dsh-plugin-agentflow 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -22
- package/cordis.patch.yml +0 -187
- package/index.js +43 -0
- package/lib/client.js +3 -3
- package/lib/commands.js +1058 -0
- package/lib/flow.js +611 -0
- package/lib/observe.js +286 -0
- package/package.json +5 -3
- package/runtime/boards.mjs +42 -1
- package/runtime/commands.mjs +195 -0
- package/runtime/orchestrator.mjs +57 -0
- package/runtime/server.mjs +67 -96
- package/runtime/web/dist/assets/index-BRBK2BoT.css +1 -0
- package/runtime/web/dist/assets/{index-DhM_avMx.js → index-BxE5pyuf.js} +5 -5
- package/runtime/web/dist/index.html +2 -2
- package/scripts/observe-report.mjs +131 -0
- package/runtime/preset-gen.mjs +0 -1117
- package/runtime/web/dist/assets/index-DEZcpxgr.css +0 -1
package/lib/client.js
CHANGED
|
@@ -230,7 +230,7 @@ html body {
|
|
|
230
230
|
${t}-collapse,
|
|
231
231
|
${t}-edit,
|
|
232
232
|
${t}-copy:not(${t}-copy-icon-only)
|
|
233
|
-
`]:{marginInlineStart:0,marginInlineEnd:e.marginXXS}},...Gk(e),...Kk(e),...qk(),"&-rtl":{direction:`rtl`}}}},()=>({titleMarginTop:`1.2em`,titleMarginBottom:`0.5em`})),Yk=e=>{let{prefixCls:t,"aria-label":n,className:r,style:i,classNames:a,styles:o,direction:s,maxLength:c,autoSize:u=!0,value:d,onSave:f,onCancel:p,onEnd:m,component:h,enterIcon:g=l.createElement(Bk,null)}=e,_=l.useRef(null),v=l.useRef(!1),y=l.useRef(null),[b,x]=l.useState(d);l.useEffect(()=>{x(d)},[d]),l.useEffect(()=>{if(_.current?.resizableTextArea){let{textArea:e}=_.current.resizableTextArea;e.focus();let{length:t}=e.value;e.setSelectionRange(t,t)}},[]);let S=({target:e})=>{x(e.value.replace(/[\n\r]/g,``))},C=()=>{v.current=!0},w=()=>{v.current=!1},T=({keyCode:e})=>{v.current||(y.current=e)},E=()=>{f(b.trim())},D=({keyCode:e,ctrlKey:t,altKey:n,metaKey:r,shiftKey:i})=>{y.current!==e||v.current||t||n||r||i||(e===Z.ENTER?(E(),m?.()):e===Z.ESC&&p())},O=()=>{E()},[k,A]=Jk(t),j=Q(t,`${t}-edit-content`,{[`${t}-rtl`]:s===`rtl`,[`${t}-${h}`]:!!h},r,a.root,k,A);return l.createElement(`div`,{className:j,style:{...o.root,...i}},l.createElement(kD,{ref:_,maxLength:c,value:b,onChange:S,onKeyDown:T,onKeyUp:D,onCompositionStart:C,onCompositionEnd:w,onBlur:O,"aria-label":n,rows:1,autoSize:u,className:a.textarea,style:o.textarea}),g===null?null:sd(g,{className:`${t}-edit-content-confirm`}))},Xk=(e,t)=>{let n=!1,r=r=>{r.stopPropagation(),r.preventDefault(),r.clipboardData?.clearData(),r.clipboardData?.setData(`text/plain`,e),t&&r.clipboardData?.setData(`text/html`,e),n=!0};try{return document.addEventListener(`copy`,r,{capture:!0}),document.execCommand(`copy`),n}catch{return!1}finally{document.removeEventListener(`copy`,r,{capture:!0})}},Zk=async(e,t)=>{try{return t?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:`text/html`}),"text/plain":new Blob([e],{type:`text/plain`})})]):await navigator.clipboard.writeText(e),!0}catch{return!1}};async function Qk(e,t){if(typeof e!=`string`)return!1;let n=t?.format===`text/html`;return!!(await Zk(e,n)||Xk(e,n))}var $k=({copyConfig:e,children:t})=>{let[n,r]=Ae(!1),[i,a]=l.useState(!1),o={};return e.format&&(o.format=e.format),{copied:n,copyLoading:i,onClick:ve(async n=>{n?.preventDefault(),n?.stopPropagation(),a(!0);try{await Qk((bl(e.text)?await e.text():e.text)||jD(t,{skipEmpty:!0}).join(``)||``,o),a(!1),r(!0,!0),r(!1,{ms:3e3}),e.onCopy?.(n)}catch(e){throw a(!1),e}})}},eA=(e,t)=>{let n=!!e;return l.useMemo(()=>{let r={...t,...n&&yl(e)?e:null};return[n,r]},[n,e,t])},tA=e=>{let t=(0,l.useRef)(void 0);return(0,l.useEffect)(()=>{t.current=e}),t.current},nA=(e,t,n)=>(0,l.useMemo)(()=>e===!0?{title:t??n}:(0,l.isValidElement)(e)?{title:e}:yl(e)?{title:t??n,...e}:{title:e},[e,t,n]),rA=(e,t,n,r,i)=>{let{getPrefixCls:a,direction:o,className:s,style:c,classNames:u,styles:d}=Zn(`typography`),f=r??o,p=a(`typography`,e),m={...i,prefixCls:p,direction:f},h=(0,l.useMemo)(()=>({root:s}),[s]),g=Ol(c),[_,v]=Al([h,u,t],[d,g,n],{props:m});return[_,v,p,f]},iA=l.forwardRef((e,t)=>{let{component:n=`article`,className:r,rootClassName:i,children:a,direction:o,style:s,classNames:c,styles:u,prefixCls:d,...f}=e,[p,m]=Jk(d),h=Q(d,{[`${d}-rtl`]:o===`rtl`},r,i,p,m,c?.root),g={...u?.root,...s};return l.createElement(n,{...f,className:h,style:g,ref:t},a)}),aA=l.forwardRef((e,t)=>{let{prefixCls:n,className:r,rootClassName:i,direction:a,classNames:o,styles:s,...c}=e,[u,d,f,p]=rA(n,o,s,a,e);return l.createElement(iA,{ref:t,className:Q(r,i),direction:p,classNames:u,styles:d,prefixCls:f,...c})}),oA={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z`}}]},name:`copy`,theme:`outlined`};function sA(){return sA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sA.apply(this,arguments)}var cA=l.forwardRef((e,t)=>l.createElement(fc,sA({},e,{ref:t,icon:oA}))),lA=e=>e===!1?[!1,!1]:jD(e);function uA(e,t,n){return e===!0||e===void 0?t:e||n&&t}function dA(e){let t=document.createElement(`em`);e.appendChild(t);let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.removeChild(t),n.left>r.left||r.right>n.right||n.top>r.top||r.bottom>n.bottom}var fA=e=>[`string`,`number`].includes(typeof e),pA=e=>{let{prefixCls:t,copied:n,locale:r,iconOnly:i,tooltips:a,icon:o,tabIndex:s,onCopy:c,loading:u,className:d,style:f}=e,p=lA(a),m=lA(o),{copied:h,copy:g}=r??{},_=n?h:g,v=uA(p[+!!n],_),y=typeof v==`string`?v:_;return l.createElement(px,{title:v},l.createElement(`button`,{type:`button`,className:Q(`${t}-copy`,d,{[`${t}-copy-success`]:n,[`${t}-copy-icon-only`]:i}),style:f,onClick:c,"aria-label":y,tabIndex:s},n?uA(m[1],l.createElement(bb,null),!0):uA(m[0],u?l.createElement(Fd,null):l.createElement(cA,null),!0)))},mA=l.forwardRef(({style:e,children:t},n)=>{let r=l.useRef(null);return l.useImperativeHandle(n,()=>({isExceed:()=>{let e=r.current;return e.scrollHeight>e.clientHeight},getHeight:()=>r.current.clientHeight})),l.createElement(`span`,{"aria-hidden":!0,ref:r,style:{position:`fixed`,display:`block`,left:0,top:0,pointerEvents:`none`,backgroundColor:`rgba(255, 0, 0, 0.65)`,...e}},t)}),hA=e=>e.reduce((e,t)=>e+(fA(t)?String(t).length:1),0);function gA(e,t){let n=0,r=[];for(let i=0;i<e.length;i+=1){if(n===t)return r;let a=e[i],o=fA(a)?String(a).length:1,s=n+o;if(s>t){let e=t-n;return r.push(String(a).slice(0,e)),r}r.push(a),n=s}return e}var _A=0,vA=1,yA=2,bA=3,xA=4,SA={display:`-webkit-box`,overflow:`hidden`,WebkitBoxOrient:`vertical`};function CA(e){let{enableMeasure:t,width:n,text:r,children:i,rows:a,expanded:o,measureDeps:s,miscDeps:c,onEllipsis:u}=e,d=l.useMemo(()=>sn(r),[r]),f=l.useMemo(()=>hA(d),[r]),p=l.useMemo(()=>i(d,!1),[r].concat(Gn(s))),[m,h]=l.useState(null),g=l.useRef(null),_=l.useRef(null),v=l.useRef(null),y=l.useRef(null),b=l.useRef(null),[x,S]=l.useState(!1),[C,w]=l.useState(_A),[T,E]=l.useState(0),[D,O]=l.useState(null);xe(()=>{w(t&&n&&f?vA:_A)},[n,r,a,t,d].concat(Gn(s))),xe(()=>{if(C===vA){w(yA);let e=_.current&&getComputedStyle(_.current).whiteSpace;O(e)}else if(C===yA){let e=!!v.current?.isExceed();w(e?bA:xA),h(e?[0,f]:null),S(e);let t=v.current?.getHeight()||0,n=a===1?0:y.current?.getHeight()||0,r=b.current?.getHeight()||0,i=Math.max(t,n+r);E(i+1),u(e)}},[C]);let k=m?Math.ceil((m[0]+m[1])/2):0;xe(()=>{let[e,t]=m||[0,0];if(e!==t){let n=(g.current?.getHeight()||0)>T,r=k;t-e===1&&(r=n?e:t),h(n?[e,r]:[r,t])}},[m,k]);let A=l.useMemo(()=>{if(!t)return i(d,!1);if(C!==bA||!m||m[0]!==m[1]){let e=i(d,!1);return[xA,_A].includes(C)?e:l.createElement(`span`,{style:{...SA,WebkitLineClamp:a}},e)}return i(o?d:gA(d,m[0]),x)},[o,C,m,d].concat(Gn(c))),j={width:n,margin:0,padding:0,whiteSpace:D===`nowrap`?`normal`:`inherit`};return l.createElement(l.Fragment,null,A,C===yA&&l.createElement(l.Fragment,null,l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:a},ref:v},p),l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:a-1},ref:y},p),l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:1},ref:b},i([],!0))),C===bA&&m&&m[0]!==m[1]&&l.createElement(mA,{style:{...j,top:400},ref:g},i(gA(d,k),!0)),C===vA&&l.createElement(`span`,{style:{whiteSpace:`inherit`},ref:_}))}var wA=({enableEllipsis:e,isEllipsis:t,disabled:n,children:r,tooltipProps:i})=>!i?.title||!e?r:l.createElement(px,{...i,disabled:!t||n},r);function TA({mark:e,code:t,underline:n,delete:r,strong:i,keyboard:a,italic:o},s){let c=s;function u(e,t){t&&(c=l.createElement(e,{},c))}return u(`strong`,i),u(`u`,n),u(`del`,r),u(`code`,t),u(`mark`,e),u(`kbd`,a),u(`i`,o),c}var EA=`...`,DA=[`delete`,`mark`,`code`,`underline`,`strong`,`keyboard`,`italic`],OA=l.forwardRef((e,t)=>{let{prefixCls:n,className:r,style:i,classNames:a,styles:o,direction:s,type:c,disabled:u,children:d,ellipsis:f,editable:p,copyable:m,actions:h,component:g,title:_,onClick:v,onMouseEnter:y,onMouseLeave:b,...x}=e,[S]=ru(`Text`),C=l.useRef(null),w=l.useRef(null),[T,E,D,O]=rA(n,a,o,s,e),k=en(x,DA),[A,j]=eA(p),[M,N]=Ce(!1,j.editing),{triggerType:P=[`icon`]}=j,F=e=>{e&&j.onStart?.(),N(e)},I=tA(M);xe(()=>{!M&&I&&w.current?.focus()},[M]);let L=e=>{e?.preventDefault(),F(!0)},R=e=>{j.onChange?.(e),F(!1)},z=()=>{j.onCancel?.(),F(!1)},[B,V]=eA(m),{placement:H=`end`}=h??{},{copied:U,copyLoading:W,onClick:G}=$k({copyConfig:V,children:d}),[ee,te]=l.useState(!1),[ne,K]=l.useState(!1),[re,ie]=l.useState(!1),[ae,q]=l.useState(!1),[oe,se]=l.useState(!0),[J,ce]=eA(f,{expandable:!1,symbol:e=>e?S?.collapse:S?.expand}),[le,ue]=Ce(ce.defaultExpanded||!1,ce.expanded),de=J&&(!le||ce.expandable===`collapsible`),{rows:fe=1}=ce,pe=l.useMemo(()=>de&&(ce.suffix!==void 0||ce.onEllipsis||ce.expandable||A||B),[de,ce,A,B]);xe(()=>{J&&!pe&&(te(It(`webkitLineClamp`)),K(It(`textOverflow`)))},[pe,J]);let[me,he]=l.useState(de),ge=l.useMemo(()=>pe?!1:fe===1?ne:ee,[pe,fe,ee,ne]);xe(()=>{he(ge&&de)},[ge,de]);let _e=nA(ce.tooltip,j.text,d),Y=me&&!!_e.title,ve=de&&(me?Y&&ae:re),ye=de&&fe===1&&me,be=de&&fe>1&&me,X=(e,t)=>{ue(t.expanded),ce.onExpand?.(e,t)},[Se,we]=l.useState(0),[Te,Ee]=Ae(!1),De=l.useRef(!1),Oe=({offsetWidth:e})=>{we(e)},ke=e=>{ie(e),re!==e&&ce.onEllipsis?.(e)},je=l.useCallback(()=>{let e=C.current;if(J&&Y&&e){let t=dA(e);q(e=>e===t?e:t)}},[J,Y]);l.useEffect(()=>{De.current&&je()},[je,d,be,oe,Se]),l.useEffect(()=>{let e=C.current;if(typeof IntersectionObserver>`u`||!e||!Y||!de)return;let t=new IntersectionObserver(()=>{se(!!e.offsetParent)});return t.observe(e),()=>{t.disconnect()}},[Y,de]);let Me=l.useMemo(()=>{if(J&&!me)return[j.text,d,_,_e.title].find(fA)},[J,me,_,_e.title,ve,j.text]);if(M)return l.createElement(Yk,{value:j.text??(typeof d==`string`?d:``),onSave:R,onCancel:z,onEnd:j.onEnd,prefixCls:D,className:r,style:i,direction:O,component:g,maxLength:j.maxLength,autoSize:j.autoSize,enterIcon:j.enterIcon,classNames:T,styles:E});let Ne=()=>{let{expandable:e,symbol:t}=ce;return e?l.createElement(`button`,{type:`button`,key:`expand`,className:Q(`${D}-${le?`collapse`:`expand`}`,T.action),style:E.action,onClick:e=>X(e,{expanded:!le}),"aria-label":le?S.collapse:S?.expand},bl(t)?t(le):t):null},Pe=()=>{if(!A)return;let{icon:e,tooltip:t,tabIndex:n}=j,r=sn(t)[0]||S?.edit,i=typeof r==`string`?r:``;return P.includes(`icon`)?l.createElement(px,{key:`edit`,title:t===!1?``:r},l.createElement(`button`,{type:`button`,ref:w,className:Q(`${D}-edit`,T.action),style:E.action,onClick:L,"aria-label":i,tabIndex:n},e||l.createElement(Lk,null))):null},Fe=()=>B?l.createElement(pA,{key:`copy`,...V,prefixCls:D,copied:U,locale:S,onCopy:G,loading:W,iconOnly:!Xt(d),className:T.action,style:E.action}):null,Ie=e=>{let t=e&&Ne(),n=Pe(),r=Fe();return!t&&!n&&!r?null:l.createElement(`span`,{key:`operations`,className:Q(`${D}-actions`,T.actions,{[`${D}-actions-start`]:H===`start`}),style:E.actions,onMouseEnter:()=>Ee(!0,!0),onMouseLeave:()=>Ee(!1,{ms:500})},t,n,r)},Le=e=>[e&&!le&&l.createElement(`span`,{"aria-hidden":!0,key:`ellipsis`},EA),ce.suffix];return l.createElement(Rn,{onResize:Oe,disabled:!de},n=>l.createElement(wA,{tooltipProps:_e,enableEllipsis:de,isEllipsis:ve,disabled:Te},l.createElement(iA,{onMouseEnter:e=>{De.current=!0,je(),y?.(e)},onMouseLeave:e=>{De.current=!1,b?.(e)},className:Q({[`${D}-${c}`]:c,[`${D}-disabled`]:u,[`${D}-ellipsis`]:J,[`${D}-ellipsis-single-line`]:ye,[`${D}-ellipsis-multiple-line`]:be,[`${D}-link`]:g===`a`},r),classNames:T,styles:E,prefixCls:D,style:{...i,WebkitLineClamp:be?fe:void 0},component:g,ref:qe(n,C,t),direction:O,onClick:e=>{P.includes(`text`)&&L(e),v?.(e)},"aria-label":Me?.toString(),title:_,...k},l.createElement(CA,{enableMeasure:de&&!me,text:d,rows:fe,width:Se,onEllipsis:ke,expanded:le,measureDeps:[H],miscDeps:[U,le,W,A,B,H,S].concat(Gn(DA.map(t=>e[t])))},(t,n)=>TA(e,l.createElement(l.Fragment,null,H===`start`?Ie(n):null,t.length>0&&n&&!le&&Me?l.createElement(`span`,{key:`show-content`,"aria-hidden":!0},t):t,Le(n),H===`start`?null:Ie(n)))))))}),kA=l.forwardRef((e,t)=>{let{ellipsis:n,rel:r,children:i,navigate:a,...o}=e,s={...o,rel:r===void 0&&o.target===`_blank`?`noopener noreferrer`:r};return l.createElement(OA,{...s,ref:t,ellipsis:!!n,component:`a`},i)}),AA=l.forwardRef((e,t)=>{let{children:n,...r}=e;return l.createElement(OA,{ref:t,...r,component:`div`},n)}),jA=l.forwardRef((e,t)=>{let{ellipsis:n,children:r,...i}=e,a=l.useMemo(()=>yl(n)?en(n,[`expandable`,`rows`]):n,[n]);return l.createElement(OA,{ref:t,...i,ellipsis:a,component:`span`},r)}),MA=[1,2,3,4,5],NA=l.forwardRef((e,t)=>{let{level:n=1,children:r,...i}=e,a=MA.includes(n)?`h${n}`:`h1`;return l.createElement(OA,{ref:t,...i,component:a},r)}),PA=aA;PA.Text=jA,PA.Link=kA,PA.Title=NA,PA.Paragraph=AA;var FA=o(((e,t)=>{function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),IA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={items_per_page:`条/页`,jump_to:`跳至`,jump_to_confirm:`确定`,page:`页`,prev_page:`上一页`,next_page:`下一页`,prev_5:`向前 5 页`,next_5:`向后 5 页`,prev_3:`向前 3 页`,next_3:`向后 3 页`,page_size:`页码`}})),LA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.commonLocale=void 0,e.commonLocale={yearFormat:`YYYY`,dayFormat:`D`,cellMeridiemFormat:`A`,monthBeforeYear:!0}})),RA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={...LA().commonLocale,locale:`zh_CN`,today:`今天`,now:`此刻`,backToToday:`返回今天`,ok:`确定`,timeSelect:`选择时间`,dateSelect:`选择日期`,weekSelect:`选择周`,clear:`清除`,week:`周`,month:`月`,year:`年`,previousMonth:`上个月`,nextMonth:`下个月`,monthSelect:`选择月份`,yearSelect:`选择年份`,decadeSelect:`选择年代`,previousYear:`上一年`,nextYear:`下一年`,previousDecade:`上一年代`,nextDecade:`下一年代`,previousCentury:`上一世纪`,nextCentury:`下一世纪`,yearFormat:`YYYY年`,cellDateFormat:`D`,monthBeforeYear:!1}})),zA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={placeholder:`请选择时间`,rangePlaceholder:[`开始时间`,`结束时间`]}})),BA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(RA()),r=t(zA()),i={lang:{placeholder:`请选择日期`,yearPlaceholder:`请选择年份`,quarterPlaceholder:`请选择季度`,monthPlaceholder:`请选择月份`,weekPlaceholder:`请选择周`,rangePlaceholder:[`开始日期`,`结束日期`],rangeYearPlaceholder:[`开始年份`,`结束年份`],rangeMonthPlaceholder:[`开始月份`,`结束月份`],rangeQuarterPlaceholder:[`开始季度`,`结束季度`],rangeWeekPlaceholder:[`开始周`,`结束周`],...n.default},timePickerLocale:{...r.default}};i.lang.ok=`确定`,e.default=i})),VA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=t(BA()).default})),HA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(IA()),r=t(VA()),i=t(BA()),a=t(zA()),o="${label}不是一个有效的${type}";e.default={locale:`zh-cn`,Pagination:n.default,DatePicker:i.default,TimePicker:a.default,Calendar:r.default,global:{placeholder:`请选择`,close:`关闭`,sortable:`可排序`,show:`显示`,hide:`隐藏`},Table:{filterTitle:`筛选`,filterConfirm:`确定`,filterReset:`重置`,filterEmptyText:`无筛选项`,filterCheckAll:`全选`,filterSearchPlaceholder:`在筛选项中搜索`,emptyText:`暂无数据`,selectAll:`全选当页`,selectInvert:`反选当页`,selectNone:`清空所有`,selectionAll:`全选所有`,sortTitle:`排序`,expand:`展开行`,collapse:`关闭行`,triggerDesc:`点击降序`,triggerAsc:`点击升序`,cancelSort:`取消排序`},Modal:{okText:`确定`,cancelText:`取消`,justOkText:`知道了`},Tour:{Next:`下一步`,Previous:`上一步`,Finish:`结束导览`},Popconfirm:{cancelText:`取消`,okText:`确定`},Transfer:{titles:[``,``],searchPlaceholder:`请输入搜索内容`,itemUnit:`项`,itemsUnit:`项`,remove:`删除`,selectCurrent:`全选当页`,removeCurrent:`删除当页`,selectAll:`全选所有`,deselectAll:`取消全选`,removeAll:`删除全部`,selectInvert:`反选当页`},Upload:{uploading:`文件上传中`,removeFile:`删除文件`,uploadError:`上传错误`,previewFile:`预览文件`,downloadFile:`下载文件`},Empty:{description:`暂无数据`},Icon:{icon:`图标`},Text:{edit:`编辑`,copy:`复制`,copied:`复制成功`,expand:`展开`,collapse:`收起`},Carousel:{prevSlide:`上一张幻灯片`,nextSlide:`下一张幻灯片`},Form:{optional:`(可选)`,defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label}须为${len}个字符",min:"${label}最少${min}个字符",max:"${label}最多${max}个字符",range:"${label}须在${min}-${max}字符之间"},number:{len:"${label}必须等于${len}",min:"${label}最小值为${min}",max:"${label}最大值为${max}",range:"${label}须在${min}-${max}之间"},array:{len:"须为${len}个${label}",min:"最少${min}个${label}",max:"最多${max}个${label}",range:"${label}数量须在${min}-${max}之间"},pattern:{mismatch:"${label}与模式不匹配${pattern}"}}},QRCode:{expired:`二维码过期`,refresh:`点击刷新`,scanned:`已扫描`},ColorPicker:{presetEmpty:`暂无`,transparent:`无色`,singleColor:`单色`,gradientColor:`渐变色`}}})),UA=c(o(((e,t)=>{t.exports=HA()}))(),1);function WA(e){try{let t=globalThis.__AGENTFLOW_HOST__;return`${typeof t?.apiBase==`string`?t.apiBase.replace(/\/+$/,``):``}${e}`}catch{return e}}async function GA(e,t){let n=await fetch(WA(e),{...t,headers:t?.body==null?t?.headers:{"Content-Type":`application/json`,...t?.headers||{}}});if(!n.ok){let e=``;try{let t=await n.json();e=t?.error||JSON.stringify(t)}catch{e=await n.text().catch(()=>``)}throw Error(`HTTP ${n.status} ${e}`.slice(0,300))}return n.json()}function KA(e){return{...e,nodes:e.nodes.map(e=>{let t={...e};return delete t.delta,t})}}function qA(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}board=${encodeURIComponent(t)}`:e}var JA={listBoards:()=>GA(`/api/boards`),listPresets:()=>GA(`/api/presets`),getBoard:e=>GA(`/api/boards/${encodeURIComponent(e)}`),createBoard:e=>GA(`/api/boards`,{method:`POST`,body:JSON.stringify(e)}),importPreset:e=>GA(`/api/boards/import-preset`,{method:`POST`,body:JSON.stringify({presetId:e})}),putBoard:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({board:KA(t)})}),putDraft:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}/draft`,{method:`PUT`,body:JSON.stringify({board:KA(t)})}),getDraft:e=>GA(`/api/boards/${encodeURIComponent(e)}/draft`),deleteDraft:e=>GA(`/api/boards/${encodeURIComponent(e)}/draft`,{method:`DELETE`}),patchBoard:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),deleteBoard:e=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`DELETE`}),getSkills:()=>GA(`/api/skills`),getMcp:()=>GA(`/api/mcp`),getConfig:()=>GA(`/api/config`),getModels:(e=!1)=>GA(`/api/models${e?`?refresh=1`:``}`),getBridge:()=>GA(`/api/bridge`),putConfig:e=>GA(`/api/config`,{method:`PUT`,body:JSON.stringify(e)}),exportPreset:(e,t)=>GA(qA(`/api/export/preset`,e),{method:`POST`,body:JSON.stringify(t?{name:t}:{})}),verify:(e,t,n,r)=>GA(qA(`/api/verify/${encodeURIComponent(e)}`,r),{method:`POST`,body:JSON.stringify({pass:t,reason:n})})};function YA(e){let[t,n]=(0,u.useState)(!1),r=(0,u.useRef)(null),i=(0,u.useCallback)(()=>{r.current?.abort(),r.current=null,n(!1)},[]);return{running:t,run:(0,u.useCallback)(async(i,a)=>{if(t)return;let o=new AbortController;r.current=o,n(!0);try{let t=a?`/api/run?board=${encodeURIComponent(a)}`:`/api/run`,n=await fetch(WA(t),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i?.length?{targets:i}:{}),signal:o.signal});if(!n.ok||!n.body){let e=await n.text().catch(()=>``);throw Error(`HTTP ${n.status} ${e}`.slice(0,200))}let r=n.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:t,value:n}=await r.read();if(t)break;c+=s.decode(n,{stream:!0});let i=c.split(`
|
|
233
|
+
`]:{marginInlineStart:0,marginInlineEnd:e.marginXXS}},...Gk(e),...Kk(e),...qk(),"&-rtl":{direction:`rtl`}}}},()=>({titleMarginTop:`1.2em`,titleMarginBottom:`0.5em`})),Yk=e=>{let{prefixCls:t,"aria-label":n,className:r,style:i,classNames:a,styles:o,direction:s,maxLength:c,autoSize:u=!0,value:d,onSave:f,onCancel:p,onEnd:m,component:h,enterIcon:g=l.createElement(Bk,null)}=e,_=l.useRef(null),v=l.useRef(!1),y=l.useRef(null),[b,x]=l.useState(d);l.useEffect(()=>{x(d)},[d]),l.useEffect(()=>{if(_.current?.resizableTextArea){let{textArea:e}=_.current.resizableTextArea;e.focus();let{length:t}=e.value;e.setSelectionRange(t,t)}},[]);let S=({target:e})=>{x(e.value.replace(/[\n\r]/g,``))},C=()=>{v.current=!0},w=()=>{v.current=!1},T=({keyCode:e})=>{v.current||(y.current=e)},E=()=>{f(b.trim())},D=({keyCode:e,ctrlKey:t,altKey:n,metaKey:r,shiftKey:i})=>{y.current!==e||v.current||t||n||r||i||(e===Z.ENTER?(E(),m?.()):e===Z.ESC&&p())},O=()=>{E()},[k,A]=Jk(t),j=Q(t,`${t}-edit-content`,{[`${t}-rtl`]:s===`rtl`,[`${t}-${h}`]:!!h},r,a.root,k,A);return l.createElement(`div`,{className:j,style:{...o.root,...i}},l.createElement(kD,{ref:_,maxLength:c,value:b,onChange:S,onKeyDown:T,onKeyUp:D,onCompositionStart:C,onCompositionEnd:w,onBlur:O,"aria-label":n,rows:1,autoSize:u,className:a.textarea,style:o.textarea}),g===null?null:sd(g,{className:`${t}-edit-content-confirm`}))},Xk=(e,t)=>{let n=!1,r=r=>{r.stopPropagation(),r.preventDefault(),r.clipboardData?.clearData(),r.clipboardData?.setData(`text/plain`,e),t&&r.clipboardData?.setData(`text/html`,e),n=!0};try{return document.addEventListener(`copy`,r,{capture:!0}),document.execCommand(`copy`),n}catch{return!1}finally{document.removeEventListener(`copy`,r,{capture:!0})}},Zk=async(e,t)=>{try{return t?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:`text/html`}),"text/plain":new Blob([e],{type:`text/plain`})})]):await navigator.clipboard.writeText(e),!0}catch{return!1}};async function Qk(e,t){if(typeof e!=`string`)return!1;let n=t?.format===`text/html`;return!!(await Zk(e,n)||Xk(e,n))}var $k=({copyConfig:e,children:t})=>{let[n,r]=Ae(!1),[i,a]=l.useState(!1),o={};return e.format&&(o.format=e.format),{copied:n,copyLoading:i,onClick:ve(async n=>{n?.preventDefault(),n?.stopPropagation(),a(!0);try{await Qk((bl(e.text)?await e.text():e.text)||jD(t,{skipEmpty:!0}).join(``)||``,o),a(!1),r(!0,!0),r(!1,{ms:3e3}),e.onCopy?.(n)}catch(e){throw a(!1),e}})}},eA=(e,t)=>{let n=!!e;return l.useMemo(()=>{let r={...t,...n&&yl(e)?e:null};return[n,r]},[n,e,t])},tA=e=>{let t=(0,l.useRef)(void 0);return(0,l.useEffect)(()=>{t.current=e}),t.current},nA=(e,t,n)=>(0,l.useMemo)(()=>e===!0?{title:t??n}:(0,l.isValidElement)(e)?{title:e}:yl(e)?{title:t??n,...e}:{title:e},[e,t,n]),rA=(e,t,n,r,i)=>{let{getPrefixCls:a,direction:o,className:s,style:c,classNames:u,styles:d}=Zn(`typography`),f=r??o,p=a(`typography`,e),m={...i,prefixCls:p,direction:f},h=(0,l.useMemo)(()=>({root:s}),[s]),g=Ol(c),[_,v]=Al([h,u,t],[d,g,n],{props:m});return[_,v,p,f]},iA=l.forwardRef((e,t)=>{let{component:n=`article`,className:r,rootClassName:i,children:a,direction:o,style:s,classNames:c,styles:u,prefixCls:d,...f}=e,[p,m]=Jk(d),h=Q(d,{[`${d}-rtl`]:o===`rtl`},r,i,p,m,c?.root),g={...u?.root,...s};return l.createElement(n,{...f,className:h,style:g,ref:t},a)}),aA=l.forwardRef((e,t)=>{let{prefixCls:n,className:r,rootClassName:i,direction:a,classNames:o,styles:s,...c}=e,[u,d,f,p]=rA(n,o,s,a,e);return l.createElement(iA,{ref:t,className:Q(r,i),direction:p,classNames:u,styles:d,prefixCls:f,...c})}),oA={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z`}}]},name:`copy`,theme:`outlined`};function sA(){return sA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sA.apply(this,arguments)}var cA=l.forwardRef((e,t)=>l.createElement(fc,sA({},e,{ref:t,icon:oA}))),lA=e=>e===!1?[!1,!1]:jD(e);function uA(e,t,n){return e===!0||e===void 0?t:e||n&&t}function dA(e){let t=document.createElement(`em`);e.appendChild(t);let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.removeChild(t),n.left>r.left||r.right>n.right||n.top>r.top||r.bottom>n.bottom}var fA=e=>[`string`,`number`].includes(typeof e),pA=e=>{let{prefixCls:t,copied:n,locale:r,iconOnly:i,tooltips:a,icon:o,tabIndex:s,onCopy:c,loading:u,className:d,style:f}=e,p=lA(a),m=lA(o),{copied:h,copy:g}=r??{},_=n?h:g,v=uA(p[+!!n],_),y=typeof v==`string`?v:_;return l.createElement(px,{title:v},l.createElement(`button`,{type:`button`,className:Q(`${t}-copy`,d,{[`${t}-copy-success`]:n,[`${t}-copy-icon-only`]:i}),style:f,onClick:c,"aria-label":y,tabIndex:s},n?uA(m[1],l.createElement(bb,null),!0):uA(m[0],u?l.createElement(Fd,null):l.createElement(cA,null),!0)))},mA=l.forwardRef(({style:e,children:t},n)=>{let r=l.useRef(null);return l.useImperativeHandle(n,()=>({isExceed:()=>{let e=r.current;return e.scrollHeight>e.clientHeight},getHeight:()=>r.current.clientHeight})),l.createElement(`span`,{"aria-hidden":!0,ref:r,style:{position:`fixed`,display:`block`,left:0,top:0,pointerEvents:`none`,backgroundColor:`rgba(255, 0, 0, 0.65)`,...e}},t)}),hA=e=>e.reduce((e,t)=>e+(fA(t)?String(t).length:1),0);function gA(e,t){let n=0,r=[];for(let i=0;i<e.length;i+=1){if(n===t)return r;let a=e[i],o=fA(a)?String(a).length:1,s=n+o;if(s>t){let e=t-n;return r.push(String(a).slice(0,e)),r}r.push(a),n=s}return e}var _A=0,vA=1,yA=2,bA=3,xA=4,SA={display:`-webkit-box`,overflow:`hidden`,WebkitBoxOrient:`vertical`};function CA(e){let{enableMeasure:t,width:n,text:r,children:i,rows:a,expanded:o,measureDeps:s,miscDeps:c,onEllipsis:u}=e,d=l.useMemo(()=>sn(r),[r]),f=l.useMemo(()=>hA(d),[r]),p=l.useMemo(()=>i(d,!1),[r].concat(Gn(s))),[m,h]=l.useState(null),g=l.useRef(null),_=l.useRef(null),v=l.useRef(null),y=l.useRef(null),b=l.useRef(null),[x,S]=l.useState(!1),[C,w]=l.useState(_A),[T,E]=l.useState(0),[D,O]=l.useState(null);xe(()=>{w(t&&n&&f?vA:_A)},[n,r,a,t,d].concat(Gn(s))),xe(()=>{if(C===vA){w(yA);let e=_.current&&getComputedStyle(_.current).whiteSpace;O(e)}else if(C===yA){let e=!!v.current?.isExceed();w(e?bA:xA),h(e?[0,f]:null),S(e);let t=v.current?.getHeight()||0,n=a===1?0:y.current?.getHeight()||0,r=b.current?.getHeight()||0,i=Math.max(t,n+r);E(i+1),u(e)}},[C]);let k=m?Math.ceil((m[0]+m[1])/2):0;xe(()=>{let[e,t]=m||[0,0];if(e!==t){let n=(g.current?.getHeight()||0)>T,r=k;t-e===1&&(r=n?e:t),h(n?[e,r]:[r,t])}},[m,k]);let A=l.useMemo(()=>{if(!t)return i(d,!1);if(C!==bA||!m||m[0]!==m[1]){let e=i(d,!1);return[xA,_A].includes(C)?e:l.createElement(`span`,{style:{...SA,WebkitLineClamp:a}},e)}return i(o?d:gA(d,m[0]),x)},[o,C,m,d].concat(Gn(c))),j={width:n,margin:0,padding:0,whiteSpace:D===`nowrap`?`normal`:`inherit`};return l.createElement(l.Fragment,null,A,C===yA&&l.createElement(l.Fragment,null,l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:a},ref:v},p),l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:a-1},ref:y},p),l.createElement(mA,{style:{...j,...SA,WebkitLineClamp:1},ref:b},i([],!0))),C===bA&&m&&m[0]!==m[1]&&l.createElement(mA,{style:{...j,top:400},ref:g},i(gA(d,k),!0)),C===vA&&l.createElement(`span`,{style:{whiteSpace:`inherit`},ref:_}))}var wA=({enableEllipsis:e,isEllipsis:t,disabled:n,children:r,tooltipProps:i})=>!i?.title||!e?r:l.createElement(px,{...i,disabled:!t||n},r);function TA({mark:e,code:t,underline:n,delete:r,strong:i,keyboard:a,italic:o},s){let c=s;function u(e,t){t&&(c=l.createElement(e,{},c))}return u(`strong`,i),u(`u`,n),u(`del`,r),u(`code`,t),u(`mark`,e),u(`kbd`,a),u(`i`,o),c}var EA=`...`,DA=[`delete`,`mark`,`code`,`underline`,`strong`,`keyboard`,`italic`],OA=l.forwardRef((e,t)=>{let{prefixCls:n,className:r,style:i,classNames:a,styles:o,direction:s,type:c,disabled:u,children:d,ellipsis:f,editable:p,copyable:m,actions:h,component:g,title:_,onClick:v,onMouseEnter:y,onMouseLeave:b,...x}=e,[S]=ru(`Text`),C=l.useRef(null),w=l.useRef(null),[T,E,D,O]=rA(n,a,o,s,e),k=en(x,DA),[A,j]=eA(p),[M,N]=Ce(!1,j.editing),{triggerType:P=[`icon`]}=j,F=e=>{e&&j.onStart?.(),N(e)},I=tA(M);xe(()=>{!M&&I&&w.current?.focus()},[M]);let L=e=>{e?.preventDefault(),F(!0)},R=e=>{j.onChange?.(e),F(!1)},z=()=>{j.onCancel?.(),F(!1)},[B,V]=eA(m),{placement:H=`end`}=h??{},{copied:U,copyLoading:W,onClick:G}=$k({copyConfig:V,children:d}),[ee,te]=l.useState(!1),[ne,K]=l.useState(!1),[re,ie]=l.useState(!1),[ae,q]=l.useState(!1),[oe,se]=l.useState(!0),[J,ce]=eA(f,{expandable:!1,symbol:e=>e?S?.collapse:S?.expand}),[le,ue]=Ce(ce.defaultExpanded||!1,ce.expanded),de=J&&(!le||ce.expandable===`collapsible`),{rows:fe=1}=ce,pe=l.useMemo(()=>de&&(ce.suffix!==void 0||ce.onEllipsis||ce.expandable||A||B),[de,ce,A,B]);xe(()=>{J&&!pe&&(te(It(`webkitLineClamp`)),K(It(`textOverflow`)))},[pe,J]);let[me,he]=l.useState(de),ge=l.useMemo(()=>pe?!1:fe===1?ne:ee,[pe,fe,ee,ne]);xe(()=>{he(ge&&de)},[ge,de]);let _e=nA(ce.tooltip,j.text,d),Y=me&&!!_e.title,ve=de&&(me?Y&&ae:re),ye=de&&fe===1&&me,be=de&&fe>1&&me,X=(e,t)=>{ue(t.expanded),ce.onExpand?.(e,t)},[Se,we]=l.useState(0),[Te,Ee]=Ae(!1),De=l.useRef(!1),Oe=({offsetWidth:e})=>{we(e)},ke=e=>{ie(e),re!==e&&ce.onEllipsis?.(e)},je=l.useCallback(()=>{let e=C.current;if(J&&Y&&e){let t=dA(e);q(e=>e===t?e:t)}},[J,Y]);l.useEffect(()=>{De.current&&je()},[je,d,be,oe,Se]),l.useEffect(()=>{let e=C.current;if(typeof IntersectionObserver>`u`||!e||!Y||!de)return;let t=new IntersectionObserver(()=>{se(!!e.offsetParent)});return t.observe(e),()=>{t.disconnect()}},[Y,de]);let Me=l.useMemo(()=>{if(J&&!me)return[j.text,d,_,_e.title].find(fA)},[J,me,_,_e.title,ve,j.text]);if(M)return l.createElement(Yk,{value:j.text??(typeof d==`string`?d:``),onSave:R,onCancel:z,onEnd:j.onEnd,prefixCls:D,className:r,style:i,direction:O,component:g,maxLength:j.maxLength,autoSize:j.autoSize,enterIcon:j.enterIcon,classNames:T,styles:E});let Ne=()=>{let{expandable:e,symbol:t}=ce;return e?l.createElement(`button`,{type:`button`,key:`expand`,className:Q(`${D}-${le?`collapse`:`expand`}`,T.action),style:E.action,onClick:e=>X(e,{expanded:!le}),"aria-label":le?S.collapse:S?.expand},bl(t)?t(le):t):null},Pe=()=>{if(!A)return;let{icon:e,tooltip:t,tabIndex:n}=j,r=sn(t)[0]||S?.edit,i=typeof r==`string`?r:``;return P.includes(`icon`)?l.createElement(px,{key:`edit`,title:t===!1?``:r},l.createElement(`button`,{type:`button`,ref:w,className:Q(`${D}-edit`,T.action),style:E.action,onClick:L,"aria-label":i,tabIndex:n},e||l.createElement(Lk,null))):null},Fe=()=>B?l.createElement(pA,{key:`copy`,...V,prefixCls:D,copied:U,locale:S,onCopy:G,loading:W,iconOnly:!Xt(d),className:T.action,style:E.action}):null,Ie=e=>{let t=e&&Ne(),n=Pe(),r=Fe();return!t&&!n&&!r?null:l.createElement(`span`,{key:`operations`,className:Q(`${D}-actions`,T.actions,{[`${D}-actions-start`]:H===`start`}),style:E.actions,onMouseEnter:()=>Ee(!0,!0),onMouseLeave:()=>Ee(!1,{ms:500})},t,n,r)},Le=e=>[e&&!le&&l.createElement(`span`,{"aria-hidden":!0,key:`ellipsis`},EA),ce.suffix];return l.createElement(Rn,{onResize:Oe,disabled:!de},n=>l.createElement(wA,{tooltipProps:_e,enableEllipsis:de,isEllipsis:ve,disabled:Te},l.createElement(iA,{onMouseEnter:e=>{De.current=!0,je(),y?.(e)},onMouseLeave:e=>{De.current=!1,b?.(e)},className:Q({[`${D}-${c}`]:c,[`${D}-disabled`]:u,[`${D}-ellipsis`]:J,[`${D}-ellipsis-single-line`]:ye,[`${D}-ellipsis-multiple-line`]:be,[`${D}-link`]:g===`a`},r),classNames:T,styles:E,prefixCls:D,style:{...i,WebkitLineClamp:be?fe:void 0},component:g,ref:qe(n,C,t),direction:O,onClick:e=>{P.includes(`text`)&&L(e),v?.(e)},"aria-label":Me?.toString(),title:_,...k},l.createElement(CA,{enableMeasure:de&&!me,text:d,rows:fe,width:Se,onEllipsis:ke,expanded:le,measureDeps:[H],miscDeps:[U,le,W,A,B,H,S].concat(Gn(DA.map(t=>e[t])))},(t,n)=>TA(e,l.createElement(l.Fragment,null,H===`start`?Ie(n):null,t.length>0&&n&&!le&&Me?l.createElement(`span`,{key:`show-content`,"aria-hidden":!0},t):t,Le(n),H===`start`?null:Ie(n)))))))}),kA=l.forwardRef((e,t)=>{let{ellipsis:n,rel:r,children:i,navigate:a,...o}=e,s={...o,rel:r===void 0&&o.target===`_blank`?`noopener noreferrer`:r};return l.createElement(OA,{...s,ref:t,ellipsis:!!n,component:`a`},i)}),AA=l.forwardRef((e,t)=>{let{children:n,...r}=e;return l.createElement(OA,{ref:t,...r,component:`div`},n)}),jA=l.forwardRef((e,t)=>{let{ellipsis:n,children:r,...i}=e,a=l.useMemo(()=>yl(n)?en(n,[`expandable`,`rows`]):n,[n]);return l.createElement(OA,{ref:t,...i,ellipsis:a,component:`span`},r)}),MA=[1,2,3,4,5],NA=l.forwardRef((e,t)=>{let{level:n=1,children:r,...i}=e,a=MA.includes(n)?`h${n}`:`h1`;return l.createElement(OA,{ref:t,...i,component:a},r)}),PA=aA;PA.Text=jA,PA.Link=kA,PA.Title=NA,PA.Paragraph=AA;var FA=o(((e,t)=>{function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),IA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={items_per_page:`条/页`,jump_to:`跳至`,jump_to_confirm:`确定`,page:`页`,prev_page:`上一页`,next_page:`下一页`,prev_5:`向前 5 页`,next_5:`向后 5 页`,prev_3:`向前 3 页`,next_3:`向后 3 页`,page_size:`页码`}})),LA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.commonLocale=void 0,e.commonLocale={yearFormat:`YYYY`,dayFormat:`D`,cellMeridiemFormat:`A`,monthBeforeYear:!0}})),RA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={...LA().commonLocale,locale:`zh_CN`,today:`今天`,now:`此刻`,backToToday:`返回今天`,ok:`确定`,timeSelect:`选择时间`,dateSelect:`选择日期`,weekSelect:`选择周`,clear:`清除`,week:`周`,month:`月`,year:`年`,previousMonth:`上个月`,nextMonth:`下个月`,monthSelect:`选择月份`,yearSelect:`选择年份`,decadeSelect:`选择年代`,previousYear:`上一年`,nextYear:`下一年`,previousDecade:`上一年代`,nextDecade:`下一年代`,previousCentury:`上一世纪`,nextCentury:`下一世纪`,yearFormat:`YYYY年`,cellDateFormat:`D`,monthBeforeYear:!1}})),zA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={placeholder:`请选择时间`,rangePlaceholder:[`开始时间`,`结束时间`]}})),BA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(RA()),r=t(zA()),i={lang:{placeholder:`请选择日期`,yearPlaceholder:`请选择年份`,quarterPlaceholder:`请选择季度`,monthPlaceholder:`请选择月份`,weekPlaceholder:`请选择周`,rangePlaceholder:[`开始日期`,`结束日期`],rangeYearPlaceholder:[`开始年份`,`结束年份`],rangeMonthPlaceholder:[`开始月份`,`结束月份`],rangeQuarterPlaceholder:[`开始季度`,`结束季度`],rangeWeekPlaceholder:[`开始周`,`结束周`],...n.default},timePickerLocale:{...r.default}};i.lang.ok=`确定`,e.default=i})),VA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=t(BA()).default})),HA=o((e=>{var t=FA().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(IA()),r=t(VA()),i=t(BA()),a=t(zA()),o="${label}不是一个有效的${type}";e.default={locale:`zh-cn`,Pagination:n.default,DatePicker:i.default,TimePicker:a.default,Calendar:r.default,global:{placeholder:`请选择`,close:`关闭`,sortable:`可排序`,show:`显示`,hide:`隐藏`},Table:{filterTitle:`筛选`,filterConfirm:`确定`,filterReset:`重置`,filterEmptyText:`无筛选项`,filterCheckAll:`全选`,filterSearchPlaceholder:`在筛选项中搜索`,emptyText:`暂无数据`,selectAll:`全选当页`,selectInvert:`反选当页`,selectNone:`清空所有`,selectionAll:`全选所有`,sortTitle:`排序`,expand:`展开行`,collapse:`关闭行`,triggerDesc:`点击降序`,triggerAsc:`点击升序`,cancelSort:`取消排序`},Modal:{okText:`确定`,cancelText:`取消`,justOkText:`知道了`},Tour:{Next:`下一步`,Previous:`上一步`,Finish:`结束导览`},Popconfirm:{cancelText:`取消`,okText:`确定`},Transfer:{titles:[``,``],searchPlaceholder:`请输入搜索内容`,itemUnit:`项`,itemsUnit:`项`,remove:`删除`,selectCurrent:`全选当页`,removeCurrent:`删除当页`,selectAll:`全选所有`,deselectAll:`取消全选`,removeAll:`删除全部`,selectInvert:`反选当页`},Upload:{uploading:`文件上传中`,removeFile:`删除文件`,uploadError:`上传错误`,previewFile:`预览文件`,downloadFile:`下载文件`},Empty:{description:`暂无数据`},Icon:{icon:`图标`},Text:{edit:`编辑`,copy:`复制`,copied:`复制成功`,expand:`展开`,collapse:`收起`},Carousel:{prevSlide:`上一张幻灯片`,nextSlide:`下一张幻灯片`},Form:{optional:`(可选)`,defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label}须为${len}个字符",min:"${label}最少${min}个字符",max:"${label}最多${max}个字符",range:"${label}须在${min}-${max}字符之间"},number:{len:"${label}必须等于${len}",min:"${label}最小值为${min}",max:"${label}最大值为${max}",range:"${label}须在${min}-${max}之间"},array:{len:"须为${len}个${label}",min:"最少${min}个${label}",max:"最多${max}个${label}",range:"${label}数量须在${min}-${max}之间"},pattern:{mismatch:"${label}与模式不匹配${pattern}"}}},QRCode:{expired:`二维码过期`,refresh:`点击刷新`,scanned:`已扫描`},ColorPicker:{presetEmpty:`暂无`,transparent:`无色`,singleColor:`单色`,gradientColor:`渐变色`}}})),UA=c(o(((e,t)=>{t.exports=HA()}))(),1);function WA(e){try{let t=globalThis.__AGENTFLOW_HOST__;return`${typeof t?.apiBase==`string`?t.apiBase.replace(/\/+$/,``):``}${e}`}catch{return e}}async function GA(e,t){let n=await fetch(WA(e),{...t,headers:t?.body==null?t?.headers:{"Content-Type":`application/json`,...t?.headers||{}}});if(!n.ok){let e=``;try{let t=await n.json();e=t?.error||JSON.stringify(t)}catch{e=await n.text().catch(()=>``)}throw Error(`HTTP ${n.status} ${e}`.slice(0,300))}return n.json()}function KA(e){return{...e,nodes:e.nodes.map(e=>{let t={...e};return delete t.delta,t})}}function qA(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}board=${encodeURIComponent(t)}`:e}var JA={listBoards:()=>GA(`/api/boards`),listPresets:()=>GA(`/api/presets`),getBoard:e=>GA(`/api/boards/${encodeURIComponent(e)}`),createBoard:e=>GA(`/api/boards`,{method:`POST`,body:JSON.stringify(e)}),importPreset:e=>GA(`/api/boards/import-preset`,{method:`POST`,body:JSON.stringify({presetId:e})}),putBoard:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({board:KA(t)})}),putDraft:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}/draft`,{method:`PUT`,body:JSON.stringify({board:KA(t)})}),getDraft:e=>GA(`/api/boards/${encodeURIComponent(e)}/draft`),deleteDraft:e=>GA(`/api/boards/${encodeURIComponent(e)}/draft`,{method:`DELETE`}),patchBoard:(e,t)=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)}),deleteBoard:e=>GA(`/api/boards/${encodeURIComponent(e)}`,{method:`DELETE`}),getSkills:()=>GA(`/api/skills`),getMcp:()=>GA(`/api/mcp`),getConfig:()=>GA(`/api/config`),getModels:(e=!1)=>GA(`/api/models${e?`?refresh=1`:``}`),getBridge:()=>GA(`/api/bridge`),putConfig:e=>GA(`/api/config`,{method:`PUT`,body:JSON.stringify(e)}),exportCommand:(e,t)=>GA(qA(`/api/export/command`,e),{method:`POST`,body:JSON.stringify(t?{name:t}:{})}),listCommands:()=>GA(`/api/commands`),deleteCommand:e=>GA(`/api/commands/${encodeURIComponent(e)}`,{method:`DELETE`}),verify:(e,t,n,r)=>GA(qA(`/api/verify/${encodeURIComponent(e)}`,r),{method:`POST`,body:JSON.stringify({pass:t,reason:n})})};function YA(e){let[t,n]=(0,u.useState)(!1),r=(0,u.useRef)(null),i=(0,u.useCallback)(()=>{r.current?.abort(),r.current=null,n(!1)},[]);return{running:t,run:(0,u.useCallback)(async(i,a)=>{if(t)return;let o=new AbortController;r.current=o,n(!0);try{let t=a?`/api/run?board=${encodeURIComponent(a)}`:`/api/run`,n=await fetch(WA(t),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i?.length?{targets:i}:{}),signal:o.signal});if(!n.ok||!n.body){let e=await n.text().catch(()=>``);throw Error(`HTTP ${n.status} ${e}`.slice(0,200))}let r=n.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:t,value:n}=await r.read();if(t)break;c+=s.decode(n,{stream:!0});let i=c.split(`
|
|
234
234
|
|
|
235
235
|
`);c=i.pop()??``;for(let t of i)for(let n of t.split(`
|
|
236
236
|
`))if(n.startsWith(`data: `))try{e(JSON.parse(n.slice(6)))}catch{}}}catch(t){t?.name!==`AbortError`&&e({type:`run:error`,error:t.message})}finally{r.current=null,n(!1)}},[e,t]),stop:i}}function XA(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=XA(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var ZA={value:()=>{}};function QA(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new $A(n)}function $A(e){this._=e}function ej(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}$A.prototype=QA.prototype={constructor:$A,on:function(e,t){var n=this._,r=ej(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=tj(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=nj(n[i],e.name,t);else if(t==null)for(i in n)n[i]=nj(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new $A(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function tj(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function nj(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ZA,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var rj={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function ij(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),rj.hasOwnProperty(t)?{space:rj[t],local:e}:e}function aj(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function oj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sj(e){var t=ij(e);return(t.local?oj:aj)(t)}function cj(){}function lj(e){return e==null?cj:function(){return this.querySelector(e)}}function uj(e){typeof e!=`function`&&(e=lj(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new QM(r,this._parents)}function dj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function fj(){return[]}function pj(e){return e==null?fj:function(){return this.querySelectorAll(e)}}function mj(e){return function(){return dj(e.apply(this,arguments))}}function hj(e){e=typeof e==`function`?mj(e):pj(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new QM(r,i)}function gj(e){return function(){return this.matches(e)}}function _j(e){return function(t){return t.matches(e)}}var vj=Array.prototype.find;function yj(e){return function(){return vj.call(this.children,e)}}function bj(){return this.firstElementChild}function xj(e){return this.select(e==null?bj:yj(typeof e==`function`?e:_j(e)))}var Sj=Array.prototype.filter;function Cj(){return Array.from(this.children)}function wj(e){return function(){return Sj.call(this.children,e)}}function Tj(e){return this.selectAll(e==null?Cj:wj(typeof e==`function`?e:_j(e)))}function Ej(e){typeof e!=`function`&&(e=gj(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new QM(r,this._parents)}function Dj(e){return Array(e.length)}function Oj(){return new QM(this._enter||this._groups.map(Dj),this._parents)}function kj(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}kj.prototype={constructor:kj,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Aj(e){return function(){return e}}function jj(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new kj(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Mj(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new kj(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Nj(e){return e.__data__}function Pj(e,t){if(!arguments.length)return Array.from(this,Nj);var n=t?Mj:jj,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Aj(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Fj(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new QM(o,r),o._enter=s,o._exit=c,o}function Fj(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Ij(){return new QM(this._exit||this._groups.map(Dj),this._parents)}function Lj(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function Rj(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new QM(s,this._parents)}function zj(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Bj(e){e||=Vj;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new QM(i,this._parents).order()}function Vj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Hj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Uj(){return Array.from(this)}function Wj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Gj(){let e=0;for(let t of this)++e;return e}function Kj(){return!this.node()}function qj(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Jj(e){return function(){this.removeAttribute(e)}}function Yj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Xj(e,t){return function(){this.setAttribute(e,t)}}function Zj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function $j(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function eM(e,t){var n=ij(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Yj:Jj:typeof t==`function`?n.local?$j:Qj:n.local?Zj:Xj)(n,t))}function tM(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function nM(e){return function(){this.style.removeProperty(e)}}function rM(e,t,n){return function(){this.style.setProperty(e,t,n)}}function iM(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function aM(e,t,n){return arguments.length>1?this.each((t==null?nM:typeof t==`function`?iM:rM)(e,t,n??``)):oM(this.node(),e)}function oM(e,t){return e.style.getPropertyValue(t)||tM(e).getComputedStyle(e,null).getPropertyValue(t)}function sM(e){return function(){delete this[e]}}function cM(e,t){return function(){this[e]=t}}function lM(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uM(e,t){return arguments.length>1?this.each((t==null?sM:typeof t==`function`?lM:cM)(e,t)):this.node()[e]}function dM(e){return e.trim().split(/^|\s+/)}function fM(e){return e.classList||new pM(e)}function pM(e){this._node=e,this._names=dM(e.getAttribute(`class`)||``)}pM.prototype={add:function(e){this._names.indexOf(e)<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 mM(e,t){for(var n=fM(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function hM(e,t){for(var n=fM(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function gM(e){return function(){mM(this,e)}}function _M(e){return function(){hM(this,e)}}function vM(e,t){return function(){(t.apply(this,arguments)?mM:hM)(this,e)}}function yM(e,t){var n=dM(e+``);if(arguments.length<2){for(var r=fM(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?vM:t?gM:_M)(n,t))}function bM(){this.textContent=``}function xM(e){return function(){this.textContent=e}}function SM(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function CM(e){return arguments.length?this.each(e==null?bM:(typeof e==`function`?SM:xM)(e)):this.node().textContent}function wM(){this.innerHTML=``}function TM(e){return function(){this.innerHTML=e}}function EM(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function DM(e){return arguments.length?this.each(e==null?wM:(typeof e==`function`?EM:TM)(e)):this.node().innerHTML}function OM(){this.nextSibling&&this.parentNode.appendChild(this)}function kM(){return this.each(OM)}function AM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jM(){return this.each(AM)}function MM(e){var t=typeof e==`function`?e:sj(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function NM(){return null}function PM(e,t){var n=typeof e==`function`?e:sj(e),r=t==null?NM:typeof t==`function`?t:lj(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function FM(){var e=this.parentNode;e&&e.removeChild(this)}function IM(){return this.each(FM)}function LM(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RM(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zM(e){return this.select(e?RM:LM)}function BM(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function VM(e){return function(t){e.call(this,t,this.__data__)}}function HM(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function UM(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function WM(e,t,n){return function(){var r=this.__on,i,a=VM(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function GM(e,t,n){var r=HM(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}}else{for(s=t?WM:UM,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function KM(e,t,n){var r=tM(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function qM(e,t){return function(){return KM(this,e,t)}}function JM(e,t){return function(){return KM(this,e,t.apply(this,arguments))}}function YM(e,t){return this.each((typeof t==`function`?JM:qM)(e,t))}function*XM(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var ZM=[null];function QM(e,t){this._groups=e,this._parents=t}function $M(){return new QM([[document.documentElement]],ZM)}function eN(){return this}QM.prototype=$M.prototype={constructor:QM,select:uj,selectAll:hj,selectChild:xj,selectChildren:Tj,filter:Ej,data:Pj,enter:Oj,exit:Ij,join:Lj,merge:Rj,selection:eN,order:zj,sort:Bj,call:Hj,nodes:Uj,node:Wj,size:Gj,empty:Kj,each:qj,attr:eM,style:aM,property:uM,classed:yM,text:CM,html:DM,raise:kM,lower:jM,append:MM,insert:PM,remove:IM,clone:zM,datum:BM,on:GM,dispatch:YM,[Symbol.iterator]:XM};function tN(e){return typeof e==`string`?new QM([[document.querySelector(e)]],[document.documentElement]):new QM([[e]],ZM)}function nN(e){let t;for(;t=e.sourceEvent;)e=t;return e}function rN(e,t){if(e=nN(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var iN={passive:!1},aN={capture:!0,passive:!1};function oN(e){e.stopImmediatePropagation()}function sN(e){e.preventDefault(),e.stopImmediatePropagation()}function cN(e){var t=e.document.documentElement,n=tN(e).on(`dragstart.drag`,sN,aN);`onselectstart`in t?n.on(`selectstart.drag`,sN,aN):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function lN(e,t){var n=e.document.documentElement,r=tN(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,sN,aN),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var uN=e=>()=>e;function dN(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){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:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}dN.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function fN(e){return!e.ctrlKey&&!e.button}function pN(){return this.parentNode}function mN(e,t){return t??{x:e.x,y:e.y}}function hN(){return navigator.maxTouchPoints||`ontouchstart`in this}function gN(){var e=fN,t=pN,n=mN,r=hN,i={},a=QA(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,iN).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(tN(n.view).on(`mousemove.drag`,m,aN).on(`mouseup.drag`,h,aN),cN(n.view),oN(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(sN(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){tN(e.view).on(`mousemove.drag mouseup.drag`,null),lN(e.view,l),sN(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(oN(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(sN(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(oN(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=rN(l||r,t),p,m,h;if((h=n.call(e,new dN(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=rN(l||a,t),_=o}u.call(r,e,new dN(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:uN(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:uN(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:uN(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:uN(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function _N(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function vN(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function yN(){}var bN=.7,xN=1/bN,SN=`\\s*([+-]?\\d+)\\s*`,CN=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,wN=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,TN=/^#([0-9a-f]{3,8})$/,EN=RegExp(`^rgb\\(${SN},${SN},${SN}\\)$`),DN=RegExp(`^rgb\\(${wN},${wN},${wN}\\)$`),ON=RegExp(`^rgba\\(${SN},${SN},${SN},${CN}\\)$`),kN=RegExp(`^rgba\\(${wN},${wN},${wN},${CN}\\)$`),AN=RegExp(`^hsl\\(${CN},${wN},${wN}\\)$`),jN=RegExp(`^hsla\\(${CN},${wN},${wN},${CN}\\)$`),MN={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};_N(yN,LN,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:NN,formatHex:NN,formatHex8:PN,formatHsl:FN,formatRgb:IN,toString:IN});function NN(){return this.rgb().formatHex()}function PN(){return this.rgb().formatHex8()}function FN(){return XN(this).formatHsl()}function IN(){return this.rgb().formatRgb()}function LN(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=TN.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?RN(t):n===3?new HN(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zN(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zN(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=EN.exec(e))?new HN(t[1],t[2],t[3],1):(t=DN.exec(e))?new HN(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ON.exec(e))?zN(t[1],t[2],t[3],t[4]):(t=kN.exec(e))?zN(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=AN.exec(e))?YN(t[1],t[2]/100,t[3]/100,1):(t=jN.exec(e))?YN(t[1],t[2]/100,t[3]/100,t[4]):MN.hasOwnProperty(e)?RN(MN[e]):e===`transparent`?new HN(NaN,NaN,NaN,0):null}function RN(e){return new HN(e>>16&255,e>>8&255,e&255,1)}function zN(e,t,n,r){return r<=0&&(e=t=n=NaN),new HN(e,t,n,r)}function BN(e){return e instanceof yN||(e=LN(e)),e?(e=e.rgb(),new HN(e.r,e.g,e.b,e.opacity)):new HN}function VN(e,t,n,r){return arguments.length===1?BN(e):new HN(e,t,n,r??1)}function HN(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}_N(HN,VN,vN(yN,{brighter(e){return e=e==null?xN:xN**+e,new HN(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bN:bN**+e,new HN(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new HN(qN(this.r),qN(this.g),qN(this.b),KN(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:UN,formatHex:UN,formatHex8:WN,formatRgb:GN,toString:GN}));function UN(){return`#${JN(this.r)}${JN(this.g)}${JN(this.b)}`}function WN(){return`#${JN(this.r)}${JN(this.g)}${JN(this.b)}${JN((isNaN(this.opacity)?1:this.opacity)*255)}`}function GN(){let e=KN(this.opacity);return`${e===1?`rgb(`:`rgba(`}${qN(this.r)}, ${qN(this.g)}, ${qN(this.b)}${e===1?`)`:`, ${e})`}`}function KN(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function qN(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function JN(e){return e=qN(e),(e<16?`0`:``)+e.toString(16)}function YN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new QN(e,t,n,r)}function XN(e){if(e instanceof QN)return new QN(e.h,e.s,e.l,e.opacity);if(e instanceof yN||(e=LN(e)),!e)return new QN;if(e instanceof QN)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new QN(o,s,c,e.opacity)}function ZN(e,t,n,r){return arguments.length===1?XN(e):new QN(e,t,n,r??1)}function QN(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}_N(QN,ZN,vN(yN,{brighter(e){return e=e==null?xN:xN**+e,new QN(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bN:bN**+e,new QN(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,i=2*n-r;return new HN(tP(e>=240?e-240:e+120,i,r),tP(e,i,r),tP(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new QN($N(this.h),eP(this.s),eP(this.l),KN(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(){let e=KN(this.opacity);return`${e===1?`hsl(`:`hsla(`}${$N(this.h)}, ${eP(this.s)*100}%, ${eP(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function $N(e){return e=(e||0)%360,e<0?e+360:e}function eP(e){return Math.max(0,Math.min(1,e||0))}function tP(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var nP=e=>()=>e;function rP(e,t){return function(n){return e+n*t}}function iP(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function aP(e){return(e=+e)==1?oP:function(t,n){return n-t?iP(t,n,e):nP(isNaN(t)?n:t)}}function oP(e,t){var n=t-e;return n?rP(e,n):nP(isNaN(e)?t:e)}var sP=(function e(t){var n=aP(t);function r(e,t){var r=n((e=VN(e)).r,(t=VN(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=oP(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function cP(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function lP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function uP(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=yP(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function dP(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function fP(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function pP(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=yP(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var mP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,hP=new RegExp(mP.source,`g`);function gP(e){return function(){return e}}function _P(e){return function(t){return e(t)+``}}function vP(e,t){var n=mP.lastIndex=hP.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=mP.exec(e))&&(i=hP.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:fP(r,i)})),n=hP.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?_P(c[0].x):gP(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function yP(e,t){var n=typeof t,r;return t==null||n===`boolean`?nP(t):(n===`number`?fP:n===`string`?(r=LN(t))?(t=r,sP):vP:t instanceof LN?sP:t instanceof Date?dP:lP(t)?cP:Array.isArray(t)?uP:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?pP:fP)(e,t)}var bP=180/Math.PI,xP={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function SP(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*bP,skewX:Math.atan(c)*bP,scaleX:o,scaleY:s}}var CP;function wP(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?xP:SP(t.a,t.b,t.c,t.d,t.e,t.f)}function TP(e){return e==null||(CP||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),CP.setAttribute(`transform`,e),!(e=CP.transform.baseVal.consolidate()))?xP:(e=e.matrix,SP(e.a,e.b,e.c,e.d,e.e,e.f))}function EP(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:fP(e,i)},{i:c-2,x:fP(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:fP(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:fP(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:fP(e,n)},{i:s-2,x:fP(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var DP=EP(wP,`px, `,`px)`,`deg)`),OP=EP(TP,`, `,`)`,`)`),kP=1e-12;function AP(e){return((e=Math.exp(e))+1/e)/2}function jP(e){return((e=Math.exp(e))-1/e)/2}function MP(e){return((e=Math.exp(2*e))-1)/(e+1)}var NP=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<kP)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=AP(y),c=s/(n*g)*(i*MP(t*r+y)-jP(y));return[a+c*d,o+c*f,s*i/AP(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),PP=0,FP=0,IP=0,LP=1e3,RP,zP,BP=0,VP=0,HP=0,UP=typeof performance==`object`&&performance.now?performance:Date,WP=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function GP(){return VP||=(WP(KP),UP.now()+HP)}function KP(){VP=0}function qP(){this._call=this._time=this._next=null}qP.prototype=JP.prototype={constructor:qP,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?GP():+n)+(t==null?0:+t),!this._next&&zP!==this&&(zP?zP._next=this:RP=this,zP=this),this._call=e,this._time=n,$P()},stop:function(){this._call&&(this._call=null,this._time=1/0,$P())}};function JP(e,t,n){var r=new qP;return r.restart(e,t,n),r}function YP(){GP(),++PP;for(var e=RP,t;e;)(t=VP-e._time)>=0&&e._call.call(void 0,t),e=e._next;--PP}function XP(){VP=(BP=UP.now())+HP,PP=FP=0;try{YP()}finally{PP=0,QP(),VP=0}}function ZP(){var e=UP.now(),t=e-BP;t>LP&&(HP-=t,BP=e)}function QP(){for(var e,t=RP,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:RP=n);zP=e,$P(r)}function $P(e){PP||(FP&&=clearTimeout(FP),e-VP>24?(e<1/0&&(FP=setTimeout(XP,e-UP.now()-HP)),IP&&=clearInterval(IP)):(IP||=(BP=UP.now(),setInterval(ZP,LP)),PP=1,WP(XP)))}function eF(e,t,n){var r=new qP;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var tF=QA(`start`,`end`,`cancel`,`interrupt`),nF=[];function rF(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;sF(e,n,{name:t,index:r,group:i,on:tF,tween:nF,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function iF(e,t){var n=oF(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function aF(e,t){var n=oF(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function oF(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function sF(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=JP(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return eF(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(eF(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function cF(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n)(r=n[o]).name===t?(i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]):a=!1;a&&delete e.__transition}}function lF(e){return this.each(function(){cF(this,e)})}function uF(e,t){var n,r;return function(){var i=aF(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function dF(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=aF(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function fF(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=oF(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?uF:dF)(n,e,t))}function pF(e,t,n){var r=e._id;return e.each(function(){var e=aF(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return oF(e,r).value[t]}}function mF(e,t){var n;return(typeof t==`number`?fP:t instanceof LN?sP:(n=LN(t))?(t=n,sP):vP)(e,t)}function hF(e){return function(){this.removeAttribute(e)}}function gF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _F(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function vF(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function yF(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function bF(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function xF(e,t){var n=ij(e),r=n===`transform`?OP:mF;return this.attrTween(e,typeof t==`function`?(n.local?bF:yF)(n,r,pF(this,`attr.`+e,t)):t==null?(n.local?gF:hF)(n):(n.local?vF:_F)(n,r,t))}function SF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function CF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function wF(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&CF(e,i)),n}return i._value=t,i}function TF(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&SF(e,i)),n}return i._value=t,i}function EF(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=ij(e);return this.tween(n,(r.local?wF:TF)(r,t))}function DF(e,t){return function(){iF(this,e).delay=+t.apply(this,arguments)}}function OF(e,t){return t=+t,function(){iF(this,e).delay=t}}function kF(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?DF:OF)(t,e)):oF(this.node(),t).delay}function AF(e,t){return function(){aF(this,e).duration=+t.apply(this,arguments)}}function jF(e,t){return t=+t,function(){aF(this,e).duration=t}}function MF(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?AF:jF)(t,e)):oF(this.node(),t).duration}function NF(e,t){if(typeof t!=`function`)throw Error();return function(){aF(this,e).ease=t}}function PF(e){var t=this._id;return arguments.length?this.each(NF(t,e)):oF(this.node(),t).ease}function FF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();aF(this,e).ease=n}}function IF(e){if(typeof e!=`function`)throw Error();return this.each(FF(this._id,e))}function LF(e){typeof e!=`function`&&(e=gj(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new fI(r,this._parents,this._name,this._id)}function RF(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new fI(o,this._parents,this._name,this._id)}function zF(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function BF(e,t,n){var r,i,a=zF(t)?iF:aF;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function VF(e,t){var n=this._id;return arguments.length<2?oF(this.node(),n).on.on(e):this.each(BF(n,e,t))}function HF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function UF(){return this.on(`end.remove`,HF(this._id))}function WF(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=lj(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,rF(l[f],t,n,f,l,oF(u,n)));return new fI(a,this._parents,t,n)}function GF(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=pj(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=oF(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&rF(p,t,n,h,f,m);a.push(f),o.push(u)}return new fI(a,o,t,n)}var KF=$M.prototype.constructor;function qF(){return new KF(this._groups,this._parents)}function JF(e,t){var n,r,i;return function(){var a=oM(this,e),o=(this.style.removeProperty(e),oM(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function YF(e){return function(){this.style.removeProperty(e)}}function XF(e,t,n){var r,i=n+``,a;return function(){var o=oM(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function ZF(e,t,n){var r,i,a;return function(){var o=oM(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),oM(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function QF(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=aF(this,e),l=c.on,u=c.value[a]==null?s||=YF(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function $F(e,t,n){var r=(e+=``)==`transform`?DP:mF;return t==null?this.styleTween(e,JF(e,r)).on(`end.style.`+e,YF(e)):typeof t==`function`?this.styleTween(e,ZF(e,r,pF(this,`style.`+e,t))).each(QF(this._id,e)):this.styleTween(e,XF(e,r,t),n).on(`end.style.`+e,null)}function eI(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function tI(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&eI(e,a,n)),r}return a._value=t,a}function nI(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,tI(e,t,n??``))}function rI(e){return function(){this.textContent=e}}function iI(e){return function(){var t=e(this);this.textContent=t??``}}function aI(e){return this.tween(`text`,typeof e==`function`?iI(pF(this,`text`,e)):rI(e==null?``:e+``))}function oI(e){return function(t){this.textContent=e.call(this,t)}}function sI(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&oI(r)),t}return r._value=e,r}function cI(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,sI(e))}function lI(){for(var e=this._name,t=this._id,n=pI(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=oF(c,t);rF(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new fI(r,this._parents,e,n)}function uI(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=aF(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var dI=0;function fI(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function pI(){return++dI}var mI=$M.prototype;fI.prototype={constructor:fI,select:WF,selectAll:GF,selectChild:mI.selectChild,selectChildren:mI.selectChildren,filter:LF,merge:RF,selection:qF,transition:lI,call:mI.call,nodes:mI.nodes,node:mI.node,size:mI.size,empty:mI.empty,each:mI.each,on:VF,attr:xF,attrTween:EF,style:$F,styleTween:nI,text:aI,textTween:cI,remove:UF,tween:fF,delay:kF,duration:MF,ease:PF,easeVarying:IF,end:uI,[Symbol.iterator]:mI[Symbol.iterator]};function hI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var gI={time:null,delay:0,duration:250,ease:hI};function _I(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function vI(e){var t,n;e instanceof fI?(t=e._id,e=e._name):(t=pI(),(n=gI).time=GP(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&rF(c,e,t,l,o,n||_I(c,t));return new fI(r,this._parents,e,t)}$M.prototype.interrupt=lF,$M.prototype.transition=vI;var yI=e=>()=>e;function bI(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function xI(e,t,n){this.k=e,this.x=t,this.y=n}xI.prototype={constructor:xI,scale:function(e){return e===1?this:new xI(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xI(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 SI=new xI(1,0,0);CI.prototype=xI.prototype;function CI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return SI;return e.__zoom}function wI(e){e.stopImmediatePropagation()}function TI(e){e.preventDefault(),e.stopImmediatePropagation()}function EI(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function DI(){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 OI(){return this.__zoom||SI}function kI(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function AI(){return navigator.maxTouchPoints||`ontouchstart`in this}function jI(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function MI(){var e=EI,t=DI,n=jI,r=kI,i=AI,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=NP,l=QA(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,OI).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,OI),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(SI.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new xI(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new xI(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new xI(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=tN(this.that).datum();l.call(e,this.that,new bI(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=rN(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],cF(this),s.start();TI(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=tN(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=rN(t,i),l=t.clientX,u=t.clientY;cN(t.view),wI(t),a.mouse=[c,this.__zoom.invert(c)],cF(this),a.start();function d(e){if(TI(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=rN(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),lN(e.view,a.moved),TI(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=rN(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);TI(r),s>0?tN(this).transition().duration(s).call(x,d,c,r):tN(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(wI(t),s=0;s<i;++s)c=r[s],l=rN(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),cF(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(TI(e),s=0;s<a;++s)c=i[s],l=rN(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(wI(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=rN(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=tN(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:yI(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:yI(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:yI(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:yI([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var NI={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} 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.`},PI=[[-1/0,-1/0],[1/0,1/0]],FI=[`Enter`,` `,`Escape`],II={"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`},LI;(function(e){e.Strict=`strict`,e.Loose=`loose`})(LI||={});var RI;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(RI||={});var zI;(function(e){e.Partial=`partial`,e.Full=`full`})(zI||={});var BI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},VI;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(VI||={});var HI;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(HI||={});var UI;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(UI||={});var WI={[UI.Left]:UI.Right,[UI.Right]:UI.Left,[UI.Top]:UI.Bottom,[UI.Bottom]:UI.Top},GI=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,KI=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),qI=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),JI=(e,t=[0,0])=>{let{width:n,height:r}=OL(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},YI=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):qI(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,cL(e,fL(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?uL(r):{x:0,y:0,width:0,height:0}},XI=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=cL(n,fL(e)),r=!0)}),r?uL(n):{x:0,y:0,width:0,height:0}},ZI=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=mL(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},QI=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function $I(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=OL(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function eL({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=TL(XI($I(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function tL({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,NI.error005());else{let{width:e,height:t}=OL(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&DL(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=DL(d)?iL(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,NI.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function nL({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=QI(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var rL=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),iL=(e={x:0,y:0},t,n)=>({x:rL(e.x,t[0][0],t[1][0]-(n?.width??0)),y:rL(e.y,t[0][1],t[1][1]-(n?.height??0))});function aL(e,t,n){let{width:r,height:i}=OL(n),{x:a,y:o}=n.internals.positionAbsolute;return iL(e,[[a,o],[a+r,o+i]],t)}var oL=(e,t,n)=>e<t?rL(Math.abs(e-t),1,t)/t:e>n?-rL(Math.abs(e-n),1,t)/t:0,sL=(e,t,n=15,r=40)=>[oL(e.x,r,t.width-r)*n,oL(e.y,r,t.height-r)*n],cL=(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)}),lL=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),uL=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),dL=(e,t=[0,0])=>{let{x:n,y:r}=qI(e)?e.internals.positionAbsolute:JI(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},fL=(e,t=[0,0])=>{let{x:n,y:r}=qI(e)?e.internals.positionAbsolute:JI(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pL=(e,t)=>uL(cL(lL(e),lL(t))),mL=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},hL=(e,t)=>mL(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),gL=e=>_L(e.width)&&_L(e.height)&&_L(e.x)&&_L(e.y),_L=e=>!isNaN(e)&&isFinite(e),vL=(e,t)=>(e,t)=>{},yL=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bL=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?yL(s,o):s},xL=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function SL(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let 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 CL(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=SL(e,n),i=SL(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=SL(e.top??e.y??0,n),i=SL(e.bottom??e.y??0,n),a=SL(e.left??e.x??0,t),o=SL(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function wL(e,t,n,r,i,a){let{x:o,y:s}=xL(e,[t,n,r]),{x:c,y:l}=xL({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var TL=(e,t,n,r,i,a)=>{let o=CL(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=rL(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=wL(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},EL=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function DL(e){return e!=null&&e!==`parent`}function OL(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function kL(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function AL(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function jL(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ML(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function NL(e){return{...II,...e||{}}}function PL(e){return e===null?null:e?`valid`:`invalid`}function FL(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=VL(e),s=bL({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?yL(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var IL=e=>({width:e.offsetWidth,height:e.offsetHeight}),LL=e=>e?.getRootNode?.()||window?.document,RL=[`INPUT`,`SELECT`,`TEXTAREA`];function zL(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?RL.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var BL=e=>`clientX`in e,VL=(e,t)=>{let n=BL(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},HL=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...IL(t)}})};function UL({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function WL(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function GL({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case UI.Left:return[t-WL(t-r,a),n];case UI.Right:return[t+WL(r-t,a),n];case UI.Top:return[t,n-WL(n-i,a)];case UI.Bottom:return[t,n+WL(i-n,a)]}}function KL({sourceX:e,sourceY:t,sourcePosition:n=UI.Bottom,targetX:r,targetY:i,targetPosition:a=UI.Top,curvature:o=.25}){let[s,c]=GL({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=GL({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=UL({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function qL({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function JL({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function YL({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=cL(fL(e),fL(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),hL({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},uL(a))>0}var XL=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ZL=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),QL=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,NI.error006()),t;let r=n.getEdgeId||XL,i;return i=GI(e)?{...e}:{...e,id:r(e)},ZL(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function $L({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=qL({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var eR={[UI.Left]:{x:-1,y:0},[UI.Right]:{x:1,y:0},[UI.Top]:{x:0,y:-1},[UI.Bottom]:{x:0,y:1}},tR=({source:e,sourcePosition:t=UI.Bottom,target:n})=>t===UI.Left||t===UI.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nR=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function rR({source:e,sourcePosition:t=UI.Bottom,target:n,targetPosition:r=UI.Top,center:i,offset:a,stepPosition:o}){let s=eR[t],c=eR[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=tR({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=qL({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function iR(e,t,n,r){let i=Math.min(nR(e,t)/2,nR(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function aR({sourceX:e,sourceY:t,sourcePosition:n=UI.Bottom,targetX:r,targetY:i,targetPosition:a=UI.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=rR({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=iR(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function oR(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function sR(e){let{sourceNode:t,targetNode:n}=e;if(!oR(t)||!oR(n))return null;let r=t.internals.handleBounds||cR(t.handles),i=n.internals.handleBounds||cR(n.handles),a=uR(r?.source??[],e.sourceHandle),o=uR(e.connectionMode===LI.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,NI.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||UI.Bottom,c=o?.position||UI.Top,l=lR(t,a,s),u=lR(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function cR(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function lR(e,t,n=UI.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??OL(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case UI.Top:return{x:i+o/2,y:a};case UI.Right:return{x:i+o,y:a+s/2};case UI.Bottom:return{x:i+o/2,y:a+s};case UI.Left:return{x:i,y:a+s/2}}}function uR(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function dR(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function fR(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=dR(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var pR=1e3,mR=10,hR={nodeOrigin:[0,0],nodeExtent:PI,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},gR={...hR,checkEquality:!0};function _R(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function vR(e,t,n){let r=_R(hR,n);for(let n of e.values())if(n.parentId)CR(n,e,t,r);else{let e=iL(JI(n,r.nodeOrigin),DL(n.extent)?n.extent:r.nodeExtent,OL(n));n.internals.positionAbsolute=e}}function yR(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function bR(e){return e===`manual`}function xR(e,t,n,r={}){let i=_R(gR,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!bR(i.zIndexMode)?pR:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=iL(JI(u,i.nodeOrigin),DL(u.extent)?u.extent:i.nodeExtent,OL(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:yR(u,e),z:wR(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&CR(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function SR(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function CR(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=_R(hR,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}SR(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*mR),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=TR(e,u,o,s,a&&!bR(c)?pR:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function wR(e,t,n){let r=_L(e.zIndex)?e.zIndex:0;return bR(n)?r:r+(e.selected?t:0)}function TR(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=OL(e),l=JI(e,n),u=DL(e.extent)?iL(l,e.extent,c):l,d=iL({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=aL(d,c,t));let f=wR(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function ER(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=pL(a.get(n.parentId)?.expandedRect??dL(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=OL(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function DR(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=IL(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=DL(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=aL(h,s,n))}else m&&(h=iL(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:HL(`source`,r.nodeElement,p,d,e.id),target:HL(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&CR(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:dL(g,i)}))}}if(f.length>0){let e=ER(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function OR({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function kR(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function AR(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;kR(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),kR(`target`,s,c,e,i,o),t.set(r.id,r)}}function jR(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:jR(n,t):!1}function MR(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function NR(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!jR(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function PR({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function FR({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=yL(a,t);return{x:o.x-a.x,y:o.y-a.y}}function IR({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=tN(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?lL(XI(s)):null,x=v&&l?FR({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:yL(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=tL({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=PR({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=sL(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=FL(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=NR(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=PR({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=gN().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=FL(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=VL(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=FL(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=VL(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=VL(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=PR({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!MR(t,`.${g}`,v))&&(!_||MR(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function LR(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())hL(i,dL(e))>0&&r.push(e);return r}var RR=250;function zR(e,t,n,r){let i=[],a=1/0,o=LR(e,n,t+RR);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=lR(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function BR(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...lR(o,c,c.position,!0)}:c}function VR(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function HR(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var UR=()=>!0;function WR(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=UR,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=LL(e.target),E=0,D,{x:O,y:k}=VL(e),A=VR(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=BR(i,A,r,c,t);if(!N)return;let P=VL(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=sL(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:lR(V,B,UI.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:WI[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function W(e){if(!M){let{x:t,y:n}=VL(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){G(e);return}let a=b();P=VL(e,j),D=zR(bL(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=GR(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=HR(!!D,s.isValid);let u=c.get(i),f=u?lR(u,B,UI.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?xL({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:WI[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function G(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,W),T.removeEventListener(`mouseup`,G),T.removeEventListener(`touchmove`,W),T.removeEventListener(`touchend`,G)}}T.addEventListener(`mousemove`,W),T.addEventListener(`mouseup`,G),T.addEventListener(`touchmove`,W),T.addEventListener(`touchend`,G)}function GR(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=UR,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=VL(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=VR(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===LI.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=BR(t,e,a,u,n,!0)}return _}var KR={onPointerDown:WR,isValid:GR};function qR({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=tN(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&EL()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=MI().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:rN}}var JR=e=>({x:e.x,y:e.y,zoom:e.k}),YR=({x:e,y:t,zoom:n})=>SI.translate(e,t).scale(n),XR=(e,t)=>e.target.closest(`.${t}`),ZR=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),QR=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,$R=(e,t=0,n=QR,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ez=e=>{let t=e.ctrlKey&&EL()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function tz({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(XR(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=rN(u),t=d*2**ez(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===RI.Vertical?0:u.deltaX*f,m=i===RI.Horizontal?0:u.deltaY*f;!EL()&&u.shiftKey&&i!==RI.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=JR(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function nz({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=XR(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function rz({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=JR(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function iz({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&ZR(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,JR(a.transform))}}function az({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&ZR(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=JR(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function oz({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(XR(f,`${u}-flow__node`)||XR(f,`${u}-flow__edge`)||XR(f,`${u}-flow__selection`)||XR(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||XR(f,c)&&h||XR(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function sz({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=MI().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=tN(e).call(f);y({x:i.x,y:i.y,zoom:rL(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(ez);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yP:NP).transform($R(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!_L(D)||D<0?0:D);let A=k?tz({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):nz({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=rz({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=iz({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=az({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=oz({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=YR(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=YR(e);return await g(n,t),n}function x(e){if(p){let t=YR(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?CI(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yP:NP).scaleTo($R(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yP:NP).scaleBy($R(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!_L(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var cz;(function(e){e.Line=`line`,e.Handle=`handle`})(cz||={});function lz({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function uz(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function dz(e,t){return Math.max(0,t-e)}function fz(e,t){return Math.max(0,e-t)}function pz(e,t,n){return Math.max(0,t-e,e-n)}function mz(e,t){return e?!t:t}function hz(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=pz(E,h,g),j=pz(D,_,v);if(o){let e=0,t=0;c&&w<0?e=dz(y+w+O,o[0][0]):!c&&w>0&&(e=fz(y+E+O,o[1][0])),l&&T<0?t=dz(b+T+k,o[0][1]):!l&&T>0&&(t=fz(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=fz(y+w,s[0][0]):!c&&w<0&&(e=dz(y+E,s[1][0])),l&&T>0?t=fz(b+T,s[0][1]):!l&&T<0&&(t=dz(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=pz(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?fz(b+k+E/C,o[1][1])*C:dz(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?dz(b+E/C,s[1][1])*C:fz(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=pz(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?fz(y+D*C+O,o[1][0])/C:dz(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?dz(y+D*C,s[1][0])/C:fz(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(mz(c,l)?-w:w)/C:w=(mz(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var gz={width:0,height:0,x:0,y:0},_z={...gz,pointerX:0,pointerY:0,aspectRatio:1};function vz(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function yz({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=tN(e),o={controlDirection:uz(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...gz},h={..._z};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:uz(e)};let g,_=null,v=[],y,b,x,S=gN().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=FL(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=DL(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=vz(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=FL(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=hz(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=lz({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,I),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var bz=o((e=>{var t=require("react");function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),xz=o(((e,t)=>{t.exports=bz()})),Sz=o((e=>{var t=require("react"),n=xz();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Cz=c(o(((e,t)=>{t.exports=Sz()}))(),1),wz=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Tz=e=>e?wz(e):wz,{useDebugValue:Ez}=u.default,{useSyncExternalStoreWithSelector:Dz}=Cz.default,Oz=e=>e;function kz(e,t=Oz,n){let r=Dz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ez(r),r}var Az=(e,t)=>{let n=Tz(e),r=(e,r=t)=>kz(n,e,r);return Object.assign(r,n),r},jz=(e,t)=>e?Az(e,t):Az;function Mz(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Nz=(0,l.createContext)(null),Pz=Nz.Provider,Fz=NI.error001(`react`);function Iz(e,t){let n=(0,l.useContext)(Nz);if(n===null)throw Error(Fz);return kz(n,e,t)}function Lz(){let e=(0,l.useContext)(Nz);if(e===null)throw Error(Fz);return(0,l.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Rz={display:`none`},zz={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Bz=`react-flow__node-desc`,Vz=`react-flow__edge-desc`,Hz=`react-flow__aria-live`,Uz=e=>e.ariaLiveMessage,Wz=e=>e.ariaLabelConfig;function Gz({rfId:e}){let t=Iz(Uz);return(0,p.jsx)(`div`,{id:`${Hz}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:zz,children:t})}function Kz({rfId:e,disableKeyboardA11y:t}){let n=Iz(Wz);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{id:`${Bz}-${e}`,style:Rz,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,p.jsx)(`div`,{id:`${Vz}-${e}`,style:Rz,children:n[`edge.a11yDescription.default`]}),!t&&(0,p.jsx)(Gz,{rfId:e})]})}var qz=(0,l.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,p.jsx)(`div`,{className:XA([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});qz.displayName=`Panel`;var Jz=`https://reactflow.dev?utm_source=attribution`;function Yz({proOptions:e,position:t=`bottom-right`}){return(0,l.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,p.jsx)(qz,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Jz}`,children:(0,p.jsx)(`a`,{href:Jz,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Xz=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Zz=e=>e.id;function Qz(e,t){return Mz(e.selectedNodes.map(Zz),t.selectedNodes.map(Zz))&&Mz(e.selectedEdges.map(Zz),t.selectedEdges.map(Zz))}function $z({onSelectionChange:e}){let t=Lz(),{selectedNodes:n,selectedEdges:r}=Iz(Xz,Qz);return(0,l.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var eB=e=>!!e.onSelectionChangeHandlers;function tB({onSelectionChange:e}){let t=Iz(eB);return e||t?(0,p.jsx)($z,{onSelectionChange:e}):null}var nB=[0,0],rB={x:0,y:0,zoom:1},iB=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],aB=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),oB={translateExtent:PI,nodeOrigin:nB,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function sB(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Iz(aB,Mz),u=Lz();(0,l.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=oB,s()}),[]);let d=(0,l.useRef)(oB);return(0,l.useEffect)(()=>{for(let s of iB){let c=e[s];c!==d.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?u.setState({ariaLabelConfig:NL(c)}):s===`fitView`?u.setState({fitViewQueued:c}):s===`fitViewOptions`?u.setState({fitViewOptions:c}):u.setState({[s]:c}))}d.current=e},iB.map(t=>e[t])),null}function cB(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function lB(e){let[t,n]=(0,l.useState)(e===`system`?null:e);return(0,l.useEffect)(()=>{if(e!==`system`){n(e);return}let t=cB(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?cB()?.matches?`dark`:`light`:t}var uB=typeof document<`u`?document:null;function dB(e=null,t={target:uB,actInsideInputWithModifier:!0}){let[n,r]=(0,l.useState)(!1),i=(0,l.useRef)(!1),a=(0,l.useRef)(new Set([])),[o,s]=(0,l.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
@@ -336,7 +336,7 @@ html body {
|
|
|
336
336
|
.dark .af-panel .af-row:hover {
|
|
337
337
|
background: #1d1e1b;
|
|
338
338
|
}
|
|
339
|
-
`,aW=`w-full rounded-lg border border-[#E1E2DD] bg-[#FCFCFA] px-2.5 py-2 text-[13px] leading-[1.65] text-[#1B1B18] outline-none transition-colors placeholder:text-[#9a9a92] focus:border-[#24543F] focus:bg-white dark:border-[#33353B] dark:bg-[#17181B] dark:text-[#EDEDE8] dark:focus:border-[#6aa583] dark:focus:bg-[#1B1C20]`,oW=`rounded-[4px] px-2.5 py-1.5 text-[12px] text-[#5b6472] transition-colors hover:bg-[#EFEFEA] dark:text-[#a3a39b] dark:hover:bg-[#232421]`;function sW(e){return(0,p.jsxs)(`aside`,{className:`af-panel absolute bottom-0 right-0 top-14 z-30 flex w-[420px] flex-col border-l border-[#E3E4DF] bg-[#FCFCFA] dark:border-[#262724] dark:bg-[#17181B]`,role:`complementary`,"aria-label":`节点详情`,children:[(0,p.jsx)(`style`,{children:iW}),(0,p.jsx)(lW,{...e},e.node.id)]})}function cW(e,...t){let n=e.trim().toLowerCase();return!n||t.some(e=>String(e??``).toLowerCase().includes(n))}function lW(e){let{node:t,nodes:n,edges:r,boardId:i,skills:a,servers:o,catalog:s,bridge:c,running:l,onPatch:d,onDerive:f,onVerify:m,onRerun:h,onRefreshModels:g,onEdgesChange:_,onDelete:v,onClose:y}=e,[b,x]=(0,u.useState)(t.label),[S,C]=(0,u.useState)(t.task),[w,T]=(0,u.useState)(t.criteria),[E,D]=(0,u.useState)(QU),[O,k]=(0,u.useState)(0),[A,M]=(0,u.useState)(``),[N,P]=(0,u.useState)(``),[I,L]=(0,u.useState)(null),R=(0,u.useRef)(null),z=(0,u.useRef)(null);(0,u.useEffect)(()=>{mW(R.current)},[S]),(0,u.useEffect)(()=>{mW(z.current)},[w]);let B=(0,u.useRef)(d);(0,u.useEffect)(()=>{B.current=d},[d]);let V=(0,u.useRef)({}),H=(0,u.useRef)(null),W=(0,u.useCallback)(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null);let e=V.current;Object.keys(e).length&&(V.current={},B.current(e))},[]),G=(0,u.useCallback)(e=>{V.current={...V.current,...e},H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(W,400)},[W]);(0,u.useEffect)(()=>()=>{if(H.current!==null){window.clearTimeout(H.current),H.current=null;let e=V.current;Object.keys(e).length&&B.current(e)}},[]),(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&String(e.key).toLowerCase()===`s`&&W()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W]);let[ee,te]=(0,u.useState)(r);(0,u.useEffect)(()=>{te(r)},[r]);let ne=new Set(ee.filter(e=>e.to===t.id).map(e=>e.from)),K=n.filter(e=>e.id!==t.id);function re(e){let n=[...ee.filter(e=>e.to!==t.id),...e.map(e=>({from:e,to:t.id}))];te(n),_(n)}function ae(e,n){let r=new Set(t.skills);n?r.add(e):r.delete(e),d({skills:[...r]})}let q=s?.providers??[],oe=t.provider&&t.model?`${t.provider}/${t.model}`:``,J=q.some(e=>e.id===t.provider&&e.models.some(e=>e.id===t.model)),ce=t.model&&!J?t.model:``,le=J?q.find(e=>e.id===t.provider)?.models.find(e=>e.id===t.model)??null:null,ue=le?.levels??[],de=le?.defaultLevel??``,fe=q.every(e=>!e.models.length),pe=new Set,he=[];for(let e of E){let{provider:t,model:n}=eW(e.value),r=q.find(e=>e.id===t),i=r?.models.find(e=>e.id===n);r&&i&&!pe.has(e.value)&&(pe.add(e.value),he.push({title:i.name,label:`${r.label} · ${i.name}`,value:`${YU}${e.value}`}))}let ge=[];he.length&&ge.push({title:`最近使用`,label:`最近使用`,value:qU,selectable:!1,children:he}),ce&&ge.push({title:`当前值`,label:`当前值`,value:JU,selectable:!1,children:[{title:ce,label:tW(t.provider,ce),value:KU}]});for(let e of q){let t=e.models.length;ge.push({title:t?`${e.label}(${t})`:e.label,label:e.label,value:`p:${e.id}`,selectable:!1,children:e.error?[{title:e.error,label:e.error,value:`e:${e.id}`,disabled:!0}]:e.models.map(t=>({title:t.name,label:`${e.label} · ${t.name}`,value:`${e.id}/${t.id}`}))})}let _e=q.find(e=>e.id===t.provider),ve=E.map(e=>e.provider).find(e=>q.some(t=>t.id===e)),ye=_e?.id??ve??``,be=[...he.length?[qU]:[],...ce?[JU]:[],...ye?[`p:${ye}`]:[]],xe=J?oe:ce?KU:void 0,X=t.fallback??[],Se=t.fallbackEfforts??{},Ce=new Set(X),we=q.map(e=>{let t=e.models.length,n=e.error?[{title:e.error,label:e.error,value:`e:${e.id}`,disabled:!0}]:e.models.filter(t=>{let n=`${e.id}/${t.id}`;return n!==oe&&!Ce.has(n)}).map(t=>({title:t.name,label:`${e.label} · ${t.name}`,value:`${e.id}/${t.id}`}));return{title:t?`${e.label}(${t})`:e.label,label:e.label,value:`p:${e.id}`,selectable:!1,children:n}}).filter(e=>e.children.length>0),Te=ye?[`p:${ye}`]:[];function Ee(e){if(!e||e===KU)return;let n=e.startsWith(YU)?e.slice(2):e,{provider:r,model:i}=eW(n),a=q.find(e=>e.id===r),o=a?.models.find(e=>e.id===i);if(!a||!o)return;let s=o.levels.includes(t.reasoningEffort??``)?t.reasoningEffort??``:``,c={value:n,label:o.name,provider:r},l=[c,...E.filter(e=>e.value!==c.value)].slice(0,ZU);D(l),$U(l),d({provider:r,model:i,reasoningEffort:s})}function De(e){let{provider:t,model:n}=eW(e),r=q.find(e=>e.id===t),i=r?.models.find(e=>e.id===n);return!r||!i?{label:`${e}(不在 DSH 目录里)`,levels:[]}:{label:`${r.label} · ${i.name}`,levels:i.levels}}function Oe(e,t){d({fallback:e,fallbackEfforts:t})}function ke(e){e&&e.includes(`/`)&&!Ce.has(e)&&(Oe([...X,e],{...Se,[e]:``}),k(e=>e+1))}function Ae(e){let t={...Se};delete t[e],Oe(X.filter(t=>t!==e),t)}function je(e,t){Oe(X,{...Se,[e]:t})}let Me=nW[t.status]??nW.idle,Ne=t.type===`orchestrator`,Pe=n.some(e=>e.id!==t.id&&e.type===`orchestrator`),Fe=OU.map(e=>({...e,disabled:e.value===`orchestrator`&&Pe})),Ie=rW.find(e=>e.value===(t.verify??``))??rW[0],Le=t.status===`review`,Re=a.filter(e=>cW(A,e.name,e.description)),ze=o.map(e=>({...e,tools:e.tools.filter(e=>cW(N,e.name,e.description))})).filter(e=>cW(N,e.name)||e.tools.length>0),Be=N.trim()?ze.map(e=>e.name):I??o.filter(e=>e.ok&&e.tools.length).slice(0,1).map(e=>e.name);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b ${WU} bg-[#FAFAF7] px-5 py-3.5 dark:bg-[#1B1C20]`,children:[(0,p.jsx)(`input`,{value:b,onChange:e=>{let t=e.target.value;x(t),G({label:t})},onBlur:W,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},placeholder:`节点名称`,"aria-label":`节点名称`,className:`min-w-0 flex-1 rounded-[3px] border-0 bg-transparent p-0 text-[17px] font-semibold tracking-tight outline-none placeholder:text-[#a8a8a0] focus-visible:ring-2 focus-visible:ring-[#24543F]/30 dark:placeholder:text-[#6f6f68] dark:focus-visible:ring-[#6aa583]/40 ${VU}`}),(0,p.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[12px] ${HU}`,children:[(0,p.jsx)(`span`,{className:`h-[6px] w-[6px] rounded-full ${Me.dot}`}),Me.label]}),(0,p.jsx)(`button`,{type:`button`,onClick:y,"aria-label":`关闭详情`,title:`关闭`,className:`-mr-1 grid h-8 w-8 shrink-0 place-items-center rounded-[4px] text-[#6b6b66] transition-colors hover:bg-[#EFEFEA] dark:text-[#8b8b85] dark:hover:bg-[#232421]`,children:(0,p.jsx)(Y,{size:16})})]}),t.verdict&&(0,p.jsxs)(`div`,{className:`shrink-0 border-b px-5 py-2 text-[12px] leading-[1.5] ${WU} ${t.verdict.pass?`bg-[#EEF3EF] text-[#24543F] dark:bg-[#1B2A22] dark:text-[#8FC3A7]`:`bg-[#FBEFEA] text-[#B4451F] dark:bg-[#2A1C17] dark:text-[#E08A6A]`}`,children:[pW(t.verdict.by),` `,t.verdict.pass?`通过`:`未通过`,t.verdict.reason?`:${t.verdict.reason}`:``]}),t.error&&(0,p.jsx)(`div`,{className:`shrink-0 border-b px-5 py-2 text-[12px] leading-[1.5] ${WU} bg-[#FBEFEA] text-[#B4451F] dark:bg-[#2A1C17] dark:text-[#E08A6A]`,children:t.error}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-6 pt-3`,children:[Ne?null:(0,p.jsxs)(uW,{title:`节点类型`,children:[(0,p.jsx)(jb,{value:t.type||`llm`,onChange:e=>d({type:e}),options:Fe,"aria-label":`节点类型`,className:`w-full`,size:`middle`}),Pe?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:`画布已有根节点,这张卡不能再设为调度卡。`}):null]}),(0,p.jsx)(uW,{title:`模型`,extra:(0,p.jsxs)(`button`,{type:`button`,onClick:g,title:`重新读取 DSH 的模型目录`,className:`flex items-center gap-1 text-[11px] transition-opacity hover:opacity-70 ${UU}`,children:[(0,p.jsx)(ie,{size:11}),`刷新`]}),children:(0,p.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,p.jsx)(Nk,{value:xe,placeholder:`选择模型`,showSearch:!0,treeNodeFilterProp:`title`,treeDefaultExpandAll:!1,treeDefaultExpandedKeys:be,treeNodeLabelProp:`label`,treeData:ge,onChange:Ee,"aria-label":`模型`,className:`w-full`,size:`middle`}),(0,p.jsx)(jb,{value:t.reasoningEffort??``,onChange:e=>d({reasoningEffort:e}),disabled:!ue.length,"aria-label":`推理强度`,title:ue.length?`推理强度`:`当前模型没有可选推理档位`,options:[{value:``,label:`推理强度:模型默认${de?`(${de})`:``}`},...ue.map(e=>({value:e,label:e}))],className:`w-full`,size:`middle`}),fe&&(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] leading-[1.6] ${HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-50`}),(0,p.jsx)(`span`,{children:`没读到 DSH 的模型目录,检查 DSH 凭据或网络。`})]}),(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 border-t border-[#EDEEE9] pt-2 text-[11px] leading-[1.6] dark:border-[#2A2C31] ${c&&!c.healthy?`text-[#B4451F] dark:text-[#e08a6a]`:HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-60`}),(0,p.jsxs)(`span`,{children:[`模型通道:DSH 内核(未连接时不可跑图)`,c&&!c.healthy?` · ${c.reason||`原因未知`}`:``]})]})]})}),(0,p.jsx)(uW,{title:`兜底模型`,extra:X.length?(0,p.jsxs)(`span`,{className:`text-[11px] ${HU}`,children:[X.length,` 个 · 按顺序重试`]}):void 0,children:(0,p.jsxs)(`div`,{className:`space-y-1.5`,children:[X.map(e=>{let t=De(e);return(0,p.jsxs)(`div`,{className:`flex min-h-[32px] items-center gap-2 border-b py-1 last:border-b-0 ${WU}`,children:[(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] ${VU}`,title:t.label,children:t.label}),(0,p.jsx)(jb,{size:`small`,value:Se[e]??``,disabled:!t.levels.length,title:t.levels.length?`这条兜底的推理强度`:`该模型没有可选推理档位`,options:[{value:``,label:`模型默认`},...t.levels.map(e=>({value:e,label:e}))],onChange:t=>je(e,t),"aria-label":`${t.label} 的推理强度`,style:{width:104}}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ae(e),"aria-label":`移除兜底模型 ${t.label}`,title:`移除`,className:`grid h-7 w-7 shrink-0 place-items-center rounded-[4px] transition-colors hover:bg-[#FBEFEA] hover:text-[#B4451F] dark:hover:bg-[#2A1C17] dark:hover:text-[#e08a6a] ${UU}`,children:(0,p.jsx)(Y,{size:13})})]},e)}),(0,p.jsx)(Nk,{onChange:ke,placeholder:`添加兜底模型…`,showSearch:!0,treeNodeFilterProp:`title`,treeDefaultExpandAll:!1,treeDefaultExpandedKeys:Te,treeNodeLabelProp:`label`,treeData:we,"aria-label":`添加兜底模型`,className:`w-full`,size:`middle`},O),(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 pt-0.5 text-[11px] leading-[1.6] ${HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-50`}),(0,p.jsx)(`span`,{children:`兜底模型:主模型失败后按顺序尝试,可单独设推理强度`})]})]})}),(0,p.jsxs)(uW,{title:Ne?`人格`:`任务`,children:[(0,p.jsx)(`textarea`,{ref:R,rows:3,value:S,onChange:e=>{C(e.target.value),G({task:e.target.value}),mW(e.currentTarget)},onBlur:W,placeholder:Ne?`默认:只负责和用户对话,再严格按后续节点的 AgentFlow 流执行(可自己改)`:`写清楚这张卡要做什么…`,className:`${aW} max-h-[240px] resize-none overflow-y-auto`}),Ne&&(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:`默认人格只是起点,可以自己改:它只负责和用户对话,确认需求后严格按后续节点的流程执行。`})]}),(0,p.jsx)(uW,{title:`完成标准`,children:(0,p.jsx)(`textarea`,{ref:z,rows:2,value:w,onChange:e=>{T(e.target.value),G({criteria:e.target.value}),mW(e.currentTarget)},onBlur:W,placeholder:`做到什么程度算完成…`,className:`${aW} max-h-[200px] resize-none overflow-y-auto`})}),(0,p.jsxs)(uW,{title:`结果判断`,children:[(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":`结果判断`,className:`flex gap-[2px] rounded-[6px] bg-[#EFEFEA] p-[3px] dark:bg-[#232421]`,children:rW.map(e=>{let n=(t.verify??``)===e.value;return(0,p.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,title:e.desc,onClick:()=>d({verify:e.value}),className:`flex-1 rounded-[4px] px-1 py-[5px] text-[13px] leading-[1.3] transition-colors ${n?`bg-white text-[#1B1B18] shadow-[0_1px_2px_rgba(0,0,0,0.06)] dark:bg-[#3A3B35] dark:text-[#e8e8e4]`:`hover:text-[#1B1B18] dark:hover:text-[#e8e8e4] ${HU}`}`,children:e.label},e.value||`none`)})}),(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:Ie.desc}),(t.verify??``)===`jev`&&(0,p.jsx)(`p`,{className:`mt-1.5 rounded-[4px] border border-[#E9D9B8] bg-[#FBF4E6] px-2 py-1.5 text-[11px] leading-[1.5] text-[#8a6220] dark:border-[#4a3a1c] dark:bg-[#2a2314] dark:text-[#e0b866]`,children:`需要本机安装 jev(TypeSafe)并配置 API key,否则这张卡跑到判定时会失败。`})]}),(0,p.jsx)(uW,{title:`技能`,extra:(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[`已选 `,t.skills.length]}),children:a.length===0?(0,p.jsx)(dW,{children:`没有找到技能`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(AD,{value:A,onChange:e=>M(e.target.value),allowClear:!0,size:`middle`,placeholder:`搜索技能名或描述…`,"aria-label":`搜索技能`,prefix:(0,p.jsx)(se,{size:12,className:UU}),className:`mb-2`}),Re.length===0?(0,p.jsxs)(dW,{children:[`没有匹配「`,A.trim(),`」的技能`]}):null,(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto`,children:Re.map(e=>{let n=t.skills.includes(e.name);return(0,p.jsx)(GT,{className:`af-row`,checked:n,onChange:t=>ae(e.name,t.target.checked),title:e.description,children:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`shrink-0 text-[13px] ${VU}`,children:e.name}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-[11px] ${UU}`,children:e.description||`无描述`})]})},e.name)})})]})}),(0,p.jsx)(uW,{title:`MCP 工具`,extra:(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[`已选 `,t.tools.length]}),children:o.length===0?(0,p.jsx)(dW,{children:`还没配置 MCP 服务器`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(AD,{value:N,onChange:e=>P(e.target.value),allowClear:!0,size:`middle`,placeholder:`搜索服务器或工具…`,"aria-label":`搜索 MCP 工具`,prefix:(0,p.jsx)(se,{size:12,className:UU}),className:`mb-2`}),ze.length===0?(0,p.jsxs)(dW,{children:[`没有匹配「`,N.trim(),`」的工具`]}):null,(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto af-tree`,children:(0,p.jsx)(jO,{checkable:!0,selectable:!1,expandedKeys:Be,onExpand:e=>L(e),treeData:ze.map(e=>({key:e.name,selectable:!1,title:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`h-[5px] w-[5px] shrink-0 rounded-full ${e.ok?`bg-[#24543F] dark:bg-[#6aa583]`:`bg-[#B4451F] dark:bg-[#e08a6a]`}`}),(0,p.jsx)(`span`,{className:`text-[12px] font-medium ${VU}`,children:e.name}),(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[e.tools.length,` 个工具`]}),!e.ok&&(0,p.jsx)(`span`,{className:`text-[11px] text-[#B4451F] dark:text-[#e08a6a]`,children:`连接失败`})]}),children:e.tools.map(t=>({key:`${e.name}.${t.name}`,title:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`shrink-0 text-[13px] ${VU}`,children:t.name}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-[11px] ${UU}`,children:t.description})]})}))})),checkedKeys:t.tools,onCheck:e=>{let t=Array.isArray(e)?e:e.checked;d({tools:t.filter(e=>String(e).includes(`.`))})}})})]})}),Ne?null:(0,p.jsx)(uW,{title:`上游`,children:K.length===0?(0,p.jsx)(dW,{children:`还没有其它卡片`}):(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto`,children:K.map(e=>{let n=ne.has(e.id),r=!n&&fW(ee,t.id,e.id),i=n?[...ne].filter(t=>t!==e.id):[...ne,e.id];return(0,p.jsx)(GT,{className:`af-row ${r?`af-row-disabled`:``}`,checked:n,disabled:r,onChange:()=>re(i),children:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${VU}`,children:e.label||e.id}),r&&(0,p.jsx)(`span`,{className:`shrink-0 text-[11px] ${UU}`,children:`会成环`})]})},e.id)})})})]}),Le&&(0,p.jsxs)(`div`,{className:`shrink-0 border-t ${WU} bg-[#FAEFE6] px-5 py-3 dark:bg-[#2A1C17]`,children:[(0,p.jsx)(`p`,{className:`text-[12px] text-[#B4451F] dark:text-[#e08a6a]`,children:`这张卡跑完了,等你判断结果`}),(0,p.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`h-8 flex-1 rounded-[4px] bg-[#24543F] text-[13px] font-medium text-white transition-colors hover:bg-[#1D4634] dark:bg-[#3F7A5F] dark:hover:bg-[#4B8B6D]`,children:`通过`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`h-8 flex-1 rounded-[4px] text-[13px] text-[#6b6b66] transition-colors hover:bg-white/60 dark:text-[#a3a39b] dark:hover:bg-[#232421]`,children:`打回重跑`})]})]}),(0,p.jsxs)(`footer`,{className:`shrink-0 border-t ${WU} bg-[#FAFAF7] px-5 py-3 dark:bg-[#1B1C20]`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:h,disabled:l,className:`flex h-8 flex-1 items-center justify-center gap-1.5 rounded-[4px] bg-[#24543F] text-[13px] font-medium text-white transition-colors hover:bg-[#1D4634] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#3F7A5F] dark:hover:bg-[#4B8B6D]`,children:[l?(0,p.jsx)(U,{size:13,className:`animate-spin`}):(0,p.jsx)(ie,{size:13}),l?`运行中…`:`重跑此卡`]}),Ne?null:(0,p.jsxs)(`button`,{type:`button`,onClick:()=>f(`prev`),className:`${oW} flex items-center gap-1`,children:[(0,p.jsx)(F,{size:13}),`加上游`]}),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>f(`next`),className:`${oW} flex items-center gap-1`,children:[(0,p.jsx)(j,{size:13}),`加下游`]})]}),(0,p.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,p.jsxs)(`button`,{type:`button`,onClick:v,disabled:Ne,title:Ne?`根节点是对话入口(人格来源),不能删除`:void 0,className:`flex items-center gap-1.5 rounded-[4px] px-2.5 py-1.5 text-[12px] text-[#B4451F] transition-colors hover:bg-[#FBEFEA] disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-[#e08a6a] dark:hover:bg-[#2A1C17]`,children:[(0,p.jsx)(me,{size:13}),`删除此卡`]})})]})]})}function uW({title:e,extra:t,children:n}){return(0,p.jsxs)(`section`,{className:`mt-3 rounded-xl border p-3 first:mt-1 ${GU}`,children:[(0,p.jsxs)(`div`,{className:`mb-2.5 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-[12px] font-semibold tracking-[0.01em] ${VU}`,children:e}),t]}),n]})}function dW({children:e}){return(0,p.jsx)(`p`,{className:`py-1 text-[12px] leading-[1.6] ${UU}`,children:e})}function fW(e,t,n){if(t===n)return!0;let r=new Set([t]),i=[t];for(;i.length;){let t=i.pop();for(let a of e)if(a.from===t){if(a.to===n)return!0;r.has(a.to)||(r.add(a.to),i.push(a.to))}}return!1}function pW(e){return e===`human`?`人工`:e===`jev`?`jev`:e===`self`?`自评`:e||`系统`}function mW(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var{Text:hW}=PA;function gW({open:e,config:t,servers:n,onClose:r,onSaved:i,onError:a}){let o=t,[s,c]=(0,u.useState)(o?.mock??!1),[l,d]=(0,u.useState)(!1),[f,m]=(0,u.useState)(null),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(a);(0,u.useEffect)(()=>{_.current=a},[a]),(0,u.useEffect)(()=>{e&&c(o?.mock??!1)},[e,o?.mock]),(0,u.useEffect)(()=>{if(!e)return;let t=!1;return g(!0),JA.getBridge().then(e=>{t||m(e)}).catch(e=>{t||_.current(`读取模型通道状态失败:${e.message}`)}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e]);async function v(){if(h)return;g(!0);let[e,t]=await Promise.allSettled([JA.getBridge(),JA.getModels(!0)]);e.status===`fulfilled`?m(e.value):_.current(`读取模型通道状态失败:${e.reason.message}`),t.status===`rejected`&&_.current(`重新读取模型目录失败:${t.reason.message}`),g(!1)}async function y(e){if(l||!t)return;let n=s;c(e),d(!0);try{let t=await JA.putConfig({mock:e}),n=typeof t?.mock==`boolean`?t.mock:e;c(n),i({mock:n})}catch(e){c(n),a(`切换 mock 失败:${e.message}`)}finally{d(!1)}}let b=Object.entries(o?.providers??{}),x=o?.mcpServers??n.map(e=>({name:e.name})),S=o?.skillDirs?.length?o.skillDirs:o?.dshPaths?.skills?[o.dshPaths.skills]:[],C=f?f.healthy?(0,p.jsx)(WO,{color:`success`,style:{marginInlineEnd:0},children:`已连接`}):(0,p.jsx)(WO,{color:`warning`,style:{marginInlineEnd:0},children:`未连接`}):(0,p.jsx)(hW,{type:`secondary`,style:{fontSize:12},children:`读取中…`}),w=f&&(f.lastError||f.reason)||``;return(0,p.jsxs)(PD,{open:e,title:`设置`,width:640,centered:!0,getContainer:()=>document.querySelector(`.af-canvas`)??document.body,onCancel:r,styles:{body:{maxHeight:`calc(100vh - 220px)`,overflowY:`auto`,paddingTop:12}},footer:(0,p.jsx)(oD,{justify:`flex-end`,children:(0,p.jsx)(VS,{onClick:r,children:`关闭`})}),children:[(0,p.jsx)(Vl,{type:`info`,showIcon:!0,title:`模型、MCP 服务器、技能都来自 DSH 的配置。要增删改请到 DSH 的 cordis.patch.yml,AgentFlow 这边只读。`,description:o?.dshPaths?.patch?(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:12,wordBreak:`break-all`},children:[`patch:`,(0,p.jsx)(hW,{code:!0,style:{fontSize:12},children:o.dshPaths.patch})]}):void 0}),(0,p.jsx)(_W,{title:`模型`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[b.length,` 个`]}),children:b.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置模型提供商`}):b.map(([e,t])=>(0,p.jsx)(Rw,{size:`small`,style:{marginBottom:12},title:(0,p.jsx)(hW,{strong:!0,style:{fontSize:14},children:t.label||e}),extra:t.hasKey?(0,p.jsx)(WO,{color:`green`,style:{marginInlineEnd:0},children:`已配置 key`}):(0,p.jsx)(WO,{color:`red`,style:{marginInlineEnd:0},children:`缺 key`}),children:(0,p.jsx)(LE,{size:`small`,column:1,colon:!1,items:[{key:`provider`,label:`provider`,children:(0,p.jsx)(hW,{code:!0,children:e})},{key:`baseURL`,label:`baseURL`,children:(0,p.jsx)(hW,{code:!0,children:t.baseURL||`—`})},{key:`model`,label:`model`,children:(0,p.jsx)(hW,{code:!0,children:t.model||`—`})}]})},e))}),(0,p.jsxs)(_W,{title:`模型通道`,extra:(0,p.jsx)(VS,{size:`small`,loading:h,onClick:()=>void v(),children:`刷新`}),children:[f&&!f.healthy&&(0,p.jsx)(Vl,{type:`warning`,showIcon:!0,style:{marginBottom:10},title:`DSH 未运行或插件未加载,画布不能调模型`}),(0,p.jsx)(LE,{size:`small`,bordered:!0,column:1,colon:!1,items:[{key:`status`,label:`状态`,children:C},{key:`infoPath`,label:`发现文件`,children:(0,p.jsx)(hW,{code:!0,style:{fontSize:12,wordBreak:`break-all`,userSelect:`text`},title:f?.dir,children:f?.infoPath||`—`})},{key:`version`,label:`版本`,children:f?.version==null?`—`:(0,p.jsx)(hW,{code:!0,children:f.version})},{key:`startedAt`,label:`启动时间`,children:vW(f?.startedAt??null)},{key:`providers`,label:`provider 数`,children:f?String(f.providers):`—`},{key:`modelCount`,label:`模型数`,children:f?String(f.modelCount):`—`},{key:`lastError`,label:`最后错误`,children:w?(0,p.jsx)(hW,{type:`danger`,style:{fontSize:12,wordBreak:`break-all`},children:w}):(0,p.jsx)(hW,{type:`secondary`,children:`—`})}]})]}),(0,p.jsx)(_W,{title:`MCP 服务器`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[x.length,` 个`]}),children:x.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置 MCP 服务器`}):(0,p.jsx)(LE,{size:`small`,bordered:!0,column:1,colon:!1,items:x.map(e=>({key:e.name,label:(0,p.jsx)(hW,{strong:!0,style:{fontSize:13},children:e.name}),children:e.kind?(0,p.jsx)(WO,{style:{marginInlineEnd:0},children:e.kind}):(0,p.jsx)(hW,{type:`secondary`,children:`—`})}))})}),(0,p.jsx)(_W,{title:`技能目录`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[S.length,` 个`]}),children:S.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置技能目录`}):(0,p.jsx)(oD,{vertical:!0,gap:6,children:S.map(e=>(0,p.jsx)(hW,{code:!0,style:{fontSize:12,wordBreak:`break-all`},children:e},e))})}),(0,p.jsx)(_W,{title:`运行模式`,children:(0,p.jsx)(Rw,{size:`small`,children:(0,p.jsxs)(oD,{align:`center`,justify:`space-between`,gap:16,children:[(0,p.jsxs)(`div`,{style:{minWidth:0},children:[(0,p.jsx)(hW,{strong:!0,style:{display:`block`,fontSize:15},children:`mock 模式`}),(0,p.jsx)(hW,{type:`secondary`,style:{display:`block`,fontSize:12},children:`AgentFlow 自己的开关,不属于 DSH 配置。打开后不真正调用模型。`})]}),(0,p.jsx)(UD,{checked:s,loading:l,disabled:!t,onChange:e=>void y(e)})]})})})]})}function _W({title:e,extra:t,children:n}){return(0,p.jsxs)(`section`,{style:{marginTop:20},children:[(0,p.jsxs)(oD,{align:`center`,justify:`space-between`,gap:8,style:{marginBottom:8},children:[(0,p.jsx)(hW,{strong:!0,style:{fontSize:13},children:e}),t]}),n]})}function vW(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return`—`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var{Text:yW}=PA,bW=`'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', ui-monospace, monospace`;function xW({open:e,boardId:t,boardName:n,onClose:r}){let{token:i}=ek.useToken(),[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(null),[l,d]=(0,u.useState)(!1),[f,m]=(0,u.useState)(``);(0,u.useEffect)(()=>{e&&(o(null),c(null),d(!1),m(n||``))},[e,n]);async function h(){if(!l){d(!0),c(null),o(null);try{let e=await JA.exportPreset(t,f.trim());o(e)}catch(e){let t=e.message||`未知错误`;t.includes(`HTTP 404`)?c({title:`暂不可用`,detail:`后端还没有这个接口(POST /api/export/preset),等后端上线后再试。`}):t.includes(`HTTP 409`)?c({title:`自定义目录已存在,换个目录`,detail:t}):c({title:`生成失败`,detail:t})}finally{d(!1)}}}let g={border:`1px solid ${i.colorBorderSecondary}`,borderRadius:8,background:i.colorFillTertiary,padding:`10px 12px`,fontFamily:bW,fontSize:12,lineHeight:1.7,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:i.colorText};return(0,p.jsxs)(PD,{open:e,title:`导出为 DSH 预设`,width:720,centered:!0,getContainer:()=>document.querySelector(`.af-canvas`)??document.body,onCancel:r,styles:{body:{maxHeight:`calc(100vh - 240px)`,overflowY:`auto`}},footer:(0,p.jsxs)(oD,{justify:`flex-end`,gap:8,children:[(0,p.jsx)(VS,{onClick:r,children:`关闭`}),(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(z,{size:14}),loading:l,onClick:()=>void h(),children:`生成`})]}),children:[(0,p.jsx)(Vl,{type:`info`,showIcon:!0,title:`把这张画布编译成 DSH 预设,直接写进 dsh-plugin-agentflow 插件包。重启 DSH 后,新会话的预设列表里就能选到它:主 agent 会先和你对齐需求,再按画布结构分层下发子 agent(提示词驱动,不保证严格按 DAG 执行)。`,style:{marginBottom:16}}),(0,p.jsxs)(`div`,{style:{marginBottom:16},children:[(0,p.jsx)(yW,{style:{fontSize:12,display:`block`,marginBottom:6},children:`预设名称`}),(0,p.jsx)(AD,{value:f,onChange:e=>m(e.target.value),placeholder:`在 DSH 预设列表里显示的名字`,maxLength:40,disabled:!!a}),(0,p.jsx)(yW,{type:`secondary`,style:{fontSize:11},children:`只改显示名,预设 id 不变(重复导出还是覆盖同一个预设)。`})]}),s&&(0,p.jsx)(Vl,{type:`error`,showIcon:!0,title:s.title,description:s.detail?(0,p.jsx)(yW,{style:{fontSize:12,fontFamily:bW,wordBreak:`break-all`},children:s.detail}):void 0,style:{marginBottom:16}}),a&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Vl,{type:`success`,showIcon:!0,title:a.replaced?`预设已更新`:`预设已写入插件`,description:(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{style:{marginBottom:6},children:[`已写进 profile 的 `,(0,p.jsx)(`b`,{children:`cordis.patch.yml`}),`(用标记段包裹,重新导出整段替换)。`,(0,p.jsx)(`b`,{children:`重启 DSH 后`}),`,新会话的预设列表里就能选到它。`]}),(0,p.jsxs)(`div`,{style:{marginBottom:4},children:[`预设 id:`,(0,p.jsx)(yW,{code:!0,style:{fontSize:12},children:a.presetId})]}),(0,p.jsxs)(`div`,{children:[`文件:`,(0,p.jsx)(yW,{code:!0,copyable:!0,style:{fontSize:12,wordBreak:`break-all`},children:a.file})]})]}),style:{marginBottom:12}}),(a.addedOrchestrator||a.personaSource)&&(0,p.jsxs)(`div`,{style:{marginBottom:16},children:[(0,p.jsx)(yW,{strong:!0,style:{display:`block`,fontSize:13,marginBottom:6},children:`调度与人设`}),(0,p.jsxs)(oD,{vertical:!0,gap:4,children:[a.addedOrchestrator&&(0,p.jsxs)(yW,{style:{fontSize:13},children:[`已自动补充调度卡:`,(0,p.jsx)(yW,{strong:!0,children:a.addedOrchestrator.label})]}),a.personaSource&&(0,p.jsxs)(yW,{style:{fontSize:13},type:`secondary`,children:[`人格来源:`,CW(a.personaSource)]})]})]}),(0,p.jsxs)(`div`,{style:{marginBottom:16},children:[(0,p.jsx)(yW,{strong:!0,style:{display:`block`,fontSize:13,marginBottom:6},children:`写入文件`}),(0,p.jsx)(WO,{style:{marginInlineEnd:0,fontFamily:bW},children:a.file})]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(oD,{align:`baseline`,justify:`space-between`,style:{marginBottom:6},children:[(0,p.jsx)(yW,{strong:!0,style:{fontSize:13},children:`预览人格`}),a?.personaPreview&&(0,p.jsxs)(yW,{type:`secondary`,style:{fontSize:11},children:[a.personaPreview.length,` 字符`]})]}),(0,p.jsx)(`pre`,{style:{...g,margin:0,maxHeight:320,overflowY:`auto`},children:a?.personaPreview||`生成后会在这里显示完整的人格文本。`})]})]})}var SW={orchestrator:`调度(根)节点的人格`,"single-card":`单卡片画布(唯一那张卡)`,"auto-orchestrator":`自动补充的调度卡`};function CW(e){return SW[e]??e}var wW=`border-[#E3E4DF] dark:border-[#262724]`,TW=`text-[#1B1B18] dark:text-[#e8e8e4]`,EW=`text-[#6b6b66] dark:text-[#8b8b85]`,DW=`text-[#8b8b85] dark:text-[#8b8b85]`;function OW(){try{let e=globalThis.__AGENTFLOW_HOST__;return e&&typeof e==`object`?e:null}catch{return null}}function kW(){return OW()?.remote===!0}function AW(){let[e,t]=(0,u.useState)(`list`),[n,r]=(0,u.useState)([]),[i,a]=(0,u.useState)([]),[o,s]=(0,u.useState)({}),[c,l]=(0,u.useState)(!0),[d,f]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)(!1),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)(``),M=(0,u.useRef)(!1),P=(0,u.useRef)(!1),[F,I]=(0,u.useState)([]),[L,R]=(0,u.useState)([]),[B,H]=(0,u.useState)(null),[W,ee]=(0,u.useState)(null),[te,ne]=(0,u.useState)(null),[re,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)(!1),[se,J]=(0,u.useState)(!1),[le,ue]=(0,u.useState)(!1),de=(0,u.useRef)(!1),pe=(0,u.useRef)(!1),me=(0,u.useCallback)(()=>{pe.current=!0,J(!0)},[]),he=(0,u.useCallback)(()=>{pe.current=!1,J(!1)},[]),ge=(0,u.useRef)(0),_e=(0,u.useRef)(null);(0,u.useEffect)(()=>{_e.current=m},[m]),(0,u.useEffect)(()=>{if(!m||e!==`board`)return;let t=window.setTimeout(()=>{JA.putBoard(m.id,m).catch(e=>{console.warn(`[agentflow] 自动保存失败:`,e)}),r(e=>e.map(e=>e.id===m.id?{...e,presetOutdated:!0}:e))},200);return()=>window.clearTimeout(t)},[m,e]),(0,u.useEffect)(()=>{let e=()=>{let e=_e.current;if(e)try{fetch(WA(`/api/boards/${encodeURIComponent(e.id)}`),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({board:e}),keepalive:!0}).catch(()=>{})}catch{}};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let[Y,ve]=(0,u.useState)(()=>{let e=OW();if(e?.remote){if(e.theme===`dark`)return!0;if(e.theme===`light`)return!1;try{return window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}try{localStorage.removeItem(`agentflow-theme`)}catch{}try{let e=sessionStorage.getItem(`agentflow-theme`);if(e===`dark`)return!0;if(e===`light`)return!1}catch{}try{let e=new URLSearchParams(window.location.search).get(`theme`);if(e===`dark`)return!0;if(e===`light`)return!1}catch{}try{return window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}});(0,u.useEffect)(()=>{if(kW())window.dispatchEvent(new Event(`themechange`));else{document.documentElement.classList.toggle(`dark`,Y);try{sessionStorage.setItem(`agentflow-theme`,Y?`dark`:`light`)}catch{}window.dispatchEvent(new Event(`themechange`))}},[Y]),(0,u.useEffect)(()=>{if(!kW())return;let e=e=>{let t=e.detail?.theme;t===`dark`?ve(!0):t===`light`&&ve(!1)};return window.addEventListener(`agentflow-theme`,e),()=>window.removeEventListener(`agentflow-theme`,e)},[]);let[ye,be]=(0,u.useState)(null),xe=(0,u.useRef)(null),X=(0,u.useCallback)((e,t=`ok`)=>{be({msg:e,kind:t}),xe.current&&window.clearTimeout(xe.current),xe.current=window.setTimeout(()=>be(null),3200)},[]),Se=(0,u.useCallback)((e,t)=>{h(n=>n&&{...n,nodes:n.nodes.map(n=>n.id===e?{...n,...t}:n)})},[]),Ce=(0,u.useRef)(null),we=(0,u.useRef)(null);(0,u.useEffect)(()=>{Ce.current=d},[d]),(0,u.useEffect)(()=>{_(m?.name??``)},[m?.id,m?.name]);let Te=(0,u.useCallback)(async(e=!1)=>{e||l(!0);let[t,n]=await Promise.allSettled([JA.listBoards(),JA.listPresets()]);if(t.status===`fulfilled`){let e=t.value.boards;r(e);let n=await Promise.allSettled(e.map(e=>JA.getBoard(e.id))),i={};n.forEach((t,n)=>{t.status===`fulfilled`&&(i[e[n].id]=MW(t.value.board))}),s(i)}else X(`加载画布列表失败:${t.reason.message}`,`err`);n.status===`fulfilled`?a(n.value.presets):X(`加载预设列表失败:${n.reason.message}`,`err`),e||l(!1)},[X]);(0,u.useEffect)(()=>{Te(),JA.getSkills().then(e=>I(e.skills)).catch(()=>{}),JA.getMcp().then(e=>R(e.servers)).catch(()=>{}),JA.getConfig().then(H).catch(()=>{}),JA.getModels().then(ee).catch(()=>{}),JA.getBridge().then(ne).catch(()=>{})},[Te]);let Ee=(0,u.useRef)(0);(0,u.useEffect)(()=>{v&&(Date.now()-Ee.current<3e4||(Ee.current=Date.now(),JA.getModels(!0).then(ee).catch(()=>{}),JA.getBridge().then(ne).catch(()=>{})))},[v]);let{running:De,run:Oe,stop:ke}=YA((0,u.useCallback)(e=>{let t=we.current!=null&&Ce.current!==we.current;if((e.type===`run:end`||e.type===`run:error`)&&(we.current=null),!t)switch(e.type){case`node:start`:Se(e.id,{status:`running`});break;case`node:delta`:h(t=>t&&{...t,nodes:t.nodes.map(t=>t.id===e.id?{...t,delta:(t.delta||``)+e.chunk}:t)});break;case`node:done`:Se(e.id,{status:e.status??`done`,content:e.content,usage:e.usage,verdict:e.verdict??null,error:null,delta:void 0});break;case`node:failed`:Se(e.id,{status:`failed`,error:`该节点所有模型都失败`});break;case`node:blocked`:Se(e.id,{status:`blocked`});break;case`node:retry`:h(t=>t&&{...t,nodes:t.nodes.map(t=>t.id===e.id?{...t,delta:void 0}:t)}),X(`${e.id} 换 ${e.model} 重试:${e.error}`,`err`);break;case`run:end`:{let{done:t,failed:n,blocked:r,review:i}=e.summary,a=[`完成 ${t.length}`];i.length&&a.push(`待确认 ${i.length}`),n.length&&a.push(`失败 ${n.length}`),r.length&&a.push(`阻塞 ${r.length}`),X(a.join(`,`),n.length||r.length?`err`:`ok`);break}case`run:error`:X(`运行出错:${e.error}`,`err`)}},[Se,X])),Ae=(0,u.useCallback)(e=>{let t=Ce.current;t&&(we.current=t,Oe(e,t))},[Oe]),je=(0,u.useCallback)(()=>{we.current=null,ke()},[ke]),Me=(0,u.useCallback)(async e=>{let n=++ge.current;t(`board`),f(e),h(null),_(``),y(null),oe(!1),he();let r=await JA.getBoard(e).then(e=>({status:`fulfilled`,value:e})).catch(e=>({status:`rejected`,reason:e}));n===ge.current&&(r.status===`rejected`?(X(`打开画布失败:${r.reason.message}`,`err`),t(`list`),f(null),he(),Te(!0)):h(r.value.board))},[Te,X]),Ne=(0,u.useRef)((()=>{let e=OW();return e?.remote&&e.boardId?e.boardId:typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`)})());(0,u.useEffect)(()=>{let e=Ne.current;e&&(Ne.current=null,Me(e))},[Me]),(0,u.useEffect)(()=>{if(!kW())return;let e=e=>{let t=e.detail?.boardId;t&&t!==Ce.current&&Me(t)};return window.addEventListener(`agentflow-board`,e),()=>window.removeEventListener(`agentflow-board`,e)},[Me]);let Pe=(0,u.useCallback)(()=>{ge.current+=1,t(`list`),h(null),f(null),y(null),oe(!1),he(),Te(!0)},[Te]);function Fe(){Pe()}function Ie(e){Me(e)}let Le=(0,u.useCallback)(async()=>{let e=_e.current;if(!e)return!1;try{return await JA.putBoard(e.id,e),he(),!0}catch(e){return X(`保存画布失败:${e.message}`,`err`),!1}},[X,he]),Re=(0,u.useCallback)(async()=>{let e=_e.current;if(!e||de.current)return!1;de.current=!0,ue(!0);try{return await JA.putBoard(e.id,e),await JA.exportPreset(e.id,e.name),he(),r(t=>t.map(t=>t.id===e.id?{...t,name:e.name,nodeCount:e.nodes.length,presetOutdated:!1,updatedAt:Date.now()}:t)),X(`已保存,预设已更新`),!0}catch(e){return X(`保存失败:${e.message}`,`err`),!1}finally{de.current=!1,ue(!1)}},[X,he]);(0,u.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&String(t.key).toLowerCase()===`s`&&(t.preventDefault(),e===`board`&&window.setTimeout(()=>void Re(),0))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[Re,e]);let ze=(0,u.useCallback)(async e=>{m&&(!pe.current||await Le())&&Ae(e)},[m,Le,Ae]),Be=(0,u.useCallback)(async()=>{m&&(!pe.current||await Le())&&oe(!0)},[m,Le]),Ve=(0,u.useCallback)((e,t)=>{Se(e,t),me()},[Se]),He=(0,u.useCallback)(e=>{h(t=>t&&{...t,edges:e}),me()},[]),Ue=(0,u.useCallback)((e,t,n)=>{m&&(h({...m,nodes:m.nodes.map(r=>r.id===e?{...r,x:t,y:n}:r)}),me())},[m]),We=(0,u.useCallback)((e,t)=>{if(!m)return;let n=m.nodes.find(t=>t.id===e);if(!n)return;let r=W?.providers.find(e=>e.models.length),i=n.provider||r?.id||``,a=n.model||r?.models[0]?.id||``,o=jW(m.nodes),s={id:o,label:t===`next`?`下游卡片`:`上游卡片`,type:`llm`,x:t===`next`?n.x+360:n.x-360,y:n.y,provider:i,model:a,reasoningEffort:``,fallback:[],fallbackEfforts:{},task:``,criteria:``,skills:[],tools:[],verify:``,content:``,status:`idle`,usage:null,error:null,verdict:null};h({...m,nodes:[...m.nodes,s],edges:[...m.edges,t===`next`?{from:e,to:o}:{from:o,to:e}]}),y(o),me(),X(t===`next`?`已派生下游卡片(未保存)`:`已添加上游卡片(未保存)`)},[m,W,X]),Ge=(0,u.useCallback)((e,t)=>{m&&e!==t&&(m.nodes.find(e=>e.id===t)?.type===`orchestrator`?X(`根节点是对话入口,不能有上游节点`,`err`):m.edges.some(n=>n.from===e&&n.to===t)||(PW(m.edges,e,t)?X(`这条连线会形成环,已忽略`,`err`):(h({...m,edges:[...m.edges,{from:e,to:t}]}),me())))},[m,X]),Ke=(0,u.useCallback)(e=>{m&&(h({...m,nodes:m.nodes.filter(t=>t.id!==e),edges:m.edges.filter(t=>t.from!==e&&t.to!==e)}),y(null),me(),X(`已删除(未保存)`))},[m,X]),qe=(0,u.useCallback)(async(e,t)=>{if(!pe.current||await Le())try{let n=await JA.verify(e,t,void 0,Ce.current);Se(e,{status:n.status,verdict:n.verdict}),X(t?`已通过`:`已打回,可以改完再跑`)}catch(e){X(`操作失败:${e.message}`,`err`)}},[Se,X,Le]),Je=(0,u.useMemo)(()=>m?.nodes.find(e=>e.id===v)??null,[m,v]),Ye=(0,u.useMemo)(()=>new Set(n.map(e=>e.presetId).filter(e=>!!e)),[n]),Xe=(0,u.useMemo)(()=>i.filter(e=>!Ye.has(e.id)),[i,Ye]);function Ze(){T(``),C(!0)}async function Qe(){let e=w.trim();if(e&&!E){D(!0);try{let n=await JA.createBoard({name:e});ge.current+=1,C(!1),T(``),h(n.board),f(n.board.id),y(null),he(),t(`board`),Te(!0)}catch(e){X(`新建画布失败:${e.message}`,`err`)}finally{D(!1)}}}async function $e(e){if(!b){x(e.id);try{let n=await JA.importPreset(e.id);X(n.reused?`已有这张画布:${e.name}`:`已从预设创建画布:${e.name}`),ge.current+=1,h(n.board),f(n.board.id),y(null),he(),t(`board`),Te(!0)}catch(e){let t=e.message;t.includes(`HTTP 501`)?X(`创建画布功能还没上线(服务端 P1 未完成)`,`err`):X(`创建画布失败:${t}`,`err`)}finally{x(null)}}}function et(e){k(e.id),j(e.name)}async function tt(e){if(O!==e.id)return;let t=M.current;if(M.current=!1,k(null),t){j(e.name);return}let n=A.trim();if(n&&n!==e.name)try{let t=await JA.patchBoard(e.id,{name:n});r(r=>r.map(r=>r.id===e.id?{...r,name:n,updatedAt:t.meta?.updatedAt??r.updatedAt}:r)),m?.id===e.id&&h(e=>e&&{...e,name:n}),X(`画布已重命名`)}catch(e){X(`重命名失败:${e.message}`,`err`)}}async function nt(e){if(n.length<=1)X(`至少要保留一张画布`,`err`);else if(window.confirm(`删除画布《${e.name}》?里面的节点会一起删掉,且不可恢复。`))try{await JA.deleteBoard(e.id),X(`画布已删除`),await Te(!0)}catch(e){X(`删除失败:${e.message}`,`err`)}}async function rt(){if(!m)return;let e=P.current;if(P.current=!1,e){_(m.name);return}let t=g.trim();if(!t)_(m.name);else if(t!==m.name)try{let e=await JA.patchBoard(m.id,{name:t});h(e=>e&&{...e,name:t}),r(n=>n.map(n=>n.id===m.id?{...n,name:t,updatedAt:e.meta?.updatedAt??n.updatedAt}:n)),X(`画布已重命名`)}catch(e){_(m.name),X(`重命名失败:${e.message}`,`err`)}}let it=(0,u.useRef)(null);return(0,p.jsx)(Md,{locale:UA.default,getPopupContainer:()=>it.current??document.body,theme:{algorithm:Y?ek.darkAlgorithm:ek.defaultAlgorithm,token:{colorPrimary:`#24543F`,borderRadius:7,fontSize:15,fontFamily:`-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', ui-sans-serif, sans-serif`},components:{Drawer:{paddingLG:20},Modal:{borderRadiusLG:12},Card:{borderRadiusLG:10}}},children:(0,p.jsxs)(`div`,{ref:it,className:`af-canvas flex h-full flex-col${Y?` dark`:``}`,children:[e===`list`?(0,p.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-3 border-b ${wW} bg-[#FCFCFA] px-5 dark:bg-[#17181b]`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`grid h-7 w-7 place-items-center rounded-[4px] bg-[#24543F] text-white`,children:`◈`}),(0,p.jsx)(`span`,{className:`text-[17px] font-semibold tracking-tight ${TW}`,children:`AgentFlow`})]}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(K,{size:14}),onClick:Ze,children:`新建画布`}),(0,p.jsx)(VS,{icon:Y?(0,p.jsx)(fe,{size:14}):(0,p.jsx)(G,{size:14}),onClick:()=>ve(e=>!e),title:Y?`切到浅色`:`切到深色`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(ce,{size:14}),onClick:()=>ie(!0),children:`设置`})]})]}):(0,p.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b ${wW} bg-[#FCFCFA] px-4 dark:bg-[#17181b]`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:Fe,title:`返回画布列表`,className:`flex shrink-0 items-center gap-1 rounded-[4px] px-2 py-1.5 text-[12px] transition-colors hover:bg-[#EFEFEA] dark:hover:bg-[#232421] ${EW}`,children:[(0,p.jsx)(N,{size:14}),`返回列表`]}),(0,p.jsx)(`div`,{className:`h-5 w-px shrink-0 bg-[#E3E4DF] dark:bg-[#2c2d29]`}),(0,p.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),onBlur:()=>void rt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P.current=!0,e.currentTarget.blur())},disabled:!m,placeholder:`画布名称`,"aria-label":`画布名称`,className:`min-w-0 max-w-[280px] flex-1 rounded-[3px] border-0 bg-transparent px-1 py-1 text-[16px] font-semibold tracking-tight outline-none placeholder:text-[#a8a8a0] focus-visible:ring-2 focus-visible:ring-[#24543F]/30 disabled:bg-transparent dark:placeholder:text-[#6f6f68] dark:focus-visible:ring-[#6aa583]/40 ${TW}`}),se&&(0,p.jsx)(`span`,{title:`有未保存的修改`,"aria-label":`有未保存的修改`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[#B4451F] dark:bg-[#e08a6a]`}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,p.jsx)(VS,{icon:(0,p.jsx)(q,{size:14}),disabled:!m,loading:le,onClick:()=>void Re(),title:`保存画布并更新预设(⌘S / Ctrl+S)`,children:`保存`}),De?(0,p.jsx)(VS,{danger:!0,icon:(0,p.jsx)(U,{size:14,className:`animate-spin`}),onClick:je,children:`停止`}):(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(V,{size:14}),disabled:!m,onClick:()=>void ze(),title:`先保存,再跑一遍验证(会真实调用模型)`,children:`验证 AgentFlow`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(z,{size:14}),disabled:!m,onClick:()=>void Be(),children:`导出预设`}),(0,p.jsx)(VS,{icon:Y?(0,p.jsx)(fe,{size:14}):(0,p.jsx)(G,{size:14}),onClick:()=>ve(e=>!e),title:Y?`切到浅色`:`切到深色`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(ce,{size:14}),onClick:()=>ie(!0),children:`设置`})]})]}),e===`list`?(0,p.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-[#F4F5F2] px-6 py-7 dark:bg-[#111214]`,children:(0,p.jsxs)(`div`,{className:`mx-auto w-full max-w-[1080px]`,children:[(0,p.jsxs)(`div`,{className:`mb-5`,children:[(0,p.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight ${TW}`,children:`画布`}),(0,p.jsx)(`p`,{className:`mt-1 text-[12px] leading-[1.6] ${EW}`,children:`每张画布对应一个 DSH 预设;编辑会自动保存,点「保存」才会更新/生成预设。`})]}),c&&n.length===0?(0,p.jsx)(`div`,{className:`py-16 text-center text-[13px] ${EW}`,children:`正在加载画布…`}):(0,p.jsxs)(p.Fragment,{children:[n.length===0?(0,p.jsx)(`div`,{className:`rounded-[8px] border border-dashed ${wW} py-14 text-center text-[13px] ${EW}`,children:`还没有画布,点右上角「新建画布」开始。`}):(0,p.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>{let t=e.presetId?i.find(t=>t.id===e.presetId):null;return(0,p.jsxs)(`article`,{className:`flex min-h-[150px] flex-col rounded-[8px] border ${wW} bg-[#FCFCFA] p-4 dark:bg-[#17181B]`,children:[(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[O===e.id?(0,p.jsx)(AD,{size:`small`,autoFocus:!0,maxLength:60,value:A,onChange:e=>j(e.target.value),onBlur:()=>void tt(e),onPressEnter:e=>e.currentTarget.blur(),onKeyDown:e=>{e.key===`Escape`&&(M.current=!0,e.currentTarget.blur())},"aria-label":`重命名画布 ${e.name}`}):(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e.id),title:e.name,className:`block max-w-full text-left`,children:(0,p.jsx)(`h2`,{className:`truncate text-[15px] font-semibold ${TW}`,children:e.name})}),(0,p.jsxs)(`p`,{className:`mt-1 text-[11px] leading-[1.6] ${DW}`,children:[e.nodeCount,` 个节点 · 更新于 `,NW(e.updatedAt)]}),o[e.id]!==void 0&&(0,p.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] leading-[1.6] ${EW}`,title:o[e.id]||`没有调度卡,首次导出会自动补一张`,children:[`对话入口:`,o[e.id]||`未设置(首次导出会自动补一张调度卡)`]})]}),(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,p.jsx)(WO,{color:t?`blue`:`default`,style:{marginInlineEnd:0},children:t?t.name:`自定义`}),e.presetOutdated&&(0,p.jsx)(WO,{color:`orange`,style:{marginInlineEnd:0},children:`预设未更新`}),e.hasDraft&&(0,p.jsx)(WO,{color:`gold`,style:{marginInlineEnd:0},children:`草稿`})]})]}),(0,p.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-1 pt-3`,children:[(0,p.jsx)(VS,{size:`small`,type:`primary`,onClick:()=>Ie(e.id),children:`编辑`}),(0,p.jsx)(VS,{size:`small`,type:`text`,onClick:()=>et(e),children:`重命名`}),(0,p.jsx)(VS,{size:`small`,type:`text`,danger:!0,disabled:n.length<=1,title:n.length<=1?`至少要保留一张画布`:void 0,onClick:()=>void nt(e),children:`删除`})]})]},e.id)})}),Xe.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`mb-3 mt-8 flex flex-wrap items-baseline gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-[13px] font-semibold ${TW}`,children:`还没有画布的预设`}),(0,p.jsx)(`span`,{className:`text-[11px] ${DW}`,children:`从预设生成一张单卡片画布,再继续编辑`})]}),(0,p.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Xe.map(e=>(0,p.jsxs)(`article`,{className:`flex min-h-[150px] flex-col rounded-[8px] border border-dashed ${wW} bg-[#F9F9F6] p-4 dark:bg-[#151617]`,children:[(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold ${TW}`,title:e.name,children:e.name}),(0,p.jsx)(WO,{style:{marginInlineEnd:0,flexShrink:0},children:e.source===`bundle`?`bundle`:`自定义`})]}),(0,p.jsx)(`p`,{className:`mt-1 line-clamp-3 text-[12px] leading-[1.6] ${EW}`,children:e.description||`没有描述`}),(0,p.jsx)(`div`,{className:`mt-auto pt-3`,children:(0,p.jsx)(VS,{size:`small`,loading:b===e.id,onClick:()=>void $e(e),children:`创建画布`})})]},e.id))})]})]})]})}):(0,p.jsxs)(`main`,{className:`relative min-h-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`pointer-events-none absolute left-4 top-[12px] z-10 flex items-center gap-1.5 rounded-[4px] bg-[#FCFCFA]/90 px-2 py-1 text-[11px] text-[#6b6b66] dark:bg-[#17181b]/90 dark:text-[#8b8b85]`,children:[(0,p.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full`,style:{background:B?B.mock?`#B4451F`:`#24543F`:`#b9bcb4`}}),B?B.mock?`mock`:`real`:`连接中`]}),m?(0,p.jsx)(BU,{board:m,selectedId:v,running:De,onSelect:y,onMove:Ue,onDerive:We,onConnect:Ge}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-[13px] text-[#8a93a3]`,children:`正在加载画布…`})]}),e===`board`&&m&&Je&&(0,p.jsx)(sW,{node:Je,nodes:m.nodes,edges:m.edges,boardId:m.id,skills:F,servers:L,catalog:W,bridge:te,running:De,onPatch:e=>Ve(Je.id,e),onDerive:e=>We(Je.id,e),onVerify:e=>void qe(Je.id,e),onEdgesChange:He,onRefreshModels:()=>{Ee.current=Date.now(),JA.getModels(!0).then(ee).catch(e=>X(`刷新模型失败:${e.message}`,`err`)),JA.getBridge().then(ne).catch(()=>{})},onRerun:()=>void ze([Je.id]),onDelete:()=>void Ke(Je.id),onClose:()=>y(null)}),(0,p.jsx)(gW,{open:re,config:B,servers:L,onClose:()=>ie(!1),onSaved:e=>{H(t=>t&&{...t,mock:e.mock}),JA.getMcp().then(e=>R(e.servers)).catch(()=>{}),X(`设置已保存`)},onError:e=>X(e,`err`)}),(0,p.jsx)(xW,{open:ae,boardId:d,boardName:g,onClose:()=>oe(!1)}),(0,p.jsx)(PD,{open:S,title:`新建画布`,centered:!0,getContainer:()=>it.current??document.body,okText:`创建`,cancelText:`取消`,confirmLoading:E,okButtonProps:{disabled:!w.trim()},onOk:()=>void Qe(),onCancel:()=>C(!1),children:(0,p.jsx)(AD,{autoFocus:!0,maxLength:60,placeholder:`画布名称,例如「活动文案」`,value:w,onChange:e=>T(e.target.value),onPressEnter:()=>{w.trim()&&!E&&Qe()}})}),ye&&(0,p.jsx)(`div`,{className:`absolute bottom-6 left-1/2 z-50 -translate-x-1/2 rounded-lg px-4 py-2 text-[13px] shadow-lg ${ye.kind===`err`?`bg-[#ffebee] text-[#c62828] dark:bg-[#3a1b1f] dark:text-[#ff9a9a]`:`bg-[#1C1C1A] text-white dark:bg-[#e7e9ee] dark:text-[#0f1116]`}`,children:ye.msg})]})})}function jW(e){let t=`n-${Date.now().toString(36)}`,n=t,r=2;for(;e.some(e=>e.id===n);)n=`${t}-${r++}`;return n}function MW(e){let t=e.nodes.find(e=>e.type===`orchestrator`)??(e.nodes.length===1?e.nodes[0]:null);return t?t.label||t.id:null}function NW(e){if(!e)return`—`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function PW(e,t,n){let r=new Set,i=[n];for(;i.length;){let n=i.pop();if(n===t)return!0;if(!r.has(n)){r.add(n);for(let t of e)t.from===n&&i.push(t.to)}}return!1}var FW=`http://127.0.0.1:8791`;function IW(e){return String(e??``).trim().replace(/\/+$/,``)}function LW(e){let t=IW(e);return t&&(FW=t),FW}function RW(){return FW}function zW(){try{if(document.body&&document.body.hasAttribute(`data-ds-dark-theme`))return`dark`}catch{}try{if(document.documentElement.classList.contains(`dark`))return`dark`}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function BW(e){let t=zW(),n=()=>{let n=zW();n!==t&&(t=n,e(n))},r=[];try{if(typeof MutationObserver<`u`){let e=new MutationObserver(n);document.body&&(e.observe(document.body,{attributes:!0,attributeFilter:[`data-ds-dark-theme`,`class`]}),r.push(e));let t=new MutationObserver(n);t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`]}),r.push(t)}}catch{}let i=null,a=()=>n();try{i=window.matchMedia(`(prefers-color-scheme: dark)`),i.addEventListener(`change`,a)}catch{i=null}return window.addEventListener(`focus`,n),()=>{for(let e of r)e.disconnect();if(i)try{i.removeEventListener(`change`,a)}catch{}window.removeEventListener(`focus`,n)}}var VW=`__AGENTFLOW_HOST__`,HW=`data-agentflow-style`,UW=[0,1e3,2500],WW=6e3,GW=2e3;function KW(){try{let e=globalThis[VW];return e&&typeof e==`object`?e:null}catch{return null}}function qW(e){let t={apiBase:e.apiBase,theme:e.theme,boardId:e.boardId,remote:!0};return globalThis[VW]=t,t}var JW=`
|
|
339
|
+
`,aW=`w-full rounded-lg border border-[#E1E2DD] bg-[#FCFCFA] px-2.5 py-2 text-[13px] leading-[1.65] text-[#1B1B18] outline-none transition-colors placeholder:text-[#9a9a92] focus:border-[#24543F] focus:bg-white dark:border-[#33353B] dark:bg-[#17181B] dark:text-[#EDEDE8] dark:focus:border-[#6aa583] dark:focus:bg-[#1B1C20]`,oW=`rounded-[4px] px-2.5 py-1.5 text-[12px] text-[#5b6472] transition-colors hover:bg-[#EFEFEA] dark:text-[#a3a39b] dark:hover:bg-[#232421]`;function sW(e){return(0,p.jsxs)(`aside`,{className:`af-panel absolute bottom-0 right-0 top-14 z-30 flex w-[420px] flex-col border-l border-[#E3E4DF] bg-[#FCFCFA] dark:border-[#262724] dark:bg-[#17181B]`,role:`complementary`,"aria-label":`节点详情`,children:[(0,p.jsx)(`style`,{children:iW}),(0,p.jsx)(lW,{...e},e.node.id)]})}function cW(e,...t){let n=e.trim().toLowerCase();return!n||t.some(e=>String(e??``).toLowerCase().includes(n))}function lW(e){let{node:t,nodes:n,edges:r,boardId:i,skills:a,servers:o,catalog:s,bridge:c,running:l,onPatch:d,onDerive:f,onVerify:m,onRerun:h,onRefreshModels:g,onEdgesChange:_,onDelete:v,onClose:y}=e,[b,x]=(0,u.useState)(t.label),[S,C]=(0,u.useState)(t.task),[w,T]=(0,u.useState)(t.criteria),[E,D]=(0,u.useState)(QU),[O,k]=(0,u.useState)(0),[A,M]=(0,u.useState)(``),[N,P]=(0,u.useState)(``),[I,L]=(0,u.useState)(null),R=(0,u.useRef)(null),z=(0,u.useRef)(null);(0,u.useEffect)(()=>{mW(R.current)},[S]),(0,u.useEffect)(()=>{mW(z.current)},[w]);let B=(0,u.useRef)(d);(0,u.useEffect)(()=>{B.current=d},[d]);let V=(0,u.useRef)({}),H=(0,u.useRef)(null),W=(0,u.useCallback)(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null);let e=V.current;Object.keys(e).length&&(V.current={},B.current(e))},[]),G=(0,u.useCallback)(e=>{V.current={...V.current,...e},H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(W,400)},[W]);(0,u.useEffect)(()=>()=>{if(H.current!==null){window.clearTimeout(H.current),H.current=null;let e=V.current;Object.keys(e).length&&B.current(e)}},[]),(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&String(e.key).toLowerCase()===`s`&&W()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W]);let[ee,te]=(0,u.useState)(r);(0,u.useEffect)(()=>{te(r)},[r]);let ne=new Set(ee.filter(e=>e.to===t.id).map(e=>e.from)),K=n.filter(e=>e.id!==t.id);function re(e){let n=[...ee.filter(e=>e.to!==t.id),...e.map(e=>({from:e,to:t.id}))];te(n),_(n)}function ae(e,n){let r=new Set(t.skills);n?r.add(e):r.delete(e),d({skills:[...r]})}let q=s?.providers??[],oe=t.provider&&t.model?`${t.provider}/${t.model}`:``,J=q.some(e=>e.id===t.provider&&e.models.some(e=>e.id===t.model)),ce=t.model&&!J?t.model:``,le=J?q.find(e=>e.id===t.provider)?.models.find(e=>e.id===t.model)??null:null,ue=le?.levels??[],de=le?.defaultLevel??``,fe=q.every(e=>!e.models.length),pe=new Set,he=[];for(let e of E){let{provider:t,model:n}=eW(e.value),r=q.find(e=>e.id===t),i=r?.models.find(e=>e.id===n);r&&i&&!pe.has(e.value)&&(pe.add(e.value),he.push({title:i.name,label:`${r.label} · ${i.name}`,value:`${YU}${e.value}`}))}let ge=[];he.length&&ge.push({title:`最近使用`,label:`最近使用`,value:qU,selectable:!1,children:he}),ce&&ge.push({title:`当前值`,label:`当前值`,value:JU,selectable:!1,children:[{title:ce,label:tW(t.provider,ce),value:KU}]});for(let e of q){let t=e.models.length;ge.push({title:t?`${e.label}(${t})`:e.label,label:e.label,value:`p:${e.id}`,selectable:!1,children:e.error?[{title:e.error,label:e.error,value:`e:${e.id}`,disabled:!0}]:e.models.map(t=>({title:t.name,label:`${e.label} · ${t.name}`,value:`${e.id}/${t.id}`}))})}let _e=q.find(e=>e.id===t.provider),ve=E.map(e=>e.provider).find(e=>q.some(t=>t.id===e)),ye=_e?.id??ve??``,be=[...he.length?[qU]:[],...ce?[JU]:[],...ye?[`p:${ye}`]:[]],xe=J?oe:ce?KU:void 0,X=t.fallback??[],Se=t.fallbackEfforts??{},Ce=new Set(X),we=q.map(e=>{let t=e.models.length,n=e.error?[{title:e.error,label:e.error,value:`e:${e.id}`,disabled:!0}]:e.models.filter(t=>{let n=`${e.id}/${t.id}`;return n!==oe&&!Ce.has(n)}).map(t=>({title:t.name,label:`${e.label} · ${t.name}`,value:`${e.id}/${t.id}`}));return{title:t?`${e.label}(${t})`:e.label,label:e.label,value:`p:${e.id}`,selectable:!1,children:n}}).filter(e=>e.children.length>0),Te=ye?[`p:${ye}`]:[];function Ee(e){if(!e||e===KU)return;let n=e.startsWith(YU)?e.slice(2):e,{provider:r,model:i}=eW(n),a=q.find(e=>e.id===r),o=a?.models.find(e=>e.id===i);if(!a||!o)return;let s=o.levels.includes(t.reasoningEffort??``)?t.reasoningEffort??``:``,c={value:n,label:o.name,provider:r},l=[c,...E.filter(e=>e.value!==c.value)].slice(0,ZU);D(l),$U(l),d({provider:r,model:i,reasoningEffort:s})}function De(e){let{provider:t,model:n}=eW(e),r=q.find(e=>e.id===t),i=r?.models.find(e=>e.id===n);return!r||!i?{label:`${e}(不在 DSH 目录里)`,levels:[]}:{label:`${r.label} · ${i.name}`,levels:i.levels}}function Oe(e,t){d({fallback:e,fallbackEfforts:t})}function ke(e){e&&e.includes(`/`)&&!Ce.has(e)&&(Oe([...X,e],{...Se,[e]:``}),k(e=>e+1))}function Ae(e){let t={...Se};delete t[e],Oe(X.filter(t=>t!==e),t)}function je(e,t){Oe(X,{...Se,[e]:t})}let Me=nW[t.status]??nW.idle,Ne=t.type===`orchestrator`,Pe=n.some(e=>e.id!==t.id&&e.type===`orchestrator`),Fe=OU.map(e=>({...e,disabled:e.value===`orchestrator`&&Pe})),Ie=rW.find(e=>e.value===(t.verify??``))??rW[0],Le=t.status===`review`,Re=a.filter(e=>cW(A,e.name,e.description)),ze=o.map(e=>({...e,tools:e.tools.filter(e=>cW(N,e.name,e.description))})).filter(e=>cW(N,e.name)||e.tools.length>0),Be=N.trim()?ze.map(e=>e.name):I??o.filter(e=>e.ok&&e.tools.length).slice(0,1).map(e=>e.name);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b ${WU} bg-[#FAFAF7] px-5 py-3.5 dark:bg-[#1B1C20]`,children:[(0,p.jsx)(`input`,{value:b,onChange:e=>{let t=e.target.value;x(t),G({label:t})},onBlur:W,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},placeholder:`节点名称`,"aria-label":`节点名称`,className:`min-w-0 flex-1 rounded-[3px] border-0 bg-transparent p-0 text-[17px] font-semibold tracking-tight outline-none placeholder:text-[#a8a8a0] focus-visible:ring-2 focus-visible:ring-[#24543F]/30 dark:placeholder:text-[#6f6f68] dark:focus-visible:ring-[#6aa583]/40 ${VU}`}),(0,p.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[12px] ${HU}`,children:[(0,p.jsx)(`span`,{className:`h-[6px] w-[6px] rounded-full ${Me.dot}`}),Me.label]}),(0,p.jsx)(`button`,{type:`button`,onClick:y,"aria-label":`关闭详情`,title:`关闭`,className:`-mr-1 grid h-8 w-8 shrink-0 place-items-center rounded-[4px] text-[#6b6b66] transition-colors hover:bg-[#EFEFEA] dark:text-[#8b8b85] dark:hover:bg-[#232421]`,children:(0,p.jsx)(Y,{size:16})})]}),t.verdict&&(0,p.jsxs)(`div`,{className:`shrink-0 border-b px-5 py-2 text-[12px] leading-[1.5] ${WU} ${t.verdict.pass?`bg-[#EEF3EF] text-[#24543F] dark:bg-[#1B2A22] dark:text-[#8FC3A7]`:`bg-[#FBEFEA] text-[#B4451F] dark:bg-[#2A1C17] dark:text-[#E08A6A]`}`,children:[pW(t.verdict.by),` `,t.verdict.pass?`通过`:`未通过`,t.verdict.reason?`:${t.verdict.reason}`:``]}),t.error&&(0,p.jsx)(`div`,{className:`shrink-0 border-b px-5 py-2 text-[12px] leading-[1.5] ${WU} bg-[#FBEFEA] text-[#B4451F] dark:bg-[#2A1C17] dark:text-[#E08A6A]`,children:t.error}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-6 pt-3`,children:[Ne?null:(0,p.jsxs)(uW,{title:`节点类型`,children:[(0,p.jsx)(jb,{value:t.type||`llm`,onChange:e=>d({type:e}),options:Fe,"aria-label":`节点类型`,className:`w-full`,size:`middle`}),Pe?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:`画布已有根节点,这张卡不能再设为调度卡。`}):null]}),(0,p.jsx)(uW,{title:`模型`,extra:(0,p.jsxs)(`button`,{type:`button`,onClick:g,title:`重新读取 DSH 的模型目录`,className:`flex items-center gap-1 text-[11px] transition-opacity hover:opacity-70 ${UU}`,children:[(0,p.jsx)(ie,{size:11}),`刷新`]}),children:(0,p.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,p.jsx)(Nk,{value:xe,placeholder:`选择模型`,showSearch:!0,treeNodeFilterProp:`title`,treeDefaultExpandAll:!1,treeDefaultExpandedKeys:be,treeNodeLabelProp:`label`,treeData:ge,onChange:Ee,"aria-label":`模型`,className:`w-full`,size:`middle`}),(0,p.jsx)(jb,{value:t.reasoningEffort??``,onChange:e=>d({reasoningEffort:e}),disabled:!ue.length,"aria-label":`推理强度`,title:ue.length?`推理强度`:`当前模型没有可选推理档位`,options:[{value:``,label:`推理强度:模型默认${de?`(${de})`:``}`},...ue.map(e=>({value:e,label:e}))],className:`w-full`,size:`middle`}),fe&&(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] leading-[1.6] ${HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-50`}),(0,p.jsx)(`span`,{children:`没读到 DSH 的模型目录,检查 DSH 凭据或网络。`})]}),(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 border-t border-[#EDEEE9] pt-2 text-[11px] leading-[1.6] dark:border-[#2A2C31] ${c&&!c.healthy?`text-[#B4451F] dark:text-[#e08a6a]`:HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-60`}),(0,p.jsxs)(`span`,{children:[`模型通道:DSH 内核(未连接时不可跑图)`,c&&!c.healthy?` · ${c.reason||`原因未知`}`:``]})]})]})}),(0,p.jsx)(uW,{title:`兜底模型`,extra:X.length?(0,p.jsxs)(`span`,{className:`text-[11px] ${HU}`,children:[X.length,` 个 · 按顺序重试`]}):void 0,children:(0,p.jsxs)(`div`,{className:`space-y-1.5`,children:[X.map(e=>{let t=De(e);return(0,p.jsxs)(`div`,{className:`flex min-h-[32px] items-center gap-2 border-b py-1 last:border-b-0 ${WU}`,children:[(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] ${VU}`,title:t.label,children:t.label}),(0,p.jsx)(jb,{size:`small`,value:Se[e]??``,disabled:!t.levels.length,title:t.levels.length?`这条兜底的推理强度`:`该模型没有可选推理档位`,options:[{value:``,label:`模型默认`},...t.levels.map(e=>({value:e,label:e}))],onChange:t=>je(e,t),"aria-label":`${t.label} 的推理强度`,style:{width:104}}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ae(e),"aria-label":`移除兜底模型 ${t.label}`,title:`移除`,className:`grid h-7 w-7 shrink-0 place-items-center rounded-[4px] transition-colors hover:bg-[#FBEFEA] hover:text-[#B4451F] dark:hover:bg-[#2A1C17] dark:hover:text-[#e08a6a] ${UU}`,children:(0,p.jsx)(Y,{size:13})})]},e)}),(0,p.jsx)(Nk,{onChange:ke,placeholder:`添加兜底模型…`,showSearch:!0,treeNodeFilterProp:`title`,treeDefaultExpandAll:!1,treeDefaultExpandedKeys:Te,treeNodeLabelProp:`label`,treeData:we,"aria-label":`添加兜底模型`,className:`w-full`,size:`middle`},O),(0,p.jsxs)(`div`,{className:`flex items-start gap-1.5 pt-0.5 text-[11px] leading-[1.6] ${HU}`,children:[(0,p.jsx)(`span`,{className:`mt-[5px] h-[3px] w-[3px] shrink-0 rounded-full bg-current opacity-50`}),(0,p.jsx)(`span`,{children:`兜底模型:主模型失败后按顺序尝试,可单独设推理强度`})]})]})}),(0,p.jsxs)(uW,{title:Ne?`人格`:`任务`,children:[(0,p.jsx)(`textarea`,{ref:R,rows:3,value:S,onChange:e=>{C(e.target.value),G({task:e.target.value}),mW(e.currentTarget)},onBlur:W,placeholder:Ne?`默认:只负责和用户对话,再严格按后续节点的 AgentFlow 流执行(可自己改)`:`写清楚这张卡要做什么…`,className:`${aW} max-h-[240px] resize-none overflow-y-auto`}),Ne&&(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:`默认人格只是起点,可以自己改:它只负责和用户对话,确认需求后严格按后续节点的流程执行。`})]}),(0,p.jsx)(uW,{title:`完成标准`,children:(0,p.jsx)(`textarea`,{ref:z,rows:2,value:w,onChange:e=>{T(e.target.value),G({criteria:e.target.value}),mW(e.currentTarget)},onBlur:W,placeholder:`做到什么程度算完成…`,className:`${aW} max-h-[200px] resize-none overflow-y-auto`})}),(0,p.jsxs)(uW,{title:`结果判断`,children:[(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":`结果判断`,className:`flex gap-[2px] rounded-[6px] bg-[#EFEFEA] p-[3px] dark:bg-[#232421]`,children:rW.map(e=>{let n=(t.verify??``)===e.value;return(0,p.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,title:e.desc,onClick:()=>d({verify:e.value}),className:`flex-1 rounded-[4px] px-1 py-[5px] text-[13px] leading-[1.3] transition-colors ${n?`bg-white text-[#1B1B18] shadow-[0_1px_2px_rgba(0,0,0,0.06)] dark:bg-[#3A3B35] dark:text-[#e8e8e4]`:`hover:text-[#1B1B18] dark:hover:text-[#e8e8e4] ${HU}`}`,children:e.label},e.value||`none`)})}),(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-[1.5] ${UU}`,children:Ie.desc}),(t.verify??``)===`jev`&&(0,p.jsx)(`p`,{className:`mt-1.5 rounded-[4px] border border-[#E9D9B8] bg-[#FBF4E6] px-2 py-1.5 text-[11px] leading-[1.5] text-[#8a6220] dark:border-[#4a3a1c] dark:bg-[#2a2314] dark:text-[#e0b866]`,children:`需要本机安装 jev(TypeSafe)并配置 API key,否则这张卡跑到判定时会失败。`})]}),(0,p.jsx)(uW,{title:`技能`,extra:(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[`已选 `,t.skills.length]}),children:a.length===0?(0,p.jsx)(dW,{children:`没有找到技能`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(AD,{value:A,onChange:e=>M(e.target.value),allowClear:!0,size:`middle`,placeholder:`搜索技能名或描述…`,"aria-label":`搜索技能`,prefix:(0,p.jsx)(se,{size:12,className:UU}),className:`mb-2`}),Re.length===0?(0,p.jsxs)(dW,{children:[`没有匹配「`,A.trim(),`」的技能`]}):null,(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto`,children:Re.map(e=>{let n=t.skills.includes(e.name);return(0,p.jsx)(GT,{className:`af-row`,checked:n,onChange:t=>ae(e.name,t.target.checked),title:e.description,children:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`shrink-0 text-[13px] ${VU}`,children:e.name}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-[11px] ${UU}`,children:e.description||`无描述`})]})},e.name)})})]})}),(0,p.jsx)(uW,{title:`MCP 工具`,extra:(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[`已选 `,t.tools.length]}),children:o.length===0?(0,p.jsx)(dW,{children:`还没配置 MCP 服务器`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(AD,{value:N,onChange:e=>P(e.target.value),allowClear:!0,size:`middle`,placeholder:`搜索服务器或工具…`,"aria-label":`搜索 MCP 工具`,prefix:(0,p.jsx)(se,{size:12,className:UU}),className:`mb-2`}),ze.length===0?(0,p.jsxs)(dW,{children:[`没有匹配「`,N.trim(),`」的工具`]}):null,(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto af-tree`,children:(0,p.jsx)(jO,{checkable:!0,selectable:!1,expandedKeys:Be,onExpand:e=>L(e),treeData:ze.map(e=>({key:e.name,selectable:!1,title:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`h-[5px] w-[5px] shrink-0 rounded-full ${e.ok?`bg-[#24543F] dark:bg-[#6aa583]`:`bg-[#B4451F] dark:bg-[#e08a6a]`}`}),(0,p.jsx)(`span`,{className:`text-[12px] font-medium ${VU}`,children:e.name}),(0,p.jsxs)(`span`,{className:`text-[11px] ${UU}`,children:[e.tools.length,` 个工具`]}),!e.ok&&(0,p.jsx)(`span`,{className:`text-[11px] text-[#B4451F] dark:text-[#e08a6a]`,children:`连接失败`})]}),children:e.tools.map(t=>({key:`${e.name}.${t.name}`,title:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`shrink-0 text-[13px] ${VU}`,children:t.name}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-[11px] ${UU}`,children:t.description})]})}))})),checkedKeys:t.tools,onCheck:e=>{let t=Array.isArray(e)?e:e.checked;d({tools:t.filter(e=>String(e).includes(`.`))})}})})]})}),Ne?null:(0,p.jsx)(uW,{title:`上游`,children:K.length===0?(0,p.jsx)(dW,{children:`还没有其它卡片`}):(0,p.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto`,children:K.map(e=>{let n=ne.has(e.id),r=!n&&fW(ee,t.id,e.id),i=n?[...ne].filter(t=>t!==e.id):[...ne,e.id];return(0,p.jsx)(GT,{className:`af-row ${r?`af-row-disabled`:``}`,checked:n,disabled:r,onChange:()=>re(i),children:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${VU}`,children:e.label||e.id}),r&&(0,p.jsx)(`span`,{className:`shrink-0 text-[11px] ${UU}`,children:`会成环`})]})},e.id)})})})]}),Le&&(0,p.jsxs)(`div`,{className:`shrink-0 border-t ${WU} bg-[#FAEFE6] px-5 py-3 dark:bg-[#2A1C17]`,children:[(0,p.jsx)(`p`,{className:`text-[12px] text-[#B4451F] dark:text-[#e08a6a]`,children:`这张卡跑完了,等你判断结果`}),(0,p.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`h-8 flex-1 rounded-[4px] bg-[#24543F] text-[13px] font-medium text-white transition-colors hover:bg-[#1D4634] dark:bg-[#3F7A5F] dark:hover:bg-[#4B8B6D]`,children:`通过`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`h-8 flex-1 rounded-[4px] text-[13px] text-[#6b6b66] transition-colors hover:bg-white/60 dark:text-[#a3a39b] dark:hover:bg-[#232421]`,children:`打回重跑`})]})]}),(0,p.jsxs)(`footer`,{className:`shrink-0 border-t ${WU} bg-[#FAFAF7] px-5 py-3 dark:bg-[#1B1C20]`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:h,disabled:l,className:`flex h-8 flex-1 items-center justify-center gap-1.5 rounded-[4px] bg-[#24543F] text-[13px] font-medium text-white transition-colors hover:bg-[#1D4634] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#3F7A5F] dark:hover:bg-[#4B8B6D]`,children:[l?(0,p.jsx)(U,{size:13,className:`animate-spin`}):(0,p.jsx)(ie,{size:13}),l?`运行中…`:`重跑此卡`]}),Ne?null:(0,p.jsxs)(`button`,{type:`button`,onClick:()=>f(`prev`),className:`${oW} flex items-center gap-1`,children:[(0,p.jsx)(F,{size:13}),`加上游`]}),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>f(`next`),className:`${oW} flex items-center gap-1`,children:[(0,p.jsx)(j,{size:13}),`加下游`]})]}),(0,p.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,p.jsxs)(`button`,{type:`button`,onClick:v,disabled:Ne,title:Ne?`根节点是对话入口(人格来源),不能删除`:void 0,className:`flex items-center gap-1.5 rounded-[4px] px-2.5 py-1.5 text-[12px] text-[#B4451F] transition-colors hover:bg-[#FBEFEA] disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-[#e08a6a] dark:hover:bg-[#2A1C17]`,children:[(0,p.jsx)(me,{size:13}),`删除此卡`]})})]})]})}function uW({title:e,extra:t,children:n}){return(0,p.jsxs)(`section`,{className:`mt-3 rounded-xl border p-3 first:mt-1 ${GU}`,children:[(0,p.jsxs)(`div`,{className:`mb-2.5 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-[12px] font-semibold tracking-[0.01em] ${VU}`,children:e}),t]}),n]})}function dW({children:e}){return(0,p.jsx)(`p`,{className:`py-1 text-[12px] leading-[1.6] ${UU}`,children:e})}function fW(e,t,n){if(t===n)return!0;let r=new Set([t]),i=[t];for(;i.length;){let t=i.pop();for(let a of e)if(a.from===t){if(a.to===n)return!0;r.has(a.to)||(r.add(a.to),i.push(a.to))}}return!1}function pW(e){return e===`human`?`人工`:e===`jev`?`jev`:e===`self`?`自评`:e||`系统`}function mW(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var{Text:hW}=PA;function gW({open:e,config:t,servers:n,onClose:r,onSaved:i,onError:a}){let o=t,[s,c]=(0,u.useState)(o?.mock??!1),[l,d]=(0,u.useState)(!1),[f,m]=(0,u.useState)(null),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(a);(0,u.useEffect)(()=>{_.current=a},[a]),(0,u.useEffect)(()=>{e&&c(o?.mock??!1)},[e,o?.mock]),(0,u.useEffect)(()=>{if(!e)return;let t=!1;return g(!0),JA.getBridge().then(e=>{t||m(e)}).catch(e=>{t||_.current(`读取模型通道状态失败:${e.message}`)}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e]);async function v(){if(h)return;g(!0);let[e,t]=await Promise.allSettled([JA.getBridge(),JA.getModels(!0)]);e.status===`fulfilled`?m(e.value):_.current(`读取模型通道状态失败:${e.reason.message}`),t.status===`rejected`&&_.current(`重新读取模型目录失败:${t.reason.message}`),g(!1)}async function y(e){if(l||!t)return;let n=s;c(e),d(!0);try{let t=await JA.putConfig({mock:e}),n=typeof t?.mock==`boolean`?t.mock:e;c(n),i({mock:n})}catch(e){c(n),a(`切换 mock 失败:${e.message}`)}finally{d(!1)}}let b=Object.entries(o?.providers??{}),x=o?.mcpServers??n.map(e=>({name:e.name})),S=o?.skillDirs?.length?o.skillDirs:o?.dshPaths?.skills?[o.dshPaths.skills]:[],C=f?f.healthy?(0,p.jsx)(WO,{color:`success`,style:{marginInlineEnd:0},children:`已连接`}):(0,p.jsx)(WO,{color:`warning`,style:{marginInlineEnd:0},children:`未连接`}):(0,p.jsx)(hW,{type:`secondary`,style:{fontSize:12},children:`读取中…`}),w=f&&(f.lastError||f.reason)||``;return(0,p.jsxs)(PD,{open:e,title:`设置`,width:640,centered:!0,getContainer:()=>document.querySelector(`.af-canvas`)??document.body,onCancel:r,styles:{body:{maxHeight:`calc(100vh - 220px)`,overflowY:`auto`,paddingTop:12}},footer:(0,p.jsx)(oD,{justify:`flex-end`,children:(0,p.jsx)(VS,{onClick:r,children:`关闭`})}),children:[(0,p.jsx)(Vl,{type:`info`,showIcon:!0,title:`模型、MCP 服务器、技能都来自 DSH 的配置。要增删改请到 DSH 的 cordis.patch.yml,AgentFlow 这边只读。`,description:o?.dshPaths?.patch?(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:12,wordBreak:`break-all`},children:[`patch:`,(0,p.jsx)(hW,{code:!0,style:{fontSize:12},children:o.dshPaths.patch})]}):void 0}),(0,p.jsx)(_W,{title:`模型`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[b.length,` 个`]}),children:b.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置模型提供商`}):b.map(([e,t])=>(0,p.jsx)(Rw,{size:`small`,style:{marginBottom:12},title:(0,p.jsx)(hW,{strong:!0,style:{fontSize:14},children:t.label||e}),extra:t.hasKey?(0,p.jsx)(WO,{color:`green`,style:{marginInlineEnd:0},children:`已配置 key`}):(0,p.jsx)(WO,{color:`red`,style:{marginInlineEnd:0},children:`缺 key`}),children:(0,p.jsx)(LE,{size:`small`,column:1,colon:!1,items:[{key:`provider`,label:`provider`,children:(0,p.jsx)(hW,{code:!0,children:e})},{key:`baseURL`,label:`baseURL`,children:(0,p.jsx)(hW,{code:!0,children:t.baseURL||`—`})},{key:`model`,label:`model`,children:(0,p.jsx)(hW,{code:!0,children:t.model||`—`})}]})},e))}),(0,p.jsxs)(_W,{title:`模型通道`,extra:(0,p.jsx)(VS,{size:`small`,loading:h,onClick:()=>void v(),children:`刷新`}),children:[f&&!f.healthy&&(0,p.jsx)(Vl,{type:`warning`,showIcon:!0,style:{marginBottom:10},title:`DSH 未运行或插件未加载,画布不能调模型`}),(0,p.jsx)(LE,{size:`small`,bordered:!0,column:1,colon:!1,items:[{key:`status`,label:`状态`,children:C},{key:`infoPath`,label:`发现文件`,children:(0,p.jsx)(hW,{code:!0,style:{fontSize:12,wordBreak:`break-all`,userSelect:`text`},title:f?.dir,children:f?.infoPath||`—`})},{key:`version`,label:`版本`,children:f?.version==null?`—`:(0,p.jsx)(hW,{code:!0,children:f.version})},{key:`startedAt`,label:`启动时间`,children:vW(f?.startedAt??null)},{key:`providers`,label:`provider 数`,children:f?String(f.providers):`—`},{key:`modelCount`,label:`模型数`,children:f?String(f.modelCount):`—`},{key:`lastError`,label:`最后错误`,children:w?(0,p.jsx)(hW,{type:`danger`,style:{fontSize:12,wordBreak:`break-all`},children:w}):(0,p.jsx)(hW,{type:`secondary`,children:`—`})}]})]}),(0,p.jsx)(_W,{title:`MCP 服务器`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[x.length,` 个`]}),children:x.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置 MCP 服务器`}):(0,p.jsx)(LE,{size:`small`,bordered:!0,column:1,colon:!1,items:x.map(e=>({key:e.name,label:(0,p.jsx)(hW,{strong:!0,style:{fontSize:13},children:e.name}),children:e.kind?(0,p.jsx)(WO,{style:{marginInlineEnd:0},children:e.kind}):(0,p.jsx)(hW,{type:`secondary`,children:`—`})}))})}),(0,p.jsx)(_W,{title:`技能目录`,extra:(0,p.jsxs)(hW,{type:`secondary`,style:{fontSize:11},children:[S.length,` 个`]}),children:S.length===0?(0,p.jsx)(eb,{image:eb.PRESENTED_IMAGE_SIMPLE,description:`DSH 没有配置技能目录`}):(0,p.jsx)(oD,{vertical:!0,gap:6,children:S.map(e=>(0,p.jsx)(hW,{code:!0,style:{fontSize:12,wordBreak:`break-all`},children:e},e))})}),(0,p.jsx)(_W,{title:`运行模式`,children:(0,p.jsx)(Rw,{size:`small`,children:(0,p.jsxs)(oD,{align:`center`,justify:`space-between`,gap:16,children:[(0,p.jsxs)(`div`,{style:{minWidth:0},children:[(0,p.jsx)(hW,{strong:!0,style:{display:`block`,fontSize:15},children:`mock 模式`}),(0,p.jsx)(hW,{type:`secondary`,style:{display:`block`,fontSize:12},children:`AgentFlow 自己的开关,不属于 DSH 配置。打开后不真正调用模型。`})]}),(0,p.jsx)(UD,{checked:s,loading:l,disabled:!t,onChange:e=>void y(e)})]})})})]})}function _W({title:e,extra:t,children:n}){return(0,p.jsxs)(`section`,{style:{marginTop:20},children:[(0,p.jsxs)(oD,{align:`center`,justify:`space-between`,gap:8,style:{marginBottom:8},children:[(0,p.jsx)(hW,{strong:!0,style:{fontSize:13},children:e}),t]}),n]})}function vW(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return`—`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var{Text:yW}=PA,bW=`'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', ui-monospace, monospace`;function xW({open:e,boardId:t,boardName:n,onClose:r}){let{token:i}=ek.useToken(),[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(null),[l,d]=(0,u.useState)(!1),[f,m]=(0,u.useState)(``),[h,g]=(0,u.useState)([]),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=(0,u.useCallback)(async()=>{v(!0);try{let e=await JA.listCommands();g(e.commands)}catch{g([])}finally{v(!1)}},[]);(0,u.useEffect)(()=>{e&&(o(null),c(null),d(!1),m(``),x())},[e,x]);async function S(){if(!l){d(!0),c(null),o(null);try{let e=f.trim(),n=await JA.exportCommand(t,e||void 0);o(n),await x()}catch(e){let t=e.message||`未知错误`;c({title:t.includes(`HTTP 400`)?`生成失败(检查命令名)`:`生成失败`,detail:t})}finally{d(!1)}}}async function C(e){if(!y&&window.confirm(`删除命令 /${e}?删掉后 DSH 里立刻就不能用了。`)){b(e),c(null);try{await JA.deleteCommand(e),a?.name===e&&o(null),await x()}catch(e){c({title:`删除失败`,detail:e.message})}finally{b(null)}}}let w=h.filter(e=>!t||e.board===t),T={border:`1px solid ${i.colorBorderSecondary}`,borderRadius:8,background:i.colorFillTertiary,padding:`10px 12px`,fontFamily:bW,fontSize:12,lineHeight:1.7,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:i.colorText};return(0,p.jsxs)(PD,{open:e,title:`生成斜杠命令`,width:640,centered:!0,onCancel:r,styles:{body:{maxHeight:`calc(100vh - 240px)`,overflowY:`auto`}},footer:(0,p.jsxs)(oD,{justify:`flex-end`,gap:8,children:[(0,p.jsx)(VS,{onClick:r,children:`关闭`}),(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(z,{size:14}),loading:l,onClick:()=>void S(),children:`生成`})]}),children:[(0,p.jsx)(Vl,{type:`info`,showIcon:!0,title:`把这张画布挂成一条 DSH 斜杠命令:生成后在对话里输入 /命令名,就能进入这张画布的工作流(无参数先看画布,带文字直接进流程)。命令即时生效,不用重启 DSH。`,style:{marginBottom:16}}),(0,p.jsxs)(`div`,{style:{marginBottom:12},children:[(0,p.jsx)(yW,{type:`secondary`,style:{fontSize:12},children:`当前画布:`}),(0,p.jsx)(yW,{strong:!0,style:{fontSize:12},children:n||t||`索引里的第一张画布`})]}),(0,p.jsxs)(`div`,{style:{marginBottom:16},children:[(0,p.jsx)(yW,{style:{fontSize:12,display:`block`,marginBottom:6},children:`命令名(可选)`}),(0,p.jsx)(AD,{value:f,onChange:e=>m(e.target.value),placeholder:`留空=按画布 id 自动生成(agentflow-…)`,maxLength:48,disabled:l}),(0,p.jsx)(yW,{type:`secondary`,style:{fontSize:11},children:`小写字母开头,只允许 a-z 0-9 _ -,不超过 48 个字符;同名会覆盖旧命令。`})]}),s&&(0,p.jsx)(Vl,{type:`error`,showIcon:!0,title:s.title,description:s.detail?(0,p.jsx)(yW,{style:{fontSize:12,fontFamily:bW,wordBreak:`break-all`},children:s.detail}):void 0,style:{marginBottom:16}}),a&&(0,p.jsxs)(`div`,{style:{marginBottom:16},children:[(0,p.jsx)(Vl,{type:`success`,showIcon:!0,title:a.replaced?`命令已更新(覆盖了同名旧命令)`:`命令已生成`,description:(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{style:{marginBottom:4},children:[`命令名:`,(0,p.jsxs)(yW,{code:!0,copyable:!0,style:{fontSize:12},children:[`/`,a.name]})]}),(0,p.jsxs)(`div`,{style:{marginBottom:4},children:[`用法:在 DSH 对话里输入 `,(0,p.jsxs)(yW,{code:!0,style:{fontSize:12},children:[`/`,a.name]}),`,回车即可。`]}),(0,p.jsx)(`div`,{style:{marginBottom:4},children:(0,p.jsx)(`b`,{children:`已即时生效,无需重启。`})}),(0,p.jsxs)(`div`,{children:[`文件:`,(0,p.jsx)(yW,{code:!0,copyable:!0,style:{fontSize:12,wordBreak:`break-all`},children:a.file})]})]})}),(0,p.jsx)(oD,{justify:`flex-end`,style:{marginTop:8},children:(0,p.jsx)(VS,{size:`small`,danger:!0,icon:(0,p.jsx)(me,{size:13}),loading:y===a.name,onClick:()=>void C(a.name),children:`删除命令`})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(oD,{align:`baseline`,justify:`space-between`,style:{marginBottom:6},children:[(0,p.jsx)(yW,{strong:!0,style:{fontSize:13},children:`这张画布已有的命令`}),(0,p.jsx)(yW,{type:`secondary`,style:{fontSize:11},children:_?`读取中…`:`${w.length} 条`})]}),w.length===0?(0,p.jsx)(`div`,{style:{...T,color:i.colorTextTertiary},children:_?`正在读取…`:`还没有命令,点右下角「生成」创建一条。`}):(0,p.jsx)(`div`,{style:{border:`1px solid ${i.colorBorderSecondary}`,borderRadius:8},children:w.map((e,t)=>(0,p.jsxs)(oD,{align:`center`,gap:8,style:{padding:`8px 12px`,borderTop:t===0?void 0:`1px solid ${i.colorBorderSecondary}`},children:[(0,p.jsxs)(yW,{code:!0,style:{fontSize:12},children:[`/`,e.name]}),(0,p.jsx)(yW,{type:`secondary`,style:{fontSize:11},children:SW(e.createdAt)}),(0,p.jsx)(`div`,{style:{marginLeft:`auto`},children:(0,p.jsx)(VS,{size:`small`,type:`text`,danger:!0,icon:(0,p.jsx)(me,{size:13}),loading:y===e.name,onClick:()=>void C(e.name),children:`删除`})})]},e.name))})]})]})}function SW(e){if(!e)return`—`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}var CW=`border-[#E3E4DF] dark:border-[#262724]`,wW=`text-[#1B1B18] dark:text-[#e8e8e4]`,TW=`text-[#6b6b66] dark:text-[#8b8b85]`,EW=`text-[#8b8b85] dark:text-[#8b8b85]`;function DW(){try{let e=globalThis.__AGENTFLOW_HOST__;return e&&typeof e==`object`?e:null}catch{return null}}function OW(){return DW()?.remote===!0}function kW(){let[e,t]=(0,u.useState)(`list`),[n,r]=(0,u.useState)([]),[i,a]=(0,u.useState)([]),[o,s]=(0,u.useState)({}),[c,l]=(0,u.useState)(!0),[d,f]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)(!1),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)(``),M=(0,u.useRef)(!1),P=(0,u.useRef)(!1),[F,I]=(0,u.useState)([]),[L,R]=(0,u.useState)([]),[B,H]=(0,u.useState)(null),[W,ee]=(0,u.useState)(null),[te,ne]=(0,u.useState)(null),[re,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)(!1),[se,J]=(0,u.useState)(!1),[le,ue]=(0,u.useState)(!1),de=(0,u.useRef)(!1),pe=(0,u.useRef)(!1),me=(0,u.useCallback)(()=>{pe.current=!0,J(!0)},[]),he=(0,u.useCallback)(()=>{pe.current=!1,J(!1)},[]),ge=(0,u.useRef)(0),_e=(0,u.useRef)(null);(0,u.useEffect)(()=>{_e.current=m},[m]),(0,u.useEffect)(()=>{if(!m||e!==`board`)return;let t=window.setTimeout(()=>{JA.putBoard(m.id,m).catch(e=>{console.warn(`[agentflow] 自动保存失败:`,e)}),r(e=>e.map(e=>e.id===m.id?{...e,presetOutdated:!0}:e))},200);return()=>window.clearTimeout(t)},[m,e]),(0,u.useEffect)(()=>{let e=()=>{let e=_e.current;if(e)try{fetch(WA(`/api/boards/${encodeURIComponent(e.id)}`),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({board:e}),keepalive:!0}).catch(()=>{})}catch{}};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let[Y,ve]=(0,u.useState)(()=>{let e=DW();if(e?.remote){if(e.theme===`dark`)return!0;if(e.theme===`light`)return!1;try{return window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}try{localStorage.removeItem(`agentflow-theme`)}catch{}try{let e=sessionStorage.getItem(`agentflow-theme`);if(e===`dark`)return!0;if(e===`light`)return!1}catch{}try{let e=new URLSearchParams(window.location.search).get(`theme`);if(e===`dark`)return!0;if(e===`light`)return!1}catch{}try{return window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}});(0,u.useEffect)(()=>{if(OW())window.dispatchEvent(new Event(`themechange`));else{document.documentElement.classList.toggle(`dark`,Y);try{sessionStorage.setItem(`agentflow-theme`,Y?`dark`:`light`)}catch{}window.dispatchEvent(new Event(`themechange`))}},[Y]),(0,u.useEffect)(()=>{if(!OW())return;let e=e=>{let t=e.detail?.theme;t===`dark`?ve(!0):t===`light`&&ve(!1)};return window.addEventListener(`agentflow-theme`,e),()=>window.removeEventListener(`agentflow-theme`,e)},[]);let[ye,be]=(0,u.useState)(null),xe=(0,u.useRef)(null),X=(0,u.useCallback)((e,t=`ok`)=>{be({msg:e,kind:t}),xe.current&&window.clearTimeout(xe.current),xe.current=window.setTimeout(()=>be(null),3200)},[]),Se=(0,u.useCallback)((e,t)=>{h(n=>n&&{...n,nodes:n.nodes.map(n=>n.id===e?{...n,...t}:n)})},[]),Ce=(0,u.useRef)(null),we=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(Ce.current=d,OW()&&d)try{window.dispatchEvent(new CustomEvent(`agentflow-board-active`,{detail:{boardId:d}}))}catch{}},[d]),(0,u.useEffect)(()=>{_(m?.name??``)},[m?.id,m?.name]);let Te=(0,u.useCallback)(async(e=!1)=>{e||l(!0);let[t,n]=await Promise.allSettled([JA.listBoards(),JA.listPresets()]);if(t.status===`fulfilled`){let e=t.value.boards;r(e);let n=await Promise.allSettled(e.map(e=>JA.getBoard(e.id))),i={};n.forEach((t,n)=>{t.status===`fulfilled`&&(i[e[n].id]=jW(t.value.board))}),s(i)}else X(`加载画布列表失败:${t.reason.message}`,`err`);n.status===`fulfilled`?a(n.value.presets):X(`加载预设列表失败:${n.reason.message}`,`err`),e||l(!1)},[X]);(0,u.useEffect)(()=>{Te(),JA.getSkills().then(e=>I(e.skills)).catch(()=>{}),JA.getMcp().then(e=>R(e.servers)).catch(()=>{}),JA.getConfig().then(H).catch(()=>{}),JA.getModels().then(ee).catch(()=>{}),JA.getBridge().then(ne).catch(()=>{})},[Te]);let Ee=(0,u.useRef)(0);(0,u.useEffect)(()=>{v&&(Date.now()-Ee.current<3e4||(Ee.current=Date.now(),JA.getModels(!0).then(ee).catch(()=>{}),JA.getBridge().then(ne).catch(()=>{})))},[v]);let{running:De,run:Oe,stop:ke}=YA((0,u.useCallback)(e=>{let t=we.current!=null&&Ce.current!==we.current;if((e.type===`run:end`||e.type===`run:error`)&&(we.current=null),!t)switch(e.type){case`node:start`:Se(e.id,{status:`running`});break;case`node:delta`:h(t=>t&&{...t,nodes:t.nodes.map(t=>t.id===e.id?{...t,delta:(t.delta||``)+e.chunk}:t)});break;case`node:done`:Se(e.id,{status:e.status??`done`,content:e.content,usage:e.usage,verdict:e.verdict??null,error:null,delta:void 0});break;case`node:failed`:Se(e.id,{status:`failed`,error:`该节点所有模型都失败`});break;case`node:blocked`:Se(e.id,{status:`blocked`});break;case`node:retry`:h(t=>t&&{...t,nodes:t.nodes.map(t=>t.id===e.id?{...t,delta:void 0}:t)}),X(`${e.id} 换 ${e.model} 重试:${e.error}`,`err`);break;case`run:end`:{let{done:t,failed:n,blocked:r,review:i}=e.summary,a=[`完成 ${t.length}`];i.length&&a.push(`待确认 ${i.length}`),n.length&&a.push(`失败 ${n.length}`),r.length&&a.push(`阻塞 ${r.length}`),X(a.join(`,`),n.length||r.length?`err`:`ok`);break}case`run:error`:X(`运行出错:${e.error}`,`err`)}},[Se,X])),Ae=(0,u.useCallback)(e=>{let t=Ce.current;t&&(we.current=t,Oe(e,t))},[Oe]),je=(0,u.useCallback)(()=>{we.current=null,ke()},[ke]),Me=(0,u.useCallback)(async e=>{let n=++ge.current;t(`board`),f(e),h(null),_(``),y(null),oe(!1),he();let r=await JA.getBoard(e).then(e=>({status:`fulfilled`,value:e})).catch(e=>({status:`rejected`,reason:e}));n===ge.current&&(r.status===`rejected`?(X(`打开画布失败:${r.reason.message}`,`err`),t(`list`),f(null),he(),Te(!0)):h(r.value.board))},[Te,X]),Ne=(0,u.useRef)((()=>{let e=DW();return e?.remote&&e.boardId?e.boardId:typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`)})());(0,u.useEffect)(()=>{let e=Ne.current;e&&(Ne.current=null,Me(e))},[Me]),(0,u.useEffect)(()=>{if(!OW())return;let e=e=>{let t=e.detail?.boardId;t&&t!==Ce.current&&Me(t)};return window.addEventListener(`agentflow-board`,e),()=>window.removeEventListener(`agentflow-board`,e)},[Me]);let Pe=(0,u.useCallback)(()=>{ge.current+=1,t(`list`),h(null),f(null),y(null),oe(!1),he(),Te(!0)},[Te]);function Fe(){Pe()}function Ie(e){Me(e)}let Le=(0,u.useCallback)(async()=>{let e=_e.current;if(!e)return!1;try{return await JA.putBoard(e.id,e),he(),!0}catch(e){return X(`保存画布失败:${e.message}`,`err`),!1}},[X,he]),Re=(0,u.useCallback)(async()=>{let e=_e.current;if(!e||de.current)return!1;de.current=!0,ue(!0);try{return await JA.putBoard(e.id,e),he(),r(t=>t.map(t=>t.id===e.id?{...t,name:e.name,nodeCount:e.nodes.length,presetOutdated:!1,updatedAt:Date.now()}:t)),X(`已保存`),!0}catch(e){return X(`保存失败:${e.message}`,`err`),!1}finally{de.current=!1,ue(!1)}},[X,he]);(0,u.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&String(t.key).toLowerCase()===`s`&&(t.preventDefault(),e===`board`&&window.setTimeout(()=>void Re(),0))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[Re,e]);let ze=(0,u.useCallback)(async e=>{m&&(!pe.current||await Le())&&Ae(e)},[m,Le,Ae]),Be=(0,u.useCallback)(async()=>{m&&(!pe.current||await Le())&&oe(!0)},[m,Le]),Ve=(0,u.useCallback)((e,t)=>{Se(e,t),me()},[Se]),He=(0,u.useCallback)(e=>{h(t=>t&&{...t,edges:e}),me()},[]),Ue=(0,u.useCallback)((e,t,n)=>{m&&(h({...m,nodes:m.nodes.map(r=>r.id===e?{...r,x:t,y:n}:r)}),me())},[m]),We=(0,u.useCallback)((e,t)=>{if(!m)return;let n=m.nodes.find(t=>t.id===e);if(!n)return;let r=W?.providers.find(e=>e.models.length),i=n.provider||r?.id||``,a=n.model||r?.models[0]?.id||``,o=AW(m.nodes),s={id:o,label:t===`next`?`下游卡片`:`上游卡片`,type:`llm`,x:t===`next`?n.x+360:n.x-360,y:n.y,provider:i,model:a,reasoningEffort:``,fallback:[],fallbackEfforts:{},task:``,criteria:``,skills:[],tools:[],verify:``,content:``,status:`idle`,usage:null,error:null,verdict:null};h({...m,nodes:[...m.nodes,s],edges:[...m.edges,t===`next`?{from:e,to:o}:{from:o,to:e}]}),y(o),me(),X(t===`next`?`已派生下游卡片(未保存)`:`已添加上游卡片(未保存)`)},[m,W,X]),Ge=(0,u.useCallback)((e,t)=>{m&&e!==t&&(m.nodes.find(e=>e.id===t)?.type===`orchestrator`?X(`根节点是对话入口,不能有上游节点`,`err`):m.edges.some(n=>n.from===e&&n.to===t)||(NW(m.edges,e,t)?X(`这条连线会形成环,已忽略`,`err`):(h({...m,edges:[...m.edges,{from:e,to:t}]}),me())))},[m,X]),Ke=(0,u.useCallback)(e=>{m&&(h({...m,nodes:m.nodes.filter(t=>t.id!==e),edges:m.edges.filter(t=>t.from!==e&&t.to!==e)}),y(null),me(),X(`已删除(未保存)`))},[m,X]),qe=(0,u.useCallback)(async(e,t)=>{if(!pe.current||await Le())try{let n=await JA.verify(e,t,void 0,Ce.current);Se(e,{status:n.status,verdict:n.verdict}),X(t?`已通过`:`已打回,可以改完再跑`)}catch(e){X(`操作失败:${e.message}`,`err`)}},[Se,X,Le]),Je=(0,u.useMemo)(()=>m?.nodes.find(e=>e.id===v)??null,[m,v]),Ye=(0,u.useMemo)(()=>new Set(n.map(e=>e.presetId).filter(e=>!!e)),[n]),Xe=(0,u.useMemo)(()=>i.filter(e=>!Ye.has(e.id)),[i,Ye]);function Ze(){T(``),C(!0)}async function Qe(){let e=w.trim();if(e&&!E){D(!0);try{let n=await JA.createBoard({name:e});ge.current+=1,C(!1),T(``),h(n.board),f(n.board.id),y(null),he(),t(`board`),Te(!0)}catch(e){X(`新建画布失败:${e.message}`,`err`)}finally{D(!1)}}}async function $e(e){if(!b){x(e.id);try{let n=await JA.importPreset(e.id);X(n.reused?`已有这张画布:${e.name}`:`已从预设创建画布:${e.name}`),ge.current+=1,h(n.board),f(n.board.id),y(null),he(),t(`board`),Te(!0)}catch(e){let t=e.message;t.includes(`HTTP 501`)?X(`创建画布功能还没上线(服务端 P1 未完成)`,`err`):X(`创建画布失败:${t}`,`err`)}finally{x(null)}}}function et(e){k(e.id),j(e.name)}async function tt(e){if(O!==e.id)return;let t=M.current;if(M.current=!1,k(null),t){j(e.name);return}let n=A.trim();if(n&&n!==e.name)try{let t=await JA.patchBoard(e.id,{name:n});r(r=>r.map(r=>r.id===e.id?{...r,name:n,updatedAt:t.meta?.updatedAt??r.updatedAt}:r)),m?.id===e.id&&h(e=>e&&{...e,name:n}),X(`画布已重命名`)}catch(e){X(`重命名失败:${e.message}`,`err`)}}async function nt(e){if(n.length<=1)X(`至少要保留一张画布`,`err`);else if(window.confirm(`删除画布《${e.name}》?里面的节点会一起删掉,且不可恢复。`))try{await JA.deleteBoard(e.id),X(`画布已删除`),await Te(!0)}catch(e){X(`删除失败:${e.message}`,`err`)}}async function rt(){if(!m)return;let e=P.current;if(P.current=!1,e){_(m.name);return}let t=g.trim();if(!t)_(m.name);else if(t!==m.name)try{let e=await JA.patchBoard(m.id,{name:t});h(e=>e&&{...e,name:t}),r(n=>n.map(n=>n.id===m.id?{...n,name:t,updatedAt:e.meta?.updatedAt??n.updatedAt}:n)),X(`画布已重命名`)}catch(e){_(m.name),X(`重命名失败:${e.message}`,`err`)}}let it=(0,u.useRef)(null);return(0,p.jsx)(Md,{locale:UA.default,getPopupContainer:()=>it.current??document.body,theme:{algorithm:Y?ek.darkAlgorithm:ek.defaultAlgorithm,token:{colorPrimary:`#24543F`,borderRadius:7,fontSize:15,fontFamily:`-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', ui-sans-serif, sans-serif`},components:{Drawer:{paddingLG:20},Modal:{borderRadiusLG:12},Card:{borderRadiusLG:10}}},children:(0,p.jsxs)(`div`,{ref:it,className:`af-canvas flex h-full flex-col${Y?` dark`:``}`,children:[e===`list`?(0,p.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-3 border-b ${CW} bg-[#FCFCFA] px-5 dark:bg-[#17181b]`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`grid h-7 w-7 place-items-center rounded-[4px] bg-[#24543F] text-white`,children:`◈`}),(0,p.jsx)(`span`,{className:`text-[17px] font-semibold tracking-tight ${wW}`,children:`AgentFlow`})]}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(K,{size:14}),onClick:Ze,children:`新建画布`}),(0,p.jsx)(VS,{icon:Y?(0,p.jsx)(fe,{size:14}):(0,p.jsx)(G,{size:14}),onClick:()=>ve(e=>!e),title:Y?`切到浅色`:`切到深色`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(ce,{size:14}),onClick:()=>ie(!0),children:`设置`})]})]}):(0,p.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b ${CW} bg-[#FCFCFA] px-4 dark:bg-[#17181b]`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:Fe,title:`返回画布列表`,className:`flex shrink-0 items-center gap-1 rounded-[4px] px-2 py-1.5 text-[12px] transition-colors hover:bg-[#EFEFEA] dark:hover:bg-[#232421] ${TW}`,children:[(0,p.jsx)(N,{size:14}),`返回列表`]}),(0,p.jsx)(`div`,{className:`h-5 w-px shrink-0 bg-[#E3E4DF] dark:bg-[#2c2d29]`}),(0,p.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),onBlur:()=>void rt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P.current=!0,e.currentTarget.blur())},disabled:!m,placeholder:`画布名称`,"aria-label":`画布名称`,className:`min-w-0 max-w-[280px] flex-1 rounded-[3px] border-0 bg-transparent px-1 py-1 text-[16px] font-semibold tracking-tight outline-none placeholder:text-[#a8a8a0] focus-visible:ring-2 focus-visible:ring-[#24543F]/30 disabled:bg-transparent dark:placeholder:text-[#6f6f68] dark:focus-visible:ring-[#6aa583]/40 ${wW}`}),se&&(0,p.jsx)(`span`,{title:`有未保存的修改`,"aria-label":`有未保存的修改`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[#B4451F] dark:bg-[#e08a6a]`}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,p.jsx)(VS,{icon:(0,p.jsx)(q,{size:14}),disabled:!m,loading:le,onClick:()=>void Re(),title:`保存画布并更新预设(⌘S / Ctrl+S)`,children:`保存`}),De?(0,p.jsx)(VS,{danger:!0,icon:(0,p.jsx)(U,{size:14,className:`animate-spin`}),onClick:je,children:`停止`}):(0,p.jsx)(VS,{type:`primary`,icon:(0,p.jsx)(V,{size:14}),disabled:!m,onClick:()=>void ze(),title:`先保存,再跑一遍验证(会真实调用模型)`,children:`验证 AgentFlow`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(z,{size:14}),disabled:!m,onClick:()=>void Be(),children:`生成命令`}),(0,p.jsx)(VS,{icon:Y?(0,p.jsx)(fe,{size:14}):(0,p.jsx)(G,{size:14}),onClick:()=>ve(e=>!e),title:Y?`切到浅色`:`切到深色`}),(0,p.jsx)(VS,{icon:(0,p.jsx)(ce,{size:14}),onClick:()=>ie(!0),children:`设置`})]})]}),e===`list`?(0,p.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-[#F4F5F2] px-6 py-7 dark:bg-[#111214]`,children:(0,p.jsxs)(`div`,{className:`mx-auto w-full max-w-[1080px]`,children:[(0,p.jsxs)(`div`,{className:`mb-5`,children:[(0,p.jsx)(`h1`,{className:`text-[20px] font-semibold tracking-tight ${wW}`,children:`画布`}),(0,p.jsx)(`p`,{className:`mt-1 text-[12px] leading-[1.6] ${TW}`,children:`每张画布对应一个 DSH 预设;编辑会自动保存,点「保存」才会更新/生成预设。`})]}),c&&n.length===0?(0,p.jsx)(`div`,{className:`py-16 text-center text-[13px] ${TW}`,children:`正在加载画布…`}):(0,p.jsxs)(p.Fragment,{children:[n.length===0?(0,p.jsx)(`div`,{className:`rounded-[8px] border border-dashed ${CW} py-14 text-center text-[13px] ${TW}`,children:`还没有画布,点右上角「新建画布」开始。`}):(0,p.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>{let t=e.presetId?i.find(t=>t.id===e.presetId):null;return(0,p.jsxs)(`article`,{className:`flex min-h-[150px] flex-col rounded-[8px] border ${CW} bg-[#FCFCFA] p-4 dark:bg-[#17181B]`,children:[(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[O===e.id?(0,p.jsx)(AD,{size:`small`,autoFocus:!0,maxLength:60,value:A,onChange:e=>j(e.target.value),onBlur:()=>void tt(e),onPressEnter:e=>e.currentTarget.blur(),onKeyDown:e=>{e.key===`Escape`&&(M.current=!0,e.currentTarget.blur())},"aria-label":`重命名画布 ${e.name}`}):(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e.id),title:e.name,className:`block max-w-full text-left`,children:(0,p.jsx)(`h2`,{className:`truncate text-[15px] font-semibold ${wW}`,children:e.name})}),(0,p.jsxs)(`p`,{className:`mt-1 text-[11px] leading-[1.6] ${EW}`,children:[e.nodeCount,` 个节点 · 更新于 `,MW(e.updatedAt)]}),o[e.id]!==void 0&&(0,p.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] leading-[1.6] ${TW}`,title:o[e.id]||`没有调度卡,首次导出会自动补一张`,children:[`对话入口:`,o[e.id]||`未设置(首次导出会自动补一张调度卡)`]})]}),(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,p.jsx)(WO,{color:t?`blue`:`default`,style:{marginInlineEnd:0},children:t?t.name:`自定义`}),e.presetOutdated&&(0,p.jsx)(WO,{color:`orange`,style:{marginInlineEnd:0},children:`预设未更新`}),e.hasDraft&&(0,p.jsx)(WO,{color:`gold`,style:{marginInlineEnd:0},children:`草稿`})]})]}),(0,p.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-1 pt-3`,children:[(0,p.jsx)(VS,{size:`small`,type:`primary`,onClick:()=>Ie(e.id),children:`编辑`}),(0,p.jsx)(VS,{size:`small`,type:`text`,onClick:()=>et(e),children:`重命名`}),(0,p.jsx)(VS,{size:`small`,type:`text`,danger:!0,disabled:n.length<=1,title:n.length<=1?`至少要保留一张画布`:void 0,onClick:()=>void nt(e),children:`删除`})]})]},e.id)})}),Xe.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`mb-3 mt-8 flex flex-wrap items-baseline gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-[13px] font-semibold ${wW}`,children:`还没有画布的预设`}),(0,p.jsx)(`span`,{className:`text-[11px] ${EW}`,children:`从预设生成一张单卡片画布,再继续编辑`})]}),(0,p.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Xe.map(e=>(0,p.jsxs)(`article`,{className:`flex min-h-[150px] flex-col rounded-[8px] border border-dashed ${CW} bg-[#F9F9F6] p-4 dark:bg-[#151617]`,children:[(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold ${wW}`,title:e.name,children:e.name}),(0,p.jsx)(WO,{style:{marginInlineEnd:0,flexShrink:0},children:e.source===`bundle`?`bundle`:`自定义`})]}),(0,p.jsx)(`p`,{className:`mt-1 line-clamp-3 text-[12px] leading-[1.6] ${TW}`,children:e.description||`没有描述`}),(0,p.jsx)(`div`,{className:`mt-auto pt-3`,children:(0,p.jsx)(VS,{size:`small`,loading:b===e.id,onClick:()=>void $e(e),children:`创建画布`})})]},e.id))})]})]})]})}):(0,p.jsxs)(`main`,{className:`relative min-h-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`pointer-events-none absolute left-4 top-[12px] z-10 flex items-center gap-1.5 rounded-[4px] bg-[#FCFCFA]/90 px-2 py-1 text-[11px] text-[#6b6b66] dark:bg-[#17181b]/90 dark:text-[#8b8b85]`,children:[(0,p.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full`,style:{background:B?B.mock?`#B4451F`:`#24543F`:`#b9bcb4`}}),B?B.mock?`mock`:`real`:`连接中`]}),m?(0,p.jsx)(BU,{board:m,selectedId:v,running:De,onSelect:y,onMove:Ue,onDerive:We,onConnect:Ge}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-[13px] text-[#8a93a3]`,children:`正在加载画布…`})]}),e===`board`&&m&&Je&&(0,p.jsx)(sW,{node:Je,nodes:m.nodes,edges:m.edges,boardId:m.id,skills:F,servers:L,catalog:W,bridge:te,running:De,onPatch:e=>Ve(Je.id,e),onDerive:e=>We(Je.id,e),onVerify:e=>void qe(Je.id,e),onEdgesChange:He,onRefreshModels:()=>{Ee.current=Date.now(),JA.getModels(!0).then(ee).catch(e=>X(`刷新模型失败:${e.message}`,`err`)),JA.getBridge().then(ne).catch(()=>{})},onRerun:()=>void ze([Je.id]),onDelete:()=>void Ke(Je.id),onClose:()=>y(null)}),(0,p.jsx)(gW,{open:re,config:B,servers:L,onClose:()=>ie(!1),onSaved:e=>{H(t=>t&&{...t,mock:e.mock}),JA.getMcp().then(e=>R(e.servers)).catch(()=>{}),X(`设置已保存`)},onError:e=>X(e,`err`)}),(0,p.jsx)(xW,{open:ae,boardId:d,boardName:g,onClose:()=>oe(!1)}),(0,p.jsx)(PD,{open:S,title:`新建画布`,centered:!0,getContainer:()=>it.current??document.body,okText:`创建`,cancelText:`取消`,confirmLoading:E,okButtonProps:{disabled:!w.trim()},onOk:()=>void Qe(),onCancel:()=>C(!1),children:(0,p.jsx)(AD,{autoFocus:!0,maxLength:60,placeholder:`画布名称,例如「活动文案」`,value:w,onChange:e=>T(e.target.value),onPressEnter:()=>{w.trim()&&!E&&Qe()}})}),ye&&(0,p.jsx)(`div`,{className:`absolute bottom-6 left-1/2 z-50 -translate-x-1/2 rounded-lg px-4 py-2 text-[13px] shadow-lg ${ye.kind===`err`?`bg-[#ffebee] text-[#c62828] dark:bg-[#3a1b1f] dark:text-[#ff9a9a]`:`bg-[#1C1C1A] text-white dark:bg-[#e7e9ee] dark:text-[#0f1116]`}`,children:ye.msg})]})})}function AW(e){let t=`n-${Date.now().toString(36)}`,n=t,r=2;for(;e.some(e=>e.id===n);)n=`${t}-${r++}`;return n}function jW(e){let t=e.nodes.find(e=>e.type===`orchestrator`)??(e.nodes.length===1?e.nodes[0]:null);return t?t.label||t.id:null}function MW(e){if(!e)return`—`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function NW(e,t,n){let r=new Set,i=[n];for(;i.length;){let n=i.pop();if(n===t)return!0;if(!r.has(n)){r.add(n);for(let t of e)t.from===n&&i.push(t.to)}}return!1}var PW=`http://127.0.0.1:8791`;function FW(e){return String(e??``).trim().replace(/\/+$/,``)}function IW(e){let t=FW(e);return t&&(PW=t),PW}function LW(){return PW}function RW(){try{if(document.body&&document.body.hasAttribute(`data-ds-dark-theme`))return`dark`}catch{}try{if(document.documentElement.classList.contains(`dark`))return`dark`}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function zW(e){let t=RW(),n=()=>{let n=RW();n!==t&&(t=n,e(n))},r=[];try{if(typeof MutationObserver<`u`){let e=new MutationObserver(n);document.body&&(e.observe(document.body,{attributes:!0,attributeFilter:[`data-ds-dark-theme`,`class`]}),r.push(e));let t=new MutationObserver(n);t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`]}),r.push(t)}}catch{}let i=null,a=()=>n();try{i=window.matchMedia(`(prefers-color-scheme: dark)`),i.addEventListener(`change`,a)}catch{i=null}return window.addEventListener(`focus`,n),()=>{for(let e of r)e.disconnect();if(i)try{i.removeEventListener(`change`,a)}catch{}window.removeEventListener(`focus`,n)}}var BW=`__AGENTFLOW_HOST__`,VW=`data-agentflow-style`,HW=[0,1e3,2500],UW=6e3,WW=2e3;function GW(){try{let e=globalThis[BW];return e&&typeof e==`object`?e:null}catch{return null}}function KW(e){let t={apiBase:e.apiBase,theme:e.theme,boardId:e.boardId,remote:!0};return globalThis[BW]=t,t}var qW=`
|
|
340
340
|
@keyframes af-host-spin { to { transform: rotate(360deg); } }
|
|
341
341
|
.af-host, .af-host *, .af-host *::before, .af-host *::after { box-sizing: border-box; }
|
|
342
342
|
.af-host-spinner {
|
|
@@ -361,4 +361,4 @@ html body {
|
|
|
361
361
|
background: transparent; cursor: pointer;
|
|
362
362
|
}
|
|
363
363
|
.af-host-button:hover { opacity: 0.75; }
|
|
364
|
-
`;function YW(){if(typeof document>`u`||document.querySelector(`style[${HW}]`))return;let e=m.replace(/:root\b(\s*,\s*:host\b)?/g,`.af-canvas`),t=document.createElement(`style`);t.setAttribute(HW,``),t.textContent=`${h}\n${e}\n${JW}`,document.head.appendChild(t)}function XW(e,t){return new Promise(n=>{let r=window.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e),i=()=>{window.clearTimeout(r),n()};t.addEventListener(`abort`,i,{once:!0})})}async function ZW(e){let t=Date.now()+WW;for(let n=0;n<UW.length;n+=1){if(e.aborted)return!1;let r=UW[n];if(r>0&&await XW(r,e),e.aborted)return!1;let i=t-Date.now();if(i<=0)return!1;let a=new AbortController,o=()=>a.abort();e.addEventListener(`abort`,o,{once:!0});let s=window.setTimeout(()=>a.abort(),Math.min(i,GW));try{if((await fetch(`${RW()}/api/plugin-alive`,{method:`GET`,cache:`no-store`,signal:a.signal})).ok)return!0}catch{}finally{window.clearTimeout(s),e.removeEventListener(`abort`,o)}}return!1}function QW(e){let t=e.theme===`dark`;return(0,p.jsx)(`div`,{className:`af-host`,style:{height:`100%`,minHeight:160,display:`grid`,placeItems:`center`,padding:24,background:t?`#121312`:`#f4f5f2`,color:t?`#e8e8e4`:`#1c1c1a`},children:(0,p.jsxs)(`div`,{className:`af-host-notice`,style:{border:`1px solid ${t?`#262724`:`#e2e4e0`}`,background:t?`#17181b`:`#fcfcfa`},children:[(0,p.jsx)(`div`,{className:`af-host-notice-title`,children:e.title}),e.detail?(0,p.jsx)(`div`,{className:`af-host-notice-detail`,children:e.detail}):null,(0,p.jsxs)(`div`,{className:`af-host-notice-actions`,children:[e.busy?(0,p.jsx)(`span`,{className:`af-host-spinner`,"aria-hidden":`true`}):null,e.onAction&&e.actionLabel?(0,p.jsx)(`button`,{type:`button`,className:`af-host-button`,onClick:e.onAction,children:e.actionLabel}):null]})]})})}var $W=class extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[agentflow] 内联画布渲染失败:`,e,t.componentStack)}render(){return this.state.error?(0,p.jsx)(QW,{theme:this.props.theme,title:`画布渲染出错`,detail:this.state.error.message||String(this.state.error),actionLabel:`重试`,onAction:()=>this.setState({error:null})}):this.props.children}};function eG({boardId:e,apiBase:t}){let n=e??``,[r,i]=(0,u.useState)(()=>{t&&LW(t),YW();let e=zW();return qW({apiBase:RW(),theme:e,boardId:n}),e});(0,u.useEffect)(()=>BW(i),[]),(0,u.useEffect)(()=>{let e=KW();e&&(e.theme=r),window.dispatchEvent(new CustomEvent(`agentflow-theme`,{detail:{theme:r}}))},[r]);let a=(0,u.useRef)(n);(0,u.useEffect)(()=>{let e=KW();e&&(e.boardId=n),a.current!==n&&(a.current=n,window.dispatchEvent(new CustomEvent(`agentflow-board`,{detail:{boardId:n}})))},[n]),(0,u.useEffect)(()=>{if(!t)return;let e=LW(t),n=KW();n&&(n.apiBase=e)},[t]);let[o,s]=(0,u.useState)(`checking`),[c,l]=(0,u.useState)(0);(0,u.useEffect)(()=>{let e=!1,t=new AbortController;return s(`checking`),ZW(t.signal).then(t=>{e||s(t?`ready`:`error`)}),()=>{e=!0,t.abort()}},[c]);let d=(0,u.useRef)(null),[f,m]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{let e=d.current;if(!e)return;let t=f,n=()=>{if(t)return;let n=e.parentElement,r=n?n.getBoundingClientRect().height:0,i=e.getBoundingClientRect().height;(r<1||i<1)&&(t=!0,m(!0))};n();let r=window.requestAnimationFrame(n),i=null;try{i=new ResizeObserver(n),e.parentElement&&i.observe(e.parentElement)}catch{i=null}return window.addEventListener(`resize`,n),()=>{window.cancelAnimationFrame(r),i&&i.disconnect(),window.removeEventListener(`resize`,n)}},[]),(0,p.jsx)(`div`,{ref:d,className:`af-host`,"data-agentflow-host":``,style:{position:`relative`,width:`100%`,height:f?`100vh`:`100%`,minHeight:0,overflow:`hidden`,background:r===`dark`?`#121312`:`#f4f5f2`,colorScheme:r===`dark`?`dark`:`light`},children:o===`checking`?(0,p.jsx)(QW,{theme:r,title:`正在连接 AgentFlow 后端…`,detail:`等待 ${RW()} 就绪`,busy:!0}):o===`error`?(0,p.jsx)(QW,{theme:r,title:`连不上 AgentFlow 后端`,detail:`请确认 ${RW()} 上的 AgentFlow 服务已启动后重试。`,actionLabel:`重试`,onAction:()=>l(e=>e+1)}):(0,p.jsx)($W,{theme:r,children:(0,p.jsx)(AW,{})})})}var tG=`agentflow`,nG=30,rG=`native`;function iG(){return rG}var aG=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){bG(`render`,e),console.error(`[agentflow] 画布渲染失败:`,e,t.componentStack)}render(){return this.state.error?(0,p.jsx)(oG,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}};function oG({error:e,onRetry:t}){return(0,p.jsx)(`div`,{style:{padding:16},children:(0,p.jsxs)(`div`,{style:{...wG,borderColor:`rgba(180,69,31,0.45)`,maxWidth:640},children:[(0,p.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`#B4451F`,marginBottom:6},children:`AgentFlow 画布渲染失败`}),(0,p.jsx)(`div`,{style:{fontSize:12.5,lineHeight:1.7,opacity:.8,wordBreak:`break-all`},children:e.message||String(e)}),(0,p.jsx)(`div`,{style:{marginTop:10},children:(0,p.jsx)(MG,{onClick:t,children:`重试`})})]})})}function sG(){let[e,t]=(0,u.useState)(fG);return(0,u.useRef)(!1),(0,u.useEffect)(()=>(pG.add(t),()=>{pG.delete(t)}),[]),(0,p.jsx)(aG,{children:iG()===`iframe`?(0,p.jsx)(cG,{boardId:e}):(0,p.jsx)(eG,{boardId:e,apiBase:uG})})}function cG({boardId:e}){return(0,p.jsx)(`iframe`,{src:gG(e),onLoad:()=>{try{fetch(`http://127.0.0.1:8791/api/plugin-alive?stage=iframe-load`,{mode:`no-cors`}).catch(()=>{})}catch{}},onError:()=>{try{fetch(`http://127.0.0.1:8791/api/plugin-alive?stage=iframe-error`,{mode:`no-cors`}).catch(()=>{})}catch{}},title:`AgentFlow`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`,background:`#f7f8fa`}})}function lG({size:e}){let t=typeof e==`number`?e:16;return(0,p.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,p.jsx)(`rect`,{x:1.5,y:6,width:4,height:4,rx:1}),(0,p.jsx)(`rect`,{x:10.5,y:1.5,width:4,height:4,rx:1}),(0,p.jsx)(`rect`,{x:10.5,y:10.5,width:4,height:4,rx:1}),(0,p.jsx)(`path`,{d:`M5.5 8h2.5V3.5h2.5M8 8v4.5h2.5`})]})}var uG=`http://127.0.0.1:8791`,dG=null,fG=``,pG=new Set;function mG(e){fG=String(e||``);for(let e of pG)try{e(fG)}catch{}}function hG(){try{if(document.body&&document.body.hasAttribute(`data-ds-dark-theme`)||document.documentElement.classList.contains(`dark`))return`dark`}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function gG(e){let t=new URLSearchParams;return e&&t.set(`board`,e),t.set(`theme`,hG()),`${uG}/?${t.toString()}`}function _G(){try{if(dG&&typeof dG.selectPanel==`function`)return dG.selectPanel(tG),!0}catch{}return!1}var vG=`agentflow`,yG=[`slots`,`layout`];function bG(e,t){try{let n=`${e}: ${t?.stack||String(t)}`;fetch(`${uG}/api/plugin-alive?stage=apply-error&detail=${encodeURIComponent(n.slice(0,800))}`,{mode:`no-cors`}).catch(()=>{})}catch{}}function xG(e,t,n,r){try{e.slots.inject(n,()=>{try{return r()}catch(e){bG(t,e);return}})}catch(e){bG(t,e)}}function SG(e,t){try{CG(e,t)}catch(e){bG(`apply`,e),console.error(`[agentflow] 客户端插件初始化失败:`,e)}}function CG(e,t){t&&typeof t.agentflowUrl==`string`&&t.agentflowUrl&&(uG=t.agentflowUrl,LW(t.agentflowUrl)),rG=t?.agentflowRenderMode===`iframe`?`iframe`:`native`;let n=null;try{n=e.layout??null}catch(e){bG(`layout`,e),n=null}dG=n,xG(e,`main`,`main`,()=>e.slots.register({name:`main`,key:tG},sG)),xG(e,`settings.section`,`settings.section`,()=>e.slots.register({name:`settings.section`,id:`agentflow`,order:90,label:()=>`AgentFlow`,inject:()=>({})},NG)),xG(e,`plugins.add.actions`,`plugins.add.actions`,()=>e.slots.register({name:`plugins.add.actions`,id:`agentflow-export`,inject:()=>({})},PG)),xG(e,`sidebar.panellist`,`sidebar.panellist`,()=>e.slots.register({name:`sidebar.panellist`,id:tG,order:nG,label:()=>`AgentFlow`},e=>(0,p.jsx)(lG,{...e})))}var wG={border:`1px solid rgba(128,130,120,0.28)`,borderRadius:12,padding:`14px 16px`,background:`rgba(128,130,120,0.06)`,maxWidth:560},TG={border:`none`,borderRadius:8,padding:`8px 14px`,fontSize:13,fontWeight:600,color:`#fff`,background:`#24543F`,cursor:`pointer`},EG={...TG,opacity:.55,cursor:`not-allowed`};function DG(){let[e,t]=(0,u.useState)(!1),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null);return{busy:e,result:n,error:i,run:()=>{e||(t(!0),a(null),r(null),fetch(`${uG}/api/export/preset`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`HTTP ${e.status}`);return t}).then(e=>r(e)).catch(e=>a(String(e&&e.message||e))).finally(()=>t(!1)))}}}function OG(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),i=()=>{r(null),fetch(`${uG}/api/board`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t).catch(e=>r(String(e&&e.message||e)))};return(0,u.useEffect)(i,[]),{board:e,error:n,reload:i}}function kG({busy:e,result:t,error:n}){return n?(0,p.jsx)(`div`,{style:{marginTop:10,fontSize:12,color:`#B4451F`,lineHeight:1.6},children:`导出失败:${n}`}):e?(0,p.jsx)(`div`,{style:{marginTop:10,fontSize:12,opacity:.7},children:`正在写入 profile…`}):t?(0,p.jsxs)(`div`,{style:{marginTop:10,fontSize:12,lineHeight:1.7},children:[(0,p.jsxs)(`div`,{children:[`已${t.replaced?`更新`:`写入`}预设 `,(0,p.jsx)(`b`,{children:t.presetId||``})]}),(0,p.jsx)(`div`,{style:{opacity:.7,wordBreak:`break-all`},children:t.file||``}),(0,p.jsx)(`div`,{style:{marginTop:4,fontWeight:600},children:`重启 DSH 后生效`})]}):null}function AG(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),o=()=>{r(null),fetch(`${uG}/api/presets`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();if(n.error)throw Error(n.error);t(n.presets||[])}).catch(e=>r(String(e&&e.message||e)))};return(0,u.useEffect)(o,[]),{presets:e,error:n,busyId:i,reload:o,copy:e=>{a(e.id),r(null),fetch(`${uG}/api/presets/${encodeURIComponent(e.id)}/copy`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:`${e.name} 副本`})}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`HTTP ${e.status}`);return t}).then(()=>o()).catch(e=>r(String(e&&e.message||e))).finally(()=>a(null))},remove:e=>{window.confirm(`删除预设「${e.name}」?只删 profile 里的这一行,重启 DSH 生效。`)&&(a(e.id),r(null),fetch(`${uG}/api/presets/${encodeURIComponent(e.id)}`,{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`HTTP ${e.status}`);return t}).then(()=>o()).catch(e=>r(String(e&&e.message||e))).finally(()=>a(null)))}}}var jG={display:`inline-block`,padding:`1px 7px`,borderRadius:999,fontSize:11,border:`1px solid rgba(128,130,120,0.35)`,opacity:.85};function MG({children:e,onClick:t,disabled:n,danger:r}){return(0,p.jsx)(`button`,{type:`button`,onClick:t,disabled:n,style:{border:`1px solid ${r?`rgba(180,69,31,0.45)`:`rgba(128,130,120,0.35)`}`,borderRadius:7,padding:`4px 10px`,fontSize:12,background:`transparent`,color:r?`#B4451F`:`inherit`,cursor:n?`not-allowed`:`pointer`,opacity:n?.5:1},children:e})}function NG({close:e}){let[t,n]=(0,u.useState)(!1),r=t=>{if(mG(t),_G())try{typeof e==`function`&&e()}catch{}else n(!0)},{board:i,error:a,reload:o}=OG(),{busy:s,result:c,error:l,run:d}=DG(),{presets:f,error:m,busyId:h,reload:g,copy:_,remove:v}=AG(),y=i?.nodes?.length??0,b=i?.edges?.length??0;return(0,p.jsxs)(`div`,{style:wG,children:[t?(0,p.jsxs)(`div`,{style:{position:`fixed`,inset:0,zIndex:9999,background:`rgba(0,0,0,0.45)`,display:`flex`,flexDirection:`column`},children:[(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,background:`#17181B`,color:`#EDEDE8`,fontSize:13},children:[(0,p.jsx)(`span`,{children:`AgentFlow 画布`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>n(!1),style:{border:`1px solid rgba(255,255,255,0.25)`,borderRadius:7,padding:`4px 12px`,fontSize:12,background:`transparent`,color:`inherit`,cursor:`pointer`},children:`关闭`})]}),(0,p.jsx)(`iframe`,{src:gG(fG),title:`AgentFlow 画布`,style:{flex:1,width:`100%`,border:`none`,background:`#F4F5F2`}})]}):null,(0,p.jsx)(`div`,{style:{fontSize:14,fontWeight:600,marginBottom:6},children:`AgentFlow 画布 → 预设`}),(0,p.jsx)(`div`,{style:{fontSize:12.5,lineHeight:1.7,opacity:.78},children:a?`读不到画布:${a}(确认 AgentFlow 服务在 ${uG} 运行)`:i?`当前画布「${i.name||`未命名`}」${y} 个节点 / ${b} 条连线`:`正在读取画布…`}),(0,p.jsxs)(`div`,{style:{marginTop:12,display:`flex`,gap:10,alignItems:`center`},children:[(0,p.jsx)(`button`,{type:`button`,onClick:d,disabled:s||a!==null,style:s||a!==null?EG:TG,children:s?`导出中…`:`导出当前画布为预设`}),(0,p.jsx)(`button`,{type:`button`,onClick:o,style:{border:`1px solid rgba(128,130,120,0.35)`,borderRadius:8,padding:`7px 12px`,fontSize:12.5,background:`transparent`,color:`inherit`,cursor:`pointer`},children:`刷新画布信息`})]}),(0,p.jsxs)(`div`,{style:{marginTop:16,borderTop:`1px solid rgba(128,130,120,0.25)`,paddingTop:12},children:[(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,p.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:`自定义预设`}),(0,p.jsx)(MG,{onClick:g,disabled:h!==null,children:`刷新`})]}),m?(0,p.jsx)(`div`,{style:{fontSize:12,color:`#B4451F`},children:`读取失败:${m}`}):null,f?f.length===0?(0,p.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`还没有自定义预设`}):(0,p.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:f.map(e=>(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 10px`,borderRadius:9,background:`rgba(128,130,120,0.08)`},children:[(0,p.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,p.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.name}),(0,p.jsxs)(`div`,{style:{fontSize:11,opacity:.65,display:`flex`,gap:6,flexWrap:`wrap`,marginTop:2},children:[(0,p.jsx)(`span`,{children:e.id}),(0,p.jsx)(`span`,{style:jG,children:e.source===`profile`?`profile`:e.packageName||`插件包`})]})]}),(0,p.jsx)(MG,{onClick:()=>_(e),disabled:h!==null,children:h===e.id?`处理中…`:`复制`}),e.editable?(0,p.jsx)(MG,{onClick:()=>v(e),disabled:h!==null,danger:!0,children:`删除`}):null,(0,p.jsx)(MG,{onClick:()=>r(e.id),children:`编辑`})]},e.id))}):(0,p.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`读取中…`}),(0,p.jsx)(`div`,{style:{fontSize:11,opacity:.6,marginTop:8,lineHeight:1.6},children:`插件包自带的预设(Sharp Agent / 群友腔)只能复制成自己的再改;删除与编辑只对 profile 里的预设开放。改完记得重启 DSH。`})]}),(0,p.jsx)(kG,{busy:s,result:c,error:l})]})}function PG(){let{busy:e,error:t,run:n}=DG();return(0,p.jsxs)(`button`,{type:`button`,onClick:n,disabled:e,style:{display:`block`,width:`100%`,textAlign:`left`,border:`none`,background:`transparent`,color:`inherit`,padding:`8px 12px`,fontSize:13,cursor:e?`not-allowed`:`pointer`,opacity:e?.6:1},children:[e?`正在导出 AgentFlow 预设…`:`从 AgentFlow 画布生成预设`,t?(0,p.jsx)(`span`,{style:{display:`block`,fontSize:11,color:`#B4451F`},children:t}):null]})}exports.apply=SG,exports.inject=yG,exports.name=vG;return module.exports; } });
|
|
364
|
+
`;function JW(){if(typeof document>`u`||document.querySelector(`style[${VW}]`))return;let e=m.replace(/:root\b(\s*,\s*:host\b)?/g,`.af-canvas`),t=document.createElement(`style`);t.setAttribute(VW,``),t.textContent=`${h}\n${e}\n${qW}`,document.head.appendChild(t)}function YW(e,t){return new Promise(n=>{let r=window.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e),i=()=>{window.clearTimeout(r),n()};t.addEventListener(`abort`,i,{once:!0})})}async function XW(e){let t=Date.now()+UW;for(let n=0;n<HW.length;n+=1){if(e.aborted)return!1;let r=HW[n];if(r>0&&await YW(r,e),e.aborted)return!1;let i=t-Date.now();if(i<=0)return!1;let a=new AbortController,o=()=>a.abort();e.addEventListener(`abort`,o,{once:!0});let s=window.setTimeout(()=>a.abort(),Math.min(i,WW));try{if((await fetch(`${LW()}/api/plugin-alive`,{method:`GET`,cache:`no-store`,signal:a.signal})).ok)return!0}catch{}finally{window.clearTimeout(s),e.removeEventListener(`abort`,o)}}return!1}function ZW(e){let t=e.theme===`dark`;return(0,p.jsx)(`div`,{className:`af-host`,style:{height:`100%`,minHeight:160,display:`grid`,placeItems:`center`,padding:24,background:t?`#121312`:`#f4f5f2`,color:t?`#e8e8e4`:`#1c1c1a`},children:(0,p.jsxs)(`div`,{className:`af-host-notice`,style:{border:`1px solid ${t?`#262724`:`#e2e4e0`}`,background:t?`#17181b`:`#fcfcfa`},children:[(0,p.jsx)(`div`,{className:`af-host-notice-title`,children:e.title}),e.detail?(0,p.jsx)(`div`,{className:`af-host-notice-detail`,children:e.detail}):null,(0,p.jsxs)(`div`,{className:`af-host-notice-actions`,children:[e.busy?(0,p.jsx)(`span`,{className:`af-host-spinner`,"aria-hidden":`true`}):null,e.onAction&&e.actionLabel?(0,p.jsx)(`button`,{type:`button`,className:`af-host-button`,onClick:e.onAction,children:e.actionLabel}):null]})]})})}var QW=class extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[agentflow] 内联画布渲染失败:`,e,t.componentStack)}render(){return this.state.error?(0,p.jsx)(ZW,{theme:this.props.theme,title:`画布渲染出错`,detail:this.state.error.message||String(this.state.error),actionLabel:`重试`,onAction:()=>this.setState({error:null})}):this.props.children}};function $W({boardId:e,apiBase:t}){let n=e??``,[r,i]=(0,u.useState)(()=>{t&&IW(t),JW();let e=RW();return KW({apiBase:LW(),theme:e,boardId:n}),e});(0,u.useEffect)(()=>zW(i),[]),(0,u.useEffect)(()=>{let e=GW();e&&(e.theme=r),window.dispatchEvent(new CustomEvent(`agentflow-theme`,{detail:{theme:r}}))},[r]);let a=(0,u.useRef)(n);(0,u.useEffect)(()=>{let e=GW();e&&(e.boardId=n),a.current!==n&&(a.current=n,window.dispatchEvent(new CustomEvent(`agentflow-board`,{detail:{boardId:n}})))},[n]),(0,u.useEffect)(()=>{if(!t)return;let e=IW(t),n=GW();n&&(n.apiBase=e)},[t]);let[o,s]=(0,u.useState)(`checking`),[c,l]=(0,u.useState)(0);(0,u.useEffect)(()=>{let e=!1,t=new AbortController;return s(`checking`),XW(t.signal).then(t=>{e||s(t?`ready`:`error`)}),()=>{e=!0,t.abort()}},[c]);let d=(0,u.useRef)(null),[f,m]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{let e=d.current;if(!e)return;let t=f,n=()=>{if(t)return;let n=e.parentElement,r=n?n.getBoundingClientRect().height:0,i=e.getBoundingClientRect().height;(r<1||i<1)&&(t=!0,m(!0))};n();let r=window.requestAnimationFrame(n),i=null;try{i=new ResizeObserver(n),e.parentElement&&i.observe(e.parentElement)}catch{i=null}return window.addEventListener(`resize`,n),()=>{window.cancelAnimationFrame(r),i&&i.disconnect(),window.removeEventListener(`resize`,n)}},[]),(0,p.jsx)(`div`,{ref:d,className:`af-host`,"data-agentflow-host":``,style:{position:`relative`,width:`100%`,height:f?`100vh`:`100%`,minHeight:0,overflow:`hidden`,background:r===`dark`?`#121312`:`#f4f5f2`,colorScheme:r===`dark`?`dark`:`light`},children:o===`checking`?(0,p.jsx)(ZW,{theme:r,title:`正在连接 AgentFlow 后端…`,detail:`等待 ${LW()} 就绪`,busy:!0}):o===`error`?(0,p.jsx)(ZW,{theme:r,title:`连不上 AgentFlow 后端`,detail:`请确认 ${LW()} 上的 AgentFlow 服务已启动后重试。`,actionLabel:`重试`,onAction:()=>l(e=>e+1)}):(0,p.jsx)(QW,{theme:r,children:(0,p.jsx)(kW,{})})})}var eG=`agentflow`,tG=30,nG=`native`;function rG(){return nG}var iG=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){yG(`render`,e),console.error(`[agentflow] 画布渲染失败:`,e,t.componentStack)}render(){return this.state.error?(0,p.jsx)(aG,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}};function aG({error:e,onRetry:t}){return(0,p.jsx)(`div`,{style:{padding:16},children:(0,p.jsxs)(`div`,{style:{...CG,borderColor:`rgba(180,69,31,0.45)`,maxWidth:640},children:[(0,p.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`#B4451F`,marginBottom:6},children:`AgentFlow 画布渲染失败`}),(0,p.jsx)(`div`,{style:{fontSize:12.5,lineHeight:1.7,opacity:.8,wordBreak:`break-all`},children:e.message||String(e)}),(0,p.jsx)(`div`,{style:{marginTop:10},children:(0,p.jsx)(NG,{onClick:t,children:`重试`})})]})})}function oG(){let[e,t]=(0,u.useState)(dG);return(0,u.useEffect)(()=>(fG.add(t),()=>{fG.delete(t)}),[]),(0,p.jsx)(iG,{children:rG()===`iframe`?(0,p.jsx)(sG,{boardId:e}):(0,p.jsx)($W,{boardId:e,apiBase:lG})})}function sG({boardId:e}){return(0,p.jsx)(`iframe`,{src:hG(e),onLoad:()=>{try{fetch(`http://127.0.0.1:8791/api/plugin-alive?stage=iframe-load`,{mode:`no-cors`}).catch(()=>{})}catch{}},onError:()=>{try{fetch(`http://127.0.0.1:8791/api/plugin-alive?stage=iframe-error`,{mode:`no-cors`}).catch(()=>{})}catch{}},title:`AgentFlow`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`,background:`#f7f8fa`}})}function cG({size:e}){let t=typeof e==`number`?e:16;return(0,p.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,p.jsx)(`rect`,{x:1.5,y:6,width:4,height:4,rx:1}),(0,p.jsx)(`rect`,{x:10.5,y:1.5,width:4,height:4,rx:1}),(0,p.jsx)(`rect`,{x:10.5,y:10.5,width:4,height:4,rx:1}),(0,p.jsx)(`path`,{d:`M5.5 8h2.5V3.5h2.5M8 8v4.5h2.5`})]})}var lG=`http://127.0.0.1:8791`,uG=null,dG=``,fG=new Set;function pG(e){dG=String(e||``);for(let e of fG)try{e(dG)}catch{}}function mG(){try{if(document.body&&document.body.hasAttribute(`data-ds-dark-theme`)||document.documentElement.classList.contains(`dark`))return`dark`}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function hG(e){let t=new URLSearchParams;return e&&t.set(`board`,e),t.set(`theme`,mG()),`${lG}/?${t.toString()}`}function gG(){try{if(uG&&typeof uG.selectPanel==`function`)return uG.selectPanel(eG),!0}catch{}return!1}var _G=`agentflow`,vG=[`slots`,`layout`];function yG(e,t){try{let n=`${e}: ${t?.stack||String(t)}`;fetch(`${lG}/api/plugin-alive?stage=apply-error&detail=${encodeURIComponent(n.slice(0,800))}`,{mode:`no-cors`}).catch(()=>{})}catch{}}function bG(e,t,n,r){try{e.slots.inject(n,()=>{try{return r()}catch(e){yG(t,e);return}})}catch(e){yG(t,e)}}function xG(e,t){try{SG(e,t)}catch(e){yG(`apply`,e),console.error(`[agentflow] 客户端插件初始化失败:`,e)}}function SG(e,t){t&&typeof t.agentflowUrl==`string`&&t.agentflowUrl&&(lG=t.agentflowUrl,IW(t.agentflowUrl)),nG=t?.agentflowRenderMode===`iframe`?`iframe`:`native`;let n=null;try{n=e.layout??null}catch(e){yG(`layout`,e),n=null}uG=n,bG(e,`main`,`main`,()=>e.slots.register({name:`main`,key:eG},oG)),bG(e,`settings.section`,`settings.section`,()=>e.slots.register({name:`settings.section`,id:`agentflow`,order:90,label:()=>`AgentFlow`,inject:()=>({})},PG)),bG(e,`plugins.add.actions`,`plugins.add.actions`,()=>e.slots.register({name:`plugins.add.actions`,id:`agentflow-export`,inject:()=>({})},FG)),bG(e,`sidebar.panellist`,`sidebar.panellist`,()=>e.slots.register({name:`sidebar.panellist`,id:eG,order:tG,label:()=>`AgentFlow`},e=>(0,p.jsx)(cG,{...e})))}var CG={border:`1px solid rgba(128,130,120,0.28)`,borderRadius:12,padding:`14px 16px`,background:`rgba(128,130,120,0.06)`,maxWidth:560},wG={border:`none`,borderRadius:8,padding:`8px 14px`,fontSize:13,fontWeight:600,color:`#fff`,background:`#24543F`,cursor:`pointer`},TG={...wG,opacity:.55,cursor:`not-allowed`};function EG(){let[e,t]=(0,u.useState)(``);return(0,u.useEffect)(()=>{let e=e=>{let n=e.detail?.boardId;typeof n==`string`&&n&&t(n)};return window.addEventListener(`agentflow-board-active`,e),()=>window.removeEventListener(`agentflow-board-active`,e)},[]),e}function DG(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}board=${encodeURIComponent(t)}`:e}function OG(e){let[t,n]=(0,u.useState)(!1),[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(null);return{busy:t,result:r,error:a,run:()=>{t||(n(!0),o(null),i(null),fetch(`${lG}${DG(`/api/export/command`,e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`HTTP ${e.status}`);return t}).then(e=>i(e)).catch(e=>o(String(e&&e.message||e))).finally(()=>n(!1)))}}}function kG(e){let[t,n]=(0,u.useState)(null),[r,i]=(0,u.useState)(null),a=()=>{i(null),fetch(`${lG}${e?`/api/boards/${encodeURIComponent(e)}`:`/api/board`}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(n).catch(e=>i(String(e&&e.message||e)))};return(0,u.useEffect)(a,[]),{board:t,error:r,reload:a}}function AG({busy:e,result:t,error:n}){if(n)return(0,p.jsx)(`div`,{style:{marginTop:10,fontSize:12,color:`#B4451F`,lineHeight:1.6},children:`生成失败:${n}`});if(e)return(0,p.jsx)(`div`,{style:{marginTop:10,fontSize:12,opacity:.7},children:`正在生成命令…`});if(!t)return null;let r=t.name?`/${t.name}`:``;return(0,p.jsxs)(`div`,{style:{marginTop:10,fontSize:12,lineHeight:1.7},children:[(0,p.jsxs)(`div`,{children:[`已${t.replaced?`更新`:`生成`}命令 `,(0,p.jsx)(`b`,{children:r})]}),(0,p.jsx)(`div`,{style:{opacity:.7,wordBreak:`break-all`},children:t.file||``}),(0,p.jsx)(`div`,{style:{marginTop:4,fontWeight:600},children:`输入框输入 ${r} 即可使用(无需重启)`})]})}function jG(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),o=()=>{r(null),fetch(`${lG}/api/presets`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();if(n.error)throw Error(n.error);t(n.presets||[])}).catch(e=>r(String(e&&e.message||e)))};return(0,u.useEffect)(o,[]),{presets:e,error:n,busyId:i,reload:o,remove:e=>{window.confirm(`删除预设「${e.name}」?只删 profile 里的这一行,重启 DSH 生效。`)&&(a(e.id),r(null),fetch(`${lG}/api/presets/${encodeURIComponent(e.id)}`,{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`HTTP ${e.status}`);return t}).then(()=>o()).catch(e=>r(String(e&&e.message||e))).finally(()=>a(null)))}}}var MG={display:`inline-block`,padding:`1px 7px`,borderRadius:999,fontSize:11,border:`1px solid rgba(128,130,120,0.35)`,opacity:.85};function NG({children:e,onClick:t,disabled:n,danger:r}){return(0,p.jsx)(`button`,{type:`button`,onClick:t,disabled:n,style:{border:`1px solid ${r?`rgba(180,69,31,0.45)`:`rgba(128,130,120,0.35)`}`,borderRadius:7,padding:`4px 10px`,fontSize:12,background:`transparent`,color:r?`#B4451F`:`inherit`,cursor:n?`not-allowed`:`pointer`,opacity:n?.5:1},children:e})}function PG({close:e}){let[t,n]=(0,u.useState)(!1),r=t=>{if(pG(t),gG())try{typeof e==`function`&&e()}catch{}else n(!0)},i=EG(),{board:a,error:o,reload:s}=kG(i),{busy:c,result:l,error:d,run:f}=OG(i),{presets:m,error:h,busyId:g,reload:_,remove:v}=jG(),y=a?.nodes?.length??0,b=a?.edges?.length??0;return(0,p.jsxs)(`div`,{style:CG,children:[t?(0,p.jsxs)(`div`,{style:{position:`fixed`,inset:0,zIndex:9999,background:`rgba(0,0,0,0.45)`,display:`flex`,flexDirection:`column`},children:[(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`8px 12px`,background:`#17181B`,color:`#EDEDE8`,fontSize:13},children:[(0,p.jsx)(`span`,{children:`AgentFlow 画布`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>n(!1),style:{border:`1px solid rgba(255,255,255,0.25)`,borderRadius:7,padding:`4px 12px`,fontSize:12,background:`transparent`,color:`inherit`,cursor:`pointer`},children:`关闭`})]}),(0,p.jsx)(`iframe`,{src:hG(dG),title:`AgentFlow 画布`,style:{flex:1,width:`100%`,border:`none`,background:`#F4F5F2`}})]}):null,(0,p.jsx)(`div`,{style:{fontSize:14,fontWeight:600,marginBottom:6},children:`AgentFlow 画布 → 命令`}),(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,p.jsx)(`div`,{style:{fontSize:12.5,lineHeight:1.7,opacity:.78,flex:1},children:o?`读不到画布:${o}(确认 AgentFlow 服务在 ${lG} 运行)`:a?`当前画布「${a.name||`未命名`}」${y} 个节点 / ${b} 条连线`:`正在读取画布…`}),(0,p.jsx)(NG,{onClick:()=>{a&&a.id&&r(a.id)},disabled:!a||!a.id,children:`打开画布`})]}),(0,p.jsxs)(`div`,{style:{marginTop:12,display:`flex`,gap:10,alignItems:`center`},children:[(0,p.jsx)(`button`,{type:`button`,onClick:f,disabled:c||o!==null,style:c||o!==null?TG:wG,children:c?`生成中…`:`生成当前画布命令`}),(0,p.jsx)(`button`,{type:`button`,onClick:s,style:{border:`1px solid rgba(128,130,120,0.35)`,borderRadius:8,padding:`7px 12px`,fontSize:12.5,background:`transparent`,color:`inherit`,cursor:`pointer`},children:`刷新画布信息`})]}),(0,p.jsxs)(`div`,{style:{marginTop:16,borderTop:`1px solid rgba(128,130,120,0.25)`,paddingTop:12},children:[(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,p.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:`旧预设清理`}),(0,p.jsx)(NG,{onClick:_,disabled:g!==null,children:`刷新`})]}),(0,p.jsx)(`div`,{style:{fontSize:11.5,opacity:.68,lineHeight:1.6,marginBottom:8},children:`预设生成已下线,这里只清理历史残留(profile 里旧预设留下的行);删除后重启 DSH 生效。`}),h?(0,p.jsx)(`div`,{style:{fontSize:12,color:`#B4451F`},children:`读取失败:${h}`}):null,m?m.length===0?(0,p.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`没有历史预设残留`}):(0,p.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:m.map(e=>(0,p.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 10px`,borderRadius:9,background:`rgba(128,130,120,0.08)`},children:[(0,p.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,p.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.name}),(0,p.jsxs)(`div`,{style:{fontSize:11,opacity:.65,display:`flex`,gap:6,flexWrap:`wrap`,marginTop:2},children:[(0,p.jsx)(`span`,{children:e.id}),(0,p.jsx)(`span`,{style:MG,children:e.source===`profile`?`profile`:e.packageName||`插件包`})]})]}),e.editable?(0,p.jsx)(NG,{onClick:()=>v(e),disabled:g!==null,danger:!0,children:g===e.id?`删除中…`:`删除`}):null]},e.id))}):(0,p.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`读取中…`})]}),(0,p.jsx)(AG,{busy:c,result:l,error:d})]})}function FG(){let{busy:e,result:t,error:n,run:r}=OG(EG());return(0,p.jsxs)(`button`,{type:`button`,onClick:r,disabled:e,style:{display:`block`,width:`100%`,textAlign:`left`,border:`none`,background:`transparent`,color:`inherit`,padding:`8px 12px`,fontSize:13,cursor:e?`not-allowed`:`pointer`,opacity:e?.6:1},children:[e?`正在生成 AgentFlow 命令…`:`从 AgentFlow 画布生成命令`,n?(0,p.jsx)(`span`,{style:{display:`block`,fontSize:11,color:`#B4451F`},children:n}):null,!n&&t&&t.name?(0,p.jsx)(`span`,{style:{display:`block`,fontSize:11,opacity:.7,marginTop:2,lineHeight:1.6},children:`已${t.replaced?`更新`:`生成`} /${t.name},输入框输入即可使用(无需重启)`}):null]})}exports.apply=xG,exports.inject=vG,exports.name=_G;return module.exports; } });
|