@fieldwangai/agentflow 0.1.44 → 0.1.45

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.
@@ -125,7 +125,7 @@ script: node -e "console.log('TODO: scripts/x.mjs')"
125
125
 
126
126
  `).trimEnd()}function Dy(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function MU(e){const t=String(e||"");let n="",r=0;cm.lastIndex=0;let s;for(;s=cm.exec(t);)n+=Dy(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Dy(s[0])}</span>`,r=s.index+s[0].length;return n+=Dy(t.slice(r)),n||" "}function $U(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,u=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(u,2),8);return Math.ceil(d*r+s+i+a+l)}function OI({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:u,onModelChange:d}){var Vn,Mr;const{t:f}=wn(),c=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=IU(e),v=TU(g),k=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),b=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,N=(e==null?void 0:e.nodeStatus)??null,C=(e==null?void 0:e.nodeElapsed)??null,j=(e==null?void 0:e.definitionId)||"",R=j.startsWith("provide_"),D=j==="provide_bool",M=j==="provide_str",B=j==="provide_file",$=j==="agent_subAgent",A=$&&!k,z=D?RU(p[0]):!1,T=R?String(((Vn=p[0])==null?void 0:Vn.value)??((Mr=p[0])==null?void 0:Mr.default)??(e==null?void 0:e.body)??""):"",L=String((e==null?void 0:e.body)||""),I=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),F=!R&&!A&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",P=os(e==null?void 0:e.images),O=m.useRef(!1),_=m.useRef(!1),G=m.useRef(null),Z=m.useRef(null),U=m.useRef(null),[ie,de]=m.useState(T),[he,ye]=m.useState(L);m.useEffect(()=>{O.current||de(T)},[n,T]),m.useEffect(()=>{_.current||ye(L)},[n,L]),m.useEffect(()=>{const we=Z.current;if(!we)return;const $e=$U(we,he);we.style.minHeight=`${$e}px`,we.style.height="",U.current&&(U.current.style.minHeight=`${$e}px`,U.current.style.height="")},[he]),m.useEffect(()=>{const we=G.current,$e=e==null?void 0:e.onNodeContentResize;if(!A||!we||!$e||typeof ResizeObserver>"u")return;let et=0;const Lt=()=>{window.cancelAnimationFrame(et),et=window.requestAnimationFrame(()=>$e(n))},Qt=new ResizeObserver(Lt);return Qt.observe(we),Lt(),()=>{window.cancelAnimationFrame(et),Qt.disconnect()}},[e==null?void 0:e.onNodeContentResize,A,n]);const oe=Array.isArray(u==null?void 0:u.cursor)?u.cursor:[],Se=Array.isArray(u==null?void 0:u.opencode)?u.opencode:[],_e=Array.isArray(u==null?void 0:u.claudeCode)?u.claudeCode:[],ve=((e==null?void 0:e.model)??"").trim(),Pe=h==="agent"&&!j.startsWith("tool_nodejs"),Ce=new Set(oe.map(ko)),Je=new Set(Se.map(ko)),nt=new Set(_e.map(ko)),Ue=ve?ve.startsWith("cursor:")||ve.startsWith("opencode:")||ve.startsWith("claude-code:")?ve:nt.has(ve)?`claude-code:${ve}`:Je.has(ve)?`opencode:${ve}`:Ce.has(ve)?`cursor:${ve}`:ve:"",_t=ve&&!Ue.startsWith("cursor:")&&!Ue.startsWith("opencode:")&&!Ue.startsWith("claude-code:")&&!Ce.has(ve)&&!Je.has(ve)&&!nt.has(ve),qe=ve.startsWith("cursor:")?ve.slice(7):ve.startsWith("opencode:")?ve.slice(9):ve.startsWith("claude-code:")?ve.slice(12):ve,gt=we=>{if(y)return;const $e=we.target.value;d&&d(n,$e)},Ft=we=>{we.stopPropagation(),!y&&r&&r(n)},Fe=we=>{we.stopPropagation(),s&&s()},tn=we=>{we.stopPropagation(),!y&&(i==null||i(n,we.target.value==="true"?"true":"false"))},Jt=we=>{if(we.stopPropagation(),y)return;const $e=we.target.value;de($e),O.current||i==null||i(n,$e)},bn=we=>{we.stopPropagation(),O.current=!0},ue=we=>{if(we.stopPropagation(),y)return;O.current=!1;const $e=we.currentTarget.value;de($e),i==null||i(n,$e)},ee=()=>{y||i==null||i(n,ie)},me=we=>{if(we.stopPropagation(),y)return;const $e=window.prompt("文件路径",ie);$e!=null&&(de($e),i==null||i(n,$e))},Me=we=>{if(ye(we),a==null||a(n,we),l){const $e=mU(P,we);($e.length!==P.length||$e.some((et,Lt)=>{var Qt;return et.id!==((Qt=P[Lt])==null?void 0:Qt.id)}))&&l(n,$e)}},ce=we=>{if(we.stopPropagation(),y)return;const $e=we.target.value;_.current?ye($e):Me($e)},rt=we=>{we.stopPropagation(),!y&&(_.current=!0)},qt=we=>{if(we.stopPropagation(),y)return;_.current=!1;const $e=we.currentTarget.value;Me($e)},qn=()=>{y||Me(he)},vn=async we=>{if(y)return;const $e=await AI({files:we,body:he,images:P});$e&&(ye($e.body),a==null||a(n,$e.body),l==null||l(n,$e.images))},nn=(we,$e)=>{if(we.stopPropagation(),y)return;const et=P.filter(Qt=>Qt.id!==$e.id),Lt=OU(he,$e.label);ye(Lt),a==null||a(n,Lt),l==null||l(n,et)},mr=we=>{if(y)return;const $e=PI(we);$e.length!==0&&(we.preventDefault(),we.stopPropagation(),vn($e).catch(()=>{}))},dn=we=>{if(y)return;const $e=um(we);$e.length!==0&&(we.preventDefault(),we.stopPropagation(),vn($e).catch(()=>{}))},Yn=()=>{const we=Z.current,$e=U.current;!we||!$e||($e.scrollTop=we.scrollTop,$e.scrollLeft=we.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(b?" af-flow-node--executing":"")+(N==="success"?" af-flow-node--done":"")+(N==="failed"?" af-flow-node--failed":"")+(N==="running"&&!b?" af-flow-node--running-disk":"")+(w?" af-flow-node--dim":"")+(A?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+h.replace(/[^a-z0-9_-]/g,""),"data-schema":h,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:v}),!k&&Pe&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:er,onMouseDown:er,onClick:er,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:Ue,onChange:gt,onPointerDown:er,onMouseDown:er,onClick:er,"aria-label":f("flow:node.model"),title:qe||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),_t&&o.jsx("option",{value:ve,children:ve}),oe.length>0&&o.jsx("optgroup",{label:"Cursor",children:oe.map(we=>o.jsx("option",{value:`cursor:${ko(we)}`,children:ko(we)},`c-${we}`))}),Se.length>0&&o.jsx("optgroup",{label:"OpenCode",children:Se.map(we=>o.jsx("option",{value:`opencode:${ko(we)}`,children:ko(we)},`o-${we}`))}),_e.length>0&&o.jsx("optgroup",{label:"Claude Code",children:_e.map(we=>o.jsx("option",{value:`claude-code:${ko(we)}`,children:ko(we)},`cc-${we}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),b&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),N==="running"&&!b&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),N==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:C!=null&&String(C).trim()!==""?C:"--"}),N==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&R&&!D&&!M&&!B&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Fe,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:Ft,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:c.map((we,$e)=>{if(we.showOnNode===!1)return null;const et=f("flow:node.inputTooltip",{name:we.name||`#${$e}`,type:we.type})+(we.default!=null&&we.default!==""?f("flow:node.defaultSuffix",{value:we.default}):""),Lt=we.name||`#${$e+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:et,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Lt,we.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(ps,{type:"target",position:Ke.Left,id:`input-${$e}`,className:"af-flow-node__handle",style:{background:Wn(we.type)},title:et})]},`in-${$e}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:I}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,D?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(z?" af-flow-node__bool-select--true":""),value:z?"true":"false",onChange:tn,onPointerDown:er,onMouseDown:er,onClick:er,"aria-label":"Boolean value",title:z?"true":"false",disabled:y,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):M?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ie,onChange:Jt,onCompositionStart:bn,onCompositionEnd:ue,onBlur:ee,onPointerDown:er,onMouseDown:er,onClick:er,placeholder:"输入文本",rows:2,readOnly:y}):B?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:er,onMouseDown:er,onClick:er,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ie,onChange:Jt,onCompositionStart:bn,onCompositionEnd:ue,onBlur:ee,placeholder:"选择或输入文件路径",title:ie||"选择或输入文件路径",readOnly:y}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:me,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):$&&!k?o.jsxs("div",{ref:G,className:"af-flow-node__prompt-stack nodrag",onPointerDown:er,onMouseDown:er,onClick:er,children:[o.jsx("pre",{ref:U,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:MU(he)+`
127
127
  `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:he,onChange:ce,onCompositionStart:rt,onCompositionEnd:qt,onBlur:qn,onPaste:mr,onDrop:dn,onScroll:Yn,onDragOver:we=>{um(we).length>0&&we.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,$&&P.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:P.map((we,$e)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:we.name,children:[o.jsx("img",{src:we.dataUrl,alt:""}),o.jsxs("span",{children:["[",we.label||`image ${$e+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:et=>nn(et,we),onPointerDown:er,onMouseDown:er,"aria-label":`删除 ${we.label||`image ${$e+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},we.id||$e))}):null,F?o.jsx("span",{className:"af-flow-node__prompt-preview",title:F,children:F}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((we,$e)=>{if(we.showOnNode===!1)return null;const et=f("flow:node.outputTooltip",{name:we.name||`#${$e}`,type:we.type})+(we.default!=null&&we.default!==""?f("flow:node.defaultSuffix",{value:we.default}):""),Lt=we.name||`#${$e+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:et,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Lt,we.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(ps,{type:"source",position:Ke.Right,id:`output-${$e}`,className:"af-flow-node__handle",style:{background:Wn(we.type)},title:et})]},`out-${$e}`)})})]})]})}const Lf="flowNode";function MI(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function pm(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function DU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function FU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=wn(),a=m.useId(),l=m.useRef(null),[u,d]=m.useState(""),[f,c]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),h(""),c(!1);const y=requestAnimationFrame(()=>{var b;return(b=l.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=u.trim(),v=g===n;async function k(y){if(y.preventDefault(),!(!v||f)){c(!0),h("");try{const b=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await b.json().catch(()=>({}));if(!b.ok){h(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(b){h(String((b==null?void 0:b.message)||b))}finally{c(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:u,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!v})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function XN({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:u,onConfirm:d,onCancel:f}){const{t:c}=wn(),p=m.useId(),h=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=h.current)==null?void 0:w.focus()});function b(w){w.key==="Escape"&&f(),w.key==="Enter"&&d()}return window.addEventListener("keydown",b),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",b)}},[e,f,d]),!e)return null;const g=r??c("common:common.confirm","确定"),v=s??c("common:common.cancel","取消"),k=t??c("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&f()},children:o.jsxs("div",{ref:h,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:k}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":v,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:v}),a&&u?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:u,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function zU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=wn(),l=m.useId(),u=m.useRef(null),[d,f]=m.useState(""),[c,p]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;f(""),g(""),p(!1);const b=requestAnimationFrame(()=>{var w;return(w=u.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(b)},[e,n]),!e)return null;const v=d.trim(),k=v===n;async function y(b){if(b.preventDefault(),!k||c)return;p(!0),g("");let w=null;try{const N=new AbortController;w=setTimeout(()=>N.abort(),15e3);const C=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:v,flowArchived:s}),signal:N.signal}),j=await C.json().catch(()=>({}));if(!C.ok){g(typeof j.error=="string"?j.error:a("project:deleteModal.deleteFailed"));return}try{for(let R=localStorage.length-1;R>=0;R--){const D=localStorage.key(R);D&&(D.startsWith(`af:composer-sessions:${n}:${r}`)||D.startsWith(`af:composer-active-session:${n}:${r}`)||D.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(D)}}catch{}await i()}catch(N){if((N==null?void 0:N.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((N==null?void 0:N.message)||N))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:b=>f(b.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":v.length>0&&!k})]}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:c,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||c,children:a(c?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function BU({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Yi({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(BU,{children:t})]},n))})}function $I({open:e,onClose:t}){const{t:n}=wn(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=DU()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(Yi,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(Yi,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Yi,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(Yi,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(Yi,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(Yi,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(Yi,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Yi,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(Yi,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(Yi,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function HU(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function WU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=wn(),[i,a]=m.useState(""),[l,u]=m.useState(0),d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),u(0);const g=requestAnimationFrame(()=>{var v;return(v=d.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(g)},[e]);const c=m.useMemo(()=>{const g=(r||[]).map(y=>{var b,w,N;return{id:y.id,label:((b=y.data)==null?void 0:b.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((N=y.data)==null?void 0:N.schemaType)||""}}),v=i.trim(),k=g.map(y=>({e:y,s:HU(y,v)})).filter(y=>y.s>0);return k.sort((y,b)=>b.s-y.s||y.e.id.localeCompare(b.e.id)),k.slice(0,50).map(y=>y.e)},[r,i]);if(m.useEffect(()=>{l>=c.length&&u(0)},[c.length,l]),m.useEffect(()=>{var v;const g=(v=f.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const v=c[g];v&&(n(v.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),u(v=>Math.min(c.length-1,v+1));return}if(g.key==="ArrowUp"){g.preventDefault(),u(v=>Math.max(0,v-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),u(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:c.length})]}),c.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:c.map((g,v)=>o.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>u(v),onMouseDown:k=>{k.preventDefault(),p(v)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function VU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:u}){const{t:d}=wn(),f=m.useId(),c=m.useRef(null),p=m.useRef(null),[h,g]=m.useState(""),[v,k]=m.useState(""),[y,b]=m.useState(!1),[w,N]=m.useState(!1),[C,j]=m.useState(!1),[R,D]=m.useState(""),[M,B]=m.useState("");if(m.useEffect(()=>{if(!e||!i)return;g(""),k(""),D(""),B(""),b(!0),N(!1),j(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const P=await fetch(`/api/pipeline-file-content?${I}`),O=await P.json();if(!P.ok)throw new Error(O.error||"HTTP "+P.status);g(O.content||""),k(O.content||"")}catch(P){D(P.message||String(P))}finally{b(!1)}})();const F=requestAnimationFrame(()=>{var P;return(P=c.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(F)},[e,i,n,r,s]),!e)return null;const $=h!==v;async function A(I){if(I.preventDefault(),!w){N(!0),D(""),B("");try{const F=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),P=await fetch(`/api/pipeline-file-save?${F}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),O=await P.json();if(!P.ok)throw new Error(O.error||"HTTP "+P.status);k(h),B(d("flow:fileEdit.saved")),l&&l()}catch(F){D(F.message||String(F))}finally{N(!1)}}}async function z(){if(!(!u||C||!h)){j(!0),D("");try{const I=await u(h);typeof I=="string"&&I&&g(I)}catch(I){D(I.message||String(I))}finally{j(!1)}}}function T(){g(v),D(""),B("")}const L=h.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):R&&!h?o.jsx("div",{className:"af-file-edit-error",children:R}):o.jsxs(o.Fragment,{children:[L&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:h,onChange:I=>g(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(R||M)&&!y&&o.jsx("div",{className:`af-file-edit-status${M?" af-file-edit-status--success":""}`,children:M||R}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:T,disabled:!$||w||C,children:d("flow:fileEdit.reset")}),u&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:z,disabled:C||w||!h,children:d(C?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:A,disabled:!$||w||C,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const DI=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),UU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function KU(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function qU(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function JN(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function FI(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(DI.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function zI(e){return{inputNames:JN(e==null?void 0:e.inputs),outputNames:JN(e==null?void 0:e.outputs)}}function YU(e,t,n){const r=zI(t),s=qU(e),i=[];for(const a of s)if(!FI(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function GU(e,t){const n=zI(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],u=FI(a[1],n);s.push({kind:u?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function XU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function JU(e){return e.map(t=>{const n=XU(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function QU(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of UU)DI.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function ZU(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function e7(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),u=parseFloat(r.lineHeight),d=Number.isFinite(u)&&u>0?u:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function $p({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:u,onImagesChange:d}){const{t:f}=wn(),c=m.useId(),p=m.useRef(null),h=m.useRef(null),[g,v]=m.useState(0),[k,y]=m.useState(0),[b,w]=m.useState(null),N=m.useMemo(()=>os(u),[u]),C=m.useMemo(()=>YU(e,a,f),[e,a,f]),j=C.length>0,R=m.useMemo(()=>GU(e,a),[e,a]),D=m.useMemo(()=>JU(R),[R]),M=m.useMemo(()=>n?null:KU(e,g),[e,g,n]),B=m.useMemo(()=>{if(!M)return[];const I=QU(a,f);return ZU(I,M.query)},[M,a,f]);m.useEffect(()=>{y(I=>{const F=Math.max(0,B.length-1);return Math.min(Math.max(0,I),F)})},[B.length]);const $=m.useCallback(()=>{const I=p.current;if(!I||!M||B.length===0){w(null);return}const F=e7(I,g);if(!F){w(null);return}const P=4,O=44,_=13.5*16,G=Math.min(B.length*O+8,_);let Z=F.bottom+P;Z+G>window.innerHeight-8&&(Z=Math.max(8,F.top-G-P));const U=288;let ie=F.left;ie=Math.max(8,Math.min(ie,window.innerWidth-U-8)),w({top:Z,left:ie})},[M,B.length,g]);m.useLayoutEffect(()=>{if(!M||B.length===0){w(null);return}const I=requestAnimationFrame(()=>$());return()=>cancelAnimationFrame(I)},[M,B.length,g,e,$]),m.useEffect(()=>{if(!M||B.length===0)return;const I=()=>$();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[M,B.length,$]);const A=m.useCallback(I=>{if(!M)return;const{atIndex:F}=M,P=e.slice(0,F)+"${"+I+"}"+e.slice(g);t(P);const O=F+I.length+3;queueMicrotask(()=>{const _=p.current;_&&(_.focus(),_.setSelectionRange(O,O)),v(O)})},[M,e,g,t]),z=m.useCallback(()=>{const I=p.current,F=h.current;!I||!F||(F.scrollTop=I.scrollTop,F.scrollLeft=I.scrollLeft,M&&B.length>0&&queueMicrotask(()=>$()))},[M,B.length,$]),T=m.useCallback(I=>{if(!n&&M&&B.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),y(F=>(F+1)%B.length);else if(I.key==="ArrowUp")I.preventDefault(),y(F=>(F-1+B.length)%B.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const F=B[k];F&&A(F.insert)}}},[n,M,B,k,A]),L=m.useCallback(async I=>{if(n||typeof d!="function")return!1;const F=await AI({files:I,body:e,images:N});return F?(t(F.body),d(F.images),queueMicrotask(()=>{const P=p.current;if(!P)return;P.focus();const O=F.body.length;P.setSelectionRange(O,O),v(O)}),!0):!1},[n,N,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[N.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:N.map((I,F)=>o.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[o.jsx("img",{src:I.dataUrl,alt:""}),o.jsxs("span",{children:["[",I.label||`image ${F+1}`,"]"]})]},I.id||F))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:D+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?c:void 0,onChange:I=>{t(I.target.value),v(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:T,onPaste:I=>{const F=PI(I);F.length!==0&&(I.preventDefault(),L(F).catch(()=>{}))},onDragOver:I=>{um(I).length>0&&I.preventDefault()},onDrop:I=>{const F=um(I);F.length!==0&&(I.preventDefault(),L(F).catch(()=>{}))},onScroll:z})]}),M&&B.length>0&&b?ns.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:B.map((I,F)=>o.jsx("li",{role:"option","aria-selected":F===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(F),onClick:()=>A(I.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,j?o.jsx("p",{id:c,className:"af-body-ph-issues",role:"status",children:C.map(I=>I.message).join(" · ")}):null]})}const BI=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Dp(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function QN({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=wn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),u=c=>r(n.filter((p,h)=>h!==c)),d=(c,p,h)=>{const g=n.map((v,k)=>{if(k!==c)return v;const y={...v,[p]:h};return p==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((c,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:c.type,onChange:h=>d(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.name,onChange:h=>d(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.default,onChange:h=>d(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!c.required,onChange:h=>{i||d(p,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:c.showOnNode!==!1,onChange:h=>d(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>u(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function HI({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:u,allowEditRequiredPins:d=!1,error:f,ioSlots:c}){const{t:p}=wn(),[h,g]=m.useState(!1),[v,k]=m.useState(!1),[y,b]=m.useState({status:"idle",message:""}),w=m.useCallback(A=>{t(z=>z&&{...z,...A})},[t]),{cursorList:N,opencodeList:C,claudeCodeList:j,currentNotInLists:R}=m.useMemo(()=>{const A=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],z=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],T=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],L=new Set([...A,...z,...T].map(Dp)),I=((e==null?void 0:e.model)??"").trim(),F=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!L.has(F)?I:"";return{cursorList:A,opencodeList:z,claudeCodeList:T,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const D=String(e.script??""),M=n==="tool_nodejs"||D.trim()!=="",B=typeof u=="function"&&!i&&(e==null?void 0:e.newId),$=async()=>{if(B){b({status:"running",message:p("flow:nodeProps.publishRunning")});try{const A=await u(e,n);b({status:"success",message:A!=null&&A.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:A.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(A){b({status:"error",message:String((A==null?void 0:A.message)||A)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:$,disabled:!B||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:A=>w({newId:A.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:A=>w({label:A.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:La.includes(e.role)?e.role:p("flow:roles.normal"),onChange:A=>w({role:A.target.value}),disabled:i,children:La.map(A=>o.jsx("option",{value:A,children:A},A))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const A=(e.model||"").trim();return A?R||A:""})(),onChange:A=>w({model:A.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?o.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?o.jsx("optgroup",{label:"Cursor",children:N.map(A=>o.jsx("option",{value:Dp(A),children:A},`c-${A}`))}):null,C.length>0?o.jsx("optgroup",{label:"OpenCode",children:C.map(A=>o.jsx("option",{value:Dp(A),children:A},`o-${A}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map(A=>o.jsx("option",{value:`claude-code:${Dp(A)}`,children:A},`cc-${A}`))}):null]})]}),o.jsx(QN,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:A=>w({inputs:A}),disabled:i,requiredReadonly:!d}),o.jsx(QN,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:A=>w({outputs:A}),disabled:i,requiredReadonly:!d}),M?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($p,{value:D,onChange:A=>w({script:A}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:c,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($p,{value:e.body,onChange:A=>w({body:A}),images:e.images,onImagesChange:A=>w({images:A}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:c,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:A=>{A.target===A.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($p,{value:D,onChange:A=>w({script:A}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null,h?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:A=>{A.target===A.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($p,{value:e.body,onChange:A=>w({body:A}),images:e.images,onImagesChange:A=>w({images:A}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null]})}function Av(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function t7(e){const t=Av(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function WI(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function ZN({text:e}){const{t}=wn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Tf,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function ej({o:e}){var r;const{t}=wn(),n=Av(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:WI(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Tf,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function tj(e){return t7(e)}function nj(e){var r;if(!e)return null;const t=Av(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?WI(String(n)):String(n)}function rj({text:e,title:t,copiedLabel:n}){const[r,s]=m.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const sj=2e4,VI="af:run-node-ctx-width";function hh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function ga(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):ga(hh())}function n7(){try{const e=localStorage.getItem(VI);if(e==null)return ga(hh());const t=parseInt(e,10);return Number.isFinite(t)?ga(t):ga(hh())}catch{return ga(hh())}}async function ij(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function r7(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function s7({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=wn(),[a,l]=m.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[u,d]=m.useState(n7),f=m.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[c,p]=m.useState(!0),[h,g]=m.useState(""),[v,k]=m.useState([]),[y,b]=m.useState(null),[w,N]=m.useState(null),C=m.useRef(null),j=m.useRef(null),R=m.useRef(0),D=m.useRef(0);m.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),O=()=>l(P.matches);return P.addEventListener("change",O),()=>P.removeEventListener("change",O)},[]),m.useEffect(()=>{function P(){d(O=>ga(O))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const M=m.useCallback(()=>{d(P=>{const O=ga(P);try{localStorage.setItem(VI,String(O))}catch{}return O})},[]),B=m.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const O=P.currentTarget;f.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:u},O.setPointerCapture(P.pointerId)},[a,u]),$=m.useCallback(P=>{const O=f.current;if(!O.active||P.pointerId!==O.pointerId)return;const _=O.startX-P.clientX;d(ga(O.startW+_))},[]),A=m.useCallback(P=>{const O=f.current;if(!(!O.active||P.pointerId!==O.pointerId)){O.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}M()}},[M]),z=m.useCallback(()=>{const P=f.current;P.active&&(P.active=!1,M())},[M]),T=m.useCallback(P=>{const O=Array.isArray(P)?P:[];k(O),b(_=>_&&O.some(G=>G.execId===_)?_:O.length>0?O[O.length-1].execId:null)},[]),L=m.useCallback(()=>{if(!e||!t)return;const P=++R.current,O=new AbortController,_=window.setTimeout(()=>O.abort(),sj);(async()=>{try{const G=await ij(t,e,n,O.signal);if(P!==R.current)return;T(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(_)}})()},[e,t,n,T]);m.useEffect(()=>{if(!e||!t){p(!1),g(""),k([]);return}const P=++D.current;p(!0),g(""),k([]),b(null);const O=new AbortController,_=window.setTimeout(()=>O.abort(),sj);return(async()=>{try{const G=await ij(t,e,n,O.signal);if(P!==D.current)return;T(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(P!==D.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(_),P===D.current&&p(!1)}})(),()=>{O.abort(),D.current++,R.current++}},[e,t,n,T]),m.useEffect(()=>{r&&L()},[r,L]),m.useEffect(()=>{clearInterval(j.current);const P=v.length>0?v[v.length-1]:null;return(r==="running"&&v.length===0||!!(P&&P.status==="running"))&&e&&t&&(j.current=setInterval(()=>L(),2e3)),()=>clearInterval(j.current)},[v,e,t,n,r,L]),m.useEffect(()=>{C.current&&(C.current.scrollTop=0)},[y]);const I=v.find(P=>P.execId===y),F=a?void 0:{width:`${u}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:F,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:B,onPointerMove:$,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:z}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),h&&o.jsx("div",{className:"af-run-ctx-error",children:r7(i,h)}),!c&&!h&&v.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),v.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+o7((I==null?void 0:I.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const O=P.target.value;b(O==="latest"?"latest":Number(O))},children:[...v].reverse().map(P=>{const O=P.execId==="latest"?i("flow:runContext.latest"):`#${P.execId}`,_=a7(i,P.status),G=P.finishedAt?` · ${i7(P.finishedAt)}`:"";return o.jsx("option",{value:String(P.execId),children:`${O} · ${_}${G}`},P.execId)})})]}),I&&o.jsxs("div",{className:"af-run-ctx-body",ref:C,children:[I.inputs&&I.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,O)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${O}`))]}),I.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(ZN,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,O)=>{const _=tj(P),G=nj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:_}):null,o.jsx(rj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(ej,{o:P})]},`${P.slot}-${O}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&I&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&N(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&I.prompt!=null&&o.jsx(ZN,{text:I.prompt}),w==="output"&&I.outputs&&I.outputs.map((P,O)=>{const _=tj(P),G=nj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?o.jsx("span",{className:"af-run-ctx-format-badge",children:_}):null,o.jsx(rj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(ej,{o:P})]},`${P.slot}-${O}`)})]})]})})]})}function i7(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function o7(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function a7(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function l7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:u}=wn(),[d,f]=m.useState({}),[c,p]=m.useState(null),[h,g]=m.useState({}),[v,k]=m.useState(!0),[y,b]=m.useState(!1),[w,N]=m.useState(""),[C,j]=m.useState(!1),[R,D]=m.useState(null),M=m.useRef(null),B=m.useRef(!0),$=m.useRef({});m.useMemo(()=>{var _,G,Z;const O={};for(const U of r){const ie=(Z=(G=(_=U.data)==null?void 0:_.outputs)==null?void 0:G[0])==null?void 0:Z.default;ie!=null&&ie!==""&&(O[U.id]=String(ie))}return $.current=O,O},[r]);const A=m.useMemo(()=>{var _;const O={};for(const G of i){if(!((_=G.data)!=null&&_.inputs))continue;const Z=G.data.inputs;for(let U=0;U<Z.length;U++){const ie=Z[U];if(!(ie!=null&&ie.name))continue;const de=s.find(ye=>ye.target===G.id&&ye.targetHandle===`input-${U}`);if(!(de!=null&&de.source))continue;r.find(ye=>ye.id===de.source)&&(O[de.source]=ie.name)}}return O},[i,s,r]);m.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),m.useEffect(()=>{if(!e){k(!1);return}k(!0);const O=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&O.set("archived","1"),fetch(`/api/flow/run-config?${O.toString()}`).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{var Z;if(!B.current)return;f(_.presets||{}),p(_.activePreset||null);const G=_.activePreset&&((Z=_.presets)!=null&&Z[_.activePreset])?_.presets[_.activePreset]:{};g({...$.current,...G}),k(!1)}).catch(()=>{B.current&&(g($.current),k(!1))})},[e,t,n]),m.useEffect(()=>{var _;if(!a)return;const O={};for(const[G,Z]of Object.entries(h)){const U=A[G];if(!U)continue;const ie=r.find(he=>he.id===G);if(!ie)continue;(((_=ie.data)==null?void 0:_.definitionId)||"").startsWith("provide_file")?O[U]={type:"file",path:Z}:O[U]={type:"str",value:Z}}a(O)},[h,A,r,a]);const z=m.useCallback((O,_)=>{g(G=>({...G,[O]:_}))},[]),T=m.useCallback(O=>{O!==c&&(p(O),O&&d[O]?g({...$.current,...d[O]}):g($.current))},[c,d]),L=m.useCallback(async()=>{if(w.trim()){b(!0);try{const O={...d,[w.trim()]:h},_={flowId:e,flowSource:t,archived:n,presets:O,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).ok&&(f(O),p(w.trim()),N(""),j(!1))}finally{b(!1)}}},[e,t,n,d,h,w]),I=m.useCallback(async()=>{if(c){b(!0);try{const O={...d};delete O[c];const _=Object.keys(O)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:_})})).ok&&(f(O),p(_),_&&O[_]?g({...$.current,...O[_]}):g($.current))}finally{b(!1)}}},[e,t,n,d,c]),F=m.useCallback(async()=>{if(c){b(!0);try{const O={...d,[c]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:c})})).ok&&f(O)}finally{b(!1)}}},[e,t,n,d,c,h]),P=Object.keys(d);return P.length>0,v?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:u("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:u("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:c||"",onChange:O=>T(O.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:u("flow:runConfig.default")}),P.map(O=>o.jsx("option",{value:O,children:O},O))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>j(!0),disabled:y,title:u("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:F,disabled:y,title:u("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:u("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),C&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:u("flow:runConfig.presetNamePlaceholder"),value:w,onChange:O=>N(O.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:L,disabled:y||!w.trim(),children:u(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{j(!1),N("")},disabled:y,children:u("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:u("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:u("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(O=>{var ye,oe;const _=((ye=O.data)==null?void 0:ye.definitionId)||"",G=_.startsWith("provide_file"),Z=_==="provide_bool",U=((oe=O.data)==null?void 0:oe.label)||O.id,ie=O.id,de=h[ie]||"",he=["true","1","yes","on"].includes(String(de).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:U}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>D({instanceId:ie,label:U,content:de}),"aria-label":u("flow:runConfig.expandInput"),title:u("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ie}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(he?" af-run-config-bool-toggle--true":""),onClick:()=>z(ie,he?"false":"true"),"aria-pressed":he,children:he?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:de,onChange:Se=>z(ie,Se.target.value),placeholder:u(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ie)})})]}),R&&ns.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:R.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>D(null),"aria-label":u("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:R.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!R||!M.current||(z(R.instanceId,M.current.value),D(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),u("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>D(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),u("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const UI={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},c7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function u7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function d7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function f7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function oj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(UI))if(r.includes(e))return n;return"other"}function p7({event:e,defaultExpanded:t}){const[n,r]=m.useState(!!t),s=c7[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),u=a?i.meta:null,d=m.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const g=i[h];return g==null?`${h}:null`:typeof g=="object"?`${h}:{…}`:`${h}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=m.useCallback(c=>{c.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(c=>!c),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:d7(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[u&&Object.keys(u).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(u,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function h7({open:e,onClose:t,flowId:n}){var D;const[r,s]=m.useState([]),[i,a]=m.useState(!1),[l,u]=m.useState(null),[d,f]=m.useState(null),[c,p]=m.useState(!1),[h,g]=m.useState(!0),[v,k]=m.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=m.useState(""),w=m.useRef(null),N=m.useCallback(async()=>{a(!0);try{const M=h&&n?`?flowId=${encodeURIComponent(n)}`:"",$=await(await fetch(`/api/composer-logs${M}`)).json();s(Array.isArray($.sessions)?$.sessions:[])}catch{s([])}finally{a(!1)}},[n,h]),C=m.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const $=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f($)}catch{f(null)}finally{p(!1)}},[]);m.useEffect(()=>{e&&N()},[e,N]),m.useEffect(()=>{if(!(!e||!l))return C(l),w.current=setInterval(()=>C(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,C]);const j=m.useMemo(()=>{const M=(d==null?void 0:d.events)||[],B=y.trim().toLowerCase();return M.filter($=>{const A=oj($.tag,$.payload);return!v[A]&&A!=="other"?!1:B?[$.tag,JSON.stringify($.payload||"")].join(" ").toLowerCase().includes(B):!0})},[d,v,y]),R=m.useMemo(()=>{const M=(d==null?void 0:d.events)||[],B={};for(const $ of M){const A=oj($.tag,$.payload);B[A]=(B[A]||0)+1}return B},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:h,onChange:M=>g(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:N,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const B=l===M.sessionId;return o.jsxs("div",{onClick:()=>u(M.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:B?"rgba(124,77,255,0.18)":"transparent",borderLeft:B?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:f7(M.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[u7(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(UI).map(M=>o.jsxs("button",{type:"button",onClick:()=>k(B=>({...B,[M]:!B[M]})),style:{background:v[M]?"rgba(124,77,255,0.25)":"transparent",color:v[M]?"#e8deff":"#6a6a6a",border:`1px solid ${v[M]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[M," ",R[M]!=null?`(${R[M]})`:""]},M)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:M=>b(M.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),c&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&j.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((D=d.events)==null?void 0:D.length)||0," total)"]}),j.map((M,B)=>o.jsx(p7,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${B}`))]})]})]})]}):null}const m7="0.1.44";function aj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Fy(e,t){return t==="running"?aj(e):e==null||!Number.isFinite(e)||e<=0?"--":aj(e)}const KI=m.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function g7(e){const{setNodes:t}=Dl(),{modelLists:n,onModelChange:r}=m.useContext(KI),s=m.useCallback(d=>{t(f=>f.filter(c=>c.id!==d))},[t]),i=m.useCallback(()=>{var p,h,g,v,k,y,b,w;const d=((p=e.data)==null?void 0:p.definitionId)||"",f=((h=e.data)==null?void 0:h.label)||e.id,c=((k=(v=(g=e.data)==null?void 0:g.outputs)==null?void 0:v[0])==null?void 0:k.value)||((w=(b=(y=e.data)==null?void 0:y.outputs)==null?void 0:b[0])==null?void 0:w.default)||"";window.__provideEditContent={instanceId:e.id,label:f,definitionId:d,content:c},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),a=m.useCallback((d,f)=>{t(c=>c.map(p=>{var g;if(p.id!==d)return p;const h=Array.isArray((g=p.data)==null?void 0:g.outputs)&&p.data.outputs.length?p.data.outputs.map((v,k)=>k===0?{...v,default:f,value:f}:v):[{type:"bool",name:"value",default:f,value:f}];return{...p,data:{...p.data,body:"",outputs:h}}}))},[t]),l=m.useCallback((d,f)=>{t(c=>c.map(p=>p.id===d?{...p,data:{...p.data,body:f}}:p))},[t]),u=m.useCallback((d,f)=>{t(c=>c.map(p=>p.id===d?{...p,data:{...p.data,images:os(f)}}:p))},[t]);return o.jsx(OI,{...e,deleteNode:s,onProvideExpand:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:u,modelLists:n,onModelChange:r})}const y7={[Lf]:g7},ld=["CONTROL","TOOL","PROVIDE","AGENT"],x7=1200,lj="af-flow-node--sync-flash",cj="af-flow-edge--sync-flash";function uj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function dj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function Iv(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function w7(e){const t=Iv(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Fp(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function qI(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function YI(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function zy(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function fj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function pj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function b7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function v7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function GI(e,t,n,r,s){const i=w7(e),a={id:t,type:Lf,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return ff(a,r,s)}function k7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function hj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=au(i,e.sourceHandle||"output-0","source"),u=au(a,e.targetHandle||"input-0","target");return!l||!u?!1:ou(l,u)}function S7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=au(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:LI(a)}:null}function N7(e,t,n){var a;const r=GI(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const u=i[l];if(n.handleType==="source"?ou(n.slot,u):ou(u,n.slot))return{slot:u,slotIndex:l,hydrated:r}}return null}function j7(e,t){return t?e.map((n,r)=>{const s=N7(n,e,t);if(!s)return null;const i=Iv(n);return{def:n,order:r,category:i,categoryRank:ld.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:qI(s.hydrated.data||n),description:YI(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const C7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function E7(e){const t=new Set,n=[];let r;const s=new RegExp(C7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function mj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function jo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function zp(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],u=i.map(jo),d=a.map(jo);return l.map(jo).includes(s)&&!u.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!u.includes(s)?`opencode:${s}`:s}function _7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function By(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function P7({steps:e}){const{t}=wn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
128
+ `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?c:void 0,onChange:I=>{t(I.target.value),v(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:T,onPaste:I=>{const F=PI(I);F.length!==0&&(I.preventDefault(),L(F).catch(()=>{}))},onDragOver:I=>{um(I).length>0&&I.preventDefault()},onDrop:I=>{const F=um(I);F.length!==0&&(I.preventDefault(),L(F).catch(()=>{}))},onScroll:z})]}),M&&B.length>0&&b?ns.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:B.map((I,F)=>o.jsx("li",{role:"option","aria-selected":F===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(F),onClick:()=>A(I.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,j?o.jsx("p",{id:c,className:"af-body-ph-issues",role:"status",children:C.map(I=>I.message).join(" · ")}):null]})}const BI=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Dp(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function QN({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=wn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),u=c=>r(n.filter((p,h)=>h!==c)),d=(c,p,h)=>{const g=n.map((v,k)=>{if(k!==c)return v;const y={...v,[p]:h};return p==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((c,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:c.type,onChange:h=>d(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.name,onChange:h=>d(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.default,onChange:h=>d(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!c.required,onChange:h=>{i||d(p,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:c.showOnNode!==!1,onChange:h=>d(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>u(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function HI({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:u,allowEditRequiredPins:d=!1,error:f,ioSlots:c}){const{t:p}=wn(),[h,g]=m.useState(!1),[v,k]=m.useState(!1),[y,b]=m.useState({status:"idle",message:""}),w=m.useCallback(A=>{t(z=>z&&{...z,...A})},[t]),{cursorList:N,opencodeList:C,claudeCodeList:j,currentNotInLists:R}=m.useMemo(()=>{const A=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],z=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],T=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],L=new Set([...A,...z,...T].map(Dp)),I=((e==null?void 0:e.model)??"").trim(),F=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!L.has(F)?I:"";return{cursorList:A,opencodeList:z,claudeCodeList:T,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const D=String(e.script??""),M=n==="tool_nodejs"||D.trim()!=="",B=typeof u=="function"&&!i&&(e==null?void 0:e.newId),$=async()=>{if(B){b({status:"running",message:p("flow:nodeProps.publishRunning")});try{const A=await u(e,n);b({status:"success",message:A!=null&&A.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:A.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(A){b({status:"error",message:String((A==null?void 0:A.message)||A)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:$,disabled:!B||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:A=>w({newId:A.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:A=>w({label:A.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:La.includes(e.role)?e.role:p("flow:roles.normal"),onChange:A=>w({role:A.target.value}),disabled:i,children:La.map(A=>o.jsx("option",{value:A,children:A},A))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const A=(e.model||"").trim();return A?R||A:""})(),onChange:A=>w({model:A.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?o.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?o.jsx("optgroup",{label:"Cursor",children:N.map(A=>o.jsx("option",{value:Dp(A),children:A},`c-${A}`))}):null,C.length>0?o.jsx("optgroup",{label:"OpenCode",children:C.map(A=>o.jsx("option",{value:Dp(A),children:A},`o-${A}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map(A=>o.jsx("option",{value:`claude-code:${Dp(A)}`,children:A},`cc-${A}`))}):null]})]}),o.jsx(QN,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:A=>w({inputs:A}),disabled:i,requiredReadonly:!d}),o.jsx(QN,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:A=>w({outputs:A}),disabled:i,requiredReadonly:!d}),M?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($p,{value:D,onChange:A=>w({script:A}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:c,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx($p,{value:e.body,onChange:A=>w({body:A}),images:e.images,onImagesChange:A=>w({images:A}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:c,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:A=>{A.target===A.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($p,{value:D,onChange:A=>w({script:A}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null,h?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:A=>{A.target===A.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx($p,{value:e.body,onChange:A=>w({body:A}),images:e.images,onImagesChange:A=>w({images:A}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null]})}function Av(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function t7(e){const t=Av(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function WI(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function ZN({text:e}){const{t}=wn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Tf,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function ej({o:e}){var r;const{t}=wn(),n=Av(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:WI(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Tf,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function tj(e){return t7(e)}function nj(e){var r;if(!e)return null;const t=Av(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?WI(String(n)):String(n)}function rj({text:e,title:t,copiedLabel:n}){const[r,s]=m.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const sj=2e4,VI="af:run-node-ctx-width";function hh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function ga(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):ga(hh())}function n7(){try{const e=localStorage.getItem(VI);if(e==null)return ga(hh());const t=parseInt(e,10);return Number.isFinite(t)?ga(t):ga(hh())}catch{return ga(hh())}}async function ij(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function r7(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function s7({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=wn(),[a,l]=m.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[u,d]=m.useState(n7),f=m.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[c,p]=m.useState(!0),[h,g]=m.useState(""),[v,k]=m.useState([]),[y,b]=m.useState(null),[w,N]=m.useState(null),C=m.useRef(null),j=m.useRef(null),R=m.useRef(0),D=m.useRef(0);m.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),O=()=>l(P.matches);return P.addEventListener("change",O),()=>P.removeEventListener("change",O)},[]),m.useEffect(()=>{function P(){d(O=>ga(O))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const M=m.useCallback(()=>{d(P=>{const O=ga(P);try{localStorage.setItem(VI,String(O))}catch{}return O})},[]),B=m.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const O=P.currentTarget;f.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:u},O.setPointerCapture(P.pointerId)},[a,u]),$=m.useCallback(P=>{const O=f.current;if(!O.active||P.pointerId!==O.pointerId)return;const _=O.startX-P.clientX;d(ga(O.startW+_))},[]),A=m.useCallback(P=>{const O=f.current;if(!(!O.active||P.pointerId!==O.pointerId)){O.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}M()}},[M]),z=m.useCallback(()=>{const P=f.current;P.active&&(P.active=!1,M())},[M]),T=m.useCallback(P=>{const O=Array.isArray(P)?P:[];k(O),b(_=>_&&O.some(G=>G.execId===_)?_:O.length>0?O[O.length-1].execId:null)},[]),L=m.useCallback(()=>{if(!e||!t)return;const P=++R.current,O=new AbortController,_=window.setTimeout(()=>O.abort(),sj);(async()=>{try{const G=await ij(t,e,n,O.signal);if(P!==R.current)return;T(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(_)}})()},[e,t,n,T]);m.useEffect(()=>{if(!e||!t){p(!1),g(""),k([]);return}const P=++D.current;p(!0),g(""),k([]),b(null);const O=new AbortController,_=window.setTimeout(()=>O.abort(),sj);return(async()=>{try{const G=await ij(t,e,n,O.signal);if(P!==D.current)return;T(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(P!==D.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(_),P===D.current&&p(!1)}})(),()=>{O.abort(),D.current++,R.current++}},[e,t,n,T]),m.useEffect(()=>{r&&L()},[r,L]),m.useEffect(()=>{clearInterval(j.current);const P=v.length>0?v[v.length-1]:null;return(r==="running"&&v.length===0||!!(P&&P.status==="running"))&&e&&t&&(j.current=setInterval(()=>L(),2e3)),()=>clearInterval(j.current)},[v,e,t,n,r,L]),m.useEffect(()=>{C.current&&(C.current.scrollTop=0)},[y]);const I=v.find(P=>P.execId===y),F=a?void 0:{width:`${u}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:F,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:B,onPointerMove:$,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:z}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),h&&o.jsx("div",{className:"af-run-ctx-error",children:r7(i,h)}),!c&&!h&&v.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),v.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+o7((I==null?void 0:I.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const O=P.target.value;b(O==="latest"?"latest":Number(O))},children:[...v].reverse().map(P=>{const O=P.execId==="latest"?i("flow:runContext.latest"):`#${P.execId}`,_=a7(i,P.status),G=P.finishedAt?` · ${i7(P.finishedAt)}`:"";return o.jsx("option",{value:String(P.execId),children:`${O} · ${_}${G}`},P.execId)})})]}),I&&o.jsxs("div",{className:"af-run-ctx-body",ref:C,children:[I.inputs&&I.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,O)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${O}`))]}),I.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(ZN,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,O)=>{const _=tj(P),G=nj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:_}):null,o.jsx(rj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(ej,{o:P})]},`${P.slot}-${O}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&I&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&N(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&I.prompt!=null&&o.jsx(ZN,{text:I.prompt}),w==="output"&&I.outputs&&I.outputs.map((P,O)=>{const _=tj(P),G=nj(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?o.jsx("span",{className:"af-run-ctx-format-badge",children:_}):null,o.jsx(rj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(ej,{o:P})]},`${P.slot}-${O}`)})]})]})})]})}function i7(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function o7(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function a7(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function l7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:u}=wn(),[d,f]=m.useState({}),[c,p]=m.useState(null),[h,g]=m.useState({}),[v,k]=m.useState(!0),[y,b]=m.useState(!1),[w,N]=m.useState(""),[C,j]=m.useState(!1),[R,D]=m.useState(null),M=m.useRef(null),B=m.useRef(!0),$=m.useRef({});m.useMemo(()=>{var _,G,Z;const O={};for(const U of r){const ie=(Z=(G=(_=U.data)==null?void 0:_.outputs)==null?void 0:G[0])==null?void 0:Z.default;ie!=null&&ie!==""&&(O[U.id]=String(ie))}return $.current=O,O},[r]);const A=m.useMemo(()=>{var _;const O={};for(const G of i){if(!((_=G.data)!=null&&_.inputs))continue;const Z=G.data.inputs;for(let U=0;U<Z.length;U++){const ie=Z[U];if(!(ie!=null&&ie.name))continue;const de=s.find(ye=>ye.target===G.id&&ye.targetHandle===`input-${U}`);if(!(de!=null&&de.source))continue;r.find(ye=>ye.id===de.source)&&(O[de.source]=ie.name)}}return O},[i,s,r]);m.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),m.useEffect(()=>{if(!e){k(!1);return}k(!0);const O=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&O.set("archived","1"),fetch(`/api/flow/run-config?${O.toString()}`).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{var Z;if(!B.current)return;f(_.presets||{}),p(_.activePreset||null);const G=_.activePreset&&((Z=_.presets)!=null&&Z[_.activePreset])?_.presets[_.activePreset]:{};g({...$.current,...G}),k(!1)}).catch(()=>{B.current&&(g($.current),k(!1))})},[e,t,n]),m.useEffect(()=>{var _;if(!a)return;const O={};for(const[G,Z]of Object.entries(h)){const U=A[G];if(!U)continue;const ie=r.find(he=>he.id===G);if(!ie)continue;(((_=ie.data)==null?void 0:_.definitionId)||"").startsWith("provide_file")?O[U]={type:"file",path:Z}:O[U]={type:"str",value:Z}}a(O)},[h,A,r,a]);const z=m.useCallback((O,_)=>{g(G=>({...G,[O]:_}))},[]),T=m.useCallback(O=>{O!==c&&(p(O),O&&d[O]?g({...$.current,...d[O]}):g($.current))},[c,d]),L=m.useCallback(async()=>{if(w.trim()){b(!0);try{const O={...d,[w.trim()]:h},_={flowId:e,flowSource:t,archived:n,presets:O,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).ok&&(f(O),p(w.trim()),N(""),j(!1))}finally{b(!1)}}},[e,t,n,d,h,w]),I=m.useCallback(async()=>{if(c){b(!0);try{const O={...d};delete O[c];const _=Object.keys(O)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:_})})).ok&&(f(O),p(_),_&&O[_]?g({...$.current,...O[_]}):g($.current))}finally{b(!1)}}},[e,t,n,d,c]),F=m.useCallback(async()=>{if(c){b(!0);try{const O={...d,[c]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:c})})).ok&&f(O)}finally{b(!1)}}},[e,t,n,d,c,h]),P=Object.keys(d);return P.length>0,v?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:u("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:u("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:c||"",onChange:O=>T(O.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:u("flow:runConfig.default")}),P.map(O=>o.jsx("option",{value:O,children:O},O))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>j(!0),disabled:y,title:u("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:F,disabled:y,title:u("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:u("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),C&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:u("flow:runConfig.presetNamePlaceholder"),value:w,onChange:O=>N(O.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:L,disabled:y||!w.trim(),children:u(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{j(!1),N("")},disabled:y,children:u("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:u("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:u("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(O=>{var ye,oe;const _=((ye=O.data)==null?void 0:ye.definitionId)||"",G=_.startsWith("provide_file"),Z=_==="provide_bool",U=((oe=O.data)==null?void 0:oe.label)||O.id,ie=O.id,de=h[ie]||"",he=["true","1","yes","on"].includes(String(de).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:U}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>D({instanceId:ie,label:U,content:de}),"aria-label":u("flow:runConfig.expandInput"),title:u("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ie}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(he?" af-run-config-bool-toggle--true":""),onClick:()=>z(ie,he?"false":"true"),"aria-pressed":he,children:he?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:de,onChange:Se=>z(ie,Se.target.value),placeholder:u(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ie)})})]}),R&&ns.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:R.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>D(null),"aria-label":u("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:R.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!R||!M.current||(z(R.instanceId,M.current.value),D(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),u("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>D(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),u("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const UI={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},c7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function u7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function d7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function f7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function oj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(UI))if(r.includes(e))return n;return"other"}function p7({event:e,defaultExpanded:t}){const[n,r]=m.useState(!!t),s=c7[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),u=a?i.meta:null,d=m.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const g=i[h];return g==null?`${h}:null`:typeof g=="object"?`${h}:{…}`:`${h}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=m.useCallback(c=>{c.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(c=>!c),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:d7(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[u&&Object.keys(u).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(u,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function h7({open:e,onClose:t,flowId:n}){var D;const[r,s]=m.useState([]),[i,a]=m.useState(!1),[l,u]=m.useState(null),[d,f]=m.useState(null),[c,p]=m.useState(!1),[h,g]=m.useState(!0),[v,k]=m.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=m.useState(""),w=m.useRef(null),N=m.useCallback(async()=>{a(!0);try{const M=h&&n?`?flowId=${encodeURIComponent(n)}`:"",$=await(await fetch(`/api/composer-logs${M}`)).json();s(Array.isArray($.sessions)?$.sessions:[])}catch{s([])}finally{a(!1)}},[n,h]),C=m.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const $=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f($)}catch{f(null)}finally{p(!1)}},[]);m.useEffect(()=>{e&&N()},[e,N]),m.useEffect(()=>{if(!(!e||!l))return C(l),w.current=setInterval(()=>C(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,C]);const j=m.useMemo(()=>{const M=(d==null?void 0:d.events)||[],B=y.trim().toLowerCase();return M.filter($=>{const A=oj($.tag,$.payload);return!v[A]&&A!=="other"?!1:B?[$.tag,JSON.stringify($.payload||"")].join(" ").toLowerCase().includes(B):!0})},[d,v,y]),R=m.useMemo(()=>{const M=(d==null?void 0:d.events)||[],B={};for(const $ of M){const A=oj($.tag,$.payload);B[A]=(B[A]||0)+1}return B},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:h,onChange:M=>g(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:N,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const B=l===M.sessionId;return o.jsxs("div",{onClick:()=>u(M.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:B?"rgba(124,77,255,0.18)":"transparent",borderLeft:B?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:f7(M.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[u7(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(UI).map(M=>o.jsxs("button",{type:"button",onClick:()=>k(B=>({...B,[M]:!B[M]})),style:{background:v[M]?"rgba(124,77,255,0.25)":"transparent",color:v[M]?"#e8deff":"#6a6a6a",border:`1px solid ${v[M]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[M," ",R[M]!=null?`(${R[M]})`:""]},M)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:M=>b(M.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),c&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&j.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((D=d.events)==null?void 0:D.length)||0," total)"]}),j.map((M,B)=>o.jsx(p7,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${B}`))]})]})]})]}):null}const m7="0.1.45";function aj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Fy(e,t){return t==="running"?aj(e):e==null||!Number.isFinite(e)||e<=0?"--":aj(e)}const KI=m.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function g7(e){const{setNodes:t}=Dl(),{modelLists:n,onModelChange:r}=m.useContext(KI),s=m.useCallback(d=>{t(f=>f.filter(c=>c.id!==d))},[t]),i=m.useCallback(()=>{var p,h,g,v,k,y,b,w;const d=((p=e.data)==null?void 0:p.definitionId)||"",f=((h=e.data)==null?void 0:h.label)||e.id,c=((k=(v=(g=e.data)==null?void 0:g.outputs)==null?void 0:v[0])==null?void 0:k.value)||((w=(b=(y=e.data)==null?void 0:y.outputs)==null?void 0:b[0])==null?void 0:w.default)||"";window.__provideEditContent={instanceId:e.id,label:f,definitionId:d,content:c},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),a=m.useCallback((d,f)=>{t(c=>c.map(p=>{var g;if(p.id!==d)return p;const h=Array.isArray((g=p.data)==null?void 0:g.outputs)&&p.data.outputs.length?p.data.outputs.map((v,k)=>k===0?{...v,default:f,value:f}:v):[{type:"bool",name:"value",default:f,value:f}];return{...p,data:{...p.data,body:"",outputs:h}}}))},[t]),l=m.useCallback((d,f)=>{t(c=>c.map(p=>p.id===d?{...p,data:{...p.data,body:f}}:p))},[t]),u=m.useCallback((d,f)=>{t(c=>c.map(p=>p.id===d?{...p,data:{...p.data,images:os(f)}}:p))},[t]);return o.jsx(OI,{...e,deleteNode:s,onProvideExpand:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:u,modelLists:n,onModelChange:r})}const y7={[Lf]:g7},ld=["CONTROL","TOOL","PROVIDE","AGENT"],x7=1200,lj="af-flow-node--sync-flash",cj="af-flow-edge--sync-flash";function uj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function dj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function Iv(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function w7(e){const t=Iv(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Fp(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function qI(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function YI(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function zy(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function fj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function pj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function b7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function v7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function GI(e,t,n,r,s){const i=w7(e),a={id:t,type:Lf,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return ff(a,r,s)}function k7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function hj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=au(i,e.sourceHandle||"output-0","source"),u=au(a,e.targetHandle||"input-0","target");return!l||!u?!1:ou(l,u)}function S7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=au(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:LI(a)}:null}function N7(e,t,n){var a;const r=GI(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const u=i[l];if(n.handleType==="source"?ou(n.slot,u):ou(u,n.slot))return{slot:u,slotIndex:l,hydrated:r}}return null}function j7(e,t){return t?e.map((n,r)=>{const s=N7(n,e,t);if(!s)return null;const i=Iv(n);return{def:n,order:r,category:i,categoryRank:ld.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:qI(s.hydrated.data||n),description:YI(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const C7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function E7(e){const t=new Set,n=[];let r;const s=new RegExp(C7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function mj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function jo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function zp(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],u=i.map(jo),d=a.map(jo);return l.map(jo).includes(s)&&!u.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!u.includes(s)?`opencode:${s}`:s}function _7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function By(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function P7({steps:e}){const{t}=wn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
129
  `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:_7(s)}):null]}):null})]},n.index)})})}function A7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function I7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
130
  ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function T7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function R7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function gj({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=wn(),a=m.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return m.useEffect(()=>{if(!s||!a.current)return;const u=a.current;requestAnimationFrame(()=>{u.scrollTop=u.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((u,d)=>u.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`composer-u-${d}-${u.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(yj,{segments:u.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(yj,{segments:t,running:n})})]})}function yj({segments:e,running:t=!1}){const{t:n}=wn(),r=e.filter(c=>c.kind==="assistant").map(c=>c.text).join(""),s=e.filter(c=>c.kind==="result").map(c=>c.text).join(""),i=A7(r,s),a=e.filter(c=>c.kind==="error").map(c=>c.text).join(`
131
131
  `),l=e.filter(c=>c.kind!=="error"),u=i?l.filter(c=>c.kind!=="result"):l,d=I7(u),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((c,p)=>o.jsxs("section",{className:R7(c.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:T7(c.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`${c.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function L7({fitViewEpoch:e}){const{fitView:t}=Dl(),n=m.useRef(t);return n.current=t,m.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function O7({onReady:e}){const t=lv();return m.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function xj(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}const mh=1500,wj=500,M7=262144,$7=2e3;function Hy(e){return typeof e!="string"?"":e.length<=$7?e:`[log line truncated, ${e.length} chars]`}const D7=mh;function F7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Hy(s)}}catch{return{ts:n,type:"info",text:Hy(s)}}return{ts:n,type:"log",text:Hy(`[${r}] ${s}`)}}function bj(e){if(!e)return[];const t=[],n=e.split(`
@@ -133,7 +133,7 @@ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function T7(e,t){return
133
133
  `);pe=ke.pop()??"";for(const ft of ke)De(ft);if(le)break}pe.trim()&&De(pe),Gt("done")}catch(X){X.name==="AbortError"?(pt(te=>[...te,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),Gt("stopped")):(pt(te=>[...te,{ts:new Date().toISOString(),type:"error",text:X.message||e("flow:run.unknownError")}]),Gt("error"))}finally{ii.current=null,In(new Set)}},[c]),[j2,Pg]=m.useState(!1),C2=m.useCallback(()=>{Pg(!0)},[]),E2=m.useCallback(async()=>{if(Pg(!1),ii.current&&(ii.current.abort(),ii.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}Gt("stopped"),In(new Set)},[c]),il=m.useCallback(()=>{Gt("edit"),In(new Set),ot({}),Er(null),bs(null)},[]),[_2,ep]=m.useState(!1),P2=m.useCallback(async()=>{if(ep(!1),ii.current&&(ii.current.abort(),ii.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}il()},[c,il]),A2=m.useCallback(()=>{ep(!1),n("/projects")},[n]),I2=m.useCallback(x=>{const S=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,H=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(c==null?void 0:c.id)!=null?String(c.id):null;bs(S);const K=x.status||"unknown";let q="stopped";K==="success"?q="done":K==="failed"?q="error":K==="running"?q="running":q="stopped",Gt(q);const X=typeof x.at=="number"?x.at:null;if(q==="running"&&X!=null?(zt(X),Ye(Math.max(0,Date.now()-X))):X!=null&&typeof x.endedAt=="number"&&x.endedAt>X?(zt(null),Ye(x.endedAt-X)):(zt(null),Ye(Math.max(0,x.durationMs??0))),pt([]),In(new Set),ot({}),Er(null),Lt(null),Dr(!1),S&&H){const te=new URLSearchParams({flowId:H,runId:S});fetch(`/api/run-node-statuses?${te}`).then(ne=>ne.json()).then(ne=>{const pe=ne.statuses&&typeof ne.statuses=="object"?ne.statuses:{},xe={};for(const[De,le]of Object.entries(pe))le&&typeof le=="object"&&typeof le.status=="string"&&(xe[De]={status:le.status,...le.elapsed!=null&&String(le.elapsed).trim()!==""?{elapsed:String(le.elapsed)}:{}});ot(xe)}).catch(()=>{})}},[c==null?void 0:c.id]);m.useEffect(()=>{if(!(c!=null&&c.id)||Te!=="edit")return;let x=!1;return(async()=>{try{const S=await fetch("/api/pipeline-recent-runs"),H=await S.json();if(x||!S.ok)return;const q=(Array.isArray(H.runs)?H.runs:[]).find(ne=>ne.flowId===c.id&&ne.status==="running");if(!q||x)return;const X=q.runId||null;bs(X),Gt("running"),Dr(!0),zt(q.at||Date.now()),$s.current=0;const te=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${X},已恢复运行视图`}];if(X){const ne=new URLSearchParams({flowId:c.id,runId:X}),xe=await(await fetch(`/api/run-node-statuses?${ne}`)).json();if(x)return;const De=xe.statuses&&typeof xe.statuses=="object"?xe.statuses:{},le={},Le=new Set;for(const[ke,ft]of Object.entries(De))ft&&typeof ft=="object"&&typeof ft.status=="string"&&(le[ke]={status:ft.status,...ft.elapsed!=null&&String(ft.elapsed).trim()!==""?{elapsed:String(ft.elapsed)}:{}},ft.status==="running"&&Le.add(ke));ot(le),In(Le);try{const ke=new URLSearchParams({flowId:c.id,runId:X,sinceBytes:"0",tailBytes:"262144"}),ft=await fetch(`/api/run-log?${ke}`);if(ft.ok){const an=await ft.json();if(!x){$s.current=Number(an.bytes||0);const ln=bj(typeof an.text=="string"?an.text:"");pt([...ln,...te]);return}}}catch{}}pt(te)}catch{}})(),()=>{x=!0}},[c==null?void 0:c.id]),m.useEffect(()=>{if(Te==="edit"||!(c!=null&&c.id)||!Zt)return;let x=!1,S=null;const H=async()=>{try{const K=new URLSearchParams({flowId:c.id,runId:Zt}),q=await fetch(`/api/run-node-statuses?${K}`);if(!q.ok)return;const X=await q.json();if(x)return;const te=X.statuses&&typeof X.statuses=="object"?X.statuses:{},ne={},pe=new Set;for(const[xe,De]of Object.entries(te))De&&typeof De=="object"&&typeof De.status=="string"&&(ne[xe]={status:De.status,...De.elapsed!=null&&String(De.elapsed).trim()!==""?{elapsed:String(De.elapsed)}:{}},De.status==="running"&&pe.add(xe));ot(xe=>z7(xe,ne)?xe:ne),In(xe=>B7(xe,pe)?xe:pe);try{const xe=new URLSearchParams({flowId:c.id,runId:Zt,sinceBytes:String($s.current||0),tailBytes:String(M7)}),De=await fetch(`/api/run-log?${xe}`);if(De.ok){const le=await De.json();if(x)return;const Le=Number(le.bytes||0),ke=typeof le.text=="string"?le.text:"";if(ke){const ft=bj(ke);ft.length>0&&pt(an=>[...an,...ft])}$s.current=Le}}catch{}try{const xe=await fetch("/api/pipeline-recent-runs");if(!xe.ok)return;const De=await xe.json();if(x)return;const Le=(Array.isArray(De.runs)?De.runs:[]).find(ke=>ke.flowId===c.id&&ke.runId===Zt);if(Le&&Le.status){const ke=Le.status;ke==="running"?Gt(ft=>ft==="running"?ft:"running"):ke==="success"?Gt("done"):ke==="failed"?Gt("error"):(ke==="stopped"||ke==="interrupted")&&Gt("stopped")}}catch{}}catch{}};return H(),S=window.setInterval(H,2500),()=>{x=!0,S&&window.clearInterval(S)}},[Te,c==null?void 0:c.id,Zt]),m.useEffect(()=>{if(et!=="history"||!c)return;let x=!1;return(async()=>{Ms(!0),_i("");try{const S=await fetch("/api/pipeline-recent-runs"),H=await S.json();if(!S.ok)throw new Error(H.error||"HTTP "+S.status);x||$r(Array.isArray(H.runs)?H.runs:[])}catch(S){x||(_i(String(S.message||S)),$r([]))}finally{x||Ms(!1)}})(),()=>{x=!0}},[et,c]),m.useEffect(()=>{if(!c){ys({files:[]});return}let x=!1;return(async()=>{mo(!0);try{const S=new URLSearchParams({flowId:c.id,flowSource:c.source||"user",archived:c.archived?"1":"0"}),H=await fetch(`/api/pipeline-files?${S}`),K=await H.json();if(!H.ok)throw new Error(K.error||"HTTP "+H.status);x||ys({files:Array.isArray(K.files)?K.files:[],path:K.path,error:K.error})}catch(S){x||ys({files:[],error:S.message||String(S)})}finally{x||mo(!1)}})(),()=>{x=!0}},[c]);const Tu=m.useMemo(()=>c?Qt.filter(x=>x&&x.flowId===c.id).sort((x,S)=>S.at-x.at):[],[Qt,c]),Fr=m.useMemo(()=>{let x=0,S=0,H=0,K=0,q=0;for(const X of Tu){const te=X.status||"unknown";te==="success"?x+=1:te==="failed"?S+=1:te==="running"?H+=1:te==="stopped"?K+=1:te==="interrupted"&&(q+=1)}return{success:x,failed:S,running:H,stopped:K,interrupted:q}},[Tu]),Ru=m.useMemo(()=>c?mj(Xr,$i):null,[c,Xr,$i]),ci=m.useMemo(()=>{if(!Ru||!c)return[];const x=Ru.query.toLowerCase(),S=q=>x?q.some(X=>X&&String(X).toLowerCase().includes(x)):!0,H=Ct.map(q=>{var xe,De;const X=q.id,te=String(((xe=q.data)==null?void 0:xe.label)??X),ne=(De=q.data)!=null&&De.definitionId?String(q.data.definitionId):"",pe=[te!==X?te:"",ne&&ne!==X?ne:""].filter(Boolean);return{id:X,label:te,defId:ne,subs:pe}}).filter(({id:q,label:X,defId:te})=>S([q,X,te])).sort((q,X)=>q.id.localeCompare(X.id)).slice(0,18).map(({id:q,label:X,defId:te})=>{const ne=[X!==q?X:null,te||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:q,title:q,subtitle:ne}}),K=oe.filter(q=>q&&q.id&&S([q.id,q.label,q.description])).sort((q,X)=>q.id.localeCompare(X.id)).slice(0,22).map(q=>({kind:"definition",id:q.id,title:q.id,subtitle:q.label&&q.label!==q.id?String(q.label):String(q.type||"")}));return[...H,...K]},[Ru,Ct,oe,c]),Lu=m.useMemo(()=>{const x=ci.filter(H=>H.kind==="instance"),S=ci.filter(H=>H.kind==="definition");return{instances:x,definitions:S}},[ci]);m.useEffect(()=>{Za(x=>{const S=Math.max(0,ci.length-1);return Math.min(Math.max(0,x),S)})},[ci]);const i0=m.useMemo(()=>E7(Xr),[Xr]),vr=m.useMemo(()=>Ct.filter(x=>x.selected),[Ct]),Ag=m.useMemo(()=>new Set(vr.map(x=>x.id)),[vr]),tp=m.useMemo(()=>Sn.filter(x=>Ag.has(x.source)&&Ag.has(x.target)),[Sn,Ag]),o0=m.useMemo(()=>{const x=_e.trim().toLowerCase();return x?nt.filter(S=>[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].filter(Boolean).some(H=>String(H).toLowerCase().includes(x))):nt},[nt,_e]),a0=m.useCallback((x,S)=>{const H=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",K=Date.now().toString(36);let q=`${H}-${K}`,X=2;for(;S.has(q);)q=`${H}-${K}-${X}`,X+=1;return S.add(q),q},[]),l0=m.useCallback((x,S)=>{var Kt,zr;if(!c||!x)return;const H=x.snippet&&typeof x.snippet=="object"?x.snippet:{},K=H.instances&&typeof H.instances=="object"?H.instances:{},q=Object.keys(K);if(q.length===0)return;const X=new Set(Hi.current.map(We=>We.id)),te={};for(const We of q)te[We]=a0(We,X);const ne=(Kt=H.ui)!=null&&Kt.nodePositions&&typeof H.ui.nodePositions=="object"?H.ui.nodePositions:{},pe=(zr=H.ui)!=null&&zr.nodeSizes&&typeof H.ui.nodeSizes=="object"?H.ui.nodeSizes:{},xe=q.map(We=>{const cn=ne[We];return{id:We,x:typeof(cn==null?void 0:cn.x)=="number"?cn.x:0,y:typeof(cn==null?void 0:cn.y)=="number"?cn.y:0}}),De=Math.min(...xe.map(We=>We.x)),le=Math.min(...xe.map(We=>We.y));let Le=S||{x:180,y:160};const ke=wo.current,ft=document.querySelector(".af-pipeline-flow .react-flow");if(!S&&ke&&ft){const We=ft.getBoundingClientRect();Le=ke.screenToFlowPosition({x:We.left+We.width*.48,y:We.top+We.height*.32})}const an={};for(const We of q)an[te[We]]={...K[We]||{}};hn.current={...hn.current,...an};const ln=q.map(We=>{const cn=K[We]||{},Ki=xe.find(Mu=>Mu.id===We)||{x:0,y:0},ui=pe[We]&&typeof pe[We].width=="number"&&typeof pe[We].height=="number"?{width:pe[We].width,height:pe[We].height}:null,al={id:te[We],type:"flowNode",selected:!0,position:{x:Le.x+(Ki.x-De),y:Le.y+(Ki.y-le)},...ui?{width:ui.width,height:ui.height}:{},data:{label:cn.label||te[We],definitionId:cn.definitionId||We,role:cn.role||"normal",body:cn.body||"",script:cn.script||"",...ui?{displaySize:ui}:{}}};return ff(al,hn.current,oe,{},c.id)}),$t=new Set(q),xt=(Array.isArray(H.edges)?H.edges:[]).filter(We=>$t.has(We==null?void 0:We.source)&&$t.has(We==null?void 0:We.target)).map((We,cn)=>({id:`e-${te[We.source]}-${te[We.target]}-${Date.now()}-${cn}`,source:te[We.source],target:te[We.target],sourceHandle:We.sourceHandle??void 0,targetHandle:We.targetHandle??void 0,markerEnd:{type:ds.ArrowClosed}}));bt(We=>[...We.map(cn=>({...cn,selected:!1})),...ln]),on(We=>[...We.map(cn=>({...cn,selected:!1})),...xt]),N(`已添加流程片段:${x.displayName||x.id}`)},[a0,oe,c,on,bt]);Hf.current=l0;const T2=m.useCallback(()=>{var H,K;if(vr.length<2){Ft("请先在画布上选择至少两个节点。"),Ce("flows");return}const x=vr[0],S=vr.length===2?`${((H=x.data)==null?void 0:H.label)||x.id} 片段`:`${((K=x.data)==null?void 0:K.label)||x.id} 等 ${vr.length} 个节点`;bn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Me(""),tn(!0),Ce("flows")},[vr]),R2=m.useCallback(async()=>{var X,te;if(!c||vr.length<2)return;const x=Jt.name.trim();if(!x){Me("请填写片段名称。");return}const S=Rf(vr,hn.current),H={},K={};for(const ne of vr){H[ne.id]={x:((X=ne.position)==null?void 0:X.x)||0,y:((te=ne.position)==null?void 0:te.y)||0};const pe=V7(ne);pe&&(K[ne.id]=pe)}const q=tp.map(ne=>({source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle??null,targetHandle:ne.targetHandle??null}));ee(!0),Me("");try{const ne=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Jt.id,name:x,displayName:x,version:"1.0.0",description:Jt.description,snippet:{instances:S,edges:q,ui:{nodePositions:H,nodeSizes:K}}})}),pe=await ne.json().catch(()=>({}));if(!ne.ok||(pe==null?void 0:pe.ok)===!1)throw new Error((pe==null?void 0:pe.error)||"Publish failed");tn(!1),N(`流程片段已发布:${pe.id||x}`),ms(`流程片段已发布:${pe.id||x}`),await qf(),Ce("flows")}catch(ne){Me(String(ne.message||ne))}finally{ee(!1)}},[c,vr,tp,Jt,qf,ms]),np=m.useMemo(()=>{const x=[],S=new Set;for(const q of vr)S.add(q.id),x.push({node:q,kind:"canvas"});const H=new Map(Ct.map(q=>[q.id,q])),K=new Map(oe.map(q=>[q.id,q]));for(const q of i0){if(S.has(q))continue;const X=H.get(q);if(X){S.add(q),x.push({node:X,kind:"mention"});continue}const te=K.get(q);te&&(S.add(q),x.push({definition:te,kind:"definition"}))}return x},[vr,i0,Ct,oe]),Qr=m.useMemo(()=>{const x=Array.isArray(yt==null?void 0:yt.cursor)?yt.cursor:[],S=Array.isArray(yt==null?void 0:yt.opencode)?yt.opencode:[],H=Array.isArray(yt==null?void 0:yt.claudeCode)?yt.claudeCode:[],K=S.map(xe=>`opencode:${jo(xe)}`),q=H.map(xe=>`claude-code:${jo(xe)}`),X=new Set([...x,...S,...H].map(jo).concat(K).concat(q)),te=(zs||"").trim(),ne=zp(zs,x,S,H),pe=ne&&!X.has(ne)&&!X.has(te)?te:"";return{cursorList:x,opencodeList:S,claudeCodeList:H,currentNotInLists:pe}},[yt,zs]),Ig=m.useMemo(()=>new Set(xo),[xo]),Tg=xo.length,rp=m.useMemo(()=>{const x=new Map(ai.map(X=>[X.key,X])),S=new Set,H=new Set,K=Xl.map(X=>{const te=Ta(X,ai).map(ne=>x.get(ne)).filter(Boolean);for(const ne of te)S.add(ne.key),H.add(String(ne.name||ne.id||ne.key||"").trim());return{...X,skills:te}}).filter(X=>X.skills.length>0),q=ai.filter(X=>{const te=String(X.name||X.id||X.key||"").trim();return!S.has(X.key)&&!H.has(te)});return{groups:K,ungrouped:q}},[Xl,ai]),nc=m.useCallback(()=>{const x=_u.current;if(!x)return;const S=x.getBoundingClientRect(),H=Math.min(400,Math.max(300,window.innerWidth-24)),K=Math.min(Math.max(12,S.right-H),window.innerWidth-H-12),q=Math.max(140,S.top-22),X=Math.min(360,q);bg({position:"fixed",left:`${K}px`,top:`${Math.max(12,S.top-X-10)}px`,width:`${H}px`,maxHeight:`${X}px`})},[]);m.useEffect(()=>{const x=Array.isArray(yt==null?void 0:yt.cursor)?yt.cursor:[],S=Array.isArray(yt==null?void 0:yt.opencode)?yt.opencode:[],H=Array.isArray(yt==null?void 0:yt.claudeCode)?yt.claudeCode:[];Bs(K=>{const q=zp(K,x,S,H);return q===K?K:q})},[yt.cursor,yt.opencode,yt.claudeCode]),m.useEffect(()=>{if(!nl)return;nc();const x=H=>{var q,X;const K=H.target;(q=_u.current)!=null&&q.contains(K)||(X=Pu.current)!=null&&X.contains(K)||Jl(!1)},S=H=>{H.key==="Escape"&&Jl(!1)};return window.addEventListener("resize",nc),window.addEventListener("scroll",nc,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",S),()=>{window.removeEventListener("resize",nc),window.removeEventListener("scroll",nc,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",S)}},[nl,nc]);const ol=m.useCallback(async(x,S={})=>{var xt;if(!c||Ze.current)return;const H=S.phaseContextSnapshot,K=(typeof x=="string"?x:Xr).trim();if(!K)return;const q=Mt.current;Ze.current=!0,Ut(!0),kt(e("flow:composer.connecting")),Lt(Kt=>Kt!=="composer"?"composer":Kt);const X=[...pn];if(q.length>0&&X.push({type:"assistant",segments:[...q]}),sn([...X,{type:"user",text:K}]),X.filter(Kt=>Kt.type==="user").length===0){const Kt=K.replace(/\s+/g," ").slice(0,30)+(K.length>30?"…":"");J(zr=>zr.map(We=>We.id===Q?{...We,label:Kt}:We))}const te=X.map(Kt=>Kt.type==="user"?{role:"user",text:Kt.text}:{role:"assistant",text:(Kt.segments||[]).filter(We=>We.kind==="assistant"||We.kind==="result").map(We=>We.text).join(`
134
134
  `)}).filter(Kt=>Kt.text),ne=H??Re;yo(""),Rt([]),St([]),Xt(!1);const pe=new AbortController;br.current=pe,ge.current=Q;let xe=null;const De=Array.isArray(yt==null?void 0:yt.cursor)?yt.cursor:[],le=Array.isArray(yt==null?void 0:yt.opencode)?yt.opencode:[],Le=Array.isArray(yt==null?void 0:yt.claudeCode)?yt.claudeCode:[],ke=zp(zs,De,le,Le),ft=np.filter(Kt=>Kt.kind!=="definition"&&Kt.node).map(Kt=>Kt.node.id),an=c;let ln=!1,$t=!1;try{xe=setTimeout(()=>pe.abort(),12e4);const Kt={prompt:K,model:ke,flowId:c.id,flowSource:c.source??"user",...c.archived?{flowArchived:!0}:{},contextInstanceIds:ft,thread:te,selectedSkills:xo};ne&&ne.nextPhase&&!ne.isLastPhase&&(Kt.phaseContext={phaseIndex:ne.nextPhase.index,phases:ne.phases,userPromptOriginal:ne.userPromptOriginal||K}),Cu&&(Kt.phaseRole=Cu);const zr=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Kt),signal:pe.signal});if(xe&&(clearTimeout(xe),xe=null),!zr.ok){let ui=zr.statusText||e("flow:composer.requestFailed");try{const al=await zr.json();al&&al.error&&(ui=String(al.error))}catch{}kt(ui),Rt([{kind:"error",text:ui}]);return}const We=(xt=zr.body)==null?void 0:xt.getReader();if(!We){kt(e("flow:composer.cannotReadStream"));return}const cn=new TextDecoder;let Ki="";for(;;){const{done:ui,value:al}=await We.read();if(ui)break;for(Ki+=cn.decode(al,{stream:!0});;){const Mu=Ki.indexOf(`
135
135
  `);if(Mu<0)break;const m0=Ki.slice(0,Mu).trim();if(Ki=Ki.slice(Mu+1),!m0)continue;let Ve;try{Ve=JSON.parse(m0)}catch{continue}if(Ve.type==="status"&&typeof Ve.line=="string"&&kt(Ve.line),Ve.type==="natural"&&typeof Ve.text=="string"&&Ve.text){const mn=typeof Ve.kind=="string"&&Ve.kind?Ve.kind:"assistant";Rt(un=>[...un,{kind:mn,text:Ve.text}])}if(Ve.type==="error"&&Ve.message){$t=!0;const mn=Ve.code?` [${Ve.code}]`:"",un=String(Ve.message)+mn;kt(un),Rt(Zr=>[...Zr,{kind:"error",text:un}])}if(Ve.type==="plan"&&Array.isArray(Ve.steps)){St(Ve.steps.map(un=>({...un,status:"pending"})));const mn=Ve.steps.map((un,Zr)=>`${Zr+1}. ${un.description||un.type}`).join(`
136
- `);Rt(un=>[...un,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ve.steps.length,summary:mn})}])}if(Ve.type==="step-start"){const mn=Ve.index??0,un=Ve.total??0,Zr=Ve.tier?` [${Ve.tier}]`:"",F2=Ve.model?` (${Ve.model})`:"";kt(e("flow:composer.step",{current:mn+1,total:un,description:(Ve.description||"")+Zr+F2})),St(z2=>z2.map(rc=>rc.index===mn?{...rc,status:"running",model:Ve.model,tier:Ve.tier,nodeRole:Ve.nodeRole??rc.nodeRole,instanceId:Ve.instanceId??rc.instanceId,instanceLabel:Ve.instanceLabel??rc.instanceLabel}:rc))}if(Ve.type==="step-progress"){const mn=Ve.index??0,un=Ve.total??0;kt(e("flow:composer.step",{current:mn+1,total:un,description:Ve.description||""}))}if(Ve.type==="step-done"){const mn=Ve.index??0;St(un=>un.map(Zr=>Zr.index===mn?{...Zr,status:Ve.success?"done":"error"}:Zr))}if(Ve.type==="phase-plan"&&Array.isArray(Ve.phases)){or(un=>({...un||{},phases:Ve.phases,currentPhase:Ve.currentPhase??0,phaseTotal:Ve.phaseTotal??Ve.phases.length,phaseName:Ve.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(un==null?void 0:un.userPromptOriginal)||K}));const mn=Ve.phases.map((un,Zr)=>`${Zr+1}. ${un.label}`).join(" → ");Rt(un=>[...un,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ve.phases.length,labels:mn,current:Ve.phaseName||""})}])}Ve.type==="phase-complete"&&(or(mn=>{var Zr;return{...mn||{},phases:Ve.phases||(mn==null?void 0:mn.phases)||[],currentPhase:Ve.phaseIndex??0,phaseTotal:Ve.phaseTotal??((Zr=Ve.phases)==null?void 0:Zr.length)??0,phaseName:Ve.phaseName||"",isLastPhase:!!Ve.isLastPhase,nextPhase:Ve.nextPhase||null,userPromptOriginal:Ve.userPromptOriginal||(mn==null?void 0:mn.userPromptOriginal)||K}}),!Ve.isLastPhase&&Ve.nextPhase&&Rt(mn=>[...mn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ve.phaseName||e("flow:composer.nextPhase"),nextPhase:Ve.nextPhase.label})}])),Ve.type==="done"&&(ln=!0,kt(mn=>mn||e("flow:composer.done")))}}}catch(Kt){const zr=Kt;if(zr.name==="AbortError"){const We=e(xe?"flow:composer.connectTimeout":"flow:composer.aborted");kt(We),Rt(cn=>[...cn,{kind:"error",text:We}])}else{const We=zr.code||zr.name||"UNKNOWN",cn=`${zr.message||String(Kt)} [${We}]`;kt(cn),Rt(Ki=>[...Ki,{kind:"error",text:cn}])}}finally{if(Ze.current=!1,Ut(!1),br.current=null,ge.current=null,xe&&clearTimeout(xe),ln&&an){const Kt={id:an.id,source:an.source??"user",archived:an.archived};(async()=>(await Ws(Kt,{preserveComposer:!0,incrementalSync:!0}),await ea(Kt,{quiet:!0,force:!0})))()}}},[c,Xr,zs,yt,np,Ws,ea,pn,Q,Re,Cu,xo]);dt.current=ol;const c0=m.useCallback(()=>{!Re||Re.isLastPhase||(or(null),ol(e("flow:composer.skipRemainingPhases")))},[Re,ol]),u0=m.useCallback(()=>{if(!Re||Re.isLastPhase||!Re.nextPhase)return;const x=String(Re.nextPhase.label||"").trim()||e("flow:composer.nextPhase");ol(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:Re})},[Re,ol]);m.useEffect(()=>{if(!Pt)return;const x=S=>{S.key==="Escape"&&rn(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[Pt]),m.useEffect(()=>{Te!=="edit"&&rn(!1)},[Te]),m.useLayoutEffect(()=>{const x=Yo.current;if(!x)return;if(!c){x.style.height="";return}x.style.height="0px";const S=getComputedStyle(x),H=parseFloat(S.lineHeight),K=(parseFloat(S.paddingTop)||0)+(parseFloat(S.paddingBottom)||0),q=Number.isFinite(H)&&H>0?H:13*1.45,X=K+q*2,te=K+q*10,ne=Math.min(Math.max(x.scrollHeight,X),te);x.style.height=`${ne}px`},[Xr,c]);const Rg=m.useCallback(x=>{const S=Xr,H=$i,K=mj(S,H);if(!K)return;const q=S.slice(0,K.atIndex)+`@${x} `+S.slice(H);yo(q);const X=K.atIndex+x.length+2;queueMicrotask(()=>{const te=Yo.current;te&&(te.focus(),te.setSelectionRange(X,X)),oi(X)})},[Xr,$i]),Lg=m.useCallback(x=>{yo(S=>{const H=`@${x}`,K=S.indexOf(H);return K<0?S:S.slice(0,K)+S.slice(K+H.length)})},[]),d0=m.useCallback(x=>{x.kind==="canvas"?bt(S=>S.map(H=>H.id===x.node.id?{...H,selected:!1}:H)):x.kind==="mention"?Lg(x.node.id):Lg(x.definition.id)},[bt,Lg]),L2=m.useCallback(()=>{Lt(x=>x==="history"?null:"history")},[]),O2=m.useCallback(()=>{Lt(x=>x==="settings"?null:"settings")},[]),M2=m.useCallback(()=>{Lt(x=>x==="composer"?null:"composer")},[]),Ou=m.useCallback(()=>{Lt(x=>(x==="node"&&Go.current&&(Yl.current=Go.current.id),null))},[]),f0=m.useCallback(()=>{Fi(x=>!x)},[]),$2=()=>{if(!c)return null;const x=si||c.archived||Vs(c.source),S=Rn!=null&&Rn.running?e("flow:schedule.running"):Qn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),H=Rn!=null&&Rn.running?"running":Qn.enabled?"waiting":"disabled",K=qn.slice(0,12),q=c.archived||Vs(c.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Ou,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:X=>{B(X.target.value),T("")},onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),Jf())},onBlur:()=>{M.trim()&&M.trim()!==c.id&&Jf()},placeholder:c.id,disabled:$,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),z?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:z}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),c.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:v,onChange:X=>k(X.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>n0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:L?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("workspace"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("user"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),C?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:C}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[qn.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:jg,disabled:nn,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(nn?"common:common.loading":"common:common.refresh")]})]}),dn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:dn}):null,nn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):K.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:K.map(X=>{const te=X.definitionId||`marketplace:${X.id}${X.version?`@${X.version}`:""}`,ne=Qv.has(te)||Qv.has(`marketplace:${X.id}`),pe=Vf.find(Le=>String(Le.id)===te||String(Le.id)===`marketplace:${X.id}`),xe=Vn===te,De=Fp(X.inputs||X.input),le=Fp(X.outputs||X.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ne?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:X.displayName||X.label||X.id}),o.jsx("span",{children:X.version?`v${X.version}`:te})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:X.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:De.length>0?De.map(Le=>o.jsx("span",{className:"af-pipeline-market-chip",children:Le},`in-${te}-${Le}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:le.length>0?le.map(Le=>o.jsx("span",{className:"af-pipeline-market-chip",children:Le},`out-${te}-${Le}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>$e(X),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:ne?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:q||xe,onClick:()=>{ne&&pe?(t0(pe),Lt(null)):n2(X)},children:e(xe?"flow:settings.installingNode":ne?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},te)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),zl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!Qn.enabled,disabled:x,onChange:X=>Zo(te=>({...te,enabled:X.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.cron||"",disabled:x,onChange:X=>Zo(te=>({...te,cron:X.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.timezone||"",disabled:x,onChange:X=>Zo(te=>({...te,timezone:X.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:Qn.preset||"",disabled:x,onChange:X=>Zo(te=>({...te,preset:X.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Tn).map(X=>o.jsx("option",{value:X,children:X},X))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${H}`}),o.jsx("span",{children:Qn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(Qn.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",S]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Bt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Bt.lastTriggeredAt).toLocaleString()})]}):null,Bt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Bt.lastSkippedAt).toLocaleString(),Bt.lastSkipReason?` · ${Bt.lastSkipReason}`:""]})]}):null,Bt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Bt.lastRunUuid})]}):null,Bt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Bt.lastExitCode)})]}):null,Bt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Bt.lastFinishedAt).toLocaleString()})]}):null]}),Rn!=null&&Rn.lastError||Bt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Rn==null?void 0:Rn.lastError)||Bt.lastError}):null,c.archived||Vs(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Yr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Yr}):null,Wa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Wa}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:Vf.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:cc(c.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:c.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${H}`,children:S})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:Ct.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:c.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:cc(c.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void w2(),disabled:si,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(si?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:Ou,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},D2=()=>{const x=we;if(!x)return null;const S=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,H=x.displayName||x.label||x.id,K=Fp(x.inputs||x.input),q=Fp(x.outputs||x.output);return ns.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:X=>{X.target===X.currentTarget&&$e(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:H})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>$e(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(K.length>0?K:[""]).slice(0,4).map((X,te)=>o.jsx("span",{title:X},`preview-in-${te}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:H}),o.jsx("span",{children:S})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(q.length>0?q:[""]).slice(0,4).map((X,te)=>o.jsx("span",{title:X},`preview-out-${te}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:K.length>0?K.map(X=>o.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-input-${X}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(X=>o.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-output-${X}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:S})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(X=>X.to||X).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(av,{children:[o.jsx(O7,{onReady:a}),o.jsxs(KI.Provider,{value:{modelLists:yt,onModelChange:b2},children:[o.jsxs("div",{className:"af-pipeline-page"+(Te!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Te==="running"?ep(!0):Te!=="edit"?il():n("/projects")},"aria-label":e(Te!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Te!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",m7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Hb(c,"workspace")),children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[go&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Ii?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>ws(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Te==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,"running")})]}),Te==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,"stopped")})]}),(Te==="done"||Te==="error")&&o.jsxs("div",{className:"af-run-timer"+(Te==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Te==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,Te)})]}),Te!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Jn?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Dr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Te==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(et==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!c,onClick:L2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(et==="settings"?" af-icon-btn--active":""),onClick:O2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!c,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(et==="composer"?" af-composer-topbar-btn--active":"")+(Xe?" af-composer-topbar-btn--running":""),onClick:M2,"aria-label":"AI Composer",title:"AI Composer",disabled:!c,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(zn?" af-icon-btn--active":""),onClick:f0,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!c,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!c||Vs(c.source)||c.source!=="user"&&c.source!=="workspace",onClick:()=>_(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!c||Vs(c.source)||c.archived||c.source!=="user"&&c.source!=="workspace",onClick:()=>P(!0),children:"Archive"})]}),Te==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:C2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Te==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Te==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui({runUuid:Zt}),title:Zt?e("flow:topbar.resumeTitle",{uuid:Zt}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Te==="done"||Te==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!c,onClick:()=>void Ui(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!c,onClick:()=>Ee(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":Ie,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),Ie&&c&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var S,H,K,q,X;Ee(!1);const x={};for(const te of li){const ne=ec[te.id];ne&&(x[ne]=((S=xr[ne])==null?void 0:S.value)??((H=xr[ne])==null?void 0:H.path)??((X=(q=(K=te.data)==null?void 0:K.outputs)==null?void 0:q[0])==null?void 0:X.default)??"")}Fn(x),Ot(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Ee(!1),Ui({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Ee(!1),Ui()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Tn).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var K;Ee(!1);const S=Tn[x]||{},H={};for(const q of li){const X=ec[q.id];if(!X)continue;const te=((K=q.data)==null?void 0:K.definitionId)||"",ne=S[q.id]??"";te.startsWith("provide_file")?H[X]={type:"file",path:ne}:H[X]={type:"str",value:ne}}Ui({cliInputsOverride:H})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),ce?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:ce}),o.jsx("button",{type:"button",onClick:()=>rt(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(Te!=="edit"?" af-pipeline-body--run-mode":""),children:[Te==="edit"&&et!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${gs?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Wo(x=>!x),"aria-expanded":gs,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:gs?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:c&&(c.path||Gn.path)||"",children:c?c.id:e("flow:palette2.noPipelineSelected")}),gs&&o.jsx("div",{className:"af-palette-workspace-tree",children:Ai?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Gn.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Gn.error}):c?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:c.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",Gn.files.length,")"]})]}),Gn.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Gn.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Z({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):Gn.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Gn.files.filter(x=>{var S;return x.type==="directory"&&((S=x.children)==null?void 0:S.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(S=>o.jsxs("li",{className:`af-palette-workspace-item${S.type==="file"?" af-palette-workspace-item--clickable":""}`,title:S.path,onClick:S.type==="file"?()=>Z({filePath:S.path,fileName:S.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:S.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:S.name}),S.type==="file"&&S.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:S.size<1024?`${S.size}B`:S.size<1024*1024?`${(S.size/1024).toFixed(1)}KB`:`${(S.size/1024/1024).toFixed(1)}MB`})]},S.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Je,type:"search",className:"af-palette-search-input",value:_e,onChange:x=>ve(x.target.value),placeholder:(Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Pe==="nodes",className:"af-palette-tab"+(Pe==="nodes"?" af-palette-tab--active":""),onClick:()=>Ce("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Pe==="flows",className:"af-palette-tab"+(Pe==="flows"?" af-palette-tab--active":""),onClick:()=>Ce("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?o.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Pe==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:T2,disabled:!c||vr.length<2,title:vr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",vr.length," 节点 / ",tp.length," 连线"]})]})}),gt?o.jsx("p",{className:"af-err af-palette-list-err",children:gt}):null,_t?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):o0.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:o0.map(x=>{const S=`${x.id}@${x.version}`,H=x.displayName||x.name||x.id,K=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>l0(x),draggable:!!c,onDragStart:q=>{q.dataTransfer.setData("application/agentflow-snippet",S),q.dataTransfer.effectAllowed="move"},disabled:!c,title:K,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:H}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),K?o.jsx("span",{className:"af-palette-card-desc",children:K}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},S)})})]}):o.jsx("p",{className:"af-palette-empty",children:_e.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[ld.filter(x=>Wf[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:Wf[x].map(S=>{const H=pj(S.inputs,"input"),K=pj(S.outputs,"output"),X=S.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":YI(S),te=qI(S);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>t0(S),draggable:!!c,onDragStart:ne=>{ne.dataTransfer.setData("application/agentflow-node",S.id),ne.dataTransfer.effectAllowed="move"},disabled:!c,title:X||S.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:b7(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:te}),te!==S.id?o.jsx("span",{className:"af-palette-card-id",children:S.id}):null]})]}),X?o.jsx("span",{className:"af-palette-card-desc",children:X}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[H.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[H.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:fj("input",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ne==null?void 0:ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:zy(ne,pe)})]},`in-${pe}`)),H.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",H.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[K.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[K.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:fj("output",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:zy(ne,pe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ne==null?void 0:ne.type)}})]},`out-${pe}`)),K.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",K.hidden]}):null]})]})]})]},S.id)})})]},x)),c&&oe.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,c&&oe.length>0&&_e.trim()&&t2===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,c?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(ei?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(ei?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+s2,role:"status","aria-live":"polite",children:w}):null]})]}):Te!=="edit"&&c?o.jsx(l7,{flowId:c.id,flowSource:c.source||"user",flowArchived:c.archived,provideNodes:li,edges:Sn,nodes:Ct,onCliInputsChange:V,onBackToEdit:il}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,c&&Wi.length>0&&!U?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:de,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void e0(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>ie(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:Wi.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:S=>{S.preventDefault(),h2(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,c&&Wi.length>0&&U?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Wi.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:f0,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>ie(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:de,onClick:()=>void e0(),children:e("common:common.refresh")})]})]}):null,et==="settings"&&c&&Te==="edit"?$2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:c?o.jsxs(o.Fragment,{children:[o.jsx(H7,{fitViewEpoch:h,canvasTool:Su,nodes:JT,edges:QT,onNodesChange:Te!=="edit"?void 0:qT,onEdgesChange:Te!=="edit"?void 0:YT,onConnect:Te!=="edit"?void 0:c2,onConnectStart:Te!=="edit"?void 0:u2,onConnectEnd:Te!=="edit"?void 0:d2,isValidConnection:Te!=="edit"?void 0:l2,onNodesDelete:Te!=="edit"?void 0:f2,onNodeClick:i2,onNodeDoubleClick:o2,onEdgeClick:a2,onFlowInit:p2,onDrop:x2,onDragOver:y2,hideMinimapAndControls:!!(c&&et),bottomSlot:Te==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:np.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):np.map((x,S)=>{var pe,xe;if(x.kind==="definition"){const De=x.definition,le=String(De.label??De.id),Le=[De.id,De.description?String(De.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Le,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:le}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>d0(x),"aria-label":e("flow:composer.removeFromInput",{id:De.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${De.id}`)}const H=x.node,K=x.kind,q=String(((pe=H.data)==null?void 0:pe.label)??H.id),X=(xe=H.data)!=null&&xe.definitionId?String(H.data.definitionId):"",te=X&&X!==q?`${q} · ${H.id} · ${X}`:`${q} · ${H.id}`,ne=K==="canvas"?e("flow:composer.deselectNode",{id:H.id}):e("flow:composer.removeFromInput",{id:H.id});return o.jsxs("div",{className:"af-composer-node-chip"+(K==="mention"?" af-composer-node-chip--mention":""),title:te,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:q}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>d0(x),"aria-label":ne,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},H.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:Yo,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!c,value:Xr,rows:2,onChange:x=>{yo(x.target.value),oi(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),ol();return}if(Ru&&ci.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),Za(S=>(S+1)%ci.length);else if(x.key==="ArrowUp")x.preventDefault(),Za(S=>(S-1+ci.length)%ci.length);else if(x.key==="Enter"){x.preventDefault();const S=ci[Qa];S&&Rg(S.id)}}},onKeyUp:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??S.value.length)},onClick:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Ru&&c&&ci.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Lu.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Lu.instances.map((x,S)=>{const H=S;return o.jsx("li",{role:"option","aria-selected":H===Qa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Qa?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Za(H),onClick:()=>Rg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),Lu.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Lu.definitions.map((x,S)=>{const H=Lu.instances.length+S;return o.jsx("li",{role:"option","aria-selected":H===Qa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Qa?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Za(H),onClick:()=>Rg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[Y.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Q||"",onChange:x=>{x.target.value==="__new__"?st():Hs(x.target.value)},disabled:Xe,"aria-label":e("flow:composer.switchConversation"),children:[Y.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:_u,type:"button",className:"af-composer-skills-button"+(Tg>0?" af-composer-skills-button--active":""),disabled:!c||Xe,"aria-haspopup":"listbox","aria-expanded":nl,onClick:()=>Jl(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Tg>0?`Skills ${Tg}`:"Skills"})]}),nl&&!Xe?ns.createPortal(o.jsx("div",{ref:Pu,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:_r,children:ai.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[rp.groups.map(x=>{const S=Ta(x,ai),H=n_(x,Ig,ai),K=xg.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(K?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:H==="all",disabled:S.length===0,onChange:q=>{const X=q.target.checked;Qo(te=>X?e_(te,S):t_(te,S))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,H==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":K?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{wg(q=>{const X=new Set(q);return X.has(x.id)?X.delete(x.id):X.add(x.id),X})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:K?"expand_more":"expand_less"})]})]}),K?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ig.has(q.key),onChange:X=>{const te=X.target.checked;Qo(ne=>te?ne.includes(q.key)?ne:[...ne,q.key]:ne.filter(pe=>pe!==q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:q.description}):null]})]},`${x.id}:${q.key}`))})]},x.id)}),rp.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:rp.ungrouped.length})]}),rp.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ig.has(x.key),onChange:S=>{const H=S.target.checked;Qo(K=>H?K.includes(x.key)?K:[...K,x.key]:K.filter(q=>q!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(zs||"").trim()?Qr.currentNotInLists?Qr.currentNotInLists:zp(zs,Qr.cursorList,Qr.opencodeList,Qr.claudeCodeList):"",onChange:x=>Bs(x.target.value),disabled:!c||Xe,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Qr.currentNotInLists?o.jsxs("option",{value:Qr.currentNotInLists,children:[Qr.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Qr.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:Qr.cursorList.map(x=>o.jsx("option",{value:jo(x),children:x},`composer-c-${x}`))}):null,Qr.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:Qr.opencodeList.map(x=>o.jsx("option",{value:`opencode:${jo(x)}`,children:x},`composer-o-${x}`))}):null,Qr.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:Qr.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${jo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(c&&Xr.trim()&&!Xe?" af-composer-send--active":"")+(Xe?" af-composer-send--stop":""),disabled:!c||!Xe&&!Xr.trim(),"aria-label":e(Xe?"flow:composer.stopGeneration":"flow:composer.send"),title:Xe?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(Xe){(x=br.current)==null||x.abort();return}ol()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Xe?"stop":"arrow_upward"})})]})]}),Pt?ns.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&rn(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(Xe?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:Ht||void 0,children:Xe&&!Ht?e("flow:composer.executing"):Ht||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>rn(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),wr.length>1&&!(Re&&Array.isArray(Re.phases)&&Re.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(P7,{steps:wr})}):null,Re&&Array.isArray(Re.phases)&&Re.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Re.phases.map((x,S)=>{const H=x.status||(S<(Re.currentPhase??0)?"done":S===(Re.currentPhase??0)?Xe?"running":Re.nextPhase||Re.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:S+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||S)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(gj,{thread:pn,liveSegments:fn,running:Xe})}),Re&&!Re.isLastPhase&&Re.nextPhase&&!Xe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Re.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:u0,children:e("flow:composer.phaseReviewContinue",{label:Re.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:c0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),Jr&&Te==="edit"?(()=>{var K;const x=String(Jr.query||"").trim().toLowerCase(),S=x?Jr.candidates.filter(q=>{var X,te,ne;return[(X=q.def)==null?void 0:X.id,q.displayLabel,q.description,(te=q.slot)==null?void 0:te.name,(ne=q.slot)==null?void 0:ne.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(x))}):Jr.candidates,H=Jr.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:Jr.left,top:Jr.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Wn((K=Jr.draft.slot)==null?void 0:K.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",Jr.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>bo(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:Jr.query,onChange:q=>bo(X=>X&&{...X,query:q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[S.map(q=>{var ne,pe;const X=q.displayLabel||((ne=q.def)==null?void 0:ne.id),te=zy(q.slot,q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>g2(q),title:q.description||q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:X}),X!==q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:H}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Wn((pe=q.slot)==null?void 0:pe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:te})]})]},`${q.def.id}-${q.slotIndex}`)}),S.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Te!=="edit"&&Jn&&o.jsxs("div",{className:"af-run-console",style:{height:ti},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:k2,onPointerMove:S2,onPointerUp:s0,onPointerCancel:s0,onLostPointerCapture:N2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[Te==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>Dr(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[Xn.map((x,S)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},S)),o.jsx("div",{ref:Va})]})]})]}),Te!=="edit"&&ri&&c?o.jsx(s7,{instanceId:ri,flowId:c.id,runId:Zt,nodeStatus:((p0=xs[ri])==null?void 0:p0.status)??null,onClose:()=>Er(null)}):null,et&&et!=="settings"&&c&&Te==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(et==="node"?" af-pipeline-drawer--wide":"")+(et==="composer"?" af-pipeline-drawer--wide":""),"aria-label":et==="settings"?e("flow:settings.title"):et==="history"?e("flow:history.title"):et==="composer"?"AI Composer":e("flow:nodeProps.title"),children:et==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Ou,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Y.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[Y.map(x=>o.jsxs("button",{type:"button",ref:S=>{S&&x.id===Q&&S.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Q?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Hs(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:S=>{S.stopPropagation(),Oe(x.id)},onKeyDown:S=>{S.key!=="Enter"&&S.key!==" "||(S.preventDefault(),S.stopPropagation(),Oe(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>st(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Xe?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Xe&&!Ht?e("flow:composer.executing"):Ht||e("flow:composer.ready")}),Re&&Array.isArray(Re.phases)&&Re.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Re.phases.map((x,S)=>{const H=x.status||(S<(Re.currentPhase??0)?"done":S===(Re.currentPhase??0)?Xe?"running":Re.isLastPhase&&S===Re.phases.length-1||Re.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:S+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||S)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:ut,children:o.jsx(gj,{thread:pn,liveSegments:fn,running:Xe})}),Re&&!Re.isLastPhase&&Re.nextPhase&&!Xe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Re.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:u0,children:e("flow:composer.phaseReviewContinue",{label:Re.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:c0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):et==="node"&&ct?vt?o.jsx(HI,{draft:vt,setDraft:ju,definitionId:String(((h0=ct.data)==null?void 0:h0.definitionId)??ct.id),systemPromptReadonly:String((Sg==null?void 0:Sg.description)??""),modelLists:yt,disabled:!c,onIdBlur:v2,onClose:Ou,onPublishToMarketplace:r2,error:Xo,ioSlots:{inputs:Array.isArray(vt==null?void 0:vt.inputs)?vt.inputs:[],outputs:Array.isArray(vt==null?void 0:vt.outputs)?vt.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(et==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Ou,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:et==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:x=>{B(x.target.value),T("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Jf())},onBlur:()=>{M.trim()&&M.trim()!==c.id&&Jf()},placeholder:c.id,disabled:$,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),z?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:z}):null]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>n0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:L?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("workspace"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("user"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),C?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:C}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:v,onChange:x=>k(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),zl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!Qn.enabled,disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.cron||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.timezone||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:Qn.preset||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Tn).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),Qn.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(Qn.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:Rn!=null&&Rn.running?e("flow:schedule.running"):Qn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Bt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Bt.lastTriggeredAt).toLocaleString()})]}):null,Bt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Bt.lastSkippedAt).toLocaleString(),Bt.lastSkipReason?` · ${Bt.lastSkipReason}`:""]})]}):null,Bt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Bt.lastRunUuid})]}):null,Bt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Bt.lastExitCode)})]}):null,Bt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Bt.lastFinishedAt).toLocaleString()})]}):null]}),Rn!=null&&Rn.lastError||Bt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Rn==null?void 0:Rn.lastError)||Bt.lastError}):null,c.archived||Vs(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Yr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Yr}):null,Wa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Wa}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:si||c.archived||Vs(c.source),onClick:Cg,children:e(si?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:c.id})]}),gr?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Kr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Kr}):Tu.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[Fr.success+Fr.failed+Fr.running+Fr.stopped+Fr.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[Fr.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:Fr.success})}):null,Fr.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:Fr.failed})}):null,Fr.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:Fr.stopped})}):null,Fr.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:Fr.interrupted})}):null,Fr.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:Fr.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:Tu.map((x,S)=>{const H=x.status||"unknown",K=H==="success"?"af-exec-history-card--success":H==="failed"?"af-exec-history-card--failed":H==="stopped"?"af-exec-history-card--stopped":H==="interrupted"?"af-exec-history-card--interrupted":H==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",q=e(H==="success"?"flow:history.success":H==="failed"?"flow:history.failed":H==="stopped"?"flow:history.stopped":H==="interrupted"?"flow:history.interrupted":H==="running"?"flow:history.running":"flow:history.unknown"),X=H==="success"?"check_circle":H==="failed"?"error":H==="stopped"?"stop_circle":H==="interrupted"?"sync_disabled":H==="running"?"progress_activity":"help",te=x.runId||`${x.at}-${S}`,ne=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:Tu.length-S});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${K}`,onClick:()=>I2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:ne}),o.jsx("span",{className:"af-exec-history-card-time",children:Jx(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X}),q]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),FO(x.durationMs,e)]})]})]})},`${c.id}-${te}`)})})]})]})})]})}):null]}),o.jsx(XN,{open:j2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:E2,onCancel:()=>Pg(!1)}),o.jsx(XN,{open:_2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:A2,onSecondary:P2,onCancel:()=>ep(!1)}),o.jsx($I,{open:zn,onClose:()=>Fi(!1)}),D2(),o.jsx(WU,{open:Nu,onClose:()=>ql(!1),onJump:m2,nodes:Ct}),o.jsx(h7,{open:Ii,onClose:()=>ws(!1),flowId:(c==null?void 0:c.id)??""}),o.jsx(FU,{open:F,onClose:()=>P(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",onArchived:async()=>{P(!1),await Uf(),n("/projects?tab=archived")}}),o.jsx(zU,{open:O&&!!(c!=null&&c.id),onClose:()=>_(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),onDeleted:async()=>{_(!1),p(null),bt([]),on([]),or(null),await Uf(),n("/projects")}}),Fe&&ns.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>tn(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Jt.name,onChange:x=>{const S=x.target.value;bn(H=>({...H,name:S,id:H.id?H.id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Jt.id,onChange:x=>bn(S=>({...S,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Jt.description,onChange:x=>bn(S=>({...S,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",vr.length," 个节点和 ",tp.length," 条内部连线。"]}),me?o.jsx("div",{className:"af-flow-snippet-error",children:me}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>tn(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ue||!Jt.name.trim(),onClick:()=>void R2(),children:ue?"发布中…":"发布"})]})]})}),document.body),o.jsx(VU,{open:!!G,onClose:()=>Z(null),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),filePath:(G==null?void 0:G.filePath)??"",fileName:(G==null?void 0:G.fileName)??"",onSaved:()=>{ys(x=>({...x}))}})]}),ur&&Te!=="edit"&&ns.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:ur.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:qa?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!ur||!c||!Zt)return;const x=Uo||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:x})})).ok?(Ua(H=>H&&{...H,content:x}),Li(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Ka(ur.content),Li(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Li(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Ua(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:qa?o.jsx("textarea",{ref:Ko,className:"af-user-check-modal__textarea",value:Uo||ur.content,onChange:x=>Ka(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:Uo||ur.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:Ya,onChange:x=>Ga(x.target.value),disabled:Wl}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Wl||!Ya.trim(),onClick:()=>{!ur||!c||!Zt||!Ya.trim()||(Xa(!0),pt(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"ai-edit-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:Uo||ur.content,prompt:Ya})}).then(x=>x.json()).then(x=>{Xa(!1),x.ok&&x.content?(Ka(x.content),Li(!0),Ga(""),pt(S=>[...S,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{Xa(!1),pt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Wl?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!ur||!c||!Zt)return;const x=Uo||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-check",runUuid:Zt,instanceId:ur.instanceId,execId:ur.execId})}),Ua(null),Ga(""),Ui({runUuid:Zt})):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),Gr&&Te!=="edit"&&ns.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:Gr.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Vl(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[Gr.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:Gr.question})}):null,Gr.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:Gr.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:vu,onClick:async()=>{if(!(!Gr||!c||!Zt)){qo(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-ask",runUuid:Zt,instanceId:Gr.instanceId,execId:Gr.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Vl(null),qo(!1),Ui({runUuid:Zt})):(qo(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{qo(!1),pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(vu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),Ul&&Te!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(Oi?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:Ul.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Tt(x=>!x),"aria-label":e(Oi?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(Oi?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:Oi?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>ku(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(Tf,{children:Ul.content})})})]}),Mi&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:Mi.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Kl(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:Ja,className:"af-provide-edit-modal__textarea",defaultValue:Mi.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:ZT,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Kl(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Ge&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Ot(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:li.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:li.map(x=>{var pe,xe;const S=ec[x.id];if(!S)return null;const H=((pe=x.data)==null?void 0:pe.definitionId)||"",K=H.startsWith("provide_file"),q=H==="provide_bool",X=((xe=x.data)==null?void 0:xe.label)||x.id,te=ht[S]??"",ne=["true","1","yes","on"].includes(String(te).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(K?" af-run-params-item__icon--file":""),children:K?"description":q?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:X}),o.jsx("span",{className:"af-run-params-item__slot",children:S})]}),q?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ne?" af-run-config-bool-toggle--true":""),onClick:()=>Fn(De=>({...De,[S]:ne?"false":"true"})),"aria-pressed":ne,children:ne?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:te,onChange:De=>Fn(le=>({...le,[S]:De.target.value})),placeholder:e(K?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var S;const x={};for(const H of li){const K=ec[H.id];if(!K)continue;const q=((S=H.data)==null?void 0:S.definitionId)||"",X=ht[K]??"";q.startsWith("provide_file")?x[K]={type:"file",path:X}:x[K]={type:"str",value:X}}Ot(!1),Ee(!1),Ui({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Ot(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const q7="modulepreload",Y7=function(e){return"/"+e},kj={},G7=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(u=>{if(u=Y7(u),u in kj)return;kj[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const c=document.createElement("link");if(c.rel=d?"stylesheet":q7,d||(c.as="script"),c.crossOrigin="",c.href=u,l&&c.setAttribute("nonce",l),document.head.appendChild(c),d)return new Promise((p,h)=>{c.addEventListener("load",p),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},X7=new Set(["echarts"]),J7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),Q7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),Z7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Pa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Ll(e,t){if(!Pa(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Pa(n[r])&&Pa(s)&&(n[r]=Ll(n[r],s));return n}function og(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Pa(n)?Ll(n,t):n):Pa(e)?Ll(e,t):e}function eK(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function Dw(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>Dw(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||Q7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Dw(r,`${t}.${n}`)}}}function tK(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!J7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function nK(e){const t={trigger:"item",renderMode:"richText",backgroundColor:"rgba(20, 22, 28, 0.96)",borderColor:"rgba(124, 156, 255, 0.28)",textStyle:{color:"rgba(255, 255, 255, 0.92)"}};return!e||typeof e!="object"||Array.isArray(e)?t:Ll(e,t)}function rK(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Pa(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return Ll(i,n)}):Pa(e)?Ll(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function sK(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:og(e,n)}function Sj(e,t="rgba(255, 255, 255, 0.62)"){return og(e,{nameTextStyle:{color:t},axisLabel:{color:"rgba(255, 255, 255, 0.58)"},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.22)"}},axisTick:{lineStyle:{color:"rgba(255, 255, 255, 0.18)"}},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}}})}function iK(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:og(e,n)}function oK(e){const t={axisName:{color:"rgba(255, 255, 255, 0.68)"},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}},splitArea:{areaStyle:{color:["rgba(255, 255, 255, 0.025)","rgba(255, 255, 255, 0.045)"]}},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.16)"}}};return e==null?e:og(e,t)}function aK(e,t,n){const r=rK(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Pa(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??Z7,textStyle:Ll(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:nK(e.tooltip),legend:sK(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?iK(e.grid,s||i):e.grid,xAxis:Sj(e.xAxis),yAxis:Sj(e.yAxis),radar:oK(e.radar),series:t}}function lK(e){const t=eK(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!X7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");Dw(n);const r=tK(n.option.series),s=n.title==null?"":String(n.title),i=aK(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}const cK="af:workspace-graph:v2",pc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],uK=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),dK={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},fK={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},pK={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},hK=new Set(["png","jpg","jpeg","gif","webp","svg"]),mK="0.1.44";function gK(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function hl(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function hm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return hK.has(n)}function JI(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=hl(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function yK(e,t){const n=String(e||"").trim();if(!n)return"";const r=hl(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function xK(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function wK(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function bK(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function Nj(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function QI(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function ZI(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Tv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function cd(e){const t=String(Tv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function jj(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function mm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ud(e){return mm(e)}function Fw(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Wy(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function Cj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Ej(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function _j(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=au(s.get(n),e.sourceHandle||"output-0","source"),a=au(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&ou(i,a))}function vK(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=au(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:LI(a)}:null}function kK(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?ou(t.slot,a):ou(a,t.slot)))continue;const u=cd(n);return{def:n,order:r,category:u,categoryRank:pc.indexOf(u),slot:a,slotIndex:i,displayLabel:ud(n),description:Fw(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function dd(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function SK(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function NK(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Hp(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:NK(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function eT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function jK(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[eT(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function Vy(e,t){var c,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=nT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(c=e==null?void 0:e.ui)!=null&&c.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const h of s)h!=null&&h.source&&l.add(String(h.source)),h!=null&&h.target&&l.add(String(h.target));const d=Array.from(l).map(h=>{const g=r[h]||{},v=g.definitionId||h,k=t.find(R=>R.id===v),y=Tv(k)||v,b=t.find(R=>R.id===y)||k,w=g.marketplaceRef||ZI(k),N=i[h]&&typeof i[h].x=="number"&&typeof i[h].y=="number"?i[h]:{x:320+l.size*20,y:180+l.size*12},C=a[h]&&typeof a[h].width=="number"&&typeof a[h].height=="number"?{width:a[h].width,height:a[h].height}:null,j=!!Es(y);return{id:h,type:Lf,position:N,...C?{width:C.width,height:C.height}:{},data:{label:g.label||mm(k)||mm(b)||h,definitionId:y,...w?{marketplaceRef:w}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:QI(y,b||k),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...C?{nodeSize:C}:{},...j&&C?{displaySize:C}:{}}}}).map(h=>ff(h,r,t)),f=s.filter(h=>(h==null?void 0:h.source)&&(h==null?void 0:h.target)).map((h,g)=>({id:h.id||`we-${h.source}-${h.target}-${g}`,source:String(h.source),target:String(h.target),sourceHandle:h.sourceHandle??void 0,targetHandle:h.targetHandle??void 0,markerEnd:{type:ds.ArrowClosed}}));return{nodes:d,edges:TI(f,d),instances:r}}function tT(e){var s,i,a,l,u,d,f,c,p,h,g;const t=!!Es((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((u=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:u.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((c=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:c.height)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return n>0&&r>0?{width:Math.round(n),height:Math.round(r)}:null}function Wp(e,t,n){var l,u;const r=nT(Rf(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((u=d.position)==null?void 0:u.y)||0};const f=tT(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function nT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Es(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Es(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Pd(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Es(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function rT(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function CK(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function EK(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Ao(e){let t=String(e||"").trim();return t.includes("|")?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())):[]}function sT(e){const t=Ao(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function iT(e){return Ao(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function _K(e){const t=String(e||"").replace(/\r\n/g,`
136
+ `);Rt(un=>[...un,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ve.steps.length,summary:mn})}])}if(Ve.type==="step-start"){const mn=Ve.index??0,un=Ve.total??0,Zr=Ve.tier?` [${Ve.tier}]`:"",F2=Ve.model?` (${Ve.model})`:"";kt(e("flow:composer.step",{current:mn+1,total:un,description:(Ve.description||"")+Zr+F2})),St(z2=>z2.map(rc=>rc.index===mn?{...rc,status:"running",model:Ve.model,tier:Ve.tier,nodeRole:Ve.nodeRole??rc.nodeRole,instanceId:Ve.instanceId??rc.instanceId,instanceLabel:Ve.instanceLabel??rc.instanceLabel}:rc))}if(Ve.type==="step-progress"){const mn=Ve.index??0,un=Ve.total??0;kt(e("flow:composer.step",{current:mn+1,total:un,description:Ve.description||""}))}if(Ve.type==="step-done"){const mn=Ve.index??0;St(un=>un.map(Zr=>Zr.index===mn?{...Zr,status:Ve.success?"done":"error"}:Zr))}if(Ve.type==="phase-plan"&&Array.isArray(Ve.phases)){or(un=>({...un||{},phases:Ve.phases,currentPhase:Ve.currentPhase??0,phaseTotal:Ve.phaseTotal??Ve.phases.length,phaseName:Ve.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(un==null?void 0:un.userPromptOriginal)||K}));const mn=Ve.phases.map((un,Zr)=>`${Zr+1}. ${un.label}`).join(" → ");Rt(un=>[...un,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ve.phases.length,labels:mn,current:Ve.phaseName||""})}])}Ve.type==="phase-complete"&&(or(mn=>{var Zr;return{...mn||{},phases:Ve.phases||(mn==null?void 0:mn.phases)||[],currentPhase:Ve.phaseIndex??0,phaseTotal:Ve.phaseTotal??((Zr=Ve.phases)==null?void 0:Zr.length)??0,phaseName:Ve.phaseName||"",isLastPhase:!!Ve.isLastPhase,nextPhase:Ve.nextPhase||null,userPromptOriginal:Ve.userPromptOriginal||(mn==null?void 0:mn.userPromptOriginal)||K}}),!Ve.isLastPhase&&Ve.nextPhase&&Rt(mn=>[...mn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ve.phaseName||e("flow:composer.nextPhase"),nextPhase:Ve.nextPhase.label})}])),Ve.type==="done"&&(ln=!0,kt(mn=>mn||e("flow:composer.done")))}}}catch(Kt){const zr=Kt;if(zr.name==="AbortError"){const We=e(xe?"flow:composer.connectTimeout":"flow:composer.aborted");kt(We),Rt(cn=>[...cn,{kind:"error",text:We}])}else{const We=zr.code||zr.name||"UNKNOWN",cn=`${zr.message||String(Kt)} [${We}]`;kt(cn),Rt(Ki=>[...Ki,{kind:"error",text:cn}])}}finally{if(Ze.current=!1,Ut(!1),br.current=null,ge.current=null,xe&&clearTimeout(xe),ln&&an){const Kt={id:an.id,source:an.source??"user",archived:an.archived};(async()=>(await Ws(Kt,{preserveComposer:!0,incrementalSync:!0}),await ea(Kt,{quiet:!0,force:!0})))()}}},[c,Xr,zs,yt,np,Ws,ea,pn,Q,Re,Cu,xo]);dt.current=ol;const c0=m.useCallback(()=>{!Re||Re.isLastPhase||(or(null),ol(e("flow:composer.skipRemainingPhases")))},[Re,ol]),u0=m.useCallback(()=>{if(!Re||Re.isLastPhase||!Re.nextPhase)return;const x=String(Re.nextPhase.label||"").trim()||e("flow:composer.nextPhase");ol(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:Re})},[Re,ol]);m.useEffect(()=>{if(!Pt)return;const x=S=>{S.key==="Escape"&&rn(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[Pt]),m.useEffect(()=>{Te!=="edit"&&rn(!1)},[Te]),m.useLayoutEffect(()=>{const x=Yo.current;if(!x)return;if(!c){x.style.height="";return}x.style.height="0px";const S=getComputedStyle(x),H=parseFloat(S.lineHeight),K=(parseFloat(S.paddingTop)||0)+(parseFloat(S.paddingBottom)||0),q=Number.isFinite(H)&&H>0?H:13*1.45,X=K+q*2,te=K+q*10,ne=Math.min(Math.max(x.scrollHeight,X),te);x.style.height=`${ne}px`},[Xr,c]);const Rg=m.useCallback(x=>{const S=Xr,H=$i,K=mj(S,H);if(!K)return;const q=S.slice(0,K.atIndex)+`@${x} `+S.slice(H);yo(q);const X=K.atIndex+x.length+2;queueMicrotask(()=>{const te=Yo.current;te&&(te.focus(),te.setSelectionRange(X,X)),oi(X)})},[Xr,$i]),Lg=m.useCallback(x=>{yo(S=>{const H=`@${x}`,K=S.indexOf(H);return K<0?S:S.slice(0,K)+S.slice(K+H.length)})},[]),d0=m.useCallback(x=>{x.kind==="canvas"?bt(S=>S.map(H=>H.id===x.node.id?{...H,selected:!1}:H)):x.kind==="mention"?Lg(x.node.id):Lg(x.definition.id)},[bt,Lg]),L2=m.useCallback(()=>{Lt(x=>x==="history"?null:"history")},[]),O2=m.useCallback(()=>{Lt(x=>x==="settings"?null:"settings")},[]),M2=m.useCallback(()=>{Lt(x=>x==="composer"?null:"composer")},[]),Ou=m.useCallback(()=>{Lt(x=>(x==="node"&&Go.current&&(Yl.current=Go.current.id),null))},[]),f0=m.useCallback(()=>{Fi(x=>!x)},[]),$2=()=>{if(!c)return null;const x=si||c.archived||Vs(c.source),S=Rn!=null&&Rn.running?e("flow:schedule.running"):Qn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),H=Rn!=null&&Rn.running?"running":Qn.enabled?"waiting":"disabled",K=qn.slice(0,12),q=c.archived||Vs(c.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Ou,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:X=>{B(X.target.value),T("")},onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),Jf())},onBlur:()=>{M.trim()&&M.trim()!==c.id&&Jf()},placeholder:c.id,disabled:$,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),z?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:z}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),c.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:v,onChange:X=>k(X.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>n0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:L?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("workspace"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("user"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),C?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:C}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[qn.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:jg,disabled:nn,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(nn?"common:common.loading":"common:common.refresh")]})]}),dn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:dn}):null,nn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):K.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:K.map(X=>{const te=X.definitionId||`marketplace:${X.id}${X.version?`@${X.version}`:""}`,ne=Qv.has(te)||Qv.has(`marketplace:${X.id}`),pe=Vf.find(Le=>String(Le.id)===te||String(Le.id)===`marketplace:${X.id}`),xe=Vn===te,De=Fp(X.inputs||X.input),le=Fp(X.outputs||X.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ne?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:X.displayName||X.label||X.id}),o.jsx("span",{children:X.version?`v${X.version}`:te})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:X.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:De.length>0?De.map(Le=>o.jsx("span",{className:"af-pipeline-market-chip",children:Le},`in-${te}-${Le}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:le.length>0?le.map(Le=>o.jsx("span",{className:"af-pipeline-market-chip",children:Le},`out-${te}-${Le}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>$e(X),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:ne?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:q||xe,onClick:()=>{ne&&pe?(t0(pe),Lt(null)):n2(X)},children:e(xe?"flow:settings.installingNode":ne?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},te)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),zl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!Qn.enabled,disabled:x,onChange:X=>Zo(te=>({...te,enabled:X.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.cron||"",disabled:x,onChange:X=>Zo(te=>({...te,cron:X.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.timezone||"",disabled:x,onChange:X=>Zo(te=>({...te,timezone:X.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:Qn.preset||"",disabled:x,onChange:X=>Zo(te=>({...te,preset:X.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Tn).map(X=>o.jsx("option",{value:X,children:X},X))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${H}`}),o.jsx("span",{children:Qn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(Qn.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",S]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Bt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Bt.lastTriggeredAt).toLocaleString()})]}):null,Bt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Bt.lastSkippedAt).toLocaleString(),Bt.lastSkipReason?` · ${Bt.lastSkipReason}`:""]})]}):null,Bt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Bt.lastRunUuid})]}):null,Bt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Bt.lastExitCode)})]}):null,Bt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Bt.lastFinishedAt).toLocaleString()})]}):null]}),Rn!=null&&Rn.lastError||Bt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Rn==null?void 0:Rn.lastError)||Bt.lastError}):null,c.archived||Vs(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Yr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Yr}):null,Wa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Wa}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:Vf.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:cc(c.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:c.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${H}`,children:S})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:Ct.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:c.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:cc(c.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void w2(),disabled:si,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(si?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:Ou,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},D2=()=>{const x=we;if(!x)return null;const S=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,H=x.displayName||x.label||x.id,K=Fp(x.inputs||x.input),q=Fp(x.outputs||x.output);return ns.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:X=>{X.target===X.currentTarget&&$e(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:H})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>$e(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(K.length>0?K:[""]).slice(0,4).map((X,te)=>o.jsx("span",{title:X},`preview-in-${te}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:H}),o.jsx("span",{children:S})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(q.length>0?q:[""]).slice(0,4).map((X,te)=>o.jsx("span",{title:X},`preview-out-${te}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:K.length>0?K.map(X=>o.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-input-${X}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(X=>o.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-output-${X}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:S})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(X=>X.to||X).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(av,{children:[o.jsx(O7,{onReady:a}),o.jsxs(KI.Provider,{value:{modelLists:yt,onModelChange:b2},children:[o.jsxs("div",{className:"af-pipeline-page"+(Te!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Te==="running"?ep(!0):Te!=="edit"?il():n("/projects")},"aria-label":e(Te!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Te!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",m7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Hb(c,"workspace")),children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[go&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Ii?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>ws(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Te==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,"running")})]}),Te==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,"stopped")})]}),(Te==="done"||Te==="error")&&o.jsxs("div",{className:"af-run-timer"+(Te==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Te==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:Fy(kn,Te)})]}),Te!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Jn?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Dr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Te==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(et==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!c,onClick:L2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(et==="settings"?" af-icon-btn--active":""),onClick:O2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!c,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(et==="composer"?" af-composer-topbar-btn--active":"")+(Xe?" af-composer-topbar-btn--running":""),onClick:M2,"aria-label":"AI Composer",title:"AI Composer",disabled:!c,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(zn?" af-icon-btn--active":""),onClick:f0,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!c,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!c||Vs(c.source)||c.source!=="user"&&c.source!=="workspace",onClick:()=>_(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!c||Vs(c.source)||c.archived||c.source!=="user"&&c.source!=="workspace",onClick:()=>P(!0),children:"Archive"})]}),Te==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:C2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Te==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Te==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui({runUuid:Zt}),title:Zt?e("flow:topbar.resumeTitle",{uuid:Zt}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Te==="done"||Te==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void Ui(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:il,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!c,onClick:()=>void Ui(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!c,onClick:()=>Ee(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":Ie,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),Ie&&c&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var S,H,K,q,X;Ee(!1);const x={};for(const te of li){const ne=ec[te.id];ne&&(x[ne]=((S=xr[ne])==null?void 0:S.value)??((H=xr[ne])==null?void 0:H.path)??((X=(q=(K=te.data)==null?void 0:K.outputs)==null?void 0:q[0])==null?void 0:X.default)??"")}Fn(x),Ot(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Ee(!1),Ui({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Ee(!1),Ui()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Tn).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var K;Ee(!1);const S=Tn[x]||{},H={};for(const q of li){const X=ec[q.id];if(!X)continue;const te=((K=q.data)==null?void 0:K.definitionId)||"",ne=S[q.id]??"";te.startsWith("provide_file")?H[X]={type:"file",path:ne}:H[X]={type:"str",value:ne}}Ui({cliInputsOverride:H})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),ce?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:ce}),o.jsx("button",{type:"button",onClick:()=>rt(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(Te!=="edit"?" af-pipeline-body--run-mode":""),children:[Te==="edit"&&et!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${gs?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Wo(x=>!x),"aria-expanded":gs,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:gs?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:c&&(c.path||Gn.path)||"",children:c?c.id:e("flow:palette2.noPipelineSelected")}),gs&&o.jsx("div",{className:"af-palette-workspace-tree",children:Ai?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Gn.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Gn.error}):c?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:c.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",Gn.files.length,")"]})]}),Gn.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Gn.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Z({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):Gn.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Gn.files.filter(x=>{var S;return x.type==="directory"&&((S=x.children)==null?void 0:S.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(S=>o.jsxs("li",{className:`af-palette-workspace-item${S.type==="file"?" af-palette-workspace-item--clickable":""}`,title:S.path,onClick:S.type==="file"?()=>Z({filePath:S.path,fileName:S.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:S.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:S.name}),S.type==="file"&&S.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:S.size<1024?`${S.size}B`:S.size<1024*1024?`${(S.size/1024).toFixed(1)}KB`:`${(S.size/1024/1024).toFixed(1)}MB`})]},S.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Je,type:"search",className:"af-palette-search-input",value:_e,onChange:x=>ve(x.target.value),placeholder:(Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Pe==="nodes",className:"af-palette-tab"+(Pe==="nodes"?" af-palette-tab--active":""),onClick:()=>Ce("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Pe==="flows",className:"af-palette-tab"+(Pe==="flows"?" af-palette-tab--active":""),onClick:()=>Ce("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?o.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Pe==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:T2,disabled:!c||vr.length<2,title:vr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",vr.length," 节点 / ",tp.length," 连线"]})]})}),gt?o.jsx("p",{className:"af-err af-palette-list-err",children:gt}):null,_t?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):o0.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:o0.map(x=>{const S=`${x.id}@${x.version}`,H=x.displayName||x.name||x.id,K=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>l0(x),draggable:!!c,onDragStart:q=>{q.dataTransfer.setData("application/agentflow-snippet",S),q.dataTransfer.effectAllowed="move"},disabled:!c,title:K,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:H}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),K?o.jsx("span",{className:"af-palette-card-desc",children:K}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},S)})})]}):o.jsx("p",{className:"af-palette-empty",children:_e.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[ld.filter(x=>Wf[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:Wf[x].map(S=>{const H=pj(S.inputs,"input"),K=pj(S.outputs,"output"),X=S.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":YI(S),te=qI(S);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>t0(S),draggable:!!c,onDragStart:ne=>{ne.dataTransfer.setData("application/agentflow-node",S.id),ne.dataTransfer.effectAllowed="move"},disabled:!c,title:X||S.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:b7(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:te}),te!==S.id?o.jsx("span",{className:"af-palette-card-id",children:S.id}):null]})]}),X?o.jsx("span",{className:"af-palette-card-desc",children:X}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[H.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[H.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:fj("input",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ne==null?void 0:ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:zy(ne,pe)})]},`in-${pe}`)),H.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",H.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[K.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[K.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:fj("output",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:zy(ne,pe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ne==null?void 0:ne.type)}})]},`out-${pe}`)),K.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",K.hidden]}):null]})]})]})]},S.id)})})]},x)),c&&oe.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,c&&oe.length>0&&_e.trim()&&t2===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,c?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(ei?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(ei?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+s2,role:"status","aria-live":"polite",children:w}):null]})]}):Te!=="edit"&&c?o.jsx(l7,{flowId:c.id,flowSource:c.source||"user",flowArchived:c.archived,provideNodes:li,edges:Sn,nodes:Ct,onCliInputsChange:V,onBackToEdit:il}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,c&&Wi.length>0&&!U?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:de,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void e0(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>ie(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:Wi.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:S=>{S.preventDefault(),h2(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,c&&Wi.length>0&&U?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Wi.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:f0,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>ie(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:de,onClick:()=>void e0(),children:e("common:common.refresh")})]})]}):null,et==="settings"&&c&&Te==="edit"?$2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:c?o.jsxs(o.Fragment,{children:[o.jsx(H7,{fitViewEpoch:h,canvasTool:Su,nodes:JT,edges:QT,onNodesChange:Te!=="edit"?void 0:qT,onEdgesChange:Te!=="edit"?void 0:YT,onConnect:Te!=="edit"?void 0:c2,onConnectStart:Te!=="edit"?void 0:u2,onConnectEnd:Te!=="edit"?void 0:d2,isValidConnection:Te!=="edit"?void 0:l2,onNodesDelete:Te!=="edit"?void 0:f2,onNodeClick:i2,onNodeDoubleClick:o2,onEdgeClick:a2,onFlowInit:p2,onDrop:x2,onDragOver:y2,hideMinimapAndControls:!!(c&&et),bottomSlot:Te==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:np.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):np.map((x,S)=>{var pe,xe;if(x.kind==="definition"){const De=x.definition,le=String(De.label??De.id),Le=[De.id,De.description?String(De.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Le,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:le}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>d0(x),"aria-label":e("flow:composer.removeFromInput",{id:De.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${De.id}`)}const H=x.node,K=x.kind,q=String(((pe=H.data)==null?void 0:pe.label)??H.id),X=(xe=H.data)!=null&&xe.definitionId?String(H.data.definitionId):"",te=X&&X!==q?`${q} · ${H.id} · ${X}`:`${q} · ${H.id}`,ne=K==="canvas"?e("flow:composer.deselectNode",{id:H.id}):e("flow:composer.removeFromInput",{id:H.id});return o.jsxs("div",{className:"af-composer-node-chip"+(K==="mention"?" af-composer-node-chip--mention":""),title:te,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:q}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>d0(x),"aria-label":ne,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},H.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:Yo,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!c,value:Xr,rows:2,onChange:x=>{yo(x.target.value),oi(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),ol();return}if(Ru&&ci.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),Za(S=>(S+1)%ci.length);else if(x.key==="ArrowUp")x.preventDefault(),Za(S=>(S-1+ci.length)%ci.length);else if(x.key==="Enter"){x.preventDefault();const S=ci[Qa];S&&Rg(S.id)}}},onKeyUp:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??S.value.length)},onClick:x=>{const S=x.target;S instanceof HTMLTextAreaElement&&oi(S.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Ru&&c&&ci.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Lu.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Lu.instances.map((x,S)=>{const H=S;return o.jsx("li",{role:"option","aria-selected":H===Qa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Qa?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Za(H),onClick:()=>Rg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),Lu.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Lu.definitions.map((x,S)=>{const H=Lu.instances.length+S;return o.jsx("li",{role:"option","aria-selected":H===Qa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Qa?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Za(H),onClick:()=>Rg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[Y.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Q||"",onChange:x=>{x.target.value==="__new__"?st():Hs(x.target.value)},disabled:Xe,"aria-label":e("flow:composer.switchConversation"),children:[Y.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:_u,type:"button",className:"af-composer-skills-button"+(Tg>0?" af-composer-skills-button--active":""),disabled:!c||Xe,"aria-haspopup":"listbox","aria-expanded":nl,onClick:()=>Jl(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Tg>0?`Skills ${Tg}`:"Skills"})]}),nl&&!Xe?ns.createPortal(o.jsx("div",{ref:Pu,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:_r,children:ai.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[rp.groups.map(x=>{const S=Ta(x,ai),H=n_(x,Ig,ai),K=xg.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(K?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:H==="all",disabled:S.length===0,onChange:q=>{const X=q.target.checked;Qo(te=>X?e_(te,S):t_(te,S))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,H==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":K?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{wg(q=>{const X=new Set(q);return X.has(x.id)?X.delete(x.id):X.add(x.id),X})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:K?"expand_more":"expand_less"})]})]}),K?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ig.has(q.key),onChange:X=>{const te=X.target.checked;Qo(ne=>te?ne.includes(q.key)?ne:[...ne,q.key]:ne.filter(pe=>pe!==q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:q.description}):null]})]},`${x.id}:${q.key}`))})]},x.id)}),rp.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:rp.ungrouped.length})]}),rp.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ig.has(x.key),onChange:S=>{const H=S.target.checked;Qo(K=>H?K.includes(x.key)?K:[...K,x.key]:K.filter(q=>q!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(zs||"").trim()?Qr.currentNotInLists?Qr.currentNotInLists:zp(zs,Qr.cursorList,Qr.opencodeList,Qr.claudeCodeList):"",onChange:x=>Bs(x.target.value),disabled:!c||Xe,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Qr.currentNotInLists?o.jsxs("option",{value:Qr.currentNotInLists,children:[Qr.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Qr.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:Qr.cursorList.map(x=>o.jsx("option",{value:jo(x),children:x},`composer-c-${x}`))}):null,Qr.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:Qr.opencodeList.map(x=>o.jsx("option",{value:`opencode:${jo(x)}`,children:x},`composer-o-${x}`))}):null,Qr.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:Qr.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${jo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(c&&Xr.trim()&&!Xe?" af-composer-send--active":"")+(Xe?" af-composer-send--stop":""),disabled:!c||!Xe&&!Xr.trim(),"aria-label":e(Xe?"flow:composer.stopGeneration":"flow:composer.send"),title:Xe?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(Xe){(x=br.current)==null||x.abort();return}ol()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Xe?"stop":"arrow_upward"})})]})]}),Pt?ns.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&rn(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(Xe?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:Ht||void 0,children:Xe&&!Ht?e("flow:composer.executing"):Ht||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>rn(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),wr.length>1&&!(Re&&Array.isArray(Re.phases)&&Re.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(P7,{steps:wr})}):null,Re&&Array.isArray(Re.phases)&&Re.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Re.phases.map((x,S)=>{const H=x.status||(S<(Re.currentPhase??0)?"done":S===(Re.currentPhase??0)?Xe?"running":Re.nextPhase||Re.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:S+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||S)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(gj,{thread:pn,liveSegments:fn,running:Xe})}),Re&&!Re.isLastPhase&&Re.nextPhase&&!Xe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Re.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:u0,children:e("flow:composer.phaseReviewContinue",{label:Re.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:c0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),Jr&&Te==="edit"?(()=>{var K;const x=String(Jr.query||"").trim().toLowerCase(),S=x?Jr.candidates.filter(q=>{var X,te,ne;return[(X=q.def)==null?void 0:X.id,q.displayLabel,q.description,(te=q.slot)==null?void 0:te.name,(ne=q.slot)==null?void 0:ne.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(x))}):Jr.candidates,H=Jr.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:Jr.left,top:Jr.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Wn((K=Jr.draft.slot)==null?void 0:K.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",Jr.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>bo(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:Jr.query,onChange:q=>bo(X=>X&&{...X,query:q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[S.map(q=>{var ne,pe;const X=q.displayLabel||((ne=q.def)==null?void 0:ne.id),te=zy(q.slot,q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>g2(q),title:q.description||q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:X}),X!==q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:H}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Wn((pe=q.slot)==null?void 0:pe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:te})]})]},`${q.def.id}-${q.slotIndex}`)}),S.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Te!=="edit"&&Jn&&o.jsxs("div",{className:"af-run-console",style:{height:ti},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:k2,onPointerMove:S2,onPointerUp:s0,onPointerCancel:s0,onLostPointerCapture:N2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[Te==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>Dr(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[Xn.map((x,S)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},S)),o.jsx("div",{ref:Va})]})]})]}),Te!=="edit"&&ri&&c?o.jsx(s7,{instanceId:ri,flowId:c.id,runId:Zt,nodeStatus:((p0=xs[ri])==null?void 0:p0.status)??null,onClose:()=>Er(null)}):null,et&&et!=="settings"&&c&&Te==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(et==="node"?" af-pipeline-drawer--wide":"")+(et==="composer"?" af-pipeline-drawer--wide":""),"aria-label":et==="settings"?e("flow:settings.title"):et==="history"?e("flow:history.title"):et==="composer"?"AI Composer":e("flow:nodeProps.title"),children:et==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Ou,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Y.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[Y.map(x=>o.jsxs("button",{type:"button",ref:S=>{S&&x.id===Q&&S.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Q?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Hs(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:S=>{S.stopPropagation(),Oe(x.id)},onKeyDown:S=>{S.key!=="Enter"&&S.key!==" "||(S.preventDefault(),S.stopPropagation(),Oe(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>st(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Xe?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Xe&&!Ht?e("flow:composer.executing"):Ht||e("flow:composer.ready")}),Re&&Array.isArray(Re.phases)&&Re.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Re.phases.map((x,S)=>{const H=x.status||(S<(Re.currentPhase??0)?"done":S===(Re.currentPhase??0)?Xe?"running":Re.isLastPhase&&S===Re.phases.length-1||Re.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:S+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||S)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:ut,children:o.jsx(gj,{thread:pn,liveSegments:fn,running:Xe})}),Re&&!Re.isLastPhase&&Re.nextPhase&&!Xe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Re.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:u0,children:e("flow:composer.phaseReviewContinue",{label:Re.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:c0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):et==="node"&&ct?vt?o.jsx(HI,{draft:vt,setDraft:ju,definitionId:String(((h0=ct.data)==null?void 0:h0.definitionId)??ct.id),systemPromptReadonly:String((Sg==null?void 0:Sg.description)??""),modelLists:yt,disabled:!c,onIdBlur:v2,onClose:Ou,onPublishToMarketplace:r2,error:Xo,ioSlots:{inputs:Array.isArray(vt==null?void 0:vt.inputs)?vt.inputs:[],outputs:Array.isArray(vt==null?void 0:vt.outputs)?vt.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(et==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Ou,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:et==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:x=>{B(x.target.value),T("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Jf())},onBlur:()=>{M.trim()&&M.trim()!==c.id&&Jf()},placeholder:c.id,disabled:$,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:cc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),z?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:z}):null]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>n0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:L?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("workspace"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:R,onClick:()=>Xf("user"),children:e(R?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),C?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:C}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:v,onChange:x=>k(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),zl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!Qn.enabled,disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.cron||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Qn.timezone||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:Qn.preset||"",disabled:si||c.archived||Vs(c.source),onChange:x=>Zo(S=>({...S,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Tn).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),Qn.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(Qn.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:Rn!=null&&Rn.running?e("flow:schedule.running"):Qn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Bt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Bt.lastTriggeredAt).toLocaleString()})]}):null,Bt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Bt.lastSkippedAt).toLocaleString(),Bt.lastSkipReason?` · ${Bt.lastSkipReason}`:""]})]}):null,Bt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Bt.lastRunUuid})]}):null,Bt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Bt.lastExitCode)})]}):null,Bt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Bt.lastFinishedAt).toLocaleString()})]}):null]}),Rn!=null&&Rn.lastError||Bt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Rn==null?void 0:Rn.lastError)||Bt.lastError}):null,c.archived||Vs(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Yr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Yr}):null,Wa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Wa}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:si||c.archived||Vs(c.source),onClick:Cg,children:e(si?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:c.id})]}),gr?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Kr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Kr}):Tu.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[Fr.success+Fr.failed+Fr.running+Fr.stopped+Fr.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[Fr.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:Fr.success})}):null,Fr.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:Fr.failed})}):null,Fr.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:Fr.stopped})}):null,Fr.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:Fr.interrupted})}):null,Fr.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:Fr.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:Tu.map((x,S)=>{const H=x.status||"unknown",K=H==="success"?"af-exec-history-card--success":H==="failed"?"af-exec-history-card--failed":H==="stopped"?"af-exec-history-card--stopped":H==="interrupted"?"af-exec-history-card--interrupted":H==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",q=e(H==="success"?"flow:history.success":H==="failed"?"flow:history.failed":H==="stopped"?"flow:history.stopped":H==="interrupted"?"flow:history.interrupted":H==="running"?"flow:history.running":"flow:history.unknown"),X=H==="success"?"check_circle":H==="failed"?"error":H==="stopped"?"stop_circle":H==="interrupted"?"sync_disabled":H==="running"?"progress_activity":"help",te=x.runId||`${x.at}-${S}`,ne=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:Tu.length-S});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${K}`,onClick:()=>I2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:ne}),o.jsx("span",{className:"af-exec-history-card-time",children:Jx(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X}),q]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),FO(x.durationMs,e)]})]})]})},`${c.id}-${te}`)})})]})]})})]})}):null]}),o.jsx(XN,{open:j2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:E2,onCancel:()=>Pg(!1)}),o.jsx(XN,{open:_2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:A2,onSecondary:P2,onCancel:()=>ep(!1)}),o.jsx($I,{open:zn,onClose:()=>Fi(!1)}),D2(),o.jsx(WU,{open:Nu,onClose:()=>ql(!1),onJump:m2,nodes:Ct}),o.jsx(h7,{open:Ii,onClose:()=>ws(!1),flowId:(c==null?void 0:c.id)??""}),o.jsx(FU,{open:F,onClose:()=>P(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",onArchived:async()=>{P(!1),await Uf(),n("/projects?tab=archived")}}),o.jsx(zU,{open:O&&!!(c!=null&&c.id),onClose:()=>_(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),onDeleted:async()=>{_(!1),p(null),bt([]),on([]),or(null),await Uf(),n("/projects")}}),Fe&&ns.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>tn(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Jt.name,onChange:x=>{const S=x.target.value;bn(H=>({...H,name:S,id:H.id?H.id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Jt.id,onChange:x=>bn(S=>({...S,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Jt.description,onChange:x=>bn(S=>({...S,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",vr.length," 个节点和 ",tp.length," 条内部连线。"]}),me?o.jsx("div",{className:"af-flow-snippet-error",children:me}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>tn(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ue||!Jt.name.trim(),onClick:()=>void R2(),children:ue?"发布中…":"发布"})]})]})}),document.body),o.jsx(VU,{open:!!G,onClose:()=>Z(null),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),filePath:(G==null?void 0:G.filePath)??"",fileName:(G==null?void 0:G.fileName)??"",onSaved:()=>{ys(x=>({...x}))}})]}),ur&&Te!=="edit"&&ns.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:ur.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:qa?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!ur||!c||!Zt)return;const x=Uo||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:x})})).ok?(Ua(H=>H&&{...H,content:x}),Li(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Ka(ur.content),Li(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Li(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Ua(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:qa?o.jsx("textarea",{ref:Ko,className:"af-user-check-modal__textarea",value:Uo||ur.content,onChange:x=>Ka(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:Uo||ur.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:Ya,onChange:x=>Ga(x.target.value),disabled:Wl}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Wl||!Ya.trim(),onClick:()=>{!ur||!c||!Zt||!Ya.trim()||(Xa(!0),pt(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"ai-edit-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:Uo||ur.content,prompt:Ya})}).then(x=>x.json()).then(x=>{Xa(!1),x.ok&&x.content?(Ka(x.content),Li(!0),Ga(""),pt(S=>[...S,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{Xa(!1),pt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Wl?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!ur||!c||!Zt)return;const x=Uo||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Zt,instanceId:ur.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-check",runUuid:Zt,instanceId:ur.instanceId,execId:ur.execId})}),Ua(null),Ga(""),Ui({runUuid:Zt})):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),Gr&&Te!=="edit"&&ns.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:Gr.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Vl(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[Gr.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:Gr.question})}):null,Gr.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:Gr.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:vu,onClick:async()=>{if(!(!Gr||!c||!Zt)){qo(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-ask",runUuid:Zt,instanceId:Gr.instanceId,execId:Gr.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Vl(null),qo(!1),Ui({runUuid:Zt})):(qo(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{qo(!1),pt(S=>[...S,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(vu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),Ul&&Te!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(Oi?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:Ul.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Tt(x=>!x),"aria-label":e(Oi?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(Oi?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:Oi?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>ku(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(Tf,{children:Ul.content})})})]}),Mi&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:Mi.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Kl(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:Ja,className:"af-provide-edit-modal__textarea",defaultValue:Mi.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:ZT,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Kl(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Ge&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Ot(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:li.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:li.map(x=>{var pe,xe;const S=ec[x.id];if(!S)return null;const H=((pe=x.data)==null?void 0:pe.definitionId)||"",K=H.startsWith("provide_file"),q=H==="provide_bool",X=((xe=x.data)==null?void 0:xe.label)||x.id,te=ht[S]??"",ne=["true","1","yes","on"].includes(String(te).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(K?" af-run-params-item__icon--file":""),children:K?"description":q?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:X}),o.jsx("span",{className:"af-run-params-item__slot",children:S})]}),q?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ne?" af-run-config-bool-toggle--true":""),onClick:()=>Fn(De=>({...De,[S]:ne?"false":"true"})),"aria-pressed":ne,children:ne?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:te,onChange:De=>Fn(le=>({...le,[S]:De.target.value})),placeholder:e(K?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var S;const x={};for(const H of li){const K=ec[H.id];if(!K)continue;const q=((S=H.data)==null?void 0:S.definitionId)||"",X=ht[K]??"";q.startsWith("provide_file")?x[K]={type:"file",path:X}:x[K]={type:"str",value:X}}Ot(!1),Ee(!1),Ui({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Ot(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const q7="modulepreload",Y7=function(e){return"/"+e},kj={},G7=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(u=>{if(u=Y7(u),u in kj)return;kj[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const c=document.createElement("link");if(c.rel=d?"stylesheet":q7,d||(c.as="script"),c.crossOrigin="",c.href=u,l&&c.setAttribute("nonce",l),document.head.appendChild(c),d)return new Promise((p,h)=>{c.addEventListener("load",p),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},X7=new Set(["echarts"]),J7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),Q7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),Z7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Pa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Ll(e,t){if(!Pa(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Pa(n[r])&&Pa(s)&&(n[r]=Ll(n[r],s));return n}function og(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Pa(n)?Ll(n,t):n):Pa(e)?Ll(e,t):e}function eK(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function Dw(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>Dw(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||Q7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Dw(r,`${t}.${n}`)}}}function tK(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!J7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function nK(e){const t={trigger:"item",renderMode:"richText",backgroundColor:"rgba(20, 22, 28, 0.96)",borderColor:"rgba(124, 156, 255, 0.28)",textStyle:{color:"rgba(255, 255, 255, 0.92)"}};return!e||typeof e!="object"||Array.isArray(e)?t:Ll(e,t)}function rK(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Pa(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return Ll(i,n)}):Pa(e)?Ll(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function sK(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:og(e,n)}function Sj(e,t="rgba(255, 255, 255, 0.62)"){return og(e,{nameTextStyle:{color:t},axisLabel:{color:"rgba(255, 255, 255, 0.58)"},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.22)"}},axisTick:{lineStyle:{color:"rgba(255, 255, 255, 0.18)"}},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}}})}function iK(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:og(e,n)}function oK(e){const t={axisName:{color:"rgba(255, 255, 255, 0.68)"},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}},splitArea:{areaStyle:{color:["rgba(255, 255, 255, 0.025)","rgba(255, 255, 255, 0.045)"]}},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.16)"}}};return e==null?e:og(e,t)}function aK(e,t,n){const r=rK(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Pa(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??Z7,textStyle:Ll(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:nK(e.tooltip),legend:sK(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?iK(e.grid,s||i):e.grid,xAxis:Sj(e.xAxis),yAxis:Sj(e.yAxis),radar:oK(e.radar),series:t}}function lK(e){const t=eK(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!X7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");Dw(n);const r=tK(n.option.series),s=n.title==null?"":String(n.title),i=aK(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}const cK="af:workspace-graph:v2",pc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],uK=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),dK={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},fK={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},pK={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},hK=new Set(["png","jpg","jpeg","gif","webp","svg"]),mK="0.1.45";function gK(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function hl(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function hm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return hK.has(n)}function JI(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=hl(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function yK(e,t){const n=String(e||"").trim();if(!n)return"";const r=hl(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function xK(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function wK(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function bK(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function Nj(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function QI(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function ZI(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Tv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function cd(e){const t=String(Tv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function jj(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function mm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ud(e){return mm(e)}function Fw(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Wy(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function Cj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Ej(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function _j(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=au(s.get(n),e.sourceHandle||"output-0","source"),a=au(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&ou(i,a))}function vK(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=au(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:LI(a)}:null}function kK(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?ou(t.slot,a):ou(a,t.slot)))continue;const u=cd(n);return{def:n,order:r,category:u,categoryRank:pc.indexOf(u),slot:a,slotIndex:i,displayLabel:ud(n),description:Fw(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function dd(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function SK(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function NK(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Hp(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:NK(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function eT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function jK(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[eT(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function Vy(e,t){var c,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=nT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(c=e==null?void 0:e.ui)!=null&&c.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const h of s)h!=null&&h.source&&l.add(String(h.source)),h!=null&&h.target&&l.add(String(h.target));const d=Array.from(l).map(h=>{const g=r[h]||{},v=g.definitionId||h,k=t.find(R=>R.id===v),y=Tv(k)||v,b=t.find(R=>R.id===y)||k,w=g.marketplaceRef||ZI(k),N=i[h]&&typeof i[h].x=="number"&&typeof i[h].y=="number"?i[h]:{x:320+l.size*20,y:180+l.size*12},C=a[h]&&typeof a[h].width=="number"&&typeof a[h].height=="number"?{width:a[h].width,height:a[h].height}:null,j=!!Es(y);return{id:h,type:Lf,position:N,...C?{width:C.width,height:C.height}:{},data:{label:g.label||mm(k)||mm(b)||h,definitionId:y,...w?{marketplaceRef:w}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:QI(y,b||k),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...C?{nodeSize:C}:{},...j&&C?{displaySize:C}:{}}}}).map(h=>ff(h,r,t)),f=s.filter(h=>(h==null?void 0:h.source)&&(h==null?void 0:h.target)).map((h,g)=>({id:h.id||`we-${h.source}-${h.target}-${g}`,source:String(h.source),target:String(h.target),sourceHandle:h.sourceHandle??void 0,targetHandle:h.targetHandle??void 0,markerEnd:{type:ds.ArrowClosed}}));return{nodes:d,edges:TI(f,d),instances:r}}function tT(e){var s,i,a,l,u,d,f,c,p,h,g;const t=!!Es((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((u=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:u.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((c=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:c.height)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return n>0&&r>0?{width:Math.round(n),height:Math.round(r)}:null}function Wp(e,t,n){var l,u;const r=nT(Rf(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((u=d.position)==null?void 0:u.y)||0};const f=tT(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function nT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Es(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function Es(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Pd(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Es(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function rT(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function CK(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function EK(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Ao(e){let t=String(e||"").trim();return t.includes("|")?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())):[]}function sT(e){const t=Ao(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function iT(e){return Ao(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function _K(e){const t=String(e||"").replace(/\r\n/g,`
137
137
  `).split(`
138
138
  `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
139
  `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"";if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&Ao(l).length>1&&sT(t[a+1])){i();const u=Ao(l),d=iT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Ao(t[a]).length>1;)f.push(Ao(t[a])),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return i(),n}function oT(e,t=!1){return{...t?{p:({children:n})=>o.jsx(o.Fragment,{children:n})}:{},img:({src:n,alt:r})=>o.jsx("img",{src:JI(n,e),alt:r||"",loading:"lazy"})}}function Pj({children:e,flowParams:t}){return o.jsx(Tf,{components:oT(t,!0),children:String(e||"")})}function PK({content:e,flowParams:t}){const n=m.useMemo(()=>_K(e),[e]),r=m.useMemo(()=>oT(t),[t]);return o.jsx(o.Fragment,{children:n.map((s,i)=>s.type!=="table"?o.jsx(Tf,{components:r,children:s.text},`md-${i}`):o.jsx("div",{className:"af-work-display-table-wrap",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:s.headers.map((a,l)=>o.jsx("th",{style:{textAlign:s.align[l]||"left"},children:o.jsx(Pj,{flowParams:t,children:a})},l))})}),o.jsx("tbody",{children:s.rows.map((a,l)=>o.jsx("tr",{children:s.headers.map((u,d)=>o.jsx("td",{style:{textAlign:s.align[d]||"left"},children:o.jsx(Pj,{flowParams:t,children:a[d]||""})},d))},l))})]})},`table-${i}`))})}function AK(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
@@ -156,7 +156,7 @@ ${Oe}`;yr(Ut=>Ut.map(kt=>{if(kt.id!==Y)return kt;const sn=[...Array.isArray(kt.r
156
156
  `),at:Date.now()},Hs=[...St];return Xt>=0?Hs[Xt]=or:Hs.push(or),{...kt,rawTrace:sn,messages:Hs.slice(-160)}}))},rn=ge=>{yr(Ze=>Ze.map(dt=>dt.id===Y?{...dt,status:ge,endedAt:Date.now()}:dt))},br=ge=>{const Ze=new Set,dt=String((ge==null?void 0:ge.nodeId)||"").trim();dt&&Ze.add(dt);for(const st of Array.isArray(ge==null?void 0:ge.displayNodeIds)?ge.displayNodeIds:[]){const Oe=String(st||"").trim();Oe&&Ze.add(Oe)}for(const st of Array.isArray(ge==null?void 0:ge.touchedNodeIds)?ge.touchedNodeIds:[]){const Oe=String(st||"").trim();Oe&&Ze.add(Oe)}if(Ze.size===0)for(const st of Array.isArray(ge==null?void 0:ge.order)?ge.order:[]){const Oe=String(st||"").trim();Oe&&Ze.add(Oe)}return Ze},ut=(ge,Ze=null)=>{const dt=Vy(ge||W,D),st=new Map(dt.nodes.map(Ut=>[Ut.id,Ut])),Oe=dt.instances||{},at=Ze instanceof Set?Ze:null;a(Ut=>{const kt=new Set(Ut.map(St=>St.id)),sn={...Wp(Ut,c.current,C.current).instances||{}};for(const[St,Xt]of Object.entries(Oe)){if(at&&!at.has(St)||!kt.has(St))continue;const or=sn[St];Es((Xt==null?void 0:Xt.definitionId)||(or==null?void 0:or.definitionId))?sn[St]=Xt:Array.isArray(Xt==null?void 0:Xt.output)&&(sn[St]={...or||Xt,output:Xt.output})}return C.current=sn,N(sn),Ut.map(St=>{var or,Hs,hn;if(at&&!at.has(St.id))return St;const Xt=st.get(St.id);return Xt?Es(((or=Xt.data)==null?void 0:or.definitionId)||((Hs=St.data)==null?void 0:Hs.definitionId))?{...St,data:{...St.data,...Xt.data}}:Array.isArray((hn=Xt.data)==null?void 0:hn.outputs)?{...St,data:{...St.data,outputs:Xt.data.outputs}}:St:St})})};for(;;){const{value:ge,done:Ze}=await re.read();if(Ze)break;be+=ae.decode(ge,{stream:!0});const dt=be.split(`
157
157
  `);be=dt.pop()||"";for(const st of dt){if(!st.trim())continue;const Oe=JSON.parse(st);if(Oe.type==="error")throw new Error(Oe.error||"Workspace run failed");if(Oe.type==="stopped"){ks.current=!0,Ae=Array.isArray(Oe.order)?Oe.order:Ae;continue}if(Oe.type==="node-start"&&(ze(`Running ${Oe.nodeId}...`),fn(Oe.nodeId),Ht(Oe.nodeId,Oe.definitionId,"running")),Oe.type==="node-done"&&(pn(Oe.nodeId),Ht(Oe.nodeId,Oe.definitionId,"done")),Oe.type==="status"&&Mt(Oe.line||Oe.message||""),Oe.type==="paused"&&(lt=Array.isArray(Oe.nodeIds)?Oe.nodeIds:[]),Oe.type==="natural"&&(Oe.kind==="thinking"?Re(Oe.text||""):wr(Oe.kind,Oe.text||"")),Oe.type==="raw"){const at=Nj(Oe);at&&Re(at),Pt(Oe)}Oe.type==="graph"&&Oe.graph&&ut(Oe.graph,br(Oe)),Oe.type==="done"&&(Oe.graph&&ut(Oe.graph,br(Oe)),Ae=Array.isArray(Oe.order)?Oe.order:[],lt=Array.isArray(Oe.pauseNodeIds)?Oe.pauseNodeIds:lt)}}if(be.trim()){const ge=JSON.parse(be);if(ge.type==="error")throw new Error(ge.error||"Workspace run failed");if(ge.type==="stopped"&&(ks.current=!0),ge.type==="node-start"&&(ze(`Running ${ge.nodeId}...`),fn(ge.nodeId),Ht(ge.nodeId,ge.definitionId,"running")),ge.type==="node-done"&&(pn(ge.nodeId),Ht(ge.nodeId,ge.definitionId,"done")),ge.type==="status"&&Mt(ge.line||ge.message||""),ge.type==="paused"&&(lt=Array.isArray(ge.nodeIds)?ge.nodeIds:[]),ge.type==="natural"&&(ge.kind==="thinking"?Re(ge.text||""):wr(ge.kind,ge.text||"")),ge.type==="raw"){const Ze=Nj(ge);Ze&&Re(Ze),Pt(ge)}ge.type==="graph"&&ge.graph&&ut(ge.graph,br(ge)),ge.type==="done"&&(ge.graph&&ut(ge.graph,br(ge)),Ae=Array.isArray(ge.order)?ge.order:[],lt=Array.isArray(ge.pauseNodeIds)?ge.pauseNodeIds:lt)}ks.current&&(qr(new Set),Ri(ge=>{var dt;const Ze=((dt=Object.entries(ge).find(([,st])=>(st==null?void 0:st.status)==="running"))==null?void 0:dt[0])||E;return Ze?{...ge,[Ze]:{status:"stopped"}}:ge})),ze(ks.current?`Workspace run stopped: ${E}`:lt.length?`Workspace run paused at ${lt.join(", ")}`:`Workspace run done: ${Ae.length?Ae.join(" -> "):E}`),rn(ks.current?"stopped":lt.length?"paused":"done"),ks.current||await Zn()}catch(se){if(ks.current||(se==null?void 0:se.name)==="AbortError"){qr(new Set),Ri(re=>{var be;const ae=((be=Object.entries(re).find(([,Ae])=>(Ae==null?void 0:Ae.status)==="running"))==null?void 0:be[0])||E;return ae?{...re,[ae]:{status:"stopped"}}:re}),ze(`Workspace run stopped: ${E}`),yr(re=>re.map(ae=>ae.id===Y?{...ae,status:"stopped",endedAt:Date.now()}:ae));return}qr(new Set),Ri(re=>{var be;const ae=(be=Object.entries(re).find(([,Ae])=>(Ae==null?void 0:Ae.status)==="running"))==null?void 0:be[0];return ae?{...re,[ae]:{status:"failed"}}:re}),ze(String(se.message||se)),yr(re=>re.map(ae=>ae.id===Y?{...ae,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(ae.messages)?ae.messages:[],{role:"assistant",error:!0,text:String(se.message||se),at:Date.now()}].slice(-160)}:ae))}finally{vs.current===Q&&(vs.current=null),Ti(""),qr(new Set)}},[et,l,s,Zn,i,D,Tn,ir,gr,u,a,ce]),qa=m.useCallback(async()=>{try{const W=await(await fetch("/api/skills")).json().catch(()=>({})),Y=Array.isArray(W.skills)?W.skills.map(J=>({key:String(J.key),name:String(J.name||J.id||J.key),description:J.description?String(J.description):"",sourceLabel:J.sourceLabel?String(J.sourceLabel):""})):[];$r(Y),_i(!0)}catch{_i(!0)}},[]),Li=m.useCallback(async()=>{try{const W=await(await fetch("/api/mcps")).json().catch(()=>({})),Y=Array.isArray(W.servers)?W.servers.map(J=>({name:String((J==null?void 0:J.name)||""),type:String((J==null?void 0:J.type)||""),url:String((J==null?void 0:J.url)||""),command:String((J==null?void 0:J.command)||""),args:Array.isArray(J==null?void 0:J.args)?J.args.map(String):[],description:String((J==null?void 0:J.description)||"")})).filter(J=>J.name):[];ys(Y)}catch{ys([])}},[]);m.useEffect(()=>{Fs().catch(E=>ze(String(E.message||E))),Bt(),fetch("/api/model-lists").then(E=>E.json()).then(E=>$e({cursor:Array.isArray(E.cursor)?E.cursor.map(String):[],opencode:Array.isArray(E.opencode)?E.opencode.map(String):[],claudeCode:Array.isArray(E.claudeCode)?E.claudeCode.map(String):[]})).catch(()=>{}),qa(),Li(),fetch("/api/skill-collections").then(E=>E.json()).then(E=>{Pi(Ca(E)),Wo(!0)}).catch(()=>{}),fetch("/api/auth/me").then(E=>E.json()).then(E=>Fn(E.user||null)).catch(()=>Fn(null))},[Fs,Bt,Li,qa,Yr]),m.useEffect(()=>{if(Wa(""),!(!Kr||!gs)){if(!Yr){Ms([]);return}Ms(r_(Yr,"workspace",Qt,ms)),Wa(Yr)}},[ms,gs,Qt,Kr,Yr]),m.useEffect(()=>{if(!(Vo!==Yr||!Yr))try{localStorage.setItem(Yr,JSON.stringify(gr))}catch{}},[gr,Yr,Vo]),m.useEffect(()=>{C.current=w},[w]),m.useEffect(()=>{f.current=i},[i]),m.useEffect(()=>{const E=p.current,W=new Map,Y=[];for(const re of i){const ae=eT(re);W.set(re.id,ae),E.get(re.id)!==ae&&Y.push(re.id)}if(p.current=W,Y.length===0)return;const J=()=>Y.forEach(re=>r(re)),Q=window.requestAnimationFrame(J),se=window.setTimeout(J,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(se)}},[i,r]),m.useEffect(()=>{c.current=l},[l]),m.useEffect(()=>{k.current=y},[y]),m.useEffect(()=>{if(!y)return;const E=Y=>{Y.key==="Escape"&&b(null)},W=Y=>{var J,Q;(Q=(J=Y.target)==null?void 0:J.closest)!=null&&Q.call(J,".af-connect-node-menu")||b(null)};return document.addEventListener("keydown",E),document.addEventListener("pointerdown",W),()=>{document.removeEventListener("keydown",E),document.removeEventListener("pointerdown",W)}},[y]),m.useEffect(()=>{if(j.current&&ce)return R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{ir().catch(E=>ze(String(E.message||E)))},650),()=>{R.current&&window.clearTimeout(R.current)}},[i,l,ir,ce]);const Ya=m.useCallback((E,W)=>{if(!ce){ze("Readonly workspace");return}const Y=JK(W),J=be=>Array.isArray(be)?be.map(Ae=>(Ae==null?void 0:Ae.name)!=="skillKeys"&&(Ae==null?void 0:Ae.name)!=="skillsContext"&&(Ae==null?void 0:Ae.type)!=="text"?Ae:{...Ae,default:Y,value:Y}):[],Q=i.map(be=>{var Ae;return be.id!==E?be:{...be,data:{...be.data,body:Y,inputs:J((Ae=be.data)==null?void 0:Ae.inputs)}}}),se=C.current||{},re=se[E]&&typeof se[E]=="object"?se[E]:{},ae={...se,[E]:{...re,body:Y,input:J(re.input)}};C.current=ae,a(Q),N(ae),tn(be=>!be||be.id!==E?be:{...be,body:Y,inputs:J(be.inputs)}),ir(Q,l).catch(be=>ze(String(be.message||be)))},[l,i,ir,a,ce]),Ga=m.useCallback((E,W)=>{if(!ce){ze("Readonly workspace");return}const Y=ZK(W),J=be=>Array.isArray(be)?be.map(Ae=>(Ae==null?void 0:Ae.name)!=="serverNames"&&(Ae==null?void 0:Ae.name)!=="mcpContext"&&(Ae==null?void 0:Ae.type)!=="text"?Ae:{...Ae,default:Y,value:Y}):[],Q=i.map(be=>{var Ae;return be.id!==E?be:{...be,data:{...be.data,body:Y,inputs:J((Ae=be.data)==null?void 0:Ae.inputs)}}}),se=C.current||{},re=se[E]&&typeof se[E]=="object"?se[E]:{},ae={...se,[E]:{...re,body:Y,input:J(re.input)}};C.current=ae,a(Q),N(ae),tn(be=>!be||be.id!==E?be:{...be,body:Y,inputs:J(be.inputs)}),ir(Q,l).catch(be=>ze(String(be.message||be)))},[l,i,ir,a,ce]),Wl=m.useCallback(E=>{const W=String(E||"").trim();W&&(ri(Y=>Y===W?"":W),xr(Y=>({...Y,[W]:Y[W]||{sessionId:`nodechat_${Date.now()}_${W.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Xa=m.useCallback((E,W)=>{const Y=String(E||"").trim();Y&&xr(J=>({...J,[Y]:{...J[Y]||{sessionId:`nodechat_${Date.now()}_${Y.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(W||""),error:""}}))},[]),Ko=m.useCallback((E,W,Y="replace",J={})=>{var wr;if(!ce){ze("Readonly workspace");return}const Q=String(E||"").trim();if(!Q)return;const se=f.current.find(Re=>Re.id===Q),re=Es((wr=se==null?void 0:se.data)==null?void 0:wr.definitionId),ae=re==="html"?rT(W):String(W||""),be=se?Pd(se.data):"",Ae=Y==="append"&&String(be||"").trim()?`${String(be).replace(/\s+$/g,"")}
158
158
 
159
- ${ae.trim()}`:ae,lt=re==="image"?"src":"content",Qe=Re=>{let Mt=!1;return(Array.isArray(Re)?Re:[]).map(rn=>{const br=String((rn==null?void 0:rn.name)||""),ut=String((rn==null?void 0:rn.type)||"");return!Mt&&(br===lt||br==="filePath"||ut==="text")?(Mt=!0,{...rn,default:Ae,value:Ae}):rn})},Xe=f.current.map(Re=>{var Mt,Pt;return Re.id!==Q?Re:{...Re,data:{...Re.data,body:Ae,inputs:Qe((Mt=Re.data)==null?void 0:Mt.inputs),outputs:Qe((Pt=Re.data)==null?void 0:Pt.outputs)}}}),Ht=C.current||{},fn=Ht[Q]&&typeof Ht[Q]=="object"?Ht[Q]:{},pn={...Ht,[Q]:{...fn,body:Ae,input:Qe(fn.input),output:Qe(fn.output)}};C.current=pn,a(Xe),N(pn),tn(Re=>(Re==null?void 0:Re.id)===Q?{...Re,body:Ae}:Re),(J==null?void 0:J.logChat)!==!1&&xr(Re=>{var Mt;return{...Re,[Q]:{...Re[Q]||{},candidateContent:"",messages:[...(Mt=Re[Q])!=null&&Mt.messages&&Array.isArray(Re[Q].messages)?Re[Q].messages:[],{role:"assistant",text:Y==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),ir(Xe,c.current).catch(Re=>ze(String(Re.message||Re))),ze(String((J==null?void 0:J.statusMessage)||"")||(Y==="append"?"已追加节点内容":"已替换节点内容"))},[ir,a,ce]),Gr=m.useCallback(async E=>{if(!ce)return ze("Readonly workspace"),"";if(!hm(E))return ze("请选择图片文件"),"";try{const W=new FormData;W.set("file",E),W.set("dir","img"),s.flowId&&W.set("flowId",s.flowId),s.flowSource&&W.set("flowSource",s.flowSource),s.archived&&W.set("archived","1");const Y=await fetch("/api/workspace/upload",{method:"POST",body:W}),J=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(J.error||"上传图片失败");const Q=String(J.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q))re.delete(ae);return re}),ze(`已上传图片 ${Q}`),Q}catch(W){return ze(String(W.message||W)),""}},[s,Zn,ce]),Vl=m.useCallback(async(E,W)=>{const Y=String(E||"").trim();if(!Y)return;const J=await Gr(W);J&&Ko(Y,J,"replace",{logChat:!1,statusMessage:`已上传图片 ${J}`})},[Ko,Gr]),vu=m.useCallback((E,W="replace")=>{var Q;const Y=String(E||"").trim(),J=String(((Q=Er[Y])==null?void 0:Q.candidateContent)||"").trim();!Y||!J||Ko(Y,J,W)},[Er,Ko]),qo=m.useCallback(async(E,W=void 0)=>{var Ae,lt,Qe;if(!ce){ze("Readonly workspace");return}const Y=String(E||"").trim();if(!Y)return;const J=Er[Y]||{},Q=String(W!==void 0?W:J.draft||"").trim();if(!Q||J.running)return;const se=f.current.find(Xe=>Xe.id===Y);if(!se)return;const re={role:"user",text:Q,at:Date.now()},ae=Array.isArray(J.messages)?J.messages:[],be=J.sessionId||`nodechat_${Date.now()}_${Y.replace(/[^a-z0-9_-]+/gi,"_")}`;xr(Xe=>({...Xe,[Y]:{...J,sessionId:be,messages:[...ae,re],draft:"",running:!0,error:""}}));try{const Xe=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:be,node:{id:Y,label:((Ae=se.data)==null?void 0:Ae.label)||Y,definitionId:((lt=se.data)==null?void 0:lt.definitionId)||""},nodeKind:Es((Qe=se.data)==null?void 0:Qe.definitionId)||"markdown",currentContent:Pd(se.data),messages:ae,message:Q,model:et})}),Ht=await Xe.json().catch(()=>({}));if(!Xe.ok)throw new Error(Ht.error||"节点微调失败");const fn=String(Ht.candidateContent||Ht.reply||"").trim();xr(pn=>{var wr;return{...pn,[Y]:{...pn[Y]||{},sessionId:String(Ht.sessionId||be),running:!1,candidateContent:fn,messages:[...(wr=pn[Y])!=null&&wr.messages&&Array.isArray(pn[Y].messages)?pn[Y].messages:[...ae,re],{role:"assistant",text:fn||"已生成候选内容。",at:Date.now()}]}}})}catch(Xe){const Ht=String(Xe.message||Xe);xr(fn=>({...fn,[Y]:{...fn[Y]||{},running:!1,error:Ht}})),ze(Ht)}},[et,s,Er,ce]),Ul=m.useCallback(async(E,W)=>{if(!ce){ze("Readonly workspace");return}const Y=Pd(W);if(!String(Y||"").trim()){ze("展示节点没有可保存内容");return}const J=HK(E,W),Q=window.prompt("保存到 workspace 相对路径",J);if(Q)try{const se=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Q,content:Y})}),re=await se.json().catch(()=>({}));if(!se.ok)throw new Error(re.error||"保存文件失败");const ae=re.path||Q,be=hl(s);be.set("path",ae);const Ae=await fetch(`/api/workspace/file?${be.toString()}`);if(!Ae.ok){const lt=await Ae.json().catch(()=>({}));throw new Error(lt.error||`保存后读取失败:${ae}`)}await Zn(),ee(lt=>YK(lt,ae,String(Y||"").length)),nn(lt=>{const Qe=new Set(lt);for(const Xe of Vp(ae))Qe.delete(Xe);return Qe}),ze(`已保存 ${ae}`)}catch(se){ze(String(se.message||se))}},[s,Zn,ce]),ku=m.useCallback((E,W)=>{const Y=String(E||"");Y&&tn(J=>{if(!J||J.id!==Y)return J;const Q=typeof W=="function"?W(J):W;return!Q||typeof Q!="object"?J:{...J,...Q}})},[]),Oi=m.useMemo(()=>i.map(E=>{var W,Y;return{...E,data:{...E.data,selected:E.selected===!0,modelLists:we,showBodyPreview:!0,isExecuting:Qn.has(E.id),nodeStatus:((W=zl[E.id])==null?void 0:W.status)??null,nodeElapsed:((Y=zl[E.id])==null?void 0:Y.elapsed)??null,flowParams:s,readOnly:!ce,onRunWorkspaceNode:Ka,onStopWorkspaceNode:Uo,runningRunNodeId:Tn,skills:Qt,skillCollections:ms,onChangeLoadSkillKeys:Ya,onRefreshSkills:qa,mcpServers:Gn,onChangeLoadMcpNames:Ga,onRefreshMcps:Li,onSaveDisplayNodeToFile:Ul,onUploadWorkspaceImage:Gr,onUploadImageToDisplayNode:Vl,nodeChatActive:bs===E.id,nodeChat:Er[E.id]||null,onSetDisplayNodeContent:Ko,onToggleNodeChat:Wl,onCloseNodeChat:()=>ri(""),onUpdateNodeChatDraft:Xa,onSendNodeChat:qo,onApplyNodeChatCandidate:vu,onSyncNodePropDraft:ku}}}),[bs,vu,Ga,Ya,s,Gn,we,Er,i,Li,qa,Ka,Tn,Ul,qo,Ko,ms,Qt,Uo,ku,Wl,Xa,Vl,Gr,Qn,zl,ce]);m.useEffect(()=>{const E=h.current,W=new Map,Y=[];for(const re of Oi){const ae=jK(re);W.set(re.id,ae),E.get(re.id)!==ae&&Y.push(re.id)}if(h.current=W,Y.length===0)return;const J=()=>Y.forEach(re=>r(re)),Q=window.requestAnimationFrame(J),se=window.setTimeout(J,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(se)}},[Oi,r]);const Tt=m.useMemo(()=>i.find(E=>E.id===gt)||null,[i,gt]),Mi=m.useRef({id:"",draft:null}),Kl=m.useMemo(()=>{const E=Aj(Tt);return E?JSON.stringify(E):""},[Tt]);m.useEffect(()=>{if(!Tt){Mi.current={id:"",draft:null},tn(null),bn("");return}const E=Aj(Tt),W=Mi.current;Mi.current={id:Tt.id,draft:E},tn(Y=>!Y||Y.id!==Tt.id||W.id!==Tt.id||!W.draft?E:tq(Y,W.draft,E)),bn("")},[Tt==null?void 0:Tt.id,Kl]);const Ja=m.useCallback((E=!1)=>{var wr,Re;if(!Fe||!Tt)return!1;if(!ce)return bn("Readonly workspace"),ze("Readonly workspace"),!1;const W=Tt.id,Y=String(Fe.newId||"").trim(),J=E?Y:W;if(bn(""),E){if(!BI.test(J))return bn("Invalid instance id"),!1;if(i.some(Mt=>Mt.id===J&&Mt.id!==W))return bn("Duplicate instance id"),!1}const Q=String(Fe.role||"").trim(),se=La.includes(Q)?Q:"normal",re=String(Fe.model||"").trim(),ae=Mt=>(Array.isArray(Mt)?Mt:[]).map(Pt=>({type:String((Pt==null?void 0:Pt.type)??"node").trim()||"node",name:String((Pt==null?void 0:Pt.name)??""),default:String((Pt==null?void 0:Pt.default)??""),required:!!(Pt!=null&&Pt.required),showOnNode:(Pt==null?void 0:Pt.showOnNode)!=null?Pt.showOnNode!==!1:!!(Pt!=null&&Pt.required)||String((Pt==null?void 0:Pt.type)??"node").trim().toLowerCase()==="node"})),be=String(((wr=Tt.data)==null?void 0:wr.definitionId)??J),Ae=be.startsWith("provide_"),lt={...Tt.data,label:String(Fe.label||"").trim()||J,role:se,model:re===""||re==="default"?void 0:re,body:Ae?"":String(Fe.body??""),images:Ae?[]:os(Fe.images),inputs:ae(Fe.inputs),outputs:Ae&&Array.isArray((Re=Tt.data)==null?void 0:Re.outputs)?Tt.data.outputs:ae(Fe.outputs)},Qe=String(Fe.script??"").trim();be==="tool_nodejs"||Qe!==""?lt.script=String(Fe.script??""):delete lt.script;const Xe=Tt.data||{};if(!(J!==W||Xe.label!==lt.label||Xe.role!==lt.role||Xe.model!==lt.model||Xe.body!==lt.body||JSON.stringify(os(Xe.images))!==JSON.stringify(lt.images)||(Xe.script??void 0)!==(lt.script??void 0)||JSON.stringify(Xe.inputs||[])!==JSON.stringify(lt.inputs||[])||JSON.stringify(Xe.outputs||[])!==JSON.stringify(lt.outputs||[])))return!0;let fn=i.map(Mt=>Mt.id===W?{...Mt,id:J,selected:!0,data:lt}:Mt),pn=l;if(J!==W){const Mt={...C.current},Pt={...Mt[W]||{}};delete Mt[W],Mt[J]=Pt,C.current=Mt,N(Mt),pn=l.map((rn,br)=>({...rn,source:rn.source===W?J:rn.source,target:rn.target===W?J:rn.target,id:`we-${rn.source===W?J:rn.source}-${rn.target===W?J:rn.target}-${br}`})),Ft(J)}return a(fn),u(pn),mo(J),!0},[l,Fe,i,Tt,u,a,mo,ce]);m.useEffect(()=>{if(!ce||!Fe||!Tt)return;const E=window.setTimeout(()=>{Ja(!1)},350);return()=>window.clearTimeout(E)},[Fe==null?void 0:Fe.label,Fe==null?void 0:Fe.role,Fe==null?void 0:Fe.model,Fe==null?void 0:Fe.body,JSON.stringify((Fe==null?void 0:Fe.images)||[]),Fe==null?void 0:Fe.script,JSON.stringify((Fe==null?void 0:Fe.inputs)||[]),JSON.stringify((Fe==null?void 0:Fe.outputs)||[]),Ja,Tt==null?void 0:Tt.id,ce]);const Xr=m.useMemo(()=>{const E=new Map(Oi.map(W=>[W.id,W]));return l.map(W=>{var Ae,lt,Qe,Xe;const Y=E.get(W.source),J=E.get(W.target),Q=/^output-(\d+)$/.exec(W.sourceHandle||""),se=/^input-(\d+)$/.exec(W.targetHandle||""),re=Y&&Q?(lt=(Ae=Y.data)==null?void 0:Ae.outputs)==null?void 0:lt[parseInt(Q[1],10)]:null,ae=J&&se?(Xe=(Qe=J.data)==null?void 0:Qe.inputs)==null?void 0:Xe[parseInt(se[1],10)]:null,be=re!=null&&re.type?Wn(re.type):ae!=null&&ae.type?Wn(ae.type):"";return be?{...W,style:{...W.style||{},stroke:be,strokeWidth:2},markerEnd:{type:ds.ArrowClosed,color:be}}:W})},[l,Oi]),yo=m.useMemo(()=>{const E=B.trim().toLowerCase(),W={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const Y of D)E&&![Y.id,Y.label,Y.displayName,Y.description].some(J=>String(J||"").toLowerCase().includes(E))||W[cd(Y)].push(Y);for(const Y of pc)W[Y].sort((J,Q)=>J.id.localeCompare(Q.id));return W},[D,B]),$i=m.useMemo(()=>{const E=nt.trim().toLowerCase();return D.filter(W=>!E||[W.id,W.label,W.displayName,W.description].some(Y=>String(Y||"").toLowerCase().includes(E))).sort((W,Y)=>{const J=pc.indexOf(cd(W)),Q=pc.indexOf(cd(Y));return J!==Q?J-Q:ud(W).localeCompare(ud(Y))}).slice(0,30)},[D,nt]),oi=m.useMemo(()=>{const E=nt.trim().toLowerCase();return T.filter(W=>!E||[W.id,W.version,W.displayName,W.name,W.description,...Array.isArray(W.tags)?W.tags:[]].some(Y=>String(Y||"").toLowerCase().includes(E))).sort((W,Y)=>String(W.displayName||W.name||W.id).localeCompare(String(Y.displayName||Y.name||Y.id))).slice(0,30)},[T,nt]);m.useEffect(()=>{qe(0)},[nt,ve,Ce]),m.useEffect(()=>{if(!ve)return;const E=window.setTimeout(()=>{var W;return(W=In.current)==null?void 0:W.focus()},0);return()=>window.clearTimeout(E)},[ve]);const Qa=m.useMemo(()=>{const E=qt.trim().toLowerCase();return E?aT(ue).filter(W=>W.path.toLowerCase().includes(E)):ue},[qt,ue]),Za=[...(we.cursor||[]).map(E=>({label:`Cursor · ${E.split(" - ")[0]}`,value:`cursor:${E.split(" - ")[0]}`})),...(we.opencode||[]).map(E=>({label:`OpenCode · ${E.split(" - ")[0]}`,value:`opencode:${E.split(" - ")[0]}`})),...(we.claudeCode||[]).map(E=>({label:`Claude · ${E.split(" - ")[0]}`,value:`claude-code:${E.split(" - ")[0]}`}))],Su=m.useMemo(()=>new Set(gr),[gr]),Di=m.useMemo(()=>{const E=new Map(Qt.map(se=>[se.key,se])),W=new Set,Y=new Set,J=ms.map(se=>{const re=Ta(se,Qt).map(ae=>E.get(ae)).filter(Boolean);for(const ae of re)W.add(ae.key),Y.add(String(ae.name||ae.id||ae.key||"").trim());return{...se,skills:re}}).filter(se=>se.skills.length>0),Q=Qt.filter(se=>{const re=String(se.name||se.id||se.key||"").trim();return!W.has(se.key)&&!Y.has(re)});return{groups:J,ungrouped:Q}},[ms,Qt]);m.useEffect(()=>{Gt(E=>{let W=!1;const Y=new Set(E);for(const J of Di.groups)Y.has(J.id)||(Y.add(J.id),W=!0);return W?Y:E})},[Di.groups]);const zn=m.useMemo(()=>{const E=i.filter(W=>W.selected);return E.length>0?E:gt?i.filter(W=>W.id===gt):[]},[i,gt]),Fi=m.useMemo(()=>zn.map(E=>E.id),[zn]),Nu=m.useMemo(()=>{const E=String((ht==null?void 0:ht.username)||(ht==null?void 0:ht.userId)||"").trim();return E?E.slice(0,1).toUpperCase():"?"},[ht]),ql=m.useMemo(()=>new Set(Fi),[Fi]),Yo=m.useMemo(()=>l.filter(E=>ql.has(E.source)&&ql.has(E.target)),[l,ql]),Yl=m.useMemo(()=>{const E=B.trim().toLowerCase();return E?T.filter(W=>[W.id,W.version,W.displayName,W.name,W.description,...Array.isArray(W.tags)?W.tags:[]].filter(Boolean).some(Y=>String(Y).toLowerCase().includes(E))):T},[T,B]),Go=m.useCallback((E,W)=>{const Y=String(E||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let J=`${Y}_${Date.now().toString(36)}`,Q=2;for(;W.has(J);)J=`${Y}_${Date.now().toString(36)}_${Q}`,Q+=1;return W.add(J),J},[]),el=m.useCallback((E,W)=>{var rn,br;if(!ce){ze("Readonly workspace");return}const Y=E!=null&&E.snippet&&typeof E.snippet=="object"?E.snippet:{},J=Y.instances&&typeof Y.instances=="object"?Y.instances:{},Q=Object.keys(J);if(Q.length===0)return;const se=new Set(f.current.map(ut=>ut.id)),re={};for(const ut of Q)re[ut]=Go(ut,se);const ae=(rn=Y.ui)!=null&&rn.nodePositions&&typeof Y.ui.nodePositions=="object"?Y.ui.nodePositions:{},be=(br=Y.ui)!=null&&br.nodeSizes&&typeof Y.ui.nodeSizes=="object"?Y.ui.nodeSizes:{},Ae=Q.map(ut=>{const ge=ae[ut];return{id:ut,x:typeof(ge==null?void 0:ge.x)=="number"?ge.x:0,y:typeof(ge==null?void 0:ge.y)=="number"?ge.y:0}}),lt=Math.min(...Ae.map(ut=>ut.x)),Qe=Math.min(...Ae.map(ut=>ut.y));let Xe=W||{x:360+f.current.length*24,y:180+f.current.length*18};if(!W){const ut=document.querySelector(".af-workspace-canvas .react-flow");if(ut){const ge=ut.getBoundingClientRect();Xe=n.screenToFlowPosition({x:ge.left+ge.width*.48,y:ge.top+ge.height*.32})}}const Ht={},fn={},pn={};for(const ut of Ae){const ge=re[ut.id];Ht[ge]={...J[ut.id]||{}},fn[ge]={x:Xe.x+(ut.x-lt),y:Xe.y+(ut.y-Qe)};const Ze=be[ut.id];typeof(Ze==null?void 0:Ze.width)=="number"&&typeof(Ze==null?void 0:Ze.height)=="number"&&(pn[ge]={width:Ze.width,height:Ze.height})}const wr=new Set(Q),Re=(Array.isArray(Y.edges)?Y.edges:[]).filter(ut=>wr.has(ut==null?void 0:ut.source)&&wr.has(ut==null?void 0:ut.target)).map(ut=>({source:re[ut.source],target:re[ut.target],sourceHandle:ut.sourceHandle??null,targetHandle:ut.targetHandle??null})),Mt=Vy({instances:Ht,edges:Re,ui:{nodePositions:fn,nodeSizes:pn}},D),Pt=Mt.nodes.map(ut=>({...ut,selected:!0}));C.current={...C.current,...Mt.instances},N(C.current),a(ut=>[...ut.map(ge=>({...ge,selected:!1})),...Pt]),u(ut=>[...ut.map(ge=>({...ge,selected:!1})),...Mt.edges]),ze(`已添加流程片段:${E.displayName||E.id}`)},[Go,D,n,u,a,ce]),pg=m.useCallback(()=>{var Y,J;if(zn.length<2){O("请先在 workspace 画布上选择至少两个节点。"),z("flows");return}const E=zn[0],W=zn.length===2?`${((Y=E.data)==null?void 0:Y.label)||E.id} 片段`:`${((J=E.data)==null?void 0:J.label)||E.id} 等 ${zn.length} 个节点`;U({name:W,id:W.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ye(""),G(!0),z("flows")},[zn]),vt=m.useCallback(async()=>{var Q,se;if(zn.length<2)return;const E=Z.name.trim();if(!E){ye("请填写片段名称。");return}const W={},Y={};for(const re of zn){W[re.id]={x:((Q=re.position)==null?void 0:Q.x)||0,y:((se=re.position)==null?void 0:se.y)||0};const ae=tT(re);ae&&(Y[re.id]=ae)}const J=Yo.map(re=>({source:re.source,target:re.target,sourceHandle:re.sourceHandle??null,targetHandle:re.targetHandle??null}));de(!0),ye("");try{const re=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Z.id,name:E,displayName:E,version:"1.0.0",description:Z.description,snippet:{instances:Rf(zn,C.current),edges:J,ui:{nodePositions:W,nodeSizes:Y}}})}),ae=await re.json().catch(()=>({}));if(!re.ok||ae.ok===!1)throw new Error(ae.error||"发布流程片段失败");G(!1),ze(`流程片段已发布:${ae.id||E}`),Ai(`流程片段已发布:${ae.id||E}`),await Bt(),z("flows")}catch(re){ye(String(re.message||re))}finally{de(!1)}},[Bt,Z,Yo,zn,Ai]),ju=m.useCallback(E=>{a(W=>W.map(Y=>Y.id===E?{...Y,selected:!1}:Y)),Ft(W=>W===E?"":W)},[readOnly,a]),Xo=m.useCallback(()=>{const E=$s.current;if(!E)return;const W=E.getBoundingClientRect(),Y=Math.min(420,Math.max(320,W.width+160)),J=12,Q=Math.max(180,W.top-J*2),se=Math.min(560,Q);ot({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-Y-12,W.left)),top:Math.max(J,W.top-se-J),width:Y,maxHeight:se,zIndex:1e4})},[]);m.useEffect(()=>{if(!Xn)return;Xo();const E=Y=>{var Q,se;const J=Y.target;(Q=$s.current)!=null&&Q.contains(J)||(se=Dn.current)!=null&&se.contains(J)||pt(!1)},W=Y=>{Y.key==="Escape"&&pt(!1)};return window.addEventListener("pointerdown",E),window.addEventListener("keydown",W),window.addEventListener("resize",Xo),window.addEventListener("scroll",Xo,!0),()=>{window.removeEventListener("pointerdown",E),window.removeEventListener("keydown",W),window.removeEventListener("resize",Xo),window.removeEventListener("scroll",Xo,!0)}},[Xn,Xo]);const Gl=m.useCallback(E=>{var J,Q;if(!ce){const se=(E||[]).filter(re=>(re==null?void 0:re.type)==="select");se.length>0&&a(re=>Zh(se,re));return}const W=new Map;for(const se of E||[])(se==null?void 0:se.type)==="dimensions"&&((J=se.dimensions)!=null&&J.width)&&((Q=se.dimensions)!=null&&Q.height)&&W.set(se.id,{width:Math.round(Number(se.dimensions.width)),height:Math.round(Number(se.dimensions.height))});const Y=Array.from(W.keys());if(a(se=>Zh(E,se).map(re=>{var be;const ae=W.get(re.id);return ae?Es((be=re.data)==null?void 0:be.definitionId)?{...re,width:ae.width,height:ae.height,data:{...re.data,nodeSize:ae,displaySize:ae}}:{...re,width:ae.width,height:ae.height,data:{...re.data,nodeSize:ae}}:re})),Y.length>0){const se=()=>Y.forEach(re=>r(re));window.requestAnimationFrame(se),window.setTimeout(se,80)}},[a,r,ce]),yt=m.useCallback(E=>{if(!ce){const W=(E||[]).filter(Y=>(Y==null?void 0:Y.type)==="select");W.length>0&&u(Y=>iv(W,Y));return}d(E)},[d,u,ce]),Jo=m.useCallback(()=>{const E=document.querySelector(".af-workspace-canvas .react-flow");if(E){const W=E.getBoundingClientRect();return n.screenToFlowPosition({x:W.left+W.width*.48,y:W.top+W.height*.32})}return{x:360+i.length*36,y:180+i.length*28}},[i.length,n]),zs=m.useCallback(()=>{var E,W,Y;if(Tt){const J=Number(((E=Tt.measured)==null?void 0:E.width)||Tt.width||260);return{x:Number(((W=Tt.position)==null?void 0:W.x)||0)+J+140,y:Number(((Y=Tt.position)==null?void 0:Y.y)||0)}}return Jo()},[Jo,Tt]),Bs=m.useCallback((E,W={})=>{if(!ce)return ze("Readonly workspace"),null;if(!E)return null;const Y=Tv(E)||E.id,J=ZI(E),Q=W.id||SK(Y,i),se=Hp(E.inputs),re=Hp(E.outputs),ae={definitionId:Y,...J?{marketplaceRef:J}:{},...E.packageId?{marketplacePackageId:E.packageId}:{},...E.version?{marketplaceVersion:E.version}:{},label:W.label||mm(E),role:"normal",body:W.body||"",input:W.inputs||se,output:W.outputs||re},be={id:Q,type:Lf,position:W.position||Jo(),data:{label:ae.label,definitionId:Y,...J?{marketplaceRef:J}:{},...E.packageId?{marketplacePackageId:E.packageId}:{},...E.version?{marketplaceVersion:E.version}:{},schemaType:QI(Y,E),role:"normal",body:ae.body,inputs:ae.input,outputs:ae.output}},Ae={...ff(be,{...C.current,[Q]:ae},D),selected:!0};return a(lt=>[...lt.map(Qe=>({...Qe,selected:!1})),Ae]),W.openProperties&&Ft(Q),Q},[Jo,i,D,a,ce]),Cu=m.useCallback(E=>_j(E,f.current),[]),Uv=m.useCallback(E=>{if(!ce){ze("Readonly workspace");return}if(!_j(E,f.current)){ze("端口类型不匹配,已取消连线");return}b(null),a(W=>dm(W,E)),u(W=>{const Y=W.filter(J=>!(J.target===E.target&&J.targetHandle===E.targetHandle));return rf({...E,markerEnd:{type:ds.ArrowClosed}},Y)})},[u,a,ce]),ai=m.useCallback((E,W)=>{ce&&(v.current=vK(W,f.current),b(null))},[ce]),hg=m.useCallback((E,W)=>{var Xe,Ht,fn,pn;if(!ce)return;const Y=v.current;if(v.current=null,!Y||W!=null&&W.toNode)return;const J=kK(D,Y);if(J.length===0){ze(`没有匹配 ${Y.slotType} 端口的节点`);return}const Q=((Ht=(Xe=E==null?void 0:E.changedTouches)==null?void 0:Xe[0])==null?void 0:Ht.clientX)??(E==null?void 0:E.clientX),se=((pn=(fn=E==null?void 0:E.changedTouches)==null?void 0:fn[0])==null?void 0:pn.clientY)??(E==null?void 0:E.clientY);if(!Number.isFinite(Q)||!Number.isFinite(se))return;const re=document.querySelector(".af-workspace-canvas .react-flow");if(!re)return;const ae=re.getBoundingClientRect(),be=320,Ae=Math.min(440,104+J.length*58),lt=Math.max(12,Math.min(Q-ae.left,ae.width-be-12)),Qe=Math.max(12,Math.min(se-ae.top,ae.height-Ae-12));b({left:lt,top:Qe,flowPosition:n.screenToFlowPosition({x:Q,y:se}),draft:Y,candidates:J,query:""})},[D,n,ce]),xo=m.useCallback(E=>{if(!ce){ze("Readonly workspace"),b(null);return}const W=k.current;if(!W||!(E!=null&&E.def))return;const Y=Bs(E.def,{position:W.flowPosition});if(!Y)return;const J=W.draft.handleType==="source"?{source:W.draft.nodeId,sourceHandle:W.draft.handleId,target:Y,targetHandle:`input-${E.slotIndex}`}:{source:Y,sourceHandle:`output-${E.slotIndex}`,target:W.draft.nodeId,targetHandle:W.draft.handleId};a(Q=>dm(Q,J)),u(Q=>{const se=Q.filter(re=>!(re.target===J.target&&re.targetHandle===J.targetHandle));return rf({...J,markerEnd:{type:ds.ArrowClosed}},se)}),b(null)},[Bs,u,ce]),Qo=m.useCallback(E=>{E&&(Bs(E,{position:zs()}),Pe(!1),Ue(""))},[Bs,zs]),Eu=m.useCallback(E=>{E&&(el(E,zs()),Pe(!1),Ue(""))},[el,zs]);m.useEffect(()=>{const E=W=>{if(W.defaultPrevented)return;const Y=MI(W.target)||wK(W.target);if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"){W.preventDefault(),ir().catch(re=>ze(String(re.message||re)));return}if(Ie){(W.key==="Escape"||pm(W))&&(W.preventDefault(),Ee(!1));return}if(Y)return;const J=W.key.toLowerCase(),Q=(W.metaKey||W.ctrlKey)&&!W.shiftKey&&J==="z",se=(W.metaKey||W.ctrlKey)&&(W.shiftKey&&J==="z"||J==="y");if(Q||se){if(!ce){W.preventDefault(),ze("Readonly workspace");return}W.preventDefault(),W.stopPropagation();const re=Q?Va():Hl();ze(re?Q?"Undo canvas change":"Redo canvas change":Q?"Nothing to undo":"Nothing to redo");return}if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="c"){const re=EI(f.current,c.current,C.current);re&&(W.preventDefault(),W.stopPropagation(),g.current=re,ze(`Copied ${re.nodes.length} node${re.nodes.length>1?"s":""}`));return}if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="v"){if(!ce){W.preventDefault(),ze("Readonly workspace");return}const re=_I(g.current,f.current,c.current,C.current);re&&(W.preventDefault(),W.stopPropagation(),C.current=re.instances,N(re.instances),a(re.nodes),u(re.edges),ze(`Pasted ${re.pastedNodeIds.length} node${re.pastedNodeIds.length>1?"s":""}`));return}if(pm(W)&&!W.metaKey&&!W.ctrlKey&&!W.altKey){W.preventDefault(),Ee(!0);return}if(W.key==="a"||W.key==="A"){if(W.metaKey||W.ctrlKey){W.preventDefault(),a(re=>re.map(ae=>({...ae,selected:!0}))),u(re=>re.map(ae=>({...ae,selected:!1})));return}if(W.altKey)return;if(!ce){W.preventDefault(),ze("Readonly workspace");return}W.preventDefault(),Pe(!0);return}if((W.key==="v"||W.key==="V")&&!W.metaKey&&!W.ctrlKey&&!W.altKey){W.preventDefault(),Ot("select");return}(W.key==="h"||W.key==="H")&&!W.metaKey&&!W.ctrlKey&&!W.altKey&&(W.preventDefault(),Ot("pan"))};return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[Hl,ir,Ie,u,a,Va,ce]);const mg=m.useCallback(E=>{nn(W=>{const Y=new Set(W);return Y.has(E)?Y.delete(E):Y.add(E),Y})},[]),Xl=m.useCallback((E,W)=>{E.dataTransfer.effectAllowed="copy",E.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:W.path,name:W.name,type:W.type})),E.dataTransfer.setData("text/plain",W.path)},[]),gg=m.useCallback((E,W)=>{E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("application/agentflow-node",W.id),E.dataTransfer.setData("text/plain",W.id)},[]),tl=m.useCallback(async(E,W)=>{const Y=String((E==null?void 0:E.name)||(E==null?void 0:E.path)||"").toLowerCase(),J=Y.split(".").pop(),Q=J==="html"?"display_html":J==="csv"||J==="tsv"||J==="json"&&/\b(table|data|rows|report)\b/i.test(Y)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(J)?"display_image":"display_markdown",se=D.find(Qe=>Qe.id===Q);if(!se){ze("展示节点不可用");return}const re=Q==="display_image";let ae=String(E.path||"");if(!re){const Qe=hl(s);Qe.set("path",E.path);const Xe=await fetch(`/api/workspace/file?${Qe.toString()}`),Ht=await Xe.json();if(!Xe.ok)throw new Error(Ht.error||"读取文件失败");ae=String(Ht.content||"")}const be=Q==="display_image"?"src":"content",Ae=Hp(se.inputs).map(Qe=>Qe.name===be?{...Qe,default:ae,value:ae}:Qe),lt=Hp(se.outputs).map(Qe=>Qe.name===be?{...Qe,default:ae,value:ae}:Qe);Bs(se,{label:E.name||"Display",body:ae,inputs:Ae,outputs:lt,position:W}),ze(`已创建展示:${E.path}`)},[Bs,s,D]),yg=m.useCallback(E=>{if(!ce){ze("Readonly workspace");return}tl(E,Jo()).catch(W=>ze(String(W.message||W)))},[tl,Jo,ce]),xg=m.useCallback(E=>{if(!ce){E.preventDefault(),ze("Readonly workspace");return}const W=E.dataTransfer.getData("application/x-agentflow-workspace-file");if(W){E.preventDefault();let re;try{re=JSON.parse(W)}catch{return}if(!(re!=null&&re.path))return;const ae=n.screenToFlowPosition({x:E.clientX,y:E.clientY});tl(re,ae).catch(be=>ze(String(be.message||be)));return}const Y=E.dataTransfer.getData("application/agentflow-snippet");if(Y){const re=T.find(be=>`${be.id}@${be.version}`===Y);if(!re)return;E.preventDefault();const ae=n.screenToFlowPosition({x:E.clientX,y:E.clientY});el(re,ae);return}const J=E.dataTransfer.getData("application/agentflow-node");if(!J)return;const Q=D.find(re=>re.id===J);if(!Q)return;E.preventDefault();const se=n.screenToFlowPosition({x:E.clientX,y:E.clientY});Bs(Q,{position:se})},[tl,Bs,T,el,D,n,ce]),wg=m.useCallback(E=>{if(!ce)return;const W=Array.from(E.dataTransfer.types||[]);!W.includes("application/x-agentflow-workspace-file")&&!W.includes("application/agentflow-node")&&!W.includes("application/agentflow-snippet")||(E.preventDefault(),E.dataTransfer.dropEffect=W.includes("application/agentflow-node")||W.includes("application/agentflow-snippet")?"move":"copy")},[ce]),nl=m.useCallback(async(E="")=>{if(!ce){ze("Readonly workspace");return}const W=window.prompt("新文件名",E?`${E}/notes.md`:"notes.md");if(!W)return;const Y=E&&!W.includes("/")?`${E}/${W}`:W;try{const J=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Y,content:""})}),Q=await J.json();if(!J.ok)throw new Error(Q.error||"创建文件失败");await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q.path||Y))re.delete(ae);return re}),ze(`已创建 ${Q.path}`)}catch(J){ze(String(J.message||J))}},[s,Zn,ce]),Jl=m.useCallback(async(E="")=>{if(!ce){ze("Readonly workspace");return}const W=window.prompt("新文件夹名",E?`${E}/docs`:"docs");if(!W)return;const Y=E&&!W.includes("/")?`${E}/${W}`:W;try{const J=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Y})}),Q=await J.json();if(!J.ok)throw new Error(Q.error||"创建文件夹失败");await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q.path||Y))re.delete(ae);return Q.path&&re.delete(Q.path),re}),ze(`已创建 ${Q.path}`)}catch(J){ze(String(J.message||J))}},[s,Zn,ce]),_u=m.useCallback(async E=>{if(!ce){ze("Readonly workspace");return}if(!(!(E!=null&&E.path)||!window.confirm(`删除 ${E.path}?`)))try{const W=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:E.path})}),Y=await W.json();if(!W.ok)throw new Error(Y.error||"删除失败");ze(`已删除 ${Y.path}`),await Zn()}catch(W){ze(String(W.message||W))}},[s,Zn,ce]),Pu=m.useCallback(async()=>{if(!ce){ze("Readonly workspace");return}const E=Vt.trim();if(!E||kn)return;const W=Wp(i,l,C.current);zt(""),Ye(!0),Ua("workspace"),Dr(Y=>[...Y,{role:"user",text:E,at:Date.now()}]);try{await ir(i,l);const Y=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,prompt:E,outputKind:"markdown",workspaceGraph:W,allowFlowYaml:!1,model:et,selectedSkills:gr,selectedNodeIds:Fi})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"生成失败");const Q=String(J.content||"").trim();Dr(se=>[...se,{role:"assistant",text:Q,at:Date.now()}]),await Fs(),ze("AI 生成完成")}catch(Y){const J=String(Y.message||Y);Dr(Q=>[...Q,{role:"assistant",text:J,error:!0,at:Date.now()}]),ze(J)}finally{Ye(!1)}},[et,kn,Vt,l,s,Fs,i,Ua,ir,Fi,gr,ce]),_r=go.find(E=>E.id===Ii)||null,bg=_r?Array.isArray(_r.messages)?_r.messages:[]:Jn,rl=_r?_r.status==="running":kn,zf=_r?_r.status==="running"?`${_r.label} running`:_r.status==="paused"?`${_r.label} paused`:_r.status==="failed"?`${_r.label} failed`:`${_r.label} done`:kn?"Workspace agent running":Jn.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>t("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:s.flowId?`${s.flowId} · ${me}`:me||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",mK,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(Hb({id:s.flowId,source:s.flowSource||"user",archived:!!s.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:si}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ee(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ti?" af-composer-topbar-btn--active":"")+(kn?" af-composer-topbar-btn--running":""),onClick:()=>Ds(E=>!E),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!ce,onClick:()=>ir().catch(E=>ze(String(E.message||E))),children:"Save"})]})]}),oe?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:oe}),o.jsx("button",{type:"button",onClick:()=>Se(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(ti||Fe?" af-workspace-body--drawer":"")+(V?" af-workspace-body--sidebar-collapsed":""),children:[V?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Pe(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>fe(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>fe(!1),"aria-label":"展开侧边栏",title:(ht==null?void 0:ht.username)||(ht==null?void 0:ht.userId)||"展开侧边栏",children:Nu})]})}):null,o.jsxs("aside",{ref:mr,className:"af-workspace-sidebar"+(Vn?" af-workspace-sidebar--resizing":""),"aria-hidden":V,style:{"--af-work-files-pane-height":`${Math.round(dn)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>fe(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!ce,onClick:()=>nl(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!ce,onClick:()=>Jl(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Zn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:qt,onChange:E=>qn(E.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(cT,{items:Qa,flowParams:s,onOpen:yg,collapsedDirs:vn,onToggleDir:mg,onCreateFile:nl,onCreateFolder:Jl,onDelete:_u,onFileDragStart:Xl})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:$n,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:A==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:B,onChange:E=>$(E.target.value),placeholder:A==="flows"?"搜索流程片段...":"搜索节点...","aria-label":A==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":A==="nodes",className:"af-palette-tab"+(A==="nodes"?" af-palette-tab--active":""),onClick:()=>z("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":A==="flows",className:"af-palette-tab"+(A==="flows"?" af-palette-tab--active":""),onClick:()=>z("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:A==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:pg,disabled:zn.length<2,title:zn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",zn.length," 节点 / ",Yo.length," 连线"]})]})}),P?o.jsx("p",{className:"af-err af-palette-list-err",children:P}):null,I?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Yl.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:Yl.map(E=>{const W=`${E.id}@${E.version}`,Y=E.displayName||E.name||E.id,J=E.description||`${E.nodeCount||0} 个节点,${E.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Q=>{Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/agentflow-snippet",W),Q.dataTransfer.setData("text/plain",W)},onClick:()=>el(E),title:J,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:Y}),o.jsxs("span",{className:"af-palette-card-id",children:[E.id,"@",E.version]})]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[E.nodeCount||0," nodes"]}),o.jsxs("span",{children:[E.edgeCount||0," edges"]})]})]},W)})})]}):o.jsx("p",{className:"af-palette-empty",children:B.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[pc.map(E=>{var W;return(W=yo[E])!=null&&W.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${E}`,children:[o.jsx("h3",{className:"af-palette-cat",children:E}),o.jsx("div",{className:"af-palette-cards",children:yo[E].map(Y=>{const J=Ej(Y.inputs,"input"),Q=Ej(Y.outputs,"output"),se=Fw(Y),re=ud(Y);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:ae=>gg(ae,Y),onClick:()=>Bs(Y),title:se||Y.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:jj(E)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:re}),re!==Y.id?o.jsx("span",{className:"af-palette-card-id",children:Y.id}):null]})]}),se?o.jsx("span",{className:"af-palette-card-desc",children:se}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[J.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[J.shown.map((ae,be)=>o.jsxs("span",{className:"af-palette-card-port",title:Cj("input",ae,be),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ae==null?void 0:ae.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Wy(ae,be)})]},`in-${be}`)),J.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",J.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((ae,be)=>o.jsxs("span",{className:"af-palette-card-port",title:Cj("output",ae,be),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Wy(ae,be)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ae==null?void 0:ae.type)}})]},`out-${be}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},Y.id)})})]},E):null}),D.length>0&&B.trim()&&pc.every(E=>{var W;return!((W=yo[E])!=null&&W.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(GP,{className:"af-flow-canvas af-workspace-flow"+(Ge==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),nodes:Oi,edges:Xr,nodeTypes:KK,onNodesChange:Gl,onEdgesChange:yt,onConnect:Uv,onConnectStart:ai,onConnectEnd:hg,isValidConnection:Cu,onNodeClick:(E,W)=>{gt&&Ft(W.id)},onNodeDoubleClick:(E,W)=>{E.preventDefault(),Ds(!1),a(Y=>Y.map(J=>({...J,selected:J.id===W.id}))),u(Y=>Y.map(J=>({...J,selected:!1}))),Ft(W.id)},onPaneClick:()=>Ft(""),onDrop:xg,onDragOver:wg,nodesDraggable:ce,nodesConnectable:ce,edgesReconnectable:ce,deleteKeyCode:ce?["Backspace","Delete"]:null,selectionOnDrag:Ge==="select",panOnDrag:Ge==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(ZP,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),y?(()=>{var J;const E=String(y.query||"").trim().toLowerCase(),W=E?y.candidates.filter(Q=>{var se,re,ae;return[(se=Q.def)==null?void 0:se.id,Q.displayLabel,Q.description,(re=Q.slot)==null?void 0:re.name,(ae=Q.slot)==null?void 0:ae.type].filter(Boolean).some(be=>String(be).toLowerCase().includes(E))}):y.candidates,Y=y.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:y.left,top:y.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Wn((J=y.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",y.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>b(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:y.query,onChange:Q=>b(se=>se&&{...se,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[W.map(Q=>{var ae,be;const se=Q.displayLabel||((ae=Q.def)==null?void 0:ae.id),re=Wy(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>xo(Q),title:Q.description||Q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:se}),se!==Q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:Y}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Wn((be=Q.slot)==null?void 0:be.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:re})]})]},`${Q.def.id}-${Q.slotIndex}`)}),W.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,ni?o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Zt(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Zt(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:zn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):zn.map(E=>{var Q,se;const W=String(((Q=E.data)==null?void 0:Q.label)??E.id),Y=(se=E.data)!=null&&se.definitionId?String(E.data.definitionId):"",J=Y&&Y!==W?`${W} · ${E.id} · ${Y}`:`${W} · ${E.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:J,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:Y||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:W}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>ju(E.id),"aria-label":`取消选择 ${E.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},E.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:Vt,rows:2,onChange:E=>zt(E.target.value),onKeyDown:E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),Pu())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!ce})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:$s,type:"button",className:"af-composer-skills-button"+(gr.length>0?" af-composer-skills-button--active":""),disabled:kn||!ce,"aria-haspopup":"listbox","aria-expanded":Xn,onClick:()=>pt(E=>!E),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:gr.length>0?`Skills ${gr.length}`:"Skills"})]}),Xn&&!kn?ns.createPortal(o.jsx("div",{ref:Dn,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:xs,children:Qt.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Di.groups.map(E=>{const W=Ta(E,Qt),Y=n_(E,Su,Qt),J=Te.has(E.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(J?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:Y==="all",disabled:W.length===0,onChange:Q=>{const se=Q.target.checked;Ms(re=>se?e_(re,W):t_(re,W))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:E.name}),E.builtin?o.jsx("em",{children:"built-in"}):null,Y==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":J?`展开 ${E.name}`:`收起 ${E.name}`,onClick:()=>{Gt(Q=>{const se=new Set(Q);return se.has(E.id)?se.delete(E.id):se.add(E.id),se})},children:[o.jsx("span",{children:E.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J?"expand_more":"expand_less"})]})]}),J?null:o.jsx("div",{className:"af-composer-skill-group-items",children:E.skills.map(Q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Su.has(Q.key),onChange:se=>{const re=se.target.checked;Ms(ae=>re?ae.includes(Q.key)?ae:[...ae,Q.key]:ae.filter(be=>be!==Q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${E.id}:${Q.key}`))})]},E.id)}),Di.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Di.ungrouped.length})]}),Di.ungrouped.map(E=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Su.has(E.key),onChange:W=>{const Y=W.target.checked;Ms(J=>Y?J.includes(E.key)?J:[...J,E.key]:J.filter(Q=>Q!==E.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:E.name}),E.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:E.description}):null]})]},`ungrouped:${E.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:et,onChange:E=>Lt(E.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),Za.map(E=>o.jsx("option",{value:E.value,children:E.label},E.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(Vt.trim()&&!kn?" af-composer-send--active":"")+(kn?" af-composer-send--stop":""),disabled:kn||!Vt.trim()||!ce,"aria-label":kn?"Running":"Send",onClick:()=>void Pu(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:kn?"sync":"arrow_upward"})})]})]})]})})]}),ti?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Ds(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Ii==="workspace"?" af-composer-session-tab--active":""),onClick:()=>ws("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),go.map(E=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Ii===E.id?" af-composer-session-tab--active":"")+(E.status==="running"?" af-composer-session-tab--running":""),onClick:()=>ws(E.id),title:E.runNodeId||E.label,children:o.jsx("span",{className:"af-composer-session-label",children:E.label})},E.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(rl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:zf}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(GK,{messages:bg,running:rl,showRunningIndicator:!_r})})]})}):Fe&&Tt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(HI,{draft:Fe,setDraft:tn,definitionId:String(((Au=Tt.data)==null?void 0:Au.definitionId)||Tt.id),systemPromptReadonly:String(((sl=Tt.data)==null?void 0:sl.description)||""),modelLists:we,disabled:!ce,onIdBlur:()=>Ja(!0),onClose:()=>Ft(""),onPublishToMarketplace:ur,error:Jt,ioSlots:{inputs:Array.isArray(Fe==null?void 0:Fe.inputs)?Fe.inputs:[],outputs:Array.isArray(Fe==null?void 0:Fe.outputs)?Fe.outputs:[]}})}):null,o.jsx($I,{open:Ie,onClose:()=>Ee(!1)}),_?ns.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>G(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Z.name,onChange:E=>{const W=E.target.value;U(Y=>({...Y,name:W,id:Y.id?Y.id:W.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Z.id,onChange:E=>U(W=>({...W,id:E.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Z.description,onChange:E=>U(W=>({...W,description:E.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",zn.length," 个节点和 ",Yo.length," 条内部连线。"]}),he?o.jsx("div",{className:"af-flow-snippet-error",children:he}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>G(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ie||!Z.name.trim(),onClick:()=>void vt(),children:ie?"发布中...":"发布"})]})]})}),document.body):null,ve?ns.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Pe(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="nodes",className:"af-workspace-quick-add__tab"+(Ce==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Je("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="flows",className:"af-workspace-quick-add__tab"+(Ce==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Je("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:In,value:nt,onChange:E=>Ue(E.target.value),onKeyDown:E=>{if(E.key==="Escape")E.preventDefault(),Pe(!1);else if(E.key==="ArrowDown"){E.preventDefault();const W=Ce==="flows"?oi.length:$i.length;qe(Y=>Math.min(Math.max(0,W-1),Y+1))}else E.key==="ArrowUp"?(E.preventDefault(),qe(W=>Math.max(0,W-1))):E.key==="Tab"?(E.preventDefault(),Je(W=>W==="nodes"?"flows":"nodes")):E.key==="Enter"&&(E.preventDefault(),Ce==="flows"?Eu(oi[_t]||oi[0]):Qo($i[_t]||$i[0]))},placeholder:Ce==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ce==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:Ce==="flows"?oi.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:I?"正在加载流程片段...":P||"没有匹配的流程片段"}):oi.map((E,W)=>{const Y=E.displayName||E.name||E.id,J=E.snippet&&typeof E.snippet=="object"?E.snippet.instances:null,Q=E.snippet&&typeof E.snippet=="object"?E.snippet.edges:null,se=Number.isFinite(Number(E.nodeCount))?Number(E.nodeCount):Object.keys(J||{}).length,re=Number.isFinite(Number(E.edgeCount))?Number(E.edgeCount):Array.isArray(Q)?Q.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(W===_t?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>qe(W),onClick:()=>Eu(E),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:Y}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[E.id,E.version?` · v${E.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:E.description||`${se} 节点 / ${re} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${E.id}@${E.version}`)}):$i.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):$i.map((E,W)=>{const Y=cd(E),J=ud(E),Q=Fw(E);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(W===_t?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>qe(W),onClick:()=>Qo(E),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:jj(Y)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:J}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:E.id}),Q?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:Y})]},E.id)})})]})}),document.body):null]})]})}function iq(){return o.jsx(av,{children:o.jsx(sq,{})})}const wt=e=>typeof e=="string",Ju=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},Ij=e=>e==null?"":""+e,oq=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},aq=/###/g,Tj=e=>e&&e.indexOf("###")>-1?e.replace(aq,"."):e,Rj=e=>!e||wt(e),Ad=(e,t,n)=>{const r=wt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Rj(e))return{};const i=Tj(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return Rj(e)?{}:{obj:e,k:Tj(r[s])}},Lj=(e,t,n)=>{const{obj:r,k:s}=Ad(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=Ad(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=Ad(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},lq=(e,t,n,r)=>{const{obj:s,k:i}=Ad(e,t,Object);s[i]=s[i]||[],s[i].push(n)},ym=(e,t)=>{const{obj:n,k:r}=Ad(e,t);if(n)return n[r]},cq=(e,t,n)=>{const r=ym(e,n);return r!==void 0?r:ym(t,n)},uT=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?wt(e[r])||e[r]instanceof String||wt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):uT(e[r],t[r],n):e[r]=t[r]);return e},uc=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var uq={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const dq=e=>wt(e)?e.replace(/[&<>"'\/]/g,t=>uq[t]):e;class fq{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const pq=[" ",",","?","!",";"],hq=new fq(20),mq=(e,t,n)=>{t=t||"",n=n||"";const r=pq.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=hq.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},zw=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let u=i;u<r.length;++u)if(u!==i&&(l+=n),l+=r[u],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&u<r.length-1)continue;i+=u-i+1;break}s=a}return s},xm=e=>e&&e.replace("_","-"),gq={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class wm{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||gq,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(wt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new wm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new wm(this.logger,t)}}var ro=new wm;class ag{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l.apply(l,[t,...r])})}}class Oj extends ag{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):wt(r)&&i?l.push(...r.split(i)):l.push(r)));const u=ym(this.data,l);return!u&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),u||!a||!wt(r)?u:zw(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),Lj(this.data,l,s),i.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const i in r)(wt(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let u=ym(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?uT(u,r,i):u={...u,...r},Lj(this.data,l,u),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var dT={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const Mj={};class bm extends ag{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),oq(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ro.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!mq(t,r,s);if(a&&!l){const u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:wt(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:wt(i)?[i]:i}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),u=l[l.length-1],d=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(f){const N=n.nsSeparator||this.options.nsSeparator;return s?{res:`${u}${N}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:`${u}${N}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:a}const c=this.resolve(t,n);let p=c&&c.res;const h=c&&c.usedKey||a,g=c&&c.exactUsedKey||a,v=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!wt(p)&&typeof p!="boolean"&&typeof p!="number";if(b&&p&&w&&k.indexOf(v)<0&&!(wt(y)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const N=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(c.res=N,c.usedParams=this.getUsedParamsDetails(n),c):N}if(i){const N=Array.isArray(p),C=N?[]:{},j=N?g:h;for(const R in p)if(Object.prototype.hasOwnProperty.call(p,R)){const D=`${j}${i}${R}`;C[R]=this.translate(D,{...n,joinArrays:!1,ns:l}),C[R]===D&&(C[R]=p[R])}p=C}}else if(b&&wt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let N=!1,C=!1;const j=n.count!==void 0&&!wt(n.count),R=bm.hasDefaultValue(n),D=j?this.pluralResolver.getSuffix(d,n.count,n):"",M=n.ordinal&&j?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",B=j&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),$=B&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${D}`]||n[`defaultValue${M}`]||n.defaultValue;!this.isValidLookup(p)&&R&&(N=!0,p=$),this.isValidLookup(p)||(C=!0,p=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:p,T=R&&$!==p&&this.options.updateMissing;if(C||N||T){if(this.logger.log(T?"updateKey":"missingKey",d,u,a,T?$:p),i){const P=this.resolve(a,{...n,keySeparator:!1});P&&P.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let L=[];const I=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&I&&I[0])for(let P=0;P<I.length;P++)L.push(I[P]);else this.options.saveMissingTo==="all"?L=this.languageUtils.toResolveHierarchy(n.lng||this.language):L.push(n.lng||this.language);const F=(P,O,_)=>{const G=R&&_!==p?_:z;this.options.missingKeyHandler?this.options.missingKeyHandler(P,u,O,G,T,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(P,u,O,G,T,n),this.emit("missingKey",P,u,O,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&j?L.forEach(P=>{const O=this.pluralResolver.getSuffixes(P,n);B&&n[`defaultValue${this.options.pluralSeparator}zero`]&&O.indexOf(`${this.options.pluralSeparator}zero`)<0&&O.push(`${this.options.pluralSeparator}zero`),O.forEach(_=>{F([P],a+_,n[`defaultValue${_}`]||$)})}):F(L,a,$))}p=this.extendTranslation(p,t,n,c,r),C&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${u}:${a}`),(C||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}:${a}`:a,N?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(c.res=p,c.usedParams=this.getUsedParamsDetails(n),c):p}extendTranslation(t,n,r,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=wt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(d){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let c=r.replace&&!wt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;f<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return i&&i[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,u=wt(l)?[l]:l;return t!=null&&u&&u.length&&r.applyPostProcessor!==!1&&(t=dT.handle(u,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,i,a,l;return wt(t)&&(t=[t]),t.forEach(u=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(u,n),f=d.key;s=f;let c=d.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const p=n.count!==void 0&&!wt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(wt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(k=>{this.isValidLookup(r)||(l=k,!Mj[`${v[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(Mj[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;a=y;const b=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(b,f,y,k,n);else{let N;p&&(N=this.pluralResolver.getSuffix(y,n.count,n));const C=`${this.options.pluralSeparator}zero`,j=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(b.push(f+N),n.ordinal&&N.indexOf(j)===0&&b.push(f+N.replace(j,this.options.pluralSeparator)),h&&b.push(f+C)),g){const R=`${f}${this.options.contextSeparator}${n.context}`;b.push(R),p&&(b.push(R+N),n.ordinal&&N.indexOf(j)===0&&b.push(R+N.replace(j,this.options.pluralSeparator)),h&&b.push(R+C))}}let w;for(;w=b.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,k,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!wt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const i of n)delete s[i]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Uy=e=>e.charAt(0).toUpperCase()+e.slice(1);class $j{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ro.create("languageUtils")}getScriptPartFromCode(t){if(t=xm(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=xm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(wt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Uy(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Uy(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Uy(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),wt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return wt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):wt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let yq=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],xq={1:e=>+(e>1),2:e=>+(e!=1),3:e=>0,4:e=>e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,5:e=>e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5,6:e=>e==1?0:e>=2&&e<=4?1:2,7:e=>e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,8:e=>e==1?0:e==2?1:e!=8&&e!=11?2:3,9:e=>+(e>=2),10:e=>e==1?0:e==2?1:e<7?2:e<11?3:4,11:e=>e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3,12:e=>+(e%10!=1||e%100==11),13:e=>+(e!==0),14:e=>e==1?0:e==2?1:e==3?2:3,15:e=>e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2,16:e=>e%10==1&&e%100!=11?0:e!==0?1:2,17:e=>e==1||e%10==1&&e%100!=11?0:1,18:e=>e==0?0:e==1?1:2,19:e=>e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3,20:e=>e==1?0:e==0||e%100>0&&e%100<20?1:2,21:e=>e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0,22:e=>e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3};const wq=["v1","v2","v3"],bq=["v4"],Dj={zero:0,one:1,two:2,few:3,many:4,other:5},vq=()=>{const e={};return yq.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:xq[t.fc]}})}),e};class kq{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=ro.create("pluralResolver"),(!this.options.compatibilityJSON||bq.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=vq(),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const r=xm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const u=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(u,n)}return this.pluralRulesCache[i]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,i)=>Dj[s]-Dj[i]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const i=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!wq.includes(this.options.compatibilityJSON)}}const Fj=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=cq(e,t,n);return!i&&s&&wt(n)&&(i=zw(e,n,r),i===void 0&&(i=zw(t,n,r))),i},Ky=e=>e.replace(/\$/g,"$$$$");class Sq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ro.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:i,prefixEscaped:a,suffix:l,suffixEscaped:u,formatSeparator:d,unescapeSuffix:f,unescapePrefix:c,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:dq,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?uc(i):a||"{{",this.suffix=l?uc(l):u||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?uc(p):h||uc("$t("),this.nestingSuffix=g?uc(g):v||uc(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let i,a,l;const u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const y=Fj(n,u,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:h}):y}const g=h.split(this.formatSeparator),v=g.shift().trim(),k=g.join(this.formatSeparator).trim();return this.format(Fj(n,u,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,c=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Ky(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ky(this.escape(h)):Ky(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const k=f(t,i,s);a=wt(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(c){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!wt(a)&&!this.useRawValueToEscape&&(a=Ij(a));const v=h.safeValue(a);if(t=t.replace(i[0],v),c?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=i[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(u,d)=>{const f=this.nestingOptionsSeparator;if(u.indexOf(f)<0)return u;const c=u.split(new RegExp(`${f}[ ]*{`));let p=`{${c[1]}`;u=c[0],p=this.interpolate(p,a);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,v),`${u}${f}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,u};for(;s=this.nestingRegexp.exec(t);){let u=[];a={...r},a=a.replace&&!wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const f=s[1].split(this.formatSeparator).map(c=>c.trim());s[1]=f.shift(),u=f,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!wt(i))return i;wt(i)||(i=Ij(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=u.reduce((f,c)=>this.format(f,c,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const Nq=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...u]=a.split(":"),d=u.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},dc=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(xm(r),s),t[a]=l),l(n)}};class jq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ro.create("formatter"),this.options=t,this.formats={number:dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:dc((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:dc((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:dc((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=dc(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(u=>u.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,u)=>{const{formatName:d,formatOptions:f}=Nq(u);if(this.formats[d]){let c=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;c=this.formats[d](l,h,{...f,...s,...p})}catch(p){this.logger.warn(p)}return c}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const Cq=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class Eq extends ag{constructor(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=ro.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const i={},a={},l={},u={};return t.forEach(d=>{let f=!0;n.forEach(c=>{const p=`${d}|${c}`;!r.reload&&this.store.hasResourceBundle(d,c)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),u[c]===void 0&&(u[c]=!0)))}),f||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(u)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(u=>{lq(u.loaded,[i],a),Cq(u,t),n&&u.errors.push(n),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(d=>{l[d]||(l[d]={});const f=u.loaded[d];f.length&&f.forEach(c=>{l[d][c]===void 0&&(l[d][c]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(u=>!u.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:i,callback:a});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const c=this.waitingReads.shift();this.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,f)},u=this.backend[r].bind(this.backend);if(u.length===2){try{const d=u(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return u(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();wt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),wt(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const u={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,r,s,u):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(c=>l(null,c)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,u)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const zj=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),wt(e[1])&&(t.defaultValue=e[1]),wt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Bj=e=>(wt(e.ns)&&(e.ns=[e.ns]),wt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),wt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Up=()=>{},_q=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class pf extends ag{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Bj(t),this.services={},this.logger=ro,this.modules={external:[]},_q(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(wt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=zj();this.options={...s,...this.options,...Bj(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const i=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?ro.init(i(this.modules.logger),this.options):ro.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=jq);const c=new $j(this.options);this.store=new Oj(this.options.resources,this.options);const p=this.services;p.logger=ro,p.resourceStore=this.store,p.languageUtils=c,p.pluralResolver=new kq(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Sq(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new Eq(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new bm(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Up),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const u=Ju(),d=()=>{const f=(c,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),u.resolve(p),r(c,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),u}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Up;const s=wt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>a(u)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Ju();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=Up),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&dT.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const s=Ju();this.emit("languageChanging",t);const i=u=>{this.language=u,this.languages=this.services.languageUtils.toResolveHierarchy(u),this.resolvedLanguage=void 0,this.setResolvedLanguage(u)},a=(u,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(u,function(){return r.t(...arguments)})},l=u=>{!t&&!u&&this.services.languageDetector&&(u=[]);const d=wt(u)?u:this.services.languageUtils.getBestMatchFromCodes(u);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let u;if(typeof l!="object"){for(var d=arguments.length,f=new Array(d>2?d-2:0),c=2;c<d;c++)f[c-2]=arguments[c];u=s.options.overloadTranslationOptionHandler([a,l].concat(f))}else u={...l};u.lng=u.lng||i.lng,u.lngs=u.lngs||i.lngs,u.ns=u.ns||i.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let h;return u.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${u.keyPrefix}${p}${g}`):h=u.keyPrefix?`${u.keyPrefix}${p}${a}`:a,s.t(h,u)};return wt(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=this.services.backendConnector.state[`${l}|${u}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Ju();return this.options.ns?(wt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Ju();wt(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new $j(zj());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new pf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Up;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new pf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new Oj(this.store.data,s),i.services.resourceStore=i.store),i.translator=new bm(i.services,s),i.translator.on("*",function(l){for(var u=arguments.length,d=new Array(u>1?u-1:0),f=1;f<u;f++)d[f-1]=arguments[f];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Cr=pf.createInstance();Cr.createInstance=pf.createInstance;Cr.createInstance;Cr.dir;Cr.init;Cr.loadResources;Cr.reloadResources;Cr.use;Cr.changeLanguage;Cr.getFixedT;Cr.t;Cr.exists;Cr.setDefaultNamespace;Cr.hasLoadedNamespace;Cr.loadNamespaces;Cr.loadLanguages;function Pq(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hf(e){"@babel/helpers - typeof";return hf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hf(e)}function Aq(e,t){if(hf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(hf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Iq(e){var t=Aq(e,"string");return hf(t)=="symbol"?t:t+""}function Tq(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Iq(r.key),r)}}function Rq(e,t,n){return t&&Tq(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var fT=[],Lq=fT.forEach,Oq=fT.slice;function Mq(e){return Lq.call(Oq.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var Hj=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,$q=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!Hj.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!Hj.test(s.path))throw new TypeError("option path is invalid");a+="; Path=".concat(s.path)}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(s.expires.toUTCString())}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite){var u=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(u){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},Wj={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=$q(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},Dq={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=Wj.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&Wj.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},Fq={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var u=i[a].substring(0,l);u===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Qu=null,Vj=function(){if(Qu!==null)return Qu;try{Qu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qu=!1}return Qu},zq={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&Vj()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&Vj()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Zu=null,Uj=function(){if(Zu!==null)return Zu;try{Zu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zu=!1}return Zu},Bq={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&Uj()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&Uj()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},Hq={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},Wq={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},Vq={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},Uq={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},pT=!1;try{document.cookie,pT=!0}catch{}var hT=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];pT||hT.splice(1,1);function Kq(){return{order:hT,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var mT=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Pq(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return Rq(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=Mq(r,this.options||{},Kq()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(Dq),this.addDetector(Fq),this.addDetector(zq),this.addDetector(Bq),this.addDetector(Hq),this.addDetector(Wq),this.addDetector(Vq),this.addDetector(Uq)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();mT.type="languageDetector";const qq={name:"AgentFlow",tagline:"AI Workflow Orchestration"},Yq={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},Gq={loading:"Loading...",saving:"Saving...",save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",create:"Create",close:"Close",confirm:"Confirm",copy:"Copy",copied:"Copied!",refresh:"Refresh",search:"Search",filter:"Filter",success:"Success",error:"Error",warning:"Warning",info:"Info",done:"Done",pending:"Pending",running:"Running",notFound:"Not found",required:"Required",optional:"Optional"},Xq={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},Jq={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},Qq={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},Zq={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},eY={app:qq,nav:Yq,common:Gq,status:Xq,nodeTypes:Jq,engine:Qq,links:Zq},tY="Flow Editor",nY="Nodes",rY="Edges",sY="Properties",iY={label:"Node Label",type:"Node Type",model:"Model",body:"Body",inputs:"Inputs",outputs:"Outputs",addInput:"Add Input",addOutput:"Add Output",remove:"Remove Node",duplicate:"Duplicate Node",nodeType:"Node Type",displayName:"Display Name",displayNameHint:"(letters, numbers, underscores, hyphens, do not start with a number)",role:"Role",modelHint:"From ~/agentflow/model-lists.json; UI service runs agentflow update-model-lists in background on startup",defaultModel:"Default",userPrompt:"User Prompt (USER PROMPT / body)",systemDescription:"System Description (read-only, from node definition)",directCommand:"Direct Command (script)",scriptHint:"(tool_nodejs: skips AI when script exists, executed by pipeline)",diskRunning:"Disk record shows running",deleteNode:"Delete node",inputTooltip:"Input {{name}} | Type: {{type}}",outputTooltip:"Output {{name}} | Type: {{type}}",defaultSuffix:" | Default: {{value}}",fallbackLabel:"Node",expandProvide:"Edit content"},oY={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},aY={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},lY={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},cY={workspace:"Workspace",loading:"Loading...",archived:"Archived",noPipelines:"No pipelines",more:"more",moreFlows:"more flows",noRuns:"No run records",searchNodes:"Search nodes",noComponents:"No components available (check node library directory)",noMatch:"No matching nodes, adjust search terms",selectPipeline:"Select a pipeline from above to load components and canvas",validationWarnings:"Validation warnings (consistent with agentflow validate slot checks)",output:"Output",model:"Model",userDir:"User Directory",toggleRecentActivity:"Toggle recent opened or recent runs"},uY={selectPipeline:"Please select a pipeline from the dropdown above",loadingProps:"Loading node properties...",pipelineId:"Pipeline ID",diskPath:"Disk Path",storageLocation:"Storage Location",introduction:"Introduction",introductionPlaceholder:"Briefly describe this pipeline (saved as flow.yaml ui.description)",metadata:"Metadata",nodeCount:"Node Count",nodesUnit:"nodes",loading:"Loading...",noRuns:"No run records (run records are generated in the workspace after terminal execution)"},dY={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},fY={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},pY={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},hY={node:"Node",text:"Text",file:"File",bool:"Boolean"},mY={title:"Node Execution Context",resizeHandle:"Drag to resize node context width",apiConnectError:"Cannot connect to API (please open the page with agentflow ui, or configure /api proxy for Vite dev)",invalidJson:"Response is not valid JSON",requestTimeout:"Request timed out, please retry or check agentflow ui",executingNoArtifacts:"Executing, artifacts not yet written to workspace…",noData:"No data (this run has not reached this node or produced artifacts)",latest:"Latest",detectedContentType:"Detected content type",roundNoContent:"No content in this round",empty:"(empty)",imageTruncated:"Image truncated (exceeds size limit)",statusSuccess:"Success",statusFailed:"Failed",statusRunning:"Running",statusCacheMiss:"Cache miss",statusPending:"Pending"},gY={title:"Keyboard Shortcuts",general:"General",saveDesc:"Save; when node properties sidebar is open, submit node first then save flow",shortcutsLabel:"Keyboard Shortcuts",jumpToNode:"Jump to node by ID",openNodePalette:"Open node palette",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},yY={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},xY={title:"Start Building Your Flow",text:"Describe your workflow in the AI input box below, or drag nodes from the left panel to the canvas",composerHint:"Build AgentFlow with AI Composer",composerSub:"Drag nodes from the left panel, or describe your workflow in the <strong>input box below</strong>.<br/>Press <kbd>?</kbd> to view shortcuts."},wY={mainNav:"Main Navigation"},bY={flowWarningAriaLabel:"Flow validation warnings",reloadFromServer:"Reload flow from server and refresh validation",reloadFromServerShort:"Reload from server",closeBanner:"Close validation warning banner",nodePrefix:"Node",focusNodeAriaLabel:"Select and focus node {{nodeId}} on canvas",slotWarningCount:"Slot validation: {{count}} warnings (hidden)",show:"Show",shortcutHint:"Press ? to view keyboard shortcuts",shortcutHintLabel:"shortcuts",inputSlotNoEdge:' input slot "{{slotName}}" ({{handle}}) has no edge connection',outputSlotNoEdge:' output slot "{{slotName}}" ({{handle}}) has no edge connection'},vY={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
159
+ ${ae.trim()}`:ae,lt=re==="image"?"src":"content",Qe=Re=>{let Mt=!1;return(Array.isArray(Re)?Re:[]).map(rn=>{const br=String((rn==null?void 0:rn.name)||""),ut=String((rn==null?void 0:rn.type)||"");return!Mt&&(br===lt||br==="filePath"||ut==="text")?(Mt=!0,{...rn,default:Ae,value:Ae}):rn})},Xe=f.current.map(Re=>{var Mt,Pt;return Re.id!==Q?Re:{...Re,data:{...Re.data,body:Ae,inputs:Qe((Mt=Re.data)==null?void 0:Mt.inputs),outputs:Qe((Pt=Re.data)==null?void 0:Pt.outputs)}}}),Ht=C.current||{},fn=Ht[Q]&&typeof Ht[Q]=="object"?Ht[Q]:{},pn={...Ht,[Q]:{...fn,body:Ae,input:Qe(fn.input),output:Qe(fn.output)}};C.current=pn,a(Xe),N(pn),tn(Re=>(Re==null?void 0:Re.id)===Q?{...Re,body:Ae}:Re),(J==null?void 0:J.logChat)!==!1&&xr(Re=>{var Mt;return{...Re,[Q]:{...Re[Q]||{},candidateContent:"",messages:[...(Mt=Re[Q])!=null&&Mt.messages&&Array.isArray(Re[Q].messages)?Re[Q].messages:[],{role:"assistant",text:Y==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),ir(Xe,c.current).catch(Re=>ze(String(Re.message||Re))),ze(String((J==null?void 0:J.statusMessage)||"")||(Y==="append"?"已追加节点内容":"已替换节点内容"))},[ir,a,ce]),Gr=m.useCallback(async E=>{if(!ce)return ze("Readonly workspace"),"";if(!hm(E))return ze("请选择图片文件"),"";try{const W=new FormData;W.set("file",E),W.set("dir","img"),s.flowId&&W.set("flowId",s.flowId),s.flowSource&&W.set("flowSource",s.flowSource),s.archived&&W.set("archived","1");const Y=await fetch("/api/workspace/upload",{method:"POST",body:W}),J=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(J.error||"上传图片失败");const Q=String(J.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q))re.delete(ae);return re}),ze(`已上传图片 ${Q}`),Q}catch(W){return ze(String(W.message||W)),""}},[s,Zn,ce]),Vl=m.useCallback(async(E,W)=>{const Y=String(E||"").trim();if(!Y)return;const J=await Gr(W);J&&Ko(Y,J,"replace",{logChat:!1,statusMessage:`已上传图片 ${J}`})},[Ko,Gr]),vu=m.useCallback((E,W="replace")=>{var Q;const Y=String(E||"").trim(),J=String(((Q=Er[Y])==null?void 0:Q.candidateContent)||"").trim();!Y||!J||Ko(Y,J,W)},[Er,Ko]),qo=m.useCallback(async(E,W=void 0)=>{var Ae,lt,Qe;if(!ce){ze("Readonly workspace");return}const Y=String(E||"").trim();if(!Y)return;const J=Er[Y]||{},Q=String(W!==void 0?W:J.draft||"").trim();if(!Q||J.running)return;const se=f.current.find(Xe=>Xe.id===Y);if(!se)return;const re={role:"user",text:Q,at:Date.now()},ae=Array.isArray(J.messages)?J.messages:[],be=J.sessionId||`nodechat_${Date.now()}_${Y.replace(/[^a-z0-9_-]+/gi,"_")}`;xr(Xe=>({...Xe,[Y]:{...J,sessionId:be,messages:[...ae,re],draft:"",running:!0,error:""}}));try{const Xe=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:be,node:{id:Y,label:((Ae=se.data)==null?void 0:Ae.label)||Y,definitionId:((lt=se.data)==null?void 0:lt.definitionId)||""},nodeKind:Es((Qe=se.data)==null?void 0:Qe.definitionId)||"markdown",currentContent:Pd(se.data),messages:ae,message:Q,model:et})}),Ht=await Xe.json().catch(()=>({}));if(!Xe.ok)throw new Error(Ht.error||"节点微调失败");const fn=String(Ht.candidateContent||Ht.reply||"").trim();xr(pn=>{var wr;return{...pn,[Y]:{...pn[Y]||{},sessionId:String(Ht.sessionId||be),running:!1,candidateContent:fn,messages:[...(wr=pn[Y])!=null&&wr.messages&&Array.isArray(pn[Y].messages)?pn[Y].messages:[...ae,re],{role:"assistant",text:fn||"已生成候选内容。",at:Date.now()}]}}})}catch(Xe){const Ht=String(Xe.message||Xe);xr(fn=>({...fn,[Y]:{...fn[Y]||{},running:!1,error:Ht}})),ze(Ht)}},[et,s,Er,ce]),Ul=m.useCallback(async(E,W)=>{if(!ce){ze("Readonly workspace");return}const Y=Pd(W);if(!String(Y||"").trim()){ze("展示节点没有可保存内容");return}const J=HK(E,W),Q=window.prompt("保存到 workspace 相对路径",J);if(Q)try{const se=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Q,content:Y})}),re=await se.json().catch(()=>({}));if(!se.ok)throw new Error(re.error||"保存文件失败");const ae=re.path||Q,be=hl(s);be.set("path",ae);const Ae=await fetch(`/api/workspace/file?${be.toString()}`);if(!Ae.ok){const lt=await Ae.json().catch(()=>({}));throw new Error(lt.error||`保存后读取失败:${ae}`)}await Zn(),ee(lt=>YK(lt,ae,String(Y||"").length)),nn(lt=>{const Qe=new Set(lt);for(const Xe of Vp(ae))Qe.delete(Xe);return Qe}),ze(`已保存 ${ae}`)}catch(se){ze(String(se.message||se))}},[s,Zn,ce]),ku=m.useCallback((E,W)=>{const Y=String(E||"");Y&&tn(J=>{if(!J||J.id!==Y)return J;const Q=typeof W=="function"?W(J):W;return!Q||typeof Q!="object"?J:{...J,...Q}})},[]),Oi=m.useMemo(()=>i.map(E=>{var W,Y;return{...E,data:{...E.data,selected:E.selected===!0,modelLists:we,showBodyPreview:!0,isExecuting:Qn.has(E.id),nodeStatus:((W=zl[E.id])==null?void 0:W.status)??null,nodeElapsed:((Y=zl[E.id])==null?void 0:Y.elapsed)??null,flowParams:s,readOnly:!ce,onRunWorkspaceNode:Ka,onStopWorkspaceNode:Uo,runningRunNodeId:Tn,skills:Qt,skillCollections:ms,onChangeLoadSkillKeys:Ya,onRefreshSkills:qa,mcpServers:Gn,onChangeLoadMcpNames:Ga,onRefreshMcps:Li,onSaveDisplayNodeToFile:Ul,onUploadWorkspaceImage:Gr,onUploadImageToDisplayNode:Vl,nodeChatActive:bs===E.id,nodeChat:Er[E.id]||null,onSetDisplayNodeContent:Ko,onToggleNodeChat:Wl,onCloseNodeChat:()=>ri(""),onUpdateNodeChatDraft:Xa,onSendNodeChat:qo,onApplyNodeChatCandidate:vu,onSyncNodePropDraft:ku}}}),[bs,vu,Ga,Ya,s,Gn,we,Er,i,Li,qa,Ka,Tn,Ul,qo,Ko,ms,Qt,Uo,ku,Wl,Xa,Vl,Gr,Qn,zl,ce]);m.useEffect(()=>{const E=h.current,W=new Map,Y=[];for(const re of Oi){const ae=jK(re);W.set(re.id,ae),E.get(re.id)!==ae&&Y.push(re.id)}if(h.current=W,Y.length===0)return;const J=()=>Y.forEach(re=>r(re)),Q=window.requestAnimationFrame(J),se=window.setTimeout(J,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(se)}},[Oi,r]);const Tt=m.useMemo(()=>i.find(E=>E.id===gt)||null,[i,gt]),Mi=m.useRef({id:"",draft:null}),Kl=m.useMemo(()=>{const E=Aj(Tt);return E?JSON.stringify(E):""},[Tt]);m.useEffect(()=>{if(!Tt){Mi.current={id:"",draft:null},tn(null),bn("");return}const E=Aj(Tt),W=Mi.current;Mi.current={id:Tt.id,draft:E},tn(Y=>!Y||Y.id!==Tt.id||W.id!==Tt.id||!W.draft?E:tq(Y,W.draft,E)),bn("")},[Tt==null?void 0:Tt.id,Kl]);const Ja=m.useCallback((E=!1)=>{var wr,Re;if(!Fe||!Tt)return!1;if(!ce)return bn("Readonly workspace"),ze("Readonly workspace"),!1;const W=Tt.id,Y=String(Fe.newId||"").trim(),J=E?Y:W;if(bn(""),E){if(!BI.test(J))return bn("Invalid instance id"),!1;if(i.some(Mt=>Mt.id===J&&Mt.id!==W))return bn("Duplicate instance id"),!1}const Q=String(Fe.role||"").trim(),se=La.includes(Q)?Q:"normal",re=String(Fe.model||"").trim(),ae=Mt=>(Array.isArray(Mt)?Mt:[]).map(Pt=>({type:String((Pt==null?void 0:Pt.type)??"node").trim()||"node",name:String((Pt==null?void 0:Pt.name)??""),default:String((Pt==null?void 0:Pt.default)??""),required:!!(Pt!=null&&Pt.required),showOnNode:(Pt==null?void 0:Pt.showOnNode)!=null?Pt.showOnNode!==!1:!!(Pt!=null&&Pt.required)||String((Pt==null?void 0:Pt.type)??"node").trim().toLowerCase()==="node"})),be=String(((wr=Tt.data)==null?void 0:wr.definitionId)??J),Ae=be.startsWith("provide_"),lt={...Tt.data,label:String(Fe.label||"").trim()||J,role:se,model:re===""||re==="default"?void 0:re,body:Ae?"":String(Fe.body??""),images:Ae?[]:os(Fe.images),inputs:ae(Fe.inputs),outputs:Ae&&Array.isArray((Re=Tt.data)==null?void 0:Re.outputs)?Tt.data.outputs:ae(Fe.outputs)},Qe=String(Fe.script??"").trim();be==="tool_nodejs"||Qe!==""?lt.script=String(Fe.script??""):delete lt.script;const Xe=Tt.data||{};if(!(J!==W||Xe.label!==lt.label||Xe.role!==lt.role||Xe.model!==lt.model||Xe.body!==lt.body||JSON.stringify(os(Xe.images))!==JSON.stringify(lt.images)||(Xe.script??void 0)!==(lt.script??void 0)||JSON.stringify(Xe.inputs||[])!==JSON.stringify(lt.inputs||[])||JSON.stringify(Xe.outputs||[])!==JSON.stringify(lt.outputs||[])))return!0;let fn=i.map(Mt=>Mt.id===W?{...Mt,id:J,selected:!0,data:lt}:Mt),pn=l;if(J!==W){const Mt={...C.current},Pt={...Mt[W]||{}};delete Mt[W],Mt[J]=Pt,C.current=Mt,N(Mt),pn=l.map((rn,br)=>({...rn,source:rn.source===W?J:rn.source,target:rn.target===W?J:rn.target,id:`we-${rn.source===W?J:rn.source}-${rn.target===W?J:rn.target}-${br}`})),Ft(J)}return a(fn),u(pn),mo(J),!0},[l,Fe,i,Tt,u,a,mo,ce]);m.useEffect(()=>{if(!ce||!Fe||!Tt)return;const E=window.setTimeout(()=>{Ja(!1)},350);return()=>window.clearTimeout(E)},[Fe==null?void 0:Fe.label,Fe==null?void 0:Fe.role,Fe==null?void 0:Fe.model,Fe==null?void 0:Fe.body,JSON.stringify((Fe==null?void 0:Fe.images)||[]),Fe==null?void 0:Fe.script,JSON.stringify((Fe==null?void 0:Fe.inputs)||[]),JSON.stringify((Fe==null?void 0:Fe.outputs)||[]),Ja,Tt==null?void 0:Tt.id,ce]);const Xr=m.useMemo(()=>{const E=new Map(Oi.map(W=>[W.id,W]));return l.map(W=>{var Ae,lt,Qe,Xe;const Y=E.get(W.source),J=E.get(W.target),Q=/^output-(\d+)$/.exec(W.sourceHandle||""),se=/^input-(\d+)$/.exec(W.targetHandle||""),re=Y&&Q?(lt=(Ae=Y.data)==null?void 0:Ae.outputs)==null?void 0:lt[parseInt(Q[1],10)]:null,ae=J&&se?(Xe=(Qe=J.data)==null?void 0:Qe.inputs)==null?void 0:Xe[parseInt(se[1],10)]:null,be=re!=null&&re.type?Wn(re.type):ae!=null&&ae.type?Wn(ae.type):"";return be?{...W,style:{...W.style||{},stroke:be,strokeWidth:2},markerEnd:{type:ds.ArrowClosed,color:be}}:W})},[l,Oi]),yo=m.useMemo(()=>{const E=B.trim().toLowerCase(),W={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const Y of D)E&&![Y.id,Y.label,Y.displayName,Y.description].some(J=>String(J||"").toLowerCase().includes(E))||W[cd(Y)].push(Y);for(const Y of pc)W[Y].sort((J,Q)=>J.id.localeCompare(Q.id));return W},[D,B]),$i=m.useMemo(()=>{const E=nt.trim().toLowerCase();return D.filter(W=>!E||[W.id,W.label,W.displayName,W.description].some(Y=>String(Y||"").toLowerCase().includes(E))).sort((W,Y)=>{const J=pc.indexOf(cd(W)),Q=pc.indexOf(cd(Y));return J!==Q?J-Q:ud(W).localeCompare(ud(Y))}).slice(0,30)},[D,nt]),oi=m.useMemo(()=>{const E=nt.trim().toLowerCase();return T.filter(W=>!E||[W.id,W.version,W.displayName,W.name,W.description,...Array.isArray(W.tags)?W.tags:[]].some(Y=>String(Y||"").toLowerCase().includes(E))).sort((W,Y)=>String(W.displayName||W.name||W.id).localeCompare(String(Y.displayName||Y.name||Y.id))).slice(0,30)},[T,nt]);m.useEffect(()=>{qe(0)},[nt,ve,Ce]),m.useEffect(()=>{if(!ve)return;const E=window.setTimeout(()=>{var W;return(W=In.current)==null?void 0:W.focus()},0);return()=>window.clearTimeout(E)},[ve]);const Qa=m.useMemo(()=>{const E=qt.trim().toLowerCase();return E?aT(ue).filter(W=>W.path.toLowerCase().includes(E)):ue},[qt,ue]),Za=[...(we.cursor||[]).map(E=>({label:`Cursor · ${E.split(" - ")[0]}`,value:`cursor:${E.split(" - ")[0]}`})),...(we.opencode||[]).map(E=>({label:`OpenCode · ${E.split(" - ")[0]}`,value:`opencode:${E.split(" - ")[0]}`})),...(we.claudeCode||[]).map(E=>({label:`Claude · ${E.split(" - ")[0]}`,value:`claude-code:${E.split(" - ")[0]}`}))],Su=m.useMemo(()=>new Set(gr),[gr]),Di=m.useMemo(()=>{const E=new Map(Qt.map(se=>[se.key,se])),W=new Set,Y=new Set,J=ms.map(se=>{const re=Ta(se,Qt).map(ae=>E.get(ae)).filter(Boolean);for(const ae of re)W.add(ae.key),Y.add(String(ae.name||ae.id||ae.key||"").trim());return{...se,skills:re}}).filter(se=>se.skills.length>0),Q=Qt.filter(se=>{const re=String(se.name||se.id||se.key||"").trim();return!W.has(se.key)&&!Y.has(re)});return{groups:J,ungrouped:Q}},[ms,Qt]);m.useEffect(()=>{Gt(E=>{let W=!1;const Y=new Set(E);for(const J of Di.groups)Y.has(J.id)||(Y.add(J.id),W=!0);return W?Y:E})},[Di.groups]);const zn=m.useMemo(()=>{const E=i.filter(W=>W.selected);return E.length>0?E:gt?i.filter(W=>W.id===gt):[]},[i,gt]),Fi=m.useMemo(()=>zn.map(E=>E.id),[zn]),Nu=m.useMemo(()=>{const E=String((ht==null?void 0:ht.username)||(ht==null?void 0:ht.userId)||"").trim();return E?E.slice(0,1).toUpperCase():"?"},[ht]),ql=m.useMemo(()=>new Set(Fi),[Fi]),Yo=m.useMemo(()=>l.filter(E=>ql.has(E.source)&&ql.has(E.target)),[l,ql]),Yl=m.useMemo(()=>{const E=B.trim().toLowerCase();return E?T.filter(W=>[W.id,W.version,W.displayName,W.name,W.description,...Array.isArray(W.tags)?W.tags:[]].filter(Boolean).some(Y=>String(Y).toLowerCase().includes(E))):T},[T,B]),Go=m.useCallback((E,W)=>{const Y=String(E||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let J=`${Y}_${Date.now().toString(36)}`,Q=2;for(;W.has(J);)J=`${Y}_${Date.now().toString(36)}_${Q}`,Q+=1;return W.add(J),J},[]),el=m.useCallback((E,W)=>{var rn,br;if(!ce){ze("Readonly workspace");return}const Y=E!=null&&E.snippet&&typeof E.snippet=="object"?E.snippet:{},J=Y.instances&&typeof Y.instances=="object"?Y.instances:{},Q=Object.keys(J);if(Q.length===0)return;const se=new Set(f.current.map(ut=>ut.id)),re={};for(const ut of Q)re[ut]=Go(ut,se);const ae=(rn=Y.ui)!=null&&rn.nodePositions&&typeof Y.ui.nodePositions=="object"?Y.ui.nodePositions:{},be=(br=Y.ui)!=null&&br.nodeSizes&&typeof Y.ui.nodeSizes=="object"?Y.ui.nodeSizes:{},Ae=Q.map(ut=>{const ge=ae[ut];return{id:ut,x:typeof(ge==null?void 0:ge.x)=="number"?ge.x:0,y:typeof(ge==null?void 0:ge.y)=="number"?ge.y:0}}),lt=Math.min(...Ae.map(ut=>ut.x)),Qe=Math.min(...Ae.map(ut=>ut.y));let Xe=W||{x:360+f.current.length*24,y:180+f.current.length*18};if(!W){const ut=document.querySelector(".af-workspace-canvas .react-flow");if(ut){const ge=ut.getBoundingClientRect();Xe=n.screenToFlowPosition({x:ge.left+ge.width*.48,y:ge.top+ge.height*.32})}}const Ht={},fn={},pn={};for(const ut of Ae){const ge=re[ut.id];Ht[ge]={...J[ut.id]||{}},fn[ge]={x:Xe.x+(ut.x-lt),y:Xe.y+(ut.y-Qe)};const Ze=be[ut.id];typeof(Ze==null?void 0:Ze.width)=="number"&&typeof(Ze==null?void 0:Ze.height)=="number"&&(pn[ge]={width:Ze.width,height:Ze.height})}const wr=new Set(Q),Re=(Array.isArray(Y.edges)?Y.edges:[]).filter(ut=>wr.has(ut==null?void 0:ut.source)&&wr.has(ut==null?void 0:ut.target)).map(ut=>({source:re[ut.source],target:re[ut.target],sourceHandle:ut.sourceHandle??null,targetHandle:ut.targetHandle??null})),Mt=Vy({instances:Ht,edges:Re,ui:{nodePositions:fn,nodeSizes:pn}},D),Pt=Mt.nodes.map(ut=>({...ut,selected:!0}));C.current={...C.current,...Mt.instances},N(C.current),a(ut=>[...ut.map(ge=>({...ge,selected:!1})),...Pt]),u(ut=>[...ut.map(ge=>({...ge,selected:!1})),...Mt.edges]),ze(`已添加流程片段:${E.displayName||E.id}`)},[Go,D,n,u,a,ce]),pg=m.useCallback(()=>{var Y,J;if(zn.length<2){O("请先在 workspace 画布上选择至少两个节点。"),z("flows");return}const E=zn[0],W=zn.length===2?`${((Y=E.data)==null?void 0:Y.label)||E.id} 片段`:`${((J=E.data)==null?void 0:J.label)||E.id} 等 ${zn.length} 个节点`;U({name:W,id:W.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ye(""),G(!0),z("flows")},[zn]),vt=m.useCallback(async()=>{var Q,se;if(zn.length<2)return;const E=Z.name.trim();if(!E){ye("请填写片段名称。");return}const W={},Y={};for(const re of zn){W[re.id]={x:((Q=re.position)==null?void 0:Q.x)||0,y:((se=re.position)==null?void 0:se.y)||0};const ae=tT(re);ae&&(Y[re.id]=ae)}const J=Yo.map(re=>({source:re.source,target:re.target,sourceHandle:re.sourceHandle??null,targetHandle:re.targetHandle??null}));de(!0),ye("");try{const re=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Z.id,name:E,displayName:E,version:"1.0.0",description:Z.description,snippet:{instances:Rf(zn,C.current),edges:J,ui:{nodePositions:W,nodeSizes:Y}}})}),ae=await re.json().catch(()=>({}));if(!re.ok||ae.ok===!1)throw new Error(ae.error||"发布流程片段失败");G(!1),ze(`流程片段已发布:${ae.id||E}`),Ai(`流程片段已发布:${ae.id||E}`),await Bt(),z("flows")}catch(re){ye(String(re.message||re))}finally{de(!1)}},[Bt,Z,Yo,zn,Ai]),ju=m.useCallback(E=>{a(W=>W.map(Y=>Y.id===E?{...Y,selected:!1}:Y)),Ft(W=>W===E?"":W)},[a]),Xo=m.useCallback(()=>{const E=$s.current;if(!E)return;const W=E.getBoundingClientRect(),Y=Math.min(420,Math.max(320,W.width+160)),J=12,Q=Math.max(180,W.top-J*2),se=Math.min(560,Q);ot({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-Y-12,W.left)),top:Math.max(J,W.top-se-J),width:Y,maxHeight:se,zIndex:1e4})},[]);m.useEffect(()=>{if(!Xn)return;Xo();const E=Y=>{var Q,se;const J=Y.target;(Q=$s.current)!=null&&Q.contains(J)||(se=Dn.current)!=null&&se.contains(J)||pt(!1)},W=Y=>{Y.key==="Escape"&&pt(!1)};return window.addEventListener("pointerdown",E),window.addEventListener("keydown",W),window.addEventListener("resize",Xo),window.addEventListener("scroll",Xo,!0),()=>{window.removeEventListener("pointerdown",E),window.removeEventListener("keydown",W),window.removeEventListener("resize",Xo),window.removeEventListener("scroll",Xo,!0)}},[Xn,Xo]);const Gl=m.useCallback(E=>{var J,Q;if(!ce){const se=(E||[]).filter(re=>(re==null?void 0:re.type)==="select");se.length>0&&a(re=>Zh(se,re));return}const W=new Map;for(const se of E||[])(se==null?void 0:se.type)==="dimensions"&&((J=se.dimensions)!=null&&J.width)&&((Q=se.dimensions)!=null&&Q.height)&&W.set(se.id,{width:Math.round(Number(se.dimensions.width)),height:Math.round(Number(se.dimensions.height))});const Y=Array.from(W.keys());if(a(se=>Zh(E,se).map(re=>{var be;const ae=W.get(re.id);return ae?Es((be=re.data)==null?void 0:be.definitionId)?{...re,width:ae.width,height:ae.height,data:{...re.data,nodeSize:ae,displaySize:ae}}:{...re,width:ae.width,height:ae.height,data:{...re.data,nodeSize:ae}}:re})),Y.length>0){const se=()=>Y.forEach(re=>r(re));window.requestAnimationFrame(se),window.setTimeout(se,80)}},[a,r,ce]),yt=m.useCallback(E=>{if(!ce){const W=(E||[]).filter(Y=>(Y==null?void 0:Y.type)==="select");W.length>0&&u(Y=>iv(W,Y));return}d(E)},[d,u,ce]),Jo=m.useCallback(()=>{const E=document.querySelector(".af-workspace-canvas .react-flow");if(E){const W=E.getBoundingClientRect();return n.screenToFlowPosition({x:W.left+W.width*.48,y:W.top+W.height*.32})}return{x:360+i.length*36,y:180+i.length*28}},[i.length,n]),zs=m.useCallback(()=>{var E,W,Y;if(Tt){const J=Number(((E=Tt.measured)==null?void 0:E.width)||Tt.width||260);return{x:Number(((W=Tt.position)==null?void 0:W.x)||0)+J+140,y:Number(((Y=Tt.position)==null?void 0:Y.y)||0)}}return Jo()},[Jo,Tt]),Bs=m.useCallback((E,W={})=>{if(!ce)return ze("Readonly workspace"),null;if(!E)return null;const Y=Tv(E)||E.id,J=ZI(E),Q=W.id||SK(Y,i),se=Hp(E.inputs),re=Hp(E.outputs),ae={definitionId:Y,...J?{marketplaceRef:J}:{},...E.packageId?{marketplacePackageId:E.packageId}:{},...E.version?{marketplaceVersion:E.version}:{},label:W.label||mm(E),role:"normal",body:W.body||"",input:W.inputs||se,output:W.outputs||re},be={id:Q,type:Lf,position:W.position||Jo(),data:{label:ae.label,definitionId:Y,...J?{marketplaceRef:J}:{},...E.packageId?{marketplacePackageId:E.packageId}:{},...E.version?{marketplaceVersion:E.version}:{},schemaType:QI(Y,E),role:"normal",body:ae.body,inputs:ae.input,outputs:ae.output}},Ae={...ff(be,{...C.current,[Q]:ae},D),selected:!0};return a(lt=>[...lt.map(Qe=>({...Qe,selected:!1})),Ae]),W.openProperties&&Ft(Q),Q},[Jo,i,D,a,ce]),Cu=m.useCallback(E=>_j(E,f.current),[]),Uv=m.useCallback(E=>{if(!ce){ze("Readonly workspace");return}if(!_j(E,f.current)){ze("端口类型不匹配,已取消连线");return}b(null),a(W=>dm(W,E)),u(W=>{const Y=W.filter(J=>!(J.target===E.target&&J.targetHandle===E.targetHandle));return rf({...E,markerEnd:{type:ds.ArrowClosed}},Y)})},[u,a,ce]),ai=m.useCallback((E,W)=>{ce&&(v.current=vK(W,f.current),b(null))},[ce]),hg=m.useCallback((E,W)=>{var Xe,Ht,fn,pn;if(!ce)return;const Y=v.current;if(v.current=null,!Y||W!=null&&W.toNode)return;const J=kK(D,Y);if(J.length===0){ze(`没有匹配 ${Y.slotType} 端口的节点`);return}const Q=((Ht=(Xe=E==null?void 0:E.changedTouches)==null?void 0:Xe[0])==null?void 0:Ht.clientX)??(E==null?void 0:E.clientX),se=((pn=(fn=E==null?void 0:E.changedTouches)==null?void 0:fn[0])==null?void 0:pn.clientY)??(E==null?void 0:E.clientY);if(!Number.isFinite(Q)||!Number.isFinite(se))return;const re=document.querySelector(".af-workspace-canvas .react-flow");if(!re)return;const ae=re.getBoundingClientRect(),be=320,Ae=Math.min(440,104+J.length*58),lt=Math.max(12,Math.min(Q-ae.left,ae.width-be-12)),Qe=Math.max(12,Math.min(se-ae.top,ae.height-Ae-12));b({left:lt,top:Qe,flowPosition:n.screenToFlowPosition({x:Q,y:se}),draft:Y,candidates:J,query:""})},[D,n,ce]),xo=m.useCallback(E=>{if(!ce){ze("Readonly workspace"),b(null);return}const W=k.current;if(!W||!(E!=null&&E.def))return;const Y=Bs(E.def,{position:W.flowPosition});if(!Y)return;const J=W.draft.handleType==="source"?{source:W.draft.nodeId,sourceHandle:W.draft.handleId,target:Y,targetHandle:`input-${E.slotIndex}`}:{source:Y,sourceHandle:`output-${E.slotIndex}`,target:W.draft.nodeId,targetHandle:W.draft.handleId};a(Q=>dm(Q,J)),u(Q=>{const se=Q.filter(re=>!(re.target===J.target&&re.targetHandle===J.targetHandle));return rf({...J,markerEnd:{type:ds.ArrowClosed}},se)}),b(null)},[Bs,u,ce]),Qo=m.useCallback(E=>{E&&(Bs(E,{position:zs()}),Pe(!1),Ue(""))},[Bs,zs]),Eu=m.useCallback(E=>{E&&(el(E,zs()),Pe(!1),Ue(""))},[el,zs]);m.useEffect(()=>{const E=W=>{if(W.defaultPrevented)return;const Y=MI(W.target)||wK(W.target);if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"){W.preventDefault(),ir().catch(re=>ze(String(re.message||re)));return}if(Ie){(W.key==="Escape"||pm(W))&&(W.preventDefault(),Ee(!1));return}if(Y)return;const J=W.key.toLowerCase(),Q=(W.metaKey||W.ctrlKey)&&!W.shiftKey&&J==="z",se=(W.metaKey||W.ctrlKey)&&(W.shiftKey&&J==="z"||J==="y");if(Q||se){if(!ce){W.preventDefault(),ze("Readonly workspace");return}W.preventDefault(),W.stopPropagation();const re=Q?Va():Hl();ze(re?Q?"Undo canvas change":"Redo canvas change":Q?"Nothing to undo":"Nothing to redo");return}if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="c"){const re=EI(f.current,c.current,C.current);re&&(W.preventDefault(),W.stopPropagation(),g.current=re,ze(`Copied ${re.nodes.length} node${re.nodes.length>1?"s":""}`));return}if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="v"){if(!ce){W.preventDefault(),ze("Readonly workspace");return}const re=_I(g.current,f.current,c.current,C.current);re&&(W.preventDefault(),W.stopPropagation(),C.current=re.instances,N(re.instances),a(re.nodes),u(re.edges),ze(`Pasted ${re.pastedNodeIds.length} node${re.pastedNodeIds.length>1?"s":""}`));return}if(pm(W)&&!W.metaKey&&!W.ctrlKey&&!W.altKey){W.preventDefault(),Ee(!0);return}if(W.key==="a"||W.key==="A"){if(W.metaKey||W.ctrlKey){W.preventDefault(),a(re=>re.map(ae=>({...ae,selected:!0}))),u(re=>re.map(ae=>({...ae,selected:!1})));return}if(W.altKey)return;if(!ce){W.preventDefault(),ze("Readonly workspace");return}W.preventDefault(),Pe(!0);return}if((W.key==="v"||W.key==="V")&&!W.metaKey&&!W.ctrlKey&&!W.altKey){W.preventDefault(),Ot("select");return}(W.key==="h"||W.key==="H")&&!W.metaKey&&!W.ctrlKey&&!W.altKey&&(W.preventDefault(),Ot("pan"))};return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[Hl,ir,Ie,u,a,Va,ce]);const mg=m.useCallback(E=>{nn(W=>{const Y=new Set(W);return Y.has(E)?Y.delete(E):Y.add(E),Y})},[]),Xl=m.useCallback((E,W)=>{E.dataTransfer.effectAllowed="copy",E.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:W.path,name:W.name,type:W.type})),E.dataTransfer.setData("text/plain",W.path)},[]),gg=m.useCallback((E,W)=>{E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("application/agentflow-node",W.id),E.dataTransfer.setData("text/plain",W.id)},[]),tl=m.useCallback(async(E,W)=>{const Y=String((E==null?void 0:E.name)||(E==null?void 0:E.path)||"").toLowerCase(),J=Y.split(".").pop(),Q=J==="html"?"display_html":J==="csv"||J==="tsv"||J==="json"&&/\b(table|data|rows|report)\b/i.test(Y)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(J)?"display_image":"display_markdown",se=D.find(Qe=>Qe.id===Q);if(!se){ze("展示节点不可用");return}const re=Q==="display_image";let ae=String(E.path||"");if(!re){const Qe=hl(s);Qe.set("path",E.path);const Xe=await fetch(`/api/workspace/file?${Qe.toString()}`),Ht=await Xe.json();if(!Xe.ok)throw new Error(Ht.error||"读取文件失败");ae=String(Ht.content||"")}const be=Q==="display_image"?"src":"content",Ae=Hp(se.inputs).map(Qe=>Qe.name===be?{...Qe,default:ae,value:ae}:Qe),lt=Hp(se.outputs).map(Qe=>Qe.name===be?{...Qe,default:ae,value:ae}:Qe);Bs(se,{label:E.name||"Display",body:ae,inputs:Ae,outputs:lt,position:W}),ze(`已创建展示:${E.path}`)},[Bs,s,D]),yg=m.useCallback(E=>{if(!ce){ze("Readonly workspace");return}tl(E,Jo()).catch(W=>ze(String(W.message||W)))},[tl,Jo,ce]),xg=m.useCallback(E=>{if(!ce){E.preventDefault(),ze("Readonly workspace");return}const W=E.dataTransfer.getData("application/x-agentflow-workspace-file");if(W){E.preventDefault();let re;try{re=JSON.parse(W)}catch{return}if(!(re!=null&&re.path))return;const ae=n.screenToFlowPosition({x:E.clientX,y:E.clientY});tl(re,ae).catch(be=>ze(String(be.message||be)));return}const Y=E.dataTransfer.getData("application/agentflow-snippet");if(Y){const re=T.find(be=>`${be.id}@${be.version}`===Y);if(!re)return;E.preventDefault();const ae=n.screenToFlowPosition({x:E.clientX,y:E.clientY});el(re,ae);return}const J=E.dataTransfer.getData("application/agentflow-node");if(!J)return;const Q=D.find(re=>re.id===J);if(!Q)return;E.preventDefault();const se=n.screenToFlowPosition({x:E.clientX,y:E.clientY});Bs(Q,{position:se})},[tl,Bs,T,el,D,n,ce]),wg=m.useCallback(E=>{if(!ce)return;const W=Array.from(E.dataTransfer.types||[]);!W.includes("application/x-agentflow-workspace-file")&&!W.includes("application/agentflow-node")&&!W.includes("application/agentflow-snippet")||(E.preventDefault(),E.dataTransfer.dropEffect=W.includes("application/agentflow-node")||W.includes("application/agentflow-snippet")?"move":"copy")},[ce]),nl=m.useCallback(async(E="")=>{if(!ce){ze("Readonly workspace");return}const W=window.prompt("新文件名",E?`${E}/notes.md`:"notes.md");if(!W)return;const Y=E&&!W.includes("/")?`${E}/${W}`:W;try{const J=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Y,content:""})}),Q=await J.json();if(!J.ok)throw new Error(Q.error||"创建文件失败");await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q.path||Y))re.delete(ae);return re}),ze(`已创建 ${Q.path}`)}catch(J){ze(String(J.message||J))}},[s,Zn,ce]),Jl=m.useCallback(async(E="")=>{if(!ce){ze("Readonly workspace");return}const W=window.prompt("新文件夹名",E?`${E}/docs`:"docs");if(!W)return;const Y=E&&!W.includes("/")?`${E}/${W}`:W;try{const J=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Y})}),Q=await J.json();if(!J.ok)throw new Error(Q.error||"创建文件夹失败");await Zn(),nn(se=>{const re=new Set(se);for(const ae of Vp(Q.path||Y))re.delete(ae);return Q.path&&re.delete(Q.path),re}),ze(`已创建 ${Q.path}`)}catch(J){ze(String(J.message||J))}},[s,Zn,ce]),_u=m.useCallback(async E=>{if(!ce){ze("Readonly workspace");return}if(!(!(E!=null&&E.path)||!window.confirm(`删除 ${E.path}?`)))try{const W=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:E.path})}),Y=await W.json();if(!W.ok)throw new Error(Y.error||"删除失败");ze(`已删除 ${Y.path}`),await Zn()}catch(W){ze(String(W.message||W))}},[s,Zn,ce]),Pu=m.useCallback(async()=>{if(!ce){ze("Readonly workspace");return}const E=Vt.trim();if(!E||kn)return;const W=Wp(i,l,C.current);zt(""),Ye(!0),Ua("workspace"),Dr(Y=>[...Y,{role:"user",text:E,at:Date.now()}]);try{await ir(i,l);const Y=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,prompt:E,outputKind:"markdown",workspaceGraph:W,allowFlowYaml:!1,model:et,selectedSkills:gr,selectedNodeIds:Fi})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"生成失败");const Q=String(J.content||"").trim();Dr(se=>[...se,{role:"assistant",text:Q,at:Date.now()}]),await Fs(),ze("AI 生成完成")}catch(Y){const J=String(Y.message||Y);Dr(Q=>[...Q,{role:"assistant",text:J,error:!0,at:Date.now()}]),ze(J)}finally{Ye(!1)}},[et,kn,Vt,l,s,Fs,i,Ua,ir,Fi,gr,ce]),_r=go.find(E=>E.id===Ii)||null,bg=_r?Array.isArray(_r.messages)?_r.messages:[]:Jn,rl=_r?_r.status==="running":kn,zf=_r?_r.status==="running"?`${_r.label} running`:_r.status==="paused"?`${_r.label} paused`:_r.status==="failed"?`${_r.label} failed`:`${_r.label} done`:kn?"Workspace agent running":Jn.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>t("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:s.flowId?`${s.flowId} · ${me}`:me||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",mK,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(Hb({id:s.flowId,source:s.flowSource||"user",archived:!!s.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:si}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ee(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ti?" af-composer-topbar-btn--active":"")+(kn?" af-composer-topbar-btn--running":""),onClick:()=>Ds(E=>!E),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!ce,onClick:()=>ir().catch(E=>ze(String(E.message||E))),children:"Save"})]})]}),oe?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:oe}),o.jsx("button",{type:"button",onClick:()=>Se(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(ti||Fe?" af-workspace-body--drawer":"")+(V?" af-workspace-body--sidebar-collapsed":""),children:[V?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Pe(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>fe(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>fe(!1),"aria-label":"展开侧边栏",title:(ht==null?void 0:ht.username)||(ht==null?void 0:ht.userId)||"展开侧边栏",children:Nu})]})}):null,o.jsxs("aside",{ref:mr,className:"af-workspace-sidebar"+(Vn?" af-workspace-sidebar--resizing":""),"aria-hidden":V,style:{"--af-work-files-pane-height":`${Math.round(dn)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>fe(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!ce,onClick:()=>nl(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!ce,onClick:()=>Jl(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Zn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:qt,onChange:E=>qn(E.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(cT,{items:Qa,flowParams:s,onOpen:yg,collapsedDirs:vn,onToggleDir:mg,onCreateFile:nl,onCreateFolder:Jl,onDelete:_u,onFileDragStart:Xl})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:$n,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:A==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:B,onChange:E=>$(E.target.value),placeholder:A==="flows"?"搜索流程片段...":"搜索节点...","aria-label":A==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":A==="nodes",className:"af-palette-tab"+(A==="nodes"?" af-palette-tab--active":""),onClick:()=>z("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":A==="flows",className:"af-palette-tab"+(A==="flows"?" af-palette-tab--active":""),onClick:()=>z("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:A==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:pg,disabled:zn.length<2,title:zn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",zn.length," 节点 / ",Yo.length," 连线"]})]})}),P?o.jsx("p",{className:"af-err af-palette-list-err",children:P}):null,I?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Yl.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:Yl.map(E=>{const W=`${E.id}@${E.version}`,Y=E.displayName||E.name||E.id,J=E.description||`${E.nodeCount||0} 个节点,${E.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Q=>{Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/agentflow-snippet",W),Q.dataTransfer.setData("text/plain",W)},onClick:()=>el(E),title:J,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:Y}),o.jsxs("span",{className:"af-palette-card-id",children:[E.id,"@",E.version]})]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[E.nodeCount||0," nodes"]}),o.jsxs("span",{children:[E.edgeCount||0," edges"]})]})]},W)})})]}):o.jsx("p",{className:"af-palette-empty",children:B.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[pc.map(E=>{var W;return(W=yo[E])!=null&&W.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${E}`,children:[o.jsx("h3",{className:"af-palette-cat",children:E}),o.jsx("div",{className:"af-palette-cards",children:yo[E].map(Y=>{const J=Ej(Y.inputs,"input"),Q=Ej(Y.outputs,"output"),se=Fw(Y),re=ud(Y);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:ae=>gg(ae,Y),onClick:()=>Bs(Y),title:se||Y.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:jj(E)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:re}),re!==Y.id?o.jsx("span",{className:"af-palette-card-id",children:Y.id}):null]})]}),se?o.jsx("span",{className:"af-palette-card-desc",children:se}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[J.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[J.shown.map((ae,be)=>o.jsxs("span",{className:"af-palette-card-port",title:Cj("input",ae,be),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ae==null?void 0:ae.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Wy(ae,be)})]},`in-${be}`)),J.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",J.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((ae,be)=>o.jsxs("span",{className:"af-palette-card-port",title:Cj("output",ae,be),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Wy(ae,be)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Wn(ae==null?void 0:ae.type)}})]},`out-${be}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},Y.id)})})]},E):null}),D.length>0&&B.trim()&&pc.every(E=>{var W;return!((W=yo[E])!=null&&W.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(GP,{className:"af-flow-canvas af-workspace-flow"+(Ge==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),nodes:Oi,edges:Xr,nodeTypes:KK,onNodesChange:Gl,onEdgesChange:yt,onConnect:Uv,onConnectStart:ai,onConnectEnd:hg,isValidConnection:Cu,onNodeClick:(E,W)=>{gt&&Ft(W.id)},onNodeDoubleClick:(E,W)=>{E.preventDefault(),Ds(!1),a(Y=>Y.map(J=>({...J,selected:J.id===W.id}))),u(Y=>Y.map(J=>({...J,selected:!1}))),Ft(W.id)},onPaneClick:()=>Ft(""),onDrop:xg,onDragOver:wg,nodesDraggable:ce,nodesConnectable:ce,edgesReconnectable:ce,deleteKeyCode:ce?["Backspace","Delete"]:null,selectionOnDrag:Ge==="select",panOnDrag:Ge==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(ZP,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),y?(()=>{var J;const E=String(y.query||"").trim().toLowerCase(),W=E?y.candidates.filter(Q=>{var se,re,ae;return[(se=Q.def)==null?void 0:se.id,Q.displayLabel,Q.description,(re=Q.slot)==null?void 0:re.name,(ae=Q.slot)==null?void 0:ae.type].filter(Boolean).some(be=>String(be).toLowerCase().includes(E))}):y.candidates,Y=y.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:y.left,top:y.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Wn((J=y.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",y.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>b(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:y.query,onChange:Q=>b(se=>se&&{...se,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[W.map(Q=>{var ae,be;const se=Q.displayLabel||((ae=Q.def)==null?void 0:ae.id),re=Wy(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>xo(Q),title:Q.description||Q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:se}),se!==Q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:Y}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Wn((be=Q.slot)==null?void 0:be.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:re})]})]},`${Q.def.id}-${Q.slotIndex}`)}),W.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,ni?o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Zt(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Zt(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:zn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):zn.map(E=>{var Q,se;const W=String(((Q=E.data)==null?void 0:Q.label)??E.id),Y=(se=E.data)!=null&&se.definitionId?String(E.data.definitionId):"",J=Y&&Y!==W?`${W} · ${E.id} · ${Y}`:`${W} · ${E.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:J,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:Y||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:W}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>ju(E.id),"aria-label":`取消选择 ${E.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},E.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:Vt,rows:2,onChange:E=>zt(E.target.value),onKeyDown:E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),Pu())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!ce})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:$s,type:"button",className:"af-composer-skills-button"+(gr.length>0?" af-composer-skills-button--active":""),disabled:kn||!ce,"aria-haspopup":"listbox","aria-expanded":Xn,onClick:()=>pt(E=>!E),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:gr.length>0?`Skills ${gr.length}`:"Skills"})]}),Xn&&!kn?ns.createPortal(o.jsx("div",{ref:Dn,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:xs,children:Qt.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Di.groups.map(E=>{const W=Ta(E,Qt),Y=n_(E,Su,Qt),J=Te.has(E.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(J?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:Y==="all",disabled:W.length===0,onChange:Q=>{const se=Q.target.checked;Ms(re=>se?e_(re,W):t_(re,W))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:E.name}),E.builtin?o.jsx("em",{children:"built-in"}):null,Y==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":J?`展开 ${E.name}`:`收起 ${E.name}`,onClick:()=>{Gt(Q=>{const se=new Set(Q);return se.has(E.id)?se.delete(E.id):se.add(E.id),se})},children:[o.jsx("span",{children:E.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J?"expand_more":"expand_less"})]})]}),J?null:o.jsx("div",{className:"af-composer-skill-group-items",children:E.skills.map(Q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Su.has(Q.key),onChange:se=>{const re=se.target.checked;Ms(ae=>re?ae.includes(Q.key)?ae:[...ae,Q.key]:ae.filter(be=>be!==Q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${E.id}:${Q.key}`))})]},E.id)}),Di.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Di.ungrouped.length})]}),Di.ungrouped.map(E=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Su.has(E.key),onChange:W=>{const Y=W.target.checked;Ms(J=>Y?J.includes(E.key)?J:[...J,E.key]:J.filter(Q=>Q!==E.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:E.name}),E.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:E.description}):null]})]},`ungrouped:${E.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:et,onChange:E=>Lt(E.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),Za.map(E=>o.jsx("option",{value:E.value,children:E.label},E.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(Vt.trim()&&!kn?" af-composer-send--active":"")+(kn?" af-composer-send--stop":""),disabled:kn||!Vt.trim()||!ce,"aria-label":kn?"Running":"Send",onClick:()=>void Pu(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:kn?"sync":"arrow_upward"})})]})]})]})})]}),ti?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Ds(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Ii==="workspace"?" af-composer-session-tab--active":""),onClick:()=>ws("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),go.map(E=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Ii===E.id?" af-composer-session-tab--active":"")+(E.status==="running"?" af-composer-session-tab--running":""),onClick:()=>ws(E.id),title:E.runNodeId||E.label,children:o.jsx("span",{className:"af-composer-session-label",children:E.label})},E.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(rl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:zf}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(GK,{messages:bg,running:rl,showRunningIndicator:!_r})})]})}):Fe&&Tt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(HI,{draft:Fe,setDraft:tn,definitionId:String(((Au=Tt.data)==null?void 0:Au.definitionId)||Tt.id),systemPromptReadonly:String(((sl=Tt.data)==null?void 0:sl.description)||""),modelLists:we,disabled:!ce,onIdBlur:()=>Ja(!0),onClose:()=>Ft(""),onPublishToMarketplace:ur,error:Jt,ioSlots:{inputs:Array.isArray(Fe==null?void 0:Fe.inputs)?Fe.inputs:[],outputs:Array.isArray(Fe==null?void 0:Fe.outputs)?Fe.outputs:[]}})}):null,o.jsx($I,{open:Ie,onClose:()=>Ee(!1)}),_?ns.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>G(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Z.name,onChange:E=>{const W=E.target.value;U(Y=>({...Y,name:W,id:Y.id?Y.id:W.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Z.id,onChange:E=>U(W=>({...W,id:E.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Z.description,onChange:E=>U(W=>({...W,description:E.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",zn.length," 个节点和 ",Yo.length," 条内部连线。"]}),he?o.jsx("div",{className:"af-flow-snippet-error",children:he}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>G(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ie||!Z.name.trim(),onClick:()=>void vt(),children:ie?"发布中...":"发布"})]})]})}),document.body):null,ve?ns.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Pe(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="nodes",className:"af-workspace-quick-add__tab"+(Ce==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Je("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="flows",className:"af-workspace-quick-add__tab"+(Ce==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Je("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:In,value:nt,onChange:E=>Ue(E.target.value),onKeyDown:E=>{if(E.key==="Escape")E.preventDefault(),Pe(!1);else if(E.key==="ArrowDown"){E.preventDefault();const W=Ce==="flows"?oi.length:$i.length;qe(Y=>Math.min(Math.max(0,W-1),Y+1))}else E.key==="ArrowUp"?(E.preventDefault(),qe(W=>Math.max(0,W-1))):E.key==="Tab"?(E.preventDefault(),Je(W=>W==="nodes"?"flows":"nodes")):E.key==="Enter"&&(E.preventDefault(),Ce==="flows"?Eu(oi[_t]||oi[0]):Qo($i[_t]||$i[0]))},placeholder:Ce==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ce==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:Ce==="flows"?oi.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:I?"正在加载流程片段...":P||"没有匹配的流程片段"}):oi.map((E,W)=>{const Y=E.displayName||E.name||E.id,J=E.snippet&&typeof E.snippet=="object"?E.snippet.instances:null,Q=E.snippet&&typeof E.snippet=="object"?E.snippet.edges:null,se=Number.isFinite(Number(E.nodeCount))?Number(E.nodeCount):Object.keys(J||{}).length,re=Number.isFinite(Number(E.edgeCount))?Number(E.edgeCount):Array.isArray(Q)?Q.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(W===_t?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>qe(W),onClick:()=>Eu(E),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:Y}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[E.id,E.version?` · v${E.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:E.description||`${se} 节点 / ${re} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${E.id}@${E.version}`)}):$i.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):$i.map((E,W)=>{const Y=cd(E),J=ud(E),Q=Fw(E);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(W===_t?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>qe(W),onClick:()=>Qo(E),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:jj(Y)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:J}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:E.id}),Q?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:Y})]},E.id)})})]})}),document.body):null]})]})}function iq(){return o.jsx(av,{children:o.jsx(sq,{})})}const wt=e=>typeof e=="string",Ju=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},Ij=e=>e==null?"":""+e,oq=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},aq=/###/g,Tj=e=>e&&e.indexOf("###")>-1?e.replace(aq,"."):e,Rj=e=>!e||wt(e),Ad=(e,t,n)=>{const r=wt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Rj(e))return{};const i=Tj(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return Rj(e)?{}:{obj:e,k:Tj(r[s])}},Lj=(e,t,n)=>{const{obj:r,k:s}=Ad(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=Ad(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=Ad(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},lq=(e,t,n,r)=>{const{obj:s,k:i}=Ad(e,t,Object);s[i]=s[i]||[],s[i].push(n)},ym=(e,t)=>{const{obj:n,k:r}=Ad(e,t);if(n)return n[r]},cq=(e,t,n)=>{const r=ym(e,n);return r!==void 0?r:ym(t,n)},uT=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?wt(e[r])||e[r]instanceof String||wt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):uT(e[r],t[r],n):e[r]=t[r]);return e},uc=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var uq={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const dq=e=>wt(e)?e.replace(/[&<>"'\/]/g,t=>uq[t]):e;class fq{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const pq=[" ",",","?","!",";"],hq=new fq(20),mq=(e,t,n)=>{t=t||"",n=n||"";const r=pq.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=hq.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},zw=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let u=i;u<r.length;++u)if(u!==i&&(l+=n),l+=r[u],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&u<r.length-1)continue;i+=u-i+1;break}s=a}return s},xm=e=>e&&e.replace("_","-"),gq={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class wm{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||gq,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(wt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new wm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new wm(this.logger,t)}}var ro=new wm;class ag{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l.apply(l,[t,...r])})}}class Oj extends ag{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):wt(r)&&i?l.push(...r.split(i)):l.push(r)));const u=ym(this.data,l);return!u&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),u||!a||!wt(r)?u:zw(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),Lj(this.data,l,s),i.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const i in r)(wt(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let u=ym(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?uT(u,r,i):u={...u,...r},Lj(this.data,l,u),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var dT={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const Mj={};class bm extends ag{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),oq(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ro.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!mq(t,r,s);if(a&&!l){const u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:wt(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:wt(i)?[i]:i}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),u=l[l.length-1],d=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(f){const N=n.nsSeparator||this.options.nsSeparator;return s?{res:`${u}${N}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:`${u}${N}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:a}const c=this.resolve(t,n);let p=c&&c.res;const h=c&&c.usedKey||a,g=c&&c.exactUsedKey||a,v=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!wt(p)&&typeof p!="boolean"&&typeof p!="number";if(b&&p&&w&&k.indexOf(v)<0&&!(wt(y)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const N=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(c.res=N,c.usedParams=this.getUsedParamsDetails(n),c):N}if(i){const N=Array.isArray(p),C=N?[]:{},j=N?g:h;for(const R in p)if(Object.prototype.hasOwnProperty.call(p,R)){const D=`${j}${i}${R}`;C[R]=this.translate(D,{...n,joinArrays:!1,ns:l}),C[R]===D&&(C[R]=p[R])}p=C}}else if(b&&wt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let N=!1,C=!1;const j=n.count!==void 0&&!wt(n.count),R=bm.hasDefaultValue(n),D=j?this.pluralResolver.getSuffix(d,n.count,n):"",M=n.ordinal&&j?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",B=j&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),$=B&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${D}`]||n[`defaultValue${M}`]||n.defaultValue;!this.isValidLookup(p)&&R&&(N=!0,p=$),this.isValidLookup(p)||(C=!0,p=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:p,T=R&&$!==p&&this.options.updateMissing;if(C||N||T){if(this.logger.log(T?"updateKey":"missingKey",d,u,a,T?$:p),i){const P=this.resolve(a,{...n,keySeparator:!1});P&&P.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let L=[];const I=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&I&&I[0])for(let P=0;P<I.length;P++)L.push(I[P]);else this.options.saveMissingTo==="all"?L=this.languageUtils.toResolveHierarchy(n.lng||this.language):L.push(n.lng||this.language);const F=(P,O,_)=>{const G=R&&_!==p?_:z;this.options.missingKeyHandler?this.options.missingKeyHandler(P,u,O,G,T,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(P,u,O,G,T,n),this.emit("missingKey",P,u,O,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&j?L.forEach(P=>{const O=this.pluralResolver.getSuffixes(P,n);B&&n[`defaultValue${this.options.pluralSeparator}zero`]&&O.indexOf(`${this.options.pluralSeparator}zero`)<0&&O.push(`${this.options.pluralSeparator}zero`),O.forEach(_=>{F([P],a+_,n[`defaultValue${_}`]||$)})}):F(L,a,$))}p=this.extendTranslation(p,t,n,c,r),C&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${u}:${a}`),(C||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}:${a}`:a,N?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(c.res=p,c.usedParams=this.getUsedParamsDetails(n),c):p}extendTranslation(t,n,r,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=wt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(d){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let c=r.replace&&!wt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;f<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return i&&i[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,u=wt(l)?[l]:l;return t!=null&&u&&u.length&&r.applyPostProcessor!==!1&&(t=dT.handle(u,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,i,a,l;return wt(t)&&(t=[t]),t.forEach(u=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(u,n),f=d.key;s=f;let c=d.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const p=n.count!==void 0&&!wt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(wt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(k=>{this.isValidLookup(r)||(l=k,!Mj[`${v[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(Mj[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;a=y;const b=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(b,f,y,k,n);else{let N;p&&(N=this.pluralResolver.getSuffix(y,n.count,n));const C=`${this.options.pluralSeparator}zero`,j=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(b.push(f+N),n.ordinal&&N.indexOf(j)===0&&b.push(f+N.replace(j,this.options.pluralSeparator)),h&&b.push(f+C)),g){const R=`${f}${this.options.contextSeparator}${n.context}`;b.push(R),p&&(b.push(R+N),n.ordinal&&N.indexOf(j)===0&&b.push(R+N.replace(j,this.options.pluralSeparator)),h&&b.push(R+C))}}let w;for(;w=b.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,k,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!wt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const i of n)delete s[i]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Uy=e=>e.charAt(0).toUpperCase()+e.slice(1);class $j{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ro.create("languageUtils")}getScriptPartFromCode(t){if(t=xm(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=xm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(wt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Uy(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Uy(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Uy(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),wt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return wt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):wt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let yq=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],xq={1:e=>+(e>1),2:e=>+(e!=1),3:e=>0,4:e=>e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,5:e=>e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5,6:e=>e==1?0:e>=2&&e<=4?1:2,7:e=>e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,8:e=>e==1?0:e==2?1:e!=8&&e!=11?2:3,9:e=>+(e>=2),10:e=>e==1?0:e==2?1:e<7?2:e<11?3:4,11:e=>e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3,12:e=>+(e%10!=1||e%100==11),13:e=>+(e!==0),14:e=>e==1?0:e==2?1:e==3?2:3,15:e=>e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2,16:e=>e%10==1&&e%100!=11?0:e!==0?1:2,17:e=>e==1||e%10==1&&e%100!=11?0:1,18:e=>e==0?0:e==1?1:2,19:e=>e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3,20:e=>e==1?0:e==0||e%100>0&&e%100<20?1:2,21:e=>e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0,22:e=>e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3};const wq=["v1","v2","v3"],bq=["v4"],Dj={zero:0,one:1,two:2,few:3,many:4,other:5},vq=()=>{const e={};return yq.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:xq[t.fc]}})}),e};class kq{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=ro.create("pluralResolver"),(!this.options.compatibilityJSON||bq.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=vq(),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const r=xm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const u=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(u,n)}return this.pluralRulesCache[i]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,i)=>Dj[s]-Dj[i]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const i=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!wq.includes(this.options.compatibilityJSON)}}const Fj=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=cq(e,t,n);return!i&&s&&wt(n)&&(i=zw(e,n,r),i===void 0&&(i=zw(t,n,r))),i},Ky=e=>e.replace(/\$/g,"$$$$");class Sq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ro.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:i,prefixEscaped:a,suffix:l,suffixEscaped:u,formatSeparator:d,unescapeSuffix:f,unescapePrefix:c,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:dq,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?uc(i):a||"{{",this.suffix=l?uc(l):u||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?uc(p):h||uc("$t("),this.nestingSuffix=g?uc(g):v||uc(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let i,a,l;const u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const y=Fj(n,u,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:h}):y}const g=h.split(this.formatSeparator),v=g.shift().trim(),k=g.join(this.formatSeparator).trim();return this.format(Fj(n,u,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,c=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Ky(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ky(this.escape(h)):Ky(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const k=f(t,i,s);a=wt(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(c){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!wt(a)&&!this.useRawValueToEscape&&(a=Ij(a));const v=h.safeValue(a);if(t=t.replace(i[0],v),c?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=i[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(u,d)=>{const f=this.nestingOptionsSeparator;if(u.indexOf(f)<0)return u;const c=u.split(new RegExp(`${f}[ ]*{`));let p=`{${c[1]}`;u=c[0],p=this.interpolate(p,a);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,v),`${u}${f}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,u};for(;s=this.nestingRegexp.exec(t);){let u=[];a={...r},a=a.replace&&!wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const f=s[1].split(this.formatSeparator).map(c=>c.trim());s[1]=f.shift(),u=f,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!wt(i))return i;wt(i)||(i=Ij(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=u.reduce((f,c)=>this.format(f,c,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const Nq=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...u]=a.split(":"),d=u.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},dc=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(xm(r),s),t[a]=l),l(n)}};class jq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ro.create("formatter"),this.options=t,this.formats={number:dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:dc((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:dc((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:dc((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=dc(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(u=>u.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,u)=>{const{formatName:d,formatOptions:f}=Nq(u);if(this.formats[d]){let c=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;c=this.formats[d](l,h,{...f,...s,...p})}catch(p){this.logger.warn(p)}return c}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const Cq=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class Eq extends ag{constructor(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=ro.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const i={},a={},l={},u={};return t.forEach(d=>{let f=!0;n.forEach(c=>{const p=`${d}|${c}`;!r.reload&&this.store.hasResourceBundle(d,c)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),u[c]===void 0&&(u[c]=!0)))}),f||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(u)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(u=>{lq(u.loaded,[i],a),Cq(u,t),n&&u.errors.push(n),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(d=>{l[d]||(l[d]={});const f=u.loaded[d];f.length&&f.forEach(c=>{l[d][c]===void 0&&(l[d][c]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(u=>!u.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:i,callback:a});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const c=this.waitingReads.shift();this.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,f)},u=this.backend[r].bind(this.backend);if(u.length===2){try{const d=u(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return u(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();wt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),wt(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const u={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,r,s,u):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(c=>l(null,c)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,u)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const zj=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),wt(e[1])&&(t.defaultValue=e[1]),wt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Bj=e=>(wt(e.ns)&&(e.ns=[e.ns]),wt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),wt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Up=()=>{},_q=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class pf extends ag{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Bj(t),this.services={},this.logger=ro,this.modules={external:[]},_q(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(wt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=zj();this.options={...s,...this.options,...Bj(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const i=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?ro.init(i(this.modules.logger),this.options):ro.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=jq);const c=new $j(this.options);this.store=new Oj(this.options.resources,this.options);const p=this.services;p.logger=ro,p.resourceStore=this.store,p.languageUtils=c,p.pluralResolver=new kq(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Sq(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new Eq(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new bm(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Up),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const u=Ju(),d=()=>{const f=(c,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),u.resolve(p),r(c,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),u}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Up;const s=wt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>a(u)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Ju();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=Up),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&dT.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const s=Ju();this.emit("languageChanging",t);const i=u=>{this.language=u,this.languages=this.services.languageUtils.toResolveHierarchy(u),this.resolvedLanguage=void 0,this.setResolvedLanguage(u)},a=(u,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(u,function(){return r.t(...arguments)})},l=u=>{!t&&!u&&this.services.languageDetector&&(u=[]);const d=wt(u)?u:this.services.languageUtils.getBestMatchFromCodes(u);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let u;if(typeof l!="object"){for(var d=arguments.length,f=new Array(d>2?d-2:0),c=2;c<d;c++)f[c-2]=arguments[c];u=s.options.overloadTranslationOptionHandler([a,l].concat(f))}else u={...l};u.lng=u.lng||i.lng,u.lngs=u.lngs||i.lngs,u.ns=u.ns||i.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let h;return u.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${u.keyPrefix}${p}${g}`):h=u.keyPrefix?`${u.keyPrefix}${p}${a}`:a,s.t(h,u)};return wt(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=this.services.backendConnector.state[`${l}|${u}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Ju();return this.options.ns?(wt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Ju();wt(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new $j(zj());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new pf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Up;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new pf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new Oj(this.store.data,s),i.services.resourceStore=i.store),i.translator=new bm(i.services,s),i.translator.on("*",function(l){for(var u=arguments.length,d=new Array(u>1?u-1:0),f=1;f<u;f++)d[f-1]=arguments[f];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Cr=pf.createInstance();Cr.createInstance=pf.createInstance;Cr.createInstance;Cr.dir;Cr.init;Cr.loadResources;Cr.reloadResources;Cr.use;Cr.changeLanguage;Cr.getFixedT;Cr.t;Cr.exists;Cr.setDefaultNamespace;Cr.hasLoadedNamespace;Cr.loadNamespaces;Cr.loadLanguages;function Pq(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hf(e){"@babel/helpers - typeof";return hf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hf(e)}function Aq(e,t){if(hf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(hf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Iq(e){var t=Aq(e,"string");return hf(t)=="symbol"?t:t+""}function Tq(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Iq(r.key),r)}}function Rq(e,t,n){return t&&Tq(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var fT=[],Lq=fT.forEach,Oq=fT.slice;function Mq(e){return Lq.call(Oq.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var Hj=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,$q=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!Hj.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!Hj.test(s.path))throw new TypeError("option path is invalid");a+="; Path=".concat(s.path)}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(s.expires.toUTCString())}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite){var u=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(u){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},Wj={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=$q(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},Dq={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=Wj.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&Wj.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},Fq={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var u=i[a].substring(0,l);u===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Qu=null,Vj=function(){if(Qu!==null)return Qu;try{Qu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qu=!1}return Qu},zq={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&Vj()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&Vj()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Zu=null,Uj=function(){if(Zu!==null)return Zu;try{Zu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zu=!1}return Zu},Bq={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&Uj()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&Uj()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},Hq={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},Wq={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},Vq={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},Uq={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},pT=!1;try{document.cookie,pT=!0}catch{}var hT=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];pT||hT.splice(1,1);function Kq(){return{order:hT,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var mT=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Pq(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return Rq(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=Mq(r,this.options||{},Kq()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(Dq),this.addDetector(Fq),this.addDetector(zq),this.addDetector(Bq),this.addDetector(Hq),this.addDetector(Wq),this.addDetector(Vq),this.addDetector(Uq)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();mT.type="languageDetector";const qq={name:"AgentFlow",tagline:"AI Workflow Orchestration"},Yq={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},Gq={loading:"Loading...",saving:"Saving...",save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",create:"Create",close:"Close",confirm:"Confirm",copy:"Copy",copied:"Copied!",refresh:"Refresh",search:"Search",filter:"Filter",success:"Success",error:"Error",warning:"Warning",info:"Info",done:"Done",pending:"Pending",running:"Running",notFound:"Not found",required:"Required",optional:"Optional"},Xq={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},Jq={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},Qq={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},Zq={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},eY={app:qq,nav:Yq,common:Gq,status:Xq,nodeTypes:Jq,engine:Qq,links:Zq},tY="Flow Editor",nY="Nodes",rY="Edges",sY="Properties",iY={label:"Node Label",type:"Node Type",model:"Model",body:"Body",inputs:"Inputs",outputs:"Outputs",addInput:"Add Input",addOutput:"Add Output",remove:"Remove Node",duplicate:"Duplicate Node",nodeType:"Node Type",displayName:"Display Name",displayNameHint:"(letters, numbers, underscores, hyphens, do not start with a number)",role:"Role",modelHint:"From ~/agentflow/model-lists.json; UI service runs agentflow update-model-lists in background on startup",defaultModel:"Default",userPrompt:"User Prompt (USER PROMPT / body)",systemDescription:"System Description (read-only, from node definition)",directCommand:"Direct Command (script)",scriptHint:"(tool_nodejs: skips AI when script exists, executed by pipeline)",diskRunning:"Disk record shows running",deleteNode:"Delete node",inputTooltip:"Input {{name}} | Type: {{type}}",outputTooltip:"Output {{name}} | Type: {{type}}",defaultSuffix:" | Default: {{value}}",fallbackLabel:"Node",expandProvide:"Edit content"},oY={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},aY={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},lY={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},cY={workspace:"Workspace",loading:"Loading...",archived:"Archived",noPipelines:"No pipelines",more:"more",moreFlows:"more flows",noRuns:"No run records",searchNodes:"Search nodes",noComponents:"No components available (check node library directory)",noMatch:"No matching nodes, adjust search terms",selectPipeline:"Select a pipeline from above to load components and canvas",validationWarnings:"Validation warnings (consistent with agentflow validate slot checks)",output:"Output",model:"Model",userDir:"User Directory",toggleRecentActivity:"Toggle recent opened or recent runs"},uY={selectPipeline:"Please select a pipeline from the dropdown above",loadingProps:"Loading node properties...",pipelineId:"Pipeline ID",diskPath:"Disk Path",storageLocation:"Storage Location",introduction:"Introduction",introductionPlaceholder:"Briefly describe this pipeline (saved as flow.yaml ui.description)",metadata:"Metadata",nodeCount:"Node Count",nodesUnit:"nodes",loading:"Loading...",noRuns:"No run records (run records are generated in the workspace after terminal execution)"},dY={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},fY={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},pY={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},hY={node:"Node",text:"Text",file:"File",bool:"Boolean"},mY={title:"Node Execution Context",resizeHandle:"Drag to resize node context width",apiConnectError:"Cannot connect to API (please open the page with agentflow ui, or configure /api proxy for Vite dev)",invalidJson:"Response is not valid JSON",requestTimeout:"Request timed out, please retry or check agentflow ui",executingNoArtifacts:"Executing, artifacts not yet written to workspace…",noData:"No data (this run has not reached this node or produced artifacts)",latest:"Latest",detectedContentType:"Detected content type",roundNoContent:"No content in this round",empty:"(empty)",imageTruncated:"Image truncated (exceeds size limit)",statusSuccess:"Success",statusFailed:"Failed",statusRunning:"Running",statusCacheMiss:"Cache miss",statusPending:"Pending"},gY={title:"Keyboard Shortcuts",general:"General",saveDesc:"Save; when node properties sidebar is open, submit node first then save flow",shortcutsLabel:"Keyboard Shortcuts",jumpToNode:"Jump to node by ID",openNodePalette:"Open node palette",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},yY={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},xY={title:"Start Building Your Flow",text:"Describe your workflow in the AI input box below, or drag nodes from the left panel to the canvas",composerHint:"Build AgentFlow with AI Composer",composerSub:"Drag nodes from the left panel, or describe your workflow in the <strong>input box below</strong>.<br/>Press <kbd>?</kbd> to view shortcuts."},wY={mainNav:"Main Navigation"},bY={flowWarningAriaLabel:"Flow validation warnings",reloadFromServer:"Reload flow from server and refresh validation",reloadFromServerShort:"Reload from server",closeBanner:"Close validation warning banner",nodePrefix:"Node",focusNodeAriaLabel:"Select and focus node {{nodeId}} on canvas",slotWarningCount:"Slot validation: {{count}} warnings (hidden)",show:"Show",shortcutHint:"Press ? to view keyboard shortcuts",shortcutHintLabel:"shortcuts",inputSlotNoEdge:' input slot "{{slotName}}" ({{handle}}) has no edge connection',outputSlotNoEdge:' output slot "{{slotName}}" ({{handle}}) has no edge connection'},vY={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
160
160
  {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
161
161
  Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},kY={currentPipeline:"Current Pipeline",backToEdit:"Back to edit",backToProjects:"Back to projects",executionLog:"Execution log",history:"History",pipelineSettings:"Pipeline settings",shortcutsLabel:"Shortcuts",shortcutsTitle:"Shortcuts (?)",deletePipeline:"Delete pipeline",resumeTitle:"Resume in same run directory (uuid={{uuid}})",resumeTitleNoUuid:"No apply-start received, will start a new run",rerunTitle:"Start a new run from scratch",runOptions:"Run options",runWithParams:"Run with params",runWithPreset:"Run with preset",editRun:"Edit run parameters",startRun:"Start run",stopRun:"Stop background run"},SY={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},NY={connectingApi:"Connecting to /api/flow/run…",connectingApiResume:"Connecting to /api/flow/run (resuming run uuid={{uuid}})…",connectedReceiving:"Connected to execution stream, receiving NDJSON output…",noBody:"Response has no body (cannot stream), please check browser and agentflow ui version",nodeStart:"▶ Starting: {{instanceId}}",nodeStartWithLabel:"▶ Starting: {{instanceId}} ({{label}})",nodeDone:"✓ Done: {{instanceId}}",nodeDoneWithElapsed:"✓ Done: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ Failed: {{instanceId}}",pipelineStart:"Pipeline started (uuid={{uuid}})",pipelineDone:"Pipeline completed",pipelineDoneWithElapsed:"Pipeline completed ({{elapsed}})",pipelinePaused:"Pipeline paused: waiting for user input ({{nodes}})",unknownError:"Unknown error",executionEnd:"Execution ended (exit code: {{exitCode}})",executionStopped:"Execution paused",pauseRun:"Pause run (can resume later)",pauseConfirm:"Pause the current run? You can resume from the interrupted node later.",pauseTitle:"Pause run",pauseConfirmOk:"Pause",backPromptTitle:"Back to projects",backPromptMessage:"Pipeline still running. Keep it in the background and exit, or stop it and return to edit mode?",backBackground:"Run in background & exit",backStopEdit:"Stop & enter edit",resizeConsole:"Drag to resize execution log height",closeLog:"Close log",userCheckContent:"Waiting for user to confirm content for node {{instanceId}}",userAskPrompt:"Waiting for user to choose branch for node {{instanceId}}"},jY={close:"Close",loading:"Loading…",placeholder:"File content",largeFileWarning:"Large file, editor performance may be affected",reset:"Reset",aiEdit:"AI Edit",aiRunning:"AI processing…",save:"Save",saving:"Saving…",saved:"Saved"},CY={title:"Pipeline Settings",subtitle:"Manage basic information, storage, node marketplace, scheduled runs, and metadata.",sectionNav:"Settings sections",basicInfo:"Basic Info",storageAndPath:"Storage & Path",nodeMarketplace:"Node Marketplace",overview:"Pipeline Overview",owner:"Owner",source:"Source",marketplaceNodes:"Marketplace nodes",marketNodesUnit:"market nodes",marketplaceHint:"Local marketplace nodes can be added to this pipeline; installed nodes can then be placed on the canvas.",marketplaceEmpty:"No local marketplace nodes are installed in this workspace yet. Publish one from the node properties panel.",addNodeFromMarket:"Back to canvas",quickActions:"Quick Actions",saveChanges:"Save changes",savingChanges:"Saving…",installNode:"Add to pipeline",installingNode:"Adding…",addInstalledNode:"Add to canvas",previewNode:"Preview",nodePreviewTitle:"Node preview",nodeStylePreview:"Node style preview",closePreview:"Close preview",nodeFunction:"Node purpose",nodePackageInfo:"Package info",definitionId:"Definition ID",version:"Version",packagePath:"Package path",packagedFiles:"Packaged files",marketplaceNoDescription:"No node purpose has been provided.",noInputs:"No inputs",noOutputs:"No outputs",backToCanvas:"Back to canvas",help:"Help",helpText:"Publish nodes from the node properties panel; installed collections sync into the local node marketplace.",archived:"Archived",archivedNote:"This pipeline is in the archive directory (_archived) and cannot be moved between user directory and workspace.",builtinNote:"Built-in templates are read-only; first save will write to workspace .workspace/agentflow/pipelines (pipelines), .workspace/agentflow/nodes (custom nodes), etc.",moveBusy:"Moving…",moveToWorkspace:"Move to workspace",moveToUserDir:"Move to user directory",globalSettings:"Global settings",currentPipeline:"Current pipeline:",builtin:"Built-in",rename:"Rename",renameBusy:"Renaming…",renameSuccess:"Renamed",copyPath:"Copy path",pathCopied:"Copied"},EY={title:"Scheduled Run",enabled:"Enable scheduled trigger",cron:"Cron expression",timezone:"Timezone",preset:"Run preset",defaultPreset:"Default inputs",overlapSkip:"Overlap policy: skip this trigger while the pipeline is running",nextRun:"Next estimated trigger: {{time}}",noNextRun:"No next trigger is configured",runtime:"Scheduler state",running:"Running",waiting:"Waiting",disabled:"Disabled",lastTriggeredAt:"Last triggered",lastSkippedAt:"Last skipped",lastRun:"Last run",lastExit:"Last exit code",lastFinishedAt:"Last finished",readonlyNote:"Built-in or archived pipelines cannot save schedule settings.",save:"Save schedule",saving:"Saving…",saved:"Schedule saved"},_Y={title:"Execution History",summary:"Execution results summary",successCount:"{{count}} succeeded",failedCount:"{{count}} failed",stoppedCount:"{{count}} stopped",interruptedCount:"{{count}} interrupted",runningCount:"{{count}} running",success:"Success",failed:"Failed",stopped:"Stopped",interrupted:"Interrupted",running:"Running",unknown:"Unknown",runLabel:"Run #{{id}}",enterRunView:"Enter run view with canvas and log"},PY={invalidInstanceId:"Invalid Instance ID: only letters, numbers, underscores, and hyphens allowed, must not start with a number.",duplicateInstanceId:"This Instance ID already exists, please choose another.",loadFlowFailed:"Failed to load flow",loadNodesFailed:"Failed to load node library"},AY={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},IY={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},TY={title:"User Confirmation ({{instanceId}})",edit:"Edit",save:"Save",cancel:"Cancel",aiEditPlaceholder:"Enter AI edit instruction, e.g., remove item 2, merge first two items…",aiEditBtn:"AI Edit",aiEditStarted:"AI is modifying content…",aiEditDone:"AI modification complete",aiEditFailed:"AI modification failed",contentSaved:"Content saved",saveFailed:"Save failed",close:"Close",continue:"Continue Execution",hint:"Edit or use AI to modify, then save. Click 'Continue Execution' to resume the flow"},RY={title:"User Choice ({{instanceId}})",hint:"Pick an option below to continue the flow",submitting:"Submitting…",submitFailed:"Submit failed",close:"Close",noOptions:"No options configured on this node. Add items to the output slots in the editor first."},LY={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},OY={save:"Save",cancel:"Cancel"},MY={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},$Y={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},DY={preset:"Preset",default:"Default",newPreset:"New preset",deletePreset:"Delete preset",presetNamePlaceholder:"Preset name",inputParams:"Input Parameters",noProvideNodes:"No provide nodes in this flow",filePathPlaceholder:"File path…",stringValuePlaceholder:"Value…",presetSaved:"Preset saved",presetDeleted:"Preset Deleted",savePreset:"Save current preset",expandInput:"Edit content"},FY={title:tY,nodes:nY,edges:rY,properties:sY,node:iY,nodeProps:oY,actions:aY,panel:lY,palette:cY,pipeline:uY,status:dY,roles:fY,phases:pY,types:hY,runContext:mY,shortcuts:gY,jumpPalette:yY,emptyCanvas:xY,sidebar:wY,validation:bY,composer:vY,topbar:kY,palette2:SY,run:NY,fileEdit:jY,settings:CY,schedule:EY,history:_Y,nodePropsError:PY,placeholder:AY,time:IY,userCheck:TY,userAsk:RY,toolPrint:LY,provideEdit:OY,runParams:MY,runPreset:$Y,runConfig:DY},zY="Settings",BY={engine:"Engine Settings",preferences:"Global Preferences"},HY={title:"Workspace",currentPath:"Current Workspace Root",placeholder:"Loading...",copyPath:"Copy path",description:"Pipelines and node lists are resolved relative to this directory (passed when starting the UI)."},WY={title:"Cursor CLI",status:{cached:"Cached",notCached:"Not cached"},modelPreviewLabel:"Cursor model id list",modelList:{cached:"Model list cached",empty:"No model list",count:"{{count}} items",fetchedAt:"Updated {{time}}",never:"Never fetched",refresh:"Refresh List",fetching:"Fetching..."}},VY={modelPreviewLabel:"OpenCode model id list",title:"OpenCode CLI",status:{ready:"Ready",notFound:"Not found"},provider:"Plan / Provider ID",providerPlaceholder:"e.g., bailian-coding-plan",saving:"Saving and updating list...",description:"Corresponds to CLI opencode models <provider> parameter; written to user directory config and triggers model-lists.json refresh after typing stops."},UY={title:"Claude Code CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Claude Code model id list",description:"Built-in model list (Claude Code CLI has no models subcommand); refresh probes the claude binary in PATH. Run 'claude /login' first."},KY={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",noteAdmin:"Configure personal or global env; personal values override global values",saving:"Saving...",key:"Key",value:"Value",scope:"Scope",personal:"Personal",global:"Global",add:"Add",delete:"Delete {{key}}",invalidKey:"Env key must start with a letter or underscore, and only contain letters, numbers, and underscores.",newKey:"New env key",newValue:"Value (be careful with secrets)"},qY={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},YY={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},GY={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},XY={title:"Onboarding Tour",description:"Restart the product tour to learn about AgentFlow's core features.",reset:"Reset Tour",resetSuccess:"Reset complete. Tour will start automatically on next visit."},JY={title:zY,crumb:BY,workspace:HY,cursor:WY,opencode:VY,claudeCode:UY,env:KY,system:qY,shortcuts:YY,language:GY,onboarding:XY},QY={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},ZY={input:"Ask AI to help edit this node...",waiting:"Waiting for response...",selectedEmpty:"Select a node on the canvas, or use @ in the input to select instances or node types",textarea:"Describe your workflow or ask AI to help (⌘/Ctrl+Enter to send)"},eG={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},tG={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},nG={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},rG={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},sG={aiLabels:QY,placeholders:ZY,actions:eG,labels:tG,tooltips:nG,rightPanel:rG},iG="Projects",oG="All",aG="Archived",lG="Nodes",cG="My Nodes",uG="My Flows",dG="Skills",fG="Active Projects",pG="Archived Pipelines",hG="Global Nodes",mG="Manage node versions published to the current workspace marketplace, {{count}} total.",gG="Manage flow snippets published to the current workspace marketplace, {{count}} total.",yG="Global Skills",xG="Create New Project",wG="New Pipeline",bG="SEARCH PIPELINES...",vG="SEARCH NODES...",kG="SEARCH FLOW SNIPPETS...",SG="SEARCH SKILLS...",NG="Refresh Resources",jG="Loading pipelines...",CG="Loading global resources...",EG="Filter result: {{count}} items (matching title, description, path and tags)",_G="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",PG="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",AG="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",IG="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",TG="Executable building blocks for pipeline runtime",RG="Nodes define what can be placed on the canvas, which inputs and outputs exist, and whether runtime behavior is agent, control, provide, or marketplace logic.",LG="Published local node packages",OG="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",MG="Published flow snippets",$G="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",DG="Operating guides for Composer and agents",FG="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",zG="No archived projects.",BG="No active pipelines; archived items are in the Archived tab.",HG="No global nodes available.",WG="No marketplace nodes have been published.",VG="No flow snippets have been published. Select multiple canvas nodes and publish them first.",UG="No skills available.",KG="No description.",qG='No node matches "{{query}}".',YG='No flow snippet matches "{{query}}".',GG='No skill matches "{{query}}".',XG="{{inputs}} in / {{outputs}} out",JG="Flow Snippet",QG="{{nodes}} nodes / {{edges}} edges",ZG="Skill",eX="Node detail",tX="Flow snippet detail",nX="Skill detail",rX="Type",sX="Source",iX="Package",oX="Version",aX="Path",lX="Editable",cX="Read only",uX="Editable",dX="Schema",fX="Inputs",pX="Outputs",hX="Runtime",mX="Node Body",gX="Files",yX="Usage",xX="No runtime manifest.",wX="No node body or README.",bX="No previewable files.",vX="Select a file to preview.",kX="Binary file preview is not supported.",SX="Large file; showing the first 256KB only.",NX="No pipelines using this node were found.",jX="Node Management",CX="Delete Node Version",EX="Deleting...",_X="AgentFlow checks all flow references before deleting; installed or used versions are kept.",PX="Delete {{id}}@{{version}}? This cannot be undone.",AX="Deleted {{id}}@{{version}}.",IX="{{count}} flow(s) still use it.",TX="Flow Snippet Management",RX="Delete Flow Snippet",LX="Deleting...",OX="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",MX="Delete {{id}}@{{version}}? This cannot be undone.",$X="Deleted {{id}}@{{version}}.",DX="No slots",FX="Purpose",zX="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",BX="A flow snippet is a reusable part of a fixed workflow. Loading it copies its nodes, edges, and layout into the current canvas without replacing existing content.",HX="Scale",WX="Flow Preview",VX="Edges",UX="Snippet JSON",KX="{{count}} more edge(s)",qX="No previewable nodes.",YX="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",GX="SKILL.md Preview",XX="No preview content available.",JX="Select a resource to inspect details.",QX="Failed to load pipeline list.",ZX="No pipelines in current workspace.",eJ="Run {{code1}} in the repository root and ensure the workspace contains {{code2}} or pipelines in the user directory; or click New Pipeline to create one.",tJ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',nJ="Recent Activity",rJ="No recent activity",sJ="No recent activity matching the keyword",iJ="Recent Run",oJ="Recent Open",aJ={builtin:"Built-in",workspace:"Workspace",user:"User"},lJ={flow:"Flow",global:"Global",marketplace:"Marketplace"},cJ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},uJ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},dJ="Open to edit this pipeline in the node canvas.",fJ={eyebrow:"AgentFlow Hub",title:"Browse community flows",desc:"Discover and install ready-made pipelines shared by the community.",cta:"Explore Hub",cliHint:"Or install via CLI: agentflow download <slug>"},pJ={title:"Create New Pipeline",lead:"Enter a pipeline name (English identifier); description is optional and will be saved in flow's ui.description.",nameLabel:"Name (required)",namePlaceholder:"e.g., my_feature_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",descLabel:"Description (optional)",descPlaceholder:"Briefly describe the purpose of this pipeline...",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",createFailed:"Creation failed",creating:"Creating...",createAndOpen:"Create and Open",cancel:"Cancel",close:"Close"},hJ={title:"Import Pipeline",lead:'File "{{filename}}" selected. Please confirm the pipeline name and save location; ZIP will preserve scripts and other files in the directory.',nameLabel:"Name (required)",namePlaceholder:"e.g., my_shared_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",changeFile:"Change File...",importFailed:"Import failed",importing:"Importing...",importAndOpen:"Import and Open",cancel:"Cancel",close:"Close"},mJ={title:"Delete Pipeline",lead:'This will permanently delete the pipeline directory from disk (including flow.yaml, scripts, etc.) and cannot be undone. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",deleteFailed:"Delete failed",deleteTimeout:"Delete request timed out, please retry (check UI service logs in terminal)",delete:"Delete",deleting:"Deleting...",confirmDelete:"Confirm Delete",cancel:"Cancel",close:"Close"},gJ={title:"Archive Pipeline",lead:'After archiving, the pipeline will be moved to the "Archived" list and can still be opened and edited from there. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",archiveFailed:"Archive failed",archive:"Archive",archiving:"Archiving...",confirmArchive:"Confirm Archive",cancel:"Cancel",close:"Close"},yJ={title:iG,all:oG,archived:aG,nodes:lG,myNodes:cG,myFlows:uG,skills:dG,activeProjects:fG,archivedPipelines:pG,globalNodes:hG,myNodesHint:mG,myFlowsHint:gG,globalSkills:yG,createNew:xG,newPipeline:wG,searchPipelines:bG,searchNodes:vG,searchFlows:kG,searchSkills:SG,refreshResources:NG,loadingPipelines:jG,loadingResources:CG,filterResult:EG,archivedHint:_G,activeHint:PG,nodesHint:AG,skillsHint:IG,nodesPurposeTitle:TG,nodesPurposeDesc:RG,myNodesPurposeTitle:LG,myNodesPurposeDesc:OG,myFlowsPurposeTitle:MG,myFlowsPurposeDesc:$G,skillsPurposeTitle:DG,skillsPurposeDesc:FG,noArchived:zG,noActive:BG,noNodes:HG,noMyNodes:WG,noMyFlows:VG,noSkills:UG,noDescription:KG,noNodeMatch:qG,noFlowSnippetMatch:YG,noSkillMatch:GG,nodeSlots:XG,flowSnippet:JG,flowSnippetNodes:QG,skill:ZG,nodeDetail:eX,flowDetail:tX,skillDetail:nX,detailType:rX,detailSource:sX,detailPackage:iX,detailVersion:oX,detailPath:aX,detailEditable:lX,readOnly:cX,editable:uX,nodeSchema:dX,nodeInputs:fX,nodeOutputs:pX,nodeRuntime:hX,nodeBody:mX,nodeFiles:gX,nodeUsage:yX,noRuntimeManifest:xX,noNodeBody:wX,noNodeFiles:bX,selectNodeFile:vX,binaryFile:kX,fileTruncated:SX,noNodeUsage:NX,myNodeManagement:jX,deleteMyNode:CX,deletingMyNode:EX,deleteMyNodeHint:_X,deleteMyNodeConfirm:PX,deleteMyNodeSuccess:AX,deleteMyNodeUsedBy:IX,myFlowManagement:TX,deleteMyFlow:RX,deletingMyFlow:LX,deleteMyFlowHint:OX,deleteMyFlowConfirm:MX,deleteMyFlowSuccess:$X,noSlots:DX,resourceMeaning:FX,nodesMeaning:zX,myFlowsMeaning:BX,flowSnippetScale:HX,flowSnippetPreview:WX,flowSnippetEdges:VX,flowSnippetJson:UX,flowSnippetMoreEdges:KX,noFlowSnippetPreview:qX,skillsMeaning:YX,skillPreview:GX,skillPreviewEmpty:XX,selectResource:JX,loadFailed:QX,noPipelines:ZX,emptyHint:eJ,noMatch:tJ,recentActivity:nJ,noRecentActivity:rJ,noMatchRecent:sJ,recentRun:iJ,recentOpen:oJ,sourceBadge:aJ,resourceSource:lJ,resourceFilter:cJ,nodeDetailTabs:uJ,defaultCardDesc:dJ,hubCard:fJ,newPipelineModal:pJ,importModal:hJ,deleteModal:mJ,archiveModal:gJ},xJ="Back",wJ="Next",bJ="Skip",vJ="Done",kJ="Start Creating",SJ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
162
162