>=1;if(v!==0?(z&=v-1,z+=v):z=0,T++,--X[P]==0){if(P===K)break;P=d[p+y[T]]}if($>>7)]}function te(S,F){S.pending_buf[S.pending++]=255&F,S.pending_buf[S.pending++]=F>>>8&255}function X(S,F,V){S.bi_valid>m-V?(S.bi_buf|=F<>m-S.bi_valid,S.bi_valid+=V-m):(S.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ge(S,F,V){var Z,M,Q=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)Q[Z]=re=re+V[Z-1]<<1;for(M=0;M<=F;M++){var ee=S[2*M+1];ee!==0&&(S[2*M]=me(Q[ee]++,ee))}}function ie(S){var F;for(F=0;F>1;1<=V;V--)ye(S,Q,V);for(M=se;V=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ye(S,Q,1),Z=S.heap[1],S.heap[--S.heap_max]=V,S.heap[--S.heap_max]=Z,Q[2*M]=Q[2*V]+Q[2*Z],S.depth[M]=(S.depth[V]>=S.depth[Z]?S.depth[V]:S.depth[Z])+1,Q[2*V+1]=Q[2*Z+1]=M,S.heap[1]=M++,ye(S,Q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(he,Ye){var wn,st,bn,je,Yn,oo,ft=Ye.dyn_tree,Us=Ye.max_code,dl=Ye.stat_desc.static_tree,fl=Ye.stat_desc.has_stree,hl=Ye.stat_desc.extra_bits,Ks=Ye.stat_desc.extra_base,_n=Ye.stat_desc.max_length,Jn=0;for(je=0;je<=y;je++)he.bl_count[je]=0;for(ft[2*he.heap[he.heap_max]+1]=0,wn=he.heap_max+1;wn>=7;M>>=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)<=M&&(M=Q)):M=Q=V+5,V+4<=M&&F!==-1?I(S,F,V,Z):S.strategy===4||Q===M?(X(S,2+(Z?1:0),3),pe(S,q,P)):(X(S,4+(Z?1:0),3),function(ee,se,ve,he){var Ye;for(X(ee,se-257,5),X(ee,ve-1,5),X(ee,he-4,4),Ye=0;Ye>>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&V,S.last_lit++,F===0?S.dyn_ltree[2*V]++:(S.matches++,F--,S.dyn_ltree[2*(b[V]+d+1)]++,S.dyn_dtree[2*B(F)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){X(S,2,3),Y(S,_,q),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,f={},w=!1,h=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,k=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=k,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){v(x.data)},function(x){c.port2.postMessage(x)}):h&&"onreadystatechange"in h.createElement("script")?(u=h.documentElement,function(x){var k=h.createElement("script");k.onreadystatechange=function(){v(x),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(x){setTimeout(v,0,x)},y.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var k=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ul);var np=ul.exports;const rp=ka(np);async function op(t){let e="",n=t;for(;n!=null;){const r=await(qe==null?void 0:qe.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Tp(t){if(await(J==null?void 0:J.getSetting("twoWaySync")))return await St.genFilesCountInFolder(t)??0;const n=await(H==null?void 0:H.listAll())??[],r=await(qe==null?void 0:qe.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}const sp=async t=>{const e=`ComfyUI workspace workflows ${Yf(Date.now())}`,n=new rp,r=await(J==null?void 0:J.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await op(o.parentFolderID??null).then(async a=>At(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 ap({myWorkflowsDir:t}){return C.jsxs(It,{gap:3,children:[C.jsx(hs,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),C.jsx("p",{children:"Your workflows will be synced to and from path:"}),C.jsx("p",{children:C.jsx("b",{children:t})}),C.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"]}),C.jsxs("p",{children:[C.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."]}),C.jsx(Le,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(H==null?void 0:H.listAll());sp(e??[])},children:"👉 Download All My Workflows"})]})}const ip=ja.lazy(()=>Ft(()=>import("./RecentFilesDrawer-efSIwVKr.js"),__vite__mapDeps([15,1,9,2,14,16,13,5]))),lp=ja.lazy(()=>Ft(()=>import("./GalleryModal-DmDbPyXZ.js"),__vite__mapDeps([17,1,16,13,2,10,9,4])));function cp(){const[t,e]=j.useState(null),[n,r]=j.useState("root"),[o,s]=j.useState(!0),[i,a]=j.useState(null),l=j.useRef(null),[u,c]=j.useState(null),[d,p]=j.useState(!1),f=j.useRef(null),{showDialog:w}=Pa(),[h,y]=j.useState(!1);j.useRef(!1);const m=ds(),[v,_]=tp(null),x=j.useCallback(async($=!1)=>{var G;const A=H==null?void 0:H.curWorkflow;if(A){if(!$&&((G=H==null?void 0:H.curWorkflow)!=null&&G.saveLock)){m({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const L=JSON.stringify(Pe.graph.serialize());await Promise.all([H==null?void 0:H.updateFlow(A.id,{json:L}),Ve==null?void 0:Ve.create({workflowID:A.id,json:L,isAutoSave:!1})]),p(!1)}},[]),k=async()=>{var A,G;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 L=(A=H==null?void 0:H.curWorkflow)==null?void 0:A.id;if(L==null)return;const ne=(G=await(H==null?void 0:H.get(L)))==null?void 0:G.json;ne?(H==null||H.updateCurWorkflow({...H.curWorkflow,json:ne}),await Pe.loadGraphData(JSON.parse(ne)),p(!1)):alert("Error: No last saved version found")}},O=$=>{const A=($==null?void 0:$.id)??null;if(H==null||H.updateCurWorkflow($),l.current=A,a(A),e(($==null?void 0:$.name)??""),A==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(wa()){const G=nl(A);window.location.hash=G,document.title=$.name+" - ComfyUI"}else localStorage.setItem("curFlowID",A),document.title="ComfyUI - "+$.name;$&&(H==null||H.updateLastOpenedTime($.id))},E=async()=>{localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await ah()}catch(L){console.error("error loading db",L)}s(!1);const $=wa();if($!=null&&N($),ke("/workspace/deduplicate_workflow_ids"),ke("/workspace/get_os").then(L=>L.json()).then(L=>{L.os&&(Ls.os=L.os)}),!await(J==null?void 0:J.getSetting("twoWaySync"))){if(await ce.workflows.count()==0){await(J==null?void 0:J.upsert({twoWaySync:!0})),await ce.cache.put({id:ba,value:"true"});return}const ne=await(J==null?void 0:J.getSetting("myWorkflowsDir"));w(C.jsx(ap,{myWorkflowsDir:ne??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(J==null?void 0:J.upsert({twoWaySync:!0})),await(J==null?void 0:J.getSetting("twoWaySync"))&&(ce.cache.put({id:ba,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}const G=localStorage.getItem("workspace_manager_shareKey");if(G){const L=Ah(G);L&&c({shareKey:L,username:null})}},N=async($,A)=>{if(Pe.graph==null)return;const G=await(H==null?void 0:H.get($));if(G==null){alert("Error: Workflow not found! id: "+$),O(null);return}const L=A?await(De==null?void 0:De.get(A)):null;Pe.ui.dialog.close(),L?(_(L),O({...G,json:L.json}),Pe.loadGraphData(JSON.parse(L.json))):(O(G),_(null),Pe.loadGraphData(JSON.parse(G.json))),r("root"),d&&p(!1)},D=async($,A,G=!1)=>{var L;if($===null){O(null),Pe.graph.clear();return}if(!d||G||(H==null?void 0:H.curWorkflow)==null||(L=J==null?void 0:J.settings)!=null&&L.disableUnsavedWarning){N($,A);return}R($)},R=async $=>{var G;const A=[$?{label:"Open in new tab",icon:C.jsx(gh,{}),onClick:()=>{Qf($)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await x(),$&&N($)}}];A.push({label:"Discard",colorScheme:"red",onClick:async()=>{$&&N($)}}),w(`Please save or discard your changes to "${(G=H==null?void 0:H.curWorkflow)==null?void 0:G.name}" before leaving, or your changes will be lost.`,A)},q=async $=>{const A=($==null?void 0:$.json)??JSON.stringify(rl),G=await(H==null?void 0:H.createFlow({json:A,name:$==null?void 0:$.name}));G&&await D(G.id),r("root")},P=async($,A=!1)=>{const G=$.split("/").pop()??$;A?x():q({name:G});const L=await fetch(Xf($)),ne=await L.blob(),z=new File([ne],G,{type:L.headers.get("Content-Type")||""});await Pe.handleFile(z),r("root")},T=async($,A)=>{const G=await(H==null?void 0:H.get($));if(G==null)return;const L=await(H==null?void 0:H.createFlow({json:G.json,name:A||G.name,parentFolderID:G.parentFolderID}));L&&await D(L.id)},b=j.useCallback($=>{if(l.current==null)return;let A=$.filename;$.subfolder!=null&&$.subfolder!==""&&(A=$.subfolder+"/"+A),Ht==null||Ht.create({workflowID:l.current,localPath:A})},[]),K=j.useCallback(()=>{r("root")},[]);return j.useEffect(()=>{E(),y(!0);const $=A=>{var G,L,ne,z,B,te;(ne=(L=(G=A.detail)==null?void 0:G.output)==null?void 0:L.images)==null||ne.forEach(X=>{X.type==="output"&&b(X)}),(te=(B=(z=A.detail)==null?void 0:z.output)==null?void 0:B.gifs)==null||te.forEach(X=>{X.type==="output"&&b(X)})};return Ir.addEventListener("executed",$),()=>{window.removeEventListener("executed",$)}},[]),o?null:C.jsx(ot.Provider,{value:{curFlowID:i,onDuplicateWorkflow:T,loadWorkflowID:D,discardUnsavedChanges:k,saveCurWorkflow:x,isDirty:d,setIsDirty:p,loadNewWorkflow:q,loadFilePath:P,setRoute:r,route:n,curVersion:v,setCurVersion:_,setCurFlowIDAndName:O,session:u,updateSession:c},children:C.jsx("div",{ref:f,className:"workspace_manager",children:C.jsxs(Sa,{containerRef:f,children:[C.jsxs(Ot,{style:{position:"absolute",top:0,right:0,left:0},zIndex:eh,draggable:!1,children:[C.jsx(Jh,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&C.jsx(j.Suspense,{children:C.jsx(ip,{onClose:K,onClickNewFlow:()=>{q(),r("root")}})}),n==="gallery"&&C.jsx(j.Suspense,{children:C.jsx(lp,{onclose:()=>r("root")})})]}),C.jsx(Xh,{})]})})})}const Bp=Object.freeze(Object.defineProperty({__proto__:null,default:cp},Symbol.toStringTag,{value:"Module"}));export{il as $,_r as A,Ot as B,xp as C,Dh as D,qf as E,on as F,wh as G,Lt as H,yn as I,qe as J,Gr as K,Yr as L,ci as M,Zr as N,Ch as O,rl as P,Tp as Q,Ap as R,hd as S,mt as T,gr as U,Ip as V,ot as W,sh as X,_p as Y,gh as Z,Qf as _,pp as a,xh as a0,ke as a1,Ht as a2,Yf as a3,lt as a4,Pe as a5,Gl as a6,eh as a7,yp as a8,wr as a9,tp as aA,rh as aB,Op as aC,zs as aD,fs as aE,Bh as aF,Fp as aG,Np as aH,Rh as aI,Th as aJ,Rp as aK,Bp as aL,kp as aa,Ra as ab,nc as ac,Cp as ad,hs as ae,rn as af,rc as ag,Te as ah,Sp as ai,Ep as aj,Rl as ak,qn as al,Ss as am,ce as an,vp as ao,Pp as ap,jp as aq,gp as ar,Ir as as,wp as at,xc as au,di as av,ui as aw,mi as ax,hi as ay,Dp as az,fp as b,hp as c,Re as d,ds as e,It as f,Vt as g,J as h,ap as i,Zd as j,to as k,Nn as l,kc as m,mp as n,bp as o,ko as p,Es as q,Cs as r,Nh as s,xt as t,Xr as u,vh as v,H as w,Oh as x,sp as y,yh as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
- __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-g_a6xMAM.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-wlKuxWhy.js","workspace_web/civitUtils-T1Lq3reo.js","workspace_web/chunk-VTV6N5LE-qccSGxq6.js","workspace_web/IconCopy-zZpZ6D5h.js","workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-jjabvfOI.js","workspace_web/chunk-JARCRF6W-UTrQeKCZ.js","workspace_web/chunk-3RSXBRAN-oKoElBXY.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-T7ZdSk0R.js","workspace_web/IconSearch-hyGkJAd5.js","workspace_web/chunk-NTCQBYKE-vNLNCBtA.js","workspace_web/RecentFilesDrawer-GvndxTNj.js","workspace_web/MediaPreview-46fgYP_n.js","workspace_web/GalleryModal-bkUIdDKq.js"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-DSSo_bep.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-gOmt0HWF.js","workspace_web/civitUtils-TPBejtrP.js","workspace_web/chunk-VTV6N5LE-VcPf7MxV.js","workspace_web/IconCopy-RhFbFhX0.js","workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-d0zTxQle.js","workspace_web/chunk-JARCRF6W-1gGfj837.js","workspace_web/chunk-3RSXBRAN-WBOq6SL0.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-rjI_Y8hu.js","workspace_web/IconSearch-srLS9f0l.js","workspace_web/chunk-NTCQBYKE-ROuYoItA.js","workspace_web/RecentFilesDrawer-efSIwVKr.js","workspace_web/MediaPreview-VRNiVJ5t.js","workspace_web/GalleryModal-DmDbPyXZ.js"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file
diff --git a/dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js b/dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js
similarity index 93%
rename from dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js
rename to dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js
index 9e33788..b45ce51 100644
--- a/dist/workspace_web/AppIsDirtyEventListener-4Wpnq-tF.js
+++ b/dist/workspace_web/AppIsDirtyEventListener-XYtSk7Rv.js
@@ -1 +1 @@
-import{r as l}from"./input.js";import{W as S,a4 as r,ag as w,w as p,E as f,ah as _,ai as C}from"./App-ZTJclgGW.js";import{u as b}from"./useDebounceFn-ld478fd0.js";function R(){const{isDirty:d,setIsDirty:h,setRoute:g,saveCurWorkflow:v,setCurFlowIDAndName:k}=l.useContext(S),E=l.useRef(d);l.useEffect(()=>{E.current=d},[d]),l.useEffect(()=>{const c=e=>{var n;if(document.visibilityState==="hidden")return;const t=C(e);if(t)switch(t===f.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:t}})),t){case f.SAVE:v();break;case f.SAVE_AS:g("saveAsModal");break;case f.openSpotlightSearch:g("spotlightSearch");break}else(n=e.target)!=null&&n.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},u=async()=>{var t,n,a,i;if(!((t=r)!=null&&t.graph)){console.error("🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()");return}const e=(a=(n=r.graph.extra)==null?void 0:n[w])==null?void 0:a.id;if(e){const s=await((i=p)==null?void 0:i.get(e));s&&k(s),!(s!=null&&s.saveLock)&&s&&s.json!==JSON.stringify(r.graph.serialize())&&h(!0)}},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,n,a,i;const e=(n=(t=r.graph.extra)==null?void 0:t[w])==null?void 0:n.id;(e==null||e!=((i=(a=p)==null?void 0:a.curWorkflow)==null?void 0:i.id))&&k(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),u(),()=>{document.removeEventListener("keydown",c)}},[]);const y=async()=>{var u,o,e,t;if((o=(u=p)==null?void 0:u.curWorkflow)!=null&&o.saveLock||E.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((t=(e=p)==null?void 0:e.curWorkflow)==null?void 0:t.json)&&h(!0)},[m,D]=b(y,900);return null}export{R as default};
+import{r as l}from"./input.js";import{W as S,a5 as r,ah as w,w as p,E as f,ai as _,aj as C}from"./App-9GIQJeUY.js";import{u as b}from"./useDebounceFn-ld478fd0.js";function R(){const{isDirty:d,setIsDirty:h,setRoute:g,saveCurWorkflow:v,setCurFlowIDAndName:k}=l.useContext(S),E=l.useRef(d);l.useEffect(()=>{E.current=d},[d]),l.useEffect(()=>{const c=e=>{var n;if(document.visibilityState==="hidden")return;const t=C(e);if(t)switch(t===f.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:t}})),t){case f.SAVE:v();break;case f.SAVE_AS:g("saveAsModal");break;case f.openSpotlightSearch:g("spotlightSearch");break}else(n=e.target)!=null&&n.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},u=async()=>{var t,n,a,i;if(!((t=r)!=null&&t.graph)){console.error("🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()");return}const e=(a=(n=r.graph.extra)==null?void 0:n[w])==null?void 0:a.id;if(e){const s=await((i=p)==null?void 0:i.get(e));s&&k(s),!(s!=null&&s.saveLock)&&s&&s.json!==JSON.stringify(r.graph.serialize())&&h(!0)}},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,n,a,i;const e=(n=(t=r.graph.extra)==null?void 0:t[w])==null?void 0:n.id;(e==null||e!=((i=(a=p)==null?void 0:a.curWorkflow)==null?void 0:i.id))&&k(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),u(),()=>{document.removeEventListener("keydown",c)}},[]);const y=async()=>{var u,o,e,t;if((o=(u=p)==null?void 0:u.curWorkflow)!=null&&o.saveLock||E.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((t=(e=p)==null?void 0:e.curWorkflow)==null?void 0:t.json)&&h(!0)},[m,D]=b(y,900);return null}export{R as default};
diff --git a/dist/workspace_web/GalleryModal-bkUIdDKq.js b/dist/workspace_web/GalleryModal-DmDbPyXZ.js
similarity index 98%
rename from dist/workspace_web/GalleryModal-bkUIdDKq.js
rename to dist/workspace_web/GalleryModal-DmDbPyXZ.js
index adc2f75..70099ad 100644
--- a/dist/workspace_web/GalleryModal-bkUIdDKq.js
+++ b/dist/workspace_web/GalleryModal-DmDbPyXZ.js
@@ -1 +1 @@
-import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Wt,o as ct,E as Kt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,T as qt,N as Jt,U as Qt,Q as en,O as tn}from"./input.js";import{aa as nn,ab as sn,d as Re,F as m,ac as rn,l as E,I as on,f as Ee,B as ht,T as K,W as oe,a4 as tt,H as Y,w as W,g as D,v as ft,a2 as xt,O as pt,a1 as R,ad as an,x as ln}from"./App-ZTJclgGW.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-46fgYP_n.js";import{I as bn}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{S as jn}from"./chunk-3RSXBRAN-oKoElBXY.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-qccSGxq6.js";import"./IconSearch-hyGkJAd5.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,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.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(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=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 j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,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 x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(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 Dn(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,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(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:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(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,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=Kn(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:Wn(t,.1)}}var Hn=e=>e*1e3;function Wn(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 Kn(...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),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,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,g=>{n(f=>[...f.slice(0,u),g,...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:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({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||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,We]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),Ke=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:We,"data-disabled":$(f),style:{...h.style,...qe}}),[f,We,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,Ke),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,Ke]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,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=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Wt("Slider",n),a=ct(n),{direction:l}=Kt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{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=B((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=B((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=B((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 ls=B((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})});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=B((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(O.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(E,{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(E,{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 ze=({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(E,{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(ze,{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(ze,{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(ze,{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(K,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.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=[],De=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([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},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:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&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=W)==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(K,{children:e==null?void 0:e.localPath}),r.jsx(D,{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(E,{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(K,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{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=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=W)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{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=W)==null?void 0:i.updateMetaInfo(W.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=R)==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=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(K,{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(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{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=R)==null?void 0:g.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=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==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(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([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=W)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},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:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(K,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{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:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default};
+import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Wt,o as ct,E as Kt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,T as qt,N as Jt,U as Qt,Q as en,O as tn}from"./input.js";import{ab as nn,ac as sn,d as Re,F as m,ad as rn,l as E,I as on,f as Ee,B as ht,T as K,W as oe,a5 as tt,H as Y,w as W,g as D,v as ft,a3 as xt,O as pt,a2 as R,ae as an,x as ln}from"./App-9GIQJeUY.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-VRNiVJ5t.js";import{I as bn}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{S as jn}from"./chunk-3RSXBRAN-WBOq6SL0.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-1gGfj837.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-VcPf7MxV.js";import"./IconSearch-srLS9f0l.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,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.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(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=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 j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,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 x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(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 Dn(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,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(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:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(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,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=Kn(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:Wn(t,.1)}}var Hn=e=>e*1e3;function Wn(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 Kn(...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),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,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,g=>{n(f=>[...f.slice(0,u),g,...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:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({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||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,We]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),Ke=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:We,"data-disabled":$(f),style:{...h.style,...qe}}),[f,We,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,Ke),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,Ke]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,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=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Wt("Slider",n),a=ct(n),{direction:l}=Kt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{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=B((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=B((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=B((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 ls=B((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})});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=B((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(O.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(E,{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(E,{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 ze=({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(E,{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(ze,{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(ze,{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(ze,{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(K,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.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=[],De=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([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},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:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&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=W)==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(K,{children:e==null?void 0:e.localPath}),r.jsx(D,{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(E,{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(K,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{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=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=W)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{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=W)==null?void 0:i.updateMetaInfo(W.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=R)==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=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(K,{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(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{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=R)==null?void 0:g.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=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==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(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([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=W)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},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:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(K,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{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:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default};
diff --git a/dist/workspace_web/IconCopy-zZpZ6D5h.js b/dist/workspace_web/IconCopy-RhFbFhX0.js
similarity index 83%
rename from dist/workspace_web/IconCopy-zZpZ6D5h.js
rename to dist/workspace_web/IconCopy-RhFbFhX0.js
index 6357199..5791232 100644
--- a/dist/workspace_web/IconCopy-zZpZ6D5h.js
+++ b/dist/workspace_web/IconCopy-RhFbFhX0.js
@@ -1 +1 @@
-import{d as a}from"./App-ZTJclgGW.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-9GIQJeUY.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-hyGkJAd5.js b/dist/workspace_web/IconSearch-srLS9f0l.js
similarity index 67%
rename from dist/workspace_web/IconSearch-hyGkJAd5.js
rename to dist/workspace_web/IconSearch-srLS9f0l.js
index 84d030e..eb0ab2d 100644
--- a/dist/workspace_web/IconSearch-hyGkJAd5.js
+++ b/dist/workspace_web/IconSearch-srLS9f0l.js
@@ -1 +1 @@
-import{d as a}from"./App-ZTJclgGW.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-9GIQJeUY.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/MediaPreview-46fgYP_n.js b/dist/workspace_web/MediaPreview-VRNiVJ5t.js
similarity index 98%
rename from dist/workspace_web/MediaPreview-46fgYP_n.js
rename to dist/workspace_web/MediaPreview-VRNiVJ5t.js
index 3c163f1..abc1439 100644
--- a/dist/workspace_web/MediaPreview-46fgYP_n.js
+++ b/dist/workspace_web/MediaPreview-VRNiVJ5t.js
@@ -1 +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{ae as Ge,af as We,d as Le,B as qe,l as ze,x as He,I as Xe,ac as $e}from"./App-ZTJclgGW.js";import{I as Ye}from"./IconSearch-hyGkJAd5.js";import{I as Je}from"./chunk-7D6N5TE5-wlKuxWhy.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:""}),y=typeof i<"u",h=y?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(y||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,y,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]),y=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:y,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:y="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 x=z(n.currentTarget.value);U(q(x)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,x,C;te==null||te(n),L.current&&(n.target.selectionStart=(x=L.current.start)!=null?x:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),xe=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,x=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[x];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},ye=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,x;const M=((x=(p=E.current)==null?void 0:p.ownerDocument)!=null?x: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 x=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var x,C,M,O;return{name:k,inputMode:y,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(x=n.readOnly)!=null?x: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":ye,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,xe),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,y,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,ye,he,xe,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[y]=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),y=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(y);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};
+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{af as Ge,ag as We,d as Le,B as qe,l as ze,x as He,I as Xe,ad as $e}from"./App-9GIQJeUY.js";import{I as Ye}from"./IconSearch-srLS9f0l.js";import{I as Je}from"./chunk-7D6N5TE5-gOmt0HWF.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:""}),y=typeof i<"u",h=y?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(y||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,y,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]),y=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:y,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:y="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 x=z(n.currentTarget.value);U(q(x)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,x,C;te==null||te(n),L.current&&(n.target.selectionStart=(x=L.current.start)!=null?x:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),xe=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,x=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[x];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},ye=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,x;const M=((x=(p=E.current)==null?void 0:p.ownerDocument)!=null?x: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 x=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const x=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||x||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:x,"aria-disabled":se(x)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var x,C,M,O;return{name:k,inputMode:y,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(x=n.readOnly)!=null?x: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":ye,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,xe),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,y,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,ye,he,xe,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[y]=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),y=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(y);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/ModelManagerTopbar-jjabvfOI.js b/dist/workspace_web/ModelManagerTopbar-d0zTxQle.js
similarity index 98%
rename from dist/workspace_web/ModelManagerTopbar-jjabvfOI.js
rename to dist/workspace_web/ModelManagerTopbar-d0zTxQle.js
index 78d4d72..34c2b61 100644
--- a/dist/workspace_web/ModelManagerTopbar-jjabvfOI.js
+++ b/dist/workspace_web/ModelManagerTopbar-d0zTxQle.js
@@ -1 +1 @@
-import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as qe,k as Ye,h as A,a0 as ae,P as Qe,a1 as Je,T as ke,a2 as Xe,U as Ie,O as Le,R as Ze,Z as et,M as tt,N as st,Q as nt}from"./input.js";import{aj as ot,m as it,ak as rt,al as at,am as P,B as oe,F as W,T as D,g as ie,W as Ee,an as lt,h as H,a4 as U,a5 as Ae,a6 as ct,ad as Ne,I as X,H as $,ao as De,ap as xe,f as q,v as dt,aq as Te,e as Fe,ar as ye,as as ht,at as Pe,au as ut,av as mt,aw as ft,ax as pt,ay as gt,az as xt,aA as ee,aB as yt,aC as wt}from"./App-ZTJclgGW.js";import{f as le,s as vt,g as jt}from"./civitUtils-T1Lq3reo.js";import{I as Oe}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-oKoElBXY.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...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:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(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:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(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 i=="function"?i(e,l):r})(),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:r,isIndeterminate:i,role:a,...c}=t,l=kt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=qe(t),M=Ye("Progress",t),b=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${bt} 1s linear infinite`},T={...!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(B.div,{ref:e,borderRadius:b,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:b,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(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 Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=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 r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.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,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}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(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(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=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=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 r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(b[w+1]|b[w])<<1|1|b[w+1]),y[w]&Y&&(k=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),k<=g)){if(g=k,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;b=y}const T={isMatch:p>=0,score:Math.max(.001,k)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:b,indices:k}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=b,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};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 G{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){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.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))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&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:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.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 m=await le(t.file_hash),u=m.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:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[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(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{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(D,{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}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Yt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{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"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(b=>b.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(b=>b.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,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(Ht,{list:u}),c&&n.jsx(W,{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 r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.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,r,i,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((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{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(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{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(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{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($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.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})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{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[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();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(D,{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(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(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(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.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:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,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(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{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:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&Y(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=k.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=k.current)==null?void 0:fe.id}`,_=(pe=k.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),b(void 0),j()},z=async(y,w)=>{const S=T[w.type];b(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.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($,{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($,{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&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,k.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.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}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.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{fs as default};
+import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as qe,k as Ye,h as A,a0 as ae,P as Qe,a1 as Je,T as ke,a2 as Xe,U as Ie,O as Le,R as Ze,Z as et,M as tt,N as st,Q as nt}from"./input.js";import{ak as ot,m as it,al as rt,am as at,an as P,B as oe,F as W,T as D,g as ie,W as Ee,ao as lt,h as H,a5 as U,a6 as Ae,a7 as ct,ae as Ne,I as X,H as $,ap as De,aq as xe,f as q,v as dt,ar as Te,e as Fe,as as ye,at as ht,au as Pe,av as ut,aw as mt,ax as ft,ay as pt,az as gt,aA as xt,aB as ee,aC as yt,aD as wt}from"./App-9GIQJeUY.js";import{f as le,s as vt,g as jt}from"./civitUtils-TPBejtrP.js";import{I as Oe}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-1gGfj837.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-WBOq6SL0.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...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:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(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:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(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 i=="function"?i(e,l):r})(),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:r,isIndeterminate:i,role:a,...c}=t,l=kt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=qe(t),M=Ye("Progress",t),b=d??((s=M.track)==null?void 0:s.borderRadius),k={animation:`${bt} 1s linear infinite`},T={...!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(B.div,{ref:e,borderRadius:b,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:b,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(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 Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=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 r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.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,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}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(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(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=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=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 r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(b[w+1]|b[w])<<1|1|b[w+1]),y[w]&Y&&(k=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),k<=g)){if(g=k,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;b=y}const T={isMatch:p>=0,score:Math.max(.001,k)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:b,indices:k}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=b,M&&k&&(h=[...h,...k])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};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 G{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){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.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))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&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:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.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 m=await le(t.file_hash),u=m.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:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[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(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{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(D,{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}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Yt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{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"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(b=>b.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(b=>b.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,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(Ht,{list:u}),c&&n.jsx(W,{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 r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.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,r,i,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((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{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(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{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(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{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($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.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})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{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[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();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(D,{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(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(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(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.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:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,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(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{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:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&Y(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=k.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=k.current)==null?void 0:fe.id}`,_=(pe=k.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=k.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),b(void 0),j()},z=async(y,w)=>{const S=T[w.type];b(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.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($,{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($,{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&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,k.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.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}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.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{fs as default};
diff --git a/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js b/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js
deleted file mode 100644
index b8fd654..0000000
--- a/dist/workspace_web/RecentFilesDrawer-GvndxTNj.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import{f as J,E as Ze,j as e,Y as Ye,e as re,g as pe,r,V as ge,h as W,M as me,T as fe,N as xe,U as ye,Q as je,O as we,Z as ve,R as Xe}from"./input.js";import{m as Te,u as We,a as qe,b as Je,c as Qe,S as et,M as tt,d as T,e as Y,E as de,f as B,T as L,H as N,g as R,I as Q,h as C,R as G,i as st,j as be,B as _,F as U,k as nt,l as A,n as Ie,o as at,W as le,s as ot,p as it,q as ee,r as te,t as P,v as rt,D as Ne,w as O,x as Pe,y as lt,z as ke,A as ct,C as dt,G as Ae,J as $,K as ut,L as ht,N as pt,O as gt,P as mt,Q as ft,U as xt,V as De,X as Z,Y as he,Z as yt,_ as jt,$ as Re,a0 as wt,a1 as vt,a2 as kt,a3 as q,a4 as ie,a5 as St,a6 as Ct,a7 as bt,a8 as ue,a9 as It}from"./App-ZTJclgGW.js";import{G as Dt,C as se}from"./chunk-JARCRF6W-UTrQeKCZ.js";import{V as _e}from"./chunk-NTCQBYKE-vNLNCBtA.js";import{N as Ft,a as Mt,g as Et,I as Ot,M as zt,u as Lt,S as Tt}from"./MediaPreview-46fgYP_n.js";import{I as Wt}from"./IconCopy-zZpZ6D5h.js";import"./chunk-7D6N5TE5-wlKuxWhy.js";import"./IconSearch-hyGkJAd5.js";var Be=J(function(t,i){const{columns:l,spacingX:c,spacingY:n,spacing:d,minChildWidth:p,...s}=t,h=Ze(),u=p?Pt(p,h):At(l);return e.jsx(Dt,{ref:i,gap:d,columnGap:c,rowGap:n,templateColumns:u,...s})});Be.displayName="SimpleGrid";function Nt(o){return typeof o=="number"?`${o}px`:o}function Pt(o,t){return Te(o,i=>{const l=Ye("sizes",i,Nt(i))(t);return i===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function At(o){return Te(o,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ke=J((o,t)=>{const{title:i,children:l,className:c,...n}=o,d=re("chakra-menu__group__title",c),p=We();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[i&&e.jsx(pe.p,{className:d,...n,__css:p.groupTitle,children:i}),l]})});Ke.displayName="MenuGroup";var He=o=>{const{className:t,title:i,...l}=o,c=qe(l);return e.jsx(Ke,{title:i,className:re("chakra-menu__option-group",t),...c})};He.displayName="MenuOptionGroup";var Rt=J((o,t)=>{const i=We();return e.jsx(pe.button,{ref:t,...o,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...i.button}})}),ne=J((o,t)=>{const{children:i,as:l,...c}=o,n=Je(c,t),d=l||Rt;return e.jsx(d,{...n,className:re("chakra-menu__menu-button",o.className),children:e.jsx(pe.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:o.children})})});ne.displayName="MenuButton";var _t=o=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...o,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"})}),Se=J((o,t)=>{const{icon:i,iconSpacing:l="0.75rem",...c}=o,n=Qe(c,t);return e.jsxs(et,{...n,className:re("chakra-menu__menuitem-option",c.className),children:[i!==null&&e.jsx(tt,{fontSize:"0.8em",marginEnd:l,opacity:o.isChecked?1:0,children:i||e.jsx(_t,{})}),e.jsx("span",{style:{flex:1},children:n.children})]})});Se.id="MenuItemOption";Se.displayName="MenuItemOption";var Bt=T("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Kt=T("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"}]]),Ht=T("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"}]]),Fe=T("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"}]]),$t=T("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"}]]),$e=T("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Gt=T("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=T("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=T("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=T("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=T("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"}]]),Ge=T("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Xt=T("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"}]]),qt=T("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"}]]),Jt=T("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(){const o=Y(),t=r.useRef([{title:"Save current workflow",key:de.SAVE},{title:"Save as current workflow",key:de.SAVE_AS},{title:"Open spotlight search",key:de.openSpotlightSearch}]),[i,l]=r.useState({save:"",saveAs:"",openSpotlightSearch:""}),[c,n]=r.useState(),d=async(s,h)=>{var g;s.preventDefault();let u="";if(s.ctrlKey&&(u+="Control+"),s.metaKey&&(u+="Command+"),s.shiftKey&&(u+="Shift+"),s.altKey&&(u+="Alt+"),u.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){u+=s.key.toUpperCase();const m={...i};delete m[h],Object.values(m).includes(u)?o({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:{...i,[h]:u}})),p())}},p=()=>{var s;(s=C)==null||s.getSetting("shortcuts").then(h=>{var g;const u=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...i,...u})})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(N,{children:[e.jsx(L,{fontSize:"sm",w:170,children:s.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:c===s.key,children:e.jsx(Q,{value:i[s.key],onKeyDown:h=>{d(h,s.key)},onFocus:()=>{n(s.key)},onBlur:()=>{n(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function es(){const{setRefreshFolderStamp:o}=r.useContext(G),[t,i]=r.useState(!1),l=()=>{var n;(n=C)==null||n.getSetting("foldersOnTop").then(d=>{i(!!d)})},c=n=>{var p;const d=n.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),o(Date.now())})};return r.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:t,onChange:c,children:"Folders always on top"})})}function ts(){const[o,t]=r.useState(!1),[i,l]=r.useState(""),{showDialog:c}=ge(),n=()=>{var p,s;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(s=C)==null||s.getSetting("twoWaySync").then(h=>{t(h??!1)})};r.useEffect(()=>{n()},[]);const d=async p=>{var h,u;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),n();return}const s=await((u=C)==null?void 0:u.getSetting("myWorkflowsDir"));c(e.jsx(st,{myWorkflowsDir:s??"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})),n()},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]"}),e.jsx(se,{isChecked:o,onChange:d,children:"Enable two way sync"})]})}function Me({settingKey:o,text:t,defaultChecked:i=!1}){const[l,c]=r.useState(i),n=Y(),d=()=>{var p;(p=C)==null||p.getSetting(o).then(s=>{c(!!s)})};return r.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:l,onChange:async p=>{var s;await((s=C)==null?void 0:s.upsert({[o]:p.target.checked})),d(),n({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ss(){const[o,t]=r.useState(!1),[i,l]=r.useState(!1),[c,n]=r.useState([]),[d,p]=r.useState(""),[s,h]=r.useState([]),[u,g]=r.useState(!1),[m,a]=r.useState(!1),[f,v]=r.useState(!1),S=r.useRef(null),w=Y();ge();const b=f?"\\":"/";r.useEffect(()=>{var y;be().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=C)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async y=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Ie(y??"");return V.includes("Operation not permitted")?(a(!0),z(),{isError:!0}):{dirList:E,dirPath:k}},j=async()=>{const{isError:y=!1,dirList:k=[]}=await F(d);y||(n(k),l(!0),h(d&&d.split(b).filter(E=>!!E)||[]))},z=()=>{l(!1),t(!1),h([])},K=async(y,k=!1,E=!1)=>{var x,I;if(k){const{path:D}=await be();D&&await at(D,y)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:y}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&a(!1),z()},H=async y=>{if(y){const{error:E=""}=await Ie(y);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=y??`${f?"":b}${s.join(b)}`;K(k,!1,!!y)},X=async()=>{const{dirPath:y,dirList:k}=await F("");h(y.split(b).filter(E=>!!E)),n(k)},ae=async(y,k)=>{var I;let E="";y===-1&&k?E=`${f?"":b}${s.concat([k]).join(b)}`:E=`${f?"":b}${s.slice(0,y+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(n(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},oe=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(Q,{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 y,k;(y=S==null?void 0:S.current)!=null&&y.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ce=()=>{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"}),i?o?oe:e.jsxs(_e,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ae(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Be,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((y,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:()=>{ae(-1,y)},children:y},`${y}-${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:z,children:"Cancel"})]})]}):e.jsxs(U,{children:[e.jsx(nt,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:u?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"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:j})}),e.jsx(R,{label:u?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!u,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx(Ht,{size:19}),onClick:ce,variant:"ghost"})})]})]}),e.jsxs(me,{isOpen:m,onClose:()=>a(!1),size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Kind tips"}),e.jsx(je,{}),e.jsx(we,{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."}),oe]})})]})]})]})}function ns({label:o,settingKey:t}){const[i,l]=r.useState(200),c=Y(),n=s=>{if(!s.length){l(0);return}l(parseInt(s))},d=async()=>{var s;i<0&&l(0),await((s=C)==null?void 0:s.upsert({[t]:Number(i)})),c({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=C)==null||s.getSetting(t).then(h=>{l(h)})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:o}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:i,onChange:s=>n(s),onBlur:()=>{d()},onKeyUp:s=>{s.key==="Enter"&&d()},children:e.jsx(Mt,{})})]})}function as(){const o=Y(),[t,i]=r.useState(""),l=()=>{var n;(n=C)==null||n.getSetting("cloudHost").then(d=>{i(d??"")})};r.useEffect(()=>{l()},[]);const c=async n=>{var d;n=n.trim(),n.endsWith("/")&&(n=n.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:n})),l(),o({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(U,{gap:2,alignItems:"center",children:[e.jsx(Q,{value:t,onChange:n=>i(n.target.value),onBlur:()=>c(t),onKeyDown:n=>{n.key==="Enter"&&c(t)}}),e.jsx(W,{size:"sm",onClick:()=>{var d;const n=(d=C)==null?void 0:d.defaultSettings.cloudHost;i(n),c(n)},children:"Reset"})]})]})}function os(){var p,s,h,u,g,m;const o=Y(),{session:t,updateSession:i}=r.useContext(le),[l,c]=r.useState(""),n=new URL((s=(p=C)==null?void 0:p.settings)==null?void 0:s.cloudHost).hostname;r.useEffect(()=>{c((t==null?void 0:t.shareKey)??"")},[t]);const d=async a=>{ot(a),i({username:(t==null?void 0:t.username)??null,shareKey:a}),o({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{gap:3,children:[e.jsx("p",{style:{fontWeight:"bold"},children:"Cloud Backup [Beta]"}),e.jsxs("p",{children:[e.jsx("a",{href:((u=(h=C)==null?void 0:h.settings)==null?void 0:u.cloudHost)+"/auth/shareKey",target:"_blank",style:{textDecoration:"underline"},children:e.jsx(W,{size:"sm",children:"👉Copy your share key from here"})})," ","and paste it below to start saving workflow versions to cloud at"," ",e.jsx("a",{href:(m=(g=C)==null?void 0:g.settings)==null?void 0:m.cloudHost,target:"_blank",children:n})]}),e.jsx(U,{alignItems:"center",children:e.jsx(Q,{value:l,placeholder:"Paste your share key here",onChange:a=>c(a.target.value),onBlur:()=>d(l),onKeyDown:a=>{a.key==="Enter"&&d(l)}})})]})}function is({onClose:o}){return e.jsx(e.Fragment,{children:e.jsxs(me,{isOpen:!0,onClose:o,size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Settings"}),e.jsx(je,{}),e.jsx(we,{pb:14,children:e.jsx(N,{children:e.jsxs(_e,{divider:e.jsx(it,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ss,{}),e.jsx(Qt,{}),e.jsx(ts,{}),e.jsx(os,{}),e.jsx(es,{}),e.jsx(ns,{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(Me,{settingKey:"disableUnsavedWarning",text:'Disable the "Save or Discard" warning when closing a workflow with unsaved changes. ⛔️Be careful, if you disable this reminder and forget to save your workflow, you will lose your changes.'}),e.jsx(Me,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(as,{})]})})})]})]})})}const Ee=16;function rs({}){const[o,t]=r.useState(!1),{colorMode:i,toggleColorMode:l}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(ne,{as:A,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(P,{onClick:()=>t(!0),icon:e.jsx(Xt,{size:16}),fontSize:16,children:"Settings"}),e.jsxs(P,{onClick:l,icon:i==="light"?e.jsx(Zt,{size:Ee}):e.jsx(qt,{size:Ee}),fontSize:16,children:[i==="light"?"Dark":"Light"," Mode"]})]})]}),o&&e.jsx(is,{onClose:()=>t(!1)})]})}function ls(o){const{multipleState:t,changeMultipleState:i,selectedKeys:l,isSelectedAll:c,batchOperationCallback:n}=o,d=async()=>{var h;const s=await((h=O)==null?void 0:h.batchQuery(l))??[];lt(s)},p=l.length===0;return e.jsx(N,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(se,{isChecked:c,onChange:s=>{n("selectAll",s.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(rt,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Ne,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=O)==null?void 0:s.batchDeleteFlow(l)),n("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(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{i(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(A,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Gt,{size:21}),onClick:()=>{i(!0)}})})})}const Oe=6;function cs({setSelectedTag:o,selectedTag:t}){const[i,l]=r.useState(!1),[c,n]=r.useState([]);return r.useEffect(()=>{var d;(d=ct)==null||d.listAll().then(p=>{n(p)})},[]),e.jsxs(N,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{o(void 0)}}),c.slice(0,i?void 0:Oe).map(d=>e.jsx(W,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{o(d.name)},isActive:t===d.name,children:d.name},d.name)),(c.length??0)>Oe&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:i?e.jsx(Bt,{}):e.jsx(ke,{}),onClick:()=>l(!i)})]})}function Ve({parentFolderID:o,onlyImportFile:t=!1}){const{onRefreshFilesList:i}=r.useContext(G),[l,c]=r.useState("file"),n=r.useRef(null),d=u=>{var g;c(u),u==="folder"?n.current.setAttribute("webkitdirectory",""):n.current.removeAttribute("webkitdirectory"),(g=n.current)==null||g.click()},p=async u=>{var g;if(u.type==="image/png"){const m=await Et(u),a=m==null?void 0:m.workflow;if(a)return{json:a,name:u.name.replace(".png","")}}else if(u.type==="application/json"||(g=u.name)!=null&&g.endsWith(".json"))return await new Promise((m,a)=>{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","")}):a(new Error("File content is not a string"))}catch(w){a(w)}},f.onerror=a,f.readAsText(u)});return null},s=async u=>{var m,a;const g=[u];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=$)==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((a=O)==null?void 0:a.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}i==null||i()},h=async u=>{var m;const g=u.target.files;if(g)if(l==="folder"){const a={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=a.children??[];for(let w=1;wj.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const j=await p(f);j&&(F.file=j)}S.push(F)}F&&!F.isFile&&(S=F.children)}}s(a)}else{const a=[];for(const f of g){const v=await p(f);v&&a.push(v)}a.length&&(await((m=O)==null?void 0:m.batchCreateFlows(a,void 0,o)),i&&i())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(P,{onClick:u=>{u.stopPropagation(),d("file")},icon:e.jsx(Fe,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,leftIcon:e.jsx(Fe,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((u,g)=>e.jsx(P,{onClick:()=>{d(u.type)},iconSpacing:2,icon:u.type==="folder"?e.jsx(Ae,{size:18}):e.jsx($t,{size:18}),children:u.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:n,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:u=>{u.stopPropagation()}})]})}function ds({folder:o,onclose:t}){const[i,l]=r.useState(o.name),[c,n]=r.useState(""),{onRefreshFilesList:d}=r.useContext(G),p=h=>{l(h.target.value),c&&n("")},s=async()=>{var g,m;const h=i.trim();if(l(h),h===o.name)return t();await((g=$)==null?void 0:g.generateUniqueName(h,o.parentFolderID??""))!==h?n("The name is duplicated, please modify it and submit again."):(await((m=$)==null?void 0:m.update(o.id,{name:h})),d&&d(),t())};return e.jsxs(me,{isOpen:!0,onClose:t,children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Edit folder name"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(ut,{isInvalid:!!c,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(Q,{value:i,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!c&&i&&s()}}),c&&e.jsx(pt,{children:c})]})}),e.jsxs(Xe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!i||!!c,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function us({menuPosition:o,isopen:t,folder:i,onClose:l}){const[c,n]=r.useState(!1),{onRefreshFilesList:d}=r.useContext(G),{showDialog:p}=ge(),s=async m=>{var a;m.stopPropagation(),await((a=$)==null?void 0:a.create({name:"New Folder",parentFolderID:i.id})),d&&d()},h=async m=>{var a;m.stopPropagation(),await((a=O)==null?void 0:a.createFlow({json:JSON.stringify(mt),parentFolderID:i.id})),d&&d()},u=async m=>{m.stopPropagation();const a=await ft(i.id);p(`Do you want to delete the ${a} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(xt.DELETE)}}])},g=async m=>{var a;await((a=$)==null?void 0:a.deleteFolder(i.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:o.y,left:o.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(P,{icon:e.jsx(Yt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),n(!0)},children:"Rename"}),e.jsx(P,{icon:e.jsx(gt,{size:19}),onClick:u,children:"Delete"}),e.jsx(P,{onClick:s,icon:e.jsx($e,{size:19}),children:"New folder"}),e.jsx(P,{onClick:h,icon:e.jsx(Ge,{size:19}),children:"New file"}),e.jsx(Ve,{parentFolderID:i.id,onlyImportFile:!0})]})})}),c&&e.jsx(ds,{folder:i,onclose:()=>n(!1)})]})}const ze=r.memo(function({folder:t}){const[i,l]=r.useState(!1),[c,n]=r.useState(t.isCollapse??!0),[d,p]=r.useState([]),[s,h]=r.useState({x:0,y:0}),[u,g]=r.useState(!1),{colorMode:m}=ve(),{draggingFile:a,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=r.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};r.useEffect(()=>{var j;c||(j=O)==null||j.listFolderContent(t.id,window.localStorage.getItem(he)).then(z=>{p(z)})},[t.id,v,c]);const b=j=>{j.preventDefault(),h({x:j.clientX,y:j.clientY}),g(!0)},F=async j=>{var z,K;if(j.preventDefault(),j.stopPropagation(),!a)return l(!1);if(Z(a)){if(a.id===t.id)return l(!1);await((z=$)==null?void 0:z.update(a.id,{parentFolderID:t.id}))}else Z(a)||await((K=O)==null?void 0:K.updateFolder(a.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return r.useEffect(()=>{var j;!!t.isCollapse!==c&&((j=$)==null||j.update(t.id,{isCollapse:c}))},[c]),r.useEffect(()=>{var X;const j=(X=O)==null?void 0:X.curWorkflow,z=(j==null?void 0:j.parentFolderID)+De(),K=t.id+De();z.startsWith(K)&&n(!1)},[]),e.jsxs(B,{children:[e.jsxs(N,{w:"100%",as:"button",py:1,onClick:()=>{n(!c)},onContextMenu:b,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:i||u?w:void 0,className:"droppable",children:[e.jsxs(N,{gap:1,children:[c?e.jsx(Ot,{size:20}):e.jsx(ke,{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:s,onClose:()=>g(!1),folder:t}),!c&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Ue,{items:d})})]})});function hs({workflow:o}){const t=r.useRef(null),i=Y(),{onDuplicateWorkflow:l}=r.useContext(le),[c,n]=r.useState(o.saveLock??!1),d=async()=>{var h;const s=!c;n(s),await((h=O)==null?void 0:h.updateMetaInfo(o.id,{saveLock:s})),i({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const h=s.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 wt("/workspace/images/save",{method:"POST",body:u}),Array.from(h).forEach(async g=>{var a,f;const m=`workspace_manager/${g.name}`;(a=vt)==null||a.create({workflowID:o.id,localPath:m}),(f=O)==null||f.updateMetaInfo(o.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(ne,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Kt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(P,{icon:e.jsx(Wt,{}),onClick:()=>l&&l(o.id),children:"Duplicate"}),e.jsx(P,{icon:e.jsx(yt,{size:20}),onClick:()=>jt(o.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:c?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(P,{icon:c?e.jsx(Re,{}):e.jsx(Vt,{}),onClick:d,children:c?"Unlock":"Lock"})}),e.jsx(P,{icon:e.jsx(Jt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function ps({workflow:o}){const{onDeleteFlow:t}=r.useContext(G);return e.jsxs(U,{justifyContent:"flex-end",children:[e.jsx(Ne,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(o.id)}}),e.jsx(hs,{workflow:o})]})}const Le=r.memo(function({workflow:t}){var v,S,w,b;const{colorMode:i}=ve(),{setDraggingFile:l,isMultiSelecting:c,onMultiSelectFlow:n,multiSelectedFlowsID:d}=r.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:s,loadWorkflowID:h}=r.useContext(le),u=s===t.id,g=i==="light"?"gray.200":"#4A5568",[m,a]=r.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:u?"teal.200":void 0,color:u&&!c?"#333":void 0,draggable:!c,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!c&&h(t.id)},_hover:{bg:g},children:e.jsxs(N,{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(zt,{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(U,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx(Re,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(N,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:i=="dark"?"gray.700":"gray.200",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:c?e.jsx(se,{isChecked:p,spacing:4,onChange:F=>{n&&n(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:kt(t.updateTime,!1,!1,"/")})})]})})});function Ue({items:o}){var m;const[t,i]=r.useState(!1),l=o.filter(Z),c=o.filter(a=>!Z(a)),n=(m=c[0])==null?void 0:m.parentFolderID,[d,p]=r.useState(!1),{onRefreshFilesList:s,draggingFile:h,refreshFolderStamp:u}=r.useContext(G),g=async a=>{var f,v;if(a.preventDefault(),a.stopPropagation(),!h)return p(!1);if(Z(h)){if(h.id===n)return p(!1);await((f=$)==null?void 0:f.update(h.id,{parentFolderID:n}))}else await((v=O)==null?void 0:v.updateFolder(h.id,{parentFolderID:n}));await(s==null?void 0:s()),p(!1)};return r.useEffect(()=>{var a;(a=C)==null||a.getSetting("foldersOnTop").then(f=>{i(f??!1)})},[u]),e.jsxs(e.Fragment,{children:[t&&l.map(a=>e.jsx(ze,{folder:a},a.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:a=>{a.preventDefault(),a.stopPropagation(),p(!0)},onDragLeave:a=>{a.preventDefault(),a.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?c.map(a=>e.jsx(Le,{workflow:a},a.id)):o.map(a=>Z(a)?e.jsx(ze,{folder:a},a.id):e.jsx(Le,{workflow:a},a.id))})]})}function ks({onClose:o,onClickNewFlow:t}){const[i,l]=r.useState([]),c=r.useRef([]),{loadWorkflowID:n,curFlowID:d}=r.useContext(le),[p,s]=r.useState(),[h,u]=r.useState(!1),[g,m]=r.useState([]),[a,f]=r.useState(0),[v,S]=r.useState(""),w=Lt(v,400),b=r.useRef(null),[F,j]=r.useState(null),z=r.useRef(window.localStorage.getItem(he)??q.RECENTLY_MODIFIED),K=!!p||!!w.length,H=async()=>{var I,D;const x=await((I=O)==null?void 0:I.listFolderContent())??[];l(ue(x,z.current)),f(Date.now()),c.current=await((D=O)==null?void 0:D.listAll())??[]},X=()=>{const x=c.current.filter(I=>{var Ce;let D=!0,M=!0;return p&&(D=!!((Ce=I.tags)!=null&&Ce.includes(p))),w&&(M=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),D&&M});l(ue(x,z.current))},ae=x=>{l(ue(i,x)),z.current=x,window.localStorage.setItem(he,x),!K&&f(Date.now())};r.useEffect(()=>{K?X():H()},[w,p]);const oe=r.useCallback(async x=>{var I,D,M;await((I=O)==null?void 0:I.deleteFlow(x)),((M=(D=O)==null?void 0:D.curWorkflow)==null?void 0:M.id)===x&&await(n==null?void 0:n(null)),await H()},[p,w]);r.useEffect(()=>{const x=async I=>{var D;if(b.current){const M=await((D=O)==null?void 0:D.get(b.current));M&&M.json&&It(M.json,[I.canvasX,I.canvasY])}};return ie.canvasEl.addEventListener("drop",x),ie.canvasEl.addEventListener("click",o),()=>{ie.canvasEl.removeEventListener("drop",x),ie.canvasEl.removeEventListener("click",o)}},[]);const ce=r.useCallback((x,I)=>{m(D=>{const M=[...D];return I?M.push(x):M.splice(M.indexOf(x),1),M})},[]),y=(x,I)=>{var D;switch(x){case"batchDelete":d&&((D=O)==null||D.get(d).then(M=>{M||n==null||n(null)})),H(),u(!1),m([]);return;case"selectAll":m(I?c.current.map(M=>M.id):[]);return}},k=x=>{j(x),Z(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:ce,multiSelectedFlowsID:g,onDeleteFlow:oe,refreshFolderStamp:a,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(St,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(U,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(N,{gap:4,children:[e.jsx(N,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ve,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(Ae,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(R,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Ge,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(N,{alignItems:"center",children:e.jsx(rs,{})})]}),e.jsxs(U,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(cs,{selectedTag:p,setSelectedTag:s}),e.jsxs(N,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(N,{children:[e.jsx(ls,{multipleState:h,changeMultipleState:x=>{u(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===c.current.length,batchOperationCallback:y}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx($e,{size:21}),onClick:async()=>{var x;await((x=$)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(ke,{size:"16"}),children:e.jsxs(N,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:z.current})]})}),e.jsx(te,{children:e.jsx(He,{value:z.current,type:"radio",onChange:x=>ae(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,I)=>e.jsx(Se,{value:x,children:x},I))})})]})]}),e.jsx(Tt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(U,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Ue,{items:i})})]})]})})})}export{ks as default};
diff --git a/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js b/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js
new file mode 100644
index 0000000..09e4c23
--- /dev/null
+++ b/dist/workspace_web/RecentFilesDrawer-efSIwVKr.js
@@ -0,0 +1,5 @@
+import{f as J,E as Ze,j as e,Y as Ye,e as re,g as pe,r,V as ge,h as W,M as me,T as fe,N as xe,U as ye,Q as je,O as we,Z as ve,R as Xe}from"./input.js";import{m as Te,u as We,a as qe,b as Je,c as Qe,S as et,M as tt,d as T,e as Y,E as de,f as B,T as z,H as N,g as R,I as Q,h as C,R as G,i as st,j as be,B as _,F as U,k as nt,l as A,n as Ie,o as at,W as le,s as ot,p as it,q as ee,r as te,t as P,v as rt,D as Ne,w as O,x as Pe,y as lt,z as ke,A as ct,C as dt,G as Ae,J as $,K as ut,L as ht,N as pt,O as gt,P as mt,Q as ft,U as xt,V as De,X as Z,Y as he,Z as yt,_ as jt,$ as Re,a0 as wt,a1 as vt,a2 as kt,a3 as St,a4 as q,a5 as ie,a6 as Ct,a7 as bt,a8 as It,a9 as ue,aa as Dt}from"./App-9GIQJeUY.js";import{G as Ft,C as se}from"./chunk-JARCRF6W-1gGfj837.js";import{V as _e}from"./chunk-NTCQBYKE-ROuYoItA.js";import{N as Mt,a as Et,g as Ot,I as Lt,M as zt,u as Tt,S as Wt}from"./MediaPreview-VRNiVJ5t.js";import{I as Nt}from"./IconCopy-RhFbFhX0.js";import"./chunk-7D6N5TE5-gOmt0HWF.js";import"./IconSearch-srLS9f0l.js";var Be=J(function(t,o){const{columns:l,spacingX:c,spacingY:n,spacing:d,minChildWidth:p,...s}=t,u=Ze(),h=p?At(p,u):Rt(l);return e.jsx(Ft,{ref:o,gap:d,columnGap:c,rowGap:n,templateColumns:h,...s})});Be.displayName="SimpleGrid";function Pt(a){return typeof a=="number"?`${a}px`:a}function At(a,t){return Te(a,o=>{const l=Ye("sizes",o,Pt(o))(t);return o===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function Rt(a){return Te(a,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ke=J((a,t)=>{const{title:o,children:l,className:c,...n}=a,d=re("chakra-menu__group__title",c),p=We();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[o&&e.jsx(pe.p,{className:d,...n,__css:p.groupTitle,children:o}),l]})});Ke.displayName="MenuGroup";var He=a=>{const{className:t,title:o,...l}=a,c=qe(l);return e.jsx(Ke,{title:o,className:re("chakra-menu__option-group",t),...c})};He.displayName="MenuOptionGroup";var _t=J((a,t)=>{const o=We();return e.jsx(pe.button,{ref:t,...a,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...o.button}})}),ne=J((a,t)=>{const{children:o,as:l,...c}=a,n=Je(c,t),d=l||_t;return e.jsx(d,{...n,className:re("chakra-menu__menu-button",a.className),children:e.jsx(pe.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:a.children})})});ne.displayName="MenuButton";var Bt=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"})}),Se=J((a,t)=>{const{icon:o,iconSpacing:l="0.75rem",...c}=a,n=Qe(c,t);return e.jsxs(et,{...n,className:re("chakra-menu__menuitem-option",c.className),children:[o!==null&&e.jsx(tt,{fontSize:"0.8em",marginEnd:l,opacity:a.isChecked?1:0,children:o||e.jsx(Bt,{})}),e.jsx("span",{style:{flex:1},children:n.children})]})});Se.id="MenuItemOption";Se.displayName="MenuItemOption";var Kt=T("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Ht=T("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=T("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"}]]),Fe=T("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=T("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"}]]),$e=T("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Vt=T("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"}]]),Ut=T("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"}]]),Zt=T("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"}]]),Yt=T("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"}]]),Xt=T("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"}]]),Ge=T("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),qt=T("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"}]]),Jt=T("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=T("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 es(){const a=Y(),t=r.useRef([{title:"Save current workflow",key:de.SAVE},{title:"Save as current workflow",key:de.SAVE_AS},{title:"Open spotlight search",key:de.openSpotlightSearch}]),[o,l]=r.useState({save:"",saveAs:"",openSpotlightSearch:""}),[c,n]=r.useState(),d=async(s,u)=>{var g;s.preventDefault();let h="";if(s.ctrlKey&&(h+="Control+"),s.metaKey&&(h+="Command+"),s.shiftKey&&(h+="Shift+"),s.altKey&&(h+="Alt+"),h.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){h+=s.key.toUpperCase();const m={...o};delete m[u],Object.values(m).includes(h)?a({title:"Shortcut key conflict",description:`The shortcut key 「${h}」 is already used, please
+ modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...o,[u]:h}})),p())}},p=()=>{var s;(s=C)==null||s.getSetting("shortcuts").then(u=>{var g;const h=u??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...o,...h})})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(z,{children:"Keyboard Shortcut"}),t.current.map(s=>e.jsxs(N,{children:[e.jsx(z,{fontSize:"sm",w:170,children:s.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:c===s.key,children:e.jsx(Q,{value:o[s.key],onKeyDown:u=>{d(u,s.key)},onFocus:()=>{n(s.key)},onBlur:()=>{n(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function ts(){const{setRefreshFolderStamp:a}=r.useContext(G),[t,o]=r.useState(!1),l=()=>{var n;(n=C)==null||n.getSetting("foldersOnTop").then(d=>{o(!!d)})},c=n=>{var p;const d=n.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),a(Date.now())})};return r.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:t,onChange:c,children:"Folders always on top"})})}function ss(){const[a,t]=r.useState(!1),[o,l]=r.useState(""),{showDialog:c}=ge(),n=()=>{var p,s;(p=C)==null||p.getSetting("myWorkflowsDir").then(u=>{l(u??"undefined")}),(s=C)==null||s.getSetting("twoWaySync").then(u=>{t(u??!1)})};r.useEffect(()=>{n()},[]);const d=async p=>{var u,h;if(!p.target.checked){await((u=C)==null?void 0:u.upsert({twoWaySync:p.target.checked})),n();return}const s=await((h=C)==null?void 0:h.getSetting("myWorkflowsDir"));c(e.jsx(st,{myWorkflowsDir:s??"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})),n()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(z,{children:"Only for legacy two way sync users to get back their data. [DO NOT DISABLE]"}),e.jsx(se,{isChecked:a,onChange:d,children:"Enable two way sync"})]})}function Me({settingKey:a,text:t,defaultChecked:o=!1}){const[l,c]=r.useState(o),n=Y(),d=()=>{var p;(p=C)==null||p.getSetting(a).then(s=>{c(!!s)})};return r.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(se,{isChecked:l,onChange:async p=>{var s;await((s=C)==null?void 0:s.upsert({[a]:p.target.checked})),d(),n({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ns(){const[a,t]=r.useState(!1),[o,l]=r.useState(!1),[c,n]=r.useState([]),[d,p]=r.useState(""),[s,u]=r.useState([]),[h,g]=r.useState(!1),[m,i]=r.useState(!1),[f,v]=r.useState(!1),S=r.useRef(null),w=Y();ge();const b=f?"\\":"/";r.useEffect(()=>{var y;be().then(k=>{p(k.path??""),v(k.os==="win32")}),(y=C)==null||y.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async y=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Ie(y??"");return V.includes("Operation not permitted")?(i(!0),L(),{isError:!0}):{dirList:E,dirPath:k}},j=async()=>{const{isError:y=!1,dirList:k=[]}=await F(d);y||(n(k),l(!0),u(d&&d.split(b).filter(E=>!!E)||[]))},L=()=>{l(!1),t(!1),u([])},K=async(y,k=!1,E=!1)=>{var x,I;if(k){const{path:D}=await be();D&&await at(D,y)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:y}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&i(!1),L()},H=async y=>{if(y){const{error:E=""}=await Ie(y);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=y??`${f?"":b}${s.join(b)}`;K(k,!1,!!y)},X=async()=>{const{dirPath:y,dirList:k}=await F("");u(y.split(b).filter(E=>!!E)),n(k)},ae=async(y,k)=>{var I;let E="";y===-1&&k?E=`${f?"":b}${s.concat([k]).join(b)}`:E=`${f?"":b}${s.slice(0,y+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(n(x),u(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},oe=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(Q,{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 y,k;(y=S==null?void 0:S.current)!=null&&y.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ce=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(z,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),o?a?oe:e.jsxs(_e,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:s.map((y,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(W,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ae(k)},children:y},`${y}-${k}`)]},y))}),e.jsx(Be,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((y,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:()=>{ae(-1,y)},children:y},`${y}-${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:L,children:"Cancel"})]})]}):e.jsxs(U,{children:[e.jsx(nt,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:h?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(A,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!h,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:j})}),e.jsx(R,{label:h?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(A,{isDisabled:!h,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:ce,variant:"ghost"})})]})]}),e.jsxs(me,{isOpen:m,onClose:()=>i(!1),size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Kind tips"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(_,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(z,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(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(z,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),oe]})})]})]})]})}function as({label:a,settingKey:t}){const[o,l]=r.useState(200),c=Y(),n=s=>{if(!s.length){l(0);return}l(parseInt(s))},d=async()=>{var s;o<0&&l(0),await((s=C)==null?void 0:s.upsert({[t]:Number(o)})),c({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var s;(s=C)==null||s.getSetting(t).then(u=>{l(u)})};return r.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(z,{children:a}),e.jsx(Mt,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:o,onChange:s=>n(s),onBlur:()=>{d()},onKeyUp:s=>{s.key==="Enter"&&d()},children:e.jsx(Et,{})})]})}function os(){const a=Y(),[t,o]=r.useState(""),l=()=>{var n;(n=C)==null||n.getSetting("cloudHost").then(d=>{o(d??"")})};r.useEffect(()=>{l()},[]);const c=async n=>{var d;n=n.trim(),n.endsWith("/")&&(n=n.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:n})),l(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(z,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(U,{gap:2,alignItems:"center",children:[e.jsx(Q,{value:t,onChange:n=>o(n.target.value),onBlur:()=>c(t),onKeyDown:n=>{n.key==="Enter"&&c(t)}}),e.jsx(W,{size:"sm",onClick:()=>{var d;const n=(d=C)==null?void 0:d.defaultSettings.cloudHost;o(n),c(n)},children:"Reset"})]})]})}function is(){var p,s,u,h,g,m;const a=Y(),{session:t,updateSession:o}=r.useContext(le),[l,c]=r.useState(""),n=new URL((s=(p=C)==null?void 0:p.settings)==null?void 0:s.cloudHost).hostname;r.useEffect(()=>{c((t==null?void 0:t.shareKey)??"")},[t]);const d=async i=>{ot(i),o({username:(t==null?void 0:t.username)??null,shareKey:i}),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{gap:3,children:[e.jsx("p",{style:{fontWeight:"bold"},children:"Cloud Backup [Beta]"}),e.jsxs("p",{children:[e.jsx("a",{href:((h=(u=C)==null?void 0:u.settings)==null?void 0:h.cloudHost)+"/auth/shareKey",target:"_blank",style:{textDecoration:"underline"},children:e.jsx(W,{size:"sm",children:"👉Copy your share key from here"})})," ","and paste it below to start saving workflow versions to cloud at"," ",e.jsx("a",{href:(m=(g=C)==null?void 0:g.settings)==null?void 0:m.cloudHost,target:"_blank",children:n})]}),e.jsx(U,{alignItems:"center",children:e.jsx(Q,{value:l,placeholder:"Paste your share key here",onChange:i=>c(i.target.value),onBlur:()=>d(l),onKeyDown:i=>{i.key==="Enter"&&d(l)}})})]})}function rs({onClose:a}){return e.jsx(e.Fragment,{children:e.jsxs(me,{isOpen:!0,onClose:a,size:"xl",children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Settings"}),e.jsx(je,{}),e.jsx(we,{pb:14,children:e.jsx(N,{children:e.jsxs(_e,{divider:e.jsx(it,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ns,{}),e.jsx(es,{}),e.jsx(ss,{}),e.jsx(is,{}),e.jsx(ts,{}),e.jsx(as,{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(Me,{settingKey:"disableUnsavedWarning",text:'Disable the "Save or Discard" warning when closing a workflow with unsaved changes. ⛔️Be careful, if you disable this reminder and forget to save your workflow, you will lose your changes.'}),e.jsx(Me,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(os,{})]})})})]})]})})}const Ee=16;function ls({}){const[a,t]=r.useState(!1),{colorMode:o,toggleColorMode:l}=ve();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(ne,{as:A,"aria-label":"Options",icon:e.jsx(Zt,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(P,{onClick:()=>t(!0),icon:e.jsx(qt,{size:16}),fontSize:16,children:"Settings"}),e.jsxs(P,{onClick:l,icon:o==="light"?e.jsx(Yt,{size:Ee}):e.jsx(Jt,{size:Ee}),fontSize:16,children:[o==="light"?"Dark":"Light"," Mode"]})]})]}),a&&e.jsx(rs,{onClose:()=>t(!1)})]})}function cs(a){const{multipleState:t,changeMultipleState:o,selectedKeys:l,isSelectedAll:c,batchOperationCallback:n}=a,d=async()=>{var u;const s=await((u=O)==null?void 0:u.batchQuery(l))??[];lt(s)},p=l.length===0;return e.jsx(N,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(se,{isChecked:c,onChange:s=>{n("selectAll",s.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(A,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(rt,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Ne,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=O)==null?void 0:s.batchDeleteFlow(l)),n("batchDelete")}})}),l.length>0&&e.jsx(z,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(A,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{o(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(A,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Vt,{size:21}),onClick:()=>{o(!0)}})})})}const Oe=6;function ds({setSelectedTag:a,selectedTag:t}){const[o,l]=r.useState(!1),[c,n]=r.useState([]);return r.useEffect(()=>{var d;(d=ct)==null||d.listAll().then(p=>{n(p)})},[]),e.jsxs(N,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(A,{"aria-label":"Close",size:"sm",icon:e.jsx(Pe,{}),onClick:()=>{a(void 0)}}),c.slice(0,o?void 0:Oe).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)),(c.length??0)>Oe&&e.jsx(A,{"aria-label":"Show-all-tags",size:"sm",icon:o?e.jsx(Kt,{}):e.jsx(ke,{}),onClick:()=>l(!o)})]})}function Ve({parentFolderID:a,onlyImportFile:t=!1}){const{onRefreshFilesList:o}=r.useContext(G),[l,c]=r.useState("file"),n=r.useRef(null),d=h=>{var g;c(h),h==="folder"?n.current.setAttribute("webkitdirectory",""):n.current.removeAttribute("webkitdirectory"),(g=n.current)==null||g.click()},p=async h=>{var g;if(h.type==="image/png"){const m=await Ot(h),i=m==null?void 0:m.workflow;if(i)return{json:i,name:h.name.replace(".png","")}}else if(h.type==="application/json"||(g=h.name)!=null&&g.endsWith(".json"))return await new Promise((m,i)=>{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:h.name.replace(".json","")}):i(new Error("File content is not a string"))}catch(w){i(w)}},f.onerror=i,f.readAsText(h)});return null},s=async h=>{var m,i;const g=[h];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=$)==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((i=O)==null?void 0:i.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}o==null||o()},u=async h=>{var m;const g=h.target.files;if(g)if(l==="folder"){const i={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=i.children??[];for(let w=1;wj.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const j=await p(f);j&&(F.file=j)}S.push(F)}F&&!F.isFile&&(S=F.children)}}s(i)}else{const i=[];for(const f of g){const v=await p(f);v&&i.push(v)}i.length&&(await((m=O)==null?void 0:m.batchCreateFlows(i,void 0,a)),o&&o())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(P,{onClick:h=>{h.stopPropagation(),d("file")},icon:e.jsx(Fe,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,leftIcon:e.jsx(Fe,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((h,g)=>e.jsx(P,{onClick:()=>{d(h.type)},iconSpacing:2,icon:h.type==="folder"?e.jsx(Ae,{size:18}):e.jsx(Gt,{size:18}),children:h.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:n,type:"file",accept:".json,image/png",multiple:!0,onChange:u,onClick:h=>{h.stopPropagation()}})]})}function us({folder:a,onclose:t}){const[o,l]=r.useState(a.name),[c,n]=r.useState(""),{onRefreshFilesList:d}=r.useContext(G),p=u=>{l(u.target.value),c&&n("")},s=async()=>{var g,m;const u=o.trim();if(l(u),u===a.name)return t();await((g=$)==null?void 0:g.generateUniqueName(u,a.parentFolderID??""))!==u?n("The name is duplicated, please modify it and submit again."):(await((m=$)==null?void 0:m.update(a.id,{name:u})),d&&d(),t())};return e.jsxs(me,{isOpen:!0,onClose:t,children:[e.jsx(fe,{}),e.jsxs(xe,{children:[e.jsx(ye,{children:"Edit folder name"}),e.jsx(je,{}),e.jsx(we,{children:e.jsxs(ut,{isInvalid:!!c,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(Q,{value:o,onChange:p,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!c&&o&&s()}}),c&&e.jsx(pt,{children:c})]})}),e.jsxs(Xe,{children:[e.jsx(W,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!o||!!c,children:"Save"}),e.jsx(W,{onClick:t,children:"Cancel"})]})]})]})}function hs({menuPosition:a,isopen:t,folder:o,onClose:l}){const[c,n]=r.useState(!1),{onRefreshFilesList:d}=r.useContext(G),{showDialog:p}=ge(),s=async m=>{var i;m.stopPropagation(),await((i=$)==null?void 0:i.create({name:"New Folder",parentFolderID:o.id})),d&&d()},u=async m=>{var i;m.stopPropagation(),await((i=O)==null?void 0:i.createFlow({json:JSON.stringify(mt),parentFolderID:o.id})),d&&d()},h=async m=>{m.stopPropagation();const i=await ft(o.id);p(`Do you want to delete the ${i} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(xt.DELETE)}}])},g=async m=>{var i;await((i=$)==null?void 0:i.deleteFolder(o.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(P,{icon:e.jsx(Xt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),n(!0)},children:"Rename"}),e.jsx(P,{icon:e.jsx(gt,{size:19}),onClick:h,children:"Delete"}),e.jsx(P,{onClick:s,icon:e.jsx($e,{size:19}),children:"New folder"}),e.jsx(P,{onClick:u,icon:e.jsx(Ge,{size:19}),children:"New file"}),e.jsx(Ve,{parentFolderID:o.id,onlyImportFile:!0})]})})}),c&&e.jsx(us,{folder:o,onclose:()=>n(!1)})]})}const Le=r.memo(function({folder:t}){const[o,l]=r.useState(!1),[c,n]=r.useState(t.isCollapse??!0),[d,p]=r.useState([]),[s,u]=r.useState({x:0,y:0}),[h,g]=r.useState(!1),{colorMode:m}=ve(),{draggingFile:i,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=r.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};r.useEffect(()=>{var j;c||(j=O)==null||j.listFolderContent(t.id,window.localStorage.getItem(he)).then(L=>{p(L)})},[t.id,v,c]);const b=j=>{j.preventDefault(),u({x:j.clientX,y:j.clientY}),g(!0)},F=async j=>{var L,K;if(j.preventDefault(),j.stopPropagation(),!i)return l(!1);if(Z(i)){if(i.id===t.id)return l(!1);await((L=$)==null?void 0:L.update(i.id,{parentFolderID:t.id}))}else Z(i)||await((K=O)==null?void 0:K.updateFolder(i.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return r.useEffect(()=>{var j;!!t.isCollapse!==c&&((j=$)==null||j.update(t.id,{isCollapse:c}))},[c]),r.useEffect(()=>{var X;const j=(X=O)==null?void 0:X.curWorkflow,L=(j==null?void 0:j.parentFolderID)+De(),K=t.id+De();L.startsWith(K)&&n(!1)},[]),e.jsxs(B,{children:[e.jsxs(N,{w:"100%",as:"button",py:1,onClick:()=>{n(!c)},onContextMenu:b,draggable:"true",onDragOver:j=>{j.preventDefault(),j.stopPropagation(),l(!0)},onDragLeave:j=>{j.preventDefault(),j.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:o||h?w:void 0,className:"droppable",children:[e.jsxs(N,{gap:1,children:[c?e.jsx(Lt,{size:20}):e.jsx(ke,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(z,{children:t.name})]}),e.jsx(hs,{isopen:h,menuPosition:s,onClose:()=>g(!1),folder:t}),!c&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Ue,{items:d})})]})});function ps({workflow:a}){const t=r.useRef(null),o=Y(),{onDuplicateWorkflow:l}=r.useContext(le),[c,n]=r.useState(a.saveLock??!1),d=async()=>{var u;const s=!c;n(s),await((u=O)==null?void 0:u.updateMetaInfo(a.id,{saveLock:s})),o({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async s=>{const u=s.target.files;if(!u)return;const h=new FormData;Array.from(u).forEach((g,m)=>{h.append(`images[${m}]`,g,g.name)}),h.append("subfolder","workspace_manager"),await vt("/workspace/images/save",{method:"POST",body:h}),Array.from(u).forEach(async g=>{var i,f;const m=`workspace_manager/${g.name}`;(i=kt)==null||i.create({workflowID:a.id,localPath:m}),(f=O)==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(ne,{border:0,as:A,"aria-label":"Options",icon:e.jsx(Ht,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(P,{icon:e.jsx(Nt,{}),onClick:()=>l&&l(a.id),children:"Duplicate"}),e.jsx(P,{icon:e.jsx(yt,{size:20}),onClick:()=>jt(a.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:c?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(P,{icon:c?e.jsx(Re,{}):e.jsx(Ut,{}),onClick:d,children:c?"Unlock":"Lock"})}),a.cloudID&&e.jsx(P,{icon:e.jsx(wt,{}),onClick:()=>{var s,u;navigator.clipboard.writeText(`${(u=(s=C)==null?void 0:s.settings)==null?void 0:u.cloudHost}/workflow/${a.cloudID}`),o({title:"Cloud link copied",status:"success",duration:3e3})},children:"Copy cloud share link"}),e.jsx(P,{icon:e.jsx(Qt,{}),onClick:()=>{var s;(s=t.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:s=>{s.stopPropagation()}})]})}function gs({workflow:a}){const{onDeleteFlow:t}=r.useContext(G);return e.jsxs(U,{justifyContent:"flex-end",children:[e.jsx(Ne,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(a.id)}}),e.jsx(ps,{workflow:a})]})}const ze=r.memo(function({workflow:t}){var v,S,w,b;const{colorMode:o}=ve(),{setDraggingFile:l,isMultiSelecting:c,onMultiSelectFlow:n,multiSelectedFlowsID:d}=r.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:s,loadWorkflowID:u}=r.useContext(le),h=s===t.id,g=o==="light"?"gray.200":"#4A5568",[m,i]=r.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:h?"teal.200":void 0,color:h&&!c?"#333":void 0,draggable:!c,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!c&&u(t.id)},_hover:{bg:g},children:e.jsxs(N,{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(zt,{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(U,{alignItems:"center",children:[e.jsx(z,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx(Re,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(N,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:o=="dark"?"gray.700":"gray.200",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:c?e.jsx(se,{isChecked:p,spacing:4,onChange:F=>{n&&n(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(gs,{workflow:t}):e.jsx(z,{color:"GrayText",fontSize:"sm",children:St(t.updateTime,!1,!1,"/")})})]})})});function Ue({items:a}){var m;const[t,o]=r.useState(!1),l=a.filter(Z),c=a.filter(i=>!Z(i)),n=(m=c[0])==null?void 0:m.parentFolderID,[d,p]=r.useState(!1),{onRefreshFilesList:s,draggingFile:u,refreshFolderStamp:h}=r.useContext(G),g=async i=>{var f,v;if(i.preventDefault(),i.stopPropagation(),!u)return p(!1);if(Z(u)){if(u.id===n)return p(!1);await((f=$)==null?void 0:f.update(u.id,{parentFolderID:n}))}else await((v=O)==null?void 0:v.updateFolder(u.id,{parentFolderID:n}));await(s==null?void 0:s()),p(!1)};return r.useEffect(()=>{var i;(i=C)==null||i.getSetting("foldersOnTop").then(f=>{o(f??!1)})},[h]),e.jsxs(e.Fragment,{children:[t&&l.map(i=>e.jsx(Le,{folder:i},i.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:i=>{i.preventDefault(),i.stopPropagation(),p(!0)},onDragLeave:i=>{i.preventDefault(),i.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?c.map(i=>e.jsx(ze,{workflow:i},i.id)):a.map(i=>Z(i)?e.jsx(Le,{folder:i},i.id):e.jsx(ze,{workflow:i},i.id))})]})}function Ss({onClose:a,onClickNewFlow:t}){const[o,l]=r.useState([]),c=r.useRef([]),{loadWorkflowID:n,curFlowID:d}=r.useContext(le),[p,s]=r.useState(),[u,h]=r.useState(!1),[g,m]=r.useState([]),[i,f]=r.useState(0),[v,S]=r.useState(""),w=Tt(v,400),b=r.useRef(null),[F,j]=r.useState(null),L=r.useRef(window.localStorage.getItem(he)??q.RECENTLY_MODIFIED),K=!!p||!!w.length,H=async()=>{var I,D;const x=await((I=O)==null?void 0:I.listFolderContent())??[];l(ue(x,L.current)),f(Date.now()),c.current=await((D=O)==null?void 0:D.listAll())??[]},X=()=>{const x=c.current.filter(I=>{var Ce;let D=!0,M=!0;return p&&(D=!!((Ce=I.tags)!=null&&Ce.includes(p))),w&&(M=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),D&&M});l(ue(x,L.current))},ae=x=>{l(ue(o,x)),L.current=x,window.localStorage.setItem(he,x),!K&&f(Date.now())};r.useEffect(()=>{K?X():H()},[w,p]);const oe=r.useCallback(async x=>{var I,D,M;await((I=O)==null?void 0:I.deleteFlow(x)),((M=(D=O)==null?void 0:D.curWorkflow)==null?void 0:M.id)===x&&await(n==null?void 0:n(null)),await H()},[p,w]);r.useEffect(()=>{const x=async I=>{var D;if(b.current){const M=await((D=O)==null?void 0:D.get(b.current));M&&M.json&&Dt(M.json,[I.canvasX,I.canvasY])}};return ie.canvasEl.addEventListener("drop",x),ie.canvasEl.addEventListener("click",a),()=>{ie.canvasEl.removeEventListener("drop",x),ie.canvasEl.removeEventListener("click",a)}},[]);const ce=r.useCallback((x,I)=>{m(D=>{const M=[...D];return I?M.push(x):M.splice(M.indexOf(x),1),M})},[]),y=(x,I)=>{var D;switch(x){case"batchDelete":d&&((D=O)==null||D.get(d).then(M=>{M||n==null||n(null)})),H(),h(!1),m([]);return;case"selectAll":m(I?c.current.map(M=>M.id):[]);return}},k=x=>{j(x),Z(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:u,onMultiSelectFlow:ce,multiSelectedFlowsID:g,onDeleteFlow:oe,refreshFolderStamp:i,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(U,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(N,{gap:4,children:[e.jsx(N,{gap:2,children:e.jsx(z,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ve,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(A,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(Ae,{}),variant:"outline",colorScheme:"teal",onClick:()=>It()})}),e.jsx(R,{label:"New workflow",children:e.jsx(A,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Ge,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(N,{alignItems:"center",children:e.jsx(ls,{})})]}),e.jsxs(U,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(ds,{selectedTag:p,setSelectedTag:s}),e.jsxs(N,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(N,{children:[e.jsx(cs,{multipleState:u,changeMultipleState:x=>{h(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===c.current.length,batchOperationCallback:y}),!u&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(A,{size:"sm",variant:"outline",icon:e.jsx($e,{size:21}),onClick:async()=>{var x;await((x=$)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(ne,{as:W,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(ke,{size:"16"}),children:e.jsxs(N,{children:[e.jsx(z,{children:"Sort by:"}),e.jsx(z,{display:"inline-block",children:L.current})]})}),e.jsx(te,{children:e.jsx(He,{value:L.current,type:"radio",onChange:x=>ae(x),children:[q.RECENTLY_MODIFIED,q.OLDEST_MODIFIED,q.AZ,q.ZA].map((x,I)=>e.jsx(Se,{value:x,children:x},I))})})]})]}),e.jsx(Wt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(U,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Ue,{items:o})})]})]})})})}export{Ss as default};
diff --git a/dist/workspace_web/ShareDialog-DSSo_bep.js b/dist/workspace_web/ShareDialog-DSSo_bep.js
new file mode 100644
index 0000000..3f108ee
--- /dev/null
+++ b/dist/workspace_web/ShareDialog-DSSo_bep.js
@@ -0,0 +1 @@
+import{f as te,n as me,o as ge,j as e,g as ae,e as ne,r as u,m as xe,w as Q,b as we,h as M,a0 as X,M as je,T as ve,N as be,U as ye,O as ke}from"./input.js";import{B as Ce,z as Se,a6 as Ie,f as P,H as A,ae as Re,a5 as D,ah as F,an as Ee,aA as ee,aF as De,W as Ne,e as Pe,F as se,aG as Te,I as We,h as oe,w as O,a1 as Oe,aH as _e,aI as Fe,aJ as Me,T as ze,k as Le,aK as Ae,Z as Ge}from"./App-9GIQJeUY.js";import{I as He}from"./chunk-7D6N5TE5-gOmt0HWF.js";import{a as Ue}from"./civitUtils-TPBejtrP.js";import{S as Be,L as Ve}from"./chunk-VTV6N5LE-VcPf7MxV.js";import{I as Ke}from"./IconCopy-RhFbFhX0.js";var re=te(function(i,l){const r=me("Badge",i),{className:o,...s}=ge(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function $e(n){return n&&Q(n)&&Q(n.target)}function Je(n={}){const{onChange:i,value:l,defaultValue:r,name:o,isDisabled:s,isFocusable:f,isNative:b,...d}=n,[y,v]=u.useState(r||""),h=typeof l<"u",x=h?l:y,w=u.useRef(null),t=u.useCallback(()=>{const m=w.current;if(!m)return;let g="input:not(:disabled):checked";const T=m.querySelector(g);if(T){T.focus();return}g="input:not(:disabled)";const N=m.querySelector(g);N==null||N.focus()},[]),j=`radio-${u.useId()}`,p=o||j,I=u.useCallback(m=>{const g=$e(m)?m.target.value:m;h||v(g),i==null||i(String(g))},[i,h]),k=u.useCallback((m={},g=null)=>({...m,ref:xe(g,w),role:"radiogroup"}),[]),z=u.useCallback((m={},g=null)=>({...m,ref:g,name:p,[b?"checked":"isChecked"]:x!=null?m.value===x:void 0,onChange(N){I(N)},"data-radiogroup":!0}),[b,p,I,x]);return{getRootProps:k,getRadioProps:z,name:p,ref:w,focus:t,setValue:v,value:x,onChange:I,isDisabled:s,isFocusable:f,htmlProps:d}}var[qe,rs]=we({name:"RadioGroupContext",strict:!1}),ie=te((n,i)=>{const{colorScheme:l,size:r,variant:o,children:s,className:f,isDisabled:b,isFocusable:d,...y}=n,{value:v,onChange:h,getRootProps:x,name:w,htmlProps:t}=Je(y),E=u.useMemo(()=>({name:w,size:r,onChange:h,colorScheme:l,value:v,variant:o,isDisabled:b,isFocusable:d}),[w,r,h,l,v,o,b,d]);return e.jsx(qe,{value:E,children:e.jsx(ae.div,{...x(t,i),className:ne("chakra-radio-group",f),children:s})})});ie.displayName="RadioGroup";function Ye({options:n,value:i,onChange:l}){const[r,o]=u.useState(!1),s=u.useRef(null),f=n.find(d=>d.value===i);u.useEffect(()=>{const d=y=>{s.current&&!s.current.contains(y.target)&&o(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]);const b=()=>o(!r);return e.jsxs(Ce,{position:"relative",children:[e.jsx(M,{onClick:b,rightIcon:e.jsx(Se,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),r&&e.jsx(Ie,{gap:4,ref:s,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:n.map(d=>e.jsx(M,{onClick:()=>{o(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Ze({deps:n,uploadingImage:i}){const l=Object.values((n==null?void 0:n.images)??{});return n?e.jsx(P,{gap:5,children:l.length>0&&e.jsxs(P,{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(X,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(P,{children:[e.jsx("p",{children:r.filename}),e.jsx(He,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(X,{size:"md",color:"teal.400"})}async function Qe(n,i,l){const r=await Ee.models.where("fileName").equals(n).toArray()??[],o=r.at(0);return{name:n,nodeType:i,hash:(o==null?void 0:o.fileHash)??null,folder:(o==null?void 0:o.fileFolder)??null,url:o!=null&&o.civitModelVersionID?Ue(o.civitModelVersionID):(o==null?void 0:o.downloadUrl)??null,inputName:l,length:r.length}}async function Xe(n){var x,w;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],o=[".jpeg",".jpg",".png",".gif",".webp"],s=(w=(x=D.graph.extra)==null?void 0:x[F])==null?void 0:w.deps,f=await D.graphToPrompt();Object.values(f.output).forEach(t=>{t.inputs&&Object.keys(t.inputs).forEach(E=>{var p,I;const j=(p=t.inputs)==null?void 0:p[E];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Qe(j,t.class_type,E)),o.some(k=>j.endsWith(k))&&(l[j]=((I=s==null?void 0:s.images)==null?void 0:I[j])??{filename:j,nodeType:t.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:n.map(t=>t.type)})}).then(t=>t.ok?t.json():[]).catch(t=>(console.error("Error fetching node repos",t),[])),y=await Promise.all(i),v={};y.forEach(t=>{v[t.name]=t});const h={};return Object.values(d).forEach(t=>{h[t.gitRepo]=t}),{models:v,images:l,nodeRepos:Object.values(h)}}function is({onClose:n}){var G,H,U,B,V;const[i,l,r]=ee("v"+De()),{saveCurWorkflow:o}=u.useContext(Ne),[s,f]=u.useState(),[b,d]=u.useState(!1),[y,v]=u.useState(!1),h=(H=(G=oe)==null?void 0:G.settings)==null?void 0:H.cloudHost,[x,w,t]=ee("PRIVATE"),[E,j]=u.useState("new_version"),p=(U=O)==null?void 0:U.curWorkflow,I=Pe(),[k,z]=u.useState(!0),m=async a=>{var C;const c=a.data;if(c.type!=="share_workflow_success"||!p)return;const S=c.version.id,R=c.version.workflowID;R&&await((C=O)==null?void 0:C.updateMetaInfo(p.id,{cloudID:R})),g(),window.open(h+"/workflow/"+R+"/"+S,"_blank"),v(!1)};u.useEffect(()=>{g();const a=D.graph.serialize();return Xe(a.nodes??[]).then(c=>{f(c)}),window.addEventListener("message",m),()=>{window.removeEventListener("message",m)}},[]);const g=async()=>{p!=null&&p.cloudID&&p.cloudOrigin&&Me(p).then(a=>{w(a)})},T=a=>{navigator.clipboard.writeText(a).then(()=>{I({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},N=async a=>{var J,q,Y;const c=D.graph.serialize();(J=c.extra||(c.extra={}))[q=F]||(J[q]={}),c.extra[F].deps={models:(s==null?void 0:s.models)??{},images:a??{},nodeRepos:(s==null?void 0:s.nodeRepos)??[]},await o(),await D.graphToPrompt(D.graph).then(W=>(c.extra[F].apiPrompt=W.output,W.output));const S=JSON.stringify(c);v(!0);const R=_e(32),C=await((Y=oe)==null?void 0:Y.getSetting("cloudHost"));let K;K=Fe(),r.current,S??JSON.stringify(D.graph.serialize());const ce=window.location.protocol,de=window.location.host,ue=`${ce}//${de}`,he=C+`/share_workflow_confirm/${R}?redirectUrl=${ue}`,pe=window.open(he,"Share Workflow","width=800,height=800"),$=W=>{var Z;if(W.origin===C&&W.data==="child_ready"){const L=(Z=O)==null?void 0:Z.curWorkflow;if(!L)return;const fe={workflow:{name:L.name,cloudID:L.cloudID},version:{name:r.current,json:S},nodeDefs:K,privacy:t.current};pe.postMessage(fe,C),window.removeEventListener("message",$)}};window.addEventListener("message",$)},le=async()=>{const a=(s==null?void 0:s.images)??{};if(k){d(!0);const c=Object.values((s==null?void 0:s.images)??{}).map(S=>S.filename);if(c.length)try{const R=await(await Oe("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(R).forEach(C=>{a!=null&&a[C]&&(a[C].url=R[C])})}catch(S){console.error("Error uploading images:",S)}d(!1)}N(a)},_=(V=(B=O)==null?void 0:B.curWorkflow)==null?void 0:V.cloudID;return e.jsxs(je,{isOpen:!0,onClose:n,size:"lg",children:[e.jsx(ve,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:[e.jsxs(se,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',p==null?void 0:p.name,'"']}),e.jsx(M,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:y,children:y?"Sharing":"Share"})]}),h&&e.jsxs(ze,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(h).host]})]}),e.jsx(ke,{pb:10,children:e.jsxs(P,{gap:5,children:[_==null?e.jsx(Ye,{options:Te,value:x,onChange:a=>{w(a)}}):e.jsx(Le,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ae,{privacy:x,showEmoji:!0})}),_&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Ve,{wordBreak:"break-all",href:h+"/workflow/"+_,isExternal:!0,children:[h+"/workflow/"+_," ",e.jsx(Ge,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(M,{size:"sm",leftIcon:e.jsx(Ke,{size:18}),onClick:()=>{var a,c;T(h+"/workflow/"+((c=(a=O)==null?void 0:a.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:a=>{j(a)},value:E,children:e.jsx(P,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(We,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:a=>{l(a.target.value)}}),e.jsx(se,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((s==null?void 0:s.images)??{}).length>0&&e.jsxs(P,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Be,{isChecked:k,onChange:()=>z(!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"," ",h]}),k&&e.jsx(Ze,{deps:s??null,setDeps:f,uploadingImage:b})]})]})})]})]})}export{is as default};
diff --git a/dist/workspace_web/ShareDialog-g_a6xMAM.js b/dist/workspace_web/ShareDialog-g_a6xMAM.js
deleted file mode 100644
index 6c1285e..0000000
--- a/dist/workspace_web/ShareDialog-g_a6xMAM.js
+++ /dev/null
@@ -1 +0,0 @@
-import{f as te,n as fe,o as ge,j as e,g as ae,e as ne,r as u,m as we,w as Q,b as xe,h as M,a0 as X,M as je,T as ve,N as ye,U as be,O as ke}from"./input.js";import{B as Se,z as Ce,a5 as Ie,f as P,H as A,ad as Re,a4 as E,ag as F,am as De,az as ee,W as Ee,e as Ne,F as se,aE as Pe,I as Te,h as oe,w as O,a0 as We,aF as Oe,aG as _e,aH as Fe,T as Me,k as ze,aI as Le,Z as Ae}from"./App-ZTJclgGW.js";import{I as Ge}from"./chunk-7D6N5TE5-wlKuxWhy.js";import{a as He}from"./civitUtils-T1Lq3reo.js";import{S as Ue,L as Be}from"./chunk-VTV6N5LE-qccSGxq6.js";import{I as Ve}from"./IconCopy-zZpZ6D5h.js";var re=te(function(i,l){const r=fe("Badge",i),{className:t,...s}=ge(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function $e(o){return o&&Q(o)&&Q(o.target)}function Ke(o={}){const{onChange:i,value:l,defaultValue:r,name:t,isDisabled:s,isFocusable:m,isNative:y,...d}=o,[b,v]=u.useState(r||""),h=typeof l<"u",w=h?l:b,x=u.useRef(null),a=u.useCallback(()=>{const f=x.current;if(!f)return;let g="input:not(:disabled):checked";const T=f.querySelector(g);if(T){T.focus();return}g="input:not(:disabled)";const N=f.querySelector(g);N==null||N.focus()},[]),j=`radio-${u.useId()}`,p=t||j,I=u.useCallback(f=>{const g=$e(f)?f.target.value:f;h||v(g),i==null||i(String(g))},[i,h]),k=u.useCallback((f={},g=null)=>({...f,ref:we(g,x),role:"radiogroup"}),[]),z=u.useCallback((f={},g=null)=>({...f,ref:g,name:p,[y?"checked":"isChecked"]:w!=null?f.value===w:void 0,onChange(N){I(N)},"data-radiogroup":!0}),[y,p,I,w]);return{getRootProps:k,getRadioProps:z,name:p,ref:x,focus:a,setValue:v,value:w,onChange:I,isDisabled:s,isFocusable:m,htmlProps:d}}var[qe,rs]=xe({name:"RadioGroupContext",strict:!1}),ie=te((o,i)=>{const{colorScheme:l,size:r,variant:t,children:s,className:m,isDisabled:y,isFocusable:d,...b}=o,{value:v,onChange:h,getRootProps:w,name:x,htmlProps:a}=Ke(b),D=u.useMemo(()=>({name:x,size:r,onChange:h,colorScheme:l,value:v,variant:t,isDisabled:y,isFocusable:d}),[x,r,h,l,v,t,y,d]);return e.jsx(qe,{value:D,children:e.jsx(ae.div,{...w(a,i),className:ne("chakra-radio-group",m),children:s})})});ie.displayName="RadioGroup";function Je({options:o,value:i,onChange:l}){const[r,t]=u.useState(!1),s=u.useRef(null),m=o.find(d=>d.value===i);u.useEffect(()=>{const d=b=>{s.current&&!s.current.contains(b.target)&&t(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]);const y=()=>t(!r);return e.jsxs(Se,{position:"relative",children:[e.jsx(M,{onClick:y,rightIcon:e.jsx(Ce,{}),leftIcon:m==null?void 0:m.icon,children:m==null?void 0:m.label}),r&&e.jsx(Ie,{gap:4,ref:s,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:o.map(d=>e.jsx(M,{onClick:()=>{t(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Ye({deps:o,uploadingImage:i}){const l=Object.values((o==null?void 0:o.images)??{});return o?e.jsx(P,{gap:5,children:l.length>0&&e.jsxs(P,{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(X,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(P,{children:[e.jsx("p",{children:r.filename}),e.jsx(Ge,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(X,{size:"md",color:"teal.400"})}async function Ze(o,i,l){const r=await De.models.where("fileName").equals(o).toArray()??[],t=r.at(0);return{name:o,nodeType:i,hash:(t==null?void 0:t.fileHash)??null,folder:(t==null?void 0:t.fileFolder)??null,url:t!=null&&t.civitModelVersionID?He(t.civitModelVersionID):(t==null?void 0:t.downloadUrl)??null,inputName:l,length:r.length}}async function Qe(o){var w,x;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],t=[".jpeg",".jpg",".png",".gif",".webp"],s=(x=(w=E.graph.extra)==null?void 0:w[F])==null?void 0:x.deps,m=await E.graphToPrompt();Object.values(m.output).forEach(a=>{a.inputs&&Object.keys(a.inputs).forEach(D=>{var p,I;const j=(p=a.inputs)==null?void 0:p[D];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Ze(j,a.class_type,D)),t.some(k=>j.endsWith(k))&&(l[j]=((I=s==null?void 0:s.images)==null?void 0:I[j])??{filename:j,nodeType:a.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:o.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 h={};return Object.values(d).forEach(a=>{h[a.gitRepo]=a}),{models:v,images:l,nodeRepos:Object.values(h)}}function is({onClose:o}){var G,H,U,B,V;const[i,l,r]=ee("v"+Xe()),{saveCurWorkflow:t}=u.useContext(Ee),[s,m]=u.useState(),[y,d]=u.useState(!1),[b,v]=u.useState(!1),h=(H=(G=oe)==null?void 0:G.settings)==null?void 0:H.cloudHost,[w,x,a]=ee("PRIVATE"),[D,j]=u.useState("new_version"),p=(U=O)==null?void 0:U.curWorkflow,I=Ne(),[k,z]=u.useState(!0),f=async n=>{var S;const c=n.data;if(c.type!=="share_workflow_success"||!p)return;const C=c.version.id,R=c.version.workflowID;R&&await((S=O)==null?void 0:S.updateMetaInfo(p.id,{cloudID:R})),g(),window.open(h+"/workflow/"+R+"/"+C,"_blank"),v(!1)};u.useEffect(()=>{g();const n=E.graph.serialize();return Qe(n.nodes??[]).then(c=>{m(c)}),window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[]);const g=async()=>{p!=null&&p.cloudID&&p.cloudOrigin&&Fe(p).then(n=>{x(n)})},T=n=>{navigator.clipboard.writeText(n).then(()=>{I({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},N=async n=>{var q,J,Y;const c=E.graph.serialize();(q=c.extra||(c.extra={}))[J=F]||(q[J]={}),c.extra[F].deps={models:(s==null?void 0:s.models)??{},images:n??{},nodeRepos:(s==null?void 0:s.nodeRepos)??[]},await t(),await E.graphToPrompt(E.graph).then(W=>(c.extra[F].apiPrompt=W.output,W.output));const C=JSON.stringify(c);v(!0);const R=Oe(32),S=await((Y=oe)==null?void 0:Y.getSetting("cloudHost"));let $;$=_e(),r.current,C??JSON.stringify(E.graph.serialize());const ce=window.location.protocol,de=window.location.host,ue=`${ce}//${de}`,he=S+`/share_workflow_confirm/${R}?redirectUrl=${ue}`,pe=window.open(he,"Share Workflow","width=800,height=800"),K=W=>{var Z;if(W.origin===S&&W.data==="child_ready"){const L=(Z=O)==null?void 0:Z.curWorkflow;if(!L)return;const me={workflow:{name:L.name,cloudID:L.cloudID},version:{name:r.current,json:C},nodeDefs:$,privacy:a.current};pe.postMessage(me,S),window.removeEventListener("message",K)}};window.addEventListener("message",K)},le=async()=>{const n=(s==null?void 0:s.images)??{};if(k){d(!0);const c=Object.values((s==null?void 0:s.images)??{}).map(C=>C.filename);if(c.length)try{const R=await(await We("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(R).forEach(S=>{n!=null&&n[S]&&(n[S].url=R[S])})}catch(C){console.error("Error uploading images:",C)}d(!1)}N(n)},_=(V=(B=O)==null?void 0:B.curWorkflow)==null?void 0:V.cloudID;return e.jsxs(je,{isOpen:!0,onClose:o,size:"lg",children:[e.jsx(ve,{}),e.jsxs(ye,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(be,{children:[e.jsxs(se,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',p==null?void 0:p.name,'"']}),e.jsx(M,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:b,children:b?"Sharing":"Share"})]}),h&&e.jsxs(Me,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(h).host]})]}),e.jsx(ke,{pb:10,children:e.jsxs(P,{gap:5,children:[_==null?e.jsx(Je,{options:Pe,value:w,onChange:n=>{x(n)}}):e.jsx(ze,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Le,{privacy:w,showEmoji:!0})}),_&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{wordBreak:"break-all",href:h+"/workflow/"+_,isExternal:!0,children:[h+"/workflow/"+_," ",e.jsx(Ae,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(M,{size:"sm",leftIcon:e.jsx(Ve,{size:18}),onClick:()=>{var n,c;T(h+"/workflow/"+((c=(n=O)==null?void 0:n.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:n=>{j(n)},value:D,children:e.jsx(P,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(Te,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:n=>{l(n.target.value)}}),e.jsx(se,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((s==null?void 0:s.images)??{}).length>0&&e.jsxs(P,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Ue,{isChecked:k,onChange:()=>z(!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"," ",h]}),k&&e.jsx(Ye,{deps:s??null,setDeps:m,uploadingImage:y})]})]})})]})]})}function Xe(){const o=new Date,i=o.getFullYear(),l=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");return`${i}-${l}-${r}`}export{is as default};
diff --git a/dist/workspace_web/SpotlightSearch-T7ZdSk0R.js b/dist/workspace_web/SpotlightSearch-rjI_Y8hu.js
similarity index 89%
rename from dist/workspace_web/SpotlightSearch-T7ZdSk0R.js
rename to dist/workspace_web/SpotlightSearch-rjI_Y8hu.js
index b1debb5..2c06af3 100644
--- a/dist/workspace_web/SpotlightSearch-T7ZdSk0R.js
+++ b/dist/workspace_web/SpotlightSearch-rjI_Y8hu.js
@@ -1 +1 @@
-import{b as Z,f as j,k as $,o as q,e as w,r as g,j as n,g as A,Z as J,M as Q,N as X,a0 as ee,h as te}from"./input.js";import{aD as ne,aj as se,W as re,az as T,ah as D,H as ae,I as oe,T as G,a2 as ie,w as ce,a3 as le,E as ue,h as O}from"./App-ZTJclgGW.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-hyGkJAd5.js";import{V as he}from"./chunk-NTCQBYKE-vNLNCBtA.js";var[me,ge]=Z({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=$("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function Ie(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},W=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,U]=pe(W,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),U(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(G,{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(G,{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=O)==null||k.getSetting("shortcuts").then(h=>{var F;const L=(h.openSpotlightSearch??((F=O)==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(D,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(D,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};
+import{b as Z,f as j,k as $,o as q,e as w,r as g,j as n,g as A,Z as J,M as Q,N as X,a0 as ee,h as te}from"./input.js";import{aE as ne,ak as se,W as re,aA as T,ai as G,H as ae,I as oe,T as D,a3 as ie,w as ce,a4 as le,E as ue,h as O}from"./App-9GIQJeUY.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-srLS9f0l.js";import{V as he}from"./chunk-NTCQBYKE-ROuYoItA.js";var[me,ge]=Z({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=$("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function Ie(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},W=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[H,U]=pe(W,300),V=e=>{I(e.target.value),e.target.value?(H(),!s&&p(!0)):(p(!1),U(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(D,{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(D,{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=O)==null||k.getSetting("shortcuts").then(h=>{var F;const L=(h.openSpotlightSearch??((F=O)==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-oKoElBXY.js b/dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js
similarity index 81%
rename from dist/workspace_web/chunk-3RSXBRAN-oKoElBXY.js
rename to dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js
index 7a15973..2d3b87e 100644
--- a/dist/workspace_web/chunk-3RSXBRAN-oKoElBXY.js
+++ b/dist/workspace_web/chunk-3RSXBRAN-WBOq6SL0.js
@@ -1 +1 @@
-import{f as x,j as l,g as i,e as w,k as C,o as E,l as I,r as f,a3 as P}from"./input.js";import{ab as z}from"./App-ZTJclgGW.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:w("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},b={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:b,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{ac as z}from"./App-9GIQJeUY.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-wlKuxWhy.js b/dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js
similarity index 98%
rename from dist/workspace_web/chunk-7D6N5TE5-wlKuxWhy.js
rename to dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js
index 227271f..c537918 100644
--- a/dist/workspace_web/chunk-7D6N5TE5-wlKuxWhy.js
+++ b/dist/workspace_web/chunk-7D6N5TE5-gOmt0HWF.js
@@ -1 +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{af as pe}from"./App-ZTJclgGW.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};
+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{ag as pe}from"./App-9GIQJeUY.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-JARCRF6W-UTrQeKCZ.js b/dist/workspace_web/chunk-JARCRF6W-1gGfj837.js
similarity index 97%
rename from dist/workspace_web/chunk-JARCRF6W-UTrQeKCZ.js
rename to dist/workspace_web/chunk-JARCRF6W-1gGfj837.js
index bd927a7..8c2614f 100644
--- a/dist/workspace_web/chunk-JARCRF6W-UTrQeKCZ.js
+++ b/dist/workspace_web/chunk-JARCRF6W-1gGfj837.js
@@ -1 +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-wlKuxWhy.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};
+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-gOmt0HWF.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-vNLNCBtA.js b/dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js
similarity index 65%
rename from dist/workspace_web/chunk-NTCQBYKE-vNLNCBtA.js
rename to dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js
index 714c943..703d4bb 100644
--- a/dist/workspace_web/chunk-NTCQBYKE-vNLNCBtA.js
+++ b/dist/workspace_web/chunk-NTCQBYKE-ROuYoItA.js
@@ -1 +1 @@
-import{f as t}from"./App-ZTJclgGW.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{f as t}from"./App-9GIQJeUY.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-qccSGxq6.js b/dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js
similarity index 95%
rename from dist/workspace_web/chunk-VTV6N5LE-qccSGxq6.js
rename to dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js
index 3b00f4c..fa896a2 100644
--- a/dist/workspace_web/chunk-VTV6N5LE-qccSGxq6.js
+++ b/dist/workspace_web/chunk-VTV6N5LE-VcPf7MxV.js
@@ -1 +1 @@
-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-wlKuxWhy.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};
+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-gOmt0HWF.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-T1Lq3reo.js b/dist/workspace_web/civitUtils-TPBejtrP.js
similarity index 91%
rename from dist/workspace_web/civitUtils-T1Lq3reo.js
rename to dist/workspace_web/civitUtils-TPBejtrP.js
index 2fecbbe..9b58a99 100644
--- a/dist/workspace_web/civitUtils-T1Lq3reo.js
+++ b/dist/workspace_web/civitUtils-TPBejtrP.js
@@ -1 +1 @@
-import{h as m}from"./App-ZTJclgGW.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function h(){return localStorage.getItem(r)}function g(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,h as g,g as s};
+import{h as m}from"./App-9GIQJeUY.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function h(){return localStorage.getItem(r)}function g(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,h as g,g as s};
diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js
index a497b3d..cd44f8e 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-ZTJclgGW.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,_w as N,$w as O,ja as P,Aw as Q,Pw as R,xb as S,Ew as T,Tw 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};
+ `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-9GIQJeUY.js").then(e=>e.aL),__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,_w as N,$w as O,ja as P,Aw as Q,Pw as R,xb as S,Ew as T,Tw 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-ZTJclgGW.js","workspace_web/assets/App-JXePnJiV.css"]
+ __vite__mapDeps.viteFileDeps = ["workspace_web/App-9GIQJeUY.js","workspace_web/assets/App-JXePnJiV.css"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
\ No newline at end of file