>>=1,q<<=1,0<--T;);return q>>>1}function ye(S,T,q){var J,L,Q=new Array(m+1),re=0;for(J=1;J<=m;J++)Q[J]=re=re+q[J-1]<<1;for(L=0;L<=T;L++){var ee=S[2*L+1];ee!==0&&(S[2*L]=he(Q[ee]++,ee))}}function le(S){var T;for(T=0;T>1;1<=q;q--)ve(S,Q,q);for(L=se;q=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ve(S,Q,1),J=S.heap[1],S.heap[--S.heap_max]=q,S.heap[--S.heap_max]=J,Q[2*L]=Q[2*q]+Q[2*J],S.depth[L]=(S.depth[q]>=S.depth[J]?S.depth[q]:S.depth[J])+1,Q[2*q+1]=Q[2*J+1]=L,S.heap[1]=L++,ve(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(pe,Xe){var xn,at,kn,je,Qn,io,ht=Xe.dyn_tree,Js=Xe.max_code,Il=Xe.stat_desc.static_tree,Ol=Xe.stat_desc.has_stree,Dl=Xe.stat_desc.extra_bits,Ys=Xe.stat_desc.extra_base,En=Xe.stat_desc.max_length,er=0;for(je=0;je<=m;je++)pe.bl_count[je]=0;for(ht[2*pe.heap[pe.heap_max]+1]=0,xn=pe.heap_max+1;xn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*se]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(se=32;se>>3,(Q=S.static_len+3+7>>>3)<=L&&(L=Q)):L=Q=q+5,q+4<=L&&T!==-1?O(S,T,q,J):S.strategy===4||Q===L?(Y(S,2+(J?1:0),3),me(S,K,j)):(Y(S,4+(J?1:0),3),function(ee,se,ge,pe){var Xe;for(Y(ee,se-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Xe=0;Xe>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&T,S.pending_buf[S.l_buf+S.last_lit]=255&q,S.last_lit++,T===0?S.dyn_ltree[2*q]++:(S.matches++,T--,S.dyn_ltree[2*(b[q]+d+1)]++,S.dyn_dtree[2*B(T)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){Y(S,2,3),Z(S,_,K),function(T){T.bi_valid===16?(ne(T,T.bi_buf),T.bi_buf=0,T.bi_valid=0):8<=T.bi_valid&&(T.pending_buf[T.pending++]=255&T.bi_buf,T.bi_buf>>=8,T.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},v=!1,f=i.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(i);m=m&&m.setTimeout?m:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){g(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,C=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=C,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(x){g(x.data)},function(x){u.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(x){var C=f.createElement("script");C.onreadystatechange=function(){g(x),C.onreadystatechange=null,c.removeChild(C),C=null},c.appendChild(C)}):function(x){setTimeout(g,0,x)},m.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var C=new Array(arguments.length-1),D=0;D"u"?s===void 0?this:s:self)}).call(this,typeof tr<"u"?tr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Sl);var Mp=Sl.exports;const Bp=Fa(Mp),zp=async t=>{const e=`ComfyUI workspace workflows ${ml(Date.now())}`,n=new Bp,r=await(G==null?void 0:G.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await kh(o.parentFolderID??null).then(async a=>Ft(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function Lp({myWorkflowsDir:t}){return k.jsxs(Ke,{gap:3,children:[k.jsx(sn,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),k.jsx("p",{children:"Your workflows will be synced to and from path:"}),k.jsx("p",{children:k.jsx("b",{children:t})}),k.jsxs("p",{children:["You can manually put workflow files into this folder using File Explorer to sync them with your workspace. You can change this path anytime in Settings ",">"," Workspace Save Directory"]}),k.jsxs("p",{children:[k.jsx("b",{children:"Please download all your workflows before enabling two way sync as a backup!"})," ","So you can manually import some workflows into your workspace in case something unexpected happens."]}),k.jsx(Te,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await($==null?void 0:$.listAll());zp(e??[])},children:"👉 Download All My Workflows"})]})}const Wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},Up=La.lazy(()=>yn(()=>import("./RecentFilesDrawer-ouPPEt3o.js"),__vite__mapDeps([14,1,8,2,13,15,12,4]))),Kp=La.lazy(()=>yn(()=>import("./GalleryModal-pPf4t3nM.js"),__vite__mapDeps([16,1,15,12,9,8,2,3])));function $p(){const[t,e]=P.useState(null),[n,r]=P.useState("root"),[o,s]=P.useState(!0),[i,a]=P.useState(null),l=P.useRef(null),[c,u]=P.useState(!1),d=P.useRef(null),{showDialog:p}=za(),[h,v]=P.useState(!1);P.useRef(!1);const f=Ua(),[m,y]=Tp(null),g=P.useCallback(async()=>{var N,H;if(l.current){if((N=$==null?void 0:$.curWorkflow)!=null&&N.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const A=JSON.stringify(we.graph.serialize());await Promise.all([$==null?void 0:$.updateFlow(l.current,{json:A}),Ge==null?void 0:Ge.create({workflowID:l.current,json:A,isAutoSave:!1})]),(H=G==null?void 0:G.settings)!=null&&H.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{var H,A,X;if((H=G==null?void 0:G.settings)!=null&&H.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const V=(A=$==null?void 0:$.curWorkflow)==null?void 0:A.id;if(V==null)return;const te=(X=await($==null?void 0:$.get(V)))==null?void 0:X.json;te?($==null||$.updateCurWorkflow({...$.curWorkflow,json:te}),await we.loadGraphData(JSON.parse(te)),u(!1)):alert("Error: No last saved version found")}},x=N=>{const H=(N==null?void 0:N.id)??null;if($==null||$.updateCurWorkflow(N),l.current=H,a(H),e((N==null?void 0:N.name)??""),H==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Da()){const A=yl(H);window.location.hash=A,document.title=N.name+" - ComfyUI"}else localStorage.setItem("curFlowID",H),document.title="ComfyUI - "+N.name;N&&($==null||$.updateLastOpenedTime(N.id))},C=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Lh()}catch(A){console.error("error loading db",A)}s(!1);let N=null;N=Da(),N==null&&(N=localStorage.getItem("curFlowID")),N&&E(N),fetch("/workspace/deduplicate_workflow_ids"),!await(G==null?void 0:G.getSetting("twoWaySync"))&&ie.cache.get(ko).then(async A=>{if((A==null?void 0:A.value)!=="true"){if(await ie.workflows.count()==0){await(G==null?void 0:G.upsert({twoWaySync:!0})),await ie.cache.put({id:ko,value:"true"});return}const V=await(G==null?void 0:G.getSetting("myWorkflowsDir"));p(k.jsx(Lp,{myWorkflowsDir:V??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(G==null?void 0:G.upsert({twoWaySync:!0})),await(G==null?void 0:G.getSetting("twoWaySync"))&&(ie.cache.put({id:ko,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},D=()=>{if(l.current==null)return!1;const N=$==null?void 0:$.curWorkflow;if(N==null)return!1;if(N.json==null)return!0;const H=we.graph.serialize()??{};let A={};try{A=N!=null&&N.json?JSON.parse(N==null?void 0:N.json):{}}catch(V){console.error("error parsing json",V)}return!Wp(H,A)},E=async(N,H)=>{if(we.graph==null)return;const A=await($==null?void 0:$.get(N));if(A==null){alert("Error: Workflow not found! id: "+N),x(null);return}const X=H?await(be==null?void 0:be.get(H)):null;we.ui.dialog.close(),X?(y(X),x({...A,json:X.json}),we.loadGraphData(JSON.parse(X.json))):(x(A),y(null),we.loadGraphData(JSON.parse(A.json))),r("root"),c&&u(!1)},F=async(N,H,A=!1)=>{var X;if(N===null){x(null),we.graph.clear();return}if(!c||A||(X=G==null?void 0:G.settings)!=null&&X.autoSave||($==null?void 0:$.curWorkflow)==null){E(N,H);return}I(N)},I=async N=>{var A;const H=[N?{label:"Open in new tab",icon:k.jsx(bl,{}),onClick:()=>{Oh(N)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await g(),N&&E(N)}}];H.push({label:"Discard",colorScheme:"red",onClick:async()=>{N&&E(N)}}),p(`Please save or discard your changes to "${(A=$==null?void 0:$.curWorkflow)==null?void 0:A.name}" before leaving, or your changes will be lost.`,H)},R=async N=>{const H=(N==null?void 0:N.json)??JSON.stringify(Cr),A=await($==null?void 0:$.createFlow({json:H,name:N==null?void 0:N.name}));A&&await F(A.id),r("root")},K=async(N,H=!1)=>{const A=N.split("/").pop()??N;H?g():R({name:A});const X=await fetch(Ih(N)),V=await X.blob(),te=new File([V],A,{type:X.headers.get("Content-Type")||""});await we.handleFile(te),r("root")},j=async(N,H)=>{const A=await($==null?void 0:$.get(N));if(A==null)return;const X=await($==null?void 0:$.createFlow({json:A.json,name:H||A.name,parentFolderID:A.parentFolderID,tags:A.tags}));X&&await F(X.id)},M=P.useCallback(N=>{if(l.current==null)return;let H=N.filename;N.subfolder!=null&&N.subfolder!==""&&(H=N.subfolder+"/"+H),Ht==null||Ht.create({workflowID:l.current,localPath:H})},[]),b=P.useCallback(()=>{r("root")},[]);return P.useEffect(()=>{C(),v(!0);const N=document.getElementById("comfy-file-input"),H=async()=>{if(N&&N.files&&N.files.length>0){const te={id:Dr(),name:N.files[0].name,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(te),await($==null?void 0:$.createFlow(te))}};N==null||N.addEventListener("change",H);const A=te=>{var ne,Y;const z=((ne=G==null?void 0:G.settings)==null?void 0:ne.autoSave)??!0;if((Y=$==null?void 0:$.curWorkflow)!=null&&Y.saveLock)return;const B=D();!z&&B&&(te.preventDefault(),te.returnValue="You have unsaved changes!",I())};window.addEventListener("beforeunload",A);const X=te=>{var z,B,ne,Y,Z,he;(ne=(B=(z=te.detail)==null?void 0:z.output)==null?void 0:B.images)==null||ne.forEach(ye=>{ye.type==="output"&&M(ye)}),(he=(Z=(Y=te.detail)==null?void 0:Y.output)==null?void 0:Z.gifs)==null||he.forEach(ye=>{ye.type==="output"&&M(ye)})};ql.addEventListener("executed",X);const V=async te=>{var Y,Z;const z=(Z=(Y=te.dataTransfer)==null?void 0:Y.files[0])==null?void 0:Z.name,B=we.dragOverNode;if(B&&B.onDragDrop)return;if(!(await(G==null?void 0:G.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&z){const he={id:Dr(),name:z,json:JSON.stringify(Cr),updateTime:Date.now(),createTime:Date.now()};x(he),await($==null?void 0:$.createFlow(he))}};return we.canvasEl.addEventListener("drop",V),()=>{window.removeEventListener("change",H),window.removeEventListener("beforeunload",A),window.removeEventListener("executed",X),we.canvasEl.removeEventListener("drop",V)}},[]),o?null:k.jsx(Ct.Provider,{value:{curFlowID:i,onDuplicateWorkflow:j,loadWorkflowID:F,discardUnsavedChanges:_,saveCurWorkflow:g,isDirty:c,setIsDirty:u,loadNewWorkflow:R,loadFilePath:K,setRoute:r,route:n,curVersion:m,setCurVersion:y},children:k.jsx("div",{ref:d,className:"workspace_manager",children:k.jsxs(Ma,{containerRef:d,children:[k.jsxs(jt,{style:{position:"absolute",top:0,right:0,left:0},zIndex:xh,draggable:!1,children:[k.jsx(Ap,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&k.jsx(P.Suspense,{children:k.jsx(Up,{onClose:b,onClickNewFlow:()=>{R(),r("root")}})}),n==="gallery"&&k.jsx(P.Suspense,{children:k.jsx(Kp,{onclose:()=>r("root")})})]}),k.jsx(Np,{})]})})})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:$p},Symbol.toStringTag,{value:"Module"}));export{Oh as $,Jh as A,jt as B,om as C,dp as D,yh as E,Wt as F,Yh as G,ot as H,un as I,Ph as J,Le as K,Yr as L,_i as M,Qr as N,Xr as O,np as P,op as Q,hm as R,Ad as S,Gt as T,Cr as U,am as V,xr as W,zh as X,rm as Y,Ct as Z,bl as _,Yp as a,_l as a0,Ht as a1,ml as a2,ct as a3,hc as a4,xh as a5,Qp as a6,Er as a7,im as a8,Va as a9,Tp as aA,Mh as aB,um as aC,pm as aD,us as aE,ks as aF,vn as aG,gm as aH,oi as aI,be as aJ,vm as aK,wm as aL,Sp as aM,bm as aN,qe as aO,fc as aP,_m as aQ,_c as aa,cm as ab,Ha as ac,Th as ad,sn as ae,on as af,xc as ag,Wp as ah,sm as ai,lm as aj,Ge as ak,Yl as al,ie as am,ym as an,bf as ao,dm as ap,fm as aq,em as ar,tm as as,Wc as at,ki as au,xi as av,Oi as aw,Ei as ax,Si as ay,mm as az,Zp as b,Jp as c,Pe as d,ip as e,Ua as f,Ke as g,wt as h,bt as i,gn as j,G as k,Lp as l,Uc as m,wf as n,Xp as o,nm as p,jo as q,Fs as r,Rs as s,Sr as t,to as u,mt as v,Aa as w,$ as x,up as y,zp as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-ABShBZ_r.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-Vyo84f0U.js","workspace_web/IconCopy-j3_qolNw.js","workspace_web/AppIsDirtyEventListener-BH8Pedq1.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-jwv1A1hH.js","workspace_web/chunk-JARCRF6W-66xSMED8.js","workspace_web/chunk-3RSXBRAN-xkXXv8lg.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-ysZyuBYf.js","workspace_web/IconSearch-yd7KVSRG.js","workspace_web/chunk-NTCQBYKE-7yeghZmZ.js","workspace_web/RecentFilesDrawer-qy9dTPVG.js","workspace_web/MediaPreview-IFYm2Mq_.js","workspace_web/GalleryModal-cB6QErx6.js"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-uq7XVWvD.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-Vyo84f0U.js","workspace_web/IconCopy-wyTg5wiq.js","workspace_web/AppIsDirtyEventListener-09XYx3lY.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-wj7k34WI.js","workspace_web/chunk-JARCRF6W-xouhmv4h.js","workspace_web/chunk-3RSXBRAN-8cE0TZNF.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-TbsT5AM9.js","workspace_web/IconSearch-e7N1azjj.js","workspace_web/chunk-NTCQBYKE-nDCdQPx1.js","workspace_web/RecentFilesDrawer-ouPPEt3o.js","workspace_web/MediaPreview-KLEWGSXc.js","workspace_web/GalleryModal-pPf4t3nM.js"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file
diff --git a/dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js b/dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js
similarity index 97%
rename from dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js
rename to dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js
index cfc6702..24e6954 100644
--- a/dist/workspace_web/AppIsDirtyEventListener-BH8Pedq1.js
+++ b/dist/workspace_web/AppIsDirtyEventListener-09XYx3lY.js
@@ -1 +1 @@
-import{r as l,j as S}from"./input.js";import{app as s}from"/scripts/app.js";import{Z as D,f as C,ah as j,i as x,T as W,E as d,ai as _,aj as I,x as r,k as h,ak as L}from"./App-YT7a4Gj6.js";import{u as R}from"./useDebounceFn-ld478fd0.js";import"/scripts/api.js";function F(){const{isDirty:p,setIsDirty:w,setRoute:g,saveCurWorkflow:y}=l.useContext(D),k=l.useRef(p),[m,E]=l.useState(!1);C();const v=l.useRef(null);l.useEffect(()=>{k.current=p},[p]),l.useEffect(()=>{var i,c;const n=t=>{var u;if(document.visibilityState==="hidden")return;const e=I(t);if(e)switch(e===d.openSpotlightSearch&&t.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:e}})),e){case d.SAVE:y();break;case d.SAVE_AS:g("saveAsModal");break;case d.openSpotlightSearch:g("spotlightSearch");break}else(u=t.target)!=null&&u.matches("input, textarea")&&Object.keys(s.canvas.selected_nodes??{}).length&&f()},o=s.canvas.onAfterChange;s.graph.onAfterChange=function(){o==null||o.apply(this,arguments),f()};const a=s.graph.onConfigure;return s.graph.onConfigure=function(){a==null||a.apply(this,arguments),setTimeout(()=>{var e,u;j(s.graph.serialize(),JSON.parse(((u=(e=r)==null?void 0:e.curWorkflow)==null?void 0:u.json)??"{}"))||f()},1e3)},document.addEventListener("click",t=>{Object.keys(s.canvas.selected_nodes??{}).length&&(s.canvas.node_over!=null||s.canvas.node_capturing_input!=null||s.canvas.node_widget!=null)&&f()}),document.addEventListener("keydown",n),(c=(i=h)==null?void 0:i.settings)!=null&&c.autoSave&&h.settings.autoSaveDuration&&(v.current=setInterval(()=>{T()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",n),v.current&&clearInterval(v.current)}},[]);const T=async()=>{var o,a,i,c,t,e;if((a=(o=r)==null?void 0:o.curWorkflow)!=null&&a.saveLock||!((c=(i=r)==null?void 0:i.curWorkflow)!=null&&c.id)||!k.current)return;const n=JSON.stringify(s.graph.serialize());await((t=r)==null?void 0:t.updateFlow(r.curWorkflow.id,{json:n})),(e=L)==null||e.create({workflowID:r.curWorkflow.id,isAutoSave:!0,json:n}),w(!1)},b=async()=>{var n,o,a,i,c,t,e;(o=(n=r)==null?void 0:n.curWorkflow)!=null&&o.saveLock||k.current||(w(!0),(i=(a=h)==null?void 0:a.settings)!=null&&i.autoSave&&((t=(c=r)==null?void 0:c.curWorkflow)!=null&&t.id)&&!m&&(await((e=r)==null?void 0:e.latestVersionCheck())||E(!0)))},[f,A]=R(b,900);return m?S.jsx(x,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:S.jsx(W,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{F as default};
+import{r as l,j as S}from"./input.js";import{app as s}from"/scripts/app.js";import{Z as D,f as C,ah as j,i as x,T as W,E as d,ai as _,aj as I,x as r,k as h,ak as L}from"./App-bXo9NVT7.js";import{u as R}from"./useDebounceFn-ld478fd0.js";import"/scripts/api.js";function F(){const{isDirty:p,setIsDirty:w,setRoute:g,saveCurWorkflow:y}=l.useContext(D),k=l.useRef(p),[m,E]=l.useState(!1);C();const v=l.useRef(null);l.useEffect(()=>{k.current=p},[p]),l.useEffect(()=>{var i,c;const n=t=>{var u;if(document.visibilityState==="hidden")return;const e=I(t);if(e)switch(e===d.openSpotlightSearch&&t.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:e}})),e){case d.SAVE:y();break;case d.SAVE_AS:g("saveAsModal");break;case d.openSpotlightSearch:g("spotlightSearch");break}else(u=t.target)!=null&&u.matches("input, textarea")&&Object.keys(s.canvas.selected_nodes??{}).length&&f()},o=s.canvas.onAfterChange;s.graph.onAfterChange=function(){o==null||o.apply(this,arguments),f()};const a=s.graph.onConfigure;return s.graph.onConfigure=function(){a==null||a.apply(this,arguments),setTimeout(()=>{var e,u;j(s.graph.serialize(),JSON.parse(((u=(e=r)==null?void 0:e.curWorkflow)==null?void 0:u.json)??"{}"))||f()},1e3)},document.addEventListener("click",t=>{Object.keys(s.canvas.selected_nodes??{}).length&&(s.canvas.node_over!=null||s.canvas.node_capturing_input!=null||s.canvas.node_widget!=null)&&f()}),document.addEventListener("keydown",n),(c=(i=h)==null?void 0:i.settings)!=null&&c.autoSave&&h.settings.autoSaveDuration&&(v.current=setInterval(()=>{T()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",n),v.current&&clearInterval(v.current)}},[]);const T=async()=>{var o,a,i,c,t,e;if((a=(o=r)==null?void 0:o.curWorkflow)!=null&&a.saveLock||!((c=(i=r)==null?void 0:i.curWorkflow)!=null&&c.id)||!k.current)return;const n=JSON.stringify(s.graph.serialize());await((t=r)==null?void 0:t.updateFlow(r.curWorkflow.id,{json:n})),(e=L)==null||e.create({workflowID:r.curWorkflow.id,isAutoSave:!0,json:n}),w(!1)},b=async()=>{var n,o,a,i,c,t,e;(o=(n=r)==null?void 0:n.curWorkflow)!=null&&o.saveLock||k.current||(w(!0),(i=(a=h)==null?void 0:a.settings)!=null&&i.autoSave&&((t=(c=r)==null?void 0:c.curWorkflow)!=null&&t.id)&&!m&&(await((e=r)==null?void 0:e.latestVersionCheck())||E(!0)))},[f,A]=R(b,900);return m?S.jsx(x,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:S.jsx(W,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{F as default};
diff --git a/dist/workspace_web/GalleryModal-cB6QErx6.js b/dist/workspace_web/GalleryModal-cB6QErx6.js
deleted file mode 100644
index 3a0e243..0000000
--- a/dist/workspace_web/GalleryModal-cB6QErx6.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as d,d as Se,y as Wt,m as be,b as ct,f as V,l as ut,o as Ae,E as Yt,j as r,g as E,h as dt,p as Xt,W as ht,i as ft,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{a9 as nn,aa as sn,d as Fe,F as v,ab as rn,ac as on,I as M,j as an,g as Ee,B as xt,h as W,Z as oe,ad as ln,x as A,H as Y,i as F,w as mt,a2 as pt,e as gt,$,ae as cn,y as un}from"./App-YT7a4Gj6.js";import{c as je,p as dn,r as st,v as rt,I as hn,N as fn,a as xn,b as mn,d as pn,e as gn,M as vt,u as vn,S as yn}from"./MediaPreview-IFYm2Mq_.js";import{S as wn}from"./chunk-3RSXBRAN-xkXXv8lg.js";import{u as Sn,C as $e,G as bn}from"./chunk-JARCRF6W-66xSMED8.js";import{app as ot}from"/scripts/app.js";import{L as Ne}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import"/scripts/api.js";import"./IconSearch-yd7KVSRG.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,jn=typeof performance<"u"?()=>performance.now():()=>Date.now(),wt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(jn()),yt);function kn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,x=!1)=>{const f=x&&o,g=f?t:s;return u&&l.add(i),g.indexOf(i)===-1&&(g.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=kn(()=>X=!0),e),{}),Cn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||En(),s.schedule(n,o,a)),e},{}),In=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(O),e),{});const Tn=e=>ae[e].process(O),St=e=>{X=!1,O.delta=_e?yt:Math.max(Math.min(e-O.timestamp,Pn),1),O.timestamp=e,Me=!0,Z.forEach(Tn),Me=!1,X&&(_e=!1,wt(St))},En=()=>{X=!0,_e=!0,Me||wt(St)},at=()=>O;var L=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function Nn(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const N=(w=n[y])!=null?w:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${N.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${N.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,w)=>ee(y).height>ee(w).height?y:w,te):n.reduce((y,w)=>ee(y).width>ee(w).width?y:w,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,x=[0,o?100-s[0]:s[0]],f=u?x:s;let g=f[0];!u&&o&&(g=100-g);const p=Math.abs(f[f.length-1]-f[0]),k={...i,...Q({orientation:t,vertical:o?{height:`${p}%`,top:`${g}%`}:{height:`${p}%`,bottom:`${g}%`},horizontal:o?{width:`${p}%`,right:`${g}%`}:{width:`${p}%`,left:`${g}%`}})};return{trackStyle:i,innerTrackStyle:k,rootStyle:c,getThumbStyle:a}}function _n(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Mn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Dn(e){const t=Rn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function bt(e){return!!e.touches}function zn(e){return bt(e)&&e.touches.length>1}function Rn(e){var t;return(t=e.view)!=null?t:window}function An(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Fn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function jt(e,t="page"){return bt(e)?An(e,t):Fn(e,t)}function $n(e){return t=>{const s=Dn(t);(!s||s&&t.button===0)&&e(t)}}function Vn(e,t=!1){function s(o){e(o,{point:jt(o)})}return t?$n(s):s}function ne(e,t,s,n){return Mn(e,t,Vn(s,t==="pointerdown"),n)}var Bn=Object.defineProperty,Ln=(e,t,s)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Ln(e,typeof t!="symbol"?t+"":t,s),s),On=class{constructor(e,t,s){T(this,"history",[]),T(this,"startEvent",null),T(this,"lastEvent",null),T(this,"lastEventInfo",null),T(this,"handlers",{}),T(this,"removeListeners",()=>{}),T(this,"threshold",3),T(this,"win"),T(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Kn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:x}=at();this.history.push({...c.point,timestamp:x});const{onStart:f,onMove:g}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),g==null||g(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Cn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:x,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!x||!this.startEvent)&&(x==null||x(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,zn(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:jt(e)},{timestamp:a}=at();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Hn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),In.update(this.updatePoint)}};function lt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:lt(e.point,t[t.length-1]),offset:lt(e.point,t[0]),velocity:Un(t,.1)}}var Gn=e=>e*1e3;function Un(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Gn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Hn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function it(e){return"x"in e&&"y"in e}function Kn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(it(e)&&it(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function kt(e){const t=d.useRef(null);return t.current=e,t}function Wn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),x=kt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,g){u.current=null,o==null||o(f,g)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(x.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function g(p){u.current=new On(p,x.current,c)}return ne(f,"pointerdown",g)},[e,i,x,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Yn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var Xn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Zn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return Xn(()=>{const l=e(),c=l.map((i,u)=>Yn(i,x=>{n(f=>[...f.slice(0,u),x,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Zn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function Jn(e){return typeof e=="object"&&e!==null&&"current"in e}function Qn(e){const[t]=qn({observeMutation:!1,getNodes(){return[Jn(e)?e.current:e]}});return t}function es(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:x,isDisabled:f,isReadOnly:g,onChangeStart:p,onChangeEnd:k,step:y=1,getAriaValueText:w,"aria-valuetext":N,"aria-label":B,"aria-labelledby":b,name:D,focusThumbOnChange:Dt=!0,...Ve}=e,Be=Se(p),G=Se(k),Le=Se(w),I=_n({isReversed:c,direction:i,orientation:u}),[zt,de]=nn({value:a,defaultValue:l??ns(s,n),onChange:o}),[he,Oe]=d.useState(!1),[fe,Ge]=d.useState(!1),xe=!(f||g),me=(n-s)/10,U=y||(n-s)/100,S=je(zt,s,n),Rt=n-S+s,Ue=rt(I?Rt:S,s,n),J=u==="vertical",j=kt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:I,isVertical:J,eventSource:null,focusThumbOnChange:Dt,orientation:u}),pe=d.useRef(null),ge=d.useRef(null),He=d.useRef(null),At=d.useId(),Ke=x??At,[We,Ye]=[`slider-thumb-${Ke}`,`slider-track-${Ke}`],Ft=d.useCallback(h=>{var m,H;if(!pe.current)return;const P=j.current;P.eventSource="pointer";const _=pe.current.getBoundingClientRect(),{clientX:ye,clientY:Ut}=(H=(m=h.touches)==null?void 0:m[0])!=null?H:h,Ht=J?_.bottom-Ut:ye-_.left,Kt=J?_.height:_.width;let we=Ht/Kt;I&&(we=1-we);let K=dn(we,P.min,P.max);return P.step&&(K=parseFloat(st(K,P.min,P.step))),K=je(K,P.min,P.max),K},[J,I,j]),z=d.useCallback(h=>{const m=j.current;m.isInteractive&&(h=parseFloat(st(h,m.min,U)),h=je(h,m.min,m.max),de(h))},[U,de,j]),R=d.useMemo(()=>({stepUp(h=U){const m=I?S-h:S+h;z(m)},stepDown(h=U){const m=I?S+h:S-h;z(m)},reset(){z(l||0)},stepTo(h){z(h)}}),[z,I,S,U,l]),Xe=d.useCallback(h=>{const m=j.current,P={ArrowRight:()=>R.stepUp(),ArrowUp:()=>R.stepUp(),ArrowLeft:()=>R.stepDown(),ArrowDown:()=>R.stepDown(),PageUp:()=>R.stepUp(me),PageDown:()=>R.stepDown(me),Home:()=>z(m.min),End:()=>z(m.max)}[h.key];P&&(h.preventDefault(),h.stopPropagation(),P(h),m.eventSource="keyboard")},[R,z,me,j]),Ze=(t=Le==null?void 0:Le(S))!=null?t:N,ve=Qn(ge),{getThumbStyle:qe,rootStyle:Je,trackStyle:Qe,innerTrackStyle:et}=d.useMemo(()=>{const h=j.current,m=ve??{width:0,height:0};return Nn({isReversed:I,orientation:h.orientation,thumbRects:[m],thumbPercents:[Ue]})},[I,ve,Ue,j]),tt=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var m;return(m=ge.current)==null?void 0:m.focus()})},[j]);Wt(()=>{const h=j.current;tt(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function nt(h){const m=Ft(h);m!=null&&m!==j.current.value&&de(m)}Wn(He,{onPanSessionStart(h){const m=j.current;m.isInteractive&&(Oe(!0),tt(),nt(h),Be==null||Be(m.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Oe(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&nt(h)}});const $t=d.useCallback((h={},m=null)=>({...h,...Ve,ref:be(m,He),tabIndex:-1,"aria-disabled":ke(f),"data-focused":L(fe),style:{...h.style,...Je}}),[Ve,f,fe,Je]),Vt=d.useCallback((h={},m=null)=>({...h,ref:be(m,pe),id:Ye,"data-disabled":L(f),style:{...h.style,...Qe}}),[f,Ye,Qe]),Bt=d.useCallback((h={},m=null)=>({...h,ref:m,style:{...h.style,...et}}),[et]),Lt=d.useCallback((h={},m=null)=>({...h,ref:be(m,ge),role:"slider",tabIndex:xe?0:void 0,id:We,"data-active":L(he),"aria-valuetext":Ze,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(g),"aria-label":B,"aria-labelledby":B?void 0:b,style:{...h.style,...qe(0)},onKeyDown:Pe(h.onKeyDown,Xe),onFocus:Pe(h.onFocus,()=>Ge(!0)),onBlur:Pe(h.onBlur,()=>Ge(!1))}),[xe,We,he,Ze,s,n,S,u,f,g,B,b,qe,Xe]),Ot=d.useCallback((h,m=null)=>{const H=!(h.valuen),P=S>=h.value,_=rt(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ts({orientation:u,vertical:{bottom:I?`${100-_}%`:`${_}%`},horizontal:{left:I?`${100-_}%`:`${_}%`}})};return{...h,ref:m,role:"presentation","aria-hidden":!0,"data-disabled":L(f),"data-invalid":L(!H),"data-highlighted":L(P),style:{...h.style,...ye}}},[f,I,n,s,u,S]),Gt=d.useCallback((h={},m=null)=>({...h,ref:m,type:"hidden",value:S,name:D}),[D,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:R,getRootProps:$t,getTrackProps:Vt,getInnerTrackProps:Bt,getThumbProps:Lt,getMarkerProps:Ot,getInputProps:Gt}}function ts(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function ns(e,t){return t"}),[rs,ie]=ct({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Pt=V((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=ut("Slider",n),a=Ae(n),{direction:l}=Yt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=es(a),x=i(),f=c({},t);return r.jsx(ss,{value:u,children:r.jsx(rs,{value:o,children:r.jsxs(E.div,{...x,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});Pt.displayName="Slider";var Ct=V((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});Ct.displayName="SliderThumb";var It=V((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});It.displayName="SliderTrack";var Tt=V((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Tt.displayName="SliderFilledTrack";var os=V((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});os.displayName="SliderMark";var De=V(function(t,s){const n=ut("Switch",t),{spacing:o="0.5rem",children:a,...l}=Ae(t),{getIndicatorProps:c,getInputProps:i,getCheckboxProps:u,getRootProps:x,getLabelProps:f}=Sn(l),g=d.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...n.container}),[n.container]),p=d.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...n.track}),[n.track]),k=d.useMemo(()=>({userSelect:"none",marginStart:o,...n.label}),[o,n.label]);return r.jsxs(E.label,{...x(),className:dt("chakra-switch",t.className),__css:g,children:[r.jsx("input",{className:"chakra-switch__input",...i({},s)}),r.jsx(E.span,{...u(),className:"chakra-switch__track",__css:p,children:r.jsx(E.span,{__css:n.thumb,className:"chakra-switch__thumb",...c()})}),a&&r.jsx(E.span,{className:"chakra-switch__label",...f(),__css:k,children:a})]})});De.displayName="Switch";function as(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var ls=["h","minH","height","minHeight"],Et=V((e,t)=>{const s=Xt("Textarea",e),{className:n,rows:o,...a}=Ae(e),l=sn(a),c=o?as(s,ls):s;return r.jsx(E.textarea,{ref:t,rows:o,...l,className:dt("chakra-textarea",n),__css:c})});Et.displayName="Textarea";var is=Fe("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Nt=Fe("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),_t=Fe("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const cs=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(v,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(on,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(is,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(hn,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null},us=({inputItem:e})=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(an,{value:e.inputValue,onChange:t=>{}})]}),ds=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(fn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(xn,{}),r.jsxs(mn,{children:[r.jsx(pn,{}),r.jsx(gn,{})]})]})]}),r.jsx(v,{children:r.jsxs(Pt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(It,{children:r.jsx(Tt,{})}),r.jsx(Ct,{})]})})]})},hs=e=>{var s;const{inputItem:t}=e;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(wn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},fs=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsx(v,{children:t.label??t.inputName}),r.jsx(Et,{value:t.inputValue,onChange:s=>{},rows:5})]})};var C=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(C||{});const xs=e=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(v,{children:"No Support"})]}),ms=e=>{const t=e.inputItem;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx($e,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ps={[C.Input]:us,[C.InputSlider]:ds,[C.Select]:hs,[C.Textarea]:fs,[C.Checkbox]:ms,NoSupport:xs},gs=LiteGraph.registered_node_types;function vs(e,t){var o,a,l,c,i;const s=(o=gs[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:C.Textarea}:{type:C.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:C.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:C.Select}:{type:C.NoSupport}}const ze=({inputItem:e})=>{const t=vs(e.classType,e.inputName),[s,n]=d.useState(!1),o=ps[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(v,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(M,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Nt,{size:14}):r.jsx(_t,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function ys(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(v,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function ws(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(Ss,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(v,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function Ss({title:e,children:t}){return r.jsxs(xt,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],Re=new Set;function Mt(e,t){if(!Re.has(e.nodeID))return Re.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Mt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function bs(e){se=[],Re=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Mt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function js({media:e}){const[t,s]=d.useState([]),{curFlowID:n}=d.useContext(oe),[o,a]=d.useState(),[l,c]=d.useState(!0),[i,u]=d.useState(!0);d.useEffect(()=>{e?ln(`/workspace/view_media?filename=${e.localPath}`).then(p=>{a(p.prompt)}):ot.graphToPrompt(ot.graph).then(p=>{a(p.output)})},[e]),d.useEffect(()=>{if(!o)return;const p=bs(o);s(p)},[o]);const[x,f]=d.useState([]);d.useEffect(()=>{(async()=>{var p,k;if(n){const y=(k=await((p=A)==null?void 0:p.get(n)))==null?void 0:k.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const g=p=>{var k,y;if(re(x,{name:p.name,promptKey:p==null?void 0:p.promptKey,classType:(p==null?void 0:p.class_type)??""})){const w=x.filter(N=>N.name!==p.name||N.promptKey!==p.promptKey);f(w),n&&((k=A)==null||k.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...x,p];f(w),n&&((y=A)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:x,showNodeName:i,calcInputList:t,updateTopField:g},children:r.jsxs(v,{direction:"column",align:"stretch",gap:5,children:[r.jsx(ys,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(De,{isChecked:l,onChange:p=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(De,{isChecked:i,onChange:p=>u(!i)})]}),l&&r.jsx(ws,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),ks=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ht();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=A)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(v,{flexWrap:"wrap",gap:3,children:[r.jsx(v,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(M,{size:"sm",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(v,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:pt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=$)==null?void 0:u.delete(e.id)),n(x=>x.filter(f=>f.id!==e.id)))}})}),((c=(l=A)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(F,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Nt,{size:19}):r.jsx(_t,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=A)==null?void 0:i.updateMetaInfo(A.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(ft,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ps=({media:e})=>r.jsxs(v,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(ks,{media:e}),r.jsx(js,{media:e??null})]}),Te=120;function Cs({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(v,{gap:3,h:"100%",children:[r.jsxs(bn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(cs,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(v,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(xt,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(vt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=$)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ps,{media:t??void 0})]})}const Is=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ht();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx($e,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(vt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=$)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(F,{label:pt(e.createTime,!0),children:i}),r.jsx(F,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(ft,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var x;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((x=$)==null?void 0:x.delete(e.id))}})})]})]})},Ts=Is;function Es({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=$)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=$)==null||i.filter(u=>{var x;return((x=u.workflowJSON)==null?void 0:x.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ts,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Os({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[x,f]=d.useState(),[g,p]=d.useState(""),k=vn(g,300),[y,w]=d.useState(!1),N=async()=>{var D;if(t==null)return;const b=await((D=$)==null?void 0:D.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;N(),t&&((b=A)==null||b.get(t).then(D=>{D&&n(D.name)}))},[]),t==null)return null;const B=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:x??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:w},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(cn,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(yn,{searchValue:g,onUpdateSearchValue:b=>{p(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx($e,{isChecked:B,onChange:()=>{a(B?[]:i.map(b=>b.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(M,{size:"sm",icon:r.jsx(un,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(Es,{searchQuery:k}):r.jsx(Cs,{mediaList:i})})]})]})})}export{Os as default};
diff --git a/dist/workspace_web/GalleryModal-pPf4t3nM.js b/dist/workspace_web/GalleryModal-pPf4t3nM.js
new file mode 100644
index 0000000..1de97e7
--- /dev/null
+++ b/dist/workspace_web/GalleryModal-pPf4t3nM.js
@@ -0,0 +1 @@
+import{r as d,d as Se,y as Wt,m as be,b as ct,f as V,l as ut,o as Ae,E as Yt,j as r,g as E,h as dt,p as Xt,W as ht,i as ft,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{a9 as nn,aa as sn,d as Fe,F as v,ab as rn,ac as on,I as M,j as an,g as Ee,B as xt,h as W,Z as oe,ad as ln,x as A,H as Y,i as F,w as mt,a2 as pt,e as gt,a1 as $,ae as cn,y as un}from"./App-bXo9NVT7.js";import{c as je,p as dn,r as st,v as rt,I as hn,N as fn,a as xn,b as mn,d as pn,e as gn,M as vt,u as vn,S as yn}from"./MediaPreview-KLEWGSXc.js";import{S as wn}from"./chunk-3RSXBRAN-8cE0TZNF.js";import{u as Sn,C as $e,G as bn}from"./chunk-JARCRF6W-xouhmv4h.js";import{app as ot}from"/scripts/app.js";import{L as Ne}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import"/scripts/api.js";import"./IconSearch-e7N1azjj.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,jn=typeof performance<"u"?()=>performance.now():()=>Date.now(),wt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(jn()),yt);function kn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,x=!1)=>{const f=x&&o,g=f?t:s;return u&&l.add(i),g.indexOf(i)===-1&&(g.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=kn(()=>X=!0),e),{}),Cn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||En(),s.schedule(n,o,a)),e},{}),In=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(O),e),{});const Tn=e=>ae[e].process(O),St=e=>{X=!1,O.delta=_e?yt:Math.max(Math.min(e-O.timestamp,Pn),1),O.timestamp=e,Me=!0,Z.forEach(Tn),Me=!1,X&&(_e=!1,wt(St))},En=()=>{X=!0,_e=!0,Me||wt(St)},at=()=>O;var L=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function Nn(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const N=(w=n[y])!=null?w:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${N.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${N.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,w)=>ee(y).height>ee(w).height?y:w,te):n.reduce((y,w)=>ee(y).width>ee(w).width?y:w,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,x=[0,o?100-s[0]:s[0]],f=u?x:s;let g=f[0];!u&&o&&(g=100-g);const p=Math.abs(f[f.length-1]-f[0]),k={...i,...Q({orientation:t,vertical:o?{height:`${p}%`,top:`${g}%`}:{height:`${p}%`,bottom:`${g}%`},horizontal:o?{width:`${p}%`,right:`${g}%`}:{width:`${p}%`,left:`${g}%`}})};return{trackStyle:i,innerTrackStyle:k,rootStyle:c,getThumbStyle:a}}function _n(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Mn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Dn(e){const t=Rn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function bt(e){return!!e.touches}function zn(e){return bt(e)&&e.touches.length>1}function Rn(e){var t;return(t=e.view)!=null?t:window}function An(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Fn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function jt(e,t="page"){return bt(e)?An(e,t):Fn(e,t)}function $n(e){return t=>{const s=Dn(t);(!s||s&&t.button===0)&&e(t)}}function Vn(e,t=!1){function s(o){e(o,{point:jt(o)})}return t?$n(s):s}function ne(e,t,s,n){return Mn(e,t,Vn(s,t==="pointerdown"),n)}var Bn=Object.defineProperty,Ln=(e,t,s)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Ln(e,typeof t!="symbol"?t+"":t,s),s),On=class{constructor(e,t,s){T(this,"history",[]),T(this,"startEvent",null),T(this,"lastEvent",null),T(this,"lastEventInfo",null),T(this,"handlers",{}),T(this,"removeListeners",()=>{}),T(this,"threshold",3),T(this,"win"),T(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Kn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:x}=at();this.history.push({...c.point,timestamp:x});const{onStart:f,onMove:g}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),g==null||g(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Cn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:x,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!x||!this.startEvent)&&(x==null||x(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,zn(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:jt(e)},{timestamp:a}=at();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Hn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),In.update(this.updatePoint)}};function lt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:lt(e.point,t[t.length-1]),offset:lt(e.point,t[0]),velocity:Un(t,.1)}}var Gn=e=>e*1e3;function Un(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Gn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Hn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function it(e){return"x"in e&&"y"in e}function Kn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(it(e)&&it(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function kt(e){const t=d.useRef(null);return t.current=e,t}function Wn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),x=kt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,g){u.current=null,o==null||o(f,g)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(x.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function g(p){u.current=new On(p,x.current,c)}return ne(f,"pointerdown",g)},[e,i,x,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Yn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var Xn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Zn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return Xn(()=>{const l=e(),c=l.map((i,u)=>Yn(i,x=>{n(f=>[...f.slice(0,u),x,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Zn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function Jn(e){return typeof e=="object"&&e!==null&&"current"in e}function Qn(e){const[t]=qn({observeMutation:!1,getNodes(){return[Jn(e)?e.current:e]}});return t}function es(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:x,isDisabled:f,isReadOnly:g,onChangeStart:p,onChangeEnd:k,step:y=1,getAriaValueText:w,"aria-valuetext":N,"aria-label":B,"aria-labelledby":b,name:D,focusThumbOnChange:Dt=!0,...Ve}=e,Be=Se(p),G=Se(k),Le=Se(w),I=_n({isReversed:c,direction:i,orientation:u}),[zt,de]=nn({value:a,defaultValue:l??ns(s,n),onChange:o}),[he,Oe]=d.useState(!1),[fe,Ge]=d.useState(!1),xe=!(f||g),me=(n-s)/10,U=y||(n-s)/100,S=je(zt,s,n),Rt=n-S+s,Ue=rt(I?Rt:S,s,n),J=u==="vertical",j=kt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:I,isVertical:J,eventSource:null,focusThumbOnChange:Dt,orientation:u}),pe=d.useRef(null),ge=d.useRef(null),He=d.useRef(null),At=d.useId(),Ke=x??At,[We,Ye]=[`slider-thumb-${Ke}`,`slider-track-${Ke}`],Ft=d.useCallback(h=>{var m,H;if(!pe.current)return;const P=j.current;P.eventSource="pointer";const _=pe.current.getBoundingClientRect(),{clientX:ye,clientY:Ut}=(H=(m=h.touches)==null?void 0:m[0])!=null?H:h,Ht=J?_.bottom-Ut:ye-_.left,Kt=J?_.height:_.width;let we=Ht/Kt;I&&(we=1-we);let K=dn(we,P.min,P.max);return P.step&&(K=parseFloat(st(K,P.min,P.step))),K=je(K,P.min,P.max),K},[J,I,j]),z=d.useCallback(h=>{const m=j.current;m.isInteractive&&(h=parseFloat(st(h,m.min,U)),h=je(h,m.min,m.max),de(h))},[U,de,j]),R=d.useMemo(()=>({stepUp(h=U){const m=I?S-h:S+h;z(m)},stepDown(h=U){const m=I?S+h:S-h;z(m)},reset(){z(l||0)},stepTo(h){z(h)}}),[z,I,S,U,l]),Xe=d.useCallback(h=>{const m=j.current,P={ArrowRight:()=>R.stepUp(),ArrowUp:()=>R.stepUp(),ArrowLeft:()=>R.stepDown(),ArrowDown:()=>R.stepDown(),PageUp:()=>R.stepUp(me),PageDown:()=>R.stepDown(me),Home:()=>z(m.min),End:()=>z(m.max)}[h.key];P&&(h.preventDefault(),h.stopPropagation(),P(h),m.eventSource="keyboard")},[R,z,me,j]),Ze=(t=Le==null?void 0:Le(S))!=null?t:N,ve=Qn(ge),{getThumbStyle:qe,rootStyle:Je,trackStyle:Qe,innerTrackStyle:et}=d.useMemo(()=>{const h=j.current,m=ve??{width:0,height:0};return Nn({isReversed:I,orientation:h.orientation,thumbRects:[m],thumbPercents:[Ue]})},[I,ve,Ue,j]),tt=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var m;return(m=ge.current)==null?void 0:m.focus()})},[j]);Wt(()=>{const h=j.current;tt(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function nt(h){const m=Ft(h);m!=null&&m!==j.current.value&&de(m)}Wn(He,{onPanSessionStart(h){const m=j.current;m.isInteractive&&(Oe(!0),tt(),nt(h),Be==null||Be(m.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Oe(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&nt(h)}});const $t=d.useCallback((h={},m=null)=>({...h,...Ve,ref:be(m,He),tabIndex:-1,"aria-disabled":ke(f),"data-focused":L(fe),style:{...h.style,...Je}}),[Ve,f,fe,Je]),Vt=d.useCallback((h={},m=null)=>({...h,ref:be(m,pe),id:Ye,"data-disabled":L(f),style:{...h.style,...Qe}}),[f,Ye,Qe]),Bt=d.useCallback((h={},m=null)=>({...h,ref:m,style:{...h.style,...et}}),[et]),Lt=d.useCallback((h={},m=null)=>({...h,ref:be(m,ge),role:"slider",tabIndex:xe?0:void 0,id:We,"data-active":L(he),"aria-valuetext":Ze,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(g),"aria-label":B,"aria-labelledby":B?void 0:b,style:{...h.style,...qe(0)},onKeyDown:Pe(h.onKeyDown,Xe),onFocus:Pe(h.onFocus,()=>Ge(!0)),onBlur:Pe(h.onBlur,()=>Ge(!1))}),[xe,We,he,Ze,s,n,S,u,f,g,B,b,qe,Xe]),Ot=d.useCallback((h,m=null)=>{const H=!(h.valuen),P=S>=h.value,_=rt(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ts({orientation:u,vertical:{bottom:I?`${100-_}%`:`${_}%`},horizontal:{left:I?`${100-_}%`:`${_}%`}})};return{...h,ref:m,role:"presentation","aria-hidden":!0,"data-disabled":L(f),"data-invalid":L(!H),"data-highlighted":L(P),style:{...h.style,...ye}}},[f,I,n,s,u,S]),Gt=d.useCallback((h={},m=null)=>({...h,ref:m,type:"hidden",value:S,name:D}),[D,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:R,getRootProps:$t,getTrackProps:Vt,getInnerTrackProps:Bt,getThumbProps:Lt,getMarkerProps:Ot,getInputProps:Gt}}function ts(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function ns(e,t){return t"}),[rs,ie]=ct({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Pt=V((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=ut("Slider",n),a=Ae(n),{direction:l}=Yt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=es(a),x=i(),f=c({},t);return r.jsx(ss,{value:u,children:r.jsx(rs,{value:o,children:r.jsxs(E.div,{...x,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});Pt.displayName="Slider";var Ct=V((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});Ct.displayName="SliderThumb";var It=V((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});It.displayName="SliderTrack";var Tt=V((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Tt.displayName="SliderFilledTrack";var os=V((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(E.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});os.displayName="SliderMark";var De=V(function(t,s){const n=ut("Switch",t),{spacing:o="0.5rem",children:a,...l}=Ae(t),{getIndicatorProps:c,getInputProps:i,getCheckboxProps:u,getRootProps:x,getLabelProps:f}=Sn(l),g=d.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...n.container}),[n.container]),p=d.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...n.track}),[n.track]),k=d.useMemo(()=>({userSelect:"none",marginStart:o,...n.label}),[o,n.label]);return r.jsxs(E.label,{...x(),className:dt("chakra-switch",t.className),__css:g,children:[r.jsx("input",{className:"chakra-switch__input",...i({},s)}),r.jsx(E.span,{...u(),className:"chakra-switch__track",__css:p,children:r.jsx(E.span,{__css:n.thumb,className:"chakra-switch__thumb",...c()})}),a&&r.jsx(E.span,{className:"chakra-switch__label",...f(),__css:k,children:a})]})});De.displayName="Switch";function as(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var ls=["h","minH","height","minHeight"],Et=V((e,t)=>{const s=Xt("Textarea",e),{className:n,rows:o,...a}=Ae(e),l=sn(a),c=o?as(s,ls):s;return r.jsx(E.textarea,{ref:t,rows:o,...l,className:dt("chakra-textarea",n),__css:c})});Et.displayName="Textarea";var is=Fe("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Nt=Fe("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),_t=Fe("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const cs=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(v,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(on,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(is,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(M,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(hn,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null},us=({inputItem:e})=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(an,{value:e.inputValue,onChange:t=>{}})]}),ds=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(fn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(xn,{}),r.jsxs(mn,{children:[r.jsx(pn,{}),r.jsx(gn,{})]})]})]}),r.jsx(v,{children:r.jsxs(Pt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(It,{children:r.jsx(Tt,{})}),r.jsx(Ct,{})]})})]})},hs=e=>{var s;const{inputItem:t}=e;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(wn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},fs=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsx(v,{children:t.label??t.inputName}),r.jsx(Et,{value:t.inputValue,onChange:s=>{},rows:5})]})};var C=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(C||{});const xs=e=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(v,{children:"No Support"})]}),ms=e=>{const t=e.inputItem;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx($e,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ps={[C.Input]:us,[C.InputSlider]:ds,[C.Select]:hs,[C.Textarea]:fs,[C.Checkbox]:ms,NoSupport:xs},gs=LiteGraph.registered_node_types;function vs(e,t){var o,a,l,c,i;const s=(o=gs[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:C.Textarea}:{type:C.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:C.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:C.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:C.Select}:{type:C.NoSupport}}const ze=({inputItem:e})=>{const t=vs(e.classType,e.inputName),[s,n]=d.useState(!1),o=ps[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(v,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(M,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Nt,{size:14}):r.jsx(_t,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function ys(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(v,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function ws(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(Ss,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(v,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function Ss({title:e,children:t}){return r.jsxs(xt,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],Re=new Set;function Mt(e,t){if(!Re.has(e.nodeID))return Re.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Mt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function bs(e){se=[],Re=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Mt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function js({media:e}){const[t,s]=d.useState([]),{curFlowID:n}=d.useContext(oe),[o,a]=d.useState(),[l,c]=d.useState(!0),[i,u]=d.useState(!0);d.useEffect(()=>{e?ln(`/workspace/view_media?filename=${e.localPath}`).then(p=>{a(p.prompt)}):ot.graphToPrompt(ot.graph).then(p=>{a(p.output)})},[e]),d.useEffect(()=>{if(!o)return;const p=bs(o);s(p)},[o]);const[x,f]=d.useState([]);d.useEffect(()=>{(async()=>{var p,k;if(n){const y=(k=await((p=A)==null?void 0:p.get(n)))==null?void 0:k.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const g=p=>{var k,y;if(re(x,{name:p.name,promptKey:p==null?void 0:p.promptKey,classType:(p==null?void 0:p.class_type)??""})){const w=x.filter(N=>N.name!==p.name||N.promptKey!==p.promptKey);f(w),n&&((k=A)==null||k.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...x,p];f(w),n&&((y=A)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:x,showNodeName:i,calcInputList:t,updateTopField:g},children:r.jsxs(v,{direction:"column",align:"stretch",gap:5,children:[r.jsx(ys,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(De,{isChecked:l,onChange:p=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(De,{isChecked:i,onChange:p=>u(!i)})]}),l&&r.jsx(ws,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),ks=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ht();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=A)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(v,{flexWrap:"wrap",gap:3,children:[r.jsx(v,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(M,{size:"sm",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(v,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:pt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=$)==null?void 0:u.delete(e.id)),n(x=>x.filter(f=>f.id!==e.id)))}})}),((c=(l=A)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(F,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Nt,{size:19}):r.jsx(_t,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=A)==null?void 0:i.updateMetaInfo(A.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(ft,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ps=({media:e})=>r.jsxs(v,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(ks,{media:e}),r.jsx(js,{media:e??null})]}),Te=120;function Cs({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(v,{gap:3,h:"100%",children:[r.jsxs(bn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(cs,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(v,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(xt,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(vt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=$)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ps,{media:t??void 0})]})}const Is=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ht();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx($e,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(vt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=$)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(F,{label:pt(e.createTime,!0),children:i}),r.jsx(F,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(ft,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(F,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(F,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(gt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var x;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((x=$)==null?void 0:x.delete(e.id))}})})]})]})},Ts=Is;function Es({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=$)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=$)==null||i.filter(u=>{var x;return((x=u.workflowJSON)==null?void 0:x.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ts,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Os({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[x,f]=d.useState(),[g,p]=d.useState(""),k=vn(g,300),[y,w]=d.useState(!1),N=async()=>{var D;if(t==null)return;const b=await((D=$)==null?void 0:D.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;N(),t&&((b=A)==null||b.get(t).then(D=>{D&&n(D.name)}))},[]),t==null)return null;const B=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:x??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:w},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(cn,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(yn,{searchValue:g,onUpdateSearchValue:b=>{p(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx($e,{isChecked:B,onChange:()=>{a(B?[]:i.map(b=>b.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(M,{size:"sm",icon:r.jsx(un,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(Es,{searchQuery:k}):r.jsx(Cs,{mediaList:i})})]})]})})}export{Os as default};
diff --git a/dist/workspace_web/IconCopy-j3_qolNw.js b/dist/workspace_web/IconCopy-wyTg5wiq.js
similarity index 83%
rename from dist/workspace_web/IconCopy-j3_qolNw.js
rename to dist/workspace_web/IconCopy-wyTg5wiq.js
index 896913e..5c66076 100644
--- a/dist/workspace_web/IconCopy-j3_qolNw.js
+++ b/dist/workspace_web/IconCopy-wyTg5wiq.js
@@ -1 +1 @@
-import{d as a}from"./App-YT7a4Gj6.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I};
+import{d as a}from"./App-bXo9NVT7.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I};
diff --git a/dist/workspace_web/IconSearch-yd7KVSRG.js b/dist/workspace_web/IconSearch-e7N1azjj.js
similarity index 67%
rename from dist/workspace_web/IconSearch-yd7KVSRG.js
rename to dist/workspace_web/IconSearch-e7N1azjj.js
index a924ef7..b404cef 100644
--- a/dist/workspace_web/IconSearch-yd7KVSRG.js
+++ b/dist/workspace_web/IconSearch-e7N1azjj.js
@@ -1 +1 @@
-import{d as a}from"./App-YT7a4Gj6.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I};
+import{d as a}from"./App-bXo9NVT7.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I};
diff --git a/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js b/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js
new file mode 100644
index 0000000..82de30d
--- /dev/null
+++ b/dist/workspace_web/InstallMissingModelsButton-OE80g4ub.js
@@ -0,0 +1 @@
+import{r as o,j as e,i as C,P as k}from"./input.js";import{app as x}from"/scripts/app.js";import{aO as b,g as I,h as v,H as y,i as S,ac as E,_ as F,am as D,Z as A,ar as z,f as H,B as L,a4 as P,a5 as O,aP as R,F as T,ae as G,aD as N}from"./App-bXo9NVT7.js";import{G as U,i as W}from"./ModelManagerTopbar-wj7k34WI.js";import{C as q,G as B}from"./chunk-JARCRF6W-xouhmv4h.js";import{S as K}from"./chunk-3RSXBRAN-8cE0TZNF.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const Y="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png",Z="https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa";function $({model:l,selectedModelDeps:c,setSelectedModelDeps:n,foldersList:d,setFoldersList:h}){var m,t,a,g,_;const[s,u]=o.useState(),p=(a=(t=(m=x.graph.extra)==null?void 0:m[b])==null?void 0:t.deps)==null?void 0:a.models;o.useEffect(()=>{(async()=>{var f;if(p){const M=p[l.received_value];if((f=p[l.received_value])!=null&&f.downloadUrl){const w=await D.models.where({fileHash:M.fileHash}).toArray();w[0]?u({existingModel:w[0].fileName}):u(M)}}})()},[]);const j=c.map(i=>i.filename);function r(i){return i.existingModel!=null}return e.jsx(U,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(I,{align:"start",children:[e.jsx(v,{children:l.class_type}),e.jsx(y,{ml:3,children:e.jsx(v,{color:"red.400",children:l.received_value})}),s&&r(s)&&e.jsxs(v,{children:["This model is already installed as"," ",e.jsx(v,{as:"span",color:"blue.400",fontWeight:600,children:s.existingModel})]}),s&&!r(s)&&s.fileFolder&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{children:[e.jsx(q,{size:"sm",isChecked:j.includes(s.filename),onChange:i=>{i.target.checked?n([...c,p[l.received_value]]):n(c.filter(f=>f.filename!==s.filename))}},s.filename),e.jsx(S,{label:s.infoUrl,children:e.jsx(C,{size:"sm",onClick:i=>{i.stopPropagation(),window.open(s.infoUrl??"","_blank")},leftIcon:e.jsx(E,{width:5,src:(g=s.downloadUrl)!=null&&g.includes("huggingface")?Y:Z}),rightIcon:e.jsx(F,{size:20}),children:s.filename})})]}),e.jsxs(I,{children:[e.jsx(v,{width:"fit-content",children:"Install path:"}),((_=d[s.fileFolder])==null?void 0:_.length)&&e.jsx(K,{value:d[s.fileFolder].at(0),onChange:i=>{const f={...d},M=f[s.fileFolder].filter(w=>w!==i.target.value);f[s.fileFolder]=[i.target.value,...M],h(f)},children:d[s.fileFolder].map(i=>e.jsx("option",{value:i,children:i},i))})]})]}),!s&&e.jsx(C,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(F,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v7&query=${l.received_value}`,"_blank")},children:"Search in CivitAI"})]})})}function V({onClose:l,missingModels:c}){o.useEffect(()=>(x.canvasEl.addEventListener("click",l),()=>{x.canvasEl.removeEventListener("click",l)}),[]);const[n,d]=o.useState([]),[h,s]=o.useState({}),{setRoute:u}=o.useContext(A),p=o.useCallback(async()=>{const t=await z();t&&s(t)},[]),j=H();o.useEffect(()=>{p()},[]);const r=480,m=()=>{n.forEach(t=>{let a=t.downloadUrl;if(!a||!t.fileFolder||!h[t.fileFolder][0]){j({title:"Error",description:a?"Model install folder path is missing":"Download URL is missing",status:"error",duration:4e3,isClosable:!0});return}if(a.includes("civitai")){const g=N();g&&(a+=`?token=${g}`)}W({file_hash:t.fileHash??void 0,filename:t.filename,save_path:h[t.fileFolder][0],url:a,force_filename:!0})}),j({title:"Installing...Please open Install Models modal or python terminal to view progress.",description:n.map(t=>t.filename).join(", "),status:"info",duration:4e3,isClosable:!0}),u("installModels")};return e.jsx(k,{children:e.jsx(L,{style:{width:r},children:e.jsxs(P,{width:r,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:O,overflowY:"auto",children:[e.jsx(R,{children:e.jsx(T,{justifyContent:"space-between",alignContent:"center",children:e.jsx(G,{size:"md",mr:2,children:"Missing Models"})})}),e.jsxs(C,{width:"fit-content",colorScheme:"teal",size:"sm",onClick:m,children:["Install Selected (",n.length,")"]}),e.jsx(B,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:c.map(t=>e.jsx($,{model:t,setSelectedModelDeps:d,selectedModelDeps:n,foldersList:h,setFoldersList:s},t.received_value))})]})})})}function le({}){const[l,c]=o.useState(!1),[n,d]=o.useState([]);return o.useEffect(()=>{const h=x.queuePrompt;x.queuePrompt=async function(){var s,u;try{await h.apply(this,arguments)}finally{if(!((u=(s=x.graph.extra)==null?void 0:s[b])==null?void 0:u.deps))return;const j=x.lastNodeErrors??{};d(Object.values(j).flatMap(r=>{var m,t;return(t=(m=r==null?void 0:r.errors)==null?void 0:m.filter(a=>(a==null?void 0:a.type)==="value_not_in_list"))==null?void 0:t.map(a=>{const{input_name:g,received_value:_}=a.extra_info;return{class_type:r.class_type,input_name:g,received_value:_}})}))}}},[]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(C,{size:"sm","aria-label":"missing models",px:2,onClick:()=>c(!0),colorScheme:"teal",children:["Install Missing (",n.length,")"]}),l&&e.jsx(V,{onClose:()=>c(!1),missingModels:n})]})}export{le as default};
diff --git a/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js b/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js
deleted file mode 100644
index 9a0305d..0000000
--- a/dist/workspace_web/InstallMissingModelsButton-at3wACEK.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as o,j as e,i as C,P as k}from"./input.js";import{app as x}from"/scripts/app.js";import{aO as b,g as I,h as v,H as y,i as S,ac as E,a1 as F,am as D,Z as A,ar as z,f as H,B as L,a4 as P,a5 as O,aP as R,F as T,ae as G,aD as N}from"./App-YT7a4Gj6.js";import{G as U,i as W}from"./ModelManagerTopbar-jwv1A1hH.js";import{C as q,G as B}from"./chunk-JARCRF6W-66xSMED8.js";import{S as K}from"./chunk-3RSXBRAN-xkXXv8lg.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const Y="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png",Z="https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa";function $({model:l,selectedModelDeps:c,setSelectedModelDeps:n,foldersList:d,setFoldersList:h}){var m,t,a,g,_;const[s,u]=o.useState(),p=(a=(t=(m=x.graph.extra)==null?void 0:m[b])==null?void 0:t.deps)==null?void 0:a.models;o.useEffect(()=>{(async()=>{var f;if(p){const M=p[l.received_value];if((f=p[l.received_value])!=null&&f.downloadUrl){const w=await D.models.where({fileHash:M.fileHash}).toArray();w[0]?u({existingModel:w[0].fileName}):u(M)}}})()},[]);const j=c.map(i=>i.filename);function r(i){return i.existingModel!=null}return e.jsx(U,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(I,{align:"start",children:[e.jsx(v,{children:l.class_type}),e.jsx(y,{ml:3,children:e.jsx(v,{color:"red.400",children:l.received_value})}),s&&r(s)&&e.jsxs(v,{children:["This model is already installed as"," ",e.jsx(v,{as:"span",color:"blue.400",fontWeight:600,children:s.existingModel})]}),s&&!r(s)&&s.fileFolder&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{children:[e.jsx(q,{size:"sm",isChecked:j.includes(s.filename),onChange:i=>{i.target.checked?n([...c,p[l.received_value]]):n(c.filter(f=>f.filename!==s.filename))}},s.filename),e.jsx(S,{label:s.infoUrl,children:e.jsx(C,{size:"sm",onClick:i=>{i.stopPropagation(),window.open(s.infoUrl??"","_blank")},leftIcon:e.jsx(E,{width:5,src:(g=s.downloadUrl)!=null&&g.includes("huggingface")?Y:Z}),rightIcon:e.jsx(F,{size:20}),children:s.filename})})]}),e.jsxs(I,{children:[e.jsx(v,{width:"fit-content",children:"Install path:"}),((_=d[s.fileFolder])==null?void 0:_.length)&&e.jsx(K,{value:d[s.fileFolder].at(0),onChange:i=>{const f={...d},M=f[s.fileFolder].filter(w=>w!==i.target.value);f[s.fileFolder]=[i.target.value,...M],h(f)},children:d[s.fileFolder].map(i=>e.jsx("option",{value:i,children:i},i))})]})]}),!s&&e.jsx(C,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(F,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v7&query=${l.received_value}`,"_blank")},children:"Search in CivitAI"})]})})}function V({onClose:l,missingModels:c}){o.useEffect(()=>(x.canvasEl.addEventListener("click",l),()=>{x.canvasEl.removeEventListener("click",l)}),[]);const[n,d]=o.useState([]),[h,s]=o.useState({}),{setRoute:u}=o.useContext(A),p=o.useCallback(async()=>{const t=await z();t&&s(t)},[]),j=H();o.useEffect(()=>{p()},[]);const r=480,m=()=>{n.forEach(t=>{let a=t.downloadUrl;if(!a||!t.fileFolder||!h[t.fileFolder][0]){j({title:"Error",description:a?"Model install folder path is missing":"Download URL is missing",status:"error",duration:4e3,isClosable:!0});return}if(a.includes("civitai")){const g=N();g&&(a+=`?token=${g}`)}W({file_hash:t.fileHash??void 0,filename:t.filename,save_path:h[t.fileFolder][0],url:a,force_filename:!0})}),j({title:"Installing...Please open Install Models modal or python terminal to view progress.",description:n.map(t=>t.filename).join(", "),status:"info",duration:4e3,isClosable:!0}),u("installModels")};return e.jsx(k,{children:e.jsx(L,{style:{width:r},children:e.jsxs(P,{width:r,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:O,overflowY:"auto",children:[e.jsx(R,{children:e.jsx(T,{justifyContent:"space-between",alignContent:"center",children:e.jsx(G,{size:"md",mr:2,children:"Missing Models"})})}),e.jsxs(C,{width:"fit-content",colorScheme:"teal",size:"sm",onClick:m,children:["Install Selected (",n.length,")"]}),e.jsx(B,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:c.map(t=>e.jsx($,{model:t,setSelectedModelDeps:d,selectedModelDeps:n,foldersList:h,setFoldersList:s},t.received_value))})]})})})}function le({}){const[l,c]=o.useState(!1),[n,d]=o.useState([]);return o.useEffect(()=>{const h=x.queuePrompt;x.queuePrompt=async function(){var s,u;try{await h.apply(this,arguments)}finally{if(!((u=(s=x.graph.extra)==null?void 0:s[b])==null?void 0:u.deps))return;const j=x.lastNodeErrors??{};d(Object.values(j).flatMap(r=>{var m,t;return(t=(m=r==null?void 0:r.errors)==null?void 0:m.filter(a=>(a==null?void 0:a.type)==="value_not_in_list"))==null?void 0:t.map(a=>{const{input_name:g,received_value:_}=a.extra_info;return{class_type:r.class_type,input_name:g,received_value:_}})}))}}},[]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(C,{size:"sm","aria-label":"missing models",px:2,onClick:()=>c(!0),colorScheme:"teal",children:["Install Missing (",n.length,")"]}),l&&e.jsx(V,{onClose:()=>c(!1),missingModels:n})]})}export{le as default};
diff --git a/dist/workspace_web/MediaPreview-IFYm2Mq_.js b/dist/workspace_web/MediaPreview-KLEWGSXc.js
similarity index 98%
rename from dist/workspace_web/MediaPreview-IFYm2Mq_.js
rename to dist/workspace_web/MediaPreview-KLEWGSXc.js
index 21ff558..fe5c61a 100644
--- a/dist/workspace_web/MediaPreview-IFYm2Mq_.js
+++ b/dist/workspace_web/MediaPreview-KLEWGSXc.js
@@ -1 +1 @@
-import{d as M,r as s,j as f,I as ke,y as Oe,e as Be,m as ae,s as C,q as se,b as Pe,f as j,g as Y,l as Ke,o as Ue,h as Me}from"./input.js";import{af as Ge,ag as qe,d as He,B as Le,I as $e,y as ze,j as We,ab as Xe,ac as Ye}from"./App-YT7a4Gj6.js";import{I as Je}from"./IconSearch-yd7KVSRG.js";function Qe(n){const e=parseFloat(n);return typeof e!="number"||Number.isNaN(e)?0:e}function le(n,e){let r=Qe(n);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(n){if(!Number.isFinite(n))return 0;let e=1,r=0;for(;Math.round(n*e)/e!==n;)e*=10,r+=1;return r}function It(n,e,r){return(n-e)*100/(r-e)}function yt(n,e,r){return(r-e)*n+e}function Ct(n,e,r){const a=Math.round((n-e)/r)*r+e,u=oe(r);return le(a,u)}function Ze(n,e,r){return n==null?n:(r{var p;return a==null?"":(p=ue(a,o,r))!=null?p:""}),S=typeof u<"u",x=S?u:I,O=Fe(A(x),o),F=r??O,y=s.useCallback(p=>{p!==x&&(S||E(p.toString()),h==null||h(p.toString(),A(p)))},[h,S,x]),w=s.useCallback(p=>{let d=p;return b&&(d=Ze(d,i,m)),le(d,F)},[F,b,m,i]),B=s.useCallback((p=o)=>{let d;x===""?d=A(p):d=A(x)+p,d=w(d),y(d)},[w,o,y,x]),K=s.useCallback((p=o)=>{let d;x===""?d=A(-p):d=A(x)-p,d=w(d),y(d)},[w,o,y,x]),U=s.useCallback(()=>{var p;let d;a==null?d="":d=(p=ue(a,o,r))!=null?p:i,y(d)},[a,r,o,y,i]),Q=s.useCallback(p=>{var d;const ee=(d=ue(p,o,F))!=null?d:i;y(ee)},[F,o,y,i]),k=A(x);return{isOutOfRange:k>m||kf.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=n=>f.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function Ae(n,e,r,a){s.useEffect(()=>{var u;if(!n.current||!a)return;const o=(u=n.current.ownerDocument.defaultView)!=null?u:window,i=Array.isArray(e)?e:[e],m=new o.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return m.observe(n.current,{attributes:!0,attributeFilter:i}),()=>m.disconnect()})}function rt(n,e){const r=M(n);s.useEffect(()=>{let a=null;const u=()=>r();return e!==null&&(a=window.setInterval(u,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,Ee=300;function st(n,e){const[r,a]=s.useState(!1),[u,o]=s.useState(null),[i,m]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);rt(()=>{u==="increment"&&n(),u==="decrement"&&e()},r?at:null);const I=s.useCallback(()=>{i&&n(),b.current=setTimeout(()=>{m(!1),a(!0),o("increment")},Ee)},[n,i]),E=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{m(!1),a(!0),o("decrement")},Ee)},[e,i]),S=s.useCallback(()=>{m(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:I,down:E,stop:S,isSpinning:r}}var ut=/^[Ee0-9+\-.]$/;function ot(n){return ut.test(n)}function lt(n,e){if(n.key==null)return!0;const r=n.ctrlKey||n.altKey||n.metaKey;return!(n.key.length===1)||r?!0:e(n.key)}function it(n={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:u=Number.MIN_SAFE_INTEGER,max:o=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:m,isDisabled:b,isRequired:h,isInvalid:I,pattern:E="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:y,name:w,"aria-describedby":B,"aria-label":K,"aria-labelledby":U,onFocus:Q,onBlur:k,onInvalid:ce,getAriaValueText:de,isValidCharacter:Z,format:p,parse:d,...ee}=n,te=M(Q),pe=M(k),V=M(ce),G=M(Z??ot),ne=M(de),l=et(n),{update:T,increment:me,decrement:fe}=l,[Ve,re]=s.useState(!1),q=!(m||b),_=s.useRef(null),H=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),L=s.useCallback(t=>t.split("").filter(G).join(""),[G]),$=s.useCallback(t=>{var c;return(c=d==null?void 0:d(t))!=null?c:t},[d]),R=s.useCallback(t=>{var c;return((c=p==null?void 0:p(t))!=null?c:t).toString()},[p]);Oe(()=>{(l.valueAsNumber>o||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=$(_.current.value);l.setValue(L(c))}},[$,L]);const z=s.useCallback((t=i)=>{q&&me(t)},[me,q,i]),W=s.useCallback((t=i)=>{q&&fe(t)},[fe,q,i]),g=st(z,W);Ae(be,"disabled",g.stop,g.isSpinning),Ae(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;const v=$(t.currentTarget.value);T(L(v)),H.current={start:t.currentTarget.selectionStart,end:t.currentTarget.selectionEnd}},[T,L,$]),ge=s.useCallback(t=>{var c,v,N;te==null||te(t),H.current&&(t.target.selectionStart=(v=H.current.start)!=null?v:(c=t.currentTarget.value)==null?void 0:c.length,t.currentTarget.selectionEnd=(N=H.current.end)!=null?N:t.currentTarget.selectionStart)},[te]),xe=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;lt(t,G)||t.preventDefault();const c=Ne(t)*i,v=t.key,P={ArrowUp:()=>z(c),ArrowDown:()=>W(c),Home:()=>T(u),End:()=>T(o)}[v];P&&(t.preventDefault(),P(t))},[G,i,z,W,T,u,o]),Ne=t=>{let c=1;return(t.metaKey||t.ctrlKey)&&(c=.1),t.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const t=ne==null?void 0:ne(l.value);if(t!=null)return t;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let t=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumbero&&(t=o),l.cast(t))},[l,o,u]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var t;(t=_.current)==null||t.focus()})},[e]),Se=s.useCallback(t=>{t.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(t=>{t.preventDefault(),g.down(),X()},[X,g]);Ge(()=>_.current,"wheel",t=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;t.preventDefault();const D=Ne(t)*i,_e=Math.sign(t.deltaY);_e===-1?z(D):_e===1&&W(D)},{passive:!1});const Te=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMax;return{...t,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),De=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMin;return{...t,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),je=s.useCallback((t={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:E,"aria-labelledby":U,"aria-label":K,"aria-describedby":B,id:O,disabled:b,...t,readOnly:(v=t.readOnly)!=null?v:m,"aria-readonly":(N=t.readOnly)!=null?N:m,"aria-required":(P=t.required)!=null?P:h,required:(D=t.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":u,"aria-valuemax":o,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(I??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:C(t.onChange,he),onKeyDown:C(t.onKeyDown,xe),onFocus:C(t.onFocus,ge,()=>re(!0)),onBlur:C(t.onBlur,pe,Ce)}},[w,S,E,U,K,R,B,O,b,h,m,I,l.value,l.valueAsNumber,l.isOutOfRange,u,o,Ie,he,xe,ge,pe,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:Ve,isDisabled:b,isReadOnly:m,getIncrementButtonProps:Te,getDecrementButtonProps:De,getInputProps:je,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[dt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),pt=j(function(e,r){const a=Ke("NumberInput",e),u=Ue(e),o=qe(u),{htmlProps:i,...m}=it(o),b=s.useMemo(()=>m,[m]);return f.jsx(dt,{value:b,children:f.jsx(ct,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});pt.displayName="NumberInput";var mt=j(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});mt.displayName="NumberInputStepper";var ft=j(function(e,r){const{getInputProps:a}=ie(),u=a(e,r),o=J();return f.jsx(Y.input,{...u,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...o.field}})});ft.displayName="NumberInputField";var Re=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=j(function(e,r){var a;const u=J(),{getDecrementButtonProps:o}=ie(),i=o(e,r);return f.jsx(Re,{...i,__css:u.stepper,children:(a=e.children)!=null?a:f.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var vt=j(function(e,r){var a;const{getIncrementButtonProps:u}=ie(),o=u(e,r),i=J();return f.jsx(Re,{...o,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(nt,{})})});vt.displayName="NumberIncrementStepper";var St=He("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const wt=(n,e)=>{const[r,a]=s.useState(n);return s.useEffect(()=>{const u=setTimeout(()=>{a(n)},e);return()=>{clearTimeout(u)}},[n,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function _t(n){const{searchValue:e,onUpdateSearchValue:r,style:a}=n,u=e!=="";return f.jsxs(Le,{style:{position:"relative",...a},mb:2,children:[f.jsx(Je,{style:ht}),u&&f.jsx($e,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(ze,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(We,{placeholder:n.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function At({mediaLocalPath:n,size:e,isPreview:r,autoPlay:a,hideBrokenImage:u,objectFit:o,onBrokenLink:i}){const[m,b]=s.useState(!0);return s.useEffect(()=>{u&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${n}`:`/workspace/view_media?filename=${n}`)).status==404){b(!1),i==null||i();return}}catch(I){console.error("Error checking media exists",I)}})()},[]),m?Xe(n)?f.jsx(Ye,{borderRadius:3,boxSize:`${e}px`,objectFit:o??"cover",src:`/workspace/view_media?filename=${n}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${n}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{St as I,At as M,pt as N,_t as S,ft as a,mt as b,Ze as c,vt as d,bt as e,yt as p,Ct as r,wt as u,It as v};
+import{d as M,r as s,j as f,I as ke,y as Oe,e as Be,m as ae,s as C,q as se,b as Pe,f as j,g as Y,l as Ke,o as Ue,h as Me}from"./input.js";import{af as Ge,ag as qe,d as He,B as Le,I as $e,y as ze,j as We,ab as Xe,ac as Ye}from"./App-bXo9NVT7.js";import{I as Je}from"./IconSearch-e7N1azjj.js";function Qe(n){const e=parseFloat(n);return typeof e!="number"||Number.isNaN(e)?0:e}function le(n,e){let r=Qe(n);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(n){if(!Number.isFinite(n))return 0;let e=1,r=0;for(;Math.round(n*e)/e!==n;)e*=10,r+=1;return r}function It(n,e,r){return(n-e)*100/(r-e)}function yt(n,e,r){return(r-e)*n+e}function Ct(n,e,r){const a=Math.round((n-e)/r)*r+e,u=oe(r);return le(a,u)}function Ze(n,e,r){return n==null?n:(r{var p;return a==null?"":(p=ue(a,o,r))!=null?p:""}),S=typeof u<"u",x=S?u:I,O=Fe(A(x),o),F=r??O,y=s.useCallback(p=>{p!==x&&(S||E(p.toString()),h==null||h(p.toString(),A(p)))},[h,S,x]),w=s.useCallback(p=>{let d=p;return b&&(d=Ze(d,i,m)),le(d,F)},[F,b,m,i]),B=s.useCallback((p=o)=>{let d;x===""?d=A(p):d=A(x)+p,d=w(d),y(d)},[w,o,y,x]),K=s.useCallback((p=o)=>{let d;x===""?d=A(-p):d=A(x)-p,d=w(d),y(d)},[w,o,y,x]),U=s.useCallback(()=>{var p;let d;a==null?d="":d=(p=ue(a,o,r))!=null?p:i,y(d)},[a,r,o,y,i]),Q=s.useCallback(p=>{var d;const ee=(d=ue(p,o,F))!=null?d:i;y(ee)},[F,o,y,i]),k=A(x);return{isOutOfRange:k>m||kf.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=n=>f.jsx(ke,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function Ae(n,e,r,a){s.useEffect(()=>{var u;if(!n.current||!a)return;const o=(u=n.current.ownerDocument.defaultView)!=null?u:window,i=Array.isArray(e)?e:[e],m=new o.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return m.observe(n.current,{attributes:!0,attributeFilter:i}),()=>m.disconnect()})}function rt(n,e){const r=M(n);s.useEffect(()=>{let a=null;const u=()=>r();return e!==null&&(a=window.setInterval(u,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,Ee=300;function st(n,e){const[r,a]=s.useState(!1),[u,o]=s.useState(null),[i,m]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);rt(()=>{u==="increment"&&n(),u==="decrement"&&e()},r?at:null);const I=s.useCallback(()=>{i&&n(),b.current=setTimeout(()=>{m(!1),a(!0),o("increment")},Ee)},[n,i]),E=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{m(!1),a(!0),o("decrement")},Ee)},[e,i]),S=s.useCallback(()=>{m(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:I,down:E,stop:S,isSpinning:r}}var ut=/^[Ee0-9+\-.]$/;function ot(n){return ut.test(n)}function lt(n,e){if(n.key==null)return!0;const r=n.ctrlKey||n.altKey||n.metaKey;return!(n.key.length===1)||r?!0:e(n.key)}function it(n={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:u=Number.MIN_SAFE_INTEGER,max:o=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:m,isDisabled:b,isRequired:h,isInvalid:I,pattern:E="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:y,name:w,"aria-describedby":B,"aria-label":K,"aria-labelledby":U,onFocus:Q,onBlur:k,onInvalid:ce,getAriaValueText:de,isValidCharacter:Z,format:p,parse:d,...ee}=n,te=M(Q),pe=M(k),V=M(ce),G=M(Z??ot),ne=M(de),l=et(n),{update:T,increment:me,decrement:fe}=l,[Ve,re]=s.useState(!1),q=!(m||b),_=s.useRef(null),H=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),L=s.useCallback(t=>t.split("").filter(G).join(""),[G]),$=s.useCallback(t=>{var c;return(c=d==null?void 0:d(t))!=null?c:t},[d]),R=s.useCallback(t=>{var c;return((c=p==null?void 0:p(t))!=null?c:t).toString()},[p]);Oe(()=>{(l.valueAsNumber>o||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=$(_.current.value);l.setValue(L(c))}},[$,L]);const z=s.useCallback((t=i)=>{q&&me(t)},[me,q,i]),W=s.useCallback((t=i)=>{q&&fe(t)},[fe,q,i]),g=st(z,W);Ae(be,"disabled",g.stop,g.isSpinning),Ae(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;const v=$(t.currentTarget.value);T(L(v)),H.current={start:t.currentTarget.selectionStart,end:t.currentTarget.selectionEnd}},[T,L,$]),ge=s.useCallback(t=>{var c,v,N;te==null||te(t),H.current&&(t.target.selectionStart=(v=H.current.start)!=null?v:(c=t.currentTarget.value)==null?void 0:c.length,t.currentTarget.selectionEnd=(N=H.current.end)!=null?N:t.currentTarget.selectionStart)},[te]),xe=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;lt(t,G)||t.preventDefault();const c=Ne(t)*i,v=t.key,P={ArrowUp:()=>z(c),ArrowDown:()=>W(c),Home:()=>T(u),End:()=>T(o)}[v];P&&(t.preventDefault(),P(t))},[G,i,z,W,T,u,o]),Ne=t=>{let c=1;return(t.metaKey||t.ctrlKey)&&(c=.1),t.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const t=ne==null?void 0:ne(l.value);if(t!=null)return t;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let t=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumbero&&(t=o),l.cast(t))},[l,o,u]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var t;(t=_.current)==null||t.focus()})},[e]),Se=s.useCallback(t=>{t.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(t=>{t.preventDefault(),g.down(),X()},[X,g]);Ge(()=>_.current,"wheel",t=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;t.preventDefault();const D=Ne(t)*i,_e=Math.sign(t.deltaY);_e===-1?z(D):_e===1&&W(D)},{passive:!1});const Te=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMax;return{...t,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),De=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMin;return{...t,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),je=s.useCallback((t={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:E,"aria-labelledby":U,"aria-label":K,"aria-describedby":B,id:O,disabled:b,...t,readOnly:(v=t.readOnly)!=null?v:m,"aria-readonly":(N=t.readOnly)!=null?N:m,"aria-required":(P=t.required)!=null?P:h,required:(D=t.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":u,"aria-valuemax":o,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(I??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:C(t.onChange,he),onKeyDown:C(t.onKeyDown,xe),onFocus:C(t.onFocus,ge,()=>re(!0)),onBlur:C(t.onBlur,pe,Ce)}},[w,S,E,U,K,R,B,O,b,h,m,I,l.value,l.valueAsNumber,l.isOutOfRange,u,o,Ie,he,xe,ge,pe,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:Ve,isDisabled:b,isReadOnly:m,getIncrementButtonProps:Te,getDecrementButtonProps:De,getInputProps:je,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[dt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),pt=j(function(e,r){const a=Ke("NumberInput",e),u=Ue(e),o=qe(u),{htmlProps:i,...m}=it(o),b=s.useMemo(()=>m,[m]);return f.jsx(dt,{value:b,children:f.jsx(ct,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});pt.displayName="NumberInput";var mt=j(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});mt.displayName="NumberInputStepper";var ft=j(function(e,r){const{getInputProps:a}=ie(),u=a(e,r),o=J();return f.jsx(Y.input,{...u,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...o.field}})});ft.displayName="NumberInputField";var Re=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=j(function(e,r){var a;const u=J(),{getDecrementButtonProps:o}=ie(),i=o(e,r);return f.jsx(Re,{...i,__css:u.stepper,children:(a=e.children)!=null?a:f.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var vt=j(function(e,r){var a;const{getIncrementButtonProps:u}=ie(),o=u(e,r),i=J();return f.jsx(Re,{...o,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(nt,{})})});vt.displayName="NumberIncrementStepper";var St=He("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const wt=(n,e)=>{const[r,a]=s.useState(n);return s.useEffect(()=>{const u=setTimeout(()=>{a(n)},e);return()=>{clearTimeout(u)}},[n,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function _t(n){const{searchValue:e,onUpdateSearchValue:r,style:a}=n,u=e!=="";return f.jsxs(Le,{style:{position:"relative",...a},mb:2,children:[f.jsx(Je,{style:ht}),u&&f.jsx($e,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(ze,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(We,{placeholder:n.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function At({mediaLocalPath:n,size:e,isPreview:r,autoPlay:a,hideBrokenImage:u,objectFit:o,onBrokenLink:i}){const[m,b]=s.useState(!0);return s.useEffect(()=>{u&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${n}`:`/workspace/view_media?filename=${n}`)).status==404){b(!1),i==null||i();return}}catch(I){console.error("Error checking media exists",I)}})()},[]),m?Xe(n)?f.jsx(Ye,{borderRadius:3,boxSize:`${e}px`,objectFit:o??"cover",src:`/workspace/view_media?filename=${n}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${n}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{St as I,At as M,pt as N,_t as S,ft as a,mt as b,Ze as c,vt as d,bt as e,yt as p,Ct as r,wt as u,It as v};
diff --git a/dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js b/dist/workspace_web/ModelManagerTopbar-wj7k34WI.js
similarity index 98%
rename from dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js
rename to dist/workspace_web/ModelManagerTopbar-wj7k34WI.js
index df2fbab..b125529 100644
--- a/dist/workspace_web/ModelManagerTopbar-jwv1A1hH.js
+++ b/dist/workspace_web/ModelManagerTopbar-wj7k34WI.js
@@ -1,7 +1,7 @@
-import{f as q,r as m,j as n,g as $,h as Se,a0 as X,b as $e,o as Ue,l as He,i as T,U as re,P as Ve,a1 as qe,N as be,a2 as Ye,Q as Ce,S as ke,T as Qe,$ as Je,M as Xe,O as Ze,R as et,_ as tt}from"./input.js";import{al as st,m as nt,am as G,an as ae,B as oe,F as R,ac as Le,h as N,i as ie,Z as Ie,ao as ot,k as H,a4 as Ee,a5 as it,ae as Te,j as Z,H as W,ap as Ae,aq as pe,g as Y,w as rt,ar as Ne,f as De,as as at,at as Fe,au as lt,av as ct,aw as dt,ax as ht,ay as ut,az as ft,aA as mt,aB as te,aC as pt,aD as gt,aE as xt}from"./App-YT7a4Gj6.js";import{G as yt,C as vt}from"./chunk-JARCRF6W-66xSMED8.js";import{app as z}from"/scripts/app.js";import{api as V}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-xkXXv8lg.js";var Pe=q(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:l,direction:c,align:h,className:d,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(le,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",d),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:h,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Pe.displayName="Wrap";var le=q(function(e,s){const{className:o,...i}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...i})});le.displayName="WrapItem";function ge(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Oe=q(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:l,rowSpan:c,rowStart:h,...d}=e,f=st({gridArea:o,gridColumn:ge(i),gridRow:ge(c),gridColumnStart:r,gridColumnEnd:a,gridRowStart:h,gridRowEnd:l});return n.jsx($.div,{ref:s,__css:f,...d})});Oe.displayName="GridItem";function Mt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var jt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),wt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function _t(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:l="progressbar"}=t,c=Mt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof r=="function"?r(e,c):i})(),role:l},percent:c,value:e}}var[St,bt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ct=q((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...l}=t,c=_t({value:i,min:s,max:o,isIndeterminate:r,role:a}),d={height:"100%",...bt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:d})}),ze=q((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:l,children:c,borderRadius:h,isIndeterminate:d,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ue(t),w=He("Progress",t),C=h??((s=w.track)==null?void 0:s.borderRadius),k={animation:`${wt} 1s linear infinite`},D={...!d&&a&&l&&k,...d&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${jt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...w.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(St,{value:w,children:[n.jsx(Ct,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:d,css:D,borderRadius:C,title:p,role:x}),c]})})});ze.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const kt=1/0;function Lt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-kt?"-0":s}(t)}function F(t){return typeof t=="string"}function Be(t){return typeof t=="number"}function It(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function A(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Et=t=>`Missing ${t} property in key`,Tt=t=>`Property 'weight' in key '${t}' must be a positive integer`,xe=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=We(o);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function We(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=ye(t),s=ve(t);else{if(!xe.call(t,"name"))throw new Error(Et("name"));const a=t.name;if(o=a,xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Tt(a));e=ye(a),s=ve(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function ye(t){return K(t)?t:t.split(".")}function ve(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(A(r))if(a[l]){const c=r[a[l]];if(!A(c))return;if(l===a.length-1&&(F(c)||Be(c)||It(c)))s.push(Lt(c));else if(K(c)){o=!0;for(let h=0,d=c.length;h{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=i.getFn?i.getFn(e):this.getFn(e,i.path);if(A(a)){if(K(a)){let l=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:h,value:d}=c.pop();if(A(d))if(F(d)&&!se(d)){let f={v:d,i:h,n:this.norm.get(d)};l.push(f)}else K(d)&&d.forEach((f,u)=>{c.push({nestedArrIndex:u,value:f})})}o.$[r]=l}else if(F(a)&&!se(a)){let l={v:a,n:this.norm.get(a)};o.$[r]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ge(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const i=new ce({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(We)),i.setSources(e),i.create(),i}function J(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const a=e/t.length;if(r)return a;const l=Math.abs(o-s);return i?a+l/i:l?1:a}const B=32;function Dt(t,e,s,{location:o=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:l=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:h=M.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const d=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=l>1||c,j=x?Array(f):[];let w;for(;(w=t.indexOf(e,p))>-1;){let b=J(e,{currentLocation:w,expectedLocation:u,distance:i,ignoreLocation:h});if(g=Math.min(b,g),p=w+d,x){let L=0;for(;L=O;v-=1){let _=v-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[v]=(y[v+1]<<1|1)&S,b&&(y[v]|=(C[v+1]|C[v])<<1|1|C[v+1]),y[v]&Q&&(k=J(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:h}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(J(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:h})>g)break;C=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const b=function(L=[],I=M.minMatchCharLength){let O=[],E=-1,y=-1,v=0;for(let _=L.length;v<_;v+=1){let S=L[v];S&&E===-1?E=v:S||E===-1||(y=v-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[v-1]&&v-E>=I&&O.push([E,v-1]),O}(j,l);b.length?c&&(D.indices=b):D.isMatch=!1}return D}function Ft(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Ft(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:w,score:C,indices:k}=Dt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:l,minMatchCharLength:c,includeMatches:o,ignoreLocation:h});w&&(u=!0),f+=C,w&&k&&(d=[...d,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=d),g}}const Me=[];function je(t,e){for(let s=0,o=Me.length;s{if(!A(o.indices)||!o.indices.length)return;const{indices:i,value:r}=o;let a={indices:i,value:r};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function zt(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new At(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof ce))throw new Error("Incorrect 'index' type");this._myIndex=s||Ge(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){A(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,i=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(d?1:p))}),f.score=u})}(c,{ignoreFieldNorm:l}),r&&c.sort(a),Be(s)&&s>-1&&(c=c.slice(0,s)),function(h,d,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Ot),u&&g.push(zt),h.map(p=>{const{idx:x}=p,j={item:d[x],refIndex:x};return g.length&&g.forEach(w=>{w(p,j)}),j})}(c,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=je(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=s.searchIn(r);c&&i.push({item:r,idx:a,matches:[{score:h,value:r,norm:l,indices:d}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=je(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:l})=>{if(!A(a))return;let c=[];o.forEach((h,d)=>{c.push(...this._findMatches({key:h,value:a[d],searcher:s}))}),c.length&&r.push({idx:l,item:a,matches:c})}),r}_findMatches({key:e,value:s,searcher:o}){if(!A(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=o.searchIn(r);c&&i.push({score:h,key:e,value:r,idx:a,norm:l,indices:d})});else{const{v:r,n:a}=s,{isMatch:l,score:c,indices:h}=o.searchIn(r);l&&i.push({score:c,key:e,value:r,norm:a,indices:h})}return i}}U.version="7.0.0",U.createIndex=Ge,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new ce({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=M;function Bt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Pe,{children:s.map(i=>n.jsx(le,{children:n.jsx(T,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Rt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Wt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=m.useState(!t.file_hash),[r,a]=m.useState();m.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var d;const h=await G.models.get(t.model_name+"@"+t.model_type);if(h!=null&&(a(h),(d=h.imageUrl)!=null&&d.length&&s(h.imageUrl)),!(h!=null&&h.imageUrl)&&t.file_hash!=null)try{const f=await ae(t.file_hash),u=f.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:f.modelName??null,civitModelID:f.civitModelID,civitModelVersionID:f.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},c=h=>{const d=Rt[t.model_type];d&&(h.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),h.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),h.dataTransfer.setData("nodeType",d))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(Le,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(r==null?void 0:r.civitModelID)!=null?"pointer":"auto",onClick:()=>{(r==null?void 0:r.civitModelID)==null||(r==null?void 0:r.civitModelVersionID)==null||window.open(`https://civitai.com/models/${r==null?void 0:r.civitModelID}?modelVersionId=${r==null?void 0:r.civitModelVersionID}`)}}),n.jsx(N,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(N,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Gt({list:t}){return n.jsx(yt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Oe,{children:n.jsx(Wt,{data:e})},e.model_name+e.date.getTime()))})}function Kt(){const{setRoute:t}=m.useContext(Ie);return n.jsx(n.Fragment,{children:n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const $t=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),V.addEventListener("model_list",async c=>{l(c.detail)})},[]);const a=async()=>{const c=await ot();l(c)},l=async c=>{if(!c)return;r(!1);const h=Array.from(new Set(c.map(f=>f.model_type))),d=h.indexOf("checkpoints");d>=0&&h.splice(d,1),h.unshift("checkpoints"),e(h),o(c.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Ut(){const[t,e]=m.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var c;const l=a.target.checked;(c=H)==null||c.upsert({showNsfwModelThumbnail:l}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await G.models.toArray();for(let l=0;l{try{if(a.fileHash==null)return;const c=(await ae(a.fileHash)).imageUrl;G.models.update(a.id,{imageUrl:c??null})}catch{}};return n.jsx(vt,{isChecked:t,onChange:o,children:"Show NSFW"})}function Ht(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),i=e.dataTransfer.getData("nodeType"),r=LiteGraph.createNode(i);r.pos=[e.canvasX,e.canvasY],r.configure({widgets_values:[o]}),z.graph.add(r)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function Vt({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:l,modelTypeList:c,modelsList:h}=$t(),[d,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await G.models.toArray();f(h.map(w=>({...w,db:j.find(C=>C.id===w.model_name+"@"+w.model_type)})))}},[h]),m.useEffect(()=>{let x=[];o.length?x=new U(d,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=h.filter(j=>j.model_type===e).sort((j,w)=>r==="name"?j.model_name.localeCompare(w.model_name):w.date.getTime()-j.date.getTime()),g(x)},[e,h,o,r,d]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Ve,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ee,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:it,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Kt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>i(x.target.value)})}),n.jsxs(R,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:r,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Ut,{})]}),!o.length&&n.jsx(Bt,{modelTypeList:c,setSelectedModel:s,selectedModel:e}),n.jsx(Gt,{list:u}),l&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(Ht,{})]})})}const qt=async t=>{try{const s=await(await V.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function we(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function _e(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Yt(t,e=280,s){var o,i,r,a;if(t)return Ae(t)?(r=_e((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,s))==null?void 0:r.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=_e(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Qt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=m.useState();m.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Yt(t,ne,x))}},[t]);const r=Ae(t)?t.modelVersions:t.versions,[a,l]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),c=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),h=()=>{window.open(`https://civitai.com/models/${t.id}`)},d=m.useCallback(()=>{if(c==null){console.error("no file is find by name",a);return}e(pe(c,t.name),t)},[a]),f=(g=pe(c))==null?void 0:g.sizeKB;return n.jsxs(Ee,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Le,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>h()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(N,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(R,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(N,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(rt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>d(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{l(p.target.value)},children:r==null?void 0:r.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:we(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:we(f)})})]})]})]})}function Jt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function Xt({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,l]=m.useState([]),[c,h]=m.useState(""),d=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Ne();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),l(Object.values(u).flatMap(g=>g)))};return n.jsx(qe,{isOpen:t,leastDestructiveRef:d,onClose:s,children:n.jsx(be,{children:n.jsxs(Ye,{children:[n.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(ke,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>h(u.target.value),value:c})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:i,onChange:u=>r(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Qe,{children:[n.jsx(T,{ref:d,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function Zt(){const{colorMode:t}=Je(),e=De(),[s,o]=m.useState([]);return m.useEffect(()=>{V.addEventListener("download_progress",i=>{o(i.detail)}),V.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:i,progress:r})=>n.jsxs(W,{children:[n.jsx(N,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),n.jsx(ze,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>at(i),children:"Cancel"})]},i))})}function es(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Fe(),r=()=>{ft(t),o()};return n.jsxs(lt,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(ct,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(dt,{p:5,children:[n.jsx(ht,{}),n.jsx(ut,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(N,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function ts(t,e){var a,l;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((l=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:l.at(0)).hits??[]}function ss({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[l,c]=m.useState(s),h=De(),[d,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Fe(),[w,C,k]=mt(),[P,Q]=m.useState({}),[D,b]=m.useState(te),L=m.useCallback(async()=>{var S;a(!0);const y=await ts(u,l);i(y);const v=await Ne();v&&Q(v);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,l]),I=(y,v)=>{var he,ue,fe,me;if(!((he=k.current)!=null&&he.id)&&!v){console.error("no url to download");return}let _=v??`https://civitai.com/api/download/models/${(ue=k.current)==null?void 0:ue.id}`,S=(fe=k.current)==null?void 0:fe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}h({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(Ke=>[...Ke,S??""]);const de=gt();de&&(_+=`?token=${de}`),qt({file_hash:(me=k.current)==null?void 0:me.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,v)=>{const _=D[v.type];C(y),_==null?x():I(_)},E=async(y,v)=>{var S;const _={...D,[y]:v};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return m.useEffect(()=>{L()},[l]),n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(Ze,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ce,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(es,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),pt.map(y=>n.jsx(T,{size:"sm",py:1,isActive:l===y,onClick:()=>{c(y)},children:y},y)),l&&P[te[l]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:D[l],onChange:y=>E(l,y.target.value),children:P[te[l]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(et,{}),n.jsxs(ke,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(Qt,{model:y,onClickInstallModel:O,installing:d},y.id))}),n.jsx(Zt,{})]})]})]}),n.jsx(Xt,{fileSelected:!!w,isOpen:p,onClose:j,selectFolder:(y,v)=>{I(y,k.current?void 0:v)}})]})}const ns=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-at3wACEK.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function os(){const{setRoute:t,route:e}=m.useContext(Ie),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const r=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),l=LiteGraph.createNode(a);l.pos=[o.canvasX,o.canvasY],l.configure({widgets_values:[r]}),z.graph.add(l)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),V.addEventListener("model_list",async o=>{var a;const i=(a=o.detail)==null?void 0:a.map(async l=>{const c=await G.models.get(l.model_name+"@"+l.model_type);if(c!=null&&c.fileHash)return c;let h={id:l.model_name+"@"+l.model_type,modelName:null,fileHash:l.file_hash??null,fileFolder:l.model_type,fileName:l.model_name+l.model_extension};if(!l.file_hash)return h;const d=await ae(l.file_hash);return h={...h,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},h}),r=(await Promise.all(i)).filter(l=>l!=null);await G.models.clear(),await G.models.bulkPut(r.filter(l=>l!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))}),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:xt+"px",children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(m.Suspense,{children:n.jsx(ns,{})})}),e==="modelList"&&n.jsx(Vt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(ss,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const hs=Object.freeze(Object.defineProperty({__proto__:null,default:os},Symbol.toStringTag,{value:"Module"}));export{Oe as G,hs as M,qt as i};
+import{f as q,r as m,j as n,g as $,h as Se,a0 as X,b as $e,o as Ue,l as He,i as T,U as re,P as Ve,a1 as qe,N as be,a2 as Ye,Q as Ce,S as ke,T as Qe,$ as Je,M as Xe,O as Ze,R as et,_ as tt}from"./input.js";import{al as st,m as nt,am as G,an as ae,B as oe,F as R,ac as Le,h as N,i as ie,Z as Ie,ao as ot,k as H,a4 as Ee,a5 as it,ae as Te,j as Z,H as W,ap as Ae,aq as pe,g as Y,w as rt,ar as Ne,f as De,as as at,at as Fe,au as lt,av as ct,aw as dt,ax as ht,ay as ut,az as ft,aA as mt,aB as te,aC as pt,aD as gt,aE as xt}from"./App-bXo9NVT7.js";import{G as yt,C as vt}from"./chunk-JARCRF6W-xouhmv4h.js";import{app as z}from"/scripts/app.js";import{api as V}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-8cE0TZNF.js";var Pe=q(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:l,direction:c,align:h,className:d,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(le,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",d),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:h,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Pe.displayName="Wrap";var le=q(function(e,s){const{className:o,...i}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...i})});le.displayName="WrapItem";function ge(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Oe=q(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:l,rowSpan:c,rowStart:h,...d}=e,f=st({gridArea:o,gridColumn:ge(i),gridRow:ge(c),gridColumnStart:r,gridColumnEnd:a,gridRowStart:h,gridRowEnd:l});return n.jsx($.div,{ref:s,__css:f,...d})});Oe.displayName="GridItem";function Mt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var jt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),wt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function _t(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:l="progressbar"}=t,c=Mt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof r=="function"?r(e,c):i})(),role:l},percent:c,value:e}}var[St,bt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ct=q((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...l}=t,c=_t({value:i,min:s,max:o,isIndeterminate:r,role:a}),d={height:"100%",...bt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:d})}),ze=q((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:l,children:c,borderRadius:h,isIndeterminate:d,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ue(t),w=He("Progress",t),C=h??((s=w.track)==null?void 0:s.borderRadius),k={animation:`${wt} 1s linear infinite`},D={...!d&&a&&l&&k,...d&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${jt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...w.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(St,{value:w,children:[n.jsx(Ct,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:d,css:D,borderRadius:C,title:p,role:x}),c]})})});ze.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const kt=1/0;function Lt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-kt?"-0":s}(t)}function F(t){return typeof t=="string"}function Be(t){return typeof t=="number"}function It(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function A(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Et=t=>`Missing ${t} property in key`,Tt=t=>`Property 'weight' in key '${t}' must be a positive integer`,xe=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=We(o);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function We(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=ye(t),s=ve(t);else{if(!xe.call(t,"name"))throw new Error(Et("name"));const a=t.name;if(o=a,xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Tt(a));e=ye(a),s=ve(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function ye(t){return K(t)?t:t.split(".")}function ve(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(A(r))if(a[l]){const c=r[a[l]];if(!A(c))return;if(l===a.length-1&&(F(c)||Be(c)||It(c)))s.push(Lt(c));else if(K(c)){o=!0;for(let h=0,d=c.length;h{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=i.getFn?i.getFn(e):this.getFn(e,i.path);if(A(a)){if(K(a)){let l=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:h,value:d}=c.pop();if(A(d))if(F(d)&&!se(d)){let f={v:d,i:h,n:this.norm.get(d)};l.push(f)}else K(d)&&d.forEach((f,u)=>{c.push({nestedArrIndex:u,value:f})})}o.$[r]=l}else if(F(a)&&!se(a)){let l={v:a,n:this.norm.get(a)};o.$[r]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ge(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const i=new ce({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(We)),i.setSources(e),i.create(),i}function J(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const a=e/t.length;if(r)return a;const l=Math.abs(o-s);return i?a+l/i:l?1:a}const B=32;function Dt(t,e,s,{location:o=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:l=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:h=M.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const d=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=l>1||c,j=x?Array(f):[];let w;for(;(w=t.indexOf(e,p))>-1;){let b=J(e,{currentLocation:w,expectedLocation:u,distance:i,ignoreLocation:h});if(g=Math.min(b,g),p=w+d,x){let L=0;for(;L=O;v-=1){let _=v-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[v]=(y[v+1]<<1|1)&S,b&&(y[v]|=(C[v+1]|C[v])<<1|1|C[v+1]),y[v]&Q&&(k=J(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:h}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(J(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:h})>g)break;C=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const b=function(L=[],I=M.minMatchCharLength){let O=[],E=-1,y=-1,v=0;for(let _=L.length;v<_;v+=1){let S=L[v];S&&E===-1?E=v:S||E===-1||(y=v-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[v-1]&&v-E>=I&&O.push([E,v-1]),O}(j,l);b.length?c&&(D.indices=b):D.isMatch=!1}return D}function Ft(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Ft(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:w,score:C,indices:k}=Dt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:l,minMatchCharLength:c,includeMatches:o,ignoreLocation:h});w&&(u=!0),f+=C,w&&k&&(d=[...d,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=d),g}}const Me=[];function je(t,e){for(let s=0,o=Me.length;s{if(!A(o.indices)||!o.indices.length)return;const{indices:i,value:r}=o;let a={indices:i,value:r};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function zt(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new At(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof ce))throw new Error("Incorrect 'index' type");this._myIndex=s||Ge(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){A(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,i=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(d?1:p))}),f.score=u})}(c,{ignoreFieldNorm:l}),r&&c.sort(a),Be(s)&&s>-1&&(c=c.slice(0,s)),function(h,d,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Ot),u&&g.push(zt),h.map(p=>{const{idx:x}=p,j={item:d[x],refIndex:x};return g.length&&g.forEach(w=>{w(p,j)}),j})}(c,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=je(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=s.searchIn(r);c&&i.push({item:r,idx:a,matches:[{score:h,value:r,norm:l,indices:d}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=je(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:l})=>{if(!A(a))return;let c=[];o.forEach((h,d)=>{c.push(...this._findMatches({key:h,value:a[d],searcher:s}))}),c.length&&r.push({idx:l,item:a,matches:c})}),r}_findMatches({key:e,value:s,searcher:o}){if(!A(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:l})=>{if(!A(r))return;const{isMatch:c,score:h,indices:d}=o.searchIn(r);c&&i.push({score:h,key:e,value:r,idx:a,norm:l,indices:d})});else{const{v:r,n:a}=s,{isMatch:l,score:c,indices:h}=o.searchIn(r);l&&i.push({score:c,key:e,value:r,norm:a,indices:h})}return i}}U.version="7.0.0",U.createIndex=Ge,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new ce({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=M;function Bt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Pe,{children:s.map(i=>n.jsx(le,{children:n.jsx(T,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Rt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Wt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=m.useState(!t.file_hash),[r,a]=m.useState();m.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var d;const h=await G.models.get(t.model_name+"@"+t.model_type);if(h!=null&&(a(h),(d=h.imageUrl)!=null&&d.length&&s(h.imageUrl)),!(h!=null&&h.imageUrl)&&t.file_hash!=null)try{const f=await ae(t.file_hash),u=f.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:f.modelName??null,civitModelID:f.civitModelID,civitModelVersionID:f.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},c=h=>{const d=Rt[t.model_type];d&&(h.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),h.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),h.dataTransfer.setData("nodeType",d))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(Le,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(r==null?void 0:r.civitModelID)!=null?"pointer":"auto",onClick:()=>{(r==null?void 0:r.civitModelID)==null||(r==null?void 0:r.civitModelVersionID)==null||window.open(`https://civitai.com/models/${r==null?void 0:r.civitModelID}?modelVersionId=${r==null?void 0:r.civitModelVersionID}`)}}),n.jsx(N,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(N,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Gt({list:t}){return n.jsx(yt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Oe,{children:n.jsx(Wt,{data:e})},e.model_name+e.date.getTime()))})}function Kt(){const{setRoute:t}=m.useContext(Ie);return n.jsx(n.Fragment,{children:n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const $t=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),V.addEventListener("model_list",async c=>{l(c.detail)})},[]);const a=async()=>{const c=await ot();l(c)},l=async c=>{if(!c)return;r(!1);const h=Array.from(new Set(c.map(f=>f.model_type))),d=h.indexOf("checkpoints");d>=0&&h.splice(d,1),h.unshift("checkpoints"),e(h),o(c.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Ut(){const[t,e]=m.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var c;const l=a.target.checked;(c=H)==null||c.upsert({showNsfwModelThumbnail:l}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await G.models.toArray();for(let l=0;l{try{if(a.fileHash==null)return;const c=(await ae(a.fileHash)).imageUrl;G.models.update(a.id,{imageUrl:c??null})}catch{}};return n.jsx(vt,{isChecked:t,onChange:o,children:"Show NSFW"})}function Ht(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),i=e.dataTransfer.getData("nodeType"),r=LiteGraph.createNode(i);r.pos=[e.canvasX,e.canvasY],r.configure({widgets_values:[o]}),z.graph.add(r)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function Vt({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:l,modelTypeList:c,modelsList:h}=$t(),[d,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await G.models.toArray();f(h.map(w=>({...w,db:j.find(C=>C.id===w.model_name+"@"+w.model_type)})))}},[h]),m.useEffect(()=>{let x=[];o.length?x=new U(d,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=h.filter(j=>j.model_type===e).sort((j,w)=>r==="name"?j.model_name.localeCompare(w.model_name):w.date.getTime()-j.date.getTime()),g(x)},[e,h,o,r,d]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Ve,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ee,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:it,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Kt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>i(x.target.value)})}),n.jsxs(R,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:r,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Ut,{})]}),!o.length&&n.jsx(Bt,{modelTypeList:c,setSelectedModel:s,selectedModel:e}),n.jsx(Gt,{list:u}),l&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(Ht,{})]})})}const qt=async t=>{try{const s=await(await V.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function we(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function _e(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Yt(t,e=280,s){var o,i,r,a;if(t)return Ae(t)?(r=_e((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,s))==null?void 0:r.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=_e(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Qt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=m.useState();m.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Yt(t,ne,x))}},[t]);const r=Ae(t)?t.modelVersions:t.versions,[a,l]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),c=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),h=()=>{window.open(`https://civitai.com/models/${t.id}`)},d=m.useCallback(()=>{if(c==null){console.error("no file is find by name",a);return}e(pe(c,t.name),t)},[a]),f=(g=pe(c))==null?void 0:g.sizeKB;return n.jsxs(Ee,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Le,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>h()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(N,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(R,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(N,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(rt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>d(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{l(p.target.value)},children:r==null?void 0:r.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:we(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:we(f)})})]})]})]})}function Jt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function Xt({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,l]=m.useState([]),[c,h]=m.useState(""),d=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Ne();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),l(Object.values(u).flatMap(g=>g)))};return n.jsx(qe,{isOpen:t,leastDestructiveRef:d,onClose:s,children:n.jsx(be,{children:n.jsxs(Ye,{children:[n.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(ke,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>h(u.target.value),value:c})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:i,onChange:u=>r(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Qe,{children:[n.jsx(T,{ref:d,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function Zt(){const{colorMode:t}=Je(),e=De(),[s,o]=m.useState([]);return m.useEffect(()=>{V.addEventListener("download_progress",i=>{o(i.detail)}),V.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:i,progress:r})=>n.jsxs(W,{children:[n.jsx(N,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),n.jsx(ze,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>at(i),children:"Cancel"})]},i))})}function es(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Fe(),r=()=>{ft(t),o()};return n.jsxs(lt,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(ct,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(dt,{p:5,children:[n.jsx(ht,{}),n.jsx(ut,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(N,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function ts(t,e){var a,l;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((l=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:l.at(0)).hits??[]}function ss({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[l,c]=m.useState(s),h=De(),[d,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Fe(),[w,C,k]=mt(),[P,Q]=m.useState({}),[D,b]=m.useState(te),L=m.useCallback(async()=>{var S;a(!0);const y=await ts(u,l);i(y);const v=await Ne();v&&Q(v);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,l]),I=(y,v)=>{var he,ue,fe,me;if(!((he=k.current)!=null&&he.id)&&!v){console.error("no url to download");return}let _=v??`https://civitai.com/api/download/models/${(ue=k.current)==null?void 0:ue.id}`,S=(fe=k.current)==null?void 0:fe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}h({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(Ke=>[...Ke,S??""]);const de=gt();de&&(_+=`?token=${de}`),qt({file_hash:(me=k.current)==null?void 0:me.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,v)=>{const _=D[v.type];C(y),_==null?x():I(_)},E=async(y,v)=>{var S;const _={...D,[y]:v};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return m.useEffect(()=>{L()},[l]),n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(Ze,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ce,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Te,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(es,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),pt.map(y=>n.jsx(T,{size:"sm",py:1,isActive:l===y,onClick:()=>{c(y)},children:y},y)),l&&P[te[l]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:D[l],onChange:y=>E(l,y.target.value),children:P[te[l]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(et,{}),n.jsxs(ke,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(Qt,{model:y,onClickInstallModel:O,installing:d},y.id))}),n.jsx(Zt,{})]})]})]}),n.jsx(Xt,{fileSelected:!!w,isOpen:p,onClose:j,selectFolder:(y,v)=>{I(y,k.current?void 0:v)}})]})}const ns=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-OE80g4ub.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function os(){const{setRoute:t,route:e}=m.useContext(Ie),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const r=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),l=LiteGraph.createNode(a);l.pos=[o.canvasX,o.canvasY],l.configure({widgets_values:[r]}),z.graph.add(l)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),V.addEventListener("model_list",async o=>{var a;const i=(a=o.detail)==null?void 0:a.map(async l=>{const c=await G.models.get(l.model_name+"@"+l.model_type);if(c!=null&&c.fileHash)return c;let h={id:l.model_name+"@"+l.model_type,modelName:null,fileHash:l.file_hash??null,fileFolder:l.model_type,fileName:l.model_name+l.model_extension};if(!l.file_hash)return h;const d=await ae(l.file_hash);return h={...h,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},h}),r=(await Promise.all(i)).filter(l=>l!=null);await G.models.clear(),await G.models.bulkPut(r.filter(l=>l!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))}),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:xt+"px",children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(m.Suspense,{children:n.jsx(ns,{})})}),e==="modelList"&&n.jsx(Vt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(ss,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const hs=Object.freeze(Object.defineProperty({__proto__:null,default:os},Symbol.toStringTag,{value:"Module"}));export{Oe as G,hs as M,qt as i};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-at3wACEK.js","workspace_web/input.js","workspace_web/App-YT7a4Gj6.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-66xSMED8.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-xkXXv8lg.js"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-OE80g4ub.js","workspace_web/input.js","workspace_web/App-bXo9NVT7.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-xouhmv4h.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-8cE0TZNF.js"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file
diff --git a/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js b/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js
new file mode 100644
index 0000000..a207fdd
--- /dev/null
+++ b/dist/workspace_web/RecentFilesDrawer-ouPPEt3o.js
@@ -0,0 +1,5 @@
+import{f as J,E as qe,j as e,Z as Je,h as oe,g as ye,r as o,M as ie,N as re,O as le,Q as ce,R as de,S as ue,W as we,i as P,$ as ve,T as Qe}from"./input.js";import{m as Le,u as Ne,a as et,b as tt,c as st,S as nt,M as at,d as L,H as T,T as We,I as A,t as xe,e as Ae,f as Y,E as ge,g as K,h as z,i as _,j as ke,k as F,R as V,l as ot,n as Me,B as $,F as Z,o as Fe,p as it,q as rt,r as Q,s as ee,v as W,w as lt,D as Pe,x as E,y as Re,z as ct,A as Se,C as dt,G as _e,J as ut,K as G,L as ht,N as pt,O as gt,P as mt,Q as Be,U as ft,V as xt,W as jt,X as H,Y as je,Z as Ce,_ as yt,$ as wt,a0 as $e,a1 as vt,a2 as kt,a3 as q,a4 as St,a5 as Ct,a6 as bt,a7 as me,a8 as It}from"./App-bXo9NVT7.js";import{G as Mt,C as X}from"./chunk-JARCRF6W-xouhmv4h.js";import{V as Ke}from"./chunk-NTCQBYKE-nDCdQPx1.js";import{N as Ft,a as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-KLEWGSXc.js";import{app as ae}from"/scripts/app.js";import{I as Lt}from"./IconCopy-wyTg5wiq.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";import"./IconSearch-e7N1azjj.js";var Ge=J(function(t,r){const{columns:l,spacingX:a,spacingY:i,spacing:u,minChildWidth:p,...s}=t,h=qe(),d=p?Wt(p,h):At(l);return e.jsx(Mt,{ref:r,gap:u,columnGap:a,rowGap:i,templateColumns:d,...s})});Ge.displayName="SimpleGrid";function Nt(n){return typeof n=="number"?`${n}px`:n}function Wt(n,t){return Le(n,r=>{const l=Je("sizes",r,Nt(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(n){return Le(n,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ve=J((n,t)=>{const{title:r,children:l,className:a,...i}=n,u=oe("chakra-menu__group__title",a),p=Ne();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(ye.p,{className:u,...i,__css:p.groupTitle,children:r}),l]})});Ve.displayName="MenuGroup";var Ue=n=>{const{className:t,title:r,...l}=n,a=et(l);return e.jsx(Ve,{title:r,className:oe("chakra-menu__option-group",t),...a})};Ue.displayName="MenuOptionGroup";var Pt=J((n,t)=>{const r=Ne();return e.jsx(ye.button,{ref:t,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),te=J((n,t)=>{const{children:r,as:l,...a}=n,i=tt(a,t),u=l||Pt;return e.jsx(u,{...i,className:oe("chakra-menu__menu-button",n.className),children:e.jsx(ye.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});te.displayName="MenuButton";var Rt=n=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=J((n,t)=>{const{icon:r,iconSpacing:l="0.75rem",...a}=n,i=st(a,t);return e.jsxs(nt,{...i,className:oe("chakra-menu__menuitem-option",a.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:n.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:i.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=L("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=L("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),$t=L("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),De=L("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Kt=L("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),He=L("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Gt=L("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Vt=L("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Ut=L("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Ht=L("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Zt=L("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),Yt=L("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Xt=L("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),qt=L("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function Jt({onclose:n}){const[t,r]=o.useState([]),l=async()=>{var i;const a=await((i=xe)==null?void 0:i.listAll());r(a??[])};return o.useEffect(()=>{l()},[]),e.jsxs(ie,{isOpen:!0,onClose:n,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"My Tags"}),e.jsx(de,{}),e.jsx(ue,{children:t.map(a=>e.jsxs(T,{children:[e.jsx(We,{children:a.name}),e.jsx(A,{onClick:async()=>{var i;await((i=xe)==null?void 0:i.delete(a.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ae,{})})]}))})]})]})}function Qt(){const n=Y(),t=o.useRef([{title:"Save current workflow",key:ge.SAVE},{title:"Save as current workflow",key:ge.SAVE_AS},{title:"Open spotlight search",key:ge.openSpotlightSearch}]),[r,l]=o.useState({save:"",saveAs:"",openSpotlightSearch:""}),[a,i]=o.useState(),u=async(s,h)=>{var g;s.preventDefault();let d="";if(s.ctrlKey&&(d+="Control+"),s.metaKey&&(d+="Command+"),s.shiftKey&&(d+="Shift+"),s.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){d+=s.key.toUpperCase();const m={...r};delete m[h],Object.values(m).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please
+ modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=F)==null?void 0:g.upsert({shortcuts:{...r,[h]:d}})),p())}},p=()=>{var s;(s=F)==null||s.getSetting("shortcuts").then(h=>{var g;const d=h??((g=F)==null?void 0:g.defaultSettings.shortcuts);l({...r,...d})})};return o.useEffect(()=>{p()},[]),e.jsxs(K,{children:[e.jsx(z,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(T,{children:[e.jsx(z,{fontSize:"sm",w:170,children:s.title}),e.jsx(_,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:a===s.key,children:e.jsx(ke,{value:r[s.key],onKeyDown:h=>{u(h,s.key)},onFocus:()=>{i(s.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:n}=o.useContext(V),[t,r]=o.useState(!1),l=()=>{var i;(i=F)==null||i.getSetting("foldersOnTop").then(u=>{r(!!u)})},a=i=>{var p;const u=i.target.checked;(p=F)==null||p.upsert({foldersOnTop:u}).then(()=>{l(),n(Date.now())})};return o.useEffect(()=>{l()},[]),e.jsx(K,{children:e.jsx(X,{isChecked:t,onChange:a,children:"Folders always on top"})})}function ts(){const[n,t]=o.useState(!1),[r,l]=o.useState(""),{showDialog:a}=we(),i=()=>{var p,s;(p=F)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=F)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};o.useEffect(()=>{i()},[]);const u=async p=>{var h,d;if(!p.target.checked){await((h=F)==null?void 0:h.upsert({twoWaySync:p.target.checked})),i();return}const s=await((d=F)==null?void 0:d.getSetting("myWorkflowsDir"));a(e.jsx(ot,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=F)==null?void 0:g.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return e.jsxs(K,{children:[e.jsx(z,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(X,{isChecked:n,onChange:u,children:"Enable two way sync"})]})}function Ee({settingKey:n,text:t,defaultChecked:r=!1}){const[l,a]=o.useState(r),i=Y(),u=()=>{var p;(p=F)==null||p.getSetting(n).then(s=>{a(!!s)})};return o.useEffect(()=>{u()},[]),e.jsx(K,{children:e.jsx(X,{isChecked:l,onChange:async p=>{var s;await((s=F)==null?void 0:s.upsert({[n]:p.target.checked})),u(),i({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),[a,i]=o.useState([]),[u,p]=o.useState(""),[s,h]=o.useState([]),[d,g]=o.useState(!1),[m,c]=o.useState(!1),[f,v]=o.useState(!1),S=o.useRef(null),w=Y(),{showDialog:N}=we(),C=f?"\\":"/";o.useEffect(()=>{var y;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=F)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const j=async y=>{const{dir_path:k="",dir_contents:D=[],error:x=""}=await Fe(y??"");return x.includes("Operation not permitted")?(c(!0),R(),{isError:!0}):{dirList:D,dirPath:k}},O=async()=>{const{isError:y=!1,dirList:k=[]}=await j(u);y||(i(k),l(!0),h(u&&u.split(C).filter(D=>!!D)||[]))},R=()=>{l(!1),t(!1),h([])},B=async(y,k=!1,D=!1)=>{var b,I;if(k){const{path:M}=await Me();M&&await it(M,y)}await((b=F)==null?void 0:b.upsert({myWorkflowsDir:y}));const x=await((I=F)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(x),D&&c(!1),R()},U=async y=>{if(y){const{error:D=""}=await Fe(y);if(D.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=y??`${f?"":C}${s.join(C)}`;N("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{B(k,!0,!!y)}},{label:"No",onClick:()=>{B(k,!1,!!y)}}])},he=async()=>{const{dirPath:y,dirList:k}=await j("");h(y.split(C).filter(D=>!!D)),i(k)},se=async(y,k)=>{var I;let D="";y===-1&&k?D=`${f?"":C}${s.concat([k]).join(C)}`:D=`${f?"":C}${s.slice(0,y+1).join(C)}`;const{isError:x=!1,dirList:b=[]}=await j(D);x||(i(b),h(f?D.split(C):(I=D.slice(1))==null?void 0:I.split(C)))},ne=e.jsxs($,{textAlign:"end",mb:4,children:[e.jsx(ke,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(P,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&U((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),pe=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs($,{mb:4,children:[e.jsx(z,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?n?ne:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(K,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&C,e.jsx(P,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{se(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Ge,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:a.map((y,k)=>e.jsx(P,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{se(-1,y)},children:y},`${y}-${k}`))}),e.jsxs($,{w:"100%",textAlign:"end",children:[e.jsx(P,{colorScheme:"teal",size:"sm",onClick:()=>{U()},children:"Save"}),e.jsx(P,{size:"sm",onClick:he,mr:2,ml:2,children:"Reset"}),e.jsx(P,{size:"sm",onClick:R,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:u}),e.jsx(_,{label:d?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:O})}),e.jsx(_,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:pe,variant:"ghost"})})]})]}),e.jsxs(ie,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Kind tips"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs($,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(z,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(P,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos
+ -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(z,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ne]})})]})]})]})}function Ze({label:n,settingKey:t}){const[r,l]=o.useState(200),a=Y(),i=s=>{if(!s.length){l(0);return}l(parseInt(s))},u=async()=>{var s;r<0&&l(0),await((s=F)==null?void 0:s.upsert({[t]:Number(r)})),a({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=F)==null||s.getSetting(t).then(h=>{l(h)})};return o.useEffect(()=>{p()},[]),e.jsxs(K,{children:[e.jsx(z,{children:n}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:s=>i(s),onBlur:()=>{u()},onKeyUp:s=>{s.key==="Enter"&&u()},children:e.jsx(Dt,{})})]})}function ns(){const[n,t]=o.useState(!1),r=Y(),l=()=>{var a;(a=F)==null||a.getSetting("autoSave").then(i=>{t(!!i)})};return o.useEffect(()=>{l()},[]),e.jsxs(K,{children:[e.jsx(X,{isChecked:n,onChange:async a=>{var i;await((i=F)==null?void 0:i.upsert({autoSave:a.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),n&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function as({onClose:n}){return e.jsx(e.Fragment,{children:e.jsxs(ie,{isOpen:!0,onClose:n,size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Settings"}),e.jsx(de,{}),e.jsx(ue,{pb:14,children:e.jsx(T,{children:e.jsxs(Ke,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(ns,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(es,{}),e.jsx(Ee,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ze,{label:`Maximum number of save change history to store. This does not include
+ versions that you created by "Create Version", which are always stored
+ and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Ee,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"})]})})})]})]})})}const fe=16;function os({}){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),{colorMode:a,toggleColorMode:i}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,children:[e.jsx(te,{as:A,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(ee,{children:[e.jsx(W,{onClick:()=>l(!0),icon:e.jsx(Zt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(W,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:fe}),fontSize:16,children:"Manage Tags"}),e.jsxs(W,{onClick:i,icon:a==="light"?e.jsx(Ht,{size:fe}):e.jsx(Yt,{size:fe}),fontSize:16,children:[a==="light"?"Dark":"Light"," Mode"]})]})]}),n&&e.jsx(Jt,{onclose:()=>t(!1)}),r&&e.jsx(as,{onClose:()=>l(!1)})]})}function is(n){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:a,batchOperationCallback:i}=n,u=async()=>{var h;const s=await((h=E)==null?void 0:h.batchQuery(l))??[];ct(s)},p=l.length===0;return e.jsx(T,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(X,{isChecked:a,onChange:s=>{i("selectAll",s.target.checked)}}),e.jsx(_,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:u})}),e.jsx(_,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=E)==null?void 0:s.batchDeleteFlow(l)),i("batchDelete")}})}),l.length>0&&e.jsx(z,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(_,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(_,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(A,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Gt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function rs({setSelectedTag:n,selectedTag:t}){const[r,l]=o.useState(!1),[a,i]=o.useState([]);return o.useEffect(()=>{var u;(u=xe)==null||u.listAll().then(p=>{i(p)})},[]),e.jsxs(T,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{n(void 0)}}),a.slice(0,r?void 0:Te).map(u=>e.jsx(P,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(u.name)},isActive:t===u.name,children:u.name},u.name)),(a.length??0)>Te&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:n,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=o.useContext(V),[l,a]=o.useState("file"),i=o.useRef(null),u=d=>{var g;a(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(g=i.current)==null||g.click()},p=async d=>{var g;if(d.type==="image/png"){const m=await ut(d),c=m==null?void 0:m.workflow;if(c)return{json:c,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(g=d.name)!=null&&g.endsWith(".json"))return await new Promise((m,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?m({json:w,name:d.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(d)});return null},s=async d=>{var m,c;const g=[d];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=G)==null?void 0:m.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,g.push(w))}),S.length&&await((c=E)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async d=>{var m;const g=d.target.files;if(g)if(l==="folder"){const c={name:g[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of g)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wj.name===N);if(!C){if(C={name:N,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},C.isFile){const j=await p(f);j&&(C.file=j)}S.push(C)}C&&!C.isFile&&(S=C.children)}}s(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=E)==null?void 0:m.batchCreateFlows(c,void 0,n)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(W,{onClick:d=>{d.stopPropagation(),u("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:P,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(ee,{children:dt.map((d,g)=>e.jsx(W,{onClick:()=>{u(d.type)},iconSpacing:2,icon:d.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Kt,{size:18}),children:d.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:d=>{d.stopPropagation()}})]})}function ls({folder:n,onclose:t}){const[r,l]=o.useState(n.name),[a,i]=o.useState(""),{onRefreshFilesList:u}=o.useContext(V),p=h=>{l(h.target.value),a&&i("")},s=async()=>{var g,m;const h=r.trim();if(l(h),h===n.name)return t();await((g=G)==null?void 0:g.generateUniqueName(h,n.parentFolderID??""))!==h?i("The name is duplicated, please modify it and submit again."):(await((m=G)==null?void 0:m.update(n.id,{name:h})),u&&u(),t())};return e.jsxs(ie,{isOpen:!0,onClose:t,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Edit folder name"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(ht,{isInvalid:!!a,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(ke,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!a&&r&&s()}}),a&&e.jsx(gt,{children:a})]})}),e.jsxs(Qe,{children:[e.jsx(P,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!r||!!a,children:"Save"}),e.jsx(P,{onClick:t,children:"Cancel"})]})]})]})}function cs({menuPosition:n,isopen:t,folder:r,onClose:l}){const[a,i]=o.useState(!1),{onRefreshFilesList:u}=o.useContext(V),{showDialog:p}=we(),s=async m=>{var c;m.stopPropagation(),await((c=G)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),u&&u()},h=async m=>{var c;m.stopPropagation(),await((c=E)==null?void 0:c.createFlow({json:JSON.stringify(ft),parentFolderID:r.id})),u&&u()},d=async m=>{m.stopPropagation();const c=await xt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(jt.DELETE)}}])},g=async m=>{var c;await((c=G)==null?void 0:c.deleteFolder(r.id,m)),l(),u&&u()};return e.jsxs(e.Fragment,{children:[e.jsx($,{position:"absolute",top:n.y,left:n.x,children:e.jsx(Q,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(ee,{children:[e.jsx(W,{icon:e.jsx(mt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),i(!0)},children:"Rename"}),e.jsx(W,{icon:e.jsx(Ae,{size:19}),onClick:d,children:"Delete"}),e.jsx(W,{onClick:s,icon:e.jsx(He,{size:19}),children:"New folder"}),e.jsx(W,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),a&&e.jsx(ls,{folder:r,onclose:()=>i(!1)})]})}const Oe=o.memo(function({folder:t}){const[r,l]=o.useState(!1),[a,i]=o.useState(t.isCollapse??!0),[u,p]=o.useState([]),[s,h]=o.useState({x:0,y:0}),[d,g]=o.useState(!1),{colorMode:m}=ve(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=o.useContext(V),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};o.useEffect(()=>{var j;a||(j=E)==null||j.listFolderContent(t.id,window.localStorage.getItem(je)).then(O=>{p(O)})},[t.id,v,a]);const N=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),g(!0)},C=async j=>{var O,R;if(j.preventDefault(),j.stopPropagation(),!c)return l(!1);if(H(c)){if(c.id===t.id)return l(!1);await((O=G)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else H(c)||await((R=E)==null?void 0:R.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return o.useEffect(()=>{var j;!!t.isCollapse!==a&&((j=G)==null||j.update(t.id,{isCollapse:a}))},[a]),o.useEffect(()=>{var U;const j=(U=E)==null?void 0:U.curWorkflow,O=(j==null?void 0:j.parentFolderID)+"/",R=t.id+"/";O.startsWith(R)&&i(!1)},[]),e.jsxs(K,{children:[e.jsxs(T,{w:"100%",as:"button",py:1,onClick:()=>{i(!a)},onContextMenu:N,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:C,_hover:w,style:r||d?w:void 0,className:"droppable",children:[e.jsxs(T,{gap:1,children:[a?e.jsx(Et,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(z,{children:t.name})]}),e.jsx(cs,{isopen:d,menuPosition:s,onClose:()=>g(!1),folder:t}),!a&&e.jsx(K,{ml:4,gap:0,children:e.jsx(Xe,{items:u})})]})});function ds({workflow:n}){const t=o.useRef(null),r=Y(),{onDuplicateWorkflow:l}=o.useContext(Ce),[a,i]=o.useState(n.saveLock??!1),u=async()=>{var h;const s=!a;i(s),await((h=E)==null?void 0:h.updateMetaInfo(n.id,{saveLock:s})),r({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.target.files;if(!h)return;const d=new FormData;Array.from(h).forEach((g,m)=>{d.append(`images[${m}]`,g,g.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=vt)==null||c.create({workflowID:n.id,localPath:m}),(f=E)==null||f.updateMetaInfo(n.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(te,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(ee,{zIndex:101,children:[e.jsx(W,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(n.id),children:"Duplicate"}),e.jsx(W,{icon:e.jsx(yt,{size:20}),onClick:()=>wt(n.id),children:"Open in new tab"}),e.jsx(_,{hasArrow:!0,label:a?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(W,{icon:a?e.jsx($e,{}):e.jsx(Vt,{}),onClick:u,children:a?"Unlock":"Lock"})}),e.jsx(W,{icon:e.jsx(qt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function us({workflow:n}){const{onDeleteFlow:t}=o.useContext(V);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(n.id)}}),e.jsx(ds,{workflow:n})]})}const ze=o.memo(function({workflow:t}){var v,S,w,N;const{colorMode:r}=ve(),{setDraggingFile:l,isMultiSelecting:a,onMultiSelectFlow:i,multiSelectedFlowsID:u}=o.useContext(V),p=u&&u.length>0&&u.includes(t.id),{curFlowID:s,loadWorkflowID:h}=o.useContext(Ce),d=s===t.id,g=r==="light"?"gray.200":"#4A5568",[m,c]=o.useState(!1),f=e.jsx($,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!a?"#333":void 0,draggable:!a,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!a&&h(t.id)},_hover:{bg:g},children:e.jsxs(T,{flexGrow:1,children:[!((S=(v=F)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((N=t.latestImage)==null?void 0:N.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(T,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(z,{fontWeight:"500",noOfLines:2,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(T,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:r=="dark"?"gray.900":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:a?e.jsx(X,{isChecked:p,spacing:4,onChange:C=>{i&&i(t.id,C.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx("div",{style:{width:"80px"},children:m?e.jsx(us,{workflow:t}):e.jsx(z,{color:"GrayText",ml:"2px",fontSize:"sm",children:kt(t.updateTime,!1,!1,"/")})})]})})});function Xe({items:n}){var m;const[t,r]=o.useState(!1),l=n.filter(H),a=n.filter(c=>!H(c)),i=(m=a[0])==null?void 0:m.parentFolderID,[u,p]=o.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:d}=o.useContext(V),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(H(h)){if(h.id===i)return p(!1);await((f=G)==null?void 0:f.update(h.id,{parentFolderID:i}))}else await((v=E)==null?void 0:v.updateFolder(h.id,{parentFolderID:i}));await(s==null?void 0:s()),p(!1)};return o.useEffect(()=>{var c;(c=F)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[d]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx($,{border:u?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?a.map(c=>e.jsx(ze,{workflow:c},c.id)):n.map(c=>H(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:n,onClickNewFlow:t}){const[r,l]=o.useState([]),a=o.useRef([]),{loadWorkflowID:i,curFlowID:u}=o.useContext(Ce),[p,s]=o.useState(),[h,d]=o.useState(!1),[g,m]=o.useState([]),[c,f]=o.useState(0),[v,S]=o.useState(""),w=Ot(v,400),N=o.useRef(null),[C,j]=o.useState(null),O=o.useRef(window.localStorage.getItem(je)??q.RECENTLY_MODIFIED),R=!!p||!!w.length,B=async()=>{var b,I;const x=await((b=E)==null?void 0:b.listFolderContent())??[];l(me(x,O.current)),f(Date.now()),a.current=await((I=E)==null?void 0:I.listAll())??[]},U=()=>{const x=a.current.filter(b=>{var Ie;let I=!0,M=!0;return p&&(I=!!((Ie=b.tags)!=null&&Ie.includes(p))),w&&(M=!!b.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),I&&M});l(me(x,O.current))},he=x=>{l(me(r,x)),O.current=x,window.localStorage.setItem(je,x),!R&&f(Date.now())};o.useEffect(()=>{R?U():B()},[w,p]);const se=o.useCallback(async x=>{var b,I,M;await((b=E)==null?void 0:b.deleteFlow(x)),((M=(I=E)==null?void 0:I.curWorkflow)==null?void 0:M.id)===x&&await(i==null?void 0:i(null)),await B()},[p,w]);o.useEffect(()=>{const x=async b=>{var I;if(N.current){const M=await((I=E)==null?void 0:I.get(N.current));M&&M.json&&It(M.json,[b.canvasX,b.canvasY])}};return ae.canvasEl.addEventListener("drop",x),ae.canvasEl.addEventListener("click",n),()=>{ae.canvasEl.removeEventListener("drop",x),ae.canvasEl.removeEventListener("click",n)}},[]);const ne=o.useCallback((x,b)=>{m(I=>{const M=[...I];return b?M.push(x):M.splice(M.indexOf(x),1),M})},[]),pe=(x,b)=>{var I;switch(x){case"batchDelete":u&&((I=E)==null||I.get(u).then(M=>{M||i==null||i(null)})),B(),d(!1),m([]);return;case"selectAll":m(b?a.current.map(M=>M.id):[]);return}},y=x=>{j(x),H(x)||(N.current=x.id)},k=x=>{S(x)},D=450;return e.jsx(V.Provider,{value:{onRefreshFilesList:B,draggingFile:C??void 0,setDraggingFile:y,isMultiSelecting:h,onMultiSelectFlow:ne,multiSelectedFlowsID:g,onDeleteFlow:se,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx($,{style:{width:D},children:e.jsxs(St,{width:D,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(T,{gap:4,children:[e.jsx(T,{gap:2,children:e.jsx(z,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(_,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(_,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(T,{alignItems:"center",children:e.jsx(os,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(rs,{selectedTag:p,setSelectedTag:s}),e.jsxs(T,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(T,{children:[a.current.length>0?e.jsx(is,{multipleState:h,changeMultipleState:x=>{d(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===a.current.length,batchOperationCallback:pe}):e.jsx($,{}),!h&&e.jsx(_,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx(He,{size:21}),onClick:async()=>{var x;await((x=G)==null?void 0:x.create({name:"New Folder"})),B()},"aria-label":"new folder button"})})]}),e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:P,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(T,{children:[e.jsx(z,{children:"Sort by:"}),e.jsx(z,{display:"inline-block",children:O.current})]})}),e.jsx(ee,{children:e.jsx(Ue,{value:O.current,type:"radio",onChange:x=>he(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,b)=>e.jsx(be,{value:x,children:x},b))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:k}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default};
diff --git a/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js b/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js
deleted file mode 100644
index 0816044..0000000
--- a/dist/workspace_web/RecentFilesDrawer-qy9dTPVG.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import{f as J,E as qe,j as e,Z as Je,h as oe,g as ye,r as o,M as ie,N as re,O as le,Q as ce,R as de,S as ue,W as we,i as A,$ as ve,T as Qe}from"./input.js";import{m as Le,u as Ne,a as et,b as tt,c as st,S as nt,M as at,d as N,H as T,T as We,I as z,t as xe,e as Ae,f as Y,E as me,g as B,h as L,i as P,j as ke,k as F,R as G,l as ot,n as Me,B as K,F as Z,o as Fe,p as it,q as rt,r as Q,s as ee,v as R,w as lt,D as Pe,x as E,y as Re,z as ct,A as Se,C as dt,G as _e,J as ut,K as V,L as ht,N as pt,O as mt,P as gt,Q as Be,U as ft,V as xt,W as jt,X as H,Y as je,Z as Ce,_ as $e,$ as yt,a0 as wt,a1 as vt,a2 as kt,a3 as q,a4 as St,a5 as Ct,a6 as bt,a7 as ge,a8 as It}from"./App-YT7a4Gj6.js";import{G as Mt,C as X}from"./chunk-JARCRF6W-66xSMED8.js";import{V as Ke}from"./chunk-NTCQBYKE-7yeghZmZ.js";import{N as Ft,a as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-IFYm2Mq_.js";import{app as ae}from"/scripts/app.js";import{I as Lt}from"./IconCopy-j3_qolNw.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";import"./IconSearch-yd7KVSRG.js";var Ve=J(function(t,r){const{columns:l,spacingX:a,spacingY:i,spacing:u,minChildWidth:p,...s}=t,h=qe(),d=p?Wt(p,h):At(l);return e.jsx(Mt,{ref:r,gap:u,columnGap:a,rowGap:i,templateColumns:d,...s})});Ve.displayName="SimpleGrid";function Nt(n){return typeof n=="number"?`${n}px`:n}function Wt(n,t){return Le(n,r=>{const l=Je("sizes",r,Nt(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(n){return Le(n,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ge=J((n,t)=>{const{title:r,children:l,className:a,...i}=n,u=oe("chakra-menu__group__title",a),p=Ne();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(ye.p,{className:u,...i,__css:p.groupTitle,children:r}),l]})});Ge.displayName="MenuGroup";var Ue=n=>{const{className:t,title:r,...l}=n,a=et(l);return e.jsx(Ge,{title:r,className:oe("chakra-menu__option-group",t),...a})};Ue.displayName="MenuOptionGroup";var Pt=J((n,t)=>{const r=Ne();return e.jsx(ye.button,{ref:t,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),te=J((n,t)=>{const{children:r,as:l,...a}=n,i=tt(a,t),u=l||Pt;return e.jsx(u,{...i,className:oe("chakra-menu__menu-button",n.className),children:e.jsx(ye.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});te.displayName="MenuButton";var Rt=n=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=J((n,t)=>{const{icon:r,iconSpacing:l="0.75rem",...a}=n,i=st(a,t);return e.jsxs(nt,{...i,className:oe("chakra-menu__menuitem-option",a.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:n.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:i.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=N("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=N("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),$t=N("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),De=N("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Kt=N("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),He=N("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Vt=N("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Gt=N("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Ut=N("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Ht=N("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Zt=N("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),Yt=N("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Xt=N("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),qt=N("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function Jt({onclose:n}){const[t,r]=o.useState([]),l=async()=>{var i;const a=await((i=xe)==null?void 0:i.listAll());r(a??[])};return o.useEffect(()=>{l()},[]),e.jsxs(ie,{isOpen:!0,onClose:n,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"My Tags"}),e.jsx(de,{}),e.jsx(ue,{children:t.map(a=>e.jsxs(T,{children:[e.jsx(We,{children:a.name}),e.jsx(z,{onClick:async()=>{var i;await((i=xe)==null?void 0:i.delete(a.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ae,{})})]}))})]})]})}function Qt(){const n=Y(),t=o.useRef([{title:"Save current workflow",key:me.SAVE},{title:"Save as current workflow",key:me.SAVE_AS},{title:"Open spotlight search",key:me.openSpotlightSearch}]),[r,l]=o.useState({save:"",saveAs:"",openSpotlightSearch:""}),[a,i]=o.useState(),u=async(s,h)=>{var m;s.preventDefault();let d="";if(s.ctrlKey&&(d+="Control+"),s.metaKey&&(d+="Command+"),s.shiftKey&&(d+="Shift+"),s.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){d+=s.key.toUpperCase();const g={...r};delete g[h],Object.values(g).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please
- modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((m=F)==null?void 0:m.upsert({shortcuts:{...r,[h]:d}})),p())}},p=()=>{var s;(s=F)==null||s.getSetting("shortcuts").then(h=>{var m;const d=h??((m=F)==null?void 0:m.defaultSettings.shortcuts);l({...r,...d})})};return o.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(T,{children:[e.jsx(L,{fontSize:"sm",w:170,children:s.title}),e.jsx(P,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:a===s.key,children:e.jsx(ke,{value:r[s.key],onKeyDown:h=>{u(h,s.key)},onFocus:()=>{i(s.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:n}=o.useContext(G),[t,r]=o.useState(!1),l=()=>{var i;(i=F)==null||i.getSetting("foldersOnTop").then(u=>{r(!!u)})},a=i=>{var p;const u=i.target.checked;(p=F)==null||p.upsert({foldersOnTop:u}).then(()=>{l(),n(Date.now())})};return o.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(X,{isChecked:t,onChange:a,children:"Folders always on top"})})}function ts(){const[n,t]=o.useState(!1),[r,l]=o.useState(""),{showDialog:a}=we(),i=()=>{var p,s;(p=F)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=F)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};o.useEffect(()=>{i()},[]);const u=async p=>{var h,d;if(!p.target.checked){await((h=F)==null?void 0:h.upsert({twoWaySync:p.target.checked})),i();return}const s=await((d=F)==null?void 0:d.getSetting("myWorkflowsDir"));a(e.jsx(ot,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var m;await((m=F)==null?void 0:m.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(L,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(X,{isChecked:n,onChange:u,children:"Enable two way sync"})]})}function Ee({settingKey:n,text:t,defaultChecked:r=!1}){const[l,a]=o.useState(r),i=Y(),u=()=>{var p;(p=F)==null||p.getSetting(n).then(s=>{a(!!s)})};return o.useEffect(()=>{u()},[]),e.jsx(B,{children:e.jsx(X,{isChecked:l,onChange:async p=>{var s;await((s=F)==null?void 0:s.upsert({[n]:p.target.checked})),u(),i({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),[a,i]=o.useState([]),[u,p]=o.useState(""),[s,h]=o.useState([]),[d,m]=o.useState(!1),[g,c]=o.useState(!1),[f,v]=o.useState(!1),S=o.useRef(null),w=Y(),{showDialog:W}=we(),C=f?"\\":"/";o.useEffect(()=>{var y;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=F)==null||y.getSetting("twoWaySync").then(k=>{m(k??!1)})},[]);const j=async y=>{const{dir_path:k="",dir_contents:D=[],error:x=""}=await Fe(y??"");return x.includes("Operation not permitted")?(c(!0),_(),{isError:!0}):{dirList:D,dirPath:k}},O=async()=>{const{isError:y=!1,dirList:k=[]}=await j(u);y||(i(k),l(!0),h(u&&u.split(C).filter(D=>!!D)||[]))},_=()=>{l(!1),t(!1),h([])},$=async(y,k=!1,D=!1)=>{var b,I;if(k){const{path:M}=await Me();M&&await it(M,y)}await((b=F)==null?void 0:b.upsert({myWorkflowsDir:y}));const x=await((I=F)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(x),D&&c(!1),_()},U=async y=>{if(y){const{error:D=""}=await Fe(y);if(D.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=y??`${f?"":C}${s.join(C)}`;W("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{$(k,!0,!!y)}},{label:"No",onClick:()=>{$(k,!1,!!y)}}])},he=async()=>{const{dirPath:y,dirList:k}=await j("");h(y.split(C).filter(D=>!!D)),i(k)},se=async(y,k)=>{var I;let D="";y===-1&&k?D=`${f?"":C}${s.concat([k]).join(C)}`:D=`${f?"":C}${s.slice(0,y+1).join(C)}`;const{isError:x=!1,dirList:b=[]}=await j(D);x||(i(b),h(f?D.split(C):(I=D.slice(1))==null?void 0:I.split(C)))},ne=e.jsxs(K,{textAlign:"end",mb:4,children:[e.jsx(ke,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(A,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var y,k;(y=S==null?void 0:S.current)!=null&&y.value&&U((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),pe=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(K,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?n?ne:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&C,e.jsx(A,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{se(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Ve,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:a.map((y,k)=>e.jsx(A,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{se(-1,y)},children:y},`${y}-${k}`))}),e.jsxs(K,{w:"100%",textAlign:"end",children:[e.jsx(A,{colorScheme:"teal",size:"sm",onClick:()=>{U()},children:"Save"}),e.jsx(A,{size:"sm",onClick:he,mr:2,ml:2,children:"Reset"}),e.jsx(A,{size:"sm",onClick:_,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:u}),e.jsx(P,{label:d?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(z,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:O})}),e.jsx(P,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(z,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:pe,variant:"ghost"})})]})]}),e.jsxs(ie,{isOpen:g,onClose:()=>c(!1),size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Kind tips"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(K,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(L,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(A,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos
- -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(L,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ne]})})]})]})]})}function Ze({label:n,settingKey:t}){const[r,l]=o.useState(200),a=Y(),i=s=>{if(!s.length){l(0);return}l(parseInt(s))},u=async()=>{var s;r<0&&l(0),await((s=F)==null?void 0:s.upsert({[t]:Number(r)})),a({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=F)==null||s.getSetting(t).then(h=>{l(h)})};return o.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:n}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:s=>i(s),onBlur:()=>{u()},onKeyUp:s=>{s.key==="Enter"&&u()},children:e.jsx(Dt,{})})]})}function ns(){const[n,t]=o.useState(!1),r=Y(),l=()=>{var a;(a=F)==null||a.getSetting("autoSave").then(i=>{t(!!i)})};return o.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(X,{isChecked:n,onChange:async a=>{var i;await((i=F)==null?void 0:i.upsert({autoSave:a.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),n&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function as({onClose:n}){return e.jsx(e.Fragment,{children:e.jsxs(ie,{isOpen:!0,onClose:n,size:"xl",children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Settings"}),e.jsx(de,{}),e.jsx(ue,{pb:14,children:e.jsx(T,{children:e.jsxs(Ke,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(ns,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(es,{}),e.jsx(Ee,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ze,{label:`Maximum number of save change history to store. This does not include
- versions that you created by "Create Version", which are always stored
- and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Ee,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"})]})})})]})]})})}const fe=16;function os({}){const[n,t]=o.useState(!1),[r,l]=o.useState(!1),{colorMode:a,toggleColorMode:i}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,children:[e.jsx(te,{as:z,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(ee,{children:[e.jsx(R,{onClick:()=>l(!0),icon:e.jsx(Zt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(R,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:fe}),fontSize:16,children:"Manage Tags"}),e.jsxs(R,{onClick:i,icon:a==="light"?e.jsx(Ht,{size:fe}):e.jsx(Yt,{size:fe}),fontSize:16,children:[a==="light"?"Dark":"Light"," Mode"]})]})]}),n&&e.jsx(Jt,{onclose:()=>t(!1)}),r&&e.jsx(as,{onClose:()=>l(!1)})]})}function is(n){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:a,batchOperationCallback:i}=n,u=async()=>{var h;const s=await((h=E)==null?void 0:h.batchQuery(l))??[];ct(s)},p=l.length===0;return e.jsx(T,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(X,{isChecked:a,onChange:s=>{i("selectAll",s.target.checked)}}),e.jsx(P,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(z,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:u})}),e.jsx(P,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=E)==null?void 0:s.batchDeleteFlow(l)),i("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(P,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(z,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(P,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(z,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Vt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function rs({setSelectedTag:n,selectedTag:t}){const[r,l]=o.useState(!1),[a,i]=o.useState([]);return o.useEffect(()=>{var u;(u=xe)==null||u.listAll().then(p=>{i(p)})},[]),e.jsxs(T,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(z,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{n(void 0)}}),a.slice(0,r?void 0:Te).map(u=>e.jsx(A,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(u.name)},isActive:t===u.name,children:u.name},u.name)),(a.length??0)>Te&&e.jsx(z,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:n,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=o.useContext(G),[l,a]=o.useState("file"),i=o.useRef(null),u=d=>{var m;a(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(m=i.current)==null||m.click()},p=async d=>{var m;if(d.type==="image/png"){const g=await ut(d),c=g==null?void 0:g.workflow;if(c)return{json:c,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(m=d.name)!=null&&m.endsWith(".json"))return await new Promise((g,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?g({json:w,name:d.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(d)});return null},s=async d=>{var g,c;const m=[d];for(;m.length>0;){const f=m.shift();if(f&&!f.isFile){const v=await((g=V)==null?void 0:g.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,m.push(w))}),S.length&&await((c=E)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async d=>{var g;const m=d.target.files;if(m)if(l==="folder"){const c={name:m[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of m)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wj.name===W);if(!C){if(C={name:W,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},C.isFile){const j=await p(f);j&&(C.file=j)}S.push(C)}C&&!C.isFile&&(S=C.children)}}s(c)}else{const c=[];for(const f of m){const v=await p(f);v&&c.push(v)}c.length&&(await((g=E)==null?void 0:g.batchCreateFlows(c,void 0,n)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(R,{onClick:d=>{d.stopPropagation(),u("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:A,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(ee,{children:dt.map((d,m)=>e.jsx(R,{onClick:()=>{u(d.type)},iconSpacing:2,icon:d.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Kt,{size:18}),children:d.title},m))})]}),e.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:d=>{d.stopPropagation()}})]})}function ls({folder:n,onclose:t}){const[r,l]=o.useState(n.name),[a,i]=o.useState(""),{onRefreshFilesList:u}=o.useContext(G),p=h=>{l(h.target.value),a&&i("")},s=async()=>{var m,g;const h=r.trim();if(l(h),h===n.name)return t();await((m=V)==null?void 0:m.generateUniqueName(h,n.parentFolderID??""))!==h?i("The name is duplicated, please modify it and submit again."):(await((g=V)==null?void 0:g.update(n.id,{name:h})),u&&u(),t())};return e.jsxs(ie,{isOpen:!0,onClose:t,children:[e.jsx(re,{}),e.jsxs(le,{children:[e.jsx(ce,{children:"Edit folder name"}),e.jsx(de,{}),e.jsx(ue,{children:e.jsxs(ht,{isInvalid:!!a,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(ke,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!a&&r&&s()}}),a&&e.jsx(mt,{children:a})]})}),e.jsxs(Qe,{children:[e.jsx(A,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!r||!!a,children:"Save"}),e.jsx(A,{onClick:t,children:"Cancel"})]})]})]})}function cs({menuPosition:n,isopen:t,folder:r,onClose:l}){const[a,i]=o.useState(!1),{onRefreshFilesList:u}=o.useContext(G),{showDialog:p}=we(),s=async g=>{var c;g.stopPropagation(),await((c=V)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),u&&u()},h=async g=>{var c;g.stopPropagation(),await((c=E)==null?void 0:c.createFlow({json:JSON.stringify(ft),parentFolderID:r.id})),u&&u()},d=async g=>{g.stopPropagation();const c=await xt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{m(jt.DELETE)}}])},m=async g=>{var c;await((c=V)==null?void 0:c.deleteFolder(r.id,g)),l(),u&&u()};return e.jsxs(e.Fragment,{children:[e.jsx(K,{position:"absolute",top:n.y,left:n.x,children:e.jsx(Q,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(ee,{children:[e.jsx(R,{icon:e.jsx(gt,{size:19}),onClick:g=>{g.preventDefault(),g.stopPropagation(),i(!0)},children:"Rename"}),e.jsx(R,{icon:e.jsx(Ae,{size:19}),onClick:d,children:"Delete"}),e.jsx(R,{onClick:s,icon:e.jsx(He,{size:19}),children:"New folder"}),e.jsx(R,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),a&&e.jsx(ls,{folder:r,onclose:()=>i(!1)})]})}const Oe=o.memo(function({folder:t}){const[r,l]=o.useState(!1),[a,i]=o.useState(t.isCollapse??!0),[u,p]=o.useState([]),[s,h]=o.useState({x:0,y:0}),[d,m]=o.useState(!1),{colorMode:g}=ve(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=o.useContext(G),w=g==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};o.useEffect(()=>{var j;a||(j=E)==null||j.listFolderContent(t.id,window.localStorage.getItem(je)).then(O=>{p(O)})},[t.id,v,a]);const W=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),m(!0)},C=async j=>{var O,_;if(j.preventDefault(),j.stopPropagation(),!c)return l(!1);if(H(c)){if(c.id===t.id)return l(!1);await((O=V)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else H(c)||await((_=E)==null?void 0:_.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return o.useEffect(()=>{var j;!!t.isCollapse!==a&&((j=V)==null||j.update(t.id,{isCollapse:a}))},[a]),o.useEffect(()=>{var U;const j=(U=E)==null?void 0:U.curWorkflow,O=(j==null?void 0:j.parentFolderID)+"/",_=t.id+"/";O.startsWith(_)&&i(!1)},[]),e.jsxs(B,{children:[e.jsxs(T,{w:"100%",as:"button",py:1,onClick:()=>{i(!a)},onContextMenu:W,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:C,_hover:w,style:r||d?w:void 0,className:"droppable",children:[e.jsxs(T,{gap:1,children:[a?e.jsx(Et,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(L,{children:t.name})]}),e.jsx(cs,{isopen:d,menuPosition:s,onClose:()=>m(!1),folder:t}),!a&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Xe,{items:u})})]})});function ds({workflow:n}){const t=o.useRef(null),r=Y(),{onDuplicateWorkflow:l}=o.useContext(Ce),[a,i]=o.useState(n.saveLock??!1),u=async()=>{var h;const s=!a;i(s),await((h=E)==null?void 0:h.updateMetaInfo(n.id,{saveLock:s})),r({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.target.files;if(!h)return;const d=new FormData;Array.from(h).forEach((m,g)=>{d.append(`images[${g}]`,m,m.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(h).forEach(async m=>{var c,f;const g=`workspace_manager/${m.name}`;(c=yt)==null||c.create({workflowID:n.id,localPath:g}),(f=E)==null||f.updateMetaInfo(n.id,{coverMediaPath:g})})};return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{isLazy:!0,closeOnSelect:!1,children:[e.jsx(te,{border:0,as:z,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(ee,{zIndex:101,children:[e.jsx(R,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(n.id),children:"Duplicate"}),e.jsx(P,{hasArrow:!0,label:a?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(R,{icon:a?e.jsx($e,{}):e.jsx(Gt,{}),onClick:u,children:a?"Unlock":"Lock"})}),e.jsx(R,{icon:e.jsx(qt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function us({workflow:n}){const{onDeleteFlow:t}=o.useContext(G);return e.jsxs(Z,{width:"90px",justifyContent:"flex-end",children:[e.jsx(P,{label:"Open in new tab",children:e.jsx(z,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>wt(n.id),icon:e.jsx(vt,{color:"#718096",size:23})})}),e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(n.id)}}),e.jsx(ds,{workflow:n})]})}const ze=o.memo(function({workflow:t}){var v,S,w,W;const{colorMode:r}=ve(),{setDraggingFile:l,isMultiSelecting:a,onMultiSelectFlow:i,multiSelectedFlowsID:u}=o.useContext(G),p=u&&u.length>0&&u.includes(t.id),{curFlowID:s,loadWorkflowID:h}=o.useContext(Ce),d=s===t.id,m=r==="light"?"gray.200":"#4A5568",[g,c]=o.useState(!1),f=e.jsx(K,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!a?"#333":void 0,draggable:!a,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"3px",onClick:()=>{!a&&h(t.id)},_hover:{bg:m},children:e.jsxs(T,{children:[!((S=(v=F)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((W=t.latestImage)==null?void 0:W.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsxs(B,{textAlign:"left",gap:0,children:[e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:2,style:{display:"inline-block"},children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]}),e.jsxs(L,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",kt(t.updateTime)]})]})]})});return e.jsx(T,{w:"100%",mb:1,justify:"space-between",onMouseEnter:()=>c(!0),children:a?e.jsx(X,{isChecked:p,spacing:4,onChange:C=>{i&&i(t.id,C.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,g&&e.jsx(us,{workflow:t})]})})});function Xe({items:n}){var g;const[t,r]=o.useState(!1),l=n.filter(H),a=n.filter(c=>!H(c)),i=(g=a[0])==null?void 0:g.parentFolderID,[u,p]=o.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:d}=o.useContext(G),m=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(H(h)){if(h.id===i)return p(!1);await((f=V)==null?void 0:f.update(h.id,{parentFolderID:i}))}else await((v=E)==null?void 0:v.updateFolder(h.id,{parentFolderID:i}));await(s==null?void 0:s()),p(!1)};return o.useEffect(()=>{var c;(c=F)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[d]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx(K,{border:u?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:m,className:"droppable",children:t?a.map(c=>e.jsx(ze,{workflow:c},c.id)):n.map(c=>H(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:n,onClickNewFlow:t}){const[r,l]=o.useState([]),a=o.useRef([]),{loadWorkflowID:i,curFlowID:u}=o.useContext(Ce),[p,s]=o.useState(),[h,d]=o.useState(!1),[m,g]=o.useState([]),[c,f]=o.useState(0),[v,S]=o.useState(""),w=Ot(v,400),W=o.useRef(null),[C,j]=o.useState(null),O=o.useRef(window.localStorage.getItem(je)??q.RECENTLY_MODIFIED),_=!!p||!!w.length,$=async()=>{var b,I;const x=await((b=E)==null?void 0:b.listFolderContent())??[];l(ge(x,O.current)),f(Date.now()),a.current=await((I=E)==null?void 0:I.listAll())??[]},U=()=>{const x=a.current.filter(b=>{var Ie;let I=!0,M=!0;return p&&(I=!!((Ie=b.tags)!=null&&Ie.includes(p))),w&&(M=!!b.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),I&&M});l(ge(x,O.current))},he=x=>{l(ge(r,x)),O.current=x,window.localStorage.setItem(je,x),!_&&f(Date.now())};o.useEffect(()=>{_?U():$()},[w,p]);const se=o.useCallback(async x=>{var b,I,M;await((b=E)==null?void 0:b.deleteFlow(x)),((M=(I=E)==null?void 0:I.curWorkflow)==null?void 0:M.id)===x&&await(i==null?void 0:i(null)),await $()},[p,w]);o.useEffect(()=>{const x=async b=>{var I;if(W.current){const M=await((I=E)==null?void 0:I.get(W.current));M&&M.json&&It(M.json,[b.canvasX,b.canvasY])}};return ae.canvasEl.addEventListener("drop",x),ae.canvasEl.addEventListener("click",n),()=>{ae.canvasEl.removeEventListener("drop",x),ae.canvasEl.removeEventListener("click",n)}},[]);const ne=o.useCallback((x,b)=>{g(I=>{const M=[...I];return b?M.push(x):M.splice(M.indexOf(x),1),M})},[]),pe=(x,b)=>{var I;switch(x){case"batchDelete":u&&((I=E)==null||I.get(u).then(M=>{M||i==null||i(null)})),$(),d(!1),g([]);return;case"selectAll":g(b?a.current.map(M=>M.id):[]);return}},y=x=>{j(x),H(x)||(W.current=x.id)},k=x=>{S(x)},D=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:$,draggingFile:C??void 0,setDraggingFile:y,isMultiSelecting:h,onMultiSelectFlow:ne,multiSelectedFlowsID:m,onDeleteFlow:se,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(K,{style:{width:D},children:e.jsxs(St,{width:D,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(T,{gap:4,children:[e.jsx(T,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(P,{label:"Open workspace save directory",children:e.jsx(z,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(P,{label:"New workflow",children:e.jsx(z,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(T,{alignItems:"center",children:e.jsx(os,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(rs,{selectedTag:p,setSelectedTag:s}),e.jsxs(T,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(T,{children:[a.current.length>0?e.jsx(is,{multipleState:h,changeMultipleState:x=>{d(x),!x&&g([])},selectedKeys:m,isSelectedAll:m.length===a.current.length,batchOperationCallback:pe}):e.jsx(K,{}),!h&&e.jsx(P,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(z,{size:"sm",variant:"outline",icon:e.jsx(He,{size:21}),onClick:async()=>{var x;await((x=V)==null?void 0:x.create({name:"New Folder"})),$()},"aria-label":"new folder button"})})]}),e.jsxs(Q,{closeOnSelect:!0,children:[e.jsx(te,{as:A,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(T,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(ee,{children:e.jsx(Ue,{value:O.current,type:"radio",onChange:x=>he(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,b)=>e.jsx(be,{value:x,children:x},b))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:k}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default};
diff --git a/dist/workspace_web/ShareDialog-ABShBZ_r.js b/dist/workspace_web/ShareDialog-ABShBZ_r.js
deleted file mode 100644
index f27f4dd..0000000
--- a/dist/workspace_web/ShareDialog-ABShBZ_r.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as a,m as he,x as ae,b as fe,f as le,j as e,g as J,h as pe,n as y,s as M,q as Y,l as ge,o as me,H as ve,a3 as we,i as q,M as xe,N as ke,O as be,Q as ye,S as Ce}from"./input.js";import{aG as je,d as Se,B as Ie,A as De,a4 as Pe,H as Q,h as X,a2 as Re,a1 as ie,f as _e,k as ne,g as re,aH as Fe,j as Me,F as Ee,aI as Ne,x as K,aJ as U,aK as Le,aL as We,aM as Te,T as He,aN as Ve}from"./App-YT7a4Gj6.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Be}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import{I as Ke}from"./IconCopy-j3_qolNw.js";import"/scripts/api.js";function qe(t){return t&&ae(t)&&ae(t.target)}function Ge(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[w,C]=a.useState(s||""),x=typeof c<"u",j=x?c:w,k=a.useRef(null),S=a.useCallback(()=>{const n=k.current;if(!n)return;let i="input:not(:disabled):checked";const I=n.querySelector(i);if(I){I.focus();return}i="input:not(:disabled)";const o=n.querySelector(i);o==null||o.focus()},[]),m=`radio-${a.useId()}`,N=d||m,R=a.useCallback(n=>{const i=qe(n)?n.target.value:n;x||C(i),p==null||p(String(i))},[p,x]),O=a.useCallback((n={},i=null)=>({...n,ref:he(i,k),role:"radiogroup"}),[]),_=a.useCallback((n={},i=null)=>({...n,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?n.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:O,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=le((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...w}=t,{value:C,onChange:x,getRootProps:j,name:k,htmlProps:S}=Ge(w),E=a.useMemo(()=>({name:k,size:s,onChange:x,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,x,c,C,d,g,f]);return e.jsx($e,{value:E,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var ze={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Ue(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:w,value:C,id:x,"data-radiogroup":j,"aria-describedby":k,...S}=t,E=`radio-${a.useId()}`,m=je(),R=!!ce()||!!j;let _=!!m&&!R?m.id:E;_=x??_;const n=d??(m==null?void 0:m.isDisabled),i=h??(m==null?void 0:m.isReadOnly),I=u??(m==null?void 0:m.isRequired),o=f??(m==null?void 0:m.isInvalid),[r,P]=a.useState(!1),[v,D]=a.useState(!1),[b,L]=a.useState(!1),[W,T]=a.useState(!1),[G,$]=a.useState(!!p),A=typeof c<"u",F=A?c:G;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(l=>{if(i||n){l.preventDefault();return}A||$(l.target.checked),g==null||g(l)},[A,n,i,g]),B=a.useCallback(l=>{l.key===" "&&T(!0)},[T]),z=a.useCallback(l=>{l.key===" "&&T(!1)},[T]),ee=a.useCallback((l={},V=null)=>({...l,ref:V,"data-active":y(W),"data-hover":y(b),"data-disabled":y(n),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&r),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:M(l.onMouseDown,()=>T(!0)),onMouseUp:M(l.onMouseUp,()=>T(!1)),onMouseEnter:M(l.onMouseEnter,()=>L(!0)),onMouseLeave:M(l.onMouseLeave,()=>L(!1))}),[W,b,n,o,F,v,i,r]),{onFocus:oe,onBlur:se}=m??{},ue=a.useCallback((l={},V=null)=>{const te=n&&!s;return{...l,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(l.onChange,H),onBlur:M(se,l.onBlur,()=>D(!1)),onFocus:M(oe,l.onFocus,()=>D(!0)),onKeyDown:M(l.onKeyDown,B),onKeyUp:M(l.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:I,"aria-invalid":Y(o),"aria-disabled":Y(te),"aria-required":Y(I),"data-readonly":y(i),"aria-describedby":k,style:ze}},[n,s,_,w,C,H,se,oe,B,z,F,i,I,o,k]);return{state:{isInvalid:o,isFocused:v,isChecked:F,isActive:W,isHovered:b,isDisabled:n,isReadOnly:i,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(l={},V=null)=>({...l,ref:V,onMouseDown:M(l.onMouseDown,Je),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(l,V=null)=>({...l,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Je(t){t.preventDefault(),t.stopPropagation()}function Qe(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=le((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=me(t),{spacing:f="0.5rem",children:w,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:x=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let E=d;s!=null&&s.onChange&&h!=null&&(E=ve(s.onChange,d));const m=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:O,getRootProps:_,htmlProps:n}=Ue({...k,isChecked:S,isFocusable:x,isDisabled:C,onChange:E,name:m}),[i,I]=Qe(n,we),o=R(I),r=N(j,p),P=O(),v=Object.assign({},i,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},b={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},L={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...r}),e.jsx(J.span,{className:"chakra-radio__control",...o,__css:b}),w&&e.jsx(J.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});Z.displayName="Radio";var Ye=Se("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Xe({options:t,value:p,onChange:c}){const[s,d]=a.useState(!1),h=a.useRef(null),u=t.find(f=>f.value===p);a.useEffect(()=>{const f=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Ie,{position:"relative",children:[e.jsx(q,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Pe,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(q,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Ze({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:s.name}),e.jsx(X,{color:"GrayText",children:Re(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(q,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ye,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ho({onClose:t}){var i,I;const[p,c]=a.useState("v"+eo()),[s,d]=a.useState([]),[h,u]=a.useState(!1),[g,f]=a.useState(""),[w,C]=a.useState("PRIVATE"),[x,j]=a.useState("new_version"),k=a.useRef(""),[S,E]=a.useState(),m=_e(),N=async o=>{var L,W;const r=o.data;if(o.origin!==k.current||r.type!=="share_workflow_success")return;const P=r.localWorkflowID,v=r.localVersionID,D=r.version.id,b=r.version.workflowID;b&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:b,cloudOrigin:o.origin,privacy:w})),v&&D&&await((W=U)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+b+"/"+D,"_blank"),u(!1)};a.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,v,D;const o=await((P=ne)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const r=((v=K)==null?void 0:v.curWorkflow)??void 0;E(r),r!=null&&r.cloudID&&r.cloudOrigin&&Te(r).then(b=>{C(b)}),(D=U)==null||D.listByWorkflowID(r.id).then(b=>{d(b)})},O=o=>{navigator.clipboard.writeText(o).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(r=>{console.error("Failed to copy text: ",r)})},_=async()=>{var $,A,F;u(!0);const o=Le(32),r=await(($=ne)==null?void 0:$.getSetting("cloudHost"));let P,v;try{if(P=We(),x==="new_version"?v=await((A=U)==null?void 0:A.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=U)==null?void 0:F.get(x)),!v){alert(`Failed to find version: ${x}, please try again.`),u(!1);return}}catch(H){console.error(H),u(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,b=window.location.host,L=`${D}//${b}`,W=r+`/share_workflow_confirm/${o}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),G=H=>{var B;if(H.origin===r&&H.data==="child_ready"){const z=(B=K)==null?void 0:B.curWorkflow;T.postMessage({workflow:z,version:v,nodeDefs:P,privacy:w},r),window.removeEventListener("message",G)}};window.addEventListener("message",G)},n=(I=(i=K)==null?void 0:i.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Xe,{options:Fe,value:w,onChange:o=>{C(o)}}):e.jsx(He,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(q,{width:"180px",size:"sm",leftIcon:e.jsx(Ke,{}),onClick:()=>{var o,r;O(g+"/workflow/"+((r=(o=K)==null?void 0:o.curWorkflow)==null?void 0:r.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{j(o)},value:x,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Me,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Ne,{colorScheme:"purple",children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Ze,{version:o,cloudHost:g,cloudWorkflowID:n??null},o.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(q,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function eo(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ho as default};
diff --git a/dist/workspace_web/ShareDialog-uq7XVWvD.js b/dist/workspace_web/ShareDialog-uq7XVWvD.js
new file mode 100644
index 0000000..49c3a0d
--- /dev/null
+++ b/dist/workspace_web/ShareDialog-uq7XVWvD.js
@@ -0,0 +1 @@
+import{r as n,m as he,x as ne,b as fe,f as le,j as e,g as J,h as pe,n as y,s as M,q as Y,l as ge,o as me,H as ve,a3 as we,i as q,M as xe,N as ke,O as be,Q as ye,S as Ce}from"./input.js";import{aG as je,d as Se,B as Ie,A as De,a4 as Pe,H as Q,h as X,a2 as Re,_ as ie,f as _e,k as ae,g as re,aH as Fe,j as Me,F as Ee,aI as Ne,x as K,aJ as U,aK as Le,aL as We,aM as Te,T as He,aN as Ve}from"./App-bXo9NVT7.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Be}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import{I as Ke}from"./IconCopy-wyTg5wiq.js";import"/scripts/api.js";function qe(t){return t&&ne(t)&&ne(t.target)}function Ge(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[w,C]=n.useState(s||""),x=typeof c<"u",j=x?c:w,k=n.useRef(null),S=n.useCallback(()=>{const a=k.current;if(!a)return;let i="input:not(:disabled):checked";const I=a.querySelector(i);if(I){I.focus();return}i="input:not(:disabled)";const o=a.querySelector(i);o==null||o.focus()},[]),m=`radio-${n.useId()}`,N=d||m,R=n.useCallback(a=>{const i=qe(a)?a.target.value:a;x||C(i),p==null||p(String(i))},[p,x]),O=n.useCallback((a={},i=null)=>({...a,ref:he(i,k),role:"radiogroup"}),[]),_=n.useCallback((a={},i=null)=>({...a,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?a.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:O,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=le((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...w}=t,{value:C,onChange:x,getRootProps:j,name:k,htmlProps:S}=Ge(w),E=n.useMemo(()=>({name:k,size:s,onChange:x,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,x,c,C,d,g,f]);return e.jsx($e,{value:E,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var ze={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Ue(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:w,value:C,id:x,"data-radiogroup":j,"aria-describedby":k,...S}=t,E=`radio-${n.useId()}`,m=je(),R=!!ce()||!!j;let _=!!m&&!R?m.id:E;_=x??_;const a=d??(m==null?void 0:m.isDisabled),i=h??(m==null?void 0:m.isReadOnly),I=u??(m==null?void 0:m.isRequired),o=f??(m==null?void 0:m.isInvalid),[r,P]=n.useState(!1),[v,D]=n.useState(!1),[b,L]=n.useState(!1),[W,T]=n.useState(!1),[G,$]=n.useState(!!p),A=typeof c<"u",F=A?c:G;n.useEffect(()=>Ae(P),[]);const H=n.useCallback(l=>{if(i||a){l.preventDefault();return}A||$(l.target.checked),g==null||g(l)},[A,a,i,g]),B=n.useCallback(l=>{l.key===" "&&T(!0)},[T]),z=n.useCallback(l=>{l.key===" "&&T(!1)},[T]),ee=n.useCallback((l={},V=null)=>({...l,ref:V,"data-active":y(W),"data-hover":y(b),"data-disabled":y(a),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&r),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:M(l.onMouseDown,()=>T(!0)),onMouseUp:M(l.onMouseUp,()=>T(!1)),onMouseEnter:M(l.onMouseEnter,()=>L(!0)),onMouseLeave:M(l.onMouseLeave,()=>L(!1))}),[W,b,a,o,F,v,i,r]),{onFocus:oe,onBlur:se}=m??{},ue=n.useCallback((l={},V=null)=>{const te=a&&!s;return{...l,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(l.onChange,H),onBlur:M(se,l.onBlur,()=>D(!1)),onFocus:M(oe,l.onFocus,()=>D(!0)),onKeyDown:M(l.onKeyDown,B),onKeyUp:M(l.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:I,"aria-invalid":Y(o),"aria-disabled":Y(te),"aria-required":Y(I),"data-readonly":y(i),"aria-describedby":k,style:ze}},[a,s,_,w,C,H,se,oe,B,z,F,i,I,o,k]);return{state:{isInvalid:o,isFocused:v,isChecked:F,isActive:W,isHovered:b,isDisabled:a,isReadOnly:i,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(l={},V=null)=>({...l,ref:V,onMouseDown:M(l.onMouseDown,Je),"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(l,V=null)=>({...l,ref:V,"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Je(t){t.preventDefault(),t.stopPropagation()}function Qe(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=le((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=me(t),{spacing:f="0.5rem",children:w,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:x=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let E=d;s!=null&&s.onChange&&h!=null&&(E=ve(s.onChange,d));const m=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:O,getRootProps:_,htmlProps:a}=Ue({...k,isChecked:S,isFocusable:x,isDisabled:C,onChange:E,name:m}),[i,I]=Qe(a,we),o=R(I),r=N(j,p),P=O(),v=Object.assign({},i,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},b={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},L={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...r}),e.jsx(J.span,{className:"chakra-radio__control",...o,__css:b}),w&&e.jsx(J.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});Z.displayName="Radio";var Ye=Se("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Xe({options:t,value:p,onChange:c}){const[s,d]=n.useState(!1),h=n.useRef(null),u=t.find(f=>f.value===p);n.useEffect(()=>{const f=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Ie,{position:"relative",children:[e.jsx(q,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Pe,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(q,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Ze({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:s.name}),e.jsx(X,{color:"GrayText",children:Re(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(q,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ye,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ho({onClose:t}){var i,I;const[p,c]=n.useState("v"+eo()),[s,d]=n.useState([]),[h,u]=n.useState(!1),[g,f]=n.useState(""),[w,C]=n.useState("PRIVATE"),[x,j]=n.useState("new_version"),k=n.useRef(""),[S,E]=n.useState(),m=_e(),N=async o=>{var L,W;const r=o.data;if(o.origin!==k.current||r.type!=="share_workflow_success")return;const P=r.localWorkflowID,v=r.localVersionID,D=r.version.id,b=r.version.workflowID;b&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:b,cloudOrigin:o.origin,privacy:w})),v&&D&&await((W=U)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+b+"/"+D,"_blank"),u(!1)};n.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,v,D;const o=await((P=ae)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const r=((v=K)==null?void 0:v.curWorkflow)??void 0;E(r),r!=null&&r.cloudID&&r.cloudOrigin&&Te(r).then(b=>{C(b)}),(D=U)==null||D.listByWorkflowID(r.id).then(b=>{d(b)})},O=o=>{navigator.clipboard.writeText(o).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(r=>{console.error("Failed to copy text: ",r)})},_=async()=>{var $,A,F;u(!0);const o=Le(32),r=await(($=ae)==null?void 0:$.getSetting("cloudHost"));let P,v;try{if(P=We(),x==="new_version"?v=await((A=U)==null?void 0:A.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=U)==null?void 0:F.get(x)),!v){alert(`Failed to find version: ${x}, please try again.`),u(!1);return}}catch(H){console.error(H),u(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,b=window.location.host,L=`${D}//${b}`,W=r+`/share_workflow_confirm/${o}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),G=H=>{var B;if(H.origin===r&&H.data==="child_ready"){const z=(B=K)==null?void 0:B.curWorkflow;T.postMessage({workflow:z,version:v,nodeDefs:P,privacy:w},r),window.removeEventListener("message",G)}};window.addEventListener("message",G)},a=(I=(i=K)==null?void 0:i.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(re,{gap:5,children:[a==null?e.jsx(Xe,{options:Fe,value:w,onChange:o=>{C(o)}}):e.jsx(He,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:w,showEmoji:!0})}),a&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{href:g+"/workflow/"+a,isExternal:!0,children:[g+"/workflow/"+a," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(q,{width:"180px",size:"sm",leftIcon:e.jsx(Ke,{}),onClick:()=>{var o,r;O(g+"/workflow/"+((r=(o=K)==null?void 0:o.curWorkflow)==null?void 0:r.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{j(o)},value:x,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Me,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Ne,{colorScheme:"purple",children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Ze,{version:o,cloudHost:g,cloudWorkflowID:a??null},o.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(q,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function eo(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ho as default};
diff --git a/dist/workspace_web/SpotlightSearch-ysZyuBYf.js b/dist/workspace_web/SpotlightSearch-TbsT5AM9.js
similarity index 96%
rename from dist/workspace_web/SpotlightSearch-ysZyuBYf.js
rename to dist/workspace_web/SpotlightSearch-TbsT5AM9.js
index 21d494c..c211a05 100644
--- a/dist/workspace_web/SpotlightSearch-ysZyuBYf.js
+++ b/dist/workspace_web/SpotlightSearch-TbsT5AM9.js
@@ -1 +1 @@
-import{b as $,f as j,l as Z,o as q,h as w,r as g,j as n,g as A,$ as J,M as Q,O as X,U as ee,i as te}from"./input.js";import{aF as ne,al as se,Z as re,aA as T,ai as G,H as ae,j as oe,h as O,a2 as ie,x as ce,a3 as le,E as ue,k as D}from"./App-YT7a4Gj6.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-yd7KVSRG.js";import{V as he}from"./chunk-NTCQBYKE-7yeghZmZ.js";import"/scripts/app.js";import"/scripts/api.js";var[me,ge]=$({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function ke(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),F=()=>{u("root")},_=e=>{a(e.id),F()},U=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,W]=pe(U,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(O,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=D)==null||k.getSetting("shortcuts").then(h=>{var z;const L=(h.openSpotlightSearch??((z=D)==null?void 0:z.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=L[0]==="Command"?"Meta":L[0],v.current.spotlightSearchShortcutLastKey=L[L.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(G,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(G,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:F,size:"xl",children:n.jsxs(X,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{ke as default};
+import{b as $,f as j,l as Z,o as q,h as w,r as g,j as n,g as A,$ as J,M as Q,O as X,U as ee,i as te}from"./input.js";import{aF as ne,al as se,Z as re,aA as T,ai as G,H as ae,j as oe,h as O,a2 as ie,x as ce,a3 as le,E as ue,k as D}from"./App-bXo9NVT7.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-e7N1azjj.js";import{V as he}from"./chunk-NTCQBYKE-nDCdQPx1.js";import"/scripts/app.js";import"/scripts/api.js";var[me,ge]=$({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function ke(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),F=()=>{u("root")},_=e=>{a(e.id),F()},U=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,W]=pe(U,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(O,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=D)==null||k.getSetting("shortcuts").then(h=>{var z;const L=(h.openSpotlightSearch??((z=D)==null?void 0:z.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=L[0]==="Command"?"Meta":L[0],v.current.spotlightSearchShortcutLastKey=L[L.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(G,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(G,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:F,size:"xl",children:n.jsxs(X,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{ke as default};
diff --git a/dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js b/dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js
similarity index 96%
rename from dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js
rename to dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js
index 92eef33..d151714 100644
--- a/dist/workspace_web/chunk-3RSXBRAN-xkXXv8lg.js
+++ b/dist/workspace_web/chunk-3RSXBRAN-8cE0TZNF.js
@@ -1 +1 @@
-import{f as x,j as l,g as i,h as b,l as C,o as E,n as I,r as f,a3 as P}from"./input.js";import{aa as z}from"./App-YT7a4Gj6.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S};
+import{f as x,j as l,g as i,h as b,l as C,o as E,n as I,r as f,a3 as P}from"./input.js";import{aa as z}from"./App-bXo9NVT7.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S};
diff --git a/dist/workspace_web/chunk-JARCRF6W-66xSMED8.js b/dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js
similarity index 99%
rename from dist/workspace_web/chunk-JARCRF6W-66xSMED8.js
rename to dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js
index 559fc7d..3a125bc 100644
--- a/dist/workspace_web/chunk-JARCRF6W-66xSMED8.js
+++ b/dist/workspace_web/chunk-JARCRF6W-xouhmv4h.js
@@ -1 +1 @@
-import{b as de,r as o,j as u,g as I,d as $,e as z,y as ue,n,s as m,m as te,a0 as W,f as ae,l as fe,o as me,H as he,h as ke}from"./input.js";import{ag as be}from"./App-YT7a4Gj6.js";import{t as ve}from"./index-pz0vT7Or.js";var[Ne,pe]=de({name:"CheckboxGroupContext",strict:!1});function Ce(s){const[l,t]=o.useState(s),[a,f]=o.useState(!1);return s!==l&&(f(!0),t(s)),a}function ge(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...s,children:u.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function ye(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...s,children:u.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function xe(s){const{isIndeterminate:l,isChecked:t,...a}=s,f=l?ye:ge;return t||l?u.jsx(I.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:u.jsx(f,{...a})}):null}var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function we(s,l=[]){const t=Object.assign({},s);for(const a of l)a in t&&delete t[a];return t}function Se(s={}){const l=be(s),{isDisabled:t,isReadOnly:a,isRequired:f,isInvalid:r,id:b,onBlur:P,onFocus:A,"aria-describedby":C}=l,{defaultChecked:g,isChecked:y,isFocusable:D,onChange:R,isIndeterminate:c,name:x,value:M,tabIndex:N=void 0,"aria-label":_,"aria-labelledby":j,"aria-invalid":v,...q}=s,F=we(q,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),E=$(R),K=$(P),L=$(A),[w,T]=o.useState(!1),[p,U]=o.useState(!1),[B,X]=o.useState(!1),[G,S]=o.useState(!1);o.useEffect(()=>ve(T),[]);const h=o.useRef(null),[J,ne]=o.useState(!0),[oe,H]=o.useState(!!g),V=y!==void 0,i=V?y:oe,Q=o.useCallback(e=>{if(a||t){e.preventDefault();return}V||H(i?e.target.checked:c?!0:e.target.checked),E==null||E(e)},[a,t,i,V,c,E]);z(()=>{h.current&&(h.current.indeterminate=!!c)},[c]),ue(()=>{t&&U(!1)},[t,U]),z(()=>{const e=h.current;if(!(e!=null&&e.form))return;const d=()=>{H(!!g)};return e.form.addEventListener("reset",d),()=>{var k;return(k=e.form)==null?void 0:k.removeEventListener("reset",d)}},[]);const Y=t&&!D,Z=o.useCallback(e=>{e.key===" "&&S(!0)},[S]),ee=o.useCallback(e=>{e.key===" "&&S(!1)},[S]);z(()=>{if(!h.current)return;h.current.checked!==i&&H(h.current.checked)},[h.current]);const se=o.useCallback((e={},d=null)=>{const k=O=>{p&&O.preventDefault(),S(!0)};return{...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a),"aria-hidden":!0,onMouseDown:m(e.onMouseDown,k),onMouseUp:m(e.onMouseUp,()=>S(!1)),onMouseEnter:m(e.onMouseEnter,()=>X(!0)),onMouseLeave:m(e.onMouseLeave,()=>X(!1))}},[G,i,t,p,w,B,c,r,a]),re=o.useCallback((e={},d=null)=>({...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a)}),[G,i,t,p,w,B,c,r,a]),ie=o.useCallback((e={},d=null)=>({...F,...e,ref:te(d,k=>{k&&ne(k.tagName==="LABEL")}),onClick:m(e.onClick,()=>{var k;J||((k=h.current)==null||k.click(),requestAnimationFrame(()=>{var O;(O=h.current)==null||O.focus({preventScroll:!0})}))}),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[F,t,i,r,J]),le=o.useCallback((e={},d=null)=>({...e,ref:te(h,d),type:"checkbox",name:x,value:M,id:b,tabIndex:N,onChange:m(e.onChange,Q),onBlur:m(e.onBlur,K,()=>U(!1)),onFocus:m(e.onFocus,L,()=>U(!0)),onKeyDown:m(e.onKeyDown,Z),onKeyUp:m(e.onKeyUp,ee),required:f,checked:i,disabled:Y,readOnly:a,"aria-label":_,"aria-labelledby":j,"aria-invalid":v?!!v:r,"aria-describedby":C,"aria-disabled":t,style:Ie}),[x,M,b,Q,K,L,Z,ee,f,i,Y,a,_,j,v,r,C,t,N]),ce=o.useCallback((e={},d=null)=>({...e,ref:d,onMouseDown:m(e.onMouseDown,Pe),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[i,t,r]);return{state:{isInvalid:r,isFocused:p,isChecked:i,isActive:G,isHovered:B,isIndeterminate:c,isDisabled:t,isReadOnly:a,isRequired:f},getRootProps:ie,getCheckboxProps:se,getIndicatorProps:re,getInputProps:le,getLabelProps:ce,htmlProps:F}}function Pe(s){s.preventDefault(),s.stopPropagation()}var Ae={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},De={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Re=W({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),_e=W({from:{opacity:0},to:{opacity:1}}),je=W({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Fe=ae(function(l,t){const a=pe(),f={...a,...l},r=fe("Checkbox",f),b=me(l),{spacing:P="0.5rem",className:A,children:C,iconColor:g,iconSize:y,icon:D=u.jsx(xe,{}),isChecked:R,isDisabled:c=a==null?void 0:a.isDisabled,onChange:x,inputProps:M,...N}=b;let _=R;a!=null&&a.value&&b.value&&(_=a.value.includes(b.value));let j=x;a!=null&&a.onChange&&b.value&&(j=he(a.onChange,x));const{state:v,getInputProps:q,getCheckboxProps:F,getLabelProps:E,getRootProps:K}=Se({...N,isDisabled:c,isChecked:_,onChange:j}),L=Ce(v.isChecked),w=o.useMemo(()=>({animation:L?v.isIndeterminate?`${_e} 20ms linear, ${je} 200ms linear`:`${Re} 200ms linear`:void 0,fontSize:y,color:g,...r.icon}),[g,y,L,v.isIndeterminate,r.icon]),T=o.cloneElement(D,{__css:w,isIndeterminate:v.isIndeterminate,isChecked:v.isChecked});return u.jsxs(I.label,{__css:{...De,...r.container},className:ke("chakra-checkbox",A),...K(),children:[u.jsx("input",{className:"chakra-checkbox__input",...q(M,t)}),u.jsx(I.span,{__css:{...Ae,...r.control},className:"chakra-checkbox__control",...F(),children:T}),C&&u.jsx(I.span,{className:"chakra-checkbox__label",...E(),__css:{marginStart:P,...r.label},children:C})]})});Fe.displayName="Checkbox";var Ee=ae(function(l,t){const{templateAreas:a,gap:f,rowGap:r,columnGap:b,column:P,row:A,autoFlow:C,autoRows:g,templateRows:y,autoColumns:D,templateColumns:R,...c}=l,x={display:"grid",gridTemplateAreas:a,gridGap:f,gridRowGap:r,gridColumnGap:b,gridAutoColumns:D,gridColumn:P,gridRow:A,gridAutoFlow:C,gridAutoRows:g,gridTemplateRows:y,gridTemplateColumns:R};return u.jsx(I.div,{ref:t,__css:x,...c})});Ee.displayName="Grid";export{Fe as C,Ee as G,Se as u};
+import{b as de,r as o,j as u,g as I,d as $,e as z,y as ue,n,s as m,m as te,a0 as W,f as ae,l as fe,o as me,H as he,h as ke}from"./input.js";import{ag as be}from"./App-bXo9NVT7.js";import{t as ve}from"./index-pz0vT7Or.js";var[Ne,pe]=de({name:"CheckboxGroupContext",strict:!1});function Ce(s){const[l,t]=o.useState(s),[a,f]=o.useState(!1);return s!==l&&(f(!0),t(s)),a}function ge(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...s,children:u.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function ye(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...s,children:u.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function xe(s){const{isIndeterminate:l,isChecked:t,...a}=s,f=l?ye:ge;return t||l?u.jsx(I.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:u.jsx(f,{...a})}):null}var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function we(s,l=[]){const t=Object.assign({},s);for(const a of l)a in t&&delete t[a];return t}function Se(s={}){const l=be(s),{isDisabled:t,isReadOnly:a,isRequired:f,isInvalid:r,id:b,onBlur:P,onFocus:A,"aria-describedby":C}=l,{defaultChecked:g,isChecked:y,isFocusable:D,onChange:R,isIndeterminate:c,name:x,value:M,tabIndex:N=void 0,"aria-label":_,"aria-labelledby":j,"aria-invalid":v,...q}=s,F=we(q,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),E=$(R),K=$(P),L=$(A),[w,T]=o.useState(!1),[p,U]=o.useState(!1),[B,X]=o.useState(!1),[G,S]=o.useState(!1);o.useEffect(()=>ve(T),[]);const h=o.useRef(null),[J,ne]=o.useState(!0),[oe,H]=o.useState(!!g),V=y!==void 0,i=V?y:oe,Q=o.useCallback(e=>{if(a||t){e.preventDefault();return}V||H(i?e.target.checked:c?!0:e.target.checked),E==null||E(e)},[a,t,i,V,c,E]);z(()=>{h.current&&(h.current.indeterminate=!!c)},[c]),ue(()=>{t&&U(!1)},[t,U]),z(()=>{const e=h.current;if(!(e!=null&&e.form))return;const d=()=>{H(!!g)};return e.form.addEventListener("reset",d),()=>{var k;return(k=e.form)==null?void 0:k.removeEventListener("reset",d)}},[]);const Y=t&&!D,Z=o.useCallback(e=>{e.key===" "&&S(!0)},[S]),ee=o.useCallback(e=>{e.key===" "&&S(!1)},[S]);z(()=>{if(!h.current)return;h.current.checked!==i&&H(h.current.checked)},[h.current]);const se=o.useCallback((e={},d=null)=>{const k=O=>{p&&O.preventDefault(),S(!0)};return{...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a),"aria-hidden":!0,onMouseDown:m(e.onMouseDown,k),onMouseUp:m(e.onMouseUp,()=>S(!1)),onMouseEnter:m(e.onMouseEnter,()=>X(!0)),onMouseLeave:m(e.onMouseLeave,()=>X(!1))}},[G,i,t,p,w,B,c,r,a]),re=o.useCallback((e={},d=null)=>({...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(p),"data-focus-visible":n(p&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a)}),[G,i,t,p,w,B,c,r,a]),ie=o.useCallback((e={},d=null)=>({...F,...e,ref:te(d,k=>{k&&ne(k.tagName==="LABEL")}),onClick:m(e.onClick,()=>{var k;J||((k=h.current)==null||k.click(),requestAnimationFrame(()=>{var O;(O=h.current)==null||O.focus({preventScroll:!0})}))}),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[F,t,i,r,J]),le=o.useCallback((e={},d=null)=>({...e,ref:te(h,d),type:"checkbox",name:x,value:M,id:b,tabIndex:N,onChange:m(e.onChange,Q),onBlur:m(e.onBlur,K,()=>U(!1)),onFocus:m(e.onFocus,L,()=>U(!0)),onKeyDown:m(e.onKeyDown,Z),onKeyUp:m(e.onKeyUp,ee),required:f,checked:i,disabled:Y,readOnly:a,"aria-label":_,"aria-labelledby":j,"aria-invalid":v?!!v:r,"aria-describedby":C,"aria-disabled":t,style:Ie}),[x,M,b,Q,K,L,Z,ee,f,i,Y,a,_,j,v,r,C,t,N]),ce=o.useCallback((e={},d=null)=>({...e,ref:d,onMouseDown:m(e.onMouseDown,Pe),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[i,t,r]);return{state:{isInvalid:r,isFocused:p,isChecked:i,isActive:G,isHovered:B,isIndeterminate:c,isDisabled:t,isReadOnly:a,isRequired:f},getRootProps:ie,getCheckboxProps:se,getIndicatorProps:re,getInputProps:le,getLabelProps:ce,htmlProps:F}}function Pe(s){s.preventDefault(),s.stopPropagation()}var Ae={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},De={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Re=W({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),_e=W({from:{opacity:0},to:{opacity:1}}),je=W({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Fe=ae(function(l,t){const a=pe(),f={...a,...l},r=fe("Checkbox",f),b=me(l),{spacing:P="0.5rem",className:A,children:C,iconColor:g,iconSize:y,icon:D=u.jsx(xe,{}),isChecked:R,isDisabled:c=a==null?void 0:a.isDisabled,onChange:x,inputProps:M,...N}=b;let _=R;a!=null&&a.value&&b.value&&(_=a.value.includes(b.value));let j=x;a!=null&&a.onChange&&b.value&&(j=he(a.onChange,x));const{state:v,getInputProps:q,getCheckboxProps:F,getLabelProps:E,getRootProps:K}=Se({...N,isDisabled:c,isChecked:_,onChange:j}),L=Ce(v.isChecked),w=o.useMemo(()=>({animation:L?v.isIndeterminate?`${_e} 20ms linear, ${je} 200ms linear`:`${Re} 200ms linear`:void 0,fontSize:y,color:g,...r.icon}),[g,y,L,v.isIndeterminate,r.icon]),T=o.cloneElement(D,{__css:w,isIndeterminate:v.isIndeterminate,isChecked:v.isChecked});return u.jsxs(I.label,{__css:{...De,...r.container},className:ke("chakra-checkbox",A),...K(),children:[u.jsx("input",{className:"chakra-checkbox__input",...q(M,t)}),u.jsx(I.span,{__css:{...Ae,...r.control},className:"chakra-checkbox__control",...F(),children:T}),C&&u.jsx(I.span,{className:"chakra-checkbox__label",...E(),__css:{marginStart:P,...r.label},children:C})]})});Fe.displayName="Checkbox";var Ee=ae(function(l,t){const{templateAreas:a,gap:f,rowGap:r,columnGap:b,column:P,row:A,autoFlow:C,autoRows:g,templateRows:y,autoColumns:D,templateColumns:R,...c}=l,x={display:"grid",gridTemplateAreas:a,gridGap:f,gridRowGap:r,gridColumnGap:b,gridAutoColumns:D,gridColumn:P,gridRow:A,gridAutoFlow:C,gridAutoRows:g,gridTemplateRows:y,gridTemplateColumns:R};return u.jsx(I.div,{ref:t,__css:x,...c})});Ee.displayName="Grid";export{Fe as C,Ee as G,Se as u};
diff --git a/dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js b/dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js
similarity index 65%
rename from dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js
rename to dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js
index 88dbc32..4a3105a 100644
--- a/dist/workspace_web/chunk-NTCQBYKE-7yeghZmZ.js
+++ b/dist/workspace_web/chunk-NTCQBYKE-nDCdQPx1.js
@@ -1 +1 @@
-import{g as t}from"./App-YT7a4Gj6.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};
+import{g as t}from"./App-bXo9NVT7.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};
diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js
index cc2ca3f..a89aa4b 100644
--- a/dist/workspace_web/input.js
+++ b/dist/workspace_web/input.js
@@ -679,10 +679,10 @@ Error generating stack: `+i.message+`
}
${aB}
- `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-YT7a4Gj6.js").then(e=>e.aQ),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({zIndices:uB});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{Qh as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,Tp as U,xb as V,EB as W,os as X,Ar as Y,pB as Z,Xk as _,kB as a,vP as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Bl as e,pt as f,_e as g,Be as h,Mx as i,E as j,SB as k,Xb as l,If as m,_v as n,Iu as o,Bu as p,mB as q,S as r,Ei as s,Gf as t,IP as u,uw as v,bB as w,Kt as x,yg as y,uO as z};
+ `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-bXo9NVT7.js").then(e=>e.aQ),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({zIndices:uB});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{Qh as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,Tp as U,xb as V,EB as W,os as X,Ar as Y,pB as Z,Xk as _,kB as a,vP as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Bl as e,pt as f,_e as g,Be as h,Mx as i,E as j,SB as k,Xb as l,If as m,_v as n,Iu as o,Bu as p,mB as q,S as r,Ei as s,Gf as t,IP as u,uw as v,bB as w,Kt as x,yg as y,uO as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/App-YT7a4Gj6.js","workspace_web/assets/App-JXePnJiV.css"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/App-bXo9NVT7.js","workspace_web/assets/App-JXePnJiV.css"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file
diff --git a/service/file_sync_service.py b/service/file_sync_service.py
index 805b763..e671df4 100644
--- a/service/file_sync_service.py
+++ b/service/file_sync_service.py
@@ -176,7 +176,7 @@ def dedupe_workflow_ids():
@server.PromptServer.instance.routes.get('/workspace/deduplicate_workflow_ids')
async def deduplicate_workflow_ids(request):
- dedupe_workflow_ids()
+ await asyncio.to_thread(dedupe_workflow_ids)
return web.json_response(text="success", content_type='application/json')
@server.PromptServer.instance.routes.post('/workspace/get_workflow_file')
diff --git a/ui/src/RecentFilesDrawer/MoreActionMenu.tsx b/ui/src/RecentFilesDrawer/MoreActionMenu.tsx
index d8c8e01..c9f4e74 100644
--- a/ui/src/RecentFilesDrawer/MoreActionMenu.tsx
+++ b/ui/src/RecentFilesDrawer/MoreActionMenu.tsx
@@ -11,6 +11,7 @@ import {
import {
IconCopy,
IconDotsVertical,
+ IconExternalLink,
IconLock,
IconLockOpen,
IconUpload,
@@ -19,6 +20,7 @@ import AddTagToWorkflowPopover from "./AddTagToWorkflowPopover";
import { Workflow } from "../types/dbTypes";
import { mediaTable, workflowsTable } from "../db-tables/WorkspaceDB";
import { WorkspaceContext } from "../WorkspaceContext";
+import { openWorkflowInNewTab } from "../utils";
type Props = {
workflow: Workflow;
@@ -71,7 +73,7 @@ export default function MoreActionMenu({ workflow }: Props) {
return (
<>
-