>>=1,q<<=1,0<--F;);return q>>>1}function be(S,F,q){var G,L,Q=new Array(m+1),re=0;for(G=1;G<=m;G++)Q[G]=re=re+q[G-1]<<1;for(L=0;L<=F;L++){var ee=S[2*L+1];ee!==0&&(S[2*L]=me(Q[ee]++,ee))}}function le(S){var F;for(F=0;F>1;1<=q;q--)ye(S,Q,q);for(L=se;q=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ye(S,Q,1),G=S.heap[1],S.heap[--S.heap_max]=q,S.heap[--S.heap_max]=G,Q[2*L]=Q[2*q]+Q[2*G],S.depth[L]=(S.depth[q]>=S.depth[G]?S.depth[q]:S.depth[G])+1,Q[2*q+1]=Q[2*G+1]=L,S.heap[1]=L++,ye(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(he,Xe){var _n,it,xn,Pe,Qn,ao,pt=Xe.dyn_tree,qs=Xe.max_code,bl=Xe.stat_desc.static_tree,_l=Xe.stat_desc.has_stree,xl=Xe.stat_desc.extra_bits,Gs=Xe.stat_desc.extra_base,kn=Xe.stat_desc.max_length,er=0;for(Pe=0;Pe<=m;Pe++)he.bl_count[Pe]=0;for(pt[2*he.heap[he.heap_max]+1]=0,_n=he.heap_max+1;_n>=7;L>>=1)if(1&ve&&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&&F!==-1?O(S,F,q,G):S.strategy===4||Q===L?(J(S,2+(G?1:0),3),pe(S,W,D)):(J(S,4+(G?1:0),3),function(ee,se,ve,he){var Xe;for(J(ee,se-257,5),J(ee,ve-1,5),J(ee,he-4,4),Xe=0;Xe>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&F,S.pending_buf[S.l_buf+S.last_lit]=255&q,S.last_lit++,F===0?S.dyn_ltree[2*q]++:(S.matches++,F--,S.dyn_ltree[2*(w[q]+d+1)]++,S.dyn_dtree[2*B(F)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){J(S,2,3),Z(S,_,W),function(F){F.bi_valid===16?(te(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.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,u,c,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,E=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=E,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){g(x.data)},function(x){c.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(u=f.documentElement,function(x){var E=f.createElement("script");E.onreadystatechange=function(){g(x),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(x){setTimeout(g,0,x)},m.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var E=new Array(arguments.length-1),I=0;I"u"?s===void 0?this:s:self)}).call(this,typeof tr<"u"?tr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(wl);var jp=wl.exports;const Pp=Da(jp),Ap=async t=>{const e=`ComfyUI workspace workflows ${ll(Date.now())}`,n=new Pp,r=await(Y==null?void 0:Y.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await yh(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 Np({myWorkflowsDir:t}){return k.jsxs($e,{gap:3,children:[k.jsx(un,{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(H==null?void 0:H.listAll());Ap(e??[])},children:"👉 Download All My Workflows"})]})}const Fp=Ra.lazy(()=>Tt(()=>import("./RecentFilesDrawer-h9_pZtx6.js"),__vite__mapDeps([14,1,8,3,13,15,12,4]))),Rp=Ra.lazy(()=>Tt(()=>import("./GalleryModal-xU6CfB8I.js"),__vite__mapDeps([16,1,15,12,9,8,3,2])));function Tp(){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),[u,c]=P.useState(!1),d=P.useRef(null),{showDialog:p}=Fa(),[h,v]=P.useState(!1);P.useRef(!1);const f=Ma(),[m,y]=Dp(null),g=P.useCallback(async(w=!1)=>{var V,A;const T=H==null?void 0:H.curWorkflow;if(T){if(!w&&((V=H==null?void 0:H.curWorkflow)!=null&&V.saveLock)){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const X=JSON.stringify(we.graph.serialize());await Promise.all([H==null?void 0:H.updateFlow(T.id,{json:X}),Ge==null?void 0:Ge.create({workflowID:T.id,json:X,isAutoSave:!1})]),(A=Y==null?void 0:Y.settings)!=null&&A.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),c(!1)}},[]),_=async()=>{var T,V,A;if((T=Y==null?void 0:Y.settings)!=null&&T.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 X=(V=H==null?void 0:H.curWorkflow)==null?void 0:V.id;if(X==null)return;const $=(A=await(H==null?void 0:H.get(X)))==null?void 0:A.json;$?(H==null||H.updateCurWorkflow({...H.curWorkflow,json:$}),await we.loadGraphData(JSON.parse($)),c(!1)):alert("Error: No last saved version found")}},x=w=>{const T=(w==null?void 0:w.id)??null;if(H==null||H.updateCurWorkflow(w),l.current=T,a(T),e((w==null?void 0:w.name)??""),T==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Ca()){const V=cl(T);window.location.hash=V,document.title=w.name+" - ComfyUI"}else localStorage.setItem("curFlowID",T),document.title="ComfyUI - "+w.name;w&&(H==null||H.updateLastOpenedTime(w.id))},E=async()=>{var V,A;localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Dh()}catch(X){console.error("error loading db",X)}s(!1);const w=Ca();if(w==null){const X=localStorage.getItem("workflow");if(X){const ne=(A=(V=JSON.parse(X).extra)==null?void 0:V[We])==null?void 0:A.id;if(ne){const z=await(H==null?void 0:H.get(ne));z&&x(z),z&&z.json!=X&&c(!0)}}}else I(w);Ee("/workspace/deduplicate_workflow_ids"),!await(Y==null?void 0:Y.getSetting("twoWaySync"))&&ie.cache.get(_o).then(async X=>{if((X==null?void 0:X.value)!=="true"){if(await ie.workflows.count()==0){await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await ie.cache.put({id:_o,value:"true"});return}const ne=await(Y==null?void 0:Y.getSetting("myWorkflowsDir"));p(k.jsx(Np,{myWorkflowsDir:ne??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await(Y==null?void 0:Y.getSetting("twoWaySync"))&&(ie.cache.put({id:_o,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},I=async(w,T)=>{if(we.graph==null)return;const V=await(H==null?void 0:H.get(w));if(V==null){alert("Error: Workflow not found! id: "+w),x(null);return}const A=T?await(ge==null?void 0:ge.get(T)):null;we.ui.dialog.close(),A?(y(A),x({...V,json:A.json}),we.loadGraphData(JSON.parse(A.json))):(x(V),y(null),we.loadGraphData(JSON.parse(V.json))),r("root"),u&&c(!1)},C=async(w,T,V=!1)=>{var A;if(w===null){x(null),we.graph.clear();return}if(!u||V||(A=Y==null?void 0:Y.settings)!=null&&A.autoSave||(H==null?void 0:H.curWorkflow)==null){I(w,T);return}N(w)},N=async w=>{var V;const T=[w?{label:"Open in new tab",icon:k.jsx(pl,{}),onClick:()=>{hh(w)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await g(),w&&I(w)}}];T.push({label:"Discard",colorScheme:"red",onClick:async()=>{w&&I(w)}}),p(`Please save or discard your changes to "${(V=H==null?void 0:H.curWorkflow)==null?void 0:V.name}" before leaving, or your changes will be lost.`,T)},j=async w=>{const T=(w==null?void 0:w.json)??JSON.stringify(ul),V=await(H==null?void 0:H.createFlow({json:T,name:w==null?void 0:w.name}));V&&await C(V.id),r("root")},R=async(w,T=!1)=>{const V=w.split("/").pop()??w;T?g():j({name:V});const A=await fetch(fh(w)),X=await A.blob(),$=new File([X],V,{type:A.headers.get("Content-Type")||""});await we.handleFile($),r("root")},W=async(w,T)=>{const V=await(H==null?void 0:H.get(w));if(V==null)return;const A=await(H==null?void 0:H.createFlow({json:V.json,name:T||V.name,parentFolderID:V.parentFolderID,tags:V.tags}));A&&await C(A.id)},D=P.useCallback(w=>{if(l.current==null)return;let T=w.filename;w.subfolder!=null&&w.subfolder!==""&&(T=w.subfolder+"/"+T),qt==null||qt.create({workflowID:l.current,localPath:T})},[]),M=P.useCallback(()=>{r("root")},[]);return P.useEffect(()=>{E(),v(!0);const w=T=>{var V,A,X,$,ne,z;(X=(A=(V=T.detail)==null?void 0:V.output)==null?void 0:A.images)==null||X.forEach(B=>{B.type==="output"&&D(B)}),(z=(ne=($=T.detail)==null?void 0:$.output)==null?void 0:ne.gifs)==null||z.forEach(B=>{B.type==="output"&&D(B)})};return Or.addEventListener("executed",w),()=>{window.removeEventListener("executed",w)}},[]),o?null:k.jsx(at.Provider,{value:{curFlowID:i,onDuplicateWorkflow:W,loadWorkflowID:C,discardUnsavedChanges:_,saveCurWorkflow:g,isDirty:u,setIsDirty:c,loadNewWorkflow:j,loadFilePath:R,setRoute:r,route:n,curVersion:m,setCurVersion:y,setCurFlowIDAndName:x},children:k.jsx("div",{ref:d,className:"workspace_manager",children:k.jsxs(Aa,{containerRef:d,children:[k.jsxs(jt,{style:{position:"absolute",top:0,right:0,left:0},zIndex:mh,draggable:!1,children:[k.jsx(Cp,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&k.jsx(P.Suspense,{children:k.jsx(Fp,{onClose:M,onClickNewFlow:()=>{j(),r("root")}})}),n==="gallery"&&k.jsx(P.Suspense,{children:k.jsx(Rp,{onclose:()=>r("root")})})]}),k.jsx(Sp,{})]})})})}const dm=Object.freeze(Object.defineProperty({__proto__:null,default:Tp},Symbol.toStringTag,{value:"Module"}));export{hh as $,zh as A,jt as B,Gp as C,tp as D,ah as E,Ut as F,Wh as G,ot as H,cn as I,bh as J,Le as K,Jr as L,yi as M,Qr as N,Xr as O,Vh as P,Gh as Q,rm as R,Ed as S,mn as T,ul as U,Qp as V,xr as W,Oh as X,qp as Y,at as Z,pl as _,Wp as a,ml as a0,Ee as a1,qt as a2,ll as a3,ut as a4,we as a5,sc as a6,mh as a7,Kp as a8,kr as a9,vi as aA,xi as aB,bi as aC,sm as aD,Dp as aE,Sh as aF,em as aG,om as aH,$s as aI,gs as aJ,lm as aK,Qa as aL,up as aM,ge as aN,im as aO,cm as aP,mp as aQ,um as aR,oc as aS,dm as aT,Zp as aa,La as ab,hc as ac,Jp as ad,Wa as ae,Ch as af,un as ag,on as ah,pc as ai,We as aj,Xp as ak,Yp as al,Ge as am,Kl as an,Zn as ao,Ps as ap,ie as aq,am as ar,uf as as,tm as at,nm as au,$p as av,Or as aw,Hp as ax,Nc as ay,gi as az,zp as b,Lp as c,Ae as d,Jh as e,Ma as f,$e as g,wt as h,kt as i,gn as j,Y as k,Np as l,Fc as m,cf as n,Up as o,Vp as p,Oo as q,Ds as r,js as s,Cr as t,to as u,Ct as v,Lh as w,H as x,ep as y,Ap as z};
-function __vite__mapDeps(indexes) {
- if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-3XWt4eF0.js","workspace_web/input.js","workspace_web/chunk-VTV6N5LE-_EaL4yE7.js","workspace_web/chunk-7D6N5TE5-lFR77IBa.js","workspace_web/IconCopy-D2k-9fMf.js","workspace_web/AppIsDirtyEventListener-z5bVS2B2.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-vr3vytmQ.js","workspace_web/chunk-JARCRF6W-OjDz07lE.js","workspace_web/chunk-3RSXBRAN-LXNJ9qB5.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-wRJMVnPo.js","workspace_web/IconSearch-3Gq-3maw.js","workspace_web/chunk-NTCQBYKE-a6jE7X_b.js","workspace_web/RecentFilesDrawer-h9_pZtx6.js","workspace_web/MediaPreview-gKBl9R3H.js","workspace_web/GalleryModal-xU6CfB8I.js"]
- }
- return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
-}
\ No newline at end of file
diff --git a/dist/workspace_web/AppIsDirtyEventListener-z5bVS2B2.js b/dist/workspace_web/AppIsDirtyEventListener-4QIATPDH.js
similarity index 68%
rename from dist/workspace_web/AppIsDirtyEventListener-z5bVS2B2.js
rename to dist/workspace_web/AppIsDirtyEventListener-4QIATPDH.js
index bae697d..8b95b9e 100644
--- a/dist/workspace_web/AppIsDirtyEventListener-z5bVS2B2.js
+++ b/dist/workspace_web/AppIsDirtyEventListener-4QIATPDH.js
@@ -1 +1 @@
-import{r as u,j as E}from"./input.js";import{Z as x,a5 as r,aj as C,x as a,i as W,T as j,E as d,ak as A,al as L,k as h,am as R}from"./App-eQybp91e.js";import{u as O}from"./useDebounceFn-ld478fd0.js";function M(){const{isDirty:p,setIsDirty:g,setRoute:v,saveCurWorkflow:T,setCurFlowIDAndName:b}=u.useContext(x),w=u.useRef(p),[S,D]=u.useState(!1),k=u.useRef(null);u.useEffect(()=>{w.current=p},[p]),u.useEffect(()=>{var n,i;const c=e=>{var s;if(document.visibilityState==="hidden")return;const t=L(e);if(t)switch(t===d.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(A,{detail:{shortcutType:t}})),t){case d.SAVE:T();break;case d.SAVE_AS:v("saveAsModal");break;case d.openSpotlightSearch:v("spotlightSearch");break}else(s=e.target)!=null&&s.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,s,l,f;const e=(s=(t=r.graph.extra)==null?void 0:t[C])==null?void 0:s.id;(e==null||e!=((f=(l=a)==null?void 0:l.curWorkflow)==null?void 0:f.id))&&b(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),(i=(n=h)==null?void 0:n.settings)!=null&&i.autoSave&&h.settings.autoSaveDuration&&(k.current=setInterval(()=>{_()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",c),k.current&&clearInterval(k.current)}},[]);const _=async()=>{var o,n,i,e,t,s;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||!((e=(i=a)==null?void 0:i.curWorkflow)!=null&&e.id)||!w.current)return;const c=JSON.stringify(r.graph.serialize());await((t=a)==null?void 0:t.updateFlow(a.curWorkflow.id,{json:c})),(s=R)==null||s.create({workflowID:a.curWorkflow.id,isAutoSave:!0,json:c}),g(!1)},I=async()=>{var o,n,i,e,t,s,l,f,y;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||w.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((e=(i=a)==null?void 0:i.curWorkflow)==null?void 0:e.json)&&(g(!0),(s=(t=h)==null?void 0:t.settings)!=null&&s.autoSave&&((f=(l=a)==null?void 0:l.curWorkflow)!=null&&f.id)&&!S&&(await((y=a)==null?void 0:y.latestVersionCheck())||D(!0)))},[m,N]=O(I,900);return S?E.jsx(W,{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:E.jsx(j,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{M as default};
+import{r as u,j as E}from"./input.js";import{X as x,a3 as r,af as C,x as a,i as W,T as A,E as d,ag as L,ah as R,k as h,ai as j}from"./App-Pi18TWng.js";import{u as O}from"./useDebounceFn-ld478fd0.js";function M(){const{isDirty:p,setIsDirty:k,setRoute:v,saveCurWorkflow:T,setCurFlowIDAndName:b}=u.useContext(x),w=u.useRef(p),[S,D]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{w.current=p},[p]),u.useEffect(()=>{var n,i;const c=e=>{var s;if(document.visibilityState==="hidden")return;const t=R(e);if(t)switch(t===d.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(L,{detail:{shortcutType:t}})),t){case d.SAVE:T();break;case d.SAVE_AS:v("saveAsModal");break;case d.openSpotlightSearch:v("spotlightSearch");break}else(s=e.target)!=null&&s.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,s,l,f;const e=(s=(t=r.graph.extra)==null?void 0:t[C])==null?void 0:s.id;(e==null||e!=((f=(l=a)==null?void 0:l.curWorkflow)==null?void 0:f.id))&&b(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),(i=(n=h)==null?void 0:n.settings)!=null&&i.autoSave&&h.settings.autoSaveDuration&&(g.current=setInterval(()=>{_()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",c),g.current&&clearInterval(g.current)}},[]);const _=async()=>{var o,n,i,e,t,s;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||!((e=(i=a)==null?void 0:i.curWorkflow)!=null&&e.id)||!w.current)return;const c=JSON.stringify(r.graph.serialize());await((t=a)==null?void 0:t.updateFlow(a.curWorkflow.id,{json:c})),(s=j)==null||s.create({workflowID:a.curWorkflow.id,isAutoSave:!0,json:c}),k(!1)},I=async()=>{var o,n,i,e,t,s,l,f,y;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||w.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((e=(i=a)==null?void 0:i.curWorkflow)==null?void 0:e.json)&&(k(!0),(s=(t=h)==null?void 0:t.settings)!=null&&s.autoSave&&((f=(l=a)==null?void 0:l.curWorkflow)!=null&&f.id)&&!S&&(await((y=a)==null?void 0:y.latestVersionCheck())||D(!0)))},[m,N]=O(I,900);return S?E.jsx(W,{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:E.jsx(A,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{M as default};
diff --git a/dist/workspace_web/GalleryModal--OOrrwTO.js b/dist/workspace_web/GalleryModal--OOrrwTO.js
new file mode 100644
index 0000000..ae099d4
--- /dev/null
+++ b/dist/workspace_web/GalleryModal--OOrrwTO.js
@@ -0,0 +1 @@
+import{r as d,d as Se,x as Ht,m as be,b as it,f as O,k as Kt,o as ct,E as Wt,j as r,g as L,n as Yt,e as Xt,V as ut,h as dt,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 Re,F as m,ab as rn,I as M,j as on,g as Ee,B as ht,h as W,X as oe,a3 as tt,x as R,H as Y,i as A,w as ft,a1 as xt,e as pt,a0 as F,ac as an,y as ln}from"./App-Pi18TWng.js";import{c as je,p as cn,r as nt,v as st,I as un,i as dn,b as hn,d as fn,g as xn,N as pn,a as gn,e as mn,f as vn,h as yn,M as gt,u as wn,S as Sn}from"./MediaPreview-AxH1rOBH.js";import{I as bn}from"./chunk-7D6N5TE5-ZfhYDM9i.js";import{S as jn}from"./chunk-3RSXBRAN-1feEpIXZ.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-sDjzfEGl.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-K9rVd8eY.js";import"./IconSearch-xcUfhAk-.js";const mt=1/60*1e3,Pn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Pn()),mt);function Cn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,p=!1)=>{const f=p&&o,v=f?t:s;return u&&l.add(i),v.indexOf(i)===-1&&(v.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]=Cn(()=>X=!0),e),{}),Tn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Mn(),s.schedule(n,o,a)),e},{}),En=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(B),e),{});const Nn=e=>ae[e].process(B),yt=e=>{X=!1,B.delta=Me?mt:Math.max(Math.min(e-B.timestamp,In),1),B.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>B;var V=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 _n(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const E=(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]}% - ${E.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${E.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,p=[0,o?100-s[0]:s[0]],f=u?p:s;let v=f[0];!u&&o&&(v=100-v);const g=Math.abs(f[f.length-1]-f[0]),I={...i,...Q({orientation:t,vertical:o?{height:`${g}%`,top:`${v}%`}:{height:`${g}%`,bottom:`${v}%`},horizontal:o?{width:`${g}%`,right:`${v}%`}:{width:`${g}%`,left:`${v}%`}})};return{trackStyle:i,innerTrackStyle:I,rootStyle:c,getThumbStyle:a}}function Dn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function zn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Rn(e){const t=Fn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function An(e){return wt(e)&&e.touches.length>1}function Fn(e){var t;return(t=e.view)!=null?t:window}function $n(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Vn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?$n(e,t):Vn(e,t)}function Bn(e){return t=>{const s=Rn(t);(!s||s&&t.button===0)&&e(t)}}function On(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Bn(s):s}function ne(e,t,s,n){return zn(e,t,On(s,t==="pointerdown"),n)}var Ln=Object.defineProperty,Gn=(e,t,s)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=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=Yn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:p}=ot();this.history.push({...c.point,timestamp:p});const{onStart:f,onMove:v}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),v==null||v(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:p,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!p||!this.startEvent)&&(p==null||p(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,An(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Wn(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),En.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Kn(t,.1)}}var Hn=e=>e*1e3;function Kn(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>Hn(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 Wn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Yn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Xn(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),p=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,v){u.current=null,o==null||o(f,v)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(p.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function v(g){u.current=new Un(g,p.current,c)}return ne(f,"pointerdown",v)},[e,i,p,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Zn(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 qn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Jn(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 qn(()=>{const l=e(),c=l.map((i,u)=>Zn(i,p=>{n(f=>[...f.slice(0,u),p,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Jn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function es(e){return typeof e=="object"&&e!==null&&"current"in e}function ts(e){const[t]=Qn({observeMutation:!1,getNodes(){return[es(e)?e.current:e]}});return t}function ns(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:p,isDisabled:f,isReadOnly:v,onChangeStart:g,onChangeEnd:I,step:y=1,getAriaValueText:w,"aria-valuetext":E,"aria-label":$,"aria-labelledby":b,name:_,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(g),G=Se(I),Ve=Se(w),C=Dn({isReversed:c,direction:i,orientation:u}),[_t,de]=nn({value:a,defaultValue:l??rs(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Oe]=d.useState(!1),xe=!(f||v),pe=(n-s)/10,U=y||(n-s)/100,S=je(_t,s,n),Dt=n-S+s,Le=st(C?Dt:S,s,n),J=u==="vertical",j=bt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),zt=d.useId(),Ue=p??zt,[He,Ke]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var x,H;if(!ge.current)return;const k=j.current;k.eventSource="pointer";const N=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(H=(x=h.touches)==null?void 0:x[0])!=null?H:h,Gt=J?N.bottom-Lt:ye-N.left,Ut=J?N.height:N.width;let we=Gt/Ut;C&&(we=1-we);let K=cn(we,k.min,k.max);return k.step&&(K=parseFloat(nt(K,k.min,k.step))),K=je(K,k.min,k.max),K},[J,C,j]),D=d.useCallback(h=>{const x=j.current;x.isInteractive&&(h=parseFloat(nt(h,x.min,U)),h=je(h,x.min,x.max),de(h))},[U,de,j]),z=d.useMemo(()=>({stepUp(h=U){const x=C?S-h:S+h;D(x)},stepDown(h=U){const x=C?S+h:S-h;D(x)},reset(){D(l||0)},stepTo(h){D(h)}}),[D,C,S,U,l]),We=d.useCallback(h=>{const x=j.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>D(x.min),End:()=>D(x.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),x.eventSource="keyboard")},[z,D,pe,j]),Ye=(t=Ve==null?void 0:Ve(S))!=null?t:E,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=j.current,x=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[x],thumbPercents:[Le]})},[C,ve,Le,j]),Qe=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var x;return(x=me.current)==null?void 0:x.focus()})},[j]);Ht(()=>{const h=j.current;Qe(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function et(h){const x=Rt(h);x!=null&&x!==j.current.value&&de(x)}Xn(Ge,{onPanSessionStart(h){const x=j.current;x.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(x.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Be(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&et(h)}});const At=d.useCallback((h={},x=null)=>({...h,...Fe,ref:be(x,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":V(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},x=null)=>({...h,ref:be(x,ge),id:Ke,"data-disabled":V(f),style:{...h.style,...qe}}),[f,Ke,qe]),$t=d.useCallback((h={},x=null)=>({...h,ref:x,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},x=null)=>({...h,ref:be(x,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":V(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(v),"aria-label":$,"aria-labelledby":$?void 0:b,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,We),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,S,u,f,v,$,b,Xe,We]),Bt=d.useCallback((h,x=null)=>{const H=!(h.valuen),k=S>=h.value,N=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-N}%`:`${N}%`},horizontal:{left:C?`${100-N}%`:`${N}%`}})};return{...h,ref:x,role:"presentation","aria-hidden":!0,"data-disabled":V(f),"data-invalid":V(!H),"data-highlighted":V(k),style:{...h.style,...ye}}},[f,C,n,s,u,S]),Ot=d.useCallback((h={},x=null)=>({...h,ref:x,type:"hidden",value:S,name:_}),[_,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Ot}}function ss(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function rs(e,t){return t"}),[as,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=O((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Kt("Slider",n),a=ct(n),{direction:l}=Wt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),p=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{value:o,children:r.jsxs(L.div,{...p,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=O((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(L.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=O((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(L.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=O((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(L.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ls=O((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(L.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});ls.displayName="SliderMark";function is(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var cs=["h","minH","height","minHeight"],It=O((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?is(s,cs):s;return r.jsx(L.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var us=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("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"}]]),Et=Re("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 ds=({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(m,{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(bn,{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(us,{}),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(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null};function hs(e){const t=e.split(".").pop();return fetch(e).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.blob()}).then(async s=>{const n=e.split("/").pop()??"",o=new File([s],n);if(dn(e))return hn(o);if(t==="webp")return fn(o);const a=await xn(o),l=JSON.parse(a==null?void 0:a.prompt),c=JSON.parse(a==null?void 0:a.workflow);return{prompt:l,workflow:c}})}const fs=({inputItem:e})=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(on,{value:e.inputValue,onChange:t=>{}})]}),xs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(pn,{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(gn,{}),r.jsxs(mn,{children:[r.jsx(vn,{}),r.jsx(yn,{})]})]})]}),r.jsx(m,{children:r.jsxs(jt,{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(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ps=e=>{var s;const{inputItem:t}=e;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(jn,{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}`))})]})},gs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsx(m,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const ms=e=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(m,{children:"No Support"})]}),vs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{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(){}}),ys={[P.Input]:fs,[P.InputSlider]:xs,[P.Select]:ps,[P.Textarea]:gs,[P.Checkbox]:vs,NoSupport:ms},ws=LiteGraph.registered_node_types;function Ss(e,t){var o,a,l,c,i;const s=(o=ws[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:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.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:P.Select}:{type:P.NoSupport}}const De=({inputItem:e})=>{const t=Ss(e.classType,e.inputName),[s,n]=d.useState(!1),o=ys[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(m,{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(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function bs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(m,{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(De,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function js(){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(De,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(ks,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(m,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(De,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function ks({title:e,children:t}){return r.jsxs(ht,{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=[],ze=new Set;function Nt(e,t){if(!ze.has(e.nodeID))return ze.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(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 Ps(e){se=[],ze=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))Nt(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 Cs({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?hs(`/workspace/view_media?filename=${e.localPath}`).then(g=>{a(g.prompt)}):tt.graphToPrompt(tt.graph).then(g=>{a(g.output)})},[e]),d.useEffect(()=>{if(!o)return;const g=Ps(o);s(g)},[o]);const[p,f]=d.useState([]);d.useEffect(()=>{(async()=>{var g,I;if(n){const y=(I=await((g=R)==null?void 0:g.get(n)))==null?void 0:I.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const v=g=>{var I,y;if(re(p,{name:g.name,promptKey:g==null?void 0:g.promptKey,classType:(g==null?void 0:g.class_type)??""})){const w=p.filter(E=>E.name!==g.name||E.promptKey!==g.promptKey);f(w),n&&((I=R)==null||I.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...p,g];f(w),n&&((y=R)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:p,showNodeName:i,calcInputList:t,updateTopField:v},children:r.jsxs(m,{direction:"column",align:"stretch",gap:5,children:[r.jsx(bs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:l,onChange:g=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:i,onChange:g=>u(!i)})]}),l&&r.jsx(js,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Is=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=R)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(m,{flexWrap:"wrap",gap:3,children:[r.jsx(m,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(A,{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(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(m,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(A,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(pt,{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=F)==null?void 0:u.delete(e.id)),n(p=>p.filter(f=>f.id!==e.id)))}})}),((c=(l=R)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(A,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=R)==null?void 0:i.updateMetaInfo(R.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{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},Ts=({media:e})=>r.jsxs(m,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(Is,{media:e}),r.jsx(Cs,{media:e??null})]}),Te=120;function Es({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(m,{gap:3,h:"100%",children:[r.jsxs(kn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(ds,{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(m,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{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(gt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=F)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ts,{media:t??void 0})]})}const Ns=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(gt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=F)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(A,{label:xt(e.createTime,!0),children:i}),r.jsx(A,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{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(A,{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(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(A,{label:"Remove image from gallery",children:r.jsx(M,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var p;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((p=F)==null?void 0:p.delete(e.id))}})})]})]})},Ms=Ns;function _s({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=F)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=F)==null||i.filter(u=>{var p;return((p=u.workflowJSON)==null?void 0:p.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(Ms,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Gs({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([]),[p,f]=d.useState(),[v,g]=d.useState(""),I=wn(v,300),[y,w]=d.useState(!1),E=async()=>{var _;if(t==null)return;const b=await((_=F)==null?void 0:_.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;E(),t&&((b=R)==null||b.get(t).then(_=>{_&&n(_.name)}))},[]),t==null)return null;const $=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:p??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(an,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(Sn,{searchValue:v,onUpdateSearchValue:b=>{g(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:$,onChange:()=>{a($?[]:i.map(b=>b.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(M,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(_s,{searchQuery:I}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default};
diff --git a/dist/workspace_web/GalleryModal-xU6CfB8I.js b/dist/workspace_web/GalleryModal-xU6CfB8I.js
deleted file mode 100644
index 54fdc4a..0000000
--- a/dist/workspace_web/GalleryModal-xU6CfB8I.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as d,d as Se,y as Ht,m as be,b as it,f as L,l as Kt,o as ct,E as Wt,j as r,g as O,p as Yt,h as Xt,W as ut,i as dt,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{ab as nn,ac as sn,d as Re,F as p,ad as rn,ae as on,I as M,j as an,g as Ee,B as ht,h as W,Z as oe,af as ln,a5 as tt,x as R,H as Y,i as A,w as ft,a3 as xt,e as gt,a2 as F,ag as cn,y as un}from"./App-eQybp91e.js";import{c as je,p as dn,r as nt,v as st,I as hn,N as fn,a as xn,b as gn,d as mn,e as pn,M as mt,u as vn,S as yn}from"./MediaPreview-gKBl9R3H.js";import{S as wn}from"./chunk-3RSXBRAN-LXNJ9qB5.js";import{C as Ae,G as Sn}from"./chunk-JARCRF6W-OjDz07lE.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-_EaL4yE7.js";import"./IconSearch-3Gq-3maw.js";import"./chunk-7D6N5TE5-lFR77IBa.js";const pt=1/60*1e3,bn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(bn()),pt);function jn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,g=!1)=>{const f=g&&o,v=f?t:s;return u&&l.add(i),v.indexOf(i)===-1&&(v.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]=jn(()=>X=!0),e),{}),Pn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Tn(),s.schedule(n,o,a)),e},{}),Cn=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(B),e),{});const In=e=>ae[e].process(B),yt=e=>{X=!1,B.delta=Me?pt:Math.max(Math.min(e-B.timestamp,kn),1),B.timestamp=e,De=!0,Z.forEach(In),De=!1,X&&(Me=!1,vt(yt))},Tn=()=>{X=!0,Me=!0,De||vt(yt)},ot=()=>B;var V=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 En(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var w;const E=(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]}% - ${E.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${E.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,g=[0,o?100-s[0]:s[0]],f=u?g:s;let v=f[0];!u&&o&&(v=100-v);const m=Math.abs(f[f.length-1]-f[0]),I={...i,...Q({orientation:t,vertical:o?{height:`${m}%`,top:`${v}%`}:{height:`${m}%`,bottom:`${v}%`},horizontal:o?{width:`${m}%`,right:`${v}%`}:{width:`${m}%`,left:`${v}%`}})};return{trackStyle:i,innerTrackStyle:I,rootStyle:c,getThumbStyle:a}}function Nn(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=zn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function _n(e){return wt(e)&&e.touches.length>1}function zn(e){var t;return(t=e.view)!=null?t:window}function Rn(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function An(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?Rn(e,t):An(e,t)}function Fn(e){return t=>{const s=Dn(t);(!s||s&&t.button===0)&&e(t)}}function $n(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Fn(s):s}function ne(e,t,s,n){return Mn(e,t,$n(s,t==="pointerdown"),n)}var Vn=Object.defineProperty,Bn=(e,t,s)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t,s)=>(Bn(e,typeof t!="symbol"?t+"":t,s),s),Ln=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=Hn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:v}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),v==null||v(this.lastEvent,c)}),T(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Pn.update(this.updatePoint,!0)}),T(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:g,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!g||!this.startEvent)&&(g==null||g(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,_n(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Un(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),Cn.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Gn(t,.1)}}var On=e=>e*1e3;function Gn(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>On(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 Un(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Hn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Kn(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),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,v){u.current=null,o==null||o(f,v)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function v(m){u.current=new Ln(m,g.current,c)}return ne(f,"pointerdown",v)},[e,i,g,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Wn(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 Yn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Xn(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 Zn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return Yn(()=>{const l=e(),c=l.map((i,u)=>Wn(i,g=>{n(f=>[...f.slice(0,u),g,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Xn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function qn(e){return typeof e=="object"&&e!==null&&"current"in e}function Jn(e){const[t]=Zn({observeMutation:!1,getNodes(){return[qn(e)?e.current:e]}});return t}function Qn(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:g,isDisabled:f,isReadOnly:v,onChangeStart:m,onChangeEnd:I,step:y=1,getAriaValueText:w,"aria-valuetext":E,"aria-label":$,"aria-labelledby":b,name:D,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(m),G=Se(I),Ve=Se(w),C=Nn({isReversed:c,direction:i,orientation:u}),[Dt,de]=nn({value:a,defaultValue:l??ts(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Le]=d.useState(!1),xe=!(f||v),ge=(n-s)/10,U=y||(n-s)/100,S=je(Dt,s,n),_t=n-S+s,Oe=st(C?_t:S,s,n),J=u==="vertical",j=bt({min:s,max:n,step:y,isDisabled:f,value:S,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),me=d.useRef(null),pe=d.useRef(null),Ge=d.useRef(null),zt=d.useId(),Ue=g??zt,[He,Ke]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var x,H;if(!me.current)return;const k=j.current;k.eventSource="pointer";const N=me.current.getBoundingClientRect(),{clientX:ye,clientY:Ot}=(H=(x=h.touches)==null?void 0:x[0])!=null?H:h,Gt=J?N.bottom-Ot:ye-N.left,Ut=J?N.height:N.width;let we=Gt/Ut;C&&(we=1-we);let K=dn(we,k.min,k.max);return k.step&&(K=parseFloat(nt(K,k.min,k.step))),K=je(K,k.min,k.max),K},[J,C,j]),_=d.useCallback(h=>{const x=j.current;x.isInteractive&&(h=parseFloat(nt(h,x.min,U)),h=je(h,x.min,x.max),de(h))},[U,de,j]),z=d.useMemo(()=>({stepUp(h=U){const x=C?S-h:S+h;_(x)},stepDown(h=U){const x=C?S+h:S-h;_(x)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,S,U,l]),We=d.useCallback(h=>{const x=j.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(ge),PageDown:()=>z.stepDown(ge),Home:()=>_(x.min),End:()=>_(x.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),x.eventSource="keyboard")},[z,_,ge,j]),Ye=(t=Ve==null?void 0:Ve(S))!=null?t:E,ve=Jn(pe),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=j.current,x=ve??{width:0,height:0};return En({isReversed:C,orientation:h.orientation,thumbRects:[x],thumbPercents:[Oe]})},[C,ve,Oe,j]),Qe=d.useCallback(()=>{j.current.focusThumbOnChange&&setTimeout(()=>{var x;return(x=pe.current)==null?void 0:x.focus()})},[j]);Ht(()=>{const h=j.current;Qe(),h.eventSource==="keyboard"&&(G==null||G(h.value))},[S,G]);function et(h){const x=Rt(h);x!=null&&x!==j.current.value&&de(x)}Kn(Ge,{onPanSessionStart(h){const x=j.current;x.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(x.value))},onPanSessionEnd(){const h=j.current;h.isInteractive&&(Be(!1),G==null||G(h.value))},onPan(h){j.current.isInteractive&&et(h)}});const At=d.useCallback((h={},x=null)=>({...h,...Fe,ref:be(x,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":V(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},x=null)=>({...h,ref:be(x,me),id:Ke,"data-disabled":V(f),style:{...h.style,...qe}}),[f,Ke,qe]),$t=d.useCallback((h={},x=null)=>({...h,ref:x,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},x=null)=>({...h,ref:be(x,pe),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":V(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":S,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(v),"aria-label":$,"aria-labelledby":$?void 0:b,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,We),onFocus:Pe(h.onFocus,()=>Le(!0)),onBlur:Pe(h.onBlur,()=>Le(!1))}),[xe,He,he,Ye,s,n,S,u,f,v,$,b,Xe,We]),Bt=d.useCallback((h,x=null)=>{const H=!(h.valuen),k=S>=h.value,N=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...es({orientation:u,vertical:{bottom:C?`${100-N}%`:`${N}%`},horizontal:{left:C?`${100-N}%`:`${N}%`}})};return{...h,ref:x,role:"presentation","aria-hidden":!0,"data-disabled":V(f),"data-invalid":V(!H),"data-highlighted":V(k),style:{...h.style,...ye}}},[f,C,n,s,u,S]),Lt=d.useCallback((h={},x=null)=>({...h,ref:x,type:"hidden",value:S,name:D}),[D,S]);return{state:{value:S,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Lt}}function es(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function ts(e,t){return t"}),[ss,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=L((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Kt("Slider",n),a=ct(n),{direction:l}=Wt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=Qn(a),g=i(),f=c({},t);return r.jsx(ns,{value:u,children:r.jsx(ss,{value:o,children:r.jsxs(O.div,{...g,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=L((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=L((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=L((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var rs=L((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});rs.displayName="SliderMark";function os(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var as=["h","minH","height","minHeight"],It=L((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?os(s,as):s;return r.jsx(O.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var ls=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("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"}]]),Et=Re("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 is=({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(p,{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(ls,{}),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},cs=({inputItem:e})=>r.jsxs(p,{gap:2,children:[r.jsx(p,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(an,{value:e.inputValue,onChange:t=>{}})]}),us=e=>{const t=e.inputItem;return r.jsxs(p,{gap:1,direction:"column",children:[r.jsxs(p,{gap:2,children:[r.jsx(p,{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(gn,{children:[r.jsx(mn,{}),r.jsx(pn,{})]})]})]}),r.jsx(p,{children:r.jsxs(jt,{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(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ds=e=>{var s;const{inputItem:t}=e;return r.jsxs(p,{gap:2,children:[r.jsx(p,{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}`))})]})},hs=e=>{const t=e.inputItem;return r.jsxs(p,{gap:1,direction:"column",children:[r.jsx(p,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const fs=e=>r.jsxs(p,{gap:2,children:[r.jsx(p,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(p,{children:"No Support"})]}),xs=e=>{const t=e.inputItem;return r.jsxs(p,{gap:2,children:[r.jsx(p,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{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(){}}),gs={[P.Input]:cs,[P.InputSlider]:us,[P.Select]:ds,[P.Textarea]:hs,[P.Checkbox]:xs,NoSupport:fs},ms=LiteGraph.registered_node_types;function ps(e,t){var o,a,l,c,i;const s=(o=ms[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:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.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:P.Select}:{type:P.NoSupport}}const _e=({inputItem:e})=>{const t=ps(e.classType,e.inputName),[s,n]=d.useState(!1),o=gs[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(p,{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(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function vs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(p,{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(_e,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function ys(){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(_e,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(ws,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(p,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(_e,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function ws({title:e,children:t}){return r.jsxs(ht,{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=[],ze=new Set;function Nt(e,t){if(!ze.has(e.nodeID))return ze.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(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 Ss(e){se=[],ze=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))Nt(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 bs({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(m=>{a(m.prompt)}):tt.graphToPrompt(tt.graph).then(m=>{a(m.output)})},[e]),d.useEffect(()=>{if(!o)return;const m=Ss(o);s(m)},[o]);const[g,f]=d.useState([]);d.useEffect(()=>{(async()=>{var m,I;if(n){const y=(I=await((m=R)==null?void 0:m.get(n)))==null?void 0:I.topFieldsConfig;y&&(f(y),c(!1))}})()},[n]);const v=m=>{var I,y;if(re(g,{name:m.name,promptKey:m==null?void 0:m.promptKey,classType:(m==null?void 0:m.class_type)??""})){const w=g.filter(E=>E.name!==m.name||E.promptKey!==m.promptKey);f(w),n&&((I=R)==null||I.updateTopFields(n,{topFieldsConfig:w}))}else{const w=[...g,m];f(w),n&&((y=R)==null||y.updateTopFields(n,{topFieldsConfig:w}))}};return r.jsx(ce.Provider,{value:{topFields:g,showNodeName:i,calcInputList:t,updateTopField:v},children:r.jsxs(p,{direction:"column",align:"stretch",gap:5,children:[r.jsx(vs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:l,onChange:m=>c(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:i,onChange:m=>u(!i)})]}),l&&r.jsx(ys,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),js=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=R)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(p,{flexWrap:"wrap",gap:3,children:[r.jsx(p,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(A,{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(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(p,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(A,{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=F)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=R)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(A,{label:"Set as cover",children:r.jsx(M,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=R)==null?void 0:i.updateMetaInfo(R.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{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},ks=({media:e})=>r.jsxs(p,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(js,{media:e}),r.jsx(bs,{media:e??null})]}),Te=120;function Ps({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(p,{gap:3,h:"100%",children:[r.jsxs(Sn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(is,{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(p,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{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(mt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=F)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(ks,{media:t??void 0})]})}const Cs=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(mt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=F)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(A,{label:xt(e.createTime,!0),children:i}),r.jsx(A,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{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(A,{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(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(A,{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 g;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((g=F)==null?void 0:g.delete(e.id))}})})]})]})},Is=Cs;function Ts({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=F)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=F)==null||i.filter(u=>{var g;return((g=u.workflowJSON)==null?void 0:g.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(Is,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Vs({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([]),[g,f]=d.useState(),[v,m]=d.useState(""),I=vn(v,300),[y,w]=d.useState(!1),E=async()=>{var D;if(t==null)return;const b=await((D=F)==null?void 0:D.listByWorkflowID(t));u(b??[]),b!=null&&b.length&&f(b[0])};if(d.useEffect(()=>{var b;E(),t&&((b=R)==null||b.get(t).then(D=>{D&&n(D.name)}))},[]),t==null)return null;const $=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??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:v,onUpdateSearchValue:b=>{m(b),y||w(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:$,onChange:()=>{a($?[]: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(Ts,{searchQuery:I}):r.jsx(Ps,{mediaList:i})})]})]})})}export{Vs as default};
diff --git a/dist/workspace_web/IconCopy-D2k-9fMf.js b/dist/workspace_web/IconCopy-Ge1LD4_a.js
similarity index 83%
rename from dist/workspace_web/IconCopy-D2k-9fMf.js
rename to dist/workspace_web/IconCopy-Ge1LD4_a.js
index 88b4a3b..0fae38c 100644
--- a/dist/workspace_web/IconCopy-D2k-9fMf.js
+++ b/dist/workspace_web/IconCopy-Ge1LD4_a.js
@@ -1 +1 @@
-import{d as a}from"./App-eQybp91e.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-Pi18TWng.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-3Gq-3maw.js b/dist/workspace_web/IconSearch-xcUfhAk-.js
similarity index 67%
rename from dist/workspace_web/IconSearch-3Gq-3maw.js
rename to dist/workspace_web/IconSearch-xcUfhAk-.js
index 53476c0..b01599d 100644
--- a/dist/workspace_web/IconSearch-3Gq-3maw.js
+++ b/dist/workspace_web/IconSearch-xcUfhAk-.js
@@ -1 +1 @@
-import{d as a}from"./App-eQybp91e.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-Pi18TWng.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-s0RcQvMb.js b/dist/workspace_web/InstallMissingModelsButton-s0RcQvMb.js
deleted file mode 100644
index 80f5a45..0000000
--- a/dist/workspace_web/InstallMissingModelsButton-s0RcQvMb.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as o,j as e,i as C,P as b}from"./input.js";import{a5 as x,aj as S,g as I,h as v,H as y,i as k,ae as E,_ as F,aq as A,Z as D,av as z,f as H,B as L,a6 as P,a7 as R,aS as T,F as G,ag as O,aH as q}from"./App-eQybp91e.js";import{G as N,i as U}from"./ModelManagerTopbar-vr3vytmQ.js";import{C as W,G as B}from"./chunk-JARCRF6W-OjDz07lE.js";import{S as K}from"./chunk-3RSXBRAN-LXNJ9qB5.js";import"/scripts/api.js";import"./chunk-7D6N5TE5-lFR77IBa.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[S])==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 A.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(N,{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(W,{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(k,{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(D),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=q();g&&(a+=`?token=${g}`)}U({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(b,{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:R,overflowY:"auto",children:[e.jsx(T,{children:e.jsx(G,{justifyContent:"space-between",alignContent:"center",children:e.jsx(O,{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 ae({}){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[S])==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{ae as default};
diff --git a/dist/workspace_web/MediaPreview-AxH1rOBH.js b/dist/workspace_web/MediaPreview-AxH1rOBH.js
new file mode 100644
index 0000000..ab5e416
--- /dev/null
+++ b/dist/workspace_web/MediaPreview-AxH1rOBH.js
@@ -0,0 +1 @@
+import{d as D,r as l,j as v,I as Ee,x as Te,y as je,m as ae,q as _,p as se,b as Pe,f as T,g as Y,k as Be,o as Ke,e as Ve}from"./input.js";import{ad as Ge,ae as We,d as Le,B as qe,I as ze,y as He,j as Xe,ab as $e}from"./App-Pi18TWng.js";import{I as Ye}from"./IconSearch-xcUfhAk-.js";import{I as Je}from"./chunk-7D6N5TE5-ZfhYDM9i.js";function Qe(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function ie(t,e){let r=Qe(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function ue(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Ct(t,e,r){return(t-e)*100/(r-e)}function It(t,e,r){return(r-e)*t+e}function St(t,e,r){const a=Math.round((t-e)/r)*r+e,i=ue(r);return ie(a,i)}function Ze(t,e,r){return t==null?t:(r{var g;return a==null?"":(g=oe(a,s,r))!=null?g:""}),x=typeof i<"u",h=x?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(x||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,x,h]),k=l.useCallback(g=>{let b=g;return f&&(b=Ze(b,u,o)),ie(b,S)},[S,f,o,u]),j=l.useCallback((g=s)=>{let b;h===""?b=P(g):b=P(h)+g,b=k(b),A(b)},[k,s,A,h]),B=l.useCallback((g=s)=>{let b;h===""?b=P(-g):b=P(h)-g,b=k(b),A(b)},[k,s,A,h]),K=l.useCallback(()=>{var g;let b;a==null?b="":b=(g=oe(a,s,r))!=null?g:u,A(b)},[a,r,s,A,u]),Q=l.useCallback(g=>{var b;const ee=(b=oe(g,s,S))!=null?b:u;A(ee)},[S,s,A,u]),V=P(h);return{isOutOfRange:V>o||Vv.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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=t=>v.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.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 _e(t,e,r,a){l.useEffect(()=>{var i;if(!t.current||!a)return;const s=(i=t.current.ownerDocument.defaultView)!=null?i:window,u=Array.isArray(e)?e:[e],o=new s.MutationObserver(f=>{for(const c of f)c.type==="attributes"&&c.attributeName&&u.includes(c.attributeName)&&r(c)});return o.observe(t.current,{attributes:!0,attributeFilter:u}),()=>o.disconnect()})}function rt(t,e){const r=D(t);l.useEffect(()=>{let a=null;const i=()=>r();return e!==null&&(a=window.setInterval(i,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(t,e){const[r,a]=l.useState(!1),[i,s]=l.useState(null),[u,o]=l.useState(!0),f=l.useRef(null),c=()=>clearTimeout(f.current);rt(()=>{i==="increment"&&t(),i==="decrement"&&e()},r?at:null);const m=l.useCallback(()=>{u&&t(),f.current=setTimeout(()=>{o(!1),a(!0),s("increment")},ke)},[t,u]),w=l.useCallback(()=>{u&&e(),f.current=setTimeout(()=>{o(!1),a(!0),s("decrement")},ke)},[e,u]),x=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:x,isSpinning:r}}var ot=/^[Ee0-9+\-.]$/;function ut(t){return ot.test(t)}function it(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function lt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:i=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER,step:u=1,isReadOnly:o,isDisabled:f,isRequired:c,isInvalid:m,pattern:w="[0-9]*(.[0-9]+)?",inputMode:x="decimal",allowMouseWheel:h,id:I,onChange:S,precision:A,name:k,"aria-describedby":j,"aria-label":B,"aria-labelledby":K,onFocus:Q,onBlur:V,onInvalid:ce,getAriaValueText:fe,isValidCharacter:Z,format:g,parse:b,...ee}=t,te=D(Q),de=D(V),R=D(ce),G=D(Z??ut),ne=D(fe),d=et(t),{update:U,increment:pe,decrement:me}=d,[Fe,re]=l.useState(!1),W=!(o||f),E=l.useRef(null),L=l.useRef(null),be=l.useRef(null),ge=l.useRef(null),q=l.useCallback(n=>n.split("").filter(G).join(""),[G]),z=l.useCallback(n=>{var p;return(p=b==null?void 0:b(n))!=null?p:n},[b]),F=l.useCallback(n=>{var p;return((p=g==null?void 0:g(n))!=null?p:n).toString()},[g]);Te(()=>{(d.valueAsNumber>s||d.valueAsNumber{if(!E.current)return;if(E.current.value!=d.value){const p=z(E.current.value);d.setValue(q(p))}},[z,q]);const H=l.useCallback((n=u)=>{W&&pe(n)},[pe,W,u]),X=l.useCallback((n=u)=>{W&&me(n)},[me,W,u]),N=st(H,X);_e(be,"disabled",N.stop,N.isSpinning),_e(ge,"disabled",N.stop,N.isSpinning);const he=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;const y=z(n.currentTarget.value);U(q(y)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,y,C;te==null||te(n),L.current&&(n.target.selectionStart=(y=L.current.start)!=null?y:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),ye=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,y=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[y];M&&(n.preventDefault(),M(n))},[G,u,H,X,U,i,s]),we=n=>{let p=1;return(n.metaKey||n.ctrlKey)&&(p=.1),n.shiftKey&&(p=10),p},xe=l.useMemo(()=>{const n=ne==null?void 0:ne(d.value);if(n!=null)return n;const p=d.value.toString();return p||void 0},[d.value,ne]),Ne=l.useCallback(()=>{let n=d.value;if(d.value==="")return;/^[eE]/.test(d.value.toString())?d.setValue(""):(d.valueAsNumbers&&(n=s),d.cast(n))},[d,s,i]),Ce=l.useCallback(()=>{re(!1),r&&Ne()},[r,re,Ne]),$=l.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=E.current)==null||n.focus()})},[e]),Ie=l.useCallback(n=>{n.preventDefault(),N.up(),$()},[$,N]),Se=l.useCallback(n=>{n.preventDefault(),N.down(),$()},[$,N]);Ge(()=>E.current,"wheel",n=>{var p,y;const M=((y=(p=E.current)==null?void 0:p.ownerDocument)!=null?y:document).activeElement===E.current;if(!h||!M)return;n.preventDefault();const O=we(n)*u,Ae=Math.sign(n.deltaY);Ae===-1?H(O):Ae===1&&X(O)},{passive:!1});const Re=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var y,C,M,O;return{name:k,inputMode:x,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(y=n.readOnly)!=null?y:o,"aria-readonly":(C=n.readOnly)!=null?C:o,"aria-required":(M=n.required)!=null?M:c,required:(O=n.required)!=null?O:c,ref:ae(E,p),value:F(d.value),role:"spinbutton","aria-valuemin":i,"aria-valuemax":s,"aria-valuenow":Number.isNaN(d.valueAsNumber)?void 0:d.valueAsNumber,"aria-invalid":se(m??d.isOutOfRange),"aria-valuetext":xe,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,ye),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,x,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,xe,he,ye,ve,de,Ce]);return{value:F(d.value),valueAsNumber:d.valueAsNumber,isFocused:Fe,isDisabled:f,isReadOnly:o,getIncrementButtonProps:Re,getDecrementButtonProps:Ue,getInputProps:Oe,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[ft,le]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),dt=T(function(e,r){const a=Be("NumberInput",e),i=Ke(e),s=We(i),{htmlProps:u,...o}=lt(s),f=l.useMemo(()=>o,[o]);return v.jsx(ft,{value:f,children:v.jsx(ct,{value:a,children:v.jsx(Y.div,{...u,ref:r,className:Ve("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});dt.displayName="NumberInput";var pt=T(function(e,r){const a=J();return v.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}})});pt.displayName="NumberInputStepper";var mt=T(function(e,r){const{getInputProps:a}=le(),i=a(e,r),s=J();return v.jsx(Y.input,{...i,className:Ve("chakra-numberinput__field",e.className),__css:{width:"100%",...s.field}})});mt.displayName="NumberInputField";var De=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=T(function(e,r){var a;const i=J(),{getDecrementButtonProps:s}=le(),u=s(e,r);return v.jsx(De,{...u,__css:i.stepper,children:(a=e.children)!=null?a:v.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var gt=T(function(e,r){var a;const{getIncrementButtonProps:i}=le(),s=i(e,r),u=J();return v.jsx(De,{...s,__css:u.stepper,children:(a=e.children)!=null?a:v.jsx(nt,{})})});gt.displayName="NumberIncrementStepper";var At=Le("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const _t=(t,e)=>{const[r,a]=l.useState(t);return l.useEffect(()=>{const i=setTimeout(()=>{a(t)},e);return()=>{clearTimeout(i)}},[t,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function kt(t){const{searchValue:e,onUpdateSearchValue:r,style:a}=t,i=e!=="";return v.jsxs(qe,{style:{position:"relative",...a},mb:2,children:[v.jsx(Ye,{style:ht}),i&&v.jsx(ze,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:v.jsx(He,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),v.jsx(Xe,{placeholder:t.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:s})=>r(s.value)})]})}function Et(t){return new Promise((e,r)=>{const a=new FileReader;a.onload=i=>{const s=new Uint8Array(i.target.result),u=new DataView(s.buffer);u.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),r());let o=8;const f={};for(;oString.fromCharCode(S)).join("");f[x]=I}o+=12+c}e(f)},a.readAsArrayBuffer(t)})}function vt(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function r(u,o,f){const c=t.slice(u,u+f);if(f===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,o);if(f===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,o)}const a=r(4,e,4);function i(u){const o=r(u,e,2),f={};for(let c=0;c{const r=new FileReader;r.onload=a=>{var f;const i=new Uint8Array((f=a==null?void 0:a.target)==null?void 0:f.result),s=new DataView(i.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let u=12;const o={};for(;u{const r=new FileReader;r.onload=a=>{const i=new Uint8Array(a.target.result),s=new DataView(i.buffer),u=new TextDecoder;if(s.getUint32(0)==440786851){let o=12;for(;o>8*(4-m)&~(1<<7*m),x=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(x);e(h);return}}o+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let o=i.length-4;for(;o>16;){if(s.getUint32(o)==1684108385&&s.getUint32(o-8)==2841865588){s.getUint32(o+4),s.getUint32(o+8);const f=s.getUint32(o-4)-4*4,c=u.decode(i.slice(o+12,o+12+f)),m=JSON.parse(c);e(m);return}o-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},r.readAsArrayBuffer(t)})}function Dt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:i,objectFit:s,onBrokenLink:u}){const[o,f]=l.useState(!0);return l.useEffect(()=>{i&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).status==404){f(!1),u==null||u();return}}catch(m){console.error("Error checking media exists",m)}})()},[]),o?$e(t)?v.jsx(Je,{borderRadius:3,boxSize:`${e}px`,objectFit:s??"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):v.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:v.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:v.jsx("track",{kind:"captions"})})}):null}export{At as I,Dt as M,dt as N,kt as S,mt as a,Mt as b,Ze as c,Pt as d,pt as e,gt as f,Et as g,bt as h,Vt as i,It as p,St as r,_t as u,Ct as v};
diff --git a/dist/workspace_web/MediaPreview-gKBl9R3H.js b/dist/workspace_web/MediaPreview-gKBl9R3H.js
deleted file mode 100644
index 0a02a88..0000000
--- a/dist/workspace_web/MediaPreview-gKBl9R3H.js
+++ /dev/null
@@ -1 +0,0 @@
-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{ah as Ge,ai as qe,d as He,B as Le,I as $e,y as ze,j as We,ad as Xe,ae as Ye}from"./App-eQybp91e.js";import{I as Je}from"./IconSearch-3Gq-3maw.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-SNvLsit2.js b/dist/workspace_web/ModelManagerTopbar-SNvLsit2.js
new file mode 100644
index 0000000..eda7eac
--- /dev/null
+++ b/dist/workspace_web/ModelManagerTopbar-SNvLsit2.js
@@ -0,0 +1 @@
+import{f as H,r as m,j as n,g as z,e as re,$ as J,b as qe,o as Ye,k as Qe,h as A,a0 as ae,P as Je,a1 as Xe,N as Le,a2 as Ze,Q as Ie,S as Ee,T as et,Z as tt,M as st,O as nt,R as ot}from"./input.js";import{aj as it,m as rt,ak as at,al as lt,am as $,B as oe,F as R,h as N,i as ie,X as Ae,an as ct,k as V,a3 as G,a4 as Te,a5 as dt,ac as Ne,j as X,H as W,ao as De,ap as xe,g as q,w as ht,aq as Fe,f as Pe,ar as ye,as as ut,at as Oe,au as ft,av as mt,aw as pt,ax as gt,ay as xt,az as ee,aA as yt,aB as wt}from"./App-Pi18TWng.js";import{f as le,s as vt,g as jt}from"./civitUtils-8IbIESmj.js";import{I as ze}from"./chunk-7D6N5TE5-ZfhYDM9i.js";import{G as Mt,C as _t}from"./chunk-JARCRF6W-sDjzfEGl.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-1feEpIXZ.js";var Be=H(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,f]);return n.jsx(z.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(z.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Be.displayName="Wrap";var de=H(function(e,s){const{className:o,...i}=e;return n.jsx(z.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...i})});de.displayName="WrapItem";function we(t){return rt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Re=H(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=it({gridArea:o,gridColumn:we(i),gridRow:we(l),gridColumnStart:r,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(z.div,{ref:s,__css:f,...h})});Re.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function We(t){var e;const{bg:s,bgColor:o,backgroundColor:i,shadow:r,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=at(),h=lt(),f=(e=s??o)!=null?e:i,u=r??a;return n.jsx(z.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(z.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",f),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}We.displayName="PopoverArrow";function St(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Ct=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),bt=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function kt(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:c="progressbar"}=t,l=St(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,l):i})(),role:c},percent:l,value:e}}var[Lt,It]=qe({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=H((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...c}=t,l=kt({value:i,min:s,max:o,isIndeterminate:r,role:a}),h={height:"100%",...It().filledTrack};return n.jsx(z.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),$e=H((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ye(t),M=Qe("Progress",t),b=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${bt} 1s linear infinite`},D={...!h&&a&&c&&k,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Ct} 1s ease infinite normal none running`}},C={overflow:"hidden",position:"relative",...M.track};return n.jsx(z.div,{ref:e,borderRadius:b,__css:C,...j,children:n.jsxs(Lt,{value:M,children:[n.jsx(Et,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:h,css:D,borderRadius:b,title:p,role:x}),l]})})});$e.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ue(t)==="[object Array]"}const At=1/0;function Tt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function Ke(t){return typeof t=="number"}function Nt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ue(t)=="[object Boolean]"}function T(t){return t!=null}function se(t){return!t.trim().length}function Ue(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Dt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=Ge(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 Ge(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Dt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ft(a));e=je(a),s=Me(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function je(t){return K(t)?t:t.split(".")}function Me(t){return K(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(T(r))if(a[c]){const l=r[a[c]];if(!T(l))return;if(c===a.length-1&&(F(l)||Ke(l)||Nt(l)))s.push(Tt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{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(T(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(T(h))if(F(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else K(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[r]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[r]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ve(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const i=new he({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(Ge)),i.setSources(e),i.create(),i}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=v.distance,ignoreLocation:r=v.ignoreLocation}={}){const a=e/t.length;if(r)return a;const c=Math.abs(o-s);return i?a+c/i:c?1:a}const B=32;function zt(t,e,s,{location:o=v.location,distance:i=v.distance,threshold:r=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=c>1||l,j=x?Array(f):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:i,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let L=0;for(;L=O;w-=1){let _=w-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[w]=(y[w+1]<<1|1)&S,C&&(y[w]|=(b[w+1]|b[w])<<1|1|b[w+1]),y[w]&Y&&(k=Q(e,{errors:C,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:d}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:d})>g)break;b=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const C=function(L=[],I=v.minMatchCharLength){let O=[],E=-1,y=-1,w=0;for(let _=L.length;w<_;w+=1){let S=L[w];S&&E===-1?E=w:S||E===-1||(y=w-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[w-1]&&w-E>=I&&O.push([E,w-1]),O}(j,c);C.length?l&&(D.indices=C):D.isMatch=!1}return D}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:M,score:b,indices:k}=zt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),f+=b,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const _e=[];function Se(t,e){for(let s=0,o=_e.length;s{if(!T(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 $t(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ve(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){T(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)*(h?1:p))}),f.score=u})}(l,{ignoreFieldNorm:c}),r&&l.sort(a),Ke(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return f&&g.push(Wt),u&&g.push($t),d.map(p=>{const{idx:x}=p,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(p,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=Se(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:c})=>{if(!T(r))return;const{isMatch:l,score:d,indices:h}=s.searchIn(r);l&&i.push({item:r,idx:a,matches:[{score:d,value:r,norm:c,indices:h}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=Se(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:c})=>{if(!T(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&r.push({idx:c,item:a,matches:l})}),r}_findMatches({key:e,value:s,searcher:o}){if(!T(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:c})=>{if(!T(r))return;const{isMatch:l,score:d,indices:h}=o.searchIn(r);l&&i.push({score:d,key:e,value:r,idx:a,norm:c,indices:h})});else{const{v:r,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(r);c&&i.push({score:l,key:e,value:r,norm:a,indices:d})}return i}}U.version="7.0.0",U.createIndex=Ve,U.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new he({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Be,{children:s.map(i=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Ut={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Gt({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),c()},[t.file_hash]);const c=async()=>{var h;const d=await $.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const f=await le(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)},l=d=>{const h=Ut[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(ze,{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 Vt({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Re,{children:n.jsx(Gt,{data:e})},e.model_name+e.date.getTime()))})}function Ht(){const{setRoute:t}=m.useContext(Ae);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await ct();c(l)},c=async l=>{if(!l)return;r(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Yt(){const[t,e]=m.useState(!1),s=()=>{var a;(a=V)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=V)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await $.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;$.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(_t,{isChecked:t,onChange:o,children:"Show NSFW"})}function Qt(){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]}),G.graph.add(r)};return m.useEffect(()=>(G.canvasEl.addEventListener("drop",t),()=>{G.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await $.models.toArray();f(d.map(M=>({...M,db:j.find(b=>b.id===M.model_name+"@"+M.model_type)})))}},[d]),m.useEffect(()=>{let x=[];o.length?x=new U(h,{keys:["model_name","db.modelName"]}).search(o).map(b=>b.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>r==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,r,h]),m.useEffect(()=>(G.canvasEl.addEventListener("click",t),()=>{G.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Je,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Te,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:dt,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Ht,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{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(Z,{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(Yt,{})]}),!o.length&&n.jsx(Kt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Vt,{list:u}),c&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Qt,{})]})})}const Xt=async t=>{try{const s=await(await ce.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 Ce(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function be(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,i,r,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=be(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=be((r=(i=t.modelVersions)==null?void 0:i.at(0))==null?void 0:r.images,s))==null?void 0:a.url}}const ne=280;function es({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=V)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Zt(t,ne,x))}},[t]);const r=De(t)?t.modelVersions:t.versions,[a,c]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),l=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=m.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),f=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Te,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(ze,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{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(A,{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(A,{leftIcon:n.jsx(ht,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(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:Ce(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(f)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,c]=m.useState([]),[l,d]=m.useState(""),h=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Fe();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Xe,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(Le,{children:n.jsxs(Ze,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Ee,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(Z,{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(et,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(i,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=tt(),e=Pe(),[s,o]=m.useState([]);return m.useEffect(()=>{ye.addEventListener("download_progress",i=>{o(i.detail)}),ye.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{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($e,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ut(i),children:"Cancel"})]},i))})}function os(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Oe(),r=()=>{vt(t),o()};return n.jsxs(ft,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(mt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(pt,{p:5,children:[n.jsx(We,{}),n.jsx(gt,{}),n.jsxs(q,{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(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}var ke={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};async function is(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v9",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}"`]]),((c=(a=await(await fetch(ke.VITE_CMODEL_SEARCH_URL,{headers:{"Content-Type":"application/json",Authorization:ke.VITE_CMODEL_APP_KEY},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:c.at(0)).hits??[]}function rs({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[c,l]=m.useState(s),d=Pe(),[h,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Oe(),[M,b,k]=xt(),[P,Y]=m.useState({}),[D,C]=m.useState(ee),L=m.useCallback(async()=>{var S;a(!0);const y=await is(u,c);i(y);const w=await Fe();w&&Y(w);const _=await((S=V)==null?void 0:S.getSetting("defaultFolders"));_&&C(_),a(!1)},[u,c]),I=(y,w)=>{var fe,me,pe,ge;if(!((fe=k.current)!=null&&fe.id)&&!w){console.error("no url to download");return}let _=w??`https://civitai.com/api/download/models/${(me=k.current)==null?void 0:me.id}`,S=(pe=k.current)==null?void 0:pe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(He=>[...He,S??""]);const ue=jt();ue&&(_+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:S,save_path:y,url:_}),b(void 0),j()},O=async(y,w)=>{const _=D[w.type];b(y),_==null?x():I(_)},E=async(y,w)=>{var S;const _={...D,[y]:w};await((S=V)==null?void 0:S.upsert({defaultFolders:_})),C(_)};return m.useEffect(()=>{L()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(st,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(Le,{}),n.jsxs(nt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),yt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&P[ee[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:D[c],onChange:y=>E(c,y.target.value),children:P[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(ot,{}),n.jsxs(Ee,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:O,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{I(y,k.current?void 0:w)}})]})}function ms(){const{setRoute:t,route:e}=m.useContext(Ae);return m.useEffect(()=>{ce.addEventListener("model_list",async s=>{var r;const o=(r=s.detail)==null?void 0:r.map(async a=>{const c=await $.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),i=(await Promise.all(o)).filter(a=>a!=null);await $.models.clear(),await $.models.bulkPut(i.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:wt+"px",children:"Models"}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}export{ms as default};
diff --git a/dist/workspace_web/ModelManagerTopbar-vr3vytmQ.js b/dist/workspace_web/ModelManagerTopbar-vr3vytmQ.js
deleted file mode 100644
index 21fcf02..0000000
--- a/dist/workspace_web/ModelManagerTopbar-vr3vytmQ.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import{f as V,r as p,j as n,g as z,h as re,a0 as J,b as Ve,o as qe,l as Qe,i as A,U as ae,P as Ye,a1 as Je,N as ke,a2 as Xe,Q as Ie,S as Le,T as Ze,$ as et,M as tt,O as st,R as nt,_ as ot}from"./input.js";import{an as it,m as rt,ao as at,ap as lt,aq as $,ar as le,B as oe,F as R,ae as Ee,h as N,i as ie,Z as Ae,as as ct,k as H,a5 as U,a6 as Te,a7 as dt,ag as Ne,j as X,H as W,at as De,au as xe,g as q,w as ht,av as Fe,f as Pe,aw as ye,ax as ut,ay as Oe,az as ft,aA as pt,aB as mt,aC as gt,aD as xt,aE as yt,aF as ee,aG as wt,aH as vt,aI as jt}from"./App-eQybp91e.js";import{G as Mt,C as _t}from"./chunk-JARCRF6W-OjDz07lE.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-LXNJ9qB5.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=p.useMemo(()=>f?p.Children.map(a,(m,x)=>n.jsx(de,{children:m},x)):a,[a,f]);return n.jsx(z.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(z.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...i}=e;return n.jsx(z.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...i})});de.displayName="WrapItem";function we(t){return rt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=it({gridArea:o,gridColumn:we(i),gridRow:we(l),gridColumnStart:r,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(z.div,{ref:s,__css:f,...h})});Be.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Re(t){var e;const{bg:s,bgColor:o,backgroundColor:i,shadow:r,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=at(),h=lt(),f=(e=s??o)!=null?e:i,u=r??a;return n.jsx(z.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(z.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",f),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function St(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var bt=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),Ct=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function kt(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:c="progressbar"}=t,l=St(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,l):i})(),role:c},percent:l,value:e}}var[It,Lt]=Ve({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=V((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...c}=t,l=kt({value:i,min:s,max:o,isIndeterminate:r,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(z.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:m,role:x,...j}=qe(t),M=Qe("Progress",t),C=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${Ct} 1s linear infinite`},D={...!h&&a&&c&&k,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${bt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...M.track};return n.jsx(z.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:h,css:D,borderRadius:C,title:m,role:x}),l]})})});We.displayName="Progress";function G(t){return Array.isArray?Array.isArray(t):Ge(t)==="[object Array]"}const At=1/0;function Tt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function Nt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ge(t)=="[object Boolean]"}function T(t){return t!=null}function se(t){return!t.trim().length}function Ge(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Dt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=Ke(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 Ke(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||G(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Dt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ft(a));e=je(a),s=Me(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function je(t){return G(t)?t:t.split(".")}function Me(t){return G(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(T(r))if(a[c]){const l=r[a[c]];if(!T(l))return;if(c===a.length-1&&(F(l)||$e(l)||Nt(l)))s.push(Tt(l));else if(G(l)){o=!0;for(let d=0,h=l.length;d{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(T(a)){if(G(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(T(h))if(F(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else G(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[r]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[r]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ue(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const i=new he({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(Ke)),i.setSources(e),i.create(),i}function Y(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=v.distance,ignoreLocation:r=v.ignoreLocation}={}){const a=e/t.length;if(r)return a;const c=Math.abs(o-s);return i?a+c/i:c?1:a}const B=32;function zt(t,e,s,{location:o=v.location,distance:i=v.distance,threshold:r=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,m=u;const x=c>1||l,j=x?Array(f):[];let M;for(;(M=t.indexOf(e,m))>-1;){let b=Y(e,{currentLocation:M,expectedLocation:u,distance:i,ignoreLocation:d});if(g=Math.min(b,g),m=M+h,x){let I=0;for(;I=O;w-=1){let _=w-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[w]=(y[w+1]<<1|1)&S,b&&(y[w]|=(C[w+1]|C[w])<<1|1|C[w+1]),y[w]&Q&&(k=Y(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:d}),k<=g)){if(g=k,m=_,m<=u)break;O=Math.max(1,2*u-m)}}if(Y(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:d})>g)break;C=y}const D={isMatch:m>=0,score:Math.max(.001,k)};if(x){const b=function(I=[],L=v.minMatchCharLength){let O=[],E=-1,y=-1,w=0;for(let _=I.length;w<_;w+=1){let S=I[w];S&&E===-1?E=w:S||E===-1||(y=w-1,y-E+1>=L&&O.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&O.push([E,w-1]),O}(j,c);b.length?l&&(D.indices=b):D.isMatch=!1}return D}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,m=f-g;for(;u{const{isMatch:M,score:C,indices:k}=zt(e,m,x,{location:i+j,distance:r,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),f+=C,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const _e=[];function Se(t,e){for(let s=0,o=_e.length;s{if(!T(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 $t(t,e){e.score=t.score}class K{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){T(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:m,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(h?1:m))}),f.score=u})}(l,{ignoreFieldNorm:c}),r&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return f&&g.push(Wt),u&&g.push($t),d.map(m=>{const{idx:x}=m,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(m,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=Se(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:c})=>{if(!T(r))return;const{isMatch:l,score:d,indices:h}=s.searchIn(r);l&&i.push({item:r,idx:a,matches:[{score:d,value:r,norm:c,indices:h}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=Se(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:c})=>{if(!T(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&r.push({idx:c,item:a,matches:l})}),r}_findMatches({key:e,value:s,searcher:o}){if(!T(s))return[];let i=[];if(G(s))s.forEach(({v:r,i:a,n:c})=>{if(!T(r))return;const{isMatch:l,score:d,indices:h}=o.searchIn(r);l&&i.push({score:d,key:e,value:r,idx:a,norm:c,indices:h})});else{const{v:r,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(r);c&&i.push({score:l,key:e,value:r,norm:a,indices:d})}return i}}K.version="7.0.0",K.createIndex=Ue,K.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new he({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},K.config=v;function Gt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(ze,{children:s.map(i=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Kt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=p.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=p.useState(!t.file_hash),[r,a]=p.useState();p.useEffect(()=>{i(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await $.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const f=await le(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)},l=d=>{const h=Kt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Ee,{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 Ht({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Be,{children:n.jsx(Ut,{data:e})},e.model_name+e.date.getTime()))})}function Vt(){const{setRoute:t}=p.useContext(Ae);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=p.useState(["checkpoints"]),[s,o]=p.useState([]),[i,r]=p.useState(!0);p.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await ct();c(l)},c=async l=>{if(!l)return;r(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function Qt(){const[t,e]=p.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};p.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await $.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;$.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(_t,{isChecked:t,onChange:o,children:"Show NSFW"})}function Yt(){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]}),U.graph.add(r)};return p.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=p.useState("checkpoints"),[o,i]=p.useState(""),[r,a]=p.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,f]=p.useState([]),[u,g]=p.useState([]);p.useEffect(()=>{x();async function x(){const j=await $.models.toArray();f(d.map(M=>({...M,db:j.find(C=>C.id===M.model_name+"@"+M.model_type)})))}},[d]),p.useEffect(()=>{let x=[];o.length?x=new K(h,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>r==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,r,h]),p.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const m=440;return n.jsx(Ye,{children:n.jsxs(oe,{style:{width:m},children:[n.jsxs(Te,{width:m,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:dt,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{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(Z,{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(Qt,{})]}),!o.length&&n.jsx(Gt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Ht,{list:u}),c&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Yt,{})]})})}const Xt=async t=>{try{const s=await(await ce.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 be(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function Ce(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,i,r,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=Ce(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=Ce((r=(i=t.modelVersions)==null?void 0:i.at(0))==null?void 0:r.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=p.useState();p.useEffect(()=>{m();async function m(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(Zt(t,ne,x))}},[t]);const r=De(t)?t.modelVersions:t.versions,[a,c]=p.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),l=r==null?void 0:r.find(m=>(m==null?void 0:m.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=p.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),f=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Te,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Ee,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{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(A,{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(A,{leftIcon:n.jsx(ht,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:m=>{c(m.target.value)},children:r==null?void 0:r.map(m=>{const x=m==null?void 0:m.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},m.id):null})}),f&&n.jsx(ie,{label:be(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:be(f)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=p.useState(""),[a,c]=p.useState([]),[l,d]=p.useState(""),h=p.useRef(null);p.useEffect(()=>{f()},[]);const f=async()=>{const u=await Fe();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Je,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(ke,{children:n.jsxs(Xe,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Le,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(Z,{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(Ze,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(i,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Pe(),[s,o]=p.useState([]);return p.useEffect(()=>{ye.addEventListener("download_progress",i=>{o(i.detail)}),ye.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{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(We,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ut(i),children:"Cancel"})]},i))})}function os(){const[t,e]=p.useState(""),{onOpen:s,onClose:o,isOpen:i}=Oe(),r=()=>{xt(t),o()};return n.jsxs(ft,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(pt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(mt,{p:5,children:[n.jsx(Re,{}),n.jsx(gt,{}),n.jsxs(q,{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(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function is(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v9",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}"`]]),((c=(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:c.at(0)).hits??[]}function rs({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=p.useState([]),[r,a]=p.useState(!1),[c,l]=p.useState(s),d=Pe(),[h,f]=p.useState([]),[u,g]=p.useState(e),{isOpen:m,onOpen:x,onClose:j}=Oe(),[M,C,k]=yt(),[P,Q]=p.useState({}),[D,b]=p.useState(ee),I=p.useCallback(async()=>{var S;a(!0);const y=await is(u,c);i(y);const w=await Fe();w&&Q(w);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,c]),L=(y,w)=>{var fe,pe,me,ge;if(!((fe=k.current)!=null&&fe.id)&&!w){console.error("no url to download");return}let _=w??`https://civitai.com/api/download/models/${(pe=k.current)==null?void 0:pe.id}`,S=(me=k.current)==null?void 0:me.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(He=>[...He,S??""]);const ue=vt();ue&&(_+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,w)=>{const _=D[w.type];C(y),_==null?x():L(_)},E=async(y,w)=>{var S;const _={...D,[y]:w};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return p.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(tt,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(ke,{}),n.jsxs(st,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),wt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&P[ee[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:D[c],onChange:y=>E(c,y.target.value),children:P[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:O,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:m,onClose:j,selectFolder:(y,w)=>{L(y,k.current?void 0:w)}})]})}const as=p.lazy(()=>ot(()=>import("./InstallMissingModelsButton-s0RcQvMb.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function ls(){const{setRoute:t,route:e}=p.useContext(Ae);return p.useEffect(()=>{ce.addEventListener("model_list",async s=>{var r;const o=(r=s.detail)==null?void 0:r.map(async a=>{const c=await $.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),i=(await Promise.all(o)).filter(a=>a!=null);await $.models.clear(),await $.models.bulkPut(i.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:jt+"px",children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(p.Suspense,{children:n.jsx(as,{})})}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const ps=Object.freeze(Object.defineProperty({__proto__:null,default:ls},Symbol.toStringTag,{value:"Module"}));export{Be as G,ps as M,Xt as i};
-function __vite__mapDeps(indexes) {
- if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-s0RcQvMb.js","workspace_web/input.js","workspace_web/App-eQybp91e.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-OjDz07lE.js","workspace_web/chunk-7D6N5TE5-lFR77IBa.js","workspace_web/chunk-3RSXBRAN-LXNJ9qB5.js"]
- }
- return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
-}
\ No newline at end of file
diff --git a/dist/workspace_web/RecentFilesDrawer-h9_pZtx6.js b/dist/workspace_web/RecentFilesDrawer-h9_pZtx6.js
deleted file mode 100644
index 6a49951..0000000
--- a/dist/workspace_web/RecentFilesDrawer-h9_pZtx6.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import{f as Q,E as qe,j as e,Z as Je,h as ie,g as we,r,M as re,N as le,O as ce,Q as de,R as ue,S as he,W as ve,i as W,$ as ke,T as Qe}from"./input.js";import{m as Le,u as Ae,a as et,b as tt,c as st,S as nt,M as at,d as A,H as z,T as We,I as P,t as je,e as Ne,f as Y,E as me,g as B,h as L,i as R,j as pe,k as C,R as H,l as ot,n as Me,B as _,F as Z,o as Fe,p as it,q as rt,r as ee,s as te,v as N,w as lt,D as Pe,x as T,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 U,Y as ye,Z as Ce,_ as yt,$ as wt,a0 as $e,a1 as vt,a2 as kt,a3 as St,a4 as J,a5 as oe,a6 as Ct,a7 as bt,a8 as It,a9 as fe,aa as Mt}from"./App-eQybp91e.js";import{G as Ft,C as q}from"./chunk-JARCRF6W-OjDz07lE.js";import{V as Ke}from"./chunk-NTCQBYKE-a6jE7X_b.js";import{N as Dt,a as Et,I as Tt,M as Ot,u as zt,S as Lt}from"./MediaPreview-gKBl9R3H.js";import{I as At}from"./IconCopy-D2k-9fMf.js";import"./chunk-7D6N5TE5-lFR77IBa.js";import"./IconSearch-3Gq-3maw.js";var Ge=Q(function(t,l){const{columns:o,spacingX:n,spacingY:a,spacing:u,minChildWidth:p,...i}=t,h=qe(),d=p?Nt(p,h):Pt(o);return e.jsx(Ft,{ref:l,gap:u,columnGap:n,rowGap:a,templateColumns:d,...i})});Ge.displayName="SimpleGrid";function Wt(s){return typeof s=="number"?`${s}px`:s}function Nt(s,t){return Le(s,l=>{const o=Je("sizes",l,Wt(l))(t);return l===null?null:`repeat(auto-fit, minmax(${o}, 1fr))`})}function Pt(s){return Le(s,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var He=Q((s,t)=>{const{title:l,children:o,className:n,...a}=s,u=ie("chakra-menu__group__title",n),p=Ae();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[l&&e.jsx(we.p,{className:u,...a,__css:p.groupTitle,children:l}),o]})});He.displayName="MenuGroup";var Ve=s=>{const{className:t,title:l,...o}=s,n=et(o);return e.jsx(He,{title:l,className:ie("chakra-menu__option-group",t),...n})};Ve.displayName="MenuOptionGroup";var Rt=Q((s,t)=>{const l=Ae();return e.jsx(we.button,{ref:t,...s,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...l.button}})}),se=Q((s,t)=>{const{children:l,as:o,...n}=s,a=tt(n,t),u=o||Rt;return e.jsx(u,{...a,className:ie("chakra-menu__menu-button",s.className),children:e.jsx(we.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:s.children})})});se.displayName="MenuButton";var _t=s=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...s,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=Q((s,t)=>{const{icon:l,iconSpacing:o="0.75rem",...n}=s,a=st(n,t);return e.jsxs(nt,{...a,className:ie("chakra-menu__menuitem-option",n.className),children:[l!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:o,opacity:s.isChecked?1:0,children:l||e.jsx(_t,{})}),e.jsx("span",{style:{flex:1},children:a.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var Bt=A("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),$t=A("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"}]]),Kt=A("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=A("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"}]]),Gt=A("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"}]]),Ue=A("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"}]]),Ht=A("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=A("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=A("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"}]]),Zt=A("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"}]]),Yt=A("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"}]]),Xt=A("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"}]]),qt=A("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"}]]),Jt=A("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 Qt({onclose:s}){const[t,l]=r.useState([]),o=async()=>{var a;const n=await((a=je)==null?void 0:a.listAll());l(n??[])};return r.useEffect(()=>{o()},[]),e.jsxs(re,{isOpen:!0,onClose:s,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"My Tags"}),e.jsx(ue,{}),e.jsx(he,{children:t.map(n=>e.jsxs(z,{children:[e.jsx(We,{children:n.name}),e.jsx(P,{onClick:async()=>{var a;await((a=je)==null?void 0:a.delete(n.name)),o()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ne,{})})]}))})]})]})}function es(){const s=Y(),t=r.useRef([{title:"Save current workflow",key:me.SAVE},{title:"Save as current workflow",key:me.SAVE_AS},{title:"Open spotlight search",key:me.openSpotlightSearch}]),[l,o]=r.useState({save:"",saveAs:"",openSpotlightSearch:""}),[n,a]=r.useState(),u=async(i,h)=>{var g;i.preventDefault();let d="";if(i.ctrlKey&&(d+="Control+"),i.metaKey&&(d+="Command+"),i.shiftKey&&(d+="Shift+"),i.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(i.key)){d+=i.key.toUpperCase();const m={...l};delete m[h],Object.values(m).includes(d)?s({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=C)==null?void 0:g.upsert({shortcuts:{...l,[h]:d}})),p())}},p=()=>{var i;(i=C)==null||i.getSetting("shortcuts").then(h=>{var g;const d=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);o({...l,...d})})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(i=>e.jsxs(z,{children:[e.jsx(L,{fontSize:"sm",w:170,children:i.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:n===i.key,children:e.jsx(pe,{value:l[i.key],onKeyDown:h=>{u(h,i.key)},onFocus:()=>{a(i.key)},onBlur:()=>{a(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},i.key))]})}function ts(){const{setRefreshFolderStamp:s}=r.useContext(H),[t,l]=r.useState(!1),o=()=>{var a;(a=C)==null||a.getSetting("foldersOnTop").then(u=>{l(!!u)})},n=a=>{var p;const u=a.target.checked;(p=C)==null||p.upsert({foldersOnTop:u}).then(()=>{o(),s(Date.now())})};return r.useEffect(()=>{o()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:t,onChange:n,children:"Folders always on top"})})}function ss(){const[s,t]=r.useState(!1),[l,o]=r.useState(""),{showDialog:n}=ve(),a=()=>{var p,i;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{o(h??"undefined")}),(i=C)==null||i.getSetting("twoWaySync").then(h=>{t(h??!1)})};r.useEffect(()=>{a()},[]);const u=async p=>{var h,d;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),a();return}const i=await((d=C)==null?void 0:d.getSetting("myWorkflowsDir"));n(e.jsx(ot,{myWorkflowsDir:i??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),a()},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(q,{isChecked:s,onChange:u,children:"Enable two way sync"})]})}function Ee({settingKey:s,text:t,defaultChecked:l=!1}){const[o,n]=r.useState(l),a=Y(),u=()=>{var p;(p=C)==null||p.getSetting(s).then(i=>{n(!!i)})};return r.useEffect(()=>{u()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:o,onChange:async p=>{var i;await((i=C)==null?void 0:i.upsert({[s]:p.target.checked})),u(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ns(){const[s,t]=r.useState(!1),[l,o]=r.useState(!1),[n,a]=r.useState([]),[u,p]=r.useState(""),[i,h]=r.useState([]),[d,g]=r.useState(!1),[m,c]=r.useState(!1),[f,v]=r.useState(!1),S=r.useRef(null),w=Y();ve();const b=f?"\\":"/";r.useEffect(()=>{var j;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(j=C)==null||j.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async j=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Fe(j??"");return V.includes("Operation not permitted")?(c(!0),O(),{isError:!0}):{dirList:E,dirPath:k}},y=async()=>{const{isError:j=!1,dirList:k=[]}=await F(u);j||(a(k),o(!0),h(u&&u.split(b).filter(E=>!!E)||[]))},O=()=>{o(!1),t(!1),h([])},$=async(j,k=!1,E=!1)=>{var x,I;if(k){const{path:M}=await Me();M&&await it(M,j)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:j}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&c(!1),O()},K=async j=>{if(j){const{error:E=""}=await Fe(j);if(E.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=j??`${f?"":b}${i.join(b)}`;$(k,!1,!!j)},X=async()=>{const{dirPath:j,dirList:k}=await F("");h(j.split(b).filter(E=>!!E)),a(k)},ne=async(j,k)=>{var I;let E="";j===-1&&k?E=`${f?"":b}${i.concat([k]).join(b)}`:E=`${f?"":b}${i.slice(0,j+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(a(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},ae=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(pe,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(W,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var j,k;(j=S==null?void 0:S.current)!=null&&j.value&&K((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ge=()=>{o(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),l?s?ae:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:i.map((j,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ne(k)},children:j},`${j}-${k}`)]},j))}),e.jsx(Ge,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:n.map((j,k)=>e.jsx(W,{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:()=>{ne(-1,j)},children:j},`${j}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(W,{colorScheme:"teal",size:"sm",onClick:()=>{K()},children:"Save"}),e.jsx(W,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(W,{size:"sm",onClick:O,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:u}),e.jsx(R,{label:d?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(P,{"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:y})}),e.jsx(R,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(P,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx(Kt,{size:19}),onClick:ge,variant:"ghost"})})]})]}),e.jsxs(re,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Kind tips"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(_,{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(W,{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."}),ae]})})]})]})]})}function Ze({label:s,settingKey:t}){const[l,o]=r.useState(200),n=Y(),a=i=>{if(!i.length){o(0);return}o(parseInt(i))},u=async()=>{var i;l<0&&o(0),await((i=C)==null?void 0:i.upsert({[t]:Number(l)})),n({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var i;(i=C)==null||i.getSetting(t).then(h=>{o(h)})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:s}),e.jsx(Dt,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:l,onChange:i=>a(i),onBlur:()=>{u()},onKeyUp:i=>{i.key==="Enter"&&u()},children:e.jsx(Et,{})})]})}function as(){const[s,t]=r.useState(!1),l=Y(),o=()=>{var n;(n=C)==null||n.getSetting("autoSave").then(a=>{t(!!a)})};return r.useEffect(()=>{o()},[]),e.jsxs(B,{children:[e.jsx(q,{isChecked:s,onChange:async n=>{var a;await((a=C)==null?void 0:a.upsert({autoSave:n.target.checked})),o(),l({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),s&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function os(){const s=r.useRef(null),t=Y(),l=()=>{var o;(o=C)==null||o.getSetting("cloudHost").then(n=>{var a;(a=s.current)==null||a.setAttribute("value",n??"")})};return r.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(Z,{gap:2,alignItems:"center",children:[e.jsx(pe,{ref:s,onBlur:()=>{var o,n,a;console.log("onBlur",(o=s.current)==null?void 0:o.value),(a=C)==null||a.upsert({cloudHost:(n=s.current)==null?void 0:n.value}),l(),t({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})}}),e.jsx(W,{size:"sm",onClick:()=>{var o,n,a;(n=s.current)==null||n.setAttribute("value",(o=C)==null?void 0:o.defaultSettings.cloudHost),(a=s.current)==null||a.blur()},children:"Reset"})]})]})}function is({onClose:s}){return e.jsx(e.Fragment,{children:e.jsxs(re,{isOpen:!0,onClose:s,size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Settings"}),e.jsx(ue,{}),e.jsx(he,{pb:14,children:e.jsx(z,{children:e.jsxs(Ke,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ns,{}),e.jsx(as,{}),e.jsx(es,{}),e.jsx(ss,{}),e.jsx(ts,{}),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"}),e.jsx(os,{})]})})})]})]})})}const xe=16;function rs({}){const[s,t]=r.useState(!1),[l,o]=r.useState(!1),{colorMode:n,toggleColorMode:a}=ke();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(se,{as:P,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(N,{onClick:()=>o(!0),icon:e.jsx(Yt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(N,{onClick:()=>t(!0),icon:e.jsx(qt,{size:xe}),fontSize:16,children:"Manage Tags"}),e.jsxs(N,{onClick:a,icon:n==="light"?e.jsx(Zt,{size:xe}):e.jsx(Xt,{size:xe}),fontSize:16,children:[n==="light"?"Dark":"Light"," Mode"]})]})]}),s&&e.jsx(Qt,{onclose:()=>t(!1)}),l&&e.jsx(is,{onClose:()=>o(!1)})]})}function ls(s){const{multipleState:t,changeMultipleState:l,selectedKeys:o,isSelectedAll:n,batchOperationCallback:a}=s,u=async()=>{var h;const i=await((h=T)==null?void 0:h.batchQuery(o))??[];ct(i)},p=o.length===0;return e.jsx(z,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(q,{isChecked:n,onChange:i=>{a("selectAll",i.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(P,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:u})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${o.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var i;await((i=T)==null?void 0:i.batchDeleteFlow(o)),a("batchDelete")}})}),o.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${o.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(P,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{l(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(P,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Ht,{size:21}),onClick:()=>{l(!0)}})})})}const Te=6;function cs({setSelectedTag:s,selectedTag:t}){const[l,o]=r.useState(!1),[n,a]=r.useState([]);return r.useEffect(()=>{var u;(u=je)==null||u.listAll().then(p=>{a(p)})},[]),e.jsxs(z,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(P,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{s(void 0)}}),n.slice(0,l?void 0:Te).map(u=>e.jsx(W,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{s(u.name)},isActive:t===u.name,children:u.name},u.name)),(n.length??0)>Te&&e.jsx(P,{"aria-label":"Show-all-tags",size:"sm",icon:l?e.jsx(Bt,{}):e.jsx(Se,{}),onClick:()=>o(!l)})]})}function Ye({parentFolderID:s,onlyImportFile:t=!1}){const{onRefreshFilesList:l}=r.useContext(H),[o,n]=r.useState("file"),a=r.useRef(null),u=d=>{var g;n(d),d==="folder"?a.current.setAttribute("webkitdirectory",""):a.current.removeAttribute("webkitdirectory"),(g=a.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},i=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=T)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}l==null||l()},h=async d=>{var m;const g=d.target.files;if(g)if(o==="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;wy.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const y=await p(f);y&&(F.file=y)}S.push(F)}F&&!F.isFile&&(S=F.children)}}i(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=T)==null?void 0:m.batchCreateFlows(c,void 0,s)),l&&l())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(N,{onClick:d=>{d.stopPropagation(),u("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:W,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((d,g)=>e.jsx(N,{onClick:()=>{u(d.type)},iconSpacing:2,icon:d.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Gt,{size:18}),children:d.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:a,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:d=>{d.stopPropagation()}})]})}function ds({folder:s,onclose:t}){const[l,o]=r.useState(s.name),[n,a]=r.useState(""),{onRefreshFilesList:u}=r.useContext(H),p=h=>{o(h.target.value),n&&a("")},i=async()=>{var g,m;const h=l.trim();if(o(h),h===s.name)return t();await((g=G)==null?void 0:g.generateUniqueName(h,s.parentFolderID??""))!==h?a("The name is duplicated, please modify it and submit again."):(await((m=G)==null?void 0:m.update(s.id,{name:h})),u&&u(),t())};return e.jsxs(re,{isOpen:!0,onClose:t,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Edit folder name"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(ht,{isInvalid:!!n,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(pe,{value:l,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!n&&l&&i()}}),n&&e.jsx(gt,{children:n})]})}),e.jsxs(Qe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:i,isDisabled:!l||!!n,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function us({menuPosition:s,isopen:t,folder:l,onClose:o}){const[n,a]=r.useState(!1),{onRefreshFilesList:u}=r.useContext(H),{showDialog:p}=ve(),i=async m=>{var c;m.stopPropagation(),await((c=G)==null?void 0:c.create({name:"New Folder",parentFolderID:l.id})),u&&u()},h=async m=>{var c;m.stopPropagation(),await((c=T)==null?void 0:c.createFlow({json:JSON.stringify(ft),parentFolderID:l.id})),u&&u()},d=async m=>{m.stopPropagation();const c=await xt(l.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(l.id,m)),o(),u&&u()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:s.y,left:s.x,children:e.jsx(ee,{isOpen:t,onClose:o,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(N,{icon:e.jsx(mt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),a(!0)},children:"Rename"}),e.jsx(N,{icon:e.jsx(Ne,{size:19}),onClick:d,children:"Delete"}),e.jsx(N,{onClick:i,icon:e.jsx(Ue,{size:19}),children:"New folder"}),e.jsx(N,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:l.id,onlyImportFile:!0})]})})}),n&&e.jsx(ds,{folder:l,onclose:()=>a(!1)})]})}const Oe=r.memo(function({folder:t}){const[l,o]=r.useState(!1),[n,a]=r.useState(t.isCollapse??!0),[u,p]=r.useState([]),[i,h]=r.useState({x:0,y:0}),[d,g]=r.useState(!1),{colorMode:m}=ke(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=r.useContext(H),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};r.useEffect(()=>{var y;n||(y=T)==null||y.listFolderContent(t.id,window.localStorage.getItem(ye)).then(O=>{p(O)})},[t.id,v,n]);const b=y=>{y.preventDefault(),h({x:y.clientX,y:y.clientY}),g(!0)},F=async y=>{var O,$;if(y.preventDefault(),y.stopPropagation(),!c)return o(!1);if(U(c)){if(c.id===t.id)return o(!1);await((O=G)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else U(c)||await(($=T)==null?void 0:$.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),o(!1)};return r.useEffect(()=>{var y;!!t.isCollapse!==n&&((y=G)==null||y.update(t.id,{isCollapse:n}))},[n]),r.useEffect(()=>{var X;const y=(X=T)==null?void 0:X.curWorkflow,O=(y==null?void 0:y.parentFolderID)+"/",$=t.id+"/";O.startsWith($)&&a(!1)},[]),e.jsxs(B,{children:[e.jsxs(z,{w:"100%",as:"button",py:1,onClick:()=>{a(!n)},onContextMenu:b,draggable:"true",onDragOver:y=>{y.preventDefault(),y.stopPropagation(),o(!0)},onDragLeave:y=>{y.preventDefault(),y.stopPropagation(),o(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:l||d?w:void 0,className:"droppable",children:[e.jsxs(z,{gap:1,children:[n?e.jsx(Tt,{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(us,{isopen:d,menuPosition:i,onClose:()=>g(!1),folder:t}),!n&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Xe,{items:u})})]})});function hs({workflow:s}){const t=r.useRef(null),l=Y(),{onDuplicateWorkflow:o}=r.useContext(Ce),[n,a]=r.useState(s.saveLock??!1),u=async()=>{var h;const i=!n;a(i),await((h=T)==null?void 0:h.updateMetaInfo(s.id,{saveLock:i})),l({title:`${i?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async i=>{const h=i.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 vt("/workspace/images/save",{method:"POST",body:d}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=kt)==null||c.create({workflowID:s.id,localPath:m}),(f=T)==null||f.updateMetaInfo(s.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(se,{border:0,as:P,"aria-label":"Options",icon:e.jsx($t,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(N,{icon:e.jsx(At,{}),onClick:()=>o&&o(s.id),children:"Duplicate"}),e.jsx(N,{icon:e.jsx(yt,{size:20}),onClick:()=>wt(s.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:n?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(N,{icon:n?e.jsx($e,{}):e.jsx(Vt,{}),onClick:u,children:n?"Unlock":"Lock"})}),e.jsx(N,{icon:e.jsx(Jt,{}),onClick:()=>{var i;(i=t.current)==null||i.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:i=>{i.stopPropagation()}})]})}function ps({workflow:s}){const{onDeleteFlow:t}=r.useContext(H);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(s.id)}}),e.jsx(hs,{workflow:s})]})}const ze=r.memo(function({workflow:t}){var v,S,w,b;const{colorMode:l}=ke(),{setDraggingFile:o,isMultiSelecting:n,onMultiSelectFlow:a,multiSelectedFlowsID:u}=r.useContext(H),p=u&&u.length>0&&u.includes(t.id),{curFlowID:i,loadWorkflowID:h}=r.useContext(Ce),d=i===t.id,g=l==="light"?"gray.200":"#4A5568",[m,c]=r.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!n?"#333":void 0,draggable:!n,onDragStart:()=>o==null?void 0:o(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!n&&h(t.id)},_hover:{bg:g},children:e.jsxs(z,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(Ot,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(z,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:l=="dark"?"gray.700":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:n?e.jsx(q,{isChecked:p,spacing:4,onChange:F=>{a&&a(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(ps,{workflow:t}):e.jsx(L,{color:"GrayText",fontSize:"sm",children:St(t.updateTime,!1,!1,"/")})})]})})});function Xe({items:s}){var m;const[t,l]=r.useState(!1),o=s.filter(U),n=s.filter(c=>!U(c)),a=(m=n[0])==null?void 0:m.parentFolderID,[u,p]=r.useState(!1),{onRefreshFilesList:i,draggingFile:h,refreshFolderStamp:d}=r.useContext(H),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(U(h)){if(h.id===a)return p(!1);await((f=G)==null?void 0:f.update(h.id,{parentFolderID:a}))}else await((v=T)==null?void 0:v.updateFolder(h.id,{parentFolderID:a}));await(i==null?void 0:i()),p(!1)};return r.useEffect(()=>{var c;(c=C)==null||c.getSetting("foldersOnTop").then(f=>{l(f??!1)})},[d]),e.jsxs(e.Fragment,{children:[t&&o.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?n.map(c=>e.jsx(ze,{workflow:c},c.id)):s.map(c=>U(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:s,onClickNewFlow:t}){const[l,o]=r.useState([]),n=r.useRef([]),{loadWorkflowID:a,curFlowID:u}=r.useContext(Ce),[p,i]=r.useState(),[h,d]=r.useState(!1),[g,m]=r.useState([]),[c,f]=r.useState(0),[v,S]=r.useState(""),w=zt(v,400),b=r.useRef(null),[F,y]=r.useState(null),O=r.useRef(window.localStorage.getItem(ye)??J.RECENTLY_MODIFIED),$=!!p||!!w.length,K=async()=>{var I,M;const x=await((I=T)==null?void 0:I.listFolderContent())??[];o(fe(x,O.current)),f(Date.now()),n.current=await((M=T)==null?void 0:M.listAll())??[]},X=()=>{const x=n.current.filter(I=>{var Ie;let M=!0,D=!0;return p&&(M=!!((Ie=I.tags)!=null&&Ie.includes(p))),w&&(D=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),M&&D});o(fe(x,O.current))},ne=x=>{o(fe(l,x)),O.current=x,window.localStorage.setItem(ye,x),!$&&f(Date.now())};r.useEffect(()=>{$?X():K()},[w,p]);const ae=r.useCallback(async x=>{var I,M,D;await((I=T)==null?void 0:I.deleteFlow(x)),((D=(M=T)==null?void 0:M.curWorkflow)==null?void 0:D.id)===x&&await(a==null?void 0:a(null)),await K()},[p,w]);r.useEffect(()=>{const x=async I=>{var M;if(b.current){const D=await((M=T)==null?void 0:M.get(b.current));D&&D.json&&Mt(D.json,[I.canvasX,I.canvasY])}};return oe.canvasEl.addEventListener("drop",x),oe.canvasEl.addEventListener("click",s),()=>{oe.canvasEl.removeEventListener("drop",x),oe.canvasEl.removeEventListener("click",s)}},[]);const ge=r.useCallback((x,I)=>{m(M=>{const D=[...M];return I?D.push(x):D.splice(D.indexOf(x),1),D})},[]),j=(x,I)=>{var M;switch(x){case"batchDelete":u&&((M=T)==null||M.get(u).then(D=>{D||a==null||a(null)})),K(),d(!1),m([]);return;case"selectAll":m(I?n.current.map(D=>D.id):[]);return}},k=x=>{y(x),U(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(H.Provider,{value:{onRefreshFilesList:K,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:h,onMultiSelectFlow:ge,multiSelectedFlowsID:g,onDeleteFlow:ae,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(Ct,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:bt,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(z,{gap:4,children:[e.jsx(z,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(P,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>It()})}),e.jsx(R,{label:"New workflow",children:e.jsx(P,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(z,{alignItems:"center",children:e.jsx(rs,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(cs,{selectedTag:p,setSelectedTag:i}),e.jsxs(z,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(z,{children:[e.jsx(ls,{multipleState:h,changeMultipleState:x=>{d(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===n.current.length,batchOperationCallback:j}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(P,{size:"sm",variant:"outline",icon:e.jsx(Ue,{size:21}),onClick:async()=>{var x;await((x=G)==null?void 0:x.create({name:"New Folder"})),K()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(z,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(te,{children:e.jsx(Ve,{value:O.current,type:"radio",onChange:x=>ne(x),children:[J.RECENTLY_MODIFIED,J.OLDEST_MODIFIED,J.AZ,J.ZA].map((x,I)=>e.jsx(be,{value:x,children:x},I))})})]})]}),e.jsx(Lt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Xe,{items:l})})]})]})})})}export{ks as default};
diff --git a/dist/workspace_web/RecentFilesDrawer-nkyCGrYH.js b/dist/workspace_web/RecentFilesDrawer-nkyCGrYH.js
new file mode 100644
index 0000000..c98975b
--- /dev/null
+++ b/dist/workspace_web/RecentFilesDrawer-nkyCGrYH.js
@@ -0,0 +1,5 @@
+import{f as Q,E as qe,j as e,Y as Je,e as ie,g as we,r as i,M as re,N as le,O as ce,Q as de,R as ue,S as he,V as ve,h as W,Z as ke,T as Qe}from"./input.js";import{m as Le,u as Ae,a as et,b as tt,c as st,S as nt,M as at,d as A,H as z,T as We,I as P,t as je,e as Ne,f as Y,E as me,g as B,h as L,i as R,j as pe,k as C,R as G,l as ot,n as Me,B as _,F as Z,o as Fe,p as it,q as rt,r as ee,s as te,v as N,w as lt,D as Pe,x as T,y as Re,z as ct,A as Se,C as dt,G as _e,J as K,K as ut,L as ht,N as pt,O as Be,P as gt,Q as mt,U as ft,V as U,W as ye,X as Ce,Y as xt,Z as jt,_ as $e,$ as yt,a0 as wt,a1 as vt,a2 as J,a3 as oe,a4 as kt,a5 as St,a6 as Ct,a7 as fe,a8 as bt}from"./App-Pi18TWng.js";import{G as It,C as q}from"./chunk-JARCRF6W-sDjzfEGl.js";import{V as He}from"./chunk-NTCQBYKE-6cj7iDLd.js";import{N as Mt,a as Ft,g as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-AxH1rOBH.js";import{I as Lt}from"./IconCopy-Ge1LD4_a.js";import"./chunk-7D6N5TE5-ZfhYDM9i.js";import"./IconSearch-xcUfhAk-.js";var Ke=Q(function(t,r){const{columns:l,spacingX:o,spacingY:s,spacing:d,minChildWidth:p,...n}=t,h=qe(),u=p?Wt(p,h):Nt(l);return e.jsx(It,{ref:r,gap:d,columnGap:o,rowGap:s,templateColumns:u,...n})});Ke.displayName="SimpleGrid";function At(a){return typeof a=="number"?`${a}px`:a}function Wt(a,t){return Le(a,r=>{const l=Je("sizes",r,At(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function Nt(a){return Le(a,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ge=Q((a,t)=>{const{title:r,children:l,className:o,...s}=a,d=ie("chakra-menu__group__title",o),p=Ae();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(we.p,{className:d,...s,__css:p.groupTitle,children:r}),l]})});Ge.displayName="MenuGroup";var Ve=a=>{const{className:t,title:r,...l}=a,o=et(l);return e.jsx(Ge,{title:r,className:ie("chakra-menu__option-group",t),...o})};Ve.displayName="MenuOptionGroup";var Pt=Q((a,t)=>{const r=Ae();return e.jsx(we.button,{ref:t,...a,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),se=Q((a,t)=>{const{children:r,as:l,...o}=a,s=tt(o,t),d=l||Pt;return e.jsx(d,{...s,className:ie("chakra-menu__menu-button",a.className),children:e.jsx(we.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:a.children})})});se.displayName="MenuButton";var Rt=a=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...a,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=Q((a,t)=>{const{icon:r,iconSpacing:l="0.75rem",...o}=a,s=st(o,t);return e.jsxs(nt,{...s,className:ie("chakra-menu__menuitem-option",o.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:a.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:s.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=A("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=A("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=A("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=A("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"}]]),Ht=A("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"}]]),Ue=A("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"}]]),Kt=A("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=A("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"}]]),Vt=A("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"}]]),Ut=A("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=A("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),Yt=A("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"}]]),Xt=A("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"}]]),qt=A("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"}]]),Jt=A("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 Qt({onclose:a}){const[t,r]=i.useState([]),l=async()=>{var s;const o=await((s=je)==null?void 0:s.listAll());r(o??[])};return i.useEffect(()=>{l()},[]),e.jsxs(re,{isOpen:!0,onClose:a,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"My Tags"}),e.jsx(ue,{}),e.jsx(he,{children:t.map(o=>e.jsxs(z,{children:[e.jsx(We,{children:o.name}),e.jsx(P,{onClick:async()=>{var s;await((s=je)==null?void 0:s.delete(o.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ne,{})})]}))})]})]})}function es(){const a=Y(),t=i.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]=i.useState({save:"",saveAs:"",openSpotlightSearch:""}),[o,s]=i.useState(),d=async(n,h)=>{var g;n.preventDefault();let u="";if(n.ctrlKey&&(u+="Control+"),n.metaKey&&(u+="Command+"),n.shiftKey&&(u+="Shift+"),n.altKey&&(u+="Alt+"),u.length>0&&!["Control","Shift","Alt","Meta"].includes(n.key)){u+=n.key.toUpperCase();const m={...r};delete m[h],Object.values(m).includes(u)?a({title:"Shortcut key conflict",description:`The shortcut key 「${u}」 is already used, please
+ modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...r,[h]:u}})),p())}},p=()=>{var n;(n=C)==null||n.getSetting("shortcuts").then(h=>{var g;const u=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...r,...u})})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(n=>e.jsxs(z,{children:[e.jsx(L,{fontSize:"sm",w:170,children:n.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:o===n.key,children:e.jsx(pe,{value:r[n.key],onKeyDown:h=>{d(h,n.key)},onFocus:()=>{s(n.key)},onBlur:()=>{s(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},n.key))]})}function ts(){const{setRefreshFolderStamp:a}=i.useContext(G),[t,r]=i.useState(!1),l=()=>{var s;(s=C)==null||s.getSetting("foldersOnTop").then(d=>{r(!!d)})},o=s=>{var p;const d=s.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),a(Date.now())})};return i.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:t,onChange:o,children:"Folders always on top"})})}function ss(){const[a,t]=i.useState(!1),[r,l]=i.useState(""),{showDialog:o}=ve(),s=()=>{var p,n;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(n=C)==null||n.getSetting("twoWaySync").then(h=>{t(h??!1)})};i.useEffect(()=>{s()},[]);const d=async p=>{var h,u;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),s();return}const n=await((u=C)==null?void 0:u.getSetting("myWorkflowsDir"));o(e.jsx(ot,{myWorkflowsDir:n??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),s()},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(q,{isChecked:a,onChange:d,children:"Enable two way sync"})]})}function Ee({settingKey:a,text:t,defaultChecked:r=!1}){const[l,o]=i.useState(r),s=Y(),d=()=>{var p;(p=C)==null||p.getSetting(a).then(n=>{o(!!n)})};return i.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:l,onChange:async p=>{var n;await((n=C)==null?void 0:n.upsert({[a]:p.target.checked})),d(),s({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ns(){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),[o,s]=i.useState([]),[d,p]=i.useState(""),[n,h]=i.useState([]),[u,g]=i.useState(!1),[m,c]=i.useState(!1),[f,v]=i.useState(!1),S=i.useRef(null),w=Y();ve();const b=f?"\\":"/";i.useEffect(()=>{var j;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(j=C)==null||j.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async j=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Fe(j??"");return V.includes("Operation not permitted")?(c(!0),O(),{isError:!0}):{dirList:E,dirPath:k}},y=async()=>{const{isError:j=!1,dirList:k=[]}=await F(d);j||(s(k),l(!0),h(d&&d.split(b).filter(E=>!!E)||[]))},O=()=>{l(!1),t(!1),h([])},$=async(j,k=!1,E=!1)=>{var x,I;if(k){const{path:M}=await Me();M&&await it(M,j)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:j}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&c(!1),O()},H=async j=>{if(j){const{error:E=""}=await Fe(j);if(E.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=j??`${f?"":b}${n.join(b)}`;$(k,!1,!!j)},X=async()=>{const{dirPath:j,dirList:k}=await F("");h(j.split(b).filter(E=>!!E)),s(k)},ne=async(j,k)=>{var I;let E="";j===-1&&k?E=`${f?"":b}${n.concat([k]).join(b)}`:E=`${f?"":b}${n.slice(0,j+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(s(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},ae=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(pe,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(W,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var j,k;(j=S==null?void 0:S.current)!=null&&j.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ge=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?a?ae:e.jsxs(He,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:n.map((j,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ne(k)},children:j},`${j}-${k}`)]},j))}),e.jsx(Ke,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:o.map((j,k)=>e.jsx(W,{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:()=>{ne(-1,j)},children:j},`${j}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(W,{colorScheme:"teal",size:"sm",onClick:()=>{H()},children:"Save"}),e.jsx(W,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(W,{size:"sm",onClick:O,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(We,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:u?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(P,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!u,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:y})}),e.jsx(R,{label:u?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(P,{isDisabled:!u,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:ge,variant:"ghost"})})]})]}),e.jsxs(re,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Kind tips"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(_,{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(W,{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."}),ae]})})]})]})]})}function Ze({label:a,settingKey:t}){const[r,l]=i.useState(200),o=Y(),s=n=>{if(!n.length){l(0);return}l(parseInt(n))},d=async()=>{var n;r<0&&l(0),await((n=C)==null?void 0:n.upsert({[t]:Number(r)})),o({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var n;(n=C)==null||n.getSetting(t).then(h=>{l(h)})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:a}),e.jsx(Mt,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:n=>s(n),onBlur:()=>{d()},onKeyUp:n=>{n.key==="Enter"&&d()},children:e.jsx(Ft,{})})]})}function as(){const[a,t]=i.useState(!1),r=Y(),l=()=>{var o;(o=C)==null||o.getSetting("autoSave").then(s=>{t(!!s)})};return i.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(q,{isChecked:a,onChange:async o=>{var s;await((s=C)==null?void 0:s.upsert({autoSave:o.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),a&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function os(){const a=Y(),[t,r]=i.useState(""),l=()=>{var s;(s=C)==null||s.getSetting("cloudHost").then(d=>{r(d??"")})};i.useEffect(()=>{l()},[]);const o=async s=>{var d;await((d=C)==null?void 0:d.upsert({cloudHost:s})),l(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(L,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(Z,{gap:2,alignItems:"center",children:[e.jsx(pe,{value:t,onChange:s=>r(s.target.value),onBlur:()=>o(t)}),e.jsx(W,{size:"sm",onClick:()=>{var d;const s=(d=C)==null?void 0:d.defaultSettings.cloudHost;r(s),o(s)},children:"Reset"})]})]})}function is({onClose:a}){return e.jsx(e.Fragment,{children:e.jsxs(re,{isOpen:!0,onClose:a,size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Settings"}),e.jsx(ue,{}),e.jsx(he,{pb:14,children:e.jsx(z,{children:e.jsxs(He,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ns,{}),e.jsx(as,{}),e.jsx(es,{}),e.jsx(ss,{}),e.jsx(ts,{}),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"}),e.jsx(os,{})]})})})]})]})})}const xe=16;function rs({}){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),{colorMode:o,toggleColorMode:s}=ke();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(se,{as:P,"aria-label":"Options",icon:e.jsx(Vt,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(N,{onClick:()=>l(!0),icon:e.jsx(Yt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(N,{onClick:()=>t(!0),icon:e.jsx(qt,{size:xe}),fontSize:16,children:"Manage Tags"}),e.jsxs(N,{onClick:s,icon:o==="light"?e.jsx(Ut,{size:xe}):e.jsx(Xt,{size:xe}),fontSize:16,children:[o==="light"?"Dark":"Light"," Mode"]})]})]}),a&&e.jsx(Qt,{onclose:()=>t(!1)}),r&&e.jsx(is,{onClose:()=>l(!1)})]})}function ls(a){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:o,batchOperationCallback:s}=a,d=async()=>{var h;const n=await((h=T)==null?void 0:h.batchQuery(l))??[];ct(n)},p=l.length===0;return e.jsx(z,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(q,{isChecked:o,onChange:n=>{s("selectAll",n.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(P,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:d})}),e.jsx(R,{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 n;await((n=T)==null?void 0:n.batchDeleteFlow(l)),s("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(P,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(P,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Kt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function cs({setSelectedTag:a,selectedTag:t}){const[r,l]=i.useState(!1),[o,s]=i.useState([]);return i.useEffect(()=>{var d;(d=je)==null||d.listAll().then(p=>{s(p)})},[]),e.jsxs(z,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(P,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{a(void 0)}}),o.slice(0,r?void 0:Te).map(d=>e.jsx(W,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{a(d.name)},isActive:t===d.name,children:d.name},d.name)),(o.length??0)>Te&&e.jsx(P,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:a,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=i.useContext(G),[l,o]=i.useState("file"),s=i.useRef(null),d=u=>{var g;o(u),u==="folder"?s.current.setAttribute("webkitdirectory",""):s.current.removeAttribute("webkitdirectory"),(g=s.current)==null||g.click()},p=async u=>{var g;if(u.type==="image/png"){const m=await Dt(u),c=m==null?void 0:m.workflow;if(c)return{json:c,name:u.name.replace(".png","")}}else if(u.type==="application/json"||(g=u.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:u.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(u)});return null},n=async u=>{var m,c;const g=[u];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=K)==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=T)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async u=>{var m;const g=u.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;wy.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const y=await p(f);y&&(F.file=y)}S.push(F)}F&&!F.isFile&&(S=F.children)}}n(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=T)==null?void 0:m.batchCreateFlows(c,void 0,a)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(N,{onClick:u=>{u.stopPropagation(),d("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:W,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((u,g)=>e.jsx(N,{onClick:()=>{d(u.type)},iconSpacing:2,icon:u.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Ht,{size:18}),children:u.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:s,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:u=>{u.stopPropagation()}})]})}function ds({folder:a,onclose:t}){const[r,l]=i.useState(a.name),[o,s]=i.useState(""),{onRefreshFilesList:d}=i.useContext(G),p=h=>{l(h.target.value),o&&s("")},n=async()=>{var g,m;const h=r.trim();if(l(h),h===a.name)return t();await((g=K)==null?void 0:g.generateUniqueName(h,a.parentFolderID??""))!==h?s("The name is duplicated, please modify it and submit again."):(await((m=K)==null?void 0:m.update(a.id,{name:h})),d&&d(),t())};return e.jsxs(re,{isOpen:!0,onClose:t,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Edit folder name"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(ut,{isInvalid:!!o,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(pe,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!o&&r&&n()}}),o&&e.jsx(pt,{children:o})]})}),e.jsxs(Qe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:n,isDisabled:!r||!!o,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function us({menuPosition:a,isopen:t,folder:r,onClose:l}){const[o,s]=i.useState(!1),{onRefreshFilesList:d}=i.useContext(G),{showDialog:p}=ve(),n=async m=>{var c;m.stopPropagation(),await((c=K)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),d&&d()},h=async m=>{var c;m.stopPropagation(),await((c=T)==null?void 0:c.createFlow({json:JSON.stringify(gt),parentFolderID:r.id})),d&&d()},u=async m=>{m.stopPropagation();const c=await mt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(ft.DELETE)}}])},g=async m=>{var c;await((c=K)==null?void 0:c.deleteFolder(r.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:a.y,left:a.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(N,{icon:e.jsx(Zt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),s(!0)},children:"Rename"}),e.jsx(N,{icon:e.jsx(Ne,{size:19}),onClick:u,children:"Delete"}),e.jsx(N,{onClick:n,icon:e.jsx(Ue,{size:19}),children:"New folder"}),e.jsx(N,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),o&&e.jsx(ds,{folder:r,onclose:()=>s(!1)})]})}const Oe=i.memo(function({folder:t}){const[r,l]=i.useState(!1),[o,s]=i.useState(t.isCollapse??!0),[d,p]=i.useState([]),[n,h]=i.useState({x:0,y:0}),[u,g]=i.useState(!1),{colorMode:m}=ke(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=i.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};i.useEffect(()=>{var y;o||(y=T)==null||y.listFolderContent(t.id,window.localStorage.getItem(ye)).then(O=>{p(O)})},[t.id,v,o]);const b=y=>{y.preventDefault(),h({x:y.clientX,y:y.clientY}),g(!0)},F=async y=>{var O,$;if(y.preventDefault(),y.stopPropagation(),!c)return l(!1);if(U(c)){if(c.id===t.id)return l(!1);await((O=K)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else U(c)||await(($=T)==null?void 0:$.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return i.useEffect(()=>{var y;!!t.isCollapse!==o&&((y=K)==null||y.update(t.id,{isCollapse:o}))},[o]),i.useEffect(()=>{var X;const y=(X=T)==null?void 0:X.curWorkflow,O=(y==null?void 0:y.parentFolderID)+"/",$=t.id+"/";O.startsWith($)&&s(!1)},[]),e.jsxs(B,{children:[e.jsxs(z,{w:"100%",as:"button",py:1,onClick:()=>{s(!o)},onContextMenu:b,draggable:"true",onDragOver:y=>{y.preventDefault(),y.stopPropagation(),l(!0)},onDragLeave:y=>{y.preventDefault(),y.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:r||u?w:void 0,className:"droppable",children:[e.jsxs(z,{gap:1,children:[o?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(us,{isopen:u,menuPosition:n,onClose:()=>g(!1),folder:t}),!o&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Xe,{items:d})})]})});function hs({workflow:a}){const t=i.useRef(null),r=Y(),{onDuplicateWorkflow:l}=i.useContext(Ce),[o,s]=i.useState(a.saveLock??!1),d=async()=>{var h;const n=!o;s(n),await((h=T)==null?void 0:h.updateMetaInfo(a.id,{saveLock:n})),r({title:`${n?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async n=>{const h=n.target.files;if(!h)return;const u=new FormData;Array.from(h).forEach((g,m)=>{u.append(`images[${m}]`,g,g.name)}),u.append("subfolder","workspace_manager"),await yt("/workspace/images/save",{method:"POST",body:u}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=wt)==null||c.create({workflowID:a.id,localPath:m}),(f=T)==null||f.updateMetaInfo(a.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(se,{border:0,as:P,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(N,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(a.id),children:"Duplicate"}),e.jsx(N,{icon:e.jsx(xt,{size:20}),onClick:()=>jt(a.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:o?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(N,{icon:o?e.jsx($e,{}):e.jsx(Gt,{}),onClick:d,children:o?"Unlock":"Lock"})}),e.jsx(N,{icon:e.jsx(Jt,{}),onClick:()=>{var n;(n=t.current)==null||n.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:n=>{n.stopPropagation()}})]})}function ps({workflow:a}){const{onDeleteFlow:t}=i.useContext(G);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(a.id)}}),e.jsx(hs,{workflow:a})]})}const ze=i.memo(function({workflow:t}){var v,S,w,b;const{colorMode:r}=ke(),{setDraggingFile:l,isMultiSelecting:o,onMultiSelectFlow:s,multiSelectedFlowsID:d}=i.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:n,loadWorkflowID:h}=i.useContext(Ce),u=n===t.id,g=r==="light"?"gray.200":"#4A5568",[m,c]=i.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:u?"teal.200":void 0,color:u&&!o?"#333":void 0,draggable:!o,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!o&&h(t.id)},_hover:{bg:g},children:e.jsxs(z,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(z,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:r=="dark"?"gray.700":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:o?e.jsx(q,{isChecked:p,spacing:4,onChange:F=>{s&&s(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(ps,{workflow:t}):e.jsx(L,{color:"GrayText",fontSize:"sm",children:vt(t.updateTime,!1,!1,"/")})})]})})});function Xe({items:a}){var m;const[t,r]=i.useState(!1),l=a.filter(U),o=a.filter(c=>!U(c)),s=(m=o[0])==null?void 0:m.parentFolderID,[d,p]=i.useState(!1),{onRefreshFilesList:n,draggingFile:h,refreshFolderStamp:u}=i.useContext(G),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(U(h)){if(h.id===s)return p(!1);await((f=K)==null?void 0:f.update(h.id,{parentFolderID:s}))}else await((v=T)==null?void 0:v.updateFolder(h.id,{parentFolderID:s}));await(n==null?void 0:n()),p(!1)};return i.useEffect(()=>{var c;(c=C)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[u]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx(_,{border:d?"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?o.map(c=>e.jsx(ze,{workflow:c},c.id)):a.map(c=>U(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:a,onClickNewFlow:t}){const[r,l]=i.useState([]),o=i.useRef([]),{loadWorkflowID:s,curFlowID:d}=i.useContext(Ce),[p,n]=i.useState(),[h,u]=i.useState(!1),[g,m]=i.useState([]),[c,f]=i.useState(0),[v,S]=i.useState(""),w=Ot(v,400),b=i.useRef(null),[F,y]=i.useState(null),O=i.useRef(window.localStorage.getItem(ye)??J.RECENTLY_MODIFIED),$=!!p||!!w.length,H=async()=>{var I,M;const x=await((I=T)==null?void 0:I.listFolderContent())??[];l(fe(x,O.current)),f(Date.now()),o.current=await((M=T)==null?void 0:M.listAll())??[]},X=()=>{const x=o.current.filter(I=>{var Ie;let M=!0,D=!0;return p&&(M=!!((Ie=I.tags)!=null&&Ie.includes(p))),w&&(D=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),M&&D});l(fe(x,O.current))},ne=x=>{l(fe(r,x)),O.current=x,window.localStorage.setItem(ye,x),!$&&f(Date.now())};i.useEffect(()=>{$?X():H()},[w,p]);const ae=i.useCallback(async x=>{var I,M,D;await((I=T)==null?void 0:I.deleteFlow(x)),((D=(M=T)==null?void 0:M.curWorkflow)==null?void 0:D.id)===x&&await(s==null?void 0:s(null)),await H()},[p,w]);i.useEffect(()=>{const x=async I=>{var M;if(b.current){const D=await((M=T)==null?void 0:M.get(b.current));D&&D.json&&bt(D.json,[I.canvasX,I.canvasY])}};return oe.canvasEl.addEventListener("drop",x),oe.canvasEl.addEventListener("click",a),()=>{oe.canvasEl.removeEventListener("drop",x),oe.canvasEl.removeEventListener("click",a)}},[]);const ge=i.useCallback((x,I)=>{m(M=>{const D=[...M];return I?D.push(x):D.splice(D.indexOf(x),1),D})},[]),j=(x,I)=>{var M;switch(x){case"batchDelete":d&&((M=T)==null||M.get(d).then(D=>{D||s==null||s(null)})),H(),u(!1),m([]);return;case"selectAll":m(I?o.current.map(D=>D.id):[]);return}},k=x=>{y(x),U(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:H,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:h,onMultiSelectFlow:ge,multiSelectedFlowsID:g,onDeleteFlow:ae,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(kt,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:St,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(z,{gap:4,children:[e.jsx(z,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(P,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>Ct()})}),e.jsx(R,{label:"New workflow",children:e.jsx(P,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(z,{alignItems:"center",children:e.jsx(rs,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(cs,{selectedTag:p,setSelectedTag:n}),e.jsxs(z,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(z,{children:[e.jsx(ls,{multipleState:h,changeMultipleState:x=>{u(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===o.current.length,batchOperationCallback:j}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(P,{size:"sm",variant:"outline",icon:e.jsx(Ue,{size:21}),onClick:async()=>{var x;await((x=K)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(z,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(te,{children:e.jsx(Ve,{value:O.current,type:"radio",onChange:x=>ne(x),children:[J.RECENTLY_MODIFIED,J.OLDEST_MODIFIED,J.AZ,J.ZA].map((x,I)=>e.jsx(be,{value:x,children:x},I))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default};
diff --git a/dist/workspace_web/ShareDialog-3XWt4eF0.js b/dist/workspace_web/ShareDialog-3XWt4eF0.js
deleted file mode 100644
index b1284e0..0000000
--- a/dist/workspace_web/ShareDialog-3XWt4eF0.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as t,m as ae,x as Y,b as ne,f as re,j as e,g as ie,h as le,i as M,M as ce,N as de,O as ue,Q as fe,S as he}from"./input.js";import{B as pe,A as ge,a6 as we,aE as me,f as xe,k as z,F as X,g as H,aK as ve,H as Z,j as ke,aL as ye,aM as be,x as E,aN as F,aO as je,aP as Se,a5 as Ce,aQ as De,h as Ie,T as Re,aR as Ee,_ as Le}from"./App-eQybp91e.js";import{S as Te,L as We}from"./chunk-VTV6N5LE-_EaL4yE7.js";import{I as _e}from"./IconCopy-D2k-9fMf.js";import"./chunk-7D6N5TE5-lFR77IBa.js";function Pe(n){return n&&Y(n)&&Y(n.target)}function Ne(n={}){const{onChange:u,value:f,defaultValue:g,name:w,isDisabled:h,isFocusable:r,isNative:c,...a}=n,[b,j]=t.useState(g||""),p=typeof f<"u",m=p?f:b,x=t.useRef(null),i=t.useCallback(()=>{const l=x.current;if(!l)return;let d="input:not(:disabled):checked";const I=l.querySelector(d);if(I){I.focus();return}d="input:not(:disabled)";const v=l.querySelector(d);v==null||v.focus()},[]),T=`radio-${t.useId()}`,S=w||T,D=t.useCallback(l=>{const d=Pe(l)?l.target.value:l;p||j(d),u==null||u(String(d))},[u,p]),W=t.useCallback((l={},d=null)=>({...l,ref:ae(d,x),role:"radiogroup"}),[]),_=t.useCallback((l={},d=null)=>({...l,ref:d,name:S,[c?"checked":"isChecked"]:m!=null?l.value===m:void 0,onChange(v){D(v)},"data-radiogroup":!0}),[c,S,D,m]);return{getRootProps:W,getRadioProps:_,name:S,ref:x,focus:i,setValue:j,value:m,onChange:D,isDisabled:h,isFocusable:r,htmlProps:a}}var[Ve,Be]=ne({name:"RadioGroupContext",strict:!1}),ee=re((n,u)=>{const{colorScheme:f,size:g,variant:w,children:h,className:r,isDisabled:c,isFocusable:a,...b}=n,{value:j,onChange:p,getRootProps:m,name:x,htmlProps:i}=Ne(b),L=t.useMemo(()=>({name:x,size:g,onChange:p,colorScheme:f,value:j,variant:w,isDisabled:c,isFocusable:a}),[x,g,p,f,j,w,c,a]);return e.jsx(Ve,{value:L,children:e.jsx(ie.div,{...m(i,u),className:le("chakra-radio-group",r),children:h})})});ee.displayName="RadioGroup";function Fe({options:n,value:u,onChange:f}){const[g,w]=t.useState(!1),h=t.useRef(null),r=n.find(a=>a.value===u);t.useEffect(()=>{const a=b=>{h.current&&!h.current.contains(b.target)&&w(!1)};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[h]);const c=()=>w(!g);return e.jsxs(pe,{position:"relative",children:[e.jsx(M,{onClick:c,rightIcon:e.jsx(ge,{}),leftIcon:r==null?void 0:r.icon,children:r==null?void 0:r.label}),g&&e.jsx(we,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:n.map(a=>e.jsx(M,{onClick:()=>{w(!1),f(a.value)},leftIcon:a.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:a.label},a.label))})]})}function Ke({onClose:n}){var O,$,G,B,K;const[u,f]=t.useState("v"+Me()),[g,w]=t.useState([]),[h,r]=t.useState(!1),c=($=(O=z)==null?void 0:O.settings)==null?void 0:$.cloudHost,[a,b,j]=me("PRIVATE"),[p,m]=t.useState("new_version"),x=t.useRef(""),i=(G=E)==null?void 0:G.curWorkflow,L=xe(),T=t.useRef(null),[S,D]=t.useState(!0),W=async o=>{var P,N;const s=o.data;if(s.type!=="share_workflow_success")return;const k=s.localWorkflowID,y=s.localVersionID,C=s.version.id,R=s.version.workflowID;R&&k&&await((P=E)==null?void 0:P.updateMetaInfo(k,{cloudID:R,cloudOrigin:o.origin,privacy:j.current})),y&&C&&await((N=F)==null?void 0:N.update(y,{cloudID:C,cloudOrigin:o.origin})),_(),window.open(x.current+"/workflow/"+R+"/"+C,"_blank"),r(!1)};t.useEffect(()=>{_(),window.addEventListener("message",W);const o=s=>{s.detail&&d(s.detail?JSON.stringify(s.detail):void 0)};return window.addEventListener("workspace_info_deps_updated",o),()=>{window.removeEventListener("message",W),window.removeEventListener("workspace_info_deps_updated",o)}},[]);const _=async()=>{var s,k;const o=await((s=z)==null?void 0:s.getSetting("cloudHost"));o&&(x.current=o),i!=null&&i.cloudID&&i.cloudOrigin&&De(i).then(y=>{b(y)}),(k=F)==null||k.listByWorkflowID(i.id).then(y=>{w(y)})},l=o=>{navigator.clipboard.writeText(o).then(()=>{L({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(s=>{console.error("Failed to copy text: ",s)})},d=async o=>{var A,U,J;r(!0);const s=je(32),k=await((A=z)==null?void 0:A.getSetting("cloudHost"));let y,C;try{if(y=Se(),p==="new_version"?C=await((U=F)==null?void 0:U.add({workflowID:i.id,name:u,createTime:Date.now(),json:o??JSON.stringify(Ce.graph.serialize())})):C=await((J=F)==null?void 0:J.get(p)),!C){alert(`Failed to find version: ${p}, please try again.`),r(!1);return}}catch(V){console.error(V),r(!1),alert("Failed to share workflow, please try again.");return}const R=window.location.protocol,P=window.location.host,N=`${R}//${P}`,oe=k+`/share_workflow_confirm/${s}?redirectUrl=${N}`,se=window.open(oe,"Share Workflow","width=800,height=800"),q=V=>{var Q;if(V.origin===k&&V.data==="child_ready"){const te=(Q=E)==null?void 0:Q.curWorkflow;se.postMessage({workflow:te,version:C,nodeDefs:y,privacy:j.current},k),window.removeEventListener("message",q)}};window.addEventListener("message",q)},I=async()=>{var o;S?(o=T.current)==null||o.requestSubmit():d()},v=(K=(B=E)==null?void 0:B.curWorkflow)==null?void 0:K.cloudID;return e.jsxs(ce,{isOpen:!0,onClose:n,size:"lg",children:[e.jsx(de,{}),e.jsxs(ue,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(fe,{children:[e.jsxs(X,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',i==null?void 0:i.name,'"']}),e.jsx(M,{colorScheme:"teal",onClick:I,size:"sm",isDisabled:h,children:h?"Sharing":"Share"})]}),c&&e.jsxs(Ie,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(c).host]})]}),e.jsx(he,{pb:10,children:e.jsxs(H,{gap:5,children:[v==null?e.jsx(Fe,{options:ve,value:a,onChange:o=>{b(o)}}):e.jsx(Re,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ee,{privacy:a,showEmoji:!0})}),v&&e.jsxs(Z,{spacing:2,color:"teal.400",children:[e.jsxs(We,{wordBreak:"break-all",href:c+"/workflow/"+v,isExternal:!0,children:[c+"/workflow/"+v," ",e.jsx(Le,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(M,{size:"sm",leftIcon:e.jsx(_e,{size:18}),onClick:()=>{var o,s;l(c+"/workflow/"+((s=(o=E)==null?void 0:o.curWorkflow)==null?void 0:s.cloudID))},children:"Copy link"})]}),e.jsx(ee,{gap:4,onChange:o=>{m(o)},value:p,children:e.jsx(H,{children:e.jsxs(Z,{mb:5,alignItems:"center",children:[e.jsx(ke,{value:u,width:"60%",onFocus:()=>{m("new_version")},onChange:o=>{f(o.target.value)}}),e.jsx(X,{color:"green",children:e.jsx(ye,{colorScheme:"purple",children:"Version Name"})})]})})}),e.jsxs(H,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Te,{isChecked:S,onChange:()=>D(!S),fontWeight:"600",children:"Share Resource Links"}),S&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"GrayText"},children:"You can disable reource sharing if you don't want to resolve submit errors"}),e.jsx(be,{ref:T})]})]})]})})]})]})}function Me(){const n=new Date,u=n.getFullYear(),f=String(n.getMonth()+1).padStart(2,"0"),g=String(n.getDate()).padStart(2,"0");return`${u}-${f}-${g}`}export{Ke as default};
diff --git a/dist/workspace_web/ShareDialog-gnVPTurL.js b/dist/workspace_web/ShareDialog-gnVPTurL.js
new file mode 100644
index 0000000..9821829
--- /dev/null
+++ b/dist/workspace_web/ShareDialog-gnVPTurL.js
@@ -0,0 +1 @@
+import{f as te,n as ge,o as we,j as e,g as ae,e as ne,r as u,m as xe,w as X,b as je,h as z,a0 as Z,M as ve,N as ye,O as be,Q as ke,S as Se}from"./input.js";import{B as Ce,A as Ie,a4 as De,g as T,H as A,ac as Re,a3 as R,af as M,am as Ee,ay as ee,X as Ne,f as Pe,F as oe,aD as Te,j as Oe,k as se,x as _,$ as We,aE as _e,aF as Fe,aG as Me,aH as ze,h as Le,T as Ae,aI as Ge,Y as He}from"./App-Pi18TWng.js";import{I as $e}from"./chunk-7D6N5TE5-ZfhYDM9i.js";import{a as Be}from"./civitUtils-8IbIESmj.js";import{S as Ue,L as Ve}from"./chunk-VTV6N5LE-K9rVd8eY.js";import{I as Je}from"./IconCopy-Ge1LD4_a.js";var re=te(function(i,l){const r=ge("Badge",i),{className:t,...o}=we(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...o,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function Ke(s){return s&&X(s)&&X(s.target)}function qe(s={}){const{onChange:i,value:l,defaultValue:r,name:t,isDisabled:o,isFocusable:f,isNative:y,...d}=s,[b,v]=u.useState(r||""),p=typeof l<"u",w=p?l:b,x=u.useRef(null),a=u.useCallback(()=>{const m=x.current;if(!m)return;let g="input:not(:disabled):checked";const O=m.querySelector(g);if(O){O.focus();return}g="input:not(:disabled)";const E=m.querySelector(g);E==null||E.focus()},[]),j=`radio-${u.useId()}`,h=t||j,C=u.useCallback(m=>{const g=Ke(m)?m.target.value:m;p||v(g),i==null||i(String(g))},[i,p]),k=u.useCallback((m={},g=null)=>({...m,ref:xe(g,x),role:"radiogroup"}),[]),L=u.useCallback((m={},g=null)=>({...m,ref:g,name:h,[y?"checked":"isChecked"]:w!=null?m.value===w:void 0,onChange(E){C(E)},"data-radiogroup":!0}),[y,h,C,w]);return{getRootProps:k,getRadioProps:L,name:h,ref:x,focus:a,setValue:v,value:w,onChange:C,isDisabled:o,isFocusable:f,htmlProps:d}}var[Ye,lo]=je({name:"RadioGroupContext",strict:!1}),ie=te((s,i)=>{const{colorScheme:l,size:r,variant:t,children:o,className:f,isDisabled:y,isFocusable:d,...b}=s,{value:v,onChange:p,getRootProps:w,name:x,htmlProps:a}=qe(b),I=u.useMemo(()=>({name:x,size:r,onChange:p,colorScheme:l,value:v,variant:t,isDisabled:y,isFocusable:d}),[x,r,p,l,v,t,y,d]);return e.jsx(Ye,{value:I,children:e.jsx(ae.div,{...w(a,i),className:ne("chakra-radio-group",f),children:o})})});ie.displayName="RadioGroup";function Qe({options:s,value:i,onChange:l}){const[r,t]=u.useState(!1),o=u.useRef(null),f=s.find(d=>d.value===i);u.useEffect(()=>{const d=b=>{o.current&&!o.current.contains(b.target)&&t(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[o]);const y=()=>t(!r);return e.jsxs(Ce,{position:"relative",children:[e.jsx(z,{onClick:y,rightIcon:e.jsx(Ie,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),r&&e.jsx(De,{gap:4,ref:o,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:s.map(d=>e.jsx(z,{onClick:()=>{t(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Xe({deps:s,uploadingImage:i}){const l=Object.values((s==null?void 0:s.images)??{});return s?e.jsx(T,{gap:5,children:l.length>0&&e.jsxs(T,{children:[e.jsxs(A,{children:[e.jsxs(Re,{size:"sm",children:["Images (",l.length,")"]}),e.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&e.jsxs("span",{children:[e.jsx(Z,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(T,{children:[e.jsx("p",{children:r.filename}),e.jsx($e,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(Z,{size:"md",color:"teal.400"})}async function Ze(s,i,l){const r=await Ee.models.where("fileName").equals(s).toArray()??[];console.log("fetch modeldata",r);const t=r.at(0);return{name:s,nodeType:i,hash:(t==null?void 0:t.fileHash)??null,folder:(t==null?void 0:t.fileFolder)??null,url:t!=null&&t.civitModelVersionID?Be(t.civitModelVersionID):(t==null?void 0:t.downloadUrl)??null,inputName:l,length:r.length}}async function eo(s){var w,x;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],t=[".jpeg",".jpg",".png",".gif",".webp"],o=(x=(w=R.graph.extra)==null?void 0:w[M])==null?void 0:x.deps,f=await R.graphToPrompt();Object.values(f.output).forEach(a=>{a.inputs&&Object.keys(a.inputs).forEach(I=>{var h,C;const j=(h=a.inputs)==null?void 0:h[I];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Ze(j,a.class_type,I)),t.some(k=>j.endsWith(k))&&(l[j]=((C=o==null?void 0:o.images)==null?void 0:C[j])??{filename:j,nodeType:a.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:s.map(a=>a.type)})}).then(a=>a.ok?a.json():[]).catch(a=>(console.error("Error fetching node repos",a),[])),b=await Promise.all(i),v={};b.forEach(a=>{v[a.name]=a});const p={};return Object.values(d).forEach(a=>{p[a.gitRepo]=a}),{models:v,images:l,nodeRepos:Object.values(p)}}function co({onClose:s}){var G,H,$,B,U;const[i,l,r]=ee("v"+oo()),{saveCurWorkflow:t}=u.useContext(Ne),[o,f]=u.useState(),[y,d]=u.useState(!1),[b,v]=u.useState(!1),p=(H=(G=se)==null?void 0:G.settings)==null?void 0:H.cloudHost,[w,x,a]=ee("PRIVATE"),[I,j]=u.useState("new_version"),h=($=_)==null?void 0:$.curWorkflow,C=Pe(),[k,L]=u.useState(!0),m=async n=>{var P;const c=n.data;if(c.type!=="share_workflow_success")return;const D=c.localWorkflowID,N=c.version.id,S=c.version.workflowID;S&&D&&await((P=_)==null?void 0:P.updateMetaInfo(D,{cloudID:S,privacy:a.current})),g(),window.open(p+"/workflow/"+S+"/"+N,"_blank"),v(!1)};u.useEffect(()=>{g();const n=R.graph.serialize();return eo(n.nodes??[]).then(c=>{f(c)}),window.addEventListener("message",m),()=>{window.removeEventListener("message",m)}},[]);const g=async()=>{h!=null&&h.cloudID&&h.cloudOrigin&&ze(h).then(n=>{x(n)})},O=n=>{navigator.clipboard.writeText(n).then(()=>{C({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},E=async n=>{var K,q,Y;const c=R.graph.serialize();(K=c.extra||(c.extra={}))[q=M]||(K[q]={}),c.extra[M].deps={models:(o==null?void 0:o.models)??{},images:n??{},nodeRepos:(o==null?void 0:o.nodeRepos)??[]},await t();const D=await R.graphToPrompt(R.graph).then(W=>(c.extra[M].apiPrompt=W.output,W.output)),N=JSON.stringify(c);v(!0);const S=_e(32),P=await((Y=se)==null?void 0:Y.getSetting("cloudHost"));let V;V=Fe();const ce={id:Me(),workflowID:h.id,name:r.current,createTime:Date.now(),api_prompt:JSON.stringify(D),json:N??JSON.stringify(R.graph.serialize())},de=window.location.protocol,ue=window.location.host,pe=`${de}//${ue}`,he=P+`/share_workflow_confirm/${S}?redirectUrl=${pe}`,fe=window.open(he,"Share Workflow","width=800,height=800"),J=W=>{var Q;if(W.origin===P&&W.data==="child_ready"){const me=(Q=_)==null?void 0:Q.curWorkflow;fe.postMessage({workflow:me,version:ce,nodeDefs:V,privacy:a.current},P),window.removeEventListener("message",J)}};window.addEventListener("message",J)},le=async()=>{const n=(o==null?void 0:o.images)??{};if(k){d(!0);const c=Object.values((o==null?void 0:o.images)??{}).map(D=>D.filename);if(c.length){const N=await(await We("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(N).forEach(S=>{n!=null&&n[S]&&(n[S].url=N[S])})}d(!1)}E(n)},F=(U=(B=_)==null?void 0:B.curWorkflow)==null?void 0:U.cloudID;return e.jsxs(ve,{isOpen:!0,onClose:s,size:"lg",children:[e.jsx(ye,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ke,{children:[e.jsxs(oe,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',h==null?void 0:h.name,'"']}),e.jsx(z,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:b,children:b?"Sharing":"Share"})]}),p&&e.jsxs(Le,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(p).host]})]}),e.jsx(Se,{pb:10,children:e.jsxs(T,{gap:5,children:[F==null?e.jsx(Qe,{options:Te,value:w,onChange:n=>{x(n)}}):e.jsx(Ae,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ge,{privacy:w,showEmoji:!0})}),F&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Ve,{wordBreak:"break-all",href:p+"/workflow/"+F,isExternal:!0,children:[p+"/workflow/"+F," ",e.jsx(He,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(z,{size:"sm",leftIcon:e.jsx(Je,{size:18}),onClick:()=>{var n,c;O(p+"/workflow/"+((c=(n=_)==null?void 0:n.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:n=>{j(n)},value:I,children:e.jsx(T,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(Oe,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:n=>{l(n.target.value)}}),e.jsx(oe,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((o==null?void 0:o.images)??{}).length>0&&e.jsxs(T,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Ue,{isChecked:k,onChange:()=>L(!k),fontWeight:"600",children:"Share input images"}),e.jsxs("span",{style:{color:"GrayText"},children:["If enabled your input images will be uploaded and shared to"," ",p]}),k&&e.jsx(Xe,{deps:o??null,setDeps:f,uploadingImage:y})]})]})})]})]})}function oo(){const s=new Date,i=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),r=String(s.getDate()).padStart(2,"0");return`${i}-${l}-${r}`}export{co as default};
diff --git a/dist/workspace_web/SpotlightSearch-pfa51tE-.js b/dist/workspace_web/SpotlightSearch-pfa51tE-.js
new file mode 100644
index 0000000..577d2ed
--- /dev/null
+++ b/dist/workspace_web/SpotlightSearch-pfa51tE-.js
@@ -0,0 +1 @@
+import{b as X,f as L,k as Z,o as $,e as w,r as g,j as n,g as A,Z as q,M as J,O as Q,a0 as ee,h as te}from"./input.js";import{aC as ne,aj as se,X as re,ay as T,ag as G,H as ae,j as oe,h as O,a1 as ie,x as ce,a2 as le,E as ue,k as D}from"./App-Pi18TWng.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-xcUfhAk-.js";import{V as he}from"./chunk-NTCQBYKE-6cj7iDLd.js";var[me,ge]=X({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=L(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=$(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=L(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=L(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=L(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 Ie(){const{colorMode:S}=q(),{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:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},H=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[U,W]=pe(H,300),V=e=>{I(e.target.value),e.target.value?(U(),!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 F;const j=(h.openSpotlightSearch??((F=D)==null?void 0:F.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=j[0]==="Command"?"Meta":j[0],v.current.spotlightSearchShortcutLastKey=j[j.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(J,{isOpen:!0,onClose:z,size:"xl",children:n.jsxs(Q,{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{Ie as default};
diff --git a/dist/workspace_web/SpotlightSearch-wRJMVnPo.js b/dist/workspace_web/SpotlightSearch-wRJMVnPo.js
deleted file mode 100644
index 4b502a1..0000000
--- a/dist/workspace_web/SpotlightSearch-wRJMVnPo.js
+++ /dev/null
@@ -1 +0,0 @@
-import{b as $,f as j,l as J,o as Z,h as w,r as g,j as n,g as A,$ as q,M as Q,O as X,U as ee,i as te}from"./input.js";import{aJ as ne,an as se,Z as re,aE as T,ak as G,H as ae,j as oe,h as O,a3 as ie,x as ce,a4 as le,E as ue,k as D}from"./App-eQybp91e.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-3Gq-3maw.js";import{V as he}from"./chunk-NTCQBYKE-a6jE7X_b.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=J("Input",a),{children:c,className:l,...I}=Z(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 Ie(){const{colorMode:S}=q(),{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:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},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 F;const L=(h.openSpotlightSearch??((F=D)==null?void 0:F.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:z,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{Ie as default};
diff --git a/dist/workspace_web/chunk-3RSXBRAN-LXNJ9qB5.js b/dist/workspace_web/chunk-3RSXBRAN-1feEpIXZ.js
similarity index 92%
rename from dist/workspace_web/chunk-3RSXBRAN-LXNJ9qB5.js
rename to dist/workspace_web/chunk-3RSXBRAN-1feEpIXZ.js
index 8993372..830f855 100644
--- a/dist/workspace_web/chunk-3RSXBRAN-LXNJ9qB5.js
+++ b/dist/workspace_web/chunk-3RSXBRAN-1feEpIXZ.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{ac as z}from"./App-eQybp91e.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,e as b,k as C,o as E,l as I,r as f,a3 as P}from"./input.js";import{aa as z}from"./App-Pi18TWng.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-7D6N5TE5-ZfhYDM9i.js b/dist/workspace_web/chunk-7D6N5TE5-ZfhYDM9i.js
new file mode 100644
index 0000000..c8dfa24
--- /dev/null
+++ b/dist/workspace_web/chunk-7D6N5TE5-ZfhYDM9i.js
@@ -0,0 +1 @@
+import{f as ce,j as W,r as i,y as A,g as oe,d as T,x as ye,l as r,q as m,m as re}from"./input.js";import{ae as pe}from"./App-Pi18TWng.js";var z=ce(function(n,t){const{htmlWidth:o,htmlHeight:d,alt:l,...v}=n;return W.jsx("img",{width:o,height:d,ref:t,alt:l,...v})});z.displayName="NativeImage";function Ee(e){const{loading:n,src:t,srcSet:o,onLoad:d,onError:l,crossOrigin:v,sizes:w,ignoreFallback:L}=e,[h,k]=i.useState("pending");i.useEffect(()=>{k(t?"loading":"pending")},[t]);const f=i.useRef(),I=i.useCallback(()=>{if(!t)return;y();const s=new Image;s.src=t,v&&(s.crossOrigin=v),o&&(s.srcset=o),w&&(s.sizes=w),n&&(s.loading=n),s.onload=p=>{y(),k("loaded"),d==null||d(p)},s.onerror=p=>{y(),k("failed"),l==null||l(p)},f.current=s},[t,v,o,w,d,l,n]),y=()=>{f.current&&(f.current.onload=null,f.current.onerror=null,f.current=null)};return A(()=>{if(!L)return h==="loading"&&I(),()=>{y()}},[h,I,L]),L?"loaded":h}var we=(e,n)=>e!=="loaded"&&n==="beforeLoadOrError"||e==="failed"&&n==="onError";function Le(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}var Ce=ce(function(n,t){const{fallbackSrc:o,fallback:d,src:l,srcSet:v,align:w,fit:L,loading:h,ignoreFallback:k,crossOrigin:f,fallbackStrategy:I="beforeLoadOrError",referrerPolicy:y,...s}=n,p=o!==void 0||d!==void 0,P=h!=null||k||!p,B=Ee({...n,crossOrigin:f,ignoreFallback:P}),K=we(B,I),D={ref:t,objectFit:L,objectPosition:w,...P?s:Le(s,["onError","onLoad"])};return K?d||W.jsx(oe.img,{as:z,className:"chakra-image__placeholder",src:o,...D}):W.jsx(oe.img,{as:z,src:l,srcSet:v,crossOrigin:f,loading:h,referrerPolicy:y,className:"chakra-image",...D})});Ce.displayName="Image";var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Fe=()=>typeof document<"u",se=!1,M=null,C=!1,$=!1,G=new Set;function J(e,n){G.forEach(t=>t(e,n))}var Se=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function Pe(e){return!(e.metaKey||!Se&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ie(e){C=!0,Pe(e)&&(M="keyboard",J("keyboard",e))}function S(e){if(M="pointer",e.type==="mousedown"||e.type==="pointerdown"){C=!0;const n=e.composedPath?e.composedPath()[0]:e.target;let t=!1;try{t=n.matches(":focus-visible")}catch{}if(t)return;J("pointer",e)}}function De(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Re(e){De(e)&&(C=!0,M="virtual")}function xe(e){e.target===window||e.target===document||(!C&&!$&&(M="virtual",J("virtual",e)),C=!1,$=!1)}function Me(){C=!1,$=!0}function le(){return M!=="pointer"}function Be(){if(!Fe()||se)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...t){C=!0,e.apply(this,t)},document.addEventListener("keydown",ie,!0),document.addEventListener("keyup",ie,!0),document.addEventListener("click",Re,!0),window.addEventListener("focus",xe,!0),window.addEventListener("blur",Me,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",S,!0),document.addEventListener("pointermove",S,!0),document.addEventListener("pointerup",S,!0)):(document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",S,!0),document.addEventListener("mouseup",S,!0)),se=!0}function Ke(e){Be(),e(le());const n=()=>e(le());return G.add(n),()=>{G.delete(n)}}function Oe(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}function Ue(e={}){const n=pe(e),{isDisabled:t,isReadOnly:o,isRequired:d,isInvalid:l,id:v,onBlur:w,onFocus:L,"aria-describedby":h}=n,{defaultChecked:k,isChecked:f,isFocusable:I,onChange:y,isIndeterminate:s,name:p,value:P,tabIndex:B=void 0,"aria-label":K,"aria-labelledby":D,"aria-invalid":U,...de}=e,V=Oe(de,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),q=T(y),Q=T(w),X=T(L),[O,ue]=i.useState(!1),[E,j]=i.useState(!1),[R,Y]=i.useState(!1),[x,F]=i.useState(!1);i.useEffect(()=>Ke(ue),[]);const b=i.useRef(null),[Z,fe]=i.useState(!0),[me,N]=i.useState(!!k),_=f!==void 0,c=_?f:me,ee=i.useCallback(a=>{if(o||t){a.preventDefault();return}_||N(c?a.target.checked:s?!0:a.target.checked),q==null||q(a)},[o,t,c,_,s,q]);A(()=>{b.current&&(b.current.indeterminate=!!s)},[s]),ye(()=>{t&&j(!1)},[t,j]),A(()=>{const a=b.current;if(!(a!=null&&a.form))return;const u=()=>{N(!!k)};return a.form.addEventListener("reset",u),()=>{var g;return(g=a.form)==null?void 0:g.removeEventListener("reset",u)}},[]);const te=t&&!I,ae=i.useCallback(a=>{a.key===" "&&F(!0)},[F]),ne=i.useCallback(a=>{a.key===" "&&F(!1)},[F]);A(()=>{if(!b.current)return;b.current.checked!==c&&N(b.current.checked)},[b.current]);const ve=i.useCallback((a={},u=null)=>{const g=H=>{E&&H.preventDefault(),F(!0)};return{...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o),"aria-hidden":!0,onMouseDown:m(a.onMouseDown,g),onMouseUp:m(a.onMouseUp,()=>F(!1)),onMouseEnter:m(a.onMouseEnter,()=>Y(!0)),onMouseLeave:m(a.onMouseLeave,()=>Y(!1))}},[x,c,t,E,O,R,s,l,o]),be=i.useCallback((a={},u=null)=>({...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o)}),[x,c,t,E,O,R,s,l,o]),ge=i.useCallback((a={},u=null)=>({...V,...a,ref:re(u,g=>{g&&fe(g.tagName==="LABEL")}),onClick:m(a.onClick,()=>{var g;Z||((g=b.current)==null||g.click(),requestAnimationFrame(()=>{var H;(H=b.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[V,t,c,l,Z]),he=i.useCallback((a={},u=null)=>({...a,ref:re(b,u),type:"checkbox",name:p,value:P,id:v,tabIndex:B,onChange:m(a.onChange,ee),onBlur:m(a.onBlur,Q,()=>j(!1)),onFocus:m(a.onFocus,X,()=>j(!0)),onKeyDown:m(a.onKeyDown,ae),onKeyUp:m(a.onKeyUp,ne),required:d,checked:c,disabled:te,readOnly:o,"aria-label":K,"aria-labelledby":D,"aria-invalid":U?!!U:l,"aria-describedby":h,"aria-disabled":t,style:Ie}),[p,P,v,ee,Q,X,ae,ne,d,c,te,o,K,D,U,l,h,t,B]),ke=i.useCallback((a={},u=null)=>({...a,ref:u,onMouseDown:m(a.onMouseDown,je),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[c,t,l]);return{state:{isInvalid:l,isFocused:E,isChecked:c,isActive:x,isHovered:R,isIndeterminate:s,isDisabled:t,isReadOnly:o,isRequired:d},getRootProps:ge,getCheckboxProps:ve,getIndicatorProps:be,getInputProps:he,getLabelProps:ke,htmlProps:V}}function je(e){e.preventDefault(),e.stopPropagation()}export{Ce as I,Ue as u};
diff --git a/dist/workspace_web/chunk-7D6N5TE5-lFR77IBa.js b/dist/workspace_web/chunk-7D6N5TE5-lFR77IBa.js
deleted file mode 100644
index 77cd896..0000000
--- a/dist/workspace_web/chunk-7D6N5TE5-lFR77IBa.js
+++ /dev/null
@@ -1 +0,0 @@
-import{ai as me}from"./App-eQybp91e.js";import{d as B,r as o,e as I,y as ye,n as a,s as l,m as Z}from"./input.js";var he={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},pe=()=>typeof document<"u",$=!1,w=null,m=!1,R=!1,K=new Set;function x(e,u){K.forEach(n=>n(e,u))}var ke=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function we(e){return!(e.metaKey||!ke&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ee(e){m=!0,we(e)&&(w="keyboard",x("keyboard",e))}function h(e){if(w="pointer",e.type==="mousedown"||e.type==="pointerdown"){m=!0;const u=e.composedPath?e.composedPath()[0]:e.target;let n=!1;try{n=u.matches(":focus-visible")}catch{}if(n)return;x("pointer",e)}}function Ee(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Ce(e){Ee(e)&&(m=!0,w="virtual")}function ge(e){e.target===window||e.target===document||(!m&&!R&&(w="virtual",x("virtual",e)),m=!1,R=!1)}function Le(){m=!1,R=!0}function te(){return w!=="pointer"}function Pe(){if(!pe()||$)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...n){m=!0,e.apply(this,n)},document.addEventListener("keydown",ee,!0),document.addEventListener("keyup",ee,!0),document.addEventListener("click",Ce,!0),window.addEventListener("focus",ge,!0),window.addEventListener("blur",Le,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",h,!0),document.addEventListener("pointermove",h,!0),document.addEventListener("pointerup",h,!0)):(document.addEventListener("mousedown",h,!0),document.addEventListener("mousemove",h,!0),document.addEventListener("mouseup",h,!0)),$=!0}function Se(e){Pe(),e(te());const u=()=>e(te());return K.add(u),()=>{K.delete(u)}}function Fe(e,u=[]){const n=Object.assign({},e);for(const s of u)s in n&&delete n[s];return n}function Re(e={}){const u=me(e),{isDisabled:n,isReadOnly:s,isRequired:P,isInvalid:d,id:A,onBlur:ne,onFocus:ae,"aria-describedby":H}=u,{defaultChecked:U,isChecked:V,isFocusable:oe,onChange:re,isIndeterminate:v,name:q,value:O,tabIndex:T=void 0,"aria-label":W,"aria-labelledby":_,"aria-invalid":S,...se}=e,F=Fe(se,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),D=B(re),j=B(ne),z=B(ae),[E,ie]=o.useState(!1),[b,C]=o.useState(!1),[p,G]=o.useState(!1),[k,y]=o.useState(!1);o.useEffect(()=>Se(ie),[]);const c=o.useRef(null),[N,ue]=o.useState(!0),[de,g]=o.useState(!!U),M=V!==void 0,r=M?V:de,J=o.useCallback(t=>{if(s||n){t.preventDefault();return}M||g(r?t.target.checked:v?!0:t.target.checked),D==null||D(t)},[s,n,r,M,v,D]);I(()=>{c.current&&(c.current.indeterminate=!!v)},[v]),ye(()=>{n&&C(!1)},[n,C]),I(()=>{const t=c.current;if(!(t!=null&&t.form))return;const i=()=>{g(!!U)};return t.form.addEventListener("reset",i),()=>{var f;return(f=t.form)==null?void 0:f.removeEventListener("reset",i)}},[]);const Q=n&&!oe,X=o.useCallback(t=>{t.key===" "&&y(!0)},[y]),Y=o.useCallback(t=>{t.key===" "&&y(!1)},[y]);I(()=>{if(!c.current)return;c.current.checked!==r&&g(c.current.checked)},[c.current]);const le=o.useCallback((t={},i=null)=>{const f=L=>{b&&L.preventDefault(),y(!0)};return{...t,ref:i,"data-active":a(k),"data-hover":a(p),"data-checked":a(r),"data-focus":a(b),"data-focus-visible":a(b&&E),"data-indeterminate":a(v),"data-disabled":a(n),"data-invalid":a(d),"data-readonly":a(s),"aria-hidden":!0,onMouseDown:l(t.onMouseDown,f),onMouseUp:l(t.onMouseUp,()=>y(!1)),onMouseEnter:l(t.onMouseEnter,()=>G(!0)),onMouseLeave:l(t.onMouseLeave,()=>G(!1))}},[k,r,n,b,E,p,v,d,s]),ce=o.useCallback((t={},i=null)=>({...t,ref:i,"data-active":a(k),"data-hover":a(p),"data-checked":a(r),"data-focus":a(b),"data-focus-visible":a(b&&E),"data-indeterminate":a(v),"data-disabled":a(n),"data-invalid":a(d),"data-readonly":a(s)}),[k,r,n,b,E,p,v,d,s]),fe=o.useCallback((t={},i=null)=>({...F,...t,ref:Z(i,f=>{f&&ue(f.tagName==="LABEL")}),onClick:l(t.onClick,()=>{var f;N||((f=c.current)==null||f.click(),requestAnimationFrame(()=>{var L;(L=c.current)==null||L.focus({preventScroll:!0})}))}),"data-disabled":a(n),"data-checked":a(r),"data-invalid":a(d)}),[F,n,r,d,N]),ve=o.useCallback((t={},i=null)=>({...t,ref:Z(c,i),type:"checkbox",name:q,value:O,id:A,tabIndex:T,onChange:l(t.onChange,J),onBlur:l(t.onBlur,j,()=>C(!1)),onFocus:l(t.onFocus,z,()=>C(!0)),onKeyDown:l(t.onKeyDown,X),onKeyUp:l(t.onKeyUp,Y),required:P,checked:r,disabled:Q,readOnly:s,"aria-label":W,"aria-labelledby":_,"aria-invalid":S?!!S:d,"aria-describedby":H,"aria-disabled":n,style:he}),[q,O,A,J,j,z,X,Y,P,r,Q,s,W,_,S,d,H,n,T]),be=o.useCallback((t={},i=null)=>({...t,ref:i,onMouseDown:l(t.onMouseDown,De),"data-disabled":a(n),"data-checked":a(r),"data-invalid":a(d)}),[r,n,d]);return{state:{isInvalid:d,isFocused:b,isChecked:r,isActive:k,isHovered:p,isIndeterminate:v,isDisabled:n,isReadOnly:s,isRequired:P},getRootProps:fe,getCheckboxProps:le,getIndicatorProps:ce,getInputProps:ve,getLabelProps:be,htmlProps:F}}function De(e){e.preventDefault(),e.stopPropagation()}export{Re as u};
diff --git a/dist/workspace_web/chunk-JARCRF6W-OjDz07lE.js b/dist/workspace_web/chunk-JARCRF6W-OjDz07lE.js
deleted file mode 100644
index a1b57f7..0000000
--- a/dist/workspace_web/chunk-JARCRF6W-OjDz07lE.js
+++ /dev/null
@@ -1 +0,0 @@
-import{b as D,r as p,j as t,g as i,a0 as v,f as j,l as T,o as B,H as E,h as $}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-lFR77IBa.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=p.useState(o),[e,r]=p.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=B(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:f=t.jsx(H,{}),isChecked:g,isDisabled:k=e==null?void 0:e.isDisabled,onChange:h,inputProps:w,..._}=c;let y=g;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=h;e!=null&&e.onChange&&c.value&&(b=E(e.onChange,h));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:k,isChecked:y,onChange:b}),I=M(l.isChecked),R=p.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=p.cloneElement(f,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:$("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:f,templateColumns:g,...k}=s,h={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:f,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:g};return t.jsx(i.div,{ref:n,__css:h,...k})});U.displayName="Grid";export{Q as C,U as G};
diff --git a/dist/workspace_web/chunk-JARCRF6W-sDjzfEGl.js b/dist/workspace_web/chunk-JARCRF6W-sDjzfEGl.js
new file mode 100644
index 0000000..7282868
--- /dev/null
+++ b/dist/workspace_web/chunk-JARCRF6W-sDjzfEGl.js
@@ -0,0 +1 @@
+import{b as D,r as h,j as t,g as i,$ as v,f as j,k as T,o as $,H as B,e as E}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-ZfhYDM9i.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=$(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=B(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:E("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G};
diff --git a/dist/workspace_web/chunk-NTCQBYKE-a6jE7X_b.js b/dist/workspace_web/chunk-NTCQBYKE-6cj7iDLd.js
similarity index 65%
rename from dist/workspace_web/chunk-NTCQBYKE-a6jE7X_b.js
rename to dist/workspace_web/chunk-NTCQBYKE-6cj7iDLd.js
index b658520..688f95f 100644
--- a/dist/workspace_web/chunk-NTCQBYKE-a6jE7X_b.js
+++ b/dist/workspace_web/chunk-NTCQBYKE-6cj7iDLd.js
@@ -1 +1 @@
-import{g as t}from"./App-eQybp91e.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-Pi18TWng.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/chunk-VTV6N5LE-_EaL4yE7.js b/dist/workspace_web/chunk-VTV6N5LE-K9rVd8eY.js
similarity index 75%
rename from dist/workspace_web/chunk-VTV6N5LE-_EaL4yE7.js
rename to dist/workspace_web/chunk-VTV6N5LE-K9rVd8eY.js
index 3080b86..67ccc08 100644
--- a/dist/workspace_web/chunk-VTV6N5LE-_EaL4yE7.js
+++ b/dist/workspace_web/chunk-VTV6N5LE-K9rVd8eY.js
@@ -1 +1 @@
-import{f as l,p as f,o as h,j as e,g as n,h as m,l as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-lFR77IBa.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:p,getInputProps:u,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...u({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...p()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S};
+import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-ZfhYDM9i.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S};
diff --git a/dist/workspace_web/civitUtils-8IbIESmj.js b/dist/workspace_web/civitUtils-8IbIESmj.js
new file mode 100644
index 0000000..f282d15
--- /dev/null
+++ b/dist/workspace_web/civitUtils-8IbIESmj.js
@@ -0,0 +1 @@
+import{k as m}from"./App-Pi18TWng.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function g(){return localStorage.getItem(r)}function h(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,g,h as s};
diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js
index 3c8e16f..37b2696 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-eQybp91e.js").then(e=>e.aT),__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,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});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-Pi18TWng.js").then(e=>e.aJ),__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({config:{initialColorMode:"dark",useSystemColorMode:!1},zIndices:uB,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});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{vP 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,xb as U,EB as V,os as W,Ar as X,pB as Y,Qh as Z,Xk as _,kB as a,Tp as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Be as e,pt as f,_e as g,Mx as h,SB as i,E as j,Xb as k,_v as l,If as m,Bu as n,Iu as o,mB as p,Ei as q,S as r,Gf as s,uw as t,IP as u,bB as v,Kt as w,yg as x,Bl as y,uO as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/App-eQybp91e.js","workspace_web/assets/App-JXePnJiV.css"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/App-Pi18TWng.js","workspace_web/assets/App-JXePnJiV.css"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..cdb6763
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+send2trash
diff --git a/service/media_service.py b/service/media_service.py
index 5cfe256..6281380 100644
--- a/service/media_service.py
+++ b/service/media_service.py
@@ -9,7 +9,7 @@ from .model_manager.model_preview import get_thumbnail_for_image_file
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp']
video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv']
-API_URL = 'https://www.nodecafe.org/api/image/upload'
+API_URL = 'https://www.nodecafe.co/api/image/upload'
def view_media(filename, isPreview = False, isInput = False):
if not filename:
return web.Response(status=404)
diff --git a/service/twoway_sync_folder_service.py b/service/twoway_sync_folder_service.py
index efdc7d0..e14a81a 100644
--- a/service/twoway_sync_folder_service.py
+++ b/service/twoway_sync_folder_service.py
@@ -5,6 +5,10 @@ import os
from pathlib import Path
import server
from .db_service import get_my_workflows_dir
+try:
+ from send2trash import send2trash
+except ImportError:
+ send2trash = None
@server.PromptServer.instance.routes.post('/workspace/folder/create')
async def create_folder(request):
@@ -31,7 +35,11 @@ def delete_folder_sync(reqJson):
folder_path = reqJson.get('path')
folder_path = os.path.join(get_my_workflows_dir(), folder_path)
try:
- shutil.rmtree(folder_path)
+ if send2trash:
+ send2trash(folder_path)
+ else:
+ shutil.rmtree(folder_path)
+ print("❌⛔️send2trash is not available. Deleting file permanently. Please `pip install send2trash`")
return {"success": True}
except Exception as e:
return {"success": False, "error": str(e)}
diff --git a/ui/src/App.tsx b/ui/src/App.tsx
index a98dc5d..ce3c1ef 100644
--- a/ui/src/App.tsx
+++ b/ui/src/App.tsx
@@ -157,7 +157,7 @@ export default function App() {
if (id) {
const flow = await workflowsTable?.get(id);
flow && setCurFlowIDAndName(flow);
- if (flow && flow.json != latestWf) {
+ if (!flow?.saveLock && flow && flow.json != latestWf) {
setIsDirty(true);
}
}
@@ -167,47 +167,45 @@ export default function App() {
}
fetchApi("/workspace/deduplicate_workflow_ids");
const twoway = await userSettingsTable?.getSetting("twoWaySync");
- !twoway &&
- indexdb.cache.get(UPGRADE_TO_2WAY_SYNC_KEY).then(async (value) => {
- if (value?.value !== "true") {
- const workflowsCount = await indexdb.workflows.count();
- if (workflowsCount == 0) {
- // empty workflows, enable 2way sync
- await userSettingsTable?.upsert({ twoWaySync: true });
- await indexdb.cache.put({
- id: UPGRADE_TO_2WAY_SYNC_KEY,
- value: "true",
- });
- return;
- }
- const myWorkflowsDir =
- await userSettingsTable?.getSetting("myWorkflowsDir");
- showDialog(
- ,
- [
- {
- label: "I have downloaded all my workflows and ready to enable",
- onClick: async () => {
- await userSettingsTable?.upsert({ twoWaySync: true });
- if (await userSettingsTable?.getSetting("twoWaySync")) {
- indexdb.cache.put({
- id: UPGRADE_TO_2WAY_SYNC_KEY,
- value: "true",
- });
- location.reload();
- }
- },
- colorScheme: "red",
- },
- ],
- {
- closeOnOverlayClick: false,
+
+ if (!twoway) {
+ const workflowsCount = await indexdb.workflows.count();
+ if (workflowsCount == 0) {
+ // empty workflows, enable 2way sync
+ await userSettingsTable?.upsert({ twoWaySync: true });
+ await indexdb.cache.put({
+ id: UPGRADE_TO_2WAY_SYNC_KEY,
+ value: "true",
+ });
+ return;
+ }
+ const myWorkflowsDir =
+ await userSettingsTable?.getSetting("myWorkflowsDir");
+ showDialog(
+ ,
+ [
+ {
+ label: "I have downloaded all my workflows and ready to enable",
+ onClick: async () => {
+ await userSettingsTable?.upsert({ twoWaySync: true });
+ if (await userSettingsTable?.getSetting("twoWaySync")) {
+ indexdb.cache.put({
+ id: UPGRADE_TO_2WAY_SYNC_KEY,
+ value: "true",
+ });
+ location.reload();
+ }
},
- );
- }
- });
+ colorScheme: "red",
+ },
+ ],
+ {
+ closeOnOverlayClick: false,
+ },
+ );
+ }
};
const loadWorkflowIDImpl = async (id: string, versionID?: string | null) => {
diff --git a/ui/src/components/DropdownTitle.tsx b/ui/src/components/DropdownTitle.tsx
index 6e3e5ca..1783d75 100644
--- a/ui/src/components/DropdownTitle.tsx
+++ b/ui/src/components/DropdownTitle.tsx
@@ -44,7 +44,6 @@ import CreateVersionDialog from "./CreateVersionDialog";
import HoverMenu from "./HoverMenu";
const ShareDialog = lazy(() => import("../share/ShareDialog"));
import { TOPBAR_BUTTON_HEIGHT } from "../const";
-import DownloadSpaceJsonDialog from "../spacejson/DownloadSpaceJsonDialog";
import { downloadJsonFile } from "../utils/downloadJsonFile";
import { SharedTopbarButton } from "../share/SharedTopbarButton";
import { app } from "../utils/comfyapp";
@@ -186,13 +185,6 @@ export default function DropdownTitle() {
>
Versions History
- {/* */}