diff --git a/dist/workspace_web/App-bqAziDgv.js b/dist/workspace_web/App-sgH6j00M.js similarity index 99% rename from dist/workspace_web/App-bqAziDgv.js rename to dist/workspace_web/App-sgH6j00M.js index dcd38d7..6964675 100644 --- a/dist/workspace_web/App-bqAziDgv.js +++ b/dist/workspace_web/App-sgH6j00M.js @@ -7,7 +7,7 @@ var kl=Object.defineProperty;var xl=(t,e,n)=>e in t?kl(t,e,{enumerable:!0,config From previous: `);return this._state!==null&&(this._stack=t),t}finally{Bo=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ce.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&pt(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),on.env=Hi(),un(oe,{all:function(){var t=ft.apply(null,arguments).map(or);return new oe(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>oe.resolve(o).then(i=>{t[s]=i,--r||e(t)},n))})},resolve:t=>{if(t instanceof oe)return t;if(t&&typeof t.then=="function")return new oe((n,r)=>{t.then(n,r)});var e=new oe(Bn,!0,t);return Vi(e,zo),e},reject:rr,race:function(){var t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ie,set:t=>ie=t},totalEchoes:{get:()=>Pr},newPSD:St,usePSD:pn,scheduler:{get:()=>On,set:t=>{On=t}},rejectionMapper:{get:()=>Lo,set:t=>{Lo=t}},follow:(t,e)=>new oe((n,r)=>St((o,s)=>{var i=ie;i.unhandleds=[],i.onunhandled=s,i.finalize=qt(function(){(function(a){function l(){a(),mr.splice(mr.indexOf(l),1)}mr.push(l),++Wt,On(()=>{--Wt==0&&Ws()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),hr&&(hr.allSettled&&pt(oe,"allSettled",function(){const t=ft.apply(null,arguments).map(or);return new oe(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>oe.resolve(o).then(i=>r[s]={status:"fulfilled",value:i},i=>r[s]={status:"rejected",reason:i}).then(()=>--n||e(r)))})}),hr.any&&typeof AggregateError<"u"&&pt(oe,"any",function(){const t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,i)=>oe.resolve(s).then(a=>e(a),a=>{o[i]=a,--r||n(new AggregateError(o))}))})}));const Be={awaits:0,echoes:0,id:0};var jf=0,yr=[],uo=0,Pr=0,Af=0;function St(t,e,n,r){var o=ie,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Af;var i=on.env;s.env=zs?{Promise:oe,PromiseProp:{value:oe,configurable:!0,writable:!0},all:oe.all,race:oe.race,allSettled:oe.allSettled,any:oe.any,resolve:oe.resolve,reject:oe.reject,nthen:ma(i.nthen,s),gthen:ma(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=pn(s,t,n,r);return s.ref===0&&s.finalize(),a}function hn(){return Be.id||(Be.id=++jf),++Be.awaits,Be.echoes+=Li,Be.id}function vt(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Li,!0)}function or(t){return Be.echoes&&t&&t.constructor===hr?(hn(),t.then(e=>(vt(),e),e=>(vt(),Ne(e)))):t}function Nf(t){++Pr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),yr.push(ie),Ot(t,!0)}function Ff(){var t=yr[yr.length-1];yr.pop(),Ot(t,!1)}function Ot(t,e){var n=ie;if((e?!Be.echoes||uo++&&t===ie:!uo||--uo&&t===ie)||Zi(e?Nf.bind(null,t):Ff),t!==ie&&(ie=t,n===on&&(on.env=Hi()),zs)){var r=on.env.Promise,o=t.env;Ir.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ce,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function Hi(){var t=Ce.Promise;return zs?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ce,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Ir.then,gthen:t.prototype.then}:{}}function pn(t,e,n,r,o){var s=ie;try{return Ot(t,!0),e(n,r,o)}finally{Ot(s,!1)}}function Zi(t){Wi.call(Ro,t)}function jr(t,e,n,r){return typeof t!="function"?t:function(){var o=ie;n&&hn(),Ot(e,!0);try{return t.apply(this,arguments)}finally{Ot(o,!1),r&&Zi(vt)}}}function ma(t,e){return function(n,r){return t.call(this,jr(n,e),jr(r,e))}}(""+Wi).indexOf("[native code]")===-1&&(hn=vt=be);const ya="unhandledrejection";function va(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ce.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ya,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(ya,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}lt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Ne=oe.reject;function Ko(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ie.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ko(t,e,n,r))):Ne(s)}return o._promise(e,(s,i)=>St(()=>(ie.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Ne(new ce.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Ne(new ce.DatabaseClosed);t.open().catch(be)}return t._state.dbReadyPromise.then(()=>Ko(t,e,n,r))}const ga="3.2.4",Rt="￿",$o=-1/0,ut="Invalid key provided. Keys must be of type string, number, Date or Array.",Gi="String expected.",In=[],eo=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Rf=eo,Tf=eo,Ji=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),to="__dbnames",fo="readonly",ho="readwrite";function Vt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Yi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Hn(e))[t],e)}class Bf{_trans(e,n,r){const o=this._tx||ie.trans,s=this.name;function i(l,c,u){if(!u.schema[s])throw new ce.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const a=Zn();try{return o&&o.db===this.db?o===ie.trans?o._promise(e,i,r):St(()=>o._promise(e,i,r),{trans:o,transless:ie.transless||ie}):Ko(this.db,e,[this.name],i)}finally{a&&Gn()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(o=>this.hook.reading.fire(o))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(Me(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=Ae(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==Rt)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&<&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[a,l]=n.reduce(([c,u],d)=>{const p=o[d],h=e[d];return[c||p,c||!p?Vt(u,p&&p.multi?g=>{const f=mt(g,d);return Me(f)&&f.some(y=>i(h,y))}:g=>i(h,mt(g,d))):u]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,Me(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const o=Object.create(e.prototype);for(var s in r)if(Ze(r,s))try{o[s]=r[s]}catch{}return o};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){Ue(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[s]})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||Me(e))return this.where(":id").equals(e).modify(n);{const r=mt(e,this.schema.primKey.keyPath);if(r===void 0)return Ne(new ce.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ae(n).forEach(o=>{nt(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:n!=null?[n]:null})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?oe.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Yi})).then(e=>e.numFailures?oe.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(o=>this.hook.reading.fire(o))))}bulkAdd(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,g)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,g)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new Sn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Dn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[i].subscribe.apply(null,c),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rVt(r(),e()):e,t.justLimit=n&&!r}function vr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ce.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function wa(t,e,n){const r=vr(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function ar(t,e,n,r){const o=t.replayFilter?Vt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,c)=>{if(!o||o(l,c,p=>l.stop(p),p=>l.fail(p))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Ze(s,d)||(s[d]=!0,e(a,l,c))}};return Promise.all([t.or._iterate(i,n),ba(wa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ba(wa(t,r,n),Vt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ba(t,e,n,r){var o=Se(r?(s,i,a)=>n(r(s),i,a):n);return t.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();e&&!e(s,a=>i=a,a=>{s.stop(a),i=be},a=>{s.fail(a),i=be})||o(s.value,s,a=>i=a),i()})})}function Le(t,e){try{const n=_a(t),r=_a(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tar(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Yt(r,!0))return o.count({trans:n,query:{index:vr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return ar(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(c,u){return u?i(c[r[u]],u-1):c[o]}var a=this._ctx.dir==="next"?1:-1;function l(c,u){var d=i(c,s),p=i(u,s);return dp?a:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Yt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=vr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:i})=>o?i.map(o):i)}{const o=[];return ar(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Yt(n)?mo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):mo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),mo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return po(this._ctx,function(r,o,s){return!e(r.value)||(o(s),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return po(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Vt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Yt(n,!0)&&n.limit>0)return this._read(o=>{var s=vr(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return po(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ze(r,s);return r[s]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=Ae(e),i=s.length;o=function(f){for(var y=!1,m=0;m{const{failures:m,numFailures:w}=y;p+=f-w;for(let _ of Ae(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const w=Math.min(u,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+w),cache:"immutable"}).then(_=>{const k=[],x=[],O=l?[]:null,E=[];for(let P=0;P0&&a.mutate({trans:r,type:"add",values:k}).then(P=>{for(let R in P.failures)E.splice(parseInt(R),1);g(k.length,P)})).then(()=>(x.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:x,criteria:N,changeSpec:typeof e!="function"&&e}).then(P=>g(x.length,P))).then(()=>(E.length>0||N&&e===yo)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(P=>g(E.length,P))).then(()=>f.length>m+w&&y(m+u))})};return y(0).then(()=>{if(d.length>0)throw new Or("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return Yt(e)&&(e.isPrimKey&&!Tf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:c,numFailures:u})=>{if(u)throw new Or("Could not delete some values",Object.keys(a).map(d=>a[d]),i-u);return i-u}))}):this.modify(yo)}}const yo=(t,e)=>e.value=null;function zf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Qi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Xt(t){return new t.Collection(t,()=>Xi("")).limit(0)}function Wf(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],c)<0&&(a=l)}return itypeof f=="string"))return qe(t,Gi);function p(f){o=function(m){return m==="next"?w=>w.toUpperCase():w=>w.toLowerCase()}(f),s=function(m){return m==="next"?w=>w.toLowerCase():w=>w.toUpperCase()}(f),i=f==="next"?zf:Lf;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,w){return i(m.lower,w.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),c=f,u=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>wt(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var g=0;return h._addAlgorithm(function(f,y,m){var w=f.key;if(typeof w!="string")return!1;var _=s(w);if(e(_,l,g))return!0;for(var k=null,x=g;x0)&&(k=O)}return y(k!==null?function(){f.continue(k+u)}:m),!1}),h}function wt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Xi(t){return{type:1,lower:t,upper:t}}class Qi{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,o){r=r!==!1,o=o===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||o)&&(!r||!o)?Xt(this):new this.Collection(this,()=>wt(e,n,!r,!o))}catch{return qe(this,ut)}}equals(e){return e==null?qe(this,ut):new this.Collection(this,()=>Xi(e))}above(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!1))}below(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Gi):this.between(e,e+Rt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ir(this,(n,r)=>n.indexOf(r[0])===0,[e],Rt)}equalsIgnoreCase(e){return ir(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Rt)}anyOf(){const e=ft.apply(Qt,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ut)}if(e.length===0)return Xt(this);const r=new this.Collection(this,()=>wt(e[0],e[e.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((s,i,a)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return i(a),!1;return n(l,e[o])===0||(i(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[$o,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=ft.apply(Qt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ut)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[$o,o]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,o=this._ascending,s=this._descending,i=this._min,a=this._max;if(e.length===0)return Xt(this);if(!e.every(w=>w[0]!==void 0&&w[1]!==void 0&&o(w[0],w[1])<=0))return qe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ce.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function p(w,_){return d(w[0],_[0])}try{u=e.reduce(function(w,_){let k=0,x=w.length;for(;k0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return k===x&&w.push(_),w},[]),u.sort(p)}catch{return qe(this,ut)}let h=0;const g=c?w=>o(w,u[h][1])>0:w=>o(w,u[h][1])>=0,f=l?w=>s(w,u[h][0])>0:w=>s(w,u[h][0])>=0;let y=g;const m=new this.Collection(this,()=>wt(u[0][0],u[u.length-1][1],!l,!c));return m._ondirectionchange=w=>{w==="next"?(y=g,d=o):(y=f,d=s),u.sort(p)},m._addAlgorithm((w,_,k)=>{for(var x=w.key;y(x);)if(++h,h===u.length)return _(k),!1;return!!function(O){return!g(O)&&!f(O)}(x)||(this._cmp(x,u[h][1])===0||this._cmp(x,u[h][0])===0||_(()=>{d===o?w.continue(u[h][0]):w.continue(u[h][1])}),!1)}),m}startsWithAnyOf(){const e=ft.apply(Qt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Xt(this):this.inAnyRange(e.map(n=>[n,n+Rt])):qe(this,"startsWithAnyOf() only works with strings")}}function st(t){return Se(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const zn="storagemutated",_t="x-storagemutated-1",It=Dn(null,zn);class Uf{_lock(){return bn(!ie.global),++this._reculock,this._reculock!==1||ie.global||(ie.lockOwnerFor=this),this}_unlock(){if(bn(!ie.global),--this._reculock==0)for(ie.global||(ie.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{pn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ie.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(bn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ce.DatabaseClosed(r);case"MissingAPIError":throw new ce.MissingAPI(r.message,r);default:throw new ce.OpenFailed(r)}if(!this.active)throw new ce.TransactionInactive;return bn(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Se(o=>{Mn(o),this._reject(e.error)}),e.onabort=Se(o=>{Mn(o),this.active&&this._reject(new ce.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&It.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Ne(new ce.ReadOnly("Transaction is readonly"));if(!this.active)return Ne(new ce.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ie])});if(r)return St(()=>{var s=new oe((i,a)=>{this._lock();const l=n(i,a,this);l&&l.then&&l.then(i,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new oe((s,i)=>{var a=n(s,i,this);a&&a.then&&a.then(s,i)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=oe.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=i)})()}var s=n._waitingFor;return new oe((i,a)=>{r.then(l=>n._waitingQueue.push(Se(i.bind(null,l))),l=>n._waitingQueue.push(Se(a.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ce.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ze(n,e))return n[e];const r=this.schema[e];if(!r)throw new ce.NotFound("Table "+e+" not part of transaction");const o=new this.db.Table(e,r,this);return o.core=this.db.core.table(e),n[e]=o,o}}function qo(t,e,n,r,o,s,i){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+el(e)}}function el(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function tl(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ai(n,r=>[r.name,r])}}let Ln=t=>{try{return t.only([[]]),Ln=()=>[[]],[[]]}catch{return Ln=()=>Rt,Rt}};function Vo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>mt(r,e)}(t):e=>mt(e,t)}function xa(t){return[].slice.call(t)}let Kf=0;function Pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function $f(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:p}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!p):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,c){const u=xa(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,g=Me(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:g,keyPath:p,autoIncrement:h,unique:!0,extractKey:Vo(p)},indexes:xa(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:_,unique:k,multiEntry:x,keyPath:O}=w,E={name:_,compound:Me(O),keyPath:O,unique:k,multiEntry:x,extractKey:Vo(O)};return y[Pn(O)]=E,E}),getIndexByKeyPath:w=>y[Pn(w)]};return y[":id"]=m.primaryKey,p!=null&&(y[Pn(p)]=m.primaryKey),m})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:p,keys:h,values:g,range:f}){return new Promise((y,m)=>{y=Se(y);const w=d.objectStore(u),_=w.keyPath==null,k=p==="put"||p==="add";if(!k&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:x}=h||g||{length:1};if(h&&g&&h.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(x===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let P=0;const R=j=>{++P,Mn(j)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:P,failures:N,results:[],lastResult:void 0});f.type===3?E.push(O=w.clear()):E.push(O=w.delete(r(f)))}else{const[j,B]=k?_?[g,h]:[g,null]:[h,null];if(k)for(let b=0;b{const B=j.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:P,failures:N,results:p==="delete"?h:E.map(b=>b.result),lastResult:B})};O.onerror=j=>{R(j),$(j)},O.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,g)=>{h=Se(h);const f=d.objectStore(u),y=p.length,m=new Array(y);let w,_=0,k=0;const x=E=>{const N=E.target;m[N._pos]=N.result,++k===_&&h(m)},O=st(g);for(let E=0;Enew Promise((h,g)=>{h=Se(h);const f=d.objectStore(u).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=st(g)}),query:function(d){return p=>new Promise((h,g)=>{h=Se(h);const{trans:f,values:y,limit:m,query:w}=p,_=m===1/0?void 0:m,{index:k,range:x}=w,O=f.objectStore(u),E=k.isPrimaryKey?O:O.index(k.name),N=r(x);if(m===0)return h({result:[]});if(d){const P=y?E.getAll(N,_):E.getAllKeys(N,_);P.onsuccess=R=>h({result:R.target.result}),P.onerror=st(g)}else{let P=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];R.onsuccess=j=>{const B=R.result;return B?($.push(y?B.value:B.primaryKey),++P===m?h({result:$}):void B.continue()):h({result:$})},R.onerror=st(g)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:g,unique:f}){return new Promise((y,m)=>{y=Se(y);const{index:w,range:_}=h,k=d.objectStore(u),x=w.isPrimaryKey?k:k.index(w.name),O=g?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in x)?x.openCursor(r(_),O):x.openKeyCursor(r(_),O);E.onerror=st(m),E.onsuccess=Se(N=>{const P=E.result;if(!P)return void y(null);P.___id=++Kf,P.done=!1;const R=P.continue.bind(P);let $=P.continuePrimaryKey;$&&($=$.bind(P));const j=P.advance.bind(P),B=()=>{throw new Error("Cursor not stopped")};P.trans=d,P.stop=P.continue=P.continuePrimaryKey=P.advance=()=>{throw new Error("Cursor not started")},P.fail=Se(m),P.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},P.start=b=>{const K=new Promise((S,G)=>{S=Se(S),E.onerror=st(G),P.fail=G,P.stop=z=>{P.stop=P.continue=P.continuePrimaryKey=P.advance=B,S(z)}}),te=()=>{if(E.result)try{b()}catch(S){P.fail(S)}else P.done=!0,P.start=()=>{throw new Error("Cursor behind last entry")},P.stop()};return E.onsuccess=Se(S=>{E.onsuccess=te,te()}),P.continue=R,P.continuePrimaryKey=$,P.advance=j,te(),K},y(P)},m)})},count({query:d,trans:p}){const{index:h,range:g}=d;return new Promise((f,y)=>{const m=p.objectStore(u),w=h.isPrimaryKey?m:m.index(h.name),_=r(g),k=_?w.count(_):w.count();k.onsuccess=Se(x=>f(x.target.result)),k.onerror=st(y)})}}}(l)),a={};return i.forEach(l=>a[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!a[l])throw new Error(`Table '${l}' not found`);return a[l]},MIN_KEY:-1/0,MAX_KEY:Ln(e),schema:o}}function Ho({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(u,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),u)}($f(s,i,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const s=o.name;t.core.schema.tables.some(i=>i.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function Ar({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Fs(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?pt(i,o,{get(){return this.table(o)},set(l){Di(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function Zo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function qf(t,e){return t._cfg.version-e._cfg.version}function Vf(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const i=s._reject.bind(s),a=ie.transless||ie;St(()=>{ie.trans=s,ie.transless=a,e===0?(Ae(o).forEach(l=>{vo(n,l,o[l].primKey,o[l].indexes)}),Ho(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},c,u,d){const p=[],h=l._versions;let g=l._dbSchema=Jo(l,l.idbdb,d),f=!1;const y=h.filter(w=>w._cfg.version>=c);function m(){return p.length?oe.resolve(p.shift()(u.idbtrans)).then(m):oe.resolve()}return y.forEach(w=>{p.push(()=>{const _=g,k=w._cfg.dbschema;Yo(l,_,d),Yo(l,k,d),g=l._dbSchema=k;const x=nl(_,k);x.add.forEach(E=>{vo(d,E[0],E[1].primKey,E[1].indexes)}),x.change.forEach(E=>{if(E.recreate)throw new ce.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(P=>Go(N,P)),E.change.forEach(P=>{N.deleteIndex(P.name),Go(N,P)}),E.del.forEach(P=>N.deleteIndex(P))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>c){Ho(l,d),u._memoizedTables={},f=!0;let E=Ni(k);x.del.forEach($=>{E[$]=_[$]}),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],Ae(E),E),u.schema=E;const N=Rs(O);let P;N&&hn();const R=oe.follow(()=>{if(P=O(u),P&&N){var $=vt.bind(null,null);P.then($,$)}});return P&&typeof P.then=="function"?oe.resolve(P):R.then(()=>P)}}),p.push(_=>{(!f||!Rf)&&function(k,x){[].slice.call(x.db.objectStoreNames).forEach(O=>k[O]==null&&x.db.deleteObjectStore(O))}(w._cfg.dbschema,_),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),m().then(()=>{var w,_;_=d,Ae(w=g).forEach(k=>{_.db.objectStoreNames.contains(k)||vo(_,k,w[k].primKey,w[k].indexes)})})}(t,e,s,n).catch(i)})}function nl(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const o=t[r],s=e[r];if(o){const i={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!eo)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let c;for(c in a)l[c]||i.del.push(c);for(c in l){const u=a[c],d=l[c];u?u.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function vo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>Go(o,s)),o}function Go(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Jo(t,e,n){const r={};return Sr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=qo(el(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return qo(l,c||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Me(c),a===0)}),s=o.shift();if(s.multi)throw new ce.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ce.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ce.Schema("Index must have a name and cannot be an empty string")}),n[r]=tl(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ue(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{Ue(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,Zo(n,[n._allTables,n,n.Transaction.prototype]),Ar(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ae(s),s),n._storeNames=Ae(s),this}upgrade(e){return this._cfg.contentUpgrade=Ms(this._cfg.contentUpgrade||be,e),this}}function Us(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Ut(to,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ks(t){return t&&typeof t.databases=="function"}function Xo(t){return St(function(){return ie.letThrough=!0,t()})}function Zf(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Gf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Ne(e.dbOpenError):t);lt&&(e.openCanceller._stackHolder=Ht()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ce.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Zf()).then(()=>new oe((l,c)=>{if(o(),!n)throw new ce.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new ce.MissingAPI;d.onerror=st(c),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,i.abort(),d.result.close();const g=n.deleteDatabase(u);g.onsuccess=g.onerror=Se(()=>{c(new ce.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{i.onerror=st(c);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,Vf(t,h/10,i,c)}},c),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Sr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((g=h).length===1?g[0]:g,"readonly");e.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const _=y._dbSchema=Jo(0,m,w);y._storeNames=Sr(m.objectStoreNames,0),Ar(y,[y._allTables],Ae(_),_)}(t,p,f):(Yo(t,t._dbSchema,f),function(y,m){const w=nl(Jo(0,y.idbdb,m),y._dbSchema);return!(w.add.length||w.change.some(_=>_.add.length||_.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ho(t,f)}catch{}var g;In.push(t),p.onversionchange=Se(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Se(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:y},m){!Ks(f)&&m!==to&&Us(f,y).put({name:m}).catch(be)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Xo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ms,be);return e.onReadyBeingFired=[],oe.resolve(Xo(()=>c(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Ne(l)}).finally(()=>{e.openComplete=!0,s()})}function Qo(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return i=>{var a=s(i),l=a.value;return a.done?l:l&&typeof l.then=="function"?l.then(n,r):Me(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function Jf(t,e,n){var r=arguments.length;if(r<2)throw new ce.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Fi(o),n]}function rl(t,e,n,r,o){return oe.resolve().then(()=>{const s=ie.transless||ie,i=t._createTransaction(e,n,t._dbSchema,r),a={trans:i,transless:s};if(r)i.idbtrans=r.idbtrans;else try{i.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>rl(t,e,n,null,o))):Ne(d)}const l=Rs(o);let c;l&&hn();const u=oe.follow(()=>{if(c=o.call(i,i),c)if(l){var d=vt.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Qo(c))},a);return(c&&typeof c.then=="function"?oe.resolve(c).then(d=>i.active?d:Ne(new ce.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Ne(d)))})}function lr(t,e,n){const r=Me(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Vo(u),unique:!y&&p.unique};return g.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?u[0]:u.slice(0,f-1),d+1,p),g.sort((w,_)=>w.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const u of r.indexes)i(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(p=u.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:lr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:lr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:u;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(u){const d=o[Pn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:p,keyLength:h}=u.query.index;return p?n.openCursor(l(u)).then(g=>g&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(lr(m,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?f.continue(f.key.slice(0,h).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,w){f.continuePrimaryKey(lr(m,t.MAX_KEY,d),w)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const m=f.key;return h===1?m[0]:m.slice(0,h)}},value:{get:()=>f.value}})}(g)):n.openCursor(u)}}}}}};function $s(t,e,n,r){return n=n||{},r=r||"",Ae(t).forEach(o=>{if(Ze(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Ao(s);a!==Ao(i)?n[r+o]=e[o]:a==="Object"?$s(s,i,n,r+o+"."):s!==i&&(n[r+o]=e[o])}else s!==i&&(n[r+o]=e[o])}else n[r+o]=void 0}),Ae(e).forEach(o=>{Ze(t,o)||(n[r+o]=e[o])}),n}const Xf={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=ie.trans,{deleting:a,creating:l,updating:c}=i.table(e).hook;switch(s.type){case"add":if(l.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"put":if(l.fire===be&&c.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"delete":if(a.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"deleteRange":if(a.fire===be)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function u(p){const h=ie.trans,g=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!g)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:g}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(f,y,m){return y.type==="add"?Promise.resolve([]):f.getMany({trans:y.trans,keys:m,cache:"immutable"})}(n,p,g).then(f=>{const y=g.map((m,w)=>{const _=f[w],k={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(k,m,_,h);else if(p.type==="add"||_===void 0){const x=l.fire.call(k,m,p.values[w],h);m==null&&x!=null&&(m=x,p.keys[w]=m,r.outbound||nt(p.values[w],r.keyPath,m))}else{const x=$s(_,p.values[w]),O=c.fire.call(k,x,m,_,h);if(O){const E=p.values[w];Object.keys(O).forEach(N=>{Ze(E,N)?E[N]=O[N]:nt(E,N,O[N])})}}return k});return n.mutate(p).then(({failures:m,results:w,numFailures:_,lastResult:k})=>{for(let x=0;x(y.forEach(w=>w.onerror&&w.onerror(m)),Promise.reject(m)))})}function d(p,h,g){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:g}).then(({result:f})=>u({type:"delete",keys:f,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=ol(r.keys,r.trans._cache,r.cache==="clone");return o?oe.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Hn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const dt=function(t,e){if(!this){const n=new dt;return t&&"d"in t&&Ue(n,t),n}Ue(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Wn(t,e,n){const r=Le(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(qs(t))return Ue(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(Le(n,t.from)<0)return o?Wn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ea(t);if(Le(e,t.to)>0)return s?Wn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ea(t);Le(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),Le(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const i=!t.r;o&&!t.l&&Nr(t,o),s&&i&&Nr(t,s)}function Nr(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Wn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function eh(t,e){const n=es(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=es(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(Le(a.from,o.to)<=0&&Le(a.to,o.from)>=0)return!0;Le(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function es(t){let e=qs(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&Le(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||Le(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ea(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",i={...t},a=t[o];t.from=a.from,t.to=a.to,t[o]=a[o],i[o]=a[s],t[s]=i,i.d=Ca(i)}t.d=Ca(t)}function Ca({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}un(dt.prototype,{add(t){return Nr(this,t),this},addKey(t){return Wn(this,t,t),this},addKeys(t){return t.forEach(e=>Wn(this,e,e)),this},[No](){return es(this)}});const th={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new dt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,c={...o,mutate:p=>{const h=p.trans,g=h.mutatedParts||(h.mutatedParts={}),f=O=>{const E=`idb://${e}/${r}/${O}`;return g[E]||(g[E]=new dt)},y=f(""),m=f(":dels"),{type:w}=p;let[_,k]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const x=p.trans._cache;return o.mutate(p).then(O=>{if(Me(_)){w!=="delete"&&(_=O.results),y.addKeys(_);const E=ol(_,x);E||w==="add"||m.addKeys(_),(E||k)&&function(N,P,R,$){function j(B){const b=N(B.name||"");function K(S){return S!=null?B.extractKey(S):null}const te=S=>B.multiEntry&&Me(S)?S.forEach(G=>b.addKey(G)):b.addKey(S);(R||$).forEach((S,G)=>{const z=R&&K(R[G]),Q=$&&K($[G]);Le(z,Q)!==0&&(z!=null&&te(z),Q!=null&&te(Q))})}P.indexes.forEach(j)}(f,s,E,k)}else if(_){const E={from:_.lower,to:_.upper};m.add(E),y.add(E)}else y.add(n),m.add(n),s.indexes.forEach(E=>f(E.name).add(n));return O})}},u=({query:{index:p,range:h}})=>{var g,f;return[p,new dt((g=h.lower)!==null&&g!==void 0?g:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new dt(p.key)],getMany:p=>[i,new dt().addKeys(p.keys)],count:u,query:u,openCursor:u};return Ae(d).forEach(p=>{c[p]=function(h){const{subscr:g}=ie;if(g){const f=k=>{const x=`idb://${e}/${r}/${k}`;return g[x]||(g[x]=new dt)},y=f(""),m=f(":dels"),[w,_]=d[p](h);if(f(w.name||"").add(_),!w.isPrimaryKey){if(p!=="count"){const k=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(x=>{if(p==="query"){if(l&&h.values)return k.then(({result:E})=>(y.addKeys(E),x));const O=h.values?x.result.map(a):x.result;h.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=x,E=h.values;return O&&Object.create(O,{key:{get:()=>(m.addKey(O.primaryKey),O.key)},primaryKey:{get(){const N=O.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(O.primaryKey),O.value)}})}return x})}m.add(n)}}return o[p].apply(this,arguments)}}),c}}}};class Ut{constructor(e,n){this._middlewares={},this.verno=0;const r=Ut.dependencies;this._options=n={addons:Ut.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:be,dbReadyPromise:null,cancelOpen:be,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new oe(a=>{s.dbReadyResolve=a}),s.openCanceller=new oe((a,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=Dn(this,"populate","blocked","versionchange","close",{ready:[Ms,be]}),this.on.ready.subscribe=Pi(this.on.ready.subscribe,a=>(l,c)=>{Ut.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||oe.resolve().then(l),c&&a(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&a(l);else{a(l);const d=this;c||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,wn(Mf.prototype,function(a,l){this.db=i;let c=Yi,u=null;if(l)try{c=l()}catch(g){u=g}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:h!==Tn?h:null}})),this.Table=function(a){return wn(Bf.prototype,function(l,c,u){this.db=a,this._tx=u,this.name=l,this.schema=c,this.hook=a._allTables[l]?a._allTables[l].hook:Dn(null,{creating:[Cf,be],reading:[Ef,Tn],updating:[Of,be],deleting:[Sf,be]})})}(this),this.Transaction=function(a){return wn(Uf.prototype,function(l,c,u,d,p){this.db=a,this.mode=l,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Dn(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new oe((h,g)=>{this._resolve=h,this._reject=g}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var g=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):g&&this.idbtrans&&this.idbtrans.abort(),Ne(h)})})}(this),this.Version=function(a){return wn(Hf.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return wn(Qi.prototype,function(l,c,u){this.db=a,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=a._deps.indexedDB;if(!d)throw new ce.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),In.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Yf),this.use(Xf),this.use(th),this.use(Qf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ce.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ce.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(o=>o._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(qf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ie.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new ce.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ce.DatabaseClosed);this.open().catch(be)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:o}){o&&this.unuse({stack:e,name:o});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:o}),s.sort((i,a)=>i.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(o=>r?o.create!==r:!!n&&o.name!==n)),this}open(){return Gf(this)}_close(){const e=this._state,n=In.indexOf(this);if(n>=0&&In.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new oe(r=>{e.dbReadyResolve=r}),e.openCanceller=new oe((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ce.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},c){!Ks(a)&&c!==to&&Us(a,l).delete(c).catch(be)})(this._deps,this.name),r()}),i.onerror=st(o),i.onblocked=this._fireOnBlocked};if(e)throw new ce.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ae(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Jf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ie.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let i,a;e=e.replace("!","").replace("?","");try{if(a=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===fo)i=fo;else{if(e!="rw"&&e!=ho)throw new ce.InvalidArgument("Invalid transaction mode: "+e);i=ho}if(o){if(o.mode===fo&&i===ho){if(!s)throw new ce.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!s)throw new ce.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Ne(c)}const l=rl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ie.trans?pn(ie.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ze(this._allTables,e))throw new ce.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const nh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class rh{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[nh](){return this}}function sl(t,e){return Ae(e).forEach(n=>{Nr(t[n]||(t[n]=new dt),e[n])}),t}function oh(t){let e,n=!1;const r=new rh(o=>{const s=Rs(t);let i=!1,a={},l={};const c={get closed(){return i},unsubscribe:()=>{i=!0,It.storagemutated.unsubscribe(h)}};o.start&&o.start(c);let u=!1,d=!1;function p(){return Ae(l).some(f=>a[f]&&eh(a[f],l[f]))}const h=f=>{sl(a,f),p()&&g()},g=()=>{if(u||i)return;a={};const f={},y=function(m){s&&hn();const w=()=>St(t,{subscr:m,trans:null}),_=ie.trans?pn(ie.transless,w):w();return s&&_.then(vt,vt),_}(f);d||(It(zn,h),d=!0),u=!0,Promise.resolve(y).then(m=>{n=!0,e=m,u=!1,i||(p()?g():(a={},l=f,o.next&&o.next(m)))},m=>{u=!1,n=!1,o.error&&o.error(m),c.unsubscribe()})};return g(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let ts;try{ts={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{ts={indexedDB:null,IDBKeyRange:null}}const Ft=Ut;function gr(t){let e=ht;try{ht=!0,It.storagemutated.fire(t)}finally{ht=e}}un(Ft,{...fr,delete:t=>new Ft(t,{addons:[]}).delete(),exists:t=>new Ft(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Ks(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==to)):Us(e,n).toCollection().primaryKeys()}(Ft.dependencies).then(t)}catch{return Ne(new ce.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ie.trans?pn(ie.transless,t):t(),vip:Xo,async:function(t){return function(){try{var e=Qo(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Ne(n)}}},spawn:function(t,e,n){try{var r=Qo(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Ne(o)}},currentTransaction:{get:()=>ie.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Ft.ignoreTransaction(t):t).timeout(e||6e4);return ie.trans?ie.trans.waitFor(n):n},Promise:oe,debug:{get:()=>lt,set:t=>{Ti(t,t==="dexie"?()=>!0:Ji)}},derive:nn,extend:Ue,props:un,override:Pi,Events:Dn,on:It,liveQuery:oh,extendObservabilitySet:sl,getByKeyPath:mt,setByKeyPath:nt,delByKeyPath:function(t,e){typeof e=="string"?nt(t,e,void 0):"length"in e&&[].map.call(e,function(n){nt(t,n,void 0)})},shallowClone:Ni,deepClone:Hn,getObjectDiff:$s,cmp:Le,asap:ji,minKey:$o,addons:[],connections:In,errnames:Bs,dependencies:ts,semVer:ga,version:ga.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Ft.maxKey=Ln(Ft.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(It(zn,t=>{if(!ht){let e;eo?(e=document.createEvent("CustomEvent"),e.initCustomEvent(_t,!0,!0,t)):e=new CustomEvent(_t,{detail:t}),ht=!0,dispatchEvent(e),ht=!1}}),addEventListener(_t,({detail:t})=>{ht||gr(t)}));let ht=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(_t);typeof t.unref=="function"&&t.unref(),It(zn,e=>{ht||t.postMessage(e)}),t.onmessage=e=>{e.data&&gr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){It(zn,e=>{try{ht||(typeof localStorage<"u"&&localStorage.setItem(_t,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:_t,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===_t){const n=JSON.parse(e.newValue);n&&gr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===_t&&gr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof rn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!pa[t.name])return t;var n=new pa[t.name](e||t.message,t);return"stack"in t&&pt(n,"stack",{get:function(){return this.inner.stack}}),n},Ti(lt,Ji);var sh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t))(sh||{}),wr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(wr||{});const ah="comfyui_workspace_db";class ih extends Ut{constructor(){super(ah);Ie(this,"workflows");Ie(this,"changelogs");Ie(this,"media");Ie(this,"folders");Ie(this,"tags");Ie(this,"userSettings");Ie(this,"models");Ie(this,"cache");Ie(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ue=new ih,lh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=lh[n[t]&63];return e};class Zt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ue[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")}),af(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=ns()),e.createTime||(e.createTime=Date.now()),await ue[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ue[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ue[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ue[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ue[this.tableName].toArray()}async batchQuery(e){return await ue[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await sf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await hf()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ue[this.tableName].get(e)}async delete(e){await ue[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await ue[this.tableName].where(e).equals(n).toArray()}}const ch=150,Tr=class Tr extends Zt{constructor(){super("changelogs")}static async load(){return new Tr}async listByWorkflowID(e){return await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:Fn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return this.deleteLogsExceedLimit(e.workflowID),await ue.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e){const n=await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=await(Z==null?void 0:Z.getSetting("maximumChangelogNumber"))??ch;if(n.length>r){const o=n.slice(r);await ue.changelogs.bulkDelete(o.map(s=>s.id)),await this.saveDiskDB()}}};Ie(Tr,"TABLE_NAME","changelogs");let rs=Tr;const zp="CWM_WORKFLOWS_SORT_TYPE";var kt=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(kt||{});const Lp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],uh="comfyspace_tracking",Fr="workspace_info",dh=9999999,go="upgrade_to_2way_sync",al=29;function br(...t){const e=t.filter(n=>n!=="").join("/");return Dt(e)}function Dt(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function wo(t){return br(t.parentFolderID??"",t.name+".json")}var xt;(t=>{async function e({parentFolderID:a,name:l}){return Dt(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(a.id)})})}t.createFolder=n;async function r(a,l){const u=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();u.error&&alert("Failed to move folder: "+u.error)}t.moveFolder=r;async function o(a){try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).text()}catch(l){console.error("Error deleting file:",l)}}t.deleteFolder=o;async function s(a){try{const c=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return c.error&&console.error("Error counting files:",c.error),c.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const u=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();u.error&&alert("Failed to rename folder: "+u.error)}catch(c){console.error("Error renaming file:",c)}}t.renameFolder=i})(xt||(xt={}));async function kn(t){const e=await Vs(t);if(e==null)return;const n=await il(t);await(q==null?void 0:q.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Fr]={id:t.id,name:t.name},delete o.extra[uh],await lf(e,JSON.stringify(o))}async function bo(t){if(t.name==null)return;const e=await Vs(t);e!=null&&Ii(e)}async function Vs(t){let e=hh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function fh(t){let e="",n=t;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function il(t){const e=await Vs(t);let n=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function Wp(t){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await xt.genFilesCountInFolder(t)??0;const n=await(q==null?void 0:q.listAll())??[],r=await(ze==null?void 0:ze.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}function hh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function ll(t,e=!0,n=!1){const r=new Date(t),o=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0"),i=r.getFullYear(),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=String(r.getSeconds()).padStart(2,"0"),u=`${s}-${o}-${i}`;return e?u+` ${a}:${l}`:n?u+`:${c}`:u}async function cl(t=!1){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return;const n=await(q==null?void 0:q.listAll())??[];for(const r of n){const o=await il(r);r.filePath!=o&&(r.filePath!=null&&await Ii(r.filePath,t),await kn(r))}}const ul=(t,e=kt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case kt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case kt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case kt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case kt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n};function ph(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{const e=await(Z==null?void 0:Z.getSetting("shortcuts"))??(Z==null?void 0:Z.defaultSettings.shortcuts);if(!e)return!1;for(const n in e){const o=e[n].split("+"),s={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const i in s)s[i]||delete s[i];if(o.length===Object.keys(s).length&&o.every(i=>s[i]))return n}};function $p(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function mh(t){return`/workspace/view_media?filename=${t}`}function Sa(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function dl(t){const e=window.location.hash.slice(1).split("/"),n=e.findIndex(o=>o.includes("workspaceId@")),r=`workspaceId@${t}`;return n>=0?e[n]=r:e.push(r),`${e.join("/")}`}const yh=t=>{const e=dl(t);window.open(`${window.location.origin}/#${e}`)},_r={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Je;(t=>{async function e(l,c){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),newParentPath:c})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(u){console.error("Error deleting file:",u)}}t.moveWorkflow=e;async function n(l,c){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(c??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(u){console.error("Error deleting file:",u)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:c},u){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(l??"",c+".json"),newName:u})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const c=l.json,u=JSON.parse(c);u.extra[Fr]={id:l.id};const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),json:JSON.stringify(u)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} 👉Please try "Save as" from "Files" dropdown menu - `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(l),deleteEmptyFolder:!1})})).text()}catch(c){alert("Error deleting workflow .json file: "+c),console.error("Error deleting file:",c)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:c,json:u,id:d}){var g;let p=JSON.parse(u);p={...p,extra:{[Fr]:{id:d}}};const h={parentFolderPath:Dt(l??""),name:c,json:JSON.stringify(p)};console.log("createWorkflow",h);try{const y=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return y.name&&await((g=ue.workflows)==null?void 0:g.update(d,{name:y.name})),y}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:c,id:u}){const d=br(l??"",c+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:u})})).json();return h.error&&(console.error(`Error getting file <${u}> at "${d}"`,h.error),alert({message:`Error getting file <${u}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${u}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function fl(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function vh(t,e){const n=Dt(t??""),o=(await fl(n)).map(async a=>{var u;const l=a.name,c=[n,l].join("/");return gh(a)?{id:Dt(c),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((u=ue.workflows)==null?void 0:u.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,lastSavedJson:a.json??"{}",json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ue.workflows.bulkPut(s.filter(a=>!Oh(a)));const i=s.filter(a=>a!=null);return ul(i,e??kt.RECENTLY_MODIFIED)}function gh(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Zt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Br}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ue.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){const l=await Je.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,c=!0;for(;c;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ns(),json:n.json??JSON.stringify(_r),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ue.workflows.add(i),this.saveDiskDB(),await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):(kn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ue.workflows.update(n,r);const o=await ue.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Je.moveWorkflow(s,r.parentFolderID):(await kn(i),await bo(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ue.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(Z==null?void 0:Z.getSetting("twoWaySync"))&&o&&await Je.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(Z==null?void 0:Z.getSetting("twoWaySync"))?a&&await Je.saveWorkflow(a):a&&await kn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const c=l.name&&r?l.name:await this.generateUniqueName(l.name,o),u=ns(),d=Date.now(),p={id:u,name:c,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Z==null?void 0:Z.getSetting("twoWaySync")))try{const g=JSON.parse(l.json),f=(a=(i=g==null?void 0:g.extra)==null?void 0:i[Fr])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(g){console.error("batchCreateFlows error",g)}else await kn(p)}try{await ue.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(r):bo({...r})),await ue.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ue.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(o):bo({...o})}await ue.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await vh(n??null);const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],i=await(ze==null?void 0:ze.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],a=[...s,...i];return ul(a,r??kt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await ue.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}};Ie(Br,"TABLE_NAME","workflows");let os=Br;const Mr=class Mr extends Zt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Z==null?void 0:Z.getSetting("twoWaySync")),o=await xt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Fn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await xt.createFolder(s):(await ue.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return"parentFolderID"in n&&await xt.moveFolder(e,n.parentFolderID??""),"name"in n&&await xt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ue.folders.update(e,n),this.saveDiskDB(),(s||i)&&cl(!0),a}async deleteFolder(e,n=wr.DELETE){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){await fl(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await xt.deleteFolder(e);return}const o=await(q==null?void 0:q.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const c of o)if(c.parentFolderID===a)switch(n){case wr.DELETE:await(q==null?void 0:q.deleteFlow(c.id));break;case wr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(c.id,{parentFolderID:void 0}));break}await ue.folders.delete(a);const l=s.filter(c=>c.parentFolderID===a).map(c=>c.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await Je.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Mr,"TABLE_NAME","folders");let ss=Mr;function wh(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=g}a+=12+c}e(l)},r.readAsArrayBuffer(t)})}function bh(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const c=t.slice(i,i+l);if(l===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,a);if(l===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let c=0;c{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-u)&~(1<<7*u),p=i.decode(o.slice(a+2+u,a+2+u+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,c=i.decode(o.slice(a+12,a+12+l)),u=JSON.parse(c);e(u);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Eh(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(kh(t))return xh(o);if(e==="webp")return _h(o);const s=await wh(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}function qp(){return LiteGraph.registered_node_types}class hl extends Zt{constructor(){super("media")}async listByWorkflowID(e){return await ue.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Eh(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:Fn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ue.media.add(o),this.saveDiskDB(),o}}Ie(hl,"TABLE_NAME","media");const Vp=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Ch={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Hp(t){return t.modelVersions!==void 0}function Sh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Zp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Sh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const zr=class zr extends Zt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S"},defaultFolders:Ch,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:200}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new zr,r=await cf();return n.defaultSettings.myWorkflowsDir=r.path,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};Ie(zr,"TABLE_NAME","userSettings");let as=zr;const Lr=class Lr extends Zt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let is=Lr;const Wr=class Wr extends Zt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ue[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Wr,"TABLE_NAME","workflowVersions");let ls=Wr;function Oh(t){return"type"in t&&t.type==="folder"}let q=null,kr=null,Z=null,ze=null,Ve=null,Kt=null,we=null;async function Ih(){const t=async()=>{q=await os.load()},e=async()=>{kr=await is.load()},n=async()=>{Z=await as.load()},r=async()=>{ze=await ss.load()},o=async()=>{Ve=await rs.load()},s=async()=>{Kt=new hl},i=async()=>{we=await ls.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Dh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Dh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ue.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(ze==null?void 0:ze.getRecords());a&&await ue.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Kt==null?void 0:Kt.getRecords());a&&await ue.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ue.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(kr==null?void 0:kr.getRecords());a&&await ue.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Z,l=await a.getRecords().then(c=>c[a.DEFAULT_USER]?c[a.DEFAULT_USER]:c);await ue.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(we==null?void 0:we.getRecords());a&&await ue.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const At=A.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),Gp=A.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),_o={x:0,y:0};function Ph({children:t,onDragEnd:e,dragIconId:n}){const r=A.useRef(_o),o=A.useRef(!1),[s,i]=A.useState(_o),a=d=>{var p,h,g;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(g=(h=d.target)==null?void 0:h.parentNode)==null?void 0:g.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=A.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),c=A.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),_o)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return D.jsx("div",{style:u,onMouseDown:a,children:t})}var jh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ah=Object.defineProperty,Nh=Object.defineProperties,Fh=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,pl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,Oa=(t,e,n)=>e in t?Ah(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ia=(t,e)=>{for(var n in e||(e={}))pl.call(e,n)&&Oa(t,n,e[n]);if(Rr)for(var n of Rr(e))ml.call(e,n)&&Oa(t,n,e[n]);return t},Rh=(t,e)=>Nh(t,Fh(e)),Th=(t,e)=>{var n={};for(var r in t)pl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Rr)for(var r of Rr(t))e.indexOf(r)<0&&ml.call(t,r)&&(n[r]=t[r]);return n},Fe=(t,e,n)=>{const r=A.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:c=2,children:u}=i,d=Th(i,["color","size","stroke","children"]);return A.createElement("svg",Ia(Rh(Ia({ref:s},jh),{width:l,height:l,stroke:a,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>A.createElement(p,h)),...u||[]])});return r.propTypes={color:Nt.string,size:Nt.oneOfType([Nt.string,Nt.number]),stroke:Nt.oneOfType([Nt.string,Nt.number])},r.displayName=`${e}`,r},Bh=Fe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Mh=Fe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),cs=Fe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),zh=Fe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),Lh=Fe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Wh=Fe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Uh=Fe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Kh=Fe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),$h=Fe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),yl=Fe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),qh=Fe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),Vh=Fe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Hh=Fe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),Zh=Fe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),vl=Fe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Gh=Fe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),Jh=Fe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),Yh=Fe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Xh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return D.jsx(mi,{isLazy:!0,placement:"auto",children:({onClose:i})=>D.jsxs(D.Fragment,{children:[D.jsx(pi,{children:D.jsx(Ct,{children:D.jsx(zt,{hasArrow:!0,label:s,placement:"bottom",children:D.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:D.jsx(Zh,{color:"#F56565"}),isDisabled:o,variant:n})})})}),D.jsxs(bi,{children:[D.jsx(yi,{}),D.jsx(gi,{onClick:i}),D.jsxs(vi,{children:[D.jsx(Bt,{mb:4,pr:4,fontWeight:600,children:e}),D.jsx(We,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Qh({onClose:t}){Ta();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=A.useContext(At),[s,i]=A.useState(0),[a,l]=A.useState(null),[c,u]=A.useState([]),[d,p]=A.useState([]),h=async y=>{var x;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));u(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),k=(x=_==null?void 0:_[0])==null?void 0:x.id;k&&l(k)},g=async()=>{const y=await(we==null?void 0:we.listByWorkflowID(e))??[];p(y)},f=y=>{we==null||we.delete(y).then(()=>{g()})};return A.useEffect(()=>{switch(s){case 0:g();break;case 1:h(e);break}},[s]),A.useEffect(()=>(xe.canvasEl.addEventListener("click",t),()=>{xe.canvasEl.removeEventListener("click",t)}),[s]),D.jsxs(nc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[D.jsx(tc,{pb:1,mb:0,children:D.jsxs(xn,{justifyContent:"space-between",alignItems:"center",children:[D.jsx(_s,{size:"md",children:"Version History"}),D.jsx(jn,{size:"sm",icon:D.jsx(Yh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),D.jsx(ec,{overflowY:"auto",gap:0,children:D.jsxs(xi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[D.jsxs(Ei,{mb:"1em",children:[D.jsx(Do,{children:"Versions"}),D.jsx(Do,{children:"Change History"})]}),D.jsxs(Ci,{children:[D.jsx(Io,{children:D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:d==null?void 0:d.map(y=>D.jsxs(xn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[D.jsxs(tn,{textAlign:"left",gap:0,children:[D.jsx(Bt,{fontWeight:"500",children:y.name??"untitled"}),D.jsxs(Bt,{color:"GrayText",fontSize:"sm",children:["Created: ",ll(y.createTime)]})]}),D.jsxs(xn,{alignItems:"center",gap:2,children:[D.jsx(We,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),D.jsx(Xh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),D.jsxs(Io,{children:[D.jsx(Bt,{mb:4,children:"All the saved changes of this workflow"}),D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:c==null?void 0:c.map(y=>D.jsxs(Et,{justifyContent:"space-between",children:[D.jsxs(We,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),q==null||q.updateFlow(e,{json:y.json}),t()},isActive:y.id===a,children:["Saved at ",new Date(y.createTime).toLocaleString()]},y.id),y.isAutoSave?D.jsx(Qr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function ep({workflowId:t,onClose:e}){const[n,r]=A.useState(""),[o,s]=A.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(we==null?void 0:we.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(xe.graph.serialize());await(we==null?void 0:we.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return D.jsxs(fs,{isOpen:!0,onClose:e,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Create Version"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!o,children:[D.jsx(Hr,{children:"Name"}),D.jsx(Kn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&D.jsx(Vr,{children:o})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),D.jsx(We,{onClick:e,children:"Cancel"})]})]})]})}function tp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=A.useRef(null);return Oc({ref:o,handler:()=>r()}),D.jsxs(Ct,{position:"relative",children:[D.jsx(Ct,{children:e}),n&&D.jsx(Ct,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function np({menuButton:t,menuContent:e,onClose:n}){const r=A.useRef(),[o,s]=A.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return D.jsx(tp,{isOpen:o,onClose:i,menuButton:D.jsx(Ct,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:D.jsx(As,{isOpen:!0,children:D.jsx(Ns,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const rp=A.lazy(()=>Un(()=>import("./ShareDialog-o8m3m3T9.js"),__vite__mapDeps([0,1,2,3,4])));function op(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=A.useContext(At),[i,a]=A.useState(!1),[l,c]=A.useState(""),[u,d]=A.useState(""),[p,h]=A.useState(),[g,f]=A.useState({save:"",saveAs:""}),[y,m]=A.useState(!1);A.useEffect(()=>{t&&(q==null||q.get(t).then(O=>{c((O==null?void 0:O.name)??""),h(O)})),Z==null||Z.getSetting("shortcuts").then(O=>{f(O)})},[t]);const w=O=>{c(O.target.value),u&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const O=JSON.stringify(xe.graph.serialize()),E=await(q==null?void 0:q.createFlow({json:O,lastSavedJson:O,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));E&&await e(E.id,null,!0),k()},k=()=>{o("root")},x=A.useCallback(async()=>{const O=q==null?void 0:q.curWorkflow;if(!O){alert("No current workflow!");return}const E=xe.graph.serialize(),N=JSON.stringify(E),P=new Blob([N],{type:"application/json"}),R=URL.createObjectURL(P),$=document.createElement("a");$.href=R,$.download=`${O.name}.json`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(R)},[t]);return A.useCallback(async()=>{console.log("app.graph",xe.graph);const O=xe.graph.serialize();console.log("graph serialize",O)},[]),D.jsxs(D.Fragment,{children:[D.jsx(np,{menuButton:D.jsx(Na,{children:D.jsxs(We,{px:1,height:al+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",D.jsx(Mh,{size:20})]})}),menuContent:D.jsx(As,{isOpen:!0,children:D.jsxs(Ns,{minWidth:150,zIndex:1e3,children:[D.jsx(gt,{onClick:r,icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.save,children:"Save"}),!(Z!=null&&Z.autoSave)&&D.jsx(zt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:D.jsx(gt,{onClick:n,icon:D.jsx(Bh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),D.jsx(gt,{onClick:x,icon:D.jsx(zh,{size:20}),iconSpacing:1,children:"Download"}),D.jsx(gt,{onClick:()=>o("saveAsModal"),icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.saveAs,children:"Save As"}),D.jsx(gt,{onClick:()=>a(!0),icon:D.jsx(Gh,{size:20}),iconSpacing:1,children:"Create Version"}),D.jsx(gt,{onClick:()=>o("versionHistory"),icon:D.jsx(Kh,{size:20}),iconSpacing:1,children:"Versions History"}),D.jsx(gt,{onClick:()=>m(!0),icon:D.jsx(Hh,{size:20}),iconSpacing:1,alignItems:"center",children:D.jsxs(Et,{children:[D.jsx("p",{children:"Share"})," ",D.jsx(Qr,{size:"sm",children:"🧪🧪beta"})]})})]})})}),y&&D.jsx(rp,{onClose:()=>m(!1)}),s=="versionHistory"&&D.jsx(Qh,{onClose:()=>o("root")}),s==="saveAsModal"&&D.jsxs(fs,{isOpen:!0,onClose:k,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Save As"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!u,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:l,onChange:w,autoFocus:!0,onKeyUp:O=>{O.code==="Enter"&&!u&&l&&_()}}),u&&D.jsx(Vr,{children:u})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!u,children:"Save"}),D.jsx(We,{onClick:k,children:"Cancel"})]})]})]}),i&&D.jsx(ep,{workflowId:t,onClose:()=>a(!1)})]})}function sp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Pc(),{curFlowID:i}=A.useContext(At),[a,l]=A.useState(t),[c,u]=A.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),c&&u("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return g();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?u("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),g())}},g=()=>{u(""),s()};return i==null?null:D.jsxs(Et,{children:[D.jsx(zt,{label:t,placement:"bottom",children:D.jsxs(Bt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[D.jsx("div",{style:{width:8,display:"inline-block"},children:D.jsx(Bt,{as:"span",children:n&&"* "})}),t]})}),D.jsxs(fs,{isOpen:r,onClose:g,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Edit workflow name"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!c,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!c&&a&&h()}}),c&&D.jsx(Vr,{children:c})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!c,children:"Save"}),D.jsx(We,{onClick:g,children:"Cancel"})]})]})]})]})}function Jp(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Yp=[{label:"Private",value:"PRIVATE",icon:D.jsx(yl,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:D.jsx($h,{})},{label:"Public",value:"PUBLIC",icon:D.jsx(Jh,{})}],Xp=()=>{const t=xe.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function ap(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Qp({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),D.jsx("span",{children:n})}function ip({}){const[t,e]=A.useState(),[n,r]=A.useState(),{curFlowID:o}=A.useContext(At);return A.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),ap(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?D.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:D.jsx(Na,{children:D.jsx(Qr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function lp({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=A.useContext(At);return A.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?D.jsx(xn,{alignItems:"center",children:D.jsx(La,{size:"sm",isAttached:!0,variant:"outline",children:D.jsx(We,{rightIcon:D.jsx(vl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const cp=A.lazy(()=>Un(()=>import("./ModelManagerTopbar--uE4bw7I.js").then(t=>t.M),__vite__mapDeps([5,1,6,2,7,8])));function up({curFlowName:t,setCurFlowName:e}){var u;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i}=A.useContext(At),[a,l]=A.useState(),c=A.useCallback((d,p=!1)=>{const{top:h=0,left:g=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=g;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),k=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+k>=m&&(y=m-k),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Z==null||Z.upsert({topBarStyle:{top:f,left:y}}))},[a]);return A.useEffect(()=>{Z==null||Z.getSetting("topBarStyle").then(d=>{c(d,!1)})},[]),a?D.jsx(Ph,{onDragEnd:d=>{c({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:D.jsxs(Et,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[D.jsx(We,{size:"sm","aria-label":"workspace folder",onClick:()=>s("recentFlows"),px:2,children:D.jsxs(Et,{gap:1,children:[D.jsx(Wh,{size:21}),D.jsx(vl,{size:8})]})}),D.jsx(cp,{}),D.jsx(zt,{label:"New workflow",children:D.jsx(We,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:al+"px",onClick:()=>r(),px:2,py:2,children:D.jsx(Et,{gap:0,children:D.jsx(Vh,{size:16,color:"white"})})})}),D.jsx(sp,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{c()})}}),((u=q==null?void 0:q.curWorkflow)==null?void 0:u.saveLock)&&D.jsx(yl,{color:"#FFF",size:20}),i&&D.jsxs(Et,{gap:"4px",children:[D.jsx(zt,{label:"Open gallery",children:D.jsx(jn,{onClick:()=>s("gallery"),icon:D.jsx(qh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),D.jsx(op,{})]}),i&&n?D.jsx(zt,{label:"Save workflow",children:D.jsx(jn,{onClick:o,icon:D.jsx(cs,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):D.jsx("div",{style:{width:1}}),D.jsx(ip,{}),D.jsx(lp,{}),D.jsx(Uh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})}):null}function dp(){const{showDialog:t}=Fa(),{loadWorkflowID:e}=A.useContext(At),n=async(o,s)=>{var c,u;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(c=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:c.at(0);if(l){const d=(u=await(we==null?void 0:we.listByIndex("cloudID",a.id)))==null?void 0:u.at(0);if(d)await e(l.id,d.id);else{const p=await(we==null?void 0:we.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await(q==null?void 0:q.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(we==null?void 0:we.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return A.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function fp(t){return t.type==="workspace_open_workflow"}const hp=t=>typeof t=="function",pp=t=>{const[e,n]=A.useState(t),r=A.useRef(e),o=A.useCallback(s=>{r.current=hp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function cr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var gl={exports:{}};/*! + `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(l),deleteEmptyFolder:!1})})).text()}catch(c){alert("Error deleting workflow .json file: "+c),console.error("Error deleting file:",c)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:c,json:u,id:d}){var g;let p=JSON.parse(u);p={...p,extra:{[Fr]:{id:d}}};const h={parentFolderPath:Dt(l??""),name:c,json:JSON.stringify(p)};console.log("createWorkflow",h);try{const y=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return y.name&&await((g=ue.workflows)==null?void 0:g.update(d,{name:y.name})),y}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:c,id:u}){const d=br(l??"",c+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:u})})).json();return h.error&&(console.error(`Error getting file <${u}> at "${d}"`,h.error),alert({message:`Error getting file <${u}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${u}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function fl(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function vh(t,e){const n=Dt(t??""),o=(await fl(n)).map(async a=>{var u;const l=a.name,c=[n,l].join("/");return gh(a)?{id:Dt(c),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((u=ue.workflows)==null?void 0:u.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,lastSavedJson:a.json??"{}",json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ue.workflows.bulkPut(s.filter(a=>!Oh(a)));const i=s.filter(a=>a!=null);return ul(i,e??kt.RECENTLY_MODIFIED)}function gh(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Zt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Br}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ue.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){const l=await Je.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,c=!0;for(;c;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ns(),json:n.json??JSON.stringify(_r),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ue.workflows.add(i),this.saveDiskDB(),await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):(kn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ue.workflows.update(n,r);const o=await ue.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Je.moveWorkflow(s,r.parentFolderID):(await kn(i),await bo(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ue.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(Z==null?void 0:Z.getSetting("twoWaySync"))&&o&&await Je.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(Z==null?void 0:Z.getSetting("twoWaySync"))?a&&await Je.saveWorkflow(a):a&&await kn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const c=l.name&&r?l.name:await this.generateUniqueName(l.name,o),u=ns(),d=Date.now(),p={id:u,name:c,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Z==null?void 0:Z.getSetting("twoWaySync")))try{const g=JSON.parse(l.json),f=(a=(i=g==null?void 0:g.extra)==null?void 0:i[Fr])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(g){console.error("batchCreateFlows error",g)}else await kn(p)}try{await ue.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(r):bo({...r})),await ue.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ue.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(o):bo({...o})}await ue.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await vh(n??null);const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],i=await(ze==null?void 0:ze.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],a=[...s,...i];return ul(a,r??kt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await ue.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}};Ie(Br,"TABLE_NAME","workflows");let os=Br;const Mr=class Mr extends Zt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Z==null?void 0:Z.getSetting("twoWaySync")),o=await xt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Fn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await xt.createFolder(s):(await ue.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return"parentFolderID"in n&&await xt.moveFolder(e,n.parentFolderID??""),"name"in n&&await xt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ue.folders.update(e,n),this.saveDiskDB(),(s||i)&&cl(!0),a}async deleteFolder(e,n=wr.DELETE){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){await fl(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await xt.deleteFolder(e);return}const o=await(q==null?void 0:q.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const c of o)if(c.parentFolderID===a)switch(n){case wr.DELETE:await(q==null?void 0:q.deleteFlow(c.id));break;case wr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(c.id,{parentFolderID:void 0}));break}await ue.folders.delete(a);const l=s.filter(c=>c.parentFolderID===a).map(c=>c.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await Je.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Mr,"TABLE_NAME","folders");let ss=Mr;function wh(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=g}a+=12+c}e(l)},r.readAsArrayBuffer(t)})}function bh(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const c=t.slice(i,i+l);if(l===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,a);if(l===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let c=0;c{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-u)&~(1<<7*u),p=i.decode(o.slice(a+2+u,a+2+u+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,c=i.decode(o.slice(a+12,a+12+l)),u=JSON.parse(c);e(u);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Eh(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(kh(t))return xh(o);if(e==="webp")return _h(o);const s=await wh(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}function qp(){return LiteGraph.registered_node_types}class hl extends Zt{constructor(){super("media")}async listByWorkflowID(e){return await ue.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Eh(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:Fn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ue.media.add(o),this.saveDiskDB(),o}}Ie(hl,"TABLE_NAME","media");const Vp=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Ch={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Hp(t){return t.modelVersions!==void 0}function Sh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Zp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Sh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const zr=class zr extends Zt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S"},defaultFolders:Ch,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:200}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new zr,r=await cf();return n.defaultSettings.myWorkflowsDir=r.path,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};Ie(zr,"TABLE_NAME","userSettings");let as=zr;const Lr=class Lr extends Zt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let is=Lr;const Wr=class Wr extends Zt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ue[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Wr,"TABLE_NAME","workflowVersions");let ls=Wr;function Oh(t){return"type"in t&&t.type==="folder"}let q=null,kr=null,Z=null,ze=null,Ve=null,Kt=null,we=null;async function Ih(){const t=async()=>{q=await os.load()},e=async()=>{kr=await is.load()},n=async()=>{Z=await as.load()},r=async()=>{ze=await ss.load()},o=async()=>{Ve=await rs.load()},s=async()=>{Kt=new hl},i=async()=>{we=await ls.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Dh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Dh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ue.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(ze==null?void 0:ze.getRecords());a&&await ue.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Kt==null?void 0:Kt.getRecords());a&&await ue.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ue.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(kr==null?void 0:kr.getRecords());a&&await ue.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Z,l=await a.getRecords().then(c=>c[a.DEFAULT_USER]?c[a.DEFAULT_USER]:c);await ue.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(we==null?void 0:we.getRecords());a&&await ue.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const At=A.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),Gp=A.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),_o={x:0,y:0};function Ph({children:t,onDragEnd:e,dragIconId:n}){const r=A.useRef(_o),o=A.useRef(!1),[s,i]=A.useState(_o),a=d=>{var p,h,g;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(g=(h=d.target)==null?void 0:h.parentNode)==null?void 0:g.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=A.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),c=A.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),_o)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return D.jsx("div",{style:u,onMouseDown:a,children:t})}var jh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ah=Object.defineProperty,Nh=Object.defineProperties,Fh=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,pl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,Oa=(t,e,n)=>e in t?Ah(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ia=(t,e)=>{for(var n in e||(e={}))pl.call(e,n)&&Oa(t,n,e[n]);if(Rr)for(var n of Rr(e))ml.call(e,n)&&Oa(t,n,e[n]);return t},Rh=(t,e)=>Nh(t,Fh(e)),Th=(t,e)=>{var n={};for(var r in t)pl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Rr)for(var r of Rr(t))e.indexOf(r)<0&&ml.call(t,r)&&(n[r]=t[r]);return n},Fe=(t,e,n)=>{const r=A.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:c=2,children:u}=i,d=Th(i,["color","size","stroke","children"]);return A.createElement("svg",Ia(Rh(Ia({ref:s},jh),{width:l,height:l,stroke:a,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>A.createElement(p,h)),...u||[]])});return r.propTypes={color:Nt.string,size:Nt.oneOfType([Nt.string,Nt.number]),stroke:Nt.oneOfType([Nt.string,Nt.number])},r.displayName=`${e}`,r},Bh=Fe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Mh=Fe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),cs=Fe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),zh=Fe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),Lh=Fe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Wh=Fe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Uh=Fe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Kh=Fe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),$h=Fe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),yl=Fe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),qh=Fe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),Vh=Fe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Hh=Fe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),Zh=Fe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),vl=Fe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Gh=Fe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),Jh=Fe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),Yh=Fe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Xh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return D.jsx(mi,{isLazy:!0,placement:"auto",children:({onClose:i})=>D.jsxs(D.Fragment,{children:[D.jsx(pi,{children:D.jsx(Ct,{children:D.jsx(zt,{hasArrow:!0,label:s,placement:"bottom",children:D.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:D.jsx(Zh,{color:"#F56565"}),isDisabled:o,variant:n})})})}),D.jsxs(bi,{children:[D.jsx(yi,{}),D.jsx(gi,{onClick:i}),D.jsxs(vi,{children:[D.jsx(Bt,{mb:4,pr:4,fontWeight:600,children:e}),D.jsx(We,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Qh({onClose:t}){Ta();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=A.useContext(At),[s,i]=A.useState(0),[a,l]=A.useState(null),[c,u]=A.useState([]),[d,p]=A.useState([]),h=async y=>{var x;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));u(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),k=(x=_==null?void 0:_[0])==null?void 0:x.id;k&&l(k)},g=async()=>{const y=await(we==null?void 0:we.listByWorkflowID(e))??[];p(y)},f=y=>{we==null||we.delete(y).then(()=>{g()})};return A.useEffect(()=>{switch(s){case 0:g();break;case 1:h(e);break}},[s]),A.useEffect(()=>(xe.canvasEl.addEventListener("click",t),()=>{xe.canvasEl.removeEventListener("click",t)}),[s]),D.jsxs(nc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[D.jsx(tc,{pb:1,mb:0,children:D.jsxs(xn,{justifyContent:"space-between",alignItems:"center",children:[D.jsx(_s,{size:"md",children:"Version History"}),D.jsx(jn,{size:"sm",icon:D.jsx(Yh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),D.jsx(ec,{overflowY:"auto",gap:0,children:D.jsxs(xi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[D.jsxs(Ei,{mb:"1em",children:[D.jsx(Do,{children:"Versions"}),D.jsx(Do,{children:"Change History"})]}),D.jsxs(Ci,{children:[D.jsx(Io,{children:D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:d==null?void 0:d.map(y=>D.jsxs(xn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[D.jsxs(tn,{textAlign:"left",gap:0,children:[D.jsx(Bt,{fontWeight:"500",children:y.name??"untitled"}),D.jsxs(Bt,{color:"GrayText",fontSize:"sm",children:["Created: ",ll(y.createTime)]})]}),D.jsxs(xn,{alignItems:"center",gap:2,children:[D.jsx(We,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),D.jsx(Xh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),D.jsxs(Io,{children:[D.jsx(Bt,{mb:4,children:"All the saved changes of this workflow"}),D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:c==null?void 0:c.map(y=>D.jsxs(Et,{justifyContent:"space-between",children:[D.jsxs(We,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),q==null||q.updateFlow(e,{json:y.json}),t()},isActive:y.id===a,children:["Saved at ",new Date(y.createTime).toLocaleString()]},y.id),y.isAutoSave?D.jsx(Qr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function ep({workflowId:t,onClose:e}){const[n,r]=A.useState(""),[o,s]=A.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(we==null?void 0:we.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(xe.graph.serialize());await(we==null?void 0:we.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return D.jsxs(fs,{isOpen:!0,onClose:e,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Create Version"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!o,children:[D.jsx(Hr,{children:"Name"}),D.jsx(Kn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&D.jsx(Vr,{children:o})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),D.jsx(We,{onClick:e,children:"Cancel"})]})]})]})}function tp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=A.useRef(null);return Oc({ref:o,handler:()=>r()}),D.jsxs(Ct,{position:"relative",children:[D.jsx(Ct,{children:e}),n&&D.jsx(Ct,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function np({menuButton:t,menuContent:e,onClose:n}){const r=A.useRef(),[o,s]=A.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return D.jsx(tp,{isOpen:o,onClose:i,menuButton:D.jsx(Ct,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:D.jsx(As,{isOpen:!0,children:D.jsx(Ns,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const rp=A.lazy(()=>Un(()=>import("./ShareDialog-MoNpT1nG.js"),__vite__mapDeps([0,1,2,3,4])));function op(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=A.useContext(At),[i,a]=A.useState(!1),[l,c]=A.useState(""),[u,d]=A.useState(""),[p,h]=A.useState(),[g,f]=A.useState({save:"",saveAs:""}),[y,m]=A.useState(!1);A.useEffect(()=>{t&&(q==null||q.get(t).then(O=>{c((O==null?void 0:O.name)??""),h(O)})),Z==null||Z.getSetting("shortcuts").then(O=>{f(O)})},[t]);const w=O=>{c(O.target.value),u&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const O=JSON.stringify(xe.graph.serialize()),E=await(q==null?void 0:q.createFlow({json:O,lastSavedJson:O,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));E&&await e(E.id,null,!0),k()},k=()=>{o("root")},x=A.useCallback(async()=>{const O=q==null?void 0:q.curWorkflow;if(!O){alert("No current workflow!");return}const E=xe.graph.serialize(),N=JSON.stringify(E),P=new Blob([N],{type:"application/json"}),R=URL.createObjectURL(P),$=document.createElement("a");$.href=R,$.download=`${O.name}.json`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(R)},[t]);return A.useCallback(async()=>{console.log("app.graph",xe.graph);const O=xe.graph.serialize();console.log("graph serialize",O)},[]),D.jsxs(D.Fragment,{children:[D.jsx(np,{menuButton:D.jsx(Na,{children:D.jsxs(We,{px:1,height:al+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",D.jsx(Mh,{size:20})]})}),menuContent:D.jsx(As,{isOpen:!0,children:D.jsxs(Ns,{minWidth:150,zIndex:1e3,children:[D.jsx(gt,{onClick:r,icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.save,children:"Save"}),!(Z!=null&&Z.autoSave)&&D.jsx(zt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:D.jsx(gt,{onClick:n,icon:D.jsx(Bh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),D.jsx(gt,{onClick:x,icon:D.jsx(zh,{size:20}),iconSpacing:1,children:"Download"}),D.jsx(gt,{onClick:()=>o("saveAsModal"),icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.saveAs,children:"Save As"}),D.jsx(gt,{onClick:()=>a(!0),icon:D.jsx(Gh,{size:20}),iconSpacing:1,children:"Create Version"}),D.jsx(gt,{onClick:()=>o("versionHistory"),icon:D.jsx(Kh,{size:20}),iconSpacing:1,children:"Versions History"}),D.jsx(gt,{onClick:()=>m(!0),icon:D.jsx(Hh,{size:20}),iconSpacing:1,alignItems:"center",children:D.jsxs(Et,{children:[D.jsx("p",{children:"Share"})," ",D.jsx(Qr,{size:"sm",children:"🧪🧪beta"})]})})]})})}),y&&D.jsx(rp,{onClose:()=>m(!1)}),s=="versionHistory"&&D.jsx(Qh,{onClose:()=>o("root")}),s==="saveAsModal"&&D.jsxs(fs,{isOpen:!0,onClose:k,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Save As"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!u,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:l,onChange:w,autoFocus:!0,onKeyUp:O=>{O.code==="Enter"&&!u&&l&&_()}}),u&&D.jsx(Vr,{children:u})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!u,children:"Save"}),D.jsx(We,{onClick:k,children:"Cancel"})]})]})]}),i&&D.jsx(ep,{workflowId:t,onClose:()=>a(!1)})]})}function sp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Pc(),{curFlowID:i}=A.useContext(At),[a,l]=A.useState(t),[c,u]=A.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),c&&u("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return g();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?u("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),g())}},g=()=>{u(""),s()};return i==null?null:D.jsxs(Et,{children:[D.jsx(zt,{label:t,placement:"bottom",children:D.jsxs(Bt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[D.jsx("div",{style:{width:8,display:"inline-block"},children:D.jsx(Bt,{as:"span",children:n&&"* "})}),t]})}),D.jsxs(fs,{isOpen:r,onClose:g,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Edit workflow name"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!c,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!c&&a&&h()}}),c&&D.jsx(Vr,{children:c})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!c,children:"Save"}),D.jsx(We,{onClick:g,children:"Cancel"})]})]})]})]})}function Jp(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Yp=[{label:"Private",value:"PRIVATE",icon:D.jsx(yl,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:D.jsx($h,{})},{label:"Public",value:"PUBLIC",icon:D.jsx(Jh,{})}],Xp=()=>{const t=xe.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function ap(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Qp({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),D.jsx("span",{children:n})}function ip({}){const[t,e]=A.useState(),[n,r]=A.useState(),{curFlowID:o}=A.useContext(At);return A.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),ap(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?D.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:D.jsx(Na,{children:D.jsx(Qr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function lp({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=A.useContext(At);return A.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?D.jsx(xn,{alignItems:"center",children:D.jsx(La,{size:"sm",isAttached:!0,variant:"outline",children:D.jsx(We,{rightIcon:D.jsx(vl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const cp=A.lazy(()=>Un(()=>import("./ModelManagerTopbar-4fKW20g4.js").then(t=>t.M),__vite__mapDeps([5,1,6,2,7,8])));function up({curFlowName:t,setCurFlowName:e}){var u;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i}=A.useContext(At),[a,l]=A.useState(),c=A.useCallback((d,p=!1)=>{const{top:h=0,left:g=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=g;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),k=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+k>=m&&(y=m-k),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Z==null||Z.upsert({topBarStyle:{top:f,left:y}}))},[a]);return A.useEffect(()=>{Z==null||Z.getSetting("topBarStyle").then(d=>{c(d,!1)})},[]),a?D.jsx(Ph,{onDragEnd:d=>{c({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:D.jsxs(Et,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[D.jsx(We,{size:"sm","aria-label":"workspace folder",onClick:()=>s("recentFlows"),px:2,children:D.jsxs(Et,{gap:1,children:[D.jsx(Wh,{size:21}),D.jsx(vl,{size:8})]})}),D.jsx(cp,{}),D.jsx(zt,{label:"New workflow",children:D.jsx(We,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:al+"px",onClick:()=>r(),px:2,py:2,children:D.jsx(Et,{gap:0,children:D.jsx(Vh,{size:16,color:"white"})})})}),D.jsx(sp,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{c()})}}),((u=q==null?void 0:q.curWorkflow)==null?void 0:u.saveLock)&&D.jsx(yl,{color:"#FFF",size:20}),i&&D.jsxs(Et,{gap:"4px",children:[D.jsx(zt,{label:"Open gallery",children:D.jsx(jn,{onClick:()=>s("gallery"),icon:D.jsx(qh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),D.jsx(op,{})]}),i&&n?D.jsx(zt,{label:"Save workflow",children:D.jsx(jn,{onClick:o,icon:D.jsx(cs,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):D.jsx("div",{style:{width:1}}),D.jsx(ip,{}),D.jsx(lp,{}),D.jsx(Uh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})}):null}function dp(){const{showDialog:t}=Fa(),{loadWorkflowID:e}=A.useContext(At),n=async(o,s)=>{var c,u;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(c=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:c.at(0);if(l){const d=(u=await(we==null?void 0:we.listByIndex("cloudID",a.id)))==null?void 0:u.at(0);if(d)await e(l.id,d.id);else{const p=await(we==null?void 0:we.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await(q==null?void 0:q.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(we==null?void 0:we.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return A.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function fp(t){return t.type==="workspace_open_workflow"}const hp=t=>typeof t=="function",pp=t=>{const[e,n]=A.useState(t),r=A.useRef(e),o=A.useCallback(s=>{r.current=hp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function cr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var gl={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -18,10 +18,10 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,e){(function(n){t.exports=n()})(function(){return function n(r,o,s){function i(c,u){if(!o[c]){if(!r[c]){var d=typeof cr=="function"&&cr;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[c]={exports:{}};r[c][0].call(h.exports,function(g){var f=r[c][1][g];return i(f||g)},h,h.exports,n,r,o,s)}return o[c].exports}for(var a=typeof cr=="function"&&cr,l=0;l>2,h=(3&c)<<4|u>>4,g=1<_?(15&u)<<2|d>>6:64,f=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(h)+a.charAt(g)+a.charAt(f));return y.join("")},o.decode=function(l){var c,u,d,p,h,g,f=0,y=0,m="data:";if(l.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var w,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,u=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(g=a.indexOf(l.charAt(f++))),w[y++]=c,h!==64&&(w[y++]=u),g!==64&&(w[y++]=d);return w}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,p,h,g){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=g}c.prototype={getContentWorker:function(){var u=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,p){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u[f])];return-1^c}(0|l,a,a.length,0):function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u.charCodeAt(f))];return-1^c}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function u(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new u("Deflate",d)},o.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,g){var f,y="";for(f=0;f>>=8;return y}function i(h,g,f,y,m,w){var _,k,x=h.file,O=h.compression,E=w!==c.utf8encode,N=a.transformTo("string",w(x.name)),P=a.transformTo("string",c.utf8encode(x.name)),R=x.comment,$=a.transformTo("string",w(R)),j=a.transformTo("string",c.utf8encode(R)),B=P.length!==x.name.length,b=j.length!==R.length,K="",te="",S="",G=x.dir,z=x.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};g&&!f||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var M=0;g&&(M|=8),E||!B&&!b||(M|=2048);var T=0,ne=0;G&&(T|=16),m==="UNIX"?(ne=798,T|=function(H,fe){var ye=H;return H||(ye=fe?16893:33204),(65535&ye)<<16}(x.unixPermissions,G)):(ne=20,T|=function(H){return 63&(H||0)}(x.dosPermissions)),_=z.getUTCHours(),_<<=6,_|=z.getUTCMinutes(),_<<=5,_|=z.getUTCSeconds()/2,k=z.getUTCFullYear()-1980,k<<=4,k|=z.getUTCMonth()+1,k<<=5,k|=z.getUTCDate(),B&&(te=s(1,1)+s(u(N),4)+P,K+="up"+s(te.length,2)+te),b&&(S=s(1,1)+s(u($),4)+j,K+="uc"+s(S.length,2)+S);var Y="";return Y+=` -\0`,Y+=s(M,2),Y+=O.magic,Y+=s(_,2),Y+=s(k,2),Y+=s(Q.crc32,4),Y+=s(Q.compressedSize,4),Y+=s(Q.uncompressedSize,4),Y+=s(N.length,2),Y+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s($.length,2)+"\0\0\0\0"+s(T,4)+s(y,4)+N+K+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function p(h,g,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=y,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var g=h.meta.percent||0,f=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var g=this.streamFiles&&!h.file.dir;if(g){var f=i(h,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var g=this.streamFiles&&!h.file.dir,f=i(h,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new c(d):i.uint8array?new u(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,f){return new u.Promise(function(y,m){var w=[],_=g._internalType,k=g._outputType,x=g._mimeType;g.on("data",function(O,E){w.push(O),f&&f(E)}).on("error",function(O){w=[],m(O)}).on("end",function(){try{var O=function(E,N,P){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),P);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(k,function(E,N){var P,R=0,$=null,j=0;for(P=0;P"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(g){var f,y,m,w,_,k=g.length,x=0;for(w=0;w>>6:(y<65536?f[_++]=224|y>>>12:(f[_++]=240|y>>>18,f[_++]=128|y>>>12&63),f[_++]=128|y>>>6&63),f[_++]=128|63&y);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(g){var f,y,m,w,_=g.length,k=new Array(2*_);for(f=y=0;f<_;)if((m=g[f++])<128)k[y++]=m;else if(4<(w=c[m]))k[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,k[y++]=56320|1023&m)}return k.length!==y&&(k.subarray?k=k.subarray(0,y):k.length=y),s.applyFromCharCode(k)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var g=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var y=function(w,_){var k;for((_=_||w.length)>w.length&&(_=w.length),k=_-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?_:k+c[w[k]]>_?k:_}(g),m=g;y!==g.length&&(i.uint8array?(m=g.subarray(0,y),this.leftOver=g.subarray(y,g.length)):(m=g.slice(0,y),this.leftOver=g.slice(y,g.length))),this.push({data:o.utf8decode(m),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(f){return f}function u(f,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var g,f,y,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[y++]=224|h>>>12:(p[y++]=240|h>>>18,p[y++]=128|h>>>12&63),p[y++]=128|h>>>6&63),p[y++]=128|63&h);return p},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,g=p.length;h>10&1023,w[g++]=56320|1023&f)}return u(w,g)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var c=65535&s|0,u=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,c){var u=s,d=c+l;i^=-1;for(var p=c;p>>8^u[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,p=4,h=0,g=-2,f=-1,y=4,m=2,w=8,_=9,k=286,x=30,O=19,E=2*k+1,N=15,P=3,R=258,$=R+P+1,j=42,B=113,b=1,K=2,te=3,S=4;function G(v,U){return v.msg=u[U],U}function z(v){return(v<<1)-(4v.avail_out&&(W=v.avail_out),W!==0&&(i.arraySet(v.output,U.pending_buf,U.pending_out,W,v.next_out),v.next_out+=W,U.pending_out+=W,v.total_out+=W,v.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function T(v,U){a._tr_flush_block(v,0<=v.block_start?v.block_start:-1,v.strstart-v.block_start,U),v.block_start=v.strstart,M(v.strm)}function ne(v,U){v.pending_buf[v.pending++]=U}function Y(v,U){v.pending_buf[v.pending++]=U>>>8&255,v.pending_buf[v.pending++]=255&U}function H(v,U){var W,I,C=v.max_chain_length,F=v.strstart,V=v.prev_length,J=v.nice_match,L=v.strstart>v.w_size-$?v.strstart-(v.w_size-$):0,X=v.window,re=v.w_mask,ee=v.prev,ae=v.strstart+R,ge=X[F+V-1],pe=X[F+V];v.prev_length>=v.good_match&&(C>>=2),J>v.lookahead&&(J=v.lookahead);do if(X[(W=U)+V]===pe&&X[W+V-1]===ge&&X[W]===X[F]&&X[++W]===X[F+1]){F+=2,W++;do;while(X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&FL&&--C!=0);return V<=v.lookahead?V:v.lookahead}function fe(v){var U,W,I,C,F,V,J,L,X,re,ee=v.w_size;do{if(C=v.window_size-v.lookahead-v.strstart,v.strstart>=ee+(ee-$)){for(i.arraySet(v.window,v.window,ee,ee,0),v.match_start-=ee,v.strstart-=ee,v.block_start-=ee,U=W=v.hash_size;I=v.head[--U],v.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=v.prev[--U],v.prev[U]=ee<=I?I-ee:0,--W;);C+=ee}if(v.strm.avail_in===0)break;if(V=v.strm,J=v.window,L=v.strstart+v.lookahead,X=C,re=void 0,re=V.avail_in,X=P)for(F=v.strstart-v.insert,v.ins_h=v.window[F],v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P)if(I=a._tr_tally(v,v.strstart-v.match_start,v.match_length-P),v.lookahead-=v.match_length,v.match_length<=v.max_lazy_match&&v.lookahead>=P){for(v.match_length--;v.strstart++,v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P&&v.match_length<=v.prev_length){for(C=v.strstart+v.lookahead-P,I=a._tr_tally(v,v.strstart-1-v.prev_match,v.prev_length-P),v.lookahead-=v.prev_length-1,v.prev_length-=2;++v.strstart<=C&&(v.ins_h=(v.ins_h<v.pending_buf_size-5&&(W=v.pending_buf_size-5);;){if(v.lookahead<=1){if(fe(v),v.lookahead===0&&U===d)return b;if(v.lookahead===0)break}v.strstart+=v.lookahead,v.lookahead=0;var I=v.block_start+W;if((v.strstart===0||v.strstart>=I)&&(v.lookahead=v.strstart-I,v.strstart=I,T(v,!1),v.strm.avail_out===0)||v.strstart-v.block_start>=v.w_size-$&&(T(v,!1),v.strm.avail_out===0))return b}return v.insert=0,U===p?(T(v,!0),v.strm.avail_out===0?te:S):(v.strstart>v.block_start&&(T(v,!1),v.strm.avail_out),b)}),new le(4,4,8,4,ye),new le(4,5,16,8,ye),new le(4,6,32,32,ye),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],o.deflateInit=function(v,U){return Ee(v,U,w,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(v,U){return v&&v.state?v.state.wrap!==2?g:(v.state.gzhead=U,h):g},o.deflate=function(v,U){var W,I,C,F;if(!v||!v.state||5>8&255),ne(I,I.gzhead.time>>16&255),ne(I,I.gzhead.time>>24&255),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ne(I,255&I.gzhead.extra.length),ne(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(v.adler=c(v.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,3),I.status=B);else{var V=w+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=B,Y(I,V),I.strstart!==0&&(Y(I,v.adler>>>16),Y(I,65535&v.adler)),v.adler=1}if(I.status===69)if(I.gzhead.extra){for(C=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending!==I.pending_buf_size));)ne(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&M(v),I.pending+2<=I.pending_buf_size&&(ne(I,255&v.adler),ne(I,v.adler>>8&255),v.adler=0,I.status=B)):I.status=B),I.pending!==0){if(M(v),v.avail_out===0)return I.last_flush=-1,h}else if(v.avail_in===0&&z(U)<=z(W)&&U!==p)return G(v,-5);if(I.status===666&&v.avail_in!==0)return G(v,-5);if(v.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var J=I.strategy===2?function(L,X){for(var re;;){if(L.lookahead===0&&(fe(L),L.lookahead===0)){if(X===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(L,X){for(var re,ee,ae,ge,pe=L.window;;){if(L.lookahead<=R){if(fe(L),L.lookahead<=R&&X===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=P&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=P?(re=a._tr_tally(L,1,L.match_length-P),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(J!==te&&J!==S||(I.status=666),J===b||J===te)return v.avail_out===0&&(I.last_flush=-1),h;if(J===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(Q(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),M(v),v.avail_out===0))return I.last_flush=-1,h}return U!==p?h:I.wrap<=0?1:(I.wrap===2?(ne(I,255&v.adler),ne(I,v.adler>>8&255),ne(I,v.adler>>16&255),ne(I,v.adler>>24&255),ne(I,255&v.total_in),ne(I,v.total_in>>8&255),ne(I,v.total_in>>16&255),ne(I,v.total_in>>24&255)):(Y(I,v.adler>>>16),Y(I,65535&v.adler)),M(v),0=W.w_size&&(F===0&&(Q(W.head),W.strstart=0,W.block_start=0,W.insert=0),X=new i.Buf8(W.w_size),i.arraySet(X,U,re-W.w_size,W.w_size,0),U=X,re=W.w_size),V=v.avail_in,J=v.next_in,L=v.input,v.avail_in=re,v.next_in=0,v.input=U,fe(W);W.lookahead>=P;){for(I=W.strstart,C=W.lookahead-(P-1);W.ins_h=(W.ins_h<>>=P=N>>>24,_-=P,(P=N>>>16&255)===0)K[u++]=65535&N;else{if(!(16&P)){if(!(64&P)){N=k[(65535&N)+(w&(1<>>=P,_-=P),_<15&&(w+=b[l++]<<_,_+=8,w+=b[l++]<<_,_+=8),N=x[w&E];n:for(;;){if(w>>>=P=N>>>24,_-=P,!(16&(P=N>>>16&255))){if(!(64&P)){N=x[(65535&N)+(w&(1<>>=P,_-=P,(P=u-d)<$){if(f<(P=$-P)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(j=0)===y){if(j+=g-P,P>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var B;return j&&j.state?(B=j.state,j.total_in=j.total_out=B.total=0,j.msg="",B.wrap&&(j.adler=1&B.wrap),B.mode=g,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(f),B.distcode=B.distdyn=new s.Buf32(y),B.sane=1,B.back=-1,p):h}function k(j){var B;return j&&j.state?((B=j.state).wsize=0,B.whave=0,B.wnext=0,_(j)):h}function x(j,B){var b,K;return j&&j.state?(K=j.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=S.wsize?(s.arraySet(S.window,B,b-S.wsize,S.wsize,0),S.wnext=0,S.whave=S.wsize):(K<(te=S.wsize-S.wnext)&&(te=K),s.arraySet(S.window,B,b-K,te,S.wnext),(K-=te)?(s.arraySet(S.window,B,b-K,K,0),S.wnext=K,S.whave=S.wsize):(S.wnext+=te,S.wnext===S.wsize&&(S.wnext=0),S.whave>>8&255,b.check=a(b.check,F,2,0),T=M=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&M)<<8)+(M>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&M)!=8){j.msg="unknown compression method",b.mode=30;break}if(T-=4,v=8+(15&(M>>>=4)),b.wbits===0)b.wbits=v;else if(v>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=3;case 3:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>8&255,F[2]=M>>>16&255,F[3]=M>>>24&255,b.check=a(b.check,F,4,0)),T=M=0,b.mode=4;case 4:for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>8),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=5;case 5:if(1024&b.flags){for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>>8&255,b.check=a(b.check,F,2,0)),T=M=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(z<(H=b.length)&&(H=z),H&&(b.head&&(v=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,S,H,v)),512&b.flags&&(b.check=a(b.check,K,H,S)),z-=H,S+=H,b.length-=H),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(z===0)break e;for(H=0;v=K[S+H++],b.head&&v&&b.length<65536&&(b.head.name+=String.fromCharCode(v)),v&&H>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>=7&T,T-=7&T,b.mode=27;break}for(;T<3;){if(z===0)break e;z--,M+=K[S++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,B!==6)break;M>>>=2,T-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}M>>>=2,T-=2;break;case 14:for(M>>>=7&T,T-=7&T;T<32;){if(z===0)break e;z--,M+=K[S++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&M,T=M=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(H=b.length){if(z>>=5,T-=5,b.ndist=1+(31&M),M>>>=5,T-=5,b.ncode=4+(15&M),M>>>=4,T-=4,286>>=3,T-=3}for(;b.have<19;)b.lens[V[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=se,T-=se,b.lens[b.have++]=ke;else{if(ke===16){for(I=se+2;T>>=se,T-=se,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}v=b.lens[b.have-1],H=3+(3&M),M>>>=2,T-=2}else if(ke===17){for(I=se+3;T>>=se)),M>>>=3,T-=3}else{for(I=se+7;T>>=se)),M>>>=7,T-=7}if(b.have+H>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;H--;)b.lens[b.have++]=v}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=c(u,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=c(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,B===6)break e;case 20:b.mode=21;case 21:if(6<=z&&258<=Q){j.next_out=G,j.avail_out=Q,j.next_in=S,j.avail_in=z,b.hold=M,b.bits=T,l(j,Y),G=j.next_out,te=j.output,Q=j.avail_out,S=j.next_in,K=j.input,z=j.avail_in,M=b.hold,T=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;le=(C=b.lencode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,b.length=ke,le===0){b.mode=26;break}if(32&le){b.back=-1,b.mode=12;break}if(64&le){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&le,b.mode=22;case 22:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;le=(C=b.distcode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,64&le){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&le,b.mode=24;case 24:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(Q===0)break e;if(H=Y-Q,b.offset>H){if((H=b.offset-H)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}fe=H>b.wnext?(H-=b.wnext,b.wsize-H):b.wnext-H,H>b.length&&(H=b.length),ye=b.window}else ye=te,fe=G-b.offset,H=b.length;for(QE?(P=fe[ye+y[B]],T[ne+y[B]]):(P=96,0),w=1<>G)+(_-=w)]=N<<24|P<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(M&=w-1,M+=w):M=0,B++,--Y[j]==0){if(j===K)break;j=d[p+y[B]]}if(te>>7)]}function ne(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function Y(C,F,V){C.bi_valid>m-V?(C.bi_buf|=F<>m-C.bi_valid,C.bi_valid+=V-m):(C.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ye(C,F,V){var J,L,X=new Array(y+1),re=0;for(J=1;J<=y;J++)X[J]=re=re+V[J-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=fe(X[ee]++,ee))}}function se(C){var F;for(F=0;F>1;1<=V;V--)ve(C,X,V);for(L=ae;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ve(C,X,1),J=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=J,X[2*L]=X[2*V]+X[2*J],C.depth[L]=(C.depth[V]>=C.depth[J]?C.depth[V]:C.depth[J])+1,X[2*V+1]=X[2*J+1]=L,C.heap[1]=L++,ve(C,X,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(pe,Ge){var mn,rt,yn,Pe,Jn,no,ct=Ge.dyn_tree,Hs=Ge.max_code,wl=Ge.stat_desc.static_tree,bl=Ge.stat_desc.has_stree,_l=Ge.stat_desc.extra_bits,Zs=Ge.stat_desc.extra_base,vn=Ge.stat_desc.max_length,Yn=0;for(Pe=0;Pe<=y;Pe++)pe.bl_count[Pe]=0;for(ct[2*pe.heap[pe.heap_max]+1]=0,mn=pe.heap_max+1;mn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*ae]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(ae=32;ae>>3,(X=C.static_len+3+7>>>3)<=L&&(L=X)):L=X=V+5,V+4<=L&&F!==-1?I(C,F,V,J):C.strategy===4||X===L?(Y(C,2+(J?1:0),3),me(C,$,j)):(Y(C,4+(J?1:0),3),function(ee,ae,ge,pe){var Ge;for(Y(ee,ae-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Ge=0;Ge>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&F,C.pending_buf[C.l_buf+C.last_lit]=255&V,C.last_lit++,F===0?C.dyn_ltree[2*V]++:(C.matches++,F--,C.dyn_ltree[2*(b[V]+d+1)]++,C.dyn_dtree[2*T(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){Y(C,2,3),H(C,_,$),function(F){F.bi_valid===16?(ne(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)}(C)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},g=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:function(){if(i.postMessage&&!i.importScripts){var k=!0,x=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=x,k}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(k){i.postMessage(d+k,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){u.port2.postMessage(k)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(k){var x=f.createElement("script");x.onreadystatechange=function(){w(k),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(k){setTimeout(w,0,k)},y.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=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)})})(gl);var mp=gl.exports;const yp=Da(mp),vp=async t=>{const e=`ComfyUI workspace workflows ${ll(Date.now())}`,n=new yp,r=await(Z==null?void 0:Z.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await fh(o.parentFolderID??null).then(async a=>Dt(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 gp({myWorkflowsDir:t}){return D.jsxs(tn,{gap:3,children:[D.jsx(_s,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),D.jsx("p",{children:"Your workflows will be synced to and from path:"}),D.jsx("p",{children:D.jsx("b",{children:t})}),D.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"]}),D.jsxs("p",{children:[D.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."]}),D.jsx(We,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());vp(e??[])},children:"👉 Download All My Workflows"})]})}const wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},bp=ws.lazy(()=>Un(()=>import("./RecentFilesDrawer-4bh_pwSS.js"),__vite__mapDeps([9,1,6,2,10,11,4]))),_p=ws.lazy(()=>Un(()=>import("./GalleryModal-mtYV1YJE.js"),__vite__mapDeps([12,1,11,6,2,7,3]))),kp=ws.lazy(()=>Un(()=>import("./AppIsDirtyEventListener-4vtCCyCS.js"),__vite__mapDeps([13,1]))),xp=["download_progress","download_error","model_list"];function Ep(){const[t,e]=A.useState(null),[n,r]=A.useState("root"),[o,s]=A.useState(!0),[i,a]=A.useState(null),l=A.useRef(null),[c,u]=A.useState(!1),d=A.useRef(null),{showDialog:p}=Fa(),[h,g]=A.useState(!1);A.useRef(!1);const f=Ta(),[y,m]=pp(null),w=A.useCallback(async()=>{var S;if(l.current){if((S=q==null?void 0:q.curWorkflow)!=null&&S.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const G=JSON.stringify(xe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(l.current,{json:G}),Ve==null?void 0:Ve.create({workflowID:l.current,json:G,isAutoSave:!1})]),Z!=null&&Z.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(q==null?void 0:q.delete(l.current)),x(null))},k=async()=>{var G,z;if(Z!=null&&Z.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const Q=(G=q==null?void 0:q.curWorkflow)==null?void 0:G.id;if(Q==null)return;const M=(z=await(q==null?void 0:q.get(Q)))==null?void 0:z.json;M?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:M}),await xe.loadGraphData(JSON.parse(M)),u(!1)):alert("Error: No last saved version found")}},x=S=>{const G=(S==null?void 0:S.id)??null;if(q==null||q.updateCurWorkflow(S),l.current=G,a(G),e((S==null?void 0:S.name)??""),G==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Sa()){const z=dl(G);window.location.hash=z,document.title=S.name+" - ComfyUI"}else localStorage.setItem("curFlowID",G),document.title="ComfyUI - "+S.name},O=async()=>{E(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Ih()}catch(z){console.error("error loading db",z)}s(!1);let S=null;S=Sa(),S==null&&(S=localStorage.getItem("curFlowID")),S&&P(S),await cl(),!await(Z==null?void 0:Z.getSetting("twoWaySync"))&&ue.cache.get(go).then(async z=>{if((z==null?void 0:z.value)!=="true"){if(await ue.workflows.count()==0){await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await ue.cache.put({id:go,value:"true"});return}const M=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));p(D.jsx(gp,{myWorkflowsDir:M??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await(Z==null?void 0:Z.getSetting("twoWaySync"))&&(ue.cache.put({id:go,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},E=()=>{xp.forEach(S=>{Gs.addEventListener(S,()=>null)})},N=()=>{if(l.current==null)return!1;const S=q==null?void 0:q.curWorkflow;if(S==null)return!1;if(S.json==null)return!0;const G=xe.graph.serialize()??{};let z={};try{z=S!=null&&S.json?JSON.parse(S==null?void 0:S.json):{}}catch(M){console.error("error parsing json",M)}return!wp(G,z)},P=async(S,G)=>{if(xe.graph==null)return;const z=await(q==null?void 0:q.get(S));if(z==null){alert("Error: Workflow not found! id: "+S),x(null);return}const Q=G?await(we==null?void 0:we.get(G)):null;xe.ui.dialog.close(),Q?(m(Q),x({...z,json:Q.json}),xe.loadGraphData(JSON.parse(Q.json))):(x(z),m(null),xe.loadGraphData(JSON.parse(z.json))),r("root"),c&&u(!1)},R=async(S,G,z=!1)=>{if(S===null){x(null),xe.graph.clear();return}if(!c||z||await(Z==null?void 0:Z.getSetting("autoSave"))){P(S,G);return}$(S)},$=async S=>{var z,Q;const G=[S?{label:"Open in new tab",icon:D.jsx(Lh,{}),onClick:()=>{yh(S)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),S&&P(S)}}];((z=q==null?void 0:q.curWorkflow)==null?void 0:z.lastSavedJson)!=null?G.push({label:"Discard",colorScheme:"red",onClick:async()=>{S&&P(S)}}):G.push({label:"Delete",colorScheme:"red",onClick:async()=>{await _(),S&&P(S)}}),p(`Please save or discard your changes to "${(Q=q==null?void 0:q.curWorkflow)==null?void 0:Q.name}" before leaving, or your changes will be lost.`,G)},j=async S=>{const G=(S==null?void 0:S.json)??JSON.stringify(_r),z=await(q==null?void 0:q.createFlow({json:G,name:S==null?void 0:S.name}));z&&await R(z.id),r("root")},B=async(S,G=!1)=>{const z=S.split("/").pop()??S;G?w():j({name:z});const Q=await fetch(mh(S)),M=await Q.blob(),T=new File([M],z,{type:Q.headers.get("Content-Type")||""});await xe.handleFile(T),r("root")},b=async(S,G)=>{const z=await(q==null?void 0:q.get(S));if(z==null)return;const Q=await(q==null?void 0:q.createFlow({json:z.json,lastSavedJson:z.lastSavedJson,name:G||z.name,parentFolderID:z.parentFolderID,tags:z.tags}));Q&&await R(Q.id)},K=A.useCallback(S=>{if(l.current==null)return;let G=S.filename;S.subfolder!=null&&S.subfolder!==""&&(G=S.subfolder+"/"+G),Kt==null||Kt.create({workflowID:l.current,localPath:G})},[]),te=A.useCallback(()=>{r("root")},[]);return A.useEffect(()=>{O(),g(!0);const S=document.getElementById("comfy-file-input"),G=async()=>{if(S&&S.files&&S.files.length>0){const T={id:Fn(),name:S.files[0].name,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(T),await(q==null?void 0:q.createFlow(T))}};S==null||S.addEventListener("change",G);const z=T=>{var H;const ne=(Z==null?void 0:Z.autoSave)??!0;if((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)return;const Y=N();!ne&&Y&&(T.preventDefault(),T.returnValue="You have unsaved changes!",$())};window.addEventListener("beforeunload",z);const Q=T=>{var ne,Y,H,fe,ye,se;(H=(Y=(ne=T.detail)==null?void 0:ne.output)==null?void 0:Y.images)==null||H.forEach(le=>{le.type==="output"&&K(le)}),(se=(ye=(fe=T.detail)==null?void 0:fe.output)==null?void 0:ye.gifs)==null||se.forEach(le=>{le.type==="output"&&K(le)})};Gs.addEventListener("executed",Q);const M=async T=>{var fe,ye;const ne=(ye=(fe=T.dataTransfer)==null?void 0:fe.files[0])==null?void 0:ye.name,Y=xe.dragOverNode;if(Y&&Y.onDragDrop)return;if(!(await(Z==null?void 0:Z.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ne){const se={id:Fn(),name:ne,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(se),await(q==null?void 0:q.createFlow(se))}};return xe.canvasEl.addEventListener("drop",M),()=>{window.removeEventListener("change",G),window.removeEventListener("beforeunload",z),window.removeEventListener("executed",Q),xe.canvasEl.removeEventListener("drop",M)}},[]),o?null:D.jsx(At.Provider,{value:{curFlowID:i,onDuplicateWorkflow:b,loadWorkflowID:R,discardUnsavedChanges:k,saveCurWorkflow:w,isDirty:c,setIsDirty:u,loadNewWorkflow:j,loadFilePath:B,setRoute:r,route:n,curVersion:y,setCurVersion:m},children:D.jsx("div",{ref:d,className:"workspace_manager",children:D.jsxs(Aa,{containerRef:d,children:[D.jsxs(Ct,{style:{position:"absolute",top:0,right:0,left:0},zIndex:dh,draggable:!1,children:[D.jsx(up,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&D.jsx(A.Suspense,{children:D.jsx(bp,{onClose:te,onClickNewFlow:()=>{j(),r("root")}})}),n==="gallery"&&D.jsx(A.Suspense,{children:D.jsx(_p,{onclose:()=>r("root")})})]}),D.jsx(dp,{}),D.jsx(kp,{})]})})})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"}));export{uc as $,q as A,Ct as B,Yh as C,Xh as D,sh as E,xn as F,vp as G,Et as H,jn as I,Mh as J,Lp as K,Wh as L,hi as M,wh as N,ze as O,qr as P,Hr as Q,Gp as R,kd as S,Qr as T,Vr as U,Vh as V,_r as W,Wp as X,wr as Y,Oh as Z,zp as _,Dp as a,mi as a0,pi as a1,bi as a2,yi as a3,gi as a4,vi as a5,At as a6,yl as a7,Kt as a8,ll as a9,Pc as aA,pp as aB,Ch as aC,Vp as aD,Rp as aE,dn as aF,Yp as aG,we as aH,Jp as aI,Xp as aJ,ap as aK,Qp as aL,tc as aM,em as aN,yh as aa,Lh as ab,kt as ac,nc as ad,dh as ae,Fp as af,ul as ag,Up as ah,Ma as ai,za as aj,$p as ak,qp as al,Eh as am,_s as an,Ac as ao,en as ap,dc as aq,wp as ar,Kp as as,Ve as at,Kl as au,ue as av,Hp as aw,Zp as ax,Tp as ay,Bp as az,jc as b,Ap as c,Pp as d,jp as e,fn as f,Jr as g,Fe as h,Zh as i,Ta as j,tn as k,Bt as l,zt as m,Kn as n,Z as o,gp as p,cf as q,Np as r,Mp as s,kr as t,Gr as u,Eo as v,As as w,Ns as x,gt as y,zh as z}; +\0`,Y+=s(M,2),Y+=O.magic,Y+=s(_,2),Y+=s(k,2),Y+=s(Q.crc32,4),Y+=s(Q.compressedSize,4),Y+=s(Q.uncompressedSize,4),Y+=s(N.length,2),Y+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s($.length,2)+"\0\0\0\0"+s(T,4)+s(y,4)+N+K+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function p(h,g,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=y,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var g=h.meta.percent||0,f=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var g=this.streamFiles&&!h.file.dir;if(g){var f=i(h,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var g=this.streamFiles&&!h.file.dir,f=i(h,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new c(d):i.uint8array?new u(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,f){return new u.Promise(function(y,m){var w=[],_=g._internalType,k=g._outputType,x=g._mimeType;g.on("data",function(O,E){w.push(O),f&&f(E)}).on("error",function(O){w=[],m(O)}).on("end",function(){try{var O=function(E,N,P){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),P);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(k,function(E,N){var P,R=0,$=null,j=0;for(P=0;P"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(g){var f,y,m,w,_,k=g.length,x=0;for(w=0;w>>6:(y<65536?f[_++]=224|y>>>12:(f[_++]=240|y>>>18,f[_++]=128|y>>>12&63),f[_++]=128|y>>>6&63),f[_++]=128|63&y);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(g){var f,y,m,w,_=g.length,k=new Array(2*_);for(f=y=0;f<_;)if((m=g[f++])<128)k[y++]=m;else if(4<(w=c[m]))k[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,k[y++]=56320|1023&m)}return k.length!==y&&(k.subarray?k=k.subarray(0,y):k.length=y),s.applyFromCharCode(k)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var g=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var y=function(w,_){var k;for((_=_||w.length)>w.length&&(_=w.length),k=_-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?_:k+c[w[k]]>_?k:_}(g),m=g;y!==g.length&&(i.uint8array?(m=g.subarray(0,y),this.leftOver=g.subarray(y,g.length)):(m=g.slice(0,y),this.leftOver=g.slice(y,g.length))),this.push({data:o.utf8decode(m),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(f){return f}function u(f,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var g,f,y,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[y++]=224|h>>>12:(p[y++]=240|h>>>18,p[y++]=128|h>>>12&63),p[y++]=128|h>>>6&63),p[y++]=128|63&h);return p},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,g=p.length;h>10&1023,w[g++]=56320|1023&f)}return u(w,g)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var c=65535&s|0,u=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,c){var u=s,d=c+l;i^=-1;for(var p=c;p>>8^u[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,p=4,h=0,g=-2,f=-1,y=4,m=2,w=8,_=9,k=286,x=30,O=19,E=2*k+1,N=15,P=3,R=258,$=R+P+1,j=42,B=113,b=1,K=2,te=3,S=4;function G(v,U){return v.msg=u[U],U}function z(v){return(v<<1)-(4v.avail_out&&(W=v.avail_out),W!==0&&(i.arraySet(v.output,U.pending_buf,U.pending_out,W,v.next_out),v.next_out+=W,U.pending_out+=W,v.total_out+=W,v.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function T(v,U){a._tr_flush_block(v,0<=v.block_start?v.block_start:-1,v.strstart-v.block_start,U),v.block_start=v.strstart,M(v.strm)}function ne(v,U){v.pending_buf[v.pending++]=U}function Y(v,U){v.pending_buf[v.pending++]=U>>>8&255,v.pending_buf[v.pending++]=255&U}function H(v,U){var W,I,C=v.max_chain_length,F=v.strstart,V=v.prev_length,J=v.nice_match,L=v.strstart>v.w_size-$?v.strstart-(v.w_size-$):0,X=v.window,re=v.w_mask,ee=v.prev,ae=v.strstart+R,ge=X[F+V-1],pe=X[F+V];v.prev_length>=v.good_match&&(C>>=2),J>v.lookahead&&(J=v.lookahead);do if(X[(W=U)+V]===pe&&X[W+V-1]===ge&&X[W]===X[F]&&X[++W]===X[F+1]){F+=2,W++;do;while(X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&FL&&--C!=0);return V<=v.lookahead?V:v.lookahead}function fe(v){var U,W,I,C,F,V,J,L,X,re,ee=v.w_size;do{if(C=v.window_size-v.lookahead-v.strstart,v.strstart>=ee+(ee-$)){for(i.arraySet(v.window,v.window,ee,ee,0),v.match_start-=ee,v.strstart-=ee,v.block_start-=ee,U=W=v.hash_size;I=v.head[--U],v.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=v.prev[--U],v.prev[U]=ee<=I?I-ee:0,--W;);C+=ee}if(v.strm.avail_in===0)break;if(V=v.strm,J=v.window,L=v.strstart+v.lookahead,X=C,re=void 0,re=V.avail_in,X=P)for(F=v.strstart-v.insert,v.ins_h=v.window[F],v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P)if(I=a._tr_tally(v,v.strstart-v.match_start,v.match_length-P),v.lookahead-=v.match_length,v.match_length<=v.max_lazy_match&&v.lookahead>=P){for(v.match_length--;v.strstart++,v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P&&v.match_length<=v.prev_length){for(C=v.strstart+v.lookahead-P,I=a._tr_tally(v,v.strstart-1-v.prev_match,v.prev_length-P),v.lookahead-=v.prev_length-1,v.prev_length-=2;++v.strstart<=C&&(v.ins_h=(v.ins_h<v.pending_buf_size-5&&(W=v.pending_buf_size-5);;){if(v.lookahead<=1){if(fe(v),v.lookahead===0&&U===d)return b;if(v.lookahead===0)break}v.strstart+=v.lookahead,v.lookahead=0;var I=v.block_start+W;if((v.strstart===0||v.strstart>=I)&&(v.lookahead=v.strstart-I,v.strstart=I,T(v,!1),v.strm.avail_out===0)||v.strstart-v.block_start>=v.w_size-$&&(T(v,!1),v.strm.avail_out===0))return b}return v.insert=0,U===p?(T(v,!0),v.strm.avail_out===0?te:S):(v.strstart>v.block_start&&(T(v,!1),v.strm.avail_out),b)}),new le(4,4,8,4,ye),new le(4,5,16,8,ye),new le(4,6,32,32,ye),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],o.deflateInit=function(v,U){return Ee(v,U,w,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(v,U){return v&&v.state?v.state.wrap!==2?g:(v.state.gzhead=U,h):g},o.deflate=function(v,U){var W,I,C,F;if(!v||!v.state||5>8&255),ne(I,I.gzhead.time>>16&255),ne(I,I.gzhead.time>>24&255),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ne(I,255&I.gzhead.extra.length),ne(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(v.adler=c(v.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,3),I.status=B);else{var V=w+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=B,Y(I,V),I.strstart!==0&&(Y(I,v.adler>>>16),Y(I,65535&v.adler)),v.adler=1}if(I.status===69)if(I.gzhead.extra){for(C=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending!==I.pending_buf_size));)ne(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&M(v),I.pending+2<=I.pending_buf_size&&(ne(I,255&v.adler),ne(I,v.adler>>8&255),v.adler=0,I.status=B)):I.status=B),I.pending!==0){if(M(v),v.avail_out===0)return I.last_flush=-1,h}else if(v.avail_in===0&&z(U)<=z(W)&&U!==p)return G(v,-5);if(I.status===666&&v.avail_in!==0)return G(v,-5);if(v.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var J=I.strategy===2?function(L,X){for(var re;;){if(L.lookahead===0&&(fe(L),L.lookahead===0)){if(X===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(L,X){for(var re,ee,ae,ge,pe=L.window;;){if(L.lookahead<=R){if(fe(L),L.lookahead<=R&&X===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=P&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=P?(re=a._tr_tally(L,1,L.match_length-P),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(J!==te&&J!==S||(I.status=666),J===b||J===te)return v.avail_out===0&&(I.last_flush=-1),h;if(J===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(Q(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),M(v),v.avail_out===0))return I.last_flush=-1,h}return U!==p?h:I.wrap<=0?1:(I.wrap===2?(ne(I,255&v.adler),ne(I,v.adler>>8&255),ne(I,v.adler>>16&255),ne(I,v.adler>>24&255),ne(I,255&v.total_in),ne(I,v.total_in>>8&255),ne(I,v.total_in>>16&255),ne(I,v.total_in>>24&255)):(Y(I,v.adler>>>16),Y(I,65535&v.adler)),M(v),0=W.w_size&&(F===0&&(Q(W.head),W.strstart=0,W.block_start=0,W.insert=0),X=new i.Buf8(W.w_size),i.arraySet(X,U,re-W.w_size,W.w_size,0),U=X,re=W.w_size),V=v.avail_in,J=v.next_in,L=v.input,v.avail_in=re,v.next_in=0,v.input=U,fe(W);W.lookahead>=P;){for(I=W.strstart,C=W.lookahead-(P-1);W.ins_h=(W.ins_h<>>=P=N>>>24,_-=P,(P=N>>>16&255)===0)K[u++]=65535&N;else{if(!(16&P)){if(!(64&P)){N=k[(65535&N)+(w&(1<>>=P,_-=P),_<15&&(w+=b[l++]<<_,_+=8,w+=b[l++]<<_,_+=8),N=x[w&E];n:for(;;){if(w>>>=P=N>>>24,_-=P,!(16&(P=N>>>16&255))){if(!(64&P)){N=x[(65535&N)+(w&(1<>>=P,_-=P,(P=u-d)<$){if(f<(P=$-P)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(j=0)===y){if(j+=g-P,P>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var B;return j&&j.state?(B=j.state,j.total_in=j.total_out=B.total=0,j.msg="",B.wrap&&(j.adler=1&B.wrap),B.mode=g,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(f),B.distcode=B.distdyn=new s.Buf32(y),B.sane=1,B.back=-1,p):h}function k(j){var B;return j&&j.state?((B=j.state).wsize=0,B.whave=0,B.wnext=0,_(j)):h}function x(j,B){var b,K;return j&&j.state?(K=j.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=S.wsize?(s.arraySet(S.window,B,b-S.wsize,S.wsize,0),S.wnext=0,S.whave=S.wsize):(K<(te=S.wsize-S.wnext)&&(te=K),s.arraySet(S.window,B,b-K,te,S.wnext),(K-=te)?(s.arraySet(S.window,B,b-K,K,0),S.wnext=K,S.whave=S.wsize):(S.wnext+=te,S.wnext===S.wsize&&(S.wnext=0),S.whave>>8&255,b.check=a(b.check,F,2,0),T=M=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&M)<<8)+(M>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&M)!=8){j.msg="unknown compression method",b.mode=30;break}if(T-=4,v=8+(15&(M>>>=4)),b.wbits===0)b.wbits=v;else if(v>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=3;case 3:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>8&255,F[2]=M>>>16&255,F[3]=M>>>24&255,b.check=a(b.check,F,4,0)),T=M=0,b.mode=4;case 4:for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>8),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=5;case 5:if(1024&b.flags){for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>>8&255,b.check=a(b.check,F,2,0)),T=M=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(z<(H=b.length)&&(H=z),H&&(b.head&&(v=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,S,H,v)),512&b.flags&&(b.check=a(b.check,K,H,S)),z-=H,S+=H,b.length-=H),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(z===0)break e;for(H=0;v=K[S+H++],b.head&&v&&b.length<65536&&(b.head.name+=String.fromCharCode(v)),v&&H>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>=7&T,T-=7&T,b.mode=27;break}for(;T<3;){if(z===0)break e;z--,M+=K[S++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,B!==6)break;M>>>=2,T-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}M>>>=2,T-=2;break;case 14:for(M>>>=7&T,T-=7&T;T<32;){if(z===0)break e;z--,M+=K[S++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&M,T=M=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(H=b.length){if(z>>=5,T-=5,b.ndist=1+(31&M),M>>>=5,T-=5,b.ncode=4+(15&M),M>>>=4,T-=4,286>>=3,T-=3}for(;b.have<19;)b.lens[V[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=se,T-=se,b.lens[b.have++]=ke;else{if(ke===16){for(I=se+2;T>>=se,T-=se,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}v=b.lens[b.have-1],H=3+(3&M),M>>>=2,T-=2}else if(ke===17){for(I=se+3;T>>=se)),M>>>=3,T-=3}else{for(I=se+7;T>>=se)),M>>>=7,T-=7}if(b.have+H>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;H--;)b.lens[b.have++]=v}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=c(u,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=c(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,B===6)break e;case 20:b.mode=21;case 21:if(6<=z&&258<=Q){j.next_out=G,j.avail_out=Q,j.next_in=S,j.avail_in=z,b.hold=M,b.bits=T,l(j,Y),G=j.next_out,te=j.output,Q=j.avail_out,S=j.next_in,K=j.input,z=j.avail_in,M=b.hold,T=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;le=(C=b.lencode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,b.length=ke,le===0){b.mode=26;break}if(32&le){b.back=-1,b.mode=12;break}if(64&le){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&le,b.mode=22;case 22:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;le=(C=b.distcode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,64&le){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&le,b.mode=24;case 24:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(Q===0)break e;if(H=Y-Q,b.offset>H){if((H=b.offset-H)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}fe=H>b.wnext?(H-=b.wnext,b.wsize-H):b.wnext-H,H>b.length&&(H=b.length),ye=b.window}else ye=te,fe=G-b.offset,H=b.length;for(QE?(P=fe[ye+y[B]],T[ne+y[B]]):(P=96,0),w=1<>G)+(_-=w)]=N<<24|P<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(M&=w-1,M+=w):M=0,B++,--Y[j]==0){if(j===K)break;j=d[p+y[B]]}if(te>>7)]}function ne(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function Y(C,F,V){C.bi_valid>m-V?(C.bi_buf|=F<>m-C.bi_valid,C.bi_valid+=V-m):(C.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ye(C,F,V){var J,L,X=new Array(y+1),re=0;for(J=1;J<=y;J++)X[J]=re=re+V[J-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=fe(X[ee]++,ee))}}function se(C){var F;for(F=0;F>1;1<=V;V--)ve(C,X,V);for(L=ae;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ve(C,X,1),J=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=J,X[2*L]=X[2*V]+X[2*J],C.depth[L]=(C.depth[V]>=C.depth[J]?C.depth[V]:C.depth[J])+1,X[2*V+1]=X[2*J+1]=L,C.heap[1]=L++,ve(C,X,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(pe,Ge){var mn,rt,yn,Pe,Jn,no,ct=Ge.dyn_tree,Hs=Ge.max_code,wl=Ge.stat_desc.static_tree,bl=Ge.stat_desc.has_stree,_l=Ge.stat_desc.extra_bits,Zs=Ge.stat_desc.extra_base,vn=Ge.stat_desc.max_length,Yn=0;for(Pe=0;Pe<=y;Pe++)pe.bl_count[Pe]=0;for(ct[2*pe.heap[pe.heap_max]+1]=0,mn=pe.heap_max+1;mn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*ae]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(ae=32;ae>>3,(X=C.static_len+3+7>>>3)<=L&&(L=X)):L=X=V+5,V+4<=L&&F!==-1?I(C,F,V,J):C.strategy===4||X===L?(Y(C,2+(J?1:0),3),me(C,$,j)):(Y(C,4+(J?1:0),3),function(ee,ae,ge,pe){var Ge;for(Y(ee,ae-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Ge=0;Ge>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&F,C.pending_buf[C.l_buf+C.last_lit]=255&V,C.last_lit++,F===0?C.dyn_ltree[2*V]++:(C.matches++,F--,C.dyn_ltree[2*(b[V]+d+1)]++,C.dyn_dtree[2*T(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){Y(C,2,3),H(C,_,$),function(F){F.bi_valid===16?(ne(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)}(C)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},g=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:function(){if(i.postMessage&&!i.importScripts){var k=!0,x=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=x,k}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(k){i.postMessage(d+k,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){u.port2.postMessage(k)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(k){var x=f.createElement("script");x.onreadystatechange=function(){w(k),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(k){setTimeout(w,0,k)},y.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=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)})})(gl);var mp=gl.exports;const yp=Da(mp),vp=async t=>{const e=`ComfyUI workspace workflows ${ll(Date.now())}`,n=new yp,r=await(Z==null?void 0:Z.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await fh(o.parentFolderID??null).then(async a=>Dt(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 gp({myWorkflowsDir:t}){return D.jsxs(tn,{gap:3,children:[D.jsx(_s,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),D.jsx("p",{children:"Your workflows will be synced to and from path:"}),D.jsx("p",{children:D.jsx("b",{children:t})}),D.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"]}),D.jsxs("p",{children:[D.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."]}),D.jsx(We,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());vp(e??[])},children:"👉 Download All My Workflows"})]})}const wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},bp=ws.lazy(()=>Un(()=>import("./RecentFilesDrawer-UFHH0mIW.js"),__vite__mapDeps([9,1,6,2,10,11,4]))),_p=ws.lazy(()=>Un(()=>import("./GalleryModal-oZQWNmu9.js"),__vite__mapDeps([12,1,11,6,2,7,3]))),kp=ws.lazy(()=>Un(()=>import("./AppIsDirtyEventListener-Cjpx6yXx.js"),__vite__mapDeps([13,1]))),xp=["download_progress","download_error","model_list"];function Ep(){const[t,e]=A.useState(null),[n,r]=A.useState("root"),[o,s]=A.useState(!0),[i,a]=A.useState(null),l=A.useRef(null),[c,u]=A.useState(!1),d=A.useRef(null),{showDialog:p}=Fa(),[h,g]=A.useState(!1);A.useRef(!1);const f=Ta(),[y,m]=pp(null),w=A.useCallback(async()=>{var S;if(l.current){if((S=q==null?void 0:q.curWorkflow)!=null&&S.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const G=JSON.stringify(xe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(l.current,{json:G}),Ve==null?void 0:Ve.create({workflowID:l.current,json:G,isAutoSave:!1})]),Z!=null&&Z.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(q==null?void 0:q.delete(l.current)),x(null))},k=async()=>{var G,z;if(Z!=null&&Z.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const Q=(G=q==null?void 0:q.curWorkflow)==null?void 0:G.id;if(Q==null)return;const M=(z=await(q==null?void 0:q.get(Q)))==null?void 0:z.json;M?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:M}),await xe.loadGraphData(JSON.parse(M)),u(!1)):alert("Error: No last saved version found")}},x=S=>{const G=(S==null?void 0:S.id)??null;if(q==null||q.updateCurWorkflow(S),l.current=G,a(G),e((S==null?void 0:S.name)??""),G==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Sa()){const z=dl(G);window.location.hash=z,document.title=S.name+" - ComfyUI"}else localStorage.setItem("curFlowID",G),document.title="ComfyUI - "+S.name},O=async()=>{E(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Ih()}catch(z){console.error("error loading db",z)}s(!1);let S=null;S=Sa(),S==null&&(S=localStorage.getItem("curFlowID")),S&&P(S),await cl(),!await(Z==null?void 0:Z.getSetting("twoWaySync"))&&ue.cache.get(go).then(async z=>{if((z==null?void 0:z.value)!=="true"){if(await ue.workflows.count()==0){await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await ue.cache.put({id:go,value:"true"});return}const M=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));p(D.jsx(gp,{myWorkflowsDir:M??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await(Z==null?void 0:Z.getSetting("twoWaySync"))&&(ue.cache.put({id:go,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},E=()=>{xp.forEach(S=>{Gs.addEventListener(S,()=>null)})},N=()=>{if(l.current==null)return!1;const S=q==null?void 0:q.curWorkflow;if(S==null)return!1;if(S.json==null)return!0;const G=xe.graph.serialize()??{};let z={};try{z=S!=null&&S.json?JSON.parse(S==null?void 0:S.json):{}}catch(M){console.error("error parsing json",M)}return!wp(G,z)},P=async(S,G)=>{if(xe.graph==null)return;const z=await(q==null?void 0:q.get(S));if(z==null){alert("Error: Workflow not found! id: "+S),x(null);return}const Q=G?await(we==null?void 0:we.get(G)):null;xe.ui.dialog.close(),Q?(m(Q),x({...z,json:Q.json}),xe.loadGraphData(JSON.parse(Q.json))):(x(z),m(null),xe.loadGraphData(JSON.parse(z.json))),r("root"),c&&u(!1)},R=async(S,G,z=!1)=>{if(S===null){x(null),xe.graph.clear();return}if(!c||z||await(Z==null?void 0:Z.getSetting("autoSave"))){P(S,G);return}$(S)},$=async S=>{var z,Q;const G=[S?{label:"Open in new tab",icon:D.jsx(Lh,{}),onClick:()=>{yh(S)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),S&&P(S)}}];((z=q==null?void 0:q.curWorkflow)==null?void 0:z.lastSavedJson)!=null?G.push({label:"Discard",colorScheme:"red",onClick:async()=>{S&&P(S)}}):G.push({label:"Delete",colorScheme:"red",onClick:async()=>{await _(),S&&P(S)}}),p(`Please save or discard your changes to "${(Q=q==null?void 0:q.curWorkflow)==null?void 0:Q.name}" before leaving, or your changes will be lost.`,G)},j=async S=>{const G=(S==null?void 0:S.json)??JSON.stringify(_r),z=await(q==null?void 0:q.createFlow({json:G,name:S==null?void 0:S.name}));z&&await R(z.id),r("root")},B=async(S,G=!1)=>{const z=S.split("/").pop()??S;G?w():j({name:z});const Q=await fetch(mh(S)),M=await Q.blob(),T=new File([M],z,{type:Q.headers.get("Content-Type")||""});await xe.handleFile(T),r("root")},b=async(S,G)=>{const z=await(q==null?void 0:q.get(S));if(z==null)return;const Q=await(q==null?void 0:q.createFlow({json:z.json,lastSavedJson:z.lastSavedJson,name:G||z.name,parentFolderID:z.parentFolderID,tags:z.tags}));Q&&await R(Q.id)},K=A.useCallback(S=>{if(l.current==null)return;let G=S.filename;S.subfolder!=null&&S.subfolder!==""&&(G=S.subfolder+"/"+G),Kt==null||Kt.create({workflowID:l.current,localPath:G})},[]),te=A.useCallback(()=>{r("root")},[]);return A.useEffect(()=>{O(),g(!0);const S=document.getElementById("comfy-file-input"),G=async()=>{if(S&&S.files&&S.files.length>0){const T={id:Fn(),name:S.files[0].name,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(T),await(q==null?void 0:q.createFlow(T))}};S==null||S.addEventListener("change",G);const z=T=>{var H;const ne=(Z==null?void 0:Z.autoSave)??!0;if((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)return;const Y=N();!ne&&Y&&(T.preventDefault(),T.returnValue="You have unsaved changes!",$())};window.addEventListener("beforeunload",z);const Q=T=>{var ne,Y,H,fe,ye,se;(H=(Y=(ne=T.detail)==null?void 0:ne.output)==null?void 0:Y.images)==null||H.forEach(le=>{le.type==="output"&&K(le)}),(se=(ye=(fe=T.detail)==null?void 0:fe.output)==null?void 0:ye.gifs)==null||se.forEach(le=>{le.type==="output"&&K(le)})};Gs.addEventListener("executed",Q);const M=async T=>{var fe,ye;const ne=(ye=(fe=T.dataTransfer)==null?void 0:fe.files[0])==null?void 0:ye.name,Y=xe.dragOverNode;if(Y&&Y.onDragDrop)return;if(!(await(Z==null?void 0:Z.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ne){const se={id:Fn(),name:ne,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(se),await(q==null?void 0:q.createFlow(se))}};return xe.canvasEl.addEventListener("drop",M),()=>{window.removeEventListener("change",G),window.removeEventListener("beforeunload",z),window.removeEventListener("executed",Q),xe.canvasEl.removeEventListener("drop",M)}},[]),o?null:D.jsx(At.Provider,{value:{curFlowID:i,onDuplicateWorkflow:b,loadWorkflowID:R,discardUnsavedChanges:k,saveCurWorkflow:w,isDirty:c,setIsDirty:u,loadNewWorkflow:j,loadFilePath:B,setRoute:r,route:n,curVersion:y,setCurVersion:m},children:D.jsx("div",{ref:d,className:"workspace_manager",children:D.jsxs(Aa,{containerRef:d,children:[D.jsxs(Ct,{style:{position:"absolute",top:0,right:0,left:0},zIndex:dh,draggable:!1,children:[D.jsx(up,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&D.jsx(A.Suspense,{children:D.jsx(bp,{onClose:te,onClickNewFlow:()=>{j(),r("root")}})}),n==="gallery"&&D.jsx(A.Suspense,{children:D.jsx(_p,{onclose:()=>r("root")})})]}),D.jsx(dp,{}),D.jsx(kp,{})]})})})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"}));export{uc as $,q as A,Ct as B,Yh as C,Xh as D,sh as E,xn as F,vp as G,Et as H,jn as I,Mh as J,Lp as K,Wh as L,hi as M,wh as N,ze as O,qr as P,Hr as Q,Gp as R,kd as S,Qr as T,Vr as U,Vh as V,_r as W,Wp as X,wr as Y,Oh as Z,zp as _,Dp as a,mi as a0,pi as a1,bi as a2,yi as a3,gi as a4,vi as a5,At as a6,yl as a7,Kt as a8,ll as a9,Pc as aA,pp as aB,Ch as aC,Vp as aD,Rp as aE,dn as aF,Yp as aG,we as aH,Jp as aI,Xp as aJ,ap as aK,Qp as aL,tc as aM,em as aN,yh as aa,Lh as ab,kt as ac,nc as ad,dh as ae,Fp as af,ul as ag,Up as ah,Ma as ai,za as aj,$p as ak,qp as al,Eh as am,_s as an,Ac as ao,en as ap,dc as aq,wp as ar,Kp as as,Ve as at,Kl as au,ue as av,Hp as aw,Zp as ax,Tp as ay,Bp as az,jc as b,Ap as c,Pp as d,jp as e,fn as f,Jr as g,Fe as h,Zh as i,Ta as j,tn as k,Bt as l,zt as m,Kn as n,Z as o,gp as p,cf as q,Np as r,Mp as s,kr as t,Gr as u,Eo as v,As as w,Ns as x,gt as y,zh as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-o8m3m3T9.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-DRLDc1uk.js","workspace_web/IconCopy-Vm3ws_0T.js","workspace_web/ModelManagerTopbar--uE4bw7I.js","workspace_web/chunk-JARCRF6W-fNDfXRta.js","workspace_web/chunk-3RSXBRAN-ajfTuIGC.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/RecentFilesDrawer-4bh_pwSS.js","workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js","workspace_web/MediaPreview-cVvL6fHO.js","workspace_web/GalleryModal-mtYV1YJE.js","workspace_web/AppIsDirtyEventListener-4vtCCyCS.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-MoNpT1nG.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-DRLDc1uk.js","workspace_web/IconCopy-Hs60LgD8.js","workspace_web/ModelManagerTopbar-4fKW20g4.js","workspace_web/chunk-JARCRF6W-swAlFRrB.js","workspace_web/chunk-3RSXBRAN-hQn4Wngd.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/RecentFilesDrawer-UFHH0mIW.js","workspace_web/chunk-NTCQBYKE-4zMWD2m4.js","workspace_web/MediaPreview-_sS52WD-.js","workspace_web/GalleryModal-oZQWNmu9.js","workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js b/dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js similarity index 97% rename from dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js rename to dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js index 43c17f7..5e3f844 100644 --- a/dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js +++ b/dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js @@ -1 +1 @@ -import{r as l,j as y}from"./input.js";import{app as o}from"/scripts/app.js";import{a6 as S,j as C,ar as E,as as A,E as g,o as W,A as c,at as j,B as x}from"./App-bqAziDgv.js";import"/scripts/api.js";function v(d,f){const i=l.useRef(0),u=l.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=0)},[]),p=l.useCallback((...k)=>{u(),i.current=setTimeout(()=>d(...k),f)},[d,f,u]);return l.useEffect(()=>()=>{u()},[]),[p,u]}function F(){const{isDirty:d,setIsDirty:f,setRoute:i,saveCurWorkflow:u}=l.useContext(S),p=C();l.useEffect(()=>{const a=async e=>{switch(e){case g.SAVE:u();break;case g.SAVE_AS:i("saveAsModal");break}},s=o.canvas.onAfterChange;o.graph.onAfterChange=function(){s==null||s.apply(this,arguments),h()};const n=o.graph.onConfigure;o.graph.onConfigure=function(){n==null||n.apply(this,arguments),setTimeout(()=>{var t,r;E(o.graph.serialize(),JSON.parse(((r=(t=c)==null?void 0:t.curWorkflow)==null?void 0:r.json)??"{}"))||h()},1e3)},document.addEventListener("click",e=>{Object.keys(o.canvas.selected_nodes??{}).length&&(o.canvas.node_over!=null||o.canvas.node_capturing_input!=null||o.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var r;if(document.visibilityState==="hidden")return;const t=await A(e);t?a(t):(r=e.target)!=null&&r.matches("input, textarea")&&Object.keys(o.canvas.selected_nodes??{}).length&&h()})},[]);const k=async()=>{var s,n,e,t;if(!((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.id))return;const a=JSON.stringify(o.graph.serialize());a!=null&&await((e=c)==null?void 0:e.updateFlow(c.curWorkflow.id,{json:a})),(t=j)==null||t.create({workflowID:c.curWorkflow.id,isAutoSave:!0,json:a}),f(!1),p({position:"bottom-left",duration:1e3,render:()=>y.jsx(x,{color:"white",p:3,children:"Auto saved"})})},[b,D]=v(k,1e3),m=async()=>{var s,n,e,t,r,w;if((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.saveLock)return;const a=await((e=W)==null?void 0:e.getSetting("autoSave"));if(!a){!d&&f(!0);return}(r=(t=c)==null?void 0:t.curWorkflow)!=null&&r.id&&a&&(await((w=c)==null?void 0:w.latestVersionCheck())?b():p({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))},[h,_]=v(m,500);return null}export{F as default}; +import{r as l,j as y}from"./input.js";import{app as o}from"/scripts/app.js";import{a6 as S,j as C,ar as E,as as A,E as g,o as W,A as c,at as j,B as x}from"./App-sgH6j00M.js";import"/scripts/api.js";function v(d,f){const i=l.useRef(0),u=l.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=0)},[]),p=l.useCallback((...k)=>{u(),i.current=setTimeout(()=>d(...k),f)},[d,f,u]);return l.useEffect(()=>()=>{u()},[]),[p,u]}function F(){const{isDirty:d,setIsDirty:f,setRoute:i,saveCurWorkflow:u}=l.useContext(S),p=C();l.useEffect(()=>{const a=async e=>{switch(e){case g.SAVE:u();break;case g.SAVE_AS:i("saveAsModal");break}},s=o.canvas.onAfterChange;o.graph.onAfterChange=function(){s==null||s.apply(this,arguments),h()};const n=o.graph.onConfigure;o.graph.onConfigure=function(){n==null||n.apply(this,arguments),setTimeout(()=>{var t,r;E(o.graph.serialize(),JSON.parse(((r=(t=c)==null?void 0:t.curWorkflow)==null?void 0:r.json)??"{}"))||h()},1e3)},document.addEventListener("click",e=>{Object.keys(o.canvas.selected_nodes??{}).length&&(o.canvas.node_over!=null||o.canvas.node_capturing_input!=null||o.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var r;if(document.visibilityState==="hidden")return;const t=await A(e);t?a(t):(r=e.target)!=null&&r.matches("input, textarea")&&Object.keys(o.canvas.selected_nodes??{}).length&&h()})},[]);const k=async()=>{var s,n,e,t;if(!((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.id))return;const a=JSON.stringify(o.graph.serialize());a!=null&&await((e=c)==null?void 0:e.updateFlow(c.curWorkflow.id,{json:a})),(t=j)==null||t.create({workflowID:c.curWorkflow.id,isAutoSave:!0,json:a}),f(!1),p({position:"bottom-left",duration:1e3,render:()=>y.jsx(x,{color:"white",p:3,children:"Auto saved"})})},[b,D]=v(k,1e3),m=async()=>{var s,n,e,t,r,w;if((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.saveLock)return;const a=await((e=W)==null?void 0:e.getSetting("autoSave"));if(!a){!d&&f(!0);return}(r=(t=c)==null?void 0:t.curWorkflow)!=null&&r.id&&a&&(await((w=c)==null?void 0:w.latestVersionCheck())?b():p({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))},[h,_]=v(m,500);return null}export{F as default}; diff --git a/dist/workspace_web/GalleryModal-mtYV1YJE.js b/dist/workspace_web/GalleryModal-oZQWNmu9.js similarity index 99% rename from dist/workspace_web/GalleryModal-mtYV1YJE.js rename to dist/workspace_web/GalleryModal-oZQWNmu9.js index e17dcd9..52db179 100644 --- a/dist/workspace_web/GalleryModal-mtYV1YJE.js +++ b/dist/workspace_web/GalleryModal-oZQWNmu9.js @@ -1,2 +1,2 @@ -import{b as Z,f as R,j as s,g as z,e as L,r as m,m as le,q as Ce,ab as Q,I as qt,L as ut,G as dt,ac as at,ad as se,k as ht,o as Oe,d as Te,x as Jt,E as Zt,n as Qt,V as en,h as tn,M as nn,N as an,O as sn,Q as on,R as rn,S as ln}from"./input.js";import{ai as cn,aj as mt,$ as un,h as he,F as b,ak as dn,I as O,n as hn,al as mn,B as fn,l as q,m as H,z as ft,a9 as xt,am as xn,a6 as gt,k as gn,H as ie,i as vn,a8 as vt,A as De,an as yn,C as bn}from"./App-bqAziDgv.js";import{c as Ae,p as Sn,r as st,v as ot,I as wn,N as pn,a as Pn,d as jn,e as kn,f as In,S as Cn,M as Tn,b as An}from"./MediaPreview-cVvL6fHO.js";import{I as Mn,C as Be,G as _n}from"./chunk-JARCRF6W-fNDfXRta.js";import{S as En}from"./chunk-3RSXBRAN-ajfTuIGC.js";import{L as Re}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,Nn=typeof performance<"u"?()=>performance.now():()=>Date.now(),bt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Nn()),yt);function Dn(e){let t=[],n=[],a=0,o=!1,l=!1;const i=new WeakSet,h={schedule:(r,c=!1,d=!1)=>{const u=d&&o,x=u?t:n;return c&&i.add(r),x.indexOf(r)===-1&&(x.push(r),u&&o&&(a=t.length)),r},cancel:r=>{const c=n.indexOf(r);c!==-1&&n.splice(c,1),i.delete(r)},process:r=>{if(o){l=!0;return}if(o=!0,[t,n]=[n,t],n.length=0,a=t.length,a)for(let c=0;c(e[t]=Dn(()=>J=!0),e),{}),zn=ee.reduce((e,t)=>{const n=me[t];return e[t]=(a,o=!1,l=!1)=>(J||Bn(),n.schedule(a,o,l)),e},{}),$n=ee.reduce((e,t)=>(e[t]=me[t].cancel,e),{});ee.reduce((e,t)=>(e[t]=()=>me[t].process(G),e),{});const On=e=>me[e].process(G),St=e=>{J=!1,G.delta=ze?yt:Math.max(Math.min(e-G.timestamp,Rn),1),G.timestamp=e,$e=!0,ee.forEach(On),$e=!1,J&&(ze=!1,bt(St))},Bn=()=>{J=!0,ze=!0,$e||bt(St)},rt=()=>G;var[Fn,fe]=Z({name:"AccordionStylesContext",hookName:"useAccordionStyles",providerName:""}),[Kn,Fe]=Z({name:"AccordionItemContext",hookName:"useAccordionItemContext",providerName:""}),[Vn,cs,Ln,Un]=cn(),wt=R(function(t,n){const{getButtonProps:a}=Fe(),o=a(t,n),i={display:"flex",alignItems:"center",width:"100%",outline:0,...fe().button};return s.jsx(z.button,{...o,className:L("chakra-accordion__button",t.className),__css:i})});wt.displayName="AccordionButton";function Hn(e){const{onChange:t,defaultIndex:n,index:a,allowMultiple:o,allowToggle:l,...i}=e;Yn(e),Xn(e);const h=Ln(),[r,c]=m.useState(-1);m.useEffect(()=>()=>{c(-1)},[]);const[d,u]=mt({value:a,defaultValue(){return o?n??[]:n??-1},onChange:t});return{index:d,setIndex:u,htmlProps:i,getAccordionItemProps:v=>{let w=!1;return v!==null&&(w=Array.isArray(d)?d.includes(v):d===v),{isOpen:w,onChange:S=>{if(v!==null)if(o&&Array.isArray(d)){const C=S?d.concat(v):d.filter(_=>_!==v);u(C)}else S?u(v):l&&u(-1)}}},focusedIndex:r,setFocusedIndex:c,descendants:h}}var[Gn,Ke]=Z({name:"AccordionContext",hookName:"useAccordionContext",providerName:"Accordion"});function Wn(e){const{isDisabled:t,isFocusable:n,id:a,...o}=e,{getAccordionItemProps:l,setFocusedIndex:i}=Ke(),h=m.useRef(null),r=m.useId(),c=a??r,d=`accordion-button-${c}`,u=`accordion-panel-${c}`;qn(e);const{register:x,index:v,descendants:w}=Un({disabled:t&&!n}),{isOpen:y,onChange:S}=l(v===-1?null:v);Jn({isOpen:y,isDisabled:t});const C=()=>{S==null||S(!0)},_=()=>{S==null||S(!1)},V=m.useCallback(()=>{S==null||S(!y),i(v)},[v,i,y,S]),B=m.useCallback(E=>{const j={ArrowDown:()=>{const T=w.nextEnabled(v);T==null||T.node.focus()},ArrowUp:()=>{const T=w.prevEnabled(v);T==null||T.node.focus()},Home:()=>{const T=w.firstEnabled();T==null||T.node.focus()},End:()=>{const T=w.lastEnabled();T==null||T.node.focus()}}[E.key];j&&(E.preventDefault(),j(E))},[w,v]),p=m.useCallback(()=>{i(v)},[i,v]),P=m.useCallback(function(D={},j=null){return{...D,type:"button",ref:le(x,h,j),id:d,disabled:!!t,"aria-expanded":!!y,"aria-controls":u,onClick:Ce(D.onClick,V),onFocus:Ce(D.onFocus,p),onKeyDown:Ce(D.onKeyDown,B)}},[d,t,y,V,p,B,u,x]),ne=m.useCallback(function(D={},j=null){return{...D,ref:j,role:"region",id:u,"aria-labelledby":d,hidden:!y}},[d,y,u]);return{isOpen:y,isDisabled:t,isFocusable:n,onOpen:C,onClose:_,getButtonProps:P,getPanelProps:ne,htmlProps:o}}function Yn(e){const t=e.index||e.defaultIndex,n=t!=null&&!Array.isArray(t)&&e.allowMultiple;Q({condition:!!n,message:`If 'allowMultiple' is passed, then 'index' or 'defaultIndex' must be an array. You passed: ${typeof t},`})}function Xn(e){Q({condition:!!(e.allowMultiple&&e.allowToggle),message:"If 'allowMultiple' is passed, 'allowToggle' will be ignored. Either remove 'allowToggle' or 'allowMultiple' depending on whether you want multiple accordions visible or not"})}function qn(e){Q({condition:!!(e.isFocusable&&!e.isDisabled),message:`Using only 'isFocusable', this prop is reserved for situations where you pass 'isDisabled' but you still want the element to receive focus (A11y). Either remove it or pass 'isDisabled' as well. +import{b as Z,f as R,j as s,g as z,e as L,r as m,m as le,q as Ce,ab as Q,I as qt,L as ut,G as dt,ac as at,ad as se,k as ht,o as Oe,d as Te,x as Jt,E as Zt,n as Qt,V as en,h as tn,M as nn,N as an,O as sn,Q as on,R as rn,S as ln}from"./input.js";import{ai as cn,aj as mt,$ as un,h as he,F as b,ak as dn,I as O,n as hn,al as mn,B as fn,l as q,m as H,z as ft,a9 as xt,am as xn,a6 as gt,k as gn,H as ie,i as vn,a8 as vt,A as De,an as yn,C as bn}from"./App-sgH6j00M.js";import{c as Ae,p as Sn,r as st,v as ot,I as wn,N as pn,a as Pn,d as jn,e as kn,f as In,S as Cn,M as Tn,b as An}from"./MediaPreview-_sS52WD-.js";import{I as Mn,C as Be,G as _n}from"./chunk-JARCRF6W-swAlFRrB.js";import{S as En}from"./chunk-3RSXBRAN-hQn4Wngd.js";import{L as Re}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,Nn=typeof performance<"u"?()=>performance.now():()=>Date.now(),bt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Nn()),yt);function Dn(e){let t=[],n=[],a=0,o=!1,l=!1;const i=new WeakSet,h={schedule:(r,c=!1,d=!1)=>{const u=d&&o,x=u?t:n;return c&&i.add(r),x.indexOf(r)===-1&&(x.push(r),u&&o&&(a=t.length)),r},cancel:r=>{const c=n.indexOf(r);c!==-1&&n.splice(c,1),i.delete(r)},process:r=>{if(o){l=!0;return}if(o=!0,[t,n]=[n,t],n.length=0,a=t.length,a)for(let c=0;c(e[t]=Dn(()=>J=!0),e),{}),zn=ee.reduce((e,t)=>{const n=me[t];return e[t]=(a,o=!1,l=!1)=>(J||Bn(),n.schedule(a,o,l)),e},{}),$n=ee.reduce((e,t)=>(e[t]=me[t].cancel,e),{});ee.reduce((e,t)=>(e[t]=()=>me[t].process(G),e),{});const On=e=>me[e].process(G),St=e=>{J=!1,G.delta=ze?yt:Math.max(Math.min(e-G.timestamp,Rn),1),G.timestamp=e,$e=!0,ee.forEach(On),$e=!1,J&&(ze=!1,bt(St))},Bn=()=>{J=!0,ze=!0,$e||bt(St)},rt=()=>G;var[Fn,fe]=Z({name:"AccordionStylesContext",hookName:"useAccordionStyles",providerName:""}),[Kn,Fe]=Z({name:"AccordionItemContext",hookName:"useAccordionItemContext",providerName:""}),[Vn,cs,Ln,Un]=cn(),wt=R(function(t,n){const{getButtonProps:a}=Fe(),o=a(t,n),i={display:"flex",alignItems:"center",width:"100%",outline:0,...fe().button};return s.jsx(z.button,{...o,className:L("chakra-accordion__button",t.className),__css:i})});wt.displayName="AccordionButton";function Hn(e){const{onChange:t,defaultIndex:n,index:a,allowMultiple:o,allowToggle:l,...i}=e;Yn(e),Xn(e);const h=Ln(),[r,c]=m.useState(-1);m.useEffect(()=>()=>{c(-1)},[]);const[d,u]=mt({value:a,defaultValue(){return o?n??[]:n??-1},onChange:t});return{index:d,setIndex:u,htmlProps:i,getAccordionItemProps:v=>{let w=!1;return v!==null&&(w=Array.isArray(d)?d.includes(v):d===v),{isOpen:w,onChange:S=>{if(v!==null)if(o&&Array.isArray(d)){const C=S?d.concat(v):d.filter(_=>_!==v);u(C)}else S?u(v):l&&u(-1)}}},focusedIndex:r,setFocusedIndex:c,descendants:h}}var[Gn,Ke]=Z({name:"AccordionContext",hookName:"useAccordionContext",providerName:"Accordion"});function Wn(e){const{isDisabled:t,isFocusable:n,id:a,...o}=e,{getAccordionItemProps:l,setFocusedIndex:i}=Ke(),h=m.useRef(null),r=m.useId(),c=a??r,d=`accordion-button-${c}`,u=`accordion-panel-${c}`;qn(e);const{register:x,index:v,descendants:w}=Un({disabled:t&&!n}),{isOpen:y,onChange:S}=l(v===-1?null:v);Jn({isOpen:y,isDisabled:t});const C=()=>{S==null||S(!0)},_=()=>{S==null||S(!1)},V=m.useCallback(()=>{S==null||S(!y),i(v)},[v,i,y,S]),B=m.useCallback(E=>{const j={ArrowDown:()=>{const T=w.nextEnabled(v);T==null||T.node.focus()},ArrowUp:()=>{const T=w.prevEnabled(v);T==null||T.node.focus()},Home:()=>{const T=w.firstEnabled();T==null||T.node.focus()},End:()=>{const T=w.lastEnabled();T==null||T.node.focus()}}[E.key];j&&(E.preventDefault(),j(E))},[w,v]),p=m.useCallback(()=>{i(v)},[i,v]),P=m.useCallback(function(D={},j=null){return{...D,type:"button",ref:le(x,h,j),id:d,disabled:!!t,"aria-expanded":!!y,"aria-controls":u,onClick:Ce(D.onClick,V),onFocus:Ce(D.onFocus,p),onKeyDown:Ce(D.onKeyDown,B)}},[d,t,y,V,p,B,u,x]),ne=m.useCallback(function(D={},j=null){return{...D,ref:j,role:"region",id:u,"aria-labelledby":d,hidden:!y}},[d,y,u]);return{isOpen:y,isDisabled:t,isFocusable:n,onOpen:C,onClose:_,getButtonProps:P,getPanelProps:ne,htmlProps:o}}function Yn(e){const t=e.index||e.defaultIndex,n=t!=null&&!Array.isArray(t)&&e.allowMultiple;Q({condition:!!n,message:`If 'allowMultiple' is passed, then 'index' or 'defaultIndex' must be an array. You passed: ${typeof t},`})}function Xn(e){Q({condition:!!(e.allowMultiple&&e.allowToggle),message:"If 'allowMultiple' is passed, 'allowToggle' will be ignored. Either remove 'allowToggle' or 'allowMultiple' depending on whether you want multiple accordions visible or not"})}function qn(e){Q({condition:!!(e.isFocusable&&!e.isDisabled),message:`Using only 'isFocusable', this prop is reserved for situations where you pass 'isDisabled' but you still want the element to receive focus (A11y). Either remove it or pass 'isDisabled' as well. `})}function Jn(e){Q({condition:e.isOpen&&!!e.isDisabled,message:"Cannot open a disabled accordion item"})}function pt(e){const{isOpen:t,isDisabled:n}=Fe(),{reduceMotion:a}=Ke(),o=L("chakra-accordion__icon",e.className),l=fe(),i={opacity:n?.4:1,transform:t?"rotate(-180deg)":void 0,transition:a?void 0:"transform 0.2s",transformOrigin:"center",...l.icon};return s.jsx(qt,{viewBox:"0 0 24 24","aria-hidden":!0,className:o,__css:i,...e,children:s.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})})}pt.displayName="AccordionIcon";var Pt=R(function(t,n){const{children:a,className:o}=t,{htmlProps:l,...i}=Wn(t),r={...fe().container,overflowAnchor:"none"},c=m.useMemo(()=>i,[i]);return s.jsx(Kn,{value:c,children:s.jsx(z.div,{ref:n,...l,className:L("chakra-accordion__item",o),__css:r,children:typeof a=="function"?a({isExpanded:!!i.isOpen,isDisabled:!!i.isDisabled}):a})})});Pt.displayName="AccordionItem";var Zn=e=>e!=null&&parseInt(e.toString(),10)>0,lt={exit:{height:{duration:.2,ease:se.ease},opacity:{duration:.3,ease:se.ease}},enter:{height:{duration:.3,ease:se.ease},opacity:{duration:.4,ease:se.ease}}},Qn={exit:({animateOpacity:e,startingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:Zn(t)?1:0},height:t,transitionEnd:a==null?void 0:a.exit,transition:(l=n==null?void 0:n.exit)!=null?l:at.exit(lt.exit,o)}},enter:({animateOpacity:e,endingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:1},height:t,transitionEnd:a==null?void 0:a.enter,transition:(l=n==null?void 0:n.enter)!=null?l:at.enter(lt.enter,o)}}},jt=m.forwardRef((e,t)=>{const{in:n,unmountOnExit:a,animateOpacity:o=!0,startingHeight:l=0,endingHeight:i="auto",style:h,className:r,transition:c,transitionEnd:d,...u}=e,[x,v]=m.useState(!1);m.useEffect(()=>{const _=setTimeout(()=>{v(!0)});return()=>clearTimeout(_)},[]),Q({condition:Number(l)>0&&!!a,message:"startingHeight and unmountOnExit are mutually exclusive. You can't use them together"});const w=parseFloat(l.toString())>0,y={startingHeight:l,endingHeight:i,animateOpacity:o,transition:x?c:{enter:{duration:0}},transitionEnd:{enter:d==null?void 0:d.enter,exit:a?d==null?void 0:d.exit:{...d==null?void 0:d.exit,display:w?"block":"none"}}},S=a?n:!0,C=n||a?"enter":"exit";return s.jsx(ut,{initial:!1,custom:y,children:S&&s.jsx(dt.div,{ref:t,...u,className:L("chakra-collapse",r),style:{overflow:"hidden",display:"block",...h},custom:y,variants:Qn,initial:a?"exit":!1,animate:C,exit:"exit"})})});jt.displayName="Collapse";var kt=R(function(t,n){const{className:a,motionProps:o,...l}=t,{reduceMotion:i}=Ke(),{getPanelProps:h,isOpen:r}=Fe(),c=h(l,n),d=L("chakra-accordion__panel",a),u=fe();i||delete c.hidden;const x=s.jsx(z.div,{...c,__css:u.panel,className:d});return i?x:s.jsx(jt,{in:r,...o,children:x})});kt.displayName="AccordionPanel";var It=R(function({children:t,reduceMotion:n,...a},o){const l=ht("Accordion",a),i=Oe(a),{htmlProps:h,descendants:r,...c}=Hn(i),d=m.useMemo(()=>({...c,reduceMotion:!!n}),[c,n]);return s.jsx(Vn,{value:r,children:s.jsx(Gn,{value:d,children:s.jsx(Fn,{value:l,children:s.jsx(z.div,{ref:o,...h,className:L("chakra-accordion",a.className),__css:l.root,children:t})})})})});It.displayName="Accordion";var U=e=>e?"":void 0,Me=e=>e?!0:void 0,te=(...e)=>e.filter(Boolean).join(" ");function _e(...e){return function(n){e.some(a=>(a==null||a(n),n==null?void 0:n.defaultPrevented))}}function oe(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}var ce={width:0,height:0},re=e=>e||ce;function ea(e){const{orientation:t,thumbPercents:n,thumbRects:a,isReversed:o}=e,l=y=>{var S;const C=(S=a[y])!=null?S:ce;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...oe({orientation:t,vertical:{bottom:`calc(${n[y]}% - ${C.height/2}px)`},horizontal:{left:`calc(${n[y]}% - ${C.width/2}px)`}})}},i=t==="vertical"?a.reduce((y,S)=>re(y).height>re(S).height?y:S,ce):a.reduce((y,S)=>re(y).width>re(S).width?y:S,ce),h={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...oe({orientation:t,vertical:i?{paddingLeft:i.width/2,paddingRight:i.width/2}:{},horizontal:i?{paddingTop:i.height/2,paddingBottom:i.height/2}:{}})},r={position:"absolute",...oe({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},c=n.length===1,d=[0,o?100-n[0]:n[0]],u=c?d:n;let x=u[0];!c&&o&&(x=100-x);const v=Math.abs(u[u.length-1]-u[0]),w={...r,...oe({orientation:t,vertical:o?{height:`${v}%`,top:`${x}%`}:{height:`${v}%`,bottom:`${x}%`},horizontal:o?{width:`${v}%`,right:`${x}%`}:{width:`${v}%`,left:`${x}%`}})};return{trackStyle:r,innerTrackStyle:w,rootStyle:h,getThumbStyle:l}}function ta(e){const{isReversed:t,direction:n,orientation:a}=e;return n==="ltr"||a==="vertical"?t:!t}function na(e,t,n,a){return e.addEventListener(t,n,a),()=>{e.removeEventListener(t,n,a)}}function aa(e){const t=oa(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function Ct(e){return!!e.touches}function sa(e){return Ct(e)&&e.touches.length>1}function oa(e){var t;return(t=e.view)!=null?t:window}function ra(e,t="page"){const n=e.touches[0]||e.changedTouches[0];return{x:n[`${t}X`],y:n[`${t}Y`]}}function la(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function Tt(e,t="page"){return Ct(e)?ra(e,t):la(e,t)}function ia(e){return t=>{const n=aa(t);(!n||n&&t.button===0)&&e(t)}}function ca(e,t=!1){function n(o){e(o,{point:Tt(o)})}return t?ia(n):n}function ue(e,t,n,a){return na(e,t,ca(n,t==="pointerdown"),a)}var ua=Object.defineProperty,da=(e,t,n)=>t in e?ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(da(e,typeof t!="symbol"?t+"":t,n),n),ha=class{constructor(e,t,n){N(this,"history",[]),N(this,"startEvent",null),N(this,"lastEvent",null),N(this,"lastEventInfo",null),N(this,"handlers",{}),N(this,"removeListeners",()=>{}),N(this,"threshold",3),N(this,"win"),N(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const h=Ee(this.lastEventInfo,this.history),r=this.startEvent!==null,c=ga(h.offset,{x:0,y:0})>=this.threshold;if(!r&&!c)return;const{timestamp:d}=rt();this.history.push({...h.point,timestamp:d});const{onStart:u,onMove:x}=this.handlers;r||(u==null||u(this.lastEvent,h),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,h)}),N(this,"onPointerMove",(h,r)=>{this.lastEvent=h,this.lastEventInfo=r,zn.update(this.updatePoint,!0)}),N(this,"onPointerUp",(h,r)=>{const c=Ee(r,this.history),{onEnd:d,onSessionEnd:u}=this.handlers;u==null||u(h,c),this.end(),!(!d||!this.startEvent)&&(d==null||d(h,c))});var a;if(this.win=(a=e.view)!=null?a:window,sa(e))return;this.handlers=t,n&&(this.threshold=n),e.stopPropagation(),e.preventDefault();const o={point:Tt(e)},{timestamp:l}=rt();this.history=[{...o.point,timestamp:l}];const{onSessionStart:i}=t;i==null||i(e,Ee(o,this.history)),this.removeListeners=xa(ue(this.win,"pointermove",this.onPointerMove),ue(this.win,"pointerup",this.onPointerUp),ue(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),$n.update(this.updatePoint)}};function it(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ee(e,t){return{point:e.point,delta:it(e.point,t[t.length-1]),offset:it(e.point,t[0]),velocity:fa(t,.1)}}var ma=e=>e*1e3;function fa(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const o=e[e.length-1];for(;n>=0&&(a=e[n],!(o.timestamp-a.timestamp>ma(t)));)n--;if(!a)return{x:0,y:0};const l=(o.timestamp-a.timestamp)/1e3;if(l===0)return{x:0,y:0};const i={x:(o.x-a.x)/l,y:(o.y-a.y)/l};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function xa(...e){return t=>e.reduce((n,a)=>a(n),t)}function Ne(e,t){return Math.abs(e-t)}function ct(e){return"x"in e&&"y"in e}function ga(e,t){if(typeof e=="number"&&typeof t=="number")return Ne(e,t);if(ct(e)&&ct(t)){const n=Ne(e.x,t.x),a=Ne(e.y,t.y);return Math.sqrt(n**2+a**2)}return 0}function At(e){const t=m.useRef(null);return t.current=e,t}function va(e,t){const{onPan:n,onPanStart:a,onPanEnd:o,onPanSessionStart:l,onPanSessionEnd:i,threshold:h}=t,r=!!(n||a||o||l||i),c=m.useRef(null),d=At({onSessionStart:l,onSessionEnd:i,onStart:a,onMove:n,onEnd(u,x){c.current=null,o==null||o(u,x)}});m.useEffect(()=>{var u;(u=c.current)==null||u.updateHandlers(d.current)}),m.useEffect(()=>{const u=e.current;if(!u||!r)return;function x(v){c.current=new ha(v,d.current,h)}return ue(u,"pointerdown",x)},[e,r,d,h]),m.useEffect(()=>()=>{var u;(u=c.current)==null||u.end(),c.current=null},[])}function ya(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const n=e.ownerDocument.defaultView??window,a=new n.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[l]=o;let i,h;if("borderBoxSize"in l){const r=l.borderBoxSize,c=Array.isArray(r)?r[0]:r;i=c.inlineSize,h=c.blockSize}else i=e.offsetWidth,h=e.offsetHeight;t({width:i,height:h})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}var ba=globalThis!=null&&globalThis.document?m.useLayoutEffect:m.useEffect;function Sa(e,t){var n,a;if(!e||!e.parentElement)return;const o=(a=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?a:window,l=new o.MutationObserver(()=>{t()});return l.observe(e.parentElement,{childList:!0}),()=>{l.disconnect()}}function wa({getNodes:e,observeMutation:t=!0}){const[n,a]=m.useState([]),[o,l]=m.useState(0);return ba(()=>{const i=e(),h=i.map((r,c)=>ya(r,d=>{a(u=>[...u.slice(0,c),d,...u.slice(c+1)])}));if(t){const r=i[0];h.push(Sa(r,()=>{l(c=>c+1)}))}return()=>{h.forEach(r=>{r==null||r()})}},[o]),n}function pa(e){return typeof e=="object"&&e!==null&&"current"in e}function Pa(e){const[t]=wa({observeMutation:!1,getNodes(){return[pa(e)?e.current:e]}});return t}function ja(e){var t;const{min:n=0,max:a=100,onChange:o,value:l,defaultValue:i,isReversed:h,direction:r="ltr",orientation:c="horizontal",id:d,isDisabled:u,isReadOnly:x,onChangeStart:v,onChangeEnd:w,step:y=1,getAriaValueText:S,"aria-valuetext":C,"aria-label":_,"aria-labelledby":V,name:B,focusThumbOnChange:p=!0,...P}=e,ne=Te(v),E=Te(w),D=Te(S),j=ta({isReversed:h,direction:r,orientation:c}),[T,ve]=mt({value:l,defaultValue:i??Ia(n,a),onChange:o}),[ye,Ve]=m.useState(!1),[be,Le]=m.useState(!1),Se=!(u||x),we=(a-n)/10,W=y||(a-n)/100,k=Ae(T,n,a),Ot=a-k+n,Ue=ot(j?Ot:k,n,a),ae=c==="vertical",I=At({min:n,max:a,step:y,isDisabled:u,value:k,isInteractive:Se,isReversed:j,isVertical:ae,eventSource:null,focusThumbOnChange:p,orientation:c}),pe=m.useRef(null),Pe=m.useRef(null),He=m.useRef(null),Bt=m.useId(),Ge=d??Bt,[We,Ye]=[`slider-thumb-${Ge}`,`slider-track-${Ge}`],Ft=m.useCallback(f=>{var g,Y;if(!pe.current)return;const A=I.current;A.eventSource="pointer";const $=pe.current.getBoundingClientRect(),{clientX:ke,clientY:Wt}=(Y=(g=f.touches)==null?void 0:g[0])!=null?Y:f,Yt=ae?$.bottom-Wt:ke-$.left,Xt=ae?$.height:$.width;let Ie=Yt/Xt;j&&(Ie=1-Ie);let X=Sn(Ie,A.min,A.max);return A.step&&(X=parseFloat(st(X,A.min,A.step))),X=Ae(X,A.min,A.max),X},[ae,j,I]),F=m.useCallback(f=>{const g=I.current;g.isInteractive&&(f=parseFloat(st(f,g.min,W)),f=Ae(f,g.min,g.max),ve(f))},[W,ve,I]),K=m.useMemo(()=>({stepUp(f=W){const g=j?k-f:k+f;F(g)},stepDown(f=W){const g=j?k+f:k-f;F(g)},reset(){F(i||0)},stepTo(f){F(f)}}),[F,j,k,W,i]),Xe=m.useCallback(f=>{const g=I.current,A={ArrowRight:()=>K.stepUp(),ArrowUp:()=>K.stepUp(),ArrowLeft:()=>K.stepDown(),ArrowDown:()=>K.stepDown(),PageUp:()=>K.stepUp(we),PageDown:()=>K.stepDown(we),Home:()=>F(g.min),End:()=>F(g.max)}[f.key];A&&(f.preventDefault(),f.stopPropagation(),A(f),g.eventSource="keyboard")},[K,F,we,I]),qe=(t=D==null?void 0:D(k))!=null?t:C,je=Pa(Pe),{getThumbStyle:Je,rootStyle:Ze,trackStyle:Qe,innerTrackStyle:et}=m.useMemo(()=>{const f=I.current,g=je??{width:0,height:0};return ea({isReversed:j,orientation:f.orientation,thumbRects:[g],thumbPercents:[Ue]})},[j,je,Ue,I]),tt=m.useCallback(()=>{I.current.focusThumbOnChange&&setTimeout(()=>{var g;return(g=Pe.current)==null?void 0:g.focus()})},[I]);Jt(()=>{const f=I.current;tt(),f.eventSource==="keyboard"&&(E==null||E(f.value))},[k,E]);function nt(f){const g=Ft(f);g!=null&&g!==I.current.value&&ve(g)}va(He,{onPanSessionStart(f){const g=I.current;g.isInteractive&&(Ve(!0),tt(),nt(f),ne==null||ne(g.value))},onPanSessionEnd(){const f=I.current;f.isInteractive&&(Ve(!1),E==null||E(f.value))},onPan(f){I.current.isInteractive&&nt(f)}});const Kt=m.useCallback((f={},g=null)=>({...f,...P,ref:le(g,He),tabIndex:-1,"aria-disabled":Me(u),"data-focused":U(be),style:{...f.style,...Ze}}),[P,u,be,Ze]),Vt=m.useCallback((f={},g=null)=>({...f,ref:le(g,pe),id:Ye,"data-disabled":U(u),style:{...f.style,...Qe}}),[u,Ye,Qe]),Lt=m.useCallback((f={},g=null)=>({...f,ref:g,style:{...f.style,...et}}),[et]),Ut=m.useCallback((f={},g=null)=>({...f,ref:le(g,Pe),role:"slider",tabIndex:Se?0:void 0,id:We,"data-active":U(ye),"aria-valuetext":qe,"aria-valuemin":n,"aria-valuemax":a,"aria-valuenow":k,"aria-orientation":c,"aria-disabled":Me(u),"aria-readonly":Me(x),"aria-label":_,"aria-labelledby":_?void 0:V,style:{...f.style,...Je(0)},onKeyDown:_e(f.onKeyDown,Xe),onFocus:_e(f.onFocus,()=>Le(!0)),onBlur:_e(f.onBlur,()=>Le(!1))}),[Se,We,ye,qe,n,a,k,c,u,x,_,V,Je,Xe]),Ht=m.useCallback((f,g=null)=>{const Y=!(f.valuea),A=k>=f.value,$=ot(f.value,n,a),ke={position:"absolute",pointerEvents:"none",...ka({orientation:c,vertical:{bottom:j?`${100-$}%`:`${$}%`},horizontal:{left:j?`${100-$}%`:`${$}%`}})};return{...f,ref:g,role:"presentation","aria-hidden":!0,"data-disabled":U(u),"data-invalid":U(!Y),"data-highlighted":U(A),style:{...f.style,...ke}}},[u,j,a,n,c,k]),Gt=m.useCallback((f={},g=null)=>({...f,ref:g,type:"hidden",value:k,name:B}),[B,k]);return{state:{value:k,isFocused:be,isDragging:ye},actions:K,getRootProps:Kt,getTrackProps:Vt,getInnerTrackProps:Lt,getThumbProps:Ut,getMarkerProps:Ht,getInputProps:Gt}}function ka(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}function Ia(e,t){return t"}),[Ta,ge]=Z({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Mt=R((e,t)=>{var n;const a={...e,orientation:(n=e==null?void 0:e.orientation)!=null?n:"horizontal"},o=ht("Slider",a),l=Oe(a),{direction:i}=Zt();l.direction=i;const{getInputProps:h,getRootProps:r,...c}=ja(l),d=r(),u=h({},t);return s.jsx(Ca,{value:c,children:s.jsx(Ta,{value:o,children:s.jsxs(z.div,{...d,className:te("chakra-slider",a.className),__css:o.container,children:[a.children,s.jsx("input",{...u})]})})})});Mt.displayName="Slider";var _t=R((e,t)=>{const{getThumbProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__thumb",e.className),__css:a.thumb})});_t.displayName="SliderThumb";var Et=R((e,t)=>{const{getTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__track",e.className),__css:a.track})});Et.displayName="SliderTrack";var Nt=R((e,t)=>{const{getInnerTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__filled-track",e.className),__css:a.filledTrack})});Nt.displayName="SliderFilledTrack";var Aa=R((e,t)=>{const{getMarkerProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__marker",e.className),__css:a.mark})});Aa.displayName="SliderMark";function Ma(e,t=[]){const n=Object.assign({},e);for(const a of t)a in n&&delete n[a];return n}var _a=["h","minH","height","minHeight"],Dt=R((e,t)=>{const n=Qt("Textarea",e),{className:a,rows:o,...l}=Oe(e),i=un(l),h=o?Ma(n,_a):n;return s.jsx(z.textarea,{ref:t,rows:o,...i,className:L("chakra-textarea",a),__css:h})});Dt.displayName="Textarea";var Ea=he("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]),Na=he("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Rt=he("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"}]]),zt=he("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 Da=({setMediaAct:e,media:t,currentNum:n})=>{const[a,o]=m.useState(0);m.useEffect(()=>{n!==void 0&&o(n)},[n]);const l=r=>{const c=(a+r+t.length)%t.length;o(c),e&&e(t[c])},i={width:"100%",height:"100%"},h={enter:r=>({x:r>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:r=>({x:r<0?500:-500,opacity:1})};return s.jsxs(b,{justifyContent:"center",alignItems:"center",position:"relative",width:i.width,height:i.height,overflow:"hidden",children:[s.jsx(ut,{custom:a,children:t.map((r,c)=>s.jsx(dt.div,{custom:c-a,variants:h,initial:"enter",animate:"center",exit:"exit",transition:{x:{type:"spring",stiffness:300,damping:30},opacity:{duration:.2}},style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%",display:c===a?"block":"none"},onClick:()=>{window.open(r.imageUrl)},children:dn(r.imageUrl)?s.jsx(Mn,{src:r.imageUrl,alt:`image-${r.id}`,width:"100%",height:"100%",objectFit:"contain"}):s.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:r.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:s.jsx("track",{kind:"captions"})})},r.id))}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:s.jsx(Na,{}),onClick:()=>l(-1),position:"absolute",left:"0",zIndex:"2"}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:s.jsx(wn,{}),onClick:()=>l(1),position:"absolute",right:"0",zIndex:"2"})]})},Ra=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(hn,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})}})]}),za=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsxs(pn,{width:"100%",step:e==null?void 0:e.step,value:e.value,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Pn,{}),s.jsxs(jn,{children:[s.jsx(kn,{}),s.jsx(In,{})]})]})]}),s.jsx(b,{children:s.jsxs(Mt,{step:e==null?void 0:e.step,value:Number(e.value),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Et,{children:s.jsx(Nt,{})}),s.jsx(_t,{})]})})]}),$a=e=>{var t;return s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(En,{value:e.value,onChange:n=>{var a;return(a=e==null?void 0:e.updateMetaData)==null?void 0:a.call(e,{promptKey:e.promptKey,name:e.name,value:n.target.value})},children:(t=e==null?void 0:e.options)==null?void 0:t.map((n,a)=>s.jsx("option",{value:n,children:n},`select${e.promptKey}${e.classType}${e.name}${a}`))})]})},Oa=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsx(b,{children:e.label??e.name}),s.jsx(Dt,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})},rows:5})]});var M=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(M||{});const Ba=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(b,{children:"No Support"})]}),Fa=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(Be,{isChecked:!!e.value,onChange:t=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.checked})}})]}),Ka={[M.Input]:Ra,[M.InputSlider]:za,[M.Select]:$a,[M.Textarea]:Oa,[M.Checkbox]:Fa,NoSupport:Ba},Va=mn();function La(e){var a,o,l,i,h;const t=(a=Va[e.classType])==null?void 0:a.nodeData,n={...((o=t==null?void 0:t.input)==null?void 0:o.required)??{},...((l=t==null?void 0:t.input)==null?void 0:l.optional)??{}}[e.name];return(n==null?void 0:n[0])==="STRING"?(i=n==null?void 0:n[1])!=null&&i.multiline?{type:M.Textarea}:{type:M.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:M.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((h=n==null?void 0:n[0])!=null&&h.every(r=>typeof r=="string"))?{options:n==null?void 0:n[0],type:M.Select}:{type:M.NoSupport}}const $t=e=>{const t=La(e),n=Ka[t.type??"Input"];return s.jsxs(_n,{templateColumns:"max-content 1fr",gap:1,children:[s.jsx(b,{children:s.jsx(O,{onClick:()=>{var a;return(a=e==null?void 0:e.updateTopField)==null?void 0:a.call(e,{name:e.name,promptKey:e.promptKey,class_type:e.classType})},variant:"text",icon:de(e.topFields,{name:e.name,promptKey:e.promptKey,classType:e.classType})?s.jsx(Rt,{}):s.jsx(zt,{}),"aria-label":"pin"})}),s.jsx(n,{...e,...t})]})};function Ua({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){if(n.length===0)return null;const o=e.prompt;return s.jsx(s.Fragment,{children:s.jsx(b,{px:2,gap:2,direction:"column",children:n==null?void 0:n.map((l,i)=>{var d,u,x;const h=(d=o==null?void 0:o[l.promptKey])==null?void 0:d.inputs;if(!h||((u=o==null?void 0:o[l.promptKey])==null?void 0:u.class_type)!==l.class_type)return null;const c=h==null?void 0:h[l.name];return s.jsx($t,{promptKey:l.promptKey,classType:(x=o==null?void 0:o[l.promptKey])==null?void 0:x.class_type,name:l.name,value:c,updateMetaData:t,updateTopField:a,topFields:n},`formTop${l.name}${i}`)})})})}function Ha({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){const o=e.prompt,[l,i]=m.useState([]);return m.useEffect(()=>{i(Object.keys(o).map((h,r)=>r))},[o]),s.jsx(It,{index:l,onChange:h=>i(h),allowMultiple:!0,children:Object.keys(o).map(h=>{const r=o[h],c=r.inputs,d=Object.keys(c).filter(u=>!Array.isArray(c[u])&&!de(n,{name:u,promptKey:h,classType:r.class_type}));return d.length===0?null:s.jsxs(Pt,{borderWidth:1,borderRadius:8,my:2,children:[s.jsxs(wt,{children:[s.jsx(fn,{as:"span",flex:"1",textAlign:"left",children:r.class_type}),s.jsx(pt,{})]}),s.jsx(kt,{children:s.jsx(b,{px:2,gap:1,direction:"column",children:d==null?void 0:d.map(u=>{const x=c[u];return de(n,{name:u,promptKey:h,classType:r.class_type})?null:s.jsx($t,{promptKey:h,classType:r==null?void 0:r.class_type,value:x,name:u,updateMetaData:t,updateTopField:a,topFields:n,metaData:e},`form${u}`)})})})]},`AccordionItem${h}`)})})}const Ga=[{promptKey:"4",name:"ckpt_name",class_type:"CheckpointLoaderSimple"},{promptKey:"6",name:"text",class_type:"CLIPTextEncode"},{promptKey:"7",name:"text",class_type:"CLIPTextEncode"},{promptKey:"5",name:"width",class_type:"EmptyLatentImage"},{promptKey:"5",name:"height",class_type:"EmptyLatentImage"},{promptKey:"3",name:"steps",class_type:"KSampler"},{promptKey:"3",name:"sampler_name",class_type:"KSampler"},{promptKey:"3",name:"cfg",class_type:"KSampler"}],de=(e,t)=>e==null?void 0:e.some(n=>n.promptKey===(t==null?void 0:t.promptKey)&&n.name===(t==null?void 0:t.name)&&n.class_type===t.classType);function Wa({metaData:e}){const t=JSON.parse(JSON.stringify(e)),[n,a]=m.useState(Ga),[o,l]=m.useState(t),i=({promptKey:r,name:c,value:d})=>{l(u=>{var x,v,w;return{...u??{},prompt:{...(u==null?void 0:u.prompt)??{},[r]:{...((x=u==null?void 0:u.prompt)==null?void 0:x[r])??{},inputs:{...((w=(v=u.prompt)==null?void 0:v[r])==null?void 0:w.inputs)??{},[c]:d}}}}})},h=r=>{de(n,{name:r.name,promptKey:r==null?void 0:r.promptKey,classType:(r==null?void 0:r.class_type)??""})?a(c=>c.filter(d=>d.name!==r.name||d.promptKey!==r.promptKey)):a(c=>[...c,r])};return s.jsxs(b,{direction:"column",align:"stretch",children:[s.jsx(Ua,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h}),s.jsx(Ha,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h})]})}const Ya=({media:e})=>{const[t,n]=m.useState(),a=async o=>{try{const l=await xn(`/workspace/view_media?filename=${o.localPath}`);n(l)}catch(l){console.error(l)}};return m.useEffect(()=>{e&&a(e)},[e]),s.jsxs(b,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[s.jsxs(Cn,{alignItems:"center",columns:2,spacing:2,children:[s.jsxs(b,{alignItems:"center",gap:1,children:[s.jsx(q,{children:e==null?void 0:e.localPath}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:s.jsx(O,{size:"sm",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]}),s.jsxs(b,{gap:1,alignItems:"center",children:[s.jsx(q,{children:"Create Time:"}),s.jsx(q,{children:xt((e==null?void 0:e.createTime)??0,!0)})]})]}),e&&t&&s.jsx(Wa,{metaData:t,media:e})]})},Xa=({mediaList:e,media:t})=>{const[n,a]=m.useState();return m.useEffect(()=>{t&&a(t)},[t]),s.jsxs(b,{gap:3,h:"100%",children:[s.jsx(b,{flex:1,children:s.jsx(Da,{media:e.map(o=>({id:o.id,imageUrl:`/workspace/view_media?filename=${o.localPath}`})),currentNum:e==null?void 0:e.findIndex(o=>o.id===(n==null?void 0:n.id)),setMediaAct:o=>a(e==null?void 0:e.find(l=>l.id===o.id))})}),s.jsx(Ya,{media:n})]})},qa=({media:e,isSelecting:t,selectedID:n,onClickMedia:a,onRefreshImagesList:o,coverPath:l,setCoverPath:i})=>{const{curFlowID:r,loadFilePath:c}=m.useContext(gt),{showDialog:d}=en();if(e.localPath==null)return null;const u=l!=null&&l===e.localPath;if(r==null)return null;const x=s.jsxs(Re,{isExternal:!0,onClick:()=>a(e),position:"relative",children:[t&&s.jsx(Be,{isChecked:n.includes(e.id),position:"absolute",top:2,left:2}),s.jsx(Tn,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!0})]});return s.jsxs(gn,{width:180,mb:2,children:[s.jsx(H,{label:xt(e.createTime,!0),children:x}),s.jsx(H,{label:e.localPath,children:s.jsx(q,{color:"GrayText",noOfLines:1,children:e.localPath})}),s.jsxs(ie,{hidden:t,gap:0,children:[s.jsx(H,{label:"Set as cover",children:s.jsx(O,{size:"sm",variant:"ghost",icon:u?s.jsx(Rt,{size:19}):s.jsx(zt,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=De)==null||v.updateMetaInfo(r,{coverMediaPath:e.localPath}),i(e.localPath)}})}),s.jsx(tn,{flexGrow:1,onClick:()=>d("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{c(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>c(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),s.jsx(H,{label:"Remove image from gallery",children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(vn,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var w,y;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((w=vt)==null?void 0:w.delete(e.id)),u&&(await((y=De)==null?void 0:y.updateMetaInfo(r,{coverMediaPath:void 0})),i("")),o())}})})]})]})},Ja=qa;function us({onclose:e}){const{curFlowID:t}=m.useContext(gt),[n,a]=m.useState(""),[o,l]=m.useState([]),[i,h]=m.useState(!1),[r,c]=m.useState(""),[d,u]=m.useState([]),[x,v]=m.useState(),[w,y]=m.useState(""),S=p=>{y(p)},C=async()=>{var P;if(t==null)return;const p=await((P=vt)==null?void 0:P.listByWorkflowID(t));u(p??[])};m.useEffect(()=>{var p;C(),t&&((p=De)==null||p.get(t).then(P=>{P&&(a(P.name),P!=null&&P.coverMediaPath&&c(P==null?void 0:P.coverMediaPath))}))},[]);const _=w.length?d==null?void 0:d.filter(p=>{var P;return(P=p.workflowJSON)==null?void 0:P.includes(w??"")}):d;if(t==null)return null;const V=p=>{if(i){o.includes(p.id)?l(o.filter(P=>P!==p.id)):l([...o,p.id]);return}v(p)},B=d.length>0&&o.length===d.length;return s.jsxs(nn,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[s.jsx(an,{}),s.jsxs(sn,{width:"90%",maxWidth:"90vw",height:"90vh",children:[s.jsxs(on,{children:[s.jsx(ie,{gap:2,mb:2,children:s.jsxs(yn,{size:"md",mr:2,children:[!!x&&s.jsx(O,{onClick:()=>v(void 0),variant:"ghost",mr:1,"aria-label":"back",icon:s.jsx(Ea,{})}),"Gallery - ",n,!x&&s.jsx(b,{gap:2,display:"inline-flex",ml:2,children:s.jsx(An,{searchValue:w,onUpdateSearchValue:S})})]})}),i&&s.jsxs(ie,{gap:3,children:[s.jsx(Be,{isChecked:B,onChange:()=>{l(B?[]:d.map(p=>p.id))},children:"All"}),s.jsxs(q,{fontSize:16,children:[o.length," Selected"]}),s.jsx(O,{size:"sm",icon:s.jsx(bn,{size:19}),onClick:()=>h(!1),"aria-label":"cancel"})]})]}),s.jsx(rn,{}),s.jsx(ln,{overflowY:"auto",children:x?s.jsx(Xa,{mediaList:d,media:x}):s.jsx(ie,{wrap:"wrap",children:_.map(p=>s.jsx(Ja,{selectedID:o,media:p,isSelecting:i,onClickMedia:V,onRefreshImagesList:C,coverPath:r,setCoverPath:c},p.id))})})]})]})}export{us as default}; diff --git a/dist/workspace_web/IconCopy-Vm3ws_0T.js b/dist/workspace_web/IconCopy-Hs60LgD8.js similarity index 83% rename from dist/workspace_web/IconCopy-Vm3ws_0T.js rename to dist/workspace_web/IconCopy-Hs60LgD8.js index b6c56d0..2e6c4c8 100644 --- a/dist/workspace_web/IconCopy-Vm3ws_0T.js +++ b/dist/workspace_web/IconCopy-Hs60LgD8.js @@ -1 +1 @@ -import{h as a}from"./App-bqAziDgv.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{h as a}from"./App-sgH6j00M.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/InstallMissingModelsButton-g1lfodpY.js b/dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js similarity index 89% rename from dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js rename to dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js index 12e03a5..fdd3df9 100644 --- a/dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js +++ b/dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js @@ -1 +1 @@ -import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar--uE4bw7I.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aM as I,F as S,an as b}from"./App-bqAziDgv.js";import{V as k}from"./chunk-NTCQBYKE-ZJqEVTS0.js";import{I as y,G as C}from"./chunk-JARCRF6W-fNDfXRta.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-ajfTuIGC.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default}; +import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar-4fKW20g4.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aM as I,F as S,an as b}from"./App-sgH6j00M.js";import{V as k}from"./chunk-NTCQBYKE-4zMWD2m4.js";import{I as y,G as C}from"./chunk-JARCRF6W-swAlFRrB.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-hQn4Wngd.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default}; diff --git a/dist/workspace_web/MediaPreview-cVvL6fHO.js b/dist/workspace_web/MediaPreview-_sS52WD-.js similarity index 98% rename from dist/workspace_web/MediaPreview-cVvL6fHO.js rename to dist/workspace_web/MediaPreview-_sS52WD-.js index 41c8a03..3c967f8 100644 --- a/dist/workspace_web/MediaPreview-cVvL6fHO.js +++ b/dist/workspace_web/MediaPreview-_sS52WD-.js @@ -1 +1 @@ -import{G as Ge,I as Ke}from"./chunk-JARCRF6W-fNDfXRta.js";import{d as M,r as s,f as T,E as Ue,j as f,ae as $e,I as Ee,x as qe,y as ze,m as ae,q as y,p as se,b as Pe,g as Y,k as He,o as Le,e as Me}from"./input.js";import{ao as Fe,ap as We,aq as Xe,h as Re,B as Ye,I as Je,C as Qe,n as Ze,ak as et}from"./App-bqAziDgv.js";function tt(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function le(t,e){let r=tt(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(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 Et(t,e,r){return(t-e)*100/(r-e)}function Pt(t,e,r){return(r-e)*t+e}function Mt(t,e,r){const a=Math.round((t-e)/r)*r+e,o=oe(r);return le(a,o)}function nt(t,e,r){return t==null?t:(r{var m;return a==null?"":(m=ue(a,u,r))!=null?m:""}),S=typeof o<"u",x=S?o:C,O=Te(k(x),u),F=r??O,I=s.useCallback(m=>{m!==x&&(S||A(m.toString()),h==null||h(m.toString(),k(m)))},[h,S,x]),w=s.useCallback(m=>{let d=m;return b&&(d=nt(d,i,p)),le(d,F)},[F,b,p,i]),B=s.useCallback((m=u)=>{let d;x===""?d=k(m):d=k(x)+m,d=w(d),I(d)},[w,u,I,x]),G=s.useCallback((m=u)=>{let d;x===""?d=k(-m):d=k(x)-m,d=w(d),I(d)},[w,u,I,x]),K=s.useCallback(()=>{var m;let d;a==null?d="":d=(m=ue(a,u,r))!=null?m:i,I(d)},[a,r,u,I,i]),Q=s.useCallback(m=>{var d;const ee=(d=ue(m,u,F))!=null?d:i;I(ee)},[F,u,I,i]),E=k(x);return{isOutOfRange:E>p||E{const a=$e("sizes",r,st(r))(e);return r===null?null:`repeat(auto-fit, minmax(${a}, 1fr))`})}function ot(t){return Fe(t,e=>e===null?null:`repeat(${e}, minmax(0, 1fr))`)}var lt=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),it=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function ke(t,e,r,a){s.useEffect(()=>{var o;if(!t.current||!a)return;const u=(o=t.current.ownerDocument.defaultView)!=null?o:window,i=Array.isArray(e)?e:[e],p=new u.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return p.observe(t.current,{attributes:!0,attributeFilter:i}),()=>p.disconnect()})}function ct(t,e){const r=M(t);s.useEffect(()=>{let a=null;const o=()=>r();return e!==null&&(a=window.setInterval(o,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var pt=50,Ae=300;function dt(t,e){const[r,a]=s.useState(!1),[o,u]=s.useState(null),[i,p]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);ct(()=>{o==="increment"&&t(),o==="decrement"&&e()},r?pt:null);const C=s.useCallback(()=>{i&&t(),b.current=setTimeout(()=>{p(!1),a(!0),u("increment")},Ae)},[t,i]),A=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{p(!1),a(!0),u("decrement")},Ae)},[e,i]),S=s.useCallback(()=>{p(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:C,down:A,stop:S,isSpinning:r}}var mt=/^[Ee0-9+\-.]$/;function ft(t){return mt.test(t)}function bt(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 vt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:o=Number.MIN_SAFE_INTEGER,max:u=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:p,isDisabled:b,isRequired:h,isInvalid:C,pattern:A="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:I,name:w,"aria-describedby":B,"aria-label":G,"aria-labelledby":K,onFocus:Q,onBlur:E,onInvalid:ce,getAriaValueText:pe,isValidCharacter:Z,format:m,parse:d,...ee}=t,te=M(Q),de=M(E),V=M(ce),U=M(Z??ft),ne=M(pe),l=rt(t),{update:j,increment:me,decrement:fe}=l,[je,re]=s.useState(!1),$=!(p||b),_=s.useRef(null),q=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),z=s.useCallback(n=>n.split("").filter(U).join(""),[U]),H=s.useCallback(n=>{var c;return(c=d==null?void 0:d(n))!=null?c:n},[d]),R=s.useCallback(n=>{var c;return((c=m==null?void 0:m(n))!=null?c:n).toString()},[m]);qe(()=>{(l.valueAsNumber>u||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=H(_.current.value);l.setValue(z(c))}},[H,z]);const L=s.useCallback((n=i)=>{$&&me(n)},[me,$,i]),W=s.useCallback((n=i)=>{$&&fe(n)},[fe,$,i]),g=dt(L,W);ke(be,"disabled",g.stop,g.isSpinning),ke(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;const v=H(n.currentTarget.value);j(z(v)),q.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[j,z,H]),ge=s.useCallback(n=>{var c,v,N;te==null||te(n),q.current&&(n.target.selectionStart=(v=q.current.start)!=null?v:(c=n.currentTarget.value)==null?void 0:c.length,n.currentTarget.selectionEnd=(N=q.current.end)!=null?N:n.currentTarget.selectionStart)},[te]),xe=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;bt(n,U)||n.preventDefault();const c=Ne(n)*i,v=n.key,P={ArrowUp:()=>L(c),ArrowDown:()=>W(c),Home:()=>j(o),End:()=>j(u)}[v];P&&(n.preventDefault(),P(n))},[U,i,L,W,j,o,u]),Ne=n=>{let c=1;return(n.metaKey||n.ctrlKey)&&(c=.1),n.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const n=ne==null?void 0:ne(l.value);if(n!=null)return n;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let n=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumberu&&(n=u),l.cast(n))},[l,u,o]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=_.current)==null||n.focus()})},[e]),Se=s.useCallback(n=>{n.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(n=>{n.preventDefault(),g.down(),X()},[X,g]);We(()=>_.current,"wheel",n=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;n.preventDefault();const D=Ne(n)*i,_e=Math.sign(n.deltaY);_e===-1?L(D):_e===1&&W(D)},{passive:!1});const De=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMax;return{...n,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),Oe=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMin;return{...n,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),Be=s.useCallback((n={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:A,"aria-labelledby":K,"aria-label":G,"aria-describedby":B,id:O,disabled:b,...n,readOnly:(v=n.readOnly)!=null?v:p,"aria-readonly":(N=n.readOnly)!=null?N:p,"aria-required":(P=n.required)!=null?P:h,required:(D=n.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":o,"aria-valuemax":u,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(C??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:y(n.onChange,he),onKeyDown:y(n.onKeyDown,xe),onFocus:y(n.onFocus,ge,()=>re(!0)),onBlur:y(n.onBlur,de,Ce)}},[w,S,A,K,G,R,B,O,b,h,p,C,l.value,l.valueAsNumber,l.isOutOfRange,o,u,Ie,he,xe,ge,de,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:je,isDisabled:b,isReadOnly:p,getIncrementButtonProps:De,getDecrementButtonProps:Oe,getInputProps:Be,htmlProps:ee}}var[ht,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[gt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),xt=T(function(e,r){const a=He("NumberInput",e),o=Le(e),u=Xe(o),{htmlProps:i,...p}=vt(u),b=s.useMemo(()=>p,[p]);return f.jsx(gt,{value:b,children:f.jsx(ht,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});xt.displayName="NumberInput";var Nt=T(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});Nt.displayName="NumberInputStepper";var It=T(function(e,r){const{getInputProps:a}=ie(),o=a(e,r),u=J();return f.jsx(Y.input,{...o,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...u.field}})});It.displayName="NumberInputField";var Ve=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),yt=T(function(e,r){var a;const o=J(),{getDecrementButtonProps:u}=ie(),i=u(e,r);return f.jsx(Ve,{...i,__css:o.stepper,children:(a=e.children)!=null?a:f.jsx(lt,{})})});yt.displayName="NumberDecrementStepper";var Ct=T(function(e,r){var a;const{getIncrementButtonProps:o}=ie(),u=o(e,r),i=J();return f.jsx(Ve,{...u,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(it,{})})});Ct.displayName="NumberIncrementStepper";var Ft=Re("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]),St=Re("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"}]]);const wt={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function Rt(t){const{searchValue:e,onUpdateSearchValue:r}=t,a=e!=="";return f.jsxs(Ye,{style:{position:"relative"},mb:2,children:[f.jsx(St,{style:wt}),a&&f.jsx(Je,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(Qe,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(Ze,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function Tt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:o,onBrokenLink:u}){const[i,p]=s.useState(!0);return s.useEffect(()=>{o&&(async()=>{try{if(!(await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");p(!0)}catch{p(!1),u==null||u()}})()},[]),i?et(t)?f.jsx(Ke,{borderRadius:3,boxSize:`${e}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{Ft as I,Tt as M,xt as N,at as S,It as a,Rt as b,nt as c,Nt as d,Ct as e,yt as f,Pt as p,Mt as r,Et as v}; +import{G as Ge,I as Ke}from"./chunk-JARCRF6W-swAlFRrB.js";import{d as M,r as s,f as T,E as Ue,j as f,ae as $e,I as Ee,x as qe,y as ze,m as ae,q as y,p as se,b as Pe,g as Y,k as He,o as Le,e as Me}from"./input.js";import{ao as Fe,ap as We,aq as Xe,h as Re,B as Ye,I as Je,C as Qe,n as Ze,ak as et}from"./App-sgH6j00M.js";function tt(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function le(t,e){let r=tt(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(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 Et(t,e,r){return(t-e)*100/(r-e)}function Pt(t,e,r){return(r-e)*t+e}function Mt(t,e,r){const a=Math.round((t-e)/r)*r+e,o=oe(r);return le(a,o)}function nt(t,e,r){return t==null?t:(r{var m;return a==null?"":(m=ue(a,u,r))!=null?m:""}),S=typeof o<"u",x=S?o:C,O=Te(k(x),u),F=r??O,I=s.useCallback(m=>{m!==x&&(S||A(m.toString()),h==null||h(m.toString(),k(m)))},[h,S,x]),w=s.useCallback(m=>{let d=m;return b&&(d=nt(d,i,p)),le(d,F)},[F,b,p,i]),B=s.useCallback((m=u)=>{let d;x===""?d=k(m):d=k(x)+m,d=w(d),I(d)},[w,u,I,x]),G=s.useCallback((m=u)=>{let d;x===""?d=k(-m):d=k(x)-m,d=w(d),I(d)},[w,u,I,x]),K=s.useCallback(()=>{var m;let d;a==null?d="":d=(m=ue(a,u,r))!=null?m:i,I(d)},[a,r,u,I,i]),Q=s.useCallback(m=>{var d;const ee=(d=ue(m,u,F))!=null?d:i;I(ee)},[F,u,I,i]),E=k(x);return{isOutOfRange:E>p||E{const a=$e("sizes",r,st(r))(e);return r===null?null:`repeat(auto-fit, minmax(${a}, 1fr))`})}function ot(t){return Fe(t,e=>e===null?null:`repeat(${e}, minmax(0, 1fr))`)}var lt=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),it=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function ke(t,e,r,a){s.useEffect(()=>{var o;if(!t.current||!a)return;const u=(o=t.current.ownerDocument.defaultView)!=null?o:window,i=Array.isArray(e)?e:[e],p=new u.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return p.observe(t.current,{attributes:!0,attributeFilter:i}),()=>p.disconnect()})}function ct(t,e){const r=M(t);s.useEffect(()=>{let a=null;const o=()=>r();return e!==null&&(a=window.setInterval(o,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var pt=50,Ae=300;function dt(t,e){const[r,a]=s.useState(!1),[o,u]=s.useState(null),[i,p]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);ct(()=>{o==="increment"&&t(),o==="decrement"&&e()},r?pt:null);const C=s.useCallback(()=>{i&&t(),b.current=setTimeout(()=>{p(!1),a(!0),u("increment")},Ae)},[t,i]),A=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{p(!1),a(!0),u("decrement")},Ae)},[e,i]),S=s.useCallback(()=>{p(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:C,down:A,stop:S,isSpinning:r}}var mt=/^[Ee0-9+\-.]$/;function ft(t){return mt.test(t)}function bt(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 vt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:o=Number.MIN_SAFE_INTEGER,max:u=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:p,isDisabled:b,isRequired:h,isInvalid:C,pattern:A="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:I,name:w,"aria-describedby":B,"aria-label":G,"aria-labelledby":K,onFocus:Q,onBlur:E,onInvalid:ce,getAriaValueText:pe,isValidCharacter:Z,format:m,parse:d,...ee}=t,te=M(Q),de=M(E),V=M(ce),U=M(Z??ft),ne=M(pe),l=rt(t),{update:j,increment:me,decrement:fe}=l,[je,re]=s.useState(!1),$=!(p||b),_=s.useRef(null),q=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),z=s.useCallback(n=>n.split("").filter(U).join(""),[U]),H=s.useCallback(n=>{var c;return(c=d==null?void 0:d(n))!=null?c:n},[d]),R=s.useCallback(n=>{var c;return((c=m==null?void 0:m(n))!=null?c:n).toString()},[m]);qe(()=>{(l.valueAsNumber>u||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=H(_.current.value);l.setValue(z(c))}},[H,z]);const L=s.useCallback((n=i)=>{$&&me(n)},[me,$,i]),W=s.useCallback((n=i)=>{$&&fe(n)},[fe,$,i]),g=dt(L,W);ke(be,"disabled",g.stop,g.isSpinning),ke(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;const v=H(n.currentTarget.value);j(z(v)),q.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[j,z,H]),ge=s.useCallback(n=>{var c,v,N;te==null||te(n),q.current&&(n.target.selectionStart=(v=q.current.start)!=null?v:(c=n.currentTarget.value)==null?void 0:c.length,n.currentTarget.selectionEnd=(N=q.current.end)!=null?N:n.currentTarget.selectionStart)},[te]),xe=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;bt(n,U)||n.preventDefault();const c=Ne(n)*i,v=n.key,P={ArrowUp:()=>L(c),ArrowDown:()=>W(c),Home:()=>j(o),End:()=>j(u)}[v];P&&(n.preventDefault(),P(n))},[U,i,L,W,j,o,u]),Ne=n=>{let c=1;return(n.metaKey||n.ctrlKey)&&(c=.1),n.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const n=ne==null?void 0:ne(l.value);if(n!=null)return n;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let n=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumberu&&(n=u),l.cast(n))},[l,u,o]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=_.current)==null||n.focus()})},[e]),Se=s.useCallback(n=>{n.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(n=>{n.preventDefault(),g.down(),X()},[X,g]);We(()=>_.current,"wheel",n=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;n.preventDefault();const D=Ne(n)*i,_e=Math.sign(n.deltaY);_e===-1?L(D):_e===1&&W(D)},{passive:!1});const De=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMax;return{...n,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),Oe=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMin;return{...n,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),Be=s.useCallback((n={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:A,"aria-labelledby":K,"aria-label":G,"aria-describedby":B,id:O,disabled:b,...n,readOnly:(v=n.readOnly)!=null?v:p,"aria-readonly":(N=n.readOnly)!=null?N:p,"aria-required":(P=n.required)!=null?P:h,required:(D=n.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":o,"aria-valuemax":u,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(C??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:y(n.onChange,he),onKeyDown:y(n.onKeyDown,xe),onFocus:y(n.onFocus,ge,()=>re(!0)),onBlur:y(n.onBlur,de,Ce)}},[w,S,A,K,G,R,B,O,b,h,p,C,l.value,l.valueAsNumber,l.isOutOfRange,o,u,Ie,he,xe,ge,de,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:je,isDisabled:b,isReadOnly:p,getIncrementButtonProps:De,getDecrementButtonProps:Oe,getInputProps:Be,htmlProps:ee}}var[ht,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[gt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),xt=T(function(e,r){const a=He("NumberInput",e),o=Le(e),u=Xe(o),{htmlProps:i,...p}=vt(u),b=s.useMemo(()=>p,[p]);return f.jsx(gt,{value:b,children:f.jsx(ht,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});xt.displayName="NumberInput";var Nt=T(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});Nt.displayName="NumberInputStepper";var It=T(function(e,r){const{getInputProps:a}=ie(),o=a(e,r),u=J();return f.jsx(Y.input,{...o,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...u.field}})});It.displayName="NumberInputField";var Ve=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),yt=T(function(e,r){var a;const o=J(),{getDecrementButtonProps:u}=ie(),i=u(e,r);return f.jsx(Ve,{...i,__css:o.stepper,children:(a=e.children)!=null?a:f.jsx(lt,{})})});yt.displayName="NumberDecrementStepper";var Ct=T(function(e,r){var a;const{getIncrementButtonProps:o}=ie(),u=o(e,r),i=J();return f.jsx(Ve,{...u,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(it,{})})});Ct.displayName="NumberIncrementStepper";var Ft=Re("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]),St=Re("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"}]]);const wt={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function Rt(t){const{searchValue:e,onUpdateSearchValue:r}=t,a=e!=="";return f.jsxs(Ye,{style:{position:"relative"},mb:2,children:[f.jsx(St,{style:wt}),a&&f.jsx(Je,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(Qe,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(Ze,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function Tt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:o,onBrokenLink:u}){const[i,p]=s.useState(!0);return s.useEffect(()=>{o&&(async()=>{try{if(!(await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");p(!0)}catch{p(!1),u==null||u()}})()},[]),i?et(t)?f.jsx(Ke,{borderRadius:3,boxSize:`${e}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{Ft as I,Tt as M,xt as N,at as S,It as a,Rt as b,nt as c,Nt as d,Ct as e,yt as f,Pt as p,Mt as r,Et as v}; diff --git a/dist/workspace_web/ModelManagerTopbar--uE4bw7I.js b/dist/workspace_web/ModelManagerTopbar-4fKW20g4.js similarity index 98% rename from dist/workspace_web/ModelManagerTopbar--uE4bw7I.js rename to dist/workspace_web/ModelManagerTopbar-4fKW20g4.js index 2d785cf..6fbe5aa 100644 --- a/dist/workspace_web/ModelManagerTopbar--uE4bw7I.js +++ b/dist/workspace_web/ModelManagerTopbar-4fKW20g4.js @@ -1,7 +1,7 @@ -import{f as Y,r as m,j as n,g as $,e as Se,a4 as X,b as $e,o as Ve,k as Ue,h as T,a9 as re,af as He,N as _e,ag as Ye,Q as be,S as Ce,T as qe,Z as Qe,M as Je,O as Xe,R as Ze,P as et,_ as tt}from"./input.js";import{au as st,ao as nt,av as H,o as V,B as oe,F as B,l as D,m as ie,aw as ke,ax as pe,ad as Ie,k as q,z as ot,H as W,n as Z,ay as Le,j as Ee,az as it,aA as Te,a0 as rt,a1 as at,a2 as lt,a3 as ct,a4 as dt,aB as Ae,aC as te,an as Ne,aD as ht,aE as ut,ae as ft,a6 as pt}from"./App-bqAziDgv.js";import{I as De,G as mt,C as gt}from"./chunk-JARCRF6W-fNDfXRta.js";import{app as z}from"/scripts/app.js";import{api as J}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-ajfTuIGC.js";var Fe=Y(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(ae,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",h),...u,children:n.jsx($.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})})});Fe.displayName="Wrap";var ae=Y(function(e,s){const{className:o,...r}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...r})});ae.displayName="WrapItem";function me(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Pe=Y(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=st({gridArea:o,gridColumn:me(r),gridRow:me(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx($.div,{ref:s,__css:f,...h})});Pe.displayName="GridItem";function xt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var yt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),vt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function wt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=xt(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[jt,Mt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),St=Y((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=wt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Mt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),Oe=Y((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":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...y}=Ve(t),j=Ue("Progress",t),C=d??((s=j.track)==null?void 0:s.borderRadius),b={animation:`${vt} 1s linear infinite`},F={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${yt} 1s ease infinite normal none running`}},k={overflow:"hidden",position:"relative",...j.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:k,...y,children:n.jsxs(jt,{value:j,children:[n.jsx(St,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:F,borderRadius:C,title:p,role:x}),l]})})});Oe.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const _t=1/0;function bt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-_t?"-0":s}(t)}function P(t){return typeof t=="string"}function ze(t){return typeof t=="number"}function Ct(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kt=t=>`Missing ${t} property in key`,It=t=>`Property 'weight' in key '${t}' must be a positive integer`,ge=Object.prototype.hasOwnProperty;class Lt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Be(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 Be(t){let e=null,s=null,o=null,r=1,i=null;if(P(t)||K(t))o=t,e=xe(t),s=ye(t);else{if(!ge.call(t,"name"))throw new Error(kt("name"));const a=t.name;if(o=a,ge.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(It(a));e=xe(a),s=ye(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function xe(t){return K(t)?t:t.split(".")}function ye(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(P(l)||ze(l)||Ct(l)))s.push(bt(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,P(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();P(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(P(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else K(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[i]=c}else if(P(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 We(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const r=new le({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Be)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=M.distance,ignoreLocation:i=M.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 Tt(t,e,s,{location:o=M.location,distance:r=M.distance,threshold:i=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,includeMatches:l=M.includeMatches,ignoreLocation:d=M.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=i,p=u;const x=c>1||l,y=x?Array(f):[];let j;for(;(j=t.indexOf(e,p))>-1;){let k=Q(e,{currentLocation:j,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(k,g),p=j+h,x){let I=0;for(;I=O;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(y[S]=+!!_),v[w]=(v[w+1]<<1|1)&_,k&&(v[w]|=(C[w+1]|C[w])<<1|1|C[w+1]),v[w]&G&&(b=Q(e,{errors:k,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;O=Math.max(1,2*u-p)}}if(Q(e,{errors:k+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;C=v}const F={isMatch:p>=0,score:Math.max(.001,b)};if(x){const k=function(I=[],L=M.minMatchCharLength){let O=[],E=-1,v=-1,w=0;for(let S=I.length;w=L&&O.push([E,v]),E=-1)}return I[w-1]&&w-E>=L&&O.push([E,w-1]),O}(y,c);k.length?l&&(F.indices=k):F.isMatch=!1}return F}function At(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:At(u),startIndex:g})},f=this.pattern.length;if(f>R){let u=0;const g=f%R,p=f-g;for(;u{const{isMatch:j,score:C,indices:b}=Tt(e,p,x,{location:r+y,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});j&&(u=!0),f+=C,j&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const ve=[];function we(t,e){for(let s=0,o=ve.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 Ft(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Lt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof le))throw new Error("Incorrect 'index' type");this._myIndex=s||We(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;f.matches.forEach(({key:g,norm:p,score:x})=>{const y=g?g.weight:null;u*=Math.pow(x===0&&y?Number.EPSILON:x,(y||1)*(h?1:p))}),f.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),ze(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Dt),u&&g.push(Ft),d.map(p=>{const{idx:x}=p,y={item:h[x],refIndex:x};return g.length&&g.forEach(j=>{j(p,y)}),y})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=we(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=we(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}}U.version="7.0.0",U.createIndex=We,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new le({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},U.config=M;function Pt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(Fe,{children:s.map(r=>n.jsx(ae,{children:n.jsx(T,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Ot={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function zt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=m.useState(!t.file_hash),[i,a]=m.useState();m.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,u,g;const d=await H.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,y=await(await fetch(p)).json();let j;if(await((f=V)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)j=(g=(u=y==null?void 0:y.images)==null?void 0:u[0])==null?void 0:g.url;else if(!y.model.nsfw){const A=y.images.find(G=>G.nsfw==="None");j=A==null?void 0:A.url}j&&s(j);const b={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:y.model.name,civitModelID:String(y.modelId),civitModelVersionID:String(y.id),imageUrl:j??null};H.models.put(b),a(b)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Ot[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(B,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(De,{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:(i==null?void 0:i.modelName)??t.model_name+t.model_extension})})]})}function Rt({list:t}){return n.jsx(mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Pe,{children:n.jsx(zt,{data:e})},e.model_name+e.date.getTime()))})}const Bt=async t=>{try{const s=await(await J.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 je(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function Me(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Wt(t,e=280,s){var o,r,i,a;if(t)return ke(t)?(i=Me((r=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:r.images,s))==null?void 0:i.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=Me(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Kt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=m.useState();m.useEffect(()=>{p();async function p(){var y;const x=await((y=V)==null?void 0:y.getSetting("showNsfwModelThumbnail"));r(Wt(t,ne,x))}},[t]);const i=ke(t)?t.modelVersions:t.versions,[a,c]=m.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=m.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(pe(l,t.name),t)},[a]),f=(g=pe(l))==null?void 0:g.sizeKB;return n.jsxs(Ie,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(De,{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(B,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(ot,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{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})}),f&&n.jsx(ie,{label:je(f),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:je(f)})})]})]})]})}function Gt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(B,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function $t({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=m.useState(""),[a,c]=m.useState([]),[l,d]=m.useState(""),h=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Le();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(He,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(_e,{children:n.jsxs(Ye,{children:[n.jsx(be,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Ce,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(Z,{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(ee,{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(qe,{children:[n.jsx(T,{ref:h,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function Vt(){const{colorMode:t}=Qe(),e=Ee(),[s,o]=m.useState([]);return m.useEffect(()=>{J.addEventListener("download_progress",r=>{o(r.detail)}),J.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(W,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(Oe,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>it(r),children:"Cancel"})]},r))})}const Ke="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function Ut(){return localStorage.getItem(Ke)}function Ht(t){localStorage.setItem(Ke,t)}function Yt(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:r}=Te(),i=()=>{Ht(t),o()};return n.jsxs(rt,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(at,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(lt,{p:5,children:[n.jsx(ct,{}),n.jsx(dt,{}),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(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function qt(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v5",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((c=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:c.at(0)).hits??[]}function Qt({onclose:t,searchQuery:e="",modelType:s}){const[o,r]=m.useState([]),[i,a]=m.useState(!1),[c,l]=m.useState(s),d=Ee(),[h,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:y}=Te(),[j,C,b]=Ae(),[A,G]=m.useState({}),[F,k]=m.useState(te),I=m.useCallback(async()=>{var _;a(!0);const v=await qt(u,c);r(v);const w=await Le();w&&G(w);const S=await((_=V)==null?void 0:_.getSetting("defaultFolders"));S&&k(S),a(!1)},[u,c]),L=(v,w)=>{var de,he,ue,fe;if(!((de=b.current)!=null&&de.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(he=b.current)==null?void 0:he.id}`,_=(ue=b.current)==null?void 0:ue.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&f(Ge=>[...Ge,_??""]);const ce=Ut();ce&&(S+=`?token=${ce}`),Bt({file_hash:(fe=b.current)==null?void 0:fe.SHA256,filename:_,save_path:v,url:S}),C(void 0),y()},O=async(v,w)=>{const S=F[w.type];C(v),S==null?x():L(S)},E=async(v,w)=>{var _;const S={...F,[v]:w};await((_=V)==null?void 0:_.upsert({defaultFolders:S})),k(S)};return m.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(Je,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(_e,{}),n.jsxs(Xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(be,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Gt,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(Yt,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(v=>n.jsx(T,{size:"sm",py:1,isActive:c===v,onClick:()=>{l(v)},children:v},v)),c&&A[te[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:F[c],onChange:v=>E(c,v.target.value),children:A[te[c]].map(v=>n.jsx("option",{value:v,children:v}))})]})]}),i&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(Ze,{}),n.jsxs(Ce,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(v=>n.jsx(Kt,{model:v,onClickInstallModel:O,installing:h},v.id))}),n.jsx(Vt,{})]})]})]}),n.jsx($t,{fileSelected:!!j,isOpen:p,onClose:y,selectFolder:(v,w)=>{L(v,b.current?void 0:w)}})]})}function Jt(){const[t,e]=m.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>e(!0),children:"Install Models"}),t&&n.jsx(Qt,{modelType:"Checkpoint",onclose:()=>e(!1)})]})}const Xt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{a(),J.addEventListener("model_list",l=>{c(l.detail)})},[]);const a=async()=>{const l=await ut();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Zt(){const[t,e,s]=Ae(!1),o=()=>{var c;(c=V)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{o()},[]);const r=c=>{var d;const l=c.target.checked;(d=V)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const c=await H.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,u=await(await fetch(h)).json();let g;if(s.current)g=(d=(l=u==null?void 0:u.images)==null?void 0:l[0])==null?void 0:d.url;else if(!u.model.nsfw){const p=u.images.find(x=>x.nsfw==="None");g=p==null?void 0:p.url}H.models.update(c.id,{imageUrl:g??null})}catch{}};return n.jsx(gt,{isChecked:t,onChange:r,children:"Show NSFW"})}function es(){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]}),z.graph.add(i)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function ts({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,r]=m.useState(""),[i,a]=m.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=Xt(),[h,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const y=await H.models.toArray();f(d.map(j=>({...j,db:y.find(C=>C.id===j.model_name+"@"+j.model_type)})))}},[d]),m.useEffect(()=>{let x=[];o.length?x=new U(h,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=d.filter(y=>y.model_type===e).sort((y,j)=>i==="name"?y.model_name.localeCompare(j.model_name):j.date.getTime()-y.date.getTime()),g(x)},[e,d,o,i,h]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(et,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ie,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ft,overflowY:"auto",children:[n.jsxs(B,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{})]}),n.jsx(B,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(B,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value: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(Zt,{})]}),!o.length&&n.jsx(Pt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Rt,{list:u}),c&&n.jsx(B,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(es,{})]})})}const ss=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-g1lfodpY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function ns(){const{setRoute:t,route:e}=m.useContext(pt),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const i=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),c=LiteGraph.createNode(a);c.pos=[o.canvasX,o.canvasY],c.configure({widgets_values:[i]}),z.graph.add(c)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(ss,{})}),e==="modelList"&&n.jsx(ts,{onClose:()=>t("root")})]})}const ds=Object.freeze(Object.defineProperty({__proto__:null,default:ns},Symbol.toStringTag,{value:"Module"}));export{Pe as G,Jt as I,ds as M,qt as g}; +import{f as Y,r as m,j as n,g as $,e as Se,a4 as X,b as $e,o as Ve,k as Ue,h as T,a9 as re,af as He,N as _e,ag as Ye,Q as be,S as Ce,T as qe,Z as Qe,M as Je,O as Xe,R as Ze,P as et,_ as tt}from"./input.js";import{au as st,ao as nt,av as H,o as V,B as oe,F as B,l as D,m as ie,aw as ke,ax as pe,ad as Ie,k as q,z as ot,H as W,n as Z,ay as Le,j as Ee,az as it,aA as Te,a0 as rt,a1 as at,a2 as lt,a3 as ct,a4 as dt,aB as Ae,aC as te,an as Ne,aD as ht,aE as ut,ae as ft,a6 as pt}from"./App-sgH6j00M.js";import{I as De,G as mt,C as gt}from"./chunk-JARCRF6W-swAlFRrB.js";import{app as z}from"/scripts/app.js";import{api as J}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-hQn4Wngd.js";var Fe=Y(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(ae,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",h),...u,children:n.jsx($.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})})});Fe.displayName="Wrap";var ae=Y(function(e,s){const{className:o,...r}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...r})});ae.displayName="WrapItem";function me(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Pe=Y(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=st({gridArea:o,gridColumn:me(r),gridRow:me(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx($.div,{ref:s,__css:f,...h})});Pe.displayName="GridItem";function xt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var yt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),vt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function wt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=xt(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[jt,Mt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),St=Y((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=wt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Mt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),Oe=Y((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":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...y}=Ve(t),j=Ue("Progress",t),C=d??((s=j.track)==null?void 0:s.borderRadius),b={animation:`${vt} 1s linear infinite`},F={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${yt} 1s ease infinite normal none running`}},k={overflow:"hidden",position:"relative",...j.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:k,...y,children:n.jsxs(jt,{value:j,children:[n.jsx(St,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:F,borderRadius:C,title:p,role:x}),l]})})});Oe.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const _t=1/0;function bt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-_t?"-0":s}(t)}function P(t){return typeof t=="string"}function ze(t){return typeof t=="number"}function Ct(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kt=t=>`Missing ${t} property in key`,It=t=>`Property 'weight' in key '${t}' must be a positive integer`,ge=Object.prototype.hasOwnProperty;class Lt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Be(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 Be(t){let e=null,s=null,o=null,r=1,i=null;if(P(t)||K(t))o=t,e=xe(t),s=ye(t);else{if(!ge.call(t,"name"))throw new Error(kt("name"));const a=t.name;if(o=a,ge.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(It(a));e=xe(a),s=ye(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function xe(t){return K(t)?t:t.split(".")}function ye(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(P(l)||ze(l)||Ct(l)))s.push(bt(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,P(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();P(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(P(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else K(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[i]=c}else if(P(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 We(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const r=new le({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Be)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=M.distance,ignoreLocation:i=M.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 Tt(t,e,s,{location:o=M.location,distance:r=M.distance,threshold:i=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,includeMatches:l=M.includeMatches,ignoreLocation:d=M.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=i,p=u;const x=c>1||l,y=x?Array(f):[];let j;for(;(j=t.indexOf(e,p))>-1;){let k=Q(e,{currentLocation:j,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(k,g),p=j+h,x){let I=0;for(;I=O;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(y[S]=+!!_),v[w]=(v[w+1]<<1|1)&_,k&&(v[w]|=(C[w+1]|C[w])<<1|1|C[w+1]),v[w]&G&&(b=Q(e,{errors:k,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;O=Math.max(1,2*u-p)}}if(Q(e,{errors:k+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;C=v}const F={isMatch:p>=0,score:Math.max(.001,b)};if(x){const k=function(I=[],L=M.minMatchCharLength){let O=[],E=-1,v=-1,w=0;for(let S=I.length;w=L&&O.push([E,v]),E=-1)}return I[w-1]&&w-E>=L&&O.push([E,w-1]),O}(y,c);k.length?l&&(F.indices=k):F.isMatch=!1}return F}function At(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:At(u),startIndex:g})},f=this.pattern.length;if(f>R){let u=0;const g=f%R,p=f-g;for(;u{const{isMatch:j,score:C,indices:b}=Tt(e,p,x,{location:r+y,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});j&&(u=!0),f+=C,j&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const ve=[];function we(t,e){for(let s=0,o=ve.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 Ft(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Lt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof le))throw new Error("Incorrect 'index' type");this._myIndex=s||We(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;f.matches.forEach(({key:g,norm:p,score:x})=>{const y=g?g.weight:null;u*=Math.pow(x===0&&y?Number.EPSILON:x,(y||1)*(h?1:p))}),f.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),ze(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Dt),u&&g.push(Ft),d.map(p=>{const{idx:x}=p,y={item:h[x],refIndex:x};return g.length&&g.forEach(j=>{j(p,y)}),y})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=we(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=we(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}}U.version="7.0.0",U.createIndex=We,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new le({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},U.config=M;function Pt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(Fe,{children:s.map(r=>n.jsx(ae,{children:n.jsx(T,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Ot={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function zt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=m.useState(!t.file_hash),[i,a]=m.useState();m.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,u,g;const d=await H.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,y=await(await fetch(p)).json();let j;if(await((f=V)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)j=(g=(u=y==null?void 0:y.images)==null?void 0:u[0])==null?void 0:g.url;else if(!y.model.nsfw){const A=y.images.find(G=>G.nsfw==="None");j=A==null?void 0:A.url}j&&s(j);const b={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:y.model.name,civitModelID:String(y.modelId),civitModelVersionID:String(y.id),imageUrl:j??null};H.models.put(b),a(b)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Ot[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(B,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(De,{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:(i==null?void 0:i.modelName)??t.model_name+t.model_extension})})]})}function Rt({list:t}){return n.jsx(mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Pe,{children:n.jsx(zt,{data:e})},e.model_name+e.date.getTime()))})}const Bt=async t=>{try{const s=await(await J.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 je(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function Me(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Wt(t,e=280,s){var o,r,i,a;if(t)return ke(t)?(i=Me((r=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:r.images,s))==null?void 0:i.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=Me(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Kt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=m.useState();m.useEffect(()=>{p();async function p(){var y;const x=await((y=V)==null?void 0:y.getSetting("showNsfwModelThumbnail"));r(Wt(t,ne,x))}},[t]);const i=ke(t)?t.modelVersions:t.versions,[a,c]=m.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=m.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(pe(l,t.name),t)},[a]),f=(g=pe(l))==null?void 0:g.sizeKB;return n.jsxs(Ie,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(De,{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(B,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(ot,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{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})}),f&&n.jsx(ie,{label:je(f),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:je(f)})})]})]})]})}function Gt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(B,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function $t({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=m.useState(""),[a,c]=m.useState([]),[l,d]=m.useState(""),h=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Le();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(He,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(_e,{children:n.jsxs(Ye,{children:[n.jsx(be,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Ce,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(Z,{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(ee,{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(qe,{children:[n.jsx(T,{ref:h,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function Vt(){const{colorMode:t}=Qe(),e=Ee(),[s,o]=m.useState([]);return m.useEffect(()=>{J.addEventListener("download_progress",r=>{o(r.detail)}),J.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(W,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(Oe,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>it(r),children:"Cancel"})]},r))})}const Ke="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function Ut(){return localStorage.getItem(Ke)}function Ht(t){localStorage.setItem(Ke,t)}function Yt(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:r}=Te(),i=()=>{Ht(t),o()};return n.jsxs(rt,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(at,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(lt,{p:5,children:[n.jsx(ct,{}),n.jsx(dt,{}),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(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function qt(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((c=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:c.at(0)).hits??[]}function Qt({onclose:t,searchQuery:e="",modelType:s}){const[o,r]=m.useState([]),[i,a]=m.useState(!1),[c,l]=m.useState(s),d=Ee(),[h,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:y}=Te(),[j,C,b]=Ae(),[A,G]=m.useState({}),[F,k]=m.useState(te),I=m.useCallback(async()=>{var _;a(!0);const v=await qt(u,c);r(v);const w=await Le();w&&G(w);const S=await((_=V)==null?void 0:_.getSetting("defaultFolders"));S&&k(S),a(!1)},[u,c]),L=(v,w)=>{var de,he,ue,fe;if(!((de=b.current)!=null&&de.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(he=b.current)==null?void 0:he.id}`,_=(ue=b.current)==null?void 0:ue.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&f(Ge=>[...Ge,_??""]);const ce=Ut();ce&&(S+=`?token=${ce}`),Bt({file_hash:(fe=b.current)==null?void 0:fe.SHA256,filename:_,save_path:v,url:S}),C(void 0),y()},O=async(v,w)=>{const S=F[w.type];C(v),S==null?x():L(S)},E=async(v,w)=>{var _;const S={...F,[v]:w};await((_=V)==null?void 0:_.upsert({defaultFolders:S})),k(S)};return m.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(Je,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(_e,{}),n.jsxs(Xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(be,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Gt,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(Yt,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(v=>n.jsx(T,{size:"sm",py:1,isActive:c===v,onClick:()=>{l(v)},children:v},v)),c&&A[te[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:F[c],onChange:v=>E(c,v.target.value),children:A[te[c]].map(v=>n.jsx("option",{value:v,children:v}))})]})]}),i&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(Ze,{}),n.jsxs(Ce,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(v=>n.jsx(Kt,{model:v,onClickInstallModel:O,installing:h},v.id))}),n.jsx(Vt,{})]})]})]}),n.jsx($t,{fileSelected:!!j,isOpen:p,onClose:y,selectFolder:(v,w)=>{L(v,b.current?void 0:w)}})]})}function Jt(){const[t,e]=m.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>e(!0),children:"Install Models"}),t&&n.jsx(Qt,{modelType:"Checkpoint",onclose:()=>e(!1)})]})}const Xt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{a(),J.addEventListener("model_list",l=>{c(l.detail)})},[]);const a=async()=>{const l=await ut();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Zt(){const[t,e,s]=Ae(!1),o=()=>{var c;(c=V)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{o()},[]);const r=c=>{var d;const l=c.target.checked;(d=V)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const c=await H.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,u=await(await fetch(h)).json();let g;if(s.current)g=(d=(l=u==null?void 0:u.images)==null?void 0:l[0])==null?void 0:d.url;else if(!u.model.nsfw){const p=u.images.find(x=>x.nsfw==="None");g=p==null?void 0:p.url}H.models.update(c.id,{imageUrl:g??null})}catch{}};return n.jsx(gt,{isChecked:t,onChange:r,children:"Show NSFW"})}function es(){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]}),z.graph.add(i)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function ts({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,r]=m.useState(""),[i,a]=m.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=Xt(),[h,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const y=await H.models.toArray();f(d.map(j=>({...j,db:y.find(C=>C.id===j.model_name+"@"+j.model_type)})))}},[d]),m.useEffect(()=>{let x=[];o.length?x=new U(h,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=d.filter(y=>y.model_type===e).sort((y,j)=>i==="name"?y.model_name.localeCompare(j.model_name):j.date.getTime()-y.date.getTime()),g(x)},[e,d,o,i,h]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(et,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ie,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ft,overflowY:"auto",children:[n.jsxs(B,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{})]}),n.jsx(B,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(B,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value: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(Zt,{})]}),!o.length&&n.jsx(Pt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Rt,{list:u}),c&&n.jsx(B,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(es,{})]})})}const ss=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-sP7CX4K3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function ns(){const{setRoute:t,route:e}=m.useContext(pt),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const i=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),c=LiteGraph.createNode(a);c.pos=[o.canvasX,o.canvasY],c.configure({widgets_values:[i]}),z.graph.add(c)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(ss,{})}),e==="modelList"&&n.jsx(ts,{onClose:()=>t("root")})]})}const ds=Object.freeze(Object.defineProperty({__proto__:null,default:ns},Symbol.toStringTag,{value:"Module"}));export{Pe as G,Jt as I,ds as M,qt as g}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-g1lfodpY.js","workspace_web/input.js","workspace_web/App-bqAziDgv.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js","workspace_web/chunk-JARCRF6W-fNDfXRta.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-ajfTuIGC.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-sP7CX4K3.js","workspace_web/input.js","workspace_web/App-sgH6j00M.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-4zMWD2m4.js","workspace_web/chunk-JARCRF6W-swAlFRrB.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-hQn4Wngd.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js b/dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js similarity index 99% rename from dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js rename to dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js index 9537555..7dfc5e8 100644 --- a/dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js +++ b/dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js @@ -1,4 +1,4 @@ -import{f as Oe,n as fn,o as pa,j as c,g as be,e as Ie,Y as ha,r as v,E as Ke,w as pn,M as qe,N as Xe,O as Ze,Q as Je,R as Qe,S as et,V as xt,h as ee,Z as yt,T as ma,$ as je,a0 as va,a1 as ga,a2 as ba,a3 as hn,a4 as Sa,a5 as P,a6 as E,a7 as xa,a8 as mn,X as F,k as ge,a9 as ya,I as Ct,aa as Rt}from"./input.js";import{b as Ca,a as wa,u as vn,c as Oa,d as Ia,e as Ma,S as ka,M as gn,f as Pa,g as ja,h as q,H as K,T as bn,I as Z,t as Se,i as Sn,j as wt,E as Tt,k as de,l as J,m as ne,n as tt,o as U,R as pe,p as Da,q as Nt,B as z,F as Ce,r as $t,s as Va,v as Ea,w as Me,x as Ve,y as te,z as Fa,D as xn,A as G,C as yn,G as La,J as Ot,K as Ra,L as Cn,N as Ta,O as fe,P as Na,Q as $a,U as za,V as It,W as Aa,X as _a,Y as Ha,Z as xe,_ as dt,$ as Ba,a0 as Wa,a1 as Ua,a2 as Ga,a3 as Ya,a4 as Ka,a5 as qa,a6 as Mt,a7 as wn,a8 as Xa,a9 as Za,aa as Ja,ab as Qa,ac as zt,ad as er,ae as tr,af as nr,ag as at,ah as ar}from"./App-bqAziDgv.js";import{C as Ee}from"./chunk-JARCRF6W-fNDfXRta.js";import{V as On}from"./chunk-NTCQBYKE-ZJqEVTS0.js";import{S as rr,N as ir,a as or,I as sr,M as lr,b as cr}from"./MediaPreview-cVvL6fHO.js";import{app as Re}from"/scripts/app.js";import{I as ur}from"./IconCopy-Vm3ws_0T.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var In=Oe(function(e,a){const{borderLeftWidth:r,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:s,borderWidth:o,borderStyle:l,borderColor:u,...d}=fn("Divider",e),{className:f,orientation:h="horizontal",__css:p,...m}=pa(e),b={vertical:{borderLeftWidth:r||s||o||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||o||"1px",width:"100%"}};return c.jsx(be.hr,{ref:a,"aria-orientation":h,...m,__css:{...d,border:"0",borderColor:u,borderStyle:l,...b[h],...p},className:Ie("chakra-divider",f)})});In.displayName="Divider";function dr(n,e={}){const{ssr:a=!0,fallback:r}=e,{getWindow:t}=ha(),i=Array.isArray(n)?n:[n];let s=Array.isArray(r)?r:[r];s=s.filter(u=>u!=null);const[o,l]=v.useState(()=>i.map((u,d)=>({media:u,matches:a?!!s[d]:t().matchMedia(u).matches})));return v.useEffect(()=>{const u=t();l(i.map(h=>({media:h,matches:u.matchMedia(h).matches})));const d=i.map(h=>u.matchMedia(h)),f=h=>{l(p=>p.slice().map(m=>m.media===h.media?{...m,matches:h.matches}:m))};return d.forEach(h=>{typeof h.addListener=="function"?h.addListener(f):h.addEventListener("change",f)}),()=>{d.forEach(h=>{typeof h.removeListener=="function"?h.removeListener(f):h.removeEventListener("change",f)})}},[t]),o.map(u=>u.matches)}function fr(n,e,a=Ca){let r=Object.keys(n).indexOf(e);if(r!==-1)return n[e];let t=a.indexOf(e);for(;t>=0;){const i=a[t];if(n.hasOwnProperty(i)){r=t;break}t-=1}if(r!==-1){const i=a[r];return n[i]}}function pr(n){var e,a;const r=pn(n)?n:{fallback:n??"base"},i=Ke().__breakpoints.details.map(({minMaxQuery:u,breakpoint:d})=>({breakpoint:d,query:u.replace("@media screen and ","")})),s=i.map(u=>u.breakpoint===r.fallback),l=dr(i.map(u=>u.query),{fallback:s,ssr:r.ssr}).findIndex(u=>u==!0);return(a=(e=i[l])==null?void 0:e.breakpoint)!=null?a:r.fallback}function hr(n,e){var a;const r=pn(e)?e:{fallback:e??"base"},t=pr(r),i=Ke();if(!t)return;const s=Array.from(((a=i.__breakpoints)==null?void 0:a.keys)||[]),o=Array.isArray(n)?Object.fromEntries(Object.entries(wa(n,s)).map(([l,u])=>[l,u])):n;return fr(o,t,s)}var Mn=Oe((n,e)=>{const{title:a,children:r,className:t,...i}=n,s=Ie("chakra-menu__group__title",t),o=vn();return c.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[a&&c.jsx(be.p,{className:s,...i,__css:o.groupTitle,children:a}),r]})});Mn.displayName="MenuGroup";var kn=n=>{const{className:e,title:a,...r}=n,t=Oa(r);return c.jsx(Mn,{title:a,className:Ie("chakra-menu__option-group",e),...t})};kn.displayName="MenuOptionGroup";var mr=Oe((n,e)=>{const a=vn();return c.jsx(be.button,{ref:e,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...a.button}})}),Fe=Oe((n,e)=>{const{children:a,as:r,...t}=n,i=Ia(t,e),s=r||mr;return c.jsx(s,{...i,className:Ie("chakra-menu__menu-button",n.className),children:c.jsx(be.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});Fe.displayName="MenuButton";var vr=n=>c.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:c.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"})}),kt=Oe((n,e)=>{const{icon:a,iconSpacing:r="0.75rem",...t}=n,i=Ma(t,e);return c.jsxs(ka,{...i,className:Ie("chakra-menu__menuitem-option",t.className),children:[a!==null&&c.jsx(gn,{fontSize:"0.8em",marginEnd:r,opacity:n.isChecked?1:0,children:a||c.jsx(vr,{})}),c.jsx("span",{style:{flex:1},children:i.children})]})});kt.id="MenuItemOption";kt.displayName="MenuItemOption";var Pn=Oe(function(e,a){const{getHeaderProps:r}=Pa(),t=ja();return c.jsx(be.header,{...r(e,a),className:Ie("chakra-popover__header",e.className),__css:t.header})});Pn.displayName="PopoverHeader";var gr=q("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),br=q("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"}]]),Sr=q("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"}]]),At=q("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"}]]),xr=q("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"}]]),jn=q("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"}]]),yr=q("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"}]]),Cr=q("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"}]]),wr=q("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"}]]),Or=q("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"}]]),Ir=q("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"}]]),Mr=q("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"}]]),kr=q("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"}]]),Dn=q("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Pr=q("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 jr({onclose:n}){const[e,a]=v.useState([]),r=async()=>{var i;const t=await((i=Se)==null?void 0:i.listAll());a(t??[])};return v.useEffect(()=>{r()},[]),c.jsxs(qe,{isOpen:!0,onClose:n,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"My Tags"}),c.jsx(Qe,{}),c.jsx(et,{children:e.map(t=>c.jsxs(K,{children:[c.jsx(bn,{children:t.name}),c.jsx(Z,{onClick:async()=>{var i;await((i=Se)==null?void 0:i.delete(t.name)),r()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:c.jsx(Sn,{})})]}))})]})]})}function Dr(){const n=wt(),e=v.useRef([{title:"Save current workflow",key:Tt.SAVE},{title:"Save as current workflow",key:Tt.SAVE_AS}]),[a,r]=v.useState({save:"",saveAs:""}),[t,i]=v.useState(),s=async(l,u)=>{var f;l.preventDefault();let d="";if(l.ctrlKey&&(d+="Control+"),l.metaKey&&(d+="Command+"),l.shiftKey&&(d+="Shift+"),l.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt"].includes(l.key)){d+=l.key.toUpperCase();const h={...a};delete h[u],Object.values(h).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please +import{f as Oe,n as fn,o as pa,j as c,g as be,e as Ie,Y as ha,r as v,E as Ke,w as pn,M as qe,N as Xe,O as Ze,Q as Je,R as Qe,S as et,V as xt,h as ee,Z as yt,T as ma,$ as je,a0 as va,a1 as ga,a2 as ba,a3 as hn,a4 as Sa,a5 as P,a6 as E,a7 as xa,a8 as mn,X as F,k as ge,a9 as ya,I as Ct,aa as Rt}from"./input.js";import{b as Ca,a as wa,u as vn,c as Oa,d as Ia,e as Ma,S as ka,M as gn,f as Pa,g as ja,h as q,H as K,T as bn,I as Z,t as Se,i as Sn,j as wt,E as Tt,k as de,l as J,m as ne,n as tt,o as U,R as pe,p as Da,q as Nt,B as z,F as Ce,r as $t,s as Va,v as Ea,w as Me,x as Ve,y as te,z as Fa,D as xn,A as G,C as yn,G as La,J as Ot,K as Ra,L as Cn,N as Ta,O as fe,P as Na,Q as $a,U as za,V as It,W as Aa,X as _a,Y as Ha,Z as xe,_ as dt,$ as Ba,a0 as Wa,a1 as Ua,a2 as Ga,a3 as Ya,a4 as Ka,a5 as qa,a6 as Mt,a7 as wn,a8 as Xa,a9 as Za,aa as Ja,ab as Qa,ac as zt,ad as er,ae as tr,af as nr,ag as at,ah as ar}from"./App-sgH6j00M.js";import{C as Ee}from"./chunk-JARCRF6W-swAlFRrB.js";import{V as On}from"./chunk-NTCQBYKE-4zMWD2m4.js";import{S as rr,N as ir,a as or,I as sr,M as lr,b as cr}from"./MediaPreview-_sS52WD-.js";import{app as Re}from"/scripts/app.js";import{I as ur}from"./IconCopy-Hs60LgD8.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var In=Oe(function(e,a){const{borderLeftWidth:r,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:s,borderWidth:o,borderStyle:l,borderColor:u,...d}=fn("Divider",e),{className:f,orientation:h="horizontal",__css:p,...m}=pa(e),b={vertical:{borderLeftWidth:r||s||o||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||o||"1px",width:"100%"}};return c.jsx(be.hr,{ref:a,"aria-orientation":h,...m,__css:{...d,border:"0",borderColor:u,borderStyle:l,...b[h],...p},className:Ie("chakra-divider",f)})});In.displayName="Divider";function dr(n,e={}){const{ssr:a=!0,fallback:r}=e,{getWindow:t}=ha(),i=Array.isArray(n)?n:[n];let s=Array.isArray(r)?r:[r];s=s.filter(u=>u!=null);const[o,l]=v.useState(()=>i.map((u,d)=>({media:u,matches:a?!!s[d]:t().matchMedia(u).matches})));return v.useEffect(()=>{const u=t();l(i.map(h=>({media:h,matches:u.matchMedia(h).matches})));const d=i.map(h=>u.matchMedia(h)),f=h=>{l(p=>p.slice().map(m=>m.media===h.media?{...m,matches:h.matches}:m))};return d.forEach(h=>{typeof h.addListener=="function"?h.addListener(f):h.addEventListener("change",f)}),()=>{d.forEach(h=>{typeof h.removeListener=="function"?h.removeListener(f):h.removeEventListener("change",f)})}},[t]),o.map(u=>u.matches)}function fr(n,e,a=Ca){let r=Object.keys(n).indexOf(e);if(r!==-1)return n[e];let t=a.indexOf(e);for(;t>=0;){const i=a[t];if(n.hasOwnProperty(i)){r=t;break}t-=1}if(r!==-1){const i=a[r];return n[i]}}function pr(n){var e,a;const r=pn(n)?n:{fallback:n??"base"},i=Ke().__breakpoints.details.map(({minMaxQuery:u,breakpoint:d})=>({breakpoint:d,query:u.replace("@media screen and ","")})),s=i.map(u=>u.breakpoint===r.fallback),l=dr(i.map(u=>u.query),{fallback:s,ssr:r.ssr}).findIndex(u=>u==!0);return(a=(e=i[l])==null?void 0:e.breakpoint)!=null?a:r.fallback}function hr(n,e){var a;const r=pn(e)?e:{fallback:e??"base"},t=pr(r),i=Ke();if(!t)return;const s=Array.from(((a=i.__breakpoints)==null?void 0:a.keys)||[]),o=Array.isArray(n)?Object.fromEntries(Object.entries(wa(n,s)).map(([l,u])=>[l,u])):n;return fr(o,t,s)}var Mn=Oe((n,e)=>{const{title:a,children:r,className:t,...i}=n,s=Ie("chakra-menu__group__title",t),o=vn();return c.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[a&&c.jsx(be.p,{className:s,...i,__css:o.groupTitle,children:a}),r]})});Mn.displayName="MenuGroup";var kn=n=>{const{className:e,title:a,...r}=n,t=Oa(r);return c.jsx(Mn,{title:a,className:Ie("chakra-menu__option-group",e),...t})};kn.displayName="MenuOptionGroup";var mr=Oe((n,e)=>{const a=vn();return c.jsx(be.button,{ref:e,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...a.button}})}),Fe=Oe((n,e)=>{const{children:a,as:r,...t}=n,i=Ia(t,e),s=r||mr;return c.jsx(s,{...i,className:Ie("chakra-menu__menu-button",n.className),children:c.jsx(be.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});Fe.displayName="MenuButton";var vr=n=>c.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:c.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"})}),kt=Oe((n,e)=>{const{icon:a,iconSpacing:r="0.75rem",...t}=n,i=Ma(t,e);return c.jsxs(ka,{...i,className:Ie("chakra-menu__menuitem-option",t.className),children:[a!==null&&c.jsx(gn,{fontSize:"0.8em",marginEnd:r,opacity:n.isChecked?1:0,children:a||c.jsx(vr,{})}),c.jsx("span",{style:{flex:1},children:i.children})]})});kt.id="MenuItemOption";kt.displayName="MenuItemOption";var Pn=Oe(function(e,a){const{getHeaderProps:r}=Pa(),t=ja();return c.jsx(be.header,{...r(e,a),className:Ie("chakra-popover__header",e.className),__css:t.header})});Pn.displayName="PopoverHeader";var gr=q("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),br=q("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"}]]),Sr=q("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"}]]),At=q("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"}]]),xr=q("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"}]]),jn=q("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"}]]),yr=q("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"}]]),Cr=q("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"}]]),wr=q("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"}]]),Or=q("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"}]]),Ir=q("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"}]]),Mr=q("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"}]]),kr=q("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"}]]),Dn=q("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Pr=q("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 jr({onclose:n}){const[e,a]=v.useState([]),r=async()=>{var i;const t=await((i=Se)==null?void 0:i.listAll());a(t??[])};return v.useEffect(()=>{r()},[]),c.jsxs(qe,{isOpen:!0,onClose:n,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"My Tags"}),c.jsx(Qe,{}),c.jsx(et,{children:e.map(t=>c.jsxs(K,{children:[c.jsx(bn,{children:t.name}),c.jsx(Z,{onClick:async()=>{var i;await((i=Se)==null?void 0:i.delete(t.name)),r()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:c.jsx(Sn,{})})]}))})]})]})}function Dr(){const n=wt(),e=v.useRef([{title:"Save current workflow",key:Tt.SAVE},{title:"Save as current workflow",key:Tt.SAVE_AS}]),[a,r]=v.useState({save:"",saveAs:""}),[t,i]=v.useState(),s=async(l,u)=>{var f;l.preventDefault();let d="";if(l.ctrlKey&&(d+="Control+"),l.metaKey&&(d+="Command+"),l.shiftKey&&(d+="Shift+"),l.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt"].includes(l.key)){d+=l.key.toUpperCase();const h={...a};delete h[u],Object.values(h).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((f=U)==null?void 0:f.upsert({shortcuts:{...a,[u]:d}})),o())}},o=()=>{var l;(l=U)==null||l.getSetting("shortcuts").then(u=>{var f;const d=u??((f=U)==null?void 0:f.defaultSettings.shortcuts);r({...a,...d})})};return v.useEffect(()=>{o()},[]),c.jsxs(de,{children:[c.jsx(J,{children:"Keyboard Shortcut"}),e.current.map(l=>c.jsxs(K,{children:[c.jsx(J,{fontSize:"sm",w:170,children:l.title}),c.jsx(ne,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:t===l.key,children:c.jsx(tt,{value:a[l.key],onKeyDown:u=>{s(u,l.key)},onFocus:()=>{i(l.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},l.key))]})}function Vr(){const{setRefreshFolderStamp:n}=v.useContext(pe),[e,a]=v.useState(!1),r=()=>{var i;(i=U)==null||i.getSetting("foldersOnTop").then(s=>{a(!!s)})},t=i=>{var o;const s=i.target.checked;(o=U)==null||o.upsert({foldersOnTop:s}).then(()=>{r(),n(Date.now())})};return v.useEffect(()=>{r()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:e,onChange:t,children:"Folders always on top"})})}function Er(){const[n,e]=v.useState(!1),[a,r]=v.useState(""),{showDialog:t}=xt(),i=()=>{var o,l;(o=U)==null||o.getSetting("myWorkflowsDir").then(u=>{r(u??"undefined")}),(l=U)==null||l.getSetting("twoWaySync").then(u=>{e(u??!1)})};v.useEffect(()=>{i()},[]);const s=async o=>{var u,d;if(!o.target.checked){await((u=U)==null?void 0:u.upsert({twoWaySync:o.target.checked})),i();return}const l=await((d=U)==null?void 0:d.getSetting("myWorkflowsDir"));t(c.jsx(Da,{myWorkflowsDir:l??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var f;await((f=U)==null?void 0:f.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return c.jsxs(de,{children:[c.jsx(J,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),c.jsx(Ee,{isChecked:n,onChange:s,children:"Enable two way sync"})]})}function _t({settingKey:n,text:e,defaultChecked:a=!1}){const[r,t]=v.useState(a),i=()=>{var s;(s=U)==null||s.getSetting(n).then(o=>{t(!!o)})};return v.useEffect(()=>{i()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:r,onChange:async s=>{var o;await((o=U)==null?void 0:o.upsert({[n]:s.target.checked})),i()},children:e})})}function Fr(){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),[t,i]=v.useState([]),[s,o]=v.useState(""),[l,u]=v.useState([]),[d,f]=v.useState(!1),[h,p]=v.useState(!1),[m,b]=v.useState(!1),g=v.useRef(null),S=wt(),{showDialog:w}=xt(),y=m?"\\":"/";v.useEffect(()=>{var D;Nt().then(O=>{o(O.path??""),b(O.os==="win32")}),(D=U)==null||D.getSetting("twoWaySync").then(O=>{f(O??!1)})},[]);const x=async D=>{const{dir_path:O="",dir_contents:L=[],error:_=""}=await $t(D??"");return _.includes("Operation not permitted")?(p(!0),C(),{isError:!0}):{dirList:L,dirPath:O}},j=async()=>{const{isError:D=!1,dirList:O=[]}=await x(s);D||(i(O),r(!0),u(s&&s.split(y).filter(L=>!!L)||[]))},C=()=>{r(!1),e(!1),u([])},V=async(D,O=!1,L=!1)=>{var I,R;if(O){const{path:N}=await Nt();N&&await Va(N,D)}await((I=U)==null?void 0:I.upsert({myWorkflowsDir:D}));const _=await((R=U)==null?void 0:R.getSetting("myWorkflowsDir"))??"";o(_),L&&p(!1),C()},M=async D=>{if(D){const{error:L=""}=await $t(D);if(L.includes("Not a directory")){S({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const O=D??`${m?"":y}${l.join(y)}`;w("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{V(O,!0,!!D)}},{label:"No",onClick:()=>{V(O,!1,!!D)}}])},T=async()=>{const{dirPath:D,dirList:O}=await x("");u(D.split(y).filter(L=>!!L)),i(O)},A=async(D,O)=>{var R;let L="";D===-1&&O?L=`${m?"":y}${l.concat([O]).join(y)}`:L=`${m?"":y}${l.slice(0,D+1).join(y)}`;const{isError:_=!1,dirList:I=[]}=await x(L);_||(i(I),u(m?L.split(y):(R=L.slice(1))==null?void 0:R.split(y)))},W=c.jsxs(z,{textAlign:"end",mb:4,children:[c.jsx(tt,{placeholder:"Please enter the absolute path directory address",ref:g,mt:2,mb:2}),c.jsx(ee,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var D,O;(D=g==null?void 0:g.current)!=null&&D.value&&M((O=g==null?void 0:g.current)==null?void 0:O.value)},children:"Save"})]}),H=()=>{r(!0),e(!0)};return c.jsxs(c.Fragment,{children:[c.jsxs(z,{mb:4,children:[c.jsx(J,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),a?n?W:c.jsxs(On,{spacing:2,alignItems:"start",children:[c.jsx(de,{spacing:"2px",direction:"row",wrap:"wrap",children:l.map((D,O)=>c.jsxs("span",{children:[O>0&&y,c.jsx(ee,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{A(O)},children:D},`${D}-${O}`)]},D))}),c.jsx(rr,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:t.map((D,O)=>c.jsx(ee,{size:"sm",leftIcon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.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:()=>{A(-1,D)},children:D},`${D}-${O}`))}),c.jsxs(z,{w:"100%",textAlign:"end",children:[c.jsx(ee,{colorScheme:"teal",size:"sm",onClick:()=>{M()},children:"Save"}),c.jsx(ee,{size:"sm",onClick:T,mr:2,ml:2,children:"Reset"}),c.jsx(ee,{size:"sm",onClick:C,children:"Cancel"})]})]}):c.jsxs(Ce,{children:[c.jsx(bn,{overflowWrap:"anywhere",children:s}),c.jsx(ne,{label:d?"Choose folder":"Enable two way sync to link local folder",children:c.jsx(Z,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:c.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})}),c.jsx(ne,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:c.jsx(Z,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:c.jsx(Sr,{size:19}),onClick:H,variant:"ghost"})})]})]}),c.jsxs(qe,{isOpen:h,onClose:()=>p(!1),size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Kind tips"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(z,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?c.jsxs(J,{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",c.jsx(ee,{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."]}):c.jsx(J,{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."}),W]})})]})]})]})}function Lr(){const[n,e]=v.useState(200),a=i=>{if(!i.length){e(0);return}e(parseInt(i))},r=async()=>{var i;n<0&&e(0),await((i=U)==null?void 0:i.upsert({maximumChangelogNumber:Number(n)}))},t=()=>{var i;(i=U)==null||i.getSetting("maximumChangelogNumber").then(s=>{e(s)})};return v.useEffect(()=>{t()},[]),c.jsxs(de,{children:[c.jsx(J,{children:'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.'}),c.jsx(ir,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:n,onChange:i=>a(i),onBlur:()=>{r()},onKeyUp:i=>{i.key==="Enter"&&r()},children:c.jsx(or,{})})]})}function Rr({onClose:n}){return c.jsx(c.Fragment,{children:c.jsxs(qe,{isOpen:!0,onClose:n,size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Settings"}),c.jsx(Qe,{}),c.jsx(et,{pb:14,children:c.jsx(K,{children:c.jsxs(On,{divider:c.jsx(Ea,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[c.jsx(Fr,{}),c.jsx(Dr,{}),c.jsx(_t,{settingKey:"autoSave",text:"Enable auto save workflow"}),c.jsx(Er,{}),c.jsx(Vr,{}),c.jsx(_t,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),c.jsx(Lr,{})]})})})]})]})})}const rt=16;function Tr({}){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),{colorMode:t,toggleColorMode:i}=yt();return c.jsxs(c.Fragment,{children:[c.jsxs(Me,{isLazy:!0,children:[c.jsx(Fe,{as:Z,"aria-label":"Options",icon:c.jsx(wr,{}),size:"sm",variant:"outline"}),c.jsxs(Ve,{children:[c.jsx(te,{onClick:()=>r(!0),icon:c.jsx(Mr,{size:16}),fontSize:16,children:"Settings"}),c.jsx(te,{onClick:()=>e(!0),icon:c.jsx(Dn,{size:rt}),fontSize:16,children:"Manage Tags"}),c.jsxs(te,{onClick:i,icon:t==="light"?c.jsx(Or,{size:rt}):c.jsx(kr,{size:rt}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),n&&c.jsx(jr,{onclose:()=>e(!1)}),a&&c.jsx(Rr,{onClose:()=>r(!1)})]})}function Nr(n){const{multipleState:e,changeMultipleState:a,selectedKeys:r,isSelectedAll:t,batchOperationCallback:i}=n,s=async()=>{var u;const l=await((u=G)==null?void 0:u.batchQuery(r))??[];La(l)},o=r.length===0;return c.jsx(K,{spacing:2,wrap:"wrap",mb:0,children:e?c.jsxs(c.Fragment,{children:[c.jsx(Ee,{isChecked:t,onChange:l=>{i("selectAll",l.target.checked)}}),c.jsx(ne,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:c.jsx(Z,{isDisabled:o,"aria-label":"Batch export",size:"sm",icon:c.jsx(Fa,{size:21}),onClick:s})}),c.jsx(ne,{hasArrow:!0,label:"Batch deletion",children:c.jsx(xn,{isDisabled:o,variant:"solid",promptMessage:`Are you sure you want to delete these ${r.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var l;await((l=G)==null?void 0:l.batchDeleteFlow(r)),i("batchDelete")}})}),r.length>0&&c.jsx(J,{fontWeight:600,children:`Selected ${r.length}`}),c.jsx(ne,{hasArrow:!0,label:"Exit multi-select",children:c.jsx(Z,{"aria-label":"Close multi-select operation",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{a(!1)}})})]}):c.jsx(ne,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:c.jsx(Z,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:c.jsx(yr,{size:21}),onClick:()=>{a(!0)}})})})}const $r=(n,e)=>{const[a,r]=v.useState(n);return v.useEffect(()=>{const t=setTimeout(()=>{r(n)},e);return()=>{clearTimeout(t)}},[n,e]),a},Ht=6;function zr({setSelectedTag:n,selectedTag:e}){const[a,r]=v.useState(!1),[t,i]=v.useState([]);return v.useEffect(()=>{var s;(s=Se)==null||s.listAll().then(o=>{i(o)})},[]),c.jsxs(K,{spacing:2,wrap:"wrap",mb:0,children:[e!=null&&c.jsx(Z,{"aria-label":"Close",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{n(void 0)}}),t.slice(0,a?void 0:Ht).map(s=>c.jsx(ee,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(s.name)},isActive:e===s.name,children:s.name},s.name)),(t.length??0)>Ht&&c.jsx(Z,{"aria-label":"Show-all-tags",size:"sm",icon:a?c.jsx(gr,{}):c.jsx(Ot,{}),onClick:()=>r(!a)})]})}function Vn({parentFolderID:n,onlyImportFile:e=!1}){const{onRefreshFilesList:a}=v.useContext(pe),[r,t]=v.useState("file"),i=v.useRef(null),s=d=>{var f;t(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(f=i.current)==null||f.click()},o=async d=>{var f;if(d.type==="image/png"){const h=await Ta(d),p=h==null?void 0:h.workflow;if(p)return{json:p,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(f=d.name)!=null&&f.endsWith(".json"))return await new Promise((h,p)=>{const m=new FileReader;m.onload=b=>{var g;try{const S=(g=b.target)==null?void 0:g.result;typeof S=="string"?h({json:S,name:d.name.replace(".json","")}):p(new Error("File content is not a string"))}catch(S){p(S)}},m.onerror=p,m.readAsText(d)});return null},l=async d=>{var h,p;const f=[d];for(;f.length>0;){const m=f.shift();if(m&&!m.isFile){const b=await((h=fe)==null?void 0:h.create({name:m.name,parentFolderID:m.parentFolderID}));if(m.children&&m.children.length){const g=[];m.children.forEach(S=>{S.isFile&&S.file?g.push(S.file):(S.parentFolderID=b==null?void 0:b.id,f.push(S))}),g.length&&await((p=G)==null?void 0:p.batchCreateFlows(g,void 0,b==null?void 0:b.id))}}}a==null||a()},u=async d=>{var h;const f=d.target.files;if(f)if(r==="folder"){const p={name:f[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const m of f)if(m.name!==".DS_Store"){const b=m.webkitRelativePath.split("/");let g=p.children??[];for(let S=1;Sx.name===w);if(!y){if(y={name:w,isFile:S===b.length-1,children:S===b.length-1?void 0:[]},y.isFile){const x=await o(m);x&&(y.file=x)}g.push(y)}y&&!y.isFile&&(g=y.children)}}l(p)}else{const p=[];for(const m of f){const b=await o(m);b&&p.push(b)}p.length&&(await((h=G)==null?void 0:h.batchCreateFlows(p,void 0,n)),a&&a())}};return c.jsxs(c.Fragment,{children:[e?c.jsx(te,{onClick:d=>{d.stopPropagation(),s("file")},icon:c.jsx(At,{size:19}),children:"Import workflows"}):c.jsxs(Me,{closeOnSelect:!0,children:[c.jsx(Fe,{as:ee,leftIcon:c.jsx(At,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),c.jsx(Ve,{children:Ra.map((d,f)=>c.jsx(te,{onClick:()=>{s(d.type)},iconSpacing:2,icon:d.type==="folder"?c.jsx(Cn,{size:18}):c.jsx(xr,{size:18}),children:d.title},f))})]}),c.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:u,onClick:d=>{d.stopPropagation()}})]})}function Ar({folder:n,onclose:e}){const[a,r]=v.useState(n.name),[t,i]=v.useState(""),{onRefreshFilesList:s}=v.useContext(pe),o=u=>{r(u.target.value),t&&i("")},l=async()=>{var f,h;const u=a.trim();if(r(u),u===n.name)return e();await((f=fe)==null?void 0:f.generateUniqueName(u,n.parentFolderID??""))!==u?i("The name is duplicated, please modify it and submit again."):(await((h=fe)==null?void 0:h.update(n.id,{name:u})),s&&s(),e())};return c.jsxs(qe,{isOpen:!0,onClose:e,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Edit folder name"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(Na,{isInvalid:!!t,children:[c.jsx($a,{children:"Folder name"}),c.jsx(tt,{value:a,onChange:o,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!t&&a&&l()}}),t&&c.jsx(za,{children:t})]})}),c.jsxs(ma,{children:[c.jsx(ee,{colorScheme:"teal",mr:3,onClick:l,isDisabled:!a||!!t,children:"Save"}),c.jsx(ee,{onClick:e,children:"Cancel"})]})]})]})}function _r({menuPosition:n,isopen:e,folder:a,onClose:r}){const[t,i]=v.useState(!1),{onRefreshFilesList:s}=v.useContext(pe),{showDialog:o}=xt(),l=async h=>{var p;h.stopPropagation(),await((p=fe)==null?void 0:p.create({name:"New Folder",parentFolderID:a.id})),s&&s()},u=async h=>{var p;h.stopPropagation(),await((p=G)==null?void 0:p.createFlow({json:JSON.stringify(Aa),parentFolderID:a.id})),s&&s()},d=async h=>{h.stopPropagation();const p=await _a(a.id);o(`Do you want to delete the ${p} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{f(Ha.DELETE)}}])},f=async h=>{var p;await((p=fe)==null?void 0:p.deleteFolder(a.id,h)),r(),s&&s()};return c.jsxs(c.Fragment,{children:[c.jsx(z,{position:"absolute",top:n.y,left:n.x,children:c.jsx(Me,{isOpen:e,onClose:r,isLazy:!0,lazyBehavior:"keepMounted",children:c.jsxs(Ve,{children:[c.jsx(te,{icon:c.jsx(Ir,{size:19}),onClick:h=>{h.preventDefault(),h.stopPropagation(),i(!0)},children:"Rename"}),c.jsx(te,{icon:c.jsx(Sn,{size:19}),onClick:d,children:"Delete"}),c.jsx(te,{onClick:l,icon:c.jsx(jn,{size:19}),children:"New folder"}),c.jsx(te,{onClick:u,icon:c.jsx(It,{size:19}),children:"New file"}),c.jsx(Vn,{parentFolderID:a.id,onlyImportFile:!0})]})})}),t&&c.jsx(Ar,{folder:a,onclose:()=>i(!1)})]})}const Bt=v.memo(function({folder:e}){const[a,r]=v.useState(!1),[t,i]=v.useState(e.isCollapse??!0),[s,o]=v.useState([]),[l,u]=v.useState({x:0,y:0}),[d,f]=v.useState(!1),{colorMode:h}=yt(),{draggingFile:p,setDraggingFile:m,refreshFolderStamp:b,onRefreshFilesList:g}=v.useContext(pe),S=h==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};v.useEffect(()=>{var x;t||(x=G)==null||x.listFolderContent(e.id,window.localStorage.getItem(dt)).then(j=>{o(j)})},[e.id,b,t]);const w=x=>{x.preventDefault(),u({x:x.clientX,y:x.clientY}),f(!0)},y=async x=>{var j,C;if(x.preventDefault(),x.stopPropagation(),!p)return r(!1);if(xe(p)){if(p.id===e.id)return r(!1);await((j=fe)==null?void 0:j.update(p.id,{parentFolderID:e.id}))}else xe(p)||await((C=G)==null?void 0:C.updateFolder(p.id,{parentFolderID:e.id}));await(g==null?void 0:g()),r(!1)};return v.useEffect(()=>{var x;!!e.isCollapse!==t&&((x=fe)==null||x.update(e.id,{isCollapse:t}))},[t]),v.useEffect(()=>{var M;const x=(M=G)==null?void 0:M.curWorkflow,j=(x==null?void 0:x.parentFolderID)+"/",C=e.id+"/";j.startsWith(C)&&i(!1)},[]),c.jsxs(de,{children:[c.jsxs(K,{w:"100%",as:"button",py:1,onClick:()=>{i(!t)},onContextMenu:w,draggable:"true",onDragOver:x=>{x.preventDefault(),x.stopPropagation(),r(!0)},onDragLeave:x=>{x.preventDefault(),x.stopPropagation(),r(!1)},onDragStart:()=>m==null?void 0:m(e),onDrop:y,_hover:S,style:a||d?S:void 0,className:"droppable",children:[c.jsxs(K,{gap:1,children:[t?c.jsx(sr,{size:20}):c.jsx(Ot,{size:20}),c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.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"})})]}),c.jsx(J,{children:e.name})]}),c.jsx(_r,{isopen:d,menuPosition:l,onClose:()=>f(!1),folder:e}),!t&&c.jsx(de,{ml:4,gap:0,children:c.jsx(ca,{items:s})})]})});function Wt(n,e){var a=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),a.push.apply(a,r)}return a}function k(n){for(var e=1;en.length)&&(e=n.length);for(var a=0,r=new Array(e);a=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(a[r]=n[r])}return a}var Ur=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function Gr(n){var e=n.defaultInputValue,a=e===void 0?"":e,r=n.defaultMenuIsOpen,t=r===void 0?!1:r,i=n.defaultValue,s=i===void 0?null:i,o=n.inputValue,l=n.menuIsOpen,u=n.onChange,d=n.onInputChange,f=n.onMenuClose,h=n.onMenuOpen,p=n.value,m=he(n,Ur),b=v.useState(o!==void 0?o:a),g=ue(b,2),S=g[0],w=g[1],y=v.useState(l!==void 0?l:t),x=ue(y,2),j=x[0],C=x[1],V=v.useState(p!==void 0?p:s),M=ue(V,2),T=M[0],A=M[1],W=v.useCallback(function(R,N){typeof u=="function"&&u(R,N),A(R)},[u]),H=v.useCallback(function(R,N){var $;typeof d=="function"&&($=d(R,N)),w($!==void 0?$:R)},[d]),D=v.useCallback(function(){typeof h=="function"&&h(),C(!0)},[h]),O=v.useCallback(function(){typeof f=="function"&&f(),C(!1)},[f]),L=o!==void 0?o:S,_=l!==void 0?l:j,I=p!==void 0?p:T;return k(k({},m),{},{inputValue:L,menuIsOpen:_,onChange:W,onInputChange:H,onMenuClose:O,onMenuOpen:D,value:I})}function Yr(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ut(n,e){for(var a=0;a"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Zr(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Jr(n,e){if(e&&(hn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zr(n)}function Qr(n){var e=Xr();return function(){var r=Ae(n),t;if(e){var i=Ae(this).constructor;t=Reflect.construct(r,arguments,i)}else t=r.apply(this,arguments);return Jr(this,t)}}function ei(n){if(Array.isArray(n))return ft(n)}function ti(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ni(){throw new TypeError(`Invalid attempt to spread non-iterable instance. diff --git a/dist/workspace_web/ShareDialog-o8m3m3T9.js b/dist/workspace_web/ShareDialog-MoNpT1nG.js similarity index 98% rename from dist/workspace_web/ShareDialog-o8m3m3T9.js rename to dist/workspace_web/ShareDialog-MoNpT1nG.js index 06b4e47..a9bf05c 100644 --- a/dist/workspace_web/ShareDialog-o8m3m3T9.js +++ b/dist/workspace_web/ShareDialog-MoNpT1nG.js @@ -1 +1 @@ -import{f as Z,n as ge,o as ie,j as e,g as q,e as ce,r as a,m as me,w as ne,b as ve,l as y,q as M,p as Y,k as we,H as ke,ah as be,h as G,M as xe,N as ye,O as Ce,Q as Se,S as je}from"./input.js";import{aF as Ie,h as De,B as Pe,J as Re,ad as _e,H as Q,l as X,a9 as Fe,ab as de,j as Me,o as le,k as re,aG as Ne,n as Ee,F as Le,A as K,aH as J,aI as We,aJ as Te,aK as He,T as Ve,aL as Be}from"./App-bqAziDgv.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Ke}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import{I as qe}from"./IconCopy-Vm3ws_0T.js";import"/scripts/api.js";var ue=Z(function(c,r){const o=ge("Badge",c),{className:d,...h}=ie(c);return e.jsx(q.span,{ref:r,className:ce("chakra-badge",c.className),...h,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...o}})});ue.displayName="Badge";function Ge(t){return t&&ne(t)&&ne(t.target)}function $e(t={}){const{onChange:c,value:r,defaultValue:o,name:d,isDisabled:h,isFocusable:f,isNative:g,...p}=t,[w,C]=a.useState(o||""),k=typeof r<"u",S=k?r:w,b=a.useRef(null),j=a.useCallback(()=>{const n=b.current;if(!n)return;let u="input:not(:disabled):checked";const I=n.querySelector(u);if(I){I.focus();return}u="input:not(:disabled)";const s=n.querySelector(u);s==null||s.focus()},[]),m=`radio-${a.useId()}`,E=d||m,R=a.useCallback(n=>{const u=Ge(n)?n.target.value:n;k||C(u),c==null||c(String(u))},[c,k]),B=a.useCallback((n={},u=null)=>({...n,ref:me(u,b),role:"radiogroup"}),[]),_=a.useCallback((n={},u=null)=>({...n,ref:u,name:E,[g?"checked":"isChecked"]:S!=null?n.value===S:void 0,onChange(s){R(s)},"data-radiogroup":!0}),[g,E,R,S]);return{getRootProps:B,getRadioProps:_,name:E,ref:b,focus:j,setValue:C,value:S,onChange:R,isDisabled:h,isFocusable:f,htmlProps:p}}var[ze,he]=ve({name:"RadioGroupContext",strict:!1}),fe=Z((t,c)=>{const{colorScheme:r,size:o,variant:d,children:h,className:f,isDisabled:g,isFocusable:p,...w}=t,{value:C,onChange:k,getRootProps:S,name:b,htmlProps:j}=$e(w),N=a.useMemo(()=>({name:b,size:o,onChange:k,colorScheme:r,value:C,variant:d,isDisabled:g,isFocusable:p}),[b,o,k,r,C,d,g,p]);return e.jsx(ze,{value:N,children:e.jsx(q.div,{...S(j,c),className:ce("chakra-radio-group",f),children:h})})});fe.displayName="RadioGroup";var Ue={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Je(t={}){const{defaultChecked:c,isChecked:r,isFocusable:o,isDisabled:d,isReadOnly:h,isRequired:f,onChange:g,isInvalid:p,name:w,value:C,id:k,"data-radiogroup":S,"aria-describedby":b,...j}=t,N=`radio-${a.useId()}`,m=Ie(),R=!!he()||!!S;let _=!!m&&!R?m.id:N;_=k??_;const n=d??(m==null?void 0:m.isDisabled),u=h??(m==null?void 0:m.isReadOnly),I=f??(m==null?void 0:m.isRequired),s=p??(m==null?void 0:m.isInvalid),[l,P]=a.useState(!1),[v,D]=a.useState(!1),[x,L]=a.useState(!1),[W,T]=a.useState(!1),[$,z]=a.useState(!!c),O=typeof r<"u",F=O?r:$;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(i=>{if(u||n){i.preventDefault();return}O||z(i.target.checked),g==null||g(i)},[O,n,u,g]),A=a.useCallback(i=>{i.key===" "&&T(!0)},[T]),U=a.useCallback(i=>{i.key===" "&&T(!1)},[T]),oe=a.useCallback((i={},V=null)=>({...i,ref:V,"data-active":y(W),"data-hover":y(x),"data-disabled":y(n),"data-invalid":y(s),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&l),"data-readonly":y(u),"aria-hidden":!0,onMouseDown:M(i.onMouseDown,()=>T(!0)),onMouseUp:M(i.onMouseUp,()=>T(!1)),onMouseEnter:M(i.onMouseEnter,()=>L(!0)),onMouseLeave:M(i.onMouseLeave,()=>L(!1))}),[W,x,n,s,F,v,u,l]),{onFocus:se,onBlur:te}=m??{},pe=a.useCallback((i={},V=null)=>{const ae=n&&!o;return{...i,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(i.onChange,H),onBlur:M(te,i.onBlur,()=>D(!1)),onFocus:M(se,i.onFocus,()=>D(!0)),onKeyDown:M(i.onKeyDown,A),onKeyUp:M(i.onKeyUp,U),checked:F,disabled:ae,readOnly:u,required:I,"aria-invalid":Y(s),"aria-disabled":Y(ae),"aria-required":Y(I),"data-readonly":y(u),"aria-describedby":b,style:Ue}},[n,o,_,w,C,H,te,se,A,U,F,u,I,s,b]);return{state:{isInvalid:s,isFocused:v,isChecked:F,isActive:W,isHovered:x,isDisabled:n,isReadOnly:u,isRequired:I},getCheckboxProps:oe,getRadioProps:oe,getInputProps:pe,getLabelProps:(i={},V=null)=>({...i,ref:V,onMouseDown:M(i.onMouseDown,Qe),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),getRootProps:(i,V=null)=>({...i,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),htmlProps:j}}function Qe(t){t.preventDefault(),t.stopPropagation()}function Ye(t,c){const r={},o={};for(const[d,h]of Object.entries(t))c.includes(d)?r[d]=h:o[d]=h;return[r,o]}var ee=Z((t,c)=>{var r;const o=he(),{onChange:d,value:h}=t,f=we("Radio",{...o,...t}),g=ie(t),{spacing:p="0.5rem",children:w,isDisabled:C=o==null?void 0:o.isDisabled,isFocusable:k=o==null?void 0:o.isFocusable,inputProps:S,...b}=g;let j=t.isChecked;(o==null?void 0:o.value)!=null&&h!=null&&(j=o.value===h);let N=d;o!=null&&o.onChange&&h!=null&&(N=ke(o.onChange,d));const m=(r=t==null?void 0:t.name)!=null?r:o==null?void 0:o.name,{getInputProps:E,getCheckboxProps:R,getLabelProps:B,getRootProps:_,htmlProps:n}=Je({...b,isChecked:j,isFocusable:k,isDisabled:C,onChange:N,name:m}),[u,I]=Ye(n,be),s=R(I),l=E(S,c),P=B(),v=Object.assign({},u,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...f.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...f.control},L={userSelect:"none",marginStart:p,...f.label};return e.jsxs(q.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...l}),e.jsx(q.span,{className:"chakra-radio__control",...s,__css:x}),w&&e.jsx(q.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});ee.displayName="Radio";var Xe=De("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Ze({options:t,value:c,onChange:r}){const[o,d]=a.useState(!1),h=a.useRef(null),f=t.find(p=>p.value===c);a.useEffect(()=>{const p=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[h]);const g=()=>d(!o);return e.jsxs(Pe,{position:"relative",children:[e.jsx(G,{onClick:g,rightIcon:e.jsx(Re,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),o&&e.jsx(_e,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(p=>e.jsx(G,{onClick:()=>{d(!1),r(p.value)},leftIcon:p.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:p.label},p.label))})]})}function eo({version:t,cloudHost:c,cloudWorkflowID:r}){const o=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:o.name}),e.jsx(X,{color:"GrayText",children:Fe(o.createTime,!1)}),o.cloudID&&r&&e.jsx("a",{href:c+"/workflow/"+r+"/"+o.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(G,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Xe,{}),rightIcon:e.jsx(de,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(ee,{value:o.id,mb:5,children:d},o.id)}function fo({onClose:t}){var u,I;const[c,r]=a.useState("version "+oo()),[o,d]=a.useState([]),[h,f]=a.useState(!1),[g,p]=a.useState(""),[w,C]=a.useState("PRIVATE"),[k,S]=a.useState("new_version"),b=a.useRef(""),[j,N]=a.useState(),m=Me(),E=async s=>{var L,W;const l=s.data;if(s.origin!==b.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,v=l.localVersionID,D=l.version.id,x=l.version.workflowID;x&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:x,cloudOrigin:s.origin,privacy:w})),v&&D&&await((W=J)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:s.origin})),R(),window.open(b.current+"/workflow/"+x+"/"+D,"_blank"),f(!1)};a.useEffect(()=>(R(),window.addEventListener("message",E),()=>{window.removeEventListener("message",E)}),[]);const R=async()=>{var P,v,D;const s=await((P=le)==null?void 0:P.getSetting("cloudHost"));s&&(p(s),b.current=s);const l=((v=K)==null?void 0:v.curWorkflow)??void 0;N(l),l!=null&&l.cloudID&&l.cloudOrigin&&He(l).then(x=>{C(x)}),(D=J)==null||D.listByWorkflowID(l.id).then(x=>{d(x)})},B=s=>{navigator.clipboard.writeText(s).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var z,O,F;f(!0);const s=We(32),l=await((z=le)==null?void 0:z.getSetting("cloudHost"));let P,v;try{if(P=Te(),k==="new_version"?v=await((O=J)==null?void 0:O.add({workflowID:j.id,name:c,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=J)==null?void 0:F.get(k)),!v){alert(`Failed to find version: ${k}, please try again.`),f(!1);return}}catch(H){console.error(H),f(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,x=window.location.host,L=`${D}//${x}`,W=l+`/share_workflow_confirm/${s}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),$=H=>{var A;if(H.origin===l&&H.data==="child_ready"){const U=(A=K)==null?void 0:A.curWorkflow;T.postMessage({workflow:U,version:v,nodeDefs:P,privacy:w},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},n=(I=(u=K)==null?void 0:u.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ye,{}),e.jsxs(Ce,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(Se,{children:['Share "',j==null?void 0:j.name,'"']}),e.jsxs(je,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Ze,{options:Ne,value:w,onChange:s=>{C(s)}}):e.jsx(Ve,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Be,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Ke,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(de,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(G,{width:"180px",size:"sm",leftIcon:e.jsx(qe,{}),onClick:()=>{var s,l;B(g+"/workflow/"+((l=(s=K)==null?void 0:s.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(fe,{gap:4,onChange:s=>{S(s)},value:k,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(ee,{value:"new_version"},"new_version"),e.jsx(Ee,{value:c,width:"60%",onFocus:()=>{S("new_version")},onChange:s=>{r(s.target.value)}}),e.jsx(Le,{color:"green",children:e.jsx(ue,{colorScheme:"purple",children:"New version"})})]}),o.slice(0,4).map(s=>e.jsx(eo,{version:s,cloudHost:g,cloudWorkflowID:n??null},s.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(G,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function oo(){const t=new Date,c=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${c}-${r}-${o}`}export{fo as default}; +import{f as Z,n as ge,o as ie,j as e,g as q,e as ce,r as a,m as me,w as ne,b as ve,l as y,q as M,p as Y,k as we,H as ke,ah as be,h as G,M as xe,N as ye,O as Ce,Q as Se,S as je}from"./input.js";import{aF as Ie,h as De,B as Pe,J as Re,ad as _e,H as Q,l as X,a9 as Fe,ab as de,j as Me,o as le,k as re,aG as Ne,n as Ee,F as Le,A as K,aH as J,aI as We,aJ as Te,aK as He,T as Ve,aL as Be}from"./App-sgH6j00M.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Ke}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import{I as qe}from"./IconCopy-Hs60LgD8.js";import"/scripts/api.js";var ue=Z(function(c,r){const o=ge("Badge",c),{className:d,...h}=ie(c);return e.jsx(q.span,{ref:r,className:ce("chakra-badge",c.className),...h,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...o}})});ue.displayName="Badge";function Ge(t){return t&&ne(t)&&ne(t.target)}function $e(t={}){const{onChange:c,value:r,defaultValue:o,name:d,isDisabled:h,isFocusable:f,isNative:g,...p}=t,[w,C]=a.useState(o||""),k=typeof r<"u",S=k?r:w,b=a.useRef(null),j=a.useCallback(()=>{const n=b.current;if(!n)return;let u="input:not(:disabled):checked";const I=n.querySelector(u);if(I){I.focus();return}u="input:not(:disabled)";const s=n.querySelector(u);s==null||s.focus()},[]),m=`radio-${a.useId()}`,E=d||m,R=a.useCallback(n=>{const u=Ge(n)?n.target.value:n;k||C(u),c==null||c(String(u))},[c,k]),B=a.useCallback((n={},u=null)=>({...n,ref:me(u,b),role:"radiogroup"}),[]),_=a.useCallback((n={},u=null)=>({...n,ref:u,name:E,[g?"checked":"isChecked"]:S!=null?n.value===S:void 0,onChange(s){R(s)},"data-radiogroup":!0}),[g,E,R,S]);return{getRootProps:B,getRadioProps:_,name:E,ref:b,focus:j,setValue:C,value:S,onChange:R,isDisabled:h,isFocusable:f,htmlProps:p}}var[ze,he]=ve({name:"RadioGroupContext",strict:!1}),fe=Z((t,c)=>{const{colorScheme:r,size:o,variant:d,children:h,className:f,isDisabled:g,isFocusable:p,...w}=t,{value:C,onChange:k,getRootProps:S,name:b,htmlProps:j}=$e(w),N=a.useMemo(()=>({name:b,size:o,onChange:k,colorScheme:r,value:C,variant:d,isDisabled:g,isFocusable:p}),[b,o,k,r,C,d,g,p]);return e.jsx(ze,{value:N,children:e.jsx(q.div,{...S(j,c),className:ce("chakra-radio-group",f),children:h})})});fe.displayName="RadioGroup";var Ue={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Je(t={}){const{defaultChecked:c,isChecked:r,isFocusable:o,isDisabled:d,isReadOnly:h,isRequired:f,onChange:g,isInvalid:p,name:w,value:C,id:k,"data-radiogroup":S,"aria-describedby":b,...j}=t,N=`radio-${a.useId()}`,m=Ie(),R=!!he()||!!S;let _=!!m&&!R?m.id:N;_=k??_;const n=d??(m==null?void 0:m.isDisabled),u=h??(m==null?void 0:m.isReadOnly),I=f??(m==null?void 0:m.isRequired),s=p??(m==null?void 0:m.isInvalid),[l,P]=a.useState(!1),[v,D]=a.useState(!1),[x,L]=a.useState(!1),[W,T]=a.useState(!1),[$,z]=a.useState(!!c),O=typeof r<"u",F=O?r:$;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(i=>{if(u||n){i.preventDefault();return}O||z(i.target.checked),g==null||g(i)},[O,n,u,g]),A=a.useCallback(i=>{i.key===" "&&T(!0)},[T]),U=a.useCallback(i=>{i.key===" "&&T(!1)},[T]),oe=a.useCallback((i={},V=null)=>({...i,ref:V,"data-active":y(W),"data-hover":y(x),"data-disabled":y(n),"data-invalid":y(s),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&l),"data-readonly":y(u),"aria-hidden":!0,onMouseDown:M(i.onMouseDown,()=>T(!0)),onMouseUp:M(i.onMouseUp,()=>T(!1)),onMouseEnter:M(i.onMouseEnter,()=>L(!0)),onMouseLeave:M(i.onMouseLeave,()=>L(!1))}),[W,x,n,s,F,v,u,l]),{onFocus:se,onBlur:te}=m??{},pe=a.useCallback((i={},V=null)=>{const ae=n&&!o;return{...i,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(i.onChange,H),onBlur:M(te,i.onBlur,()=>D(!1)),onFocus:M(se,i.onFocus,()=>D(!0)),onKeyDown:M(i.onKeyDown,A),onKeyUp:M(i.onKeyUp,U),checked:F,disabled:ae,readOnly:u,required:I,"aria-invalid":Y(s),"aria-disabled":Y(ae),"aria-required":Y(I),"data-readonly":y(u),"aria-describedby":b,style:Ue}},[n,o,_,w,C,H,te,se,A,U,F,u,I,s,b]);return{state:{isInvalid:s,isFocused:v,isChecked:F,isActive:W,isHovered:x,isDisabled:n,isReadOnly:u,isRequired:I},getCheckboxProps:oe,getRadioProps:oe,getInputProps:pe,getLabelProps:(i={},V=null)=>({...i,ref:V,onMouseDown:M(i.onMouseDown,Qe),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),getRootProps:(i,V=null)=>({...i,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),htmlProps:j}}function Qe(t){t.preventDefault(),t.stopPropagation()}function Ye(t,c){const r={},o={};for(const[d,h]of Object.entries(t))c.includes(d)?r[d]=h:o[d]=h;return[r,o]}var ee=Z((t,c)=>{var r;const o=he(),{onChange:d,value:h}=t,f=we("Radio",{...o,...t}),g=ie(t),{spacing:p="0.5rem",children:w,isDisabled:C=o==null?void 0:o.isDisabled,isFocusable:k=o==null?void 0:o.isFocusable,inputProps:S,...b}=g;let j=t.isChecked;(o==null?void 0:o.value)!=null&&h!=null&&(j=o.value===h);let N=d;o!=null&&o.onChange&&h!=null&&(N=ke(o.onChange,d));const m=(r=t==null?void 0:t.name)!=null?r:o==null?void 0:o.name,{getInputProps:E,getCheckboxProps:R,getLabelProps:B,getRootProps:_,htmlProps:n}=Je({...b,isChecked:j,isFocusable:k,isDisabled:C,onChange:N,name:m}),[u,I]=Ye(n,be),s=R(I),l=E(S,c),P=B(),v=Object.assign({},u,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...f.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...f.control},L={userSelect:"none",marginStart:p,...f.label};return e.jsxs(q.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...l}),e.jsx(q.span,{className:"chakra-radio__control",...s,__css:x}),w&&e.jsx(q.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});ee.displayName="Radio";var Xe=De("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Ze({options:t,value:c,onChange:r}){const[o,d]=a.useState(!1),h=a.useRef(null),f=t.find(p=>p.value===c);a.useEffect(()=>{const p=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[h]);const g=()=>d(!o);return e.jsxs(Pe,{position:"relative",children:[e.jsx(G,{onClick:g,rightIcon:e.jsx(Re,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),o&&e.jsx(_e,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(p=>e.jsx(G,{onClick:()=>{d(!1),r(p.value)},leftIcon:p.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:p.label},p.label))})]})}function eo({version:t,cloudHost:c,cloudWorkflowID:r}){const o=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:o.name}),e.jsx(X,{color:"GrayText",children:Fe(o.createTime,!1)}),o.cloudID&&r&&e.jsx("a",{href:c+"/workflow/"+r+"/"+o.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(G,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Xe,{}),rightIcon:e.jsx(de,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(ee,{value:o.id,mb:5,children:d},o.id)}function fo({onClose:t}){var u,I;const[c,r]=a.useState("version "+oo()),[o,d]=a.useState([]),[h,f]=a.useState(!1),[g,p]=a.useState(""),[w,C]=a.useState("PRIVATE"),[k,S]=a.useState("new_version"),b=a.useRef(""),[j,N]=a.useState(),m=Me(),E=async s=>{var L,W;const l=s.data;if(s.origin!==b.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,v=l.localVersionID,D=l.version.id,x=l.version.workflowID;x&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:x,cloudOrigin:s.origin,privacy:w})),v&&D&&await((W=J)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:s.origin})),R(),window.open(b.current+"/workflow/"+x+"/"+D,"_blank"),f(!1)};a.useEffect(()=>(R(),window.addEventListener("message",E),()=>{window.removeEventListener("message",E)}),[]);const R=async()=>{var P,v,D;const s=await((P=le)==null?void 0:P.getSetting("cloudHost"));s&&(p(s),b.current=s);const l=((v=K)==null?void 0:v.curWorkflow)??void 0;N(l),l!=null&&l.cloudID&&l.cloudOrigin&&He(l).then(x=>{C(x)}),(D=J)==null||D.listByWorkflowID(l.id).then(x=>{d(x)})},B=s=>{navigator.clipboard.writeText(s).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var z,O,F;f(!0);const s=We(32),l=await((z=le)==null?void 0:z.getSetting("cloudHost"));let P,v;try{if(P=Te(),k==="new_version"?v=await((O=J)==null?void 0:O.add({workflowID:j.id,name:c,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=J)==null?void 0:F.get(k)),!v){alert(`Failed to find version: ${k}, please try again.`),f(!1);return}}catch(H){console.error(H),f(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,x=window.location.host,L=`${D}//${x}`,W=l+`/share_workflow_confirm/${s}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),$=H=>{var A;if(H.origin===l&&H.data==="child_ready"){const U=(A=K)==null?void 0:A.curWorkflow;T.postMessage({workflow:U,version:v,nodeDefs:P,privacy:w},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},n=(I=(u=K)==null?void 0:u.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ye,{}),e.jsxs(Ce,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(Se,{children:['Share "',j==null?void 0:j.name,'"']}),e.jsxs(je,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Ze,{options:Ne,value:w,onChange:s=>{C(s)}}):e.jsx(Ve,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Be,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Ke,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(de,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(G,{width:"180px",size:"sm",leftIcon:e.jsx(qe,{}),onClick:()=>{var s,l;B(g+"/workflow/"+((l=(s=K)==null?void 0:s.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(fe,{gap:4,onChange:s=>{S(s)},value:k,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(ee,{value:"new_version"},"new_version"),e.jsx(Ee,{value:c,width:"60%",onFocus:()=>{S("new_version")},onChange:s=>{r(s.target.value)}}),e.jsx(Le,{color:"green",children:e.jsx(ue,{colorScheme:"purple",children:"New version"})})]}),o.slice(0,4).map(s=>e.jsx(eo,{version:s,cloudHost:g,cloudWorkflowID:n??null},s.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(G,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function oo(){const t=new Date,c=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${c}-${r}-${o}`}export{fo as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js b/dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js similarity index 96% rename from dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js rename to dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js index 8ce198b..6171cfc 100644 --- a/dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js +++ b/dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js @@ -1 +1 @@ -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,ah as P}from"./input.js";import{$ as z}from"./App-bqAziDgv.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; +import{f as x,j as l,g as i,e as b,k as C,o as E,l as I,r as f,ah as P}from"./input.js";import{$ as z}from"./App-sgH6j00M.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; diff --git a/dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js b/dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js similarity index 99% rename from dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js rename to dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js index c514adb..b929c5c 100644 --- a/dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js +++ b/dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js @@ -1 +1 @@ -import{f as $,j as f,r as l,y as U,g as P,b as ue,d as W,x as fe,l as i,q as y,m as oe,a4 as J,k as me,o as he,H as ge,e as be}from"./input.js";import{aq as ke}from"./App-bqAziDgv.js";import{t as ve}from"./index-pz0vT7Or.js";var X=$(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;k();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=b=>{k(),g("loaded"),c==null||c(b)},r.onerror=b=>{k(),g("failed"),s==null||s(b)},u.current=r},[e,d,a,p,c,s,n]),k=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return U(()=>{if(!C)return m==="loading"&&x(),()=>{k()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=$(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:k,...r}=n,b=a!==void 0||c!==void 0,R=m!=null||g||!b,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:k,className:"chakra-image",...j})});xe.displayName="Image";var[Ue,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=ke(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:k,isIndeterminate:r,name:b,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(k),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,q]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,H]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||H(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);U(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&q(!1)},[e,q]),U(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{H(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);U(()=>{if(!I.current)return;I.current.checked!==h&&H(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=K=>{F&&K.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var K;(K=I.current)==null||K.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:b,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>q(!1)),onFocus:y(t.onFocus,B,()=>q(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[b,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=$(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:k,isDisabled:r=a==null?void 0:a.isDisabled,onChange:b,inputProps:R,..._}=d;let A=k;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=b;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,b));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:be("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=$(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:k,...r}=n,b={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:k};return f.jsx(P.div,{ref:e,__css:b,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; +import{f as $,j as f,r as l,y as U,g as P,b as ue,d as W,x as fe,l as i,q as y,m as oe,a4 as J,k as me,o as he,H as ge,e as be}from"./input.js";import{aq as ke}from"./App-sgH6j00M.js";import{t as ve}from"./index-pz0vT7Or.js";var X=$(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;k();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=b=>{k(),g("loaded"),c==null||c(b)},r.onerror=b=>{k(),g("failed"),s==null||s(b)},u.current=r},[e,d,a,p,c,s,n]),k=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return U(()=>{if(!C)return m==="loading"&&x(),()=>{k()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=$(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:k,...r}=n,b=a!==void 0||c!==void 0,R=m!=null||g||!b,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:k,className:"chakra-image",...j})});xe.displayName="Image";var[Ue,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=ke(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:k,isIndeterminate:r,name:b,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(k),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,q]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,H]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||H(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);U(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&q(!1)},[e,q]),U(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{H(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);U(()=>{if(!I.current)return;I.current.checked!==h&&H(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=K=>{F&&K.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var K;(K=I.current)==null||K.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:b,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>q(!1)),onFocus:y(t.onFocus,B,()=>q(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[b,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=$(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:k,isDisabled:r=a==null?void 0:a.isDisabled,onChange:b,inputProps:R,..._}=d;let A=k;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=b;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,b));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:be("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=$(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:k,...r}=n,b={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:k};return f.jsx(P.div,{ref:e,__css:b,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js b/dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js rename to dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js index b14c30d..345d1b3 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js +++ b/dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js @@ -1 +1 @@ -import{k as t}from"./App-bqAziDgv.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{k as t}from"./App-sgH6j00M.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index fca58a7..63d351b 100644 --- a/dist/workspace_web/input.js +++ b/dist/workspace_web/input.js @@ -679,10 +679,10 @@ Error generating stack: `+i.message+` } ${hB} - `}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-bqAziDgv.js").then(e=>e.aN),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={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},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=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 Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z}; + `}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-sgH6j00M.js").then(e=>e.aN),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={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},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=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 Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-bqAziDgv.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-sgH6j00M.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file