From 0b5e1b6bc54d32dcd455e31613f4b60c06fd23c4 Mon Sep 17 00:00:00 2001 From: ai-business-hql Date: Tue, 24 Jun 2025 16:13:42 +0800 Subject: [PATCH] feat: online --- dist/copilot_web/{App-DD4ojCC_.js => App-C-RrQ6X5.js} | 4 ++-- ...-BeDd4UDV.js => ParameterDebugInterfaceV2-DMoq59aG.js} | 2 +- ...kflowOption-BtmAE9V8.js => WorkflowOption-X60j_dVY.js} | 2 +- dist/copilot_web/input.js | 4 ++-- ...ponents-BCfBUoNX.js => message-components-Cg4LI9Ou.js} | 2 +- ...{workflowChat-GY-DLogc.js => workflowChat-BJV1D-VM.js} | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) rename dist/copilot_web/{App-DD4ojCC_.js => App-C-RrQ6X5.js} (85%) rename dist/copilot_web/{ParameterDebugInterfaceV2-BeDd4UDV.js => ParameterDebugInterfaceV2-DMoq59aG.js} (99%) rename dist/copilot_web/{WorkflowOption-BtmAE9V8.js => WorkflowOption-X60j_dVY.js} (98%) rename dist/copilot_web/{message-components-BCfBUoNX.js => message-components-Cg4LI9Ou.js} (99%) rename dist/copilot_web/{workflowChat-GY-DLogc.js => workflowChat-BJV1D-VM.js} (99%) diff --git a/dist/copilot_web/App-DD4ojCC_.js b/dist/copilot_web/App-C-RrQ6X5.js similarity index 85% rename from dist/copilot_web/App-DD4ojCC_.js rename to dist/copilot_web/App-C-RrQ6X5.js index ab227f2..fd29e8e 100644 --- a/dist/copilot_web/App-DD4ojCC_.js +++ b/dist/copilot_web/App-C-RrQ6X5.js @@ -1,7 +1,7 @@ function getImportPath(filename) { return `./${filename}`; } - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-GY-DLogc.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-BCfBUoNX.js","copilot_web/assets/input-l5zbI7RM.css","copilot_web/fonts.css"].map(path => { + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BJV1D-VM.js","copilot_web/input.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-Cg4LI9Ou.js","copilot_web/assets/input-l5zbI7RM.css","copilot_web/fonts.css"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; if (apiBase) { // 有 API base 时,使用完整路径 @@ -11,4 +11,4 @@ function getImportPath(filename) { return `./${path}`; } }))))=>i.map(i=>d[i]); -import{_ as a}from"./input.js";import{j as t}from"./vendor-markdown-Dek94WS0.js";import{r,R as i}from"./vendor-react-V04_Axys.js";import{C as n}from"./message-components-BCfBUoNX.js";/* empty css */const o={EXPLAIN_NODE:"copilot:explain-node"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-GY-DLogc.js")).then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function p(){const[e,s]=r.useState(!1);return r.useEffect(()=>{const l=()=>{s(!0)};return window.addEventListener(o.EXPLAIN_NODE,l),()=>window.removeEventListener(o.EXPLAIN_NODE,l)},[]),t.jsx(n,{children:t.jsx("div",{className:"h-full w-full flex flex-col",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:t.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>s(!1)})})})})}export{p as default}; +import{_ as a}from"./input.js";import{j as t}from"./vendor-markdown-Dek94WS0.js";import{r,R as i}from"./vendor-react-V04_Axys.js";import{C as n}from"./message-components-Cg4LI9Ou.js";/* empty css */const o={EXPLAIN_NODE:"copilot:explain-node"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-BJV1D-VM.js")).then(e=>e.w),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.default})));function p(){const[e,s]=r.useState(!1);return r.useEffect(()=>{const l=()=>{s(!0)};return window.addEventListener(o.EXPLAIN_NODE,l),()=>window.removeEventListener(o.EXPLAIN_NODE,l)},[]),t.jsx(n,{children:t.jsx("div",{className:"h-full w-full flex flex-col",children:t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:t.jsx(d,{visible:!0,triggerUsage:e,onUsageTriggered:()=>s(!1)})})})})}export{p as default}; diff --git a/dist/copilot_web/ParameterDebugInterfaceV2-BeDd4UDV.js b/dist/copilot_web/ParameterDebugInterfaceV2-DMoq59aG.js similarity index 99% rename from dist/copilot_web/ParameterDebugInterfaceV2-BeDd4UDV.js rename to dist/copilot_web/ParameterDebugInterfaceV2-DMoq59aG.js index 2e4bcf3..9d57de0 100644 --- a/dist/copilot_web/ParameterDebugInterfaceV2-BeDd4UDV.js +++ b/dist/copilot_web/ParameterDebugInterfaceV2-DMoq59aG.js @@ -1,7 +1,7 @@ function getImportPath(filename) { return `./${filename}`; } - import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as w}from"./vendor-react-V04_Axys.js";import{u as ve,a as V,g as ie,W as se}from"./message-components-BCfBUoNX.js";import{m as gt,i as pt,r as ft,g as bt}from"./workflowChat-GY-DLogc.js";import"./input.js";/* empty css */const yt=({selectedNodes:t,handleParamSelect:r,selectedParams:s,handleNext:l,handleClose:a})=>{const n=t.flatMap(i=>(i.widgets||[]).map(d=>d.name)).some(i=>s[i]===!0);return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select parameters"}),e.jsx("p",{className:"text-xs text-gray-500",children:"multiple selections supported"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:a,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.map((i,d)=>{const m=i.title||"Unknown Node",u=i.widgets||[];return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:m}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:u.map((x,g)=>{const f=x.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s[f]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:b=>r(f,b),children:s[f]&&e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),e.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:f})]},`widget-${g}`)})})})]},`node-${d}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:i=>l(i),disabled:!n,className:`px-3 py-1.5 text-xs ${n?"bg-pink-200 text-pink-700 hover:bg-pink-300":"bg-gray-200 text-gray-500 cursor-not-allowed"} rounded-md transition-colors`,children:"Next"})})]})},jt=({selectedNodes:t,paramTestValues:r,selectedParams:s,updateParamTestValues:l,toggleDropdown:a,openDropdowns:o,handleTestValueSelect:n,searchTerms:i,handleSearch:d,handleSelectAll:m,handleNext:u,handlePrevious:x,handleClose:g,inputValues:f,setInputValues:b,textInputs:$,handleTextInputChange:k,handleAddTextInput:L,handleRemoveTextInput:P,openAiWritingModal:y})=>{const N=(p,S,O,G=0)=>{if(p=isNaN(p)?0:p,S=isNaN(S)?100:S,O=isNaN(O)||O<=0?1:O,S{!t||t.length===0||t.forEach(p=>{const S=p.id.toString(),O=p.widgets||{};Object.values(O).forEach(j=>{const E=j.name;if(!s[E])return;if(!(r[S]?.[E]?.length>0)&&j.type==="number"){const v=j.options?.min||0,T=j.options?.max||100;let I=(j.options?.step||10)/10;I<.1&&(I=.1);const _=j.options?.precision||0,B=N(v,T,I,_);if(B.length>0){l(S,E,B);const z=`${S}_${E}`;b(C=>({...C,[z]:{min:v.toString(),max:T.toString(),step:I.toString()}}))}}if(j.type==="customtext"||j.type.toLowerCase().includes("text")){const v=`${S}_${E}`,T=$[v]||[""];JSON.stringify(T)!==JSON.stringify(r[S]?.[E]||[""])&&l(S,E,T)}})})},[t,s,r,$,l,b,N]),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Set test values"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:g,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.length>0?t.map((p,S)=>{const O=p.widgets||{},G=Object.values(O),j=p.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b flex justify-between items-center",children:[e.jsxs("span",{children:[p.type," (ID: ",j,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:E=>g(E,S),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-4 space-y-4",children:G.map((E,R)=>{const v=E.name;if(!s[v])return null;const T=`${j}_${v}`;if(E.type==="customtext"||E.type.toLowerCase().includes("text")){const I=$[T]||[""];return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[v,":"]}),e.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>y(j,v),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})}),"AI Writing"]})]}),e.jsx("div",{className:"space-y-2",children:I.map((_,B)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${_?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:_,onChange:z=>k(j,v,B,z.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>P(j,v,B),title:"Remove",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},B))}),e.jsxs("button",{className:"mt-2 px-2 py-1 border border-dashed border-gray-300 rounded text-xs text-gray-600 hover:bg-gray-50 flex items-center",onClick:()=>L(j,v),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},R)}if(E.type==="number"){const I=E.options?.min||0,_=E.options?.max||100,B=(E.options?.step||10)/10,z=E.options?.precision||0,C=N(I,_,B,z),F=f[T]||{min:I.toString(),max:_.toString(),step:B.toString()};return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[v,":"]}),e.jsx("div",{className:"w-4"})]}),e.jsxs("div",{className:"flex space-x-2 items-center",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.min,required:!0,onClick:M=>{M.preventDefault(),M.stopPropagation()},onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],min:D}})),D===""||!isNaN(parseFloat(D))){const A=D===""?0:parseFloat(D),H=parseFloat(F.max||_.toString()),U=parseFloat(F.step||B.toString()),J=N(A,H,U,z);l(j,v,J)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.max,onClick:M=>{M.preventDefault(),M.stopPropagation()},required:!0,onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],max:D}})),D===""||!isNaN(parseFloat(D))){const A=parseFloat(F.min||I.toString()),H=D===""?A:parseFloat(D),U=parseFloat(F.step||B.toString()),J=N(A,H,U,z);l(j,v,J)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.step,required:!0,onClick:M=>{M.preventDefault(),M.stopPropagation()},onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],step:D}})),D===""||!isNaN(parseFloat(D))&&parseFloat(D)>0){const A=parseFloat(F.min||I.toString()),H=parseFloat(F.max||_.toString());let U=D===""?1:parseFloat(D);U<.1&&(U=.1);const J=N(A,H,U,z);l(j,v,J)}}})]}),e.jsxs("div",{className:"mt-1",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(()=>{const M=r[j]?.[v]||C;if(M.length<=10)return M.map((D,A)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:H=>{H.stopPropagation(),n(j,v,D,H)},children:[e.jsx("span",{children:D}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},A));{const D=M.slice(0,5),A=M.slice(M.length-5);return e.jsxs(e.Fragment,{children:[D.map((H,U)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:J=>{J.stopPropagation(),n(j,v,H,J)},children:[e.jsx("span",{children:H}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`first-${U}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),A.map((H,U)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:J=>{J.stopPropagation(),n(j,v,H,J)},children:[e.jsx("span",{children:H}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`last-${U}`))]})}})()})]}),e.jsx("div",{className:"mt-1",children:e.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max"})})]},R)}else if(E.type==="combo"){const I=E.options?.values||[],_=`${j}_${v}`,B=C=>typeof C=="string"?C:C&&typeof C=="object"&&"name"in C?C.name:String(C),z=C=>typeof C=="object"&&C!==null&&"name"in C?C.name:C;return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("label",{className:"text-xs font-medium text-gray-700",children:v}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(r[j]?.[v]||[]).length===0?"border-red-500":"border-gray-300"} rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700`,onClick:C=>{C.preventDefault(),C.stopPropagation(),a(j,v,C)},"data-dropdown":_,children:[e.jsx("span",{children:(r[j]?.[v]||[]).length>0?`${v}: ${(r[j]?.[v]||[]).length} selected`:`Select ${v}`}),e.jsx("div",{className:"ml-2",children:e.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),o[_]&&e.jsxs("div",{className:"absolute z-[9999] mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg dropdown-menu",style:{position:"fixed",top:typeof o[_]=="object"?`${o[_].y}px`:"0px",left:typeof o[_]=="object"?`${o[_].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[e.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:e.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:i[_]||"",onChange:C=>{C.preventDefault(),C.stopPropagation(),d(j,v,C.target.value)},onClick:C=>{C.preventDefault(),C.stopPropagation()},autoFocus:!0})}),e.jsxs("div",{className:"px-3 py-1.5 bg-gray-50 border-b cursor-pointer text-xs flex items-center text-gray-700 hover:bg-gray-100",onClick:C=>{C.preventDefault(),C.stopPropagation();const M=I.filter(D=>!i[_]||B(D).toLowerCase().includes((i[_]||"").toLowerCase())).map(z);m(j,v,M)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${I.length>0&&(r[j]?.[v]||[]).length===I.length?"bg-blue-500 border-blue-500":(r[j]?.[v]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(r[j]?.[v]||[]).length>0&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"font-medium",children:I.length>0&&(r[j]?.[v]||[]).length===I.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[I.filter(C=>!i[_]||B(C).toLowerCase().includes((i[_]||"").toLowerCase())).map((C,F)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:M=>{M.preventDefault(),M.stopPropagation(),n(j,v,z(C),M)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(r[j]?.[v]||[]).includes(z(C))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(r[j]?.[v]||[]).includes(z(C))&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:B(C)})]},F)),I.filter(C=>!i[_]||B(C).toLowerCase().includes((i[_]||"").toLowerCase())).length===0&&e.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),(r[j]?.[v]||[]).length===0&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(r[j]?.[v]||[]).map((C,F)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:C}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:M=>{M.preventDefault(),M.stopPropagation(),n(j,v,C,M)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},F))})]})]},R)}else return e.jsxs("div",{className:"border-b pb-3",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx("label",{className:"text-xs font-medium text-gray-700",children:v})}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(r[j]?.[v]||[]).map((I,_)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:I}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:B=>{B.preventDefault(),B.stopPropagation(),n(j,v,I,B)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},_)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:I=>{I.preventDefault(),I.stopPropagation();const _=`${v}${(r[j]?.[v]||[]).length+1}`;l(j,v,[...r[j]?.[v]||[],_])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},R)})})]},S)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:p=>x(p),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:p=>u(p),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},vt=({selectedNodes:t,paramTestValues:r,selectedParams:s,totalCount:l,errorMessage:a,handlePrevious:o,handleStartGeneration:n,handleClose:i})=>{const[d,m]=w.useState([]),[u,x]=w.useState(null),[g,f]=w.useState(!1);ve();const b=()=>{const k=Object.values(V.graph._nodes_by_id),L=[],P=[];for(const N of k)N.type==="SaveImage"?L.push(N.id):N.type==="PreviewImage"&&P.push(N.id);const y=[...L,...P];m(y),y.length===1?x(y[0]):y.length>1&&(f(!0),x(null))};w.useEffect(()=>{b()},[]),w.useEffect(()=>{const k=()=>{if(!V.canvas.selected_nodes)return;const L=Object.values(V.canvas.selected_nodes);if(L.length===0)return;const P=L[0];P&&(P.type==="SaveImage"||P.type==="PreviewImage")&&(console.log("Selected image node:",P.id),x(P.id))};return document.addEventListener("click",k),()=>{document.removeEventListener("click",k)}},[]);const $=k=>{if(k&&(k.preventDefault(),k.stopPropagation()),d.length>1&&!u){f(!0);return}n(k,u||void 0)};return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Conform combinations"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",l," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:i,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g&&d.length>1&&e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:u===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${d.join(",")}. Please click the node on canvas.`:`Current node ID is ${u}, please click Start Generation again`})]})}),a&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:a})]})}),t.length>0?t.map((k,L)=>{const P=k.type||"Unknown Node",y=k.widgets||[],N=k.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[P," (ID: ",N,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:y.map((p,S)=>{const O=p.name;if(!s[O])return null;const G=r[N]?.[O]||[],j=Array.isArray(G)?`[${G.join(", ")}]`:JSON.stringify(G);return e.jsxs("div",{className:SE.preventDefault()})})]},S)})})]},L)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500 text-xs",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:k=>o(k),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:k=>$(k),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${d.length>1&&!u?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:d.length>1&&!u,children:"Generate & Compare"})]})]})},Nt=({selectedNodes:t,paramTestValues:r,selectedParams:s,totalCount:l,completedCount:a,errorMessage:o,handleClose:n,setIsProcessing:i,setCurrentScreen:d,cleanupPolling:m})=>{const u=x=>{x.preventDefault(),x.stopPropagation(),gt({clear:!0}),pt(),m&&m(),i(!1),d(2)};return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:e.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),e.jsxs("div",{className:"text-xs mb-3",children:["Completed ",a," of ",l," runs"]}),e.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${a/l*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",a," images"]}),e.jsx("button",{onClick:u,className:"mt-4 px-3 py-1.5 text-xs bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors",children:"Cancel"})]})}),e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",l," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:n,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:o})]})}),t.length>0?t.map((x,g)=>{const f=x.type||"Unknown Node",b=x.widgets||[],$=x.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[f," (ID: ",$,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:b.map((k,L)=>{const P=k.name;if(!s[P])return null;const y=r[$]?.[P]||[],N=Array.isArray(y)?`[${y.join(", ")}]`:JSON.stringify(y);return e.jsxs("div",{className:Lp.preventDefault()})})]},L)})})]},g)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."})]})},te=({visible:t,imageUrl:r,params:s,onClose:l})=>{if(!t)return null;const a=()=>{if(!s||!s.nodeParams)return null;const o=Object.entries(s.nodeParams).map(([n,i])=>{const d=s.nodeNames?.[n]||s.selectedNodeInfoMap&&s.selectedNodeInfoMap[n]||(n.includes("text")?"Text Node":`Node ${n}`),m=Object.entries(i).filter(([u,x])=>typeof x!="object"||x===null).map(([u,x])=>e.jsxs("div",{className:"pl-4 text-sm py-1 flex",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400 mr-2",children:"-"}),e.jsxs("span",{className:"font-medium mr-1",children:[u,":"]}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-all",children:String(x)})]},u));return e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"font-semibold text-pink-600 dark:text-pink-400 text-base py-1 border-b border-gray-200 dark:border-gray-700 mb-2",children:d}),m.length>0?m:e.jsx("div",{className:"pl-4 text-sm text-gray-500 italic",children:"nodeParams is null"})]},n)});return e.jsx("div",{className:"overflow-y-auto max-h-full",children:o.length>0?o:e.jsx("div",{className:"text-sm text-gray-500 italic",children:"nodeParams is null"})})};return e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",onClick:l,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl flex flex-row w-[90%] max-w-6xl max-h-[90vh] relative m-4 overflow-hidden",onClick:o=>o.stopPropagation(),style:{display:"flex",flexDirection:"row"},children:[e.jsx("button",{className:"absolute top-2 right-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 p-1 z-10",onClick:l,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("div",{className:"w-[65%] border-r border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"p-4 h-full flex items-center justify-center",children:e.jsx("img",{src:r,alt:"Enlarged image",className:"max-w-full max-h-[calc(90vh-2rem)] object-contain"})})}),e.jsx("div",{className:"w-[35%] h-full overflow-hidden flex flex-col",children:e.jsxs("div",{className:"p-4 flex-1 overflow-y-auto",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-800 dark:text-gray-200 mb-4",children:"Parameters"}),s&&!s.nodeParams&&Object.entries(s).filter(([o,n])=>o!=="nodeParams"&&typeof n!="object").map(([o,n])=>e.jsxs("div",{className:"py-1 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("span",{className:"font-medium",children:[o,":"]})," ",String(n)]},o)),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:a()})]})})]})})},wt=({generatedImages:t,selectedImageIndex:r,handleSelectImage:s,handleApplySelected:l,handlePrevious:a,handleClose:o,currentPage:n,handlePageChange:i,imagesPerPage:d,notificationVisible:m,modalVisible:u,modalImageUrl:x,modalImageParams:g,openImageModal:f,closeImageModal:b})=>{const $=Math.ceil(t.length/d),k=(n-1)*d,L=Math.min(k+d,t.length),P=t.slice(k,L);return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["All ",t.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:o,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),e.jsx(te,{visible:u,imageUrl:x,params:g||{},onClose:b}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:P.map((y,N)=>{const p=k+N;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${r===p?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:S=>s(p,S),children:[e.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:S=>f(y.url,y.params,S),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),e.jsx("div",{className:"aspect-square",children:e.jsx("img",{src:y.url,alt:`Generated image ${p+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(y.params).filter(([S,O])=>S!=="nodeParams"&&typeof O!="object").map(([S,O])=>e.jsxs("div",{children:[S,": ",String(O)]},S))})]},p)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:y=>i(1,y),disabled:n===1,className:`px-2 py-1 rounded ${n===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M15.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M8.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L4.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})]})}),e.jsx("button",{onClick:y=>i(n-1,y),disabled:n===1,className:`px-2 py-1 rounded ${n===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"px-2 py-1 text-xs text-gray-800",children:["Page ",n," of ",$]}),e.jsx("button",{onClick:y=>i(n+1,y),disabled:n===$,className:`px-2 py-1 rounded ${n===$?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})}),e.jsx("button",{onClick:y=>i($,y),disabled:n===$,className:`px-2 py-1 rounded ${n===$?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M4.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L8.586 10 4.293 14.293a1 1 0 000 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M11.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L15.586 10l-4.293 4.293a1 1 0 000 1.414z",clipRule:"evenodd"})]})})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{onClick:y=>l(y),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:r===null,children:"Apply Selected"})})]})},kt=({visible:t,aiWritingModalText:r,setAiWritingModalText:s,aiGeneratedTexts:l,aiSelectedTexts:a,aiWritingLoading:o,aiWritingError:n,handleAiWriting:i,toggleTextSelection:d,addSelectedTexts:m,onClose:u})=>t?e.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:u,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-white + import{j as e}from"./vendor-markdown-Dek94WS0.js";import{r as w}from"./vendor-react-V04_Axys.js";import{u as ve,a as V,g as ie,W as se}from"./message-components-Cg4LI9Ou.js";import{m as gt,i as pt,r as ft,g as bt}from"./workflowChat-BJV1D-VM.js";import"./input.js";/* empty css */const yt=({selectedNodes:t,handleParamSelect:r,selectedParams:s,handleNext:l,handleClose:a})=>{const n=t.flatMap(i=>(i.widgets||[]).map(d=>d.name)).some(i=>s[i]===!0);return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select parameters"}),e.jsx("p",{className:"text-xs text-gray-500",children:"multiple selections supported"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:a,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.map((i,d)=>{const m=i.title||"Unknown Node",u=i.widgets||[];return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:m}),e.jsx("div",{className:"p-4 space-y-3",children:e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:u.map((x,g)=>{const f=x.name;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s[f]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:b=>r(f,b),children:s[f]&&e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),e.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:f})]},`widget-${g}`)})})})]},`node-${d}`)}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx("button",{onClick:i=>l(i),disabled:!n,className:`px-3 py-1.5 text-xs ${n?"bg-pink-200 text-pink-700 hover:bg-pink-300":"bg-gray-200 text-gray-500 cursor-not-allowed"} rounded-md transition-colors`,children:"Next"})})]})},jt=({selectedNodes:t,paramTestValues:r,selectedParams:s,updateParamTestValues:l,toggleDropdown:a,openDropdowns:o,handleTestValueSelect:n,searchTerms:i,handleSearch:d,handleSelectAll:m,handleNext:u,handlePrevious:x,handleClose:g,inputValues:f,setInputValues:b,textInputs:$,handleTextInputChange:k,handleAddTextInput:L,handleRemoveTextInput:P,openAiWritingModal:y})=>{const N=(p,S,O,G=0)=>{if(p=isNaN(p)?0:p,S=isNaN(S)?100:S,O=isNaN(O)||O<=0?1:O,S{!t||t.length===0||t.forEach(p=>{const S=p.id.toString(),O=p.widgets||{};Object.values(O).forEach(j=>{const E=j.name;if(!s[E])return;if(!(r[S]?.[E]?.length>0)&&j.type==="number"){const v=j.options?.min||0,T=j.options?.max||100;let I=(j.options?.step||10)/10;I<.1&&(I=.1);const _=j.options?.precision||0,B=N(v,T,I,_);if(B.length>0){l(S,E,B);const z=`${S}_${E}`;b(C=>({...C,[z]:{min:v.toString(),max:T.toString(),step:I.toString()}}))}}if(j.type==="customtext"||j.type.toLowerCase().includes("text")){const v=`${S}_${E}`,T=$[v]||[""];JSON.stringify(T)!==JSON.stringify(r[S]?.[E]||[""])&&l(S,E,T)}})})},[t,s,r,$,l,b,N]),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Set test values"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:g,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.length>0?t.map((p,S)=>{const O=p.widgets||{},G=Object.values(O),j=p.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b flex justify-between items-center",children:[e.jsxs("span",{children:[p.type," (ID: ",j,")"]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:E=>g(E,S),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-4 space-y-4",children:G.map((E,R)=>{const v=E.name;if(!s[v])return null;const T=`${j}_${v}`;if(E.type==="customtext"||E.type.toLowerCase().includes("text")){const I=$[T]||[""];return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[v,":"]}),e.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>y(j,v),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})}),"AI Writing"]})]}),e.jsx("div",{className:"space-y-2",children:I.map((_,B)=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("textarea",{className:`flex-1 border ${_?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:_,onChange:z=>k(j,v,B,z.target.value),required:!0}),e.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>P(j,v,B),title:"Remove",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},B))}),e.jsxs("button",{className:"mt-2 px-2 py-1 border border-dashed border-gray-300 rounded text-xs text-gray-600 hover:bg-gray-50 flex items-center",onClick:()=>L(j,v),children:[e.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},R)}if(E.type==="number"){const I=E.options?.min||0,_=E.options?.max||100,B=(E.options?.step||10)/10,z=E.options?.precision||0,C=N(I,_,B,z),F=f[T]||{min:I.toString(),max:_.toString(),step:B.toString()};return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[v,":"]}),e.jsx("div",{className:"w-4"})]}),e.jsxs("div",{className:"flex space-x-2 items-center",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.min,required:!0,onClick:M=>{M.preventDefault(),M.stopPropagation()},onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],min:D}})),D===""||!isNaN(parseFloat(D))){const A=D===""?0:parseFloat(D),H=parseFloat(F.max||_.toString()),U=parseFloat(F.step||B.toString()),J=N(A,H,U,z);l(j,v,J)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.max,onClick:M=>{M.preventDefault(),M.stopPropagation()},required:!0,onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],max:D}})),D===""||!isNaN(parseFloat(D))){const A=parseFloat(F.min||I.toString()),H=D===""?A:parseFloat(D),U=parseFloat(F.step||B.toString()),J=N(A,H,U,z);l(j,v,J)}}}),e.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),e.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:F.step,required:!0,onClick:M=>{M.preventDefault(),M.stopPropagation()},onChange:M=>{M.preventDefault(),M.stopPropagation();const D=M.target.value;if(b(A=>({...A,[T]:{...A[T],step:D}})),D===""||!isNaN(parseFloat(D))&&parseFloat(D)>0){const A=parseFloat(F.min||I.toString()),H=parseFloat(F.max||_.toString());let U=D===""?1:parseFloat(D);U<.1&&(U=.1);const J=N(A,H,U,z);l(j,v,J)}}})]}),e.jsxs("div",{className:"mt-1",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(()=>{const M=r[j]?.[v]||C;if(M.length<=10)return M.map((D,A)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:H=>{H.stopPropagation(),n(j,v,D,H)},children:[e.jsx("span",{children:D}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},A));{const D=M.slice(0,5),A=M.slice(M.length-5);return e.jsxs(e.Fragment,{children:[D.map((H,U)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:J=>{J.stopPropagation(),n(j,v,H,J)},children:[e.jsx("span",{children:H}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`first-${U}`)),e.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),A.map((H,U)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:J=>{J.stopPropagation(),n(j,v,H,J)},children:[e.jsx("span",{children:H}),e.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`last-${U}`))]})}})()})]}),e.jsx("div",{className:"mt-1",children:e.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max"})})]},R)}else if(E.type==="combo"){const I=E.options?.values||[],_=`${j}_${v}`,B=C=>typeof C=="string"?C:C&&typeof C=="object"&&"name"in C?C.name:String(C),z=C=>typeof C=="object"&&C!==null&&"name"in C?C.name:C;return e.jsxs("div",{className:"border-b pb-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("label",{className:"text-xs font-medium text-gray-700",children:v}),e.jsxs("div",{className:"relative dropdown-container",children:[e.jsxs("button",{className:`appearance-none border ${(r[j]?.[v]||[]).length===0?"border-red-500":"border-gray-300"} rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700`,onClick:C=>{C.preventDefault(),C.stopPropagation(),a(j,v,C)},"data-dropdown":_,children:[e.jsx("span",{children:(r[j]?.[v]||[]).length>0?`${v}: ${(r[j]?.[v]||[]).length} selected`:`Select ${v}`}),e.jsx("div",{className:"ml-2",children:e.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),o[_]&&e.jsxs("div",{className:"absolute z-[9999] mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg dropdown-menu",style:{position:"fixed",top:typeof o[_]=="object"?`${o[_].y}px`:"0px",left:typeof o[_]=="object"?`${o[_].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[e.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:e.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:i[_]||"",onChange:C=>{C.preventDefault(),C.stopPropagation(),d(j,v,C.target.value)},onClick:C=>{C.preventDefault(),C.stopPropagation()},autoFocus:!0})}),e.jsxs("div",{className:"px-3 py-1.5 bg-gray-50 border-b cursor-pointer text-xs flex items-center text-gray-700 hover:bg-gray-100",onClick:C=>{C.preventDefault(),C.stopPropagation();const M=I.filter(D=>!i[_]||B(D).toLowerCase().includes((i[_]||"").toLowerCase())).map(z);m(j,v,M)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${I.length>0&&(r[j]?.[v]||[]).length===I.length?"bg-blue-500 border-blue-500":(r[j]?.[v]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(r[j]?.[v]||[]).length>0&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"font-medium",children:I.length>0&&(r[j]?.[v]||[]).length===I.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[I.filter(C=>!i[_]||B(C).toLowerCase().includes((i[_]||"").toLowerCase())).map((C,F)=>e.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:M=>{M.preventDefault(),M.stopPropagation(),n(j,v,z(C),M)},children:[e.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(r[j]?.[v]||[]).includes(z(C))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(r[j]?.[v]||[]).includes(z(C))&&e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:B(C)})]},F)),I.filter(C=>!i[_]||B(C).toLowerCase().includes((i[_]||"").toLowerCase())).length===0&&e.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),(r[j]?.[v]||[]).length===0&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(r[j]?.[v]||[]).map((C,F)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:C}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:M=>{M.preventDefault(),M.stopPropagation(),n(j,v,C,M)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},F))})]})]},R)}else return e.jsxs("div",{className:"border-b pb-3",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx("label",{className:"text-xs font-medium text-gray-700",children:v})}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(r[j]?.[v]||[]).map((I,_)=>e.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[e.jsx("span",{children:I}),e.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:B=>{B.preventDefault(),B.stopPropagation(),n(j,v,I,B)},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},_)),e.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:I=>{I.preventDefault(),I.stopPropagation();const _=`${v}${(r[j]?.[v]||[]).length+1}`;l(j,v,[...r[j]?.[v]||[],_])},children:[e.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),e.jsx("span",{children:"Add"})]})]})]})]},R)})})]},S)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:p=>x(p),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:p=>u(p),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},vt=({selectedNodes:t,paramTestValues:r,selectedParams:s,totalCount:l,errorMessage:a,handlePrevious:o,handleStartGeneration:n,handleClose:i})=>{const[d,m]=w.useState([]),[u,x]=w.useState(null),[g,f]=w.useState(!1);ve();const b=()=>{const k=Object.values(V.graph._nodes_by_id),L=[],P=[];for(const N of k)N.type==="SaveImage"?L.push(N.id):N.type==="PreviewImage"&&P.push(N.id);const y=[...L,...P];m(y),y.length===1?x(y[0]):y.length>1&&(f(!0),x(null))};w.useEffect(()=>{b()},[]),w.useEffect(()=>{const k=()=>{if(!V.canvas.selected_nodes)return;const L=Object.values(V.canvas.selected_nodes);if(L.length===0)return;const P=L[0];P&&(P.type==="SaveImage"||P.type==="PreviewImage")&&(console.log("Selected image node:",P.id),x(P.id))};return document.addEventListener("click",k),()=>{document.removeEventListener("click",k)}},[]);const $=k=>{if(k&&(k.preventDefault(),k.stopPropagation()),d.length>1&&!u){f(!0);return}n(k,u||void 0)};return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Conform combinations"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",l," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:i,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g&&d.length>1&&e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:u===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${d.join(",")}. Please click the node on canvas.`:`Current node ID is ${u}, please click Start Generation again`})]})}),a&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:a})]})}),t.length>0?t.map((k,L)=>{const P=k.type||"Unknown Node",y=k.widgets||[],N=k.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[P," (ID: ",N,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:y.map((p,S)=>{const O=p.name;if(!s[O])return null;const G=r[N]?.[O]||[],j=Array.isArray(G)?`[${G.join(", ")}]`:JSON.stringify(G);return e.jsxs("div",{className:SE.preventDefault()})})]},S)})})]},L)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500 text-xs",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),e.jsxs("div",{className:"mt-6 flex justify-between",children:[e.jsx("button",{onClick:k=>o(k),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),e.jsx("button",{onClick:k=>$(k),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${d.length>1&&!u?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:d.length>1&&!u,children:"Generate & Compare"})]})]})},Nt=({selectedNodes:t,paramTestValues:r,selectedParams:s,totalCount:l,completedCount:a,errorMessage:o,handleClose:n,setIsProcessing:i,setCurrentScreen:d,cleanupPolling:m})=>{const u=x=>{x.preventDefault(),x.stopPropagation(),gt({clear:!0}),pt(),m&&m(),i(!1),d(2)};return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:e.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),e.jsxs("div",{className:"text-xs mb-3",children:["Completed ",a," of ",l," runs"]}),e.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${a/l*100}%`}})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",a," images"]}),e.jsx("button",{onClick:u,className:"mt-4 px-3 py-1.5 text-xs bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors",children:"Cancel"})]})}),e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",l," total runs. Each run will generate a separate image."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:n,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("div",{className:"ml-2",children:o})]})}),t.length>0?t.map((x,g)=>{const f=x.type||"Unknown Node",b=x.widgets||[],$=x.id;return e.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[e.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[f," (ID: ",$,")"]}),e.jsx("div",{className:"p-4 space-y-3",children:b.map((k,L)=>{const P=k.name;if(!s[P])return null;const y=r[$]?.[P]||[],N=Array.isArray(y)?`[${y.join(", ")}]`:JSON.stringify(y);return e.jsxs("div",{className:Lp.preventDefault()})})]},L)})})]},g)}):e.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."})]})},te=({visible:t,imageUrl:r,params:s,onClose:l})=>{if(!t)return null;const a=()=>{if(!s||!s.nodeParams)return null;const o=Object.entries(s.nodeParams).map(([n,i])=>{const d=s.nodeNames?.[n]||s.selectedNodeInfoMap&&s.selectedNodeInfoMap[n]||(n.includes("text")?"Text Node":`Node ${n}`),m=Object.entries(i).filter(([u,x])=>typeof x!="object"||x===null).map(([u,x])=>e.jsxs("div",{className:"pl-4 text-sm py-1 flex",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400 mr-2",children:"-"}),e.jsxs("span",{className:"font-medium mr-1",children:[u,":"]}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-all",children:String(x)})]},u));return e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"font-semibold text-pink-600 dark:text-pink-400 text-base py-1 border-b border-gray-200 dark:border-gray-700 mb-2",children:d}),m.length>0?m:e.jsx("div",{className:"pl-4 text-sm text-gray-500 italic",children:"nodeParams is null"})]},n)});return e.jsx("div",{className:"overflow-y-auto max-h-full",children:o.length>0?o:e.jsx("div",{className:"text-sm text-gray-500 italic",children:"nodeParams is null"})})};return e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",onClick:l,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl flex flex-row w-[90%] max-w-6xl max-h-[90vh] relative m-4 overflow-hidden",onClick:o=>o.stopPropagation(),style:{display:"flex",flexDirection:"row"},children:[e.jsx("button",{className:"absolute top-2 right-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 p-1 z-10",onClick:l,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("div",{className:"w-[65%] border-r border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"p-4 h-full flex items-center justify-center",children:e.jsx("img",{src:r,alt:"Enlarged image",className:"max-w-full max-h-[calc(90vh-2rem)] object-contain"})})}),e.jsx("div",{className:"w-[35%] h-full overflow-hidden flex flex-col",children:e.jsxs("div",{className:"p-4 flex-1 overflow-y-auto",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-800 dark:text-gray-200 mb-4",children:"Parameters"}),s&&!s.nodeParams&&Object.entries(s).filter(([o,n])=>o!=="nodeParams"&&typeof n!="object").map(([o,n])=>e.jsxs("div",{className:"py-1 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("span",{className:"font-medium",children:[o,":"]})," ",String(n)]},o)),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:a()})]})})]})})},wt=({generatedImages:t,selectedImageIndex:r,handleSelectImage:s,handleApplySelected:l,handlePrevious:a,handleClose:o,currentPage:n,handlePageChange:i,imagesPerPage:d,notificationVisible:m,modalVisible:u,modalImageUrl:x,modalImageParams:g,openImageModal:f,closeImageModal:b})=>{const $=Math.ceil(t.length/d),k=(n-1)*d,L=Math.min(k+d,t.length),P=t.slice(k,L);return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[e.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["All ",t.length," images have been generated."]})]}),e.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:o,children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m&&e.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"py-1",children:e.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),e.jsx(te,{visible:u,imageUrl:x,params:g||{},onClose:b}),e.jsx("div",{className:"grid grid-cols-3 gap-4 mb-6",children:P.map((y,N)=>{const p=k+N;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden border ${r===p?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:S=>s(p,S),children:[e.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:S=>f(y.url,y.params,S),children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),e.jsx("div",{className:"aspect-square",children:e.jsx("img",{src:y.url,alt:`Generated image ${p+1}`,className:"w-full h-full object-cover"})}),e.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(y.params).filter(([S,O])=>S!=="nodeParams"&&typeof O!="object").map(([S,O])=>e.jsxs("div",{children:[S,": ",String(O)]},S))})]},p)})}),$>1&&e.jsxs("div",{className:"flex justify-center items-center space-x-2 mt-4 mb-4",children:[e.jsx("button",{onClick:y=>i(1,y),disabled:n===1,className:`px-2 py-1 rounded ${n===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M15.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M8.707 15.707a1 1 0 01-1.414 0l-5-5a1 1 0 010-1.414l5-5a1 1 0 111.414 1.414L4.414 10l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})]})}),e.jsx("button",{onClick:y=>i(n-1,y),disabled:n===1,className:`px-2 py-1 rounded ${n===1?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"px-2 py-1 text-xs text-gray-800",children:["Page ",n," of ",$]}),e.jsx("button",{onClick:y=>i(n+1,y),disabled:n===$,className:`px-2 py-1 rounded ${n===$?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})}),e.jsx("button",{onClick:y=>i($,y),disabled:n===$,className:`px-2 py-1 rounded ${n===$?"text-gray-400 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}`,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{fillRule:"evenodd",d:"M4.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L8.586 10 4.293 14.293a1 1 0 000 1.414z",clipRule:"evenodd"}),e.jsx("path",{fillRule:"evenodd",d:"M11.293 15.707a1 1 0 001.414 0l5-5a1 1 0 000-1.414l-5-5a1 1 0 00-1.414 1.414L15.586 10l-4.293 4.293a1 1 0 000 1.414z",clipRule:"evenodd"})]})})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{onClick:y=>l(y),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:r===null,children:"Apply Selected"})})]})},kt=({visible:t,aiWritingModalText:r,setAiWritingModalText:s,aiGeneratedTexts:l,aiSelectedTexts:a,aiWritingLoading:o,aiWritingError:n,handleAiWriting:i,toggleTextSelection:d,addSelectedTexts:m,onClose:u})=>t?e.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),e.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:u,children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),e.jsx("textarea",{className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-white bg-gray-50 dark:bg-gray-700 placeholder-gray-500 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-400 diff --git a/dist/copilot_web/WorkflowOption-BtmAE9V8.js b/dist/copilot_web/WorkflowOption-X60j_dVY.js similarity index 98% rename from dist/copilot_web/WorkflowOption-BtmAE9V8.js rename to dist/copilot_web/WorkflowOption-X60j_dVY.js index 35b2b7b..4ab4053 100644 --- a/dist/copilot_web/WorkflowOption-BtmAE9V8.js +++ b/dist/copilot_web/WorkflowOption-X60j_dVY.js @@ -1,4 +1,4 @@ function getImportPath(filename) { return `./${filename}`; } - import{j as s}from"./vendor-markdown-Dek94WS0.js";import{W as x,g as j,a as d}from"./message-components-BCfBUoNX.js";import{r as P}from"./vendor-react-V04_Axys.js";function G({content:C,name:D="Assistant",avatar:H,latestInput:N,installedNodes:z,onAddMessage:y}){const _=JSON.parse(C),v=_.ext?.find(e=>e.type==="workflow")?.data||[],[p,g]=P.useState({}),W=async e=>{if(!e.id){console.error("No workflow id provided");return}const i=String(e.id);if(!p[i]){g(t=>({...t,[i]:!0})),x.trackEvent({event_type:"workflow_accept",message_type:"workflow",message_id:_.message_id,data:{workflow_id:e.id,workflow_name:e.name}});try{const t=await x.getOptimizedWorkflow(e.id,N);if(t.workflow){const r=new Set;if(t.workflow.nodes)for(const o of t.workflow.nodes)r.add(o.type);else for(const o of Object.values(t.workflow))r.add(o.class_type);const a=Array.from(r).filter(o=>!z.includes(o));if(console.log("[WorkflowOption] Missing node types:",a),a.length>0){try{console.log("[WorkflowOption] Fetching info for missing nodes");const o=await x.batchGetNodeInfo(a);console.log("[WorkflowOption] Received node infos:",o);const m={text:"",ext:[{type:"node_install_guide",data:o.map(l=>({name:l.name,repository_url:l.github_url}))}]},c={id:j(),role:"ai",content:JSON.stringify(m),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:t.workflow,optimizedParams:t.optimized_params}};y?.(c)}catch(o){console.error("[WorkflowOption] Error fetching node info:",o),alert("Error checking required nodes. Please try again.")}finally{g(o=>({...o,[i]:!1}))}return}O(t.workflow,t.optimized_params)}}catch(t){console.error("Failed to optimize workflow:",t),alert("Failed to optimize workflow. Please try again.")}finally{g(t=>({...t,[i]:!1}))}}},O=(e,i)=>{if(e.nodes)d.loadGraphData(e);else{d.loadApiJson(e);const r=Object.keys(e),a=Object.keys(d.graph._nodes_by_id)[0],o=d.graph._nodes_by_id[a],m=o?o.pos[0]:0,c=o?o.pos[1]:0,l=250,f=60,A=20,E=60,b=50,I=1e3;let k=m,h=c,u=0;for(const F of r){const n=d.graph._nodes_by_id[F];if(n){u>I&&(k+=l+E,u=0,h=c);const M=n.inputs?n.inputs.length:0,S=n.outputs?n.outputs.length:0,J=n.widgets?n.widgets.length:0,L=Math.max(M,S)+J,w=A*L+f;n.size[0]=l,n.size[1]=w,n.pos[0]=k,n.pos[1]=h,u+=w+b,h+=w+b}}}for(const[r,a,o,m,c]of i){const l=d.graph._nodes_by_id[r].widgets;for(const f of l)f.name===m&&(f.value=c)}d.graph.setDirtyCanvas(!1,!0);const t={id:j(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};y?.(t)};return s.jsx("div",{className:"space-y-3",children:v.length>0&&s.jsx("div",{className:"flex flex-col space-y-4",children:v.map((e,i)=>{const t=e.id?String(e.id):"";return s.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&s.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:r=>{const a=r.target;a.onerror=null,a.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),s.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[s.jsx("div",{children:s.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),s.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&s.jsxs("div",{className:"relative group",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),s.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:s.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),s.jsx("button",{onClick:()=>W(e),disabled:p[t],className:`px-3 py-1.5 ${p[t]?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"} text-white rounded-md transition-colors text-xs`,children:p[t]?"Loading...":"Accept"})]})]})]},i)})})})}export{G as WorkflowOption}; + import{j as s}from"./vendor-markdown-Dek94WS0.js";import{W as x,g as j,a as d}from"./message-components-Cg4LI9Ou.js";import{r as P}from"./vendor-react-V04_Axys.js";function G({content:C,name:D="Assistant",avatar:H,latestInput:N,installedNodes:z,onAddMessage:y}){const _=JSON.parse(C),v=_.ext?.find(e=>e.type==="workflow")?.data||[],[p,g]=P.useState({}),W=async e=>{if(!e.id){console.error("No workflow id provided");return}const i=String(e.id);if(!p[i]){g(t=>({...t,[i]:!0})),x.trackEvent({event_type:"workflow_accept",message_type:"workflow",message_id:_.message_id,data:{workflow_id:e.id,workflow_name:e.name}});try{const t=await x.getOptimizedWorkflow(e.id,N);if(t.workflow){const r=new Set;if(t.workflow.nodes)for(const o of t.workflow.nodes)r.add(o.type);else for(const o of Object.values(t.workflow))r.add(o.class_type);const a=Array.from(r).filter(o=>!z.includes(o));if(console.log("[WorkflowOption] Missing node types:",a),a.length>0){try{console.log("[WorkflowOption] Fetching info for missing nodes");const o=await x.batchGetNodeInfo(a);console.log("[WorkflowOption] Received node infos:",o);const m={text:"",ext:[{type:"node_install_guide",data:o.map(l=>({name:l.name,repository_url:l.github_url}))}]},c={id:j(),role:"ai",content:JSON.stringify(m),format:"markdown",name:"Assistant",metadata:{pendingWorkflow:t.workflow,optimizedParams:t.optimized_params}};y?.(c)}catch(o){console.error("[WorkflowOption] Error fetching node info:",o),alert("Error checking required nodes. Please try again.")}finally{g(o=>({...o,[i]:!1}))}return}O(t.workflow,t.optimized_params)}}catch(t){console.error("Failed to optimize workflow:",t),alert("Failed to optimize workflow. Please try again.")}finally{g(t=>({...t,[i]:!1}))}}},O=(e,i)=>{if(e.nodes)d.loadGraphData(e);else{d.loadApiJson(e);const r=Object.keys(e),a=Object.keys(d.graph._nodes_by_id)[0],o=d.graph._nodes_by_id[a],m=o?o.pos[0]:0,c=o?o.pos[1]:0,l=250,f=60,A=20,E=60,b=50,I=1e3;let k=m,h=c,u=0;for(const F of r){const n=d.graph._nodes_by_id[F];if(n){u>I&&(k+=l+E,u=0,h=c);const M=n.inputs?n.inputs.length:0,S=n.outputs?n.outputs.length:0,J=n.widgets?n.widgets.length:0,L=Math.max(M,S)+J,w=A*L+f;n.size[0]=l,n.size[1]=w,n.pos[0]=k,n.pos[1]=h,u+=w+b,h+=w+b}}}for(const[r,a,o,m,c]of i){const l=d.graph._nodes_by_id[r].widgets;for(const f of l)f.name===m&&(f.value=c)}d.graph.setDirtyCanvas(!1,!0);const t={id:j(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};y?.(t)};return s.jsx("div",{className:"space-y-3",children:v.length>0&&s.jsx("div",{className:"flex flex-col space-y-4",children:v.map((e,i)=>{const t=e.id?String(e.id):"";return s.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 hover:bg-gray-50",children:[e.image&&s.jsx("img",{src:e.image,alt:e.name,className:"w-14 h-14 object-cover rounded-lg",onError:r=>{const a=r.target;a.onerror=null,a.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none'%3E%3Crect width='56' height='56' fill='%23F3F4F6'/%3E%3Cpath d='M28 28C30.2091 28 32 26.2091 32 24C32 21.7909 30.2091 20 28 20C25.7909 20 24 21.7909 24 24C24 26.2091 25.7909 28 28 28Z' fill='%239CA3AF'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M18.7253 37.6307C19.8278 35.1533 22.6897 33.6 26 33.6H30C33.3103 33.6 36.1722 35.1533 37.2747 37.6307C37.6419 38.4561 37.0611 39.2 36.1694 39.2H19.8306C18.9389 39.2 18.3581 38.4561 18.7253 37.6307Z' fill='%239CA3AF'/%3E%3C/svg%3E"}}),s.jsxs("div",{className:"flex-1 break-words flex flex-col h-[4.5rem] justify-between",children:[s.jsx("div",{children:s.jsx("h3",{className:"font-medium text-sm line-clamp-2 h-10 overflow-hidden",children:e.name})}),s.jsxs("div",{className:"flex justify-between items-center mt-1",children:[e.description&&s.jsxs("div",{className:"relative group",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-500 cursor-help",children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})}),s.jsx("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block",children:s.jsx("div",{className:"bg-gray-900 text-white text-xs rounded-md py-2 px-3 min-w-[400px] whitespace-normal break-words",children:e.description})})]}),s.jsx("button",{onClick:()=>W(e),disabled:p[t],className:`px-3 py-1.5 ${p[t]?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"} text-white rounded-md transition-colors text-xs`,children:p[t]?"Loading...":"Accept"})]})]})]},i)})})})}export{G as WorkflowOption}; diff --git a/dist/copilot_web/input.js b/dist/copilot_web/input.js index a0b085d..a2cc054 100644 --- a/dist/copilot_web/input.js +++ b/dist/copilot_web/input.js @@ -1,7 +1,7 @@ function getImportPath(filename) { return `./${filename}`; } - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-DD4ojCC_.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-BCfBUoNX.js","copilot_web/fonts.css"].map(path => { + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/App-C-RrQ6X5.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-Cg4LI9Ou.js","copilot_web/fonts.css"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; if (apiBase) { // 有 API base 时,使用完整路径 @@ -11,4 +11,4 @@ function getImportPath(filename) { return `./${path}`; } }))))=>i.map(i=>d[i]); -import{j as s}from"./vendor-markdown-Dek94WS0.js";import{a as w,R as p,r as x}from"./vendor-react-V04_Axys.js";import{w as v,a as g}from"./message-components-BCfBUoNX.js";/* empty css */const R="modulepreload",b=function(e){return"/"+e},m={},C=function(c,a,P){let d=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(a.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const i=o.endsWith(".css"),h=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=i?"stylesheet":R,i||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),i)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function u(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&u(t.reason);return c().catch(u)})};var l={},f=w;l.createRoot=f.createRoot,l.hydrateRoot=f.hydrateRoot;const S=p.lazy(()=>C(async()=>{const{default:e}=await import(getImportPath("App-DD4ojCC_.js"));return{default:e}},__vite__mapDeps([0,1,2,3,4])).then(({default:e})=>({default:e})));function j(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}j().then(()=>v()).then(()=>{g.extensionManager.registerSidebarTab({id:"comfyui-copilot",icon:"cc-icon-logo",title:"ComfyUI Copilot",tooltip:"ComfyUI Copilot",type:"custom",render:e=>{const c=document.createElement("div");c.id="comfyui-copilot-plugin",c.className="h-full w-full flex flex-col",e.style.height="100%",e.appendChild(c),l.createRoot(c).render(s.jsx(p.StrictMode,{children:s.jsx(x.Suspense,{fallback:s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:s.jsx(S,{})})}))}})});export{C as _}; +import{j as s}from"./vendor-markdown-Dek94WS0.js";import{a as w,R as p,r as x}from"./vendor-react-V04_Axys.js";import{w as v,a as g}from"./message-components-Cg4LI9Ou.js";/* empty css */const R="modulepreload",b=function(e){return"/"+e},m={},C=function(c,a,P){let d=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),t=r?.nonce||r?.getAttribute("nonce");d=Promise.allSettled(a.map(o=>{if(o=b(o),o in m)return;m[o]=!0;const i=o.endsWith(".css"),h=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=i?"stylesheet":R,i||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),i)return new Promise((y,E)=>{n.addEventListener("load",y),n.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${o}`)))})}))}function u(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return d.then(r=>{for(const t of r||[])t.status==="rejected"&&u(t.reason);return c().catch(u)})};var l={},f=w;l.createRoot=f.createRoot,l.hydrateRoot=f.hydrateRoot;const S=p.lazy(()=>C(async()=>{const{default:e}=await import(getImportPath("App-C-RrQ6X5.js"));return{default:e}},__vite__mapDeps([0,1,2,3,4])).then(({default:e})=>({default:e})));function j(){return new Promise(e=>{if(document.body)return e(document.body);document.addEventListener("DOMContentLoaded",()=>{e(document.body)})})}j().then(()=>v()).then(()=>{g.extensionManager.registerSidebarTab({id:"comfyui-copilot",icon:"cc-icon-logo",title:"ComfyUI Copilot",tooltip:"ComfyUI Copilot",type:"custom",render:e=>{const c=document.createElement("div");c.id="comfyui-copilot-plugin",c.className="h-full w-full flex flex-col",e.style.height="100%",e.appendChild(c),l.createRoot(c).render(s.jsx(p.StrictMode,{children:s.jsx(x.Suspense,{fallback:s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:s.jsx(S,{})})}))}})});export{C as _}; diff --git a/dist/copilot_web/message-components-BCfBUoNX.js b/dist/copilot_web/message-components-Cg4LI9Ou.js similarity index 99% rename from dist/copilot_web/message-components-BCfBUoNX.js rename to dist/copilot_web/message-components-Cg4LI9Ou.js index 2dd8fba..b4bc603 100644 --- a/dist/copilot_web/message-components-BCfBUoNX.js +++ b/dist/copilot_web/message-components-Cg4LI9Ou.js @@ -1,7 +1,7 @@ function getImportPath(filename) { return `./${filename}`; } - import{r as We,R as eI}from"./vendor-react-V04_Axys.js";import{j as S,M as tI,r as rI,a as iI,b as nI,c as aI}from"./vendor-markdown-Dek94WS0.js";let Mt=null;const mp=location.pathname.split("/").slice(0,-1).join("/");let oI=null;async function Mpe(){try{await Promise.all([import(mp+"/scripts/api.js").then(i=>{oI=i?.api}),import(mp+"/scripts/app.js").then(i=>{Mt=i?.app})])}catch(i){console.error("waitForApp error",i)}}const W$={messages:[],selectedNode:null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null};function sI(i,r){switch(r.type){case"SET_MESSAGES":return{...i,messages:r.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,r.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(e=>e.id===r.payload.id&&!e.finished?r.payload:e)};case"SET_SELECTED_NODE":return{...i,selectedNode:r.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:r.payload};case"SET_LOADING":return{...i,loading:r.payload};case"SET_SESSION_ID":return{...i,sessionId:r.payload};case"SET_SHOW_CHAT":return{...i,showChat:r.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:r.payload};case"SET_SCREEN_STATE":return{...i,screenState:r.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const U$=We.createContext({state:W$,dispatch:()=>null});function Bpe({children:i}){const[r,e]=We.useReducer(sI,W$);return eI.useEffect(()=>{r.sessionId&&r.messages.length>0&&localStorage.setItem(`messages_${r.sessionId}`,JSON.stringify(r.messages))},[r.messages,r.sessionId]),S.jsx(U$.Provider,{value:{state:r,dispatch:e},children:i})}function uI(){const i=We.useContext(U$);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const Ff={apiBaseUrl:"https://comfyui-copilot-server-pre.onrender.com"};function dr(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const r=Math.random()*16|0;return(i==="x"?r:r&3|8).toString(16)})}var lI="0123456789abcdefghijklmnopqrstuvwxyz";function Or(i){return lI.charAt(i)}function hI(i,r){return i&r}function ys(i,r){return i|r}function bp(i,r){return i^r}function $p(i,r){return i&~r}function cI(i){if(i==0)return-1;var r=0;return i&65535||(i>>=16,r+=16),i&255||(i>>=8,r+=8),i&15||(i>>=4,r+=4),i&3||(i>>=2,r+=2),i&1||++r,r}function dI(i){for(var r=0;i!=0;)i&=i-1,++r;return r}var Pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K$="=";function Iu(i){var r,e,t="";for(r=0;r+3<=i.length;r+=3)e=parseInt(i.substring(r,r+3),16),t+=Pn.charAt(e>>6)+Pn.charAt(e&63);for(r+1==i.length?(e=parseInt(i.substring(r,r+1),16),t+=Pn.charAt(e<<2)):r+2==i.length&&(e=parseInt(i.substring(r,r+2),16),t+=Pn.charAt(e>>2)+Pn.charAt((e&3)<<4));(t.length&3)>0;)t+=K$;return t}function wp(i){var r="",e,t=0,n=0;for(e=0;e>2),n=a&3,t=1):t==1?(r+=Or(n<<2|a>>4),n=a&15,t=2):t==2?(r+=Or(n),r+=Or(a>>2),n=a&3,t=3):(r+=Or(n<<2|a>>4),r+=Or(a&15),t=0))}return t==1&&(r+=Or(n<<2)),r}var pn,fI={decode:function(i){var r;if(pn===void 0){var e="0123456789ABCDEF",t=` \f + import{r as We,R as eI}from"./vendor-react-V04_Axys.js";import{j as S,M as tI,r as rI,a as iI,b as nI,c as aI}from"./vendor-markdown-Dek94WS0.js";let Mt=null;const mp=location.pathname.split("/").slice(0,-1).join("/");let oI=null;async function Mpe(){try{await Promise.all([import(mp+"/scripts/api.js").then(i=>{oI=i?.api}),import(mp+"/scripts/app.js").then(i=>{Mt=i?.app})])}catch(i){console.error("waitForApp error",i)}}const W$={messages:[],selectedNode:null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null};function sI(i,r){switch(r.type){case"SET_MESSAGES":return{...i,messages:r.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,r.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(e=>e.id===r.payload.id&&!e.finished?r.payload:e)};case"SET_SELECTED_NODE":return{...i,selectedNode:r.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:r.payload};case"SET_LOADING":return{...i,loading:r.payload};case"SET_SESSION_ID":return{...i,sessionId:r.payload};case"SET_SHOW_CHAT":return{...i,showChat:r.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:r.payload};case"SET_SCREEN_STATE":return{...i,screenState:r.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const U$=We.createContext({state:W$,dispatch:()=>null});function Bpe({children:i}){const[r,e]=We.useReducer(sI,W$);return eI.useEffect(()=>{r.sessionId&&r.messages.length>0&&localStorage.setItem(`messages_${r.sessionId}`,JSON.stringify(r.messages))},[r.messages,r.sessionId]),S.jsx(U$.Provider,{value:{state:r,dispatch:e},children:i})}function uI(){const i=We.useContext(U$);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const Ff={apiBaseUrl:"https://comfyui-copilot-server.onrender.com"};function dr(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const r=Math.random()*16|0;return(i==="x"?r:r&3|8).toString(16)})}var lI="0123456789abcdefghijklmnopqrstuvwxyz";function Or(i){return lI.charAt(i)}function hI(i,r){return i&r}function ys(i,r){return i|r}function bp(i,r){return i^r}function $p(i,r){return i&~r}function cI(i){if(i==0)return-1;var r=0;return i&65535||(i>>=16,r+=16),i&255||(i>>=8,r+=8),i&15||(i>>=4,r+=4),i&3||(i>>=2,r+=2),i&1||++r,r}function dI(i){for(var r=0;i!=0;)i&=i-1,++r;return r}var Pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K$="=";function Iu(i){var r,e,t="";for(r=0;r+3<=i.length;r+=3)e=parseInt(i.substring(r,r+3),16),t+=Pn.charAt(e>>6)+Pn.charAt(e&63);for(r+1==i.length?(e=parseInt(i.substring(r,r+1),16),t+=Pn.charAt(e<<2)):r+2==i.length&&(e=parseInt(i.substring(r,r+2),16),t+=Pn.charAt(e>>2)+Pn.charAt((e&3)<<4));(t.length&3)>0;)t+=K$;return t}function wp(i){var r="",e,t=0,n=0;for(e=0;e>2),n=a&3,t=1):t==1?(r+=Or(n<<2|a>>4),n=a&15,t=2):t==2?(r+=Or(n),r+=Or(a>>2),n=a&3,t=3):(r+=Or(n<<2|a>>4),r+=Or(a&15),t=0))}return t==1&&(r+=Or(n<<2)),r}var pn,fI={decode:function(i){var r;if(pn===void 0){var e="0123456789ABCDEF",t=` \f \r  \u2028\u2029`;for(pn={},r=0;r<16;++r)pn[e.charAt(r)]=r;for(e=e.toLowerCase(),r=10;r<16;++r)pn[e.charAt(r)]=r;for(r=0;r=2?(n[n.length]=a,a=0,o=0):a<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},Ii,wd={decode:function(i){var r;if(Ii===void 0){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=`= \f \r  \u2028\u2029`;for(Ii=Object.create(null),r=0;r<64;++r)Ii[e.charAt(r)]=r;for(Ii["-"]=62,Ii._=63,r=0;r=4?(n[n.length]=a>>16,n[n.length]=a>>8&255,n[n.length]=a&255,a=0,o=0):a<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=a>>10;break;case 3:n[n.length]=a>>16,n[n.length]=a>>8&255;break}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(i){var r=wd.re.exec(i);if(r)if(r[1])i=r[1];else if(r[2])i=r[2];else throw new Error("RegExp out of sync");return wd.decode(i)}},gn=1e13,Ua=function(){function i(r){this.buf=[+r||0]}return i.prototype.mulAdd=function(r,e){var t=this.buf,n=t.length,a,o;for(a=0;a0&&(t[a]=e)},i.prototype.sub=function(r){var e=this.buf,t=e.length,n,a;for(n=0;n=0;--n)t+=(gn+e[n]).toString().substring(1);return t},i.prototype.valueOf=function(){for(var r=this.buf,e=0,t=r.length-1;t>=0;--t)e=e*gn+r[t];return e},i.prototype.simplify=function(){var r=this.buf;return r.length==1?r[0]:this},i}(),G$="…",vI=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,pI=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Wn(i,r){return i.length>r&&(i=i.substring(0,r)+G$),i}var nh=function(){function i(r,e){this.hexDigits="0123456789ABCDEF",r instanceof i?(this.enc=r.enc,this.pos=r.pos):(this.enc=r,this.pos=e)}return i.prototype.get=function(r){if(r===void 0&&(r=this.pos++),r>=this.enc.length)throw new Error("Requesting byte offset ".concat(r," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(r):this.enc[r]},i.prototype.hexByte=function(r){return this.hexDigits.charAt(r>>4&15)+this.hexDigits.charAt(r&15)},i.prototype.hexDump=function(r,e,t){for(var n="",a=r;a176)return!1}return!0},i.prototype.parseStringISO=function(r,e){for(var t="",n=r;n191&&a<224?t+=String.fromCharCode((a&31)<<6|this.get(n++)&63):t+=String.fromCharCode((a&15)<<12|(this.get(n++)&63)<<6|this.get(n++)&63)}return t},i.prototype.parseStringBMP=function(r,e){for(var t="",n,a,o=r;o127,a=n?255:0,o,s="";t==a&&++r4){for(s=t,o<<=3;!((+s^a)&128);)s=+s<<1,--o;s="("+o+` bit) diff --git a/dist/copilot_web/workflowChat-GY-DLogc.js b/dist/copilot_web/workflowChat-BJV1D-VM.js similarity index 99% rename from dist/copilot_web/workflowChat-GY-DLogc.js rename to dist/copilot_web/workflowChat-BJV1D-VM.js index 8b5969c..5f7235b 100644 --- a/dist/copilot_web/workflowChat-GY-DLogc.js +++ b/dist/copilot_web/workflowChat-BJV1D-VM.js @@ -1,7 +1,7 @@ function getImportPath(filename) { return `./${filename}`; } - const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-BtmAE9V8.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-BCfBUoNX.js","copilot_web/ParameterDebugInterfaceV2-BeDd4UDV.js","copilot_web/input.js","copilot_web/assets/input-l5zbI7RM.css","copilot_web/fonts.css"].map(path => { + const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-X60j_dVY.js","copilot_web/vendor-markdown-Dek94WS0.js","copilot_web/vendor-react-V04_Axys.js","copilot_web/message-components-Cg4LI9Ou.js","copilot_web/ParameterDebugInterfaceV2-DMoq59aG.js","copilot_web/input.js","copilot_web/assets/input-l5zbI7RM.css","copilot_web/fonts.css"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; if (apiBase) { // 有 API base 时,使用完整路径 @@ -11,7 +11,7 @@ function getImportPath(filename) { return `./${path}`; } }))))=>i.map(i=>d[i]); -import{_ as Bt}from"./input.js";import{j as h,r as xg,b as yg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as An,c as Ut}from"./vendor-react-V04_Axys.js";import{f as wg,v as bg,W as mt,a as je,B as Sg,U as Ag,A as Rr,b as Eg,g as tn,c as Ft,u as ts,M as Ig}from"./message-components-BCfBUoNX.js";/** +import{_ as Bt}from"./input.js";import{j as h,r as xg,b as yg}from"./vendor-markdown-Dek94WS0.js";import{r as I,R as An,c as Ut}from"./vendor-react-V04_Axys.js";import{f as wg,v as bg,W as mt,a as je,B as Sg,U as Ag,A as Rr,b as Eg,g as tn,c as Ft,u as ts,M as Ig}from"./message-components-Cg4LI9Ou.js";/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. @@ -116,7 +116,7 @@ ${J.join(` hover:bg-gray-50`,children:"Close"})})]})})]})}function Zg(m){const w=m[0],u=new Set;function j(D,A){if(!(!D||A>=1)&&D.inputs)for(const U of Object.values(D.inputs)){const ie=U.link;if(ie&&je.graph.links[ie]){const y=je.graph.links[ie].origin_id,Y=je.graph._nodes_by_id[y];Y&&(u.add(Y.type),j(Y,A+1))}}}return w?(j(w,0),[{type:"upstream_node_types",data:Array.from(u)}]):null}function Jg({nodeInfo:m,onSendWithIntent:w,loading:u,onSendWithContent:j}){return console.log("SelectedNodeInfo nodeInfo:",m[0]),h.jsx("div",{className:"mb-3 p-3 rounded-md bg-gray-50 border border-gray-200",children:h.jsxs("div",{className:"text-sm text-gray-700",children:[h.jsxs("p",{children:["Selected node: ",m[0].type]}),h.jsxs("div",{className:"flex gap-2 mt-2",children:[h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-blue-50 text-blue-700 hover:bg-blue-100`,onClick:()=>j(`Reply in ${navigator.language} language: How does the ${m[0].type} node work? I need its official usage guide.`),disabled:u,children:"Usage"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-green-100 text-green-700 hover:bg-green-200`,onClick:()=>j(`Reply in ${navigator.language} language: Show me the technical specifications for the ${m[0].type} node's inputs and outputs.`),disabled:u,children:"Parameters"}),h.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-purple-100 - text-purple-700 hover:bg-purple-200`,onClick:()=>w("downstream_subgraph_search",Zg(m)),disabled:u,children:"Downstream Nodes"})]})]})})}function Yg(){return h.jsx(Sg,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Xg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Qg=I.lazy(()=>Bt(()=>import(getImportPath("WorkflowOption-BtmAE9V8.js")),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Vg=I.lazy(()=>Bt(()=>import(getImportPath("message-components-BCfBUoNX.js")).then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),ep=I.lazy(()=>Bt(()=>import(getImportPath("message-components-BCfBUoNX.js")).then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),np=I.lazy(()=>Bt(()=>import(getImportPath("message-components-BCfBUoNX.js")).then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function tp({messages:m,latestInput:w,onOptionClick:u,installedNodes:j,onAddMessage:D,loading:A}){const U=An.useMemo(()=>y=>{if(y.role==="user")return h.jsx(Ag,{content:y.content,trace_id:y.trace_id},y.id);if(y.role==="ai"||y.role==="tool"){const Y=Xg(y.role);try{const Z=JSON.parse(y.content),F=Z.ext?.find(T=>T.type==="workflow"),pe=Z.ext?.find(T=>T.type==="node"),ae=Z.ext?.find(T=>T.type==="downstream_subgraph_search"),ce=Z.ext?.find(T=>T.type==="node_install_guide");let he=null;if(F)he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:y.content,name:y.name,avatar:Y,latestInput:w,installedNodes:j,onAddMessage:D})});else if(pe)he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:y.content,name:y.name,avatar:Y,installedNodes:j})});else if(ae){const T=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:y.content,name:y.name,avatar:Y,onAddMessage:D})});if(y.metadata?.intent==="downstream_subgraph_search")return h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,extComponent:T,metadata:y.metadata},y.id);he=T}else ce&&(he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(np,{content:y.content,onLoadSubgraph:()=>{if(y.metadata?.pendingSubgraph){const T=Object.values(je.canvas.selected_nodes)[0];if(T){const _e=y.metadata.pendingSubgraph,k=_e.json.nodes,J=_e.json.links,me=k.find(q=>q.id===0),z=me?.id,K={};z&&(K[z]=T),je.canvas.emitBeforeChange();try{for(const q of k)if(q.id!==z){const xe=me?.pos||[0,0],le=T._pos||[0,0],fn=[q.pos[0]+le[0]-xe[0],q.pos[1]+le[1]-xe[1]];K[q.id]=Eg(q.type,{pos:fn})}}finally{je.canvas.emitAfterChange()}for(const q of J){const xe=K[q.origin_id],le=K[q.target_id];xe&&le&&xe.connect(q.origin_slot,le,q.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(y.metadata?.pendingWorkflow){const T=y.metadata.pendingWorkflow,_e=y.metadata.optimizedParams;if(T.nodes)je.loadGraphData(T);else{je.loadApiJson(T);const J=Object.keys(T),me=Object.keys(je.graph._nodes_by_id)[0],z=je.graph._nodes_by_id[me],K=z?z.pos[0]:0,q=z?z.pos[1]:0,xe=250,le=60,fn=20,xt=60,Un=50,ye=1e3;let Bn=K,En=q,cn=0;for(const In of J){const ve=je.graph._nodes_by_id[In];if(ve){cn>ye&&(Bn+=xe+xt,cn=0,En=q);const et=ve.inputs?ve.inputs.length:0,Cn=ve.outputs?ve.outputs.length:0,ke=ve.widgets?ve.widgets.length:0,yt=Math.max(et,Cn)+ke,Fn=fn*yt+le;ve.size[0]=xe,ve.size[1]=Fn,ve.pos[0]=Bn,ve.pos[1]=En,cn+=Fn+Un,En+=Fn+Un}}}for(const[J,me,z,K,q]of _e){const xe=je.graph._nodes_by_id[J].widgets;for(const le of xe)le.name===K&&(le.value=q)}je.graph.setDirtyCanvas(!1,!0);const k={id:tn(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};D?.(k)}}})}));return Z.text||he?h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,extComponent:he,metadata:y.metadata},y.id):he||h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,metadata:y.metadata},y.id)}catch(Z){return console.error("[MessageList] Error parsing message content:",Z),console.error("解析JSON失败",y.content),h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,metadata:y.metadata},y.id)}}return null},[j,u,D,w]),ie=An.useMemo(()=>m?.map(U),[m,U]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[ie,A&&h.jsx(Yg,{})]})}async function rp(){try{return await(await Ft.fetchApi("/object_info",{method:"GET"})).json()}catch(m){throw console.error("Error fetching object info:",m),m}}async function ip(){const m=await rp();return Object.keys(m)}async function gp(m){return await(await Ft.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function pp(m){try{const w=await Ft.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!w.ok)throw new Error(`Failed to manage queue: ${w.status} ${w.statusText}`);return w}catch(w){throw console.error("Error managing queue:",w),w}}async function _p(){try{const m=await Ft.fetchApi("/interrupt",{method:"POST"});if(!m.ok)throw new Error(`Failed to interrupt processing: ${m.status} ${m.statusText}`);return m}catch(m){throw console.error("Error interrupting processing:",m),m}}async function vp(m){try{const w=await Ft.fetchApi(`/history/${m}`,{method:"GET"});if(!w.ok)throw new Error(`Failed to fetch history: ${w.status} ${w.statusText}`);return await w.json()}catch(w){throw console.error("Error fetching history:",w),w}}var Or={exports:{}};/** + text-purple-700 hover:bg-purple-200`,onClick:()=>w("downstream_subgraph_search",Zg(m)),disabled:u,children:"Downstream Nodes"})]})]})})}function Yg(){return h.jsx(Sg,{name:"Assistant",children:h.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[h.jsxs("div",{className:"flex space-x-1",children:[h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Xg=m=>`https://ui-avatars.com/api/?name=${m||"User"}&background=random`,Qg=I.lazy(()=>Bt(()=>import(getImportPath("WorkflowOption-X60j_dVY.js")),__vite__mapDeps([0,1,2,3])).then(m=>({default:m.WorkflowOption}))),Vg=I.lazy(()=>Bt(()=>import(getImportPath("message-components-Cg4LI9Ou.js")).then(m=>m.N),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeSearch}))),ep=I.lazy(()=>Bt(()=>import(getImportPath("message-components-Cg4LI9Ou.js")).then(m=>m.D),__vite__mapDeps([3,2,1])).then(m=>({default:m.DownstreamSubgraphs}))),np=I.lazy(()=>Bt(()=>import(getImportPath("message-components-Cg4LI9Ou.js")).then(m=>m.d),__vite__mapDeps([3,2,1])).then(m=>({default:m.NodeInstallGuide})));function tp({messages:m,latestInput:w,onOptionClick:u,installedNodes:j,onAddMessage:D,loading:A}){const U=An.useMemo(()=>y=>{if(y.role==="user")return h.jsx(Ag,{content:y.content,trace_id:y.trace_id},y.id);if(y.role==="ai"||y.role==="tool"){const Y=Xg(y.role);try{const Z=JSON.parse(y.content),F=Z.ext?.find(T=>T.type==="workflow"),pe=Z.ext?.find(T=>T.type==="node"),ae=Z.ext?.find(T=>T.type==="downstream_subgraph_search"),ce=Z.ext?.find(T=>T.type==="node_install_guide");let he=null;if(F)he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Qg,{content:y.content,name:y.name,avatar:Y,latestInput:w,installedNodes:j,onAddMessage:D})});else if(pe)he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(Vg,{content:y.content,name:y.name,avatar:Y,installedNodes:j})});else if(ae){const T=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(ep,{content:y.content,name:y.name,avatar:Y,onAddMessage:D})});if(y.metadata?.intent==="downstream_subgraph_search")return h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,extComponent:T,metadata:y.metadata},y.id);he=T}else ce&&(he=h.jsx(I.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(np,{content:y.content,onLoadSubgraph:()=>{if(y.metadata?.pendingSubgraph){const T=Object.values(je.canvas.selected_nodes)[0];if(T){const _e=y.metadata.pendingSubgraph,k=_e.json.nodes,J=_e.json.links,me=k.find(q=>q.id===0),z=me?.id,K={};z&&(K[z]=T),je.canvas.emitBeforeChange();try{for(const q of k)if(q.id!==z){const xe=me?.pos||[0,0],le=T._pos||[0,0],fn=[q.pos[0]+le[0]-xe[0],q.pos[1]+le[1]-xe[1]];K[q.id]=Eg(q.type,{pos:fn})}}finally{je.canvas.emitAfterChange()}for(const q of J){const xe=K[q.origin_id],le=K[q.target_id];xe&&le&&xe.connect(q.origin_slot,le,q.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(y.metadata?.pendingWorkflow){const T=y.metadata.pendingWorkflow,_e=y.metadata.optimizedParams;if(T.nodes)je.loadGraphData(T);else{je.loadApiJson(T);const J=Object.keys(T),me=Object.keys(je.graph._nodes_by_id)[0],z=je.graph._nodes_by_id[me],K=z?z.pos[0]:0,q=z?z.pos[1]:0,xe=250,le=60,fn=20,xt=60,Un=50,ye=1e3;let Bn=K,En=q,cn=0;for(const In of J){const ve=je.graph._nodes_by_id[In];if(ve){cn>ye&&(Bn+=xe+xt,cn=0,En=q);const et=ve.inputs?ve.inputs.length:0,Cn=ve.outputs?ve.outputs.length:0,ke=ve.widgets?ve.widgets.length:0,yt=Math.max(et,Cn)+ke,Fn=fn*yt+le;ve.size[0]=xe,ve.size[1]=Fn,ve.pos[0]=Bn,ve.pos[1]=En,cn+=Fn+Un,En+=Fn+Un}}}for(const[J,me,z,K,q]of _e){const xe=je.graph._nodes_by_id[J].widgets;for(const le of xe)le.name===K&&(le.value=q)}je.graph.setDirtyCanvas(!1,!0);const k={id:tn(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};D?.(k)}}})}));return Z.text||he?h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,extComponent:he,metadata:y.metadata},y.id):he||h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,metadata:y.metadata},y.id)}catch(Z){return console.error("[MessageList] Error parsing message content:",Z),console.error("解析JSON失败",y.content),h.jsx(Rr,{content:y.content,name:y.name,avatar:Y,format:y.format,onOptionClick:u,metadata:y.metadata},y.id)}}return null},[j,u,D,w]),ie=An.useMemo(()=>m?.map(U),[m,U]);return h.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[ie,A&&h.jsx(Yg,{})]})}async function rp(){try{return await(await Ft.fetchApi("/object_info",{method:"GET"})).json()}catch(m){throw console.error("Error fetching object info:",m),m}}async function ip(){const m=await rp();return Object.keys(m)}async function gp(m){return await(await Ft.fetchApi("/prompt",{method:"POST",body:JSON.stringify(m)})).json()}async function pp(m){try{const w=await Ft.fetchApi("/queue",{method:"POST",body:JSON.stringify(m)});if(!w.ok)throw new Error(`Failed to manage queue: ${w.status} ${w.statusText}`);return w}catch(w){throw console.error("Error managing queue:",w),w}}async function _p(){try{const m=await Ft.fetchApi("/interrupt",{method:"POST"});if(!m.ok)throw new Error(`Failed to interrupt processing: ${m.status} ${m.statusText}`);return m}catch(m){throw console.error("Error interrupting processing:",m),m}}async function vp(m){try{const w=await Ft.fetchApi(`/history/${m}`,{method:"GET"});if(!w.ok)throw new Error(`Failed to fetch history: ${w.status} ${w.statusText}`);return await w.json()}catch(w){throw console.error("Error fetching history:",w),w}}var Or={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors @@ -142,4 +142,4 @@ __p += '`),H&&(v+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+v+`return __p -}`;var W=Tu(function(){return X(o,S+"return "+v).apply(u,a)});if(W.source=v,Ki(W))throw W;return W}function I0(e){return Q(e).toLowerCase()}function C0(e){return Q(e).toUpperCase()}function N0(e,n,t){if(e=Q(e),e&&(t||n===u))return Us(e);if(!e||!(n=Ke(n)))return e;var r=on(e),i=on(n),o=Bs(r,i),a=Fs(r,i)+1;return kn(r,o,a).join("")}function L0(e,n,t){if(e=Q(e),e&&(t||n===u))return e.slice(0,Gs(e)+1);if(!e||!(n=Ke(n)))return e;var r=on(e),i=Fs(r,on(n))+1;return kn(r,0,i).join("")}function T0(e,n,t){if(e=Q(e),e&&(t||n===u))return e.replace(Kr,"");if(!e||!(n=Ke(n)))return e;var r=on(e),i=Bs(r,on(n));return kn(r,i).join("")}function R0(e,n){var t=fn,r=xt;if(ue(n)){var i="separator"in n?n.separator:i;t="length"in n?P(n.length):t,r="omission"in n?Ke(n.omission):r}e=Q(e);var o=e.length;if(ot(e)){var a=on(e);o=a.length}if(t>=o)return e;var l=t-ut(r);if(l<1)return r;var c=a?kn(a,0,l).join(""):e.slice(0,l);if(i===u)return c+r;if(a&&(l+=c.length-l),$i(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=ui(i.source,Q(os.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===u?l:v)}}else if(e.indexOf(Ke(i),l)!=l){var x=c.lastIndexOf(i);x>-1&&(c=c.slice(0,x))}return c+r}function O0(e){return e=Q(e),e&&Gu.test(e)?e.replace(rs,ol):e}var M0=gt(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Zi=Ro("toUpperCase");function Lu(e,n,t){return e=Q(e),n=t?u:n,n===u?nl(e)?ll(e):Ha(e):e.match(n)||[]}var Tu=B(function(e,n){try{return Ge(e,u,n)}catch(t){return Ki(t)?t:new O(t)}}),D0=xn(function(e,n){return Je(n,function(t){t=gn(t),vn(e,t,Gi(e[t],e))}),e});function P0(e){var n=e==null?0:e.length,t=C();return e=n?se(e,function(r){if(typeof r[1]!="function")throw new Ye(U);return[t(r[0]),r[1]]}):[],B(function(r){for(var i=-1;++ive)return[];var t=ke,r=Re(e,ke);n=C(n),e-=ke;for(var i=ii(r,n);++t0||n<0)?new $(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==u&&(n=P(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},$.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},$.prototype.toArray=function(){return this.take(ke)},hn($.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof $,p=l[0],_=c||M(a),v=function(G){var H=i.apply(s,Tn([G],l));return r&&x?H[0]:H};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var x=this.__chain__,S=!!this.__actions__.length,N=o&&!x,W=c&&!S;if(!o&&_){a=W?a:new $(this);var L=e.apply(a,l);return L.__actions__.push({func:Sr,args:[v],thisArg:u}),new Xe(L,x)}return N&&W?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),Je(["pop","push","shift","sort","splice","unshift"],function(e){var n=Jt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(M(o)?o:[],i)}return this[t](function(a){return n.apply(M(a)?a:[],i)})}}),hn($.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";V.call(ct,r)||(ct[r]=[]),ct[r].push({name:n,func:t})}}),ct[_r(u,_e).name]=[{name:"wrapper",func:u}],$.prototype.clone=Rl,$.prototype.reverse=Ol,$.prototype.value=Ml,s.prototype.at=lh,s.prototype.chain=fh,s.prototype.commit=ch,s.prototype.next=hh,s.prototype.plant=gh,s.prototype.reverse=ph,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=_h,s.prototype.first=s.prototype.head,At&&(s.prototype[At]=dh),s},at=fl();Kn?((Kn.exports=at)._=at,Yr._=at):Ie._=at}).call(Ut)})(Or,Or.exports);var ku=Or.exports;function sp(m=!0){I.useEffect(()=>{if(!m)return;const w=ku.debounce(u=>{document.documentElement.style.setProperty("--mouse-x",`${u.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${u.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function op(m=!0){const{state:w,dispatch:u}=ts(),{activeTab:j,screenState:D}=w;I.useEffect(()=>{if(!m)return;const A=U=>{const ie=j==="parameter-debug",y=j==="chat",Y=!D||D.currentScreen===0;if(y||Y&&ie){const Z=je.canvas.selected_nodes;Object.keys(Z??{}).length?u({type:"SET_SELECTED_NODE",payload:Object.values(Z)}):u({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",A),()=>{document.removeEventListener("click",A)}},[u,m,j,D])}const up=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(Ig,{rehypePlugins:[[xg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[yg],className:"prose !text-[11px] prose-a:text-amber-700 prose-a:underline prose-a:font-medium hover:prose-a:text-amber-800",components:{a:({node:u,...j})=>h.jsx("a",{...j,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:u})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:u}),span:({children:u})=>h.jsx("span",{style:{fontSize:"11px"},children:u}),li:({children:u})=>h.jsx("li",{style:{fontSize:"11px"},children:u}),ul:({children:u})=>h.jsx("ul",{style:{fontSize:"11px"},children:u}),ol:({children:u})=>h.jsx("ol",{style:{fontSize:"11px"},children:u})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,ap=()=>{const{state:m,dispatch:w}=ts(),{selectedNode:u,screenState:j}=m,D=u||[],A=An.lazy(()=>Bt(()=>import(getImportPath("ParameterDebugInterfaceV2-BeDd4UDV.js")),__vite__mapDeps([4,1,2,3,5,6,7])).then(ie=>({default:ie.ParameterDebugInterface}))),U=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(An.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(A,{selectedNodes:D,visible:!0,onClose:U})})})},Du=({active:m,onClick:w,children:u})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-xs transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:u});function lp({onClose:m,visible:w=!0,triggerUsage:u=!1,onUsageTriggered:j}){const{state:D,dispatch:A}=ts(),{messages:U,installedNodes:ie,loading:y,sessionId:Y,selectedNode:Z,activeTab:F}=D,pe=I.useRef(null),[ae,ce]=I.useState(""),[he,T]=I.useState(""),[_e,k]=I.useState(window.innerWidth/3),[J,me]=I.useState(!1),[z,K]=I.useState([]),[q,xe]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[le,fn]=I.useState(""),[xt,Un]=I.useState(!1),ye=I.useRef(null);sp(w&&F==="chat"),op(w),I.useEffect(()=>{pe.current&&(pe.current.scrollTop=pe.current.scrollHeight)},[U]),I.useEffect(()=>{if(F!=="chat")return;(async()=>{const R=await ip();console.log("[WorkflowChat] Received installed nodes:",R.length),A({type:"SET_INSTALLED_NODES",payload:R})})()},[F]);const Bn=async E=>{try{const R=await mt.fetchMessages(E);A({type:"SET_MESSAGES",payload:R})}catch(R){console.error("Error fetching messages:",R)}};I.useEffect(()=>{if(F!=="chat")return;let E=localStorage.getItem("sessionId");E?(A({type:"SET_SESSION_ID",payload:E}),Bn(E)):(E=tn(),A({type:"SET_SESSION_ID",payload:E}),localStorage.setItem("sessionId",E))},[F]),I.useEffect(()=>{const E=localStorage.getItem("activeTab");E&&A({type:"SET_ACTIVE_TAB",payload:E});const R=localStorage.getItem("screenState");R&&A({type:"SET_SCREEN_STATE",payload:JSON.parse(R)})},[]),I.useEffect(()=>{localStorage.setItem("activeTab",F)},[F]),I.useEffect(()=>{D.screenState&&localStorage.setItem("screenState",JSON.stringify(D.screenState))},[D.screenState]);const En=An.useCallback(E=>{if(!J)return;const R=window.innerWidth-E.clientX,te=Math.min(Math.max(300,R),window.innerWidth*.8);k(te)},[J]),cn=An.useMemo(()=>ku.debounce(En,16),[En]);I.useEffect(()=>(J&&(document.addEventListener("mousemove",cn),document.addEventListener("mouseup",Gt)),()=>{document.removeEventListener("mousemove",cn),document.removeEventListener("mouseup",Gt),cn.cancel()}),[J,cn]);const In=E=>{ce(E.target.value)},ve=()=>{ye.current&&(ye.current.abort(),ye.current=null,A({type:"SET_LOADING",payload:!1}))},et=async()=>{if(A({type:"SET_LOADING",payload:!0}),ae.trim()===""&&!Z||!Y)return;T(ae);const E=tn(),R={id:tn(),role:"user",content:ae,trace_id:E};A({type:"ADD_MESSAGE",payload:R}),ce(""),ye.current=new AbortController;try{const te={type:"model_select",data:[q]};let Ae=tn(),Ne=!0;for await(const Le of mt.streamInvokeServer(Y,ae,z.map(Te=>Te.file),null,te,E,ye.current.signal)){const Te={id:Ae,role:"ai",content:JSON.stringify(Le),format:Le.format,finished:Le.finished,name:"Assistant"};if(Ne)A({type:"ADD_MESSAGE",payload:Te}),Ne=!1;else{A({type:"UPDATE_MESSAGE",payload:Te});const we=D.messages.map(oe=>oe.id===Te.id&&!oe.finished?Te:oe);rn(we)}Le.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(te){te instanceof Error&&te.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",te),A({type:"SET_LOADING",payload:!1}),ye.current=null}finally{K([])}},Cn=async E=>{if(!Y)return;A({type:"SET_LOADING",payload:!0}),T(E);const R=tn(),te={id:tn(),role:"user",content:E,trace_id:R};A({type:"ADD_MESSAGE",payload:te}),ye.current=new AbortController;try{const Ae={type:"model_select",data:[q]};let Ne=tn(),Le=!0;for await(const Te of mt.streamInvokeServer(Y,E,z.map(we=>we.file),null,Ae,R,ye.current.signal)){const we={id:Ne,role:"ai",content:JSON.stringify(Te),format:Te.format,finished:Te.finished,name:"Assistant"};if(Le)A({type:"ADD_MESSAGE",payload:we}),Le=!1;else{A({type:"UPDATE_MESSAGE",payload:we});const oe=D.messages.map(sn=>sn.id===we.id&&!sn.finished?we:sn);rn(oe)}Te.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(Ae){Ae instanceof Error&&Ae.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Ae),A({type:"SET_LOADING",payload:!1}),ye.current=null}finally{K([])}},ke=E=>{E.metaKey&&E.key==="Enter"&&et()},yt=()=>{A({type:"CLEAR_MESSAGES"});const E=D.sessionId;E&&localStorage.removeItem(`messages_${E}`),localStorage.removeItem("sessionId");const R=tn();A({type:"SET_SESSION_ID",payload:R}),localStorage.setItem("sessionId",R)},Fn=E=>{ce(E)},jt=async(E,R)=>{if(!Y||!Z)return;A({type:"SET_LOADING",payload:!0});const te=Z[0].comfyClass||Z[0].type,Ae=tn(),Ne={id:tn(),role:"user",content:te,trace_id:Ae};A({type:"ADD_MESSAGE",payload:Ne}),ye.current=new AbortController;try{let Le=tn(),Te=!0;for await(const we of mt.streamInvokeServer(Y,te,[],E,R,Ae,ye.current.signal)){const oe={id:Le,role:"ai",content:JSON.stringify(we),format:we.format,finished:we.finished,name:"Assistant"};if(E&&E!==""&&(oe.metadata={intent:E}),Te)A({type:"ADD_MESSAGE",payload:oe}),Te=!1;else{A({type:"UPDATE_MESSAGE",payload:oe});const sn=D.messages.map(Nn=>Nn.id===oe.id&&!Nn.finished?oe:Nn);rn(sn)}we.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(Le){Le instanceof Error&&Le.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Le),A({type:"SET_LOADING",payload:!1}),ye.current=null}},rn=E=>{D.sessionId&&localStorage.setItem(`messages_${D.sessionId}`,JSON.stringify(E))},nt=E=>{console.log("[WorkflowChat] Adding new message:",E);const R=[...D.messages,E];A({type:"ADD_MESSAGE",payload:E}),rn(R)},Gt=()=>{me(!1)},jn=E=>{const R=Array.from(E).map(te=>({id:Math.random().toString(36).substr(2,9),file:te,preview:URL.createObjectURL(te)}));K(te=>[...te,...R])},Gn=E=>{K(R=>R.filter(Ae=>Ae.id!==E))};An.useEffect(()=>()=>{z.forEach(E=>URL.revokeObjectURL(E.preview))},[z]),I.useEffect(()=>{u&&j&&F==="chat"&&(jt("node_explain"),j())},[u,F]),I.useEffect(()=>{if(!w||F!=="chat")return;(async()=>{try{const R=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==R){const Ae=await mt.fetchAnnouncement();Ae&&Ae.trim()!==""&&(fn(Ae),Un(!0),localStorage.setItem("announcementLastShownDate",R))}}catch(R){console.error("Error fetching announcement:",R)}})()},[w,F]);const Mr=()=>{Un(!1)},zn=E=>{A({type:"SET_ACTIVE_TAB",payload:E})},tt=An.useMemo(()=>h.jsx(ap,{}),[]);return w?h.jsxs("div",{className:"flex flex-col h-full w-full bg-white",style:{display:w?"flex":"none",height:"100%"},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx($g,{onClose:m,onClear:yt,hasMessages:U.length>0,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Du,{active:F==="chat",onClick:()=>zn("chat"),children:"Chat"}),h.jsx(Du,{active:F==="parameter-debug",onClick:()=>zn("parameter-debug"),children:"GenLab"})]}),xt&&le&&F==="chat"&&h.jsx(up,{message:le,onClose:Mr}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth h-0",style:{display:F==="chat"?"block":"none"},ref:pe,children:h.jsx(tp,{messages:U,latestInput:he,onOptionClick:Fn,installedNodes:ie,onAddMessage:nt,loading:y})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:F==="chat"?"block":"none"},children:[Z&&h.jsx(Jg,{nodeInfo:Z,onSendWithIntent:jt,loading:y,onSendWithContent:Cn}),h.jsx(qg,{input:ae,loading:y,onChange:In,onSend:et,onKeyPress:ke,onUploadImages:jn,uploadedImages:z,onRemoveImage:Gn,selectedModel:q,onModelChange:xe,onStop:ve})]}),h.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:F==="parameter-debug"?"flex":"none"},children:tt})]})]}):null}const mp=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"}));export{vp as g,_p as i,pp as m,gp as r,mp as w}; +}`;var W=Tu(function(){return X(o,S+"return "+v).apply(u,a)});if(W.source=v,Ki(W))throw W;return W}function I0(e){return Q(e).toLowerCase()}function C0(e){return Q(e).toUpperCase()}function N0(e,n,t){if(e=Q(e),e&&(t||n===u))return Us(e);if(!e||!(n=Ke(n)))return e;var r=on(e),i=on(n),o=Bs(r,i),a=Fs(r,i)+1;return kn(r,o,a).join("")}function L0(e,n,t){if(e=Q(e),e&&(t||n===u))return e.slice(0,Gs(e)+1);if(!e||!(n=Ke(n)))return e;var r=on(e),i=Fs(r,on(n))+1;return kn(r,0,i).join("")}function T0(e,n,t){if(e=Q(e),e&&(t||n===u))return e.replace(Kr,"");if(!e||!(n=Ke(n)))return e;var r=on(e),i=Bs(r,on(n));return kn(r,i).join("")}function R0(e,n){var t=fn,r=xt;if(ue(n)){var i="separator"in n?n.separator:i;t="length"in n?P(n.length):t,r="omission"in n?Ke(n.omission):r}e=Q(e);var o=e.length;if(ot(e)){var a=on(e);o=a.length}if(t>=o)return e;var l=t-ut(r);if(l<1)return r;var c=a?kn(a,0,l).join(""):e.slice(0,l);if(i===u)return c+r;if(a&&(l+=c.length-l),$i(i)){if(e.slice(l).search(i)){var p,_=c;for(i.global||(i=ui(i.source,Q(os.exec(i))+"g")),i.lastIndex=0;p=i.exec(_);)var v=p.index;c=c.slice(0,v===u?l:v)}}else if(e.indexOf(Ke(i),l)!=l){var x=c.lastIndexOf(i);x>-1&&(c=c.slice(0,x))}return c+r}function O0(e){return e=Q(e),e&&Gu.test(e)?e.replace(rs,ol):e}var M0=gt(function(e,n,t){return e+(t?" ":"")+n.toUpperCase()}),Zi=Ro("toUpperCase");function Lu(e,n,t){return e=Q(e),n=t?u:n,n===u?nl(e)?ll(e):Ha(e):e.match(n)||[]}var Tu=B(function(e,n){try{return Ge(e,u,n)}catch(t){return Ki(t)?t:new O(t)}}),D0=xn(function(e,n){return Je(n,function(t){t=gn(t),vn(e,t,Gi(e[t],e))}),e});function P0(e){var n=e==null?0:e.length,t=C();return e=n?se(e,function(r){if(typeof r[1]!="function")throw new Ye(U);return[t(r[0]),r[1]]}):[],B(function(r){for(var i=-1;++ive)return[];var t=ke,r=Re(e,ke);n=C(n),e-=ke;for(var i=ii(r,n);++t0||n<0)?new $(t):(e<0?t=t.takeRight(-e):e&&(t=t.drop(e)),n!==u&&(n=P(n),t=n<0?t.dropRight(-n):t.take(n-e)),t)},$.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},$.prototype.toArray=function(){return this.take(ke)},hn($.prototype,function(e,n){var t=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),i=s[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);i&&(s.prototype[n]=function(){var a=this.__wrapped__,l=r?[1]:arguments,c=a instanceof $,p=l[0],_=c||M(a),v=function(G){var H=i.apply(s,Tn([G],l));return r&&x?H[0]:H};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var x=this.__chain__,S=!!this.__actions__.length,N=o&&!x,W=c&&!S;if(!o&&_){a=W?a:new $(this);var L=e.apply(a,l);return L.__actions__.push({func:Sr,args:[v],thisArg:u}),new Xe(L,x)}return N&&W?e.apply(this,l):(L=this.thru(v),N?r?L.value()[0]:L.value():L)})}),Je(["pop","push","shift","sort","splice","unshift"],function(e){var n=Jt[e],t=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);s.prototype[e]=function(){var i=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(M(o)?o:[],i)}return this[t](function(a){return n.apply(M(a)?a:[],i)})}}),hn($.prototype,function(e,n){var t=s[n];if(t){var r=t.name+"";V.call(ct,r)||(ct[r]=[]),ct[r].push({name:n,func:t})}}),ct[_r(u,_e).name]=[{name:"wrapper",func:u}],$.prototype.clone=Rl,$.prototype.reverse=Ol,$.prototype.value=Ml,s.prototype.at=lh,s.prototype.chain=fh,s.prototype.commit=ch,s.prototype.next=hh,s.prototype.plant=gh,s.prototype.reverse=ph,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=_h,s.prototype.first=s.prototype.head,At&&(s.prototype[At]=dh),s},at=fl();Kn?((Kn.exports=at)._=at,Yr._=at):Ie._=at}).call(Ut)})(Or,Or.exports);var ku=Or.exports;function sp(m=!0){I.useEffect(()=>{if(!m)return;const w=ku.debounce(u=>{document.documentElement.style.setProperty("--mouse-x",`${u.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${u.clientY}px`)},16);return document.addEventListener("mousemove",w),()=>{w.cancel(),document.removeEventListener("mousemove",w)}},[m])}function op(m=!0){const{state:w,dispatch:u}=ts(),{activeTab:j,screenState:D}=w;I.useEffect(()=>{if(!m)return;const A=U=>{const ie=j==="parameter-debug",y=j==="chat",Y=!D||D.currentScreen===0;if(y||Y&&ie){const Z=je.canvas.selected_nodes;Object.keys(Z??{}).length?u({type:"SET_SELECTED_NODE",payload:Object.values(Z)}):u({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",A),()=>{document.removeEventListener("click",A)}},[u,m,j,D])}const up=({message:m,onClose:w})=>m?h.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-amber-100 border-b border-amber-200 px-5 py-2 mt-2 relative shadow-sm",children:[h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"flex-shrink-0 mr-2",children:h.jsx("svg",{className:"w-3.5 h-3.5 text-amber-600",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),h.jsx("div",{className:"text-amber-800 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:h.jsx(Ig,{rehypePlugins:[[xg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[yg],className:"prose !text-[11px] prose-a:text-amber-700 prose-a:underline prose-a:font-medium hover:prose-a:text-amber-800",components:{a:({node:u,...j})=>h.jsx("a",{...j,className:"text-amber-700 underline hover:text-amber-800 transition-colors",style:{fontSize:"11px"}}),p:({children:u})=>h.jsx("span",{className:"inline",style:{fontSize:"11px"},children:u}),span:({children:u})=>h.jsx("span",{style:{fontSize:"11px"},children:u}),li:({children:u})=>h.jsx("li",{style:{fontSize:"11px"},children:u}),ul:({children:u})=>h.jsx("ul",{style:{fontSize:"11px"},children:u}),ol:({children:u})=>h.jsx("ol",{style:{fontSize:"11px"},children:u})},children:m})})]}),h.jsx("button",{onClick:w,className:"absolute right-2 top-1/2 -translate-y-1/2 text-amber-500 hover:text-amber-700 transition-colors p-1 rounded-full hover:bg-amber-200/50","aria-label":"Close announcement",children:h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,ap=()=>{const{state:m,dispatch:w}=ts(),{selectedNode:u,screenState:j}=m,D=u||[],A=An.lazy(()=>Bt(()=>import(getImportPath("ParameterDebugInterfaceV2-DMoq59aG.js")),__vite__mapDeps([4,1,2,3,5,6,7])).then(ie=>({default:ie.ParameterDebugInterface}))),U=()=>{w({type:"SET_SELECTED_NODE",payload:null}),w({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};return h.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:h.jsx(An.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(A,{selectedNodes:D,visible:!0,onClose:U})})})},Du=({active:m,onClick:w,children:u})=>h.jsx("button",{onClick:w,className:`px-4 py-2 font-medium text-xs transition-colors duration-200 ${m?"text-blue-600 border-b-2 border-blue-600":"text-gray-600 hover:text-blue-500 hover:border-b-2 hover:border-blue-300"}`,children:u});function lp({onClose:m,visible:w=!0,triggerUsage:u=!1,onUsageTriggered:j}){const{state:D,dispatch:A}=ts(),{messages:U,installedNodes:ie,loading:y,sessionId:Y,selectedNode:Z,activeTab:F}=D,pe=I.useRef(null),[ae,ce]=I.useState(""),[he,T]=I.useState(""),[_e,k]=I.useState(window.innerWidth/3),[J,me]=I.useState(!1),[z,K]=I.useState([]),[q,xe]=I.useState("gpt-4o-mini");I.useState(window.innerHeight),I.useState(0);const[le,fn]=I.useState(""),[xt,Un]=I.useState(!1),ye=I.useRef(null);sp(w&&F==="chat"),op(w),I.useEffect(()=>{pe.current&&(pe.current.scrollTop=pe.current.scrollHeight)},[U]),I.useEffect(()=>{if(F!=="chat")return;(async()=>{const R=await ip();console.log("[WorkflowChat] Received installed nodes:",R.length),A({type:"SET_INSTALLED_NODES",payload:R})})()},[F]);const Bn=async E=>{try{const R=await mt.fetchMessages(E);A({type:"SET_MESSAGES",payload:R})}catch(R){console.error("Error fetching messages:",R)}};I.useEffect(()=>{if(F!=="chat")return;let E=localStorage.getItem("sessionId");E?(A({type:"SET_SESSION_ID",payload:E}),Bn(E)):(E=tn(),A({type:"SET_SESSION_ID",payload:E}),localStorage.setItem("sessionId",E))},[F]),I.useEffect(()=>{const E=localStorage.getItem("activeTab");E&&A({type:"SET_ACTIVE_TAB",payload:E});const R=localStorage.getItem("screenState");R&&A({type:"SET_SCREEN_STATE",payload:JSON.parse(R)})},[]),I.useEffect(()=>{localStorage.setItem("activeTab",F)},[F]),I.useEffect(()=>{D.screenState&&localStorage.setItem("screenState",JSON.stringify(D.screenState))},[D.screenState]);const En=An.useCallback(E=>{if(!J)return;const R=window.innerWidth-E.clientX,te=Math.min(Math.max(300,R),window.innerWidth*.8);k(te)},[J]),cn=An.useMemo(()=>ku.debounce(En,16),[En]);I.useEffect(()=>(J&&(document.addEventListener("mousemove",cn),document.addEventListener("mouseup",Gt)),()=>{document.removeEventListener("mousemove",cn),document.removeEventListener("mouseup",Gt),cn.cancel()}),[J,cn]);const In=E=>{ce(E.target.value)},ve=()=>{ye.current&&(ye.current.abort(),ye.current=null,A({type:"SET_LOADING",payload:!1}))},et=async()=>{if(A({type:"SET_LOADING",payload:!0}),ae.trim()===""&&!Z||!Y)return;T(ae);const E=tn(),R={id:tn(),role:"user",content:ae,trace_id:E};A({type:"ADD_MESSAGE",payload:R}),ce(""),ye.current=new AbortController;try{const te={type:"model_select",data:[q]};let Ae=tn(),Ne=!0;for await(const Le of mt.streamInvokeServer(Y,ae,z.map(Te=>Te.file),null,te,E,ye.current.signal)){const Te={id:Ae,role:"ai",content:JSON.stringify(Le),format:Le.format,finished:Le.finished,name:"Assistant"};if(Ne)A({type:"ADD_MESSAGE",payload:Te}),Ne=!1;else{A({type:"UPDATE_MESSAGE",payload:Te});const we=D.messages.map(oe=>oe.id===Te.id&&!oe.finished?Te:oe);rn(we)}Le.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(te){te instanceof Error&&te.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",te),A({type:"SET_LOADING",payload:!1}),ye.current=null}finally{K([])}},Cn=async E=>{if(!Y)return;A({type:"SET_LOADING",payload:!0}),T(E);const R=tn(),te={id:tn(),role:"user",content:E,trace_id:R};A({type:"ADD_MESSAGE",payload:te}),ye.current=new AbortController;try{const Ae={type:"model_select",data:[q]};let Ne=tn(),Le=!0;for await(const Te of mt.streamInvokeServer(Y,E,z.map(we=>we.file),null,Ae,R,ye.current.signal)){const we={id:Ne,role:"ai",content:JSON.stringify(Te),format:Te.format,finished:Te.finished,name:"Assistant"};if(Le)A({type:"ADD_MESSAGE",payload:we}),Le=!1;else{A({type:"UPDATE_MESSAGE",payload:we});const oe=D.messages.map(sn=>sn.id===we.id&&!sn.finished?we:sn);rn(oe)}Te.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(Ae){Ae instanceof Error&&Ae.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Ae),A({type:"SET_LOADING",payload:!1}),ye.current=null}finally{K([])}},ke=E=>{E.metaKey&&E.key==="Enter"&&et()},yt=()=>{A({type:"CLEAR_MESSAGES"});const E=D.sessionId;E&&localStorage.removeItem(`messages_${E}`),localStorage.removeItem("sessionId");const R=tn();A({type:"SET_SESSION_ID",payload:R}),localStorage.setItem("sessionId",R)},Fn=E=>{ce(E)},jt=async(E,R)=>{if(!Y||!Z)return;A({type:"SET_LOADING",payload:!0});const te=Z[0].comfyClass||Z[0].type,Ae=tn(),Ne={id:tn(),role:"user",content:te,trace_id:Ae};A({type:"ADD_MESSAGE",payload:Ne}),ye.current=new AbortController;try{let Le=tn(),Te=!0;for await(const we of mt.streamInvokeServer(Y,te,[],E,R,Ae,ye.current.signal)){const oe={id:Le,role:"ai",content:JSON.stringify(we),format:we.format,finished:we.finished,name:"Assistant"};if(E&&E!==""&&(oe.metadata={intent:E}),Te)A({type:"ADD_MESSAGE",payload:oe}),Te=!1;else{A({type:"UPDATE_MESSAGE",payload:oe});const sn=D.messages.map(Nn=>Nn.id===oe.id&&!Nn.finished?oe:Nn);rn(sn)}we.finished&&(A({type:"SET_LOADING",payload:!1}),ye.current=null)}}catch(Le){Le instanceof Error&&Le.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Le),A({type:"SET_LOADING",payload:!1}),ye.current=null}},rn=E=>{D.sessionId&&localStorage.setItem(`messages_${D.sessionId}`,JSON.stringify(E))},nt=E=>{console.log("[WorkflowChat] Adding new message:",E);const R=[...D.messages,E];A({type:"ADD_MESSAGE",payload:E}),rn(R)},Gt=()=>{me(!1)},jn=E=>{const R=Array.from(E).map(te=>({id:Math.random().toString(36).substr(2,9),file:te,preview:URL.createObjectURL(te)}));K(te=>[...te,...R])},Gn=E=>{K(R=>R.filter(Ae=>Ae.id!==E))};An.useEffect(()=>()=>{z.forEach(E=>URL.revokeObjectURL(E.preview))},[z]),I.useEffect(()=>{u&&j&&F==="chat"&&(jt("node_explain"),j())},[u,F]),I.useEffect(()=>{if(!w||F!=="chat")return;(async()=>{try{const R=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==R){const Ae=await mt.fetchAnnouncement();Ae&&Ae.trim()!==""&&(fn(Ae),Un(!0),localStorage.setItem("announcementLastShownDate",R))}}catch(R){console.error("Error fetching announcement:",R)}})()},[w,F]);const Mr=()=>{Un(!1)},zn=E=>{A({type:"SET_ACTIVE_TAB",payload:E})},tt=An.useMemo(()=>h.jsx(ap,{}),[]);return w?h.jsxs("div",{className:"flex flex-col h-full w-full bg-white",style:{display:w?"flex":"none",height:"100%"},children:[h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsx($g,{onClose:m,onClear:yt,hasMessages:U.length>0,title:"ComfyUI-Copilot"}),h.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[h.jsx(Du,{active:F==="chat",onClick:()=>zn("chat"),children:"Chat"}),h.jsx(Du,{active:F==="parameter-debug",onClick:()=>zn("parameter-debug"),children:"GenLab"})]}),xt&&le&&F==="chat"&&h.jsx(up,{message:le,onClose:Mr}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4 scroll-smooth h-0",style:{display:F==="chat"?"block":"none"},ref:pe,children:h.jsx(tp,{messages:U,latestInput:he,onOptionClick:Fn,installedNodes:ie,onAddMessage:nt,loading:y})}),h.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:F==="chat"?"block":"none"},children:[Z&&h.jsx(Jg,{nodeInfo:Z,onSendWithIntent:jt,loading:y,onSendWithContent:Cn}),h.jsx(qg,{input:ae,loading:y,onChange:In,onSend:et,onKeyPress:ke,onUploadImages:jn,uploadedImages:z,onRemoveImage:Gn,selectedModel:q,onModelChange:xe,onStop:ve})]}),h.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:F==="parameter-debug"?"flex":"none"},children:tt})]})]}):null}const mp=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"}));export{vp as g,_p as i,pp as m,gp as r,mp as w};