@fieldwangai/agentflow 0.1.25 → 0.1.26

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.
@@ -110,23 +110,23 @@ script: node -e "console.log('TODO: scripts/x.mjs')"
110
110
  `;break}case-3:{s=`\r
111
111
  `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function LH(e){const r={constructs:B5([IH,...(e||{}).extensions||[]]),content:i(G5),defined:[],document:i(Q5),flow:i(mH),lazy:{},string:i(xH),text:i(wH)};return r;function i(o){return s;function s(a){return AH(r,o,a)}}}function OH(e){for(;!Ij(e););return e}const kb=/[\0\t\n\r]/g;function MH(){let e=1,t="",n=!0,r;return i;function i(o,s,a){const l=[];let u,f,d,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,t="",n&&(o.charCodeAt(0)===65279&&d++,n=void 0);d<o.length;){if(kb.lastIndex=d,u=kb.exec(o),p=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(p),!u){t=o.slice(d);break}if(h===10&&d===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<p&&(l.push(o.slice(d,p)),e+=p-d),h){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const DH=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FH(e){return e.replace(DH,$H)}function $H(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return Ej(n.slice(o?2:1),o?16:10)}return xx(n)||e}const Mj={}.hasOwnProperty;function zH(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),BH(n)(OH(LH(n).document().write(MH()(e,t,!0))))}function BH(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Dt),autolinkProtocol:M,autolinkEmail:M,atxHeading:o(Ke),blockQuote:o(Se),characterEscape:M,characterReference:M,codeFenced:o(ye),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(ye,s),codeText:o(ge,s),codeTextData:M,data:M,codeFlowValue:M,definition:o(xe),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o($e),hardBreakEscape:o(Le),hardBreakTrailing:o(Le),htmlFlow:o(mt,s),htmlFlowData:M,htmlText:o(mt,s),htmlTextData:M,image:o(_t),label:s,link:o(Dt),listItem:o(wr),listItemValue:p,listOrdered:o(Fn,d),listUnordered:o(Fn),paragraph:o(vr),reference:O,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Ke),strong:o(br),thematicBreak:o(gt)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:le,autolinkProtocol:J,blockQuote:l(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:ne,characterReference:ae,codeFenced:l(k),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:B,codeIndented:l(g),codeText:l(H),codeTextData:B,data:B,definition:l(),definitionDestinationString:N,definitionLabelString:w,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(V),htmlFlowData:B,htmlText:l(L),htmlTextData:B,image:l($),label:I,labelText:_,lineEnding:A,link:l(D),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:q,resourceDestinationString:C,resourceTitleString:F,resource:U,setextHeading:l(T),setextHeadingLineSequence:P,setextHeadingText:S,strong:l(),thematicBreak:l()}};Dj(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(G){let Q={type:"root",children:[]};const Ne={stack:[Q],tokenStack:[],config:t,enter:a,exit:u,buffer:s,resume:f,data:n},Ce=[];let Ie=-1;for(;++Ie<G.length;)if(G[Ie][1].type==="listOrdered"||G[Ie][1].type==="listUnordered")if(G[Ie][0]==="enter")Ce.push(Ie);else{const It=Ce.pop();Ie=i(G,It,Ie)}for(Ie=-1;++Ie<G.length;){const It=t[G[Ie][0]];Mj.call(It,G[Ie][1].type)&&It[G[Ie][1].type].call(Object.assign({sliceSerialize:G[Ie][2].sliceSerialize},Ne),G[Ie][1])}if(Ne.tokenStack.length>0){const It=Ne.tokenStack[Ne.tokenStack.length-1];(It[1]||Nb).call(Ne,void 0,It[0])}for(Q.position={start:_i(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:_i(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},Ie=-1;++Ie<t.transforms.length;)Q=t.transforms[Ie](Q)||Q;return Q}function i(G,Q,Ne){let Ce=Q-1,Ie=-1,It=!1,Ct,Vt,tn,Jn;for(;++Ce<=Ne;){const lt=G[Ce];switch(lt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{lt[0]==="enter"?Ie++:Ie--,Jn=void 0;break}case"lineEndingBlank":{lt[0]==="enter"&&(Ct&&!Jn&&!Ie&&!tn&&(tn=Ce),Jn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Jn=void 0}if(!Ie&&lt[0]==="enter"&&lt[1].type==="listItemPrefix"||Ie===-1&&lt[0]==="exit"&&(lt[1].type==="listUnordered"||lt[1].type==="listOrdered")){if(Ct){let cn=Ce;for(Vt=void 0;cn--;){const Ft=G[cn];if(Ft[1].type==="lineEnding"||Ft[1].type==="lineEndingBlank"){if(Ft[0]==="exit")continue;Vt&&(G[Vt][1].type="lineEndingBlank",It=!0),Ft[1].type="lineEnding",Vt=cn}else if(!(Ft[1].type==="linePrefix"||Ft[1].type==="blockQuotePrefix"||Ft[1].type==="blockQuotePrefixWhitespace"||Ft[1].type==="blockQuoteMarker"||Ft[1].type==="listItemIndent"))break}tn&&(!Vt||tn<Vt)&&(Ct._spread=!0),Ct.end=Object.assign({},Vt?G[Vt][1].start:lt[1].end),G.splice(Vt||Ce,0,["exit",Ct,lt[2]]),Ce++,Ne++}if(lt[1].type==="listItemPrefix"){const cn={type:"listItem",_spread:!1,start:Object.assign({},lt[1].start),end:void 0};Ct=cn,G.splice(Ce,0,["enter",cn,lt[2]]),Ce++,Ne++,tn=void 0,Jn=!0}}}return G[Q][1]._spread=It,Ne}function o(G,Q){return Ne;function Ne(Ce){a.call(this,G(Ce),Ce),Q&&Q.call(this,Ce)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(G,Q,Ne){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([Q,Ne||void 0]),G.position={start:_i(Q.start),end:void 0}}function l(G){return Q;function Q(Ne){G&&G.call(this,Ne),u.call(this,Ne)}}function u(G,Q){const Ne=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==G.type&&(Q?Q.call(this,G,Ce[0]):(Ce[1]||Nb).call(this,G,Ce[0]));else throw new Error("Cannot close `"+G.type+"` ("+Ol({start:G.start,end:G.end})+"): it’s not open");Ne.position.end=_i(G.end)}function f(){return $5(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(G){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function h(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=G}function m(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=G}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G.replace(/(\r?\n|\r)$/g,"")}function w(G){const Q=this.resume(),Ne=this.stack[this.stack.length-1];Ne.label=Q,Ne.identifier=Ys(this.sliceSerialize(G)).toLowerCase()}function y(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.title=G}function N(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.url=G}function E(G){const Q=this.stack[this.stack.length-1];if(!Q.depth){const Ne=this.sliceSerialize(G).length;Q.depth=Ne}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function P(G){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function M(G){const Ne=this.stack[this.stack.length-1].children;let Ce=Ne[Ne.length-1];(!Ce||Ce.type!=="text")&&(Ce=he(),Ce.position={start:_i(G.start),end:void 0},Ne.push(Ce)),this.stack.push(Ce)}function B(G){const Q=this.stack.pop();Q.value+=this.sliceSerialize(G),Q.position.end=_i(G.end)}function A(G){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ne=Q.children[Q.children.length-1];Ne.position.end=_i(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(M.call(this,G),B.call(this,G))}function R(){this.data.atHardBreak=!0}function V(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function L(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function H(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function D(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Q,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function $(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Q,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function _(G){const Q=this.sliceSerialize(G),Ne=this.stack[this.stack.length-2];Ne.label=FH(Q),Ne.identifier=Ys(Q).toLowerCase()}function I(){const G=this.stack[this.stack.length-1],Q=this.resume(),Ne=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ne.type==="link"){const Ce=G.children;Ne.children=Ce}else Ne.alt=Q}function C(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.url=G}function F(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.title=G}function U(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function q(G){const Q=this.resume(),Ne=this.stack[this.stack.length-1];Ne.label=Q,Ne.identifier=Ys(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function ee(G){this.data.characterReferenceType=G.type}function ne(G){const Q=this.sliceSerialize(G),Ne=this.data.characterReferenceType;let Ce;Ne?(Ce=Ej(Q,Ne==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=xx(Q);const Ie=this.stack[this.stack.length-1];Ie.value+=Ce}function ae(G){const Q=this.stack.pop();Q.position.end=_i(G.end)}function J(G){B.call(this,G);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(G)}function le(G){B.call(this,G);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(G)}function Se(){return{type:"blockquote",children:[]}}function ye(){return{type:"code",lang:null,meta:null,value:""}}function ge(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function Ke(){return{type:"heading",depth:0,children:[]}}function Le(){return{type:"break"}}function mt(){return{type:"html",value:""}}function _t(){return{type:"image",title:null,url:"",alt:null}}function Dt(){return{type:"link",title:null,url:"",children:[]}}function Fn(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function wr(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function vr(){return{type:"paragraph",children:[]}}function br(){return{type:"strong",children:[]}}function he(){return{type:"text",value:""}}function gt(){return{type:"thematicBreak"}}}function _i(e){return{line:e.line,column:e.column,offset:e.offset}}function Dj(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Dj(e,r):HH(e,r)}}function HH(e,t){let n;for(n in t)if(Mj.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Nb(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ol({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ol({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ol({start:t.start,end:t.end})+") is still open")}function UH(e){const t=this;t.parser=n;function n(r){return zH(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function VH(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function WH(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
112
112
  `}]}function KH(e,t){const n=t.value?t.value+`
113
- `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function YH(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qH(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GH(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=va(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=o+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function XH(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QH(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Fj(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const s=i[i.length-1];return s&&s.type==="text"?s.value+=r:i.push({type:"text",value:r}),i}function JH(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Fj(e,t);const i={src:va(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function ZH(e,t){const n={src:va(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function e8(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function t8(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Fj(e,t);const i={href:va(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function n8(e,t){const n={href:va(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r8(e,t,n){const r=e.all(t),i=n?i8(n):$j(t),o={},s=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(i||a!==0||f.type!=="element"||f.tagName!=="p")&&s.push({type:"text",value:`
113
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function YH(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qH(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GH(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=va(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let s,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=o+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function XH(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QH(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Fj(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const s=i[i.length-1];return s&&s.type==="text"?s.value+=r:i.push({type:"text",value:r}),i}function JH(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Fj(e,t);const i={src:va(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function ZH(e,t){const n={src:va(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function e6(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function t6(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Fj(e,t);const i={href:va(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function n6(e,t){const n={href:va(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r6(e,t,n){const r=e.all(t),i=n?i6(n):$j(t),o={},s=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(i||a!==0||f.type!=="element"||f.tagName!=="p")&&s.push({type:"text",value:`
114
114
  `}),f.type==="element"&&f.tagName==="p"&&!i?s.push(...f.children):s.push(f)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&s.push({type:"text",value:`
115
- `});const u={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,u),e.applyData(t,u)}function i8(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=$j(n[r])}return t}function $j(e){const t=e.spread;return t??e.children.length>1}function o8(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const s=r[i];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function s8(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a8(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function l8(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function c8(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),i.push(s)}if(n.length>0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=hx(t.children[1]),l=wj(t.children[t.children.length-1]);a&&l&&(s.position={start:a,end:l}),i.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function u8(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const d=t.children[l],p={},h=s?s[l]:void 0;h&&(p.align=h);let m={type:"element",tagName:o,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function d8(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Cb=9,Eb=32;function f8(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(jb(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(jb(t.slice(i),i>0,!1)),o.join("")}function jb(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===Cb||o===Eb;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===Cb||o===Eb;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function p8(e,t){const n={type:"text",value:f8(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function h8(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const m8={blockquote:VH,break:WH,code:KH,delete:YH,emphasis:qH,footnoteReference:GH,heading:XH,html:QH,imageReference:JH,image:ZH,inlineCode:e8,linkReference:t8,link:n8,listItem:r8,list:o8,paragraph:s8,root:a8,strong:l8,table:c8,tableCell:d8,tableRow:u8,text:p8,thematicBreak:h8,toml:Ju,yaml:Ju,definition:Ju,footnoteDefinition:Ju};function Ju(){}const zj=-1,lp=0,Dl=1,wf=2,bx=3,Sx=4,kx=5,Nx=6,Bj=7,Hj=8,Pb=typeof self=="object"?self:globalThis,g8=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,s]=t[i];switch(o){case lp:case zj:return n(s,i);case Dl:{const a=n([],i);for(const l of s)a.push(r(l));return a}case wf:{const a=n({},i);for(const[l,u]of s)a[r(l)]=r(u);return a}case bx:return n(new Date(s),i);case Sx:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case kx:{const a=n(new Map,i);for(const[l,u]of s)a.set(r(l),r(u));return a}case Nx:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case Bj:{const{name:a,message:l}=s;return n(new Pb[a](l),i)}case Hj:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new Pb[o](s),i)};return r},_b=e=>g8(new Map,e)(0),gs="",{toString:y8}={},{keys:x8}=Object,ul=e=>{const t=typeof e;if(t!=="object"||!e)return[lp,t];const n=y8.call(e).slice(8,-1);switch(n){case"Array":return[Dl,gs];case"Object":return[wf,gs];case"Date":return[bx,gs];case"RegExp":return[Sx,gs];case"Map":return[kx,gs];case"Set":return[Nx,gs];case"DataView":return[Dl,n]}return n.includes("Array")?[Dl,n]:n.includes("Error")?[Bj,n]:[wf,n]},Zu=([e,t])=>e===lp&&(t==="function"||t==="symbol"),w8=(e,t,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=ul(s);switch(a){case lp:{let f=s;switch(l){case"bigint":a=Hj,f=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([zj],s)}return i([a,f],s)}case Dl:{if(l){let p=s;return l==="DataView"?p=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(s)),i([l,[...p]],s)}const f=[],d=i([a,f],s);for(const p of s)f.push(o(p));return d}case wf:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const f=[],d=i([a,f],s);for(const p of x8(s))(e||!Zu(ul(s[p])))&&f.push([o(p),o(s[p])]);return d}case bx:return i([a,s.toISOString()],s);case Sx:{const{source:f,flags:d}=s;return i([a,{source:f,flags:d}],s)}case kx:{const f=[],d=i([a,f],s);for(const[p,h]of s)(e||!(Zu(ul(p))||Zu(ul(h))))&&f.push([o(p),o(h)]);return d}case Nx:{const f=[],d=i([a,f],s);for(const p of s)(e||!Zu(ul(p)))&&f.push(o(p));return d}}const{message:u}=s;return i([a,{name:l,message:u}],s)};return o},Ib=(e,{json:t,lossy:n}={})=>{const r=[];return w8(!(t||n),!!t,new Map,r)(e),r},vf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_b(Ib(e,t)):structuredClone(e):(e,t)=>_b(Ib(e,t));function v8(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function b8(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function S8(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||v8,r=e.options.footnoteBackLabel||b8,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),p=va(d.toLowerCase());let h=0;const m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++h<=v;){m.length>0&&m.push({type:"text",value:" "});let w=typeof n=="string"?n:n(l,h);typeof w=="string"&&(w={type:"text",value:w}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(w)?w:[w]})}const k=f[f.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const w=k.children[k.children.length-1];w&&w.type==="text"?w.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...m)}else f.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(u,g),a.push(g)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...vf(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
115
+ `});const u={type:"element",tagName:"li",properties:o,children:s};return e.patch(t,u),e.applyData(t,u)}function i6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=$j(n[r])}return t}function $j(e){const t=e.spread;return t??e.children.length>1}function o6(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const s=r[i];if(s.type==="element"&&s.tagName==="li"&&s.properties&&Array.isArray(s.properties.className)&&s.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function s6(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a6(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function l6(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function c6(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const s={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],s),i.push(s)}if(n.length>0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=hx(t.children[1]),l=wj(t.children[t.children.length-1]);a&&l&&(s.position={start:a,end:l}),i.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function u6(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const d=t.children[l],p={},h=s?s[l]:void 0;h&&(p.align=h);let m={type:"element",tagName:o,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),u.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function d6(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Cb=9,Eb=32;function f6(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(jb(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(jb(t.slice(i),i>0,!1)),o.join("")}function jb(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===Cb||o===Eb;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===Cb||o===Eb;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function p6(e,t){const n={type:"text",value:f6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function h6(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const m6={blockquote:VH,break:WH,code:KH,delete:YH,emphasis:qH,footnoteReference:GH,heading:XH,html:QH,imageReference:JH,image:ZH,inlineCode:e6,linkReference:t6,link:n6,listItem:r6,list:o6,paragraph:s6,root:a6,strong:l6,table:c6,tableCell:d6,tableRow:u6,text:p6,thematicBreak:h6,toml:Ju,yaml:Ju,definition:Ju,footnoteDefinition:Ju};function Ju(){}const zj=-1,lp=0,Dl=1,wf=2,bx=3,Sx=4,kx=5,Nx=6,Bj=7,Hj=8,Pb=typeof self=="object"?self:globalThis,g6=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,s]=t[i];switch(o){case lp:case zj:return n(s,i);case Dl:{const a=n([],i);for(const l of s)a.push(r(l));return a}case wf:{const a=n({},i);for(const[l,u]of s)a[r(l)]=r(u);return a}case bx:return n(new Date(s),i);case Sx:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case kx:{const a=n(new Map,i);for(const[l,u]of s)a.set(r(l),r(u));return a}case Nx:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case Bj:{const{name:a,message:l}=s;return n(new Pb[a](l),i)}case Hj:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new Pb[o](s),i)};return r},_b=e=>g6(new Map,e)(0),gs="",{toString:y6}={},{keys:x6}=Object,ul=e=>{const t=typeof e;if(t!=="object"||!e)return[lp,t];const n=y6.call(e).slice(8,-1);switch(n){case"Array":return[Dl,gs];case"Object":return[wf,gs];case"Date":return[bx,gs];case"RegExp":return[Sx,gs];case"Map":return[kx,gs];case"Set":return[Nx,gs];case"DataView":return[Dl,n]}return n.includes("Array")?[Dl,n]:n.includes("Error")?[Bj,n]:[wf,n]},Zu=([e,t])=>e===lp&&(t==="function"||t==="symbol"),w6=(e,t,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=ul(s);switch(a){case lp:{let f=s;switch(l){case"bigint":a=Hj,f=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([zj],s)}return i([a,f],s)}case Dl:{if(l){let p=s;return l==="DataView"?p=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(s)),i([l,[...p]],s)}const f=[],d=i([a,f],s);for(const p of s)f.push(o(p));return d}case wf:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const f=[],d=i([a,f],s);for(const p of x6(s))(e||!Zu(ul(s[p])))&&f.push([o(p),o(s[p])]);return d}case bx:return i([a,s.toISOString()],s);case Sx:{const{source:f,flags:d}=s;return i([a,{source:f,flags:d}],s)}case kx:{const f=[],d=i([a,f],s);for(const[p,h]of s)(e||!(Zu(ul(p))||Zu(ul(h))))&&f.push([o(p),o(h)]);return d}case Nx:{const f=[],d=i([a,f],s);for(const p of s)(e||!Zu(ul(p)))&&f.push(o(p));return d}}const{message:u}=s;return i([a,{name:l,message:u}],s)};return o},Ib=(e,{json:t,lossy:n}={})=>{const r=[];return w6(!(t||n),!!t,new Map,r)(e),r},vf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_b(Ib(e,t)):structuredClone(e):(e,t)=>_b(Ib(e,t));function v6(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function b6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function S6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||v6,r=e.options.footnoteBackLabel||b6,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),p=va(d.toLowerCase());let h=0;const m=[],v=e.footnoteCounts.get(d);for(;v!==void 0&&++h<=v;){m.length>0&&m.push({type:"text",value:" "});let w=typeof n=="string"?n:n(l,h);typeof w=="string"&&(w={type:"text",value:w}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(w)?w:[w]})}const k=f[f.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const w=k.children[k.children.length-1];w&&w.type==="text"?w.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...m)}else f.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(u,g),a.push(g)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...vf(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
116
116
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
117
- `}]}}const Uj=function(e){if(e==null)return E8;if(typeof e=="function")return cp(e);if(typeof e=="object")return Array.isArray(e)?k8(e):N8(e);if(typeof e=="string")return C8(e);throw new Error("Expected function, string, or object as test")};function k8(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Uj(e[n]);return cp(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function N8(e){const t=e;return cp(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function C8(e){return cp(t);function t(n){return n&&n.type===e}}function cp(e){return t;function t(n,r,i){return!!(j8(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function E8(){return!0}function j8(e){return e!==null&&typeof e=="object"&&"type"in e}const Vj=[],P8=!0,Ab=!1,_8="skip";function I8(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Uj(i),s=r?-1:1;a(e,void 0,[])();function a(l,u,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Vj,m,v,k;if((!t||o(l,u,f[f.length-1]||void 0))&&(h=A8(n(l,f)),h[0]===Ab))return h;if("children"in l&&l.children){const g=l;if(g.children&&h[0]!==_8)for(v=(r?g.children.length:-1)+s,k=f.concat(g);v>-1&&v<g.children.length;){const w=g.children[v];if(m=a(w,v,k)(),m[0]===Ab)return m;v=typeof m[1]=="number"?m[1]:v+s}}return h}}}function A8(e){return Array.isArray(e)?e:typeof e=="number"?[P8,e]:e==null?Vj:[e]}function Wj(e,t,n,r){let i,o,s;typeof t=="function"&&typeof n!="function"?(o=void 0,s=t,i=n):(o=t,s=n,i=r),I8(e,o,a,i);function a(l,u){const f=u[u.length-1],d=f?f.children.indexOf(l):void 0;return s(l,d,f)}}const Dg={}.hasOwnProperty,T8={};function R8(e,t){const n=t||T8,r=new Map,i=new Map,o=new Map,s={...m8,...n.handlers},a={all:u,applyData:O8,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:s,one:l,options:n,patch:L8,wrap:D8};return Wj(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),a;function l(f,d){const p=f.type,h=a.handlers[p];if(Dg.call(a.handlers,p)&&h)return h(a,f,d);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in f){const{children:v,...k}=f,g=vf(k);return g.children=a.all(f),g}return vf(f)}return(a.options.unknownHandler||M8)(a,f,d)}function u(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=a.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Tb(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Tb(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function L8(e,t){e.position&&(t.position=y5(e))}function O8(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&o&&Object.assign(n.properties,vf(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function M8(e,t){const n=t.data||{},r="value"in t&&!(Dg.call(n,"hProperties")||Dg.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function D8(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
117
+ `}]}}const Uj=function(e){if(e==null)return E6;if(typeof e=="function")return cp(e);if(typeof e=="object")return Array.isArray(e)?k6(e):N6(e);if(typeof e=="string")return C6(e);throw new Error("Expected function, string, or object as test")};function k6(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Uj(e[n]);return cp(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function N6(e){const t=e;return cp(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function C6(e){return cp(t);function t(n){return n&&n.type===e}}function cp(e){return t;function t(n,r,i){return!!(j6(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function E6(){return!0}function j6(e){return e!==null&&typeof e=="object"&&"type"in e}const Vj=[],P6=!0,Ab=!1,_6="skip";function I6(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Uj(i),s=r?-1:1;a(e,void 0,[])();function a(l,u,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Vj,m,v,k;if((!t||o(l,u,f[f.length-1]||void 0))&&(h=A6(n(l,f)),h[0]===Ab))return h;if("children"in l&&l.children){const g=l;if(g.children&&h[0]!==_6)for(v=(r?g.children.length:-1)+s,k=f.concat(g);v>-1&&v<g.children.length;){const w=g.children[v];if(m=a(w,v,k)(),m[0]===Ab)return m;v=typeof m[1]=="number"?m[1]:v+s}}return h}}}function A6(e){return Array.isArray(e)?e:typeof e=="number"?[P6,e]:e==null?Vj:[e]}function Wj(e,t,n,r){let i,o,s;typeof t=="function"&&typeof n!="function"?(o=void 0,s=t,i=n):(o=t,s=n,i=r),I6(e,o,a,i);function a(l,u){const f=u[u.length-1],d=f?f.children.indexOf(l):void 0;return s(l,d,f)}}const Dg={}.hasOwnProperty,T6={};function R6(e,t){const n=t||T6,r=new Map,i=new Map,o=new Map,s={...m6,...n.handlers},a={all:u,applyData:O6,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:s,one:l,options:n,patch:L6,wrap:D6};return Wj(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),a;function l(f,d){const p=f.type,h=a.handlers[p];if(Dg.call(a.handlers,p)&&h)return h(a,f,d);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in f){const{children:v,...k}=f,g=vf(k);return g.children=a.all(f),g}return vf(f)}return(a.options.unknownHandler||M6)(a,f,d)}function u(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=a.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Tb(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Tb(v.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function L6(e,t){e.position&&(t.position=y5(e))}function O6(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const s="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:s}}n.type==="element"&&o&&Object.assign(n.properties,vf(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function M6(e,t){const n=t.data||{},r="value"in t&&!(Dg.call(n,"hProperties")||Dg.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function D6(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
118
118
  `});++r<e.length;)r&&n.push({type:"text",value:`
119
119
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
120
- `}),n}function Tb(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Rb(e,t){const n=R8(e,t),r=n.one(e,void 0),i=S8(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
121
- `},i),o}function F8(e,t){return e&&"run"in e?async function(n,r){const i=Rb(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Rb(n,{file:r,...e||t})}}function Lb(e){if(e)throw e}var Ed=Object.prototype.hasOwnProperty,Kj=Object.prototype.toString,Ob=Object.defineProperty,Mb=Object.getOwnPropertyDescriptor,Db=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Kj.call(t)==="[object Array]"},Fb=function(t){if(!t||Kj.call(t)!=="[object Object]")return!1;var n=Ed.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Ed.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||Ed.call(t,i)},$b=function(t,n){Ob&&n.name==="__proto__"?Ob(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},zb=function(t,n){if(n==="__proto__")if(Ed.call(t,n)){if(Mb)return Mb(t,n).value}else return;return t[n]},$8=function e(){var t,n,r,i,o,s,a=arguments[0],l=1,u=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(t=arguments[l],t!=null)for(n in t)r=zb(a,n),i=zb(t,n),a!==i&&(f&&i&&(Fb(i)||(o=Db(i)))?(o?(o=!1,s=r&&Db(r)?r:[]):s=r&&Fb(r)?r:{},$b(a,{name:n,newValue:e(f,s,i)})):typeof i<"u"&&$b(a,{name:n,newValue:i}));return a};const $h=ro($8);function Fg(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function z8(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...i);function a(l,...u){const f=e[++o];let d=-1;if(l){s(l);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,f?B8(f,a)(...u):s(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function B8(e,t){let n;return r;function r(...s){const a=e.length>s.length;let l;a&&s.push(i);try{l=e.apply(this,s)}catch(u){const f=u;if(a&&n)throw f;return i(f)}a||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(s,...a){n||(n=!0,t(s,...a))}function o(s){i(null,s)}}const Ar={basename:H8,dirname:U8,extname:V8,join:W8,sep:"/"};function H8(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fc(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function U8(e){if(Fc(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function V8(e){Fc(e);let t=e.length,n=-1,r=0,i=-1,o=0,s;for(;t--;){const a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function W8(...e){let t=-1,n;for(;++t<e.length;)Fc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":K8(n)}function K8(e){Fc(e);const t=e.codePointAt(0)===47;let n=Y8(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Y8(e,t){let n="",r=0,i=-1,o=0,s=-1,a,l;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,o=0}else a===46&&o>-1?o++:o=-1}return n}function Fc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const q8={cwd:G8};function G8(){return"/"}function $g(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function X8(e){if(typeof e=="string")e=new URL(e);else if(!$g(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Q8(e)}function Q8(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const zh=["history","path","basename","stem","extname","dirname"];class Yj{constructor(t){let n;t?$g(t)?n={path:t}:typeof t=="string"||J8(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":q8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zh.length;){const o=zh[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)zh.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ar.basename(this.path):void 0}set basename(t){Hh(t,"basename"),Bh(t,"basename"),this.path=Ar.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ar.dirname(this.path):void 0}set dirname(t){Bb(this.basename,"dirname"),this.path=Ar.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ar.extname(this.path):void 0}set extname(t){if(Bh(t,"extname"),Bb(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ar.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){$g(t)&&(t=X8(t)),Hh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ar.basename(this.path,this.extname):void 0}set stem(t){Hh(t,"stem"),Bh(t,"stem"),this.path=Ar.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new en(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Bh(e,t){if(e&&e.includes(Ar.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ar.sep+"`")}function Hh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Bb(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function J8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Z8=function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},e6={}.hasOwnProperty;class Cx extends Z8{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=z8()}copy(){const t=new Cx;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data($h(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Wh("data",this.frozen),this.namespace[t]=n,this):e6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Wh("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ed(t),r=this.parser||this.Parser;return Uh("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Uh("process",this.parser||this.Parser),Vh("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){const a=ed(t),l=r.parse(a);r.run(l,a,function(f,d,p){if(f||!d||!p)return u(f);const h=d,m=r.stringify(h,p);r6(m)?p.value=m:p.result=m,u(f,p)});function u(f,d){f||!d?s(f):o?o(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Uh("processSync",this.parser||this.Parser),Vh("processSync",this.compiler||this.Compiler),this.process(t,i),Ub("processSync","process",n),r;function i(o,s){n=!0,Lb(o),r=s}}run(t,n,r){Hb(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,a){const l=ed(n);i.run(t,l,u);function u(f,d,p){const h=d||t;f?a(f):s?s(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),Ub("runSync","run",r),i;function o(s,a){Lb(s),i=a,r=!0}}stringify(t,n){this.freeze();const r=ed(n),i=this.compiler||this.Compiler;return Vh("stringify",i),Hb(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Wh("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,d)}else s(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function s(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=$h(!0,i.settings,u.settings))}function a(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];o(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...f]);else if(f.length>0){let[h,...m]=f;const v=r[p][1];Fg(v)&&Fg(h)&&(h=$h(!0,v,h)),r[p]=[u,h,...m]}}}}const t6=new Cx().freeze();function Uh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Vh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Wh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Hb(e){if(!Fg(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ub(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ed(e){return n6(e)?e:new Yj(e)}function n6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function r6(e){return typeof e=="string"||i6(e)}function i6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const o6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Vb=[],Wb={allowDangerousHtml:!0},s6=/^(https?|ircs?|mailto|xmpp)$/i,a6=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function qj(e){const t=l6(e),n=c6(e);return u6(t.runSync(t.parse(n),n),e)}function l6(e){const t=e.rehypePlugins||Vb,n=e.remarkPlugins||Vb,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Wb}:Wb;return t6().use(UH).use(n).use(F8,r).use(t)}function c6(e){const t=e.children||"",n=new Yj;return typeof t=="string"&&(n.value=t),n}function u6(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||d6;for(const f of a6)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+o6+f.id,void 0);return Wj(e,u),S5(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return s?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Mh)if(Object.hasOwn(Mh,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],v=Mh[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=l(String(m||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):o?o.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return a&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function d6(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||s6.test(e.slice(0,t))?e:""}function Ex(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 f6(e){const t=Ex(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 Gj(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Kb({text:e}){const{t}=rt(),n=e||"";return n.trim()?c.jsx("div",{className:"af-run-ctx-md",children:c.jsx(qj,{children:n})}):c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Yb({o:e}){var r;const{t}=rt(),n=Ex(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return c.jsxs("div",{className:"af-run-ctx-media",children:[c.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return c.jsx("pre",{className:"af-run-ctx-pre",children:Gj(e.content||"")});if(n==="markdown"){const i=e.content||"";return i.trim()?c.jsx("div",{className:"af-run-ctx-md",children:c.jsx(qj,{children:i})}):c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return c.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function qb(e){return f6(e)}function Gb(e){var r;if(!e)return null;const t=Ex(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"?Gj(String(n)):String(n)}function Xb({text:e,title:t,copiedLabel:n}){const[r,i]=x.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),i(!0),window.setTimeout(()=>i(!1),1400)}catch{}};return c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:c.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Qb=2e4,Xj="af:run-node-ctx-width";function jd(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Fi(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):Fi(jd())}function p6(){try{const e=localStorage.getItem(Xj);if(e==null)return Fi(jd());const t=parseInt(e,10);return Number.isFinite(t)?Fi(t):Fi(jd())}catch{return Fi(jd())}}async function Jb(e,t,n,r){const i=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&i.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${i.toString()}`,{signal:r}),s=await o.text();let a;try{a=JSON.parse(s)}catch{throw new Error(s.startsWith("<!")||s.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(a.error||"HTTP "+o.status);return a}function h6(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function m6({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:i}){const{t:o}=rt(),[s,a]=x.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[l,u]=x.useState(p6),f=x.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[d,p]=x.useState(!0),[h,m]=x.useState(""),[v,k]=x.useState([]),[g,w]=x.useState(null),[y,N]=x.useState(null),E=x.useRef(null),S=x.useRef(null),P=x.useRef(0),T=x.useRef(0);x.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),I=()=>a(_.matches);return _.addEventListener("change",I),()=>_.removeEventListener("change",I)},[]),x.useEffect(()=>{function _(){u(I=>Fi(I))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const M=x.useCallback(()=>{u(_=>{const I=Fi(_);try{localStorage.setItem(Xj,String(I))}catch{}return I})},[]),B=x.useCallback(_=>{if(s||_.button!==0)return;_.preventDefault();const I=_.currentTarget;f.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:l},I.setPointerCapture(_.pointerId)},[s,l]),A=x.useCallback(_=>{const I=f.current;if(!I.active||_.pointerId!==I.pointerId)return;const C=I.startX-_.clientX;u(Fi(I.startW+C))},[]),R=x.useCallback(_=>{const I=f.current;if(!(!I.active||_.pointerId!==I.pointerId)){I.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}M()}},[M]),V=x.useCallback(()=>{const _=f.current;_.active&&(_.active=!1,M())},[M]),L=x.useCallback(_=>{const I=Array.isArray(_)?_:[];k(I),w(C=>C&&I.some(F=>F.execId===C)?C:I.length>0?I[I.length-1].execId:null)},[]),H=x.useCallback(()=>{if(!e||!t)return;const _=++P.current,I=new AbortController,C=window.setTimeout(()=>I.abort(),Qb);(async()=>{try{const F=await Jb(t,e,n,I.signal);if(_!==P.current)return;L(Array.isArray(F.rounds)?F.rounds:[])}catch{}finally{window.clearTimeout(C)}})()},[e,t,n,L]);x.useEffect(()=>{if(!e||!t){p(!1),m(""),k([]);return}const _=++T.current;p(!0),m(""),k([]),w(null);const I=new AbortController,C=window.setTimeout(()=>I.abort(),Qb);return(async()=>{try{const F=await Jb(t,e,n,I.signal);if(_!==T.current)return;L(Array.isArray(F.rounds)?F.rounds:[])}catch(F){if(_!==T.current)return;const U=(F==null?void 0:F.name)==="AbortError"?"requestTimeout":F.message||String(F);m(U)}finally{window.clearTimeout(C),_===T.current&&p(!1)}})(),()=>{I.abort(),T.current++,P.current++}},[e,t,n,L]),x.useEffect(()=>{r&&H()},[r,H]),x.useEffect(()=>{clearInterval(S.current);const _=v.length>0?v[v.length-1]:null;return(r==="running"&&v.length===0||!!(_&&_.status==="running"))&&e&&t&&(S.current=setInterval(()=>H(),2e3)),()=>clearInterval(S.current)},[v,e,t,n,r,H]),x.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[g]);const D=v.find(_=>_.execId===g),$=s?void 0:{width:`${l}px`};return c.jsxs("aside",{className:"af-run-ctx-panel",style:$,"aria-label":o("flow:runContext.title"),children:[s?null:c.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:B,onPointerMove:A,onPointerUp:R,onPointerCancel:R,onLostPointerCapture:V}),c.jsxs("div",{className:"af-run-ctx-panel__main",children:[c.jsxs("div",{className:"af-run-ctx-head",children:[c.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:i,"aria-label":o("common:common.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),d&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),h&&c.jsx("div",{className:"af-run-ctx-error",children:h6(o,h)}),!d&&!h&&v.length===0&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),v.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+y6((D==null?void 0:D.status)||""),children:[c.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),c.jsx("select",{className:"af-run-ctx-round-select",value:String(g??""),onChange:_=>{const I=_.target.value;w(I==="latest"?"latest":Number(I))},children:[...v].reverse().map(_=>{const I=_.execId==="latest"?o("flow:runContext.latest"):`#${_.execId}`,C=x6(o,_.status),F=_.finishedAt?` · ${g6(_.finishedAt)}`:"";return c.jsx("option",{value:String(_.execId),children:`${I} · ${C}${F}`},_.execId)})})]}),D&&c.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[D.inputs&&D.inputs.length>0&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),D.inputs.map((_,I)=>c.jsxs("div",{className:"af-run-ctx-output-slot",children:[c.jsx("div",{className:"af-run-ctx-slot-head",children:c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot})}),c.jsx("pre",{className:"af-run-ctx-slot-text",children:_.value})]},`${_.slot}-${I}`))]}),D.prompt!=null&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:o("flow:nodeProps.expand"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),c.jsx(Kb,{text:D.prompt})]}),D.outputs&&D.outputs.length>0&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:o("flow:nodeProps.expand"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),D.outputs.map((_,I)=>{const C=qb(_),F=Gb(_);return c.jsxs("div",{className:"af-run-ctx-output-slot",children:[c.jsxs("div",{className:"af-run-ctx-slot-head",children:[c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),C?c.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:C}):null,c.jsx(Xb,{text:F,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),c.jsx(Yb,{o:_})]},`${_.slot}-${I}`)})]}),!D.prompt&&(!D.outputs||D.outputs.length===0)&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),y&&D&&c.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:_=>{_.target===_.currentTarget&&N(null)},children:c.jsxs("div",{className:"af-node-props-expand-panel",children:[c.jsxs("div",{className:"af-node-props-expand-head",children:[c.jsx("span",{className:"af-node-props-expand-title",children:y==="prompt"?"Prompt":"Outputs"}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":o("common:common.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[y==="prompt"&&D.prompt!=null&&c.jsx(Kb,{text:D.prompt}),y==="output"&&D.outputs&&D.outputs.map((_,I)=>{const C=qb(_),F=Gb(_);return c.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[c.jsxs("div",{className:"af-run-ctx-slot-head",children:[c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),C?c.jsx("span",{className:"af-run-ctx-format-badge",children:C}):null,c.jsx(Xb,{text:F,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),c.jsx(Yb,{o:_})]},`${_.slot}-${I}`)})]})]})})]})}function g6(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 y6(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 x6(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 w6({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:i,nodes:o,onCliInputsChange:s,onBackToEdit:a}){const{t:l}=rt(),[u,f]=x.useState({}),[d,p]=x.useState(null),[h,m]=x.useState({}),[v,k]=x.useState(!0),[g,w]=x.useState(!1),[y,N]=x.useState(""),[E,S]=x.useState(!1),[P,T]=x.useState(null),M=x.useRef(null),B=x.useRef(!0),A=x.useRef({});x.useMemo(()=>{var C,F,U;const I={};for(const O of r){const q=(U=(F=(C=O.data)==null?void 0:C.outputs)==null?void 0:F[0])==null?void 0:U.default;q!=null&&q!==""&&(I[O.id]=String(q))}return A.current=I,I},[r]);const R=x.useMemo(()=>{var C;const I={};for(const F of o){if(!((C=F.data)!=null&&C.inputs))continue;const U=F.data.inputs;for(let O=0;O<U.length;O++){const q=U[O];if(!(q!=null&&q.name))continue;const ee=i.find(ae=>ae.target===F.id&&ae.targetHandle===`input-${O}`);if(!(ee!=null&&ee.source))continue;r.find(ae=>ae.id===ee.source)&&(I[ee.source]=q.name)}}return I},[o,i,r]);x.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),x.useEffect(()=>{if(!e){k(!1);return}k(!0);const I=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&I.set("archived","1"),fetch(`/api/flow/run-config?${I.toString()}`).then(C=>{if(!C.ok)throw new Error(`HTTP ${C.status}`);return C.json()}).then(C=>{var U;if(!B.current)return;f(C.presets||{}),p(C.activePreset||null);const F=C.activePreset&&((U=C.presets)!=null&&U[C.activePreset])?C.presets[C.activePreset]:{};m({...A.current,...F}),k(!1)}).catch(()=>{B.current&&(m(A.current),k(!1))})},[e,t,n]),x.useEffect(()=>{var C;if(!s)return;const I={};for(const[F,U]of Object.entries(h)){const O=R[F];if(!O)continue;const q=r.find(ne=>ne.id===F);if(!q)continue;(((C=q.data)==null?void 0:C.definitionId)||"").startsWith("provide_file")?I[O]={type:"file",path:U}:I[O]={type:"str",value:U}}s(I)},[h,R,r,s]);const V=x.useCallback((I,C)=>{m(F=>({...F,[I]:C}))},[]),L=x.useCallback(I=>{I!==d&&(p(I),I&&u[I]?m({...A.current,...u[I]}):m(A.current))},[d,u]),H=x.useCallback(async()=>{if(y.trim()){w(!0);try{const I={...u,[y.trim()]:h},C={flowId:e,flowSource:t,archived:n,presets:I,activePreset:y.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)})).ok&&(f(I),p(y.trim()),N(""),S(!1))}finally{w(!1)}}},[e,t,n,u,h,y]),D=x.useCallback(async()=>{if(d){w(!0);try{const I={...u};delete I[d];const C=Object.keys(I)[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:I,activePreset:C})})).ok&&(f(I),p(C),C&&I[C]?m({...A.current,...I[C]}):m(A.current))}finally{w(!1)}}},[e,t,n,u,d]),$=x.useCallback(async()=>{if(d){w(!0);try{const I={...u,[d]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:I,activePreset:d})})).ok&&f(I)}finally{w(!1)}}},[e,t,n,u,d,h]),_=Object.keys(u);return _.length>0,v?c.jsx("aside",{className:"af-run-config-panel",children:c.jsx("div",{className:"af-run-config-loading",children:l("common.loading")})}):c.jsxs("aside",{className:"af-run-config-panel",children:[c.jsxs("div",{className:"af-run-config-preset",children:[c.jsx("label",{className:"af-run-config-preset-label",children:l("flow:runConfig.preset")}),c.jsxs("div",{className:"af-run-config-preset-row",children:[c.jsxs("select",{className:"af-run-config-preset-select",value:d||"",onChange:I=>L(I.target.value||null),disabled:g,children:[c.jsx("option",{value:"",children:l("flow:runConfig.default")}),_.map(I=>c.jsx("option",{value:I,children:I},I))]}),c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>S(!0),disabled:g,title:l("flow:runConfig.newPreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),d&&c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:$,disabled:g,title:l("flow:runConfig.savePreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),d&&c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:D,disabled:g,title:l("flow:runConfig.deletePreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&c.jsxs("div",{className:"af-run-config-save-dialog",children:[c.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:l("flow:runConfig.presetNamePlaceholder"),value:y,onChange:I=>N(I.target.value),disabled:g}),c.jsxs("div",{className:"af-run-config-save-actions",children:[c.jsx("button",{type:"button",className:"af-btn-primary",onClick:H,disabled:g||!y.trim(),children:l(g?"common.saving":"common.save")}),c.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{S(!1),N("")},disabled:g,children:l("common.cancel")})]})]}),c.jsxs("div",{className:"af-run-config-inputs",children:[c.jsx("div",{className:"af-run-config-inputs-header",children:l("flow:runConfig.inputParams")}),r.length===0?c.jsx("div",{className:"af-run-config-empty",children:l("flow:runConfig.noProvideNodes")}):c.jsx("div",{className:"af-run-config-input-list",children:r.map(I=>{var ee,ne;const F=(((ee=I.data)==null?void 0:ee.definitionId)||"").startsWith("provide_file"),U=((ne=I.data)==null?void 0:ne.label)||I.id,O=I.id,q=h[O]||"";return c.jsxs("div",{className:"af-run-config-input-item",children:[c.jsxs("div",{className:"af-run-config-input-head",children:[c.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(F?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:F?"description":"text_fields"}),c.jsx("span",{className:"af-run-config-input-label",children:U}),c.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>T({instanceId:O,label:U,content:q}),"aria-label":l("flow:runConfig.expandInput"),title:l("flow:runConfig.expandInput"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),c.jsx("div",{className:"af-run-config-input-id",children:O}),c.jsx("input",{type:"text",className:"af-run-config-input-field",value:q,onChange:ae=>V(O,ae.target.value),placeholder:l(F?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},O)})})]}),P&&qi.createPortal(c.jsx("div",{className:"af-provide-edit-overlay",children:c.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-provide-edit-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),c.jsx("span",{className:"af-provide-edit-modal__title",children:P.label}),c.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>T(null),"aria-label":l("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-provide-edit-modal__body",children:c.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:P.content,autoFocus:!0})}),c.jsxs("div",{className:"af-provide-edit-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!P||!M.current||(V(P.instanceId,M.current.value),T(null))},children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),l("flow:provideEdit.save")]}),c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>T(null),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),l("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const Qj={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"]},v6={"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 b6(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function S6(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 k6(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 Zb(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(Qj))if(r.includes(e))return n;return"other"}function N6({event:e,defaultExpanded:t}){const[n,r]=x.useState(!!t),i=v6[e.tag]||"#a8a8a8",o=e.payload,s=o&&typeof o=="object",a=s?typeof o.text=="string"?o.text:"":String(o||""),l=s?o.meta:null,u=x.useMemo(()=>a?a.slice(0,140).replace(/\s+/g," "):s?Object.keys(o).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const m=o[h];return m==null?`${h}:null`:typeof m=="object"?`${h}:{…}`:`${h}:${String(m).slice(0,30)}`}).join(" "):"",[o,a,s]),f=x.useCallback(d=>{d.stopPropagation();const p=s?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(p)}catch{}},[o,s]);return c.jsxs("div",{style:{borderLeft:`3px solid ${i}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(d=>!d),children:[c.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[c.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:S6(e.ts)}),c.jsx("span",{style:{color:i,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),c.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:u}),n&&c.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&&c.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[l&&Object.keys(l).length>0&&c.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(l,null,2)}),a?c.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:a}):s?c.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(o,null,2)}):null]})]})}function C6({open:e,onClose:t,flowId:n}){var T;const[r,i]=x.useState([]),[o,s]=x.useState(!1),[a,l]=x.useState(null),[u,f]=x.useState(null),[d,p]=x.useState(!1),[h,m]=x.useState(!0),[v,k]=x.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[g,w]=x.useState(""),y=x.useRef(null),N=x.useCallback(async()=>{s(!0);try{const M=h&&n?`?flowId=${encodeURIComponent(n)}`:"",A=await(await fetch(`/api/composer-logs${M}`)).json();i(Array.isArray(A.sessions)?A.sessions:[])}catch{i([])}finally{s(!1)}},[n,h]),E=x.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const A=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f(A)}catch{f(null)}finally{p(!1)}},[]);x.useEffect(()=>{e&&N()},[e,N]),x.useEffect(()=>{if(!(!e||!a))return E(a),y.current=setInterval(()=>E(a),2e3),()=>{y.current&&clearInterval(y.current),y.current=null}},[e,a,E]);const S=x.useMemo(()=>{const M=(u==null?void 0:u.events)||[],B=g.trim().toLowerCase();return M.filter(A=>{const R=Zb(A.tag,A.payload);return!v[R]&&R!=="other"?!1:B?[A.tag,JSON.stringify(A.payload||"")].join(" ").toLowerCase().includes(B):!0})},[u,v,g]),P=x.useMemo(()=>{const M=(u==null?void 0:u.events)||[],B={};for(const A of M){const R=Zb(A.tag,A.payload);B[R]=(B[R]||0)+1}return B},[u]);return e?c.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:[c.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:[c.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),c.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),c.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[c.jsx("input",{type:"checkbox",checked:h,onChange:M=>m(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),c.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"}),c.jsx("span",{style:{flex:1}}),c.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"})]}),c.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[c.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&c.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&c.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const B=a===M.sessionId;return c.jsxs("div",{onClick:()=>l(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:[c.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:k6(M.mtime)}),c.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&c.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),c.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[b6(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),c.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[c.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(Qj).map(M=>c.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," ",P[M]!=null?`(${P[M]})`:""]},M)),c.jsx("input",{type:"text",placeholder:"search…",value:g,onChange:M=>w(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}})]}),c.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!a&&c.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),d&&!u&&c.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),u&&S.length===0&&c.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((T=u.events)==null?void 0:T.length)||0," total)"]}),S.map((M,B)=>c.jsx(N6,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${B}`))]})]})]})]}):null}const E6="0.1.25";function e1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function Kh(e,t){return t==="running"?e1(e):e==null||!Number.isFinite(e)||e<=0?"--":e1(e)}const Jj=x.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function j6(e){const{setNodes:t}=Mc(),{modelLists:n,onModelChange:r}=x.useContext(Jj),i=x.useCallback(s=>{t(a=>a.filter(l=>l.id!==s))},[t]),o=x.useCallback(()=>{var u,f,d,p,h,m,v,k;const s=((u=e.data)==null?void 0:u.definitionId)||"",a=((f=e.data)==null?void 0:f.label)||e.id,l=((h=(p=(d=e.data)==null?void 0:d.outputs)==null?void 0:p[0])==null?void 0:h.value)||((k=(v=(m=e.data)==null?void 0:m.outputs)==null?void 0:v[0])==null?void 0:k.default)||"";window.__provideEditContent={instanceId:e.id,label:a,definitionId:s,content:l},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]);return c.jsx(i4,{...e,deleteNode:i,onProvideExpand:o,modelLists:n,onModelChange:r})}const P6={[Pg]:j6},td=["CONTROL","TOOL","PROVIDE","AGENT"],_6=1200,t1="af-flow-node--sync-flash",n1="af-flow-edge--sync-flash";function r1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function i1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function Zj(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 o1(e){const t=Zj(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function I6(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function A6(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 s1(e){if(!e)return"";const t=e.lastIndexOf("/");if(t===-1)return e;const n=e.slice(0,t),r=n.indexOf("/.agentflow/");return r!==-1&&n.slice(0,r)||n}const T6=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function R6(e){const t=new Set,n=[];let r;const i=new RegExp(T6.source,"g");for(;(r=i.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function a1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const i=n.slice(r+1);return/[\s\n]/.test(i)?null:{atIndex:r,query:i}}function ei(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function nd(e,t,n,r){const i=(e||"").trim();if(!i)return"";if(i.startsWith("opencode:")||i.startsWith("claude-code:"))return i;const o=Array.isArray(t)?t:[],s=Array.isArray(n)?n:[],a=Array.isArray(r)?r:[],l=o.map(ei),u=s.map(ei);return a.map(ei).includes(i)&&!l.includes(i)&&!u.includes(i)?`claude-code:${i}`:u.includes(i)&&!l.includes(i)?`opencode:${i}`:i}function L6(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Yh(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 O6({steps:e}){const{t}=rt();return!e||e.length===0?null:c.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(),i=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",i?`${t("flow:palette.model")}:${i}`:""].filter(Boolean).join(`
122
- `),s=n.status||"pending";return c.jsxs("div",{className:"af-composer-step-chip"+(s==="done"?" af-composer-step-chip--done":"")+(s==="running"?" af-composer-step-chip--running":"")+(s==="error"?" af-composer-step-chip--error":"")+(s==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:o,children:[c.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),c.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||i?c.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?c.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,i?c.jsx("span",{className:"af-composer-step-chip-model",children:L6(i)}):null]}):null})]},n.index)})})}function M6(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 D6(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const i=typeof n.kind=="string"&&n.kind?n.kind:"assistant",o=t[t.length-1];o&&o.kind===i?o.text+=i==="error"||i==="result"?`
123
- ${n.text}`:n.text:t.push({kind:i,text:n.text})}return t}function F6(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 $6(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 l1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:i=!0}){const{t:o}=rt(),s=x.useRef(null),a=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return x.useEffect(()=>{if(!i||!s.current)return;const l=s.current;requestAnimationFrame(()=>{l.scrollTop=l.scrollHeight})},[e,t,i]),c.jsxs("div",{ref:s,className:a,children:[e.map((l,u)=>l.type==="user"?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:o("flow:composer.yourQuestion")}),c.jsx("div",{className:"af-composer-ai-block-body",children:l.text})]},`composer-u-${u}-${l.text.slice(0,48)}`):c.jsx("div",{className:"af-composer-thread-assistant",children:c.jsx(c1,{segments:l.segments,running:!1})},`composer-a-${u}`)),c.jsx("div",{className:"af-composer-thread-assistant",children:c.jsx(c1,{segments:t,running:n})})]})}function c1({segments:e,running:t=!1}){const{t:n}=rt(),r=e.filter(d=>d.kind==="assistant").map(d=>d.text).join(""),i=e.filter(d=>d.kind==="result").map(d=>d.text).join(""),o=M6(r,i),s=e.filter(d=>d.kind==="error").map(d=>d.text).join(`
124
- `),a=e.filter(d=>d.kind!=="error"),l=o?a.filter(d=>d.kind!=="result"):a,u=D6(l),f=!!(u.length>0||s);return c.jsxs(c.Fragment,{children:[u.map((d,p)=>c.jsxs("section",{className:$6(d.kind),children:[c.jsx("div",{className:"af-composer-ai-block-label",children:F6(d.kind,n)}),c.jsx("div",{className:"af-composer-ai-block-body",children:d.text})]},`${d.kind}-${p}`)),t&&!f?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),c.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,s?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),c.jsx("div",{className:"af-composer-ai-block-body",children:s})]}):null]})}function z6({fitViewEpoch:e}){const{fitView:t}=Mc(),n=x.useRef(t);return n.current=t,x.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200}));return()=>cancelAnimationFrame(r)}},[e]),null}const Pd=1500,u1=500,B6=262144,H6=2e3;function qh(e){return typeof e!="string"?"":e.length<=H6?e:`[log line truncated, ${e.length} chars]`}const U6=Pd;function V6(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,i]=t;if(r==="cli")try{const o=JSON.parse(i);return o&&o.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${o.instanceId||""}${o.label?` · ${o.label}`:""} 开始`}:o&&o.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${o.instanceId||""} 完成${o.elapsed?` (${o.elapsed})`:""}`}:o&&o.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${o.instanceId||""} 失败${o.error?`: ${o.error}`:""}`}:o&&o.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${o.uuid||""}`}:{ts:n,type:"info",text:qh(i)}}catch{return{ts:n,type:"info",text:qh(i)}}return{ts:n,type:"log",text:qh(`[${r}] ${i}`)}}function d1(e){if(!e)return[];const t=[],n=e.split(`
125
- `);for(let r=n.length-1;r>=0&&t.length<U6;r--){const i=n[r];if(!i)continue;const o=V6(i);o&&t.push(o)}return t.reverse(),t}function W6(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const o=e[i],s=t[i];if(!s)return!1;if(o!==s&&(o.status!==s.status||(o.elapsed??null)!==(s.elapsed??null)))return!1}return!0}function K6(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Y6({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:i,onEdgesChange:o,onConnect:s,onNodesDelete:a,onNodeClick:l,onEdgeClick:u,onFlowInit:f,onDrop:d,onDragOver:p,hideMinimapAndControls:h,bottomSlot:m}){const{t:v}=rt(),k=!i,g=k||t==="pan"?!0:[1,2],w=k?!1:t==="select",y="af-flow-canvas"+(k?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),N=x.useCallback(()=>{},[]),E=x.useMemo(()=>{const S=new Map(n.map(A=>[A.id,A])),P=new Set(n.filter(A=>A.selected).map(A=>A.id)),T=P.size>0,M=(A,R)=>{const V=/^#([0-9a-f]{6})$/i.exec(A);if(!V)return A;const L=parseInt(V[1],16);return`rgba(${L>>16&255}, ${L>>8&255}, ${L&255}, ${R})`},B="#ff5169";return r.map(A=>{var ae,J,le,Se;const R=S.get(A.source),V=S.get(A.target),L=/^output-(\d+)$/.exec(A.sourceHandle||""),H=/^input-(\d+)$/.exec(A.targetHandle||""),D=R&&L?(J=(ae=R.data)==null?void 0:ae.outputs)==null?void 0:J[parseInt(L[1],10)]:null,$=V&&H?(Se=(le=V.data)==null?void 0:le.inputs)==null?void 0:Se[parseInt(H[1],10)]:null,_=D!=null&&D.type?xf(D.type):null,I=$!=null&&$.type?xf($.type):null,C=_&&I&&_!==I,F=T&&(P.has(A.source)||P.has(A.target)),U=A.style||{};if(C){const ye=A.selected?.95:F?.85:.78,ge=M(B,ye);return{...A,className:((A.className||"")+" af-flow-edge--type-mismatch"+(F?" af-flow-edge--adjacent":"")).trim(),style:{...U,stroke:ge,strokeWidth:F?2.75:2.5,strokeDasharray:"6 4"},markerEnd:A.markerEnd&&typeof A.markerEnd=="object"?{...A.markerEnd,color:ge}:{type:Zi.ArrowClosed,color:ge}}}const O=_||I;if(!O)return F?{...A,className:((A.className||"")+" af-flow-edge--adjacent").trim(),style:{...U,strokeWidth:2.5}}:A;const q=F||A.selected?.7:.38,ee=M(O,q),ne=F?2.5:U.strokeWidth??2;return{...A,className:((A.className||"")+(F?" af-flow-edge--adjacent":"")).trim(),style:{...U,stroke:ee,strokeWidth:ne},markerEnd:A.markerEnd&&typeof A.markerEnd=="object"?{...A.markerEnd,color:ee}:{type:Zi.ArrowClosed,color:ee}}})},[n,r]);return c.jsxs(XF,{className:y,nodes:n,edges:E,onNodesChange:i||N,onEdgesChange:o||N,onConnect:k?void 0:s,onNodesDelete:k?void 0:a,onNodeClick:l,onEdgeClick:k?void 0:u,onInit:f,onDrop:k?void 0:d,onDragOver:k?void 0:p,nodeTypes:P6,selectionOnDrag:w,panOnDrag:g,nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k,edgesFocusable:!k,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[c.jsx(r$,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),c.jsx(ua,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(h?" af-flow-bottom-unified-panel--solo":""),children:c.jsxs("div",{className:"af-flow-bottom-unified-row"+(h?" af-flow-bottom-unified-row--solo":""),children:[h?null:c.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:c.jsx(k$,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:S=>{var T;const P=(((T=S.data)==null?void 0:T.schemaType)??"agent").toLowerCase();return P==="control"?"rgba(237, 108, 2, 0.85)":P==="provide"?"rgba(0, 228, 117, 0.35)":P==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),c.jsx("div",{className:"af-flow-bottom-unified__center",children:m}),h?null:c.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:c.jsx(u$,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!h&&c.jsx(ua,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:S,color:P})=>c.jsxs("span",{className:"af-pin-legend__item",children:[c.jsx("span",{className:"af-pin-legend__dot",style:{background:P}}),c.jsx("span",{className:"af-pin-legend__label",children:S})]},S))}),c.jsx(z6,{fitViewEpoch:e}),!k&&n.length===0?c.jsxs("div",{className:"af-flow-empty-hint",children:[c.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),c.jsx("p",{className:"af-flow-empty-hint-text",children:v("flow:emptyCanvas.composerHint")}),c.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:v("flow:emptyCanvas.composerSub")}})]}):null]})}function Gh(e){const t=e.source??"user",n=e.archived?"1":"0";return`${e.id}\0${t}\0${n}`}function f1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&t.set("flowArchived","1"),window.history.replaceState({},"","/flow?"+t.toString())}function q6(e){return e==="builtin"?"workspace":e??"user"}function Xh(e,t){return t(e==="builtin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}const eP="af:run-console-height",Fl=230,dl={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},rd={};function _d(e){if(!Number.isFinite(e))return Fl;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function G6(){try{const e=localStorage.getItem(eP);if(e==null)return Fl;const t=parseInt(e,10);return Number.isFinite(t)?_d(t):Fl}catch{return Fl}}function X6(){var dw,fw;const{t:e}=rt(),{navigate:t,path:n}=xa(),[r,i]=x.useState([]),[o,s]=x.useState(""),[a,l]=x.useState(null),[u,f]=x.useState(0),[d,p]=x.useState(""),[h,m]=x.useState(""),[v,k]=x.useState(""),[g,w]=x.useState(""),[y,N]=x.useState(!1),[E,S]=x.useState(""),[P,T]=x.useState(!1),[M,B]=x.useState(""),[A,R]=x.useState(!1),[V,L]=x.useState(!1),[H,D]=x.useState(!1),[$,_]=x.useState(null),[I,C]=x.useState(!1),[F,U]=x.useState(!1),O=x.useRef(!1),[q,ee]=x.useState([]),[ne,ae]=x.useState(""),[J,le]=x.useState(null),[Se,ye]=x.useState([]),[ge,xe]=x.useState(""),[$e,Ke]=x.useState(!1),[Le,mt]=x.useState(!1),[_t,Dt]=x.useState({files:[]}),[Fn,wr]=x.useState(!1),[vr,br]=x.useState(!0);x.useEffect(()=>{let b=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(W=>{b||br(W.ok)}).catch(()=>{b||br(!1)})};j();const z=window.setInterval(j,5e3);return()=>{b=!0,window.clearInterval(z)}},[]),x.useEffect(()=>{let b=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{b||yp(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{b=!0}},[]);const[he,gt]=x.useState("edit"),[G,Q]=x.useState([]),Ne=x.useRef(0),[Ce,Ie]=x.useState(new Set),[It,Ct]=x.useState({}),[Vt,tn]=x.useState(null),[Jn,lt]=x.useState(0),[cn,Ft]=x.useState(!1),[gp,yp]=x.useState(!1),[Vc,Wc]=x.useState(!1),[Ea,ja]=x.useState(G6),Qo=x.useRef({active:!1,pointerId:-1,startY:0,startH:Fl}),[ft,lo]=x.useState(null),[Pa,Jo]=x.useState(null),[co,Kc]=x.useState({}),Yc=x.useRef(co);x.useEffect(()=>{Yc.current=co},[co]);const[qc,yi]=x.useState(!1),[xp,Zo]=x.useState(!1),[Gc,Xc]=x.useState({}),[xi,_a]=x.useState({}),[uo,es]=x.useState(null),[$n,Sr]=x.useState(dl),[wp,Qc]=x.useState(!1),[wi,Jc]=x.useState(!1),[Zc,vi]=x.useState(""),[eu,ts]=x.useState(""),[Wt,Ia]=x.useState(rd),[Zn,Aa]=x.useState(null),kr=x.useRef(null),fo=x.useRef(null),Ta=x.useRef(!0),po=x.useRef(!1),[At,ns]=x.useState(null),[ho,rs]=x.useState(null),[tu,mo]=x.useState(!1),[qr,is]=x.useState(""),[os,ss]=x.useState(!1),vp=x.useRef(null),[Nn,Ra]=x.useState(null),[nu,bi]=x.useState(!1),[as,$x]=x.useState(null),[ls,ru]=x.useState(null),bp=x.useRef(null),[zn,La]=x.useState(""),[iu,Oa]=x.useState(0),[Ma,Da]=x.useState(0),[FP,Sp]=x.useState("pan"),[ou,Fa]=x.useState(!1),[kp,zx]=x.useState(!1),Np=x.useRef(null),Cp=x.useRef(null),$a=x.useRef(null),[$P,zP]=x.useState(0),[Oe,Ep]=x.useState(null),[BP,su]=x.useState(""),[_e,HP]=x.useState({cursor:[],opencode:[],claudeCode:[]}),[go,Bx]=x.useState(""),[jp,nG]=x.useState(""),au=x.useCallback(b=>{if(!b)return null;const j=b.id,z=b.source??"user",W=b.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${z}${W?":"+W:""}`,activeKey:`af:composer-active-session:${j}:${z}${W?":"+W:""}`}},[]),Hx=x.useCallback(b=>{const j=au(b);if(!j)return{sessions:[],activeSessionId:null};try{const z=localStorage.getItem(j.sessionsKey);if(!z)return{sessions:[],activeSessionId:null};const W=JSON.parse(z);if(!Array.isArray(W))return{sessions:[],activeSessionId:null};const K=W.filter(Z=>Z&&typeof Z.id=="string").map(Z=>({...Z,running:!1,statusLine:Z.running?e("flow:composer.pageRefreshReset"):Z.statusLine,steps:[]}));let Y=null;try{Y=localStorage.getItem(j.activeKey),Y&&!K.some(Z=>Z.id===Y)&&(Y=null)}catch{Y=null}return{sessions:K,activeSessionId:Y}}catch{return{sessions:[],activeSessionId:null}}},[au]),lu=x.useCallback((b,j,z)=>{const W=au(b);if(W)try{localStorage.setItem(W.sessionsKey,JSON.stringify(j)),z?localStorage.setItem(W.activeKey,z):localStorage.removeItem(W.activeKey)}catch{}},[au]),yo=x.useRef(0),cu=x.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Bn,Nr]=x.useState([]),[Kt,Si]=x.useState(null),uu=x.useMemo(()=>{if(!a)return null;const b=a.id,j=a.source??"user",z=a.archived?"archived":"";return`${b}:${j}${z?":"+z:""}`},[a]),Pp=x.useRef(!1);x.useEffect(()=>{if(!uu){Nr([]),Si(null),cu.current={sessions:[],activeSessionId:null,flowKey:null};return}const b=cu.current;if(b.flowKey===uu)return;b.flowKey=uu,Pp.current&&b.sessions.length>0&&lu(a,b.sessions,b.activeSessionId);const{sessions:j,activeSessionId:z}=Hx(a);if(j.length===0){const W=`session-1-${Date.now()}`,K={id:W,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};b.sessions=[K],b.activeSessionId=W,Nr([K]),Si(W)}else{const W=j[j.length-1];if(W&&(!W.thread||W.thread.length===0))yo.current=Yh(j),b.sessions=j,b.activeSessionId=W.id,Nr(j),Si(W.id);else{const Y=Yh(j)+1;yo.current=Y;const Z=`session-${Y}-${Date.now()}`,te={id:Z,label:e("flow:composer.conversationLabel",{n:Y}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},se=[...j,te];b.sessions=se,b.activeSessionId=Z,Nr(se),Si(Z)}}Pp.current=!0},[uu,a,Hx,lu]);const yt=x.useMemo(()=>Bn.find(b=>b.id===Kt)||null,[Bn,Kt]),vt=(yt==null?void 0:yt.running)??!1,za=(yt==null?void 0:yt.statusLine)??"",Ba=(yt==null?void 0:yt.segments)??[],Ha=(yt==null?void 0:yt.thread)??[],Ux=(yt==null?void 0:yt.steps)??[];yt==null||yt.outputDismissed;const Ae=(yt==null?void 0:yt.phaseContext)??null,Vx=x.useRef([]),[_p,du]=x.useState(!1),fu=x.useRef(null),Wx=x.useRef(null);x.useEffect(()=>{const b=Wx.current;b&&requestAnimationFrame(()=>{b.scrollTop=b.scrollHeight})},[Ha,Ba]);const Ip=x.useRef(null),Ap=x.useRef(!1),UP=x.useRef(null),Kx=x.useCallback(b=>{const j=++yo.current,z=`session-${j}-${Date.now()}`,W={id:z,label:b||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Nr(K=>[...K,W]),Si(z),z},[]);x.useEffect(()=>{!a||!Pp.current||(cu.current.sessions=Bn,cu.current.activeSessionId=Kt,lu(a,Bn,Kt))},[Bn,Kt,a,lu]),x.useEffect(()=>{yo.current=Math.max(yo.current,Yh(Bn))},[Bn]);const VP=x.useCallback(b=>{var j;Ip.current===b&&((j=fu.current)==null||j.abort()),Nr(z=>{const W=z.filter(Y=>Y.id!==b);if(z.some((Y,Z)=>Y.id===b&&z.findIndex(te=>te.id===Kt)===Z)||Kt===b){const Y=W;Y.length>0?Si(Y[Y.length-1].id):setTimeout(()=>{yo.current=0;const Z=++yo.current,te=`session-${Z}-${Date.now()}`,se={id:te,label:e("flow:composer.conversationLabel",{n:Z}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Nr(oe=>[...oe,se]),Si(te)},0)}return W})},[Kt]),un=x.useCallback(b=>{Nr(j=>{const z=j.findIndex(Y=>Y.id===Kt);if(z<0)return j;const W={...j[z]};b(W);const K=[...j];return K[z]=W,K})},[Kt]),Yx=x.useCallback(b=>{un(j=>{j.running=b})},[un]),Cr=x.useCallback(b=>{un(j=>{j.statusLine=b})},[un]),Er=x.useCallback(b=>{un(j=>{typeof b=="function"?j.segments=b(j.segments):j.segments=b})},[un]),qx=x.useCallback(b=>{un(j=>{typeof b=="function"?j.thread=b(j.thread):j.thread=b})},[un]),Ua=x.useCallback(b=>{un(j=>{typeof b=="function"?j.steps=b(j.steps):j.steps=b})},[un]),Gx=x.useCallback(b=>{un(j=>{j.outputDismissed=b})},[un]),Va=x.useCallback(b=>{un(j=>{j.phaseContext=typeof b=="function"?b(j.phaseContext):b})},[un]),Xx=x.useCallback(b=>{Si(b),Nr(j=>{const z=j.findIndex(K=>K.id===b);if(z<0||!j[z].outputDismissed)return j;const W=[...j];return W[z]={...j[z],outputDismissed:!1},W})},[]);x.useEffect(()=>{Vx.current=Ba},[Ba]);const Gr=x.useRef({}),Qx=x.useRef(!1),Wa=x.useRef(null),ki=x.useRef(null),Ka=x.useRef(!1),Tp=x.useRef(0),pu=x.useRef(""),[He,Ue,WP]=QF([]),[xt,Tt,KP]=JF([]),Rp=x.useRef(He),Lp=x.useRef(xt),er=x.useMemo(()=>He.filter(b=>{var j;return(((j=b.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[He]),cs=x.useMemo(()=>{var j;const b={};for(const z of He){if(!((j=z.data)!=null&&j.inputs))continue;const W=z.data.inputs;for(let K=0;K<W.length;K++){const Y=W[K];if(!(Y!=null&&Y.name))continue;const Z=xt.find(se=>se.target===z.id&&se.targetHandle===`input-${K}`);if(!(Z!=null&&Z.source))continue;er.find(se=>se.id===Z.source)&&(b[Z.source]=Y.name)}}return b},[He,xt,er]),Ya=x.useMemo(()=>{if(he==="edit"||Ce.size===0)return null;const b=new Set(Ce);for(const j of xt)Ce.has(j.source)&&b.add(j.target),Ce.has(j.target)&&b.add(j.source);return b},[he,Ce,xt]),YP=x.useMemo(()=>he==="edit"?He:He.map(b=>{var j,z;return{...b,draggable:!1,connectable:!1,data:{...b.data,isRunMode:!0,isExecuting:Ce.has(b.id),nodeStatus:((j=It[b.id])==null?void 0:j.status)??null,nodeElapsed:((z=It[b.id])==null?void 0:z.elapsed)??null,isDim:Ya?!Ya.has(b.id):!1}}}),[he,He,Ce,It,Ya]),qP=x.useMemo(()=>Ya?xt.map(b=>{const j=Ce.has(b.source)||Ce.has(b.target),z=b.className?b.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",W=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...b,className:(z?z+" ":"")+W}}):xt,[xt,Ce,Ya]);x.useEffect(()=>{if(!a){_a({}),es(null),Sr(dl),Ia(rd),Aa(null),vi(""),ts("");return}const b=new URLSearchParams({flowId:a.id,flowSource:a.source||"user"});a.archived&&b.set("archived","1"),fetch(`/api/flow/run-config?${b.toString()}`).then(j=>j.json()).then(j=>{_a(j.presets||{}),es(j.activePreset||null)}).catch(()=>{_a({}),es(null)})},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived]);const hu=x.useCallback(async(b,j={})=>{if(!b)return;!!j.quiet||(Qc(!0),vi(""),ts(""));const W=new URLSearchParams({flowId:b.id,flowSource:b.source||"user"});b.archived&&W.set("archived","1");try{const K=await fetch(`/api/flow/schedule?${W.toString()}`),Y=await K.json().catch(()=>({}));if(!K.ok)throw new Error(Y.error||`HTTP ${K.status}`);Sr({...dl,...Y.schedule||{}}),Ia(Y.state&&typeof Y.state=="object"?Y.state:rd),Aa(Y.status||null)}catch(K){Sr(dl),Ia(rd),Aa(null),vi(String(K.message||K))}finally{Qc(!1)}},[]);x.useEffect(()=>{if(!a)return;let b=!1;return(async()=>{await hu(a)})(),()=>{b=!0}},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived,hu]),x.useEffect(()=>{var z,W,K,Y;if(!uo||!xi[uo]||er.length===0)return;const b=xi[uo],j={};for(const Z of er){const te=cs[Z.id];if(!te)continue;const se=((z=Z.data)==null?void 0:z.definitionId)||"",oe=b[Z.id]??((Y=(K=(W=Z.data)==null?void 0:W.outputs)==null?void 0:K[0])==null?void 0:Y.default)??"";se.startsWith("provide_file")?j[te]={type:"file",path:oe}:j[te]={type:"str",value:oe}}Object.keys(j).length>0&&Kc(j)},[uo,xi,er,cs]);const GP=x.useCallback(()=>{if(!ls||!bp.current)return;const b=bp.current.value;Ue(j=>j.map(z=>{var W,K;return z.id!==ls.instanceId?z:{...z,data:{...z.data,outputs:((K=(W=z.data)==null?void 0:W.outputs)==null?void 0:K.map((Y,Z)=>Z===0?{...Y,default:b}:Y))||[{type:"text",name:"value",default:b}]}}})),ru(null)},[ls,Ue]),Pe=x.useMemo(()=>{const b=He.filter(j=>j.selected);return b.length===1?b[0]:null},[He]),jr=x.useMemo(()=>a?e4(He,xt,e):[],[a,He,xt,e]),XP=x.useMemo(()=>jr.map(b=>b.key).join("|"),[jr]),Jx=x.useMemo(()=>jr.some(b=>String((b==null?void 0:b.level)||"warning").toLowerCase()==="error"),[jr]);x.useLayoutEffect(()=>{C(jr.length>0&&!Jx)},[XP,a==null?void 0:a.id,a==null?void 0:a.source,jr.length,Jx]),$a.current=Pe,x.useEffect(()=>{Rp.current=He},[He]),x.useEffect(()=>{Lp.current=xt},[xt]),x.useEffect(()=>()=>{ki.current!=null&&(clearTimeout(ki.current),ki.current=null)},[]);const Op=x.useMemo(()=>{var j;if(!Pe)return null;const b=(j=Pe.data)==null?void 0:j.definitionId;return q.find(z=>z.id===b)??null},[Pe,q]),Mp=x.useMemo(()=>{const b={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of q){const z=Zj(j);b[z].push(j)}for(const j of td)b[j].sort((z,W)=>z.id.localeCompare(W.id));return b},[q]),mu=x.useMemo(()=>{const b=ne.trim().toLowerCase();if(!b)return Mp;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const z of td)j[z]=Mp[z].filter(W=>A6(W,b));return j},[Mp,ne]),QP=x.useMemo(()=>td.reduce((b,j)=>b+mu[j].length,0),[mu]),gu=x.useCallback(async()=>{s("");try{const b=await fetch("/api/flows");if(!b.ok)throw new Error("HTTP "+b.status);i(await b.json())}catch(b){s(String(b.message||b))}},[]);x.useEffect(()=>{gu()},[gu]),x.useEffect(()=>{if(n!=="/flow")return;const b=new URLSearchParams(window.location.search);b.get("new")==="1"&&!b.get("flowId")&&t("/projects?new=1")},[n,t]),x.useEffect(()=>{let b=!1;const j=()=>{fetch("/api/model-lists").then(W=>W.json()).then(W=>{b||HP({cursor:Array.isArray(W.cursor)?W.cursor.map(String):[],opencode:Array.isArray(W.opencode)?W.opencode.map(String):[],claudeCode:Array.isArray(W.claudeCode)?W.claudeCode.map(String):[]})}).catch(()=>{})};j();const z=setTimeout(j,4e3);return()=>{b=!0,clearTimeout(z)}},[]);const Zx=x.useCallback(async b=>{const j=b.source??"user",z=!!b.archived,W=new URLSearchParams({flowId:b.id,flowSource:j});z&&W.set("archived","1");const K=new URLSearchParams({flowId:b.id,flowSource:j});z&&K.set("archived","1");const[Y,Z]=await Promise.all([fetch("/api/flow?"+W.toString()),fetch("/api/nodes?"+K.toString())]),te=await Y.json();if(!Y.ok||te.error)throw new Error(te.error||e("flow:nodePropsError.loadFlowFailed"));const se=await Z.json();if(!Z.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const oe=Array.isArray(se)?se:Array.isArray(se==null?void 0:se.nodes)?se.nodes:[],me=!Array.isArray(se)&&(se==null?void 0:se.pipelineTranslations)||{},X=Qz(te.flowYaml||"");if(X.error)throw new Error(X.error);const ue={...X.instances||{}},ce=X.nodes.map(Ve=>Lh(Ve,ue,oe,me,b.id)),we=n4(X.edges,ce);return{flowSource:j,paletteList:oe,instances:ue,flowDescriptionText:X.description??"",nodes:ce,edges:we}},[]),Cn=x.useCallback(async(b,j={})=>{const z=!!j.preserveComposer,W=z&&!!j.incrementalSync;Ka.current=!1,Tp.current+=1,l(b),m(""),z||(k(""),ae(""),le(null),p(""),S(""),B(""),La(""),qx([]),Er([]),Ua([]),Gx(!1),Va(null),Sp("pan")),W||(Gr.current={},Ue([]),Tt([])),f1(b);try{const K=await Zx(b);if(ee(K.paletteList),Gr.current=K.instances,p(K.flowDescriptionText),S(b.id||""),W){const Y=Rp.current,Z=Lp.current;try{const te=P$(Y,Z,K.nodes,K.edges),se=new Set([...te.changes.addedNodeIds,...te.changes.updatedNodeIds]),oe=new Set([...te.changes.addedEdgeKeys,...te.changes.updatedEdgeKeys]),me=se.size>0?te.nodes.map(ue=>se.has(ue.id)?{...ue,className:r1(ue.className,t1)}:ue):te.nodes,X=oe.size>0?te.edges.map(ue=>oe.has(pc(ue))?{...ue,className:r1(ue.className,n1)}:ue):te.edges;Ue(me),Tt(X),ki.current!=null&&(clearTimeout(ki.current),ki.current=null),(se.size>0||oe.size>0)&&(ki.current=window.setTimeout(()=>{ki.current=null,se.size>0&&Ue(ue=>ue.map(ce=>{if(!se.has(ce.id))return ce;const we=i1(ce.className,t1);return we===String(ce.className||"")?ce:{...ce,className:we}})),oe.size>0&&Tt(ue=>ue.map(ce=>{if(!oe.has(pc(ce)))return ce;const we=i1(ce.className,n1);return we===String(ce.className||"")?ce:{...ce,className:we}}))},_6))}catch{Ue(K.nodes),Tt(K.edges)}}else Ue(K.nodes),Tt(K.edges),f(Y=>Y+1);zu(b.id,K.flowSource),zP(Y=>Y+1);try{pu.current=Qv(K.nodes,K.edges,K.instances,{description:K.flowDescriptionText})}catch{pu.current=""}Ka.current=!0}catch(K){m(String(K.message||K))}},[Zx,Ue,Tt]),ew=x.useCallback(async()=>{var W;if(!a||O.current)return;const b=a.id,j=a.source??"user",z=((W=$a.current)==null?void 0:W.id)??null;O.current=!0,U(!0);try{await Cn({id:b,source:j,archived:a.archived},{preserveComposer:!0,incrementalSync:!0}),z&&Ue(K=>K.map(Y=>({...Y,selected:Y.id===z})))}finally{O.current=!1,U(!1)}},[a,a==null?void 0:a.archived,Cn,Ue]);x.useEffect(()=>{if(Qx.current||r.length===0)return;const b=new URLSearchParams(window.location.search),j=b.get("flowId");if(!j)return;const z=b.get("flowSource")??"user",W=b.get("flowArchived")==="1",K=r.find(Y=>Y.id===j&&(Y.source??"user")===z&&!!Y.archived===W);K&&(Qx.current=!0,Cn(K))},[r,Cn]);const yu=x.useRef(0);x.useEffect(()=>{if(!a)return;const b=a.id,j=a.source??"user",z=!!a.archived;yu.current=0;let W=!1;const K=async()=>{var te;if(W)return;const Z=new URLSearchParams({flowId:b,flowSource:j,v:String(yu.current)});z&&Z.set("archived","1");try{const se=await fetch("/api/flow-editor-sync-poll?"+Z.toString());if(!se.ok||W)return;const oe=await se.json();if(W)return;if(oe.changed){yu.current=oe.version;const me=((te=$a.current)==null?void 0:te.id)??null;await Cn({id:b,source:j,archived:z},{preserveComposer:!0,incrementalSync:!0}),me&&Ue(X=>X.map(ue=>({...ue,selected:ue.id===me})))}else yu.current=oe.version}catch{}},Y=window.setInterval(K,2e3);return K(),()=>{W=!0,window.clearInterval(Y)}},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived,Cn,Ue]);const JP=x.useMemo(()=>v?v.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":v===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[v]);x.useEffect(()=>{if(!v)return;v===e("flow:status.saved")||v.startsWith(e("flow:status.runInTerminal"));const b=v.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>k(""),b);return()=>clearTimeout(j)},[v,e]),x.useEffect(()=>{w("")},[a==null?void 0:a.id,a==null?void 0:a.source]),x.useEffect(()=>{const b=()=>{window.__provideEditContent&&(ru(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",b),()=>window.removeEventListener("provide-expand",b)},[]),x.useEffect(()=>{var te,se,oe,me,X,ue;if(!Pe){Ep(null);return}const b=Gr.current[Pe.id]||{},{inputs:j,outputs:z}=t4(Pe),W=String(((te=Pe.data)==null?void 0:te.definitionId)??Pe.id??""),K=((se=Pe.data)==null?void 0:se.script)!=null?String(Pe.data.script):void 0,Y=b.script!=null?String(b.script):void 0,Z=W==="tool_nodejs"||K&&K.trim()!==""||Y&&Y.trim()!==""?String(K??Y??""):"";Ep({id:Pe.id,newId:Pe.id,label:String(((oe=Pe.data)==null?void 0:oe.label)??Pe.id),role:((me=Pe.data)==null?void 0:me.role)??"普通",model:String(((X=Pe.data)==null?void 0:X.model)??b.model??""),body:String(((ue=Pe.data)==null?void 0:ue.body)??b.body??""),script:Z,inputs:j,outputs:z})},[Pe==null?void 0:Pe.id,$P]),x.useEffect(()=>{a&&(Pe||(Cp.current=null,le(b=>b==="node"?null:b)))},[a,Pe==null?void 0:Pe.id]);const xu=x.useCallback(()=>{Cp.current=null,le(b=>b==="settings"||b==="history"?b:"node")},[]),ZP=x.useCallback((b,j)=>{if(!(b.metaKey||b.ctrlKey||b.shiftKey)){if(he!=="edit"){Jo((j==null?void 0:j.id)??null);return}xu()}},[xu,he]),e_=x.useCallback((b,j)=>{if(he!=="edit")return;const z=b.metaKey||b.ctrlKey||b.shiftKey;Tt(W=>W.map(K=>K.id===j.id?{...K,selected:!K.selected||!z}:z?K:{...K,selected:!1})),z||Ue(W=>W.map(K=>({...K,selected:!1})))},[he,Tt,Ue]),t_=x.useCallback(b=>Tt(j=>{const z=j.filter(W=>!(W.target===b.target&&W.targetHandle===b.targetHandle));return vC({...b,markerEnd:{type:Zi.ArrowClosed}},z)}),[Tt]),n_=x.useCallback(b=>{for(const j of b)delete Gr.current[j.id]},[]),r_=x.useCallback(b=>{Wa.current=b},[]),i_=x.useCallback(b=>{Ue(z=>z.map(W=>({...W,selected:W.id===b}))),Tt(z=>z.map(W=>({...W,selected:!1}))),xu();const j=()=>{var se,oe,me;const z=Wa.current;if(!(z!=null&&z.getNode))return;const W=z.getNode(b);if(!W)return;const K=(se=z.getInternalNode)==null?void 0:se.call(z,b),Y=((oe=K==null?void 0:K.measured)==null?void 0:oe.width)??(K==null?void 0:K.width)??W.width??200,Z=((me=K==null?void 0:K.measured)==null?void 0:me.height)??(K==null?void 0:K.height)??W.height??88,{zoom:te}=z.getViewport();z.setCenter(W.position.x+Y/2,W.position.y+Z/2,{zoom:te,duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[Ue,Tt,xu]),o_=x.useCallback(b=>{Ue(z=>z.map(W=>({...W,selected:W.id===b}))),Tt(z=>z.map(W=>({...W,selected:!1})));const j=()=>{var oe,me,X;const z=Wa.current;if(!(z!=null&&z.getNode))return;const W=z.getNode(b);if(!W)return;const K=(oe=z.getInternalNode)==null?void 0:oe.call(z,b),Y=((me=K==null?void 0:K.measured)==null?void 0:me.width)??(K==null?void 0:K.width)??W.width??200,Z=((X=K==null?void 0:K.measured)==null?void 0:X.height)??(K==null?void 0:K.height)??W.height??88,{zoom:te}=z.getViewport(),se=Math.max(te,1);z.setCenter(W.position.x+Y/2,W.position.y+Z/2,{zoom:se,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[Ue,Tt]),s_=x.useCallback(b=>{if(!a||!b)return;let j={x:180,y:160};const z=Wa.current,W=document.querySelector(".af-pipeline-flow .react-flow");if(z&&W){const se=W.getBoundingClientRect();j=z.screenToFlowPosition({x:se.left+se.width*.45,y:se.top+se.height*.38})}const K=`node-${Date.now()}`,Y=o1(b),Z={id:K,type:Pg,position:j,data:{label:b.label??b.id,definitionId:b.id,schemaType:Y,inputs:Array.isArray(b.inputs)?b.inputs.map(se=>({...se})):[],outputs:Array.isArray(b.outputs)?b.outputs.map(se=>({...se})):[]}},te=Lh(Z,Gr.current,q);Ue(se=>[...se,te])},[a,q,Ue]),a_=x.useCallback(b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},[]),l_=x.useCallback(b=>{if(b.preventDefault(),!a)return;const j=b.dataTransfer.getData("application/agentflow-node");if(!j)return;const z=q.find(oe=>oe.id===j);if(!z)return;const W=Wa.current;if(!W)return;const K=W.screenToFlowPosition({x:b.clientX,y:b.clientY}),Y=`node-${Date.now()}`,Z=o1(z),te={id:Y,type:Pg,position:K,data:{label:z.label??z.id,definitionId:z.id,schemaType:Z,inputs:Array.isArray(z.inputs)?z.inputs.map(oe=>({...oe})):[],outputs:Array.isArray(z.outputs)?z.outputs.map(oe=>({...oe})):[]}},se=Lh(te,Gr.current,q);Ue(oe=>[...oe,se])},[a,q,Ue]),Ni=x.useCallback(async(b,j)=>{if(!a)return;const z=Qv(b,j,Gr.current,{description:d});if(z!==pu.current){k(e("flow:status.saving"));try{const W=q6(a.source),K=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:W,flowYaml:z,...a.archived?{flowArchived:!0}:{}})}),Y=await K.json();if(!K.ok||!Y.success)throw new Error(Y.error||e("flow:status.saveFailed"));if(pu.current=z,k(e("flow:status.saved")),a.source==="builtin"&&W==="workspace"){const Z={id:a.id,source:"workspace",path:void 0};l(Z),f1(Z),zu(a.id,"workspace")}}catch(W){k(e("flow:status.saveFailed")+": "+(W.message||W))}}},[a,d]);x.useEffect(()=>{if(!a||!Ka.current||he!=="edit"||a.archived)return;const b=Tp.current,j=setTimeout(()=>{b===Tp.current&&Ka.current&&Ni(Rp.current,Lp.current)},400);return()=>clearTimeout(j)},[He,xt,d,he,a,Ni]);const tw=x.useCallback(async b=>{if(!a||a.archived)return;const j=a.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==b){N(!0),w("");try{const z=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,fromSource:j,toSource:b})}),W=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof W.error=="string"?W.error:e("flow:composer.requestFailed"));const K=W.flowSource==="workspace"||W.flowSource==="user"?W.flowSource:b;let Y={id:a.id,source:K,archived:a.archived};try{const Z=await fetch("/api/flows");if(Z.ok){const te=await Z.json(),se=Array.isArray(te)?te.find(oe=>oe.id===a.id&&(oe.source??"user")===K&&!!oe.archived==!!a.archived):null;se&&(Y=se)}}catch{}await Cn(Y,{preserveComposer:!0}),zu(a.id,K)}catch(z){w(String(z.message||z))}finally{N(!1)}}},[a,Cn]),c_=x.useCallback(async()=>{if(a){Jc(!0),vi(""),ts("");try{const b=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source||"user",archived:!!a.archived,schedule:$n})}),j=await b.json().catch(()=>({}));if(!b.ok||!j.success)throw new Error(j.error||"Failed to save schedule");Sr({...dl,...j.schedule||{}}),ts(e("flow:schedule.saved")),await hu(a,{quiet:!0})}catch(b){vi(String(b.message||b))}finally{Jc(!1)}}},[a,$n,hu,e]),nw=x.useCallback(async()=>{if(!a||!E.trim())return;const b=E.trim();if(b===a.id){B("");return}T(!0),B("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",newFlowId:b})}),z=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof z.error=="string"?z.error:e("flow:composer.requestFailed"));let W={id:z.flowId,source:z.flowSource??a.source,archived:a.archived};try{const K=await fetch("/api/flows");if(K.ok){const Y=await K.json(),Z=Array.isArray(Y)?Y.find(te=>te.id===z.flowId&&(te.source??"user")===(z.flowSource??a.source)):null;Z&&(W=Z)}}catch{}await Cn(W,{preserveComposer:!0}),zu(z.flowId,z.flowSource??a.source)}catch(j){B(String(j.message||j))}finally{T(!1)}},[a,E,Cn]),u_=x.useCallback(b=>{navigator.clipboard.writeText(b).then(()=>{R(!0),setTimeout(()=>R(!1),2e3)}).catch(()=>{})},[]),Dp=x.useCallback(()=>{Ni(He,xt)},[Ni,He,xt]),d_=x.useCallback((b,j)=>{const z=j.trim()===""||j==="default"?void 0:j.trim(),W=He.map(K=>K.id===b?{...K,data:{...K.data,model:z}}:K);Ue(W),Ni(W,xt)},[He,xt,Ue,Ni]),wu=x.useCallback(()=>{var ce;if(!Oe||!a||!Pe)return!1;const b=Pe.id,j=Oe.newId.trim();if(su(""),!N4.test(j))return su(e("flow:nodePropsError.invalidInstanceId")),!1;if(He.some(we=>we.id===j&&we.id!==b))return su(e("flow:nodePropsError.duplicateInstanceId")),!1;const z=Oe.role.trim(),W=Ko.includes(z)?z:"普通",K=Oe.model.trim(),Y=we=>(Array.isArray(we)?we:[]).map(Ve=>({type:String((Ve==null?void 0:Ve.type)??"节点").trim()||"节点",name:String((Ve==null?void 0:Ve.name)??""),default:String((Ve==null?void 0:Ve.default)??"")})),Z=Y(Oe.inputs),te=Y(Oe.outputs),se=String(((ce=Pe.data)==null?void 0:ce.definitionId)??j),oe={...Pe.data,label:Oe.label.trim()||j,role:W,model:K===""||K==="default"?void 0:K,body:Oe.body,inputs:Z,outputs:te},me=String(Oe.script??"").trim();se==="tool_nodejs"||me!==""?oe.script=String(Oe.script??""):delete oe.script;let X,ue=xt;if(j!==b){const we={...Gr.current},Ve={...we[b]||{}};delete we[b],we[j]=Ve,Gr.current=we,X=He.map(We=>We.id!==b?We:{...We,id:j,selected:!0,data:oe}),ue=xt.map((We,Up)=>({...We,source:We.source===b?j:We.source,target:We.target===b?j:We.target,id:`e-${We.source===b?j:We.source}-${We.target===b?j:We.target}-${Up}`}))}else X=He.map(we=>we.id===b?{...we,data:oe}:we);return Ue(X),Tt(ue),Ni(X,ue),!0},[Oe,a,Pe,He,xt,Ue,Tt,Ni]),Fp=x.useCallback(()=>{var we;if(!Oe||!a||!Pe)return!1;const b=Pe.id,j=Oe.role.trim(),z=Ko.includes(j)?j:"普通",W=Oe.model.trim(),K=Ve=>(Array.isArray(Ve)?Ve:[]).map(We=>({type:String((We==null?void 0:We.type)??"节点").trim()||"节点",name:String((We==null?void 0:We.name)??""),default:String((We==null?void 0:We.default)??"")})),Y=K(Oe.inputs),Z=K(Oe.outputs),te=String(((we=Pe.data)==null?void 0:we.definitionId)??b),se=Oe.label.trim()||b,oe=W===""||W==="default"?void 0:W,me={...Pe.data,label:se,role:z,model:oe,body:Oe.body,inputs:Y,outputs:Z},X=String(Oe.script??"").trim();te==="tool_nodejs"||X!==""?me.script=String(Oe.script??""):delete me.script;const ue=Pe.data||{};return(ue.label!==me.label||ue.role!==me.role||ue.model!==me.model||ue.body!==me.body||(ue.script??void 0)!==(me.script??void 0)||JSON.stringify(ue.inputs||[])!==JSON.stringify(Y)||JSON.stringify(ue.outputs||[])!==JSON.stringify(Z))&&Ue(Ve=>Ve.map(We=>We.id===b?{...We,data:me}:We)),!0},[Oe,a,Pe,Ue]),rw=x.useRef(Fp);x.useEffect(()=>{rw.current=Fp},[Fp]),x.useEffect(()=>{if(!Oe||!a||!Ka.current||he!=="edit")return;const b=setTimeout(()=>{rw.current()},400);return()=>clearTimeout(b)},[Oe,a,he]);const f_=x.useCallback(()=>{if(!(!Oe||!Pe)){if(Oe.newId.trim()===Pe.id){su("");return}wu()}},[Oe,Pe,wu]);x.useEffect(()=>{const b=j=>{if(he!=="edit")return;const z=o4(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(J==="node"&&Pe&&Oe){j.preventDefault(),j.stopPropagation(),wu()||Dp();return}if(z)return;j.preventDefault(),j.stopPropagation(),Dp();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),zx(W=>!W);return}if(!kp){if(ou){if(j.key==="Escape"){j.preventDefault(),Fa(!1);return}if(Jv(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Fa(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(!z){if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),Ue(W=>W.map(K=>({...K,selected:!0}))),Tt(W=>W.map(K=>({...K,selected:!1})));return}if(Jv(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Fa(W=>!W);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Sp("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Sp("pan");return}}}};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[Dp,ou,kp,J,Pe,Oe,wu,he]),x.useEffect(()=>{if(he!=="running"||Vt==null)return;let b=Math.floor((Date.now()-Vt)/1e3);const j=setInterval(()=>{const z=Date.now()-Vt,W=Math.floor(z/1e3);W!==b&&(b=W,lt(z))},500);return()=>clearInterval(j)},[he,Vt]),x.useEffect(()=>{const b=fo.current;!b||!b.parentElement||Ta.current&&(po.current=!0,b.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{po.current=!1}))},[G]),x.useEffect(()=>{const b=fo.current;if(!b)return;const j=b.parentElement;if(!j)return;const z=()=>{if(po.current)return;const W=j.scrollHeight-j.scrollTop-j.clientHeight;Ta.current=W<40};return j.addEventListener("scroll",z,{passive:!0}),()=>j.removeEventListener("scroll",z)},[cn,he]),x.useEffect(()=>{if(he==="edit"||!cn)return;Ta.current=!0;const b=fo.current;b&&(po.current=!0,b.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{po.current=!1}))},[he,cn]),x.useEffect(()=>{G.length>Pd+u1&&Q(b=>b.length>Pd+u1?b.slice(-Pd):b)},[G]);const p_=x.useCallback(b=>{if(b.button!==0)return;b.preventDefault();const j=b.currentTarget;Qo.current={active:!0,pointerId:b.pointerId,startY:b.clientY,startH:Ea},j.setPointerCapture(b.pointerId)},[Ea]),h_=x.useCallback(b=>{const j=Qo.current;if(!j.active||b.pointerId!==j.pointerId)return;const z=j.startY-b.clientY;ja(_d(j.startH+z))},[]),vu=x.useCallback(()=>{ja(b=>{const j=_d(b);try{localStorage.setItem(eP,String(j))}catch{}return j})},[]),iw=x.useCallback(b=>{const j=Qo.current;if(!(!j.active||b.pointerId!==j.pointerId)){j.active=!1;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}vu()}},[vu]),m_=x.useCallback(()=>{const b=Qo.current;b.active&&(b.active=!1,vu())},[vu]);x.useEffect(()=>{function b(){ja(j=>_d(j))}return window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const Pr=x.useCallback(async(b={})=>{if(!a)return;const j=b.runUuid!=null&&String(b.runUuid).trim()?String(b.runUuid).trim():null,z=b.cliInputsOverride??Yc.current,W=!!b.prepareOnly;if(gt(W?"ready":"running"),Q(W?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),Ie(new Set),Ct({}),Ft(!W),le(null),j||lo(null),W)return;if(!j){const Y=Date.now();tn(Y),lt(0)}const K=new AbortController;kr.current=K;try{const Y=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,...j?{uuid:j}:{},cliInputs:z}),signal:K.signal});if(!Y.ok){const X=await Y.json().catch(()=>({error:e("flow:composer.requestFailed")}));Q(ue=>[...ue,{ts:new Date().toISOString(),type:"error",text:X.error||e("flow:composer.requestFailed")}]),gt("error");return}if(Q(X=>[...X,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!Y.body){Q(X=>[...X,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),gt("error");return}const Z=Y.body.getReader(),te=new TextDecoder;let se="";const oe=X=>{const ue=X.ts||new Date().toISOString();if(X.type==="event")if(X.event==="node-start")Ie(ce=>new Set(ce).add(X.instanceId)),Ct(ce=>({...ce,[X.instanceId]:{status:"running",startMs:Date.now()}})),Q(ce=>[...ce,{ts:ue,type:"node-start",text:X.label?e("flow:run.nodeStartWithLabel",{instanceId:X.instanceId,label:X.label}):e("flow:run.nodeStart",{instanceId:X.instanceId})}]);else if(X.event==="node-done"){Ie(we=>{const Ve=new Set(we);return Ve.delete(X.instanceId),Ve});const ce=X.elapsed??null;Ct(we=>({...we,[X.instanceId]:{status:"success",elapsed:ce}})),Q(we=>[...we,{ts:ue,type:"node-done",text:ce?e("flow:run.nodeDoneWithElapsed",{instanceId:X.instanceId,elapsed:ce}):e("flow:run.nodeDone",{instanceId:X.instanceId})}])}else if(X.event==="node-failed")Ie(ce=>{const we=new Set(ce);return we.delete(X.instanceId),we}),Ct(ce=>({...ce,[X.instanceId]:{status:"failed",elapsed:X.elapsed??null}})),Q(ce=>[...ce,{ts:ue,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:X.instanceId})}]);else if(X.event==="apply-start"){if(X.uuid&&lo(String(X.uuid)),typeof X.runStartTime=="number"&&X.runStartTime>0)tn(X.runStartTime),lt(Math.max(0,Date.now()-X.runStartTime));else if(typeof X.totalExecutedMs=="number"&&X.totalExecutedMs>0){const ce=Date.now()-X.totalExecutedMs;tn(ce),lt(X.totalExecutedMs)}Q(ce=>[...ce,{ts:ue,type:"info",text:e("flow:run.pipelineStart",{uuid:X.uuid||"?"})}])}else X.event==="apply-done"?Q(ce=>[...ce,{ts:ue,type:"info",text:X.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:X.totalElapsed}):e("flow:run.pipelineDone")}]):X.event==="apply-paused"?Q(ce=>[...ce,{ts:ue,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(X.pendingNodes||[]).join(", ")})}]):Q(ce=>[...ce,{ts:ue,type:"event",text:`[${X.event}] ${JSON.stringify(X)}`}]);else X.type==="user-check-content"?(ns({instanceId:X.instanceId,execId:X.execId??1,inputPath:X.inputPath,outputPath:X.outputPath,content:X.content||""}),rs(X.content||""),mo(!1),is(""),ss(!1),Q(ce=>[...ce,{ts:ue,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:X.instanceId})}])):X.type==="user-ask-prompt"?(Ra({instanceId:X.instanceId,execId:X.execId??1,question:X.question||"",options:Array.isArray(X.options)?X.options:[]}),bi(!1),Q(ce=>[...ce,{ts:ue,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:X.instanceId,defaultValue:`等待用户选择 (${X.instanceId})`})}])):X.type==="tool-print-content"?$x({instanceId:X.instanceId,execId:X.execId??1,content:X.content||"",createdAt:Date.now()}):X.type==="log"?Q(ce=>[...ce,{ts:ue,type:"log",text:X.text!=null?String(X.text):""}]):X.type==="error"?Q(ce=>[...ce,{ts:ue,type:"error",text:X.message||e("flow:run.unknownError")}]):X.type==="done"?Q(ce=>[...ce,{ts:ue,type:"done",text:e("flow:run.executionEnd",{exitCode:X.exitCode??"?"})}]):Q(ce=>[...ce,{ts:ue,type:"log",text:JSON.stringify(X)}])},me=X=>{if(X.trim())try{oe(JSON.parse(X))}catch{Q(ue=>[...ue,{ts:new Date().toISOString(),type:"log",text:X}])}};for(;;){const{done:X,value:ue}=await Z.read();se+=te.decode(ue??new Uint8Array,{stream:!X});const ce=se.split(`
126
- `);se=ce.pop()??"";for(const we of ce)me(we);if(X)break}se.trim()&&me(se),gt("done")}catch(Y){Y.name==="AbortError"?(Q(Z=>[...Z,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),gt("stopped")):(Q(Z=>[...Z,{ts:new Date().toISOString(),type:"error",text:Y.message||e("flow:run.unknownError")}]),gt("error"))}finally{kr.current=null,Ie(new Set)}},[a]),[g_,$p]=x.useState(!1),y_=x.useCallback(()=>{$p(!0)},[]),x_=x.useCallback(async()=>{if($p(!1),kr.current&&(kr.current.abort(),kr.current=null),a)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id})})}catch{}gt("stopped"),Ie(new Set)},[a]),xo=x.useCallback(()=>{gt("edit"),Ie(new Set),Ct({}),Jo(null),lo(null)},[]),[w_,bu]=x.useState(!1),v_=x.useCallback(async()=>{if(bu(!1),kr.current&&(kr.current.abort(),kr.current=null),a)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id})})}catch{}xo()},[a,xo]),b_=x.useCallback(()=>{bu(!1),t("/projects")},[t]),S_=x.useCallback(b=>{const j=b.runId!=null&&String(b.runId).trim()?String(b.runId).trim():null,z=b.flowId!=null&&String(b.flowId).trim()?String(b.flowId).trim():(a==null?void 0:a.id)!=null?String(a.id):null;lo(j);const W=b.status||"unknown";let K="stopped";W==="success"?K="done":W==="failed"?K="error":W==="running"?K="running":K="stopped",gt(K);const Y=typeof b.at=="number"?b.at:null;if(K==="running"&&Y!=null?(tn(Y),lt(Math.max(0,Date.now()-Y))):Y!=null&&typeof b.endedAt=="number"&&b.endedAt>Y?(tn(null),lt(b.endedAt-Y)):(tn(null),lt(Math.max(0,b.durationMs??0))),Q([]),Ie(new Set),Ct({}),Jo(null),le(null),Ft(!1),j&&z){const Z=new URLSearchParams({flowId:z,runId:j});fetch(`/api/run-node-statuses?${Z}`).then(te=>te.json()).then(te=>{const se=te.statuses&&typeof te.statuses=="object"?te.statuses:{},oe={};for(const[me,X]of Object.entries(se))X&&typeof X=="object"&&typeof X.status=="string"&&(oe[me]={status:X.status,...X.elapsed!=null&&String(X.elapsed).trim()!==""?{elapsed:String(X.elapsed)}:{}});Ct(oe)}).catch(()=>{})}},[a==null?void 0:a.id]);x.useEffect(()=>{if(!(a!=null&&a.id)||he!=="edit")return;let b=!1;return(async()=>{try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(b||!j.ok)return;const K=(Array.isArray(z.runs)?z.runs:[]).find(te=>te.flowId===a.id&&te.status==="running");if(!K||b)return;const Y=K.runId||null;lo(Y),gt("running"),Ft(!0),tn(K.at||Date.now()),Ne.current=0;const Z=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${Y},已恢复运行视图`}];if(Y){const te=new URLSearchParams({flowId:a.id,runId:Y}),oe=await(await fetch(`/api/run-node-statuses?${te}`)).json();if(b)return;const me=oe.statuses&&typeof oe.statuses=="object"?oe.statuses:{},X={},ue=new Set;for(const[ce,we]of Object.entries(me))we&&typeof we=="object"&&typeof we.status=="string"&&(X[ce]={status:we.status,...we.elapsed!=null&&String(we.elapsed).trim()!==""?{elapsed:String(we.elapsed)}:{}},we.status==="running"&&ue.add(ce));Ct(X),Ie(ue);try{const ce=new URLSearchParams({flowId:a.id,runId:Y,sinceBytes:"0",tailBytes:"262144"}),we=await fetch(`/api/run-log?${ce}`);if(we.ok){const Ve=await we.json();if(!b){Ne.current=Number(Ve.bytes||0);const We=d1(typeof Ve.text=="string"?Ve.text:"");Q([...We,...Z]);return}}}catch{}}Q(Z)}catch{}})(),()=>{b=!0}},[a==null?void 0:a.id]),x.useEffect(()=>{if(he==="edit"||!(a!=null&&a.id)||!ft)return;let b=!1,j=null;const z=async()=>{try{const W=new URLSearchParams({flowId:a.id,runId:ft}),K=await fetch(`/api/run-node-statuses?${W}`);if(!K.ok)return;const Y=await K.json();if(b)return;const Z=Y.statuses&&typeof Y.statuses=="object"?Y.statuses:{},te={},se=new Set;for(const[oe,me]of Object.entries(Z))me&&typeof me=="object"&&typeof me.status=="string"&&(te[oe]={status:me.status,...me.elapsed!=null&&String(me.elapsed).trim()!==""?{elapsed:String(me.elapsed)}:{}},me.status==="running"&&se.add(oe));Ct(oe=>W6(oe,te)?oe:te),Ie(oe=>K6(oe,se)?oe:se);try{const oe=new URLSearchParams({flowId:a.id,runId:ft,sinceBytes:String(Ne.current||0),tailBytes:String(B6)}),me=await fetch(`/api/run-log?${oe}`);if(me.ok){const X=await me.json();if(b)return;const ue=Number(X.bytes||0),ce=typeof X.text=="string"?X.text:"";if(ce){const we=d1(ce);we.length>0&&Q(Ve=>[...Ve,...we])}Ne.current=ue}}catch{}try{const oe=await fetch("/api/pipeline-recent-runs");if(!oe.ok)return;const me=await oe.json();if(b)return;const ue=(Array.isArray(me.runs)?me.runs:[]).find(ce=>ce.flowId===a.id&&ce.runId===ft);if(ue&&ue.status){const ce=ue.status;ce==="running"?gt(we=>we==="running"?we:"running"):ce==="success"?gt("done"):ce==="failed"?gt("error"):(ce==="stopped"||ce==="interrupted")&&gt("stopped")}}catch{}}catch{}};return z(),j=window.setInterval(z,2500),()=>{b=!0,j&&window.clearInterval(j)}},[he,a==null?void 0:a.id,ft]),x.useEffect(()=>{if(J!=="history"||!a)return;let b=!1;return(async()=>{Ke(!0),xe("");try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(!j.ok)throw new Error(z.error||"HTTP "+j.status);b||ye(Array.isArray(z.runs)?z.runs:[])}catch(j){b||(xe(String(j.message||j)),ye([]))}finally{b||Ke(!1)}})(),()=>{b=!0}},[J,a]),x.useEffect(()=>{if(!a){Dt({files:[]});return}let b=!1;return(async()=>{wr(!0);try{const j=new URLSearchParams({flowId:a.id,flowSource:a.source||"user",archived:a.archived?"1":"0"}),z=await fetch(`/api/pipeline-files?${j}`),W=await z.json();if(!z.ok)throw new Error(W.error||"HTTP "+z.status);b||Dt({files:Array.isArray(W.files)?W.files:[],path:W.path,error:W.error})}catch(j){b||Dt({files:[],error:j.message||String(j)})}finally{b||wr(!1)}})(),()=>{b=!0}},[a]);const qa=x.useMemo(()=>a?Se.filter(b=>b&&b.flowId===a.id).sort((b,j)=>j.at-b.at):[],[Se,a]),nn=x.useMemo(()=>{let b=0,j=0,z=0,W=0,K=0;for(const Y of qa){const Z=Y.status||"unknown";Z==="success"?b+=1:Z==="failed"?j+=1:Z==="running"?z+=1:Z==="stopped"?W+=1:Z==="interrupted"&&(K+=1)}return{success:b,failed:j,running:z,stopped:W,interrupted:K}},[qa]),Ga=x.useMemo(()=>a?a1(zn,iu):null,[a,zn,iu]),tr=x.useMemo(()=>{if(!Ga||!a)return[];const b=Ga.query.toLowerCase(),j=K=>b?K.some(Y=>Y&&String(Y).toLowerCase().includes(b)):!0,z=He.map(K=>{var oe,me;const Y=K.id,Z=String(((oe=K.data)==null?void 0:oe.label)??Y),te=(me=K.data)!=null&&me.definitionId?String(K.data.definitionId):"",se=[Z!==Y?Z:"",te&&te!==Y?te:""].filter(Boolean);return{id:Y,label:Z,defId:te,subs:se}}).filter(({id:K,label:Y,defId:Z})=>j([K,Y,Z])).sort((K,Y)=>K.id.localeCompare(Y.id)).slice(0,18).map(({id:K,label:Y,defId:Z})=>{const te=[Y!==K?Y:null,Z||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:K,title:K,subtitle:te}}),W=q.filter(K=>K&&K.id&&j([K.id,K.label,K.description])).sort((K,Y)=>K.id.localeCompare(Y.id)).slice(0,22).map(K=>({kind:"definition",id:K.id,title:K.id,subtitle:K.label&&K.label!==K.id?String(K.label):String(K.type||"")}));return[...z,...W]},[Ga,He,q,a]),Xa=x.useMemo(()=>{const b=tr.filter(z=>z.kind==="instance"),j=tr.filter(z=>z.kind==="definition");return{instances:b,definitions:j}},[tr]);x.useEffect(()=>{Da(b=>{const j=Math.max(0,tr.length-1);return Math.min(Math.max(0,b),j)})},[tr]);const ow=x.useMemo(()=>R6(zn),[zn]),sw=x.useMemo(()=>He.filter(b=>b.selected),[He]),Su=x.useMemo(()=>{const b=[],j=new Set;for(const K of sw)j.add(K.id),b.push({node:K,kind:"canvas"});const z=new Map(He.map(K=>[K.id,K])),W=new Map(q.map(K=>[K.id,K]));for(const K of ow){if(j.has(K))continue;const Y=z.get(K);if(Y){j.add(K),b.push({node:Y,kind:"mention"});continue}const Z=W.get(K);Z&&(j.add(K),b.push({definition:Z,kind:"definition"}))}return b},[sw,ow,He,q]),dn=x.useMemo(()=>{const b=Array.isArray(_e==null?void 0:_e.cursor)?_e.cursor:[],j=Array.isArray(_e==null?void 0:_e.opencode)?_e.opencode:[],z=Array.isArray(_e==null?void 0:_e.claudeCode)?_e.claudeCode:[],W=j.map(oe=>`opencode:${ei(oe)}`),K=z.map(oe=>`claude-code:${ei(oe)}`),Y=new Set([...b,...j,...z].map(ei).concat(W).concat(K)),Z=(go||"").trim(),te=nd(go,b,j,z),se=te&&!Y.has(te)&&!Y.has(Z)?Z:"";return{cursorList:b,opencodeList:j,claudeCodeList:z,currentNotInLists:se}},[_e,go]);x.useEffect(()=>{const b=Array.isArray(_e==null?void 0:_e.cursor)?_e.cursor:[],j=Array.isArray(_e==null?void 0:_e.opencode)?_e.opencode:[],z=Array.isArray(_e==null?void 0:_e.claudeCode)?_e.claudeCode:[];Bx(W=>{const K=nd(W,b,j,z);return K===W?W:K})},[_e.cursor,_e.opencode,_e.claudeCode]);const wo=x.useCallback(async(b,j={})=>{var pw;if(!a||Ap.current)return;const z=j.phaseContextSnapshot,W=(typeof b=="string"?b:zn).trim();if(!W)return;const K=Vx.current;Ap.current=!0,Yx(!0),Cr(e("flow:composer.connecting")),le(it=>it!=="composer"?"composer":it);const Y=[...Ha];if(K.length>0&&Y.push({type:"assistant",segments:[...K]}),qx([...Y,{type:"user",text:W}]),Y.filter(it=>it.type==="user").length===0){const it=W.replace(/\s+/g," ").slice(0,30)+(W.length>30?"…":"");Nr(Hn=>Hn.map(Yt=>Yt.id===Kt?{...Yt,label:it}:Yt))}const Z=Y.map(it=>it.type==="user"?{role:"user",text:it.text}:{role:"assistant",text:(it.segments||[]).filter(Yt=>Yt.kind==="assistant"||Yt.kind==="result").map(Yt=>Yt.text).join(`
120
+ `}),n}function Tb(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Rb(e,t){const n=R6(e,t),r=n.one(e,void 0),i=S6(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
121
+ `},i),o}function F6(e,t){return e&&"run"in e?async function(n,r){const i=Rb(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Rb(n,{file:r,...e||t})}}function Lb(e){if(e)throw e}var Ed=Object.prototype.hasOwnProperty,Kj=Object.prototype.toString,Ob=Object.defineProperty,Mb=Object.getOwnPropertyDescriptor,Db=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Kj.call(t)==="[object Array]"},Fb=function(t){if(!t||Kj.call(t)!=="[object Object]")return!1;var n=Ed.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Ed.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||Ed.call(t,i)},$b=function(t,n){Ob&&n.name==="__proto__"?Ob(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},zb=function(t,n){if(n==="__proto__")if(Ed.call(t,n)){if(Mb)return Mb(t,n).value}else return;return t[n]},$6=function e(){var t,n,r,i,o,s,a=arguments[0],l=1,u=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(t=arguments[l],t!=null)for(n in t)r=zb(a,n),i=zb(t,n),a!==i&&(f&&i&&(Fb(i)||(o=Db(i)))?(o?(o=!1,s=r&&Db(r)?r:[]):s=r&&Fb(r)?r:{},$b(a,{name:n,newValue:e(f,s,i)})):typeof i<"u"&&$b(a,{name:n,newValue:i}));return a};const $h=ro($6);function Fg(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function z6(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...i);function a(l,...u){const f=e[++o];let d=-1;if(l){s(l);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,f?B6(f,a)(...u):s(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function B6(e,t){let n;return r;function r(...s){const a=e.length>s.length;let l;a&&s.push(i);try{l=e.apply(this,s)}catch(u){const f=u;if(a&&n)throw f;return i(f)}a||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(s,...a){n||(n=!0,t(s,...a))}function o(s){i(null,s)}}const Ar={basename:H6,dirname:U6,extname:V6,join:W6,sep:"/"};function H6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fc(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}function U6(e){if(Fc(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function V6(e){Fc(e);let t=e.length,n=-1,r=0,i=-1,o=0,s;for(;t--;){const a=e.codePointAt(t);if(a===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),a===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function W6(...e){let t=-1,n;for(;++t<e.length;)Fc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":K6(n)}function K6(e){Fc(e);const t=e.codePointAt(0)===47;let n=Y6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Y6(e,t){let n="",r=0,i=-1,o=0,s=-1,a,l;for(;++s<=e.length;){if(s<e.length)a=e.codePointAt(s);else{if(a===47)break;a=47}if(a===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,o=0}else a===46&&o>-1?o++:o=-1}return n}function Fc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const q6={cwd:G6};function G6(){return"/"}function $g(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function X6(e){if(typeof e=="string")e=new URL(e);else if(!$g(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Q6(e)}function Q6(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const zh=["history","path","basename","stem","extname","dirname"];class Yj{constructor(t){let n;t?$g(t)?n={path:t}:typeof t=="string"||J6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":q6.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zh.length;){const o=zh[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)zh.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ar.basename(this.path):void 0}set basename(t){Hh(t,"basename"),Bh(t,"basename"),this.path=Ar.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ar.dirname(this.path):void 0}set dirname(t){Bb(this.basename,"dirname"),this.path=Ar.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ar.extname(this.path):void 0}set extname(t){if(Bh(t,"extname"),Bb(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ar.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){$g(t)&&(t=X6(t)),Hh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ar.basename(this.path,this.extname):void 0}set stem(t){Hh(t,"stem"),Bh(t,"stem"),this.path=Ar.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new en(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Bh(e,t){if(e&&e.includes(Ar.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ar.sep+"`")}function Hh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Bb(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function J6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Z6=function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},e8={}.hasOwnProperty;class Cx extends Z6{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=z6()}copy(){const t=new Cx;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data($h(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Wh("data",this.frozen),this.namespace[t]=n,this):e8.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Wh("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ed(t),r=this.parser||this.Parser;return Uh("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Uh("process",this.parser||this.Parser),Vh("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){const a=ed(t),l=r.parse(a);r.run(l,a,function(f,d,p){if(f||!d||!p)return u(f);const h=d,m=r.stringify(h,p);r8(m)?p.value=m:p.result=m,u(f,p)});function u(f,d){f||!d?s(f):o?o(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Uh("processSync",this.parser||this.Parser),Vh("processSync",this.compiler||this.Compiler),this.process(t,i),Ub("processSync","process",n),r;function i(o,s){n=!0,Lb(o),r=s}}run(t,n,r){Hb(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,a){const l=ed(n);i.run(t,l,u);function u(f,d,p){const h=d||t;f?a(f):s?s(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),Ub("runSync","run",r),i;function o(s,a){Lb(s),i=a,r=!0}}stringify(t,n){this.freeze();const r=ed(n),i=this.compiler||this.Compiler;return Vh("stringify",i),Hb(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Wh("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,d)}else s(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function s(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=$h(!0,i.settings,u.settings))}function a(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];o(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...f]);else if(f.length>0){let[h,...m]=f;const v=r[p][1];Fg(v)&&Fg(h)&&(h=$h(!0,v,h)),r[p]=[u,h,...m]}}}}const t8=new Cx().freeze();function Uh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Vh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Wh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Hb(e){if(!Fg(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ub(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ed(e){return n8(e)?e:new Yj(e)}function n8(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function r8(e){return typeof e=="string"||i8(e)}function i8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const o8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Vb=[],Wb={allowDangerousHtml:!0},s8=/^(https?|ircs?|mailto|xmpp)$/i,a8=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function qj(e){const t=l8(e),n=c8(e);return u8(t.runSync(t.parse(n),n),e)}function l8(e){const t=e.rehypePlugins||Vb,n=e.remarkPlugins||Vb,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Wb}:Wb;return t8().use(UH).use(n).use(F6,r).use(t)}function c8(e){const t=e.children||"",n=new Yj;return typeof t=="string"&&(n.value=t),n}function u8(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||d8;for(const f of a8)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+o8+f.id,void 0);return Wj(e,u),S5(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return s?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Mh)if(Object.hasOwn(Mh,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],v=Mh[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=l(String(m||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):o?o.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return a&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function d8(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||s8.test(e.slice(0,t))?e:""}function Ex(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 f8(e){const t=Ex(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 Gj(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Kb({text:e}){const{t}=rt(),n=e||"";return n.trim()?c.jsx("div",{className:"af-run-ctx-md",children:c.jsx(qj,{children:n})}):c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Yb({o:e}){var r;const{t}=rt(),n=Ex(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return c.jsxs("div",{className:"af-run-ctx-media",children:[c.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return c.jsx("pre",{className:"af-run-ctx-pre",children:Gj(e.content||"")});if(n==="markdown"){const i=e.content||"";return i.trim()?c.jsx("div",{className:"af-run-ctx-md",children:c.jsx(qj,{children:i})}):c.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return c.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function qb(e){return f8(e)}function Gb(e){var r;if(!e)return null;const t=Ex(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"?Gj(String(n)):String(n)}function Xb({text:e,title:t,copiedLabel:n}){const[r,i]=x.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),i(!0),window.setTimeout(()=>i(!1),1400)}catch{}};return c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:c.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Qb=2e4,Xj="af:run-node-ctx-width";function jd(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Fi(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):Fi(jd())}function p8(){try{const e=localStorage.getItem(Xj);if(e==null)return Fi(jd());const t=parseInt(e,10);return Number.isFinite(t)?Fi(t):Fi(jd())}catch{return Fi(jd())}}async function Jb(e,t,n,r){const i=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&i.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${i.toString()}`,{signal:r}),s=await o.text();let a;try{a=JSON.parse(s)}catch{throw new Error(s.startsWith("<!")||s.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(a.error||"HTTP "+o.status);return a}function h8(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function m8({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:i}){const{t:o}=rt(),[s,a]=x.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[l,u]=x.useState(p8),f=x.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[d,p]=x.useState(!0),[h,m]=x.useState(""),[v,k]=x.useState([]),[g,w]=x.useState(null),[y,N]=x.useState(null),E=x.useRef(null),S=x.useRef(null),P=x.useRef(0),T=x.useRef(0);x.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),I=()=>a(_.matches);return _.addEventListener("change",I),()=>_.removeEventListener("change",I)},[]),x.useEffect(()=>{function _(){u(I=>Fi(I))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const M=x.useCallback(()=>{u(_=>{const I=Fi(_);try{localStorage.setItem(Xj,String(I))}catch{}return I})},[]),B=x.useCallback(_=>{if(s||_.button!==0)return;_.preventDefault();const I=_.currentTarget;f.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:l},I.setPointerCapture(_.pointerId)},[s,l]),A=x.useCallback(_=>{const I=f.current;if(!I.active||_.pointerId!==I.pointerId)return;const C=I.startX-_.clientX;u(Fi(I.startW+C))},[]),R=x.useCallback(_=>{const I=f.current;if(!(!I.active||_.pointerId!==I.pointerId)){I.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}M()}},[M]),V=x.useCallback(()=>{const _=f.current;_.active&&(_.active=!1,M())},[M]),L=x.useCallback(_=>{const I=Array.isArray(_)?_:[];k(I),w(C=>C&&I.some(F=>F.execId===C)?C:I.length>0?I[I.length-1].execId:null)},[]),H=x.useCallback(()=>{if(!e||!t)return;const _=++P.current,I=new AbortController,C=window.setTimeout(()=>I.abort(),Qb);(async()=>{try{const F=await Jb(t,e,n,I.signal);if(_!==P.current)return;L(Array.isArray(F.rounds)?F.rounds:[])}catch{}finally{window.clearTimeout(C)}})()},[e,t,n,L]);x.useEffect(()=>{if(!e||!t){p(!1),m(""),k([]);return}const _=++T.current;p(!0),m(""),k([]),w(null);const I=new AbortController,C=window.setTimeout(()=>I.abort(),Qb);return(async()=>{try{const F=await Jb(t,e,n,I.signal);if(_!==T.current)return;L(Array.isArray(F.rounds)?F.rounds:[])}catch(F){if(_!==T.current)return;const U=(F==null?void 0:F.name)==="AbortError"?"requestTimeout":F.message||String(F);m(U)}finally{window.clearTimeout(C),_===T.current&&p(!1)}})(),()=>{I.abort(),T.current++,P.current++}},[e,t,n,L]),x.useEffect(()=>{r&&H()},[r,H]),x.useEffect(()=>{clearInterval(S.current);const _=v.length>0?v[v.length-1]:null;return(r==="running"&&v.length===0||!!(_&&_.status==="running"))&&e&&t&&(S.current=setInterval(()=>H(),2e3)),()=>clearInterval(S.current)},[v,e,t,n,r,H]),x.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[g]);const D=v.find(_=>_.execId===g),$=s?void 0:{width:`${l}px`};return c.jsxs("aside",{className:"af-run-ctx-panel",style:$,"aria-label":o("flow:runContext.title"),children:[s?null:c.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:B,onPointerMove:A,onPointerUp:R,onPointerCancel:R,onLostPointerCapture:V}),c.jsxs("div",{className:"af-run-ctx-panel__main",children:[c.jsxs("div",{className:"af-run-ctx-head",children:[c.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:i,"aria-label":o("common:common.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),d&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),h&&c.jsx("div",{className:"af-run-ctx-error",children:h8(o,h)}),!d&&!h&&v.length===0&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),v.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+y8((D==null?void 0:D.status)||""),children:[c.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),c.jsx("select",{className:"af-run-ctx-round-select",value:String(g??""),onChange:_=>{const I=_.target.value;w(I==="latest"?"latest":Number(I))},children:[...v].reverse().map(_=>{const I=_.execId==="latest"?o("flow:runContext.latest"):`#${_.execId}`,C=x8(o,_.status),F=_.finishedAt?` · ${g8(_.finishedAt)}`:"";return c.jsx("option",{value:String(_.execId),children:`${I} · ${C}${F}`},_.execId)})})]}),D&&c.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[D.inputs&&D.inputs.length>0&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),D.inputs.map((_,I)=>c.jsxs("div",{className:"af-run-ctx-output-slot",children:[c.jsx("div",{className:"af-run-ctx-slot-head",children:c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot})}),c.jsx("pre",{className:"af-run-ctx-slot-text",children:_.value})]},`${_.slot}-${I}`))]}),D.prompt!=null&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:o("flow:nodeProps.expand"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),c.jsx(Kb,{text:D.prompt})]}),D.outputs&&D.outputs.length>0&&c.jsxs("section",{className:"af-run-ctx-section",children:[c.jsxs("h3",{className:"af-run-ctx-section-title",children:[c.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",c.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:o("flow:nodeProps.expand"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),D.outputs.map((_,I)=>{const C=qb(_),F=Gb(_);return c.jsxs("div",{className:"af-run-ctx-output-slot",children:[c.jsxs("div",{className:"af-run-ctx-slot-head",children:[c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),C?c.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:C}):null,c.jsx(Xb,{text:F,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),c.jsx(Yb,{o:_})]},`${_.slot}-${I}`)})]}),!D.prompt&&(!D.outputs||D.outputs.length===0)&&c.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),y&&D&&c.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:_=>{_.target===_.currentTarget&&N(null)},children:c.jsxs("div",{className:"af-node-props-expand-panel",children:[c.jsxs("div",{className:"af-node-props-expand-head",children:[c.jsx("span",{className:"af-node-props-expand-title",children:y==="prompt"?"Prompt":"Outputs"}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":o("common:common.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[y==="prompt"&&D.prompt!=null&&c.jsx(Kb,{text:D.prompt}),y==="output"&&D.outputs&&D.outputs.map((_,I)=>{const C=qb(_),F=Gb(_);return c.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[c.jsxs("div",{className:"af-run-ctx-slot-head",children:[c.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),C?c.jsx("span",{className:"af-run-ctx-format-badge",children:C}):null,c.jsx(Xb,{text:F,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),c.jsx(Yb,{o:_})]},`${_.slot}-${I}`)})]})]})})]})}function g8(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 y8(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 x8(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 w8({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:i,nodes:o,onCliInputsChange:s,onBackToEdit:a}){const{t:l}=rt(),[u,f]=x.useState({}),[d,p]=x.useState(null),[h,m]=x.useState({}),[v,k]=x.useState(!0),[g,w]=x.useState(!1),[y,N]=x.useState(""),[E,S]=x.useState(!1),[P,T]=x.useState(null),M=x.useRef(null),B=x.useRef(!0),A=x.useRef({});x.useMemo(()=>{var C,F,U;const I={};for(const O of r){const q=(U=(F=(C=O.data)==null?void 0:C.outputs)==null?void 0:F[0])==null?void 0:U.default;q!=null&&q!==""&&(I[O.id]=String(q))}return A.current=I,I},[r]);const R=x.useMemo(()=>{var C;const I={};for(const F of o){if(!((C=F.data)!=null&&C.inputs))continue;const U=F.data.inputs;for(let O=0;O<U.length;O++){const q=U[O];if(!(q!=null&&q.name))continue;const ee=i.find(ae=>ae.target===F.id&&ae.targetHandle===`input-${O}`);if(!(ee!=null&&ee.source))continue;r.find(ae=>ae.id===ee.source)&&(I[ee.source]=q.name)}}return I},[o,i,r]);x.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),x.useEffect(()=>{if(!e){k(!1);return}k(!0);const I=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&I.set("archived","1"),fetch(`/api/flow/run-config?${I.toString()}`).then(C=>{if(!C.ok)throw new Error(`HTTP ${C.status}`);return C.json()}).then(C=>{var U;if(!B.current)return;f(C.presets||{}),p(C.activePreset||null);const F=C.activePreset&&((U=C.presets)!=null&&U[C.activePreset])?C.presets[C.activePreset]:{};m({...A.current,...F}),k(!1)}).catch(()=>{B.current&&(m(A.current),k(!1))})},[e,t,n]),x.useEffect(()=>{var C;if(!s)return;const I={};for(const[F,U]of Object.entries(h)){const O=R[F];if(!O)continue;const q=r.find(ne=>ne.id===F);if(!q)continue;(((C=q.data)==null?void 0:C.definitionId)||"").startsWith("provide_file")?I[O]={type:"file",path:U}:I[O]={type:"str",value:U}}s(I)},[h,R,r,s]);const V=x.useCallback((I,C)=>{m(F=>({...F,[I]:C}))},[]),L=x.useCallback(I=>{I!==d&&(p(I),I&&u[I]?m({...A.current,...u[I]}):m(A.current))},[d,u]),H=x.useCallback(async()=>{if(y.trim()){w(!0);try{const I={...u,[y.trim()]:h},C={flowId:e,flowSource:t,archived:n,presets:I,activePreset:y.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)})).ok&&(f(I),p(y.trim()),N(""),S(!1))}finally{w(!1)}}},[e,t,n,u,h,y]),D=x.useCallback(async()=>{if(d){w(!0);try{const I={...u};delete I[d];const C=Object.keys(I)[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:I,activePreset:C})})).ok&&(f(I),p(C),C&&I[C]?m({...A.current,...I[C]}):m(A.current))}finally{w(!1)}}},[e,t,n,u,d]),$=x.useCallback(async()=>{if(d){w(!0);try{const I={...u,[d]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:I,activePreset:d})})).ok&&f(I)}finally{w(!1)}}},[e,t,n,u,d,h]),_=Object.keys(u);return _.length>0,v?c.jsx("aside",{className:"af-run-config-panel",children:c.jsx("div",{className:"af-run-config-loading",children:l("common.loading")})}):c.jsxs("aside",{className:"af-run-config-panel",children:[c.jsxs("div",{className:"af-run-config-preset",children:[c.jsx("label",{className:"af-run-config-preset-label",children:l("flow:runConfig.preset")}),c.jsxs("div",{className:"af-run-config-preset-row",children:[c.jsxs("select",{className:"af-run-config-preset-select",value:d||"",onChange:I=>L(I.target.value||null),disabled:g,children:[c.jsx("option",{value:"",children:l("flow:runConfig.default")}),_.map(I=>c.jsx("option",{value:I,children:I},I))]}),c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>S(!0),disabled:g,title:l("flow:runConfig.newPreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),d&&c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:$,disabled:g,title:l("flow:runConfig.savePreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),d&&c.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:D,disabled:g,title:l("flow:runConfig.deletePreset"),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&c.jsxs("div",{className:"af-run-config-save-dialog",children:[c.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:l("flow:runConfig.presetNamePlaceholder"),value:y,onChange:I=>N(I.target.value),disabled:g}),c.jsxs("div",{className:"af-run-config-save-actions",children:[c.jsx("button",{type:"button",className:"af-btn-primary",onClick:H,disabled:g||!y.trim(),children:l(g?"common.saving":"common.save")}),c.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{S(!1),N("")},disabled:g,children:l("common.cancel")})]})]}),c.jsxs("div",{className:"af-run-config-inputs",children:[c.jsx("div",{className:"af-run-config-inputs-header",children:l("flow:runConfig.inputParams")}),r.length===0?c.jsx("div",{className:"af-run-config-empty",children:l("flow:runConfig.noProvideNodes")}):c.jsx("div",{className:"af-run-config-input-list",children:r.map(I=>{var ee,ne;const F=(((ee=I.data)==null?void 0:ee.definitionId)||"").startsWith("provide_file"),U=((ne=I.data)==null?void 0:ne.label)||I.id,O=I.id,q=h[O]||"";return c.jsxs("div",{className:"af-run-config-input-item",children:[c.jsxs("div",{className:"af-run-config-input-head",children:[c.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(F?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:F?"description":"text_fields"}),c.jsx("span",{className:"af-run-config-input-label",children:U}),c.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>T({instanceId:O,label:U,content:q}),"aria-label":l("flow:runConfig.expandInput"),title:l("flow:runConfig.expandInput"),children:c.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),c.jsx("div",{className:"af-run-config-input-id",children:O}),c.jsx("input",{type:"text",className:"af-run-config-input-field",value:q,onChange:ae=>V(O,ae.target.value),placeholder:l(F?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},O)})})]}),P&&qi.createPortal(c.jsx("div",{className:"af-provide-edit-overlay",children:c.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-provide-edit-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),c.jsx("span",{className:"af-provide-edit-modal__title",children:P.label}),c.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>T(null),"aria-label":l("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-provide-edit-modal__body",children:c.jsx("textarea",{ref:M,className:"af-provide-edit-modal__textarea",defaultValue:P.content,autoFocus:!0})}),c.jsxs("div",{className:"af-provide-edit-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!P||!M.current||(V(P.instanceId,M.current.value),T(null))},children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),l("flow:provideEdit.save")]}),c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>T(null),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),l("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const Qj={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"]},v8={"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 b8(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function S8(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 k8(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 Zb(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(Qj))if(r.includes(e))return n;return"other"}function N8({event:e,defaultExpanded:t}){const[n,r]=x.useState(!!t),i=v8[e.tag]||"#a8a8a8",o=e.payload,s=o&&typeof o=="object",a=s?typeof o.text=="string"?o.text:"":String(o||""),l=s?o.meta:null,u=x.useMemo(()=>a?a.slice(0,140).replace(/\s+/g," "):s?Object.keys(o).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const m=o[h];return m==null?`${h}:null`:typeof m=="object"?`${h}:{…}`:`${h}:${String(m).slice(0,30)}`}).join(" "):"",[o,a,s]),f=x.useCallback(d=>{d.stopPropagation();const p=s?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(p)}catch{}},[o,s]);return c.jsxs("div",{style:{borderLeft:`3px solid ${i}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(d=>!d),children:[c.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[c.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:S8(e.ts)}),c.jsx("span",{style:{color:i,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),c.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:u}),n&&c.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&&c.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[l&&Object.keys(l).length>0&&c.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(l,null,2)}),a?c.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:a}):s?c.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(o,null,2)}):null]})]})}function C8({open:e,onClose:t,flowId:n}){var T;const[r,i]=x.useState([]),[o,s]=x.useState(!1),[a,l]=x.useState(null),[u,f]=x.useState(null),[d,p]=x.useState(!1),[h,m]=x.useState(!0),[v,k]=x.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[g,w]=x.useState(""),y=x.useRef(null),N=x.useCallback(async()=>{s(!0);try{const M=h&&n?`?flowId=${encodeURIComponent(n)}`:"",A=await(await fetch(`/api/composer-logs${M}`)).json();i(Array.isArray(A.sessions)?A.sessions:[])}catch{i([])}finally{s(!1)}},[n,h]),E=x.useCallback(async M=>{if(!M){f(null);return}p(!0);try{const A=await(await fetch(`/api/composer-logs/${encodeURIComponent(M)}`)).json();f(A)}catch{f(null)}finally{p(!1)}},[]);x.useEffect(()=>{e&&N()},[e,N]),x.useEffect(()=>{if(!(!e||!a))return E(a),y.current=setInterval(()=>E(a),2e3),()=>{y.current&&clearInterval(y.current),y.current=null}},[e,a,E]);const S=x.useMemo(()=>{const M=(u==null?void 0:u.events)||[],B=g.trim().toLowerCase();return M.filter(A=>{const R=Zb(A.tag,A.payload);return!v[R]&&R!=="other"?!1:B?[A.tag,JSON.stringify(A.payload||"")].join(" ").toLowerCase().includes(B):!0})},[u,v,g]),P=x.useMemo(()=>{const M=(u==null?void 0:u.events)||[],B={};for(const A of M){const R=Zb(A.tag,A.payload);B[R]=(B[R]||0)+1}return B},[u]);return e?c.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:[c.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:[c.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),c.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),c.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[c.jsx("input",{type:"checkbox",checked:h,onChange:M=>m(M.target.checked),disabled:!n}),"仅显示当前 flow"]}),c.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"}),c.jsx("span",{style:{flex:1}}),c.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"})]}),c.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[c.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&c.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&c.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(M=>{const B=a===M.sessionId;return c.jsxs("div",{onClick:()=>l(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:[c.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:k8(M.mtime)}),c.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:M.flowId||"(no flow)"}),M.promptPreview&&c.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:M.promptPreview}),c.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[b8(M.size)," · ",M.model||"default"]})]},M.sessionId)})]}),c.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[c.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(Qj).map(M=>c.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," ",P[M]!=null?`(${P[M]})`:""]},M)),c.jsx("input",{type:"text",placeholder:"search…",value:g,onChange:M=>w(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}})]}),c.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!a&&c.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),d&&!u&&c.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),u&&S.length===0&&c.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((T=u.events)==null?void 0:T.length)||0," total)"]}),S.map((M,B)=>c.jsx(N8,{event:M,defaultExpanded:M.tag==="error"},`${M.ts}_${B}`))]})]})]})]}):null}const E8="0.1.26";function e1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function Kh(e,t){return t==="running"?e1(e):e==null||!Number.isFinite(e)||e<=0?"--":e1(e)}const Jj=x.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function j8(e){const{setNodes:t}=Mc(),{modelLists:n,onModelChange:r}=x.useContext(Jj),i=x.useCallback(s=>{t(a=>a.filter(l=>l.id!==s))},[t]),o=x.useCallback(()=>{var u,f,d,p,h,m,v,k;const s=((u=e.data)==null?void 0:u.definitionId)||"",a=((f=e.data)==null?void 0:f.label)||e.id,l=((h=(p=(d=e.data)==null?void 0:d.outputs)==null?void 0:p[0])==null?void 0:h.value)||((k=(v=(m=e.data)==null?void 0:m.outputs)==null?void 0:v[0])==null?void 0:k.default)||"";window.__provideEditContent={instanceId:e.id,label:a,definitionId:s,content:l},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]);return c.jsx(i4,{...e,deleteNode:i,onProvideExpand:o,modelLists:n,onModelChange:r})}const P8={[Pg]:j8},td=["CONTROL","TOOL","PROVIDE","AGENT"],_8=1200,t1="af-flow-node--sync-flash",n1="af-flow-edge--sync-flash";function r1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function i1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function Zj(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 o1(e){const t=Zj(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function I8(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function A8(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 s1(e){if(!e)return"";const t=e.lastIndexOf("/");if(t===-1)return e;const n=e.slice(0,t),r=n.indexOf("/.agentflow/");return r!==-1&&n.slice(0,r)||n}const T8=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function R8(e){const t=new Set,n=[];let r;const i=new RegExp(T8.source,"g");for(;(r=i.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function a1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const i=n.slice(r+1);return/[\s\n]/.test(i)?null:{atIndex:r,query:i}}function ei(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function nd(e,t,n,r){const i=(e||"").trim();if(!i)return"";if(i.startsWith("opencode:")||i.startsWith("claude-code:"))return i;const o=Array.isArray(t)?t:[],s=Array.isArray(n)?n:[],a=Array.isArray(r)?r:[],l=o.map(ei),u=s.map(ei);return a.map(ei).includes(i)&&!l.includes(i)&&!u.includes(i)?`claude-code:${i}`:u.includes(i)&&!l.includes(i)?`opencode:${i}`:i}function L8(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Yh(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 O8({steps:e}){const{t}=rt();return!e||e.length===0?null:c.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(),i=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",i?`${t("flow:palette.model")}:${i}`:""].filter(Boolean).join(`
122
+ `),s=n.status||"pending";return c.jsxs("div",{className:"af-composer-step-chip"+(s==="done"?" af-composer-step-chip--done":"")+(s==="running"?" af-composer-step-chip--running":"")+(s==="error"?" af-composer-step-chip--error":"")+(s==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:o,children:[c.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),c.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||i?c.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?c.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,i?c.jsx("span",{className:"af-composer-step-chip-model",children:L8(i)}):null]}):null})]},n.index)})})}function M8(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 D8(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const i=typeof n.kind=="string"&&n.kind?n.kind:"assistant",o=t[t.length-1];o&&o.kind===i?o.text+=i==="error"||i==="result"?`
123
+ ${n.text}`:n.text:t.push({kind:i,text:n.text})}return t}function F8(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 $8(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 l1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:i=!0}){const{t:o}=rt(),s=x.useRef(null),a=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return x.useEffect(()=>{if(!i||!s.current)return;const l=s.current;requestAnimationFrame(()=>{l.scrollTop=l.scrollHeight})},[e,t,i]),c.jsxs("div",{ref:s,className:a,children:[e.map((l,u)=>l.type==="user"?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:o("flow:composer.yourQuestion")}),c.jsx("div",{className:"af-composer-ai-block-body",children:l.text})]},`composer-u-${u}-${l.text.slice(0,48)}`):c.jsx("div",{className:"af-composer-thread-assistant",children:c.jsx(c1,{segments:l.segments,running:!1})},`composer-a-${u}`)),c.jsx("div",{className:"af-composer-thread-assistant",children:c.jsx(c1,{segments:t,running:n})})]})}function c1({segments:e,running:t=!1}){const{t:n}=rt(),r=e.filter(d=>d.kind==="assistant").map(d=>d.text).join(""),i=e.filter(d=>d.kind==="result").map(d=>d.text).join(""),o=M8(r,i),s=e.filter(d=>d.kind==="error").map(d=>d.text).join(`
124
+ `),a=e.filter(d=>d.kind!=="error"),l=o?a.filter(d=>d.kind!=="result"):a,u=D8(l),f=!!(u.length>0||s);return c.jsxs(c.Fragment,{children:[u.map((d,p)=>c.jsxs("section",{className:$8(d.kind),children:[c.jsx("div",{className:"af-composer-ai-block-label",children:F8(d.kind,n)}),c.jsx("div",{className:"af-composer-ai-block-body",children:d.text})]},`${d.kind}-${p}`)),t&&!f?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),c.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,s?c.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[c.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),c.jsx("div",{className:"af-composer-ai-block-body",children:s})]}):null]})}function z8({fitViewEpoch:e}){const{fitView:t}=Mc(),n=x.useRef(t);return n.current=t,x.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200}));return()=>cancelAnimationFrame(r)}},[e]),null}const Pd=1500,u1=500,B8=262144,H8=2e3;function qh(e){return typeof e!="string"?"":e.length<=H8?e:`[log line truncated, ${e.length} chars]`}const U8=Pd;function V8(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,i]=t;if(r==="cli")try{const o=JSON.parse(i);return o&&o.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${o.instanceId||""}${o.label?` · ${o.label}`:""} 开始`}:o&&o.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${o.instanceId||""} 完成${o.elapsed?` (${o.elapsed})`:""}`}:o&&o.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${o.instanceId||""} 失败${o.error?`: ${o.error}`:""}`}:o&&o.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${o.uuid||""}`}:{ts:n,type:"info",text:qh(i)}}catch{return{ts:n,type:"info",text:qh(i)}}return{ts:n,type:"log",text:qh(`[${r}] ${i}`)}}function d1(e){if(!e)return[];const t=[],n=e.split(`
125
+ `);for(let r=n.length-1;r>=0&&t.length<U8;r--){const i=n[r];if(!i)continue;const o=V8(i);o&&t.push(o)}return t.reverse(),t}function W8(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const o=e[i],s=t[i];if(!s)return!1;if(o!==s&&(o.status!==s.status||(o.elapsed??null)!==(s.elapsed??null)))return!1}return!0}function K8(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Y8({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:i,onEdgesChange:o,onConnect:s,onNodesDelete:a,onNodeClick:l,onEdgeClick:u,onFlowInit:f,onDrop:d,onDragOver:p,hideMinimapAndControls:h,bottomSlot:m}){const{t:v}=rt(),k=!i,g=k||t==="pan"?!0:[1,2],w=k?!1:t==="select",y="af-flow-canvas"+(k?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),N=x.useCallback(()=>{},[]),E=x.useMemo(()=>{const S=new Map(n.map(A=>[A.id,A])),P=new Set(n.filter(A=>A.selected).map(A=>A.id)),T=P.size>0,M=(A,R)=>{const V=/^#([0-9a-f]{6})$/i.exec(A);if(!V)return A;const L=parseInt(V[1],16);return`rgba(${L>>16&255}, ${L>>8&255}, ${L&255}, ${R})`},B="#ff5169";return r.map(A=>{var ae,J,le,Se;const R=S.get(A.source),V=S.get(A.target),L=/^output-(\d+)$/.exec(A.sourceHandle||""),H=/^input-(\d+)$/.exec(A.targetHandle||""),D=R&&L?(J=(ae=R.data)==null?void 0:ae.outputs)==null?void 0:J[parseInt(L[1],10)]:null,$=V&&H?(Se=(le=V.data)==null?void 0:le.inputs)==null?void 0:Se[parseInt(H[1],10)]:null,_=D!=null&&D.type?xf(D.type):null,I=$!=null&&$.type?xf($.type):null,C=_&&I&&_!==I,F=T&&(P.has(A.source)||P.has(A.target)),U=A.style||{};if(C){const ye=A.selected?.95:F?.85:.78,ge=M(B,ye);return{...A,className:((A.className||"")+" af-flow-edge--type-mismatch"+(F?" af-flow-edge--adjacent":"")).trim(),style:{...U,stroke:ge,strokeWidth:F?2.75:2.5,strokeDasharray:"6 4"},markerEnd:A.markerEnd&&typeof A.markerEnd=="object"?{...A.markerEnd,color:ge}:{type:Zi.ArrowClosed,color:ge}}}const O=_||I;if(!O)return F?{...A,className:((A.className||"")+" af-flow-edge--adjacent").trim(),style:{...U,strokeWidth:2.5}}:A;const q=F||A.selected?.7:.38,ee=M(O,q),ne=F?2.5:U.strokeWidth??2;return{...A,className:((A.className||"")+(F?" af-flow-edge--adjacent":"")).trim(),style:{...U,stroke:ee,strokeWidth:ne},markerEnd:A.markerEnd&&typeof A.markerEnd=="object"?{...A.markerEnd,color:ee}:{type:Zi.ArrowClosed,color:ee}}})},[n,r]);return c.jsxs(XF,{className:y,nodes:n,edges:E,onNodesChange:i||N,onEdgesChange:o||N,onConnect:k?void 0:s,onNodesDelete:k?void 0:a,onNodeClick:l,onEdgeClick:k?void 0:u,onInit:f,onDrop:k?void 0:d,onDragOver:k?void 0:p,nodeTypes:P8,selectionOnDrag:w,panOnDrag:g,nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k,edgesFocusable:!k,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[c.jsx(r$,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),c.jsx(ua,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(h?" af-flow-bottom-unified-panel--solo":""),children:c.jsxs("div",{className:"af-flow-bottom-unified-row"+(h?" af-flow-bottom-unified-row--solo":""),children:[h?null:c.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:c.jsx(k$,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:S=>{var T;const P=(((T=S.data)==null?void 0:T.schemaType)??"agent").toLowerCase();return P==="control"?"rgba(237, 108, 2, 0.85)":P==="provide"?"rgba(0, 228, 117, 0.35)":P==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),c.jsx("div",{className:"af-flow-bottom-unified__center",children:m}),h?null:c.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:c.jsx(u$,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!h&&c.jsx(ua,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:S,color:P})=>c.jsxs("span",{className:"af-pin-legend__item",children:[c.jsx("span",{className:"af-pin-legend__dot",style:{background:P}}),c.jsx("span",{className:"af-pin-legend__label",children:S})]},S))}),c.jsx(z8,{fitViewEpoch:e}),!k&&n.length===0?c.jsxs("div",{className:"af-flow-empty-hint",children:[c.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),c.jsx("p",{className:"af-flow-empty-hint-text",children:v("flow:emptyCanvas.composerHint")}),c.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:v("flow:emptyCanvas.composerSub")}})]}):null]})}function Gh(e){const t=e.source??"user",n=e.archived?"1":"0";return`${e.id}\0${t}\0${n}`}function f1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&t.set("flowArchived","1"),window.history.replaceState({},"","/flow?"+t.toString())}function q8(e){return e==="builtin"?"workspace":e??"user"}function Xh(e,t){return t(e==="builtin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}const eP="af:run-console-height",Fl=230,dl={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},rd={};function _d(e){if(!Number.isFinite(e))return Fl;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function G8(){try{const e=localStorage.getItem(eP);if(e==null)return Fl;const t=parseInt(e,10);return Number.isFinite(t)?_d(t):Fl}catch{return Fl}}function X8(){var dw,fw;const{t:e}=rt(),{navigate:t,path:n}=xa(),[r,i]=x.useState([]),[o,s]=x.useState(""),[a,l]=x.useState(null),[u,f]=x.useState(0),[d,p]=x.useState(""),[h,m]=x.useState(""),[v,k]=x.useState(""),[g,w]=x.useState(""),[y,N]=x.useState(!1),[E,S]=x.useState(""),[P,T]=x.useState(!1),[M,B]=x.useState(""),[A,R]=x.useState(!1),[V,L]=x.useState(!1),[H,D]=x.useState(!1),[$,_]=x.useState(null),[I,C]=x.useState(!1),[F,U]=x.useState(!1),O=x.useRef(!1),[q,ee]=x.useState([]),[ne,ae]=x.useState(""),[J,le]=x.useState(null),[Se,ye]=x.useState([]),[ge,xe]=x.useState(""),[$e,Ke]=x.useState(!1),[Le,mt]=x.useState(!1),[_t,Dt]=x.useState({files:[]}),[Fn,wr]=x.useState(!1),[vr,br]=x.useState(!0);x.useEffect(()=>{let b=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(W=>{b||br(W.ok)}).catch(()=>{b||br(!1)})};j();const z=window.setInterval(j,5e3);return()=>{b=!0,window.clearInterval(z)}},[]),x.useEffect(()=>{let b=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{b||yp(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{b=!0}},[]);const[he,gt]=x.useState("edit"),[G,Q]=x.useState([]),Ne=x.useRef(0),[Ce,Ie]=x.useState(new Set),[It,Ct]=x.useState({}),[Vt,tn]=x.useState(null),[Jn,lt]=x.useState(0),[cn,Ft]=x.useState(!1),[gp,yp]=x.useState(!1),[Vc,Wc]=x.useState(!1),[Ea,ja]=x.useState(G8),Qo=x.useRef({active:!1,pointerId:-1,startY:0,startH:Fl}),[ft,lo]=x.useState(null),[Pa,Jo]=x.useState(null),[co,Kc]=x.useState({}),Yc=x.useRef(co);x.useEffect(()=>{Yc.current=co},[co]);const[qc,yi]=x.useState(!1),[xp,Zo]=x.useState(!1),[Gc,Xc]=x.useState({}),[xi,_a]=x.useState({}),[uo,es]=x.useState(null),[$n,Sr]=x.useState(dl),[wp,Qc]=x.useState(!1),[wi,Jc]=x.useState(!1),[Zc,vi]=x.useState(""),[eu,ts]=x.useState(""),[Wt,Ia]=x.useState(rd),[Zn,Aa]=x.useState(null),kr=x.useRef(null),fo=x.useRef(null),Ta=x.useRef(!0),po=x.useRef(!1),[At,ns]=x.useState(null),[ho,rs]=x.useState(null),[tu,mo]=x.useState(!1),[qr,is]=x.useState(""),[os,ss]=x.useState(!1),vp=x.useRef(null),[Nn,Ra]=x.useState(null),[nu,bi]=x.useState(!1),[as,$x]=x.useState(null),[ls,ru]=x.useState(null),bp=x.useRef(null),[zn,La]=x.useState(""),[iu,Oa]=x.useState(0),[Ma,Da]=x.useState(0),[FP,Sp]=x.useState("pan"),[ou,Fa]=x.useState(!1),[kp,zx]=x.useState(!1),Np=x.useRef(null),Cp=x.useRef(null),$a=x.useRef(null),[$P,zP]=x.useState(0),[Oe,Ep]=x.useState(null),[BP,su]=x.useState(""),[_e,HP]=x.useState({cursor:[],opencode:[],claudeCode:[]}),[go,Bx]=x.useState(""),[jp,nG]=x.useState(""),au=x.useCallback(b=>{if(!b)return null;const j=b.id,z=b.source??"user",W=b.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${z}${W?":"+W:""}`,activeKey:`af:composer-active-session:${j}:${z}${W?":"+W:""}`}},[]),Hx=x.useCallback(b=>{const j=au(b);if(!j)return{sessions:[],activeSessionId:null};try{const z=localStorage.getItem(j.sessionsKey);if(!z)return{sessions:[],activeSessionId:null};const W=JSON.parse(z);if(!Array.isArray(W))return{sessions:[],activeSessionId:null};const K=W.filter(Z=>Z&&typeof Z.id=="string").map(Z=>({...Z,running:!1,statusLine:Z.running?e("flow:composer.pageRefreshReset"):Z.statusLine,steps:[]}));let Y=null;try{Y=localStorage.getItem(j.activeKey),Y&&!K.some(Z=>Z.id===Y)&&(Y=null)}catch{Y=null}return{sessions:K,activeSessionId:Y}}catch{return{sessions:[],activeSessionId:null}}},[au]),lu=x.useCallback((b,j,z)=>{const W=au(b);if(W)try{localStorage.setItem(W.sessionsKey,JSON.stringify(j)),z?localStorage.setItem(W.activeKey,z):localStorage.removeItem(W.activeKey)}catch{}},[au]),yo=x.useRef(0),cu=x.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Bn,Nr]=x.useState([]),[Kt,Si]=x.useState(null),uu=x.useMemo(()=>{if(!a)return null;const b=a.id,j=a.source??"user",z=a.archived?"archived":"";return`${b}:${j}${z?":"+z:""}`},[a]),Pp=x.useRef(!1);x.useEffect(()=>{if(!uu){Nr([]),Si(null),cu.current={sessions:[],activeSessionId:null,flowKey:null};return}const b=cu.current;if(b.flowKey===uu)return;b.flowKey=uu,Pp.current&&b.sessions.length>0&&lu(a,b.sessions,b.activeSessionId);const{sessions:j,activeSessionId:z}=Hx(a);if(j.length===0){const W=`session-1-${Date.now()}`,K={id:W,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};b.sessions=[K],b.activeSessionId=W,Nr([K]),Si(W)}else{const W=j[j.length-1];if(W&&(!W.thread||W.thread.length===0))yo.current=Yh(j),b.sessions=j,b.activeSessionId=W.id,Nr(j),Si(W.id);else{const Y=Yh(j)+1;yo.current=Y;const Z=`session-${Y}-${Date.now()}`,te={id:Z,label:e("flow:composer.conversationLabel",{n:Y}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},se=[...j,te];b.sessions=se,b.activeSessionId=Z,Nr(se),Si(Z)}}Pp.current=!0},[uu,a,Hx,lu]);const yt=x.useMemo(()=>Bn.find(b=>b.id===Kt)||null,[Bn,Kt]),vt=(yt==null?void 0:yt.running)??!1,za=(yt==null?void 0:yt.statusLine)??"",Ba=(yt==null?void 0:yt.segments)??[],Ha=(yt==null?void 0:yt.thread)??[],Ux=(yt==null?void 0:yt.steps)??[];yt==null||yt.outputDismissed;const Ae=(yt==null?void 0:yt.phaseContext)??null,Vx=x.useRef([]),[_p,du]=x.useState(!1),fu=x.useRef(null),Wx=x.useRef(null);x.useEffect(()=>{const b=Wx.current;b&&requestAnimationFrame(()=>{b.scrollTop=b.scrollHeight})},[Ha,Ba]);const Ip=x.useRef(null),Ap=x.useRef(!1),UP=x.useRef(null),Kx=x.useCallback(b=>{const j=++yo.current,z=`session-${j}-${Date.now()}`,W={id:z,label:b||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Nr(K=>[...K,W]),Si(z),z},[]);x.useEffect(()=>{!a||!Pp.current||(cu.current.sessions=Bn,cu.current.activeSessionId=Kt,lu(a,Bn,Kt))},[Bn,Kt,a,lu]),x.useEffect(()=>{yo.current=Math.max(yo.current,Yh(Bn))},[Bn]);const VP=x.useCallback(b=>{var j;Ip.current===b&&((j=fu.current)==null||j.abort()),Nr(z=>{const W=z.filter(Y=>Y.id!==b);if(z.some((Y,Z)=>Y.id===b&&z.findIndex(te=>te.id===Kt)===Z)||Kt===b){const Y=W;Y.length>0?Si(Y[Y.length-1].id):setTimeout(()=>{yo.current=0;const Z=++yo.current,te=`session-${Z}-${Date.now()}`,se={id:te,label:e("flow:composer.conversationLabel",{n:Z}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Nr(oe=>[...oe,se]),Si(te)},0)}return W})},[Kt]),un=x.useCallback(b=>{Nr(j=>{const z=j.findIndex(Y=>Y.id===Kt);if(z<0)return j;const W={...j[z]};b(W);const K=[...j];return K[z]=W,K})},[Kt]),Yx=x.useCallback(b=>{un(j=>{j.running=b})},[un]),Cr=x.useCallback(b=>{un(j=>{j.statusLine=b})},[un]),Er=x.useCallback(b=>{un(j=>{typeof b=="function"?j.segments=b(j.segments):j.segments=b})},[un]),qx=x.useCallback(b=>{un(j=>{typeof b=="function"?j.thread=b(j.thread):j.thread=b})},[un]),Ua=x.useCallback(b=>{un(j=>{typeof b=="function"?j.steps=b(j.steps):j.steps=b})},[un]),Gx=x.useCallback(b=>{un(j=>{j.outputDismissed=b})},[un]),Va=x.useCallback(b=>{un(j=>{j.phaseContext=typeof b=="function"?b(j.phaseContext):b})},[un]),Xx=x.useCallback(b=>{Si(b),Nr(j=>{const z=j.findIndex(K=>K.id===b);if(z<0||!j[z].outputDismissed)return j;const W=[...j];return W[z]={...j[z],outputDismissed:!1},W})},[]);x.useEffect(()=>{Vx.current=Ba},[Ba]);const Gr=x.useRef({}),Qx=x.useRef(!1),Wa=x.useRef(null),ki=x.useRef(null),Ka=x.useRef(!1),Tp=x.useRef(0),pu=x.useRef(""),[He,Ue,WP]=QF([]),[xt,Tt,KP]=JF([]),Rp=x.useRef(He),Lp=x.useRef(xt),er=x.useMemo(()=>He.filter(b=>{var j;return(((j=b.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[He]),cs=x.useMemo(()=>{var j;const b={};for(const z of He){if(!((j=z.data)!=null&&j.inputs))continue;const W=z.data.inputs;for(let K=0;K<W.length;K++){const Y=W[K];if(!(Y!=null&&Y.name))continue;const Z=xt.find(se=>se.target===z.id&&se.targetHandle===`input-${K}`);if(!(Z!=null&&Z.source))continue;er.find(se=>se.id===Z.source)&&(b[Z.source]=Y.name)}}return b},[He,xt,er]),Ya=x.useMemo(()=>{if(he==="edit"||Ce.size===0)return null;const b=new Set(Ce);for(const j of xt)Ce.has(j.source)&&b.add(j.target),Ce.has(j.target)&&b.add(j.source);return b},[he,Ce,xt]),YP=x.useMemo(()=>he==="edit"?He:He.map(b=>{var j,z;return{...b,draggable:!1,connectable:!1,data:{...b.data,isRunMode:!0,isExecuting:Ce.has(b.id),nodeStatus:((j=It[b.id])==null?void 0:j.status)??null,nodeElapsed:((z=It[b.id])==null?void 0:z.elapsed)??null,isDim:Ya?!Ya.has(b.id):!1}}}),[he,He,Ce,It,Ya]),qP=x.useMemo(()=>Ya?xt.map(b=>{const j=Ce.has(b.source)||Ce.has(b.target),z=b.className?b.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",W=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...b,className:(z?z+" ":"")+W}}):xt,[xt,Ce,Ya]);x.useEffect(()=>{if(!a){_a({}),es(null),Sr(dl),Ia(rd),Aa(null),vi(""),ts("");return}const b=new URLSearchParams({flowId:a.id,flowSource:a.source||"user"});a.archived&&b.set("archived","1"),fetch(`/api/flow/run-config?${b.toString()}`).then(j=>j.json()).then(j=>{_a(j.presets||{}),es(j.activePreset||null)}).catch(()=>{_a({}),es(null)})},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived]);const hu=x.useCallback(async(b,j={})=>{if(!b)return;!!j.quiet||(Qc(!0),vi(""),ts(""));const W=new URLSearchParams({flowId:b.id,flowSource:b.source||"user"});b.archived&&W.set("archived","1");try{const K=await fetch(`/api/flow/schedule?${W.toString()}`),Y=await K.json().catch(()=>({}));if(!K.ok)throw new Error(Y.error||`HTTP ${K.status}`);Sr({...dl,...Y.schedule||{}}),Ia(Y.state&&typeof Y.state=="object"?Y.state:rd),Aa(Y.status||null)}catch(K){Sr(dl),Ia(rd),Aa(null),vi(String(K.message||K))}finally{Qc(!1)}},[]);x.useEffect(()=>{if(!a)return;let b=!1;return(async()=>{await hu(a)})(),()=>{b=!0}},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived,hu]),x.useEffect(()=>{var z,W,K,Y;if(!uo||!xi[uo]||er.length===0)return;const b=xi[uo],j={};for(const Z of er){const te=cs[Z.id];if(!te)continue;const se=((z=Z.data)==null?void 0:z.definitionId)||"",oe=b[Z.id]??((Y=(K=(W=Z.data)==null?void 0:W.outputs)==null?void 0:K[0])==null?void 0:Y.default)??"";se.startsWith("provide_file")?j[te]={type:"file",path:oe}:j[te]={type:"str",value:oe}}Object.keys(j).length>0&&Kc(j)},[uo,xi,er,cs]);const GP=x.useCallback(()=>{if(!ls||!bp.current)return;const b=bp.current.value;Ue(j=>j.map(z=>{var W,K;return z.id!==ls.instanceId?z:{...z,data:{...z.data,outputs:((K=(W=z.data)==null?void 0:W.outputs)==null?void 0:K.map((Y,Z)=>Z===0?{...Y,default:b}:Y))||[{type:"text",name:"value",default:b}]}}})),ru(null)},[ls,Ue]),Pe=x.useMemo(()=>{const b=He.filter(j=>j.selected);return b.length===1?b[0]:null},[He]),jr=x.useMemo(()=>a?e4(He,xt,e):[],[a,He,xt,e]),XP=x.useMemo(()=>jr.map(b=>b.key).join("|"),[jr]),Jx=x.useMemo(()=>jr.some(b=>String((b==null?void 0:b.level)||"warning").toLowerCase()==="error"),[jr]);x.useLayoutEffect(()=>{C(jr.length>0&&!Jx)},[XP,a==null?void 0:a.id,a==null?void 0:a.source,jr.length,Jx]),$a.current=Pe,x.useEffect(()=>{Rp.current=He},[He]),x.useEffect(()=>{Lp.current=xt},[xt]),x.useEffect(()=>()=>{ki.current!=null&&(clearTimeout(ki.current),ki.current=null)},[]);const Op=x.useMemo(()=>{var j;if(!Pe)return null;const b=(j=Pe.data)==null?void 0:j.definitionId;return q.find(z=>z.id===b)??null},[Pe,q]),Mp=x.useMemo(()=>{const b={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of q){const z=Zj(j);b[z].push(j)}for(const j of td)b[j].sort((z,W)=>z.id.localeCompare(W.id));return b},[q]),mu=x.useMemo(()=>{const b=ne.trim().toLowerCase();if(!b)return Mp;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const z of td)j[z]=Mp[z].filter(W=>A8(W,b));return j},[Mp,ne]),QP=x.useMemo(()=>td.reduce((b,j)=>b+mu[j].length,0),[mu]),gu=x.useCallback(async()=>{s("");try{const b=await fetch("/api/flows");if(!b.ok)throw new Error("HTTP "+b.status);i(await b.json())}catch(b){s(String(b.message||b))}},[]);x.useEffect(()=>{gu()},[gu]),x.useEffect(()=>{if(n!=="/flow")return;const b=new URLSearchParams(window.location.search);b.get("new")==="1"&&!b.get("flowId")&&t("/projects?new=1")},[n,t]),x.useEffect(()=>{let b=!1;const j=()=>{fetch("/api/model-lists").then(W=>W.json()).then(W=>{b||HP({cursor:Array.isArray(W.cursor)?W.cursor.map(String):[],opencode:Array.isArray(W.opencode)?W.opencode.map(String):[],claudeCode:Array.isArray(W.claudeCode)?W.claudeCode.map(String):[]})}).catch(()=>{})};j();const z=setTimeout(j,4e3);return()=>{b=!0,clearTimeout(z)}},[]);const Zx=x.useCallback(async b=>{const j=b.source??"user",z=!!b.archived,W=new URLSearchParams({flowId:b.id,flowSource:j});z&&W.set("archived","1");const K=new URLSearchParams({flowId:b.id,flowSource:j});z&&K.set("archived","1");const[Y,Z]=await Promise.all([fetch("/api/flow?"+W.toString()),fetch("/api/nodes?"+K.toString())]),te=await Y.json();if(!Y.ok||te.error)throw new Error(te.error||e("flow:nodePropsError.loadFlowFailed"));const se=await Z.json();if(!Z.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const oe=Array.isArray(se)?se:Array.isArray(se==null?void 0:se.nodes)?se.nodes:[],me=!Array.isArray(se)&&(se==null?void 0:se.pipelineTranslations)||{},X=Qz(te.flowYaml||"");if(X.error)throw new Error(X.error);const ue={...X.instances||{}},ce=X.nodes.map(Ve=>Lh(Ve,ue,oe,me,b.id)),we=n4(X.edges,ce);return{flowSource:j,paletteList:oe,instances:ue,flowDescriptionText:X.description??"",nodes:ce,edges:we}},[]),Cn=x.useCallback(async(b,j={})=>{const z=!!j.preserveComposer,W=z&&!!j.incrementalSync;Ka.current=!1,Tp.current+=1,l(b),m(""),z||(k(""),ae(""),le(null),p(""),S(""),B(""),La(""),qx([]),Er([]),Ua([]),Gx(!1),Va(null),Sp("pan")),W||(Gr.current={},Ue([]),Tt([])),f1(b);try{const K=await Zx(b);if(ee(K.paletteList),Gr.current=K.instances,p(K.flowDescriptionText),S(b.id||""),W){const Y=Rp.current,Z=Lp.current;try{const te=P$(Y,Z,K.nodes,K.edges),se=new Set([...te.changes.addedNodeIds,...te.changes.updatedNodeIds]),oe=new Set([...te.changes.addedEdgeKeys,...te.changes.updatedEdgeKeys]),me=se.size>0?te.nodes.map(ue=>se.has(ue.id)?{...ue,className:r1(ue.className,t1)}:ue):te.nodes,X=oe.size>0?te.edges.map(ue=>oe.has(pc(ue))?{...ue,className:r1(ue.className,n1)}:ue):te.edges;Ue(me),Tt(X),ki.current!=null&&(clearTimeout(ki.current),ki.current=null),(se.size>0||oe.size>0)&&(ki.current=window.setTimeout(()=>{ki.current=null,se.size>0&&Ue(ue=>ue.map(ce=>{if(!se.has(ce.id))return ce;const we=i1(ce.className,t1);return we===String(ce.className||"")?ce:{...ce,className:we}})),oe.size>0&&Tt(ue=>ue.map(ce=>{if(!oe.has(pc(ce)))return ce;const we=i1(ce.className,n1);return we===String(ce.className||"")?ce:{...ce,className:we}}))},_8))}catch{Ue(K.nodes),Tt(K.edges)}}else Ue(K.nodes),Tt(K.edges),f(Y=>Y+1);zu(b.id,K.flowSource),zP(Y=>Y+1);try{pu.current=Qv(K.nodes,K.edges,K.instances,{description:K.flowDescriptionText})}catch{pu.current=""}Ka.current=!0}catch(K){m(String(K.message||K))}},[Zx,Ue,Tt]),ew=x.useCallback(async()=>{var W;if(!a||O.current)return;const b=a.id,j=a.source??"user",z=((W=$a.current)==null?void 0:W.id)??null;O.current=!0,U(!0);try{await Cn({id:b,source:j,archived:a.archived},{preserveComposer:!0,incrementalSync:!0}),z&&Ue(K=>K.map(Y=>({...Y,selected:Y.id===z})))}finally{O.current=!1,U(!1)}},[a,a==null?void 0:a.archived,Cn,Ue]);x.useEffect(()=>{if(Qx.current||r.length===0)return;const b=new URLSearchParams(window.location.search),j=b.get("flowId");if(!j)return;const z=b.get("flowSource")??"user",W=b.get("flowArchived")==="1",K=r.find(Y=>Y.id===j&&(Y.source??"user")===z&&!!Y.archived===W);K&&(Qx.current=!0,Cn(K))},[r,Cn]);const yu=x.useRef(0);x.useEffect(()=>{if(!a)return;const b=a.id,j=a.source??"user",z=!!a.archived;yu.current=0;let W=!1;const K=async()=>{var te;if(W)return;const Z=new URLSearchParams({flowId:b,flowSource:j,v:String(yu.current)});z&&Z.set("archived","1");try{const se=await fetch("/api/flow-editor-sync-poll?"+Z.toString());if(!se.ok||W)return;const oe=await se.json();if(W)return;if(oe.changed){yu.current=oe.version;const me=((te=$a.current)==null?void 0:te.id)??null;await Cn({id:b,source:j,archived:z},{preserveComposer:!0,incrementalSync:!0}),me&&Ue(X=>X.map(ue=>({...ue,selected:ue.id===me})))}else yu.current=oe.version}catch{}},Y=window.setInterval(K,2e3);return K(),()=>{W=!0,window.clearInterval(Y)}},[a==null?void 0:a.id,a==null?void 0:a.source,a==null?void 0:a.archived,Cn,Ue]);const JP=x.useMemo(()=>v?v.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":v===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[v]);x.useEffect(()=>{if(!v)return;v===e("flow:status.saved")||v.startsWith(e("flow:status.runInTerminal"));const b=v.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>k(""),b);return()=>clearTimeout(j)},[v,e]),x.useEffect(()=>{w("")},[a==null?void 0:a.id,a==null?void 0:a.source]),x.useEffect(()=>{const b=()=>{window.__provideEditContent&&(ru(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",b),()=>window.removeEventListener("provide-expand",b)},[]),x.useEffect(()=>{var te,se,oe,me,X,ue;if(!Pe){Ep(null);return}const b=Gr.current[Pe.id]||{},{inputs:j,outputs:z}=t4(Pe),W=String(((te=Pe.data)==null?void 0:te.definitionId)??Pe.id??""),K=((se=Pe.data)==null?void 0:se.script)!=null?String(Pe.data.script):void 0,Y=b.script!=null?String(b.script):void 0,Z=W==="tool_nodejs"||K&&K.trim()!==""||Y&&Y.trim()!==""?String(K??Y??""):"";Ep({id:Pe.id,newId:Pe.id,label:String(((oe=Pe.data)==null?void 0:oe.label)??Pe.id),role:((me=Pe.data)==null?void 0:me.role)??"普通",model:String(((X=Pe.data)==null?void 0:X.model)??b.model??""),body:String(((ue=Pe.data)==null?void 0:ue.body)??b.body??""),script:Z,inputs:j,outputs:z})},[Pe==null?void 0:Pe.id,$P]),x.useEffect(()=>{a&&(Pe||(Cp.current=null,le(b=>b==="node"?null:b)))},[a,Pe==null?void 0:Pe.id]);const xu=x.useCallback(()=>{Cp.current=null,le(b=>b==="settings"||b==="history"?b:"node")},[]),ZP=x.useCallback((b,j)=>{if(!(b.metaKey||b.ctrlKey||b.shiftKey)){if(he!=="edit"){Jo((j==null?void 0:j.id)??null);return}xu()}},[xu,he]),e_=x.useCallback((b,j)=>{if(he!=="edit")return;const z=b.metaKey||b.ctrlKey||b.shiftKey;Tt(W=>W.map(K=>K.id===j.id?{...K,selected:!K.selected||!z}:z?K:{...K,selected:!1})),z||Ue(W=>W.map(K=>({...K,selected:!1})))},[he,Tt,Ue]),t_=x.useCallback(b=>Tt(j=>{const z=j.filter(W=>!(W.target===b.target&&W.targetHandle===b.targetHandle));return vC({...b,markerEnd:{type:Zi.ArrowClosed}},z)}),[Tt]),n_=x.useCallback(b=>{for(const j of b)delete Gr.current[j.id]},[]),r_=x.useCallback(b=>{Wa.current=b},[]),i_=x.useCallback(b=>{Ue(z=>z.map(W=>({...W,selected:W.id===b}))),Tt(z=>z.map(W=>({...W,selected:!1}))),xu();const j=()=>{var se,oe,me;const z=Wa.current;if(!(z!=null&&z.getNode))return;const W=z.getNode(b);if(!W)return;const K=(se=z.getInternalNode)==null?void 0:se.call(z,b),Y=((oe=K==null?void 0:K.measured)==null?void 0:oe.width)??(K==null?void 0:K.width)??W.width??200,Z=((me=K==null?void 0:K.measured)==null?void 0:me.height)??(K==null?void 0:K.height)??W.height??88,{zoom:te}=z.getViewport();z.setCenter(W.position.x+Y/2,W.position.y+Z/2,{zoom:te,duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[Ue,Tt,xu]),o_=x.useCallback(b=>{Ue(z=>z.map(W=>({...W,selected:W.id===b}))),Tt(z=>z.map(W=>({...W,selected:!1})));const j=()=>{var oe,me,X;const z=Wa.current;if(!(z!=null&&z.getNode))return;const W=z.getNode(b);if(!W)return;const K=(oe=z.getInternalNode)==null?void 0:oe.call(z,b),Y=((me=K==null?void 0:K.measured)==null?void 0:me.width)??(K==null?void 0:K.width)??W.width??200,Z=((X=K==null?void 0:K.measured)==null?void 0:X.height)??(K==null?void 0:K.height)??W.height??88,{zoom:te}=z.getViewport(),se=Math.max(te,1);z.setCenter(W.position.x+Y/2,W.position.y+Z/2,{zoom:se,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[Ue,Tt]),s_=x.useCallback(b=>{if(!a||!b)return;let j={x:180,y:160};const z=Wa.current,W=document.querySelector(".af-pipeline-flow .react-flow");if(z&&W){const se=W.getBoundingClientRect();j=z.screenToFlowPosition({x:se.left+se.width*.45,y:se.top+se.height*.38})}const K=`node-${Date.now()}`,Y=o1(b),Z={id:K,type:Pg,position:j,data:{label:b.label??b.id,definitionId:b.id,schemaType:Y,inputs:Array.isArray(b.inputs)?b.inputs.map(se=>({...se})):[],outputs:Array.isArray(b.outputs)?b.outputs.map(se=>({...se})):[]}},te=Lh(Z,Gr.current,q);Ue(se=>[...se,te])},[a,q,Ue]),a_=x.useCallback(b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},[]),l_=x.useCallback(b=>{if(b.preventDefault(),!a)return;const j=b.dataTransfer.getData("application/agentflow-node");if(!j)return;const z=q.find(oe=>oe.id===j);if(!z)return;const W=Wa.current;if(!W)return;const K=W.screenToFlowPosition({x:b.clientX,y:b.clientY}),Y=`node-${Date.now()}`,Z=o1(z),te={id:Y,type:Pg,position:K,data:{label:z.label??z.id,definitionId:z.id,schemaType:Z,inputs:Array.isArray(z.inputs)?z.inputs.map(oe=>({...oe})):[],outputs:Array.isArray(z.outputs)?z.outputs.map(oe=>({...oe})):[]}},se=Lh(te,Gr.current,q);Ue(oe=>[...oe,se])},[a,q,Ue]),Ni=x.useCallback(async(b,j)=>{if(!a)return;const z=Qv(b,j,Gr.current,{description:d});if(z!==pu.current){k(e("flow:status.saving"));try{const W=q8(a.source),K=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:W,flowYaml:z,...a.archived?{flowArchived:!0}:{}})}),Y=await K.json();if(!K.ok||!Y.success)throw new Error(Y.error||e("flow:status.saveFailed"));if(pu.current=z,k(e("flow:status.saved")),a.source==="builtin"&&W==="workspace"){const Z={id:a.id,source:"workspace",path:void 0};l(Z),f1(Z),zu(a.id,"workspace")}}catch(W){k(e("flow:status.saveFailed")+": "+(W.message||W))}}},[a,d]);x.useEffect(()=>{if(!a||!Ka.current||he!=="edit"||a.archived)return;const b=Tp.current,j=setTimeout(()=>{b===Tp.current&&Ka.current&&Ni(Rp.current,Lp.current)},400);return()=>clearTimeout(j)},[He,xt,d,he,a,Ni]);const tw=x.useCallback(async b=>{if(!a||a.archived)return;const j=a.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==b){N(!0),w("");try{const z=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,fromSource:j,toSource:b})}),W=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof W.error=="string"?W.error:e("flow:composer.requestFailed"));const K=W.flowSource==="workspace"||W.flowSource==="user"?W.flowSource:b;let Y={id:a.id,source:K,archived:a.archived};try{const Z=await fetch("/api/flows");if(Z.ok){const te=await Z.json(),se=Array.isArray(te)?te.find(oe=>oe.id===a.id&&(oe.source??"user")===K&&!!oe.archived==!!a.archived):null;se&&(Y=se)}}catch{}await Cn(Y,{preserveComposer:!0}),zu(a.id,K)}catch(z){w(String(z.message||z))}finally{N(!1)}}},[a,Cn]),c_=x.useCallback(async()=>{if(a){Jc(!0),vi(""),ts("");try{const b=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source||"user",archived:!!a.archived,schedule:$n})}),j=await b.json().catch(()=>({}));if(!b.ok||!j.success)throw new Error(j.error||"Failed to save schedule");Sr({...dl,...j.schedule||{}}),ts(e("flow:schedule.saved")),await hu(a,{quiet:!0})}catch(b){vi(String(b.message||b))}finally{Jc(!1)}}},[a,$n,hu,e]),nw=x.useCallback(async()=>{if(!a||!E.trim())return;const b=E.trim();if(b===a.id){B("");return}T(!0),B("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",newFlowId:b})}),z=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof z.error=="string"?z.error:e("flow:composer.requestFailed"));let W={id:z.flowId,source:z.flowSource??a.source,archived:a.archived};try{const K=await fetch("/api/flows");if(K.ok){const Y=await K.json(),Z=Array.isArray(Y)?Y.find(te=>te.id===z.flowId&&(te.source??"user")===(z.flowSource??a.source)):null;Z&&(W=Z)}}catch{}await Cn(W,{preserveComposer:!0}),zu(z.flowId,z.flowSource??a.source)}catch(j){B(String(j.message||j))}finally{T(!1)}},[a,E,Cn]),u_=x.useCallback(b=>{navigator.clipboard.writeText(b).then(()=>{R(!0),setTimeout(()=>R(!1),2e3)}).catch(()=>{})},[]),Dp=x.useCallback(()=>{Ni(He,xt)},[Ni,He,xt]),d_=x.useCallback((b,j)=>{const z=j.trim()===""||j==="default"?void 0:j.trim(),W=He.map(K=>K.id===b?{...K,data:{...K.data,model:z}}:K);Ue(W),Ni(W,xt)},[He,xt,Ue,Ni]),wu=x.useCallback(()=>{var ce;if(!Oe||!a||!Pe)return!1;const b=Pe.id,j=Oe.newId.trim();if(su(""),!N4.test(j))return su(e("flow:nodePropsError.invalidInstanceId")),!1;if(He.some(we=>we.id===j&&we.id!==b))return su(e("flow:nodePropsError.duplicateInstanceId")),!1;const z=Oe.role.trim(),W=Ko.includes(z)?z:"普通",K=Oe.model.trim(),Y=we=>(Array.isArray(we)?we:[]).map(Ve=>({type:String((Ve==null?void 0:Ve.type)??"节点").trim()||"节点",name:String((Ve==null?void 0:Ve.name)??""),default:String((Ve==null?void 0:Ve.default)??"")})),Z=Y(Oe.inputs),te=Y(Oe.outputs),se=String(((ce=Pe.data)==null?void 0:ce.definitionId)??j),oe={...Pe.data,label:Oe.label.trim()||j,role:W,model:K===""||K==="default"?void 0:K,body:Oe.body,inputs:Z,outputs:te},me=String(Oe.script??"").trim();se==="tool_nodejs"||me!==""?oe.script=String(Oe.script??""):delete oe.script;let X,ue=xt;if(j!==b){const we={...Gr.current},Ve={...we[b]||{}};delete we[b],we[j]=Ve,Gr.current=we,X=He.map(We=>We.id!==b?We:{...We,id:j,selected:!0,data:oe}),ue=xt.map((We,Up)=>({...We,source:We.source===b?j:We.source,target:We.target===b?j:We.target,id:`e-${We.source===b?j:We.source}-${We.target===b?j:We.target}-${Up}`}))}else X=He.map(we=>we.id===b?{...we,data:oe}:we);return Ue(X),Tt(ue),Ni(X,ue),!0},[Oe,a,Pe,He,xt,Ue,Tt,Ni]),Fp=x.useCallback(()=>{var we;if(!Oe||!a||!Pe)return!1;const b=Pe.id,j=Oe.role.trim(),z=Ko.includes(j)?j:"普通",W=Oe.model.trim(),K=Ve=>(Array.isArray(Ve)?Ve:[]).map(We=>({type:String((We==null?void 0:We.type)??"节点").trim()||"节点",name:String((We==null?void 0:We.name)??""),default:String((We==null?void 0:We.default)??"")})),Y=K(Oe.inputs),Z=K(Oe.outputs),te=String(((we=Pe.data)==null?void 0:we.definitionId)??b),se=Oe.label.trim()||b,oe=W===""||W==="default"?void 0:W,me={...Pe.data,label:se,role:z,model:oe,body:Oe.body,inputs:Y,outputs:Z},X=String(Oe.script??"").trim();te==="tool_nodejs"||X!==""?me.script=String(Oe.script??""):delete me.script;const ue=Pe.data||{};return(ue.label!==me.label||ue.role!==me.role||ue.model!==me.model||ue.body!==me.body||(ue.script??void 0)!==(me.script??void 0)||JSON.stringify(ue.inputs||[])!==JSON.stringify(Y)||JSON.stringify(ue.outputs||[])!==JSON.stringify(Z))&&Ue(Ve=>Ve.map(We=>We.id===b?{...We,data:me}:We)),!0},[Oe,a,Pe,Ue]),rw=x.useRef(Fp);x.useEffect(()=>{rw.current=Fp},[Fp]),x.useEffect(()=>{if(!Oe||!a||!Ka.current||he!=="edit")return;const b=setTimeout(()=>{rw.current()},400);return()=>clearTimeout(b)},[Oe,a,he]);const f_=x.useCallback(()=>{if(!(!Oe||!Pe)){if(Oe.newId.trim()===Pe.id){su("");return}wu()}},[Oe,Pe,wu]);x.useEffect(()=>{const b=j=>{if(he!=="edit")return;const z=o4(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(J==="node"&&Pe&&Oe){j.preventDefault(),j.stopPropagation(),wu()||Dp();return}if(z)return;j.preventDefault(),j.stopPropagation(),Dp();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),zx(W=>!W);return}if(!kp){if(ou){if(j.key==="Escape"){j.preventDefault(),Fa(!1);return}if(Jv(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Fa(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(!z){if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),Ue(W=>W.map(K=>({...K,selected:!0}))),Tt(W=>W.map(K=>({...K,selected:!1})));return}if(Jv(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Fa(W=>!W);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Sp("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Sp("pan");return}}}};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[Dp,ou,kp,J,Pe,Oe,wu,he]),x.useEffect(()=>{if(he!=="running"||Vt==null)return;let b=Math.floor((Date.now()-Vt)/1e3);const j=setInterval(()=>{const z=Date.now()-Vt,W=Math.floor(z/1e3);W!==b&&(b=W,lt(z))},500);return()=>clearInterval(j)},[he,Vt]),x.useEffect(()=>{const b=fo.current;!b||!b.parentElement||Ta.current&&(po.current=!0,b.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{po.current=!1}))},[G]),x.useEffect(()=>{const b=fo.current;if(!b)return;const j=b.parentElement;if(!j)return;const z=()=>{if(po.current)return;const W=j.scrollHeight-j.scrollTop-j.clientHeight;Ta.current=W<40};return j.addEventListener("scroll",z,{passive:!0}),()=>j.removeEventListener("scroll",z)},[cn,he]),x.useEffect(()=>{if(he==="edit"||!cn)return;Ta.current=!0;const b=fo.current;b&&(po.current=!0,b.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{po.current=!1}))},[he,cn]),x.useEffect(()=>{G.length>Pd+u1&&Q(b=>b.length>Pd+u1?b.slice(-Pd):b)},[G]);const p_=x.useCallback(b=>{if(b.button!==0)return;b.preventDefault();const j=b.currentTarget;Qo.current={active:!0,pointerId:b.pointerId,startY:b.clientY,startH:Ea},j.setPointerCapture(b.pointerId)},[Ea]),h_=x.useCallback(b=>{const j=Qo.current;if(!j.active||b.pointerId!==j.pointerId)return;const z=j.startY-b.clientY;ja(_d(j.startH+z))},[]),vu=x.useCallback(()=>{ja(b=>{const j=_d(b);try{localStorage.setItem(eP,String(j))}catch{}return j})},[]),iw=x.useCallback(b=>{const j=Qo.current;if(!(!j.active||b.pointerId!==j.pointerId)){j.active=!1;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}vu()}},[vu]),m_=x.useCallback(()=>{const b=Qo.current;b.active&&(b.active=!1,vu())},[vu]);x.useEffect(()=>{function b(){ja(j=>_d(j))}return window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const Pr=x.useCallback(async(b={})=>{if(!a)return;const j=b.runUuid!=null&&String(b.runUuid).trim()?String(b.runUuid).trim():null,z=b.cliInputsOverride??Yc.current,W=!!b.prepareOnly;if(gt(W?"ready":"running"),Q(W?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),Ie(new Set),Ct({}),Ft(!W),le(null),j||lo(null),W)return;if(!j){const Y=Date.now();tn(Y),lt(0)}const K=new AbortController;kr.current=K;try{const Y=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,...j?{uuid:j}:{},cliInputs:z}),signal:K.signal});if(!Y.ok){const X=await Y.json().catch(()=>({error:e("flow:composer.requestFailed")}));Q(ue=>[...ue,{ts:new Date().toISOString(),type:"error",text:X.error||e("flow:composer.requestFailed")}]),gt("error");return}if(Q(X=>[...X,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!Y.body){Q(X=>[...X,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),gt("error");return}const Z=Y.body.getReader(),te=new TextDecoder;let se="";const oe=X=>{const ue=X.ts||new Date().toISOString();if(X.type==="event")if(X.event==="node-start")Ie(ce=>new Set(ce).add(X.instanceId)),Ct(ce=>({...ce,[X.instanceId]:{status:"running",startMs:Date.now()}})),Q(ce=>[...ce,{ts:ue,type:"node-start",text:X.label?e("flow:run.nodeStartWithLabel",{instanceId:X.instanceId,label:X.label}):e("flow:run.nodeStart",{instanceId:X.instanceId})}]);else if(X.event==="node-done"){Ie(we=>{const Ve=new Set(we);return Ve.delete(X.instanceId),Ve});const ce=X.elapsed??null;Ct(we=>({...we,[X.instanceId]:{status:"success",elapsed:ce}})),Q(we=>[...we,{ts:ue,type:"node-done",text:ce?e("flow:run.nodeDoneWithElapsed",{instanceId:X.instanceId,elapsed:ce}):e("flow:run.nodeDone",{instanceId:X.instanceId})}])}else if(X.event==="node-failed")Ie(ce=>{const we=new Set(ce);return we.delete(X.instanceId),we}),Ct(ce=>({...ce,[X.instanceId]:{status:"failed",elapsed:X.elapsed??null}})),Q(ce=>[...ce,{ts:ue,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:X.instanceId})}]);else if(X.event==="apply-start"){if(X.uuid&&lo(String(X.uuid)),typeof X.runStartTime=="number"&&X.runStartTime>0)tn(X.runStartTime),lt(Math.max(0,Date.now()-X.runStartTime));else if(typeof X.totalExecutedMs=="number"&&X.totalExecutedMs>0){const ce=Date.now()-X.totalExecutedMs;tn(ce),lt(X.totalExecutedMs)}Q(ce=>[...ce,{ts:ue,type:"info",text:e("flow:run.pipelineStart",{uuid:X.uuid||"?"})}])}else X.event==="apply-done"?Q(ce=>[...ce,{ts:ue,type:"info",text:X.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:X.totalElapsed}):e("flow:run.pipelineDone")}]):X.event==="apply-paused"?Q(ce=>[...ce,{ts:ue,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(X.pendingNodes||[]).join(", ")})}]):Q(ce=>[...ce,{ts:ue,type:"event",text:`[${X.event}] ${JSON.stringify(X)}`}]);else X.type==="user-check-content"?(ns({instanceId:X.instanceId,execId:X.execId??1,inputPath:X.inputPath,outputPath:X.outputPath,content:X.content||""}),rs(X.content||""),mo(!1),is(""),ss(!1),Q(ce=>[...ce,{ts:ue,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:X.instanceId})}])):X.type==="user-ask-prompt"?(Ra({instanceId:X.instanceId,execId:X.execId??1,question:X.question||"",options:Array.isArray(X.options)?X.options:[]}),bi(!1),Q(ce=>[...ce,{ts:ue,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:X.instanceId,defaultValue:`等待用户选择 (${X.instanceId})`})}])):X.type==="tool-print-content"?$x({instanceId:X.instanceId,execId:X.execId??1,content:X.content||"",createdAt:Date.now()}):X.type==="log"?Q(ce=>[...ce,{ts:ue,type:"log",text:X.text!=null?String(X.text):""}]):X.type==="error"?Q(ce=>[...ce,{ts:ue,type:"error",text:X.message||e("flow:run.unknownError")}]):X.type==="done"?Q(ce=>[...ce,{ts:ue,type:"done",text:e("flow:run.executionEnd",{exitCode:X.exitCode??"?"})}]):Q(ce=>[...ce,{ts:ue,type:"log",text:JSON.stringify(X)}])},me=X=>{if(X.trim())try{oe(JSON.parse(X))}catch{Q(ue=>[...ue,{ts:new Date().toISOString(),type:"log",text:X}])}};for(;;){const{done:X,value:ue}=await Z.read();se+=te.decode(ue??new Uint8Array,{stream:!X});const ce=se.split(`
126
+ `);se=ce.pop()??"";for(const we of ce)me(we);if(X)break}se.trim()&&me(se),gt("done")}catch(Y){Y.name==="AbortError"?(Q(Z=>[...Z,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),gt("stopped")):(Q(Z=>[...Z,{ts:new Date().toISOString(),type:"error",text:Y.message||e("flow:run.unknownError")}]),gt("error"))}finally{kr.current=null,Ie(new Set)}},[a]),[g_,$p]=x.useState(!1),y_=x.useCallback(()=>{$p(!0)},[]),x_=x.useCallback(async()=>{if($p(!1),kr.current&&(kr.current.abort(),kr.current=null),a)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id})})}catch{}gt("stopped"),Ie(new Set)},[a]),xo=x.useCallback(()=>{gt("edit"),Ie(new Set),Ct({}),Jo(null),lo(null)},[]),[w_,bu]=x.useState(!1),v_=x.useCallback(async()=>{if(bu(!1),kr.current&&(kr.current.abort(),kr.current=null),a)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id})})}catch{}xo()},[a,xo]),b_=x.useCallback(()=>{bu(!1),t("/projects")},[t]),S_=x.useCallback(b=>{const j=b.runId!=null&&String(b.runId).trim()?String(b.runId).trim():null,z=b.flowId!=null&&String(b.flowId).trim()?String(b.flowId).trim():(a==null?void 0:a.id)!=null?String(a.id):null;lo(j);const W=b.status||"unknown";let K="stopped";W==="success"?K="done":W==="failed"?K="error":W==="running"?K="running":K="stopped",gt(K);const Y=typeof b.at=="number"?b.at:null;if(K==="running"&&Y!=null?(tn(Y),lt(Math.max(0,Date.now()-Y))):Y!=null&&typeof b.endedAt=="number"&&b.endedAt>Y?(tn(null),lt(b.endedAt-Y)):(tn(null),lt(Math.max(0,b.durationMs??0))),Q([]),Ie(new Set),Ct({}),Jo(null),le(null),Ft(!1),j&&z){const Z=new URLSearchParams({flowId:z,runId:j});fetch(`/api/run-node-statuses?${Z}`).then(te=>te.json()).then(te=>{const se=te.statuses&&typeof te.statuses=="object"?te.statuses:{},oe={};for(const[me,X]of Object.entries(se))X&&typeof X=="object"&&typeof X.status=="string"&&(oe[me]={status:X.status,...X.elapsed!=null&&String(X.elapsed).trim()!==""?{elapsed:String(X.elapsed)}:{}});Ct(oe)}).catch(()=>{})}},[a==null?void 0:a.id]);x.useEffect(()=>{if(!(a!=null&&a.id)||he!=="edit")return;let b=!1;return(async()=>{try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(b||!j.ok)return;const K=(Array.isArray(z.runs)?z.runs:[]).find(te=>te.flowId===a.id&&te.status==="running");if(!K||b)return;const Y=K.runId||null;lo(Y),gt("running"),Ft(!0),tn(K.at||Date.now()),Ne.current=0;const Z=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${Y},已恢复运行视图`}];if(Y){const te=new URLSearchParams({flowId:a.id,runId:Y}),oe=await(await fetch(`/api/run-node-statuses?${te}`)).json();if(b)return;const me=oe.statuses&&typeof oe.statuses=="object"?oe.statuses:{},X={},ue=new Set;for(const[ce,we]of Object.entries(me))we&&typeof we=="object"&&typeof we.status=="string"&&(X[ce]={status:we.status,...we.elapsed!=null&&String(we.elapsed).trim()!==""?{elapsed:String(we.elapsed)}:{}},we.status==="running"&&ue.add(ce));Ct(X),Ie(ue);try{const ce=new URLSearchParams({flowId:a.id,runId:Y,sinceBytes:"0",tailBytes:"262144"}),we=await fetch(`/api/run-log?${ce}`);if(we.ok){const Ve=await we.json();if(!b){Ne.current=Number(Ve.bytes||0);const We=d1(typeof Ve.text=="string"?Ve.text:"");Q([...We,...Z]);return}}}catch{}}Q(Z)}catch{}})(),()=>{b=!0}},[a==null?void 0:a.id]),x.useEffect(()=>{if(he==="edit"||!(a!=null&&a.id)||!ft)return;let b=!1,j=null;const z=async()=>{try{const W=new URLSearchParams({flowId:a.id,runId:ft}),K=await fetch(`/api/run-node-statuses?${W}`);if(!K.ok)return;const Y=await K.json();if(b)return;const Z=Y.statuses&&typeof Y.statuses=="object"?Y.statuses:{},te={},se=new Set;for(const[oe,me]of Object.entries(Z))me&&typeof me=="object"&&typeof me.status=="string"&&(te[oe]={status:me.status,...me.elapsed!=null&&String(me.elapsed).trim()!==""?{elapsed:String(me.elapsed)}:{}},me.status==="running"&&se.add(oe));Ct(oe=>W8(oe,te)?oe:te),Ie(oe=>K8(oe,se)?oe:se);try{const oe=new URLSearchParams({flowId:a.id,runId:ft,sinceBytes:String(Ne.current||0),tailBytes:String(B8)}),me=await fetch(`/api/run-log?${oe}`);if(me.ok){const X=await me.json();if(b)return;const ue=Number(X.bytes||0),ce=typeof X.text=="string"?X.text:"";if(ce){const we=d1(ce);we.length>0&&Q(Ve=>[...Ve,...we])}Ne.current=ue}}catch{}try{const oe=await fetch("/api/pipeline-recent-runs");if(!oe.ok)return;const me=await oe.json();if(b)return;const ue=(Array.isArray(me.runs)?me.runs:[]).find(ce=>ce.flowId===a.id&&ce.runId===ft);if(ue&&ue.status){const ce=ue.status;ce==="running"?gt(we=>we==="running"?we:"running"):ce==="success"?gt("done"):ce==="failed"?gt("error"):(ce==="stopped"||ce==="interrupted")&&gt("stopped")}}catch{}}catch{}};return z(),j=window.setInterval(z,2500),()=>{b=!0,j&&window.clearInterval(j)}},[he,a==null?void 0:a.id,ft]),x.useEffect(()=>{if(J!=="history"||!a)return;let b=!1;return(async()=>{Ke(!0),xe("");try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(!j.ok)throw new Error(z.error||"HTTP "+j.status);b||ye(Array.isArray(z.runs)?z.runs:[])}catch(j){b||(xe(String(j.message||j)),ye([]))}finally{b||Ke(!1)}})(),()=>{b=!0}},[J,a]),x.useEffect(()=>{if(!a){Dt({files:[]});return}let b=!1;return(async()=>{wr(!0);try{const j=new URLSearchParams({flowId:a.id,flowSource:a.source||"user",archived:a.archived?"1":"0"}),z=await fetch(`/api/pipeline-files?${j}`),W=await z.json();if(!z.ok)throw new Error(W.error||"HTTP "+z.status);b||Dt({files:Array.isArray(W.files)?W.files:[],path:W.path,error:W.error})}catch(j){b||Dt({files:[],error:j.message||String(j)})}finally{b||wr(!1)}})(),()=>{b=!0}},[a]);const qa=x.useMemo(()=>a?Se.filter(b=>b&&b.flowId===a.id).sort((b,j)=>j.at-b.at):[],[Se,a]),nn=x.useMemo(()=>{let b=0,j=0,z=0,W=0,K=0;for(const Y of qa){const Z=Y.status||"unknown";Z==="success"?b+=1:Z==="failed"?j+=1:Z==="running"?z+=1:Z==="stopped"?W+=1:Z==="interrupted"&&(K+=1)}return{success:b,failed:j,running:z,stopped:W,interrupted:K}},[qa]),Ga=x.useMemo(()=>a?a1(zn,iu):null,[a,zn,iu]),tr=x.useMemo(()=>{if(!Ga||!a)return[];const b=Ga.query.toLowerCase(),j=K=>b?K.some(Y=>Y&&String(Y).toLowerCase().includes(b)):!0,z=He.map(K=>{var oe,me;const Y=K.id,Z=String(((oe=K.data)==null?void 0:oe.label)??Y),te=(me=K.data)!=null&&me.definitionId?String(K.data.definitionId):"",se=[Z!==Y?Z:"",te&&te!==Y?te:""].filter(Boolean);return{id:Y,label:Z,defId:te,subs:se}}).filter(({id:K,label:Y,defId:Z})=>j([K,Y,Z])).sort((K,Y)=>K.id.localeCompare(Y.id)).slice(0,18).map(({id:K,label:Y,defId:Z})=>{const te=[Y!==K?Y:null,Z||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:K,title:K,subtitle:te}}),W=q.filter(K=>K&&K.id&&j([K.id,K.label,K.description])).sort((K,Y)=>K.id.localeCompare(Y.id)).slice(0,22).map(K=>({kind:"definition",id:K.id,title:K.id,subtitle:K.label&&K.label!==K.id?String(K.label):String(K.type||"")}));return[...z,...W]},[Ga,He,q,a]),Xa=x.useMemo(()=>{const b=tr.filter(z=>z.kind==="instance"),j=tr.filter(z=>z.kind==="definition");return{instances:b,definitions:j}},[tr]);x.useEffect(()=>{Da(b=>{const j=Math.max(0,tr.length-1);return Math.min(Math.max(0,b),j)})},[tr]);const ow=x.useMemo(()=>R8(zn),[zn]),sw=x.useMemo(()=>He.filter(b=>b.selected),[He]),Su=x.useMemo(()=>{const b=[],j=new Set;for(const K of sw)j.add(K.id),b.push({node:K,kind:"canvas"});const z=new Map(He.map(K=>[K.id,K])),W=new Map(q.map(K=>[K.id,K]));for(const K of ow){if(j.has(K))continue;const Y=z.get(K);if(Y){j.add(K),b.push({node:Y,kind:"mention"});continue}const Z=W.get(K);Z&&(j.add(K),b.push({definition:Z,kind:"definition"}))}return b},[sw,ow,He,q]),dn=x.useMemo(()=>{const b=Array.isArray(_e==null?void 0:_e.cursor)?_e.cursor:[],j=Array.isArray(_e==null?void 0:_e.opencode)?_e.opencode:[],z=Array.isArray(_e==null?void 0:_e.claudeCode)?_e.claudeCode:[],W=j.map(oe=>`opencode:${ei(oe)}`),K=z.map(oe=>`claude-code:${ei(oe)}`),Y=new Set([...b,...j,...z].map(ei).concat(W).concat(K)),Z=(go||"").trim(),te=nd(go,b,j,z),se=te&&!Y.has(te)&&!Y.has(Z)?Z:"";return{cursorList:b,opencodeList:j,claudeCodeList:z,currentNotInLists:se}},[_e,go]);x.useEffect(()=>{const b=Array.isArray(_e==null?void 0:_e.cursor)?_e.cursor:[],j=Array.isArray(_e==null?void 0:_e.opencode)?_e.opencode:[],z=Array.isArray(_e==null?void 0:_e.claudeCode)?_e.claudeCode:[];Bx(W=>{const K=nd(W,b,j,z);return K===W?W:K})},[_e.cursor,_e.opencode,_e.claudeCode]);const wo=x.useCallback(async(b,j={})=>{var pw;if(!a||Ap.current)return;const z=j.phaseContextSnapshot,W=(typeof b=="string"?b:zn).trim();if(!W)return;const K=Vx.current;Ap.current=!0,Yx(!0),Cr(e("flow:composer.connecting")),le(it=>it!=="composer"?"composer":it);const Y=[...Ha];if(K.length>0&&Y.push({type:"assistant",segments:[...K]}),qx([...Y,{type:"user",text:W}]),Y.filter(it=>it.type==="user").length===0){const it=W.replace(/\s+/g," ").slice(0,30)+(W.length>30?"…":"");Nr(Hn=>Hn.map(Yt=>Yt.id===Kt?{...Yt,label:it}:Yt))}const Z=Y.map(it=>it.type==="user"?{role:"user",text:it.text}:{role:"assistant",text:(it.segments||[]).filter(Yt=>Yt.kind==="assistant"||Yt.kind==="result").map(Yt=>Yt.text).join(`
127
127
  `)}).filter(it=>it.text),te=z??Ae;La(""),Er([]),Ua([]),Gx(!1);const se=new AbortController;fu.current=se,Ip.current=Kt;let oe=null;const me=Array.isArray(_e==null?void 0:_e.cursor)?_e.cursor:[],X=Array.isArray(_e==null?void 0:_e.opencode)?_e.opencode:[],ue=Array.isArray(_e==null?void 0:_e.claudeCode)?_e.claudeCode:[],ce=nd(go,me,X,ue),we=Su.filter(it=>it.kind!=="definition"&&it.node).map(it=>it.node.id),Ve=a;let We=!1,Up=!1;try{oe=setTimeout(()=>se.abort(),12e4);const it={prompt:W,model:ce,flowId:a.id,flowSource:a.source??"user",...a.archived?{flowArchived:!0}:{},contextInstanceIds:we,thread:Z};te&&te.nextPhase&&!te.isLastPhase&&(it.phaseContext={phaseIndex:te.nextPhase.index,phases:te.phases,userPromptOriginal:te.userPromptOriginal||W}),jp&&(it.phaseRole=jp);const Hn=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(it),signal:se.signal});if(oe&&(clearTimeout(oe),oe=null),!Hn.ok){let Qa=Hn.statusText||e("flow:composer.requestFailed");try{const Ja=await Hn.json();Ja&&Ja.error&&(Qa=String(Ja.error))}catch{}Cr(Qa),Er([{kind:"error",text:Qa}]);return}const Yt=(pw=Hn.body)==null?void 0:pw.getReader();if(!Yt){Cr(e("flow:composer.cannotReadStream"));return}const us=new TextDecoder;let vo="";for(;;){const{done:Qa,value:Ja}=await Yt.read();if(Qa)break;for(vo+=us.decode(Ja,{stream:!0});;){const Vp=vo.indexOf(`
128
128
  `);if(Vp<0)break;const hw=vo.slice(0,Vp).trim();if(vo=vo.slice(Vp+1),!hw)continue;let pe;try{pe=JSON.parse(hw)}catch{continue}if(pe.type==="status"&&typeof pe.line=="string"&&Cr(pe.line),pe.type==="natural"&&typeof pe.text=="string"&&pe.text){const Xe=typeof pe.kind=="string"&&pe.kind?pe.kind:"assistant";Er(Ge=>[...Ge,{kind:Xe,text:pe.text}])}if(pe.type==="error"&&pe.message){Up=!0;const Xe=pe.code?` [${pe.code}]`:"",Ge=String(pe.message)+Xe;Cr(Ge),Er(fn=>[...fn,{kind:"error",text:Ge}])}if(pe.type==="plan"&&Array.isArray(pe.steps)){Ua(pe.steps.map(Ge=>({...Ge,status:"pending"})));const Xe=pe.steps.map((Ge,fn)=>`${fn+1}. ${Ge.description||Ge.type}`).join(`
129
- `);Er(Ge=>[...Ge,{kind:"assistant",text:e("flow:composer.taskPlan",{count:pe.steps.length,summary:Xe})}])}if(pe.type==="step-start"){const Xe=pe.index??0,Ge=pe.total??0,fn=pe.tier?` [${pe.tier}]`:"",j_=pe.model?` (${pe.model})`:"";Cr(e("flow:composer.step",{current:Xe+1,total:Ge,description:(pe.description||"")+fn+j_})),Ua(P_=>P_.map(ds=>ds.index===Xe?{...ds,status:"running",model:pe.model,tier:pe.tier,nodeRole:pe.nodeRole??ds.nodeRole,instanceId:pe.instanceId??ds.instanceId,instanceLabel:pe.instanceLabel??ds.instanceLabel}:ds))}if(pe.type==="step-progress"){const Xe=pe.index??0,Ge=pe.total??0;Cr(e("flow:composer.step",{current:Xe+1,total:Ge,description:pe.description||""}))}if(pe.type==="step-done"){const Xe=pe.index??0;Ua(Ge=>Ge.map(fn=>fn.index===Xe?{...fn,status:pe.success?"done":"error"}:fn))}if(pe.type==="phase-plan"&&Array.isArray(pe.phases)){Va(Ge=>({...Ge||{},phases:pe.phases,currentPhase:pe.currentPhase??0,phaseTotal:pe.phaseTotal??pe.phases.length,phaseName:pe.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(Ge==null?void 0:Ge.userPromptOriginal)||W}));const Xe=pe.phases.map((Ge,fn)=>`${fn+1}. ${Ge.label}`).join(" → ");Er(Ge=>[...Ge,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:pe.phases.length,labels:Xe,current:pe.phaseName||""})}])}pe.type==="phase-complete"&&(Va(Xe=>{var fn;return{...Xe||{},phases:pe.phases||(Xe==null?void 0:Xe.phases)||[],currentPhase:pe.phaseIndex??0,phaseTotal:pe.phaseTotal??((fn=pe.phases)==null?void 0:fn.length)??0,phaseName:pe.phaseName||"",isLastPhase:!!pe.isLastPhase,nextPhase:pe.nextPhase||null,userPromptOriginal:pe.userPromptOriginal||(Xe==null?void 0:Xe.userPromptOriginal)||W}}),!pe.isLastPhase&&pe.nextPhase&&Er(Xe=>[...Xe,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:pe.phaseName||e("flow:composer.nextPhase"),nextPhase:pe.nextPhase.label})}])),pe.type==="done"&&(We=!0,Cr(Xe=>Xe||e("flow:composer.done")))}}}catch(it){const Hn=it;if(Hn.name==="AbortError"){const Yt=e(oe?"flow:composer.connectTimeout":"flow:composer.aborted");Cr(Yt),Er(us=>[...us,{kind:"error",text:Yt}])}else{const Yt=Hn.code||Hn.name||"UNKNOWN",us=`${Hn.message||String(it)} [${Yt}]`;Cr(us),Er(vo=>[...vo,{kind:"error",text:us}])}}finally{Ap.current=!1,Yx(!1),fu.current=null,Ip.current=null,oe&&clearTimeout(oe),We&&Ve&&Cn({id:Ve.id,source:Ve.source??"user",archived:Ve.archived},{preserveComposer:!0,incrementalSync:!0})}},[a,zn,go,_e,Su,Cn,Ha,Kt,Ae,jp]);UP.current=wo;const aw=x.useCallback(()=>{!Ae||Ae.isLastPhase||(Va(null),wo(e("flow:composer.skipRemainingPhases")))},[Ae,wo]),lw=x.useCallback(()=>{if(!Ae||Ae.isLastPhase||!Ae.nextPhase)return;const b=String(Ae.nextPhase.label||"").trim()||e("flow:composer.nextPhase");wo(e("flow:composer.continuePhase",{label:b}),{phaseContextSnapshot:Ae})},[Ae,wo]);x.useEffect(()=>{if(!_p)return;const b=j=>{j.key==="Escape"&&du(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[_p]),x.useEffect(()=>{he!=="edit"&&du(!1)},[he]),x.useLayoutEffect(()=>{const b=Np.current;if(!b)return;if(!a){b.style.height="";return}b.style.height="0px";const j=getComputedStyle(b),z=parseFloat(j.lineHeight),W=(parseFloat(j.paddingTop)||0)+(parseFloat(j.paddingBottom)||0),K=Number.isFinite(z)&&z>0?z:13*1.45,Y=W+K*2,Z=W+K*10,te=Math.min(Math.max(b.scrollHeight,Y),Z);b.style.height=`${te}px`},[zn,a]);const zp=x.useCallback(b=>{const j=zn,z=iu,W=a1(j,z);if(!W)return;const K=j.slice(0,W.atIndex)+`@${b} `+j.slice(z);La(K);const Y=W.atIndex+b.length+2;queueMicrotask(()=>{const Z=Np.current;Z&&(Z.focus(),Z.setSelectionRange(Y,Y)),Oa(Y)})},[zn,iu]),Bp=x.useCallback(b=>{La(j=>{const z=`@${b}`,W=j.indexOf(z);return W<0?j:j.slice(0,W)+j.slice(W+z.length)})},[]),cw=x.useCallback(b=>{b.kind==="canvas"?Ue(j=>j.map(z=>z.id===b.node.id?{...z,selected:!1}:z)):b.kind==="mention"?Bp(b.node.id):Bp(b.definition.id)},[Ue,Bp]),k_=x.useCallback(()=>{le(b=>b==="history"?null:"history")},[]),N_=x.useCallback(()=>{le(b=>b==="settings"?null:"settings")},[]),C_=x.useCallback(()=>{le(b=>b==="composer"?null:"composer")},[]),Hp=x.useCallback(()=>{le(b=>(b==="node"&&$a.current&&(Cp.current=$a.current.id),null))},[]),uw=x.useCallback(()=>{Fa(b=>!b)},[]),E_=a?Gh(a):"";return c.jsx(gE,{children:c.jsxs(Jj.Provider,{value:{modelLists:_e,onModelChange:d_},children:[c.jsxs("div",{className:"af-pipeline-page"+(he!=="edit"?" af-pipeline-page--run-mode":""),children:[c.jsxs("header",{className:"af-pipeline-top",children:[c.jsxs("div",{className:"af-pipeline-top-left",children:[c.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{he==="running"?bu(!0):he!=="edit"?xo():t("/projects")},"aria-label":e(he!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(he!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:c.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),c.jsxs("div",{className:"af-pipeline-brand",children:[c.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),c.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",E6,"-STABLE"]})]}),c.jsxs("div",{className:"af-pipeline-flow-pick",children:[c.jsx("label",{className:"af-visually-hidden",htmlFor:"af-flow-select",children:e("flow:topbar.currentPipeline")}),c.jsx("select",{id:"af-flow-select",className:"af-pipeline-flow-select",value:E_,onChange:b=>{const j=b.target.value;if(!j)return;const z=j.split("\0"),W=z[0],K=z[1]||"user",Y=z[2]==="1",Z=r.find(te=>te.id===W&&(te.source??"user")===K&&!!te.archived===Y);Z&&Cn(Z)},disabled:r.length===0,children:r.length===0?c.jsx("option",{value:"",children:e("flow:palette.loading")}):c.jsxs(c.Fragment,{children:[a?null:c.jsx("option",{value:"",children:e("flow:pipeline.selectPipeline")}),r.map(b=>c.jsxs("option",{value:Gh(b),children:[b.id," (",Xh(b.source??"user",e),")",b.archived?` · ${e("flow:palette.archived")}`:""]},Gh(b)))]})})]})]}),c.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[gp&&c.jsx("button",{type:"button",className:"af-icon-btn"+(Vc?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Wc(b=>!b),children:c.jsx("span",{className:"material-symbols-outlined",children:"description"})}),he==="running"&&c.jsxs("div",{className:"af-run-timer",children:[c.jsx("span",{className:"af-run-timer__dot"}),c.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,"running")})]}),he==="stopped"&&c.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[c.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,"stopped")})]}),(he==="done"||he==="error")&&c.jsxs("div",{className:"af-run-timer"+(he==="error"?" af-run-timer--error":" af-run-timer--done"),children:[c.jsx("span",{className:"af-run-timer__label",children:he==="error"?"FAILED":"COMPLETED"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,he)})]}),he!=="edit"&&c.jsx("button",{type:"button",className:"af-icon-btn"+(cn?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Ft(b=>!b),children:c.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),he==="edit"&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-icon-btn"+(J==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!a,onClick:k_,children:c.jsx("span",{className:"material-symbols-outlined",children:"history"})}),c.jsx("button",{type:"button",className:"af-icon-btn"+(J==="settings"?" af-icon-btn--active":""),onClick:N_,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!a,children:c.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),c.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(J==="composer"?" af-composer-topbar-btn--active":"")+(vt?" af-composer-topbar-btn--running":""),onClick:C_,"aria-label":"AI Composer",title:"AI Composer",disabled:!a,children:"AI"}),c.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(ou?" af-icon-btn--active":""),onClick:uw,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!a,children:c.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),c.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!a||a.source==="builtin"||a.source!=="user"&&a.source!=="workspace",onClick:()=>D(!0),children:c.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),c.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!a||a.source==="builtin"||a.archived||a.source!=="user"&&a.source!=="workspace",onClick:()=>L(!0),children:"Archive"})]}),he==="running"?c.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:y_,title:e("flow:run.pauseRun"),children:[c.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):he==="ready"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):he==="stopped"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr({runUuid:ft}),title:ft?e("flow:topbar.resumeTitle",{uuid:ft}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):he==="done"||he==="error"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr(),title:e("flow:topbar.rerunTitle"),children:"Run"}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):c.jsxs("div",{className:"af-run-btn-group",children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!a,onClick:()=>void Pr(),children:"Run"}),c.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!a,onClick:()=>yi(b=>!b),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":qc,children:c.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),qc&&a&&c.jsxs("div",{className:"af-run-dropdown-menu",children:[c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var j,z,W,K,Y;yi(!1);const b={};for(const Z of er){const te=cs[Z.id];te&&(b[te]=((j=co[te])==null?void 0:j.value)??((z=co[te])==null?void 0:z.path)??((Y=(K=(W=Z.data)==null?void 0:W.outputs)==null?void 0:K[0])==null?void 0:Y.default)??"")}Xc(b),Zo(!0)},children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{yi(!1),Pr({prepareOnly:!0})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),c.jsx("div",{className:"af-run-dropdown-divider"}),c.jsxs("div",{className:"af-run-dropdown-section",children:[c.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{yi(!1),Pr()},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(xi).map(b=>c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var W;yi(!1);const j=xi[b]||{},z={};for(const K of er){const Y=cs[K.id];if(!Y)continue;const Z=((W=K.data)==null?void 0:W.definitionId)||"",te=j[K.id]??"";Z.startsWith("provide_file")?z[Y]={type:"file",path:te}:z[Y]={type:"str",value:te}}Pr({cliInputsOverride:z})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),b]},b))]})]})]})]})]}),c.jsxs("div",{className:"af-pipeline-body"+(he!=="edit"?" af-pipeline-body--run-mode":""),children:[he==="edit"?c.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[c.jsxs("div",{className:`af-palette-workspace${Le?" af-palette-workspace--expanded":""}`,children:[c.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>mt(b=>!b),"aria-expanded":Le,children:[c.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),c.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),c.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Le?"expand_less":"expand_more"})]}),c.jsx("div",{className:"af-palette-workspace-path",title:a!=null&&a.path?s1(a.path):"",children:a!=null&&a.path?s1(a.path):e("flow:palette2.noPipelineSelected")}),Le&&c.jsx("div",{className:"af-palette-workspace-tree",children:Fn?c.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):_t.error?c.jsx("div",{className:"af-palette-workspace-empty",children:_t.error}):a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-palette-workspace-group",children:[c.jsxs("div",{className:"af-palette-workspace-group-head",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),c.jsx("span",{children:a.id}),c.jsxs("span",{className:"af-palette-workspace-count",children:["(",_t.files.length,")"]})]}),_t.files.length>0?c.jsx("ul",{className:"af-palette-workspace-list",children:_t.files.filter(b=>b.type==="file").map(b=>c.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:b.path,onClick:()=>_({filePath:b.path,fileName:b.name}),children:[c.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:b.icon}),c.jsx("span",{className:"af-palette-workspace-item-label",children:b.name}),b.size!=null&&c.jsx("span",{className:"af-palette-workspace-item-size",children:b.size<1024?`${b.size}B`:b.size<1024*1024?`${(b.size/1024).toFixed(1)}KB`:`${(b.size/1024/1024).toFixed(1)}MB`})]},b.path))}):_t.files.filter(b=>b.type==="directory").length===0?c.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),_t.files.filter(b=>{var j;return b.type==="directory"&&((j=b.children)==null?void 0:j.length)>0}).map(b=>c.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[c.jsxs("div",{className:"af-palette-workspace-group-head",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:b.icon}),c.jsxs("span",{children:[b.name,"/"]}),c.jsxs("span",{className:"af-palette-workspace-count",children:["(",b.children.length,")"]})]}),c.jsx("ul",{className:"af-palette-workspace-list",children:b.children.map(j=>c.jsxs("li",{className:`af-palette-workspace-item${j.type==="file"?" af-palette-workspace-item--clickable":""}`,title:j.path,onClick:j.type==="file"?()=>_({filePath:j.path,fileName:j.name}):void 0,children:[c.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:j.icon}),c.jsx("span",{className:"af-palette-workspace-item-label",children:j.name}),j.type==="file"&&j.size!=null&&c.jsx("span",{className:"af-palette-workspace-item-size",children:j.size<1024?`${j.size}B`:j.size<1024*1024?`${(j.size/1024).toFixed(1)}KB`:`${(j.size/1024/1024).toFixed(1)}MB`})]},j.path))})]},b.path))]}):c.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),c.jsxs("div",{className:"af-node-palette-head",children:[c.jsx("h2",{className:"af-node-palette-title",children:"Node Palette"}),c.jsxs("label",{className:"af-palette-search-wrap",children:[c.jsx("span",{className:"af-visually-hidden",children:e("flow:palette.searchNodes")}),c.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),c.jsx("input",{type:"search",className:"af-palette-search-input",value:ne,onChange:b=>ae(b.target.value),placeholder:e("flow:palette.searchNodes")+"…","aria-label":e("flow:palette.searchNodes")})]})]}),o?c.jsx("p",{className:"af-err af-palette-list-err",children:o}):null,c.jsxs("div",{className:"af-node-palette-scroll",children:[td.filter(b=>mu[b].length>0).map(b=>c.jsxs("section",{className:`af-palette-section af-flow-palette-section--${b}`,children:[c.jsx("h3",{className:"af-palette-cat",children:b}),c.jsx("div",{className:"af-palette-cards",children:mu[b].map(j=>c.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>s_(j),draggable:!!a,onDragStart:z=>{z.dataTransfer.setData("application/agentflow-node",j.id),z.dataTransfer.effectAllowed="move"},disabled:!a,title:j.description||j.id,children:[c.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:c.jsx("span",{className:"material-symbols-outlined",children:I6(b)})}),c.jsx("span",{className:"af-palette-card-label",children:j.id})]},j.id))})]},b)),a&&q.length===0?c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,a&&q.length>0&&ne.trim()&&QP===0?c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,a?null:c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]}),c.jsxs("footer",{className:"af-palette-engine",children:[c.jsxs("div",{className:"af-palette-engine-head",children:[c.jsx("span",{className:"af-palette-engine-dot"+(vr?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),c.jsx("span",{className:"af-palette-engine-label",children:e(vr?"common:engine.online":"common:engine.offline")})]}),v?c.jsx("div",{className:"af-palette-tip"+JP,role:"status","aria-live":"polite",children:v}):null]})]}):a?c.jsx(w6,{flowId:a.id,flowSource:a.source||"user",flowArchived:a.archived,provideNodes:er,edges:xt,nodes:He,onCliInputsChange:Kc,onBackToEdit:xo}):null,c.jsxs("div",{className:"af-pipeline-main-stack",children:[c.jsxs("div",{className:"af-pipeline-canvas-col",children:[h?c.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:h}):null,a&&jr.length>0&&!I?c.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[c.jsxs("div",{className:"af-flow-slot-warnings-head",children:[c.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),c.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[c.jsx("button",{type:"button",className:"af-icon-btn",disabled:F,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void ew(),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),c.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>C(!0),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),c.jsx("ul",{className:"af-flow-slot-warnings-list",children:jr.map(b=>c.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',c.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:b.nodeId}),onClick:j=>{j.preventDefault(),i_(b.nodeId)},children:b.nodeId}),'"',b.suffix]},b.key))})]}):null,a&&jr.length>0&&I?c.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:jr.length})}),c.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:uw,title:e("flow:validation.shortcutHint"),children:[c.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),c.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[c.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>C(!1),children:e("flow:validation.show")}),c.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:F,onClick:()=>void ew(),children:e("common:common.refresh")})]})]}):null,c.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:a?c.jsx(Y6,{fitViewEpoch:u,canvasTool:FP,nodes:YP,edges:qP,onNodesChange:he!=="edit"?void 0:WP,onEdgesChange:he!=="edit"?void 0:KP,onConnect:he!=="edit"?void 0:t_,onNodesDelete:he!=="edit"?void 0:n_,onNodeClick:ZP,onEdgeClick:e_,onFlowInit:r_,onDrop:l_,onDragOver:a_,hideMinimapAndControls:!!(a&&J),bottomSlot:he==="edit"?c.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:c.jsxs("div",{className:"af-pipeline-composer-inner",children:[c.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Su.length===0?c.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Su.map((b,j)=>{var se,oe;if(b.kind==="definition"){const me=b.definition,X=String(me.label??me.id),ue=[me.id,me.description?String(me.description).slice(0,120):""].filter(Boolean).join(" — ");return c.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:ue,children:[c.jsx("span",{className:"af-composer-node-chip-label",children:X}),c.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>cw(b),"aria-label":e("flow:composer.removeFromInput",{id:me.id}),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${me.id}`)}const z=b.node,W=b.kind,K=String(((se=z.data)==null?void 0:se.label)??z.id),Y=(oe=z.data)!=null&&oe.definitionId?String(z.data.definitionId):"",Z=Y&&Y!==K?`${K} · ${z.id} · ${Y}`:`${K} · ${z.id}`,te=W==="canvas"?e("flow:composer.deselectNode",{id:z.id}):e("flow:composer.removeFromInput",{id:z.id});return c.jsxs("div",{className:"af-composer-node-chip"+(W==="mention"?" af-composer-node-chip--mention":""),title:Z,children:[c.jsx("span",{className:"af-composer-node-chip-label",children:K}),c.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>cw(b),"aria-label":te,children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},z.id)})}),c.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[c.jsxs("div",{className:"af-composer-input-wrap",children:[c.jsx("textarea",{ref:Np,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!a,value:zn,rows:2,onChange:b=>{La(b.target.value),Oa(b.target.selectionStart??b.target.value.length)},onSelect:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??0)},onKeyDown:b=>{if((b.metaKey||b.ctrlKey)&&b.key==="Enter"){b.preventDefault(),wo();return}if(Ga&&tr.length>0&&(b.key==="ArrowDown"||b.key==="ArrowUp"||b.key==="Enter")){if(b.key==="ArrowDown")b.preventDefault(),Da(j=>(j+1)%tr.length);else if(b.key==="ArrowUp")b.preventDefault(),Da(j=>(j-1+tr.length)%tr.length);else if(b.key==="Enter"){b.preventDefault();const j=tr[Ma];j&&zp(j.id)}}},onKeyUp:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??j.value.length)},onClick:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Ga&&a&&tr.length>0?c.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Xa.instances.length>0?c.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:c.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Xa.instances.map((b,j)=>{const z=j;return c.jsx("li",{role:"option","aria-selected":z===Ma,children:c.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ma?" af-composer-mention-item--active":""),onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>Da(z),onClick:()=>zp(b.id),children:[c.jsx("span",{className:"af-composer-mention-id",children:b.title}),b.subtitle?c.jsx("span",{className:"af-composer-mention-sub",children:b.subtitle}):null]})},`i-${b.id}`)}),Xa.definitions.length>0?c.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:c.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Xa.definitions.map((b,j)=>{const z=Xa.instances.length+j;return c.jsx("li",{role:"option","aria-selected":z===Ma,children:c.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ma?" af-composer-mention-item--active":""),onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>Da(z),onClick:()=>zp(b.id),children:[c.jsx("span",{className:"af-composer-mention-id",children:b.title}),b.subtitle?c.jsx("span",{className:"af-composer-mention-sub",children:b.subtitle}):null]})},`d-${b.id}`)})]}):null]}),c.jsxs("div",{className:"af-composer-toolbar",children:[Bn.length>0&&c.jsx("label",{className:"af-composer-session-field",children:c.jsxs("select",{className:"af-composer-session-select",value:Kt||"",onChange:b=>{b.target.value==="__new__"?Kx():Xx(b.target.value)},disabled:vt,"aria-label":e("flow:composer.switchConversation"),children:[Bn.map(b=>c.jsxs("option",{value:b.id,children:[b.label,b.running?" ⏳":""]},b.id)),c.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),c.jsxs("label",{className:"af-composer-model-field",children:[c.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),c.jsxs("select",{className:"af-composer-model-select",value:(go||"").trim()?dn.currentNotInLists?dn.currentNotInLists:nd(go,dn.cursorList,dn.opencodeList,dn.claudeCodeList):"",onChange:b=>Bx(b.target.value),disabled:!a||vt,"aria-label":e("flow:composer.modelAriaLabel"),children:[c.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),dn.currentNotInLists?c.jsxs("option",{value:dn.currentNotInLists,children:[dn.currentNotInLists,e("flow:composer.modelNotInList")]}):null,dn.cursorList.length>0?c.jsx("optgroup",{label:"Cursor",children:dn.cursorList.map(b=>c.jsx("option",{value:ei(b),children:b},`composer-c-${b}`))}):null,dn.opencodeList.length>0?c.jsx("optgroup",{label:"OpenCode",children:dn.opencodeList.map(b=>c.jsx("option",{value:`opencode:${ei(b)}`,children:b},`composer-o-${b}`))}):null,dn.claudeCodeList.length>0?c.jsx("optgroup",{label:"Claude Code",children:dn.claudeCodeList.map(b=>c.jsx("option",{value:`claude-code:${ei(b)}`,children:b},`composer-cc-${b}`))}):null]})]}),c.jsx("button",{type:"button",className:"af-composer-send"+(a&&zn.trim()&&!vt?" af-composer-send--active":"")+(vt?" af-composer-send--stop":""),disabled:!a||!vt&&!zn.trim(),"aria-label":e(vt?"flow:composer.stopGeneration":"flow:composer.send"),title:vt?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var b;if(vt){(b=fu.current)==null||b.abort();return}wo()},children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:vt?"stop":"arrow_upward"})})]})]}),_p?qi.createPortal(c.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:b=>{b.target===b.currentTarget&&du(!1)},children:c.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[c.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[c.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[c.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),c.jsx("div",{className:"af-composer-thread-dialog-status"+(vt?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:za||void 0,children:vt&&!za?e("flow:composer.executing"):za||e("flow:composer.ready")})]}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>du(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ux.length>1&&!(Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1)?c.jsx("div",{className:"af-composer-steps-track-wrap",children:c.jsx(O6,{steps:Ux})}):null,Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1?c.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Ae.phases.map((b,j)=>{const z=b.status||(j<(Ae.currentPhase??0)?"done":j===(Ae.currentPhase??0)?vt?"running":Ae.nextPhase||Ae.isLastPhase?"done":"running":"pending");return c.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${b.label}${b.description?":"+b.description:""}`,children:[c.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):c.jsx("span",{children:j+1})}),c.jsx("span",{className:"af-composer-phase-label",children:b.label})]},b.name||j)})}):null,c.jsx("div",{className:"af-composer-thread-dialog-scroll",children:c.jsx(l1,{thread:Ha,liveSegments:Ba,running:vt})}),Ae&&!Ae.isLastPhase&&Ae.nextPhase&&!vt?c.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[c.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Ae.nextPhase.label})}),c.jsxs("div",{className:"af-composer-phase-review-buttons",children:[c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:lw,children:e("flow:composer.phaseReviewContinue",{label:Ae.nextPhase.label})}),c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:aw,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}):c.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),he!=="edit"&&cn&&c.jsxs("div",{className:"af-run-console",style:{height:Ea},children:[c.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:p_,onPointerMove:h_,onPointerUp:iw,onPointerCancel:iw,onLostPointerCapture:m_}),c.jsxs("div",{className:"af-run-console__head",children:[c.jsxs("span",{className:"af-run-console__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),c.jsxs("div",{className:"af-run-console__head-right",children:[he==="running"&&c.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),c.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>Ft(!1),"aria-label":e("flow:run.closeLog"),children:c.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),c.jsxs("div",{className:"af-run-console__body",children:[G.map((b,j)=>c.jsxs("div",{className:"af-run-console__line"+(b.type==="error"?" af-run-console__line--error":"")+(b.type==="warn"?" af-run-console__line--warn":"")+(b.type==="node-start"?" af-run-console__line--start":"")+(b.type==="node-done"?" af-run-console__line--done":"")+(b.type==="node-failed"?" af-run-console__line--error":"")+(b.type==="done"?" af-run-console__line--done":""),children:[c.jsxs("span",{className:"af-run-console__ts",children:["[",b.ts?new Date(b.ts).toLocaleTimeString():"--:--:--","]"]}),c.jsx("span",{className:"af-run-console__text",children:b.text!=null?String(b.text):""})]},j)),c.jsx("div",{ref:fo})]})]})]}),he!=="edit"&&Pa&&a?c.jsx(m6,{instanceId:Pa,flowId:a.id,runId:ft,nodeStatus:((dw=It[Pa])==null?void 0:dw.status)??null,onClose:()=>Jo(null)}):null,J&&a&&he==="edit"?c.jsx("aside",{className:"af-pipeline-drawer"+(J==="node"?" af-pipeline-drawer--wide":"")+(J==="composer"?" af-pipeline-drawer--wide":""),"aria-label":J==="settings"?e("flow:settings.title"):J==="history"?e("flow:history.title"):J==="composer"?"AI Composer":e("flow:nodeProps.title"),children:J==="composer"?c.jsxs("div",{className:"af-composer-sidebar",children:[c.jsxs("div",{className:"af-pipeline-drawer-head",children:[c.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Hp,"aria-label":e("flow:composer.closeSidebar"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Bn.length>0&&c.jsxs("div",{className:"af-composer-session-tabs",children:[Bn.map(b=>c.jsxs("button",{type:"button",ref:j=>{j&&b.id===Kt&&j.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",b.id===Kt?"af-composer-session-tab--active":"",b.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Xx(b.id),title:b.label,children:[c.jsx("span",{className:"af-composer-session-label",children:b.label}),(Bn.length>1||b.running)&&c.jsx("span",{className:"af-composer-session-close",onClick:j=>{j.stopPropagation(),VP(b.id)},title:b.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},b.id)),c.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>Kx(),title:e("flow:composer.newConversation"),children:c.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),c.jsx("div",{className:"af-composer-sidebar-status"+(vt?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:vt&&!za?e("flow:composer.executing"):za||e("flow:composer.ready")}),Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1?c.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Ae.phases.map((b,j)=>{const z=b.status||(j<(Ae.currentPhase??0)?"done":j===(Ae.currentPhase??0)?vt?"running":Ae.isLastPhase&&j===Ae.phases.length-1||Ae.nextPhase?"done":"running":"pending");return c.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${b.label}${b.description?":"+b.description:""}`,children:[c.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):c.jsx("span",{children:j+1})}),c.jsx("span",{className:"af-composer-phase-label",children:b.label})]},b.name||j)})}):null,c.jsx("div",{className:"af-composer-sidebar-thread",ref:Wx,children:c.jsx(l1,{thread:Ha,liveSegments:Ba,running:vt})}),Ae&&!Ae.isLastPhase&&Ae.nextPhase&&!vt?c.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[c.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Ae.nextPhase.label})}),c.jsxs("div",{className:"af-composer-phase-review-buttons",children:[c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:lw,children:e("flow:composer.phaseReviewContinue",{label:Ae.nextPhase.label})}),c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:aw,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):J==="node"&&Pe?Oe?c.jsx(C4,{draft:Oe,setDraft:Ep,definitionId:String(((fw=Pe.data)==null?void 0:fw.definitionId)??Pe.id),systemPromptReadonly:String((Op==null?void 0:Op.description)??""),modelLists:_e,disabled:!a,onIdBlur:f_,onClose:Hp,error:BP,ioSlots:{inputs:Array.isArray(Oe==null?void 0:Oe.inputs)?Oe.inputs:[],outputs:Array.isArray(Oe==null?void 0:Oe.outputs)?Oe.outputs:[]}}):c.jsx("div",{className:"af-pipeline-drawer-body",children:c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-pipeline-drawer-head",children:[c.jsx("h2",{className:"af-pipeline-drawer-title",children:e(J==="settings"?"flow:settings.title":"flow:history.title")}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Hp,"aria-label":e("flow:composer.closeSidebar"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-pipeline-drawer-body",children:J==="settings"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(a.source==="user"||a.source==="workspace")&&!a.archived?c.jsxs("div",{className:"af-pipeline-rename-row",children:[c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:E,onChange:b=>{S(b.target.value),B("")},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),nw())},onBlur:()=>{E.trim()&&E.trim()!==a.id&&nw()},placeholder:a.id,disabled:P,spellCheck:!1}),c.jsx("span",{className:"af-pipeline-drawer-badge",children:Xh(a.source??"user",e)})]}):c.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[a.id,c.jsx("span",{className:"af-pipeline-drawer-badge",children:Xh(a.source??"user",e)}),a.archived?c.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),M?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:M}):null]}),typeof a.path=="string"&&a.path?c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),c.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[c.jsx("span",{className:"af-pipeline-path-text",children:a.path}),c.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>u_(a.path),title:e("flow:settings.copyPath"),children:c.jsx("span",{className:"material-symbols-outlined",children:A?"check":"content_copy"})})]})]}):null,a.source==="user"||a.source==="workspace"?a.archived?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),c.jsx("div",{className:"af-pipeline-move-actions",children:a.source==="user"?c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:y,onClick:()=>tw("workspace"),children:e(y?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:y,onClick:()=>tw("user"),children:e(y?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),g?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:g}):null]}):c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),c.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:d,onChange:b=>p(b.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),c.jsxs("div",{className:"af-pipeline-meta-card",children:[c.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),wp?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"af-new-pipeline-radio",children:[c.jsx("input",{type:"checkbox",checked:!!$n.enabled,disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,enabled:b.target.checked}))}),c.jsx("span",{children:e("flow:schedule.enabled")})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:$n.cron||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,cron:b.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:$n.timezone||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,timezone:b.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),c.jsxs("select",{className:"af-pipeline-flow-select",value:$n.preset||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,preset:b.target.value})),children:[c.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(xi).map(b=>c.jsx("option",{value:b,children:b},b))]})]}),c.jsx("div",{className:"af-pipeline-drawer-readonly",children:c.jsx("span",{children:e("flow:schedule.overlapSkip")})}),$n.nextRunAt?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date($n.nextRunAt).toLocaleString()})}):c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),c.jsxs("dl",{className:"af-pipeline-meta-dl",children:[c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.runtime")}),c.jsx("dd",{children:Zn!=null&&Zn.running?e("flow:schedule.running"):$n.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Wt.lastTriggeredAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),c.jsx("dd",{children:new Date(Wt.lastTriggeredAt).toLocaleString()})]}):null,Wt.lastSkippedAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),c.jsxs("dd",{children:[new Date(Wt.lastSkippedAt).toLocaleString(),Wt.lastSkipReason?` · ${Wt.lastSkipReason}`:""]})]}):null,Wt.lastRunUuid?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastRun")}),c.jsx("dd",{children:Wt.lastRunUuid})]}):null,Wt.lastExitCode!=null?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastExit")}),c.jsx("dd",{children:String(Wt.lastExitCode)})]}):null,Wt.lastFinishedAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),c.jsx("dd",{children:new Date(Wt.lastFinishedAt).toLocaleString()})]}):null]}),Zn!=null&&Zn.lastError||Wt.lastError?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Zn==null?void 0:Zn.lastError)||Wt.lastError}):null,a.archived||a.source==="builtin"?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Zc?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Zc}):null,eu?c.jsx("p",{className:"af-pipeline-drawer-muted",children:eu}):null,c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:wi||a.archived||a.source==="builtin",onClick:c_,children:e(wi?"flow:schedule.saving":"flow:schedule.save")})]})]}),c.jsxs("div",{className:"af-pipeline-meta-card",children:[c.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),c.jsx("dl",{className:"af-pipeline-meta-dl",children:c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:pipeline.nodeCount")}),c.jsxs("dd",{children:[He.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>t("/settings"),children:e("flow:settings.globalSettings")})]}):c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),c.jsx("strong",{children:a.id})]}),$e?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):ge?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:ge}):qa.length===0?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):c.jsxs(c.Fragment,{children:[nn.success+nn.failed+nn.running+nn.stopped+nn.interrupted>0?c.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[nn.success>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:nn.success})}):null,nn.failed>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:nn.failed})}):null,nn.stopped>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:nn.stopped})}):null,nn.interrupted>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:nn.interrupted})}):null,nn.running>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:nn.running})}):null]}):null,c.jsx("ul",{className:"af-exec-history-list",children:qa.map((b,j)=>{const z=b.status||"unknown",W=z==="success"?"af-exec-history-card--success":z==="failed"?"af-exec-history-card--failed":z==="stopped"?"af-exec-history-card--stopped":z==="interrupted"?"af-exec-history-card--interrupted":z==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",K=e(z==="success"?"flow:history.success":z==="failed"?"flow:history.failed":z==="stopped"?"flow:history.stopped":z==="interrupted"?"flow:history.interrupted":z==="running"?"flow:history.running":"flow:history.unknown"),Y=z==="success"?"check_circle":z==="failed"?"error":z==="stopped"?"stop_circle":z==="interrupted"?"sync_disabled":z==="running"?"progress_activity":"help",Z=b.runId||`${b.at}-${j}`,te=b.runId!=null&&b.runId.length>=6?e("flow:history.runLabel",{id:b.runId.length>8?b.runId.slice(-8):b.runId}):e("flow:history.runLabel",{id:qa.length-j});return c.jsx("li",{className:"af-exec-history-list-item",children:c.jsxs("button",{type:"button",className:`af-exec-history-card ${W}`,onClick:()=>S_(b),title:e("flow:history.enterRunView"),children:[c.jsxs("div",{className:"af-exec-history-card-top",children:[c.jsx("span",{className:"af-exec-history-card-title",children:te}),c.jsx("span",{className:"af-exec-history-card-time",children:ng(b.at,e)})]}),c.jsxs("div",{className:"af-exec-history-card-bottom",children:[c.jsxs("span",{className:"af-exec-history-card-status",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Y}),K]}),c.jsxs("span",{className:"af-exec-history-card-duration",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),jA(b.durationMs,e)]})]})]})},`${a.id}-${Z}`)})})]})]})})]})}):null]}),c.jsx(Zv,{open:g_,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:x_,onCancel:()=>$p(!1)}),c.jsx(Zv,{open:w_,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:b_,onSecondary:v_,onCancel:()=>bu(!1)}),c.jsx(u4,{open:ou,onClose:()=>Fa(!1)}),c.jsx(f4,{open:kp,onClose:()=>zx(!1),onJump:o_,nodes:He}),c.jsx(C6,{open:Vc,onClose:()=>Wc(!1),flowId:(a==null?void 0:a.id)??""}),c.jsx(a4,{open:V,onClose:()=>L(!1),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",onArchived:async()=>{L(!1),await gu(),t("/projects?tab=archived")}}),c.jsx(l4,{open:H&&!!(a!=null&&a.id),onClose:()=>D(!1),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",flowArchived:!!(a!=null&&a.archived),onDeleted:async()=>{D(!1),l(null),Ue([]),Tt([]),Va(null),await gu(),t("/projects")}}),c.jsx(p4,{open:!!$,onClose:()=>_(null),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",flowArchived:!!(a!=null&&a.archived),filePath:($==null?void 0:$.filePath)??"",fileName:($==null?void 0:$.fileName)??"",onSaved:()=>{Dt(b=>({...b}))}})]}),At&&he!=="edit"&&qi.createPortal(c.jsx("div",{className:"af-user-check-modal-overlay",children:c.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-user-check-modal__head",children:[c.jsxs("span",{className:"af-user-check-modal__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:At.instanceId})]}),c.jsx("div",{className:"af-user-check-modal__actions",children:tu?c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!At||!a||!ft)return;const b=ho||At.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"save-user-check-content",runUuid:ft,instanceId:At.instanceId,content:b})})).ok?(ns(z=>z&&{...z,content:b}),mo(!1),Q(z=>[...z,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{rs(At.content),mo(!1)},children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>mo(!0),children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),c.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>ns(null),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),c.jsx("div",{className:"af-user-check-modal__body",children:tu?c.jsx("textarea",{ref:vp,className:"af-user-check-modal__textarea",value:ho||At.content,onChange:b=>rs(b.target.value)}):c.jsx("div",{className:"af-user-check-modal__preview",children:c.jsx("pre",{children:ho||At.content})})}),c.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[c.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:qr,onChange:b=>is(b.target.value),disabled:os}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:os||!qr.trim(),onClick:()=>{!At||!a||!ft||!qr.trim()||(ss(!0),Q(b=>[...b,{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:a.id,flowSource:a.source??"user",action:"ai-edit-user-check-content",runUuid:ft,instanceId:At.instanceId,content:ho||At.content,prompt:qr})}).then(b=>b.json()).then(b=>{ss(!1),b.ok&&b.content?(rs(b.content),mo(!0),is(""),Q(j=>[...j,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:b.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{ss(!1),Q(b=>[...b,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[os?c.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):c.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),c.jsxs("div",{className:"af-user-check-modal__foot",children:[c.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!At||!a||!ft)return;const b=ho||At.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"save-user-check-content",runUuid:ft,instanceId:At.instanceId,content:b})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"confirm-user-check",runUuid:ft,instanceId:At.instanceId,execId:At.execId})}),ns(null),is(""),Pr({runUuid:ft})):Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),Nn&&he!=="edit"&&qi.createPortal(c.jsx("div",{className:"af-user-ask-modal-overlay",children:c.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-user-ask-modal__head",children:[c.jsxs("span",{className:"af-user-ask-modal__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:Nn.instanceId})]}),c.jsx("div",{className:"af-user-ask-modal__actions",children:c.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Ra(null),"aria-label":e("flow:userAsk.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),c.jsxs("div",{className:"af-user-ask-modal__body",children:[Nn.question.trim()?c.jsx("div",{className:"af-user-ask-modal__question",children:c.jsx("pre",{children:Nn.question})}):null,Nn.options.length===0?c.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):c.jsx("div",{className:"af-user-ask-modal__options",children:Nn.options.map(b=>c.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:nu,onClick:async()=>{if(!(!Nn||!a||!ft)){bi(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"confirm-user-ask",runUuid:ft,instanceId:Nn.instanceId,execId:Nn.execId,branch:b.name,selectedIndex:b.index,selectedLabel:b.label})})).ok?(Ra(null),bi(!1),Pr({runUuid:ft})):(bi(!1),Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{bi(!1),Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[c.jsxs("span",{className:"af-user-ask-option__index",children:["[",b.index,"]"]}),c.jsx("span",{className:"af-user-ask-option__label",children:b.label})]},b.name))})]}),c.jsx("div",{className:"af-user-ask-modal__foot",children:c.jsx("span",{className:"af-user-ask-modal__hint",children:e(nu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),as&&he!=="edit"&&c.jsxs("div",{className:"af-tool-print-toast",role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"af-tool-print-toast__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"print"}),c.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:as.instanceId})}),c.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>$x(null),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsxs("div",{className:"af-tool-print-toast__body",children:[c.jsx("pre",{children:as.content.length>500?as.content.slice(0,500):as.content}),as.content.length>500&&c.jsx("span",{className:"af-tool-print-toast__more",children:e("flow:toolPrint.truncated")})]})]}),ls&&c.jsx("div",{className:"af-provide-edit-overlay",children:c.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-provide-edit-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),c.jsx("span",{className:"af-provide-edit-modal__title",children:ls.label}),c.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>ru(null),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-provide-edit-modal__body",children:c.jsx("textarea",{ref:bp,className:"af-provide-edit-modal__textarea",defaultValue:ls.content,autoFocus:!0})}),c.jsxs("div",{className:"af-provide-edit-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:GP,children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>ru(null),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),xp&&c.jsx("div",{className:"af-run-params-overlay",children:c.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-run-params-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),c.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),c.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Zo(!1),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-run-params-modal__body",children:er.length===0?c.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):c.jsx("div",{className:"af-run-params-list",children:er.map(b=>{var Z,te;const j=cs[b.id];if(!j)return null;const W=(((Z=b.data)==null?void 0:Z.definitionId)||"").startsWith("provide_file"),K=((te=b.data)==null?void 0:te.label)||b.id,Y=Gc[j]??"";return c.jsxs("div",{className:"af-run-params-item",children:[c.jsxs("div",{className:"af-run-params-item__head",children:[c.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(W?" af-run-params-item__icon--file":""),children:W?"description":"text_fields"}),c.jsx("span",{className:"af-run-params-item__label",children:K}),c.jsx("span",{className:"af-run-params-item__slot",children:j})]}),c.jsx("input",{type:"text",className:"af-run-params-item__input",value:Y,onChange:se=>Xc(oe=>({...oe,[j]:se.target.value})),placeholder:e(W?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},b.id)})})}),c.jsxs("div",{className:"af-run-params-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var j;const b={};for(const z of er){const W=cs[z.id];if(!W)continue;const K=((j=z.data)==null?void 0:j.definitionId)||"",Y=Gc[W]??"";K.startsWith("provide_file")?b[W]={type:"file",path:Y}:b[W]={type:"str",value:Y}}Zo(!1),yi(!1),Pr({cliInputsOverride:b})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),c.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Zo(!1),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})})}const je=e=>typeof e=="string",fl=()=>{let e,t;const n=new Promise((r,i)=>{e=r,t=i});return n.resolve=e,n.reject=t,n},p1=e=>e==null?"":""+e,Q6=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},J6=/###/g,h1=e=>e&&e.indexOf("###")>-1?e.replace(J6,"."):e,m1=e=>!e||je(e),$l=(e,t,n)=>{const r=je(t)?t.split("."):t;let i=0;for(;i<r.length-1;){if(m1(e))return{};const o=h1(r[i]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++i}return m1(e)?{}:{obj:e,k:h1(r[i])}},g1=(e,t,n)=>{const{obj:r,k:i}=$l(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let o=t[t.length-1],s=t.slice(0,t.length-1),a=$l(e,s,Object);for(;a.obj===void 0&&s.length;)o=`${s[s.length-1]}.${o}`,s=s.slice(0,s.length-1),a=$l(e,s,Object),a&&a.obj&&typeof a.obj[`${a.k}.${o}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${o}`]=n},Z6=(e,t,n,r)=>{const{obj:i,k:o}=$l(e,t,Object);i[o]=i[o]||[],i[o].push(n)},bf=(e,t)=>{const{obj:n,k:r}=$l(e,t);if(n)return n[r]},e9=(e,t,n)=>{const r=bf(e,n);return r!==void 0?r:bf(t,n)},tP=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?je(e[r])||e[r]instanceof String||je(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):tP(e[r],t[r],n):e[r]=t[r]);return e},ys=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var t9={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const n9=e=>je(e)?e.replace(/[&<>"'\/]/g,t=>t9[t]):e;class r9{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 i9=[" ",",","?","!",";"],o9=new r9(20),s9=(e,t,n)=>{t=t||"",n=n||"";const r=i9.filter(s=>t.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=o9.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let o=!i.test(e);if(!o){const s=e.indexOf(n);s>0&&!i.test(e.substring(0,s))&&(o=!0)}return o},zg=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 i=e;for(let o=0;o<r.length;){if(!i||typeof i!="object")return;let s,a="";for(let l=o;l<r.length;++l)if(l!==o&&(a+=n),a+=r[l],s=i[a],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&l<r.length-1)continue;o+=l-o+1;break}i=s}return i},Sf=e=>e&&e.replace("_","-"),a9={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 kf{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||a9,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,i){return i&&!this.debug?null:(je(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new kf(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new kf(this.logger,t)}}var Dr=new kf;class up{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(s=>{let[a,l]=s;for(let u=0;u<l;u++)a(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(s=>{let[a,l]=s;for(let u=0;u<l;u++)a.apply(a,[t,...r])})}}class y1 extends up{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 i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;t.indexOf(".")>-1?a=t.split("."):(a=[t,n],r&&(Array.isArray(r)?a.push(...r):je(r)&&o?a.push(...r.split(o)):a.push(r)));const l=bf(this.data,a);return!l&&!n&&!r&&t.indexOf(".")>-1&&(t=a[0],n=a[1],r=a.slice(2).join(".")),l||!s||!je(r)?l:zg(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const s=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let a=[t,n];r&&(a=a.concat(s?r.split(s):r)),t.indexOf(".")>-1&&(a=t.split("."),i=n,n=a[1]),this.addNamespaces(n),g1(this.data,a,i),o.silent||this.emit("added",t,n,r,i)}addResources(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(je(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});i.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,i,o){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},a=[t,n];t.indexOf(".")>-1&&(a=t.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let l=bf(this.data,a)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?tP(l,r,o):l={...l,...r},g1(this.data,a,l),s.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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var nP={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,i))}),t}};const x1={};class Nf extends up{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Q6(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Dr.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 i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const s=r&&t.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!s9(t,r,i);if(s&&!a){const l=t.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:t,namespaces:je(o)?[o]:o};const u=t.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(i)}return{key:t,namespaces:je(o)?[o]:o}}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 i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:s,namespaces:a}=this.extractFromKey(t[t.length-1],n),l=a[a.length-1],u=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(f){const N=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${N}${s}`,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${N}${s}`}return i?{res:s,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:s}const d=this.resolve(t,n);let p=d&&d.res;const h=d&&d.usedKey||s,m=d&&d.exactUsedKey||s,v=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,y=!je(p)&&typeof p!="boolean"&&typeof p!="number";if(w&&p&&y&&k.indexOf(v)<0&&!(je(g)&&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:a}):`key '${s} (${this.language})' returned an object instead of string.`;return i?(d.res=N,d.usedParams=this.getUsedParamsDetails(n),d):N}if(o){const N=Array.isArray(p),E=N?[]:{},S=N?m:h;for(const P in p)if(Object.prototype.hasOwnProperty.call(p,P)){const T=`${S}${o}${P}`;E[P]=this.translate(T,{...n,joinArrays:!1,ns:a}),E[P]===T&&(E[P]=p[P])}p=E}}else if(w&&je(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let N=!1,E=!1;const S=n.count!==void 0&&!je(n.count),P=Nf.hasDefaultValue(n),T=S?this.pluralResolver.getSuffix(u,n.count,n):"",M=n.ordinal&&S?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",B=S&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),A=B&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${T}`]||n[`defaultValue${M}`]||n.defaultValue;!this.isValidLookup(p)&&P&&(N=!0,p=A),this.isValidLookup(p)||(E=!0,p=s);const V=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:p,L=P&&A!==p&&this.options.updateMissing;if(E||N||L){if(this.logger.log(L?"updateKey":"missingKey",u,l,s,L?A:p),o){const _=this.resolve(s,{...n,keySeparator:!1});_&&_.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 H=[];const D=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&D&&D[0])for(let _=0;_<D.length;_++)H.push(D[_]);else this.options.saveMissingTo==="all"?H=this.languageUtils.toResolveHierarchy(n.lng||this.language):H.push(n.lng||this.language);const $=(_,I,C)=>{const F=P&&C!==p?C:V;this.options.missingKeyHandler?this.options.missingKeyHandler(_,l,I,F,L,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,l,I,F,L,n),this.emit("missingKey",_,l,I,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&S?H.forEach(_=>{const I=this.pluralResolver.getSuffixes(_,n);B&&n[`defaultValue${this.options.pluralSeparator}zero`]&&I.indexOf(`${this.options.pluralSeparator}zero`)<0&&I.push(`${this.options.pluralSeparator}zero`),I.forEach(C=>{$([_],s+C,n[`defaultValue${C}`]||A)})}):$(H,s,A))}p=this.extendTranslation(p,t,n,d,r),E&&p===s&&this.options.appendNamespaceToMissingKey&&(p=`${l}:${s}`),(E||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${s}`:s,N?p:void 0):p=this.options.parseMissingKeyHandler(p))}return i?(d.res=p,d.usedParams=this.getUsedParamsDetails(n),d):p}extendTranslation(t,n,r,i,o){var s=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=je(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(u){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let d=r.replace&&!je(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),t=this.interpolator.interpolate(t,d,r.lng||this.language||i.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;f<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),m=0;m<p;m++)h[m]=arguments[m];return o&&o[0]===h[0]&&!r.context?(s.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):s.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,l=je(a)?[a]:a;return t!=null&&l&&l.length&&r.applyPostProcessor!==!1&&(t=nP.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,o,s,a;return je(t)&&(t=[t]),t.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),f=u.key;i=f;let d=u.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const p=n.count!==void 0&&!je(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),m=n.context!==void 0&&(je(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(k=>{this.isValidLookup(r)||(a=k,!x1[`${v[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(a)&&(x1[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${a}" 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(g=>{if(this.isValidLookup(r))return;s=g;const w=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,g,k,n);else{let N;p&&(N=this.pluralResolver.getSuffix(g,n.count,n));const E=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(w.push(f+N),n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),h&&w.push(f+E)),m){const P=`${f}${this.options.contextSeparator}${n.context}`;w.push(P),p&&(w.push(P+N),n.ordinal&&N.indexOf(S)===0&&w.push(P+N.replace(S,this.options.pluralSeparator)),h&&w.push(P+E))}}let y;for(;y=w.pop();)this.isValidLookup(r)||(o=y,r=this.getResource(g,k,y,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:s,usedNS:a}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,i):this.resourceStore.getResource(t,n,r,i)}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&&!je(t.replace);let i=r?t.replace:t;if(r&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const o of n)delete i[o]}return i}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 Qh=e=>e.charAt(0).toUpperCase()+e.slice(1);class w1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Dr.create("languageUtils")}getScriptPartFromCode(t){if(t=Sf(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=Sf(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(je(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let i=Intl.getCanonicalLocales(t)[0];if(i&&this.options.lowerCaseLng&&(i=i.toLowerCase()),i)return i}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Qh(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]=Qh(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Qh(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 i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),je(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),i=[],o=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return je(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):je(t)&&o(this.formatLanguageCode(t)),r.forEach(s=>{i.indexOf(s)<0&&o(this.formatLanguageCode(s))}),i}}let l9=[{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}],c9={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 u9=["v1","v2","v3"],d9=["v4"],v1={zero:0,one:1,two:2,few:3,many:4,other:5},f9=()=>{const e={};return l9.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:c9[t.fc]}})}),e};class p9{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Dr.create("pluralResolver"),(!this.options.compatibilityJSON||d9.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=f9(),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=Sf(t==="dev"?"en":t),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!t.match(/-|_/))return;const l=this.languageUtils.getLanguagePartFromCode(t);s=this.getRule(l,n)}return this.pluralRulesCache[o]=s,s}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(i=>`${n}${i}`)}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((i,o)=>v1[i]-v1[o]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(t,i,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,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 i=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const o=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!u9.includes(this.options.compatibilityJSON)}}const b1=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=e9(e,t,n);return!o&&i&&je(n)&&(o=zg(e,n,r),o===void 0&&(o=zg(t,n,r))),o},Jh=e=>e.replace(/\$/g,"$$$$");class h9{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Dr.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:i,prefix:o,prefixEscaped:s,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:d,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:m,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:g,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:n9,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?ys(o):s||"{{",this.suffix=a?ys(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?ys(p):h||ys("$t("),this.nestingSuffix=m?ys(m):v||ys(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=g||1e3,this.alwaysFormat=w!==void 0?w:!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,i){let o,s,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=b1(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...i,...n,interpolationkey:h}):g}const m=h.split(this.formatSeparator),v=m.shift().trim(),k=m.join(this.formatSeparator).trim();return this.format(b1(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const f=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Jh(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Jh(this.escape(h)):Jh(h)}].forEach(h=>{for(a=0;o=h.regex.exec(t);){const m=o[1].trim();if(s=u(m),s===void 0)if(typeof f=="function"){const k=f(t,o,i);s=je(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,m))s="";else if(d){s=o[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${t}`),s="";else!je(s)&&!this.useRawValueToEscape&&(s=p1(s));const v=h.safeValue(s);if(t=t.replace(o[0],v),d?(h.regex.lastIndex+=s.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,o,s;const a=(l,u)=>{const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const d=l.split(new RegExp(`${f}[ ]*{`));let p=`{${d[1]}`;l=d[0],p=this.interpolate(p,s);const h=p.match(/'/g),m=p.match(/"/g);(h&&h.length%2===0&&!m||m.length%2!==0)&&(p=p.replace(/'/g,'"'));try{s=JSON.parse(p),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,v),`${l}${f}${p}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,l};for(;i=this.nestingRegexp.exec(t);){let l=[];s={...r},s=s.replace&&!je(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const f=i[1].split(this.formatSeparator).map(d=>d.trim());i[1]=f.shift(),l=f,u=!0}if(o=n(a.call(this,i[1].trim(),s),s),o&&i[0]===t&&!je(o))return o;je(o)||(o=p1(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),o=""),u&&(o=l.reduce((f,d)=>this.format(f,d,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),t=t.replace(i[0],o),this.regexp.lastIndex=0}return t}}const m9=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);t==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[a,...l]=s.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=a.trim();n[f]||(n[f]=u),u==="false"&&(n[f]=!1),u==="true"&&(n[f]=!0),isNaN(u)||(n[f]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},xs=e=>{const t={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const s=r+JSON.stringify(o);let a=t[s];return a||(a=e(Sf(r),i),t[s]=a),a(n)}};class g9{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Dr.create("formatter"),this.options=t,this.formats={number:xs((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:xs((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:xs((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:xs((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:xs((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},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()]=xs(n)}format(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(a=>a.indexOf(")")>-1)){const a=o.findIndex(l=>l.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,a)].join(this.formatSeparator)}return o.reduce((a,l)=>{const{formatName:u,formatOptions:f}=m9(l);if(this.formats[u]){let d=a;try{const p=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},h=p.locale||p.lng||i.locale||i.lng||r;d=this.formats[u](a,h,{...f,...i,...p})}catch(p){this.logger.warn(p)}return d}else this.logger.warn(`there was no format function for ${u}`);return a},t)}}const y9=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class x9 extends up{constructor(t,n,r){let i=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=i,this.logger=Dr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(t,n,r,i){const o={},s={},a={},l={};return t.forEach(u=>{let f=!0;n.forEach(d=>{const p=`${u}|${d}`;!r.reload&&this.store.hasResourceBundle(u,d)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?s[p]===void 0&&(s[p]=!0):(this.state[p]=1,f=!1,s[p]===void 0&&(s[p]=!0),o[p]===void 0&&(o[p]=!0),l[d]===void 0&&(l[d]=!0)))}),f||(a[u]=!0)}),(Object.keys(o).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(s),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(t,n,r){const i=t.split("|"),o=i[0],s=i[1];n&&this.emit("failedLoading",o,s,n),!n&&r&&this.store.addResourceBundle(o,s,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const a={};this.queue.forEach(l=>{Z6(l.loaded,[o],s),y9(l,t),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const f=l.loaded[u];f.length&&f.forEach(d=>{a[u][d]===void 0&&(a[u][d]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;if(!t.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:i,wait:o,callback:s});return}this.readingCalls++;const a=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,i+1,o*2,s)},o);return}s(u,f)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(t,n);u&&typeof u.then=="function"?u.then(f=>a(null,f)).catch(a):a(null,u)}catch(u){a(u)}return}return l(t,n,a)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=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."),i&&i();je(t)&&(t=this.languageUtils.toResolveHierarchy(t)),je(n)&&(n=[n]);const o=this.queueLoad(t,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(s=>{this.loadOne(s)})}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("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(s,a)=>{s&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,s),!s&&a&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,a),this.loaded(t,s,a)})}saveMissing(t,n,r,i,o){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},a=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 l={...s,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let f;u.length===5?f=u(t,n,r,i,l):f=u(t,n,r,i),f&&typeof f.then=="function"?f.then(d=>a(null,d)).catch(a):a(null,f)}catch(f){a(f)}else u(t,n,r,i,a,l)}!t||!t[0]||this.store.addResource(t[0],n,r,i)}}}const S1=()=>({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]),je(e[1])&&(t.defaultValue=e[1]),je(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}}),k1=e=>(je(e.ns)&&(e.ns=[e.ns]),je(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),je(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),id=()=>{},w9=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class wc extends up{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=k1(t),this.services={},this.logger=Dr,this.modules={external:[]},w9(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&&(je(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=S1();this.options={...i,...this.options,...k1(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?Dr.init(o(this.modules.logger),this.options):Dr.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=g9);const d=new w1(this.options);this.store=new y1(this.options.resources,this.options);const p=this.services;p.logger=Dr,p.resourceStore=this.store,p.languageUtils=d,p.pluralResolver=new p9(d,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(p.formatter=o(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new h9(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new x9(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var m=arguments.length,v=new Array(m>1?m-1:0),k=1;k<m;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=o(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=o(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Nf(this.services,this.options),this.translator.on("*",function(h){for(var m=arguments.length,v=new Array(m>1?m-1:0),k=1;k<m;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=id),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 l=fl(),u=()=>{const f=(d,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),l.resolve(p),r(d,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?u():setTimeout(u,0),l}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:id;const i=je(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],s=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload&&this.options.preload.forEach(a=>s(a)),this.services.backendConnector.load(o,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(t,n,r){const i=fl();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=id),this.services.backendConnector.reload(t,n,o=>{i.resolve(),r(o)}),i}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"&&nP.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 i=fl();this.emit("languageChanging",t);const o=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(l,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},a=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const u=je(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,f=>{s(f,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t),i}getFixedT(t,n,r){var i=this;const o=function(s,a){let l;if(typeof a!="object"){for(var u=arguments.length,f=new Array(u>2?u-2:0),d=2;d<u;d++)f[d-2]=arguments[d];l=i.options.overloadTranslationOptionHandler([s,a].concat(f))}else l={...a};l.lng=l.lng||o.lng,l.lngs=l.lngs||o.lngs,l.ns=l.ns||o.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||o.keyPrefix);const p=i.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(s)?h=s.map(m=>`${l.keyPrefix}${p}${m}`):h=l.keyPrefix?`${l.keyPrefix}${p}${s}`:s,i.t(h,l)};return je(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}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],i=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const a=n.precheck(this,s);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,t)&&(!i||s(o,t)))}loadNamespaces(t,n){const r=fl();return this.options.ns?(je(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=fl();je(t)&&(t=[t]);const i=this.options.preload||[],o=t.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return o.length?(this.options.preload=i.concat(o),this.loadResources(s=>{r.resolve(),n&&n(s)}),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 w1(S1());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 wc(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:id;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},o=new wc(i);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(a=>{o[a]=this[a]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new y1(this.store.data,i),o.services.resourceStore=o.store),o.translator=new Nf(o.services,i),o.translator.on("*",function(a){for(var l=arguments.length,u=new Array(l>1?l-1:0),f=1;f<l;f++)u[f-1]=arguments[f];o.emit(a,...u)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ut=wc.createInstance();Ut.createInstance=wc.createInstance;Ut.createInstance;Ut.dir;Ut.init;Ut.loadResources;Ut.reloadResources;Ut.use;Ut.changeLanguage;Ut.getFixedT;Ut.t;Ut.exists;Ut.setDefaultNamespace;Ut.hasLoadedNamespace;Ut.loadNamespaces;Ut.loadLanguages;function v9(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vc(e){"@babel/helpers - typeof";return vc=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},vc(e)}function b9(e,t){if(vc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(vc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function S9(e){var t=b9(e,"string");return vc(t)=="symbol"?t:t+""}function k9(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,S9(r.key),r)}}function N9(e,t,n){return t&&k9(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var rP=[],C9=rP.forEach,E9=rP.slice;function j9(e){return C9.call(E9.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var N1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,P9=function(t,n,r){var i=r||{};i.path=i.path||"/";var o=encodeURIComponent(n),s="".concat(t,"=").concat(o);if(i.maxAge>0){var a=i.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+="; Max-Age=".concat(Math.floor(a))}if(i.domain){if(!N1.test(i.domain))throw new TypeError("option domain is invalid");s+="; Domain=".concat(i.domain)}if(i.path){if(!N1.test(i.path))throw new TypeError("option path is invalid");s+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return s},C1={create:function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),i&&(o.domain=i),document.cookie=P9(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),i=0;i<r.length;i++){for(var o=r[i];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},_9={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=C1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&C1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},I9={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 i=r.substring(1),o=i.split("&"),s=0;s<o.length;s++){var a=o[s].indexOf("=");if(a>0){var l=o[s].substring(0,a);l===t.lookupQuerystring&&(n=o[s].substring(a+1))}}}return n}},pl=null,E1=function(){if(pl!==null)return pl;try{pl=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pl=!1}return pl},A9={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&E1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&E1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},hl=null,j1=function(){if(hl!==null)return hl;try{hl=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{hl=!1}return hl},T9={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&j1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&j1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},R9={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}},L9={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}},O9={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}},M9={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]}},iP=!1;try{document.cookie,iP=!0}catch{}var oP=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];iP||oP.splice(1,1);function D9(){return{order:oP,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var sP=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};v9(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return N9(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=j9(r,this.options||{},D9()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(_9),this.addDetector(I9),this.addDetector(A9),this.addDetector(T9),this.addDetector(R9),this.addDetector(L9),this.addDetector(O9),this.addDetector(M9)}},{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 i=[];return n.forEach(function(o){if(r.detectors[o]){var s=r.detectors[o].lookup(r.options);s&&typeof s=="string"&&(s=[s]),s&&(i=i.concat(s))}}),i=i.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){i.detectors[o]&&i.detectors[o].cacheUserLanguage(n,i.options)}))}}])}();sP.type="languageDetector";const F9={name:"AgentFlow",tagline:"AI Workflow Orchestration"},$9={projects:"Projects",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},z9={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"},B9={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},H9={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},U9={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},V9={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},W9={app:F9,nav:$9,common:z9,status:B9,nodeTypes:H9,engine:U9,links:V9},K9="Flow Editor",Y9="Nodes",q9="Edges",G9="Properties",X9={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"},Q9={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",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:"Instance 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}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${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"},J9={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},Z9={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},eU={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"},tU={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)"},nU={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},rU={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},iU={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},oU={node:"Node",text:"Text",file:"File",bool:"Boolean"},sU={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"},aU={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",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",selectAll:"Select all nodes"},lU={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},cU={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."},uU={mainNav:"Main Navigation"},dU={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'},fU={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):
129
+ `);Er(Ge=>[...Ge,{kind:"assistant",text:e("flow:composer.taskPlan",{count:pe.steps.length,summary:Xe})}])}if(pe.type==="step-start"){const Xe=pe.index??0,Ge=pe.total??0,fn=pe.tier?` [${pe.tier}]`:"",j_=pe.model?` (${pe.model})`:"";Cr(e("flow:composer.step",{current:Xe+1,total:Ge,description:(pe.description||"")+fn+j_})),Ua(P_=>P_.map(ds=>ds.index===Xe?{...ds,status:"running",model:pe.model,tier:pe.tier,nodeRole:pe.nodeRole??ds.nodeRole,instanceId:pe.instanceId??ds.instanceId,instanceLabel:pe.instanceLabel??ds.instanceLabel}:ds))}if(pe.type==="step-progress"){const Xe=pe.index??0,Ge=pe.total??0;Cr(e("flow:composer.step",{current:Xe+1,total:Ge,description:pe.description||""}))}if(pe.type==="step-done"){const Xe=pe.index??0;Ua(Ge=>Ge.map(fn=>fn.index===Xe?{...fn,status:pe.success?"done":"error"}:fn))}if(pe.type==="phase-plan"&&Array.isArray(pe.phases)){Va(Ge=>({...Ge||{},phases:pe.phases,currentPhase:pe.currentPhase??0,phaseTotal:pe.phaseTotal??pe.phases.length,phaseName:pe.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(Ge==null?void 0:Ge.userPromptOriginal)||W}));const Xe=pe.phases.map((Ge,fn)=>`${fn+1}. ${Ge.label}`).join(" → ");Er(Ge=>[...Ge,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:pe.phases.length,labels:Xe,current:pe.phaseName||""})}])}pe.type==="phase-complete"&&(Va(Xe=>{var fn;return{...Xe||{},phases:pe.phases||(Xe==null?void 0:Xe.phases)||[],currentPhase:pe.phaseIndex??0,phaseTotal:pe.phaseTotal??((fn=pe.phases)==null?void 0:fn.length)??0,phaseName:pe.phaseName||"",isLastPhase:!!pe.isLastPhase,nextPhase:pe.nextPhase||null,userPromptOriginal:pe.userPromptOriginal||(Xe==null?void 0:Xe.userPromptOriginal)||W}}),!pe.isLastPhase&&pe.nextPhase&&Er(Xe=>[...Xe,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:pe.phaseName||e("flow:composer.nextPhase"),nextPhase:pe.nextPhase.label})}])),pe.type==="done"&&(We=!0,Cr(Xe=>Xe||e("flow:composer.done")))}}}catch(it){const Hn=it;if(Hn.name==="AbortError"){const Yt=e(oe?"flow:composer.connectTimeout":"flow:composer.aborted");Cr(Yt),Er(us=>[...us,{kind:"error",text:Yt}])}else{const Yt=Hn.code||Hn.name||"UNKNOWN",us=`${Hn.message||String(it)} [${Yt}]`;Cr(us),Er(vo=>[...vo,{kind:"error",text:us}])}}finally{Ap.current=!1,Yx(!1),fu.current=null,Ip.current=null,oe&&clearTimeout(oe),We&&Ve&&Cn({id:Ve.id,source:Ve.source??"user",archived:Ve.archived},{preserveComposer:!0,incrementalSync:!0})}},[a,zn,go,_e,Su,Cn,Ha,Kt,Ae,jp]);UP.current=wo;const aw=x.useCallback(()=>{!Ae||Ae.isLastPhase||(Va(null),wo(e("flow:composer.skipRemainingPhases")))},[Ae,wo]),lw=x.useCallback(()=>{if(!Ae||Ae.isLastPhase||!Ae.nextPhase)return;const b=String(Ae.nextPhase.label||"").trim()||e("flow:composer.nextPhase");wo(e("flow:composer.continuePhase",{label:b}),{phaseContextSnapshot:Ae})},[Ae,wo]);x.useEffect(()=>{if(!_p)return;const b=j=>{j.key==="Escape"&&du(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[_p]),x.useEffect(()=>{he!=="edit"&&du(!1)},[he]),x.useLayoutEffect(()=>{const b=Np.current;if(!b)return;if(!a){b.style.height="";return}b.style.height="0px";const j=getComputedStyle(b),z=parseFloat(j.lineHeight),W=(parseFloat(j.paddingTop)||0)+(parseFloat(j.paddingBottom)||0),K=Number.isFinite(z)&&z>0?z:13*1.45,Y=W+K*2,Z=W+K*10,te=Math.min(Math.max(b.scrollHeight,Y),Z);b.style.height=`${te}px`},[zn,a]);const zp=x.useCallback(b=>{const j=zn,z=iu,W=a1(j,z);if(!W)return;const K=j.slice(0,W.atIndex)+`@${b} `+j.slice(z);La(K);const Y=W.atIndex+b.length+2;queueMicrotask(()=>{const Z=Np.current;Z&&(Z.focus(),Z.setSelectionRange(Y,Y)),Oa(Y)})},[zn,iu]),Bp=x.useCallback(b=>{La(j=>{const z=`@${b}`,W=j.indexOf(z);return W<0?j:j.slice(0,W)+j.slice(W+z.length)})},[]),cw=x.useCallback(b=>{b.kind==="canvas"?Ue(j=>j.map(z=>z.id===b.node.id?{...z,selected:!1}:z)):b.kind==="mention"?Bp(b.node.id):Bp(b.definition.id)},[Ue,Bp]),k_=x.useCallback(()=>{le(b=>b==="history"?null:"history")},[]),N_=x.useCallback(()=>{le(b=>b==="settings"?null:"settings")},[]),C_=x.useCallback(()=>{le(b=>b==="composer"?null:"composer")},[]),Hp=x.useCallback(()=>{le(b=>(b==="node"&&$a.current&&(Cp.current=$a.current.id),null))},[]),uw=x.useCallback(()=>{Fa(b=>!b)},[]),E_=a?Gh(a):"";return c.jsx(gE,{children:c.jsxs(Jj.Provider,{value:{modelLists:_e,onModelChange:d_},children:[c.jsxs("div",{className:"af-pipeline-page"+(he!=="edit"?" af-pipeline-page--run-mode":""),children:[c.jsxs("header",{className:"af-pipeline-top",children:[c.jsxs("div",{className:"af-pipeline-top-left",children:[c.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{he==="running"?bu(!0):he!=="edit"?xo():t("/projects")},"aria-label":e(he!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(he!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:c.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),c.jsxs("div",{className:"af-pipeline-brand",children:[c.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),c.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",E8,"-STABLE"]})]}),c.jsxs("div",{className:"af-pipeline-flow-pick",children:[c.jsx("label",{className:"af-visually-hidden",htmlFor:"af-flow-select",children:e("flow:topbar.currentPipeline")}),c.jsx("select",{id:"af-flow-select",className:"af-pipeline-flow-select",value:E_,onChange:b=>{const j=b.target.value;if(!j)return;const z=j.split("\0"),W=z[0],K=z[1]||"user",Y=z[2]==="1",Z=r.find(te=>te.id===W&&(te.source??"user")===K&&!!te.archived===Y);Z&&Cn(Z)},disabled:r.length===0,children:r.length===0?c.jsx("option",{value:"",children:e("flow:palette.loading")}):c.jsxs(c.Fragment,{children:[a?null:c.jsx("option",{value:"",children:e("flow:pipeline.selectPipeline")}),r.map(b=>c.jsxs("option",{value:Gh(b),children:[b.id," (",Xh(b.source??"user",e),")",b.archived?` · ${e("flow:palette.archived")}`:""]},Gh(b)))]})})]})]}),c.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[gp&&c.jsx("button",{type:"button",className:"af-icon-btn"+(Vc?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Wc(b=>!b),children:c.jsx("span",{className:"material-symbols-outlined",children:"description"})}),he==="running"&&c.jsxs("div",{className:"af-run-timer",children:[c.jsx("span",{className:"af-run-timer__dot"}),c.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,"running")})]}),he==="stopped"&&c.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[c.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,"stopped")})]}),(he==="done"||he==="error")&&c.jsxs("div",{className:"af-run-timer"+(he==="error"?" af-run-timer--error":" af-run-timer--done"),children:[c.jsx("span",{className:"af-run-timer__label",children:he==="error"?"FAILED":"COMPLETED"}),c.jsx("span",{className:"af-run-timer__value",children:Kh(Jn,he)})]}),he!=="edit"&&c.jsx("button",{type:"button",className:"af-icon-btn"+(cn?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Ft(b=>!b),children:c.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),he==="edit"&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-icon-btn"+(J==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!a,onClick:k_,children:c.jsx("span",{className:"material-symbols-outlined",children:"history"})}),c.jsx("button",{type:"button",className:"af-icon-btn"+(J==="settings"?" af-icon-btn--active":""),onClick:N_,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!a,children:c.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),c.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(J==="composer"?" af-composer-topbar-btn--active":"")+(vt?" af-composer-topbar-btn--running":""),onClick:C_,"aria-label":"AI Composer",title:"AI Composer",disabled:!a,children:"AI"}),c.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(ou?" af-icon-btn--active":""),onClick:uw,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!a,children:c.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),c.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!a||a.source==="builtin"||a.source!=="user"&&a.source!=="workspace",onClick:()=>D(!0),children:c.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),c.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!a||a.source==="builtin"||a.archived||a.source!=="user"&&a.source!=="workspace",onClick:()=>L(!0),children:"Archive"})]}),he==="running"?c.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:y_,title:e("flow:run.pauseRun"),children:[c.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):he==="ready"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):he==="stopped"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr({runUuid:ft}),title:ft?e("flow:topbar.resumeTitle",{uuid:ft}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):he==="done"||he==="error"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!a,onClick:()=>void Pr(),title:e("flow:topbar.rerunTitle"),children:"Run"}),c.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:xo,children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):c.jsxs("div",{className:"af-run-btn-group",children:[c.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!a,onClick:()=>void Pr(),children:"Run"}),c.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!a,onClick:()=>yi(b=>!b),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":qc,children:c.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),qc&&a&&c.jsxs("div",{className:"af-run-dropdown-menu",children:[c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var j,z,W,K,Y;yi(!1);const b={};for(const Z of er){const te=cs[Z.id];te&&(b[te]=((j=co[te])==null?void 0:j.value)??((z=co[te])==null?void 0:z.path)??((Y=(K=(W=Z.data)==null?void 0:W.outputs)==null?void 0:K[0])==null?void 0:Y.default)??"")}Xc(b),Zo(!0)},children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{yi(!1),Pr({prepareOnly:!0})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),c.jsx("div",{className:"af-run-dropdown-divider"}),c.jsxs("div",{className:"af-run-dropdown-section",children:[c.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{yi(!1),Pr()},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(xi).map(b=>c.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var W;yi(!1);const j=xi[b]||{},z={};for(const K of er){const Y=cs[K.id];if(!Y)continue;const Z=((W=K.data)==null?void 0:W.definitionId)||"",te=j[K.id]??"";Z.startsWith("provide_file")?z[Y]={type:"file",path:te}:z[Y]={type:"str",value:te}}Pr({cliInputsOverride:z})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),b]},b))]})]})]})]})]}),c.jsxs("div",{className:"af-pipeline-body"+(he!=="edit"?" af-pipeline-body--run-mode":""),children:[he==="edit"?c.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[c.jsxs("div",{className:`af-palette-workspace${Le?" af-palette-workspace--expanded":""}`,children:[c.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>mt(b=>!b),"aria-expanded":Le,children:[c.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),c.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),c.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Le?"expand_less":"expand_more"})]}),c.jsx("div",{className:"af-palette-workspace-path",title:a!=null&&a.path?s1(a.path):"",children:a!=null&&a.path?s1(a.path):e("flow:palette2.noPipelineSelected")}),Le&&c.jsx("div",{className:"af-palette-workspace-tree",children:Fn?c.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):_t.error?c.jsx("div",{className:"af-palette-workspace-empty",children:_t.error}):a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-palette-workspace-group",children:[c.jsxs("div",{className:"af-palette-workspace-group-head",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),c.jsx("span",{children:a.id}),c.jsxs("span",{className:"af-palette-workspace-count",children:["(",_t.files.length,")"]})]}),_t.files.length>0?c.jsx("ul",{className:"af-palette-workspace-list",children:_t.files.filter(b=>b.type==="file").map(b=>c.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:b.path,onClick:()=>_({filePath:b.path,fileName:b.name}),children:[c.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:b.icon}),c.jsx("span",{className:"af-palette-workspace-item-label",children:b.name}),b.size!=null&&c.jsx("span",{className:"af-palette-workspace-item-size",children:b.size<1024?`${b.size}B`:b.size<1024*1024?`${(b.size/1024).toFixed(1)}KB`:`${(b.size/1024/1024).toFixed(1)}MB`})]},b.path))}):_t.files.filter(b=>b.type==="directory").length===0?c.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),_t.files.filter(b=>{var j;return b.type==="directory"&&((j=b.children)==null?void 0:j.length)>0}).map(b=>c.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[c.jsxs("div",{className:"af-palette-workspace-group-head",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:b.icon}),c.jsxs("span",{children:[b.name,"/"]}),c.jsxs("span",{className:"af-palette-workspace-count",children:["(",b.children.length,")"]})]}),c.jsx("ul",{className:"af-palette-workspace-list",children:b.children.map(j=>c.jsxs("li",{className:`af-palette-workspace-item${j.type==="file"?" af-palette-workspace-item--clickable":""}`,title:j.path,onClick:j.type==="file"?()=>_({filePath:j.path,fileName:j.name}):void 0,children:[c.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:j.icon}),c.jsx("span",{className:"af-palette-workspace-item-label",children:j.name}),j.type==="file"&&j.size!=null&&c.jsx("span",{className:"af-palette-workspace-item-size",children:j.size<1024?`${j.size}B`:j.size<1024*1024?`${(j.size/1024).toFixed(1)}KB`:`${(j.size/1024/1024).toFixed(1)}MB`})]},j.path))})]},b.path))]}):c.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),c.jsxs("div",{className:"af-node-palette-head",children:[c.jsx("h2",{className:"af-node-palette-title",children:"Node Palette"}),c.jsxs("label",{className:"af-palette-search-wrap",children:[c.jsx("span",{className:"af-visually-hidden",children:e("flow:palette.searchNodes")}),c.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),c.jsx("input",{type:"search",className:"af-palette-search-input",value:ne,onChange:b=>ae(b.target.value),placeholder:e("flow:palette.searchNodes")+"…","aria-label":e("flow:palette.searchNodes")})]})]}),o?c.jsx("p",{className:"af-err af-palette-list-err",children:o}):null,c.jsxs("div",{className:"af-node-palette-scroll",children:[td.filter(b=>mu[b].length>0).map(b=>c.jsxs("section",{className:`af-palette-section af-flow-palette-section--${b}`,children:[c.jsx("h3",{className:"af-palette-cat",children:b}),c.jsx("div",{className:"af-palette-cards",children:mu[b].map(j=>c.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>s_(j),draggable:!!a,onDragStart:z=>{z.dataTransfer.setData("application/agentflow-node",j.id),z.dataTransfer.effectAllowed="move"},disabled:!a,title:j.description||j.id,children:[c.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:c.jsx("span",{className:"material-symbols-outlined",children:I8(b)})}),c.jsx("span",{className:"af-palette-card-label",children:j.id})]},j.id))})]},b)),a&&q.length===0?c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,a&&q.length>0&&ne.trim()&&QP===0?c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,a?null:c.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]}),c.jsxs("footer",{className:"af-palette-engine",children:[c.jsxs("div",{className:"af-palette-engine-head",children:[c.jsx("span",{className:"af-palette-engine-dot"+(vr?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),c.jsx("span",{className:"af-palette-engine-label",children:e(vr?"common:engine.online":"common:engine.offline")})]}),v?c.jsx("div",{className:"af-palette-tip"+JP,role:"status","aria-live":"polite",children:v}):null]})]}):a?c.jsx(w8,{flowId:a.id,flowSource:a.source||"user",flowArchived:a.archived,provideNodes:er,edges:xt,nodes:He,onCliInputsChange:Kc,onBackToEdit:xo}):null,c.jsxs("div",{className:"af-pipeline-main-stack",children:[c.jsxs("div",{className:"af-pipeline-canvas-col",children:[h?c.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:h}):null,a&&jr.length>0&&!I?c.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[c.jsxs("div",{className:"af-flow-slot-warnings-head",children:[c.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),c.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[c.jsx("button",{type:"button",className:"af-icon-btn",disabled:F,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void ew(),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),c.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>C(!0),children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),c.jsx("ul",{className:"af-flow-slot-warnings-list",children:jr.map(b=>c.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',c.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:b.nodeId}),onClick:j=>{j.preventDefault(),i_(b.nodeId)},children:b.nodeId}),'"',b.suffix]},b.key))})]}):null,a&&jr.length>0&&I?c.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:jr.length})}),c.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:uw,title:e("flow:validation.shortcutHint"),children:[c.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),c.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[c.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>C(!1),children:e("flow:validation.show")}),c.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:F,onClick:()=>void ew(),children:e("common:common.refresh")})]})]}):null,c.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:a?c.jsx(Y8,{fitViewEpoch:u,canvasTool:FP,nodes:YP,edges:qP,onNodesChange:he!=="edit"?void 0:WP,onEdgesChange:he!=="edit"?void 0:KP,onConnect:he!=="edit"?void 0:t_,onNodesDelete:he!=="edit"?void 0:n_,onNodeClick:ZP,onEdgeClick:e_,onFlowInit:r_,onDrop:l_,onDragOver:a_,hideMinimapAndControls:!!(a&&J),bottomSlot:he==="edit"?c.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:c.jsxs("div",{className:"af-pipeline-composer-inner",children:[c.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Su.length===0?c.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Su.map((b,j)=>{var se,oe;if(b.kind==="definition"){const me=b.definition,X=String(me.label??me.id),ue=[me.id,me.description?String(me.description).slice(0,120):""].filter(Boolean).join(" — ");return c.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:ue,children:[c.jsx("span",{className:"af-composer-node-chip-label",children:X}),c.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>cw(b),"aria-label":e("flow:composer.removeFromInput",{id:me.id}),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${me.id}`)}const z=b.node,W=b.kind,K=String(((se=z.data)==null?void 0:se.label)??z.id),Y=(oe=z.data)!=null&&oe.definitionId?String(z.data.definitionId):"",Z=Y&&Y!==K?`${K} · ${z.id} · ${Y}`:`${K} · ${z.id}`,te=W==="canvas"?e("flow:composer.deselectNode",{id:z.id}):e("flow:composer.removeFromInput",{id:z.id});return c.jsxs("div",{className:"af-composer-node-chip"+(W==="mention"?" af-composer-node-chip--mention":""),title:Z,children:[c.jsx("span",{className:"af-composer-node-chip-label",children:K}),c.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>cw(b),"aria-label":te,children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},z.id)})}),c.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[c.jsxs("div",{className:"af-composer-input-wrap",children:[c.jsx("textarea",{ref:Np,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!a,value:zn,rows:2,onChange:b=>{La(b.target.value),Oa(b.target.selectionStart??b.target.value.length)},onSelect:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??0)},onKeyDown:b=>{if((b.metaKey||b.ctrlKey)&&b.key==="Enter"){b.preventDefault(),wo();return}if(Ga&&tr.length>0&&(b.key==="ArrowDown"||b.key==="ArrowUp"||b.key==="Enter")){if(b.key==="ArrowDown")b.preventDefault(),Da(j=>(j+1)%tr.length);else if(b.key==="ArrowUp")b.preventDefault(),Da(j=>(j-1+tr.length)%tr.length);else if(b.key==="Enter"){b.preventDefault();const j=tr[Ma];j&&zp(j.id)}}},onKeyUp:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??j.value.length)},onClick:b=>{const j=b.target;j instanceof HTMLTextAreaElement&&Oa(j.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Ga&&a&&tr.length>0?c.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Xa.instances.length>0?c.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:c.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Xa.instances.map((b,j)=>{const z=j;return c.jsx("li",{role:"option","aria-selected":z===Ma,children:c.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ma?" af-composer-mention-item--active":""),onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>Da(z),onClick:()=>zp(b.id),children:[c.jsx("span",{className:"af-composer-mention-id",children:b.title}),b.subtitle?c.jsx("span",{className:"af-composer-mention-sub",children:b.subtitle}):null]})},`i-${b.id}`)}),Xa.definitions.length>0?c.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:c.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Xa.definitions.map((b,j)=>{const z=Xa.instances.length+j;return c.jsx("li",{role:"option","aria-selected":z===Ma,children:c.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ma?" af-composer-mention-item--active":""),onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>Da(z),onClick:()=>zp(b.id),children:[c.jsx("span",{className:"af-composer-mention-id",children:b.title}),b.subtitle?c.jsx("span",{className:"af-composer-mention-sub",children:b.subtitle}):null]})},`d-${b.id}`)})]}):null]}),c.jsxs("div",{className:"af-composer-toolbar",children:[Bn.length>0&&c.jsx("label",{className:"af-composer-session-field",children:c.jsxs("select",{className:"af-composer-session-select",value:Kt||"",onChange:b=>{b.target.value==="__new__"?Kx():Xx(b.target.value)},disabled:vt,"aria-label":e("flow:composer.switchConversation"),children:[Bn.map(b=>c.jsxs("option",{value:b.id,children:[b.label,b.running?" ⏳":""]},b.id)),c.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),c.jsxs("label",{className:"af-composer-model-field",children:[c.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),c.jsxs("select",{className:"af-composer-model-select",value:(go||"").trim()?dn.currentNotInLists?dn.currentNotInLists:nd(go,dn.cursorList,dn.opencodeList,dn.claudeCodeList):"",onChange:b=>Bx(b.target.value),disabled:!a||vt,"aria-label":e("flow:composer.modelAriaLabel"),children:[c.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),dn.currentNotInLists?c.jsxs("option",{value:dn.currentNotInLists,children:[dn.currentNotInLists,e("flow:composer.modelNotInList")]}):null,dn.cursorList.length>0?c.jsx("optgroup",{label:"Cursor",children:dn.cursorList.map(b=>c.jsx("option",{value:ei(b),children:b},`composer-c-${b}`))}):null,dn.opencodeList.length>0?c.jsx("optgroup",{label:"OpenCode",children:dn.opencodeList.map(b=>c.jsx("option",{value:`opencode:${ei(b)}`,children:b},`composer-o-${b}`))}):null,dn.claudeCodeList.length>0?c.jsx("optgroup",{label:"Claude Code",children:dn.claudeCodeList.map(b=>c.jsx("option",{value:`claude-code:${ei(b)}`,children:b},`composer-cc-${b}`))}):null]})]}),c.jsx("button",{type:"button",className:"af-composer-send"+(a&&zn.trim()&&!vt?" af-composer-send--active":"")+(vt?" af-composer-send--stop":""),disabled:!a||!vt&&!zn.trim(),"aria-label":e(vt?"flow:composer.stopGeneration":"flow:composer.send"),title:vt?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var b;if(vt){(b=fu.current)==null||b.abort();return}wo()},children:c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:vt?"stop":"arrow_upward"})})]})]}),_p?qi.createPortal(c.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:b=>{b.target===b.currentTarget&&du(!1)},children:c.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[c.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[c.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[c.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),c.jsx("div",{className:"af-composer-thread-dialog-status"+(vt?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:za||void 0,children:vt&&!za?e("flow:composer.executing"):za||e("flow:composer.ready")})]}),c.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>du(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ux.length>1&&!(Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1)?c.jsx("div",{className:"af-composer-steps-track-wrap",children:c.jsx(O8,{steps:Ux})}):null,Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1?c.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Ae.phases.map((b,j)=>{const z=b.status||(j<(Ae.currentPhase??0)?"done":j===(Ae.currentPhase??0)?vt?"running":Ae.nextPhase||Ae.isLastPhase?"done":"running":"pending");return c.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${b.label}${b.description?":"+b.description:""}`,children:[c.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):c.jsx("span",{children:j+1})}),c.jsx("span",{className:"af-composer-phase-label",children:b.label})]},b.name||j)})}):null,c.jsx("div",{className:"af-composer-thread-dialog-scroll",children:c.jsx(l1,{thread:Ha,liveSegments:Ba,running:vt})}),Ae&&!Ae.isLastPhase&&Ae.nextPhase&&!vt?c.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[c.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Ae.nextPhase.label})}),c.jsxs("div",{className:"af-composer-phase-review-buttons",children:[c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:lw,children:e("flow:composer.phaseReviewContinue",{label:Ae.nextPhase.label})}),c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:aw,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}):c.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),he!=="edit"&&cn&&c.jsxs("div",{className:"af-run-console",style:{height:Ea},children:[c.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:p_,onPointerMove:h_,onPointerUp:iw,onPointerCancel:iw,onLostPointerCapture:m_}),c.jsxs("div",{className:"af-run-console__head",children:[c.jsxs("span",{className:"af-run-console__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),c.jsxs("div",{className:"af-run-console__head-right",children:[he==="running"&&c.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),c.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>Ft(!1),"aria-label":e("flow:run.closeLog"),children:c.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),c.jsxs("div",{className:"af-run-console__body",children:[G.map((b,j)=>c.jsxs("div",{className:"af-run-console__line"+(b.type==="error"?" af-run-console__line--error":"")+(b.type==="warn"?" af-run-console__line--warn":"")+(b.type==="node-start"?" af-run-console__line--start":"")+(b.type==="node-done"?" af-run-console__line--done":"")+(b.type==="node-failed"?" af-run-console__line--error":"")+(b.type==="done"?" af-run-console__line--done":""),children:[c.jsxs("span",{className:"af-run-console__ts",children:["[",b.ts?new Date(b.ts).toLocaleTimeString():"--:--:--","]"]}),c.jsx("span",{className:"af-run-console__text",children:b.text!=null?String(b.text):""})]},j)),c.jsx("div",{ref:fo})]})]})]}),he!=="edit"&&Pa&&a?c.jsx(m8,{instanceId:Pa,flowId:a.id,runId:ft,nodeStatus:((dw=It[Pa])==null?void 0:dw.status)??null,onClose:()=>Jo(null)}):null,J&&a&&he==="edit"?c.jsx("aside",{className:"af-pipeline-drawer"+(J==="node"?" af-pipeline-drawer--wide":"")+(J==="composer"?" af-pipeline-drawer--wide":""),"aria-label":J==="settings"?e("flow:settings.title"):J==="history"?e("flow:history.title"):J==="composer"?"AI Composer":e("flow:nodeProps.title"),children:J==="composer"?c.jsxs("div",{className:"af-composer-sidebar",children:[c.jsxs("div",{className:"af-pipeline-drawer-head",children:[c.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Hp,"aria-label":e("flow:composer.closeSidebar"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Bn.length>0&&c.jsxs("div",{className:"af-composer-session-tabs",children:[Bn.map(b=>c.jsxs("button",{type:"button",ref:j=>{j&&b.id===Kt&&j.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",b.id===Kt?"af-composer-session-tab--active":"",b.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Xx(b.id),title:b.label,children:[c.jsx("span",{className:"af-composer-session-label",children:b.label}),(Bn.length>1||b.running)&&c.jsx("span",{className:"af-composer-session-close",onClick:j=>{j.stopPropagation(),VP(b.id)},title:b.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},b.id)),c.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>Kx(),title:e("flow:composer.newConversation"),children:c.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),c.jsx("div",{className:"af-composer-sidebar-status"+(vt?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:vt&&!za?e("flow:composer.executing"):za||e("flow:composer.ready")}),Ae&&Array.isArray(Ae.phases)&&Ae.phases.length>1?c.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Ae.phases.map((b,j)=>{const z=b.status||(j<(Ae.currentPhase??0)?"done":j===(Ae.currentPhase??0)?vt?"running":Ae.isLastPhase&&j===Ae.phases.length-1||Ae.nextPhase?"done":"running":"pending");return c.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${b.label}${b.description?":"+b.description:""}`,children:[c.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?c.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):c.jsx("span",{children:j+1})}),c.jsx("span",{className:"af-composer-phase-label",children:b.label})]},b.name||j)})}):null,c.jsx("div",{className:"af-composer-sidebar-thread",ref:Wx,children:c.jsx(l1,{thread:Ha,liveSegments:Ba,running:vt})}),Ae&&!Ae.isLastPhase&&Ae.nextPhase&&!vt?c.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[c.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Ae.nextPhase.label})}),c.jsxs("div",{className:"af-composer-phase-review-buttons",children:[c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:lw,children:e("flow:composer.phaseReviewContinue",{label:Ae.nextPhase.label})}),c.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:aw,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):J==="node"&&Pe?Oe?c.jsx(C4,{draft:Oe,setDraft:Ep,definitionId:String(((fw=Pe.data)==null?void 0:fw.definitionId)??Pe.id),systemPromptReadonly:String((Op==null?void 0:Op.description)??""),modelLists:_e,disabled:!a,onIdBlur:f_,onClose:Hp,error:BP,ioSlots:{inputs:Array.isArray(Oe==null?void 0:Oe.inputs)?Oe.inputs:[],outputs:Array.isArray(Oe==null?void 0:Oe.outputs)?Oe.outputs:[]}}):c.jsx("div",{className:"af-pipeline-drawer-body",children:c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-pipeline-drawer-head",children:[c.jsx("h2",{className:"af-pipeline-drawer-title",children:e(J==="settings"?"flow:settings.title":"flow:history.title")}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Hp,"aria-label":e("flow:composer.closeSidebar"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-pipeline-drawer-body",children:J==="settings"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(a.source==="user"||a.source==="workspace")&&!a.archived?c.jsxs("div",{className:"af-pipeline-rename-row",children:[c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:E,onChange:b=>{S(b.target.value),B("")},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),nw())},onBlur:()=>{E.trim()&&E.trim()!==a.id&&nw()},placeholder:a.id,disabled:P,spellCheck:!1}),c.jsx("span",{className:"af-pipeline-drawer-badge",children:Xh(a.source??"user",e)})]}):c.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[a.id,c.jsx("span",{className:"af-pipeline-drawer-badge",children:Xh(a.source??"user",e)}),a.archived?c.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),M?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:M}):null]}),typeof a.path=="string"&&a.path?c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),c.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[c.jsx("span",{className:"af-pipeline-path-text",children:a.path}),c.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>u_(a.path),title:e("flow:settings.copyPath"),children:c.jsx("span",{className:"material-symbols-outlined",children:A?"check":"content_copy"})})]})]}):null,a.source==="user"||a.source==="workspace"?a.archived?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):c.jsxs("div",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),c.jsx("div",{className:"af-pipeline-move-actions",children:a.source==="user"?c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:y,onClick:()=>tw("workspace"),children:e(y?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:y,onClick:()=>tw("user"),children:e(y?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),g?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:g}):null]}):c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),c.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:d,onChange:b=>p(b.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),c.jsxs("div",{className:"af-pipeline-meta-card",children:[c.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),wp?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"af-new-pipeline-radio",children:[c.jsx("input",{type:"checkbox",checked:!!$n.enabled,disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,enabled:b.target.checked}))}),c.jsx("span",{children:e("flow:schedule.enabled")})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:$n.cron||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,cron:b.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),c.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:$n.timezone||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,timezone:b.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),c.jsxs("label",{className:"af-pipeline-drawer-field",children:[c.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),c.jsxs("select",{className:"af-pipeline-flow-select",value:$n.preset||"",disabled:wi||a.archived||a.source==="builtin",onChange:b=>Sr(j=>({...j,preset:b.target.value})),children:[c.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(xi).map(b=>c.jsx("option",{value:b,children:b},b))]})]}),c.jsx("div",{className:"af-pipeline-drawer-readonly",children:c.jsx("span",{children:e("flow:schedule.overlapSkip")})}),$n.nextRunAt?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date($n.nextRunAt).toLocaleString()})}):c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),c.jsxs("dl",{className:"af-pipeline-meta-dl",children:[c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.runtime")}),c.jsx("dd",{children:Zn!=null&&Zn.running?e("flow:schedule.running"):$n.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Wt.lastTriggeredAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),c.jsx("dd",{children:new Date(Wt.lastTriggeredAt).toLocaleString()})]}):null,Wt.lastSkippedAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),c.jsxs("dd",{children:[new Date(Wt.lastSkippedAt).toLocaleString(),Wt.lastSkipReason?` · ${Wt.lastSkipReason}`:""]})]}):null,Wt.lastRunUuid?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastRun")}),c.jsx("dd",{children:Wt.lastRunUuid})]}):null,Wt.lastExitCode!=null?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastExit")}),c.jsx("dd",{children:String(Wt.lastExitCode)})]}):null,Wt.lastFinishedAt?c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),c.jsx("dd",{children:new Date(Wt.lastFinishedAt).toLocaleString()})]}):null]}),Zn!=null&&Zn.lastError||Wt.lastError?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Zn==null?void 0:Zn.lastError)||Wt.lastError}):null,a.archived||a.source==="builtin"?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Zc?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Zc}):null,eu?c.jsx("p",{className:"af-pipeline-drawer-muted",children:eu}):null,c.jsx("button",{type:"button",className:"af-btn-secondary",disabled:wi||a.archived||a.source==="builtin",onClick:c_,children:e(wi?"flow:schedule.saving":"flow:schedule.save")})]})]}),c.jsxs("div",{className:"af-pipeline-meta-card",children:[c.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),c.jsx("dl",{className:"af-pipeline-meta-dl",children:c.jsxs("div",{className:"af-pipeline-meta-row",children:[c.jsx("dt",{children:e("flow:pipeline.nodeCount")}),c.jsxs("dd",{children:[He.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),c.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>t("/settings"),children:e("flow:settings.globalSettings")})]}):c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),c.jsx("strong",{children:a.id})]}),$e?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):ge?c.jsx("p",{className:"af-err af-pipeline-drawer-err",children:ge}):qa.length===0?c.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):c.jsxs(c.Fragment,{children:[nn.success+nn.failed+nn.running+nn.stopped+nn.interrupted>0?c.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[nn.success>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:nn.success})}):null,nn.failed>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:nn.failed})}):null,nn.stopped>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:nn.stopped})}):null,nn.interrupted>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:nn.interrupted})}):null,nn.running>0?c.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:nn.running})}):null]}):null,c.jsx("ul",{className:"af-exec-history-list",children:qa.map((b,j)=>{const z=b.status||"unknown",W=z==="success"?"af-exec-history-card--success":z==="failed"?"af-exec-history-card--failed":z==="stopped"?"af-exec-history-card--stopped":z==="interrupted"?"af-exec-history-card--interrupted":z==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",K=e(z==="success"?"flow:history.success":z==="failed"?"flow:history.failed":z==="stopped"?"flow:history.stopped":z==="interrupted"?"flow:history.interrupted":z==="running"?"flow:history.running":"flow:history.unknown"),Y=z==="success"?"check_circle":z==="failed"?"error":z==="stopped"?"stop_circle":z==="interrupted"?"sync_disabled":z==="running"?"progress_activity":"help",Z=b.runId||`${b.at}-${j}`,te=b.runId!=null&&b.runId.length>=6?e("flow:history.runLabel",{id:b.runId.length>8?b.runId.slice(-8):b.runId}):e("flow:history.runLabel",{id:qa.length-j});return c.jsx("li",{className:"af-exec-history-list-item",children:c.jsxs("button",{type:"button",className:`af-exec-history-card ${W}`,onClick:()=>S_(b),title:e("flow:history.enterRunView"),children:[c.jsxs("div",{className:"af-exec-history-card-top",children:[c.jsx("span",{className:"af-exec-history-card-title",children:te}),c.jsx("span",{className:"af-exec-history-card-time",children:ng(b.at,e)})]}),c.jsxs("div",{className:"af-exec-history-card-bottom",children:[c.jsxs("span",{className:"af-exec-history-card-status",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Y}),K]}),c.jsxs("span",{className:"af-exec-history-card-duration",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),jA(b.durationMs,e)]})]})]})},`${a.id}-${Z}`)})})]})]})})]})}):null]}),c.jsx(Zv,{open:g_,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:x_,onCancel:()=>$p(!1)}),c.jsx(Zv,{open:w_,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:b_,onSecondary:v_,onCancel:()=>bu(!1)}),c.jsx(u4,{open:ou,onClose:()=>Fa(!1)}),c.jsx(f4,{open:kp,onClose:()=>zx(!1),onJump:o_,nodes:He}),c.jsx(C8,{open:Vc,onClose:()=>Wc(!1),flowId:(a==null?void 0:a.id)??""}),c.jsx(a4,{open:V,onClose:()=>L(!1),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",onArchived:async()=>{L(!1),await gu(),t("/projects?tab=archived")}}),c.jsx(l4,{open:H&&!!(a!=null&&a.id),onClose:()=>D(!1),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",flowArchived:!!(a!=null&&a.archived),onDeleted:async()=>{D(!1),l(null),Ue([]),Tt([]),Va(null),await gu(),t("/projects")}}),c.jsx(p4,{open:!!$,onClose:()=>_(null),flowId:(a==null?void 0:a.id)??"",flowSource:(a==null?void 0:a.source)??"user",flowArchived:!!(a!=null&&a.archived),filePath:($==null?void 0:$.filePath)??"",fileName:($==null?void 0:$.fileName)??"",onSaved:()=>{Dt(b=>({...b}))}})]}),At&&he!=="edit"&&qi.createPortal(c.jsx("div",{className:"af-user-check-modal-overlay",children:c.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-user-check-modal__head",children:[c.jsxs("span",{className:"af-user-check-modal__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:At.instanceId})]}),c.jsx("div",{className:"af-user-check-modal__actions",children:tu?c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!At||!a||!ft)return;const b=ho||At.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"save-user-check-content",runUuid:ft,instanceId:At.instanceId,content:b})})).ok?(ns(z=>z&&{...z,content:b}),mo(!1),Q(z=>[...z,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{rs(At.content),mo(!1)},children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>mo(!0),children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),c.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>ns(null),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),c.jsx("div",{className:"af-user-check-modal__body",children:tu?c.jsx("textarea",{ref:vp,className:"af-user-check-modal__textarea",value:ho||At.content,onChange:b=>rs(b.target.value)}):c.jsx("div",{className:"af-user-check-modal__preview",children:c.jsx("pre",{children:ho||At.content})})}),c.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[c.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:qr,onChange:b=>is(b.target.value),disabled:os}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:os||!qr.trim(),onClick:()=>{!At||!a||!ft||!qr.trim()||(ss(!0),Q(b=>[...b,{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:a.id,flowSource:a.source??"user",action:"ai-edit-user-check-content",runUuid:ft,instanceId:At.instanceId,content:ho||At.content,prompt:qr})}).then(b=>b.json()).then(b=>{ss(!1),b.ok&&b.content?(rs(b.content),mo(!0),is(""),Q(j=>[...j,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:b.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{ss(!1),Q(b=>[...b,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[os?c.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):c.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),c.jsxs("div",{className:"af-user-check-modal__foot",children:[c.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),c.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!At||!a||!ft)return;const b=ho||At.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"save-user-check-content",runUuid:ft,instanceId:At.instanceId,content:b})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"confirm-user-check",runUuid:ft,instanceId:At.instanceId,execId:At.execId})}),ns(null),is(""),Pr({runUuid:ft})):Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),Nn&&he!=="edit"&&qi.createPortal(c.jsx("div",{className:"af-user-ask-modal-overlay",children:c.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-user-ask-modal__head",children:[c.jsxs("span",{className:"af-user-ask-modal__title",children:[c.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:Nn.instanceId})]}),c.jsx("div",{className:"af-user-ask-modal__actions",children:c.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Ra(null),"aria-label":e("flow:userAsk.close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),c.jsxs("div",{className:"af-user-ask-modal__body",children:[Nn.question.trim()?c.jsx("div",{className:"af-user-ask-modal__question",children:c.jsx("pre",{children:Nn.question})}):null,Nn.options.length===0?c.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):c.jsx("div",{className:"af-user-ask-modal__options",children:Nn.options.map(b=>c.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:nu,onClick:async()=>{if(!(!Nn||!a||!ft)){bi(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:a.id,flowSource:a.source??"user",action:"confirm-user-ask",runUuid:ft,instanceId:Nn.instanceId,execId:Nn.execId,branch:b.name,selectedIndex:b.index,selectedLabel:b.label})})).ok?(Ra(null),bi(!1),Pr({runUuid:ft})):(bi(!1),Q(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{bi(!1),Q(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[c.jsxs("span",{className:"af-user-ask-option__index",children:["[",b.index,"]"]}),c.jsx("span",{className:"af-user-ask-option__label",children:b.label})]},b.name))})]}),c.jsx("div",{className:"af-user-ask-modal__foot",children:c.jsx("span",{className:"af-user-ask-modal__hint",children:e(nu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),as&&he!=="edit"&&c.jsxs("div",{className:"af-tool-print-toast",role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"af-tool-print-toast__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"print"}),c.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:as.instanceId})}),c.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>$x(null),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsxs("div",{className:"af-tool-print-toast__body",children:[c.jsx("pre",{children:as.content.length>500?as.content.slice(0,500):as.content}),as.content.length>500&&c.jsx("span",{className:"af-tool-print-toast__more",children:e("flow:toolPrint.truncated")})]})]}),ls&&c.jsx("div",{className:"af-provide-edit-overlay",children:c.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-provide-edit-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),c.jsx("span",{className:"af-provide-edit-modal__title",children:ls.label}),c.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>ru(null),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-provide-edit-modal__body",children:c.jsx("textarea",{ref:bp,className:"af-provide-edit-modal__textarea",defaultValue:ls.content,autoFocus:!0})}),c.jsxs("div",{className:"af-provide-edit-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:GP,children:[c.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),c.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>ru(null),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),xp&&c.jsx("div",{className:"af-run-params-overlay",children:c.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[c.jsxs("div",{className:"af-run-params-modal__head",children:[c.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),c.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),c.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Zo(!1),"aria-label":e("common:close"),children:c.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c.jsx("div",{className:"af-run-params-modal__body",children:er.length===0?c.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):c.jsx("div",{className:"af-run-params-list",children:er.map(b=>{var Z,te;const j=cs[b.id];if(!j)return null;const W=(((Z=b.data)==null?void 0:Z.definitionId)||"").startsWith("provide_file"),K=((te=b.data)==null?void 0:te.label)||b.id,Y=Gc[j]??"";return c.jsxs("div",{className:"af-run-params-item",children:[c.jsxs("div",{className:"af-run-params-item__head",children:[c.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(W?" af-run-params-item__icon--file":""),children:W?"description":"text_fields"}),c.jsx("span",{className:"af-run-params-item__label",children:K}),c.jsx("span",{className:"af-run-params-item__slot",children:j})]}),c.jsx("input",{type:"text",className:"af-run-params-item__input",value:Y,onChange:se=>Xc(oe=>({...oe,[j]:se.target.value})),placeholder:e(W?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},b.id)})})}),c.jsxs("div",{className:"af-run-params-modal__foot",children:[c.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var j;const b={};for(const z of er){const W=cs[z.id];if(!W)continue;const K=((j=z.data)==null?void 0:j.definitionId)||"",Y=Gc[W]??"";K.startsWith("provide_file")?b[W]={type:"file",path:Y}:b[W]={type:"str",value:Y}}Zo(!1),yi(!1),Pr({cliInputsOverride:b})},children:[c.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),c.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Zo(!1),children:[c.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})})}const je=e=>typeof e=="string",fl=()=>{let e,t;const n=new Promise((r,i)=>{e=r,t=i});return n.resolve=e,n.reject=t,n},p1=e=>e==null?"":""+e,Q8=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},J8=/###/g,h1=e=>e&&e.indexOf("###")>-1?e.replace(J8,"."):e,m1=e=>!e||je(e),$l=(e,t,n)=>{const r=je(t)?t.split("."):t;let i=0;for(;i<r.length-1;){if(m1(e))return{};const o=h1(r[i]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++i}return m1(e)?{}:{obj:e,k:h1(r[i])}},g1=(e,t,n)=>{const{obj:r,k:i}=$l(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let o=t[t.length-1],s=t.slice(0,t.length-1),a=$l(e,s,Object);for(;a.obj===void 0&&s.length;)o=`${s[s.length-1]}.${o}`,s=s.slice(0,s.length-1),a=$l(e,s,Object),a&&a.obj&&typeof a.obj[`${a.k}.${o}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${o}`]=n},Z8=(e,t,n,r)=>{const{obj:i,k:o}=$l(e,t,Object);i[o]=i[o]||[],i[o].push(n)},bf=(e,t)=>{const{obj:n,k:r}=$l(e,t);if(n)return n[r]},e9=(e,t,n)=>{const r=bf(e,n);return r!==void 0?r:bf(t,n)},tP=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?je(e[r])||e[r]instanceof String||je(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):tP(e[r],t[r],n):e[r]=t[r]);return e},ys=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var t9={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const n9=e=>je(e)?e.replace(/[&<>"'\/]/g,t=>t9[t]):e;class r9{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 i9=[" ",",","?","!",";"],o9=new r9(20),s9=(e,t,n)=>{t=t||"",n=n||"";const r=i9.filter(s=>t.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=o9.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let o=!i.test(e);if(!o){const s=e.indexOf(n);s>0&&!i.test(e.substring(0,s))&&(o=!0)}return o},zg=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 i=e;for(let o=0;o<r.length;){if(!i||typeof i!="object")return;let s,a="";for(let l=o;l<r.length;++l)if(l!==o&&(a+=n),a+=r[l],s=i[a],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&l<r.length-1)continue;o+=l-o+1;break}i=s}return i},Sf=e=>e&&e.replace("_","-"),a9={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 kf{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||a9,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,i){return i&&!this.debug?null:(je(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new kf(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new kf(this.logger,t)}}var Dr=new kf;class up{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(s=>{let[a,l]=s;for(let u=0;u<l;u++)a(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(s=>{let[a,l]=s;for(let u=0;u<l;u++)a.apply(a,[t,...r])})}}class y1 extends up{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 i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;t.indexOf(".")>-1?a=t.split("."):(a=[t,n],r&&(Array.isArray(r)?a.push(...r):je(r)&&o?a.push(...r.split(o)):a.push(r)));const l=bf(this.data,a);return!l&&!n&&!r&&t.indexOf(".")>-1&&(t=a[0],n=a[1],r=a.slice(2).join(".")),l||!s||!je(r)?l:zg(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const s=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let a=[t,n];r&&(a=a.concat(s?r.split(s):r)),t.indexOf(".")>-1&&(a=t.split("."),i=n,n=a[1]),this.addNamespaces(n),g1(this.data,a,i),o.silent||this.emit("added",t,n,r,i)}addResources(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(je(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});i.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,i,o){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},a=[t,n];t.indexOf(".")>-1&&(a=t.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let l=bf(this.data,a)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?tP(l,r,o):l={...l,...r},g1(this.data,a,l),s.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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var nP={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,i))}),t}};const x1={};class Nf extends up{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Q8(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Dr.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 i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const s=r&&t.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!s9(t,r,i);if(s&&!a){const l=t.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:t,namespaces:je(o)?[o]:o};const u=t.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(i)}return{key:t,namespaces:je(o)?[o]:o}}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 i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:s,namespaces:a}=this.extractFromKey(t[t.length-1],n),l=a[a.length-1],u=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(f){const N=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${N}${s}`,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${N}${s}`}return i?{res:s,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:s}const d=this.resolve(t,n);let p=d&&d.res;const h=d&&d.usedKey||s,m=d&&d.exactUsedKey||s,v=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,y=!je(p)&&typeof p!="boolean"&&typeof p!="number";if(w&&p&&y&&k.indexOf(v)<0&&!(je(g)&&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:a}):`key '${s} (${this.language})' returned an object instead of string.`;return i?(d.res=N,d.usedParams=this.getUsedParamsDetails(n),d):N}if(o){const N=Array.isArray(p),E=N?[]:{},S=N?m:h;for(const P in p)if(Object.prototype.hasOwnProperty.call(p,P)){const T=`${S}${o}${P}`;E[P]=this.translate(T,{...n,joinArrays:!1,ns:a}),E[P]===T&&(E[P]=p[P])}p=E}}else if(w&&je(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let N=!1,E=!1;const S=n.count!==void 0&&!je(n.count),P=Nf.hasDefaultValue(n),T=S?this.pluralResolver.getSuffix(u,n.count,n):"",M=n.ordinal&&S?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",B=S&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),A=B&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${T}`]||n[`defaultValue${M}`]||n.defaultValue;!this.isValidLookup(p)&&P&&(N=!0,p=A),this.isValidLookup(p)||(E=!0,p=s);const V=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:p,L=P&&A!==p&&this.options.updateMissing;if(E||N||L){if(this.logger.log(L?"updateKey":"missingKey",u,l,s,L?A:p),o){const _=this.resolve(s,{...n,keySeparator:!1});_&&_.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 H=[];const D=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&D&&D[0])for(let _=0;_<D.length;_++)H.push(D[_]);else this.options.saveMissingTo==="all"?H=this.languageUtils.toResolveHierarchy(n.lng||this.language):H.push(n.lng||this.language);const $=(_,I,C)=>{const F=P&&C!==p?C:V;this.options.missingKeyHandler?this.options.missingKeyHandler(_,l,I,F,L,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,l,I,F,L,n),this.emit("missingKey",_,l,I,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&S?H.forEach(_=>{const I=this.pluralResolver.getSuffixes(_,n);B&&n[`defaultValue${this.options.pluralSeparator}zero`]&&I.indexOf(`${this.options.pluralSeparator}zero`)<0&&I.push(`${this.options.pluralSeparator}zero`),I.forEach(C=>{$([_],s+C,n[`defaultValue${C}`]||A)})}):$(H,s,A))}p=this.extendTranslation(p,t,n,d,r),E&&p===s&&this.options.appendNamespaceToMissingKey&&(p=`${l}:${s}`),(E||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${s}`:s,N?p:void 0):p=this.options.parseMissingKeyHandler(p))}return i?(d.res=p,d.usedParams=this.getUsedParamsDetails(n),d):p}extendTranslation(t,n,r,i,o){var s=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=je(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(u){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let d=r.replace&&!je(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),t=this.interpolator.interpolate(t,d,r.lng||this.language||i.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;f<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),m=0;m<p;m++)h[m]=arguments[m];return o&&o[0]===h[0]&&!r.context?(s.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):s.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,l=je(a)?[a]:a;return t!=null&&l&&l.length&&r.applyPostProcessor!==!1&&(t=nP.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,o,s,a;return je(t)&&(t=[t]),t.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),f=u.key;i=f;let d=u.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const p=n.count!==void 0&&!je(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),m=n.context!==void 0&&(je(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(k=>{this.isValidLookup(r)||(a=k,!x1[`${v[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(a)&&(x1[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${a}" 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(g=>{if(this.isValidLookup(r))return;s=g;const w=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,g,k,n);else{let N;p&&(N=this.pluralResolver.getSuffix(g,n.count,n));const E=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(w.push(f+N),n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),h&&w.push(f+E)),m){const P=`${f}${this.options.contextSeparator}${n.context}`;w.push(P),p&&(w.push(P+N),n.ordinal&&N.indexOf(S)===0&&w.push(P+N.replace(S,this.options.pluralSeparator)),h&&w.push(P+E))}}let y;for(;y=w.pop();)this.isValidLookup(r)||(o=y,r=this.getResource(g,k,y,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:s,usedNS:a}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,i):this.resourceStore.getResource(t,n,r,i)}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&&!je(t.replace);let i=r?t.replace:t;if(r&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const o of n)delete i[o]}return i}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 Qh=e=>e.charAt(0).toUpperCase()+e.slice(1);class w1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Dr.create("languageUtils")}getScriptPartFromCode(t){if(t=Sf(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=Sf(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(je(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let i=Intl.getCanonicalLocales(t)[0];if(i&&this.options.lowerCaseLng&&(i=i.toLowerCase()),i)return i}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Qh(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]=Qh(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Qh(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 i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),je(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),i=[],o=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return je(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):je(t)&&o(this.formatLanguageCode(t)),r.forEach(s=>{i.indexOf(s)<0&&o(this.formatLanguageCode(s))}),i}}let l9=[{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}],c9={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 u9=["v1","v2","v3"],d9=["v4"],v1={zero:0,one:1,two:2,few:3,many:4,other:5},f9=()=>{const e={};return l9.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:c9[t.fc]}})}),e};class p9{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Dr.create("pluralResolver"),(!this.options.compatibilityJSON||d9.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=f9(),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=Sf(t==="dev"?"en":t),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!t.match(/-|_/))return;const l=this.languageUtils.getLanguagePartFromCode(t);s=this.getRule(l,n)}return this.pluralRulesCache[o]=s,s}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(i=>`${n}${i}`)}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((i,o)=>v1[i]-v1[o]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(t,i,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,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 i=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const o=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!u9.includes(this.options.compatibilityJSON)}}const b1=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=e9(e,t,n);return!o&&i&&je(n)&&(o=zg(e,n,r),o===void 0&&(o=zg(t,n,r))),o},Jh=e=>e.replace(/\$/g,"$$$$");class h9{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Dr.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:i,prefix:o,prefixEscaped:s,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:d,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:m,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:g,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:n9,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?ys(o):s||"{{",this.suffix=a?ys(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":d||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?ys(p):h||ys("$t("),this.nestingSuffix=m?ys(m):v||ys(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=g||1e3,this.alwaysFormat=w!==void 0?w:!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,i){let o,s,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=b1(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...i,...n,interpolationkey:h}):g}const m=h.split(this.formatSeparator),v=m.shift().trim(),k=m.join(this.formatSeparator).trim();return this.format(b1(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const f=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Jh(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Jh(this.escape(h)):Jh(h)}].forEach(h=>{for(a=0;o=h.regex.exec(t);){const m=o[1].trim();if(s=u(m),s===void 0)if(typeof f=="function"){const k=f(t,o,i);s=je(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,m))s="";else if(d){s=o[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${t}`),s="";else!je(s)&&!this.useRawValueToEscape&&(s=p1(s));const v=h.safeValue(s);if(t=t.replace(o[0],v),d?(h.regex.lastIndex+=s.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,o,s;const a=(l,u)=>{const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const d=l.split(new RegExp(`${f}[ ]*{`));let p=`{${d[1]}`;l=d[0],p=this.interpolate(p,s);const h=p.match(/'/g),m=p.match(/"/g);(h&&h.length%2===0&&!m||m.length%2!==0)&&(p=p.replace(/'/g,'"'));try{s=JSON.parse(p),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,v),`${l}${f}${p}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,l};for(;i=this.nestingRegexp.exec(t);){let l=[];s={...r},s=s.replace&&!je(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const f=i[1].split(this.formatSeparator).map(d=>d.trim());i[1]=f.shift(),l=f,u=!0}if(o=n(a.call(this,i[1].trim(),s),s),o&&i[0]===t&&!je(o))return o;je(o)||(o=p1(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),o=""),u&&(o=l.reduce((f,d)=>this.format(f,d,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),t=t.replace(i[0],o),this.regexp.lastIndex=0}return t}}const m9=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);t==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[a,...l]=s.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=a.trim();n[f]||(n[f]=u),u==="false"&&(n[f]=!1),u==="true"&&(n[f]=!0),isNaN(u)||(n[f]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},xs=e=>{const t={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const s=r+JSON.stringify(o);let a=t[s];return a||(a=e(Sf(r),i),t[s]=a),a(n)}};class g9{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Dr.create("formatter"),this.options=t,this.formats={number:xs((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:xs((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:xs((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:xs((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:xs((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},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()]=xs(n)}format(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(a=>a.indexOf(")")>-1)){const a=o.findIndex(l=>l.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,a)].join(this.formatSeparator)}return o.reduce((a,l)=>{const{formatName:u,formatOptions:f}=m9(l);if(this.formats[u]){let d=a;try{const p=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},h=p.locale||p.lng||i.locale||i.lng||r;d=this.formats[u](a,h,{...f,...i,...p})}catch(p){this.logger.warn(p)}return d}else this.logger.warn(`there was no format function for ${u}`);return a},t)}}const y9=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class x9 extends up{constructor(t,n,r){let i=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=i,this.logger=Dr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(t,n,r,i){const o={},s={},a={},l={};return t.forEach(u=>{let f=!0;n.forEach(d=>{const p=`${u}|${d}`;!r.reload&&this.store.hasResourceBundle(u,d)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?s[p]===void 0&&(s[p]=!0):(this.state[p]=1,f=!1,s[p]===void 0&&(s[p]=!0),o[p]===void 0&&(o[p]=!0),l[d]===void 0&&(l[d]=!0)))}),f||(a[u]=!0)}),(Object.keys(o).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(s),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(t,n,r){const i=t.split("|"),o=i[0],s=i[1];n&&this.emit("failedLoading",o,s,n),!n&&r&&this.store.addResourceBundle(o,s,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const a={};this.queue.forEach(l=>{Z8(l.loaded,[o],s),y9(l,t),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const f=l.loaded[u];f.length&&f.forEach(d=>{a[u][d]===void 0&&(a[u][d]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;if(!t.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:i,wait:o,callback:s});return}this.readingCalls++;const a=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,i+1,o*2,s)},o);return}s(u,f)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(t,n);u&&typeof u.then=="function"?u.then(f=>a(null,f)).catch(a):a(null,u)}catch(u){a(u)}return}return l(t,n,a)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=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."),i&&i();je(t)&&(t=this.languageUtils.toResolveHierarchy(t)),je(n)&&(n=[n]);const o=this.queueLoad(t,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(s=>{this.loadOne(s)})}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("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(s,a)=>{s&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,s),!s&&a&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,a),this.loaded(t,s,a)})}saveMissing(t,n,r,i,o){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},a=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 l={...s,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let f;u.length===5?f=u(t,n,r,i,l):f=u(t,n,r,i),f&&typeof f.then=="function"?f.then(d=>a(null,d)).catch(a):a(null,f)}catch(f){a(f)}else u(t,n,r,i,a,l)}!t||!t[0]||this.store.addResource(t[0],n,r,i)}}}const S1=()=>({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]),je(e[1])&&(t.defaultValue=e[1]),je(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}}),k1=e=>(je(e.ns)&&(e.ns=[e.ns]),je(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),je(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),id=()=>{},w9=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class wc extends up{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=k1(t),this.services={},this.logger=Dr,this.modules={external:[]},w9(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&&(je(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=S1();this.options={...i,...this.options,...k1(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?Dr.init(o(this.modules.logger),this.options):Dr.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=g9);const d=new w1(this.options);this.store=new y1(this.options.resources,this.options);const p=this.services;p.logger=Dr,p.resourceStore=this.store,p.languageUtils=d,p.pluralResolver=new p9(d,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(p.formatter=o(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new h9(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new x9(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var m=arguments.length,v=new Array(m>1?m-1:0),k=1;k<m;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=o(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=o(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Nf(this.services,this.options),this.translator.on("*",function(h){for(var m=arguments.length,v=new Array(m>1?m-1:0),k=1;k<m;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=id),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 l=fl(),u=()=>{const f=(d,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),l.resolve(p),r(d,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?u():setTimeout(u,0),l}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:id;const i=je(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],s=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload&&this.options.preload.forEach(a=>s(a)),this.services.backendConnector.load(o,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(t,n,r){const i=fl();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=id),this.services.backendConnector.reload(t,n,o=>{i.resolve(),r(o)}),i}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"&&nP.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 i=fl();this.emit("languageChanging",t);const o=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(l,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},a=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const u=je(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,f=>{s(f,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t),i}getFixedT(t,n,r){var i=this;const o=function(s,a){let l;if(typeof a!="object"){for(var u=arguments.length,f=new Array(u>2?u-2:0),d=2;d<u;d++)f[d-2]=arguments[d];l=i.options.overloadTranslationOptionHandler([s,a].concat(f))}else l={...a};l.lng=l.lng||o.lng,l.lngs=l.lngs||o.lngs,l.ns=l.ns||o.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||o.keyPrefix);const p=i.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(s)?h=s.map(m=>`${l.keyPrefix}${p}${m}`):h=l.keyPrefix?`${l.keyPrefix}${p}${s}`:s,i.t(h,l)};return je(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}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],i=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const a=n.precheck(this,s);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,t)&&(!i||s(o,t)))}loadNamespaces(t,n){const r=fl();return this.options.ns?(je(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=fl();je(t)&&(t=[t]);const i=this.options.preload||[],o=t.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return o.length?(this.options.preload=i.concat(o),this.loadResources(s=>{r.resolve(),n&&n(s)}),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 w1(S1());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 wc(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:id;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},o=new wc(i);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(a=>{o[a]=this[a]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new y1(this.store.data,i),o.services.resourceStore=o.store),o.translator=new Nf(o.services,i),o.translator.on("*",function(a){for(var l=arguments.length,u=new Array(l>1?l-1:0),f=1;f<l;f++)u[f-1]=arguments[f];o.emit(a,...u)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ut=wc.createInstance();Ut.createInstance=wc.createInstance;Ut.createInstance;Ut.dir;Ut.init;Ut.loadResources;Ut.reloadResources;Ut.use;Ut.changeLanguage;Ut.getFixedT;Ut.t;Ut.exists;Ut.setDefaultNamespace;Ut.hasLoadedNamespace;Ut.loadNamespaces;Ut.loadLanguages;function v9(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vc(e){"@babel/helpers - typeof";return vc=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},vc(e)}function b9(e,t){if(vc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(vc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function S9(e){var t=b9(e,"string");return vc(t)=="symbol"?t:t+""}function k9(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,S9(r.key),r)}}function N9(e,t,n){return t&&k9(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var rP=[],C9=rP.forEach,E9=rP.slice;function j9(e){return C9.call(E9.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var N1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,P9=function(t,n,r){var i=r||{};i.path=i.path||"/";var o=encodeURIComponent(n),s="".concat(t,"=").concat(o);if(i.maxAge>0){var a=i.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+="; Max-Age=".concat(Math.floor(a))}if(i.domain){if(!N1.test(i.domain))throw new TypeError("option domain is invalid");s+="; Domain=".concat(i.domain)}if(i.path){if(!N1.test(i.path))throw new TypeError("option path is invalid");s+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return s},C1={create:function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),i&&(o.domain=i),document.cookie=P9(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),i=0;i<r.length;i++){for(var o=r[i];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},_9={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=C1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&C1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},I9={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 i=r.substring(1),o=i.split("&"),s=0;s<o.length;s++){var a=o[s].indexOf("=");if(a>0){var l=o[s].substring(0,a);l===t.lookupQuerystring&&(n=o[s].substring(a+1))}}}return n}},pl=null,E1=function(){if(pl!==null)return pl;try{pl=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pl=!1}return pl},A9={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&E1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&E1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},hl=null,j1=function(){if(hl!==null)return hl;try{hl=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{hl=!1}return hl},T9={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&j1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&j1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},R9={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}},L9={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}},O9={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}},M9={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]}},iP=!1;try{document.cookie,iP=!0}catch{}var oP=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];iP||oP.splice(1,1);function D9(){return{order:oP,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var sP=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};v9(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return N9(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=j9(r,this.options||{},D9()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(_9),this.addDetector(I9),this.addDetector(A9),this.addDetector(T9),this.addDetector(R9),this.addDetector(L9),this.addDetector(O9),this.addDetector(M9)}},{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 i=[];return n.forEach(function(o){if(r.detectors[o]){var s=r.detectors[o].lookup(r.options);s&&typeof s=="string"&&(s=[s]),s&&(i=i.concat(s))}}),i=i.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){i.detectors[o]&&i.detectors[o].cacheUserLanguage(n,i.options)}))}}])}();sP.type="languageDetector";const F9={name:"AgentFlow",tagline:"AI Workflow Orchestration"},$9={projects:"Projects",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},z9={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"},B9={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},H9={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},U9={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},V9={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},W9={app:F9,nav:$9,common:z9,status:B9,nodeTypes:H9,engine:U9,links:V9},K9="Flow Editor",Y9="Nodes",q9="Edges",G9="Properties",X9={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"},Q9={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",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:"Instance 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}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${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"},J9={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},Z9={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},eU={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"},tU={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)"},nU={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},rU={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},iU={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},oU={node:"Node",text:"Text",file:"File",bool:"Boolean"},sU={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"},aU={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",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",selectAll:"Select all nodes"},lU={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},cU={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."},uU={mainNav:"Main Navigation"},dU={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'},fU={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):
130
130
  {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
131
131
  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}}"},pU={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"},hU={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},mU={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}}"},gU={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"},yU={title:"Pipeline Settings",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"},xU={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"},wU={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"},vU={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"},bU={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},SU={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},kU={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"},NU={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."},CU={title:"Print Output: {{instanceId}}",truncated:"...content truncated"},EU={save:"Save",cancel:"Cancel"},jU={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},PU={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},_U={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"},IU={title:K9,nodes:Y9,edges:q9,properties:G9,node:X9,nodeProps:Q9,actions:J9,panel:Z9,palette:eU,pipeline:tU,status:nU,roles:rU,phases:iU,types:oU,runContext:sU,shortcuts:aU,jumpPalette:lU,emptyCanvas:cU,sidebar:uU,validation:dU,composer:fU,topbar:pU,palette2:hU,run:mU,fileEdit:gU,settings:yU,schedule:xU,history:wU,nodePropsError:vU,placeholder:bU,time:SU,userCheck:kU,userAsk:NU,toolPrint:CU,provideEdit:EU,runParams:jU,runPreset:PU,runConfig:_U},AU="Settings",TU={engine:"Engine Settings",preferences:"Global Preferences"},RU={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)."},LU={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..."}},OU={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."},MU={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."},DU={title:"Environment Variables",note:"Local machine, this browser only",key:"Key",value:"Value",add:"Add",delete:"Delete {{key}}",newKey:"New env key",newValue:"Value (be careful with secrets)"},FU={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},$U={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},zU={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},BU={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."},HU={title:AU,crumb:TU,workspace:RU,cursor:LU,opencode:OU,claudeCode:MU,env:DU,system:FU,shortcuts:$U,language:zU,onboarding:BU},UU={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},VU={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)"},WU={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},KU={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},YU={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},qU={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},GU={aiLabels:UU,placeholders:VU,actions:WU,labels:KU,tooltips:YU,rightPanel:qU},XU="Projects",QU="All",JU="Archived",ZU="Active Projects",eV="Archived Pipelines",tV="Create New Project",nV="New Pipeline",rV="SEARCH PIPELINES...",iV="Loading pipelines...",oV="Filter result: {{count}} items (matching title, description, path and tags)",sV="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",aV="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",lV="No archived projects.",cV="No active pipelines; archived items are in the Archived tab.",uV="Failed to load pipeline list.",dV="No pipelines in current workspace.",fV="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.",pV='No pipelines found matching "{{query}}". Try different keywords or clear the search.',hV="Recent Activity",mV="No recent activity",gV="No recent activity matching the keyword",yV="Recent Run",xV="Recent Open",wV={builtin:"Built-in",workspace:"Workspace",user:"User"},vV="Open to edit this pipeline in the node canvas.",bV={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>"},SV={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"},kV={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"},NV={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"},CV={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"},EV={title:XU,all:QU,archived:JU,activeProjects:ZU,archivedPipelines:eV,createNew:tV,newPipeline:nV,searchPipelines:rV,loadingPipelines:iV,filterResult:oV,archivedHint:sV,activeHint:aV,noArchived:lV,noActive:cV,loadFailed:uV,noPipelines:dV,emptyHint:fV,noMatch:pV,recentActivity:hV,noRecentActivity:mV,noMatchRecent:gV,recentRun:yV,recentOpen:xV,sourceBadge:wV,defaultCardDesc:vV,hubCard:bV,newPipelineModal:SV,importModal:kV,deleteModal:NV,archiveModal:CV},jV="Back",PV="Next",_V="Skip",IV="Done",AV="Start Creating",TV={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
132
132
 
@@ -187,4 +187,4 @@ The left node panel allows you to freely drag, delete, and adjust connections.`}
187
187
  transform: scale(1);
188
188
  }
189
189
  }
190
- `)),document.head.appendChild(k);const g=setTimeout(()=>{Qt.domElement(p.current)&&l&&p.current.focus()},0);return()=>{clearTimeout(g);const w=document.getElementById("joyride-beacon-animation");w!=null&&w.parentNode&&w.parentNode.removeChild(w)}},[h,s,l]);const m=ti(o.open);let v;if(t){const k=t;v=ke.createElement(k,{continuous:n,index:r,isLastStep:i,size:u,step:f})}else v=ke.createElement("span",{style:d.beacon},ke.createElement("span",{style:d.beaconOuter}),ke.createElement("span",{style:d.beaconInner}));return ke.createElement("button",{ref:p,"aria-label":m,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:a,onMouseEnter:a,style:d.beaconWrapper,title:m,type:"button"},v)}function Dq({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return ke.createElement("button",{style:o,type:"button",...t},ke.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},ke.createElement("g",null,ke.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Fq(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:s,step:a,tooltipProps:l}=e,{buttons:u,content:f,styles:d,title:p}=a,h={};u.includes("primary")&&(h.primary=ke.createElement("button",{"data-testid":"button-primary",style:d.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(h.skip=ke.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:d.buttonSkip,type:"button",...s})),u.includes("back")&&r>0&&(h.back=ke.createElement("button",{"data-testid":"button-back",style:d.buttonBack,type:"button",...t})),h.close=u.includes("close")&&ke.createElement(Dq,{"data-testid":"button-close",styles:d.buttonClose,...n});const m=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":ti(f),"aria-describedby":"joyride-tooltip-content"};return ke.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...a.id&&{"data-joyride-id":a.id},style:d.tooltip,...l,...m},ke.createElement("div",{style:d.tooltipContainer},p&&ke.createElement("h4",{id:"joyride-tooltip-title",style:d.tooltipTitle},p),ke.createElement("div",{id:"joyride-tooltip-content",style:d.tooltipContent},f)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&ke.createElement("div",{style:d.tooltipFooter},ke.createElement("div",{style:d.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function $q(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:s}=e,a=g=>{g.preventDefault(),n.prev(Rr.BUTTON_BACK)},l=g=>{g.preventDefault(),s.closeButtonAction==="skip"?n.skip(Rr.BUTTON_CLOSE):n.close(Rr.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Rr.BUTTON_PRIMARY);return}n.next(Rr.BUTTON_PRIMARY)},f=g=>{g.preventDefault(),n.skip(Rr.BUTTON_SKIP)},d=()=>{const{back:g,close:w,last:y,next:N,nextWithProgress:E,skip:S}=s.locale,P=ti(g),T=ti(w),M=ti(y),B=ti(N),A=ti(S);let R=w,V=T;if(t){if(R=N,V=B,s.showProgress&&!i){const L=ti(E,{step:r+1,steps:o});R=Kg(E,r+1,o),V=L}i&&(R=y,V=M)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:a,role:"button",title:P},closeProps:{"aria-label":T,children:w,"data-action":"close",onClick:l,role:"button",title:T},primaryProps:{"aria-label":V,children:R,"data-action":"primary",onClick:u,role:"button",title:V},skipProps:{"aria-label":A,children:S,"data-action":"skip",onClick:f,role:"button",title:A},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:m,...v}=s;let k;if(m){const g=m;k=ke.createElement(g,{...d(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else k=ke.createElement(Fq,{...d(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return k}function zq(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Bq(e,t,n){var r,i;return e?[WY()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[VY({crossAxis:!1,fallbackPlacements:zq(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function Hq(e){var I,C,F,U,O;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:s,portalElement:a,setPositionData:l,setTooltipRef:u,shouldScroll:f,size:d,step:p,target:h,updateState:m}=e,v=x.useRef(null),k=x.useRef({}),g=x.useRef({}),w=p.placement==="center",y=p.placement==="auto",N=x.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),E=x.useMemo(()=>RP(h)?Na(h):void 0,[h]),S=x.useMemo(()=>Ca(h),[h]),P=x.useMemo(()=>E?{boundary:E,rootBoundary:"viewport"}:{},[E]),T=w||y?"bottom":p.placement,M=w?"fixed":((I=p.floatingOptions)==null?void 0:I.strategy)??(p.isFixed||S?"fixed":"absolute"),B=x.useMemo(()=>{var q,ee,ne,ae;return w?[{name:"center",fn:({rects:J})=>({x:(window.innerWidth-J.floating.width)/2,y:(window.innerHeight-J.floating.height)/2})}]:[K1(({placement:J})=>{var ye;let le="right";J.startsWith("top")?le="top":J.startsWith("bottom")?le="bottom":J.startsWith("left")&&(le="left");const Se=p.spotlightTarget?0:p.spotlightPadding[le];return p.offset+Se+((ye=p.floatingOptions)!=null&&ye.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(q=p.floatingOptions)==null?void 0:q.hideArrow]),...Bq(y,p,T),UY({padding:10,...P,...(ee=p.floatingOptions)==null?void 0:ee.shiftOptions}),...(ne=p.floatingOptions)!=null&&ne.hideArrow?[]:[KY({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ae=p.floatingOptions)==null?void 0:ae.middleware)??[]]},[w,p,y,T,P]),A=W1({...w?{elements:{reference:N}}:{},placement:T,strategy:M,middleware:B}),R=W1({strategy:M,placement:p.beaconPlacement??(y||w?"bottom":p.placement),middleware:x.useMemo(()=>{var q,ee;return[K1(((ee=(q=p.floatingOptions)==null?void 0:q.beaconOptions)==null?void 0:ee.offset)??-18)]},[(F=(C=p.floatingOptions)==null?void 0:C.beaconOptions)==null?void 0:F.offset]),whileElementsMounted:H1});g.current=A.middlewareData,k.current=R.middlewareData,x.useEffect(()=>{var ne;const{floating:q,reference:ee}=A.elements;if(!(!ee||!q||i!==de.TOOLTIP))return H1(ee,q,A.update,(ne=p.floatingOptions)==null?void 0:ne.autoUpdate)},[i,A.update,(U=p.floatingOptions)==null?void 0:U.autoUpdate,p.target,A.elements]),x.useEffect(()=>{!w&&h&&A.refs.setReference(h),h&&R.refs.setReference(h)},[R.refs,w,h,A.refs]),x.useEffect(()=>{A.isPositioned&&l("tooltip",{placement:A.placement,x:A.x??0,y:A.y??0,middlewareData:g.current})},[l,A.isPositioned,A.placement,A.x,A.y]),x.useEffect(()=>{R.isPositioned&&l("beacon",{placement:R.placement,x:R.x??0,y:R.y??0,middlewareData:k.current})},[l,R.isPositioned,R.placement,R.x,R.y]);const V=p.zIndex+100,L=x.useCallback(q=>{q.type==="mouseenter"&&p.beaconTrigger!=="hover"||m({lifecycle:de.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,m]),H=x.useCallback(q=>{q&&(A.refs.setFloating(q),u(q))},[A.refs,u]),{arrow:D,floater:$}=p.styles;let _=null;if(i===de.TOOLTIP||i===de.TOOLTIP_BEFORE){const q=q1({...$,...A.floatingStyles,zIndex:V,opacity:s&&A.isPositioned?1:0,...!s&&{transition:"none"}});_=ke.createElement("div",{ref:H,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:q},ke.createElement($q,{continuous:t,controls:n,index:r,isLastStep:r+1===d,size:d,step:p}),!w&&!((O=p.floatingOptions)!=null&&O.hideArrow)&&ke.createElement(Oq,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:A.placement,position:A.middlewareData.arrow,size:p.arrowSize,styles:D}))}else(i===de.BEACON||i===de.BEACON_BEFORE)&&(_=ke.createElement("div",{ref:R.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:q1({...R.floatingStyles,zIndex:V})},ke.createElement(Mq,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===d,locale:p.locale,nonce:o,onInteract:L,shouldFocus:f,size:d,step:p,styles:p.styles})));return ke.createElement(DP,{element:a},_)}function Uq(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:s,setPositionData:a,shouldScroll:l,size:u,step:f,updateState:d}=e,[p,h]=x.useState(null);Tq(f.disableFocusTrap?null:p,"[data-action=primary]");const m=Yn(f.target),v=i===de.TOOLTIP;return!OP(f)||!Qt.domElement(m)?null:ke.createElement(Hq,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:s,setPositionData:a,setTooltipRef:h,shouldScroll:l,size:u,step:f,target:m,updateState:d})}function Vq({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:s,nonce:a,portalElement:l,scrollToFirstStep:u}=t,f=kq(l),{index:d,lifecycle:p,status:h}=n,m=h===Me.RUNNING,[v,k]=x.useState(!1),g=x.useRef(null),w=(r==null?void 0:r.loaderDelay)??0;x.useEffect(()=>(n.waiting?w===0?k(!0):g.current=setTimeout(()=>{k(!0)},w):k(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[w,n.waiting]),x.useEffect(()=>{if(!m)return;const E=S=>{!r||p!==de.TOOLTIP||S.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Rr.KEYBOARD):e.close(Rr.KEYBOARD))};return document.body.addEventListener("keydown",E,{passive:!0}),()=>{document.body.removeEventListener("keydown",E)}},[e,m,p,r]);const y=x.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Rr.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Rr.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!m)return null;const N=n.action===Fe.START&&!r.skipBeacon&&r.placement!=="center";return ke.createElement(ke.Fragment,null,p!==de.INIT&&ke.createElement(Uq,{...n,continuous:o,controls:e,debug:s,nonce:a,portalElement:f,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(d!==0||u),step:r,updateState:i.current.updateState}),ke.createElement(DP,{element:f},ke.createElement(ke.Fragment,null,v&&ke.createElement(Cq,{nonce:a,step:r}),!N&&ke.createElement(Iq,{...r,continuous:o,lifecycle:p,onClickOverlay:y,portalElement:l?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Wq(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:s}=Sq(e);return{controls:t,failures:n,on:x.useCallback((a,l)=>s.current.on(a,l),[s]),state:x.useMemo(()=>If(i,"positioned"),[i]),step:o,Tour:Mx()?ke.createElement(Vq,{controls:t,mergedProps:r,state:i,step:o,store:s}):null}}function Kq(e){const{Tour:t}=Wq(e);return t}function Yq(e){return Mx()?ke.createElement(Kq,e):null}function qq(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function Gq(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Xq(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const om="af:onboarding";function Qq({page:e,hasNodes:t=!1}){const{t:n}=rt(),[r,i]=x.useState(!1),[o,s]=x.useState([]),a=x.useRef(null),l=x.useMemo(()=>e==="projects"?qq(n):t?Gq(n):Xq(n),[e,t,n]);return x.useEffect(()=>{const u=localStorage.getItem(om);console.log("[Onboarding] localStorage:",u);const f=u?JSON.parse(u):{};if(console.log("[Onboarding] progress:",f,"page:",e),f.completed||f[e]){console.log("[Onboarding] skipped - already done"),i(!1),s([]);return}console.log("[Onboarding] starting with steps:",l),s(l),i(!0)},[e,t,l]),x.useEffect(()=>{if(!r)return;const u=f=>{var m;const d=f.target.closest("button");if(!d||!d.closest(".react-joyride__tooltip"))return;const h=(m=d.textContent)==null?void 0:m.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(om)||"{}",k=JSON.parse(v);h===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(om,JSON.stringify(k)),s([]),i(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:c.jsx(Yq,{ref:a,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function Jq(){const{navigate:e,path:t}=xa(),[n,r]=x.useState([]),[i,o]=x.useState(!1);if(x.useEffect(()=>{let f=!1;const d=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const m=await h.json();if(f)return;const v=Array.isArray(m.runs)?m.runs:[];r(v.filter(k=>k&&k.status==="running"))}catch{}};d();const p=window.setInterval(d,3e3);return()=>{f=!0,window.clearInterval(p)}},[]),n.length===0)return null;const s=f=>{const d=new URLSearchParams({flowId:f.flowId,flowSource:f.flowSource||"workspace"});e(`/flow?${d.toString()}`),o(!1)},a=t==="/flow"?new URLSearchParams(window.location.search):null,l=(a==null?void 0:a.get("flowId"))||"",u=n.length===1;return c.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[i&&!u&&c.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:n.map(f=>c.jsxs("button",{type:"button",className:"af-run-indicator__item"+(f.flowId===l?" af-run-indicator__item--current":""),onClick:()=>s(f),title:`${f.flowId} · ${f.runId}`,children:[c.jsx("span",{className:"af-run-indicator__dot"}),c.jsx("span",{className:"af-run-indicator__flow",children:f.flowId}),c.jsx("span",{className:"af-run-indicator__run",children:f.runId.slice(0,12)})]},`${f.flowId}:${f.runId}`))}),c.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>u?s(n[0]):o(f=>!f),title:u?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[c.jsx("span",{className:"af-run-indicator__pulse"}),c.jsx("span",{className:"af-run-indicator__label",children:u?n[0].flowId:`${n.length} running`})]})]})}function Zq(){const{path:e}=xa();return e==="/projects"||e==="/"?c.jsx(_0,{}):e==="/flow"?c.jsx(X6,{}):e==="/settings"?c.jsx(BW,{}):c.jsx(_0,{})}function eG(){const{path:e}=xa(),t=e==="/flow";return c.jsxs("div",{className:"af-app",children:[e!=="/settings"?c.jsx(Qq,{page:t?"flow":"projects"}):null,t?null:c.jsx(SA,{}),c.jsx("div",{className:t?"af-main af-main--pipeline":"af-main",children:c.jsx(Zq,{})}),c.jsx(Jq,{})]})}function tG(){return c.jsx(rA,{children:c.jsx(eG,{})})}const eS=document.querySelector('link[rel="icon"]');eS&&(eS.href=gN);sm.createRoot(document.getElementById("root")).render(c.jsx(ke.StrictMode,{children:c.jsx(tG,{})}));
190
+ `)),document.head.appendChild(k);const g=setTimeout(()=>{Qt.domElement(p.current)&&l&&p.current.focus()},0);return()=>{clearTimeout(g);const w=document.getElementById("joyride-beacon-animation");w!=null&&w.parentNode&&w.parentNode.removeChild(w)}},[h,s,l]);const m=ti(o.open);let v;if(t){const k=t;v=ke.createElement(k,{continuous:n,index:r,isLastStep:i,size:u,step:f})}else v=ke.createElement("span",{style:d.beacon},ke.createElement("span",{style:d.beaconOuter}),ke.createElement("span",{style:d.beaconInner}));return ke.createElement("button",{ref:p,"aria-label":m,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:a,onMouseEnter:a,style:d.beaconWrapper,title:m,type:"button"},v)}function Dq({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return ke.createElement("button",{style:o,type:"button",...t},ke.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},ke.createElement("g",null,ke.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Fq(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:s,step:a,tooltipProps:l}=e,{buttons:u,content:f,styles:d,title:p}=a,h={};u.includes("primary")&&(h.primary=ke.createElement("button",{"data-testid":"button-primary",style:d.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(h.skip=ke.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:d.buttonSkip,type:"button",...s})),u.includes("back")&&r>0&&(h.back=ke.createElement("button",{"data-testid":"button-back",style:d.buttonBack,type:"button",...t})),h.close=u.includes("close")&&ke.createElement(Dq,{"data-testid":"button-close",styles:d.buttonClose,...n});const m=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":ti(f),"aria-describedby":"joyride-tooltip-content"};return ke.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...a.id&&{"data-joyride-id":a.id},style:d.tooltip,...l,...m},ke.createElement("div",{style:d.tooltipContainer},p&&ke.createElement("h4",{id:"joyride-tooltip-title",style:d.tooltipTitle},p),ke.createElement("div",{id:"joyride-tooltip-content",style:d.tooltipContent},f)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&ke.createElement("div",{style:d.tooltipFooter},ke.createElement("div",{style:d.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function $q(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:s}=e,a=g=>{g.preventDefault(),n.prev(Rr.BUTTON_BACK)},l=g=>{g.preventDefault(),s.closeButtonAction==="skip"?n.skip(Rr.BUTTON_CLOSE):n.close(Rr.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Rr.BUTTON_PRIMARY);return}n.next(Rr.BUTTON_PRIMARY)},f=g=>{g.preventDefault(),n.skip(Rr.BUTTON_SKIP)},d=()=>{const{back:g,close:w,last:y,next:N,nextWithProgress:E,skip:S}=s.locale,P=ti(g),T=ti(w),M=ti(y),B=ti(N),A=ti(S);let R=w,V=T;if(t){if(R=N,V=B,s.showProgress&&!i){const L=ti(E,{step:r+1,steps:o});R=Kg(E,r+1,o),V=L}i&&(R=y,V=M)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:a,role:"button",title:P},closeProps:{"aria-label":T,children:w,"data-action":"close",onClick:l,role:"button",title:T},primaryProps:{"aria-label":V,children:R,"data-action":"primary",onClick:u,role:"button",title:V},skipProps:{"aria-label":A,children:S,"data-action":"skip",onClick:f,role:"button",title:A},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:m,...v}=s;let k;if(m){const g=m;k=ke.createElement(g,{...d(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else k=ke.createElement(Fq,{...d(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return k}function zq(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Bq(e,t,n){var r,i;return e?[WY()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[VY({crossAxis:!1,fallbackPlacements:zq(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function Hq(e){var I,C,F,U,O;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:s,portalElement:a,setPositionData:l,setTooltipRef:u,shouldScroll:f,size:d,step:p,target:h,updateState:m}=e,v=x.useRef(null),k=x.useRef({}),g=x.useRef({}),w=p.placement==="center",y=p.placement==="auto",N=x.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),E=x.useMemo(()=>RP(h)?Na(h):void 0,[h]),S=x.useMemo(()=>Ca(h),[h]),P=x.useMemo(()=>E?{boundary:E,rootBoundary:"viewport"}:{},[E]),T=w||y?"bottom":p.placement,M=w?"fixed":((I=p.floatingOptions)==null?void 0:I.strategy)??(p.isFixed||S?"fixed":"absolute"),B=x.useMemo(()=>{var q,ee,ne,ae;return w?[{name:"center",fn:({rects:J})=>({x:(window.innerWidth-J.floating.width)/2,y:(window.innerHeight-J.floating.height)/2})}]:[K1(({placement:J})=>{var ye;let le="right";J.startsWith("top")?le="top":J.startsWith("bottom")?le="bottom":J.startsWith("left")&&(le="left");const Se=p.spotlightTarget?0:p.spotlightPadding[le];return p.offset+Se+((ye=p.floatingOptions)!=null&&ye.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(q=p.floatingOptions)==null?void 0:q.hideArrow]),...Bq(y,p,T),UY({padding:10,...P,...(ee=p.floatingOptions)==null?void 0:ee.shiftOptions}),...(ne=p.floatingOptions)!=null&&ne.hideArrow?[]:[KY({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ae=p.floatingOptions)==null?void 0:ae.middleware)??[]]},[w,p,y,T,P]),A=W1({...w?{elements:{reference:N}}:{},placement:T,strategy:M,middleware:B}),R=W1({strategy:M,placement:p.beaconPlacement??(y||w?"bottom":p.placement),middleware:x.useMemo(()=>{var q,ee;return[K1(((ee=(q=p.floatingOptions)==null?void 0:q.beaconOptions)==null?void 0:ee.offset)??-18)]},[(F=(C=p.floatingOptions)==null?void 0:C.beaconOptions)==null?void 0:F.offset]),whileElementsMounted:H1});g.current=A.middlewareData,k.current=R.middlewareData,x.useEffect(()=>{var ne;const{floating:q,reference:ee}=A.elements;if(!(!ee||!q||i!==de.TOOLTIP))return H1(ee,q,A.update,(ne=p.floatingOptions)==null?void 0:ne.autoUpdate)},[i,A.update,(U=p.floatingOptions)==null?void 0:U.autoUpdate,p.target,A.elements]),x.useEffect(()=>{!w&&h&&A.refs.setReference(h),h&&R.refs.setReference(h)},[R.refs,w,h,A.refs]),x.useEffect(()=>{A.isPositioned&&l("tooltip",{placement:A.placement,x:A.x??0,y:A.y??0,middlewareData:g.current})},[l,A.isPositioned,A.placement,A.x,A.y]),x.useEffect(()=>{R.isPositioned&&l("beacon",{placement:R.placement,x:R.x??0,y:R.y??0,middlewareData:k.current})},[l,R.isPositioned,R.placement,R.x,R.y]);const V=p.zIndex+100,L=x.useCallback(q=>{q.type==="mouseenter"&&p.beaconTrigger!=="hover"||m({lifecycle:de.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,m]),H=x.useCallback(q=>{q&&(A.refs.setFloating(q),u(q))},[A.refs,u]),{arrow:D,floater:$}=p.styles;let _=null;if(i===de.TOOLTIP||i===de.TOOLTIP_BEFORE){const q=q1({...$,...A.floatingStyles,zIndex:V,opacity:s&&A.isPositioned?1:0,...!s&&{transition:"none"}});_=ke.createElement("div",{ref:H,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:q},ke.createElement($q,{continuous:t,controls:n,index:r,isLastStep:r+1===d,size:d,step:p}),!w&&!((O=p.floatingOptions)!=null&&O.hideArrow)&&ke.createElement(Oq,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:A.placement,position:A.middlewareData.arrow,size:p.arrowSize,styles:D}))}else(i===de.BEACON||i===de.BEACON_BEFORE)&&(_=ke.createElement("div",{ref:R.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:q1({...R.floatingStyles,zIndex:V})},ke.createElement(Mq,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===d,locale:p.locale,nonce:o,onInteract:L,shouldFocus:f,size:d,step:p,styles:p.styles})));return ke.createElement(DP,{element:a},_)}function Uq(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:s,setPositionData:a,shouldScroll:l,size:u,step:f,updateState:d}=e,[p,h]=x.useState(null);Tq(f.disableFocusTrap?null:p,"[data-action=primary]");const m=Yn(f.target),v=i===de.TOOLTIP;return!OP(f)||!Qt.domElement(m)?null:ke.createElement(Hq,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:s,setPositionData:a,setTooltipRef:h,shouldScroll:l,size:u,step:f,target:m,updateState:d})}function Vq({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:s,nonce:a,portalElement:l,scrollToFirstStep:u}=t,f=kq(l),{index:d,lifecycle:p,status:h}=n,m=h===Me.RUNNING,[v,k]=x.useState(!1),g=x.useRef(null),w=(r==null?void 0:r.loaderDelay)??0;x.useEffect(()=>(n.waiting?w===0?k(!0):g.current=setTimeout(()=>{k(!0)},w):k(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[w,n.waiting]),x.useEffect(()=>{if(!m)return;const E=S=>{!r||p!==de.TOOLTIP||S.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Rr.KEYBOARD):e.close(Rr.KEYBOARD))};return document.body.addEventListener("keydown",E,{passive:!0}),()=>{document.body.removeEventListener("keydown",E)}},[e,m,p,r]);const y=x.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Rr.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Rr.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!m)return null;const N=n.action===Fe.START&&!r.skipBeacon&&r.placement!=="center";return ke.createElement(ke.Fragment,null,p!==de.INIT&&ke.createElement(Uq,{...n,continuous:o,controls:e,debug:s,nonce:a,portalElement:f,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(d!==0||u),step:r,updateState:i.current.updateState}),ke.createElement(DP,{element:f},ke.createElement(ke.Fragment,null,v&&ke.createElement(Cq,{nonce:a,step:r}),!N&&ke.createElement(Iq,{...r,continuous:o,lifecycle:p,onClickOverlay:y,portalElement:l?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Wq(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:s}=Sq(e);return{controls:t,failures:n,on:x.useCallback((a,l)=>s.current.on(a,l),[s]),state:x.useMemo(()=>If(i,"positioned"),[i]),step:o,Tour:Mx()?ke.createElement(Vq,{controls:t,mergedProps:r,state:i,step:o,store:s}):null}}function Kq(e){const{Tour:t}=Wq(e);return t}function Yq(e){return Mx()?ke.createElement(Kq,e):null}function qq(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function Gq(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Xq(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const om="af:onboarding";function Qq({page:e,hasNodes:t=!1}){const{t:n}=rt(),[r,i]=x.useState(!1),[o,s]=x.useState([]),a=x.useRef(null),l=x.useMemo(()=>e==="projects"?qq(n):t?Gq(n):Xq(n),[e,t,n]);return x.useEffect(()=>{const u=localStorage.getItem(om);console.log("[Onboarding] localStorage:",u);const f=u?JSON.parse(u):{};if(console.log("[Onboarding] progress:",f,"page:",e),f.completed||f[e]){console.log("[Onboarding] skipped - already done"),i(!1),s([]);return}console.log("[Onboarding] starting with steps:",l),s(l),i(!0)},[e,t,l]),x.useEffect(()=>{if(!r)return;const u=f=>{var m;const d=f.target.closest("button");if(!d||!d.closest(".react-joyride__tooltip"))return;const h=(m=d.textContent)==null?void 0:m.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(om)||"{}",k=JSON.parse(v);h===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(om,JSON.stringify(k)),s([]),i(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:c.jsx(Yq,{ref:a,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function Jq(){const{navigate:e,path:t}=xa(),[n,r]=x.useState([]),[i,o]=x.useState(!1);if(x.useEffect(()=>{let f=!1;const d=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const m=await h.json();if(f)return;const v=Array.isArray(m.runs)?m.runs:[];r(v.filter(k=>k&&k.status==="running"))}catch{}};d();const p=window.setInterval(d,3e3);return()=>{f=!0,window.clearInterval(p)}},[]),n.length===0)return null;const s=f=>{const d=new URLSearchParams({flowId:f.flowId,flowSource:f.flowSource||"workspace"});e(`/flow?${d.toString()}`),o(!1)},a=t==="/flow"?new URLSearchParams(window.location.search):null,l=(a==null?void 0:a.get("flowId"))||"",u=n.length===1;return c.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[i&&!u&&c.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:n.map(f=>c.jsxs("button",{type:"button",className:"af-run-indicator__item"+(f.flowId===l?" af-run-indicator__item--current":""),onClick:()=>s(f),title:`${f.flowId} · ${f.runId}`,children:[c.jsx("span",{className:"af-run-indicator__dot"}),c.jsx("span",{className:"af-run-indicator__flow",children:f.flowId}),c.jsx("span",{className:"af-run-indicator__run",children:f.runId.slice(0,12)})]},`${f.flowId}:${f.runId}`))}),c.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>u?s(n[0]):o(f=>!f),title:u?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[c.jsx("span",{className:"af-run-indicator__pulse"}),c.jsx("span",{className:"af-run-indicator__label",children:u?n[0].flowId:`${n.length} running`})]})]})}function Zq(){const{path:e}=xa();return e==="/projects"||e==="/"?c.jsx(_0,{}):e==="/flow"?c.jsx(X8,{}):e==="/settings"?c.jsx(BW,{}):c.jsx(_0,{})}function eG(){const{path:e}=xa(),t=e==="/flow";return c.jsxs("div",{className:"af-app",children:[e!=="/settings"?c.jsx(Qq,{page:t?"flow":"projects"}):null,t?null:c.jsx(SA,{}),c.jsx("div",{className:t?"af-main af-main--pipeline":"af-main",children:c.jsx(Zq,{})}),c.jsx(Jq,{})]})}function tG(){return c.jsx(rA,{children:c.jsx(eG,{})})}const eS=document.querySelector('link[rel="icon"]');eS&&(eS.href=gN);sm.createRoot(document.getElementById("root")).render(c.jsx(ke.StrictMode,{children:c.jsx(tG,{})}));