function getImportPath(filename) {
            return `./${filename}`;
        }
            const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/message-components-DwkOoCr5.js","copilot_web/vendor-react-ByKzdfMq.js","copilot_web/vendor-markdown-B4Av9P7l.js","copilot_web/WorkflowOption-BNm2RO52.js","copilot_web/input.js","copilot_web/assets/input-DcMY2yOB.css","copilot_web/fonts.css","copilot_web/App-Cr-Csxh5.js","copilot_web/DebugGuide-Bc3pTp8l.js","copilot_web/DebugResult-BJrSKJkE.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 s,r as _g,b as wg}from"./vendor-markdown-B4Av9P7l.js";import{r as b,c as Ss,e as Xl,R as Qi}from"./vendor-react-ByKzdfMq.js";import{b as vg,c as kg,X as Ln,a as $e,g as Yl,f as Sg,d as Ql,v as Ml,W as ht,S as Ig,H as Cg,M as jg,T as Zl,E as Lg,I as Is,e as Ng,F as ec,h as ss,i as Tl,B as Pl,j as Ag,P as Eg,u as gn,R as Mg,k as Tg,l as Pg,m as Dg,n as at,o as tc,p as Og,q as Fg,r as Rg,s as zg,t as Ug,x as Bg,y as Wg,z as Gg,A as $g}from"./message-components-DwkOoCr5.js";import{_ as sn}from"./input.js";import{C as rs}from"./App-Cr-Csxh5.js";const Dl=o=>{const{isPassword:u=!1,value:r="",setValue:d=()=>{},setIsValueValid:c,placeholder:h="",className:m=""}=o,[g,_]=b.useState(!u),S=v=>{d(v.target.value),c?.(v.target.value)};return s.jsxs("div",{className:`relative ${m}`,children:[s.jsx("input",{type:g?"text":"password",value:r,onChange:S,placeholder:h,className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg
          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`}),u&&s.jsx("button",{type:"button",className:`absolute inset-y-0 right-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:()=>_(!g),children:g?s.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}):s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})})]})},Ol=o=>{const{title:u="",className:r="",children:d}=o,[c,h]=b.useState(!1);return s.jsxs("div",{className:`border border-gray-200 dark:border-gray-600 rounded-lg p-4 ${r}`,children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("div",{children:typeof u=="string"?s.jsx("h3",{className:"text-sm text-gray-900 dark:text-white font-medium mb-4",children:u}):u}),s.jsx("button",{onClick:()=>h(!c),children:c?s.jsx(vg,{}):s.jsx(kg,{})})]}),s.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:c&&d})]})},so=({open:o,onClose:u,children:r,className:d="",overlayClassName:c="",autoClose:h=!0})=>(b.useEffect(()=>{let m;return o&&h&&(m=setTimeout(()=>{u()},3e3)),()=>clearTimeout(m)},[o,h]),o?s.jsx("div",{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 ${c}`,onClick:u,children:s.jsxs("div",{className:`relative bg-white rounded-lg shadow-lg p-6 min-w-[300px] max-w-full ${d}`,onClick:m=>m.stopPropagation(),children:[s.jsx("button",{className:"absolute top-2 right-4 bg-transparent border-none text-gray-400 hover:text-gray-600",onClick:u,"aria-label":"Close",children:s.jsx(Ln,{size:16})}),r]})}):null);var Cr={exports:{}};/**
 * @license
 * Lodash <https://lodash.com/>
 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
 * Released under MIT license <https://lodash.com/license>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 */Cr.exports;(function(o,u){(function(){var r,d="4.17.21",c=200,h="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",m="Expected a function",g="Invalid `variable` option passed into `_.template`",_="__lodash_hash_undefined__",S=500,v="__lodash_placeholder__",C=1,I=2,L=4,A=1,B=2,R=1,z=2,Z=4,Y=8,$=16,O=32,U=64,V=128,J=256,p=512,K=30,te="...",F=800,pe=16,he=1,ae=2,de=3,ie=1/0,q=9007199254740991,Be=17976931348623157e292,se=NaN,re=4294967295,_e=re-1,H=re>>>1,xe=[["ary",V],["bind",R],["bindKey",z],["curry",Y],["curryRight",$],["flip",p],["partial",O],["partialRight",U],["rearg",J]],ue="[object Arguments]",Pe="[object Array]",fe="[object AsyncFunction]",Ce="[object Boolean]",Oe="[object Date]",Me="[object DOMException]",Ne="[object Error]",We="[object Function]",mt="[object GeneratorFunction]",Je="[object Map]",kt="[object Number]",Ht="[object Null]",lt="[object Object]",ct="[object Promise]",Rt="[object Proxy]",St="[object RegExp]",Re="[object Set]",yt="[object String]",Q="[object Symbol]",je="[object Undefined]",tt="[object WeakMap]",gt="[object WeakSet]",It="[object ArrayBuffer]",Ct="[object DataView]",bt="[object Float32Array]",W="[object Float64Array]",ne="[object Int8Array]",ke="[object Int16Array]",we="[object Int32Array]",Ae="[object Uint8Array]",Ye="[object Uint8ClampedArray]",He="[object Uint16Array]",ze="[object Uint32Array]",rt=/\b__p \+= '';/g,Kt=/\b(__p \+=) '' \+/g,Jt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ns=/&(?:amp|lt|gt|quot|#39);/g,As=/[&<>"']/g,Er=RegExp(Ns.source),Mr=RegExp(As.source),Tr=/<%-([\s\S]+?)%>/g,Es=/<%([\s\S]+?)%>/g,Ms=/<%=([\s\S]+?)%>/g,Pr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Dr=/^\w*$/,Qe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,os=/[\\^$.*+?()[\]{}|]/g,Ts=RegExp(os.source),Nn=/^\s+/,Or=/\s/,Fr=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,pn=/\{\n\/\* \[wrapped with (.+)\] \*/,Rr=/,? & /,zr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ur=/[()=,{}\[\]\/\s]/,Ps=/\\(\\)?/g,as=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ls=/\w*$/,Ds=/^[-+]0x[0-9a-f]+$/i,Os=/^0b[01]+$/i,An=/^\[object .+?Constructor\]$/,Br=/^0o[0-7]+$/i,xn=/^(?:0|[1-9]\d*)$/,Bn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,T=/($^)/,P=/['\n\r\u2028\u2029\\]/g,me="\\ud800-\\udfff",Ze="\\u0300-\\u036f",jt="\\ufe20-\\ufe2f",Wn="\\u20d0-\\u20ff",oo=Ze+jt+Wn,ao="\\u2700-\\u27bf",lo="a-z\\xdf-\\xf6\\xf8-\\xff",gc="\\xac\\xb1\\xd7\\xf7",pc="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",xc="\\u2000-\\u206f",yc=" \\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",co="A-Z\\xc0-\\xd6\\xd8-\\xde",uo="\\ufe0e\\ufe0f",fo=gc+pc+xc+yc,Wr="['’]",bc="["+me+"]",ho="["+fo+"]",Fs="["+oo+"]",mo="\\d+",_c="["+ao+"]",go="["+lo+"]",po="[^"+me+fo+mo+ao+lo+co+"]",Gr="\\ud83c[\\udffb-\\udfff]",wc="(?:"+Fs+"|"+Gr+")",xo="[^"+me+"]",$r="(?:\\ud83c[\\udde6-\\uddff]){2}",Vr="[\\ud800-\\udbff][\\udc00-\\udfff]",Gn="["+co+"]",yo="\\u200d",bo="(?:"+go+"|"+po+")",vc="(?:"+Gn+"|"+po+")",_o="(?:"+Wr+"(?:d|ll|m|re|s|t|ve))?",wo="(?:"+Wr+"(?:D|LL|M|RE|S|T|VE))?",vo=wc+"?",ko="["+uo+"]?",kc="(?:"+yo+"(?:"+[xo,$r,Vr].join("|")+")"+ko+vo+")*",Sc="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ic="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",So=ko+vo+kc,Cc="(?:"+[_c,$r,Vr].join("|")+")"+So,jc="(?:"+[xo+Fs+"?",Fs,$r,Vr,bc].join("|")+")",Lc=RegExp(Wr,"g"),Nc=RegExp(Fs,"g"),qr=RegExp(Gr+"(?="+Gr+")|"+jc+So,"g"),Ac=RegExp([Gn+"?"+go+"+"+_o+"(?="+[ho,Gn,"$"].join("|")+")",vc+"+"+wo+"(?="+[ho,Gn+bo,"$"].join("|")+")",Gn+"?"+bo+"+"+_o,Gn+"+"+wo,Ic,Sc,mo,Cc].join("|"),"g"),Ec=RegExp("["+yo+me+oo+uo+"]"),Mc=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Tc=["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"],Pc=-1,qe={};qe[bt]=qe[W]=qe[ne]=qe[ke]=qe[we]=qe[Ae]=qe[Ye]=qe[He]=qe[ze]=!0,qe[ue]=qe[Pe]=qe[It]=qe[Ce]=qe[Ct]=qe[Oe]=qe[Ne]=qe[We]=qe[Je]=qe[kt]=qe[lt]=qe[St]=qe[Re]=qe[yt]=qe[tt]=!1;var Ve={};Ve[ue]=Ve[Pe]=Ve[It]=Ve[Ct]=Ve[Ce]=Ve[Oe]=Ve[bt]=Ve[W]=Ve[ne]=Ve[ke]=Ve[we]=Ve[Je]=Ve[kt]=Ve[lt]=Ve[St]=Ve[Re]=Ve[yt]=Ve[Q]=Ve[Ae]=Ve[Ye]=Ve[He]=Ve[ze]=!0,Ve[Ne]=Ve[We]=Ve[tt]=!1;var Dc={À:"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",Œ:"Oe",œ:"oe",ŉ:"'n",ſ:"s"},Oc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Fc={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Rc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},zc=parseFloat,Uc=parseInt,Io=typeof Ss=="object"&&Ss&&Ss.Object===Object&&Ss,Bc=typeof self=="object"&&self&&self.Object===Object&&self,ut=Io||Bc||Function("return this")(),Hr=u&&!u.nodeType&&u,En=Hr&&!0&&o&&!o.nodeType&&o,Co=En&&En.exports===Hr,Kr=Co&&Io.process,zt=function(){try{var w=En&&En.require&&En.require("util").types;return w||Kr&&Kr.binding&&Kr.binding("util")}catch{}}(),jo=zt&&zt.isArrayBuffer,Lo=zt&&zt.isDate,No=zt&&zt.isMap,Ao=zt&&zt.isRegExp,Eo=zt&&zt.isSet,Mo=zt&&zt.isTypedArray;function Mt(w,N,j){switch(j.length){case 0:return w.call(N);case 1:return w.call(N,j[0]);case 2:return w.call(N,j[0],j[1]);case 3:return w.call(N,j[0],j[1],j[2])}return w.apply(N,j)}function Wc(w,N,j,X){for(var ge=-1,De=w==null?0:w.length;++ge<De;){var it=w[ge];N(X,it,j(it),w)}return X}function Ut(w,N){for(var j=-1,X=w==null?0:w.length;++j<X&&N(w[j],j,w)!==!1;);return w}function Gc(w,N){for(var j=w==null?0:w.length;j--&&N(w[j],j,w)!==!1;);return w}function To(w,N){for(var j=-1,X=w==null?0:w.length;++j<X;)if(!N(w[j],j,w))return!1;return!0}function yn(w,N){for(var j=-1,X=w==null?0:w.length,ge=0,De=[];++j<X;){var it=w[j];N(it,j,w)&&(De[ge++]=it)}return De}function Rs(w,N){var j=w==null?0:w.length;return!!j&&$n(w,N,0)>-1}function Jr(w,N,j){for(var X=-1,ge=w==null?0:w.length;++X<ge;)if(j(N,w[X]))return!0;return!1}function Ke(w,N){for(var j=-1,X=w==null?0:w.length,ge=Array(X);++j<X;)ge[j]=N(w[j],j,w);return ge}function bn(w,N){for(var j=-1,X=N.length,ge=w.length;++j<X;)w[ge+j]=N[j];return w}function Xr(w,N,j,X){var ge=-1,De=w==null?0:w.length;for(X&&De&&(j=w[++ge]);++ge<De;)j=N(j,w[ge],ge,w);return j}function $c(w,N,j,X){var ge=w==null?0:w.length;for(X&&ge&&(j=w[--ge]);ge--;)j=N(j,w[ge],ge,w);return j}function Yr(w,N){for(var j=-1,X=w==null?0:w.length;++j<X;)if(N(w[j],j,w))return!0;return!1}var Vc=Qr("length");function qc(w){return w.split("")}function Hc(w){return w.match(zr)||[]}function Po(w,N,j){var X;return j(w,function(ge,De,it){if(N(ge,De,it))return X=De,!1}),X}function zs(w,N,j,X){for(var ge=w.length,De=j+(X?1:-1);X?De--:++De<ge;)if(N(w[De],De,w))return De;return-1}function $n(w,N,j){return N===N?id(w,N,j):zs(w,Do,j)}function Kc(w,N,j,X){for(var ge=j-1,De=w.length;++ge<De;)if(X(w[ge],N))return ge;return-1}function Do(w){return w!==w}function Oo(w,N){var j=w==null?0:w.length;return j?ei(w,N)/j:se}function Qr(w){return function(N){return N==null?r:N[w]}}function Zr(w){return function(N){return w==null?r:w[N]}}function Fo(w,N,j,X,ge){return ge(w,function(De,it,Ge){j=X?(X=!1,De):N(j,De,it,Ge)}),j}function Jc(w,N){var j=w.length;for(w.sort(N);j--;)w[j]=w[j].value;return w}function ei(w,N){for(var j,X=-1,ge=w.length;++X<ge;){var De=N(w[X]);De!==r&&(j=j===r?De:j+De)}return j}function ti(w,N){for(var j=-1,X=Array(w);++j<w;)X[j]=N(j);return X}function Xc(w,N){return Ke(N,function(j){return[j,w[j]]})}function Ro(w){return w&&w.slice(0,Wo(w)+1).replace(Nn,"")}function Tt(w){return function(N){return w(N)}}function ni(w,N){return Ke(N,function(j){return w[j]})}function cs(w,N){return w.has(N)}function zo(w,N){for(var j=-1,X=w.length;++j<X&&$n(N,w[j],0)>-1;);return j}function Uo(w,N){for(var j=w.length;j--&&$n(N,w[j],0)>-1;);return j}function Yc(w,N){for(var j=w.length,X=0;j--;)w[j]===N&&++X;return X}var Qc=Zr(Dc),Zc=Zr(Oc);function ed(w){return"\\"+Rc[w]}function td(w,N){return w==null?r:w[N]}function Vn(w){return Ec.test(w)}function nd(w){return Mc.test(w)}function sd(w){for(var N,j=[];!(N=w.next()).done;)j.push(N.value);return j}function si(w){var N=-1,j=Array(w.size);return w.forEach(function(X,ge){j[++N]=[ge,X]}),j}function Bo(w,N){return function(j){return w(N(j))}}function _n(w,N){for(var j=-1,X=w.length,ge=0,De=[];++j<X;){var it=w[j];(it===N||it===v)&&(w[j]=v,De[ge++]=j)}return De}function Us(w){var N=-1,j=Array(w.size);return w.forEach(function(X){j[++N]=X}),j}function rd(w){var N=-1,j=Array(w.size);return w.forEach(function(X){j[++N]=[X,X]}),j}function id(w,N,j){for(var X=j-1,ge=w.length;++X<ge;)if(w[X]===N)return X;return-1}function od(w,N,j){for(var X=j+1;X--;)if(w[X]===N)return X;return X}function qn(w){return Vn(w)?ld(w):Vc(w)}function Xt(w){return Vn(w)?cd(w):qc(w)}function Wo(w){for(var N=w.length;N--&&Or.test(w.charAt(N)););return N}var ad=Zr(Fc);function ld(w){for(var N=qr.lastIndex=0;qr.test(w);)++N;return N}function cd(w){return w.match(qr)||[]}function dd(w){return w.match(Ac)||[]}var ud=function w(N){N=N==null?ut:Hn.defaults(ut.Object(),N,Hn.pick(ut,Tc));var j=N.Array,X=N.Date,ge=N.Error,De=N.Function,it=N.Math,Ge=N.Object,ri=N.RegExp,fd=N.String,Bt=N.TypeError,Bs=j.prototype,hd=De.prototype,Kn=Ge.prototype,Ws=N["__core-js_shared__"],Gs=hd.toString,Ue=Kn.hasOwnProperty,md=0,Go=function(){var e=/[^.]+$/.exec(Ws&&Ws.keys&&Ws.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),$s=Kn.toString,gd=Gs.call(Ge),pd=ut._,xd=ri("^"+Gs.call(Ue).replace(os,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Vs=Co?N.Buffer:r,wn=N.Symbol,qs=N.Uint8Array,$o=Vs?Vs.allocUnsafe:r,Hs=Bo(Ge.getPrototypeOf,Ge),Vo=Ge.create,qo=Kn.propertyIsEnumerable,Ks=Bs.splice,Ho=wn?wn.isConcatSpreadable:r,ds=wn?wn.iterator:r,Mn=wn?wn.toStringTag:r,Js=function(){try{var e=Fn(Ge,"defineProperty");return e({},"",{}),e}catch{}}(),yd=N.clearTimeout!==ut.clearTimeout&&N.clearTimeout,bd=X&&X.now!==ut.Date.now&&X.now,_d=N.setTimeout!==ut.setTimeout&&N.setTimeout,Xs=it.ceil,Ys=it.floor,ii=Ge.getOwnPropertySymbols,wd=Vs?Vs.isBuffer:r,Ko=N.isFinite,vd=Bs.join,kd=Bo(Ge.keys,Ge),ot=it.max,pt=it.min,Sd=X.now,Id=N.parseInt,Jo=it.random,Cd=Bs.reverse,oi=Fn(N,"DataView"),us=Fn(N,"Map"),ai=Fn(N,"Promise"),Jn=Fn(N,"Set"),fs=Fn(N,"WeakMap"),hs=Fn(Ge,"create"),Qs=fs&&new fs,Xn={},jd=Rn(oi),Ld=Rn(us),Nd=Rn(ai),Ad=Rn(Jn),Ed=Rn(fs),Zs=wn?wn.prototype:r,ms=Zs?Zs.valueOf:r,Xo=Zs?Zs.toString:r;function l(e){if(et(e)&&!ye(e)&&!(e instanceof Ee)){if(e instanceof Wt)return e;if(Ue.call(e,"__wrapped__"))return Ya(e)}return new Wt(e)}var Yn=function(){function e(){}return function(t){if(!Xe(t))return{};if(Vo)return Vo(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function er(){}function Wt(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}l.templateSettings={escape:Tr,evaluate:Es,interpolate:Ms,variable:"",imports:{_:l}},l.prototype=er.prototype,l.prototype.constructor=l,Wt.prototype=Yn(er.prototype),Wt.prototype.constructor=Wt;function Ee(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=re,this.__views__=[]}function Md(){var e=new Ee(this.__wrapped__);return e.__actions__=Lt(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Lt(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Lt(this.__views__),e}function Td(){if(this.__filtered__){var e=new Ee(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Pd(){var e=this.__wrapped__.value(),t=this.__dir__,n=ye(e),i=t<0,a=n?e.length:0,f=qu(0,a,this.__views__),x=f.start,y=f.end,k=y-x,E=i?y:x-1,M=this.__iteratees__,D=M.length,G=0,ee=pt(k,this.__takeCount__);if(!n||!i&&a==k&&ee==k)return _a(e,this.__actions__);var le=[];e:for(;k--&&G<ee;){E+=t;for(var ve=-1,ce=e[E];++ve<D;){var Le=M[ve],Te=Le.iteratee,Ot=Le.type,vt=Te(ce);if(Ot==ae)ce=vt;else if(!vt){if(Ot==he)continue e;break e}}le[G++]=ce}return le}Ee.prototype=Yn(er.prototype),Ee.prototype.constructor=Ee;function Tn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Dd(){this.__data__=hs?hs(null):{},this.size=0}function Od(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Fd(e){var t=this.__data__;if(hs){var n=t[e];return n===_?r:n}return Ue.call(t,e)?t[e]:r}function Rd(e){var t=this.__data__;return hs?t[e]!==r:Ue.call(t,e)}function zd(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=hs&&t===r?_:t,this}Tn.prototype.clear=Dd,Tn.prototype.delete=Od,Tn.prototype.get=Fd,Tn.prototype.has=Rd,Tn.prototype.set=zd;function rn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Ud(){this.__data__=[],this.size=0}function Bd(e){var t=this.__data__,n=tr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():Ks.call(t,n,1),--this.size,!0}function Wd(e){var t=this.__data__,n=tr(t,e);return n<0?r:t[n][1]}function Gd(e){return tr(this.__data__,e)>-1}function $d(e,t){var n=this.__data__,i=tr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}rn.prototype.clear=Ud,rn.prototype.delete=Bd,rn.prototype.get=Wd,rn.prototype.has=Gd,rn.prototype.set=$d;function on(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Vd(){this.size=0,this.__data__={hash:new Tn,map:new(us||rn),string:new Tn}}function qd(e){var t=hr(this,e).delete(e);return this.size-=t?1:0,t}function Hd(e){return hr(this,e).get(e)}function Kd(e){return hr(this,e).has(e)}function Jd(e,t){var n=hr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}on.prototype.clear=Vd,on.prototype.delete=qd,on.prototype.get=Hd,on.prototype.has=Kd,on.prototype.set=Jd;function Pn(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new on;++t<n;)this.add(e[t])}function Xd(e){return this.__data__.set(e,_),this}function Yd(e){return this.__data__.has(e)}Pn.prototype.add=Pn.prototype.push=Xd,Pn.prototype.has=Yd;function Yt(e){var t=this.__data__=new rn(e);this.size=t.size}function Qd(){this.__data__=new rn,this.size=0}function Zd(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function eu(e){return this.__data__.get(e)}function tu(e){return this.__data__.has(e)}function nu(e,t){var n=this.__data__;if(n instanceof rn){var i=n.__data__;if(!us||i.length<c-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new on(i)}return n.set(e,t),this.size=n.size,this}Yt.prototype.clear=Qd,Yt.prototype.delete=Zd,Yt.prototype.get=eu,Yt.prototype.has=tu,Yt.prototype.set=nu;function Yo(e,t){var n=ye(e),i=!n&&zn(e),a=!n&&!i&&Cn(e),f=!n&&!i&&!a&&ts(e),x=n||i||a||f,y=x?ti(e.length,fd):[],k=y.length;for(var E in e)(t||Ue.call(e,E))&&!(x&&(E=="length"||a&&(E=="offset"||E=="parent")||f&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||dn(E,k)))&&y.push(E);return y}function Qo(e){var t=e.length;return t?e[yi(0,t-1)]:r}function su(e,t){return mr(Lt(e),Dn(t,0,e.length))}function ru(e){return mr(Lt(e))}function li(e,t,n){(n!==r&&!Qt(e[t],n)||n===r&&!(t in e))&&an(e,t,n)}function gs(e,t,n){var i=e[t];(!(Ue.call(e,t)&&Qt(i,n))||n===r&&!(t in e))&&an(e,t,n)}function tr(e,t){for(var n=e.length;n--;)if(Qt(e[n][0],t))return n;return-1}function iu(e,t,n,i){return vn(e,function(a,f,x){t(i,a,n(a),x)}),i}function Zo(e,t){return e&&tn(t,dt(t),e)}function ou(e,t){return e&&tn(t,At(t),e)}function an(e,t,n){t=="__proto__"&&Js?Js(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ci(e,t){for(var n=-1,i=t.length,a=j(i),f=e==null;++n<i;)a[n]=f?r:Gi(e,t[n]);return a}function Dn(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function Gt(e,t,n,i,a,f){var x,y=t&C,k=t&I,E=t&L;if(n&&(x=a?n(e,i,a,f):n(e)),x!==r)return x;if(!Xe(e))return e;var M=ye(e);if(M){if(x=Ku(e),!y)return Lt(e,x)}else{var D=xt(e),G=D==We||D==mt;if(Cn(e))return ka(e,y);if(D==lt||D==ue||G&&!a){if(x=k||G?{}:Wa(e),!y)return k?Fu(e,ou(x,e)):Ou(e,Zo(x,e))}else{if(!Ve[D])return a?e:{};x=Ju(e,D,y)}}f||(f=new Yt);var ee=f.get(e);if(ee)return ee;f.set(e,x),xl(e)?e.forEach(function(ce){x.add(Gt(ce,t,n,ce,e,f))}):gl(e)&&e.forEach(function(ce,Le){x.set(Le,Gt(ce,t,n,Le,e,f))});var le=E?k?Ni:Li:k?At:dt,ve=M?r:le(e);return Ut(ve||e,function(ce,Le){ve&&(Le=ce,ce=e[Le]),gs(x,Le,Gt(ce,t,n,Le,e,f))}),x}function au(e){var t=dt(e);return function(n){return ea(n,e,t)}}function ea(e,t,n){var i=n.length;if(e==null)return!i;for(e=Ge(e);i--;){var a=n[i],f=t[a],x=e[a];if(x===r&&!(a in e)||!f(x))return!1}return!0}function ta(e,t,n){if(typeof e!="function")throw new Bt(m);return vs(function(){e.apply(r,n)},t)}function ps(e,t,n,i){var a=-1,f=Rs,x=!0,y=e.length,k=[],E=t.length;if(!y)return k;n&&(t=Ke(t,Tt(n))),i?(f=Jr,x=!1):t.length>=c&&(f=cs,x=!1,t=new Pn(t));e:for(;++a<y;){var M=e[a],D=n==null?M:n(M);if(M=i||M!==0?M:0,x&&D===D){for(var G=E;G--;)if(t[G]===D)continue e;k.push(M)}else f(t,D,i)||k.push(M)}return k}var vn=La(en),na=La(ui,!0);function lu(e,t){var n=!0;return vn(e,function(i,a,f){return n=!!t(i,a,f),n}),n}function nr(e,t,n){for(var i=-1,a=e.length;++i<a;){var f=e[i],x=t(f);if(x!=null&&(y===r?x===x&&!Dt(x):n(x,y)))var y=x,k=f}return k}function cu(e,t,n,i){var a=e.length;for(n=be(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:be(i),i<0&&(i+=a),i=n>i?0:bl(i);n<i;)e[n++]=t;return e}function sa(e,t){var n=[];return vn(e,function(i,a,f){t(i,a,f)&&n.push(i)}),n}function ft(e,t,n,i,a){var f=-1,x=e.length;for(n||(n=Yu),a||(a=[]);++f<x;){var y=e[f];t>0&&n(y)?t>1?ft(y,t-1,n,i,a):bn(a,y):i||(a[a.length]=y)}return a}var di=Na(),ra=Na(!0);function en(e,t){return e&&di(e,t,dt)}function ui(e,t){return e&&ra(e,t,dt)}function sr(e,t){return yn(t,function(n){return un(e[n])})}function On(e,t){t=Sn(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[nn(t[n++])];return n&&n==i?e:r}function ia(e,t,n){var i=t(e);return ye(e)?i:bn(i,n(e))}function _t(e){return e==null?e===r?je:Ht:Mn&&Mn in Ge(e)?Vu(e):rf(e)}function fi(e,t){return e>t}function du(e,t){return e!=null&&Ue.call(e,t)}function uu(e,t){return e!=null&&t in Ge(e)}function fu(e,t,n){return e>=pt(t,n)&&e<ot(t,n)}function hi(e,t,n){for(var i=n?Jr:Rs,a=e[0].length,f=e.length,x=f,y=j(f),k=1/0,E=[];x--;){var M=e[x];x&&t&&(M=Ke(M,Tt(t))),k=pt(M.length,k),y[x]=!n&&(t||a>=120&&M.length>=120)?new Pn(x&&M):r}M=e[0];var D=-1,G=y[0];e:for(;++D<a&&E.length<k;){var ee=M[D],le=t?t(ee):ee;if(ee=n||ee!==0?ee:0,!(G?cs(G,le):i(E,le,n))){for(x=f;--x;){var ve=y[x];if(!(ve?cs(ve,le):i(e[x],le,n)))continue e}G&&G.push(le),E.push(ee)}}return E}function hu(e,t,n,i){return en(e,function(a,f,x){t(i,n(a),f,x)}),i}function xs(e,t,n){t=Sn(t,e),e=qa(e,t);var i=e==null?e:e[nn(Vt(t))];return i==null?r:Mt(i,e,n)}function oa(e){return et(e)&&_t(e)==ue}function mu(e){return et(e)&&_t(e)==It}function gu(e){return et(e)&&_t(e)==Oe}function ys(e,t,n,i,a){return e===t?!0:e==null||t==null||!et(e)&&!et(t)?e!==e&&t!==t:pu(e,t,n,i,ys,a)}function pu(e,t,n,i,a,f){var x=ye(e),y=ye(t),k=x?Pe:xt(e),E=y?Pe:xt(t);k=k==ue?lt:k,E=E==ue?lt:E;var M=k==lt,D=E==lt,G=k==E;if(G&&Cn(e)){if(!Cn(t))return!1;x=!0,M=!1}if(G&&!M)return f||(f=new Yt),x||ts(e)?za(e,t,n,i,a,f):Gu(e,t,k,n,i,a,f);if(!(n&A)){var ee=M&&Ue.call(e,"__wrapped__"),le=D&&Ue.call(t,"__wrapped__");if(ee||le){var ve=ee?e.value():e,ce=le?t.value():t;return f||(f=new Yt),a(ve,ce,n,i,f)}}return G?(f||(f=new Yt),$u(e,t,n,i,a,f)):!1}function xu(e){return et(e)&&xt(e)==Je}function mi(e,t,n,i){var a=n.length,f=a,x=!i;if(e==null)return!f;for(e=Ge(e);a--;){var y=n[a];if(x&&y[2]?y[1]!==e[y[0]]:!(y[0]in e))return!1}for(;++a<f;){y=n[a];var k=y[0],E=e[k],M=y[1];if(x&&y[2]){if(E===r&&!(k in e))return!1}else{var D=new Yt;if(i)var G=i(E,M,k,e,t,D);if(!(G===r?ys(M,E,A|B,i,D):G))return!1}}return!0}function aa(e){if(!Xe(e)||Zu(e))return!1;var t=un(e)?xd:An;return t.test(Rn(e))}function yu(e){return et(e)&&_t(e)==St}function bu(e){return et(e)&&xt(e)==Re}function _u(e){return et(e)&&_r(e.length)&&!!qe[_t(e)]}function la(e){return typeof e=="function"?e:e==null?Et:typeof e=="object"?ye(e)?ua(e[0],e[1]):da(e):Al(e)}function gi(e){if(!ws(e))return kd(e);var t=[];for(var n in Ge(e))Ue.call(e,n)&&n!="constructor"&&t.push(n);return t}function wu(e){if(!Xe(e))return sf(e);var t=ws(e),n=[];for(var i in e)i=="constructor"&&(t||!Ue.call(e,i))||n.push(i);return n}function pi(e,t){return e<t}function ca(e,t){var n=-1,i=Nt(e)?j(e.length):[];return vn(e,function(a,f,x){i[++n]=t(a,f,x)}),i}function da(e){var t=Ei(e);return t.length==1&&t[0][2]?$a(t[0][0],t[0][1]):function(n){return n===e||mi(n,e,t)}}function ua(e,t){return Ti(e)&&Ga(t)?$a(nn(e),t):function(n){var i=Gi(n,e);return i===r&&i===t?$i(n,e):ys(t,i,A|B)}}function rr(e,t,n,i,a){e!==t&&di(t,function(f,x){if(a||(a=new Yt),Xe(f))vu(e,t,x,n,rr,i,a);else{var y=i?i(Di(e,x),f,x+"",e,t,a):r;y===r&&(y=f),li(e,x,y)}},At)}function vu(e,t,n,i,a,f,x){var y=Di(e,n),k=Di(t,n),E=x.get(k);if(E){li(e,n,E);return}var M=f?f(y,k,n+"",e,t,x):r,D=M===r;if(D){var G=ye(k),ee=!G&&Cn(k),le=!G&&!ee&&ts(k);M=k,G||ee||le?ye(y)?M=y:nt(y)?M=Lt(y):ee?(D=!1,M=ka(k,!0)):le?(D=!1,M=Sa(k,!0)):M=[]:ks(k)||zn(k)?(M=y,zn(y)?M=_l(y):(!Xe(y)||un(y))&&(M=Wa(k))):D=!1}D&&(x.set(k,M),a(M,k,i,f,x),x.delete(k)),li(e,n,M)}function fa(e,t){var n=e.length;if(n)return t+=t<0?n:0,dn(t,n)?e[t]:r}function ha(e,t,n){t.length?t=Ke(t,function(f){return ye(f)?function(x){return On(x,f.length===1?f[0]:f)}:f}):t=[Et];var i=-1;t=Ke(t,Tt(oe()));var a=ca(e,function(f,x,y){var k=Ke(t,function(E){return E(f)});return{criteria:k,index:++i,value:f}});return Jc(a,function(f,x){return Du(f,x,n)})}function ku(e,t){return ma(e,t,function(n,i){return $i(e,i)})}function ma(e,t,n){for(var i=-1,a=t.length,f={};++i<a;){var x=t[i],y=On(e,x);n(y,x)&&bs(f,Sn(x,e),y)}return f}function Su(e){return function(t){return On(t,e)}}function xi(e,t,n,i){var a=i?Kc:$n,f=-1,x=t.length,y=e;for(e===t&&(t=Lt(t)),n&&(y=Ke(e,Tt(n)));++f<x;)for(var k=0,E=t[f],M=n?n(E):E;(k=a(y,M,k,i))>-1;)y!==e&&Ks.call(y,k,1),Ks.call(e,k,1);return e}function ga(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==f){var f=a;dn(a)?Ks.call(e,a,1):wi(e,a)}}return e}function yi(e,t){return e+Ys(Jo()*(t-e+1))}function Iu(e,t,n,i){for(var a=-1,f=ot(Xs((t-e)/(n||1)),0),x=j(f);f--;)x[i?f:++a]=e,e+=n;return x}function bi(e,t){var n="";if(!e||t<1||t>q)return n;do t%2&&(n+=e),t=Ys(t/2),t&&(e+=e);while(t);return n}function Se(e,t){return Oi(Va(e,t,Et),e+"")}function Cu(e){return Qo(ns(e))}function ju(e,t){var n=ns(e);return mr(n,Dn(t,0,n.length))}function bs(e,t,n,i){if(!Xe(e))return e;t=Sn(t,e);for(var a=-1,f=t.length,x=f-1,y=e;y!=null&&++a<f;){var k=nn(t[a]),E=n;if(k==="__proto__"||k==="constructor"||k==="prototype")return e;if(a!=x){var M=y[k];E=i?i(M,k,y):r,E===r&&(E=Xe(M)?M:dn(t[a+1])?[]:{})}gs(y,k,E),y=y[k]}return e}var pa=Qs?function(e,t){return Qs.set(e,t),e}:Et,Lu=Js?function(e,t){return Js(e,"toString",{configurable:!0,enumerable:!1,value:qi(t),writable:!0})}:Et;function Nu(e){return mr(ns(e))}function $t(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var f=j(a);++i<a;)f[i]=e[i+t];return f}function Au(e,t){var n;return vn(e,function(i,a,f){return n=t(i,a,f),!n}),!!n}function ir(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=H){for(;i<a;){var f=i+a>>>1,x=e[f];x!==null&&!Dt(x)&&(n?x<=t:x<t)?i=f+1:a=f}return a}return _i(e,t,Et,n)}function _i(e,t,n,i){var a=0,f=e==null?0:e.length;if(f===0)return 0;t=n(t);for(var x=t!==t,y=t===null,k=Dt(t),E=t===r;a<f;){var M=Ys((a+f)/2),D=n(e[M]),G=D!==r,ee=D===null,le=D===D,ve=Dt(D);if(x)var ce=i||le;else E?ce=le&&(i||G):y?ce=le&&G&&(i||!ee):k?ce=le&&G&&!ee&&(i||!ve):ee||ve?ce=!1:ce=i?D<=t:D<t;ce?a=M+1:f=M}return pt(f,_e)}function xa(e,t){for(var n=-1,i=e.length,a=0,f=[];++n<i;){var x=e[n],y=t?t(x):x;if(!n||!Qt(y,k)){var k=y;f[a++]=x===0?0:x}}return f}function ya(e){return typeof e=="number"?e:Dt(e)?se:+e}function Pt(e){if(typeof e=="string")return e;if(ye(e))return Ke(e,Pt)+"";if(Dt(e))return Xo?Xo.call(e):"";var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function kn(e,t,n){var i=-1,a=Rs,f=e.length,x=!0,y=[],k=y;if(n)x=!1,a=Jr;else if(f>=c){var E=t?null:Bu(e);if(E)return Us(E);x=!1,a=cs,k=new Pn}else k=t?[]:y;e:for(;++i<f;){var M=e[i],D=t?t(M):M;if(M=n||M!==0?M:0,x&&D===D){for(var G=k.length;G--;)if(k[G]===D)continue e;t&&k.push(D),y.push(M)}else a(k,D,n)||(k!==y&&k.push(D),y.push(M))}return y}function wi(e,t){return t=Sn(t,e),e=qa(e,t),e==null||delete e[nn(Vt(t))]}function ba(e,t,n,i){return bs(e,t,n(On(e,t)),i)}function or(e,t,n,i){for(var a=e.length,f=i?a:-1;(i?f--:++f<a)&&t(e[f],f,e););return n?$t(e,i?0:f,i?f+1:a):$t(e,i?f+1:0,i?a:f)}function _a(e,t){var n=e;return n instanceof Ee&&(n=n.value()),Xr(t,function(i,a){return a.func.apply(a.thisArg,bn([i],a.args))},n)}function vi(e,t,n){var i=e.length;if(i<2)return i?kn(e[0]):[];for(var a=-1,f=j(i);++a<i;)for(var x=e[a],y=-1;++y<i;)y!=a&&(f[a]=ps(f[a]||x,e[y],t,n));return kn(ft(f,1),t,n)}function wa(e,t,n){for(var i=-1,a=e.length,f=t.length,x={};++i<a;){var y=i<f?t[i]:r;n(x,e[i],y)}return x}function ki(e){return nt(e)?e:[]}function Si(e){return typeof e=="function"?e:Et}function Sn(e,t){return ye(e)?e:Ti(e,t)?[e]:Xa(Fe(e))}var Eu=Se;function In(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:$t(e,t,n)}var va=yd||function(e){return ut.clearTimeout(e)};function ka(e,t){if(t)return e.slice();var n=e.length,i=$o?$o(n):new e.constructor(n);return e.copy(i),i}function Ii(e){var t=new e.constructor(e.byteLength);return new qs(t).set(new qs(e)),t}function Mu(e,t){var n=t?Ii(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Tu(e){var t=new e.constructor(e.source,ls.exec(e));return t.lastIndex=e.lastIndex,t}function Pu(e){return ms?Ge(ms.call(e)):{}}function Sa(e,t){var n=t?Ii(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ia(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,f=Dt(e),x=t!==r,y=t===null,k=t===t,E=Dt(t);if(!y&&!E&&!f&&e>t||f&&x&&k&&!y&&!E||i&&x&&k||!n&&k||!a)return 1;if(!i&&!f&&!E&&e<t||E&&n&&a&&!i&&!f||y&&n&&a||!x&&a||!k)return-1}return 0}function Du(e,t,n){for(var i=-1,a=e.criteria,f=t.criteria,x=a.length,y=n.length;++i<x;){var k=Ia(a[i],f[i]);if(k){if(i>=y)return k;var E=n[i];return k*(E=="desc"?-1:1)}}return e.index-t.index}function Ca(e,t,n,i){for(var a=-1,f=e.length,x=n.length,y=-1,k=t.length,E=ot(f-x,0),M=j(k+E),D=!i;++y<k;)M[y]=t[y];for(;++a<x;)(D||a<f)&&(M[n[a]]=e[a]);for(;E--;)M[y++]=e[a++];return M}function ja(e,t,n,i){for(var a=-1,f=e.length,x=-1,y=n.length,k=-1,E=t.length,M=ot(f-y,0),D=j(M+E),G=!i;++a<M;)D[a]=e[a];for(var ee=a;++k<E;)D[ee+k]=t[k];for(;++x<y;)(G||a<f)&&(D[ee+n[x]]=e[a++]);return D}function Lt(e,t){var n=-1,i=e.length;for(t||(t=j(i));++n<i;)t[n]=e[n];return t}function tn(e,t,n,i){var a=!n;n||(n={});for(var f=-1,x=t.length;++f<x;){var y=t[f],k=i?i(n[y],e[y],y,n,e):r;k===r&&(k=e[y]),a?an(n,y,k):gs(n,y,k)}return n}function Ou(e,t){return tn(e,Mi(e),t)}function Fu(e,t){return tn(e,Ua(e),t)}function ar(e,t){return function(n,i){var a=ye(n)?Wc:iu,f=t?t():{};return a(n,e,oe(i,2),f)}}function Qn(e){return Se(function(t,n){var i=-1,a=n.length,f=a>1?n[a-1]:r,x=a>2?n[2]:r;for(f=e.length>3&&typeof f=="function"?(a--,f):r,x&&wt(n[0],n[1],x)&&(f=a<3?r:f,a=1),t=Ge(t);++i<a;){var y=n[i];y&&e(t,y,i,f)}return t})}function La(e,t){return function(n,i){if(n==null)return n;if(!Nt(n))return e(n,i);for(var a=n.length,f=t?a:-1,x=Ge(n);(t?f--:++f<a)&&i(x[f],f,x)!==!1;);return n}}function Na(e){return function(t,n,i){for(var a=-1,f=Ge(t),x=i(t),y=x.length;y--;){var k=x[e?y:++a];if(n(f[k],k,f)===!1)break}return t}}function Ru(e,t,n){var i=t&R,a=_s(e);function f(){var x=this&&this!==ut&&this instanceof f?a:e;return x.apply(i?n:this,arguments)}return f}function Aa(e){return function(t){t=Fe(t);var n=Vn(t)?Xt(t):r,i=n?n[0]:t.charAt(0),a=n?In(n,1).join(""):t.slice(1);return i[e]()+a}}function Zn(e){return function(t){return Xr(Ll(jl(t).replace(Lc,"")),e,"")}}function _s(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Yn(e.prototype),i=e.apply(n,t);return Xe(i)?i:n}}function zu(e,t,n){var i=_s(e);function a(){for(var f=arguments.length,x=j(f),y=f,k=es(a);y--;)x[y]=arguments[y];var E=f<3&&x[0]!==k&&x[f-1]!==k?[]:_n(x,k);if(f-=E.length,f<n)return Da(e,t,lr,a.placeholder,r,x,E,r,r,n-f);var M=this&&this!==ut&&this instanceof a?i:e;return Mt(M,this,x)}return a}function Ea(e){return function(t,n,i){var a=Ge(t);if(!Nt(t)){var f=oe(n,3);t=dt(t),n=function(y){return f(a[y],y,a)}}var x=e(t,n,i);return x>-1?a[f?t[x]:x]:r}}function Ma(e){return cn(function(t){var n=t.length,i=n,a=Wt.prototype.thru;for(e&&t.reverse();i--;){var f=t[i];if(typeof f!="function")throw new Bt(m);if(a&&!x&&fr(f)=="wrapper")var x=new Wt([],!0)}for(i=x?i:n;++i<n;){f=t[i];var y=fr(f),k=y=="wrapper"?Ai(f):r;k&&Pi(k[0])&&k[1]==(V|Y|O|J)&&!k[4].length&&k[9]==1?x=x[fr(k[0])].apply(x,k[3]):x=f.length==1&&Pi(f)?x[y]():x.thru(f)}return function(){var E=arguments,M=E[0];if(x&&E.length==1&&ye(M))return x.plant(M).value();for(var D=0,G=n?t[D].apply(this,E):M;++D<n;)G=t[D].call(this,G);return G}})}function lr(e,t,n,i,a,f,x,y,k,E){var M=t&V,D=t&R,G=t&z,ee=t&(Y|$),le=t&p,ve=G?r:_s(e);function ce(){for(var Le=arguments.length,Te=j(Le),Ot=Le;Ot--;)Te[Ot]=arguments[Ot];if(ee)var vt=es(ce),Ft=Yc(Te,vt);if(i&&(Te=Ca(Te,i,a,ee)),f&&(Te=ja(Te,f,x,ee)),Le-=Ft,ee&&Le<E){var st=_n(Te,vt);return Da(e,t,lr,ce.placeholder,n,Te,st,y,k,E-Le)}var Zt=D?n:this,hn=G?Zt[e]:e;return Le=Te.length,y?Te=of(Te,y):le&&Le>1&&Te.reverse(),M&&k<Le&&(Te.length=k),this&&this!==ut&&this instanceof ce&&(hn=ve||_s(hn)),hn.apply(Zt,Te)}return ce}function Ta(e,t){return function(n,i){return hu(n,e,t(i),{})}}function cr(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Pt(n),i=Pt(i)):(n=ya(n),i=ya(i)),a=e(n,i)}return a}}function Ci(e){return cn(function(t){return t=Ke(t,Tt(oe())),Se(function(n){var i=this;return e(t,function(a){return Mt(a,i,n)})})})}function dr(e,t){t=t===r?" ":Pt(t);var n=t.length;if(n<2)return n?bi(t,e):t;var i=bi(t,Xs(e/qn(t)));return Vn(t)?In(Xt(i),0,e).join(""):i.slice(0,e)}function Uu(e,t,n,i){var a=t&R,f=_s(e);function x(){for(var y=-1,k=arguments.length,E=-1,M=i.length,D=j(M+k),G=this&&this!==ut&&this instanceof x?f:e;++E<M;)D[E]=i[E];for(;k--;)D[E++]=arguments[++y];return Mt(G,a?n:this,D)}return x}function Pa(e){return function(t,n,i){return i&&typeof i!="number"&&wt(t,n,i)&&(n=i=r),t=fn(t),n===r?(n=t,t=0):n=fn(n),i=i===r?t<n?1:-1:fn(i),Iu(t,n,i,e)}}function ur(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=qt(t),n=qt(n)),e(t,n)}}function Da(e,t,n,i,a,f,x,y,k,E){var M=t&Y,D=M?x:r,G=M?r:x,ee=M?f:r,le=M?r:f;t|=M?O:U,t&=~(M?U:O),t&Z||(t&=-4);var ve=[e,t,a,ee,D,le,G,y,k,E],ce=n.apply(r,ve);return Pi(e)&&Ha(ce,ve),ce.placeholder=i,Ka(ce,e,t)}function ji(e){var t=it[e];return function(n,i){if(n=qt(n),i=i==null?0:pt(be(i),292),i&&Ko(n)){var a=(Fe(n)+"e").split("e"),f=t(a[0]+"e"+(+a[1]+i));return a=(Fe(f)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var Bu=Jn&&1/Us(new Jn([,-0]))[1]==ie?function(e){return new Jn(e)}:Ji;function Oa(e){return function(t){var n=xt(t);return n==Je?si(t):n==Re?rd(t):Xc(t,e(t))}}function ln(e,t,n,i,a,f,x,y){var k=t&z;if(!k&&typeof e!="function")throw new Bt(m);var E=i?i.length:0;if(E||(t&=-97,i=a=r),x=x===r?x:ot(be(x),0),y=y===r?y:be(y),E-=a?a.length:0,t&U){var M=i,D=a;i=a=r}var G=k?r:Ai(e),ee=[e,t,n,i,a,M,D,f,x,y];if(G&&nf(ee,G),e=ee[0],t=ee[1],n=ee[2],i=ee[3],a=ee[4],y=ee[9]=ee[9]===r?k?0:e.length:ot(ee[9]-E,0),!y&&t&(Y|$)&&(t&=-25),!t||t==R)var le=Ru(e,t,n);else t==Y||t==$?le=zu(e,t,y):(t==O||t==(R|O))&&!a.length?le=Uu(e,t,n,i):le=lr.apply(r,ee);var ve=G?pa:Ha;return Ka(ve(le,ee),e,t)}function Fa(e,t,n,i){return e===r||Qt(e,Kn[n])&&!Ue.call(i,n)?t:e}function Ra(e,t,n,i,a,f){return Xe(e)&&Xe(t)&&(f.set(t,e),rr(e,t,r,Ra,f),f.delete(t)),e}function Wu(e){return ks(e)?r:e}function za(e,t,n,i,a,f){var x=n&A,y=e.length,k=t.length;if(y!=k&&!(x&&k>y))return!1;var E=f.get(e),M=f.get(t);if(E&&M)return E==t&&M==e;var D=-1,G=!0,ee=n&B?new Pn:r;for(f.set(e,t),f.set(t,e);++D<y;){var le=e[D],ve=t[D];if(i)var ce=x?i(ve,le,D,t,e,f):i(le,ve,D,e,t,f);if(ce!==r){if(ce)continue;G=!1;break}if(ee){if(!Yr(t,function(Le,Te){if(!cs(ee,Te)&&(le===Le||a(le,Le,n,i,f)))return ee.push(Te)})){G=!1;break}}else if(!(le===ve||a(le,ve,n,i,f))){G=!1;break}}return f.delete(e),f.delete(t),G}function Gu(e,t,n,i,a,f,x){switch(n){case Ct:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case It:return!(e.byteLength!=t.byteLength||!f(new qs(e),new qs(t)));case Ce:case Oe:case kt:return Qt(+e,+t);case Ne:return e.name==t.name&&e.message==t.message;case St:case yt:return e==t+"";case Je:var y=si;case Re:var k=i&A;if(y||(y=Us),e.size!=t.size&&!k)return!1;var E=x.get(e);if(E)return E==t;i|=B,x.set(e,t);var M=za(y(e),y(t),i,a,f,x);return x.delete(e),M;case Q:if(ms)return ms.call(e)==ms.call(t)}return!1}function $u(e,t,n,i,a,f){var x=n&A,y=Li(e),k=y.length,E=Li(t),M=E.length;if(k!=M&&!x)return!1;for(var D=k;D--;){var G=y[D];if(!(x?G in t:Ue.call(t,G)))return!1}var ee=f.get(e),le=f.get(t);if(ee&&le)return ee==t&&le==e;var ve=!0;f.set(e,t),f.set(t,e);for(var ce=x;++D<k;){G=y[D];var Le=e[G],Te=t[G];if(i)var Ot=x?i(Te,Le,G,t,e,f):i(Le,Te,G,e,t,f);if(!(Ot===r?Le===Te||a(Le,Te,n,i,f):Ot)){ve=!1;break}ce||(ce=G=="constructor")}if(ve&&!ce){var vt=e.constructor,Ft=t.constructor;vt!=Ft&&"constructor"in e&&"constructor"in t&&!(typeof vt=="function"&&vt instanceof vt&&typeof Ft=="function"&&Ft instanceof Ft)&&(ve=!1)}return f.delete(e),f.delete(t),ve}function cn(e){return Oi(Va(e,r,el),e+"")}function Li(e){return ia(e,dt,Mi)}function Ni(e){return ia(e,At,Ua)}var Ai=Qs?function(e){return Qs.get(e)}:Ji;function fr(e){for(var t=e.name+"",n=Xn[t],i=Ue.call(Xn,t)?n.length:0;i--;){var a=n[i],f=a.func;if(f==null||f==e)return a.name}return t}function es(e){var t=Ue.call(l,"placeholder")?l:e;return t.placeholder}function oe(){var e=l.iteratee||Hi;return e=e===Hi?la:e,arguments.length?e(arguments[0],arguments[1]):e}function hr(e,t){var n=e.__data__;return Qu(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ei(e){for(var t=dt(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,Ga(a)]}return t}function Fn(e,t){var n=td(e,t);return aa(n)?n:r}function Vu(e){var t=Ue.call(e,Mn),n=e[Mn];try{e[Mn]=r;var i=!0}catch{}var a=$s.call(e);return i&&(t?e[Mn]=n:delete e[Mn]),a}var Mi=ii?function(e){return e==null?[]:(e=Ge(e),yn(ii(e),function(t){return qo.call(e,t)}))}:Xi,Ua=ii?function(e){for(var t=[];e;)bn(t,Mi(e)),e=Hs(e);return t}:Xi,xt=_t;(oi&&xt(new oi(new ArrayBuffer(1)))!=Ct||us&&xt(new us)!=Je||ai&&xt(ai.resolve())!=ct||Jn&&xt(new Jn)!=Re||fs&&xt(new fs)!=tt)&&(xt=function(e){var t=_t(e),n=t==lt?e.constructor:r,i=n?Rn(n):"";if(i)switch(i){case jd:return Ct;case Ld:return Je;case Nd:return ct;case Ad:return Re;case Ed:return tt}return t});function qu(e,t,n){for(var i=-1,a=n.length;++i<a;){var f=n[i],x=f.size;switch(f.type){case"drop":e+=x;break;case"dropRight":t-=x;break;case"take":t=pt(t,e+x);break;case"takeRight":e=ot(e,t-x);break}}return{start:e,end:t}}function Hu(e){var t=e.match(pn);return t?t[1].split(Rr):[]}function Ba(e,t,n){t=Sn(t,e);for(var i=-1,a=t.length,f=!1;++i<a;){var x=nn(t[i]);if(!(f=e!=null&&n(e,x)))break;e=e[x]}return f||++i!=a?f:(a=e==null?0:e.length,!!a&&_r(a)&&dn(x,a)&&(ye(e)||zn(e)))}function Ku(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Ue.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Wa(e){return typeof e.constructor=="function"&&!ws(e)?Yn(Hs(e)):{}}function Ju(e,t,n){var i=e.constructor;switch(t){case It:return Ii(e);case Ce:case Oe:return new i(+e);case Ct:return Mu(e,n);case bt:case W:case ne:case ke:case we:case Ae:case Ye:case He:case ze:return Sa(e,n);case Je:return new i;case kt:case yt:return new i(e);case St:return Tu(e);case Re:return new i;case Q:return Pu(e)}}function Xu(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(Fr,`{
/* [wrapped with `+t+`] */
`)}function Yu(e){return ye(e)||zn(e)||!!(Ho&&e&&e[Ho])}function dn(e,t){var n=typeof e;return t=t??q,!!t&&(n=="number"||n!="symbol"&&xn.test(e))&&e>-1&&e%1==0&&e<t}function wt(e,t,n){if(!Xe(n))return!1;var i=typeof t;return(i=="number"?Nt(n)&&dn(t,n.length):i=="string"&&t in n)?Qt(n[t],e):!1}function Ti(e,t){if(ye(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Dt(e)?!0:Dr.test(e)||!Pr.test(e)||t!=null&&e in Ge(t)}function Qu(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Pi(e){var t=fr(e),n=l[t];if(typeof n!="function"||!(t in Ee.prototype))return!1;if(e===n)return!0;var i=Ai(n);return!!i&&e===i[0]}function Zu(e){return!!Go&&Go in e}var ef=Ws?un:Yi;function ws(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Kn;return e===n}function Ga(e){return e===e&&!Xe(e)}function $a(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in Ge(n))}}function tf(e){var t=yr(e,function(i){return n.size===S&&n.clear(),i}),n=t.cache;return t}function nf(e,t){var n=e[1],i=t[1],a=n|i,f=a<(R|z|V),x=i==V&&n==Y||i==V&&n==J&&e[7].length<=t[8]||i==(V|J)&&t[7].length<=t[8]&&n==Y;if(!(f||x))return e;i&R&&(e[2]=t[2],a|=n&R?0:Z);var y=t[3];if(y){var k=e[3];e[3]=k?Ca(k,y,t[4]):y,e[4]=k?_n(e[3],v):t[4]}return y=t[5],y&&(k=e[5],e[5]=k?ja(k,y,t[6]):y,e[6]=k?_n(e[5],v):t[6]),y=t[7],y&&(e[7]=y),i&V&&(e[8]=e[8]==null?t[8]:pt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function sf(e){var t=[];if(e!=null)for(var n in Ge(e))t.push(n);return t}function rf(e){return $s.call(e)}function Va(e,t,n){return t=ot(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,f=ot(i.length-t,0),x=j(f);++a<f;)x[a]=i[t+a];a=-1;for(var y=j(t+1);++a<t;)y[a]=i[a];return y[t]=n(x),Mt(e,this,y)}}function qa(e,t){return t.length<2?e:On(e,$t(t,0,-1))}function of(e,t){for(var n=e.length,i=pt(t.length,n),a=Lt(e);i--;){var f=t[i];e[i]=dn(f,n)?a[f]:r}return e}function Di(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Ha=Ja(pa),vs=_d||function(e,t){return ut.setTimeout(e,t)},Oi=Ja(Lu);function Ka(e,t,n){var i=t+"";return Oi(e,Xu(i,af(Hu(i),n)))}function Ja(e){var t=0,n=0;return function(){var i=Sd(),a=pe-(i-n);if(n=i,a>0){if(++t>=F)return arguments[0]}else t=0;return e.apply(r,arguments)}}function mr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var f=yi(n,a),x=e[f];e[f]=e[n],e[n]=x}return e.length=t,e}var Xa=tf(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Qe,function(n,i,a,f){t.push(a?f.replace(Ps,"$1"):i||n)}),t});function nn(e){if(typeof e=="string"||Dt(e))return e;var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function Rn(e){if(e!=null){try{return Gs.call(e)}catch{}try{return e+""}catch{}}return""}function af(e,t){return Ut(xe,function(n){var i="_."+n[0];t&n[1]&&!Rs(e,i)&&e.push(i)}),e.sort()}function Ya(e){if(e instanceof Ee)return e.clone();var t=new Wt(e.__wrapped__,e.__chain__);return t.__actions__=Lt(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function lf(e,t,n){(n?wt(e,t,n):t===r)?t=1:t=ot(be(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,f=0,x=j(Xs(i/t));a<i;)x[f++]=$t(e,a,a+=t);return x}function cf(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var f=e[t];f&&(a[i++]=f)}return a}function df(){var e=arguments.length;if(!e)return[];for(var t=j(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return bn(ye(n)?Lt(n):[n],ft(t,1))}var uf=Se(function(e,t){return nt(e)?ps(e,ft(t,1,nt,!0)):[]}),ff=Se(function(e,t){var n=Vt(t);return nt(n)&&(n=r),nt(e)?ps(e,ft(t,1,nt,!0),oe(n,2)):[]}),hf=Se(function(e,t){var n=Vt(t);return nt(n)&&(n=r),nt(e)?ps(e,ft(t,1,nt,!0),r,n):[]});function mf(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:be(t),$t(e,t<0?0:t,i)):[]}function gf(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:be(t),t=i-t,$t(e,0,t<0?0:t)):[]}function pf(e,t){return e&&e.length?or(e,oe(t,3),!0,!0):[]}function xf(e,t){return e&&e.length?or(e,oe(t,3),!0):[]}function yf(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&wt(e,t,n)&&(n=0,i=a),cu(e,t,n,i)):[]}function Qa(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:be(n);return a<0&&(a=ot(i+a,0)),zs(e,oe(t,3),a)}function Za(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=be(n),a=n<0?ot(i+a,0):pt(a,i-1)),zs(e,oe(t,3),a,!0)}function el(e){var t=e==null?0:e.length;return t?ft(e,1):[]}function bf(e){var t=e==null?0:e.length;return t?ft(e,ie):[]}function _f(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:be(t),ft(e,t)):[]}function wf(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function tl(e){return e&&e.length?e[0]:r}function vf(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:be(n);return a<0&&(a=ot(i+a,0)),$n(e,t,a)}function kf(e){var t=e==null?0:e.length;return t?$t(e,0,-1):[]}var Sf=Se(function(e){var t=Ke(e,ki);return t.length&&t[0]===e[0]?hi(t):[]}),If=Se(function(e){var t=Vt(e),n=Ke(e,ki);return t===Vt(n)?t=r:n.pop(),n.length&&n[0]===e[0]?hi(n,oe(t,2)):[]}),Cf=Se(function(e){var t=Vt(e),n=Ke(e,ki);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?hi(n,r,t):[]});function jf(e,t){return e==null?"":vd.call(e,t)}function Vt(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Lf(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=be(n),a=a<0?ot(i+a,0):pt(a,i-1)),t===t?od(e,t,a):zs(e,Do,a,!0)}function Nf(e,t){return e&&e.length?fa(e,be(t)):r}var Af=Se(nl);function nl(e,t){return e&&e.length&&t&&t.length?xi(e,t):e}function Ef(e,t,n){return e&&e.length&&t&&t.length?xi(e,t,oe(n,2)):e}function Mf(e,t,n){return e&&e.length&&t&&t.length?xi(e,t,r,n):e}var Tf=cn(function(e,t){var n=e==null?0:e.length,i=ci(e,t);return ga(e,Ke(t,function(a){return dn(a,n)?+a:a}).sort(Ia)),i});function Pf(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],f=e.length;for(t=oe(t,3);++i<f;){var x=e[i];t(x,i,e)&&(n.push(x),a.push(i))}return ga(e,a),n}function Fi(e){return e==null?e:Cd.call(e)}function Df(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&wt(e,t,n)?(t=0,n=i):(t=t==null?0:be(t),n=n===r?i:be(n)),$t(e,t,n)):[]}function Of(e,t){return ir(e,t)}function Ff(e,t,n){return _i(e,t,oe(n,2))}function Rf(e,t){var n=e==null?0:e.length;if(n){var i=ir(e,t);if(i<n&&Qt(e[i],t))return i}return-1}function zf(e,t){return ir(e,t,!0)}function Uf(e,t,n){return _i(e,t,oe(n,2),!0)}function Bf(e,t){var n=e==null?0:e.length;if(n){var i=ir(e,t,!0)-1;if(Qt(e[i],t))return i}return-1}function Wf(e){return e&&e.length?xa(e):[]}function Gf(e,t){return e&&e.length?xa(e,oe(t,2)):[]}function $f(e){var t=e==null?0:e.length;return t?$t(e,1,t):[]}function Vf(e,t,n){return e&&e.length?(t=n||t===r?1:be(t),$t(e,0,t<0?0:t)):[]}function qf(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:be(t),t=i-t,$t(e,t<0?0:t,i)):[]}function Hf(e,t){return e&&e.length?or(e,oe(t,3),!1,!0):[]}function Kf(e,t){return e&&e.length?or(e,oe(t,3)):[]}var Jf=Se(function(e){return kn(ft(e,1,nt,!0))}),Xf=Se(function(e){var t=Vt(e);return nt(t)&&(t=r),kn(ft(e,1,nt,!0),oe(t,2))}),Yf=Se(function(e){var t=Vt(e);return t=typeof t=="function"?t:r,kn(ft(e,1,nt,!0),r,t)});function Qf(e){return e&&e.length?kn(e):[]}function Zf(e,t){return e&&e.length?kn(e,oe(t,2)):[]}function e0(e,t){return t=typeof t=="function"?t:r,e&&e.length?kn(e,r,t):[]}function Ri(e){if(!(e&&e.length))return[];var t=0;return e=yn(e,function(n){if(nt(n))return t=ot(n.length,t),!0}),ti(t,function(n){return Ke(e,Qr(n))})}function sl(e,t){if(!(e&&e.length))return[];var n=Ri(e);return t==null?n:Ke(n,function(i){return Mt(t,r,i)})}var t0=Se(function(e,t){return nt(e)?ps(e,t):[]}),n0=Se(function(e){return vi(yn(e,nt))}),s0=Se(function(e){var t=Vt(e);return nt(t)&&(t=r),vi(yn(e,nt),oe(t,2))}),r0=Se(function(e){var t=Vt(e);return t=typeof t=="function"?t:r,vi(yn(e,nt),r,t)}),i0=Se(Ri);function o0(e,t){return wa(e||[],t||[],gs)}function a0(e,t){return wa(e||[],t||[],bs)}var l0=Se(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,sl(e,n)});function rl(e){var t=l(e);return t.__chain__=!0,t}function c0(e,t){return t(e),e}function gr(e,t){return t(e)}var d0=cn(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(f){return ci(f,e)};return t>1||this.__actions__.length||!(i instanceof Ee)||!dn(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:gr,args:[a],thisArg:r}),new Wt(i,this.__chain__).thru(function(f){return t&&!f.length&&f.push(r),f}))});function u0(){return rl(this)}function f0(){return new Wt(this.value(),this.__chain__)}function h0(){this.__values__===r&&(this.__values__=yl(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function m0(){return this}function g0(e){for(var t,n=this;n instanceof er;){var i=Ya(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function p0(){var e=this.__wrapped__;if(e instanceof Ee){var t=e;return this.__actions__.length&&(t=new Ee(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Fi],thisArg:r}),new Wt(t,this.__chain__)}return this.thru(Fi)}function x0(){return _a(this.__wrapped__,this.__actions__)}var y0=ar(function(e,t,n){Ue.call(e,n)?++e[n]:an(e,n,1)});function b0(e,t,n){var i=ye(e)?To:lu;return n&&wt(e,t,n)&&(t=r),i(e,oe(t,3))}function _0(e,t){var n=ye(e)?yn:sa;return n(e,oe(t,3))}var w0=Ea(Qa),v0=Ea(Za);function k0(e,t){return ft(pr(e,t),1)}function S0(e,t){return ft(pr(e,t),ie)}function I0(e,t,n){return n=n===r?1:be(n),ft(pr(e,t),n)}function il(e,t){var n=ye(e)?Ut:vn;return n(e,oe(t,3))}function ol(e,t){var n=ye(e)?Gc:na;return n(e,oe(t,3))}var C0=ar(function(e,t,n){Ue.call(e,n)?e[n].push(t):an(e,n,[t])});function j0(e,t,n,i){e=Nt(e)?e:ns(e),n=n&&!i?be(n):0;var a=e.length;return n<0&&(n=ot(a+n,0)),wr(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&$n(e,t,n)>-1}var L0=Se(function(e,t,n){var i=-1,a=typeof t=="function",f=Nt(e)?j(e.length):[];return vn(e,function(x){f[++i]=a?Mt(t,x,n):xs(x,t,n)}),f}),N0=ar(function(e,t,n){an(e,n,t)});function pr(e,t){var n=ye(e)?Ke:ca;return n(e,oe(t,3))}function A0(e,t,n,i){return e==null?[]:(ye(t)||(t=t==null?[]:[t]),n=i?r:n,ye(n)||(n=n==null?[]:[n]),ha(e,t,n))}var E0=ar(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function M0(e,t,n){var i=ye(e)?Xr:Fo,a=arguments.length<3;return i(e,oe(t,4),n,a,vn)}function T0(e,t,n){var i=ye(e)?$c:Fo,a=arguments.length<3;return i(e,oe(t,4),n,a,na)}function P0(e,t){var n=ye(e)?yn:sa;return n(e,br(oe(t,3)))}function D0(e){var t=ye(e)?Qo:Cu;return t(e)}function O0(e,t,n){(n?wt(e,t,n):t===r)?t=1:t=be(t);var i=ye(e)?su:ju;return i(e,t)}function F0(e){var t=ye(e)?ru:Nu;return t(e)}function R0(e){if(e==null)return 0;if(Nt(e))return wr(e)?qn(e):e.length;var t=xt(e);return t==Je||t==Re?e.size:gi(e).length}function z0(e,t,n){var i=ye(e)?Yr:Au;return n&&wt(e,t,n)&&(t=r),i(e,oe(t,3))}var U0=Se(function(e,t){if(e==null)return[];var n=t.length;return n>1&&wt(e,t[0],t[1])?t=[]:n>2&&wt(t[0],t[1],t[2])&&(t=[t[0]]),ha(e,ft(t,1),[])}),xr=bd||function(){return ut.Date.now()};function B0(e,t){if(typeof t!="function")throw new Bt(m);return e=be(e),function(){if(--e<1)return t.apply(this,arguments)}}function al(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,ln(e,V,r,r,r,r,t)}function ll(e,t){var n;if(typeof t!="function")throw new Bt(m);return e=be(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var zi=Se(function(e,t,n){var i=R;if(n.length){var a=_n(n,es(zi));i|=O}return ln(e,i,t,n,a)}),cl=Se(function(e,t,n){var i=R|z;if(n.length){var a=_n(n,es(cl));i|=O}return ln(t,i,e,n,a)});function dl(e,t,n){t=n?r:t;var i=ln(e,Y,r,r,r,r,r,t);return i.placeholder=dl.placeholder,i}function ul(e,t,n){t=n?r:t;var i=ln(e,$,r,r,r,r,r,t);return i.placeholder=ul.placeholder,i}function fl(e,t,n){var i,a,f,x,y,k,E=0,M=!1,D=!1,G=!0;if(typeof e!="function")throw new Bt(m);t=qt(t)||0,Xe(n)&&(M=!!n.leading,D="maxWait"in n,f=D?ot(qt(n.maxWait)||0,t):f,G="trailing"in n?!!n.trailing:G);function ee(st){var Zt=i,hn=a;return i=a=r,E=st,x=e.apply(hn,Zt),x}function le(st){return E=st,y=vs(Le,t),M?ee(st):x}function ve(st){var Zt=st-k,hn=st-E,El=t-Zt;return D?pt(El,f-hn):El}function ce(st){var Zt=st-k,hn=st-E;return k===r||Zt>=t||Zt<0||D&&hn>=f}function Le(){var st=xr();if(ce(st))return Te(st);y=vs(Le,ve(st))}function Te(st){return y=r,G&&i?ee(st):(i=a=r,x)}function Ot(){y!==r&&va(y),E=0,i=k=a=y=r}function vt(){return y===r?x:Te(xr())}function Ft(){var st=xr(),Zt=ce(st);if(i=arguments,a=this,k=st,Zt){if(y===r)return le(k);if(D)return va(y),y=vs(Le,t),ee(k)}return y===r&&(y=vs(Le,t)),x}return Ft.cancel=Ot,Ft.flush=vt,Ft}var W0=Se(function(e,t){return ta(e,1,t)}),G0=Se(function(e,t,n){return ta(e,qt(t)||0,n)});function $0(e){return ln(e,p)}function yr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Bt(m);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],f=n.cache;if(f.has(a))return f.get(a);var x=e.apply(this,i);return n.cache=f.set(a,x)||f,x};return n.cache=new(yr.Cache||on),n}yr.Cache=on;function br(e){if(typeof e!="function")throw new Bt(m);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 V0(e){return ll(2,e)}var q0=Eu(function(e,t){t=t.length==1&&ye(t[0])?Ke(t[0],Tt(oe())):Ke(ft(t,1),Tt(oe()));var n=t.length;return Se(function(i){for(var a=-1,f=pt(i.length,n);++a<f;)i[a]=t[a].call(this,i[a]);return Mt(e,this,i)})}),Ui=Se(function(e,t){var n=_n(t,es(Ui));return ln(e,O,r,t,n)}),hl=Se(function(e,t){var n=_n(t,es(hl));return ln(e,U,r,t,n)}),H0=cn(function(e,t){return ln(e,J,r,r,r,t)});function K0(e,t){if(typeof e!="function")throw new Bt(m);return t=t===r?t:be(t),Se(e,t)}function J0(e,t){if(typeof e!="function")throw new Bt(m);return t=t==null?0:ot(be(t),0),Se(function(n){var i=n[t],a=In(n,0,t);return i&&bn(a,i),Mt(e,this,a)})}function X0(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new Bt(m);return Xe(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),fl(e,t,{leading:i,maxWait:t,trailing:a})}function Y0(e){return al(e,1)}function Q0(e,t){return Ui(Si(t),e)}function Z0(){if(!arguments.length)return[];var e=arguments[0];return ye(e)?e:[e]}function eh(e){return Gt(e,L)}function th(e,t){return t=typeof t=="function"?t:r,Gt(e,L,t)}function nh(e){return Gt(e,C|L)}function sh(e,t){return t=typeof t=="function"?t:r,Gt(e,C|L,t)}function rh(e,t){return t==null||ea(e,t,dt(t))}function Qt(e,t){return e===t||e!==e&&t!==t}var ih=ur(fi),oh=ur(function(e,t){return e>=t}),zn=oa(function(){return arguments}())?oa:function(e){return et(e)&&Ue.call(e,"callee")&&!qo.call(e,"callee")},ye=j.isArray,ah=jo?Tt(jo):mu;function Nt(e){return e!=null&&_r(e.length)&&!un(e)}function nt(e){return et(e)&&Nt(e)}function lh(e){return e===!0||e===!1||et(e)&&_t(e)==Ce}var Cn=wd||Yi,ch=Lo?Tt(Lo):gu;function dh(e){return et(e)&&e.nodeType===1&&!ks(e)}function uh(e){if(e==null)return!0;if(Nt(e)&&(ye(e)||typeof e=="string"||typeof e.splice=="function"||Cn(e)||ts(e)||zn(e)))return!e.length;var t=xt(e);if(t==Je||t==Re)return!e.size;if(ws(e))return!gi(e).length;for(var n in e)if(Ue.call(e,n))return!1;return!0}function fh(e,t){return ys(e,t)}function hh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?ys(e,t,r,n):!!i}function Bi(e){if(!et(e))return!1;var t=_t(e);return t==Ne||t==Me||typeof e.message=="string"&&typeof e.name=="string"&&!ks(e)}function mh(e){return typeof e=="number"&&Ko(e)}function un(e){if(!Xe(e))return!1;var t=_t(e);return t==We||t==mt||t==fe||t==Rt}function ml(e){return typeof e=="number"&&e==be(e)}function _r(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=q}function Xe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function et(e){return e!=null&&typeof e=="object"}var gl=No?Tt(No):xu;function gh(e,t){return e===t||mi(e,t,Ei(t))}function ph(e,t,n){return n=typeof n=="function"?n:r,mi(e,t,Ei(t),n)}function xh(e){return pl(e)&&e!=+e}function yh(e){if(ef(e))throw new ge(h);return aa(e)}function bh(e){return e===null}function _h(e){return e==null}function pl(e){return typeof e=="number"||et(e)&&_t(e)==kt}function ks(e){if(!et(e)||_t(e)!=lt)return!1;var t=Hs(e);if(t===null)return!0;var n=Ue.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Gs.call(n)==gd}var Wi=Ao?Tt(Ao):yu;function wh(e){return ml(e)&&e>=-q&&e<=q}var xl=Eo?Tt(Eo):bu;function wr(e){return typeof e=="string"||!ye(e)&&et(e)&&_t(e)==yt}function Dt(e){return typeof e=="symbol"||et(e)&&_t(e)==Q}var ts=Mo?Tt(Mo):_u;function vh(e){return e===r}function kh(e){return et(e)&&xt(e)==tt}function Sh(e){return et(e)&&_t(e)==gt}var Ih=ur(pi),Ch=ur(function(e,t){return e<=t});function yl(e){if(!e)return[];if(Nt(e))return wr(e)?Xt(e):Lt(e);if(ds&&e[ds])return sd(e[ds]());var t=xt(e),n=t==Je?si:t==Re?Us:ns;return n(e)}function fn(e){if(!e)return e===0?e:0;if(e=qt(e),e===ie||e===-ie){var t=e<0?-1:1;return t*Be}return e===e?e:0}function be(e){var t=fn(e),n=t%1;return t===t?n?t-n:t:0}function bl(e){return e?Dn(be(e),0,re):0}function qt(e){if(typeof e=="number")return e;if(Dt(e))return se;if(Xe(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Xe(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ro(e);var n=Os.test(e);return n||Br.test(e)?Uc(e.slice(2),n?2:8):Ds.test(e)?se:+e}function _l(e){return tn(e,At(e))}function jh(e){return e?Dn(be(e),-q,q):e===0?e:0}function Fe(e){return e==null?"":Pt(e)}var Lh=Qn(function(e,t){if(ws(t)||Nt(t)){tn(t,dt(t),e);return}for(var n in t)Ue.call(t,n)&&gs(e,n,t[n])}),wl=Qn(function(e,t){tn(t,At(t),e)}),vr=Qn(function(e,t,n,i){tn(t,At(t),e,i)}),Nh=Qn(function(e,t,n,i){tn(t,dt(t),e,i)}),Ah=cn(ci);function Eh(e,t){var n=Yn(e);return t==null?n:Zo(n,t)}var Mh=Se(function(e,t){e=Ge(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&wt(t[0],t[1],a)&&(i=1);++n<i;)for(var f=t[n],x=At(f),y=-1,k=x.length;++y<k;){var E=x[y],M=e[E];(M===r||Qt(M,Kn[E])&&!Ue.call(e,E))&&(e[E]=f[E])}return e}),Th=Se(function(e){return e.push(r,Ra),Mt(vl,r,e)});function Ph(e,t){return Po(e,oe(t,3),en)}function Dh(e,t){return Po(e,oe(t,3),ui)}function Oh(e,t){return e==null?e:di(e,oe(t,3),At)}function Fh(e,t){return e==null?e:ra(e,oe(t,3),At)}function Rh(e,t){return e&&en(e,oe(t,3))}function zh(e,t){return e&&ui(e,oe(t,3))}function Uh(e){return e==null?[]:sr(e,dt(e))}function Bh(e){return e==null?[]:sr(e,At(e))}function Gi(e,t,n){var i=e==null?r:On(e,t);return i===r?n:i}function Wh(e,t){return e!=null&&Ba(e,t,du)}function $i(e,t){return e!=null&&Ba(e,t,uu)}var Gh=Ta(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=$s.call(t)),e[t]=n},qi(Et)),$h=Ta(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=$s.call(t)),Ue.call(e,t)?e[t].push(n):e[t]=[n]},oe),Vh=Se(xs);function dt(e){return Nt(e)?Yo(e):gi(e)}function At(e){return Nt(e)?Yo(e,!0):wu(e)}function qh(e,t){var n={};return t=oe(t,3),en(e,function(i,a,f){an(n,t(i,a,f),i)}),n}function Hh(e,t){var n={};return t=oe(t,3),en(e,function(i,a,f){an(n,a,t(i,a,f))}),n}var Kh=Qn(function(e,t,n){rr(e,t,n)}),vl=Qn(function(e,t,n,i){rr(e,t,n,i)}),Jh=cn(function(e,t){var n={};if(e==null)return n;var i=!1;t=Ke(t,function(f){return f=Sn(f,e),i||(i=f.length>1),f}),tn(e,Ni(e),n),i&&(n=Gt(n,C|I|L,Wu));for(var a=t.length;a--;)wi(n,t[a]);return n});function Xh(e,t){return kl(e,br(oe(t)))}var Yh=cn(function(e,t){return e==null?{}:ku(e,t)});function kl(e,t){if(e==null)return{};var n=Ke(Ni(e),function(i){return[i]});return t=oe(t),ma(e,n,function(i,a){return t(i,a[0])})}function Qh(e,t,n){t=Sn(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var f=e==null?r:e[nn(t[i])];f===r&&(i=a,f=n),e=un(f)?f.call(e):f}return e}function Zh(e,t,n){return e==null?e:bs(e,t,n)}function em(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:bs(e,t,n,i)}var Sl=Oa(dt),Il=Oa(At);function tm(e,t,n){var i=ye(e),a=i||Cn(e)||ts(e);if(t=oe(t,4),n==null){var f=e&&e.constructor;a?n=i?new f:[]:Xe(e)?n=un(f)?Yn(Hs(e)):{}:n={}}return(a?Ut:en)(e,function(x,y,k){return t(n,x,y,k)}),n}function nm(e,t){return e==null?!0:wi(e,t)}function sm(e,t,n){return e==null?e:ba(e,t,Si(n))}function rm(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:ba(e,t,Si(n),i)}function ns(e){return e==null?[]:ni(e,dt(e))}function im(e){return e==null?[]:ni(e,At(e))}function om(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=qt(n),n=n===n?n:0),t!==r&&(t=qt(t),t=t===t?t:0),Dn(qt(e),t,n)}function am(e,t,n){return t=fn(t),n===r?(n=t,t=0):n=fn(n),e=qt(e),fu(e,t,n)}function lm(e,t,n){if(n&&typeof n!="boolean"&&wt(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=fn(e),t===r?(t=e,e=0):t=fn(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=Jo();return pt(e+a*(t-e+zc("1e-"+((a+"").length-1))),t)}return yi(e,t)}var cm=Zn(function(e,t,n){return t=t.toLowerCase(),e+(n?Cl(t):t)});function Cl(e){return Vi(Fe(e).toLowerCase())}function jl(e){return e=Fe(e),e&&e.replace(Bn,Qc).replace(Nc,"")}function dm(e,t,n){e=Fe(e),t=Pt(t);var i=e.length;n=n===r?i:Dn(be(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function um(e){return e=Fe(e),e&&Mr.test(e)?e.replace(As,Zc):e}function fm(e){return e=Fe(e),e&&Ts.test(e)?e.replace(os,"\\$&"):e}var hm=Zn(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),mm=Zn(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),gm=Aa("toLowerCase");function pm(e,t,n){e=Fe(e),t=be(t);var i=t?qn(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return dr(Ys(a),n)+e+dr(Xs(a),n)}function xm(e,t,n){e=Fe(e),t=be(t);var i=t?qn(e):0;return t&&i<t?e+dr(t-i,n):e}function ym(e,t,n){e=Fe(e),t=be(t);var i=t?qn(e):0;return t&&i<t?dr(t-i,n)+e:e}function bm(e,t,n){return n||t==null?t=0:t&&(t=+t),Id(Fe(e).replace(Nn,""),t||0)}function _m(e,t,n){return(n?wt(e,t,n):t===r)?t=1:t=be(t),bi(Fe(e),t)}function wm(){var e=arguments,t=Fe(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var vm=Zn(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function km(e,t,n){return n&&typeof n!="number"&&wt(e,t,n)&&(t=n=r),n=n===r?re:n>>>0,n?(e=Fe(e),e&&(typeof t=="string"||t!=null&&!Wi(t))&&(t=Pt(t),!t&&Vn(e))?In(Xt(e),0,n):e.split(t,n)):[]}var Sm=Zn(function(e,t,n){return e+(n?" ":"")+Vi(t)});function Im(e,t,n){return e=Fe(e),n=n==null?0:Dn(be(n),0,e.length),t=Pt(t),e.slice(n,n+t.length)==t}function Cm(e,t,n){var i=l.templateSettings;n&&wt(e,t,n)&&(t=r),e=Fe(e),t=vr({},t,i,Fa);var a=vr({},t.imports,i.imports,Fa),f=dt(a),x=ni(a,f),y,k,E=0,M=t.interpolate||T,D="__p += '",G=ri((t.escape||T).source+"|"+M.source+"|"+(M===Ms?as:T).source+"|"+(t.evaluate||T).source+"|$","g"),ee="//# sourceURL="+(Ue.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Pc+"]")+`
`;e.replace(G,function(ce,Le,Te,Ot,vt,Ft){return Te||(Te=Ot),D+=e.slice(E,Ft).replace(P,ed),Le&&(y=!0,D+=`' +
__e(`+Le+`) +
'`),vt&&(k=!0,D+=`';
`+vt+`;
__p += '`),Te&&(D+=`' +
((__t = (`+Te+`)) == null ? '' : __t) +
'`),E=Ft+ce.length,ce}),D+=`';
`;var le=Ue.call(t,"variable")&&t.variable;if(!le)D=`with (obj) {
`+D+`
}
`;else if(Ur.test(le))throw new ge(g);D=(k?D.replace(rt,""):D).replace(Kt,"$1").replace(Jt,"$1;"),D="function("+(le||"obj")+`) {
`+(le?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(y?", __e = _.escape":"")+(k?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+D+`return __p
}`;var ve=Nl(function(){return De(f,ee+"return "+D).apply(r,x)});if(ve.source=D,Bi(ve))throw ve;return ve}function jm(e){return Fe(e).toLowerCase()}function Lm(e){return Fe(e).toUpperCase()}function Nm(e,t,n){if(e=Fe(e),e&&(n||t===r))return Ro(e);if(!e||!(t=Pt(t)))return e;var i=Xt(e),a=Xt(t),f=zo(i,a),x=Uo(i,a)+1;return In(i,f,x).join("")}function Am(e,t,n){if(e=Fe(e),e&&(n||t===r))return e.slice(0,Wo(e)+1);if(!e||!(t=Pt(t)))return e;var i=Xt(e),a=Uo(i,Xt(t))+1;return In(i,0,a).join("")}function Em(e,t,n){if(e=Fe(e),e&&(n||t===r))return e.replace(Nn,"");if(!e||!(t=Pt(t)))return e;var i=Xt(e),a=zo(i,Xt(t));return In(i,a).join("")}function Mm(e,t){var n=K,i=te;if(Xe(t)){var a="separator"in t?t.separator:a;n="length"in t?be(t.length):n,i="omission"in t?Pt(t.omission):i}e=Fe(e);var f=e.length;if(Vn(e)){var x=Xt(e);f=x.length}if(n>=f)return e;var y=n-qn(i);if(y<1)return i;var k=x?In(x,0,y).join(""):e.slice(0,y);if(a===r)return k+i;if(x&&(y+=k.length-y),Wi(a)){if(e.slice(y).search(a)){var E,M=k;for(a.global||(a=ri(a.source,Fe(ls.exec(a))+"g")),a.lastIndex=0;E=a.exec(M);)var D=E.index;k=k.slice(0,D===r?y:D)}}else if(e.indexOf(Pt(a),y)!=y){var G=k.lastIndexOf(a);G>-1&&(k=k.slice(0,G))}return k+i}function Tm(e){return e=Fe(e),e&&Er.test(e)?e.replace(Ns,ad):e}var Pm=Zn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Vi=Aa("toUpperCase");function Ll(e,t,n){return e=Fe(e),t=n?r:t,t===r?nd(e)?dd(e):Hc(e):e.match(t)||[]}var Nl=Se(function(e,t){try{return Mt(e,r,t)}catch(n){return Bi(n)?n:new ge(n)}}),Dm=cn(function(e,t){return Ut(t,function(n){n=nn(n),an(e,n,zi(e[n],e))}),e});function Om(e){var t=e==null?0:e.length,n=oe();return e=t?Ke(e,function(i){if(typeof i[1]!="function")throw new Bt(m);return[n(i[0]),i[1]]}):[],Se(function(i){for(var a=-1;++a<t;){var f=e[a];if(Mt(f[0],this,i))return Mt(f[1],this,i)}})}function Fm(e){return au(Gt(e,C))}function qi(e){return function(){return e}}function Rm(e,t){return e==null||e!==e?t:e}var zm=Ma(),Um=Ma(!0);function Et(e){return e}function Hi(e){return la(typeof e=="function"?e:Gt(e,C))}function Bm(e){return da(Gt(e,C))}function Wm(e,t){return ua(e,Gt(t,C))}var Gm=Se(function(e,t){return function(n){return xs(n,e,t)}}),$m=Se(function(e,t){return function(n){return xs(e,n,t)}});function Ki(e,t,n){var i=dt(t),a=sr(t,i);n==null&&!(Xe(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=sr(t,dt(t)));var f=!(Xe(n)&&"chain"in n)||!!n.chain,x=un(e);return Ut(a,function(y){var k=t[y];e[y]=k,x&&(e.prototype[y]=function(){var E=this.__chain__;if(f||E){var M=e(this.__wrapped__),D=M.__actions__=Lt(this.__actions__);return D.push({func:k,args:arguments,thisArg:e}),M.__chain__=E,M}return k.apply(e,bn([this.value()],arguments))})}),e}function Vm(){return ut._===this&&(ut._=pd),this}function Ji(){}function qm(e){return e=be(e),Se(function(t){return fa(t,e)})}var Hm=Ci(Ke),Km=Ci(To),Jm=Ci(Yr);function Al(e){return Ti(e)?Qr(nn(e)):Su(e)}function Xm(e){return function(t){return e==null?r:On(e,t)}}var Ym=Pa(),Qm=Pa(!0);function Xi(){return[]}function Yi(){return!1}function Zm(){return{}}function eg(){return""}function tg(){return!0}function ng(e,t){if(e=be(e),e<1||e>q)return[];var n=re,i=pt(e,re);t=oe(t),e-=re;for(var a=ti(i,t);++n<e;)t(n);return a}function sg(e){return ye(e)?Ke(e,nn):Dt(e)?[e]:Lt(Xa(Fe(e)))}function rg(e){var t=++md;return Fe(e)+t}var ig=cr(function(e,t){return e+t},0),og=ji("ceil"),ag=cr(function(e,t){return e/t},1),lg=ji("floor");function cg(e){return e&&e.length?nr(e,Et,fi):r}function dg(e,t){return e&&e.length?nr(e,oe(t,2),fi):r}function ug(e){return Oo(e,Et)}function fg(e,t){return Oo(e,oe(t,2))}function hg(e){return e&&e.length?nr(e,Et,pi):r}function mg(e,t){return e&&e.length?nr(e,oe(t,2),pi):r}var gg=cr(function(e,t){return e*t},1),pg=ji("round"),xg=cr(function(e,t){return e-t},0);function yg(e){return e&&e.length?ei(e,Et):0}function bg(e,t){return e&&e.length?ei(e,oe(t,2)):0}return l.after=B0,l.ary=al,l.assign=Lh,l.assignIn=wl,l.assignInWith=vr,l.assignWith=Nh,l.at=Ah,l.before=ll,l.bind=zi,l.bindAll=Dm,l.bindKey=cl,l.castArray=Z0,l.chain=rl,l.chunk=lf,l.compact=cf,l.concat=df,l.cond=Om,l.conforms=Fm,l.constant=qi,l.countBy=y0,l.create=Eh,l.curry=dl,l.curryRight=ul,l.debounce=fl,l.defaults=Mh,l.defaultsDeep=Th,l.defer=W0,l.delay=G0,l.difference=uf,l.differenceBy=ff,l.differenceWith=hf,l.drop=mf,l.dropRight=gf,l.dropRightWhile=pf,l.dropWhile=xf,l.fill=yf,l.filter=_0,l.flatMap=k0,l.flatMapDeep=S0,l.flatMapDepth=I0,l.flatten=el,l.flattenDeep=bf,l.flattenDepth=_f,l.flip=$0,l.flow=zm,l.flowRight=Um,l.fromPairs=wf,l.functions=Uh,l.functionsIn=Bh,l.groupBy=C0,l.initial=kf,l.intersection=Sf,l.intersectionBy=If,l.intersectionWith=Cf,l.invert=Gh,l.invertBy=$h,l.invokeMap=L0,l.iteratee=Hi,l.keyBy=N0,l.keys=dt,l.keysIn=At,l.map=pr,l.mapKeys=qh,l.mapValues=Hh,l.matches=Bm,l.matchesProperty=Wm,l.memoize=yr,l.merge=Kh,l.mergeWith=vl,l.method=Gm,l.methodOf=$m,l.mixin=Ki,l.negate=br,l.nthArg=qm,l.omit=Jh,l.omitBy=Xh,l.once=V0,l.orderBy=A0,l.over=Hm,l.overArgs=q0,l.overEvery=Km,l.overSome=Jm,l.partial=Ui,l.partialRight=hl,l.partition=E0,l.pick=Yh,l.pickBy=kl,l.property=Al,l.propertyOf=Xm,l.pull=Af,l.pullAll=nl,l.pullAllBy=Ef,l.pullAllWith=Mf,l.pullAt=Tf,l.range=Ym,l.rangeRight=Qm,l.rearg=H0,l.reject=P0,l.remove=Pf,l.rest=K0,l.reverse=Fi,l.sampleSize=O0,l.set=Zh,l.setWith=em,l.shuffle=F0,l.slice=Df,l.sortBy=U0,l.sortedUniq=Wf,l.sortedUniqBy=Gf,l.split=km,l.spread=J0,l.tail=$f,l.take=Vf,l.takeRight=qf,l.takeRightWhile=Hf,l.takeWhile=Kf,l.tap=c0,l.throttle=X0,l.thru=gr,l.toArray=yl,l.toPairs=Sl,l.toPairsIn=Il,l.toPath=sg,l.toPlainObject=_l,l.transform=tm,l.unary=Y0,l.union=Jf,l.unionBy=Xf,l.unionWith=Yf,l.uniq=Qf,l.uniqBy=Zf,l.uniqWith=e0,l.unset=nm,l.unzip=Ri,l.unzipWith=sl,l.update=sm,l.updateWith=rm,l.values=ns,l.valuesIn=im,l.without=t0,l.words=Ll,l.wrap=Q0,l.xor=n0,l.xorBy=s0,l.xorWith=r0,l.zip=i0,l.zipObject=o0,l.zipObjectDeep=a0,l.zipWith=l0,l.entries=Sl,l.entriesIn=Il,l.extend=wl,l.extendWith=vr,Ki(l,l),l.add=ig,l.attempt=Nl,l.camelCase=cm,l.capitalize=Cl,l.ceil=og,l.clamp=om,l.clone=eh,l.cloneDeep=nh,l.cloneDeepWith=sh,l.cloneWith=th,l.conformsTo=rh,l.deburr=jl,l.defaultTo=Rm,l.divide=ag,l.endsWith=dm,l.eq=Qt,l.escape=um,l.escapeRegExp=fm,l.every=b0,l.find=w0,l.findIndex=Qa,l.findKey=Ph,l.findLast=v0,l.findLastIndex=Za,l.findLastKey=Dh,l.floor=lg,l.forEach=il,l.forEachRight=ol,l.forIn=Oh,l.forInRight=Fh,l.forOwn=Rh,l.forOwnRight=zh,l.get=Gi,l.gt=ih,l.gte=oh,l.has=Wh,l.hasIn=$i,l.head=tl,l.identity=Et,l.includes=j0,l.indexOf=vf,l.inRange=am,l.invoke=Vh,l.isArguments=zn,l.isArray=ye,l.isArrayBuffer=ah,l.isArrayLike=Nt,l.isArrayLikeObject=nt,l.isBoolean=lh,l.isBuffer=Cn,l.isDate=ch,l.isElement=dh,l.isEmpty=uh,l.isEqual=fh,l.isEqualWith=hh,l.isError=Bi,l.isFinite=mh,l.isFunction=un,l.isInteger=ml,l.isLength=_r,l.isMap=gl,l.isMatch=gh,l.isMatchWith=ph,l.isNaN=xh,l.isNative=yh,l.isNil=_h,l.isNull=bh,l.isNumber=pl,l.isObject=Xe,l.isObjectLike=et,l.isPlainObject=ks,l.isRegExp=Wi,l.isSafeInteger=wh,l.isSet=xl,l.isString=wr,l.isSymbol=Dt,l.isTypedArray=ts,l.isUndefined=vh,l.isWeakMap=kh,l.isWeakSet=Sh,l.join=jf,l.kebabCase=hm,l.last=Vt,l.lastIndexOf=Lf,l.lowerCase=mm,l.lowerFirst=gm,l.lt=Ih,l.lte=Ch,l.max=cg,l.maxBy=dg,l.mean=ug,l.meanBy=fg,l.min=hg,l.minBy=mg,l.stubArray=Xi,l.stubFalse=Yi,l.stubObject=Zm,l.stubString=eg,l.stubTrue=tg,l.multiply=gg,l.nth=Nf,l.noConflict=Vm,l.noop=Ji,l.now=xr,l.pad=pm,l.padEnd=xm,l.padStart=ym,l.parseInt=bm,l.random=lm,l.reduce=M0,l.reduceRight=T0,l.repeat=_m,l.replace=wm,l.result=Qh,l.round=pg,l.runInContext=w,l.sample=D0,l.size=R0,l.snakeCase=vm,l.some=z0,l.sortedIndex=Of,l.sortedIndexBy=Ff,l.sortedIndexOf=Rf,l.sortedLastIndex=zf,l.sortedLastIndexBy=Uf,l.sortedLastIndexOf=Bf,l.startCase=Sm,l.startsWith=Im,l.subtract=xg,l.sum=yg,l.sumBy=bg,l.template=Cm,l.times=ng,l.toFinite=fn,l.toInteger=be,l.toLength=bl,l.toLower=jm,l.toNumber=qt,l.toSafeInteger=jh,l.toString=Fe,l.toUpper=Lm,l.trim=Nm,l.trimEnd=Am,l.trimStart=Em,l.truncate=Mm,l.unescape=Tm,l.uniqueId=rg,l.upperCase=Pm,l.upperFirst=Vi,l.each=il,l.eachRight=ol,l.first=tl,Ki(l,function(){var e={};return en(l,function(t,n){Ue.call(l.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),l.VERSION=d,Ut(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){l[e].placeholder=l}),Ut(["drop","take"],function(e,t){Ee.prototype[e]=function(n){n=n===r?1:ot(be(n),0);var i=this.__filtered__&&!t?new Ee(this):this.clone();return i.__filtered__?i.__takeCount__=pt(n,i.__takeCount__):i.__views__.push({size:pt(n,re),type:e+(i.__dir__<0?"Right":"")}),i},Ee.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ut(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==he||n==de;Ee.prototype[e]=function(a){var f=this.clone();return f.__iteratees__.push({iteratee:oe(a,3),type:n}),f.__filtered__=f.__filtered__||i,f}}),Ut(["head","last"],function(e,t){var n="take"+(t?"Right":"");Ee.prototype[e]=function(){return this[n](1).value()[0]}}),Ut(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");Ee.prototype[e]=function(){return this.__filtered__?new Ee(this):this[n](1)}}),Ee.prototype.compact=function(){return this.filter(Et)},Ee.prototype.find=function(e){return this.filter(e).head()},Ee.prototype.findLast=function(e){return this.reverse().find(e)},Ee.prototype.invokeMap=Se(function(e,t){return typeof e=="function"?new Ee(this):this.map(function(n){return xs(n,e,t)})}),Ee.prototype.reject=function(e){return this.filter(br(oe(e)))},Ee.prototype.slice=function(e,t){e=be(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Ee(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=be(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},Ee.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ee.prototype.toArray=function(){return this.take(re)},en(Ee.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=l[i?"take"+(t=="last"?"Right":""):t],f=i||/^find/.test(t);a&&(l.prototype[t]=function(){var x=this.__wrapped__,y=i?[1]:arguments,k=x instanceof Ee,E=y[0],M=k||ye(x),D=function(Le){var Te=a.apply(l,bn([Le],y));return i&&G?Te[0]:Te};M&&n&&typeof E=="function"&&E.length!=1&&(k=M=!1);var G=this.__chain__,ee=!!this.__actions__.length,le=f&&!G,ve=k&&!ee;if(!f&&M){x=ve?x:new Ee(this);var ce=e.apply(x,y);return ce.__actions__.push({func:gr,args:[D],thisArg:r}),new Wt(ce,G)}return le&&ve?e.apply(this,y):(ce=this.thru(D),le?i?ce.value()[0]:ce.value():ce)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(e){var t=Bs[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);l.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var f=this.value();return t.apply(ye(f)?f:[],a)}return this[n](function(x){return t.apply(ye(x)?x:[],a)})}}),en(Ee.prototype,function(e,t){var n=l[t];if(n){var i=n.name+"";Ue.call(Xn,i)||(Xn[i]=[]),Xn[i].push({name:t,func:n})}}),Xn[lr(r,z).name]=[{name:"wrapper",func:r}],Ee.prototype.clone=Md,Ee.prototype.reverse=Td,Ee.prototype.value=Pd,l.prototype.at=d0,l.prototype.chain=u0,l.prototype.commit=f0,l.prototype.next=h0,l.prototype.plant=g0,l.prototype.reverse=p0,l.prototype.toJSON=l.prototype.valueOf=l.prototype.value=x0,l.prototype.first=l.prototype.head,ds&&(l.prototype[ds]=m0),l},Hn=ud();En?((En.exports=Hn)._=Hn,Hr._=Hn):ut._=Hn}).call(Ss)})(Cr,Cr.exports);var Un=Cr.exports;const Vg=(o,u=!1)=>{const r=b.useRef(o),d=b.useRef(null),[c,h]=b.useState(0),m=()=>{d.current||(h(r.current),d.current=setInterval(()=>{h(_=>_<=1?(g(),0):_-1)},1e3))},g=()=>{d.current&&(clearInterval(d.current),d.current=null)};return b.useEffect(()=>(r.current=o,u&&m(),g),[o,u]),{countDown:c,start:m,stop:g}},qg=()=>s.jsx("span",{children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.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"})]})}),Hg=[{type:"chat",tool:"workflow_generate",name:"给我一个工作流，基于ltx创建一个短视频",messages:[{id:"showcase1-3",role:"user",content:"给我一个工作流，基于ltx创建一个短视频",trace_id:"showcase1"},{id:"showcase1-4",role:"ai",content:`{"session_id":"611f8fda-e441-4e87-9fe3-59f51c29e910","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Workflow Recommendations for Creating Short Video Clips from LTX\\n\\nHere are some workflow options to help you create short video clips based on \\"ltx\\":\\n\\n#### 1. Recalled Workflows\\n\\nBased on your request, I found these existing workflows that might be helpful:\\n\\n*   **api-t2i2v-txt\\\\_to\\\\_image\\\\_to\\\\_video**\\n    *   **Description:** Creates a short animated video clip from a text description of a nature scene.\\n    *   **Use Case:** Ideal if your \\"ltx\\" content can be translated into a text description of a scene you want to animate.\\n    *   **Image:** ![api-t2i2v-txt\\\\_to\\\\_image\\\\_to\\\\_video](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F648f8d5e2e924162852e98f2a249e3b0.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264036&Signature=ZcP5qLm%2B4W23KXaNhJlQnPJljDw%3D)\\n\\n*   **sdxl-t2i2v-api**\\n    *   **Description:** Creates a short animated video clip based on your text description.\\n    *   **Use Case:** Similar to the above, this workflow is good for generating smooth, high-quality animations from text prompts.\\n    *   **Image:** ![sdxl-t2i2v-api](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fbb9685f63da3498f8e743172a8083f9d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264381&Signature=BiWhDeYVswBNpH23UtP9WqDNUEk%3D)\\n\\n*   **api-t2v\\\\_ltxv\\\\_text\\\\_to\\\\_video**\\n    *   **Description:** Creates a short animated video clip (about 4 seconds) from text, with a focus on natural and fluid movement. This workflow specifically mentions \\"ltxv\\".\\n    *   **Use Case:** This workflow seems highly relevant as it explicitly includes \\"ltxv\\" in its description, suggesting it might be directly applicable to your \\"ltx\\" content.\\n    *   **Image:** ![api-t2v\\\\_ltxv\\\\_text\\\\_to\\\\_video](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F2f5343c2b19c4afba48b8f9079ed736d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264124&Signature=w1X1XSG3Pxay02KBI3twT%2B3xEpQ%3D)\\n\\n#### 2. AI Generated Workflow\\n\\nI have also generated a new personalized workflow solution for you:\\n\\n*   **AI Generated Workflow**\\n    *   **Description:** Build a workflow that creates a short video clip based on 'ltx' content.\\n    *   **Use Case:** This is a custom-generated workflow tailored to your specific request.\\n    *   **Image:** ![AI Generated Workflow](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\nPlease let me know if you have any questions about these workflows or would like further adjustments!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31809,"name":"AI Generated Workflow","description":"Build a workflow that creates a short video clip based on 'ltx' content.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"4d7e074f326a544bfcba0daf615ae220","score":null,"source":"AI Generated"},{"id":26740,"name":"api-t2i2v-txt_to_image_to_video","description":"Create a short animated video clip from a text description of a nature scene. I want to describe a beautiful landscape and have it turned into a flowing video with natural movement, like clouds drifting or water flowing, without needing to provide any reference video or images.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F648f8d5e2e924162852e98f2a249e3b0.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264036&Signature=ZcP5qLm%2B4W23KXaNhJlQnPJljDw%3D","unique_id":"554fd2c996083c5b9525051d49a6b2f5","score":[0.5690833843847055,0.5]},{"id":26745,"name":"sdxl-t2i2v-api","description":"Create a short animated video clip based on my text description. I want to be able to type in what I want to see (like \\"a cute dog running on the beach\\"), and get back a smooth, high-quality animation that brings my description to life. The video should be a few seconds long and loop seamlessly.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fbb9685f63da3498f8e743172a8083f9d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264381&Signature=BiWhDeYVswBNpH23UtP9WqDNUEk%3D","unique_id":"ef568bd54974e83122c8ac59ba02c8c2","score":[0.616972625255589,0.5]},{"id":26831,"name":"api-t2v_ltxv_text_to_video","description":"Create a short animated video clip (about 4 seconds) showing two women having a conversation, where one has brown hair wearing a black jacket and the other has blonde hair. Make sure the video looks natural and fluid, focusing on the brown-haired woman's face with warm sunset lighting.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F2f5343c2b19c4afba48b8f9079ed736d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264124&Signature=w1X1XSG3Pxay02KBI3twT%2B3xEpQ%3D","unique_id":"6fc80d5671a79696ddff0db0bd39ee02","score":[0.589295913064967,1]}]}],"message_id":"3cd1418e-e57c-4c01-9005-93365b0acc70"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_generate",name:"给我一个工作流，把图片变成动漫风格",messages:[{id:"showcase1-5",role:"user",content:"给我一个工作流，把图片变成动漫风格",trace_id:"showcase1"},{id:"showcase1-6",role:"ai",content:`{"session_id":"fd931296-4337-4f1a-bd23-27b3a17caf07","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Image to Anime Style Workflows\\n\\nHere are some workflow options to transform your images into an anime style:\\n\\n#### Recalled Workflows\\n\\n1.  **api-i2i_image2image**\\n    *   **Description:** This workflow is designed to modify portrait photos to add anime-style features like furry ears while preserving most of the original facial features. It aims for a clean final image without watermarks or text overlays.\\n    *   **Image:** ![api-i2i_image2image](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Ff3a37b904b6d4ad4ae7db5039c8fffe9.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263152&Signature=DsEDthKG%2BEHXHWO3S0dSD7rRURY%3D)\\n\\n2.  **api-i2i_flux_canny_model_example**\\n    *   **Description:** This workflow focuses on transforming portrait photos into anime-style characters while maintaining the basic pose and composition of the original photo. It can incorporate specific anime features such as fennec ears, a fluffy tail, blonde hair, and blue eyes, with characters wearing casual clothes. The goal is a high-quality anime illustration.\\n    *   **Image:** ![api-i2i_flux_canny_model_example](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fa36288a992704596b74556539fefbd25.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263038&Signature=oTHt155s64%2FHAzETosaTYesTUc%3D)\\n\\n3.  **api-i2v_image_to_video_wan**\\n    *   **Description:** While primarily for animation, this workflow involves an initial image of an anime character and can be used to create movement from a still anime image. This might be relevant if you later want to animate the anime-styled output.\\n    *   **Image:** ![api-i2v_image_to_video_wan](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fbb12a2decb0c4f55a66caefa98eaf1d8.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263536&Signature=c9MxE0hqAMEb4%2FNGG7UnwRylz6Y%3D)\\n\\n#### AI Generated Workflow\\n\\n*   **Name:** AI Generated Workflow\\n*   **Description:** This custom workflow is designed to transform an input image into an anime art style, effectively preserving key features from the original image while applying characteristic anime aesthetics.\\n*   **Image:** ![AI Generated Workflow](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\nYou can choose one of the recommended workflows above, or explore the AI-generated solution. If you have any further questions about these workflows, feel free to ask!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31813,"name":"AI Generated Workflow","description":"Build a workflow that transforms an input image into an anime art style, preserving key features while applying anime aesthetics.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"578e2c1ebc888b09319bfc7310dd3b02","score":null,"source":"AI Generated"},{"id":26711,"name":"api-i2i_image2image","description":"I want to modify my portrait photo to add anime-style features like furry ears while keeping most of my original facial features intact. The final image should look clean without any watermarks or text overlays.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Ff3a37b904b6d4ad4ae7db5039c8fffe9.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263152&Signature=DsEDthKG%2BEHXHWO3S0dSD7rRURY%3D","unique_id":"7326dc2eb7014aea9bb8853293f1261b","score":[0.5843760618939373,0.5]},{"id":26819,"name":"api-i2i_flux_canny_model_example","description":"I want to transform my portrait photos into anime-style characters while keeping the basic pose and composition of the original photo. The anime character should have specific features like fennec ears and a fluffy tail, with blonde hair and blue eyes, wearing casual clothes. The final result should look like a high-quality anime illustration.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fa36288a992704596b74556539fefbd25.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263038&Signature=oTHt155s64%2FLHAzETosaTYesTUc%3D","unique_id":"8e456b0c483b5eb64b4aac78bd5cd4be","score":[0.6201659297745311,0.5]},{"id":26822,"name":"api-i2v_image_to_video_wan","description":"I have a still image of an anime character and I want to create a short animation where the character smoothly turns around. The animation should maintain the character's original style and details while adding natural movement. Can you create a workflow that can do this automatically?","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2Fbb12a2decb0c4f55a66caefa98eaf1d8.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066263536&Signature=c9MxE0hqAMEb4%2FNGG7UnwRylz6Y%3D","unique_id":"0ed3d66aea19873488df2b6821dcf7f0","score":[0.632876618757651,0.5]}]}],"message_id":"8895ed9c-f188-4bdb-9646-13b0ec909aa2"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_generate",name:"给我一个编辑图片的工作流",messages:[{id:"showcase1-7",role:"user",content:"给我一个编辑图片的工作流",trace_id:"showcase1"},{id:"showcase1-8",role:"ai",content:`{"session_id":"bb570efe-14c4-4bde-b595-593026375d5f","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Image Editing Workflows\\n\\nHere are some workflow options for image editing, including both recalled and newly generated solutions:\\n\\n#### **Recalled Workflows**\\n\\nBased on your request, I've found a few relevant workflows that handle various image editing tasks:\\n\\n1.  **image-edit-api (1)**\\n    *   **Description:** This workflow allows you to modify photos using text descriptions. For example, you can change hair color or add specific features while preserving the natural look and original composition of the image. It takes your photo and a text description of the desired changes as input.\\n\\n2.  **image-edit-api**\\n    *   **Description:** This workflow is designed for modifying photos of people. You can add specific objects or change expressions while maintaining the person's identity and overall appearance. For instance, you could make someone smile more or add a coffee cup they're holding, with the changes blending in seamlessly.\\n\\n3.  **i2i-editing**\\n    *   **Description:** If you have a landscape image and want to extend its canvas size in any direction, this workflow can help. It maintains the original artistic style and atmosphere, ensuring the new areas blend seamlessly with the existing image.\\n\\n#### **AI Generated Workflow**\\n\\nI've also generated a new, personalized workflow solution for general image editing:\\n\\n1.  **AI Generated Workflow**\\n    *   **Description:** This workflow is designed to perform general image editing operations, including resizing, cropping, and color correction. It provides a versatile solution for common image manipulation needs.\\n\\nYou can choose one of the recommended workflows above, or let AI generate a personalized solution based on your input. If you have any specific questions about any of these workflows, feel free to ask!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31815,"name":"AI Generated Workflow","description":"Build a workflow that allows for general image editing, including operations like resizing, cropping, and color correction.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"6f7faac37e32285a935b8699ecc70c15","score":null,"source":"AI Generated"},{"id":26728,"name":"image-edit-api (1)","description":"I want to modify my photos by describing the changes I want in plain text. For example, I want to be able to change hair color or add specific features while keeping the rest of the image looking natural and maintaining the original composition. The workflow should take my photo and a text description of the desired changes as input, and produce a modified version of my photo that incorporates these changes.","image":"","unique_id":"7c9029b78952b52475f5a77d3b5dd781","score":[0.6382076740264893,0]},{"id":26733,"name":"image-edit-api","description":"I have a photo of a person, and I'd like to modify it to add specific objects or change their expression while keeping their identity and overall appearance intact. For example, I want to make them smile more and add objects they're holding, like a coffee cup. The changes should look natural and seamless.","image":"","unique_id":"4080a7a9b33783892cf3cf4fed1755de","score":[0.5695966821668564,0]},{"id":26776,"name":"i2i-editing","description":"I have a beautiful landscape image and I want to extend its canvas size in all directions while maintaining the same artistic style and atmosphere. The new areas should blend seamlessly with the original image and follow the same artistic pattern. Can you create a workflow that achieves this?","image":"","unique_id":"2e7970867f24319161de9a09504350d3","score":[0.5364670477191844,0.25]}]}],"message_id":"225cc1d8-10d9-44ae-bccd-007d4f3e88b2"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_rewrite",name:"修改当前工作流，检测并裁剪出图片中的猫",messages:[{id:"showcase1-9",role:"user",content:"修改当前工作流，检测并裁剪出图片中的猫",trace_id:"showcase1"},{id:"showcase1-10",role:"ai",content:`{"session_id":"62d2eed7-a9c2-4b34-b596-4a73b9ce6dad","text":"\\n▸ **Switching to Workflow Rewrite Agent**\\n\\nI'll help you rewrite the current workflow to add cat detection and cutout functionality. Let me first get the current workflow and then add the appropriate nodes for intelligent background removal.Now let me get the intelligent background removal experience to add cat detection and cutout functionality:Perfect! I'll rewrite your workflow to add intelligent cat detection and cutout functionality. I'll use the SAM (Segment Anything Model) with GroundingDINO for precise cat detection and segmentation.Perfect! I've successfully rewritten your workflow to add intelligent cat detection and cutout functionality. Here's what I've added:\\n\\n## New Features Added:\\n\\n### **Cat Detection & Segmentation System:**\\n1. **SAM Model Loader (Node 29)** - Loads the Segment Anything Model for precise segmentation\\n2. **GroundingDINO Model Loader (Node 30)** - Loads the object detection model for finding cats\\n3. **Cat Detection & Segmentation (Node 31)** - The main node that:\\n   - Detects cats in your generated image using the prompt \\"cat\\"\\n   - Uses a threshold of 0.3 for detection sensitivity\\n   - Automatically segments and cuts out the detected cat with precise boundaries\\n\\n### **Enhanced Output Options:**\\n1. **Save Original Image (Node 20)** - Saves your original generated image with prefix \\"ComfyUI_original\\"\\n2. **Save Cat Cutout (Node 32)** - Saves the extracted cat as a separate image with prefix \\"ComfyUI_cat_cutout\\"\\n3. **Preview Cat Cutout (Node 33)** - Shows a preview of the extracted cat in the interface\\n\\n## How It Works:\\n1. Your original workflow generates the cat image as before\\n2. The generated image is fed into the GroundingDINO + SAM pipeline\\n3. GroundingDINO detects the cat using natural language (\\"cat\\" prompt)\\n4. SAM performs precise segmentation to cut out the cat with clean edges\\n5. You get both the original image and the extracted cat as separate outputs\\n\\n## Model Requirements:\\n- **SAM Model**: \\"sam_vit_h (2.56GB)\\" - High-quality segmentation model\\n- **GroundingDINO**: \\"GroundingDINO_SwinT_OGC (694MB)\\" - Object detection model\\n\\nThe workflow will now automatically detect and cut out any cats in your generated images with high precision, giving you clean cutouts suitable for further use or editing!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow_update","data":{"workflow_data":{"2":{"inputs":{"noise":["5",0],"guider":["7",0],"sampler":["4",0],"sigmas":["3",0],"latent_image":["10",0]},"class_type":"SamplerCustomAdvanced","_meta":{"title":"SamplerCustomAdvanced"}},"3":{"inputs":{"scheduler":"simple","steps":20,"denoise":1,"model":["8",0]},"class_type":"BasicScheduler","_meta":{"title":"BasicScheduler"}},"4":{"inputs":{"sampler_name":"euler"},"class_type":"KSamplerSelect","_meta":{"title":"KSamplerSelect"}},"5":{"inputs":{"noise_seed":571457442342604},"class_type":"RandomNoise","_meta":{"title":"RandomNoise"}},"6":{"inputs":{"clip_name1":"t5xxl_fp8_e4m3fn.safetensors","clip_name2":"clip_l.safetensors","type":"flux","device":"default"},"class_type":"DualCLIPLoader","_meta":{"title":"DualCLIPLoader"}},"7":{"inputs":{"model":["8",0],"conditioning":["11",0]},"class_type":"BasicGuider","_meta":{"title":"BasicGuider"}},"8":{"inputs":{"unet_name":"flux1-krea-dev.safetensors","weight_dtype":"fp8_e4m3fn"},"class_type":"UNETLoader","_meta":{"title":"Load Diffusion Model"}},"9":{"inputs":{"vae_name":"ae.safetensors"},"class_type":"VAELoader","_meta":{"title":"Load VAE"}},"10":{"inputs":{"width":["27",0],"height":["28",0],"batch_size":1},"class_type":"EmptyLatentImage","_meta":{"title":"Empty Latent Image"}},"11":{"inputs":{"text":["25",0],"clip":["6",0]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"14":{"inputs":{"samples":["2",0],"vae":["9",0]},"class_type":"VAEDecode","_meta":{"title":"VAE Decode"}},"20":{"inputs":{"filename_prefix":"ComfyUI_original","images":["14",0]},"class_type":"SaveImage","_meta":{"title":"Save Original Image"}},"25":{"inputs":{"text":"a cat,simple background"},"class_type":"Text _O","_meta":{"title":"Text _O"}},"27":{"inputs":{"value":1024},"class_type":"easy int","_meta":{"title":"Int"}},"28":{"inputs":{"value":1400},"class_type":"easy int","_meta":{"title":"Int"}},"29":{"inputs":{"model_name":"sam_vit_h (2.56GB)"},"class_type":"SAMModelLoader (segment anything)","_meta":{"title":"SAM Model Loader"}},"30":{"inputs":{"model_name":"GroundingDINO_SwinT_OGC (694MB)"},"class_type":"GroundingDinoModelLoader (segment anything)","_meta":{"title":"GroundingDINO Model Loader"}},"31":{"inputs":{"prompt":"cat","threshold":0.3,"sam_model":["29",0],"grounding_dino_model":["30",0],"image":["14",0]},"class_type":"GroundingDinoSAMSegment (segment anything)","_meta":{"title":"Cat Detection & Segmentation"}},"32":{"inputs":{"filename_prefix":"ComfyUI_cat_cutout","images":["31",0]},"class_type":"SaveImage","_meta":{"title":"Save Cat Cutout"}},"33":{"inputs":{"images":["31",0]},"class_type":"PreviewImage","_meta":{"title":"Preview Cat Cutout"}}}}},{"type":"workflow_rewrite_checkpoint","data":{"checkpoint_id":21,"checkpoint_type":"workflow_rewrite_start"}}],"message_id":"b0ddb085-c47b-496a-9f63-ecb5f7afafe1"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_debug",name:"调试当前工作流",messages:[{id:"showcase1-11",role:"ai",content:'{"text":"Would you like me to help you debug the current workflow on the canvas?","ext":[{"type":"debug_start_checkpoint","data":{"checkpoint_id":2168,"checkpoint_type":"debug_start"}}]}',format:"debug_guide",name:"Assistant"},{id:"showcase1-12",role:"ai",content:'{"text":"▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nI\'ll validate and debug your ComfyUI workflow. Let me start by checking the current state of the workflow to identify any errors.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"21\\": {\\"errors\\": [{\\"type\\": \\"re...\\n```\\n\\nI found an error in the workflow! There\'s a connection issue where node 21 (VAEDecode) is missing its required \\"samples\\" input. Let me analyze this error type to determine the best approach for fixing it.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using analyze_error_type...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"error_type\\": \\"connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 4 connection-related issues\\", \\"details\\": \\"Connection or ...\\n```\\n\\nThis is a connection error where the VAEDecode node is missing its required \\"samples\\" input connection. I\'ll hand this off to the Link Agent to fix the missing connection.\\n\\n▸ **Switching to Link Agent**\\n\\nPerfect! Now I\'m the Link Agent and will analyze and fix the connection issues in your workflow. Let me start by performing a comprehensive connection analysis.\\n\\n⚙ *Link Agent is using analyze_missing_connections...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"missing_connections\\": [{\\"node_id\\": \\"7\\", \\"node_class\\": \\"KSampler\\", \\"input_name\\": \\"latent_image\\", \\"input_config\\": [\\"LATENT\\", {\\"tooltip\\": \\"The latent image to denoise.\\"}], \\"required\\": true, \\"expected_t...\\n```\\n\\n**Connection analysis:** Found 5 missing required connections across multiple nodes:\\n- Node 7 (KSampler): missing latent_image input \\n- Node 21 (VAEDecode): missing samples input\\n- Node 28 (ReduxAdvanced): missing conditioning, style_model, and image inputs\\n\\nAll missing connections can be resolved using existing nodes with high confidence matches available.\\n\\n**Chosen strategy:** Connect existing nodes - all required inputs have perfect type-compatible outputs available from existing nodes. This is a pure connection fix scenario with no new nodes needed.\\n\\nLet me apply the connection fixes using the optimal connection strategy:\\n\\n⚙ *Link Agent is using apply_connection_fixes...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"version_id\\": 2171, \\"applied_fixes\\": [{\\"type\\": \\"connection\\", \\"target\\": \\"7.latent_image\\", \\"source\\": \\"75[0]\\", \\"old_value\\": \\"not connected\\", \\"new_value\\": [\\"75\\", 0]}, {\\"type\\": \\"connectio...\\n```\\n\\n**Fixes applied:** Successfully connected all 5 missing required inputs:\\n- ✅ Connected EmptyLatentImage → KSampler (latent_image)\\n- ✅ Connected KSampler → VAEDecode (samples) \\n- ✅ Connected CLIPTextEncode → ReduxAdvanced (conditioning)\\n- ✅ Connected StyleModelLoader → ReduxAdvanced (style_model)\\n- ✅ Connected LoadImage → ReduxAdvanced (image)\\n\\nAll connections were established with high confidence type matches. The workflow now has a complete data flow from input nodes through processing to final output.\\n\\n▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nExcellent! The Link Agent has successfully fixed all the missing connections. Now let me validate the workflow again to confirm all issues have been resolved.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"3\\": {\\"errors\\": [{\\"type\\": \\"val...\\n```\\n\\nGreat progress! The connection issues have been resolved, but now there\'s a parameter error. Node 3 (LoraLoader) has an invalid LoRA name that\'s not in the available list. Let me analyze this error type.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using analyze_error_type...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"error_type\\": \\"mixed_connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 3 connection-related issues\\", \\"details\\": \\"Connecti...\\n```\\n\\nThis is actually a parameter error (value_not_in_list), not a connection error. The analysis might be mixed up. Let me hand this off to the Parameter Agent to fix the invalid LoRA name.\\n\\n▸ **Switching to Parameter Agent**\\n\\nIssue identified: enum_value_mismatch - LoRA file \'flux/Flux_Ghibli_v2_25.safetensors\' not found in available LoRA list.\\n\\nLet me analyze this parameter error to find a suitable replacement:\\n\\n⚙ *Parameter Agent is using find_matching_parameter_value...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"found_match\\": false, \\"error_type\\": \\"model_missing\\", \\"message\\": \\"Missing model file: flux/Flux_Ghibli_v2_25.safetensors\\", \\"recommendation\\": \\"Check for available model replacements, otherwise download...\\n```\\n\\nGreat! I can see the available LoRA list and found several Ghibli-style LoRAs. The requested \\"flux/Flux_Ghibli_v2_25.safetensors\\" is not available, but there are several similar Ghibli LoRAs in the FLUX folder. \\n\\nLooking at the available options, the closest matches are:\\n- \\"FLUX/Flux_Ghibli_people_v3_23.safetensors\\"\\n- \\"FLUX/Flux_Ghibli_v1_10.safetensors\\", \\"FLUX/Flux_Ghibli_v1_15.safetensors\\", \\"FLUX/Flux_Ghibli_v1_20.safetensors\\"\\n- \\"FLUX/Flux_Ghibli_v2_30.safetensors\\"\\n\\nThe \\"FLUX/Flux_Ghibli_v2_30.safetensors\\" seems like the best match since it\'s from the same v2 series and has a higher version number (30 vs 25).\\n\\n**Solution:** auto-fixed - Replacing with the most similar available Ghibli v2 version LoRA.\\n\\n⚙ *Parameter Agent is using update_workflow_parameter...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"answer\\": \\"Successfully updated lora_name from \'flux/Flux_Ghibli_v2_25.safetensors\' to \'FLUX/Flux_Ghibli_v2_30.safetensors\' in node 3\\", \\"node_id\\": \\"3\\", \\"parameter\\": \\"lora_name\\", \\"old...\\n```\\n\\n**Status:** Fixed - Successfully updated the LoRA from unavailable \'flux/Flux_Ghibli_v2_25.safetensors\' to the available \'FLUX/Flux_Ghibli_v2_30.safetensors\' which is a very similar Ghibli v2 style LoRA.\\n\\n▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nExcellent! The Parameter Agent has fixed the invalid LoRA name. Now let me validate the workflow again to check if all issues have been resolved.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"prompt_id\\": \\"a028058b-4aab-4f9b-9d0d-48c12ace616b\\", \\"number\\": 3, \\"node_errors\\": {}}\\n```\\n\\n🎉 **Workflow Validation Complete - SUCCESS!**\\n\\nYour ComfyUI workflow has been successfully debugged and is now fully functional! Here\'s a summary of the issues that were fixed:\\n\\n## Issues Fixed:\\n\\n1. **Connection Issues (5 fixes via Link Agent):**\\n   - ✅ Connected EmptyLatentImage (75) → KSampler (7) latent_image input\\n   - ✅ Connected KSampler (7) → VAEDecode (21) samples input  \\n   - ✅ Connected CLIPTextEncode (8) → ReduxAdvanced (28) conditioning input\\n   - ✅ Connected StyleModelLoader (29) → ReduxAdvanced (28) style_model input\\n   - ✅ Connected LoadImage (6) → ReduxAdvanced (28) image input\\n\\n2. **Parameter Issue (1 fix via Parameter Agent):**\\n   - ✅ Updated invalid LoRA: `flux/Flux_Ghibli_v2_25.safetensors` → `FLUX/Flux_Ghibli_v2_30.safetensors`\\n\\n## Current Workflow Status:\\n- **Validation:** ✅ PASSED\\n- **Prompt ID:** a028058b-4aab-4f9b-9d0d-48c12ace616b\\n- **Node Errors:** None\\n- **Ready to Execute:** Yes\\n\\nYour workflow now has a complete data flow from input nodes through processing to final output, with all required connections established and valid parameters configured. The workflow is ready for execution!","ext":[{"type":"param_update","data":{"workflow_data":{"1":{"inputs":{"unet_name":"flux1-dev.safetensors","weight_dtype":"default"},"class_type":"UNETLoader","_meta":{"title":"Load Diffusion Model"}},"2":{"inputs":{"clip_name1":"clip_l.safetensors","clip_name2":"t5xxl_fp16.safetensors","type":"flux","device":"default"},"class_type":"DualCLIPLoader","_meta":{"title":"DualCLIPLoader"}},"3":{"inputs":{"lora_name":"FLUX/Flux_Ghibli_v2_30.safetensors","strength_model":0.8,"strength_clip":1,"model":["1",0],"clip":["2",0]},"class_type":"LoraLoader","_meta":{"title":"Load LoRA"}},"6":{"inputs":{"image":"狗-德国短毛指示犬-4.jpeg"},"class_type":"LoadImage","_meta":{"title":"Load Image"}},"7":{"inputs":{"seed":720601145747867,"steps":20,"cfg":1,"sampler_name":"euler","scheduler":"normal","denoise":1,"model":["3",0],"positive":["28",0],"negative":["9",0],"latent_image":["75",0]},"class_type":"KSampler","_meta":{"title":"KSampler"}},"8":{"inputs":{"text":"Ghibli style,illustration,graphic,2d,Rich colors","clip":["3",1]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"9":{"inputs":{"text":"","clip":["3",1]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"20":{"inputs":{"vae_name":"ae.safetensors"},"class_type":"VAELoader","_meta":{"title":"Load VAE"}},"21":{"inputs":{"vae":["20",0],"samples":["7",0]},"class_type":"VAEDecode","_meta":{"title":"VAE Decode"}},"28":{"inputs":{"downsampling_factor":1,"downsampling_function":"area","mode":"keep aspect ratio","weight":0.6,"autocrop_margin":0.1,"clip_vision":["30",0],"conditioning":["8",0],"style_model":["29",0],"image":["6",0]},"class_type":"ReduxAdvanced","_meta":{"title":"ReduxAdvanced"}},"29":{"inputs":{"style_model_name":"flux1-redux-dev.safetensors"},"class_type":"StyleModelLoader","_meta":{"title":"Load Style Model"}},"30":{"inputs":{"clip_name":"sigclip_vision_patch14_384.safetensors"},"class_type":"CLIPVisionLoader","_meta":{"title":"Load CLIP Vision"}},"75":{"inputs":{"width":768,"height":1344,"batch_size":1},"class_type":"EmptyLatentImage","_meta":{"title":"Empty Latent Image"}},"78":{"inputs":{"images":["21",0]},"class_type":"PreviewImage","_meta":{"title":"Preview Image"}}},"changes":[{"node_id":"3","parameter":"lora_name","old_value":"flux/Flux_Ghibli_v2_25.safetensors","new_value":"FLUX/Flux_Ghibli_v2_30.safetensors"}]}},{"type":"debug_complete","data":{"status":"completed","final_agent":"ComfyUI-Debug-Coordinator","events":[{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":46},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":233},{"type":"tool_result","output_preview":"{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"21\\": {\\"errors\\": [{\\"type\\": \\"re...","agent":"ComfyUI-Debug-Coordinator","timestamp":478},{"type":"tool_call","tool":"analyze_error_type","agent":"ComfyUI-Debug-Coordinator","timestamp":746},{"type":"tool_result","output_preview":"{\\"error_type\\": \\"connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 4 connection-related issues\\", \\"details\\": \\"Connection or ...","agent":"ComfyUI-Debug-Coordinator","timestamp":991},{"type":"agent_handoff","current_agent":"Link Agent","to_agent":"Link Agent","timestamp":1195},{"type":"tool_call","tool":"analyze_missing_connections","agent":"Link Agent","timestamp":1413},{"type":"tool_result","output_preview":"{\\"missing_connections\\": [{\\"node_id\\": \\"7\\", \\"node_class\\": \\"KSampler\\", \\"input_name\\": \\"latent_image\\", \\"input_config\\": [\\"LATENT\\", {\\"tooltip\\": \\"The latent image to denoise.\\"}], \\"required\\": true, \\"expected_t...","agent":"Link Agent","timestamp":1658},{"type":"tool_call","tool":"apply_connection_fixes","agent":"Link Agent","timestamp":2344},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"version_id\\": 2171, \\"applied_fixes\\": [{\\"type\\": \\"connection\\", \\"target\\": \\"7.latent_image\\", \\"source\\": \\"75[0]\\", \\"old_value\\": \\"not connected\\", \\"new_value\\": [\\"75\\", 0]}, {\\"type\\": \\"connectio...","agent":"Link Agent","timestamp":2589},{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":3145},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":3361},{"type":"tool_result","output_preview":"{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"3\\": {\\"errors\\": [{\\"type\\": \\"val...","agent":"ComfyUI-Debug-Coordinator","timestamp":3606},{"type":"tool_call","tool":"analyze_error_type","agent":"ComfyUI-Debug-Coordinator","timestamp":3873},{"type":"tool_result","output_preview":"{\\"error_type\\": \\"mixed_connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 3 connection-related issues\\", \\"details\\": \\"Connecti...","agent":"ComfyUI-Debug-Coordinator","timestamp":4118},{"type":"agent_handoff","current_agent":"Parameter Agent","to_agent":"Parameter Agent","timestamp":4341},{"type":"tool_call","tool":"find_matching_parameter_value","agent":"Parameter Agent","timestamp":4595},{"type":"tool_result","output_preview":"{\\"found_match\\": false, \\"error_type\\": \\"model_missing\\", \\"message\\": \\"Missing model file: flux/Flux_Ghibli_v2_25.safetensors\\", \\"recommendation\\": \\"Check for available model replacements, otherwise download...","agent":"Parameter Agent","timestamp":4840},{"type":"tool_call","tool":"update_workflow_parameter","agent":"Parameter Agent","timestamp":5613},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"answer\\": \\"Successfully updated lora_name from \'flux/Flux_Ghibli_v2_25.safetensors\' to \'FLUX/Flux_Ghibli_v2_30.safetensors\' in node 3\\", \\"node_id\\": \\"3\\", \\"parameter\\": \\"lora_name\\", \\"old...","agent":"Parameter Agent","timestamp":5858},{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":6109},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":6312},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"prompt_id\\": \\"a028058b-4aab-4f9b-9d0d-48c12ace616b\\", \\"number\\": 3, \\"node_errors\\": {}}","agent":"ComfyUI-Debug-Coordinator","timestamp":6456}],"total_events":23}},{"type":"debug_checkpoint","data":{"checkpoint_id":2173,"checkpoint_type":"debug_complete"}},{"type":"debug_checkpoint","data":{"checkpoint_id":2174,"checkpoint_type":"debug_complete"}}]}',format:"markdown",name:"Assistant",finished:!0,debugGuide:!0}]},{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"}]}],Fl=[{type:"chat",tool:"workflow_generate",name:"Give me a workflow to create a short video clip based on ltx",messages:[{id:"showcase1-3",role:"user",content:"Give me a workflow to create a short video clip based on ltx",trace_id:"showcase1"},{id:"showcase1-4",role:"ai",content:`{"session_id":"611f8fda-e441-4e87-9fe3-59f51c29e910","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Workflow Recommendations for Creating Short Video Clips from LTX\\n\\nHere are some workflow options to help you create short video clips based on \\"ltx\\":\\n\\n#### 1. Recalled Workflows\\n\\nBased on your request, I found these existing workflows that might be helpful:\\n\\n*   **api-t2i2v-txt\\\\_to\\\\_image\\\\_to\\\\_video**\\n    *   **Description:** Creates a short animated video clip from a text description of a nature scene.\\n    *   **Use Case:** Ideal if your \\"ltx\\" content can be translated into a text description of a scene you want to animate.\\n    *   **Image:** ![api-t2i2v-txt\\\\_to\\\\_image\\\\_to\\\\_video](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F5cdab63527824cfc80749127cb0b15ee.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225390&Signature=T%2B9URvbgI7KPB4%2Ft9CSe3zBLHtA%3D)\\n\\n*   **sdxl-t2i2v-api**\\n    *   **Description:** Creates a short animated video clip based on your text description.\\n    *   **Use Case:** Similar to the above, this workflow is good for generating smooth, high-quality animations from text prompts.\\n    *   **Image:** ![sdxl-t2i2v-api](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Ff1fd0f203429423ca3e334701736b1f5.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225261&Signature=8pSHmG2Yl%2FTpkxy9SVjjVk5M7RA%3D)\\n\\n*   **api-t2v\\\\_ltxv\\\\_text\\\\_to\\\\_video**\\n    *   **Description:** Creates a short animated video clip (about 4 seconds) from text, with a focus on natural and fluid movement. This workflow specifically mentions \\"ltxv\\".\\n    *   **Use Case:** This workflow seems highly relevant as it explicitly includes \\"ltxv\\" in its description, suggesting it might be directly applicable to your \\"ltx\\" content.\\n    *   **Image:** ![api-t2v\\\\_ltxv\\\\_text\\\\_to\\\\_video](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F2f5343c2b19c4afba48b8f9079ed736d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264124&Signature=w1X1XSG3Pxay02KBI3twT%2B3xEpQ%3D)\\n\\n#### 2. AI Generated Workflow\\n\\nI have also generated a new personalized workflow solution for you:\\n\\n*   **AI Generated Workflow**\\n    *   **Description:** Build a workflow that creates a short video clip based on 'ltx' content.\\n    *   **Use Case:** This is a custom-generated workflow tailored to your specific request.\\n    *   **Image:** ![AI Generated Workflow](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\nPlease let me know if you have any questions about these workflows or would like further adjustments!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31809,"name":"AI Generated Workflow","description":"Build a workflow that creates a short video clip based on 'ltx' content.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"4d7e074f326a544bfcba0daf615ae220","score":null,"source":"AI Generated"},{"id":26740,"name":"api-t2i2v-txt_to_image_to_video","description":"Create a short animated video clip from a text description of a nature scene. I want to describe a beautiful landscape and have it turned into a flowing video with natural movement, like clouds drifting or water flowing, without needing to provide any reference video or images.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F5cdab63527824cfc80749127cb0b15ee.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225390&Signature=T%2B9URvbgI7KPB4%2Ft9CSe3zBLHtA%3D","unique_id":"554fd2c996083c5b9525051d49a6b2f5","score":[0.5690833843847055,0.5]},{"id":26745,"name":"sdxl-t2i2v-api","description":"Create a short animated video clip based on my text description. I want to be able to type in what I want to see (like \\"a cute dog running on the beach\\"), and get back a smooth, high-quality animation that brings my description to life. The video should be a few seconds long and loop seamlessly.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Ff1fd0f203429423ca3e334701736b1f5.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225261&Signature=8pSHmG2Yl%2FTpkxy9SVjjVk5M7RA%3D","unique_id":"ef568bd54974e83122c8ac59ba02c8c2","score":[0.616972625255589,0.5]},{"id":26831,"name":"api-t2v_ltxv_text_to_video","description":"Create a short animated video clip (about 4 seconds) showing two women having a conversation, where one has brown hair wearing a black jacket and the other has blonde hair. Make sure the video looks natural and fluid, focusing on the brown-haired woman's face with warm sunset lighting.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-06-26%2F2f5343c2b19c4afba48b8f9079ed736d.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2066264124&Signature=w1X1XSG3Pxay02KBI3twT%2B3xEpQ%3D","unique_id":"6fc80d5671a79696ddff0db0bd39ee02","score":[0.589295913064967,1]}]}],"message_id":"3cd1418e-e57c-4c01-9005-93365b0acc70"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_generate",name:"Give me a workflow that can turn the image into anime style",messages:[{id:"showcase1-5",role:"user",content:"give me a workflow that can turn the image into anime style",trace_id:"showcase1"},{id:"showcase1-6",role:"ai",content:`{"session_id":"fd931296-4337-4f1a-bd23-27b3a17caf07","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Image to Anime Style Workflows\\n\\nHere are some workflow options to transform your images into an anime style:\\n\\n#### Recalled Workflows\\n\\n1.  **api-i2i_image2image**\\n    *   **Description:** This workflow is designed to modify portrait photos to add anime-style features like furry ears while preserving most of the original facial features. It aims for a clean final image without watermarks or text overlays.\\n    *   **Image:** ![api-i2i_image2image](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fcc02e225a2eb4468bbbb588af597b2aa.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069223989&Signature=TjszfM%2FgbSWnsgLzRvaah9B7SQE%3D)\\n\\n2.  **api-i2i_flux_canny_model_example**\\n    *   **Description:** This workflow focuses on transforming portrait photos into anime-style characters while maintaining the basic pose and composition of the original photo. It can incorporate specific anime features such as fennec ears, a fluffy tail, blonde hair, and blue eyes, with characters wearing casual clothes. The goal is a high-quality anime illustration.\\n    *   **Image:** ![api-i2i_flux_canny_model_example](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fb97fb825b2f843f086079dc0b3cf4993.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224074&Signature=5DXU4qpuEcMbimfInVQcsTcwDIU%3D)\\n\\n3.  **api-i2v_image_to_video_wan**\\n    *   **Description:** While primarily for animation, this workflow involves an initial image of an anime character and can be used to create movement from a still anime image. This might be relevant if you later want to animate the anime-styled output.\\n    *   **Image:** ![api-i2v_image_to_video_wan](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fa1369bd4f3304e4f9cf5f7e0cb427733.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225510&Signature=SHsULg0tYRJlw6riGKwrKBJgVAs%3D)\\n\\n#### AI Generated Workflow\\n\\n*   **Name:** AI Generated Workflow\\n*   **Description:** This custom workflow is designed to transform an input image into an anime art style, effectively preserving key features from the original image while applying characteristic anime aesthetics.\\n*   **Image:** ![AI Generated Workflow](https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg)\\n\\nYou can choose one of the recommended workflows above, or explore the AI-generated solution. If you have any further questions about these workflows, feel free to ask!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31813,"name":"AI Generated Workflow","description":"Build a workflow that transforms an input image into an anime art style, preserving key features while applying anime aesthetics.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"578e2c1ebc888b09319bfc7310dd3b02","score":null,"source":"AI Generated"},{"id":26711,"name":"api-i2i_image2image","description":"I want to modify my portrait photo to add anime-style features like furry ears while keeping most of my original facial features intact. The final image should look clean without any watermarks or text overlays.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fcc02e225a2eb4468bbbb588af597b2aa.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069223989&Signature=TjszfM%2FgbSWnsgLzRvaah9B7SQE%3D","unique_id":"7326dc2eb7014aea9bb8853293f1261b","score":[0.5843760618939373,0.5]},{"id":26819,"name":"api-i2i_flux_canny_model_example","description":"I want to transform my portrait photos into anime-style characters while keeping the basic pose and composition of the original photo. The anime character should have specific features like fennec ears and a fluffy tail, with blonde hair and blue eyes, wearing casual clothes. The final result should look like a high-quality anime illustration.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fb97fb825b2f843f086079dc0b3cf4993.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224074&Signature=5DXU4qpuEcMbimfInVQcsTcwDIU%3D","unique_id":"8e456b0c483b5eb64b4aac78bd5cd4be","score":[0.6201659297745311,0.5]},{"id":26822,"name":"api-i2v_image_to_video_wan","description":"I have a still image of an anime character and I want to create a short animation where the character smoothly turns around. The animation should maintain the character's original style and details while adding natural movement. Can you create a workflow that can do this automatically?","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Fa1369bd4f3304e4f9cf5f7e0cb427733.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069225510&Signature=SHsULg0tYRJlw6riGKwrKBJgVAs%3D","unique_id":"0ed3d66aea19873488df2b6821dcf7f0","score":[0.632876618757651,0.5]}]}],"message_id":"8895ed9c-f188-4bdb-9646-13b0ec909aa2"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_generate",name:"Give me a workflow for image editing",messages:[{id:"showcase1-7",role:"user",content:"give me a workflow for image editing",trace_id:"showcase1"},{id:"showcase1-8",role:"ai",content:`{"session_id":"bb570efe-14c4-4bde-b595-593026375d5f","text":"\\n\\n🔄 **Switching to ComfyUI-Copilot**\\n\\n### Image Editing Workflows\\n\\nHere are some workflow options for image editing, including both recalled and newly generated solutions:\\n\\n#### **Recalled Workflows**\\n\\nBased on your request, I've found a few relevant workflows that handle various image editing tasks:\\n\\n1.  **image-edit-api (1)**\\n    *   **Description:** This workflow allows you to modify photos using text descriptions. For example, you can change hair color or add specific features while preserving the natural look and original composition of the image. It takes your photo and a text description of the desired changes as input.\\n*   **Image:** ![image-edit-api1](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F6475427cb093410fbe86ddecead83082.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224145&Signature=ZTw8WXVW3aB7LRStH6RhwqtywsM%3D)   \\n\\n2.  **image-edit-api**\\n    *   **Description:** This workflow is designed for modifying photos of people. You can add specific objects or change expressions while maintaining the person's identity and overall appearance. For instance, you could make someone smile more or add a coffee cup they're holding, with the changes blending in seamlessly. \\n*   **Image:** ![image-edit-api](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F31914a4fe5f448ea8ab4e677f26b536a.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224230&Signature=AqBT3em4CKJE7jZNHXvyrvHZOik%3D) \\n\\n3.  **i2i-editing**\\n    *   **Description:** If you have a landscape image and want to extend its canvas size in any direction, this workflow can help. It maintains the original artistic style and atmosphere, ensuring the new areas blend seamlessly with the existing image.\\n*   **Image:** ![i2i-editing](https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Ff4d1ff5492ef43fdb57d3b3d8976bba1.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224308&Signature=i8uqKJcqBgNGPq3uXS8PD%2BS8UF8%3D)  \\n\\n#### **AI Generated Workflow**\\n\\nI've also generated a new, personalized workflow solution for general image editing:\\n\\n1.  **AI Generated Workflow**\\n    *   **Description:** This workflow is designed to perform general image editing operations, including resizing, cropping, and color correction. It provides a versatile solution for common image manipulation needs.\\n\\nYou can choose one of the recommended workflows above, or let AI generate a personalized solution based on your input. If you have any specific questions about any of these workflows, feel free to ask!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow","data":[{"id":31815,"name":"AI Generated Workflow","description":"Build a workflow that allows for general image editing, including operations like resizing, cropping, and color correction.","image":"https://ppc-img.oss-ap-southeast-1.aliyuncs.com/AI_workflow_default.jpg","unique_id":"6f7faac37e32285a935b8699ecc70c15","score":null,"source":"AI Generated"},{"id":26728,"name":"image-edit-api (1)","description":"I want to modify my photos by describing the changes I want in plain text. For example, I want to be able to change hair color or add specific features while keeping the rest of the image looking natural and maintaining the original composition. The workflow should take my photo and a text description of the desired changes as input, and produce a modified version of my photo that incorporates these changes.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F6475427cb093410fbe86ddecead83082.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224145&Signature=ZTw8WXVW3aB7LRStH6RhwqtywsM%3D","unique_id":"7c9029b78952b52475f5a77d3b5dd781","score":[0.6382076740264893,0]},{"id":26733,"name":"image-edit-api","description":"I have a photo of a person, and I'd like to modify it to add specific objects or change their expression while keeping their identity and overall appearance intact. For example, I want to make them smile more and add objects they're holding, like a coffee cup. The changes should look natural and seamless.","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2F31914a4fe5f448ea8ab4e677f26b536a.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224230&Signature=AqBT3em4CKJE7jZNHXvyrvHZOik%3D","unique_id":"4080a7a9b33783892cf3cf4fed1755de","score":[0.5695966821668564,0]},{"id":26776,"name":"i2i-editing","description":"I have a beautiful landscape image and I want to extend its canvas size in all directions while maintaining the same artistic style and atmosphere. The new areas should blend seamlessly with the original image and follow the same artistic pattern. Can you create a workflow that achieves this?","image":"https://aib-vision-hz.oss-accelerate.aliyuncs.com/mood_board%2Finput%2F2025-07-30%2Ff4d1ff5492ef43fdb57d3b3d8976bba1.png?x-oss-process=style%2Fresize&OSSAccessKeyId=LTAI5tQyhnsJhtiinV3B1gfV&Expires=2069224308&Signature=i8uqKJcqBgNGPq3uXS8PD%2BS8UF8%3D","unique_id":"2e7970867f24319161de9a09504350d3","score":[0.5364670477191844,0.25]}]}],"message_id":"225cc1d8-10d9-44ae-bccd-007d4f3e88b2"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_rewrite",name:"rewrite current workflow, cut out the cat in my output image",messages:[{id:"showcase1-9",role:"user",content:"rewrite the workflow of the current canvas to detect and cut out the cat in my output image",trace_id:"showcase1"},{id:"showcase1-10",role:"ai",content:`{"session_id":"62d2eed7-a9c2-4b34-b596-4a73b9ce6dad","text":"\\n▸ **Switching to Workflow Rewrite Agent**\\n\\nI'll help you rewrite the current workflow to add cat detection and cutout functionality. Let me first get the current workflow and then add the appropriate nodes for intelligent background removal.Now let me get the intelligent background removal experience to add cat detection and cutout functionality:Perfect! I'll rewrite your workflow to add intelligent cat detection and cutout functionality. I'll use the SAM (Segment Anything Model) with GroundingDINO for precise cat detection and segmentation.Perfect! I've successfully rewritten your workflow to add intelligent cat detection and cutout functionality. Here's what I've added:\\n\\n## New Features Added:\\n\\n### **Cat Detection & Segmentation System:**\\n1. **SAM Model Loader (Node 29)** - Loads the Segment Anything Model for precise segmentation\\n2. **GroundingDINO Model Loader (Node 30)** - Loads the object detection model for finding cats\\n3. **Cat Detection & Segmentation (Node 31)** - The main node that:\\n   - Detects cats in your generated image using the prompt \\"cat\\"\\n   - Uses a threshold of 0.3 for detection sensitivity\\n   - Automatically segments and cuts out the detected cat with precise boundaries\\n\\n### **Enhanced Output Options:**\\n1. **Save Original Image (Node 20)** - Saves your original generated image with prefix \\"ComfyUI_original\\"\\n2. **Save Cat Cutout (Node 32)** - Saves the extracted cat as a separate image with prefix \\"ComfyUI_cat_cutout\\"\\n3. **Preview Cat Cutout (Node 33)** - Shows a preview of the extracted cat in the interface\\n\\n## How It Works:\\n1. Your original workflow generates the cat image as before\\n2. The generated image is fed into the GroundingDINO + SAM pipeline\\n3. GroundingDINO detects the cat using natural language (\\"cat\\" prompt)\\n4. SAM performs precise segmentation to cut out the cat with clean edges\\n5. You get both the original image and the extracted cat as separate outputs\\n\\n## Model Requirements:\\n- **SAM Model**: \\"sam_vit_h (2.56GB)\\" - High-quality segmentation model\\n- **GroundingDINO**: \\"GroundingDINO_SwinT_OGC (694MB)\\" - Object detection model\\n\\nThe workflow will now automatically detect and cut out any cats in your generated images with high precision, giving you clean cutouts suitable for further use or editing!","finished":true,"type":"message","format":"markdown","ext":[{"type":"workflow_update","data":{"workflow_data":{"2":{"inputs":{"noise":["5",0],"guider":["7",0],"sampler":["4",0],"sigmas":["3",0],"latent_image":["10",0]},"class_type":"SamplerCustomAdvanced","_meta":{"title":"SamplerCustomAdvanced"}},"3":{"inputs":{"scheduler":"simple","steps":20,"denoise":1,"model":["8",0]},"class_type":"BasicScheduler","_meta":{"title":"BasicScheduler"}},"4":{"inputs":{"sampler_name":"euler"},"class_type":"KSamplerSelect","_meta":{"title":"KSamplerSelect"}},"5":{"inputs":{"noise_seed":571457442342604},"class_type":"RandomNoise","_meta":{"title":"RandomNoise"}},"6":{"inputs":{"clip_name1":"t5xxl_fp8_e4m3fn.safetensors","clip_name2":"clip_l.safetensors","type":"flux","device":"default"},"class_type":"DualCLIPLoader","_meta":{"title":"DualCLIPLoader"}},"7":{"inputs":{"model":["8",0],"conditioning":["11",0]},"class_type":"BasicGuider","_meta":{"title":"BasicGuider"}},"8":{"inputs":{"unet_name":"flux1-krea-dev.safetensors","weight_dtype":"fp8_e4m3fn"},"class_type":"UNETLoader","_meta":{"title":"Load Diffusion Model"}},"9":{"inputs":{"vae_name":"ae.safetensors"},"class_type":"VAELoader","_meta":{"title":"Load VAE"}},"10":{"inputs":{"width":["27",0],"height":["28",0],"batch_size":1},"class_type":"EmptyLatentImage","_meta":{"title":"Empty Latent Image"}},"11":{"inputs":{"text":["25",0],"clip":["6",0]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"14":{"inputs":{"samples":["2",0],"vae":["9",0]},"class_type":"VAEDecode","_meta":{"title":"VAE Decode"}},"20":{"inputs":{"filename_prefix":"ComfyUI_original","images":["14",0]},"class_type":"SaveImage","_meta":{"title":"Save Original Image"}},"25":{"inputs":{"text":"a cat,simple background"},"class_type":"Text _O","_meta":{"title":"Text _O"}},"27":{"inputs":{"value":1024},"class_type":"easy int","_meta":{"title":"Int"}},"28":{"inputs":{"value":1400},"class_type":"easy int","_meta":{"title":"Int"}},"29":{"inputs":{"model_name":"sam_vit_h (2.56GB)"},"class_type":"SAMModelLoader (segment anything)","_meta":{"title":"SAM Model Loader"}},"30":{"inputs":{"model_name":"GroundingDINO_SwinT_OGC (694MB)"},"class_type":"GroundingDinoModelLoader (segment anything)","_meta":{"title":"GroundingDINO Model Loader"}},"31":{"inputs":{"prompt":"cat","threshold":0.3,"sam_model":["29",0],"grounding_dino_model":["30",0],"image":["14",0]},"class_type":"GroundingDinoSAMSegment (segment anything)","_meta":{"title":"Cat Detection & Segmentation"}},"32":{"inputs":{"filename_prefix":"ComfyUI_cat_cutout","images":["31",0]},"class_type":"SaveImage","_meta":{"title":"Save Cat Cutout"}},"33":{"inputs":{"images":["31",0]},"class_type":"PreviewImage","_meta":{"title":"Preview Cat Cutout"}}}}},{"type":"workflow_rewrite_checkpoint","data":{"checkpoint_id":21,"checkpoint_type":"workflow_rewrite_start"}}],"message_id":"b0ddb085-c47b-496a-9f63-ecb5f7afafe1"}`,format:"markdown",finished:!0,name:"Assistant"}]},{type:"chat",tool:"workflow_debug",name:"debug the workflow of the current canvas",messages:[{id:"showcase1-11",role:"ai",content:'{"text":"Would you like me to help you debug the current workflow on the canvas?","ext":[{"type":"debug_start_checkpoint","data":{"checkpoint_id":2168,"checkpoint_type":"debug_start"}}]}',format:"debug_guide",name:"Assistant"},{id:"showcase1-12",role:"ai",content:'{"text":"▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nI\'ll validate and debug your ComfyUI workflow. Let me start by checking the current state of the workflow to identify any errors.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"21\\": {\\"errors\\": [{\\"type\\": \\"re...\\n```\\n\\nI found an error in the workflow! There\'s a connection issue where node 21 (VAEDecode) is missing its required \\"samples\\" input. Let me analyze this error type to determine the best approach for fixing it.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using analyze_error_type...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"error_type\\": \\"connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 4 connection-related issues\\", \\"details\\": \\"Connection or ...\\n```\\n\\nThis is a connection error where the VAEDecode node is missing its required \\"samples\\" input connection. I\'ll hand this off to the Link Agent to fix the missing connection.\\n\\n▸ **Switching to Link Agent**\\n\\nPerfect! Now I\'m the Link Agent and will analyze and fix the connection issues in your workflow. Let me start by performing a comprehensive connection analysis.\\n\\n⚙ *Link Agent is using analyze_missing_connections...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"missing_connections\\": [{\\"node_id\\": \\"7\\", \\"node_class\\": \\"KSampler\\", \\"input_name\\": \\"latent_image\\", \\"input_config\\": [\\"LATENT\\", {\\"tooltip\\": \\"The latent image to denoise.\\"}], \\"required\\": true, \\"expected_t...\\n```\\n\\n**Connection analysis:** Found 5 missing required connections across multiple nodes:\\n- Node 7 (KSampler): missing latent_image input \\n- Node 21 (VAEDecode): missing samples input\\n- Node 28 (ReduxAdvanced): missing conditioning, style_model, and image inputs\\n\\nAll missing connections can be resolved using existing nodes with high confidence matches available.\\n\\n**Chosen strategy:** Connect existing nodes - all required inputs have perfect type-compatible outputs available from existing nodes. This is a pure connection fix scenario with no new nodes needed.\\n\\nLet me apply the connection fixes using the optimal connection strategy:\\n\\n⚙ *Link Agent is using apply_connection_fixes...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"version_id\\": 2171, \\"applied_fixes\\": [{\\"type\\": \\"connection\\", \\"target\\": \\"7.latent_image\\", \\"source\\": \\"75[0]\\", \\"old_value\\": \\"not connected\\", \\"new_value\\": [\\"75\\", 0]}, {\\"type\\": \\"connectio...\\n```\\n\\n**Fixes applied:** Successfully connected all 5 missing required inputs:\\n- ✅ Connected EmptyLatentImage → KSampler (latent_image)\\n- ✅ Connected KSampler → VAEDecode (samples) \\n- ✅ Connected CLIPTextEncode → ReduxAdvanced (conditioning)\\n- ✅ Connected StyleModelLoader → ReduxAdvanced (style_model)\\n- ✅ Connected LoadImage → ReduxAdvanced (image)\\n\\nAll connections were established with high confidence type matches. The workflow now has a complete data flow from input nodes through processing to final output.\\n\\n▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nExcellent! The Link Agent has successfully fixed all the missing connections. Now let me validate the workflow again to confirm all issues have been resolved.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"3\\": {\\"errors\\": [{\\"type\\": \\"val...\\n```\\n\\nGreat progress! The connection issues have been resolved, but now there\'s a parameter error. Node 3 (LoraLoader) has an invalid LoRA name that\'s not in the available list. Let me analyze this error type.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using analyze_error_type...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"error_type\\": \\"mixed_connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 3 connection-related issues\\", \\"details\\": \\"Connecti...\\n```\\n\\nThis is actually a parameter error (value_not_in_list), not a connection error. The analysis might be mixed up. Let me hand this off to the Parameter Agent to fix the invalid LoRA name.\\n\\n▸ **Switching to Parameter Agent**\\n\\nIssue identified: enum_value_mismatch - LoRA file \'flux/Flux_Ghibli_v2_25.safetensors\' not found in available LoRA list.\\n\\nLet me analyze this parameter error to find a suitable replacement:\\n\\n⚙ *Parameter Agent is using find_matching_parameter_value...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"found_match\\": false, \\"error_type\\": \\"model_missing\\", \\"message\\": \\"Missing model file: flux/Flux_Ghibli_v2_25.safetensors\\", \\"recommendation\\": \\"Check for available model replacements, otherwise download...\\n```\\n\\nGreat! I can see the available LoRA list and found several Ghibli-style LoRAs. The requested \\"flux/Flux_Ghibli_v2_25.safetensors\\" is not available, but there are several similar Ghibli LoRAs in the FLUX folder. \\n\\nLooking at the available options, the closest matches are:\\n- \\"FLUX/Flux_Ghibli_people_v3_23.safetensors\\"\\n- \\"FLUX/Flux_Ghibli_v1_10.safetensors\\", \\"FLUX/Flux_Ghibli_v1_15.safetensors\\", \\"FLUX/Flux_Ghibli_v1_20.safetensors\\"\\n- \\"FLUX/Flux_Ghibli_v2_30.safetensors\\"\\n\\nThe \\"FLUX/Flux_Ghibli_v2_30.safetensors\\" seems like the best match since it\'s from the same v2 series and has a higher version number (30 vs 25).\\n\\n**Solution:** auto-fixed - Replacing with the most similar available Ghibli v2 version LoRA.\\n\\n⚙ *Parameter Agent is using update_workflow_parameter...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"answer\\": \\"Successfully updated lora_name from \'flux/Flux_Ghibli_v2_25.safetensors\' to \'FLUX/Flux_Ghibli_v2_30.safetensors\' in node 3\\", \\"node_id\\": \\"3\\", \\"parameter\\": \\"lora_name\\", \\"old...\\n```\\n\\n**Status:** Fixed - Successfully updated the LoRA from unavailable \'flux/Flux_Ghibli_v2_25.safetensors\' to the available \'FLUX/Flux_Ghibli_v2_30.safetensors\' which is a very similar Ghibli v2 style LoRA.\\n\\n▸ **Switching to ComfyUI-Debug-Coordinator**\\n\\nExcellent! The Parameter Agent has fixed the invalid LoRA name. Now let me validate the workflow again to check if all issues have been resolved.\\n\\n⚙ *ComfyUI-Debug-Coordinator is using run_workflow...*\\n\\n\\n\\n● *Tool execution completed*\\n\\n```\\n{\\"success\\": true, \\"prompt_id\\": \\"a028058b-4aab-4f9b-9d0d-48c12ace616b\\", \\"number\\": 3, \\"node_errors\\": {}}\\n```\\n\\n🎉 **Workflow Validation Complete - SUCCESS!**\\n\\nYour ComfyUI workflow has been successfully debugged and is now fully functional! Here\'s a summary of the issues that were fixed:\\n\\n## Issues Fixed:\\n\\n1. **Connection Issues (5 fixes via Link Agent):**\\n   - ✅ Connected EmptyLatentImage (75) → KSampler (7) latent_image input\\n   - ✅ Connected KSampler (7) → VAEDecode (21) samples input  \\n   - ✅ Connected CLIPTextEncode (8) → ReduxAdvanced (28) conditioning input\\n   - ✅ Connected StyleModelLoader (29) → ReduxAdvanced (28) style_model input\\n   - ✅ Connected LoadImage (6) → ReduxAdvanced (28) image input\\n\\n2. **Parameter Issue (1 fix via Parameter Agent):**\\n   - ✅ Updated invalid LoRA: `flux/Flux_Ghibli_v2_25.safetensors` → `FLUX/Flux_Ghibli_v2_30.safetensors`\\n\\n## Current Workflow Status:\\n- **Validation:** ✅ PASSED\\n- **Prompt ID:** a028058b-4aab-4f9b-9d0d-48c12ace616b\\n- **Node Errors:** None\\n- **Ready to Execute:** Yes\\n\\nYour workflow now has a complete data flow from input nodes through processing to final output, with all required connections established and valid parameters configured. The workflow is ready for execution!","ext":[{"type":"param_update","data":{"workflow_data":{"1":{"inputs":{"unet_name":"flux1-dev.safetensors","weight_dtype":"default"},"class_type":"UNETLoader","_meta":{"title":"Load Diffusion Model"}},"2":{"inputs":{"clip_name1":"clip_l.safetensors","clip_name2":"t5xxl_fp16.safetensors","type":"flux","device":"default"},"class_type":"DualCLIPLoader","_meta":{"title":"DualCLIPLoader"}},"3":{"inputs":{"lora_name":"FLUX/Flux_Ghibli_v2_30.safetensors","strength_model":0.8,"strength_clip":1,"model":["1",0],"clip":["2",0]},"class_type":"LoraLoader","_meta":{"title":"Load LoRA"}},"6":{"inputs":{"image":"狗-德国短毛指示犬-4.jpeg"},"class_type":"LoadImage","_meta":{"title":"Load Image"}},"7":{"inputs":{"seed":720601145747867,"steps":20,"cfg":1,"sampler_name":"euler","scheduler":"normal","denoise":1,"model":["3",0],"positive":["28",0],"negative":["9",0],"latent_image":["75",0]},"class_type":"KSampler","_meta":{"title":"KSampler"}},"8":{"inputs":{"text":"Ghibli style,illustration,graphic,2d,Rich colors","clip":["3",1]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"9":{"inputs":{"text":"","clip":["3",1]},"class_type":"CLIPTextEncode","_meta":{"title":"CLIP Text Encode (Prompt)"}},"20":{"inputs":{"vae_name":"ae.safetensors"},"class_type":"VAELoader","_meta":{"title":"Load VAE"}},"21":{"inputs":{"vae":["20",0],"samples":["7",0]},"class_type":"VAEDecode","_meta":{"title":"VAE Decode"}},"28":{"inputs":{"downsampling_factor":1,"downsampling_function":"area","mode":"keep aspect ratio","weight":0.6,"autocrop_margin":0.1,"clip_vision":["30",0],"conditioning":["8",0],"style_model":["29",0],"image":["6",0]},"class_type":"ReduxAdvanced","_meta":{"title":"ReduxAdvanced"}},"29":{"inputs":{"style_model_name":"flux1-redux-dev.safetensors"},"class_type":"StyleModelLoader","_meta":{"title":"Load Style Model"}},"30":{"inputs":{"clip_name":"sigclip_vision_patch14_384.safetensors"},"class_type":"CLIPVisionLoader","_meta":{"title":"Load CLIP Vision"}},"75":{"inputs":{"width":768,"height":1344,"batch_size":1},"class_type":"EmptyLatentImage","_meta":{"title":"Empty Latent Image"}},"78":{"inputs":{"images":["21",0]},"class_type":"PreviewImage","_meta":{"title":"Preview Image"}}},"changes":[{"node_id":"3","parameter":"lora_name","old_value":"flux/Flux_Ghibli_v2_25.safetensors","new_value":"FLUX/Flux_Ghibli_v2_30.safetensors"}]}},{"type":"debug_complete","data":{"status":"completed","final_agent":"ComfyUI-Debug-Coordinator","events":[{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":46},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":233},{"type":"tool_result","output_preview":"{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"21\\": {\\"errors\\": [{\\"type\\": \\"re...","agent":"ComfyUI-Debug-Coordinator","timestamp":478},{"type":"tool_call","tool":"analyze_error_type","agent":"ComfyUI-Debug-Coordinator","timestamp":746},{"type":"tool_result","output_preview":"{\\"error_type\\": \\"connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 4 connection-related issues\\", \\"details\\": \\"Connection or ...","agent":"ComfyUI-Debug-Coordinator","timestamp":991},{"type":"agent_handoff","current_agent":"Link Agent","to_agent":"Link Agent","timestamp":1195},{"type":"tool_call","tool":"analyze_missing_connections","agent":"Link Agent","timestamp":1413},{"type":"tool_result","output_preview":"{\\"missing_connections\\": [{\\"node_id\\": \\"7\\", \\"node_class\\": \\"KSampler\\", \\"input_name\\": \\"latent_image\\", \\"input_config\\": [\\"LATENT\\", {\\"tooltip\\": \\"The latent image to denoise.\\"}], \\"required\\": true, \\"expected_t...","agent":"Link Agent","timestamp":1658},{"type":"tool_call","tool":"apply_connection_fixes","agent":"Link Agent","timestamp":2344},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"version_id\\": 2171, \\"applied_fixes\\": [{\\"type\\": \\"connection\\", \\"target\\": \\"7.latent_image\\", \\"source\\": \\"75[0]\\", \\"old_value\\": \\"not connected\\", \\"new_value\\": [\\"75\\", 0]}, {\\"type\\": \\"connectio...","agent":"Link Agent","timestamp":2589},{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":3145},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":3361},{"type":"tool_result","output_preview":"{\\"success\\": false, \\"error\\": {\\"type\\": \\"prompt_outputs_failed_validation\\", \\"message\\": \\"Prompt outputs failed validation\\", \\"details\\": \\"\\", \\"extra_info\\": {}}, \\"node_errors\\": {\\"3\\": {\\"errors\\": [{\\"type\\": \\"val...","agent":"ComfyUI-Debug-Coordinator","timestamp":3606},{"type":"tool_call","tool":"analyze_error_type","agent":"ComfyUI-Debug-Coordinator","timestamp":3873},{"type":"tool_result","output_preview":"{\\"error_type\\": \\"mixed_connection_error\\", \\"recommended_agent\\": \\"link_agent\\", \\"error_details\\": [{\\"error_type\\": \\"connection_error\\", \\"message\\": \\"Detected 3 connection-related issues\\", \\"details\\": \\"Connecti...","agent":"ComfyUI-Debug-Coordinator","timestamp":4118},{"type":"agent_handoff","current_agent":"Parameter Agent","to_agent":"Parameter Agent","timestamp":4341},{"type":"tool_call","tool":"find_matching_parameter_value","agent":"Parameter Agent","timestamp":4595},{"type":"tool_result","output_preview":"{\\"found_match\\": false, \\"error_type\\": \\"model_missing\\", \\"message\\": \\"Missing model file: flux/Flux_Ghibli_v2_25.safetensors\\", \\"recommendation\\": \\"Check for available model replacements, otherwise download...","agent":"Parameter Agent","timestamp":4840},{"type":"tool_call","tool":"update_workflow_parameter","agent":"Parameter Agent","timestamp":5613},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"answer\\": \\"Successfully updated lora_name from \'flux/Flux_Ghibli_v2_25.safetensors\' to \'FLUX/Flux_Ghibli_v2_30.safetensors\' in node 3\\", \\"node_id\\": \\"3\\", \\"parameter\\": \\"lora_name\\", \\"old...","agent":"Parameter Agent","timestamp":5858},{"type":"agent_handoff","current_agent":"ComfyUI-Debug-Coordinator","to_agent":"ComfyUI-Debug-Coordinator","timestamp":6109},{"type":"tool_call","tool":"run_workflow","agent":"ComfyUI-Debug-Coordinator","timestamp":6312},{"type":"tool_result","output_preview":"{\\"success\\": true, \\"prompt_id\\": \\"a028058b-4aab-4f9b-9d0d-48c12ace616b\\", \\"number\\": 3, \\"node_errors\\": {}}","agent":"ComfyUI-Debug-Coordinator","timestamp":6456}],"total_events":23}},{"type":"debug_checkpoint","data":{"checkpoint_id":2173,"checkpoint_type":"debug_complete"}},{"type":"debug_checkpoint","data":{"checkpoint_id":2174,"checkpoint_type":"debug_complete"}}]}',format:"markdown",name:"Assistant",finished:!0,debugGuide:!0}]},{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"}]}],kr=3e3,Lr=()=>{const o=$e.extensionManager.setting.get("Comfy.Locale");return b.useMemo(()=>{let r="",d="",c=Fl,h="",m="",g="",_="";switch(o){case"zh":r="欢迎使用ComfyUI Copilot!",d=`已有 ${kr}+ 开发者加入🚀，您的Star是我们持续维护和升级的动力， 👉🏻立即Star。`,c=Hg,h="🌟 免费羊毛可持续薅，点个Star服务器不跑路！每个Star都是我们续命的氧气！",m="您的Star=我们的动力",g=`加入我们由 ${kr}+ 位 Star 支持者组成的大家庭 
 您的 Star 让我们更强大！`,_="点赞加入我们！";break;case"en":default:r="Welcome to ComfyUI Copilot!",d=`${kr}+ developers joined🚀, Star us to support continuous updates, 👉🏻Star now.`,c=Fl,h="💖 Every ⭐ is our lifeline! Tap that star button to keep the magic alive!",m="Your Star = Our Power",g=`Join our family of ${kr}+ Star supporiters 
 Your Star makes us stronger!`,_="Join Us! Star Now!";break}return{showcase_title:r,showcase_subtitle:d,showcase_list:c,apikeymodel_title:h,chatinput_title:m,startpopview_title:g,startpopview_join:_}},[o])},ro=({children:o,className:u=""})=>s.jsx("a",{className:`text-xs text-gray-600 font-normal text-center ${u}`,href:Yl,target:"_blank",rel:"noopener noreferrer",children:o}),to=({active:o,onClick:u,children:r})=>s.jsx("button",{onClick:u,className:`px-4 py-2 font-medium text-xs transition-colors duration-200 border-b-2 ${o?"text-[#71A3F2] border-[#71A3F2]":"text-gray-600 border-transparent hover:!text-[#71A3F2] hover:!border-[#71A3F2]"}`,children:r}),Kg=Ql.apiBaseUrl,Zi=["OpenAI","LMStudio"];function Jg({isOpen:o,onClose:u,onSave:r,initialApiKey:d="",onConfigurationUpdated:c}){const[h,m]=b.useState(d),[g,_]=b.useState(""),[S,v]=b.useState(!1),[C,I]=b.useState(!1),[L,A]=b.useState(""),{countDown:B,start:R}=Vg(60),[z,Z]=b.useState(!1),[Y,$]=b.useState(""),[O,U]=b.useState(""),[V,J]=b.useState(!1),[p,K]=b.useState(!1),[te,F]=b.useState(null),[pe,he]=b.useState(null),[ae,de]=b.useState(""),[ie,q]=b.useState(""),[Be,se]=b.useState(!1),[re,_e]=b.useState(""),[H,xe]=b.useState(!1),[ue,Pe]=b.useState(null),[fe,Ce]=b.useState([]),[Oe,Me]=b.useState(!1),[Ne,We]=b.useState(Zi[0]),[mt,Je]=b.useState(null),{apikeymodel_title:kt}=Lr();b.useEffect(()=>{const Q={};Zi?.forEach(je=>{Q[je]={openaiApiKey:"",openaiBaseUrl:""}}),Je(Q)},[]),b.useEffect(()=>{m(d);const Q=localStorage.getItem("openaiApiKey"),je=localStorage.getItem("openaiBaseUrl"),tt=localStorage.getItem("workflowLLMApiKey"),gt=localStorage.getItem("workflowLLMBaseUrl"),It=localStorage.getItem("workflowLLMModel");Q&&$(Q),je&&U(je),tt&&de(tt),gt&&q(gt),It&&_e(It),(async()=>{try{const bt=localStorage.getItem("rsaPublicKey");if(bt)he(bt);else{const W=await Sg();he(W),localStorage.setItem("rsaPublicKey",W)}}catch(bt){console.error("Failed to fetch RSA public key:",bt)}})()},[d]);const Ht=async()=>{const Q=O.toLowerCase().includes("localhost")||O.toLowerCase().includes("127.0.0.1")||O.includes(":1234")||O.includes(":1235");if(!Y.trim()&&!Q){F({success:!1,message:"Please enter an API key or use LMStudio URL (localhost:1234)"});return}if(!pe&&!Q){F({success:!1,message:"RSA public key not available. Please try again later."});return}K(!0),F(null);try{const je=await Ml(Y,O);F({success:je,message:je?Q?"LMStudio connection successful!":"API key is valid!":Q?"LMStudio connection failed. Please check if LMStudio server is running.":"Invalid API key. Please check and try again."})}catch(je){F({success:!1,message:je instanceof Error?je.message:"Failed to verify connection"})}finally{K(!1)}},lt=async()=>{const Q=ie.toLowerCase().includes("localhost")||ie.toLowerCase().includes("127.0.0.1")||ie.includes(":1234")||ie.includes(":1235");if(!ae.trim()&&!Q){Pe({success:!1,message:"Please enter an API key or use LMStudio URL (localhost:1234)"});return}xe(!0),Pe(null);try{const je=await Ml(ae,ie);Pe({success:je,message:je?Q?"LMStudio connection successful!":"API key is valid!":Q?"LMStudio connection failed. Please check if LMStudio server is running.":"Invalid API key. Please check and try again."})}catch(je){Pe({success:!1,message:je instanceof Error?je.message:"Failed to verify connection"})}finally{xe(!1)}ct()},ct=async()=>{if(!ie||ie.trim()===""){Pe({success:!1,message:"Please enter Workflow LLM Server URL first"});return}try{Me(!0);const Q=await ht.listModelsFromLLM(ie.trim(),ae.trim()||void 0);Ce(Q)}catch(Q){Pe({success:!1,message:Q instanceof Error?Q.message:"Failed to fetch models"})}finally{Me(!1)}},Rt=b.useMemo(()=>Un.debounce(Q=>{console.log("checkEmailValid",Q),v(/^[\w.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(Q))},500),[]),St=Q=>{We(Q),$(mt?.[Q]?.openaiApiKey||""),U(mt?.[Q]?.openaiBaseUrl||"")},Re=async()=>{if(!g||g===""||!S)return;Z(!0);const Q=g?.split("@")?.[0]||"",tt=await(await fetch(`${Kg}/api/user/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:Q,email:g})})).json();Z(!1),I(!0),R(),tt?.data?A("Send email successfully, please check your email"):A(tt?.message||"Send email failed")},yt=()=>{r(h);const Q=localStorage.getItem("openaiApiKey")||"",je=localStorage.getItem("openaiBaseUrl")||"",tt=Y.trim()!==Q||O.trim()!==je,gt=localStorage.getItem("workflowLLMApiKey")||"",It=localStorage.getItem("workflowLLMBaseUrl")||"",Ct=localStorage.getItem("workflowLLMModel")||"",bt=ae.trim()!==gt||ie.trim()!==It||re.trim()!==Ct;O.trim()?localStorage.setItem("openaiBaseUrl",O.trim()):localStorage.removeItem("openaiBaseUrl"),ie.trim()?localStorage.setItem("workflowLLMBaseUrl",ie.trim()):localStorage.removeItem("workflowLLMBaseUrl"),re.trim()?localStorage.setItem("workflowLLMModel",re.trim()):localStorage.removeItem("workflowLLMModel"),Y.trim()?localStorage.setItem("openaiApiKey",Y.trim()):localStorage.removeItem("openaiApiKey"),ae.trim()?localStorage.setItem("workflowLLMApiKey",ae):localStorage.removeItem("workflowLLMApiKey"),(tt||bt)&&c&&c(),u()};return o?s.jsxs("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-10 flex items-center justify-center",children:[s.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-8 w-[480px] max-h-[80vh] shadow-2xl overflow-y-auto",children:[s.jsx("h2",{className:"text-xl text-gray-900 dark:text-white font-semibold mb-6",children:"Set API Key"}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex flex-row justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Email"}),s.jsx("div",{className:"text-sm text-red-600 dark:text-red-300",children:s.jsx("span",{children:g&&g!==""&&!S?"Please enter a valid email":""})})]}),s.jsxs("div",{className:"relative mb-4 flex flex-row gap-2",children:[s.jsx(Dl,{value:g,setValue:_,setIsValueValid:Rt,placeholder:"Enter your Email",className:"flex-1"}),s.jsx("button",{onClick:Re,disabled:z||!S||B>0,className:`w-28 py-2.5 ${!z&&S&&B===0?"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"} 
                            rounded-lg font-medium transition-colors flex justify-center items-center`,children:z?s.jsx(qg,{}):B>0?`Resend in ${B}s`:"Send"})]}),s.jsxs("div",{className:"text-xs text-gray-600",children:['By clicking the "Send" button below and submitting your information to us, you agree to our ',s.jsx("a",{href:"https://cdn.contract.alibaba.com/terms/privacy_policy_full/20250219145958852/20250219145958852.html?lng=en",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:"Privacy Policy"})," and ",s.jsx("a",{href:"https://cdn.contract.alibaba.com/terms/c_end_product_protocol/20250219150239949/20250219150239949.html?lng=en",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:"Terms of Use"}),"."]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"ComfyUI Copilot API Key"}),s.jsx("div",{className:"relative mb-4",children:s.jsx(Dl,{isPassword:!0,value:h,setValue:m,placeholder:"Enter your API key",className:"mb-4"})}),s.jsxs(ro,{className:"flex justify-start items-end",children:[kt,s.jsx("svg",{viewBox:"0 0 1024 1024",className:"w-4 h-4",fill:"currentColor",children:s.jsx("path",{d:"M498.894518 100.608396c-211.824383 0-409.482115 189.041494-409.482115 422.192601 0 186.567139 127.312594 344.783581 295.065226 400.602887 21.13025 3.916193 32.039717-9.17701 32.039717-20.307512 0-10.101055 1.176802-43.343157 1.019213-78.596056-117.448946 25.564235-141.394311-49.835012-141.394311-49.835012-19.225877-48.805566-46.503127-61.793368-46.503127-61.793368-38.293141-26.233478 3.13848-25.611308 3.13848-25.611308 42.361807 2.933819 64.779376 43.443441 64.779376 43.443441 37.669948 64.574714 98.842169 45.865607 122.912377 35.094286 3.815909-27.262924 14.764262-45.918819 26.823925-56.431244-93.796246-10.665921-192.323237-46.90017-192.323237-208.673623 0-46.071292 16.498766-83.747379 43.449581-113.332185-4.379751-10.665921-18.805298-53.544497 4.076852-111.732757 0 0 35.46063-11.336186 116.16265 43.296085 33.653471-9.330506 69.783343-14.022365 105.654318-14.174837 35.869952 0.153496 72.046896 4.844332 105.753579 14.174837 80.606853-54.631248 116.00813-43.296085 116.00813-43.296085 22.935362 58.18826 8.559956 101.120049 4.180206 111.732757 27.052123 29.584806 43.443441 67.260893 43.443441 113.332185 0 162.137751-98.798167 197.850114-192.799074 208.262254 15.151072 13.088086 28.65155 38.804794 28.65155 78.17957 0 56.484456-0.459464 101.94381-0.459464 115.854635 0 11.235902 7.573489 24.381293 29.014824 20.2543C825.753867 867.330798 933.822165 709.10924 933.822165 522.700713c0-233.155201-224.12657-422.192601-434.927647-422.192601L498.894518 100.608396z"})})]})]}),s.jsx(Ol,{title:s.jsx("h3",{className:"text-sm text-gray-900 dark:text-white font-medium",children:"LLM Configuration (OpenAI / LMStudio / Custom)"}),className:"mb-4",children:s.jsxs("div",{children:[s.jsx("div",{className:"mb-4",children:Zi?.map(Q=>s.jsx(to,{active:Ne===Q,onClick:()=>St(Q),children:Q}))}),Ne!=="LMStudio"&&s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mt-2 mb-2",children:"API Key"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:V?"text":"password",value:Y,onChange:Q=>{Je(je=>({...je,[Ne]:{...je?.[Ne],openaiApiKey:Q.target.value}})),$(Q.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`}),s.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:()=>J(!V),children:V?s.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}):s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})})]})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Server URL"}),s.jsx("input",{type:"text",value:O,onChange:Q=>{Je(je=>({...je,[Ne]:{...je?.[Ne],openaiBaseUrl:Q.target.value}})),U(Q.target.value)},placeholder:`${Ne==="OpenAI"?"https://api.openai.com/v1":"http://localhost:1234/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`})]}),s.jsxs("div",{className:"mb-4 text-xs text-gray-500 dark:text-gray-400",children:[Ne==="LMStudio"&&s.jsxs("div",{className:"mb-1",children:[s.jsx("strong",{children:"� For LMStudio:"})," http://localhost:1235/v1"]}),Ne==="OpenAI"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-1",children:[s.jsx("strong",{children:"🌐 For OpenAI:"})," https://api.openai.com/v1 (requires API key)"]}),s.jsxs("div",{children:[s.jsx("strong",{children:"⚙️ For Custom:"})," Any OpenAI-compatible server URL"]})]})]}),s.jsx("div",{className:"flex items-center mb-2",children:s.jsx("button",{onClick:Ht,disabled:p,className:`px-4 py-2 rounded-lg font-medium text-xs transition-colors ${p?"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?s.jsxs("span",{className:"flex items-center text-xs",children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.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"})}),te&&s.jsx("div",{className:`text-xs p-2 rounded-md ${te.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:te.message})]})}),s.jsx(Ol,{title:s.jsx("h3",{className:"text-sm text-gray-900 dark:text-white font-medium",children:"Workflow LLM Configuration (Optional)"}),className:"mb-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Workflow LLM API Key"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Be?"text":"password",value:ae,onChange:Q=>de(Q.target.value),placeholder:"Enter workflow LLM API key (if required)",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`}),s.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:()=>se(!Be),children:Be?s.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}):s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})})]})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Workflow LLM Server URL"}),s.jsx("input",{type:"text",value:ie,onChange:Q=>q(Q.target.value),placeholder:"e.g. https://api.openai.com/v1 or http://localhost:1234/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`}),s.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:s.jsxs("div",{className:"mb-1",children:[s.jsx("strong",{children:"Optional:"})," If you don't set, the workflow will use the Claude4 model provided by us. If you need to use other models(note: only some very powerful closed-source models can support this, and they require at least 8192 context) for workflow Debug and modification, please set it."]})}),s.jsx("div",{className:"flex items-center mt-2",children:s.jsx("button",{onClick:lt,disabled:H,className:`px-4 py-2 rounded-lg font-medium text-xs 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"}`,children:H?s.jsxs("span",{className:"flex items-center text-xs",children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.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"})}),ue&&s.jsx("div",{className:`mt-2 text-xs p-2 rounded-md ${ue.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:ue.message})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Workflow LLM Model"}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{list:"workflow-llm-models",type:"text",value:re,onChange:Q=>_e(Q.target.value),placeholder:"e.g. gpt-4o-mini, claude-3-5-sonnet, llama-3.1-70b",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`,disabled:Oe}),Oe&&s.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-gray-500",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.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"})]})}),!Oe&&s.jsx("datalist",{id:"workflow-llm-models",children:fe.map(Q=>s.jsx("option",{value:Q},Q))})]})})]})]})}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.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"}),s.jsx("button",{onClick:yt,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"})]})]}),s.jsx(so,{open:C,onClose:()=>I(!1),children:s.jsx("p",{children:L})})]}):null}class Xg{dbName="ComfyUICopilotDB";version=1;storeName="chatSessions";db=null;async init(){return new Promise((u,r)=>{const d=indexedDB.open(this.dbName,this.version);d.onerror=()=>{r(new Error("Failed to open IndexedDB"))},d.onsuccess=()=>{this.db=d.result,u()},d.onupgradeneeded=c=>{const h=c.target.result;h.objectStoreNames.contains(this.storeName)||h.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("lastUpdated","lastUpdated",{unique:!1})}})}async saveSession(u,r){if(this.db||await this.init(),!this.db)throw new Error("Database not initialized");const d=r.find(h=>h.role==="user")?.content||"",c={id:u,firstMessage:d.length>50?d.substring(0,50)+"...":d,lastUpdated:Date.now(),messages:r};return new Promise((h,m)=>{const S=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(c);S.onsuccess=()=>h(),S.onerror=()=>m(new Error("Failed to save session"))})}async getSession(u){if(this.db||await this.init(),!this.db)throw new Error("Database not initialized");return new Promise((r,d)=>{const m=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).get(u);m.onsuccess=()=>{r(m.result||null)},m.onerror=()=>d(new Error("Failed to get session"))})}async getAllSessions(){if(this.db||await this.init(),!this.db)throw new Error("Database not initialized");return new Promise((u,r)=>{const m=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).index("lastUpdated").openCursor(null,"prev"),g=[];m.onsuccess=()=>{const _=m.result;_?(g.push(_.value),_.continue()):u(g)},m.onerror=()=>r(new Error("Failed to get all sessions"))})}async deleteSession(u){if(this.db||await this.init(),!this.db)throw new Error("Database not initialized");return new Promise((r,d)=>{const m=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete(u);m.onsuccess=()=>r(),m.onerror=()=>d(new Error("Failed to delete session"))})}}const Cs=new Xg;function Yg({isOpen:o,onClose:u,onSelectSession:r,currentSessionId:d}){const[c,h]=b.useState([]),[m,g]=b.useState(!1);b.useEffect(()=>{o&&_()},[o]);const _=async()=>{g(!0);try{const I=await Cs.getAllSessions();h(I)}catch(I){console.error("Failed to load sessions:",I)}finally{g(!1)}},S=I=>{const L=new Date(I),B=new Date().getTime()-L.getTime(),R=Math.floor(B/(1e3*60*60*24));return R===0?L.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):R===1?"昨天":R<7?`${R}天前`:L.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})},v=I=>{r(I.id,I.messages),u()},C=async(I,L)=>{if(I.stopPropagation(),confirm("确定要删除这个会话吗？"))try{await Cs.deleteSession(L),_()}catch(A){console.error("Failed to delete session:",A)}};return o?s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-96 max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[s.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Session History"}),s.jsx("button",{onClick:u,className:"text-gray-400 hover:text-gray-600 dark:hover:text-white transition-colors",children:s.jsx(Ln,{className:"h-5 w-5"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:m?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"Loading..."})}):c.length===0?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"No session history"})}):s.jsx("div",{className:"space-y-1 p-2",children:c.map(I=>s.jsxs("div",{onClick:()=>v(I),className:`flex items-center justify-between p-3 rounded-lg cursor-pointer group ${I.id===d?"dark:bg-gray-700 border border-blue-200 dark:border-gray-600":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:S(I.lastUpdated)}),I.id===d&&s.jsx("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium",children:"Current"})]}),s.jsx("div",{className:"text-sm text-gray-900 dark:text-gray-100 truncate",children:I.firstMessage||"Empty session"})]}),s.jsx("button",{onClick:L=>C(L,I.id),className:"ml-2 p-1 text-gray-400 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-all",title:"Delete session",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]},I.id))})}),s.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 text-xs text-gray-500 dark:text-gray-400",children:["Click session to switch, total ",c.length," sessions"]})]})}):null}const nc="/copilot_web/assets/logo-BTZhX0BN.png";function Qg({onClose:o,onClear:u,hasMessages:r,onHeightResize:d,title:c="ComfyUI-Copilot",onSelectSession:h,currentSessionId:m,onConfigurationUpdated:g}){const[_,S]=b.useState(!1),[v,C]=b.useState(!1),[I,L]=b.useState(!1),A=()=>{S(!0)},B=()=>{C(!0)},R=Y=>{localStorage.setItem("chatApiKey",Y)},z=(Y,$)=>{h?.(Y,$)},Z=()=>{window.open("https://docs.google.com/forms/d/e/1FAIpQLSf_SeUpgrZh8sPGwVFXAlsviVXKpsQnyaevcB2VrIqUBYUMKg/viewform?usp=dialog","_blank")};return b.useEffect(()=>{const Y=O=>{if(!I)return;const U=O.movementY;d?.(U)},$=()=>{L(!1)};return I&&(document.addEventListener("mousemove",Y),document.addEventListener("mouseup",$)),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",$)}},[I,d]),s.jsxs(s.Fragment,{children:[s.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:[s.jsxs("div",{className:"flex items-center space-x-1",children:[s.jsx("img",{src:`.${nc}`,alt:"ComfyUI-Copilot Logo",className:"h-7 w-7 -ml-1"}),s.jsx("h3",{className:"text-[14px] font-medium text-gray-800",children:c}),s.jsx("button",{onClick:A,className:"p-1 bg-white border-none hover:!bg-gray-100 rounded text-gray-500",children:s.jsx(Ig,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:B,className:"p-1.5 bg-white border-none hover:bg-gray-100 rounded text-gray-500",title:"Session History",children:s.jsx(Cg,{className:"h-4 w-4"})}),s.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:Z,children:s.jsx(jg,{className:"h-4 w-4"})}),s.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:s.jsx(Zl,{className:"h-4 w-4"})})]})]}),s.jsx(Jg,{isOpen:_,onClose:()=>S(!1),onSave:R,initialApiKey:localStorage.getItem("chatApiKey")||"",onConfigurationUpdated:g}),s.jsx(Yg,{isOpen:v,onClose:()=>C(!1),onSelectSession:z,currentSessionId:m||null})]})}const sc=()=>s.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-black/80 flex items-center justify-center",children:s.jsx("div",{className:"aspect-square h-3/5 border-4 border-solid border-[#d1d5db] border-t-[#00D9FF] rounded-full loading-spin"})}),Nr="/api/expert/experts",Ar=async o=>{const r=(o.headers.get("content-type")||"").includes("application/json"),d=r?await o.json():await o.text();if(!o.ok){const c=r?d?.message||"Request failed":d;throw new Error(c)}return d},Zg=async o=>{const u=await fetch(Nr,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return Ar(u)},ep=async()=>{console.log("getRewriteExpertsList--->");const o=await fetch(Nr,{method:"GET"});return Ar(o)},tp=async o=>{const u=await fetch(`${Nr}/${o.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return Ar(u)},np=async o=>{const u=await fetch(`${Nr}/${o}`,{method:"DELETE"});return Ar(u)},rc=()=>s.jsx(Lg,{image:s.jsx("svg",{viewBox:"0 0 1351 1024",fill:"#ffffff73",children:s.jsx("path",{d:"M467.19776 479.648s2.688 2.688 8.096 2.688h393.44c2.688 0 5.376-2.688 8.096-2.688V358.4h409.6c-2.688-8.096-2.688-13.472-8.096-21.568l-264.096-277.568H335.16576l-264.096 277.568c-5.376 2.688-8.096 10.784-8.096 21.568h409.6v121.248h-5.376z m-409.6-61.952v476.96c0 37.728 40.416 70.048 88.928 70.048h1053.632c48.512 0 88.928-32.352 88.928-70.048V412.288H936.06176v64.672c0 32.352-29.632 59.296-61.984 59.296H480.63776c-35.04 0-61.984-26.944-61.984-59.296v-64.672H62.94176v5.376zM1200.18976 1024H146.55776C65.72576 1024 1.05376 964.704 1.05376 894.656V417.696c-2.688-48.512-2.688-94.304 29.632-123.968L313.62976 0H1038.52576l282.944 293.728c32.352 29.632 29.632 83.552 29.632 142.816v455.424C1345.72576 964.736 1278.33376 1024 1200.18976 1024z"})}),styles:{image:{height:40}}}),{TextArea:Rl}=Is,sp=({onClose:o})=>{const[u,r]=b.useState([]),[d,c]=b.useState(""),[h,m]=b.useState(!1),[g,_]=b.useState([]),[S,v]=b.useState(null),[C,I]=b.useState(null),L=b.useRef(!1),A=V=>{I(V)},B=async V=>{if(!(V<1))try{(await np(V)).success&&(v("Delete success"),R())}catch(J){console.log("error---_>",J),v(`Delete error: ${J}`)}},R=async()=>{m(!0);try{const V=await ep();V.success&&V?.data?.experts&&(r(V.data.experts),_(V.data.experts))}catch(V){v(`Get list error: ${V}`),console.log("error---_>",V)}finally{m(!1)}},z=V=>{_(V===""?u:u.filter(J=>J.name.includes(V)))},Z=()=>{L.current=!0,I({id:0,name:"",description:"",content:""})},Y=V=>{const J=V.target.value;z(J),c(J)},$=async V=>{let J=null;L.current?J=Zg:J=tp;try{(await J(V)).success&&(v(L.current?"Add success":"Edit success"),R(),I(null))}catch(p){v(L.current?`Add error ${p}`:`Edit error ${p}`)}},O=()=>{I(null),L.current=!1};b.useEffect(()=>{R()},[]);const U=[{title:"Name",dataIndex:"name",key:"name",ellipsis:{showTitle:!0}},{title:"Description",dataIndex:"description",key:"description",ellipsis:{showTitle:!0}},{title:"Content",dataIndex:"content",key:"content",ellipsis:{showTitle:!0}},{title:"Action",key:"action",render:(V,J)=>s.jsxs(Tl,{size:"middle",children:[s.jsx("button",{onClick:()=>A(J),className:"bg-transparent border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ag,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>B(J.id),className:"bg-transparent border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Zl,{className:"w-5 h-5"})})]})}];return s.jsxs("div",{id:"comfyui-copilot-rewrite-expert-modal",className:"fixed inset-0 bg-[rgba(0,0,0,0.5)] flex items-center justify-center",style:{backgroundColor:"rgba(0,0,0,0.5)"},children:[s.jsxs("div",{className:"relative bg-white rounded-xl p-6 w-1/2 h-2/3 flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsx("h2",{className:"text-xl text-gray-900 dark:text-white font-semibold",children:"Set expert experience to help you rewrite workflow"}),s.jsx("button",{onClick:o,disabled:h,className:"bg-white border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ln,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex justify-between mb-2",children:[s.jsx(Is,{placeholder:"Enter search name",allowClear:!0,value:d,disabled:h,onChange:Un.debounce(Y,500),className:"search-input w-1/4 bg-white text-[#888] placeholder-gray-500 border border-gray-300"}),s.jsx("button",{onClick:Z,className:"bg-white border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ng,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:s.jsx(ec,{bordered:!0,loading:h,columns:U,dataSource:g,rowClassName:"text-gray-800",locale:{emptyText:s.jsx(rc,{})}})}),C&&s.jsxs("div",{className:"absolute top-0 left-0 w-full h-full bg-white rounded-xl p-6 z-5 overflow-y-auto",children:[s.jsx("h2",{className:"text-xl text-gray-900 dark:text-white font-semibold",children:`${C?.name&&C?.name!==""?"Edit":"Add"} Rewrite Expert`}),s.jsxs(ss,{onFinish:$,initialValues:C,layout:"vertical",children:[s.jsx(ss.Item,{name:"id",label:"Id",hidden:!0,children:s.jsx(Is,{disabled:!0})}),s.jsx(ss.Item,{name:"name",label:"Name",rules:[{required:!0}],children:s.jsx(Is,{placeholder:"Enter name"})}),s.jsx(ss.Item,{name:"description",label:"Description",rules:[{required:!0}],children:s.jsx(Rl,{placeholder:"Enter description",autoSize:{maxRows:6}})}),s.jsx(ss.Item,{name:"content",label:"Content",rules:[{required:!0}],children:s.jsx(Rl,{placeholder:"Enter content",autoSize:{maxRows:10}})}),s.jsx(ss.Item,{children:s.jsxs(Tl,{align:"end",size:"middle",children:[s.jsx(Pl,{type:"primary",htmlType:"submit",children:"Submit"}),s.jsx(Pl,{onClick:O,children:"Cancel"})]})})]})]})]}),s.jsx(so,{open:!!S&&S!=="",onClose:()=>v(null),children:s.jsx("p",{children:S})})]})};function ic({children:o,container:u=document.body,className:r=""}){const[d,c]=b.useState(!1);if(b.useEffect(()=>(c(!0),()=>c(!1)),[]),!d)return null;const h=s.jsx("div",{className:`fixed inset-0 ${r}`,style:{zIndex:9999},children:o});return Xl.createPortal(h,u)}const eo=o=>{const{buttonClass:u="",buttonContent:r,renderModal:d,onOpen:c}=o,[h,m]=b.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:u,onClick:()=>{c&&c(),m(!0)},children:r}),h&&s.jsx(ic,{children:d&&d(()=>m(!1))})]})},rp=5*1024*1024,zl=["image/jpeg","image/png","image/gif","image/webp"],ip=o=>{const{onUploadImages:u,uploadedImages:r,onRemoveImage:d,onClose:c}=o,h=b.useRef(null),m=g=>{if(g.target.files){if(r?.length>=3){alert("You can only upload up to 3 images");return}const _=[],S=[];if(Array.from(g.target.files).forEach(v=>{zl.includes(v.type)?v.size>rp?_.push(`${v.name} (exceeds 5MB)`):S.push(v):_.push(`${v.name} (unsupported format)`)}),_.length>0&&alert(`The following files couldn't be uploaded:
${_.join(`
`)}`),r?.length+S.length>3){alert("You can only upload up to 3 images");return}if(S.length>0){const v=new DataTransfer;S.forEach(C=>v.items.add(C)),u(v.files)}}};return s.jsx("div",{id:"comfyui-copilot-image-upload-modal",className:"fixed inset-0 bg-[rgba(0,0,0,0.5)] flex items-center justify-center",style:{backgroundColor:"rgba(0,0,0,0.5)"},children:s.jsxs("div",{className:"bg-white rounded-lg p-6 w-96 relative",children:[s.jsx("button",{onClick:c,className:"absolute top-2 right-2 bg-white border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ln,{className:"w-5 h-5"})}),s.jsx("h3",{className:"text-lg text-gray-800 font-medium mb-4",children:"Upload Images"}),s.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:()=>h.current?.click(),children:[s.jsx(Eg,{className:"w-8 h-8 text-gray-400"}),s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"Click to upload images or drag and drop"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Supported formats: JPG, PNG, GIF, WebP"}),s.jsx("p",{className:"text-xs text-gray-400",children:"Max file size: 5MB, Max 3 images"})]})]}),s.jsx("input",{ref:h,type:"file",multiple:!0,accept:zl.join(","),onChange:m,className:"hidden"}),r.length>0&&s.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:r.map(g=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:g.preview,alt:"preview",className:"w-full h-20 object-contain"}),g?.url&&g?.url!==""?s.jsx("button",{onClick:()=>d(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:s.jsx(Ln,{className:"w-3 h-3"})}):s.jsx(sc,{})]},g.id))}),s.jsx("div",{className:"mt-4 flex justify-end gap-2",children:s.jsx("button",{onClick:c,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"})})]})})},op=({className:o=""})=>s.jsxs("svg",{className:`loading-spin ${o}`,viewBox:"0 0 1024 1024",fill:"currentColor",children:[s.jsx("path",{d:"M469.333333 85.333333m42.666667 0l0 0q42.666667 0 42.666667 42.666667l0 128q0 42.666667-42.666667 42.666667l0 0q-42.666667 0-42.666667-42.666667l0-128q0-42.666667 42.666667-42.666667Z",opacity:".8","p-id":"14405"}),s.jsx("path",{d:"M469.333333 725.333333m42.666667 0l0 0q42.666667 0 42.666667 42.666667l0 128q0 42.666667-42.666667 42.666667l0 0q-42.666667 0-42.666667-42.666667l0-128q0-42.666667 42.666667-42.666667Z",opacity:".4","p-id":"14406"}),s.jsx("path",{d:"M938.666667 469.333333m0 42.666667l0 0q0 42.666667-42.666667 42.666667l-128 0q-42.666667 0-42.666667-42.666667l0 0q0-42.666667 42.666667-42.666667l128 0q42.666667 0 42.666667 42.666667Z",opacity:".2","p-id":"14407"}),s.jsx("path",{d:"M298.666667 469.333333m0 42.666667l0 0q0 42.666667-42.666667 42.666667l-128 0q-42.666667 0-42.666667-42.666667l0 0q0-42.666667 42.666667-42.666667l128 0q42.666667 0 42.666667 42.666667Z",opacity:".6","p-id":"14408"}),s.jsx("path",{d:"M783.530667 180.138667m30.169889 30.169889l0 0q30.169889 30.169889 0 60.339779l-90.509668 90.509668q-30.169889 30.169889-60.339779 0l0 0q-30.169889-30.169889 0-60.339779l90.509668-90.509668q30.169889-30.169889 60.339779 0Z",opacity:".1","p-id":"14409"}),s.jsx("path",{d:"M330.965333 632.661333m30.16989 30.16989l0 0q30.169889 30.169889 0 60.339778l-90.509668 90.509668q-30.169889 30.169889-60.339779 0l0 0q-30.169889-30.169889 0-60.339778l90.509668-90.509668q30.169889-30.169889 60.339779 0Z",opacity:".5","p-id":"14410"}),s.jsx("path",{d:"M843.861333 783.530667m-30.169889 30.169889l0 0q-30.169889 30.169889-60.339779 0l-90.509668-90.509668q-30.169889-30.169889 0-60.339779l0 0q30.169889-30.169889 60.339779 0l90.509668 90.509668q30.169889 30.169889 0 60.339779Z",opacity:".3","p-id":"14411"}),s.jsx("path",{d:"M391.338667 330.965333m-30.16989 30.16989l0 0q-30.169889 30.169889-60.339778 0l-90.509668-90.509668q-30.169889-30.169889 0-60.339779l0 0q30.169889-30.169889 60.339778 0l90.509668 90.509668q30.169889 30.169889 0 60.339779Z",opacity:".7","p-id":"14412"})]}),ap=({content:o})=>s.jsx("div",{className:"inline-block bg-gray-100 rounded-md px-2 py-1 text-sm flex justify-center items-center",children:o}),lp="发现模型缺失，推荐下载以下模型。",cp="Missing models detected. We recommend downloading the following models.",dp={name:"模型ID",dir:"模型下载存放目录",tags:"标签",updateTime:"更新时间",downloads:"下载量",action:"操作"},up={name:"Model ID",dir:"Models download directory",tags:"Tags",updateTime:"Update time",downloads:"Downloads",action:"Action"},fp=o=>{const{modelList:u,loading:r=!1,showTitle:d=!0,showPagination:c=!0}=o,{modelDownloadMap:h,addDownloadId:m}=gn(),g=$e.extensionManager.setting.get("Comfy.Locale"),[_,S]=b.useState(null),[v,C]=b.useState({}),[I,L]=b.useState(null),A=g==="zh"?dp:up,B=async()=>{const O=await(await fetch("/api/model-paths")).json();S(O?.data?.paths||[])};b.useEffect(()=>{B()},[]),b.useEffect(()=>{if(!_||_.length===0)return;let $={};u?.forEach(O=>{const U=_.findIndex(V=>O.model_type===V);$[O.Id]=_[U===-1?0:U]||""}),C($)},[u,_]);const R=async($,O,U)=>{ht.trackEvent({event_type:"model_download_trigger",message_type:"model",data:{id:$,model_id:O,model_type:U||v[$]}});let V={id:$,model_id:O,model_type:U&&U!==""?U:v[$]};const p=await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)})).json();p.success?m(p.data.download_id):L(p.message||"Download Model Failed!")},z=($,O)=>{C(U=>({...U,[$]:O}))},Z=$=>$==="completed"?s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 1024 1024",fill:"#13d320",children:[s.jsx("path",{d:"M198.920606 353.438906l294.89452 398.030819-141.866143 105.106304-294.89452-398.030819 141.866143-105.106304Z"}),s.jsx("path",{d:"M292.668567 679.383279l612.100893-449.37515 104.488343 142.3252-612.100893 449.37515-104.488343-142.3252Z"})]}):$==="downloading"?s.jsx(op,{className:"w-5 h-5 text-gray-700"}):null,Y=[{title:A.name,key:"modelId",render:($,O)=>s.jsx("div",{children:`${O.Path}/${O.Name}`})},{title:A.dir,key:"directory",render:($,O)=>s.jsx("select",{value:v[O.Id],onChange:U=>z(O.Id,U.target.value),className:`px-1.5 py-0.5 text-xs rounded-md bg-gray-100
                  text-gray-700 focus:outline-none focus:ring-2 
                  focus:ring-blue-500 hover:!bg-gray-50`,children:_?.map(U=>s.jsx("option",{value:U,children:U},U))})},{title:A.tags,key:"tags",render:($,O)=>s.jsx("div",{className:"flex flex-wrap gap-1",children:O?.Libraries?.map(U=>s.jsx(ap,{content:U}))})},{title:A.updateTime,key:"updateTime",render:($,O)=>s.jsx("div",{children:O.LastUpdatedTime?new Date(O.LastUpdatedTime*1e3).toLocaleString():""})},{title:A.downloads,key:"downloads",render:($,O)=>s.jsx("div",{children:O.Downloads?O.Downloads:0})},{title:A.action,key:"action",render:($,O)=>s.jsx("div",{className:"w-full h-full flex justify-center items-center",children:h[O.Id]&&h[O.Id].status!=="failed"?Z(h[O.Id]?.status):s.jsx("button",{className:"text-gray-900 hover:!text-blue-500 disabled:!text-gray-300 flex justify-center items-center bg-transparent border-none",onClick:()=>R(O.Id,`${O.Path}/${O.Name}`,O?.model_type||""),children:s.jsxs("svg",{viewBox:"0 0 1071 1024",className:"w-5 h-5",fill:"currentColor",children:[s.jsx("path",{d:"M1022.955204 522.570753c0 100.19191-81.516572 181.698249-181.718715 181.698249l-185.637977 0c-11.2973 0-20.466124-9.168824-20.466124-20.466124 0-11.307533 9.168824-20.466124 20.466124-20.466124l185.637977 0c77.628008 0 140.786467-63.148226 140.786467-140.766001 0-77.423347-62.841234-140.448776-140.203182-140.766001-0.419556 0.030699-0.818645 0.051165-1.217734 0.061398-5.945409 0.143263-11.686157-2.292206-15.687284-6.702656-4.001127-4.400217-5.894244-10.335393-5.167696-16.250102 1.330298-10.806113 1.944282-19.760043 1.944282-28.192086 0-60.763922-23.658839-117.884874-66.617234-160.833035-42.968627-42.968627-100.089579-66.617234-160.843268-66.617234-47.368844 0-92.742241 14.449084-131.208321 41.781592-37.616736 26.738991-65.952084 63.700811-81.925894 106.884332-2.425236 6.538927-8.012488 11.399631-14.827707 12.893658-6.815219 1.483794-13.927197-0.603751-18.859533-5.54632-19.289322-19.330254-44.943608-29.972639-72.245418-29.972639-56.322773 0-102.146425 45.813419-102.146425 102.125959 0 0.317225 0.040932 0.982374 0.092098 1.627057 0.061398 0.920976 0.122797 1.831718 0.153496 2.762927 0.337691 9.465582-5.863545 17.928325-15.001669 20.455891-32.356942 8.933463-61.541635 28.550243-82.181721 55.217602-21.305235 27.516704-32.571836 60.508096-32.571836 95.41307 0 86.244246 70.188572 156.422585 156.443052 156.422585l169.981393 0c11.2973 0 20.466124 9.15859 20.466124 20.466124 0 11.2973-9.168824 20.466124-20.466124 20.466124l-169.981393 0c-108.828614 0-197.3753-88.536452-197.3753-197.354833 0-44.053332 14.223956-85.712127 41.126676-120.473839 22.809495-29.460985 53.897537-52.086285 88.710414-64.816215 5.065366-74.322729 67.149353-133.2447 142.751215-133.2447 28.386514 0 55.504128 8.217149 78.651314 23.52581 19.657712-39.868009 48.842405-74.169233 85.497233-100.212376 45.434795-32.295544 99.004875-49.354058 154.918325-49.354058 71.692832 0 139.087778 27.915793 189.782368 78.600149 50.694589 50.694589 78.610382 118.089535 78.610382 189.782368 0 3.704368-0.102331 7.470135-0.296759 11.368932C952.633602 352.568894 1022.955204 429.511287 1022.955204 522.570753z","p-id":"4439"}),s.jsx("path",{d:"M629.258611 820.711014l-102.023628 102.013395c-3.990894 4.001127-9.230222 5.996574-14.46955 5.996574s-10.478655-1.995447-14.46955-5.996574l-102.023628-102.013395c-7.992021-7.992021-7.992021-20.947078 0-28.939099s20.947078-8.002254 28.939099 0l67.087954 67.077721 0-358.699522c0-11.2973 9.15859-20.466124 20.466124-20.466124 11.307533 0 20.466124 9.168824 20.466124 20.466124l0 358.699522 67.087954-67.077721c7.992021-8.002254 20.947078-7.992021 28.939099 0S637.250632 812.718993 629.258611 820.711014z","p-id":"4440"})]})})}),fixed:"right"}];return _?s.jsxs("div",{className:"mt-4 w-full h-auto flex-1 min-h-0 overflow-y-auto",children:[d&&s.jsx("h3",{className:"text-xl text-gray-900 font-bold",children:g==="zh"?lp:cp}),s.jsx(ec,{id:"comfyui-copilot-model-download",loading:r,columns:Y,dataSource:u,pagination:c?void 0:!1,rowClassName:"text-gray-800",locale:{emptyText:s.jsx(rc,{})}}),s.jsx(so,{open:!!I&&I!=="",onClose:()=>L(null),children:s.jsx("p",{children:I})})]}):null},hp=o=>{const{onClose:u}=o,[r,d]=b.useState(!1),[c,h]=b.useState([]),m=b.useRef(null);b.useEffect(()=>{m?.current?.focus()},[c]);const g=async S=>{d(!0);try{ht.trackEvent({event_type:"model_search",message_type:"model",data:{keyword:S}});const C=await(await fetch(`/api/model-searchs?keyword=${S}`)).json();h(C?.data?.searchs||[])}catch(v){console.log("e--->",v)}finally{d(!1)}},_=S=>{g(S.target.value)};return s.jsx("div",{id:"comfyui-copilot-model-download-modal",className:"fixed inset-0 bg-[rgba(0,0,0,0.5)] flex items-center justify-center",style:{backgroundColor:"rgba(0,0,0,0.5)"},children:s.jsxs("div",{className:"relative bg-white rounded-xl p-6 w-1/2 h-3/4 flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsx("h2",{className:"text-xl text-gray-900 font-semibold",children:"Model Download"}),s.jsx("button",{onClick:u,disabled:r,className:"bg-white border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ln,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex justify-start mb-2",children:s.jsx(Is,{ref:m,placeholder:"Enter search name",allowClear:!0,disabled:r,onChange:Un.debounce(_,500),className:"search-input w-1/4 bg-white text-[#888] placeholder-gray-500 border border-gray-300"})}),s.jsx(fp,{modelList:c,loading:r,showTitle:!1})]})})};var mn=(o=>(o.START_POP_VIEW_AUTO_TIME="auto_time",o.START_POP_VIEW_ACCEPT_TIME="accept_time",o.MODELS_POP_VIEW_TIME="models_time",o.MODELS_POP_VIEW_SELECTED="models_selected",o.MODELS_POP_VIEW_LIST="models_list",o))(mn||{});const Ir=o=>localStorage.getItem(o),jr=(o,u)=>{localStorage.setItem(o,u)},mp=({className:o})=>s.jsxs("svg",{className:o,viewBox:"0 0 1024 1024",fill:"currentColor",children:[s.jsx("path",{d:"M928 576h-96.32V365.333333l86.826667-86.613333c12.48-12.48 12.48-32.746667 0.106666-45.226667-12.586667-12.586667-32.853333-12.48-45.333333-0.106666L786.453333 320H237.226667l-86.933334-86.613333c-12.48-12.48-32.746667-12.48-45.226666 0.106666-12.48 12.48-12.48 32.746667 0.106666 45.226667l87.146667 86.933333V576H96c-17.706667 0-32 14.293333-32 32s14.293333 32 32 32h96.32v29.653333c-0.213333 1.493333-0.32 2.986667-0.32 4.48 0 50.24 13.546667 97.493333 37.546667 138.986667l-92.053334 92.16c-12.48 12.48-12.48 32.746667 0 45.226667 6.293333 6.293333 14.4 9.386667 22.613334 9.386666s16.426667-3.093333 22.613333-9.386666l85.12-85.226667c58.773333 64.106667 146.346667 104.96 244.16 104.96 97.813333 0 185.493333-40.853333 244.16-104.96l85.226667 85.333333c6.293333 6.293333 14.4 9.386667 22.613333 9.386667s16.426667-3.093333 22.613333-9.386667c12.48-12.48 12.48-32.746667 0-45.226666l-92.16-92.266667c23.893333-41.493333 37.44-88.746667 37.44-138.986667 0-1.493333-0.106667-2.986667-0.32-4.48V640H928c17.706667 0 32-14.293333 32-32s-14.293333-32-32-32zM543.573333 904.533333c0.32-1.706667 0.426667-3.413333 0.426667-5.226666V544c0-17.706667-14.293333-32-32-32s-32 14.293333-32 32v355.413333c0 1.813333 0.106667 3.52 0.426667 5.226667-124.8-13.973333-222.08-109.76-224.426667-226.133333 0.213333-1.386667 0.32-2.773333 0.32-4.16V384h511.36v290.24c0 1.386667 0.106667 2.773333 0.213333 4.16-2.24 116.373333-99.52 212.16-224.32 226.133333z"}),s.jsx("path",{d:"M352 256h320c10.24 0 19.733333-4.8 25.813333-13.013333 5.973333-8.213333 7.786667-18.773333 4.8-28.48C674.453333 124.48 597.76 64 512 64c-85.866667 0-162.453333 60.48-190.506667 150.506667-3.093333 9.706667-1.28 20.266667 4.8 28.48 5.973333 8.213333 15.466667 13.013333 25.706667 13.013333z m160-128c43.84 0 84.48 24.533333 110.08 64H401.92c25.6-39.466667 66.24-64 110.08-64z"})]}),gp=({className:o})=>s.jsxs("svg",{className:o,viewBox:"0 0 1024 1024",fill:"currentColor",children:[s.jsx("path",{d:"M512.82 958.87c-25.38 0-49.1-12-63.45-32.21l-20.95-29.43a8 8 0 0 0-6.41-2.79l-319.1 1.72C46.17 896.16 0 852 0 797.7V165.3c0-54.3 46.17-98.45 102.91-98.45l256.13-1.72c50 0 97.12 18.21 132.6 51.28A182.32 182.32 0 0 1 512.9 140a184.56 184.56 0 0 1 21.06-23.31c35.55-33.21 82.65-51.51 132.63-51.51h254.7c56.74 0 102.91 44.17 102.91 98.46V796c0 54.29-46.17 98.45-102.91 98.45H603.63a8 8 0 0 0-6.42 2.79l-20.94 29.43c-14.35 20.16-38.07 32.2-63.45 32.2z m-409.91-822c-18.15 0-32.91 12.76-32.91 28.45V797.7c0 15.69 14.76 28.46 32.91 28.46l319.1-1.72c25.38 0 49.1 12 63.45 32.2l20.94 29.44c1.84 2.58 5.38 2.79 6.42 2.79s4.57-0.21 6.41-2.79l21-29.44c14.35-20.16 38.06-32.2 63.45-32.2h317.61c18.15 0 32.91-12.76 32.91-28.45v-632.4c0-15.69-14.76-28.46-32.91-28.46h-254.7c-65.49 0-118.77 48.76-118.77 108.68v461a35 35 0 1 1-70 0v-461c0-28.76-12-55.82-33.9-76.19-22.48-21-52.62-32.49-84.88-32.49z"}),s.jsx("path",{d:"M362.52 330.46H197.37a35 35 0 0 1 0-70h165.15a35 35 0 0 1 0 70zM298.32 482.71h-101a35 35 0 0 1 0-70h101a35 35 0 0 1 0 70zM828.16 330.46H663.02a35 35 0 0 1 0-70h165.14a35 35 0 0 1 0 70zM828.16 482.71H727.21a35 35 0 0 1 0-70h100.95a35 35 0 0 1 0 70z"})]}),pp=({className:o})=>s.jsx("svg",{className:o,viewBox:"0 0 1024 1024",fill:"currentColor",children:s.jsx("path",{d:"M820.376748 284.430361v228.885113a20.509419 20.509419 0 0 0 41.018838 0V249.974538a19.689042 19.689042 0 0 0-2.871319-9.434333v-2.050942a21.739984 21.739984 0 0 0-5.332449-5.332448L423.314402 2.630948a20.509419 20.509419 0 0 0-20.09923 0L10.254709 232.336438a13.946405 13.946405 0 0 0-4.92226 4.92226v2.461131a16.407535 16.407535 0 0 0-5.332449 10.254709v533.244886a8.203767 8.203767 0 0 0 2.46113 2.871319l2.871319 2.871319 392.960462 229.295301a20.09923 20.09923 0 0 0 20.099231 0l196.890419-100.085964a20.919607 20.919607 0 0 0 8.203768-27.892809 20.509419 20.509419 0 0 0-27.89281-8.613956l-164.075349 87.780312v-243.651894l189.917217-102.136905a20.509419 20.509419 0 0 0 11.075086-18.048289V383.695948zM41.018837 287.30168l184.17458 105.8286V615.452379l2.461131 3.281507a11.075086 11.075086 0 0 0 3.281507 2.871319l157.512335 91.882196v252.676038L41.018837 762.710006z m351.941625 210.016448v172.279117l-126.748207-75.88485v-176.381L394.191028 492.395867a22.150172 22.150172 0 0 0-1.230566 3.281507z m20.919608-41.018838l-137.413106-82.037675 146.43725-85.72937L574.263724 369.339355z m0-410.188374l382.295564 205.094187L615.282561 347.189183l-182.944015-98.855399a20.509419 20.509419 0 0 0-20.09923 0L235.448127 351.701255 61.118068 249.974538z m180.072696 549.242233l-159.973466 86.139559v-185.815334-3.691695l160.383654-86.139559zM1066.489773 841.876362a20.509419 20.509419 0 0 0-29.123375 0l-98.035021 95.984079v-229.295301a20.509419 20.509419 0 0 0-41.018837 0v229.295301l-95.98408-95.984079a20.509419 20.509419 0 0 0-29.123375 0 20.509419 20.509419 0 0 0 0 28.713186l131.26028 131.26028a20.919607 20.919607 0 0 0 28.713186 0l131.26028-131.26028a20.509419 20.509419 0 0 0 2.050942-28.713186z"})}),oc=b.forwardRef(({input:o,loading:u,onChange:r,onSend:d,onKeyPress:c,onUploadImages:h,uploadedImages:m,onRemoveImage:g,selectedModel:_,onModelChange:S,onStop:v,onAddDebugMessage:C},I)=>{const{state:L,dispatch:A}=gn(),{messages:B}=L,[R,z]=b.useState([]),Z=b.useRef(null),[Y,$]=b.useState(!1);b.useEffect(()=>{const p=Z.current;if(!p)return;const K=()=>{requestAnimationFrame(()=>{const pe=p.style.cssText;p.style.height="auto",p.style.minHeight="auto",p.style.cssText=pe})},te=new ResizeObserver(K);te.observe(p);const F=new MutationObserver(K);return F.observe(p,{childList:!0,subtree:!0,characterData:!0}),K(),()=>{te.disconnect(),F.disconnect()}},[]),b.useLayoutEffect(()=>{Z.current&&(Z.current.style.height="auto",Z.current.style.height=`${Math.min(Z.current.scrollHeight,400)}px`)},[o]);const O=p=>{const K=Ir(mn.MODELS_POP_VIEW_SELECTED);K&&p.findIndex(te=>te.name===K)!==-1?S(K):S(p[0].name),jr(mn.MODELS_POP_VIEW_LIST,JSON.stringify(p)),z(p)},U=async()=>{$(!0);try{const p=await ht.listModels();O(p.models)}catch(p){console.error("Failed to load models:",p),O([{label:"gemini-2.5-flash",name:"gemini-2.5-flash",image_enable:!0},{label:"gpt-4.1-mini",name:"gpt-4.1-mini-2025-04-14-GlobalStandard",image_enable:!0},{label:"gpt-4.1",name:"gpt-4.1-2025-04-14-GlobalStandard",image_enable:!0}])}$(!1)};b.useImperativeHandle(I,()=>({refreshModels:U}),[]),b.useEffect(()=>{const p=new Date().getTime(),K=Ir(mn.MODELS_POP_VIEW_TIME);if(Number(K)&&p-Number(K)<1e3*60*60*24){const te=Ir(mn.MODELS_POP_VIEW_LIST);te&&O(JSON.parse(te));return}jr(mn.MODELS_POP_VIEW_TIME,new Date().getTime().toString()),U()},[]);const V=()=>{if(ht.trackEvent({event_type:"debug_icon_click",message_type:"debug",data:{}}),C){B?.[0]?.role==="showcase"&&A({type:"CLEAR_MESSAGES"});const p={id:at(),role:"ai",content:JSON.stringify({text:"Would you like me to help you debug the current workflow on the canvas?",ext:[]}),format:"debug_guide",name:"Assistant"};C(p)}},J=p=>{p==="reload"?U():S(p)};return s.jsxs("div",{className:`relative ${m.length>0?"mt-12":""}`,children:[m.length>0&&s.jsx("div",{className:"absolute -top-10 left-0 grid grid-cols-3 gap-2 w-1/2",children:m.map(p=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:p.preview,alt:"uploaded",className:"w-full h-12 object-contain"}),p?.url&&p?.url!==""?s.jsx("button",{onClick:()=>g(p.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:s.jsx(Ln,{className:"w-3 h-3"})}):s.jsx(sc,{})]},p.id))}),s.jsxs("div",{className:"w-full flex flex-row justify-end p-1 gap-2",children:[s.jsx(eo,{buttonClass:`rounded-md bg-white border-none 
                                hover:!bg-gray-100`,buttonContent:s.jsx(pp,{className:"h-5 w-5"}),onOpen:()=>{ht.trackEvent({event_type:"model_download_icon_click",message_type:"ui",data:{}})},renderModal:p=>s.jsx(hp,{onClose:p})}),s.jsx(eo,{buttonClass:`rounded-md bg-white border-none 
                                hover:!bg-gray-100`,buttonContent:s.jsx(gp,{className:"h-5 w-5"}),renderModal:p=>s.jsx(sp,{onClose:p})}),s.jsx("button",{onClick:V,className:`rounded-md bg-white border-none 
                                hover:!bg-gray-100`,children:s.jsx(mp,{className:"h-5 w-5"})})]}),s.jsx("textarea",{ref:Z,onChange:r,onKeyDown:p=>{if(p.key==="Enter"&&!p.shiftKey){if(p.nativeEvent.isComposing)return;p.preventDefault(),o.trim()!==""&&d()}c(p)},value:o,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"}}),s.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:[s.jsxs("div",{className:"border-r border-gray-100 flex flex-row justify-center pr-2",children:[s.jsx("button",{className:`${Y?"text-gray-200":"text-gray-500"} transition-all hover:!text-gray-600`,onClick:U,disabled:Y,children:s.jsx(Mg,{className:`w-4 h-4 transition-transform ${Y?"animate-spin":""}`})}),s.jsx("select",{value:_,disabled:Y,onChange:p=>J(p.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:R?.map(p=>s.jsx("option",{value:p.name,children:p.label},p.name))})]}),s.jsx(eo,{buttonClass:`p-1.5 text-gray-500 bg-white border-none
                        hover:!bg-gray-100 hover:!text-gray-600 
                        transition-all duration-200 outline-none
                        ${R?.find(p=>p.name===_)?.image_enable?"":"opacity-50 cursor-not-allowed"}`,buttonContent:s.jsx(Tg,{className:"h-4 w-4"}),renderModal:p=>s.jsx(ip,{onUploadImages:h,uploadedImages:m,onRemoveImage:g,onClose:p})})]}),s.jsx("button",{type:"submit",onClick:u?v:d,disabled:u?!1:o.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?s.jsx(Pg,{className:"h-5 w-5 text-red-500 hover:text-red-600"}):s.jsx(Dg,{className:"h-5 w-5 group-hover:translate-x-1"})})]})});oc.displayName="ChatInput";function xp(o){const u=o[0],r=new Set;function d(c,h){if(!(!c||h>=1)&&c.inputs)for(const m of Object.values(c.inputs)){const g=m.link;if(g&&$e.graph.links[g]){const _=$e.graph.links[g].origin_id,S=$e.graph._nodes_by_id[_];S&&(r.add(S.type),d(S,h+1))}}}return u?(d(u,0),[{type:"upstream_node_types",data:Array.from(r)}]):null}function yp({nodeInfo:o,onSendWithIntent:u,loading:r,onSendWithContent:d}){return console.log("SelectedNodeInfo nodeInfo:",o[0]),s.jsx("div",{className:"mb-3 p-3 rounded-md bg-gray-50 border border-gray-200",children:s.jsxs("div",{className:"text-sm text-gray-700",children:[s.jsxs("p",{children:["Selected node: ",o[0].type]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.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 ${o[0].type} node work? I need its official usage guide.`),disabled:r,children:"Usage"}),s.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 ${o[0].type} node's inputs and outputs.`),disabled:r,children:"Parameters"}),s.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",xp(o)),disabled:r,children:"Downstream Nodes"})]})]})})}function bp(){return s.jsx(tc,{name:"Assistant",children:s.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex space-x-1",children:[s.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),s.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),s.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const _p=({children:o,className:u,borderClassName:r})=>{const d=Og();return s.jsx("div",{className:"sticky w-full",children:s.jsxs("div",{className:`relative ${u||""} ${d?"beautify-card-dark":"beautify-card-light"}`,children:[s.jsx("div",{className:`card-border ${r||""}`}),o]})})},wp=2,vp=[s.jsxs("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:[s.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:"currentColor","p-id":"27396"}),s.jsx("path",{d:"M256 277.333333m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z",fill:"currentColor","p-id":"27397"}),s.jsx("path",{d:"M768 768m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z",fill:"currentColor","p-id":"27398"}),s.jsx("path",{d:"M234.666667 512h42.666666v106.666667h-42.666666z",fill:"currentColor","p-id":"27399"}),s.jsx("path",{d:"M256 448l-64 85.333333h128z",fill:"currentColor","p-id":"27400"}),s.jsx("path",{d:"M426.666667 256h106.666666v42.666667h-106.666666z",fill:"currentColor","p-id":"27401"}),s.jsx("path",{d:"M597.333333 277.333333l-85.333333-64v128z",fill:"currentColor","p-id":"27402"}),s.jsx("path",{d:"M746.666667 448h42.666666v106.666667h-42.666666z",fill:"currentColor","p-id":"27403"}),s.jsx("path",{d:"M768 618.666667l64-85.333334h-128z",fill:"currentColor","p-id":"27404"})]}),s.jsxs("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:[s.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:"currentColor","p-id":"11651"}),s.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:"currentColor","p-id":"11652"})]}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.jsx("path",{d:"M800 960 224 960c-52.928 0-96-43.072-96-96L128 224c0-52.928 43.072-96 96-96l448 0c17.696 0 32 14.336 32 32s-14.304 32-32 32L224 192C206.368 192 192 206.368 192 224l0 640c0 17.664 14.368 32 32 32l576 0c17.664 0 32-14.336 32-32L832 352c0-17.664 14.304-32 32-32s32 14.336 32 32l0 512C896 916.928 852.928 960 800 960zM612 448c-8.192 0-16.384-3.136-22.624-9.376-12.512-12.512-12.512-32.736 0-45.248l318.016-318.016c12.512-12.512 32.736-12.512 45.248 0s12.512 32.736 0 45.248l-318.016 318.016C628.384 444.896 620.192 448 612 448zM480 448 288 448c-17.664 0-32-14.336-32-32s14.336-32 32-32l192 0c17.664 0 32 14.336 32 32S497.664 448 480 448zM672 640 288 640c-17.664 0-32-14.304-32-32s14.336-32 32-32l384 0c17.696 0 32 14.304 32 32S689.696 640 672 640z",fill:"currentColor","p-id":"17265"})}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.jsx("path",{d:"M812.8 204.8c-6.4-12.8-12.8-25.6-25.6-32L633.6 70.4c-6.4 0-12.8-6.4-19.2-6.4-25.6-6.4-51.2 6.4-70.4 32l-384 595.2c-6.4 12.8-12.8 25.6-12.8 38.4l19.2 185.6v12.8c6.4 12.8 12.8 25.6 32 25.6h25.6l166.4-70.4c12.8-6.4 25.6-12.8 32-25.6l384-595.2c12.8-19.2 12.8-38.4 6.4-57.6z m-224-44.8c6.4-12.8 19.2-12.8 32-12.8l6.4 6.4 96 64c12.8 6.4 19.2 25.6 6.4 38.4l-38.4 57.6-140.8-96 38.4-57.6zM384 787.2l-19.2 19.2-96 51.2c-6.4 0-12.8 6.4-19.2 0-12.8 0-19.2-12.8-19.2-25.6v-115.2c0-12.8 6.4-19.2 12.8-32L512 275.2l140.8 89.6L384 787.2zM256 249.6s-6.4 0-6.4 6.4l-25.6 19.2c-6.4 12.8-19.2 19.2-38.4 19.2h-6.4l-32-6.4c-6.4 0-6.4 0-6.4 6.4-6.4 6.4-6.4 12.8 0 12.8l25.6 25.6c12.8 12.8 19.2 25.6 12.8 44.8v38.4H192l19.2-25.6c19.2-12.8 32-19.2 44.8-19.2h38.4c6.4 0 12.8-6.4 12.8-12.8 0 0 0-6.4-6.4-6.4l-25.6-19.2c-6.4-12.8-12.8-25.6-12.8-44.8V256s0-6.4-6.4-6.4c6.4 0 0 0 0 0zM697.6 691.2c-6.4 0-6.4 0-6.4 6.4l-25.6 32c-12.8 12.8-32 25.6-51.2 25.6H576c-6.4 0-6.4 0-12.8 6.4s-6.4 12.8 0 19.2l32 25.6c12.8 12.8 25.6 25.6 25.6 51.2v38.4c0 6.4 0 6.4 6.4 6.4h6.4c6.4 0 6.4 0 6.4-6.4l25.6-32c12.8-12.8 25.6-25.6 44.8-25.6h38.4c6.4 0 6.4 0 12.8-6.4s6.4-12.8 0-19.2l-32-25.6c-12.8-12.8-19.2-25.6-25.6-44.8V704c0-6.4 0-6.4-6.4-6.4 6.4-6.4 6.4-6.4 0-6.4zM812.8 435.2c-6.4 0-6.4 6.4-6.4 6.4v25.6c0 12.8-6.4 25.6-19.2 38.4l-25.6 19.2-6.4 6.4v6.4l6.4 6.4h32c12.8 0 25.6 6.4 32 19.2l12.8 25.6 6.4 6.4c6.4 0 6.4-6.4 6.4-6.4v-25.6c0-12.8 6.4-25.6 19.2-32l19.2-19.2 6.4-6.4c0-6.4-6.4-12.8-6.4-12.8h-25.6c-12.8 0-25.6-6.4-32-19.2l-12.8-25.6c0-12.8-6.4-12.8-6.4-12.8z","p-id":"43213"})}),s.jsxs("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:[s.jsx("path",{d:"M256 85.333333h85.333333v85.333334H256V85.333333zM426.666667 469.333333h170.666666v85.333334h-170.666666v-85.333334zM597.333333 640h-170.666666v85.333333h170.666666v-85.333333z","p-id":"36367"}),s.jsx("path",{d:"M682.666667 170.666667h-85.333334v85.333333h-170.666666V170.666667H341.333333v85.333333H256v128H170.666667V298.666667H85.333333v85.333333h85.333334v85.333333h85.333333v85.333334H85.333333v85.333333h170.666667v85.333333H170.666667v85.333334H85.333333v85.333333h85.333334v-85.333333h85.333333v128h512v-128h85.333333v85.333333h85.333334v-85.333333h-85.333334v-85.333334h-85.333333v-85.333333h170.666667v-85.333333h-170.666667v-85.333334h85.333333V384h85.333334V298.666667h-85.333334v85.333333h-85.333333V256h-85.333333V170.666667zM341.333333 853.333333V341.333333h341.333334v512H341.333333z","p-id":"36368"}),s.jsx("path",{d:"M682.666667 170.666667V85.333333h85.333333v85.333334h-85.333333z","p-id":"36369"})]}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.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:"currentColor","p-id":"24974"})}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.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:"currentColor","p-id":"26245"})}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.jsx("path",{d:"M625.7664 886.6816V739.5328h147.1488L625.7664 886.6816z m-398.2336 23.552V113.7664h568.9344v568.9344H625.7664c-31.4368 0-56.9344 25.3952-56.9344 56.9344V910.336l-341.2992-0.1024zM796.4672 56.9344H227.5328c-31.4368 0-56.9344 25.3952-56.9344 56.9344V910.336c0 31.4368 25.3952 56.9344 56.9344 56.9344h374.6816c15.0528 0 29.5936-6.0416 40.2432-16.6912l40.2432-40.2432 113.7664-113.7664 40.2432-40.2432c10.6496-10.6496 16.6912-25.1904 16.6912-40.2432V113.7664c-0.1024-31.4368-25.4976-56.832-56.9344-56.832zM654.2336 227.5328H369.7664c-15.6672 0-28.4672 12.6976-28.4672 28.4672 0 15.6672 12.6976 28.4672 28.4672 28.4672h284.4672c15.6672 0 28.4672-12.6976 28.4672-28.4672 0-15.6672-12.8-28.4672-28.4672-28.4672m0 113.7664H369.7664c-15.6672 0-28.4672 12.6976-28.4672 28.4672 0 15.6672 12.6976 28.4672 28.4672 28.4672h284.4672c15.6672 0 28.4672-12.6976 28.4672-28.4672 0-15.6672-12.8-28.4672-28.4672-28.4672M540.4672 455.0656H369.7664c-15.6672 0-28.4672 12.6976-28.4672 28.4672 0 15.6672 12.6976 28.4672 28.4672 28.4672h170.7008c15.6672 0 28.4672-12.6976 28.4672-28.4672 0-15.6672-12.8-28.4672-28.4672-28.4672",fill:"currentColor","p-id":"20502"})}),s.jsx("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16",fill:"currentColor",children:s.jsx("path",{d:"M812.885333 302.08v227.370667a42.666667 42.666667 0 1 0 85.333334 0V302.08q0-74.197333-52.48-126.634667-52.48-52.48-126.634667-52.48H264.405333q-74.154667 0-126.634666 52.48Q85.333333 227.925333 85.333333 302.08v454.698667q0 74.197333 52.48 126.634666 52.394667 52.394667 126.506667 52.48h341.12a42.666667 42.666667 0 1 0 0-85.333333H372.053333l278.058667-261.76 38.954667 38.784a42.666667 42.666667 0 0 0 60.16-60.501333L681.045333 499.2a42.666667 42.666667 0 0 0-59.306666-0.853333L248.32 849.792Q170.666667 842.112 170.666667 756.778667V302.08q0-38.826667 27.477333-66.304 27.434667-27.434667 66.261333-27.434667h454.698667q93.781333 0 93.781333 93.738667z m-369.408 68.224q0-110.890667-110.848-110.890667-45.952 0-78.421333 32.469334-32.426667 32.469333-32.426667 78.421333 0 45.909333 32.426667 78.378667 32.469333 32.469333 78.421333 32.469333 45.909333 0 78.378667-32.469333 32.469333-32.469333 32.469333-78.378667z m-136.405333 0q0-25.557333 25.557333-25.557333 25.514667 0 25.514667 25.557333 0 25.514667-25.514667 25.514667-25.557333 0-25.557333-25.514667z m464.213333 427.221333q-14.890667 0-28.416-6.101333a42.666667 42.666667 0 0 0-56.405333 56.448q18.688 41.429333 56.917333 66.133333 38.186667 24.661333 83.669334 24.661334 63.914667 0 109.098666-45.226667Q981.333333 848.341333 981.333333 784.426667q0-45.482667-24.661333-83.669334-24.704-38.229333-66.133333-56.917333a42.666667 42.666667 0 0 0-56.448 56.405333q6.101333 13.525333 6.101333 28.373334 0 28.586667-20.181333 48.768t-48.768 20.181333z","p-id":"22383",fill:"currentColor"})})],kp=({scrollRef:o})=>{const{dispatch:u,showcasIng:r}=gn(),{showcase_title:d,showcase_subtitle:c,showcase_list:h}=Lr(),m=(S,v=!1,C=()=>{})=>{let I=0;const L=at(),A=(B=!1)=>{if(!r.current)return;I+=wp;const z=typeof S=="string"?S:S?.text||"",Z=v?{id:L,role:"user",content:z.slice(0,I)}:{id:L,role:"ai",content:I>z.length&&S?.ext?JSON.stringify({text:z.slice(0,I),ext:S?.ext}):JSON.stringify({text:z.slice(0,I)}),finished:I>z.length,format:"markdown",name:"Assistant"};u({type:B?"ADD_MESSAGE":"UPDATE_MESSAGE",payload:Z}),I<=z.length?setTimeout(()=>{A()},10):setTimeout(()=>{C()},500)};A(!0)},g=(S,v)=>{u({type:"SET_LOADING",payload:!0}),m(S,!0,v)},_=(S,v)=>{u({type:"SET_LOADING",payload:!1}),m(S,!1,v)};return s.jsx(tc,{name:"showcase",children:s.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[s.jsx("div",{className:"text-xl text-gray-900 font-extrabold text-center mb-2",children:d}),s.jsx("div",{className:"w-full mb-4 flex justify-center items-center",children:s.jsx(ro,{children:c})}),h?.map((S,v)=>s.jsx("div",{onClick:()=>{o?.current&&(o.current.scrollTop=o.current.scrollHeight),r.current=!0;const C=S.messages||[];let I=0;const L=()=>{if(I<C.length){const A=C[I];A.role==="user"?g(A.content,L):_(JSON.parse(A.content||"{}")||"",L),I++}};setTimeout(L,100)},children:s.jsxs(_p,{className:"min-h-[50px] flex flex-row items-center mt-4 px-4 py-2 rounded-full mx-[1px] my-[1px]",borderClassName:"rounded-full",children:[s.jsx("div",{className:"text-[#4fabdb]",children:vp[v]}),s.jsx("div",{className:"flex-1 text-sm text-gray-700 font-normal ml-4",children:S.name})]})},v.toString()))]})})},ac=(o,u,r)=>{const d=new Map;for(const c of o)d.set(c[r],{...c});for(const c of u){const h=c[r];d.set(h,{...d.get(h)??{},...c})}return Array.from(d.values())},jn=o=>o!==null&&typeof o=="object"&&!Array.isArray(o),Sp=o=>`https://ui-avatars.com/api/?name=${o||"User"}&background=random`,Sr=b.lazy(()=>sn(()=>import(getImportPath("message-components-DwkOoCr5.js")).then(o=>o.L),__vite__mapDeps([0,1,2])).then(o=>({default:o.AIMessage}))),Ip=b.lazy(()=>sn(()=>import(getImportPath("message-components-DwkOoCr5.js")).then(o=>o.U),__vite__mapDeps([0,1,2])).then(o=>({default:o.UserMessage}))),Cp=b.lazy(()=>sn(()=>import(getImportPath("WorkflowOption-BNm2RO52.js")),__vite__mapDeps([3,2,1,0,4,5,6,7])).then(o=>({default:o.WorkflowOption}))),jp=b.lazy(()=>sn(()=>import(getImportPath("message-components-DwkOoCr5.js")).then(o=>o.N),__vite__mapDeps([0,1,2])).then(o=>({default:o.NodeSearch}))),Lp=b.lazy(()=>sn(()=>import(getImportPath("message-components-DwkOoCr5.js")).then(o=>o.O),__vite__mapDeps([0,1,2])).then(o=>({default:o.DownstreamSubgraphs}))),Np=b.lazy(()=>sn(()=>import(getImportPath("message-components-DwkOoCr5.js")).then(o=>o.Q),__vite__mapDeps([0,1,2])).then(o=>({default:o.NodeInstallGuide}))),Ap=b.lazy(()=>sn(()=>import(getImportPath("DebugGuide-Bc3pTp8l.js")),__vite__mapDeps([8,2,1,0])).then(o=>({default:o.DebugGuide}))),Ul=b.lazy(()=>sn(()=>import(getImportPath("DebugResult-BJrSKJkE.js")),__vite__mapDeps([9,2,1,0,4,5,6,7])).then(o=>({default:o.DebugResult}))),Ep=3;function Mp({messages:o,latestInput:u,onOptionClick:r,installedNodes:d,onAddMessage:c,onUpdateMessage:h,loading:m,isActive:g}){const[_,S]=b.useState(0),[v,C]=b.useState([]),I=b.useRef(null),L=b.useRef(0),A=b.useRef(0),B=b.useRef(0),R=b.useRef(0),z=b.useRef(0),Z=b.useRef(!1),Y=b.useRef(new Set),$=b.useRef(!1);b.useEffect(()=>{o.length<Y.current.size/2&&Y.current.clear()},[o]);const O=p=>{const K=[...p];for(let te=0;te<K.length;te++){const F=K[te];if((F.role==="ai"||F.role==="tool")&&F.content&&F.finished)try{const pe=JSON.parse(F.content);if(pe.ext){console.log(`[MessageList] Processing AI message ${te} with ext:`,pe.ext);const he=pe.ext.find(de=>de.type==="workflow_rewrite_checkpoint"||de.type==="debug_checkpoint"&&de.data?.checkpoint_type==="workflow_rewrite_start"),ae=pe.ext.find(de=>de.type==="workflow_rewrite_complete");if(he&&te>0){const de=K[te-1];if(console.log("[MessageList] Found checkpoint ext:",he),console.log("[MessageList] Previous message role:",de.role),de.role==="user"){const q=[...de.ext||[],he];K[te-1]={...de,ext:q},console.log("[MessageList] Associated checkpoint to user message:",K[te-1])}}if(ae){const de={...pe};de.ext=pe.ext.filter(ie=>ie.type!=="workflow_rewrite_checkpoint"&&!(ie.type==="debug_checkpoint"&&ie.data?.checkpoint_type==="workflow_rewrite_start")),K[te]={...F,content:JSON.stringify(de)}}}}catch(pe){console.warn("[MessageList] Failed to parse AI message content:",pe)}}return K};b.useEffect(()=>{const p=I.current;if(!p)return;const K=()=>{requestAnimationFrame(()=>{Z.current?p.scrollTop=p.scrollHeight-z.current:(A.current<p.scrollHeight&&A.current-B.current-R.current<1&&(p.scrollTop=p.scrollHeight-p.clientHeight),A.current=p.scrollHeight,B.current=p.scrollTop,R.current=p.clientHeight)})},te=new ResizeObserver(K);te.observe(p);const F=new MutationObserver(K);F.observe(p,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),K();const pe=()=>{p.scrollHeight<A.current&&A.current>0||(Z.current?p.scrollHeight>A.current?(p.scrollTop=p.scrollHeight-z.current,A.current=p.scrollHeight):(Z.current=!1,A.current=p.scrollHeight,z.current=p.scrollHeight):(A.current<p.scrollHeight&&A.current-B.current-R.current<1&&(p.scrollTop=p.scrollHeight-p.clientHeight),A.current=p.scrollHeight,B.current=p.scrollTop,R.current=p.clientHeight,z.current=p.scrollHeight))};return p.addEventListener("scroll",pe),()=>{te.disconnect(),F.disconnect(),p.removeEventListener("scroll",pe)}},[]);const U=(p,K)=>{if(console.log("[MessageList] Rendering message:",p),p.role==="user")return s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Ip,{content:p.content,trace_id:p.trace_id,ext:p.ext,finished:p.finished})},p.id);if(p.role==="showcase")return s.jsx(kp,{scrollRef:I},"showcase");if(p.role==="ai"||p.role==="tool"){const te=Sp(p.role);try{const F=JSON.parse(p.content),pe=F.ext?.find(H=>H.type==="workflow"),he=F.ext?.find(H=>H.type==="node"),ae=F.ext?.find(H=>H.type==="downstream_subgraph_search"),de=F.ext?.find(H=>H.type==="node_install_guide"),ie=F.ext?.find(H=>H.type==="param_update"),q=F.ext?.find(H=>H.type==="workflow_update"),Be=F.ext?.find(H=>H.type==="debug_checkpoint"),se=F.ext?.find(H=>H.type==="workflow_update_complete"),re=F.text==="The workflow has been successfully loaded to the canvas";if(q&&q.data){const{workflow_data:H}=q.data;if(typeof window<"u"&&window.app&&H){const xe=JSON.stringify(H).slice(0,100),ue=`workflow_update_${p.id}_${xe}`;if(!Y.current.has(ue)){const Pe=async(fe=0)=>{try{const{applyNewWorkflow:Ce}=await sn(async()=>{const{applyNewWorkflow:Me}=await import(getImportPath("message-components-DwkOoCr5.js")).then(Ne=>Ne.K);return{applyNewWorkflow:Me}},__vite__mapDeps([0,1,2]));Ce(H)?(console.log("[MessageList] Successfully applied workflow update"),Y.current.add(ue)):(console.warn(`[MessageList] Failed to apply workflow update (attempt ${fe+1})`),fe<2?setTimeout(()=>{Pe(fe+1)},1e3*(fe+1)):console.error("[MessageList] Workflow update failed after 3 attempts"))}catch(Ce){console.error(`[MessageList] Error in workflow update (attempt ${fe+1}):`,Ce),fe<2&&setTimeout(()=>{Pe(fe+1)},1e3*(fe+1))}};Pe()}}}if(ie&&ie.data){const{changes:H}=ie.data;if(typeof window<"u"&&window.app&&H){const xe=JSON.stringify(H).slice(0,100),ue=`param_update_${p.id}_${xe}`;if(!Y.current.has(ue)){const Pe=async(fe=0)=>{try{const{applyParameterChanges:Ce}=await sn(async()=>{const{applyParameterChanges:Ne}=await import(getImportPath("message-components-DwkOoCr5.js")).then(We=>We.K);return{applyParameterChanges:Ne}},__vite__mapDeps([0,1,2])),Oe=Array.isArray(H)?H:[H];Ce(Oe)?(console.log(`[MessageList] Successfully applied ${Oe.length} parameter changes`),Y.current.add(ue)):(console.warn(`[MessageList] Failed to apply parameter changes, changes is ${JSON.stringify(Oe)}, (attempt ${fe+1})`),fe<2?setTimeout(()=>{Pe(fe+1)},1e3*(fe+1)):console.error("[MessageList] Parameter update failed after 3 attempts"))}catch(Ce){console.error(`[MessageList] Error in parameter update (attempt ${fe+1}):`,Ce),fe<2&&setTimeout(()=>{Pe(fe+1)},1e3*(fe+1))}};Pe()}}}if(F.ext&&p.finished){const H=F.ext.find(xe=>xe.data&&xe.data.checkpoint_id&&(xe.type==="debug_checkpoint"||xe.type==="workflow_rewrite_complete"||xe.type==="workflow_update_complete"));if(H&&H.data?.checkpoint_id){const xe=H.data.checkpoint_id,ue=`save_workflow_ui_${p.id}_${xe}`;if(!Y.current.has(ue)){const Pe=async(fe=0)=>{try{if(typeof window<"u"&&window.app){const Ce=window.app;if(Ce.graph){const Me=(await Ce.graphToPrompt()).workflow;if(Me){const We=await(await fetch("/api/update-workflow-ui",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({checkpoint_id:xe,workflow_data_ui:Me})})).json();We.success?(console.log(`[MessageList] Successfully saved workflow UI for checkpoint ${xe}`),Y.current.add(ue)):(console.warn(`[MessageList] Failed to save workflow UI for checkpoint ${xe}: ${We.message}`),fe<2?setTimeout(()=>{Pe(fe+1)},1e3*(fe+1)):console.error(`[MessageList] Save workflow UI failed after 3 attempts for checkpoint ${xe}`))}}}}catch(Ce){console.error(`[MessageList] Error saving workflow UI (attempt ${fe+1}):`,Ce),fe<2&&setTimeout(()=>{Pe(fe+1)},1e3*(fe+1))}};Pe()}}}let _e=null;if(pe)_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Cp,{content:p.content,name:p.name,avatar:te,latestInput:u,installedNodes:d,onAddMessage:c})},`workflow_option_${p.id}`);else if(he)_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(jp,{content:p.content,name:p.name,avatar:te,installedNodes:d})},`node_search_${p.id}`);else if(ae){const H=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Lp,{content:p.content,name:p.name,avatar:te,onAddMessage:c})},`down_stream_subgraph_${p.id}`);if(p.metadata?.intent==="downstream_subgraph_search")return s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Sr,{content:p.content,name:p.name,avatar:te,format:p.format,onOptionClick:r,extComponent:H,metadata:p.metadata,finished:p.finished,debugGuide:p.debugGuide})},p.id);_e=H}else de?_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Np,{content:p.content,onLoadSubgraph:()=>{if(p.metadata?.pendingSubgraph){const H=Object.values($e.canvas.selected_nodes)[0];if(H){const xe=p.metadata.pendingSubgraph,ue=xe.json.nodes,Pe=xe.json.links,fe=ue.find(Me=>Me.id===0),Ce=fe?.id,Oe={};Ce&&(Oe[Ce]=H),$e.canvas.emitBeforeChange();try{for(const Me of ue)if(Me.id!==Ce){const Ne=fe?.pos||[0,0],We=H._pos||[0,0],mt=[Me.pos[0]+We[0]-Ne[0],Me.pos[1]+We[1]-Ne[1]];Oe[Me.id]=Fg(Me.type,{pos:mt})}}finally{$e.canvas.emitAfterChange()}for(const Me of Pe){const Ne=Oe[Me.origin_id],We=Oe[Me.target_id];Ne&&We&&Ne.connect(Me.origin_slot,We,Me.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(p.metadata?.pendingWorkflow){const H=p.metadata.pendingWorkflow,xe=p.metadata.optimizedParams;if(H.nodes)$e.loadGraphData(H);else{$e.loadApiJson(H);const Pe=Object.keys(H),fe=Object.keys($e.graph._nodes_by_id)[0],Ce=$e.graph._nodes_by_id[fe],Oe=Ce?Ce.pos[0]:0,Me=Ce?Ce.pos[1]:0,Ne=250,We=60,mt=20,Je=60,kt=50,Ht=1e3;let lt=Oe,ct=Me,Rt=0;for(const St of Pe){const Re=$e.graph._nodes_by_id[St];if(Re){Rt>Ht&&(lt+=Ne+Je,Rt=0,ct=Me);const yt=Re.inputs?Re.inputs.length:0,Q=Re.outputs?Re.outputs.length:0,je=Re.widgets?Re.widgets.length:0,tt=Math.max(yt,Q)+je,gt=mt*tt+We;Re.size[0]=Ne,Re.size[1]=gt,Re.pos[0]=lt,Re.pos[1]=ct,Rt+=gt+kt,ct+=gt+kt}}}for(const[Pe,fe,Ce,Oe,Me]of xe){const Ne=$e.graph._nodes_by_id[Pe].widgets;for(const We of Ne)We.name===Oe&&(We.value=Me)}$e.graph.setDirtyCanvas(!1,!0);const ue={id:at(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};c?.(ue)}}})},`node_install_guide_${p.id}`):re||p.format==="debug_guide"?_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Ap,{content:p.content,name:p.name,avatar:te,onAddMessage:c,onUpdateMessage:h,messageId:p.id})},`debug_guide_${p.id}`):Be?p.finished&&(_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Ul,{content:p.content,name:p.name,avatar:te,format:p.format})},p.id)):(q||ie)&&p.finished&&(_e=s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Ul,{content:p.content,name:p.name,avatar:te,format:p.format})},`debug_result_${p.id}`));return(re||p.format==="debug_guide")&&_e||Be&&p.finished&&_e||(q||ie)&&p.finished&&_e?_e:F.text||_e?s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Sr,{content:p.content,name:p.name,avatar:te,format:p.format,onOptionClick:r,extComponent:_e,metadata:p.metadata,finished:p.finished,debugGuide:p.debugGuide})},p.id):_e||s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Sr,{content:p.content,name:p.name,avatar:te,format:p.format,onOptionClick:r,metadata:p.metadata,finished:p.finished,debugGuide:p.debugGuide})},p.id)}catch{return s.jsx(b.Suspense,{fallback:s.jsx("div",{children:"Loading..."}),children:s.jsx(Sr,{content:p.content,name:p.name,avatar:te,format:p.format,onOptionClick:r,metadata:p.metadata,finished:p.finished,debugGuide:p.debugGuide})},p.id)}}return null},V=()=>{Z.current=!0,S(p=>p+1)},J=b.useMemo(()=>O(o),[o]);return b.useEffect(()=>{let p=[];if(L.current>0&&L.current<J.length)J?.[L.current-1]?.role==="user"?p=J?.slice(L.current-1):p=J?.slice(L.current),C(K=>ac(K,p,"id")),p?.[p?.length-1].finished&&(L.current=J.length);else{let K=0,te=J?.length-1;$.current=!1;for(let F=J?.length-1;F>=0;F--)if(te=F,(J[F].role==="user"||J[F].role==="showcase"||J[F].format==="debug_guide")&&(K++,F>0&&K>=Ep+_)){$.current=!0;break}C([...J.slice(te,J?.length)]),L.current=J.length}},[J,_]),b.useLayoutEffect(()=>{},[v]),s.jsxs("div",{className:"flex-1 flex-col overflow-y-auto p-4 h-0",ref:I,style:{display:g?"flex":"none"},children:[$.current&&s.jsx("div",{className:"flex justify-center items-center",children:s.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:V,children:"Load more"})},"loadmore"),v?.map((p,K)=>!!p&&U(p)),m&&s.jsx(bp,{})]})}function Tp(o=!0){b.useEffect(()=>{if(!o)return;const u=Un.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)}},[o])}function Pp(o=!0){const{state:u,dispatch:r}=gn(),{activeTab:d,screenState:c}=u;b.useEffect(()=>{if(!o)return;const h=m=>{const g=d==="parameter-debug",_=d==="chat";//!screenState || screenState.currentScreen === 0;
if(_||g){const S=$e.canvas.selected_nodes;Object.keys(S??{}).length?r({type:"SET_SELECTED_NODE",payload:Object.values(S)}):r({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[r,o,d,c])}const Dp=({selectedNodes:o,handleParamSelect:u,selectedParams:r,handleNext:d,handleClose:c})=>{const m=o.flatMap(g=>(g.widgets||[]).map(_=>_.name)).some(g=>r[g]===!0);return s.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select parameters"}),s.jsx("p",{className:"text-xs text-gray-500",children:"multiple selections supported"})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:c,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.map((g,_)=>{const S=g.title||"Unknown Node",v=g.widgets||[];return s.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[s.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:S}),s.jsx("div",{className:"p-4 space-y-3",children:s.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:v.map((C,I)=>{const L=C.name;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${r[L]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:A=>u(L,A),children:r[L]&&s.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),s.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:L})]},`widget-${I}`)})})})]},`node-${_}`)}),s.jsx("div",{className:"mt-6 flex justify-center",children:s.jsx("button",{onClick:g=>d(g),disabled:!m,className:`px-3 py-1.5 text-xs ${m?"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"})})]})},Op=({selectedNodes:o,paramTestValues:u,selectedParams:r,updateParamTestValues:d,toggleDropdown:c,openDropdowns:h,handleTestValueSelect:m,searchTerms:g,handleSearch:_,handleSelectAll:S,handleNext:v,handlePrevious:C,handleClose:I,inputValues:L,updateState:A,textInputs:B,handleTextInputChange:R,handleAddTextInput:z,handleRemoveTextInput:Z,openAiWritingModal:Y})=>{const $=(O,U,V,J=0)=>{if(O=isNaN(O)?0:O,U=isNaN(U)?100:U,V=isNaN(V)||V<=0?1:V,U<O&&(U=O),Math.floor((U-O)/V)+1<=1)return[O];const K=[];let te=O;for(;te<=U;){const F=Math.pow(10,J),pe=Math.round(te*F)/F;K.push(pe),te+=V}return K};return b.useEffect(()=>{!o||o.length===0||o.forEach(O=>{const U=O.id.toString(),V=O.widgets||{};Object.values(V).forEach(p=>{const K=p.name;if(!r[K])return;if(!(u[U]?.[K]?.length>0)&&p.type==="number"){const F=p.options?.min||0,pe=p.options?.max||100;let he=(p.options?.step||10)/10;he<.1&&(he=.1);const ae=p.options?.precision||0,de=$(F,pe,he,ae);if(de.length>0){d(U,K,de);const ie=`${U}_${K}`;A(Ie.InputValues,{...L,[ie]:{min:F.toString(),max:pe.toString(),step:he.toString()}})}}if(p.type==="customtext"||p.type.toLowerCase().includes("text")){const F=`${U}_${K}`,pe=B[F]||[""];JSON.stringify(pe)!==JSON.stringify(u[U]?.[K]||[""])&&d(U,K,pe)}})})},[o,r,u,B,d,$]),s.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Set test values"}),s.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:I,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.length>0?o.map((O,U)=>{const V=O.widgets||{},J=Object.values(V),p=O.id;return s.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[s.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:[s.jsxs("span",{children:[O.type," (ID: ",p,")"]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:K=>I(K,U),children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("div",{className:"p-4 space-y-4",children:J.map((K,te)=>{const F=K.name;if(!r[F])return null;const pe=`${p}_${F}`;if(K.type==="customtext"||K.type.toLowerCase().includes("text")){const he=B[pe]||[""];return s.jsxs("div",{className:"border-b pb-3",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[F,":"]}),s.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>Y(p,F),children:[s.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"]})]}),s.jsx("div",{className:"space-y-2",children:he.map((ae,de)=>s.jsxs("div",{className:"flex items-start",children:[s.jsx("textarea",{className:`flex-1 border ${ae?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:ae,onChange:ie=>R(p,F,de,ie.target.value),required:!0}),s.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>Z(p,F,de),title:"Remove",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},de))}),s.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(p,F),children:[s.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},te)}if(K.type==="number"){const he=K.options?.min||0,ae=K.options?.max||100,de=(K.options?.step||10)/10,ie=K.options?.precision||0,q=$(he,ae,de,ie),Be=L[pe]||{min:he.toString(),max:ae.toString(),step:de.toString()};return s.jsxs("div",{className:"border-b pb-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[F,":"]}),s.jsx("div",{className:"w-4"})]}),s.jsxs("div",{className:"flex space-x-2 items-center",children:[s.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),s.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:Be.min,required:!0,onClick:se=>{se.preventDefault(),se.stopPropagation()},onChange:se=>{se.preventDefault(),se.stopPropagation();const re=se.target.value;if(A(Ie.InputValues,{...L,[pe]:{...L[pe],min:re}}),re===""||!isNaN(parseFloat(re))){const _e=re===""?0:parseFloat(re),H=parseFloat(Be.max||ae.toString()),xe=parseFloat(Be.step||de.toString()),ue=$(_e,H,xe,ie);d(p,F,ue)}}}),s.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),s.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:Be.max,onClick:se=>{se.preventDefault(),se.stopPropagation()},required:!0,onChange:se=>{se.preventDefault(),se.stopPropagation();const re=se.target.value;if(A(Ie.InputValues,{...L,[pe]:{...L[pe],max:re}}),re===""||!isNaN(parseFloat(re))){const _e=parseFloat(Be.min||he.toString()),H=re===""?_e:parseFloat(re),xe=parseFloat(Be.step||de.toString()),ue=$(_e,H,xe,ie);d(p,F,ue)}}}),s.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),s.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:Be.step,required:!0,onClick:se=>{se.preventDefault(),se.stopPropagation()},onChange:se=>{se.preventDefault(),se.stopPropagation();const re=se.target.value;if(A(Ie.InputValues,{...L,[pe]:{...L[pe],step:re}}),re===""||!isNaN(parseFloat(re))&&parseFloat(re)>0){const _e=parseFloat(Be.min||he.toString()),H=parseFloat(Be.max||ae.toString());let xe=re===""?1:parseFloat(re);xe<.1&&(xe=.1);const ue=$(_e,H,xe,ie);d(p,F,ue)}}})]}),s.jsxs("div",{className:"mt-1",children:[s.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(()=>{const se=u[p]?.[F]||q;if(se.length<=10)return se.map((re,_e)=>s.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:H=>{H.stopPropagation(),m(p,F,re,H)},children:[s.jsx("span",{children:re}),s.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},_e));{const re=se.slice(0,5),_e=se.slice(se.length-5);return s.jsxs(s.Fragment,{children:[re.map((H,xe)=>s.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:ue=>{ue.stopPropagation(),m(p,F,H,ue)},children:[s.jsx("span",{children:H}),s.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`first-${xe}`)),s.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),_e.map((H,xe)=>s.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:ue=>{ue.stopPropagation(),m(p,F,H,ue)},children:[s.jsx("span",{children:H}),s.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`last-${xe}`))]})}})()})]}),s.jsx("div",{className:"mt-1",children:s.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max"})})]},te)}else if(K.type==="combo"){const he=K.options?.values||[],ae=`${p}_${F}`,de=q=>typeof q=="string"?q:q&&typeof q=="object"&&"name"in q?q.name:String(q),ie=q=>typeof q=="object"&&q!==null&&"name"in q?q.name:q;return s.jsxs("div",{className:"border-b pb-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("label",{className:"text-xs font-medium text-gray-700",children:F}),s.jsxs("div",{className:"relative dropdown-container",children:[s.jsxs("button",{className:`appearance-none border ${(u[p]?.[F]||[]).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:q=>{q.preventDefault(),q.stopPropagation(),c(p,F,q)},"data-dropdown":ae,children:[s.jsx("span",{children:(u[p]?.[F]||[]).length>0?`${F}: ${(u[p]?.[F]||[]).length} selected`:`Select ${F}`}),s.jsx("div",{className:"ml-2",children:s.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:s.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[ae]&&s.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[ae]=="object"?`${h[ae].y}px`:"0px",left:typeof h[ae]=="object"?`${h[ae].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[s.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:s.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:g[ae]||"",onChange:q=>{q.preventDefault(),q.stopPropagation(),_(p,F,q.target.value)},onClick:q=>{q.preventDefault(),q.stopPropagation()},autoFocus:!0})}),s.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:q=>{q.preventDefault(),q.stopPropagation();const se=he.filter(re=>!g[ae]||de(re).toLowerCase().includes((g[ae]||"").toLowerCase())).map(ie);S(p,F,se)},children:[s.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${he.length>0&&(u[p]?.[F]||[]).length===he.length?"bg-blue-500 border-blue-500":(u[p]?.[F]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(u[p]?.[F]||[]).length>0&&s.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("span",{className:"font-medium",children:he.length>0&&(u[p]?.[F]||[]).length===he.length?"Deselect All":"Select All"})]}),s.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[he.filter(q=>!g[ae]||de(q).toLowerCase().includes((g[ae]||"").toLowerCase())).map((q,Be)=>s.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:se=>{se.preventDefault(),se.stopPropagation(),m(p,F,ie(q),se)},children:[s.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(u[p]?.[F]||[]).includes(ie(q))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(u[p]?.[F]||[]).includes(ie(q))&&s.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:de(q)})]},Be)),he.filter(q=>!g[ae]||de(q).toLowerCase().includes((g[ae]||"").toLowerCase())).length===0&&s.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),(u[p]?.[F]||[]).length===0&&s.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(u[p]?.[F]||[]).map((q,Be)=>s.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[s.jsx("span",{children:q}),s.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:se=>{se.preventDefault(),se.stopPropagation(),m(p,F,q,se)},children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},Be))})]})]},te)}else return s.jsxs("div",{className:"border-b pb-3",children:[s.jsx("div",{className:"flex justify-between items-center",children:s.jsx("label",{className:"text-xs font-medium text-gray-700",children:F})}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(u[p]?.[F]||[]).map((he,ae)=>s.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[s.jsx("span",{children:he}),s.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:de=>{de.preventDefault(),de.stopPropagation(),m(p,F,he,de)},children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},ae)),s.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:he=>{he.preventDefault(),he.stopPropagation();const ae=`${F}${(u[p]?.[F]||[]).length+1}`;d(p,F,[...u[p]?.[F]||[],ae])},children:[s.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),s.jsx("span",{children:"Add"})]})]})]})]},te)})})]},U)}):s.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."}),s.jsxs("div",{className:"mt-6 flex justify-between",children:[s.jsx("button",{onClick:O=>C(O),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),s.jsx("button",{onClick:O=>v(O),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},Fp=({selectedNodes:o,paramTestValues:u,selectedParams:r,totalCount:d,errorMessage:c,handlePrevious:h,handleStartGeneration:m,handleClose:g})=>{const[_,S]=b.useState([]),[v,C]=b.useState(null),[I,L]=b.useState(!1),{dispatch:A}=gn(),B=()=>{const z=Object.values($e.graph._nodes_by_id),Z=[],Y=[];for(const O of z)O.type==="SaveImage"?Z.push(O.id):O.type==="PreviewImage"&&Y.push(O.id);const $=[...Z,...Y];S($),$.length===1?C($[0]):$.length>1&&(L(!0),C(null))};b.useEffect(()=>{B()},[]),b.useEffect(()=>{if(o?.length>0){const z=o?.find(Z=>Z.type==="SaveImage"||Z.type==="PreviewImage");z&&C(z.id)}},[o]);const R=z=>{if(z&&(z.preventDefault(),z.stopPropagation()),_.length>1&&!v){L(!0);return}console.log("selectedImageNodeId-->",v),m(z,v||void 0)};return s.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Conform combinations"}),s.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."]})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:g,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),I&&_.length>1&&s.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-600 text-xs",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.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"})})}),s.jsx("div",{className:"ml-2",children:v===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${_.join(",")}. Please click the node on canvas.`:`Current node ID is ${v}, please click Start Generation again`})]})}),c&&s.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.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"})})}),s.jsx("div",{className:"ml-2",children:c})]})}),o.length>0?o.map((z,Z)=>{const Y=z.type||"Unknown Node",$=z.widgets||[],O=z.id;return s.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[s.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[Y," (ID: ",O,")"]}),s.jsx("div",{className:"p-4 space-y-3",children:$.map((U,V)=>{const J=U.name;if(!r[J])return null;const p=u[O]?.[J]||[],K=Array.isArray(p)?`[${p.join(", ")}]`:JSON.stringify(p);return s.jsxs("div",{className:V<$.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[s.jsx("label",{className:"font-medium text-gray-700 text-xs",children:J}),s.jsx("div",{className:"flex space-x-2 items-center",children:s.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-xs px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:K,onClick:te=>te.preventDefault()})})]},V)})})]},Z)}):s.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."}),s.jsxs("div",{className:"mt-6 flex justify-between",children:[s.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"}),s.jsx("button",{onClick:z=>R(z),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${_.length>1&&!v?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:_.length>1&&!v,children:"Generate & Compare"})]})]})},Rp=({selectedNodes:o,paramTestValues:u,selectedParams:r,totalCount:d,completedCount:c,errorMessage:h,handleClose:m,updateState:g,cleanupPolling:_})=>{const S=v=>{v.preventDefault(),v.stopPropagation(),Rg({clear:!0}),zg(),_&&_(),g(Ie.IsProcessing,!1),g(Ie.CurrentScreen,2)};return s.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[s.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:s.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[s.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),s.jsxs("div",{className:"text-xs mb-3",children:["Completed ",c," of ",d," runs"]}),s.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${c/d*100}%`}})}),s.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",c," images"]}),s.jsx("button",{onClick:S,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"})]})}),s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),s.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."]})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:m,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&s.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.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"})})}),s.jsx("div",{className:"ml-2",children:h})]})}),o.length>0?o.map((v,C)=>{const I=v.type||"Unknown Node",L=v.widgets||[],A=v.id;return s.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[s.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[I," (ID: ",A,")"]}),s.jsx("div",{className:"p-4 space-y-3",children:L.map((B,R)=>{const z=B.name;if(!r[z])return null;const Z=u[A]?.[z]||[],Y=Array.isArray(Z)?`[${Z.join(", ")}]`:JSON.stringify(Z);return s.jsxs("div",{className:R<L.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[s.jsx("label",{className:"font-medium text-gray-700",children:z}),s.jsx("div",{className:"flex space-x-2 items-center",children:s.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-sm px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:Y,onClick:$=>$.preventDefault()})})]},R)})})]},C)}):s.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."})]})},js=({visible:o,imageUrl:u,params:r,onClose:d})=>{if(!o)return null;const c=()=>{if(!r||!r.nodeParams)return null;const h=Object.entries(r.nodeParams).map(([m,g])=>{const _=r.nodeNames?.[m]||r.selectedNodeInfoMap&&r.selectedNodeInfoMap[m]||(m.includes("text")?"Text Node":`Node ${m}`),S=Object.entries(g).filter(([v,C])=>typeof C!="object"||C===null).map(([v,C])=>s.jsxs("div",{className:"pl-4 text-sm py-1 flex",children:[s.jsx("span",{className:"text-gray-600 dark:text-gray-400 mr-2",children:"-"}),s.jsxs("span",{className:"font-medium mr-1",children:[v,":"]}),s.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-all",children:String(C)})]},v));return s.jsxs("div",{className:"mb-4",children:[s.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:_}),S.length>0?S:s.jsx("div",{className:"pl-4 text-sm text-gray-500 italic",children:"nodeParams is null"})]},m)});return s.jsx("div",{className:"overflow-y-auto max-h-full",children:h.length>0?h:s.jsx("div",{className:"text-sm text-gray-500 italic",children:"nodeParams is null"})})};return s.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",onClick:d,children:s.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:[s.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:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),s.jsx("div",{className:"w-[65%] border-r border-gray-200 dark:border-gray-700",children:s.jsx("div",{className:"p-4 h-full flex items-center justify-center",children:s.jsx("img",{src:u,alt:"Enlarged image",className:"max-w-full max-h-[calc(90vh-2rem)] object-contain"})})}),s.jsx("div",{className:"w-[35%] h-full overflow-hidden flex flex-col",children:s.jsxs("div",{className:"p-4 flex-1 overflow-y-auto",children:[s.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,m])=>h!=="nodeParams"&&typeof m!="object").map(([h,m])=>s.jsxs("div",{className:"py-1 text-sm text-gray-600 dark:text-gray-300",children:[s.jsxs("span",{className:"font-medium",children:[h,":"]})," ",String(m)]},h)),s.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:c()})]})})]})})};function is(o,u,r){let d=r.initialDeps??[],c;function h(){var m,g,_,S;let v;r.key&&((m=r.debug)!=null&&m.call(r))&&(v=Date.now());const C=o();if(!(C.length!==d.length||C.some((A,B)=>d[B]!==A)))return c;d=C;let L;if(r.key&&((g=r.debug)!=null&&g.call(r))&&(L=Date.now()),c=u(...C),r.key&&((_=r.debug)!=null&&_.call(r))){const A=Math.round((Date.now()-v)*100)/100,B=Math.round((Date.now()-L)*100)/100,R=B/16,z=(Z,Y)=>{for(Z=String(Z);Z.length<Y;)Z=" "+Z;return Z};console.info(`%c⏱ ${z(B,5)} /${z(A,5)} ms`,`
            font-size: .6rem;
            font-weight: bold;
            color: hsl(${Math.max(0,Math.min(120-120*R,120))}deg 100% 31%);`,r?.key)}return(S=r?.onChange)==null||S.call(r,c),c}return h.updateDeps=m=>{d=m},h}function Bl(o,u){if(o===void 0)throw new Error("Unexpected undefined");return o}const zp=(o,u)=>Math.abs(o-u)<1.01,Up=(o,u,r)=>{let d;return function(...c){o.clearTimeout(d),d=o.setTimeout(()=>u.apply(this,c),r)}},Wl=o=>{const{offsetWidth:u,offsetHeight:r}=o;return{width:u,height:r}},Bp=o=>o,Wp=o=>{const u=Math.max(o.startIndex-o.overscan,0),r=Math.min(o.endIndex+o.overscan,o.count-1),d=[];for(let c=u;c<=r;c++)d.push(c);return d},Gp=(o,u)=>{const r=o.scrollElement;if(!r)return;const d=o.targetWindow;if(!d)return;const c=m=>{const{width:g,height:_}=m;u({width:Math.round(g),height:Math.round(_)})};if(c(Wl(r)),!d.ResizeObserver)return()=>{};const h=new d.ResizeObserver(m=>{const g=()=>{const _=m[0];if(_?.borderBoxSize){const S=_.borderBoxSize[0];if(S){c({width:S.inlineSize,height:S.blockSize});return}}c(Wl(r))};o.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(g):g()});return h.observe(r,{box:"border-box"}),()=>{h.unobserve(r)}},Gl={passive:!0},$l=typeof window>"u"?!0:"onscrollend"in window,$p=(o,u)=>{const r=o.scrollElement;if(!r)return;const d=o.targetWindow;if(!d)return;let c=0;const h=o.options.useScrollendEvent&&$l?()=>{}:Up(d,()=>{u(c,!1)},o.options.isScrollingResetDelay),m=v=>()=>{const{horizontal:C,isRtl:I}=o.options;c=C?r.scrollLeft*(I&&-1||1):r.scrollTop,h(),u(c,v)},g=m(!0),_=m(!1);_(),r.addEventListener("scroll",g,Gl);const S=o.options.useScrollendEvent&&$l;return S&&r.addEventListener("scrollend",_,Gl),()=>{r.removeEventListener("scroll",g),S&&r.removeEventListener("scrollend",_)}},Vp=(o,u,r)=>{if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d)return Math.round(d[r.options.horizontal?"inlineSize":"blockSize"])}return o[r.options.horizontal?"offsetWidth":"offsetHeight"]},qp=(o,{adjustments:u=0,behavior:r},d)=>{var c,h;const m=o+u;(h=(c=d.scrollElement)==null?void 0:c.scrollTo)==null||h.call(c,{[d.options.horizontal?"left":"top"]:m,behavior:r})};class Hp{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(c=>{c.forEach(h=>{const m=()=>{this._measureElement(h.target,h)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(m):m()})}));return{disconnect:()=>{var c;(c=d())==null||c.disconnect(),r=null},observe:c=>{var h;return(h=d())==null?void 0:h.observe(c,{box:"border-box"})},unobserve:c=>{var h;return(h=d())==null?void 0:h.unobserve(c)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([d,c])=>{typeof c>"u"&&delete r[d]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Bp,rangeExtractor:Wp,onChange:()=>{},measureElement:Vp,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,c;(c=(d=this.options).onChange)==null||c.call(d,this,r)},this.maybeNotify=is(()=>(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(c=>{this.observer.observe(c)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,c=>{this.scrollRect=c,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(c,h)=>{this.scrollAdjustments=0,this.scrollDirection=h?this.getScrollOffset()<c?"forward":"backward":null,this.scrollOffset=c,this.isScrolling=h,this.maybeNotify()}))}},this.getSize=()=>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 c=new Map,h=new Map;for(let m=d-1;m>=0;m--){const g=r[m];if(c.has(g.lane))continue;const _=h.get(g.lane);if(_==null||g.end>_.end?h.set(g.lane,g):g.end<_.end&&c.set(g.lane,!0),c.size===this.options.lanes)break}return h.size===this.options.lanes?Array.from(h.values()).sort((m,g)=>m.end===g.end?m.index-g.index:m.end-g.end)[0]:void 0},this.getMeasurementOptions=is(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(r,d,c,h,m)=>(this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:d,scrollMargin:c,getItemKey:h,enabled:m}),{key:!1}),this.getMeasurements=is(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:d,scrollMargin:c,getItemKey:h,enabled:m},g)=>{if(!m)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(v=>{this.itemSizeCache.set(v.key,v.size)}));const _=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const S=this.measurementsCache.slice(0,_);for(let v=_;v<r;v++){const C=h(v),I=this.options.lanes===1?S[v-1]:this.getFurthestMeasurement(S,v),L=I?I.end+this.options.gap:d+c,A=g.get(C),B=typeof A=="number"?A:this.options.estimateSize(v),R=L+B,z=I?I.lane:v%this.options.lanes;S[v]={index:v,start:L,size:B,end:R,key:C,lane:z}}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=is(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,d,c,h)=>this.range=r.length>0&&d>0?Kp({measurements:r,outerSize:d,scrollOffset:c,lanes:h}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=is(()=>{let r=null,d=null;const c=this.calculateRange();return c&&(r=c.startIndex,d=c.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,d]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,d]},(r,d,c,h,m)=>h===null||m===null?[]:r({startIndex:h,endIndex:m,overscan:d,count:c}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const d=this.options.indexAttribute,c=r.getAttribute(d);return c?parseInt(c,10):(console.warn(`Missing attribute name '${d}={index}' on measured element.`),-1)},this._measureElement=(r,d)=>{const c=this.indexFromElement(r),h=this.measurementsCache[c];if(!h)return;const m=h.key,g=this.elementsCache.get(m);g!==r&&(g&&this.observer.unobserve(g),this.observer.observe(r),this.elementsCache.set(m,r)),r.isConnected&&this.resizeItem(c,this.options.measureElement(r,d,this))},this.resizeItem=(r,d)=>{const c=this.measurementsCache[r];if(!c)return;const h=this.itemSizeCache.get(c.key)??c.size,m=d-h;m!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(c,m,this):c.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=m,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(c.index),this.itemSizeCache=new Map(this.itemSizeCache.set(c.key,d)),this.notify(!1))},this.measureElement=r=>{if(!r){this.elementsCache.forEach((d,c)=>{d.isConnected||(this.observer.unobserve(d),this.elementsCache.delete(c))});return}this._measureElement(r,void 0)},this.getVirtualItems=is(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,d)=>{const c=[];for(let h=0,m=r.length;h<m;h++){const g=r[h],_=d[g];c.push(_)}return c},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const d=this.getMeasurements();if(d.length!==0)return Bl(d[lc(0,d.length-1,c=>Bl(d[c]).start,r)])},this.getOffsetForAlignment=(r,d,c=0)=>{const h=this.getSize(),m=this.getScrollOffset();d==="auto"&&(d=r>=m+h?"end":"start"),d==="center"?r+=(c-h)/2:d==="end"&&(r-=h);const g=this.getTotalSize()+this.options.scrollMargin-h;return Math.max(Math.min(g,r),0)},this.getOffsetForIndex=(r,d="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const c=this.measurementsCache[r];if(!c)return;const h=this.getSize(),m=this.getScrollOffset();if(d==="auto")if(c.end>=m+h-this.options.scrollPaddingEnd)d="end";else if(c.start<=m+this.options.scrollPaddingStart)d="start";else return[m,d];const g=d==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(g,d,c.size),d]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(r,{align:d="start",behavior:c}={})=>{c==="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:c})},this.scrollToIndex=(r,{align:d="auto",behavior:c}={})=>{c==="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 m=10,g=S=>{if(!this.targetWindow)return;const v=this.getOffsetForIndex(r,S);if(!v){console.warn("Failed to get offset for index:",r);return}const[C,I]=v;this._scrollToOffset(C,{adjustments:void 0,behavior:c}),this.targetWindow.requestAnimationFrame(()=>{const L=this.getScrollOffset(),A=this.getOffsetForIndex(r,I);if(!A){console.warn("Failed to get offset for index:",r);return}zp(A[0],L)||_(I)})},_=S=>{this.targetWindow&&(h++,h<m?this.targetWindow.requestAnimationFrame(()=>g(S)):console.warn(`Failed to scroll to index ${r} after ${m} attempts.`))};g(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 c;if(d.length===0)c=this.options.paddingStart;else if(this.options.lanes===1)c=((r=d[d.length-1])==null?void 0:r.end)??0;else{const h=Array(this.options.lanes).fill(null);let m=d.length-1;for(;m>=0&&h.some(g=>g===null);){const g=d[m];h[g.lane]===null&&(h[g.lane]=g.end),m--}c=Math.max(...h.filter(g=>g!==null))}return Math.max(c-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:d,behavior:c})=>{this.options.scrollToFn(r,{behavior:c,adjustments:d},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(u)}}const lc=(o,u,r,d)=>{for(;o<=u;){const c=(o+u)/2|0,h=r(c);if(h<d)o=c+1;else if(h>d)u=c-1;else return c}return o>0?o-1:0};function Kp({measurements:o,outerSize:u,scrollOffset:r,lanes:d}){const c=o.length-1,h=_=>o[_].start;if(o.length<=d)return{startIndex:0,endIndex:c};let m=lc(0,c,h,r),g=m;if(d===1)for(;g<c&&o[g].end<r+u;)g++;else if(d>1){const _=Array(d).fill(0);for(;g<c&&_.some(v=>v<r+u);){const v=o[g];_[v.lane]=v.end,g++}const S=Array(d).fill(r+u);for(;m>=0&&S.some(v=>v>=r);){const v=o[m];S[v.lane]=v.start,m--}m=Math.max(0,m-m%d),g=Math.min(c,g+(d-1-g%d))}return{startIndex:m,endIndex:g}}const Vl=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Jp(o){const u=b.useReducer(()=>({}),{})[1],r={...o,onChange:(c,h)=>{var m;h?Xl.flushSync(u):u(),(m=o.onChange)==null||m.call(o,c,h)}},[d]=b.useState(()=>new Hp(r));return d.setOptions(r),Vl(()=>d._didMount(),[]),Vl(()=>d._willUpdate()),d}function Xp(o){return Jp({observeElementRect:Gp,observeElementOffset:$p,scrollToFn:qp,...o})}const cc=o=>{const{items:u,renderItem:r,minWidth:d=200,gap:c=16}=o,h=b.useRef(null),[m,g]=b.useState(1),[_,S]=b.useState(0);b.useLayoutEffect(()=>{if(!h.current)return;const C=()=>{if(h.current){const L=h.current.offsetWidth,A=Math.max(1,Math.floor(L/(d+c/2)));g(A),S(Math.ceil(u.length/A))}};C();const I=new window.ResizeObserver(Un.debounce(C,50));return I.observe(h.current),()=>I.disconnect()},[]);const v=Xp({count:_,getScrollElement:()=>h.current,estimateSize:()=>d+40,overscan:3,gap:c});return s.jsx("div",{ref:h,className:"h-full relative overflow-auto hide-scrollbar",children:s.jsx("div",{style:{height:v.getTotalSize(),position:"relative"},children:v.getVirtualItems().map(C=>{const I=C.index,L=I*m,A=Math.min(L+m,u.length);return s.jsx("div",{"data-index":I,ref:v.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`,display:"grid",gridTemplateColumns:`repeat(${m}, minmax(${d}px, 1fr))`,gap:`${c}px`},children:u.slice(L,A).map((B,R)=>r(B,L+R))},I)})})})},Yp=({generatedImages:o,selectedImageIndex:u,handleSelectImage:r,handleApplySelected:d,handleClose:c,notificationVisible:h,modalVisible:m,modalImageUrl:g,modalImageParams:_,openImageModal:S,closeImageModal:v})=>{const C=(I,L)=>s.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${u===L?"border-2 border-green-400":"border-gray-200"}`,style:{boxShadow:u===L?"inset 0 -16px 24px 0 rgba(255, 255, 255, 0.25)":""},onClick:A=>r(L,A),children:[s.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:A=>S(I.url,I.params,A),children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("div",{className:"aspect-square",children:s.jsx("img",{src:I.url,alt:`Generated image ${L+1}`,className:"w-full h-full object-cover",onError:A=>{const B=A.target;B.onerror=null,B.src="data:image/svg+xml,%3Csvg t='1760082631200' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='4747' width='56' height='56' fill='%238a8a8a'%3E%3Cpath d='M371.2 737.536l137.728-247.808c5.376-9.472 7.936-20.224 7.936-30.976 0-19.456-8.704-37.632-24.064-49.92L222.208 192.512 437.76 1.28H118.528C53.248 1.536 0 54.784 0 120.064v783.36c0 65.536 53.248 118.784 118.784 118.784h566.528L371.2 737.536z m-252.672 211.712c-25.088 0-45.568-20.48-45.568-45.824v-783.36c0-24.832 19.712-44.8 44.288-45.568h109.312l-71.68 62.976C137.984 150.784 128.256 170.752 128.256 192.512c0 21.504 9.728 41.728 26.368 55.04l271.104 216.832-133.376 240.128c-6.144 10.752-9.216 23.296-9.216 35.84 0 21.504 9.216 41.728 25.088 55.552l168.704 153.088h-358.4z' p-id='4748'%3E%3C/path%3E%3Cpath d='M905.216 1.536H565.504c-1.792 2.048-156.16 135.936-156.16 135.936-16.896 13.312-26.624 33.28-26.624 55.04 0 21.504 9.728 41.728 26.368 55.04l271.104 216.832-133.376 240.128c-6.144 10.752-9.216 23.296-9.216 35.84 0 21.504 9.216 41.728 25.088 55.552l249.088 226.304h93.44c65.536 0 118.784-53.248 118.784-118.784v-783.36c0-65.28-53.248-118.528-118.784-118.528z m45.824 901.888c0 25.344-20.48 45.824-45.824 45.824h-47.104l-232.448-211.456 137.728-247.808c5.376-9.472 7.936-20.224 7.936-30.976 0-19.456-8.704-37.632-24.064-49.92L476.672 192.512l133.632-118.016h294.912c25.344 0 45.824 20.48 45.824 45.568v783.36z' p-id='4749'%3E%3C/path%3E%3C/svg%3E"}})}),s.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(I.params).filter(([A,B])=>A!=="nodeParams"&&typeof B!="object").map(([A,B])=>s.jsxs("div",{children:[A,": ",String(B)]},A))})]},L.toString());return s.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["All ",o.length," images have been generated."]})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:c,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&s.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:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"py-1",children:s.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),s.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(cc,{items:o,renderItem:C})}),s.jsx("div",{className:"mt-6 flex justify-end",children:s.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"})}),s.jsx(js,{visible:m,imageUrl:g,params:_||{},onClose:v})]})},Qp=({visible:o,aiWritingModalText:u,setAiWritingModalText:r,aiGeneratedTexts:d,aiSelectedTexts:c,aiWritingLoading:h,aiWritingError:m,handleAiWriting:g,toggleTextSelection:_,addSelectedTexts:S,onClose:v})=>o?s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:s.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:[s.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),s.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:v,children:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),s.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:C=>r(C.target.value)}),s.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:g,disabled:h,children:h?s.jsxs(s.Fragment,{children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.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..."]}):s.jsx(s.Fragment,{children:"Generate"})})]}),m&&s.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:m}),d.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Generated variations (select items to add):"}),s.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:d.map((C,I)=>s.jsxs("div",{className:"flex items-start border border-gray-200 dark:border-gray-600 rounded-md p-2",children:[s.jsx("div",{className:"mr-2 mt-1",children:s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"checkbox",id:`text${I+1}`,checked:!!c[`text${I+1}`],onChange:()=>_(`text${I+1}`),className:"sr-only"}),s.jsx("div",{className:`h-4 w-4 rounded border ${c[`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:()=>_(`text${I+1}`),children:c[`text${I+1}`]&&s.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),s.jsx("label",{htmlFor:`text${I+1}`,className:"text-sm text-gray-700 dark:text-gray-300 cursor-pointer flex-1",children:C})]},I))})]})]}),s.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end flex-shrink-0",children:[s.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:v,children:"Cancel"}),s.jsx("button",{className:`px-5 py-2.5 rounded-lg font-medium transition-colors ${Object.values(c).every(C=>!C)?"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:S,disabled:Object.values(c).every(C=>!C),children:"Add Selected"})]})]})}):null,no=o=>{const u=[],r={};if(Object.keys(o).forEach(h=>{const m=parseInt(h),g=o[h]||{},_=Object.keys(g).filter(v=>g[v]&&g[v].length>0);if(_.length===0)return;const S=[[]];_.forEach(v=>{const C=g[v],I=[];S.forEach(L=>{C.forEach(A=>{const B=[...L,{nodeId:m,paramName:v,paramValue:String(A)}];I.push(B)})}),S.length=0,S.push(...I)}),r[h]=S}),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 c=r[d[0]];for(let h=1;h<d.length;h++){const m=r[d[h]],g=[];c.forEach(_=>{m.forEach(S=>{g.push([..._,...S])})}),c=g}return c},Zp=(o,u)=>{const r={};r.nodeParams={};const d=no(o);return u<d.length&&d[u].forEach(h=>{const m=h.nodeId.toString(),g=h.paramName,_=h.paramValue;r.nodeParams[m]||(r.nodeParams[m]={}),r.nodeParams[m][g]=_,r[g]=_}),r},dc="parameter_debug_history",ql=30,Hl=async(o,u,r,d,c)=>{try{const h=uc(),m={id:at(),timestamp:Date.now(),title:io(o,u),nodeName:o,params:{...u,nodeNames:{...u.nodeNames||{},[o.split("<")[0]]:o.split("<")[0]}},generatedImages:r,totalCount:d,workflow:c};return h.unshift(m),h.length>ql&&h.splice(ql),localStorage.setItem(dc,JSON.stringify(h)),m}catch(h){return console.error("Error saving parameter debug history:",h),null}},uc=()=>{try{const o=localStorage.getItem(dc);if(o)return JSON.parse(o)}catch(o){console.error("Error loading parameter debug history:",o)}return[]},fc=o=>{const u=new Date(o);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")}`},io=(o,u)=>{if(u.nodeParams)return Object.entries(u.nodeParams).map(([h,m])=>{let g=o;u.selectedNodeInfoMap&&u.selectedNodeInfoMap[h]&&(g=u.selectedNodeInfoMap[h]);const _=Object.keys(m).slice(0,3);return`${g}<${_.join(",")}>`}).join(";");const r=Object.keys(u).filter(d=>d!=="nodeParams"&&d!=="selectedNodeInfoMap").slice(0,3);return`${o}<${r.join(",")}>`},e2=({historyItems:o,onViewHistoryItem:u,onClose:r})=>s.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 flex flex-col h-full",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Experiments History"}),s.jsxs("p",{className:"text-xs text-gray-500",children:["Last ",o.length," experiments"]})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:r,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500 text-sm",children:"No history items found"}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:o.map(d=>s.jsxs("div",{className:"border border-gray-200 rounded-lg mb-3 overflow-hidden",children:[s.jsxs("div",{className:"bg-gray-50 py-2 px-3 flex items-center justify-between border-b",children:[s.jsx("div",{className:"text-[14px] text-gray-600",children:fc(d.timestamp)}),s.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"})]}),s.jsx("div",{className:"p-3",children:s.jsx("div",{className:"text-[10px] font-medium text-gray-700",children:io(d.nodeName,d.params)})})]},d.id))})]}),t2=({historyItem:o,selectedImageIndex:u,handleSelectImage:r,handleClose:d,modalVisible:c,modalImageUrl:h,modalImageParams:m,openImageModal:g,closeImageModal:_})=>{const{timestamp:S,nodeName:v,generatedImages:C,params:I}=o,L=(A,B)=>s.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${u===B?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:R=>r(B,R),children:[s.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:R=>g(A.url,A.params,R),children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("div",{className:"aspect-square",children:s.jsx("img",{src:A.url,alt:`Generated image ${B+1}`,className:"w-full h-full object-cover"})}),s.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(A.params).filter(([R,z])=>R!=="nodeParams"&&typeof z!="object").map(([R,z])=>s.jsxs("div",{children:[R,": ",String(z)]},R))})]},B.toString());return s.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[s.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-start",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-gray-800 truncate hover:!break-words hover:!whitespace-normal hover:!overflow-visible",children:io(v,I)}),s.jsxs("p",{className:"text-xs text-gray-500",children:[fc(S)," • ",C.length," images"]})]}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600 mt-0",onClick:d,children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(cc,{items:C,renderItem:L})}),s.jsx(js,{visible:c,imageUrl:h,params:m?{...m,nodeNames:{[o.nodeName.split("<")[0]]:o.nodeName.split("<")[0]}}:void 0,onClose:_})]})},n2=`
  @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;
  }
`,Ls="parameter_debug_state",s2=o=>{try{localStorage.setItem(Ls,JSON.stringify(o))}catch(u){console.error("Error saving parameter debug state:",u)}},r2=()=>{try{const o=localStorage.getItem(Ls);if(o)return JSON.parse(o)}catch(o){console.error("Error loading parameter debug state:",o)}return null},i2=()=>{try{localStorage.removeItem(Ls)}catch(o){console.error("Error clearing parameter debug state:",o)}},o2=(o,u,r,d,c,h)=>{const m=`${o}_${u}`,g=[...c[m]||[]];return g[r]=d,h(Ie.TextInputs,{...c,[m]:g.map((_,S)=>S===r?d:_)}),g},a2=(o,u,r,d)=>{const c=`${o}_${u}`,h=[...r[c]||[]];return h.push(""),d(Ie.TextInputs,{...r,[c]:h}),h},l2=(o,u,r,d,c)=>{const h=`${o}_${u}`,m=[...d[h]||[]];return m.splice(r,1),c(Ie.TextInputs,{...d,[h]:m}),m},c2=(o,u,r,d,c)=>{r.preventDefault(),r.stopPropagation();const h=`${o}_${u}`;c(m=>{if(m[h]&&typeof m[h]=="object"?m[h].isOpen:!!m[h])return{...m,[h]:!1};{let _=0,S=0;if(r.currentTarget){const I=r.currentTarget.getBoundingClientRect();_=I.left,S=I.bottom}else _=r.clientX,S=r.clientY+20;const v=window.innerWidth,C=250;return _+C>v&&(_=v-C-10),_<0&&(_=10),{...m,[h]:{isOpen:!0,x:_,y:S}}}})},d2=(o,u,r,d,c)=>{const h={...d};h[o]||(h[o]={}),h[o][u]=r,c(Ie.ParamTestValues,h)},u2=(o,u,r,d,c,h)=>{h&&(h.preventDefault(),h.stopPropagation());const m={...d};m[o]||(m[o]={}),m[o][u]||(m[o][u]=[]);const g=m[o][u];g.includes(r)?m[o][u]=g.filter(_=>_!==r):m[o][u]=[...g,r],c(Ie.ParamTestValues,m)},f2=(o,u,r,d,c)=>{const h=`${o}_${u}`;c(Ie.SearchTerms,{...d,[h]:r})},h2=(o,u,r,d,c)=>{if(!d[o]){c(o,u,r);return}const h=d[o][u]||[];r.length===h.length?c(o,u,[]):c(o,u,[...r])},m2=(o,u,r,d,c)=>{c&&(c.preventDefault(),c.stopPropagation());const h=u[o];if(d(Ie.SelectedParams,{...u,[o]:!h}),h){const m={...r};Object.keys(m).forEach(g=>{m[g][o]&&delete m[g][o]}),d(Ie.ParamTestValues,m)}},g2=(o,u,r,d,c,h,m)=>{m.preventDefault(),m.stopPropagation();const g={...u};if(u.nodeParams){const _={};Object.keys(u.nodeParams).forEach(S=>{const v=r.find(C=>C.id.toString()===S);_[S]=v?v.title||`Node ${S}`:`Node ${S}`}),g.nodeNames=_}else if(Object.keys(u).length>0){const _={};Object.entries(u).forEach(([S,v])=>{(typeof v!="object"||v===null)&&(_[S]=v)}),Object.keys(_).length>0&&(g.nodeParams={default:_},g.nodeNames={default:u.node_name||u.nodeName||"参数"})}d(o),c(g),h(!0)},p2=(o,u)=>{u&&(u.preventDefault(),u.stopPropagation()),o(!1)},x2=(o,u,r,d,c,h,m,g,_)=>{if(_&&(_.preventDefault(),_.stopPropagation()),o===0){const S={...r};Object.keys(S).forEach(v=>{const C=S[v];Object.keys(C).forEach(I=>{u[I]||delete C[I]})}),g(Ie.ParamTestValues,S)}if(o===1){const S={...r};c.forEach(C=>{const I=C.id.toString(),L=C.widgets||{};Object.values(L).forEach(A=>{const B=A.name;if(u[B]&&(A.type==="customtext"||A.type.toLowerCase().includes("text"))){const R=`${I}_${B}`,z=d[R]||[""];S[I]=S[I]||{},S[I][B]=z}})}),g(Ie.ParamTestValues,S);const v=m(S);g(Ie.TotalCount,v.length)}h(null),g(Ie.CurrentScreen,Math.min(o+1,2))},y2=(o,u,r,d,c,h,m,g)=>{if(g&&(g.preventDefault(),g.stopPropagation()),h(null),c&&m(Ie.IsCompleted,!1),o===1){const _=u.map(C=>C.id.toString()),S=Object.keys(r),v={...r};S.forEach(C=>{_.includes(C)||delete v[C]}),m(Ie.ParamTestValues,v)}if(o===2||c){const _={...r};Object.entries(d).forEach(([S,v])=>{if(!v||v.length===0)return;const[C,I]=S.split("_");u.some(L=>L.id.toString()===C)&&(_[C]=_[C]||{},JSON.stringify(_[C][I])!==JSON.stringify(v)&&(_[C][I]=v))}),m(Ie.ParamTestValues,_)}m(Ie.CurrentScreen,Math.max(o-1,0))},b2=(o,u,r,d,c)=>{c&&(c.preventDefault(),c.stopPropagation()),d(Ie.CurrentPage,Math.max(1,Math.min(o,Math.ceil(r.length/u))))};function _2(o,u){try{if(!o)return console.error("Invalid prompt_output: ",o),o;for(const r of u){if(!o[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!o[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}o[r.nodeId].inputs[r.paramName]=r.paramValue}return o}catch(r){return console.error("Error updating prompt:",r),o}}async function w2(o){const u=await $e.graphToPrompt(),r=_2(u.output,o);console.log("queuePrompt updated_prompt:",r);const d={prompt:r,client_id:$e.api.clientId,extra_data:{extra_pageinfo:{workflow:u.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const c=await Ug(d);return console.debug("queuePrompt response:",c),c}function Kl(o){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,c=30,h=o.split(" ");let m="",g=250;for(let _=0;_<h.length;_++){const S=m+h[_]+" ";r.measureText(S).width>d&&_>0?(r.fillText(m,u.width/2,g),m=h[_]+" ",g+=c):m=S}r.fillText(m,u.width/2,g)}return u.toDataURL("image/png")}async function v2(o){try{if(!o||o==="")return console.log("No prompt ID provided"),{1:[Kl("Fail to generate prompt ID")]};const u=await Bg(o);if(!u||!u[o])return console.log("Not finished for prompt ID:",o),{};const r=u[o];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",o);const c=r.status.messages;if(c&&c.length>0){const h=c[c.length-1];if(h&&h.length>0){const m=h[0];return{1:[Kl(m)]}}}}const d={};if(r.outputs)for(const c in r.outputs){const h=r.outputs[c];if(h&&h.images){d[c]=[];for(const m of h.images)if(m&&m.filename&&m.type){const g=$e?.graph._nodes_by_id?.[c]?.imgs?.[0]?.currentSrc?.split("?")[0];d[c].push(g+"?filename="+encodeURIComponent(m.filename)+"&type="+encodeURIComponent(m.type)+(m.subfolder?"&subfolder="+encodeURIComponent(m.subfolder):""))}console.log("outputImages for nodeId:",c,d[c])}}return d}catch(u){throw console.error("Error getting output images from prompt:",u),u}}function k2(){const o=Object.values($e.graph._nodes_by_id),u=[],r=[];for(const d of o)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 S2(o,u){const r=await v2(o);return Object.keys(r).length===0?null:r[u.toString()]&&r[u.toString()].length>0?r[u.toString()][0]:null}const I2=async(o,u,r,d,c,h,m,g,_,S)=>{_&&(_.preventDefault(),_.stopPropagation()),mc(c,d);const v=h(o),C=v.length;if(C>100){r(`Cannot generate more than 100 images at once (currently: ${C} images)`);return}r(null),g(Ie.IsProcessing,!0),g(Ie.CompletedCount,0),console.log("Generated parameter combinations:",v);let I=null;try{I=(await m.graphToPrompt()).output}catch(R){console.error("Error capturing workflow data:",R)}if(ht.trackEvent({event_type:"start_generation",message_type:"parameter_debug",message_id:u,data:{workflow:I,all_params:o,count:C}}),v.length===0){r("No valid parameter combinations found. Please check your parameter selections."),g(Ie.IsProcessing,!1);return}let L=S||null;if(L===null){const R=k2();R!==null&&(L=R)}if(console.log("showNodeId-->",L,S),L===null){r("Please select a SaveImage or PreviewImage node first."),g(Ie.IsProcessing,!1);return}const A={};Object.keys(o).forEach(R=>{const z=m.graph._nodes_by_id[R];z&&(A[R]=z.type||z.comfyClass||"Unknown Node")});const B=[];try{const R=Date.now().toString();d.current=R;for(const V of v){const J=await w2(V);J.prompt_id?B.push(J.prompt_id):(console.error("Failed to get prompt_id from response:",J),B.push(""))}const z=Array(v.length).fill(null).map((V,J)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:Zp(o,J)}));g(Ie.GeneratedImages,z);const Z=Date.now(),Y=5*60*1e3,$=Object.keys(o)[0],O=A[$]||"Unknown Node";hc(B,L,z,R,Z,Y,d,c,g,{},O,o,C,I,A)}catch(R){console.error("Error generating images:",R),g(Ie.IsProcessing,!1)}},hc=async(o,u,r,d,c,h,m,g,_,S,v,C,I,L,A)=>{if(m.current!==d){console.log("Another polling session has started, stopping this one");return}if(Date.now()-c>h){if(console.log("Timeout reached while waiting for images"),m.current===d&&(_(Ie.IsProcessing,!1),_(Ie.IsCompleted,!0),_(Ie.CurrentPage,1),r.length>0&&v&&C)){const R=r[0].params;A&&(R.selectedNodeInfoMap=A),Hl(v,R,r,I||r.length,L)}return}let B=Object.keys(S)?.length||0;for(let R=0;R<o.length;R++){const z=o[R];if(!(!z||S[z]))try{const Z=await S2(z,Number(u));Z&&(r[R]={...r[R],url:Z},S[z]=!0,B++)}catch(Z){console.error(`Error fetching image for prompt ID ${z}:`,Z)}}if(_(Ie.GeneratedImages,[...r]),_(Ie.CompletedCount,B),B===o.length){if(console.log("All images have been generated!"),m.current===d&&(_(Ie.IsProcessing,!1),_(Ie.IsCompleted,!0),_(Ie.CurrentPage,1),r.length>0&&v&&C)){const R=r[0].params;A&&(R.selectedNodeInfoMap=A),Hl(v,R,r,I||r.length,L)}return}m.current===d&&(g.current=setTimeout(()=>{hc(o,u,r,d,c,h,m,g,_,S,v,C,I,L,A)},2e3))},mc=(o,u)=>{o.current&&(clearTimeout(o.current),o.current=null),u.current=null},C2=async(o,u,r,d,c,h)=>{if(!o.trim()){d("Please enter some text to generate variations");return}r(!0),d(null),c([]),h({});try{const m=await ht.generateSDPrompts(o);c(m),ht.trackEvent({event_type:"prompt_generate",message_type:"parameter_debug",message_id:u,data:{input_text:o,generated_texts:m}});const g={};m.forEach((_,S)=>{g[`text${S+1}`]=!1}),h(g)}catch(m){console.error("Error generating text:",m),d("Failed to generate text variations. Please try again.")}finally{r(!1)}},j2=(o,u)=>{u(r=>({...r,[o]:!r[o]}))},L2=(o,u,r,d,c,h,m,g,_,S)=>{const v=`${o}_${u}`,C=Object.entries(r).filter(([A,B])=>B).map(([A])=>{const B=parseInt(A.replace("text",""))-1;return d[B]});if(C.length===0)return;const I=[...m[v]||[]];g(Ie.TextInputs,{...m,[v]:[...I,...C]}),ht.trackEvent({event_type:"prompt_apply",message_type:"parameter_debug",message_id:h,data:{input_text:c,generated_texts:d,selected_texts:C}});const L=[...m[v]||[],...C];_(o,u,L),S(!1)},N2=(o,u,r,d,c,h,m,g,_,S)=>{r(!0),d(o),c(u),h(""),m([]),g({}),_(!1),S(null)},A2=(o,u,r,d,c,h,m,g,_,S,v,C,I,L,A,B,R,z,Z,Y,$,O,U,V,J,p,K,te,F,pe=!1)=>{o(0),u({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),r(at()),d(),c(!1),h(!1),m(0),g(12),_(null),S(Array(12).fill(null).map((he,ae)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:ae%3===0?5:ae%3===1?10:15,sampler_name:"euler",cfg:1}}))),v({}),C({}),I({}),L({}),A(1),B(null),R(!1),z(!1),Z(""),Y(null),$({}),O(!1),U(""),V([]),J(!1),p(""),K(""),te(null),F({}),pe&&i2()},E2=async(o,u,r,d,c,h,m)=>{if(m&&(m.preventDefault(),m.stopPropagation()),o!==null){console.log(`Applied image ${o+1} with parameters:`,u[o].params);let g=1;if(c){for(const S in c)if(c[S])for(const v in c[S]){const C=c[S][v];if(C){let I=1;Array.isArray(C)?I=C.length>0?C.length:1:typeof C=="object"&&C!==null&&(I=Object.keys(C).length>0?Object.keys(C).length:1),g=g*I}}}ht.trackEvent({event_type:"parameter_debug_apply",message_type:"parameter_debug",message_id:d,data:{workflow:(await r.graphToPrompt()).output,selected_params:u[o].params,all_params:c,count:g}});const _=u[o].params;_.nodeParams&&(Wg(_.nodeParams)?(console.log("[stateManagementUtils] Successfully applied selected parameters to canvas"),h(!0),setTimeout(()=>{h(!1)},3e3)):console.warn("[stateManagementUtils] Failed to apply selected parameters to canvas"))}},M2=(o,u,r,d,c,h,m)=>{if(m&&(m.preventDefault(),m.stopPropagation()),o===1&&r!==void 0){const g=[...u];g[r],g.splice(r,1),g.length===0?c&&(d({type:"SET_SCREEN_STATE",payload:null}),h(!0),c()):d({type:"SET_SELECTED_NODE",payload:g});return}c&&(d({type:"SET_SCREEN_STATE",payload:null}),h(!0),c())};var Ie=(o=>(o.CurrentScreen="currentScreen",o.SelectedParams="selectedParams",o.TaskId="task_id",o.IsProcessing="isProcessing",o.IsCompleted="isCompleted",o.CompletedCount="completedCount",o.TotalCount="totalCount",o.SelectedImageIndex="selectedImageIndex",o.GeneratedImages="generatedImages",o.ParamTestValues="paramTestValues",o.SearchTerms="searchTerms",o.InputValues="inputValues",o.CurrentPage="currentPage",o.TextInputs="textInputs",o))(Ie||{});const T2=({selectedNodes:o,visible:u,onClose:r})=>{const d=b.useRef([]),[c,h]=b.useState(0),[m,g]=b.useState({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),[_,S]=b.useState(at()),[v,C]=b.useState(!1),[I,L]=b.useState(!1),[A,B]=b.useState(0),[R,z]=b.useState(12),[Z,Y]=b.useState(null),[$,O]=b.useState(()=>Array(12).fill(null).map((T,P)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:P%3===0?5:P%3===1?10:15,sampler_name:"euler",cfg:1}}))),[U,V]=b.useState({}),[J,p]=b.useState({}),[K,te]=b.useState({}),[F,pe]=b.useState({}),[he,ae]=b.useState(1),de=6,[ie,q]=b.useState(null),[Be,se]=b.useState(!1),[re,_e]=b.useState(!1),[H,xe]=b.useState(""),[ue,Pe]=b.useState(null),[fe,Ce]=b.useState({}),[Oe,Me]=b.useState(!1),[Ne,We]=b.useState(""),[mt,Je]=b.useState([]),[kt,Ht]=b.useState(!1),[lt,ct]=b.useState(""),[Rt,St]=b.useState(""),[Re,yt]=b.useState(null),[Q,je]=b.useState({}),[tt,gt]=b.useState(!1),[It,Ct]=b.useState([]),[bt,W]=b.useState(null),{dispatch:ne}=gn(),ke=b.useRef(null),we=b.useRef(null),Ae=b.useRef(!0),[Ye,He]=b.useState(()=>u),[ze,rt]=b.useState(!1);b.useEffect(()=>{if(tt){const T=uc();Ct(T)}},[tt]);const Kt=async()=>{C2(Ne,_,Ht,yt,Je,je)},Jt=(T,P,me,Ze)=>{const jt=o2(T,P,me,Ze,fe,Qe);pn(T,P,jt)},Ns=(T,P)=>{const me=a2(T,P,fe,Qe);pn(T,P,me)},As=(T,P,me)=>{const Ze=l2(T,P,me,fe,Qe);pn(T,P,Ze)},Er=T=>{j2(T,je)},Mr=()=>{L2(lt,Rt,Q,mt,Ne,_,fe,Qe,pn,Me)},Tr=(T,P)=>{N2(T,P,Me,ct,St,We,Je,je,Ht,yt)},Es=T=>{T&&(T.preventDefault(),T.stopPropagation()),gt(P=>!P)},Ms=T=>{W(T),gt(!1),Qe("generatedImages",T.generatedImages||[]),Qe("selectedImageIndex",null),Qe("currentPage",1)},Pr=T=>{T&&(T.preventDefault(),T.stopPropagation()),W(null)},Dr=(T,P)=>{const me={currentScreen:c,selectedParams:m,task_id:_,isProcessing:v,isCompleted:I,completedCount:A,totalCount:R,selectedImageIndex:Z,generatedImages:$,paramTestValues:U,searchTerms:K,inputValues:F,currentPage:he,textInputs:fe},Ze=me[T],jt=jn(Ze)&&jn(P)?{...Ze,...P}:P;s2({...me,[T]:jt})},Qe=(T,P)=>{switch(T){case"currentScreen":h(P);break;case"selectedParams":g(me=>jn(me)&&jn(P)?{...me,...P}:P);break;case"task_id":S(P);break;case"isProcessing":C(P);break;case"isCompleted":L(P);break;case"completedCount":B(P);break;case"totalCount":z(P);break;case"selectedImageIndex":Y(P);break;case"generatedImages":O(P);break;case"paramTestValues":V(me=>jn(me)&&jn(P)?{...me,...P}:P);break;case"searchTerms":te(me=>jn(me)&&jn(P)?{...me,...P}:P);break;case"inputValues":pe(P);break;case"currentPage":ae(P);break;case"textInputs":Ce(P);break}Dr(T,P)};b.useEffect(()=>{if(!ze||!o||o.length===0)return;const T={...U},P=o.map(Ze=>Ze.id.toString());Object.keys(T).forEach(Ze=>{P.includes(Ze)||delete T[Ze]}),o.forEach(Ze=>{const jt=Ze.id.toString();T[jt]||(T[jt]={})}),JSON.stringify(T)!==JSON.stringify(U)&&Qe("paramTestValues",T)},[o,U,ze]),b.useEffect(()=>{ne({type:"SET_SCREEN_STATE",payload:{currentScreen:c,isProcessing:v,isCompleted:I}})},[c,v,I,ne]),b.useEffect(()=>{const T=document.createElement("style");return T.textContent=n2,document.head.appendChild(T),()=>{document.head.removeChild(T)}},[]),b.useEffect(()=>{const T=P=>{if(Object.values(J).some(me=>me)){const me=P.target,Ze=!!me.closest(".dropdown-menu"),jt=!!me.closest("[data-dropdown]");!Ze&&!jt&&p({})}};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[J]),b.useEffect(()=>{u&&(JSON.parse(localStorage.getItem(Ls)||"{}").task_id||Qe("task_id",at()))},[u]),b.useEffect(()=>{if(Ae.current&&(Ae.current=!1,v)){let T=0;const P=Object.values($e.graph._nodes_by_id),me=[],Ze=[];for(const Wn of P)Wn.type==="SaveImage"?me.push(Wn.id):Wn.type==="PreviewImage"&&Ze.push(Wn.id);const jt=[...me,...Ze];jt.length===1?T=jt[0]:jt.length>1&&(T=void 0),console.log("isProcessing-->",T),ls(void 0,T)}},[v]),b.useEffect(()=>{if(u){He(!0);try{const T=localStorage.getItem(Ls);if(T){const P=JSON.parse(T);if(console.log("parsedState-->",P),!o||o.length===0){console.log("Not restoring parameter debug state: no nodes selected"),He(!1);return}P.currentScreen!==void 0&&h(Un.isEqual(o,d.current)?P.currentScreen:0),P.selectedParams&&g(P.selectedParams),P.task_id&&S(P.task_id),C(P?.isProcessing);const me=P.generatedImages&&P.generatedImages.length>0;P.isCompleted!==void 0&&me&&L(P.isCompleted),P.completedCount!==void 0&&B(P.completedCount),P.totalCount!==void 0&&z(P.totalCount),P.selectedImageIndex!==void 0&&Y(P.selectedImageIndex),P.generatedImages&&O(P.generatedImages),P.paramTestValues&&V(P.paramTestValues),P.searchTerms&&te(P.searchTerms),P.inputValues&&pe(P.inputValues),P.currentPage!==void 0&&ae(P.currentPage),P.textInputs&&Ce(P.textInputs),ze||rt(!0)}}catch(T){console.error("Error loading parameter debug state:",T)}finally{d.current=o,setTimeout(()=>{He(!1)},50)}}else He(!0)},[u,o]);const os=(T=!1)=>{A2(h,g,S,as,C,L,B,z,Y,O,V,p,te,pe,ae,q,se,_e,xe,Pe,Ce,Me,We,Je,Ht,ct,St,yt,je,T),gt(!1),W(null)},Ts=T=>{x2(c,m,U,fe,o,q,no,Qe,T)},Nn=T=>{y2(c,o,U,fe,I,q,Qe,T)},Or=(T,P)=>{m2(T,m,U,Qe,P)},Fr=(T,P,me)=>{c2(T,P,me,J,p)},pn=(T,P,me)=>{d2(T,P,me,U,Qe)},Rr=(T,P,me,Ze)=>{u2(T,P,me,U,Qe,Ze)},zr=(T,P,me)=>{f2(T,P,me,K,Qe)},Ur=(T,P,me)=>{h2(T,P,me,U,pn)},Ps=(T,P)=>{b2(T,de,$,Qe,P)},as=()=>{mc(ke,we)};b.useEffect(()=>()=>{as()},[]);const ls=async(T,P)=>{console.log("handleStartGeneration-->",P),I2(U,_,q,we,ke,no,$e,Qe,T,P)},Ds=(T,P)=>{P&&(P.preventDefault(),P.stopPropagation()),Qe("selectedImageIndex",T)},Os=(T,P,me)=>{g2(T,P,o,xe,Pe,_e,me)},An=T=>{p2(_e,T)},Br=async T=>{E2(Z,$,$e,_,U,se,T)},xn=(T,P)=>{M2(c,o,P,ne,r,os,T)},Bn=()=>s.jsx(s.Fragment,{children:s.jsx(js,{visible:re,imageUrl:H,params:ue||{},onClose:An})});return bt?s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:s.jsx(t2,{historyItem:bt,selectedImageIndex:Z,handleSelectImage:Ds,handleClose:Pr,currentPage:he,handlePageChange:Ps,imagesPerPage:de,modalVisible:re,modalImageUrl:H,modalImageParams:ue,openImageModal:Os,closeImageModal:An})}):tt?s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:s.jsx(e2,{historyItems:It,onViewHistoryItem:Ms,onClose:Es})}):Ye&&u&&o.length>0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"p-8 rounded-lg shadow-sm relative flex flex-col items-center",children:[s.jsx("div",{className:"w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"}),s.jsx("div",{className:"mt-4 text-gray-600 text-sm",children:"Loading interface..."})]}),s.jsx(js,{visible:re,imageUrl:H,params:ue||{},onClose:An})]}):!u||o.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"max-w-lg p-8 rounded-lg shadow-sm border border-blue-100 relative",children:[s.jsxs("div",{className:"absolute top-3 right-3 flex",children:[s.jsx("button",{className:"text-blue-500 hover:text-blue-700 mr-2",onClick:Es,title:"Show History",children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})}),s.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:xn,children:s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h3",{className:"text-base font-bold text-blue-600 mb-2",children:"GenLab"}),s.jsx("div",{className:"h-1 w-16 bg-blue-500 mx-auto rounded-full mb-4"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-left mb-4",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-800 mb-3",children:"Batch-test parameters & find the best combo in one click."}),s.jsx("div",{className:"h-px w-full bg-gray-200 my-4"})]}),s.jsxs("div",{className:"text-left",children:[s.jsx("h4",{className:"text-base font-medium text-gray-800 mb-4",children:"How to use"}),s.jsxs("div",{className:"space-y-2 mb-4",children:[s.jsxs("p",{className:"text-sm text-gray-700",children:[s.jsx("span",{className:"font-bold",children:"1 - "}),"Click any node(hold Shift to select multiple nodes)"]}),s.jsxs("p",{className:"text-sm text-gray-700",children:[s.jsx("span",{className:"font-bold",children:"2 - "}),"Set parameter ranges and start batch generation."]})]}),s.jsx("div",{className:"h-px w-full bg-gray-200 my-4"}),s.jsx("p",{className:"text-sm text-blue-600 mt-6",children:"Let's select a node to begin!"})]})]})]}),s.jsx(js,{visible:re,imageUrl:H,params:ue||{},onClose:An})]}):I?s.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:s.jsx(Yp,{generatedImages:$,selectedImageIndex:Z,handleSelectImage:Ds,handleApplySelected:Br,handlePrevious:Nn,handleClose:xn,currentPage:he,handlePageChange:Ps,imagesPerPage:de,notificationVisible:Be,modalVisible:re,modalImageUrl:H,modalImageParams:ue,openImageModal:Os,closeImageModal:An})}):v?s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:[s.jsx(Rp,{selectedNodes:o,paramTestValues:U,selectedParams:m,totalCount:R,completedCount:A,errorMessage:ie,handleClose:xn,updateState:Qe,cleanupPolling:as}),s.jsx(Bn,{})]}):c===0?s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[s.jsx(Dp,{selectedNodes:o,handleParamSelect:Or,selectedParams:m,handleNext:Ts,handleClose:xn}),s.jsx(Bn,{})]}):c===1?s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[s.jsx(Op,{selectedNodes:o,paramTestValues:U,selectedParams:m,updateParamTestValues:pn,toggleDropdown:Fr,openDropdowns:J,handleTestValueSelect:Rr,searchTerms:K,handleSearch:zr,handleSelectAll:Ur,handleNext:Ts,handlePrevious:Nn,handleClose:xn,inputValues:F,updateState:Qe,textInputs:fe,handleTextInputChange:Jt,handleAddTextInput:Ns,handleRemoveTextInput:As,openAiWritingModal:Tr}),s.jsx(Qp,{visible:Oe,aiWritingModalText:Ne,setAiWritingModalText:We,aiGeneratedTexts:mt,aiSelectedTexts:Q,aiWritingLoading:kt,aiWritingError:Re,handleAiWriting:Kt,toggleTextSelection:Er,addSelectedTexts:Mr,onClose:()=>Me(!1)}),s.jsx(Bn,{})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[s.jsx(Fp,{selectedNodes:o,paramTestValues:U,selectedParams:m,totalCount:R,errorMessage:ie,handlePrevious:Nn,handleStartGeneration:ls,handleClose:xn}),s.jsx(Bn,{})]})},P2=o=>{const{dispatch:u}=gn(),[r,d]=b.useState(!1);return b.useEffect(()=>{if(o.visible&&!r){const c=r2();c&&c.screenState&&u({type:"SET_SCREEN_STATE",payload:{currentScreen:c.currentScreen,isProcessing:c.isProcessing,isCompleted:c.isCompleted}}),d(!0)}},[o.visible,r,u]),b.useEffect(()=>()=>{o.visible||u({type:"SET_SCREEN_STATE",payload:null})},[o.visible,u]),s.jsx(T2,{...o})},D2="/copilot_web/assets/gif-Dx_BC5pS.gif",O2=({onClose:o=()=>{},loading:u=!1})=>s.jsx("button",{onClick:o,disabled:u,className:"bg-white border-none text-gray-500 hover:!text-gray-700",children:s.jsx(Ln,{className:"w-5 h-5"})}),Jl="accept_event",F2={auto:{name:mn.START_POP_VIEW_AUTO_TIME,offset:1e3*60*60*24*3},accept:{name:mn.START_POP_VIEW_ACCEPT_TIME,offset:1e3*60*60*24*1}},R2=()=>{const{startpopview_title:o,startpopview_join:u}=Lr(),[r,d]=b.useState(!1),c=()=>{window.open(Yl,"_blank"),d(!1)},h=m=>{const{name:g,offset:_}=F2[m],S=new Date().getTime(),v=Ir(g);(!v||Number(v)&&S-Number(v)>_)&&(jr(g,S.toString()),d(!0))};return b.useEffect(()=>{h("auto");const m=()=>{h("accept")};return window.addEventListener(Jl,m),()=>{window.removeEventListener(Jl,m)}},[]),s.jsx(ic,{className:"pointer-events-none",children:s.jsx("div",{id:"comfyui-copilot-start-pop-view",children:r&&s.jsxs("div",{className:"fixed !left-auto !top-auto right-2 bottom-2 text-gray-700 w-[300px] h-[280px] bg-white border border-gray-600 rounded-[12px] flex flex-col justify-center shadow-[inset_0_0_12px_2px_#3b82f6] shadow-[inset_0_0_0_4px_rgba(59,130,246,0.15)] pointer-events-auto",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"w-full flex justify-between items-center",children:[s.jsx("img",{src:`.${nc}`,alt:"ComfyUI-Copilot Logo",className:"w-16 h-16"}),s.jsx("div",{className:"w-16 h-16 flex justify-center items-center",children:s.jsx(O2,{onClose:()=>d(!1)})})]}),s.jsx("div",{className:"text-gray-700 text-sm text-center whitespace-pre-line",children:o}),s.jsx("img",{src:`.${D2}`,className:"w-20 h-20 mt-2 mx-auto block"})]}),s.jsx("button",{className:"bg-gray-100 rounded-md flex justify-center items-center w-[240px] h-[40px] mx-[30px] mb-4",onClick:c,children:s.jsx("span",{className:"text-gray-900 text-sm",children:u})})]})})})},z2=Ql.apiBaseUrl,U2=({message:o,onClose:u})=>o?s.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:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"flex-shrink-0 mr-1",children:s.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:s.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"})})}),s.jsx("div",{className:"text-gray-700 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:s.jsx($g,{rehypePlugins:[[wg,{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})=>s.jsx("a",{...d,className:"text-gray-700 underline hover:text-gray-800 transition-colors",style:{fontSize:"11px"}}),p:({children:r})=>s.jsx("span",{className:"inline",style:{fontSize:"11px"},children:r}),span:({children:r})=>s.jsx("span",{style:{fontSize:"11px"},children:r}),li:({children:r})=>s.jsx("li",{style:{fontSize:"11px"},children:r}),ul:({children:r})=>s.jsx("ul",{style:{fontSize:"11px"},children:r}),ol:({children:r})=>s.jsx("ol",{style:{fontSize:"11px"},children:r})},children:o})})]}),s.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:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,B2=()=>{const{state:o,dispatch:u}=gn(),{selectedNode:r,screenState:d}=o,c=r||[],h=()=>{u({type:"SET_SELECTED_NODE",payload:null}),u({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};return s.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:s.jsx(P2,{selectedNodes:c,visible:!0,onClose:h})})};function W2({onClose:o,visible:u=!0,triggerUsage:r=!1,onUsageTriggered:d}){const{state:c,dispatch:h,showcasIng:m,abortControllerRef:g}=gn(),{messages:_,installedNodes:S,loading:v,sessionId:C,selectedNode:I,activeTab:L}=c;b.useRef(null);const[A,B]=b.useState(""),[R,z]=b.useState(""),[Z,Y]=b.useState(window.innerWidth/3),[$,O]=b.useState(!1),[U,V]=b.useState([]),[J,p]=b.useState("gemini-2.5-flash"),[K,te]=b.useState(window.innerHeight),[F,pe]=b.useState(0),[he,ae]=b.useState(""),[de,ie]=b.useState(!1);b.useRef(I);const q=b.useRef(null),[Be,se]=b.useState("None");Tp(u&&L==="chat"),Pp(u);const{chatinput_title:re}=Lr();b.useEffect(()=>{Cs.init().catch(console.error)},[]),b.useEffect(()=>{_.length>0&&C&&ct(_)},[_,C]),b.useEffect(()=>{switch(Be){case"Usage":Je();break;case"Parameters":kt();break;case"DownstreamNodes":lt();break}se("None")},[Be]),b.useEffect(()=>{if(L!=="chat")return;(async()=>{const ne=await Gg();console.log("[WorkflowChat] Received installed nodes:",ne.length),h({type:"SET_INSTALLED_NODES",payload:ne})})()},[L]);const _e=()=>{h({type:"SET_MESSAGES",payload:[{id:at(),role:"showcase",content:""}]})},H=async W=>{try{const ne=await Cs.getSession(W);if(ne&&ne.messages.length>0){h({type:"SET_MESSAGES",payload:ne.messages});return}const ke=await ht.fetchMessages(W);ke?.length>0?h({type:"SET_MESSAGES",payload:ke}):_e()}catch(ne){console.error("Error fetching messages:",ne)}};b.useEffect(()=>{if(L!=="chat")return;let W=localStorage.getItem("sessionId");W?(h({type:"SET_SESSION_ID",payload:W}),H(W)):(W=at(),h({type:"SET_SESSION_ID",payload:W}),localStorage.setItem("sessionId",W))},[L]),b.useEffect(()=>{const W=localStorage.getItem("activeTab");W&&h({type:"SET_ACTIVE_TAB",payload:W});const ne=localStorage.getItem("screenState");ne&&h({type:"SET_SCREEN_STATE",payload:JSON.parse(ne)});const ke=()=>{se("Usage")},we=()=>{se("Parameters")},Ae=()=>{se("DownstreamNodes")};return window.addEventListener(rs.TOOLBOX_USAGE,ke),window.addEventListener(rs.TOOLBOX_PARAMETERS,we),window.addEventListener(rs.TOOLBOX_DOWNSTREAMNODES,Ae),()=>{window.removeEventListener(rs.TOOLBOX_USAGE,ke),window.removeEventListener(rs.TOOLBOX_PARAMETERS,we),window.removeEventListener(rs.TOOLBOX_DOWNSTREAMNODES,Ae)}},[]),b.useEffect(()=>{localStorage.setItem("activeTab",L)},[L]),b.useEffect(()=>{c.screenState&&localStorage.setItem("screenState",JSON.stringify(c.screenState))},[c.screenState]);const xe=Qi.useCallback(W=>{if(!$)return;const ne=window.innerWidth-W.clientX,ke=Math.min(Math.max(300,ne),window.innerWidth*.8);Y(ke)},[$]),ue=Qi.useMemo(()=>Un.debounce(xe,16),[xe]);b.useEffect(()=>($&&(document.addEventListener("mousemove",ue),document.addEventListener("mouseup",Q)),()=>{document.removeEventListener("mousemove",ue),document.removeEventListener("mouseup",Q),ue.cancel()}),[$,ue]);const Pe=W=>{B(W.target.value)},fe=()=>{g.current&&(g.current.abort(),g.current=null,h({type:"SET_LOADING",payload:!1}))},Ce=async()=>{if(_?.[0]?.role==="showcase"&&h({type:"CLEAR_MESSAGES"}),m.current=!1,h({type:"SET_LOADING",payload:!0}),A.trim()===""&&!I||!C)return;z(A);const W=at(),ne=at(),ke={id:ne,role:"user",content:A,trace_id:W};U.length>0&&(ke.ext=[{type:"img",data:U.map(we=>({url:we.url,name:we.file.name}))}]),h({type:"ADD_MESSAGE",payload:ke}),B(""),g.current=new AbortController;try{const we={type:"model_select",data:[J]};let Ae=at(),Ye=!0;for await(const He of ht.streamInvokeServer(C,A,U.map(ze=>({url:ze.url,name:ze.file.name})),null,we,W,g.current.signal,c.messages,ne)){const ze={id:Ae,role:"ai",content:JSON.stringify(He),format:He.format,finished:He.finished,name:"Assistant",ext:He.ext};if(Ye)h({type:"ADD_MESSAGE",payload:ze}),Ye=!1;else{h({type:"UPDATE_MESSAGE",payload:ze});const rt=c.messages.map(Kt=>Kt.id===ze.id&&!Kt.finished?ze:Kt);ct(rt)}He.finished&&(h({type:"SET_LOADING",payload:!1}),g.current=null)}}catch(we){we instanceof Error&&we.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",we),h({type:"SET_LOADING",payload:!1}),g.current=null}finally{V([])}},Oe=async W=>{if(!C)return;h({type:"SET_LOADING",payload:!0}),z(W);const ne=at(),ke=at();h({type:"ADD_MESSAGE",payload:{id:ke,role:"user",content:W,trace_id:ne}}),g.current=new AbortController;try{const Ae={type:"model_select",data:[J]};let Ye=at(),He=!0;for await(const ze of ht.streamInvokeServer(C,W,U.map(rt=>({url:rt.url,name:rt.file.name})),null,Ae,ne,g.current.signal,c.messages,ke)){const rt={id:Ye,role:"ai",content:JSON.stringify(ze),format:ze.format,finished:ze.finished,name:"Assistant"};if(He)h({type:"ADD_MESSAGE",payload:rt}),He=!1;else{h({type:"UPDATE_MESSAGE",payload:rt});const Kt=c.messages.map(Jt=>Jt.id===rt.id&&!Jt.finished?rt:Jt);ct(Kt)}ze.finished&&(h({type:"SET_LOADING",payload:!1}),g.current=null)}}catch(Ae){Ae instanceof Error&&Ae.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Ae),h({type:"SET_LOADING",payload:!1}),g.current=null}finally{V([])}},Me=W=>{W.metaKey&&W.key==="Enter"&&Ce()},Ne=()=>{m.current=!1,h({type:"CLEAR_MESSAGES"});const W=c.sessionId;W&&localStorage.removeItem(`messages_${W}`),localStorage.removeItem("sessionId");const ne=at();h({type:"SET_SESSION_ID",payload:ne}),localStorage.setItem("sessionId",ne),setTimeout(()=>{_e()},500)},We=W=>{B(W)},mt=async(W,ne)=>{if(!C||!I)return;h({type:"SET_LOADING",payload:!0});const ke=I[0].comfyClass||I[0].type,we=at(),Ae={id:at(),role:"user",content:ke,trace_id:we};h({type:"ADD_MESSAGE",payload:Ae}),g.current=new AbortController;try{let Ye=at(),He=!0;for await(const ze of ht.streamInvokeServer(C,ke,[],W,ne,we,g.current.signal,c.messages)){const rt={id:Ye,role:"ai",content:JSON.stringify(ze),format:ze.format,finished:ze.finished,name:"Assistant"};if(W&&W!==""&&(rt.metadata={intent:W}),He)h({type:"ADD_MESSAGE",payload:rt}),He=!1;else{h({type:"UPDATE_MESSAGE",payload:rt});const Kt=c.messages.map(Jt=>Jt.id===rt.id&&!Jt.finished?rt:Jt);ct(Kt)}ze.finished&&(h({type:"SET_LOADING",payload:!1}),g.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}),g.current=null}},Je=()=>{Oe(`Reply in ${navigator.language} language: How does the ${I?.[0]?.type} node work? I need its official usage guide.`)},kt=()=>{Oe(`Reply in ${navigator.language} language: Show me the technical specifications for the ${I?.[0].type} node's inputs and outputs.`)},Ht=()=>{const W=new Set;function ne(ke,we){if(!(!ke||we>=1)&&ke.inputs)for(const Ae of Object.values(ke.inputs)){const Ye=Ae.link;if(Ye&&$e.graph.links[Ye]){const He=$e.graph.links[Ye].origin_id,ze=$e.graph._nodes_by_id[He];ze&&(W.add(ze.type),ne(ze,we+1))}}}return I[0]?(ne(I[0],0),[{type:"upstream_node_types",data:Array.from(W)}]):null},lt=()=>{mt("downstream_subgraph_search",Ht())},ct=async W=>{if(c.sessionId){localStorage.setItem(`messages_${c.sessionId}`,JSON.stringify(W));try{await Cs.saveSession(c.sessionId,W)}catch(ne){console.error("Failed to save session to IndexedDB:",ne)}}},Rt=W=>{console.log("[WorkflowChat] Adding new message:",W);const ne=[...c.messages,W];h({type:"ADD_MESSAGE",payload:W}),ct(ne)},St=W=>{const ne=c.messages.map(ke=>ke.id===W.id&&!ke.finished?W:ke);h({type:"UPDATE_MESSAGE",payload:W}),ct(ne)},Re=(W,ne)=>{h({type:"SET_SESSION_ID",payload:W}),h({type:"SET_MESSAGES",payload:ne}),localStorage.setItem("sessionId",W),localStorage.setItem(`messages_${W}`,JSON.stringify(ne))},yt=()=>{q.current&&q.current.refreshModels()},Q=()=>{O(!1)},je=async(W,ne)=>{const ke=new FormData;ke.append("file",W);const Ae=await(await fetch(`${z2}/api/chat/imgfile2oss`,{method:"POST",body:ke})).json();return await ht.uploadImage(W),Ae.success?{url:Ae.data,file:W,id:ne}:null},tt=W=>{const ne=[],ke=[];Array.from(W).forEach(we=>{const Ae=Math.random().toString(36).substr(2,9);ke.push(je(we,Ae)),ne.push({id:Ae,file:we,preview:URL.createObjectURL(we),url:""})}),V(we=>[...we,...ne]),Promise.all(ke).then(we=>{we?.forEach(Ae=>{if(Ae){const Ye=ne.findIndex(He=>He.id===Ae.id);ne.splice(Ye,1,{id:Ae.id,file:Ae?.file,preview:URL.createObjectURL(Ae?.file),url:Ae?.url})}}),V(Ae=>ac(Ae,ne,"id"))})},gt=W=>{V(ne=>ne.filter(we=>we.id!==W))};Qi.useEffect(()=>()=>{U.forEach(W=>URL.revokeObjectURL(W.preview))},[U]),b.useEffect(()=>{r&&d&&L==="chat"&&(mt("node_explain"),d())},[r,L]),b.useEffect(()=>{if(!u||L!=="chat")return;(async()=>{try{const ne=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==ne){const we=await ht.fetchAnnouncement();we&&we.trim()!==""&&(ae(we),ie(!0),localStorage.setItem("announcementLastShownDate",ne))}}catch(ne){console.error("Error fetching announcement:",ne)}})()},[u,L]);const It=()=>{ie(!1)},Ct=W=>{h({type:"SET_ACTIVE_TAB",payload:W})},bt=W=>{p(W),jr(mn.MODELS_POP_VIEW_SELECTED,W)};return u?s.jsxs("div",{className:"flex flex-col h-full w-full bg-white relative",style:{display:u?"flex":"none"},children:[s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(Qg,{onClose:o,onClear:Ne,hasMessages:_.length>0,title:"ComfyUI-Copilot",onSelectSession:Re,currentSessionId:C,onConfigurationUpdated:yt}),s.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[s.jsx(to,{active:L==="chat",onClick:()=>Ct("chat"),children:"Chat"}),s.jsx(to,{active:L==="parameter-debug",onClick:()=>Ct("parameter-debug"),children:"GenLab"})]}),de&&he&&L==="chat"&&s.jsx(U2,{message:he,onClose:It}),s.jsx(Mp,{messages:_,latestInput:R,onOptionClick:We,installedNodes:S,onAddMessage:Rt,onUpdateMessage:St,loading:v,isActive:L==="chat"}),s.jsxs("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:L==="chat"?"block":"none"},children:[I&&s.jsx(yp,{nodeInfo:I,onSendWithIntent:mt,loading:v,onSendWithContent:Oe}),s.jsx(oc,{ref:q,input:A,loading:v,onChange:Pe,onSend:Ce,onKeyPress:Me,onUploadImages:tt,uploadedImages:U,onRemoveImage:gt,selectedModel:J,onModelChange:bt,onStop:fe,onAddDebugMessage:Rt}),s.jsxs(ro,{className:"w-full mt-2 flex-1 flex justify-center items-center gap-1",children:[re,"👉🏻",s.jsx("svg",{viewBox:"0 0 1024 1024",className:"w-4 h-4",fill:"currentColor",children:s.jsx("path",{d:"M498.894518 100.608396c-211.824383 0-409.482115 189.041494-409.482115 422.192601 0 186.567139 127.312594 344.783581 295.065226 400.602887 21.13025 3.916193 32.039717-9.17701 32.039717-20.307512 0-10.101055 1.176802-43.343157 1.019213-78.596056-117.448946 25.564235-141.394311-49.835012-141.394311-49.835012-19.225877-48.805566-46.503127-61.793368-46.503127-61.793368-38.293141-26.233478 3.13848-25.611308 3.13848-25.611308 42.361807 2.933819 64.779376 43.443441 64.779376 43.443441 37.669948 64.574714 98.842169 45.865607 122.912377 35.094286 3.815909-27.262924 14.764262-45.918819 26.823925-56.431244-93.796246-10.665921-192.323237-46.90017-192.323237-208.673623 0-46.071292 16.498766-83.747379 43.449581-113.332185-4.379751-10.665921-18.805298-53.544497 4.076852-111.732757 0 0 35.46063-11.336186 116.16265 43.296085 33.653471-9.330506 69.783343-14.022365 105.654318-14.174837 35.869952 0.153496 72.046896 4.844332 105.753579 14.174837 80.606853-54.631248 116.00813-43.296085 116.00813-43.296085 22.935362 58.18826 8.559956 101.120049 4.180206 111.732757 27.052123 29.584806 43.443441 67.260893 43.443441 113.332185 0 162.137751-98.798167 197.850114-192.799074 208.262254 15.151072 13.088086 28.65155 38.804794 28.65155 78.17957 0 56.484456-0.459464 101.94381-0.459464 115.854635 0 11.235902 7.573489 24.381293 29.014824 20.2543C825.753867 867.330798 933.822165 709.10924 933.822165 522.700713c0-233.155201-224.12657-422.192601-434.927647-422.192601L498.894518 100.608396z"})}),"⭐️"]})]}),s.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:L==="parameter-debug"?"flex":"none"},children:s.jsx(B2,{})})]}),s.jsx(R2,{})]}):null}const K2=Object.freeze(Object.defineProperty({__proto__:null,default:W2},Symbol.toStringTag,{value:"Module"}));export{Jl as A,_p as B,fp as M,K2 as w};
