function getImportPath(filename) { return `./${filename}`; } const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-Q_Dg76RS.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-DKOeeG13.js"].map(path => { const apiBase = window.comfyAPI?.api?.api?.api_base; if (apiBase) { // 有 API base 时,使用完整路径 return `${apiBase.substring(1)}/${path}`; } else { // 没有 API base 时,使用相对路径 return `./${path}`; } }))))=>i.map(i=>d[i]); import{j as i,r as $g,b as Gg}from"./vendor-markdown-CBmlBP6m.js";import{r as k,R as ms,c as xr,a as Hg}from"./vendor-react-Dixhfmvb.js";import{f as Kg,v as qg,W as Ft,a as Ce,B as Cl,u as bn,g as Ze,U as Vg,A as gs,b as Jg,c as vr,M as Yg}from"./message-components-DKOeeG13.js";import{_ as xs}from"./input.js";import{C as Jn}from"./App-CGC3pP89.js";/* empty css *//** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xg=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Al=(...a)=>a.filter((u,r,d)=>!!u&&u.trim()!==""&&d.indexOf(u)===r).join(" ").trim();/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var Zg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qg=k.forwardRef(({color:a="currentColor",size:u=24,strokeWidth:r=2,absoluteStrokeWidth:d,className:f="",children:h,iconNode:g,...p},v)=>k.createElement("svg",{ref:v,...Zg,width:u,height:u,stroke:a,strokeWidth:d?Number(r)*24/Number(u):r,className:Al("lucide",f),...p},[...g.map(([N,_])=>k.createElement(N,_)),...Array.isArray(h)?h:[h]]));/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yn=(a,u)=>{const r=k.forwardRef(({className:d,...f},h)=>k.createElement(Qg,{ref:h,iconNode:u,className:Al(`lucide-${Xg(a)}`,d),...f}));return r.displayName=`${a}`,r};/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const em=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],tm=yn("CircleStop",em);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nm=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],rm=yn("Image",nm);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sm=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],im=yn("MessageCircleWarning",sm);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const om=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],am=yn("Plus",om);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],cm=yn("Send",lm);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const um=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],dm=yn("Settings",um);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fm=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],hm=yn("Trash",fm);/** * @license lucide-react v0.475.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gm=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bi=yn("X",gm);function mm({isOpen:a,onClose:u,onSave:r,initialApiKey:d=""}){const[f,h]=k.useState(d),[g,p]=k.useState(!1),[v,N]=k.useState(""),[_,j]=k.useState("https://api.openai.com/v1"),[I,M]=k.useState(!1),[P,R]=k.useState(!1),[D,z]=k.useState(null),[G,Z]=k.useState(null);k.useEffect(()=>{h(d);const F=localStorage.getItem("openaiApiKey"),J=localStorage.getItem("openaiBaseUrl");F&&N(F),J&&j(J),(async()=>{try{const B=localStorage.getItem("rsaPublicKey");if(B)Z(B);else{const le=await Kg();Z(le),localStorage.setItem("rsaPublicKey",le)}}catch(B){console.error("Failed to fetch RSA public key:",B)}})()},[d]);const ae=async()=>{if(!v.trim()){z({success:!1,message:"Please enter an OpenAI API key"});return}if(!G){z({success:!1,message:"RSA public key not available. Please try again later."});return}R(!0),z(null);try{const F=await qg(v,_,G);z({success:F,message:F?"API key is valid!":"Invalid API key. Please check and try again."})}catch(F){z({success:!1,message:F instanceof Error?F.message:"Failed to verify API key"})}finally{R(!1)}},w=()=>{r(f),v.trim()?(localStorage.setItem("openaiApiKey",v),localStorage.setItem("openaiBaseUrl",_)):(localStorage.removeItem("openaiApiKey"),localStorage.removeItem("openaiBaseUrl")),u()};return a?i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-8 w-[480px] shadow-2xl",children:[i.jsx("h2",{className:"text-xl text-gray-900 dark:text-white font-semibold mb-6",children:"Set API Key"}),i.jsxs("div",{className:"mb-6",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"ComfyUI Copilot API Key"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:g?"text":"password",value:f,onChange:F=>h(F.target.value),placeholder:"Enter your API key",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg mb-4 pr-12 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:outline-none`}),i.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 pr-4 flex items-center text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none`,onClick:()=>p(!g),children:g?i.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}):i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})})})]}),i.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:[i.jsx("span",{children:"Don't have an API key? "}),i.jsx("a",{href:"https://form.typeform.com/to/tkg91K8D",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:"Click here to request one"})]})]}),i.jsxs("div",{className:"mb-6 border-t border-gray-200 dark:border-gray-700 pt-6",children:[i.jsx("h3",{className:"text-sm text-gray-900 dark:text-white font-medium mb-4",children:"OpenAI API Configuration (Optional)"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"OpenAI API Key"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:I?"text":"password",value:v,onChange:F=>N(F.target.value),placeholder:"Enter your OpenAI API key",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg pr-12 text-xs bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:outline-none`}),i.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 pr-4 flex items-center text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none`,onClick:()=>M(!I),children:I?i.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}):i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})})})]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"OpenAI Base URL"}),i.jsx("input",{type:"text",value:_,onChange:F=>j(F.target.value),placeholder:"https://api.openai.com/v1",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-xs bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:outline-none`})]}),i.jsx("div",{className:"flex items-center mb-2",children:i.jsx("button",{onClick:ae,disabled:P||!v.trim(),className:`px-4 py-2 rounded-lg font-medium text-xs transition-colors ${P||!v.trim()?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,children:P?i.jsxs("span",{className:"flex items-center",children:[i.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying..."]}):"Verify"})}),D&&i.jsx("div",{className:`text-xs p-2 rounded-md ${D.success?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"}`,children:D.message})]}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx("button",{onClick:u,className:`px-5 py-2.5 text-gray-700 bg-white dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg font-medium transition-colors`,children:"Cancel"}),i.jsx("button",{onClick:w,className:`px-5 py-2.5 bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white rounded-lg font-medium transition-colors`,children:"Save"})]})]})}):null}const pm="/copilot_web/assets/logo-BTZhX0BN.png";function xm({onClose:a,onClear:u,hasMessages:r,onHeightResize:d,title:f="ComfyUI-Copilot"}){const[h,g]=k.useState(!1),[p,v]=k.useState(!1),N=()=>{g(!0)},_=I=>{localStorage.setItem("chatApiKey",I)},j=()=>{window.open("https://docs.google.com/forms/d/e/1FAIpQLSf_SeUpgrZh8sPGwVFXAlsviVXKpsQnyaevcB2VrIqUBYUMKg/viewform?usp=dialog","_blank")};return k.useEffect(()=>{const I=P=>{if(!p)return;const R=P.movementY;d?.(R)},M=()=>{v(!1)};return p&&(document.addEventListener("mousemove",I),document.addEventListener("mouseup",M)),()=>{document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",M)}},[p,d]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`flex items-center justify-between border-b px-3 py-2 bg-white border-gray-200 sticky top-2 z-10`,children:[i.jsxs("div",{className:"flex items-center space-x-1",children:[i.jsx("img",{src:`.${pm}`,alt:"ComfyUI-Copilot Logo",className:"h-7 w-7 -ml-1"}),i.jsx("h3",{className:"text-[14px] font-medium text-gray-800",children:f}),i.jsx("button",{onClick:N,className:"p-1 bg-white border-none hover:!bg-gray-100 rounded text-gray-500",children:i.jsx(dm,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{className:"inline-flex bg-white border-none items-center justify-center rounded-md p-1.5 text-gray-500 hover:!bg-gray-100",onClick:j,children:i.jsx(im,{className:"h-4 w-4"})}),i.jsx("button",{className:`inline-flex bg-white border-none items-center justify-center rounded-md p-1.5 ${r?"text-gray-500 hover:!bg-gray-100":"text-gray-300 cursor-not-allowed"}`,disabled:!r,onClick:u,children:i.jsx(hm,{className:"h-4 w-4"})})]})]}),i.jsx(mm,{isOpen:h,onClose:()=>g(!1),onSave:_,initialApiKey:localStorage.getItem("chatApiKey")||""})]})}const bm=5*1024*1024,xl=["image/jpeg","image/png","image/gif","image/webp"];function ym({input:a,loading:u,onChange:r,onSend:d,onKeyPress:f,onUploadImages:h,uploadedImages:g,onRemoveImage:p,selectedModel:v,onModelChange:N,onStop:_}){const[j,I]=k.useState(!1),[M,P]=k.useState([]),R=ms.useRef(null),D=k.useRef(null);k.useEffect(()=>{D.current&&(D.current.style.height="auto",D.current.style.height=`${Math.min(D.current.scrollHeight,400)}px`)},[a]),k.useEffect(()=>{(async()=>{try{const Z=await Ft.listModels();P(Z.models)}catch(Z){console.error("Failed to load models:",Z),P([{name:"gpt-4o",image_enable:!0},{name:"gpt-4o-mini",image_enable:!0},{name:"qwen-plus",image_enable:!1},{name:"DeepSeek-V3",image_enable:!1}])}})()},[]);const z=G=>{if(G.target.files){const Z=[],ae=[];if(Array.from(G.target.files).forEach(w=>{xl.includes(w.type)?w.size>bm?Z.push(`${w.name} (exceeds 5MB)`):ae.push(w):Z.push(`${w.name} (unsupported format)`)}),Z.length>0&&alert(`The following files couldn't be uploaded: ${Z.join(` `)}`),ae.length>0){const w=new DataTransfer;ae.forEach(F=>w.items.add(F)),h(w.files)}}};return i.jsxs("div",{className:`relative ${g.length>0?"mt-12":""}`,children:[g.length>0&&i.jsx("div",{className:"absolute -top-10 left-0 flex gap-2",children:g.map(G=>i.jsxs("div",{className:"relative group",children:[i.jsx("img",{src:G.preview,alt:"uploaded",className:"w-8 h-8 rounded object-cover"}),i.jsx("button",{onClick:()=>p(G.id),className:`absolute -top-1 -right-1 bg-white border-none text-gray-500 rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:i.jsx(Bi,{className:"w-3 h-3"})})]},G.id))}),i.jsx("textarea",{ref:D,onChange:r,onKeyDown:G=>{if(G.key==="Enter"&&!G.shiftKey){if(G.nativeEvent.isComposing)return;G.preventDefault(),a.trim()!==""&&d()}f(G)},value:a,placeholder:"Type your message...",className:`w-full min-h-[80px] max-h-[400px] resize-none rounded-md border border-gray-200 px-3 py-2 pr-12 pb-10 text-[14px] shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white transition-all duration-200 text-gray-700 overflow-y-auto`,style:{height:"80px"}}),i.jsxs("div",{className:`absolute bottom-2 left-3 right-12 flex items-center gap-2 bg-white border-t border-gray-100 pt-1`,children:[i.jsx("select",{value:v,onChange:G=>N(G.target.value),className:`px-1.5 py-0.5 text-xs rounded-md border border-gray-200 bg-white text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent hover:bg-gray-50 transition-colors border-0`,children:M.map(G=>i.jsx("option",{value:G.name,children:G.name},G.name))}),i.jsx("button",{type:"button",onClick:()=>I(!0),disabled:!M.find(G=>G.name===v)?.image_enable,className:`p-1.5 text-gray-500 bg-white border-none hover:bg-gray-100 hover:text-gray-600 transition-all duration-200 outline-none ${M.find(G=>G.name===v)?.image_enable?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(rm,{className:"h-4 w-4"})})]}),i.jsx("button",{type:"submit",onClick:u?_:d,disabled:u?!1:a.trim()==="",className:`absolute bottom-3 right-3 p-2 rounded-md text-gray-500 bg-white border-none hover:bg-gray-100 hover:text-gray-600 disabled:opacity-50 transition-all duration-200 active:scale-95`,children:u?i.jsx(tm,{className:"h-5 w-5 text-red-500 hover:text-red-600"}):i.jsx(cm,{className:"h-5 w-5 group-hover:translate-x-1"})}),j&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg p-6 w-96 relative",children:[i.jsx("button",{onClick:()=>I(!1),className:"absolute top-2 right-2 bg-white border-none text-gray-500 hover:text-gray-700",children:i.jsx(Bi,{className:"w-5 h-5"})}),i.jsx("h3",{className:"text-lg text-gray-800 font-medium mb-4",children:"Upload Images"}),i.jsxs("div",{className:`border-2 border-dashed border-gray-300 rounded-lg p-8 flex flex-col items-center justify-center gap-4 hover:border-blue-500 transition-colors cursor-pointer`,onClick:()=>R.current?.click(),children:[i.jsx(am,{className:"w-8 h-8 text-gray-400"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"Click to upload images or drag and drop"}),i.jsx("p",{className:"text-xs text-gray-400",children:"Supported formats: JPG, PNG, GIF, WebP"}),i.jsx("p",{className:"text-xs text-gray-400",children:"Max file size: 5MB"})]})]}),i.jsx("input",{ref:R,type:"file",multiple:!0,accept:xl.join(","),onChange:z,className:"hidden"}),g.length>0&&i.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:g.map(G=>i.jsxs("div",{className:"relative group",children:[i.jsx("img",{src:G.preview,alt:"preview",className:"w-full h-20 object-cover rounded"}),i.jsx("button",{onClick:()=>p(G.id),className:`absolute -top-1 -right-1 bg-white border-none text-gray-500 rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:i.jsx(Bi,{className:"w-3 h-3"})})]},G.id))}),i.jsx("div",{className:"mt-4 flex justify-end gap-2",children:i.jsx("button",{onClick:()=>I(!1),className:`px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50`,children:"Close"})})]})})]})}function vm(a){const u=a[0],r=new Set;function d(f,h){if(!(!f||h>=1)&&f.inputs)for(const g of Object.values(f.inputs)){const p=g.link;if(p&&Ce.graph.links[p]){const v=Ce.graph.links[p].origin_id,N=Ce.graph._nodes_by_id[v];N&&(r.add(N.type),d(N,h+1))}}}return u?(d(u,0),[{type:"upstream_node_types",data:Array.from(r)}]):null}function _m({nodeInfo:a,onSendWithIntent:u,loading:r,onSendWithContent:d}){return console.log("SelectedNodeInfo nodeInfo:",a[0]),i.jsx("div",{className:"mb-3 p-3 rounded-md bg-gray-50 border border-gray-200",children:i.jsxs("div",{className:"text-sm text-gray-700",children:[i.jsxs("p",{children:["Selected node: ",a[0].type]}),i.jsxs("div",{className:"flex gap-2 mt-2",children:[i.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-blue-50 text-blue-700 hover:bg-blue-100`,onClick:()=>d(`Reply in ${navigator.language} language: How does the ${a[0].type} node work? I need its official usage guide.`),disabled:r,children:"Usage"}),i.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-green-100 text-green-700 hover:bg-green-200`,onClick:()=>d(`Reply in ${navigator.language} language: Show me the technical specifications for the ${a[0].type} node's inputs and outputs.`),disabled:r,children:"Parameters"}),i.jsx("button",{className:`px-3 py-1 text-xs rounded-md bg-purple-100 text-purple-700 hover:bg-purple-200`,onClick:()=>u("downstream_subgraph_search",vm(a)),disabled:r,children:"Downstream Nodes"})]})]})})}function wm(){return i.jsx(Cl,{name:"Assistant",children:i.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[i.jsxs("div",{className:"flex space-x-1",children:[i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),i.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const Sm=[{type:"chat",tool:"workflow_generate",name:"给我一个SK波普风插画工作流",messages:[{id:"showcase1-1",role:"user",content:"我需要一个创建SK波普风插画的工作流",trace_id:"showcase1"},{id:"showcase1-2",role:"ai",content:'{"session_id":"3da22770-b7ba-46ff-851f-d43d4190ba35","text":"我为您找到了一些相关的SK波普风插画工作流:\\n\\n1. **SK波普风插画工作流**\\n - 描述: SK波普风插画工作流v2\\n - 图片: ![SK波普风插画工作流](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||9b6dee1eb02e454b8b9f90047f67fdcf||00d68f37853c540b8a179f890056cbdf.jpg)\\n\\n2. **SK清新风插画出图工作流**\\n - 描述: SK清新风插画F.1,推荐模型强度:1.4(0.8到1.4都有不同效果,自己尝试)\\n - 图片: ![SK清新风插画出图工作流](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||c469a538da36496b9bc299bbfe4dcbfb||2c7a058f219502bf7f7ab006717541a1.jpg)\\n\\n3. **SK点线艺术抽象插画蓝墨工作流**\\n - 描述: SK点线艺术抽象插画 | 蓝墨效果。推荐使用ComfyUI生图,生成快、节省算力。点击在线ComfyUI生图,模型推荐强度:0.8~1.4。\\n - 图片: ![SK点线艺术抽象插画蓝墨工作流](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||5dea5dd339de4cdc9b77d755b9f0789a||22d21104ece72e8b034905e0fe436633.jpg)\\n\\n同时,我已经生成了一个定制的工作流:\\n\\n- **AI生成的工作流**\\n - 描述: 将任何肖像或插图转换为SK波普艺术风格,保持鲜艳的色彩和大胆的几何形状。该工作流应优化低VRAM使用和快速渲染速度,使用稳定的官方模型。\\n - 图片: ![AI生成的工作流](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\n您可以选择以上推荐的工作流或使用AI生成的定制解决方案。","finished":true,"format":"markdown","ext":[{"type":"workflow","data":[{"id":29504,"name":"AI Generated Workflow","description":"Build a workflow that transforms any portrait or illustration into SK Pop Art style, maintaining vibrant colors and bold geometric shapes. The workflow should be optimized for low VRAM usage and quick rendering speeds, using stable and official models where possible.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"75f4dc64e8947aefc00451fd574dbdc8","score":null,"source":"AI Generated"}, {"id":3806,"name":"SK_波普风插画_工作流","description":"SK_波普风插画_工作流v2","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||9b6dee1eb02e454b8b9f90047f67fdcf||00d68f37853c540b8a179f890056cbdf.jpg","unique_id":"0d5f9aa415592f370ad05747594f851d","score":[0.7427938887126632,1]},{"id":4126,"name":"SK_清新风插画_出图工作流","description":"SK_清新风插画_F.1 建议模型强度:1.4 (0.81.4都有不同效果,自己尝试吧)","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||c469a538da36496b9bc299bbfe4dcbfb||2c7a058f219502bf7f7ab006717541a1.jpg","unique_id":"4c8f9233892a68aa1fdb7b0aa7d7eab0","score":[0.646644434532856,0.6666666666666666]},{"id":4904,"name":"SK_点线艺术抽象插画_蓝墨_工作流","description":"SK_点线艺术抽象插画 | 蓝墨效果 建议使用ComfyUI生图(以下是我搭建的工作流,出图快,省算力) 点击在线 ComfyUI 生图   大模型:F.1基础算法模型 模型强度建议:0.8~1.4,(每种强度有不同效果,快去尝试吧!) 基础魔法:SK,Stylish blue and white line paintings with radiating line patterns on the background,(1 girl) ","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||5dea5dd339de4cdc9b77d755b9f0789a||22d21104ece72e8b034905e0fe436633.jpg","unique_id":"e0bf07efb70e4720347a571a3be8587d","score":[0.6317212205099343,0.6666666666666666]}]}],"message_id":"277361b7-f5f7-4b2a-80b8-d88a75fa2687"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"node_recommend",name:"给我一个把多张图合并的节点",messages:[{id:"showcase2-1",role:"user",content:"给我一个把多张图合并的节点",trace_id:"showcase2"},{id:"showcase2-2",role:"ai",content:'{"session_id":"bbe71936-8402-4fd0-8bb4-69eecac5ee01","text":"以下是可以合并多张图片的节点:\\n\\n1. **MonoMerge** \\n [GitHub链接](https://github.com/bmad4ever/comfyui_bmad_nodes): 将两张图片合并为单色图片,可选择在白色或黑色方向合并。\\n\\n2. **Concat Images (mtb)** \\n [GitHub链接](https://github.com/melMass/comfy_mtb): 可将多张图片合并成一个批次,适用于处理和操控图片集。\\n\\n3. **JoinImageBatch** \\n [GitHub链接](https://github.com/yolain/ComfyUI-Easy-Use): 合并批量图片成一张大图,支持水平或垂直拼接。\\n\\n4. **MergeLayers** \\n [GitHub链接](https://github.com/shadowcz007/comfyui-mixlab-nodes): 将多层图像合并为单张图片,支持指定的遮罩和混合选项。\\n\\n5. **Composite Images 🧅** \\n [GitHub链接](https://github.com/natto-maki/ComfyUI-NegiTools): 结合两张图片,支持多种复合方法,如乘法、划分、叠加等。\\n\\n6. **ImageContainerInheritanceSum** \\n [GitHub链接](https://github.com/Nourepide/ComfyUI-Allor): 通过总结图像维度以创建复合图像,适用于需要考虑输入图像总宽和高的情况。\\n\\n7. **Join Image Lists** \\n [GitHub链接](https://github.com/M1kep/Comfy_KepListStuff): 合并多张图片列表成为一个列表,同时提供原列表大小。\\n\\n8. **Merge Image List** \\n [GitHub链接](https://github.com/AInseven/ComfyUI-fastblend): 合并图像张量列表为一个单一张量,便于图像相关任务的批处理。\\n\\n根据你的具体需求选择合适的节点使用。","finished":true,"format":"markdown","ext":[{"type":"node","data":[{"id":28311,"unique_id":"7cca1314298b9a9d4b785e009099ea28","name":"MonoMerge","name_oral":"MonoMerge","description":"The MonoMerge node is designed to merge two images into a monochromatic image based on a target color scheme (either towards white or black). This process involves comparing the luminance (L component) of corresponding pixels from both images and selecting the higher or lower value depending on the target, resulting in an image that emphasizes either the lighter or darker aspects of the combined images.","github_url":"https://github.com/bmad4ever/comfyui_bmad_nodes","github_stars":50,"from_index":0,"to_index":0,"is_existed":true},{"id":29658,"unique_id":"e3a2782874d3bf8f99bb2b70c7090f74","name":"Concat Images (mtb)","name_oral":"Concat Images (mtb)","description":"The Concat Images node is designed to merge multiple images into a single batch, allowing for efficient processing and manipulation of image collections. It provides flexibility in handling size mismatches through customizable strategies.","github_url":"https://github.com/melMass/comfy_mtb","github_stars":350,"from_index":0,"to_index":0,"is_existed":true},{"id":29719,"unique_id":"458e445b2f21e81111dc9a7d3fb8cb7b","name":"easy joinImageBatch","name_oral":"JoinImageBatch","description":"This node is designed to merge a batch of images into a single large image, either by stacking them horizontally or vertically based on the specified mode. It abstracts the complexity of image manipulation and resizing, providing a straightforward way to create composite images from multiple inputs.","github_url":"https://github.com/yolain/ComfyUI-Easy-Use","github_stars":510,"from_index":0,"to_index":0,"is_existed":true},{"id":32325,"unique_id":"0ea3707eaaf8052e37630f95f4e5b72b","name":"MergeLayers","name_oral":"Merge Layers ♾️Mixlab","description":"The MergeLayers node is designed to combine multiple image layers into a single image while applying specified masks and blending options. It facilitates the creation of complex images by layering and compositing various elements based on their defined properties.","github_url":"https://github.com/shadowcz007/comfyui-mixlab-nodes","github_stars":null,"from_index":0,"to_index":0,"is_existed":true},{"id":32571,"unique_id":"0bd39afd25f012f877c9676b3c9837a1","name":"NegiTools_CompositeImages","name_oral":"Composite Images 🧅","description":"NegiTools_CompositeImages is a versatile node designed to combine two images using various compositing methods. This node allows you to blend images in multiple ways, such as multiplying, dividing, overlaying, and more, to achieve different visual effects.","github_url":"https://github.com/natto-maki/ComfyUI-NegiTools","github_stars":30,"from_index":0,"to_index":0,"is_existed":true},{"id":32865,"unique_id":"4e6b0fa27366545e19695c4e8931e270","name":"ImageContainerInheritanceSum","name_oral":"ImageContainerInheritanceSum","description":"Efficiently combine and sum image dimensions for creating composite images with integrity and visual quality. This node is designed to facilitate the combination of multiple images by summing their dimensions. This node is particularly useful when you need to create a composite image that encompasses the total width and height of the input images.","github_url":"https://github.com/Nourepide/ComfyUI-Allor","github_stars":200,"from_index":0,"to_index":0,"is_existed":true},{"id":72827,"unique_id":"1c76ce5bcc2c5097bdf515bddd32fb0b","name":"Join Image Lists","name_oral":"Join Image Lists","description":"This node is designed to combine multiple lists of images into a single list while also providing the sizes of the original lists. It facilitates the management of image data by allowing users to easily merge and track the number of images from various sources.","github_url":"https://github.com/M1kep/Comfy_KepListStuff","github_stars":null,"from_index":0,"to_index":0,"is_existed":true},{"id":81206,"unique_id":"1cc97ed3bc709de3f23c378eef1ce74e","name":"Merge_Image_List","name_oral":"Merge Image List","description":"This node is designed to merge a list of image tensors into a single tensor, facilitating batch processing in image-related tasks. It efficiently concatenates the input images along a specified dimension, enabling seamless integration of multiple images for further processing.","github_url":"https://github.com/AInseven/ComfyUI-fastblend","github_stars":null,"from_index":0,"to_index":0,"is_existed":true}]}],"message_id":"f60c3cf2-0b54-47a3-97e3-f536fc992c81"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"model_recommend",name:"给我一个宫崎骏风格的lora",messages:[{id:"showcase3-1",role:"user",content:"给我一个宫崎骏风格的lora",trace_id:"showcase3"},{id:"showcase3-2",role:"ai",content:'{"session_id":"0b26efaf-e417-4344-9942-658fedbbc12c","text":"请问您需要基于哪种基座模型的宫崎骏风格LORA?可选择以下基座模型:\\n\\n1. Stable Diffusion v1.5\\n2. Illustrious\\n3. Pony\\n4. Flux.1\\n5. Flux.1 D\\n6. Stable Diffusion XL 1.0","finished":true,"format":"markdown","ext":[{"type":"guides","data":["Stable Diffusion v1.5","Illustrious","Pony","Flux.1","Flux.1 D","Stable Diffusion XL 1.0"]}],"message_id":"cfecdc29-5131-4afa-9807-9fe911e6b670"}',format:"markdown",finished:!0,name:"Assistant"},{id:"showcase3-3",role:"user",content:"Flux.1",trace_id:"showcase3"},{id:"showcase3-4",role:"ai",content:`{"session_id":"0b26efaf-e417-4344-9942-658fedbbc12c","text":"以下是几个基于Flux.1的宫崎骏风格LORA模型:\\n\\n1. **宫崎骏风格插画** \\n - 描述:此模型擅长创作灵感来自宫崎骏风格的插图,展示奇幻、细致的风景和幻想元素。它强调丰富的质感、鲜艳的色彩和复杂的自然环境,擅长营造充满生机和暖意的场景,以讲述具有特色的宫崎骏风格的故事。 \\n - [获取链接](https://www.liblib.art/modelinfo/51b6a44f87b543a6b21dfbadc2952313) \\n\\n2. **宫崎骏的现实主义** \\n - 描述:模型擅长生成吉卜力风格的梦幻景观,展现葱郁的绿地、鲜亮的蓝色以及自然与建筑之间的和谐融合。它捕捉梦幻般的场景,具有柔和的幻想氛围,体现出在宁静森林和空中城堡间的魔幻现实主义。 \\n - ![示例图片1](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||20d56a93ad9fd5daeaf043453766b60d.jpg) \\n - ![示例图片2](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||4fca763050d3e8941193b4230e8e7410.jpg) \\n - [获取链接](https://www.liblib.art/modelinfo/c2ea3eebba764e388a3f08c2ca6eed3a) \\n\\n3. **F.1-宫崎骏风格** \\n - 描述:模型擅长生成宫崎骏影响下的动漫风格图像,呈现鲜艳的色彩、富有想象力的构图和生动的表现。专注于生成年轻女孩在各种迷人环境中的场景,擅长渲染云的细节纹理和复杂的光影。 \\n - [获取链接](https://www.liblib.art/modelinfo/5638cc813c264f899b43536e02abfc82) \\n\\n您可以选择一个适合您需求的模型进行使用。","finished":true,"format":"markdown","ext":[{"type":"model","data":[{"id":375989,"name":"宫崎骏风格插画","description":"This model excels in creating illustrations inspired by Miyazaki's style, featuring whimsical, detailed landscapes and fantastical elements. It consistently captures scenes brimming with life and warmth, emphasizing lush textures, vibrant colors, and intricate natural settings. This model is adept at generating compositions that convey a sense of wonder and storytelling in a distinctively Miyazaki fashion.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":[],"source_url":"https://www.liblib.art/modelinfo/51b6a44f87b543a6b21dfbadc2952313","unique_id":"c3123b5ab427eebeaae884a3f1fe10cc"},{"id":378349,"name":"宫崎骏的现实主义","description":"The model excels in generating whimsical, serene landscapes with a Ghibli-inspired aesthetic, featuring lush greenery, vibrant blues, and harmonious nature-architecture integration. It captures dreamy sceneries with a soft, fantasy-like ambiance, demonstrating strengths in depicting tranquil forests, ethereal sky castles, and interactions between natural and man-made elements with a magical realism touch.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":["https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||20d56a93ad9fd5daeaf043453766b60d.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||4fca763050d3e8941193b4230e8e7410.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||b782cc39b8d159cb2c52fbb31b0c51b8.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||cddb9c4648639e78805dd2c088f3f039.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||ef8b418d2ad9c6092c14c17e4aa1b051.jpg"],"source_url":"https://www.liblib.art/modelinfo/c2ea3eebba764e388a3f08c2ca6eed3a","unique_id":"256ec6894dd15b42eb60c91fde22b61b"},{"id":385880,"name":"F.1-宫崎骏风格","description":"The model excels in generating whimsical anime-style images influenced by Miyazaki's distinct aesthetic, characterized by vibrant colors, playful compositions, and lively expressions. It specializes in scenes featuring young girls in varied enchanting settings, demonstrating strong skills in rendering detailed textures like clouds and intricate lighting. Notably adept at creating charming and imaginative animated environments.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":[],"source_url":"https://www.liblib.art/modelinfo/5638cc813c264f899b43536e02abfc82","unique_id":"cbcbc993133822bccd46f16d49f5a4db"}]}],"message_id":"6903403f-cd32-447e-a9a6-a9247ab77c15"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"prompt",name:"基于我的描述生成prompt",messages:[{id:"showcase4-1",role:"user",content:'请为我生成英文prompt: "一个红衣女子在海边跳舞,笑容很灿烂"',trace_id:"showcase4"},{id:"showcase4-2",role:"ai",content:'{"session_id":"6272c460-04da-4b30-9090-1c05406f46e3","text":"woman in a red dress dancing by the seaside, bright smile, high quality, cinematic lighting, detailed, realistic, wide shot","finished":true,"format":"markdown","ext":null,"message_id":"13f0a58e-8670-4457-97da-cbad7a7d7530"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"genlab",tool:"genlab_prompt",name:"根据我的诉求生成3个prompt,各自生图查看效果",messages:[{id:"showcase5-1",role:"user",content:"根据我的诉求生成3个prompt,各自生图查看效果",trace_id:"showcase5"},{id:"showcase5-2",role:"ai",content:'{"text":"请根据下面的演示,使用Genlab来实现您的调试prompt的诉求。\\n ![](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-16%2Fab89513606fd4966b0362f95f3f1ab86.gif?OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2068018398&Signature=3XUgadQjjsGRu46S1fRxA7iDWJU%3D)"}',format:"markdown",finished:!0,name:"Assistant"}]}],bl=[{type:"chat",tool:"workflow_generate",name:"Give me an SK Pop Art illustration workflow",messages:[{id:"showcase1-1",role:"user",content:"I need a workflow for creating SK Pop Art illustrations",trace_id:"showcase1"},{id:"showcase1-2",role:"ai",content:'{"session_id":"3da22770-b7ba-46ff-851f-d43d4190ba35","text":"I found some relevant SK Pop Art illustration workflows for you:\\n\\n1. **SK Pop Art Illustration Workflow**\\n - Description: SK Pop Art Illustration Workflow v2\\n - Image: ![SK Pop Art Illustration Workflow](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||9b6dee1eb02e454b8b9f90047f67fdcf||00d68f37853c540b8a179f890056cbdf.jpg)\\n\\n2. **SK Fresh Style Illustration Workflow**\\n - Description: SK Fresh Style Illustration F.1, Recommended model strength: 1.4 (0.8 to 1.4 all have different effects, try it yourself)\\n - Image: ![SK Fresh Style Illustration Workflow](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||c469a538da36496b9bc299bbfe4dcbfb||2c7a058f219502bf7f7ab006717541a1.jpg)\\n\\n3. **SK Dot Line Art Abstract Illustration Blue Ink Workflow**\\n - Description: SK Dot Line Art Abstract Illustration | Blue Ink Effect. Recommended to use ComfyUI for generation, fast generation and power saving. Click online ComfyUI generation, model recommended strength: 0.8~1.4.\\n - Image: ![SK Dot Line Art Abstract Illustration Blue Ink Workflow](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||5dea5dd339de4cdc9b77d755b9f0789a||22d21104ece72e8b034905e0fe436633.jpg)\\n\\nAdditionally, I have generated a custom workflow:\\n\\n- **AI Generated Workflow**\\n - Description: Transform any portrait or illustration into SK Pop Art style, maintaining vibrant colors and bold geometric shapes. The workflow should be optimized for low VRAM usage and quick rendering speeds, using stable official models.\\n - Image: ![AI Generated Workflow](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\nYou can choose from the recommended workflows above or use the AI-generated custom solution.","finished":true,"format":"markdown","ext":[{"type":"workflow","data":[{"id":29504,"name":"AI Generated Workflow","description":"Build a workflow that transforms any portrait or illustration into SK Pop Art style, maintaining vibrant colors and bold geometric shapes. The workflow should be optimized for low VRAM usage and quick rendering speeds, using stable and official models where possible.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"75f4dc64e8947aefc00451fd574dbdc8","score":null,"source":"AI Generated"}, {"id":3806,"name":"SK_Pop_Art_Illustration_Workflow","description":"SK_Pop_Art_Illustration_Workflow_v2","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||9b6dee1eb02e454b8b9f90047f67fdcf||00d68f37853c540b8a179f890056cbdf.jpg","unique_id":"0d5f9aa415592f370ad05747594f851d","score":[0.7427938887126632,1]},{"id":4126,"name":"SK_Fresh_Style_Illustration_Workflow","description":"SK_Fresh_Style_Illustration_F.1 Recommended model strength: 1.4 (0.8-1.4 all have different effects, try it yourself)","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||c469a538da36496b9bc299bbfe4dcbfb||2c7a058f219502bf7f7ab006717541a1.jpg","unique_id":"4c8f9233892a68aa1fdb7b0aa7d7eab0","score":[0.646644434532856,0.6666666666666666]},{"id":4904,"name":"SK_Dot_Line_Art_Abstract_Illustration_Blue_Ink_Workflow","description":"SK_Dot_Line_Art_Abstract_Illustration | Blue Ink Effect Recommended to use ComfyUI for generation (below is the workflow I built, fast generation, power saving) Click online ComfyUI generation Base model: F.1 base algorithm model Model strength recommendation: 0.8~1.4, (each strength has different effects, go try it!) Base magic: SK,Stylish blue and white line paintings with radiating line patterns on the background,(1 girl) ","image":"https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||5dea5dd339de4cdc9b77d755b9f0789a||22d21104ece72e8b034905e0fe436633.jpg","unique_id":"e0bf07efb70e4720347a571a3be8587d","score":[0.6317212205099343,0.6666666666666666]}]}],"message_id":"277361b7-f5f7-4b2a-80b8-d88a75fa2687"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"node_recommend",name:"Give me a node to merge multiple images",messages:[{id:"showcase2-1",role:"user",content:"Give me a node to merge multiple images",trace_id:"showcase2"},{id:"showcase2-2",role:"ai",content:'{"session_id":"bbe71936-8402-4fd0-8bb4-69eecac5ee01","text":"Here are nodes that can merge multiple images:\\n\\n1. **MonoMerge** \\n [GitHub Link](https://github.com/bmad4ever/comfyui_bmad_nodes): Merges two images into a monochromatic image, with options to merge towards white or black direction.\\n\\n2. **Concat Images (mtb)** \\n [GitHub Link](https://github.com/melMass/comfy_mtb): Can merge multiple images into a single batch, suitable for processing and manipulating image collections.\\n\\n3. **JoinImageBatch** \\n [GitHub Link](https://github.com/yolain/ComfyUI-Easy-Use): Merges batch images into one large image, supports horizontal or vertical stitching.\\n\\n4. **MergeLayers** \\n [GitHub Link](https://github.com/shadowcz007/comfyui-mixlab-nodes): Merges multi-layer images into a single image, supports specified masks and blending options.\\n\\n5. **Composite Images 🧅** \\n [GitHub Link](https://github.com/natto-maki/ComfyUI-NegiTools): Combines two images, supports multiple composite methods such as multiply, divide, overlay, etc.\\n\\n6. **ImageContainerInheritanceSum** \\n [GitHub Link](https://github.com/Nourepide/ComfyUI-Allor): Creates composite images by summarizing image dimensions, suitable for cases that need to consider the total width and height of input images.\\n\\n7. **Join Image Lists** \\n [GitHub Link](https://github.com/M1kep/Comfy_KepListStuff): Merges multiple image lists into one list while providing original list sizes.\\n\\n8. **Merge Image List** \\n [GitHub Link](https://github.com/AInseven/ComfyUI-fastblend): Merges image tensor lists into a single tensor, convenient for batch processing of image-related tasks.\\n\\nChoose the appropriate node based on your specific needs.","finished":true,"format":"markdown","ext":[{"type":"node","data":[{"id":28311,"unique_id":"7cca1314298b9a9d4b785e009099ea28","name":"MonoMerge","name_oral":"MonoMerge","description":"The MonoMerge node is designed to merge two images into a monochromatic image based on a target color scheme (either towards white or black). This process involves comparing the luminance (L component) of corresponding pixels from both images and selecting the higher or lower value depending on the target, resulting in an image that emphasizes either the lighter or darker aspects of the combined images.","github_url":"https://github.com/bmad4ever/comfyui_bmad_nodes","github_stars":50,"from_index":0,"to_index":0,"is_existed":true},{"id":29658,"unique_id":"e3a2782874d3bf8f99bb2b70c7090f74","name":"Concat Images (mtb)","name_oral":"Concat Images (mtb)","description":"The Concat Images node is designed to merge multiple images into a single batch, allowing for efficient processing and manipulation of image collections. It provides flexibility in handling size mismatches through customizable strategies.","github_url":"https://github.com/melMass/comfy_mtb","github_stars":350,"from_index":0,"to_index":0,"is_existed":true},{"id":29719,"unique_id":"458e445b2f21e81111dc9a7d3fb8cb7b","name":"easy joinImageBatch","name_oral":"JoinImageBatch","description":"This node is designed to merge a batch of images into a single large image, either by stacking them horizontally or vertically based on the specified mode. It abstracts the complexity of image manipulation and resizing, providing a straightforward way to create composite images from multiple inputs.","github_url":"https://github.com/yolain/ComfyUI-Easy-Use","github_stars":510,"from_index":0,"to_index":0,"is_existed":true},{"id":32325,"unique_id":"0ea3707eaaf8052e37630f95f4e5b72b","name":"MergeLayers","name_oral":"Merge Layers ♾️Mixlab","description":"The MergeLayers node is designed to combine multiple image layers into a single image while applying specified masks and blending options. It facilitates the creation of complex images by layering and compositing various elements based on their defined properties.","github_url":"https://github.com/shadowcz007/comfyui-mixlab-nodes","github_stars":null,"from_index":0,"to_index":0,"is_existed":true},{"id":32571,"unique_id":"0bd39afd25f012f877c9676b3c9837a1","name":"NegiTools_CompositeImages","name_oral":"Composite Images 🧅","description":"NegiTools_CompositeImages is a versatile node designed to combine two images using various compositing methods. This node allows you to blend images in multiple ways, such as multiplying, dividing, overlaying, and more, to achieve different visual effects.","github_url":"https://github.com/natto-maki/ComfyUI-NegiTools","github_stars":30,"from_index":0,"to_index":0,"is_existed":true},{"id":32865,"unique_id":"4e6b0fa27366545e19695c4e8931e270","name":"ImageContainerInheritanceSum","name_oral":"ImageContainerInheritanceSum","description":"Efficiently combine and sum image dimensions for creating composite images with integrity and visual quality. This node is designed to facilitate the combination of multiple images by summing their dimensions. This node is particularly useful when you need to create a composite image that encompasses the total width and height of the input images.","github_url":"https://github.com/Nourepide/ComfyUI-Allor","github_stars":200,"from_index":0,"to_index":0,"is_existed":true},{"id":72827,"unique_id":"1c76ce5bcc2c5097bdf515bddd32fb0b","name":"Join Image Lists","name_oral":"Join Image Lists","description":"This node is designed to combine multiple lists of images into a single list while also providing the sizes of the original lists. It facilitates the management of image data by allowing users to easily merge and track the number of images from various sources.","github_url":"https://github.com/M1kep/Comfy_KepListStuff","github_stars":null,"from_index":0,"to_index":0,"is_existed":true},{"id":81206,"unique_id":"1cc97ed3bc709de3f23c378eef1ce74e","name":"Merge_Image_List","name_oral":"Merge Image List","description":"This node is designed to merge a list of image tensors into a single tensor, facilitating batch processing in image-related tasks. It efficiently concatenates the input images along a specified dimension, enabling seamless integration of multiple images for further processing.","github_url":"https://github.com/AInseven/ComfyUI-fastblend","github_stars":null,"from_index":0,"to_index":0,"is_existed":true}]}],"message_id":"f60c3cf2-0b54-47a3-97e3-f536fc992c81"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"model_recommend",name:"Give me a Studio Ghibli style LoRA",messages:[{id:"showcase3-1",role:"user",content:"Give me a Studio Ghibli style LoRA",trace_id:"showcase3"},{id:"showcase3-2",role:"ai",content:'{"session_id":"0b26efaf-e417-4344-9942-658fedbbc12c","text":"Which base model would you like for the Studio Ghibli style LoRA? You can choose from the following base models:\\n\\n1. Stable Diffusion v1.5\\n2. Illustrious\\n3. Pony\\n4. Flux.1\\n5. Flux.1 D\\n6. Stable Diffusion XL 1.0","finished":true,"format":"markdown","ext":[{"type":"guides","data":["Stable Diffusion v1.5","Illustrious","Pony","Flux.1","Flux.1 D","Stable Diffusion XL 1.0"]}],"message_id":"cfecdc29-5131-4afa-9807-9fe911e6b670"}',format:"markdown",finished:!0,name:"Assistant"},{id:"showcase3-3",role:"user",content:"Flux.1",trace_id:"showcase3"},{id:"showcase3-4",role:"ai",content:`{"session_id":"0b26efaf-e417-4344-9942-658fedbbc12c","text":"Here are several Studio Ghibli style LoRA models based on Flux.1:\\n\\n1. **Studio Ghibli Style Illustration** \\n - Description: This model excels at creating illustrations inspired by Studio Ghibli's style, showcasing whimsical, detailed landscapes and fantasy elements. It emphasizes rich textures, vibrant colors, and intricate natural environments, excelling at creating scenes full of life and warmth to tell stories with distinctive Studio Ghibli characteristics. \\n - [Get Link](https://www.liblib.art/modelinfo/51b6a44f87b543a6b21dfbadc2952313) \\n\\n2. **Studio Ghibli Realism** \\n - Description: The model excels at generating Ghibli-style dreamlike landscapes, showcasing lush greenery, bright blues, and harmonious integration between nature and architecture. It captures dreamy scenes with soft fantasy atmosphere, embodying magical realism between tranquil forests and sky castles. \\n - ![Example Image 1](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||20d56a93ad9fd5daeaf043453766b60d.jpg) \\n - ![Example Image 2](https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||4fca763050d3e8941193b4230e8e7410.jpg) \\n - [Get Link](https://www.liblib.art/modelinfo/c2ea3eebba764e388a3f08c2ca6eed3a) \\n\\n3. **F.1-Studio Ghibli Style** \\n - Description: The model excels at generating anime-style images influenced by Studio Ghibli, presenting vibrant colors, imaginative compositions, and lively expressions. It focuses on generating scenes of young girls in various charming environments, excelling at rendering detailed cloud textures and complex lighting and shadows. \\n - [Get Link](https://www.liblib.art/modelinfo/5638cc813c264f899b43536e02abfc82) \\n\\nYou can choose a model that suits your needs.","finished":true,"format":"markdown","ext":[{"type":"model","data":[{"id":375989,"name":"Studio Ghibli Style Illustration","description":"This model excels in creating illustrations inspired by Miyazaki's style, featuring whimsical, detailed landscapes and fantastical elements. It consistently captures scenes brimming with life and warmth, emphasizing lush textures, vibrant colors, and intricate natural settings. This model is adept at generating compositions that convey a sense of wonder and storytelling in a distinctively Miyazaki fashion.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":[],"source_url":"https://www.liblib.art/modelinfo/51b6a44f87b543a6b21dfbadc2952313","unique_id":"c3123b5ab427eebeaae884a3f1fe10cc"},{"id":378349,"name":"Studio Ghibli Realism","description":"The model excels in generating whimsical, serene landscapes with a Ghibli-inspired aesthetic, featuring lush greenery, vibrant blues, and harmonious nature-architecture integration. It captures dreamy sceneries with a soft, fantasy-like ambiance, demonstrating strengths in depicting tranquil forests, ethereal sky castles, and interactions between natural and man-made elements with a magical realism touch.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":["https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||20d56a93ad9fd5daeaf043453766b60d.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||4fca763050d3e8941193b4230e8e7410.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||b782cc39b8d159cb2c52fbb31b0c51b8.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||cddb9c4648639e78805dd2c088f3f039.jpg","https://aib-data-sg.oss-ap-southeast-1.aliyuncs.com/ext-img/comuify/liblib||505b51e94736455c9d78ebe38afc3148||ef8b418d2ad9c6092c14c17e4aa1b051.jpg"],"source_url":"https://www.liblib.art/modelinfo/c2ea3eebba764e388a3f08c2ca6eed3a","unique_id":"256ec6894dd15b42eb60c91fde22b61b"},{"id":385880,"name":"F.1-Studio Ghibli Style","description":"The model excels in generating whimsical anime-style images influenced by Miyazaki's distinct aesthetic, characterized by vibrant colors, playful compositions, and lively expressions. It specializes in scenes featuring young girls in varied enchanting settings, demonstrating strong skills in rendering detailed textures like clouds and intricate lighting. Notably adept at creating charming and imaginative animated environments.","model_type":"LORA","model_algorithm":"Flux.1","model_pics":[],"source_url":"https://www.liblib.art/modelinfo/5638cc813c264f899b43536e02abfc82","unique_id":"cbcbc993133822bccd46f16d49f5a4db"}]}],"message_id":"6903403f-cd32-447e-a9a6-a9247ab77c15"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"prompt",name:"Generate prompt based on my description",messages:[{id:"showcase4-1",role:"user",content:'Please generate an English prompt for me: "A woman in red dancing by the seaside with a bright smile"',trace_id:"showcase4"},{id:"showcase4-2",role:"ai",content:'{"session_id":"6272c460-04da-4b30-9090-1c05406f46e3","text":"woman in a red dress dancing by the seaside, bright smile, high quality, cinematic lighting, detailed, realistic, wide shot","finished":true,"format":"markdown","ext":null,"message_id":"13f0a58e-8670-4457-97da-cbad7a7d7530"}',format:"markdown",finished:!0,name:"Assistant"}]},{type:"genlab",tool:"genlab_prompt",name:"Generate 3 prompts based on my requirements and test each with image generation",messages:[{id:"showcase5-1",role:"user",content:"Generate 3 prompts based on my requirements and test each with image generation",trace_id:"showcase5"},{id:"showcase5-2",role:"ai",content:'{"text":"Please follow the demonstration below to use Genlab to fulfill your prompt debugging requirements.\\n ![](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-16%2Fab89513606fd4966b0362f95f3f1ab86.gif?OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2068018398&Signature=3XUgadQjjsGRu46S1fRxA7iDWJU%3D)"}',format:"markdown",finished:!0,name:"Assistant"}]}],Nm=2,jm=[i.jsxs("svg",{t:"1752732936328",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"27395",width:"16",height:"16",children:[i.jsx("path",{d:"M149.333333 661.333333h213.333334v213.333334H149.333333zM753.066667 411.733333l-119.466667-119.466666c-8.533333-8.533333-8.533333-21.333333 0-29.866667l119.466667-119.466667c8.533333-8.533333 21.333333-8.533333 29.866666 0l119.466667 119.466667c8.533333 8.533333 8.533333 21.333333 0 29.866667l-119.466667 119.466666c-8.533333 8.533333-21.333333 8.533333-29.866666 0z",fill:"#1296db","p-id":"27396"}),i.jsx("path",{d:"M256 277.333333m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z",fill:"#1296db","p-id":"27397"}),i.jsx("path",{d:"M768 768m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z",fill:"#1296db","p-id":"27398"}),i.jsx("path",{d:"M234.666667 512h42.666666v106.666667h-42.666666z",fill:"#1296db","p-id":"27399"}),i.jsx("path",{d:"M256 448l-64 85.333333h128z",fill:"#1296db","p-id":"27400"}),i.jsx("path",{d:"M426.666667 256h106.666666v42.666667h-106.666666z",fill:"#1296db","p-id":"27401"}),i.jsx("path",{d:"M597.333333 277.333333l-85.333333-64v128z",fill:"#1296db","p-id":"27402"}),i.jsx("path",{d:"M746.666667 448h42.666666v106.666667h-42.666666z",fill:"#1296db","p-id":"27403"}),i.jsx("path",{d:"M768 618.666667l64-85.333334h-128z",fill:"#1296db","p-id":"27404"})]}),i.jsxs("svg",{t:"1752729194808",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"11650",width:"16",height:"16",children:[i.jsx("path",{d:"M512 1024C229.2224 1024 0 794.7776 0 512S229.2224 0 512 0s512 229.2224 512 512-229.2224 512-512 512z m0-53.9136a458.0864 458.0864 0 1 0 0-916.1728 458.0864 458.0864 0 0 0 0 916.1728z",fill:"#1296db","p-id":"11651"}),i.jsx("path",{d:"M363.5712 657.9712a8.8576 8.8576 0 0 1 8.8576 8.8576v143.5136A8.8576 8.8576 0 0 1 363.52 819.2H220.5184a8.8576 8.8576 0 0 1-8.8064-9.3184v-143.0528c0-4.864 3.9424-8.8576 8.8064-8.8576h143.0528z m222.6688 0c4.9152 0 8.96 3.9424 9.0624 8.8576v143.0528a9.1136 9.1136 0 0 1-9.0624 8.8064H443.392a9.1136 9.1136 0 0 1-9.1136-8.8064v-143.0528a9.1136 9.1136 0 0 1 9.1136-8.8576h142.7968z m216.5248 0c4.9152 0 8.96 3.9424 9.0624 8.8576v143.0528a9.1136 9.1136 0 0 1-9.0624 8.8064h-142.848a9.1136 9.1136 0 0 1-9.0624-8.8064v-143.0528a9.1136 9.1136 0 0 1 9.1136-8.8576h142.7968z m-25.1904 33.2288h-90.8288a5.7856 5.7856 0 0 0-5.7856 5.632v91.136c0.1024 3.1232 2.6624 5.632 5.7856 5.632h90.8288a5.7856 5.7856 0 0 0 5.7856-5.632v-91.136a5.7856 5.7856 0 0 0-5.7856-5.632z m-215.04 0H471.7056a5.7856 5.7856 0 0 0-5.7856 5.632v91.136c0.1024 3.1232 2.6624 5.632 5.7856 5.632h90.8288a5.7856 5.7856 0 0 0 5.7856-5.632v-91.136a5.7856 5.7856 0 0 0-5.7856-5.632z m-225.28 0H246.4256a5.7856 5.7856 0 0 0-5.7856 5.632v91.136c0.1024 3.1232 2.6624 5.632 5.7856 5.632h90.8288a5.7856 5.7856 0 0 0 5.7856-5.632v-91.136a5.7856 5.7856 0 0 0-5.7856-5.632zM608.8192 204.8H414.72c-6.3488 0-12.032 3.9424-12.032 8.8576v143.0016c0 4.9152 5.4272 8.8576 12.032 8.8576h194.1504c6.656 0 12.0832-3.9424 12.0832-8.8576V213.6576c0-4.9152-5.4272-8.8576-12.0832-8.8576z m53.3504 419.0208v-107.4176h-136.3968v107.1616h-27.2896v-107.1616H361.3696v107.4176h-27.2896V489.3696h163.6864V394.752h27.7504v94.6176h163.9424v134.4512h-27.2896zM584.6528 235.52c5.0176 0 9.1136 2.5088 9.2672 5.632v91.136c-0.1536 3.1232-4.2496 5.632-9.216 5.632H439.296c-4.9664 0-9.0624-2.5088-9.216-5.632V241.152c0.1536-3.1232 4.2496-5.632 9.216-5.632h145.408z",fill:"#1296db","p-id":"11652"})]}),i.jsxs("svg",{t:"1752729509637",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"22212",width:"16",height:"16",children:[i.jsx("path",{d:"M114.0736 307.2l-1.4336 0.73728v418.33472L512 942.08V511.20128z",fill:"#FFFFFF","p-id":"22213"}),i.jsx("path",{d:"M930.73408 302.72512L521.3184 92.16 128.50176 294.07232l-15.86176 8.2944L521.3184 501.76l4.79232-2.16064L931.84 303.45216v-0.3584l-1.10592-0.36864zM526.11072 499.6096L521.3184 501.76l4.79232-2.16064z",fill:"#91D5FF","p-id":"22214"}),i.jsx("path",{d:"M1006.40768 264.31488a68.21888 68.21888 0 0 0-29.04064-30.39232L548.00384 7.68a67.51232 67.51232 0 0 0-62.49472 0L56.50432 232.448a66.44736 66.44736 0 0 0-17.64352 15.74912 73.25696 73.25696 0 0 0-11.02848 14.27456A67.87072 67.87072 0 0 0 20.48 291.76832v439.33696a67.33824 67.33824 0 0 0 36.7616 59.31008l428.99456 224.79872c9.32864 5.29408 19.79392 8.31488 30.5152 8.78592h5.15072a64.53248 64.53248 0 0 0 26.10176-6.9632L976.9984 792.25856A67.33824 67.33824 0 0 0 1013.76 732.93824V291.76832a64.23552 64.23552 0 0 0-7.35232-27.45344z m-80.50688 39.90528l-404.3776 199.168-4.77184 2.56v427.25376L107.60192 719.02208V303.85152l15.81056-8.41728L516.75136 89.67168l408.04352 213.8112 1.10592 0.73728z",fill:"#40A9FF","p-id":"22215"})]}),i.jsx("svg",{t:"1752729587088",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"24973",width:"16",height:"16",children:i.jsx("path",{d:"M153.6 204.8a128 128 0 0 1 128-128h386.9696c21.6576 0 41.984 9.1136 56.6272 24.4736 14.7968 15.5648 37.888 39.168 59.904 58.88 18.688 16.6912 47.36 46.08 64.0512 63.3856 13.824 14.2336 21.248 33.28 21.248 52.8384V819.2a128 128 0 0 1-128 128h-460.8A128 128 0 0 1 153.6 819.2V204.8z m665.6 76.8v-5.2224a24.8832 24.8832 0 0 0-6.912-17.3056c-16.896-17.5616-44.288-45.568-61.3376-60.7744-23.552-21.0944-47.7696-45.8752-62.8736-61.7472a27.0336 27.0336 0 0 0-19.456-8.5504H665.6V256a25.6 25.6 0 0 0 25.6 25.6H819.2z m-204.8-153.6H281.6A76.8 76.8 0 0 0 204.8 204.8v614.4a76.8 76.8 0 0 0 76.8 76.8h460.8A76.8 76.8 0 0 0 819.2 819.2V332.8h-128A76.8 76.8 0 0 1 614.4 256V128zM332.8 307.2a25.6 25.6 0 0 1 25.6-25.6h102.4a25.6 25.6 0 1 1 0 51.2H358.4a25.6 25.6 0 0 1-25.6-25.6z m0 153.6a25.6 25.6 0 0 1 25.6-25.6h307.2a25.6 25.6 0 1 1 0 51.2H358.4a25.6 25.6 0 0 1-25.6-25.6z m0 153.6a25.6 25.6 0 0 1 25.6-25.6h307.2a25.6 25.6 0 1 1 0 51.2H358.4a25.6 25.6 0 0 1-25.6-25.6z",fill:"#1296db","p-id":"24974"})}),i.jsx("svg",{t:"1752729687983",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"26244",width:"16",height:"16",children:i.jsx("path",{d:"M960.547341 839.611479l0-656.56349c0-119.372761-102.850459-119.372761-119.385041-119.372761L184.573227 63.675228c-16.471137 0-119.346155 0-119.346155 119.372761l0 656.56349c0 119.378901 119.346155 119.378901 119.346155 119.378901l656.589073 0c34.458813 0 58.69582-10.053983 76.130911-24.249287 1.105171-0.816598 2.211365-1.633197 3.316535-2.533706 3.960195-3.497661 7.637957-7.231705 10.839883-11.109012 0.938372-1.105171 1.696642-2.301416 2.571568-3.496637C960.367239 883.154181 960.547341 839.611479 960.547341 839.611479L960.547341 839.611479zM187.453834 128.375809l645.788076 0c16.265452 0 58.69582 0 58.69582 58.721403l0 645.725654c0 0-0.115634 33.892925-25.998117 50.125631-43.075051-45.201481-161.341618-169.178097-191.248765-199.054545-22.205745-22.237467-45.170782-27.27725-59.160401-26.51898-30.048363 0.405229-49.489134 19.260669-50.891064 20.893866l-61.872163 53.919027c-12.562107 11.919471-22.964014 1.511423-28.004821-3.554966-37.827537-37.8347-111.092168-103.230106-120.311133-111.394043-6.055926-6.088672-27.502377-25.118074-58.426691-25.851784-16.175401-0.784876-40.720424 4.314259-65.343217 28.943193-22.938432 22.964014-66.950831 63.530942-101.925391 95.418186L128.755967 187.097212C128.756991 128.375809 171.252851 128.375809 187.453834 128.375809L187.453834 128.375809zM128.756991 830.636061l0-28.505217c26.873044-24.218588 110.809735-100.137675 147.1852-136.571469 4.718465-4.685719 11.186783-10.986215 18.361183-10.254551 7.522324 0.058328 14.400988 6.583952 14.452153 6.583952l0 0 2.391467 2.359744c0.822738 0.700965 80.207763 71.380724 118.408807 109.61349 23.298636 23.318078 47.188742 26.784016 62.052265 27.774577 32.92897-0.437975 54.736649-22.438035 54.91675-22.817682l61.782112-53.803393c6.351662-5.998621 12.292977-4.776793 21.215184 4.081968 23.080671 23.136953 102.991676 106.637716 156.185178 162.363901-139.251507-0.058328-540.893051-0.264013-594.22777-0.264013C126.776893 891.287419 128.756991 830.636061 128.756991 830.636061L128.756991 830.636061zM662.076552 549.130665c83.550904 0 151.582347-68.108191 151.582347-151.755286 0-83.672678-68.030419-151.755286-151.582347-151.755286-83.563184 0-151.581324 68.082608-151.581324 151.755286C510.495228 481.022475 578.513368 549.130665 662.076552 549.130665L662.076552 549.130665zM662.076552 309.59515c48.293913 0 87.575568 39.370683 87.575568 87.781252s-39.281655 87.754646-87.575568 87.754646-87.574544-39.3451-87.574544-87.754646S613.782639 309.59515 662.076552 309.59515L662.076552 309.59515zM662.076552 309.59515",fill:"#1296db","p-id":"26245"})})],Im=()=>{const{dispatch:a,isAutoScroll:u,showcasIng:r}=bn(),d=(p,v=!1,N=()=>{})=>{let _=0;const j=Ze(),I=(M=!1)=>{if(!r.current)return;_+=Nm;const R=typeof p=="string"?p:p?.text||"",D=v?{id:j,role:"user",content:R.slice(0,_)}:{id:j,role:"ai",content:_>R.length&&p?.ext?JSON.stringify({text:R.slice(0,_),ext:p?.ext}):JSON.stringify({text:R.slice(0,_)}),finished:_>R.length,format:"markdown",name:"Assistant"};a({type:M?"ADD_MESSAGE":"UPDATE_MESSAGE",payload:D}),_<=R.length?setTimeout(()=>{I()},10):setTimeout(()=>{N()},500)};I(!0)},f=(p,v)=>{a({type:"SET_LOADING",payload:!0}),d(p,!0,v)},h=(p,v)=>{a({type:"SET_LOADING",payload:!1}),d(p,!1,v)},g=()=>{const p=Ce.extensionManager.setting.get("Comfy.Locale");let v=bl,N="welcome to ComfyUI Copilot!";switch(p){case"zh":N="欢迎使用ComfyUI Copilot!",v=Sm;break;case"en":default:N="welcome to ComfyUI Copilot!",v=bl;break}return{title:N,list:v}};return i.jsx(Cl,{name:"showcase",children:i.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[i.jsx("div",{className:"text-xl text-gray-900 font-extrabold text-center mb-4",children:g()?.title}),g()?.list?.map((p,v)=>i.jsxs("div",{className:"min-h-[50px] flex flex-row items-center mt-4 bg-showcase-bg shadow-[0_4px_24px_rgba(0,0,0,0.12)] hover:!shadow-[0_0_12px_2px_#3b82f6] hover:!shadow-[0_0_0_4px_rgba(59,130,246,0.15)] px-4 py-2 rounded-full",onClick:()=>{u.current=!0,r.current=!0;const N=p.messages||[];let _=0;const j=()=>{if(_`https://ui-avatars.com/api/?name=${a||"User"}&background=random`,Cm=k.lazy(()=>xs(()=>import(getImportPath("WorkflowOption-Q_Dg76RS.js")),__vite__mapDeps([0,1,2,3])).then(a=>({default:a.WorkflowOption}))),Am=k.lazy(()=>xs(()=>import(getImportPath("message-components-DKOeeG13.js")).then(a=>a.N),__vite__mapDeps([3,2,1])).then(a=>({default:a.NodeSearch}))),Em=k.lazy(()=>xs(()=>import(getImportPath("message-components-DKOeeG13.js")).then(a=>a.D),__vite__mapDeps([3,2,1])).then(a=>({default:a.DownstreamSubgraphs}))),Mm=k.lazy(()=>xs(()=>import(getImportPath("message-components-DKOeeG13.js")).then(a=>a.d),__vite__mapDeps([3,2,1])).then(a=>({default:a.NodeInstallGuide}))),Lm=3;function Tm({messages:a,latestInput:u,onOptionClick:r,installedNodes:d,onAddMessage:f,loading:h,isActive:g}){const{isAutoScroll:p}=bn(),[v,N]=k.useState(0),[_,j]=k.useState([]),I=k.useRef(null),M=k.useRef(0),P=k.useRef(0),R=k.useRef(!1);k.useEffect(()=>{const w=I.current;if(!w)return;const F=()=>{I.current&&(p.current=w.scrollHeight-w.scrollTop-w.clientHeight<=10),P.current=w.scrollHeight};return w.addEventListener("scroll",F),()=>w.removeEventListener("scroll",F)},[]);const D=()=>{I?.current&&p.current&&(I.current.scrollTop=I.current.scrollHeight)},z=w=>{if(w.role==="user")return i.jsx(Vg,{content:w.content,trace_id:w.trace_id},w.id);if(w.role==="showcase")return i.jsx(Im,{});if(w.role==="ai"||w.role==="tool"){const F=km(w.role);try{const J=JSON.parse(w.content),de=J.ext?.find(te=>te.type==="workflow"),B=J.ext?.find(te=>te.type==="node"),le=J.ext?.find(te=>te.type==="downstream_subgraph_search"),$e=J.ext?.find(te=>te.type==="node_install_guide");let U=null;if(de)U=i.jsx(k.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Cm,{content:w.content,name:w.name,avatar:F,latestInput:u,installedNodes:d,onAddMessage:f,onFinishLoad:D})});else if(B)U=i.jsx(k.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Am,{content:w.content,name:w.name,avatar:F,installedNodes:d,onFinishLoad:D})});else if(le){const te=i.jsx(k.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Em,{content:w.content,name:w.name,avatar:F,onAddMessage:f,onFinishLoad:D})});if(w.metadata?.intent==="downstream_subgraph_search")return i.jsx(gs,{content:w.content,name:w.name,avatar:F,format:w.format,onOptionClick:r,extComponent:te,metadata:w.metadata},w.id);U=te}else $e&&(U=i.jsx(k.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Mm,{content:w.content,onLoadSubgraph:()=>{if(w.metadata?.pendingSubgraph){const te=Object.values(Ce.canvas.selected_nodes)[0];if(te){const fe=w.metadata.pendingSubgraph,ne=fe.json.nodes,ve=fe.json.links,be=ne.find($=>$.id===0),K=be?.id,re={};K&&(re[K]=te),Ce.canvas.emitBeforeChange();try{for(const $ of ne)if($.id!==K){const Y=be?.pos||[0,0],we=te._pos||[0,0],Me=[$.pos[0]+we[0]-Y[0],$.pos[1]+we[1]-Y[1]];re[$.id]=Jg($.type,{pos:Me})}}finally{Ce.canvas.emitAfterChange()}for(const $ of ve){const Y=re[$.origin_id],we=re[$.target_id];Y&&we&&Y.connect($.origin_slot,we,$.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(w.metadata?.pendingWorkflow){const te=w.metadata.pendingWorkflow,fe=w.metadata.optimizedParams;if(te.nodes)Ce.loadGraphData(te);else{Ce.loadApiJson(te);const ve=Object.keys(te),be=Object.keys(Ce.graph._nodes_by_id)[0],K=Ce.graph._nodes_by_id[be],re=K?K.pos[0]:0,$=K?K.pos[1]:0,Y=250,we=60,Me=20,Oe=60,Ie=50,Qe=1e3;let Bt=re,ct=$,Je=0;for(const qt of ve){const ze=Ce.graph._nodes_by_id[qt];if(ze){Je>Qe&&(Bt+=Y+Oe,Je=0,ct=$);const Tt=ze.inputs?ze.inputs.length:0,wt=ze.outputs?ze.outputs.length:0,et=ze.widgets?ze.widgets.length:0,mt=Math.max(Tt,wt)+et,Vt=Me*mt+we;ze.size[0]=Y,ze.size[1]=Vt,ze.pos[0]=Bt,ze.pos[1]=ct,Je+=Vt+Ie,ct+=Vt+Ie}}}for(const[ve,be,K,re,$]of fe){const Y=Ce.graph._nodes_by_id[ve].widgets;for(const we of Y)we.name===re&&(we.value=$)}Ce.graph.setDirtyCanvas(!1,!0);const ne={id:Ze(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};f?.(ne)}},onFinishLoad:D})}));return J.text||U?i.jsx(gs,{content:w.content,name:w.name,avatar:F,format:w.format,onOptionClick:r,extComponent:U,metadata:w.metadata},w.id):U||i.jsx(gs,{content:w.content,name:w.name,avatar:F,format:w.format,onOptionClick:r,metadata:w.metadata},w.id)}catch(J){return console.error("[MessageList] Error parsing message content:",J),console.error("解析JSON失败",w.content),i.jsx(gs,{content:w.content,name:w.name,avatar:F,format:w.format,onOptionClick:r,metadata:w.metadata},w.id)}}return null},G=w=>{const F=w?.buttonStatus==="not_used";return i.jsx("div",{className:"flex justify-center items-center",children:F?i.jsx("button",{className:"w-full h-[24px] text-gray-700 text-xs bg-transparent hover:!bg-gray-100 px-2 py-1 rounded-md",onClick:ae,children:"Load more"}):i.jsx("div",{className:"w-full h-[24px] bg-transparent"})},w.id)};function Z(w){return w&&typeof w=="object"&&w.buttonType==="loadmore"}const ae=()=>{R.current=!0,N(w=>w+1)};return k.useEffect(()=>{let w=[];if(M.current>0&&M.current[...F,...w]);else{let F=0,J=a?.length;for(let de=a?.length-1;de>=0;de--)if(a[de].role==="ai"||de===0)if(F>Lm+v){w.unshift({id:`${a[de].id}_loadmore`,buttonType:"loadmore",buttonStatus:"not_used"});break}else F++,w?.length>0&&w.unshift({id:`${a[de].id}_loadmore`,buttonType:"loadmore",buttonStatus:"used"}),w=[...a?.slice(Math.min(J,de===0?de:de+1),J+1),...w],J=de;j(w)}M.current=a.length},[a,v]),k.useLayoutEffect(()=>{I?.current&&(R.current?(I.current.scrollTop=I.current.scrollHeight-P.current,R.current=!1):p.current&&(I.current.scrollTop=I.current.scrollHeight),P.current=I.current.scrollHeight)},[_]),i.jsxs("div",{className:"flex-1 flex-col overflow-y-auto p-4 h-0",ref:I,style:{display:g?"block":"none"},children:[_?.map(w=>!!w&&(Z(w)?G(w):z(w))),h&&i.jsx(wm,{})]})}async function Om(){try{return await(await vr.fetchApi("/object_info",{method:"GET"})).json()}catch(a){throw console.error("Error fetching object info:",a),a}}async function Pm(){const a=await Om();return Object.keys(a)}async function Rm(a){return await(await vr.fetchApi("/prompt",{method:"POST",body:JSON.stringify(a)})).json()}async function Dm(a){try{const u=await vr.fetchApi("/queue",{method:"POST",body:JSON.stringify(a)});if(!u.ok)throw new Error(`Failed to manage queue: ${u.status} ${u.statusText}`);return u}catch(u){throw console.error("Error managing queue:",u),u}}async function Wm(){try{const a=await vr.fetchApi("/interrupt",{method:"POST"});if(!a.ok)throw new Error(`Failed to interrupt processing: ${a.status} ${a.statusText}`);return a}catch(a){throw console.error("Error interrupting processing:",a),a}}async function zm(a){try{const u=await vr.fetchApi(`/history/${a}`,{method:"GET"});if(!u.ok)throw new Error(`Failed to fetch history: ${u.status} ${u.statusText}`);return await u.json()}catch(u){throw console.error("Error fetching history:",u),u}}var ps={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ps.exports;(function(a,u){(function(){var r,d="4.17.21",f=200,h="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",g="Expected a function",p="Invalid `variable` option passed into `_.template`",v="__lodash_hash_undefined__",N=500,_="__lodash_placeholder__",j=1,I=2,M=4,P=1,R=2,D=1,z=2,G=4,Z=8,ae=16,w=32,F=64,J=128,de=256,B=512,le=30,$e="...",U=800,te=16,fe=1,ne=2,ve=3,be=1/0,K=9007199254740991,re=17976931348623157e292,$=NaN,Y=4294967295,we=Y-1,Me=Y>>>1,Oe=[["ary",J],["bind",D],["bindKey",z],["curry",Z],["curryRight",ae],["flip",B],["partial",w],["partialRight",F],["rearg",de]],Ie="[object Arguments]",Qe="[object Array]",Bt="[object AsyncFunction]",ct="[object Boolean]",Je="[object Date]",qt="[object DOMException]",ze="[object Error]",Tt="[object Function]",wt="[object GeneratorFunction]",et="[object Map]",mt="[object Number]",Vt="[object Null]",ut="[object Object]",Jt="[object Promise]",Mn="[object Proxy]",Ut="[object RegExp]",tt="[object Set]",$t="[object String]",Ot="[object Symbol]",on="[object Undefined]",q="[object WeakMap]",ce="[object WeakSet]",ye="[object ArrayBuffer]",Se="[object DataView]",Ke="[object Float32Array]",Le="[object Float64Array]",De="[object Int8Array]",Pe="[object Int16Array]",Ye="[object Int32Array]",Pt="[object Uint8Array]",St="[object Uint8ClampedArray]",vn="[object Uint16Array]",Xn="[object Uint32Array]",bs=/\b__p \+= '';/g,ys=/\b(__p \+=) '' \+/g,vs=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_r=/&(?:amp|lt|gt|quot|#39);/g,wr=/[&<>"']/g,_s=RegExp(_r.source),ws=RegExp(wr.source),Sr=/<%-([\s\S]+?)%>/g,Ss=/<%([\s\S]+?)%>/g,Nr=/<%=([\s\S]+?)%>/g,Ns=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fe=/^\w*$/,js=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ln=/[\\^$.*+?()[\]{}|]/g,Zn=RegExp(Ln.source),Qn=/^\s+/,Is=/\s/,an=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ks=/\{\n\/\* \[wrapped with (.+)\] \*/,Cs=/,? & /,As=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,jr=/[()=,{}\[\]\/\s]/,er=/\\(\\)?/g,Ir=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tr=/\w*$/,kr=/^[-+]0x[0-9a-f]+$/i,_n=/^0b[01]+$/i,Es=/^\[object .+?Constructor\]$/,ln=/^0o[0-7]+$/i,Tn=/^(?:0|[1-9]\d*)$/,L=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,O=/($^)/,_e=/['\n\r\u2028\u2029\\]/g,Be="\\ud800-\\udfff",Nt="\\u0300-\\u036f",On="\\ufe20-\\ufe2f",Dl="\\u20d0-\\u20ff",Hi=Nt+On+Dl,Ki="\\u2700-\\u27bf",qi="a-z\\xdf-\\xf6\\xf8-\\xff",Wl="\\xac\\xb1\\xd7\\xf7",zl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Fl="\\u2000-\\u206f",Bl=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Vi="A-Z\\xc0-\\xd6\\xd8-\\xde",Ji="\\ufe0e\\ufe0f",Yi=Wl+zl+Fl+Bl,Ms="['’]",Ul="["+Be+"]",Xi="["+Yi+"]",Cr="["+Hi+"]",Zi="\\d+",$l="["+Ki+"]",Qi="["+qi+"]",eo="[^"+Be+Yi+Zi+Ki+qi+Vi+"]",Ls="\\ud83c[\\udffb-\\udfff]",Gl="(?:"+Cr+"|"+Ls+")",to="[^"+Be+"]",Ts="(?:\\ud83c[\\udde6-\\uddff]){2}",Os="[\\ud800-\\udbff][\\udc00-\\udfff]",Pn="["+Vi+"]",no="\\u200d",ro="(?:"+Qi+"|"+eo+")",Hl="(?:"+Pn+"|"+eo+")",so="(?:"+Ms+"(?:d|ll|m|re|s|t|ve))?",io="(?:"+Ms+"(?:D|LL|M|RE|S|T|VE))?",oo=Gl+"?",ao="["+Ji+"]?",Kl="(?:"+no+"(?:"+[to,Ts,Os].join("|")+")"+ao+oo+")*",ql="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Vl="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",lo=ao+oo+Kl,Jl="(?:"+[$l,Ts,Os].join("|")+")"+lo,Yl="(?:"+[to+Cr+"?",Cr,Ts,Os,Ul].join("|")+")",Xl=RegExp(Ms,"g"),Zl=RegExp(Cr,"g"),Ps=RegExp(Ls+"(?="+Ls+")|"+Yl+lo,"g"),Ql=RegExp([Pn+"?"+Qi+"+"+so+"(?="+[Xi,Pn,"$"].join("|")+")",Hl+"+"+io+"(?="+[Xi,Pn+ro,"$"].join("|")+")",Pn+"?"+ro+"+"+so,Pn+"+"+io,Vl,ql,Zi,Jl].join("|"),"g"),ec=RegExp("["+no+Be+Hi+Ji+"]"),tc=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nc=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rc=-1,Te={};Te[Ke]=Te[Le]=Te[De]=Te[Pe]=Te[Ye]=Te[Pt]=Te[St]=Te[vn]=Te[Xn]=!0,Te[Ie]=Te[Qe]=Te[ye]=Te[ct]=Te[Se]=Te[Je]=Te[ze]=Te[Tt]=Te[et]=Te[mt]=Te[ut]=Te[Ut]=Te[tt]=Te[$t]=Te[q]=!1;var Ee={};Ee[Ie]=Ee[Qe]=Ee[ye]=Ee[Se]=Ee[ct]=Ee[Je]=Ee[Ke]=Ee[Le]=Ee[De]=Ee[Pe]=Ee[Ye]=Ee[et]=Ee[mt]=Ee[ut]=Ee[Ut]=Ee[tt]=Ee[$t]=Ee[Ot]=Ee[Pt]=Ee[St]=Ee[vn]=Ee[Xn]=!0,Ee[ze]=Ee[Tt]=Ee[q]=!1;var sc={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ic={"&":"&","<":"<",">":">",'"':""","'":"'"},oc={"&":"&","<":"<",">":">",""":'"',"'":"'"},ac={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lc=parseFloat,cc=parseInt,co=typeof xr=="object"&&xr&&xr.Object===Object&&xr,uc=typeof self=="object"&&self&&self.Object===Object&&self,nt=co||uc||Function("return this")(),Rs=u&&!u.nodeType&&u,wn=Rs&&!0&&a&&!a.nodeType&&a,uo=wn&&wn.exports===Rs,Ds=uo&&co.process,jt=function(){try{var b=wn&&wn.require&&wn.require("util").types;return b||Ds&&Ds.binding&&Ds.binding("util")}catch{}}(),fo=jt&&jt.isArrayBuffer,ho=jt&&jt.isDate,go=jt&&jt.isMap,mo=jt&&jt.isRegExp,po=jt&&jt.isSet,xo=jt&&jt.isTypedArray;function pt(b,C,S){switch(S.length){case 0:return b.call(C);case 1:return b.call(C,S[0]);case 2:return b.call(C,S[0],S[1]);case 3:return b.call(C,S[0],S[1],S[2])}return b.apply(C,S)}function dc(b,C,S,H){for(var se=-1,Ne=b==null?0:b.length;++se-1}function Ws(b,C,S){for(var H=-1,se=b==null?0:b.length;++H-1;);return S}function jo(b,C){for(var S=b.length;S--&&Rn(C,b[S],0)>-1;);return S}function vc(b,C){for(var S=b.length,H=0;S--;)b[S]===C&&++H;return H}var _c=Us(sc),wc=Us(ic);function Sc(b){return"\\"+ac[b]}function Nc(b,C){return b==null?r:b[C]}function Dn(b){return ec.test(b)}function jc(b){return tc.test(b)}function Ic(b){for(var C,S=[];!(C=b.next()).done;)S.push(C.value);return S}function Ks(b){var C=-1,S=Array(b.size);return b.forEach(function(H,se){S[++C]=[se,H]}),S}function Io(b,C){return function(S){return b(C(S))}}function dn(b,C){for(var S=-1,H=b.length,se=0,Ne=[];++S-1}function hu(e,t){var n=this.__data__,s=Kr(n,e);return s<0?(++this.size,n.push([e,t])):n[s][1]=t,this}Yt.prototype.clear=cu,Yt.prototype.delete=uu,Yt.prototype.get=du,Yt.prototype.has=fu,Yt.prototype.set=hu;function Xt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t=t?e:t)),e}function At(e,t,n,s,o,c){var m,x=t&j,y=t&I,A=t&M;if(n&&(m=o?n(e,s,o,c):n(e)),m!==r)return m;if(!We(e))return e;var E=ie(e);if(E){if(m=xd(e),!x)return dt(e,m)}else{var T=it(e),W=T==Tt||T==wt;if(xn(e))return la(e,x);if(T==ut||T==Ie||W&&!o){if(m=y||W?{}:ka(e),!x)return y?od(e,Au(m,e)):id(e,Wo(m,e))}else{if(!Ee[T])return o?e:{};m=bd(e,T,x)}}c||(c=new Dt);var V=c.get(e);if(V)return V;c.set(e,m),nl(e)?e.forEach(function(ee){m.add(At(ee,t,n,ee,e,c))}):el(e)&&e.forEach(function(ee,me){m.set(me,At(ee,t,n,me,e,c))});var Q=A?y?bi:xi:y?ht:Xe,ue=E?r:Q(e);return It(ue||e,function(ee,me){ue&&(me=ee,ee=e[me]),lr(m,me,At(ee,t,n,me,e,c))}),m}function Eu(e){var t=Xe(e);return function(n){return zo(n,e,t)}}function zo(e,t,n){var s=n.length;if(e==null)return!s;for(e=Ae(e);s--;){var o=n[s],c=t[o],m=e[o];if(m===r&&!(o in e)||!c(m))return!1}return!0}function Fo(e,t,n){if(typeof e!="function")throw new kt(g);return mr(function(){e.apply(r,n)},t)}function cr(e,t,n,s){var o=-1,c=Ar,m=!0,x=e.length,y=[],A=t.length;if(!x)return y;n&&(t=Re(t,xt(n))),s?(c=Ws,m=!1):t.length>=f&&(c=nr,m=!1,t=new jn(t));e:for(;++oo?0:o+n),s=s===r||s>o?o:oe(s),s<0&&(s+=o),s=n>s?0:sl(s);n0&&n(x)?t>1?rt(x,t-1,n,s,o):un(o,x):s||(o[o.length]=x)}return o}var Qs=ga(),$o=ga(!0);function Gt(e,t){return e&&Qs(e,t,Xe)}function ei(e,t){return e&&$o(e,t,Xe)}function Vr(e,t){return cn(t,function(n){return nn(e[n])})}function kn(e,t){t=mn(t,e);for(var n=0,s=t.length;e!=null&&nt}function Tu(e,t){return e!=null&&ke.call(e,t)}function Ou(e,t){return e!=null&&t in Ae(e)}function Pu(e,t,n){return e>=st(t,n)&&e=120&&E.length>=120)?new jn(m&&E):r}E=e[0];var T=-1,W=x[0];e:for(;++T-1;)x!==e&&zr.call(x,y,1),zr.call(e,y,1);return e}function ea(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;tn(o)?zr.call(e,o,1):ui(e,o)}}return e}function ai(e,t){return e+Ur(Oo()*(t-e+1))}function Vu(e,t,n,s){for(var o=-1,c=Ve(Br((t-e)/(n||1)),0),m=S(c);c--;)m[s?c:++o]=e,e+=n;return m}function li(e,t){var n="";if(!e||t<1||t>K)return n;do t%2&&(n+=e),t=Ur(t/2),t&&(e+=e);while(t);return n}function he(e,t){return ji(Ea(e,t,gt),e+"")}function Ju(e){return Do(Vn(e))}function Yu(e,t){var n=Vn(e);return is(n,In(t,0,n.length))}function fr(e,t,n,s){if(!We(e))return e;t=mn(t,e);for(var o=-1,c=t.length,m=c-1,x=e;x!=null&&++oo?0:o+t),n=n>o?o:n,n<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var c=S(o);++s>>1,m=e[c];m!==null&&!yt(m)&&(n?m<=t:m=f){var A=t?null:ud(e);if(A)return Mr(A);m=!1,o=nr,y=new jn}else y=t?[]:x;e:for(;++s=s?e:Et(e,t,n)}var aa=Bc||function(e){return nt.clearTimeout(e)};function la(e,t){if(t)return e.slice();var n=e.length,s=Ao?Ao(n):new e.constructor(n);return e.copy(s),s}function gi(e){var t=new e.constructor(e.byteLength);return new Dr(t).set(new Dr(e)),t}function td(e,t){var n=t?gi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function nd(e){var t=new e.constructor(e.source,tr.exec(e));return t.lastIndex=e.lastIndex,t}function rd(e){return ar?Ae(ar.call(e)):{}}function ca(e,t){var n=t?gi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ua(e,t){if(e!==t){var n=e!==r,s=e===null,o=e===e,c=yt(e),m=t!==r,x=t===null,y=t===t,A=yt(t);if(!x&&!A&&!c&&e>t||c&&m&&y&&!x&&!A||s&&m&&y||!n&&y||!o)return 1;if(!s&&!c&&!A&&e=x)return y;var A=n[s];return y*(A=="desc"?-1:1)}}return e.index-t.index}function da(e,t,n,s){for(var o=-1,c=e.length,m=n.length,x=-1,y=t.length,A=Ve(c-m,0),E=S(y+A),T=!s;++x1?n[o-1]:r,m=o>2?n[2]:r;for(c=e.length>3&&typeof c=="function"?(o--,c):r,m&&at(n[0],n[1],m)&&(c=o<3?r:c,o=1),t=Ae(t);++s-1?o[c?t[m]:m]:r}}function xa(e){return en(function(t){var n=t.length,s=n,o=Ct.prototype.thru;for(e&&t.reverse();s--;){var c=t[s];if(typeof c!="function")throw new kt(g);if(o&&!m&&rs(c)=="wrapper")var m=new Ct([],!0)}for(s=m?s:n;++s1&&xe.reverse(),E&&yx))return!1;var A=c.get(e),E=c.get(t);if(A&&E)return A==t&&E==e;var T=-1,W=!0,V=n&R?new jn:r;for(c.set(e,t),c.set(t,e);++T1?"& ":"")+t[s],t=t.join(n>2?", ":" "),e.replace(an,`{ /* [wrapped with `+t+`] */ `)}function vd(e){return ie(e)||En(e)||!!(Lo&&e&&e[Lo])}function tn(e,t){var n=typeof e;return t=t??K,!!t&&(n=="number"||n!="symbol"&&Tn.test(e))&&e>-1&&e%1==0&&e0){if(++t>=U)return arguments[0]}else t=0;return e.apply(r,arguments)}}function is(e,t){var n=-1,s=e.length,o=s-1;for(t=t===r?s:t;++n1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Ua(e,n)});function $a(e){var t=l(e);return t.__chain__=!0,t}function Lf(e,t){return t(e),e}function os(e,t){return t(e)}var Tf=en(function(e){var t=e.length,n=t?e[0]:0,s=this.__wrapped__,o=function(c){return Zs(c,e)};return t>1||this.__actions__.length||!(s instanceof pe)||!tn(n)?this.thru(o):(s=s.slice(n,+n+(t?1:0)),s.__actions__.push({func:os,args:[o],thisArg:r}),new Ct(s,this.__chain__).thru(function(c){return t&&!c.length&&c.push(r),c}))});function Of(){return $a(this)}function Pf(){return new Ct(this.value(),this.__chain__)}function Rf(){this.__values__===r&&(this.__values__=rl(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function Df(){return this}function Wf(e){for(var t,n=this;n instanceof Hr;){var s=Ra(n);s.__index__=0,s.__values__=r,t?o.__wrapped__=s:t=s;var o=s;n=n.__wrapped__}return o.__wrapped__=e,t}function zf(){var e=this.__wrapped__;if(e instanceof pe){var t=e;return this.__actions__.length&&(t=new pe(this)),t=t.reverse(),t.__actions__.push({func:os,args:[Ii],thisArg:r}),new Ct(t,this.__chain__)}return this.thru(Ii)}function Ff(){return ia(this.__wrapped__,this.__actions__)}var Bf=Zr(function(e,t,n){ke.call(e,n)?++e[n]:Zt(e,n,1)});function Uf(e,t,n){var s=ie(e)?bo:Mu;return n&&at(e,t,n)&&(t=r),s(e,X(t,3))}function $f(e,t){var n=ie(e)?cn:Uo;return n(e,X(t,3))}var Gf=pa(Da),Hf=pa(Wa);function Kf(e,t){return rt(as(e,t),1)}function qf(e,t){return rt(as(e,t),be)}function Vf(e,t,n){return n=n===r?1:oe(n),rt(as(e,t),n)}function Ga(e,t){var n=ie(e)?It:hn;return n(e,X(t,3))}function Ha(e,t){var n=ie(e)?fc:Bo;return n(e,X(t,3))}var Jf=Zr(function(e,t,n){ke.call(e,n)?e[n].push(t):Zt(e,n,[t])});function Yf(e,t,n,s){e=ft(e)?e:Vn(e),n=n&&!s?oe(n):0;var o=e.length;return n<0&&(n=Ve(o+n,0)),fs(e)?n<=o&&e.indexOf(t,n)>-1:!!o&&Rn(e,t,n)>-1}var Xf=he(function(e,t,n){var s=-1,o=typeof t=="function",c=ft(e)?S(e.length):[];return hn(e,function(m){c[++s]=o?pt(t,m,n):ur(m,t,n)}),c}),Zf=Zr(function(e,t,n){Zt(e,n,t)});function as(e,t){var n=ie(e)?Re:Vo;return n(e,X(t,3))}function Qf(e,t,n,s){return e==null?[]:(ie(t)||(t=t==null?[]:[t]),n=s?r:n,ie(n)||(n=n==null?[]:[n]),Zo(e,t,n))}var eh=Zr(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function th(e,t,n){var s=ie(e)?zs:wo,o=arguments.length<3;return s(e,X(t,4),n,o,hn)}function nh(e,t,n){var s=ie(e)?hc:wo,o=arguments.length<3;return s(e,X(t,4),n,o,Bo)}function rh(e,t){var n=ie(e)?cn:Uo;return n(e,us(X(t,3)))}function sh(e){var t=ie(e)?Do:Ju;return t(e)}function ih(e,t,n){(n?at(e,t,n):t===r)?t=1:t=oe(t);var s=ie(e)?Iu:Yu;return s(e,t)}function oh(e){var t=ie(e)?ku:Zu;return t(e)}function ah(e){if(e==null)return 0;if(ft(e))return fs(e)?Wn(e):e.length;var t=it(e);return t==et||t==tt?e.size:si(e).length}function lh(e,t,n){var s=ie(e)?Fs:Qu;return n&&at(e,t,n)&&(t=r),s(e,X(t,3))}var ch=he(function(e,t){if(e==null)return[];var n=t.length;return n>1&&at(e,t[0],t[1])?t=[]:n>2&&at(t[0],t[1],t[2])&&(t=[t[0]]),Zo(e,rt(t,1),[])}),ls=Uc||function(){return nt.Date.now()};function uh(e,t){if(typeof t!="function")throw new kt(g);return e=oe(e),function(){if(--e<1)return t.apply(this,arguments)}}function Ka(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,Qt(e,J,r,r,r,r,t)}function qa(e,t){var n;if(typeof t!="function")throw new kt(g);return e=oe(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Ci=he(function(e,t,n){var s=D;if(n.length){var o=dn(n,Kn(Ci));s|=w}return Qt(e,s,t,n,o)}),Va=he(function(e,t,n){var s=D|z;if(n.length){var o=dn(n,Kn(Va));s|=w}return Qt(t,s,e,n,o)});function Ja(e,t,n){t=n?r:t;var s=Qt(e,Z,r,r,r,r,r,t);return s.placeholder=Ja.placeholder,s}function Ya(e,t,n){t=n?r:t;var s=Qt(e,ae,r,r,r,r,r,t);return s.placeholder=Ya.placeholder,s}function Xa(e,t,n){var s,o,c,m,x,y,A=0,E=!1,T=!1,W=!0;if(typeof e!="function")throw new kt(g);t=Lt(t)||0,We(n)&&(E=!!n.leading,T="maxWait"in n,c=T?Ve(Lt(n.maxWait)||0,t):c,W="trailing"in n?!!n.trailing:W);function V(He){var zt=s,sn=o;return s=o=r,A=He,m=e.apply(sn,zt),m}function Q(He){return A=He,x=mr(me,t),E?V(He):m}function ue(He){var zt=He-y,sn=He-A,pl=t-zt;return T?st(pl,c-sn):pl}function ee(He){var zt=He-y,sn=He-A;return y===r||zt>=t||zt<0||T&&sn>=c}function me(){var He=ls();if(ee(He))return xe(He);x=mr(me,ue(He))}function xe(He){return x=r,W&&s?V(He):(s=o=r,m)}function vt(){x!==r&&aa(x),A=0,s=y=o=x=r}function lt(){return x===r?m:xe(ls())}function _t(){var He=ls(),zt=ee(He);if(s=arguments,o=this,y=He,zt){if(x===r)return Q(y);if(T)return aa(x),x=mr(me,t),V(y)}return x===r&&(x=mr(me,t)),m}return _t.cancel=vt,_t.flush=lt,_t}var dh=he(function(e,t){return Fo(e,1,t)}),fh=he(function(e,t,n){return Fo(e,Lt(t)||0,n)});function hh(e){return Qt(e,B)}function cs(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new kt(g);var n=function(){var s=arguments,o=t?t.apply(this,s):s[0],c=n.cache;if(c.has(o))return c.get(o);var m=e.apply(this,s);return n.cache=c.set(o,m)||c,m};return n.cache=new(cs.Cache||Xt),n}cs.Cache=Xt;function us(e){if(typeof e!="function")throw new kt(g);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function gh(e){return qa(2,e)}var mh=ed(function(e,t){t=t.length==1&&ie(t[0])?Re(t[0],xt(X())):Re(rt(t,1),xt(X()));var n=t.length;return he(function(s){for(var o=-1,c=st(s.length,n);++o=t}),En=Ho(function(){return arguments}())?Ho:function(e){return Ue(e)&&ke.call(e,"callee")&&!Mo.call(e,"callee")},ie=S.isArray,Eh=fo?xt(fo):Du;function ft(e){return e!=null&&ds(e.length)&&!nn(e)}function Ge(e){return Ue(e)&&ft(e)}function Mh(e){return e===!0||e===!1||Ue(e)&&ot(e)==ct}var xn=Gc||Fi,Lh=ho?xt(ho):Wu;function Th(e){return Ue(e)&&e.nodeType===1&&!pr(e)}function Oh(e){if(e==null)return!0;if(ft(e)&&(ie(e)||typeof e=="string"||typeof e.splice=="function"||xn(e)||qn(e)||En(e)))return!e.length;var t=it(e);if(t==et||t==tt)return!e.size;if(gr(e))return!si(e).length;for(var n in e)if(ke.call(e,n))return!1;return!0}function Ph(e,t){return dr(e,t)}function Rh(e,t,n){n=typeof n=="function"?n:r;var s=n?n(e,t):r;return s===r?dr(e,t,r,n):!!s}function Ei(e){if(!Ue(e))return!1;var t=ot(e);return t==ze||t==qt||typeof e.message=="string"&&typeof e.name=="string"&&!pr(e)}function Dh(e){return typeof e=="number"&&To(e)}function nn(e){if(!We(e))return!1;var t=ot(e);return t==Tt||t==wt||t==Bt||t==Mn}function Qa(e){return typeof e=="number"&&e==oe(e)}function ds(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=K}function We(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Ue(e){return e!=null&&typeof e=="object"}var el=go?xt(go):Fu;function Wh(e,t){return e===t||ri(e,t,vi(t))}function zh(e,t,n){return n=typeof n=="function"?n:r,ri(e,t,vi(t),n)}function Fh(e){return tl(e)&&e!=+e}function Bh(e){if(Sd(e))throw new se(h);return Ko(e)}function Uh(e){return e===null}function $h(e){return e==null}function tl(e){return typeof e=="number"||Ue(e)&&ot(e)==mt}function pr(e){if(!Ue(e)||ot(e)!=ut)return!1;var t=Wr(e);if(t===null)return!0;var n=ke.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Or.call(n)==Wc}var Mi=mo?xt(mo):Bu;function Gh(e){return Qa(e)&&e>=-K&&e<=K}var nl=po?xt(po):Uu;function fs(e){return typeof e=="string"||!ie(e)&&Ue(e)&&ot(e)==$t}function yt(e){return typeof e=="symbol"||Ue(e)&&ot(e)==Ot}var qn=xo?xt(xo):$u;function Hh(e){return e===r}function Kh(e){return Ue(e)&&it(e)==q}function qh(e){return Ue(e)&&ot(e)==ce}var Vh=ns(ii),Jh=ns(function(e,t){return e<=t});function rl(e){if(!e)return[];if(ft(e))return fs(e)?Rt(e):dt(e);if(rr&&e[rr])return Ic(e[rr]());var t=it(e),n=t==et?Ks:t==tt?Mr:Vn;return n(e)}function rn(e){if(!e)return e===0?e:0;if(e=Lt(e),e===be||e===-be){var t=e<0?-1:1;return t*re}return e===e?e:0}function oe(e){var t=rn(e),n=t%1;return t===t?n?t-n:t:0}function sl(e){return e?In(oe(e),0,Y):0}function Lt(e){if(typeof e=="number")return e;if(yt(e))return $;if(We(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=We(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=So(e);var n=_n.test(e);return n||ln.test(e)?cc(e.slice(2),n?2:8):kr.test(e)?$:+e}function il(e){return Ht(e,ht(e))}function Yh(e){return e?In(oe(e),-K,K):e===0?e:0}function je(e){return e==null?"":bt(e)}var Xh=Gn(function(e,t){if(gr(t)||ft(t)){Ht(t,Xe(t),e);return}for(var n in t)ke.call(t,n)&&lr(e,n,t[n])}),ol=Gn(function(e,t){Ht(t,ht(t),e)}),hs=Gn(function(e,t,n,s){Ht(t,ht(t),e,s)}),Zh=Gn(function(e,t,n,s){Ht(t,Xe(t),e,s)}),Qh=en(Zs);function e0(e,t){var n=$n(e);return t==null?n:Wo(n,t)}var t0=he(function(e,t){e=Ae(e);var n=-1,s=t.length,o=s>2?t[2]:r;for(o&&at(t[0],t[1],o)&&(s=1);++n1),c}),Ht(e,bi(e),n),s&&(n=At(n,j|I|M,dd));for(var o=t.length;o--;)ui(n,t[o]);return n});function y0(e,t){return ll(e,us(X(t)))}var v0=en(function(e,t){return e==null?{}:Ku(e,t)});function ll(e,t){if(e==null)return{};var n=Re(bi(e),function(s){return[s]});return t=X(t),Qo(e,n,function(s,o){return t(s,o[0])})}function _0(e,t,n){t=mn(t,e);var s=-1,o=t.length;for(o||(o=1,e=r);++st){var s=e;e=t,t=s}if(n||e%1||t%1){var o=Oo();return st(e+o*(t-e+lc("1e-"+((o+"").length-1))),t)}return ai(e,t)}var L0=Hn(function(e,t,n){return t=t.toLowerCase(),e+(n?dl(t):t)});function dl(e){return Oi(je(e).toLowerCase())}function fl(e){return e=je(e),e&&e.replace(L,_c).replace(Zl,"")}function T0(e,t,n){e=je(e),t=bt(t);var s=e.length;n=n===r?s:In(oe(n),0,s);var o=n;return n-=t.length,n>=0&&e.slice(n,o)==t}function O0(e){return e=je(e),e&&ws.test(e)?e.replace(wr,wc):e}function P0(e){return e=je(e),e&&Zn.test(e)?e.replace(Ln,"\\$&"):e}var R0=Hn(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),D0=Hn(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),W0=ma("toLowerCase");function z0(e,t,n){e=je(e),t=oe(t);var s=t?Wn(e):0;if(!t||s>=t)return e;var o=(t-s)/2;return ts(Ur(o),n)+e+ts(Br(o),n)}function F0(e,t,n){e=je(e),t=oe(t);var s=t?Wn(e):0;return t&&s>>0,n?(e=je(e),e&&(typeof t=="string"||t!=null&&!Mi(t))&&(t=bt(t),!t&&Dn(e))?pn(Rt(e),0,n):e.split(t,n)):[]}var q0=Hn(function(e,t,n){return e+(n?" ":"")+Oi(t)});function V0(e,t,n){return e=je(e),n=n==null?0:In(oe(n),0,e.length),t=bt(t),e.slice(n,n+t.length)==t}function J0(e,t,n){var s=l.templateSettings;n&&at(e,t,n)&&(t=r),e=je(e),t=hs({},t,s,wa);var o=hs({},t.imports,s.imports,wa),c=Xe(o),m=Hs(o,c),x,y,A=0,E=t.interpolate||O,T="__p += '",W=qs((t.escape||O).source+"|"+E.source+"|"+(E===Nr?Ir:O).source+"|"+(t.evaluate||O).source+"|$","g"),V="//# sourceURL="+(ke.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rc+"]")+` `;e.replace(W,function(ee,me,xe,vt,lt,_t){return xe||(xe=vt),T+=e.slice(A,_t).replace(_e,Sc),me&&(x=!0,T+=`' + __e(`+me+`) + '`),lt&&(y=!0,T+=`'; `+lt+`; __p += '`),xe&&(T+=`' + ((__t = (`+xe+`)) == null ? '' : __t) + '`),A=_t+ee.length,ee}),T+=`'; `;var Q=ke.call(t,"variable")&&t.variable;if(!Q)T=`with (obj) { `+T+` } `;else if(jr.test(Q))throw new se(p);T=(y?T.replace(bs,""):T).replace(ys,"$1").replace(vs,"$1;"),T="function("+(Q||"obj")+`) { `+(Q?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(x?", __e = _.escape":"")+(y?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+T+`return __p }`;var ue=gl(function(){return Ne(c,V+"return "+T).apply(r,m)});if(ue.source=T,Ei(ue))throw ue;return ue}function Y0(e){return je(e).toLowerCase()}function X0(e){return je(e).toUpperCase()}function Z0(e,t,n){if(e=je(e),e&&(n||t===r))return So(e);if(!e||!(t=bt(t)))return e;var s=Rt(e),o=Rt(t),c=No(s,o),m=jo(s,o)+1;return pn(s,c,m).join("")}function Q0(e,t,n){if(e=je(e),e&&(n||t===r))return e.slice(0,ko(e)+1);if(!e||!(t=bt(t)))return e;var s=Rt(e),o=jo(s,Rt(t))+1;return pn(s,0,o).join("")}function eg(e,t,n){if(e=je(e),e&&(n||t===r))return e.replace(Qn,"");if(!e||!(t=bt(t)))return e;var s=Rt(e),o=No(s,Rt(t));return pn(s,o).join("")}function tg(e,t){var n=le,s=$e;if(We(t)){var o="separator"in t?t.separator:o;n="length"in t?oe(t.length):n,s="omission"in t?bt(t.omission):s}e=je(e);var c=e.length;if(Dn(e)){var m=Rt(e);c=m.length}if(n>=c)return e;var x=n-Wn(s);if(x<1)return s;var y=m?pn(m,0,x).join(""):e.slice(0,x);if(o===r)return y+s;if(m&&(x+=y.length-x),Mi(o)){if(e.slice(x).search(o)){var A,E=y;for(o.global||(o=qs(o.source,je(tr.exec(o))+"g")),o.lastIndex=0;A=o.exec(E);)var T=A.index;y=y.slice(0,T===r?x:T)}}else if(e.indexOf(bt(o),x)!=x){var W=y.lastIndexOf(o);W>-1&&(y=y.slice(0,W))}return y+s}function ng(e){return e=je(e),e&&_s.test(e)?e.replace(_r,Ec):e}var rg=Hn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Oi=ma("toUpperCase");function hl(e,t,n){return e=je(e),t=n?r:t,t===r?jc(e)?Tc(e):pc(e):e.match(t)||[]}var gl=he(function(e,t){try{return pt(e,r,t)}catch(n){return Ei(n)?n:new se(n)}}),sg=en(function(e,t){return It(t,function(n){n=Kt(n),Zt(e,n,Ci(e[n],e))}),e});function ig(e){var t=e==null?0:e.length,n=X();return e=t?Re(e,function(s){if(typeof s[1]!="function")throw new kt(g);return[n(s[0]),s[1]]}):[],he(function(s){for(var o=-1;++oK)return[];var n=Y,s=st(e,Y);t=X(t),e-=Y;for(var o=Gs(s,t);++n0||t<0)?new pe(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=oe(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},pe.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},pe.prototype.toArray=function(){return this.take(Y)},Gt(pe.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),s=/^(?:head|last)$/.test(t),o=l[s?"take"+(t=="last"?"Right":""):t],c=s||/^find/.test(t);o&&(l.prototype[t]=function(){var m=this.__wrapped__,x=s?[1]:arguments,y=m instanceof pe,A=x[0],E=y||ie(m),T=function(me){var xe=o.apply(l,un([me],x));return s&&W?xe[0]:xe};E&&n&&typeof A=="function"&&A.length!=1&&(y=E=!1);var W=this.__chain__,V=!!this.__actions__.length,Q=c&&!W,ue=y&&!V;if(!c&&E){m=ue?m:new pe(this);var ee=e.apply(m,x);return ee.__actions__.push({func:os,args:[T],thisArg:r}),new Ct(ee,W)}return Q&&ue?e.apply(this,x):(ee=this.thru(T),Q?s?ee.value()[0]:ee.value():ee)})}),It(["pop","push","shift","sort","splice","unshift"],function(e){var t=Lr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",s=/^(?:pop|shift)$/.test(e);l.prototype[e]=function(){var o=arguments;if(s&&!this.__chain__){var c=this.value();return t.apply(ie(c)?c:[],o)}return this[n](function(m){return t.apply(ie(m)?m:[],o)})}}),Gt(pe.prototype,function(e,t){var n=l[t];if(n){var s=n.name+"";ke.call(Un,s)||(Un[s]=[]),Un[s].push({name:t,func:n})}}),Un[Qr(r,z).name]=[{name:"wrapper",func:r}],pe.prototype.clone=tu,pe.prototype.reverse=nu,pe.prototype.value=ru,l.prototype.at=Tf,l.prototype.chain=Of,l.prototype.commit=Pf,l.prototype.next=Rf,l.prototype.plant=Wf,l.prototype.reverse=zf,l.prototype.toJSON=l.prototype.valueOf=l.prototype.value=Ff,l.prototype.first=l.prototype.head,rr&&(l.prototype[rr]=Df),l},zn=Oc();wn?((wn.exports=zn)._=zn,Rs._=zn):nt._=zn}).call(xr)})(ps,ps.exports);var $i=ps.exports;function Fm(a=!0){k.useEffect(()=>{if(!a)return;const u=$i.debounce(r=>{document.documentElement.style.setProperty("--mouse-x",`${r.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${r.clientY}px`)},16);return document.addEventListener("mousemove",u),()=>{u.cancel(),document.removeEventListener("mousemove",u)}},[a])}function Bm(a=!0){const{state:u,dispatch:r}=bn(),{activeTab:d,screenState:f}=u;k.useEffect(()=>{if(!a)return;const h=g=>{const p=d==="parameter-debug",v=d==="chat";//!screenState || screenState.currentScreen === 0; if(v||p){const N=Ce.canvas.selected_nodes;Object.keys(N??{}).length?r({type:"SET_SELECTED_NODE",payload:Object.values(N)}):r({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[r,a,d,f])}const Um=({selectedNodes:a,handleParamSelect:u,selectedParams:r,handleNext:d,handleClose:f})=>{const g=a.flatMap(p=>(p.widgets||[]).map(v=>v.name)).some(p=>r[p]===!0);return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select parameters"}),i.jsx("p",{className:"text-xs text-gray-500",children:"multiple selections supported"})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:f,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.map((p,v)=>{const N=p.title||"Unknown Node",_=p.widgets||[];return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:N}),i.jsx("div",{className:"p-4 space-y-3",children:i.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:_.map((j,I)=>{const M=j.name;return i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${r[M]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:P=>u(M,P),children:r[M]&&i.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),i.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:M})]},`widget-${I}`)})})})]},`node-${v}`)}),i.jsx("div",{className:"mt-6 flex justify-center",children:i.jsx("button",{onClick:p=>d(p),disabled:!g,className:`px-3 py-1.5 text-xs ${g?"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"})})]})},$m=({selectedNodes:a,paramTestValues:u,selectedParams:r,updateParamTestValues:d,toggleDropdown:f,openDropdowns:h,handleTestValueSelect:g,searchTerms:p,handleSearch:v,handleSelectAll:N,handleNext:_,handlePrevious:j,handleClose:I,inputValues:M,updateState:P,textInputs:R,handleTextInputChange:D,handleAddTextInput:z,handleRemoveTextInput:G,openAiWritingModal:Z})=>{const ae=(w,F,J,de=0)=>{if(w=isNaN(w)?0:w,F=isNaN(F)?100:F,J=isNaN(J)||J<=0?1:J,F{!a||a.length===0||a.forEach(w=>{const F=w.id.toString(),J=w.widgets||{};Object.values(J).forEach(B=>{const le=B.name;if(!r[le])return;if(!(u[F]?.[le]?.length>0)&&B.type==="number"){const U=B.options?.min||0,te=B.options?.max||100;let fe=(B.options?.step||10)/10;fe<.1&&(fe=.1);const ne=B.options?.precision||0,ve=ae(U,te,fe,ne);if(ve.length>0){d(F,le,ve);const be=`${F}_${le}`;P(ge.InputValues,{...M,[be]:{min:U.toString(),max:te.toString(),step:fe.toString()}})}}if(B.type==="customtext"||B.type.toLowerCase().includes("text")){const U=`${F}_${le}`,te=R[U]||[""];JSON.stringify(te)!==JSON.stringify(u[F]?.[le]||[""])&&d(F,le,te)}})})},[a,r,u,R,d,ae]),i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Set test values"}),i.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:I,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.length>0?a.map((w,F)=>{const J=w.widgets||{},de=Object.values(J),B=w.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.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:[i.jsxs("span",{children:[w.type," (ID: ",B,")"]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:le=>I(le,F),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"p-4 space-y-4",children:de.map((le,$e)=>{const U=le.name;if(!r[U])return null;const te=`${B}_${U}`;if(le.type==="customtext"||le.type.toLowerCase().includes("text")){const fe=R[te]||[""];return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[U,":"]}),i.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:()=>Z(B,U),children:[i.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"]})]}),i.jsx("div",{className:"space-y-2",children:fe.map((ne,ve)=>i.jsxs("div",{className:"flex items-start",children:[i.jsx("textarea",{className:`flex-1 border ${ne?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:ne,onChange:be=>D(B,U,ve,be.target.value),required:!0}),i.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>G(B,U,ve),title:"Remove",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},ve))}),i.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:()=>z(B,U),children:[i.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},$e)}if(le.type==="number"){const fe=le.options?.min||0,ne=le.options?.max||100,ve=(le.options?.step||10)/10,be=le.options?.precision||0,K=ae(fe,ne,ve,be),re=M[te]||{min:fe.toString(),max:ne.toString(),step:ve.toString()};return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[U,":"]}),i.jsx("div",{className:"w-4"})]}),i.jsxs("div",{className:"flex space-x-2 items-center",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:re.min,required:!0,onClick:$=>{$.preventDefault(),$.stopPropagation()},onChange:$=>{$.preventDefault(),$.stopPropagation();const Y=$.target.value;if(P(ge.InputValues,{...M,[te]:{...M[te],min:Y}}),Y===""||!isNaN(parseFloat(Y))){const we=Y===""?0:parseFloat(Y),Me=parseFloat(re.max||ne.toString()),Oe=parseFloat(re.step||ve.toString()),Ie=ae(we,Me,Oe,be);d(B,U,Ie)}}}),i.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:re.max,onClick:$=>{$.preventDefault(),$.stopPropagation()},required:!0,onChange:$=>{$.preventDefault(),$.stopPropagation();const Y=$.target.value;if(P(ge.InputValues,{...M,[te]:{...M[te],max:Y}}),Y===""||!isNaN(parseFloat(Y))){const we=parseFloat(re.min||fe.toString()),Me=Y===""?we:parseFloat(Y),Oe=parseFloat(re.step||ve.toString()),Ie=ae(we,Me,Oe,be);d(B,U,Ie)}}}),i.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:re.step,required:!0,onClick:$=>{$.preventDefault(),$.stopPropagation()},onChange:$=>{$.preventDefault(),$.stopPropagation();const Y=$.target.value;if(P(ge.InputValues,{...M,[te]:{...M[te],step:Y}}),Y===""||!isNaN(parseFloat(Y))&&parseFloat(Y)>0){const we=parseFloat(re.min||fe.toString()),Me=parseFloat(re.max||ne.toString());let Oe=Y===""?1:parseFloat(Y);Oe<.1&&(Oe=.1);const Ie=ae(we,Me,Oe,be);d(B,U,Ie)}}})]}),i.jsxs("div",{className:"mt-1",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),i.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(()=>{const $=u[B]?.[U]||K;if($.length<=10)return $.map((Y,we)=>i.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:Me=>{Me.stopPropagation(),g(B,U,Y,Me)},children:[i.jsx("span",{children:Y}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},we));{const Y=$.slice(0,5),we=$.slice($.length-5);return i.jsxs(i.Fragment,{children:[Y.map((Me,Oe)=>i.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:Ie=>{Ie.stopPropagation(),g(B,U,Me,Ie)},children:[i.jsx("span",{children:Me}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`first-${Oe}`)),i.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),we.map((Me,Oe)=>i.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:Ie=>{Ie.stopPropagation(),g(B,U,Me,Ie)},children:[i.jsx("span",{children:Me}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`last-${Oe}`))]})}})()})]}),i.jsx("div",{className:"mt-1",children:i.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max"})})]},$e)}else if(le.type==="combo"){const fe=le.options?.values||[],ne=`${B}_${U}`,ve=K=>typeof K=="string"?K:K&&typeof K=="object"&&"name"in K?K.name:String(K),be=K=>typeof K=="object"&&K!==null&&"name"in K?K.name:K;return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("label",{className:"text-xs font-medium text-gray-700",children:U}),i.jsxs("div",{className:"relative dropdown-container",children:[i.jsxs("button",{className:`appearance-none border ${(u[B]?.[U]||[]).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:K=>{K.preventDefault(),K.stopPropagation(),f(B,U,K)},"data-dropdown":ne,children:[i.jsx("span",{children:(u[B]?.[U]||[]).length>0?`${U}: ${(u[B]?.[U]||[]).length} selected`:`Select ${U}`}),i.jsx("div",{className:"ml-2",children:i.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:i.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),h[ne]&&i.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 h[ne]=="object"?`${h[ne].y}px`:"0px",left:typeof h[ne]=="object"?`${h[ne].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[i.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:i.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:p[ne]||"",onChange:K=>{K.preventDefault(),K.stopPropagation(),v(B,U,K.target.value)},onClick:K=>{K.preventDefault(),K.stopPropagation()},autoFocus:!0})}),i.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:K=>{K.preventDefault(),K.stopPropagation();const $=fe.filter(Y=>!p[ne]||ve(Y).toLowerCase().includes((p[ne]||"").toLowerCase())).map(be);N(B,U,$)},children:[i.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${fe.length>0&&(u[B]?.[U]||[]).length===fe.length?"bg-blue-500 border-blue-500":(u[B]?.[U]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(u[B]?.[U]||[]).length>0&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("span",{className:"font-medium",children:fe.length>0&&(u[B]?.[U]||[]).length===fe.length?"Deselect All":"Select All"})]}),i.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[fe.filter(K=>!p[ne]||ve(K).toLowerCase().includes((p[ne]||"").toLowerCase())).map((K,re)=>i.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:$=>{$.preventDefault(),$.stopPropagation(),g(B,U,be(K),$)},children:[i.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(u[B]?.[U]||[]).includes(be(K))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(u[B]?.[U]||[]).includes(be(K))&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:ve(K)})]},re)),fe.filter(K=>!p[ne]||ve(K).toLowerCase().includes((p[ne]||"").toLowerCase())).length===0&&i.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),(u[B]?.[U]||[]).length===0&&i.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),i.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(u[B]?.[U]||[]).map((K,re)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[i.jsx("span",{children:K}),i.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:$=>{$.preventDefault(),$.stopPropagation(),g(B,U,K,$)},children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},re))})]})]},$e)}else return i.jsxs("div",{className:"border-b pb-3",children:[i.jsx("div",{className:"flex justify-between items-center",children:i.jsx("label",{className:"text-xs font-medium text-gray-700",children:U})}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),i.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(u[B]?.[U]||[]).map((fe,ne)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[i.jsx("span",{children:fe}),i.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:ve=>{ve.preventDefault(),ve.stopPropagation(),g(B,U,fe,ve)},children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},ne)),i.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:fe=>{fe.preventDefault(),fe.stopPropagation();const ne=`${U}${(u[B]?.[U]||[]).length+1}`;d(B,U,[...u[B]?.[U]||[],ne])},children:[i.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),i.jsx("span",{children:"Add"})]})]})]})]},$e)})})]},F)}):i.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."}),i.jsxs("div",{className:"mt-6 flex justify-between",children:[i.jsx("button",{onClick:w=>j(w),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),i.jsx("button",{onClick:w=>_(w),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},Gm=({selectedNodes:a,paramTestValues:u,selectedParams:r,totalCount:d,errorMessage:f,handlePrevious:h,handleStartGeneration:g,handleClose:p})=>{const[v,N]=k.useState([]),[_,j]=k.useState(null),[I,M]=k.useState(!1),{dispatch:P}=bn(),R=()=>{const z=Object.values(Ce.graph._nodes_by_id),G=[],Z=[];for(const w of z)w.type==="SaveImage"?G.push(w.id):w.type==="PreviewImage"&&Z.push(w.id);const ae=[...G,...Z];N(ae),ae.length===1?j(ae[0]):ae.length>1&&(M(!0),j(null))};k.useEffect(()=>{R()},[]),k.useEffect(()=>{const z=()=>{if(!Ce.canvas.selected_nodes)return;const G=Object.values(Ce.canvas.selected_nodes);if(G.length===0)return;const Z=G[0];Z&&(Z.type==="SaveImage"||Z.type==="PreviewImage")&&(console.log("Selected image node:",Z.id),j(Z.id))};return document.addEventListener("click",z),()=>{document.removeEventListener("click",z)}},[]);const D=z=>{if(z&&(z.preventDefault(),z.stopPropagation()),v.length>1&&!_){M(!0);return}g(z,_||void 0)};return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Conform combinations"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",d," total runs. Each run will generate a separate image."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:p,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),I&&v.length>1&&i.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:_===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${v.join(",")}. Please click the node on canvas.`:`Current node ID is ${_}, please click Start Generation again`})]})}),f&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:f})]})}),a.length>0?a.map((z,G)=>{const Z=z.type||"Unknown Node",ae=z.widgets||[],w=z.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[Z," (ID: ",w,")"]}),i.jsx("div",{className:"p-4 space-y-3",children:ae.map((F,J)=>{const de=F.name;if(!r[de])return null;const B=u[w]?.[de]||[],le=Array.isArray(B)?`[${B.join(", ")}]`:JSON.stringify(B);return i.jsxs("div",{className:J$e.preventDefault()})})]},J)})})]},G)}):i.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."}),i.jsxs("div",{className:"mt-6 flex justify-between",children:[i.jsx("button",{onClick:z=>h(z),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),i.jsx("button",{onClick:z=>D(z),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${v.length>1&&!_?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:v.length>1&&!_,children:"Generate & Compare"})]})]})},Hm=({selectedNodes:a,paramTestValues:u,selectedParams:r,totalCount:d,completedCount:f,errorMessage:h,handleClose:g,updateState:p,cleanupPolling:v})=>{const N=_=>{_.preventDefault(),_.stopPropagation(),Dm({clear:!0}),Wm(),v&&v(),p(ge.IsProcessing,!1),p(ge.CurrentSceen,2)};return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[i.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:i.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[i.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),i.jsxs("div",{className:"text-xs mb-3",children:["Completed ",f," of ",d," runs"]}),i.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${f/d*100}%`}})}),i.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",f," images"]}),i.jsx("button",{onClick:N,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"})]})}),i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",d," total runs. Each run will generate a separate image."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:g,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:h})]})}),a.length>0?a.map((_,j)=>{const I=_.type||"Unknown Node",M=_.widgets||[],P=_.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[I," (ID: ",P,")"]}),i.jsx("div",{className:"p-4 space-y-3",children:M.map((R,D)=>{const z=R.name;if(!r[z])return null;const G=u[P]?.[z]||[],Z=Array.isArray(G)?`[${G.join(", ")}]`:JSON.stringify(G);return i.jsxs("div",{className:Dae.preventDefault()})})]},D)})})]},j)}):i.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."})]})},br=({visible:a,imageUrl:u,params:r,onClose:d})=>{if(!a)return null;const f=()=>{if(!r||!r.nodeParams)return null;const h=Object.entries(r.nodeParams).map(([g,p])=>{const v=r.nodeNames?.[g]||r.selectedNodeInfoMap&&r.selectedNodeInfoMap[g]||(g.includes("text")?"Text Node":`Node ${g}`),N=Object.entries(p).filter(([_,j])=>typeof j!="object"||j===null).map(([_,j])=>i.jsxs("div",{className:"pl-4 text-sm py-1 flex",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400 mr-2",children:"-"}),i.jsxs("span",{className:"font-medium mr-1",children:[_,":"]}),i.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-all",children:String(j)})]},_));return i.jsxs("div",{className:"mb-4",children:[i.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:v}),N.length>0?N:i.jsx("div",{className:"pl-4 text-sm text-gray-500 italic",children:"nodeParams is null"})]},g)});return i.jsx("div",{className:"overflow-y-auto max-h-full",children:h.length>0?h:i.jsx("div",{className:"text-sm text-gray-500 italic",children:"nodeParams is null"})})};return i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",onClick:d,children:i.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:h=>h.stopPropagation(),style:{display:"flex",flexDirection:"row"},children:[i.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:d,children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),i.jsx("div",{className:"w-[65%] border-r border-gray-200 dark:border-gray-700",children:i.jsx("div",{className:"p-4 h-full flex items-center justify-center",children:i.jsx("img",{src:u,alt:"Enlarged image",className:"max-w-full max-h-[calc(90vh-2rem)] object-contain"})})}),i.jsx("div",{className:"w-[35%] h-full overflow-hidden flex flex-col",children:i.jsxs("div",{className:"p-4 flex-1 overflow-y-auto",children:[i.jsx("h3",{className:"text-lg font-medium text-gray-800 dark:text-gray-200 mb-4",children:"Parameters"}),r&&!r.nodeParams&&Object.entries(r).filter(([h,g])=>h!=="nodeParams"&&typeof g!="object").map(([h,g])=>i.jsxs("div",{className:"py-1 text-sm text-gray-600 dark:text-gray-300",children:[i.jsxs("span",{className:"font-medium",children:[h,":"]})," ",String(g)]},h)),i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:f()})]})})]})})};function Yn(a,u,r){let d=r.initialDeps??[],f;function h(){var g,p,v,N;let _;r.key&&((g=r.debug)!=null&&g.call(r))&&(_=Date.now());const j=a();if(!(j.length!==d.length||j.some((P,R)=>d[R]!==P)))return f;d=j;let M;if(r.key&&((p=r.debug)!=null&&p.call(r))&&(M=Date.now()),f=u(...j),r.key&&((v=r.debug)!=null&&v.call(r))){const P=Math.round((Date.now()-_)*100)/100,R=Math.round((Date.now()-M)*100)/100,D=R/16,z=(G,Z)=>{for(G=String(G);G.length{d=g},h}function yl(a,u){if(a===void 0)throw new Error("Unexpected undefined");return a}const Km=(a,u)=>Math.abs(a-u)<1.01,qm=(a,u,r)=>{let d;return function(...f){a.clearTimeout(d),d=a.setTimeout(()=>u.apply(this,f),r)}},vl=a=>{const{offsetWidth:u,offsetHeight:r}=a;return{width:u,height:r}},Vm=a=>a,Jm=a=>{const u=Math.max(a.startIndex-a.overscan,0),r=Math.min(a.endIndex+a.overscan,a.count-1),d=[];for(let f=u;f<=r;f++)d.push(f);return d},Ym=(a,u)=>{const r=a.scrollElement;if(!r)return;const d=a.targetWindow;if(!d)return;const f=g=>{const{width:p,height:v}=g;u({width:Math.round(p),height:Math.round(v)})};if(f(vl(r)),!d.ResizeObserver)return()=>{};const h=new d.ResizeObserver(g=>{const p=()=>{const v=g[0];if(v?.borderBoxSize){const N=v.borderBoxSize[0];if(N){f({width:N.inlineSize,height:N.blockSize});return}}f(vl(r))};a.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(p):p()});return h.observe(r,{box:"border-box"}),()=>{h.unobserve(r)}},_l={passive:!0},wl=typeof window>"u"?!0:"onscrollend"in window,Xm=(a,u)=>{const r=a.scrollElement;if(!r)return;const d=a.targetWindow;if(!d)return;let f=0;const h=a.options.useScrollendEvent&&wl?()=>{}:qm(d,()=>{u(f,!1)},a.options.isScrollingResetDelay),g=_=>()=>{const{horizontal:j,isRtl:I}=a.options;f=j?r.scrollLeft*(I&&-1||1):r.scrollTop,h(),u(f,_)},p=g(!0),v=g(!1);v(),r.addEventListener("scroll",p,_l);const N=a.options.useScrollendEvent&&wl;return N&&r.addEventListener("scrollend",v,_l),()=>{r.removeEventListener("scroll",p),N&&r.removeEventListener("scrollend",v)}},Zm=(a,u,r)=>{if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d)return Math.round(d[r.options.horizontal?"inlineSize":"blockSize"])}return a[r.options.horizontal?"offsetWidth":"offsetHeight"]},Qm=(a,{adjustments:u=0,behavior:r},d)=>{var f,h;const g=a+u;(h=(f=d.scrollElement)==null?void 0:f.scrollTo)==null||h.call(f,{[d.options.horizontal?"left":"top"]:g,behavior:r})};class ep{constructor(u){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let r=null;const d=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(f=>{f.forEach(h=>{const g=()=>{this._measureElement(h.target,h)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(g):g()})}));return{disconnect:()=>{var f;(f=d())==null||f.disconnect(),r=null},observe:f=>{var h;return(h=d())==null?void 0:h.observe(f,{box:"border-box"})},unobserve:f=>{var h;return(h=d())==null?void 0:h.unobserve(f)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([d,f])=>{typeof f>"u"&&delete r[d]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Vm,rangeExtractor:Jm,onChange:()=>{},measureElement:Zm,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var d,f;(f=(d=this.options).onChange)==null||f.call(d,this,r)},this.maybeNotify=Yn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const d=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==d){if(this.cleanup(),!d){this.maybeNotify();return}this.scrollElement=d,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(f=>{this.observer.observe(f)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,f=>{this.scrollRect=f,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(f,h)=>{this.scrollAdjustments=0,this.scrollDirection=h?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,d)=>{const f=new Map,h=new Map;for(let g=d-1;g>=0;g--){const p=r[g];if(f.has(p.lane))continue;const v=h.get(p.lane);if(v==null||p.end>v.end?h.set(p.lane,p):p.endg.end===p.end?g.index-p.index:g.end-p.end)[0]:void 0},this.getMeasurementOptions=Yn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(r,d,f,h,g)=>(this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:d,scrollMargin:f,getItemKey:h,enabled:g}),{key:!1}),this.getMeasurements=Yn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:d,scrollMargin:f,getItemKey:h,enabled:g},p)=>{if(!g)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(_=>{this.itemSizeCache.set(_.key,_.size)}));const v=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const N=this.measurementsCache.slice(0,v);for(let _=v;_this.options.debug}),this.calculateRange=Yn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,d,f,h)=>this.range=r.length>0&&d>0?tp({measurements:r,outerSize:d,scrollOffset:f,lanes:h}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yn(()=>{let r=null,d=null;const f=this.calculateRange();return f&&(r=f.startIndex,d=f.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,d]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,d]},(r,d,f,h,g)=>h===null||g===null?[]:r({startIndex:h,endIndex:g,overscan:d,count:f}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const d=this.options.indexAttribute,f=r.getAttribute(d);return f?parseInt(f,10):(console.warn(`Missing attribute name '${d}={index}' on measured element.`),-1)},this._measureElement=(r,d)=>{const f=this.indexFromElement(r),h=this.measurementsCache[f];if(!h)return;const g=h.key,p=this.elementsCache.get(g);p!==r&&(p&&this.observer.unobserve(p),this.observer.observe(r),this.elementsCache.set(g,r)),r.isConnected&&this.resizeItem(f,this.options.measureElement(r,d,this))},this.resizeItem=(r,d)=>{const f=this.measurementsCache[r];if(!f)return;const h=this.itemSizeCache.get(f.key)??f.size,g=d-h;g!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(f,g,this):f.start{if(!r){this.elementsCache.forEach((d,f)=>{d.isConnected||(this.observer.unobserve(d),this.elementsCache.delete(f))});return}this._measureElement(r,void 0)},this.getVirtualItems=Yn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,d)=>{const f=[];for(let h=0,g=r.length;hthis.options.debug}),this.getVirtualItemForOffset=r=>{const d=this.getMeasurements();if(d.length!==0)return yl(d[El(0,d.length-1,f=>yl(d[f]).start,r)])},this.getOffsetForAlignment=(r,d,f=0)=>{const h=this.getSize(),g=this.getScrollOffset();d==="auto"&&(d=r>=g+h?"end":"start"),d==="center"?r+=(f-h)/2:d==="end"&&(r-=h);const p=this.getTotalSize()+this.options.scrollMargin-h;return Math.max(Math.min(p,r),0)},this.getOffsetForIndex=(r,d="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const f=this.measurementsCache[r];if(!f)return;const h=this.getSize(),g=this.getScrollOffset();if(d==="auto")if(f.end>=g+h-this.options.scrollPaddingEnd)d="end";else if(f.start<=g+this.options.scrollPaddingStart)d="start";else return[g,d];const p=d==="end"?f.end+this.options.scrollPaddingEnd:f.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(p,d,f.size),d]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(r,{align:d="start",behavior:f}={})=>{f==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(r,d),{adjustments:void 0,behavior:f})},this.scrollToIndex=(r,{align:d="auto",behavior:f}={})=>{f==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),r=Math.max(0,Math.min(r,this.options.count-1));let h=0;const g=10,p=N=>{if(!this.targetWindow)return;const _=this.getOffsetForIndex(r,N);if(!_){console.warn("Failed to get offset for index:",r);return}const[j,I]=_;this._scrollToOffset(j,{adjustments:void 0,behavior:f}),this.targetWindow.requestAnimationFrame(()=>{const M=this.getScrollOffset(),P=this.getOffsetForIndex(r,I);if(!P){console.warn("Failed to get offset for index:",r);return}Km(P[0],M)||v(I)})},v=N=>{this.targetWindow&&(h++,hp(N)):console.warn(`Failed to scroll to index ${r} after ${g} attempts.`))};p(d)},this.scrollBy=(r,{behavior:d}={})=>{d==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+r,{adjustments:void 0,behavior:d})},this.getTotalSize=()=>{var r;const d=this.getMeasurements();let f;if(d.length===0)f=this.options.paddingStart;else if(this.options.lanes===1)f=((r=d[d.length-1])==null?void 0:r.end)??0;else{const h=Array(this.options.lanes).fill(null);let g=d.length-1;for(;g>=0&&h.some(p=>p===null);){const p=d[g];h[p.lane]===null&&(h[p.lane]=p.end),g--}f=Math.max(...h.filter(p=>p!==null))}return Math.max(f-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:d,behavior:f})=>{this.options.scrollToFn(r,{behavior:f,adjustments:d},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(u)}}const El=(a,u,r,d)=>{for(;a<=u;){const f=(a+u)/2|0,h=r(f);if(hd)u=f-1;else return f}return a>0?a-1:0};function tp({measurements:a,outerSize:u,scrollOffset:r,lanes:d}){const f=a.length-1,h=v=>a[v].start;if(a.length<=d)return{startIndex:0,endIndex:f};let g=El(0,f,h,r),p=g;if(d===1)for(;p1){const v=Array(d).fill(0);for(;p_=0&&N.some(_=>_>=r);){const _=a[g];N[_.lane]=_.start,g--}g=Math.max(0,g-g%d),p=Math.min(f,p+(d-1-p%d))}return{startIndex:g,endIndex:p}}const Sl=typeof document<"u"?k.useLayoutEffect:k.useEffect;function np(a){const u=k.useReducer(()=>({}),{})[1],r={...a,onChange:(f,h)=>{var g;h?Hg.flushSync(u):u(),(g=a.onChange)==null||g.call(a,f,h)}},[d]=k.useState(()=>new ep(r));return d.setOptions(r),Sl(()=>d._didMount(),[]),Sl(()=>d._willUpdate()),d}function rp(a){return np({observeElementRect:Ym,observeElementOffset:Xm,scrollToFn:Qm,...a})}const Ml=a=>{const{items:u,renderItem:r,minWidth:d=200,gap:f=16}=a,h=k.useRef(null),[g,p]=k.useState(1),[v,N]=k.useState(0);k.useLayoutEffect(()=>{if(!h.current)return;const j=()=>{if(h.current){const M=h.current.offsetWidth,P=Math.max(1,Math.floor(M/(d+f/2)));p(P),N(Math.ceil(u.length/P))}};j();const I=new window.ResizeObserver($i.debounce(j,50));return I.observe(h.current),()=>I.disconnect()},[]);const _=rp({count:v,getScrollElement:()=>h.current,estimateSize:()=>d+40,overscan:3,gap:f});return i.jsx("div",{ref:h,className:"h-full relative overflow-auto hide-scrollbar",children:i.jsx("div",{style:{height:_.getTotalSize(),position:"relative"},children:_.getVirtualItems().map(j=>{const I=j.index,M=I*g,P=Math.min(M+g,u.length);return i.jsx("div",{"data-index":I,ref:_.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${j.start}px)`,display:"grid",gridTemplateColumns:`repeat(${g}, minmax(${d}px, 1fr))`,gap:`${f}px`},children:u.slice(M,P).map((R,D)=>r(R,M+D))},I)})})})},sp=({generatedImages:a,selectedImageIndex:u,handleSelectImage:r,handleApplySelected:d,handleClose:f,notificationVisible:h,modalVisible:g,modalImageUrl:p,modalImageParams:v,openImageModal:N,closeImageModal:_})=>{const j=(I,M)=>i.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${u===I.index?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:P=>r(M,P),children:[i.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:P=>N(I.url,I.params,P),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"})})}),i.jsx("div",{className:"aspect-square",children:i.jsx("img",{src:I.url,alt:`Generated image ${M+1}`,className:"w-full h-full object-cover"})}),i.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(I.params).filter(([P,R])=>P!=="nodeParams"&&typeof R!="object").map(([P,R])=>i.jsxs("div",{children:[P,": ",String(R)]},P))})]},M.toString());return i.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["All ",a.length," images have been generated."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:f,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&i.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:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"py-1",children:i.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Ml,{items:a,renderItem:j})}),i.jsx("div",{className:"mt-6 flex justify-end",children:i.jsx("button",{onClick:I=>d(I),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:u===null,children:"Apply Selected"})}),i.jsx(br,{visible:g,imageUrl:p,params:v||{},onClose:_})]})},ip=({visible:a,aiWritingModalText:u,setAiWritingModalText:r,aiGeneratedTexts:d,aiSelectedTexts:f,aiWritingLoading:h,aiWritingError:g,handleAiWriting:p,toggleTextSelection:v,addSelectedTexts:N,onClose:_})=>a?i.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:i.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:[i.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),i.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:_,children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),i.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 focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:outline-none`,rows:3,placeholder:"Enter some text here...",value:u,onChange:j=>r(j.target.value)}),i.jsx("button",{className:`mt-2 px-4 py-2 rounded-lg text-sm flex items-center transition-colors ${h?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,onClick:p,disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-gray-500 dark:text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):i.jsx(i.Fragment,{children:"Generate"})})]}),g&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/20 rounded-md text-red-700 dark:text-red-400 text-sm",children:g}),d.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Generated variations (select items to add):"}),i.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:d.map((j,I)=>i.jsxs("div",{className:"flex items-start border border-gray-200 dark:border-gray-600 rounded-md p-2",children:[i.jsx("div",{className:"mr-2 mt-1",children:i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"checkbox",id:`text${I+1}`,checked:!!f[`text${I+1}`],onChange:()=>v(`text${I+1}`),className:"sr-only"}),i.jsx("div",{className:`h-4 w-4 rounded border ${f[`text${I+1}`]?"bg-blue-600 dark:bg-blue-500 border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600"} flex items-center justify-center cursor-pointer`,onClick:()=>v(`text${I+1}`),children:f[`text${I+1}`]&&i.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),i.jsx("label",{htmlFor:`text${I+1}`,className:"text-sm text-gray-700 dark:text-gray-300 cursor-pointer flex-1",children:j})]},I))})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end flex-shrink-0",children:[i.jsx("button",{className:`px-5 py-2.5 text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg font-medium transition-colors mr-3`,onClick:_,children:"Cancel"}),i.jsx("button",{className:`px-5 py-2.5 rounded-lg font-medium transition-colors ${Object.values(f).every(j=>!j)?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,onClick:N,disabled:Object.values(f).every(j=>!j),children:"Add Selected"})]})]})}):null,Ui=a=>{const u=[],r={};if(Object.keys(a).forEach(h=>{const g=parseInt(h),p=a[h]||{},v=Object.keys(p).filter(_=>p[_]&&p[_].length>0);if(v.length===0)return;const N=[[]];v.forEach(_=>{const j=p[_],I=[];N.forEach(M=>{j.forEach(P=>{const R=[...M,{nodeId:g,paramName:_,paramValue:String(P)}];I.push(R)})}),N.length=0,N.push(...I)}),r[h]=N}),Object.keys(r).length===0)return u;if(Object.keys(r).length===1){const h=Object.keys(r)[0];return r[h]}const d=Object.keys(r);let f=r[d[0]];for(let h=1;h{g.forEach(N=>{p.push([...v,...N])})}),f=p}return f},op=(a,u)=>{const r={};r.nodeParams={};const d=Ui(a);return u{const g=h.nodeId.toString(),p=h.paramName,v=h.paramValue;r.nodeParams[g]||(r.nodeParams[g]={}),r.nodeParams[g][p]=v,r[p]=v}),r},Ll="parameter_debug_history",Nl=30,jl=async(a,u,r,d,f)=>{try{const h=Tl(),g={id:Ze(),timestamp:Date.now(),title:Gi(a,u),nodeName:a,params:{...u,nodeNames:{...u.nodeNames||{},[a.split("<")[0]]:a.split("<")[0]}},generatedImages:r,totalCount:d,workflow:f};return h.unshift(g),h.length>Nl&&h.splice(Nl),localStorage.setItem(Ll,JSON.stringify(h)),g}catch(h){return console.error("Error saving parameter debug history:",h),null}},Tl=()=>{try{const a=localStorage.getItem(Ll);if(a)return JSON.parse(a)}catch(a){console.error("Error loading parameter debug history:",a)}return[]},Ol=a=>{const u=new Date(a);return`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")} ${String(u.getHours()).padStart(2,"0")}:${String(u.getMinutes()).padStart(2,"0")}`},Gi=(a,u)=>{if(u.nodeParams)return Object.entries(u.nodeParams).map(([h,g])=>{let p=a;u.selectedNodeInfoMap&&u.selectedNodeInfoMap[h]&&(p=u.selectedNodeInfoMap[h]);const v=Object.keys(g).slice(0,3);return`${p}<${v.join(",")}>`}).join(";");const r=Object.keys(u).filter(d=>d!=="nodeParams"&&d!=="selectedNodeInfoMap").slice(0,3);return`${a}<${r.join(",")}>`},ap=({historyItems:a,onViewHistoryItem:u,onClose:r})=>i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 flex flex-col h-full",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Experiments History"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["Last ",a.length," experiments"]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:r,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.length===0?i.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500 text-sm",children:"No history items found"}):i.jsx("div",{className:"flex-1 overflow-y-auto",children:a.map(d=>i.jsxs("div",{className:"border border-gray-200 rounded-lg mb-3 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 py-2 px-3 flex items-center justify-between border-b",children:[i.jsx("div",{className:"text-[14px] text-gray-600",children:Ol(d.timestamp)}),i.jsx("button",{onClick:()=>u(d),className:"px-3 py-1 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"view"})]}),i.jsx("div",{className:"p-3",children:i.jsx("div",{className:"text-[10px] font-medium text-gray-700",children:Gi(d.nodeName,d.params)})})]},d.id))})]}),lp=({historyItem:a,selectedImageIndex:u,handleSelectImage:r,handleClose:d,modalVisible:f,modalImageUrl:h,modalImageParams:g,openImageModal:p,closeImageModal:v})=>{const{timestamp:N,nodeName:_,generatedImages:j,params:I}=a,M=(P,R)=>i.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${u===R?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:D=>r(R,D),children:[i.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:D=>p(P.url,P.params,D),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"})})}),i.jsx("div",{className:"aspect-square",children:i.jsx("img",{src:P.url,alt:`Generated image ${R+1}`,className:"w-full h-full object-cover"})}),i.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(P.params).filter(([D,z])=>D!=="nodeParams"&&typeof z!="object").map(([D,z])=>i.jsxs("div",{children:[D,": ",String(z)]},D))})]},R.toString());return i.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-start",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"text-base font-medium text-gray-800 truncate hover:!break-words hover:!whitespace-normal hover:!overflow-visible",children:Gi(_,I)}),i.jsxs("p",{className:"text-xs text-gray-500",children:[Ol(N)," • ",j.length," images"]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600 mt-0",onClick:d,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Ml,{items:j,renderItem:M})}),i.jsx(br,{visible:f,imageUrl:h,params:g?{...g,nodeNames:{[a.nodeName.split("<")[0]]:a.nodeName.split("<")[0]}}:void 0,onClose:v})]})},cp=` @keyframes highlight-pulse { 0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); } 70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); } 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); } } .highlight-pulse { animation: highlight-pulse 1.5s infinite; border: 2px solid #3b82f6; } @keyframes fade-in-out { 0% { opacity: 0; transform: translateY(-20px); } 10% { opacity: 1; transform: translateY(0); } 90% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-20px); } } .animate-fade-in-out { animation: fade-in-out 3s forwards; } `,yr="parameter_debug_state",up=a=>{try{localStorage.setItem(yr,JSON.stringify(a))}catch(u){console.error("Error saving parameter debug state:",u)}},dp=()=>{try{const a=localStorage.getItem(yr);if(a)return JSON.parse(a)}catch(a){console.error("Error loading parameter debug state:",a)}return null},fp=()=>{try{localStorage.removeItem(yr)}catch(a){console.error("Error clearing parameter debug state:",a)}},hp=(a,u,r,d,f,h)=>{const g=`${a}_${u}`,p=[...f[g]||[]];return p[r]=d,h(ge.TextInputs,{...f,[g]:p.map((v,N)=>N===r?d:v)}),p},gp=(a,u,r,d)=>{const f=`${a}_${u}`,h=[...r[f]||[]];return h.push(""),d(ge.TextInputs,{...r,[f]:h}),h},mp=(a,u,r,d,f)=>{const h=`${a}_${u}`,g=[...d[h]||[]];return g.splice(r,1),f(ge.TextInputs,{...d,[h]:g}),g},pp=(a,u,r,d,f)=>{r.preventDefault(),r.stopPropagation();const h=`${a}_${u}`;f(g=>{if(g[h]&&typeof g[h]=="object"?g[h].isOpen:!!g[h])return{...g,[h]:!1};{let v=0,N=0;if(r.currentTarget){const I=r.currentTarget.getBoundingClientRect();v=I.left,N=I.bottom}else v=r.clientX,N=r.clientY+20;const _=window.innerWidth,j=250;return v+j>_&&(v=_-j-10),v<0&&(v=10),{...g,[h]:{isOpen:!0,x:v,y:N}}}})},xp=(a,u,r,d,f)=>{const h={...d};h[a]||(h[a]={}),h[a][u]=r,f(ge.ParamTestValues,h)},bp=(a,u,r,d,f,h)=>{h&&(h.preventDefault(),h.stopPropagation());const g={...d};g[a]||(g[a]={}),g[a][u]||(g[a][u]=[]);const p=g[a][u];p.includes(r)?g[a][u]=p.filter(v=>v!==r):g[a][u]=[...p,r],f(ge.ParamTestValues,g)},yp=(a,u,r,d,f)=>{const h=`${a}_${u}`;f(ge.SearchTerms,{...d,[h]:r})},vp=(a,u,r,d,f)=>{if(!d[a]){f(a,u,r);return}const h=d[a][u]||[];r.length===h.length?f(a,u,[]):f(a,u,[...r])},_p=(a,u,r,d,f)=>{f&&(f.preventDefault(),f.stopPropagation());const h=u[a];if(d(ge.SelectedParams,{...u,[a]:!h}),h){const g={...r};Object.keys(g).forEach(p=>{g[p][a]&&delete g[p][a]}),d(ge.ParamTestValues,g)}},wp=(a,u,r,d,f,h,g)=>{g.preventDefault(),g.stopPropagation();const p={...u};if(u.nodeParams){const v={};Object.keys(u.nodeParams).forEach(N=>{const _=r.find(j=>j.id.toString()===N);v[N]=_?_.title||`Node ${N}`:`Node ${N}`}),p.nodeNames=v}else if(Object.keys(u).length>0){const v={};Object.entries(u).forEach(([N,_])=>{(typeof _!="object"||_===null)&&(v[N]=_)}),Object.keys(v).length>0&&(p.nodeParams={default:v},p.nodeNames={default:u.node_name||u.nodeName||"参数"})}d(a),f(p),h(!0)},Sp=(a,u)=>{u&&(u.preventDefault(),u.stopPropagation()),a(!1)},Np=(a,u,r,d,f,h,g,p,v)=>{if(v&&(v.preventDefault(),v.stopPropagation()),a===0){const N={...r};Object.keys(N).forEach(_=>{const j=N[_];Object.keys(j).forEach(I=>{u[I]||delete j[I]})}),p(ge.ParamTestValues,N)}if(a===1){const N={...r};f.forEach(j=>{const I=j.id.toString(),M=j.widgets||{};Object.values(M).forEach(P=>{const R=P.name;if(u[R]&&(P.type==="customtext"||P.type.toLowerCase().includes("text"))){const D=`${I}_${R}`,z=d[D]||[""];N[I]=N[I]||{},N[I][R]=z}})}),p(ge.ParamTestValues,N);const _=g(N);p(ge.TotalCount,_.length)}h(null),p(ge.CurrentSceen,Math.min(a+1,2))},jp=(a,u,r,d,f,h,g,p)=>{if(p&&(p.preventDefault(),p.stopPropagation()),h(null),f&&g(ge.IsCompleted,!1),a===1){const v=u.map(j=>j.id.toString()),N=Object.keys(r),_={...r};N.forEach(j=>{v.includes(j)||delete _[j]}),g(ge.ParamTestValues,_)}if(a===2||f){const v={...r};Object.entries(d).forEach(([N,_])=>{if(!_||_.length===0)return;const[j,I]=N.split("_");u.some(M=>M.id.toString()===j)&&(v[j]=v[j]||{},JSON.stringify(v[j][I])!==JSON.stringify(_)&&(v[j][I]=_))}),g(ge.ParamTestValues,v)}g(ge.CurrentSceen,Math.max(a-1,0))},Ip=(a,u,r,d,f)=>{f&&(f.preventDefault(),f.stopPropagation()),d(ge.CurrentPage,Math.max(1,Math.min(a,Math.ceil(r.length/u))))};function kp(a,u){try{if(!a)return console.error("Invalid prompt_output: ",a),a;for(const r of u){if(!a[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!a[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}a[r.nodeId].inputs[r.paramName]=r.paramValue}return a}catch(r){return console.error("Error updating prompt:",r),a}}async function Cp(a){const u=await Ce.graphToPrompt(),r=kp(u.output,a);console.log("queuePrompt updated_prompt:",r);const d={prompt:r,client_id:Ce.api.clientId,extra_data:{extra_pageinfo:{workflow:u.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const f=await Rm(d);return console.debug("queuePrompt response:",f),f}function Il(a){const u=document.createElement("canvas"),r=u.getContext("2d");if(u.width=512,u.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,u.width,u.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,u.width-20,u.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(u.width/2,150,50,0,2*Math.PI),r.fill(),r.fillStyle="white",r.font="bold 80px Arial",r.textAlign="center",r.textBaseline="middle",r.fillText("!",u.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const d=u.width-60,f=30,h=a.split(" ");let g="",p=250;for(let v=0;vd&&v>0?(r.fillText(g,u.width/2,p),g=h[v]+" ",p+=f):g=N}r.fillText(g,u.width/2,p)}return u.toDataURL("image/png")}async function Ap(a){try{if(!a||a==="")return console.log("No prompt ID provided"),{1:[Il("Fail to generate prompt ID")]};const u=await zm(a);if(!u||!u[a])return console.log("Not finished for prompt ID:",a),{};const r=u[a];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",a);const f=r.status.messages;if(f&&f.length>0){const h=f[f.length-1];if(h&&h.length>0){const g=h[0];return{1:[Il(g)]}}}}const d={};if(r.outputs)for(const f in r.outputs){const h=r.outputs[f];if(h&&h.images){d[f]=[];for(const g of h.images)if(g&&g.filename&&g.type){const p=Ce?.graph._nodes_by_id?.[f]?.imgs?.[0]?.currentSrc?.split("?")[0];d[f].push(p+"?filename="+encodeURIComponent(g.filename)+"&type="+encodeURIComponent(g.type)+(g.subfolder?"&subfolder="+encodeURIComponent(g.subfolder):""))}console.log("outputImages for nodeId:",f,d[f])}}return d}catch(u){throw console.error("Error getting output images from prompt:",u),u}}function Ep(){const a=Object.values(Ce.graph._nodes_by_id),u=[],r=[];for(const d of a)d.type==="SaveImage"?u.push(d.id):d.type==="PreviewImage"&&r.push(d.id);if(console.log("saveNodeIds:",u),console.log("previewNodeIds:",r),u.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return u.length===1?u[0]:u.length==0&&r.length===1?r[0]:null}async function Mp(a,u){const r=await Ap(a);return Object.keys(r).length===0?null:r[u.toString()]&&r[u.toString()].length>0?r[u.toString()][0]:null}const Lp=async(a,u,r,d,f,h,g,p,v,N)=>{v&&(v.preventDefault(),v.stopPropagation()),Rl(f,d);const _=h(a),j=_.length;if(j>100){r(`Cannot generate more than 100 images at once (currently: ${j} images)`);return}r(null),p(ge.IsProcessing,!0),p(ge.CompletedCount,0),console.log("Generated parameter combinations:",_);let I=null;try{I=(await g.graphToPrompt()).output}catch(D){console.error("Error capturing workflow data:",D)}if(Ft.trackEvent({event_type:"start_generation",message_type:"parameter_debug",message_id:u,data:{workflow:I,all_params:a,count:j}}),_.length===0){r("No valid parameter combinations found. Please check your parameter selections."),p(ge.IsProcessing,!1);return}let M=N||null;if(M===null){const D=Ep();D!==null&&(M=D)}if(M===null){r("Please select a SaveImage or PreviewImage node first."),p(ge.IsProcessing,!1);return}const P={};Object.keys(a).forEach(D=>{const z=g.graph._nodes_by_id[D];z&&(P[D]=z.type||z.comfyClass||"Unknown Node")});const R=[];try{const D=Date.now().toString();d.current=D;for(const F of _){const J=await Cp(F);J.prompt_id?R.push(J.prompt_id):(console.error("Failed to get prompt_id from response:",J),R.push(""))}const z=Array(_.length).fill(null).map((F,J)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:op(a,J)}));p(ge.GeneratedImages,z);const G=Date.now(),Z=5*60*1e3,ae=Object.keys(a)[0],w=P[ae]||"Unknown Node";Pl(R,M,z,D,G,Z,d,f,p,w,a,j,I,P)}catch(D){console.error("Error generating images:",D),p(ge.IsProcessing,!1)}},Pl=async(a,u,r,d,f,h,g,p,v,N,_,j,I,M)=>{if(g.current!==d){console.log("Another polling session has started, stopping this one");return}if(Date.now()-f>h){if(console.log("Timeout reached while waiting for images"),g.current===d&&(v(ge.IsProcessing,!1),v(ge.IsCompleted,!0),v(ge.CurrentPage,1),r.length>0&&N&&_)){const R=r[0].params;M&&(R.selectedNodeInfoMap=M),jl(N,R,r,j||r.length,I)}return}let P=0;for(let R=0;R0&&N&&_)){const R=r[0].params;M&&(R.selectedNodeInfoMap=M),jl(N,R,r,j||r.length,I)}return}g.current===d&&(p.current=setTimeout(()=>{Pl(a,u,r,d,f,h,g,p,v,N,_,j,I,M)},2e3))},Rl=(a,u)=>{a.current&&(clearTimeout(a.current),a.current=null),u.current=null},Tp=async(a,u,r,d,f,h)=>{if(!a.trim()){d("Please enter some text to generate variations");return}r(!0),d(null),f([]),h({});try{const g=await Ft.generateSDPrompts(a);f(g),Ft.trackEvent({event_type:"prompt_generate",message_type:"parameter_debug",message_id:u,data:{input_text:a,generated_texts:g}});const p={};g.forEach((v,N)=>{p[`text${N+1}`]=!1}),h(p)}catch(g){console.error("Error generating text:",g),d("Failed to generate text variations. Please try again.")}finally{r(!1)}},Op=(a,u)=>{u(r=>({...r,[a]:!r[a]}))},Pp=(a,u,r,d,f,h,g,p,v,N)=>{const _=`${a}_${u}`,j=Object.entries(r).filter(([P,R])=>R).map(([P])=>{const R=parseInt(P.replace("text",""))-1;return d[R]});if(j.length===0)return;const I=[...g[_]||[]];p(ge.TextInputs,{...g,[_]:[...I,...j]}),Ft.trackEvent({event_type:"prompt_apply",message_type:"parameter_debug",message_id:h,data:{input_text:f,generated_texts:d,selected_texts:j}});const M=[...g[_]||[],...j];v(a,u,M),N(!1)},Rp=(a,u,r,d,f,h,g,p,v,N)=>{r(!0),d(a),f(u),h(""),g([]),p({}),v(!1),N(null)},Dp=(a,u,r,d,f,h,g,p,v,N,_,j,I,M,P,R,D,z,G,Z,ae,w,F,J,de,B,le,$e,U,te=!1)=>{a(0),u({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),r(Ze()),d(),f(!1),h(!1),g(0),p(12),v(null),N(Array(12).fill(null).map((fe,ne)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:ne%3===0?5:ne%3===1?10:15,sampler_name:"euler",cfg:1}}))),_({}),j({}),I({}),M({}),P(1),R(null),D(!1),z(!1),G(""),Z(null),ae({}),w(!1),F(""),J([]),de(!1),B(""),le(""),$e(null),U({}),te&&fp()},Wp=async(a,u,r,d,f,h,g)=>{if(g&&(g.preventDefault(),g.stopPropagation()),a!==null){console.log(`Applied image ${a+1} with parameters:`,u[a].params);let p=1;if(f){for(const N in f)if(f[N])for(const _ in f[N]){const j=f[N][_];if(j){let I=1;Array.isArray(j)?I=j.length>0?j.length:1:typeof j=="object"&&j!==null&&(I=Object.keys(j).length>0?Object.keys(j).length:1),p=p*I}}}Ft.trackEvent({event_type:"parameter_debug_apply",message_type:"parameter_debug",message_id:d,data:{workflow:(await r.graphToPrompt()).output,selected_params:u[a].params,all_params:f,count:p}});const v=u[a].params;v.nodeParams&&(Object.entries(v.nodeParams).forEach(([N,_])=>{const j=r.graph._nodes_by_id[N];!j||!j.widgets||Object.entries(_).forEach(([I,M])=>{for(const P of j.widgets)if(P.name===I){P.value=M;break}})}),r.graph.setDirtyCanvas(!1,!0),h(!0),setTimeout(()=>{h(!1)},3e3))}},zp=(a,u,r,d,f,h,g)=>{if(g&&(g.preventDefault(),g.stopPropagation()),a===1&&r!==void 0){const p=[...u];p[r],p.splice(r,1),p.length===0?f&&(d({type:"SET_SCREEN_STATE",payload:null}),h(!0),f()):d({type:"SET_SELECTED_NODE",payload:p});return}f&&(d({type:"SET_SCREEN_STATE",payload:null}),h(!0),f())};var ge=(a=>(a.CurrentSceen="currentSceen",a.SelectedParams="selectedParams",a.TaskId="taskId",a.IsProcessing="isProcessing",a.IsCompleted="isCompleted",a.CompletedCount="completedCount",a.TotalCount="totalCount",a.SelectedImageIndex="selectedImageIndex",a.GeneratedImages="generatedImages",a.ParamTestValues="paramTestValues",a.SearchTerms="searchTerms",a.InputValues="inputValues",a.CurrentPage="currentPage",a.TextInputs="textInputs",a))(ge||{});const Fp=({selectedNodes:a,visible:u,onClose:r})=>{const[d,f]=k.useState(0),[h,g]=k.useState({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),[p,v]=k.useState(Ze()),[N,_]=k.useState(!1),[j,I]=k.useState(!1),[M,P]=k.useState(0),[R,D]=k.useState(12),[z,G]=k.useState(null),[Z,ae]=k.useState(()=>Array(12).fill(null).map((L,O)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:O%3===0?5:O%3===1?10:15,sampler_name:"euler",cfg:1}}))),[w,F]=k.useState({}),[J,de]=k.useState({}),[B,le]=k.useState({}),[$e,U]=k.useState({}),[te,fe]=k.useState(1),ne=6,[ve,be]=k.useState(null),[K,re]=k.useState(!1),[$,Y]=k.useState(!1),[we,Me]=k.useState(""),[Oe,Ie]=k.useState(null),[Qe,Bt]=k.useState({}),[ct,Je]=k.useState(!1),[qt,ze]=k.useState(""),[Tt,wt]=k.useState([]),[et,mt]=k.useState(!1),[Vt,ut]=k.useState(""),[Jt,Mn]=k.useState(""),[Ut,tt]=k.useState(null),[$t,Ot]=k.useState({}),[on,q]=k.useState(!1),[ce,ye]=k.useState([]),[Se,Ke]=k.useState(null),{dispatch:Le}=bn(),De=k.useRef(null),Pe=k.useRef(null),Ye=k.useRef(!0),[Pt,St]=k.useState(()=>u),[vn,Xn]=k.useState(!1);k.useEffect(()=>{if(on){const L=Tl();ye(L)}},[on]);const bs=async()=>{Tp(qt,p,mt,tt,wt,Ot)},ys=(L,O,_e,Be)=>{const Nt=hp(L,O,_e,Be,Qe,Fe);an(L,O,Nt)},vs=(L,O)=>{const _e=gp(L,O,Qe,Fe);an(L,O,_e)},_r=(L,O,_e)=>{const Be=mp(L,O,_e,Qe,Fe);an(L,O,Be)},wr=L=>{Op(L,Ot)},_s=()=>{Pp(Vt,Jt,$t,Tt,qt,p,Qe,Fe,an,Je)},ws=(L,O)=>{Rp(L,O,Je,ut,Mn,ze,wt,Ot,mt,tt)},Sr=L=>{L&&(L.preventDefault(),L.stopPropagation()),q(O=>!O)},Ss=L=>{Ke(L),q(!1),Fe("generatedImages",L.generatedImages||[]),Fe("selectedImageIndex",null),Fe("currentPage",1)},Nr=L=>{L&&(L.preventDefault(),L.stopPropagation()),Ke(null)},Ns=(L,O)=>{console.log("key--->",L,O);const _e={currentScreen:d,selectedParams:h,task_id:p,isProcessing:N,isCompleted:j,completedCount:M,totalCount:R,selectedImageIndex:z,generatedImages:Z,paramTestValues:w,searchTerms:B,inputValues:$e,currentPage:te,textInputs:Qe};console.log("doSaveState-->",_e),up({..._e,[L]:O})},Fe=(L,O)=>{switch(L){case"currentSceen":f(O);break;case"selectedParams":g(O);break;case"taskId":v(O);break;case"isProcessing":_(O);break;case"isCompleted":I(O);break;case"completedCount":P(O);break;case"totalCount":D(O);break;case"selectedImageIndex":G(O);break;case"generatedImages":ae(O);break;case"paramTestValues":F(O);break;case"searchTerms":le(O);break;case"inputValues":U(O);break;case"currentPage":fe(O);break;case"textInputs":Bt(O);break}Ns(L,O)};k.useEffect(()=>{if(!vn||!a||a.length===0)return;const L={...w},O=a.map(Be=>Be.id.toString());Object.keys(L).forEach(Be=>{O.includes(Be)||delete L[Be]}),a.forEach(Be=>{const Nt=Be.id.toString();L[Nt]||(L[Nt]={})}),JSON.stringify(L)!==JSON.stringify(w)&&Fe("paramTestValues",L)},[a,w,vn]),k.useEffect(()=>{Le({type:"SET_SCREEN_STATE",payload:{currentScreen:d,isProcessing:N,isCompleted:j}})},[d,N,j,Le]),k.useEffect(()=>{const L=document.createElement("style");return L.textContent=cp,document.head.appendChild(L),()=>{document.head.removeChild(L)}},[]),k.useEffect(()=>{const L=O=>{if(Object.values(J).some(_e=>_e)){const _e=O.target,Be=!!_e.closest(".dropdown-menu"),Nt=!!_e.closest("[data-dropdown]");!Be&&!Nt&&de({})}};return document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[J]),k.useEffect(()=>{u&&(JSON.parse(localStorage.getItem(yr)||"{}").task_id||Fe("taskId",Ze()))},[u]),k.useEffect(()=>{if(N&&Ye.current){Ye.current=!1;let L=0;const O=Object.values(Ce.graph._nodes_by_id),_e=[],Be=[];for(const On of O)On.type==="SaveImage"?_e.push(On.id):On.type==="PreviewImage"&&Be.push(On.id);const Nt=[..._e,...Be];Nt.length===1?L=Nt[0]:Nt.length>1&&(L=void 0),Ir(void 0,L)}},[N]),k.useEffect(()=>{if(u){St(!0);try{const L=localStorage.getItem(yr);if(L){const O=JSON.parse(L);if(!a||a.length===0){console.log("Not restoring parameter debug state: no nodes selected"),St(!1);return}O.currentScreen!==void 0&&f(O.currentScreen),O.selectedParams&&g(O.selectedParams),O.task_id&&v(O.task_id),_(O?.isProcessing);const _e=O.generatedImages&&O.generatedImages.length>0;O.isCompleted!==void 0&&_e&&I(O.isCompleted),O.completedCount!==void 0&&P(O.completedCount),O.totalCount!==void 0&&D(O.totalCount),O.selectedImageIndex!==void 0&&G(O.selectedImageIndex),O.generatedImages&&ae(O.generatedImages),O.paramTestValues&&F(O.paramTestValues),O.searchTerms&&le(O.searchTerms),O.inputValues&&U(O.inputValues),O.currentPage!==void 0&&fe(O.currentPage),O.textInputs&&Bt(O.textInputs),vn||Xn(!0)}}catch(L){console.error("Error loading parameter debug state:",L)}finally{setTimeout(()=>{St(!1)},50)}}else St(!0)},[u,a]);const js=(L=!1)=>{Dp(f,g,v,er,_,I,P,D,G,ae,F,de,le,U,fe,be,re,Y,Me,Ie,Bt,Je,ze,wt,mt,ut,Mn,tt,Ot,L),q(!1),Ke(null)},Ln=L=>{Np(d,h,w,Qe,a,be,Ui,Fe,L)},Zn=L=>{jp(d,a,w,Qe,j,be,Fe,L)},Qn=(L,O)=>{_p(L,h,w,Fe,O)},Is=(L,O,_e)=>{pp(L,O,_e,J,de)},an=(L,O,_e)=>{xp(L,O,_e,w,Fe)},ks=(L,O,_e,Be)=>{bp(L,O,_e,w,Fe,Be)},Cs=(L,O,_e)=>{yp(L,O,_e,B,Fe)},As=(L,O,_e)=>{vp(L,O,_e,w,an)},jr=(L,O)=>{Ip(L,ne,Z,Fe,O)},er=()=>{Rl(De,Pe)};k.useEffect(()=>()=>{er()},[]);const Ir=async(L,O)=>{Lp(w,p,be,Pe,De,Ui,Ce,Fe,L,O)},tr=(L,O)=>{O&&(O.preventDefault(),O.stopPropagation()),Fe("selectedImageIndex",L)},kr=(L,O,_e)=>{wp(L,O,a,Me,Ie,Y,_e)},_n=L=>{Sp(Y,L)},Es=async L=>{Wp(z,Z,Ce,p,w,re,L)},ln=(L,O)=>{zp(d,a,O,Le,r,js,L)},Tn=()=>i.jsx(i.Fragment,{children:i.jsx(br,{visible:$,imageUrl:we,params:Oe||{},onClose:_n})});return Se?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:L=>L.stopPropagation(),children:i.jsx(lp,{historyItem:Se,selectedImageIndex:z,handleSelectImage:tr,handleClose:Nr,currentPage:te,handlePageChange:jr,imagesPerPage:ne,modalVisible:$,modalImageUrl:we,modalImageParams:Oe,openImageModal:kr,closeImageModal:_n})}):on?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:L=>L.stopPropagation(),children:i.jsx(ap,{historyItems:ce,onViewHistoryItem:Ss,onClose:Sr})}):Pt&&u&&a.length>0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:L=>L.stopPropagation(),children:[i.jsxs("div",{className:"p-8 rounded-lg shadow-sm relative flex flex-col items-center",children:[i.jsx("div",{className:"w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"}),i.jsx("div",{className:"mt-4 text-gray-600 text-sm",children:"Loading interface..."})]}),i.jsx(br,{visible:$,imageUrl:we,params:Oe||{},onClose:_n})]}):!u||a.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:L=>L.stopPropagation(),children:[i.jsxs("div",{className:"max-w-lg p-8 rounded-lg shadow-sm border border-blue-100 relative",children:[i.jsxs("div",{className:"absolute top-3 right-3 flex",children:[i.jsx("button",{className:"text-blue-500 hover:text-blue-700 mr-2",onClick:Sr,title:"Show History",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z",clipRule:"evenodd"})})}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:ln,children:i.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h3",{className:"text-base font-bold text-blue-600 mb-2",children:"GenLab"}),i.jsx("div",{className:"h-1 w-16 bg-blue-500 mx-auto rounded-full mb-4"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"text-left mb-4",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-800 mb-3",children:"Batch-test parameters & find the best combo in one click."}),i.jsx("div",{className:"h-px w-full bg-gray-200 my-4"})]}),i.jsxs("div",{className:"text-left",children:[i.jsx("h4",{className:"text-base font-medium text-gray-800 mb-4",children:"How to use"}),i.jsxs("div",{className:"space-y-2 mb-4",children:[i.jsxs("p",{className:"text-sm text-gray-700",children:[i.jsx("span",{className:"font-bold",children:"1 - "}),"Click any node(hold Shift to select multiple nodes)"]}),i.jsxs("p",{className:"text-sm text-gray-700",children:[i.jsx("span",{className:"font-bold",children:"2 - "}),"Set parameter ranges and start batch generation."]})]}),i.jsx("div",{className:"h-px w-full bg-gray-200 my-4"}),i.jsx("p",{className:"text-sm text-blue-600 mt-6",children:"Let's select a node to begin!"})]})]})]}),i.jsx(br,{visible:$,imageUrl:we,params:Oe||{},onClose:_n})]}):j?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:L=>L.stopPropagation(),children:i.jsx(sp,{generatedImages:Z,selectedImageIndex:z,handleSelectImage:tr,handleApplySelected:Es,handlePrevious:Zn,handleClose:ln,currentPage:te,handlePageChange:jr,imagesPerPage:ne,notificationVisible:K,modalVisible:$,modalImageUrl:we,modalImageParams:Oe,openImageModal:kr,closeImageModal:_n})}):N?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:L=>L.stopPropagation(),children:[i.jsx(Hm,{selectedNodes:a,paramTestValues:w,selectedParams:h,totalCount:R,completedCount:M,errorMessage:ve,handleClose:ln,updateState:Fe,cleanupPolling:er}),i.jsx(Tn,{})]}):d===0?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:L=>L.stopPropagation(),children:[i.jsx(Um,{selectedNodes:a,handleParamSelect:Qn,selectedParams:h,handleNext:Ln,handleClose:ln}),i.jsx(Tn,{})]}):d===1?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:L=>L.stopPropagation(),children:[i.jsx($m,{selectedNodes:a,paramTestValues:w,selectedParams:h,updateParamTestValues:an,toggleDropdown:Is,openDropdowns:J,handleTestValueSelect:ks,searchTerms:B,handleSearch:Cs,handleSelectAll:As,handleNext:Ln,handlePrevious:Zn,handleClose:ln,inputValues:$e,updateState:Fe,textInputs:Qe,handleTextInputChange:ys,handleAddTextInput:vs,handleRemoveTextInput:_r,openAiWritingModal:ws}),i.jsx(ip,{visible:ct,aiWritingModalText:qt,setAiWritingModalText:ze,aiGeneratedTexts:Tt,aiSelectedTexts:$t,aiWritingLoading:et,aiWritingError:Ut,handleAiWriting:bs,toggleTextSelection:wr,addSelectedTexts:_s,onClose:()=>Je(!1)}),i.jsx(Tn,{})]}):i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:L=>L.stopPropagation(),children:[i.jsx(Gm,{selectedNodes:a,paramTestValues:w,selectedParams:h,totalCount:R,errorMessage:ve,handlePrevious:Zn,handleStartGeneration:Ir,handleClose:ln}),i.jsx(Tn,{})]})},Bp=a=>{const{dispatch:u}=bn(),[r,d]=k.useState(!1);return k.useEffect(()=>{if(a.visible&&!r){const f=dp();f&&f.screenState&&u({type:"SET_SCREEN_STATE",payload:{currentScreen:f.currentScreen,isProcessing:f.isProcessing,isCompleted:f.isCompleted}}),d(!0)}},[a.visible,r,u]),k.useEffect(()=>()=>{a.visible||u({type:"SET_SCREEN_STATE",payload:null})},[a.visible,u]),i.jsx(Fp,{...a})},Up=({message:a,onClose:u})=>a?i.jsxs("div",{className:`bg-gradient-to-r from-gray-50 to-gray-100 border border-gray-300 px-2 py-1 mt-2 ml-2 mr-2 relative shadow-sm rounded-sm`,children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"flex-shrink-0 mr-1",children:i.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:i.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"})})}),i.jsx("div",{className:"text-gray-700 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:i.jsx(Yg,{rehypePlugins:[[Gg,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[$g],className:"prose !text-[11px] prose-a:text-gray-700 prose-a:underline prose-a:font-medium hover:prose-a:text-gray-800",components:{a:({node:r,...d})=>i.jsx("a",{...d,className:"text-gray-700 underline hover:text-gray-800 transition-colors",style:{fontSize:"11px"}}),p:({children:r})=>i.jsx("span",{className:"inline",style:{fontSize:"11px"},children:r}),span:({children:r})=>i.jsx("span",{style:{fontSize:"11px"},children:r}),li:({children:r})=>i.jsx("li",{style:{fontSize:"11px"},children:r}),ul:({children:r})=>i.jsx("ul",{style:{fontSize:"11px"},children:r}),ol:({children:r})=>i.jsx("ol",{style:{fontSize:"11px"},children:r})},children:a})})]}),i.jsx("button",{onClick:u,className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-700 hover:text-gray-800 transition-colors p-1 rounded-full hover:bg-gray-800","aria-label":"Close announcement",children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,$p=()=>{const{state:a,dispatch:u}=bn(),{selectedNode:r,screenState:d}=a,f=r||[],h=()=>{u({type:"SET_SELECTED_NODE",payload:null}),u({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};return i.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:i.jsx(Bp,{selectedNodes:f,visible:!0,onClose:h})})},kl=({active:a,onClick:u,children:r})=>i.jsx("button",{onClick:u,className:`px-4 py-2 font-medium text-xs transition-colors duration-200 border-b-2 ${a?"text-[#71A3F2] border-[#71A3F2]":"text-gray-600 border-transparent hover:!text-[#71A3F2] hover:!border-[#71A3F2]"}`,children:r});function Yp({onClose:a,visible:u=!0,triggerUsage:r=!1,onUsageTriggered:d}){const{state:f,dispatch:h,isAutoScroll:g,showcasIng:p}=bn(),{messages:v,installedNodes:N,loading:_,sessionId:j,selectedNode:I,activeTab:M,guiding:P}=f;k.useRef(null);const[R,D]=k.useState(""),[z,G]=k.useState(""),[Z,ae]=k.useState(window.innerWidth/3),[w,F]=k.useState(!1),[J,de]=k.useState([]),[B,le]=k.useState("gpt-4o-mini"),[$e,U]=k.useState(window.innerHeight),[te,fe]=k.useState(0),[ne,ve]=k.useState(""),[be,K]=k.useState(!1),re=k.useRef(null);k.useRef(I);const[$,Y]=k.useState("None");Fm(u&&M==="chat"),Bm(u),k.useEffect(()=>{switch($){case"Usage":et();break;case"Parameters":mt();break;case"DownstreamNodes":ut();break}Y("None")},[$]),k.useEffect(()=>{if(M!=="chat")return;(async()=>{const ce=await Pm();console.log("[WorkflowChat] Received installed nodes:",ce.length),h({type:"SET_INSTALLED_NODES",payload:ce})})()},[M]);const we=()=>{h({type:"SET_GUIDING",payload:!0}),h({type:"SET_MESSAGES",payload:[{id:Ze(),role:"showcase",content:""}]})},Me=async q=>{try{const ce=await Ft.fetchMessages(q);ce?.length>0?h({type:"SET_MESSAGES",payload:ce}):we()}catch(ce){console.error("Error fetching messages:",ce)}};k.useEffect(()=>{if(M!=="chat")return;let q=localStorage.getItem("sessionId");q?(h({type:"SET_SESSION_ID",payload:q}),Me(q)):(q=Ze(),h({type:"SET_SESSION_ID",payload:q}),localStorage.setItem("sessionId",q))},[M]),k.useEffect(()=>{const q=localStorage.getItem("activeTab");q&&h({type:"SET_ACTIVE_TAB",payload:q});const ce=localStorage.getItem("screenState");ce&&h({type:"SET_SCREEN_STATE",payload:JSON.parse(ce)});const ye=()=>{Y("Usage")},Se=()=>{Y("Parameters")},Ke=()=>{Y("DownstreamNodes")};return window.addEventListener(Jn.TOOLBOX_USAGE,ye),window.addEventListener(Jn.TOOLBOX_PARAMETERS,Se),window.addEventListener(Jn.TOOLBOX_DOWNSTREAMNODES,Ke),()=>{window.removeEventListener(Jn.TOOLBOX_USAGE,ye),window.removeEventListener(Jn.TOOLBOX_PARAMETERS,Se),window.removeEventListener(Jn.TOOLBOX_DOWNSTREAMNODES,Ke)}},[]),k.useEffect(()=>{localStorage.setItem("activeTab",M)},[M]),k.useEffect(()=>{f.screenState&&localStorage.setItem("screenState",JSON.stringify(f.screenState))},[f.screenState]);const Oe=ms.useCallback(q=>{if(!w)return;const ce=window.innerWidth-q.clientX,ye=Math.min(Math.max(300,ce),window.innerWidth*.8);ae(ye)},[w]),Ie=ms.useMemo(()=>$i.debounce(Oe,16),[Oe]);k.useEffect(()=>(w&&(document.addEventListener("mousemove",Ie),document.addEventListener("mouseup",Ut)),()=>{document.removeEventListener("mousemove",Ie),document.removeEventListener("mouseup",Ut),Ie.cancel()}),[w,Ie]);const Qe=q=>{D(q.target.value)},Bt=()=>{re.current&&(re.current.abort(),re.current=null,h({type:"SET_LOADING",payload:!1}))},ct=async()=>{if(P&&(h({type:"SET_GUIDING",payload:!1}),h({type:"CLEAR_MESSAGES"})),g.current=!0,p.current=!1,h({type:"SET_LOADING",payload:!0}),R.trim()===""&&!I||!j)return;G(R);const q=Ze(),ce={id:Ze(),role:"user",content:R,trace_id:q};h({type:"ADD_MESSAGE",payload:ce}),D(""),re.current=new AbortController;try{const ye={type:"model_select",data:[B]};let Se=Ze(),Ke=!0;for await(const Le of Ft.streamInvokeServer(j,R,J.map(De=>De.file),null,ye,q,re.current.signal)){const De={id:Se,role:"ai",content:JSON.stringify(Le),format:Le.format,finished:Le.finished,name:"Assistant"};if(Ke)h({type:"ADD_MESSAGE",payload:De}),Ke=!1;else{h({type:"UPDATE_MESSAGE",payload:De});const Pe=f.messages.map(Ye=>Ye.id===De.id&&!Ye.finished?De:Ye);Jt(Pe)}Le.finished&&(h({type:"SET_LOADING",payload:!1}),re.current=null)}}catch(ye){ye instanceof Error&&ye.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",ye),h({type:"SET_LOADING",payload:!1}),re.current=null}finally{de([])}},Je=async q=>{if(!j)return;h({type:"SET_LOADING",payload:!0}),G(q);const ce=Ze(),ye={id:Ze(),role:"user",content:q,trace_id:ce};h({type:"ADD_MESSAGE",payload:ye}),re.current=new AbortController;try{const Se={type:"model_select",data:[B]};let Ke=Ze(),Le=!0;for await(const De of Ft.streamInvokeServer(j,q,J.map(Pe=>Pe.file),null,Se,ce,re.current.signal)){const Pe={id:Ke,role:"ai",content:JSON.stringify(De),format:De.format,finished:De.finished,name:"Assistant"};if(Le)h({type:"ADD_MESSAGE",payload:Pe}),Le=!1;else{h({type:"UPDATE_MESSAGE",payload:Pe});const Ye=f.messages.map(Pt=>Pt.id===Pe.id&&!Pt.finished?Pe:Pt);Jt(Ye)}De.finished&&(h({type:"SET_LOADING",payload:!1}),re.current=null)}}catch(Se){Se instanceof Error&&Se.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Se),h({type:"SET_LOADING",payload:!1}),re.current=null}finally{de([])}},qt=q=>{q.metaKey&&q.key==="Enter"&&ct()},ze=()=>{p.current=!1,h({type:"CLEAR_MESSAGES"});const q=f.sessionId;q&&localStorage.removeItem(`messages_${q}`),localStorage.removeItem("sessionId");const ce=Ze();h({type:"SET_SESSION_ID",payload:ce}),localStorage.setItem("sessionId",ce),setTimeout(()=>{we()},500)},Tt=q=>{D(q)},wt=async(q,ce)=>{if(!j||!I)return;h({type:"SET_LOADING",payload:!0});const ye=I[0].comfyClass||I[0].type,Se=Ze(),Ke={id:Ze(),role:"user",content:ye,trace_id:Se};h({type:"ADD_MESSAGE",payload:Ke}),re.current=new AbortController;try{let Le=Ze(),De=!0;for await(const Pe of Ft.streamInvokeServer(j,ye,[],q,ce,Se,re.current.signal)){const Ye={id:Le,role:"ai",content:JSON.stringify(Pe),format:Pe.format,finished:Pe.finished,name:"Assistant"};if(q&&q!==""&&(Ye.metadata={intent:q}),De)h({type:"ADD_MESSAGE",payload:Ye}),De=!1;else{h({type:"UPDATE_MESSAGE",payload:Ye});const Pt=f.messages.map(St=>St.id===Ye.id&&!St.finished?Ye:St);Jt(Pt)}Pe.finished&&(h({type:"SET_LOADING",payload:!1}),re.current=null)}}catch(Le){Le instanceof Error&&Le.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Le),h({type:"SET_LOADING",payload:!1}),re.current=null}},et=()=>{Je(`Reply in ${navigator.language} language: How does the ${I?.[0]?.type} node work? I need its official usage guide.`)},mt=()=>{Je(`Reply in ${navigator.language} language: Show me the technical specifications for the ${I?.[0].type} node's inputs and outputs.`)},Vt=()=>{const q=new Set;function ce(ye,Se){if(!(!ye||Se>=1)&&ye.inputs)for(const Ke of Object.values(ye.inputs)){const Le=Ke.link;if(Le&&Ce.graph.links[Le]){const De=Ce.graph.links[Le].origin_id,Pe=Ce.graph._nodes_by_id[De];Pe&&(q.add(Pe.type),ce(Pe,Se+1))}}}return I[0]?(ce(I[0],0),[{type:"upstream_node_types",data:Array.from(q)}]):null},ut=()=>{wt("downstream_subgraph_search",Vt())},Jt=q=>{f.sessionId&&localStorage.setItem(`messages_${f.sessionId}`,JSON.stringify(q))},Mn=q=>{console.log("[WorkflowChat] Adding new message:",q);const ce=[...f.messages,q];h({type:"ADD_MESSAGE",payload:q}),Jt(ce)},Ut=()=>{F(!1)},tt=q=>{const ce=Array.from(q).map(ye=>({id:Math.random().toString(36).substr(2,9),file:ye,preview:URL.createObjectURL(ye)}));de(ye=>[...ye,...ce])},$t=q=>{de(ce=>ce.filter(Se=>Se.id!==q))};ms.useEffect(()=>()=>{J.forEach(q=>URL.revokeObjectURL(q.preview))},[J]),k.useEffect(()=>{r&&d&&M==="chat"&&(wt("node_explain"),d())},[r,M]),k.useEffect(()=>{if(!u||M!=="chat")return;(async()=>{try{const ce=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==ce){const Se=await Ft.fetchAnnouncement();Se&&Se.trim()!==""&&(ve(Se),K(!0),localStorage.setItem("announcementLastShownDate",ce))}}catch(ce){console.error("Error fetching announcement:",ce)}})()},[u,M]);const Ot=()=>{K(!1)},on=q=>{h({type:"SET_ACTIVE_TAB",payload:q})};return u?i.jsxs("div",{className:"flex flex-col h-full w-full bg-white relative",style:{display:u?"flex":"none"},children:[i.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsx(xm,{onClose:a,onClear:ze,hasMessages:v.length>0,title:"ComfyUI-Copilot"}),i.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[i.jsx(kl,{active:M==="chat",onClick:()=>on("chat"),children:"Chat"}),i.jsx(kl,{active:M==="parameter-debug",onClick:()=>on("parameter-debug"),children:"GenLab"})]}),be&&ne&&M==="chat"&&i.jsx(Up,{message:ne,onClose:Ot}),i.jsx(Tm,{messages:v,latestInput:z,onOptionClick:Tt,installedNodes:N,onAddMessage:Mn,loading:_,isActive:M==="chat"}),i.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:M==="chat"?"block":"none"},children:[I&&i.jsx(_m,{nodeInfo:I,onSendWithIntent:wt,loading:_,onSendWithContent:Je}),i.jsx(ym,{input:R,loading:_,onChange:Qe,onSend:ct,onKeyPress:qt,onUploadImages:tt,uploadedImages:J,onRemoveImage:$t,selectedModel:B,onModelChange:le,onStop:Bt})]}),i.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:M==="parameter-debug"?"flex":"none"},children:i.jsx($p,{})})]})]}):null}export{Yp as default};