From 00fb94931d7c4479e449a9b6a917d1513982555f Mon Sep 17 00:00:00 2001 From: evanlowe <62918515+evanlowe@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:13:12 +0800 Subject: [PATCH] fix(studio): use studio auth for skill browsing --- frontend/src/ui/SessionCapabilityDialogs.tsx | 26 ++++++++++--------- frontend/tests/agentInfoRail.test.mjs | 14 ++++++++-- ...tor-3xe29i9v.js => CodeEditor-DCfiHETz.js} | 2 +- ...RF.js => MarkdownPromptEditor-Di7BE6IZ.js} | 2 +- .../{index-DYW1GYEr.js => index-BFZ8iSb4.js} | 16 ++++++------ veadk/webui/index.html | 2 +- 6 files changed, 37 insertions(+), 25 deletions(-) rename veadk/webui/assets/{CodeEditor-3xe29i9v.js => CodeEditor-DCfiHETz.js} (99%) rename veadk/webui/assets/{MarkdownPromptEditor-B7SUdnRF.js => MarkdownPromptEditor-Di7BE6IZ.js} (99%) rename veadk/webui/assets/{index-DYW1GYEr.js => index-BFZ8iSb4.js} (96%) diff --git a/frontend/src/ui/SessionCapabilityDialogs.tsx b/frontend/src/ui/SessionCapabilityDialogs.tsx index 2ad5552d..9d953935 100644 --- a/frontend/src/ui/SessionCapabilityDialogs.tsx +++ b/frontend/src/ui/SessionCapabilityDialogs.tsx @@ -1,14 +1,16 @@ import { useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { createPortal } from "react-dom"; import { - listSessionSkillsInSpace, - listSessionSkillSpaces, searchSessionPublicSkills, type AddSessionCapability, type SessionPublicSkill, - type SessionSkillCatalogItem, - type SessionSkillSpace, } from "../adk/client"; +import { + listSkillsInSpace, + listSkillSpaces, + type SkillSpaceRef, + type SkillSpaceSkill, +} from "../create/skills/skillspace"; import { BUILTIN_TOOLS } from "../create/veadkCatalog"; import { ToolCapabilityIcon } from "./CapabilityIcons"; @@ -255,9 +257,9 @@ export function SkillCapabilityDialog({ const [publicTotal, setPublicTotal] = useState(0); const [publicLoading, setPublicLoading] = useState(true); const [publicError, setPublicError] = useState(""); - const [spaces, setSpaces] = useState([]); - const [selectedSpace, setSelectedSpace] = useState(null); - const [skills, setSkills] = useState([]); + const [spaces, setSpaces] = useState([]); + const [selectedSpace, setSelectedSpace] = useState(null); + const [skills, setSkills] = useState([]); const [spaceQuery, setSpaceQuery] = useState(""); const [skillQuery, setSkillQuery] = useState(""); const [spacesLoading, setSpacesLoading] = useState(true); @@ -299,7 +301,7 @@ export function SkillCapabilityDialog({ let active = true; setSpacesLoading(true); setError(""); - void listSessionSkillSpaces(appName) + void listSkillSpaces() .then((items) => { if (!active) return; setSpaces(items); @@ -312,7 +314,7 @@ export function SkillCapabilityDialog({ if (active) setSpacesLoading(false); }); return () => { active = false; }; - }, [appName, sourceTab]); + }, [sourceTab]); useEffect(() => { if (sourceTab !== "agentkit") return; @@ -323,7 +325,7 @@ export function SkillCapabilityDialog({ let active = true; setSkillsLoading(true); setError(""); - void listSessionSkillsInSpace(appName, selectedSpace.id, selectedSpace.region) + void listSkillsInSpace(selectedSpace.id, selectedSpace.region) .then((items) => { if (active) setSkills(items); }) @@ -334,7 +336,7 @@ export function SkillCapabilityDialog({ if (active) setSkillsLoading(false); }); return () => { active = false; }; - }, [appName, selectedSpace, sourceTab]); + }, [selectedSpace, sourceTab]); const filteredSpaces = useMemo(() => { const normalized = spaceQuery.trim().toLowerCase(); @@ -352,7 +354,7 @@ export function SkillCapabilityDialog({ ); }, [skillQuery, skills]); - const addSkill = async (skill: SessionSkillCatalogItem) => { + const addSkill = async (skill: SkillSpaceSkill) => { if (!selectedSpace) return; setPending(skill.skillId); const added = await onAdd({ diff --git a/frontend/tests/agentInfoRail.test.mjs b/frontend/tests/agentInfoRail.test.mjs index d2502062..d503271e 100644 --- a/frontend/tests/agentInfoRail.test.mjs +++ b/frontend/tests/agentInfoRail.test.mjs @@ -18,6 +18,10 @@ const clientSource = readFileSync( new URL("../src/adk/client.ts", import.meta.url), "utf8", ); +const skillspaceClientSource = readFileSync( + new URL("../src/create/skills/skillspace.ts", import.meta.url), + "utf8", +); const navbarSource = readFileSync( new URL("../src/ui/Navbar.tsx", import.meta.url), "utf8", @@ -235,8 +239,14 @@ test("uses searchable dialogs for public Skill Hub and AgentKit Skill Center", ( assert.match(capabilityDialogsSource, /searchSessionPublicSkills\(appName, publicQuery\.trim\(\)\)/); assert.match(capabilityDialogsSource, /skillSourceId: `findskill:\$\{skill\.slug\}`/); assert.match(clientSource, /\/harness\/skills\/findskill/); - assert.match(capabilityDialogsSource, /listSessionSkillSpaces\(appName\)/); - assert.match(capabilityDialogsSource, /listSessionSkillsInSpace\(appName, selectedSpace\.id/); + assert.match(capabilityDialogsSource, /listSkillSpaces\(\)/); + assert.match( + capabilityDialogsSource, + /listSkillsInSpace\(selectedSpace\.id, selectedSpace\.region\)/, + ); + assert.doesNotMatch(capabilityDialogsSource, /listSessionSkillSpaces/); + assert.doesNotMatch(capabilityDialogsSource, /listSessionSkillsInSpace/); + assert.match(skillspaceClientSource, /"\/web\/skill-spaces\?region=all"/); assert.match(capabilityDialogsSource, /label="搜索 Skill Space"/); assert.match(capabilityDialogsSource, /label="搜索 AgentKit 技能"/); assert.match(capabilityDialogsSource, /skillSourceId: selectedSpace\.id/); diff --git a/veadk/webui/assets/CodeEditor-3xe29i9v.js b/veadk/webui/assets/CodeEditor-DCfiHETz.js similarity index 99% rename from veadk/webui/assets/CodeEditor-3xe29i9v.js rename to veadk/webui/assets/CodeEditor-DCfiHETz.js index 7e9e445a..99161e4f 100644 --- a/veadk/webui/assets/CodeEditor-3xe29i9v.js +++ b/veadk/webui/assets/CodeEditor-DCfiHETz.js @@ -1,4 +1,4 @@ -import{A as xe,t as sf}from"./index-DYW1GYEr.js";const of=1024;let Zm=0,Le=class{constructor(e,t){this.from=e,this.to=t}};class M{constructor(e={}){this.id=Zm++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Oe.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}M.closedBy=new M({deserialize:i=>i.split(" ")});M.openedBy=new M({deserialize:i=>i.split(" ")});M.group=new M({deserialize:i=>i.split(" ")});M.isolate=new M({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});M.contextHash=new M({perNode:!0});M.lookAhead=new M({perNode:!0});M.mounted=new M({perNode:!0});class Ri{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[M.mounted.id]}}const Am=Object.create(null);class Oe{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Am,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Oe(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(M.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(M.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}Oe.none=new Oe("",Object.create(null),0,8);class Kn{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|I.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:na(Oe.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new U(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new U(Oe.none,t,n,r)))}static build(e){return zm(e)}}U.empty=new U(Oe.none,[],[],0);class ta{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ta(this.buffer,this.index)}}class It{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Oe.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function vn(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?l.length:-1;e!=h;e+=t){let c=l[e],O=a[e]+o.from,f;if(!(!(s&I.EnterBracketed&&c instanceof U&&(f=Ri.get(c))&&!f.overlay&&f.bracketed&&n>=O&&n<=O+c.length)&&!lf(r,n,O,O+c.length))){if(c instanceof It){if(s&I.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,n-O,r);if(u>-1)return new dt(new qm(o,c,e,O),null,u)}else if(s&I.IncludeAnonymous||!c.type.isAnonymous||ia(c)){let u;if(!(s&I.IgnoreMounts)&&(u=Ri.get(c))&&!u.overlay)return new Pe(u.tree,O,e,o);let d=new Pe(c,O,e,o);return s&I.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,n,r,s)}}}if(s&I.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&I.IgnoreOverlays)&&(r=Ri.get(this._tree))&&r.overlay){let s=e-this.from,o=n&I.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l=s:a>s))return new Pe(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function ch(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Go(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class qm{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class dt extends af{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new dt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&I.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new dt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new dt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new dt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new U(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hf(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let l=new Pe(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(vn(l,e,t,!1))}}return r?hf(r):n}class Ur{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~I.EnterBracketed,e instanceof Pe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Pe?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&I.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&I.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&I.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let l=n._tree.children[s];if(this.mode&I.IncludeAnonymous||l instanceof It||!l.type.isAnonymous||ia(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return Go(this._tree,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function ia(i){return i.children.some(e=>e instanceof It||!e.type.isAnonymous||ia(e))}function zm(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=of,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ta(t,t.length):t,a=n.types,h=0,c=0;function O(x,k,$,q,_,B){let{id:z,start:A,end:V,size:E}=l,G=c,oe=h;if(E<0)if(l.next(),E==-1){let me=s[z];$.push(me),q.push(A-x);return}else if(E==-3){h=z;return}else if(E==-4){c=z;return}else throw new RangeError(`Unrecognized record size: ${E}`);let fe=a[z],we,ie,pe=A-x;if(V-A<=r&&(ie=g(l.pos-k,_))){let me=new Uint16Array(ie.size-ie.skip),ve=l.pos-ie.size,Me=me.length;for(;l.pos>ve;)Me=Q(ie.start,me,Me);we=new It(me,V-ie.start,n),pe=ie.start-x}else{let me=l.pos-E;l.next();let ve=[],Me=[],H=z>=o?z:-1,Fe=0,ni=V;for(;l.pos>me;)H>=0&&l.id==H&&l.size>=0?(l.end<=ni-r&&(d(ve,Me,A,Fe,l.end,ni,H,G,oe),Fe=ve.length,ni=l.end),l.next()):B>2500?f(A,me,ve,Me):O(A,me,ve,Me,H,B+1);if(H>=0&&Fe>0&&Fe-1&&Fe>0){let ki=u(fe,oe);we=na(fe,ve,Me,0,ve.length,0,V-A,ki,ki)}else we=m(fe,ve,Me,V-A,G-V,oe)}$.push(we),q.push(pe)}function f(x,k,$,q){let _=[],B=0,z=-1;for(;l.pos>k;){let{id:A,start:V,end:E,size:G}=l;if(G>4)l.next();else{if(z>-1&&V=0;E-=3)A[G++]=_[E],A[G++]=_[E+1]-V,A[G++]=_[E+2]-V,A[G++]=G;$.push(new It(A,_[2]-V,n)),q.push(V-x)}}function u(x,k){return($,q,_)=>{let B=0,z=$.length-1,A,V;if(z>=0&&(A=$[z])instanceof U){if(!z&&A.type==x&&A.length==_)return A;(V=A.prop(M.lookAhead))&&(B=q[z]+A.length+V)}return m(x,$,q,_,B,k)}}function d(x,k,$,q,_,B,z,A,V){let E=[],G=[];for(;x.length>q;)E.push(x.pop()),G.push(k.pop()+$-_);x.push(m(n.types[z],E,G,B-_,A-B,V)),k.push(_-$)}function m(x,k,$,q,_,B,z){if(B){let A=[M.contextHash,B];z=z?[A].concat(z):[A]}if(_>25){let A=[M.lookAhead,_];z=z?[A].concat(z):[A]}return new U(x,k,$,q,z)}function g(x,k){let $=l.fork(),q=0,_=0,B=0,z=$.end-r,A={size:0,start:0,skip:0};e:for(let V=$.pos-x;$.pos>V;){let E=$.size;if($.id==k&&E>=0){A.size=q,A.start=_,A.skip=B,B+=4,q+=4,$.next();continue}let G=$.pos-E;if(E<0||G=o?4:0,fe=$.start;for($.next();$.pos>G;){if($.size<0)if($.size==-3||$.size==-4)oe+=4;else break e;else $.id>=o&&(oe+=4);$.next()}_=fe,q+=E,B+=oe}return(k<0||q==x)&&(A.size=q,A.start=_,A.skip=B),A.size>4?A:void 0}function Q(x,k,$){let{id:q,start:_,end:B,size:z}=l;if(l.next(),z>=0&&q4){let V=l.pos-(z-4);for(;l.pos>V;)$=Q(x,k,$)}k[--$]=A,k[--$]=B-x,k[--$]=_-x,k[--$]=q}else z==-3?h=q:z==-4&&(c=q);return $}let S=[],y=[];for(;l.pos>0;)O(i.start||0,i.bufferStart||0,S,y,-1,0);let w=(e=i.length)!==null&&e!==void 0?e:S.length?y[0]+S[0].length:0;return new U(a[i.topID],S.reverse(),y.reverse(),w)}const Oh=new WeakMap;function Wr(i,e){if(!i.isAnonymous||e instanceof It||e.type!=i)return 1;let t=Oh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof U)){t=1;break}t+=Wr(i,n)}Oh.set(e,t)}return t}function na(i,e,t,n,r,s,o,l,a){let h=0;for(let d=n;d=c)break;k+=$}if(y==w+1){if(k>c){let $=d[w];u($.children,$.positions,0,$.children.length,m[w]+S);continue}O.push(d[w])}else{let $=m[y-1]+d[y-1].length-x;O.push(na(i,d,m,w,y,x,$,null,a))}f.push(x+S-s)}}return u(e,t,n,r,0),(l||a)(O,f,o)}class ra{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof dt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Pe&&this.map.set(e.tree,t)}get(e){return e instanceof dt?this.getBuffer(e.context.buffer,e.index):e instanceof Pe?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Xt{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new Xt(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=n)for(;o&&o.from=f.from||O<=f.to||h){let u=Math.max(f.from,a)-h,d=Math.min(f.to,O)-h;f=u>=d?null:new Xt(u,d,f.tree,f.offset+h,l>0,!!c)}if(f&&r.push(f),o.to>O)break;o=snew Le(r.from,r.to)):[new Le(0,0)]:[new Le(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class _m{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function cf(i){return(e,t,n,r)=>new jm(e,i,t,n,r)}class fh{constructor(e,t,n,r,s,o){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=s,this.from=o}}function uh(i){if(!i.length||i.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}class Em{constructor(e,t,n,r,s,o,l,a){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Io=new M({perNode:!0});class jm{constructor(e,t,n,r,s){this.nest=t,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new U(n.type,n.children,n.positions,n.length,n.propValues.concat([[Io,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[M.mounted.id]=new Ri(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let O=c.from+h.pos,f=c.to+h.pos;O>=r.from&&f<=r.to&&!t.ranges.some(u=>u.fromO)&&t.ranges.push({from:O,to:f})}}l=!1}else if(n&&(o=Vm(n.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Le(O.from-r.from,O.to-r.from)):null,!!s.bracketed,r.tree,c.length?c[0].from:r.from)),s.overlay?c.length&&(n={ranges:c,depth:0,prev:n}):l=!1}}else if(t&&(a=t.predicate(r))&&(a===!0&&(a=new Le(r.from,r.to)),a.from=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=mh(this.ranges,t.ranges);h.length&&(uh(h),this.inner.splice(t.index,0,new fh(t.parser,t.parser.startParse(this.input,gh(t.mounts,h),h),t.ranges.map(c=>new Le(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}}function Vm(i,e,t){for(let n of i){if(n.from>=t)break;if(n.to>e)return n.from<=e&&n.to>=t?2:1}return 0}function dh(i,e,t,n,r,s){if(e=e&&t.enter(n,1,I.IgnoreOverlays|I.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof U)t=t.children[0];else break}return!1}}let Lm=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(t=n.tree.prop(Io))!==null&&t!==void 0?t:n.to,this.inner=new ph(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Io))!==null&&e!==void 0?e:t.to,this.inner=new ph(t.tree,-t.offset)}}findMounts(e,t){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(M.mounted);if(o&&o.parser==t)for(let l=this.fragI;l=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function mh(i,e){let t=null,n=e;for(let r=1,s=0;r=l)break;a.to<=o||(t||(n=t=e.slice()),a.froml&&t.splice(s+1,0,new Le(l,a.to))):a.to>l?t[s--]=new Le(l,a.to):t.splice(s--,1))}}return n}function Dm(i,e,t,n){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=r==i.length?1e9:o?i[r].to:i[r].from,O=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let f=Math.max(a,t),u=Math.min(c,O,n);fnew Le(f.from+n,f.to+n)),O=Dm(e,c,a,h);for(let f=0,u=a;;f++){let d=f==O.length,m=d?h:O[f].from;if(m>u&&t.push(new Xt(u,m,r.tree,-o,s.from>=u||s.openStart,s.to<=m||s.openEnd)),d)break;u=O[f].to}}else t.push(new Xt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}var Qh={};class Nr{constructor(e,t,n,r,s,o,l,a,h,c=0,O){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=O}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new Nr(e,[],t,n,n,0,[],0,r?new Sh(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==n)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new Nr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Bm(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sa&1&&l==o)||r.push(t[s],o)}t=r}let n=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,s+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class Sh{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Bm{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Fr{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Fr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Fr(this.stack,this.pos,this.index)}}function un(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,r=0;n=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class Mr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const bh=new Mr;class Gm{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=bh,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,s=this.pos+e;for(;sn.to:s>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nl.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=bh,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class Zi{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Of(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}Zi.prototype.contextual=Zi.prototype.fallback=Zi.prototype.extend=!1;class Hr{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?un(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Of(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}}Hr.prototype.contextual=Zi.prototype.fallback=Zi.prototype.extend=!1;class ae{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Of(i,e,t,n,r,s){let o=0,l=1<0){let d=i[u];if(a.allows(d)&&(e.token.value==-1||e.token.value==d||Im(d,e.token.value,r,s))){e.acceptToken(d);break}}let c=e.next,O=0,f=i[o+2];if(e.next<0&&f>O&&i[h+f*3-3]==65535){o=i[h+f*3-1];continue e}for(;O>1,d=h+u+(u<<1),m=i[d],g=i[d+1]||65536;if(c=g)O=u+1;else{o=i[d+2],e.advance();continue e}}break}}function yh(i,e,t){for(let n=e,r;(r=i[n])!=65535;n++)if(r==t)return n-e;return-1}function Im(i,e,t,n){let r=yh(t,n,e);return r<0||yh(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}let Um=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?xh(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?xh(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof U){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}};class Nm{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Mr)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;hO.end+25&&(a=Math.max(O.lookAhead,a)),O.value!=0)){let f=t;if(O.extended>-1&&(t=this.addActions(e,O.extended,O.end,t)),t=this.addActions(e,O.value,O.end,t),!c.extend&&(n=O,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Mr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Mr,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;se.bufferLength*4?new Um(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)n.push(l);else{if(this.advanceStack(l,n,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!n.length){let o=r&&Km(r);if(o)return ze&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ze&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(o)return ze&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&(n.sort((o,l)=>l.score-o.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let O=this.fragments.nodeAt(r);O;){let f=this.parser.nodeSet.types[O.type.id]==O.type?s.getGoto(e.state,O.type.id):-1;if(f>-1&&O.length&&(!h||(O.prop(M.contextHash)||0)==c))return e.useNode(O,f),ze&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(O.type.id)})`),!0;if(!(O instanceof U)||O.children.length==0||O.positions[0]>0)break;let u=O.children[0];if(u instanceof U&&O.positions[0]==0)O=u;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),ze&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;hr?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return kh(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),ze&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let O=l.split(),f=c;for(let u=0;u<10&&O.forceReduce()&&(ze&&console.log(f+this.stackID(O)+" (via force-reduce)"),!this.advanceFully(O,n));u++)ze&&(f=this.stackID(O)+" -> ");for(let u of l.recoverByInsert(a))ze&&console.log(c+this.stackID(u)+" (via recover-insert)"),this.advanceFully(u,n);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),ze&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),kh(l,n)):(!r||r.scorei;class Ts{constructor(e){this.start=e.start,this.shift=e.shift||Us,this.reduce=e.reduce||Us,this.reuse=e.reuse||Us,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Rt extends sa{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(c,a,l[h++]);else{let O=l[h+-c];for(let f=-c;f>0;f--)s(l[h++],a,O);h++}}}this.nodeSet=new Kn(t.map((l,a)=>Oe.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=of;let o=un(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Zi(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new Fm(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&n)return a;for(let h=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=vt(this.data,s+2);else break;r=t(vt(this.data,s+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=vt(this.data,n+2);else break;if(!(this.data[n+2]&1)){let r=this.data[n+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(Rt.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(l=>l.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=Ph(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let r=null;for(let s=0;sn)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}let Jm=0,ct=class Uo{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Jm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Uo&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new Uo(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Kr(e);return n=>n.modified.indexOf(t)>-1?n:Kr.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}},eg=0;class Kr{constructor(e){this.name=e,this.instances=[],this.id=eg++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&tg(t,l.modified));if(n)return n;let r=[],s=new ct(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=ig(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Kr.get(l,a));return s}}function tg(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function ig(i){let e=[[]];for(let t=0;tn.length-t.length)}function zt(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let O=0;;){if(l=="..."&&O>0&&O+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),O+=f[0].length,O==r.length)break;let u=r[O++];if(O==r.length&&u=="!"){o=0;break}if(u!="/")throw new RangeError("Invalid path: "+r);l=r.slice(O)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Tn(n,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return ff.add(e)}const ff=new M({combine(i,e){let t,n,r;for(;i||e;){if(!i||e&&i.depth>=e.depth?(r=e,e=e.next):(r=i,i=i.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Tn(r.tags,r.mode,r.context);t?t.next=s:n=s,t=s}return n}});class Tn{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function ng(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function rg(i,e,t,n=0,r=i.length){let s=new sg(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class sg{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(u=>!u.scope||u.scope(o)));let h=r,c=og(e)||Tn.empty,O=ng(s,c.tags);if(O&&(h&&(h+=" "),h+=O,c.mode==1&&(r+=(r?" ":"")+O)),this.startSpan(Math.max(t,l),h),c.opaque)return;let f=e.tree&&e.tree.prop(M.mounted);if(f&&f.overlay){let u=e.node.enter(f.overlay[0].from+l,1),d=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,Q=l;;g++){let S=g=y||!e.nextSibling())););if(!S||y>n)break;Q=S.to+l,Q>t&&(this.highlightRange(u.cursor(),Math.max(t,S.from+l),Math.min(n,Q),"",d),this.startSpan(Math.min(n,Q),h))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}}function og(i){let e=i.type.prop(ff);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const T=ct.define,cr=T(),Vt=T(),$h=T(Vt),wh=T(Vt),Yt=T(),Or=T(Yt),Ns=T(Yt),ht=T(),oi=T(ht),ot=T(),lt=T(),No=T(),sn=T(No),fr=T(),p={comment:cr,lineComment:T(cr),blockComment:T(cr),docComment:T(cr),name:Vt,variableName:T(Vt),typeName:$h,tagName:T($h),propertyName:wh,attributeName:T(wh),className:T(Vt),labelName:T(Vt),namespace:T(Vt),macroName:T(Vt),literal:Yt,string:Or,docString:T(Or),character:T(Or),attributeValue:T(Or),number:Ns,integer:T(Ns),float:T(Ns),bool:T(Yt),regexp:T(Yt),escape:T(Yt),color:T(Yt),url:T(Yt),keyword:ot,self:T(ot),null:T(ot),atom:T(ot),unit:T(ot),modifier:T(ot),operatorKeyword:T(ot),controlKeyword:T(ot),definitionKeyword:T(ot),moduleKeyword:T(ot),operator:lt,derefOperator:T(lt),arithmeticOperator:T(lt),logicOperator:T(lt),bitwiseOperator:T(lt),compareOperator:T(lt),updateOperator:T(lt),definitionOperator:T(lt),typeOperator:T(lt),controlOperator:T(lt),punctuation:No,separator:T(No),bracket:sn,angleBracket:T(sn),squareBracket:T(sn),paren:T(sn),brace:T(sn),content:ht,heading:oi,heading1:T(oi),heading2:T(oi),heading3:T(oi),heading4:T(oi),heading5:T(oi),heading6:T(oi),contentSeparator:T(ht),list:T(ht),quote:T(ht),emphasis:T(ht),strong:T(ht),link:T(ht),monospace:T(ht),strikethrough:T(ht),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:fr,documentMeta:T(fr),annotation:T(fr),processingInstruction:T(fr),definition:ct.defineModifier("definition"),constant:ct.defineModifier("constant"),function:ct.defineModifier("function"),standard:ct.defineModifier("standard"),local:ct.defineModifier("local"),special:ct.defineModifier("special")};for(let i in p){let e=p[i];e instanceof ct&&(e.name=i)}uf([{tag:p.link,class:"tok-link"},{tag:p.heading,class:"tok-heading"},{tag:p.emphasis,class:"tok-emphasis"},{tag:p.strong,class:"tok-strong"},{tag:p.keyword,class:"tok-keyword"},{tag:p.atom,class:"tok-atom"},{tag:p.bool,class:"tok-bool"},{tag:p.url,class:"tok-url"},{tag:p.labelName,class:"tok-labelName"},{tag:p.inserted,class:"tok-inserted"},{tag:p.deleted,class:"tok-deleted"},{tag:p.literal,class:"tok-literal"},{tag:p.string,class:"tok-string"},{tag:p.number,class:"tok-number"},{tag:[p.regexp,p.escape,p.special(p.string)],class:"tok-string2"},{tag:p.variableName,class:"tok-variableName"},{tag:p.local(p.variableName),class:"tok-variableName tok-local"},{tag:p.definition(p.variableName),class:"tok-variableName tok-definition"},{tag:p.special(p.variableName),class:"tok-variableName2"},{tag:p.definition(p.propertyName),class:"tok-propertyName tok-definition"},{tag:p.typeName,class:"tok-typeName"},{tag:p.namespace,class:"tok-namespace"},{tag:p.className,class:"tok-className"},{tag:p.macroName,class:"tok-macroName"},{tag:p.propertyName,class:"tok-propertyName"},{tag:p.operator,class:"tok-operator"},{tag:p.comment,class:"tok-comment"},{tag:p.meta,class:"tok-meta"},{tag:p.invalid,class:"tok-invalid"},{tag:p.punctuation,class:"tok-punctuation"}]);const lg=316,ag=317,vh=1,hg=2,cg=3,Og=4,fg=318,ug=320,dg=321,pg=5,mg=6,gg=0,Fo=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],df=125,Qg=59,Ho=47,Sg=42,bg=43,yg=45,xg=60,kg=44,Pg=63,$g=46,wg=91,vg=new Ts({start:!1,shift(i,e){return e==pg||e==mg||e==ug?i:e==dg},strict:!1}),Tg=new ae((i,e)=>{let{next:t}=i;(t==df||t==-1||e.context)&&i.acceptToken(fg)},{contextual:!0,fallback:!0}),Xg=new ae((i,e)=>{let{next:t}=i,n;Fo.indexOf(t)>-1||t==Ho&&((n=i.peek(1))==Ho||n==Sg)||t!=df&&t!=Qg&&t!=-1&&!e.context&&i.acceptToken(lg)},{contextual:!0}),Cg=new ae((i,e)=>{i.next==wg&&!e.context&&i.acceptToken(ag)},{contextual:!0}),Rg=new ae((i,e)=>{let{next:t}=i;if(t==bg||t==yg){if(i.advance(),t==i.next){i.advance();let n=!e.context&&e.canShift(vh);i.acceptToken(n?vh:hg)}}else t==Pg&&i.peek(1)==$g&&(i.advance(),i.advance(),(i.next<48||i.next>57)&&i.acceptToken(cg))},{contextual:!0});function Fs(i,e){return i>=65&&i<=90||i>=97&&i<=122||i==95||i>=192||!e&&i>=48&&i<=57}const Zg=new ae((i,e)=>{if(i.next!=xg||!e.dialectEnabled(gg)||(i.advance(),i.next==Ho))return;let t=0;for(;Fo.indexOf(i.next)>-1;)i.advance(),t++;if(Fs(i.next,!0)){for(i.advance(),t++;Fs(i.next,!1);)i.advance(),t++;for(;Fo.indexOf(i.next)>-1;)i.advance(),t++;if(i.next==kg)return;for(let n=0;;n++){if(n==7){if(!Fs(i.next,!0))return;break}if(i.next!="extends".charCodeAt(n))break;i.advance(),t++}}i.acceptToken(Og,-t)}),Ag=zt({"get set async static":p.modifier,"for while do if else switch try catch finally return throw break continue default case defer":p.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":p.operatorKeyword,"let var const using function class extends":p.definitionKeyword,"import export from":p.moduleKeyword,"with debugger new":p.keyword,TemplateString:p.special(p.string),super:p.atom,BooleanLiteral:p.bool,this:p.self,null:p.null,Star:p.modifier,VariableName:p.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":p.function(p.variableName),VariableDefinition:p.definition(p.variableName),Label:p.labelName,PropertyName:p.propertyName,PrivatePropertyName:p.special(p.propertyName),"CallExpression/MemberExpression/PropertyName":p.function(p.propertyName),"FunctionDeclaration/VariableDefinition":p.function(p.definition(p.variableName)),"ClassDeclaration/VariableDefinition":p.definition(p.className),"NewExpression/VariableName":p.className,PropertyDefinition:p.definition(p.propertyName),PrivatePropertyDefinition:p.definition(p.special(p.propertyName)),UpdateOp:p.updateOperator,"LineComment Hashbang":p.lineComment,BlockComment:p.blockComment,Number:p.number,String:p.string,Escape:p.escape,ArithOp:p.arithmeticOperator,LogicOp:p.logicOperator,BitOp:p.bitwiseOperator,CompareOp:p.compareOperator,RegExp:p.regexp,Equals:p.definitionOperator,Arrow:p.function(p.punctuation),": Spread":p.punctuation,"( )":p.paren,"[ ]":p.squareBracket,"{ }":p.brace,"InterpolationStart InterpolationEnd":p.special(p.brace),".":p.derefOperator,", ;":p.separator,"@":p.meta,TypeName:p.typeName,TypeDefinition:p.definition(p.typeName),"type enum interface implements namespace module declare":p.definitionKeyword,"abstract global Privacy readonly override":p.modifier,"is keyof unique infer asserts":p.operatorKeyword,JSXAttributeValue:p.attributeValue,JSXText:p.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":p.angleBracket,"JSXIdentifier JSXNameSpacedName":p.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":p.attributeName,"JSXBuiltin/JSXIdentifier":p.standard(p.tagName)}),qg={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Wg={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},Mg={__proto__:null,"<":193},zg=Rt.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:vg,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[Ag],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[Xg,Cg,Rg,Zg,2,3,4,5,6,7,8,9,10,11,12,13,14,Tg,new Hr("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Hr("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:i=>qg[i]||-1},{term:343,get:i=>Wg[i]||-1},{term:95,get:i=>Mg[i]||-1}],tokenPrec:15201});let Ko=[],pf=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(i=pf[n])e=n+1;else return!0;if(e==t)return!1}}function Th(i){return i>=127462&&i<=127487}const Xh=8205;function Eg(i,e,t=!0,n=!0){return(t?mf:jg)(i,e,n)}function mf(i,e,t){if(e==i.length)return e;e&&gf(i.charCodeAt(e))&&Qf(i.charCodeAt(e-1))&&e--;let n=Hs(i,e);for(e+=Ch(n);e=0&&Th(Hs(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function jg(i,e,t){for(;e>1;){let n=mf(i,e-2,t);if(n=56320&&i<57344}function Qf(i){return i>=55296&&i<56320}function Ch(i){return i<65536?1:2}class D{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vi(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Ot.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vi(this,e,t);let n=[];return this.decompose(e,t,n,0),Ot.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new gn(this),s=new gn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new gn(this,e)}iterRange(e,t=this.length){return new Sf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?D.empty:e.length<=32?new le(e):Ot.from(le.split(e,[]))}}class le extends D{constructor(e,t=Vg(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?n:l)>=e)return new Yg(r,l,n,o);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new le(Rh(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=zr(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new le(l,o.length+s.length));else{let a=l.length>>1;n.push(new le(l.slice(0,a)),new le(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof le))return super.replace(e,t,n);[e,t]=Vi(this,e,t);let r=zr(this.text,zr(n.text,Rh(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new le(r,s):Ot.from(le.split(r,[]),s)}sliceString(e,t=this.length,n=` +import{A as xe,t as sf}from"./index-BFZ8iSb4.js";const of=1024;let Zm=0,Le=class{constructor(e,t){this.from=e,this.to=t}};class M{constructor(e={}){this.id=Zm++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Oe.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}M.closedBy=new M({deserialize:i=>i.split(" ")});M.openedBy=new M({deserialize:i=>i.split(" ")});M.group=new M({deserialize:i=>i.split(" ")});M.isolate=new M({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});M.contextHash=new M({perNode:!0});M.lookAhead=new M({perNode:!0});M.mounted=new M({perNode:!0});class Ri{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[M.mounted.id]}}const Am=Object.create(null);class Oe{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Am,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Oe(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(M.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(M.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}Oe.none=new Oe("",Object.create(null),0,8);class Kn{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|I.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:na(Oe.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new U(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new U(Oe.none,t,n,r)))}static build(e){return zm(e)}}U.empty=new U(Oe.none,[],[],0);class ta{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ta(this.buffer,this.index)}}class It{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Oe.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function vn(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?l.length:-1;e!=h;e+=t){let c=l[e],O=a[e]+o.from,f;if(!(!(s&I.EnterBracketed&&c instanceof U&&(f=Ri.get(c))&&!f.overlay&&f.bracketed&&n>=O&&n<=O+c.length)&&!lf(r,n,O,O+c.length))){if(c instanceof It){if(s&I.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,n-O,r);if(u>-1)return new dt(new qm(o,c,e,O),null,u)}else if(s&I.IncludeAnonymous||!c.type.isAnonymous||ia(c)){let u;if(!(s&I.IgnoreMounts)&&(u=Ri.get(c))&&!u.overlay)return new Pe(u.tree,O,e,o);let d=new Pe(c,O,e,o);return s&I.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,n,r,s)}}}if(s&I.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&I.IgnoreOverlays)&&(r=Ri.get(this._tree))&&r.overlay){let s=e-this.from,o=n&I.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l=s:a>s))return new Pe(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function ch(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Go(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class qm{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class dt extends af{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new dt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&I.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new dt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new dt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new dt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new U(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hf(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let l=new Pe(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(vn(l,e,t,!1))}}return r?hf(r):n}class Ur{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~I.EnterBracketed,e instanceof Pe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Pe?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&I.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&I.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&I.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let l=n._tree.children[s];if(this.mode&I.IncludeAnonymous||l instanceof It||!l.type.isAnonymous||ia(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return Go(this._tree,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function ia(i){return i.children.some(e=>e instanceof It||!e.type.isAnonymous||ia(e))}function zm(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=of,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ta(t,t.length):t,a=n.types,h=0,c=0;function O(x,k,$,q,_,B){let{id:z,start:A,end:V,size:E}=l,G=c,oe=h;if(E<0)if(l.next(),E==-1){let me=s[z];$.push(me),q.push(A-x);return}else if(E==-3){h=z;return}else if(E==-4){c=z;return}else throw new RangeError(`Unrecognized record size: ${E}`);let fe=a[z],we,ie,pe=A-x;if(V-A<=r&&(ie=g(l.pos-k,_))){let me=new Uint16Array(ie.size-ie.skip),ve=l.pos-ie.size,Me=me.length;for(;l.pos>ve;)Me=Q(ie.start,me,Me);we=new It(me,V-ie.start,n),pe=ie.start-x}else{let me=l.pos-E;l.next();let ve=[],Me=[],H=z>=o?z:-1,Fe=0,ni=V;for(;l.pos>me;)H>=0&&l.id==H&&l.size>=0?(l.end<=ni-r&&(d(ve,Me,A,Fe,l.end,ni,H,G,oe),Fe=ve.length,ni=l.end),l.next()):B>2500?f(A,me,ve,Me):O(A,me,ve,Me,H,B+1);if(H>=0&&Fe>0&&Fe-1&&Fe>0){let ki=u(fe,oe);we=na(fe,ve,Me,0,ve.length,0,V-A,ki,ki)}else we=m(fe,ve,Me,V-A,G-V,oe)}$.push(we),q.push(pe)}function f(x,k,$,q){let _=[],B=0,z=-1;for(;l.pos>k;){let{id:A,start:V,end:E,size:G}=l;if(G>4)l.next();else{if(z>-1&&V=0;E-=3)A[G++]=_[E],A[G++]=_[E+1]-V,A[G++]=_[E+2]-V,A[G++]=G;$.push(new It(A,_[2]-V,n)),q.push(V-x)}}function u(x,k){return($,q,_)=>{let B=0,z=$.length-1,A,V;if(z>=0&&(A=$[z])instanceof U){if(!z&&A.type==x&&A.length==_)return A;(V=A.prop(M.lookAhead))&&(B=q[z]+A.length+V)}return m(x,$,q,_,B,k)}}function d(x,k,$,q,_,B,z,A,V){let E=[],G=[];for(;x.length>q;)E.push(x.pop()),G.push(k.pop()+$-_);x.push(m(n.types[z],E,G,B-_,A-B,V)),k.push(_-$)}function m(x,k,$,q,_,B,z){if(B){let A=[M.contextHash,B];z=z?[A].concat(z):[A]}if(_>25){let A=[M.lookAhead,_];z=z?[A].concat(z):[A]}return new U(x,k,$,q,z)}function g(x,k){let $=l.fork(),q=0,_=0,B=0,z=$.end-r,A={size:0,start:0,skip:0};e:for(let V=$.pos-x;$.pos>V;){let E=$.size;if($.id==k&&E>=0){A.size=q,A.start=_,A.skip=B,B+=4,q+=4,$.next();continue}let G=$.pos-E;if(E<0||G=o?4:0,fe=$.start;for($.next();$.pos>G;){if($.size<0)if($.size==-3||$.size==-4)oe+=4;else break e;else $.id>=o&&(oe+=4);$.next()}_=fe,q+=E,B+=oe}return(k<0||q==x)&&(A.size=q,A.start=_,A.skip=B),A.size>4?A:void 0}function Q(x,k,$){let{id:q,start:_,end:B,size:z}=l;if(l.next(),z>=0&&q4){let V=l.pos-(z-4);for(;l.pos>V;)$=Q(x,k,$)}k[--$]=A,k[--$]=B-x,k[--$]=_-x,k[--$]=q}else z==-3?h=q:z==-4&&(c=q);return $}let S=[],y=[];for(;l.pos>0;)O(i.start||0,i.bufferStart||0,S,y,-1,0);let w=(e=i.length)!==null&&e!==void 0?e:S.length?y[0]+S[0].length:0;return new U(a[i.topID],S.reverse(),y.reverse(),w)}const Oh=new WeakMap;function Wr(i,e){if(!i.isAnonymous||e instanceof It||e.type!=i)return 1;let t=Oh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof U)){t=1;break}t+=Wr(i,n)}Oh.set(e,t)}return t}function na(i,e,t,n,r,s,o,l,a){let h=0;for(let d=n;d=c)break;k+=$}if(y==w+1){if(k>c){let $=d[w];u($.children,$.positions,0,$.children.length,m[w]+S);continue}O.push(d[w])}else{let $=m[y-1]+d[y-1].length-x;O.push(na(i,d,m,w,y,x,$,null,a))}f.push(x+S-s)}}return u(e,t,n,r,0),(l||a)(O,f,o)}class ra{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof dt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Pe&&this.map.set(e.tree,t)}get(e){return e instanceof dt?this.getBuffer(e.context.buffer,e.index):e instanceof Pe?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Xt{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new Xt(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=n)for(;o&&o.from=f.from||O<=f.to||h){let u=Math.max(f.from,a)-h,d=Math.min(f.to,O)-h;f=u>=d?null:new Xt(u,d,f.tree,f.offset+h,l>0,!!c)}if(f&&r.push(f),o.to>O)break;o=snew Le(r.from,r.to)):[new Le(0,0)]:[new Le(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class _m{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function cf(i){return(e,t,n,r)=>new jm(e,i,t,n,r)}class fh{constructor(e,t,n,r,s,o){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=s,this.from=o}}function uh(i){if(!i.length||i.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}class Em{constructor(e,t,n,r,s,o,l,a){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Io=new M({perNode:!0});class jm{constructor(e,t,n,r,s){this.nest=t,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new U(n.type,n.children,n.positions,n.length,n.propValues.concat([[Io,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[M.mounted.id]=new Ri(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let O=c.from+h.pos,f=c.to+h.pos;O>=r.from&&f<=r.to&&!t.ranges.some(u=>u.fromO)&&t.ranges.push({from:O,to:f})}}l=!1}else if(n&&(o=Vm(n.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Le(O.from-r.from,O.to-r.from)):null,!!s.bracketed,r.tree,c.length?c[0].from:r.from)),s.overlay?c.length&&(n={ranges:c,depth:0,prev:n}):l=!1}}else if(t&&(a=t.predicate(r))&&(a===!0&&(a=new Le(r.from,r.to)),a.from=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=mh(this.ranges,t.ranges);h.length&&(uh(h),this.inner.splice(t.index,0,new fh(t.parser,t.parser.startParse(this.input,gh(t.mounts,h),h),t.ranges.map(c=>new Le(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}}function Vm(i,e,t){for(let n of i){if(n.from>=t)break;if(n.to>e)return n.from<=e&&n.to>=t?2:1}return 0}function dh(i,e,t,n,r,s){if(e=e&&t.enter(n,1,I.IgnoreOverlays|I.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof U)t=t.children[0];else break}return!1}}let Lm=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(t=n.tree.prop(Io))!==null&&t!==void 0?t:n.to,this.inner=new ph(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Io))!==null&&e!==void 0?e:t.to,this.inner=new ph(t.tree,-t.offset)}}findMounts(e,t){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(M.mounted);if(o&&o.parser==t)for(let l=this.fragI;l=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function mh(i,e){let t=null,n=e;for(let r=1,s=0;r=l)break;a.to<=o||(t||(n=t=e.slice()),a.froml&&t.splice(s+1,0,new Le(l,a.to))):a.to>l?t[s--]=new Le(l,a.to):t.splice(s--,1))}}return n}function Dm(i,e,t,n){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=r==i.length?1e9:o?i[r].to:i[r].from,O=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let f=Math.max(a,t),u=Math.min(c,O,n);fnew Le(f.from+n,f.to+n)),O=Dm(e,c,a,h);for(let f=0,u=a;;f++){let d=f==O.length,m=d?h:O[f].from;if(m>u&&t.push(new Xt(u,m,r.tree,-o,s.from>=u||s.openStart,s.to<=m||s.openEnd)),d)break;u=O[f].to}}else t.push(new Xt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}var Qh={};class Nr{constructor(e,t,n,r,s,o,l,a,h,c=0,O){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=O}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new Nr(e,[],t,n,n,0,[],0,r?new Sh(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==n)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new Nr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Bm(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sa&1&&l==o)||r.push(t[s],o)}t=r}let n=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,s+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class Sh{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Bm{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Fr{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Fr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Fr(this.stack,this.pos,this.index)}}function un(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,r=0;n=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class Mr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const bh=new Mr;class Gm{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=bh,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,s=this.pos+e;for(;sn.to:s>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nl.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=bh,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class Zi{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Of(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}Zi.prototype.contextual=Zi.prototype.fallback=Zi.prototype.extend=!1;class Hr{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?un(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Of(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}}Hr.prototype.contextual=Zi.prototype.fallback=Zi.prototype.extend=!1;class ae{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Of(i,e,t,n,r,s){let o=0,l=1<0){let d=i[u];if(a.allows(d)&&(e.token.value==-1||e.token.value==d||Im(d,e.token.value,r,s))){e.acceptToken(d);break}}let c=e.next,O=0,f=i[o+2];if(e.next<0&&f>O&&i[h+f*3-3]==65535){o=i[h+f*3-1];continue e}for(;O>1,d=h+u+(u<<1),m=i[d],g=i[d+1]||65536;if(c=g)O=u+1;else{o=i[d+2],e.advance();continue e}}break}}function yh(i,e,t){for(let n=e,r;(r=i[n])!=65535;n++)if(r==t)return n-e;return-1}function Im(i,e,t,n){let r=yh(t,n,e);return r<0||yh(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}let Um=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?xh(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?xh(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof U){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}};class Nm{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Mr)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;hO.end+25&&(a=Math.max(O.lookAhead,a)),O.value!=0)){let f=t;if(O.extended>-1&&(t=this.addActions(e,O.extended,O.end,t)),t=this.addActions(e,O.value,O.end,t),!c.extend&&(n=O,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Mr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Mr,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;se.bufferLength*4?new Um(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)n.push(l);else{if(this.advanceStack(l,n,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!n.length){let o=r&&Km(r);if(o)return ze&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ze&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(o)return ze&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&(n.sort((o,l)=>l.score-o.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let O=this.fragments.nodeAt(r);O;){let f=this.parser.nodeSet.types[O.type.id]==O.type?s.getGoto(e.state,O.type.id):-1;if(f>-1&&O.length&&(!h||(O.prop(M.contextHash)||0)==c))return e.useNode(O,f),ze&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(O.type.id)})`),!0;if(!(O instanceof U)||O.children.length==0||O.positions[0]>0)break;let u=O.children[0];if(u instanceof U&&O.positions[0]==0)O=u;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),ze&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;hr?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return kh(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),ze&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let O=l.split(),f=c;for(let u=0;u<10&&O.forceReduce()&&(ze&&console.log(f+this.stackID(O)+" (via force-reduce)"),!this.advanceFully(O,n));u++)ze&&(f=this.stackID(O)+" -> ");for(let u of l.recoverByInsert(a))ze&&console.log(c+this.stackID(u)+" (via recover-insert)"),this.advanceFully(u,n);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),ze&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),kh(l,n)):(!r||r.scorei;class Ts{constructor(e){this.start=e.start,this.shift=e.shift||Us,this.reduce=e.reduce||Us,this.reuse=e.reuse||Us,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Rt extends sa{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(c,a,l[h++]);else{let O=l[h+-c];for(let f=-c;f>0;f--)s(l[h++],a,O);h++}}}this.nodeSet=new Kn(t.map((l,a)=>Oe.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=of;let o=un(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Zi(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new Fm(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&n)return a;for(let h=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=vt(this.data,s+2);else break;r=t(vt(this.data,s+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=vt(this.data,n+2);else break;if(!(this.data[n+2]&1)){let r=this.data[n+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(Rt.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(l=>l.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=Ph(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let r=null;for(let s=0;sn)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}let Jm=0,ct=class Uo{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Jm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Uo&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new Uo(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Kr(e);return n=>n.modified.indexOf(t)>-1?n:Kr.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}},eg=0;class Kr{constructor(e){this.name=e,this.instances=[],this.id=eg++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&tg(t,l.modified));if(n)return n;let r=[],s=new ct(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=ig(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Kr.get(l,a));return s}}function tg(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function ig(i){let e=[[]];for(let t=0;tn.length-t.length)}function zt(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let O=0;;){if(l=="..."&&O>0&&O+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),O+=f[0].length,O==r.length)break;let u=r[O++];if(O==r.length&&u=="!"){o=0;break}if(u!="/")throw new RangeError("Invalid path: "+r);l=r.slice(O)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Tn(n,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return ff.add(e)}const ff=new M({combine(i,e){let t,n,r;for(;i||e;){if(!i||e&&i.depth>=e.depth?(r=e,e=e.next):(r=i,i=i.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Tn(r.tags,r.mode,r.context);t?t.next=s:n=s,t=s}return n}});class Tn{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function ng(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function rg(i,e,t,n=0,r=i.length){let s=new sg(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class sg{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(u=>!u.scope||u.scope(o)));let h=r,c=og(e)||Tn.empty,O=ng(s,c.tags);if(O&&(h&&(h+=" "),h+=O,c.mode==1&&(r+=(r?" ":"")+O)),this.startSpan(Math.max(t,l),h),c.opaque)return;let f=e.tree&&e.tree.prop(M.mounted);if(f&&f.overlay){let u=e.node.enter(f.overlay[0].from+l,1),d=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,Q=l;;g++){let S=g=y||!e.nextSibling())););if(!S||y>n)break;Q=S.to+l,Q>t&&(this.highlightRange(u.cursor(),Math.max(t,S.from+l),Math.min(n,Q),"",d),this.startSpan(Math.min(n,Q),h))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}}function og(i){let e=i.type.prop(ff);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const T=ct.define,cr=T(),Vt=T(),$h=T(Vt),wh=T(Vt),Yt=T(),Or=T(Yt),Ns=T(Yt),ht=T(),oi=T(ht),ot=T(),lt=T(),No=T(),sn=T(No),fr=T(),p={comment:cr,lineComment:T(cr),blockComment:T(cr),docComment:T(cr),name:Vt,variableName:T(Vt),typeName:$h,tagName:T($h),propertyName:wh,attributeName:T(wh),className:T(Vt),labelName:T(Vt),namespace:T(Vt),macroName:T(Vt),literal:Yt,string:Or,docString:T(Or),character:T(Or),attributeValue:T(Or),number:Ns,integer:T(Ns),float:T(Ns),bool:T(Yt),regexp:T(Yt),escape:T(Yt),color:T(Yt),url:T(Yt),keyword:ot,self:T(ot),null:T(ot),atom:T(ot),unit:T(ot),modifier:T(ot),operatorKeyword:T(ot),controlKeyword:T(ot),definitionKeyword:T(ot),moduleKeyword:T(ot),operator:lt,derefOperator:T(lt),arithmeticOperator:T(lt),logicOperator:T(lt),bitwiseOperator:T(lt),compareOperator:T(lt),updateOperator:T(lt),definitionOperator:T(lt),typeOperator:T(lt),controlOperator:T(lt),punctuation:No,separator:T(No),bracket:sn,angleBracket:T(sn),squareBracket:T(sn),paren:T(sn),brace:T(sn),content:ht,heading:oi,heading1:T(oi),heading2:T(oi),heading3:T(oi),heading4:T(oi),heading5:T(oi),heading6:T(oi),contentSeparator:T(ht),list:T(ht),quote:T(ht),emphasis:T(ht),strong:T(ht),link:T(ht),monospace:T(ht),strikethrough:T(ht),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:fr,documentMeta:T(fr),annotation:T(fr),processingInstruction:T(fr),definition:ct.defineModifier("definition"),constant:ct.defineModifier("constant"),function:ct.defineModifier("function"),standard:ct.defineModifier("standard"),local:ct.defineModifier("local"),special:ct.defineModifier("special")};for(let i in p){let e=p[i];e instanceof ct&&(e.name=i)}uf([{tag:p.link,class:"tok-link"},{tag:p.heading,class:"tok-heading"},{tag:p.emphasis,class:"tok-emphasis"},{tag:p.strong,class:"tok-strong"},{tag:p.keyword,class:"tok-keyword"},{tag:p.atom,class:"tok-atom"},{tag:p.bool,class:"tok-bool"},{tag:p.url,class:"tok-url"},{tag:p.labelName,class:"tok-labelName"},{tag:p.inserted,class:"tok-inserted"},{tag:p.deleted,class:"tok-deleted"},{tag:p.literal,class:"tok-literal"},{tag:p.string,class:"tok-string"},{tag:p.number,class:"tok-number"},{tag:[p.regexp,p.escape,p.special(p.string)],class:"tok-string2"},{tag:p.variableName,class:"tok-variableName"},{tag:p.local(p.variableName),class:"tok-variableName tok-local"},{tag:p.definition(p.variableName),class:"tok-variableName tok-definition"},{tag:p.special(p.variableName),class:"tok-variableName2"},{tag:p.definition(p.propertyName),class:"tok-propertyName tok-definition"},{tag:p.typeName,class:"tok-typeName"},{tag:p.namespace,class:"tok-namespace"},{tag:p.className,class:"tok-className"},{tag:p.macroName,class:"tok-macroName"},{tag:p.propertyName,class:"tok-propertyName"},{tag:p.operator,class:"tok-operator"},{tag:p.comment,class:"tok-comment"},{tag:p.meta,class:"tok-meta"},{tag:p.invalid,class:"tok-invalid"},{tag:p.punctuation,class:"tok-punctuation"}]);const lg=316,ag=317,vh=1,hg=2,cg=3,Og=4,fg=318,ug=320,dg=321,pg=5,mg=6,gg=0,Fo=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],df=125,Qg=59,Ho=47,Sg=42,bg=43,yg=45,xg=60,kg=44,Pg=63,$g=46,wg=91,vg=new Ts({start:!1,shift(i,e){return e==pg||e==mg||e==ug?i:e==dg},strict:!1}),Tg=new ae((i,e)=>{let{next:t}=i;(t==df||t==-1||e.context)&&i.acceptToken(fg)},{contextual:!0,fallback:!0}),Xg=new ae((i,e)=>{let{next:t}=i,n;Fo.indexOf(t)>-1||t==Ho&&((n=i.peek(1))==Ho||n==Sg)||t!=df&&t!=Qg&&t!=-1&&!e.context&&i.acceptToken(lg)},{contextual:!0}),Cg=new ae((i,e)=>{i.next==wg&&!e.context&&i.acceptToken(ag)},{contextual:!0}),Rg=new ae((i,e)=>{let{next:t}=i;if(t==bg||t==yg){if(i.advance(),t==i.next){i.advance();let n=!e.context&&e.canShift(vh);i.acceptToken(n?vh:hg)}}else t==Pg&&i.peek(1)==$g&&(i.advance(),i.advance(),(i.next<48||i.next>57)&&i.acceptToken(cg))},{contextual:!0});function Fs(i,e){return i>=65&&i<=90||i>=97&&i<=122||i==95||i>=192||!e&&i>=48&&i<=57}const Zg=new ae((i,e)=>{if(i.next!=xg||!e.dialectEnabled(gg)||(i.advance(),i.next==Ho))return;let t=0;for(;Fo.indexOf(i.next)>-1;)i.advance(),t++;if(Fs(i.next,!0)){for(i.advance(),t++;Fs(i.next,!1);)i.advance(),t++;for(;Fo.indexOf(i.next)>-1;)i.advance(),t++;if(i.next==kg)return;for(let n=0;;n++){if(n==7){if(!Fs(i.next,!0))return;break}if(i.next!="extends".charCodeAt(n))break;i.advance(),t++}}i.acceptToken(Og,-t)}),Ag=zt({"get set async static":p.modifier,"for while do if else switch try catch finally return throw break continue default case defer":p.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":p.operatorKeyword,"let var const using function class extends":p.definitionKeyword,"import export from":p.moduleKeyword,"with debugger new":p.keyword,TemplateString:p.special(p.string),super:p.atom,BooleanLiteral:p.bool,this:p.self,null:p.null,Star:p.modifier,VariableName:p.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":p.function(p.variableName),VariableDefinition:p.definition(p.variableName),Label:p.labelName,PropertyName:p.propertyName,PrivatePropertyName:p.special(p.propertyName),"CallExpression/MemberExpression/PropertyName":p.function(p.propertyName),"FunctionDeclaration/VariableDefinition":p.function(p.definition(p.variableName)),"ClassDeclaration/VariableDefinition":p.definition(p.className),"NewExpression/VariableName":p.className,PropertyDefinition:p.definition(p.propertyName),PrivatePropertyDefinition:p.definition(p.special(p.propertyName)),UpdateOp:p.updateOperator,"LineComment Hashbang":p.lineComment,BlockComment:p.blockComment,Number:p.number,String:p.string,Escape:p.escape,ArithOp:p.arithmeticOperator,LogicOp:p.logicOperator,BitOp:p.bitwiseOperator,CompareOp:p.compareOperator,RegExp:p.regexp,Equals:p.definitionOperator,Arrow:p.function(p.punctuation),": Spread":p.punctuation,"( )":p.paren,"[ ]":p.squareBracket,"{ }":p.brace,"InterpolationStart InterpolationEnd":p.special(p.brace),".":p.derefOperator,", ;":p.separator,"@":p.meta,TypeName:p.typeName,TypeDefinition:p.definition(p.typeName),"type enum interface implements namespace module declare":p.definitionKeyword,"abstract global Privacy readonly override":p.modifier,"is keyof unique infer asserts":p.operatorKeyword,JSXAttributeValue:p.attributeValue,JSXText:p.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":p.angleBracket,"JSXIdentifier JSXNameSpacedName":p.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":p.attributeName,"JSXBuiltin/JSXIdentifier":p.standard(p.tagName)}),qg={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Wg={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},Mg={__proto__:null,"<":193},zg=Rt.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:vg,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[Ag],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[Xg,Cg,Rg,Zg,2,3,4,5,6,7,8,9,10,11,12,13,14,Tg,new Hr("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Hr("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:i=>qg[i]||-1},{term:343,get:i=>Wg[i]||-1},{term:95,get:i=>Mg[i]||-1}],tokenPrec:15201});let Ko=[],pf=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(i=pf[n])e=n+1;else return!0;if(e==t)return!1}}function Th(i){return i>=127462&&i<=127487}const Xh=8205;function Eg(i,e,t=!0,n=!0){return(t?mf:jg)(i,e,n)}function mf(i,e,t){if(e==i.length)return e;e&&gf(i.charCodeAt(e))&&Qf(i.charCodeAt(e-1))&&e--;let n=Hs(i,e);for(e+=Ch(n);e=0&&Th(Hs(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function jg(i,e,t){for(;e>1;){let n=mf(i,e-2,t);if(n=56320&&i<57344}function Qf(i){return i>=55296&&i<56320}function Ch(i){return i<65536?1:2}class D{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vi(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Ot.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vi(this,e,t);let n=[];return this.decompose(e,t,n,0),Ot.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new gn(this),s=new gn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new gn(this,e)}iterRange(e,t=this.length){return new Sf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?D.empty:e.length<=32?new le(e):Ot.from(le.split(e,[]))}}class le extends D{constructor(e,t=Vg(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?n:l)>=e)return new Yg(r,l,n,o);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new le(Rh(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=zr(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new le(l,o.length+s.length));else{let a=l.length>>1;n.push(new le(l.slice(0,a)),new le(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof le))return super.replace(e,t,n);[e,t]=Vi(this,e,t);let r=zr(this.text,zr(n.text,Rh(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new le(r,s):Ot.from(le.split(r,[]),s)}sliceString(e,t=this.length,n=` `){[e,t]=Vi(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new le(n,r)),n=[],r=-1);return r>-1&&t.push(new le(n,r)),t}}class Ot extends D{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,r);r=l+1,n=a+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?n.push(l):l.decompose(e-o,t-o,n,h)}o=a+1}}replace(e,t,n){if([e,t]=Vi(this,e,t),n.lines=s&&t<=l){let a=o.replace(e-s,t-s,n),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new Ot(c,this.length-(t-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` `){[e,t]=Vi(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=n),eo&&(r+=l.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ot))return 0;let n=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let u of e)n+=u.lines;if(n<32){let u=[];for(let d of e)d.flatten(u);return new le(u,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function O(u){let d;if(u.lines>s&&u instanceof Ot)for(let m of u.children)O(m);else u.lines>o&&(a>o||!a)?(f(),l.push(u)):u instanceof le&&a&&(d=c[c.length-1])instanceof le&&u.lines+d.lines<=32?(a+=u.lines,h+=u.length+1,c[c.length-1]=new le(d.text.concat(u.text),d.length+1+u.length)):(a+u.lines>r&&f(),a+=u.lines,h+=u.length+1,c.push(u))}function f(){a!=0&&(l.push(c.length==1?c[0]:Ot.from(c,h)),h=-1,a=c.length=0)}for(let u of e)O(u);return f(),l.length==1?l[0]:new Ot(l,t)}}D.empty=new le([""],0);function Vg(i){let e=-1;for(let t of i)e+=t.length+1;return e}function zr(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s=t&&(a>n&&(l=l.slice(0,n-r)),r0?1:(e instanceof le?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,l=r instanceof le?r.text.length:r.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof le){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof le?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Sf{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new gn(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(D.prototype[Symbol.iterator]=function(){return this.iter()},gn.prototype[Symbol.iterator]=Sf.prototype[Symbol.iterator]=bf.prototype[Symbol.iterator]=function(){return this});let Yg=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Vi(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function de(i,e,t=!0,n=!0){return Eg(i,e,t,n)}function Lg(i){return i>=56320&&i<57344}function Dg(i){return i>=55296&&i<56320}function Re(i,e){let t=i.charCodeAt(e);if(!Dg(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Lg(n)?(t-55296<<10)+(n-56320)+65536:t}function oa(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function ft(i){return i<65536?1:2}const Jo=/\r\n?|\n/;var Se=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Se||(Se={}));class Qt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=l}else{if(n!=Se.Simple&&h>=e&&(n==Se.TrackDel&&re||n==Se.TrackBefore&&re))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&l>=e)return rt?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qt(e)}static create(e){return new Qt(e)}}class ce extends Qt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return el(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return tl(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;n.length0&&Bt(n,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;of||O<0||f>t)throw new RangeError(`Invalid change range ${O} to ${f} (in doc of length ${t})`);let d=u?typeof u=="string"?D.of(u.split(n||Jo)):u:D.empty,m=d.length;if(O==f&&m==0)return;Oo&&ke(r,O-o,-1),ke(r,f-O,m),Bt(s,r,d),o=f}}return h(e),a(!l),l}static empty(e){return new ce(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;rl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length=0&&t<=0&&t==i[r+1]?i[r]+=e:r>=0&&e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function Bt(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(r,h,s,c,O),r=h,s=c}}}function tl(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Xn(i),l=new Xn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ke(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let O=Math.min(c,l.len);h+=O,c-=O,l.forward(O)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||n.length>h),s.forward2(a),o.forward(a)}}}}class Xn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?D.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?D.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lt{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Lt(n,r,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,n,r){return new Lt(e,t,n,r)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>Lt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;rr.from-s.from),t=e.indexOf(n);for(let r=1;rs.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function xf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let la=0;class C{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=la++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new C(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:aa),!!e.static,e.enables)}of(e){return new _r([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _r(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _r(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function aa(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class _r{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=la++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let O of this.dependencies)O=="doc"?a=!0:O=="selection"?h=!0:((t=e[O.id])!==null&&t!==void 0?t:1)&1||c.push(e[O.id]);return{create(O){return O.values[o]=n(O),1},update(O,f){if(a&&f.docChanged||h&&(f.docChanged||f.selection)||il(O,c)){let u=n(O);if(l?!Zh(u,O.values[o],r):!r(u,O.values[o]))return O.values[o]=u,1}return 0},reconfigure:(O,f)=>{let u,d=f.config.address[s];if(d!=null){let m=es(f,d);if(this.dependencies.every(g=>g instanceof C?f.facet(g)===O.facet(g):g instanceof ye?f.field(g,!1)==O.field(g,!1):!0)||(l?Zh(u=n(O),m,r):r(u=n(O),m)))return O.values[o]=m,0}else u=n(O);return O.values[o]=u,1}}}get extension(){return this}}function Zh(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let h=[];for(let c=0;cn===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ur).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>{let s=n.facet(ur),o=r.facet(ur),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,ur.of({field:this,create:e})]}get extension(){return this}}const ai={lowest:4,low:3,default:2,high:1,highest:0};function on(i){return e=>new kf(e,i)}const _t={highest:on(ai.highest),high:on(ai.high),default:on(ai.default),low:on(ai.low),lowest:on(ai.lowest)};class kf{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Xs{of(e){return new nl(this,e)}reconfigure(e){return Xs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class nl{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Jr{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let f of Gg(e,t,o))f instanceof ye?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],h=[];for(let f of r)l[f.id]=h.length<<1,h.push(u=>f.slot(u));let c=n==null?void 0:n.config.facets;for(let f in s){let u=s[f],d=u[0].facet,m=c&&c[f]||[];if(u.every(g=>g.type==0))if(l[d.id]=a.length<<1|1,aa(m,u))a.push(n.facet(d));else{let g=d.combine(u.map(Q=>Q.value));a.push(n&&d.compare(g,n.facet(d))?n.facet(d):g)}else{for(let g of u)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(Q=>g.dynamicSlot(Q)));l[d.id]=h.length<<1,h.push(g=>Bg(g,d,u))}}let O=h.map(f=>f(l));return new Jr(e,o,O,l,a,s)}}function Gg(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof nl&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof nl){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof kf)s(o.inner,o.prec);else if(o instanceof ye)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof _r)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,ai.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(i,ai.default),n.reduce((o,l)=>o.concat(l))}function Qn(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function es(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Pf=C.define(),rl=C.define({combine:i=>i.some(e=>e),static:!0}),$f=C.define({combine:i=>i.length?i[0]:void 0,static:!0}),wf=C.define(),vf=C.define(),Tf=C.define(),Xf=C.define({combine:i=>i.length?i[0]:!1});class bt{constructor(e,t){this.type=e,this.value=t}static define(){return new Ig}}class Ig{of(e){return new bt(this,e)}}class Ug{constructor(e){this.map=e}of(e){return new W(this,e)}}class W{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new W(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ug(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}}W.reconfigure=W.define();W.appendConfig=W.define();class he{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&xf(n,t.newLength),s.some(l=>l.type==he.time)||(this.annotations=s.concat(he.time.of(Date.now())))}static create(e,t,n,r,s,o){return new he(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(he.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}he.time=bt.define();he.userEvent=bt.define();he.addToHistory=bt.define();he.remote=bt.define();function Ng(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n=i[n]))s=i[n++],o=i[n++];else if(r=0;r--){let s=n[r](i);s instanceof he?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof he?i=s[0]:i=Rf(e,Ai(s),!1)}return i}function Hg(i){let e=i.startState,t=e.facet(Tf),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=Cf(n,sl(e,s,i.changes.newLength),!0))}return n==i?i:he.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const Kg=[];function Ai(i){return i==null?Kg:Array.isArray(i)?i:[i]}var te=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(te||(te={}));const Jg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ol;try{ol=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function e0(i){if(ol)return ol.test(i);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Jg.test(t)))return!0}return!1}function t0(i){return e=>{if(!/\S/.test(e))return te.Space;if(e0(e))return te.Word;for(let t=0;t-1)return te.Word;return te.Other}}class Y{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;lr.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(W.reconfigure)?(t=null,n=l.value):l.is(W.appendConfig)&&(t=null,n=Ai(n).concat(l.value));let s;t?s=e.startState.values.slice():(t=Jr.resolve(n,r,this),s=new Y(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(rl)?e.newSelection:e.newSelection.asSingle();new Y(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=Ai(n.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return Y.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Jr.resolve(e.extensions||[],new Map),n=e.doc instanceof D?e.doc:D.of((e.doc||"").split(t.staticFacet(Y.lineSeparator)||Jo)),r=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return xf(r,n.length),t.staticFacet(rl)||(r=r.asSingle()),new Y(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Y.tabSize)}get lineBreak(){return this.facet(Y.lineSeparator)||` diff --git a/veadk/webui/assets/MarkdownPromptEditor-B7SUdnRF.js b/veadk/webui/assets/MarkdownPromptEditor-Di7BE6IZ.js similarity index 99% rename from veadk/webui/assets/MarkdownPromptEditor-B7SUdnRF.js rename to veadk/webui/assets/MarkdownPromptEditor-Di7BE6IZ.js index 9595e2d1..b0bfd1da 100644 --- a/veadk/webui/assets/MarkdownPromptEditor-B7SUdnRF.js +++ b/veadk/webui/assets/MarkdownPromptEditor-Di7BE6IZ.js @@ -1,4 +1,4 @@ -var i2=Object.defineProperty;var s2=(t,e,n)=>e in t?i2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var P=(t,e,n)=>s2(t,typeof e!="symbol"?e+"":e,n);import{i as Dd,j as l2,f as a2,g as Fc,y as c2,G as u2,s as f2,A as C,a as N,e as Fd,c as Hd,V as it,x as mn,E as Ns,C as Za,B as d2,b as Vd,u as rn,w as pl,h as tf,v as xr,F as Un,D as zt,d as fi,k as h2,t as L,z as nr,o as g2,m as p2,n as m2,l as y2,r as x2,p as _2,q as v2,R as qo}from"./index-DYW1GYEr.js";const C2={}.hasOwnProperty;function am(t,e){let n=-1,r;if(e.extensions)for(;++ne in t?i2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var P=(t,e,n)=>s2(t,typeof e!="symbol"?e+"":e,n);import{i as Dd,j as l2,f as a2,g as Fc,y as c2,G as u2,s as f2,A as C,a as N,e as Fd,c as Hd,V as it,x as mn,E as Ns,C as Za,B as d2,b as Vd,u as rn,w as pl,h as tf,v as xr,F as Un,D as zt,d as fi,k as h2,t as L,z as nr,o as g2,m as p2,n as m2,l as y2,r as x2,p as _2,q as v2,R as qo}from"./index-BFZ8iSb4.js";const C2={}.hasOwnProperty;function am(t,e){let n=-1,r;if(e.extensions)for(;++ni.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPromptEditor-Di7BE6IZ.js","assets/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]); var N4=Object.defineProperty;var A4=(e,t,n)=>t in e?N4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pv=(e,t,n)=>A4(e,typeof t!="symbol"?t+"":t,n);function C4(e,t){for(var n=0;nr[s]})}}}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 s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var tp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var j2={exports:{}},pm={},B2={exports:{}},at={};/** * @license React * react.production.min.js @@ -496,7 +496,7 @@ Error generating stack: `+i.message+` ${Wk}`}async function*Sx(e){if(!e.body)throw new Error("Response has no body");const t=e.body.getReader(),n=new TextDecoder;let r="";try{for(;;){const{done:s,value:i}=await t.read();if(s)break;r+=n.decode(i,{stream:!0});let a=r.match(/\r?\n\r?\n/);for(;(a==null?void 0:a.index)!==void 0;){const o=r.slice(0,a.index);r=r.slice(a.index+a[0].length);const c=o.split(/\r?\n/).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trimStart()).join(` `);if(c)try{yield JSON.parse(c)}catch{c!=="[DONE]"&&c!=="ping"&&console.debug(`parseSSE: dropping unparseable frame (${c.length} chars):`,c.slice(0,200))}a=r.match(/\r?\n\r?\n/)}}}finally{try{await t.cancel()}catch{}finally{t.releaseLock()}}}const qR="veadk.messageFeedback.v1";function GR(e,t,n,r){return[e,t,n,r].join(":")}function XR(){if(typeof window>"u")return{};try{const e=JSON.parse(localStorage.getItem(qR)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function t$(e,t,n){if(typeof window>"u")return;const r=XR();r[e]={...r[e]??{},[`veadk_feedback:${t}`]:n},localStorage.setItem(qR,JSON.stringify(r))}const Dh="",Nx=new Map;function QR(e,t){Nx.set(e,t)}function ZR(){Nx.clear()}function Dn(e){const t=Nx.get(e);return t?{app:t.app,ep:{base:t.base,apiKey:t.apiKey,runtimeId:t.runtimeId,region:t.region}}:{app:e,ep:{}}}async function rt(e,t={},n={},r=gc){const s={...t,headers:Bm(t.headers)},i=()=>{const c={...s,signal:Ls(t.signal,r)};if(n.runtimeId){const u=n.region?`${e.includes("?")?"&":"?"}region=${encodeURIComponent(n.region)}`:"";return fetch(si(`${Dh}/web/runtime-proxy/${n.runtimeId}${e}${u}`),c)}if(n.base){const u=new Headers(c.headers);return u.set("X-AgentKit-Base",n.base),n.apiKey&&u.set("X-AgentKit-Key",n.apiKey),fetch(si(`${Dh}/agentkit-proxy${e}`),{...c,headers:u})}return fetch(si(`${Dh}${e}`),c)},a=async c=>{if(X7(c))return!0;if(c.status!==401)return!1;try{return await Y7()}catch{return!1}};let o=await i();for(;await a(o);)await Q7(t.signal),o=await i();return o}function n$(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{var n;if(t&&typeof t=="object"&&"msg"in t){const r=Array.isArray(t.loc)?(n=t.loc)==null?void 0:n.join("."):"",s=String(t.msg??"");return r?`${r}: ${s}`:s}return String(t)}).filter(Boolean).join(` -`):e&&typeof e=="object"?JSON.stringify(e):""}async function xn(e,t){const n=await e.text().catch(()=>"");if(!n)return`${t} (${e.status})`;try{const r=JSON.parse(n);return n$(r.detail??r.error)||n||`${t} (${e.status})`}catch{return n||`${t} (${e.status})`}}async function JR(){const e=await rt("/list-apps");if(!e.ok)throw new Error(`list-apps failed: ${e.status}`);return e.json()}class Fd extends Error{constructor(){super("当前账号无权访问该 Runtime,请刷新列表或重新登录后重试。"),this.name="RuntimeAccessDeniedError"}}class ld extends Error{constructor(t,n=!1){super(t),this.unsupported=n,this.name="RuntimeProbeError"}}async function r$(e){try{const t=await e.clone().json();return typeof t.detail=="string"?t.detail:""}catch{return""}}async function Fm(e,t,n){const r=await rt("/list-apps",{},n??{base:e,apiKey:t}),s=n!=null&&n.runtimeId?await r$(r):"";if(n!=null&&n.runtimeId&&s==="runtime_access_denied")throw new Fd;if(n!=null&&n.runtimeId&&r.status===404)throw new ld("该 Runtime 的 Agent Server 未提供连接接口,请确认 Runtime 已就绪且版本兼容。",!0);if(n!=null&&n.runtimeId&&(r.status===401||r.status===403))throw new ld("Runtime 服务拒绝了连接请求,请检查 Runtime 的鉴权配置。");if(!r.ok)throw new Error(await xn(r,"读取 Agent 列表失败"));return r.json()}async function Pp(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},r);if(!s.ok){const a=`创建会话失败 (${s.status})`,o=await xn(s,"创建会话失败");throw new Error(o===a?a:`${a}:${o}`)}return(await s.json()).id}async function Ax(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{},r);if(!s.ok)throw new Error(`list sessions failed: ${s.status}`);return s.json()}async function jp(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(`/apps/${r}/users/${encodeURIComponent(t)}/sessions/${n}`,{},s);if(!i.ok)throw new Error(`get session failed: ${i.status}`);const a=await i.json();if(s.runtimeId){const o=GR(s.runtimeId,r,t,n);a.state={...XR()[o]??{},...a.state??{}}}return a}async function eL(e){const{app:t,ep:n}=Dn(e.appName);if(!n.runtimeId)throw new Error("只有连接到 AgentKit Runtime 的会话支持反馈回流");const r=await rt("/web/evaluation/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:n.runtimeId,region:n.region??"cn-beijing",appName:t,userId:e.userId,sessionId:e.sessionId,eventId:e.eventId,rating:e.rating,comment:e.comment??""})},{},Tx);if(!r.ok)throw new Error(await xn(r,"提交反馈失败"));const s=await r.json(),i=GR(n.runtimeId,t,e.userId,e.sessionId);return t$(i,e.eventId,s),s}async function Kb(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(`/apps/${r}/users/${encodeURIComponent(t)}/sessions/${n}`,{method:"DELETE"},s);if(!i.ok&&i.status!==404)throw new Error(`delete session failed: ${i.status}`)}async function s$(e){const t=await rt("/web/media/capabilities");if(!t.ok)throw new Error(await xn(t,"media capabilities failed"));return t.json()}async function tL(e,t,n,r){const{app:s}=Dn(e),i=new FormData;i.set("app_name",s),i.set("user_id",t),i.set("session_id",n),i.set("file",r);const a=await rt("/web/media",{method:"POST",body:i},{},Tx);if(!a.ok)throw new Error(await xn(a,"文件上传失败"));return{...await a.json(),status:"ready"}}async function Yb(e,t,n){const{app:r}=Dn(e),s=`/web/media/${encodeURIComponent(r)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,i=await rt(s,{method:"DELETE"});if(!i.ok&&i.status!==404)throw new Error(await xn(i,"media cleanup failed"))}function nL(e){try{const t=new URL(e);if(t.protocol!=="veadk-media:"||t.hostname!=="apps")return;const n=t.pathname.split("/").filter(Boolean).map(decodeURIComponent);return n.length!==7||n[1]!=="users"||n[3]!=="sessions"||n[5]!=="media"?void 0:`/web/media/${n.map(encodeURIComponent).filter((r,s)=>![1,3,5].includes(s)).join("/")}`}catch{return}}async function Ph(e,t){const n=nL(t);if(!n)throw new Error("Invalid VeADK media URI");const r=await rt(n,{method:"DELETE"});if(!r.ok&&r.status!==404)throw new Error(await xn(r,"media cleanup failed"))}function rL(e,t){if(t.startsWith("data:")||t.startsWith("blob:")||/^https?:/.test(t))return t;const n=nL(t);if(!n)return t;const r=`${n}/content`;return si(`${Dh}${r}`)}async function sL(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/dev/apps/${encodeURIComponent(n)}/debug/trace/session/${encodeURIComponent(t)}`,{},r);if(!s.ok)throw new Error(`trace failed: ${s.status}`);const i=s.headers.get("content-type")??"";if(!i.includes("application/json")){const o=i.split(";",1)[0]||"Content-Type 缺失";throw new Error(`trace failed: 服务端返回了非 JSON 响应(${o}),请检查 Studio API 代理配置`)}const a=await s.json();if(!Array.isArray(a))throw new Error("trace failed: 返回格式无效");return a}function Cx(e){const t=n=>({id:String(n.id??""),kind:n.kind==="skill"?"skill":"tool",name:String(n.name??""),custom:n.custom===!0,description:typeof n.description=="string"?n.description:void 0,skillSourceId:typeof n.skill_source_id=="string"?n.skill_source_id:void 0,version:typeof n.version=="string"?n.version:void 0});return{schemaVersion:Number(e.schema_version??1),revision:Number(e.revision??0),tools:Array.isArray(e.tools)?e.tools.map(n=>t(n)):[],skills:Array.isArray(e.skills)?e.skills.map(n=>t(n)):[]}}function Ix(e,t,n){return`/harness/apps/${encodeURIComponent(e)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/capabilities`}async function iL(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(Ix(r,t,n),{},s);if(!i.ok)throw new Error(await xn(i,"读取会话能力失败"));return Cx(await i.json())}async function aL(e){const{ep:t}=Dn(e),n=await rt("/harness/capabilities/tools",{},t);if(!n.ok)throw new Error(await xn(n,"读取内置工具失败"));return((await n.json()).tools??[]).map(s=>{var i;return((i=s.name)==null?void 0:i.trim())??""}).filter(Boolean)}async function oL(e){const{ep:t}=Dn(e),n=await rt("/harness/skills/spaces?region=all",{},t);if(!n.ok)throw new Error(await xn(n,"读取 Skill Space 失败"));return(await n.json()).items??[]}async function lL(e,t,n){const{ep:r}=Dn(e),s=new URLSearchParams({region:n||"cn-beijing"}),i=`/harness/skills/spaces/${encodeURIComponent(t)}/skills?${s.toString()}`,a=await rt(i,{},r);if(!a.ok)throw new Error(await xn(a,"读取 Skill 列表失败"));return(await a.json()).items??[]}async function cL(e,t,n=1,r=20){const{ep:s}=Dn(e),i=new URLSearchParams({query:t,page_number:String(n),page_size:String(r)}),a=await rt(`/harness/skills/findskill?${i.toString()}`,{},s);if(!a.ok)throw new Error(await xn(a,"搜索 Skill Hub 失败"));const o=await a.json();return{items:o.items??[],totalCount:Number(o.totalCount??0)}}async function uL(e,t,n,r,s){const{app:i,ep:a}=Dn(e),o=await rt(Ix(i,t,n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r.kind,name:r.name,skill_source_id:r.skillSourceId,description:r.description,version:r.version,expected_revision:s})},a);if(!o.ok)throw new Error(await xn(o,"添加会话能力失败"));return Cx(await o.json())}async function dL(e,t,n,r,s){const{app:i,ep:a}=Dn(e),o=`${Ix(i,t,n)}/${encodeURIComponent(r)}?expected_revision=${s}`,c=await rt(o,{method:"DELETE"},a);if(!c.ok)throw new Error(await xn(c,"移除会话能力失败"));return Cx(await c.json())}async function fL(e,t){const n=await rt(`/web/agent-info/${e}`,{},t);if(!n.ok)throw new Error(`agent-info failed: ${n.status}`);const r=await n.json();return{name:r.name??e,description:r.description??"",type:r.type,model:r.model??"",tools:r.tools??[],skills:r.skills??[],subAgents:r.subAgents??[],components:r.components??[],searchSources:r.searchSources??[],graph:r.graph}}async function Rx(e){const{app:t,ep:n}=Dn(e);return fL(t,n)}async function hL(e,t){const n={runtimeId:e,region:t},s=(await Fm("","",n))[0];if(!s)throw new Error("该 Runtime 未提供可预览的 Agent。");return fL(s,n)}async function pL(e,t,n,r){const{app:s,ep:i}=Dn(e),a=new URLSearchParams({source:t,app_name:s,q:n,user_id:r}),o=await rt(`/web/search?${a.toString()}`,{},i);if(!o.ok)throw new Error(await xn(o,"Agent 检索失败"));return o.json()}async function mL(e,t){const{app:n}=Dn(e),r=await rt(`/web/search?source=web&app_name=${encodeURIComponent(n)}&q=${encodeURIComponent(t)}`);if(!r.ok)throw new Error(`web search failed: ${r.status}`);return r.json()}async function*cd({appName:e,userId:t,sessionId:n,text:r,attachments:s=[],invocation:i,functionResponses:a=[],signal:o,sessionCapabilities:c=!1}){const{app:u,ep:d}=Dn(e),f=s.flatMap(g=>g.status&&g.status!=="ready"?[]:g.uri?[{fileData:{mimeType:g.mimeType,fileUri:g.uri,displayName:g.name},partMetadata:{veadkMedia:{id:g.id,uri:g.uri,name:g.name,mimeType:g.mimeType,sizeBytes:g.sizeBytes}}}]:g.data?[{inlineData:{mimeType:g.mimeType,data:g.data,displayName:g.name}}]:[]),h=i&&(i.skills.length>0||i.targetAgent)?i:void 0,p=[...f,...a.map(g=>({functionResponse:{id:g.id,name:g.name,response:g.response}})),...r.trim()?[{text:r}]:[]];if(h&&p.length>0){const g=p[0],x=g.partMetadata;p[0]={...g,partMetadata:{...x,veadkInvocation:h}}}const m=await rt(c?"/harness/run_sse":"/run_sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:u,user_id:t,session_id:n,new_message:{role:"user",parts:p},streaming:!0,custom_metadata:h?{veadkInvocation:h}:void 0}),signal:o},d,0);if(!m.ok)throw new Error(Hf(`run_sse failed: ${m.status}`));for await(const g of Sx(m)){const x=g;typeof x.error=="string"&&(x.error=Hf(x.error)),typeof x.errorMessage=="string"&&(x.errorMessage=Hf(x.errorMessage)),typeof x.error_message=="string"&&(x.error_message=Hf(x.error_message)),yield x}}const Tu=new Map;async function Um(e,t,n,r){var u,d,f;const s=r==null?void 0:r.taskId,i=s?new AbortController:void 0;s&&i&&Tu.set(s,i);const a=()=>{s&&Tu.get(s)===i&&Tu.delete(s)};let o;try{(u=r==null?void 0:r.onStage)==null||u.call(r,{level:"info",phase:"upload",message:"正在上传代码包",pct:0}),o=await rt("/web/deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},signal:i==null?void 0:i.signal,body:JSON.stringify({name:e,files:t,config:n,taskId:s,im:r==null?void 0:r.im,envs:r==null?void 0:r.envs})},{},0),(d=r==null?void 0:r.onStage)==null||d.call(r,{level:"success",phase:"upload",message:"代码包上传完成",pct:100})}catch(h){throw a(),h}if(!o.ok){const h=await o.text().catch(()=>"");throw a(),new Error(h||`部署失败 (${o.status})`)}let c=null;try{for await(const h of Sx(o)){const p=h;if(p&&p.done){c=p;break}p&&p.message&&((f=r==null?void 0:r.onStage)==null||f.call(r,p))}}catch(h){throw a(),h}if(a(),!c)throw new Error("部署失败:连接中断");if(!c.success)throw new Error(c.error||"部署失败");if(!c.agentName)throw new Error("部署失败:返回缺少 Agent 名称");if(!c.runtimeId&&!c.url)throw new Error("部署失败:返回缺少 AgentKit 连接信息");return{apikey:c.apikey??"",url:c.url??"",agentName:c.agentName,runtimeId:c.runtimeId,consoleUrl:c.consoleUrl,region:c.region,feishuChannel:c.feishuChannel}}async function gL(e){var n;const t=await rt("/web/cancel-deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e})});if(!t.ok){const r=await t.text().catch(()=>"");throw new Error(r||`取消部署失败 (${t.status})`)}(n=Tu.get(e))==null||n.abort(),Tu.delete(e)}async function yL(e="cn-beijing"){const t=await rt(`/web/my-runtimes?region=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`加载失败 (${t.status})`);return(await t.json()).runtimes??[]}const ud={title:"VeADK Studio",logoUrl:""},T0={studio:!1,version:"",branding:ud,features:{newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,addAgentkit:!0,generatedAgentTestRun:!0},defaultView:"chat",agentsSource:"local"};async function bL(){var e,t;try{const n=await rt("/web/ui-config");if(!n.ok)return T0;const r=await n.json(),s=typeof((e=r.branding)==null?void 0:e.logoUrl)=="string"?r.branding.logoUrl:ud.logoUrl;return{studio:r.studio??!1,version:typeof r.version=="string"?r.version:"",branding:{title:typeof((t=r.branding)==null?void 0:t.title)=="string"?r.branding.title:ud.title,logoUrl:s?si(s):""},features:{...T0.features,...r.features??{}},defaultView:r.defaultView??"chat",agentsSource:r.agentsSource==="cloud"?"cloud":"local"}}catch{return T0}}const EL={role:"user",capabilities:{createAgents:!1,manageAgents:!1,runtimeScope:"mine"}};async function xL(){var n,r,s;const e=await rt("/web/access");if(!e.ok)throw new Error(`加载权限失败 (${e.status})`);const t=await e.json();if(!["admin","developer","user"].includes(t.role)||typeof((n=t.capabilities)==null?void 0:n.createAgents)!="boolean"||typeof((r=t.capabilities)==null?void 0:r.manageAgents)!="boolean"||!["all","mine"].includes((s=t.capabilities)==null?void 0:s.runtimeScope))throw new Error("权限服务返回了无法解析的响应");return t}async function wL(e,t){const n=new URLSearchParams;e&&n.set("targetVersion",e),t&&n.set("startedAt",String(t));const r=n.size?`?${n.toString()}`:"",s=await rt(`/web/studio-update${r}`);if(!s.ok)throw new Error(`检查 Studio 更新失败 (${s.status})`);return await s.json()}async function vL(e){const t=await rt("/web/studio-update",{method:"POST",headers:{"Content-Type":"application/json","X-VeADK-Studio-Update":"1"},body:JSON.stringify({version:e})},{},Tx);if(!t.ok){let n="";try{const r=await t.json();n=typeof r.detail=="string"?r.detail:""}catch{n=""}throw new Error(n||`提交 Studio 更新失败 (${t.status})`)}return await t.json()}async function jh(e={}){const t=new URLSearchParams({scope:e.scope??"all",page_size:String(e.pageSize??30),region:e.region??"all"});e.nextToken&&t.set("next_token",e.nextToken);const n=await rt(`/web/runtimes?${t.toString()}`);if(!n.ok)throw new Error(`加载 Runtime 失败 (${n.status})`);const r=await n.json();return{runtimes:r.runtimes??[],nextToken:r.nextToken??""}}async function _L(e,t="cn-beijing"){try{return await Fm("","",{runtimeId:e,region:t})}catch(n){if(n instanceof Fd||n instanceof ld)throw n;return null}}async function kL(e,t="cn-beijing"){const n=await rt("/web/delete-runtime",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e,region:t})});if(!n.ok){const r=await n.text().catch(()=>"");throw new Error(r||`删除失败 (${n.status})`)}}async function Lx(e,t="cn-beijing"){const n=await rt(`/web/runtime-detail?runtimeId=${encodeURIComponent(e)}®ion=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(await xn(n,"加载 Runtime 详情失败"));return n.json()}async function Bp(e){const t=await rt("/web/generated-agent-projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await xn(t,"生成项目失败"));return t.json()}async function TL(e){const t=await rt("/web/generated-agent-test-runs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await xn(t,"创建调试运行失败"));return WR(t,"创建调试运行失败")}async function SL(e,t){const n=await rt(`/web/generated-agent-test-runs/${e}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t})});if(!n.ok)throw new Error(await xn(n,"创建调试会话失败"));return(await WR(n,"创建调试会话失败")).id}async function*NL({runId:e,userId:t,sessionId:n,text:r,signal:s}){const i=r.trim()?[{text:r}]:[],a=await rt(`/web/generated-agent-test-runs/${e}/run_sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:t,session_id:n,new_message:{role:"user",parts:i},streaming:!0}),signal:s},{},0);if(!a.ok)throw new Error(await xn(a,"调试运行失败"));for await(const o of Sx(a))yield o}async function Wb(e){const t=await rt(`/web/generated-agent-test-runs/${e}`,{method:"DELETE"});if(!t.ok&&t.status!==404)throw new Error(await xn(t,"清理调试运行失败"))}const i$=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SITE_BRANDING:ud,DEFAULT_STUDIO_ACCESS:EL,RuntimeAccessDeniedError:Fd,RuntimeProbeError:ld,addSessionCapability:uL,cancelAgentkitDeployment:gL,clearRemoteApps:ZR,componentSearch:pL,createGeneratedAgentTestRun:TL,createGeneratedAgentTestSession:SL,createSession:Pp,deleteGeneratedAgentTestRun:Wb,deleteMedia:Ph,deleteRuntime:kL,deleteSession:Kb,deleteSessionMedia:Yb,deployAgentkitProject:Um,fetchRemoteApps:Fm,generateAgentProject:Bp,getAgentInfo:Rx,getMediaCapabilities:s$,getMyRuntimes:yL,getRuntimeAgentInfo:hL,getRuntimeDetail:Lx,getRuntimes:jh,getSession:jp,getSessionCapabilities:iL,getSessionTrace:sL,getStudioAccess:xL,getStudioUpdateStatus:wL,getUiConfig:bL,listApps:JR,listSessionBuiltinTools:aL,listSessionSkillSpaces:oL,listSessionSkillsInSpace:lL,listSessions:Ax,mediaContentUrl:rL,probeRuntimeApps:_L,registerRemoteApp:QR,removeSessionCapability:dL,runGeneratedAgentTestSSE:NL,runSSE:cd,searchSessionPublicSkills:cL,startStudioUpdate:vL,submitMessageFeedback:eL,uploadMedia:tL,webSearch:mL},Symbol.toStringTag,{value:"Module"})),a$="send_a2ui_json_to_client",o$="validated_a2ui_json",qb="adk_request_credential",qk="transfer_to_agent";function l$(e){var r,s,i,a;const t=e,n=((r=t==null?void 0:t.exchangedAuthCredential)==null?void 0:r.oauth2)??((s=t==null?void 0:t.exchanged_auth_credential)==null?void 0:s.oauth2)??((i=t==null?void 0:t.rawAuthCredential)==null?void 0:i.oauth2)??((a=t==null?void 0:t.raw_auth_credential)==null?void 0:a.oauth2);return(n==null?void 0:n.authUri)??(n==null?void 0:n.auth_uri)}function Ns(){return{blocks:[],liveStart:0}}const Gk=e=>e.functionCall??e.function_call,Gb=e=>e.functionResponse??e.function_response;function c$(e){if(!e||typeof e!="object")return"";const t=e,n=t.agentName??t.agent_name;return typeof n=="string"?n:""}function u$(e){return e.replace(/-/g,"+").replace(/_/g,"/")}function AL(e){const t=[];for(const[n,r]of e.entries()){const s=r.partMetadata??r.part_metadata,i=s==null?void 0:s.veadkTransport;if((i==null?void 0:i.hidden)===!0)continue;const a=s==null?void 0:s.veadkMedia;if(typeof(a==null?void 0:a.uri)=="string"){t.push({id:String(a.id??a.uri),mimeType:typeof a.mimeType=="string"?a.mimeType:void 0,uri:a.uri,name:typeof a.name=="string"?a.name:void 0,sizeBytes:typeof a.sizeBytes=="number"?a.sizeBytes:void 0});continue}const o=r.inlineData??r.inline_data;if(o&&o.data){t.push({id:`inline-${n}-${o.displayName??o.display_name??"media"}`,mimeType:o.mimeType??o.mime_type,data:u$(o.data),name:o.displayName??o.display_name});continue}const c=r.fileData??r.file_data,u=(c==null?void 0:c.fileUri)??(c==null?void 0:c.file_uri);c&&u&&t.push({id:u,mimeType:c.mimeType??c.mime_type,uri:u,name:c.displayName??c.display_name})}return t}function Xb(e){const t=e.partMetadata??e.part_metadata,n=t==null?void 0:t.veadkTransport;return(n==null?void 0:n.hideText)===!0?void 0:e.text}const d$=new Set(["llm","sequential","parallel","loop","a2a"]);function f$(e){var t;for(const n of e){const r=(t=n.partMetadata??n.part_metadata)==null?void 0:t.veadkInvocation;if(!r||typeof r!="object")continue;const s=r,i=Array.isArray(s.skills)?s.skills.flatMap(c=>{if(!c||typeof c!="object")return[];const u=c;return typeof u.name=="string"?[{name:u.name,description:typeof u.description=="string"?u.description:""}]:[]}):[];let a;const o=s.targetAgent;if(o&&typeof o=="object"){const c=o,u=c.type;typeof c.name=="string"&&typeof u=="string"&&d$.has(u)&&Array.isArray(c.path)&&(a={name:c.name,description:typeof c.description=="string"?c.description:"",type:u,path:c.path.filter(d=>typeof d=="string")})}if(i.length>0||a)return{skills:i,targetAgent:a}}}function h$(e,t){if(!t.length)return;const n=e[e.length-1];(n==null?void 0:n.kind)==="attachment"?n.files.push(...t):e.push({kind:"attachment",files:t})}function Xk(e,t,n){const r=e[e.length-1];r&&r.kind===t?r.text+=n:e.push(t==="thinking"?{kind:t,text:n,done:!1}:{kind:t,text:n})}function zf(e){for(const t of e)t.kind==="thinking"&&(t.done=!0)}function zl(e,t){var a,o,c,u;const n=e.blocks.map(d=>({...d}));let r=e.liveStart;const s=((a=t.content)==null?void 0:a.parts)??[],i=s.some(d=>Gk(d)||Gb(d));if(t.partial&&!i){for(const d of s){const f=Xb(d);typeof f=="string"&&f&&Xk(n,d.thought?"thinking":"text",f)}return{blocks:n,liveStart:r}}n.length=r;for(const d of s){const f=Gk(d),h=Gb(d),p=AL([d]),m=Xb(d);if(typeof m=="string"&&m)Xk(n,d.thought?"thinking":"text",m);else if(p.length)zf(n),h$(n,p);else if(f)if(zf(n),f.name===qk){const g=c$(f.args)||((o=t.actions)==null?void 0:o.transferToAgent)||((c=t.actions)==null?void 0:c.transfer_to_agent)||"未知 Agent";n.push({kind:"agent-transfer",agentName:g,done:!1})}else if(f.name===qb){const g=f.args??{},x=g.authConfig??g.auth_config??g,E=String(g.functionCallId??g.function_call_id??"").replace(/^_adk_toolset_auth_/,"")||void 0;n.push({kind:"auth",callId:f.id??"",label:E,authUri:l$(x),authConfig:x,done:!1})}else n.push({kind:"tool",name:f.name??"",args:f.args,done:!1});else if(h){if(zf(n),h.name===qk)for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="agent-transfer"&&!x.done){x.done=!0;break}}if(h.name===qb)for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="auth"&&!x.done){x.done=!0;break}}for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="tool"&&!x.done&&x.name===h.name){x.done=!0,x.response=h.response;break}}if(h.name===a$){const g=((u=h.response)==null?void 0:u[o$])??[];if(g.length){const x=n[n.length-1];x&&x.kind==="a2ui"?x.messages.push(...g):n.push({kind:"a2ui",messages:g})}}}}return zf(n),r=n.length,{blocks:n,liveStart:r}}function p$(e,t={}){var s,i;const n=[];let r=Ns();for(const a of e)if(a.author==="user"){const c=((s=a.content)==null?void 0:s.parts)??[];if(c.some(p=>{var m;return((m=Gb(p))==null?void 0:m.name)===qb})){for(let p=n.length-1;p>=0;p--)if(n[p].role==="assistant"){for(let m=n[p].blocks.length-1;m>=0;m--){const g=n[p].blocks[m];if(g.kind==="auth"){g.done=!0;break}}break}}const u=c.map(Xb).filter(p=>!!p).join(""),d=AL(c),f=f$(c);if(!u&&!d.length&&!f){r=Ns();continue}const h=[];f&&h.push({kind:"invocation",value:f}),d.length&&h.push({kind:"attachment",files:d}),u&&h.push({kind:"text",text:u}),n.push({role:"user",blocks:h,meta:{ts:a.timestamp}}),r=Ns()}else{const c=a.author??"";let u=n[n.length-1];(!u||u.role!=="assistant"||c&&((i=u.meta)==null?void 0:i.author)!==c)&&(u={role:"assistant",blocks:[],meta:{author:c||void 0}},n.push(u),r=Ns()),r=zl(r,a),u.blocks=r.blocks;const d=a.usageMetadata??a.usage_metadata,f=u.meta??(u.meta={});c&&(f.author=c),d!=null&&d.totalTokenCount&&(f.tokens=d.totalTokenCount),a.timestamp&&(f.ts=a.timestamp),a.id&&(f.eventId=a.id);const h=a.invocationId??a.invocation_id;h&&(f.invocationId=h)}for(const a of n){const o=a.meta,c=o==null?void 0:o.eventId;if(!c)continue;const u=t[`veadk_feedback:${c}`];if(!u||typeof u!="object")continue;const d=u;d.rating!=="good"&&d.rating!=="bad"||(o.feedback=u)}return n}function m$(e){var t,n;for(const r of e??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const s=(((n=r.content)==null?void 0:n.parts)??[]).map(i=>i.text).find(Boolean);if(s)return s}return"新会话"}async function Ud(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine AK/SK,无法访问 AgentKit Skills 中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit Skills 中心");if(t.status===404)throw new Error("技能不存在或无 SKILL.md 内容");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function g$(){return(await Ud("/web/skill-spaces?region=all")).items||[]}async function y$(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),Ud(`/web/skill-spaces?${t.toString()}`)}async function b$(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function E$(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),Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function x$(e,t,n,r,s){const i=[];n&&i.push(`version=${encodeURIComponent(n)}`),r&&i.push(`region=${encodeURIComponent(r)}`),s&&i.push(`project=${encodeURIComponent(s)}`);const a=i.length>0?`?${i.join("&")}`:"";return Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${a}`)}function w$(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 v$(e,t){return`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}function Ghe(){}function Qk(e){const t=[],n=String(e||"");let r=n.indexOf(","),s=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const a=n.slice(s,r).trim();(a||!i)&&t.push(a),s=r+1,r=n.indexOf(",",s)}return t}function CL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _$=/[$_\p{ID_Start}]/u,k$=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,T$=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,S$=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,N$=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IL={};function Xhe(e){return e?_$.test(String.fromCodePoint(e)):!1}function Qhe(e,t){const r=(t||IL).jsx?T$:k$;return e?r.test(String.fromCodePoint(e)):!1}function Zk(e,t){return(IL.jsx?N$:S$).test(e)}const A$=/[ \t\n\f\r]/g;function C$(e){return typeof e=="object"?e.type==="text"?Jk(e.value):!1:Jk(e)}function Jk(e){return e.replace(A$,"")===""}let $d=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};$d.prototype.normal={};$d.prototype.property={};$d.prototype.space=void 0;function RL(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new $d(n,r,t)}function dd(e){return e.toLowerCase()}class Or{constructor(t,n){this.attribute=n,this.property=t}}Or.prototype.attribute="";Or.prototype.booleanish=!1;Or.prototype.boolean=!1;Or.prototype.commaOrSpaceSeparated=!1;Or.prototype.commaSeparated=!1;Or.prototype.defined=!1;Or.prototype.mustUseProperty=!1;Or.prototype.number=!1;Or.prototype.overloadedBoolean=!1;Or.prototype.property="";Or.prototype.spaceSeparated=!1;Or.prototype.space=void 0;let I$=0;const Je=To(),_n=To(),Qb=To(),ve=To(),It=To(),Tl=To(),Br=To();function To(){return 2**++I$}const Zb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:_n,commaOrSpaceSeparated:Br,commaSeparated:Tl,number:ve,overloadedBoolean:Qb,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),S0=Object.keys(Zb);class Ox extends Or{constructor(t,n,r,s){let i=-1;if(super(t,n),eT(this,"space",s),typeof r=="number")for(;++i4&&n.slice(0,4)==="data"&&D$.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(tT,j$);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!tT.test(i)){let a=i.replace(M$,P$);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Ox}return new s(r,t)}function P$(e){return"-"+e.toLowerCase()}function j$(e){return e.charAt(1).toUpperCase()}const Hd=RL([LL,R$,DL,PL,jL],"html"),Ca=RL([LL,L$,DL,PL,jL],"svg");function nT(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function BL(e){return e.join(" ").trim()}var Mx={},rT=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,B$=/\n/g,F$=/^\s*/,U$=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$$=/^:\s*/,H$=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,z$=/^[;\s]*/,V$=/^\s+|\s+$/g,K$=` +`):e&&typeof e=="object"?JSON.stringify(e):""}async function xn(e,t){const n=await e.text().catch(()=>"");if(!n)return`${t} (${e.status})`;try{const r=JSON.parse(n);return n$(r.detail??r.error)||n||`${t} (${e.status})`}catch{return n||`${t} (${e.status})`}}async function JR(){const e=await rt("/list-apps");if(!e.ok)throw new Error(`list-apps failed: ${e.status}`);return e.json()}class Fd extends Error{constructor(){super("当前账号无权访问该 Runtime,请刷新列表或重新登录后重试。"),this.name="RuntimeAccessDeniedError"}}class ld extends Error{constructor(t,n=!1){super(t),this.unsupported=n,this.name="RuntimeProbeError"}}async function r$(e){try{const t=await e.clone().json();return typeof t.detail=="string"?t.detail:""}catch{return""}}async function Fm(e,t,n){const r=await rt("/list-apps",{},n??{base:e,apiKey:t}),s=n!=null&&n.runtimeId?await r$(r):"";if(n!=null&&n.runtimeId&&s==="runtime_access_denied")throw new Fd;if(n!=null&&n.runtimeId&&r.status===404)throw new ld("该 Runtime 的 Agent Server 未提供连接接口,请确认 Runtime 已就绪且版本兼容。",!0);if(n!=null&&n.runtimeId&&(r.status===401||r.status===403))throw new ld("Runtime 服务拒绝了连接请求,请检查 Runtime 的鉴权配置。");if(!r.ok)throw new Error(await xn(r,"读取 Agent 列表失败"));return r.json()}async function Pp(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},r);if(!s.ok){const a=`创建会话失败 (${s.status})`,o=await xn(s,"创建会话失败");throw new Error(o===a?a:`${a}:${o}`)}return(await s.json()).id}async function Ax(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/apps/${n}/users/${encodeURIComponent(t)}/sessions`,{},r);if(!s.ok)throw new Error(`list sessions failed: ${s.status}`);return s.json()}async function jp(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(`/apps/${r}/users/${encodeURIComponent(t)}/sessions/${n}`,{},s);if(!i.ok)throw new Error(`get session failed: ${i.status}`);const a=await i.json();if(s.runtimeId){const o=GR(s.runtimeId,r,t,n);a.state={...XR()[o]??{},...a.state??{}}}return a}async function eL(e){const{app:t,ep:n}=Dn(e.appName);if(!n.runtimeId)throw new Error("只有连接到 AgentKit Runtime 的会话支持反馈回流");const r=await rt("/web/evaluation/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:n.runtimeId,region:n.region??"cn-beijing",appName:t,userId:e.userId,sessionId:e.sessionId,eventId:e.eventId,rating:e.rating,comment:e.comment??""})},{},Tx);if(!r.ok)throw new Error(await xn(r,"提交反馈失败"));const s=await r.json(),i=GR(n.runtimeId,t,e.userId,e.sessionId);return t$(i,e.eventId,s),s}async function Kb(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(`/apps/${r}/users/${encodeURIComponent(t)}/sessions/${n}`,{method:"DELETE"},s);if(!i.ok&&i.status!==404)throw new Error(`delete session failed: ${i.status}`)}async function s$(e){const t=await rt("/web/media/capabilities");if(!t.ok)throw new Error(await xn(t,"media capabilities failed"));return t.json()}async function tL(e,t,n,r){const{app:s}=Dn(e),i=new FormData;i.set("app_name",s),i.set("user_id",t),i.set("session_id",n),i.set("file",r);const a=await rt("/web/media",{method:"POST",body:i},{},Tx);if(!a.ok)throw new Error(await xn(a,"文件上传失败"));return{...await a.json(),status:"ready"}}async function Yb(e,t,n){const{app:r}=Dn(e),s=`/web/media/${encodeURIComponent(r)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,i=await rt(s,{method:"DELETE"});if(!i.ok&&i.status!==404)throw new Error(await xn(i,"media cleanup failed"))}function nL(e){try{const t=new URL(e);if(t.protocol!=="veadk-media:"||t.hostname!=="apps")return;const n=t.pathname.split("/").filter(Boolean).map(decodeURIComponent);return n.length!==7||n[1]!=="users"||n[3]!=="sessions"||n[5]!=="media"?void 0:`/web/media/${n.map(encodeURIComponent).filter((r,s)=>![1,3,5].includes(s)).join("/")}`}catch{return}}async function Ph(e,t){const n=nL(t);if(!n)throw new Error("Invalid VeADK media URI");const r=await rt(n,{method:"DELETE"});if(!r.ok&&r.status!==404)throw new Error(await xn(r,"media cleanup failed"))}function rL(e,t){if(t.startsWith("data:")||t.startsWith("blob:")||/^https?:/.test(t))return t;const n=nL(t);if(!n)return t;const r=`${n}/content`;return si(`${Dh}${r}`)}async function sL(e,t){const{app:n,ep:r}=Dn(e),s=await rt(`/dev/apps/${encodeURIComponent(n)}/debug/trace/session/${encodeURIComponent(t)}`,{},r);if(!s.ok)throw new Error(`trace failed: ${s.status}`);const i=s.headers.get("content-type")??"";if(!i.includes("application/json")){const o=i.split(";",1)[0]||"Content-Type 缺失";throw new Error(`trace failed: 服务端返回了非 JSON 响应(${o}),请检查 Studio API 代理配置`)}const a=await s.json();if(!Array.isArray(a))throw new Error("trace failed: 返回格式无效");return a}function Cx(e){const t=n=>({id:String(n.id??""),kind:n.kind==="skill"?"skill":"tool",name:String(n.name??""),custom:n.custom===!0,description:typeof n.description=="string"?n.description:void 0,skillSourceId:typeof n.skill_source_id=="string"?n.skill_source_id:void 0,version:typeof n.version=="string"?n.version:void 0});return{schemaVersion:Number(e.schema_version??1),revision:Number(e.revision??0),tools:Array.isArray(e.tools)?e.tools.map(n=>t(n)):[],skills:Array.isArray(e.skills)?e.skills.map(n=>t(n)):[]}}function Ix(e,t,n){return`/harness/apps/${encodeURIComponent(e)}/users/${encodeURIComponent(t)}/sessions/${encodeURIComponent(n)}/capabilities`}async function iL(e,t,n){const{app:r,ep:s}=Dn(e),i=await rt(Ix(r,t,n),{},s);if(!i.ok)throw new Error(await xn(i,"读取会话能力失败"));return Cx(await i.json())}async function aL(e){const{ep:t}=Dn(e),n=await rt("/harness/capabilities/tools",{},t);if(!n.ok)throw new Error(await xn(n,"读取内置工具失败"));return((await n.json()).tools??[]).map(s=>{var i;return((i=s.name)==null?void 0:i.trim())??""}).filter(Boolean)}async function i$(e){const{ep:t}=Dn(e),n=await rt("/harness/skills/spaces?region=all",{},t);if(!n.ok)throw new Error(await xn(n,"读取 Skill Space 失败"));return(await n.json()).items??[]}async function a$(e,t,n){const{ep:r}=Dn(e),s=new URLSearchParams({region:n||"cn-beijing"}),i=`/harness/skills/spaces/${encodeURIComponent(t)}/skills?${s.toString()}`,a=await rt(i,{},r);if(!a.ok)throw new Error(await xn(a,"读取 Skill 列表失败"));return(await a.json()).items??[]}async function oL(e,t,n=1,r=20){const{ep:s}=Dn(e),i=new URLSearchParams({query:t,page_number:String(n),page_size:String(r)}),a=await rt(`/harness/skills/findskill?${i.toString()}`,{},s);if(!a.ok)throw new Error(await xn(a,"搜索 Skill Hub 失败"));const o=await a.json();return{items:o.items??[],totalCount:Number(o.totalCount??0)}}async function lL(e,t,n,r,s){const{app:i,ep:a}=Dn(e),o=await rt(Ix(i,t,n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:r.kind,name:r.name,skill_source_id:r.skillSourceId,description:r.description,version:r.version,expected_revision:s})},a);if(!o.ok)throw new Error(await xn(o,"添加会话能力失败"));return Cx(await o.json())}async function cL(e,t,n,r,s){const{app:i,ep:a}=Dn(e),o=`${Ix(i,t,n)}/${encodeURIComponent(r)}?expected_revision=${s}`,c=await rt(o,{method:"DELETE"},a);if(!c.ok)throw new Error(await xn(c,"移除会话能力失败"));return Cx(await c.json())}async function uL(e,t){const n=await rt(`/web/agent-info/${e}`,{},t);if(!n.ok)throw new Error(`agent-info failed: ${n.status}`);const r=await n.json();return{name:r.name??e,description:r.description??"",type:r.type,model:r.model??"",tools:r.tools??[],skills:r.skills??[],subAgents:r.subAgents??[],components:r.components??[],searchSources:r.searchSources??[],graph:r.graph}}async function Rx(e){const{app:t,ep:n}=Dn(e);return uL(t,n)}async function dL(e,t){const n={runtimeId:e,region:t},s=(await Fm("","",n))[0];if(!s)throw new Error("该 Runtime 未提供可预览的 Agent。");return uL(s,n)}async function fL(e,t,n,r){const{app:s,ep:i}=Dn(e),a=new URLSearchParams({source:t,app_name:s,q:n,user_id:r}),o=await rt(`/web/search?${a.toString()}`,{},i);if(!o.ok)throw new Error(await xn(o,"Agent 检索失败"));return o.json()}async function hL(e,t){const{app:n}=Dn(e),r=await rt(`/web/search?source=web&app_name=${encodeURIComponent(n)}&q=${encodeURIComponent(t)}`);if(!r.ok)throw new Error(`web search failed: ${r.status}`);return r.json()}async function*cd({appName:e,userId:t,sessionId:n,text:r,attachments:s=[],invocation:i,functionResponses:a=[],signal:o,sessionCapabilities:c=!1}){const{app:u,ep:d}=Dn(e),f=s.flatMap(g=>g.status&&g.status!=="ready"?[]:g.uri?[{fileData:{mimeType:g.mimeType,fileUri:g.uri,displayName:g.name},partMetadata:{veadkMedia:{id:g.id,uri:g.uri,name:g.name,mimeType:g.mimeType,sizeBytes:g.sizeBytes}}}]:g.data?[{inlineData:{mimeType:g.mimeType,data:g.data,displayName:g.name}}]:[]),h=i&&(i.skills.length>0||i.targetAgent)?i:void 0,p=[...f,...a.map(g=>({functionResponse:{id:g.id,name:g.name,response:g.response}})),...r.trim()?[{text:r}]:[]];if(h&&p.length>0){const g=p[0],x=g.partMetadata;p[0]={...g,partMetadata:{...x,veadkInvocation:h}}}const m=await rt(c?"/harness/run_sse":"/run_sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:u,user_id:t,session_id:n,new_message:{role:"user",parts:p},streaming:!0,custom_metadata:h?{veadkInvocation:h}:void 0}),signal:o},d,0);if(!m.ok)throw new Error(Hf(`run_sse failed: ${m.status}`));for await(const g of Sx(m)){const x=g;typeof x.error=="string"&&(x.error=Hf(x.error)),typeof x.errorMessage=="string"&&(x.errorMessage=Hf(x.errorMessage)),typeof x.error_message=="string"&&(x.error_message=Hf(x.error_message)),yield x}}const Tu=new Map;async function Um(e,t,n,r){var u,d,f;const s=r==null?void 0:r.taskId,i=s?new AbortController:void 0;s&&i&&Tu.set(s,i);const a=()=>{s&&Tu.get(s)===i&&Tu.delete(s)};let o;try{(u=r==null?void 0:r.onStage)==null||u.call(r,{level:"info",phase:"upload",message:"正在上传代码包",pct:0}),o=await rt("/web/deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},signal:i==null?void 0:i.signal,body:JSON.stringify({name:e,files:t,config:n,taskId:s,im:r==null?void 0:r.im,envs:r==null?void 0:r.envs})},{},0),(d=r==null?void 0:r.onStage)==null||d.call(r,{level:"success",phase:"upload",message:"代码包上传完成",pct:100})}catch(h){throw a(),h}if(!o.ok){const h=await o.text().catch(()=>"");throw a(),new Error(h||`部署失败 (${o.status})`)}let c=null;try{for await(const h of Sx(o)){const p=h;if(p&&p.done){c=p;break}p&&p.message&&((f=r==null?void 0:r.onStage)==null||f.call(r,p))}}catch(h){throw a(),h}if(a(),!c)throw new Error("部署失败:连接中断");if(!c.success)throw new Error(c.error||"部署失败");if(!c.agentName)throw new Error("部署失败:返回缺少 Agent 名称");if(!c.runtimeId&&!c.url)throw new Error("部署失败:返回缺少 AgentKit 连接信息");return{apikey:c.apikey??"",url:c.url??"",agentName:c.agentName,runtimeId:c.runtimeId,consoleUrl:c.consoleUrl,region:c.region,feishuChannel:c.feishuChannel}}async function pL(e){var n;const t=await rt("/web/cancel-deploy-agentkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e})});if(!t.ok){const r=await t.text().catch(()=>"");throw new Error(r||`取消部署失败 (${t.status})`)}(n=Tu.get(e))==null||n.abort(),Tu.delete(e)}async function mL(e="cn-beijing"){const t=await rt(`/web/my-runtimes?region=${encodeURIComponent(e)}`);if(!t.ok)throw new Error(`加载失败 (${t.status})`);return(await t.json()).runtimes??[]}const ud={title:"VeADK Studio",logoUrl:""},T0={studio:!1,version:"",branding:ud,features:{newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,addAgentkit:!0,generatedAgentTestRun:!0},defaultView:"chat",agentsSource:"local"};async function gL(){var e,t;try{const n=await rt("/web/ui-config");if(!n.ok)return T0;const r=await n.json(),s=typeof((e=r.branding)==null?void 0:e.logoUrl)=="string"?r.branding.logoUrl:ud.logoUrl;return{studio:r.studio??!1,version:typeof r.version=="string"?r.version:"",branding:{title:typeof((t=r.branding)==null?void 0:t.title)=="string"?r.branding.title:ud.title,logoUrl:s?si(s):""},features:{...T0.features,...r.features??{}},defaultView:r.defaultView??"chat",agentsSource:r.agentsSource==="cloud"?"cloud":"local"}}catch{return T0}}const yL={role:"user",capabilities:{createAgents:!1,manageAgents:!1,runtimeScope:"mine"}};async function bL(){var n,r,s;const e=await rt("/web/access");if(!e.ok)throw new Error(`加载权限失败 (${e.status})`);const t=await e.json();if(!["admin","developer","user"].includes(t.role)||typeof((n=t.capabilities)==null?void 0:n.createAgents)!="boolean"||typeof((r=t.capabilities)==null?void 0:r.manageAgents)!="boolean"||!["all","mine"].includes((s=t.capabilities)==null?void 0:s.runtimeScope))throw new Error("权限服务返回了无法解析的响应");return t}async function EL(e,t){const n=new URLSearchParams;e&&n.set("targetVersion",e),t&&n.set("startedAt",String(t));const r=n.size?`?${n.toString()}`:"",s=await rt(`/web/studio-update${r}`);if(!s.ok)throw new Error(`检查 Studio 更新失败 (${s.status})`);return await s.json()}async function xL(e){const t=await rt("/web/studio-update",{method:"POST",headers:{"Content-Type":"application/json","X-VeADK-Studio-Update":"1"},body:JSON.stringify({version:e})},{},Tx);if(!t.ok){let n="";try{const r=await t.json();n=typeof r.detail=="string"?r.detail:""}catch{n=""}throw new Error(n||`提交 Studio 更新失败 (${t.status})`)}return await t.json()}async function jh(e={}){const t=new URLSearchParams({scope:e.scope??"all",page_size:String(e.pageSize??30),region:e.region??"all"});e.nextToken&&t.set("next_token",e.nextToken);const n=await rt(`/web/runtimes?${t.toString()}`);if(!n.ok)throw new Error(`加载 Runtime 失败 (${n.status})`);const r=await n.json();return{runtimes:r.runtimes??[],nextToken:r.nextToken??""}}async function wL(e,t="cn-beijing"){try{return await Fm("","",{runtimeId:e,region:t})}catch(n){if(n instanceof Fd||n instanceof ld)throw n;return null}}async function vL(e,t="cn-beijing"){const n=await rt("/web/delete-runtime",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runtimeId:e,region:t})});if(!n.ok){const r=await n.text().catch(()=>"");throw new Error(r||`删除失败 (${n.status})`)}}async function Lx(e,t="cn-beijing"){const n=await rt(`/web/runtime-detail?runtimeId=${encodeURIComponent(e)}®ion=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(await xn(n,"加载 Runtime 详情失败"));return n.json()}async function Bp(e){const t=await rt("/web/generated-agent-projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await xn(t,"生成项目失败"));return t.json()}async function _L(e){const t=await rt("/web/generated-agent-test-runs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e})});if(!t.ok)throw new Error(await xn(t,"创建调试运行失败"));return WR(t,"创建调试运行失败")}async function kL(e,t){const n=await rt(`/web/generated-agent-test-runs/${e}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:t})});if(!n.ok)throw new Error(await xn(n,"创建调试会话失败"));return(await WR(n,"创建调试会话失败")).id}async function*TL({runId:e,userId:t,sessionId:n,text:r,signal:s}){const i=r.trim()?[{text:r}]:[],a=await rt(`/web/generated-agent-test-runs/${e}/run_sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_id:t,session_id:n,new_message:{role:"user",parts:i},streaming:!0}),signal:s},{},0);if(!a.ok)throw new Error(await xn(a,"调试运行失败"));for await(const o of Sx(a))yield o}async function Wb(e){const t=await rt(`/web/generated-agent-test-runs/${e}`,{method:"DELETE"});if(!t.ok&&t.status!==404)throw new Error(await xn(t,"清理调试运行失败"))}const o$=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SITE_BRANDING:ud,DEFAULT_STUDIO_ACCESS:yL,RuntimeAccessDeniedError:Fd,RuntimeProbeError:ld,addSessionCapability:lL,cancelAgentkitDeployment:pL,clearRemoteApps:ZR,componentSearch:fL,createGeneratedAgentTestRun:_L,createGeneratedAgentTestSession:kL,createSession:Pp,deleteGeneratedAgentTestRun:Wb,deleteMedia:Ph,deleteRuntime:vL,deleteSession:Kb,deleteSessionMedia:Yb,deployAgentkitProject:Um,fetchRemoteApps:Fm,generateAgentProject:Bp,getAgentInfo:Rx,getMediaCapabilities:s$,getMyRuntimes:mL,getRuntimeAgentInfo:dL,getRuntimeDetail:Lx,getRuntimes:jh,getSession:jp,getSessionCapabilities:iL,getSessionTrace:sL,getStudioAccess:bL,getStudioUpdateStatus:EL,getUiConfig:gL,listApps:JR,listSessionBuiltinTools:aL,listSessionSkillSpaces:i$,listSessionSkillsInSpace:a$,listSessions:Ax,mediaContentUrl:rL,probeRuntimeApps:wL,registerRemoteApp:QR,removeSessionCapability:cL,runGeneratedAgentTestSSE:TL,runSSE:cd,searchSessionPublicSkills:oL,startStudioUpdate:xL,submitMessageFeedback:eL,uploadMedia:tL,webSearch:hL},Symbol.toStringTag,{value:"Module"})),l$="send_a2ui_json_to_client",c$="validated_a2ui_json",qb="adk_request_credential",qk="transfer_to_agent";function u$(e){var r,s,i,a;const t=e,n=((r=t==null?void 0:t.exchangedAuthCredential)==null?void 0:r.oauth2)??((s=t==null?void 0:t.exchanged_auth_credential)==null?void 0:s.oauth2)??((i=t==null?void 0:t.rawAuthCredential)==null?void 0:i.oauth2)??((a=t==null?void 0:t.raw_auth_credential)==null?void 0:a.oauth2);return(n==null?void 0:n.authUri)??(n==null?void 0:n.auth_uri)}function Ns(){return{blocks:[],liveStart:0}}const Gk=e=>e.functionCall??e.function_call,Gb=e=>e.functionResponse??e.function_response;function d$(e){if(!e||typeof e!="object")return"";const t=e,n=t.agentName??t.agent_name;return typeof n=="string"?n:""}function f$(e){return e.replace(/-/g,"+").replace(/_/g,"/")}function SL(e){const t=[];for(const[n,r]of e.entries()){const s=r.partMetadata??r.part_metadata,i=s==null?void 0:s.veadkTransport;if((i==null?void 0:i.hidden)===!0)continue;const a=s==null?void 0:s.veadkMedia;if(typeof(a==null?void 0:a.uri)=="string"){t.push({id:String(a.id??a.uri),mimeType:typeof a.mimeType=="string"?a.mimeType:void 0,uri:a.uri,name:typeof a.name=="string"?a.name:void 0,sizeBytes:typeof a.sizeBytes=="number"?a.sizeBytes:void 0});continue}const o=r.inlineData??r.inline_data;if(o&&o.data){t.push({id:`inline-${n}-${o.displayName??o.display_name??"media"}`,mimeType:o.mimeType??o.mime_type,data:f$(o.data),name:o.displayName??o.display_name});continue}const c=r.fileData??r.file_data,u=(c==null?void 0:c.fileUri)??(c==null?void 0:c.file_uri);c&&u&&t.push({id:u,mimeType:c.mimeType??c.mime_type,uri:u,name:c.displayName??c.display_name})}return t}function Xb(e){const t=e.partMetadata??e.part_metadata,n=t==null?void 0:t.veadkTransport;return(n==null?void 0:n.hideText)===!0?void 0:e.text}const h$=new Set(["llm","sequential","parallel","loop","a2a"]);function p$(e){var t;for(const n of e){const r=(t=n.partMetadata??n.part_metadata)==null?void 0:t.veadkInvocation;if(!r||typeof r!="object")continue;const s=r,i=Array.isArray(s.skills)?s.skills.flatMap(c=>{if(!c||typeof c!="object")return[];const u=c;return typeof u.name=="string"?[{name:u.name,description:typeof u.description=="string"?u.description:""}]:[]}):[];let a;const o=s.targetAgent;if(o&&typeof o=="object"){const c=o,u=c.type;typeof c.name=="string"&&typeof u=="string"&&h$.has(u)&&Array.isArray(c.path)&&(a={name:c.name,description:typeof c.description=="string"?c.description:"",type:u,path:c.path.filter(d=>typeof d=="string")})}if(i.length>0||a)return{skills:i,targetAgent:a}}}function m$(e,t){if(!t.length)return;const n=e[e.length-1];(n==null?void 0:n.kind)==="attachment"?n.files.push(...t):e.push({kind:"attachment",files:t})}function Xk(e,t,n){const r=e[e.length-1];r&&r.kind===t?r.text+=n:e.push(t==="thinking"?{kind:t,text:n,done:!1}:{kind:t,text:n})}function zf(e){for(const t of e)t.kind==="thinking"&&(t.done=!0)}function zl(e,t){var a,o,c,u;const n=e.blocks.map(d=>({...d}));let r=e.liveStart;const s=((a=t.content)==null?void 0:a.parts)??[],i=s.some(d=>Gk(d)||Gb(d));if(t.partial&&!i){for(const d of s){const f=Xb(d);typeof f=="string"&&f&&Xk(n,d.thought?"thinking":"text",f)}return{blocks:n,liveStart:r}}n.length=r;for(const d of s){const f=Gk(d),h=Gb(d),p=SL([d]),m=Xb(d);if(typeof m=="string"&&m)Xk(n,d.thought?"thinking":"text",m);else if(p.length)zf(n),m$(n,p);else if(f)if(zf(n),f.name===qk){const g=d$(f.args)||((o=t.actions)==null?void 0:o.transferToAgent)||((c=t.actions)==null?void 0:c.transfer_to_agent)||"未知 Agent";n.push({kind:"agent-transfer",agentName:g,done:!1})}else if(f.name===qb){const g=f.args??{},x=g.authConfig??g.auth_config??g,E=String(g.functionCallId??g.function_call_id??"").replace(/^_adk_toolset_auth_/,"")||void 0;n.push({kind:"auth",callId:f.id??"",label:E,authUri:u$(x),authConfig:x,done:!1})}else n.push({kind:"tool",name:f.name??"",args:f.args,done:!1});else if(h){if(zf(n),h.name===qk)for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="agent-transfer"&&!x.done){x.done=!0;break}}if(h.name===qb)for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="auth"&&!x.done){x.done=!0;break}}for(let g=n.length-1;g>=0;g--){const x=n[g];if(x.kind==="tool"&&!x.done&&x.name===h.name){x.done=!0,x.response=h.response;break}}if(h.name===l$){const g=((u=h.response)==null?void 0:u[c$])??[];if(g.length){const x=n[n.length-1];x&&x.kind==="a2ui"?x.messages.push(...g):n.push({kind:"a2ui",messages:g})}}}}return zf(n),r=n.length,{blocks:n,liveStart:r}}function g$(e,t={}){var s,i;const n=[];let r=Ns();for(const a of e)if(a.author==="user"){const c=((s=a.content)==null?void 0:s.parts)??[];if(c.some(p=>{var m;return((m=Gb(p))==null?void 0:m.name)===qb})){for(let p=n.length-1;p>=0;p--)if(n[p].role==="assistant"){for(let m=n[p].blocks.length-1;m>=0;m--){const g=n[p].blocks[m];if(g.kind==="auth"){g.done=!0;break}}break}}const u=c.map(Xb).filter(p=>!!p).join(""),d=SL(c),f=p$(c);if(!u&&!d.length&&!f){r=Ns();continue}const h=[];f&&h.push({kind:"invocation",value:f}),d.length&&h.push({kind:"attachment",files:d}),u&&h.push({kind:"text",text:u}),n.push({role:"user",blocks:h,meta:{ts:a.timestamp}}),r=Ns()}else{const c=a.author??"";let u=n[n.length-1];(!u||u.role!=="assistant"||c&&((i=u.meta)==null?void 0:i.author)!==c)&&(u={role:"assistant",blocks:[],meta:{author:c||void 0}},n.push(u),r=Ns()),r=zl(r,a),u.blocks=r.blocks;const d=a.usageMetadata??a.usage_metadata,f=u.meta??(u.meta={});c&&(f.author=c),d!=null&&d.totalTokenCount&&(f.tokens=d.totalTokenCount),a.timestamp&&(f.ts=a.timestamp),a.id&&(f.eventId=a.id);const h=a.invocationId??a.invocation_id;h&&(f.invocationId=h)}for(const a of n){const o=a.meta,c=o==null?void 0:o.eventId;if(!c)continue;const u=t[`veadk_feedback:${c}`];if(!u||typeof u!="object")continue;const d=u;d.rating!=="good"&&d.rating!=="bad"||(o.feedback=u)}return n}function y$(e){var t,n;for(const r of e??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const s=(((n=r.content)==null?void 0:n.parts)??[]).map(i=>i.text).find(Boolean);if(s)return s}return"新会话"}async function Ud(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine AK/SK,无法访问 AgentKit Skills 中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit Skills 中心");if(t.status===404)throw new Error("技能不存在或无 SKILL.md 内容");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function NL(){return(await Ud("/web/skill-spaces?region=all")).items||[]}async function b$(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),Ud(`/web/skill-spaces?${t.toString()}`)}async function AL(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function E$(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),Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function x$(e,t,n,r,s){const i=[];n&&i.push(`version=${encodeURIComponent(n)}`),r&&i.push(`region=${encodeURIComponent(r)}`),s&&i.push(`project=${encodeURIComponent(s)}`);const a=i.length>0?`?${i.join("&")}`:"";return Ud(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${a}`)}function w$(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 v$(e,t){return`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}function Ghe(){}function Qk(e){const t=[],n=String(e||"");let r=n.indexOf(","),s=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const a=n.slice(s,r).trim();(a||!i)&&t.push(a),s=r+1,r=n.indexOf(",",s)}return t}function CL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _$=/[$_\p{ID_Start}]/u,k$=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,T$=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,S$=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,N$=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IL={};function Xhe(e){return e?_$.test(String.fromCodePoint(e)):!1}function Qhe(e,t){const r=(t||IL).jsx?T$:k$;return e?r.test(String.fromCodePoint(e)):!1}function Zk(e,t){return(IL.jsx?N$:S$).test(e)}const A$=/[ \t\n\f\r]/g;function C$(e){return typeof e=="object"?e.type==="text"?Jk(e.value):!1:Jk(e)}function Jk(e){return e.replace(A$,"")===""}let $d=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};$d.prototype.normal={};$d.prototype.property={};$d.prototype.space=void 0;function RL(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new $d(n,r,t)}function dd(e){return e.toLowerCase()}class Or{constructor(t,n){this.attribute=n,this.property=t}}Or.prototype.attribute="";Or.prototype.booleanish=!1;Or.prototype.boolean=!1;Or.prototype.commaOrSpaceSeparated=!1;Or.prototype.commaSeparated=!1;Or.prototype.defined=!1;Or.prototype.mustUseProperty=!1;Or.prototype.number=!1;Or.prototype.overloadedBoolean=!1;Or.prototype.property="";Or.prototype.spaceSeparated=!1;Or.prototype.space=void 0;let I$=0;const Je=To(),_n=To(),Qb=To(),ve=To(),It=To(),Tl=To(),Br=To();function To(){return 2**++I$}const Zb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:_n,commaOrSpaceSeparated:Br,commaSeparated:Tl,number:ve,overloadedBoolean:Qb,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),S0=Object.keys(Zb);class Ox extends Or{constructor(t,n,r,s){let i=-1;if(super(t,n),eT(this,"space",s),typeof r=="number")for(;++i4&&n.slice(0,4)==="data"&&D$.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(tT,j$);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!tT.test(i)){let a=i.replace(M$,P$);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Ox}return new s(r,t)}function P$(e){return"-"+e.toLowerCase()}function j$(e){return e.charAt(1).toUpperCase()}const Hd=RL([LL,R$,DL,PL,jL],"html"),Ca=RL([LL,L$,DL,PL,jL],"svg");function nT(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function BL(e){return e.join(" ").trim()}var Mx={},rT=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,B$=/\n/g,F$=/^\s*/,U$=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$$=/^:\s*/,H$=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,z$=/^[;\s]*/,V$=/^\s+|\s+$/g,K$=` `,sT="/",iT="*",Va="",Y$="comment",W$="declaration";function q$(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(m){var g=m.match(B$);g&&(n+=g.length);var x=m.lastIndexOf(K$);r=~x?m.length-x:r+m.length}function i(){var m={line:n,column:r};return function(g){return g.position=new a(m),u(),g}}function a(m){this.start=m,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function o(m){var g=new Error(t.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=t.source,g.line=n,g.column=r,g.source=e,!t.silent)throw g}function c(m){var g=m.exec(e);if(g){var x=g[0];return s(x),e=e.slice(x.length),g}}function u(){c(F$)}function d(m){var g;for(m=m||[];g=f();)g!==!1&&m.push(g);return m}function f(){var m=i();if(!(sT!=e.charAt(0)||iT!=e.charAt(1))){for(var g=2;Va!=e.charAt(g)&&(iT!=e.charAt(g)||sT!=e.charAt(g+1));)++g;if(g+=2,Va===e.charAt(g-1))return o("End of comment missing");var x=e.slice(2,g-2);return r+=2,s(x),e=e.slice(g),r+=2,m({type:Y$,comment:x})}}function h(){var m=i(),g=c(U$);if(g){if(f(),!c($$))return o("property missing ':'");var x=c(H$),y=m({type:W$,property:aT(g[0].replace(rT,Va)),value:x?aT(x[0].replace(rT,Va)):Va});return c(z$),y}}function p(){var m=[];d(m);for(var g;g=h();)g!==!1&&(m.push(g),d(m));return m}return u(),p()}function aT(e){return e?e.replace(V$,Va):Va}var G$=q$,X$=tp&&tp.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mx,"__esModule",{value:!0});Mx.default=Z$;const Q$=X$(G$);function Z$(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Q$.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:o}=i;s?t(a,o,i):o&&(n=n||{},n[a]=o)}),n}var Hm={};Object.defineProperty(Hm,"__esModule",{value:!0});Hm.camelCase=void 0;var J$=/^--[a-zA-Z0-9_-]+$/,eH=/-([a-z])/g,tH=/^[^-]+$/,nH=/^-(webkit|moz|ms|o|khtml)-/,rH=/^-(ms)-/,sH=function(e){return!e||tH.test(e)||J$.test(e)},iH=function(e,t){return t.toUpperCase()},oT=function(e,t){return"".concat(t,"-")},aH=function(e,t){return t===void 0&&(t={}),sH(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(rH,oT):e=e.replace(nH,oT),e.replace(eH,iH))};Hm.camelCase=aH;var oH=tp&&tp.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},lH=oH(Mx),cH=Hm;function Jb(e,t){var n={};return!e||typeof e!="string"||(0,lH.default)(e,function(r,s){r&&s&&(n[(0,cH.camelCase)(r,t)]=s)}),n}Jb.default=Jb;var uH=Jb;const dH=Cd(uH),zm=FL("end"),li=FL("start");function FL(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function fH(e){const t=li(e),n=zm(e);if(t&&n)return{start:t,end:n}}function Su(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?lT(e.position):"start"in e||"end"in e?lT(e):"line"in e||"column"in e?e1(e):""}function e1(e){return cT(e&&e.line)+":"+cT(e&&e.column)}function lT(e){return e1(e&&e.start)+"-"+e1(e&&e.end)}function cT(e){return e&&typeof e=="number"?e:1}class ur extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=o?o.line:void 0,this.name=Su(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ur.prototype.file="";ur.prototype.name="";ur.prototype.reason="";ur.prototype.message="";ur.prototype.stack="";ur.prototype.column=void 0;ur.prototype.line=void 0;ur.prototype.ancestors=void 0;ur.prototype.cause=void 0;ur.prototype.fatal=void 0;ur.prototype.place=void 0;ur.prototype.ruleId=void 0;ur.prototype.source=void 0;const Dx={}.hasOwnProperty,hH=new Map,pH=/[A-Z]/g,mH=new Set(["table","tbody","thead","tfoot","tr"]),gH=new Set(["td","th"]),UL="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function yH(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=TH(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=kH(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ca:Hd,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=$L(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function $L(e,t,n){if(t.type==="element")return bH(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return EH(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return wH(e,t,n);if(t.type==="mdxjsEsm")return xH(e,t);if(t.type==="root")return vH(e,t,n);if(t.type==="text")return _H(e,t)}function bH(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Ca,e.schema=s),e.ancestors.push(t);const i=zL(e,t.tagName,!1),a=SH(e,t);let o=jx(e,t);return mH.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!C$(c):!0})),HL(e,a,i,t),Px(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function EH(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}fd(e,t.position)}function xH(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);fd(e,t.position)}function wH(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Ca,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:zL(e,t.name,!0),a=NH(e,t),o=jx(e,t);return HL(e,a,i,t),Px(a,o),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function vH(e,t,n){const r={};return Px(r,jx(e,t)),e.create(t,e.Fragment,r,n)}function _H(e,t){return t.value}function HL(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Px(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function kH(e,t,n){return r;function r(s,i,a,o){const u=Array.isArray(a.children)?n:t;return o?u(i,a,o):u(i,a)}}function TH(e,t){return n;function n(r,s,i,a){const o=Array.isArray(i.children),c=li(r);return t(s,i,a,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function SH(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Dx.call(t.properties,s)){const i=AH(e,s,t.properties[s]);if(i){const[a,o]=i;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&gH.has(t.tagName)?r=o:n[a]=o}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function NH(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else fd(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,i=e.evaluater.evaluateExpression(o.expression)}else fd(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function jx(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:hH;for(;++rs?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i0?(Vr(e,e.length,0,t),e):t}const fT={}.hasOwnProperty;function KL(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Os(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yr=Ia(/[A-Za-z]/),lr=Ia(/[\dA-Za-z]/),jH=Ia(/[#-'*+\--9=?A-Z^-~]/);function Fp(e){return e!==null&&(e<32||e===127)}const t1=Ia(/\d/),BH=Ia(/[\dA-Fa-f]/),FH=Ia(/[!-/:-@[-`{-~]/);function ze(e){return e!==null&&e<-2}function At(e){return e!==null&&(e<0||e===32)}function it(e){return e===-2||e===-1||e===32}const Vm=Ia(new RegExp("\\p{P}|\\p{S}","u")),po=Ia(/\s/);function Ia(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function bc(e){const t=[];let n=-1,r=0,s=0;for(;++n55295&&i<57344){const o=e.charCodeAt(n+1);i<56320&&o>56319&&o<57344?(a=String.fromCharCode(i,o),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function dt(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return it(c)?(e.enter(n),o(c)):t(c)}function o(c){return it(c)&&i++a))return;const A=t.events.length;let N=A,S,C;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(S){C=t.events[N][1].end;break}S=!0}for(y(r),T=A;Tb;){const k=n[_];t.containerState=k[1],k[0].exit.call(t,e)}n.length=b}function E(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function VH(e,t,n){return dt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vl(e){if(e===null||At(e)||po(e))return 1;if(Vm(e))return 2}function Km(e,t,n){const r=[];let s=-1;for(;++s1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};pT(f,-c),pT(h,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=ss(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=ss(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),u=ss(u,Km(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=ss(u,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=ss(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Vr(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n0&&it(T)?dt(e,E,"linePrefix",i+1)(T):E(T)}function E(T){return T===null||ze(T)?e.check(mT,g,_)(T):(e.enter("codeFlowValue"),b(T))}function b(T){return T===null||ze(T)?(e.exit("codeFlowValue"),E(T)):(e.consume(T),b)}function _(T){return e.exit("codeFenced"),t(T)}function k(T,A,N){let S=0;return C;function C(D){return T.enter("lineEnding"),T.consume(D),T.exit("lineEnding"),M}function M(D){return T.enter("codeFencedFence"),it(D)?dt(T,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):U(D)}function U(D){return D===o?(T.enter("codeFencedFenceSequence"),q(D)):N(D)}function q(D){return D===o?(S++,T.consume(D),q):S>=a?(T.exit("codeFencedFenceSequence"),it(D)?dt(T,P,"whitespace")(D):P(D)):N(D)}function P(D){return D===null||ze(D)?(T.exit("codeFencedFence"),A(D)):N(D)}}}function nz(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const A0={name:"codeIndented",tokenize:sz},rz={partial:!0,tokenize:iz};function sz(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),dt(e,i,"linePrefix",5)(u)}function i(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):ze(u)?e.attempt(rz,a,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||ze(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function iz(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):ze(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):dt(e,i,"linePrefix",5)(a)}function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):ze(a)?s(a):n(a)}}const az={name:"codeText",previous:lz,resolve:oz,tokenize:cz};function oz(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&$c(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),$c(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),$c(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function QL(e,t,n,r,s,i,a,o,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),h):y===null||y===32||y===41||Fp(y)?n(y):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),g(y))}function h(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(o),h(y)):y===null||y===60||ze(y)?n(y):(e.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function g(y){return!d&&(y===null||y===41||At(y))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(y)):d999||p===null||p===91||p===93&&!c||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(i),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):ze(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||ze(p)||o++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!it(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function JL(e,t,n,r,s,i){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),a=h===40?41:h,c):n(h)}function c(h){return h===a?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(i),u(h))}function u(h){return h===a?(e.exit(i),c(a)):h===null?n(h):ze(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),dt(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||ze(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function Nu(e,t){let n;return r;function r(s){return ze(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):it(s)?dt(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const yz={name:"definition",tokenize:Ez},bz={partial:!0,tokenize:xz};function Ez(e,t,n){const r=this;let s;return i;function i(p){return e.enter("definition"),a(p)}function a(p){return ZL.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return s=Os(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return At(p)?Nu(e,u)(p):u(p)}function u(p){return QL(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(bz,f,f)(p)}function f(p){return it(p)?dt(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ze(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function xz(e,t,n){return r;function r(o){return At(o)?Nu(e,s)(o):n(o)}function s(o){return JL(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function i(o){return it(o)?dt(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ze(o)?t(o):n(o)}}const wz={name:"hardBreakEscape",tokenize:vz};function vz(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return ze(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const _z={name:"headingAtx",resolve:kz,tokenize:Tz};function kz(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Vr(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function Tz(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||At(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||ze(d)?(e.exit("atxHeading"),t(d)):it(d)?dt(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||At(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const Sz=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],yT=["pre","script","style","textarea"],Nz={concrete:!0,name:"htmlFlow",resolveTo:Iz,tokenize:Rz},Az={partial:!0,tokenize:Oz},Cz={partial:!0,tokenize:Lz};function Iz(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Rz(e,t,n){const r=this;let s,i,a,o,c;return u;function u(j){return d(j)}function d(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),f}function f(j){return j===33?(e.consume(j),h):j===47?(e.consume(j),i=!0,g):j===63?(e.consume(j),s=3,r.interrupt?t:R):yr(j)?(e.consume(j),a=String.fromCharCode(j),x):n(j)}function h(j){return j===45?(e.consume(j),s=2,p):j===91?(e.consume(j),s=5,o=0,m):yr(j)?(e.consume(j),s=4,r.interrupt?t:R):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:R):n(j)}function m(j){const re="CDATA[";return j===re.charCodeAt(o++)?(e.consume(j),o===re.length?r.interrupt?t:U:m):n(j)}function g(j){return yr(j)?(e.consume(j),a=String.fromCharCode(j),x):n(j)}function x(j){if(j===null||j===47||j===62||At(j)){const re=j===47,V=a.toLowerCase();return!re&&!i&&yT.includes(V)?(s=1,r.interrupt?t(j):U(j)):Sz.includes(a.toLowerCase())?(s=6,re?(e.consume(j),y):r.interrupt?t(j):U(j)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):i?E(j):b(j))}return j===45||lr(j)?(e.consume(j),a+=String.fromCharCode(j),x):n(j)}function y(j){return j===62?(e.consume(j),r.interrupt?t:U):n(j)}function E(j){return it(j)?(e.consume(j),E):C(j)}function b(j){return j===47?(e.consume(j),C):j===58||j===95||yr(j)?(e.consume(j),_):it(j)?(e.consume(j),b):C(j)}function _(j){return j===45||j===46||j===58||j===95||lr(j)?(e.consume(j),_):k(j)}function k(j){return j===61?(e.consume(j),T):it(j)?(e.consume(j),k):b(j)}function T(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),c=j,A):it(j)?(e.consume(j),T):N(j)}function A(j){return j===c?(e.consume(j),c=null,S):j===null||ze(j)?n(j):(e.consume(j),A)}function N(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||At(j)?k(j):(e.consume(j),N)}function S(j){return j===47||j===62||it(j)?b(j):n(j)}function C(j){return j===62?(e.consume(j),M):n(j)}function M(j){return j===null||ze(j)?U(j):it(j)?(e.consume(j),M):n(j)}function U(j){return j===45&&s===2?(e.consume(j),I):j===60&&s===1?(e.consume(j),L):j===62&&s===4?(e.consume(j),z):j===63&&s===3?(e.consume(j),R):j===93&&s===5?(e.consume(j),B):ze(j)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(Az,Y,q)(j)):j===null||ze(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),U)}function q(j){return e.check(Cz,P,Y)(j)}function P(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),D}function D(j){return j===null||ze(j)?q(j):(e.enter("htmlFlowData"),U(j))}function I(j){return j===45?(e.consume(j),R):U(j)}function L(j){return j===47?(e.consume(j),a="",O):U(j)}function O(j){if(j===62){const re=a.toLowerCase();return yT.includes(re)?(e.consume(j),z):U(j)}return yr(j)&&a.length<8?(e.consume(j),a+=String.fromCharCode(j),O):U(j)}function B(j){return j===93?(e.consume(j),R):U(j)}function R(j){return j===62?(e.consume(j),z):j===45&&s===2?(e.consume(j),R):U(j)}function z(j){return j===null||ze(j)?(e.exit("htmlFlowData"),Y(j)):(e.consume(j),z)}function Y(j){return e.exit("htmlFlow"),t(j)}}function Lz(e,t,n){const r=this;return s;function s(a){return ze(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Oz(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(zd,t,n)}}const Mz={name:"htmlText",tokenize:Dz};function Dz(e,t,n){const r=this;let s,i,a;return o;function o(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),c}function c(R){return R===33?(e.consume(R),u):R===47?(e.consume(R),k):R===63?(e.consume(R),b):yr(R)?(e.consume(R),N):n(R)}function u(R){return R===45?(e.consume(R),d):R===91?(e.consume(R),i=0,m):yr(R)?(e.consume(R),E):n(R)}function d(R){return R===45?(e.consume(R),p):n(R)}function f(R){return R===null?n(R):R===45?(e.consume(R),h):ze(R)?(a=f,L(R)):(e.consume(R),f)}function h(R){return R===45?(e.consume(R),p):f(R)}function p(R){return R===62?I(R):R===45?h(R):f(R)}function m(R){const z="CDATA[";return R===z.charCodeAt(i++)?(e.consume(R),i===z.length?g:m):n(R)}function g(R){return R===null?n(R):R===93?(e.consume(R),x):ze(R)?(a=g,L(R)):(e.consume(R),g)}function x(R){return R===93?(e.consume(R),y):g(R)}function y(R){return R===62?I(R):R===93?(e.consume(R),y):g(R)}function E(R){return R===null||R===62?I(R):ze(R)?(a=E,L(R)):(e.consume(R),E)}function b(R){return R===null?n(R):R===63?(e.consume(R),_):ze(R)?(a=b,L(R)):(e.consume(R),b)}function _(R){return R===62?I(R):b(R)}function k(R){return yr(R)?(e.consume(R),T):n(R)}function T(R){return R===45||lr(R)?(e.consume(R),T):A(R)}function A(R){return ze(R)?(a=A,L(R)):it(R)?(e.consume(R),A):I(R)}function N(R){return R===45||lr(R)?(e.consume(R),N):R===47||R===62||At(R)?S(R):n(R)}function S(R){return R===47?(e.consume(R),I):R===58||R===95||yr(R)?(e.consume(R),C):ze(R)?(a=S,L(R)):it(R)?(e.consume(R),S):I(R)}function C(R){return R===45||R===46||R===58||R===95||lr(R)?(e.consume(R),C):M(R)}function M(R){return R===61?(e.consume(R),U):ze(R)?(a=M,L(R)):it(R)?(e.consume(R),M):S(R)}function U(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),s=R,q):ze(R)?(a=U,L(R)):it(R)?(e.consume(R),U):(e.consume(R),P)}function q(R){return R===s?(e.consume(R),s=void 0,D):R===null?n(R):ze(R)?(a=q,L(R)):(e.consume(R),q)}function P(R){return R===null||R===34||R===39||R===60||R===61||R===96?n(R):R===47||R===62||At(R)?S(R):(e.consume(R),P)}function D(R){return R===47||R===62||At(R)?S(R):n(R)}function I(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):n(R)}function L(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),O}function O(R){return it(R)?dt(e,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):B(R)}function B(R){return e.enter("htmlTextData"),a(R)}}const Ux={name:"labelEnd",resolveAll:Fz,resolveTo:Uz,tokenize:$z},Pz={tokenize:Hz},jz={tokenize:zz},Bz={tokenize:Vz};function Fz(e){let t=-1;const n=[];for(;++t=3&&(u===null||ze(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),it(u)?dt(e,o,"whitespace")(u):o(u))}}const kr={continuation:{tokenize:eV},exit:nV,name:"list",tokenize:Jz},Qz={partial:!0,tokenize:rV},Zz={partial:!0,tokenize:tV};function Jz(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return o;function o(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:t1(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Bh,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return t1(p)&&++a<10?(e.consume(p),c):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(zd,r.interrupt?n:d,e.attempt(Qz,h,f))}function d(p){return r.containerState.initialBlankLine=!0,i++,h(p)}function f(p){return it(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function eV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(zd,s,i);function s(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,dt(e,t,"listItemIndent",r.containerState.size+1)(o)}function i(o){return r.containerState.furtherBlankLines||!it(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Zz,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,dt(e,e.attempt(kr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function tV(e,t,n){const r=this;return dt(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function nV(e){e.exit(this.containerState.type)}function rV(e,t,n){const r=this;return dt(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!it(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const bT={name:"setextUnderline",resolveTo:sV,tokenize:iV};function sV(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function iV(e,t,n){const r=this;let s;return i;function i(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===s?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),it(u)?dt(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||ze(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const aV={tokenize:oV};function oV(e){const t=this,n=e.attempt(zd,r,e.attempt(this.parser.constructs.flowInitial,s,dt(e,e.attempt(this.parser.constructs.flow,s,e.attempt(fz,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const lV={resolveAll:tO()},cV=eO("string"),uV=eO("text");function eO(e){return{resolveAll:tO(e==="text"?dV:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,o);return a;function a(d){return u(d)?i(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let h=-1;if(f)for(;++h-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function kV(e,t){let n=-1;const r=[];let s;for(;++n0){const Xe=ce.tokenStack[ce.tokenStack.length-1];(Xe[1]||xT).call(ce,void 0,Xe[0])}for(J.position={start:Ki(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:Ki(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},pe=-1;++pe=0?t.slice(n+5).trimStart():e}function eee({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5.25 7.5h5.25v5.25H5.25zM13.5 7.5h5.25v5.25H13.5zM9.38 15.75h5.24v3H9.38z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),l.jsx("path",{d:"M7.88 12.75v1.5c0 .83.67 1.5 1.5 1.5h5.24c.83 0 1.5-.67 1.5-1.5v-1.5M12 4.75V7.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),l.jsx("circle",{cx:"12",cy:"4.75",r:"1",fill:"currentColor"})]})}function tee({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M6.25 4.75h8.6l2.9 2.9v11.6h-11.5z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),l.jsx("path",{d:"M14.75 4.9v3h2.85M8.9 11.1h4.2M8.9 14h5.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),l.jsx("path",{d:"m17.85 13.85.42 1.13 1.13.42-1.13.42-.42 1.13-.42-1.13-1.13-.42 1.13-.42z",fill:"currentColor"})]})}function nee(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m7.5 7.5 9 9m0-9-9 9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function MS({direction:e}){return l.jsx("svg",{className:"icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:e==="left"?"m11.7 5.5-4.2 4.5 4.2 4.5":"m8.3 5.5 4.2 4.5-4.2 4.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function m1(){return l.jsx("span",{className:"skillcenter-loading-mark","aria-hidden":!0})}function DS({page:e,total:t,pageSize:n,onPage:r}){const s=Math.max(1,Math.ceil(t/n));return l.jsxs("footer",{className:"skillcenter-pager",children:[l.jsxs("span",{children:["共 ",t," 项"]}),l.jsxs("div",{className:"skillcenter-pager-actions",children:[l.jsx("button",{type:"button",onClick:()=>r(e-1),disabled:e<=1,"aria-label":"上一页",children:l.jsx(MS,{direction:"left"})}),l.jsxs("span",{children:[e," / ",s]}),l.jsx("button",{type:"button",onClick:()=>r(e+1),disabled:e>=s,"aria-label":"下一页",children:l.jsx(MS,{direction:"right"})})]})]})}function Hh({children:e}){return l.jsx("div",{className:"skillcenter-empty",children:e})}function ree({skill:e,space:t,region:n,detail:r,loading:s,error:i,onClose:a}){return v.useEffect(()=>{const o=c=>{c.key==="Escape"&&a()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a]),l.jsx("div",{className:"skill-detail-backdrop",role:"presentation",onMouseDown:a,children:l.jsxs("section",{className:"skill-detail-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-detail-title",onMouseDown:o=>o.stopPropagation(),children:[l.jsxs("header",{className:"skill-detail-head",children:[l.jsxs("div",{className:"skill-detail-heading",children:[l.jsx("span",{className:"skillcenter-symbol skillcenter-symbol--skill",children:l.jsx(tee,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"skill-detail-title",children:(r==null?void 0:r.name)||e.skillName}),l.jsx("p",{children:(r==null?void 0:r.description)||e.skillDescription||"暂无描述"})]})]}),l.jsx("button",{type:"button",className:"skill-detail-close",onClick:a,"aria-label":"关闭技能详情",children:l.jsx(nee,{})})]}),l.jsxs("dl",{className:"skill-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"技能 ID"}),l.jsx("dd",{title:e.skillId,children:e.skillId})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"版本"}),l.jsx("dd",{children:(r==null?void 0:r.version)||e.version||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:p1(e.skillStatus)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能空间"}),l.jsx("dd",{title:t.name,children:t.name})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Project"}),l.jsx("dd",{title:t.projectName||"default",children:t.projectName||"default"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"地域"}),l.jsx("dd",{children:n==="cn-beijing"?"北京":"上海"})]})]}),l.jsxs("div",{className:"skill-detail-content",children:[l.jsx("div",{className:"skill-detail-content-title",children:"SKILL.md"}),s?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(m1,{}),"正在读取技能内容…"]}):i?l.jsx("div",{className:"skillcenter-error",children:i}):r!=null&&r.skillMd?l.jsx(Gd,{text:JJ(r.skillMd),className:"skill-detail-markdown",allowRawHtml:!1}):l.jsx(Hh,{children:"该技能暂无 SKILL.md 内容"})]})]})})}function see({onClick:e}){return l.jsxs("button",{className:"new-chat",onClick:e,"aria-label":"技能中心",title:"技能中心",children:[l.jsx(eee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"技能中心"})]})}function iee(){const[e,t]=v.useState("cn-beijing"),[n,r]=v.useState([]),[s,i]=v.useState(1),[a,o]=v.useState(0),[c,u]=v.useState(!1),[d,f]=v.useState(""),[h,p]=v.useState(null),[m,g]=v.useState([]),[x,y]=v.useState(1),[E,b]=v.useState(0),[_,k]=v.useState(!1),[T,A]=v.useState(""),[N,S]=v.useState(null),[C,M]=v.useState(null),[U,q]=v.useState(!1),[P,D]=v.useState(""),I=v.useRef(0);v.useEffect(()=>{let z=!0;return u(!0),f(""),y$({region:e,page:s,pageSize:RS}).then(Y=>{if(!z)return;const j=Y.items||[];r(j),o(Y.totalCount||0),p(re=>j.find(V=>V.id===(re==null?void 0:re.id))||null)}).catch(Y=>{z&&(r([]),o(0),p(null),f(Y instanceof Error?Y.message:"读取技能空间失败,请稍后重试"))}).finally(()=>{z&&u(!1)}),()=>{z=!1}},[e,s]),v.useEffect(()=>{if(!h){g([]),b(0);return}let z=!0;return k(!0),A(""),E$(h.id,{region:e,page:x,pageSize:LS,project:h.projectName}).then(Y=>{z&&(g(Y.items||[]),b(Y.totalCount||0))}).catch(Y=>{z&&(g([]),b(0),A(Y instanceof Error?Y.message:"读取技能失败,请稍后重试"))}).finally(()=>{z&&k(!1)}),()=>{z=!1}},[e,h,x]);const L=z=>{z!==e&&(B(),t(z),i(1),y(1),p(null),g([]))},O=z=>{B(),p(z),y(1)},B=()=>{I.current+=1,S(null),M(null),D(""),q(!1)},R=async z=>{if(!h)return;const Y=I.current+1;I.current=Y,S(z),M(null),D(""),q(!0);try{const j=await x$(h.id,z.skillId,z.version,e,h.projectName);I.current===Y&&M(j)}catch(j){I.current===Y&&D(j instanceof Error?j.message:"读取技能详情失败,请稍后重试")}finally{I.current===Y&&q(!1)}};return l.jsxs("section",{className:"skillcenter",children:[l.jsxs("div",{className:"skillcenter-browser",children:[l.jsxs("section",{className:"skillcenter-panel","aria-label":"技能空间列表",children:[l.jsxs("header",{className:"skillcenter-panel-head",children:[l.jsxs("div",{children:[l.jsx("h2",{children:"技能空间"}),l.jsx("span",{className:"skillcenter-count-badge",children:a})]}),l.jsxs("div",{className:"skillcenter-regions","aria-label":"地域",children:[l.jsx("button",{type:"button",className:e==="cn-beijing"?"active":"",onClick:()=>L("cn-beijing"),children:"北京"}),l.jsx("button",{type:"button",className:e==="cn-shanghai"?"active":"",onClick:()=>L("cn-shanghai"),children:"上海"})]})]}),l.jsxs("div",{className:"skillcenter-listwrap",children:[c&&l.jsxs("div",{className:"skillcenter-loading skillcenter-loading--overlay",children:[l.jsx(m1,{}),"正在读取技能空间…"]}),d?l.jsx("div",{className:"skillcenter-error",children:d}):n.length===0&&!c?l.jsx(Hh,{children:"当前地域暂无可访问的技能空间"}):l.jsx("div",{className:"skillcenter-list",children:n.map(z=>l.jsx("button",{type:"button",className:`skillcenter-space-item ${(h==null?void 0:h.id)===z.id?"active":""}`,onClick:()=>O(z),children:l.jsxs("span",{className:"skillcenter-item-body",children:[l.jsx("span",{className:"skillcenter-item-title",title:z.name,children:z.name}),l.jsx("span",{className:"skillcenter-item-description",children:z.description||"暂无描述"}),l.jsxs("span",{className:"skillcenter-item-meta",children:[l.jsx("span",{className:`skillcenter-status ${OS(z.status)}`,children:p1(z.status)}),l.jsxs("span",{className:"skillcenter-meta-text",title:z.projectName||"default",children:["Project · ",z.projectName||"default"]}),l.jsxs("span",{className:"skillcenter-meta-text",children:[z.skillCount??0," 个技能"]}),z.updatedAt&&l.jsxs("span",{className:"skillcenter-meta-text",children:["更新于 ",ZJ(z.updatedAt)]})]})]})},`${z.projectName||"default"}:${z.id}`))})]}),l.jsx(DS,{page:s,total:a,pageSize:RS,onPage:i})]}),l.jsx("section",{className:"skillcenter-panel","aria-label":"技能列表",children:h?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:"skillcenter-panel-head",children:[l.jsx("div",{children:l.jsxs("h2",{title:h.name,children:[h.name," · 技能"]})}),l.jsx("span",{children:E})]}),l.jsxs("div",{className:"skillcenter-listwrap",children:[_&&l.jsxs("div",{className:"skillcenter-loading skillcenter-loading--overlay",children:[l.jsx(m1,{}),"正在读取技能…"]}),T?l.jsx("div",{className:"skillcenter-error",children:T}):m.length===0&&!_?l.jsx(Hh,{children:"这个空间中暂无技能"}):l.jsx("div",{className:"skillcenter-list skillcenter-list--skills",children:m.map(z=>l.jsx("button",{type:"button",className:"skillcenter-skill-item",onClick:()=>void R(z),children:l.jsxs("span",{className:"skillcenter-item-body",children:[l.jsx("span",{className:"skillcenter-item-title",title:z.skillName,children:z.skillName}),l.jsx("span",{className:"skillcenter-item-description",children:z.skillDescription||"暂无描述"}),l.jsxs("span",{className:"skillcenter-item-meta",children:[l.jsx("span",{className:`skillcenter-status ${OS(z.skillStatus)}`,children:p1(z.skillStatus)}),l.jsxs("span",{className:"skillcenter-meta-text",children:["版本 · ",z.version||"—"]})]})]})},`${z.skillId}:${z.version}`))})]}),l.jsx(DS,{page:x,total:E,pageSize:LS,onPage:y})]}):l.jsx(Hh,{children:"点击 Skill 空间以查看详情"})})]}),N&&h&&l.jsx(ree,{skill:N,space:h,region:e,detail:C,loading:U,error:P,onClose:B})]})}const aee=50,PS=48;function oee(e){return(e.events??[]).flatMap(t=>{var s,i;const r=(((s=t.content)==null?void 0:s.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return r?[{text:r,role:t.author??((i=t.content)==null?void 0:i.role)??"",ts:t.timestamp}]:[]})}function lee(e){var t,n;for(const r of e.events??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const s=(((n=r.content)==null?void 0:n.parts)??[]).map(i=>i.text).find(Boolean);if(s)return s}return"未命名会话"}function cee(e,t,n){const r=Math.max(0,t-PS),s=Math.min(e.length,t+n+PS);return(r>0?"…":"")+e.slice(r,s).trim()+(s{var c;if((c=o.events)!=null&&c.length)return o;try{return await jp(t,e,o.id)}catch{return o}})),a=[];for(const o of i)for(const{text:c,role:u,ts:d}of oee(o)){const f=c.toLowerCase().indexOf(r);if(f!==-1){a.push({type:"session",appId:t,sessionId:o.id,title:lee(o),snippet:cee(c,f,r.length),role:u,ts:d??o.lastUpdateTime});break}}return a.sort((o,c)=>(c.ts??0)-(o.ts??0)),a.slice(0,aee)}async function dee(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await mL(e,t.trim())}catch(a){const o=String(a);return{results:[],note:o.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${o}`}}const{mounted:r,results:s,error:i}=n;return r?i?{results:[],note:i}:{results:s.map((a,o)=>({type:"web",index:o,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function fee(e,t,n,r){if(!t||!r.trim())return{results:[]};const s=await pL(t,e,r.trim(),n);if(!s.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(s.error)return{results:[],note:s.error};const i=s.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:s.results.map((a,o)=>e==="knowledge"?{type:"knowledge",index:o,content:a.content,sourceName:i,sourceType:s.sourceType}:{type:"memory",index:o,content:a.content,sourceName:i,sourceType:s.sourceType,author:a.author,ts:a.timestamp})}}async function hee(e,t,n){return e==="session"?{results:await uee(n.userId,n.appId,t)}:e==="web"?dee(n.appId,t):fee(e,n.appId,n.userId,t)}function l3({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),l.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function pee({open:e}){return l.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function mee({onClick:e}){return l.jsxs("button",{className:"new-chat",onClick:e,"aria-label":"智能搜索",title:"智能搜索",children:[l.jsx(l3,{}),l.jsx("span",{className:"sidebar-nav-label",children:"智能搜索"})]})}function gee(e,t,n){const r=!!e,s=new Set((t==null?void 0:t.searchSources)??[]),i=a=>r?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:r,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:r&&s.has("web"),description:"通过 web_search 工具检索",unavailableLabel:i(" web_search 工具")},{id:"knowledge",label:"知识库",ready:r&&s.has("knowledge"),unavailableLabel:i("知识库")},{id:"memory",label:"长期记忆",ready:r&&s.has("memory"),unavailableLabel:i("长期记忆")}]}function qp(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function jS(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function yee({userId:e,appId:t,agentInfo:n,capabilitiesLoading:r,agentLabel:s,onOpenSession:i}){var D,I;const[a,o]=v.useState("session"),[c,u]=v.useState(""),[d,f]=v.useState([]),[h,p]=v.useState(),[m,g]=v.useState(!1),[x,y]=v.useState(!1),[E,b]=v.useState(!1),_=v.useRef(0),k=v.useRef(null),T=gee(t,n,r),A=T.find(L=>L.id===a),N=a==="knowledge"?(D=n==null?void 0:n.components)==null?void 0:D.find(L=>L.source==="knowledgebase"||L.kind==="knowledgebase"):a==="memory"?(I=n==null?void 0:n.components)==null?void 0:I.find(L=>L.source==="long_term_memory"||L.kind==="memory"):void 0;v.useEffect(()=>{_.current+=1,o("session"),f([]),p(void 0),y(!1),g(!1),b(!1)},[t]),v.useEffect(()=>{if(!E)return;function L(O){var B;(B=k.current)!=null&&B.contains(O.target)||b(!1)}return document.addEventListener("pointerdown",L),()=>document.removeEventListener("pointerdown",L)},[E]);async function S(L,O){var Y;const B=L.trim();if(!B||!((Y=T.find(j=>j.id===O))!=null&&Y.ready))return;const R=++_.current;g(!0),y(!0);let z;try{z=await hee(O,B,{userId:e,appId:t})}catch(j){const re=j instanceof Error?j.message:String(j);z={results:[],note:`搜索失败:${re}`}}R===_.current&&(f(z.results),p(z.note),g(!1))}function C(L){_.current+=1,u(L),f([]),p(void 0),y(!1),g(!1)}function M(L){_.current+=1,o(L),b(!1),f([]),p(void 0),y(!1),g(!1)}const U=!!(A!=null&&A.ready),q=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(N==null?void 0:N.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(N==null?void 0:N.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",P=N!=null&&N.backend?qp(N.backend):"";return l.jsxs("div",{className:"search",children:[l.jsxs("div",{className:"search-box",children:[l.jsxs("div",{className:"search-source-picker-wrap",ref:k,children:[l.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(A==null?void 0:A.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":E,onClick:()=>b(L=>!L),children:[l.jsx("span",{children:(A==null?void 0:A.label)??"搜索类型"}),P&&l.jsx("small",{children:P}),l.jsx(pee,{open:E})]}),E&&l.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:T.map(L=>{var R,z;const O=L.id==="knowledge"?(R=n==null?void 0:n.components)==null?void 0:R.find(Y=>Y.source==="knowledgebase"||Y.kind==="knowledgebase"):L.id==="memory"?(z=n==null?void 0:n.components)==null?void 0:z.find(Y=>Y.source==="long_term_memory"||Y.kind==="memory"):void 0,B=O?[O.name,O.backend?qp(O.backend):""].filter(Boolean).join(" · "):L.ready?L.description:L.unavailableLabel;return l.jsxs("button",{type:"button",role:"option","aria-selected":a===L.id,disabled:!L.ready,onClick:()=>M(L.id),children:[l.jsx("span",{children:L.label}),B&&l.jsx("small",{children:B})]},L.id)})})]}),l.jsx("span",{className:"search-box-divider","aria-hidden":!0}),l.jsx("input",{className:"search-input",value:c,onChange:L=>C(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),S(c,a))},placeholder:q,disabled:!U,autoFocus:!0}),l.jsx("button",{className:"search-go",onClick:()=>void S(c,a),disabled:!c.trim()||m,"aria-label":"搜索",children:m?l.jsx(bt,{className:"icon spin"}):l.jsx(l3,{className:"icon"})})]}),l.jsx("div",{className:"search-results",children:U?x?m?null:h?l.jsx("div",{className:"search-empty",children:h}):d.length===0&&x?l.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map((L,O)=>l.jsx(bee,{result:L,agentLabel:s,onOpen:i},O)):l.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):l.jsx("div",{className:"search-empty",children:t?r?"正在读取当前 Agent 的检索能力…":(A==null?void 0:A.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function bee({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return l.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[l.jsx(UR,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title}),l.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${jS(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return l.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[l.jsx(_x,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title||e.url}),l.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&l.jsx(wx,{className:"search-result-ext"})]})]}),e.summary&&l.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(BS,{source:"knowledge"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${qp(e.sourceType)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(BS,{source:"memory"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${qp(e.sourceType)}`:"",e.ts?` · ${jS(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function BS({source:e,className:t="search-result-icon"}){return e==="knowledge"?l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),l.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),l.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}const ow="/assets/volcengine-DM14a-L-.svg",FS="(max-width: 860px)";function Eee(){return l.jsxs("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M12.5 3 5.5 13h5l-1 8 8-11h-5l.5-7z",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M19 4.5v3M17.5 6h3",opacity:"0.85"})]})}function xee(){return l.jsxs("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("circle",{cx:"8.25",cy:"7.75",r:"3.15"}),l.jsx("path",{d:"M2.9 19.2c.45-3.45 2.48-5.35 5.35-5.35 2.4 0 4.2 1.28 4.98 3.66"}),l.jsx("path",{d:"M17.4 4.5v15M14.8 9h5.2M14.8 15.3h5.2"}),l.jsx("circle",{cx:"17.4",cy:"9",r:"1.15",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"17.4",cy:"15.3",r:"1.15",fill:"currentColor",stroke:"none"})]})}function wee(e){let t=2166136261;for(const r of e)t^=r.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const vee={admin:"管理员",developer:"开发者",user:"普通用户"};function US({role:e}){const t=vee[e];return l.jsx("span",{className:`studio-role-badge studio-role-badge--${e}`,title:t,children:t})}function _ee({version:e,onClose:t}){return v.useEffect(()=>{const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),ai.createPortal(l.jsx("div",{className:"confirm-scrim",onMouseDown:t,children:l.jsxs("section",{className:"confirm-box system-info-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"system-info-title",onMouseDown:n=>n.stopPropagation(),children:[l.jsxs("header",{className:"system-info-head",children:[l.jsx("h2",{id:"system-info-title",children:"系统信息"}),l.jsx("button",{type:"button",className:"icon-btn",onClick:t,"aria-label":"关闭系统信息",autoFocus:!0,children:l.jsx(Wr,{className:"icon","aria-hidden":"true"})})]}),l.jsx("dl",{className:"system-info-meta",children:l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:e||"—"})]})})]})}),document.body)}function kee({access:e,userInfo:t,version:n,onLogout:r}){const[s,i]=v.useState(!1),[a,o]=v.useState(!1),[c,u]=v.useState("");if(!t)return null;const d=q7(t),f=typeof t.email=="string"?t.email:"",h=(d||"U").slice(0,1).toUpperCase(),p=wee(d||f||h),m=G7(t),g=m===c?"":m;return l.jsxs("div",{className:"sidebar-user",children:[l.jsxs("button",{className:"sidebar-user-btn",onClick:()=>i(x=>!x),title:f?`${d} -${f}`:d,children:[l.jsxs("span",{className:`account-avatar${g?" has-image":""}`,style:p,children:[h,g?l.jsx("img",{className:"account-avatar-image",src:g,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>u(g)}):null]}),l.jsxs("span",{className:"sidebar-user-identity",children:[l.jsxs("span",{className:"sidebar-user-primary",children:[l.jsx("span",{className:"sidebar-user-name",children:d}),l.jsx(US,{role:e.role})]}),f&&f!==d&&l.jsx("span",{className:"sidebar-user-email",children:f})]})]}),s&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>i(!1)}),l.jsxs("div",{className:"account-pop sidebar-user-pop",children:[l.jsxs("div",{className:"account-head",children:[l.jsxs("span",{className:`account-avatar account-avatar--lg${g?" has-image":""}`,style:p,children:[h,g?l.jsx("img",{className:"account-avatar-image",src:g,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>u(g)}):null]}),l.jsxs("div",{className:"account-id",children:[l.jsxs("div",{className:"account-name-row",children:[l.jsx("div",{className:"account-name",children:d}),l.jsx(US,{role:e.role})]}),f&&f!==d&&l.jsx("div",{className:"account-sub",children:f})]})]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{i(!1),o(!0)},children:[l.jsx(Aa,{className:"icon"})," 系统信息"]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{i(!1),r()},children:[l.jsx(_7,{className:"icon"})," 退出登录"]})]})]}),a?l.jsx(_ee,{version:n,onClose:()=>o(!1)}):null]})}function Tee({branding:e,sessions:t,currentSessionId:n,features:r,access:s,streamingSids:i,onNewChat:a,onSearch:o,onQuickCreate:c,onSkillCenter:u,onAddAgent:d,onManageAgents:f,onPickSession:h,onDeleteSession:p,userInfo:m,version:g,onLogout:x}){const y=S=>(r==null?void 0:r[S])!==!1,[E,b]=v.useState(null),_=v.useRef(typeof window<"u"&&window.matchMedia(FS).matches),[k,T]=v.useState(_.current),A=[...t].sort((S,C)=>(C.lastUpdateTime??0)-(S.lastUpdateTime??0)),N=()=>{_.current=!1,T(S=>!S),b(null)};return v.useEffect(()=>{const S=window.matchMedia(FS),C=M=>{M.matches?T(U=>U||(_.current=!0,!0)):_.current&&(_.current=!1,T(!1))};return S.addEventListener("change",C),()=>S.removeEventListener("change",C)},[]),l.jsxs("aside",{className:`sidebar ${k?"is-collapsed":""}`,children:[l.jsxs("div",{className:"sidebar-top",children:[l.jsxs("div",{className:"sidebar-brand-row",children:[l.jsxs("div",{className:"brand",children:[l.jsx("img",{className:"brand-logo",src:e.logoUrl||ow,width:20,height:20,alt:"","aria-hidden":!0}),l.jsx("span",{className:"brand-title",children:e.title})]}),l.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:N,"aria-label":k?"展开侧边栏":"收起侧边栏",title:k?"展开侧边栏":"收起侧边栏",children:k?l.jsx(A7,{className:"icon"}):l.jsx(N7,{className:"icon"})})]}),y("newChat")&&l.jsxs("button",{className:"new-chat",onClick:a,"aria-label":"新会话",title:"新会话",children:[l.jsx(Ps,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),y("search")&&l.jsx(mee,{onClick:o}),y("skillCenter")&&l.jsx(see,{onClick:u}),s.capabilities.createAgents&&y("addAgent")&&l.jsxs("button",{className:"new-chat",onClick:c,"aria-label":"添加 Agent",title:"添加 Agent",children:[l.jsx(Eee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"添加 Agent"})]}),s.capabilities.manageAgents&&y("manageAgents")&&l.jsxs("button",{className:"new-chat",onClick:f,"aria-label":"管理 Agent",title:"管理 Agent",children:[l.jsx(xee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"管理 Agent"})]})]}),y("history")&&l.jsxs("div",{className:"sidebar-history",children:[l.jsxs("div",{className:"history-head",children:[l.jsx("span",{children:"历史会话"}),y("newChat")&&l.jsx("button",{type:"button",className:"history-new-chat",onClick:a,"aria-label":"新建会话",title:"新建会话",children:l.jsx(Ps,{className:"icon"})})]}),l.jsxs("div",{className:"history-list",children:[A.length===0&&l.jsx("div",{className:"history-empty",children:"暂无会话"}),A.map(S=>{const C=m$(S.events);return l.jsxs("div",{className:`history-item ${S.id===n?"active":""}`,children:[l.jsxs("button",{className:"history-item-btn",onClick:()=>h(S.id),title:C,children:[(i==null?void 0:i.has(S.id))&&l.jsx("span",{className:"history-streaming",title:"正在生成…","aria-label":"正在生成"}),l.jsx("span",{className:"history-title",children:C})]}),l.jsx("button",{className:"history-more",title:"更多",onClick:()=>b(M=>M===S.id?null:S.id),children:l.jsx(i7,{className:"icon"})}),E===S.id&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>b(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{className:"menu-item menu-item--danger",onClick:()=>{b(null),p(S.id)},children:[l.jsx(mc,{className:"icon"})," 删除"]})})]})]},S.id)})]})]}),l.jsx(kee,{access:s,userInfo:m,version:g,onLogout:x})]})}const c3="veadk_agentkit_connections";function Ti(){try{const e=localStorage.getItem(c3);return e?JSON.parse(e):[]}catch{return[]}}function Jm(e){try{localStorage.setItem(c3,JSON.stringify(e))}catch{}}function mo(e,t){return`agentkit:${e}:${t}`}function u3(e){try{return new URL(e).host}catch{return e}}function vc(e){ZR();for(const t of e)for(const n of t.apps)QR(mo(t.id,n),t.runtimeId?{app:n,runtimeId:t.runtimeId,region:t.region}:{app:n,base:t.base,apiKey:t.apiKey})}function d3(e,t,n,r,s){const i={id:`rt_${e}`,name:t||e,runtimeId:e,region:n,apps:r,appLabels:s},a=[...Ti().filter(o=>o.runtimeId!==e),i];return Jm(a),vc(a),i}async function lw(e,t,n){let r;try{r=await _L(e,n)}catch(a){throw a instanceof Fd&&g1(e),a}if(!r||r.length===0)throw g1(e),new Error("该 Runtime 暂不支持连接,请确认服务已正常运行。");const s=Object.fromEntries(r.map(a=>[a,t])),i=d3(e,t,n,r,s);return mo(i.id,r[0])}async function f3(e,t,n,r){const s=t.trim().replace(/\/+$/,""),i=await Fm(s,n.trim()),a={id:Date.now().toString(36),name:e.trim()||u3(s),base:s,apiKey:n.trim(),apps:i,appLabels:r&&i.length>0?{[i[0]]:r}:void 0},o=[...Ti().filter(c=>c.base!==s),a];return Jm(o),vc(o),a}function See(e){const t=Ti().filter(n=>n.id!==e);return Jm(t),vc(t),t}function g1(e){const t=Ti().filter(n=>n.runtimeId!==e);return Jm(t),vc(t),t}function h3(e,t){const n=e.map(s=>({id:s,label:s,app:s,remote:!1})),r=t.flatMap(s=>s.apps.map(i=>{var o;const a=((o=s.appLabels)==null?void 0:o[i])??i;return{id:mo(s.id,i),label:a,app:i,remote:!0,host:s.runtimeId?s.name:u3(s.base??"")}}));return[...n,...r]}const $S=Object.freeze(Object.defineProperty({__proto__:null,addConnection:f3,addRuntimeConnection:d3,buildAgentEntries:h3,connectRuntime:lw,loadConnections:Ti,registerConnections:vc,remoteAppId:mo,removeConnection:See,removeRuntimeConnection:g1},Symbol.toStringTag,{value:"Module"}));function ql({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"m10.05 3.7 1.95-1.12 1.95 1.12"}),l.jsx("path",{d:"m16.25 5.03 3.9 2.25v4.5"}),l.jsx("path",{d:"M20.15 15.08v1.64l-3.9 2.25"}),l.jsx("path",{d:"m13.95 20.3-1.95 1.12-1.95-1.12"}),l.jsx("path",{d:"m7.75 18.97-3.9-2.25v-4.5"}),l.jsx("path",{d:"M3.85 8.92V7.28l3.9-2.25"}),l.jsx("path",{d:"m12 7.55 1.28 3.17L16.45 12l-3.17 1.28L12 16.45l-1.28-3.17L7.55 12l3.17-1.28L12 7.55Z",fill:"currentColor",stroke:"none"})]})}function y1({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M4.5 6.7h4.2M12.3 6.7h7.2"}),l.jsx("path",{d:"M4.5 12h8.2M16.3 12h3.2"}),l.jsx("path",{d:"M4.5 17.3h2.7M10.8 17.3h8.7"}),l.jsx("circle",{cx:"10.5",cy:"6.7",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"12",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"9",cy:"17.3",r:"1.8",fill:"currentColor",stroke:"none"})]})}function Nee({className:e="icon"}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsxs("g",{transform:"translate(0 2)",children:[l.jsx("path",{d:"M11.6 3.5c.45 3.75 2.75 6.05 6.5 6.5-3.75.45-6.05 2.75-6.5 6.5-.45-3.75-2.75-6.05-6.5-6.5 3.75-.45 6.05-2.75 6.5-6.5Z"}),l.jsx("path",{d:"M18.7 3.8v3.4M20.4 5.5H17"})]})})}function p3({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M18.7 8.15A7.55 7.55 0 0 0 5.35 7.1"}),l.jsx("path",{d:"m18.7 8.15-.2-3.05-3.02.3"}),l.jsx("path",{d:"M5.3 15.85A7.55 7.55 0 0 0 18.65 16.9"}),l.jsx("path",{d:"m5.3 15.85.2 3.05 3.02-.3"}),l.jsx("path",{d:"M6.85 12h2.8l1.4-2.9 1.9 5.8 1.42-2.9h2.78"})]})}const HS=15,Aee=1e4,Cee=[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}];function Iee(e){return e==="cn-beijing"?"北京":e==="cn-shanghai"?"上海":e}function m3(e){const t=e.toLowerCase();return t.includes("invalidagentkitruntime.notfound")||t.includes("specified agentkitruntime does not exist")?"该 Runtime 已不存在或列表信息已过期,请刷新列表后重试。":t.includes("accessdenied")||t.includes("forbidden")||t.includes("permission")||t.includes("(401)")||t.includes("(403)")?"当前账号无权访问该 Runtime,请检查所属 Project 和访问权限。":t.includes("agent-info failed: 404")||t.includes("读取 agent 列表失败 (404)")?"该 Agent Server 版本暂不支持信息预览。":"该 Runtime 暂时无法访问,请确认其状态为“就绪”后重试。"}function Y0(e,t=Aee){return new Promise((n,r)=>{const s=setTimeout(()=>r(new Error("加载超时,请重试")),t);e.then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),r(i)})})}function Ree({open:e,onClose:t,variant:n="drawer",anchorTop:r=0,agentsSource:s,localApps:i,currentId:a,currentRuntime:o,runtimeScope:c,onSelect:u}){const[d,f]=v.useState([]),[h,p]=v.useState([""]),[m,g]=v.useState(0),[x,y]=v.useState(c==="mine"),[E,b]=v.useState(null),[_,k]=v.useState("cn-beijing"),[T,A]=v.useState(!1),[N,S]=v.useState(""),[C,M]=v.useState(""),[U,q]=v.useState(null),[P,D]=v.useState(new Set),[I,L]=v.useState(),[O,B]=v.useState("agent"),R=v.useRef(!1);function z(Z){L(de=>(de==null?void 0:de.runtimeId)===Z.runtimeId?void 0:{runtimeId:Z.runtimeId,name:Z.name,region:Z.region})}const Y=v.useCallback(async Z=>{if(d[Z]){g(Z);return}const de=h[Z];if(de!==void 0){A(!0),S("");try{const ye=await Y0(jh({nextToken:de,pageSize:HS,region:_,scope:"all"}));f(Q=>{const ge=[...Q];return ge[Z]=ye.runtimes,ge}),p(Q=>{const ge=[...Q];return ye.nextToken&&(ge[Z+1]=ye.nextToken),ge}),g(Z)}catch(ye){S(ye instanceof Error?ye.message:String(ye))}finally{A(!1)}}},[h,d,_]),j=v.useCallback(async()=>{A(!0),S("");try{const Z=[];let de="";do{const ye=await Y0(jh({scope:"mine",nextToken:de,pageSize:100,region:_}));Z.push(...ye.runtimes),de=ye.nextToken}while(de&&Z.length<2e3);b(Z)}catch(Z){S(Z instanceof Error?Z.message:String(Z))}finally{A(!1)}},[_]);v.useEffect(()=>{y(c==="mine"),f([]),p([""]),g(0),b(null),R.current=!1},[c]),v.useEffect(()=>{e&&s==="cloud"&&!x&&!R.current&&(R.current=!0,Y(0))},[e,s,x,Y]),v.useEffect(()=>{x&&E===null&&s==="cloud"&&j()},[x,E,s,j]),v.useEffect(()=>{e&&(L(void 0),B("agent"))},[e]);function re(){D(new Set),x?(b(null),j()):(f([]),p([""]),g(0),R.current=!0,A(!0),S(""),Y0(jh({nextToken:"",pageSize:HS,region:_,scope:"all"})).then(Z=>{f([Z.runtimes]),p(Z.nextToken?["",Z.nextToken]:[""])}).catch(Z=>S(Z instanceof Error?Z.message:String(Z))).finally(()=>A(!1)))}function V(Z){Z!==_&&(k(Z),f([]),p([""]),g(0),b(null),D(new Set),R.current=!1)}const ee=!x&&(d[m+1]!==void 0||h[m+1]!==void 0);function oe(Z){q(Z.runtimeId),lw(Z.runtimeId,Z.name,Z.region).then(de=>{u(de),t()}).catch(de=>{if(de instanceof Fd){S(de.message);return}if(de instanceof ld){de.unsupported&&D(ye=>new Set(ye).add(Z.runtimeId)),S(de.message);return}D(ye=>new Set(ye).add(Z.runtimeId))}).finally(()=>q(null))}if(!e)return null;const ae=(x?E??[]:d[m]??[]).filter(Z=>C?Z.name.toLowerCase().includes(C.toLowerCase()):!0);return l.jsxs(l.Fragment,{children:[n==="drawer"?l.jsx("div",{className:"menu-scrim",onClick:t}):null,l.jsxs("div",{className:`agentsel agentsel--${n}${I&&n==="drawer"?" has-detail":""}`,role:"dialog","aria-label":"选择 Agent",style:n==="drawer"?{top:r,height:`min(640px, calc(100dvh - ${r}px - 10px))`}:void 0,children:[l.jsxs("div",{className:"agentsel-main",children:[l.jsxs("div",{className:"agentsel-head",children:[l.jsxs("span",{className:"agentsel-title",children:[l.jsx(ql,{})," 选择 Agent"]}),l.jsxs("div",{className:"agentsel-head-actions",children:[s==="cloud"&&l.jsx("button",{className:"agentsel-refresh",onClick:re,title:"刷新",disabled:T,children:l.jsx(kx,{className:`icon ${T?"spin":""}`})}),l.jsx("button",{className:"agentsel-refresh",onClick:t,title:"关闭",children:l.jsx(Wr,{className:"icon"})})]})]}),s==="local"?l.jsx("div",{className:"agentsel-body",children:i.length===0?l.jsx("div",{className:"agentsel-empty",children:"暂无本地 Agent。"}):l.jsx("ul",{className:"agentsel-list",children:i.map(Z=>l.jsx("li",{children:l.jsxs("button",{className:`agentsel-item ${Z===a?"active":""}`,onClick:()=>{u(Z),t()},children:[l.jsx(ql,{}),l.jsx("span",{className:"agentsel-item-name",children:Z})]})},Z))})}):l.jsxs("div",{className:"agentsel-body agentsel-body--cloud",children:[l.jsxs("div",{className:"agentsel-tools",children:[l.jsxs("div",{className:"agentsel-search",children:[l.jsx(Hb,{className:"icon"}),l.jsx("input",{value:C,onChange:Z=>M(Z.target.value),placeholder:"搜索 Runtime 名称"})]}),l.jsx("div",{className:"agentsel-regions","aria-label":"按部署地域筛选",children:Cee.map(Z=>l.jsx("button",{type:"button",className:_===Z.value?"active":"","aria-pressed":_===Z.value,onClick:()=>V(Z.value),children:Z.label},Z.value))}),c==="all"&&l.jsxs("label",{className:"agentsel-mine",children:[l.jsx("input",{type:"checkbox",checked:x,onChange:Z=>y(Z.target.checked)}),"只看我创建的"]})]}),N&&l.jsx("div",{className:"agentsel-error",children:N}),l.jsxs("div",{className:"agentsel-listwrap",children:[ae.length===0&&!T?l.jsx("div",{className:"agentsel-empty",children:"暂无 Runtime。"}):l.jsx("ul",{className:"agentsel-list",children:ae.map(Z=>{const de=P.has(Z.runtimeId),ye=U===Z.runtimeId,Q=(o==null?void 0:o.runtimeId)===Z.runtimeId,ge=(I==null?void 0:I.runtimeId)===Z.runtimeId;return l.jsx("li",{children:l.jsxs("div",{className:`agentsel-item agentsel-runtime-item ${Q?"active":""} ${ge?"is-previewed":""}`,title:Z.runtimeId,children:[l.jsx(p3,{}),l.jsxs("div",{className:"agentsel-item-main",children:[l.jsx("span",{className:"agentsel-item-name",title:Z.name,children:Z.name}),l.jsxs("div",{className:"agentsel-item-meta",children:[l.jsx("span",{className:`agentsel-status is-${de?"bad":Bee(Z.status)}`,children:de?"不支持":g3(Z.status)}),Z.isMine&&l.jsx("span",{className:"agentsel-badge",children:"我创建的"})]})]}),l.jsxs("div",{className:"agentsel-item-actions",children:[l.jsx("button",{type:"button",className:"agentsel-connect",disabled:ye||Q,onClick:()=>oe(Z),children:ye?"连接中…":Q?"已连接":de?"重试":"连接"}),n==="drawer"?l.jsx("button",{type:"button",className:`agentsel-info ${ge?"active":""}`,"aria-label":`查看 ${Z.name} 信息`,"aria-pressed":ge,title:"查看信息",onClick:()=>z(Z),children:l.jsx(Aa,{className:"icon"})}):null]})]})},Z.runtimeId)})}),T&&l.jsxs("div",{className:"agentsel-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载中…"]})]}),l.jsxs("div",{className:"agentsel-pager",children:[l.jsx("button",{disabled:x||m===0||T,onClick:()=>void Y(m-1),"aria-label":"上一页",children:l.jsx(JU,{className:"icon"})}),l.jsx("span",{className:"agentsel-pager-label",children:x?1:m+1}),l.jsx("button",{disabled:x||!ee||T,onClick:()=>void Y(m+1),"aria-label":"下一页",children:l.jsx(Nr,{className:"icon"})})]})]})]}),n==="drawer"&&s==="cloud"&&I&&l.jsx(Dee,{runtime:I,tab:O,onTabChange:B})]})]})}const Lee={knowledgebase:"知识库",memory:"记忆",prompt_manager:"提示词管理",example_store:"样例库",run_processor:"运行处理器",tracer:"链路追踪",toolset:"工具集",plugin:"插件",other:"其他"};function Oee(e){return Lee[e.toLowerCase()]??e}function Mee(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function Dee({runtime:e,tab:t,onTabChange:n}){return l.jsxs("section",{className:"agentsel-detail agentsel-preview","aria-label":"Agent 与 Runtime 信息",children:[l.jsx("div",{className:"agentsel-head agentsel-preview-head",children:l.jsxs("div",{className:`agentsel-detail-tabs is-${t}`,role:"tablist","aria-label":"详情类型",children:[l.jsx("span",{className:"agentsel-detail-tabs-slider","aria-hidden":!0}),l.jsx("button",{id:"agentsel-agent-tab",type:"button",role:"tab","aria-selected":t==="agent","aria-controls":"agentsel-agent-panel",onClick:()=>n("agent"),children:"Agent 信息"}),l.jsx("button",{id:"agentsel-runtime-tab",type:"button",role:"tab","aria-selected":t==="runtime","aria-controls":"agentsel-runtime-panel",onClick:()=>n("runtime"),children:"Runtime 信息"})]})}),l.jsx("div",{id:"agentsel-agent-panel",className:"agentsel-tab-panel",role:"tabpanel","aria-labelledby":"agentsel-agent-tab",hidden:t!=="agent",children:l.jsx(Pee,{runtime:e})}),l.jsx("div",{id:"agentsel-runtime-panel",className:"agentsel-tab-panel",role:"tabpanel","aria-labelledby":"agentsel-runtime-tab",hidden:t!=="runtime",children:l.jsx(jee,{runtime:e})})]})}function Pee({runtime:e}){const[t,n]=v.useState(null),[r,s]=v.useState(!0),[i,a]=v.useState(""),o=e.runtimeId,c=e.region;v.useEffect(()=>{let d=!0;return n(null),s(!0),a(""),hL(o,c).then(f=>d&&n(f)).catch(f=>{if(!d)return;const h=f instanceof Error?f.message:String(f);a(m3(h))}).finally(()=>d&&s(!1)),()=>{d=!1}},[o,c]);const u=(t==null?void 0:t.components)??[];return l.jsx("div",{className:"agentsel-detail-body",children:r?l.jsxs("div",{className:"agentsel-panel-state",children:[l.jsx(bt,{className:"icon spin"})," 读取 Agent 信息…"]}):i?l.jsxs("div",{className:"agentsel-panel-empty",children:[l.jsx("span",{children:"暂时无法读取 Agent 信息"}),l.jsx("small",{title:i,children:i})]}):t?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"agentsel-identity",children:[l.jsx(ql,{className:"agentsel-identity-icon"}),l.jsxs("div",{className:"agentsel-identity-copy",children:[l.jsx("strong",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]})]}),t.description&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsx("h3",{children:"描述"}),l.jsx("p",{className:"agentsel-description",title:t.description,children:t.description})]}),t.subAgents.length>0&&l.jsx(zS,{icon:l.jsx($R,{className:"icon"}),title:"子 Agent",values:t.subAgents}),t.tools.length>0&&l.jsx(zS,{icon:l.jsx(y1,{}),title:"工具",values:t.tools}),t.skills.length>0&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[l.jsx(Nee,{})," 技能"]}),l.jsx("div",{className:"agentsel-info-list",children:t.skills.map(d=>l.jsxs("div",{className:"agentsel-info-list-item",children:[l.jsx("strong",{title:d.name,children:d.name}),d.description&&l.jsx("span",{title:d.description,children:d.description})]},d.name))})]}),u.length>0&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[l.jsx(OR,{className:"icon"})," 挂载组件"]}),l.jsx("div",{className:"agentsel-info-list",children:u.map((d,f)=>l.jsxs("div",{className:"agentsel-info-list-item agentsel-component",children:[l.jsxs("div",{className:"agentsel-component-head",children:[l.jsx("strong",{title:d.name,children:d.name}),l.jsxs("span",{children:[Oee(d.kind),d.backend?` · ${Mee(d.backend)}`:""]})]}),d.description&&l.jsx("span",{title:d.description,children:d.description})]},`${d.kind}:${d.name}:${f}`))})]}),!t.description&&t.subAgents.length===0&&t.tools.length===0&&t.skills.length===0&&u.length===0&&l.jsx("div",{className:"agentsel-panel-empty",children:"暂无更多 Agent 配置信息。"})]}):null})}function zS({icon:e,title:t,values:n}){return l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[e,t]}),l.jsx("div",{className:"agentsel-chips",children:n.map((r,s)=>l.jsx("span",{className:"agentsel-chip",title:r,children:r},`${r}:${s}`))})]})}function jee({runtime:e}){const[t,n]=v.useState(null),[r,s]=v.useState(!0),[i,a]=v.useState(""),o=e.runtimeId,c=e.region;v.useEffect(()=>{let d=!0;return s(!0),a(""),n(null),Lx(o,c).then(f=>d&&n(f)).catch(f=>d&&a(m3(f instanceof Error?f.message:String(f)))).finally(()=>d&&s(!1)),()=>{d=!1}},[o,c]);const u=[];if(t){t.model&&u.push(["模型",t.model]),t.description&&u.push(["描述",t.description]),t.status&&u.push(["状态",g3(t.status)]),t.region&&u.push(["区域",Iee(t.region)]);const d=t.resources,f=[d.cpuMilli!=null?`CPU ${d.cpuMilli}m`:"",d.memoryMb!=null?`内存 ${d.memoryMb}MB`:"",d.minInstance!=null||d.maxInstance!=null?`实例 ${d.minInstance??"?"}~${d.maxInstance??"?"}`:""].filter(Boolean).join(" · ");f&&u.push(["资源",f]),t.currentVersion!=null&&u.push(["版本",String(t.currentVersion)])}return l.jsxs("div",{className:"agentsel-detail-body",children:[l.jsxs("div",{className:"agentsel-runtime-identity",children:[l.jsx(p3,{}),l.jsxs("div",{children:[l.jsx("strong",{title:e.name,children:e.name}),l.jsx("span",{title:e.runtimeId,children:e.runtimeId})]})]}),r?l.jsxs("div",{className:"agentsel-apps-note",children:[l.jsx(bt,{className:"icon spin"})," 读取详情…"]}):i?l.jsx("div",{className:"agentsel-error",children:i}):t?l.jsxs(l.Fragment,{children:[l.jsx("dl",{className:"agentsel-kv",children:u.map(([d,f])=>l.jsxs("div",{className:"agentsel-kv-row",children:[l.jsx("dt",{children:d}),l.jsx("dd",{children:f})]},d))}),t.envs.length>0&&l.jsxs("div",{className:"agentsel-envs",children:[l.jsx("div",{className:"agentsel-envs-head",children:"环境变量"}),t.envs.map(d=>l.jsxs("div",{className:"agentsel-env",children:[l.jsx("span",{className:"agentsel-env-k",children:d.key}),l.jsx("span",{className:"agentsel-env-v",children:d.value})]},d.key))]})]}):null]})}function Bee(e){const t=(e||"").toLowerCase();return t.includes("run")||t.includes("ready")||t.includes("active")?"ok":t.includes("creat")||t.includes("pend")||t.includes("deploy")?"warn":t.includes("fail")||t.includes("error")||t.includes("delet")?"bad":"muted"}const Fee={ready:"就绪",unreleased:"未发布",running:"运行中",active:"运行中",creating:"创建中",pending:"等待中",deploying:"部署中",updating:"更新中",failed:"失败",error:"异常",stopping:"停止中",stopped:"已停止",deleting:"删除中",deleted:"已删除"};function g3(e){const t=e.toLowerCase().replace(/[\s_-]/g,"");return Fee[t]??(e||"-")}function Uee({appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a,title:o,titleLeading:c,crumbs:u,rightContent:d}){return l.jsxs("div",{className:"navbar",children:[l.jsxs("div",{className:"navbar-left",children:[l.jsx("div",{className:"navbar-default",children:u&&u.length>0?l.jsx("nav",{className:"navbar-crumbs","aria-label":"面包屑",children:u.map((f,h)=>l.jsxs(v.Fragment,{children:[h>0&&l.jsx(Nr,{className:"crumb-sep"}),f.onClick?l.jsx("button",{className:"crumb crumb-link",onClick:f.onClick,children:f.label}):l.jsx("span",{className:"crumb crumb-current",children:f.label})]},h))}):o?l.jsxs("div",{className:"navbar-title-group",children:[c,l.jsx("div",{className:"navbar-title",title:o,children:o})]}):l.jsxs("div",{className:"navbar-title-group",children:[c,l.jsx($ee,{appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a})]})}),l.jsx("div",{id:"veadk-page-header-left",className:"navbar-portal-slot"})]}),l.jsxs("div",{className:"navbar-right",children:[l.jsx("div",{id:"veadk-page-header-actions",className:"navbar-portal-actions"}),d]})]})}function $ee({appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a}){const[o,c]=v.useState(!1),u=f=>n?n(f):f;function d(){c(!1)}return l.jsxs("div",{className:"agent-dd",children:[l.jsxs("button",{className:"agent-dd-trigger",onClick:()=>c(f=>!f),children:[l.jsx("span",{className:"agent-dd-current",children:e?u(e):"选择 Agent"}),l.jsx(od,{className:`agent-dd-chev ${o?"open":""}`})]}),o&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:d}),l.jsx(Ree,{open:!0,variant:"navbar",agentsSource:r,localApps:s,currentId:e,currentRuntime:i,runtimeScope:a,onSelect:f=>{t(f),d()},onClose:d})]})]})}const Hee="https://ark.cn-beijing.volces.com/api/v3/",zh=[{key:"MODEL_EMBEDDING_NAME",required:!1,placeholder:"doubao-embedding-vision-250615",comment:"向量化模型(记忆/知识库需要)"},{key:"MODEL_EMBEDDING_DIM",required:!1,placeholder:"2048"},{key:"MODEL_EMBEDDING_API_BASE",required:!1,placeholder:Hee}],Gl=[],Yc=[{key:"FEISHU_APP_ID",required:!0,placeholder:"cli_xxx",comment:"飞书应用 App ID"},{key:"FEISHU_APP_SECRET",required:!0,placeholder:"输入 App Secret",comment:"飞书应用 App Secret"}],Ms={topK:"3",region:"cn-beijing",endpoint:"https://open.volcengineapi.com/"},y3=[{key:"REGISTRY_SPACE_ID",required:!0,placeholder:"请选择智能体中心",comment:"AgentKit 智能体中心"},{key:"REGISTRY_TOP_K",required:!1,placeholder:Ms.topK,comment:"召回 Agent 数量"},{key:"REGISTRY_REGION",required:!1,placeholder:Ms.region,comment:"AgentKit 智能体中心地域"},{key:"REGISTRY_ENDPOINT",required:!1,placeholder:Ms.endpoint,comment:"AgentKit 智能体中心 OpenAPI 地址"}],Xl=[{id:"web_search",label:"联网搜索",desc:"火山引擎 Web Search,获取实时信息。",importLine:"from veadk.tools.builtin_tools.web_search import web_search",toolNames:["web_search"],env:Gl},{id:"parallel_web_search",label:"并行联网搜索",desc:"并行发起多条搜索查询,更快汇总。",importLine:"from veadk.tools.builtin_tools.parallel_web_search import parallel_web_search",toolNames:["parallel_web_search"],env:Gl},{id:"link_reader",label:"网页读取",desc:"抓取并阅读给定链接的正文内容。",importLine:"from veadk.tools.builtin_tools.link_reader import link_reader",toolNames:["link_reader"],env:[]},{id:"web_scraper",label:"网页爬取",desc:"结构化爬取网页(需要 Scraper 服务)。",importLine:"from veadk.tools.builtin_tools.web_scraper import web_scraper",toolNames:["web_scraper"],env:[{key:"TOOL_WEB_SCRAPER_ENDPOINT",required:!0},{key:"TOOL_WEB_SCRAPER_API_KEY",required:!0}]},{id:"image_generate",label:"图像生成",desc:"文生图(Doubao Seedream)。",importLine:"from veadk.tools.builtin_tools.image_generate import image_generate",toolNames:["image_generate"],env:[{key:"MODEL_IMAGE_NAME",required:!1,placeholder:"doubao-seedream-5-0-260128"}]},{id:"image_edit",label:"图像编辑",desc:"图生图 / 编辑(Doubao SeedEdit)。",importLine:"from veadk.tools.builtin_tools.image_edit import image_edit",toolNames:["image_edit"],env:[{key:"MODEL_EDIT_NAME",required:!1,placeholder:"doubao-seededit-3-0-i2i-250628"}]},{id:"video_generate",label:"视频生成",desc:"文/图生视频(Doubao Seedance),含任务查询。",importLine:"from veadk.tools.builtin_tools.video_generate import video_generate, video_task_query",toolNames:["video_generate","video_task_query"],env:[{key:"MODEL_VIDEO_NAME",required:!1,placeholder:"doubao-seedance-2-0-260128"}]},{id:"text_to_speech",label:"语音合成 (TTS)",desc:"把文本转成语音(火山语音)。",importLine:"from veadk.tools.builtin_tools.tts import text_to_speech",toolNames:["text_to_speech"],env:[{key:"TOOL_VESPEECH_APP_ID",required:!0},{key:"TOOL_VESPEECH_SPEAKER",required:!1,placeholder:"zh_female_vv_uranus_bigtts"}]},{id:"run_code",label:"代码执行",desc:"在沙箱中执行代码",importLine:"from veadk.tools.builtin_tools.run_code import run_code",toolNames:["run_code"],env:[{key:"AGENTKIT_TOOL_ID",required:!0,placeholder:"t-xxxx",comment:"代码执行沙箱 ID"},{key:"AGENTKIT_TOOL_REGION",required:!1,placeholder:"cn-beijing",comment:"AgentKit Tools 地域"}]},{id:"vesearch",label:"VeSearch 智能搜索",desc:"火山 VeSearch(需要 bot 端点)。",importLine:"from veadk.tools.builtin_tools.vesearch import vesearch",toolNames:["vesearch"],env:[{key:"TOOL_VESEARCH_ENDPOINT",required:!0,comment:"VeSearch bot_id"}]}],Gp=[{id:"local",label:"本地内存",desc:"进程内,不持久化。适合开发调试。",env:[]},{id:"sqlite",label:"SQLite 文件",desc:"持久化到本地 .db 文件。",extraArgs:'local_database_path="./short_term_memory.db"',env:[]},{id:"mysql",label:"MySQL",desc:"持久化到 MySQL。",env:[{key:"DATABASE_MYSQL_HOST",required:!0},{key:"DATABASE_MYSQL_USER",required:!0},{key:"DATABASE_MYSQL_PASSWORD",required:!0},{key:"DATABASE_MYSQL_DATABASE",required:!0}]},{id:"postgresql",label:"PostgreSQL",desc:"持久化到 PostgreSQL。",env:[{key:"DATABASE_POSTGRESQL_HOST",required:!0},{key:"DATABASE_POSTGRESQL_PORT",required:!1,placeholder:"5432"},{key:"DATABASE_POSTGRESQL_USER",required:!0},{key:"DATABASE_POSTGRESQL_PASSWORD",required:!0},{key:"DATABASE_POSTGRESQL_DATABASE",required:!0}]}],Xp=[{id:"local",label:"本地向量库",desc:"进程内 llama-index 向量库。",env:zh,pipExtra:"extensions",needsEmbedding:!0},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"redis",label:"Redis",desc:"Redis 向量检索。",env:[{key:"DATABASE_REDIS_HOST",required:!0},{key:"DATABASE_REDIS_PORT",required:!1,placeholder:"6379"},{key:"DATABASE_REDIS_PASSWORD",required:!1},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"viking",label:"VikingDB Memory",desc:"火山 VikingDB 记忆库(支持用户画像)。",env:Gl},{id:"mem0",label:"Mem0",desc:"Mem0 托管记忆服务。",env:[{key:"DATABASE_MEM0_API_KEY",required:!0},{key:"DATABASE_MEM0_BASE_URL",required:!1}]}],Ql="viking",Qp=[{id:"viking",label:"VikingDB Knowledge",desc:"火山 VikingDB 知识库。",env:Gl},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"context_search",label:"Context Search",desc:"火山 Context Search 引擎(无需向量化)。",env:[...Gl,{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ID",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ENDPOINT",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_APIKEY",required:!0}]}],Zp=[{id:"apmplus",label:"APMPlus",desc:"火山 APMPlus 应用性能监控。",enableFlag:"ENABLE_APMPLUS",env:[{key:"OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME",required:!1}]},{id:"cozeloop",label:"CozeLoop",desc:"扣子 CozeLoop 链路观测。",enableFlag:"ENABLE_COZELOOP",env:[{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY",required:!0},{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME",required:!1,comment:"CozeLoop space_id"}]},{id:"tls",label:"TLS (日志服务)",desc:"火山 TLS 日志服务导出。",enableFlag:"ENABLE_TLS",env:[...Gl,{key:"OBSERVABILITY_OPENTELEMETRY_TLS_SERVICE_NAME",required:!1,comment:"TLS topic_id,留空自动创建"}]}],zee=e=>Xl.find(t=>t.id===e),Vee=e=>Gp.find(t=>t.id===e),Kee=e=>Xp.find(t=>t.id===e),Yee=e=>Qp.find(t=>t.id===e),Wee=e=>Zp.find(t=>t.id===e),qee={coding:"智能编程",get_city_weather:"城市天气查询",get_location_weather:"位置天气查询",web_fetch:"网页内容获取"};function b1(e){const t=Xl.find(n=>n.id===e||n.toolNames.includes(e));return qee[e]??(t==null?void 0:t.label)??e}function VS(e){const t=Xl.find(r=>r.id===e||r.toolNames.includes(e));return((t==null?void 0:t.desc)??"由 VeADK 提供的内置工具").replace(/[。.]+$/,"")}function Gee(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Xee(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"5.8",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.2 15.2 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function KS(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function b3({title:e,description:t,icon:n,wide:r=!1,onClose:s,children:i}){const a=v.useRef(`session-capability-${Math.random().toString(36).slice(2)}`);return v.useEffect(()=>{const o=document.body.style.overflow;document.body.style.overflow="hidden";const c=u=>{u.key==="Escape"&&s()};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=o}},[s]),ai.createPortal(l.jsxs("div",{className:"session-capability-dialog-layer",children:[l.jsx("button",{type:"button",className:"session-capability-dialog-scrim","aria-label":"关闭弹窗",onClick:s}),l.jsxs("section",{className:`session-capability-dialog${r?" is-wide":""}`,role:"dialog","aria-modal":"true","aria-labelledby":a.current,children:[l.jsxs("header",{className:`session-capability-dialog-head${n?"":" is-iconless"}`,children:[n&&l.jsx("span",{className:"session-capability-dialog-mark",children:n}),l.jsxs("div",{children:[l.jsx("h2",{id:a.current,children:e}),l.jsx("p",{children:t})]}),l.jsx("button",{type:"button",className:"session-capability-dialog-close","aria-label":`关闭${e}`,onClick:s,children:l.jsx(Gee,{})})]}),i]})]}),document.body)}function Vh({value:e,placeholder:t,label:n,onChange:r,autoFocus:s=!1}){return l.jsxs("label",{className:"session-capability-search",children:[l.jsx(Xee,{}),l.jsx("input",{value:e,"aria-label":n,placeholder:t,autoFocus:s,onChange:i=>r(i.target.value)})]})}function Qee({agentName:e,tools:t,selectedNames:n,mutating:r,onAdd:s,onClose:i}){const[a,o]=v.useState(""),[c,u]=v.useState(""),d=v.useMemo(()=>new Set(n),[n]),f=v.useMemo(()=>{const p=a.trim().toLowerCase();return t.filter(m=>p?`${b1(m)} ${m} ${VS(m)}`.toLowerCase().includes(p):!0)},[a,t]),h=async p=>{u(p);const m=await s({kind:"tool",name:p});u(""),m&&i()};return l.jsx(b3,{title:"添加内置工具",description:`添加后仅对 ${e} 的当前会话生效`,icon:l.jsx(y1,{}),onClose:i,children:l.jsxs("div",{className:"session-tool-dialog-body",children:[l.jsx(Vh,{value:a,label:"搜索内置工具",placeholder:"搜索中文名称或工具标识",onChange:o,autoFocus:!0}),l.jsx("div",{className:"session-tool-picker",role:"list","aria-label":"可用内置工具",children:f.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的内置工具"}):f.map(p=>{const m=d.has(p),g=c===p;return l.jsxs("article",{className:"session-tool-option",role:"listitem",children:[l.jsx("span",{className:"session-tool-option-icon",children:l.jsx(y1,{})}),l.jsxs("span",{className:"session-tool-option-copy",children:[l.jsx("strong",{children:b1(p)}),l.jsx("code",{children:p}),l.jsx("span",{children:VS(p)})]}),l.jsx("button",{type:"button",disabled:m||r||!!c,onClick:()=>void h(p),children:m?"已添加":g?"添加中…":"添加"})]},p)})})]})})}function Zee({appName:e,agentName:t,selectedNames:n,mutating:r,onAdd:s,onClose:i}){const[a,o]=v.useState("public"),[c,u]=v.useState(""),[d,f]=v.useState([]),[h,p]=v.useState(0),[m,g]=v.useState(!0),[x,y]=v.useState(""),[E,b]=v.useState([]),[_,k]=v.useState(null),[T,A]=v.useState([]),[N,S]=v.useState(""),[C,M]=v.useState(""),[U,q]=v.useState(!0),[P,D]=v.useState(!1),[I,L]=v.useState(""),[O,B]=v.useState(""),R=v.useMemo(()=>new Set(n),[n]);v.useEffect(()=>{if(a!=="public")return;let V=!0;const ee=window.setTimeout(()=>{g(!0),y(""),cL(e,c.trim()).then(oe=>{V&&(f(oe.items),p(oe.totalCount))}).catch(oe=>{V&&(f([]),p(0),y(oe instanceof Error?oe.message:"搜索 Skill Hub 失败"))}).finally(()=>{V&&g(!1)})},250);return()=>{V=!1,window.clearTimeout(ee)}},[e,c,a]),v.useEffect(()=>{if(a!=="agentkit")return;let V=!0;return q(!0),L(""),oL(e).then(ee=>{V&&(b(ee),k(ee[0]??null))}).catch(ee=>{V&&L(ee instanceof Error?ee.message:"读取 Skill Space 失败")}).finally(()=>{V&&q(!1)}),()=>{V=!1}},[e,a]),v.useEffect(()=>{if(a!=="agentkit")return;if(!_){A([]);return}let V=!0;return D(!0),L(""),lL(e,_.id,_.region).then(ee=>{V&&A(ee)}).catch(ee=>{V&&L(ee instanceof Error?ee.message:"读取技能失败")}).finally(()=>{V&&D(!1)}),()=>{V=!1}},[e,_,a]);const z=v.useMemo(()=>{const V=N.trim().toLowerCase();return V?E.filter(ee=>`${ee.name} ${ee.id} ${ee.description}`.toLowerCase().includes(V)):E},[N,E]),Y=v.useMemo(()=>{const V=C.trim().toLowerCase();return V?T.filter(ee=>`${ee.skillName} ${ee.skillDescription}`.toLowerCase().includes(V)):T},[C,T]),j=async V=>{if(!_)return;B(V.skillId);const ee=await s({kind:"skill",name:V.skillName,skillSourceId:_.id,description:V.skillDescription,version:V.version});B(""),ee&&i()},re=async V=>{B(V.slug);const ee=await s({kind:"skill",name:V.name,skillSourceId:`findskill:${V.slug}`,description:V.description,version:V.version||V.updatedAt});B(""),ee&&i()};return l.jsx(b3,{title:"添加技能",description:`从公域 Skill Hub 或 AgentKit Skill 中心添加到 ${t} 当前会话`,wide:!0,onClose:i,children:l.jsxs("div",{className:"session-skill-dialog-body",children:[l.jsxs("div",{className:"session-skill-source-tabs",role:"tablist","aria-label":"技能来源",children:[l.jsxs("button",{type:"button",role:"tab","aria-selected":a==="public",className:a==="public"?"is-active":"",onClick:()=>o("public"),children:["Skill Hub",l.jsx("span",{children:"公域"})]}),l.jsx("button",{type:"button",role:"tab","aria-selected":a==="agentkit",className:a==="agentkit"?"is-active":"",onClick:()=>o("agentkit"),children:"AgentKit Skill 中心"})]}),a==="public"?l.jsxs("section",{className:"session-public-skill-browser","aria-label":"Skill Hub 公域技能",children:[l.jsxs("div",{className:"session-public-skill-head",children:[l.jsx(Vh,{value:c,label:"搜索 Skill Hub",placeholder:"搜索技能名称、用途或关键词",onChange:u,autoFocus:!0}),l.jsxs("span",{children:[h.toLocaleString()," 个公域技能"]})]}),l.jsx("div",{className:"session-public-skill-list",children:x?l.jsx("div",{className:"session-capability-error",children:x}):m?l.jsx("div",{className:"session-capability-loading",children:"正在搜索 Skill Hub…"}):d.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的公域技能"}):d.map(V=>{const ee=R.has(V.name),oe=O===V.slug;return l.jsxs("article",{className:"session-skill-option session-public-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:V.name}),l.jsx("span",{children:V.description||"暂无描述"}),l.jsxs("small",{children:[V.sourceRepo||V.sourceType||"FindSkill",l.jsx("span",{"aria-hidden":"true",children:" · "}),V.downloadCount.toLocaleString()," 次下载",V.evaluationScore>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",children:" · "}),V.evaluationScore.toFixed(1)," 分"]})]})]}),l.jsx("button",{type:"button",disabled:ee||r||!!O,onClick:()=>void re(V),children:ee?"已添加":oe?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(KS,{}),"添加"]})})]},V.slug)})})]}):l.jsxs("div",{className:"session-skill-browser",children:[l.jsxs("section",{className:"session-skill-spaces","aria-label":"Skill Space 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Skill Space"}),l.jsx("span",{children:E.length})]}),l.jsx(Vh,{value:N,label:"搜索 Skill Space",placeholder:"搜索空间",onChange:S,autoFocus:!0})]}),l.jsx("div",{className:"session-skill-pane-list",children:U?l.jsx("div",{className:"session-capability-loading",children:"正在读取 Skill Space…"}):z.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的 Skill Space"}):z.map(V=>l.jsx("button",{type:"button",className:`session-skill-space${(_==null?void 0:_.id)===V.id?" is-active":""}`,onClick:()=>{k(V),M("")},children:l.jsxs("span",{children:[l.jsx("strong",{children:V.name||V.id}),l.jsx("small",{children:V.description||V.id}),l.jsxs("em",{children:[V.skillCount??0," 个技能"]})]})},`${V.projectName??"default"}:${V.id}`))})]}),l.jsxs("section",{className:"session-skill-results","aria-label":"AgentKit Skill 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{title:_==null?void 0:_.name,children:(_==null?void 0:_.name)||"选择 Skill Space"}),l.jsx("span",{children:T.length})]}),l.jsx(Vh,{value:C,label:"搜索 AgentKit 技能",placeholder:"搜索技能名称或描述",onChange:M})]}),l.jsx("div",{className:"session-skill-pane-list",children:I?l.jsx("div",{className:"session-capability-error",children:I}):_?P?l.jsx("div",{className:"session-capability-loading",children:"正在读取技能…"}):Y.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的技能"}):Y.map(V=>{const ee=R.has(V.skillName),oe=O===V.skillId;return l.jsxs("article",{className:"session-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:V.skillName}),l.jsx("span",{children:V.skillDescription||"暂无描述"}),l.jsxs("small",{children:["版本 ",V.version||"—"]})]}),l.jsx("button",{type:"button",disabled:ee||r||!!O,onClick:()=>void j(V),children:ee?"已添加":oe?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(KS,{}),"添加"]})})]},`${V.skillId}:${V.version}`)}):l.jsx("div",{className:"session-capability-empty",children:"选择一个 Skill Space 查看技能"})})]})]})]})})}function ji({as:e="span",className:t="",duration:n=4,spread:r=20,children:s,style:i,...a}){const o=Math.min(Math.max(r,5),45);return l.jsx(e,{className:`text-shimmer${t?` ${t}`:""}`,style:{...i,backgroundImage:`linear-gradient(to right, hsl(var(--muted-foreground)) ${50-o}%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground)) ${50+o}%)`,animationDuration:`${n}s`},...a,children:s})}const Jee={llm:"LLM",sequential:"顺序",parallel:"并行",loop:"循环",a2a:"A2A"};function E3(e){return 1+e.children.reduce((t,n)=>t+E3(n),0)}function Zl(e){return e.id||e.name}function ete(e,t){const n=Zl(e);if(e.id&&e.name&&e.name!==n)return e.name;if(t&&n==="agent")return"主 Agent";const r=/^agent_sub_(\d+)$/.exec(n);return r?`子 Agent ${r[1]}`:e.name||n}function x3(e,t=!0){return{...e,id:Zl(e),name:ete(e,t),children:e.children.map(n=>x3(n,!1))}}function w3(e,t){t.set(Zl(e),e.name||Zl(e)),e.children.forEach(n=>w3(n,t))}function tte(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function nte(e){return[...new Map(e.filter(t=>t.name.trim()).map(t=>[t.name.trim(),{...t,name:t.name.trim()}])).values()]}function v3({node:e,activeAgent:t,seen:n,path:r}){const s=Zl(e),i=!!s&&s===t,a=!!s&&!i&&r.has(s),o=!!s&&!i&&!a&&n.has(s);return l.jsxs("div",{className:"topo-branch",children:[l.jsxs("div",{className:`topo-node topo-type-${e.type} ${i?"is-active":""} ${a?"is-onpath":""} ${o?"is-done":""}`,title:e.description||e.name,children:[l.jsx(ql,{className:"topo-icon"}),l.jsx("span",{className:"topo-name",children:e.name||"未命名 Agent"}),l.jsx("span",{className:"topo-badge",children:Jee[e.type]??"Agent"})]}),i&&e.type==="a2a"&&l.jsx("div",{className:"topo-remote",children:"远程执行中…"}),e.children.length>0&&l.jsx("div",{className:"topo-children",children:e.children.map(c=>l.jsx(v3,{node:c,activeAgent:t,seen:n,path:r},Zl(c)))})]})}function W0({title:e,count:t}){return l.jsxs("div",{className:"topo-module-title",children:[l.jsx("span",{className:"topo-module-label",title:e,children:e}),l.jsx("span",{className:"topo-section-count","aria-label":`${t} 项`,children:t})]})}function _3({appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i=[],variant:a="rail",capabilities:o=null,capabilityLoading:c=!1,capabilityMutating:u=!1,builtinTools:d=[],onAddCapability:f,onRemoveCapability:h}){const[p,m]=v.useState(null);if(n&&!t)return l.jsx("aside",{className:`topo is-loading${a==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息","aria-live":"polite",children:l.jsx(ji,{as:"span",className:"topo-loading-label",duration:2.2,children:"正在读取 Agent 信息…"})});if(!t)return null;const g=x3(t.graph??{id:t.name,name:t.name,description:t.description,type:t.type??"llm",model:t.model,tools:t.tools,skills:t.skills,path:[t.name],mentionable:!1,children:[]}),x=(o==null?void 0:o.tools)??tte(t.tools).map(k=>({id:`base:tool:${k}`,kind:"tool",name:k,custom:!1})),y=(o==null?void 0:o.skills)??nte(t.skills).map(k=>({id:`base:skill:${k.name}`,kind:"skill",name:k.name,description:k.description,custom:!1})),E=!!(o&&f&&h),b=new Set(i),_=new Map;return w3(g,_),l.jsxs("aside",{className:`topo${a==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息与拓扑",children:[l.jsxs("section",{className:"topo-agent-card","aria-label":"Agent 信息",children:[l.jsxs("div",{className:"topo-agent-heading",children:[l.jsx("h2",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]}),t.description&&l.jsx("p",{className:"topo-description",title:t.description,children:t.description})]}),l.jsxs("div",{className:"topo-module-stack",children:[l.jsxs("section",{className:"topo-module-card topo-tools-card","aria-label":"工具",children:[l.jsx(W0,{title:"工具",count:x.length}),l.jsx("div",{className:"topo-module-scroll topo-tools-scroll",role:"region","aria-label":"工具列表",tabIndex:0,children:x.length>0?l.jsx("div",{className:"topo-tool-list",children:x.map(k=>l.jsxs("div",{className:"topo-tool",title:k.name,children:[l.jsxs("span",{className:"topo-capability-title",children:[l.jsxs("span",{className:"topo-capability-copy",children:[l.jsx("span",{className:"topo-capability-name",children:b1(k.name)}),l.jsx("code",{children:k.name})]}),k.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"})]}),k.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除工具 ${k.name}`,title:"移除",disabled:u,onClick:()=>h==null?void 0:h(k.id),children:"×"})]},k.id))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),E&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加内置工具",disabled:c||u,onClick:()=>m("tool"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加工具"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-skills-card","aria-label":"技能",children:[l.jsx(W0,{title:"技能",count:y.length}),l.jsx("div",{className:"topo-module-scroll topo-skills-scroll",role:"region","aria-label":"技能列表",tabIndex:0,children:y.length>0?l.jsx("div",{className:"topo-skill-list",children:y.map(k=>l.jsxs("div",{className:"topo-skill",title:k.description||k.name,children:[l.jsxs("div",{className:"topo-skill-title",children:[l.jsx("span",{className:"topo-skill-name",children:k.name}),k.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"}),k.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除技能 ${k.name}`,title:"移除",disabled:u,onClick:()=>h==null?void 0:h(k.id),children:"×"})]}),k.description&&l.jsx("span",{className:"topo-skill-description",children:k.description})]},`${k.name}:${k.description}`))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),E&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加技能",disabled:c||u,onClick:()=>m("skill"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加技能"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-topology","aria-label":"Agent 拓扑",children:[l.jsx(W0,{title:"拓扑",count:E3(g)}),l.jsxs("div",{className:"topo-module-scroll topo-topology-scroll",role:"region","aria-label":"Agent 拓扑列表",tabIndex:0,children:[i.length>1&&l.jsx("div",{className:"topo-path","aria-label":"执行路径",children:i.map((k,T)=>l.jsx("span",{className:"topo-path-seg",children:l.jsx("span",{className:T===i.length-1?"topo-path-name is-current":"topo-path-name",children:_.get(k)??k})},`${k}-${T}`))}),l.jsx("div",{className:"topo-tree",children:l.jsx(v3,{node:g,activeAgent:r,seen:s,path:b})})]})]})]}),p==="tool"&&f&&l.jsx(Qee,{agentName:t.name,tools:d,selectedNames:x.map(k=>k.name),mutating:u,onAdd:f,onClose:()=>m(null)}),p==="skill"&&f&&l.jsx(Zee,{appName:e,agentName:t.name,selectedNames:y.map(k=>k.name),mutating:u,onAdd:f,onClose:()=>m(null)})]})}function rte(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M6 6l12 12M18 6 6 18"})})}function ste({appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i,capabilities:a,capabilityLoading:o,capabilityMutating:c,builtinTools:u,onAddCapability:d,onRemoveCapability:f,onClose:h,returnFocusRef:p}){return v.useEffect(()=>{const m=document.body.style.overflow;document.body.style.overflow="hidden";const g=x=>{x.key==="Escape"&&h()};return document.addEventListener("keydown",g),()=>{var x;document.removeEventListener("keydown",g),document.body.style.overflow=m,(x=p.current)==null||x.focus()}},[h,p]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim agent-info-scrim",onClick:h}),l.jsxs("aside",{className:"drawer drawer--agent-info",role:"dialog","aria-modal":"true","aria-labelledby":"agent-info-drawer-title",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{id:"agent-info-drawer-title",className:"drawer-title",children:"Agent 信息"}),l.jsx("div",{className:"drawer-sub",children:"能力与协作拓扑"})]}),l.jsx("button",{type:"button",className:"drawer-close",onClick:h,"aria-label":"关闭 Agent 信息",autoFocus:!0,children:l.jsx(rte,{})})]}),l.jsx("div",{className:"agent-info-drawer-body",children:t||n?l.jsx(_3,{appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i,capabilities:a,capabilityLoading:o,capabilityMutating:c,builtinTools:u,onAddCapability:d,onRemoveCapability:f,variant:"drawer"}):l.jsx("div",{className:"drawer-empty",children:"暂时无法读取 Agent 信息。"})})]})]})}function ite({onAdded:e,onCancel:t}){const[n,r]=v.useState(""),[s,i]=v.useState(""),[a,o]=v.useState(""),[c,u]=v.useState(!1),[d,f]=v.useState(""),h=n.trim().length>0&&s.trim().length>0&&!c;async function p(){if(h){u(!0),f("");try{const m=await f3(a,n,s,a);if(m.apps.length===0){f("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。"),u(!1);return}e(mo(m.id,m.apps[0]))}catch(m){f(`连接失败:${String(m)}。请检查 URL、API Key,以及该网关是否允许跨域。`),u(!1)}}}return l.jsx("div",{className:"addagent",children:l.jsxs("div",{className:"addagent-card",children:[l.jsx("h2",{className:"addagent-title",children:"添加 AgentKit 智能体"}),l.jsx("p",{className:"addagent-sub",children:"填入 AgentKit 部署的访问地址与 API Key,将通过 ADK 协议连接,连接成功后其 Agent 会出现在左上角的下拉中。"}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"访问地址 URL"}),l.jsx("input",{className:"addagent-input",value:n,onChange:m=>r(m.target.value),placeholder:"https://xxxxx.apigateway-cn-beijing.volceapi.com",autoFocus:!0})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"API Key"}),l.jsx("input",{className:"addagent-input",type:"password",value:s,onChange:m=>i(m.target.value),placeholder:"以 Authorization: Bearer 方式连接"})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"显示名称(可选)"}),l.jsx("input",{className:"addagent-input",value:a,onChange:m=>o(m.target.value),placeholder:"默认取 URL 的主机名"})]}),d&&l.jsx("div",{className:"addagent-error",children:d}),l.jsxs("div",{className:"addagent-actions",children:[l.jsx("button",{className:"addagent-btn addagent-btn--ghost",onClick:t,disabled:c,children:"取消"}),l.jsxs("button",{className:"addagent-btn addagent-btn--primary",onClick:p,disabled:!h,children:[c?l.jsx(bt,{className:"icon spin"}):null,c?"连接中…":"连接并添加"]})]})]})})}function ate({currentRuntimeId:e,onConnect:t}){const[n,r]=v.useState([]),[s,i]=v.useState(!0),[a,o]=v.useState(""),[c,u]=v.useState(null),[d,f]=v.useState(null),[h,p]=v.useState(null),[m,g]=v.useState({}),[x,y]=v.useState("cn-beijing"),[E,b]=v.useState(!1),_=v.useCallback(async()=>{i(!0),o("");try{r(await yL(x))}catch(S){o(S instanceof Error?S.message:String(S))}finally{i(!1)}},[x]);v.useEffect(()=>{_()},[_]);async function k(S){g(M=>({...M,[S.runtimeId]:{loading:!0}}));const C={loading:!1};try{C.detail=await Lx(S.runtimeId,S.region)}catch(M){C.error=M instanceof Error?M.message:String(M)}C.detail&&(C.graphs=[{name:C.detail.name,description:C.detail.description,type:"llm",model:C.detail.model,tools:[],skills:[],path:[C.detail.name],mentionable:!1,children:[]}],C.graphNote="仅显示主 Agent(控制面信息)。"),g(M=>({...M,[S.runtimeId]:C}))}function T(S){const C=h===S.runtimeId;p(C?null:S.runtimeId),!C&&!m[S.runtimeId]&&k(S)}async function A(S){if(!c&&window.confirm(`确定删除 Agent "${S.name}"?该 Runtime 将被永久删除。`)){u(S.runtimeId),o("");try{await kL(S.runtimeId,S.region),r(C=>C.filter(M=>M.runtimeId!==S.runtimeId))}catch(C){o(C instanceof Error?C.message:String(C))}finally{u(null)}}}async function N(S){if(!(d||e===S.runtimeId)){f(S.runtimeId),o("");try{await t(S)}catch(C){o(C instanceof Error?C.message:String(C))}finally{f(null)}}}return l.jsxs("div",{className:"manage",children:[l.jsxs("div",{className:"manage-head",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"manage-title",children:"管理 Agent"}),l.jsx("p",{className:"manage-sub",children:"列出你有权管理的 AgentKit Runtime"})]}),l.jsxs("div",{className:"manage-head-actions",children:[l.jsxs("div",{className:"manage-region-picker",onKeyDown:S=>{S.key==="Escape"&&b(!1)},children:[l.jsxs("button",{type:"button",className:"manage-region",onClick:()=>b(S=>!S),title:"按区域筛选","aria-label":"区域筛选","aria-haspopup":"listbox","aria-expanded":E,children:[l.jsx("span",{children:x==="cn-beijing"?"北京":"上海"}),l.jsx(od,{className:`manage-region-chevron${E?" is-open":""}`})]}),E&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>b(!1)}),l.jsx("div",{className:"manage-region-menu",role:"listbox","aria-label":"区域",children:[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}].map(S=>{const C=S.value===x;return l.jsxs("button",{type:"button",role:"option","aria-selected":C,className:`manage-region-option${C?" is-selected":""}`,onClick:()=>{y(S.value),b(!1)},children:[l.jsx("span",{children:S.label}),C&&l.jsx(Bs,{"aria-hidden":"true"})]},S.value)})})]})]}),l.jsxs("button",{type:"button",className:"manage-refresh",onClick:()=>void _(),disabled:s,title:"刷新",children:[l.jsx(kx,{className:`icon ${s?"spin":""}`}),"刷新"]})]})]}),a&&l.jsx("div",{className:"manage-error",children:a}),s?l.jsxs("div",{className:"manage-empty",children:[l.jsx(bt,{className:"icon spin"})," 加载中…"]}):n.length===0?l.jsx("div",{className:"manage-empty",children:"暂无你部署的 Agent。"}):l.jsx("ul",{className:"manage-list",children:n.map(S=>{const C=h===S.runtimeId,M=m[S.runtimeId];return l.jsxs("li",{className:"manage-item",children:[l.jsxs("div",{className:"manage-item-row",children:[l.jsxs("button",{type:"button",className:"manage-item-toggle",onClick:()=>T(S),"aria-expanded":C,children:[C?l.jsx(od,{className:"icon"}):l.jsx(Nr,{className:"icon"}),l.jsxs("span",{className:"manage-item-main",children:[l.jsx("span",{className:"manage-item-name",children:S.name}),l.jsx("span",{className:`manage-badge is-${dte(S.status)}`,children:S.status||"-"})]})]}),l.jsxs("div",{className:"manage-item-actions",children:[l.jsxs("button",{type:"button",className:"manage-connect",onClick:()=>void N(S),disabled:d!==null||e===S.runtimeId,children:[d===S.runtimeId?l.jsx(bt,{className:"icon spin"}):l.jsx(E7,{className:"icon"}),e===S.runtimeId?"已连接":"连接到此 Agent"]}),l.jsx("button",{type:"button",className:"manage-del",onClick:()=>void A(S),disabled:c===S.runtimeId,title:"删除该 Runtime",children:c===S.runtimeId?l.jsx(bt,{className:"icon spin"}):l.jsx(mc,{className:"icon"})})]})]}),l.jsxs("div",{className:"manage-item-meta",children:[l.jsx("span",{className:"manage-item-id",title:S.runtimeId,children:S.runtimeId}),l.jsx("span",{className:"manage-item-dot",children:"·"}),l.jsx("span",{children:S.region}),S.createdAt&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"manage-item-dot",children:"·"}),l.jsx("span",{children:T3(S.createdAt)})]})]}),C&&l.jsx("div",{className:"manage-detail",children:!M||M.loading?l.jsxs("div",{className:"manage-detail-loading",children:[l.jsx(bt,{className:"icon spin"})," 读取详情…"]}):l.jsxs(l.Fragment,{children:[M.error&&l.jsx("div",{className:"manage-error",children:M.error}),M.detail&&l.jsx(cte,{detail:M.detail}),l.jsx("div",{className:"manage-tree-head",children:"Agent 结构"}),M.graphs&&M.graphs.length>0?M.graphs.map((U,q)=>l.jsx(k3,{node:U},q)):l.jsx("div",{className:"manage-tree-note",children:M.graphNote})]})})]},S.runtimeId)})})]})}const ote=/KEY|SECRET|TOKEN|PASSWORD|CREDENTIAL/i;function lte({envKey:e,value:t}){const[n,r]=v.useState(!1);return!ote.test(e)||n?l.jsx("code",{className:"manage-env-v",children:t}):l.jsx("button",{type:"button",className:"manage-env-v manage-env-masked",title:"敏感值已隐藏,点击显示","aria-label":`显示 ${e} 的值`,onClick:()=>r(!0),children:"••••••••"})}function cte({detail:e}){const t=e.resources,n=[];e.model&&n.push(["模型",e.model]),e.description&&n.push(["描述",e.description]),e.statusMessage&&n.push(["状态信息",e.statusMessage]),e.project&&n.push(["Project",e.project]),e.currentVersion!=null&&n.push(["版本",String(e.currentVersion)]);const r=[t.cpuMilli!=null?`CPU ${t.cpuMilli}m`:"",t.memoryMb!=null?`内存 ${t.memoryMb}MB`:"",t.minInstance!=null||t.maxInstance!=null?`实例 ${t.minInstance??"?"}~${t.maxInstance??"?"}`:"",t.maxConcurrency!=null?`并发 ${t.maxConcurrency}`:""].filter(Boolean).join(" · ");return r&&n.push(["资源",r]),e.memoryId&&n.push(["Memory",e.memoryId]),e.toolId&&n.push(["Tool",e.toolId]),e.knowledgeId&&n.push(["Knowledge",e.knowledgeId]),e.mcpToolsetId&&n.push(["MCP Toolset",e.mcpToolsetId]),e.updatedAt&&n.push(["更新时间",T3(e.updatedAt)]),l.jsxs("div",{className:"manage-detail-card",children:[l.jsx("dl",{className:"manage-kv",children:n.map(([s,i])=>l.jsxs("div",{className:"manage-kv-row",children:[l.jsx("dt",{children:s}),l.jsx("dd",{children:i})]},s))}),e.envs.length>0&&l.jsxs("div",{className:"manage-envs",children:[l.jsx("div",{className:"manage-envs-head",children:"环境变量"}),e.envs.map(s=>l.jsxs("div",{className:"manage-env",children:[l.jsx("code",{className:"manage-env-k",children:s.key}),l.jsx(lte,{envKey:s.key,value:s.value})]},s.key))]})]})}const ute={llm:"LLM",sequential:"Sequential",parallel:"Parallel",loop:"Loop",a2a:"A2A"};function k3({node:e,depth:t=0}){return l.jsxs("div",{className:"manage-tree",style:{marginLeft:t?16:0},children:[l.jsxs("div",{className:"manage-tree-node",children:[l.jsx("span",{className:"manage-tree-name",children:e.name||"(未命名)"}),l.jsx("span",{className:"manage-tree-type",children:ute[e.type]||e.type}),e.model&&l.jsx("span",{className:"manage-tree-model",children:e.model})]}),e.tools.length>0&&l.jsx("div",{className:"manage-tree-tools",children:e.tools.map(n=>l.jsx("span",{className:"manage-tree-tool",children:n},n))}),e.children.map((n,r)=>l.jsx(k3,{node:n,depth:t+1},r))]})}function dte(e){const t=(e||"").toLowerCase();return t.includes("run")||t.includes("ready")||t.includes("active")?"ok":t.includes("creat")||t.includes("pend")||t.includes("deploy")?"warn":t.includes("fail")||t.includes("error")||t.includes("delet")?"bad":"muted"}function T3(e){const t=Number(e),n=Number.isFinite(t)&&String(t)===e?new Date(t*1e3):new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString()}const fte={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 hte(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const s of n){if(r==null||typeof r!="object")return;r=r[s]}return r}function pte(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function mte(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function cw(e,t){if(pte(e))return hte(t,e.path);if(mte(e)){const n=fte[e.call],r={};for(const[s,i]of Object.entries(e.args??{}))r[s]=cw(i,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function gte(e,t){const n=cw(e,t);return n==null?"":typeof n=="string"?n:String(n)}const S3=new Map;function Co(e,t){S3.set(e,t)}function yte(e){return S3.get(e)}function bte(e,t,n){const r=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let s=e;for(let i=0;icw(r,e.dataModel),resolveString:r=>gte(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const s=e.components[r];if(!s)return null;const i=yte(s.component)??Ete;return l.jsx(i,{node:s,ctx:n},r)}};return l.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function wte(e){const t=v.useRef(null),n=v.useRef(!0),r=28,s=v.useCallback(()=>{const i=t.current;i&&(n.current=i.scrollHeight-i.scrollTop-i.clientHeight{const i=t.current;i&&n.current&&(i.scrollTop=i.scrollHeight)},[e]),{ref:t,onScroll:s}}function uw({value:e,onRemoveSkill:t,onRemoveAgent:n}){return e.skills.length===0&&!e.targetAgent?null:l.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(r=>l.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:r.description,children:[l.jsx(ho,{"aria-hidden":!0}),l.jsxs("span",{children:["/",r.name]}),t?l.jsx("button",{type:"button",onClick:()=>t(r.name),"aria-label":`移除技能 ${r.name}`,children:l.jsx(Wr,{})}):null]},r.name)),e.targetAgent?l.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[l.jsx(LR,{"aria-hidden":!0}),l.jsx("span",{children:e.targetAgent.name}),n?l.jsx("button",{type:"button",onClick:n,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:l.jsx(Wr,{})}):null]}):null]})}function dw(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function A3(e){var n,r,s,i;const t=dw(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"?((i=(s=e.mimeType)==null?void 0:s.split("/")[1])==null?void 0:i.toUpperCase())??"IMAGE":"TXT"}function C3(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function I3(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?rL(t,e.uri):""}function vte({kind:e}){return e==="image"?l.jsx(BR,{}):e==="video"?l.jsx(PR,{}):e==="pdf"?l.jsx(u7,{}):l.jsx(DR,{})}function fw({appName:e,items:t,compact:n=!1,onRemove:r}){const[s,i]=v.useState(null);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const o=dw(a.mimeType),c=I3(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=l.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:()=>i(a),"aria-label":`预览 ${a.name??"附件"}`,children:[o==="image"&&c?l.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):o==="video"&&c?l.jsxs("div",{className:"media-card-video-container",children:[l.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),l.jsx("span",{className:"media-card-video-play",children:l.jsx(I7,{})})]}):l.jsx("span",{className:"media-card-icon",children:l.jsx(vte,{kind:o})}),l.jsxs("span",{className:"media-card-copy",children:[l.jsx("span",{className:"media-card-name",children:a.name??"附件"}),l.jsxs("span",{className:"media-card-meta",children:[l.jsx("span",{className:"media-card-type",children:A3(a)}),a.status==="uploading"?l.jsxs(l.Fragment,{children:[l.jsx(bt,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":C3(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?l.jsx(_u,{className:"media-card-open"}):null]});return l.jsxs(Rt.div,{className:`media-card media-card--${o}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[o==="image"&&!u?l.jsx(NR,{src:c,children:d}):d,r?l.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:l.jsx(Wr,{})}):null]},a.id)})}),l.jsx(Js,{children:s?l.jsx(_te,{appName:e,item:s,onClose:()=>i(null)}):null})]})}function _te({appName:e,item:t,onClose:n}){const r=v.useMemo(()=>I3(t,e),[e,t]),s=dw(t.mimeType),[i,a]=v.useState(""),[o,c]=v.useState(s==="text"||s==="markdown"),[u,d]=v.useState("");return v.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),v.useEffect(()=>{if(s!=="text"&&s!=="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()},[s,r]),l.jsx(Rt.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:l.jsxs(Rt.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:[l.jsxs("header",{className:"media-viewer-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:t.name??"附件"}),l.jsxs("span",{children:[A3(t),t.sizeBytes?` · ${C3(t.sizeBytes)}`:""]})]}),l.jsxs("nav",{children:[l.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:l.jsx(xx,{})}),l.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:l.jsx(Wr,{})})]})]}),l.jsxs("div",{className:`media-viewer-body media-viewer-body--${s}`,children:[s==="image"?l.jsx("img",{src:r,alt:t.name??"图片"}):null,s==="video"?l.jsx("div",{className:"media-viewer-video-wrapper",children:l.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,s==="pdf"?l.jsx("iframe",{src:r,title:t.name??"PDF"}):null,o?l.jsxs("div",{className:"media-viewer-loading",children:[l.jsx(bt,{})," 正在读取文档…"]}):null,!o&&u?l.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!o&&s==="markdown"?l.jsx("div",{className:"media-document",children:l.jsx(Gd,{text:i})}):null,!o&&s==="text"?l.jsx("pre",{className:"media-document media-document--plain",children:i}):null]})]})})}function kte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),l.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 Tte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),l.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),l.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),l.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 Ste(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.5",width:"16.25",height:"13",rx:"2.4"}),l.jsx("path",{d:"m10.2 9.2 4.4 2.8-4.4 2.8V9.2Z"}),l.jsx("path",{d:"m19.25 2.5.42 1.2 1.2.42-1.2.42-.42 1.2-.42-1.2-1.2-.42 1.2-.42.42-1.2Z",fill:"currentColor",stroke:"none"})]})}function Nte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.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"}),l.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"}),l.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function Ate(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),l.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),l.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),l.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Cte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.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"}),l.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"}),l.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 Ite(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),l.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),l.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"}),l.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function R3(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Rte({definition:e,label:t,done:n,open:r,onToggle:s}){const i=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return l.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:s,"aria-expanded":r,children:[l.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:l.jsx(i,{})}),n?l.jsx("span",{className:"builtin-tool-label",children:a}):l.jsx(ji,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),l.jsx(R3,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}const Lte={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:kte},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Ite},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Tte},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:Ste},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Nte},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:Ate},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Cte}};function Ote(e){return Lte[e]}const L3="send_a2ui_json_to_client",Mte=28;function Dte(e,t,n){let r=t;for(let s=0;s65535?2:1}return r}function Pte(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function O3(e,t,n){const[r,s]=v.useState(()=>t?"":e),i=v.useRef(r),a=v.useRef(e),o=v.useRef(null),c=v.useRef(0),u=v.useRef(n);return a.current=e,u.current=n,v.useEffect(()=>{const d=i.current,f=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||f||!e.startsWith(d)){o.current!==null&&window.cancelAnimationFrame(o.current),o.current=null,d!==e&&(i.current=e,s(e));return}if(d===e||o.current!==null)return;const h=p=>{const m=a.current,g=i.current;if(!m.startsWith(g)){i.current=m,s(m),o.current=null;return}if(p-c.current{var d;(d=u.current)==null||d.call(u)},[r]),v.useEffect(()=>()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)},[]),r}function jte({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:l.jsx("path",{d:"M12 2.2l1.7 5.1a3 3 0 0 0 1.9 1.9L20.8 11l-5.1 1.7a3 3 0 0 0-1.9 1.9L12 19.8l-1.7-5.1a3 3 0 0 0-1.9-1.9L3.2 11l5.1-1.7a3 3 0 0 0 1.9-1.9L12 2.2z"})})}function Bte(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.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 Fte(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 M3({text:e,done:t,streaming:n=!1,onStreamFrame:r}){const[s,i]=v.useState(!t),a=v.useRef(!1);v.useEffect(()=>{a.current||i(!t)},[t]);const o=()=>{a.current=!0,i(h=>!h)},c=e.replace(/^\s+/,""),u=O3(c,!t||n,r),{ref:d,onScroll:f}=wte(u);return l.jsxs("div",{className:"block-thinking",children:[l.jsxs("button",{className:"think-head",onClick:o,type:"button",children:[l.jsx("span",{className:"think-icon","aria-hidden":"true",children:l.jsx(jte,{className:`spark ${t?"":"pulse"}`})}),t?l.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):l.jsx(ji,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),l.jsx(Nr,{className:`chev ${s?"open":""}`})]}),l.jsx("div",{className:`think-collapse ${s&&u?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsx("div",{className:"think-body scroll",ref:d,onScroll:f,children:u})})})]})}function D3(){return l.jsx(M3,{text:"",done:!1})}const Ute=v.memo(function({text:t,streaming:n,onStreamFrame:r}){const s=O3(t,n,r);return s?l.jsx("div",{className:"bubble",children:l.jsx(Gd,{text:s})}):null});function $te({name:e,args:t,response:n,done:r}){const[s,i]=v.useState(!1),a=e===L3?"渲染 UI":e,o=Ote(e),c=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),u=c&&c.length>2e3?c.slice(0,2e3)+` +`,4);return n>=0?t.slice(n+5).trimStart():e}function eee({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5.25 7.5h5.25v5.25H5.25zM13.5 7.5h5.25v5.25H13.5zM9.38 15.75h5.24v3H9.38z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),l.jsx("path",{d:"M7.88 12.75v1.5c0 .83.67 1.5 1.5 1.5h5.24c.83 0 1.5-.67 1.5-1.5v-1.5M12 4.75V7.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),l.jsx("circle",{cx:"12",cy:"4.75",r:"1",fill:"currentColor"})]})}function tee({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M6.25 4.75h8.6l2.9 2.9v11.6h-11.5z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),l.jsx("path",{d:"M14.75 4.9v3h2.85M8.9 11.1h4.2M8.9 14h5.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),l.jsx("path",{d:"m17.85 13.85.42 1.13 1.13.42-1.13.42-.42 1.13-.42-1.13-1.13-.42 1.13-.42z",fill:"currentColor"})]})}function nee(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m7.5 7.5 9 9m0-9-9 9",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function MS({direction:e}){return l.jsx("svg",{className:"icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:e==="left"?"m11.7 5.5-4.2 4.5 4.2 4.5":"m8.3 5.5 4.2 4.5-4.2 4.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function m1(){return l.jsx("span",{className:"skillcenter-loading-mark","aria-hidden":!0})}function DS({page:e,total:t,pageSize:n,onPage:r}){const s=Math.max(1,Math.ceil(t/n));return l.jsxs("footer",{className:"skillcenter-pager",children:[l.jsxs("span",{children:["共 ",t," 项"]}),l.jsxs("div",{className:"skillcenter-pager-actions",children:[l.jsx("button",{type:"button",onClick:()=>r(e-1),disabled:e<=1,"aria-label":"上一页",children:l.jsx(MS,{direction:"left"})}),l.jsxs("span",{children:[e," / ",s]}),l.jsx("button",{type:"button",onClick:()=>r(e+1),disabled:e>=s,"aria-label":"下一页",children:l.jsx(MS,{direction:"right"})})]})]})}function Hh({children:e}){return l.jsx("div",{className:"skillcenter-empty",children:e})}function ree({skill:e,space:t,region:n,detail:r,loading:s,error:i,onClose:a}){return v.useEffect(()=>{const o=c=>{c.key==="Escape"&&a()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a]),l.jsx("div",{className:"skill-detail-backdrop",role:"presentation",onMouseDown:a,children:l.jsxs("section",{className:"skill-detail-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"skill-detail-title",onMouseDown:o=>o.stopPropagation(),children:[l.jsxs("header",{className:"skill-detail-head",children:[l.jsxs("div",{className:"skill-detail-heading",children:[l.jsx("span",{className:"skillcenter-symbol skillcenter-symbol--skill",children:l.jsx(tee,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"skill-detail-title",children:(r==null?void 0:r.name)||e.skillName}),l.jsx("p",{children:(r==null?void 0:r.description)||e.skillDescription||"暂无描述"})]})]}),l.jsx("button",{type:"button",className:"skill-detail-close",onClick:a,"aria-label":"关闭技能详情",children:l.jsx(nee,{})})]}),l.jsxs("dl",{className:"skill-detail-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"技能 ID"}),l.jsx("dd",{title:e.skillId,children:e.skillId})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"版本"}),l.jsx("dd",{children:(r==null?void 0:r.version)||e.version||"—"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"状态"}),l.jsx("dd",{children:p1(e.skillStatus)})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"技能空间"}),l.jsx("dd",{title:t.name,children:t.name})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Project"}),l.jsx("dd",{title:t.projectName||"default",children:t.projectName||"default"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"地域"}),l.jsx("dd",{children:n==="cn-beijing"?"北京":"上海"})]})]}),l.jsxs("div",{className:"skill-detail-content",children:[l.jsx("div",{className:"skill-detail-content-title",children:"SKILL.md"}),s?l.jsxs("div",{className:"skillcenter-loading",children:[l.jsx(m1,{}),"正在读取技能内容…"]}):i?l.jsx("div",{className:"skillcenter-error",children:i}):r!=null&&r.skillMd?l.jsx(Gd,{text:JJ(r.skillMd),className:"skill-detail-markdown",allowRawHtml:!1}):l.jsx(Hh,{children:"该技能暂无 SKILL.md 内容"})]})]})})}function see({onClick:e}){return l.jsxs("button",{className:"new-chat",onClick:e,"aria-label":"技能中心",title:"技能中心",children:[l.jsx(eee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"技能中心"})]})}function iee(){const[e,t]=v.useState("cn-beijing"),[n,r]=v.useState([]),[s,i]=v.useState(1),[a,o]=v.useState(0),[c,u]=v.useState(!1),[d,f]=v.useState(""),[h,p]=v.useState(null),[m,g]=v.useState([]),[x,y]=v.useState(1),[E,b]=v.useState(0),[_,k]=v.useState(!1),[T,A]=v.useState(""),[N,S]=v.useState(null),[C,M]=v.useState(null),[U,q]=v.useState(!1),[P,D]=v.useState(""),I=v.useRef(0);v.useEffect(()=>{let z=!0;return u(!0),f(""),b$({region:e,page:s,pageSize:RS}).then(Y=>{if(!z)return;const j=Y.items||[];r(j),o(Y.totalCount||0),p(re=>j.find(V=>V.id===(re==null?void 0:re.id))||null)}).catch(Y=>{z&&(r([]),o(0),p(null),f(Y instanceof Error?Y.message:"读取技能空间失败,请稍后重试"))}).finally(()=>{z&&u(!1)}),()=>{z=!1}},[e,s]),v.useEffect(()=>{if(!h){g([]),b(0);return}let z=!0;return k(!0),A(""),E$(h.id,{region:e,page:x,pageSize:LS,project:h.projectName}).then(Y=>{z&&(g(Y.items||[]),b(Y.totalCount||0))}).catch(Y=>{z&&(g([]),b(0),A(Y instanceof Error?Y.message:"读取技能失败,请稍后重试"))}).finally(()=>{z&&k(!1)}),()=>{z=!1}},[e,h,x]);const L=z=>{z!==e&&(B(),t(z),i(1),y(1),p(null),g([]))},O=z=>{B(),p(z),y(1)},B=()=>{I.current+=1,S(null),M(null),D(""),q(!1)},R=async z=>{if(!h)return;const Y=I.current+1;I.current=Y,S(z),M(null),D(""),q(!0);try{const j=await x$(h.id,z.skillId,z.version,e,h.projectName);I.current===Y&&M(j)}catch(j){I.current===Y&&D(j instanceof Error?j.message:"读取技能详情失败,请稍后重试")}finally{I.current===Y&&q(!1)}};return l.jsxs("section",{className:"skillcenter",children:[l.jsxs("div",{className:"skillcenter-browser",children:[l.jsxs("section",{className:"skillcenter-panel","aria-label":"技能空间列表",children:[l.jsxs("header",{className:"skillcenter-panel-head",children:[l.jsxs("div",{children:[l.jsx("h2",{children:"技能空间"}),l.jsx("span",{className:"skillcenter-count-badge",children:a})]}),l.jsxs("div",{className:"skillcenter-regions","aria-label":"地域",children:[l.jsx("button",{type:"button",className:e==="cn-beijing"?"active":"",onClick:()=>L("cn-beijing"),children:"北京"}),l.jsx("button",{type:"button",className:e==="cn-shanghai"?"active":"",onClick:()=>L("cn-shanghai"),children:"上海"})]})]}),l.jsxs("div",{className:"skillcenter-listwrap",children:[c&&l.jsxs("div",{className:"skillcenter-loading skillcenter-loading--overlay",children:[l.jsx(m1,{}),"正在读取技能空间…"]}),d?l.jsx("div",{className:"skillcenter-error",children:d}):n.length===0&&!c?l.jsx(Hh,{children:"当前地域暂无可访问的技能空间"}):l.jsx("div",{className:"skillcenter-list",children:n.map(z=>l.jsx("button",{type:"button",className:`skillcenter-space-item ${(h==null?void 0:h.id)===z.id?"active":""}`,onClick:()=>O(z),children:l.jsxs("span",{className:"skillcenter-item-body",children:[l.jsx("span",{className:"skillcenter-item-title",title:z.name,children:z.name}),l.jsx("span",{className:"skillcenter-item-description",children:z.description||"暂无描述"}),l.jsxs("span",{className:"skillcenter-item-meta",children:[l.jsx("span",{className:`skillcenter-status ${OS(z.status)}`,children:p1(z.status)}),l.jsxs("span",{className:"skillcenter-meta-text",title:z.projectName||"default",children:["Project · ",z.projectName||"default"]}),l.jsxs("span",{className:"skillcenter-meta-text",children:[z.skillCount??0," 个技能"]}),z.updatedAt&&l.jsxs("span",{className:"skillcenter-meta-text",children:["更新于 ",ZJ(z.updatedAt)]})]})]})},`${z.projectName||"default"}:${z.id}`))})]}),l.jsx(DS,{page:s,total:a,pageSize:RS,onPage:i})]}),l.jsx("section",{className:"skillcenter-panel","aria-label":"技能列表",children:h?l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:"skillcenter-panel-head",children:[l.jsx("div",{children:l.jsxs("h2",{title:h.name,children:[h.name," · 技能"]})}),l.jsx("span",{children:E})]}),l.jsxs("div",{className:"skillcenter-listwrap",children:[_&&l.jsxs("div",{className:"skillcenter-loading skillcenter-loading--overlay",children:[l.jsx(m1,{}),"正在读取技能…"]}),T?l.jsx("div",{className:"skillcenter-error",children:T}):m.length===0&&!_?l.jsx(Hh,{children:"这个空间中暂无技能"}):l.jsx("div",{className:"skillcenter-list skillcenter-list--skills",children:m.map(z=>l.jsx("button",{type:"button",className:"skillcenter-skill-item",onClick:()=>void R(z),children:l.jsxs("span",{className:"skillcenter-item-body",children:[l.jsx("span",{className:"skillcenter-item-title",title:z.skillName,children:z.skillName}),l.jsx("span",{className:"skillcenter-item-description",children:z.skillDescription||"暂无描述"}),l.jsxs("span",{className:"skillcenter-item-meta",children:[l.jsx("span",{className:`skillcenter-status ${OS(z.skillStatus)}`,children:p1(z.skillStatus)}),l.jsxs("span",{className:"skillcenter-meta-text",children:["版本 · ",z.version||"—"]})]})]})},`${z.skillId}:${z.version}`))})]}),l.jsx(DS,{page:x,total:E,pageSize:LS,onPage:y})]}):l.jsx(Hh,{children:"点击 Skill 空间以查看详情"})})]}),N&&h&&l.jsx(ree,{skill:N,space:h,region:e,detail:C,loading:U,error:P,onClose:B})]})}const aee=50,PS=48;function oee(e){return(e.events??[]).flatMap(t=>{var s,i;const r=(((s=t.content)==null?void 0:s.parts)??[]).map(a=>typeof a.text=="string"?a.text:"").filter(Boolean).join("");return r?[{text:r,role:t.author??((i=t.content)==null?void 0:i.role)??"",ts:t.timestamp}]:[]})}function lee(e){var t,n;for(const r of e.events??[])if(r.author==="user"||((t=r.content)==null?void 0:t.role)==="user"){const s=(((n=r.content)==null?void 0:n.parts)??[]).map(i=>i.text).find(Boolean);if(s)return s}return"未命名会话"}function cee(e,t,n){const r=Math.max(0,t-PS),s=Math.min(e.length,t+n+PS);return(r>0?"…":"")+e.slice(r,s).trim()+(s{var c;if((c=o.events)!=null&&c.length)return o;try{return await jp(t,e,o.id)}catch{return o}})),a=[];for(const o of i)for(const{text:c,role:u,ts:d}of oee(o)){const f=c.toLowerCase().indexOf(r);if(f!==-1){a.push({type:"session",appId:t,sessionId:o.id,title:lee(o),snippet:cee(c,f,r.length),role:u,ts:d??o.lastUpdateTime});break}}return a.sort((o,c)=>(c.ts??0)-(o.ts??0)),a.slice(0,aee)}async function dee(e,t){if(!e||!t.trim())return{results:[]};let n;try{n=await hL(e,t.trim())}catch(a){const o=String(a);return{results:[],note:o.includes("404")?"网络搜索接口未就绪(后端未启用 /web/search)。":`网络搜索失败:${o}`}}const{mounted:r,results:s,error:i}=n;return r?i?{results:[],note:i}:{results:s.map((a,o)=>({type:"web",index:o,title:a.title,url:a.url,siteName:a.siteName,summary:a.summary}))}:{results:[],note:"当前 Agent 未挂载 web_search 工具。"}}async function fee(e,t,n,r){if(!t||!r.trim())return{results:[]};const s=await fL(t,e,r.trim(),n);if(!s.mounted)return{results:[],note:e==="knowledge"?"该 Agent 未挂载知识库。":"该 Agent 未挂载长期记忆。"};if(s.error)return{results:[],note:s.error};const i=s.sourceName??(e==="knowledge"?"知识库":"长期记忆");return{results:s.results.map((a,o)=>e==="knowledge"?{type:"knowledge",index:o,content:a.content,sourceName:i,sourceType:s.sourceType}:{type:"memory",index:o,content:a.content,sourceName:i,sourceType:s.sourceType,author:a.author,ts:a.timestamp})}}async function hee(e,t,n){return e==="session"?{results:await uee(n.userId,n.appId,t)}:e==="web"?dee(n.appId,t):fee(e,n.appId,n.userId,t)}function l3({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M16.4 10.7a5.7 5.7 0 1 1-1.67-4.03"}),l.jsx("path",{d:"M15.25 15.25 19.6 19.6"})]})}function pee({open:e}){return l.jsx("svg",{className:`search-source-chevron ${e?"open":""}`,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsx("path",{d:"m3.25 4.75 2.75 2.5 2.75-2.5"})})}function mee({onClick:e}){return l.jsxs("button",{className:"new-chat",onClick:e,"aria-label":"智能搜索",title:"智能搜索",children:[l.jsx(l3,{}),l.jsx("span",{className:"sidebar-nav-label",children:"智能搜索"})]})}function gee(e,t,n){const r=!!e,s=new Set((t==null?void 0:t.searchSources)??[]),i=a=>r?n?"正在检测 Agent 能力":`当前 Agent 未挂载${a}`:"请选择 Agent";return[{id:"session",label:"会话",ready:r,unavailableLabel:"请选择 Agent"},{id:"web",label:"网络",ready:r&&s.has("web"),description:"通过 web_search 工具检索",unavailableLabel:i(" web_search 工具")},{id:"knowledge",label:"知识库",ready:r&&s.has("knowledge"),unavailableLabel:i("知识库")},{id:"memory",label:"长期记忆",ready:r&&s.has("memory"),unavailableLabel:i("长期记忆")}]}function qp(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function jS(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}function yee({userId:e,appId:t,agentInfo:n,capabilitiesLoading:r,agentLabel:s,onOpenSession:i}){var D,I;const[a,o]=v.useState("session"),[c,u]=v.useState(""),[d,f]=v.useState([]),[h,p]=v.useState(),[m,g]=v.useState(!1),[x,y]=v.useState(!1),[E,b]=v.useState(!1),_=v.useRef(0),k=v.useRef(null),T=gee(t,n,r),A=T.find(L=>L.id===a),N=a==="knowledge"?(D=n==null?void 0:n.components)==null?void 0:D.find(L=>L.source==="knowledgebase"||L.kind==="knowledgebase"):a==="memory"?(I=n==null?void 0:n.components)==null?void 0:I.find(L=>L.source==="long_term_memory"||L.kind==="memory"):void 0;v.useEffect(()=>{_.current+=1,o("session"),f([]),p(void 0),y(!1),g(!1),b(!1)},[t]),v.useEffect(()=>{if(!E)return;function L(O){var B;(B=k.current)!=null&&B.contains(O.target)||b(!1)}return document.addEventListener("pointerdown",L),()=>document.removeEventListener("pointerdown",L)},[E]);async function S(L,O){var Y;const B=L.trim();if(!B||!((Y=T.find(j=>j.id===O))!=null&&Y.ready))return;const R=++_.current;g(!0),y(!0);let z;try{z=await hee(O,B,{userId:e,appId:t})}catch(j){const re=j instanceof Error?j.message:String(j);z={results:[],note:`搜索失败:${re}`}}R===_.current&&(f(z.results),p(z.note),g(!1))}function C(L){_.current+=1,u(L),f([]),p(void 0),y(!1),g(!1)}function M(L){_.current+=1,o(L),b(!1),f([]),p(void 0),y(!1),g(!1)}const U=!!(A!=null&&A.ready),q=t?a==="web"?"在网络中检索":a==="knowledge"?`在 ${(N==null?void 0:N.name)??"当前 Agent 的知识库"} 中检索`:a==="memory"?`在 ${(N==null?void 0:N.name)??"当前用户的长期记忆"} 中检索`:"在当前 Agent 的会话中检索":"请先选择 Agent",P=N!=null&&N.backend?qp(N.backend):"";return l.jsxs("div",{className:"search",children:[l.jsxs("div",{className:"search-box",children:[l.jsxs("div",{className:"search-source-picker-wrap",ref:k,children:[l.jsxs("button",{className:"search-source-picker",type:"button","aria-label":`搜索类型:${(A==null?void 0:A.label)??"未选择"}`,"aria-haspopup":"listbox","aria-expanded":E,onClick:()=>b(L=>!L),children:[l.jsx("span",{children:(A==null?void 0:A.label)??"搜索类型"}),P&&l.jsx("small",{children:P}),l.jsx(pee,{open:E})]}),E&&l.jsx("div",{className:"search-source-menu",role:"listbox","aria-label":"选择搜索类型",children:T.map(L=>{var R,z;const O=L.id==="knowledge"?(R=n==null?void 0:n.components)==null?void 0:R.find(Y=>Y.source==="knowledgebase"||Y.kind==="knowledgebase"):L.id==="memory"?(z=n==null?void 0:n.components)==null?void 0:z.find(Y=>Y.source==="long_term_memory"||Y.kind==="memory"):void 0,B=O?[O.name,O.backend?qp(O.backend):""].filter(Boolean).join(" · "):L.ready?L.description:L.unavailableLabel;return l.jsxs("button",{type:"button",role:"option","aria-selected":a===L.id,disabled:!L.ready,onClick:()=>M(L.id),children:[l.jsx("span",{children:L.label}),B&&l.jsx("small",{children:B})]},L.id)})})]}),l.jsx("span",{className:"search-box-divider","aria-hidden":!0}),l.jsx("input",{className:"search-input",value:c,onChange:L=>C(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),S(c,a))},placeholder:q,disabled:!U,autoFocus:!0}),l.jsx("button",{className:"search-go",onClick:()=>void S(c,a),disabled:!c.trim()||m,"aria-label":"搜索",children:m?l.jsx(bt,{className:"icon spin"}):l.jsx(l3,{className:"icon"})})]}),l.jsx("div",{className:"search-results",children:U?x?m?null:h?l.jsx("div",{className:"search-empty",children:h}):d.length===0&&x?l.jsxs("div",{className:"search-empty",children:["未找到匹配「",c.trim(),"」的结果。"]}):d.map((L,O)=>l.jsx(bee,{result:L,agentLabel:s,onOpen:i},O)):l.jsx("div",{className:"search-empty",children:a==="web"?"输入关键词后回车或点击按钮,通过 web_search 工具检索。":a==="knowledge"?"输入问题,检索当前 Agent 挂载的知识库。":a==="memory"?"输入线索,检索当前用户跨会话保存的长期记忆。":"输入关键词后回车或点击按钮,搜索当前 Agent 的会话。"}):l.jsx("div",{className:"search-empty",children:t?r?"正在读取当前 Agent 的检索能力…":(A==null?void 0:A.unavailableLabel)??"当前 Agent 未挂载该数据源":"选择一个 Agent 后,即可检索会话、网络及其挂载的数据源。"})})]})}function bee({result:e,agentLabel:t,onOpen:n}){switch(e.type){case"session":return l.jsxs("button",{className:"search-result",onClick:()=>n(e.appId,e.sessionId),children:[l.jsx(UR,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title}),l.jsxs("span",{className:"search-result-meta",children:[t(e.appId),e.ts?` · ${jS(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet",children:e.snippet})]})]});case"web":return l.jsxs("a",{className:"search-result",href:e.url||void 0,target:"_blank",rel:"noreferrer noopener",children:[l.jsx(_x,{className:"search-result-icon"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsx("span",{className:"search-result-title",children:e.title||e.url}),l.jsxs("span",{className:"search-result-meta",children:[e.siteName,e.url&&l.jsx(wx,{className:"search-result-ext"})]})]}),e.summary&&l.jsx("div",{className:"search-result-snippet",children:e.summary})]})]});case"knowledge":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(BS,{source:"knowledge"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["知识片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${qp(e.sourceType)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});case"memory":return l.jsxs("div",{className:"search-result search-result-static",children:[l.jsx(BS,{source:"memory"}),l.jsxs("div",{className:"search-result-body",children:[l.jsxs("div",{className:"search-result-head",children:[l.jsxs("span",{className:"search-result-title",children:["记忆片段 ",e.index+1]}),l.jsxs("span",{className:"search-result-meta",children:[e.sourceName,e.sourceType?` · ${qp(e.sourceType)}`:"",e.ts?` · ${jS(e.ts)}`:""]})]}),l.jsx("div",{className:"search-result-snippet search-result-snippet-expanded",children:e.content})]})]});default:return null}}function BS({source:e,className:t="search-result-icon"}){return e==="knowledge"?l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M5 5.5h10.5A3.5 3.5 0 0 1 19 9v9.5H8.5A3.5 3.5 0 0 1 5 15V5.5Z"}),l.jsx("path",{d:"M8.25 9h7.5M8.25 12.25h6"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[l.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 0 7.5 7.5"}),l.jsx("path",{d:"M12 8a4 4 0 1 0 4 4M12 11.3a.7.7 0 1 0 0 1.4.7.7 0 0 0 0-1.4Z"})]})}const ow="/assets/volcengine-DM14a-L-.svg",FS="(max-width: 860px)";function Eee(){return l.jsxs("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M12.5 3 5.5 13h5l-1 8 8-11h-5l.5-7z",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M19 4.5v3M17.5 6h3",opacity:"0.85"})]})}function xee(){return l.jsxs("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("circle",{cx:"8.25",cy:"7.75",r:"3.15"}),l.jsx("path",{d:"M2.9 19.2c.45-3.45 2.48-5.35 5.35-5.35 2.4 0 4.2 1.28 4.98 3.66"}),l.jsx("path",{d:"M17.4 4.5v15M14.8 9h5.2M14.8 15.3h5.2"}),l.jsx("circle",{cx:"17.4",cy:"9",r:"1.15",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"17.4",cy:"15.3",r:"1.15",fill:"currentColor",stroke:"none"})]})}function wee(e){let t=2166136261;for(const r of e)t^=r.charCodeAt(0),t=Math.imul(t,16777619);const n=t>>>0;return{"--avatar-hue-a":194+n%22,"--avatar-hue-b":214+(n>>>6)%25,"--avatar-hue-c":176+(n>>>12)%25,"--avatar-x":`${22+(n>>>18)%55}%`,"--avatar-y":`${18+(n>>>24)%58}%`}}const vee={admin:"管理员",developer:"开发者",user:"普通用户"};function US({role:e}){const t=vee[e];return l.jsx("span",{className:`studio-role-badge studio-role-badge--${e}`,title:t,children:t})}function _ee({version:e,onClose:t}){return v.useEffect(()=>{const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),ai.createPortal(l.jsx("div",{className:"confirm-scrim",onMouseDown:t,children:l.jsxs("section",{className:"confirm-box system-info-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"system-info-title",onMouseDown:n=>n.stopPropagation(),children:[l.jsxs("header",{className:"system-info-head",children:[l.jsx("h2",{id:"system-info-title",children:"系统信息"}),l.jsx("button",{type:"button",className:"icon-btn",onClick:t,"aria-label":"关闭系统信息",autoFocus:!0,children:l.jsx(Wr,{className:"icon","aria-hidden":"true"})})]}),l.jsx("dl",{className:"system-info-meta",children:l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:e||"—"})]})})]})}),document.body)}function kee({access:e,userInfo:t,version:n,onLogout:r}){const[s,i]=v.useState(!1),[a,o]=v.useState(!1),[c,u]=v.useState("");if(!t)return null;const d=q7(t),f=typeof t.email=="string"?t.email:"",h=(d||"U").slice(0,1).toUpperCase(),p=wee(d||f||h),m=G7(t),g=m===c?"":m;return l.jsxs("div",{className:"sidebar-user",children:[l.jsxs("button",{className:"sidebar-user-btn",onClick:()=>i(x=>!x),title:f?`${d} +${f}`:d,children:[l.jsxs("span",{className:`account-avatar${g?" has-image":""}`,style:p,children:[h,g?l.jsx("img",{className:"account-avatar-image",src:g,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>u(g)}):null]}),l.jsxs("span",{className:"sidebar-user-identity",children:[l.jsxs("span",{className:"sidebar-user-primary",children:[l.jsx("span",{className:"sidebar-user-name",children:d}),l.jsx(US,{role:e.role})]}),f&&f!==d&&l.jsx("span",{className:"sidebar-user-email",children:f})]})]}),s&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>i(!1)}),l.jsxs("div",{className:"account-pop sidebar-user-pop",children:[l.jsxs("div",{className:"account-head",children:[l.jsxs("span",{className:`account-avatar account-avatar--lg${g?" has-image":""}`,style:p,children:[h,g?l.jsx("img",{className:"account-avatar-image",src:g,alt:"","aria-hidden":"true",referrerPolicy:"no-referrer",onError:()=>u(g)}):null]}),l.jsxs("div",{className:"account-id",children:[l.jsxs("div",{className:"account-name-row",children:[l.jsx("div",{className:"account-name",children:d}),l.jsx(US,{role:e.role})]}),f&&f!==d&&l.jsx("div",{className:"account-sub",children:f})]})]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{i(!1),o(!0)},children:[l.jsx(Aa,{className:"icon"})," 系统信息"]}),l.jsxs("button",{type:"button",className:"account-action",onClick:()=>{i(!1),r()},children:[l.jsx(_7,{className:"icon"})," 退出登录"]})]})]}),a?l.jsx(_ee,{version:n,onClose:()=>o(!1)}):null]})}function Tee({branding:e,sessions:t,currentSessionId:n,features:r,access:s,streamingSids:i,onNewChat:a,onSearch:o,onQuickCreate:c,onSkillCenter:u,onAddAgent:d,onManageAgents:f,onPickSession:h,onDeleteSession:p,userInfo:m,version:g,onLogout:x}){const y=S=>(r==null?void 0:r[S])!==!1,[E,b]=v.useState(null),_=v.useRef(typeof window<"u"&&window.matchMedia(FS).matches),[k,T]=v.useState(_.current),A=[...t].sort((S,C)=>(C.lastUpdateTime??0)-(S.lastUpdateTime??0)),N=()=>{_.current=!1,T(S=>!S),b(null)};return v.useEffect(()=>{const S=window.matchMedia(FS),C=M=>{M.matches?T(U=>U||(_.current=!0,!0)):_.current&&(_.current=!1,T(!1))};return S.addEventListener("change",C),()=>S.removeEventListener("change",C)},[]),l.jsxs("aside",{className:`sidebar ${k?"is-collapsed":""}`,children:[l.jsxs("div",{className:"sidebar-top",children:[l.jsxs("div",{className:"sidebar-brand-row",children:[l.jsxs("div",{className:"brand",children:[l.jsx("img",{className:"brand-logo",src:e.logoUrl||ow,width:20,height:20,alt:"","aria-hidden":!0}),l.jsx("span",{className:"brand-title",children:e.title})]}),l.jsx("button",{type:"button",className:"sidebar-collapse-toggle",onClick:N,"aria-label":k?"展开侧边栏":"收起侧边栏",title:k?"展开侧边栏":"收起侧边栏",children:k?l.jsx(A7,{className:"icon"}):l.jsx(N7,{className:"icon"})})]}),y("newChat")&&l.jsxs("button",{className:"new-chat",onClick:a,"aria-label":"新会话",title:"新会话",children:[l.jsx(Ps,{className:"icon"}),l.jsx("span",{className:"sidebar-nav-label",children:"新会话"})]}),y("search")&&l.jsx(mee,{onClick:o}),y("skillCenter")&&l.jsx(see,{onClick:u}),s.capabilities.createAgents&&y("addAgent")&&l.jsxs("button",{className:"new-chat",onClick:c,"aria-label":"添加 Agent",title:"添加 Agent",children:[l.jsx(Eee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"添加 Agent"})]}),s.capabilities.manageAgents&&y("manageAgents")&&l.jsxs("button",{className:"new-chat",onClick:f,"aria-label":"管理 Agent",title:"管理 Agent",children:[l.jsx(xee,{}),l.jsx("span",{className:"sidebar-nav-label",children:"管理 Agent"})]})]}),y("history")&&l.jsxs("div",{className:"sidebar-history",children:[l.jsxs("div",{className:"history-head",children:[l.jsx("span",{children:"历史会话"}),y("newChat")&&l.jsx("button",{type:"button",className:"history-new-chat",onClick:a,"aria-label":"新建会话",title:"新建会话",children:l.jsx(Ps,{className:"icon"})})]}),l.jsxs("div",{className:"history-list",children:[A.length===0&&l.jsx("div",{className:"history-empty",children:"暂无会话"}),A.map(S=>{const C=y$(S.events);return l.jsxs("div",{className:`history-item ${S.id===n?"active":""}`,children:[l.jsxs("button",{className:"history-item-btn",onClick:()=>h(S.id),title:C,children:[(i==null?void 0:i.has(S.id))&&l.jsx("span",{className:"history-streaming",title:"正在生成…","aria-label":"正在生成"}),l.jsx("span",{className:"history-title",children:C})]}),l.jsx("button",{className:"history-more",title:"更多",onClick:()=>b(M=>M===S.id?null:S.id),children:l.jsx(i7,{className:"icon"})}),E===S.id&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>b(null)}),l.jsx("div",{className:"history-menu",children:l.jsxs("button",{className:"menu-item menu-item--danger",onClick:()=>{b(null),p(S.id)},children:[l.jsx(mc,{className:"icon"})," 删除"]})})]})]},S.id)})]})]}),l.jsx(kee,{access:s,userInfo:m,version:g,onLogout:x})]})}const c3="veadk_agentkit_connections";function Ti(){try{const e=localStorage.getItem(c3);return e?JSON.parse(e):[]}catch{return[]}}function Jm(e){try{localStorage.setItem(c3,JSON.stringify(e))}catch{}}function mo(e,t){return`agentkit:${e}:${t}`}function u3(e){try{return new URL(e).host}catch{return e}}function vc(e){ZR();for(const t of e)for(const n of t.apps)QR(mo(t.id,n),t.runtimeId?{app:n,runtimeId:t.runtimeId,region:t.region}:{app:n,base:t.base,apiKey:t.apiKey})}function d3(e,t,n,r,s){const i={id:`rt_${e}`,name:t||e,runtimeId:e,region:n,apps:r,appLabels:s},a=[...Ti().filter(o=>o.runtimeId!==e),i];return Jm(a),vc(a),i}async function lw(e,t,n){let r;try{r=await wL(e,n)}catch(a){throw a instanceof Fd&&g1(e),a}if(!r||r.length===0)throw g1(e),new Error("该 Runtime 暂不支持连接,请确认服务已正常运行。");const s=Object.fromEntries(r.map(a=>[a,t])),i=d3(e,t,n,r,s);return mo(i.id,r[0])}async function f3(e,t,n,r){const s=t.trim().replace(/\/+$/,""),i=await Fm(s,n.trim()),a={id:Date.now().toString(36),name:e.trim()||u3(s),base:s,apiKey:n.trim(),apps:i,appLabels:r&&i.length>0?{[i[0]]:r}:void 0},o=[...Ti().filter(c=>c.base!==s),a];return Jm(o),vc(o),a}function See(e){const t=Ti().filter(n=>n.id!==e);return Jm(t),vc(t),t}function g1(e){const t=Ti().filter(n=>n.runtimeId!==e);return Jm(t),vc(t),t}function h3(e,t){const n=e.map(s=>({id:s,label:s,app:s,remote:!1})),r=t.flatMap(s=>s.apps.map(i=>{var o;const a=((o=s.appLabels)==null?void 0:o[i])??i;return{id:mo(s.id,i),label:a,app:i,remote:!0,host:s.runtimeId?s.name:u3(s.base??"")}}));return[...n,...r]}const $S=Object.freeze(Object.defineProperty({__proto__:null,addConnection:f3,addRuntimeConnection:d3,buildAgentEntries:h3,connectRuntime:lw,loadConnections:Ti,registerConnections:vc,remoteAppId:mo,removeConnection:See,removeRuntimeConnection:g1},Symbol.toStringTag,{value:"Module"}));function ql({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"m10.05 3.7 1.95-1.12 1.95 1.12"}),l.jsx("path",{d:"m16.25 5.03 3.9 2.25v4.5"}),l.jsx("path",{d:"M20.15 15.08v1.64l-3.9 2.25"}),l.jsx("path",{d:"m13.95 20.3-1.95 1.12-1.95-1.12"}),l.jsx("path",{d:"m7.75 18.97-3.9-2.25v-4.5"}),l.jsx("path",{d:"M3.85 8.92V7.28l3.9-2.25"}),l.jsx("path",{d:"m12 7.55 1.28 3.17L16.45 12l-3.17 1.28L12 16.45l-1.28-3.17L7.55 12l3.17-1.28L12 7.55Z",fill:"currentColor",stroke:"none"})]})}function y1({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M4.5 6.7h4.2M12.3 6.7h7.2"}),l.jsx("path",{d:"M4.5 12h8.2M16.3 12h3.2"}),l.jsx("path",{d:"M4.5 17.3h2.7M10.8 17.3h8.7"}),l.jsx("circle",{cx:"10.5",cy:"6.7",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"12",r:"1.8",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"9",cy:"17.3",r:"1.8",fill:"currentColor",stroke:"none"})]})}function Nee({className:e="icon"}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l.jsxs("g",{transform:"translate(0 2)",children:[l.jsx("path",{d:"M11.6 3.5c.45 3.75 2.75 6.05 6.5 6.5-3.75.45-6.05 2.75-6.5 6.5-.45-3.75-2.75-6.05-6.5-6.5 3.75-.45 6.05-2.75 6.5-6.5Z"}),l.jsx("path",{d:"M18.7 3.8v3.4M20.4 5.5H17"})]})})}function p3({className:e="icon"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M18.7 8.15A7.55 7.55 0 0 0 5.35 7.1"}),l.jsx("path",{d:"m18.7 8.15-.2-3.05-3.02.3"}),l.jsx("path",{d:"M5.3 15.85A7.55 7.55 0 0 0 18.65 16.9"}),l.jsx("path",{d:"m5.3 15.85.2 3.05 3.02-.3"}),l.jsx("path",{d:"M6.85 12h2.8l1.4-2.9 1.9 5.8 1.42-2.9h2.78"})]})}const HS=15,Aee=1e4,Cee=[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}];function Iee(e){return e==="cn-beijing"?"北京":e==="cn-shanghai"?"上海":e}function m3(e){const t=e.toLowerCase();return t.includes("invalidagentkitruntime.notfound")||t.includes("specified agentkitruntime does not exist")?"该 Runtime 已不存在或列表信息已过期,请刷新列表后重试。":t.includes("accessdenied")||t.includes("forbidden")||t.includes("permission")||t.includes("(401)")||t.includes("(403)")?"当前账号无权访问该 Runtime,请检查所属 Project 和访问权限。":t.includes("agent-info failed: 404")||t.includes("读取 agent 列表失败 (404)")?"该 Agent Server 版本暂不支持信息预览。":"该 Runtime 暂时无法访问,请确认其状态为“就绪”后重试。"}function Y0(e,t=Aee){return new Promise((n,r)=>{const s=setTimeout(()=>r(new Error("加载超时,请重试")),t);e.then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),r(i)})})}function Ree({open:e,onClose:t,variant:n="drawer",anchorTop:r=0,agentsSource:s,localApps:i,currentId:a,currentRuntime:o,runtimeScope:c,onSelect:u}){const[d,f]=v.useState([]),[h,p]=v.useState([""]),[m,g]=v.useState(0),[x,y]=v.useState(c==="mine"),[E,b]=v.useState(null),[_,k]=v.useState("cn-beijing"),[T,A]=v.useState(!1),[N,S]=v.useState(""),[C,M]=v.useState(""),[U,q]=v.useState(null),[P,D]=v.useState(new Set),[I,L]=v.useState(),[O,B]=v.useState("agent"),R=v.useRef(!1);function z(Z){L(de=>(de==null?void 0:de.runtimeId)===Z.runtimeId?void 0:{runtimeId:Z.runtimeId,name:Z.name,region:Z.region})}const Y=v.useCallback(async Z=>{if(d[Z]){g(Z);return}const de=h[Z];if(de!==void 0){A(!0),S("");try{const ye=await Y0(jh({nextToken:de,pageSize:HS,region:_,scope:"all"}));f(Q=>{const ge=[...Q];return ge[Z]=ye.runtimes,ge}),p(Q=>{const ge=[...Q];return ye.nextToken&&(ge[Z+1]=ye.nextToken),ge}),g(Z)}catch(ye){S(ye instanceof Error?ye.message:String(ye))}finally{A(!1)}}},[h,d,_]),j=v.useCallback(async()=>{A(!0),S("");try{const Z=[];let de="";do{const ye=await Y0(jh({scope:"mine",nextToken:de,pageSize:100,region:_}));Z.push(...ye.runtimes),de=ye.nextToken}while(de&&Z.length<2e3);b(Z)}catch(Z){S(Z instanceof Error?Z.message:String(Z))}finally{A(!1)}},[_]);v.useEffect(()=>{y(c==="mine"),f([]),p([""]),g(0),b(null),R.current=!1},[c]),v.useEffect(()=>{e&&s==="cloud"&&!x&&!R.current&&(R.current=!0,Y(0))},[e,s,x,Y]),v.useEffect(()=>{x&&E===null&&s==="cloud"&&j()},[x,E,s,j]),v.useEffect(()=>{e&&(L(void 0),B("agent"))},[e]);function re(){D(new Set),x?(b(null),j()):(f([]),p([""]),g(0),R.current=!0,A(!0),S(""),Y0(jh({nextToken:"",pageSize:HS,region:_,scope:"all"})).then(Z=>{f([Z.runtimes]),p(Z.nextToken?["",Z.nextToken]:[""])}).catch(Z=>S(Z instanceof Error?Z.message:String(Z))).finally(()=>A(!1)))}function V(Z){Z!==_&&(k(Z),f([]),p([""]),g(0),b(null),D(new Set),R.current=!1)}const ee=!x&&(d[m+1]!==void 0||h[m+1]!==void 0);function oe(Z){q(Z.runtimeId),lw(Z.runtimeId,Z.name,Z.region).then(de=>{u(de),t()}).catch(de=>{if(de instanceof Fd){S(de.message);return}if(de instanceof ld){de.unsupported&&D(ye=>new Set(ye).add(Z.runtimeId)),S(de.message);return}D(ye=>new Set(ye).add(Z.runtimeId))}).finally(()=>q(null))}if(!e)return null;const ae=(x?E??[]:d[m]??[]).filter(Z=>C?Z.name.toLowerCase().includes(C.toLowerCase()):!0);return l.jsxs(l.Fragment,{children:[n==="drawer"?l.jsx("div",{className:"menu-scrim",onClick:t}):null,l.jsxs("div",{className:`agentsel agentsel--${n}${I&&n==="drawer"?" has-detail":""}`,role:"dialog","aria-label":"选择 Agent",style:n==="drawer"?{top:r,height:`min(640px, calc(100dvh - ${r}px - 10px))`}:void 0,children:[l.jsxs("div",{className:"agentsel-main",children:[l.jsxs("div",{className:"agentsel-head",children:[l.jsxs("span",{className:"agentsel-title",children:[l.jsx(ql,{})," 选择 Agent"]}),l.jsxs("div",{className:"agentsel-head-actions",children:[s==="cloud"&&l.jsx("button",{className:"agentsel-refresh",onClick:re,title:"刷新",disabled:T,children:l.jsx(kx,{className:`icon ${T?"spin":""}`})}),l.jsx("button",{className:"agentsel-refresh",onClick:t,title:"关闭",children:l.jsx(Wr,{className:"icon"})})]})]}),s==="local"?l.jsx("div",{className:"agentsel-body",children:i.length===0?l.jsx("div",{className:"agentsel-empty",children:"暂无本地 Agent。"}):l.jsx("ul",{className:"agentsel-list",children:i.map(Z=>l.jsx("li",{children:l.jsxs("button",{className:`agentsel-item ${Z===a?"active":""}`,onClick:()=>{u(Z),t()},children:[l.jsx(ql,{}),l.jsx("span",{className:"agentsel-item-name",children:Z})]})},Z))})}):l.jsxs("div",{className:"agentsel-body agentsel-body--cloud",children:[l.jsxs("div",{className:"agentsel-tools",children:[l.jsxs("div",{className:"agentsel-search",children:[l.jsx(Hb,{className:"icon"}),l.jsx("input",{value:C,onChange:Z=>M(Z.target.value),placeholder:"搜索 Runtime 名称"})]}),l.jsx("div",{className:"agentsel-regions","aria-label":"按部署地域筛选",children:Cee.map(Z=>l.jsx("button",{type:"button",className:_===Z.value?"active":"","aria-pressed":_===Z.value,onClick:()=>V(Z.value),children:Z.label},Z.value))}),c==="all"&&l.jsxs("label",{className:"agentsel-mine",children:[l.jsx("input",{type:"checkbox",checked:x,onChange:Z=>y(Z.target.checked)}),"只看我创建的"]})]}),N&&l.jsx("div",{className:"agentsel-error",children:N}),l.jsxs("div",{className:"agentsel-listwrap",children:[ae.length===0&&!T?l.jsx("div",{className:"agentsel-empty",children:"暂无 Runtime。"}):l.jsx("ul",{className:"agentsel-list",children:ae.map(Z=>{const de=P.has(Z.runtimeId),ye=U===Z.runtimeId,Q=(o==null?void 0:o.runtimeId)===Z.runtimeId,ge=(I==null?void 0:I.runtimeId)===Z.runtimeId;return l.jsx("li",{children:l.jsxs("div",{className:`agentsel-item agentsel-runtime-item ${Q?"active":""} ${ge?"is-previewed":""}`,title:Z.runtimeId,children:[l.jsx(p3,{}),l.jsxs("div",{className:"agentsel-item-main",children:[l.jsx("span",{className:"agentsel-item-name",title:Z.name,children:Z.name}),l.jsxs("div",{className:"agentsel-item-meta",children:[l.jsx("span",{className:`agentsel-status is-${de?"bad":Bee(Z.status)}`,children:de?"不支持":g3(Z.status)}),Z.isMine&&l.jsx("span",{className:"agentsel-badge",children:"我创建的"})]})]}),l.jsxs("div",{className:"agentsel-item-actions",children:[l.jsx("button",{type:"button",className:"agentsel-connect",disabled:ye||Q,onClick:()=>oe(Z),children:ye?"连接中…":Q?"已连接":de?"重试":"连接"}),n==="drawer"?l.jsx("button",{type:"button",className:`agentsel-info ${ge?"active":""}`,"aria-label":`查看 ${Z.name} 信息`,"aria-pressed":ge,title:"查看信息",onClick:()=>z(Z),children:l.jsx(Aa,{className:"icon"})}):null]})]})},Z.runtimeId)})}),T&&l.jsxs("div",{className:"agentsel-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载中…"]})]}),l.jsxs("div",{className:"agentsel-pager",children:[l.jsx("button",{disabled:x||m===0||T,onClick:()=>void Y(m-1),"aria-label":"上一页",children:l.jsx(JU,{className:"icon"})}),l.jsx("span",{className:"agentsel-pager-label",children:x?1:m+1}),l.jsx("button",{disabled:x||!ee||T,onClick:()=>void Y(m+1),"aria-label":"下一页",children:l.jsx(Nr,{className:"icon"})})]})]})]}),n==="drawer"&&s==="cloud"&&I&&l.jsx(Dee,{runtime:I,tab:O,onTabChange:B})]})]})}const Lee={knowledgebase:"知识库",memory:"记忆",prompt_manager:"提示词管理",example_store:"样例库",run_processor:"运行处理器",tracer:"链路追踪",toolset:"工具集",plugin:"插件",other:"其他"};function Oee(e){return Lee[e.toLowerCase()]??e}function Mee(e){return{context_search:"Context Search",local:"本地",mem0:"Mem0",milvus:"Milvus",opensearch:"OpenSearch",openviking:"OpenViking",redis:"Redis",tos_vector:"TOS Vector",viking:"VikingDB"}[e.toLowerCase()]??e}function Dee({runtime:e,tab:t,onTabChange:n}){return l.jsxs("section",{className:"agentsel-detail agentsel-preview","aria-label":"Agent 与 Runtime 信息",children:[l.jsx("div",{className:"agentsel-head agentsel-preview-head",children:l.jsxs("div",{className:`agentsel-detail-tabs is-${t}`,role:"tablist","aria-label":"详情类型",children:[l.jsx("span",{className:"agentsel-detail-tabs-slider","aria-hidden":!0}),l.jsx("button",{id:"agentsel-agent-tab",type:"button",role:"tab","aria-selected":t==="agent","aria-controls":"agentsel-agent-panel",onClick:()=>n("agent"),children:"Agent 信息"}),l.jsx("button",{id:"agentsel-runtime-tab",type:"button",role:"tab","aria-selected":t==="runtime","aria-controls":"agentsel-runtime-panel",onClick:()=>n("runtime"),children:"Runtime 信息"})]})}),l.jsx("div",{id:"agentsel-agent-panel",className:"agentsel-tab-panel",role:"tabpanel","aria-labelledby":"agentsel-agent-tab",hidden:t!=="agent",children:l.jsx(Pee,{runtime:e})}),l.jsx("div",{id:"agentsel-runtime-panel",className:"agentsel-tab-panel",role:"tabpanel","aria-labelledby":"agentsel-runtime-tab",hidden:t!=="runtime",children:l.jsx(jee,{runtime:e})})]})}function Pee({runtime:e}){const[t,n]=v.useState(null),[r,s]=v.useState(!0),[i,a]=v.useState(""),o=e.runtimeId,c=e.region;v.useEffect(()=>{let d=!0;return n(null),s(!0),a(""),dL(o,c).then(f=>d&&n(f)).catch(f=>{if(!d)return;const h=f instanceof Error?f.message:String(f);a(m3(h))}).finally(()=>d&&s(!1)),()=>{d=!1}},[o,c]);const u=(t==null?void 0:t.components)??[];return l.jsx("div",{className:"agentsel-detail-body",children:r?l.jsxs("div",{className:"agentsel-panel-state",children:[l.jsx(bt,{className:"icon spin"})," 读取 Agent 信息…"]}):i?l.jsxs("div",{className:"agentsel-panel-empty",children:[l.jsx("span",{children:"暂时无法读取 Agent 信息"}),l.jsx("small",{title:i,children:i})]}):t?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"agentsel-identity",children:[l.jsx(ql,{className:"agentsel-identity-icon"}),l.jsxs("div",{className:"agentsel-identity-copy",children:[l.jsx("strong",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]})]}),t.description&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsx("h3",{children:"描述"}),l.jsx("p",{className:"agentsel-description",title:t.description,children:t.description})]}),t.subAgents.length>0&&l.jsx(zS,{icon:l.jsx($R,{className:"icon"}),title:"子 Agent",values:t.subAgents}),t.tools.length>0&&l.jsx(zS,{icon:l.jsx(y1,{}),title:"工具",values:t.tools}),t.skills.length>0&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[l.jsx(Nee,{})," 技能"]}),l.jsx("div",{className:"agentsel-info-list",children:t.skills.map(d=>l.jsxs("div",{className:"agentsel-info-list-item",children:[l.jsx("strong",{title:d.name,children:d.name}),d.description&&l.jsx("span",{title:d.description,children:d.description})]},d.name))})]}),u.length>0&&l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[l.jsx(OR,{className:"icon"})," 挂载组件"]}),l.jsx("div",{className:"agentsel-info-list",children:u.map((d,f)=>l.jsxs("div",{className:"agentsel-info-list-item agentsel-component",children:[l.jsxs("div",{className:"agentsel-component-head",children:[l.jsx("strong",{title:d.name,children:d.name}),l.jsxs("span",{children:[Oee(d.kind),d.backend?` · ${Mee(d.backend)}`:""]})]}),d.description&&l.jsx("span",{title:d.description,children:d.description})]},`${d.kind}:${d.name}:${f}`))})]}),!t.description&&t.subAgents.length===0&&t.tools.length===0&&t.skills.length===0&&u.length===0&&l.jsx("div",{className:"agentsel-panel-empty",children:"暂无更多 Agent 配置信息。"})]}):null})}function zS({icon:e,title:t,values:n}){return l.jsxs("section",{className:"agentsel-info-section",children:[l.jsxs("h3",{children:[e,t]}),l.jsx("div",{className:"agentsel-chips",children:n.map((r,s)=>l.jsx("span",{className:"agentsel-chip",title:r,children:r},`${r}:${s}`))})]})}function jee({runtime:e}){const[t,n]=v.useState(null),[r,s]=v.useState(!0),[i,a]=v.useState(""),o=e.runtimeId,c=e.region;v.useEffect(()=>{let d=!0;return s(!0),a(""),n(null),Lx(o,c).then(f=>d&&n(f)).catch(f=>d&&a(m3(f instanceof Error?f.message:String(f)))).finally(()=>d&&s(!1)),()=>{d=!1}},[o,c]);const u=[];if(t){t.model&&u.push(["模型",t.model]),t.description&&u.push(["描述",t.description]),t.status&&u.push(["状态",g3(t.status)]),t.region&&u.push(["区域",Iee(t.region)]);const d=t.resources,f=[d.cpuMilli!=null?`CPU ${d.cpuMilli}m`:"",d.memoryMb!=null?`内存 ${d.memoryMb}MB`:"",d.minInstance!=null||d.maxInstance!=null?`实例 ${d.minInstance??"?"}~${d.maxInstance??"?"}`:""].filter(Boolean).join(" · ");f&&u.push(["资源",f]),t.currentVersion!=null&&u.push(["版本",String(t.currentVersion)])}return l.jsxs("div",{className:"agentsel-detail-body",children:[l.jsxs("div",{className:"agentsel-runtime-identity",children:[l.jsx(p3,{}),l.jsxs("div",{children:[l.jsx("strong",{title:e.name,children:e.name}),l.jsx("span",{title:e.runtimeId,children:e.runtimeId})]})]}),r?l.jsxs("div",{className:"agentsel-apps-note",children:[l.jsx(bt,{className:"icon spin"})," 读取详情…"]}):i?l.jsx("div",{className:"agentsel-error",children:i}):t?l.jsxs(l.Fragment,{children:[l.jsx("dl",{className:"agentsel-kv",children:u.map(([d,f])=>l.jsxs("div",{className:"agentsel-kv-row",children:[l.jsx("dt",{children:d}),l.jsx("dd",{children:f})]},d))}),t.envs.length>0&&l.jsxs("div",{className:"agentsel-envs",children:[l.jsx("div",{className:"agentsel-envs-head",children:"环境变量"}),t.envs.map(d=>l.jsxs("div",{className:"agentsel-env",children:[l.jsx("span",{className:"agentsel-env-k",children:d.key}),l.jsx("span",{className:"agentsel-env-v",children:d.value})]},d.key))]})]}):null]})}function Bee(e){const t=(e||"").toLowerCase();return t.includes("run")||t.includes("ready")||t.includes("active")?"ok":t.includes("creat")||t.includes("pend")||t.includes("deploy")?"warn":t.includes("fail")||t.includes("error")||t.includes("delet")?"bad":"muted"}const Fee={ready:"就绪",unreleased:"未发布",running:"运行中",active:"运行中",creating:"创建中",pending:"等待中",deploying:"部署中",updating:"更新中",failed:"失败",error:"异常",stopping:"停止中",stopped:"已停止",deleting:"删除中",deleted:"已删除"};function g3(e){const t=e.toLowerCase().replace(/[\s_-]/g,"");return Fee[t]??(e||"-")}function Uee({appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a,title:o,titleLeading:c,crumbs:u,rightContent:d}){return l.jsxs("div",{className:"navbar",children:[l.jsxs("div",{className:"navbar-left",children:[l.jsx("div",{className:"navbar-default",children:u&&u.length>0?l.jsx("nav",{className:"navbar-crumbs","aria-label":"面包屑",children:u.map((f,h)=>l.jsxs(v.Fragment,{children:[h>0&&l.jsx(Nr,{className:"crumb-sep"}),f.onClick?l.jsx("button",{className:"crumb crumb-link",onClick:f.onClick,children:f.label}):l.jsx("span",{className:"crumb crumb-current",children:f.label})]},h))}):o?l.jsxs("div",{className:"navbar-title-group",children:[c,l.jsx("div",{className:"navbar-title",title:o,children:o})]}):l.jsxs("div",{className:"navbar-title-group",children:[c,l.jsx($ee,{appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a})]})}),l.jsx("div",{id:"veadk-page-header-left",className:"navbar-portal-slot"})]}),l.jsxs("div",{className:"navbar-right",children:[l.jsx("div",{id:"veadk-page-header-actions",className:"navbar-portal-actions"}),d]})]})}function $ee({appName:e,onAppChange:t,agentLabel:n,agentsSource:r,localApps:s,currentRuntime:i,runtimeScope:a}){const[o,c]=v.useState(!1),u=f=>n?n(f):f;function d(){c(!1)}return l.jsxs("div",{className:"agent-dd",children:[l.jsxs("button",{className:"agent-dd-trigger",onClick:()=>c(f=>!f),children:[l.jsx("span",{className:"agent-dd-current",children:e?u(e):"选择 Agent"}),l.jsx(od,{className:`agent-dd-chev ${o?"open":""}`})]}),o&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:d}),l.jsx(Ree,{open:!0,variant:"navbar",agentsSource:r,localApps:s,currentId:e,currentRuntime:i,runtimeScope:a,onSelect:f=>{t(f),d()},onClose:d})]})]})}const Hee="https://ark.cn-beijing.volces.com/api/v3/",zh=[{key:"MODEL_EMBEDDING_NAME",required:!1,placeholder:"doubao-embedding-vision-250615",comment:"向量化模型(记忆/知识库需要)"},{key:"MODEL_EMBEDDING_DIM",required:!1,placeholder:"2048"},{key:"MODEL_EMBEDDING_API_BASE",required:!1,placeholder:Hee}],Gl=[],Yc=[{key:"FEISHU_APP_ID",required:!0,placeholder:"cli_xxx",comment:"飞书应用 App ID"},{key:"FEISHU_APP_SECRET",required:!0,placeholder:"输入 App Secret",comment:"飞书应用 App Secret"}],Ms={topK:"3",region:"cn-beijing",endpoint:"https://open.volcengineapi.com/"},y3=[{key:"REGISTRY_SPACE_ID",required:!0,placeholder:"请选择智能体中心",comment:"AgentKit 智能体中心"},{key:"REGISTRY_TOP_K",required:!1,placeholder:Ms.topK,comment:"召回 Agent 数量"},{key:"REGISTRY_REGION",required:!1,placeholder:Ms.region,comment:"AgentKit 智能体中心地域"},{key:"REGISTRY_ENDPOINT",required:!1,placeholder:Ms.endpoint,comment:"AgentKit 智能体中心 OpenAPI 地址"}],Xl=[{id:"web_search",label:"联网搜索",desc:"火山引擎 Web Search,获取实时信息。",importLine:"from veadk.tools.builtin_tools.web_search import web_search",toolNames:["web_search"],env:Gl},{id:"parallel_web_search",label:"并行联网搜索",desc:"并行发起多条搜索查询,更快汇总。",importLine:"from veadk.tools.builtin_tools.parallel_web_search import parallel_web_search",toolNames:["parallel_web_search"],env:Gl},{id:"link_reader",label:"网页读取",desc:"抓取并阅读给定链接的正文内容。",importLine:"from veadk.tools.builtin_tools.link_reader import link_reader",toolNames:["link_reader"],env:[]},{id:"web_scraper",label:"网页爬取",desc:"结构化爬取网页(需要 Scraper 服务)。",importLine:"from veadk.tools.builtin_tools.web_scraper import web_scraper",toolNames:["web_scraper"],env:[{key:"TOOL_WEB_SCRAPER_ENDPOINT",required:!0},{key:"TOOL_WEB_SCRAPER_API_KEY",required:!0}]},{id:"image_generate",label:"图像生成",desc:"文生图(Doubao Seedream)。",importLine:"from veadk.tools.builtin_tools.image_generate import image_generate",toolNames:["image_generate"],env:[{key:"MODEL_IMAGE_NAME",required:!1,placeholder:"doubao-seedream-5-0-260128"}]},{id:"image_edit",label:"图像编辑",desc:"图生图 / 编辑(Doubao SeedEdit)。",importLine:"from veadk.tools.builtin_tools.image_edit import image_edit",toolNames:["image_edit"],env:[{key:"MODEL_EDIT_NAME",required:!1,placeholder:"doubao-seededit-3-0-i2i-250628"}]},{id:"video_generate",label:"视频生成",desc:"文/图生视频(Doubao Seedance),含任务查询。",importLine:"from veadk.tools.builtin_tools.video_generate import video_generate, video_task_query",toolNames:["video_generate","video_task_query"],env:[{key:"MODEL_VIDEO_NAME",required:!1,placeholder:"doubao-seedance-2-0-260128"}]},{id:"text_to_speech",label:"语音合成 (TTS)",desc:"把文本转成语音(火山语音)。",importLine:"from veadk.tools.builtin_tools.tts import text_to_speech",toolNames:["text_to_speech"],env:[{key:"TOOL_VESPEECH_APP_ID",required:!0},{key:"TOOL_VESPEECH_SPEAKER",required:!1,placeholder:"zh_female_vv_uranus_bigtts"}]},{id:"run_code",label:"代码执行",desc:"在沙箱中执行代码",importLine:"from veadk.tools.builtin_tools.run_code import run_code",toolNames:["run_code"],env:[{key:"AGENTKIT_TOOL_ID",required:!0,placeholder:"t-xxxx",comment:"代码执行沙箱 ID"},{key:"AGENTKIT_TOOL_REGION",required:!1,placeholder:"cn-beijing",comment:"AgentKit Tools 地域"}]},{id:"vesearch",label:"VeSearch 智能搜索",desc:"火山 VeSearch(需要 bot 端点)。",importLine:"from veadk.tools.builtin_tools.vesearch import vesearch",toolNames:["vesearch"],env:[{key:"TOOL_VESEARCH_ENDPOINT",required:!0,comment:"VeSearch bot_id"}]}],Gp=[{id:"local",label:"本地内存",desc:"进程内,不持久化。适合开发调试。",env:[]},{id:"sqlite",label:"SQLite 文件",desc:"持久化到本地 .db 文件。",extraArgs:'local_database_path="./short_term_memory.db"',env:[]},{id:"mysql",label:"MySQL",desc:"持久化到 MySQL。",env:[{key:"DATABASE_MYSQL_HOST",required:!0},{key:"DATABASE_MYSQL_USER",required:!0},{key:"DATABASE_MYSQL_PASSWORD",required:!0},{key:"DATABASE_MYSQL_DATABASE",required:!0}]},{id:"postgresql",label:"PostgreSQL",desc:"持久化到 PostgreSQL。",env:[{key:"DATABASE_POSTGRESQL_HOST",required:!0},{key:"DATABASE_POSTGRESQL_PORT",required:!1,placeholder:"5432"},{key:"DATABASE_POSTGRESQL_USER",required:!0},{key:"DATABASE_POSTGRESQL_PASSWORD",required:!0},{key:"DATABASE_POSTGRESQL_DATABASE",required:!0}]}],Xp=[{id:"local",label:"本地向量库",desc:"进程内 llama-index 向量库。",env:zh,pipExtra:"extensions",needsEmbedding:!0},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"redis",label:"Redis",desc:"Redis 向量检索。",env:[{key:"DATABASE_REDIS_HOST",required:!0},{key:"DATABASE_REDIS_PORT",required:!1,placeholder:"6379"},{key:"DATABASE_REDIS_PASSWORD",required:!1},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"viking",label:"VikingDB Memory",desc:"火山 VikingDB 记忆库(支持用户画像)。",env:Gl},{id:"mem0",label:"Mem0",desc:"Mem0 托管记忆服务。",env:[{key:"DATABASE_MEM0_API_KEY",required:!0},{key:"DATABASE_MEM0_BASE_URL",required:!1}]}],Ql="viking",Qp=[{id:"viking",label:"VikingDB Knowledge",desc:"火山 VikingDB 知识库。",env:Gl},{id:"opensearch",label:"OpenSearch",desc:"OpenSearch 向量检索。",env:[{key:"DATABASE_OPENSEARCH_HOST",required:!0},{key:"DATABASE_OPENSEARCH_PORT",required:!1,placeholder:"9200"},{key:"DATABASE_OPENSEARCH_USERNAME",required:!0},{key:"DATABASE_OPENSEARCH_PASSWORD",required:!0},...zh],pipExtra:"extensions",needsEmbedding:!0},{id:"context_search",label:"Context Search",desc:"火山 Context Search 引擎(无需向量化)。",env:[...Gl,{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ID",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_ENDPOINT",required:!0},{key:"DATABASE_CONTEXT_SEARCH_ENGINE_APIKEY",required:!0}]}],Zp=[{id:"apmplus",label:"APMPlus",desc:"火山 APMPlus 应用性能监控。",enableFlag:"ENABLE_APMPLUS",env:[{key:"OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME",required:!1}]},{id:"cozeloop",label:"CozeLoop",desc:"扣子 CozeLoop 链路观测。",enableFlag:"ENABLE_COZELOOP",env:[{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY",required:!0},{key:"OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME",required:!1,comment:"CozeLoop space_id"}]},{id:"tls",label:"TLS (日志服务)",desc:"火山 TLS 日志服务导出。",enableFlag:"ENABLE_TLS",env:[...Gl,{key:"OBSERVABILITY_OPENTELEMETRY_TLS_SERVICE_NAME",required:!1,comment:"TLS topic_id,留空自动创建"}]}],zee=e=>Xl.find(t=>t.id===e),Vee=e=>Gp.find(t=>t.id===e),Kee=e=>Xp.find(t=>t.id===e),Yee=e=>Qp.find(t=>t.id===e),Wee=e=>Zp.find(t=>t.id===e),qee={coding:"智能编程",get_city_weather:"城市天气查询",get_location_weather:"位置天气查询",web_fetch:"网页内容获取"};function b1(e){const t=Xl.find(n=>n.id===e||n.toolNames.includes(e));return qee[e]??(t==null?void 0:t.label)??e}function VS(e){const t=Xl.find(r=>r.id===e||r.toolNames.includes(e));return((t==null?void 0:t.desc)??"由 VeADK 提供的内置工具").replace(/[。.]+$/,"")}function Gee(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"m7 7 10 10M17 7 7 17",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Xee(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"5.8",stroke:"currentColor",strokeWidth:"1.7"}),l.jsx("path",{d:"m15.2 15.2 4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function KS(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:l.jsx("path",{d:"M12 5.5v13M5.5 12h13",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function b3({title:e,description:t,icon:n,wide:r=!1,onClose:s,children:i}){const a=v.useRef(`session-capability-${Math.random().toString(36).slice(2)}`);return v.useEffect(()=>{const o=document.body.style.overflow;document.body.style.overflow="hidden";const c=u=>{u.key==="Escape"&&s()};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=o}},[s]),ai.createPortal(l.jsxs("div",{className:"session-capability-dialog-layer",children:[l.jsx("button",{type:"button",className:"session-capability-dialog-scrim","aria-label":"关闭弹窗",onClick:s}),l.jsxs("section",{className:`session-capability-dialog${r?" is-wide":""}`,role:"dialog","aria-modal":"true","aria-labelledby":a.current,children:[l.jsxs("header",{className:`session-capability-dialog-head${n?"":" is-iconless"}`,children:[n&&l.jsx("span",{className:"session-capability-dialog-mark",children:n}),l.jsxs("div",{children:[l.jsx("h2",{id:a.current,children:e}),l.jsx("p",{children:t})]}),l.jsx("button",{type:"button",className:"session-capability-dialog-close","aria-label":`关闭${e}`,onClick:s,children:l.jsx(Gee,{})})]}),i]})]}),document.body)}function Vh({value:e,placeholder:t,label:n,onChange:r,autoFocus:s=!1}){return l.jsxs("label",{className:"session-capability-search",children:[l.jsx(Xee,{}),l.jsx("input",{value:e,"aria-label":n,placeholder:t,autoFocus:s,onChange:i=>r(i.target.value)})]})}function Qee({agentName:e,tools:t,selectedNames:n,mutating:r,onAdd:s,onClose:i}){const[a,o]=v.useState(""),[c,u]=v.useState(""),d=v.useMemo(()=>new Set(n),[n]),f=v.useMemo(()=>{const p=a.trim().toLowerCase();return t.filter(m=>p?`${b1(m)} ${m} ${VS(m)}`.toLowerCase().includes(p):!0)},[a,t]),h=async p=>{u(p);const m=await s({kind:"tool",name:p});u(""),m&&i()};return l.jsx(b3,{title:"添加内置工具",description:`添加后仅对 ${e} 的当前会话生效`,icon:l.jsx(y1,{}),onClose:i,children:l.jsxs("div",{className:"session-tool-dialog-body",children:[l.jsx(Vh,{value:a,label:"搜索内置工具",placeholder:"搜索中文名称或工具标识",onChange:o,autoFocus:!0}),l.jsx("div",{className:"session-tool-picker",role:"list","aria-label":"可用内置工具",children:f.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的内置工具"}):f.map(p=>{const m=d.has(p),g=c===p;return l.jsxs("article",{className:"session-tool-option",role:"listitem",children:[l.jsx("span",{className:"session-tool-option-icon",children:l.jsx(y1,{})}),l.jsxs("span",{className:"session-tool-option-copy",children:[l.jsx("strong",{children:b1(p)}),l.jsx("code",{children:p}),l.jsx("span",{children:VS(p)})]}),l.jsx("button",{type:"button",disabled:m||r||!!c,onClick:()=>void h(p),children:m?"已添加":g?"添加中…":"添加"})]},p)})})]})})}function Zee({appName:e,agentName:t,selectedNames:n,mutating:r,onAdd:s,onClose:i}){const[a,o]=v.useState("public"),[c,u]=v.useState(""),[d,f]=v.useState([]),[h,p]=v.useState(0),[m,g]=v.useState(!0),[x,y]=v.useState(""),[E,b]=v.useState([]),[_,k]=v.useState(null),[T,A]=v.useState([]),[N,S]=v.useState(""),[C,M]=v.useState(""),[U,q]=v.useState(!0),[P,D]=v.useState(!1),[I,L]=v.useState(""),[O,B]=v.useState(""),R=v.useMemo(()=>new Set(n),[n]);v.useEffect(()=>{if(a!=="public")return;let V=!0;const ee=window.setTimeout(()=>{g(!0),y(""),oL(e,c.trim()).then(oe=>{V&&(f(oe.items),p(oe.totalCount))}).catch(oe=>{V&&(f([]),p(0),y(oe instanceof Error?oe.message:"搜索 Skill Hub 失败"))}).finally(()=>{V&&g(!1)})},250);return()=>{V=!1,window.clearTimeout(ee)}},[e,c,a]),v.useEffect(()=>{if(a!=="agentkit")return;let V=!0;return q(!0),L(""),NL().then(ee=>{V&&(b(ee),k(ee[0]??null))}).catch(ee=>{V&&L(ee instanceof Error?ee.message:"读取 Skill Space 失败")}).finally(()=>{V&&q(!1)}),()=>{V=!1}},[a]),v.useEffect(()=>{if(a!=="agentkit")return;if(!_){A([]);return}let V=!0;return D(!0),L(""),AL(_.id,_.region).then(ee=>{V&&A(ee)}).catch(ee=>{V&&L(ee instanceof Error?ee.message:"读取技能失败")}).finally(()=>{V&&D(!1)}),()=>{V=!1}},[_,a]);const z=v.useMemo(()=>{const V=N.trim().toLowerCase();return V?E.filter(ee=>`${ee.name} ${ee.id} ${ee.description}`.toLowerCase().includes(V)):E},[N,E]),Y=v.useMemo(()=>{const V=C.trim().toLowerCase();return V?T.filter(ee=>`${ee.skillName} ${ee.skillDescription}`.toLowerCase().includes(V)):T},[C,T]),j=async V=>{if(!_)return;B(V.skillId);const ee=await s({kind:"skill",name:V.skillName,skillSourceId:_.id,description:V.skillDescription,version:V.version});B(""),ee&&i()},re=async V=>{B(V.slug);const ee=await s({kind:"skill",name:V.name,skillSourceId:`findskill:${V.slug}`,description:V.description,version:V.version||V.updatedAt});B(""),ee&&i()};return l.jsx(b3,{title:"添加技能",description:`从公域 Skill Hub 或 AgentKit Skill 中心添加到 ${t} 当前会话`,wide:!0,onClose:i,children:l.jsxs("div",{className:"session-skill-dialog-body",children:[l.jsxs("div",{className:"session-skill-source-tabs",role:"tablist","aria-label":"技能来源",children:[l.jsxs("button",{type:"button",role:"tab","aria-selected":a==="public",className:a==="public"?"is-active":"",onClick:()=>o("public"),children:["Skill Hub",l.jsx("span",{children:"公域"})]}),l.jsx("button",{type:"button",role:"tab","aria-selected":a==="agentkit",className:a==="agentkit"?"is-active":"",onClick:()=>o("agentkit"),children:"AgentKit Skill 中心"})]}),a==="public"?l.jsxs("section",{className:"session-public-skill-browser","aria-label":"Skill Hub 公域技能",children:[l.jsxs("div",{className:"session-public-skill-head",children:[l.jsx(Vh,{value:c,label:"搜索 Skill Hub",placeholder:"搜索技能名称、用途或关键词",onChange:u,autoFocus:!0}),l.jsxs("span",{children:[h.toLocaleString()," 个公域技能"]})]}),l.jsx("div",{className:"session-public-skill-list",children:x?l.jsx("div",{className:"session-capability-error",children:x}):m?l.jsx("div",{className:"session-capability-loading",children:"正在搜索 Skill Hub…"}):d.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的公域技能"}):d.map(V=>{const ee=R.has(V.name),oe=O===V.slug;return l.jsxs("article",{className:"session-skill-option session-public-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:V.name}),l.jsx("span",{children:V.description||"暂无描述"}),l.jsxs("small",{children:[V.sourceRepo||V.sourceType||"FindSkill",l.jsx("span",{"aria-hidden":"true",children:" · "}),V.downloadCount.toLocaleString()," 次下载",V.evaluationScore>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",children:" · "}),V.evaluationScore.toFixed(1)," 分"]})]})]}),l.jsx("button",{type:"button",disabled:ee||r||!!O,onClick:()=>void re(V),children:ee?"已添加":oe?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(KS,{}),"添加"]})})]},V.slug)})})]}):l.jsxs("div",{className:"session-skill-browser",children:[l.jsxs("section",{className:"session-skill-spaces","aria-label":"Skill Space 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"Skill Space"}),l.jsx("span",{children:E.length})]}),l.jsx(Vh,{value:N,label:"搜索 Skill Space",placeholder:"搜索空间",onChange:S,autoFocus:!0})]}),l.jsx("div",{className:"session-skill-pane-list",children:U?l.jsx("div",{className:"session-capability-loading",children:"正在读取 Skill Space…"}):z.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的 Skill Space"}):z.map(V=>l.jsx("button",{type:"button",className:`session-skill-space${(_==null?void 0:_.id)===V.id?" is-active":""}`,onClick:()=>{k(V),M("")},children:l.jsxs("span",{children:[l.jsx("strong",{children:V.name||V.id}),l.jsx("small",{children:V.description||V.id}),l.jsxs("em",{children:[V.skillCount??0," 个技能"]})]})},`${V.projectName??"default"}:${V.id}`))})]}),l.jsxs("section",{className:"session-skill-results","aria-label":"AgentKit Skill 列表",children:[l.jsxs("div",{className:"session-skill-pane-head",children:[l.jsxs("div",{children:[l.jsx("strong",{title:_==null?void 0:_.name,children:(_==null?void 0:_.name)||"选择 Skill Space"}),l.jsx("span",{children:T.length})]}),l.jsx(Vh,{value:C,label:"搜索 AgentKit 技能",placeholder:"搜索技能名称或描述",onChange:M})]}),l.jsx("div",{className:"session-skill-pane-list",children:I?l.jsx("div",{className:"session-capability-error",children:I}):_?P?l.jsx("div",{className:"session-capability-loading",children:"正在读取技能…"}):Y.length===0?l.jsx("div",{className:"session-capability-empty",children:"没有匹配的技能"}):Y.map(V=>{const ee=R.has(V.skillName),oe=O===V.skillId;return l.jsxs("article",{className:"session-skill-option",children:[l.jsxs("span",{className:"session-skill-option-copy",children:[l.jsx("strong",{children:V.skillName}),l.jsx("span",{children:V.skillDescription||"暂无描述"}),l.jsxs("small",{children:["版本 ",V.version||"—"]})]}),l.jsx("button",{type:"button",disabled:ee||r||!!O,onClick:()=>void j(V),children:ee?"已添加":oe?"添加中…":l.jsxs(l.Fragment,{children:[l.jsx(KS,{}),"添加"]})})]},`${V.skillId}:${V.version}`)}):l.jsx("div",{className:"session-capability-empty",children:"选择一个 Skill Space 查看技能"})})]})]})]})})}function ji({as:e="span",className:t="",duration:n=4,spread:r=20,children:s,style:i,...a}){const o=Math.min(Math.max(r,5),45);return l.jsx(e,{className:`text-shimmer${t?` ${t}`:""}`,style:{...i,backgroundImage:`linear-gradient(to right, hsl(var(--muted-foreground)) ${50-o}%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground)) ${50+o}%)`,animationDuration:`${n}s`},...a,children:s})}const Jee={llm:"LLM",sequential:"顺序",parallel:"并行",loop:"循环",a2a:"A2A"};function E3(e){return 1+e.children.reduce((t,n)=>t+E3(n),0)}function Zl(e){return e.id||e.name}function ete(e,t){const n=Zl(e);if(e.id&&e.name&&e.name!==n)return e.name;if(t&&n==="agent")return"主 Agent";const r=/^agent_sub_(\d+)$/.exec(n);return r?`子 Agent ${r[1]}`:e.name||n}function x3(e,t=!0){return{...e,id:Zl(e),name:ete(e,t),children:e.children.map(n=>x3(n,!1))}}function w3(e,t){t.set(Zl(e),e.name||Zl(e)),e.children.forEach(n=>w3(n,t))}function tte(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function nte(e){return[...new Map(e.filter(t=>t.name.trim()).map(t=>[t.name.trim(),{...t,name:t.name.trim()}])).values()]}function v3({node:e,activeAgent:t,seen:n,path:r}){const s=Zl(e),i=!!s&&s===t,a=!!s&&!i&&r.has(s),o=!!s&&!i&&!a&&n.has(s);return l.jsxs("div",{className:"topo-branch",children:[l.jsxs("div",{className:`topo-node topo-type-${e.type} ${i?"is-active":""} ${a?"is-onpath":""} ${o?"is-done":""}`,title:e.description||e.name,children:[l.jsx(ql,{className:"topo-icon"}),l.jsx("span",{className:"topo-name",children:e.name||"未命名 Agent"}),l.jsx("span",{className:"topo-badge",children:Jee[e.type]??"Agent"})]}),i&&e.type==="a2a"&&l.jsx("div",{className:"topo-remote",children:"远程执行中…"}),e.children.length>0&&l.jsx("div",{className:"topo-children",children:e.children.map(c=>l.jsx(v3,{node:c,activeAgent:t,seen:n,path:r},Zl(c)))})]})}function W0({title:e,count:t}){return l.jsxs("div",{className:"topo-module-title",children:[l.jsx("span",{className:"topo-module-label",title:e,children:e}),l.jsx("span",{className:"topo-section-count","aria-label":`${t} 项`,children:t})]})}function _3({appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i=[],variant:a="rail",capabilities:o=null,capabilityLoading:c=!1,capabilityMutating:u=!1,builtinTools:d=[],onAddCapability:f,onRemoveCapability:h}){const[p,m]=v.useState(null);if(n&&!t)return l.jsx("aside",{className:`topo is-loading${a==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息","aria-live":"polite",children:l.jsx(ji,{as:"span",className:"topo-loading-label",duration:2.2,children:"正在读取 Agent 信息…"})});if(!t)return null;const g=x3(t.graph??{id:t.name,name:t.name,description:t.description,type:t.type??"llm",model:t.model,tools:t.tools,skills:t.skills,path:[t.name],mentionable:!1,children:[]}),x=(o==null?void 0:o.tools)??tte(t.tools).map(k=>({id:`base:tool:${k}`,kind:"tool",name:k,custom:!1})),y=(o==null?void 0:o.skills)??nte(t.skills).map(k=>({id:`base:skill:${k.name}`,kind:"skill",name:k.name,description:k.description,custom:!1})),E=!!(o&&f&&h),b=new Set(i),_=new Map;return w3(g,_),l.jsxs("aside",{className:`topo${a==="drawer"?" is-drawer":""}`,"aria-label":"Agent 信息与拓扑",children:[l.jsxs("section",{className:"topo-agent-card","aria-label":"Agent 信息",children:[l.jsxs("div",{className:"topo-agent-heading",children:[l.jsx("h2",{title:t.name,children:t.name||"未命名 Agent"}),t.model&&l.jsx("span",{title:t.model,children:t.model})]}),t.description&&l.jsx("p",{className:"topo-description",title:t.description,children:t.description})]}),l.jsxs("div",{className:"topo-module-stack",children:[l.jsxs("section",{className:"topo-module-card topo-tools-card","aria-label":"工具",children:[l.jsx(W0,{title:"工具",count:x.length}),l.jsx("div",{className:"topo-module-scroll topo-tools-scroll",role:"region","aria-label":"工具列表",tabIndex:0,children:x.length>0?l.jsx("div",{className:"topo-tool-list",children:x.map(k=>l.jsxs("div",{className:"topo-tool",title:k.name,children:[l.jsxs("span",{className:"topo-capability-title",children:[l.jsxs("span",{className:"topo-capability-copy",children:[l.jsx("span",{className:"topo-capability-name",children:b1(k.name)}),l.jsx("code",{children:k.name})]}),k.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"})]}),k.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除工具 ${k.name}`,title:"移除",disabled:u,onClick:()=>h==null?void 0:h(k.id),children:"×"})]},k.id))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),E&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加内置工具",disabled:c||u,onClick:()=>m("tool"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加工具"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-skills-card","aria-label":"技能",children:[l.jsx(W0,{title:"技能",count:y.length}),l.jsx("div",{className:"topo-module-scroll topo-skills-scroll",role:"region","aria-label":"技能列表",tabIndex:0,children:y.length>0?l.jsx("div",{className:"topo-skill-list",children:y.map(k=>l.jsxs("div",{className:"topo-skill",title:k.description||k.name,children:[l.jsxs("div",{className:"topo-skill-title",children:[l.jsx("span",{className:"topo-skill-name",children:k.name}),k.custom&&l.jsx("span",{className:"topo-custom-badge",children:"自定义"}),k.custom&&l.jsx("button",{type:"button",className:"topo-remove-capability","aria-label":`移除技能 ${k.name}`,title:"移除",disabled:u,onClick:()=>h==null?void 0:h(k.id),children:"×"})]}),k.description&&l.jsx("span",{className:"topo-skill-description",children:k.description})]},`${k.name}:${k.description}`))}):l.jsx("div",{className:"topo-empty",children:"未配置"})}),E&&l.jsx("div",{className:"topo-capability-add-dock",children:l.jsxs("button",{type:"button",className:"topo-capability-add-slot","aria-label":"添加技能",disabled:c||u,onClick:()=>m("skill"),children:[l.jsx("span",{"aria-hidden":"true",children:"+"}),l.jsx("span",{children:"在此对话中添加技能"})]})})]}),l.jsxs("section",{className:"topo-module-card topo-topology","aria-label":"Agent 拓扑",children:[l.jsx(W0,{title:"拓扑",count:E3(g)}),l.jsxs("div",{className:"topo-module-scroll topo-topology-scroll",role:"region","aria-label":"Agent 拓扑列表",tabIndex:0,children:[i.length>1&&l.jsx("div",{className:"topo-path","aria-label":"执行路径",children:i.map((k,T)=>l.jsx("span",{className:"topo-path-seg",children:l.jsx("span",{className:T===i.length-1?"topo-path-name is-current":"topo-path-name",children:_.get(k)??k})},`${k}-${T}`))}),l.jsx("div",{className:"topo-tree",children:l.jsx(v3,{node:g,activeAgent:r,seen:s,path:b})})]})]})]}),p==="tool"&&f&&l.jsx(Qee,{agentName:t.name,tools:d,selectedNames:x.map(k=>k.name),mutating:u,onAdd:f,onClose:()=>m(null)}),p==="skill"&&f&&l.jsx(Zee,{appName:e,agentName:t.name,selectedNames:y.map(k=>k.name),mutating:u,onAdd:f,onClose:()=>m(null)})]})}function rte(){return l.jsx("svg",{className:"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M6 6l12 12M18 6 6 18"})})}function ste({appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i,capabilities:a,capabilityLoading:o,capabilityMutating:c,builtinTools:u,onAddCapability:d,onRemoveCapability:f,onClose:h,returnFocusRef:p}){return v.useEffect(()=>{const m=document.body.style.overflow;document.body.style.overflow="hidden";const g=x=>{x.key==="Escape"&&h()};return document.addEventListener("keydown",g),()=>{var x;document.removeEventListener("keydown",g),document.body.style.overflow=m,(x=p.current)==null||x.focus()}},[h,p]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim agent-info-scrim",onClick:h}),l.jsxs("aside",{className:"drawer drawer--agent-info",role:"dialog","aria-modal":"true","aria-labelledby":"agent-info-drawer-title",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{id:"agent-info-drawer-title",className:"drawer-title",children:"Agent 信息"}),l.jsx("div",{className:"drawer-sub",children:"能力与协作拓扑"})]}),l.jsx("button",{type:"button",className:"drawer-close",onClick:h,"aria-label":"关闭 Agent 信息",autoFocus:!0,children:l.jsx(rte,{})})]}),l.jsx("div",{className:"agent-info-drawer-body",children:t||n?l.jsx(_3,{appName:e,info:t,loading:n,activeAgent:r,seenAgents:s,execPath:i,capabilities:a,capabilityLoading:o,capabilityMutating:c,builtinTools:u,onAddCapability:d,onRemoveCapability:f,variant:"drawer"}):l.jsx("div",{className:"drawer-empty",children:"暂时无法读取 Agent 信息。"})})]})]})}function ite({onAdded:e,onCancel:t}){const[n,r]=v.useState(""),[s,i]=v.useState(""),[a,o]=v.useState(""),[c,u]=v.useState(!1),[d,f]=v.useState(""),h=n.trim().length>0&&s.trim().length>0&&!c;async function p(){if(h){u(!0),f("");try{const m=await f3(a,n,s,a);if(m.apps.length===0){f("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。"),u(!1);return}e(mo(m.id,m.apps[0]))}catch(m){f(`连接失败:${String(m)}。请检查 URL、API Key,以及该网关是否允许跨域。`),u(!1)}}}return l.jsx("div",{className:"addagent",children:l.jsxs("div",{className:"addagent-card",children:[l.jsx("h2",{className:"addagent-title",children:"添加 AgentKit 智能体"}),l.jsx("p",{className:"addagent-sub",children:"填入 AgentKit 部署的访问地址与 API Key,将通过 ADK 协议连接,连接成功后其 Agent 会出现在左上角的下拉中。"}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"访问地址 URL"}),l.jsx("input",{className:"addagent-input",value:n,onChange:m=>r(m.target.value),placeholder:"https://xxxxx.apigateway-cn-beijing.volceapi.com",autoFocus:!0})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"API Key"}),l.jsx("input",{className:"addagent-input",type:"password",value:s,onChange:m=>i(m.target.value),placeholder:"以 Authorization: Bearer 方式连接"})]}),l.jsxs("label",{className:"addagent-field",children:[l.jsx("span",{className:"addagent-label",children:"显示名称(可选)"}),l.jsx("input",{className:"addagent-input",value:a,onChange:m=>o(m.target.value),placeholder:"默认取 URL 的主机名"})]}),d&&l.jsx("div",{className:"addagent-error",children:d}),l.jsxs("div",{className:"addagent-actions",children:[l.jsx("button",{className:"addagent-btn addagent-btn--ghost",onClick:t,disabled:c,children:"取消"}),l.jsxs("button",{className:"addagent-btn addagent-btn--primary",onClick:p,disabled:!h,children:[c?l.jsx(bt,{className:"icon spin"}):null,c?"连接中…":"连接并添加"]})]})]})})}function ate({currentRuntimeId:e,onConnect:t}){const[n,r]=v.useState([]),[s,i]=v.useState(!0),[a,o]=v.useState(""),[c,u]=v.useState(null),[d,f]=v.useState(null),[h,p]=v.useState(null),[m,g]=v.useState({}),[x,y]=v.useState("cn-beijing"),[E,b]=v.useState(!1),_=v.useCallback(async()=>{i(!0),o("");try{r(await mL(x))}catch(S){o(S instanceof Error?S.message:String(S))}finally{i(!1)}},[x]);v.useEffect(()=>{_()},[_]);async function k(S){g(M=>({...M,[S.runtimeId]:{loading:!0}}));const C={loading:!1};try{C.detail=await Lx(S.runtimeId,S.region)}catch(M){C.error=M instanceof Error?M.message:String(M)}C.detail&&(C.graphs=[{name:C.detail.name,description:C.detail.description,type:"llm",model:C.detail.model,tools:[],skills:[],path:[C.detail.name],mentionable:!1,children:[]}],C.graphNote="仅显示主 Agent(控制面信息)。"),g(M=>({...M,[S.runtimeId]:C}))}function T(S){const C=h===S.runtimeId;p(C?null:S.runtimeId),!C&&!m[S.runtimeId]&&k(S)}async function A(S){if(!c&&window.confirm(`确定删除 Agent "${S.name}"?该 Runtime 将被永久删除。`)){u(S.runtimeId),o("");try{await vL(S.runtimeId,S.region),r(C=>C.filter(M=>M.runtimeId!==S.runtimeId))}catch(C){o(C instanceof Error?C.message:String(C))}finally{u(null)}}}async function N(S){if(!(d||e===S.runtimeId)){f(S.runtimeId),o("");try{await t(S)}catch(C){o(C instanceof Error?C.message:String(C))}finally{f(null)}}}return l.jsxs("div",{className:"manage",children:[l.jsxs("div",{className:"manage-head",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"manage-title",children:"管理 Agent"}),l.jsx("p",{className:"manage-sub",children:"列出你有权管理的 AgentKit Runtime"})]}),l.jsxs("div",{className:"manage-head-actions",children:[l.jsxs("div",{className:"manage-region-picker",onKeyDown:S=>{S.key==="Escape"&&b(!1)},children:[l.jsxs("button",{type:"button",className:"manage-region",onClick:()=>b(S=>!S),title:"按区域筛选","aria-label":"区域筛选","aria-haspopup":"listbox","aria-expanded":E,children:[l.jsx("span",{children:x==="cn-beijing"?"北京":"上海"}),l.jsx(od,{className:`manage-region-chevron${E?" is-open":""}`})]}),E&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>b(!1)}),l.jsx("div",{className:"manage-region-menu",role:"listbox","aria-label":"区域",children:[{value:"cn-beijing",label:"北京"},{value:"cn-shanghai",label:"上海"}].map(S=>{const C=S.value===x;return l.jsxs("button",{type:"button",role:"option","aria-selected":C,className:`manage-region-option${C?" is-selected":""}`,onClick:()=>{y(S.value),b(!1)},children:[l.jsx("span",{children:S.label}),C&&l.jsx(Bs,{"aria-hidden":"true"})]},S.value)})})]})]}),l.jsxs("button",{type:"button",className:"manage-refresh",onClick:()=>void _(),disabled:s,title:"刷新",children:[l.jsx(kx,{className:`icon ${s?"spin":""}`}),"刷新"]})]})]}),a&&l.jsx("div",{className:"manage-error",children:a}),s?l.jsxs("div",{className:"manage-empty",children:[l.jsx(bt,{className:"icon spin"})," 加载中…"]}):n.length===0?l.jsx("div",{className:"manage-empty",children:"暂无你部署的 Agent。"}):l.jsx("ul",{className:"manage-list",children:n.map(S=>{const C=h===S.runtimeId,M=m[S.runtimeId];return l.jsxs("li",{className:"manage-item",children:[l.jsxs("div",{className:"manage-item-row",children:[l.jsxs("button",{type:"button",className:"manage-item-toggle",onClick:()=>T(S),"aria-expanded":C,children:[C?l.jsx(od,{className:"icon"}):l.jsx(Nr,{className:"icon"}),l.jsxs("span",{className:"manage-item-main",children:[l.jsx("span",{className:"manage-item-name",children:S.name}),l.jsx("span",{className:`manage-badge is-${dte(S.status)}`,children:S.status||"-"})]})]}),l.jsxs("div",{className:"manage-item-actions",children:[l.jsxs("button",{type:"button",className:"manage-connect",onClick:()=>void N(S),disabled:d!==null||e===S.runtimeId,children:[d===S.runtimeId?l.jsx(bt,{className:"icon spin"}):l.jsx(E7,{className:"icon"}),e===S.runtimeId?"已连接":"连接到此 Agent"]}),l.jsx("button",{type:"button",className:"manage-del",onClick:()=>void A(S),disabled:c===S.runtimeId,title:"删除该 Runtime",children:c===S.runtimeId?l.jsx(bt,{className:"icon spin"}):l.jsx(mc,{className:"icon"})})]})]}),l.jsxs("div",{className:"manage-item-meta",children:[l.jsx("span",{className:"manage-item-id",title:S.runtimeId,children:S.runtimeId}),l.jsx("span",{className:"manage-item-dot",children:"·"}),l.jsx("span",{children:S.region}),S.createdAt&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"manage-item-dot",children:"·"}),l.jsx("span",{children:T3(S.createdAt)})]})]}),C&&l.jsx("div",{className:"manage-detail",children:!M||M.loading?l.jsxs("div",{className:"manage-detail-loading",children:[l.jsx(bt,{className:"icon spin"})," 读取详情…"]}):l.jsxs(l.Fragment,{children:[M.error&&l.jsx("div",{className:"manage-error",children:M.error}),M.detail&&l.jsx(cte,{detail:M.detail}),l.jsx("div",{className:"manage-tree-head",children:"Agent 结构"}),M.graphs&&M.graphs.length>0?M.graphs.map((U,q)=>l.jsx(k3,{node:U},q)):l.jsx("div",{className:"manage-tree-note",children:M.graphNote})]})})]},S.runtimeId)})})]})}const ote=/KEY|SECRET|TOKEN|PASSWORD|CREDENTIAL/i;function lte({envKey:e,value:t}){const[n,r]=v.useState(!1);return!ote.test(e)||n?l.jsx("code",{className:"manage-env-v",children:t}):l.jsx("button",{type:"button",className:"manage-env-v manage-env-masked",title:"敏感值已隐藏,点击显示","aria-label":`显示 ${e} 的值`,onClick:()=>r(!0),children:"••••••••"})}function cte({detail:e}){const t=e.resources,n=[];e.model&&n.push(["模型",e.model]),e.description&&n.push(["描述",e.description]),e.statusMessage&&n.push(["状态信息",e.statusMessage]),e.project&&n.push(["Project",e.project]),e.currentVersion!=null&&n.push(["版本",String(e.currentVersion)]);const r=[t.cpuMilli!=null?`CPU ${t.cpuMilli}m`:"",t.memoryMb!=null?`内存 ${t.memoryMb}MB`:"",t.minInstance!=null||t.maxInstance!=null?`实例 ${t.minInstance??"?"}~${t.maxInstance??"?"}`:"",t.maxConcurrency!=null?`并发 ${t.maxConcurrency}`:""].filter(Boolean).join(" · ");return r&&n.push(["资源",r]),e.memoryId&&n.push(["Memory",e.memoryId]),e.toolId&&n.push(["Tool",e.toolId]),e.knowledgeId&&n.push(["Knowledge",e.knowledgeId]),e.mcpToolsetId&&n.push(["MCP Toolset",e.mcpToolsetId]),e.updatedAt&&n.push(["更新时间",T3(e.updatedAt)]),l.jsxs("div",{className:"manage-detail-card",children:[l.jsx("dl",{className:"manage-kv",children:n.map(([s,i])=>l.jsxs("div",{className:"manage-kv-row",children:[l.jsx("dt",{children:s}),l.jsx("dd",{children:i})]},s))}),e.envs.length>0&&l.jsxs("div",{className:"manage-envs",children:[l.jsx("div",{className:"manage-envs-head",children:"环境变量"}),e.envs.map(s=>l.jsxs("div",{className:"manage-env",children:[l.jsx("code",{className:"manage-env-k",children:s.key}),l.jsx(lte,{envKey:s.key,value:s.value})]},s.key))]})]})}const ute={llm:"LLM",sequential:"Sequential",parallel:"Parallel",loop:"Loop",a2a:"A2A"};function k3({node:e,depth:t=0}){return l.jsxs("div",{className:"manage-tree",style:{marginLeft:t?16:0},children:[l.jsxs("div",{className:"manage-tree-node",children:[l.jsx("span",{className:"manage-tree-name",children:e.name||"(未命名)"}),l.jsx("span",{className:"manage-tree-type",children:ute[e.type]||e.type}),e.model&&l.jsx("span",{className:"manage-tree-model",children:e.model})]}),e.tools.length>0&&l.jsx("div",{className:"manage-tree-tools",children:e.tools.map(n=>l.jsx("span",{className:"manage-tree-tool",children:n},n))}),e.children.map((n,r)=>l.jsx(k3,{node:n,depth:t+1},r))]})}function dte(e){const t=(e||"").toLowerCase();return t.includes("run")||t.includes("ready")||t.includes("active")?"ok":t.includes("creat")||t.includes("pend")||t.includes("deploy")?"warn":t.includes("fail")||t.includes("error")||t.includes("delet")?"bad":"muted"}function T3(e){const t=Number(e),n=Number.isFinite(t)&&String(t)===e?new Date(t*1e3):new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString()}const fte={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 hte(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const s of n){if(r==null||typeof r!="object")return;r=r[s]}return r}function pte(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function mte(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function cw(e,t){if(pte(e))return hte(t,e.path);if(mte(e)){const n=fte[e.call],r={};for(const[s,i]of Object.entries(e.args??{}))r[s]=cw(i,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function gte(e,t){const n=cw(e,t);return n==null?"":typeof n=="string"?n:String(n)}const S3=new Map;function Co(e,t){S3.set(e,t)}function yte(e){return S3.get(e)}function bte(e,t,n){const r=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let s=e;for(let i=0;icw(r,e.dataModel),resolveString:r=>gte(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const s=e.components[r];if(!s)return null;const i=yte(s.component)??Ete;return l.jsx(i,{node:s,ctx:n},r)}};return l.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function wte(e){const t=v.useRef(null),n=v.useRef(!0),r=28,s=v.useCallback(()=>{const i=t.current;i&&(n.current=i.scrollHeight-i.scrollTop-i.clientHeight{const i=t.current;i&&n.current&&(i.scrollTop=i.scrollHeight)},[e]),{ref:t,onScroll:s}}function uw({value:e,onRemoveSkill:t,onRemoveAgent:n}){return e.skills.length===0&&!e.targetAgent?null:l.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(r=>l.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:r.description,children:[l.jsx(ho,{"aria-hidden":!0}),l.jsxs("span",{children:["/",r.name]}),t?l.jsx("button",{type:"button",onClick:()=>t(r.name),"aria-label":`移除技能 ${r.name}`,children:l.jsx(Wr,{})}):null]},r.name)),e.targetAgent?l.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[l.jsx(LR,{"aria-hidden":!0}),l.jsx("span",{children:e.targetAgent.name}),n?l.jsx("button",{type:"button",onClick:n,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:l.jsx(Wr,{})}):null]}):null]})}function dw(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function A3(e){var n,r,s,i;const t=dw(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"?((i=(s=e.mimeType)==null?void 0:s.split("/")[1])==null?void 0:i.toUpperCase())??"IMAGE":"TXT"}function C3(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function I3(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?rL(t,e.uri):""}function vte({kind:e}){return e==="image"?l.jsx(BR,{}):e==="video"?l.jsx(PR,{}):e==="pdf"?l.jsx(u7,{}):l.jsx(DR,{})}function fw({appName:e,items:t,compact:n=!1,onRemove:r}){const[s,i]=v.useState(null);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const o=dw(a.mimeType),c=I3(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=l.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:()=>i(a),"aria-label":`预览 ${a.name??"附件"}`,children:[o==="image"&&c?l.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):o==="video"&&c?l.jsxs("div",{className:"media-card-video-container",children:[l.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),l.jsx("span",{className:"media-card-video-play",children:l.jsx(I7,{})})]}):l.jsx("span",{className:"media-card-icon",children:l.jsx(vte,{kind:o})}),l.jsxs("span",{className:"media-card-copy",children:[l.jsx("span",{className:"media-card-name",children:a.name??"附件"}),l.jsxs("span",{className:"media-card-meta",children:[l.jsx("span",{className:"media-card-type",children:A3(a)}),a.status==="uploading"?l.jsxs(l.Fragment,{children:[l.jsx(bt,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":C3(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?l.jsx(_u,{className:"media-card-open"}):null]});return l.jsxs(Rt.div,{className:`media-card media-card--${o}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[o==="image"&&!u?l.jsx(NR,{src:c,children:d}):d,r?l.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:l.jsx(Wr,{})}):null]},a.id)})}),l.jsx(Js,{children:s?l.jsx(_te,{appName:e,item:s,onClose:()=>i(null)}):null})]})}function _te({appName:e,item:t,onClose:n}){const r=v.useMemo(()=>I3(t,e),[e,t]),s=dw(t.mimeType),[i,a]=v.useState(""),[o,c]=v.useState(s==="text"||s==="markdown"),[u,d]=v.useState("");return v.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),v.useEffect(()=>{if(s!=="text"&&s!=="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()},[s,r]),l.jsx(Rt.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:l.jsxs(Rt.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:[l.jsxs("header",{className:"media-viewer-header",children:[l.jsxs("div",{children:[l.jsx("strong",{children:t.name??"附件"}),l.jsxs("span",{children:[A3(t),t.sizeBytes?` · ${C3(t.sizeBytes)}`:""]})]}),l.jsxs("nav",{children:[l.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:l.jsx(xx,{})}),l.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:l.jsx(Wr,{})})]})]}),l.jsxs("div",{className:`media-viewer-body media-viewer-body--${s}`,children:[s==="image"?l.jsx("img",{src:r,alt:t.name??"图片"}):null,s==="video"?l.jsx("div",{className:"media-viewer-video-wrapper",children:l.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,s==="pdf"?l.jsx("iframe",{src:r,title:t.name??"PDF"}):null,o?l.jsxs("div",{className:"media-viewer-loading",children:[l.jsx(bt,{})," 正在读取文档…"]}):null,!o&&u?l.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!o&&s==="markdown"?l.jsx("div",{className:"media-document",children:l.jsx(Gd,{text:i})}):null,!o&&s==="text"?l.jsx("pre",{className:"media-document media-document--plain",children:i}):null]})]})})}function kte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),l.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 Tte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),l.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),l.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),l.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 Ste(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("rect",{x:"3.25",y:"5.5",width:"16.25",height:"13",rx:"2.4"}),l.jsx("path",{d:"m10.2 9.2 4.4 2.8-4.4 2.8V9.2Z"}),l.jsx("path",{d:"m19.25 2.5.42 1.2 1.2.42-1.2.42-.42 1.2-.42-1.2-1.2-.42 1.2-.42.42-1.2Z",fill:"currentColor",stroke:"none"})]})}function Nte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.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"}),l.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"}),l.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function Ate(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),l.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),l.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),l.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Cte(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.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"}),l.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"}),l.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 Ite(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),l.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),l.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"}),l.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function R3(e){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:l.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Rte({definition:e,label:t,done:n,open:r,onToggle:s}){const i=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return l.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:s,"aria-expanded":r,children:[l.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:l.jsx(i,{})}),n?l.jsx("span",{className:"builtin-tool-label",children:a}):l.jsx(ji,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),l.jsx(R3,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}const Lte={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:kte},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Ite},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Tte},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:Ste},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Nte},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:Ate},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Cte}};function Ote(e){return Lte[e]}const L3="send_a2ui_json_to_client",Mte=28;function Dte(e,t,n){let r=t;for(let s=0;s65535?2:1}return r}function Pte(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function O3(e,t,n){const[r,s]=v.useState(()=>t?"":e),i=v.useRef(r),a=v.useRef(e),o=v.useRef(null),c=v.useRef(0),u=v.useRef(n);return a.current=e,u.current=n,v.useEffect(()=>{const d=i.current,f=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||f||!e.startsWith(d)){o.current!==null&&window.cancelAnimationFrame(o.current),o.current=null,d!==e&&(i.current=e,s(e));return}if(d===e||o.current!==null)return;const h=p=>{const m=a.current,g=i.current;if(!m.startsWith(g)){i.current=m,s(m),o.current=null;return}if(p-c.current{var d;(d=u.current)==null||d.call(u)},[r]),v.useEffect(()=>()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)},[]),r}function jte({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:l.jsx("path",{d:"M12 2.2l1.7 5.1a3 3 0 0 0 1.9 1.9L20.8 11l-5.1 1.7a3 3 0 0 0-1.9 1.9L12 19.8l-1.7-5.1a3 3 0 0 0-1.9-1.9L3.2 11l5.1-1.7a3 3 0 0 0 1.9-1.9L12 2.2z"})})}function Bte(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.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 Fte(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 M3({text:e,done:t,streaming:n=!1,onStreamFrame:r}){const[s,i]=v.useState(!t),a=v.useRef(!1);v.useEffect(()=>{a.current||i(!t)},[t]);const o=()=>{a.current=!0,i(h=>!h)},c=e.replace(/^\s+/,""),u=O3(c,!t||n,r),{ref:d,onScroll:f}=wte(u);return l.jsxs("div",{className:"block-thinking",children:[l.jsxs("button",{className:"think-head",onClick:o,type:"button",children:[l.jsx("span",{className:"think-icon","aria-hidden":"true",children:l.jsx(jte,{className:`spark ${t?"":"pulse"}`})}),t?l.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):l.jsx(ji,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),l.jsx(Nr,{className:`chev ${s?"open":""}`})]}),l.jsx("div",{className:`think-collapse ${s&&u?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsx("div",{className:"think-body scroll",ref:d,onScroll:f,children:u})})})]})}function D3(){return l.jsx(M3,{text:"",done:!1})}const Ute=v.memo(function({text:t,streaming:n,onStreamFrame:r}){const s=O3(t,n,r);return s?l.jsx("div",{className:"bubble",children:l.jsx(Gd,{text:s})}):null});function $te({name:e,args:t,response:n,done:r}){const[s,i]=v.useState(!1),a=e===L3?"渲染 UI":e,o=Ote(e),c=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),u=c&&c.length>2e3?c.slice(0,2e3)+` …(已截断)`:c;return l.jsxs(Rt.div,{className:`block-tool${o?" block-tool--builtin":""}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[o?l.jsx(Rte,{definition:o,label:Fte(e,t),done:r,open:s,onToggle:()=>i(d=>!d)}):l.jsxs("button",{className:"tool-head tool-head--generic",onClick:()=>i(d=>!d),type:"button","aria-expanded":s,children:[l.jsx("span",{className:"tool-icon tool-icon--generic","aria-hidden":"true",children:l.jsx(Bte,{})}),r?l.jsx("span",{className:"tool-name",children:a}):l.jsx(ji,{className:"tool-name",duration:2.2,spread:15,children:a}),l.jsx(R3,{className:`tool-chevron${s?" is-open":""}`})]}),l.jsx("div",{className:`think-collapse ${s?"open":""}`,children:l.jsx("div",{className:"think-collapse-inner",children:l.jsxs("div",{className:"tool-detail",children:[t!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"参数"}),l.jsx("pre",{className:"tool-args",children:JSON.stringify(t,null,2)})]}),u!=null&&l.jsxs("div",{className:"tool-section",children:[l.jsx("div",{className:"tool-section-label",children:"返回"}),l.jsx("pre",{className:"tool-args tool-result",children:u})]})]})})})]})}function Hte({block:e,onAuth:t}){const[n,r]=v.useState(e.done?"done":"idle"),[s,i]=v.useState(""),a=e.label||"MCP 工具集",o=(()=>{try{return e.authUri?new URL(e.authUri).host:""}catch{return""}})(),c=async()=>{if(t){i(""),r("authorizing");try{await t(e),r("done")}catch(d){i(d instanceof Error?d.message:String(d)),r("idle")}}};return e.done||n==="done"?l.jsxs(Rt.div,{className:"auth-card-collapsed",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:[l.jsx(Vk,{className:"auth-card-icon auth-card-icon--done"}),l.jsxs("span",{children:["已授权 · ",a]})]}):l.jsxs(Rt.div,{className:"auth-card",initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[l.jsxs("div",{className:"auth-card-head",children:[l.jsx(Vk,{className:"auth-card-icon"}),l.jsxs("span",{className:"auth-card-title",children:[a," 需要授权"]})]}),l.jsxs("p",{className:"auth-card-desc",children:["工具集 ",l.jsx("code",{className:"auth-card-code",children:a})," 使用 OAuth 保护, 需登录授权后方可调用。",o&&l.jsxs(l.Fragment,{children:[" ","将跳转至 ",l.jsx("code",{className:"auth-card-code",children:o})," 完成登录,"]}),"授权完成后对话自动继续。"]}),l.jsx("button",{className:"auth-card-btn",onClick:c,disabled:n==="authorizing"||!e.authUri,children:n==="authorizing"?l.jsxs(l.Fragment,{children:[l.jsx(bt,{className:"cw-i spin"})," 等待授权…"]}):l.jsx(l.Fragment,{children:"去授权"})}),!e.authUri&&l.jsx("div",{className:"auth-card-err",children:"未在事件中找到授权地址。"}),s&&l.jsx("div",{className:"auth-card-err",children:s})]})}function hw({blocks:e,appName:t="",streaming:n=!1,onStreamFrame:r,onAction:s,onAuth:i}){return l.jsx(l.Fragment,{children:e.map((a,o)=>{switch(a.kind){case"thinking":return l.jsx(M3,{text:a.text,done:a.done,streaming:n,onStreamFrame:r},o);case"text":{const c=a.text.replace(/^\s+/,"");return c?l.jsx(Ute,{text:c,streaming:n,onStreamFrame:r},o):null}case"attachment":return l.jsx(fw,{appName:t,items:a.files},o);case"invocation":return l.jsx(uw,{value:a.value},o);case"tool":return a.name===L3&&a.done?null:l.jsx($te,{name:a.name,args:a.args,response:a.response,done:a.done},o);case"agent-transfer":return null;case"auth":return l.jsx(Hte,{block:a,onAuth:i},o);case"a2ui":return N3(a.messages).filter(c=>c.components[c.rootId]).map(c=>l.jsx(Rt.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},transition:{type:"spring",stiffness:380,damping:30},children:l.jsx(xte,{surface:c,onAction:s})},`${o}-${c.surfaceId}`));default:return null}})})}function P3(e){return e.isComposing||e.keyCode===229}const zte="/assets/arkclaw-DG3MhHYM.png",Vte="/assets/codex-Csw-JJxq.png",Kte="/assets/hermes-C6L-CfGS.png",Es=[{value:"agent",label:"Agent",description:"与当前选择的 Agent 对话"},{value:"temporary",label:"内置智能体",description:"使用平台提供的智能体"},{value:"skill-create",label:"创建 Skill",description:"使用两个模型生成并对比 Skill"}],Yte=[{label:"ArkClaw",logo:zte},{label:"Hermes 智能体",logo:Kte}];function YS({mode:e}){return e==="skill-create"?l.jsxs("svg",{className:"new-chat-mode__skill-icon",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"M10 2.2l1.35 4.1 4.15 1.35-4.15 1.35L10 13.1 8.65 9 4.5 7.65 8.65 6.3 10 2.2Z"}),l.jsx("path",{d:"M15.6 12.2l.6 1.8 1.8.6-1.8.6-.6 1.8-.6-1.8-1.8-.6 1.8-.6.6-1.8Z"})]}):e==="temporary"?l.jsxs("svg",{className:"new-chat-mode__temporary-icon",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"m10 2.8 6.1 3.45v7.5L10 17.2l-6.1-3.45v-7.5L10 2.8Z"}),l.jsx("path",{d:"m3.9 6.25 6.1 3.5 6.1-3.5M10 9.75v7.45"})]}):l.jsx(ql,{className:"new-chat-mode__agent-icon"})}function Wte(){return l.jsx("svg",{className:"new-chat-mode__nested-chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m4.5 3 3 3-3 3"})})}function qte({value:e,onChange:t,disabled:n=!1,temporaryEnabled:r,skillCreateEnabled:s}){const[i,a]=v.useState(!1),[o,c]=v.useState(!1),[u,d]=v.useState(()=>Es.findIndex(k=>k.value===e)),f=v.useRef(null),h=v.useRef(null),p=Es.find(k=>k.value===e)??Es[0],m=p.value==="temporary"?"Codex 智能体":p.label;function g(k){return k.value==="temporary"?r:k.value==="skill-create"?s:!0}function x(k){return g(k)!==!0}function y(k){const T=g(k);return T===void 0?"正在检查配置":T?k.description:"管理员未配置"}v.useEffect(()=>{if(!i)return;const k=T=>{var A;(A=f.current)!=null&&A.contains(T.target)||(a(!1),c(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[i]);function E(k){let T=u;do T=(T+k+Es.length)%Es.length;while(x(Es[T]));d(T),c(Es[T].value==="temporary")}function b(k){var T;if(!x(k)){if(k.value==="temporary"){c(!0);return}t(k.value),a(!1),c(!1),(T=h.current)==null||T.focus()}}function _(){t("temporary"),a(!1),c(!1)}return l.jsxs("div",{className:"new-chat-mode",ref:f,children:[l.jsxs("button",{ref:h,type:"button",className:"new-chat-mode__trigger","aria-label":"选择新会话模式","aria-haspopup":"listbox","aria-expanded":i,disabled:n,onClick:()=>{d(Es.findIndex(k=>k.value===e)),a(k=>(k&&c(!1),!k))},onKeyDown:k=>{k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),i?E(k.key==="ArrowDown"?1:-1):a(!0)):i&&(k.key==="Enter"||k.key===" ")?(k.preventDefault(),b(Es[u])):i&&k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1))},children:[l.jsx("span",{className:"new-chat-mode__icon",children:l.jsx(YS,{mode:p.value})}),l.jsx("span",{className:"new-chat-mode__current",title:m,children:m}),l.jsx("svg",{className:"new-chat-mode__chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m3 4.5 3 3 3-3"})})]}),i?l.jsx("div",{className:"new-chat-mode__menu",role:"listbox","aria-label":"新会话模式",tabIndex:-1,onKeyDown:k=>{var T;k.key==="ArrowDown"||k.key==="ArrowUp"?(k.preventDefault(),E(k.key==="ArrowDown"?1:-1)):k.key==="Enter"?(k.preventDefault(),b(Es[u])):k.key==="Escape"&&(k.preventDefault(),a(!1),c(!1),(T=h.current)==null||T.focus())},children:Es.map((k,T)=>{const A=k.value==="temporary";return l.jsxs("button",{type:"button",role:"option","aria-selected":e===k.value,"aria-haspopup":A?"menu":void 0,"aria-expanded":A?o:void 0,"aria-disabled":x(k),disabled:x(k),className:`new-chat-mode__option${T===u?" is-active":""}`,onMouseEnter:()=>{d(T),c(k.value==="temporary")},onClick:()=>b(k),children:[l.jsx("span",{className:"new-chat-mode__option-icon",children:l.jsx(YS,{mode:k.value})}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsxs("span",{className:"new-chat-mode__label",children:[k.label,k.value==="skill-create"?l.jsx("span",{className:"new-chat-mode__beta",children:"Beta"}):null]}),l.jsx("span",{children:y(k)})]}),A?l.jsx(Wte,{}):e===k.value?l.jsx("svg",{className:"new-chat-mode__check",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})}):null]},k.value)})}):null,i&&o?l.jsxs("div",{className:"new-chat-mode__submenu",role:"menu","aria-label":"内置智能体",children:[l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",onClick:_,children:[l.jsx("img",{className:"new-chat-mode__builtin-icon",src:Vte,alt:"","aria-hidden":"true"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:"Codex 智能体"}),l.jsx("span",{children:"在沙箱中执行任务"})]})]}),Yte.map(({label:k,logo:T})=>l.jsxs("button",{type:"button",role:"menuitem",className:"new-chat-mode__submenu-option",disabled:!0,children:[l.jsx("img",{className:"new-chat-mode__builtin-icon",src:T,alt:"","aria-hidden":"true"}),l.jsxs("span",{className:"new-chat-mode__copy",children:[l.jsx("span",{className:"new-chat-mode__label",children:k}),l.jsx("span",{children:"暂不可用"})]})]},k))]}):null]})}const pw=["doubao-seed-2-0-pro-260215","deepseek-v4-flash-260425"];function Gte(){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"8.2",cy:"8.2",r:"4.7"}),l.jsx("path",{d:"m11.7 11.7 4.1 4.1"}),l.jsx("path",{d:"M14.8 2.7v3.2M13.2 4.3h3.2"}),l.jsx("circle",{cx:"8.2",cy:"8.2",r:"1",fill:"currentColor",stroke:"none"})]})}function Xte(){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[l.jsx("circle",{cx:"4.2",cy:"15.4",r:"1.4"}),l.jsx("circle",{cx:"15.7",cy:"4.2",r:"1.4"}),l.jsx("path",{d:"M5.7 15.1c3.5-.3 1.8-4.7 5.1-5.1 2.8-.4 2.1-3.7 3.5-4.8"}),l.jsx("path",{d:"m12.7 14.2 1.5 1.5 2.9-3.3"})]})}function Qte(){return l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[l.jsx("path",{d:"M3.2 5.2h7.1M3.2 9.5h5.2M3.2 13.8h4"}),l.jsx("path",{d:"m10.1 14.8.6-2.8 4.7-4.7 2.2 2.2-4.7 4.7-2.8.6Z"}),l.jsx("path",{d:"M14.5 3.1v2.5M13.2 4.4h2.6"})]})}const Zte=[{icon:Gte,text:"帮我分析一个问题,并给出清晰的解决思路"},{icon:Xte,text:"根据我的目标,制定一份可执行的行动计划"},{icon:Qte,text:"帮我整理并润色一段内容,让表达更清晰"}];function Jte({sessionId:e,sessionInitializing:t=!1,appName:n,agentName:r,value:s,onChange:i,onSubmit:a,disabled:o,busy:c,showMeta:u,attachments:d,skills:f,agents:h,invocation:p,capabilitiesLoading:m=!1,allowAttachments:g=!0,onInvocationChange:x,onAddFiles:y,onRemoveAttachment:E,newChatMode:b="agent",newChatLayout:_=!1,showModeSelector:k=!1,onModeChange:T,temporaryEnabled:A,skillCreateEnabled:N}){const S=v.useRef(null),C=v.useRef(null),M=v.useRef(null),U=v.useRef(null),[q,P]=v.useState(!1),[D,I]=v.useState(null),[L,O]=v.useState(0),[B,R]=v.useState(!1);async function z(){if(e)try{await navigator.clipboard.writeText(e),R(!0),setTimeout(()=>R(!1),1500)}catch{R(!1)}}v.useLayoutEffect(()=>{const Q=S.current;Q&&(Q.style.height="auto",Q.style.height=`${Math.min(Q.scrollHeight,200)}px`)},[s]);const Y=b==="skill-create";v.useEffect(()=>{Y&&(P(!1),I(null))},[Y]);const j=!Y&&d.some(Q=>Q.status!=="ready"),re=!o&&!c&&!j&&(s.trim().length>0||!Y&&d.length>0),V=(D==null?void 0:D.query.toLocaleLowerCase())??"",ee=(D==null?void 0:D.kind)==="skill"?f.filter(Q=>!p.skills.some(ge=>ge.name===Q.name)).filter(Q=>`${Q.name} ${Q.description}`.toLocaleLowerCase().includes(V)).map(Q=>({kind:"skill",value:Q})):(D==null?void 0:D.kind)==="agent"?h.filter(Q=>`${Q.name} ${Q.description}`.toLocaleLowerCase().includes(V)).map(Q=>({kind:"agent",value:Q})):[];function oe(Q){var ge;P(!1),I(null),(ge=Q.current)==null||ge.click()}function X(Q){i(Q),P(!1),I(null),requestAnimationFrame(()=>{var ge,be;(ge=S.current)==null||ge.focus(),(be=S.current)==null||be.setSelectionRange(Q.length,Q.length)})}function ae(Q,ge){const be=Q.slice(0,ge),_e=/(^|\s)([/@])([^\s/@]*)$/.exec(be);if(!_e){I(null);return}const Pe=_e[2].length+_e[3].length,we={kind:_e[2]==="/"?"skill":"agent",query:_e[3],start:ge-Pe,end:ge},ht=!D||D.kind!==we.kind||D.query!==we.query||D.start!==we.start||D.end!==we.end;I(we),ht&&O(0),P(!1)}function Z(Q){if(!D)return;const ge=s.slice(0,D.start)+s.slice(D.end);i(ge),Q.kind==="skill"?x({...p,skills:[...p.skills,Q.value]}):x({skills:[],targetAgent:Q.value});const be=D.start;I(null),requestAnimationFrame(()=>{var _e,Pe;(_e=S.current)==null||_e.focus(),(Pe=S.current)==null||Pe.setSelectionRange(be,be)})}function de(){if(p.targetAgent){x({skills:[]});return}p.skills.length>0&&x({...p,skills:p.skills.slice(0,-1)})}function ye(Q){const ge=Q.target.files?Array.from(Q.target.files):[];ge.length&&y(ge),Q.target.value=""}return l.jsxs("div",{className:`composer${_?" composer--new-chat":""}${Y?" composer--skill-mode":""}`,children:[Y?null:l.jsx(uw,{value:p,onRemoveSkill:Q=>x({...p,skills:p.skills.filter(ge=>ge.name!==Q)}),onRemoveAgent:()=>x({skills:[]})}),!Y&&d.length>0&&l.jsx(fw,{appName:n,compact:!0,items:d,onRemove:E}),l.jsxs("div",{className:"composer-box",children:[D?l.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":D.kind==="skill"?"可用技能":"可用子 Agent",children:[l.jsxs("div",{className:"composer-command-head",children:[D.kind==="skill"?l.jsx(ho,{}):l.jsx(LR,{}),l.jsx("span",{children:D.kind==="skill"?"调用技能":"使用子 Agent"}),l.jsx("kbd",{children:D.kind==="skill"?"/":"@"})]}),m?l.jsxs("div",{className:"composer-command-empty",children:[l.jsx(bt,{className:"spin"})," 正在读取 Agent 能力…"]}):ee.length===0?l.jsx("div",{className:"composer-command-empty",children:D.kind==="skill"?"当前 Agent 没有匹配技能":"当前 Agent 没有匹配子 Agent"}):l.jsx("div",{className:"composer-command-list",children:ee.map((Q,ge)=>l.jsxs("button",{type:"button",role:"option","aria-selected":ge===L,className:`composer-command-item${ge===L?" is-active":""}`,onMouseDown:be=>{be.preventDefault(),Z(Q)},onMouseEnter:()=>O(ge),children:[l.jsx("span",{className:`composer-command-icon composer-command-icon--${Q.kind}`,children:Q.kind==="skill"?l.jsx(ho,{}):l.jsx(Hl,{})}),l.jsxs("span",{className:"composer-command-copy",children:[l.jsxs("strong",{children:[Q.kind==="skill"?"/":"@",Q.value.name]}),l.jsx("span",{children:Q.value.description||(Q.kind==="skill"?"加载并执行该技能":"将本轮交给该 Agent")})]}),l.jsx("kbd",{children:ge===L?"↵":Q.kind==="skill"?"技能":"Agent"})]},`${Q.kind}-${Q.value.name}`))})]}):null,Y?null:l.jsxs("div",{className:"composer-menu-wrap",children:[l.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:o||!g,onClick:()=>{I(null),P(Q=>!Q)},children:l.jsx(Ps,{className:"icon"})}),q&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>P(!1)}),l.jsxs("div",{className:"composer-menu",role:"menu",children:[l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>oe(C),children:[l.jsx(BR,{className:"icon"}),"上传图片"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>oe(M),children:[l.jsx(DR,{className:"icon"}),"上传文档或 PDF"]}),l.jsxs("button",{type:"button",className:"menu-item",onClick:()=>oe(U),children:[l.jsx(PR,{className:"icon"}),"上传视频"]})]})]})]}),k&&T?l.jsx(qte,{value:b,onChange:T,disabled:c,temporaryEnabled:A,skillCreateEnabled:N}):null,l.jsx("div",{className:"composer-input-stack",children:l.jsx("textarea",{ref:S,className:"comp-input scroll",rows:_?4:1,value:s,disabled:o,placeholder:Y?`描述你想创建的 Skill,将使用 ${pw.join(" 和 ")} 并行创建…`:o?"请在页面左上角选择智能体":`向 ${r} 发消息…`,"aria-expanded":!!D,onChange:Q=>{i(Q.target.value),Y||ae(Q.target.value,Q.target.selectionStart)},onSelect:Q=>{Y||ae(Q.currentTarget.value,Q.currentTarget.selectionStart)},onBlur:()=>setTimeout(()=>I(null),0),onKeyDown:Q=>{if(!P3(Q.nativeEvent)){if(D){if(Q.key==="ArrowDown"&&ee.length>0){Q.preventDefault(),O(ge=>(ge+1)%ee.length);return}if(Q.key==="ArrowUp"&&ee.length>0){Q.preventDefault(),O(ge=>(ge-1+ee.length)%ee.length);return}if((Q.key==="Enter"||Q.key==="Tab")&&ee[L]){Q.preventDefault(),Z(ee[L]);return}if(Q.key==="Escape"){Q.preventDefault(),I(null);return}}if(Q.key==="Backspace"&&!s&&Q.currentTarget.selectionStart===0&&Q.currentTarget.selectionEnd===0){de();return}Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),re&&a())}}})}),l.jsx(Rt.button,{type:"button",className:"comp-send",disabled:!re,onClick:a,"aria-label":"发送",whileTap:re?{scale:.9}:void 0,transition:{type:"spring",stiffness:600,damping:22},children:c?l.jsx(bt,{className:"icon spin"}):l.jsx(RR,{className:"icon"})})]}),_&&b==="agent"&&!s.trim()?l.jsx("div",{className:"prompt-suggestions","aria-label":"快捷提示",children:Zte.map(Q=>{const ge=Q.icon;return l.jsxs("button",{type:"button",className:"prompt-suggestion",disabled:o||c,onClick:()=>X(Q.text),children:[l.jsx(ge,{}),l.jsx("span",{children:Q.text})]},Q.text)})}):null,u&&l.jsxs("div",{className:"composer-meta",children:[l.jsxs("span",{className:"composer-session-line",children:["会话 ID:",l.jsx("span",{className:"composer-session-id",title:e||void 0,"aria-live":"polite",children:t?"初始化中":e||"—"}),e&&l.jsx("button",{type:"button",className:"composer-session-copy",title:B?"已复制":"复制会话 ID","aria-label":B?"已复制会话 ID":"复制会话 ID",onClick:()=>void z(),children:B?l.jsx(Bs,{}):l.jsx(Ex,{})})]}),l.jsx("span",{className:"composer-meta-separator","aria-hidden":!0,children:"|"}),l.jsx("span",{children:"回答仅供参考"})]}),l.jsx("input",{ref:C,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:ye}),l.jsx("input",{ref:M,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:ye}),l.jsx("input",{ref:U,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:ye})]})}function j3({title:e,sub:t,cards:n,footer:r}){return l.jsxs("div",{className:"stk",children:[l.jsxs("div",{className:"stk-head",children:[l.jsx("h1",{className:"stk-title",children:e}),t&&l.jsx("p",{className:"stk-sub",children:t})]}),l.jsx("div",{className:"stk-list",children:n.map((s,i)=>l.jsxs(Rt.button,{type:"button",className:`stk-card ${s.disabled?"stk-card-disabled":""}`,onClick:s.disabled?void 0:s.onClick,disabled:s.disabled,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut",delay:i*.04},children:[l.jsx("span",{className:"stk-card-icon",children:l.jsx(s.icon,{})}),l.jsxs("span",{className:"stk-card-text",children:[l.jsx("span",{className:"stk-card-title",children:s.title}),l.jsx("span",{className:"stk-card-desc",children:s.desc})]}),l.jsx(Nr,{className:"stk-card-arrow"})]},s.key))}),r&&l.jsx("div",{className:"stk-footer",children:r})]})}const mw=Symbol.for("yaml.alias"),E1=Symbol.for("yaml.document"),ga=Symbol.for("yaml.map"),B3=Symbol.for("yaml.pair"),oi=Symbol.for("yaml.scalar"),_c=Symbol.for("yaml.seq"),fs=Symbol.for("yaml.node.type"),kc=e=>!!e&&typeof e=="object"&&e[fs]===mw,Xd=e=>!!e&&typeof e=="object"&&e[fs]===E1,Qd=e=>!!e&&typeof e=="object"&&e[fs]===ga,En=e=>!!e&&typeof e=="object"&&e[fs]===B3,Ot=e=>!!e&&typeof e=="object"&&e[fs]===oi,Zd=e=>!!e&&typeof e=="object"&&e[fs]===_c;function yn(e){if(e&&typeof e=="object")switch(e[fs]){case ga:case _c:return!0}return!1}function bn(e){if(e&&typeof e=="object")switch(e[fs]){case mw:case ga:case oi:case _c:return!0}return!1}const F3=e=>(Ot(e)||yn(e))&&!!e.anchor,Ua=Symbol("break visit"),ene=Symbol("skip children"),Mu=Symbol("remove node");function Tc(e,t){const n=tne(t);Xd(e)?pl(null,e.contents,n,Object.freeze([e]))===Mu&&(e.contents=null):pl(null,e,n,Object.freeze([]))}Tc.BREAK=Ua;Tc.SKIP=ene;Tc.REMOVE=Mu;function pl(e,t,n,r){const s=nne(e,t,n,r);if(bn(s)||En(s))return rne(e,r,s),pl(e,s,n,r);if(typeof s!="symbol"){if(yn(t)){r=Object.freeze(r.concat(t));for(let i=0;ie.replace(/[!,[\]{}]/g,t=>sne[t]);class gr{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},gr.defaultYaml,t),this.tags=Object.assign({},gr.defaultTags,n)}clone(){const t=new gr(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new gr(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:gr.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},gr.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:gr.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},gr.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[i,a]=r;return this.tags[i]=a,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{const a=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,a),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const a=t.slice(2,-1);return a==="!"||a==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),a)}const[,r,s]=t.match(/^(.*!)([^!]*)$/s);s||n(`The ${t} tag has no suffix`);const i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(a){return n(String(a)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+ine(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let s;if(t&&r.length>0&&bn(t.contents)){const i={};Tc(t.contents,(a,o)=>{bn(o)&&o.tag&&(i[o.tag]=!0)}),s=Object.keys(i)}else s=[];for(const[i,a]of r)i==="!!"&&a==="tag:yaml.org,2002:"||(!t||s.some(o=>o.startsWith(a)))&&n.push(`%TAG ${i} ${a}`);return n.join(` `)}}gr.defaultYaml={explicit:!1,version:"1.2"};gr.defaultTags={"!!":"tag:yaml.org,2002:"};function U3(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function $3(e){const t=new Set;return Tc(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function H3(e,t){for(let n=1;;++n){const r=`${e}${n}`;if(!t.has(r))return r}}function ane(e,t){const n=[],r=new Map;let s=null;return{onAnchor:i=>{n.push(i),s??(s=$3(e));const a=H3(t,s);return s.add(a),a},setAnchors:()=>{for(const i of n){const a=r.get(i);if(typeof a=="object"&&a.anchor&&(Ot(a.node)||yn(a.node)))a.node.anchor=a.anchor;else{const o=new Error("Failed to resolve repeated object (this should not happen)");throw o.source=i,o}}},sourceObjects:r}}function ml(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;scs(r,String(s),n));if(e&&typeof e.toJSON=="function"){if(!n||!F3(e))return e.toJSON(t,n);const r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=i=>{r.res=i,delete n.onCreate};const s=e.toJSON(t,n);return n.onCreate&&n.onCreate(s),s}return typeof e=="bigint"&&!(n!=null&&n.keep)?Number(e):e}class gw{constructor(t){Object.defineProperty(this,fs,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!Xd(t))throw new TypeError("A document argument is required");const a={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},o=cs(this,"",a);if(typeof s=="function")for(const{count:c,res:u}of a.anchors.values())s(u,c);return typeof i=="function"?ml(i,{"":o},"",o):o}}class yw extends gw{constructor(t){super(mw),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if((n==null?void 0:n.maxAliasCount)===0)throw new ReferenceError("Alias resolution is disabled");let r;n!=null&&n.aliasResolveCache?r=n.aliasResolveCache:(r=[],Tc(t,{Node:(i,a)=>{(kc(a)||F3(a))&&r.push(a)}}),n&&(n.aliasResolveCache=r));let s;for(const i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(t,n){if(!n)return{source:this.source};const{anchors:r,doc:s,maxAliasCount:i}=n,a=this.resolve(s,n);if(!a){const c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let o=r.get(a);if(o||(cs(a,null,n),o=r.get(a)),(o==null?void 0:o.res)===void 0){const c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Kh(s,a,r)),o.count*o.aliasCount>i)){const c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return o.res}toString(t,n,r){const s=`*${this.source}`;if(t){if(U3(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(t.implicitKey)return`${s} `}return s}}function Kh(e,t,n){if(kc(t)){const r=t.resolve(e),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(yn(t)){let r=0;for(const s of t.items){const i=Kh(e,s,n);i>r&&(r=i)}return r}else if(En(t)){const r=Kh(e,t.key,n),s=Kh(e,t.value,n);return Math.max(r,s)}return 1}const z3=e=>!e||typeof e!="function"&&typeof e!="object";class Ze extends gw{constructor(t){super(oi),this.value=t}toJSON(t,n){return n!=null&&n.keep?this.value:cs(this.value,t,n)}toString(){return String(this.value)}}Ze.BLOCK_FOLDED="BLOCK_FOLDED";Ze.BLOCK_LITERAL="BLOCK_LITERAL";Ze.PLAIN="PLAIN";Ze.QUOTE_DOUBLE="QUOTE_DOUBLE";Ze.QUOTE_SINGLE="QUOTE_SINGLE";const one="tag:yaml.org,2002:";function lne(e,t,n){if(t){const r=n.filter(i=>i.tag===t),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${t} not found`);return s}return n.find(r=>{var s;return((s=r.identify)==null?void 0:s.call(r,e))&&!r.format})}function yd(e,t,n){var f,h,p;if(Xd(e)&&(e=e.contents),bn(e))return e;if(En(e)){const m=(h=(f=n.schema[ga]).createNode)==null?void 0:h.call(f,n.schema,null,n);return m.items.push(e),m}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:a,sourceObjects:o}=n;let c;if(r&&e&&typeof e=="object"){if(c=o.get(e),c)return c.anchor??(c.anchor=s(e)),new yw(c.anchor);c={anchor:null,node:null},o.set(e,c)}t!=null&&t.startsWith("!!")&&(t=one+t.slice(2));let u=lne(e,t,a.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const m=new Ze(e);return c&&(c.node=m),m}u=e instanceof Map?a[ga]:Symbol.iterator in Object(e)?a[_c]:a[ga]}i&&(i(u),delete n.onTagObj);const d=u!=null&&u.createNode?u.createNode(n.schema,e,n):typeof((p=u==null?void 0:u.nodeClass)==null?void 0:p.from)=="function"?u.nodeClass.from(n.schema,e,n):new Ze(e);return t?d.tag=t:u.default||(d.tag=u.tag),c&&(c.node=d),d}function Jp(e,t,n){let r=n;for(let s=t.length-1;s>=0;--s){const i=t[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){const a=[];a[i]=r,r=a}else r=new Map([[i,r]])}return yd(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const au=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class V3 extends gw{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>bn(r)||En(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(au(t))this.add(n);else{const[r,...s]=t,i=this.get(r,!0);if(yn(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Jp(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(t){const[n,...r]=t;if(r.length===0)return this.delete(n);const s=this.get(n,!0);if(yn(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){const[r,...s]=t,i=this.get(r,!0);return s.length===0?!n&&Ot(i)?i.value:i:yn(i)?i.getIn(s,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!En(n))return!1;const r=n.value;return r==null||t&&Ot(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){const[n,...r]=t;if(r.length===0)return this.has(n);const s=this.get(n,!0);return yn(s)?s.hasIn(r):!1}setIn(t,n){const[r,...s]=t;if(s.length===0)this.set(r,n);else{const i=this.get(r,!0);if(yn(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Jp(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}}const cne=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Si(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Xa=(e,t,n)=>e.endsWith(` `)?Si(n,t):n.includes(` @@ -676,9 +676,9 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus - 需要时合理调用可用的工具,并说明关键结论。 - 保持礼貌、专业的语气。`;function _a(){return{name:"",description:fre,instruction:hre,agentType:"llm",maxIterations:3,a2aUrl:"",tools:[],skills:[],memory:{shortTerm:!1,longTerm:!1},knowledgebase:!1,tracing:!1,subAgents:[],builtinTools:[],customTools:[],mcpTools:[],a2aRegistry:{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},modelName:dre,modelProvider:"",modelApiBase:"",shortTermBackend:"local",longTermBackend:"local",autoSaveSession:!1,knowledgebaseBackend:Ql,knowledgebaseIndex:"",tracingExporters:[],selectedSkills:[],deployment:{feishuEnabled:!1}}}const pre=new Set(["local","sqlite","mysql","postgresql"]),mre=new Set(["local","opensearch","redis","viking","mem0"]),gre=new Set(["opensearch","viking","context_search"]),yre=new Set(["apmplus","cozeloop","tls"]),vD=new Set(["web_search","parallel_web_search","link_reader","web_scraper","image_generate","image_edit","video_generate","text_to_speech","run_code","vesearch"]),bre=new Set(["llm","sequential","parallel","loop","a2a"]);function st(e,t=""){return typeof e=="string"?e:t}function $a(e){return e===!0}function qh(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function _D(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"?{name:st(t.name),description:st(t.description)}:null).filter(t=>!!t&&!!t.name.trim()):[]}function ey(e,t,n){return typeof e=="string"&&t.has(e)?e:n}function kD(e){return typeof e=="string"&&bre.has(e)?e:"llm"}function TD(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):3}function SD(e){const t=e&&typeof e=="object"?e:{};return{enabled:$a(t.enabled),registrySpaceId:st(t.registrySpaceId),registryTopK:st(t.registryTopK),registryRegion:st(t.registryRegion),registryEndpoint:st(t.registryEndpoint)}}function ND(e){return Array.isArray(e)?e.map(t=>{const n=t&&typeof t=="object"?t:{},r=SD(n.a2aRegistry),s=kD(n.agentType),i=r.enabled&&s==="llm"?"a2a":s;return{..._a(),name:st(n.name),description:st(n.description),instruction:st(n.instruction),agentType:i,maxIterations:TD(n.maxIterations),a2aUrl:st(n.a2aUrl),builtinTools:qh(n.builtinTools).filter(a=>vD.has(a)),customTools:_D(n.customTools),a2aRegistry:i==="a2a"?{...r,enabled:!0}:r,subAgents:ND(n.subAgents)}}):[]}function Ere(e){if(!Array.isArray(e.selectedSkills))return[];const t=[];for(const n of e.selectedSkills){const r=n&&typeof n=="object"?n:{},s=st(r.source),i=s==="local"||s==="skillspace"||s==="skillhub"?s:"skillhub",a=st(r.name)||st(r.slug)||st(r.skillName)||st(r.skillId)||"skill",o=st(r.folder)||a,c=st(r.description);if(i==="skillhub"){const f=st(r.slug);if(!f)continue;t.push({source:i,folder:o,name:a,description:c,slug:f,namespace:st(r.namespace)||"public"});continue}if(i==="local"){const h=(Array.isArray(r.localFiles)?r.localFiles:[]).map(p=>{const m=p&&typeof p=="object"?p:{},g=st(m.path),x=st(m.content);return g?{path:g,content:x}:null}).filter(p=>p!==null);if(h.length===0)continue;t.push({source:i,folder:o,name:a,description:c,localFiles:h});continue}const u=st(r.skillSpaceId),d=st(r.skillId);!u||!d||t.push({source:i,folder:o,name:a,description:c,skillSpaceId:u,skillSpaceName:st(r.skillSpaceName),skillId:d,version:st(r.version)})}return t}function AD(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:{},s=SD(t.a2aRegistry),i=kD(t.agentType),a=s.enabled&&i==="llm"?"a2a":i,o=Array.isArray(t.mcpTools)?t.mcpTools.map(c=>{const u=c&&typeof c=="object"?c:{},d=u.transport==="stdio"?"stdio":"http";return{name:st(u.name),transport:d,url:st(u.url),authToken:st(u.authToken),command:st(u.command),args:qh(u.args)}}).filter(c=>c.transport==="http"?!!c.url:!!c.command):[];return{..._a(),name:st(t.name)||"my_agent",description:st(t.description),instruction:st(t.instruction)||"You are a helpful assistant.",agentType:a,maxIterations:TD(t.maxIterations),a2aUrl:st(t.a2aUrl),modelName:st(t.modelName),modelProvider:st(t.modelProvider),modelApiBase:st(t.modelApiBase),builtinTools:qh(t.builtinTools).filter(c=>vD.has(c)),customTools:_D(t.customTools),mcpTools:o,a2aRegistry:a==="a2a"?{...s,enabled:!0}:s,memory:{shortTerm:$a(n.shortTerm),longTerm:$a(n.longTerm)},shortTermBackend:ey(t.shortTermBackend,pre,"local"),longTermBackend:ey(t.longTermBackend,mre,"local"),autoSaveSession:$a(t.autoSaveSession),knowledgebase:$a(t.knowledgebase),knowledgebaseBackend:ey(t.knowledgebaseBackend,gre,Ql),knowledgebaseIndex:st(t.knowledgebaseIndex),tracing:$a(t.tracing),tracingExporters:qh(t.tracingExporters).filter(c=>yre.has(c)),deployment:{feishuEnabled:$a(r.feishuEnabled)},subAgents:ND(t.subAgents),selectedSkills:Ere(t)}}function CD(e){var n,r,s,i,a,o,c,u,d,f,h,p,m,g,x,y,E,b;const t={agentType:e.agentType??"llm"};if(e.agentType==="a2a"){if((n=e.a2aRegistry)!=null&&n.enabled){const _={enabled:!0};(r=e.a2aRegistry.registrySpaceId)!=null&&r.trim()&&(_.registrySpaceId=e.a2aRegistry.registrySpaceId.trim()),_.registryTopK=((s=e.a2aRegistry.registryTopK)==null?void 0:s.trim())||Ms.topK,_.registryRegion=((i=e.a2aRegistry.registryRegion)==null?void 0:i.trim())||Ms.region,_.registryEndpoint=((a=e.a2aRegistry.registryEndpoint)==null?void 0:a.trim())||Ms.endpoint,t.a2aRegistry=_}return t}return t.name=e.name,t.description=e.description,t.instruction=e.instruction,e.agentType==="loop"&&(t.maxIterations=e.maxIterations??3),(o=e.modelName)!=null&&o.trim()&&(t.modelName=e.modelName.trim()),(c=e.modelProvider)!=null&&c.trim()&&(t.modelProvider=e.modelProvider.trim()),(u=e.modelApiBase)!=null&&u.trim()&&(t.modelApiBase=e.modelApiBase.trim()),(d=e.builtinTools)!=null&&d.length&&(t.builtinTools=[...e.builtinTools]),(f=e.customTools)!=null&&f.length&&(t.customTools=e.customTools.map(_=>({name:_.name,description:_.description}))),(h=e.mcpTools)!=null&&h.length&&(t.mcpTools=e.mcpTools.map(_=>{var T,A,N,S;const k={name:_.name,transport:_.transport};return(T=_.url)!=null&&T.trim()&&(k.url=_.url.trim()),(A=_.authToken)!=null&&A.trim()&&(k.authToken=_.authToken.trim()),(N=_.command)!=null&&N.trim()&&(k.command=_.command.trim()),(S=_.args)!=null&&S.length&&(k.args=_.args),k})),((p=e.memory)!=null&&p.shortTerm||(m=e.memory)!=null&&m.longTerm)&&(t.memory={shortTerm:!!e.memory.shortTerm,longTerm:!!e.memory.longTerm},e.memory.shortTerm&&(t.shortTermBackend=e.shortTermBackend||"local"),e.memory.longTerm&&(t.longTermBackend=e.longTermBackend||"local",t.autoSaveSession=!!e.autoSaveSession)),e.knowledgebase&&(t.knowledgebase=!0,t.knowledgebaseBackend=e.knowledgebaseBackend||"viking",(g=e.knowledgebaseIndex)!=null&&g.trim()&&(t.knowledgebaseIndex=e.knowledgebaseIndex.trim())),e.tracing&&((x=e.tracingExporters)!=null&&x.length)&&(t.tracing=!0,t.tracingExporters=[...e.tracingExporters]),(y=e.deployment)!=null&&y.feishuEnabled&&(t.deployment={feishuEnabled:!0}),(E=e.selectedSkills)!=null&&E.length&&(t.selectedSkills=e.selectedSkills.map(_=>{const k={source:_.source,name:_.name,folder:_.folder};return _.description&&(k.description=_.description),_.source==="skillhub"?(k.slug=_.slug,k.namespace=_.namespace??"public"):_.source==="local"?k.localFiles=_.localFiles??[]:(k.skillSpaceId=_.skillSpaceId,k.skillSpaceName=_.skillSpaceName,k.skillId=_.skillId,_.version&&(k.version=_.version)),k})),(b=e.subAgents)!=null&&b.length&&(t.subAgents=e.subAgents.map(CD)),t}function xre(e){return`# VeADK Agent 结构配置 # 可在「创建 Agent」页通过「导入 YAML」重新载入。 -`+ure(CD(e))}function wre(e){const t=cre(e);return AD(t)}const vre=[{kind:"custom",icon:F7,title:"自定义",desc:"分步配置模型、工具、记忆、知识库等组件。"},{kind:"intelligent",icon:k7,title:"智能模式",desc:"敬请期待",disabled:!0},{kind:"template",icon:b7,title:"从模板新建",desc:"敬请期待",disabled:!0},{kind:"workflow",icon:U7,title:"工作流",desc:"敬请期待",disabled:!0}];function _re({onSelect:e,onImport:t}){const n=v.useRef(null),[r,s]=v.useState(""),i=vre.map(o=>({key:o.kind,icon:o.icon,title:o.title,desc:o.desc,disabled:o.disabled,onClick:()=>e(o.kind)})),a=async o=>{var u;const c=(u=o.target.files)==null?void 0:u[0];if(o.target.value="",!!c)try{const d=await c.text();t(wre(d))}catch(d){s(`导入失败:${d instanceof Error?d.message:String(d)}`)}};return l.jsx(j3,{title:"从 0 快速创建",sub:"选择一种方式开始",cards:i,footer:l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[l.jsxs("button",{className:"stk-import",onClick:()=>{var o;return(o=n.current)==null?void 0:o.click()},children:[l.jsx(j7,{}),"导入 YAML 配置"]}),r&&l.jsx("span",{style:{fontSize:12,color:"hsl(var(--destructive))"},children:r}),l.jsx("input",{ref:n,type:"file",accept:".yaml,.yml,text/yaml",style:{display:"none"},onChange:a})]})})}const kre="modulepreload",Tre=function(e){return"/"+e},sN={},Al=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=Tre(c),c in sN)return;sN[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":kre,u||(f.as="script"),f.crossOrigin="",f.href=c,o&&f.setAttribute("nonce",o),document.head.appendChild(f),u)return new Promise((h,p)=>{f.addEventListener("load",h),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return t().catch(i)})};function Sre({className:e,...t}){return l.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:[l.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"}),l.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 qo={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:Sre},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:h7},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:D7},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:HR},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:_x}},ah=[qo.llm,qo.sequential,qo.parallel,qo.loop,qo.a2a];function Iw(e){return qo[e??"llm"]}const ID=e=>e==="sequential"||e==="parallel"||e==="loop",nf=e=>e==="a2a";function RD(e){const t=new Map,n={};for(const r of e){for(const s of r.env){const i=t.get(s.key);(!i||s.required&&!i.required)&&t.set(s.key,s)}r.enableFlag&&(t.set(r.enableFlag,{key:r.enableFlag,required:!0}),n[r.enableFlag]="true")}return{specs:[...t.values()],fixedValues:n}}function Nre(e,t){return RD([{env:e}]).specs.map(r=>({...r,value:t[r.key]??""}))}function LD(e,t){const n=new Map;for(const r of e){const s=t[r.key]??"";s.trim()&&n.set(r.key,s)}return[...n].map(([r,s])=>({key:r,value:s}))}function iN(e,t){return e.find(n=>{var r;return n.required&&!((r=t[n.key])!=null&&r.trim())})}const Are=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Cre(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function Qt(e,t){e.push(t&255,t>>>8&255)}function jr(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}const aN=2048,ty=20,oN=0;function Ire(e){const t=new TextEncoder,n=[],r=[];let s=0;for(const p of e){const m=t.encode(p.path),g=t.encode(p.content),x=Cre(g),y=g.length,E=[];jr(E,67324752),Qt(E,ty),Qt(E,aN),Qt(E,oN),Qt(E,0),Qt(E,0),jr(E,x),jr(E,y),jr(E,y),Qt(E,m.length),Qt(E,0);const b=Uint8Array.from(E);n.push(b,m,g),r.push({nameBytes:m,dataBytes:g,crc:x,size:y,offset:s}),s+=b.length+m.length+g.length}const i=s,a=[];let o=0;for(const p of r){const m=[];jr(m,33639248),Qt(m,ty),Qt(m,ty),Qt(m,aN),Qt(m,oN),Qt(m,0),Qt(m,0),jr(m,p.crc),jr(m,p.size),jr(m,p.size),Qt(m,p.nameBytes.length),Qt(m,0),Qt(m,0),Qt(m,0),Qt(m,0),jr(m,0),jr(m,p.offset);const g=Uint8Array.from(m);a.push(g,p.nameBytes),o+=g.length+p.nameBytes.length}const c=[];jr(c,101010256),Qt(c,0),Qt(c,0),Qt(c,r.length),Qt(c,r.length),jr(c,o),jr(c,i),Qt(c,0);const u=[...n,...a,Uint8Array.from(c)],d=u.reduce((p,m)=>p+m.length,0),f=new Uint8Array(d);let h=0;for(const p of u)f.set(p,h),h+=p.length;return new Blob([f],{type:"application/zip"})}const Rre=v.lazy(()=>Al(()=>import("./CodeEditor-3xe29i9v.js"),[]));function Lre(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let s=t;r.forEach((i,a)=>{let o=s.children.get(i);o||(o={name:i,children:new Map},s.children.set(i,o)),a===r.length-1&&(o.path=n.path),s=o})}return t}function Ore(e){return[...e.children.values()].sort((t,n)=>{const r=t.children.size>0&&t.path===void 0,s=n.children.size>0&&n.path===void 0;return r!==s?r?-1:1:t.name.localeCompare(n.name)})}function OD({project:e,open:t,onClose:n,onChange:r}){var m;const[s,i]=v.useState(((m=e.files[0])==null?void 0:m.path)??null),[a,o]=v.useState(new Set),c=v.useRef(null),u=v.useMemo(()=>Lre(e.files),[e.files]),d=e.files.find(g=>g.path===s)??null;if(v.useEffect(()=>{var y;if(!t)return;const g=document.body.style.overflow;document.body.style.overflow="hidden",(y=c.current)==null||y.focus();const x=E=>{E.key==="Escape"&&n()};return window.addEventListener("keydown",x),()=>{document.body.style.overflow=g,window.removeEventListener("keydown",x)}},[n,t]),v.useEffect(()=>{d||e.files.length===0||i(e.files[0].path)},[e.files,d]),!t)return null;function f(g){o(x=>{const y=new Set(x);return y.has(g)?y.delete(g):y.add(g),y})}function h(g,x,y){return Ore(g).map(E=>{const b=y?`${y}/${E.name}`:E.name;if(!(E.children.size>0&&E.path===void 0)&&E.path)return l.jsxs("button",{type:"button",className:`code-browser-file${s===E.path?" is-active":""}`,style:{paddingLeft:`${12+x*16}px`},onClick:()=>i(E.path??null),title:E.path,children:[l.jsx(zk,{"aria-hidden":"true"}),l.jsx("span",{children:E.name})]},b);const k=a.has(b);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+x*16}px`},onClick:()=>f(b),"aria-expanded":!k,children:[l.jsx(Nr,{className:k?"":"is-open","aria-hidden":"true"}),l.jsx(jR,{"aria-hidden":"true"}),l.jsx("span",{children:E.name})]}),!k&&h(E,x+1,b)]},b)})}function p(g){d&&r({...e,files:e.files.map(x=>x.path===d.path?{...x,content:g}:x)})}return ai.createPortal(l.jsx("div",{className:"code-browser-backdrop",onMouseDown:g=>{g.target===g.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"code-browser-title",children:[l.jsxs("header",{className:"code-browser-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon","aria-hidden":"true",children:l.jsx(bx,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"code-browser-title",children:"项目代码"}),l.jsx("p",{children:e.name||"Agent 项目"})]})]}),l.jsx("button",{ref:c,type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭代码浏览器",children:l.jsx(Wr,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"code-browser-workspace",children:[l.jsxs("aside",{className:"code-browser-sidebar","aria-label":"项目文件",children:[l.jsxs("div",{className:"code-browser-sidebar-head",children:["文件 ",l.jsx("span",{children:e.files.length})]}),l.jsx("div",{className:"code-browser-tree",children:e.files.length>0?h(u,0,""):l.jsx("div",{className:"code-browser-empty",children:"暂无项目文件"})})]}),l.jsxs("main",{className:"code-browser-main",children:[l.jsxs("div",{className:"code-browser-path",children:[l.jsx(zk,{"aria-hidden":"true"}),l.jsx("span",{children:(d==null?void 0:d.path)??"未选择文件"})]}),l.jsx("div",{className:"code-browser-editor",children:d?l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:l.jsx(Rre,{value:d.content,path:d.path,onChange:p})}):l.jsx("div",{className:"code-browser-empty",children:"从左侧选择文件以查看代码"})})]})]})]})}),document.body)}function Mre({project:e,onChange:t,className:n=""}){const[r,s]=v.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:"查看源码",children:[l.jsx(bx,{"aria-hidden":"true"}),l.jsx("span",{children:"查看源码"})]}),l.jsx(OD,{project:e,open:r,onClose:()=>s(!1),onChange:t})]})}function nm({message:e,className:t="",onRetry:n}){const[r,s]=v.useState(!1),[i,a]=v.useState(!1),[o,c]=v.useState(!1),u=async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)}catch{a(!1)}},d=async()=>{if(!(!n||o)){c(!0);try{await n()}finally{c(!1)}}};return l.jsxs("div",{className:`deploy-error-message${r?" is-expanded":""}${t?` ${t}`:""}`,children:[l.jsx("p",{className:"deploy-error-message-text",children:e}),l.jsxs("div",{className:"deploy-error-message-actions",children:[n&&l.jsxs("button",{type:"button",className:"deploy-error-retry",disabled:o,onClick:()=>void d(),children:[o?l.jsx(bt,{className:"spin"}):l.jsx(L7,{}),o?"重试中…":"重试部署"]}),l.jsx("button",{type:"button",title:r?"收起错误信息":"展开完整错误信息","aria-label":r?"收起错误信息":"展开完整错误信息",onClick:()=>s(f=>!f),children:r?l.jsx(S7,{}):l.jsx(_u,{})}),l.jsx("button",{type:"button",title:i?"已复制":"复制完整错误信息","aria-label":i?"已复制":"复制完整错误信息",onClick:()=>void u(),children:i?l.jsx(Bs,{}):l.jsx(Ex,{})})]})]})}Lr.registerLanguage("python",JO);Lr.registerLanguage("typescript",dM);Lr.registerLanguage("javascript",WO);Lr.registerLanguage("json",qO);Lr.registerLanguage("yaml",fM);Lr.registerLanguage("markdown",ZO);Lr.registerLanguage("bash",$O);Lr.registerLanguage("ini",HO);Lr.registerLanguage("dockerfile",Sq);Lr.registerLanguage("makefile",QO);const Dre=v.lazy(()=>Al(()=>import("./CodeEditor-3xe29i9v.js"),[]));function Pre({open:e,onCancel:t,onConfirm:n}){const r=v.useRef(null);return v.useEffect(()=>{var a;if(!e)return;const s=document.body.style.overflow;document.body.style.overflow="hidden",(a=r.current)==null||a.focus();const i=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>{document.body.style.overflow=s,window.removeEventListener("keydown",i)}},[t,e]),e?ai.createPortal(l.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:s=>{s.target===s.currentTarget&&t()},children:l.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:[l.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:l.jsx(P7,{})}),l.jsx("h2",{id:"pp-confirm-title",children:"确认部署"})]}),l.jsx("button",{type:"button",className:"code-browser-close",onClick:t,"aria-label":"关闭部署确认",children:l.jsx(Wr,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"pp-confirm-body",children:l.jsx("p",{id:"pp-confirm-description",children:"部署后暂不支持修改 Agent 配置,确定部署吗?"})}),l.jsxs("footer",{className:"pp-confirm-actions",children:[l.jsx("button",{ref:r,type:"button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:n,children:"确定部署"})]})]})}),document.body):null}const jre={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"},lN={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function cN(e){return e.replace(/&/g,"&").replace(//g,">")}function Bre(e){const n=(e.split("/").pop()??e).toLowerCase();if(lN[n])return lN[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const r=n.lastIndexOf(".");if(r===-1)return null;const s=n.slice(r+1);return jre[s]??null}function Fre(e,t){try{const n=Bre(t);return n&&Lr.getLanguage(n)?Lr.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?Lr.highlightAuto(e).value:cN(e)}catch{return cN(e)}}const Ure=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],$re=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}];function Hre(e){return e.trim().replace(/[。.!!]+$/u,"")}function oh(e,t="未配置"){return[...new Set(e.map(r=>r==null?void 0:r.trim()).filter(Boolean))].join("、")||t}function MD(e,t="root"){var a,o,c;const n=e.agentType??"llm",r=[...(e.builtinTools??[]).map(u=>{var d;return((d=zee(u))==null?void 0:d.label)??u}),...(e.customTools??[]).map(u=>u.name),...(e.mcpTools??[]).map(u=>u.name),...e.tools??[]],s=[...(e.selectedSkills??[]).map(u=>u.name),...e.skills??[]],i=e.memory.longTerm?((a=Kee(e.longTermBackend??"local"))==null?void 0:a.label)??e.longTermBackend:void 0;return{id:t,name:e.name.trim()||"未命名 Agent",type:n,description:Hre(e.description),model:n==="llm"?e.modelName||e.model||"默认模型":"不适用",tools:oh(r),skills:oh(s),knowledgebase:e.knowledgebase?oh([((o=Yee(e.knowledgebaseBackend??Ql))==null?void 0:o.label)??e.knowledgebaseBackend??"默认知识库",e.knowledgebaseIndex]):"未配置",shortTerm:e.memory.shortTerm?((c=Vee(e.shortTermBackend??"local"))==null?void 0:c.label)??e.shortTermBackend??"默认后端":"未配置",longTerm:i?`${i}${e.autoSaveSession?" · 自动保存会话":""}`:"未配置",tracing:e.tracing?oh((e.tracingExporters??[]).map(u=>{var d;return((d=Wee(u))==null?void 0:d.label)??u}),"默认观测"):"未配置",children:e.subAgents.map((u,d)=>MD(u,`${t}.${d}`))}}function DD(e,t){if(e.id===t)return e;for(const n of e.children){const r=DD(n,t);if(r)return r}}function PD({agent:e,depth:t,inspectedId:n,onHover:r,onFocus:s}){const i=Iw(e.type),a=i.icon;return l.jsxs("div",{className:"pp-topology-branch",children:[l.jsxs("button",{type:"button",className:`pp-agent-node${e.id===n?" is-inspected":""}`,style:{marginLeft:t*16,width:`calc(100% - ${t*16}px)`},onMouseEnter:()=>r(e.id),onMouseLeave:()=>r(null),onFocus:()=>s(e.id),onBlur:()=>s(null),"aria-label":`查看 ${e.name} 配置`,children:[l.jsx("span",{className:"pp-agent-node-icon",children:l.jsx(a,{"aria-hidden":"true"})}),l.jsxs("span",{className:"pp-agent-node-main",children:[l.jsx("span",{className:"pp-agent-node-name",children:e.name}),l.jsx("span",{className:"pp-agent-node-type",children:i.label})]}),e.children.length>0&&l.jsx("span",{className:"pp-agent-child-count",children:e.children.length})]}),e.children.length>0&&l.jsx("div",{className:"pp-topology-children",children:e.children.map(o=>l.jsx(PD,{agent:o,depth:t+1,inspectedId:n,onHover:r,onFocus:s},o.id))})]})}function zre(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let s=t;r.forEach((i,a)=>{let o=s.children.get(i);o||(o={name:i,children:new Map},s.children.set(i,o)),a===r.length-1&&(o.path=n.path),s=o})}return t}function Vre(e){return[...e.children.values()].sort((t,n)=>{const r=t.children.size>0&&t.path===void 0,s=n.children.size>0&&n.path===void 0;return r!==s?r?-1:1:t.name.localeCompare(n.name)})}function Kre(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function Yre({left:e,right:t}){const[n,r]=v.useState(null);return v.useLayoutEffect(()=>{const s=document.getElementById("veadk-page-header-left"),i=document.getElementById("veadk-page-header-actions");s&&i&&r({left:s,right:i})},[]),n?l.jsxs(l.Fragment,{children:[ai.createPortal(e,n.left),ai.createPortal(t,n.right)]}):l.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function lg({project:e,agentDraft:t,agentName:n,agentCount:r,onChange:s,onDeploy:i,onAgentAdded:a,onDeploymentTaskChange:o,feishuEnabled:c=!1,onFeishuEnabledChange:u,deploymentEnv:d=[],deploymentEnvValues:f={},onDeploymentEnvChange:h,network:p,onNetworkChange:m,deployRegion:g="cn-beijing",onDeployRegionChange:x,onBack:y,backLabel:E="返回配置",onExportYaml:b,deploymentPrimaryPane:_,deployDisabled:k=!1,deployDisabledReason:T}){var dn,rn,fn;const A=typeof s=="function",N=_?$re:Ure,[S,C]=v.useState(((rn=(dn=e==null?void 0:e.files)==null?void 0:dn[0])==null?void 0:rn.path)??null),[M,U]=v.useState(new Set),[q,P]=v.useState(!1),[D,I]=v.useState(""),[L,O]=v.useState(!1),[B,R]=v.useState(!1),[z,Y]=v.useState(!1),[j,re]=v.useState(null),[V,ee]=v.useState(null),[oe,X]=v.useState({}),[ae,Z]=v.useState(null),[de,ye]=v.useState(!1),[Q,ge]=v.useState([]),[be,_e]=v.useState(!1),[Pe,we]=v.useState(!1),[ht,je]=v.useState(null),[Fe,ut]=v.useState(null),he=v.useRef(!0),Et=v.useMemo(()=>t?MD(t):{id:"root",name:n||(e==null?void 0:e.name)||"未命名 Agent",type:"llm",description:"",model:"默认模型",tools:"未配置",skills:"未配置",knowledgebase:"未配置",shortTerm:"未配置",longTerm:"未配置",tracing:"未配置",children:[]},[t,n,e==null?void 0:e.name]),mt=Fe??ht,W=mt?DD(Et,mt):void 0,J=W?Iw(W.type):void 0,ce=J==null?void 0:J.icon;v.useEffect(()=>(he.current=!0,()=>{he.current=!1}),[]);const ke=v.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:zre(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return l.jsx("div",{className:"pp-error",children:"项目数据无效"});const pe=e.files.find(se=>se.path===S)??null,Xe=(p==null?void 0:p.mode)??"public",St=Nre(c?[...d,...Yc]:d,f),We=St.length+Q.length;function Sn(se){U(ue=>{const Te=new Set(ue);return Te.has(se)?Te.delete(se):Te.add(se),Te})}function Me(se,ue){s&&(s({...e,files:se}),ue!==void 0&&C(ue))}function wt(se){pe&&Me(e.files.map(ue=>ue.path===pe.path?{...ue,content:se}:ue))}function vt(){const se=D.trim();if(P(!1),I(""),!!se){if(e.files.some(ue=>ue.path===se)){C(se);return}Me([...e.files,{path:se,content:""}],se)}}function Ct(){if(!pe)return;const se=window.prompt("重命名文件",pe.path),ue=se==null?void 0:se.trim();!ue||ue===pe.path||e.files.some(Te=>Te.path===ue)||Me(e.files.map(Te=>Te.path===pe.path?{...Te,path:ue}:Te),ue)}function Gt(){var ue;if(!pe)return;const se=e.files.filter(Te=>Te.path!==pe.path);Me(se,((ue=se[0])==null?void 0:ue.path)??null)}function Ve(se,ue){ge(Te=>Te.map(qe=>qe.id===se?{...qe,...ue}:qe))}function ot(se){ge(ue=>ue.filter(Te=>Te.id!==se))}function _t(){ge(se=>[...se,Kre()])}function kt(se){m&&m(se==="public"?void 0:{...p??{mode:se},mode:se})}function le(se){m==null||m({...p??{mode:"private"},...se})}function Le(){const se=new Map(Q.map(Te=>({key:Te.key.trim(),value:Te.value})).filter(Te=>Te.key.length>0).map(Te=>[Te.key,Te.value])),ue=c?[...d,...Yc]:d;for(const Te of LD(ue,f))se.set(Te.key,Te.value);return[...se].map(([Te,qe])=>({key:Te,value:qe}))}async function Ge(){if(!(!u||L||z)){re(null),Y(!0);try{await u(!c)}catch(se){he.current&&re(`更新飞书配置失败:${se instanceof Error?se.message:String(se)}`)}finally{he.current&&Y(!1)}}}async function Bt(){var ue;if(!i||L||k)return;if(Xe!=="public"&&!((ue=p==null?void 0:p.vpcId)!=null&&ue.trim())){re("使用 VPC 网络时,请填写 VPC ID。");return}const se=iN(d,f);if(se){const Te=d.find(qe=>qe.key===se.key);re(`请返回配置页填写 ${(Te==null?void 0:Te.comment)||(Te==null?void 0:Te.key)}(${Te==null?void 0:Te.key})。`);return}if(c){const Te=iN(Yc,f);if(Te){const qe=Yc.find($e=>$e.key===Te.key);re(`启用飞书后,请填写${(qe==null?void 0:qe.comment)||(qe==null?void 0:qe.key)}。`);return}}R(!0)}async function Nn(){if(!i||L)return;R(!1);const se=Le();he.current&&(re(null),ee(null),X({}),Z(null),O(!0));const ue=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;let Te="生成中…";const qe=Date.now();o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"running",label:"准备部署"});try{const $e=await i(e,Ie=>{var lt;Ie.runtimeName&&(Te=Ie.runtimeName),he.current&&(X(Nt=>({...Nt,[Ie.phase]:Ie})),Z(Ie.phase)),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"running",label:((lt=N.find(Nt=>Nt.phase===Ie.phase))==null?void 0:lt.label)??Ie.phase,message:Ie.message,pct:Ie.pct})},c?{taskId:ue,im:{feishu:{enabled:!0}},envs:se}:{taskId:ue,envs:se});he.current&&(ee($e),Z(null)),o==null||o({id:ue,runtimeName:$e.agentName||Te,runtimeId:$e.runtimeId,region:$e.region||g,startedAt:qe,status:"success",label:"部署完成"})}catch($e){const Ie=$e instanceof Error?$e.message:String($e);if($e instanceof DOMException&&$e.name==="AbortError"){he.current&&(re(null),Z(null)),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。"});return}he.current&&re(Ie),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"error",label:"部署失败",message:Ie,retry:Bt})}finally{he.current&&O(!1)}}function nn(){R(!1)}async function Ft(){if(!(!V||de)){ye(!0),re(null);try{const{addConnection:se,addRuntimeConnection:ue,remoteAppId:Te,loadConnections:qe}=await Al(async()=>{const{addConnection:lt,addRuntimeConnection:Nt,remoteAppId:Kn,loadConnections:sn}=await Promise.resolve().then(()=>$S);return{addConnection:lt,addRuntimeConnection:Nt,remoteAppId:Kn,loadConnections:sn}},void 0),{probeRuntimeApps:$e}=await Al(async()=>{const{probeRuntimeApps:lt}=await Promise.resolve().then(()=>i$);return{probeRuntimeApps:lt}},void 0);let Ie;if(V.runtimeId){const lt=V.region??"cn-beijing",Nt=await $e(V.runtimeId,lt)??[];Ie=ue(V.runtimeId,V.agentName,lt,Nt,Nt.length>0?{[Nt[0]]:V.agentName}:void 0)}else Ie=await se(V.agentName,V.url,V.apikey,"");if(Ie.apps.length===0)re("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const lt={[Ie.apps[0]]:V.agentName},Nt={...Ie,appLabels:{...Ie.appLabels??{},...lt}},sn=qe().map(Mt=>Mt.id===Ie.id?Nt:Mt);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(sn));const{registerConnections:Pn}=await Al(async()=>{const{registerConnections:Mt}=await Promise.resolve().then(()=>$S);return{registerConnections:Mt}},void 0);if(Pn(sn),a){const Mt=Te(Ie.id,Ie.apps[0]);a(Mt,V.agentName)}else alert(`🎉 Agent "${V.agentName}" 已添加到左上角下拉列表!`)}}catch(se){re(`添加 Agent 失败:${se instanceof Error?se.message:String(se)}`)}finally{ye(!1)}}}function Ut(){const se=Ire(e.files),ue=URL.createObjectURL(se),Te=document.createElement("a");Te.href=ue,Te.download=`${e.name||"project"}.zip`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(ue)}function wn(se,ue,Te){return Vre(se).map(qe=>{const $e=Te?`${Te}/${qe.name}`:qe.name,Ie=qe.path!==void 0,lt={paddingLeft:8+ue*14};if(Ie){const Kn=qe.path===S;return l.jsxs("button",{type:"button",className:`pp-row pp-file${Kn?" pp-active":""}`,style:lt,onClick:()=>C(qe.path),title:qe.path,children:[l.jsx(d7,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:qe.name})]},$e)}const Nt=M.has($e);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"pp-row pp-folder",style:lt,onClick:()=>Sn($e),children:[l.jsx(Nr,{className:`pp-ic pp-chevron${Nt?"":" pp-open"}`}),l.jsx(jR,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:qe.name})]}),!Nt&&wn(qe,ue+1,$e)]},$e)})}return l.jsxs("div",{className:`pp-root${i?" is-deploy":""}${_?" has-primary-pane":""}`,children:[i&&l.jsx(Yre,{left:l.jsxs("div",{className:"pp-toolbar-left",children:[y&&l.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:y,children:[l.jsx(CR,{className:"pp-ic"}),E]}),l.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",n||e.name||"未命名 Agent",r&&r>1?` 等 ${r} 个智能体`:""]})]}),right:null}),l.jsxs("div",{className:"pp-body",children:[i&&!_&&l.jsxs("section",{className:"pp-topology-pane","aria-label":"Agent 拓扑",children:[l.jsxs("div",{className:"pp-topology-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"pp-topology-title",children:"Agent 拓扑"}),l.jsxs("div",{className:"pp-topology-count",children:[r??1," 个智能体"]})]}),A&&s&&l.jsx(Mre,{project:e,onChange:s})]}),l.jsxs("div",{className:"pp-topology-scroll",children:[l.jsx("div",{className:"pp-topology-tree",children:l.jsx(PD,{agent:Et,depth:0,inspectedId:mt,onHover:je,onFocus:ut})}),W&&J&&ce&&l.jsxs("div",{className:"pp-agent-inspector","aria-live":"polite",children:[l.jsxs("div",{className:"pp-agent-inspector-head",children:[l.jsx("span",{className:"pp-agent-inspector-icon",children:l.jsx(ce,{"aria-hidden":"true"})}),l.jsxs("div",{children:[l.jsx("strong",{children:W.name}),l.jsx("span",{children:J.label})]})]}),W.description&&l.jsx("p",{children:W.description}),l.jsxs("dl",{className:"pp-agent-config-grid",children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:W.model}),l.jsx("dt",{children:"工具"}),l.jsx("dd",{children:W.tools}),l.jsx("dt",{children:"技能"}),l.jsx("dd",{children:W.skills}),l.jsx("dt",{children:"知识库"}),l.jsx("dd",{children:W.knowledgebase}),l.jsx("dt",{children:"短期记忆"}),l.jsx("dd",{children:W.shortTerm}),l.jsx("dt",{children:"长期记忆"}),l.jsx("dd",{children:W.longTerm}),l.jsx("dt",{children:"观测"}),l.jsx("dd",{children:W.tracing})]})]})]}),l.jsxs("div",{className:"pp-topology-actions",children:[b&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:b,children:[l.jsx(l7,{className:"pp-ic"}),"导出配置"]}),e.files.length>0&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:Ut,children:[l.jsx(xx,{className:"pp-ic"}),"下载源码"]})]})]}),l.jsxs("div",{className:"pp-files-area",children:[l.jsxs("div",{className:"pp-sidebar",children:[l.jsxs("div",{className:"pp-sidebar-head",children:[l.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),A&&l.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{P(!0),I("")},children:l.jsx(c7,{className:"pp-ic"})})]}),l.jsxs("div",{className:"pp-tree",children:[q&&l.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:D,onChange:se=>I(se.target.value),onBlur:vt,onKeyDown:se=>{se.key==="Enter"&&vt(),se.key==="Escape"&&(P(!1),I(""))}}),e.files.length===0&&!q?l.jsx("div",{className:"pp-empty",children:"暂无文件"}):wn(ke,0,"")]})]}),l.jsxs("div",{className:"pp-main",children:[l.jsxs("div",{className:"pp-main-head",children:[l.jsx("span",{className:"pp-path",title:pe==null?void 0:pe.path,children:(pe==null?void 0:pe.path)??"未选择文件"}),l.jsx("div",{className:"pp-actions",children:A&&pe&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Ct,children:l.jsx(C7,{className:"pp-ic"})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Gt,children:l.jsx(mc,{className:"pp-ic"})})]})})]}),l.jsx("div",{className:"pp-content",children:pe==null?l.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):A?l.jsx("div",{className:"pp-codemirror",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:l.jsx(Dre,{value:pe.content,path:pe.path,onChange:wt})})}):l.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:Fre(pe.content,pe.path)}})})]})]}),i&&l.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[l.jsx("div",{className:"pp-config-head",children:l.jsx("div",{className:"pp-config-title",children:"部署配置"})}),l.jsxs("div",{className:"pp-config-scroll",children:[_,!_&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"发布区域"}),l.jsxs("select",{className:"pp-config-select",value:g,onChange:se=>x==null?void 0:x(se.target.value),"aria-label":"部署区域",disabled:L||!x,children:[l.jsx("option",{value:"cn-beijing",children:"华北 2(北京)"}),l.jsx("option",{value:"cn-shanghai",children:"华东 2(上海)"})]})]}),!_&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"消息渠道"}),l.jsxs("button",{type:"button",role:"switch","aria-checked":c,className:`pp-channel${c?" is-on":""}`,onClick:()=>void Ge(),disabled:L||z||!u,children:[l.jsx("span",{className:"pp-channel-title",children:z?"飞书(正在更新代码…)":"飞书"}),l.jsx("span",{className:"pp-switch","aria-hidden":!0,children:l.jsx("span",{})})]}),c&&l.jsx("div",{className:"pp-channel-fields",children:Yc.map(se=>l.jsxs("label",{children:[l.jsxs("span",{children:[se.comment||se.key,se.required&&l.jsx("small",{children:"必填"})]}),l.jsx("code",{children:se.key}),l.jsx("input",{type:se.key.includes("SECRET")?"password":"text",value:f[se.key]??"",placeholder:se.placeholder,disabled:L||!h,autoComplete:"off",onChange:ue=>h==null?void 0:h(se.key,ue.currentTarget.value)})]},se.key))})]}),l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"网络"}),_&&l.jsxs("div",{className:"pp-network-region",onKeyDown:se=>{se.key==="Escape"&&we(!1)},children:[l.jsx("span",{children:"发布区域"}),l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":Pe,disabled:L||!x,onClick:()=>we(se=>!se),children:[l.jsx("span",{children:g==="cn-shanghai"?"华东 2(上海)":"华北 2(北京)"}),l.jsx(od,{className:`pp-region-chevron${Pe?" is-open":""}`})]}),Pe&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>we(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}].map(se=>{const ue=se.value===g;return l.jsxs("button",{type:"button",role:"option","aria-selected":ue,className:`pp-region-option${ue?" is-selected":""}`,onClick:()=>{x==null||x(se.value),we(!1)},children:[l.jsx("span",{children:se.label}),ue&&l.jsx(Bs,{"aria-hidden":"true"})]},se.value)})})]})]}),l.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(se=>l.jsx("button",{type:"button",role:"radio","aria-checked":Xe===se,className:Xe===se?"is-on":"",onClick:()=>kt(se),disabled:L||!m,children:se==="public"?"公网":se==="private"?"VPC":"公网 + VPC"},se))}),Xe!=="public"&&l.jsxs("div",{className:"pp-network-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"VPC ID"}),l.jsx("input",{value:(p==null?void 0:p.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:L,onChange:se=>le({vpcId:se.target.value})})]}),l.jsxs("label",{children:[l.jsxs("span",{children:["子网 ID ",l.jsx("small",{children:"可选,多个用逗号分隔"})]}),l.jsx("input",{value:(p==null?void 0:p.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:L,onChange:se=>le({subnetIds:se.target.value})})]}),l.jsxs("label",{className:"pp-network-check",children:[l.jsx("input",{type:"checkbox",checked:!!(p!=null&&p.enableSharedInternetAccess),disabled:L,onChange:se=>le({enableSharedInternetAccess:se.target.checked})}),"VPC 内共享公网出口"]})]})]}),l.jsxs("section",{className:"pp-config-section pp-env-section",children:[l.jsxs("div",{className:"pp-env-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"pp-config-label",children:["环境变量",l.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[We," 项"]})]}),l.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]}),l.jsx("button",{type:"button",className:"pp-icon-btn",title:be?"隐藏值":"显示值",onClick:()=>_e(se=>!se),children:be?l.jsx(a7,{className:"pp-ic"}):l.jsx(MR,{className:"pp-ic"})})]}),l.jsxs("button",{type:"button",className:"pp-env-add",onClick:_t,disabled:L,children:[l.jsx(Ps,{className:"pp-ic"}),"添加变量"]}),(St.length>0||Q.length>0)&&l.jsxs("div",{className:"pp-env-table",children:[St.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"组件自动生成"}),l.jsxs("small",{children:[St.length," 项"]})]}),St.map(se=>{const ue=se.key.startsWith("ENABLE_");return l.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[l.jsx("input",{className:"pp-env-key-fixed",value:se.key,readOnly:!0,disabled:L,"aria-label":`${se.key} 环境变量名`}),l.jsx("input",{type:ue||be?"text":"password",value:se.value,placeholder:se.required?"必填,尚未填写":"可选,尚未填写",readOnly:ue,disabled:L||!ue&&!h,autoComplete:"off","aria-label":`${se.key} 环境变量值`,onChange:Te=>h==null?void 0:h(se.key,Te.currentTarget.value)}),l.jsx("span",{className:"pp-env-source",children:ue?"自动":"同步"})]},se.key)})]}),Q.length>0&&l.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[l.jsx("span",{children:"自定义变量"}),l.jsxs("small",{children:[Q.length," 项"]})]}),Q.map(se=>l.jsxs("div",{className:"pp-env-row",children:[l.jsx("input",{value:se.key,placeholder:"名称",disabled:L,autoComplete:"off",onChange:ue=>Ve(se.id,{key:ue.currentTarget.value})}),l.jsx("input",{type:be?"text":"password",value:se.value,placeholder:"值",disabled:L,autoComplete:"off",onChange:ue=>Ve(se.id,{value:ue.currentTarget.value})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:L,onClick:()=>ot(se.id),children:l.jsx(Wr,{className:"pp-ic"})})]},se.id))]})]}),(L||V||Object.keys(oe).length>0)&&l.jsxs("section",{className:"pp-config-section pp-progress-section",children:[l.jsx("div",{className:"pp-config-label",children:"部署进度"}),l.jsx("ol",{className:"pp-steps",children:N.map((se,ue)=>{const Te=ae?N.findIndex(lt=>lt.phase===ae):-1,qe=!!j&&(Te===-1?ue===0:ue===Te);let $e;V?$e="done":qe?$e="failed":Te===-1?$e=L?"active":"pending":uese.phase===ae))==null?void 0:fn.label)??ae}阶段):`:""}${j}`,onRetry:Bt}),V&&l.jsxs("section",{className:"pp-deploy-result",children:[l.jsx("div",{className:"pp-deploy-result-header",children:"部署成功"}),l.jsxs("div",{className:"pp-deploy-result-body",children:[V.region&&l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"区域"}),l.jsx("code",{children:V.region==="cn-shanghai"?"上海 (cn-shanghai)":"北京 (cn-beijing)"})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Agent 名称"}),l.jsx("code",{children:V.agentName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"API 端点"}),l.jsx("code",{className:"pp-deploy-result-url",children:V.url})]})]}),l.jsxs("div",{className:"pp-deploy-result-actions",children:[l.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Ft,disabled:de,children:[de?l.jsx(bt,{className:"pp-ic spin"}):l.jsx(UR,{className:"pp-ic"}),de?"连接中…":"立即对话"]}),V.consoleUrl&&l.jsxs("a",{href:V.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[l.jsx(wx,{className:"pp-ic"}),"控制台"]})]})]})]}),l.jsxs("div",{className:"pp-config-actions",children:[k&&T&&l.jsx("span",{className:"pp-deploy-hint",children:T}),l.jsx("button",{type:"button",className:"pp-deploy",onClick:Bt,disabled:L||z||k,title:k?T:void 0,children:L?"部署中…":j?"重试部署":"部署"})]})]})]}),l.jsx(Pre,{open:B,onCancel:nn,onConfirm:()=>void Nn()})]})}const uN="dogfooding",ny="dogfooding",ry="dogfooding_b";let Wre=0;const sy=()=>++Wre;function dN(e){return e.blocks.filter(t=>t.kind==="text").map(t=>t.text).join("")}function qre(e){const t=e.trim(),n=t.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i);return(n?n[1]:t).trim()}async function fN(e){const t=[],n=qre(e);t.push(n);const r=n.indexOf("{"),s=n.lastIndexOf("}");r>=0&&s>r&&t.push(n.slice(r,s+1));for(const i of t)try{const a=JSON.parse(i);if(a&&typeof a=="object"&&(typeof a.name=="string"||typeof a.instruction=="string"))return await Bp(AD(a))}catch{}return null}function Gre({userId:e,onBack:t,onCreate:n,onAgentAdded:r,onDeploymentTaskChange:s}){const[i,a]=v.useState([{id:sy(),role:"assistant",text:"你好,我是 VeADK 的智能构建助手。用自然语言描述你想要的 Agent,我会直接帮你生成一个可运行的 VeADK 项目,并在右侧实时预览。"}]),[o,c]=v.useState(""),[u,d]=v.useState(!1),[f,h]=v.useState(null),[p,m]=v.useState(null),[g,x]=v.useState(!1),[y,E]=v.useState(null),[b,_]=v.useState(null),[k,T]=v.useState(!1),[A,N]=v.useState(!1),[S,C]=v.useState({}),M=v.useRef(null),U=v.useRef(null),q=v.useRef(null),P=v.useRef(null),D=v.useRef(null);v.useEffect(()=>{const V=P.current;V&&V.scrollTo({top:V.scrollHeight,behavior:"smooth"})},[i,u]),v.useEffect(()=>{const V=D.current;V&&(V.style.height="auto",V.style.height=Math.min(V.scrollHeight,160)+"px")},[o]);const I=V=>a(ee=>[...ee,{id:sy(),role:"assistant",text:V}]);async function L(){if(M.current)return M.current;const V=await Pp(uN,e);return M.current=V,V}async function O(V,ee){if(ee.current)return ee.current;const oe=await Pp(V,e);return ee.current=oe,oe}async function B(V,ee){if(!S[V])try{const oe=await Rx(ee);C(X=>({...X,[V]:oe.model||ee}))}catch{C(oe=>({...oe,[V]:ee}))}}async function R(V,ee,oe){const X=await O(V,ee);let ae=Ns();for await(const de of cd({appName:V,userId:e,sessionId:X,text:oe}))ae=zl(ae,de);const Z=dN(ae).trim();return{project:await fN(Z),finalText:Z}}const z=async(V,ee,oe)=>Um(V.name,V.files,{region:"cn-beijing",projectName:"default"},{...oe,onStage:ee}),Y=async()=>{const V=o.trim();if(!(!V||u)){if(a(ee=>[...ee,{id:sy(),role:"user",text:V}]),c(""),h(null),d(!0),g){E(null),_(null),T(!0),N(!0),B("a",ny),B("b",ry);const ee=R(ny,U,V).then(({project:X})=>(E(X),X)).catch(X=>{const ae=X instanceof Error?X.message:String(X);return h(ae),null}).finally(()=>T(!1)),oe=R(ry,q,V).then(({project:X})=>(_(X),X)).catch(X=>{const ae=X instanceof Error?X.message:String(X);return h(ae),null}).finally(()=>N(!1));try{const[X,ae]=await Promise.all([ee,oe]),Z=[X?`方案 A:${X.name}`:null,ae?`方案 B:${ae.name}`:null].filter(Boolean);Z.length?I(`已生成两个方案(${Z.join(",")}),请在右侧对比后采用其一。`):I("(两个方案都没有返回可用的项目,请再描述一下你的需求。)")}finally{d(!1)}return}try{const ee=await L();let oe=Ns();for await(const Z of cd({appName:uN,userId:e,sessionId:ee,text:V}))oe=zl(oe,Z);const X=dN(oe).trim(),ae=await fN(X);ae?(m(ae),I(`已生成项目:${ae.name}(${ae.files.length} 个文件),可在右侧预览和编辑。`)):I(X||"(助手没有返回内容,请再描述一下你的需求。)")}catch(ee){const oe=ee instanceof Error?ee.message:String(ee);h(oe),I(`抱歉,调用智能构建助手失败:${oe}`)}finally{d(!1)}}},j=V=>{const ee=V==="a"?y:b;if(!ee)return;m(ee),x(!1),E(null),_(null),T(!1),N(!1);const oe=V==="a"?"A":"B",X=V==="a"?S.a:S.b;I(`已采用方案 ${oe}(${X??(V==="a"?ny:ry)}),可继续编辑。`)},re=V=>{V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),Y())};return l.jsx("div",{className:"ic-root",children:l.jsxs("div",{className:"ic-body",children:[l.jsxs("div",{className:"ic-chat",children:[l.jsxs("div",{className:"ic-transcript",ref:P,children:[l.jsx(Js,{initial:!1,children:i.map(V=>l.jsxs(Rt.div,{className:`ic-turn ic-turn--${V.role}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.22,ease:"easeOut"},children:[V.role==="assistant"&&l.jsx("div",{className:"ic-avatar",children:l.jsx(Hl,{className:"ic-avatar-icon"})}),l.jsx("div",{className:"ic-bubble",children:V.role==="assistant"?l.jsx(Gd,{text:V.text}):V.text})]},V.id))}),u&&l.jsxs(Rt.div,{className:"ic-turn ic-turn--assistant",initial:{opacity:0,y:8},animate:{opacity:1,y:0},children:[l.jsx("div",{className:"ic-avatar",children:l.jsx(Hl,{className:"ic-avatar-icon"})}),l.jsxs("div",{className:"ic-bubble ic-bubble--typing",children:[l.jsx("span",{className:"ic-dot"}),l.jsx("span",{className:"ic-dot"}),l.jsx("span",{className:"ic-dot"})]})]})]}),f&&l.jsxs("div",{className:"ic-error",children:[l.jsx(yx,{className:"ic-error-icon"}),f]}),l.jsxs("div",{className:"ic-composer",children:[l.jsxs("div",{className:"ic-composer-box",children:[l.jsx("textarea",{ref:D,className:"ic-input",rows:1,placeholder:"描述你想要的 Agent,例如「一个帮我整理周报的写作助手」…",value:o,onChange:V=>c(V.target.value),onKeyDown:re,disabled:u}),l.jsx("button",{className:"ic-send",onClick:()=>void Y(),disabled:!o.trim()||u,title:"发送 (Enter)",children:l.jsx(O7,{className:"ic-send-icon"})})]}),l.jsxs("div",{className:"ic-composer-foot",children:[l.jsxs("label",{className:"ic-ab-toggle",title:"同时用两个模型生成方案进行对比",children:[l.jsx("input",{type:"checkbox",className:"ic-ab-checkbox",checked:g,disabled:u,onChange:V=>x(V.target.checked)}),l.jsx("span",{className:"ic-ab-track",children:l.jsx("span",{className:"ic-ab-thumb"})}),l.jsx("span",{className:"ic-ab-label",children:"A/B 对比"})]}),l.jsx("div",{className:"ic-composer-hint",children:"Enter 发送 · Shift+Enter 换行"})]})]})]}),l.jsx("aside",{className:"ic-preview",children:g?l.jsxs("div",{className:"ic-compare",children:[l.jsx(hN,{side:"a",project:y,loading:k,model:S.a,onAdopt:()=>j("a")}),l.jsx("div",{className:"ic-compare-divider"}),l.jsx(hN,{side:"b",project:b,loading:A,model:S.b,onAdopt:()=>j("b")})]}):p?l.jsx(lg,{project:p,onChange:m,onDeploy:z,onAgentAdded:r,onDeploymentTaskChange:s}):l.jsxs("div",{className:"ic-preview-empty",children:[l.jsxs("div",{className:"ic-preview-empty-icon",children:[l.jsx(f7,{className:"ic-preview-empty-glyph"}),l.jsx(ho,{className:"ic-preview-empty-spark"})]}),l.jsx("div",{className:"ic-preview-empty-title",children:"还没有项目"}),l.jsx("div",{className:"ic-preview-empty-sub",children:"描述你的需求,我会帮你生成 VeADK 项目"})]})})]})})}function hN({side:e,project:t,loading:n,model:r,onAdopt:s}){const i=e==="a"?"方案 A":"方案 B";return l.jsxs("div",{className:"ic-pane",children:[l.jsxs("div",{className:"ic-pane-head",children:[l.jsxs("div",{className:"ic-pane-title",children:[l.jsx("span",{className:`ic-pane-tag ic-pane-tag--${e}`,children:i}),r&&l.jsx("span",{className:"ic-pane-model",children:r})]}),l.jsxs("button",{className:"ic-adopt",onClick:s,disabled:!t||n,title:`采用${i}`,children:["采用",e==="a"?"方案 A":"方案 B"]})]}),l.jsx("div",{className:"ic-pane-body",children:n?l.jsxs("div",{className:"ic-pane-loading",children:[l.jsx(bt,{className:"ic-pane-spinner"}),l.jsx("span",{children:"正在生成…"})]}):t?l.jsx(lg,{project:t}):l.jsx("div",{className:"ic-pane-empty",children:"该方案未返回可用项目"})})]})}const Xre=/^[A-Za-z_][A-Za-z0-9_]*$/;function Cl(e){return e.trim().length===0?"名称为必填项":e==="user"?"user 是 Google ADK 保留名称,请使用其他名称":Xre.test(e)?null:"名称须以英文字母或下划线开头,且只能包含英文字母、数字和下划线"}function jD(e){const t=new Set,n=new Set,r=s=>{Cl(s.name)===null&&(t.has(s.name)?n.add(s.name):t.add(s.name)),s.subAgents.forEach(r)};return r(e),n}function hs(e){return e.trimEnd().replace(/[。.]+$/,"")}function rm(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(r=>r==null?void 0:r.toLocaleLowerCase().includes(n)):!0}function Da(e,t){return e[t]|e[t+1]<<8}function $o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}async function Qre(e){const t=new DecompressionStream("deflate-raw"),n=new Blob([new Uint8Array(e)]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}async function BD(e,t={}){let r=-1;for(let u=e.length-22;u>=0&&u>e.length-65557;u--)if($o(e,u)===101010256){r=u;break}if(r<0)throw new Error("无效的 zip:找不到 EOCD");const s=Da(e,r+10);if(t.maxEntries!==void 0&&s>t.maxEntries)throw new Error(`zip 文件数不能超过 ${t.maxEntries} 个`);let i=$o(e,r+16);const a=new TextDecoder("utf-8"),o=[];let c=0;for(let u=0;ut.maxUncompressedBytes)throw new Error("zip 解压后的内容过大");const E=Da(e,x+26),b=Da(e,x+28),_=x+30+E+b,k=e.subarray(_,_+f);let T;if(d===0)T=k;else if(d===8)T=await Qre(k);else{i+=46+p+m+g;continue}o.push({name:y,text:a.decode(T)}),i+=46+p+m+g}return o}const Zre="/skillhub/v1/skills";async function Jre(e,t="public"){const n=e.trim(),r=`${Zre}?query=${encodeURIComponent(n)}&namespace=${encodeURIComponent(t)}`,s=await fetch(r,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(!s.ok)throw new Error(`搜索失败 (${s.status})`);return((await s.json()).Skills??[]).map(a=>{var o;return{source:"skillhub",id:a.Id??a.Slug??"",slug:a.Slug??"",name:a.Name??a.Slug??"",description:((o=a.Metadata)==null?void 0:o.DisplayDescription)||a.Description||"",namespace:a.Namespace??t,sourceRepo:a.SourceRepo,downloadCount:a.DownloadCount}})}function ese({selected:e,onChange:t}){const[n,r]=v.useState(""),[s,i]=v.useState([]),[a,o]=v.useState(!1),[c,u]=v.useState(null),[d,f]=v.useState(!1),h=g=>e.some(x=>x.source==="skillhub"&&x.slug===g),p=g=>{g.slug&&(h(g.slug)?t(e.filter(x=>!(x.source==="skillhub"&&x.slug===g.slug))):t([...e,{source:"skillhub",slug:g.slug,name:g.name,folder:g.slug.split("/").pop()||g.name,namespace:g.namespace||"public",description:g.description}]))},m=async g=>{o(!0),u(null),f(!0);try{const x=await Jre(g);i(x)}catch(x){u(x instanceof Error?x.message:"搜索失败,请稍后重试。"),i([])}finally{o(!1)}};return v.useEffect(()=>{const g=n.trim();if(!g){i([]),f(!1),u(null);return}const x=setTimeout(()=>m(g),300);return()=>clearTimeout(x)},[n]),l.jsxs("div",{className:"cw-skillhub",children:[l.jsxs("div",{className:"cw-skill-searchrow",children:[l.jsxs("div",{className:"cw-skill-searchbox",children:[l.jsx(Hb,{className:"cw-i cw-skill-searchicon","aria-hidden":!0}),l.jsx("input",{className:"cw-input cw-skill-input",value:n,placeholder:"搜索火山 Find Skill 技能广场,例如 数据分析、PDF…",onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),n.trim()&&m(n))}})]}),l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft",onClick:()=>n.trim()&&m(n),disabled:!n.trim()||a,children:[a?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(Hb,{className:"cw-i"}),"搜索"]})]}),c&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:c})]}),a&&s.length===0?l.jsx("p",{className:"cw-empty-line",children:"正在搜索…"}):s.length>0?l.jsx("div",{className:"cw-skill-results",children:s.map(g=>{const x=h(g.slug||"");return l.jsxs("button",{type:"button",className:`cw-skill-result ${x?"is-on":""}`,onClick:()=>p(g),"aria-pressed":x,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:x?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:g.name}),g.description&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(g.description)}),g.sourceRepo&&l.jsx("span",{className:"cw-skill-result-repo",children:g.sourceRepo})]})]},g.id||g.slug)})}):d&&!c?l.jsx("p",{className:"cw-empty-line",children:"没有找到匹配的技能,换个关键词试试。"}):!d&&l.jsx("p",{className:"cw-empty-line",children:"输入关键词搜索火山 Find Skill 技能广场,所选技能会在生成项目时下载到 skills/ 目录。"})]})}const T1=/(^|\/)skill\.md$/i;class ya extends Error{}function tse(e,t){const n=(e??"").replace(/\r\n?/g,` +`+ure(CD(e))}function wre(e){const t=cre(e);return AD(t)}const vre=[{kind:"custom",icon:F7,title:"自定义",desc:"分步配置模型、工具、记忆、知识库等组件。"},{kind:"intelligent",icon:k7,title:"智能模式",desc:"敬请期待",disabled:!0},{kind:"template",icon:b7,title:"从模板新建",desc:"敬请期待",disabled:!0},{kind:"workflow",icon:U7,title:"工作流",desc:"敬请期待",disabled:!0}];function _re({onSelect:e,onImport:t}){const n=v.useRef(null),[r,s]=v.useState(""),i=vre.map(o=>({key:o.kind,icon:o.icon,title:o.title,desc:o.desc,disabled:o.disabled,onClick:()=>e(o.kind)})),a=async o=>{var u;const c=(u=o.target.files)==null?void 0:u[0];if(o.target.value="",!!c)try{const d=await c.text();t(wre(d))}catch(d){s(`导入失败:${d instanceof Error?d.message:String(d)}`)}};return l.jsx(j3,{title:"从 0 快速创建",sub:"选择一种方式开始",cards:i,footer:l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[l.jsxs("button",{className:"stk-import",onClick:()=>{var o;return(o=n.current)==null?void 0:o.click()},children:[l.jsx(j7,{}),"导入 YAML 配置"]}),r&&l.jsx("span",{style:{fontSize:12,color:"hsl(var(--destructive))"},children:r}),l.jsx("input",{ref:n,type:"file",accept:".yaml,.yml,text/yaml",style:{display:"none"},onChange:a})]})})}const kre="modulepreload",Tre=function(e){return"/"+e},sN={},Al=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=Tre(c),c in sN)return;sN[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":kre,u||(f.as="script"),f.crossOrigin="",f.href=c,o&&f.setAttribute("nonce",o),document.head.appendChild(f),u)return new Promise((h,p)=>{f.addEventListener("load",h),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return t().catch(i)})};function Sre({className:e,...t}){return l.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:[l.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"}),l.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 qo={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:Sre},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:h7},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:D7},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:HR},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:_x}},ah=[qo.llm,qo.sequential,qo.parallel,qo.loop,qo.a2a];function Iw(e){return qo[e??"llm"]}const ID=e=>e==="sequential"||e==="parallel"||e==="loop",nf=e=>e==="a2a";function RD(e){const t=new Map,n={};for(const r of e){for(const s of r.env){const i=t.get(s.key);(!i||s.required&&!i.required)&&t.set(s.key,s)}r.enableFlag&&(t.set(r.enableFlag,{key:r.enableFlag,required:!0}),n[r.enableFlag]="true")}return{specs:[...t.values()],fixedValues:n}}function Nre(e,t){return RD([{env:e}]).specs.map(r=>({...r,value:t[r.key]??""}))}function LD(e,t){const n=new Map;for(const r of e){const s=t[r.key]??"";s.trim()&&n.set(r.key,s)}return[...n].map(([r,s])=>({key:r,value:s}))}function iN(e,t){return e.find(n=>{var r;return n.required&&!((r=t[n.key])!=null&&r.trim())})}const Are=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Cre(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function Qt(e,t){e.push(t&255,t>>>8&255)}function jr(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}const aN=2048,ty=20,oN=0;function Ire(e){const t=new TextEncoder,n=[],r=[];let s=0;for(const p of e){const m=t.encode(p.path),g=t.encode(p.content),x=Cre(g),y=g.length,E=[];jr(E,67324752),Qt(E,ty),Qt(E,aN),Qt(E,oN),Qt(E,0),Qt(E,0),jr(E,x),jr(E,y),jr(E,y),Qt(E,m.length),Qt(E,0);const b=Uint8Array.from(E);n.push(b,m,g),r.push({nameBytes:m,dataBytes:g,crc:x,size:y,offset:s}),s+=b.length+m.length+g.length}const i=s,a=[];let o=0;for(const p of r){const m=[];jr(m,33639248),Qt(m,ty),Qt(m,ty),Qt(m,aN),Qt(m,oN),Qt(m,0),Qt(m,0),jr(m,p.crc),jr(m,p.size),jr(m,p.size),Qt(m,p.nameBytes.length),Qt(m,0),Qt(m,0),Qt(m,0),Qt(m,0),jr(m,0),jr(m,p.offset);const g=Uint8Array.from(m);a.push(g,p.nameBytes),o+=g.length+p.nameBytes.length}const c=[];jr(c,101010256),Qt(c,0),Qt(c,0),Qt(c,r.length),Qt(c,r.length),jr(c,o),jr(c,i),Qt(c,0);const u=[...n,...a,Uint8Array.from(c)],d=u.reduce((p,m)=>p+m.length,0),f=new Uint8Array(d);let h=0;for(const p of u)f.set(p,h),h+=p.length;return new Blob([f],{type:"application/zip"})}const Rre=v.lazy(()=>Al(()=>import("./CodeEditor-DCfiHETz.js"),[]));function Lre(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let s=t;r.forEach((i,a)=>{let o=s.children.get(i);o||(o={name:i,children:new Map},s.children.set(i,o)),a===r.length-1&&(o.path=n.path),s=o})}return t}function Ore(e){return[...e.children.values()].sort((t,n)=>{const r=t.children.size>0&&t.path===void 0,s=n.children.size>0&&n.path===void 0;return r!==s?r?-1:1:t.name.localeCompare(n.name)})}function OD({project:e,open:t,onClose:n,onChange:r}){var m;const[s,i]=v.useState(((m=e.files[0])==null?void 0:m.path)??null),[a,o]=v.useState(new Set),c=v.useRef(null),u=v.useMemo(()=>Lre(e.files),[e.files]),d=e.files.find(g=>g.path===s)??null;if(v.useEffect(()=>{var y;if(!t)return;const g=document.body.style.overflow;document.body.style.overflow="hidden",(y=c.current)==null||y.focus();const x=E=>{E.key==="Escape"&&n()};return window.addEventListener("keydown",x),()=>{document.body.style.overflow=g,window.removeEventListener("keydown",x)}},[n,t]),v.useEffect(()=>{d||e.files.length===0||i(e.files[0].path)},[e.files,d]),!t)return null;function f(g){o(x=>{const y=new Set(x);return y.has(g)?y.delete(g):y.add(g),y})}function h(g,x,y){return Ore(g).map(E=>{const b=y?`${y}/${E.name}`:E.name;if(!(E.children.size>0&&E.path===void 0)&&E.path)return l.jsxs("button",{type:"button",className:`code-browser-file${s===E.path?" is-active":""}`,style:{paddingLeft:`${12+x*16}px`},onClick:()=>i(E.path??null),title:E.path,children:[l.jsx(zk,{"aria-hidden":"true"}),l.jsx("span",{children:E.name})]},b);const k=a.has(b);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+x*16}px`},onClick:()=>f(b),"aria-expanded":!k,children:[l.jsx(Nr,{className:k?"":"is-open","aria-hidden":"true"}),l.jsx(jR,{"aria-hidden":"true"}),l.jsx("span",{children:E.name})]}),!k&&h(E,x+1,b)]},b)})}function p(g){d&&r({...e,files:e.files.map(x=>x.path===d.path?{...x,content:g}:x)})}return ai.createPortal(l.jsx("div",{className:"code-browser-backdrop",onMouseDown:g=>{g.target===g.currentTarget&&n()},children:l.jsxs("section",{className:"code-browser-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"code-browser-title",children:[l.jsxs("header",{className:"code-browser-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon","aria-hidden":"true",children:l.jsx(bx,{})}),l.jsxs("div",{children:[l.jsx("h2",{id:"code-browser-title",children:"项目代码"}),l.jsx("p",{children:e.name||"Agent 项目"})]})]}),l.jsx("button",{ref:c,type:"button",className:"code-browser-close",onClick:n,"aria-label":"关闭代码浏览器",children:l.jsx(Wr,{"aria-hidden":"true"})})]}),l.jsxs("div",{className:"code-browser-workspace",children:[l.jsxs("aside",{className:"code-browser-sidebar","aria-label":"项目文件",children:[l.jsxs("div",{className:"code-browser-sidebar-head",children:["文件 ",l.jsx("span",{children:e.files.length})]}),l.jsx("div",{className:"code-browser-tree",children:e.files.length>0?h(u,0,""):l.jsx("div",{className:"code-browser-empty",children:"暂无项目文件"})})]}),l.jsxs("main",{className:"code-browser-main",children:[l.jsxs("div",{className:"code-browser-path",children:[l.jsx(zk,{"aria-hidden":"true"}),l.jsx("span",{children:(d==null?void 0:d.path)??"未选择文件"})]}),l.jsx("div",{className:"code-browser-editor",children:d?l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:l.jsx(Rre,{value:d.content,path:d.path,onChange:p})}):l.jsx("div",{className:"code-browser-empty",children:"从左侧选择文件以查看代码"})})]})]})]})}),document.body)}function Mre({project:e,onChange:t,className:n=""}){const[r,s]=v.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:"查看源码",children:[l.jsx(bx,{"aria-hidden":"true"}),l.jsx("span",{children:"查看源码"})]}),l.jsx(OD,{project:e,open:r,onClose:()=>s(!1),onChange:t})]})}function nm({message:e,className:t="",onRetry:n}){const[r,s]=v.useState(!1),[i,a]=v.useState(!1),[o,c]=v.useState(!1),u=async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)}catch{a(!1)}},d=async()=>{if(!(!n||o)){c(!0);try{await n()}finally{c(!1)}}};return l.jsxs("div",{className:`deploy-error-message${r?" is-expanded":""}${t?` ${t}`:""}`,children:[l.jsx("p",{className:"deploy-error-message-text",children:e}),l.jsxs("div",{className:"deploy-error-message-actions",children:[n&&l.jsxs("button",{type:"button",className:"deploy-error-retry",disabled:o,onClick:()=>void d(),children:[o?l.jsx(bt,{className:"spin"}):l.jsx(L7,{}),o?"重试中…":"重试部署"]}),l.jsx("button",{type:"button",title:r?"收起错误信息":"展开完整错误信息","aria-label":r?"收起错误信息":"展开完整错误信息",onClick:()=>s(f=>!f),children:r?l.jsx(S7,{}):l.jsx(_u,{})}),l.jsx("button",{type:"button",title:i?"已复制":"复制完整错误信息","aria-label":i?"已复制":"复制完整错误信息",onClick:()=>void u(),children:i?l.jsx(Bs,{}):l.jsx(Ex,{})})]})]})}Lr.registerLanguage("python",JO);Lr.registerLanguage("typescript",dM);Lr.registerLanguage("javascript",WO);Lr.registerLanguage("json",qO);Lr.registerLanguage("yaml",fM);Lr.registerLanguage("markdown",ZO);Lr.registerLanguage("bash",$O);Lr.registerLanguage("ini",HO);Lr.registerLanguage("dockerfile",Sq);Lr.registerLanguage("makefile",QO);const Dre=v.lazy(()=>Al(()=>import("./CodeEditor-DCfiHETz.js"),[]));function Pre({open:e,onCancel:t,onConfirm:n}){const r=v.useRef(null);return v.useEffect(()=>{var a;if(!e)return;const s=document.body.style.overflow;document.body.style.overflow="hidden",(a=r.current)==null||a.focus();const i=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>{document.body.style.overflow=s,window.removeEventListener("keydown",i)}},[t,e]),e?ai.createPortal(l.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:s=>{s.target===s.currentTarget&&t()},children:l.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:[l.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[l.jsxs("div",{className:"code-browser-title-wrap",children:[l.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:l.jsx(P7,{})}),l.jsx("h2",{id:"pp-confirm-title",children:"确认部署"})]}),l.jsx("button",{type:"button",className:"code-browser-close",onClick:t,"aria-label":"关闭部署确认",children:l.jsx(Wr,{"aria-hidden":"true"})})]}),l.jsx("div",{className:"pp-confirm-body",children:l.jsx("p",{id:"pp-confirm-description",children:"部署后暂不支持修改 Agent 配置,确定部署吗?"})}),l.jsxs("footer",{className:"pp-confirm-actions",children:[l.jsx("button",{ref:r,type:"button",onClick:t,children:"取消"}),l.jsx("button",{type:"button",className:"is-primary",onClick:n,children:"确定部署"})]})]})}),document.body):null}const jre={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"},lN={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function cN(e){return e.replace(/&/g,"&").replace(//g,">")}function Bre(e){const n=(e.split("/").pop()??e).toLowerCase();if(lN[n])return lN[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const r=n.lastIndexOf(".");if(r===-1)return null;const s=n.slice(r+1);return jre[s]??null}function Fre(e,t){try{const n=Bre(t);return n&&Lr.getLanguage(n)?Lr.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?Lr.highlightAuto(e).value:cN(e)}catch{return cN(e)}}const Ure=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],$re=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}];function Hre(e){return e.trim().replace(/[。.!!]+$/u,"")}function oh(e,t="未配置"){return[...new Set(e.map(r=>r==null?void 0:r.trim()).filter(Boolean))].join("、")||t}function MD(e,t="root"){var a,o,c;const n=e.agentType??"llm",r=[...(e.builtinTools??[]).map(u=>{var d;return((d=zee(u))==null?void 0:d.label)??u}),...(e.customTools??[]).map(u=>u.name),...(e.mcpTools??[]).map(u=>u.name),...e.tools??[]],s=[...(e.selectedSkills??[]).map(u=>u.name),...e.skills??[]],i=e.memory.longTerm?((a=Kee(e.longTermBackend??"local"))==null?void 0:a.label)??e.longTermBackend:void 0;return{id:t,name:e.name.trim()||"未命名 Agent",type:n,description:Hre(e.description),model:n==="llm"?e.modelName||e.model||"默认模型":"不适用",tools:oh(r),skills:oh(s),knowledgebase:e.knowledgebase?oh([((o=Yee(e.knowledgebaseBackend??Ql))==null?void 0:o.label)??e.knowledgebaseBackend??"默认知识库",e.knowledgebaseIndex]):"未配置",shortTerm:e.memory.shortTerm?((c=Vee(e.shortTermBackend??"local"))==null?void 0:c.label)??e.shortTermBackend??"默认后端":"未配置",longTerm:i?`${i}${e.autoSaveSession?" · 自动保存会话":""}`:"未配置",tracing:e.tracing?oh((e.tracingExporters??[]).map(u=>{var d;return((d=Wee(u))==null?void 0:d.label)??u}),"默认观测"):"未配置",children:e.subAgents.map((u,d)=>MD(u,`${t}.${d}`))}}function DD(e,t){if(e.id===t)return e;for(const n of e.children){const r=DD(n,t);if(r)return r}}function PD({agent:e,depth:t,inspectedId:n,onHover:r,onFocus:s}){const i=Iw(e.type),a=i.icon;return l.jsxs("div",{className:"pp-topology-branch",children:[l.jsxs("button",{type:"button",className:`pp-agent-node${e.id===n?" is-inspected":""}`,style:{marginLeft:t*16,width:`calc(100% - ${t*16}px)`},onMouseEnter:()=>r(e.id),onMouseLeave:()=>r(null),onFocus:()=>s(e.id),onBlur:()=>s(null),"aria-label":`查看 ${e.name} 配置`,children:[l.jsx("span",{className:"pp-agent-node-icon",children:l.jsx(a,{"aria-hidden":"true"})}),l.jsxs("span",{className:"pp-agent-node-main",children:[l.jsx("span",{className:"pp-agent-node-name",children:e.name}),l.jsx("span",{className:"pp-agent-node-type",children:i.label})]}),e.children.length>0&&l.jsx("span",{className:"pp-agent-child-count",children:e.children.length})]}),e.children.length>0&&l.jsx("div",{className:"pp-topology-children",children:e.children.map(o=>l.jsx(PD,{agent:o,depth:t+1,inspectedId:n,onHover:r,onFocus:s},o.id))})]})}function zre(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let s=t;r.forEach((i,a)=>{let o=s.children.get(i);o||(o={name:i,children:new Map},s.children.set(i,o)),a===r.length-1&&(o.path=n.path),s=o})}return t}function Vre(e){return[...e.children.values()].sort((t,n)=>{const r=t.children.size>0&&t.path===void 0,s=n.children.size>0&&n.path===void 0;return r!==s?r?-1:1:t.name.localeCompare(n.name)})}function Kre(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function Yre({left:e,right:t}){const[n,r]=v.useState(null);return v.useLayoutEffect(()=>{const s=document.getElementById("veadk-page-header-left"),i=document.getElementById("veadk-page-header-actions");s&&i&&r({left:s,right:i})},[]),n?l.jsxs(l.Fragment,{children:[ai.createPortal(e,n.left),ai.createPortal(t,n.right)]}):l.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function lg({project:e,agentDraft:t,agentName:n,agentCount:r,onChange:s,onDeploy:i,onAgentAdded:a,onDeploymentTaskChange:o,feishuEnabled:c=!1,onFeishuEnabledChange:u,deploymentEnv:d=[],deploymentEnvValues:f={},onDeploymentEnvChange:h,network:p,onNetworkChange:m,deployRegion:g="cn-beijing",onDeployRegionChange:x,onBack:y,backLabel:E="返回配置",onExportYaml:b,deploymentPrimaryPane:_,deployDisabled:k=!1,deployDisabledReason:T}){var dn,rn,fn;const A=typeof s=="function",N=_?$re:Ure,[S,C]=v.useState(((rn=(dn=e==null?void 0:e.files)==null?void 0:dn[0])==null?void 0:rn.path)??null),[M,U]=v.useState(new Set),[q,P]=v.useState(!1),[D,I]=v.useState(""),[L,O]=v.useState(!1),[B,R]=v.useState(!1),[z,Y]=v.useState(!1),[j,re]=v.useState(null),[V,ee]=v.useState(null),[oe,X]=v.useState({}),[ae,Z]=v.useState(null),[de,ye]=v.useState(!1),[Q,ge]=v.useState([]),[be,_e]=v.useState(!1),[Pe,we]=v.useState(!1),[ht,je]=v.useState(null),[Fe,ut]=v.useState(null),he=v.useRef(!0),Et=v.useMemo(()=>t?MD(t):{id:"root",name:n||(e==null?void 0:e.name)||"未命名 Agent",type:"llm",description:"",model:"默认模型",tools:"未配置",skills:"未配置",knowledgebase:"未配置",shortTerm:"未配置",longTerm:"未配置",tracing:"未配置",children:[]},[t,n,e==null?void 0:e.name]),mt=Fe??ht,W=mt?DD(Et,mt):void 0,J=W?Iw(W.type):void 0,ce=J==null?void 0:J.icon;v.useEffect(()=>(he.current=!0,()=>{he.current=!1}),[]);const ke=v.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:zre(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return l.jsx("div",{className:"pp-error",children:"项目数据无效"});const pe=e.files.find(se=>se.path===S)??null,Xe=(p==null?void 0:p.mode)??"public",St=Nre(c?[...d,...Yc]:d,f),We=St.length+Q.length;function Sn(se){U(ue=>{const Te=new Set(ue);return Te.has(se)?Te.delete(se):Te.add(se),Te})}function Me(se,ue){s&&(s({...e,files:se}),ue!==void 0&&C(ue))}function wt(se){pe&&Me(e.files.map(ue=>ue.path===pe.path?{...ue,content:se}:ue))}function vt(){const se=D.trim();if(P(!1),I(""),!!se){if(e.files.some(ue=>ue.path===se)){C(se);return}Me([...e.files,{path:se,content:""}],se)}}function Ct(){if(!pe)return;const se=window.prompt("重命名文件",pe.path),ue=se==null?void 0:se.trim();!ue||ue===pe.path||e.files.some(Te=>Te.path===ue)||Me(e.files.map(Te=>Te.path===pe.path?{...Te,path:ue}:Te),ue)}function Gt(){var ue;if(!pe)return;const se=e.files.filter(Te=>Te.path!==pe.path);Me(se,((ue=se[0])==null?void 0:ue.path)??null)}function Ve(se,ue){ge(Te=>Te.map(qe=>qe.id===se?{...qe,...ue}:qe))}function ot(se){ge(ue=>ue.filter(Te=>Te.id!==se))}function _t(){ge(se=>[...se,Kre()])}function kt(se){m&&m(se==="public"?void 0:{...p??{mode:se},mode:se})}function le(se){m==null||m({...p??{mode:"private"},...se})}function Le(){const se=new Map(Q.map(Te=>({key:Te.key.trim(),value:Te.value})).filter(Te=>Te.key.length>0).map(Te=>[Te.key,Te.value])),ue=c?[...d,...Yc]:d;for(const Te of LD(ue,f))se.set(Te.key,Te.value);return[...se].map(([Te,qe])=>({key:Te,value:qe}))}async function Ge(){if(!(!u||L||z)){re(null),Y(!0);try{await u(!c)}catch(se){he.current&&re(`更新飞书配置失败:${se instanceof Error?se.message:String(se)}`)}finally{he.current&&Y(!1)}}}async function Bt(){var ue;if(!i||L||k)return;if(Xe!=="public"&&!((ue=p==null?void 0:p.vpcId)!=null&&ue.trim())){re("使用 VPC 网络时,请填写 VPC ID。");return}const se=iN(d,f);if(se){const Te=d.find(qe=>qe.key===se.key);re(`请返回配置页填写 ${(Te==null?void 0:Te.comment)||(Te==null?void 0:Te.key)}(${Te==null?void 0:Te.key})。`);return}if(c){const Te=iN(Yc,f);if(Te){const qe=Yc.find($e=>$e.key===Te.key);re(`启用飞书后,请填写${(qe==null?void 0:qe.comment)||(qe==null?void 0:qe.key)}。`);return}}R(!0)}async function Nn(){if(!i||L)return;R(!1);const se=Le();he.current&&(re(null),ee(null),X({}),Z(null),O(!0));const ue=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;let Te="生成中…";const qe=Date.now();o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"running",label:"准备部署"});try{const $e=await i(e,Ie=>{var lt;Ie.runtimeName&&(Te=Ie.runtimeName),he.current&&(X(Nt=>({...Nt,[Ie.phase]:Ie})),Z(Ie.phase)),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"running",label:((lt=N.find(Nt=>Nt.phase===Ie.phase))==null?void 0:lt.label)??Ie.phase,message:Ie.message,pct:Ie.pct})},c?{taskId:ue,im:{feishu:{enabled:!0}},envs:se}:{taskId:ue,envs:se});he.current&&(ee($e),Z(null)),o==null||o({id:ue,runtimeName:$e.agentName||Te,runtimeId:$e.runtimeId,region:$e.region||g,startedAt:qe,status:"success",label:"部署完成"})}catch($e){const Ie=$e instanceof Error?$e.message:String($e);if($e instanceof DOMException&&$e.name==="AbortError"){he.current&&(re(null),Z(null)),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。"});return}he.current&&re(Ie),o==null||o({id:ue,runtimeName:Te,region:g,startedAt:qe,status:"error",label:"部署失败",message:Ie,retry:Bt})}finally{he.current&&O(!1)}}function nn(){R(!1)}async function Ft(){if(!(!V||de)){ye(!0),re(null);try{const{addConnection:se,addRuntimeConnection:ue,remoteAppId:Te,loadConnections:qe}=await Al(async()=>{const{addConnection:lt,addRuntimeConnection:Nt,remoteAppId:Kn,loadConnections:sn}=await Promise.resolve().then(()=>$S);return{addConnection:lt,addRuntimeConnection:Nt,remoteAppId:Kn,loadConnections:sn}},void 0),{probeRuntimeApps:$e}=await Al(async()=>{const{probeRuntimeApps:lt}=await Promise.resolve().then(()=>o$);return{probeRuntimeApps:lt}},void 0);let Ie;if(V.runtimeId){const lt=V.region??"cn-beijing",Nt=await $e(V.runtimeId,lt)??[];Ie=ue(V.runtimeId,V.agentName,lt,Nt,Nt.length>0?{[Nt[0]]:V.agentName}:void 0)}else Ie=await se(V.agentName,V.url,V.apikey,"");if(Ie.apps.length===0)re("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const lt={[Ie.apps[0]]:V.agentName},Nt={...Ie,appLabels:{...Ie.appLabels??{},...lt}},sn=qe().map(Mt=>Mt.id===Ie.id?Nt:Mt);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(sn));const{registerConnections:Pn}=await Al(async()=>{const{registerConnections:Mt}=await Promise.resolve().then(()=>$S);return{registerConnections:Mt}},void 0);if(Pn(sn),a){const Mt=Te(Ie.id,Ie.apps[0]);a(Mt,V.agentName)}else alert(`🎉 Agent "${V.agentName}" 已添加到左上角下拉列表!`)}}catch(se){re(`添加 Agent 失败:${se instanceof Error?se.message:String(se)}`)}finally{ye(!1)}}}function Ut(){const se=Ire(e.files),ue=URL.createObjectURL(se),Te=document.createElement("a");Te.href=ue,Te.download=`${e.name||"project"}.zip`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(ue)}function wn(se,ue,Te){return Vre(se).map(qe=>{const $e=Te?`${Te}/${qe.name}`:qe.name,Ie=qe.path!==void 0,lt={paddingLeft:8+ue*14};if(Ie){const Kn=qe.path===S;return l.jsxs("button",{type:"button",className:`pp-row pp-file${Kn?" pp-active":""}`,style:lt,onClick:()=>C(qe.path),title:qe.path,children:[l.jsx(d7,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:qe.name})]},$e)}const Nt=M.has($e);return l.jsxs("div",{children:[l.jsxs("button",{type:"button",className:"pp-row pp-folder",style:lt,onClick:()=>Sn($e),children:[l.jsx(Nr,{className:`pp-ic pp-chevron${Nt?"":" pp-open"}`}),l.jsx(jR,{className:"pp-ic"}),l.jsx("span",{className:"pp-label",children:qe.name})]}),!Nt&&wn(qe,ue+1,$e)]},$e)})}return l.jsxs("div",{className:`pp-root${i?" is-deploy":""}${_?" has-primary-pane":""}`,children:[i&&l.jsx(Yre,{left:l.jsxs("div",{className:"pp-toolbar-left",children:[y&&l.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:y,children:[l.jsx(CR,{className:"pp-ic"}),E]}),l.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",n||e.name||"未命名 Agent",r&&r>1?` 等 ${r} 个智能体`:""]})]}),right:null}),l.jsxs("div",{className:"pp-body",children:[i&&!_&&l.jsxs("section",{className:"pp-topology-pane","aria-label":"Agent 拓扑",children:[l.jsxs("div",{className:"pp-topology-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"pp-topology-title",children:"Agent 拓扑"}),l.jsxs("div",{className:"pp-topology-count",children:[r??1," 个智能体"]})]}),A&&s&&l.jsx(Mre,{project:e,onChange:s})]}),l.jsxs("div",{className:"pp-topology-scroll",children:[l.jsx("div",{className:"pp-topology-tree",children:l.jsx(PD,{agent:Et,depth:0,inspectedId:mt,onHover:je,onFocus:ut})}),W&&J&&ce&&l.jsxs("div",{className:"pp-agent-inspector","aria-live":"polite",children:[l.jsxs("div",{className:"pp-agent-inspector-head",children:[l.jsx("span",{className:"pp-agent-inspector-icon",children:l.jsx(ce,{"aria-hidden":"true"})}),l.jsxs("div",{children:[l.jsx("strong",{children:W.name}),l.jsx("span",{children:J.label})]})]}),W.description&&l.jsx("p",{children:W.description}),l.jsxs("dl",{className:"pp-agent-config-grid",children:[l.jsx("dt",{children:"模型"}),l.jsx("dd",{children:W.model}),l.jsx("dt",{children:"工具"}),l.jsx("dd",{children:W.tools}),l.jsx("dt",{children:"技能"}),l.jsx("dd",{children:W.skills}),l.jsx("dt",{children:"知识库"}),l.jsx("dd",{children:W.knowledgebase}),l.jsx("dt",{children:"短期记忆"}),l.jsx("dd",{children:W.shortTerm}),l.jsx("dt",{children:"长期记忆"}),l.jsx("dd",{children:W.longTerm}),l.jsx("dt",{children:"观测"}),l.jsx("dd",{children:W.tracing})]})]})]}),l.jsxs("div",{className:"pp-topology-actions",children:[b&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:b,children:[l.jsx(l7,{className:"pp-ic"}),"导出配置"]}),e.files.length>0&&l.jsxs("button",{type:"button",className:"pp-secondary",onClick:Ut,children:[l.jsx(xx,{className:"pp-ic"}),"下载源码"]})]})]}),l.jsxs("div",{className:"pp-files-area",children:[l.jsxs("div",{className:"pp-sidebar",children:[l.jsxs("div",{className:"pp-sidebar-head",children:[l.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),A&&l.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{P(!0),I("")},children:l.jsx(c7,{className:"pp-ic"})})]}),l.jsxs("div",{className:"pp-tree",children:[q&&l.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:D,onChange:se=>I(se.target.value),onBlur:vt,onKeyDown:se=>{se.key==="Enter"&&vt(),se.key==="Escape"&&(P(!1),I(""))}}),e.files.length===0&&!q?l.jsx("div",{className:"pp-empty",children:"暂无文件"}):wn(ke,0,"")]})]}),l.jsxs("div",{className:"pp-main",children:[l.jsxs("div",{className:"pp-main-head",children:[l.jsx("span",{className:"pp-path",title:pe==null?void 0:pe.path,children:(pe==null?void 0:pe.path)??"未选择文件"}),l.jsx("div",{className:"pp-actions",children:A&&pe&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Ct,children:l.jsx(C7,{className:"pp-ic"})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Gt,children:l.jsx(mc,{className:"pp-ic"})})]})})]}),l.jsx("div",{className:"pp-content",children:pe==null?l.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):A?l.jsx("div",{className:"pp-codemirror",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:l.jsx(Dre,{value:pe.content,path:pe.path,onChange:wt})})}):l.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:Fre(pe.content,pe.path)}})})]})]}),i&&l.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[l.jsx("div",{className:"pp-config-head",children:l.jsx("div",{className:"pp-config-title",children:"部署配置"})}),l.jsxs("div",{className:"pp-config-scroll",children:[_,!_&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"发布区域"}),l.jsxs("select",{className:"pp-config-select",value:g,onChange:se=>x==null?void 0:x(se.target.value),"aria-label":"部署区域",disabled:L||!x,children:[l.jsx("option",{value:"cn-beijing",children:"华北 2(北京)"}),l.jsx("option",{value:"cn-shanghai",children:"华东 2(上海)"})]})]}),!_&&l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"消息渠道"}),l.jsxs("button",{type:"button",role:"switch","aria-checked":c,className:`pp-channel${c?" is-on":""}`,onClick:()=>void Ge(),disabled:L||z||!u,children:[l.jsx("span",{className:"pp-channel-title",children:z?"飞书(正在更新代码…)":"飞书"}),l.jsx("span",{className:"pp-switch","aria-hidden":!0,children:l.jsx("span",{})})]}),c&&l.jsx("div",{className:"pp-channel-fields",children:Yc.map(se=>l.jsxs("label",{children:[l.jsxs("span",{children:[se.comment||se.key,se.required&&l.jsx("small",{children:"必填"})]}),l.jsx("code",{children:se.key}),l.jsx("input",{type:se.key.includes("SECRET")?"password":"text",value:f[se.key]??"",placeholder:se.placeholder,disabled:L||!h,autoComplete:"off",onChange:ue=>h==null?void 0:h(se.key,ue.currentTarget.value)})]},se.key))})]}),l.jsxs("section",{className:"pp-config-section",children:[l.jsx("div",{className:"pp-config-label",children:"网络"}),_&&l.jsxs("div",{className:"pp-network-region",onKeyDown:se=>{se.key==="Escape"&&we(!1)},children:[l.jsx("span",{children:"发布区域"}),l.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":Pe,disabled:L||!x,onClick:()=>we(se=>!se),children:[l.jsx("span",{children:g==="cn-shanghai"?"华东 2(上海)":"华北 2(北京)"}),l.jsx(od,{className:`pp-region-chevron${Pe?" is-open":""}`})]}),Pe&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"menu-scrim",onClick:()=>we(!1)}),l.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:[{value:"cn-beijing",label:"华北 2(北京)"},{value:"cn-shanghai",label:"华东 2(上海)"}].map(se=>{const ue=se.value===g;return l.jsxs("button",{type:"button",role:"option","aria-selected":ue,className:`pp-region-option${ue?" is-selected":""}`,onClick:()=>{x==null||x(se.value),we(!1)},children:[l.jsx("span",{children:se.label}),ue&&l.jsx(Bs,{"aria-hidden":"true"})]},se.value)})})]})]}),l.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(se=>l.jsx("button",{type:"button",role:"radio","aria-checked":Xe===se,className:Xe===se?"is-on":"",onClick:()=>kt(se),disabled:L||!m,children:se==="public"?"公网":se==="private"?"VPC":"公网 + VPC"},se))}),Xe!=="public"&&l.jsxs("div",{className:"pp-network-fields",children:[l.jsxs("label",{children:[l.jsx("span",{children:"VPC ID"}),l.jsx("input",{value:(p==null?void 0:p.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:L,onChange:se=>le({vpcId:se.target.value})})]}),l.jsxs("label",{children:[l.jsxs("span",{children:["子网 ID ",l.jsx("small",{children:"可选,多个用逗号分隔"})]}),l.jsx("input",{value:(p==null?void 0:p.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:L,onChange:se=>le({subnetIds:se.target.value})})]}),l.jsxs("label",{className:"pp-network-check",children:[l.jsx("input",{type:"checkbox",checked:!!(p!=null&&p.enableSharedInternetAccess),disabled:L,onChange:se=>le({enableSharedInternetAccess:se.target.checked})}),"VPC 内共享公网出口"]})]})]}),l.jsxs("section",{className:"pp-config-section pp-env-section",children:[l.jsxs("div",{className:"pp-env-head",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"pp-config-label",children:["环境变量",l.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[We," 项"]})]}),l.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]}),l.jsx("button",{type:"button",className:"pp-icon-btn",title:be?"隐藏值":"显示值",onClick:()=>_e(se=>!se),children:be?l.jsx(a7,{className:"pp-ic"}):l.jsx(MR,{className:"pp-ic"})})]}),l.jsxs("button",{type:"button",className:"pp-env-add",onClick:_t,disabled:L,children:[l.jsx(Ps,{className:"pp-ic"}),"添加变量"]}),(St.length>0||Q.length>0)&&l.jsxs("div",{className:"pp-env-table",children:[St.length>0&&l.jsxs("div",{className:"pp-env-group",children:[l.jsxs("div",{className:"pp-env-group-head",children:[l.jsx("span",{children:"组件自动生成"}),l.jsxs("small",{children:[St.length," 项"]})]}),St.map(se=>{const ue=se.key.startsWith("ENABLE_");return l.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[l.jsx("input",{className:"pp-env-key-fixed",value:se.key,readOnly:!0,disabled:L,"aria-label":`${se.key} 环境变量名`}),l.jsx("input",{type:ue||be?"text":"password",value:se.value,placeholder:se.required?"必填,尚未填写":"可选,尚未填写",readOnly:ue,disabled:L||!ue&&!h,autoComplete:"off","aria-label":`${se.key} 环境变量值`,onChange:Te=>h==null?void 0:h(se.key,Te.currentTarget.value)}),l.jsx("span",{className:"pp-env-source",children:ue?"自动":"同步"})]},se.key)})]}),Q.length>0&&l.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[l.jsx("span",{children:"自定义变量"}),l.jsxs("small",{children:[Q.length," 项"]})]}),Q.map(se=>l.jsxs("div",{className:"pp-env-row",children:[l.jsx("input",{value:se.key,placeholder:"名称",disabled:L,autoComplete:"off",onChange:ue=>Ve(se.id,{key:ue.currentTarget.value})}),l.jsx("input",{type:be?"text":"password",value:se.value,placeholder:"值",disabled:L,autoComplete:"off",onChange:ue=>Ve(se.id,{value:ue.currentTarget.value})}),l.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:L,onClick:()=>ot(se.id),children:l.jsx(Wr,{className:"pp-ic"})})]},se.id))]})]}),(L||V||Object.keys(oe).length>0)&&l.jsxs("section",{className:"pp-config-section pp-progress-section",children:[l.jsx("div",{className:"pp-config-label",children:"部署进度"}),l.jsx("ol",{className:"pp-steps",children:N.map((se,ue)=>{const Te=ae?N.findIndex(lt=>lt.phase===ae):-1,qe=!!j&&(Te===-1?ue===0:ue===Te);let $e;V?$e="done":qe?$e="failed":Te===-1?$e=L?"active":"pending":uese.phase===ae))==null?void 0:fn.label)??ae}阶段):`:""}${j}`,onRetry:Bt}),V&&l.jsxs("section",{className:"pp-deploy-result",children:[l.jsx("div",{className:"pp-deploy-result-header",children:"部署成功"}),l.jsxs("div",{className:"pp-deploy-result-body",children:[V.region&&l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"区域"}),l.jsx("code",{children:V.region==="cn-shanghai"?"上海 (cn-shanghai)":"北京 (cn-beijing)"})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"Agent 名称"}),l.jsx("code",{children:V.agentName})]}),l.jsxs("div",{className:"pp-deploy-result-field",children:[l.jsx("label",{children:"API 端点"}),l.jsx("code",{className:"pp-deploy-result-url",children:V.url})]})]}),l.jsxs("div",{className:"pp-deploy-result-actions",children:[l.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Ft,disabled:de,children:[de?l.jsx(bt,{className:"pp-ic spin"}):l.jsx(UR,{className:"pp-ic"}),de?"连接中…":"立即对话"]}),V.consoleUrl&&l.jsxs("a",{href:V.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[l.jsx(wx,{className:"pp-ic"}),"控制台"]})]})]})]}),l.jsxs("div",{className:"pp-config-actions",children:[k&&T&&l.jsx("span",{className:"pp-deploy-hint",children:T}),l.jsx("button",{type:"button",className:"pp-deploy",onClick:Bt,disabled:L||z||k,title:k?T:void 0,children:L?"部署中…":j?"重试部署":"部署"})]})]})]}),l.jsx(Pre,{open:B,onCancel:nn,onConfirm:()=>void Nn()})]})}const uN="dogfooding",ny="dogfooding",ry="dogfooding_b";let Wre=0;const sy=()=>++Wre;function dN(e){return e.blocks.filter(t=>t.kind==="text").map(t=>t.text).join("")}function qre(e){const t=e.trim(),n=t.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i);return(n?n[1]:t).trim()}async function fN(e){const t=[],n=qre(e);t.push(n);const r=n.indexOf("{"),s=n.lastIndexOf("}");r>=0&&s>r&&t.push(n.slice(r,s+1));for(const i of t)try{const a=JSON.parse(i);if(a&&typeof a=="object"&&(typeof a.name=="string"||typeof a.instruction=="string"))return await Bp(AD(a))}catch{}return null}function Gre({userId:e,onBack:t,onCreate:n,onAgentAdded:r,onDeploymentTaskChange:s}){const[i,a]=v.useState([{id:sy(),role:"assistant",text:"你好,我是 VeADK 的智能构建助手。用自然语言描述你想要的 Agent,我会直接帮你生成一个可运行的 VeADK 项目,并在右侧实时预览。"}]),[o,c]=v.useState(""),[u,d]=v.useState(!1),[f,h]=v.useState(null),[p,m]=v.useState(null),[g,x]=v.useState(!1),[y,E]=v.useState(null),[b,_]=v.useState(null),[k,T]=v.useState(!1),[A,N]=v.useState(!1),[S,C]=v.useState({}),M=v.useRef(null),U=v.useRef(null),q=v.useRef(null),P=v.useRef(null),D=v.useRef(null);v.useEffect(()=>{const V=P.current;V&&V.scrollTo({top:V.scrollHeight,behavior:"smooth"})},[i,u]),v.useEffect(()=>{const V=D.current;V&&(V.style.height="auto",V.style.height=Math.min(V.scrollHeight,160)+"px")},[o]);const I=V=>a(ee=>[...ee,{id:sy(),role:"assistant",text:V}]);async function L(){if(M.current)return M.current;const V=await Pp(uN,e);return M.current=V,V}async function O(V,ee){if(ee.current)return ee.current;const oe=await Pp(V,e);return ee.current=oe,oe}async function B(V,ee){if(!S[V])try{const oe=await Rx(ee);C(X=>({...X,[V]:oe.model||ee}))}catch{C(oe=>({...oe,[V]:ee}))}}async function R(V,ee,oe){const X=await O(V,ee);let ae=Ns();for await(const de of cd({appName:V,userId:e,sessionId:X,text:oe}))ae=zl(ae,de);const Z=dN(ae).trim();return{project:await fN(Z),finalText:Z}}const z=async(V,ee,oe)=>Um(V.name,V.files,{region:"cn-beijing",projectName:"default"},{...oe,onStage:ee}),Y=async()=>{const V=o.trim();if(!(!V||u)){if(a(ee=>[...ee,{id:sy(),role:"user",text:V}]),c(""),h(null),d(!0),g){E(null),_(null),T(!0),N(!0),B("a",ny),B("b",ry);const ee=R(ny,U,V).then(({project:X})=>(E(X),X)).catch(X=>{const ae=X instanceof Error?X.message:String(X);return h(ae),null}).finally(()=>T(!1)),oe=R(ry,q,V).then(({project:X})=>(_(X),X)).catch(X=>{const ae=X instanceof Error?X.message:String(X);return h(ae),null}).finally(()=>N(!1));try{const[X,ae]=await Promise.all([ee,oe]),Z=[X?`方案 A:${X.name}`:null,ae?`方案 B:${ae.name}`:null].filter(Boolean);Z.length?I(`已生成两个方案(${Z.join(",")}),请在右侧对比后采用其一。`):I("(两个方案都没有返回可用的项目,请再描述一下你的需求。)")}finally{d(!1)}return}try{const ee=await L();let oe=Ns();for await(const Z of cd({appName:uN,userId:e,sessionId:ee,text:V}))oe=zl(oe,Z);const X=dN(oe).trim(),ae=await fN(X);ae?(m(ae),I(`已生成项目:${ae.name}(${ae.files.length} 个文件),可在右侧预览和编辑。`)):I(X||"(助手没有返回内容,请再描述一下你的需求。)")}catch(ee){const oe=ee instanceof Error?ee.message:String(ee);h(oe),I(`抱歉,调用智能构建助手失败:${oe}`)}finally{d(!1)}}},j=V=>{const ee=V==="a"?y:b;if(!ee)return;m(ee),x(!1),E(null),_(null),T(!1),N(!1);const oe=V==="a"?"A":"B",X=V==="a"?S.a:S.b;I(`已采用方案 ${oe}(${X??(V==="a"?ny:ry)}),可继续编辑。`)},re=V=>{V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),Y())};return l.jsx("div",{className:"ic-root",children:l.jsxs("div",{className:"ic-body",children:[l.jsxs("div",{className:"ic-chat",children:[l.jsxs("div",{className:"ic-transcript",ref:P,children:[l.jsx(Js,{initial:!1,children:i.map(V=>l.jsxs(Rt.div,{className:`ic-turn ic-turn--${V.role}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.22,ease:"easeOut"},children:[V.role==="assistant"&&l.jsx("div",{className:"ic-avatar",children:l.jsx(Hl,{className:"ic-avatar-icon"})}),l.jsx("div",{className:"ic-bubble",children:V.role==="assistant"?l.jsx(Gd,{text:V.text}):V.text})]},V.id))}),u&&l.jsxs(Rt.div,{className:"ic-turn ic-turn--assistant",initial:{opacity:0,y:8},animate:{opacity:1,y:0},children:[l.jsx("div",{className:"ic-avatar",children:l.jsx(Hl,{className:"ic-avatar-icon"})}),l.jsxs("div",{className:"ic-bubble ic-bubble--typing",children:[l.jsx("span",{className:"ic-dot"}),l.jsx("span",{className:"ic-dot"}),l.jsx("span",{className:"ic-dot"})]})]})]}),f&&l.jsxs("div",{className:"ic-error",children:[l.jsx(yx,{className:"ic-error-icon"}),f]}),l.jsxs("div",{className:"ic-composer",children:[l.jsxs("div",{className:"ic-composer-box",children:[l.jsx("textarea",{ref:D,className:"ic-input",rows:1,placeholder:"描述你想要的 Agent,例如「一个帮我整理周报的写作助手」…",value:o,onChange:V=>c(V.target.value),onKeyDown:re,disabled:u}),l.jsx("button",{className:"ic-send",onClick:()=>void Y(),disabled:!o.trim()||u,title:"发送 (Enter)",children:l.jsx(O7,{className:"ic-send-icon"})})]}),l.jsxs("div",{className:"ic-composer-foot",children:[l.jsxs("label",{className:"ic-ab-toggle",title:"同时用两个模型生成方案进行对比",children:[l.jsx("input",{type:"checkbox",className:"ic-ab-checkbox",checked:g,disabled:u,onChange:V=>x(V.target.checked)}),l.jsx("span",{className:"ic-ab-track",children:l.jsx("span",{className:"ic-ab-thumb"})}),l.jsx("span",{className:"ic-ab-label",children:"A/B 对比"})]}),l.jsx("div",{className:"ic-composer-hint",children:"Enter 发送 · Shift+Enter 换行"})]})]})]}),l.jsx("aside",{className:"ic-preview",children:g?l.jsxs("div",{className:"ic-compare",children:[l.jsx(hN,{side:"a",project:y,loading:k,model:S.a,onAdopt:()=>j("a")}),l.jsx("div",{className:"ic-compare-divider"}),l.jsx(hN,{side:"b",project:b,loading:A,model:S.b,onAdopt:()=>j("b")})]}):p?l.jsx(lg,{project:p,onChange:m,onDeploy:z,onAgentAdded:r,onDeploymentTaskChange:s}):l.jsxs("div",{className:"ic-preview-empty",children:[l.jsxs("div",{className:"ic-preview-empty-icon",children:[l.jsx(f7,{className:"ic-preview-empty-glyph"}),l.jsx(ho,{className:"ic-preview-empty-spark"})]}),l.jsx("div",{className:"ic-preview-empty-title",children:"还没有项目"}),l.jsx("div",{className:"ic-preview-empty-sub",children:"描述你的需求,我会帮你生成 VeADK 项目"})]})})]})})}function hN({side:e,project:t,loading:n,model:r,onAdopt:s}){const i=e==="a"?"方案 A":"方案 B";return l.jsxs("div",{className:"ic-pane",children:[l.jsxs("div",{className:"ic-pane-head",children:[l.jsxs("div",{className:"ic-pane-title",children:[l.jsx("span",{className:`ic-pane-tag ic-pane-tag--${e}`,children:i}),r&&l.jsx("span",{className:"ic-pane-model",children:r})]}),l.jsxs("button",{className:"ic-adopt",onClick:s,disabled:!t||n,title:`采用${i}`,children:["采用",e==="a"?"方案 A":"方案 B"]})]}),l.jsx("div",{className:"ic-pane-body",children:n?l.jsxs("div",{className:"ic-pane-loading",children:[l.jsx(bt,{className:"ic-pane-spinner"}),l.jsx("span",{children:"正在生成…"})]}):t?l.jsx(lg,{project:t}):l.jsx("div",{className:"ic-pane-empty",children:"该方案未返回可用项目"})})]})}const Xre=/^[A-Za-z_][A-Za-z0-9_]*$/;function Cl(e){return e.trim().length===0?"名称为必填项":e==="user"?"user 是 Google ADK 保留名称,请使用其他名称":Xre.test(e)?null:"名称须以英文字母或下划线开头,且只能包含英文字母、数字和下划线"}function jD(e){const t=new Set,n=new Set,r=s=>{Cl(s.name)===null&&(t.has(s.name)?n.add(s.name):t.add(s.name)),s.subAgents.forEach(r)};return r(e),n}function hs(e){return e.trimEnd().replace(/[。.]+$/,"")}function rm(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(r=>r==null?void 0:r.toLocaleLowerCase().includes(n)):!0}function Da(e,t){return e[t]|e[t+1]<<8}function $o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}async function Qre(e){const t=new DecompressionStream("deflate-raw"),n=new Blob([new Uint8Array(e)]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}async function BD(e,t={}){let r=-1;for(let u=e.length-22;u>=0&&u>e.length-65557;u--)if($o(e,u)===101010256){r=u;break}if(r<0)throw new Error("无效的 zip:找不到 EOCD");const s=Da(e,r+10);if(t.maxEntries!==void 0&&s>t.maxEntries)throw new Error(`zip 文件数不能超过 ${t.maxEntries} 个`);let i=$o(e,r+16);const a=new TextDecoder("utf-8"),o=[];let c=0;for(let u=0;ut.maxUncompressedBytes)throw new Error("zip 解压后的内容过大");const E=Da(e,x+26),b=Da(e,x+28),_=x+30+E+b,k=e.subarray(_,_+f);let T;if(d===0)T=k;else if(d===8)T=await Qre(k);else{i+=46+p+m+g;continue}o.push({name:y,text:a.decode(T)}),i+=46+p+m+g}return o}const Zre="/skillhub/v1/skills";async function Jre(e,t="public"){const n=e.trim(),r=`${Zre}?query=${encodeURIComponent(n)}&namespace=${encodeURIComponent(t)}`,s=await fetch(r,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(!s.ok)throw new Error(`搜索失败 (${s.status})`);return((await s.json()).Skills??[]).map(a=>{var o;return{source:"skillhub",id:a.Id??a.Slug??"",slug:a.Slug??"",name:a.Name??a.Slug??"",description:((o=a.Metadata)==null?void 0:o.DisplayDescription)||a.Description||"",namespace:a.Namespace??t,sourceRepo:a.SourceRepo,downloadCount:a.DownloadCount}})}function ese({selected:e,onChange:t}){const[n,r]=v.useState(""),[s,i]=v.useState([]),[a,o]=v.useState(!1),[c,u]=v.useState(null),[d,f]=v.useState(!1),h=g=>e.some(x=>x.source==="skillhub"&&x.slug===g),p=g=>{g.slug&&(h(g.slug)?t(e.filter(x=>!(x.source==="skillhub"&&x.slug===g.slug))):t([...e,{source:"skillhub",slug:g.slug,name:g.name,folder:g.slug.split("/").pop()||g.name,namespace:g.namespace||"public",description:g.description}]))},m=async g=>{o(!0),u(null),f(!0);try{const x=await Jre(g);i(x)}catch(x){u(x instanceof Error?x.message:"搜索失败,请稍后重试。"),i([])}finally{o(!1)}};return v.useEffect(()=>{const g=n.trim();if(!g){i([]),f(!1),u(null);return}const x=setTimeout(()=>m(g),300);return()=>clearTimeout(x)},[n]),l.jsxs("div",{className:"cw-skillhub",children:[l.jsxs("div",{className:"cw-skill-searchrow",children:[l.jsxs("div",{className:"cw-skill-searchbox",children:[l.jsx(Hb,{className:"cw-i cw-skill-searchicon","aria-hidden":!0}),l.jsx("input",{className:"cw-input cw-skill-input",value:n,placeholder:"搜索火山 Find Skill 技能广场,例如 数据分析、PDF…",onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),n.trim()&&m(n))}})]}),l.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft",onClick:()=>n.trim()&&m(n),disabled:!n.trim()||a,children:[a?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(Hb,{className:"cw-i"}),"搜索"]})]}),c&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:c})]}),a&&s.length===0?l.jsx("p",{className:"cw-empty-line",children:"正在搜索…"}):s.length>0?l.jsx("div",{className:"cw-skill-results",children:s.map(g=>{const x=h(g.slug||"");return l.jsxs("button",{type:"button",className:`cw-skill-result ${x?"is-on":""}`,onClick:()=>p(g),"aria-pressed":x,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:x?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:g.name}),g.description&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(g.description)}),g.sourceRepo&&l.jsx("span",{className:"cw-skill-result-repo",children:g.sourceRepo})]})]},g.id||g.slug)})}):d&&!c?l.jsx("p",{className:"cw-empty-line",children:"没有找到匹配的技能,换个关键词试试。"}):!d&&l.jsx("p",{className:"cw-empty-line",children:"输入关键词搜索火山 Find Skill 技能广场,所选技能会在生成项目时下载到 skills/ 目录。"})]})}const T1=/(^|\/)skill\.md$/i;class ya extends Error{}function tse(e,t){const n=(e??"").replace(/\r\n?/g,` `).split(` -`);if(!n.length||n[0].trim()!=="---")throw new ya(`${t} 的 SKILL.md 必须以 YAML frontmatter (--- ... ---) 开头`);let r=-1;for(let o=1;o=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))}function rse(e,t){if(!e)throw new ya(`${t} 的 SKILL.md 缺少必填的 name frontmatter`);if(e.length>64)throw new ya(`${t} 的 name 长度超过 64 个字符`);if(!/^[a-z0-9-]+$/.test(e))throw new ya(`${t} 的 name 必须匹配 [a-z0-9-]+(小写字母、数字、短横线)`)}function sse(e,t){if(!e)throw new ya(`${t} 的 SKILL.md 缺少必填的 description frontmatter`);if(e.length>1024)throw new ya(`${t} 的 description 长度超过 1024 个字符`);if(/<[^>]+>/.test(e))throw new ya(`${t} 的 description 不能包含 XML 标签`)}function FD(e){const t=e.map(r=>({path:r.path.replace(/\\/g,"/").replace(/^\.\//,""),text:r.text})).filter(r=>r.path.length>0&&!r.path.endsWith("/")),n=new Set(t.map(r=>r.path.split("/")[0]));if(n.size===1&&t.every(r=>r.path.includes("/"))){const r=[...n][0]+"/";return t.map(s=>({path:s.path.slice(r.length),text:s.text}))}return t}function ise(e){const t=new Map,n=new Set;for(const r of e)if(T1.test("/"+r.path)){const s=r.path.split("/");n.add(s.slice(0,-1).join("/"))}for(const r of e){const s=r.path.split("/");let i="";for(let u=s.length-1;u>=0;u--){const d=s.slice(0,u).join("/");if(n.has(d)){i=d;break}}const a=T1.test("/"+r.path);if(!i&&!a&&!n.has("")||!n.has(i)&&!a)continue;const o=i?r.path.slice(i.length+1):r.path,c=t.get(i)||[];c.push({path:o,text:r.text}),t.set(i,c)}return t}function ase(e,t,n){const r=`${n}${e?"/"+e:""}`,s=t.find(c=>T1.test("/"+c.path));if(!s)return{hit:null,error:`${r} 缺少 SKILL.md`};let i;try{i=tse(s.text,r)}catch(c){return{hit:null,error:c instanceof Error?c.message:String(c)}}const a=i.name,o=[];for(const c of t){if(c.path.split("/").some(f=>f===".."))return{hit:null,error:`${r} 包含非法路径(..):${c.path}`};const d=`skills/${a}/${c.path}`;if(!d.startsWith(`skills/${a}/`))return{hit:null,error:`${r} 包含非法路径:${c.path}`};o.push({path:d,content:c.text})}return{hit:{source:"local",id:`local:${a}:${t.length}`,name:i.name,description:i.description,folder:a,localFiles:o},error:null}}async function ose(e){const t=new Uint8Array(await e.arrayBuffer()),r=(await BD(t)).map(s=>({path:s.name,text:s.text}));return UD(FD(r),e.name)}async function lse(e,t=new Map){const n=[];for(let r=0;re.file(t,n))}async function use(e){const t=e.createReader(),n=[];for(;;){const r=await new Promise((s,i)=>t.readEntries(s,i));if(r.length===0)return n;n.push(...r)}}async function $D(e,t=""){const n=t?`${t}/${e.name}`:e.name;if(e.isFile)return[{file:await cse(e),path:n}];if(!e.isDirectory)return[];const r=await use(e);return(await Promise.all(r.map(s=>$D(s,n)))).flat()}function dse({selected:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState([]),[a,o]=v.useState(!1),[c,u]=v.useState(!1),d=v.useRef(0),f=b=>e.some(_=>_.source==="local"&&_.folder===b),h=b=>{b.localFiles&&(f(b.folder||b.name)?t(e.filter(_=>!(_.source==="local"&&_.folder===(b.folder||b.name)))):t([...e,{source:"local",folder:b.folder||b.name,name:b.name,description:b.description,localFiles:b.localFiles}]))},p=v.useRef([]),m=v.useRef(e);v.useEffect(()=>{p.current=s},[s]),v.useEffect(()=>{m.current=e},[e]);const g=b=>{const _=new Set([...p.current.map(N=>N.folder||N.name),...m.current.filter(N=>N.source==="local").map(N=>N.folder)]),k=[],T=[];for(const N of b.hits){const S=N.folder||N.name;if(_.has(S)){k.push(N.name);continue}_.add(S),T.push(N)}i(N=>[...N,...T]);const A=[...b.errors];if(k.length>0&&A.push(`已跳过重复技能:${k.join("、")}`),r(A),T.length===1&&b.errors.length===0&&k.length===0){const N=T[0];N.localFiles&&t([...m.current,{source:"local",folder:N.folder||N.name,name:N.name,description:N.description,localFiles:N.localFiles}])}},x=b=>{b.preventDefault(),d.current+=1,u(!0)},y=b=>{b.preventDefault(),d.current=Math.max(0,d.current-1),d.current===0&&u(!1)},E=async b=>{if(b.preventDefault(),d.current=0,u(!1),a)return;const _=Array.from(b.dataTransfer.items).map(k=>{var T;return(T=k.webkitGetAsEntry)==null?void 0:T.call(k)}).filter(k=>k!==null);if(_.length===0){r(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}o(!0);try{const k=(await Promise.all(_.map(N=>$D(N)))).flat(),T=_.some(N=>N.isDirectory);if(!T&&k.length===1&&k[0].file.name.toLowerCase().endsWith(".zip")){g(await ose(k[0].file));return}if(!T){r(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}const A=new Map(k.map(({file:N,path:S})=>[N,S]));g(await lse(k.map(({file:N})=>N),A))}catch(k){r([`读取失败:${k instanceof Error?k.message:String(k)}`])}finally{o(!1)}};return l.jsxs("div",{className:"cw-local",children:[l.jsxs("div",{className:`cw-local-dropzone ${c?"is-dragging":""}`,role:"group","aria-label":"拖入文件夹或 ZIP,自动识别 Skill",onDragEnter:x,onDragOver:b=>b.preventDefault(),onDragLeave:y,onDrop:b=>void E(b),children:[l.jsx(vx,{className:"cw-local-drop-icon","aria-hidden":!0}),l.jsx("p",{className:"cw-local-drop-hint",children:"拖入文件夹或 ZIP,自动识别 Skill"})]}),l.jsx("p",{className:"cw-local-hint",children:"每个技能需包含 SKILL.md(含 name / description frontmatter)。支持包含多个技能的目录。"}),a&&l.jsx("p",{className:"cw-empty-line",children:"正在读取文件…"}),n.length>0&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:n.join(";")})]}),s.length>0&&l.jsx("div",{className:"cw-skill-results",children:s.map(b=>{var k;const _=f(b.folder||b.name);return l.jsxs("button",{type:"button",className:`cw-skill-result ${_?"is-on":""}`,onClick:()=>h(b),"aria-pressed":_,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:_?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:b.name}),b.description&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(b.description)}),l.jsxs("span",{className:"cw-skill-result-repo",children:["本地 · ",((k=b.localFiles)==null?void 0:k.length)??0," 个文件"]})]})]},b.id)})})]})}function fse({selected:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState([]),[a,o]=v.useState(""),[c,u]=v.useState(!0),[d,f]=v.useState(!1),[h,p]=v.useState(null);v.useEffect(()=>{let y=!1;return(async()=>{u(!0),p(null);try{const E=await g$();y||(r(E),E.length>0&&o(E[0].id))}catch(E){y||p(E instanceof Error?E.message:"加载失败")}finally{y||u(!1)}})(),()=>{y=!0}},[]),v.useEffect(()=>{if(!a){i([]);return}const y=n.find(b=>b.id===a);let E=!1;return(async()=>{f(!0),p(null);try{const b=await b$(a,y==null?void 0:y.region);E||i(b)}catch(b){E||p(b instanceof Error?b.message:"加载失败")}finally{E||f(!1)}})(),()=>{E=!0}},[a,n]);const m=n.find(y=>y.id===a),g=(y,E)=>e.some(b=>b.source==="skillspace"&&b.skillId===y&&(b.version||"")===E),x=y=>{if(m)if(g(y.skillId,y.version))t(e.filter(E=>!(E.source==="skillspace"&&E.skillId===y.skillId&&(E.version||"")===y.version)));else{const E=w$(m,y);t([...e,{source:"skillspace",folder:E.folder||y.skillName,name:E.name,description:E.description,skillSpaceId:E.skillSpaceId,skillSpaceName:E.skillSpaceName,skillSpaceRegion:E.skillSpaceRegion,skillId:E.skillId,version:E.version}])}};return l.jsx("div",{className:"cw-skillspace",children:c?l.jsxs("p",{className:"cw-empty-line",children:[l.jsx(bt,{className:"cw-i cw-spin"})," 正在加载 AgentKit Skills 中心…"]}):h?l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:h})]}):n.length===0?l.jsx("p",{className:"cw-empty-line",children:"此账号下没有 AgentKit Skills 中心。"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-skillspace-header",children:[l.jsx("select",{className:"cw-input cw-skillspace-select",value:a,onChange:y=>o(y.target.value),"aria-label":"选择 AgentKit Skills 中心",children:n.map(y=>l.jsxs("option",{value:y.id,children:[y.name||y.id,y.region?` [${y.region}]`:"",y.description?` — ${hs(y.description)}`:""]},y.id))}),m&&l.jsx("a",{href:v$(m.id,m.region),target:"_blank",rel:"noopener noreferrer",className:"cw-button cw-button-secondary cw-skillspace-console-link",title:"在火山引擎控制台打开",children:l.jsx(wx,{className:"cw-i cw-i-sm"})})]}),d?l.jsxs("p",{className:"cw-empty-line",children:[l.jsx(bt,{className:"cw-i cw-spin"})," 正在加载技能列表…"]}):s.length===0?l.jsx("p",{className:"cw-empty-line",children:"此 AgentKit Skills 中心暂无技能。"}):l.jsx("div",{className:"cw-skill-results",children:s.map(y=>{const E=g(y.skillId,y.version);return l.jsxs("button",{type:"button",className:`cw-skill-result ${E?"is-on":""}`,onClick:()=>x(y),"aria-pressed":E,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:E?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsxs("span",{className:"cw-skill-result-name",children:[y.skillName,y.version&&l.jsxs("span",{className:"cw-skill-result-version",children:[" ","v",y.version]})]}),y.skillDescription&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(y.skillDescription)}),l.jsxs("span",{className:"cw-skill-result-repo",children:[l.jsx(n7,{className:"cw-i cw-i-sm"})," ",(m==null?void 0:m.name)||a]})]})]},`${y.skillId}/${y.version}`)})})]})})}async function hse(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine 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 pse(e={}){const t=new URLSearchParams({region:e.region||"cn-beijing",page_size:String(e.pageSize??100),project:e.project||"default"});return(await hse(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function mse(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine 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 gse(e={}){const t=new URLSearchParams({region:e.region||"cn-beijing",project:e.project||"default"});return(await mse(`/web/viking-knowledgebases?${t.toString()}`)).items||[]}const yse=v.lazy(()=>Al(()=>import("./MarkdownPromptEditor-B7SUdnRF.js"),__vite__mapDeps([0,1])));function bse(e,t,n="text/plain"){const r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(r)}const pN=[{id:"type",label:"类型",hint:"选择 Agent 类型",icon:M7,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:Aa,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:s7},{id:"tools",label:"工具",hint:"可调用的能力",icon:zR},{id:"skills",label:"技能",hint:"声明式技能",icon:ho},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:Mh},{id:"advanced",label:"进阶配置",hint:"记忆与观测",icon:FR},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:OR},{id:"review",label:"完成",hint:"预览并创建",icon:R7}];function Ese({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"m7.2 15.8 7.9-7.9a2 2 0 0 1 2.8 0l1.2 1.2a2 2 0 0 1 0 2.8l-7 7H8.7l-1.5-1.5a1.15 1.15 0 0 1 0-1.6Z"}),l.jsx("path",{d:"m12.7 10.3 4 4"}),l.jsx("path",{d:"M6.3 19h12.4"}),l.jsx("path",{d:"m5.5 8.2.5-1.4 1.4-.5L6 5.8l-.5-1.4L5 5.8l-1.4.5 1.4.5.5 1.4Z"})]})}function xse({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.25",y:"4.25",width:"17.5",height:"15.5",rx:"2.75"}),l.jsx("path",{d:"M3.75 8.75h16.5"}),l.jsx("circle",{cx:"6.35",cy:"6.5",r:"0.72",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"8.85",cy:"6.5",r:"0.72",fill:"currentColor",stroke:"none",opacity:"0.45"}),l.jsx("path",{d:"M6 14h2.2l1.35-2.8 2.1 5.5 1.7-3.1H18"})]})}function wse({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.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"}),l.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),l.jsx("path",{d:"M3 10v4",opacity:"0.45"}),l.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function HD({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5"})})}function zD({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),l.jsx("path",{d:"M4.5 4.75v3.5H8"}),l.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),l.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const iy=4,vse={llm:"LLM 智能体",sequential:"顺序型智能体",parallel:"并行型智能体",loop:"循环型智能体",a2a:"远程智能体"},mN={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},VD="REGISTRY_SPACE_ID",_se=y3.filter(e=>e.key!==VD);function KD(e,t){var r,s,i;if(!(e!=null&&e.enabled))return{};const n={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(n.REGISTRY_TOP_K=((r=e.registryTopK)==null?void 0:r.trim())||Ms.topK,n.REGISTRY_REGION=((s=e.registryRegion)==null?void 0:s.trim())||Ms.region,n.REGISTRY_ENDPOINT=((i=e.registryEndpoint)==null?void 0:i.trim())||Ms.endpoint):(n.REGISTRY_TOP_K=e.registryTopK??"",n.REGISTRY_REGION=e.registryRegion??"",n.REGISTRY_ENDPOINT=e.registryEndpoint??""),n}function gN({items:e,selected:t,onToggle:n,scrollRows:r}){return l.jsx("div",{className:`cw-checklist ${r?"cw-checklist-tools":""}`,style:r?{"--cw-checklist-max-height":`${r*65+(r-1)*8}px`}:void 0,children:e.map(s=>{const i=t.includes(s.id);return l.jsxs("button",{type:"button",className:`cw-check ${i?"is-on":""}`,onClick:()=>n(s.id),"aria-pressed":i,children:[l.jsx("span",{className:"cw-check-box","aria-hidden":!0,children:i&&l.jsx(Bs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-check-text",children:[l.jsx("span",{className:"cw-check-title",children:s.label}),l.jsx("span",{className:"cw-check-desc",children:hs(s.desc)})]})]},s.id)})})}function ay({options:e,value:t,onChange:n}){return l.jsx("div",{className:"cw-segmented",children:e.map(r=>{var i;const s=(t??((i=e[0])==null?void 0:i.id))===r.id;return l.jsxs("button",{type:"button",className:`cw-seg ${s?"is-on":""}`,onClick:()=>n(r.id),"aria-pressed":s,title:hs(r.desc),children:[l.jsx("span",{className:"cw-seg-title",children:r.label}),l.jsx("span",{className:"cw-seg-desc",children:hs(r.desc)})]},r.id)})})}function kse(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function Ho({env:e,values:t,onChange:n}){return e.length===0?l.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):l.jsx("div",{className:"cw-env-fields",children:e.map(r=>l.jsxs("label",{className:"cw-env-field",children:[l.jsxs("span",{className:"cw-env-field-head",children:[l.jsxs("span",{className:"cw-env-field-label",children:[r.comment||r.key,r.required&&l.jsx("span",{className:"cw-req",children:"*"})]}),r.comment&&l.jsx("code",{title:r.key,children:r.key})]}),l.jsx("input",{className:"cw-input",type:kse(r.key)?"password":"text",value:t[r.key]??"",placeholder:r.placeholder||"请输入参数值",autoComplete:"off",onChange:s=>n(r.key,s.currentTarget.value)})]},r.key))})}function oy(e){return e.name.trim()||"未命名智能体中心"}function ly(e){return e.name.trim()||e.id||"未命名知识库"}function Tse({value:e,region:t,invalid:n,onChange:r}){const s=t.trim()||Ms.region,[i,a]=v.useState([]),[o,c]=v.useState(!1),[u,d]=v.useState(null),[f,h]=v.useState(0),[p,m]=v.useState(!1),[g,x]=v.useState(""),y=v.useRef(null);v.useEffect(()=>{let S=!1;return c(!0),d(null),pse({region:s}).then(C=>{S||a(C)}).catch(C=>{S||(a([]),d(C instanceof Error?C.message:"加载失败"))}).finally(()=>{S||c(!1)}),()=>{S=!0}},[s,f]);const E=!e||i.some(S=>S.id===e.trim()),b=i.find(S=>S.id===e.trim()),_=b?oy(b):e&&!E?"已选择的智能体中心":"请选择智能体中心",k=o&&i.length===0,T=v.useMemo(()=>i.filter(S=>rm(g,[oy(S),S.id,S.projectName])),[g,i]),A=!!(e&&!E&&rm(g,["已选择的智能体中心",e]));v.useEffect(()=>{if(!p)return;const S=M=>{const U=M.target;U instanceof Node&&y.current&&!y.current.contains(U)&&m(!1)},C=M=>{M.key==="Escape"&&m(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",C),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",C)}},[p]);const N=S=>{r(S),m(!1)};return l.jsxs("div",{className:"cw-a2a-space-picker",ref:y,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:k,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{x(""),m(S=>!S)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:_}),l.jsx(HD,{className:"cw-a2a-space-trigger-icon"})]}),p&&l.jsxs("div",{className:"cw-a2a-space-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:g,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:S=>x(S.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[A&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>N(e),children:"已选择的智能体中心"}),T.map(S=>{const C=oy(S),M=S.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":M,className:`cw-a2a-space-option ${M?"is-selected":""}`,title:`${C} (${S.id})`,onClick:()=>N(S.id),children:C},S.id)}),!A&&T.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:o,onClick:()=>h(S=>S+1),children:o?l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(zD,{className:"cw-i cw-i-sm"})})]}),u?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:u})]}):o?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):i.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",i.length," 个智能体中心,列表仅展示中心名称。"]})]})}function Sse({value:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState(!1),[a,o]=v.useState(null),[c,u]=v.useState(0),[d,f]=v.useState(!1),[h,p]=v.useState(""),m=v.useRef(null);v.useEffect(()=>{let T=!1;return i(!0),o(null),gse().then(A=>{T||r(A)}).catch(A=>{T||(r([]),o(A instanceof Error?A.message:"加载失败"))}).finally(()=>{T||i(!1)}),()=>{T=!0}},[c]);const g=!e||n.some(T=>T.id===e.trim()),x=n.find(T=>T.id===e.trim()),y=x?ly(x):e&&!g?e:"请选择 VikingDB 知识库",E=s&&n.length===0,b=v.useMemo(()=>n.filter(T=>rm(h,[ly(T),T.id,T.description,T.projectName])),[n,h]),_=!!(e&&!g&&rm(h,[e]));v.useEffect(()=>{if(!d)return;const T=N=>{const S=N.target;S instanceof Node&&m.current&&!m.current.contains(S)&&f(!1)},A=N=>{N.key==="Escape"&&f(!1)};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",A),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",A)}},[d]);const k=T=>{t(T),f(!1)};return l.jsxs("div",{className:"cw-a2a-space-picker cw-viking-kb-picker",ref:m,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:E,"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"选择 VikingDB 知识库",onClick:()=>{p(""),f(T=>!T)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:y}),l.jsx(HD,{className:"cw-a2a-space-trigger-icon"})]}),d&&l.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:h,autoFocus:!0,autoComplete:"off","aria-label":"搜索 VikingDB 知识库",placeholder:"搜索名称或 ID",onChange:T=>p(T.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"VikingDB 知识库",children:[_&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>k(e),children:e}),b.map(T=>{const A=ly(T),N=T.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":N,className:`cw-a2a-space-option ${N?"is-selected":""}`,title:`${A} (${T.id})`,onClick:()=>k(T.id),children:A},T.id)}),!_&&b.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的知识库"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:"刷新知识库列表","aria-label":"刷新知识库列表",disabled:s,onClick:()=>u(T=>T+1),children:s?l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(zD,{className:"cw-i cw-i-sm"})})]}),a?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:a})]}):s?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 VikingDB 知识库…"]}):n.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 VikingDB 知识库。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",n.length," 个知识库,选择的知识库会用于当前 Agent。"]})]})}function Nse({tools:e,onChange:t}){const n=(i,a)=>t(e.map((o,c)=>c===i?{...o,...a}:o)),r=i=>t(e.filter((a,o)=>o!==i)),s=()=>t([...e,{name:"",transport:"http",url:""}]);return l.jsxs("div",{className:"cw-mcp",children:[e.length>0&&l.jsx("div",{className:"cw-mcp-list",children:l.jsx(Js,{initial:!1,children:e.map((i,a)=>l.jsxs(Rt.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:[l.jsxs("div",{className:"cw-mcp-rowhead",children:[l.jsxs("div",{className:"cw-mcp-transport",children:[l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${i.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":i.transport==="http",children:l.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${i.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":i.transport==="stdio",children:l.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>r(a),"aria-label":"移除 MCP 工具",children:l.jsx(mc,{className:"cw-i cw-i-sm"})})]}),l.jsx("input",{className:"cw-input",value:i.name,placeholder:"名称(用于命名,可留空)",onChange:o=>n(a,{name:o.target.value})}),i.transport==="http"?l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:i.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:o=>n(a,{url:o.target.value})}),l.jsx("input",{className:"cw-input",value:i.authToken??"",placeholder:"Bearer Token(可选)",onChange:o=>n(a,{authToken:o.target.value})})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:i.command??"",placeholder:"启动命令,例如 npx",onChange:o=>n(a,{command:o.target.value})}),l.jsx("input",{className:"cw-input",value:(i.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:o=>n(a,{args:o.target.value.split(/\s+/).filter(Boolean)})}),l.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),l.jsxs("button",{type:"button",className:"cw-add-sub",onClick:s,children:[l.jsx(Ps,{className:"cw-i"}),"添加 MCP 工具"]}),e.length===0&&l.jsx("p",{className:"cw-empty-line",children:"暂无 MCP 工具,点击「添加 MCP 工具」连接外部 MCP 服务。"})]})}function YD({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M5.5 7.5h10.75a2 2 0 0 1 2 2v7.75a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V9.5a2 2 0 0 1 2-2Z"}),l.jsx("path",{d:"M7 4.75h9.5a2 2 0 0 1 2 2",opacity:".58"}),l.jsx("path",{d:"m11 10.25.72 1.48 1.63.24-1.18 1.15.28 1.62-1.45-.77-1.45.77.28-1.62-1.18-1.15 1.63-.24.72-1.48Z"}),l.jsx("path",{d:"M19.25 11.25h1.5M20 10.5V12",opacity:".72"})]})}function Ase({s:e,onRemove:t}){let n=ho,r="火山 Find Skill 技能广场";return e.source==="local"?(n=vx,r="本地"):e.source==="skillspace"&&(n=YD,r="AgentKit Skills 中心"),l.jsxs(Rt.div,{className:"cw-selected-skill-row",layout:!0,initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16},children:[l.jsx("span",{className:"cw-selected-skill-icon","aria-hidden":!0,children:l.jsx(n,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-selected-skill-meta",children:[l.jsx("span",{className:"cw-selected-skill-name",children:e.name}),l.jsxs("span",{className:"cw-selected-skill-detail",children:[r,e.description?` · ${hs(e.description)}`:""]})]}),l.jsx("button",{type:"button",className:"cw-selected-skill-remove",onClick:t,"aria-label":`移除 ${e.name}`,title:`移除 ${e.name}`,children:l.jsx(Wr,{className:"cw-i cw-i-sm"})})]},`${e.source}:${e.folder}:${e.skillId||e.slug||""}:${e.version||""}`)}const cy=[{id:"local",label:"本地文件",icon:vx},{id:"skillspace",label:"AgentKit Skills 中心",icon:YD},{id:"skillhub",label:"火山 Find Skill 技能广场",icon:_x}];function Cse({selected:e,onChange:t}){const[n,r]=v.useState("local"),[s,i]=v.useState(!1),a=cy.findIndex(c=>c.id===n),o=c=>t(e.filter(u=>uy(u)!==c));return v.useEffect(()=>{if(!s)return;const c=u=>{u.key==="Escape"&&i(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),l.jsxs("div",{className:"cw-skillspane",children:[l.jsxs("button",{type:"button",className:"cw-skill-add","aria-haspopup":"dialog",onClick:()=>i(!0),children:[l.jsx("span",{className:"cw-skill-add-icon","aria-hidden":!0,children:l.jsx(Ps,{className:"cw-i"})}),l.jsx("span",{children:"添加 Skill"})]}),e.length>0&&l.jsxs("div",{className:"cw-skill-selected",children:[l.jsxs("span",{className:"cw-skill-selected-label",children:["已加入技能 · ",e.length]}),l.jsx("div",{className:"cw-selected-skill-list",children:l.jsx(Js,{initial:!1,children:e.map(c=>l.jsx(Ase,{s:c,onRemove:()=>o(uy(c))},uy(c)))})})]}),l.jsx(Js,{children:s&&l.jsx(Rt.div,{className:"cw-skill-dialog-backdrop",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},onMouseDown:c=>{c.target===c.currentTarget&&i(!1)},children:l.jsxs(Rt.div,{className:"cw-skill-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"cw-skill-dialog-title",initial:{opacity:0,y:10,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.99},transition:{duration:.18,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-skill-dialog-head",children:[l.jsx("h3",{id:"cw-skill-dialog-title",children:"添加 Skill"}),l.jsx("button",{type:"button",className:"cw-skill-dialog-close","aria-label":"关闭添加 Skill",onClick:()=>i(!1),children:l.jsx(Wr,{className:"cw-i"})})]}),l.jsxs("div",{className:"cw-skill-dialog-body",children:[l.jsxs("div",{className:"cw-skill-sourcetabs",role:"tablist",style:{"--cw-skill-tab-slider-width":`calc((100% - 16px) / ${cy.length})`,"--cw-active-skill-tab-offset":`calc(${a*100}% + ${a*4}px)`},children:[l.jsx("span",{className:"cw-skill-tab-slider","aria-hidden":!0}),cy.map(({id:c,label:u,icon:d})=>l.jsxs("button",{type:"button",role:"tab",id:`cw-skill-tab-${c}`,"aria-controls":"cw-skill-tabpanel","aria-selected":n===c,className:`cw-skill-pickertab ${n===c?"is-on":""}`,onClick:()=>r(c),children:[l.jsx(d,{className:"cw-i cw-i-sm"}),u]},c))]}),l.jsxs("div",{id:"cw-skill-tabpanel",className:"cw-skill-tabbody",role:"tabpanel","aria-labelledby":`cw-skill-tab-${n}`,children:[n==="skillhub"&&l.jsx(ese,{selected:e,onChange:t}),n==="local"&&l.jsx(dse,{selected:e,onChange:t}),n==="skillspace"&&l.jsx(fse,{selected:e,onChange:t})]})]})]})})})]})}function uy(e){return e.source==="skillhub"?`hub:${e.namespace}/${e.slug}`:e.source==="local"?`local:${e.folder}`:`ss:${e.skillSpaceId}/${e.skillId}/${e.version||""}`}function qc({checked:e,onChange:t,title:n,desc:r,icon:s}){return l.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[l.jsx("span",{className:"cw-toggle-icon",children:l.jsx(s,{className:"cw-i"})}),l.jsxs("span",{className:"cw-toggle-text",children:[l.jsx("span",{className:"cw-toggle-title",children:n}),l.jsx("span",{className:"cw-toggle-desc",children:hs(r)})]}),l.jsx("span",{className:"cw-switch","aria-hidden":!0,children:l.jsx(Rt.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}const yN=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function Ise(e,t){var r;let n=e;for(const s of t)if(n=(r=n.subAgents)==null?void 0:r[s],!n)return!1;return!0}function Gh(e,t){let n=e;for(const r of t)n=n.subAgents[r];return n}function rf(e,t,n){if(t.length===0)return n(e);const[r,...s]=t,i=e.subAgents.slice();return i[r]=rf(i[r],s,n),{...e,subAgents:i}}function Rse(e,t){return rf(e,t,n=>({...n,subAgents:[...n.subAgents,_a()]}))}function Lse(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1];return rf(e,n,s=>({...s,subAgents:s.subAgents.filter((i,a)=>a!==r)}))}function Ose(e,t,n,r){return rf(e,t,s=>{const i=s.subAgents.slice(),[a]=i.splice(n,1);return i.splice(r,0,a),{...s,subAgents:i}})}const Mse=e=>e==="sequential"||e==="loop",WD=e=>!nf(e.agentType),Dse=3;function qD(e,t,n=!1){var s;if(nf(e.agentType))return n?"远程 Agent 只能作为子 Agent":(s=e.a2aRegistry)!=null&&s.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const r=Cl(e.name);return r||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":ID(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function GD(e,t,n=[]){const r=[],s=nf(e.agentType),i=qD(e,t,n.length===0);return i&&r.push({path:n,name:s?"远程 Agent":e.name.trim()||"未命名",problem:i}),WD(e)&&e.subAgents.forEach((a,o)=>r.push(...GD(a,t,[...n,o]))),r}function XD(e){return 1+e.subAgents.reduce((t,n)=>t+XD(n),0)}function QD(e){const t=[],n={},r=i=>{var a,o,c,u;for(const d of i.builtinTools??[]){const f=Xl.find(h=>h.id===d);f&&t.push({env:f.env})}if((a=i.a2aRegistry)!=null&&a.enabled&&(t.push({env:y3}),Object.assign(n,KD(i.a2aRegistry,{includeDefaults:!0}))),i.memory.shortTerm&&t.push({env:((o=Gp.find(d=>d.id===(i.shortTermBackend??"local")))==null?void 0:o.env)??[]}),i.memory.longTerm&&t.push({env:((c=Xp.find(d=>d.id===(i.longTermBackend??"local")))==null?void 0:c.env)??[]}),i.knowledgebase&&t.push({env:((u=Qp.find(d=>d.id===(i.knowledgebaseBackend??Ql)))==null?void 0:u.env)??[]}),i.tracing)for(const d of i.tracingExporters??[]){const f=Zp.find(h=>h.id===d);f&&t.push({env:f.env,enableFlag:f.enableFlag})}i.subAgents.forEach(r)};r(e);const s=RD(t);return{specs:s.specs,fixedValues:{...s.fixedValues,...n}}}function ZD({root:e,path:t,selectedPath:n,duplicateNames:r,showErrors:s,validationPulse:i,onSelect:a,onChange:o,onClearRoot:c}){const u=Gh(e,t),d=Iw(u.agentType),f=d.icon,h=t.length===0,p=yN(t,n),m=WD(u),g=m&&t.length{const A=Rse(e,t),N=Gh(A,t).subAgents.length-1;o(A,[...t,N])},y=()=>o(Lse(e,t),t.slice(0,-1)),E=t.slice(0,-1),b=!h&&Mse(Gh(e,E).agentType),[_,k]=v.useState(!1),T=A=>{A.preventDefault(),A.stopPropagation(),k(!1);const N=A.dataTransfer.getData("application/x-agent-path");if(!N)return;let S;try{S=JSON.parse(N)}catch{return}if(!yN(S.slice(0,-1),E))return;const C=S[S.length-1],M=t[t.length-1];C!==M&&o(Ose(e,E,C,M),[...E,M])};return l.jsxs("div",{className:"cw-tree-branch",children:[l.jsxs("div",{className:`cw-tree-node cw-tree-type-${u.agentType??"llm"} ${p?"is-selected":""} ${b?"is-draggable":""} ${_?"is-dragover":""} ${s&&qD(u,r,h)?`is-invalid cw-error-shake-${i%2}`:""}`,role:"button",tabIndex:0,draggable:b,onDragStart:b?A=>{A.dataTransfer.setData("application/x-agent-path",JSON.stringify(t)),A.dataTransfer.effectAllowed="move",A.stopPropagation()}:void 0,onDragOver:b?A=>{A.preventDefault(),k(!0)}:void 0,onDragLeave:b?()=>k(!1):void 0,onDrop:b?T:void 0,onClick:()=>a(t),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),a(t))},children:[l.jsx(f,{className:"cw-tree-icon"}),l.jsxs("span",{className:"cw-tree-main",children:[l.jsx("span",{className:"cw-tree-name",children:nf(u.agentType)?"远程 Agent":u.name.trim()||"未命名"}),l.jsx("span",{className:"cw-tree-type",children:d.label})]}),l.jsxs("span",{className:"cw-tree-actions",children:[h&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-tree-clear",title:"清空根 Agent","aria-label":"清空根 Agent",onClick:A=>{A.stopPropagation(),c()},children:l.jsx(Ese,{className:"cw-i cw-i-sm"})}),g&&l.jsx("button",{type:"button",className:"cw-icon-btn",title:"添加子 Agent",onClick:A=>{A.stopPropagation(),x()},children:l.jsx(Ps,{className:"cw-i cw-i-sm"})}),!h&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",title:"删除",onClick:A=>{A.stopPropagation(),y()},children:l.jsx(mc,{className:"cw-i cw-i-sm"})})]})]}),m&&u.subAgents.length>0&&l.jsx("div",{className:"cw-tree-children",children:u.subAgents.map((A,N)=>l.jsx(ZD,{root:e,path:[...t,N],selectedPath:n,duplicateNames:r,showErrors:s,validationPulse:i,onSelect:a,onChange:o,onClearRoot:c},N))})]})}function S1(e){var t;return{...e,deployment:{feishuEnabled:!!((t=e.deployment)!=null&&t.feishuEnabled)}}}function JD(e){var r,s;const t=QD(e),n={...((r=e.deployment)==null?void 0:r.envValues)??{},...t.fixedValues};return{...S1(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),envValues:Object.fromEntries(LD(t.specs,n).map(({key:i,value:a})=>[i,a]))}}}function bN(e){return JSON.stringify(JD(e))}function Pse({enabled:e,disabledReason:t,phase:n,stale:r,run:s,projectName:i,logs:a,messages:o,input:c,error:u,deploying:d,deployError:f,onInput:h,onSend:p,onRestart:m,onIgnoreChanges:g,onDeploy:x}){const[y,E]=v.useState(!1),b=n==="ready"||n==="sending",_=n==="building"||n==="starting"||n==="sending",k=e&&!s&&n==="idle",T=e&&(n==="building"||n==="starting"),A=!!(s&&r&&!T);return y?l.jsx("aside",{className:"cw-debug is-collapsed","aria-label":"调试窗口(已收起)",children:l.jsx("button",{type:"button",className:"cw-debug-expand",onClick:()=>E(!1),"aria-label":"展开调试栏",title:"展开调试栏",children:l.jsx(xse,{className:"cw-i"})})}):l.jsxs("aside",{className:"cw-debug","aria-label":"调试窗口",children:[l.jsxs("div",{className:"cw-debug-head",children:[l.jsxs("div",{className:"cw-debug-title",children:[l.jsx("button",{type:"button",className:"cw-debug-collapse",onClick:()=>E(!0),"aria-label":"收起调试栏",title:"收起调试栏",children:l.jsx(Nr,{className:"cw-i cw-i-sm"})}),l.jsx("span",{children:"调试"})]}),l.jsx("div",{className:"cw-debug-head-actions",children:l.jsxs("button",{type:"button",className:"cw-debug-deploy",disabled:d,onClick:x,title:"查看源码、填写环境变量并部署",children:["去部署",d?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(IR,{className:"cw-i"})]})})]}),!s&&n==="idle"&&!e&&l.jsx("div",{className:"cw-debug-sub",children:l.jsx("span",{children:t})}),f&&l.jsx("div",{className:"cw-debug-deploy-error",role:"alert",children:f}),l.jsxs("div",{className:"cw-debug-stage",children:[l.jsx("div",{className:"cw-debug-body",children:e?n==="error"?l.jsxs("div",{className:"cw-debug-error",children:[l.jsx(nm,{message:u||"调试失败",className:"cw-debug-error-detail",onRetry:async()=>{await m()}}),a.length>0&&l.jsx("div",{className:"cw-debug-progress",children:a.map((N,S)=>l.jsx("div",{className:"cw-debug-logline",children:l.jsx("span",{children:N})},`${N}-${S}`))})]}):l.jsx("div",{className:"cw-debug-chat",children:o.length===0?l.jsx("div",{className:"cw-debug-chat-empty",children:"输入消息开始验证当前 Agent。"}):o.map((N,S)=>l.jsxs("div",{className:`cw-debug-msg cw-debug-msg-${N.role}`,children:[l.jsx("div",{className:"cw-debug-role",children:N.role==="user"?"你":i||"Agent"}),l.jsx("div",{className:"cw-debug-content",children:N.role==="user"?N.content:N.error?l.jsx(nm,{message:N.error,className:"cw-debug-msg-error"}):N.blocks&&N.blocks.length>0?l.jsx(hw,{blocks:N.blocks,onAction:()=>{}}):N.content?N.content:S===o.length-1&&n==="sending"?l.jsx(D3,{}):null})]},S))}):l.jsx("div",{className:"cw-debug-empty",children:t})}),l.jsx("div",{className:"cw-debug-composer",children:l.jsxs("div",{className:"cw-debug-composerbox",children:[l.jsx("textarea",{className:"cw-debug-input",rows:1,value:c,placeholder:r?"更新 Agent 后可继续调试":b?"输入测试消息...":"调试环境启动后可输入",disabled:!b||_||r,onChange:N=>h(N.target.value),onKeyDown:N=>{P3(N.nativeEvent)||N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),p())}}),l.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!b||_||r||!c.trim(),onClick:p,children:n==="sending"?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(RR,{className:"cw-i"})})]})}),(k||T||A)&&l.jsx("div",{className:"cw-debug-overlay",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"cw-debug-overlay-content",children:[l.jsx("strong",{className:"cw-debug-overlay-title",children:T?"正在初始化调试环境":A?"Agent 配置已变更":"启动调试环境"}),T?l.jsx("div",{className:"cw-debug-overlay-progress",children:a.map((N,S)=>l.jsxs("div",{className:"cw-debug-logline",children:[S===a.length-1?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(Bs,{className:"cw-i"}),l.jsx("span",{children:N})]},`${N}-${S}`))}):A?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"cw-debug-overlay-copy",children:"当前对话仍在使用上一次配置。更新后,新配置才会生效。"}),l.jsxs("div",{className:"cw-debug-overlay-actions",children:[l.jsx("button",{type:"button",className:"cw-debug-ignore",disabled:_,onClick:g,children:"忽略"}),l.jsxs("button",{type:"button",className:"cw-debug-start",disabled:_,onClick:m,children:[l.jsx(kx,{className:"cw-i"}),"更新 Agent"]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"cw-debug-overlay-copy",children:"启动后会生成代码并创建临时运行环境。"}),l.jsxs("button",{type:"button",className:"cw-debug-start",onClick:m,children:[l.jsx(wse,{className:"cw-i cw-debug-run-icon"}),"启动调试环境"]})]})]})})]})]})}function jse({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:r,features:s,onDeploymentTaskChange:i}){var Yn,nr,vn,$t,an,Cn,Wn,on,Mr,Fn,In,qn,Zr,Hs,ps;const[a,o]=v.useState(()=>r??_a()),[c,u]=v.useState(!1),[d,f]=v.useState(0),[h,p]=v.useState(null),[m,g]=v.useState(!1),[x,y]=v.useState("cn-beijing"),E=(s==null?void 0:s.generatedAgentTestRun)===!0,b=(s==null?void 0:s.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[_,k]=v.useState("idle"),[T,A]=v.useState(null),N=v.useRef(null),[S,C]=v.useState(null),[M,U]=v.useState(""),[q,P]=v.useState([]),[D,I]=v.useState([]),[L,O]=v.useState(""),[B,R]=v.useState(null),[z,Y]=v.useState(""),[j,re]=v.useState(""),[V,ee]=v.useState("basic"),[oe,X]=v.useState(""),[ae,Z]=v.useState(!1),[de,ye]=v.useState(!1),[Q,ge]=v.useState(!1),[be,_e]=v.useState(!1),[Pe,we]=v.useState([]),ht=v.useRef(null),je=v.useRef({});v.useEffect(()=>()=>{const ne=N.current;ne&&Wb(ne.runId).catch(Ce=>console.warn("清理调试运行失败",Ce))},[]);const Fe=v.useRef(null);Fe.current||(Fe.current=({meta:ne,children:Ce})=>l.jsxs("section",{ref:He=>{je.current[ne.id]=He},id:`cw-sec-${ne.id}`,"data-step-id":ne.id,className:"cw-section",children:[l.jsx("header",{className:"cw-sec-head",children:l.jsxs("h2",{className:"cw-sec-title",children:[ne.label,ne.required&&l.jsx("span",{className:"cw-sec-required",children:"必填"})]})}),Ce]}));const ut=Ise(a,Pe)?Pe:[],he=Gh(a,ut),Et=ut.length===0,mt=`cw-model-advanced-${ut.join("-")||"root"}`,W=`cw-a2a-registry-advanced-${ut.join("-")||"root"}`,J=`cw-more-tool-types-${ut.join("-")||"root"}`,ce=`cw-advanced-config-${ut.join("-")||"root"}`,ke=Math.max(0,ah.findIndex(ne=>ne.id===(he.agentType??"llm"))),pe=ne=>o(Ce=>rf(Ce,ut,He=>({...He,...ne}))),Xe=(ne,Ce)=>o(He=>{var ct;return{...He,deployment:{...He.deployment??{feishuEnabled:!1},envValues:{...((ct=He.deployment)==null?void 0:ct.envValues)??{},[ne]:Ce}}}}),St=ne=>pe({a2aRegistry:{...he.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...ne}}),We=(ne,Ce)=>{if(!(ne in mN))return;const He=mN[ne];St({[He]:Ce}),Xe(ne,Ce)},Sn=ne=>{if(!(Et&&ne==="a2a")){if(ne==="a2a"){pe({agentType:ne,a2aRegistry:{...he.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}pe({agentType:ne,a2aRegistry:he.a2aRegistry?{...he.a2aRegistry,enabled:!1}:void 0})}},Me=(ne,Ce)=>{o(ne),Ce&&we(Ce)},wt=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(o(_a()),we([]),u(!1),_e(!1))},vt=he.builtinTools??[],Ct=he.mcpTools??[],Gt=he.tracingExporters??[],Ve=he.selectedSkills??[],ot=[he.memory.shortTerm,he.memory.longTerm,he.tracing].filter(Boolean).length,_t=ne=>pe({builtinTools:vt.includes(ne)?vt.filter(Ce=>Ce!==ne):[...vt,ne]}),kt=ne=>{const Ce=Gt.includes(ne)?Gt.filter(He=>He!==ne):[...Gt,ne];pe({tracingExporters:Ce,tracing:Ce.length>0?!0:he.tracing})},le=ID(he.agentType),Le=nf(he.agentType),Ge=v.useMemo(()=>jD(a),[a]),Bt=Le?null:Cl(he.name)??(Ge.has(he.name)?"Agent 名称在当前结构中必须唯一":null),Nn=Bt!==null,nn=!Le&&he.description.trim().length===0,Ft=he.instruction.trim().length===0,Ut=Le&&!((Yn=he.a2aRegistry)!=null&&Yn.registrySpaceId.trim()),wn=ne=>c&&ne?`is-error cw-error-shake-${d%2}`:"",dn=v.useMemo(()=>GD(a,Ge),[a,Ge]),rn=dn.length===0,fn=v.useMemo(()=>bN(a),[a]),se=v.useMemo(()=>QD(a),[a]),ue=!!(T&&z&&z!==fn&&j!==fn);v.useEffect(()=>{j&&j!==fn&&re("")},[fn,j]);const Te=v.useMemo(()=>{var ne,Ce,He,ct;return{type:!0,basic:Le?!Ut:!Nn&&(le||!Ft),model:!!((ne=he.modelName)!=null&&ne.trim()||(Ce=he.modelProvider)!=null&&Ce.trim()||(He=he.modelApiBase)!=null&&He.trim()),tools:vt.length>0||Ct.length>0,skills:Ve.length>0,knowledge:he.knowledgebase,advanced:he.memory.shortTerm||he.memory.longTerm||he.tracing,subagents:(((ct=he.subAgents)==null?void 0:ct.length)??0)>0,review:rn}},[he,Nn,Ft,le,Le,rn,vt,Ct,Ve]),$e=le||Le?["basic"]:["basic","model","tools","skills","knowledge",...Et?["advanced"]:[]],Ie=pN.filter(ne=>$e.includes(ne.id)),lt=$e.join("|"),Nt=ut.join("."),Kn=Ie.findIndex(ne=>ne.id===V),sn=ne=>{var Ce;(Ce=je.current[ne])==null||Ce.scrollIntoView({behavior:"smooth",block:"start"})};v.useEffect(()=>{if(h)return;const ne=ht.current;if(!ne)return;const Ce=lt.split("|");let He=0;const ct=()=>{He=0;const hn=Ce[Ce.length-1];let gt=Ce[0];if(ne.scrollTop+ne.clientHeight>=ne.scrollHeight-2)gt=hn;else{const Gn=ne.getBoundingClientRect().top+24;for(const Xn of Ce){const fr=je.current[Xn];if(!fr||fr.getBoundingClientRect().top>Gn)break;gt=Xn}}gt&&ee(Gn=>Gn===gt?Gn:gt)},Ht=()=>{He||(He=window.requestAnimationFrame(ct))};return ct(),ne.addEventListener("scroll",Ht,{passive:!0}),window.addEventListener("resize",Ht),()=>{ne.removeEventListener("scroll",Ht),window.removeEventListener("resize",Ht),He&&window.cancelAnimationFrame(He)}},[h,lt,Nt]);const Pn=()=>rn?!0:(u(!0),f(ne=>ne+1),dn[0]&&(we(dn[0].path),window.requestAnimationFrame(()=>sn("basic"))),!1),Mt=async()=>{const ne=N.current;if(N.current=null,A(null),C(null),Y(""),re(""),ne)try{await Wb(ne.runId)}catch(Ce){console.warn("清理调试运行失败",Ce)}},jn=async()=>{if(X(""),!!Pn()){g(!0);try{const ne=await Bp(S1(a));await Mt(),k("idle"),U(""),P([]),I([]),O(""),R(null),p(ne)}catch(ne){X(`打开部署页失败:${ne instanceof Error?ne.message:String(ne)}`)}finally{g(!1)}}},Qr=async()=>{if(!E||m||!Pn())return;const ne=bN(a);re(""),R(null),I([]),O(""),P([]),k("building");try{await Mt();const Ce=[],He=hn=>{Ce.push(hn),P([...Ce])};He("提交 Agent 配置"),k("starting"),He("初始化调试环境");const ct=await TL(JD(a));N.current=ct,A(ct),U(ct.appName),He("创建调试会话");const Ht=await SL(ct.runId,"test_user");C(Ht),Y(ne),He("调试环境就绪"),k("ready")}catch(Ce){R(Ce instanceof Error?Ce.message:String(Ce)),k("error")}},vr=async()=>{const ne=N.current,Ce=S,He=L.trim();if(!(!ne||!Ce||!He||_==="sending")){O(""),k("sending"),I(ct=>[...ct,{role:"user",content:He},{role:"assistant",content:"",blocks:[]}]);try{let ct=Ns(),Ht="";for await(const hn of NL({runId:ne.runId,userId:"test_user",sessionId:Ce,text:He})){const gt=hn.error||hn.errorMessage||hn.error_message;if(gt){I(Gn=>{const Xn=[...Gn],fr=Xn[Xn.length-1];return(fr==null?void 0:fr.role)==="assistant"&&(fr.error=String(gt)),Xn});break}ct=zl(ct,hn),Ht=ct.blocks.filter(Gn=>Gn.kind==="text").map(Gn=>Gn.text).join(""),I(Gn=>{const Xn=[...Gn],fr=Xn[Xn.length-1];return(fr==null?void 0:fr.role)==="assistant"&&(fr.content=Ht,fr.blocks=ct.blocks),Xn})}k("ready")}catch(ct){I(Ht=>{const hn=[...Ht],gt=hn[hn.length-1];return(gt==null?void 0:gt.role)==="assistant"&&(gt.error=ct instanceof Error?ct.message:String(ct)),hn}),k("ready")}}};if(h){const ne=async(Ce,He,ct)=>{var gt;const Ht=(gt=a.deployment)==null?void 0:gt.network,hn=Ht&&Ht.mode&&Ht.mode!=="public"?{mode:Ht.mode,vpc_id:Ht.vpcId,subnet_ids:Ht.subnetIds,enable_shared_internet_access:Ht.enableSharedInternetAccess}:void 0;return Um(Ce.name,Ce.files,{region:x,projectName:"default",network:hn},{...ct,onStage:He})};return l.jsx("div",{className:"cw-root cw-root-preview",children:l.jsx("div",{className:"cw-preview-body",children:l.jsx(lg,{project:h,agentDraft:a,agentName:a.name||"未命名 Agent",agentCount:XD(a),onChange:p,onDeploy:ne,onAgentAdded:n,onDeploymentTaskChange:i,feishuEnabled:!!((nr=a.deployment)!=null&&nr.feishuEnabled),onFeishuEnabledChange:async Ce=>{const He={...a,deployment:{...a.deployment??{feishuEnabled:!1},feishuEnabled:Ce}},ct=await Bp(S1(He));o(He),p(ct)},deploymentEnv:se.specs,deploymentEnvValues:{...(vn=a.deployment)==null?void 0:vn.envValues,...se.fixedValues},onDeploymentEnvChange:Xe,network:($t=a.deployment)==null?void 0:$t.network,onNetworkChange:Ce=>o(He=>({...He,deployment:{...He.deployment??{feishuEnabled:!1},network:Ce}})),deployRegion:x,onDeployRegionChange:y,onBack:()=>p(null),onExportYaml:()=>bse(`${a.name||"agent"}.yaml`,xre(a),"text/yaml")})})})}const An=Fe.current,Bn=ne=>pN.find(Ce=>Ce.id===ne);return l.jsx("div",{className:"cw-root",children:l.jsxs("div",{className:"cw-editor",children:[l.jsxs("aside",{className:"cw-tree","aria-label":"Agent 结构",children:[l.jsx("div",{className:"cw-tree-head",children:"Agent 结构"}),l.jsx(ZD,{root:a,path:[],selectedPath:ut,duplicateNames:Ge,showErrors:c,validationPulse:d,onSelect:we,onChange:Me,onClearRoot:wt})]}),l.jsxs("div",{className:"cw-detail",children:[l.jsx("div",{className:"cw-typebar",children:l.jsx("div",{className:"cw-typebar-inner",children:l.jsxs("div",{className:"cw-typeradio cw-typeradio--row",role:"radiogroup","aria-label":"Agent 类型",style:{"--cw-agent-type-gap":`${iy}px`,"--cw-agent-type-slider-width":`calc((100% - ${8+iy*(ah.length-1)}px) / ${ah.length})`,"--cw-active-type-offset":`calc(${ke*100}% + ${ke*iy}px)`},children:[l.jsx("span",{className:"cw-typeradio-slider","aria-hidden":!0}),ah.map(ne=>{const Ce=(he.agentType??"llm")===ne.id,He=Et&&ne.id==="a2a",ct=He?"cw-remote-agent-disabled-hint":void 0;return l.jsxs("label",{className:`cw-typeradio-item ${Ce?"is-on":""} ${He?"is-disabled":""}`,title:He?void 0:ne.desc,tabIndex:He?0:void 0,"aria-describedby":ct,children:[l.jsx("input",{type:"radio",name:"agentType",className:"cw-typeradio-input",checked:Ce,disabled:He,onChange:()=>Sn(ne.id)}),l.jsxs("span",{className:"cw-typeradio-title",children:[vse[ne.id].replace("智能体",""),l.jsx("wbr",{}),"智能体"]}),He&&l.jsx("span",{id:ct,className:"cw-typeradio-disabled-hint",role:"tooltip",children:"远程 Agent 仅可作为子 Agent"})]},ne.id)})]})})}),l.jsx("div",{className:"cw-detail-scroll",ref:ht,children:l.jsx("div",{className:"cw-detail-inner",children:l.jsxs("div",{className:"cw-lower",children:[l.jsxs("div",{className:"cw-form-col",children:[l.jsx(An,{meta:Bn("basic"),children:l.jsxs("div",{className:"cw-form",children:[!Le&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["Agent 名称",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("input",{className:`cw-input ${wn(Nn)}`,value:he.name,placeholder:"customer_service",onChange:ne=>pe({name:ne.target.value})}),c&&Bt?l.jsx("span",{className:"cw-error-text",children:Bt}):l.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在 Agent 结构中保持唯一。"})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["描述",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${wn(nn)}`,value:he.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…",onChange:ne=>pe({description:ne.target.value})}),c&&nn?l.jsx("span",{className:"cw-error-text",children:"描述为必填项"}):l.jsx("span",{className:"cw-help",children:"描述会显示在 Agent 列表与选择器中。"})]})]}),le?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"cw-section-desc",children:"编排型 Agent 只负责调度子 Agent,不需要模型或系统提示词。请在左侧 「Agent 结构」中为它添加、排序子 Agent。"}),he.agentType==="loop"&&l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"最大轮次"}),l.jsx("input",{className:"cw-input",type:"number",min:1,value:he.maxIterations??3,onChange:ne=>pe({maxIterations:Math.max(1,Number(ne.target.value)||1)})}),l.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):Le?l.jsxs("div",{className:"cw-field cw-remote-center-fields",children:[l.jsxs("div",{className:"cw-remote-center-head",children:[l.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),l.jsx(Tse,{value:((an=he.a2aRegistry)==null?void 0:an.registrySpaceId)??"",region:((Cn=he.a2aRegistry)==null?void 0:Cn.registryRegion)||Ms.region,invalid:c&&Ut,onChange:ne=>We(VD,ne)}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":de,"aria-controls":W,onClick:()=>ye(ne=>!ne),children:[l.jsx("span",{children:"更多选项"}),l.jsx(Nr,{className:`cw-more-options-chevron ${de?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:de&&l.jsx(Rt.div,{id:W,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:l.jsx(Ho,{env:_se,values:KD(he.a2aRegistry,{includeDefaults:!1}),onChange:We})})}),c&&Ut&&l.jsx("span",{className:"cw-error-text",children:"请选择 AgentKit 智能体中心"})]}):l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["系统提示词",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:l.jsx(yse,{value:he.instruction,invalid:Ft,onChange:ne=>pe({instruction:ne})})}),c&&Ft?l.jsx("span",{className:"cw-error-text",children:"系统提示词为必填项"}):l.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!le&&!Le&&l.jsxs(l.Fragment,{children:[l.jsx(An,{meta:Bn("model"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型名称"}),l.jsx("input",{className:"cw-input",value:he.modelName??"",placeholder:"doubao-seed-2-1-pro-260628",onChange:ne=>pe({modelName:ne.target.value})})]}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":ae,"aria-controls":mt,onClick:()=>Z(ne=>!ne),children:[l.jsx("span",{children:"更多选项"}),l.jsx(Nr,{className:`cw-more-options-chevron ${ae?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:ae&&l.jsxs(Rt.div,{id:mt,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:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"服务商 Provider"}),l.jsx("input",{className:"cw-input",value:he.modelProvider??"",placeholder:"openai",onChange:ne=>pe({modelProvider:ne.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Base"}),l.jsx("input",{className:"cw-input",value:he.modelApiBase??"",placeholder:"https://ark.cn-beijing.volces.com/api/v3/",onChange:ne=>pe({modelApiBase:ne.target.value})}),l.jsx("span",{className:"cw-help",children:"留空则使用 VeADK 默认模型配置;Ark API Key 会由 Studio 服务端凭据自动获取。其他服务商的 Key 可在部署页添加。"})]})]})})]})}),l.jsx(An,{meta:Bn("tools"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"内置工具"}),l.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),l.jsx("div",{className:"cw-tools-list-shell",children:l.jsx(gN,{items:Xl,selected:vt,onToggle:_t,scrollRows:6})}),l.jsx(Js,{initial:!1,children:vt.includes("run_code")&&l.jsxs(Rt.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:[l.jsxs("div",{className:"cw-tool-config-head",children:[l.jsx("span",{className:"cw-label",children:"代码执行配置"}),l.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),l.jsx(Ho,{env:((Wn=Xl.find(ne=>ne.id==="run_code"))==null?void 0:Wn.env)??[],values:((on=a.deployment)==null?void 0:on.envValues)??{},onChange:Xe})]})})]}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":Q,"aria-controls":J,onClick:()=>ge(ne=>!ne),children:[l.jsx("span",{children:"更多类型工具"}),Ct.length>0&&l.jsxs("span",{className:"cw-more-options-count",children:["已配置 ",Ct.length]}),l.jsx(Nr,{className:`cw-more-options-chevron ${Q?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:Q&&l.jsx(Rt.div,{id:J,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:l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"MCP 工具"}),l.jsx("span",{className:"cw-help",children:"连接外部 MCP 服务,生成时会为每个条目创建对应的 MCPToolset。"}),l.jsx(Nse,{tools:Ct,onChange:ne=>pe({mcpTools:ne})})]})})})]})}),l.jsx(An,{meta:Bn("skills"),children:l.jsx("div",{className:"cw-form",children:l.jsx(Cse,{selected:Ve,onChange:ne=>pe({selectedSkills:ne})})})}),l.jsx(An,{meta:Bn("knowledge"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.knowledgebase,onChange:ne=>pe({knowledgebase:ne}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:Mh}),he.knowledgebase&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"知识库后端"}),l.jsx(ay,{options:Qp,value:he.knowledgebaseBackend,onChange:ne=>pe({knowledgebaseBackend:ne,knowledgebaseIndex:ne==="viking"?he.knowledgebaseIndex:""})}),(he.knowledgebaseBackend??Ql)==="viking"&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),l.jsx(Sse,{value:he.knowledgebaseIndex??"",onChange:ne=>pe({knowledgebaseIndex:ne})})]}),l.jsx(Ho,{env:((Mr=Qp.find(ne=>ne.id===(he.knowledgebaseBackend??Ql)))==null?void 0:Mr.env)??[],values:((Fn=a.deployment)==null?void 0:Fn.envValues)??{},onChange:Xe})]})]})}),Et&&l.jsxs("section",{ref:ne=>{je.current.advanced=ne},id:"cw-sec-advanced","data-step-id":"advanced",className:"cw-section cw-advanced-section",children:[l.jsxs("button",{type:"button",className:"cw-advanced-disclosure","aria-expanded":be,"aria-controls":ce,onClick:()=>_e(ne=>!ne),children:[l.jsx("span",{className:"cw-advanced-disclosure-title",children:"进阶配置"}),l.jsx(Nr,{className:`cw-advanced-disclosure-chevron ${be?"is-open":""}`,"aria-hidden":!0}),ot>0&&l.jsxs("span",{className:"cw-more-options-count",children:["已启用 ",ot]})]}),l.jsx(Js,{initial:!1,children:be&&l.jsxs(Rt.div,{id:ce,className:"cw-advanced-content",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-advanced-group",children:[l.jsx("div",{className:"cw-advanced-group-head",children:l.jsx("span",{children:"记忆"})}),l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.memory.shortTerm,onChange:ne=>pe({memory:{...he.memory,shortTerm:ne}}),title:"短期记忆",desc:"在单次会话内保留上下文,跨轮次记住对话内容。",icon:FR}),he.memory.shortTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"短期记忆后端"}),l.jsx(ay,{options:Gp,value:he.shortTermBackend,onChange:ne=>pe({shortTermBackend:ne})}),l.jsx(Ho,{env:((In=Gp.find(ne=>ne.id===(he.shortTermBackend??"local")))==null?void 0:In.env)??[],values:((qn=a.deployment)==null?void 0:qn.envValues)??{},onChange:Xe})]}),l.jsx(qc,{checked:he.memory.longTerm,onChange:ne=>pe({memory:{...he.memory,longTerm:ne}}),title:"长期记忆",desc:"跨会话持久化关键信息,让 Agent 记住历史偏好。",icon:Mh}),he.memory.longTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"长期记忆后端"}),l.jsx(ay,{options:Xp,value:he.longTermBackend,onChange:ne=>pe({longTermBackend:ne})}),l.jsx(Ho,{env:((Zr=Xp.find(ne=>ne.id===(he.longTermBackend??"local")))==null?void 0:Zr.env)??[],values:((Hs=a.deployment)==null?void 0:Hs.envValues)??{},onChange:Xe}),l.jsx(qc,{checked:!!he.autoSaveSession,onChange:ne=>pe({autoSaveSession:ne}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:Mh})]})]})]}),l.jsxs("div",{className:"cw-advanced-group",children:[l.jsx("div",{className:"cw-advanced-group-head",children:l.jsx("span",{children:"观测"})}),l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.tracing,onChange:ne=>pe({tracing:ne}),title:"观测 / Tracing",desc:"记录每一步的调用链路与耗时,便于调试与性能分析。",icon:MR}),he.tracing&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"Tracing 导出器"}),l.jsx("span",{className:"cw-help",children:"选择一个或多个观测平台,生成时会写入对应的 ENABLE_* 开关与环境变量。"}),l.jsx(gN,{items:Zp,selected:Gt,onToggle:kt}),l.jsx(Ho,{env:Zp.filter(ne=>Gt.includes(ne.id)).flatMap(ne=>ne.env),values:((ps=a.deployment)==null?void 0:ps.envValues)??{},onChange:Xe})]})]})]})]})})]})]})]}),l.jsx("nav",{className:"cw-rail","aria-label":"步骤导航",children:l.jsxs("ol",{className:"cw-steps",children:[l.jsx("div",{className:"cw-rail-track","aria-hidden":!0,children:l.jsx(Rt.div,{className:"cw-rail-fill",animate:{height:`${Math.max(Kn,0)/Math.max(Ie.length-1,1)*100}%`},transition:{type:"spring",stiffness:260,damping:32}})}),Ie.map(ne=>{const Ce=ne.id===V,He=Te[ne.id];return l.jsx("li",{children:l.jsxs("button",{type:"button",className:`cw-step ${Ce?"is-active":""} ${He?"is-done":""}`,onClick:()=>sn(ne.id),"aria-current":Ce?"step":void 0,"aria-label":ne.label,children:[l.jsx("span",{className:"cw-step-marker","aria-hidden":!0,children:Ce?l.jsx("span",{className:"cw-dot"}):He?l.jsx(Bs,{className:"cw-step-check"}):l.jsx("span",{className:"cw-dot"})}),l.jsx("span",{className:"cw-step-tooltip","aria-hidden":!0,children:ne.label})]})},ne.id)})]})})]})})})]}),l.jsx(Pse,{enabled:E,disabledReason:b,phase:_,stale:ue,run:T,projectName:M||a.name,logs:q,messages:D,input:L,error:B,deploying:m,deployError:oe,onInput:O,onSend:vr,onRestart:Qr,onIgnoreChanges:()=>re(fn),onDeploy:jn})]})})}function gi(e){return{..._a(),...e}}const Bse=[{id:"support",icon:g7,draft:gi({name:"客服助手",description:"7×24 在线答疑,结合知识库与历史对话,稳定、礼貌地解决用户问题。",instruction:"你是一名专业、耐心的客服助手。请始终保持礼貌、友好的语气,优先依据知识库中的资料回答用户问题;当资料不足以确定答案时,如实告知用户并主动引导其提供更多信息,切勿编造。回答尽量简洁、分点清晰,必要时给出操作步骤。",model:"doubao-1.5-pro-32k",knowledgebase:!0,memory:{shortTerm:!0,longTerm:!0}})},{id:"analyst",icon:ZU,draft:gi({name:"数据分析师",description:"运行代码完成统计与可视化,开启链路追踪,分析过程可观测、可复现。",instruction:"你是一名严谨的数据分析师。面对数据问题时,先厘清分析目标与口径,再通过编写并运行代码完成清洗、统计与可视化。每一步都要说明你的假设与方法,给出结论时附上关键数据支撑,并指出潜在的偏差与局限。",model:"doubao-1.5-pro-32k",tools:["code_runner"],tracing:!0})},{id:"translator",icon:y7,draft:gi({name:"翻译助手",description:"中英互译,忠实、通顺、地道,保留原文语气与专业术语。",instruction:"你是一名专业的翻译助手,精通中英互译。请在忠实于原文含义的前提下,使译文自然、地道、符合目标语言表达习惯;保留专有名词与专业术语的准确性,并尽量贴合原文的语气与风格。仅输出译文,除非用户额外要求解释。",model:"doubao-1.5-pro-32k"})},{id:"coder",icon:bx,draft:gi({name:"代码助手",description:"编写、调试与重构代码,可运行代码验证结果,给出清晰可维护的实现。",instruction:"你是一名资深软件工程师。请根据需求编写正确、清晰、可维护的代码,遵循目标语言的惯用风格与最佳实践。在不确定时通过运行代码验证你的实现,给出关键的边界条件与测试思路,并对复杂逻辑附上简要注释。",model:"doubao-1.5-pro-32k",tools:["code_runner","file_reader"],tracing:!0})},{id:"researcher",icon:T7,draft:gi({name:"研究员",description:"联网检索一手资料,结合知识库与长期记忆,输出有据可查的研究结论。",instruction:"你是一名严谨的研究员。面对研究问题时,先拆解关键子问题,再通过联网检索收集多个一手、可信的来源,交叉验证后再下结论。结论需注明出处与不确定性,区分事实与推断,避免以偏概全。",model:"doubao-1.5-pro-32k",tools:["web_search"],knowledgebase:!0,memory:{shortTerm:!0,longTerm:!0}})},{id:"research-team",icon:B7,draft:gi({name:"多智能体研究团队",description:"由检索员、分析员、撰写员协作的研究编排,分工完成端到端调研报告。",instruction:"你是一支研究团队的总协调者。负责拆解用户的研究任务,将检索、分析、撰写分别委派给对应的子 Agent,汇总各子 Agent 的产出,把控整体质量,最终输出结构清晰、有据可查的研究报告。",model:"doubao-1.5-pro-32k",tracing:!0,memory:{shortTerm:!0,longTerm:!0},subAgents:[gi({name:"检索员",description:"联网搜集与课题相关的一手资料与数据。",instruction:"你是研究团队中的检索员。根据课题联网检索多个可信来源,整理出关键事实、数据与原文出处,交付给分析员,不做主观结论。",tools:["web_search"]}),gi({name:"分析员",description:"对检索到的材料做交叉验证与归纳分析。",instruction:"你是研究团队中的分析员。对检索员提供的材料做交叉验证、归纳与对比,提炼洞见、识别矛盾与不确定性,形成结构化的分析要点。",tools:["code_runner"]}),gi({name:"撰写员",description:"将分析结论组织为结构清晰、引用规范的报告。",instruction:"你是研究团队中的撰写员。把分析员的要点组织成结构清晰、语言通顺、引用规范的研究报告,确保每个结论都能追溯到来源。"})]})}];function Fse(e){const t=[];return e.tools.length&&t.push({icon:zR,label:"工具"}),(e.memory.shortTerm||e.memory.longTerm)&&t.push({icon:QU,label:"记忆"}),e.knowledgebase&&t.push({icon:XU,label:"知识库"}),e.tracing&&t.push({icon:qU,label:"观测"}),e.subAgents.length&&t.push({icon:$R,label:`子Agent ${e.subAgents.length}`}),t}function Use({onBack:e,onCreate:t}){const[n,r]=v.useState(null);return l.jsx("div",{className:"tpl-root",children:n?l.jsx(Hse,{template:n,onBack:()=>r(null),onCreate:t}):l.jsx($se,{onPick:r})})}function $se({onPick:e}){return l.jsxs("div",{className:"tpl-scroll",children:[l.jsxs("div",{className:"tpl-head",children:[l.jsx("h1",{className:"tpl-title",children:"从模板新建"}),l.jsx("p",{className:"tpl-sub",children:"选择一个预制 agent 模板,按需微调后即可创建。"})]}),l.jsx("div",{className:"tpl-grid",children:Bse.map((t,n)=>l.jsxs(Rt.button,{type:"button",className:"tpl-card",onClick:()=>e(t),initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:n*.03,duration:.24,ease:[.22,1,.36,1]},children:[l.jsx("span",{className:"tpl-card-icon",children:l.jsx(t.icon,{className:"icon"})}),l.jsx("span",{className:"tpl-card-name",children:t.draft.name}),l.jsx("span",{className:"tpl-card-desc",children:hs(t.draft.description)})]},t.id))})]})}function Hse({template:e,onBack:t,onCreate:n}){const[r,s]=v.useState(e.draft.name),i=e.icon,a=Fse(e.draft);function o(){const c=r.trim()||e.draft.name;n({...e.draft,name:c})}return l.jsxs("div",{className:"tpl-scroll tpl-scroll--detail",children:[l.jsxs("button",{className:"tpl-back",onClick:t,children:[l.jsx(CR,{className:"icon"})," 返回模板列表"]}),l.jsxs(Rt.div,{className:"tpl-detail",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.22,1,.36,1]},children:[l.jsxs("div",{className:"tpl-detail-head",children:[l.jsx("span",{className:"tpl-detail-icon",children:l.jsx(i,{className:"icon"})}),l.jsxs("div",{className:"tpl-detail-headtext",children:[l.jsx("div",{className:"tpl-detail-name",children:e.draft.name}),l.jsx("div",{className:"tpl-detail-desc",children:hs(e.draft.description)})]})]}),a.length>0&&l.jsx("div",{className:"tpl-tags tpl-tags--detail",children:a.map(c=>l.jsxs("span",{className:"tpl-tag",children:[l.jsx(c.icon,{className:"tpl-tag-icon"})," ",c.label]},c.label))}),l.jsxs("label",{className:"tpl-field",children:[l.jsx("span",{className:"tpl-field-label",children:"名称"}),l.jsx("input",{className:"tpl-input",value:r,onChange:c=>s(c.target.value),placeholder:e.draft.name})]}),l.jsxs("div",{className:"tpl-field",children:[l.jsx("span",{className:"tpl-field-label",children:"系统提示词"}),l.jsx("p",{className:"tpl-instruction",children:e.draft.instruction})]}),l.jsxs("div",{className:"tpl-meta-grid",children:[e.draft.model&&l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"模型"}),l.jsx("span",{className:"tpl-meta-val tpl-mono",children:e.draft.model})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"工具"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.tools.length?e.draft.tools.join("、"):"无"})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"记忆"}),l.jsx("span",{className:"tpl-meta-val",children:zse(e.draft)})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"知识库"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.knowledgebase?"已开启":"关闭"})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"观测追踪"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.tracing?"已开启":"关闭"})]})]}),e.draft.subAgents.length>0&&l.jsxs("div",{className:"tpl-field",children:[l.jsxs("span",{className:"tpl-field-label",children:["子 Agent(",e.draft.subAgents.length,")"]}),l.jsx("div",{className:"tpl-subagents",children:e.draft.subAgents.map((c,u)=>l.jsxs("div",{className:"tpl-subagent",children:[l.jsxs("div",{className:"tpl-subagent-top",children:[l.jsx("span",{className:"tpl-subagent-name",children:c.name}),c.tools.length>0&&l.jsx("span",{className:"tpl-subagent-tools",children:c.tools.join("、")})]}),l.jsx("div",{className:"tpl-subagent-desc",children:hs(c.description)})]},u))})]}),l.jsxs("button",{className:"tpl-create",onClick:o,children:["使用此模板创建 ",l.jsx(Nr,{className:"icon"})]})]})]})}function zse(e){const t=[];return e.memory.shortTerm&&t.push("短期"),e.memory.longTerm&&t.push("长期"),t.length?t.join(" + "):"关闭"}function Tn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function cg(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Xh.prototype=cg.prototype={constructor:Xh,on:function(e,t){var n=this._,r=Kse(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(s),r=0,s,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),xN.hasOwnProperty(t)?{space:xN[t],local:e}:e}function Wse(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===N1&&t.documentElement.namespaceURI===N1?t.createElement(e):t.createElementNS(n,e)}}function qse(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function eP(e){var t=ug(e);return(t.local?qse:Wse)(t)}function Gse(){}function Rw(e){return e==null?Gse:function(){return this.querySelector(e)}}function Xse(e){typeof e!="function"&&(e=Rw(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=b&&(b=E+1);!(k=x[b])&&++b=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function wie(e){e||(e=vie);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,s=new Array(r),i=0;it?1:e>=t?0:NaN}function _ie(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function kie(){return Array.from(this)}function Tie(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Pie:typeof t=="function"?Bie:jie)(e,t,n??"")):tc(this.node(),e)}function tc(e,t){return e.style.getPropertyValue(t)||iP(e).getComputedStyle(e,null).getPropertyValue(t)}function Uie(e){return function(){delete this[e]}}function $ie(e,t){return function(){this[e]=t}}function Hie(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function zie(e,t){return arguments.length>1?this.each((t==null?Uie:typeof t=="function"?Hie:$ie)(e,t)):this.node()[e]}function aP(e){return e.trim().split(/^|\s+/)}function Lw(e){return e.classList||new oP(e)}function oP(e){this._node=e,this._names=aP(e.getAttribute("class")||"")}oP.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function lP(e,t){for(var n=Lw(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function yae(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n()=>e;function A1(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:o,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}A1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Nae(e){return!e.ctrlKey&&!e.button}function Aae(){return this.parentNode}function Cae(e,t){return t??{x:e.x,y:e.y}}function Iae(){return navigator.maxTouchPoints||"ontouchstart"in this}function pP(){var e=Nae,t=Aae,n=Cae,r=Iae,s={},i=cg("start","drag","end"),a=0,o,c,u,d,f=0;function h(_){_.on("mousedown.drag",p).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,Sae).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(_,k){if(!(d||!e.call(this,_,k))){var T=b(this,t.call(this,_,k),_,k,"mouse");T&&(Ur(_.view).on("mousemove.drag",m,Ed).on("mouseup.drag",g,Ed),fP(_.view),dy(_),u=!1,o=_.clientX,c=_.clientY,T("start",_))}}function m(_){if(Il(_),!u){var k=_.clientX-o,T=_.clientY-c;u=k*k+T*T>f}s.mouse("drag",_)}function g(_){Ur(_.view).on("mousemove.drag mouseup.drag",null),hP(_.view,u),Il(_),s.mouse("end",_)}function x(_,k){if(e.call(this,_,k)){var T=_.changedTouches,A=t.call(this,_,k),N=T.length,S,C;for(S=0;S>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ch(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ch(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Lae.exec(e))?new Ar(t[1],t[2],t[3],1):(t=Oae.exec(e))?new Ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mae.exec(e))?ch(t[1],t[2],t[3],t[4]):(t=Dae.exec(e))?ch(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Pae.exec(e))?NN(t[1],t[2]/100,t[3]/100,1):(t=jae.exec(e))?NN(t[1],t[2]/100,t[3]/100,t[4]):wN.hasOwnProperty(e)?kN(wN[e]):e==="transparent"?new Ar(NaN,NaN,NaN,0):null}function kN(e){return new Ar(e>>16&255,e>>8&255,e&255,1)}function ch(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ar(e,t,n,r)}function Uae(e){return e instanceof af||(e=yo(e)),e?(e=e.rgb(),new Ar(e.r,e.g,e.b,e.opacity)):new Ar}function C1(e,t,n,r){return arguments.length===1?Uae(e):new Ar(e,t,n,r??1)}function Ar(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ow(Ar,C1,mP(af,{brighter(e){return e=e==null?im:Math.pow(im,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xd:Math.pow(xd,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ar(io(this.r),io(this.g),io(this.b),am(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:TN,formatHex:TN,formatHex8:$ae,formatRgb:SN,toString:SN}));function TN(){return`#${Za(this.r)}${Za(this.g)}${Za(this.b)}`}function $ae(){return`#${Za(this.r)}${Za(this.g)}${Za(this.b)}${Za((isNaN(this.opacity)?1:this.opacity)*255)}`}function SN(){const e=am(this.opacity);return`${e===1?"rgb(":"rgba("}${io(this.r)}, ${io(this.g)}, ${io(this.b)}${e===1?")":`, ${e})`}`}function am(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function io(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Za(e){return e=io(e),(e<16?"0":"")+e.toString(16)}function NN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ss(e,t,n,r)}function gP(e){if(e instanceof Ss)return new Ss(e.h,e.s,e.l,e.opacity);if(e instanceof af||(e=yo(e)),!e)return new Ss;if(e instanceof Ss)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,o=i-s,c=(i+s)/2;return o?(t===i?a=(n-r)/o+(n0&&c<1?0:a,new Ss(a,o,c,e.opacity)}function Hae(e,t,n,r){return arguments.length===1?gP(e):new Ss(e,t,n,r??1)}function Ss(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ow(Ss,Hae,mP(af,{brighter(e){return e=e==null?im:Math.pow(im,e),new Ss(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xd:Math.pow(xd,e),new Ss(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Ar(fy(e>=240?e-240:e+120,s,r),fy(e,s,r),fy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ss(AN(this.h),uh(this.s),uh(this.l),am(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=am(this.opacity);return`${e===1?"hsl(":"hsla("}${AN(this.h)}, ${uh(this.s)*100}%, ${uh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function AN(e){return e=(e||0)%360,e<0?e+360:e}function uh(e){return Math.max(0,Math.min(1,e||0))}function fy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Mw=e=>()=>e;function zae(e,t){return function(n){return e+n*t}}function Vae(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Kae(e){return(e=+e)==1?yP:function(t,n){return n-t?Vae(t,n,e):Mw(isNaN(t)?n:t)}}function yP(e,t){var n=t-e;return n?zae(e,n):Mw(isNaN(e)?t:e)}const om=function e(t){var n=Kae(t);function r(s,i){var a=n((s=C1(s)).r,(i=C1(i)).r),o=n(s.g,i.g),c=n(s.b,i.b),u=yP(s.opacity,i.opacity);return function(d){return s.r=a(d),s.g=o(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function Yae(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;sn&&(i=t.slice(n,i),o[a]?o[a]+=i:o[++a]=i),(r=r[0])===(s=s[0])?o[a]?o[a]+=s:o[++a]=s:(o[++a]=null,c.push({i:a,x:Qs(r,s)})),n=hy.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Qs(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function o(u,d,f,h){u!==d?h.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Qs(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,h,p,m){if(u!==f||d!==h){var g=p.push(s(p)+"scale(",null,",",null,")");m.push({i:g-4,x:Qs(u,f)},{i:g-2,x:Qs(d,h)})}else(f!==1||h!==1)&&p.push(s(p)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(p){for(var m=-1,g=h.length,x;++m=0&&e._call.call(void 0,t),e=e._next;--nc}function RN(){bo=(cm=vd.now())+dg,nc=lu=0;try{ooe()}finally{nc=0,coe(),bo=0}}function loe(){var e=vd.now(),t=e-cm;t>wP&&(dg-=t,cm=e)}function coe(){for(var e,t=lm,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:lm=n);cu=e,L1(r)}function L1(e){if(!nc){lu&&(lu=clearTimeout(lu));var t=e-bo;t>24?(e<1/0&&(lu=setTimeout(RN,e-vd.now()-dg)),Gc&&(Gc=clearInterval(Gc))):(Gc||(cm=vd.now(),Gc=setInterval(loe,wP)),nc=1,vP(RN))}}function LN(e,t,n){var r=new um;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var uoe=cg("start","end","cancel","interrupt"),doe=[],kP=0,ON=1,O1=2,Zh=3,MN=4,M1=5,Jh=6;function fg(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;foe(e,n,{name:t,index:r,group:s,on:uoe,tween:doe,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:kP})}function Pw(e,t){var n=$s(e,t);if(n.state>kP)throw new Error("too late; already scheduled");return n}function ui(e,t){var n=$s(e,t);if(n.state>Zh)throw new Error("too late; already running");return n}function $s(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function foe(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=_P(i,0,n.time);function i(u){n.state=ON,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,p;if(n.state!==ON)return c();for(d in r)if(p=r[d],p.name===n.name){if(p.state===Zh)return LN(a);p.state===MN?(p.state=Jh,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[d]):+dO1&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Hoe(e,t,n){var r,s,i=$oe(t)?Pw:ui;return function(){var a=i(this,e),o=a.on;o!==r&&(s=(r=o).copy()).on(t,n),a.on=s}}function zoe(e,t){var n=this._id;return arguments.length<2?$s(this.node(),n).on.on(e):this.each(Hoe(n,e,t))}function Voe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Koe(){return this.on("end.remove",Voe(this._id))}function Yoe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Rw(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a()=>e;function yle(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Ni(e,t,n){this.k=e,this.x=t,this.y=n}Ni.prototype={constructor:Ni,scale:function(e){return e===1?this:new Ni(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ni(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var hg=new Ni(1,0,0);AP.prototype=Ni.prototype;function AP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hg;return e.__zoom}function py(e){e.stopImmediatePropagation()}function Xc(e){e.preventDefault(),e.stopImmediatePropagation()}function ble(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ele(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function DN(){return this.__zoom||hg}function xle(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wle(){return navigator.maxTouchPoints||"ontouchstart"in this}function vle(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function CP(){var e=ble,t=Ele,n=vle,r=xle,s=wle,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,c=Qh,u=cg("start","zoom","end"),d,f,h,p=500,m=150,g=0,x=10;function y(P){P.property("__zoom",DN).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",C).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(P,D,I,L){var O=P.selection?P.selection():P;O.property("__zoom",DN),P!==O?k(P,D,I,L):O.interrupt().each(function(){T(this,arguments).event(L).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},y.scaleBy=function(P,D,I,L){y.scaleTo(P,function(){var O=this.__zoom.k,B=typeof D=="function"?D.apply(this,arguments):D;return O*B},I,L)},y.scaleTo=function(P,D,I,L){y.transform(P,function(){var O=t.apply(this,arguments),B=this.__zoom,R=I==null?_(O):typeof I=="function"?I.apply(this,arguments):I,z=B.invert(R),Y=typeof D=="function"?D.apply(this,arguments):D;return n(b(E(B,Y),R,z),O,a)},I,L)},y.translateBy=function(P,D,I,L){y.transform(P,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,L)},y.translateTo=function(P,D,I,L,O){y.transform(P,function(){var B=t.apply(this,arguments),R=this.__zoom,z=L==null?_(B):typeof L=="function"?L.apply(this,arguments):L;return n(hg.translate(z[0],z[1]).scale(R.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof I=="function"?-I.apply(this,arguments):-I),B,a)},L,O)};function E(P,D){return D=Math.max(i[0],Math.min(i[1],D)),D===P.k?P:new Ni(D,P.x,P.y)}function b(P,D,I){var L=D[0]-I[0]*P.k,O=D[1]-I[1]*P.k;return L===P.x&&O===P.y?P:new Ni(P.k,L,O)}function _(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function k(P,D,I,L){P.on("start.zoom",function(){T(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(L).end()}).tween("zoom",function(){var O=this,B=arguments,R=T(O,B).event(L),z=t.apply(O,B),Y=I==null?_(z):typeof I=="function"?I.apply(O,B):I,j=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),re=O.__zoom,V=typeof D=="function"?D.apply(O,B):D,ee=c(re.invert(Y).concat(j/re.k),V.invert(Y).concat(j/V.k));return function(oe){if(oe===1)oe=V;else{var X=ee(oe),ae=j/X[2];oe=new Ni(ae,Y[0]-X[0]*ae,Y[1]-X[1]*ae)}R.zoom(null,oe)}})}function T(P,D,I){return!I&&P.__zooming||new A(P,D)}function A(P,D){this.that=P,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(P,D),this.taps=0}A.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,D){return this.mouse&&P!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var D=Ur(this.that).datum();u.call(P,this.that,new yle(P,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),D)}};function N(P,...D){if(!e.apply(this,arguments))return;var I=T(this,D).event(P),L=this.__zoom,O=Math.max(i[0],Math.min(i[1],L.k*Math.pow(2,r.apply(this,arguments)))),B=ks(P);if(I.wheel)(I.mouse[0][0]!==B[0]||I.mouse[0][1]!==B[1])&&(I.mouse[1]=L.invert(I.mouse[0]=B)),clearTimeout(I.wheel);else{if(L.k===O)return;I.mouse=[B,L.invert(B)],ep(this),I.start()}Xc(P),I.wheel=setTimeout(R,m),I.zoom("mouse",n(b(E(L,O),I.mouse[0],I.mouse[1]),I.extent,a));function R(){I.wheel=null,I.end()}}function S(P,...D){if(h||!e.apply(this,arguments))return;var I=P.currentTarget,L=T(this,D,!0).event(P),O=Ur(P.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",j,!0),B=ks(P,I),R=P.clientX,z=P.clientY;fP(P.view),py(P),L.mouse=[B,this.__zoom.invert(B)],ep(this),L.start();function Y(re){if(Xc(re),!L.moved){var V=re.clientX-R,ee=re.clientY-z;L.moved=V*V+ee*ee>g}L.event(re).zoom("mouse",n(b(L.that.__zoom,L.mouse[0]=ks(re,I),L.mouse[1]),L.extent,a))}function j(re){O.on("mousemove.zoom mouseup.zoom",null),hP(re.view,L.moved),Xc(re),L.event(re).end()}}function C(P,...D){if(e.apply(this,arguments)){var I=this.__zoom,L=ks(P.changedTouches?P.changedTouches[0]:P,this),O=I.invert(L),B=I.k*(P.shiftKey?.5:2),R=n(b(E(I,B),L,O),t.apply(this,D),a);Xc(P),o>0?Ur(this).transition().duration(o).call(k,R,L,P):Ur(this).call(y.transform,R,L,P)}}function M(P,...D){if(e.apply(this,arguments)){var I=P.touches,L=I.length,O=T(this,D,P.changedTouches.length===L).event(P),B,R,z,Y;for(py(P),R=0;R`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},_d=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],IP=["Enter"," ","Escape"],RP={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var rc;(function(e){e.Strict="strict",e.Loose="loose"})(rc||(rc={}));var ao;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ao||(ao={}));var kd;(function(e){e.Partial="partial",e.Full="full"})(kd||(kd={}));const LP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ra;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ra||(ra={}));var Td;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Td||(Td={}));var Be;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Be||(Be={}));const PN={[Be.Left]:Be.Right,[Be.Right]:Be.Left,[Be.Top]:Be.Bottom,[Be.Bottom]:Be.Top};function OP(e){return e===null?null:e?"valid":"invalid"}const MP=e=>"id"in e&&"source"in e&&"target"in e,_le=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Bw=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),of=(e,t=[0,0])=>{const{width:n,height:r}=$i(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},kle=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Bw(s)?s:t.nodeLookup.get(s.id));const o=a?dm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return pg(r,o)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return mg(n)},lf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=pg(n,dm(s)),r=!0)}),r?mg(n):{x:0,y:0,width:0,height:0}},Fw=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const o={...Ac(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const p=d.width??u.width??u.initialWidth??null,m=d.height??u.height??u.initialHeight??null,g=Sd(o,ic(u)),x=(p??0)*(m??0),y=i&&g>0;(!u.internals.handleBounds||y||g>=x||u.dragging)&&c.push(u)}return c},Tle=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Sle(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Nle({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return!0;const o=Sle(e,a),c=lf(o),u=$w(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function DP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),o=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=o?o.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!o)i==null||i("005",js.error005());else{const p=o.measured.width,m=o.measured.height;p&&m&&(f=[[c,u],[c+p,u+m]])}else o&&xo(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=xo(f)?Eo(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",js.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function Ale({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const p=i.has(h.id),m=!p&&h.parentId&&a.find(g=>g.id===h.parentId);(p||m)&&a.push(h)}const o=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),d=Tle(a,c);for(const h of c)o.has(h.id)&&!d.find(m=>m.id===h.id)&&d.push(h);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const sc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Eo=(e={x:0,y:0},t,n)=>({x:sc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function PP(e,t,n){const{width:r,height:s}=$i(n),{x:i,y:a}=n.internals.positionAbsolute;return Eo(e,[[i,a],[i+r,a+s]],t)}const jN=(e,t,n)=>en?-sc(Math.abs(e-n),1,t)/t:0,Uw=(e,t,n=15,r=40)=>{const s=jN(e.x,r,t.width-r)*n,i=jN(e.y,r,t.height-r)*n;return[s,i]},pg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),D1=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),mg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ic=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Bw(e)?e.internals.positionAbsolute:of(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},dm=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Bw(e)?e.internals.positionAbsolute:of(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},jP=(e,t)=>mg(pg(D1(e),D1(t))),Sd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},BN=e=>As(e.width)&&As(e.height)&&As(e.x)&&As(e.y),As=e=>!isNaN(e)&&isFinite(e),BP=(e,t)=>(n,r)=>{},cf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ac=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const o={x:(e-n)/s,y:(t-r)/s};return i?cf(o,a):o},ac=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function zo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Cle(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=zo(e,n),s=zo(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=zo(e.top??e.y??0,n),s=zo(e.bottom??e.y??0,n),i=zo(e.left??e.x??0,t),a=zo(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ile(e,t,n,r,s,i){const{x:a,y:o}=ac(e,[t,n,r]),{x:c,y:u}=ac({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=i-u;return{left:Math.floor(a),top:Math.floor(o),right:Math.floor(d),bottom:Math.floor(f)}}const $w=(e,t,n,r,s,i)=>{const a=Cle(i,t,n),o=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(o,c),d=sc(u,r,s),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*d,m=n/2-h*d,g=Ile(e,p,m,d,t,n),x={left:Math.min(g.left-a.left,0),top:Math.min(g.top-a.top,0),right:Math.min(g.right-a.right,0),bottom:Math.min(g.bottom-a.bottom,0)};return{x:p-x.left+x.right,y:m-x.top+x.bottom,zoom:d}},Nd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xo(e){return e!=null&&e!=="parent"}function $i(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function FP(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function UP(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const o=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*o[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*o[1]}return i}function FN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Rle(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function Lle(e){return{...RP,...e||{}}}function ju(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Cs(e),o=Ac({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?cf(o,t):o;return{xSnapped:c,ySnapped:u,...o}}const Hw=e=>({width:e.offsetWidth,height:e.offsetHeight}),$P=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Ole=["INPUT","SELECT","TEXTAREA"];function HP(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Ole.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const zP=e=>"clientX"in e,Cs=(e,t)=>{var i,a;const n=zP(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},UN=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const o=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(o.left-n.left)/r,y:(o.top-n.top)/r,...Hw(a)}})};function VP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:o}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+i*.375+o*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function hh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $N({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Be.Left:return[t-hh(t-r,i),n];case Be.Right:return[t+hh(r-t,i),n];case Be.Top:return[t,n-hh(n-s,i)];case Be.Bottom:return[t,n+hh(s-n,i)]}}function KP({sourceX:e,sourceY:t,sourcePosition:n=Be.Bottom,targetX:r,targetY:s,targetPosition:i=Be.Top,curvature:a=.25}){const[o,c]=$N({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=$N({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,h,p,m]=VP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${c} ${u},${d} ${r},${s}`,f,h,p,m]}function YP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n0}const Ple=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,jle=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Ble=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",js.error006()),t;const r=n.getEdgeId||Ple;let s;return MP(e)?s={...e}:s={...e,id:r(e)},jle(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function WP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,o]=YP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,o]}const HN={[Be.Left]:{x:-1,y:0},[Be.Right]:{x:1,y:0},[Be.Top]:{x:0,y:-1},[Be.Bottom]:{x:0,y:1}},Fle=({source:e,sourcePosition:t=Be.Bottom,target:n})=>t===Be.Left||t===Be.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ule({source:e,sourcePosition:t=Be.Bottom,target:n,targetPosition:r=Be.Top,center:s,offset:i,stepPosition:a}){const o=HN[t],c=HN[r],u={x:e.x+o.x*i,y:e.y+o.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},f=Fle({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",p=f[h];let m=[],g,x;const y={x:0,y:0},E={x:0,y:0},[,,b,_]=YP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[h]*c[h]===-1){h==="x"?(g=s.x??u.x+(d.x-u.x)*a,x=s.y??(u.y+d.y)/2):(g=s.x??(u.x+d.x)/2,x=s.y??u.y+(d.y-u.y)*a);const N=[{x:g,y:u.y},{x:g,y:d.y}],S=[{x:u.x,y:x},{x:d.x,y:x}];o[h]===p?m=h==="x"?N:S:m=h==="x"?S:N}else{const N=[{x:u.x,y:d.y}],S=[{x:d.x,y:u.y}];if(h==="x"?m=o.x===p?S:N:m=o.y===p?N:S,t===r){const P=Math.abs(e[h]-n[h]);if(P<=i){const D=Math.min(i-1,i-P);o[h]===p?y[h]=(u[h]>e[h]?-1:1)*D:E[h]=(d[h]>n[h]?-1:1)*D}}if(t!==r){const P=h==="x"?"y":"x",D=o[h]===c[P],I=u[P]>d[P],L=u[P]=q?(g=(C.x+M.x)/2,x=m[0].y):(g=m[0].x,x=(C.y+M.y)/2)}const k={x:u.x+y.x,y:u.y+y.y},T={x:d.x+E.x,y:d.y+E.y};return[[e,...k.x!==m[0].x||k.y!==m[0].y?[k]:[],...m,...T.x!==m[m.length-1].x||T.y!==m[m.length-1].y?[T]:[],n],g,x,b,_]}function $le(e,t,n,r){const s=Math.min(zN(e,t)/2,zN(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function j1(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function zle(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,o)=>([o.markerStart||r,o.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=j1(c,t);i.has(u)||(a.push({id:u,color:c.color||n,...c}),i.add(u))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))}const qP=1e3,Vle=10,zw={nodeOrigin:[0,0],nodeExtent:_d,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Kle={...zw,checkEquality:!0};function Vw(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Yle(e,t,n){const r=Vw(zw,n);for(const s of e.values())if(s.parentId)Yw(s,e,t,r);else{const i=of(s,r.nodeOrigin),a=xo(s.extent)?s.extent:r.nodeExtent,o=Eo(i,a,$i(s));s.internals.positionAbsolute=o}}function Wle(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Kw(e){return e==="manual"}function B1(e,t,n,r={}){var d,f;const s=Vw(Kle,r),i={i:0},a=new Map(t),o=s!=null&&s.elevateNodesOnSelect&&!Kw(s.zIndexMode)?qP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let p=a.get(h.id);if(s.checkEquality&&h===(p==null?void 0:p.internals.userNode))t.set(h.id,p);else{const m=of(h,s.nodeOrigin),g=xo(h.extent)?h.extent:s.nodeExtent,x=Eo(m,g,$i(h));p={...s.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:Wle(h,p),z:GP(h,o,s.zIndexMode),userNode:h}},t.set(h.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),h.parentId&&Yw(p,t,n,r,i),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function qle(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Yw(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:o,zIndexMode:c}=Vw(zw,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}qle(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*Vle),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=i&&!Kw(c)?qP:0,{x:h,y:p,z:m}=Gle(e,d,a,o,f,c),{positionAbsolute:g}=e.internals,x=h!==g.x||p!==g.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:h,y:p}:g,z:m}})}function GP(e,t,n){const r=As(e.zIndex)?e.zIndex:0;return Kw(n)?r:r+(e.selected?t:0)}function Gle(e,t,n,r,s,i){const{x:a,y:o}=t.internals.positionAbsolute,c=$i(e),u=of(e,n),d=xo(e.extent)?Eo(u,e.extent,c):u;let f=Eo({x:a+d.x,y:o+d.y},r,c);e.extent==="parent"&&(f=PP(f,c,t));const h=GP(e,s,i),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function Ww(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const o of e){const c=t.get(o.parentId);if(!c)continue;const u=((a=i.get(o.parentId))==null?void 0:a.expandedRect)??ic(c),d=jP(u,o.rect);i.set(o.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:o,parent:c},u)=>{var b;const d=c.internals.positionAbsolute,f=$i(c),h=c.origin??r,p=o.x0||m>0||y||E)&&(s.push({id:u,type:"position",position:{x:c.position.x-p+y,y:c.position.y-m+E}}),(b=n.get(u))==null||b.forEach(_=>{e.some(k=>k.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+m}})})),(f.width0){const p=Ww(h,t,n,s);u.push(...p)}return{changes:u,updatedInternals:c}}async function Qle({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function WN(e,t,n,r,s,i){let a=s;const o=r.get(a)||new Map;r.set(a,o.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),i){a=`${s}-${e}-${i}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function XP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:o=null}=r,c={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:o},u=`${s}-${a}--${i}-${o}`,d=`${i}-${o}--${s}-${a}`;WN("source",c,d,e,s,a),WN("target",c,u,e,i,o),t.set(r.id,r)}}function QP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:QP(n,t):!1}function qN(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Zle(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!QP(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const o=e.get(i);o&&s.set(i,{id:i,position:o.position||{x:0,y:0},distance:{x:n.x-o.internals.positionAbsolute.x,y:n.y-o.internals.positionAbsolute.y},extent:o.extent,parentId:o.parentId,origin:o.origin,expandParent:o.expandParent,internals:{positionAbsolute:o.internals.positionAbsolute||{x:0,y:0}},measured:{width:o.measured.width??0,height:o.measured.height??0}})}return s}function my({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,o,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.position,dragging:r})}if(!e)return[s[0],s];const i=(o=n.get(e))==null?void 0:o.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function Jle({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=cf(i,t);return{x:a.x-i.x,y:a.y-i.y}}function ece({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,o=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,p=!1,m=!1,g=null;function x({noDragClassName:E,handleSelector:b,domNode:_,isSelectable:k,nodeId:T,nodeClickDistance:A=0}){h=Ur(_);function N({x:U,y:q}){const{nodeLookup:P,nodeExtent:D,snapGrid:I,snapToGrid:L,nodeOrigin:O,onNodeDrag:B,onSelectionDrag:R,onError:z,updateNodePositions:Y}=t();i={x:U,y:q};let j=!1;const re=o.size>1,V=re&&D?D1(lf(o)):null,ee=re&&L?Jle({dragItems:o,snapGrid:I,x:U,y:q}):null;for(const[oe,X]of o){if(!P.has(oe))continue;let ae={x:U-X.distance.x,y:q-X.distance.y};L&&(ae=ee?{x:Math.round(ae.x+ee.x),y:Math.round(ae.y+ee.y)}:cf(ae,I));let Z=null;if(re&&D&&!X.extent&&V){const{positionAbsolute:Q}=X.internals,ge=Q.x-V.x+D[0][0],be=Q.x+X.measured.width-V.x2+D[1][0],_e=Q.y-V.y+D[0][1],Pe=Q.y+X.measured.height-V.y2+D[1][1];Z=[[ge,_e],[be,Pe]]}const{position:de,positionAbsolute:ye}=DP({nodeId:oe,nextPosition:ae,nodeLookup:P,nodeExtent:Z||D,nodeOrigin:O,onError:z});j=j||X.position.x!==de.x||X.position.y!==de.y,X.position=de,X.internals.positionAbsolute=ye}if(m=m||j,!!j&&(Y(o,!0),g&&(r||B||!T&&R))){const[oe,X]=my({nodeId:T,dragItems:o,nodeLookup:P});r==null||r(g,o,oe,X),B==null||B(g,oe,X),T||R==null||R(g,X)}}async function S(){if(!d)return;const{transform:U,panBy:q,autoPanSpeed:P,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(a);return}const[I,L]=Uw(u,d,P);(I!==0||L!==0)&&(i.x=(i.x??0)-I/U[2],i.y=(i.y??0)-L/U[2],await q({x:I,y:L})&&N(i)),a=requestAnimationFrame(S)}function C(U){var re;const{nodeLookup:q,multiSelectionActive:P,nodesDraggable:D,transform:I,snapGrid:L,snapToGrid:O,selectNodesOnDrag:B,onNodeDragStart:R,onSelectionDragStart:z,unselectNodesAndEdges:Y}=t();f=!0,(!B||!k)&&!P&&T&&((re=q.get(T))!=null&&re.selected||Y()),k&&B&&T&&(e==null||e(T));const j=ju(U.sourceEvent,{transform:I,snapGrid:L,snapToGrid:O,containerBounds:d});if(i=j,o=Zle(q,D,j,T),o.size>0&&(n||R||!T&&z)){const[V,ee]=my({nodeId:T,dragItems:o,nodeLookup:q});n==null||n(U.sourceEvent,o,V,ee),R==null||R(U.sourceEvent,V,ee),T||z==null||z(U.sourceEvent,ee)}}const M=pP().clickDistance(A).on("start",U=>{const{domNode:q,nodeDragThreshold:P,transform:D,snapGrid:I,snapToGrid:L}=t();d=(q==null?void 0:q.getBoundingClientRect())||null,p=!1,m=!1,g=U.sourceEvent,P===0&&C(U),i=ju(U.sourceEvent,{transform:D,snapGrid:I,snapToGrid:L,containerBounds:d}),u=Cs(U.sourceEvent,d)}).on("drag",U=>{const{autoPanOnNodeDrag:q,transform:P,snapGrid:D,snapToGrid:I,nodeDragThreshold:L,nodeLookup:O}=t(),B=ju(U.sourceEvent,{transform:P,snapGrid:D,snapToGrid:I,containerBounds:d});if(g=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||T&&!O.has(T))&&(p=!0),!p){if(!c&&q&&f&&(c=!0,S()),!f){const R=Cs(U.sourceEvent,d),z=R.x-u.x,Y=R.y-u.y;Math.sqrt(z*z+Y*Y)>L&&C(U)}(i.x!==B.xSnapped||i.y!==B.ySnapped)&&o&&f&&(u=Cs(U.sourceEvent,d),N(B))}}).on("end",U=>{if(!f||p){p&&o.size>0&&t().updateNodePositions(o,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),o.size>0){const{nodeLookup:q,updateNodePositions:P,onNodeDragStop:D,onSelectionDragStop:I}=t();if(m&&(P(o,!1),m=!1),s||D||!T&&I){const[L,O]=my({nodeId:T,dragItems:o,nodeLookup:q,dragging:!1});s==null||s(U.sourceEvent,o,L,O),D==null||D(U.sourceEvent,L,O),T||I==null||I(U.sourceEvent,O)}}}).filter(U=>{const q=U.target;return!U.button&&(!E||!qN(q,`.${E}`,_))&&(!b||qN(q,b,_))});h.call(M)}function y(){h==null||h.on(".drag",null)}return{update:x,destroy:y}}function tce(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Sd(s,ic(i))>0&&r.push(i);return r}const nce=250;function rce(e,t,n,r){var o,c;let s=[],i=1/0;const a=tce(e,n,t+nce);for(const u of a){const d=[...((o=u.internals.handleBounds)==null?void 0:o.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=wo(u,f,f.position,!0),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));m>t||(m1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function ZP(e,t,n,r,s,i=!1){var u,d,f;const a=r.get(e);if(!a)return null;const o=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?o==null?void 0:o.find(h=>h.id===n):o==null?void 0:o[0])??null;return c&&i?{...c,...wo(a,c,c.position,!0)}:c}function JP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function sce(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ej=()=>!0;function ice(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:o,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:p,onConnectStart:m,onConnect:g,onConnectEnd:x,isValidConnection:y=ej,onReconnectEnd:E,updateConnection:b,getTransform:_,getFromHandle:k,autoPanSpeed:T,dragThreshold:A=1,handleDomNode:N}){const S=$P(e.target);let C=0,M;const{x:U,y:q}=Cs(e),P=JP(i,N),D=o==null?void 0:o.getBoundingClientRect();let I=!1;if(!D||!P)return;const L=ZP(s,P,r,c,t);if(!L)return;let O=Cs(e,D),B=!1,R=null,z=!1,Y=null;function j(){if(!d||!D)return;const[de,ye]=Uw(O,D,T);h({x:de,y:ye}),C=requestAnimationFrame(j)}const re={...L,nodeId:s,type:P,position:L.position},V=c.get(s);let oe={inProgress:!0,isValid:null,from:wo(V,re,Be.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:V,to:O,toHandle:null,toPosition:PN[re.position],toNode:null,pointer:O};function X(){I=!0,b(oe),m==null||m(e,{nodeId:s,handleId:r,handleType:P})}A===0&&X();function ae(de){if(!I){const{x:Pe,y:we}=Cs(de),ht=Pe-U,je=we-q;if(!(ht*ht+je*je>A*A))return;X()}if(!k()||!re){Z(de);return}const ye=_();O=Cs(de,D),M=rce(Ac(O,ye,!1,[1,1]),n,c,re),B||(j(),B=!0);const Q=tj(de,{handle:M,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:S,lib:u,flowId:f,nodeLookup:c});Y=Q.handleDomNode,R=Q.connection,z=sce(!!M,Q.isValid);const ge=c.get(s),be=ge?wo(ge,re,Be.Left,!0):oe.from,_e={...oe,from:be,isValid:z,to:Q.toHandle&&z?ac({x:Q.toHandle.x,y:Q.toHandle.y},ye):O,toHandle:Q.toHandle,toPosition:z&&Q.toHandle?Q.toHandle.position:PN[re.position],toNode:Q.toHandle?c.get(Q.toHandle.nodeId):null,pointer:O};b(_e),oe=_e}function Z(de){if(!("touches"in de&&de.touches.length>0)){if(I){(M||Y)&&R&&z&&(g==null||g(R));const{inProgress:ye,...Q}=oe,ge={...Q,toPosition:oe.toHandle?oe.toPosition:null};x==null||x(de,ge),i&&(E==null||E(de,ge))}p(),cancelAnimationFrame(C),B=!1,z=!1,R=null,Y=null,S.removeEventListener("mousemove",ae),S.removeEventListener("mouseup",Z),S.removeEventListener("touchmove",ae),S.removeEventListener("touchend",Z)}}S.addEventListener("mousemove",ae),S.addEventListener("mouseup",Z),S.addEventListener("touchmove",ae),S.addEventListener("touchend",Z)}function tj(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:o,flowId:c,isValidConnection:u=ej,nodeLookup:d}){const f=i==="target",h=t?a.querySelector(`.${o}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:m}=Cs(e),g=a.elementFromPoint(p,m),x=g!=null&&g.classList.contains(`${o}-flow__handle`)?g:h,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const E=JP(void 0,x),b=x.getAttribute("data-nodeid"),_=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),T=x.classList.contains("connectableend");if(!b||!E)return y;const A={source:f?b:r,sourceHandle:f?_:s,target:f?r:b,targetHandle:f?s:_};y.connection=A;const S=k&&T&&(n===rc.Strict?f&&E==="source"||!f&&E==="target":b!==r||_!==s);y.isValid=S&&u(A),y.toHandle=ZP(b,E,_,d,n,!0)}return y}const F1={onPointerDown:ice,isValid:tj};function ace({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Ur(e);function i({translateExtent:o,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const m=b=>{if(b.sourceEvent.type!=="wheel"||!t)return;const _=n(),k=b.sourceEvent.ctrlKey&&Nd()?10:1,T=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,A=_[2]*Math.pow(2,T*k);t.scaleTo(A)};let g=[0,0];const x=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(g=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},y=b=>{const _=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const k=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],T=[k[0]-g[0],k[1]-g[1]];g=k;const A=r()*Math.max(_[2],Math.log(_[2]))*(p?-1:1),N={x:_[0]-T[0]*A,y:_[1]-T[1]*A},S=[[0,0],[c,u]];t.setViewportConstrained({x:N.x,y:N.y,zoom:_[2]},S,o)},E=CP().on("start",x).on("zoom",f?y:null).on("zoom.wheel",h?m:null);s.call(E,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:ks}}const gg=e=>({x:e.x,y:e.y,zoom:e.k}),gy=({x:e,y:t,zoom:n})=>hg.translate(e,t).scale(n),yl=(e,t)=>e.target.closest(`.${t}`),nj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),oce=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,yy=(e,t=0,n=oce,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},rj=e=>{const t=e.ctrlKey&&Nd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function lce({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:o,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(yl(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const x=ks(d),y=rj(d),E=f*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const h=d.deltaMode===1?20:1;let p=s===ao.Vertical?0:d.deltaX*h,m=s===ao.Horizontal?0:d.deltaY*h;!Nd()&&d.shiftKey&&s!==ao.Vertical&&(p=d.deltaY*h,m=0),r.translateBy(n,-(p/f)*i,-(m/f)*i,{internal:!0});const g=gg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,g),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,o==null||o(d,g))}}function cce({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,o=yl(r,e);if(r.ctrlKey&&i&&o&&r.preventDefault(),a||o)return null;r.preventDefault(),n.call(this,r,s)}}function uce({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,o;if((i=r.sourceEvent)!=null&&i.internal)return;const s=gg(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((o=r.sourceEvent)==null?void 0:o.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function dce({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,o;e.usedRightMouseButton=!!(n&&nj(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((o=i.sourceEvent)!=null&&o.internal)&&(s==null||s(i.sourceEvent,gg(i.transform)))}}function fce({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var o;if(!((o=a.sourceEvent)!=null&&o.internal)&&(e.isZoomingOrPanning=!1,i&&nj(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=gg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function hce({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:o,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var x;const h=e||t,p=n&&f.ctrlKey,m=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(yl(f,`${u}-flow__node`)||yl(f,`${u}-flow__edge`)))return!0;if(!r&&!h&&!s&&!i&&!n||a||d&&!m||yl(f,o)&&m||yl(f,c)&&(!m||s&&m&&!e)||!n&&f.ctrlKey&&m)return!1;if(!n&&f.type==="touchstart"&&((x=f.touches)==null?void 0:x.length)>1)return f.preventDefault(),!1;if(!h&&!s&&!p&&m||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const g=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&g}}function pce({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:o,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=CP().scaleExtent([t,n]).translateExtent(r),h=Ur(e).call(f);E({x:s.x,y:s.y,zoom:sc(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const p=h.on("wheel.zoom"),m=h.on("dblclick.zoom");f.wheelDelta(rj);async function g(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).transform(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}function x({noWheelClassName:M,noPanClassName:U,onPaneContextMenu:q,userSelectionActive:P,panOnScroll:D,panOnDrag:I,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:B,zoomOnPinch:R,zoomOnScroll:z,zoomOnDoubleClick:Y,zoomActivationKeyPressed:j,lib:re,onTransformChange:V,connectionInProgress:ee,paneClickDistance:oe,selectionOnDrag:X}){P&&!u.isZoomingOrPanning&&y();const ae=D&&!j&&!P;f.clickDistance(X?1/0:!As(oe)||oe<0?0:oe);const Z=ae?lce({zoomPanValues:u,noWheelClassName:M,d3Selection:h,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:R,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:o}):cce({noWheelClassName:M,preventScrolling:B,d3ZoomHandler:p});h.on("wheel.zoom",Z,{passive:!1});const de=uce({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const ye=dce({zoomPanValues:u,panOnDrag:I,onPaneContextMenu:!!q,onPanZoom:i,onTransformChange:V});f.on("zoom",ye);const Q=fce({zoomPanValues:u,panOnDrag:I,panOnScroll:D,onPaneContextMenu:q,onPanZoomEnd:o,onDraggingChange:c});f.on("end",Q);const ge=hce({zoomActivationKeyPressed:j,panOnDrag:I,zoomOnScroll:z,panOnScroll:D,zoomOnDoubleClick:Y,zoomOnPinch:R,userSelectionActive:P,noPanClassName:U,noWheelClassName:M,lib:re,connectionInProgress:ee});f.filter(ge),Y?h.on("dblclick.zoom",m):h.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function E(M,U,q){const P=gy(M),D=f==null?void 0:f.constrain()(P,U,q);return D&&await g(D),D}async function b(M,U){const q=gy(M);return await g(q,U),q}function _(M){if(h){const U=gy(M),q=h.property("__zoom");(q.k!==M.zoom||q.x!==M.x||q.y!==M.y)&&(f==null||f.transform(h,U,null,{sync:!0}))}}function k(){const M=h?AP(h.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function T(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).scaleTo(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}async function A(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).scaleBy(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}function N(M){f==null||f.scaleExtent(M)}function S(M){f==null||f.translateExtent(M)}function C(M){const U=!As(M)||M<0?0:M;f==null||f.clickDistance(U)}return{update:x,destroy:y,setViewport:b,setViewportConstrained:E,getViewport:k,scaleTo:T,scaleBy:A,setScaleExtent:N,setTranslateExtent:S,syncViewport:_,setClickDistance:C}}var oc;(function(e){e.Line="line",e.Handle="handle"})(oc||(oc={}));function mce({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const a=e-t,o=n-r,c=[a>0?1:a<0?-1:0,o>0?1:o<0?-1:0];return a&&s&&(c[0]=c[0]*-1),o&&i&&(c[1]=c[1]*-1),c}function GN(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Yi(e,t){return Math.max(0,t-e)}function Wi(e,t){return Math.max(0,e-t)}function ph(e,t,n){return Math.max(0,t-e,e-n)}function XN(e,t){return e?!t:t}function gce(e,t,n,r,s,i,a,o){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:p,ySnapped:m}=n,{minWidth:g,maxWidth:x,minHeight:y,maxHeight:E}=r,{x:b,y:_,width:k,height:T,aspectRatio:A}=e;let N=Math.floor(d?p-e.pointerX:0),S=Math.floor(f?m-e.pointerY:0);const C=k+(c?-N:N),M=T+(u?-S:S),U=-i[0]*k,q=-i[1]*T;let P=ph(C,g,x),D=ph(M,y,E);if(a){let O=0,B=0;c&&N<0?O=Yi(b+N+U,a[0][0]):!c&&N>0&&(O=Wi(b+C+U,a[1][0])),u&&S<0?B=Yi(_+S+q,a[0][1]):!u&&S>0&&(B=Wi(_+M+q,a[1][1])),P=Math.max(P,O),D=Math.max(D,B)}if(o){let O=0,B=0;c&&N>0?O=Wi(b+N,o[0][0]):!c&&N<0&&(O=Yi(b+C,o[1][0])),u&&S>0?B=Wi(_+S,o[0][1]):!u&&S<0&&(B=Yi(_+M,o[1][1])),P=Math.max(P,O),D=Math.max(D,B)}if(s){if(d){const O=ph(C/A,y,E)*A;if(P=Math.max(P,O),a){let B=0;!c&&!u||c&&!u&&h?B=Wi(_+q+C/A,a[1][1])*A:B=Yi(_+q+(c?N:-N)/A,a[0][1])*A,P=Math.max(P,B)}if(o){let B=0;!c&&!u||c&&!u&&h?B=Yi(_+C/A,o[1][1])*A:B=Wi(_+(c?N:-N)/A,o[0][1])*A,P=Math.max(P,B)}}if(f){const O=ph(M*A,g,x)/A;if(D=Math.max(D,O),a){let B=0;!c&&!u||u&&!c&&h?B=Wi(b+M*A+U,a[1][0])/A:B=Yi(b+(u?S:-S)*A+U,a[0][0])/A,D=Math.max(D,B)}if(o){let B=0;!c&&!u||u&&!c&&h?B=Yi(b+M*A,o[1][0])/A:B=Wi(b+(u?S:-S)*A,o[0][0])/A,D=Math.max(D,B)}}}S=S+(S<0?D:-D),N=N+(N<0?P:-P),s&&(h?C>M*A?S=(XN(c,u)?-N:N)/A:N=(XN(c,u)?-S:S)*A:d?(S=N/A,u=c):(N=S*A,c=u));const I=c?b+N:b,L=u?_+S:_;return{width:k+(c?-N:N),height:T+(u?-S:S),x:i[0]*N*(c?-1:1)+I,y:i[1]*S*(u?-1:1)+L}}const sj={width:0,height:0,x:0,y:0},yce={...sj,pointerX:0,pointerY:0,aspectRatio:1};function bce(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,o=n[0]*i,c=n[1]*a;return[[r-o,s-c],[r+i-o,s+a-c]]}function Ece({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Ur(e);let a={controlDirection:GN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function o({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:m,onResizeEnd:g,shouldResize:x}){let y={...sj},E={...yce};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:GN(u)};let b,_=null,k=[],T,A,N,S=!1;const C=pP().on("start",M=>{const{nodeLookup:U,transform:q,snapGrid:P,snapToGrid:D,nodeOrigin:I,paneDomNode:L}=n();if(b=U.get(t),!b)return;_=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:O,ySnapped:B}=ju(M.sourceEvent,{transform:q,snapGrid:P,snapToGrid:D,containerBounds:_});y={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},E={...y,pointerX:O,pointerY:B,aspectRatio:y.width/y.height},T=void 0,A=xo(b.extent)?b.extent:void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(T=U.get(b.parentId)),T&&b.extent==="parent"&&(A=[[0,0],[T.measured.width,T.measured.height]]),k=[],N=void 0;for(const[R,z]of U)if(z.parentId===t&&(k.push({id:R,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const Y=bce(z,b,z.origin??I);N?N=[[Math.min(Y[0][0],N[0][0]),Math.min(Y[0][1],N[0][1])],[Math.max(Y[1][0],N[1][0]),Math.max(Y[1][1],N[1][1])]]:N=Y}p==null||p(M,{...y})}).on("drag",M=>{const{transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D}=n(),I=ju(M.sourceEvent,{transform:U,snapGrid:q,snapToGrid:P,containerBounds:_}),L=[];if(!b)return;const{x:O,y:B,width:R,height:z}=y,Y={},j=b.origin??D,{width:re,height:V,x:ee,y:oe}=gce(E,a.controlDirection,I,a.boundaries,a.keepAspectRatio,j,A,N),X=re!==R,ae=V!==z,Z=ee!==O&&X,de=oe!==B&&ae;if(!Z&&!de&&!X&&!ae)return;if((Z||de||j[0]===1||j[1]===1)&&(Y.x=Z?ee:y.x,Y.y=de?oe:y.y,y.x=Y.x,y.y=Y.y,k.length>0)){const be=ee-O,_e=oe-B;for(const Pe of k)Pe.position={x:Pe.position.x-be+j[0]*(re-R),y:Pe.position.y-_e+j[1]*(V-z)},L.push(Pe)}if((X||ae)&&(Y.width=X&&(!a.resizeDirection||a.resizeDirection==="horizontal")?re:y.width,Y.height=ae&&(!a.resizeDirection||a.resizeDirection==="vertical")?V:y.height,y.width=Y.width,y.height=Y.height),T&&b.expandParent){const be=j[0]*(Y.width??0);Y.x&&Y.x{S&&(g==null||g(M,{...y}),s==null||s({...y}),S=!1)});i.call(C)}function c(){i.on(".drag",null)}return{update:o,destroy:c}}var ij={exports:{}},aj={},oj={exports:{}},lj={};/** +`);if(!n.length||n[0].trim()!=="---")throw new ya(`${t} 的 SKILL.md 必须以 YAML frontmatter (--- ... ---) 开头`);let r=-1;for(let o=1;o=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))}function rse(e,t){if(!e)throw new ya(`${t} 的 SKILL.md 缺少必填的 name frontmatter`);if(e.length>64)throw new ya(`${t} 的 name 长度超过 64 个字符`);if(!/^[a-z0-9-]+$/.test(e))throw new ya(`${t} 的 name 必须匹配 [a-z0-9-]+(小写字母、数字、短横线)`)}function sse(e,t){if(!e)throw new ya(`${t} 的 SKILL.md 缺少必填的 description frontmatter`);if(e.length>1024)throw new ya(`${t} 的 description 长度超过 1024 个字符`);if(/<[^>]+>/.test(e))throw new ya(`${t} 的 description 不能包含 XML 标签`)}function FD(e){const t=e.map(r=>({path:r.path.replace(/\\/g,"/").replace(/^\.\//,""),text:r.text})).filter(r=>r.path.length>0&&!r.path.endsWith("/")),n=new Set(t.map(r=>r.path.split("/")[0]));if(n.size===1&&t.every(r=>r.path.includes("/"))){const r=[...n][0]+"/";return t.map(s=>({path:s.path.slice(r.length),text:s.text}))}return t}function ise(e){const t=new Map,n=new Set;for(const r of e)if(T1.test("/"+r.path)){const s=r.path.split("/");n.add(s.slice(0,-1).join("/"))}for(const r of e){const s=r.path.split("/");let i="";for(let u=s.length-1;u>=0;u--){const d=s.slice(0,u).join("/");if(n.has(d)){i=d;break}}const a=T1.test("/"+r.path);if(!i&&!a&&!n.has("")||!n.has(i)&&!a)continue;const o=i?r.path.slice(i.length+1):r.path,c=t.get(i)||[];c.push({path:o,text:r.text}),t.set(i,c)}return t}function ase(e,t,n){const r=`${n}${e?"/"+e:""}`,s=t.find(c=>T1.test("/"+c.path));if(!s)return{hit:null,error:`${r} 缺少 SKILL.md`};let i;try{i=tse(s.text,r)}catch(c){return{hit:null,error:c instanceof Error?c.message:String(c)}}const a=i.name,o=[];for(const c of t){if(c.path.split("/").some(f=>f===".."))return{hit:null,error:`${r} 包含非法路径(..):${c.path}`};const d=`skills/${a}/${c.path}`;if(!d.startsWith(`skills/${a}/`))return{hit:null,error:`${r} 包含非法路径:${c.path}`};o.push({path:d,content:c.text})}return{hit:{source:"local",id:`local:${a}:${t.length}`,name:i.name,description:i.description,folder:a,localFiles:o},error:null}}async function ose(e){const t=new Uint8Array(await e.arrayBuffer()),r=(await BD(t)).map(s=>({path:s.name,text:s.text}));return UD(FD(r),e.name)}async function lse(e,t=new Map){const n=[];for(let r=0;re.file(t,n))}async function use(e){const t=e.createReader(),n=[];for(;;){const r=await new Promise((s,i)=>t.readEntries(s,i));if(r.length===0)return n;n.push(...r)}}async function $D(e,t=""){const n=t?`${t}/${e.name}`:e.name;if(e.isFile)return[{file:await cse(e),path:n}];if(!e.isDirectory)return[];const r=await use(e);return(await Promise.all(r.map(s=>$D(s,n)))).flat()}function dse({selected:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState([]),[a,o]=v.useState(!1),[c,u]=v.useState(!1),d=v.useRef(0),f=b=>e.some(_=>_.source==="local"&&_.folder===b),h=b=>{b.localFiles&&(f(b.folder||b.name)?t(e.filter(_=>!(_.source==="local"&&_.folder===(b.folder||b.name)))):t([...e,{source:"local",folder:b.folder||b.name,name:b.name,description:b.description,localFiles:b.localFiles}]))},p=v.useRef([]),m=v.useRef(e);v.useEffect(()=>{p.current=s},[s]),v.useEffect(()=>{m.current=e},[e]);const g=b=>{const _=new Set([...p.current.map(N=>N.folder||N.name),...m.current.filter(N=>N.source==="local").map(N=>N.folder)]),k=[],T=[];for(const N of b.hits){const S=N.folder||N.name;if(_.has(S)){k.push(N.name);continue}_.add(S),T.push(N)}i(N=>[...N,...T]);const A=[...b.errors];if(k.length>0&&A.push(`已跳过重复技能:${k.join("、")}`),r(A),T.length===1&&b.errors.length===0&&k.length===0){const N=T[0];N.localFiles&&t([...m.current,{source:"local",folder:N.folder||N.name,name:N.name,description:N.description,localFiles:N.localFiles}])}},x=b=>{b.preventDefault(),d.current+=1,u(!0)},y=b=>{b.preventDefault(),d.current=Math.max(0,d.current-1),d.current===0&&u(!1)},E=async b=>{if(b.preventDefault(),d.current=0,u(!1),a)return;const _=Array.from(b.dataTransfer.items).map(k=>{var T;return(T=k.webkitGetAsEntry)==null?void 0:T.call(k)}).filter(k=>k!==null);if(_.length===0){r(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}o(!0);try{const k=(await Promise.all(_.map(N=>$D(N)))).flat(),T=_.some(N=>N.isDirectory);if(!T&&k.length===1&&k[0].file.name.toLowerCase().endsWith(".zip")){g(await ose(k[0].file));return}if(!T){r(["请拖入包含 SKILL.md 的文件夹或一个 .zip 文件"]);return}const A=new Map(k.map(({file:N,path:S})=>[N,S]));g(await lse(k.map(({file:N})=>N),A))}catch(k){r([`读取失败:${k instanceof Error?k.message:String(k)}`])}finally{o(!1)}};return l.jsxs("div",{className:"cw-local",children:[l.jsxs("div",{className:`cw-local-dropzone ${c?"is-dragging":""}`,role:"group","aria-label":"拖入文件夹或 ZIP,自动识别 Skill",onDragEnter:x,onDragOver:b=>b.preventDefault(),onDragLeave:y,onDrop:b=>void E(b),children:[l.jsx(vx,{className:"cw-local-drop-icon","aria-hidden":!0}),l.jsx("p",{className:"cw-local-drop-hint",children:"拖入文件夹或 ZIP,自动识别 Skill"})]}),l.jsx("p",{className:"cw-local-hint",children:"每个技能需包含 SKILL.md(含 name / description frontmatter)。支持包含多个技能的目录。"}),a&&l.jsx("p",{className:"cw-empty-line",children:"正在读取文件…"}),n.length>0&&l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:n.join(";")})]}),s.length>0&&l.jsx("div",{className:"cw-skill-results",children:s.map(b=>{var k;const _=f(b.folder||b.name);return l.jsxs("button",{type:"button",className:`cw-skill-result ${_?"is-on":""}`,onClick:()=>h(b),"aria-pressed":_,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:_?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsx("span",{className:"cw-skill-result-name",children:b.name}),b.description&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(b.description)}),l.jsxs("span",{className:"cw-skill-result-repo",children:["本地 · ",((k=b.localFiles)==null?void 0:k.length)??0," 个文件"]})]})]},b.id)})})]})}function fse({selected:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState([]),[a,o]=v.useState(""),[c,u]=v.useState(!0),[d,f]=v.useState(!1),[h,p]=v.useState(null);v.useEffect(()=>{let y=!1;return(async()=>{u(!0),p(null);try{const E=await NL();y||(r(E),E.length>0&&o(E[0].id))}catch(E){y||p(E instanceof Error?E.message:"加载失败")}finally{y||u(!1)}})(),()=>{y=!0}},[]),v.useEffect(()=>{if(!a){i([]);return}const y=n.find(b=>b.id===a);let E=!1;return(async()=>{f(!0),p(null);try{const b=await AL(a,y==null?void 0:y.region);E||i(b)}catch(b){E||p(b instanceof Error?b.message:"加载失败")}finally{E||f(!1)}})(),()=>{E=!0}},[a,n]);const m=n.find(y=>y.id===a),g=(y,E)=>e.some(b=>b.source==="skillspace"&&b.skillId===y&&(b.version||"")===E),x=y=>{if(m)if(g(y.skillId,y.version))t(e.filter(E=>!(E.source==="skillspace"&&E.skillId===y.skillId&&(E.version||"")===y.version)));else{const E=w$(m,y);t([...e,{source:"skillspace",folder:E.folder||y.skillName,name:E.name,description:E.description,skillSpaceId:E.skillSpaceId,skillSpaceName:E.skillSpaceName,skillSpaceRegion:E.skillSpaceRegion,skillId:E.skillId,version:E.version}])}};return l.jsx("div",{className:"cw-skillspace",children:c?l.jsxs("p",{className:"cw-empty-line",children:[l.jsx(bt,{className:"cw-i cw-spin"})," 正在加载 AgentKit Skills 中心…"]}):h?l.jsxs("div",{className:"cw-banner",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:h})]}):n.length===0?l.jsx("p",{className:"cw-empty-line",children:"此账号下没有 AgentKit Skills 中心。"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-skillspace-header",children:[l.jsx("select",{className:"cw-input cw-skillspace-select",value:a,onChange:y=>o(y.target.value),"aria-label":"选择 AgentKit Skills 中心",children:n.map(y=>l.jsxs("option",{value:y.id,children:[y.name||y.id,y.region?` [${y.region}]`:"",y.description?` — ${hs(y.description)}`:""]},y.id))}),m&&l.jsx("a",{href:v$(m.id,m.region),target:"_blank",rel:"noopener noreferrer",className:"cw-button cw-button-secondary cw-skillspace-console-link",title:"在火山引擎控制台打开",children:l.jsx(wx,{className:"cw-i cw-i-sm"})})]}),d?l.jsxs("p",{className:"cw-empty-line",children:[l.jsx(bt,{className:"cw-i cw-spin"})," 正在加载技能列表…"]}):s.length===0?l.jsx("p",{className:"cw-empty-line",children:"此 AgentKit Skills 中心暂无技能。"}):l.jsx("div",{className:"cw-skill-results",children:s.map(y=>{const E=g(y.skillId,y.version);return l.jsxs("button",{type:"button",className:`cw-skill-result ${E?"is-on":""}`,onClick:()=>x(y),"aria-pressed":E,children:[l.jsx("span",{className:"cw-skill-result-icon","aria-hidden":!0,children:E?l.jsx(Bs,{className:"cw-i cw-i-sm"}):l.jsx(Ps,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-skill-result-meta",children:[l.jsxs("span",{className:"cw-skill-result-name",children:[y.skillName,y.version&&l.jsxs("span",{className:"cw-skill-result-version",children:[" ","v",y.version]})]}),y.skillDescription&&l.jsx("span",{className:"cw-skill-result-desc",children:hs(y.skillDescription)}),l.jsxs("span",{className:"cw-skill-result-repo",children:[l.jsx(n7,{className:"cw-i cw-i-sm"})," ",(m==null?void 0:m.name)||a]})]})]},`${y.skillId}/${y.version}`)})})]})})}async function hse(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine 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 pse(e={}){const t=new URLSearchParams({region:e.region||"cn-beijing",page_size:String(e.pageSize??100),project:e.project||"default"});return(await hse(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function mse(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:Ls(void 0,gc)});if(t.status===409)throw new Error("服务端未配置 Volcengine 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 gse(e={}){const t=new URLSearchParams({region:e.region||"cn-beijing",project:e.project||"default"});return(await mse(`/web/viking-knowledgebases?${t.toString()}`)).items||[]}const yse=v.lazy(()=>Al(()=>import("./MarkdownPromptEditor-Di7BE6IZ.js"),__vite__mapDeps([0,1])));function bse(e,t,n="text/plain"){const r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(r)}const pN=[{id:"type",label:"类型",hint:"选择 Agent 类型",icon:M7,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:Aa,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:s7},{id:"tools",label:"工具",hint:"可调用的能力",icon:zR},{id:"skills",label:"技能",hint:"声明式技能",icon:ho},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:Mh},{id:"advanced",label:"进阶配置",hint:"记忆与观测",icon:FR},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:OR},{id:"review",label:"完成",hint:"预览并创建",icon:R7}];function Ese({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"m7.2 15.8 7.9-7.9a2 2 0 0 1 2.8 0l1.2 1.2a2 2 0 0 1 0 2.8l-7 7H8.7l-1.5-1.5a1.15 1.15 0 0 1 0-1.6Z"}),l.jsx("path",{d:"m12.7 10.3 4 4"}),l.jsx("path",{d:"M6.3 19h12.4"}),l.jsx("path",{d:"m5.5 8.2.5-1.4 1.4-.5L6 5.8l-.5-1.4L5 5.8l-1.4.5 1.4.5.5 1.4Z"})]})}function xse({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.25",y:"4.25",width:"17.5",height:"15.5",rx:"2.75"}),l.jsx("path",{d:"M3.75 8.75h16.5"}),l.jsx("circle",{cx:"6.35",cy:"6.5",r:"0.72",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"8.85",cy:"6.5",r:"0.72",fill:"currentColor",stroke:"none",opacity:"0.45"}),l.jsx("path",{d:"M6 14h2.2l1.35-2.8 2.1 5.5 1.7-3.1H18"})]})}function wse({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.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"}),l.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),l.jsx("path",{d:"M3 10v4",opacity:"0.45"}),l.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function HD({className:e}){return l.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m7 9 5 5 5-5"})})}function zD({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),l.jsx("path",{d:"M4.5 4.75v3.5H8"}),l.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),l.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const iy=4,vse={llm:"LLM 智能体",sequential:"顺序型智能体",parallel:"并行型智能体",loop:"循环型智能体",a2a:"远程智能体"},mN={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},VD="REGISTRY_SPACE_ID",_se=y3.filter(e=>e.key!==VD);function KD(e,t){var r,s,i;if(!(e!=null&&e.enabled))return{};const n={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(n.REGISTRY_TOP_K=((r=e.registryTopK)==null?void 0:r.trim())||Ms.topK,n.REGISTRY_REGION=((s=e.registryRegion)==null?void 0:s.trim())||Ms.region,n.REGISTRY_ENDPOINT=((i=e.registryEndpoint)==null?void 0:i.trim())||Ms.endpoint):(n.REGISTRY_TOP_K=e.registryTopK??"",n.REGISTRY_REGION=e.registryRegion??"",n.REGISTRY_ENDPOINT=e.registryEndpoint??""),n}function gN({items:e,selected:t,onToggle:n,scrollRows:r}){return l.jsx("div",{className:`cw-checklist ${r?"cw-checklist-tools":""}`,style:r?{"--cw-checklist-max-height":`${r*65+(r-1)*8}px`}:void 0,children:e.map(s=>{const i=t.includes(s.id);return l.jsxs("button",{type:"button",className:`cw-check ${i?"is-on":""}`,onClick:()=>n(s.id),"aria-pressed":i,children:[l.jsx("span",{className:"cw-check-box","aria-hidden":!0,children:i&&l.jsx(Bs,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-check-text",children:[l.jsx("span",{className:"cw-check-title",children:s.label}),l.jsx("span",{className:"cw-check-desc",children:hs(s.desc)})]})]},s.id)})})}function ay({options:e,value:t,onChange:n}){return l.jsx("div",{className:"cw-segmented",children:e.map(r=>{var i;const s=(t??((i=e[0])==null?void 0:i.id))===r.id;return l.jsxs("button",{type:"button",className:`cw-seg ${s?"is-on":""}`,onClick:()=>n(r.id),"aria-pressed":s,title:hs(r.desc),children:[l.jsx("span",{className:"cw-seg-title",children:r.label}),l.jsx("span",{className:"cw-seg-desc",children:hs(r.desc)})]},r.id)})})}function kse(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function Ho({env:e,values:t,onChange:n}){return e.length===0?l.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):l.jsx("div",{className:"cw-env-fields",children:e.map(r=>l.jsxs("label",{className:"cw-env-field",children:[l.jsxs("span",{className:"cw-env-field-head",children:[l.jsxs("span",{className:"cw-env-field-label",children:[r.comment||r.key,r.required&&l.jsx("span",{className:"cw-req",children:"*"})]}),r.comment&&l.jsx("code",{title:r.key,children:r.key})]}),l.jsx("input",{className:"cw-input",type:kse(r.key)?"password":"text",value:t[r.key]??"",placeholder:r.placeholder||"请输入参数值",autoComplete:"off",onChange:s=>n(r.key,s.currentTarget.value)})]},r.key))})}function oy(e){return e.name.trim()||"未命名智能体中心"}function ly(e){return e.name.trim()||e.id||"未命名知识库"}function Tse({value:e,region:t,invalid:n,onChange:r}){const s=t.trim()||Ms.region,[i,a]=v.useState([]),[o,c]=v.useState(!1),[u,d]=v.useState(null),[f,h]=v.useState(0),[p,m]=v.useState(!1),[g,x]=v.useState(""),y=v.useRef(null);v.useEffect(()=>{let S=!1;return c(!0),d(null),pse({region:s}).then(C=>{S||a(C)}).catch(C=>{S||(a([]),d(C instanceof Error?C.message:"加载失败"))}).finally(()=>{S||c(!1)}),()=>{S=!0}},[s,f]);const E=!e||i.some(S=>S.id===e.trim()),b=i.find(S=>S.id===e.trim()),_=b?oy(b):e&&!E?"已选择的智能体中心":"请选择智能体中心",k=o&&i.length===0,T=v.useMemo(()=>i.filter(S=>rm(g,[oy(S),S.id,S.projectName])),[g,i]),A=!!(e&&!E&&rm(g,["已选择的智能体中心",e]));v.useEffect(()=>{if(!p)return;const S=M=>{const U=M.target;U instanceof Node&&y.current&&!y.current.contains(U)&&m(!1)},C=M=>{M.key==="Escape"&&m(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",C),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",C)}},[p]);const N=S=>{r(S),m(!1)};return l.jsxs("div",{className:"cw-a2a-space-picker",ref:y,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:k,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{x(""),m(S=>!S)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:_}),l.jsx(HD,{className:"cw-a2a-space-trigger-icon"})]}),p&&l.jsxs("div",{className:"cw-a2a-space-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:g,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:S=>x(S.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[A&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>N(e),children:"已选择的智能体中心"}),T.map(S=>{const C=oy(S),M=S.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":M,className:`cw-a2a-space-option ${M?"is-selected":""}`,title:`${C} (${S.id})`,onClick:()=>N(S.id),children:C},S.id)}),!A&&T.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:o,onClick:()=>h(S=>S+1),children:o?l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(zD,{className:"cw-i cw-i-sm"})})]}),u?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:u})]}):o?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):i.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",i.length," 个智能体中心,列表仅展示中心名称。"]})]})}function Sse({value:e,onChange:t}){const[n,r]=v.useState([]),[s,i]=v.useState(!1),[a,o]=v.useState(null),[c,u]=v.useState(0),[d,f]=v.useState(!1),[h,p]=v.useState(""),m=v.useRef(null);v.useEffect(()=>{let T=!1;return i(!0),o(null),gse().then(A=>{T||r(A)}).catch(A=>{T||(r([]),o(A instanceof Error?A.message:"加载失败"))}).finally(()=>{T||i(!1)}),()=>{T=!0}},[c]);const g=!e||n.some(T=>T.id===e.trim()),x=n.find(T=>T.id===e.trim()),y=x?ly(x):e&&!g?e:"请选择 VikingDB 知识库",E=s&&n.length===0,b=v.useMemo(()=>n.filter(T=>rm(h,[ly(T),T.id,T.description,T.projectName])),[n,h]),_=!!(e&&!g&&rm(h,[e]));v.useEffect(()=>{if(!d)return;const T=N=>{const S=N.target;S instanceof Node&&m.current&&!m.current.contains(S)&&f(!1)},A=N=>{N.key==="Escape"&&f(!1)};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",A),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",A)}},[d]);const k=T=>{t(T),f(!1)};return l.jsxs("div",{className:"cw-a2a-space-picker cw-viking-kb-picker",ref:m,children:[l.jsxs("div",{className:"cw-a2a-space-row",children:[l.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[l.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:E,"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"选择 VikingDB 知识库",onClick:()=>{p(""),f(T=>!T)},children:[l.jsx("span",{className:e?void 0:"is-placeholder",children:y}),l.jsx(HD,{className:"cw-a2a-space-trigger-icon"})]}),d&&l.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[l.jsx("div",{className:"cw-picker-search",children:l.jsx("input",{className:"cw-picker-search-input",type:"search",value:h,autoFocus:!0,autoComplete:"off","aria-label":"搜索 VikingDB 知识库",placeholder:"搜索名称或 ID",onChange:T=>p(T.currentTarget.value)})}),l.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"VikingDB 知识库",children:[_&&l.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>k(e),children:e}),b.map(T=>{const A=ly(T),N=T.id===e;return l.jsx("button",{type:"button",role:"option","aria-selected":N,className:`cw-a2a-space-option ${N?"is-selected":""}`,title:`${A} (${T.id})`,onClick:()=>k(T.id),children:A},T.id)}),!_&&b.length===0&&l.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的知识库"})]})]})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:"刷新知识库列表","aria-label":"刷新知识库列表",disabled:s,onClick:()=>u(T=>T+1),children:s?l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}):l.jsx(zD,{className:"cw-i cw-i-sm"})})]}),a?l.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[l.jsx(Aa,{className:"cw-i"}),l.jsx("span",{children:a})]}):s?l.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[l.jsx(bt,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 VikingDB 知识库…"]}):n.length===0?l.jsx("span",{className:"cw-help",children:"此账号下暂无 VikingDB 知识库。"}):l.jsxs("span",{className:"cw-help",children:["已加载 ",n.length," 个知识库,选择的知识库会用于当前 Agent。"]})]})}function Nse({tools:e,onChange:t}){const n=(i,a)=>t(e.map((o,c)=>c===i?{...o,...a}:o)),r=i=>t(e.filter((a,o)=>o!==i)),s=()=>t([...e,{name:"",transport:"http",url:""}]);return l.jsxs("div",{className:"cw-mcp",children:[e.length>0&&l.jsx("div",{className:"cw-mcp-list",children:l.jsx(Js,{initial:!1,children:e.map((i,a)=>l.jsxs(Rt.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:[l.jsxs("div",{className:"cw-mcp-rowhead",children:[l.jsxs("div",{className:"cw-mcp-transport",children:[l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${i.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":i.transport==="http",children:l.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),l.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${i.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":i.transport==="stdio",children:l.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>r(a),"aria-label":"移除 MCP 工具",children:l.jsx(mc,{className:"cw-i cw-i-sm"})})]}),l.jsx("input",{className:"cw-input",value:i.name,placeholder:"名称(用于命名,可留空)",onChange:o=>n(a,{name:o.target.value})}),i.transport==="http"?l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:i.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:o=>n(a,{url:o.target.value})}),l.jsx("input",{className:"cw-input",value:i.authToken??"",placeholder:"Bearer Token(可选)",onChange:o=>n(a,{authToken:o.target.value})})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"cw-input",value:i.command??"",placeholder:"启动命令,例如 npx",onChange:o=>n(a,{command:o.target.value})}),l.jsx("input",{className:"cw-input",value:(i.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:o=>n(a,{args:o.target.value.split(/\s+/).filter(Boolean)})}),l.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),l.jsxs("button",{type:"button",className:"cw-add-sub",onClick:s,children:[l.jsx(Ps,{className:"cw-i"}),"添加 MCP 工具"]}),e.length===0&&l.jsx("p",{className:"cw-empty-line",children:"暂无 MCP 工具,点击「添加 MCP 工具」连接外部 MCP 服务。"})]})}function YD({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M5.5 7.5h10.75a2 2 0 0 1 2 2v7.75a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V9.5a2 2 0 0 1 2-2Z"}),l.jsx("path",{d:"M7 4.75h9.5a2 2 0 0 1 2 2",opacity:".58"}),l.jsx("path",{d:"m11 10.25.72 1.48 1.63.24-1.18 1.15.28 1.62-1.45-.77-1.45.77.28-1.62-1.18-1.15 1.63-.24.72-1.48Z"}),l.jsx("path",{d:"M19.25 11.25h1.5M20 10.5V12",opacity:".72"})]})}function Ase({s:e,onRemove:t}){let n=ho,r="火山 Find Skill 技能广场";return e.source==="local"?(n=vx,r="本地"):e.source==="skillspace"&&(n=YD,r="AgentKit Skills 中心"),l.jsxs(Rt.div,{className:"cw-selected-skill-row",layout:!0,initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16},children:[l.jsx("span",{className:"cw-selected-skill-icon","aria-hidden":!0,children:l.jsx(n,{className:"cw-i cw-i-sm"})}),l.jsxs("span",{className:"cw-selected-skill-meta",children:[l.jsx("span",{className:"cw-selected-skill-name",children:e.name}),l.jsxs("span",{className:"cw-selected-skill-detail",children:[r,e.description?` · ${hs(e.description)}`:""]})]}),l.jsx("button",{type:"button",className:"cw-selected-skill-remove",onClick:t,"aria-label":`移除 ${e.name}`,title:`移除 ${e.name}`,children:l.jsx(Wr,{className:"cw-i cw-i-sm"})})]},`${e.source}:${e.folder}:${e.skillId||e.slug||""}:${e.version||""}`)}const cy=[{id:"local",label:"本地文件",icon:vx},{id:"skillspace",label:"AgentKit Skills 中心",icon:YD},{id:"skillhub",label:"火山 Find Skill 技能广场",icon:_x}];function Cse({selected:e,onChange:t}){const[n,r]=v.useState("local"),[s,i]=v.useState(!1),a=cy.findIndex(c=>c.id===n),o=c=>t(e.filter(u=>uy(u)!==c));return v.useEffect(()=>{if(!s)return;const c=u=>{u.key==="Escape"&&i(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),l.jsxs("div",{className:"cw-skillspane",children:[l.jsxs("button",{type:"button",className:"cw-skill-add","aria-haspopup":"dialog",onClick:()=>i(!0),children:[l.jsx("span",{className:"cw-skill-add-icon","aria-hidden":!0,children:l.jsx(Ps,{className:"cw-i"})}),l.jsx("span",{children:"添加 Skill"})]}),e.length>0&&l.jsxs("div",{className:"cw-skill-selected",children:[l.jsxs("span",{className:"cw-skill-selected-label",children:["已加入技能 · ",e.length]}),l.jsx("div",{className:"cw-selected-skill-list",children:l.jsx(Js,{initial:!1,children:e.map(c=>l.jsx(Ase,{s:c,onRemove:()=>o(uy(c))},uy(c)))})})]}),l.jsx(Js,{children:s&&l.jsx(Rt.div,{className:"cw-skill-dialog-backdrop",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},onMouseDown:c=>{c.target===c.currentTarget&&i(!1)},children:l.jsxs(Rt.div,{className:"cw-skill-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"cw-skill-dialog-title",initial:{opacity:0,y:10,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.99},transition:{duration:.18,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-skill-dialog-head",children:[l.jsx("h3",{id:"cw-skill-dialog-title",children:"添加 Skill"}),l.jsx("button",{type:"button",className:"cw-skill-dialog-close","aria-label":"关闭添加 Skill",onClick:()=>i(!1),children:l.jsx(Wr,{className:"cw-i"})})]}),l.jsxs("div",{className:"cw-skill-dialog-body",children:[l.jsxs("div",{className:"cw-skill-sourcetabs",role:"tablist",style:{"--cw-skill-tab-slider-width":`calc((100% - 16px) / ${cy.length})`,"--cw-active-skill-tab-offset":`calc(${a*100}% + ${a*4}px)`},children:[l.jsx("span",{className:"cw-skill-tab-slider","aria-hidden":!0}),cy.map(({id:c,label:u,icon:d})=>l.jsxs("button",{type:"button",role:"tab",id:`cw-skill-tab-${c}`,"aria-controls":"cw-skill-tabpanel","aria-selected":n===c,className:`cw-skill-pickertab ${n===c?"is-on":""}`,onClick:()=>r(c),children:[l.jsx(d,{className:"cw-i cw-i-sm"}),u]},c))]}),l.jsxs("div",{id:"cw-skill-tabpanel",className:"cw-skill-tabbody",role:"tabpanel","aria-labelledby":`cw-skill-tab-${n}`,children:[n==="skillhub"&&l.jsx(ese,{selected:e,onChange:t}),n==="local"&&l.jsx(dse,{selected:e,onChange:t}),n==="skillspace"&&l.jsx(fse,{selected:e,onChange:t})]})]})]})})})]})}function uy(e){return e.source==="skillhub"?`hub:${e.namespace}/${e.slug}`:e.source==="local"?`local:${e.folder}`:`ss:${e.skillSpaceId}/${e.skillId}/${e.version||""}`}function qc({checked:e,onChange:t,title:n,desc:r,icon:s}){return l.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[l.jsx("span",{className:"cw-toggle-icon",children:l.jsx(s,{className:"cw-i"})}),l.jsxs("span",{className:"cw-toggle-text",children:[l.jsx("span",{className:"cw-toggle-title",children:n}),l.jsx("span",{className:"cw-toggle-desc",children:hs(r)})]}),l.jsx("span",{className:"cw-switch","aria-hidden":!0,children:l.jsx(Rt.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}const yN=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function Ise(e,t){var r;let n=e;for(const s of t)if(n=(r=n.subAgents)==null?void 0:r[s],!n)return!1;return!0}function Gh(e,t){let n=e;for(const r of t)n=n.subAgents[r];return n}function rf(e,t,n){if(t.length===0)return n(e);const[r,...s]=t,i=e.subAgents.slice();return i[r]=rf(i[r],s,n),{...e,subAgents:i}}function Rse(e,t){return rf(e,t,n=>({...n,subAgents:[...n.subAgents,_a()]}))}function Lse(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1];return rf(e,n,s=>({...s,subAgents:s.subAgents.filter((i,a)=>a!==r)}))}function Ose(e,t,n,r){return rf(e,t,s=>{const i=s.subAgents.slice(),[a]=i.splice(n,1);return i.splice(r,0,a),{...s,subAgents:i}})}const Mse=e=>e==="sequential"||e==="loop",WD=e=>!nf(e.agentType),Dse=3;function qD(e,t,n=!1){var s;if(nf(e.agentType))return n?"远程 Agent 只能作为子 Agent":(s=e.a2aRegistry)!=null&&s.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const r=Cl(e.name);return r||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":ID(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function GD(e,t,n=[]){const r=[],s=nf(e.agentType),i=qD(e,t,n.length===0);return i&&r.push({path:n,name:s?"远程 Agent":e.name.trim()||"未命名",problem:i}),WD(e)&&e.subAgents.forEach((a,o)=>r.push(...GD(a,t,[...n,o]))),r}function XD(e){return 1+e.subAgents.reduce((t,n)=>t+XD(n),0)}function QD(e){const t=[],n={},r=i=>{var a,o,c,u;for(const d of i.builtinTools??[]){const f=Xl.find(h=>h.id===d);f&&t.push({env:f.env})}if((a=i.a2aRegistry)!=null&&a.enabled&&(t.push({env:y3}),Object.assign(n,KD(i.a2aRegistry,{includeDefaults:!0}))),i.memory.shortTerm&&t.push({env:((o=Gp.find(d=>d.id===(i.shortTermBackend??"local")))==null?void 0:o.env)??[]}),i.memory.longTerm&&t.push({env:((c=Xp.find(d=>d.id===(i.longTermBackend??"local")))==null?void 0:c.env)??[]}),i.knowledgebase&&t.push({env:((u=Qp.find(d=>d.id===(i.knowledgebaseBackend??Ql)))==null?void 0:u.env)??[]}),i.tracing)for(const d of i.tracingExporters??[]){const f=Zp.find(h=>h.id===d);f&&t.push({env:f.env,enableFlag:f.enableFlag})}i.subAgents.forEach(r)};r(e);const s=RD(t);return{specs:s.specs,fixedValues:{...s.fixedValues,...n}}}function ZD({root:e,path:t,selectedPath:n,duplicateNames:r,showErrors:s,validationPulse:i,onSelect:a,onChange:o,onClearRoot:c}){const u=Gh(e,t),d=Iw(u.agentType),f=d.icon,h=t.length===0,p=yN(t,n),m=WD(u),g=m&&t.length{const A=Rse(e,t),N=Gh(A,t).subAgents.length-1;o(A,[...t,N])},y=()=>o(Lse(e,t),t.slice(0,-1)),E=t.slice(0,-1),b=!h&&Mse(Gh(e,E).agentType),[_,k]=v.useState(!1),T=A=>{A.preventDefault(),A.stopPropagation(),k(!1);const N=A.dataTransfer.getData("application/x-agent-path");if(!N)return;let S;try{S=JSON.parse(N)}catch{return}if(!yN(S.slice(0,-1),E))return;const C=S[S.length-1],M=t[t.length-1];C!==M&&o(Ose(e,E,C,M),[...E,M])};return l.jsxs("div",{className:"cw-tree-branch",children:[l.jsxs("div",{className:`cw-tree-node cw-tree-type-${u.agentType??"llm"} ${p?"is-selected":""} ${b?"is-draggable":""} ${_?"is-dragover":""} ${s&&qD(u,r,h)?`is-invalid cw-error-shake-${i%2}`:""}`,role:"button",tabIndex:0,draggable:b,onDragStart:b?A=>{A.dataTransfer.setData("application/x-agent-path",JSON.stringify(t)),A.dataTransfer.effectAllowed="move",A.stopPropagation()}:void 0,onDragOver:b?A=>{A.preventDefault(),k(!0)}:void 0,onDragLeave:b?()=>k(!1):void 0,onDrop:b?T:void 0,onClick:()=>a(t),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),a(t))},children:[l.jsx(f,{className:"cw-tree-icon"}),l.jsxs("span",{className:"cw-tree-main",children:[l.jsx("span",{className:"cw-tree-name",children:nf(u.agentType)?"远程 Agent":u.name.trim()||"未命名"}),l.jsx("span",{className:"cw-tree-type",children:d.label})]}),l.jsxs("span",{className:"cw-tree-actions",children:[h&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-tree-clear",title:"清空根 Agent","aria-label":"清空根 Agent",onClick:A=>{A.stopPropagation(),c()},children:l.jsx(Ese,{className:"cw-i cw-i-sm"})}),g&&l.jsx("button",{type:"button",className:"cw-icon-btn",title:"添加子 Agent",onClick:A=>{A.stopPropagation(),x()},children:l.jsx(Ps,{className:"cw-i cw-i-sm"})}),!h&&l.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",title:"删除",onClick:A=>{A.stopPropagation(),y()},children:l.jsx(mc,{className:"cw-i cw-i-sm"})})]})]}),m&&u.subAgents.length>0&&l.jsx("div",{className:"cw-tree-children",children:u.subAgents.map((A,N)=>l.jsx(ZD,{root:e,path:[...t,N],selectedPath:n,duplicateNames:r,showErrors:s,validationPulse:i,onSelect:a,onChange:o,onClearRoot:c},N))})]})}function S1(e){var t;return{...e,deployment:{feishuEnabled:!!((t=e.deployment)!=null&&t.feishuEnabled)}}}function JD(e){var r,s;const t=QD(e),n={...((r=e.deployment)==null?void 0:r.envValues)??{},...t.fixedValues};return{...S1(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),envValues:Object.fromEntries(LD(t.specs,n).map(({key:i,value:a})=>[i,a]))}}}function bN(e){return JSON.stringify(JD(e))}function Pse({enabled:e,disabledReason:t,phase:n,stale:r,run:s,projectName:i,logs:a,messages:o,input:c,error:u,deploying:d,deployError:f,onInput:h,onSend:p,onRestart:m,onIgnoreChanges:g,onDeploy:x}){const[y,E]=v.useState(!1),b=n==="ready"||n==="sending",_=n==="building"||n==="starting"||n==="sending",k=e&&!s&&n==="idle",T=e&&(n==="building"||n==="starting"),A=!!(s&&r&&!T);return y?l.jsx("aside",{className:"cw-debug is-collapsed","aria-label":"调试窗口(已收起)",children:l.jsx("button",{type:"button",className:"cw-debug-expand",onClick:()=>E(!1),"aria-label":"展开调试栏",title:"展开调试栏",children:l.jsx(xse,{className:"cw-i"})})}):l.jsxs("aside",{className:"cw-debug","aria-label":"调试窗口",children:[l.jsxs("div",{className:"cw-debug-head",children:[l.jsxs("div",{className:"cw-debug-title",children:[l.jsx("button",{type:"button",className:"cw-debug-collapse",onClick:()=>E(!0),"aria-label":"收起调试栏",title:"收起调试栏",children:l.jsx(Nr,{className:"cw-i cw-i-sm"})}),l.jsx("span",{children:"调试"})]}),l.jsx("div",{className:"cw-debug-head-actions",children:l.jsxs("button",{type:"button",className:"cw-debug-deploy",disabled:d,onClick:x,title:"查看源码、填写环境变量并部署",children:["去部署",d?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(IR,{className:"cw-i"})]})})]}),!s&&n==="idle"&&!e&&l.jsx("div",{className:"cw-debug-sub",children:l.jsx("span",{children:t})}),f&&l.jsx("div",{className:"cw-debug-deploy-error",role:"alert",children:f}),l.jsxs("div",{className:"cw-debug-stage",children:[l.jsx("div",{className:"cw-debug-body",children:e?n==="error"?l.jsxs("div",{className:"cw-debug-error",children:[l.jsx(nm,{message:u||"调试失败",className:"cw-debug-error-detail",onRetry:async()=>{await m()}}),a.length>0&&l.jsx("div",{className:"cw-debug-progress",children:a.map((N,S)=>l.jsx("div",{className:"cw-debug-logline",children:l.jsx("span",{children:N})},`${N}-${S}`))})]}):l.jsx("div",{className:"cw-debug-chat",children:o.length===0?l.jsx("div",{className:"cw-debug-chat-empty",children:"输入消息开始验证当前 Agent。"}):o.map((N,S)=>l.jsxs("div",{className:`cw-debug-msg cw-debug-msg-${N.role}`,children:[l.jsx("div",{className:"cw-debug-role",children:N.role==="user"?"你":i||"Agent"}),l.jsx("div",{className:"cw-debug-content",children:N.role==="user"?N.content:N.error?l.jsx(nm,{message:N.error,className:"cw-debug-msg-error"}):N.blocks&&N.blocks.length>0?l.jsx(hw,{blocks:N.blocks,onAction:()=>{}}):N.content?N.content:S===o.length-1&&n==="sending"?l.jsx(D3,{}):null})]},S))}):l.jsx("div",{className:"cw-debug-empty",children:t})}),l.jsx("div",{className:"cw-debug-composer",children:l.jsxs("div",{className:"cw-debug-composerbox",children:[l.jsx("textarea",{className:"cw-debug-input",rows:1,value:c,placeholder:r?"更新 Agent 后可继续调试":b?"输入测试消息...":"调试环境启动后可输入",disabled:!b||_||r,onChange:N=>h(N.target.value),onKeyDown:N=>{P3(N.nativeEvent)||N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),p())}}),l.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!b||_||r||!c.trim(),onClick:p,children:n==="sending"?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(RR,{className:"cw-i"})})]})}),(k||T||A)&&l.jsx("div",{className:"cw-debug-overlay",role:"status","aria-live":"polite",children:l.jsxs("div",{className:"cw-debug-overlay-content",children:[l.jsx("strong",{className:"cw-debug-overlay-title",children:T?"正在初始化调试环境":A?"Agent 配置已变更":"启动调试环境"}),T?l.jsx("div",{className:"cw-debug-overlay-progress",children:a.map((N,S)=>l.jsxs("div",{className:"cw-debug-logline",children:[S===a.length-1?l.jsx(bt,{className:"cw-i cw-spin"}):l.jsx(Bs,{className:"cw-i"}),l.jsx("span",{children:N})]},`${N}-${S}`))}):A?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"cw-debug-overlay-copy",children:"当前对话仍在使用上一次配置。更新后,新配置才会生效。"}),l.jsxs("div",{className:"cw-debug-overlay-actions",children:[l.jsx("button",{type:"button",className:"cw-debug-ignore",disabled:_,onClick:g,children:"忽略"}),l.jsxs("button",{type:"button",className:"cw-debug-start",disabled:_,onClick:m,children:[l.jsx(kx,{className:"cw-i"}),"更新 Agent"]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"cw-debug-overlay-copy",children:"启动后会生成代码并创建临时运行环境。"}),l.jsxs("button",{type:"button",className:"cw-debug-start",onClick:m,children:[l.jsx(wse,{className:"cw-i cw-debug-run-icon"}),"启动调试环境"]})]})]})})]})]})}function jse({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:r,features:s,onDeploymentTaskChange:i}){var Yn,nr,vn,$t,an,Cn,Wn,on,Mr,Fn,In,qn,Zr,Hs,ps;const[a,o]=v.useState(()=>r??_a()),[c,u]=v.useState(!1),[d,f]=v.useState(0),[h,p]=v.useState(null),[m,g]=v.useState(!1),[x,y]=v.useState("cn-beijing"),E=(s==null?void 0:s.generatedAgentTestRun)===!0,b=(s==null?void 0:s.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[_,k]=v.useState("idle"),[T,A]=v.useState(null),N=v.useRef(null),[S,C]=v.useState(null),[M,U]=v.useState(""),[q,P]=v.useState([]),[D,I]=v.useState([]),[L,O]=v.useState(""),[B,R]=v.useState(null),[z,Y]=v.useState(""),[j,re]=v.useState(""),[V,ee]=v.useState("basic"),[oe,X]=v.useState(""),[ae,Z]=v.useState(!1),[de,ye]=v.useState(!1),[Q,ge]=v.useState(!1),[be,_e]=v.useState(!1),[Pe,we]=v.useState([]),ht=v.useRef(null),je=v.useRef({});v.useEffect(()=>()=>{const ne=N.current;ne&&Wb(ne.runId).catch(Ce=>console.warn("清理调试运行失败",Ce))},[]);const Fe=v.useRef(null);Fe.current||(Fe.current=({meta:ne,children:Ce})=>l.jsxs("section",{ref:He=>{je.current[ne.id]=He},id:`cw-sec-${ne.id}`,"data-step-id":ne.id,className:"cw-section",children:[l.jsx("header",{className:"cw-sec-head",children:l.jsxs("h2",{className:"cw-sec-title",children:[ne.label,ne.required&&l.jsx("span",{className:"cw-sec-required",children:"必填"})]})}),Ce]}));const ut=Ise(a,Pe)?Pe:[],he=Gh(a,ut),Et=ut.length===0,mt=`cw-model-advanced-${ut.join("-")||"root"}`,W=`cw-a2a-registry-advanced-${ut.join("-")||"root"}`,J=`cw-more-tool-types-${ut.join("-")||"root"}`,ce=`cw-advanced-config-${ut.join("-")||"root"}`,ke=Math.max(0,ah.findIndex(ne=>ne.id===(he.agentType??"llm"))),pe=ne=>o(Ce=>rf(Ce,ut,He=>({...He,...ne}))),Xe=(ne,Ce)=>o(He=>{var ct;return{...He,deployment:{...He.deployment??{feishuEnabled:!1},envValues:{...((ct=He.deployment)==null?void 0:ct.envValues)??{},[ne]:Ce}}}}),St=ne=>pe({a2aRegistry:{...he.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...ne}}),We=(ne,Ce)=>{if(!(ne in mN))return;const He=mN[ne];St({[He]:Ce}),Xe(ne,Ce)},Sn=ne=>{if(!(Et&&ne==="a2a")){if(ne==="a2a"){pe({agentType:ne,a2aRegistry:{...he.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}pe({agentType:ne,a2aRegistry:he.a2aRegistry?{...he.a2aRegistry,enabled:!1}:void 0})}},Me=(ne,Ce)=>{o(ne),Ce&&we(Ce)},wt=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(o(_a()),we([]),u(!1),_e(!1))},vt=he.builtinTools??[],Ct=he.mcpTools??[],Gt=he.tracingExporters??[],Ve=he.selectedSkills??[],ot=[he.memory.shortTerm,he.memory.longTerm,he.tracing].filter(Boolean).length,_t=ne=>pe({builtinTools:vt.includes(ne)?vt.filter(Ce=>Ce!==ne):[...vt,ne]}),kt=ne=>{const Ce=Gt.includes(ne)?Gt.filter(He=>He!==ne):[...Gt,ne];pe({tracingExporters:Ce,tracing:Ce.length>0?!0:he.tracing})},le=ID(he.agentType),Le=nf(he.agentType),Ge=v.useMemo(()=>jD(a),[a]),Bt=Le?null:Cl(he.name)??(Ge.has(he.name)?"Agent 名称在当前结构中必须唯一":null),Nn=Bt!==null,nn=!Le&&he.description.trim().length===0,Ft=he.instruction.trim().length===0,Ut=Le&&!((Yn=he.a2aRegistry)!=null&&Yn.registrySpaceId.trim()),wn=ne=>c&&ne?`is-error cw-error-shake-${d%2}`:"",dn=v.useMemo(()=>GD(a,Ge),[a,Ge]),rn=dn.length===0,fn=v.useMemo(()=>bN(a),[a]),se=v.useMemo(()=>QD(a),[a]),ue=!!(T&&z&&z!==fn&&j!==fn);v.useEffect(()=>{j&&j!==fn&&re("")},[fn,j]);const Te=v.useMemo(()=>{var ne,Ce,He,ct;return{type:!0,basic:Le?!Ut:!Nn&&(le||!Ft),model:!!((ne=he.modelName)!=null&&ne.trim()||(Ce=he.modelProvider)!=null&&Ce.trim()||(He=he.modelApiBase)!=null&&He.trim()),tools:vt.length>0||Ct.length>0,skills:Ve.length>0,knowledge:he.knowledgebase,advanced:he.memory.shortTerm||he.memory.longTerm||he.tracing,subagents:(((ct=he.subAgents)==null?void 0:ct.length)??0)>0,review:rn}},[he,Nn,Ft,le,Le,rn,vt,Ct,Ve]),$e=le||Le?["basic"]:["basic","model","tools","skills","knowledge",...Et?["advanced"]:[]],Ie=pN.filter(ne=>$e.includes(ne.id)),lt=$e.join("|"),Nt=ut.join("."),Kn=Ie.findIndex(ne=>ne.id===V),sn=ne=>{var Ce;(Ce=je.current[ne])==null||Ce.scrollIntoView({behavior:"smooth",block:"start"})};v.useEffect(()=>{if(h)return;const ne=ht.current;if(!ne)return;const Ce=lt.split("|");let He=0;const ct=()=>{He=0;const hn=Ce[Ce.length-1];let gt=Ce[0];if(ne.scrollTop+ne.clientHeight>=ne.scrollHeight-2)gt=hn;else{const Gn=ne.getBoundingClientRect().top+24;for(const Xn of Ce){const fr=je.current[Xn];if(!fr||fr.getBoundingClientRect().top>Gn)break;gt=Xn}}gt&&ee(Gn=>Gn===gt?Gn:gt)},Ht=()=>{He||(He=window.requestAnimationFrame(ct))};return ct(),ne.addEventListener("scroll",Ht,{passive:!0}),window.addEventListener("resize",Ht),()=>{ne.removeEventListener("scroll",Ht),window.removeEventListener("resize",Ht),He&&window.cancelAnimationFrame(He)}},[h,lt,Nt]);const Pn=()=>rn?!0:(u(!0),f(ne=>ne+1),dn[0]&&(we(dn[0].path),window.requestAnimationFrame(()=>sn("basic"))),!1),Mt=async()=>{const ne=N.current;if(N.current=null,A(null),C(null),Y(""),re(""),ne)try{await Wb(ne.runId)}catch(Ce){console.warn("清理调试运行失败",Ce)}},jn=async()=>{if(X(""),!!Pn()){g(!0);try{const ne=await Bp(S1(a));await Mt(),k("idle"),U(""),P([]),I([]),O(""),R(null),p(ne)}catch(ne){X(`打开部署页失败:${ne instanceof Error?ne.message:String(ne)}`)}finally{g(!1)}}},Qr=async()=>{if(!E||m||!Pn())return;const ne=bN(a);re(""),R(null),I([]),O(""),P([]),k("building");try{await Mt();const Ce=[],He=hn=>{Ce.push(hn),P([...Ce])};He("提交 Agent 配置"),k("starting"),He("初始化调试环境");const ct=await _L(JD(a));N.current=ct,A(ct),U(ct.appName),He("创建调试会话");const Ht=await kL(ct.runId,"test_user");C(Ht),Y(ne),He("调试环境就绪"),k("ready")}catch(Ce){R(Ce instanceof Error?Ce.message:String(Ce)),k("error")}},vr=async()=>{const ne=N.current,Ce=S,He=L.trim();if(!(!ne||!Ce||!He||_==="sending")){O(""),k("sending"),I(ct=>[...ct,{role:"user",content:He},{role:"assistant",content:"",blocks:[]}]);try{let ct=Ns(),Ht="";for await(const hn of TL({runId:ne.runId,userId:"test_user",sessionId:Ce,text:He})){const gt=hn.error||hn.errorMessage||hn.error_message;if(gt){I(Gn=>{const Xn=[...Gn],fr=Xn[Xn.length-1];return(fr==null?void 0:fr.role)==="assistant"&&(fr.error=String(gt)),Xn});break}ct=zl(ct,hn),Ht=ct.blocks.filter(Gn=>Gn.kind==="text").map(Gn=>Gn.text).join(""),I(Gn=>{const Xn=[...Gn],fr=Xn[Xn.length-1];return(fr==null?void 0:fr.role)==="assistant"&&(fr.content=Ht,fr.blocks=ct.blocks),Xn})}k("ready")}catch(ct){I(Ht=>{const hn=[...Ht],gt=hn[hn.length-1];return(gt==null?void 0:gt.role)==="assistant"&&(gt.error=ct instanceof Error?ct.message:String(ct)),hn}),k("ready")}}};if(h){const ne=async(Ce,He,ct)=>{var gt;const Ht=(gt=a.deployment)==null?void 0:gt.network,hn=Ht&&Ht.mode&&Ht.mode!=="public"?{mode:Ht.mode,vpc_id:Ht.vpcId,subnet_ids:Ht.subnetIds,enable_shared_internet_access:Ht.enableSharedInternetAccess}:void 0;return Um(Ce.name,Ce.files,{region:x,projectName:"default",network:hn},{...ct,onStage:He})};return l.jsx("div",{className:"cw-root cw-root-preview",children:l.jsx("div",{className:"cw-preview-body",children:l.jsx(lg,{project:h,agentDraft:a,agentName:a.name||"未命名 Agent",agentCount:XD(a),onChange:p,onDeploy:ne,onAgentAdded:n,onDeploymentTaskChange:i,feishuEnabled:!!((nr=a.deployment)!=null&&nr.feishuEnabled),onFeishuEnabledChange:async Ce=>{const He={...a,deployment:{...a.deployment??{feishuEnabled:!1},feishuEnabled:Ce}},ct=await Bp(S1(He));o(He),p(ct)},deploymentEnv:se.specs,deploymentEnvValues:{...(vn=a.deployment)==null?void 0:vn.envValues,...se.fixedValues},onDeploymentEnvChange:Xe,network:($t=a.deployment)==null?void 0:$t.network,onNetworkChange:Ce=>o(He=>({...He,deployment:{...He.deployment??{feishuEnabled:!1},network:Ce}})),deployRegion:x,onDeployRegionChange:y,onBack:()=>p(null),onExportYaml:()=>bse(`${a.name||"agent"}.yaml`,xre(a),"text/yaml")})})})}const An=Fe.current,Bn=ne=>pN.find(Ce=>Ce.id===ne);return l.jsx("div",{className:"cw-root",children:l.jsxs("div",{className:"cw-editor",children:[l.jsxs("aside",{className:"cw-tree","aria-label":"Agent 结构",children:[l.jsx("div",{className:"cw-tree-head",children:"Agent 结构"}),l.jsx(ZD,{root:a,path:[],selectedPath:ut,duplicateNames:Ge,showErrors:c,validationPulse:d,onSelect:we,onChange:Me,onClearRoot:wt})]}),l.jsxs("div",{className:"cw-detail",children:[l.jsx("div",{className:"cw-typebar",children:l.jsx("div",{className:"cw-typebar-inner",children:l.jsxs("div",{className:"cw-typeradio cw-typeradio--row",role:"radiogroup","aria-label":"Agent 类型",style:{"--cw-agent-type-gap":`${iy}px`,"--cw-agent-type-slider-width":`calc((100% - ${8+iy*(ah.length-1)}px) / ${ah.length})`,"--cw-active-type-offset":`calc(${ke*100}% + ${ke*iy}px)`},children:[l.jsx("span",{className:"cw-typeradio-slider","aria-hidden":!0}),ah.map(ne=>{const Ce=(he.agentType??"llm")===ne.id,He=Et&&ne.id==="a2a",ct=He?"cw-remote-agent-disabled-hint":void 0;return l.jsxs("label",{className:`cw-typeradio-item ${Ce?"is-on":""} ${He?"is-disabled":""}`,title:He?void 0:ne.desc,tabIndex:He?0:void 0,"aria-describedby":ct,children:[l.jsx("input",{type:"radio",name:"agentType",className:"cw-typeradio-input",checked:Ce,disabled:He,onChange:()=>Sn(ne.id)}),l.jsxs("span",{className:"cw-typeradio-title",children:[vse[ne.id].replace("智能体",""),l.jsx("wbr",{}),"智能体"]}),He&&l.jsx("span",{id:ct,className:"cw-typeradio-disabled-hint",role:"tooltip",children:"远程 Agent 仅可作为子 Agent"})]},ne.id)})]})})}),l.jsx("div",{className:"cw-detail-scroll",ref:ht,children:l.jsx("div",{className:"cw-detail-inner",children:l.jsxs("div",{className:"cw-lower",children:[l.jsxs("div",{className:"cw-form-col",children:[l.jsx(An,{meta:Bn("basic"),children:l.jsxs("div",{className:"cw-form",children:[!Le&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["Agent 名称",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("input",{className:`cw-input ${wn(Nn)}`,value:he.name,placeholder:"customer_service",onChange:ne=>pe({name:ne.target.value})}),c&&Bt?l.jsx("span",{className:"cw-error-text",children:Bt}):l.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在 Agent 结构中保持唯一。"})]}),l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["描述",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${wn(nn)}`,value:he.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…",onChange:ne=>pe({description:ne.target.value})}),c&&nn?l.jsx("span",{className:"cw-error-text",children:"描述为必填项"}):l.jsx("span",{className:"cw-help",children:"描述会显示在 Agent 列表与选择器中。"})]})]}),le?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"cw-section-desc",children:"编排型 Agent 只负责调度子 Agent,不需要模型或系统提示词。请在左侧 「Agent 结构」中为它添加、排序子 Agent。"}),he.agentType==="loop"&&l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"最大轮次"}),l.jsx("input",{className:"cw-input",type:"number",min:1,value:he.maxIterations??3,onChange:ne=>pe({maxIterations:Math.max(1,Number(ne.target.value)||1)})}),l.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):Le?l.jsxs("div",{className:"cw-field cw-remote-center-fields",children:[l.jsxs("div",{className:"cw-remote-center-head",children:[l.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),l.jsx(Tse,{value:((an=he.a2aRegistry)==null?void 0:an.registrySpaceId)??"",region:((Cn=he.a2aRegistry)==null?void 0:Cn.registryRegion)||Ms.region,invalid:c&&Ut,onChange:ne=>We(VD,ne)}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":de,"aria-controls":W,onClick:()=>ye(ne=>!ne),children:[l.jsx("span",{children:"更多选项"}),l.jsx(Nr,{className:`cw-more-options-chevron ${de?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:de&&l.jsx(Rt.div,{id:W,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:l.jsx(Ho,{env:_se,values:KD(he.a2aRegistry,{includeDefaults:!1}),onChange:We})})}),c&&Ut&&l.jsx("span",{className:"cw-error-text",children:"请选择 AgentKit 智能体中心"})]}):l.jsxs("div",{className:"cw-field",children:[l.jsxs("label",{className:"cw-label",children:["系统提示词",l.jsx("span",{className:"cw-req",children:"*"})]}),l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:l.jsx(yse,{value:he.instruction,invalid:Ft,onChange:ne=>pe({instruction:ne})})}),c&&Ft?l.jsx("span",{className:"cw-error-text",children:"系统提示词为必填项"}):l.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!le&&!Le&&l.jsxs(l.Fragment,{children:[l.jsx(An,{meta:Bn("model"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"模型名称"}),l.jsx("input",{className:"cw-input",value:he.modelName??"",placeholder:"doubao-seed-2-1-pro-260628",onChange:ne=>pe({modelName:ne.target.value})})]}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":ae,"aria-controls":mt,onClick:()=>Z(ne=>!ne),children:[l.jsx("span",{children:"更多选项"}),l.jsx(Nr,{className:`cw-more-options-chevron ${ae?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:ae&&l.jsxs(Rt.div,{id:mt,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:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"服务商 Provider"}),l.jsx("input",{className:"cw-input",value:he.modelProvider??"",placeholder:"openai",onChange:ne=>pe({modelProvider:ne.target.value})})]}),l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"API Base"}),l.jsx("input",{className:"cw-input",value:he.modelApiBase??"",placeholder:"https://ark.cn-beijing.volces.com/api/v3/",onChange:ne=>pe({modelApiBase:ne.target.value})}),l.jsx("span",{className:"cw-help",children:"留空则使用 VeADK 默认模型配置;Ark API Key 会由 Studio 服务端凭据自动获取。其他服务商的 Key 可在部署页添加。"})]})]})})]})}),l.jsx(An,{meta:Bn("tools"),children:l.jsxs("div",{className:"cw-form",children:[l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"内置工具"}),l.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),l.jsx("div",{className:"cw-tools-list-shell",children:l.jsx(gN,{items:Xl,selected:vt,onToggle:_t,scrollRows:6})}),l.jsx(Js,{initial:!1,children:vt.includes("run_code")&&l.jsxs(Rt.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:[l.jsxs("div",{className:"cw-tool-config-head",children:[l.jsx("span",{className:"cw-label",children:"代码执行配置"}),l.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),l.jsx(Ho,{env:((Wn=Xl.find(ne=>ne.id==="run_code"))==null?void 0:Wn.env)??[],values:((on=a.deployment)==null?void 0:on.envValues)??{},onChange:Xe})]})})]}),l.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":Q,"aria-controls":J,onClick:()=>ge(ne=>!ne),children:[l.jsx("span",{children:"更多类型工具"}),Ct.length>0&&l.jsxs("span",{className:"cw-more-options-count",children:["已配置 ",Ct.length]}),l.jsx(Nr,{className:`cw-more-options-chevron ${Q?"is-open":""}`,"aria-hidden":!0})]}),l.jsx(Js,{initial:!1,children:Q&&l.jsx(Rt.div,{id:J,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:l.jsxs("div",{className:"cw-field",children:[l.jsx("label",{className:"cw-label",children:"MCP 工具"}),l.jsx("span",{className:"cw-help",children:"连接外部 MCP 服务,生成时会为每个条目创建对应的 MCPToolset。"}),l.jsx(Nse,{tools:Ct,onChange:ne=>pe({mcpTools:ne})})]})})})]})}),l.jsx(An,{meta:Bn("skills"),children:l.jsx("div",{className:"cw-form",children:l.jsx(Cse,{selected:Ve,onChange:ne=>pe({selectedSkills:ne})})})}),l.jsx(An,{meta:Bn("knowledge"),children:l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.knowledgebase,onChange:ne=>pe({knowledgebase:ne}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:Mh}),he.knowledgebase&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"知识库后端"}),l.jsx(ay,{options:Qp,value:he.knowledgebaseBackend,onChange:ne=>pe({knowledgebaseBackend:ne,knowledgebaseIndex:ne==="viking"?he.knowledgebaseIndex:""})}),(he.knowledgebaseBackend??Ql)==="viking"&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),l.jsx(Sse,{value:he.knowledgebaseIndex??"",onChange:ne=>pe({knowledgebaseIndex:ne})})]}),l.jsx(Ho,{env:((Mr=Qp.find(ne=>ne.id===(he.knowledgebaseBackend??Ql)))==null?void 0:Mr.env)??[],values:((Fn=a.deployment)==null?void 0:Fn.envValues)??{},onChange:Xe})]})]})}),Et&&l.jsxs("section",{ref:ne=>{je.current.advanced=ne},id:"cw-sec-advanced","data-step-id":"advanced",className:"cw-section cw-advanced-section",children:[l.jsxs("button",{type:"button",className:"cw-advanced-disclosure","aria-expanded":be,"aria-controls":ce,onClick:()=>_e(ne=>!ne),children:[l.jsx("span",{className:"cw-advanced-disclosure-title",children:"进阶配置"}),l.jsx(Nr,{className:`cw-advanced-disclosure-chevron ${be?"is-open":""}`,"aria-hidden":!0}),ot>0&&l.jsxs("span",{className:"cw-more-options-count",children:["已启用 ",ot]})]}),l.jsx(Js,{initial:!1,children:be&&l.jsxs(Rt.div,{id:ce,className:"cw-advanced-content",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},children:[l.jsxs("div",{className:"cw-advanced-group",children:[l.jsx("div",{className:"cw-advanced-group-head",children:l.jsx("span",{children:"记忆"})}),l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.memory.shortTerm,onChange:ne=>pe({memory:{...he.memory,shortTerm:ne}}),title:"短期记忆",desc:"在单次会话内保留上下文,跨轮次记住对话内容。",icon:FR}),he.memory.shortTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"短期记忆后端"}),l.jsx(ay,{options:Gp,value:he.shortTermBackend,onChange:ne=>pe({shortTermBackend:ne})}),l.jsx(Ho,{env:((In=Gp.find(ne=>ne.id===(he.shortTermBackend??"local")))==null?void 0:In.env)??[],values:((qn=a.deployment)==null?void 0:qn.envValues)??{},onChange:Xe})]}),l.jsx(qc,{checked:he.memory.longTerm,onChange:ne=>pe({memory:{...he.memory,longTerm:ne}}),title:"长期记忆",desc:"跨会话持久化关键信息,让 Agent 记住历史偏好。",icon:Mh}),he.memory.longTerm&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"长期记忆后端"}),l.jsx(ay,{options:Xp,value:he.longTermBackend,onChange:ne=>pe({longTermBackend:ne})}),l.jsx(Ho,{env:((Zr=Xp.find(ne=>ne.id===(he.longTermBackend??"local")))==null?void 0:Zr.env)??[],values:((Hs=a.deployment)==null?void 0:Hs.envValues)??{},onChange:Xe}),l.jsx(qc,{checked:!!he.autoSaveSession,onChange:ne=>pe({autoSaveSession:ne}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:Mh})]})]})]}),l.jsxs("div",{className:"cw-advanced-group",children:[l.jsx("div",{className:"cw-advanced-group-head",children:l.jsx("span",{children:"观测"})}),l.jsxs("div",{className:"cw-form cw-toggle-stack",children:[l.jsx(qc,{checked:he.tracing,onChange:ne=>pe({tracing:ne}),title:"观测 / Tracing",desc:"记录每一步的调用链路与耗时,便于调试与性能分析。",icon:MR}),he.tracing&&l.jsxs("div",{className:"cw-field cw-subfield",children:[l.jsx("label",{className:"cw-label",children:"Tracing 导出器"}),l.jsx("span",{className:"cw-help",children:"选择一个或多个观测平台,生成时会写入对应的 ENABLE_* 开关与环境变量。"}),l.jsx(gN,{items:Zp,selected:Gt,onToggle:kt}),l.jsx(Ho,{env:Zp.filter(ne=>Gt.includes(ne.id)).flatMap(ne=>ne.env),values:((ps=a.deployment)==null?void 0:ps.envValues)??{},onChange:Xe})]})]})]})]})})]})]})]}),l.jsx("nav",{className:"cw-rail","aria-label":"步骤导航",children:l.jsxs("ol",{className:"cw-steps",children:[l.jsx("div",{className:"cw-rail-track","aria-hidden":!0,children:l.jsx(Rt.div,{className:"cw-rail-fill",animate:{height:`${Math.max(Kn,0)/Math.max(Ie.length-1,1)*100}%`},transition:{type:"spring",stiffness:260,damping:32}})}),Ie.map(ne=>{const Ce=ne.id===V,He=Te[ne.id];return l.jsx("li",{children:l.jsxs("button",{type:"button",className:`cw-step ${Ce?"is-active":""} ${He?"is-done":""}`,onClick:()=>sn(ne.id),"aria-current":Ce?"step":void 0,"aria-label":ne.label,children:[l.jsx("span",{className:"cw-step-marker","aria-hidden":!0,children:Ce?l.jsx("span",{className:"cw-dot"}):He?l.jsx(Bs,{className:"cw-step-check"}):l.jsx("span",{className:"cw-dot"})}),l.jsx("span",{className:"cw-step-tooltip","aria-hidden":!0,children:ne.label})]})},ne.id)})]})})]})})})]}),l.jsx(Pse,{enabled:E,disabledReason:b,phase:_,stale:ue,run:T,projectName:M||a.name,logs:q,messages:D,input:L,error:B,deploying:m,deployError:oe,onInput:O,onSend:vr,onRestart:Qr,onIgnoreChanges:()=>re(fn),onDeploy:jn})]})})}function gi(e){return{..._a(),...e}}const Bse=[{id:"support",icon:g7,draft:gi({name:"客服助手",description:"7×24 在线答疑,结合知识库与历史对话,稳定、礼貌地解决用户问题。",instruction:"你是一名专业、耐心的客服助手。请始终保持礼貌、友好的语气,优先依据知识库中的资料回答用户问题;当资料不足以确定答案时,如实告知用户并主动引导其提供更多信息,切勿编造。回答尽量简洁、分点清晰,必要时给出操作步骤。",model:"doubao-1.5-pro-32k",knowledgebase:!0,memory:{shortTerm:!0,longTerm:!0}})},{id:"analyst",icon:ZU,draft:gi({name:"数据分析师",description:"运行代码完成统计与可视化,开启链路追踪,分析过程可观测、可复现。",instruction:"你是一名严谨的数据分析师。面对数据问题时,先厘清分析目标与口径,再通过编写并运行代码完成清洗、统计与可视化。每一步都要说明你的假设与方法,给出结论时附上关键数据支撑,并指出潜在的偏差与局限。",model:"doubao-1.5-pro-32k",tools:["code_runner"],tracing:!0})},{id:"translator",icon:y7,draft:gi({name:"翻译助手",description:"中英互译,忠实、通顺、地道,保留原文语气与专业术语。",instruction:"你是一名专业的翻译助手,精通中英互译。请在忠实于原文含义的前提下,使译文自然、地道、符合目标语言表达习惯;保留专有名词与专业术语的准确性,并尽量贴合原文的语气与风格。仅输出译文,除非用户额外要求解释。",model:"doubao-1.5-pro-32k"})},{id:"coder",icon:bx,draft:gi({name:"代码助手",description:"编写、调试与重构代码,可运行代码验证结果,给出清晰可维护的实现。",instruction:"你是一名资深软件工程师。请根据需求编写正确、清晰、可维护的代码,遵循目标语言的惯用风格与最佳实践。在不确定时通过运行代码验证你的实现,给出关键的边界条件与测试思路,并对复杂逻辑附上简要注释。",model:"doubao-1.5-pro-32k",tools:["code_runner","file_reader"],tracing:!0})},{id:"researcher",icon:T7,draft:gi({name:"研究员",description:"联网检索一手资料,结合知识库与长期记忆,输出有据可查的研究结论。",instruction:"你是一名严谨的研究员。面对研究问题时,先拆解关键子问题,再通过联网检索收集多个一手、可信的来源,交叉验证后再下结论。结论需注明出处与不确定性,区分事实与推断,避免以偏概全。",model:"doubao-1.5-pro-32k",tools:["web_search"],knowledgebase:!0,memory:{shortTerm:!0,longTerm:!0}})},{id:"research-team",icon:B7,draft:gi({name:"多智能体研究团队",description:"由检索员、分析员、撰写员协作的研究编排,分工完成端到端调研报告。",instruction:"你是一支研究团队的总协调者。负责拆解用户的研究任务,将检索、分析、撰写分别委派给对应的子 Agent,汇总各子 Agent 的产出,把控整体质量,最终输出结构清晰、有据可查的研究报告。",model:"doubao-1.5-pro-32k",tracing:!0,memory:{shortTerm:!0,longTerm:!0},subAgents:[gi({name:"检索员",description:"联网搜集与课题相关的一手资料与数据。",instruction:"你是研究团队中的检索员。根据课题联网检索多个可信来源,整理出关键事实、数据与原文出处,交付给分析员,不做主观结论。",tools:["web_search"]}),gi({name:"分析员",description:"对检索到的材料做交叉验证与归纳分析。",instruction:"你是研究团队中的分析员。对检索员提供的材料做交叉验证、归纳与对比,提炼洞见、识别矛盾与不确定性,形成结构化的分析要点。",tools:["code_runner"]}),gi({name:"撰写员",description:"将分析结论组织为结构清晰、引用规范的报告。",instruction:"你是研究团队中的撰写员。把分析员的要点组织成结构清晰、语言通顺、引用规范的研究报告,确保每个结论都能追溯到来源。"})]})}];function Fse(e){const t=[];return e.tools.length&&t.push({icon:zR,label:"工具"}),(e.memory.shortTerm||e.memory.longTerm)&&t.push({icon:QU,label:"记忆"}),e.knowledgebase&&t.push({icon:XU,label:"知识库"}),e.tracing&&t.push({icon:qU,label:"观测"}),e.subAgents.length&&t.push({icon:$R,label:`子Agent ${e.subAgents.length}`}),t}function Use({onBack:e,onCreate:t}){const[n,r]=v.useState(null);return l.jsx("div",{className:"tpl-root",children:n?l.jsx(Hse,{template:n,onBack:()=>r(null),onCreate:t}):l.jsx($se,{onPick:r})})}function $se({onPick:e}){return l.jsxs("div",{className:"tpl-scroll",children:[l.jsxs("div",{className:"tpl-head",children:[l.jsx("h1",{className:"tpl-title",children:"从模板新建"}),l.jsx("p",{className:"tpl-sub",children:"选择一个预制 agent 模板,按需微调后即可创建。"})]}),l.jsx("div",{className:"tpl-grid",children:Bse.map((t,n)=>l.jsxs(Rt.button,{type:"button",className:"tpl-card",onClick:()=>e(t),initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:n*.03,duration:.24,ease:[.22,1,.36,1]},children:[l.jsx("span",{className:"tpl-card-icon",children:l.jsx(t.icon,{className:"icon"})}),l.jsx("span",{className:"tpl-card-name",children:t.draft.name}),l.jsx("span",{className:"tpl-card-desc",children:hs(t.draft.description)})]},t.id))})]})}function Hse({template:e,onBack:t,onCreate:n}){const[r,s]=v.useState(e.draft.name),i=e.icon,a=Fse(e.draft);function o(){const c=r.trim()||e.draft.name;n({...e.draft,name:c})}return l.jsxs("div",{className:"tpl-scroll tpl-scroll--detail",children:[l.jsxs("button",{className:"tpl-back",onClick:t,children:[l.jsx(CR,{className:"icon"})," 返回模板列表"]}),l.jsxs(Rt.div,{className:"tpl-detail",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.22,1,.36,1]},children:[l.jsxs("div",{className:"tpl-detail-head",children:[l.jsx("span",{className:"tpl-detail-icon",children:l.jsx(i,{className:"icon"})}),l.jsxs("div",{className:"tpl-detail-headtext",children:[l.jsx("div",{className:"tpl-detail-name",children:e.draft.name}),l.jsx("div",{className:"tpl-detail-desc",children:hs(e.draft.description)})]})]}),a.length>0&&l.jsx("div",{className:"tpl-tags tpl-tags--detail",children:a.map(c=>l.jsxs("span",{className:"tpl-tag",children:[l.jsx(c.icon,{className:"tpl-tag-icon"})," ",c.label]},c.label))}),l.jsxs("label",{className:"tpl-field",children:[l.jsx("span",{className:"tpl-field-label",children:"名称"}),l.jsx("input",{className:"tpl-input",value:r,onChange:c=>s(c.target.value),placeholder:e.draft.name})]}),l.jsxs("div",{className:"tpl-field",children:[l.jsx("span",{className:"tpl-field-label",children:"系统提示词"}),l.jsx("p",{className:"tpl-instruction",children:e.draft.instruction})]}),l.jsxs("div",{className:"tpl-meta-grid",children:[e.draft.model&&l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"模型"}),l.jsx("span",{className:"tpl-meta-val tpl-mono",children:e.draft.model})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"工具"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.tools.length?e.draft.tools.join("、"):"无"})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"记忆"}),l.jsx("span",{className:"tpl-meta-val",children:zse(e.draft)})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"知识库"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.knowledgebase?"已开启":"关闭"})]}),l.jsxs("div",{className:"tpl-meta",children:[l.jsx("span",{className:"tpl-meta-key",children:"观测追踪"}),l.jsx("span",{className:"tpl-meta-val",children:e.draft.tracing?"已开启":"关闭"})]})]}),e.draft.subAgents.length>0&&l.jsxs("div",{className:"tpl-field",children:[l.jsxs("span",{className:"tpl-field-label",children:["子 Agent(",e.draft.subAgents.length,")"]}),l.jsx("div",{className:"tpl-subagents",children:e.draft.subAgents.map((c,u)=>l.jsxs("div",{className:"tpl-subagent",children:[l.jsxs("div",{className:"tpl-subagent-top",children:[l.jsx("span",{className:"tpl-subagent-name",children:c.name}),c.tools.length>0&&l.jsx("span",{className:"tpl-subagent-tools",children:c.tools.join("、")})]}),l.jsx("div",{className:"tpl-subagent-desc",children:hs(c.description)})]},u))})]}),l.jsxs("button",{className:"tpl-create",onClick:o,children:["使用此模板创建 ",l.jsx(Nr,{className:"icon"})]})]})]})}function zse(e){const t=[];return e.memory.shortTerm&&t.push("短期"),e.memory.longTerm&&t.push("长期"),t.length?t.join(" + "):"关闭"}function Tn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function cg(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Xh.prototype=cg.prototype={constructor:Xh,on:function(e,t){var n=this._,r=Kse(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(s),r=0,s,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),xN.hasOwnProperty(t)?{space:xN[t],local:e}:e}function Wse(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===N1&&t.documentElement.namespaceURI===N1?t.createElement(e):t.createElementNS(n,e)}}function qse(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function eP(e){var t=ug(e);return(t.local?qse:Wse)(t)}function Gse(){}function Rw(e){return e==null?Gse:function(){return this.querySelector(e)}}function Xse(e){typeof e!="function"&&(e=Rw(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=b&&(b=E+1);!(k=x[b])&&++b=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function wie(e){e||(e=vie);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,s=new Array(r),i=0;it?1:e>=t?0:NaN}function _ie(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function kie(){return Array.from(this)}function Tie(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Pie:typeof t=="function"?Bie:jie)(e,t,n??"")):tc(this.node(),e)}function tc(e,t){return e.style.getPropertyValue(t)||iP(e).getComputedStyle(e,null).getPropertyValue(t)}function Uie(e){return function(){delete this[e]}}function $ie(e,t){return function(){this[e]=t}}function Hie(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function zie(e,t){return arguments.length>1?this.each((t==null?Uie:typeof t=="function"?Hie:$ie)(e,t)):this.node()[e]}function aP(e){return e.trim().split(/^|\s+/)}function Lw(e){return e.classList||new oP(e)}function oP(e){this._node=e,this._names=aP(e.getAttribute("class")||"")}oP.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function lP(e,t){for(var n=Lw(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function yae(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n()=>e;function A1(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:o,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}A1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Nae(e){return!e.ctrlKey&&!e.button}function Aae(){return this.parentNode}function Cae(e,t){return t??{x:e.x,y:e.y}}function Iae(){return navigator.maxTouchPoints||"ontouchstart"in this}function pP(){var e=Nae,t=Aae,n=Cae,r=Iae,s={},i=cg("start","drag","end"),a=0,o,c,u,d,f=0;function h(_){_.on("mousedown.drag",p).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,Sae).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(_,k){if(!(d||!e.call(this,_,k))){var T=b(this,t.call(this,_,k),_,k,"mouse");T&&(Ur(_.view).on("mousemove.drag",m,Ed).on("mouseup.drag",g,Ed),fP(_.view),dy(_),u=!1,o=_.clientX,c=_.clientY,T("start",_))}}function m(_){if(Il(_),!u){var k=_.clientX-o,T=_.clientY-c;u=k*k+T*T>f}s.mouse("drag",_)}function g(_){Ur(_.view).on("mousemove.drag mouseup.drag",null),hP(_.view,u),Il(_),s.mouse("end",_)}function x(_,k){if(e.call(this,_,k)){var T=_.changedTouches,A=t.call(this,_,k),N=T.length,S,C;for(S=0;S>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ch(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ch(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Lae.exec(e))?new Ar(t[1],t[2],t[3],1):(t=Oae.exec(e))?new Ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mae.exec(e))?ch(t[1],t[2],t[3],t[4]):(t=Dae.exec(e))?ch(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Pae.exec(e))?NN(t[1],t[2]/100,t[3]/100,1):(t=jae.exec(e))?NN(t[1],t[2]/100,t[3]/100,t[4]):wN.hasOwnProperty(e)?kN(wN[e]):e==="transparent"?new Ar(NaN,NaN,NaN,0):null}function kN(e){return new Ar(e>>16&255,e>>8&255,e&255,1)}function ch(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ar(e,t,n,r)}function Uae(e){return e instanceof af||(e=yo(e)),e?(e=e.rgb(),new Ar(e.r,e.g,e.b,e.opacity)):new Ar}function C1(e,t,n,r){return arguments.length===1?Uae(e):new Ar(e,t,n,r??1)}function Ar(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ow(Ar,C1,mP(af,{brighter(e){return e=e==null?im:Math.pow(im,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xd:Math.pow(xd,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ar(io(this.r),io(this.g),io(this.b),am(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:TN,formatHex:TN,formatHex8:$ae,formatRgb:SN,toString:SN}));function TN(){return`#${Za(this.r)}${Za(this.g)}${Za(this.b)}`}function $ae(){return`#${Za(this.r)}${Za(this.g)}${Za(this.b)}${Za((isNaN(this.opacity)?1:this.opacity)*255)}`}function SN(){const e=am(this.opacity);return`${e===1?"rgb(":"rgba("}${io(this.r)}, ${io(this.g)}, ${io(this.b)}${e===1?")":`, ${e})`}`}function am(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function io(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Za(e){return e=io(e),(e<16?"0":"")+e.toString(16)}function NN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ss(e,t,n,r)}function gP(e){if(e instanceof Ss)return new Ss(e.h,e.s,e.l,e.opacity);if(e instanceof af||(e=yo(e)),!e)return new Ss;if(e instanceof Ss)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,o=i-s,c=(i+s)/2;return o?(t===i?a=(n-r)/o+(n0&&c<1?0:a,new Ss(a,o,c,e.opacity)}function Hae(e,t,n,r){return arguments.length===1?gP(e):new Ss(e,t,n,r??1)}function Ss(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ow(Ss,Hae,mP(af,{brighter(e){return e=e==null?im:Math.pow(im,e),new Ss(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xd:Math.pow(xd,e),new Ss(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Ar(fy(e>=240?e-240:e+120,s,r),fy(e,s,r),fy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ss(AN(this.h),uh(this.s),uh(this.l),am(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=am(this.opacity);return`${e===1?"hsl(":"hsla("}${AN(this.h)}, ${uh(this.s)*100}%, ${uh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function AN(e){return e=(e||0)%360,e<0?e+360:e}function uh(e){return Math.max(0,Math.min(1,e||0))}function fy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Mw=e=>()=>e;function zae(e,t){return function(n){return e+n*t}}function Vae(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Kae(e){return(e=+e)==1?yP:function(t,n){return n-t?Vae(t,n,e):Mw(isNaN(t)?n:t)}}function yP(e,t){var n=t-e;return n?zae(e,n):Mw(isNaN(e)?t:e)}const om=function e(t){var n=Kae(t);function r(s,i){var a=n((s=C1(s)).r,(i=C1(i)).r),o=n(s.g,i.g),c=n(s.b,i.b),u=yP(s.opacity,i.opacity);return function(d){return s.r=a(d),s.g=o(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function Yae(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;sn&&(i=t.slice(n,i),o[a]?o[a]+=i:o[++a]=i),(r=r[0])===(s=s[0])?o[a]?o[a]+=s:o[++a]=s:(o[++a]=null,c.push({i:a,x:Qs(r,s)})),n=hy.lastIndex;return n180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Qs(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function o(u,d,f,h){u!==d?h.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Qs(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,h,p,m){if(u!==f||d!==h){var g=p.push(s(p)+"scale(",null,",",null,")");m.push({i:g-4,x:Qs(u,f)},{i:g-2,x:Qs(d,h)})}else(f!==1||h!==1)&&p.push(s(p)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(p){for(var m=-1,g=h.length,x;++m=0&&e._call.call(void 0,t),e=e._next;--nc}function RN(){bo=(cm=vd.now())+dg,nc=lu=0;try{ooe()}finally{nc=0,coe(),bo=0}}function loe(){var e=vd.now(),t=e-cm;t>wP&&(dg-=t,cm=e)}function coe(){for(var e,t=lm,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:lm=n);cu=e,L1(r)}function L1(e){if(!nc){lu&&(lu=clearTimeout(lu));var t=e-bo;t>24?(e<1/0&&(lu=setTimeout(RN,e-vd.now()-dg)),Gc&&(Gc=clearInterval(Gc))):(Gc||(cm=vd.now(),Gc=setInterval(loe,wP)),nc=1,vP(RN))}}function LN(e,t,n){var r=new um;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var uoe=cg("start","end","cancel","interrupt"),doe=[],kP=0,ON=1,O1=2,Zh=3,MN=4,M1=5,Jh=6;function fg(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;foe(e,n,{name:t,index:r,group:s,on:uoe,tween:doe,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:kP})}function Pw(e,t){var n=$s(e,t);if(n.state>kP)throw new Error("too late; already scheduled");return n}function ui(e,t){var n=$s(e,t);if(n.state>Zh)throw new Error("too late; already running");return n}function $s(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function foe(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=_P(i,0,n.time);function i(u){n.state=ON,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,p;if(n.state!==ON)return c();for(d in r)if(p=r[d],p.name===n.name){if(p.state===Zh)return LN(a);p.state===MN?(p.state=Jh,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[d]):+dO1&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Hoe(e,t,n){var r,s,i=$oe(t)?Pw:ui;return function(){var a=i(this,e),o=a.on;o!==r&&(s=(r=o).copy()).on(t,n),a.on=s}}function zoe(e,t){var n=this._id;return arguments.length<2?$s(this.node(),n).on.on(e):this.each(Hoe(n,e,t))}function Voe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Koe(){return this.on("end.remove",Voe(this._id))}function Yoe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Rw(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a()=>e;function yle(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Ni(e,t,n){this.k=e,this.x=t,this.y=n}Ni.prototype={constructor:Ni,scale:function(e){return e===1?this:new Ni(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ni(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var hg=new Ni(1,0,0);AP.prototype=Ni.prototype;function AP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hg;return e.__zoom}function py(e){e.stopImmediatePropagation()}function Xc(e){e.preventDefault(),e.stopImmediatePropagation()}function ble(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ele(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function DN(){return this.__zoom||hg}function xle(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wle(){return navigator.maxTouchPoints||"ontouchstart"in this}function vle(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function CP(){var e=ble,t=Ele,n=vle,r=xle,s=wle,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,c=Qh,u=cg("start","zoom","end"),d,f,h,p=500,m=150,g=0,x=10;function y(P){P.property("__zoom",DN).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",C).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(P,D,I,L){var O=P.selection?P.selection():P;O.property("__zoom",DN),P!==O?k(P,D,I,L):O.interrupt().each(function(){T(this,arguments).event(L).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},y.scaleBy=function(P,D,I,L){y.scaleTo(P,function(){var O=this.__zoom.k,B=typeof D=="function"?D.apply(this,arguments):D;return O*B},I,L)},y.scaleTo=function(P,D,I,L){y.transform(P,function(){var O=t.apply(this,arguments),B=this.__zoom,R=I==null?_(O):typeof I=="function"?I.apply(this,arguments):I,z=B.invert(R),Y=typeof D=="function"?D.apply(this,arguments):D;return n(b(E(B,Y),R,z),O,a)},I,L)},y.translateBy=function(P,D,I,L){y.transform(P,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,L)},y.translateTo=function(P,D,I,L,O){y.transform(P,function(){var B=t.apply(this,arguments),R=this.__zoom,z=L==null?_(B):typeof L=="function"?L.apply(this,arguments):L;return n(hg.translate(z[0],z[1]).scale(R.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof I=="function"?-I.apply(this,arguments):-I),B,a)},L,O)};function E(P,D){return D=Math.max(i[0],Math.min(i[1],D)),D===P.k?P:new Ni(D,P.x,P.y)}function b(P,D,I){var L=D[0]-I[0]*P.k,O=D[1]-I[1]*P.k;return L===P.x&&O===P.y?P:new Ni(P.k,L,O)}function _(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function k(P,D,I,L){P.on("start.zoom",function(){T(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(L).end()}).tween("zoom",function(){var O=this,B=arguments,R=T(O,B).event(L),z=t.apply(O,B),Y=I==null?_(z):typeof I=="function"?I.apply(O,B):I,j=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),re=O.__zoom,V=typeof D=="function"?D.apply(O,B):D,ee=c(re.invert(Y).concat(j/re.k),V.invert(Y).concat(j/V.k));return function(oe){if(oe===1)oe=V;else{var X=ee(oe),ae=j/X[2];oe=new Ni(ae,Y[0]-X[0]*ae,Y[1]-X[1]*ae)}R.zoom(null,oe)}})}function T(P,D,I){return!I&&P.__zooming||new A(P,D)}function A(P,D){this.that=P,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(P,D),this.taps=0}A.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,D){return this.mouse&&P!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var D=Ur(this.that).datum();u.call(P,this.that,new yle(P,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),D)}};function N(P,...D){if(!e.apply(this,arguments))return;var I=T(this,D).event(P),L=this.__zoom,O=Math.max(i[0],Math.min(i[1],L.k*Math.pow(2,r.apply(this,arguments)))),B=ks(P);if(I.wheel)(I.mouse[0][0]!==B[0]||I.mouse[0][1]!==B[1])&&(I.mouse[1]=L.invert(I.mouse[0]=B)),clearTimeout(I.wheel);else{if(L.k===O)return;I.mouse=[B,L.invert(B)],ep(this),I.start()}Xc(P),I.wheel=setTimeout(R,m),I.zoom("mouse",n(b(E(L,O),I.mouse[0],I.mouse[1]),I.extent,a));function R(){I.wheel=null,I.end()}}function S(P,...D){if(h||!e.apply(this,arguments))return;var I=P.currentTarget,L=T(this,D,!0).event(P),O=Ur(P.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",j,!0),B=ks(P,I),R=P.clientX,z=P.clientY;fP(P.view),py(P),L.mouse=[B,this.__zoom.invert(B)],ep(this),L.start();function Y(re){if(Xc(re),!L.moved){var V=re.clientX-R,ee=re.clientY-z;L.moved=V*V+ee*ee>g}L.event(re).zoom("mouse",n(b(L.that.__zoom,L.mouse[0]=ks(re,I),L.mouse[1]),L.extent,a))}function j(re){O.on("mousemove.zoom mouseup.zoom",null),hP(re.view,L.moved),Xc(re),L.event(re).end()}}function C(P,...D){if(e.apply(this,arguments)){var I=this.__zoom,L=ks(P.changedTouches?P.changedTouches[0]:P,this),O=I.invert(L),B=I.k*(P.shiftKey?.5:2),R=n(b(E(I,B),L,O),t.apply(this,D),a);Xc(P),o>0?Ur(this).transition().duration(o).call(k,R,L,P):Ur(this).call(y.transform,R,L,P)}}function M(P,...D){if(e.apply(this,arguments)){var I=P.touches,L=I.length,O=T(this,D,P.changedTouches.length===L).event(P),B,R,z,Y;for(py(P),R=0;R`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},_d=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],IP=["Enter"," ","Escape"],RP={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var rc;(function(e){e.Strict="strict",e.Loose="loose"})(rc||(rc={}));var ao;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ao||(ao={}));var kd;(function(e){e.Partial="partial",e.Full="full"})(kd||(kd={}));const LP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ra;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ra||(ra={}));var Td;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Td||(Td={}));var Be;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Be||(Be={}));const PN={[Be.Left]:Be.Right,[Be.Right]:Be.Left,[Be.Top]:Be.Bottom,[Be.Bottom]:Be.Top};function OP(e){return e===null?null:e?"valid":"invalid"}const MP=e=>"id"in e&&"source"in e&&"target"in e,_le=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Bw=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),of=(e,t=[0,0])=>{const{width:n,height:r}=$i(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},kle=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Bw(s)?s:t.nodeLookup.get(s.id));const o=a?dm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return pg(r,o)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return mg(n)},lf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=pg(n,dm(s)),r=!0)}),r?mg(n):{x:0,y:0,width:0,height:0}},Fw=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const o={...Ac(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:h=!1}=u;if(a&&!f||h)continue;const p=d.width??u.width??u.initialWidth??null,m=d.height??u.height??u.initialHeight??null,g=Sd(o,ic(u)),x=(p??0)*(m??0),y=i&&g>0;(!u.internals.handleBounds||y||g>=x||u.dragging)&&c.push(u)}return c},Tle=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Sle(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Nle({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return!0;const o=Sle(e,a),c=lf(o),u=$w(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function DP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),o=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=o?o.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!o)i==null||i("005",js.error005());else{const p=o.measured.width,m=o.measured.height;p&&m&&(f=[[c,u],[c+p,u+m]])}else o&&xo(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const h=xo(f)?Eo(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",js.error015())),{position:{x:h.x-c+(a.measured.width??0)*d[0],y:h.y-u+(a.measured.height??0)*d[1]},positionAbsolute:h}}async function Ale({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(h=>h.id)),a=[];for(const h of n){if(h.deletable===!1)continue;const p=i.has(h.id),m=!p&&h.parentId&&a.find(g=>g.id===h.parentId);(p||m)&&a.push(h)}const o=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),d=Tle(a,c);for(const h of c)o.has(h.id)&&!d.find(m=>m.id===h.id)&&d.push(h);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const sc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Eo=(e={x:0,y:0},t,n)=>({x:sc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function PP(e,t,n){const{width:r,height:s}=$i(n),{x:i,y:a}=n.internals.positionAbsolute;return Eo(e,[[i,a],[i+r,a+s]],t)}const jN=(e,t,n)=>en?-sc(Math.abs(e-n),1,t)/t:0,Uw=(e,t,n=15,r=40)=>{const s=jN(e.x,r,t.width-r)*n,i=jN(e.y,r,t.height-r)*n;return[s,i]},pg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),D1=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),mg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ic=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Bw(e)?e.internals.positionAbsolute:of(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},dm=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Bw(e)?e.internals.positionAbsolute:of(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},jP=(e,t)=>mg(pg(D1(e),D1(t))),Sd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},BN=e=>As(e.width)&&As(e.height)&&As(e.x)&&As(e.y),As=e=>!isNaN(e)&&isFinite(e),BP=(e,t)=>(n,r)=>{},cf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ac=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const o={x:(e-n)/s,y:(t-r)/s};return i?cf(o,a):o},ac=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function zo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Cle(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=zo(e,n),s=zo(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=zo(e.top??e.y??0,n),s=zo(e.bottom??e.y??0,n),i=zo(e.left??e.x??0,t),a=zo(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ile(e,t,n,r,s,i){const{x:a,y:o}=ac(e,[t,n,r]),{x:c,y:u}=ac({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=i-u;return{left:Math.floor(a),top:Math.floor(o),right:Math.floor(d),bottom:Math.floor(f)}}const $w=(e,t,n,r,s,i)=>{const a=Cle(i,t,n),o=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(o,c),d=sc(u,r,s),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*d,m=n/2-h*d,g=Ile(e,p,m,d,t,n),x={left:Math.min(g.left-a.left,0),top:Math.min(g.top-a.top,0),right:Math.min(g.right-a.right,0),bottom:Math.min(g.bottom-a.bottom,0)};return{x:p-x.left+x.right,y:m-x.top+x.bottom,zoom:d}},Nd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xo(e){return e!=null&&e!=="parent"}function $i(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function FP(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function UP(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const o=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*o[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*o[1]}return i}function FN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Rle(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function Lle(e){return{...RP,...e||{}}}function ju(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Cs(e),o=Ac({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?cf(o,t):o;return{xSnapped:c,ySnapped:u,...o}}const Hw=e=>({width:e.offsetWidth,height:e.offsetHeight}),$P=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Ole=["INPUT","SELECT","TEXTAREA"];function HP(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Ole.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const zP=e=>"clientX"in e,Cs=(e,t)=>{var i,a;const n=zP(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},UN=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const o=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(o.left-n.left)/r,y:(o.top-n.top)/r,...Hw(a)}})};function VP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:o}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+i*.375+o*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function hh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $N({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Be.Left:return[t-hh(t-r,i),n];case Be.Right:return[t+hh(r-t,i),n];case Be.Top:return[t,n-hh(n-s,i)];case Be.Bottom:return[t,n+hh(s-n,i)]}}function KP({sourceX:e,sourceY:t,sourcePosition:n=Be.Bottom,targetX:r,targetY:s,targetPosition:i=Be.Top,curvature:a=.25}){const[o,c]=$N({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=$N({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,h,p,m]=VP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${c} ${u},${d} ${r},${s}`,f,h,p,m]}function YP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n0}const Ple=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,jle=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Ble=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",js.error006()),t;const r=n.getEdgeId||Ple;let s;return MP(e)?s={...e}:s={...e,id:r(e)},jle(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function WP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,o]=YP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,o]}const HN={[Be.Left]:{x:-1,y:0},[Be.Right]:{x:1,y:0},[Be.Top]:{x:0,y:-1},[Be.Bottom]:{x:0,y:1}},Fle=({source:e,sourcePosition:t=Be.Bottom,target:n})=>t===Be.Left||t===Be.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ule({source:e,sourcePosition:t=Be.Bottom,target:n,targetPosition:r=Be.Top,center:s,offset:i,stepPosition:a}){const o=HN[t],c=HN[r],u={x:e.x+o.x*i,y:e.y+o.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},f=Fle({source:u,sourcePosition:t,target:d}),h=f.x!==0?"x":"y",p=f[h];let m=[],g,x;const y={x:0,y:0},E={x:0,y:0},[,,b,_]=YP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[h]*c[h]===-1){h==="x"?(g=s.x??u.x+(d.x-u.x)*a,x=s.y??(u.y+d.y)/2):(g=s.x??(u.x+d.x)/2,x=s.y??u.y+(d.y-u.y)*a);const N=[{x:g,y:u.y},{x:g,y:d.y}],S=[{x:u.x,y:x},{x:d.x,y:x}];o[h]===p?m=h==="x"?N:S:m=h==="x"?S:N}else{const N=[{x:u.x,y:d.y}],S=[{x:d.x,y:u.y}];if(h==="x"?m=o.x===p?S:N:m=o.y===p?N:S,t===r){const P=Math.abs(e[h]-n[h]);if(P<=i){const D=Math.min(i-1,i-P);o[h]===p?y[h]=(u[h]>e[h]?-1:1)*D:E[h]=(d[h]>n[h]?-1:1)*D}}if(t!==r){const P=h==="x"?"y":"x",D=o[h]===c[P],I=u[P]>d[P],L=u[P]=q?(g=(C.x+M.x)/2,x=m[0].y):(g=m[0].x,x=(C.y+M.y)/2)}const k={x:u.x+y.x,y:u.y+y.y},T={x:d.x+E.x,y:d.y+E.y};return[[e,...k.x!==m[0].x||k.y!==m[0].y?[k]:[],...m,...T.x!==m[m.length-1].x||T.y!==m[m.length-1].y?[T]:[],n],g,x,b,_]}function $le(e,t,n,r){const s=Math.min(zN(e,t)/2,zN(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const u=e.xn.id===t):e[0])||null}function j1(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function zle(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,o)=>([o.markerStart||r,o.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=j1(c,t);i.has(u)||(a.push({id:u,color:c.color||n,...c}),i.add(u))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))}const qP=1e3,Vle=10,zw={nodeOrigin:[0,0],nodeExtent:_d,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Kle={...zw,checkEquality:!0};function Vw(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Yle(e,t,n){const r=Vw(zw,n);for(const s of e.values())if(s.parentId)Yw(s,e,t,r);else{const i=of(s,r.nodeOrigin),a=xo(s.extent)?s.extent:r.nodeExtent,o=Eo(i,a,$i(s));s.internals.positionAbsolute=o}}function Wle(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Kw(e){return e==="manual"}function B1(e,t,n,r={}){var d,f;const s=Vw(Kle,r),i={i:0},a=new Map(t),o=s!=null&&s.elevateNodesOnSelect&&!Kw(s.zIndexMode)?qP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let p=a.get(h.id);if(s.checkEquality&&h===(p==null?void 0:p.internals.userNode))t.set(h.id,p);else{const m=of(h,s.nodeOrigin),g=xo(h.extent)?h.extent:s.nodeExtent,x=Eo(m,g,$i(h));p={...s.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(f=h.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:Wle(h,p),z:GP(h,o,s.zIndexMode),userNode:h}},t.set(h.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),h.parentId&&Yw(p,t,n,r,i),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function qle(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Yw(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:o,zIndexMode:c}=Vw(zw,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}qle(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*Vle),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=i&&!Kw(c)?qP:0,{x:h,y:p,z:m}=Gle(e,d,a,o,f,c),{positionAbsolute:g}=e.internals,x=h!==g.x||p!==g.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:h,y:p}:g,z:m}})}function GP(e,t,n){const r=As(e.zIndex)?e.zIndex:0;return Kw(n)?r:r+(e.selected?t:0)}function Gle(e,t,n,r,s,i){const{x:a,y:o}=t.internals.positionAbsolute,c=$i(e),u=of(e,n),d=xo(e.extent)?Eo(u,e.extent,c):u;let f=Eo({x:a+d.x,y:o+d.y},r,c);e.extent==="parent"&&(f=PP(f,c,t));const h=GP(e,s,i),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function Ww(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const o of e){const c=t.get(o.parentId);if(!c)continue;const u=((a=i.get(o.parentId))==null?void 0:a.expandedRect)??ic(c),d=jP(u,o.rect);i.set(o.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:o,parent:c},u)=>{var b;const d=c.internals.positionAbsolute,f=$i(c),h=c.origin??r,p=o.x0||m>0||y||E)&&(s.push({id:u,type:"position",position:{x:c.position.x-p+y,y:c.position.y-m+E}}),(b=n.get(u))==null||b.forEach(_=>{e.some(k=>k.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+m}})})),(f.width0){const p=Ww(h,t,n,s);u.push(...p)}return{changes:u,updatedInternals:c}}async function Qle({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function WN(e,t,n,r,s,i){let a=s;const o=r.get(a)||new Map;r.set(a,o.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),i){a=`${s}-${e}-${i}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function XP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:o=null}=r,c={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:o},u=`${s}-${a}--${i}-${o}`,d=`${i}-${o}--${s}-${a}`;WN("source",c,d,e,s,a),WN("target",c,u,e,i,o),t.set(r.id,r)}}function QP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:QP(n,t):!1}function qN(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Zle(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!QP(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const o=e.get(i);o&&s.set(i,{id:i,position:o.position||{x:0,y:0},distance:{x:n.x-o.internals.positionAbsolute.x,y:n.y-o.internals.positionAbsolute.y},extent:o.extent,parentId:o.parentId,origin:o.origin,expandParent:o.expandParent,internals:{positionAbsolute:o.internals.positionAbsolute||{x:0,y:0}},measured:{width:o.measured.width??0,height:o.measured.height??0}})}return s}function my({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,o,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.position,dragging:r})}if(!e)return[s[0],s];const i=(o=n.get(e))==null?void 0:o.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function Jle({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=cf(i,t);return{x:a.x-i.x,y:a.y-i.y}}function ece({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,o=new Map,c=!1,u={x:0,y:0},d=null,f=!1,h=null,p=!1,m=!1,g=null;function x({noDragClassName:E,handleSelector:b,domNode:_,isSelectable:k,nodeId:T,nodeClickDistance:A=0}){h=Ur(_);function N({x:U,y:q}){const{nodeLookup:P,nodeExtent:D,snapGrid:I,snapToGrid:L,nodeOrigin:O,onNodeDrag:B,onSelectionDrag:R,onError:z,updateNodePositions:Y}=t();i={x:U,y:q};let j=!1;const re=o.size>1,V=re&&D?D1(lf(o)):null,ee=re&&L?Jle({dragItems:o,snapGrid:I,x:U,y:q}):null;for(const[oe,X]of o){if(!P.has(oe))continue;let ae={x:U-X.distance.x,y:q-X.distance.y};L&&(ae=ee?{x:Math.round(ae.x+ee.x),y:Math.round(ae.y+ee.y)}:cf(ae,I));let Z=null;if(re&&D&&!X.extent&&V){const{positionAbsolute:Q}=X.internals,ge=Q.x-V.x+D[0][0],be=Q.x+X.measured.width-V.x2+D[1][0],_e=Q.y-V.y+D[0][1],Pe=Q.y+X.measured.height-V.y2+D[1][1];Z=[[ge,_e],[be,Pe]]}const{position:de,positionAbsolute:ye}=DP({nodeId:oe,nextPosition:ae,nodeLookup:P,nodeExtent:Z||D,nodeOrigin:O,onError:z});j=j||X.position.x!==de.x||X.position.y!==de.y,X.position=de,X.internals.positionAbsolute=ye}if(m=m||j,!!j&&(Y(o,!0),g&&(r||B||!T&&R))){const[oe,X]=my({nodeId:T,dragItems:o,nodeLookup:P});r==null||r(g,o,oe,X),B==null||B(g,oe,X),T||R==null||R(g,X)}}async function S(){if(!d)return;const{transform:U,panBy:q,autoPanSpeed:P,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(a);return}const[I,L]=Uw(u,d,P);(I!==0||L!==0)&&(i.x=(i.x??0)-I/U[2],i.y=(i.y??0)-L/U[2],await q({x:I,y:L})&&N(i)),a=requestAnimationFrame(S)}function C(U){var re;const{nodeLookup:q,multiSelectionActive:P,nodesDraggable:D,transform:I,snapGrid:L,snapToGrid:O,selectNodesOnDrag:B,onNodeDragStart:R,onSelectionDragStart:z,unselectNodesAndEdges:Y}=t();f=!0,(!B||!k)&&!P&&T&&((re=q.get(T))!=null&&re.selected||Y()),k&&B&&T&&(e==null||e(T));const j=ju(U.sourceEvent,{transform:I,snapGrid:L,snapToGrid:O,containerBounds:d});if(i=j,o=Zle(q,D,j,T),o.size>0&&(n||R||!T&&z)){const[V,ee]=my({nodeId:T,dragItems:o,nodeLookup:q});n==null||n(U.sourceEvent,o,V,ee),R==null||R(U.sourceEvent,V,ee),T||z==null||z(U.sourceEvent,ee)}}const M=pP().clickDistance(A).on("start",U=>{const{domNode:q,nodeDragThreshold:P,transform:D,snapGrid:I,snapToGrid:L}=t();d=(q==null?void 0:q.getBoundingClientRect())||null,p=!1,m=!1,g=U.sourceEvent,P===0&&C(U),i=ju(U.sourceEvent,{transform:D,snapGrid:I,snapToGrid:L,containerBounds:d}),u=Cs(U.sourceEvent,d)}).on("drag",U=>{const{autoPanOnNodeDrag:q,transform:P,snapGrid:D,snapToGrid:I,nodeDragThreshold:L,nodeLookup:O}=t(),B=ju(U.sourceEvent,{transform:P,snapGrid:D,snapToGrid:I,containerBounds:d});if(g=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||T&&!O.has(T))&&(p=!0),!p){if(!c&&q&&f&&(c=!0,S()),!f){const R=Cs(U.sourceEvent,d),z=R.x-u.x,Y=R.y-u.y;Math.sqrt(z*z+Y*Y)>L&&C(U)}(i.x!==B.xSnapped||i.y!==B.ySnapped)&&o&&f&&(u=Cs(U.sourceEvent,d),N(B))}}).on("end",U=>{if(!f||p){p&&o.size>0&&t().updateNodePositions(o,!1);return}if(c=!1,f=!1,cancelAnimationFrame(a),o.size>0){const{nodeLookup:q,updateNodePositions:P,onNodeDragStop:D,onSelectionDragStop:I}=t();if(m&&(P(o,!1),m=!1),s||D||!T&&I){const[L,O]=my({nodeId:T,dragItems:o,nodeLookup:q,dragging:!1});s==null||s(U.sourceEvent,o,L,O),D==null||D(U.sourceEvent,L,O),T||I==null||I(U.sourceEvent,O)}}}).filter(U=>{const q=U.target;return!U.button&&(!E||!qN(q,`.${E}`,_))&&(!b||qN(q,b,_))});h.call(M)}function y(){h==null||h.on(".drag",null)}return{update:x,destroy:y}}function tce(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Sd(s,ic(i))>0&&r.push(i);return r}const nce=250;function rce(e,t,n,r){var o,c;let s=[],i=1/0;const a=tce(e,n,t+nce);for(const u of a){const d=[...((o=u.internals.handleBounds)==null?void 0:o.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=wo(u,f,f.position,!0),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));m>t||(m1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function ZP(e,t,n,r,s,i=!1){var u,d,f;const a=r.get(e);if(!a)return null;const o=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?o==null?void 0:o.find(h=>h.id===n):o==null?void 0:o[0])??null;return c&&i?{...c,...wo(a,c,c.position,!0)}:c}function JP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function sce(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ej=()=>!0;function ice(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:o,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:h,cancelConnection:p,onConnectStart:m,onConnect:g,onConnectEnd:x,isValidConnection:y=ej,onReconnectEnd:E,updateConnection:b,getTransform:_,getFromHandle:k,autoPanSpeed:T,dragThreshold:A=1,handleDomNode:N}){const S=$P(e.target);let C=0,M;const{x:U,y:q}=Cs(e),P=JP(i,N),D=o==null?void 0:o.getBoundingClientRect();let I=!1;if(!D||!P)return;const L=ZP(s,P,r,c,t);if(!L)return;let O=Cs(e,D),B=!1,R=null,z=!1,Y=null;function j(){if(!d||!D)return;const[de,ye]=Uw(O,D,T);h({x:de,y:ye}),C=requestAnimationFrame(j)}const re={...L,nodeId:s,type:P,position:L.position},V=c.get(s);let oe={inProgress:!0,isValid:null,from:wo(V,re,Be.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:V,to:O,toHandle:null,toPosition:PN[re.position],toNode:null,pointer:O};function X(){I=!0,b(oe),m==null||m(e,{nodeId:s,handleId:r,handleType:P})}A===0&&X();function ae(de){if(!I){const{x:Pe,y:we}=Cs(de),ht=Pe-U,je=we-q;if(!(ht*ht+je*je>A*A))return;X()}if(!k()||!re){Z(de);return}const ye=_();O=Cs(de,D),M=rce(Ac(O,ye,!1,[1,1]),n,c,re),B||(j(),B=!0);const Q=tj(de,{handle:M,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:S,lib:u,flowId:f,nodeLookup:c});Y=Q.handleDomNode,R=Q.connection,z=sce(!!M,Q.isValid);const ge=c.get(s),be=ge?wo(ge,re,Be.Left,!0):oe.from,_e={...oe,from:be,isValid:z,to:Q.toHandle&&z?ac({x:Q.toHandle.x,y:Q.toHandle.y},ye):O,toHandle:Q.toHandle,toPosition:z&&Q.toHandle?Q.toHandle.position:PN[re.position],toNode:Q.toHandle?c.get(Q.toHandle.nodeId):null,pointer:O};b(_e),oe=_e}function Z(de){if(!("touches"in de&&de.touches.length>0)){if(I){(M||Y)&&R&&z&&(g==null||g(R));const{inProgress:ye,...Q}=oe,ge={...Q,toPosition:oe.toHandle?oe.toPosition:null};x==null||x(de,ge),i&&(E==null||E(de,ge))}p(),cancelAnimationFrame(C),B=!1,z=!1,R=null,Y=null,S.removeEventListener("mousemove",ae),S.removeEventListener("mouseup",Z),S.removeEventListener("touchmove",ae),S.removeEventListener("touchend",Z)}}S.addEventListener("mousemove",ae),S.addEventListener("mouseup",Z),S.addEventListener("touchmove",ae),S.addEventListener("touchend",Z)}function tj(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:o,flowId:c,isValidConnection:u=ej,nodeLookup:d}){const f=i==="target",h=t?a.querySelector(`.${o}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:m}=Cs(e),g=a.elementFromPoint(p,m),x=g!=null&&g.classList.contains(`${o}-flow__handle`)?g:h,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const E=JP(void 0,x),b=x.getAttribute("data-nodeid"),_=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),T=x.classList.contains("connectableend");if(!b||!E)return y;const A={source:f?b:r,sourceHandle:f?_:s,target:f?r:b,targetHandle:f?s:_};y.connection=A;const S=k&&T&&(n===rc.Strict?f&&E==="source"||!f&&E==="target":b!==r||_!==s);y.isValid=S&&u(A),y.toHandle=ZP(b,E,_,d,n,!0)}return y}const F1={onPointerDown:ice,isValid:tj};function ace({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Ur(e);function i({translateExtent:o,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const m=b=>{if(b.sourceEvent.type!=="wheel"||!t)return;const _=n(),k=b.sourceEvent.ctrlKey&&Nd()?10:1,T=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,A=_[2]*Math.pow(2,T*k);t.scaleTo(A)};let g=[0,0];const x=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(g=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},y=b=>{const _=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const k=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],T=[k[0]-g[0],k[1]-g[1]];g=k;const A=r()*Math.max(_[2],Math.log(_[2]))*(p?-1:1),N={x:_[0]-T[0]*A,y:_[1]-T[1]*A},S=[[0,0],[c,u]];t.setViewportConstrained({x:N.x,y:N.y,zoom:_[2]},S,o)},E=CP().on("start",x).on("zoom",f?y:null).on("zoom.wheel",h?m:null);s.call(E,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:ks}}const gg=e=>({x:e.x,y:e.y,zoom:e.k}),gy=({x:e,y:t,zoom:n})=>hg.translate(e,t).scale(n),yl=(e,t)=>e.target.closest(`.${t}`),nj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),oce=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,yy=(e,t=0,n=oce,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},rj=e=>{const t=e.ctrlKey&&Nd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function lce({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:o,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(yl(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const x=ks(d),y=rj(d),E=f*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const h=d.deltaMode===1?20:1;let p=s===ao.Vertical?0:d.deltaX*h,m=s===ao.Horizontal?0:d.deltaY*h;!Nd()&&d.shiftKey&&s!==ao.Vertical&&(p=d.deltaY*h,m=0),r.translateBy(n,-(p/f)*i,-(m/f)*i,{internal:!0});const g=gg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,g),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,o==null||o(d,g))}}function cce({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,o=yl(r,e);if(r.ctrlKey&&i&&o&&r.preventDefault(),a||o)return null;r.preventDefault(),n.call(this,r,s)}}function uce({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,o;if((i=r.sourceEvent)!=null&&i.internal)return;const s=gg(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((o=r.sourceEvent)==null?void 0:o.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function dce({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,o;e.usedRightMouseButton=!!(n&&nj(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((o=i.sourceEvent)!=null&&o.internal)&&(s==null||s(i.sourceEvent,gg(i.transform)))}}function fce({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var o;if(!((o=a.sourceEvent)!=null&&o.internal)&&(e.isZoomingOrPanning=!1,i&&nj(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=gg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function hce({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:o,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var x;const h=e||t,p=n&&f.ctrlKey,m=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(yl(f,`${u}-flow__node`)||yl(f,`${u}-flow__edge`)))return!0;if(!r&&!h&&!s&&!i&&!n||a||d&&!m||yl(f,o)&&m||yl(f,c)&&(!m||s&&m&&!e)||!n&&f.ctrlKey&&m)return!1;if(!n&&f.type==="touchstart"&&((x=f.touches)==null?void 0:x.length)>1)return f.preventDefault(),!1;if(!h&&!s&&!p&&m||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const g=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&g}}function pce({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:o,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=CP().scaleExtent([t,n]).translateExtent(r),h=Ur(e).call(f);E({x:s.x,y:s.y,zoom:sc(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const p=h.on("wheel.zoom"),m=h.on("dblclick.zoom");f.wheelDelta(rj);async function g(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).transform(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}function x({noWheelClassName:M,noPanClassName:U,onPaneContextMenu:q,userSelectionActive:P,panOnScroll:D,panOnDrag:I,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:B,zoomOnPinch:R,zoomOnScroll:z,zoomOnDoubleClick:Y,zoomActivationKeyPressed:j,lib:re,onTransformChange:V,connectionInProgress:ee,paneClickDistance:oe,selectionOnDrag:X}){P&&!u.isZoomingOrPanning&&y();const ae=D&&!j&&!P;f.clickDistance(X?1/0:!As(oe)||oe<0?0:oe);const Z=ae?lce({zoomPanValues:u,noWheelClassName:M,d3Selection:h,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:R,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:o}):cce({noWheelClassName:M,preventScrolling:B,d3ZoomHandler:p});h.on("wheel.zoom",Z,{passive:!1});const de=uce({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const ye=dce({zoomPanValues:u,panOnDrag:I,onPaneContextMenu:!!q,onPanZoom:i,onTransformChange:V});f.on("zoom",ye);const Q=fce({zoomPanValues:u,panOnDrag:I,panOnScroll:D,onPaneContextMenu:q,onPanZoomEnd:o,onDraggingChange:c});f.on("end",Q);const ge=hce({zoomActivationKeyPressed:j,panOnDrag:I,zoomOnScroll:z,panOnScroll:D,zoomOnDoubleClick:Y,zoomOnPinch:R,userSelectionActive:P,noPanClassName:U,noWheelClassName:M,lib:re,connectionInProgress:ee});f.filter(ge),Y?h.on("dblclick.zoom",m):h.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function E(M,U,q){const P=gy(M),D=f==null?void 0:f.constrain()(P,U,q);return D&&await g(D),D}async function b(M,U){const q=gy(M);return await g(q,U),q}function _(M){if(h){const U=gy(M),q=h.property("__zoom");(q.k!==M.zoom||q.x!==M.x||q.y!==M.y)&&(f==null||f.transform(h,U,null,{sync:!0}))}}function k(){const M=h?AP(h.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function T(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).scaleTo(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}async function A(M,U){return h?new Promise(q=>{f==null||f.interpolate((U==null?void 0:U.interpolate)==="linear"?Pu:Qh).scaleBy(yy(h,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>q(!0)),M)}):!1}function N(M){f==null||f.scaleExtent(M)}function S(M){f==null||f.translateExtent(M)}function C(M){const U=!As(M)||M<0?0:M;f==null||f.clickDistance(U)}return{update:x,destroy:y,setViewport:b,setViewportConstrained:E,getViewport:k,scaleTo:T,scaleBy:A,setScaleExtent:N,setTranslateExtent:S,syncViewport:_,setClickDistance:C}}var oc;(function(e){e.Line="line",e.Handle="handle"})(oc||(oc={}));function mce({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const a=e-t,o=n-r,c=[a>0?1:a<0?-1:0,o>0?1:o<0?-1:0];return a&&s&&(c[0]=c[0]*-1),o&&i&&(c[1]=c[1]*-1),c}function GN(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Yi(e,t){return Math.max(0,t-e)}function Wi(e,t){return Math.max(0,e-t)}function ph(e,t,n){return Math.max(0,t-e,e-n)}function XN(e,t){return e?!t:t}function gce(e,t,n,r,s,i,a,o){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,h=d&&f,{xSnapped:p,ySnapped:m}=n,{minWidth:g,maxWidth:x,minHeight:y,maxHeight:E}=r,{x:b,y:_,width:k,height:T,aspectRatio:A}=e;let N=Math.floor(d?p-e.pointerX:0),S=Math.floor(f?m-e.pointerY:0);const C=k+(c?-N:N),M=T+(u?-S:S),U=-i[0]*k,q=-i[1]*T;let P=ph(C,g,x),D=ph(M,y,E);if(a){let O=0,B=0;c&&N<0?O=Yi(b+N+U,a[0][0]):!c&&N>0&&(O=Wi(b+C+U,a[1][0])),u&&S<0?B=Yi(_+S+q,a[0][1]):!u&&S>0&&(B=Wi(_+M+q,a[1][1])),P=Math.max(P,O),D=Math.max(D,B)}if(o){let O=0,B=0;c&&N>0?O=Wi(b+N,o[0][0]):!c&&N<0&&(O=Yi(b+C,o[1][0])),u&&S>0?B=Wi(_+S,o[0][1]):!u&&S<0&&(B=Yi(_+M,o[1][1])),P=Math.max(P,O),D=Math.max(D,B)}if(s){if(d){const O=ph(C/A,y,E)*A;if(P=Math.max(P,O),a){let B=0;!c&&!u||c&&!u&&h?B=Wi(_+q+C/A,a[1][1])*A:B=Yi(_+q+(c?N:-N)/A,a[0][1])*A,P=Math.max(P,B)}if(o){let B=0;!c&&!u||c&&!u&&h?B=Yi(_+C/A,o[1][1])*A:B=Wi(_+(c?N:-N)/A,o[0][1])*A,P=Math.max(P,B)}}if(f){const O=ph(M*A,g,x)/A;if(D=Math.max(D,O),a){let B=0;!c&&!u||u&&!c&&h?B=Wi(b+M*A+U,a[1][0])/A:B=Yi(b+(u?S:-S)*A+U,a[0][0])/A,D=Math.max(D,B)}if(o){let B=0;!c&&!u||u&&!c&&h?B=Yi(b+M*A,o[1][0])/A:B=Wi(b+(u?S:-S)*A,o[0][0])/A,D=Math.max(D,B)}}}S=S+(S<0?D:-D),N=N+(N<0?P:-P),s&&(h?C>M*A?S=(XN(c,u)?-N:N)/A:N=(XN(c,u)?-S:S)*A:d?(S=N/A,u=c):(N=S*A,c=u));const I=c?b+N:b,L=u?_+S:_;return{width:k+(c?-N:N),height:T+(u?-S:S),x:i[0]*N*(c?-1:1)+I,y:i[1]*S*(u?-1:1)+L}}const sj={width:0,height:0,x:0,y:0},yce={...sj,pointerX:0,pointerY:0,aspectRatio:1};function bce(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,o=n[0]*i,c=n[1]*a;return[[r-o,s-c],[r+i-o,s+a-c]]}function Ece({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Ur(e);let a={controlDirection:GN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function o({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:m,onResizeEnd:g,shouldResize:x}){let y={...sj},E={...yce};a={boundaries:d,resizeDirection:h,keepAspectRatio:f,controlDirection:GN(u)};let b,_=null,k=[],T,A,N,S=!1;const C=pP().on("start",M=>{const{nodeLookup:U,transform:q,snapGrid:P,snapToGrid:D,nodeOrigin:I,paneDomNode:L}=n();if(b=U.get(t),!b)return;_=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:O,ySnapped:B}=ju(M.sourceEvent,{transform:q,snapGrid:P,snapToGrid:D,containerBounds:_});y={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},E={...y,pointerX:O,pointerY:B,aspectRatio:y.width/y.height},T=void 0,A=xo(b.extent)?b.extent:void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(T=U.get(b.parentId)),T&&b.extent==="parent"&&(A=[[0,0],[T.measured.width,T.measured.height]]),k=[],N=void 0;for(const[R,z]of U)if(z.parentId===t&&(k.push({id:R,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const Y=bce(z,b,z.origin??I);N?N=[[Math.min(Y[0][0],N[0][0]),Math.min(Y[0][1],N[0][1])],[Math.max(Y[1][0],N[1][0]),Math.max(Y[1][1],N[1][1])]]:N=Y}p==null||p(M,{...y})}).on("drag",M=>{const{transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D}=n(),I=ju(M.sourceEvent,{transform:U,snapGrid:q,snapToGrid:P,containerBounds:_}),L=[];if(!b)return;const{x:O,y:B,width:R,height:z}=y,Y={},j=b.origin??D,{width:re,height:V,x:ee,y:oe}=gce(E,a.controlDirection,I,a.boundaries,a.keepAspectRatio,j,A,N),X=re!==R,ae=V!==z,Z=ee!==O&&X,de=oe!==B&&ae;if(!Z&&!de&&!X&&!ae)return;if((Z||de||j[0]===1||j[1]===1)&&(Y.x=Z?ee:y.x,Y.y=de?oe:y.y,y.x=Y.x,y.y=Y.y,k.length>0)){const be=ee-O,_e=oe-B;for(const Pe of k)Pe.position={x:Pe.position.x-be+j[0]*(re-R),y:Pe.position.y-_e+j[1]*(V-z)},L.push(Pe)}if((X||ae)&&(Y.width=X&&(!a.resizeDirection||a.resizeDirection==="horizontal")?re:y.width,Y.height=ae&&(!a.resizeDirection||a.resizeDirection==="vertical")?V:y.height,y.width=Y.width,y.height=Y.height),T&&b.expandParent){const be=j[0]*(Y.width??0);Y.x&&Y.x{S&&(g==null||g(M,{...y}),s==null||s({...y}),S=!1)});i.call(C)}function c(){i.on(".drag",null)}return{update:o,destroy:c}}var ij={exports:{}},aj={},oj={exports:{}},lj={};/** * @license React * use-sync-external-store-shim.production.js * @@ -700,9 +700,9 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus `,` +`).split(` `)),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[e]);return v.useEffect(()=>{const c=(t==null?void 0:t.target)??r2,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=p=>{var x,y;if(s.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!s.current||s.current&&!u)&&HP(p))return!1;const g=i2(p.code,o);if(i.current.add(p[g]),s2(a,i.current,!1)){const E=((y=(x=p.composedPath)==null?void 0:x.call(p))==null?void 0:y[0])||p.target,b=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(s.current||!b)&&p.preventDefault(),r(!0)}},f=p=>{const m=i2(p.code,o);s2(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(p[m]),p.key==="Meta"&&i.current.clear(),s.current=!1},h=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function s2(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function i2(e,t){return t.includes(e)?"code":"key"}const uue=()=>{const e=qt();return v.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:a,panZoom:o}=e.getState(),c=$w(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return o?(await o.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:o,y:c}=a.getBoundingClientRect(),u={x:t.x-o,y:t.y-c},d=n.snapGrid??s,f=n.snapToGrid??i;return Ac(u,r,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=ac(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function pj(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const o={...i};for(const c of a)due(c,o);n.push(o)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function due(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function mj(e,t){return pj(e,t)}function gj(e,t){return pj(e,t)}function Ha(e,t){return{id:e,type:"select",selected:t}}function bl(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Ha(i.id,a)))}return r}function a2({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const o=t.get(a.id),c=((s=o==null?void 0:o.internals)==null?void 0:s.userNode)??o;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function o2(e){return{id:e.id,type:"remove"}}const fue=BP();function yj(e,t,n={}){return Ble(e,t,{...n,onError:n.onError??fue})}const l2=e=>_le(e),hue=e=>MP(e);function bj(e){return v.forwardRef(e)}const pue=typeof window<"u"?v.useLayoutEffect:v.useEffect;function c2(e){const[t,n]=v.useState(BigInt(0)),[r]=v.useState(()=>mue(()=>n(s=>s+BigInt(1))));return pue(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function mue(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ej=v.createContext(null);function gue({children:e}){const t=qt(),n=v.useCallback(o=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:h,fitViewQueued:p,onNodesChangeMiddlewareMap:m}=t.getState();let g=c;for(const y of o)g=typeof y=="function"?y(g):y;let x=a2({items:g,lookup:h});for(const y of m.values())x=y(x);d&&u(g),x.length>0?f==null||f(x):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:E,setNodes:b}=t.getState();y&&b(E)})},[]),r=c2(n),s=v.useCallback(o=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:h}=t.getState();let p=c;for(const m of o)p=typeof m=="function"?m(p):m;d?u(p):f&&f(a2({items:p,lookup:h}))},[]),i=c2(s),a=v.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return l.jsx(Ej.Provider,{value:a,children:e})}function yue(){const e=v.useContext(Ej);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const bue=e=>!!e.panZoom;function qw(){const e=uue(),t=qt(),n=yue(),r=ft(bue),s=v.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},o=f=>{n.edgeQueue.push(f)},c=f=>{var y,E;const{nodeLookup:h,nodeOrigin:p}=t.getState(),m=l2(f)?f:h.get(f.id),g=m.parentId?UP(m.position,m.measured,m.parentId,h,p):m.position,x={...m,position:g,width:((y=m.measured)==null?void 0:y.width)??m.width,height:((E=m.measured)==null?void 0:E.height)??m.height};return ic(x)},u=(f,h,p={replace:!1})=>{a(m=>m.map(g=>{if(g.id===f){const x=typeof h=="function"?h(g):h;return p.replace&&l2(x)?x:{...g,...x}}return g}))},d=(f,h,p={replace:!1})=>{o(m=>m.map(g=>{if(g.id===f){const x=typeof h=="function"?h(g):h;return p.replace&&hue(x)?x:{...g,...x}}return g}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var h;return(h=i(f))==null?void 0:h.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(h=>({...h}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:o,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:p}=t.getState(),[m,g,x]=p;return{nodes:f.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:m,y:g,zoom:x}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:p,edges:m,onNodesDelete:g,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:E,onDelete:b,onBeforeDelete:_}=t.getState(),{nodes:k,edges:T}=await Ale({nodesToRemove:f,edgesToRemove:h,nodes:p,edges:m,onBeforeDelete:_}),A=T.length>0,N=k.length>0;if(A){const S=T.map(o2);x==null||x(T),E(S)}if(N){const S=k.map(o2);g==null||g(k),y(S)}return(N||A)&&(b==null||b({nodes:k,edges:T})),{deletedNodes:k,deletedEdges:T}},getIntersectingNodes:(f,h=!0,p)=>{const m=BN(f),g=m?f:c(f),x=p!==void 0;return g?(p||t.getState().nodes).filter(y=>{const E=t.getState().nodeLookup.get(y.id);if(E&&!m&&(y.id===f.id||!E.internals.positionAbsolute))return!1;const b=ic(x?y:E),_=Sd(b,g);return h&&_>0||_>=b.width*b.height||_>=g.width*g.height}):[]},isNodeIntersecting:(f,h,p=!0)=>{const g=BN(f)?f:c(f);if(!g)return!1;const x=Sd(g,h);return p&&x>0||x>=h.width*h.height||x>=g.width*g.height},updateNode:u,updateNodeData:(f,h,p={replace:!1})=>{u(f,m=>{const g=typeof h=="function"?h(m):h;return p.replace?{...m,data:g}:{...m,data:{...m.data,...g}}},p)},updateEdge:d,updateEdgeData:(f,h,p={replace:!1})=>{d(f,m=>{const g=typeof h=="function"?h(m):h;return p.replace?{...m,data:g}:{...m,data:{...m.data,...g}}},p)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:p}=t.getState();return kle(f,{nodeLookup:h,nodeOrigin:p})},getHandleConnections:({type:f,id:h,nodeId:p})=>{var m;return Array.from(((m=t.getState().connectionLookup.get(`${p}-${f}${h?`-${h}`:""}`))==null?void 0:m.values())??[])},getNodeConnections:({type:f,handleId:h,nodeId:p})=>{var m;return Array.from(((m=t.getState().connectionLookup.get(`${p}${f?h?`-${f}-${h}`:`-${f}`:""}`))==null?void 0:m.values())??[])},fitView:async f=>{const h=t.getState().fitViewResolver??Rle();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(p=>[...p]),h.promise}}},[]);return v.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const u2=e=>e.selected,Eue=typeof window<"u"?window:void 0;function xue({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=qt(),{deleteElements:r}=qw(),s=Ad(e,{actInsideInputWithModifier:!1}),i=Ad(t,{target:Eue});v.useEffect(()=>{if(s){const{edges:a,nodes:o}=n.getState();r({nodes:o.filter(u2),edges:a.filter(u2)}),n.setState({nodesSelectionActive:!1})}},[s]),v.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function wue(e){const t=qt();v.useEffect(()=>{const n=()=>{var s,i,a,o;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=Hw(e.current);(r.height===0||r.width===0)&&((o=(a=t.getState()).onError)==null||o.call(a,"004",js.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const xg={position:"absolute",width:"100%",height:"100%",top:0,left:0},vue=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function _ue({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=ao.Free,zoomOnDoubleClick:a=!0,panOnDrag:o=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:p=!0,children:m,noWheelClassName:g,noPanClassName:x,onViewportChange:y,isControlledViewport:E,paneClickDistance:b,selectionOnDrag:_}){const k=qt(),T=v.useRef(null),{userSelectionActive:A,lib:N,connectionInProgress:S}=ft(vue,Wt),C=Ad(h),M=v.useRef();wue(T);const U=v.useCallback(q=>{y==null||y({x:q[0],y:q[1],zoom:q[2]}),E||k.setState({transform:q})},[y,E]);return v.useEffect(()=>{if(T.current){M.current=pce({domNode:T.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:I=>k.setState(L=>L.paneDragging===I?L:{paneDragging:I}),onPanZoomStart:(I,L)=>{const{onViewportChangeStart:O,onMoveStart:B}=k.getState();B==null||B(I,L),O==null||O(L)},onPanZoom:(I,L)=>{const{onViewportChange:O,onMove:B}=k.getState();B==null||B(I,L),O==null||O(L)},onPanZoomEnd:(I,L)=>{const{onViewportChangeEnd:O,onMoveEnd:B}=k.getState();B==null||B(I,L),O==null||O(L)}});const{x:q,y:P,zoom:D}=M.current.getViewport();return k.setState({panZoom:M.current,transform:[q,P,D],domNode:T.current.closest(".react-flow")}),()=>{var I;(I=M.current)==null||I.destroy()}}},[]),v.useEffect(()=>{var q;(q=M.current)==null||q.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:o,zoomActivationKeyPressed:C,preventScrolling:p,noPanClassName:x,userSelectionActive:A,noWheelClassName:g,lib:N,onTransformChange:U,connectionInProgress:S,selectionOnDrag:_,paneClickDistance:b})},[e,t,n,r,s,i,a,o,C,p,x,A,g,N,U,S,_,b]),l.jsx("div",{className:"react-flow__renderer",ref:T,style:xg,children:m})}const kue=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Tue(){const{userSelectionActive:e,userSelectionRect:t}=ft(kue,Wt);return e&&t?l.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Ey=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Sue=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Nue({isSelecting:e,selectionKeyPressed:t,selectionMode:n=kd.Full,panOnDrag:r,autoPanOnSelection:s,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:m,children:g}){const x=v.useRef(0),y=qt(),{userSelectionActive:E,elementsSelectable:b,dragging:_,connectionInProgress:k,panBy:T,autoPanSpeed:A}=ft(Sue,Wt),N=b&&(e||E),S=v.useRef(null),C=v.useRef(),M=v.useRef(new Set),U=v.useRef(new Set),q=v.useRef(!1),P=v.useRef({x:0,y:0}),D=v.useRef(!1),I=X=>{if(q.current||k){q.current=!1;return}u==null||u(X),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},L=X=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){X.preventDefault();return}d==null||d(X)},O=f?X=>f(X):void 0,B=X=>{q.current&&(X.stopPropagation(),q.current=!1)},R=X=>{var Pe,we;const{domNode:ae,transform:Z}=y.getState();if(C.current=ae==null?void 0:ae.getBoundingClientRect(),!C.current)return;const de=X.target===S.current;if(!de&&!!X.target.closest(".nokey")||!e||!(a&&de||t)||X.button!==0||!X.isPrimary)return;(we=(Pe=X.target)==null?void 0:Pe.setPointerCapture)==null||we.call(Pe,X.pointerId),q.current=!1;const{x:ge,y:be}=Cs(X.nativeEvent,C.current),_e=Ac({x:ge,y:be},Z);y.setState({userSelectionRect:{width:0,height:0,startX:_e.x,startY:_e.y,x:ge,y:be}}),de||(X.stopPropagation(),X.preventDefault())};function z(X,ae){const{userSelectionRect:Z}=y.getState();if(!Z)return;const{transform:de,nodeLookup:ye,edgeLookup:Q,connectionLookup:ge,triggerNodeChanges:be,triggerEdgeChanges:_e,defaultEdgeOptions:Pe}=y.getState(),we={x:Z.startX,y:Z.startY},{x:ht,y:je}=ac(we,de),Fe={startX:we.x,startY:we.y,x:Xmt.id)),U.current=new Set;const Et=(Pe==null?void 0:Pe.selectable)??!0;for(const mt of M.current){const W=ge.get(mt);if(W)for(const{edgeId:J}of W.values()){const ce=Q.get(J);ce&&(ce.selectable??Et)&&U.current.add(J)}}if(!FN(ut,M.current)){const mt=bl(ye,M.current,!0);be(mt)}if(!FN(he,U.current)){const mt=bl(Q,U.current);_e(mt)}y.setState({userSelectionRect:Fe,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!s||!C.current)return;const[X,ae]=Uw(P.current,C.current,A);T({x:X,y:ae}).then(Z=>{if(!q.current||!Z){x.current=requestAnimationFrame(Y);return}const{x:de,y:ye}=P.current;z(de,ye),x.current=requestAnimationFrame(Y)})}const j=()=>{cancelAnimationFrame(x.current),x.current=0,D.current=!1};v.useEffect(()=>()=>j(),[]);const re=X=>{const{userSelectionRect:ae,transform:Z,resetSelectedElements:de}=y.getState();if(!C.current||!ae)return;const{x:ye,y:Q}=Cs(X.nativeEvent,C.current);P.current={x:ye,y:Q};const ge=ac({x:ae.startX,y:ae.startY},Z);if(!q.current){const be=t?0:i;if(Math.hypot(ye-ge.x,Q-ge.y)<=be)return;de(),o==null||o(X)}q.current=!0,D.current||(Y(),D.current=!0),z(ye,Q)},V=X=>{var ae,Z;X.button===0&&((Z=(ae=X.target)==null?void 0:ae.releasePointerCapture)==null||Z.call(ae,X.pointerId),!E&&X.target===S.current&&y.getState().userSelectionRect&&(I==null||I(X)),y.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(c==null||c(X),y.setState({nodesSelectionActive:M.current.size>0})),j())},ee=X=>{var ae,Z;(Z=(ae=X.target)==null?void 0:ae.releasePointerCapture)==null||Z.call(ae,X.pointerId),j()},oe=r===!0||Array.isArray(r)&&r.includes(0);return l.jsxs("div",{className:Tn(["react-flow__pane",{draggable:oe,dragging:_,selection:e}]),onClick:N?void 0:Ey(I,S),onContextMenu:Ey(L,S),onWheel:Ey(O,S),onPointerEnter:N?void 0:h,onPointerMove:N?re:p,onPointerUp:N?V:void 0,onPointerCancel:N?ee:void 0,onPointerDownCapture:N?R:void 0,onClickCapture:N?B:void 0,onPointerLeave:m,ref:S,style:xg,children:[g,l.jsx(Tue,{})]})}function U1({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:o,onError:c}=t.getState(),u=o.get(e);if(!u){c==null||c("012",js.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function xj({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const o=qt(),[c,u]=v.useState(!1),d=v.useRef();return v.useEffect(()=>{d.current=ece({getStoreItems:()=>o.getState(),onNodeMouseDown:f=>{U1({id:f,store:o,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),v.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,r,t,i,e,s,a]),c}const Aue=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function wj(){const e=qt();return v.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,h=Aue(a),p=s?i[0]:5,m=s?i[1]:5,g=n.direction.x*p*n.factor,x=n.direction.y*m*n.factor;for(const[,y]of u){if(!h(y))continue;let E={x:y.internals.positionAbsolute.x+g,y:y.internals.positionAbsolute.y+x};s&&(E=cf(E,i));const{position:b,positionAbsolute:_}=DP({nodeId:y.id,nextPosition:E,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:o});y.position=b,y.internals.positionAbsolute=_,f.set(y.id,y)}c(f)},[])}const Gw=v.createContext(null),Cue=Gw.Provider;Gw.Consumer;const vj=()=>v.useContext(Gw),Iue=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Rue=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:o,toHandle:c,isValid:u}=a,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===rc.Strict?(o==null?void 0:o.type)!==n:e!==(o==null?void 0:o.nodeId)||t!==(o==null?void 0:o.id),connectionInProcess:!!o,clickConnectionInProcess:!!s,valid:d&&u}};function Lue({type:e="source",position:t=Be.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:o,children:c,className:u,onMouseDown:d,onTouchStart:f,...h},p){var D,I;const m=a||null,g=e==="target",x=qt(),y=vj(),{connectOnClick:E,noPanClassName:b,rfId:_}=ft(Iue,Wt),{connectingFrom:k,connectingTo:T,clickConnecting:A,isPossibleEndHandle:N,connectionInProcess:S,clickConnectionInProcess:C,valid:M}=ft(Rue(y,m,e),Wt);y||(I=(D=x.getState()).onError)==null||I.call(D,"010",js.error010());const U=L=>{const{defaultEdgeOptions:O,onConnect:B,hasDefaultEdges:R}=x.getState(),z={...O,...L};if(R){const{edges:Y,setEdges:j,onError:re}=x.getState();j(yj(z,Y,{onError:re}))}B==null||B(z),o==null||o(z)},q=L=>{if(!y)return;const O=zP(L.nativeEvent);if(s&&(O&&L.button===0||!O)){const B=x.getState();F1.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:B.autoPanOnConnect,connectionMode:B.connectionMode,connectionRadius:B.connectionRadius,domNode:B.domNode,nodeLookup:B.nodeLookup,lib:B.lib,isTarget:g,handleId:m,nodeId:y,flowId:B.rfId,panBy:B.panBy,cancelConnection:B.cancelConnection,onConnectStart:B.onConnectStart,onConnectEnd:(...R)=>{var z,Y;return(Y=(z=x.getState()).onConnectEnd)==null?void 0:Y.call(z,...R)},updateConnection:B.updateConnection,onConnect:U,isValidConnection:n||((...R)=>{var z,Y;return((Y=(z=x.getState()).isValidConnection)==null?void 0:Y.call(z,...R))??!0}),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:B.autoPanSpeed,dragThreshold:B.connectionDragThreshold})}O?d==null||d(L):f==null||f(L)},P=L=>{const{onClickConnectStart:O,onClickConnectEnd:B,connectionClickStartHandle:R,connectionMode:z,isValidConnection:Y,lib:j,rfId:re,nodeLookup:V,connection:ee}=x.getState();if(!y||!R&&!s)return;if(!R){O==null||O(L.nativeEvent,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:m}});return}const oe=$P(L.target),X=n||Y,{connection:ae,isValid:Z}=F1.isValid(L.nativeEvent,{handle:{nodeId:y,id:m,type:e},connectionMode:z,fromNodeId:R.nodeId,fromHandleId:R.id||null,fromType:R.type,isValidConnection:X,flowId:re,doc:oe,lib:j,nodeLookup:V});Z&&ae&&U(ae);const de=structuredClone(ee);delete de.inProgress,de.toPosition=de.toHandle?de.toHandle.position:null,B==null||B(L,de),x.setState({connectionClickStartHandle:null})};return l.jsx("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${_}-${y}-${m}-${e}`,className:Tn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",b,u,{source:!g,target:g,connectable:r,connectablestart:s,connectableend:i,clickconnecting:A,connectingfrom:k,connectingto:T,valid:M,connectionindicator:r&&(!S||N)&&(S||C?i:s)}]),onMouseDown:q,onTouchStart:q,onClick:E?P:void 0,ref:p,...h,children:c})}const cc=v.memo(bj(Lue));function Oue({data:e,isConnectable:t,sourcePosition:n=Be.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx(cc,{type:"source",position:n,isConnectable:t})]})}function Mue({data:e,isConnectable:t,targetPosition:n=Be.Top,sourcePosition:r=Be.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx(cc,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l.jsx(cc,{type:"source",position:r,isConnectable:t})]})}function Due(){return null}function Pue({data:e,isConnectable:t,targetPosition:n=Be.Top}){return l.jsxs(l.Fragment,{children:[l.jsx(cc,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const fm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},d2={input:Oue,default:Mue,output:Pue,group:Due};function jue(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const Bue=e=>{const{width:t,height:n,x:r,y:s}=lf(e.nodeLookup,{filter:i=>!!i.selected});return{width:As(t)?t:null,height:As(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function Fue({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=qt(),{width:s,height:i,transformString:a,userSelectionActive:o}=ft(Bue,Wt),c=wj(),u=v.useRef(null);v.useEffect(()=>{var p;n||(p=u.current)==null||p.focus({preventScroll:!0})},[n]);const d=!o&&s!==null&&i!==null;if(xj({nodeRef:u,disabled:!d}),!d)return null;const f=e?p=>{const m=r.getState().nodes.filter(g=>g.selected);e(p,m)}:void 0,h=p=>{Object.prototype.hasOwnProperty.call(fm,p.key)&&(p.preventDefault(),c({direction:fm[p.key],factor:p.shiftKey?4:1}))};return l.jsx("div",{className:Tn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:l.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:i}})})}const f2=typeof window<"u"?window:void 0,Uue=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function _j({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:o,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:g,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:E,zoomOnPinch:b,panOnScroll:_,panOnScrollSpeed:k,panOnScrollMode:T,zoomOnDoubleClick:A,panOnDrag:N,autoPanOnSelection:S,defaultViewport:C,translateExtent:M,minZoom:U,maxZoom:q,preventScrolling:P,onSelectionContextMenu:D,noWheelClassName:I,noPanClassName:L,disableKeyboardA11y:O,onViewportChange:B,isControlledViewport:R}){const{nodesSelectionActive:z,userSelectionActive:Y}=ft(Uue,Wt),j=Ad(u,{target:f2}),re=Ad(g,{target:f2}),V=re||N,ee=re||_,oe=d&&V!==!0,X=j||Y||oe;return xue({deleteKeyCode:c,multiSelectionKeyCode:m}),l.jsx(_ue,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:E,zoomOnPinch:b,panOnScroll:ee,panOnScrollSpeed:k,panOnScrollMode:T,zoomOnDoubleClick:A,panOnDrag:!j&&V,defaultViewport:C,translateExtent:M,minZoom:U,maxZoom:q,zoomActivationKeyCode:x,preventScrolling:P,noWheelClassName:I,noPanClassName:L,onViewportChange:B,isControlledViewport:R,paneClickDistance:o,selectionOnDrag:oe,children:l.jsxs(Nue,{onSelectionStart:h,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:V,autoPanOnSelection:S,isSelecting:!!X,selectionMode:f,selectionKeyPressed:j,paneClickDistance:o,selectionOnDrag:oe,children:[e,z&&l.jsx(Fue,{onSelectionContextMenu:D,noPanClassName:L,disableKeyboardA11y:O})]})})}_j.displayName="FlowRenderer";const $ue=v.memo(_j),Hue=e=>t=>e?Fw(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function zue(e){return ft(v.useCallback(Hue(e),[e]),Wt)}const Vue=e=>e.updateNodeInternals;function Kue(){const e=ft(Vue),[t]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return v.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Yue({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=qt(),i=v.useRef(null),a=v.useRef(null),o=v.useRef(e.sourcePosition),c=v.useRef(e.targetPosition),u=v.useRef(t),d=n&&!!e.internals.handleBounds;return v.useEffect(()=>{i.current&&!e.hidden&&(!d||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[d,e.hidden]),v.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),v.useEffect(()=>{if(i.current){const f=u.current!==t,h=o.current!==e.sourcePosition,p=c.current!==e.targetPosition;(f||h||p)&&(u.current=t,o.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Wue({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:o,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:h,noPanClassName:p,disableKeyboardA11y:m,rfId:g,nodeTypes:x,nodeClickDistance:y,onError:E}){const{node:b,internals:_,isParent:k}=ft(X=>{const ae=X.nodeLookup.get(e),Z=X.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:Z}},Wt);let T=b.type||"default",A=(x==null?void 0:x[T])||d2[T];A===void 0&&(E==null||E("003",js.error003(T)),T="default",A=(x==null?void 0:x.default)||d2.default);const N=!!(b.draggable||o&&typeof b.draggable>"u"),S=!!(b.selectable||c&&typeof b.selectable>"u"),C=!!(b.connectable||u&&typeof b.connectable>"u"),M=!!(b.focusable||d&&typeof b.focusable>"u"),U=qt(),q=FP(b),P=Yue({node:b,nodeType:T,hasDimensions:q,resizeObserver:f}),D=xj({nodeRef:P,disabled:b.hidden||!N,noDragClassName:h,handleSelector:b.dragHandle,nodeId:e,isSelectable:S,nodeClickDistance:y}),I=wj();if(b.hidden)return null;const L=$i(b),O=jue(b),B=S||N||t||n||r||s,R=n?X=>n(X,{..._.userNode}):void 0,z=r?X=>r(X,{..._.userNode}):void 0,Y=s?X=>s(X,{..._.userNode}):void 0,j=i?X=>i(X,{..._.userNode}):void 0,re=a?X=>a(X,{..._.userNode}):void 0,V=X=>{const{selectNodesOnDrag:ae,nodeDragThreshold:Z}=U.getState();S&&(!ae||!N||Z>0)&&U1({id:e,store:U,nodeRef:P}),t&&t(X,{..._.userNode})},ee=X=>{if(!(HP(X.nativeEvent)||m)){if(IP.includes(X.key)&&S){const ae=X.key==="Escape";U1({id:e,store:U,unselect:ae,nodeRef:P})}else if(N&&b.selected&&Object.prototype.hasOwnProperty.call(fm,X.key)){X.preventDefault();const{ariaLabelConfig:ae}=U.getState();U.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),I({direction:fm[X.key],factor:X.shiftKey?4:1})}}},oe=()=>{var ge;if(m||!((ge=P.current)!=null&&ge.matches(":focus-visible")))return;const{transform:X,width:ae,height:Z,autoPanOnNodeFocus:de,setCenter:ye}=U.getState();if(!de)return;Fw(new Map([[e,b]]),{x:0,y:0,width:ae,height:Z},X,!0).length>0||ye(b.position.x+L.width/2,b.position.y+L.height/2,{zoom:X[2]})};return l.jsx("div",{className:Tn(["react-flow__node",`react-flow__node-${T}`,{[p]:N},b.className,{selected:b.selected,selectable:S,parent:k,draggable:N,dragging:D}]),ref:P,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:B?"all":"none",visibility:q?"visible":"hidden",...b.style,...O},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:z,onMouseLeave:Y,onContextMenu:j,onClick:V,onDoubleClick:re,onKeyDown:M?ee:void 0,tabIndex:M?0:void 0,onFocus:M?oe:void 0,role:b.ariaRole??(M?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${dj}-${g}`,"aria-label":b.ariaLabel,...b.domAttributes,children:l.jsx(Cue,{value:e,children:l.jsx(A,{id:e,data:b.data,type:T,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:b.selected??!1,selectable:S,draggable:N,deletable:b.deletable??!0,isConnectable:C,sourcePosition:b.sourcePosition,targetPosition:b.targetPosition,dragging:D,dragHandle:b.dragHandle,zIndex:_.z,parentId:b.parentId,...L})})})}var que=v.memo(Wue);const Gue=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function kj(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=ft(Gue,Wt),a=zue(e.onlyRenderVisibleElements),o=Kue();return l.jsx("div",{className:"react-flow__nodes",style:xg,children:a.map(c=>l.jsx(que,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}kj.displayName="NodeRenderer";const Xue=v.memo(kj);function Que(e){return ft(v.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&Dle({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Wt)}const Zue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return l.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Jue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return l.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},h2={[Td.Arrow]:Zue,[Td.ArrowClosed]:Jue};function ede(e){const t=qt();return v.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(h2,e)?h2[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",js.error009(e)),null)},[e])}const tde=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const c=ede(t);return c?l.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:o,refX:"0",refY:"0",children:l.jsx(c,{color:n,strokeWidth:a})}):null},Tj=({defaultColor:e,rfId:t})=>{const n=ft(i=>i.edges),r=ft(i=>i.defaultEdgeOptions),s=v.useMemo(()=>zle(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?l.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:l.jsx("defs",{children:s.map(i=>l.jsx(tde,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Tj.displayName="MarkerDefinitions";var nde=v.memo(Tj);function Sj({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:c,className:u,...d}){const[f,h]=v.useState({x:1,y:0,width:0,height:0}),p=Tn(["react-flow__edge-textwrapper",u]),m=v.useRef(null);return v.useEffect(()=>{if(m.current){const g=m.current.getBBox();h({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),n?l.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...d,children:[s&&l.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:o,ry:o}),l.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:m,style:r,children:n}),c]}):null}Sj.displayName="EdgeText";const rde=v.memo(Sj);function wg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return l.jsxs(l.Fragment,{children:[l.jsx("path",{...d,d:e,fill:"none",className:Tn(["react-flow__edge-path",d.className])}),u?l.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&As(t)&&As(n)?l.jsx(rde,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:o,labelBgBorderRadius:c}):null]})}function p2({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Be.Left||e===Be.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function Nj({sourceX:e,sourceY:t,sourcePosition:n=Be.Bottom,targetX:r,targetY:s,targetPosition:i=Be.Top}){const[a,o]=p2({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=p2({pos:i,x1:r,y1:s,x2:e,y2:t}),[d,f,h,p]=VP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:o,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${o} ${c},${u} ${r},${s}`,d,f,h,p]}function Aj(e){return v.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:g,markerStart:x,interactionWidth:y})=>{const[E,b,_]=Nj({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:o}),k=e.isInternal?void 0:t;return l.jsx(wg,{id:k,path:E,labelX:b,labelY:_,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:g,markerStart:x,interactionWidth:y})})}const sde=Aj({isInternal:!1}),Cj=Aj({isInternal:!0});sde.displayName="SimpleBezierEdge";Cj.displayName="SimpleBezierEdgeInternal";function Ij(e){return v.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,sourcePosition:p=Be.Bottom,targetPosition:m=Be.Top,markerEnd:g,markerStart:x,pathOptions:y,interactionWidth:E})=>{const[b,_,k]=P1({sourceX:n,sourceY:r,sourcePosition:p,targetX:s,targetY:i,targetPosition:m,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),T=e.isInternal?void 0:t;return l.jsx(wg,{id:T,path:b,labelX:_,labelY:k,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:g,markerStart:x,interactionWidth:E})})}const Rj=Ij({isInternal:!1}),Lj=Ij({isInternal:!0});Rj.displayName="SmoothStepEdge";Lj.displayName="SmoothStepEdgeInternal";function Oj(e){return v.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return l.jsx(Rj,{...n,id:r,pathOptions:v.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const ide=Oj({isInternal:!1}),Mj=Oj({isInternal:!0});ide.displayName="StepEdge";Mj.displayName="StepEdgeInternal";function Dj(e){return v.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:m,interactionWidth:g})=>{const[x,y,E]=WP({sourceX:n,sourceY:r,targetX:s,targetY:i}),b=e.isInternal?void 0:t;return l.jsx(wg,{id:b,path:x,labelX:y,labelY:E,label:a,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:m,interactionWidth:g})})}const ade=Dj({isInternal:!1}),Pj=Dj({isInternal:!0});ade.displayName="StraightEdge";Pj.displayName="StraightEdgeInternal";function jj(e){return v.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Be.Bottom,targetPosition:o=Be.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:g,markerStart:x,pathOptions:y,interactionWidth:E})=>{const[b,_,k]=KP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:o,curvature:y==null?void 0:y.curvature}),T=e.isInternal?void 0:t;return l.jsx(wg,{id:T,path:b,labelX:_,labelY:k,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:g,markerStart:x,interactionWidth:E})})}const ode=jj({isInternal:!1}),Bj=jj({isInternal:!0});ode.displayName="BezierEdge";Bj.displayName="BezierEdgeInternal";const m2={default:Bj,straight:Pj,step:Mj,smoothstep:Lj,simplebezier:Cj},g2={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},lde=(e,t,n)=>n===Be.Left?e-t:n===Be.Right?e+t:e,cde=(e,t,n)=>n===Be.Top?e-t:n===Be.Bottom?e+t:e,y2="react-flow__edgeupdater";function b2({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:o}){return l.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:Tn([y2,`${y2}-${o}`]),cx:lde(t,r,e),cy:cde(n,r,e),r,stroke:"transparent",fill:"transparent"})}function ude({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:o,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:h,setUpdateHover:p}){const m=qt(),g=(_,k)=>{if(_.button!==0)return;const{autoPanOnConnect:T,domNode:A,connectionMode:N,connectionRadius:S,lib:C,onConnectStart:M,cancelConnection:U,nodeLookup:q,rfId:P,panBy:D,updateConnection:I}=m.getState(),L=k.type==="target",O=(z,Y)=>{h(!1),f==null||f(z,n,k.type,Y)},B=z=>u==null?void 0:u(n,z),R=(z,Y)=>{h(!0),d==null||d(_,n,k.type),M==null||M(z,Y)};F1.onPointerDown(_.nativeEvent,{autoPanOnConnect:T,connectionMode:N,connectionRadius:S,domNode:A,handleId:k.id,nodeId:k.nodeId,nodeLookup:q,isTarget:L,edgeUpdaterType:k.type,lib:C,flowId:P,cancelConnection:U,panBy:D,isValidConnection:(...z)=>{var Y,j;return((j=(Y=m.getState()).isValidConnection)==null?void 0:j.call(Y,...z))??!0},onConnect:B,onConnectStart:R,onConnectEnd:(...z)=>{var Y,j;return(j=(Y=m.getState()).onConnectEnd)==null?void 0:j.call(Y,...z)},onReconnectEnd:O,updateConnection:I,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},x=_=>g(_,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=_=>g(_,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>p(!0),b=()=>p(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx(b2,{position:o,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:E,onMouseOut:b,type:"source"}),(e===!0||e==="target")&&l.jsx(b2,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:E,onMouseOut:b,type:"target"})]})}function dde({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,rfId:m,edgeTypes:g,noPanClassName:x,onError:y,disableKeyboardA11y:E}){let b=ft(ye=>ye.edgeLookup.get(e));const _=ft(ye=>ye.defaultEdgeOptions);b=_?{..._,...b}:b;let k=b.type||"default",T=(g==null?void 0:g[k])||m2[k];T===void 0&&(y==null||y("011",js.error011(k)),k="default",T=(g==null?void 0:g.default)||m2.default);const A=!!(b.focusable||t&&typeof b.focusable>"u"),N=typeof f<"u"&&(b.reconnectable||n&&typeof b.reconnectable>"u"),S=!!(b.selectable||r&&typeof b.selectable>"u"),C=v.useRef(null),[M,U]=v.useState(!1),[q,P]=v.useState(!1),D=qt(),{zIndex:I,sourceX:L,sourceY:O,targetX:B,targetY:R,sourcePosition:z,targetPosition:Y}=ft(v.useCallback(ye=>{const Q=ye.nodeLookup.get(b.source),ge=ye.nodeLookup.get(b.target);if(!Q||!ge)return{zIndex:b.zIndex,...g2};const be=Hle({id:e,sourceNode:Q,targetNode:ge,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:ye.connectionMode,onError:y});return{zIndex:Mle({selected:b.selected,zIndex:b.zIndex,sourceNode:Q,targetNode:ge,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...be||g2}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),Wt),j=v.useMemo(()=>b.markerStart?`url('#${j1(b.markerStart,m)}')`:void 0,[b.markerStart,m]),re=v.useMemo(()=>b.markerEnd?`url('#${j1(b.markerEnd,m)}')`:void 0,[b.markerEnd,m]);if(b.hidden||L===null||O===null||B===null||R===null)return null;const V=ye=>{var _e;const{addSelectedEdges:Q,unselectNodesAndEdges:ge,multiSelectionActive:be}=D.getState();S&&(D.setState({nodesSelectionActive:!1}),b.selected&&be?(ge({nodes:[],edges:[b]}),(_e=C.current)==null||_e.blur()):Q([e])),s&&s(ye,b)},ee=i?ye=>{i(ye,{...b})}:void 0,oe=a?ye=>{a(ye,{...b})}:void 0,X=o?ye=>{o(ye,{...b})}:void 0,ae=c?ye=>{c(ye,{...b})}:void 0,Z=u?ye=>{u(ye,{...b})}:void 0,de=ye=>{var Q;if(!E&&IP.includes(ye.key)&&S){const{unselectNodesAndEdges:ge,addSelectedEdges:be}=D.getState();ye.key==="Escape"?((Q=C.current)==null||Q.blur(),ge({edges:[b]})):be([e])}};return l.jsx("svg",{style:{zIndex:I},children:l.jsxs("g",{className:Tn(["react-flow__edge",`react-flow__edge-${k}`,b.className,x,{selected:b.selected,animated:b.animated,inactive:!S&&!s,updating:M,selectable:S}]),onClick:V,onDoubleClick:ee,onContextMenu:oe,onMouseEnter:X,onMouseMove:ae,onMouseLeave:Z,onKeyDown:A?de:void 0,tabIndex:A?0:void 0,role:b.ariaRole??(A?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":A?`${fj}-${m}`:void 0,ref:C,...b.domAttributes,children:[!q&&l.jsx(T,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:S,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:L,sourceY:O,targetX:B,targetY:R,sourcePosition:z,targetPosition:Y,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:j,markerEnd:re,pathOptions:"pathOptions"in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),N&&l.jsx(ude,{edge:b,isReconnectable:N,reconnectRadius:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,sourceX:L,sourceY:O,targetX:B,targetY:R,sourcePosition:z,targetPosition:Y,setUpdateHover:U,setReconnecting:P})]})})}var fde=v.memo(dde);const hde=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Fj({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:h,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:g}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:E,onError:b}=ft(hde,Wt),_=Que(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(nde,{defaultColor:e,rfId:n}),_.map(k=>l.jsx(fde,{id:k,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:E,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:o,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:h,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:b,edgeTypes:r,disableKeyboardA11y:g},k))]})}Fj.displayName="EdgeRenderer";const pde=v.memo(Fj),mde=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function gde({children:e}){const t=ft(mde);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function yde(e){const t=qw(),n=v.useRef(!1);v.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const bde=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Ede(e){const t=ft(bde),n=qt();return v.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function xde(e){return e.connection.inProgress?{...e.connection,to:Ac(e.connection.to,e.transform)}:{...e.connection}}function wde(e){return xde}function vde(e){const t=wde();return ft(t,Wt)}const _de=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function kde({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:o,inProgress:c}=ft(_de,Wt);return!(i&&s&&c)?null:l.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:l.jsx("g",{className:Tn(["react-flow__connection",OP(o)]),children:l.jsx(Uj,{style:t,type:n,CustomComponent:r,isValid:o})})})}const Uj=({style:e,type:t=ra.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:o,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:h,pointer:p}=vde();if(!s)return;if(n)return l.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:o,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:h,connectionStatus:OP(r),toNode:d,toHandle:f,pointer:p});let m="";const g={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case ra.Bezier:[m]=KP(g);break;case ra.SimpleBezier:[m]=Nj(g);break;case ra.Step:[m]=P1({...g,borderRadius:0});break;case ra.SmoothStep:[m]=P1(g);break;default:[m]=WP(g)}return l.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};Uj.displayName="ConnectionLine";const Tde={};function E2(e=Tde){v.useRef(e),qt(),v.useEffect(()=>{},[e])}function Sde(){qt(),v.useRef(!1),v.useEffect(()=>{},[])}function $j({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:h,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:g,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:E,selectionOnDrag:b,selectionMode:_,multiSelectionKeyCode:k,panActivationKeyCode:T,zoomActivationKeyCode:A,deleteKeyCode:N,onlyRenderVisibleElements:S,elementsSelectable:C,defaultViewport:M,translateExtent:U,minZoom:q,maxZoom:P,preventScrolling:D,defaultMarkerColor:I,zoomOnScroll:L,zoomOnPinch:O,panOnScroll:B,panOnScrollSpeed:R,panOnScrollMode:z,zoomOnDoubleClick:Y,panOnDrag:j,autoPanOnSelection:re,onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:oe,onPaneMouseLeave:X,onPaneScroll:ae,onPaneContextMenu:Z,paneClickDistance:de,nodeClickDistance:ye,onEdgeContextMenu:Q,onEdgeMouseEnter:ge,onEdgeMouseMove:be,onEdgeMouseLeave:_e,reconnectRadius:Pe,onReconnect:we,onReconnectStart:ht,onReconnectEnd:je,noDragClassName:Fe,noWheelClassName:ut,noPanClassName:he,disableKeyboardA11y:Et,nodeExtent:mt,rfId:W,viewport:J,onViewportChange:ce}){return E2(e),E2(t),Sde(),yde(n),Ede(J),l.jsx($ue,{onPaneClick:V,onPaneMouseEnter:ee,onPaneMouseMove:oe,onPaneMouseLeave:X,onPaneContextMenu:Z,onPaneScroll:ae,paneClickDistance:de,deleteKeyCode:N,selectionKeyCode:E,selectionOnDrag:b,selectionMode:_,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:k,panActivationKeyCode:T,zoomActivationKeyCode:A,elementsSelectable:C,zoomOnScroll:L,zoomOnPinch:O,zoomOnDoubleClick:Y,panOnScroll:B,panOnScrollSpeed:R,panOnScrollMode:z,panOnDrag:j,autoPanOnSelection:re,defaultViewport:M,translateExtent:U,minZoom:q,maxZoom:P,onSelectionContextMenu:f,preventScrolling:D,noDragClassName:Fe,noWheelClassName:ut,noPanClassName:he,disableKeyboardA11y:Et,onViewportChange:ce,isControlledViewport:!!J,children:l.jsxs(gde,{children:[l.jsx(pde,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:we,onReconnectStart:ht,onReconnectEnd:je,onlyRenderVisibleElements:S,onEdgeContextMenu:Q,onEdgeMouseEnter:ge,onEdgeMouseMove:be,onEdgeMouseLeave:_e,reconnectRadius:Pe,defaultMarkerColor:I,noPanClassName:he,disableKeyboardA11y:Et,rfId:W}),l.jsx(kde,{style:g,type:m,component:x,containerStyle:y}),l.jsx("div",{className:"react-flow__edgelabel-renderer"}),l.jsx(Xue,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:o,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ye,onlyRenderVisibleElements:S,noPanClassName:he,noDragClassName:Fe,disableKeyboardA11y:Et,nodeExtent:mt,rfId:W}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}$j.displayName="GraphView";const Nde=v.memo($j),Ade=BP(),x2=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:o,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:h="basic"}={})=>{const p=new Map,m=new Map,g=new Map,x=new Map,y=r??t??[],E=n??e??[],b=d??[0,0],_=f??_d;XP(g,x,y);const{nodesInitialized:k}=B1(E,p,m,{nodeOrigin:b,nodeExtent:_,zIndexMode:h});let T=[0,0,1];if(a&&s&&i){const A=lf(p,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:N,y:S,zoom:C}=$w(A,s,i,c,u,(o==null?void 0:o.padding)??.1);T=[N,S,C]}return{rfId:"1",width:s??0,height:i??0,transform:T,nodes:E,nodesInitialized:k,nodeLookup:p,parentLookup:m,edges:y,edgeLookup:x,connectionLookup:g,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:_d,nodeExtent:_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:rc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:b,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:o,fitViewResolver:null,connection:{...LP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ade,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:RP,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Cde=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h})=>Kce((p,m)=>{async function g(){const{nodeLookup:x,panZoom:y,fitViewOptions:E,fitViewResolver:b,width:_,height:k,minZoom:T,maxZoom:A}=m();y&&(await Nle({nodes:x,width:_,height:k,panZoom:y,minZoom:T,maxZoom:A},E),b==null||b.resolve(!0),p({fitViewResolver:null}))}return{...x2({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:o,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:x=>{const{nodeLookup:y,parentLookup:E,nodeOrigin:b,elevateNodesOnSelect:_,fitViewQueued:k,zIndexMode:T,nodesSelectionActive:A}=m(),{nodesInitialized:N,hasSelectedNodes:S}=B1(x,y,E,{nodeOrigin:b,nodeExtent:f,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:T}),C=A&&S;k&&N?(g(),p({nodes:x,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:C})):p({nodes:x,nodesInitialized:N,nodesSelectionActive:C})},setEdges:x=>{const{connectionLookup:y,edgeLookup:E}=m();XP(y,E,x),p({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:E}=m();E(x),p({hasDefaultNodes:!0})}if(y){const{setEdges:E}=m();E(y),p({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:E,parentLookup:b,domNode:_,nodeOrigin:k,nodeExtent:T,debug:A,fitViewQueued:N,zIndexMode:S}=m(),{changes:C,updatedInternals:M}=Xle(x,E,b,_,k,T,S);M&&(Yle(E,b,{nodeOrigin:k,nodeExtent:T,zIndexMode:S}),N?(g(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(C==null?void 0:C.length)>0&&(A&&console.log("React Flow: trigger node changes",C),y==null||y(C)))},updateNodePositions:(x,y=!1)=>{const E=[];let b=[];const{nodeLookup:_,triggerNodeChanges:k,connection:T,updateConnection:A,onNodesChangeMiddlewareMap:N}=m();for(const[S,C]of x){const M=_.get(S),U=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(C!=null&&C.position)),q={id:S,type:"position",position:U?{x:Math.max(0,C.position.x),y:Math.max(0,C.position.y)}:C.position,dragging:y};if(M&&T.inProgress&&T.fromNode.id===M.id){const P=wo(M,T.fromHandle,Be.Left,!0);A({...T,from:P})}U&&M.parentId&&E.push({id:S,parentId:M.parentId,rect:{...C.internals.positionAbsolute,width:C.measured.width??0,height:C.measured.height??0}}),b.push(q)}if(E.length>0){const{parentLookup:S,nodeOrigin:C}=m(),M=Ww(E,_,S,C);b.push(...M)}for(const S of N.values())b=S(b);k(b)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:E,nodes:b,hasDefaultNodes:_,debug:k}=m();if(x!=null&&x.length){if(_){const T=mj(x,b);E(T)}k&&console.log("React Flow: trigger node changes",x),y==null||y(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:E,edges:b,hasDefaultEdges:_,debug:k}=m();if(x!=null&&x.length){if(_){const T=gj(x,b);E(T)}k&&console.log("React Flow: trigger edge changes",x),y==null||y(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:E,nodeLookup:b,triggerNodeChanges:_,triggerEdgeChanges:k}=m();if(y){const T=x.map(A=>Ha(A,!0));_(T);return}_(bl(b,new Set([...x]),!0)),k(bl(E))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:E,nodeLookup:b,triggerNodeChanges:_,triggerEdgeChanges:k}=m();if(y){const T=x.map(A=>Ha(A,!0));k(T);return}k(bl(E,new Set([...x]))),_(bl(b,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:E,nodes:b,nodeLookup:_,triggerNodeChanges:k,triggerEdgeChanges:T}=m(),A=x||b,N=y||E,S=[];for(const M of A){if(!M.selected)continue;const U=_.get(M.id);U&&(U.selected=!1),S.push(Ha(M.id,!1))}const C=[];for(const M of N)M.selected&&C.push(Ha(M.id,!1));k(S),T(C)},setMinZoom:x=>{const{panZoom:y,maxZoom:E}=m();y==null||y.setScaleExtent([x,E]),p({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:E}=m();y==null||y.setScaleExtent([E,x]),p({maxZoom:x})},setTranslateExtent:x=>{var y;(y=m().panZoom)==null||y.setTranslateExtent(x),p({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:E,triggerEdgeChanges:b,elementsSelectable:_}=m();if(!_)return;const k=y.reduce((A,N)=>N.selected?[...A,Ha(N.id,!1)]:A,[]),T=x.reduce((A,N)=>N.selected?[...A,Ha(N.id,!1)]:A,[]);E(k),b(T)},setNodeExtent:x=>{const{nodes:y,nodeLookup:E,parentLookup:b,nodeOrigin:_,elevateNodesOnSelect:k,nodeExtent:T,zIndexMode:A}=m();x[0][0]===T[0][0]&&x[0][1]===T[0][1]&&x[1][0]===T[1][0]&&x[1][1]===T[1][1]||(B1(y,E,b,{nodeOrigin:_,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:A}),p({nodeExtent:x}))},panBy:x=>{const{transform:y,width:E,height:b,panZoom:_,translateExtent:k}=m();return Qle({delta:x,panZoom:_,transform:y,translateExtent:k,width:E,height:b})},setCenter:async(x,y,E)=>{const{width:b,height:_,maxZoom:k,panZoom:T}=m();if(!T)return!1;const A=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:k;return await T.setViewport({x:b/2-x*A,y:_/2-y*A,zoom:A},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),!0},cancelConnection:()=>{p({connection:{...LP}})},updateConnection:x=>{p({connection:x})},reset:()=>p({...x2()})}},Object.is);function Hj({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:o,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:p}){const[m]=v.useState(()=>Cde({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:u,minZoom:a,maxZoom:o,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:h}));return l.jsx(Yce,{value:m,children:l.jsx(gue,{children:p})})}function Ide({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p}){return v.useContext(bg)?l.jsx(l.Fragment,{children:e}):l.jsx(Hj,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:o,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:h,zIndexMode:p,children:e})}const Rde={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Lde({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:o,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:p,onConnectStart:m,onConnectEnd:g,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:E,onNodeMouseMove:b,onNodeMouseLeave:_,onNodeContextMenu:k,onNodeDoubleClick:T,onNodeDragStart:A,onNodeDrag:N,onNodeDragStop:S,onNodesDelete:C,onEdgesDelete:M,onDelete:U,onSelectionChange:q,onSelectionDragStart:P,onSelectionDrag:D,onSelectionDragStop:I,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:B,onBeforeDelete:R,connectionMode:z,connectionLineType:Y=ra.Bezier,connectionLineStyle:j,connectionLineComponent:re,connectionLineContainerStyle:V,deleteKeyCode:ee="Backspace",selectionKeyCode:oe="Shift",selectionOnDrag:X=!1,selectionMode:ae=kd.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:de=Nd()?"Meta":"Control",zoomActivationKeyCode:ye=Nd()?"Meta":"Control",snapToGrid:Q,snapGrid:ge,onlyRenderVisibleElements:be=!1,selectNodesOnDrag:_e,nodesDraggable:Pe,autoPanOnNodeFocus:we,nodesConnectable:ht,nodesFocusable:je,nodeOrigin:Fe=hj,edgesFocusable:ut,edgesReconnectable:he,elementsSelectable:Et=!0,defaultViewport:mt=iue,minZoom:W=.5,maxZoom:J=2,translateExtent:ce=_d,preventScrolling:ke=!0,nodeExtent:pe,defaultMarkerColor:Xe="#b1b1b7",zoomOnScroll:St=!0,zoomOnPinch:We=!0,panOnScroll:Sn=!1,panOnScrollSpeed:Me=.5,panOnScrollMode:wt=ao.Free,zoomOnDoubleClick:vt=!0,panOnDrag:Ct=!0,onPaneClick:Gt,onPaneMouseEnter:Ve,onPaneMouseMove:ot,onPaneMouseLeave:_t,onPaneScroll:kt,onPaneContextMenu:le,paneClickDistance:Le=1,nodeClickDistance:Ge=0,children:Bt,onReconnect:Nn,onReconnectStart:nn,onReconnectEnd:Ft,onEdgeContextMenu:Ut,onEdgeDoubleClick:wn,onEdgeMouseEnter:dn,onEdgeMouseMove:rn,onEdgeMouseLeave:fn,reconnectRadius:se=10,onNodesChange:ue,onEdgesChange:Te,noDragClassName:qe="nodrag",noWheelClassName:$e="nowheel",noPanClassName:Ie="nopan",fitView:lt,fitViewOptions:Nt,connectOnClick:Kn,attributionPosition:sn,proOptions:Pn,defaultEdgeOptions:Mt,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Qr=!1,disableKeyboardA11y:vr=!1,autoPanOnConnect:An,autoPanOnNodeDrag:Bn,autoPanOnSelection:Yn=!0,autoPanSpeed:nr,connectionRadius:vn,isValidConnection:$t,onError:an,style:Cn,id:Wn,nodeDragThreshold:on,connectionDragThreshold:Mr,viewport:Fn,onViewportChange:In,width:qn,height:Zr,colorMode:Hs="light",debug:ps,onScroll:ne,ariaLabelConfig:Ce,zIndexMode:He="basic",...ct},Ht){const hn=Wn||"1",gt=cue(Hs),Gn=v.useCallback(Xn=>{Xn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ne==null||ne(Xn)},[ne]);return l.jsx("div",{"data-testid":"rf__wrapper",...ct,onScroll:Gn,style:{...Cn,...Rde},ref:Ht,className:Tn(["react-flow",s,gt]),id:Wn,role:"application",children:l.jsxs(Ide,{nodes:e,edges:t,width:qn,height:Zr,fitView:lt,fitViewOptions:Nt,minZoom:W,maxZoom:J,nodeOrigin:Fe,nodeExtent:pe,zIndexMode:He,children:[l.jsx(lue,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:g,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:Pe,autoPanOnNodeFocus:we,nodesConnectable:ht,nodesFocusable:je,edgesFocusable:ut,edgesReconnectable:he,elementsSelectable:Et,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Qr,minZoom:W,maxZoom:J,nodeExtent:pe,onNodesChange:ue,onEdgesChange:Te,snapToGrid:Q,snapGrid:ge,connectionMode:z,translateExtent:ce,connectOnClick:Kn,defaultEdgeOptions:Mt,fitView:lt,fitViewOptions:Nt,onNodesDelete:C,onEdgesDelete:M,onDelete:U,onNodeDragStart:A,onNodeDrag:N,onNodeDragStop:S,onSelectionDrag:D,onSelectionDragStart:P,onSelectionDragStop:I,onMove:d,onMoveStart:f,onMoveEnd:h,noPanClassName:Ie,nodeOrigin:Fe,rfId:hn,autoPanOnConnect:An,autoPanOnNodeDrag:Bn,autoPanSpeed:nr,onError:an,connectionRadius:vn,isValidConnection:$t,selectNodesOnDrag:_e,nodeDragThreshold:on,connectionDragThreshold:Mr,onBeforeDelete:R,debug:ps,ariaLabelConfig:Ce,zIndexMode:He}),l.jsx(Nde,{onInit:u,onNodeClick:o,onEdgeClick:c,onNodeMouseEnter:E,onNodeMouseMove:b,onNodeMouseLeave:_,onNodeContextMenu:k,onNodeDoubleClick:T,nodeTypes:i,edgeTypes:a,connectionLineType:Y,connectionLineStyle:j,connectionLineComponent:re,connectionLineContainerStyle:V,selectionKeyCode:oe,selectionOnDrag:X,selectionMode:ae,deleteKeyCode:ee,multiSelectionKeyCode:de,panActivationKeyCode:Z,zoomActivationKeyCode:ye,onlyRenderVisibleElements:be,defaultViewport:mt,translateExtent:ce,minZoom:W,maxZoom:J,preventScrolling:ke,zoomOnScroll:St,zoomOnPinch:We,zoomOnDoubleClick:vt,panOnScroll:Sn,panOnScrollSpeed:Me,panOnScrollMode:wt,panOnDrag:Ct,autoPanOnSelection:Yn,onPaneClick:Gt,onPaneMouseEnter:Ve,onPaneMouseMove:ot,onPaneMouseLeave:_t,onPaneScroll:kt,onPaneContextMenu:le,paneClickDistance:Le,nodeClickDistance:Ge,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:B,onReconnect:Nn,onReconnectStart:nn,onReconnectEnd:Ft,onEdgeContextMenu:Ut,onEdgeDoubleClick:wn,onEdgeMouseEnter:dn,onEdgeMouseMove:rn,onEdgeMouseLeave:fn,reconnectRadius:se,defaultMarkerColor:Xe,noDragClassName:qe,noWheelClassName:$e,noPanClassName:Ie,rfId:hn,disableKeyboardA11y:vr,nodeExtent:pe,viewport:Fn,onViewportChange:In}),l.jsx(sue,{onSelectionChange:q}),Bt,l.jsx(Jce,{proOptions:Pn,position:sn}),l.jsx(Zce,{rfId:hn,disableKeyboardA11y:vr})]})})}var Ode=bj(Lde);function Mde(e){const[t,n]=v.useState(e),r=v.useCallback(s=>n(i=>mj(s,i)),[]);return[t,n,r]}function Dde(e){const[t,n]=v.useState(e),r=v.useCallback(s=>n(i=>gj(s,i)),[]);return[t,n,r]}function Pde({dimensions:e,lineWidth:t,variant:n,className:r}){return l.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Tn(["react-flow__background-pattern",n,r])})}function jde({radius:e,className:t}){return l.jsx("circle",{cx:e,cy:e,r:e,className:Tn(["react-flow__background-pattern","dots",t])})}var ba;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ba||(ba={}));const Bde={[ba.Dots]:1,[ba.Lines]:1,[ba.Cross]:6},Fde=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function zj({id:e,variant:t=ba.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:o,style:c,className:u,patternClassName:d}){const f=v.useRef(null),{transform:h,patternId:p}=ft(Fde,Wt),m=r||Bde[t],g=t===ba.Dots,x=t===ba.Cross,y=Array.isArray(n)?n:[n,n],E=[y[0]*h[2]||1,y[1]*h[2]||1],b=m*h[2],_=Array.isArray(i)?i:[i,i],k=x?[b,b]:E,T=[_[0]*h[2]||1+k[0]/2,_[1]*h[2]||1+k[1]/2],A=`${p}${e||""}`;return l.jsxs("svg",{className:Tn(["react-flow__background",u]),style:{...c,...xg,"--xy-background-color-props":o,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[l.jsx("pattern",{id:A,x:h[0]%E[0],y:h[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:g?l.jsx(jde,{radius:b/2,className:d}):l.jsx(Pde,{dimensions:k,lineWidth:s,variant:t,className:d})}),l.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${A})`})]})}zj.displayName="Background";const Ude=v.memo(zj);function $de(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Hde(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l.jsx("path",{d:"M0 0h32v4.2H0z"})})}function zde(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Vde(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Kde(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function gh({children:e,className:t,...n}){return l.jsx("button",{type:"button",className:Tn(["react-flow__controls-button",t]),...n,children:e})}const Yde=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Vj({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:o,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:h="vertical","aria-label":p}){const m=qt(),{isInteractive:g,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:E}=ft(Yde,Wt),{zoomIn:b,zoomOut:_,fitView:k}=qw(),T=()=>{b(),i==null||i()},A=()=>{_(),a==null||a()},N=()=>{k(s),o==null||o()},S=()=>{m.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),c==null||c(!g)},C=h==="horizontal"?"horizontal":"vertical";return l.jsxs(Eg,{className:Tn(["react-flow__controls",C,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??E["controls.ariaLabel"],children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(gh,{onClick:T,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:y,children:l.jsx($de,{})}),l.jsx(gh,{onClick:A,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:x,children:l.jsx(Hde,{})})]}),n&&l.jsx(gh,{className:"react-flow__controls-fitview",onClick:N,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:l.jsx(zde,{})}),r&&l.jsx(gh,{className:"react-flow__controls-interactive",onClick:S,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:g?l.jsx(Kde,{}):l.jsx(Vde,{})}),d]})}Vj.displayName="Controls";const Wde=v.memo(Vj);function qde({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:o,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:h,onClick:p}){const{background:m,backgroundColor:g}=i||{},x=a||m||g;return l.jsx("rect",{className:Tn(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:x,stroke:o,strokeWidth:c},shapeRendering:f,onClick:p?y=>p(y,e):void 0})}const Gde=v.memo(qde),Xde=e=>e.nodes.map(t=>t.id),xy=e=>e instanceof Function?e:()=>e;function Qde({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=Gde,onClick:a}){const o=ft(Xde,Wt),c=xy(t),u=xy(e),d=xy(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return l.jsx(l.Fragment,{children:o.map(h=>l.jsx(Jde,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:f},h))})}function Zde({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:o,onClick:c}){const{node:u,x:d,y:f,width:h,height:p}=ft(m=>{const g=m.nodeLookup.get(e);if(!g)return{node:void 0,x:0,y:0,width:0,height:0};const x=g.internals.userNode,{x:y,y:E}=g.internals.positionAbsolute,{width:b,height:_}=$i(x);return{node:x,x:y,y:E,width:b,height:_}},Wt);return!u||u.hidden||!FP(u)?null:l.jsx(o,{x:d,y:f,width:h,height:p,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:a,onClick:c,id:u.id})}const Jde=v.memo(Zde);var efe=v.memo(Qde);const tfe=200,nfe=150,rfe=e=>!e.hidden,sfe=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?jP(lf(e.nodeLookup,{filter:rfe}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ife="react-flow__minimap-desc";function Kj({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:o,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:h="bottom-right",onClick:p,onNodeClick:m,pannable:g=!1,zoomable:x=!1,ariaLabel:y,inversePan:E,zoomStep:b=1,offsetScale:_=5}){const k=qt(),T=v.useRef(null),{boundingRect:A,viewBB:N,rfId:S,panZoom:C,translateExtent:M,flowWidth:U,flowHeight:q,ariaLabelConfig:P}=ft(sfe,Wt),D=(e==null?void 0:e.width)??tfe,I=(e==null?void 0:e.height)??nfe,L=A.width/D,O=A.height/I,B=Math.max(L,O),R=B*D,z=B*I,Y=_*B,j=A.x-(R-A.width)/2-Y,re=A.y-(z-A.height)/2-Y,V=R+Y*2,ee=z+Y*2,oe=`${ife}-${S}`,X=v.useRef(0),ae=v.useRef();X.current=B,v.useEffect(()=>{if(T.current&&C)return ae.current=ace({domNode:T.current,panZoom:C,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{var Q;(Q=ae.current)==null||Q.destroy()}},[C]),v.useEffect(()=>{var Q;(Q=ae.current)==null||Q.update({translateExtent:M,width:U,height:q,inversePan:E,pannable:g,zoomStep:b,zoomable:x})},[g,x,E,b,M,U,q]);const Z=p?Q=>{var _e;const[ge,be]=((_e=ae.current)==null?void 0:_e.pointer(Q))||[0,0];p(Q,{x:ge,y:be})}:void 0,de=m?v.useCallback((Q,ge)=>{const be=k.getState().nodeLookup.get(ge).internals.userNode;m(Q,be)},[]):void 0,ye=y??P["minimap.ariaLabel"];return l.jsx(Eg,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*B:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Tn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:l.jsxs("svg",{width:D,height:I,viewBox:`${j} ${re} ${V} ${ee}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":oe,ref:T,onClick:Z,children:[ye&&l.jsx("title",{id:oe,children:ye}),l.jsx(efe,{onClick:de,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:o}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${j-Y},${re-Y}h${V+Y*2}v${ee+Y*2}h${-V-Y*2}z - M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Kj.displayName="MiniMap";const afe=v.memo(Kj),ofe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,lfe={[oc.Line]:"right",[oc.Handle]:"bottom-right"};function cfe({nodeId:e,position:t,variant:n=oc.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:o=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:p=!0,shouldResize:m,onResizeStart:g,onResize:x,onResizeEnd:y}){const E=vj(),b=typeof e=="string"?e:E,_=qt(),k=v.useRef(null),T=n===oc.Handle,A=ft(v.useCallback(ofe(T&&p),[T,p]),Wt),N=v.useRef(null),S=t??lfe[n];v.useEffect(()=>{if(!(!k.current||!b))return N.current||(N.current=Ece({domNode:k.current,nodeId:b,getStoreItems:()=>{const{nodeLookup:M,transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D,domNode:I}=_.getState();return{nodeLookup:M,transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D,paneDomNode:I}},onChange:(M,U)=>{const{triggerNodeChanges:q,nodeLookup:P,parentLookup:D,nodeOrigin:I}=_.getState(),L=[],O={x:M.x,y:M.y},B=P.get(b);if(B&&B.expandParent&&B.parentId){const R=B.origin??I,z=M.width??B.measured.width??0,Y=M.height??B.measured.height??0,j={id:B.id,parentId:B.parentId,rect:{width:z,height:Y,...UP({x:M.x??B.position.x,y:M.y??B.position.y},{width:z,height:Y},B.parentId,P,R)}},re=Ww([j],P,D,I);L.push(...re),O.x=M.x?Math.max(R[0]*z,M.x):void 0,O.y=M.y?Math.max(R[1]*Y,M.y):void 0}if(O.x!==void 0&&O.y!==void 0){const R={id:b,type:"position",position:{...O}};L.push(R)}if(M.width!==void 0&&M.height!==void 0){const z={id:b,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};L.push(z)}for(const R of U){const z={...R,type:"position"};L.push(z)}q(L)},onEnd:({width:M,height:U})=>{const q={id:b,type:"dimensions",resizing:!1,dimensions:{width:M,height:U}};_.getState().triggerNodeChanges([q])}})),N.current.update({controlPosition:S,boundaries:{minWidth:o,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:h,onResizeStart:g,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{var M;(M=N.current)==null||M.destroy()}},[S,o,c,u,d,f,g,x,y,m]);const C=S.split("-");return l.jsx("div",{className:Tn(["react-flow__resize-control","nodrag",...C,n,r]),ref:k,style:{...s,scale:A,...a&&{[T?"backgroundColor":"borderColor"]:a}},children:i})}v.memo(cfe);const ufe=[{type:"sequential",label:"顺序",desc:"节点依次执行",Icon:x7},{type:"parallel",label:"并行",desc:"节点同时执行",Icon:GU},{type:"loop",label:"循环",desc:"节点循环执行",Icon:HR}];let $1=0;function wy(){return $1+=1,`node_${$1}`}function vy(e,t,n){const r=_a();return{id:e,type:"agentNode",position:t,data:{agent:{...r,name:(n==null?void 0:n.name)??`agent_${e.replace("node_","")}`,...n}}}}function dfe({data:e,selected:t}){const n=e.agent;return l.jsxs("div",{className:`wfb-node ${t?"wfb-node--selected":""}`,children:[l.jsx(cc,{type:"target",position:Be.Left,className:"wfb-handle"}),l.jsx("div",{className:"wfb-node-icon",children:l.jsx(Hl,{className:"icon"})}),l.jsxs("div",{className:"wfb-node-body",children:[l.jsx("div",{className:"wfb-node-name",children:n.name||"未命名节点"}),l.jsx("div",{className:"wfb-node-desc",children:n.instruction?n.instruction.slice(0,48):"点击编辑指令…"})]}),l.jsx(cc,{type:"source",position:Be.Right,className:"wfb-handle"})]})}const ffe={agentNode:dfe},w2={type:"smoothstep",markerEnd:{type:Td.ArrowClosed,width:16,height:16}};function hfe({onBack:e,onCreate:t}){const n=v.useRef(null),[r,s]=v.useState(""),[i,a]=v.useState(""),[o,c]=v.useState("sequential"),u=v.useMemo(()=>{$1=0;const I=wy();return vy(I,{x:80,y:120},{name:"agent_1"})},[]),[d,f,h]=Mde([u]),[p,m,g]=Dde([]),[x,y]=v.useState(u.id),E=d.find(I=>I.id===x)??null,b=r.trim()||"workflow_agent",_=v.useMemo(()=>jD({name:b,subAgents:d.map(I=>I.data.agent)}),[b,d]),k=Cl(b)??(_.has(b)?"名称须与 Agent 节点名称保持唯一":null),T=E?Cl(E.data.agent.name)??(_.has(E.data.agent.name)?"Agent 名称在当前工作流中必须唯一":null):null,A=d.length>0&&k===null&&d.every(I=>Cl(I.data.agent.name)===null&&!_.has(I.data.agent.name)),N=v.useCallback(I=>m(L=>yj({...I,...w2},L)),[m]),S=v.useCallback(()=>{const I=wy(),L=d.length*28,O=vy(I,{x:80+L,y:120+L});f(B=>B.concat(O)),y(I)},[d.length,f]),C=I=>{I.dataTransfer.setData("application/wfb-node","agentNode"),I.dataTransfer.effectAllowed="move"},M=v.useCallback(I=>{I.preventDefault(),I.dataTransfer.dropEffect="move"},[]),U=v.useCallback(I=>{if(I.preventDefault(),I.dataTransfer.getData("application/wfb-node")!=="agentNode"||!n.current)return;const O=n.current.screenToFlowPosition({x:I.clientX,y:I.clientY}),B=wy(),R=vy(B,O);f(z=>z.concat(R)),y(B)},[f]),q=v.useCallback(I=>{x&&f(L=>L.map(O=>O.id===x?{...O,data:{...O.data,agent:{...O.data.agent,...I}}}:O))},[x,f]),P=v.useCallback(()=>{x&&(f(I=>I.filter(L=>L.id!==x)),m(I=>I.filter(L=>L.source!==x&&L.target!==x)),y(null))},[x,f,m]),D=v.useCallback(()=>{if(!A)return;const I=d.map(O=>O.data.agent),L={..._a(),name:b,description:i.trim(),instruction:i.trim(),subAgents:I,workflow:{type:o,nodes:d.map(O=>({id:O.id,agent:O.data.agent})),edges:p.map(O=>({from:O.source,to:O.target}))}};t(L)},[A,d,p,b,i,o,t]);return l.jsx("div",{className:"wfb",children:l.jsxs("div",{className:"wfb-grid",children:[l.jsxs("aside",{className:"wfb-palette",children:[l.jsx("div",{className:"wfb-section-label",children:"工作流信息"}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"名称"}),l.jsx("input",{className:`wfb-input ${k?"wfb-input--error":""}`,value:r,onChange:I=>s(I.target.value),placeholder:"my_workflow"}),k&&l.jsx("span",{className:"wfb-field-error",children:k})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"描述"}),l.jsx("textarea",{className:"wfb-input wfb-textarea",value:i,onChange:I=>a(I.target.value),placeholder:"这个工作流做什么…",rows:2})]}),l.jsx("div",{className:"wfb-section-label",children:"执行方式"}),l.jsx("div",{className:"wfb-types",children:ufe.map(({type:I,label:L,desc:O,Icon:B})=>l.jsxs("button",{type:"button",className:`wfb-type ${o===I?"wfb-type--active":""}`,onClick:()=>c(I),children:[l.jsx(B,{className:"icon"}),l.jsxs("span",{className:"wfb-type-text",children:[l.jsx("span",{className:"wfb-type-name",children:L}),l.jsx("span",{className:"wfb-type-desc",children:O})]})]},I))}),l.jsx("div",{className:"wfb-section-label",children:"节点"}),l.jsxs("div",{className:"wfb-palette-item",draggable:!0,onDragStart:C,title:"拖拽到画布,或点击下方按钮添加",children:[l.jsx(m7,{className:"icon wfb-grip"}),l.jsx("span",{className:"wfb-node-icon wfb-node-icon--sm",children:l.jsx(Hl,{className:"icon"})}),l.jsx("span",{className:"wfb-palette-item-text",children:"Agent 节点"})]}),l.jsxs("button",{className:"wfb-add",type:"button",onClick:S,children:[l.jsx(Ps,{className:"icon"}),"添加节点"]}),l.jsx("div",{className:"wfb-hint",children:"拖拽节点的圆点连线以表达执行顺序。"})]}),l.jsxs("div",{className:"wfb-canvas",children:[l.jsxs("button",{className:"wfb-create",onClick:D,disabled:!A,type:"button",children:[l.jsx(ho,{className:"icon"}),"创建工作流"]}),l.jsxs(Ode,{nodes:d,edges:p,onNodesChange:h,onEdgesChange:g,onConnect:N,onInit:I=>n.current=I,nodeTypes:ffe,defaultEdgeOptions:w2,onDrop:U,onDragOver:M,onNodeClick:(I,L)=>y(L.id),onPaneClick:()=>y(null),fitView:!0,fitViewOptions:{padding:.3,maxZoom:1},proOptions:{hideAttribution:!0},children:[l.jsx(Ude,{gap:16,size:1,color:"hsl(240 5.9% 88%)"}),l.jsx(Wde,{showInteractive:!1}),l.jsx(afe,{pannable:!0,zoomable:!0,className:"wfb-minimap"})]})]}),l.jsx("aside",{className:"wfb-inspector",children:E?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"wfb-inspector-head",children:[l.jsx("div",{className:"wfb-section-label",children:"节点配置"}),l.jsx("button",{className:"wfb-icon-btn",type:"button",onClick:P,title:"删除节点",children:l.jsx(mc,{className:"icon"})})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"名称"}),l.jsx("input",{className:`wfb-input ${T?"wfb-input--error":""}`,value:E.data.agent.name,onChange:I=>q({name:I.target.value}),placeholder:"agent_name"}),T?l.jsx("span",{className:"wfb-field-error",children:T}):l.jsx("span",{className:"wfb-field-help",children:"仅使用英文字母、数字和下划线,且名称保持唯一。"})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"描述"}),l.jsx("input",{className:"wfb-input",value:E.data.agent.description,onChange:I=>q({description:I.target.value}),placeholder:"这个 agent 做什么…"})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"指令 (instruction)"}),l.jsx("textarea",{className:"wfb-input wfb-textarea",value:E.data.agent.instruction,onChange:I=>q({instruction:I.target.value}),placeholder:"你是一个…",rows:6})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"工具 (逗号分隔)"}),l.jsx("input",{className:"wfb-input",value:E.data.agent.tools.join(", "),onChange:I=>q({tools:I.target.value.split(",").map(L=>L.trim()).filter(Boolean)}),placeholder:"web_search, calculator"})]}),l.jsxs("div",{className:"wfb-inspector-meta",children:[l.jsx("span",{className:"wfb-meta-key",children:"节点 ID"}),l.jsx("code",{className:"wfb-meta-val",children:E.id})]})]}):l.jsxs("div",{className:"wfb-inspector-empty",children:[l.jsx(Hl,{className:"wfb-empty-icon"}),l.jsx("p",{children:"选择一个节点以编辑其配置"}),l.jsxs("p",{className:"wfb-empty-sub",children:["共 ",d.length," 个节点 · ",p.length," 条连线"]})]})})]})})}function pfe(e){return l.jsx(Hj,{children:l.jsx(hfe,{...e})})}const v2=50*1024*1024,H1=800,mfe={name:"code_package",files:[]};function gfe(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 yfe(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 bfe(e){const t=e.flatMap(a=>{const o=yfe(a.name);return o?[{path:o,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>H1)throw new Error(`代码包文件数不能超过 ${H1} 个。`);const s=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,i=new Set;for(const a of s){if(i.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);i.add(a.path)}if(!i.has("app.py"))throw new Error("代码包根目录必须包含 app.py,作为 AgentKit 启动入口。");return s}function Efe({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n}){const r=v.useRef(null),s=v.useRef(0),[i,a]=v.useState(null),[o,c]=v.useState(""),[u,d]=v.useState(!1),[f,h]=v.useState(!1),[p,m]=v.useState(!1),[g,x]=v.useState(""),[y,E]=v.useState("cn-beijing"),[b,_]=v.useState();v.useEffect(()=>()=>{s.current+=1},[]);async function k(S){const C=++s.current;if(x(""),!S.name.toLowerCase().endsWith(".zip")){x("请选择 .zip 格式的代码包。");return}if(S.size>v2){x("代码包不能超过 50 MB。");return}h(!0);try{const M=await BD(new Uint8Array(await S.arrayBuffer()),{maxEntries:H1,maxUncompressedBytes:v2}),U=bfe(M);if(C!==s.current)return;c(S.name),a({name:gfe(S.name),files:U})}catch(M){if(C!==s.current)return;c(""),a(null),x(M instanceof Error?M.message:String(M))}finally{C===s.current&&h(!1)}}function T(S){var M;const C=(M=S.currentTarget.files)==null?void 0:M[0];S.currentTarget.value="",C&&k(C)}function A(S){var M;S.preventDefault(),m(!1);const C=(M=S.dataTransfer.files)==null?void 0:M[0];C&&k(C)}async function N(S,C,M){const U=b&&b.mode!=="public"?{mode:b.mode,vpc_id:b.vpcId,subnet_ids:b.subnetIds,enable_shared_internet_access:b.enableSharedInternetAccess}:void 0;return Um(S.name,S.files,{region:y,projectName:"default",network:U},{...M,onStage:C})}return l.jsxs("div",{className:"package-create package-create-preview",children:[l.jsx(lg,{project:i??mfe,agentName:(i==null?void 0:i.name)||"代码包",onChange:i?a:void 0,onDeploy:N,onAgentAdded:t,onDeploymentTaskChange:n,network:b,onNetworkChange:_,deployRegion:y,onDeployRegionChange:E,onBack:e,backLabel:"返回创建方式",deployDisabled:!i||f,deployDisabledReason:f?"正在读取代码包":i?void 0:"请先上传代码包",deploymentPrimaryPane:l.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[l.jsx("div",{className:"package-source-label",children:"代码包"}),l.jsxs("div",{className:`package-dropzone${p?" is-dragging":""}${i?" is-ready":""}`,onDragEnter:S=>{S.preventDefault(),m(!0)},onDragOver:S=>S.preventDefault(),onDragLeave:S=>{S.currentTarget.contains(S.relatedTarget)||m(!1)},onDrop:A,onClick:()=>{var S;f||(S=r.current)==null||S.click()},onKeyDown:S=>{var C;!f&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),(C=r.current)==null||C.click())},role:"button",tabIndex:f?-1:0,"aria-label":i?"重新上传代码包":"上传代码包","aria-disabled":f,children:[l.jsx("strong",{children:f?"正在读取代码包…":i?o:"请上传代码包"}),l.jsx("span",{children:i?`已识别 ${i.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB,根目录需包含 app.py"}),l.jsx("div",{className:"package-upload-actions",children:i&&l.jsx("button",{type:"button",className:"package-upload-secondary",onClick:S=>{S.stopPropagation(),d(!0)},onKeyDown:S=>S.stopPropagation(),children:"查看文件"})}),l.jsx("input",{ref:r,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:T})]}),g&&l.jsx("div",{className:"package-create-error",role:"alert",children:g})]})}),i&&l.jsx(OD,{project:i,open:u,onClose:()=>d(!1),onChange:a})]})}const xfe=3*60*1e3,wfe=3e3,vfe=10*60*1e3,hm="veadk.studio.pending-update",_2=[{id:"resolving",label:"读取目标版本信息"},{id:"downloading",label:"下载并校验完整更新包"},{id:"preparing",label:"准备 VeFaaS Function 代码"},{id:"submitting",label:"提交 Function 更新"},{id:"publishing",label:"发布新 Revision 并重启服务"}],_fe={resolving:"读取版本信息",downloading:"下载更新包",preparing:"准备 Function 代码",submitting:"提交 Function 更新",publishing:"发布 Revision",checking:"检查更新",unknown:"未知阶段"};function kfe(e){return e<60?`${e} 秒`:`${Math.floor(e/60)} 分 ${e%60} 秒`}function Tfe(e,t){return e===t?!0:/^\d{14}$/.test(e)&&/^\d{14}$/.test(t)&&e>t}function Sfe(){if(typeof window>"u")return null;const e=window.localStorage.getItem(hm);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(hm),null}function _y(e,t){window.localStorage.setItem(hm,JSON.stringify({targetVersion:e,startedAt:t}))}function yh(){window.localStorage.removeItem(hm)}function k2({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M19.2 8.3A8 8 0 1 0 20 13"}),l.jsx("path",{d:"M19.2 4.8v3.5h-3.5"}),l.jsx("path",{d:"M12 7.8v7.7"}),l.jsx("path",{d:"m9.2 12.7 2.8 2.8 2.8-2.8"})]})}function Nfe(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m4 6 4 4 4-4"})})}function Afe(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})})}function T2({lines:e,phase:t,copyState:n,onCopy:r}){const s=v.useRef(null),i=v.useRef(!0);return v.useEffect(()=>{const a=s.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[e]),l.jsxs("section",{className:"studio-update-live-log","aria-label":"VeFaaS 更新日志",children:[l.jsxs("div",{className:"studio-update-log-header",children:[l.jsxs("span",{children:[l.jsx("i",{className:`is-${t}`,"aria-hidden":!0}),"VeFaaS 更新日志",l.jsx("small",{children:t==="active"?"实时":t==="complete"?"已完成":"已停止"})]}),l.jsx("button",{type:"button",onClick:r,disabled:!e.length,children:n==="copied"?"已复制":n==="error"?"复制失败":"复制日志"})]}),l.jsx("div",{ref:s,className:"studio-update-log-lines",role:"log","aria-live":"off",tabIndex:0,onScroll:a=>{const o=a.currentTarget;i.current=o.scrollHeight-o.scrollTop-o.clientHeight<24},children:e.length?e.map((a,o)=>l.jsx("div",{children:a},`${o}-${a}`)):l.jsx("p",{children:t==="active"?"等待 VeFaaS 返回更新日志…":"本次更新未返回发布日志"})})]})}function Cfe(){var q,P;const[e]=v.useState(Sfe),[t,n]=v.useState(null),[r,s]=v.useState(e?"submitting":"idle"),[i,a]=v.useState(!1),[o,c]=v.useState(""),[u,d]=v.useState((e==null?void 0:e.targetVersion)??""),[f,h]=v.useState(!1),[p,m]=v.useState("idle"),[g,x]=v.useState(0),y=v.useRef(null),E=v.useRef((e==null?void 0:e.targetVersion)??""),b=v.useRef((e==null?void 0:e.startedAt)??0);v.useEffect(()=>{if(!f)return;const D=L=>{var O;L.target instanceof Node&&!((O=y.current)!=null&&O.contains(L.target))&&h(!1)},I=L=>{L.key==="Escape"&&h(!1)};return window.addEventListener("pointerdown",D),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",D),window.removeEventListener("keydown",I)}},[f]);const _=v.useCallback(async()=>{const D=await wL(E.current||void 0,b.current||void 0);return n(D),D},[]);if(v.useEffect(()=>{let D=!0;const I=()=>{_().catch(()=>{D&&n(O=>O)})};I();const L=window.setInterval(I,xfe);return()=>{D=!1,window.clearInterval(L)}},[_]),v.useEffect(()=>{if(r!=="submitting")return;const D=window.setInterval(()=>{_().then(I=>{const L=E.current;if(L&&Tfe(I.currentVersion,L)||!L&&!I.available&&I.latestVersion){window.clearInterval(D),yh(),s("published"),c("Studio 已更新,刷新页面即可使用新版本");return}if(I.state==="error"){window.clearInterval(D),yh(),s("error"),c(I.message||"Studio 更新失败");return}Date.now()-b.current>vfe&&(window.clearInterval(D),yh(),s("error"),c("等待 VeFaaS 发布超时,请稍后重新检查版本"))}).catch(()=>{})},wfe);return()=>window.clearInterval(D)},[r,_]),v.useEffect(()=>{r!=="idle"||(t==null?void 0:t.state)!=="updating"||(E.current=t.targetVersion,b.current=t.startedAt||Date.now(),_y(t.targetVersion,b.current),d(t.targetVersion),s("submitting"))},[r,t]),v.useEffect(()=>{if(r!=="submitting"){x(0);return}const D=()=>{const L=b.current||Date.now();x(Math.max(0,Math.floor((Date.now()-L)/1e3)))};D();const I=window.setInterval(D,1e3);return()=>window.clearInterval(I)},[r]),!(t!=null&&t.enabled)||!(t.available||t.state==="updating"||r!=="idle"))return null;const T=t.releases??[],A=u||((q=T[0])==null?void 0:q.version)||t.latestVersion,N=T.find(D=>D.version===A),S=async()=>{E.current=A,b.current=Date.now(),_y(A,b.current),s("submitting"),c(""),m("idle");try{const D=await vL(A);E.current=D.version,_y(D.version,b.current),c("更新已提交,正在等待 VeFaaS 发布新版本")}catch(D){if(D instanceof TypeError){c("连接已切换,正在确认新版本状态");return}yh(),s("error");const I=D instanceof Error?D.message:"Studio 更新失败";try{const L=await _();c(L.message||I)}catch{c(I)}}},C=(P=t.updateLogs)!=null&&P.length?t.updateLogs:(t.errorLog||t.progressMessage||o).split(` + M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Kj.displayName="MiniMap";const afe=v.memo(Kj),ofe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,lfe={[oc.Line]:"right",[oc.Handle]:"bottom-right"};function cfe({nodeId:e,position:t,variant:n=oc.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:o=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:p=!0,shouldResize:m,onResizeStart:g,onResize:x,onResizeEnd:y}){const E=vj(),b=typeof e=="string"?e:E,_=qt(),k=v.useRef(null),T=n===oc.Handle,A=ft(v.useCallback(ofe(T&&p),[T,p]),Wt),N=v.useRef(null),S=t??lfe[n];v.useEffect(()=>{if(!(!k.current||!b))return N.current||(N.current=Ece({domNode:k.current,nodeId:b,getStoreItems:()=>{const{nodeLookup:M,transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D,domNode:I}=_.getState();return{nodeLookup:M,transform:U,snapGrid:q,snapToGrid:P,nodeOrigin:D,paneDomNode:I}},onChange:(M,U)=>{const{triggerNodeChanges:q,nodeLookup:P,parentLookup:D,nodeOrigin:I}=_.getState(),L=[],O={x:M.x,y:M.y},B=P.get(b);if(B&&B.expandParent&&B.parentId){const R=B.origin??I,z=M.width??B.measured.width??0,Y=M.height??B.measured.height??0,j={id:B.id,parentId:B.parentId,rect:{width:z,height:Y,...UP({x:M.x??B.position.x,y:M.y??B.position.y},{width:z,height:Y},B.parentId,P,R)}},re=Ww([j],P,D,I);L.push(...re),O.x=M.x?Math.max(R[0]*z,M.x):void 0,O.y=M.y?Math.max(R[1]*Y,M.y):void 0}if(O.x!==void 0&&O.y!==void 0){const R={id:b,type:"position",position:{...O}};L.push(R)}if(M.width!==void 0&&M.height!==void 0){const z={id:b,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};L.push(z)}for(const R of U){const z={...R,type:"position"};L.push(z)}q(L)},onEnd:({width:M,height:U})=>{const q={id:b,type:"dimensions",resizing:!1,dimensions:{width:M,height:U}};_.getState().triggerNodeChanges([q])}})),N.current.update({controlPosition:S,boundaries:{minWidth:o,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:h,onResizeStart:g,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{var M;(M=N.current)==null||M.destroy()}},[S,o,c,u,d,f,g,x,y,m]);const C=S.split("-");return l.jsx("div",{className:Tn(["react-flow__resize-control","nodrag",...C,n,r]),ref:k,style:{...s,scale:A,...a&&{[T?"backgroundColor":"borderColor"]:a}},children:i})}v.memo(cfe);const ufe=[{type:"sequential",label:"顺序",desc:"节点依次执行",Icon:x7},{type:"parallel",label:"并行",desc:"节点同时执行",Icon:GU},{type:"loop",label:"循环",desc:"节点循环执行",Icon:HR}];let $1=0;function wy(){return $1+=1,`node_${$1}`}function vy(e,t,n){const r=_a();return{id:e,type:"agentNode",position:t,data:{agent:{...r,name:(n==null?void 0:n.name)??`agent_${e.replace("node_","")}`,...n}}}}function dfe({data:e,selected:t}){const n=e.agent;return l.jsxs("div",{className:`wfb-node ${t?"wfb-node--selected":""}`,children:[l.jsx(cc,{type:"target",position:Be.Left,className:"wfb-handle"}),l.jsx("div",{className:"wfb-node-icon",children:l.jsx(Hl,{className:"icon"})}),l.jsxs("div",{className:"wfb-node-body",children:[l.jsx("div",{className:"wfb-node-name",children:n.name||"未命名节点"}),l.jsx("div",{className:"wfb-node-desc",children:n.instruction?n.instruction.slice(0,48):"点击编辑指令…"})]}),l.jsx(cc,{type:"source",position:Be.Right,className:"wfb-handle"})]})}const ffe={agentNode:dfe},w2={type:"smoothstep",markerEnd:{type:Td.ArrowClosed,width:16,height:16}};function hfe({onBack:e,onCreate:t}){const n=v.useRef(null),[r,s]=v.useState(""),[i,a]=v.useState(""),[o,c]=v.useState("sequential"),u=v.useMemo(()=>{$1=0;const I=wy();return vy(I,{x:80,y:120},{name:"agent_1"})},[]),[d,f,h]=Mde([u]),[p,m,g]=Dde([]),[x,y]=v.useState(u.id),E=d.find(I=>I.id===x)??null,b=r.trim()||"workflow_agent",_=v.useMemo(()=>jD({name:b,subAgents:d.map(I=>I.data.agent)}),[b,d]),k=Cl(b)??(_.has(b)?"名称须与 Agent 节点名称保持唯一":null),T=E?Cl(E.data.agent.name)??(_.has(E.data.agent.name)?"Agent 名称在当前工作流中必须唯一":null):null,A=d.length>0&&k===null&&d.every(I=>Cl(I.data.agent.name)===null&&!_.has(I.data.agent.name)),N=v.useCallback(I=>m(L=>yj({...I,...w2},L)),[m]),S=v.useCallback(()=>{const I=wy(),L=d.length*28,O=vy(I,{x:80+L,y:120+L});f(B=>B.concat(O)),y(I)},[d.length,f]),C=I=>{I.dataTransfer.setData("application/wfb-node","agentNode"),I.dataTransfer.effectAllowed="move"},M=v.useCallback(I=>{I.preventDefault(),I.dataTransfer.dropEffect="move"},[]),U=v.useCallback(I=>{if(I.preventDefault(),I.dataTransfer.getData("application/wfb-node")!=="agentNode"||!n.current)return;const O=n.current.screenToFlowPosition({x:I.clientX,y:I.clientY}),B=wy(),R=vy(B,O);f(z=>z.concat(R)),y(B)},[f]),q=v.useCallback(I=>{x&&f(L=>L.map(O=>O.id===x?{...O,data:{...O.data,agent:{...O.data.agent,...I}}}:O))},[x,f]),P=v.useCallback(()=>{x&&(f(I=>I.filter(L=>L.id!==x)),m(I=>I.filter(L=>L.source!==x&&L.target!==x)),y(null))},[x,f,m]),D=v.useCallback(()=>{if(!A)return;const I=d.map(O=>O.data.agent),L={..._a(),name:b,description:i.trim(),instruction:i.trim(),subAgents:I,workflow:{type:o,nodes:d.map(O=>({id:O.id,agent:O.data.agent})),edges:p.map(O=>({from:O.source,to:O.target}))}};t(L)},[A,d,p,b,i,o,t]);return l.jsx("div",{className:"wfb",children:l.jsxs("div",{className:"wfb-grid",children:[l.jsxs("aside",{className:"wfb-palette",children:[l.jsx("div",{className:"wfb-section-label",children:"工作流信息"}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"名称"}),l.jsx("input",{className:`wfb-input ${k?"wfb-input--error":""}`,value:r,onChange:I=>s(I.target.value),placeholder:"my_workflow"}),k&&l.jsx("span",{className:"wfb-field-error",children:k})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"描述"}),l.jsx("textarea",{className:"wfb-input wfb-textarea",value:i,onChange:I=>a(I.target.value),placeholder:"这个工作流做什么…",rows:2})]}),l.jsx("div",{className:"wfb-section-label",children:"执行方式"}),l.jsx("div",{className:"wfb-types",children:ufe.map(({type:I,label:L,desc:O,Icon:B})=>l.jsxs("button",{type:"button",className:`wfb-type ${o===I?"wfb-type--active":""}`,onClick:()=>c(I),children:[l.jsx(B,{className:"icon"}),l.jsxs("span",{className:"wfb-type-text",children:[l.jsx("span",{className:"wfb-type-name",children:L}),l.jsx("span",{className:"wfb-type-desc",children:O})]})]},I))}),l.jsx("div",{className:"wfb-section-label",children:"节点"}),l.jsxs("div",{className:"wfb-palette-item",draggable:!0,onDragStart:C,title:"拖拽到画布,或点击下方按钮添加",children:[l.jsx(m7,{className:"icon wfb-grip"}),l.jsx("span",{className:"wfb-node-icon wfb-node-icon--sm",children:l.jsx(Hl,{className:"icon"})}),l.jsx("span",{className:"wfb-palette-item-text",children:"Agent 节点"})]}),l.jsxs("button",{className:"wfb-add",type:"button",onClick:S,children:[l.jsx(Ps,{className:"icon"}),"添加节点"]}),l.jsx("div",{className:"wfb-hint",children:"拖拽节点的圆点连线以表达执行顺序。"})]}),l.jsxs("div",{className:"wfb-canvas",children:[l.jsxs("button",{className:"wfb-create",onClick:D,disabled:!A,type:"button",children:[l.jsx(ho,{className:"icon"}),"创建工作流"]}),l.jsxs(Ode,{nodes:d,edges:p,onNodesChange:h,onEdgesChange:g,onConnect:N,onInit:I=>n.current=I,nodeTypes:ffe,defaultEdgeOptions:w2,onDrop:U,onDragOver:M,onNodeClick:(I,L)=>y(L.id),onPaneClick:()=>y(null),fitView:!0,fitViewOptions:{padding:.3,maxZoom:1},proOptions:{hideAttribution:!0},children:[l.jsx(Ude,{gap:16,size:1,color:"hsl(240 5.9% 88%)"}),l.jsx(Wde,{showInteractive:!1}),l.jsx(afe,{pannable:!0,zoomable:!0,className:"wfb-minimap"})]})]}),l.jsx("aside",{className:"wfb-inspector",children:E?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"wfb-inspector-head",children:[l.jsx("div",{className:"wfb-section-label",children:"节点配置"}),l.jsx("button",{className:"wfb-icon-btn",type:"button",onClick:P,title:"删除节点",children:l.jsx(mc,{className:"icon"})})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"名称"}),l.jsx("input",{className:`wfb-input ${T?"wfb-input--error":""}`,value:E.data.agent.name,onChange:I=>q({name:I.target.value}),placeholder:"agent_name"}),T?l.jsx("span",{className:"wfb-field-error",children:T}):l.jsx("span",{className:"wfb-field-help",children:"仅使用英文字母、数字和下划线,且名称保持唯一。"})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"描述"}),l.jsx("input",{className:"wfb-input",value:E.data.agent.description,onChange:I=>q({description:I.target.value}),placeholder:"这个 agent 做什么…"})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"指令 (instruction)"}),l.jsx("textarea",{className:"wfb-input wfb-textarea",value:E.data.agent.instruction,onChange:I=>q({instruction:I.target.value}),placeholder:"你是一个…",rows:6})]}),l.jsxs("label",{className:"wfb-field",children:[l.jsx("span",{className:"wfb-field-label",children:"工具 (逗号分隔)"}),l.jsx("input",{className:"wfb-input",value:E.data.agent.tools.join(", "),onChange:I=>q({tools:I.target.value.split(",").map(L=>L.trim()).filter(Boolean)}),placeholder:"web_search, calculator"})]}),l.jsxs("div",{className:"wfb-inspector-meta",children:[l.jsx("span",{className:"wfb-meta-key",children:"节点 ID"}),l.jsx("code",{className:"wfb-meta-val",children:E.id})]})]}):l.jsxs("div",{className:"wfb-inspector-empty",children:[l.jsx(Hl,{className:"wfb-empty-icon"}),l.jsx("p",{children:"选择一个节点以编辑其配置"}),l.jsxs("p",{className:"wfb-empty-sub",children:["共 ",d.length," 个节点 · ",p.length," 条连线"]})]})})]})})}function pfe(e){return l.jsx(Hj,{children:l.jsx(hfe,{...e})})}const v2=50*1024*1024,H1=800,mfe={name:"code_package",files:[]};function gfe(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 yfe(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 bfe(e){const t=e.flatMap(a=>{const o=yfe(a.name);return o?[{path:o,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>H1)throw new Error(`代码包文件数不能超过 ${H1} 个。`);const s=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,i=new Set;for(const a of s){if(i.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);i.add(a.path)}if(!i.has("app.py"))throw new Error("代码包根目录必须包含 app.py,作为 AgentKit 启动入口。");return s}function Efe({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n}){const r=v.useRef(null),s=v.useRef(0),[i,a]=v.useState(null),[o,c]=v.useState(""),[u,d]=v.useState(!1),[f,h]=v.useState(!1),[p,m]=v.useState(!1),[g,x]=v.useState(""),[y,E]=v.useState("cn-beijing"),[b,_]=v.useState();v.useEffect(()=>()=>{s.current+=1},[]);async function k(S){const C=++s.current;if(x(""),!S.name.toLowerCase().endsWith(".zip")){x("请选择 .zip 格式的代码包。");return}if(S.size>v2){x("代码包不能超过 50 MB。");return}h(!0);try{const M=await BD(new Uint8Array(await S.arrayBuffer()),{maxEntries:H1,maxUncompressedBytes:v2}),U=bfe(M);if(C!==s.current)return;c(S.name),a({name:gfe(S.name),files:U})}catch(M){if(C!==s.current)return;c(""),a(null),x(M instanceof Error?M.message:String(M))}finally{C===s.current&&h(!1)}}function T(S){var M;const C=(M=S.currentTarget.files)==null?void 0:M[0];S.currentTarget.value="",C&&k(C)}function A(S){var M;S.preventDefault(),m(!1);const C=(M=S.dataTransfer.files)==null?void 0:M[0];C&&k(C)}async function N(S,C,M){const U=b&&b.mode!=="public"?{mode:b.mode,vpc_id:b.vpcId,subnet_ids:b.subnetIds,enable_shared_internet_access:b.enableSharedInternetAccess}:void 0;return Um(S.name,S.files,{region:y,projectName:"default",network:U},{...M,onStage:C})}return l.jsxs("div",{className:"package-create package-create-preview",children:[l.jsx(lg,{project:i??mfe,agentName:(i==null?void 0:i.name)||"代码包",onChange:i?a:void 0,onDeploy:N,onAgentAdded:t,onDeploymentTaskChange:n,network:b,onNetworkChange:_,deployRegion:y,onDeployRegionChange:E,onBack:e,backLabel:"返回创建方式",deployDisabled:!i||f,deployDisabledReason:f?"正在读取代码包":i?void 0:"请先上传代码包",deploymentPrimaryPane:l.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[l.jsx("div",{className:"package-source-label",children:"代码包"}),l.jsxs("div",{className:`package-dropzone${p?" is-dragging":""}${i?" is-ready":""}`,onDragEnter:S=>{S.preventDefault(),m(!0)},onDragOver:S=>S.preventDefault(),onDragLeave:S=>{S.currentTarget.contains(S.relatedTarget)||m(!1)},onDrop:A,onClick:()=>{var S;f||(S=r.current)==null||S.click()},onKeyDown:S=>{var C;!f&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),(C=r.current)==null||C.click())},role:"button",tabIndex:f?-1:0,"aria-label":i?"重新上传代码包":"上传代码包","aria-disabled":f,children:[l.jsx("strong",{children:f?"正在读取代码包…":i?o:"请上传代码包"}),l.jsx("span",{children:i?`已识别 ${i.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB,根目录需包含 app.py"}),l.jsx("div",{className:"package-upload-actions",children:i&&l.jsx("button",{type:"button",className:"package-upload-secondary",onClick:S=>{S.stopPropagation(),d(!0)},onKeyDown:S=>S.stopPropagation(),children:"查看文件"})}),l.jsx("input",{ref:r,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:T})]}),g&&l.jsx("div",{className:"package-create-error",role:"alert",children:g})]})}),i&&l.jsx(OD,{project:i,open:u,onClose:()=>d(!1),onChange:a})]})}const xfe=3*60*1e3,wfe=3e3,vfe=10*60*1e3,hm="veadk.studio.pending-update",_2=[{id:"resolving",label:"读取目标版本信息"},{id:"downloading",label:"下载并校验完整更新包"},{id:"preparing",label:"准备 VeFaaS Function 代码"},{id:"submitting",label:"提交 Function 更新"},{id:"publishing",label:"发布新 Revision 并重启服务"}],_fe={resolving:"读取版本信息",downloading:"下载更新包",preparing:"准备 Function 代码",submitting:"提交 Function 更新",publishing:"发布 Revision",checking:"检查更新",unknown:"未知阶段"};function kfe(e){return e<60?`${e} 秒`:`${Math.floor(e/60)} 分 ${e%60} 秒`}function Tfe(e,t){return e===t?!0:/^\d{14}$/.test(e)&&/^\d{14}$/.test(t)&&e>t}function Sfe(){if(typeof window>"u")return null;const e=window.localStorage.getItem(hm);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(hm),null}function _y(e,t){window.localStorage.setItem(hm,JSON.stringify({targetVersion:e,startedAt:t}))}function yh(){window.localStorage.removeItem(hm)}function k2({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("path",{d:"M19.2 8.3A8 8 0 1 0 20 13"}),l.jsx("path",{d:"M19.2 4.8v3.5h-3.5"}),l.jsx("path",{d:"M12 7.8v7.7"}),l.jsx("path",{d:"m9.2 12.7 2.8 2.8 2.8-2.8"})]})}function Nfe(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m4 6 4 4 4-4"})})}function Afe(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})})}function T2({lines:e,phase:t,copyState:n,onCopy:r}){const s=v.useRef(null),i=v.useRef(!0);return v.useEffect(()=>{const a=s.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[e]),l.jsxs("section",{className:"studio-update-live-log","aria-label":"VeFaaS 更新日志",children:[l.jsxs("div",{className:"studio-update-log-header",children:[l.jsxs("span",{children:[l.jsx("i",{className:`is-${t}`,"aria-hidden":!0}),"VeFaaS 更新日志",l.jsx("small",{children:t==="active"?"实时":t==="complete"?"已完成":"已停止"})]}),l.jsx("button",{type:"button",onClick:r,disabled:!e.length,children:n==="copied"?"已复制":n==="error"?"复制失败":"复制日志"})]}),l.jsx("div",{ref:s,className:"studio-update-log-lines",role:"log","aria-live":"off",tabIndex:0,onScroll:a=>{const o=a.currentTarget;i.current=o.scrollHeight-o.scrollTop-o.clientHeight<24},children:e.length?e.map((a,o)=>l.jsx("div",{children:a},`${o}-${a}`)):l.jsx("p",{children:t==="active"?"等待 VeFaaS 返回更新日志…":"本次更新未返回发布日志"})})]})}function Cfe(){var q,P;const[e]=v.useState(Sfe),[t,n]=v.useState(null),[r,s]=v.useState(e?"submitting":"idle"),[i,a]=v.useState(!1),[o,c]=v.useState(""),[u,d]=v.useState((e==null?void 0:e.targetVersion)??""),[f,h]=v.useState(!1),[p,m]=v.useState("idle"),[g,x]=v.useState(0),y=v.useRef(null),E=v.useRef((e==null?void 0:e.targetVersion)??""),b=v.useRef((e==null?void 0:e.startedAt)??0);v.useEffect(()=>{if(!f)return;const D=L=>{var O;L.target instanceof Node&&!((O=y.current)!=null&&O.contains(L.target))&&h(!1)},I=L=>{L.key==="Escape"&&h(!1)};return window.addEventListener("pointerdown",D),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",D),window.removeEventListener("keydown",I)}},[f]);const _=v.useCallback(async()=>{const D=await EL(E.current||void 0,b.current||void 0);return n(D),D},[]);if(v.useEffect(()=>{let D=!0;const I=()=>{_().catch(()=>{D&&n(O=>O)})};I();const L=window.setInterval(I,xfe);return()=>{D=!1,window.clearInterval(L)}},[_]),v.useEffect(()=>{if(r!=="submitting")return;const D=window.setInterval(()=>{_().then(I=>{const L=E.current;if(L&&Tfe(I.currentVersion,L)||!L&&!I.available&&I.latestVersion){window.clearInterval(D),yh(),s("published"),c("Studio 已更新,刷新页面即可使用新版本");return}if(I.state==="error"){window.clearInterval(D),yh(),s("error"),c(I.message||"Studio 更新失败");return}Date.now()-b.current>vfe&&(window.clearInterval(D),yh(),s("error"),c("等待 VeFaaS 发布超时,请稍后重新检查版本"))}).catch(()=>{})},wfe);return()=>window.clearInterval(D)},[r,_]),v.useEffect(()=>{r!=="idle"||(t==null?void 0:t.state)!=="updating"||(E.current=t.targetVersion,b.current=t.startedAt||Date.now(),_y(t.targetVersion,b.current),d(t.targetVersion),s("submitting"))},[r,t]),v.useEffect(()=>{if(r!=="submitting"){x(0);return}const D=()=>{const L=b.current||Date.now();x(Math.max(0,Math.floor((Date.now()-L)/1e3)))};D();const I=window.setInterval(D,1e3);return()=>window.clearInterval(I)},[r]),!(t!=null&&t.enabled)||!(t.available||t.state==="updating"||r!=="idle"))return null;const T=t.releases??[],A=u||((q=T[0])==null?void 0:q.version)||t.latestVersion,N=T.find(D=>D.version===A),S=async()=>{E.current=A,b.current=Date.now(),_y(A,b.current),s("submitting"),c(""),m("idle");try{const D=await xL(A);E.current=D.version,_y(D.version,b.current),c("更新已提交,正在等待 VeFaaS 发布新版本")}catch(D){if(D instanceof TypeError){c("连接已切换,正在确认新版本状态");return}yh(),s("error");const I=D instanceof Error?D.message:"Studio 更新失败";try{const L=await _();c(L.message||I)}catch{c(I)}}},C=(P=t.updateLogs)!=null&&P.length?t.updateLogs:(t.errorLog||t.progressMessage||o).split(` `).filter(Boolean),M=async()=>{try{await navigator.clipboard.writeText(C.join(` `)),m("copied")}catch{m("error")}},U=()=>{var D;h(!1),m("idle"),c(""),d(E.current||((D=T[0])==null?void 0:D.version)||""),s("confirm")};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`studio-update-trigger is-${r}`,title:r==="submitting"?"正在更新 Studio":r==="published"?"Studio 已更新":`更新 Studio 至 ${t.latestVersion}`,onClick:()=>{var D;r==="published"?window.location.reload():(r==="submitting"||r==="error"||(d(((D=T[0])==null?void 0:D.version)||t.latestVersion),s("confirm")),a(!0))},children:[l.jsx(k2,{className:"studio-update-icon"}),r==="submitting"?l.jsx(ji,{as:"span",children:"正在更新"}):r==="published"?l.jsx("span",{children:"刷新使用新版"}):r==="error"?l.jsx("span",{children:"更新失败"}):l.jsx("span",{children:"有新版更新"})]}),i&&r!=="idle"&&l.jsx("div",{className:"confirm-scrim",role:"presentation",children:l.jsxs("section",{className:"confirm-box studio-update-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"studio-update-title",children:[l.jsx("div",{className:"studio-update-dialog-mark",children:l.jsx(k2,{})}),l.jsx("div",{id:"studio-update-title",className:"confirm-title",children:r==="error"?"Studio 更新失败":r==="submitting"?"正在更新 Studio":r==="published"?"Studio 更新完成":"发现新版本"}),r==="error"?l.jsxs("div",{className:"studio-update-error-panel",children:[l.jsx("p",{className:"confirm-text studio-update-error",children:o}),l.jsxs("dl",{className:"studio-update-error-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"失败阶段"}),l.jsx("dd",{children:_fe[t.errorStage]||t.errorStage||"未知阶段"})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"错误 ID"}),l.jsx("dd",{children:t.errorId||"未生成"})]})]}),l.jsx(T2,{lines:C,phase:"error",copyState:p,onCopy:()=>void M()}),t.consoleUrl&&l.jsxs("a",{className:"studio-update-console-link",href:t.consoleUrl,target:"_blank",rel:"noreferrer",children:["前往 VeFaaS 控制台查看 Function 日志",l.jsx("span",{"aria-hidden":!0,children:"↗"})]})]}):r==="submitting"||r==="published"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"studio-update-progress-summary",children:[l.jsxs("div",{children:[l.jsx("span",{children:"目标版本"}),l.jsx("strong",{children:E.current||A})]}),l.jsxs("div",{children:[l.jsx("span",{children:r==="published"?"更新状态":"已用时"}),l.jsx("strong",{children:r==="published"?"已完成":kfe(g)})]})]}),l.jsx("ol",{className:"studio-update-progress","aria-label":"Studio 更新进度",children:_2.map((D,I)=>{const L=_2.findIndex(R=>R.id===t.progressStage),O=r==="published"||Ivoid M()}),l.jsx("p",{className:"studio-update-progress-note",children:"发布阶段会短暂中断连接;关闭此窗口不会停止更新,可随时点击右上角按钮重新查看。"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"confirm-text",children:"更新会重启 Studio 服务,预计约 3–5 分钟完成更新与发布。期间正在进行的对话、 流式响应或部署任务可能中断,登录态不会受到影响。"}),l.jsxs("div",{className:"studio-update-field",ref:y,children:[l.jsx("span",{children:"选择版本"}),l.jsxs("button",{type:"button",className:"studio-update-version-trigger","aria-label":"选择版本","aria-haspopup":"listbox","aria-expanded":f,onClick:()=>h(D=>!D),onKeyDown:D=>{(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),h(!0))},children:[l.jsx("span",{children:A}),l.jsx(Nfe,{})]}),f&&l.jsx("div",{className:"studio-update-version-menu",role:"listbox","aria-label":"选择版本",children:T.map(D=>{const I=D.version===A;return l.jsxs("button",{type:"button",role:"option","aria-selected":I,className:`studio-update-version-option${I?" is-selected":""}`,onClick:()=>{d(D.version),h(!1)},children:[l.jsx("span",{children:D.version}),I&&l.jsx(Afe,{})]},D.version)})})]}),l.jsxs("dl",{className:"studio-update-versions",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"当前版本"}),l.jsx("dd",{children:t.currentVersion})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"目标版本"}),l.jsx("dd",{children:A})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"Commit"}),l.jsx("dd",{children:((N==null?void 0:N.gitSha)||t.latestGitSha).slice(0,8)})]})]}),l.jsxs("section",{className:"studio-update-changelog","aria-labelledby":"studio-update-changelog-title",children:[l.jsx("div",{id:"studio-update-changelog-title",children:"更新内容"}),N!=null&&N.changelog.length?l.jsx("ul",{children:N.changelog.map(D=>l.jsx("li",{children:D},D))}):l.jsx("p",{children:"暂无更新说明"})]})]}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{type:"button",className:"confirm-btn",onClick:()=>{a(!1),h(!1),r==="confirm"&&(s("idle"),c(""))},children:r==="submitting"?"后台运行":r==="confirm"?"取消":"关闭"}),r==="confirm"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:()=>void S(),children:"立即更新"}),r==="error"&&l.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:U,children:"重新尝试"})]})]})})]})}const Ife="/web/skill-creator";class Xw extends Error{constructor(n,r){super(n);pv(this,"status");this.name="SkillCreatorApiError",this.status=r}}function Io(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} 格式错误`);return e}function Kt(e,...t){for(const n of t){const r=e[n];if(typeof r=="string"&&r)return r}}function Yj(e,...t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}}async function uf(e,t){return fetch(si(`${Ife}${e}`),{...t,headers:Bm({Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers})})}async function Qw(e,t){if((e.headers.get("content-type")??"").includes("application/json")){const s=Io(await e.json(),"错误响应");return Kt(s,"detail","message","error")??t}return(await e.text()).trim()||t}async function Zw(e,t){if(!e.ok)throw new Xw(await Qw(e,t),e.status);if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Error(`${t}:服务端返回了非 JSON 响应`);return e.json()}function Rfe(e){if(e==="queued")return"queued";if(e==="running")return"running";if(e==="succeeded")return"succeeded";if(e==="failed")return"failed";throw new Error(`未知的 Skill 生成状态:${String(e)}`)}function Lfe(e){if(e==="provisioning"||e==="generating"||e==="validating"||e==="packaging"||e==="completed"||e==="failed")return e;throw new Error(`未知的 Skill 生成阶段:${String(e)}`)}function Ofe(e){return Array.isArray(e)?e.map((t,n)=>{const r=Io(t,`文件 ${n+1}`),s=Kt(r,"path");if(!s)throw new Error(`文件 ${n+1} 缺少 path`);const i=Yj(r,"size");if(i===void 0)throw new Error(`文件 ${n+1} 缺少 size`);return{path:s,size:i}}):[]}function Mfe(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=Array.isArray(t.errors)?t.errors.map(String):[],r=Array.isArray(t.warnings)?t.warnings.map(String):[];return{valid:typeof t.valid=="boolean"?t.valid:n.length===0,errors:n,warnings:r}}function Dfe(e){if(e===void 0)return[];if(!Array.isArray(e))throw new Error("Skill 生成活动记录格式错误");return e.map((t,n)=>{const r=Io(t,`活动 ${n+1}`),s=Kt(r,"id"),i=Kt(r,"kind"),a=Kt(r,"status");if(!s||!i||!["status","thinking","tool","message"].includes(i))throw new Error(`活动 ${n+1} 格式错误`);if(a!=="running"&&a!=="done")throw new Error(`活动 ${n+1} 状态错误`);if(i==="tool"){const c=Kt(r,"name");if(!c)throw new Error(`活动 ${n+1} 缺少工具名称`);return{id:s,kind:i,name:c,args:r.input,response:r.output,status:a}}const o=Kt(r,"text");if(!o)throw new Error(`活动 ${n+1} 缺少文本`);return{id:s,kind:i,text:o,status:a}})}function Pfe(e,t){const n=Io(e,`候选方案 ${t+1}`),r=Kt(n,"id","candidate_id","candidateId"),s=Kt(n,"model","model_id","modelId");if(!r||!s)throw new Error(`候选方案 ${t+1} 缺少 id 或 model`);return{id:r,model:s,modelLabel:Kt(n,"modelLabel","model_label")??s,status:Rfe(n.status),stage:Lfe(n.stage),name:Kt(n,"name","skill_name","skillName"),description:Kt(n,"description"),skillMd:Kt(n,"skillMd","skill_md"),files:Ofe(n.files),activities:Dfe(n.activities),validation:Mfe(n.validation),durationMs:Yj(n,"elapsedMs","elapsed_ms"),error:Kt(n,"error","error_message","errorMessage"),published:n.published===!0,skillId:Kt(n,"skill_id","skillId"),version:Kt(n,"version")}}function z1(e,t=""){const n=Io(e,"Skill 创建任务"),r=Kt(n,"id","job_id","jobId");if(!r)throw new Error("Skill 创建任务缺少 id");const s=Array.isArray(n.candidates)?n.candidates.map(Pfe):[],i=Kt(n,"status")??"running";if(i!=="provisioning"&&i!=="running"&&i!=="completed")throw new Error(`未知的 Skill 任务状态:${i}`);return{id:r,prompt:Kt(n,"prompt")??t,status:i,candidates:s}}async function jfe(e,t){const n=await uf("/jobs",{method:"POST",body:JSON.stringify({prompt:e})});if(!n.ok)throw new Xw(await Qw(n,"创建 Skill 任务失败"),n.status);const r=n.headers.get("content-type")??"";if(r.includes("application/json")){const u=z1(await n.json(),e);return t==null||t(u),u}if(!r.includes("application/x-ndjson")||!n.body)throw new Error("创建 Skill 任务失败:服务端返回了非流式响应");const s=n.body.getReader(),i=new TextDecoder;let a="",o;const c=u=>{if(!u.trim())return;const d=Io(JSON.parse(u),"Skill 创建进度");if(d.type==="error")throw new Error(Kt(d,"error")??"创建 Skill 任务失败");if(d.type!=="progress"&&d.type!=="complete")throw new Error("未知的 Skill 创建进度事件");o=z1(d.job,e),t==null||t(o)};for(;;){const{done:u,value:d}=await s.read();a+=i.decode(d,{stream:!u});const f=a.split(` `);if(a=f.pop()??"",f.forEach(c),u)break}if(c(a),!o)throw new Error("创建 Skill 任务失败:服务端未返回任务");return o}async function Bfe(e){const t=await uf(`/jobs/${encodeURIComponent(e)}`);return z1(await Zw(t,"读取 Skill 任务失败"))}async function Ffe(e){const t=await uf(`/jobs/${encodeURIComponent(e)}`,{method:"DELETE"});await Zw(t,"清理 Skill 任务失败")}async function Ufe(e,t){var o;const n=await uf(`/jobs/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/download`);if(!n.ok)throw new Error(await Qw(n,"下载 Skill 失败"));const s=((o=(n.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:o[1])??"skill.zip",i=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=i,a.download=s,a.click(),URL.revokeObjectURL(i)}async function $fe(e,t,n){const r=await uf(`/jobs/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/publish`,{method:"POST",body:JSON.stringify(n)}),s=Io(await Zw(r,"添加到 AgentKit 失败"),"发布结果"),i=Kt(s,"skill_id","skillId","id");if(!i)throw new Error("发布结果缺少 skill_id");return{skillId:i,name:Kt(s,"name"),version:Kt(s,"version"),skillSpaceIds:Array.isArray(s.skillSpaceIds)?s.skillSpaceIds.map(String):Array.isArray(s.skill_space_ids)?s.skill_space_ids.map(String):[],message:Kt(s,"message")}}const Hfe=()=>{};function zfe(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 Vfe({activities:e}){const t=v.useMemo(()=>e.filter(n=>n.kind!=="status").map(zfe),[e]);return t.length===0?null:l.jsx("div",{className:"skill-conversation","aria-label":"Skill 生成对话","aria-live":"polite",children:l.jsx(hw,{blocks:t,onAction:Hfe})})}const S2={provisioning:"正在准备 Sandbox",generating:"正在生成 Skill",validating:"正在校验结构",packaging:"正在打包",completed:"生成完成",failed:"生成失败"},N2=12e4;function Kfe({status:e}){return e==="succeeded"?l.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"10",r:"7"}),l.jsx("path",{d:"m6.7 10.1 2.1 2.2 4.6-4.8"})]}):e==="failed"?l.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"10",r:"7"}),l.jsx("path",{d:"M10 6.2v4.5M10 13.6h.01"})]}):l.jsxs("svg",{className:"skill-candidate__spinner",viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"10",r:"7"}),l.jsx("path",{d:"M10 3a7 7 0 0 1 7 7"})]})}function Yfe(){return l.jsxs("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[l.jsx("path",{d:"M4.2 3.5h7.1l4.5 4.6v8.4H4.2z"}),l.jsx("path",{d:"M11.3 3.5v4.6h4.5M7 11h6M7 13.8h4.2"})]})}function Wfe(){return l.jsx("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:l.jsx("path",{d:"m9 5-5 5 5 5M4.5 10H16"})})}function qfe({candidate:e}){var c,u;const[t,n]=v.useState("SKILL.md"),r=e.files.find(d=>d.path.endsWith("SKILL.md")),s=e.skillMd&&!r?[{path:"SKILL.md",size:new Blob([e.skillMd]).size},...e.files]:e.files,i=s.find(d=>d.path===t)??s[0],a=(c=e.skillMd)==null?void 0:c.slice(0,N2),o=(((u=e.skillMd)==null?void 0:u.length)??0)>N2;return s.length===0?null:l.jsxs("div",{className:"skill-files",children:[l.jsx("div",{className:"skill-files__tabs",role:"tablist","aria-label":`${e.name??"Skill"} 文件`,children:s.map(d=>l.jsx("button",{type:"button",role:"tab","aria-selected":(i==null?void 0:i.path)===d.path,className:(i==null?void 0:i.path)===d.path?"is-active":"",onClick:()=>n(d.path),children:d.path},d.path))}),e.skillMd&&(i!=null&&i.path.endsWith("SKILL.md"))?l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:"skill-files__content",children:l.jsx("code",{children:a})}),o?l.jsx("p",{className:"skill-files__truncated",children:"预览内容较长,完整文件请下载 ZIP 查看。"}):null]}):l.jsx("div",{className:"skill-files__unavailable",children:i?`${i.path} · ${i.size.toLocaleString()} bytes`:"文件内容将在下载包中提供"})]})}function Gfe({label:e,jobId:t,candidate:n,selected:r,publishing:s,publishDisabled:i,publishError:a,onSelect:o,onPublish:c}){const[u,d]=v.useState("conversation"),[f,h]=v.useState(!1),[p,m]=v.useState(!1),[g,x]=v.useState(""),[y,E]=v.useState(""),[b,_]=v.useState(""),[k,T]=v.useState(""),A=v.useRef(null),N=v.useRef(null),S=n.status==="queued"||n.status==="running",C=n.status==="succeeded",M=n.validation;return l.jsxs("article",{className:`skill-candidate skill-candidate--${n.status}${r?" is-selected":""}`,"aria-label":`${e} ${n.model}`,children:[l.jsxs("header",{className:"skill-candidate__header",children:[l.jsx("h2",{children:n.model}),r?l.jsx("span",{className:"skill-candidate__selected",children:"已选方案"}):null]}),u==="conversation"?l.jsxs("div",{className:"skill-candidate__view skill-candidate__view--conversation",children:[l.jsxs("div",{className:"skill-candidate__status","aria-live":"polite",children:[l.jsx("span",{className:"skill-candidate__status-icon",children:l.jsx(Kfe,{status:n.status})}),S?l.jsx(ji,{duration:2.2,spread:16,children:S2[n.stage]}):l.jsx("span",{children:S2[n.stage]}),n.durationMs!==void 0&&C?l.jsxs("span",{className:"skill-candidate__duration",children:[(n.durationMs/1e3).toFixed(1)," 秒"]}):null]}),l.jsx(Vfe,{activities:n.activities}),n.error?l.jsx("div",{className:"skill-candidate__error",children:n.error}):null,C?l.jsx("div",{className:"skill-candidate__view-actions",children:l.jsxs("button",{ref:A,type:"button",className:"skill-action skill-action--preview",onClick:()=>{d("preview"),requestAnimationFrame(()=>{var U;return(U=N.current)==null?void 0:U.focus()})},children:[l.jsx(Yfe,{}),"查看 Skill"]})}):null]}):l.jsxs("div",{className:"skill-candidate__view skill-candidate__view--preview",children:[l.jsx("div",{className:"skill-candidate__preview-nav",children:l.jsxs("button",{ref:N,type:"button",className:"skill-candidate__back",onClick:()=>{d("conversation"),requestAnimationFrame(()=>{var U;return(U=A.current)==null?void 0:U.focus()})},children:[l.jsx(Wfe,{}),"返回对话"]})}),l.jsxs("div",{className:"skill-candidate__result",children:[l.jsxs("div",{className:"skill-candidate__summary",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Skill"}),l.jsx("strong",{children:n.name??"未命名 Skill"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"文件"}),l.jsx("strong",{children:n.files.length})]}),l.jsxs("div",{children:[l.jsx("span",{children:"校验"}),l.jsx("strong",{className:(M==null?void 0:M.valid)===!1?"is-invalid":"is-valid",children:(M==null?void 0:M.valid)===!1?"未通过":"已通过"})]})]}),n.description?l.jsx("p",{className:"skill-candidate__description",children:n.description}):null,M&&(M.errors.length>0||M.warnings.length>0)?l.jsxs("details",{className:"skill-validation",children:[l.jsx("summary",{children:"查看校验详情"}),[...M.errors,...M.warnings].map((U,q)=>l.jsx("div",{children:U},`${U}-${q}`))]}):null,l.jsx(qfe,{candidate:n}),l.jsxs("div",{className:"skill-candidate__actions",children:[l.jsx("button",{type:"button",className:"skill-action skill-action--select","aria-pressed":r,onClick:o,children:r?"已采用此方案":"采用此方案"}),l.jsx("button",{type:"button",className:"skill-action",disabled:p,onClick:()=>{m(!0),x(""),Ufe(t,n.id).catch(U=>{x(U instanceof Error?U.message:String(U))}).finally(()=>m(!1))},children:p?"正在下载…":"下载 ZIP"}),l.jsx("button",{type:"button",className:"skill-action",disabled:!r||s||i||n.published,title:r?void 0:"请先采用此方案",onClick:()=>h(U=>!U),children:n.published?"已添加到 AgentKit":s?"正在添加…":"添加到 AgentKit"})]}),g?l.jsx("div",{className:"skill-candidate__error",children:g}):null,f&&r&&!n.published?l.jsxs("form",{className:"skill-publish-form",onSubmit:U=>{U.preventDefault();const q=y.split(",").map(P=>P.trim()).filter(Boolean);c({skillSpaceIds:q,...b.trim()?{projectName:b.trim()}:{},...k.trim()?{skillId:k.trim()}:{}})},children:[l.jsxs("label",{children:[l.jsx("span",{children:"SkillSpace ID(可选)"}),l.jsx("input",{value:y,onChange:U=>E(U.target.value),placeholder:"多个 ID 用英文逗号分隔"})]}),l.jsxs("div",{className:"skill-publish-form__optional",children:[l.jsxs("label",{children:[l.jsx("span",{children:"项目名称(可选)"}),l.jsx("input",{value:b,onChange:U=>_(U.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"已有 Skill ID(可选)"}),l.jsx("input",{value:k,onChange:U=>T(U.target.value)})]})]}),l.jsx("button",{type:"submit",className:"skill-action skill-action--select",disabled:s,children:s?"正在添加…":"确认添加"})]}):null,a?l.jsx("div",{className:"skill-candidate__error",children:a}):null]})]})]})}const A2=new Set(["completed"]),bh=1100,Xfe=3e4;function Qfe(e,t){return{id:`pending-${t}`,model:e,modelLabel:e,status:"queued",stage:"provisioning",files:[],activities:[{id:"provisioning",kind:"status",text:"正在拉起 Sandbox",status:"running"}]}}function Zfe({initialJob:e}){const[t,n]=v.useState(e),[r,s]=v.useState(""),[i,a]=v.useState(!1),[o,c]=v.useState(),[u,d]=v.useState(),[f,h]=v.useState(()=>new Set),[p,m]=v.useState({});v.useEffect(()=>{n(e),s(""),a(!1)},[e]),v.useEffect(()=>{if(A2.has(e.status)||e.id.startsWith("pending-"))return;let y=!1,E;const b=Date.now()+Xfe,_=async()=>{try{const k=await Bfe(e.id);y||(n({...k,prompt:k.prompt||e.prompt}),s(""),A2.has(k.status)||(E=window.setTimeout(_,bh)))}catch(k){if(!y){const T=k instanceof Xw?k:void 0;if((T==null?void 0:T.status)===404&&Date.now(){y=!0,E!==void 0&&window.clearTimeout(E)}},[e.id,e.status]);const g=pw.map((y,E)=>t.candidates.find(b=>b.model===y)??t.candidates[E]??Qfe(y,E));async function x(y,E){d(y.id),m(b=>({...b,[y.id]:""}));try{await $fe(t.id,y.id,E),h(b=>new Set(b).add(y.id))}catch(b){m(_=>({..._,[y.id]:b instanceof Error?b.message:String(b)}))}finally{d(void 0)}}return l.jsxs("section",{className:"skill-workspace",children:[l.jsx("header",{className:"skill-workspace__intro",children:l.jsx("h1",{children:"正在把需求变成可运行的 Skill"})}),r?l.jsxs("div",{className:"skill-workspace__poll-error",role:"alert",children:["状态刷新失败:",r,"。",i?"":"页面会继续重试。"]}):null,l.jsx("div",{className:"skill-workspace__grid",children:g.map((y,E)=>{const _=f.has(y.id)||y.published?{...y,published:!0}:y;return l.jsx(Gfe,{label:`方案 ${E===0?"A":"B"}`,jobId:t.id,candidate:_,selected:o===y.id,publishing:u===y.id,publishDisabled:u!==void 0&&u!==y.id,publishError:p[y.id],onSelect:()=>c(y.id),onPublish:k=>void x(y,k)},`${y.model}-${y.id}`)})})]})}const ky="/web/sandbox/sessions",Jfe=33e4,ehe=6e5,the=15e3;function Ty(e){const t=Bm(e);return t.set("Accept","application/json"),t}async function Sy(e,t){let n={};try{n=await e.json()}catch{return new Error(`${t}(HTTP ${e.status})`)}const r=n.detail,s=r&&typeof r=="object"&&"message"in r?r.message:r??n.message;return new Error(typeof s=="string"&&s?s:t)}async function nhe(e,t){if(!e.body)throw new Error("沙箱对话服务未返回内容。");const n=e.body.getReader(),r=new TextDecoder;let s="",i="";const a=[],o=new Map;function c(){t==null||t(a.map(h=>({...h})))}function u(h){i+=h;const p=a[a.length-1];(p==null?void 0:p.kind)==="text"?p.text+=h:a.push({kind:"text",text:h}),c()}function d(h){if(typeof h.id!="string"||h.kind!=="thinking"&&h.kind!=="tool"||h.status!=="running"&&h.status!=="done")return;const p=h.status==="done";let m;if(h.kind==="thinking"){if(typeof h.text!="string"||!h.text)return;m={kind:"thinking",text:h.text,done:p}}else{if(typeof h.name!="string"||!h.name)return;m={kind:"tool",name:h.name,args:h.args,response:h.response,done:p}}const g=o.get(h.id);g===void 0?(o.set(h.id,a.length),a.push(m)):a[g]=m,c()}function f(h){let p="message";const m=[];for(const x of h.split(/\r?\n/))x.startsWith("event:")&&(p=x.slice(6).trim()),x.startsWith("data:")&&m.push(x.slice(5).trimStart());if(m.length===0)return;let g;try{g=JSON.parse(m.join(` `))}catch{throw new Error("沙箱对话服务返回了无法解析的响应。")}if(p==="error")throw new Error(typeof g.message=="string"&&g.message?g.message:"沙箱对话失败,请稍后重试。");p==="activity"&&d(g),p==="delta"&&typeof g.text=="string"&&u(g.text),p==="done"&&!i&&typeof g.text=="string"&&u(g.text)}for(;;){const{done:h,value:p}=await n.read();s+=r.decode(p,{stream:!h});const m=s.split(/\r?\n\r?\n/);if(s=m.pop()??"",m.forEach(f),h)break}if(s.trim()&&f(s),a.length===0)throw new Error("沙箱未返回有效回复,请重试。");return{text:i,blocks:a}}const Ny={async startSession(e={}){const t=await fetch(si(ky),{method:"POST",headers:Ty({"Content-Type":"application/json"}),signal:Ls(e.signal,Jfe)});if(!t.ok)throw await Sy(t,"无法启动 AgentKit 沙箱,请稍后重试。");const n=await t.json();if(!n.sessionId||n.status!=="ready")throw new Error("AgentKit 沙箱返回了无效的会话信息。");return{id:n.sessionId,toolName:"codex",createdAt:new Date().toISOString()}},async sendMessage(e,t={}){if(!e.sessionId||!e.text.trim())throw new Error("内置智能体会话缺少有效的消息内容。");const n=await fetch(si(`${ky}/${encodeURIComponent(e.sessionId)}/messages`),{method:"POST",headers:Ty({Accept:"text/event-stream","Content-Type":"application/json"}),body:JSON.stringify({message:e.text}),signal:Ls(t.signal,ehe)});if(!n.ok)throw await Sy(n,"沙箱对话失败,请稍后重试。");return nhe(n,t.onBlocks)},async closeSession(e,t={}){if(!e)return;const n=await fetch(si(`${ky}/${encodeURIComponent(e)}`),{method:"DELETE",headers:Ty(),signal:Ls(t.signal,the)});if(!n.ok&&n.status!==404)throw await Sy(n,"无法清理 AgentKit 沙箱会话。")}},rhe=1e4;async function Wj(e){const t=await fetch(si(e),{headers:Bm({Accept:"application/json"}),signal:Ls(void 0,rhe)});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}}async function she(){return Wj("/web/sandbox/capabilities")}async function ihe(){return Wj("/web/skill-creator/capabilities")}function ahe(e){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[l.jsx("path",{d:"M12 3.5c.35 3.05 1.62 5.32 4.9 6.1-3.28.78-4.55 3.05-4.9 6.1-.35-3.05-1.62-5.32-4.9-6.1 3.28-.78 4.55-3.05 4.9-6.1Z"}),l.jsx("path",{d:"M18.5 14.5c.18 1.55.84 2.7 2.5 3.1-1.66.4-2.32 1.55-2.5 3.1-.18-1.55-.84-2.7-2.5-3.1 1.66-.4 2.32-1.55 2.5-3.1Z"}),l.jsx("path",{d:"M5.3 14.2c.14 1.15.62 2 1.85 2.3-1.23.3-1.71 1.15-1.85 2.3-.14-1.15-.62-2-1.85-2.3 1.23-.3 1.71-1.15 1.85-2.3Z"})]})}function ohe({open:e,state:t,error:n,onCancel:r,onConfirm:s}){const i=v.useRef(null),a=v.useRef(null);if(v.useEffect(()=>{var f;if(!e)return;const u=document.body.style.overflow;document.body.style.overflow="hidden",(f=a.current)==null||f.focus();const d=h=>{var x;if(h.key==="Escape"){h.preventDefault(),r();return}if(h.key!=="Tab")return;const p=(x=i.current)==null?void 0:x.querySelectorAll("button:not(:disabled)");if(!(p!=null&&p.length))return;const m=p[0],g=p[p.length-1];h.shiftKey&&document.activeElement===m?(h.preventDefault(),g.focus()):!h.shiftKey&&document.activeElement===g&&(h.preventDefault(),m.focus())};return window.addEventListener("keydown",d),()=>{document.body.style.overflow=u,window.removeEventListener("keydown",d)}},[r,e]),!e)return null;const o=t==="loading",c=o?"正在初始化沙箱":t==="error"?"启动失败":"启用 Codex 智能体";return ai.createPortal(l.jsx("div",{className:"sandbox-dialog-backdrop",onMouseDown:u=>{u.target===u.currentTarget&&!o&&r()},children:l.jsxs("section",{ref:i,className:"sandbox-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-dialog-title","aria-describedby":"sandbox-dialog-description",children:[l.jsxs("div",{className:"sandbox-dialog-visual","aria-hidden":"true",children:[l.jsx("span",{className:"sandbox-dialog-orbit"}),l.jsx("span",{className:"sandbox-dialog-icon",children:o?l.jsx("span",{className:"sandbox-spinner"}):l.jsx(ahe,{})})]}),l.jsxs("div",{className:"sandbox-dialog-copy",children:[l.jsx("h2",{id:"sandbox-dialog-title",children:c}),t==="error"?l.jsx("p",{id:"sandbox-dialog-description",className:"sandbox-dialog-error",role:"alert",children:n||"AgentKit 沙箱初始化失败,请稍后重新尝试。"}):o?l.jsx("p",{id:"sandbox-dialog-description","aria-live":"polite",children:"正在寻找可用工具并创建内置智能体会话,通常需要一点时间。"}):l.jsx("p",{id:"sandbox-dialog-description",children:"将启动 AgentKit 沙箱与 Codex 智能体,本次对话不会被持久化保存。"})]}),l.jsxs("footer",{className:"sandbox-dialog-actions",children:[l.jsx("button",{ref:a,type:"button",onClick:r,children:o?"取消启动":"取消"}),!o&&l.jsx("button",{type:"button",className:"is-primary",onClick:s,children:t==="error"?"重新尝试":"确认开启"})]})]})}),document.body)}function lhe({onExit:e}){return l.jsxs("div",{className:"sandbox-session-warning",role:"status",children:[l.jsx("span",{className:"sandbox-session-warning-dot","aria-hidden":"true"}),l.jsx("span",{className:"sandbox-session-warning-copy",children:"当前为 Codex 智能体会话,退出后对话内容消失"}),l.jsx("button",{type:"button",onClick:e,children:"退出内置智能体"})]})}function che({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"9.3",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 10.2 11.3 4.8c.5-.8 1.7-.45 1.7.5v3.8h4.2a2.1 2.1 0 0 1 2.04 2.6l-1.4 5.75A2.1 2.1 0 0 1 15.8 19H8"})]})}function uhe({filled:e=!1,...t}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"4.5",height:"10.2",rx:"1.5"}),l.jsx("path",{d:"M8 13.8 11.3 19.2c.5.8 1.7.45 1.7-.5v-3.8h4.2a2.1 2.1 0 0 0 2.04-2.6l-1.4-5.75A2.1 2.1 0 0 0 15.8 5H8"})]})}const C2=["#6366f1","#0ea5e9","#10b981","#f59e0b","#f43f5e","#a855f7","#14b8a6","#f472b6"];function Ay(e){let t=0;for(let n=0;n>>0;return C2[t%C2.length]}function dhe(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 s=(u,d)=>u.start_time-d.start_time,i=(u,d)=>({span:u,depth:d,children:(n.get(u.span_id)??[]).sort(s).map(f=>i(f,d+1))}),a=r.sort(s).map(u=>i(u,0)),o=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:o,total:c-o||1}}function fhe(e,t){const n=[],r=s=>{n.push(s),t.has(s.span.span_id)||s.children.forEach(r)};return e.forEach(r),n}function I2(e){const t=e/1e6;return t>=1e3?`${(t/1e3).toFixed(2)} s`:`${t.toFixed(t<10?2:1)} ms`}const hhe=e=>e.replace(/^(gen_ai|a2ui|adk)\./,"");function R2(e){return Object.entries(e.attributes).filter(([,t])=>t!=null&&typeof t!="object").map(([t,n])=>{const r=String(n);return{key:hhe(t),value:r,long:r.length>80||r.includes(` -`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function phe({appName:e,sessionId:t,onClose:n}){const[r,s]=v.useState(null),[i,a]=v.useState(""),[o,c]=v.useState(new Set),[u,d]=v.useState(null);v.useEffect(()=>{s(null),a(""),sL(e,t).then(E=>{s(E),d(E.length?E.reduce((b,_)=>b.start_time<=_.start_time?b:_).span_id:null)}).catch(E=>a(String(E)))},[e,t]);const{rootNodes:f,min:h,total:p}=v.useMemo(()=>dhe(r??[]),[r]),m=v.useMemo(()=>fhe(f,o),[f,o]),g=(r==null?void 0:r.find(E=>E.span_id===u))??null,x=p/1e6,y=E=>c(b=>{const _=new Set(b);return _.has(E)?_.delete(E):_.add(E),_});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim",onClick:n}),l.jsxs("aside",{className:"drawer drawer--trace",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"drawer-title",children:"调用链路观测"}),l.jsx("div",{className:"drawer-sub",children:r?`${r.length} 个调用 · ${x.toFixed(1)} ms`:"加载中"})]}),l.jsx("button",{className:"drawer-close",onClick:n,"aria-label":"关闭",children:l.jsx(Wr,{className:"icon"})})]}),r==null&&!i&&l.jsxs("div",{className:"drawer-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载调用链路…"]}),i&&l.jsx("div",{className:"error",children:i}),r&&r.length===0&&l.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),m.length>0&&l.jsxs("div",{className:"trace-split",children:[l.jsx("div",{className:"trace-tree scroll",children:m.map(E=>{const b=E.span,_=(b.start_time-h)/p*100,k=Math.max((b.end_time-b.start_time)/p*100,.6),T=E.children.length>0;return l.jsxs("button",{className:`trace-row ${u===b.span_id?"active":""}`,onClick:()=>d(b.span_id),children:[l.jsxs("span",{className:"trace-label",style:{paddingLeft:E.depth*14},children:[l.jsx("span",{className:`trace-caret ${T?"":"hidden"} ${o.has(b.span_id)?"":"open"}`,onClick:A=>{A.stopPropagation(),T&&y(b.span_id)},children:l.jsx(Nr,{className:"chev"})}),l.jsx("span",{className:"trace-dot",style:{background:Ay(b.name)}}),l.jsx("span",{className:"trace-name",title:b.name,children:b.name})]}),l.jsx("span",{className:"trace-dur",children:I2(b.end_time-b.start_time)}),l.jsx("span",{className:"trace-track",children:l.jsx("span",{className:"trace-bar",style:{left:`${_}%`,width:`${k}%`,background:Ay(b.name)}})})]},b.span_id)})}),l.jsx("div",{className:"trace-detail scroll",children:g?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"td-title",children:g.name}),l.jsxs("div",{className:"td-dur",children:[l.jsx("span",{className:"td-dot",style:{background:Ay(g.name)}}),I2(g.end_time-g.start_time)]}),l.jsx("div",{className:"td-section",children:"属性"}),l.jsx("div",{className:"td-props",children:R2(g).filter(E=>!E.long).map(E=>l.jsxs("div",{className:"td-prop",children:[l.jsx("span",{className:"td-key",children:E.key}),l.jsx("span",{className:"td-val",children:E.value})]},E.key))}),R2(g).filter(E=>E.long).map(E=>l.jsxs("div",{className:"td-block",children:[l.jsx("div",{className:"td-section",children:E.key}),l.jsx("pre",{className:"td-pre",children:E.value})]},E.key))]}):l.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}function mhe(e){return e.toLowerCase()==="github"?l.jsx(p7,{className:"icon"}):l.jsx(v7,{className:"icon"})}function ghe({branding:e,onUsername:t}){const[n,r]=v.useState(null),[s,i]=v.useState(""),[a,o]=v.useState(0),[c,u]=v.useState("");v.useEffect(()=>{let h=!0;return r(null),i(""),YR().then(p=>{h&&r(p)}).catch(p=>{h&&i(p instanceof Error?p.message:String(p))}),()=>{h=!1}},[a]);const d=H7.test(c),f=()=>{d&&t(c)};return l.jsxs("div",{className:"login",children:[l.jsx("header",{className:"login-top",children:l.jsxs("span",{className:"login-brand",children:[l.jsx("img",{className:"login-brand-logo",src:e.logoUrl||ow,width:20,height:20,alt:"","aria-hidden":!0}),e.title]})}),l.jsx("main",{className:"login-main",children:l.jsxs("div",{className:"login-card",children:[l.jsx(ji,{as:"h1",className:"login-title",duration:4.8,spread:22,children:e.title}),s?l.jsxs("div",{className:"login-provider-error",role:"alert",children:[l.jsx("p",{children:s}),l.jsx("button",{type:"button",onClick:()=>o(h=>h+1),children:"重试"})]}):n===null?null:n.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"登录以继续使用"}),l.jsx("div",{className:"login-providers",children:n.map(h=>l.jsxs("button",{className:"login-btn",onClick:()=>V7(h.loginUrl),children:[mhe(h.id),l.jsxs("span",{children:["使用 ",h.label," 登录"]})]},h.id))})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"输入一个用户名即可开始"}),l.jsxs("form",{className:"login-name",onSubmit:h=>{h.preventDefault(),f()},children:[l.jsx("input",{className:"login-name-input",value:c,onChange:h=>u(h.target.value),placeholder:"用户名(字母 + 数字,最多 16 位)",maxLength:16,autoFocus:!0}),l.jsx("button",{type:"submit",className:"login-name-go",disabled:!d,"aria-label":"进入",children:l.jsx(IR,{className:"icon"})})]}),l.jsx("p",{className:"login-hint","aria-live":"polite",children:c&&!d?"只能包含大小写字母和数字,最多 16 位。":""})]}),l.jsx("p",{className:"login-powered",children:"火山引擎 AgentKit 提供企业级 Agent 解决方案"}),l.jsxs("p",{className:"login-legal",children:["继续即表示你已阅读并同意 AgentKit"," ",l.jsx("a",{href:"https://docs.volcengine.com/docs/86681/1925174?lang=zh",target:"_blank",rel:"noreferrer",children:"产品和服务条款"})]})]})}),l.jsx("footer",{className:"login-footer",children:"© 2026 VeADK. All rights reserved."})]})}function yhe({open:e,checking:t,error:n,onLogin:r}){const s=v.useRef(null);return v.useEffect(()=>{var a;if(!e)return;const i=document.body.style.overflow;return document.body.style.overflow="hidden",(a=s.current)==null||a.focus(),()=>{document.body.style.overflow=i}},[e]),e?ai.createPortal(l.jsx("div",{className:"auth-expired-backdrop",children:l.jsxs("section",{className:"auth-expired-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"auth-expired-title","aria-describedby":"auth-expired-description",children:[l.jsx("div",{className:"auth-expired-mark","aria-hidden":"true",children:l.jsx(yx,{})}),l.jsxs("div",{className:"auth-expired-copy",children:[l.jsx("h2",{id:"auth-expired-title",children:"登录状态已过期"}),l.jsx("p",{id:"auth-expired-description",children:"当前编辑内容会保留。重新登录后,刚才的操作将自动继续。"}),n&&l.jsx("p",{className:"auth-expired-error",role:"alert",children:n})]}),l.jsx("footer",{className:"auth-expired-actions",children:l.jsx("button",{ref:s,type:"button",onClick:r,disabled:t,children:t?"等待登录完成…":"重新登录"})})]})}),document.body):null}function bhe({node:e,ctx:t}){const n=e.variant??"default";return l.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)})}Co("Button",bhe);function Ehe({node:e,ctx:t}){return l.jsx("div",{className:"a2ui-card","data-a2ui-id":e.id,"data-a2ui-component":e.component,children:t.render(e.child)})}Co("Card",Ehe);const xhe={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly",stretch:"stretch"},whe={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};function qj(e){return xhe[e]??"flex-start"}function Gj(e){return whe[e]??"stretch"}function vhe({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-column","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"column",justifyContent:qj(e.justify),alignItems:Gj(e.align)},children:n.map(r=>t.render(r))})}Co("Column",vhe);function _he({node:e}){const t=e.axis==="vertical";return l.jsx("div",{className:`a2ui-divider ${t?"a2ui-divider--v":"a2ui-divider--h"}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component})}Co("Divider",_he);const khe={send:"✈️",check:"✅",close:"✖️",star:"⭐",favorite:"❤️",info:"ℹ️",help:"❓",error:"⛔",calendarToday:"📅",event:"📅",schedule:"🕒",locationOn:"📍",accountCircle:"👤",mail:"✉️",call:"📞",home:"🏠",settings:"⚙️",search:"🔍"};function The({node:e}){const t=e.name??"";return l.jsx("span",{className:"a2ui-icon",title:t,"aria-label":t,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:khe[t]??"•"})}Co("Icon",The);function She({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-row","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"row",justifyContent:qj(e.justify),alignItems:Gj(e.align??"center")},children:n.map(r=>t.render(r))})}Co("Row",She);const Nhe=new Set(["h1","h2","h3","h4","h5"]);function Ahe({node:e,ctx:t}){const n=e.variant??"body",r=t.resolveString(e.text),s=Nhe.has(n)?n:"p";return l.jsx(s,{className:`a2ui-text a2ui-text--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:r})}Co("Text",Ahe);const Che="创建 Agent",Ihe={intelligent:"智能模式",custom:"自定义",template:"从模板新建",workflow:"工作流",package:"代码包部署"},Go={app:"veadk.appName",view:"veadk.view",session:"veadk.sessionId"},Rhe=new Set,Lhe=[];function bi(){return{skills:[]}}function V1(e,t){if(e.name===t||e.id===t)return e;for(const n of e.children){const r=V1(n,t);if(r)return r}}function Xj(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(...Xj(n)));return t}function L2(){const e=typeof localStorage<"u"?localStorage.getItem(Go.view):null;return e==="menu"||e==="intelligent"||e==="custom"||e==="template"||e==="workflow"?e:null}function Ohe({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("ellipse",{cx:"12",cy:"12",rx:"6.6",ry:"8.2"}),l.jsx("path",{d:"M12 8.2l1.05 2.75 2.75 1.05-2.75 1.05L12 15.8l-1.05-2.75L8.2 12l2.75-1.05z",fill:"currentColor",stroke:"none"})]})}function Mhe(){return l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[l.jsx("rect",{x:"3",y:"4",width:"14",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("rect",{x:"6",y:"10.4",width:"13",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.7"}),l.jsx("rect",{x:"9",y:"16.8",width:"9",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.45"})]})}function Qj(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 Dhe(e){if(!e)return"";const t=[];return e.ts&&t.push(Qj(e.ts)),e.tokens!=null&&t.push(`${e.tokens.toLocaleString()} tokens`),t.join(" · ")}function O2(e){return e.blocks.map(t=>t.kind==="text"?t.text:"").join("").trim()}const Phe="send_a2ui_json_to_client";function jhe(e){return e.blocks.some(t=>t.kind==="text"?t.text.trim().length>0:t.kind==="attachment"?t.files.length>0:t.kind==="tool"?!(t.name===Phe&&t.done):t.kind==="agent-transfer"?!1:t.kind==="a2ui"?N3(t.messages).some(n=>n.components[n.rootId]):t.kind==="auth")}function Bhe(e){return e.blocks.some(t=>t.kind==="auth"&&!t.done)}function Fhe(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 s=window.open(e,"veadk_oauth","width=520,height=720");if(!s){n(new Error("弹窗被拦截,请允许弹窗后重试。"));return}let i=!1;const a=()=>{clearInterval(u),window.removeEventListener("message",c)},o=d=>{if(!i){i=!0,a();try{s.close()}catch{}t(d)}},c=d=>{if(d.origin!==window.location.origin)return;const f=d.data;f&&f.veadkOAuth&&typeof f.url=="string"&&o(f.url)};window.addEventListener("message",c);const u=setInterval(()=>{if(!i){if(s.closed){a();const d=window.prompt("授权完成后,请粘贴回调页面(浏览器地址栏)的完整 URL:");d&&d.trim()?(i=!0,t(d.trim())):n(new Error("授权已取消。"));return}try{const d=s.location.href;d&&d!=="about:blank"&&new URL(d).origin===window.location.origin&&/[?&](code|state|error)=/.test(d)&&o(d)}catch{}}},500)})}function Uhe(e,t){const n=JSON.parse(JSON.stringify(e??{})),r=n.exchangedAuthCredential??n.exchanged_auth_credential??{},s=r.oauth2??{};return s.authResponseUri=t,s.auth_response_uri=t,r.oauth2=s,n.exchangedAuthCredential=r,n}function M2({text:e}){const[t,n]=v.useState(!1);return l.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?l.jsx(Bs,{className:"icon"}):l.jsx(Ex,{className:"icon"})})}function $he(e){return e==="cn-beijing"?"华北 2(北京)":e==="cn-shanghai"?"华东 2(上海)":e||"未指定"}function Hhe({tasks:e,onCancel:t}){const[n,r]=v.useState(!1),[s,i]=v.useState(null),a=e.filter(f=>f.status==="running").length,o=e[0],c=a>0?"running":(o==null?void 0:o.status)??"idle",u=a>0?`${a} 个部署任务进行中`:(o==null?void 0:o.status)==="success"?"最近部署已完成":(o==null?void 0:o.status)==="error"?"最近部署失败":(o==null?void 0:o.status)==="cancelled"?"最近部署已取消":"部署任务",d=f=>{i(f.id),t(f).finally(()=>i(null))};return l.jsxs("div",{className:"global-deploy-center",children:[l.jsxs("button",{type:"button",className:`global-deploy-task is-${c}`,"aria-expanded":n,"aria-haspopup":"dialog",onClick:()=>r(f=>!f),children:[c==="running"?l.jsx(bt,{className:"global-deploy-task-icon spin"}):c==="success"?l.jsx(e7,{className:"global-deploy-task-icon"}):c==="error"?l.jsx(yx,{className:"global-deploy-task-icon"}):c==="cancelled"?l.jsx(t7,{className:"global-deploy-task-icon"}):l.jsx(w7,{className:"global-deploy-task-icon"}),l.jsx("span",{className:"global-deploy-task-detail",children:u}),l.jsx(od,{className:`global-deploy-task-chevron${n?" is-open":""}`})]}),n&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"global-deploy-task-scrim","aria-label":"关闭部署任务",onClick:()=>r(!1)}),l.jsxs("section",{className:"global-deploy-popover",role:"dialog","aria-label":"部署任务",children:[l.jsxs("header",{className:"global-deploy-popover-head",children:[l.jsx("span",{children:"部署任务"}),l.jsx("span",{children:e.length})]}),l.jsx("div",{className:"global-deploy-list",children:e.length===0?l.jsx("div",{className:"global-deploy-empty",children:"暂无部署任务"}):e.map(f=>{const h=`${f.label}${f.status==="running"&&typeof f.pct=="number"?` ${Math.round(f.pct)}%`:""}`;return l.jsxs("article",{className:`global-deploy-item is-${f.status}`,children:[l.jsxs("div",{className:"global-deploy-item-head",children:[l.jsx("span",{className:"global-deploy-runtime-name",children:f.runtimeName}),l.jsx("span",{className:"global-deploy-status",children:h})]}),l.jsxs("dl",{className:"global-deploy-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Runtime 名称"}),l.jsx("dd",{children:f.runtimeName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"部署地域"}),l.jsx("dd",{children:$he(f.region)})]}),f.runtimeId&&l.jsxs("div",{children:[l.jsx("dt",{children:"Runtime ID"}),l.jsx("dd",{children:f.runtimeId})]})]}),f.message&&f.status==="error"?l.jsx(nm,{className:"global-deploy-error",message:f.message,onRetry:f.retry}):f.message?l.jsx("p",{className:"global-deploy-message",children:f.message}):null,f.status==="running"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"global-deploy-progress","aria-hidden":!0,children:l.jsx("span",{style:{width:`${Math.max(6,Math.min(100,f.pct??6))}%`}})}),l.jsx("div",{className:"global-deploy-item-actions",children:l.jsx("button",{type:"button",disabled:s===f.id,onClick:()=>d(f),children:s===f.id?"取消中…":"取消部署"})})]})]},f.id)})})]})]})]})}const D2=["今天想做点什么?","有什么可以帮你的?","需要我帮你查点什么吗?","有问题尽管问我","嗨,我们开始吧","开始一段新对话吧","今天想先解决哪件事?","把你的想法告诉我吧","我们从哪里开始?","有什么任务交给我?","准备好一起推进了吗?","说说你现在最关心的问题","今天也一起把事情做好","我在,随时可以开始"],P2=()=>D2[Math.floor(Math.random()*D2.length)];function Cy(e){var t;for(const n of e)(t=n.previewUrl)!=null&&t.startsWith("blob:")&&URL.revokeObjectURL(n.previewUrl)}function zhe(){return`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Vhe(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"}function Khe(){const[e,t]=v.useState([]),[n,r]=v.useState(""),[s,i]=v.useState([]),[a,o]=v.useState(""),c=v.useRef(null),[u,d]=v.useState(!1),[f,h]=v.useState([]),[p,m]=v.useState(null),[g,x]=v.useState([]),[y,E]=v.useState(!1),[b,_]=v.useState(!1),[k,T]=v.useState("confirm"),[A,N]=v.useState(""),S=v.useRef(null),C=v.useRef(null),[M,U]=v.useState({}),q=a?M[a]??[]:f,P=p?g:q,D=(H,G)=>U(fe=>({...fe,[H]:typeof G=="function"?G(fe[H]??[]):G})),[I,L]=v.useState(""),[O,B]=v.useState("agent"),[R,z]=v.useState({}),[Y,j]=v.useState(null),[re,V]=v.useState(!1),ee=v.useRef(0),[oe,X]=v.useState([]),[ae,Z]=v.useState(bi),[de,ye]=v.useState(null),[Q,ge]=v.useState(!1),[be,_e]=v.useState(null),[Pe,we]=v.useState(!1),[ht,je]=v.useState([]),[Fe,ut]=v.useState(!1),he=v.useRef(new Set),[Et,mt]=v.useState(()=>new Set),[W,J]=v.useState(()=>new Set),ce=v.useRef(new Map),ke=v.useRef(new Map),pe=(H,G)=>mt(fe=>{const Ne=new Set(fe);return G?Ne.add(H):Ne.delete(H),Ne}),Xe=H=>{const G=ke.current.get(H);G!==void 0&&window.clearTimeout(G),ke.current.delete(H),J(fe=>new Set(fe).add(H))},St=H=>{const G=ke.current.get(H);G!==void 0&&window.clearTimeout(G);const fe=window.setTimeout(()=>{ke.current.delete(H),J(Ne=>{const De=new Set(Ne);return De.delete(H),De})},2400);ke.current.set(H,fe)},We=v.useRef(""),[Sn,Me]=v.useState(""),[wt,vt]=v.useState(()=>new Set),[Ct,Gt]=v.useState(!1),[Ve,ot]=v.useState(!1),_t=v.useRef(null),kt=v.useCallback(()=>ot(!1),[]),[le,Le]=v.useState(P2),[Ge,Bt]=v.useState(null),[Nn,nn]=v.useState(!1),[Ft,Ut]=v.useState(!1),[wn,dn]=v.useState(""),rn=v.useRef(!1),[fn,se]=v.useState(null),[ue,Te]=v.useState(""),[qe,$e]=v.useState(),[Ie,lt]=v.useState(null),[Nt,Kn]=v.useState({newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,addAgentkit:!0}),[sn,Pn]=v.useState("cloud"),[Mt,jn]=v.useState(ud),[Qr,vr]=v.useState(""),[An,Bn]=v.useState("chat"),[Yn,nr]=v.useState(!1),[vn,$t]=v.useState(!1),[an,Cn]=v.useState(!1),[Wn,on]=v.useState({}),[Mr,Fn]=v.useState({}),[In,qn]=v.useState({}),Zr=Et.has(a),Hs=W.has(a),ps=Zr||u,ne=!!a&&Pe,Ce=p?y:ps,He=Ce||!p&&Hs,ct=Wn[a]??"",Ht=Mr[a]??Rhe,hn=In[a]??Lhe,gt=de==null?void 0:de.graph,Gn=[de==null?void 0:de.name,gt==null?void 0:gt.name,gt==null?void 0:gt.id].filter(H=>!!H),Xn=ae.targetAgent&>?V1(gt,ae.targetAgent.name):gt,fr=(Xn==null?void 0:Xn.skills)??(ae.targetAgent?[]:(de==null?void 0:de.skills)??[]),Zj=gt?Xj(gt):[];function vg(H){Cy(H);for(const G of H)G.status==="uploading"?he.current.add(G.id):G.uri&&Ph(n,G.uri).catch(fe=>Me(String(fe)))}function _g(){ee.current+=1;const H=Y;j(null),V(!1),H&&!H.id.startsWith("pending-")&&Ffe(H.id).catch(G=>{Me(G instanceof Error?G.message:String(G))})}async function kg(H){try{await Yb(n,ue,H),await Kb(n,ue,H),i(G=>G.filter(fe=>fe.id!==H)),U(G=>{const{[H]:fe,...Ne}=G;return Ne})}catch(G){Me(String(G))}}function Jj(H){const G=oe.find(De=>De.id===H);if(!G)return;const fe=oe.filter(De=>De.id!==H);Cy([G]),G.status==="uploading"&&he.current.add(H),X(fe),fe.length===0&&!I.trim()&&!!a&&P.length===0?(We.current="",o(""),kg(a)):G.uri&&Ph(n,G.uri).catch(De=>Me(String(De)))}const Jw=(H,G)=>{var Oe,Ue,Qe,Ae,yt;const fe=G.author&&G.author!=="user"?G.author:void 0;fe&&(on(Ke=>({...Ke,[H]:fe})),Fn(Ke=>({...Ke,[H]:new Set(Ke[H]??[]).add(fe)})),qn(Ke=>{var tt;return(tt=Ke[H])!=null&&tt.length?Ke:{...Ke,[H]:[fe]}}));const Ne=((Oe=G.actions)==null?void 0:Oe.transferToAgent)??((Ue=G.actions)==null?void 0:Ue.transfer_to_agent);Ne&&qn(Ke=>{const tt=Ke[H]??[];return tt[tt.length-1]===Ne?Ke:{...Ke,[H]:[...tt,Ne]}}),(((Qe=G.actions)==null?void 0:Qe.endOfAgent)??((Ae=G.actions)==null?void 0:Ae.end_of_agent)??((yt=G.actions)==null?void 0:yt.escalate))&&qn(Ke=>{const tt=Ke[H]??[];return tt.length<=1?Ke:{...Ke,[H]:tt.slice(0,-1)}})},[Tg,zt]=v.useState(L2),[e4,df]=v.useState([]),Sg=v.useCallback(H=>{df(G=>{const fe=G.findIndex(De=>De.id===H.id);if(fe===-1)return[H,...G];const Ne=[...G];return Ne[fe]={...Ne[fe],...H},Ne})},[]),t4=v.useCallback(async H=>{try{await gL(H.id),df(G=>G.map(fe=>fe.id===H.id?{...fe,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。"}:fe))}catch(G){const fe=G instanceof Error?G.message:String(G);df(Ne=>Ne.map(De=>De.id===H.id?{...De,message:`取消失败:${fe}`}:De))}},[]),[n4,r4]=v.useState(!0),[Ng,zs]=v.useState(!1),[s4,Dr]=v.useState(!1),[i4,hr]=v.useState(!1),[a4,di]=v.useState(null),[Ag,ms]=v.useState(!1),[o4,gs]=v.useState(!1),Cg=v.useRef(null),[Ig,Rg]=v.useState(()=>{const H=Ti();return vc(H),H}),[l4,ff]=v.useState(!1),Lg=v.useRef(!1),hf=v.useRef(!1);function pf(H){console.log("create agent draft:",H),zt(null),Lo()}function Og(H,G){console.log("Agent added, navigating to:",H,G),Rg(Ti()),zt(null),r(H)}const Cc=v.useRef(null),Ro=v.useRef(!0),Hi=v.useRef(!1),Ra=v.useRef(null),ev=v.useRef({key:"",turnCount:0}),Mg=(p==null?void 0:p.id)??a;v.useLayoutEffect(()=>{const H=Cc.current,G=ev.current,fe=G.key!==Mg,Ne=!fe&&P.length>G.turnCount;if(ev.current={key:Mg,turnCount:P.length},!H||P.length===0||!fe&&!Ne)return;Ro.current=!0,Hi.current=!1,Ra.current!==null&&(window.clearTimeout(Ra.current),Ra.current=null);const De=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(fe||De){H.scrollTop=H.scrollHeight;return}Hi.current=!0,H.scrollTo({top:H.scrollHeight,behavior:"smooth"}),Ra.current=window.setTimeout(()=>{Hi.current=!1,Ra.current=null},450)},[Mg,P.length]),v.useLayoutEffect(()=>{const H=Cc.current;!H||!Ro.current||Hi.current||(H.scrollTop=H.scrollHeight)},[Ce,P]),v.useEffect(()=>()=>{Ra.current!==null&&window.clearTimeout(Ra.current)},[]);const c4=v.useCallback(()=>{const H=Cc.current;!H||Hi.current||(Ro.current=H.scrollHeight-H.scrollTop-H.clientHeight<32)},[]),u4=v.useCallback(H=>{H.deltaY<0&&(Hi.current=!1,Ro.current=!1)},[]),d4=v.useCallback(()=>{Hi.current=!1,Ro.current=!1},[]),f4=v.useCallback(()=>{const H=Cc.current;!H||!Ro.current||Hi.current||(H.scrollTop=H.scrollHeight)},[]),Dg=v.useCallback(()=>{se(null),zb().then(H=>{Te(H.userId),$e(H.info),$t(!!H.local),Bt(H.status)}).catch(H=>{se(H instanceof Error?H.message:String(H))})},[]);v.useEffect(()=>{Dg()},[Dg]),v.useEffect(()=>{const H=()=>{dn(""),nn(!0)};return window.addEventListener(Vb,H),Z7()&&H(),()=>window.removeEventListener(Vb,H)},[]);const h4=v.useCallback(async()=>{if(rn.current)return;rn.current=!0;const H=K7();if(!H){rn.current=!1,dn("登录窗口被浏览器拦截,请允许弹出窗口后重试。");return}Ut(!0),dn("");try{for(;;){await new Promise(G=>window.setTimeout(G,1e3));try{const G=await zb();if(G.status==="authenticated"){Te(G.userId),$e(G.info),$t(!!G.local),Bt(G.status),nn(!1),J7(),H.close();return}}catch{}if(H.closed){dn("登录窗口已关闭,请重新登录以继续当前操作。");return}}}finally{rn.current=!1,Ut(!1)}},[]);v.useEffect(()=>{vn&&ue&&Yk(ue)},[vn,ue]),v.useEffect(()=>{if(Ge!=="authenticated"||!ue){z({});return}let H=!1;return Promise.allSettled([she(),ihe()]).then(([G,fe])=>{H||z({temporaryEnabled:G.status==="fulfilled"&&G.value.enabled,skillCreateEnabled:fe.status==="fulfilled"&&fe.value.enabled})}),()=>{H=!0}},[Ge,ue]),v.useEffect(()=>{if(Ge!=="authenticated"||!ue){lt(null);return}let H=!1;return lt(null),xL().then(G=>{H||lt(G)}).catch(G=>{console.warn("[app] /web/access failed; using ordinary-user access:",G),H||lt(EL)}),()=>{H=!0}},[Ge,ue]),v.useEffect(()=>{bL().then(H=>{Kn(H.features),Pn(H.agentsSource),jn(H.branding),vr(H.version),Bn(H.defaultView),nr(!0)})},[]),v.useEffect(()=>{!Ie||!Yn||hf.current||(hf.current=!0,An==="addAgent"&&Ie.capabilities.createAgents&&(zt(null),zs(!1),ms(!1),gs(!1),Dr(!1),hr(!0)))},[Ie,An,Yn]),v.useEffect(()=>{Ie&&(Ie.capabilities.createAgents||(zt(null),di(null),Dr(!1),hr(!1),df([])),Ie.capabilities.manageAgents||gs(!1))},[Ie]),v.useEffect(()=>{document.title=Mt.title;let H=document.querySelector('link[rel~="icon"]');H||(H=document.createElement("link"),H.rel="icon",document.head.appendChild(H)),H.removeAttribute("type"),H.href=Mt.logoUrl||ow},[Mt]),v.useEffect(()=>{fetch("/web/runtime-config",{signal:AbortSignal.timeout(1e4)}).then(H=>H.ok?H.json():null).then(H=>{H&&r4(!!H.credentials)}).catch(H=>{console.warn("[app] /web/runtime-config probe failed; workbench stays hidden:",H)})},[]);function p4(H){Yk(H),Lg.current=!0,hf.current=!1,lt(null),zt(null),di(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Lo(),Te(H),$e({name:H}),$t(!0),Bt("authenticated")}function m4(){hf.current=!1,lt(null),vn?(z7(),Te(""),$e(void 0),Bt("unauthenticated")):W7()}v.useEffect(()=>{Ge!=="unauthenticated"&&JR().then(H=>{if(t(H),sn==="cloud"){r("");return}const G=localStorage.getItem(Go.app),fe=Ig.flatMap(Oe=>Oe.apps.map(Ue=>mo(Oe.id,Ue))),Ne=G&&(H.includes(G)||fe.includes(G)),De=["web_search_agent","web_demo"].find(Oe=>H.includes(Oe))??H.find(Oe=>!/^\d/.test(Oe))??H[0];r(Ne?G:De||"")}).catch(H=>Me(String(H)))},[Ge,sn]),v.useEffect(()=>{n&&localStorage.setItem(Go.app,n)},[n]),v.useEffect(()=>{let H=!1;if(_e(null),je([]),!n||!ue||!a){we(!1);return}return we(!0),iL(n,ue,a).then(G=>{H||(_e(G),aL(n).then(fe=>{H||je(fe)}).catch(()=>{H||je([])}))}).catch(()=>{H||_e(null)}).finally(()=>{H||we(!1)}),()=>{H=!0}},[n,ue,a]),v.useEffect(()=>{let H=!1;if(ye(null),Z(bi()),!n){ge(!1);return}return ge(!0),Rx(n).then(G=>{H||ye(G)}).catch(()=>{H||ye(null)}).finally(()=>{H||ge(!1)}),()=>{H=!0}},[n]),v.useEffect(()=>{Ie&&localStorage.setItem(Go.view,Ie.capabilities.createAgents?Tg??"chat":"chat")},[Ie,Tg]),v.useEffect(()=>{localStorage.setItem(Go.session,a),We.current=a},[a]),v.useEffect(()=>()=>ce.current.forEach(H=>H.abort()),[]),v.useEffect(()=>()=>ke.current.forEach(H=>{window.clearTimeout(H)}),[]),v.useEffect(()=>()=>{var H,G;(H=S.current)==null||H.abort(),(G=C.current)==null||G.abort()},[]),v.useEffect(()=>{!n||!ue||(async()=>{const H=await mf(n);if(!Lg.current){Lg.current=!0;const G=localStorage.getItem(Go.session)||"";if(L2()===null&&G&&H.some(fe=>fe.id===G)){gf(G);return}}Lo()})()},[n,ue]),v.useEffect(()=>{const H=Cg.current;H&&H.app===n&&(Cg.current=null,gf(H.sid))},[n]);function g4(H,G){ms(!1),H===n?gf(G):(Cg.current={app:H,sid:G},r(H))}async function mf(H){try{const G=await Ax(H,ue),fe=await Promise.all(G.map(Ne=>{var De;return(De=Ne.events)!=null&&De.length?Promise.resolve(Ne):jp(H,ue,Ne.id)}));return i(fe),fe}catch(G){return Me(String(G)),[]}}function y4(){p||(Me(""),N(""),T("confirm"),_(!0))}function b4(){var H;(H=S.current)==null||H.abort(),S.current=null,_(!1),T("confirm"),N(""),!p&&O==="temporary"&&B("agent")}async function E4(){var G;(G=S.current)==null||G.abort();const H=new AbortController;S.current=H,T("loading"),N("");try{const fe=await Ny.startSession({signal:H.signal});if(S.current!==H)return;We.current="",o(""),h([]),L(""),Z(bi()),B("temporary"),_g(),V(!1),vg(oe),X([]),x([]),m(fe),zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),_(!1),T("confirm")}catch(fe){if((fe==null?void 0:fe.name)==="AbortError"||S.current!==H)return;N(fe instanceof Error?fe.message:String(fe)),T("error")}finally{S.current===H&&(S.current=null)}}function La(){var G;(G=C.current)==null||G.abort(),C.current=null,E(!1),x([]),L(""),Me(""),B("agent");const H=p;m(null),H&&Ny.closeSession(H.id).catch(fe=>Me(String(fe)))}async function x4(H){var De;const G=p;if(!G||y||!H.trim())return;Me("");const fe=new AbortController;(De=C.current)==null||De.abort(),C.current=fe;const Ne=[{role:"user",blocks:[{kind:"text",text:H}],meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}];x(Oe=>[...Oe,...Ne]),E(!0);try{const Oe=await Ny.sendMessage({sessionId:G.id,text:H},{signal:fe.signal,onBlocks:Ue=>{C.current===fe&&x(Qe=>{const Ae=Qe.slice(),yt=Ae[Ae.length-1];return(yt==null?void 0:yt.role)==="assistant"&&(Ae[Ae.length-1]={...yt,blocks:Ue}),Ae})}});if(C.current!==fe)return;x(Ue=>{const Qe=Ue.slice(),Ae=Qe[Qe.length-1];return(Ae==null?void 0:Ae.role)==="assistant"&&(Qe[Qe.length-1]={...Ae,blocks:Oe.blocks,meta:{ts:Date.now()/1e3}}),Qe})}catch(Oe){if((Oe==null?void 0:Oe.name)==="AbortError"||C.current!==fe)return;x(Ue=>Ue.slice(0,-2)),L(H),Me(`内置智能体发送失败:${Oe instanceof Error?Oe.message:String(Oe)}`)}finally{C.current===fe&&(C.current=null,E(!1))}}function Lo(){La(),Me(""),ot(!1),Le(P2()),B("agent"),_g(),V(!1);const H=a&&q.length===0&&oe.length>0?a:"";We.current="",o(""),_e(null),je([]),d(!1),h([]),Z(bi()),vg(oe),X([]),H&&kg(H)}async function w4(H){var G;try{(G=ce.current.get(H))==null||G.abort(),await Yb(n,ue,H),await Kb(n,ue,H);const fe=ke.current.get(H);fe!==void 0&&window.clearTimeout(fe),ke.current.delete(H),J(Ne=>{if(!Ne.has(H))return Ne;const De=new Set(Ne);return De.delete(H),De}),U(Ne=>{const{[H]:De,...Oe}=Ne;return Oe}),H===a&&Lo(),await mf(n)}catch(fe){Me(String(fe))}}async function gf(H){if(p&&La(),H!==a&&(We.current=H,Me(""),d(!1),h([]),B("agent"),_g(),Z(bi()),_e(null),je([]),o(H),M[H]===void 0)){Cn(!0);try{const G=await jp(n,ue,H);D(H,p$(G.events??[],G.state))}catch(G){Me(String(G))}finally{Cn(!1)}}}async function tv(H=!0){if(a)return a;c.current||(c.current=Pp(n,ue));const G=c.current;try{const fe=await G;H&&o(fe);const Ne=Date.now()/1e3,De={id:fe,lastUpdateTime:Ne,events:[]};return i(Oe=>[De,...Oe.filter(Ue=>Ue.id!==fe)]),fe}finally{c.current===G&&(c.current=null)}}async function nv(H){if(!n||!ue||!a||!be)return!1;ut(!0),Me("");try{const G=await uL(n,ue,a,H,be.revision);return _e(G),!0}catch(G){return Me(String(G)),!1}finally{ut(!1)}}async function rv(H){if(!(!n||!ue||!a||!be)){ut(!0),Me("");try{const G=await dL(n,ue,a,H,be.revision);_e(G)}catch(G){Me(String(G))}finally{ut(!1)}}}async function v4(H){Me("");let G;try{G=await tv()}catch(Ne){Me(String(Ne));return}const fe=Array.from(H).map(Ne=>({file:Ne,attachment:{id:zhe(),mimeType:Vhe(Ne),name:Ne.name,sizeBytes:Ne.size,status:"uploading"}}));X(Ne=>[...Ne,...fe.map(De=>De.attachment)]),await Promise.all(fe.map(async({file:Ne,attachment:De})=>{try{const Oe=await tL(n,ue,G,Ne);if(he.current.delete(De.id)){Oe.uri&&await Ph(n,Oe.uri);return}X(Ue=>Ue.map(Qe=>Qe.id===De.id?Oe:Qe))}catch(Oe){if(he.current.delete(De.id))return;const Ue=Oe instanceof Error?Oe.message:String(Oe);X(Qe=>Qe.map(Ae=>Ae.id===De.id?{...Ae,status:"error",error:Ue}:Ae)),Me(Ue)}}))}async function sv(H,G=[],fe=bi()){if(!H.trim()&&G.length===0||ps||ne||!n||!ue)return;Me("");const Ne=[];(fe.skills.length>0||fe.targetAgent)&&Ne.push({kind:"invocation",value:fe}),G.length&&Ne.push({kind:"attachment",files:G.map(Ae=>({id:Ae.id,mimeType:Ae.mimeType,data:Ae.data,uri:Ae.uri,name:Ae.name,sizeBytes:Ae.sizeBytes}))}),H.trim()&&Ne.push({kind:"text",text:H});const De=[{role:"user",blocks:Ne,meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}],Oe=!a;Oe&&(h(De),d(!0));let Ue;try{Ue=await tv(!Oe)}catch(Ae){Oe&&(h([]),d(!1),L(H),Z(fe)),Me(String(Ae));return}D(Ue,Ae=>Oe?De:[...Ae,...De]),Oe&&(We.current=Ue,o(Ue),h([]),d(!1));const Qe=new AbortController;ce.current.set(Ue,Qe),pe(Ue,!0),Xe(Ue),We.current=Ue,on(Ae=>({...Ae,[Ue]:""})),Fn(Ae=>({...Ae,[Ue]:new Set})),qn(Ae=>({...Ae,[Ue]:[]}));try{let Ae=Ns(),yt="",Ke=0,tt=Date.now()/1e3,Xt="",Pr="";for await(const ln of cd({appName:n,userId:ue,sessionId:Ue,text:H,attachments:G,invocation:fe,signal:Qe.signal,sessionCapabilities:be!==null})){if(Qe.signal.aborted)break;const fi=ln.error??ln.errorMessage??ln.error_message;if(typeof fi=="string"&&fi){We.current===Ue&&Me(fi);break}Jw(Ue,ln);const hi=ln.author&&ln.author!=="user"?ln.author:"";hi&&hi!==yt&&(yt=hi,Ae=Ns()),Ae=zl(Ae,ln);const Vs=ln.usageMetadata??ln.usage_metadata;Vs!=null&&Vs.totalTokenCount&&(Ke=Vs.totalTokenCount),ln.timestamp&&(tt=ln.timestamp),ln.id&&(Xt=ln.id);const Rn=ln.invocationId??ln.invocation_id;Rn&&(Pr=Rn);const Jr=Ae.blocks,Ks={author:yt||void 0,tokens:Ke||void 0,ts:tt,eventId:Xt||void 0,invocationId:Pr||void 0};D(Ue,pi=>{var mi;const Qn=pi.slice(),zi=Qn[Qn.length-1];return(zi==null?void 0:zi.role)==="assistant"&&(!((mi=zi.meta)!=null&&mi.author)||zi.meta.author===yt)?Qn[Qn.length-1]={...zi,blocks:Jr,meta:Ks}:Qn.push({role:"assistant",blocks:Jr,meta:Ks}),Qn})}mf(n)}catch(Ae){(Ae==null?void 0:Ae.name)!=="AbortError"&&!Qe.signal.aborted&&We.current===Ue&&Me(String(Ae))}finally{ce.current.get(Ue)===Qe&&ce.current.delete(Ue),pe(Ue,!1),St(Ue),on(Ae=>({...Ae,[Ue]:""})),qn(Ae=>({...Ae,[Ue]:[]}))}}function _4(H,G){var De,Oe;const fe=((De=H==null?void 0:H.event)==null?void 0:De.name)??G.id,Ne=((Oe=H==null?void 0:H.event)==null?void 0:Oe.context)??{};sv(`[ui-action] ${fe}: ${JSON.stringify(Ne)}`)}async function k4(H){var Ae,yt,Ke;if(!H.authUri)throw new Error("事件中没有授权地址。");if(!n||!ue||!a)throw new Error("会话尚未就绪。");const G=a,fe=await Fhe(H.authUri),Ne=Uhe(H.authConfig,fe),De=tt=>tt.map(Xt=>Xt.kind==="auth"&&!Xt.done?{...Xt,done:!0}:Xt);D(G,tt=>{const Xt=tt.slice(),Pr=Xt[Xt.length-1];return(Pr==null?void 0:Pr.role)==="assistant"&&(Xt[Xt.length-1]={...Pr,blocks:De(Pr.blocks)}),Xt});const Oe=P[P.length-1],Ue=De(Oe&&Oe.role==="assistant"?Oe.blocks:[]),Qe=new AbortController;ce.current.set(G,Qe),pe(G,!0),Xe(G);try{let tt=Ns(),Xt=((Ae=Oe==null?void 0:Oe.meta)==null?void 0:Ae.author)??"",Pr=Ue,ln=0,fi=Date.now()/1e3,hi=((yt=Oe==null?void 0:Oe.meta)==null?void 0:yt.eventId)??"",Vs=((Ke=Oe==null?void 0:Oe.meta)==null?void 0:Ke.invocationId)??"";for await(const Rn of cd({appName:n,userId:ue,sessionId:a,text:"",functionResponses:[{id:H.callId,name:"adk_request_credential",response:Ne}],signal:Qe.signal,sessionCapabilities:be!==null})){if(Qe.signal.aborted)break;Jw(G,Rn);const Jr=Rn.author&&Rn.author!=="user"?Rn.author:"";Jr&&Jr!==Xt&&(Xt=Jr,Pr=[],tt=Ns()),tt=zl(tt,Rn);const Ks=Rn.usageMetadata??Rn.usage_metadata;Ks!=null&&Ks.totalTokenCount&&(ln=Ks.totalTokenCount),Rn.timestamp&&(fi=Rn.timestamp),Rn.id&&(hi=Rn.id);const pi=Rn.invocationId??Rn.invocation_id;pi&&(Vs=pi);const Qn=[...Pr,...tt.blocks];D(G,zi=>{var cv,uv,dv,fv,hv;const mi=zi.slice(),Un=mi[mi.length-1],lv={author:Xt||((cv=Un==null?void 0:Un.meta)==null?void 0:cv.author),tokens:ln||((uv=Un==null?void 0:Un.meta)==null?void 0:uv.tokens),ts:fi,eventId:hi||((dv=Un==null?void 0:Un.meta)==null?void 0:dv.eventId),invocationId:Vs||((fv=Un==null?void 0:Un.meta)==null?void 0:fv.invocationId)};return(Un==null?void 0:Un.role)==="assistant"&&(!((hv=Un.meta)!=null&&hv.author)||Un.meta.author===Xt)?mi[mi.length-1]={...Un,blocks:Qn,meta:lv}:mi.push({role:"assistant",blocks:Qn,meta:lv}),mi})}mf(n)}catch(tt){(tt==null?void 0:tt.name)!=="AbortError"&&!Qe.signal.aborted&&We.current===G&&Me(String(tt))}finally{ce.current.get(G)===Qe&&ce.current.delete(G),pe(G,!1),St(G),on(tt=>({...tt,[G]:""})),qn(tt=>({...tt,[G]:[]}))}}if(fn)return l.jsxs("div",{className:"boot boot-error",children:[l.jsx("p",{children:fn}),l.jsx("button",{type:"button",onClick:Dg,children:"重试"})]});if(Ge===null)return l.jsx("div",{className:"boot"});if(Ge==="unauthenticated")return l.jsx(ghe,{branding:Mt,onUsername:p4});if(!Ie)return l.jsx("div",{className:"boot"});const Oo=Ie.capabilities.createAgents,iv=Ie.capabilities.manageAgents,ys=Oo?Tg:null,yf=Oo&&i4,bf=Oo&&s4,Pg=iv&&o4,T4=h3(e,Ig),jg=H=>{var G;return((G=T4.find(fe=>fe.id===H))==null?void 0:G.label)??H},Ic=Ig.find(H=>H.runtimeId&&H.apps.some(G=>mo(H.id,G)===n)),Mo=Ic&&Ic.runtimeId?{runtimeId:Ic.runtimeId,name:Ic.name,region:Ic.region??"cn-beijing"}:void 0,av=async(H,G)=>{var Ue,Qe;const fe=(Ue=H.meta)==null?void 0:Ue.eventId,Ne=a;if(!fe||!Ne||!Mo)return;const De=(Qe=H.meta)==null?void 0:Qe.feedback,Oe={...De,rating:G,syncStatus:"syncing",updatedAt:Date.now()/1e3};D(Ne,Ae=>Ae.map(yt=>{var Ke;return((Ke=yt.meta)==null?void 0:Ke.eventId)===fe?{...yt,meta:{...yt.meta,feedback:Oe}}:yt})),vt(Ae=>new Set(Ae).add(fe));try{const Ae=await eL({appName:n,userId:ue,sessionId:Ne,eventId:fe,rating:G});D(Ne,yt=>yt.map(Ke=>{var tt;return((tt=Ke.meta)==null?void 0:tt.eventId)===fe?{...Ke,meta:{...Ke.meta,feedback:Ae}}:Ke})),i(yt=>yt.map(Ke=>Ke.id===Ne?{...Ke,state:{...Ke.state??{},[`veadk_feedback:${fe}`]:Ae}}:Ke))}catch(Ae){D(Ne,yt=>yt.map(Ke=>{var tt;return((tt=Ke.meta)==null?void 0:tt.eventId)===fe?{...Ke,meta:{...Ke.meta,feedback:De}}:Ke})),We.current===Ne&&Me(Ae instanceof Error?Ae.message:String(Ae))}finally{vt(Ae=>{const yt=new Set(Ae);return yt.delete(fe),yt})}},ov=H=>{Rg(Ti()),We.current="",o(""),r(H)},S4=async H=>{const G=await lw(H.runtimeId,H.name,H.region);ov(G)};return l.jsxs("div",{className:"layout",children:[l.jsx(Tee,{branding:Mt,access:Ie,features:Nt,sessions:s,currentSessionId:a,streamingSids:Et,onNewChat:()=>{zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Lo()},onSearch:()=>{p&&La(),zt(null),zs(!1),Dr(!1),hr(!1),gs(!1),ms(!0),Me("")},onQuickCreate:()=>{if(!Oo){Me("当前账号没有添加 Agent 的权限。");return}p&&La(),We.current="",o(""),zs(!1),Dr(!1),ms(!1),gs(!1),zt(null),di(null),hr(!0),Me("")},onSkillCenter:()=>{p&&La(),zt(null),Dr(!1),hr(!1),ms(!1),gs(!1),zs(!0),Me("")},onAddAgent:()=>{if(!Oo){Me("当前账号没有添加 Agent 的权限。");return}p&&La(),We.current="",zt(null),zs(!1),ms(!1),gs(!1),o(""),hr(!1),Dr(!0),Me("")},onManageAgents:()=>{if(!iv){Me("当前账号没有管理 Agent 的权限。");return}p&&La(),We.current="",o(""),zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!0),Me("")},onPickSession:H=>{zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Me(""),gf(H)},onDeleteSession:w4,userInfo:qe,version:Qr,onLogout:m4}),(()=>{const H=l.jsxs("div",{className:`composer-slot${p?" sandbox-composer-wrap":""}`,children:[p&&l.jsx(lhe,{onExit:Lo}),l.jsx(Jte,{sessionId:p?p.id:a,sessionInitializing:!p&&u,appName:n,agentName:p?"AgentKit 沙箱":n?jg(n):"Agent",value:I,onChange:L,onSubmit:()=>{if(!p&&O==="skill-create"){const De=I.trim();if(!De||re)return;const Oe={id:`pending-${Date.now()}`,prompt:De,status:"provisioning",candidates:pw.map((Qe,Ae)=>({id:`pending-${Ae}`,model:Qe,modelLabel:Qe,status:"queued",stage:"provisioning",files:[],activities:[{id:"provisioning",kind:"status",text:"正在拉起 Sandbox",status:"running"}]}))};V(!0);const Ue=++ee.current;Me(""),j(Oe),L(""),jfe(De,Qe=>{ee.current===Ue&&j(Qe)}).then(Qe=>{ee.current===Ue&&j(Qe)}).catch(Qe=>{ee.current===Ue&&(j(null),L(De),Me(Qe instanceof Error?Qe.message:String(Qe)))}).finally(()=>{ee.current===Ue&&V(!1)});return}const G=I;if(L(""),p){x4(G);return}const fe=oe,Ne=ae;X([]),Z(bi()),sv(G,fe,Ne),Cy(fe)},disabled:p?!1:!ue||O==="temporary"||O==="agent"&&!n,busy:p?y:O==="skill-create"?re:ps,showMeta:P.length>0&&!p,attachments:p?[]:oe,skills:p?[]:fr,agents:p?[]:Zj,invocation:p?bi():ae,capabilitiesLoading:!p&&Q,allowAttachments:!p,onInvocationChange:Z,onAddFiles:v4,onRemoveAttachment:Jj,newChatMode:p?"agent":O,newChatLayout:!p&&P.length===0&&Y===null,showModeSelector:!p&&P.length===0&&Y===null,temporaryEnabled:R.temporaryEnabled,skillCreateEnabled:R.skillCreateEnabled,onModeChange:G=>{if(!(G==="temporary"&&!R.temporaryEnabled||G==="skill-create"&&!R.skillCreateEnabled)){if(G==="temporary"){B(G),y4();return}if(B(G),Me(""),G==="skill-create"){Z(bi());const fe=a&&q.length===0&&oe.length>0?a:"";vg(oe),X([]),fe&&(We.current="",o(""),kg(fe))}}}})]});return l.jsxs("section",{className:"main-shell",children:[l.jsx(Uee,{appName:n,onAppChange:ov,agentLabel:jg,agentsSource:sn,localApps:e,currentRuntime:Mo,runtimeScope:Ie.capabilities.runtimeScope,title:yf?"添加 Agent":bf?"添加 AgentKit 智能体":Pg?"管理 Agent":void 0,titleLeading:P.length>0&&!p&&O==="agent"&&!yf&&!bf&&!Ng&&!Ag&&!Pg&&ys===null&&n?l.jsx("button",{ref:_t,type:"button",className:"agent-info-trigger","aria-label":"查看 Agent 信息",title:"Agent 信息","aria-expanded":Ve,onClick:()=>ot(!0),children:l.jsx(ql,{})}):void 0,crumbs:Ng?[{label:"技能中心"},{label:"AgentKit Skill 空间"}]:Ag||bf||yf||!ys?void 0:ys==="menu"?[{label:Che,onClick:()=>{zt(null),di(null),hr(!0)}},{label:"从 0 快速创建"}]:[{label:"从 0 快速创建",onClick:()=>ff(!0)},{label:Ihe[ys]}],rightContent:l.jsxs(l.Fragment,{children:[Ie.role==="admin"&&l.jsx(Cfe,{}),l.jsx(Hhe,{tasks:Oo?e4:[],onCancel:t4})]})}),l.jsxs("main",{className:`main${p?" is-sandbox-session":""}`,children:[Sn&&l.jsx("div",{className:"error",children:Sn}),an&&l.jsxs("div",{className:"session-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载会话…"]}),Pg?l.jsx(ate,{currentRuntimeId:Mo==null?void 0:Mo.runtimeId,onConnect:S4}):yf?l.jsx(j3,{title:"您想以哪种方式添加 Agent 来运行?",sub:"选择最适合你的方式,下一步即可开始",cards:[{key:"scratch",icon:Ohe,title:"从 0 快速创建",desc:"用智能 / 自定义 / 模板 / 工作流的方式从零创建一个 Agent。",onClick:()=>{hr(!1),di(null),zt("menu")}},{key:"package",icon:o7,title:"从代码包添加和部署",desc:"上传 Agent 项目压缩包,查看代码并直接部署到 AgentKit Runtime。",onClick:()=>{hr(!1),di(null),zt("package")}}]}):Ag?l.jsx(yee,{userId:ue,appId:n,agentInfo:de,capabilitiesLoading:Q,agentLabel:jg,onOpenSession:g4}):bf?l.jsx(ite,{onAdded:G=>{Rg(Ti()),Dr(!1),r(G)},onCancel:()=>Dr(!1)}):Ng?l.jsx(iee,{}):ys!==null&&!n4?l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",padding:24,textAlign:"center",color:"var(--text-secondary, #6b7280)"},children:[l.jsx("div",{style:{fontSize:18,fontWeight:600},children:"需要配置火山引擎 AK/SK"}),l.jsxs("div",{style:{maxWidth:420,lineHeight:1.6},children:["智能体工作台需要 Volcengine 凭据才能使用。请在运行环境中设置"," ",l.jsx("code",{children:"VOLCENGINE_ACCESS_KEY"})," 与"," ",l.jsx("code",{children:"VOLCENGINE_SECRET_KEY"})," 后重试。"]})]}):ys==="menu"?l.jsx(_re,{onSelect:G=>{di(null),zt(G)},onImport:G=>{di(G),zt("custom")}}):ys==="intelligent"?l.jsx(Gre,{userId:ue,onBack:()=>zt("menu"),onCreate:pf,onAgentAdded:Og,onDeploymentTaskChange:Sg}):ys==="custom"?l.jsx(jse,{initialDraft:a4??void 0,onBack:()=>zt("menu"),onCreate:pf,onAgentAdded:Og,features:Nt,onDeploymentTaskChange:Sg}):ys==="template"?l.jsx(Use,{onBack:()=>zt("menu"),onCreate:pf}):ys==="workflow"?l.jsx(pfe,{onBack:()=>zt("menu"),onCreate:pf}):ys==="package"?l.jsx(Efe,{onBack:()=>{zt(null),hr(!0)},onAgentAdded:Og,onDeploymentTaskChange:Sg}):P.length===0&&Y?l.jsx(Zfe,{initialJob:Y}):P.length===0?l.jsxs("div",{className:"welcome",children:[l.jsx(ji,{as:"h1",className:"welcome-title",duration:4.8,spread:22,children:p?"让灵感在临时空间里自由生长":O==="skill-create"?"想创建一个什么 Skill?":le}),H]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`transcript${He?" is-streaming":""}`,ref:Cc,onScroll:c4,onWheel:u4,onTouchMove:d4,children:P.map((G,fe)=>{var ln,fi,hi,Vs,Rn;const Ne=fe===P.length-1;if(G.role==="user"){const Jr=G.blocks.map(Qn=>Qn.kind==="text"?Qn.text:"").join(""),Ks=G.blocks.flatMap(Qn=>Qn.kind==="attachment"?Qn.files:[]),pi=G.blocks.find(Qn=>Qn.kind==="invocation");return l.jsxs(Rt.div,{className:"turn turn--user",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[(pi==null?void 0:pi.kind)==="invocation"&&l.jsx(uw,{value:pi.value}),Ks.length>0&&l.jsx(fw,{appName:n,items:Ks}),Jr&&l.jsx("div",{className:"bubble",children:l.jsx(Gd,{text:Jr})}),l.jsxs("div",{className:"turn-actions turn-actions--right",children:[((ln=G.meta)==null?void 0:ln.ts)&&l.jsx("span",{className:"meta-text",children:Qj(G.meta.ts)}),l.jsx(M2,{text:Jr})]})]},fe)}const De=((fi=G.meta)==null?void 0:fi.author)??"",Oe=De&>?V1(gt,De):void 0,Ue=!!(De&&Gn.length>0&&!Gn.includes(De)),Qe=(Oe==null?void 0:Oe.name)||De,Ae=(Oe==null?void 0:Oe.description)||(Ue?"正在执行主 Agent 移交的任务。":"");if(G.blocks.length>0&&G.blocks.every(Jr=>Jr.kind==="agent-transfer"))return null;const yt=G.blocks.length===0,Ke=((Vs=(hi=G.meta)==null?void 0:hi.feedback)==null?void 0:Vs.rating)??null,tt=((Rn=G.meta)==null?void 0:Rn.eventId)??"",Xt=wt.has(tt),Pr=!!(Mo&&tt&&O2(G));return l.jsxs(Rt.div,{className:`turn turn--assistant${Ue?" turn--subagent":""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[Ue&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"subagent-run-label",children:[l.jsxs("span",{className:"subagent-run-handoff",children:[l.jsx(r7,{}),l.jsx("span",{children:"智能体移交"})]}),l.jsx("span",{className:"subagent-run-title",children:Qe})]}),l.jsx("p",{className:"subagent-run-description",title:Ae,children:Ae})]}),yt?Ne&&Ce?l.jsx(D3,{}):null:l.jsxs(l.Fragment,{children:[l.jsx(hw,{appName:n,blocks:G.blocks,streaming:Ne&&(Ce||Hs),onStreamFrame:Ne?f4:void 0,onAction:_4,onAuth:k4}),!(Ne&&Ce)&&!jhe(G)&&l.jsx("div",{className:"turn-empty",children:"本次没有返回可显示的内容。"}),!(Ne&&Ce)&&!Bhe(G)&&l.jsxs("div",{className:"turn-meta",children:[l.jsxs("div",{className:"turn-actions",children:[Pr&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:`icon-btn feedback-btn${Ke==="good"?" feedback-btn--good":""}`,"aria-label":"赞","aria-pressed":Ke==="good","aria-busy":Xt,title:Ke==="good"?"取消点赞":"赞",disabled:Xt,onClick:()=>void av(G,Ke==="good"?null:"good"),children:l.jsx(che,{className:"icon",filled:Ke==="good"})}),l.jsx("button",{type:"button",className:`icon-btn feedback-btn${Ke==="bad"?" feedback-btn--bad":""}`,"aria-label":"踩","aria-pressed":Ke==="bad","aria-busy":Xt,title:Ke==="bad"?"取消点踩":"踩",disabled:Xt,onClick:()=>void av(G,Ke==="bad"?null:"bad"),children:l.jsx(uhe,{className:"icon",filled:Ke==="bad"})})]}),!p&&l.jsx("button",{className:"icon-btn",title:"Tracing 火焰图",onClick:()=>Gt(!0),children:l.jsx(Mhe,{})}),l.jsx(M2,{text:O2(G)})]}),G.meta&&l.jsx("span",{className:"meta-text",children:Dhe(G.meta)})]})]})]},fe)})}),!p&&l.jsx(_3,{appName:n,info:de,loading:Q,activeAgent:ct,seenAgents:Ht,execPath:hn,capabilities:be,capabilityLoading:Pe,capabilityMutating:Fe,builtinTools:ht,onAddCapability:nv,onRemoveCapability:G=>void rv(G)}),l.jsx("div",{className:"conversation-composer-slot",children:H})]})]})]})})(),Ct&&a&&l.jsx(phe,{appName:n,sessionId:a,onClose:()=>Gt(!1)}),Ve&&P.length>0&&l.jsx(ste,{appName:n,info:de,loading:Q,activeAgent:ct,seenAgents:Ht,execPath:hn,capabilities:be,capabilityLoading:Pe,capabilityMutating:Fe,builtinTools:ht,onAddCapability:nv,onRemoveCapability:H=>void rv(H),onClose:kt,returnFocusRef:_t}),l.jsx(ohe,{open:b,state:k,error:A,onCancel:b4,onConfirm:()=>void E4()}),l.jsx(yhe,{open:Nn,checking:Ft,error:wn,onLogin:()=>void h4()}),l4&&l.jsx("div",{className:"confirm-scrim",onClick:()=>ff(!1),children:l.jsxs("div",{className:"confirm-box",onClick:H=>H.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",children:"返回创建首页?"}),l.jsx("div",{className:"confirm-text",children:"返回后当前填写的内容将会丢失,确定要返回吗?"}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{className:"confirm-btn",onClick:()=>ff(!1),children:"取消"}),l.jsx("button",{className:"confirm-btn confirm-btn--danger",onClick:()=>{di(null),zt("menu"),ff(!1)},children:"确定返回"})]})]})})]})}(()=>{if(!(window.opener&&window.opener!==window&&/[?&](code|state|error)=/.test(window.location.search)))return!1;try{window.opener.postMessage({veadkOAuth:!0,url:window.location.href},window.location.origin)}catch{}return window.close(),!0})()||Iy.createRoot(document.getElementById("root")).render(l.jsx(et.StrictMode,{children:l.jsx(dB,{reducedMotion:"user",children:l.jsx(VU,{maskOpacity:.9,children:l.jsx(Khe,{})})})}));export{v as A,Km as B,Vr as C,Xhe as D,Su as E,po as F,yO as G,Whe as R,ur as V,et as a,Vl as b,$T as c,Qhe as d,Fx as e,CV as f,hd as g,dt as h,YY as i,JY as j,RV as k,Cd as l,JW as m,MY as n,DY as o,oq as p,NW as q,AW as r,AO as s,l as t,ze as u,At as v,it as w,Ghe as x,VY as y,ai as z}; +`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function phe({appName:e,sessionId:t,onClose:n}){const[r,s]=v.useState(null),[i,a]=v.useState(""),[o,c]=v.useState(new Set),[u,d]=v.useState(null);v.useEffect(()=>{s(null),a(""),sL(e,t).then(E=>{s(E),d(E.length?E.reduce((b,_)=>b.start_time<=_.start_time?b:_).span_id:null)}).catch(E=>a(String(E)))},[e,t]);const{rootNodes:f,min:h,total:p}=v.useMemo(()=>dhe(r??[]),[r]),m=v.useMemo(()=>fhe(f,o),[f,o]),g=(r==null?void 0:r.find(E=>E.span_id===u))??null,x=p/1e6,y=E=>c(b=>{const _=new Set(b);return _.has(E)?_.delete(E):_.add(E),_});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"drawer-scrim",onClick:n}),l.jsxs("aside",{className:"drawer drawer--trace",children:[l.jsxs("header",{className:"drawer-head",children:[l.jsxs("div",{children:[l.jsx("div",{className:"drawer-title",children:"调用链路观测"}),l.jsx("div",{className:"drawer-sub",children:r?`${r.length} 个调用 · ${x.toFixed(1)} ms`:"加载中"})]}),l.jsx("button",{className:"drawer-close",onClick:n,"aria-label":"关闭",children:l.jsx(Wr,{className:"icon"})})]}),r==null&&!i&&l.jsxs("div",{className:"drawer-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载调用链路…"]}),i&&l.jsx("div",{className:"error",children:i}),r&&r.length===0&&l.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),m.length>0&&l.jsxs("div",{className:"trace-split",children:[l.jsx("div",{className:"trace-tree scroll",children:m.map(E=>{const b=E.span,_=(b.start_time-h)/p*100,k=Math.max((b.end_time-b.start_time)/p*100,.6),T=E.children.length>0;return l.jsxs("button",{className:`trace-row ${u===b.span_id?"active":""}`,onClick:()=>d(b.span_id),children:[l.jsxs("span",{className:"trace-label",style:{paddingLeft:E.depth*14},children:[l.jsx("span",{className:`trace-caret ${T?"":"hidden"} ${o.has(b.span_id)?"":"open"}`,onClick:A=>{A.stopPropagation(),T&&y(b.span_id)},children:l.jsx(Nr,{className:"chev"})}),l.jsx("span",{className:"trace-dot",style:{background:Ay(b.name)}}),l.jsx("span",{className:"trace-name",title:b.name,children:b.name})]}),l.jsx("span",{className:"trace-dur",children:I2(b.end_time-b.start_time)}),l.jsx("span",{className:"trace-track",children:l.jsx("span",{className:"trace-bar",style:{left:`${_}%`,width:`${k}%`,background:Ay(b.name)}})})]},b.span_id)})}),l.jsx("div",{className:"trace-detail scroll",children:g?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"td-title",children:g.name}),l.jsxs("div",{className:"td-dur",children:[l.jsx("span",{className:"td-dot",style:{background:Ay(g.name)}}),I2(g.end_time-g.start_time)]}),l.jsx("div",{className:"td-section",children:"属性"}),l.jsx("div",{className:"td-props",children:R2(g).filter(E=>!E.long).map(E=>l.jsxs("div",{className:"td-prop",children:[l.jsx("span",{className:"td-key",children:E.key}),l.jsx("span",{className:"td-val",children:E.value})]},E.key))}),R2(g).filter(E=>E.long).map(E=>l.jsxs("div",{className:"td-block",children:[l.jsx("div",{className:"td-section",children:E.key}),l.jsx("pre",{className:"td-pre",children:E.value})]},E.key))]}):l.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}function mhe(e){return e.toLowerCase()==="github"?l.jsx(p7,{className:"icon"}):l.jsx(v7,{className:"icon"})}function ghe({branding:e,onUsername:t}){const[n,r]=v.useState(null),[s,i]=v.useState(""),[a,o]=v.useState(0),[c,u]=v.useState("");v.useEffect(()=>{let h=!0;return r(null),i(""),YR().then(p=>{h&&r(p)}).catch(p=>{h&&i(p instanceof Error?p.message:String(p))}),()=>{h=!1}},[a]);const d=H7.test(c),f=()=>{d&&t(c)};return l.jsxs("div",{className:"login",children:[l.jsx("header",{className:"login-top",children:l.jsxs("span",{className:"login-brand",children:[l.jsx("img",{className:"login-brand-logo",src:e.logoUrl||ow,width:20,height:20,alt:"","aria-hidden":!0}),e.title]})}),l.jsx("main",{className:"login-main",children:l.jsxs("div",{className:"login-card",children:[l.jsx(ji,{as:"h1",className:"login-title",duration:4.8,spread:22,children:e.title}),s?l.jsxs("div",{className:"login-provider-error",role:"alert",children:[l.jsx("p",{children:s}),l.jsx("button",{type:"button",onClick:()=>o(h=>h+1),children:"重试"})]}):n===null?null:n.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"登录以继续使用"}),l.jsx("div",{className:"login-providers",children:n.map(h=>l.jsxs("button",{className:"login-btn",onClick:()=>V7(h.loginUrl),children:[mhe(h.id),l.jsxs("span",{children:["使用 ",h.label," 登录"]})]},h.id))})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"login-sub",children:"输入一个用户名即可开始"}),l.jsxs("form",{className:"login-name",onSubmit:h=>{h.preventDefault(),f()},children:[l.jsx("input",{className:"login-name-input",value:c,onChange:h=>u(h.target.value),placeholder:"用户名(字母 + 数字,最多 16 位)",maxLength:16,autoFocus:!0}),l.jsx("button",{type:"submit",className:"login-name-go",disabled:!d,"aria-label":"进入",children:l.jsx(IR,{className:"icon"})})]}),l.jsx("p",{className:"login-hint","aria-live":"polite",children:c&&!d?"只能包含大小写字母和数字,最多 16 位。":""})]}),l.jsx("p",{className:"login-powered",children:"火山引擎 AgentKit 提供企业级 Agent 解决方案"}),l.jsxs("p",{className:"login-legal",children:["继续即表示你已阅读并同意 AgentKit"," ",l.jsx("a",{href:"https://docs.volcengine.com/docs/86681/1925174?lang=zh",target:"_blank",rel:"noreferrer",children:"产品和服务条款"})]})]})}),l.jsx("footer",{className:"login-footer",children:"© 2026 VeADK. All rights reserved."})]})}function yhe({open:e,checking:t,error:n,onLogin:r}){const s=v.useRef(null);return v.useEffect(()=>{var a;if(!e)return;const i=document.body.style.overflow;return document.body.style.overflow="hidden",(a=s.current)==null||a.focus(),()=>{document.body.style.overflow=i}},[e]),e?ai.createPortal(l.jsx("div",{className:"auth-expired-backdrop",children:l.jsxs("section",{className:"auth-expired-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"auth-expired-title","aria-describedby":"auth-expired-description",children:[l.jsx("div",{className:"auth-expired-mark","aria-hidden":"true",children:l.jsx(yx,{})}),l.jsxs("div",{className:"auth-expired-copy",children:[l.jsx("h2",{id:"auth-expired-title",children:"登录状态已过期"}),l.jsx("p",{id:"auth-expired-description",children:"当前编辑内容会保留。重新登录后,刚才的操作将自动继续。"}),n&&l.jsx("p",{className:"auth-expired-error",role:"alert",children:n})]}),l.jsx("footer",{className:"auth-expired-actions",children:l.jsx("button",{ref:s,type:"button",onClick:r,disabled:t,children:t?"等待登录完成…":"重新登录"})})]})}),document.body):null}function bhe({node:e,ctx:t}){const n=e.variant??"default";return l.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)})}Co("Button",bhe);function Ehe({node:e,ctx:t}){return l.jsx("div",{className:"a2ui-card","data-a2ui-id":e.id,"data-a2ui-component":e.component,children:t.render(e.child)})}Co("Card",Ehe);const xhe={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly",stretch:"stretch"},whe={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};function qj(e){return xhe[e]??"flex-start"}function Gj(e){return whe[e]??"stretch"}function vhe({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-column","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"column",justifyContent:qj(e.justify),alignItems:Gj(e.align)},children:n.map(r=>t.render(r))})}Co("Column",vhe);function _he({node:e}){const t=e.axis==="vertical";return l.jsx("div",{className:`a2ui-divider ${t?"a2ui-divider--v":"a2ui-divider--h"}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component})}Co("Divider",_he);const khe={send:"✈️",check:"✅",close:"✖️",star:"⭐",favorite:"❤️",info:"ℹ️",help:"❓",error:"⛔",calendarToday:"📅",event:"📅",schedule:"🕒",locationOn:"📍",accountCircle:"👤",mail:"✉️",call:"📞",home:"🏠",settings:"⚙️",search:"🔍"};function The({node:e}){const t=e.name??"";return l.jsx("span",{className:"a2ui-icon",title:t,"aria-label":t,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:khe[t]??"•"})}Co("Icon",The);function She({node:e,ctx:t}){const n=e.children??[];return l.jsx("div",{className:"a2ui-row","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"row",justifyContent:qj(e.justify),alignItems:Gj(e.align??"center")},children:n.map(r=>t.render(r))})}Co("Row",She);const Nhe=new Set(["h1","h2","h3","h4","h5"]);function Ahe({node:e,ctx:t}){const n=e.variant??"body",r=t.resolveString(e.text),s=Nhe.has(n)?n:"p";return l.jsx(s,{className:`a2ui-text a2ui-text--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:r})}Co("Text",Ahe);const Che="创建 Agent",Ihe={intelligent:"智能模式",custom:"自定义",template:"从模板新建",workflow:"工作流",package:"代码包部署"},Go={app:"veadk.appName",view:"veadk.view",session:"veadk.sessionId"},Rhe=new Set,Lhe=[];function bi(){return{skills:[]}}function V1(e,t){if(e.name===t||e.id===t)return e;for(const n of e.children){const r=V1(n,t);if(r)return r}}function Xj(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(...Xj(n)));return t}function L2(){const e=typeof localStorage<"u"?localStorage.getItem(Go.view):null;return e==="menu"||e==="intelligent"||e==="custom"||e==="template"||e==="workflow"?e:null}function Ohe({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[l.jsx("ellipse",{cx:"12",cy:"12",rx:"6.6",ry:"8.2"}),l.jsx("path",{d:"M12 8.2l1.05 2.75 2.75 1.05-2.75 1.05L12 15.8l-1.05-2.75L8.2 12l2.75-1.05z",fill:"currentColor",stroke:"none"})]})}function Mhe(){return l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[l.jsx("rect",{x:"3",y:"4",width:"14",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("rect",{x:"6",y:"10.4",width:"13",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.7"}),l.jsx("rect",{x:"9",y:"16.8",width:"9",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.45"})]})}function Qj(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 Dhe(e){if(!e)return"";const t=[];return e.ts&&t.push(Qj(e.ts)),e.tokens!=null&&t.push(`${e.tokens.toLocaleString()} tokens`),t.join(" · ")}function O2(e){return e.blocks.map(t=>t.kind==="text"?t.text:"").join("").trim()}const Phe="send_a2ui_json_to_client";function jhe(e){return e.blocks.some(t=>t.kind==="text"?t.text.trim().length>0:t.kind==="attachment"?t.files.length>0:t.kind==="tool"?!(t.name===Phe&&t.done):t.kind==="agent-transfer"?!1:t.kind==="a2ui"?N3(t.messages).some(n=>n.components[n.rootId]):t.kind==="auth")}function Bhe(e){return e.blocks.some(t=>t.kind==="auth"&&!t.done)}function Fhe(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 s=window.open(e,"veadk_oauth","width=520,height=720");if(!s){n(new Error("弹窗被拦截,请允许弹窗后重试。"));return}let i=!1;const a=()=>{clearInterval(u),window.removeEventListener("message",c)},o=d=>{if(!i){i=!0,a();try{s.close()}catch{}t(d)}},c=d=>{if(d.origin!==window.location.origin)return;const f=d.data;f&&f.veadkOAuth&&typeof f.url=="string"&&o(f.url)};window.addEventListener("message",c);const u=setInterval(()=>{if(!i){if(s.closed){a();const d=window.prompt("授权完成后,请粘贴回调页面(浏览器地址栏)的完整 URL:");d&&d.trim()?(i=!0,t(d.trim())):n(new Error("授权已取消。"));return}try{const d=s.location.href;d&&d!=="about:blank"&&new URL(d).origin===window.location.origin&&/[?&](code|state|error)=/.test(d)&&o(d)}catch{}}},500)})}function Uhe(e,t){const n=JSON.parse(JSON.stringify(e??{})),r=n.exchangedAuthCredential??n.exchanged_auth_credential??{},s=r.oauth2??{};return s.authResponseUri=t,s.auth_response_uri=t,r.oauth2=s,n.exchangedAuthCredential=r,n}function M2({text:e}){const[t,n]=v.useState(!1);return l.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?l.jsx(Bs,{className:"icon"}):l.jsx(Ex,{className:"icon"})})}function $he(e){return e==="cn-beijing"?"华北 2(北京)":e==="cn-shanghai"?"华东 2(上海)":e||"未指定"}function Hhe({tasks:e,onCancel:t}){const[n,r]=v.useState(!1),[s,i]=v.useState(null),a=e.filter(f=>f.status==="running").length,o=e[0],c=a>0?"running":(o==null?void 0:o.status)??"idle",u=a>0?`${a} 个部署任务进行中`:(o==null?void 0:o.status)==="success"?"最近部署已完成":(o==null?void 0:o.status)==="error"?"最近部署失败":(o==null?void 0:o.status)==="cancelled"?"最近部署已取消":"部署任务",d=f=>{i(f.id),t(f).finally(()=>i(null))};return l.jsxs("div",{className:"global-deploy-center",children:[l.jsxs("button",{type:"button",className:`global-deploy-task is-${c}`,"aria-expanded":n,"aria-haspopup":"dialog",onClick:()=>r(f=>!f),children:[c==="running"?l.jsx(bt,{className:"global-deploy-task-icon spin"}):c==="success"?l.jsx(e7,{className:"global-deploy-task-icon"}):c==="error"?l.jsx(yx,{className:"global-deploy-task-icon"}):c==="cancelled"?l.jsx(t7,{className:"global-deploy-task-icon"}):l.jsx(w7,{className:"global-deploy-task-icon"}),l.jsx("span",{className:"global-deploy-task-detail",children:u}),l.jsx(od,{className:`global-deploy-task-chevron${n?" is-open":""}`})]}),n&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"global-deploy-task-scrim","aria-label":"关闭部署任务",onClick:()=>r(!1)}),l.jsxs("section",{className:"global-deploy-popover",role:"dialog","aria-label":"部署任务",children:[l.jsxs("header",{className:"global-deploy-popover-head",children:[l.jsx("span",{children:"部署任务"}),l.jsx("span",{children:e.length})]}),l.jsx("div",{className:"global-deploy-list",children:e.length===0?l.jsx("div",{className:"global-deploy-empty",children:"暂无部署任务"}):e.map(f=>{const h=`${f.label}${f.status==="running"&&typeof f.pct=="number"?` ${Math.round(f.pct)}%`:""}`;return l.jsxs("article",{className:`global-deploy-item is-${f.status}`,children:[l.jsxs("div",{className:"global-deploy-item-head",children:[l.jsx("span",{className:"global-deploy-runtime-name",children:f.runtimeName}),l.jsx("span",{className:"global-deploy-status",children:h})]}),l.jsxs("dl",{className:"global-deploy-meta",children:[l.jsxs("div",{children:[l.jsx("dt",{children:"Runtime 名称"}),l.jsx("dd",{children:f.runtimeName})]}),l.jsxs("div",{children:[l.jsx("dt",{children:"部署地域"}),l.jsx("dd",{children:$he(f.region)})]}),f.runtimeId&&l.jsxs("div",{children:[l.jsx("dt",{children:"Runtime ID"}),l.jsx("dd",{children:f.runtimeId})]})]}),f.message&&f.status==="error"?l.jsx(nm,{className:"global-deploy-error",message:f.message,onRetry:f.retry}):f.message?l.jsx("p",{className:"global-deploy-message",children:f.message}):null,f.status==="running"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"global-deploy-progress","aria-hidden":!0,children:l.jsx("span",{style:{width:`${Math.max(6,Math.min(100,f.pct??6))}%`}})}),l.jsx("div",{className:"global-deploy-item-actions",children:l.jsx("button",{type:"button",disabled:s===f.id,onClick:()=>d(f),children:s===f.id?"取消中…":"取消部署"})})]})]},f.id)})})]})]})]})}const D2=["今天想做点什么?","有什么可以帮你的?","需要我帮你查点什么吗?","有问题尽管问我","嗨,我们开始吧","开始一段新对话吧","今天想先解决哪件事?","把你的想法告诉我吧","我们从哪里开始?","有什么任务交给我?","准备好一起推进了吗?","说说你现在最关心的问题","今天也一起把事情做好","我在,随时可以开始"],P2=()=>D2[Math.floor(Math.random()*D2.length)];function Cy(e){var t;for(const n of e)(t=n.previewUrl)!=null&&t.startsWith("blob:")&&URL.revokeObjectURL(n.previewUrl)}function zhe(){return`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Vhe(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"}function Khe(){const[e,t]=v.useState([]),[n,r]=v.useState(""),[s,i]=v.useState([]),[a,o]=v.useState(""),c=v.useRef(null),[u,d]=v.useState(!1),[f,h]=v.useState([]),[p,m]=v.useState(null),[g,x]=v.useState([]),[y,E]=v.useState(!1),[b,_]=v.useState(!1),[k,T]=v.useState("confirm"),[A,N]=v.useState(""),S=v.useRef(null),C=v.useRef(null),[M,U]=v.useState({}),q=a?M[a]??[]:f,P=p?g:q,D=(H,G)=>U(fe=>({...fe,[H]:typeof G=="function"?G(fe[H]??[]):G})),[I,L]=v.useState(""),[O,B]=v.useState("agent"),[R,z]=v.useState({}),[Y,j]=v.useState(null),[re,V]=v.useState(!1),ee=v.useRef(0),[oe,X]=v.useState([]),[ae,Z]=v.useState(bi),[de,ye]=v.useState(null),[Q,ge]=v.useState(!1),[be,_e]=v.useState(null),[Pe,we]=v.useState(!1),[ht,je]=v.useState([]),[Fe,ut]=v.useState(!1),he=v.useRef(new Set),[Et,mt]=v.useState(()=>new Set),[W,J]=v.useState(()=>new Set),ce=v.useRef(new Map),ke=v.useRef(new Map),pe=(H,G)=>mt(fe=>{const Ne=new Set(fe);return G?Ne.add(H):Ne.delete(H),Ne}),Xe=H=>{const G=ke.current.get(H);G!==void 0&&window.clearTimeout(G),ke.current.delete(H),J(fe=>new Set(fe).add(H))},St=H=>{const G=ke.current.get(H);G!==void 0&&window.clearTimeout(G);const fe=window.setTimeout(()=>{ke.current.delete(H),J(Ne=>{const De=new Set(Ne);return De.delete(H),De})},2400);ke.current.set(H,fe)},We=v.useRef(""),[Sn,Me]=v.useState(""),[wt,vt]=v.useState(()=>new Set),[Ct,Gt]=v.useState(!1),[Ve,ot]=v.useState(!1),_t=v.useRef(null),kt=v.useCallback(()=>ot(!1),[]),[le,Le]=v.useState(P2),[Ge,Bt]=v.useState(null),[Nn,nn]=v.useState(!1),[Ft,Ut]=v.useState(!1),[wn,dn]=v.useState(""),rn=v.useRef(!1),[fn,se]=v.useState(null),[ue,Te]=v.useState(""),[qe,$e]=v.useState(),[Ie,lt]=v.useState(null),[Nt,Kn]=v.useState({newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,addAgentkit:!0}),[sn,Pn]=v.useState("cloud"),[Mt,jn]=v.useState(ud),[Qr,vr]=v.useState(""),[An,Bn]=v.useState("chat"),[Yn,nr]=v.useState(!1),[vn,$t]=v.useState(!1),[an,Cn]=v.useState(!1),[Wn,on]=v.useState({}),[Mr,Fn]=v.useState({}),[In,qn]=v.useState({}),Zr=Et.has(a),Hs=W.has(a),ps=Zr||u,ne=!!a&&Pe,Ce=p?y:ps,He=Ce||!p&&Hs,ct=Wn[a]??"",Ht=Mr[a]??Rhe,hn=In[a]??Lhe,gt=de==null?void 0:de.graph,Gn=[de==null?void 0:de.name,gt==null?void 0:gt.name,gt==null?void 0:gt.id].filter(H=>!!H),Xn=ae.targetAgent&>?V1(gt,ae.targetAgent.name):gt,fr=(Xn==null?void 0:Xn.skills)??(ae.targetAgent?[]:(de==null?void 0:de.skills)??[]),Zj=gt?Xj(gt):[];function vg(H){Cy(H);for(const G of H)G.status==="uploading"?he.current.add(G.id):G.uri&&Ph(n,G.uri).catch(fe=>Me(String(fe)))}function _g(){ee.current+=1;const H=Y;j(null),V(!1),H&&!H.id.startsWith("pending-")&&Ffe(H.id).catch(G=>{Me(G instanceof Error?G.message:String(G))})}async function kg(H){try{await Yb(n,ue,H),await Kb(n,ue,H),i(G=>G.filter(fe=>fe.id!==H)),U(G=>{const{[H]:fe,...Ne}=G;return Ne})}catch(G){Me(String(G))}}function Jj(H){const G=oe.find(De=>De.id===H);if(!G)return;const fe=oe.filter(De=>De.id!==H);Cy([G]),G.status==="uploading"&&he.current.add(H),X(fe),fe.length===0&&!I.trim()&&!!a&&P.length===0?(We.current="",o(""),kg(a)):G.uri&&Ph(n,G.uri).catch(De=>Me(String(De)))}const Jw=(H,G)=>{var Oe,Ue,Qe,Ae,yt;const fe=G.author&&G.author!=="user"?G.author:void 0;fe&&(on(Ke=>({...Ke,[H]:fe})),Fn(Ke=>({...Ke,[H]:new Set(Ke[H]??[]).add(fe)})),qn(Ke=>{var tt;return(tt=Ke[H])!=null&&tt.length?Ke:{...Ke,[H]:[fe]}}));const Ne=((Oe=G.actions)==null?void 0:Oe.transferToAgent)??((Ue=G.actions)==null?void 0:Ue.transfer_to_agent);Ne&&qn(Ke=>{const tt=Ke[H]??[];return tt[tt.length-1]===Ne?Ke:{...Ke,[H]:[...tt,Ne]}}),(((Qe=G.actions)==null?void 0:Qe.endOfAgent)??((Ae=G.actions)==null?void 0:Ae.end_of_agent)??((yt=G.actions)==null?void 0:yt.escalate))&&qn(Ke=>{const tt=Ke[H]??[];return tt.length<=1?Ke:{...Ke,[H]:tt.slice(0,-1)}})},[Tg,zt]=v.useState(L2),[e4,df]=v.useState([]),Sg=v.useCallback(H=>{df(G=>{const fe=G.findIndex(De=>De.id===H.id);if(fe===-1)return[H,...G];const Ne=[...G];return Ne[fe]={...Ne[fe],...H},Ne})},[]),t4=v.useCallback(async H=>{try{await pL(H.id),df(G=>G.map(fe=>fe.id===H.id?{...fe,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。"}:fe))}catch(G){const fe=G instanceof Error?G.message:String(G);df(Ne=>Ne.map(De=>De.id===H.id?{...De,message:`取消失败:${fe}`}:De))}},[]),[n4,r4]=v.useState(!0),[Ng,zs]=v.useState(!1),[s4,Dr]=v.useState(!1),[i4,hr]=v.useState(!1),[a4,di]=v.useState(null),[Ag,ms]=v.useState(!1),[o4,gs]=v.useState(!1),Cg=v.useRef(null),[Ig,Rg]=v.useState(()=>{const H=Ti();return vc(H),H}),[l4,ff]=v.useState(!1),Lg=v.useRef(!1),hf=v.useRef(!1);function pf(H){console.log("create agent draft:",H),zt(null),Lo()}function Og(H,G){console.log("Agent added, navigating to:",H,G),Rg(Ti()),zt(null),r(H)}const Cc=v.useRef(null),Ro=v.useRef(!0),Hi=v.useRef(!1),Ra=v.useRef(null),ev=v.useRef({key:"",turnCount:0}),Mg=(p==null?void 0:p.id)??a;v.useLayoutEffect(()=>{const H=Cc.current,G=ev.current,fe=G.key!==Mg,Ne=!fe&&P.length>G.turnCount;if(ev.current={key:Mg,turnCount:P.length},!H||P.length===0||!fe&&!Ne)return;Ro.current=!0,Hi.current=!1,Ra.current!==null&&(window.clearTimeout(Ra.current),Ra.current=null);const De=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(fe||De){H.scrollTop=H.scrollHeight;return}Hi.current=!0,H.scrollTo({top:H.scrollHeight,behavior:"smooth"}),Ra.current=window.setTimeout(()=>{Hi.current=!1,Ra.current=null},450)},[Mg,P.length]),v.useLayoutEffect(()=>{const H=Cc.current;!H||!Ro.current||Hi.current||(H.scrollTop=H.scrollHeight)},[Ce,P]),v.useEffect(()=>()=>{Ra.current!==null&&window.clearTimeout(Ra.current)},[]);const c4=v.useCallback(()=>{const H=Cc.current;!H||Hi.current||(Ro.current=H.scrollHeight-H.scrollTop-H.clientHeight<32)},[]),u4=v.useCallback(H=>{H.deltaY<0&&(Hi.current=!1,Ro.current=!1)},[]),d4=v.useCallback(()=>{Hi.current=!1,Ro.current=!1},[]),f4=v.useCallback(()=>{const H=Cc.current;!H||!Ro.current||Hi.current||(H.scrollTop=H.scrollHeight)},[]),Dg=v.useCallback(()=>{se(null),zb().then(H=>{Te(H.userId),$e(H.info),$t(!!H.local),Bt(H.status)}).catch(H=>{se(H instanceof Error?H.message:String(H))})},[]);v.useEffect(()=>{Dg()},[Dg]),v.useEffect(()=>{const H=()=>{dn(""),nn(!0)};return window.addEventListener(Vb,H),Z7()&&H(),()=>window.removeEventListener(Vb,H)},[]);const h4=v.useCallback(async()=>{if(rn.current)return;rn.current=!0;const H=K7();if(!H){rn.current=!1,dn("登录窗口被浏览器拦截,请允许弹出窗口后重试。");return}Ut(!0),dn("");try{for(;;){await new Promise(G=>window.setTimeout(G,1e3));try{const G=await zb();if(G.status==="authenticated"){Te(G.userId),$e(G.info),$t(!!G.local),Bt(G.status),nn(!1),J7(),H.close();return}}catch{}if(H.closed){dn("登录窗口已关闭,请重新登录以继续当前操作。");return}}}finally{rn.current=!1,Ut(!1)}},[]);v.useEffect(()=>{vn&&ue&&Yk(ue)},[vn,ue]),v.useEffect(()=>{if(Ge!=="authenticated"||!ue){z({});return}let H=!1;return Promise.allSettled([she(),ihe()]).then(([G,fe])=>{H||z({temporaryEnabled:G.status==="fulfilled"&&G.value.enabled,skillCreateEnabled:fe.status==="fulfilled"&&fe.value.enabled})}),()=>{H=!0}},[Ge,ue]),v.useEffect(()=>{if(Ge!=="authenticated"||!ue){lt(null);return}let H=!1;return lt(null),bL().then(G=>{H||lt(G)}).catch(G=>{console.warn("[app] /web/access failed; using ordinary-user access:",G),H||lt(yL)}),()=>{H=!0}},[Ge,ue]),v.useEffect(()=>{gL().then(H=>{Kn(H.features),Pn(H.agentsSource),jn(H.branding),vr(H.version),Bn(H.defaultView),nr(!0)})},[]),v.useEffect(()=>{!Ie||!Yn||hf.current||(hf.current=!0,An==="addAgent"&&Ie.capabilities.createAgents&&(zt(null),zs(!1),ms(!1),gs(!1),Dr(!1),hr(!0)))},[Ie,An,Yn]),v.useEffect(()=>{Ie&&(Ie.capabilities.createAgents||(zt(null),di(null),Dr(!1),hr(!1),df([])),Ie.capabilities.manageAgents||gs(!1))},[Ie]),v.useEffect(()=>{document.title=Mt.title;let H=document.querySelector('link[rel~="icon"]');H||(H=document.createElement("link"),H.rel="icon",document.head.appendChild(H)),H.removeAttribute("type"),H.href=Mt.logoUrl||ow},[Mt]),v.useEffect(()=>{fetch("/web/runtime-config",{signal:AbortSignal.timeout(1e4)}).then(H=>H.ok?H.json():null).then(H=>{H&&r4(!!H.credentials)}).catch(H=>{console.warn("[app] /web/runtime-config probe failed; workbench stays hidden:",H)})},[]);function p4(H){Yk(H),Lg.current=!0,hf.current=!1,lt(null),zt(null),di(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Lo(),Te(H),$e({name:H}),$t(!0),Bt("authenticated")}function m4(){hf.current=!1,lt(null),vn?(z7(),Te(""),$e(void 0),Bt("unauthenticated")):W7()}v.useEffect(()=>{Ge!=="unauthenticated"&&JR().then(H=>{if(t(H),sn==="cloud"){r("");return}const G=localStorage.getItem(Go.app),fe=Ig.flatMap(Oe=>Oe.apps.map(Ue=>mo(Oe.id,Ue))),Ne=G&&(H.includes(G)||fe.includes(G)),De=["web_search_agent","web_demo"].find(Oe=>H.includes(Oe))??H.find(Oe=>!/^\d/.test(Oe))??H[0];r(Ne?G:De||"")}).catch(H=>Me(String(H)))},[Ge,sn]),v.useEffect(()=>{n&&localStorage.setItem(Go.app,n)},[n]),v.useEffect(()=>{let H=!1;if(_e(null),je([]),!n||!ue||!a){we(!1);return}return we(!0),iL(n,ue,a).then(G=>{H||(_e(G),aL(n).then(fe=>{H||je(fe)}).catch(()=>{H||je([])}))}).catch(()=>{H||_e(null)}).finally(()=>{H||we(!1)}),()=>{H=!0}},[n,ue,a]),v.useEffect(()=>{let H=!1;if(ye(null),Z(bi()),!n){ge(!1);return}return ge(!0),Rx(n).then(G=>{H||ye(G)}).catch(()=>{H||ye(null)}).finally(()=>{H||ge(!1)}),()=>{H=!0}},[n]),v.useEffect(()=>{Ie&&localStorage.setItem(Go.view,Ie.capabilities.createAgents?Tg??"chat":"chat")},[Ie,Tg]),v.useEffect(()=>{localStorage.setItem(Go.session,a),We.current=a},[a]),v.useEffect(()=>()=>ce.current.forEach(H=>H.abort()),[]),v.useEffect(()=>()=>ke.current.forEach(H=>{window.clearTimeout(H)}),[]),v.useEffect(()=>()=>{var H,G;(H=S.current)==null||H.abort(),(G=C.current)==null||G.abort()},[]),v.useEffect(()=>{!n||!ue||(async()=>{const H=await mf(n);if(!Lg.current){Lg.current=!0;const G=localStorage.getItem(Go.session)||"";if(L2()===null&&G&&H.some(fe=>fe.id===G)){gf(G);return}}Lo()})()},[n,ue]),v.useEffect(()=>{const H=Cg.current;H&&H.app===n&&(Cg.current=null,gf(H.sid))},[n]);function g4(H,G){ms(!1),H===n?gf(G):(Cg.current={app:H,sid:G},r(H))}async function mf(H){try{const G=await Ax(H,ue),fe=await Promise.all(G.map(Ne=>{var De;return(De=Ne.events)!=null&&De.length?Promise.resolve(Ne):jp(H,ue,Ne.id)}));return i(fe),fe}catch(G){return Me(String(G)),[]}}function y4(){p||(Me(""),N(""),T("confirm"),_(!0))}function b4(){var H;(H=S.current)==null||H.abort(),S.current=null,_(!1),T("confirm"),N(""),!p&&O==="temporary"&&B("agent")}async function E4(){var G;(G=S.current)==null||G.abort();const H=new AbortController;S.current=H,T("loading"),N("");try{const fe=await Ny.startSession({signal:H.signal});if(S.current!==H)return;We.current="",o(""),h([]),L(""),Z(bi()),B("temporary"),_g(),V(!1),vg(oe),X([]),x([]),m(fe),zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),_(!1),T("confirm")}catch(fe){if((fe==null?void 0:fe.name)==="AbortError"||S.current!==H)return;N(fe instanceof Error?fe.message:String(fe)),T("error")}finally{S.current===H&&(S.current=null)}}function La(){var G;(G=C.current)==null||G.abort(),C.current=null,E(!1),x([]),L(""),Me(""),B("agent");const H=p;m(null),H&&Ny.closeSession(H.id).catch(fe=>Me(String(fe)))}async function x4(H){var De;const G=p;if(!G||y||!H.trim())return;Me("");const fe=new AbortController;(De=C.current)==null||De.abort(),C.current=fe;const Ne=[{role:"user",blocks:[{kind:"text",text:H}],meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}];x(Oe=>[...Oe,...Ne]),E(!0);try{const Oe=await Ny.sendMessage({sessionId:G.id,text:H},{signal:fe.signal,onBlocks:Ue=>{C.current===fe&&x(Qe=>{const Ae=Qe.slice(),yt=Ae[Ae.length-1];return(yt==null?void 0:yt.role)==="assistant"&&(Ae[Ae.length-1]={...yt,blocks:Ue}),Ae})}});if(C.current!==fe)return;x(Ue=>{const Qe=Ue.slice(),Ae=Qe[Qe.length-1];return(Ae==null?void 0:Ae.role)==="assistant"&&(Qe[Qe.length-1]={...Ae,blocks:Oe.blocks,meta:{ts:Date.now()/1e3}}),Qe})}catch(Oe){if((Oe==null?void 0:Oe.name)==="AbortError"||C.current!==fe)return;x(Ue=>Ue.slice(0,-2)),L(H),Me(`内置智能体发送失败:${Oe instanceof Error?Oe.message:String(Oe)}`)}finally{C.current===fe&&(C.current=null,E(!1))}}function Lo(){La(),Me(""),ot(!1),Le(P2()),B("agent"),_g(),V(!1);const H=a&&q.length===0&&oe.length>0?a:"";We.current="",o(""),_e(null),je([]),d(!1),h([]),Z(bi()),vg(oe),X([]),H&&kg(H)}async function w4(H){var G;try{(G=ce.current.get(H))==null||G.abort(),await Yb(n,ue,H),await Kb(n,ue,H);const fe=ke.current.get(H);fe!==void 0&&window.clearTimeout(fe),ke.current.delete(H),J(Ne=>{if(!Ne.has(H))return Ne;const De=new Set(Ne);return De.delete(H),De}),U(Ne=>{const{[H]:De,...Oe}=Ne;return Oe}),H===a&&Lo(),await mf(n)}catch(fe){Me(String(fe))}}async function gf(H){if(p&&La(),H!==a&&(We.current=H,Me(""),d(!1),h([]),B("agent"),_g(),Z(bi()),_e(null),je([]),o(H),M[H]===void 0)){Cn(!0);try{const G=await jp(n,ue,H);D(H,g$(G.events??[],G.state))}catch(G){Me(String(G))}finally{Cn(!1)}}}async function tv(H=!0){if(a)return a;c.current||(c.current=Pp(n,ue));const G=c.current;try{const fe=await G;H&&o(fe);const Ne=Date.now()/1e3,De={id:fe,lastUpdateTime:Ne,events:[]};return i(Oe=>[De,...Oe.filter(Ue=>Ue.id!==fe)]),fe}finally{c.current===G&&(c.current=null)}}async function nv(H){if(!n||!ue||!a||!be)return!1;ut(!0),Me("");try{const G=await lL(n,ue,a,H,be.revision);return _e(G),!0}catch(G){return Me(String(G)),!1}finally{ut(!1)}}async function rv(H){if(!(!n||!ue||!a||!be)){ut(!0),Me("");try{const G=await cL(n,ue,a,H,be.revision);_e(G)}catch(G){Me(String(G))}finally{ut(!1)}}}async function v4(H){Me("");let G;try{G=await tv()}catch(Ne){Me(String(Ne));return}const fe=Array.from(H).map(Ne=>({file:Ne,attachment:{id:zhe(),mimeType:Vhe(Ne),name:Ne.name,sizeBytes:Ne.size,status:"uploading"}}));X(Ne=>[...Ne,...fe.map(De=>De.attachment)]),await Promise.all(fe.map(async({file:Ne,attachment:De})=>{try{const Oe=await tL(n,ue,G,Ne);if(he.current.delete(De.id)){Oe.uri&&await Ph(n,Oe.uri);return}X(Ue=>Ue.map(Qe=>Qe.id===De.id?Oe:Qe))}catch(Oe){if(he.current.delete(De.id))return;const Ue=Oe instanceof Error?Oe.message:String(Oe);X(Qe=>Qe.map(Ae=>Ae.id===De.id?{...Ae,status:"error",error:Ue}:Ae)),Me(Ue)}}))}async function sv(H,G=[],fe=bi()){if(!H.trim()&&G.length===0||ps||ne||!n||!ue)return;Me("");const Ne=[];(fe.skills.length>0||fe.targetAgent)&&Ne.push({kind:"invocation",value:fe}),G.length&&Ne.push({kind:"attachment",files:G.map(Ae=>({id:Ae.id,mimeType:Ae.mimeType,data:Ae.data,uri:Ae.uri,name:Ae.name,sizeBytes:Ae.sizeBytes}))}),H.trim()&&Ne.push({kind:"text",text:H});const De=[{role:"user",blocks:Ne,meta:{ts:Date.now()/1e3}},{role:"assistant",blocks:[]}],Oe=!a;Oe&&(h(De),d(!0));let Ue;try{Ue=await tv(!Oe)}catch(Ae){Oe&&(h([]),d(!1),L(H),Z(fe)),Me(String(Ae));return}D(Ue,Ae=>Oe?De:[...Ae,...De]),Oe&&(We.current=Ue,o(Ue),h([]),d(!1));const Qe=new AbortController;ce.current.set(Ue,Qe),pe(Ue,!0),Xe(Ue),We.current=Ue,on(Ae=>({...Ae,[Ue]:""})),Fn(Ae=>({...Ae,[Ue]:new Set})),qn(Ae=>({...Ae,[Ue]:[]}));try{let Ae=Ns(),yt="",Ke=0,tt=Date.now()/1e3,Xt="",Pr="";for await(const ln of cd({appName:n,userId:ue,sessionId:Ue,text:H,attachments:G,invocation:fe,signal:Qe.signal,sessionCapabilities:be!==null})){if(Qe.signal.aborted)break;const fi=ln.error??ln.errorMessage??ln.error_message;if(typeof fi=="string"&&fi){We.current===Ue&&Me(fi);break}Jw(Ue,ln);const hi=ln.author&&ln.author!=="user"?ln.author:"";hi&&hi!==yt&&(yt=hi,Ae=Ns()),Ae=zl(Ae,ln);const Vs=ln.usageMetadata??ln.usage_metadata;Vs!=null&&Vs.totalTokenCount&&(Ke=Vs.totalTokenCount),ln.timestamp&&(tt=ln.timestamp),ln.id&&(Xt=ln.id);const Rn=ln.invocationId??ln.invocation_id;Rn&&(Pr=Rn);const Jr=Ae.blocks,Ks={author:yt||void 0,tokens:Ke||void 0,ts:tt,eventId:Xt||void 0,invocationId:Pr||void 0};D(Ue,pi=>{var mi;const Qn=pi.slice(),zi=Qn[Qn.length-1];return(zi==null?void 0:zi.role)==="assistant"&&(!((mi=zi.meta)!=null&&mi.author)||zi.meta.author===yt)?Qn[Qn.length-1]={...zi,blocks:Jr,meta:Ks}:Qn.push({role:"assistant",blocks:Jr,meta:Ks}),Qn})}mf(n)}catch(Ae){(Ae==null?void 0:Ae.name)!=="AbortError"&&!Qe.signal.aborted&&We.current===Ue&&Me(String(Ae))}finally{ce.current.get(Ue)===Qe&&ce.current.delete(Ue),pe(Ue,!1),St(Ue),on(Ae=>({...Ae,[Ue]:""})),qn(Ae=>({...Ae,[Ue]:[]}))}}function _4(H,G){var De,Oe;const fe=((De=H==null?void 0:H.event)==null?void 0:De.name)??G.id,Ne=((Oe=H==null?void 0:H.event)==null?void 0:Oe.context)??{};sv(`[ui-action] ${fe}: ${JSON.stringify(Ne)}`)}async function k4(H){var Ae,yt,Ke;if(!H.authUri)throw new Error("事件中没有授权地址。");if(!n||!ue||!a)throw new Error("会话尚未就绪。");const G=a,fe=await Fhe(H.authUri),Ne=Uhe(H.authConfig,fe),De=tt=>tt.map(Xt=>Xt.kind==="auth"&&!Xt.done?{...Xt,done:!0}:Xt);D(G,tt=>{const Xt=tt.slice(),Pr=Xt[Xt.length-1];return(Pr==null?void 0:Pr.role)==="assistant"&&(Xt[Xt.length-1]={...Pr,blocks:De(Pr.blocks)}),Xt});const Oe=P[P.length-1],Ue=De(Oe&&Oe.role==="assistant"?Oe.blocks:[]),Qe=new AbortController;ce.current.set(G,Qe),pe(G,!0),Xe(G);try{let tt=Ns(),Xt=((Ae=Oe==null?void 0:Oe.meta)==null?void 0:Ae.author)??"",Pr=Ue,ln=0,fi=Date.now()/1e3,hi=((yt=Oe==null?void 0:Oe.meta)==null?void 0:yt.eventId)??"",Vs=((Ke=Oe==null?void 0:Oe.meta)==null?void 0:Ke.invocationId)??"";for await(const Rn of cd({appName:n,userId:ue,sessionId:a,text:"",functionResponses:[{id:H.callId,name:"adk_request_credential",response:Ne}],signal:Qe.signal,sessionCapabilities:be!==null})){if(Qe.signal.aborted)break;Jw(G,Rn);const Jr=Rn.author&&Rn.author!=="user"?Rn.author:"";Jr&&Jr!==Xt&&(Xt=Jr,Pr=[],tt=Ns()),tt=zl(tt,Rn);const Ks=Rn.usageMetadata??Rn.usage_metadata;Ks!=null&&Ks.totalTokenCount&&(ln=Ks.totalTokenCount),Rn.timestamp&&(fi=Rn.timestamp),Rn.id&&(hi=Rn.id);const pi=Rn.invocationId??Rn.invocation_id;pi&&(Vs=pi);const Qn=[...Pr,...tt.blocks];D(G,zi=>{var cv,uv,dv,fv,hv;const mi=zi.slice(),Un=mi[mi.length-1],lv={author:Xt||((cv=Un==null?void 0:Un.meta)==null?void 0:cv.author),tokens:ln||((uv=Un==null?void 0:Un.meta)==null?void 0:uv.tokens),ts:fi,eventId:hi||((dv=Un==null?void 0:Un.meta)==null?void 0:dv.eventId),invocationId:Vs||((fv=Un==null?void 0:Un.meta)==null?void 0:fv.invocationId)};return(Un==null?void 0:Un.role)==="assistant"&&(!((hv=Un.meta)!=null&&hv.author)||Un.meta.author===Xt)?mi[mi.length-1]={...Un,blocks:Qn,meta:lv}:mi.push({role:"assistant",blocks:Qn,meta:lv}),mi})}mf(n)}catch(tt){(tt==null?void 0:tt.name)!=="AbortError"&&!Qe.signal.aborted&&We.current===G&&Me(String(tt))}finally{ce.current.get(G)===Qe&&ce.current.delete(G),pe(G,!1),St(G),on(tt=>({...tt,[G]:""})),qn(tt=>({...tt,[G]:[]}))}}if(fn)return l.jsxs("div",{className:"boot boot-error",children:[l.jsx("p",{children:fn}),l.jsx("button",{type:"button",onClick:Dg,children:"重试"})]});if(Ge===null)return l.jsx("div",{className:"boot"});if(Ge==="unauthenticated")return l.jsx(ghe,{branding:Mt,onUsername:p4});if(!Ie)return l.jsx("div",{className:"boot"});const Oo=Ie.capabilities.createAgents,iv=Ie.capabilities.manageAgents,ys=Oo?Tg:null,yf=Oo&&i4,bf=Oo&&s4,Pg=iv&&o4,T4=h3(e,Ig),jg=H=>{var G;return((G=T4.find(fe=>fe.id===H))==null?void 0:G.label)??H},Ic=Ig.find(H=>H.runtimeId&&H.apps.some(G=>mo(H.id,G)===n)),Mo=Ic&&Ic.runtimeId?{runtimeId:Ic.runtimeId,name:Ic.name,region:Ic.region??"cn-beijing"}:void 0,av=async(H,G)=>{var Ue,Qe;const fe=(Ue=H.meta)==null?void 0:Ue.eventId,Ne=a;if(!fe||!Ne||!Mo)return;const De=(Qe=H.meta)==null?void 0:Qe.feedback,Oe={...De,rating:G,syncStatus:"syncing",updatedAt:Date.now()/1e3};D(Ne,Ae=>Ae.map(yt=>{var Ke;return((Ke=yt.meta)==null?void 0:Ke.eventId)===fe?{...yt,meta:{...yt.meta,feedback:Oe}}:yt})),vt(Ae=>new Set(Ae).add(fe));try{const Ae=await eL({appName:n,userId:ue,sessionId:Ne,eventId:fe,rating:G});D(Ne,yt=>yt.map(Ke=>{var tt;return((tt=Ke.meta)==null?void 0:tt.eventId)===fe?{...Ke,meta:{...Ke.meta,feedback:Ae}}:Ke})),i(yt=>yt.map(Ke=>Ke.id===Ne?{...Ke,state:{...Ke.state??{},[`veadk_feedback:${fe}`]:Ae}}:Ke))}catch(Ae){D(Ne,yt=>yt.map(Ke=>{var tt;return((tt=Ke.meta)==null?void 0:tt.eventId)===fe?{...Ke,meta:{...Ke.meta,feedback:De}}:Ke})),We.current===Ne&&Me(Ae instanceof Error?Ae.message:String(Ae))}finally{vt(Ae=>{const yt=new Set(Ae);return yt.delete(fe),yt})}},ov=H=>{Rg(Ti()),We.current="",o(""),r(H)},S4=async H=>{const G=await lw(H.runtimeId,H.name,H.region);ov(G)};return l.jsxs("div",{className:"layout",children:[l.jsx(Tee,{branding:Mt,access:Ie,features:Nt,sessions:s,currentSessionId:a,streamingSids:Et,onNewChat:()=>{zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Lo()},onSearch:()=>{p&&La(),zt(null),zs(!1),Dr(!1),hr(!1),gs(!1),ms(!0),Me("")},onQuickCreate:()=>{if(!Oo){Me("当前账号没有添加 Agent 的权限。");return}p&&La(),We.current="",o(""),zs(!1),Dr(!1),ms(!1),gs(!1),zt(null),di(null),hr(!0),Me("")},onSkillCenter:()=>{p&&La(),zt(null),Dr(!1),hr(!1),ms(!1),gs(!1),zs(!0),Me("")},onAddAgent:()=>{if(!Oo){Me("当前账号没有添加 Agent 的权限。");return}p&&La(),We.current="",zt(null),zs(!1),ms(!1),gs(!1),o(""),hr(!1),Dr(!0),Me("")},onManageAgents:()=>{if(!iv){Me("当前账号没有管理 Agent 的权限。");return}p&&La(),We.current="",o(""),zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!0),Me("")},onPickSession:H=>{zt(null),zs(!1),Dr(!1),hr(!1),ms(!1),gs(!1),Me(""),gf(H)},onDeleteSession:w4,userInfo:qe,version:Qr,onLogout:m4}),(()=>{const H=l.jsxs("div",{className:`composer-slot${p?" sandbox-composer-wrap":""}`,children:[p&&l.jsx(lhe,{onExit:Lo}),l.jsx(Jte,{sessionId:p?p.id:a,sessionInitializing:!p&&u,appName:n,agentName:p?"AgentKit 沙箱":n?jg(n):"Agent",value:I,onChange:L,onSubmit:()=>{if(!p&&O==="skill-create"){const De=I.trim();if(!De||re)return;const Oe={id:`pending-${Date.now()}`,prompt:De,status:"provisioning",candidates:pw.map((Qe,Ae)=>({id:`pending-${Ae}`,model:Qe,modelLabel:Qe,status:"queued",stage:"provisioning",files:[],activities:[{id:"provisioning",kind:"status",text:"正在拉起 Sandbox",status:"running"}]}))};V(!0);const Ue=++ee.current;Me(""),j(Oe),L(""),jfe(De,Qe=>{ee.current===Ue&&j(Qe)}).then(Qe=>{ee.current===Ue&&j(Qe)}).catch(Qe=>{ee.current===Ue&&(j(null),L(De),Me(Qe instanceof Error?Qe.message:String(Qe)))}).finally(()=>{ee.current===Ue&&V(!1)});return}const G=I;if(L(""),p){x4(G);return}const fe=oe,Ne=ae;X([]),Z(bi()),sv(G,fe,Ne),Cy(fe)},disabled:p?!1:!ue||O==="temporary"||O==="agent"&&!n,busy:p?y:O==="skill-create"?re:ps,showMeta:P.length>0&&!p,attachments:p?[]:oe,skills:p?[]:fr,agents:p?[]:Zj,invocation:p?bi():ae,capabilitiesLoading:!p&&Q,allowAttachments:!p,onInvocationChange:Z,onAddFiles:v4,onRemoveAttachment:Jj,newChatMode:p?"agent":O,newChatLayout:!p&&P.length===0&&Y===null,showModeSelector:!p&&P.length===0&&Y===null,temporaryEnabled:R.temporaryEnabled,skillCreateEnabled:R.skillCreateEnabled,onModeChange:G=>{if(!(G==="temporary"&&!R.temporaryEnabled||G==="skill-create"&&!R.skillCreateEnabled)){if(G==="temporary"){B(G),y4();return}if(B(G),Me(""),G==="skill-create"){Z(bi());const fe=a&&q.length===0&&oe.length>0?a:"";vg(oe),X([]),fe&&(We.current="",o(""),kg(fe))}}}})]});return l.jsxs("section",{className:"main-shell",children:[l.jsx(Uee,{appName:n,onAppChange:ov,agentLabel:jg,agentsSource:sn,localApps:e,currentRuntime:Mo,runtimeScope:Ie.capabilities.runtimeScope,title:yf?"添加 Agent":bf?"添加 AgentKit 智能体":Pg?"管理 Agent":void 0,titleLeading:P.length>0&&!p&&O==="agent"&&!yf&&!bf&&!Ng&&!Ag&&!Pg&&ys===null&&n?l.jsx("button",{ref:_t,type:"button",className:"agent-info-trigger","aria-label":"查看 Agent 信息",title:"Agent 信息","aria-expanded":Ve,onClick:()=>ot(!0),children:l.jsx(ql,{})}):void 0,crumbs:Ng?[{label:"技能中心"},{label:"AgentKit Skill 空间"}]:Ag||bf||yf||!ys?void 0:ys==="menu"?[{label:Che,onClick:()=>{zt(null),di(null),hr(!0)}},{label:"从 0 快速创建"}]:[{label:"从 0 快速创建",onClick:()=>ff(!0)},{label:Ihe[ys]}],rightContent:l.jsxs(l.Fragment,{children:[Ie.role==="admin"&&l.jsx(Cfe,{}),l.jsx(Hhe,{tasks:Oo?e4:[],onCancel:t4})]})}),l.jsxs("main",{className:`main${p?" is-sandbox-session":""}`,children:[Sn&&l.jsx("div",{className:"error",children:Sn}),an&&l.jsxs("div",{className:"session-loading",children:[l.jsx(bt,{className:"icon spin"})," 加载会话…"]}),Pg?l.jsx(ate,{currentRuntimeId:Mo==null?void 0:Mo.runtimeId,onConnect:S4}):yf?l.jsx(j3,{title:"您想以哪种方式添加 Agent 来运行?",sub:"选择最适合你的方式,下一步即可开始",cards:[{key:"scratch",icon:Ohe,title:"从 0 快速创建",desc:"用智能 / 自定义 / 模板 / 工作流的方式从零创建一个 Agent。",onClick:()=>{hr(!1),di(null),zt("menu")}},{key:"package",icon:o7,title:"从代码包添加和部署",desc:"上传 Agent 项目压缩包,查看代码并直接部署到 AgentKit Runtime。",onClick:()=>{hr(!1),di(null),zt("package")}}]}):Ag?l.jsx(yee,{userId:ue,appId:n,agentInfo:de,capabilitiesLoading:Q,agentLabel:jg,onOpenSession:g4}):bf?l.jsx(ite,{onAdded:G=>{Rg(Ti()),Dr(!1),r(G)},onCancel:()=>Dr(!1)}):Ng?l.jsx(iee,{}):ys!==null&&!n4?l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",padding:24,textAlign:"center",color:"var(--text-secondary, #6b7280)"},children:[l.jsx("div",{style:{fontSize:18,fontWeight:600},children:"需要配置火山引擎 AK/SK"}),l.jsxs("div",{style:{maxWidth:420,lineHeight:1.6},children:["智能体工作台需要 Volcengine 凭据才能使用。请在运行环境中设置"," ",l.jsx("code",{children:"VOLCENGINE_ACCESS_KEY"})," 与"," ",l.jsx("code",{children:"VOLCENGINE_SECRET_KEY"})," 后重试。"]})]}):ys==="menu"?l.jsx(_re,{onSelect:G=>{di(null),zt(G)},onImport:G=>{di(G),zt("custom")}}):ys==="intelligent"?l.jsx(Gre,{userId:ue,onBack:()=>zt("menu"),onCreate:pf,onAgentAdded:Og,onDeploymentTaskChange:Sg}):ys==="custom"?l.jsx(jse,{initialDraft:a4??void 0,onBack:()=>zt("menu"),onCreate:pf,onAgentAdded:Og,features:Nt,onDeploymentTaskChange:Sg}):ys==="template"?l.jsx(Use,{onBack:()=>zt("menu"),onCreate:pf}):ys==="workflow"?l.jsx(pfe,{onBack:()=>zt("menu"),onCreate:pf}):ys==="package"?l.jsx(Efe,{onBack:()=>{zt(null),hr(!0)},onAgentAdded:Og,onDeploymentTaskChange:Sg}):P.length===0&&Y?l.jsx(Zfe,{initialJob:Y}):P.length===0?l.jsxs("div",{className:"welcome",children:[l.jsx(ji,{as:"h1",className:"welcome-title",duration:4.8,spread:22,children:p?"让灵感在临时空间里自由生长":O==="skill-create"?"想创建一个什么 Skill?":le}),H]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`transcript${He?" is-streaming":""}`,ref:Cc,onScroll:c4,onWheel:u4,onTouchMove:d4,children:P.map((G,fe)=>{var ln,fi,hi,Vs,Rn;const Ne=fe===P.length-1;if(G.role==="user"){const Jr=G.blocks.map(Qn=>Qn.kind==="text"?Qn.text:"").join(""),Ks=G.blocks.flatMap(Qn=>Qn.kind==="attachment"?Qn.files:[]),pi=G.blocks.find(Qn=>Qn.kind==="invocation");return l.jsxs(Rt.div,{className:"turn turn--user",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[(pi==null?void 0:pi.kind)==="invocation"&&l.jsx(uw,{value:pi.value}),Ks.length>0&&l.jsx(fw,{appName:n,items:Ks}),Jr&&l.jsx("div",{className:"bubble",children:l.jsx(Gd,{text:Jr})}),l.jsxs("div",{className:"turn-actions turn-actions--right",children:[((ln=G.meta)==null?void 0:ln.ts)&&l.jsx("span",{className:"meta-text",children:Qj(G.meta.ts)}),l.jsx(M2,{text:Jr})]})]},fe)}const De=((fi=G.meta)==null?void 0:fi.author)??"",Oe=De&>?V1(gt,De):void 0,Ue=!!(De&&Gn.length>0&&!Gn.includes(De)),Qe=(Oe==null?void 0:Oe.name)||De,Ae=(Oe==null?void 0:Oe.description)||(Ue?"正在执行主 Agent 移交的任务。":"");if(G.blocks.length>0&&G.blocks.every(Jr=>Jr.kind==="agent-transfer"))return null;const yt=G.blocks.length===0,Ke=((Vs=(hi=G.meta)==null?void 0:hi.feedback)==null?void 0:Vs.rating)??null,tt=((Rn=G.meta)==null?void 0:Rn.eventId)??"",Xt=wt.has(tt),Pr=!!(Mo&&tt&&O2(G));return l.jsxs(Rt.div,{className:`turn turn--assistant${Ue?" turn--subagent":""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[Ue&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"subagent-run-label",children:[l.jsxs("span",{className:"subagent-run-handoff",children:[l.jsx(r7,{}),l.jsx("span",{children:"智能体移交"})]}),l.jsx("span",{className:"subagent-run-title",children:Qe})]}),l.jsx("p",{className:"subagent-run-description",title:Ae,children:Ae})]}),yt?Ne&&Ce?l.jsx(D3,{}):null:l.jsxs(l.Fragment,{children:[l.jsx(hw,{appName:n,blocks:G.blocks,streaming:Ne&&(Ce||Hs),onStreamFrame:Ne?f4:void 0,onAction:_4,onAuth:k4}),!(Ne&&Ce)&&!jhe(G)&&l.jsx("div",{className:"turn-empty",children:"本次没有返回可显示的内容。"}),!(Ne&&Ce)&&!Bhe(G)&&l.jsxs("div",{className:"turn-meta",children:[l.jsxs("div",{className:"turn-actions",children:[Pr&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:`icon-btn feedback-btn${Ke==="good"?" feedback-btn--good":""}`,"aria-label":"赞","aria-pressed":Ke==="good","aria-busy":Xt,title:Ke==="good"?"取消点赞":"赞",disabled:Xt,onClick:()=>void av(G,Ke==="good"?null:"good"),children:l.jsx(che,{className:"icon",filled:Ke==="good"})}),l.jsx("button",{type:"button",className:`icon-btn feedback-btn${Ke==="bad"?" feedback-btn--bad":""}`,"aria-label":"踩","aria-pressed":Ke==="bad","aria-busy":Xt,title:Ke==="bad"?"取消点踩":"踩",disabled:Xt,onClick:()=>void av(G,Ke==="bad"?null:"bad"),children:l.jsx(uhe,{className:"icon",filled:Ke==="bad"})})]}),!p&&l.jsx("button",{className:"icon-btn",title:"Tracing 火焰图",onClick:()=>Gt(!0),children:l.jsx(Mhe,{})}),l.jsx(M2,{text:O2(G)})]}),G.meta&&l.jsx("span",{className:"meta-text",children:Dhe(G.meta)})]})]})]},fe)})}),!p&&l.jsx(_3,{appName:n,info:de,loading:Q,activeAgent:ct,seenAgents:Ht,execPath:hn,capabilities:be,capabilityLoading:Pe,capabilityMutating:Fe,builtinTools:ht,onAddCapability:nv,onRemoveCapability:G=>void rv(G)}),l.jsx("div",{className:"conversation-composer-slot",children:H})]})]})]})})(),Ct&&a&&l.jsx(phe,{appName:n,sessionId:a,onClose:()=>Gt(!1)}),Ve&&P.length>0&&l.jsx(ste,{appName:n,info:de,loading:Q,activeAgent:ct,seenAgents:Ht,execPath:hn,capabilities:be,capabilityLoading:Pe,capabilityMutating:Fe,builtinTools:ht,onAddCapability:nv,onRemoveCapability:H=>void rv(H),onClose:kt,returnFocusRef:_t}),l.jsx(ohe,{open:b,state:k,error:A,onCancel:b4,onConfirm:()=>void E4()}),l.jsx(yhe,{open:Nn,checking:Ft,error:wn,onLogin:()=>void h4()}),l4&&l.jsx("div",{className:"confirm-scrim",onClick:()=>ff(!1),children:l.jsxs("div",{className:"confirm-box",onClick:H=>H.stopPropagation(),children:[l.jsx("div",{className:"confirm-title",children:"返回创建首页?"}),l.jsx("div",{className:"confirm-text",children:"返回后当前填写的内容将会丢失,确定要返回吗?"}),l.jsxs("div",{className:"confirm-actions",children:[l.jsx("button",{className:"confirm-btn",onClick:()=>ff(!1),children:"取消"}),l.jsx("button",{className:"confirm-btn confirm-btn--danger",onClick:()=>{di(null),zt("menu"),ff(!1)},children:"确定返回"})]})]})})]})}(()=>{if(!(window.opener&&window.opener!==window&&/[?&](code|state|error)=/.test(window.location.search)))return!1;try{window.opener.postMessage({veadkOAuth:!0,url:window.location.href},window.location.origin)}catch{}return window.close(),!0})()||Iy.createRoot(document.getElementById("root")).render(l.jsx(et.StrictMode,{children:l.jsx(dB,{reducedMotion:"user",children:l.jsx(VU,{maskOpacity:.9,children:l.jsx(Khe,{})})})}));export{v as A,Km as B,Vr as C,Xhe as D,Su as E,po as F,yO as G,Whe as R,ur as V,et as a,Vl as b,$T as c,Qhe as d,Fx as e,CV as f,hd as g,dt as h,YY as i,JY as j,RV as k,Cd as l,JW as m,MY as n,DY as o,oq as p,NW as q,AW as r,AO as s,l as t,ze as u,At as v,it as w,Ghe as x,VY as y,ai as z}; diff --git a/veadk/webui/index.html b/veadk/webui/index.html index a2929e33..7a67b671 100644 --- a/veadk/webui/index.html +++ b/veadk/webui/index.html @@ -5,7 +5,7 @@ VeADK Studio - +