From c017486af77dbc4ac93e1f4e04acd2f9ff4ef4a5 Mon Sep 17 00:00:00 2001 From: Weixuan Fu - windows Date: Thu, 20 Jun 2024 01:31:03 +0800 Subject: [PATCH] build dist --- .../{App-rR1IBjvq.js => App-HFfBS8qf.js} | 18 +++++++++--------- ....js => AppIsDirtyEventListener-HyyIaWmp.js} | 2 +- ...al-qNnfNTjL.js => GalleryModal-H7PcxDl8.js} | 2 +- ...onCopy-KNYgQ4PQ.js => IconCopy-pJEV5GIP.js} | 2 +- ...arch-6vngoIPw.js => IconSearch-w32ReMy0.js} | 2 +- ...ew-QD6yX7R-.js => MediaPreview-aZ3slqVC.js} | 2 +- ...EV7gi.js => ModelManagerTopbar-_rZ5F_Jv.js} | 2 +- .../RecentFilesDrawer-BJDDVyUO.js | 5 ----- .../RecentFilesDrawer-o2YKsAW_.js | 5 +++++ dist/workspace_web/ShareDialog-7hYnIR9_.js | 1 - dist/workspace_web/ShareDialog-opv28tSj.js | 1 + ...z3bKfoPZ.js => SpotlightSearch-NM7L9eNM.js} | 2 +- ...-yfOR3kNT.js => chunk-3RSXBRAN-Ge4h6OPg.js} | 2 +- ...-QyxxCI30.js => chunk-7D6N5TE5-Bj67hFEP.js} | 2 +- ...-J2YFxPIJ.js => chunk-JARCRF6W-OdkdCK_9.js} | 2 +- ...-PRXQGfLv.js => chunk-NTCQBYKE-hyXDv1Bs.js} | 2 +- ...-KWHHQVVF.js => chunk-VTV6N5LE-iPEvTIe2.js} | 2 +- ...tils-7bf079LQ.js => civitUtils-Ao2r5rP5.js} | 2 +- dist/workspace_web/input.js | 4 ++-- 19 files changed, 30 insertions(+), 30 deletions(-) rename dist/workspace_web/{App-rR1IBjvq.js => App-HFfBS8qf.js} (81%) rename dist/workspace_web/{AppIsDirtyEventListener-ZV5NPDCI.js => AppIsDirtyEventListener-HyyIaWmp.js} (82%) rename dist/workspace_web/{GalleryModal-qNnfNTjL.js => GalleryModal-H7PcxDl8.js} (98%) rename dist/workspace_web/{IconCopy-KNYgQ4PQ.js => IconCopy-pJEV5GIP.js} (83%) rename dist/workspace_web/{IconSearch-6vngoIPw.js => IconSearch-w32ReMy0.js} (67%) rename dist/workspace_web/{MediaPreview-QD6yX7R-.js => MediaPreview-aZ3slqVC.js} (98%) rename dist/workspace_web/{ModelManagerTopbar-azmEV7gi.js => ModelManagerTopbar-_rZ5F_Jv.js} (94%) delete mode 100644 dist/workspace_web/RecentFilesDrawer-BJDDVyUO.js create mode 100644 dist/workspace_web/RecentFilesDrawer-o2YKsAW_.js delete mode 100644 dist/workspace_web/ShareDialog-7hYnIR9_.js create mode 100644 dist/workspace_web/ShareDialog-opv28tSj.js rename dist/workspace_web/{SpotlightSearch-z3bKfoPZ.js => SpotlightSearch-NM7L9eNM.js} (74%) rename dist/workspace_web/{chunk-3RSXBRAN-yfOR3kNT.js => chunk-3RSXBRAN-Ge4h6OPg.js} (81%) rename dist/workspace_web/{chunk-7D6N5TE5-QyxxCI30.js => chunk-7D6N5TE5-Bj67hFEP.js} (98%) rename dist/workspace_web/{chunk-JARCRF6W-J2YFxPIJ.js => chunk-JARCRF6W-OdkdCK_9.js} (97%) rename dist/workspace_web/{chunk-NTCQBYKE-PRXQGfLv.js => chunk-NTCQBYKE-hyXDv1Bs.js} (65%) rename dist/workspace_web/{chunk-VTV6N5LE-KWHHQVVF.js => chunk-VTV6N5LE-iPEvTIe2.js} (95%) rename dist/workspace_web/{civitUtils-7bf079LQ.js => civitUtils-Ao2r5rP5.js} (91%) diff --git a/dist/workspace_web/App-rR1IBjvq.js b/dist/workspace_web/App-HFfBS8qf.js similarity index 81% rename from dist/workspace_web/App-rR1IBjvq.js rename to dist/workspace_web/App-HFfBS8qf.js index 9757382..faa8af4 100644 --- a/dist/workspace_web/App-rR1IBjvq.js +++ b/dist/workspace_web/App-HFfBS8qf.js @@ -1,13 +1,13 @@ -var fl=Object.defineProperty;var hl=(t,e,n)=>e in t?fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(hl(t,typeof e!="symbol"?e+"":e,n),n);import{u as pl,a as ml,r as j,c as yl,b as tt,m as Te,d as Bt,f as fe,e as xe,j as I,B as vl,g as de,h as Le,i as gl,o as nt,k as jt,l as st,I as Ur,n as Kr,p as no,q as Oe,s as ka,t as wl,v as bl,w as _l,x as $r,y as xl,z as kl,A as El,C as Cl,D as Sl,E as os,F as Ea,G as ss,H as Ca,J as Il,K as Ol,L as Dl,P as Sa,_ as At,M as as,N as is,O as ls,Q as cs,R as us,S as ds,T as fs,U as Ia,V as Oa,W as Xn,X as Da}from"./input.js";function Pl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Pa(t){var e;return Pl(t)&&(e=t.ownerDocument)!=null?e:document}function jl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Al=jl();function Nl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function ja(t){const{theme:e}=pl(),n=ml();return j.useMemo(()=>yl(e.direction,{...n,...t}),[t,e.direction,n])}var Fl=Object.defineProperty,Rl=(t,e,n)=>e in t?Fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(Rl(t,typeof e!="symbol"?e+"":e,n),n);function $s(t){return t.sort((e,n)=>{const r=e.compareDocumentPosition(n);if(r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS)return 1;if(r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)throw Error("Cannot sort the given nodes.");return 0})}var Tl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function qs(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Hs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var go=typeof window<"u"?j.useLayoutEffect:j.useEffect,xr=t=>t,Bl=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return Tl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=$s(Array.from(this.descendants.keys()));this.assignIndex(e)}),De(this,"destroy",()=>{this.descendants.clear()}),De(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),De(this,"count",()=>this.descendants.size),De(this,"enabledCount",()=>this.enabledValues().length),De(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),De(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),De(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),De(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),De(this,"first",()=>this.item(0)),De(this,"firstEnabled",()=>this.enabledItem(0)),De(this,"last",()=>this.item(this.descendants.size-1)),De(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),De(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),De(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),De(this,"next",(t,e=!0)=>{const n=qs(t,this.count(),e);return this.item(n)}),De(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=qs(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=Hs(t,this.count()-1,e);return this.item(n)}),De(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Hs(r,this.enabledCount()-1,e);return this.enabledItem(o)}),De(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=$s(n);e!=null&&e.disabled&&(e.disabled=!!e.disabled);const o={node:t,index:-1,...e};this.descendants.set(t,o),this.assignIndex(r)})}};function Ml(){const t=j.useRef(new Bl);return go(()=>()=>t.current.destroy()),t.current}var[zl,Aa]=tt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Ll(t){const e=Aa(),[n,r]=j.useState(-1),o=j.useRef(null);go(()=>()=>{o.current&&e.unregister(o.current)},[]),go(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=xr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Te(s,o)}}function Na(){return[xr(zl),()=>xr(Aa()),()=>Ml(),o=>Ll(o)]}function Fa(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Bt(r),i=Bt(o),[a,l]=j.useState(n),u=e!==void 0,c=u?e:a,d=Bt(p=>{const b=typeof p=="function"?p(c):p;i(c,b)&&(u||l(b),s(b))},[u,s,c,i]);return[c,d]}function hs(t){return j.Children.toArray(t).filter(e=>j.isValidElement(e))}var Wl={horizontal:{"> *:first-of-type:not(:last-of-type)":{borderEndRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderStartRadius:0}},vertical:{"> *:first-of-type:not(:last-of-type)":{borderBottomRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderTopRadius:0}}},Ul={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},Ra=fe(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:u,orientation:c="horizontal",...d}=e,p=xe("chakra-button__group",i),h=j.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let b={display:"inline-flex",...l?Wl[c]:Ul[c](a)};const f=c==="vertical";return I.jsx(vl,{value:h,children:I.jsx(de.div,{ref:n,role:"group",__css:b,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:f?"column":void 0,...d})})});Ra.displayName="ButtonGroup";var jn=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=j.isValidElement(a)?j.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return I.jsx(Le,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});jn.displayName="IconButton";var[Kl,Ta]=gl("Card"),$l=fe(function(e,n){const{className:r,...o}=e,s=Ta();return I.jsx(de.div,{ref:n,className:xe("chakra-card__body",r),__css:s.body,...o})}),ql=fe(function(e,n){const{className:r,...o}=e,s=Ta();return I.jsx(de.div,{ref:n,className:xe("chakra-card__header",r),__css:s.header,...o})}),Hl=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=nt(e),u=jt("Card",e);return I.jsx(de.div,{ref:n,className:xe("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:I.jsx(Kl,{value:u,children:o})})}),[Vl,Ba]=tt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Zl,hn]=tt({strict:!1,name:"FormControlContext"});function Gl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=j.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,h]=j.useState(!1),[b,f]=j.useState(!1),[y,m]=j.useState(!1),w=j.useCallback((E={},N=null)=>({id:d,...E,ref:Te(N,D=>{D&&f(!0)})}),[d]),_=j.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":st(y),"data-disabled":st(o),"data-invalid":st(r),"data-readonly":st(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,u]),x=j.useCallback((E={},N=null)=>({id:c,...E,ref:Te(N,D=>{D&&h(!0)}),"aria-live":"polite"}),[c]),k=j.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":st(y),"data-disabled":st(o),"data-invalid":st(r),"data-readonly":st(s)}),[i,o,y,r,s]),O=j.useCallback((E={},N=null)=>({...E,ref:N,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!y,onFocus:()=>m(!0),onBlur:()=>m(!1),hasFeedbackText:p,setHasFeedbackText:h,hasHelpText:b,setHasHelpText:f,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:w,getErrorMessageProps:x,getRootProps:k,getLabelProps:_,getRequiredIndicatorProps:O}}var qr=fe(function(e,n){const r=jt("Form",e),o=nt(e),{getRootProps:s,htmlProps:i,...a}=Gl(o),l=xe("chakra-form-control",e.className);return I.jsx(Zl,{value:a,children:I.jsx(Vl,{value:r,children:I.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});qr.displayName="FormControl";var Yl=fe(function(e,n){const r=hn(),o=Ba(),s=xe("chakra-form__helper-text",e.className);return I.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Yl.displayName="FormHelperText";var[Jl,Xl]=tt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Hr=fe((t,e)=>{const n=jt("FormError",t),r=nt(t),o=hn();return o!=null&&o.isInvalid?I.jsx(Jl,{value:n,children:I.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:xe("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Hr.displayName="FormErrorMessage";var Ql=fe((t,e)=>{const n=Xl(),r=hn();if(!(r!=null&&r.isInvalid))return null;const o=xe("chakra-form__error-icon",t.className);return I.jsx(Ur,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:I.jsx("path",{fill:"currentColor",d:"M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"})})});Ql.displayName="FormErrorIcon";var Vr=fe(function(e,n){var r;const o=Kr("FormLabel",e),s=nt(e),{className:i,children:a,requiredIndicator:l=I.jsx(Ma,{}),optionalIndicator:u=null,...c}=s,d=hn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return I.jsxs(de.label,{...p,className:xe("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:u]})});Vr.displayName="FormLabel";var Ma=fe(function(e,n){const r=hn(),o=Ba();if(!(r!=null&&r.isRequired))return null;const s=xe("chakra-form__required-indicator",e.className);return I.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ma.displayName="RequiredIndicator";function ec(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=tc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":no(n),"aria-required":no(o),"aria-readonly":no(r)}}function tc(t){var e,n,r;const o=hn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:b,...f}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...f,"aria-describedby":y.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=i??p)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=a??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??u)!=null?r:o==null?void 0:o.isRequired,isInvalid:c??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,b)}}function nn(t,e,n,r){const o=Bt(n);return j.useEffect(()=>{const s=typeof t=="function"?t():t??document;if(!(!n||!s))return s.addEventListener(e,o,r),()=>{s.removeEventListener(e,o,r)}},[e,t,r,o,n]),()=>{const s=typeof t=="function"?t():t??document;s==null||s.removeEventListener(e,o,r)}}function nc(t){return"current"in t}var za=()=>typeof window<"u";function rc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var oc=t=>za()&&t.test(navigator.vendor),sc=t=>za()&&t.test(rc()),ac=()=>sc(/mac|iphone|ipad|ipod/i),ic=()=>ac()&&oc(/apple/i);function lc(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,i;return(i=(s=e.current)==null?void 0:s.ownerDocument)!=null?i:document};nn(o,"pointerdown",s=>{if(!ic()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=nc(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var La={exports:{}},cc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",uc=cc,dc=uc;function Wa(){}function Ua(){}Ua.resetWarningCache=Wa;var fc=function(){function t(r,o,s,i,a,l){if(l!==dc){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Ua,resetWarningCache:Wa};return n.PropTypes=n,n};La.exports=fc();var hc=La.exports;const Ft=ka(hc);function pc(t){const e=t.ownerDocument.defaultView||window,{overflow:n,overflowX:r,overflowY:o}=e.getComputedStyle(t);return/auto|scroll|overlay|hidden/.test(n+o+r)}function mc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function Ka(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:wl(t)&&pc(t)?t:Ka(mc(t))}var yc=Al?j.useLayoutEffect:j.useEffect;function wo(t,e=[]){const n=j.useRef(t);return yc(()=>{n.current=t}),j.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function vc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=wo(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{ro(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ro(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ro(d,e)&&(i.isPointerDown=!1,o(d))},c=Pa(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function ro(t,e){var n;const r=t.target;return r&&!Pa(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function gc(t,e){const n=j.useId();return j.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function wc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function bc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=wo(n),i=wo(e),[a,l]=j.useState(t.defaultIsOpen||!1),[u,c]=wc(r,a),d=gc(o,"disclosure"),p=j.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),h=j.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),b=j.useCallback(()=>{(c?p:h)()},[c,h,p]);return{isOpen:!!c,onOpen:h,onClose:p,onToggle:b,isControlled:u,getButtonProps:(f={})=>({...f,"aria-expanded":c,"aria-controls":d,onClick:bl(f.onClick,b)}),getDisclosureProps:(f={})=>({...f,hidden:!c,id:d})}}var Un=fe(function(e,n){const{htmlSize:r,...o}=e,s=jt("Input",o),i=nt(o),a=ec(i),l=xe("chakra-input",e.className);return I.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});Un.displayName="Input";Un.id="Input";function _c(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):_l(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var Mt=fe(function(e,n){const r=Kr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=nt(e),u=Nl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return I.jsx(de.p,{ref:n,className:xe("chakra-text",e.className),...u,...l,__css:r})});Mt.displayName="Text";var bo=t=>I.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});bo.displayName="StackDivider";var $a=t=>I.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});$a.displayName="StackItem";function xc(t){const{spacing:e,direction:n}=t,r={column:{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},"column-reverse":{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},row:{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0},"row-reverse":{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0}};return{"&":_c(n,o=>r[o])}}var rn=fe((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:u,className:c,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",b=j.useMemo(()=>xc({spacing:i,direction:h}),[i,h]),f=!!u,y=!d&&!f,m=j.useMemo(()=>{const _=hs(l);return y?_:_.map((x,k)=>{const O=typeof x.key<"u"?x.key:k,E=k+1===_.length,D=d?I.jsx($a,{children:x},O):x;if(!f)return D;const R=j.cloneElement(u,{__css:b}),$=E?null:R;return I.jsxs(j.Fragment,{children:[D,$]},O)})},[u,b,f,y,d,l]),w=xe("chakra-stack",c);return I.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:h,flexWrap:a,gap:f?void 0:i,className:w,...p,children:m})});rn.displayName="Stack";var zt=fe((t,e)=>I.jsx(rn,{align:"center",...t,direction:"row",ref:e}));zt.displayName="HStack";var ps=fe(function(e,n){const r=Kr("Heading",e),{className:o,...s}=nt(e);return I.jsx(de.h2,{ref:n,className:xe("chakra-heading",e.className),...s,__css:r})});ps.displayName="Heading";var St=de("div");St.displayName="Box";var qa=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return I.jsx(St,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});qa.displayName="Square";var kc=fe(function(e,n){const{size:r,...o}=e;return I.jsx(qa,{size:r,ref:n,borderRadius:"9999px",...o})});kc.displayName="Circle";var kn=fe(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:u};return I.jsx(de.div,{ref:n,__css:d,...c})});kn.displayName="Flex";function Ec(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Cc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=j.useState([]),s=j.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};j.useEffect(()=>i,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Ec(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function Sc(t,e,n,r){if(e==null)return r;if(!r)return t.find(i=>n(i).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let s;return o.includes(r)?(s=o.indexOf(r)+1,s===o.length&&(s=0),o[s]):(s=t.indexOf(o[0]),t[s])}return r}function Ic(){const t=j.useRef(new Map),e=t.current,n=j.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=j.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return j.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function oo(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ha(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:p,onMouseLeave:h,...b}=t,[f,y]=j.useState(!0),[m,w]=j.useState(!1),_=Ic(),x=A=>{A&&A.tagName!=="BUTTON"&&y(!1)},k=f?d:d||0,O=n&&!r,E=j.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),N=j.useCallback(A=>{m&&oo(A)&&(A.preventDefault(),A.stopPropagation(),w(!1),_.remove(document,"keyup",N,!1))},[m,_]),D=j.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!oo(A.nativeEvent)||f)return;const X=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),w(!0)),X&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,f,u,o,s,_,N]),R=j.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!oo(A.nativeEvent)||f)return;s&&A.key===" "&&(A.preventDefault(),w(!1),A.currentTarget.click())},[s,f,n,c]),$=j.useCallback(A=>{A.button===0&&(w(!1),_.remove(document,"mouseup",$,!1))},[_]),P=j.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}f||w(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",$,!1),i==null||i(A)},[n,f,i,_,$]),B=j.useCallback(A=>{A.button===0&&(f||w(!1),a==null||a(A))},[a,f]),v=j.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),T=j.useCallback(A=>{m&&(A.preventDefault(),w(!1)),h==null||h(A)},[m,h]),H=Te(e,x);return f?{...b,ref:H,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:h}:{...b,ref:H,role:"button","data-active":st(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:k,onClick:E,onMouseDown:P,onMouseUp:B,onKeyUp:R,onKeyDown:D,onMouseOver:v,onMouseLeave:T}}function Oc(t){const e=t.current;if(!e)return!1;const n=El(e);return!n||e.contains(n)?!1:!!Cl(n)}function Va(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;$r(()=>{if(!s||Oc(t))return;const i=(o==null?void 0:o.current)||t.current;let a;if(i)return a=requestAnimationFrame(()=>{i.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(a)}},[s,t,o])}var Dc={preventScroll:!0,shouldFocus:!1};function Pc(t,e=Dc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=jc(t)?t.current:t,a=o&&s,l=j.useRef(a),u=j.useRef(s);xl(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=j.useCallback(()=>{if(!(!s||!i||!l.current)&&(l.current=!1,!i.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=kl(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);$r(()=>{c()},[c]),nn(i,"transitionend",c)}function jc(t){return"current"in t}var Jt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Jt("--popper-arrow-shadow-color"),arrowSize:Jt("--popper-arrow-size","8px"),arrowSizeHalf:Jt("--popper-arrow-size-half"),arrowBg:Jt("--popper-arrow-bg"),transformOrigin:Jt("--popper-transform-origin"),arrowOffset:Jt("--popper-arrow-offset")};function Ac(t){if(t.includes("top"))return"1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("bottom"))return"-1px -1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("right"))return"-1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("left"))return"1px -1px 0px 0 var(--popper-arrow-shadow-color)"}var Nc={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},Fc=t=>Nc[t],Vs={scroll:!0,resize:!0};function Rc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Vs,...t}}:e={enabled:t,options:Vs},e}var Tc={name:"matchWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>()=>{const e=t.elements.reference;t.elements.popper.style.width=`${e.offsetWidth}px`}},Bc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Zs(t)},effect:({state:t})=>()=>{Zs(t)}},Zs=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,Fc(t.placement))},Mc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{zc(t)}},zc=t=>{var e;if(!t.placement)return;const n=Lc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:Ae.arrowSize.varRef,height:Ae.arrowSize.varRef,zIndex:-1});const r={[Ae.arrowSizeHalf.var]:`calc(${Ae.arrowSize.varRef} / 2 - 1px)`,[Ae.arrowOffset.var]:`calc(${Ae.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},Lc=t=>{if(t.startsWith("top"))return{property:"bottom",value:Ae.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:Ae.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:Ae.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:Ae.arrowOffset.varRef}},Wc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{Gs(t)},effect:({state:t})=>()=>{Gs(t)}},Gs=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Ac(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:Ae.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Uc={"start-start":{ltr:"left-start",rtl:"right-start"},"start-end":{ltr:"left-end",rtl:"right-end"},"end-start":{ltr:"right-start",rtl:"left-start"},"end-end":{ltr:"right-end",rtl:"left-end"},start:{ltr:"left",rtl:"right"},end:{ltr:"right",rtl:"left"}},Kc={"auto-start":"auto-end","auto-end":"auto-start","top-start":"top-end","top-end":"top-start","bottom-start":"bottom-end","bottom-end":"bottom-start"};function $c(t,e="ltr"){var n,r;const o=((n=Uc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=Kc[t])!=null?r:o}var Ke="top",Qe="bottom",et="right",$e="left",ms="auto",Kn=[Ke,Qe,et,$e],ln="start",An="end",qc="clippingParents",Za="viewport",wn="popper",Hc="reference",Ys=Kn.reduce(function(t,e){return t.concat([e+"-"+ln,e+"-"+An])},[]),Ga=[].concat(Kn,[ms]).reduce(function(t,e){return t.concat([e,e+"-"+ln,e+"-"+An])},[]),Vc="beforeRead",Zc="read",Gc="afterRead",Yc="beforeMain",Jc="main",Xc="afterMain",Qc="beforeWrite",eu="write",tu="afterWrite",nu=[Vc,Zc,Gc,Yc,Jc,Xc,Qc,eu,tu];function ct(t){return t?(t.nodeName||"").toLowerCase():null}function Ze(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function qt(t){var e=Ze(t).Element;return t instanceof e||t instanceof Element}function Xe(t){var e=Ze(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ys(t){if(typeof ShadowRoot>"u")return!1;var e=Ze(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function ru(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!Xe(s)||!ct(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function ou(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,u){return l[u]="",l},{});!Xe(o)||!ct(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const su={name:"applyStyles",enabled:!0,phase:"write",fn:ru,effect:ou,requires:["computeStyles"]};function lt(t){return t.split("-")[0]}var Lt=Math.max,kr=Math.min,cn=Math.round;function _o(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Ya(){return!/^((?!chrome|android).)*safari/i.test(_o())}function un(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xe(t)&&(o=t.offsetWidth>0&&cn(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&cn(r.height)/t.offsetHeight||1);var i=qt(t)?Ze(t):window,a=i.visualViewport,l=!Ya()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/o,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:c,right:u+d,bottom:c+p,left:u,x:u,y:c}}function vs(t){var e=un(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function Ja(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ys(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function gt(t){return Ze(t).getComputedStyle(t)}function au(t){return["table","td","th"].indexOf(ct(t))>=0}function Nt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function Zr(t){return ct(t)==="html"?t:t.assignedSlot||t.parentNode||(ys(t)?t.host:null)||Nt(t)}function Js(t){return!Xe(t)||gt(t).position==="fixed"?null:t.offsetParent}function iu(t){var e=/firefox/i.test(_o()),n=/Trident/i.test(_o());if(n&&Xe(t)){var r=gt(t);if(r.position==="fixed")return null}var o=Zr(t);for(ys(o)&&(o=o.host);Xe(o)&&["html","body"].indexOf(ct(o))<0;){var s=gt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function $n(t){for(var e=Ze(t),n=Js(t);n&&au(n)&>(n).position==="static";)n=Js(n);return n&&(ct(n)==="html"||ct(n)==="body"&>(n).position==="static")?e:n||iu(t)||e}function gs(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function En(t,e,n){return Lt(t,kr(e,n))}function lu(t,e,n){var r=En(t,e,n);return r>n?n:r}function Xa(){return{top:0,right:0,bottom:0,left:0}}function Qa(t){return Object.assign({},Xa(),t)}function ei(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var cu=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,Qa(typeof e!="number"?e:ei(e,Kn))};function uu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=lt(n.placement),l=gs(a),u=[$e,et].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=cu(o.padding,n),p=vs(s),h=l==="y"?Ke:$e,b=l==="y"?Qe:et,f=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],y=i[l]-n.rects.reference[l],m=$n(s),w=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=f/2-y/2,x=d[h],k=w-p[c]-d[b],O=w/2-p[c]/2+_,E=En(x,O,k),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function du(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||Ja(e.elements.popper,o)&&(e.elements.arrow=o))}const fu={name:"arrow",enabled:!0,phase:"main",fn:uu,effect:du,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function dn(t){return t.split("-")[1]}var hu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function pu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:cn(n*o)/o||0,y:cn(r*o)/o||0}}function Xs(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,b=i.y,f=b===void 0?0:b,y=typeof c=="function"?c({x:h,y:f}):{x:h,y:f};h=y.x,f=y.y;var m=i.hasOwnProperty("x"),w=i.hasOwnProperty("y"),_=$e,x=Ke,k=window;if(u){var O=$n(n),E="clientHeight",N="clientWidth";if(O===Ze(n)&&(O=Nt(n),gt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===et)&&s===An){x=Qe;var D=d&&O===k&&k.visualViewport?k.visualViewport.height:O[E];f-=D-r.height,f*=l?1:-1}if(o===$e||(o===Ke||o===Qe)&&s===An){_=et;var R=d&&O===k&&k.visualViewport?k.visualViewport.width:O[N];h-=R-r.width,h*=l?1:-1}}var $=Object.assign({position:a},u&&hu),P=c===!0?pu({x:h,y:f},Ze(n)):{x:h,y:f};if(h=P.x,f=P.y,l){var B;return Object.assign({},$,(B={},B[x]=w?"0":"",B[_]=m?"0":"",B.transform=(k.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",B))}return Object.assign({},$,(e={},e[x]=w?f+"px":"",e[_]=m?h+"px":"",e.transform="",e))}function mu(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:lt(e.placement),variation:dn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Xs(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Xs(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const yu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:mu,data:{}};var Qn={passive:!0};function vu(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=Ze(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const gu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:vu,data:{}};var wu={left:"right",right:"left",bottom:"top",top:"bottom"};function cr(t){return t.replace(/left|right|bottom|top/g,function(e){return wu[e]})}var bu={start:"end",end:"start"};function Qs(t){return t.replace(/start|end/g,function(e){return bu[e]})}function ws(t){var e=Ze(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function bs(t){return un(Nt(t)).left+ws(t).scrollLeft}function _u(t,e){var n=Ze(t),r=Nt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=Ya();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+bs(t),y:l}}function xu(t){var e,n=Nt(t),r=ws(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Lt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Lt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+bs(t),l=-r.scrollTop;return gt(o||n).direction==="rtl"&&(a+=Lt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function _s(t){var e=gt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ti(t){return["html","body","#document"].indexOf(ct(t))>=0?t.ownerDocument.body:Xe(t)&&_s(t)?t:ti(Zr(t))}function Cn(t,e){var n;e===void 0&&(e=[]);var r=ti(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ze(r),i=o?[s].concat(s.visualViewport||[],_s(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Cn(Zr(i)))}function xo(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function ku(t,e){var n=un(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function ea(t,e,n){return e===Za?xo(_u(t,n)):qt(e)?ku(e,n):xo(xu(Nt(t)))}function Eu(t){var e=Cn(Zr(t)),n=["absolute","fixed"].indexOf(gt(t).position)>=0,r=n&&Xe(t)?$n(t):t;return qt(r)?e.filter(function(o){return qt(o)&&Ja(o,r)&&ct(o)!=="body"}):[]}function Cu(t,e,n,r){var o=e==="clippingParents"?Eu(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=ea(t,u,r);return l.top=Lt(c.top,l.top),l.right=kr(c.right,l.right),l.bottom=kr(c.bottom,l.bottom),l.left=Lt(c.left,l.left),l},ea(t,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ni(t){var e=t.reference,n=t.element,r=t.placement,o=r?lt(r):null,s=r?dn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case Ke:l={x:i,y:e.y-n.height};break;case Qe:l={x:i,y:e.y+e.height};break;case et:l={x:e.x+e.width,y:a};break;case $e:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?gs(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case ln:l[u]=l[u]-(e[c]/2-n[c]/2);break;case An:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Nn(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,i=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?qc:a,u=n.rootBoundary,c=u===void 0?Za:u,d=n.elementContext,p=d===void 0?wn:d,h=n.altBoundary,b=h===void 0?!1:h,f=n.padding,y=f===void 0?0:f,m=Qa(typeof y!="number"?y:ei(y,Kn)),w=p===wn?Hc:wn,_=t.rects.popper,x=t.elements[b?w:p],k=Cu(qt(x)?x:x.contextElement||Nt(t.elements.popper),l,c,i),O=un(t.elements.reference),E=ni({reference:O,element:_,strategy:"absolute",placement:o}),N=xo(Object.assign({},_,E)),D=p===wn?N:O,R={top:k.top-D.top+m.top,bottom:D.bottom-k.bottom+m.bottom,left:k.left-D.left+m.left,right:D.right-k.right+m.right},$=t.modifiersData.offset;if(p===wn&&$){var P=$[o];Object.keys(R).forEach(function(B){var v=[et,Qe].indexOf(B)>=0?1:-1,T=[Ke,Qe].indexOf(B)>=0?"y":"x";R[B]+=P[T]*v})}return R}function Su(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?Ga:l,c=dn(r),d=c?a?Ys:Ys.filter(function(b){return dn(b)===c}):Kn,p=d.filter(function(b){return u.indexOf(b)>=0});p.length===0&&(p=d);var h=p.reduce(function(b,f){return b[f]=Nn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[lt(f)],b},{});return Object.keys(h).sort(function(b,f){return h[b]-h[f]})}function Iu(t){if(lt(t)===ms)return[];var e=cr(t);return[Qs(t),e,Qs(e)]}function Ou(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,b=h===void 0?!0:h,f=n.allowedAutoPlacements,y=e.options.placement,m=lt(y),w=m===y,_=l||(w||!b?[cr(y)]:Iu(y)),x=[y].concat(_).reduce(function(J,G){return J.concat(lt(G)===ms?Su(e,{placement:G,boundary:c,rootBoundary:d,padding:u,flipVariations:b,allowedAutoPlacements:f}):G)},[]),k=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,D=x[0],R=0;R=0,T=v?"width":"height",H=Nn(e,{placement:$,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),A=v?B?et:$e:B?Qe:Ke;k[T]>O[T]&&(A=cr(A));var X=cr(A),K=[];if(s&&K.push(H[P]<=0),a&&K.push(H[A]<=0,H[X]<=0),K.every(function(J){return J})){D=$,N=!1;break}E.set($,K)}if(N)for(var ne=b?3:1,z=function(G){var me=x.find(function(we){var ie=E.get(we);if(ie)return ie.slice(0,G).every(function(ue){return ue})});if(me)return D=me,"break"},M=ne;M>0;M--){var te=z(M);if(te==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const Du={name:"flip",enabled:!0,phase:"main",fn:Ou,requiresIfExists:["offset"],data:{_skip:!1}};function ta(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function na(t){return[Ke,et,Qe,$e].some(function(e){return t[e]>=0})}function Pu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Nn(e,{elementContext:"reference"}),a=Nn(e,{altBoundary:!0}),l=ta(i,r),u=ta(a,o,s),c=na(l),d=na(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const ju={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Pu};function Au(t,e,n){var r=lt(t),o=[$e,Ke].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[$e,et].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function Nu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=Ga.reduce(function(c,d){return c[d]=Au(d,e.rects,s),c},{}),a=i[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=i}const Fu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Nu};function Ru(t){var e=t.state,n=t.name;e.modifiersData[n]=ni({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Tu={name:"popperOffsets",enabled:!0,phase:"read",fn:Ru,data:{}};function Bu(t){return t==="x"?"y":"x"}function Mu(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,b=n.tetherOffset,f=b===void 0?0:b,y=Nn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),m=lt(e.placement),w=dn(e.placement),_=!w,x=gs(m),k=Bu(x),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,D=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(O){if(s){var B,v=x==="y"?Ke:$e,T=x==="y"?Qe:et,H=x==="y"?"height":"width",A=O[x],X=A+y[v],K=A-y[T],ne=h?-N[H]/2:0,z=w===ln?E[H]:N[H],M=w===ln?-N[H]:-E[H],te=e.elements.arrow,J=h&&te?vs(te):{width:0,height:0},G=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Xa(),me=G[v],we=G[T],ie=En(0,E[H],J[H]),ue=_?E[H]/2-ne-ie-me-R.mainAxis:z-ie-me-R.mainAxis,_e=_?-E[H]/2+ne+ie+we+R.mainAxis:M+ie+we+R.mainAxis,ye=e.elements.arrow&&$n(e.elements.arrow),pe=ye?x==="y"?ye.clientTop||0:ye.clientLeft||0:0,ke=(B=$==null?void 0:$[x])!=null?B:0,g=A+ue-ke-pe,U=A+_e-ke,W=En(h?kr(X,g):X,A,h?Lt(K,U):K);O[x]=W,P[x]=W-A}if(a){var S,C=x==="x"?Ke:$e,F=x==="x"?Qe:et,V=O[k],Z=k==="y"?"height":"width",L=V+y[C],Q=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(S=$==null?void 0:$[k])!=null?S:0,se=re?L:V-E[Z]-N[Z]-ee+R.altAxis,ve=re?V+E[Z]+N[Z]-ee-R.altAxis:Q,he=h&&re?lu(se,V,ve):En(h?se:L,V,h?ve:Q);O[k]=he,P[k]=he-V}e.modifiersData[r]=P}}const zu={name:"preventOverflow",enabled:!0,phase:"main",fn:Mu,requiresIfExists:["offset"]};function Lu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Wu(t){return t===Ze(t)||!Xe(t)?ws(t):Lu(t)}function Uu(t){var e=t.getBoundingClientRect(),n=cn(e.width)/t.offsetWidth||1,r=cn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Ku(t,e,n){n===void 0&&(n=!1);var r=Xe(e),o=Xe(e)&&Uu(e),s=Nt(e),i=un(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((ct(e)!=="body"||_s(s))&&(a=Wu(e)),Xe(e)?(l=un(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=bs(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function $u(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function qu(t){var e=$u(t);return nu.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Hu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Vu(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var ra={placement:"bottom",modifiers:[],strategy:"absolute"};function oa(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=j.useCallback(()=>{var R;!e||!b.current||!f.current||((R=w.current)==null||R.call(w),y.current=Yu(b.current,f.current,{placement:m,modifiers:[Wc,Mc,Bc,{...Tc,enabled:!!p},{name:"eventListeners",...Rc(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),y.current.forceUpdate(),w.current=y.current.destroy)},[m,e,n,p,i,s,a,l,u,d,c,o]);j.useEffect(()=>()=>{var R;!b.current&&!f.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const x=j.useCallback(R=>{b.current=R,_()},[_]),k=j.useCallback((R={},$=null)=>({...R,ref:Te(x,$)}),[x]),O=j.useCallback(R=>{f.current=R,_()},[_]),E=j.useCallback((R={},$=null)=>({...R,ref:Te(O,$),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,O,p]),N=j.useCallback((R={},$=null)=>{const{size:P,shadowColor:B,bg:v,style:T,...H}=R;return{...H,ref:$,"data-popper-arrow":"",style:Ju(R)}},[]),D=j.useCallback((R={},$=null)=>({...R,ref:$,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=y.current)==null||R.update()},forceUpdate(){var R;(R=y.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:D,getReferenceProps:k}}function Ju(t){const{size:e,shadowColor:n,bg:r,style:o}=t,s={...o,position:"absolute"};return e&&(s["--popper-arrow-size"]=e),n&&(s["--popper-arrow-shadow-color"]=n),r&&(s["--popper-arrow-bg"]=r),s}function ks(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Bt(n),i=Bt(e),[a,l]=j.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=j.useId(),p=o??`disclosure-${d}`,h=j.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),b=j.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),f=j.useCallback(()=>{u?h():b()},[u,b,h]);function y(w={}){return{...w,"aria-expanded":u,"aria-controls":p,onClick(_){var x;(x=w.onClick)==null||x.call(w,_),f()}}}function m(w={}){return{...w,hidden:!u,id:p}}return{isOpen:u,onOpen:b,onClose:h,onToggle:f,isControlled:c,getButtonProps:y,getDisclosureProps:m}}function Xu(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Bt(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{so(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&so(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&so(d,e)&&(i.isPointerDown=!1,o(d))},c=ri(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function so(t,e){var n;const r=t.target;return r&&!ri(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function ri(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function oi(t){const{isOpen:e,ref:n}=t,[r,o]=j.useState(e),[s,i]=j.useState(!1);return j.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),nn(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Sl(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function Es(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[Qu,ed,td,nd]=Na(),[rd,qn]=tt({strict:!1,name:"MenuContext"});function od(t,...e){const n=j.useId(),r=t||n;return j.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function si(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function sa(t){return si(t).activeElement===t}function sd(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:b=!1,...f}=t,y=j.useRef(null),m=j.useRef(null),w=td(),_=j.useCallback(()=>{requestAnimationFrame(()=>{var te;(te=y.current)==null||te.focus({preventScroll:!1})})},[]),x=j.useCallback(()=>{const te=setTimeout(()=>{var J;if(o)(J=o.current)==null||J.focus();else{const G=w.firstEnabled();G&&B(G.index)}});X.current.add(te)},[w,o]),k=j.useCallback(()=>{const te=setTimeout(()=>{const J=w.lastEnabled();J&&B(J.index)});X.current.add(te)},[w]),O=j.useCallback(()=>{c==null||c(),s?x():_()},[s,x,_,c]),{isOpen:E,onOpen:N,onClose:D,onToggle:R}=ks({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:O});Xu({enabled:E&&r,ref:y,handler:te=>{var J;(J=m.current)!=null&&J.contains(te.target)||D()}});const $=xs({...f,enabled:E||b,placement:d,direction:h}),[P,B]=j.useState(-1);$r(()=>{E||B(-1)},[E]),Va(y,{focusRef:m,visible:E,shouldFocus:!0});const v=oi({isOpen:E,ref:y}),[T,H]=od(e,"menu-button","menu-list"),A=j.useCallback(()=>{N(),_()},[N,_]),X=j.useRef(new Set([]));j.useEffect(()=>{const te=X.current;return()=>{te.forEach(J=>clearTimeout(J)),te.clear()}},[]);const K=j.useCallback(()=>{N(),x()},[x,N]),ne=j.useCallback(()=>{N(),k()},[N,k]),z=j.useCallback(()=>{var te,J;const G=si(y.current),me=(te=y.current)==null?void 0:te.contains(G.activeElement);if(!(E&&!me))return;const ie=(J=w.item(P))==null?void 0:J.node;ie==null||ie.focus({preventScroll:!0})},[E,P,w]),M=j.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:K,openAndFocusLastItem:ne,onTransitionEnd:z,unstable__animationState:v,descendants:w,popper:$,buttonId:T,menuId:H,forceUpdate:$.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:D,menuRef:y,buttonRef:m,focusedIndex:P,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:B,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:M}}function op(t={},e=null){const n=qn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=j.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Te(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":st(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function ko(t){var e;return ld(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function ad(t={},e=null){const n=qn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:i,onClose:a,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,p=ed(),h=Cc({preventDefault:m=>m.key!==" "&&ko(m.target)}),b=j.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const w=m.key,x={Tab:O=>O.preventDefault(),Escape:a,ArrowDown:()=>{const O=p.nextEnabled(r);O&&o(O.index)},ArrowUp:()=>{const O=p.prevEnabled(r);O&&o(O.index)}}[w];if(x){m.preventDefault(),x(m);return}const k=h(O=>{const E=Sc(p.values(),O,N=>{var D,R;return(R=(D=N==null?void 0:N.node)==null?void 0:D.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});ko(m.target)&&k(m)},[p,r,h,a,o]),f=j.useRef(!1);i&&(f.current=!0);const y=Es({wasSelected:f.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Te(s,e),children:y?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Oe(t.onKeyDown,b)}}function id(t={}){const{popper:e,isOpen:n}=qn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function ai(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:u,type:c,...d}=t,p=qn(),{setFocusedIndex:h,focusedIndex:b,closeOnSelect:f,onClose:y,menuRef:m,isOpen:w,menuId:_,rafId:x}=p,k=j.useRef(null),O=`${_}-menuitem-${j.useId()}`,{index:E,register:N}=nd({disabled:a&&!l}),D=j.useCallback(A=>{n==null||n(A),!a&&h(E)},[h,E,a,n]),R=j.useCallback(A=>{r==null||r(A),k.current&&!sa(k.current)&&D(A)},[D,r]),$=j.useCallback(A=>{o==null||o(A),!a&&h(-1)},[h,a,o]),P=j.useCallback(A=>{s==null||s(A),ko(A.currentTarget)&&(u??f)&&y()},[y,s,f,u]),B=j.useCallback(A=>{i==null||i(A),h(E)},[h,i,E]),v=E===b,T=a&&!l;$r(()=>{if(w)return v&&!T&&k.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=k.current)==null||A.focus({preventScroll:!0}),x.current=null})):m.current&&!sa(m.current)&&m.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[v,T,m,w]);const H=Ha({onClick:P,onFocus:B,onMouseEnter:D,onMouseMove:R,onMouseLeave:$,ref:Te(N,k,e),isDisabled:a,isFocusable:l});return{...d,...H,type:c??H.type,id:O,role:"menuitem",tabIndex:v?0:-1}}function sp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...ai(o,e),role:`menuitem${n}`,"aria-checked":r}}function ap(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Fa({defaultValue:o??l,value:r,onChange:s}),d=j.useCallback(b=>{if(n==="radio"&&typeof u=="string"&&c(b),n==="checkbox"&&Array.isArray(u)){const f=u.includes(b)?u.filter(y=>y!==b):u.concat(b);c(f)}},[u,c,n]),h=hs(e).map(b=>{if(b.type.id!=="MenuItemOption")return b;const f=m=>{var w,_;d(b.props.value),(_=(w=b.props).onClick)==null||_.call(w,m)},y=n==="radio"?b.props.value===u:u.includes(b.props.value);return j.cloneElement(b,{type:n,onClick:f,isChecked:y})});return{...i,children:h}}function ld(t){var e;if(!cd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function cd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[ud,Gr]=tt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Cs=t=>{const{children:e}=t,n=jt("Menu",t),r=nt(t),{direction:o}=os(),{descendants:s,...i}=sd({...r,direction:o}),a=j.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return I.jsx(Qu,{value:s,children:I.jsx(rd,{value:a,children:I.jsx(ud,{value:n,children:Ea(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};Cs.displayName="Menu";var ii=fe((t,e)=>{const n=Gr();return I.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});ii.displayName="MenuCommand";var dd=fe((t,e)=>{const{type:n,...r}=t,o=Gr(),s=r.as||n?n??void 0:"button",i=j.useMemo(()=>({textDecoration:"none",color:"inherit",userSelect:"none",display:"flex",width:"100%",alignItems:"center",textAlign:"start",flex:"0 0 auto",outline:0,...o.item}),[o.item]);return I.jsx(de.button,{ref:e,type:s,...r,__css:i})}),li=t=>{const{className:e,children:n,...r}=t,o=Gr(),s=j.Children.only(n),i=j.isValidElement(s)?j.cloneElement(s,{focusable:"false","aria-hidden":!0,className:xe("chakra-menu__icon",s.props.className)}):null,a=xe("chakra-menu__icon-wrapper",e);return I.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};li.displayName="MenuIcon";var _t=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=ai(a,e),c=n||o?I.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return I.jsxs(dd,{...l,className:xe("chakra-menu__menuitem",l.className),children:[n&&I.jsx(li,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&I.jsx(ii,{marginStart:s,children:o})]})});_t.displayName="MenuItem";var fd={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},hd=de(ss.div),Ss=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=qn(),d=ad(a,n),p=id(s),h=Gr();return I.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:I.jsx(hd,{variants:fd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:xe("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Ca(c.onComplete,d.onAnimationComplete)})})});Ss.displayName="MenuList";var[pd,Hn]=tt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[md,Is]=tt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ci(t){const e=j.Children.only(t.children),{getTriggerProps:n}=Hn();return j.cloneElement(e,n(e.props,e.ref))}ci.displayName="PopoverTrigger";var Xt={click:"click",hover:"hover"};function yd(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=Xt.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:b,...f}=t,{isOpen:y,onClose:m,onOpen:w,onToggle:_}=ks(t),x=j.useRef(null),k=j.useRef(null),O=j.useRef(null),E=j.useRef(!1),N=j.useRef(!1);y&&(N.current=!0);const[D,R]=j.useState(!1),[$,P]=j.useState(!1),B=j.useId(),v=o??B,[T,H,A,X]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${v}`),{referenceRef:K,getArrowProps:ne,getPopperProps:z,getArrowInnerProps:M,forceUpdate:te}=xs({...f,enabled:y||!!b}),J=oi({isOpen:y,ref:O});lc({enabled:y,ref:k}),Va(O,{focusRef:k,visible:y,shouldFocus:s&&u===Xt.click}),Pc(O,{focusRef:r,visible:y,shouldFocus:i&&u===Xt.click});const G=Es({wasSelected:N.current,enabled:p,mode:h,isSelected:J.present}),me=j.useCallback((U={},W=null)=>{const S={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Te(O,W),children:G?U.children:null,id:H,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,C=>{n&&C.key==="Escape"&&m()}),onBlur:Oe(U.onBlur,C=>{const F=aa(C),V=ao(O.current,F),Z=ao(k.current,F);y&&e&&(!V&&!Z)&&m()}),"aria-labelledby":D?A:void 0,"aria-describedby":$?X:void 0};return u===Xt.hover&&(S.role="tooltip",S.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),S.onMouseLeave=Oe(U.onMouseLeave,C=>{C.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),S},[G,H,D,A,$,X,u,n,m,y,e,d,l,a]),we=j.useCallback((U={},W=null)=>z({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,z]),ie=j.useCallback((U,W=null)=>({...U,ref:Te(W,x,K)}),[x,K]),ue=j.useRef(),_e=j.useRef(),ye=j.useCallback(U=>{x.current==null&&K(U)},[K]),pe=j.useCallback((U={},W=null)=>{const S={...U,ref:Te(k,W,ye),id:T,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":H};return u===Xt.click&&(S.onClick=Oe(U.onClick,_)),u===Xt.hover&&(S.onFocus=Oe(U.onFocus,()=>{ue.current===void 0&&w()}),S.onBlur=Oe(U.onBlur,C=>{const F=aa(C),V=!ao(O.current,F);y&&e&&V&&m()}),S.onKeyDown=Oe(U.onKeyDown,C=>{C.key==="Escape"&&m()}),S.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>w(),c)}),S.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),_e.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),S},[T,y,H,u,ye,_,w,e,m,c,d]);j.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),_e.current&&clearTimeout(_e.current)},[]);const ke=j.useCallback((U={},W=null)=>({...U,id:A,ref:Te(W,S=>{R(!!S)})}),[A]),g=j.useCallback((U={},W=null)=>({...U,id:X,ref:Te(W,S=>{P(!!S)})}),[X]);return{forceUpdate:te,isOpen:y,onAnimationComplete:J.onComplete,onClose:m,getAnchorProps:ie,getArrowProps:ne,getArrowInnerProps:M,getPopoverPositionerProps:we,getPopoverProps:me,getTriggerProps:pe,getHeaderProps:ke,getBodyProps:g}}function ao(t,e){return t===e||(t==null?void 0:t.contains(e))}function aa(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function ui(t){const e=jt("Popover",t),{children:n,...r}=nt(t),o=os(),s=yd({...r,direction:o.direction});return I.jsx(pd,{value:s,children:I.jsx(md,{value:e,children:Ea(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}ui.displayName="Popover";var di=fe(function(e,n){const{getBodyProps:r}=Hn(),o=Is();return I.jsx(de.div,{...r(e,n),className:xe("chakra-popover__body",e.className),__css:o.body})});di.displayName="PopoverBody";var fi=fe(function(e,n){const{onClose:r}=Hn(),o=Is();return I.jsx(Il,{size:"sm",onClick:r,className:xe("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});fi.displayName="PopoverCloseButton";function vd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var gd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},wd=de(ss.section),hi=fe(function(e,n){const{variants:r=gd,...o}=e,{isOpen:s}=Hn();return I.jsx(wd,{ref:n,variants:vd(r),initial:!1,animate:s?"enter":"exit",...o})});hi.displayName="PopoverTransition";var pi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=Hn(),u=Is(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return I.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:I.jsx(hi,{...o,...i(s,n),onAnimationComplete:Ca(l,s.onAnimationComplete),className:xe("chakra-popover__content",e.className),__css:c})})});pi.displayName="PopoverContent";var[bd,_d,xd,kd]=Na();function Ed(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,p]=j.useState(n??0),[h,b]=Fa({defaultValue:n??0,value:o,onChange:r});j.useEffect(()=>{o!=null&&p(o)},[o]);const f=xd(),y=j.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:b,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:u,htmlProps:c}}var[Cd,Yr]=tt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Sd(t){const{focusedIndex:e,orientation:n,direction:r}=Yr(),o=_d(),s=j.useCallback(i=>{const a=()=>{var w;const _=o.nextEnabled(e);_&&((w=_.node)==null||w.focus())},l=()=>{var w;const _=o.prevEnabled(e);_&&((w=_.node)==null||w.focus())},u=()=>{var w;const _=o.firstEnabled();_&&((w=_.node)==null||w.focus())},c=()=>{var w;const _=o.lastEnabled();_&&((w=_.node)==null||w.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,b=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",m={[b]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[h];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Id(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Yr(),{index:u,register:c}=kd({disabled:e&&!n}),d=u===l,p=()=>{o(u)},h=()=>{a(u),!s&&!(e&&n)&&o(u)},b=Ha({...r,ref:Te(c,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...b,id:mi(i,u),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":yi(i,u),onFocus:e?void 0:Oe(t.onFocus,h)}}var[Od,Dd]=tt({});function Pd(t){const e=Yr(),{id:n,selectedIndex:r}=e,s=hs(t.children).map((i,a)=>j.createElement(Od,{key:a,value:{isSelected:a===r,id:yi(n,a),tabId:mi(n,a),selectedIndex:r}},i));return{...t,children:s}}function jd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Yr(),{isSelected:s,id:i,tabId:a}=Dd(),l=j.useRef(!1);s&&(l.current=!0);const u=Es({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function mi(t,e){return`${t}--tab-${e}`}function yi(t,e){return`${t}--tabpanel-${e}`}var[Ad,Jr]=tt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),vi=fe(function(e,n){const r=jt("Tabs",e),{children:o,className:s,...i}=nt(e),{htmlProps:a,descendants:l,...u}=Ed(i),c=j.useMemo(()=>u,[u]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return I.jsx(bd,{value:l,children:I.jsx(Cd,{value:c,children:I.jsx(Ad,{value:r,children:I.jsx(de.div,{className:xe("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});vi.displayName="Tabs";var gi=fe(function(e,n){const r=Sd({...e,ref:n}),s={display:"flex",...Jr().tablist};return I.jsx(de.div,{...r,className:xe("chakra-tabs__tablist",e.className),__css:s})});gi.displayName="TabList";var Eo=fe(function(e,n){const r=jd({...e,ref:n}),o=Jr();return I.jsx(de.div,{outline:"0",...r,className:xe("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Eo.displayName="TabPanel";var wi=fe(function(e,n){const r=Pd(e),o=Jr();return I.jsx(de.div,{...r,width:"100%",ref:n,className:xe("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});wi.displayName="TabPanels";var Co=fe(function(e,n){const r=Jr(),o=Id({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return I.jsx(de.button,{...o,className:xe("chakra-tabs__tab",e.className),__css:s})});Co.displayName="Tab";var[Nd,bi]=tt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xr=fe((t,e)=>{const n=jt("Tag",t),r=nt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return I.jsx(Nd,{value:n,children:I.jsx(de.span,{ref:e,...r,__css:o})})});Xr.displayName="Tag";var Fd=fe((t,e)=>{const n=bi();return I.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});Fd.displayName="TagLabel";var Rd=fe((t,e)=>I.jsx(Ur,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Rd.displayName="TagLeftIcon";var Td=fe((t,e)=>I.jsx(Ur,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Td.displayName="TagRightIcon";var _i=t=>I.jsx(Ur,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:I.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});_i.displayName="TagCloseIcon";var Bd=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...bi().closeButton};return I.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||I.jsx(_i,{})})});Bd.displayName="TagCloseButton";var Md={exit:{scale:.85,opacity:0,transition:{opacity:{duration:.15,easings:"easeInOut"},scale:{duration:.2,easings:"easeInOut"}}},enter:{scale:1,opacity:1,transition:{opacity:{easings:"easeOut",duration:.2},scale:{duration:.2,ease:[.175,.885,.4,1.1]}}}},So=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},ur=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function zd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:p,defaultIsOpen:h,arrowSize:b=10,arrowShadowColor:f,arrowPadding:y,modifiers:m,isDisabled:w,gutter:_,offset:x,direction:k,...O}=t,{isOpen:E,onOpen:N,onClose:D}=ks({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:u}),{referenceRef:R,getPopperProps:$,getArrowInnerProps:P,getArrowProps:B}=xs({enabled:E,placement:c,arrowPadding:y,modifiers:m,gutter:_,offset:x,direction:k}),v=j.useId(),H=`tooltip-${d??v}`,A=j.useRef(null),X=j.useRef(),K=j.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=void 0)},[]),ne=j.useRef(),z=j.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),M=j.useCallback(()=>{z(),D()},[D,z]),te=Ld(A,M),J=j.useCallback(()=>{if(!w&&!X.current){E&&te();const pe=ur(A);X.current=pe.setTimeout(N,e)}},[te,w,E,N,e]),G=j.useCallback(()=>{K();const pe=ur(A);ne.current=pe.setTimeout(M,n)},[n,M,K]),me=j.useCallback(()=>{E&&r&&G()},[r,G,E]),we=j.useCallback(()=>{E&&i&&G()},[i,G,E]),ie=j.useCallback(pe=>{E&&pe.key==="Escape"&&G()},[E,G]);nn(()=>So(A),"keydown",a?ie:void 0),nn(()=>{if(!s)return null;const pe=A.current;if(!pe)return null;const ke=Ka(pe);return ke.localName==="body"?ur(A):ke},"scroll",()=>{E&&s&&M()},{passive:!0,capture:!0}),j.useEffect(()=>{w&&(K(),E&&D())},[w,E,D,K]),j.useEffect(()=>()=>{K(),z()},[K,z]),nn(()=>A.current,"pointerleave",G);const ue=j.useCallback((pe={},ke=null)=>({...pe,ref:Te(A,ke,R),onPointerEnter:Oe(pe.onPointerEnter,U=>{U.pointerType!=="touch"&&J()}),onClick:Oe(pe.onClick,me),onPointerDown:Oe(pe.onPointerDown,we),onFocus:Oe(pe.onFocus,J),onBlur:Oe(pe.onBlur,G),"aria-describedby":E?H:void 0}),[J,G,we,E,H,me,R]),_e=j.useCallback((pe={},ke=null)=>$({...pe,style:{...pe.style,[Ae.arrowSize.var]:b?`${b}px`:void 0,[Ae.arrowShadowColor.var]:f}},ke),[$,b,f]),ye=j.useCallback((pe={},ke=null)=>{const g={...pe.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:ke,...O,...pe,id:H,role:"tooltip",style:g}},[O,H]);return{isOpen:E,show:J,hide:G,getTriggerProps:ue,getTooltipProps:ye,getTooltipPositionerProps:_e,getArrowProps:B,getArrowInnerProps:P}}var io="chakra-ui:close-tooltip";function Ld(t,e){return j.useEffect(()=>{const n=So(t);return n.addEventListener(io,e),()=>n.removeEventListener(io,e)},[e,t]),()=>{const n=So(t),r=ur(t);n.dispatchEvent(new r.CustomEvent(io))}}function Wd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Ud(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var Kd=de(ss.div),Ht=fe((t,e)=>{var n,r;const o=Kr("Tooltip",t),s=nt(t),i=os(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:h,background:b,backgroundColor:f,bgColor:y,motionProps:m,...w}=s,_=(r=(n=b??f)!=null?n:p)!=null?r:y;if(_){o.bg=_;const $=Ol(i,"colors",_);o[Ae.arrowBg.var]=$}const x=zd({...w,direction:i.direction}),k=typeof a=="string"||u;let O;if(k)O=I.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const $=j.Children.only(a);O=j.cloneElement($,x.getTriggerProps($.props,$.ref))}const E=!!c,N=x.getTooltipProps({},e),D=E?Wd(N,["role","id"]):N,R=Ud(N,["role","id"]);return l?I.jsxs(I.Fragment,{children:[O,I.jsx(Dl,{children:x.isOpen&&I.jsx(Sa,{...h,children:I.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:I.jsxs(Kd,{variants:Md,initial:"exit",animate:"enter",exit:"exit",...m,...D,__css:o,children:[l,E&&I.jsx(de.span,{srOnly:!0,...R,children:c}),d&&I.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:I.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):I.jsx(I.Fragment,{children:a})});Ht.displayName="Tooltip";const $d="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=$d[n[t]&63];return e},Pe=null;const xi=location.pathname.split("/").slice(0,-1).join("/");let Er=null;At(()=>import(xi+"/scripts/api.js"),__vite__mapDeps([])).then(t=>{Er=t==null?void 0:t.api});At(()=>import(xi+"/scripts/app.js"),__vite__mapDeps([])).then(t=>{Pe=t==null?void 0:t.app});function Se(t,e){if(Er==null)throw console.error("api is null!"),new Error("api is null!");return Er.fetchApi(t,e)}async function qd(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await Se(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function Hd(t,e){try{return await(await Se("/workspace/save_db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t,json:e})})).text()}catch(n){console.error("Error saving workspace:",n)}}async function ip(t){try{return await(await Se("/workspace/get_system_dir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absolute_dir:t??""})})).json()}catch(e){console.error("Error getting workflows dir:",e)}}async function lp(){try{return await(await Se("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function Vd(){const e=await(await Se("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function cp(){try{return await(await Se("/model_manager/get_model_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function up(){try{return await(await Se("/model_manager/get_folder_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function dp(t){try{return await(await Se("/model_manager/cancel_installation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({save_path:t})})).text()}catch(e){console.error("Error move file:",e)}}async function fp(t,e){try{return await(await Se("/workspace/copy_json_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:t,dst:e})})).json()}catch(n){console.error("Error copy flows to new directory:",n)}}const Zd="backup",Cr="workspace";let er=null;function Gd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(Cr)||o.createObjectStore(Cr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Yd(){try{return er==null&&(er=await Gd()),new Promise((t,e)=>{if(er==null)return e("indexDB is null");const o=er.transaction([Cr],"readonly").objectStore(Cr).get(Zd);o.onsuccess=()=>{o.result?t(o.result.value):t(void 0)},o.onerror=()=>e(o.error)})}catch(t){console.error("Error while reading from database:",t)}}async function Jd(){try{return await Yd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ee=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ne=Object.keys,Me=Array.isArray;function We(t,e){return typeof e!="object"||Ne(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ee.Promise||(Ee.Promise=Promise);const Rn=Object.getPrototypeOf,Xd={}.hasOwnProperty;function Ge(t,e){return Xd.call(t,e)}function fn(t,e){typeof e=="function"&&(e=e(Rn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{yt(t,n,e[n])})}const ki=Object.defineProperty;function yt(t,e,n,r){ki(t,e,We(n&&Ge(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function on(t){return{from:function(e){return t.prototype=Object.create(e.prototype),yt(t.prototype,"constructor",t),{extend:fn.bind(null,t.prototype)}}}}const Qd=Object.getOwnPropertyDescriptor;function Os(t,e){let n;return Qd(t,e)||(n=Rn(t))&&Os(n,e)}const ef=[].slice;function Sr(t,e,n){return ef.call(t,e,n)}function Ei(t,e){return e(t)}function _n(t){if(!t)throw new Error("Assertion Failed")}function Ci(t){Ee.setImmediate?setImmediate(t):setTimeout(t,0)}function Si(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function vt(t,e){if(Ge(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,o=e.length;r["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>Ee[t]),nf=Di.map(t=>Ee[t]);Si(Di,t=>[t,!0]);let kt=null;function Vn(t){kt=typeof WeakMap<"u"&&new WeakMap;const e=Io(t);return kt=null,e}function Io(t){if(!t||typeof t!="object")return t;let e=kt&&kt.get(t);if(e)return e;if(Me(t)){e=[],kt&&kt.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Rn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),kt&&kt.set(t,e),t)Ge(t,o)&&(e[o]=Io(t[o]))}return e}const{toString:rf}={};function Oo(t){return rf.call(t).slice(8,-1)}const Do=typeof Symbol<"u"?Symbol.iterator:"@@iterator",of=typeof Do=="symbol"?function(t){var e;return t!=null&&(e=t[Do])&&e.apply(t)}:function(){return null},tn={};function pt(t){var e,n,r,o;if(arguments.length===1){if(Me(t))return t.slice();if(this===tn&&typeof t=="string")return[t];if(o=of(t)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Ds=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var ut=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Pi(t,e){ut=t,ji=e}var ji=()=>!0;const sf=!new Error("").stack;function Gt(){if(sf)try{throw Gt.arguments,new Error}catch(t){return t}return new Error}function Po(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` +var hl=Object.defineProperty;var pl=(t,e,n)=>e in t?hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(pl(t,typeof e!="symbol"?e+"":e,n),n);import{u as ml,a as yl,r as j,c as vl,b as tt,m as Te,d as Bt,f as fe,e as xe,j as I,B as gl,g as de,h as Le,i as wl,o as nt,k as jt,l as st,I as Ur,n as Kr,p as no,q as Oe,s as Ea,t as bl,v as _l,w as xl,x as $r,y as kl,z as El,A as Cl,C as Sl,D as Il,E as os,F as Ca,G as ss,H as Sa,J as Ol,K as Dl,L as Pl,P as Ia,_ as At,M as as,N as is,O as ls,Q as cs,R as us,S as ds,T as fs,U as Oa,V as Da,W as Xn,X as Pa}from"./input.js";function jl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function ja(t){var e;return jl(t)&&(e=t.ownerDocument)!=null?e:document}function Al(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Nl=Al();function Fl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Aa(t){const{theme:e}=ml(),n=yl();return j.useMemo(()=>vl(e.direction,{...n,...t}),[t,e.direction,n])}var Rl=Object.defineProperty,Tl=(t,e,n)=>e in t?Rl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(Tl(t,typeof e!="symbol"?e+"":e,n),n);function qs(t){return t.sort((e,n)=>{const r=e.compareDocumentPosition(n);if(r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS)return 1;if(r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)throw Error("Cannot sort the given nodes.");return 0})}var Bl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Hs(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Vs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var go=typeof window<"u"?j.useLayoutEffect:j.useEffect,xr=t=>t,Ml=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return Bl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=qs(Array.from(this.descendants.keys()));this.assignIndex(e)}),De(this,"destroy",()=>{this.descendants.clear()}),De(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),De(this,"count",()=>this.descendants.size),De(this,"enabledCount",()=>this.enabledValues().length),De(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),De(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),De(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),De(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),De(this,"first",()=>this.item(0)),De(this,"firstEnabled",()=>this.enabledItem(0)),De(this,"last",()=>this.item(this.descendants.size-1)),De(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),De(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),De(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),De(this,"next",(t,e=!0)=>{const n=Hs(t,this.count(),e);return this.item(n)}),De(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Hs(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=Vs(t,this.count()-1,e);return this.item(n)}),De(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Vs(r,this.enabledCount()-1,e);return this.enabledItem(o)}),De(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=qs(n);e!=null&&e.disabled&&(e.disabled=!!e.disabled);const o={node:t,index:-1,...e};this.descendants.set(t,o),this.assignIndex(r)})}};function zl(){const t=j.useRef(new Ml);return go(()=>()=>t.current.destroy()),t.current}var[Ll,Na]=tt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Wl(t){const e=Na(),[n,r]=j.useState(-1),o=j.useRef(null);go(()=>()=>{o.current&&e.unregister(o.current)},[]),go(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=xr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Te(s,o)}}function Fa(){return[xr(Ll),()=>xr(Na()),()=>zl(),o=>Wl(o)]}function Ra(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Bt(r),i=Bt(o),[a,l]=j.useState(n),u=e!==void 0,c=u?e:a,d=Bt(p=>{const b=typeof p=="function"?p(c):p;i(c,b)&&(u||l(b),s(b))},[u,s,c,i]);return[c,d]}function hs(t){return j.Children.toArray(t).filter(e=>j.isValidElement(e))}var Ul={horizontal:{"> *:first-of-type:not(:last-of-type)":{borderEndRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderStartRadius:0}},vertical:{"> *:first-of-type:not(:last-of-type)":{borderBottomRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderTopRadius:0}}},Kl={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},Ta=fe(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:u,orientation:c="horizontal",...d}=e,p=xe("chakra-button__group",i),h=j.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let b={display:"inline-flex",...l?Ul[c]:Kl[c](a)};const f=c==="vertical";return I.jsx(gl,{value:h,children:I.jsx(de.div,{ref:n,role:"group",__css:b,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:f?"column":void 0,...d})})});Ta.displayName="ButtonGroup";var jn=fe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=j.isValidElement(a)?j.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return I.jsx(Le,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});jn.displayName="IconButton";var[$l,Ba]=wl("Card"),ql=fe(function(e,n){const{className:r,...o}=e,s=Ba();return I.jsx(de.div,{ref:n,className:xe("chakra-card__body",r),__css:s.body,...o})}),Hl=fe(function(e,n){const{className:r,...o}=e,s=Ba();return I.jsx(de.div,{ref:n,className:xe("chakra-card__header",r),__css:s.header,...o})}),Vl=fe(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=nt(e),u=jt("Card",e);return I.jsx(de.div,{ref:n,className:xe("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:I.jsx($l,{value:u,children:o})})}),[Zl,Ma]=tt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Gl,hn]=tt({strict:!1,name:"FormControlContext"});function Yl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=j.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,h]=j.useState(!1),[b,f]=j.useState(!1),[y,m]=j.useState(!1),w=j.useCallback((E={},N=null)=>({id:d,...E,ref:Te(N,D=>{D&&f(!0)})}),[d]),_=j.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":st(y),"data-disabled":st(o),"data-invalid":st(r),"data-readonly":st(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,u]),x=j.useCallback((E={},N=null)=>({id:c,...E,ref:Te(N,D=>{D&&h(!0)}),"aria-live":"polite"}),[c]),k=j.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":st(y),"data-disabled":st(o),"data-invalid":st(r),"data-readonly":st(s)}),[i,o,y,r,s]),O=j.useCallback((E={},N=null)=>({...E,ref:N,role:"presentation","aria-hidden":!0,children:E.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!y,onFocus:()=>m(!0),onBlur:()=>m(!1),hasFeedbackText:p,setHasFeedbackText:h,hasHelpText:b,setHasHelpText:f,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:w,getErrorMessageProps:x,getRootProps:k,getLabelProps:_,getRequiredIndicatorProps:O}}var qr=fe(function(e,n){const r=jt("Form",e),o=nt(e),{getRootProps:s,htmlProps:i,...a}=Yl(o),l=xe("chakra-form-control",e.className);return I.jsx(Gl,{value:a,children:I.jsx(Zl,{value:r,children:I.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});qr.displayName="FormControl";var Jl=fe(function(e,n){const r=hn(),o=Ma(),s=xe("chakra-form__helper-text",e.className);return I.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Jl.displayName="FormHelperText";var[Xl,Ql]=tt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Hr=fe((t,e)=>{const n=jt("FormError",t),r=nt(t),o=hn();return o!=null&&o.isInvalid?I.jsx(Xl,{value:n,children:I.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:xe("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Hr.displayName="FormErrorMessage";var ec=fe((t,e)=>{const n=Ql(),r=hn();if(!(r!=null&&r.isInvalid))return null;const o=xe("chakra-form__error-icon",t.className);return I.jsx(Ur,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:I.jsx("path",{fill:"currentColor",d:"M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"})})});ec.displayName="FormErrorIcon";var Vr=fe(function(e,n){var r;const o=Kr("FormLabel",e),s=nt(e),{className:i,children:a,requiredIndicator:l=I.jsx(za,{}),optionalIndicator:u=null,...c}=s,d=hn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return I.jsxs(de.label,{...p,className:xe("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:u]})});Vr.displayName="FormLabel";var za=fe(function(e,n){const r=hn(),o=Ma();if(!(r!=null&&r.isRequired))return null;const s=xe("chakra-form__required-indicator",e.className);return I.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});za.displayName="RequiredIndicator";function tc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=nc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":no(n),"aria-required":no(o),"aria-readonly":no(r)}}function nc(t){var e,n,r;const o=hn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:b,...f}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...f,"aria-describedby":y.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=i??p)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=a??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??u)!=null?r:o==null?void 0:o.isRequired,isInvalid:c??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,b)}}function nn(t,e,n,r){const o=Bt(n);return j.useEffect(()=>{const s=typeof t=="function"?t():t??document;if(!(!n||!s))return s.addEventListener(e,o,r),()=>{s.removeEventListener(e,o,r)}},[e,t,r,o,n]),()=>{const s=typeof t=="function"?t():t??document;s==null||s.removeEventListener(e,o,r)}}function rc(t){return"current"in t}var La=()=>typeof window<"u";function oc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var sc=t=>La()&&t.test(navigator.vendor),ac=t=>La()&&t.test(oc()),ic=()=>ac(/mac|iphone|ipad|ipod/i),lc=()=>ic()&&sc(/apple/i);function cc(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,i;return(i=(s=e.current)==null?void 0:s.ownerDocument)!=null?i:document};nn(o,"pointerdown",s=>{if(!lc()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=rc(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Wa={exports:{}},uc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",dc=uc,fc=dc;function Ua(){}function Ka(){}Ka.resetWarningCache=Ua;var hc=function(){function t(r,o,s,i,a,l){if(l!==fc){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Ka,resetWarningCache:Ua};return n.PropTypes=n,n};Wa.exports=hc();var pc=Wa.exports;const Ft=Ea(pc);function mc(t){const e=t.ownerDocument.defaultView||window,{overflow:n,overflowX:r,overflowY:o}=e.getComputedStyle(t);return/auto|scroll|overlay|hidden/.test(n+o+r)}function yc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function $a(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:bl(t)&&mc(t)?t:$a(yc(t))}var vc=Nl?j.useLayoutEffect:j.useEffect;function wo(t,e=[]){const n=j.useRef(t);return vc(()=>{n.current=t}),j.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function gc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=wo(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{ro(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ro(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ro(d,e)&&(i.isPointerDown=!1,o(d))},c=ja(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function ro(t,e){var n;const r=t.target;return r&&!ja(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function wc(t,e){const n=j.useId();return j.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function bc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function _c(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=wo(n),i=wo(e),[a,l]=j.useState(t.defaultIsOpen||!1),[u,c]=bc(r,a),d=wc(o,"disclosure"),p=j.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),h=j.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),b=j.useCallback(()=>{(c?p:h)()},[c,h,p]);return{isOpen:!!c,onOpen:h,onClose:p,onToggle:b,isControlled:u,getButtonProps:(f={})=>({...f,"aria-expanded":c,"aria-controls":d,onClick:_l(f.onClick,b)}),getDisclosureProps:(f={})=>({...f,hidden:!c,id:d})}}var Un=fe(function(e,n){const{htmlSize:r,...o}=e,s=jt("Input",o),i=nt(o),a=tc(i),l=xe("chakra-input",e.className);return I.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});Un.displayName="Input";Un.id="Input";function xc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):xl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}var Mt=fe(function(e,n){const r=Kr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=nt(e),u=Fl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return I.jsx(de.p,{ref:n,className:xe("chakra-text",e.className),...u,...l,__css:r})});Mt.displayName="Text";var bo=t=>I.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});bo.displayName="StackDivider";var qa=t=>I.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});qa.displayName="StackItem";function kc(t){const{spacing:e,direction:n}=t,r={column:{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},"column-reverse":{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},row:{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0},"row-reverse":{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0}};return{"&":xc(n,o=>r[o])}}var rn=fe((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:u,className:c,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",b=j.useMemo(()=>kc({spacing:i,direction:h}),[i,h]),f=!!u,y=!d&&!f,m=j.useMemo(()=>{const _=hs(l);return y?_:_.map((x,k)=>{const O=typeof x.key<"u"?x.key:k,E=k+1===_.length,D=d?I.jsx(qa,{children:x},O):x;if(!f)return D;const R=j.cloneElement(u,{__css:b}),$=E?null:R;return I.jsxs(j.Fragment,{children:[D,$]},O)})},[u,b,f,y,d,l]),w=xe("chakra-stack",c);return I.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:h,flexWrap:a,gap:f?void 0:i,className:w,...p,children:m})});rn.displayName="Stack";var zt=fe((t,e)=>I.jsx(rn,{align:"center",...t,direction:"row",ref:e}));zt.displayName="HStack";var ps=fe(function(e,n){const r=Kr("Heading",e),{className:o,...s}=nt(e);return I.jsx(de.h2,{ref:n,className:xe("chakra-heading",e.className),...s,__css:r})});ps.displayName="Heading";var St=de("div");St.displayName="Box";var Ha=fe(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return I.jsx(St,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});Ha.displayName="Square";var Ec=fe(function(e,n){const{size:r,...o}=e;return I.jsx(Ha,{size:r,ref:n,borderRadius:"9999px",...o})});Ec.displayName="Circle";var kn=fe(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:u};return I.jsx(de.div,{ref:n,__css:d,...c})});kn.displayName="Flex";function Cc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Sc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=j.useState([]),s=j.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};j.useEffect(()=>i,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Cc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function Ic(t,e,n,r){if(e==null)return r;if(!r)return t.find(i=>n(i).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let s;return o.includes(r)?(s=o.indexOf(r)+1,s===o.length&&(s=0),o[s]):(s=t.indexOf(o[0]),t[s])}return r}function Oc(){const t=j.useRef(new Map),e=t.current,n=j.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=j.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return j.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function oo(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Va(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:p,onMouseLeave:h,...b}=t,[f,y]=j.useState(!0),[m,w]=j.useState(!1),_=Oc(),x=A=>{A&&A.tagName!=="BUTTON"&&y(!1)},k=f?d:d||0,O=n&&!r,E=j.useCallback(A=>{if(n){A.stopPropagation(),A.preventDefault();return}A.currentTarget.focus(),l==null||l(A)},[n,l]),N=j.useCallback(A=>{m&&oo(A)&&(A.preventDefault(),A.stopPropagation(),w(!1),_.remove(document,"keyup",N,!1))},[m,_]),D=j.useCallback(A=>{if(u==null||u(A),n||A.defaultPrevented||A.metaKey||!oo(A.nativeEvent)||f)return;const X=o&&A.key==="Enter";s&&A.key===" "&&(A.preventDefault(),w(!0)),X&&(A.preventDefault(),A.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,f,u,o,s,_,N]),R=j.useCallback(A=>{if(c==null||c(A),n||A.defaultPrevented||A.metaKey||!oo(A.nativeEvent)||f)return;s&&A.key===" "&&(A.preventDefault(),w(!1),A.currentTarget.click())},[s,f,n,c]),$=j.useCallback(A=>{A.button===0&&(w(!1),_.remove(document,"mouseup",$,!1))},[_]),P=j.useCallback(A=>{if(A.button!==0)return;if(n){A.stopPropagation(),A.preventDefault();return}f||w(!0),A.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",$,!1),i==null||i(A)},[n,f,i,_,$]),B=j.useCallback(A=>{A.button===0&&(f||w(!1),a==null||a(A))},[a,f]),v=j.useCallback(A=>{if(n){A.preventDefault();return}p==null||p(A)},[n,p]),T=j.useCallback(A=>{m&&(A.preventDefault(),w(!1)),h==null||h(A)},[m,h]),H=Te(e,x);return f?{...b,ref:H,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:h}:{...b,ref:H,role:"button","data-active":st(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:k,onClick:E,onMouseDown:P,onMouseUp:B,onKeyUp:R,onKeyDown:D,onMouseOver:v,onMouseLeave:T}}function Dc(t){const e=t.current;if(!e)return!1;const n=Cl(e);return!n||e.contains(n)?!1:!!Sl(n)}function Za(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;$r(()=>{if(!s||Dc(t))return;const i=(o==null?void 0:o.current)||t.current;let a;if(i)return a=requestAnimationFrame(()=>{i.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(a)}},[s,t,o])}var Pc={preventScroll:!0,shouldFocus:!1};function jc(t,e=Pc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Ac(t)?t.current:t,a=o&&s,l=j.useRef(a),u=j.useRef(s);kl(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=j.useCallback(()=>{if(!(!s||!i||!l.current)&&(l.current=!1,!i.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=El(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);$r(()=>{c()},[c]),nn(i,"transitionend",c)}function Ac(t){return"current"in t}var Jt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Ae={arrowShadowColor:Jt("--popper-arrow-shadow-color"),arrowSize:Jt("--popper-arrow-size","8px"),arrowSizeHalf:Jt("--popper-arrow-size-half"),arrowBg:Jt("--popper-arrow-bg"),transformOrigin:Jt("--popper-transform-origin"),arrowOffset:Jt("--popper-arrow-offset")};function Nc(t){if(t.includes("top"))return"1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("bottom"))return"-1px -1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("right"))return"-1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("left"))return"1px -1px 0px 0 var(--popper-arrow-shadow-color)"}var Fc={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},Rc=t=>Fc[t],Zs={scroll:!0,resize:!0};function Tc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Zs,...t}}:e={enabled:t,options:Zs},e}var Bc={name:"matchWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>()=>{const e=t.elements.reference;t.elements.popper.style.width=`${e.offsetWidth}px`}},Mc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Gs(t)},effect:({state:t})=>()=>{Gs(t)}},Gs=t=>{t.elements.popper.style.setProperty(Ae.transformOrigin.var,Rc(t.placement))},zc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Lc(t)}},Lc=t=>{var e;if(!t.placement)return;const n=Wc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:Ae.arrowSize.varRef,height:Ae.arrowSize.varRef,zIndex:-1});const r={[Ae.arrowSizeHalf.var]:`calc(${Ae.arrowSize.varRef} / 2 - 1px)`,[Ae.arrowOffset.var]:`calc(${Ae.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},Wc=t=>{if(t.startsWith("top"))return{property:"bottom",value:Ae.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:Ae.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:Ae.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:Ae.arrowOffset.varRef}},Uc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{Ys(t)},effect:({state:t})=>()=>{Ys(t)}},Ys=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Nc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:Ae.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Kc={"start-start":{ltr:"left-start",rtl:"right-start"},"start-end":{ltr:"left-end",rtl:"right-end"},"end-start":{ltr:"right-start",rtl:"left-start"},"end-end":{ltr:"right-end",rtl:"left-end"},start:{ltr:"left",rtl:"right"},end:{ltr:"right",rtl:"left"}},$c={"auto-start":"auto-end","auto-end":"auto-start","top-start":"top-end","top-end":"top-start","bottom-start":"bottom-end","bottom-end":"bottom-start"};function qc(t,e="ltr"){var n,r;const o=((n=Kc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=$c[t])!=null?r:o}var Ke="top",Qe="bottom",et="right",$e="left",ms="auto",Kn=[Ke,Qe,et,$e],ln="start",An="end",Hc="clippingParents",Ga="viewport",wn="popper",Vc="reference",Js=Kn.reduce(function(t,e){return t.concat([e+"-"+ln,e+"-"+An])},[]),Ya=[].concat(Kn,[ms]).reduce(function(t,e){return t.concat([e,e+"-"+ln,e+"-"+An])},[]),Zc="beforeRead",Gc="read",Yc="afterRead",Jc="beforeMain",Xc="main",Qc="afterMain",eu="beforeWrite",tu="write",nu="afterWrite",ru=[Zc,Gc,Yc,Jc,Xc,Qc,eu,tu,nu];function ct(t){return t?(t.nodeName||"").toLowerCase():null}function Ze(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function qt(t){var e=Ze(t).Element;return t instanceof e||t instanceof Element}function Xe(t){var e=Ze(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ys(t){if(typeof ShadowRoot>"u")return!1;var e=Ze(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function ou(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!Xe(s)||!ct(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function su(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,u){return l[u]="",l},{});!Xe(o)||!ct(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const au={name:"applyStyles",enabled:!0,phase:"write",fn:ou,effect:su,requires:["computeStyles"]};function lt(t){return t.split("-")[0]}var Lt=Math.max,kr=Math.min,cn=Math.round;function _o(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Ja(){return!/^((?!chrome|android).)*safari/i.test(_o())}function un(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xe(t)&&(o=t.offsetWidth>0&&cn(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&cn(r.height)/t.offsetHeight||1);var i=qt(t)?Ze(t):window,a=i.visualViewport,l=!Ja()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/o,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:c,right:u+d,bottom:c+p,left:u,x:u,y:c}}function vs(t){var e=un(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function Xa(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ys(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function gt(t){return Ze(t).getComputedStyle(t)}function iu(t){return["table","td","th"].indexOf(ct(t))>=0}function Nt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function Zr(t){return ct(t)==="html"?t:t.assignedSlot||t.parentNode||(ys(t)?t.host:null)||Nt(t)}function Xs(t){return!Xe(t)||gt(t).position==="fixed"?null:t.offsetParent}function lu(t){var e=/firefox/i.test(_o()),n=/Trident/i.test(_o());if(n&&Xe(t)){var r=gt(t);if(r.position==="fixed")return null}var o=Zr(t);for(ys(o)&&(o=o.host);Xe(o)&&["html","body"].indexOf(ct(o))<0;){var s=gt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function $n(t){for(var e=Ze(t),n=Xs(t);n&&iu(n)&>(n).position==="static";)n=Xs(n);return n&&(ct(n)==="html"||ct(n)==="body"&>(n).position==="static")?e:n||lu(t)||e}function gs(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function En(t,e,n){return Lt(t,kr(e,n))}function cu(t,e,n){var r=En(t,e,n);return r>n?n:r}function Qa(){return{top:0,right:0,bottom:0,left:0}}function ei(t){return Object.assign({},Qa(),t)}function ti(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var uu=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,ei(typeof e!="number"?e:ti(e,Kn))};function du(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=lt(n.placement),l=gs(a),u=[$e,et].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=uu(o.padding,n),p=vs(s),h=l==="y"?Ke:$e,b=l==="y"?Qe:et,f=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],y=i[l]-n.rects.reference[l],m=$n(s),w=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=f/2-y/2,x=d[h],k=w-p[c]-d[b],O=w/2-p[c]/2+_,E=En(x,O,k),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function fu(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||Xa(e.elements.popper,o)&&(e.elements.arrow=o))}const hu={name:"arrow",enabled:!0,phase:"main",fn:du,effect:fu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function dn(t){return t.split("-")[1]}var pu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function mu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:cn(n*o)/o||0,y:cn(r*o)/o||0}}function Qs(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,b=i.y,f=b===void 0?0:b,y=typeof c=="function"?c({x:h,y:f}):{x:h,y:f};h=y.x,f=y.y;var m=i.hasOwnProperty("x"),w=i.hasOwnProperty("y"),_=$e,x=Ke,k=window;if(u){var O=$n(n),E="clientHeight",N="clientWidth";if(O===Ze(n)&&(O=Nt(n),gt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===et)&&s===An){x=Qe;var D=d&&O===k&&k.visualViewport?k.visualViewport.height:O[E];f-=D-r.height,f*=l?1:-1}if(o===$e||(o===Ke||o===Qe)&&s===An){_=et;var R=d&&O===k&&k.visualViewport?k.visualViewport.width:O[N];h-=R-r.width,h*=l?1:-1}}var $=Object.assign({position:a},u&&pu),P=c===!0?mu({x:h,y:f},Ze(n)):{x:h,y:f};if(h=P.x,f=P.y,l){var B;return Object.assign({},$,(B={},B[x]=w?"0":"",B[_]=m?"0":"",B.transform=(k.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",B))}return Object.assign({},$,(e={},e[x]=w?f+"px":"",e[_]=m?h+"px":"",e.transform="",e))}function yu(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:lt(e.placement),variation:dn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Qs(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Qs(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const vu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:yu,data:{}};var Qn={passive:!0};function gu(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=Ze(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const wu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:gu,data:{}};var bu={left:"right",right:"left",bottom:"top",top:"bottom"};function cr(t){return t.replace(/left|right|bottom|top/g,function(e){return bu[e]})}var _u={start:"end",end:"start"};function ea(t){return t.replace(/start|end/g,function(e){return _u[e]})}function ws(t){var e=Ze(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function bs(t){return un(Nt(t)).left+ws(t).scrollLeft}function xu(t,e){var n=Ze(t),r=Nt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=Ja();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+bs(t),y:l}}function ku(t){var e,n=Nt(t),r=ws(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Lt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Lt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+bs(t),l=-r.scrollTop;return gt(o||n).direction==="rtl"&&(a+=Lt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function _s(t){var e=gt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ni(t){return["html","body","#document"].indexOf(ct(t))>=0?t.ownerDocument.body:Xe(t)&&_s(t)?t:ni(Zr(t))}function Cn(t,e){var n;e===void 0&&(e=[]);var r=ni(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ze(r),i=o?[s].concat(s.visualViewport||[],_s(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Cn(Zr(i)))}function xo(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Eu(t,e){var n=un(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function ta(t,e,n){return e===Ga?xo(xu(t,n)):qt(e)?Eu(e,n):xo(ku(Nt(t)))}function Cu(t){var e=Cn(Zr(t)),n=["absolute","fixed"].indexOf(gt(t).position)>=0,r=n&&Xe(t)?$n(t):t;return qt(r)?e.filter(function(o){return qt(o)&&Xa(o,r)&&ct(o)!=="body"}):[]}function Su(t,e,n,r){var o=e==="clippingParents"?Cu(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=ta(t,u,r);return l.top=Lt(c.top,l.top),l.right=kr(c.right,l.right),l.bottom=kr(c.bottom,l.bottom),l.left=Lt(c.left,l.left),l},ta(t,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ri(t){var e=t.reference,n=t.element,r=t.placement,o=r?lt(r):null,s=r?dn(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case Ke:l={x:i,y:e.y-n.height};break;case Qe:l={x:i,y:e.y+e.height};break;case et:l={x:e.x+e.width,y:a};break;case $e:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?gs(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case ln:l[u]=l[u]-(e[c]/2-n[c]/2);break;case An:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Nn(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,i=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?Hc:a,u=n.rootBoundary,c=u===void 0?Ga:u,d=n.elementContext,p=d===void 0?wn:d,h=n.altBoundary,b=h===void 0?!1:h,f=n.padding,y=f===void 0?0:f,m=ei(typeof y!="number"?y:ti(y,Kn)),w=p===wn?Vc:wn,_=t.rects.popper,x=t.elements[b?w:p],k=Su(qt(x)?x:x.contextElement||Nt(t.elements.popper),l,c,i),O=un(t.elements.reference),E=ri({reference:O,element:_,strategy:"absolute",placement:o}),N=xo(Object.assign({},_,E)),D=p===wn?N:O,R={top:k.top-D.top+m.top,bottom:D.bottom-k.bottom+m.bottom,left:k.left-D.left+m.left,right:D.right-k.right+m.right},$=t.modifiersData.offset;if(p===wn&&$){var P=$[o];Object.keys(R).forEach(function(B){var v=[et,Qe].indexOf(B)>=0?1:-1,T=[Ke,Qe].indexOf(B)>=0?"y":"x";R[B]+=P[T]*v})}return R}function Iu(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?Ya:l,c=dn(r),d=c?a?Js:Js.filter(function(b){return dn(b)===c}):Kn,p=d.filter(function(b){return u.indexOf(b)>=0});p.length===0&&(p=d);var h=p.reduce(function(b,f){return b[f]=Nn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[lt(f)],b},{});return Object.keys(h).sort(function(b,f){return h[b]-h[f]})}function Ou(t){if(lt(t)===ms)return[];var e=cr(t);return[ea(t),e,ea(e)]}function Du(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,b=h===void 0?!0:h,f=n.allowedAutoPlacements,y=e.options.placement,m=lt(y),w=m===y,_=l||(w||!b?[cr(y)]:Ou(y)),x=[y].concat(_).reduce(function(J,G){return J.concat(lt(G)===ms?Iu(e,{placement:G,boundary:c,rootBoundary:d,padding:u,flipVariations:b,allowedAutoPlacements:f}):G)},[]),k=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,D=x[0],R=0;R=0,T=v?"width":"height",H=Nn(e,{placement:$,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),A=v?B?et:$e:B?Qe:Ke;k[T]>O[T]&&(A=cr(A));var X=cr(A),K=[];if(s&&K.push(H[P]<=0),a&&K.push(H[A]<=0,H[X]<=0),K.every(function(J){return J})){D=$,N=!1;break}E.set($,K)}if(N)for(var ne=b?3:1,z=function(G){var me=x.find(function(we){var ie=E.get(we);if(ie)return ie.slice(0,G).every(function(ue){return ue})});if(me)return D=me,"break"},M=ne;M>0;M--){var te=z(M);if(te==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const Pu={name:"flip",enabled:!0,phase:"main",fn:Du,requiresIfExists:["offset"],data:{_skip:!1}};function na(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function ra(t){return[Ke,et,Qe,$e].some(function(e){return t[e]>=0})}function ju(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Nn(e,{elementContext:"reference"}),a=Nn(e,{altBoundary:!0}),l=na(i,r),u=na(a,o,s),c=ra(l),d=ra(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const Au={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:ju};function Nu(t,e,n){var r=lt(t),o=[$e,Ke].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[$e,et].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function Fu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=Ya.reduce(function(c,d){return c[d]=Nu(d,e.rects,s),c},{}),a=i[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=i}const Ru={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Fu};function Tu(t){var e=t.state,n=t.name;e.modifiersData[n]=ri({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Bu={name:"popperOffsets",enabled:!0,phase:"read",fn:Tu,data:{}};function Mu(t){return t==="x"?"y":"x"}function zu(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,b=n.tetherOffset,f=b===void 0?0:b,y=Nn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),m=lt(e.placement),w=dn(e.placement),_=!w,x=gs(m),k=Mu(x),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,D=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(O){if(s){var B,v=x==="y"?Ke:$e,T=x==="y"?Qe:et,H=x==="y"?"height":"width",A=O[x],X=A+y[v],K=A-y[T],ne=h?-N[H]/2:0,z=w===ln?E[H]:N[H],M=w===ln?-N[H]:-E[H],te=e.elements.arrow,J=h&&te?vs(te):{width:0,height:0},G=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Qa(),me=G[v],we=G[T],ie=En(0,E[H],J[H]),ue=_?E[H]/2-ne-ie-me-R.mainAxis:z-ie-me-R.mainAxis,_e=_?-E[H]/2+ne+ie+we+R.mainAxis:M+ie+we+R.mainAxis,ye=e.elements.arrow&&$n(e.elements.arrow),pe=ye?x==="y"?ye.clientTop||0:ye.clientLeft||0:0,ke=(B=$==null?void 0:$[x])!=null?B:0,g=A+ue-ke-pe,U=A+_e-ke,W=En(h?kr(X,g):X,A,h?Lt(K,U):K);O[x]=W,P[x]=W-A}if(a){var S,C=x==="x"?Ke:$e,F=x==="x"?Qe:et,V=O[k],Z=k==="y"?"height":"width",L=V+y[C],Q=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(S=$==null?void 0:$[k])!=null?S:0,se=re?L:V-E[Z]-N[Z]-ee+R.altAxis,ve=re?V+E[Z]+N[Z]-ee-R.altAxis:Q,he=h&&re?cu(se,V,ve):En(h?se:L,V,h?ve:Q);O[k]=he,P[k]=he-V}e.modifiersData[r]=P}}const Lu={name:"preventOverflow",enabled:!0,phase:"main",fn:zu,requiresIfExists:["offset"]};function Wu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Uu(t){return t===Ze(t)||!Xe(t)?ws(t):Wu(t)}function Ku(t){var e=t.getBoundingClientRect(),n=cn(e.width)/t.offsetWidth||1,r=cn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function $u(t,e,n){n===void 0&&(n=!1);var r=Xe(e),o=Xe(e)&&Ku(e),s=Nt(e),i=un(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((ct(e)!=="body"||_s(s))&&(a=Uu(e)),Xe(e)?(l=un(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=bs(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function qu(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function Hu(t){var e=qu(t);return ru.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Vu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Zu(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var oa={placement:"bottom",modifiers:[],strategy:"absolute"};function sa(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=j.useCallback(()=>{var R;!e||!b.current||!f.current||((R=w.current)==null||R.call(w),y.current=Ju(b.current,f.current,{placement:m,modifiers:[Uc,zc,Mc,{...Bc,enabled:!!p},{name:"eventListeners",...Tc(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),y.current.forceUpdate(),w.current=y.current.destroy)},[m,e,n,p,i,s,a,l,u,d,c,o]);j.useEffect(()=>()=>{var R;!b.current&&!f.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const x=j.useCallback(R=>{b.current=R,_()},[_]),k=j.useCallback((R={},$=null)=>({...R,ref:Te(x,$)}),[x]),O=j.useCallback(R=>{f.current=R,_()},[_]),E=j.useCallback((R={},$=null)=>({...R,ref:Te(O,$),style:{...R.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,O,p]),N=j.useCallback((R={},$=null)=>{const{size:P,shadowColor:B,bg:v,style:T,...H}=R;return{...H,ref:$,"data-popper-arrow":"",style:Xu(R)}},[]),D=j.useCallback((R={},$=null)=>({...R,ref:$,"data-popper-arrow-inner":""}),[]);return{update(){var R;(R=y.current)==null||R.update()},forceUpdate(){var R;(R=y.current)==null||R.forceUpdate()},transformOrigin:Ae.transformOrigin.varRef,referenceRef:x,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:D,getReferenceProps:k}}function Xu(t){const{size:e,shadowColor:n,bg:r,style:o}=t,s={...o,position:"absolute"};return e&&(s["--popper-arrow-size"]=e),n&&(s["--popper-arrow-shadow-color"]=n),r&&(s["--popper-arrow-bg"]=r),s}function ks(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Bt(n),i=Bt(e),[a,l]=j.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=j.useId(),p=o??`disclosure-${d}`,h=j.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),b=j.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),f=j.useCallback(()=>{u?h():b()},[u,b,h]);function y(w={}){return{...w,"aria-expanded":u,"aria-controls":p,onClick(_){var x;(x=w.onClick)==null||x.call(w,_),f()}}}function m(w={}){return{...w,hidden:!u,id:p}}return{isOpen:u,onOpen:b,onClose:h,onToggle:f,isControlled:c,getButtonProps:y,getDisclosureProps:m}}function Qu(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Bt(n),i=j.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;j.useEffect(()=>{if(!r)return;const a=d=>{so(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&so(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&so(d,e)&&(i.isPointerDown=!1,o(d))},c=oi(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function so(t,e){var n;const r=t.target;return r&&!oi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function oi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function si(t){const{isOpen:e,ref:n}=t,[r,o]=j.useState(e),[s,i]=j.useState(!1);return j.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),nn(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Il(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function Es(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[ed,td,nd,rd]=Fa(),[od,qn]=tt({strict:!1,name:"MenuContext"});function sd(t,...e){const n=j.useId(),r=t||n;return j.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function ai(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function aa(t){return ai(t).activeElement===t}function ad(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:b=!1,...f}=t,y=j.useRef(null),m=j.useRef(null),w=nd(),_=j.useCallback(()=>{requestAnimationFrame(()=>{var te;(te=y.current)==null||te.focus({preventScroll:!1})})},[]),x=j.useCallback(()=>{const te=setTimeout(()=>{var J;if(o)(J=o.current)==null||J.focus();else{const G=w.firstEnabled();G&&B(G.index)}});X.current.add(te)},[w,o]),k=j.useCallback(()=>{const te=setTimeout(()=>{const J=w.lastEnabled();J&&B(J.index)});X.current.add(te)},[w]),O=j.useCallback(()=>{c==null||c(),s?x():_()},[s,x,_,c]),{isOpen:E,onOpen:N,onClose:D,onToggle:R}=ks({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:O});Qu({enabled:E&&r,ref:y,handler:te=>{var J;(J=m.current)!=null&&J.contains(te.target)||D()}});const $=xs({...f,enabled:E||b,placement:d,direction:h}),[P,B]=j.useState(-1);$r(()=>{E||B(-1)},[E]),Za(y,{focusRef:m,visible:E,shouldFocus:!0});const v=si({isOpen:E,ref:y}),[T,H]=sd(e,"menu-button","menu-list"),A=j.useCallback(()=>{N(),_()},[N,_]),X=j.useRef(new Set([]));j.useEffect(()=>{const te=X.current;return()=>{te.forEach(J=>clearTimeout(J)),te.clear()}},[]);const K=j.useCallback(()=>{N(),x()},[x,N]),ne=j.useCallback(()=>{N(),k()},[N,k]),z=j.useCallback(()=>{var te,J;const G=ai(y.current),me=(te=y.current)==null?void 0:te.contains(G.activeElement);if(!(E&&!me))return;const ie=(J=w.item(P))==null?void 0:J.node;ie==null||ie.focus({preventScroll:!0})},[E,P,w]),M=j.useRef(null);return{openAndFocusMenu:A,openAndFocusFirstItem:K,openAndFocusLastItem:ne,onTransitionEnd:z,unstable__animationState:v,descendants:w,popper:$,buttonId:T,menuId:H,forceUpdate:$.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:D,menuRef:y,buttonRef:m,focusedIndex:P,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:B,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:M}}function sp(t={},e=null){const n=qn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=j.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Te(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":st(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function ko(t){var e;return cd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function id(t={},e=null){const n=qn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:i,onClose:a,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,p=td(),h=Sc({preventDefault:m=>m.key!==" "&&ko(m.target)}),b=j.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const w=m.key,x={Tab:O=>O.preventDefault(),Escape:a,ArrowDown:()=>{const O=p.nextEnabled(r);O&&o(O.index)},ArrowUp:()=>{const O=p.prevEnabled(r);O&&o(O.index)}}[w];if(x){m.preventDefault(),x(m);return}const k=h(O=>{const E=Ic(p.values(),O,N=>{var D,R;return(R=(D=N==null?void 0:N.node)==null?void 0:D.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});ko(m.target)&&k(m)},[p,r,h,a,o]),f=j.useRef(!1);i&&(f.current=!0);const y=Es({wasSelected:f.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Te(s,e),children:y?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:Oe(t.onKeyDown,b)}}function ld(t={}){const{popper:e,isOpen:n}=qn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function ii(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:u,type:c,...d}=t,p=qn(),{setFocusedIndex:h,focusedIndex:b,closeOnSelect:f,onClose:y,menuRef:m,isOpen:w,menuId:_,rafId:x}=p,k=j.useRef(null),O=`${_}-menuitem-${j.useId()}`,{index:E,register:N}=rd({disabled:a&&!l}),D=j.useCallback(A=>{n==null||n(A),!a&&h(E)},[h,E,a,n]),R=j.useCallback(A=>{r==null||r(A),k.current&&!aa(k.current)&&D(A)},[D,r]),$=j.useCallback(A=>{o==null||o(A),!a&&h(-1)},[h,a,o]),P=j.useCallback(A=>{s==null||s(A),ko(A.currentTarget)&&(u??f)&&y()},[y,s,f,u]),B=j.useCallback(A=>{i==null||i(A),h(E)},[h,i,E]),v=E===b,T=a&&!l;$r(()=>{if(w)return v&&!T&&k.current?(x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(()=>{var A;(A=k.current)==null||A.focus({preventScroll:!0}),x.current=null})):m.current&&!aa(m.current)&&m.current.focus({preventScroll:!0}),()=>{x.current&&cancelAnimationFrame(x.current)}},[v,T,m,w]);const H=Va({onClick:P,onFocus:B,onMouseEnter:D,onMouseMove:R,onMouseLeave:$,ref:Te(N,k,e),isDisabled:a,isFocusable:l});return{...d,...H,type:c??H.type,id:O,role:"menuitem",tabIndex:v?0:-1}}function ap(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...ii(o,e),role:`menuitem${n}`,"aria-checked":r}}function ip(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Ra({defaultValue:o??l,value:r,onChange:s}),d=j.useCallback(b=>{if(n==="radio"&&typeof u=="string"&&c(b),n==="checkbox"&&Array.isArray(u)){const f=u.includes(b)?u.filter(y=>y!==b):u.concat(b);c(f)}},[u,c,n]),h=hs(e).map(b=>{if(b.type.id!=="MenuItemOption")return b;const f=m=>{var w,_;d(b.props.value),(_=(w=b.props).onClick)==null||_.call(w,m)},y=n==="radio"?b.props.value===u:u.includes(b.props.value);return j.cloneElement(b,{type:n,onClick:f,isChecked:y})});return{...i,children:h}}function cd(t){var e;if(!ud(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function ud(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[dd,Gr]=tt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Cs=t=>{const{children:e}=t,n=jt("Menu",t),r=nt(t),{direction:o}=os(),{descendants:s,...i}=ad({...r,direction:o}),a=j.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return I.jsx(ed,{value:s,children:I.jsx(od,{value:a,children:I.jsx(dd,{value:n,children:Ca(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};Cs.displayName="Menu";var li=fe((t,e)=>{const n=Gr();return I.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});li.displayName="MenuCommand";var fd=fe((t,e)=>{const{type:n,...r}=t,o=Gr(),s=r.as||n?n??void 0:"button",i=j.useMemo(()=>({textDecoration:"none",color:"inherit",userSelect:"none",display:"flex",width:"100%",alignItems:"center",textAlign:"start",flex:"0 0 auto",outline:0,...o.item}),[o.item]);return I.jsx(de.button,{ref:e,type:s,...r,__css:i})}),ci=t=>{const{className:e,children:n,...r}=t,o=Gr(),s=j.Children.only(n),i=j.isValidElement(s)?j.cloneElement(s,{focusable:"false","aria-hidden":!0,className:xe("chakra-menu__icon",s.props.className)}):null,a=xe("chakra-menu__icon-wrapper",e);return I.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};ci.displayName="MenuIcon";var _t=fe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=ii(a,e),c=n||o?I.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return I.jsxs(fd,{...l,className:xe("chakra-menu__menuitem",l.className),children:[n&&I.jsx(ci,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&I.jsx(li,{marginStart:s,children:o})]})});_t.displayName="MenuItem";var hd={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},pd=de(ss.div),Ss=fe(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=qn(),d=id(a,n),p=ld(s),h=Gr();return I.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:I.jsx(pd,{variants:hd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:xe("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Sa(c.onComplete,d.onAnimationComplete)})})});Ss.displayName="MenuList";var[md,Hn]=tt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[yd,Is]=tt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ui(t){const e=j.Children.only(t.children),{getTriggerProps:n}=Hn();return j.cloneElement(e,n(e.props,e.ref))}ui.displayName="PopoverTrigger";var Xt={click:"click",hover:"hover"};function vd(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=Xt.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:b,...f}=t,{isOpen:y,onClose:m,onOpen:w,onToggle:_}=ks(t),x=j.useRef(null),k=j.useRef(null),O=j.useRef(null),E=j.useRef(!1),N=j.useRef(!1);y&&(N.current=!0);const[D,R]=j.useState(!1),[$,P]=j.useState(!1),B=j.useId(),v=o??B,[T,H,A,X]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${v}`),{referenceRef:K,getArrowProps:ne,getPopperProps:z,getArrowInnerProps:M,forceUpdate:te}=xs({...f,enabled:y||!!b}),J=si({isOpen:y,ref:O});cc({enabled:y,ref:k}),Za(O,{focusRef:k,visible:y,shouldFocus:s&&u===Xt.click}),jc(O,{focusRef:r,visible:y,shouldFocus:i&&u===Xt.click});const G=Es({wasSelected:N.current,enabled:p,mode:h,isSelected:J.present}),me=j.useCallback((U={},W=null)=>{const S={...U,style:{...U.style,transformOrigin:Ae.transformOrigin.varRef,[Ae.arrowSize.var]:a?`${a}px`:void 0,[Ae.arrowShadowColor.var]:l},ref:Te(O,W),children:G?U.children:null,id:H,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,C=>{n&&C.key==="Escape"&&m()}),onBlur:Oe(U.onBlur,C=>{const F=ia(C),V=ao(O.current,F),Z=ao(k.current,F);y&&e&&(!V&&!Z)&&m()}),"aria-labelledby":D?A:void 0,"aria-describedby":$?X:void 0};return u===Xt.hover&&(S.role="tooltip",S.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),S.onMouseLeave=Oe(U.onMouseLeave,C=>{C.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),S},[G,H,D,A,$,X,u,n,m,y,e,d,l,a]),we=j.useCallback((U={},W=null)=>z({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,z]),ie=j.useCallback((U,W=null)=>({...U,ref:Te(W,x,K)}),[x,K]),ue=j.useRef(),_e=j.useRef(),ye=j.useCallback(U=>{x.current==null&&K(U)},[K]),pe=j.useCallback((U={},W=null)=>{const S={...U,ref:Te(k,W,ye),id:T,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":H};return u===Xt.click&&(S.onClick=Oe(U.onClick,_)),u===Xt.hover&&(S.onFocus=Oe(U.onFocus,()=>{ue.current===void 0&&w()}),S.onBlur=Oe(U.onBlur,C=>{const F=ia(C),V=!ao(O.current,F);y&&e&&V&&m()}),S.onKeyDown=Oe(U.onKeyDown,C=>{C.key==="Escape"&&m()}),S.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,ue.current=window.setTimeout(()=>w(),c)}),S.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,ue.current&&(clearTimeout(ue.current),ue.current=void 0),_e.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),S},[T,y,H,u,ye,_,w,e,m,c,d]);j.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current),_e.current&&clearTimeout(_e.current)},[]);const ke=j.useCallback((U={},W=null)=>({...U,id:A,ref:Te(W,S=>{R(!!S)})}),[A]),g=j.useCallback((U={},W=null)=>({...U,id:X,ref:Te(W,S=>{P(!!S)})}),[X]);return{forceUpdate:te,isOpen:y,onAnimationComplete:J.onComplete,onClose:m,getAnchorProps:ie,getArrowProps:ne,getArrowInnerProps:M,getPopoverPositionerProps:we,getPopoverProps:me,getTriggerProps:pe,getHeaderProps:ke,getBodyProps:g}}function ao(t,e){return t===e||(t==null?void 0:t.contains(e))}function ia(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function di(t){const e=jt("Popover",t),{children:n,...r}=nt(t),o=os(),s=vd({...r,direction:o.direction});return I.jsx(md,{value:s,children:I.jsx(yd,{value:e,children:Ca(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}di.displayName="Popover";var fi=fe(function(e,n){const{getBodyProps:r}=Hn(),o=Is();return I.jsx(de.div,{...r(e,n),className:xe("chakra-popover__body",e.className),__css:o.body})});fi.displayName="PopoverBody";var hi=fe(function(e,n){const{onClose:r}=Hn(),o=Is();return I.jsx(Ol,{size:"sm",onClick:r,className:xe("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});hi.displayName="PopoverCloseButton";function gd(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var wd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},bd=de(ss.section),pi=fe(function(e,n){const{variants:r=wd,...o}=e,{isOpen:s}=Hn();return I.jsx(bd,{ref:n,variants:gd(r),initial:!1,animate:s?"enter":"exit",...o})});pi.displayName="PopoverTransition";var mi=fe(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=Hn(),u=Is(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return I.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:I.jsx(pi,{...o,...i(s,n),onAnimationComplete:Sa(l,s.onAnimationComplete),className:xe("chakra-popover__content",e.className),__css:c})})});mi.displayName="PopoverContent";var[_d,xd,kd,Ed]=Fa();function Cd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,p]=j.useState(n??0),[h,b]=Ra({defaultValue:n??0,value:o,onChange:r});j.useEffect(()=>{o!=null&&p(o)},[o]);const f=kd(),y=j.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:b,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:u,htmlProps:c}}var[Sd,Yr]=tt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Id(t){const{focusedIndex:e,orientation:n,direction:r}=Yr(),o=xd(),s=j.useCallback(i=>{const a=()=>{var w;const _=o.nextEnabled(e);_&&((w=_.node)==null||w.focus())},l=()=>{var w;const _=o.prevEnabled(e);_&&((w=_.node)==null||w.focus())},u=()=>{var w;const _=o.firstEnabled();_&&((w=_.node)==null||w.focus())},c=()=>{var w;const _=o.lastEnabled();_&&((w=_.node)==null||w.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,b=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",m={[b]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[h];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Od(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Yr(),{index:u,register:c}=Ed({disabled:e&&!n}),d=u===l,p=()=>{o(u)},h=()=>{a(u),!s&&!(e&&n)&&o(u)},b=Va({...r,ref:Te(c,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...b,id:yi(i,u),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":vi(i,u),onFocus:e?void 0:Oe(t.onFocus,h)}}var[Dd,Pd]=tt({});function jd(t){const e=Yr(),{id:n,selectedIndex:r}=e,s=hs(t.children).map((i,a)=>j.createElement(Dd,{key:a,value:{isSelected:a===r,id:vi(n,a),tabId:yi(n,a),selectedIndex:r}},i));return{...t,children:s}}function Ad(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Yr(),{isSelected:s,id:i,tabId:a}=Pd(),l=j.useRef(!1);s&&(l.current=!0);const u=Es({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function yi(t,e){return`${t}--tab-${e}`}function vi(t,e){return`${t}--tabpanel-${e}`}var[Nd,Jr]=tt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),gi=fe(function(e,n){const r=jt("Tabs",e),{children:o,className:s,...i}=nt(e),{htmlProps:a,descendants:l,...u}=Cd(i),c=j.useMemo(()=>u,[u]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return I.jsx(_d,{value:l,children:I.jsx(Sd,{value:c,children:I.jsx(Nd,{value:r,children:I.jsx(de.div,{className:xe("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});gi.displayName="Tabs";var wi=fe(function(e,n){const r=Id({...e,ref:n}),s={display:"flex",...Jr().tablist};return I.jsx(de.div,{...r,className:xe("chakra-tabs__tablist",e.className),__css:s})});wi.displayName="TabList";var Eo=fe(function(e,n){const r=Ad({...e,ref:n}),o=Jr();return I.jsx(de.div,{outline:"0",...r,className:xe("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Eo.displayName="TabPanel";var bi=fe(function(e,n){const r=jd(e),o=Jr();return I.jsx(de.div,{...r,width:"100%",ref:n,className:xe("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});bi.displayName="TabPanels";var Co=fe(function(e,n){const r=Jr(),o=Od({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return I.jsx(de.button,{...o,className:xe("chakra-tabs__tab",e.className),__css:s})});Co.displayName="Tab";var[Fd,_i]=tt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xr=fe((t,e)=>{const n=jt("Tag",t),r=nt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return I.jsx(Fd,{value:n,children:I.jsx(de.span,{ref:e,...r,__css:o})})});Xr.displayName="Tag";var Rd=fe((t,e)=>{const n=_i();return I.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});Rd.displayName="TagLabel";var Td=fe((t,e)=>I.jsx(Ur,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Td.displayName="TagLeftIcon";var Bd=fe((t,e)=>I.jsx(Ur,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Bd.displayName="TagRightIcon";var xi=t=>I.jsx(Ur,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:I.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});xi.displayName="TagCloseIcon";var Md=fe((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",..._i().closeButton};return I.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||I.jsx(xi,{})})});Md.displayName="TagCloseButton";var zd={exit:{scale:.85,opacity:0,transition:{opacity:{duration:.15,easings:"easeInOut"},scale:{duration:.2,easings:"easeInOut"}}},enter:{scale:1,opacity:1,transition:{opacity:{easings:"easeOut",duration:.2},scale:{duration:.2,ease:[.175,.885,.4,1.1]}}}},So=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},ur=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Ld(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:p,defaultIsOpen:h,arrowSize:b=10,arrowShadowColor:f,arrowPadding:y,modifiers:m,isDisabled:w,gutter:_,offset:x,direction:k,...O}=t,{isOpen:E,onOpen:N,onClose:D}=ks({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:u}),{referenceRef:R,getPopperProps:$,getArrowInnerProps:P,getArrowProps:B}=xs({enabled:E,placement:c,arrowPadding:y,modifiers:m,gutter:_,offset:x,direction:k}),v=j.useId(),H=`tooltip-${d??v}`,A=j.useRef(null),X=j.useRef(),K=j.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=void 0)},[]),ne=j.useRef(),z=j.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),M=j.useCallback(()=>{z(),D()},[D,z]),te=Wd(A,M),J=j.useCallback(()=>{if(!w&&!X.current){E&&te();const pe=ur(A);X.current=pe.setTimeout(N,e)}},[te,w,E,N,e]),G=j.useCallback(()=>{K();const pe=ur(A);ne.current=pe.setTimeout(M,n)},[n,M,K]),me=j.useCallback(()=>{E&&r&&G()},[r,G,E]),we=j.useCallback(()=>{E&&i&&G()},[i,G,E]),ie=j.useCallback(pe=>{E&&pe.key==="Escape"&&G()},[E,G]);nn(()=>So(A),"keydown",a?ie:void 0),nn(()=>{if(!s)return null;const pe=A.current;if(!pe)return null;const ke=$a(pe);return ke.localName==="body"?ur(A):ke},"scroll",()=>{E&&s&&M()},{passive:!0,capture:!0}),j.useEffect(()=>{w&&(K(),E&&D())},[w,E,D,K]),j.useEffect(()=>()=>{K(),z()},[K,z]),nn(()=>A.current,"pointerleave",G);const ue=j.useCallback((pe={},ke=null)=>({...pe,ref:Te(A,ke,R),onPointerEnter:Oe(pe.onPointerEnter,U=>{U.pointerType!=="touch"&&J()}),onClick:Oe(pe.onClick,me),onPointerDown:Oe(pe.onPointerDown,we),onFocus:Oe(pe.onFocus,J),onBlur:Oe(pe.onBlur,G),"aria-describedby":E?H:void 0}),[J,G,we,E,H,me,R]),_e=j.useCallback((pe={},ke=null)=>$({...pe,style:{...pe.style,[Ae.arrowSize.var]:b?`${b}px`:void 0,[Ae.arrowShadowColor.var]:f}},ke),[$,b,f]),ye=j.useCallback((pe={},ke=null)=>{const g={...pe.style,position:"relative",transformOrigin:Ae.transformOrigin.varRef};return{ref:ke,...O,...pe,id:H,role:"tooltip",style:g}},[O,H]);return{isOpen:E,show:J,hide:G,getTriggerProps:ue,getTooltipProps:ye,getTooltipPositionerProps:_e,getArrowProps:B,getArrowInnerProps:P}}var io="chakra-ui:close-tooltip";function Wd(t,e){return j.useEffect(()=>{const n=So(t);return n.addEventListener(io,e),()=>n.removeEventListener(io,e)},[e,t]),()=>{const n=So(t),r=ur(t);n.dispatchEvent(new r.CustomEvent(io))}}function Ud(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Kd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var $d=de(ss.div),Ht=fe((t,e)=>{var n,r;const o=Kr("Tooltip",t),s=nt(t),i=os(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:h,background:b,backgroundColor:f,bgColor:y,motionProps:m,...w}=s,_=(r=(n=b??f)!=null?n:p)!=null?r:y;if(_){o.bg=_;const $=Dl(i,"colors",_);o[Ae.arrowBg.var]=$}const x=Ld({...w,direction:i.direction}),k=typeof a=="string"||u;let O;if(k)O=I.jsx(de.span,{display:"inline-block",tabIndex:0,...x.getTriggerProps(),children:a});else{const $=j.Children.only(a);O=j.cloneElement($,x.getTriggerProps($.props,$.ref))}const E=!!c,N=x.getTooltipProps({},e),D=E?Ud(N,["role","id"]):N,R=Kd(N,["role","id"]);return l?I.jsxs(I.Fragment,{children:[O,I.jsx(Pl,{children:x.isOpen&&I.jsx(Ia,{...h,children:I.jsx(de.div,{...x.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:I.jsxs($d,{variants:zd,initial:"exit",animate:"enter",exit:"exit",...m,...D,__css:o,children:[l,E&&I.jsx(de.span,{srOnly:!0,...R,children:c}),d&&I.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:I.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):I.jsx(I.Fragment,{children:a})});Ht.displayName="Tooltip";const qd="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=qd[n[t]&63];return e},Pe=null;const ki=location.pathname.split("/").slice(0,-1).join("/");let Er=null;At(()=>import(ki+"/scripts/api.js"),__vite__mapDeps([])).then(t=>{Er=t==null?void 0:t.api});At(()=>import(ki+"/scripts/app.js"),__vite__mapDeps([])).then(t=>{Pe=t==null?void 0:t.app});function Ee(t,e){if(Er==null)throw console.error("api is null!"),new Error("api is null!");return Er.fetchApi(t,e)}async function Hd(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await Ee(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function Vd(t,e){try{return await(await Ee("/workspace/save_db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t,json:e})})).text()}catch(n){console.error("Error saving workspace:",n)}}async function lp(t){try{return await(await Ee("/workspace/get_system_dir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absolute_dir:t??""})})).json()}catch(e){console.error("Error getting workflows dir:",e)}}async function cp(){try{return await(await Ee("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function Zd(){const e=await(await Ee("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function up(){try{return await(await Ee("/model_manager/get_model_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function dp(){try{return await(await Ee("/model_manager/get_folder_list",{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error get all models list:",t)}}async function fp(t){try{return await(await Ee("/model_manager/cancel_installation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({save_path:t})})).text()}catch(e){console.error("Error move file:",e)}}async function hp(t,e){try{return await(await Ee("/workspace/copy_json_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:t,dst:e})})).json()}catch(n){console.error("Error copy flows to new directory:",n)}}const Gd="backup",Cr="workspace";let er=null;function Yd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(Cr)||o.createObjectStore(Cr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Jd(){try{return er==null&&(er=await Yd()),new Promise((t,e)=>{if(er==null)return e("indexDB is null");const o=er.transaction([Cr],"readonly").objectStore(Cr).get(Gd);o.onsuccess=()=>{o.result?t(o.result.value):t(void 0)},o.onerror=()=>e(o.error)})}catch(t){console.error("Error while reading from database:",t)}}async function Xd(){try{return await Jd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const Ce=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ne=Object.keys,Me=Array.isArray;function We(t,e){return typeof e!="object"||Ne(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ce.Promise||(Ce.Promise=Promise);const Rn=Object.getPrototypeOf,Qd={}.hasOwnProperty;function Ge(t,e){return Qd.call(t,e)}function fn(t,e){typeof e=="function"&&(e=e(Rn(t))),(typeof Reflect>"u"?Ne:Reflect.ownKeys)(e).forEach(n=>{yt(t,n,e[n])})}const Ei=Object.defineProperty;function yt(t,e,n,r){Ei(t,e,We(n&&Ge(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function on(t){return{from:function(e){return t.prototype=Object.create(e.prototype),yt(t.prototype,"constructor",t),{extend:fn.bind(null,t.prototype)}}}}const ef=Object.getOwnPropertyDescriptor;function Os(t,e){let n;return ef(t,e)||(n=Rn(t))&&Os(n,e)}const tf=[].slice;function Sr(t,e,n){return tf.call(t,e,n)}function Ci(t,e){return e(t)}function _n(t){if(!t)throw new Error("Assertion Failed")}function Si(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Ii(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function vt(t,e){if(Ge(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,o=e.length;r["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>Ce[t]),rf=Pi.map(t=>Ce[t]);Ii(Pi,t=>[t,!0]);let kt=null;function Vn(t){kt=typeof WeakMap<"u"&&new WeakMap;const e=Io(t);return kt=null,e}function Io(t){if(!t||typeof t!="object")return t;let e=kt&&kt.get(t);if(e)return e;if(Me(t)){e=[],kt&&kt.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Rn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),kt&&kt.set(t,e),t)Ge(t,o)&&(e[o]=Io(t[o]))}return e}const{toString:of}={};function Oo(t){return of.call(t).slice(8,-1)}const Do=typeof Symbol<"u"?Symbol.iterator:"@@iterator",sf=typeof Do=="symbol"?function(t){var e;return t!=null&&(e=t[Do])&&e.apply(t)}:function(){return null},tn={};function pt(t){var e,n,r,o;if(arguments.length===1){if(Me(t))return t.slice();if(this===tn&&typeof t=="string")return[t];if(o=sf(t)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Ds=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var ut=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ji(t,e){ut=t,Ai=e}var Ai=()=>!0;const af=!new Error("").stack;function Gt(){if(af)try{throw Gt.arguments,new Error}catch(t){return t}return new Error}function Po(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` `).length),n.split(` -`).slice(e).filter(ji).map(r=>` -`+r).join("")):""}var Ai=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ps=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ai),af={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function sn(t,e){this._e=Gt(),this.name=t,this.message=e}function Ni(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function Ir(t,e,n,r){this._e=Gt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Ni(t,e)}function Sn(t,e){this._e=Gt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Ni(t,e)}on(sn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Po(this._e,2))}},toString:function(){return this.name+": "+this.message}}),on(Ir).from(sn),on(Sn).from(sn);var js=Ps.reduce((t,e)=>(t[e]=e+"Error",t),{});const lf=sn;var le=Ps.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Gt(),this.name=n,o?typeof o=="string"?(this.message=`${o}${s?` - `+s:""}`,this.inner=s||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=af[e]||n,this.inner=null)}return on(r).from(lf),t[e]=r,t},{});le.Syntax=SyntaxError,le.Type=TypeError,le.Range=RangeError;var ia=Ai.reduce((t,e)=>(t[e+"Error"]=le[e],t),{}),dr=Ps.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=le[e]),t),{});function be(){}function Tn(t){return t}function cf(t,e){return t==null||t===Tn?e:function(n){return e(t(n))}}function Vt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function uf(t,e){return t===be?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Vt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Vt(o,this.onerror):o),s!==void 0?s:n}}function df(t,e){return t===be?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Vt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Vt(r,this.onerror):r)}}function ff(t,e){return t===be?e:function(n){var r=t.apply(this,arguments);We(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Vt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Vt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:We(r,i)}}function hf(t,e){return t===be?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function As(t,e){return t===be?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,s=new Array(o);o--;)s[o]=arguments[o];return n.then(function(){return e.apply(r,s)})}return e.apply(this,arguments)}}dr.ModifyError=Ir,dr.DexieError=sn,dr.BulkError=Sn;var Bn={};const Fi=100,[jo,Or,Ao]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Rn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Rn(e),t]})(),Ri=Or&&Or.then,fr=jo&&jo.constructor,Ns=!!Ao;var No=!1,pf=Ao?()=>{Ao.then(tr)}:Ee.setImmediate?setImmediate.bind(null,tr):Ee.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{tr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(tr,0)},In=function(t,e){xn.push([t,e]),Dr&&(pf(),Dr=!1)},Fo=!0,Dr=!0,Wt=[],hr=[],Ro=null,To=Tn,an={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ua,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{ua(t[0],t[1])}catch{}})}},ae=an,xn=[],Ut=0,pr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=be,this._lib=!1;var e=this._PSD=ae;if(ut&&(this._stackHolder=Gt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Bn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Mo(this,this._value))}this._state=null,this._value=null,++e.ref,Bi(this,t)}const Bo={get:function(){var t=ae,e=Pr;function n(r,o){var s=!t.global&&(t!==ae||e!==Pr);const i=s&&!wt();var a=new oe((l,u)=>{Fs(this,new Ti(jr(r,t,s,i),jr(o,t,s,i),l,u,t))});return ut&&Li(a,this),a}return n.prototype=Bn,n},set:function(t){yt(this,"then",t&&t.prototype===Bn?Bo:{get:function(){return t},set:Bo.set})}};function Ti(t,e,n,r,o){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=o}function Bi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Zn();n&&typeof n.then=="function"?Bi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,Mi(t)),r&&Gn()}},Mo.bind(null,t))}catch(n){Mo(t,n)}}function Mo(t,e){if(hr.push(e),t._state===null){var n=t._lib&&Zn();e=To(e),t._state=!1,t._value=e,ut&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Os(e,"stack");e._promise=t,yt(e,"stack",{get:()=>No?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Wt.some(o=>o._value===r._value)||Wt.push(r)}(t),Mi(t),n&&Gn()}}function Mi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Ut==0&&Rs()},[]))}function Fs(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Ut,In(mf,[n,t,e])}else t._listeners.push(e)}function mf(t,e,n){try{Ro=e;var r,o=e._value;e._state?r=t(o):(hr.length&&(hr=[]),r=t(o),hr.indexOf(o)===-1&&function(s){for(var i=Wt.length;i;)if(Wt[--i]._value===s._value)return void Wt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Ro=null,--Ut==0&&Rs(),--n.psd.ref||n.psd.finalize()}}function zi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,i=t._value;i!=null?(o=i.name||"Error",s=i.message||i,r=Po(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return ut&&((r=Po(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&zi(t._prev,e,n)),e}function Li(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function tr(){Zn()&&Gn()}function Zn(){var t=Fo;return Fo=!1,Dr=!1,t}function Gn(){var t,e,n;do for(;xn.length>0;)for(t=xn,xn=[],n=t.length,e=0;e0);Fo=!0,Dr=!0}function Rs(){var t=Wt;Wt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=pr.slice(0),n=e.length;n;)e[--n]()}function nr(t){return new oe(Bn,!1,t)}function Ce(t,e){var n=ae;return function(){var r=Zn(),o=ae;try{return Ot(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Ot(o,!1),r&&Gn()}}}fn(oe.prototype,{then:Bo,_then:function(t,e){Fs(this,new Ti(null,null,t,e,ae))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):nr(r)):this.then(null,r=>r&&r.name===e?n(r):nr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),nr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{No=!0;var t=zi(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{No=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new le.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&yt(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),an.env=Wi(),fn(oe,{all:function(){var t=pt.apply(null,arguments).map(rr);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 Li(e,Ro),e},reject:nr,race:function(){var t=pt.apply(null,arguments).map(rr);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Pr},newPSD:It,usePSD:mn,scheduler:{get:()=>In,set:t=>{In=t}},rejectionMapper:{get:()=>To,set:t=>{To=t}},follow:(t,e)=>new oe((n,r)=>It((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Vt(function(){(function(a){function l(){a(),pr.splice(pr.indexOf(l),1)}pr.push(l),++Ut,In(()=>{--Ut==0&&Rs()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),fr&&(fr.allSettled&&yt(oe,"allSettled",function(){const t=pt.apply(null,arguments).map(rr);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)))})}),fr.any&&typeof AggregateError<"u"&&yt(oe,"any",function(){const t=pt.apply(null,arguments).map(rr);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 yf=0,mr=[],lo=0,Pr=0,vf=0;function It(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++vf;var i=an.env;s.env=Ns?{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:la(i.nthen,s),gthen:la(i.gthen,s)}:{},e&&We(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=mn(s,t,n,r);return s.ref===0&&s.finalize(),a}function pn(){return Be.id||(Be.id=++yf),++Be.awaits,Be.echoes+=Fi,Be.id}function wt(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Fi,!0)}function rr(t){return Be.echoes&&t&&t.constructor===fr?(pn(),t.then(e=>(wt(),e),e=>(wt(),Fe(e)))):t}function gf(t){++Pr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),mr.push(ae),Ot(t,!0)}function wf(){var t=mr[mr.length-1];mr.pop(),Ot(t,!1)}function Ot(t,e){var n=ae;if((e?!Be.echoes||lo++&&t===ae:!lo||--lo&&t===ae)||Ui(e?gf.bind(null,t):wf),t!==ae&&(ae=t,n===an&&(an.env=Wi()),Ns)){var r=an.env.Promise,o=t.env;Or.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ee,"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 Wi(){var t=Ee.Promise;return Ns?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ee,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Or.then,gthen:t.prototype.then}:{}}function mn(t,e,n,r,o){var s=ae;try{return Ot(t,!0),e(n,r,o)}finally{Ot(s,!1)}}function Ui(t){Ri.call(jo,t)}function jr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&pn(),Ot(e,!0);try{return t.apply(this,arguments)}finally{Ot(o,!1),r&&Ui(wt)}}}function la(t,e){return function(n,r){return t.call(this,jr(n,e),jr(r,e))}}(""+Ri).indexOf("[native code]")===-1&&(pn=wt=be);const ca="unhandledrejection";function ua(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ee.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ca,!0,!0),We(r,o)):Ee.CustomEvent&&We(r=new CustomEvent(ca,{detail:o}),o),r&&Ee.dispatchEvent&&(dispatchEvent(r),!Ee.PromiseRejectionEvent&&Ee.onunhandledrejection))try{Ee.onunhandledrejection(r)}catch{}ut&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function zo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ae.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===js.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>zo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>It(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new le.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new le.DatabaseClosed);t.open().catch(be)}return t._state.dbReadyPromise.then(()=>zo(t,e,n,r))}const da="3.2.4",Tt="￿",Lo=-1/0,ft="Invalid key provided. Keys must be of type string, number, Date or Array.",Ki="String expected.",On=[],Qr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),bf=Qr,_f=Qr,$i=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),eo="__dbnames",co="readonly",uo="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const qi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function or(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Vn(e))[t],e)}class xf{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new le.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Zn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):It(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):zo(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=Ne(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&n.every(c=>u.keyPath.indexOf(c)>=0)&&u.keyPath.every(c=>n.indexOf(c)>=0))[0];if(r&&this.db._maxKey!==Tt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&ut&&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(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[a,l]=n.reduce(([u,c],d)=>{const p=o[d],h=e[d];return[u||p,u||!p?Zt(c,p&&p.multi?b=>{const f=vt(b,d);return Me(f)&&f.some(y=>i(h,y))}:b=>i(h,vt(b,d))):c]},[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(Ge(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){We(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=or(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{rt(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=vt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new le.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{rt(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=or(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{rt(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:qi})).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 le.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:b})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,b)})})}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 le.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:b})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,b)})})}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,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[i].subscribe.apply(null,u),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rZt(r(),e()):e,t.justLimit=n&&!r}function yr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new le.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function fa(t,e,n){const r=yr(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 sr(t,e,n,r){const o=t.replayFilter?Zt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,u)=>{if(!o||o(l,u,p=>l.stop(p),p=>l.fail(p))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Ge(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),ha(fa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ha(fa(t,r,n),Zt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ha(t,e,n,r){var o=Ce(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 ze(t,e){try{const n=pa(t),r=pa(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:tsr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Qt(r,!0))return o.count({trans:n,query:{index:yr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return sr(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(u,c){return c?i(u[r[c]],c-1):u[o]}var a=this._ctx.dir==="next"?1:-1;function l(u,c){var d=i(u,s),p=i(c,s);return dp?a:0}return this.toArray(function(u){return u.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Qt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=yr(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 sr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Qt(n)?ho(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):ho(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),ho(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return fo(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 fo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Zt(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"&&Qt(n,!0)&&n.limit>0)return this._read(o=>{var s=yr(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 fo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ge(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=Ne(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 Ne(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const w=Math.min(c,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+w),cache:"immutable"}).then(_=>{const x=[],k=[],O=l?[]:null,E=[];for(let D=0;D0&&a.mutate({trans:r,type:"add",values:x}).then(D=>{for(let R in D.failures)E.splice(parseInt(R),1);b(x.length,D)})).then(()=>(k.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:k,criteria:N,changeSpec:typeof e!="function"&&e}).then(D=>b(k.length,D))).then(()=>(E.length>0||N&&e===po)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(D=>b(E.length,D))).then(()=>f.length>m+w&&y(m+c))})};return y(0).then(()=>{if(d.length>0)throw new Ir("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return Qt(e)&&(e.isPrimKey&&!_f||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:u,numFailures:c})=>{if(c)throw new Ir("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(po)}}const po=(t,e)=>e.value=null;function Ef(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Vi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function en(t){return new t.Collection(t,()=>Hi("")).limit(0)}function Sf(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],u)<0&&(a=l)}return itypeof f=="string"))return qe(t,Ki);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"?Ef:Cf;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}),u=f,c=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>xt(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var b=0;return h._addAlgorithm(function(f,y,m){var w=f.key;if(typeof w!="string")return!1;var _=s(w);if(e(_,l,b))return!0;for(var x=null,k=b;k0)&&(x=O)}return y(x!==null?function(){f.continue(x+c)}:m),!1}),h}function xt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Hi(t){return{type:1,lower:t,upper:t}}class Vi{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)?en(this):new this.Collection(this,()=>xt(e,n,!r,!o))}catch{return qe(this,ft)}}equals(e){return e==null?qe(this,ft):new this.Collection(this,()=>Hi(e))}above(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(e,void 0,!1))}below(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Ki):this.between(e,e+Tt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ar(this,(n,r)=>n.indexOf(r[0])===0,[e],Tt)}equalsIgnoreCase(e){return ar(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=pt.apply(tn,arguments);return e.length===0?en(this):ar(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=pt.apply(tn,arguments);return e.length===0?en(this):ar(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Tt)}anyOf(){const e=pt.apply(tn,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ft)}if(e.length===0)return en(this);const r=new this.Collection(this,()=>xt(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([[Lo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=pt.apply(tn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ft)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Lo,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 en(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",le.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(w,_){return d(w[0],_[0])}try{c=e.reduce(function(w,_){let x=0,k=w.length;for(;x0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return x===k&&w.push(_),w},[]),c.sort(p)}catch{return qe(this,ft)}let h=0;const b=u?w=>o(w,c[h][1])>0:w=>o(w,c[h][1])>=0,f=l?w=>s(w,c[h][0])>0:w=>s(w,c[h][0])>=0;let y=b;const m=new this.Collection(this,()=>xt(c[0][0],c[c.length-1][1],!l,!u));return m._ondirectionchange=w=>{w==="next"?(y=b,d=o):(y=f,d=s),c.sort(p)},m._addAlgorithm((w,_,x)=>{for(var k=w.key;y(k);)if(++h,h===c.length)return _(x),!1;return!!function(O){return!b(O)&&!f(O)}(k)||(this._cmp(k,c[h][1])===0||this._cmp(k,c[h][0])===0||_(()=>{d===o?w.continue(c[h][0]):w.continue(c[h][1])}),!1)}),m}startsWithAnyOf(){const e=pt.apply(tn,arguments);return e.every(n=>typeof n=="string")?e.length===0?en(this):this.inAnyRange(e.map(n=>[n,n+Tt])):qe(this,"startsWithAnyOf() only works with strings")}}function at(t){return Ce(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const zn="storagemutated",Et="x-storagemutated-1",Dt=Dn(null,zn);class If{_lock(){return _n(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(_n(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{mn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ae.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(_n(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new le.DatabaseClosed(r);case"MissingAPIError":throw new le.MissingAPI(r.message,r);default:throw new le.OpenFailed(r)}if(!this.active)throw new le.TransactionInactive;return _n(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=Ce(o=>{Mn(o),this._reject(e.error)}),e.onabort=Ce(o=>{Mn(o),this.active&&this._reject(new le.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Dt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new le.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new le.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return It(()=>{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(Ce(i.bind(null,l))),l=>n._waitingQueue.push(Ce(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 le.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ge(n,e))return n[e];const r=this.schema[e];if(!r)throw new le.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 Wo(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?"++":"")+Zi(e)}}function Zi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Gi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Si(n,r=>[r.name,r])}}let Ln=t=>{try{return t.only([[]]),Ln=()=>[[]],[[]]}catch{return Ln=()=>Tt,Tt}};function Uo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>vt(r,e)}(t):e=>vt(e,t)}function ya(t){return[].slice.call(t)}let Of=0;function Pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Df(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:u,upper:c,lowerOpen:d,upperOpen:p}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!p):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,u){const c=ya(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,b=Me(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:b,keyPath:p,autoIncrement:h,unique:!0,extractKey:Uo(p)},indexes:ya(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:_,unique:x,multiEntry:k,keyPath:O}=w,E={name:_,compound:Me(O),keyPath:O,unique:x,multiEntry:k,extractKey:Uo(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:c.length>0&&"getAll"in u.objectStore(c[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(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:p,keys:h,values:b,range:f}){return new Promise((y,m)=>{y=Ce(y);const w=d.objectStore(c),_=w.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:k}=h||b||{length:1};if(h&&b&&h.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(k===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let D=0;const R=P=>{++D,Mn(P)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:D,failures:N,results:[],lastResult:void 0});f.type===3?E.push(O=w.clear()):E.push(O=w.delete(r(f)))}else{const[P,B]=x?_?[b,h]:[b,null]:[h,null];if(x)for(let v=0;v{const B=P.target.result;E.forEach((v,T)=>v.error!=null&&(N[T]=v.error)),y({numFailures:D,failures:N,results:p==="delete"?h:E.map(v=>v.result),lastResult:B})};O.onerror=P=>{R(P),$(P)},O.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,b)=>{h=Ce(h);const f=d.objectStore(c),y=p.length,m=new Array(y);let w,_=0,x=0;const k=E=>{const N=E.target;m[N._pos]=N.result,++x===_&&h(m)},O=at(b);for(let E=0;Enew Promise((h,b)=>{h=Ce(h);const f=d.objectStore(c).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=at(b)}),query:function(d){return p=>new Promise((h,b)=>{h=Ce(h);const{trans:f,values:y,limit:m,query:w}=p,_=m===1/0?void 0:m,{index:x,range:k}=w,O=f.objectStore(c),E=x.isPrimaryKey?O:O.index(x.name),N=r(k);if(m===0)return h({result:[]});if(d){const D=y?E.getAll(N,_):E.getAllKeys(N,_);D.onsuccess=R=>h({result:R.target.result}),D.onerror=at(b)}else{let D=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];R.onsuccess=P=>{const B=R.result;return B?($.push(y?B.value:B.primaryKey),++D===m?h({result:$}):void B.continue()):h({result:$})},R.onerror=at(b)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:b,unique:f}){return new Promise((y,m)=>{y=Ce(y);const{index:w,range:_}=h,x=d.objectStore(c),k=w.isPrimaryKey?x:x.index(w.name),O=b?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in k)?k.openCursor(r(_),O):k.openKeyCursor(r(_),O);E.onerror=at(m),E.onsuccess=Ce(N=>{const D=E.result;if(!D)return void y(null);D.___id=++Of,D.done=!1;const R=D.continue.bind(D);let $=D.continuePrimaryKey;$&&($=$.bind(D));const P=D.advance.bind(D),B=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=Ce(m),D.next=function(){let v=1;return this.start(()=>v--?this.continue():this.stop()).then(()=>this)},D.start=v=>{const T=new Promise((A,X)=>{A=Ce(A),E.onerror=at(X),D.fail=X,D.stop=K=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=B,A(K)}}),H=()=>{if(E.result)try{v()}catch(A){D.fail(A)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return E.onsuccess=Ce(A=>{E.onsuccess=H,H()}),D.continue=R,D.continuePrimaryKey=$,D.advance=P,H(),T},y(D)},m)})},count({query:d,trans:p}){const{index:h,range:b}=d;return new Promise((f,y)=>{const m=p.objectStore(c),w=h.isPrimaryKey?m:m.index(h.name),_=r(b),x=_?w.count(_):w.count();x.onsuccess=Ce(k=>f(k.target.result)),x.onerror=at(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 Ko({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(c,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),c)}(Df(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=Os(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?yt(i,o,{get(){return this.table(o)},set(l){ki(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function $o({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Pf(t,e){return t._cfg.version-e._cfg.version}function jf(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=ae.transless||ae;It(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{mo(n,l,o[l].primKey,o[l].indexes)}),Ko(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},u,c,d){const p=[],h=l._versions;let b=l._dbSchema=Ho(l,l.idbdb,d),f=!1;const y=h.filter(w=>w._cfg.version>=u);function m(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(m):oe.resolve()}return y.forEach(w=>{p.push(()=>{const _=b,x=w._cfg.dbschema;Vo(l,_,d),Vo(l,x,d),b=l._dbSchema=x;const k=Yi(_,x);k.add.forEach(E=>{mo(d,E[0],E[1].primKey,E[1].indexes)}),k.change.forEach(E=>{if(E.recreate)throw new le.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(D=>qo(N,D)),E.change.forEach(D=>{N.deleteIndex(D.name),qo(N,D)}),E.del.forEach(D=>N.deleteIndex(D))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>u){Ko(l,d),c._memoizedTables={},f=!0;let E=Ii(x);k.del.forEach($=>{E[$]=_[$]}),$o(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],Ne(E),E),c.schema=E;const N=Ds(O);let D;N&&pn();const R=oe.follow(()=>{if(D=O(c),D&&N){var $=wt.bind(null,null);D.then($,$)}});return D&&typeof D.then=="function"?oe.resolve(D):R.then(()=>D)}}),p.push(_=>{(!f||!bf)&&function(x,k){[].slice.call(k.db.objectStoreNames).forEach(O=>x[O]==null&&k.db.deleteObjectStore(O))}(w._cfg.dbschema,_),$o(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),m().then(()=>{var w,_;_=d,Ne(w=b).forEach(x=>{_.db.objectStoreNames.contains(x)||mo(_,x,w[x].primKey,w[x].indexes)})})}(t,e,s,n).catch(i)})}function Yi(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&&!Qr)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let u;for(u in a)l[u]||i.del.push(u);for(u in l){const c=a[u],d=l[u];c?c.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 mo(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=>qo(o,s)),o}function qo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Ho(t,e,n){const r={};return Sr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=Wo(Zi(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Wo(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Me(u),a===0)}),s=o.shift();if(s.multi)throw new le.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new le.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new le.Schema("Index must have a name and cannot be an empty string")}),n[r]=Gi(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?We(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{We(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,$o(n,[n._allTables,n,n.Transaction.prototype]),Ar(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=As(this._cfg.contentUpgrade||be,e),this}}function Ts(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Kt(eo,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Bs(t){return t&&typeof t.databases=="function"}function Zo(t){return It(function(){return ae.letThrough=!0,t()})}function Nf(){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 Ff(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);ut&&(e.openCanceller._stackHolder=Gt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new le.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Nf()).then(()=>new oe((l,u)=>{if(o(),!n)throw new le.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new le.MissingAPI;d.onerror=at(u),d.onblocked=Ce(t._fireOnBlocked),d.onupgradeneeded=Ce(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,i.abort(),d.result.close();const b=n.deleteDatabase(c);b.onsuccess=b.onerror=Ce(()=>{u(new le.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=at(u);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,jf(t,h/10,i,u)}},u),d.onsuccess=Ce(()=>{i=null;const p=t._novip.idbdb=d.result,h=Sr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((b=h).length===1?b[0]:b,"readonly");e.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const _=y._dbSchema=Ho(0,m,w);y._storeNames=Sr(m.objectStoreNames,0),Ar(y,[y._allTables],Ne(_),_)}(t,p,f):(Vo(t,t._dbSchema,f),function(y,m){const w=Yi(Ho(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.")),Ko(t,f)}catch{}var b;On.push(t),p.onversionchange=Ce(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Ce(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:y},m){!Bs(f)&&m!==eo&&Ts(f,y).put({name:m}).catch(be)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Zo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(As,be);return e.onReadyBeingFired=[],oe.resolve(Zo(()=>u(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(),Fe(l)}).finally(()=>{e.openComplete=!0,s()})}function Go(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 Rf(t,e,n){var r=arguments.length;if(r<2)throw new le.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Oi(o),n]}function Ji(t,e,n,r,o){return oe.resolve().then(()=>{const s=ae.transless||ae,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===js.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ji(t,e,n,null,o))):Fe(d)}const l=Ds(o);let u;l&&pn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=wt.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Go(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new le.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Fe(d)))})}function ir(t,e,n){const r=Me(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Uo(c),unique:!y&&p.unique};return b.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?c[0]:c.slice(0,f-1),d+1,p),b.sort((w,_)=>w.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const c of r.indexes)i(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(p=c.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:ir(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:ir(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:c;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[Pn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:p,keyLength:h}=c.query.index;return p?n.openCursor(l(c)).then(b=>b&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(ir(m,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?f.continue(f.key.slice(0,h).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,w){f.continuePrimaryKey(ir(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}})}(b)):n.openCursor(c)}}}}}};function Ms(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Ge(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Oo(s);a!==Oo(i)?n[r+o]=e[o]:a==="Object"?Ms(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}),Ne(e).forEach(o=>{Ge(t,o)||(n[r+o]=e[o])}),n}const Bf={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=ae.trans,{deleting:a,creating:l,updating:u}=i.table(e).hook;switch(s.type){case"add":if(l.fire===be)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===be&&u.fire===be)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===be)break;return i._promise("readwrite",()=>c(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 c(p){const h=ae.trans,b=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!b)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:b}:{...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,b).then(f=>{const y=b.map((m,w)=>{const _=f[w],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,m,_,h);else if(p.type==="add"||_===void 0){const k=l.fire.call(x,m,p.values[w],h);m==null&&k!=null&&(m=k,p.keys[w]=m,r.outbound||rt(p.values[w],r.keyPath,m))}else{const k=Ms(_,p.values[w]),O=u.fire.call(x,k,m,_,h);if(O){const E=p.values[w];Object.keys(O).forEach(N=>{Ge(E,N)?E[N]=O[N]:rt(E,N,O[N])})}}return x});return n.mutate(p).then(({failures:m,results:w,numFailures:_,lastResult:x})=>{for(let k=0;k(y.forEach(w=>w.onerror&&w.onerror(m)),Promise.reject(m)))})}function d(p,h,b){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:b}).then(({result:f})=>c({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=Xi(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"?Vn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function zs(t){return!("from"in t)}const ht=function(t,e){if(!this){const n=new ht;return t&&"d"in t&&We(n,t),n}We(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Wn(t,e,n){const r=ze(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(zs(t))return We(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(ze(n,t.from)<0)return o?Wn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},va(t);if(ze(e,t.to)>0)return s?Wn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},va(t);ze(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),ze(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){zs(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 zf(t,e){const n=Yo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Yo(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(ze(a.from,o.to)<=0&&ze(a.to,o.from)>=0)return!0;ze(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function Yo(t){let e=zs(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&&ze(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||ze(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 va(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=ga(i)}t.d=ga(t)}function ga({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}fn(ht.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},[Do](){return Yo(this)}});const Lf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new ht(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,u={...o,mutate:p=>{const h=p.trans,b=h.mutatedParts||(h.mutatedParts={}),f=O=>{const E=`idb://${e}/${r}/${O}`;return b[E]||(b[E]=new ht)},y=f(""),m=f(":dels"),{type:w}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const k=p.trans._cache;return o.mutate(p).then(O=>{if(Me(_)){w!=="delete"&&(_=O.results),y.addKeys(_);const E=Xi(_,k);E||w==="add"||m.addKeys(_),(E||x)&&function(N,D,R,$){function P(B){const v=N(B.name||"");function T(A){return A!=null?B.extractKey(A):null}const H=A=>B.multiEntry&&Me(A)?A.forEach(X=>v.addKey(X)):v.addKey(A);(R||$).forEach((A,X)=>{const K=R&&T(R[X]),ne=$&&T($[X]);ze(K,ne)!==0&&(K!=null&&H(K),ne!=null&&H(ne))})}D.indexes.forEach(P)}(f,s,E,x)}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})}},c=({query:{index:p,range:h}})=>{var b,f;return[p,new ht((b=h.lower)!==null&&b!==void 0?b:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new ht(p.key)],getMany:p=>[i,new ht().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ne(d).forEach(p=>{u[p]=function(h){const{subscr:b}=ae;if(b){const f=x=>{const k=`idb://${e}/${r}/${x}`;return b[k]||(b[k]=new ht)},y=f(""),m=f(":dels"),[w,_]=d[p](h);if(f(w.name||"").add(_),!w.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(k=>{if(p==="query"){if(l&&h.values)return x.then(({result:E})=>(y.addKeys(E),k));const O=h.values?k.result.map(a):k.result;h.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=k,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 k})}m.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class Kt{constructor(e,n){this._middlewares={},this.verno=0;const r=Kt.dependencies;this._options=n={addons:Kt.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:[As,be]}),this.on.ready.subscribe=Ei(this.on.ready.subscribe,a=>(l,u)=>{Kt.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||oe.resolve().then(l),u&&a(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&a(l);else{a(l);const d=this;u||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,bn(kf.prototype,function(a,l){this.db=i;let u=qi,c=null;if(l)try{u=l()}catch(b){c=b}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:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:c,or:d.or,valueMapper:h!==Tn?h:null}})),this.Table=function(a){return bn(xf.prototype,function(l,u,c){this.db=a,this._tx=c,this.name=l,this.schema=u,this.hook=a._allTables[l]?a._allTables[l].hook:Dn(null,{creating:[uf,be],reading:[cf,Tn],updating:[ff,be],deleting:[df,be]})})}(this),this.Transaction=function(a){return bn(If.prototype,function(l,u,c,d,p){this.db=a,this.mode=l,this.storeNames=u,this.schema=c,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,b)=>{this._resolve=h,this._reject=b}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var b=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):b&&this.idbtrans&&this.idbtrans.abort(),Fe(h)})})}(this),this.Version=function(a){return bn(Af.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return bn(Vi.prototype,function(l,u,c){this.db=a,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=a._deps.indexedDB;if(!d)throw new le.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,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=a=>{this.on("blocked").fire(a),On.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Tf),this.use(Bf),this.use(Lf),this.use(Mf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new le.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new le.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(Pf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ae.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new le.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new le.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 Ff(this)}_close(){const e=this._state,n=On.indexOf(this);if(n>=0&&On.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 le.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=Ce(()=>{(function({indexedDB:a,IDBKeyRange:l},u){!Bs(a)&&u!==eo&&Ts(a,l).delete(u).catch(be)})(this._deps,this.name),r()}),i.onerror=at(o),i.onblocked=this._fireOnBlocked};if(e)throw new le.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 Ne(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Rf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ae.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(u=>{var c=u instanceof this.Table?u.name:u;if(typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===co)i=co;else{if(e!="rw"&&e!=uo)throw new le.InvalidArgument("Invalid transaction mode: "+e);i=uo}if(o){if(o.mode===co&&i===uo){if(!s)throw new le.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new le.SubTransaction("Table "+u+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(u){return o?o._promise(null,(c,d)=>{d(u)}):Fe(u)}const l=Ji.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?mn(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ge(this._allTables,e))throw new le.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Wf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Uf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Wf](){return this}}function Qi(t,e){return Ne(e).forEach(n=>{Nr(t[n]||(t[n]=new ht),e[n])}),t}function Kf(t){let e,n=!1;const r=new Uf(o=>{const s=Ds(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,Dt.storagemutated.unsubscribe(h)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ne(l).some(f=>a[f]&&zf(a[f],l[f]))}const h=f=>{Qi(a,f),p()&&b()},b=()=>{if(c||i)return;a={};const f={},y=function(m){s&&pn();const w=()=>It(t,{subscr:m,trans:null}),_=ae.trans?mn(ae.transless,w):w();return s&&_.then(wt,wt),_}(f);d||(Dt(zn,h),d=!0),c=!0,Promise.resolve(y).then(m=>{n=!0,e=m,c=!1,i||(p()?b():(a={},l=f,o.next&&o.next(m)))},m=>{c=!1,n=!1,o.error&&o.error(m),u.unsubscribe()})};return b(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let Jo;try{Jo={indexedDB:Ee.indexedDB||Ee.mozIndexedDB||Ee.webkitIndexedDB||Ee.msIndexedDB,IDBKeyRange:Ee.IDBKeyRange||Ee.webkitIDBKeyRange}}catch{Jo={indexedDB:null,IDBKeyRange:null}}const Rt=Kt;function vr(t){let e=mt;try{mt=!0,Dt.storagemutated.fire(t)}finally{mt=e}}fn(Rt,{...dr,delete:t=>new Rt(t,{addons:[]}).delete(),exists:t=>new Rt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Bs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==eo)):Ts(e,n).toCollection().primaryKeys()}(Rt.dependencies).then(t)}catch{return Fe(new le.MissingAPI)}},defineClass:()=>function(t){We(this,t)},ignoreTransaction:t=>ae.trans?mn(ae.transless,t):t(),vip:Zo,async:function(t){return function(){try{var e=Go(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Fe(n)}}},spawn:function(t,e,n){try{var r=Go(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Fe(o)}},currentTransaction:{get:()=>ae.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Rt.ignoreTransaction(t):t).timeout(e||6e4);return ae.trans?ae.trans.waitFor(n):n},Promise:oe,debug:{get:()=>ut,set:t=>{Pi(t,t==="dexie"?()=>!0:$i)}},derive:on,extend:We,props:fn,override:Ei,Events:Dn,on:Dt,liveQuery:Kf,extendObservabilitySet:Qi,getByKeyPath:vt,setByKeyPath:rt,delByKeyPath:function(t,e){typeof e=="string"?rt(t,e,void 0):"length"in e&&[].map.call(e,function(n){rt(t,n,void 0)})},shallowClone:Ii,deepClone:Vn,getObjectDiff:Ms,cmp:ze,asap:Ci,minKey:Lo,addons:[],connections:On,errnames:js,dependencies:Jo,semVer:da,version:da.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Rt.maxKey=Ln(Rt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Dt(zn,t=>{if(!mt){let e;Qr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Et,!0,!0,t)):e=new CustomEvent(Et,{detail:t}),mt=!0,dispatchEvent(e),mt=!1}}),addEventListener(Et,({detail:t})=>{mt||vr(t)}));let mt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Et);typeof t.unref=="function"&&t.unref(),Dt(zn,e=>{mt||t.postMessage(e)}),t.onmessage=e=>{e.data&&vr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Dt(zn,e=>{try{mt||(typeof localStorage<"u"&&localStorage.setItem(Et,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Et,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Et){const n=JSON.parse(e.newValue);n&&vr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Et&&vr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof sn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!ia[t.name])return t;var n=new ia[t.name](e||t.message,t);return"stack"in t&&yt(n,"stack",{get:function(){return this.inner.stack}}),n},Pi(ut,$i);var $f=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))($f||{}),gr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(gr||{});const qf="comfyui_workspace_db";class Hf extends Kt{constructor(){super(qf);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 ce=new Hf;class Yt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ce[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")});try{Hd(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=Fn()),e.createTime||(e.createTime=Date.now()),await ce[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ce[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ce[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ce[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ce[this.tableName].toArray()}async filter(e){return await ce[this.tableName].filter(e).toArray()}async batchQuery(e){return await ce[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 qd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Jd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ce[this.tableName].get(e)}async delete(e){await ce[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ce[this.tableName].where(e).equals(n).toArray()}}const Vf=80,Tr=class Tr extends Yt{constructor(){super("changelogs")}static async load(){return new Tr}async listByWorkflowID(e){return await ce.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 await ce.changelogs.add(r),await this.deleteLogsExceedLimit(e.workflowID),r}async deleteLogsExceedLimit(e){var o;const n=await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=Y==null?void 0:Y.settings)==null?void 0:o.maximumChangelogNumber)??Vf;if(n.length>r){const s=n.slice(r);await ce.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(Tr,"TABLE_NAME","changelogs");let Xo=Tr;const hp="CWM_WORKFLOWS_SORT_TYPE";var it=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(it||{});const pp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}];function el(t,e=!0,n=!1,r="-"){const o=new Date(t),s=String(o.getDate()).padStart(2,"0"),i=String(o.getMonth()+1).padStart(2,"0"),a=o.getFullYear(),l=String(o.getHours()).padStart(2,"0"),u=String(o.getMinutes()).padStart(2,"0"),c=String(o.getSeconds()).padStart(2,"0"),d=`${i}${r}${s}${r}${a}`;return e?d+` ${l}:${u}`:n?d+`:${c}`:d}const wr=(t,e=it.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case it.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case it.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case it.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case it.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case it.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Zf(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=Y==null?void 0:Y.settings)==null?void 0:n.shortcuts;if(!e)return!1;for(const r in e){const s=e[r].split("+"),i={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const a in i)i[a]||delete i[a];if(s.length===Object.keys(i).length&&s.every(a=>i[a]))return r}};function vp(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Gf(t){return`/workspace/view_media?filename=${t}`}function wa(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function tl(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 Yf=t=>{const e=tl(t);window.open(`${window.location.origin}/#${e}`)},nl={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},Ue="workspace_info",Jf=9999999,ba="upgrade_to_2way_sync",Ls=28,gp="SHORTCUT_TRIGGER_EVENT";function br(...t){const e=t.filter(n=>n!=="").join("/");return Pt(e)}function Pt(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function yo(t){return br(t.parentFolderID??"",t.name+".json")}var Je;(t=>{async function e(l,u){try{const d=await(await Se("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:yo(l),newParentPath:u})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(c){console.error("Error deleting file:",c)}}t.moveWorkflow=e;async function n(l,u){try{const d=await(await Se("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(u??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(c){console.error("Error deleting file:",c)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:u},c){try{const p=await(await Se("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(l??"",u+".json"),newName:c})})).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 u=l.json,c=JSON.parse(u);c.extra[Ue]==null&&(c.extra[Ue]={}),c.extra[Ue].id=l.id,c.extra[Ue].saveLock=l.saveLock,c.extra[Ue].cloudID=l.cloudID,c.extra[Ue].coverMediaPath=l.coverMediaPath;const p=await(await Se("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:yo(l),json:JSON.stringify(c)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} +`).slice(e).filter(Ai).map(r=>` +`+r).join("")):""}var Ni=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ps=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ni),lf={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function sn(t,e){this._e=Gt(),this.name=t,this.message=e}function Fi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` +`)}function Ir(t,e,n,r){this._e=Gt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Fi(t,e)}function Sn(t,e){this._e=Gt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Fi(t,e)}on(sn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Po(this._e,2))}},toString:function(){return this.name+": "+this.message}}),on(Ir).from(sn),on(Sn).from(sn);var js=Ps.reduce((t,e)=>(t[e]=e+"Error",t),{});const cf=sn;var le=Ps.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Gt(),this.name=n,o?typeof o=="string"?(this.message=`${o}${s?` + `+s:""}`,this.inner=s||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=lf[e]||n,this.inner=null)}return on(r).from(cf),t[e]=r,t},{});le.Syntax=SyntaxError,le.Type=TypeError,le.Range=RangeError;var la=Ni.reduce((t,e)=>(t[e+"Error"]=le[e],t),{}),dr=Ps.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=le[e]),t),{});function be(){}function Tn(t){return t}function uf(t,e){return t==null||t===Tn?e:function(n){return e(t(n))}}function Vt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function df(t,e){return t===be?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Vt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Vt(o,this.onerror):o),s!==void 0?s:n}}function ff(t,e){return t===be?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Vt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Vt(r,this.onerror):r)}}function hf(t,e){return t===be?e:function(n){var r=t.apply(this,arguments);We(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Vt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Vt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:We(r,i)}}function pf(t,e){return t===be?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function As(t,e){return t===be?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,s=new Array(o);o--;)s[o]=arguments[o];return n.then(function(){return e.apply(r,s)})}return e.apply(this,arguments)}}dr.ModifyError=Ir,dr.DexieError=sn,dr.BulkError=Sn;var Bn={};const Ri=100,[jo,Or,Ao]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Rn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Rn(e),t]})(),Ti=Or&&Or.then,fr=jo&&jo.constructor,Ns=!!Ao;var No=!1,mf=Ao?()=>{Ao.then(tr)}:Ce.setImmediate?setImmediate.bind(null,tr):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{tr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(tr,0)},In=function(t,e){xn.push([t,e]),Dr&&(mf(),Dr=!1)},Fo=!0,Dr=!0,Wt=[],hr=[],Ro=null,To=Tn,an={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:da,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{da(t[0],t[1])}catch{}})}},ae=an,xn=[],Ut=0,pr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=be,this._lib=!1;var e=this._PSD=ae;if(ut&&(this._stackHolder=Gt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Bn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Mo(this,this._value))}this._state=null,this._value=null,++e.ref,Mi(this,t)}const Bo={get:function(){var t=ae,e=Pr;function n(r,o){var s=!t.global&&(t!==ae||e!==Pr);const i=s&&!wt();var a=new oe((l,u)=>{Fs(this,new Bi(jr(r,t,s,i),jr(o,t,s,i),l,u,t))});return ut&&Wi(a,this),a}return n.prototype=Bn,n},set:function(t){yt(this,"then",t&&t.prototype===Bn?Bo:{get:function(){return t},set:Bo.set})}};function Bi(t,e,n,r,o){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=o}function Mi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Zn();n&&typeof n.then=="function"?Mi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,zi(t)),r&&Gn()}},Mo.bind(null,t))}catch(n){Mo(t,n)}}function Mo(t,e){if(hr.push(e),t._state===null){var n=t._lib&&Zn();e=To(e),t._state=!1,t._value=e,ut&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Os(e,"stack");e._promise=t,yt(e,"stack",{get:()=>No?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Wt.some(o=>o._value===r._value)||Wt.push(r)}(t),zi(t),n&&Gn()}}function zi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Ut==0&&Rs()},[]))}function Fs(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Ut,In(yf,[n,t,e])}else t._listeners.push(e)}function yf(t,e,n){try{Ro=e;var r,o=e._value;e._state?r=t(o):(hr.length&&(hr=[]),r=t(o),hr.indexOf(o)===-1&&function(s){for(var i=Wt.length;i;)if(Wt[--i]._value===s._value)return void Wt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Ro=null,--Ut==0&&Rs(),--n.psd.ref||n.psd.finalize()}}function Li(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,i=t._value;i!=null?(o=i.name||"Error",s=i.message||i,r=Po(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return ut&&((r=Po(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Li(t._prev,e,n)),e}function Wi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function tr(){Zn()&&Gn()}function Zn(){var t=Fo;return Fo=!1,Dr=!1,t}function Gn(){var t,e,n;do for(;xn.length>0;)for(t=xn,xn=[],n=t.length,e=0;e0);Fo=!0,Dr=!0}function Rs(){var t=Wt;Wt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=pr.slice(0),n=e.length;n;)e[--n]()}function nr(t){return new oe(Bn,!1,t)}function Se(t,e){var n=ae;return function(){var r=Zn(),o=ae;try{return Ot(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Ot(o,!1),r&&Gn()}}}fn(oe.prototype,{then:Bo,_then:function(t,e){Fs(this,new Bi(null,null,t,e,ae))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):nr(r)):this.then(null,r=>r&&r.name===e?n(r):nr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),nr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{No=!0;var t=Li(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{No=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new le.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&yt(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),an.env=Ui(),fn(oe,{all:function(){var t=pt.apply(null,arguments).map(rr);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 Wi(e,Ro),e},reject:nr,race:function(){var t=pt.apply(null,arguments).map(rr);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ae,set:t=>ae=t},totalEchoes:{get:()=>Pr},newPSD:It,usePSD:mn,scheduler:{get:()=>In,set:t=>{In=t}},rejectionMapper:{get:()=>To,set:t=>{To=t}},follow:(t,e)=>new oe((n,r)=>It((o,s)=>{var i=ae;i.unhandleds=[],i.onunhandled=s,i.finalize=Vt(function(){(function(a){function l(){a(),pr.splice(pr.indexOf(l),1)}pr.push(l),++Ut,In(()=>{--Ut==0&&Rs()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),fr&&(fr.allSettled&&yt(oe,"allSettled",function(){const t=pt.apply(null,arguments).map(rr);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)))})}),fr.any&&typeof AggregateError<"u"&&yt(oe,"any",function(){const t=pt.apply(null,arguments).map(rr);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 vf=0,mr=[],lo=0,Pr=0,gf=0;function It(t,e,n,r){var o=ae,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++gf;var i=an.env;s.env=Ns?{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:ca(i.nthen,s),gthen:ca(i.gthen,s)}:{},e&&We(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=mn(s,t,n,r);return s.ref===0&&s.finalize(),a}function pn(){return Be.id||(Be.id=++vf),++Be.awaits,Be.echoes+=Ri,Be.id}function wt(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Ri,!0)}function rr(t){return Be.echoes&&t&&t.constructor===fr?(pn(),t.then(e=>(wt(),e),e=>(wt(),Fe(e)))):t}function wf(t){++Pr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),mr.push(ae),Ot(t,!0)}function bf(){var t=mr[mr.length-1];mr.pop(),Ot(t,!1)}function Ot(t,e){var n=ae;if((e?!Be.echoes||lo++&&t===ae:!lo||--lo&&t===ae)||Ki(e?wf.bind(null,t):bf),t!==ae&&(ae=t,n===an&&(an.env=Ui()),Ns)){var r=an.env.Promise,o=t.env;Or.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 Ui(){var t=Ce.Promise;return Ns?{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:Or.then,gthen:t.prototype.then}:{}}function mn(t,e,n,r,o){var s=ae;try{return Ot(t,!0),e(n,r,o)}finally{Ot(s,!1)}}function Ki(t){Ti.call(jo,t)}function jr(t,e,n,r){return typeof t!="function"?t:function(){var o=ae;n&&pn(),Ot(e,!0);try{return t.apply(this,arguments)}finally{Ot(o,!1),r&&Ki(wt)}}}function ca(t,e){return function(n,r){return t.call(this,jr(n,e),jr(r,e))}}(""+Ti).indexOf("[native code]")===-1&&(pn=wt=be);const ua="unhandledrejection";function da(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(ua,!0,!0),We(r,o)):Ce.CustomEvent&&We(r=new CustomEvent(ua,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}ut&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function zo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ae.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===js.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>zo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>It(()=>(ae.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new le.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new le.DatabaseClosed);t.open().catch(be)}return t._state.dbReadyPromise.then(()=>zo(t,e,n,r))}const fa="3.2.4",Tt="￿",Lo=-1/0,ft="Invalid key provided. Keys must be of type string, number, Date or Array.",$i="String expected.",On=[],Qr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),_f=Qr,xf=Qr,qi=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),eo="__dbnames",co="readonly",uo="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Hi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function or(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Vn(e))[t],e)}class kf{_trans(e,n,r){const o=this._tx||ae.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new le.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Zn();try{return o&&o.db===this.db?o===ae.trans?o._promise(e,i,r):It(()=>o._promise(e,i,r),{trans:o,transless:ae.transless||ae}):zo(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=Ne(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&n.every(c=>u.keyPath.indexOf(c)>=0)&&u.keyPath.every(c=>n.indexOf(c)>=0))[0];if(r&&this.db._maxKey!==Tt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&ut&&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(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[a,l]=n.reduce(([u,c],d)=>{const p=o[d],h=e[d];return[u||p,u||!p?Zt(c,p&&p.multi?b=>{const f=vt(b,d);return Me(f)&&f.some(y=>i(h,y))}:b=>i(h,vt(b,d))):c]},[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(Ge(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){We(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=or(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{rt(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=vt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new le.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ne(n).forEach(o=>{rt(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=or(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{rt(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:Hi})).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 le.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:b})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,b)})})}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 le.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new le.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(or(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:b})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,b)})})}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,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[i].subscribe.apply(null,u),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rZt(r(),e()):e,t.justLimit=n&&!r}function yr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new le.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function ha(t,e,n){const r=yr(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 sr(t,e,n,r){const o=t.replayFilter?Zt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,u)=>{if(!o||o(l,u,p=>l.stop(p),p=>l.fail(p))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Ge(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),pa(ha(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return pa(ha(t,r,n),Zt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function pa(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 ze(t,e){try{const n=ma(t),r=ma(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:tsr(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Qt(r,!0))return o.count({trans:n,query:{index:yr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return sr(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(u,c){return c?i(u[r[c]],c-1):u[o]}var a=this._ctx.dir==="next"?1:-1;function l(u,c){var d=i(u,s),p=i(c,s);return dp?a:0}return this.toArray(function(u){return u.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Qt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=yr(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 sr(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Qt(n)?ho(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):ho(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),ho(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return fo(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 fo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Zt(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"&&Qt(n,!0)&&n.limit>0)return this._read(o=>{var s=yr(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 fo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ge(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=Ne(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 Ne(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const w=Math.min(c,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+w),cache:"immutable"}).then(_=>{const x=[],k=[],O=l?[]:null,E=[];for(let D=0;D0&&a.mutate({trans:r,type:"add",values:x}).then(D=>{for(let R in D.failures)E.splice(parseInt(R),1);b(x.length,D)})).then(()=>(k.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:k,criteria:N,changeSpec:typeof e!="function"&&e}).then(D=>b(k.length,D))).then(()=>(E.length>0||N&&e===po)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(D=>b(E.length,D))).then(()=>f.length>m+w&&y(m+c))})};return y(0).then(()=>{if(d.length>0)throw new Ir("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return Qt(e)&&(e.isPrimKey&&!xf||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:u,numFailures:c})=>{if(c)throw new Ir("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(po)}}const po=(t,e)=>e.value=null;function Cf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Zi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function en(t){return new t.Collection(t,()=>Vi("")).limit(0)}function If(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],u)<0&&(a=l)}return itypeof f=="string"))return qe(t,$i);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"?Cf:Sf;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}),u=f,c=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>xt(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var b=0;return h._addAlgorithm(function(f,y,m){var w=f.key;if(typeof w!="string")return!1;var _=s(w);if(e(_,l,b))return!0;for(var x=null,k=b;k0)&&(x=O)}return y(x!==null?function(){f.continue(x+c)}:m),!1}),h}function xt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Vi(t){return{type:1,lower:t,upper:t}}class Zi{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)?en(this):new this.Collection(this,()=>xt(e,n,!r,!o))}catch{return qe(this,ft)}}equals(e){return e==null?qe(this,ft):new this.Collection(this,()=>Vi(e))}above(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(e,void 0,!1))}below(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ft):new this.Collection(this,()=>xt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,$i):this.between(e,e+Tt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ar(this,(n,r)=>n.indexOf(r[0])===0,[e],Tt)}equalsIgnoreCase(e){return ar(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=pt.apply(tn,arguments);return e.length===0?en(this):ar(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=pt.apply(tn,arguments);return e.length===0?en(this):ar(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Tt)}anyOf(){const e=pt.apply(tn,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ft)}if(e.length===0)return en(this);const r=new this.Collection(this,()=>xt(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([[Lo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=pt.apply(tn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ft)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Lo,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 en(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",le.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(w,_){return d(w[0],_[0])}try{c=e.reduce(function(w,_){let x=0,k=w.length;for(;x0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return x===k&&w.push(_),w},[]),c.sort(p)}catch{return qe(this,ft)}let h=0;const b=u?w=>o(w,c[h][1])>0:w=>o(w,c[h][1])>=0,f=l?w=>s(w,c[h][0])>0:w=>s(w,c[h][0])>=0;let y=b;const m=new this.Collection(this,()=>xt(c[0][0],c[c.length-1][1],!l,!u));return m._ondirectionchange=w=>{w==="next"?(y=b,d=o):(y=f,d=s),c.sort(p)},m._addAlgorithm((w,_,x)=>{for(var k=w.key;y(k);)if(++h,h===c.length)return _(x),!1;return!!function(O){return!b(O)&&!f(O)}(k)||(this._cmp(k,c[h][1])===0||this._cmp(k,c[h][0])===0||_(()=>{d===o?w.continue(c[h][0]):w.continue(c[h][1])}),!1)}),m}startsWithAnyOf(){const e=pt.apply(tn,arguments);return e.every(n=>typeof n=="string")?e.length===0?en(this):this.inAnyRange(e.map(n=>[n,n+Tt])):qe(this,"startsWithAnyOf() only works with strings")}}function at(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",Et="x-storagemutated-1",Dt=Dn(null,zn);class Of{_lock(){return _n(!ae.global),++this._reculock,this._reculock!==1||ae.global||(ae.lockOwnerFor=this),this}_unlock(){if(_n(!ae.global),--this._reculock==0)for(ae.global||(ae.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{mn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ae.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(_n(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new le.DatabaseClosed(r);case"MissingAPIError":throw new le.MissingAPI(r.message,r);default:throw new le.OpenFailed(r)}if(!this.active)throw new le.TransactionInactive;return _n(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 le.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Dt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new le.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new le.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ae])});if(r)return It(()=>{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 le.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ge(n,e))return n[e];const r=this.schema[e];if(!r)throw new le.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 Wo(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?"++":"")+Gi(e)}}function Gi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Yi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ii(n,r=>[r.name,r])}}let Ln=t=>{try{return t.only([[]]),Ln=()=>[[]],[[]]}catch{return Ln=()=>Tt,Tt}};function Uo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>vt(r,e)}(t):e=>vt(e,t)}function va(t){return[].slice.call(t)}let Df=0;function Pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Pf(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:u,upper:c,lowerOpen:d,upperOpen:p}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!p):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,u){const c=va(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,b=Me(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:b,keyPath:p,autoIncrement:h,unique:!0,extractKey:Uo(p)},indexes:va(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:_,unique:x,multiEntry:k,keyPath:O}=w,E={name:_,compound:Me(O),keyPath:O,unique:x,multiEntry:k,extractKey:Uo(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:c.length>0&&"getAll"in u.objectStore(c[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(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:p,keys:h,values:b,range:f}){return new Promise((y,m)=>{y=Se(y);const w=d.objectStore(c),_=w.keyPath==null,x=p==="put"||p==="add";if(!x&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:k}=h||b||{length:1};if(h&&b&&h.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(k===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let D=0;const R=P=>{++D,Mn(P)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:D,failures:N,results:[],lastResult:void 0});f.type===3?E.push(O=w.clear()):E.push(O=w.delete(r(f)))}else{const[P,B]=x?_?[b,h]:[b,null]:[h,null];if(x)for(let v=0;v{const B=P.target.result;E.forEach((v,T)=>v.error!=null&&(N[T]=v.error)),y({numFailures:D,failures:N,results:p==="delete"?h:E.map(v=>v.result),lastResult:B})};O.onerror=P=>{R(P),$(P)},O.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,b)=>{h=Se(h);const f=d.objectStore(c),y=p.length,m=new Array(y);let w,_=0,x=0;const k=E=>{const N=E.target;m[N._pos]=N.result,++x===_&&h(m)},O=at(b);for(let E=0;Enew Promise((h,b)=>{h=Se(h);const f=d.objectStore(c).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=at(b)}),query:function(d){return p=>new Promise((h,b)=>{h=Se(h);const{trans:f,values:y,limit:m,query:w}=p,_=m===1/0?void 0:m,{index:x,range:k}=w,O=f.objectStore(c),E=x.isPrimaryKey?O:O.index(x.name),N=r(k);if(m===0)return h({result:[]});if(d){const D=y?E.getAll(N,_):E.getAllKeys(N,_);D.onsuccess=R=>h({result:R.target.result}),D.onerror=at(b)}else{let D=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];R.onsuccess=P=>{const B=R.result;return B?($.push(y?B.value:B.primaryKey),++D===m?h({result:$}):void B.continue()):h({result:$})},R.onerror=at(b)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:b,unique:f}){return new Promise((y,m)=>{y=Se(y);const{index:w,range:_}=h,x=d.objectStore(c),k=w.isPrimaryKey?x:x.index(w.name),O=b?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in k)?k.openCursor(r(_),O):k.openKeyCursor(r(_),O);E.onerror=at(m),E.onsuccess=Se(N=>{const D=E.result;if(!D)return void y(null);D.___id=++Df,D.done=!1;const R=D.continue.bind(D);let $=D.continuePrimaryKey;$&&($=$.bind(D));const P=D.advance.bind(D),B=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=Se(m),D.next=function(){let v=1;return this.start(()=>v--?this.continue():this.stop()).then(()=>this)},D.start=v=>{const T=new Promise((A,X)=>{A=Se(A),E.onerror=at(X),D.fail=X,D.stop=K=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=B,A(K)}}),H=()=>{if(E.result)try{v()}catch(A){D.fail(A)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return E.onsuccess=Se(A=>{E.onsuccess=H,H()}),D.continue=R,D.continuePrimaryKey=$,D.advance=P,H(),T},y(D)},m)})},count({query:d,trans:p}){const{index:h,range:b}=d;return new Promise((f,y)=>{const m=p.objectStore(c),w=h.isPrimaryKey?m:m.index(h.name),_=r(b),x=_?w.count(_):w.count();x.onsuccess=Se(k=>f(k.target.result)),x.onerror=at(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 Ko({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(c,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),c)}(Pf(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=Os(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?yt(i,o,{get(){return this.table(o)},set(l){Ei(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function $o({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function jf(t,e){return t._cfg.version-e._cfg.version}function Af(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=ae.transless||ae;It(()=>{ae.trans=s,ae.transless=a,e===0?(Ne(o).forEach(l=>{mo(n,l,o[l].primKey,o[l].indexes)}),Ko(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},u,c,d){const p=[],h=l._versions;let b=l._dbSchema=Ho(l,l.idbdb,d),f=!1;const y=h.filter(w=>w._cfg.version>=u);function m(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(m):oe.resolve()}return y.forEach(w=>{p.push(()=>{const _=b,x=w._cfg.dbschema;Vo(l,_,d),Vo(l,x,d),b=l._dbSchema=x;const k=Ji(_,x);k.add.forEach(E=>{mo(d,E[0],E[1].primKey,E[1].indexes)}),k.change.forEach(E=>{if(E.recreate)throw new le.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(D=>qo(N,D)),E.change.forEach(D=>{N.deleteIndex(D.name),qo(N,D)}),E.del.forEach(D=>N.deleteIndex(D))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>u){Ko(l,d),c._memoizedTables={},f=!0;let E=Oi(x);k.del.forEach($=>{E[$]=_[$]}),$o(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],Ne(E),E),c.schema=E;const N=Ds(O);let D;N&&pn();const R=oe.follow(()=>{if(D=O(c),D&&N){var $=wt.bind(null,null);D.then($,$)}});return D&&typeof D.then=="function"?oe.resolve(D):R.then(()=>D)}}),p.push(_=>{(!f||!_f)&&function(x,k){[].slice.call(k.db.objectStoreNames).forEach(O=>x[O]==null&&k.db.deleteObjectStore(O))}(w._cfg.dbschema,_),$o(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),m().then(()=>{var w,_;_=d,Ne(w=b).forEach(x=>{_.db.objectStoreNames.contains(x)||mo(_,x,w[x].primKey,w[x].indexes)})})}(t,e,s,n).catch(i)})}function Ji(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&&!Qr)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let u;for(u in a)l[u]||i.del.push(u);for(u in l){const c=a[u],d=l[u];c?c.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 mo(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=>qo(o,s)),o}function qo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Ho(t,e,n){const r={};return Sr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=Wo(Gi(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Wo(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Me(u),a===0)}),s=o.shift();if(s.multi)throw new le.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new le.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new le.Schema("Index must have a name and cannot be an empty string")}),n[r]=Yi(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?We(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{We(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,$o(n,[n._allTables,n,n.Transaction.prototype]),Ar(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ne(s),s),n._storeNames=Ne(s),this}upgrade(e){return this._cfg.contentUpgrade=As(this._cfg.contentUpgrade||be,e),this}}function Ts(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Kt(eo,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Bs(t){return t&&typeof t.databases=="function"}function Zo(t){return It(function(){return ae.letThrough=!0,t()})}function Ff(){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 Rf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);ut&&(e.openCanceller._stackHolder=Gt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new le.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Ff()).then(()=>new oe((l,u)=>{if(o(),!n)throw new le.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new le.MissingAPI;d.onerror=at(u),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 b=n.deleteDatabase(c);b.onsuccess=b.onerror=Se(()=>{u(new le.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=at(u);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,Af(t,h/10,i,u)}},u),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((b=h).length===1?b[0]:b,"readonly");e.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const _=y._dbSchema=Ho(0,m,w);y._storeNames=Sr(m.objectStoreNames,0),Ar(y,[y._allTables],Ne(_),_)}(t,p,f):(Vo(t,t._dbSchema,f),function(y,m){const w=Ji(Ho(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.")),Ko(t,f)}catch{}var b;On.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){!Bs(f)&&m!==eo&&Ts(f,y).put({name:m}).catch(be)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Zo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(As,be);return e.onReadyBeingFired=[],oe.resolve(Zo(()=>u(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(),Fe(l)}).finally(()=>{e.openComplete=!0,s()})}function Go(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 Tf(t,e,n){var r=arguments.length;if(r<2)throw new le.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Di(o),n]}function Xi(t,e,n,r,o){return oe.resolve().then(()=>{const s=ae.transless||ae,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===js.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Xi(t,e,n,null,o))):Fe(d)}const l=Ds(o);let u;l&&pn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=wt.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Go(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new le.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Fe(d)))})}function ir(t,e,n){const r=Me(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Uo(c),unique:!y&&p.unique};return b.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?c[0]:c.slice(0,f-1),d+1,p),b.sort((w,_)=>w.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const c of r.indexes)i(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(p=c.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:ir(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:ir(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:c;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[Pn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:p,keyLength:h}=c.query.index;return p?n.openCursor(l(c)).then(b=>b&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(ir(m,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?f.continue(f.key.slice(0,h).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,w){f.continuePrimaryKey(ir(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}})}(b)):n.openCursor(c)}}}}}};function Ms(t,e,n,r){return n=n||{},r=r||"",Ne(t).forEach(o=>{if(Ge(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Oo(s);a!==Oo(i)?n[r+o]=e[o]:a==="Object"?Ms(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}),Ne(e).forEach(o=>{Ge(t,o)||(n[r+o]=e[o])}),n}const Mf={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=ae.trans,{deleting:a,creating:l,updating:u}=i.table(e).hook;switch(s.type){case"add":if(l.fire===be)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===be&&u.fire===be)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===be)break;return i._promise("readwrite",()=>c(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 c(p){const h=ae.trans,b=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!b)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:b}:{...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,b).then(f=>{const y=b.map((m,w)=>{const _=f[w],x={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(x,m,_,h);else if(p.type==="add"||_===void 0){const k=l.fire.call(x,m,p.values[w],h);m==null&&k!=null&&(m=k,p.keys[w]=m,r.outbound||rt(p.values[w],r.keyPath,m))}else{const k=Ms(_,p.values[w]),O=u.fire.call(x,k,m,_,h);if(O){const E=p.values[w];Object.keys(O).forEach(N=>{Ge(E,N)?E[N]=O[N]:rt(E,N,O[N])})}}return x});return n.mutate(p).then(({failures:m,results:w,numFailures:_,lastResult:x})=>{for(let k=0;k(y.forEach(w=>w.onerror&&w.onerror(m)),Promise.reject(m)))})}function d(p,h,b){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:b}).then(({result:f})=>c({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=Qi(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"?Vn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function zs(t){return!("from"in t)}const ht=function(t,e){if(!this){const n=new ht;return t&&"d"in t&&We(n,t),n}We(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Wn(t,e,n){const r=ze(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(zs(t))return We(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(ze(n,t.from)<0)return o?Wn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},ga(t);if(ze(e,t.to)>0)return s?Wn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},ga(t);ze(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),ze(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){zs(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 Lf(t,e){const n=Yo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Yo(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(ze(a.from,o.to)<=0&&ze(a.to,o.from)>=0)return!0;ze(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function Yo(t){let e=zs(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&&ze(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||ze(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 ga(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=wa(i)}t.d=wa(t)}function wa({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}fn(ht.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},[Do](){return Yo(this)}});const Wf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new ht(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,u={...o,mutate:p=>{const h=p.trans,b=h.mutatedParts||(h.mutatedParts={}),f=O=>{const E=`idb://${e}/${r}/${O}`;return b[E]||(b[E]=new ht)},y=f(""),m=f(":dels"),{type:w}=p;let[_,x]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const k=p.trans._cache;return o.mutate(p).then(O=>{if(Me(_)){w!=="delete"&&(_=O.results),y.addKeys(_);const E=Qi(_,k);E||w==="add"||m.addKeys(_),(E||x)&&function(N,D,R,$){function P(B){const v=N(B.name||"");function T(A){return A!=null?B.extractKey(A):null}const H=A=>B.multiEntry&&Me(A)?A.forEach(X=>v.addKey(X)):v.addKey(A);(R||$).forEach((A,X)=>{const K=R&&T(R[X]),ne=$&&T($[X]);ze(K,ne)!==0&&(K!=null&&H(K),ne!=null&&H(ne))})}D.indexes.forEach(P)}(f,s,E,x)}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})}},c=({query:{index:p,range:h}})=>{var b,f;return[p,new ht((b=h.lower)!==null&&b!==void 0?b:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new ht(p.key)],getMany:p=>[i,new ht().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ne(d).forEach(p=>{u[p]=function(h){const{subscr:b}=ae;if(b){const f=x=>{const k=`idb://${e}/${r}/${x}`;return b[k]||(b[k]=new ht)},y=f(""),m=f(":dels"),[w,_]=d[p](h);if(f(w.name||"").add(_),!w.isPrimaryKey){if(p!=="count"){const x=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(k=>{if(p==="query"){if(l&&h.values)return x.then(({result:E})=>(y.addKeys(E),k));const O=h.values?k.result.map(a):k.result;h.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=k,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 k})}m.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class Kt{constructor(e,n){this._middlewares={},this.verno=0;const r=Kt.dependencies;this._options=n={addons:Kt.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:[As,be]}),this.on.ready.subscribe=Ci(this.on.ready.subscribe,a=>(l,u)=>{Kt.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||oe.resolve().then(l),u&&a(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&a(l);else{a(l);const d=this;u||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,bn(Ef.prototype,function(a,l){this.db=i;let u=Hi,c=null;if(l)try{u=l()}catch(b){c=b}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:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:c,or:d.or,valueMapper:h!==Tn?h:null}})),this.Table=function(a){return bn(kf.prototype,function(l,u,c){this.db=a,this._tx=c,this.name=l,this.schema=u,this.hook=a._allTables[l]?a._allTables[l].hook:Dn(null,{creating:[df,be],reading:[uf,Tn],updating:[hf,be],deleting:[ff,be]})})}(this),this.Transaction=function(a){return bn(Of.prototype,function(l,u,c,d,p){this.db=a,this.mode=l,this.storeNames=u,this.schema=c,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,b)=>{this._resolve=h,this._reject=b}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var b=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):b&&this.idbtrans&&this.idbtrans.abort(),Fe(h)})})}(this),this.Version=function(a){return bn(Nf.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return bn(Zi.prototype,function(l,u,c){this.db=a,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=a._deps.indexedDB;if(!d)throw new le.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,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=a=>{this.on("blocked").fire(a),On.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Bf),this.use(Mf),this.use(Wf),this.use(zf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new le.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new le.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(jf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ae.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new le.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new le.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 Rf(this)}_close(){const e=this._state,n=On.indexOf(this);if(n>=0&&On.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 le.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},u){!Bs(a)&&u!==eo&&Ts(a,l).delete(u).catch(be)})(this._deps,this.name),r()}),i.onerror=at(o),i.onblocked=this._fireOnBlocked};if(e)throw new le.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 Ne(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Tf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ae.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(u=>{var c=u instanceof this.Table?u.name:u;if(typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===co)i=co;else{if(e!="rw"&&e!=uo)throw new le.InvalidArgument("Invalid transaction mode: "+e);i=uo}if(o){if(o.mode===co&&i===uo){if(!s)throw new le.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new le.SubTransaction("Table "+u+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(u){return o?o._promise(null,(c,d)=>{d(u)}):Fe(u)}const l=Xi.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ae.trans?mn(ae.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ge(this._allTables,e))throw new le.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Uf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Kf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Uf](){return this}}function el(t,e){return Ne(e).forEach(n=>{Nr(t[n]||(t[n]=new ht),e[n])}),t}function $f(t){let e,n=!1;const r=new Kf(o=>{const s=Ds(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,Dt.storagemutated.unsubscribe(h)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ne(l).some(f=>a[f]&&Lf(a[f],l[f]))}const h=f=>{el(a,f),p()&&b()},b=()=>{if(c||i)return;a={};const f={},y=function(m){s&&pn();const w=()=>It(t,{subscr:m,trans:null}),_=ae.trans?mn(ae.transless,w):w();return s&&_.then(wt,wt),_}(f);d||(Dt(zn,h),d=!0),c=!0,Promise.resolve(y).then(m=>{n=!0,e=m,c=!1,i||(p()?b():(a={},l=f,o.next&&o.next(m)))},m=>{c=!1,n=!1,o.error&&o.error(m),u.unsubscribe()})};return b(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let Jo;try{Jo={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{Jo={indexedDB:null,IDBKeyRange:null}}const Rt=Kt;function vr(t){let e=mt;try{mt=!0,Dt.storagemutated.fire(t)}finally{mt=e}}fn(Rt,{...dr,delete:t=>new Rt(t,{addons:[]}).delete(),exists:t=>new Rt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Bs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==eo)):Ts(e,n).toCollection().primaryKeys()}(Rt.dependencies).then(t)}catch{return Fe(new le.MissingAPI)}},defineClass:()=>function(t){We(this,t)},ignoreTransaction:t=>ae.trans?mn(ae.transless,t):t(),vip:Zo,async:function(t){return function(){try{var e=Go(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Fe(n)}}},spawn:function(t,e,n){try{var r=Go(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Fe(o)}},currentTransaction:{get:()=>ae.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Rt.ignoreTransaction(t):t).timeout(e||6e4);return ae.trans?ae.trans.waitFor(n):n},Promise:oe,debug:{get:()=>ut,set:t=>{ji(t,t==="dexie"?()=>!0:qi)}},derive:on,extend:We,props:fn,override:Ci,Events:Dn,on:Dt,liveQuery:$f,extendObservabilitySet:el,getByKeyPath:vt,setByKeyPath:rt,delByKeyPath:function(t,e){typeof e=="string"?rt(t,e,void 0):"length"in e&&[].map.call(e,function(n){rt(t,n,void 0)})},shallowClone:Oi,deepClone:Vn,getObjectDiff:Ms,cmp:ze,asap:Si,minKey:Lo,addons:[],connections:On,errnames:js,dependencies:Jo,semVer:fa,version:fa.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Rt.maxKey=Ln(Rt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Dt(zn,t=>{if(!mt){let e;Qr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(Et,!0,!0,t)):e=new CustomEvent(Et,{detail:t}),mt=!0,dispatchEvent(e),mt=!1}}),addEventListener(Et,({detail:t})=>{mt||vr(t)}));let mt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(Et);typeof t.unref=="function"&&t.unref(),Dt(zn,e=>{mt||t.postMessage(e)}),t.onmessage=e=>{e.data&&vr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Dt(zn,e=>{try{mt||(typeof localStorage<"u"&&localStorage.setItem(Et,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Et,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===Et){const n=JSON.parse(e.newValue);n&&vr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===Et&&vr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof sn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!la[t.name])return t;var n=new la[t.name](e||t.message,t);return"stack"in t&&yt(n,"stack",{get:function(){return this.inner.stack}}),n},ji(ut,qi);var qf=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(qf||{}),gr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(gr||{});const Hf="comfyui_workspace_db";class Vf extends Kt{constructor(){super(Hf);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 ce=new Vf;class Yt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ce[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")});try{Vd(this.tableName,JSON.stringify(n))}catch(r){console.error("error saving disk db",r)}}async add(e){return e.id||(e.id=Fn()),e.createTime||(e.createTime=Date.now()),await ce[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ce[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ce[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ce[this.tableName].update(e,n),this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ce[this.tableName].toArray()}async filter(e){return await ce[this.tableName].filter(e).toArray()}async batchQuery(e){return await ce[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 Hd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Xd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ce[this.tableName].get(e)}async delete(e){await ce[this.tableName].delete(e),this.saveDiskDB()}async listByIndex(e,n){return await ce[this.tableName].where(e).equals(n).toArray()}}const Zf=80,Tr=class Tr extends Yt{constructor(){super("changelogs")}static async load(){return new Tr}async listByWorkflowID(e){return await ce.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 await ce.changelogs.add(r),await this.deleteLogsExceedLimit(e.workflowID),r}async deleteLogsExceedLimit(e){var o;const n=await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=((o=Y==null?void 0:Y.settings)==null?void 0:o.maximumChangelogNumber)??Zf;if(n.length>r){const s=n.slice(r);await ce.changelogs.bulkDelete(s.map(i=>i.id))}}};Ie(Tr,"TABLE_NAME","changelogs");let Xo=Tr;const pp="CWM_WORKFLOWS_SORT_TYPE";var it=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(it||{});const mp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}];function tl(t,e=!0,n=!1,r="-"){const o=new Date(t),s=String(o.getDate()).padStart(2,"0"),i=String(o.getMonth()+1).padStart(2,"0"),a=o.getFullYear(),l=String(o.getHours()).padStart(2,"0"),u=String(o.getMinutes()).padStart(2,"0"),c=String(o.getSeconds()).padStart(2,"0"),d=`${i}${r}${s}${r}${a}`;return e?d+` ${l}:${u}`:n?d+`:${c}`:d}const wr=(t,e=it.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case it.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case it.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case it.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case it.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case it.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Gf(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=Y==null?void 0:Y.settings)==null?void 0:n.shortcuts;if(!e)return!1;for(const r in e){const s=e[r].split("+"),i={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const a in i)i[a]||delete i[a];if(s.length===Object.keys(i).length&&s.every(a=>i[a]))return r}};function gp(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Yf(t){return`/workspace/view_media?filename=${t}`}function ba(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function nl(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 Jf=t=>{const e=nl(t);window.open(`${window.location.origin}/#${e}`)},rl={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},Ue="workspace_info",Xf=9999999,_a="upgrade_to_2way_sync",Ls=28,wp="SHORTCUT_TRIGGER_EVENT",Ws={os:null},bp=()=>Ws.os==="Windows"?"\\":"/";function br(...t){const e=t.filter(n=>n!=="").join("/");return Pt(e)}function Pt(t){const e=t.split("/").filter(r=>r!=="").join("/");let n=e.replace(/\\/g,"/");return n=n.replace(/^\/+/,""),Ws.os==="Windows"&&(n=e.replace(/\//g,"\\")),n}function yo(t){return br(t.parentFolderID??"",t.name+".json")}var Je;(t=>{async function e(l,u){try{const d=await(await Ee("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:yo(l),newParentPath:u})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(c){console.error("Error deleting file:",c)}}t.moveWorkflow=e;async function n(l,u){try{const d=await(await Ee("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(u??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(c){console.error("Error deleting file:",c)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:u},c){try{const p=await(await Ee("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(l??"",u+".json"),newName:c})})).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 u=l.json,c=JSON.parse(u);c.extra[Ue]==null&&(c.extra[Ue]={}),c.extra[Ue].id=l.id,c.extra[Ue].saveLock=l.saveLock,c.extra[Ue].cloudID=l.cloudID,c.extra[Ue].coverMediaPath=l.coverMediaPath;const p=await(await Ee("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:yo(l),json:JSON.stringify(c)})})).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 Se("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:yo(l),deleteEmptyFolder:!1})})).text()}catch(u){alert("Error deleting workflow .json file: "+u),console.error("Error deleting file:",u)}}t.deleteWorkflow=s;async function i(l){var f;const{parentFolderID:u,name:c,json:d,id:p}=l;let h=JSON.parse(d);h.extra==null&&(h.extra={}),h.extra[Ue]==null&&(h.extra[Ue]={}),h.extra[Ue].id=p,h.extra[Ue].saveLock=l.saveLock,h.extra[Ue].cloudID=l.cloudID,h.extra[Ue].coverMediaPath=l.coverMediaPath;const b={parentFolderPath:Pt(u??""),name:c,json:JSON.stringify(h)};try{const m=await(await Se("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})).json();return m.name&&await((f=ce.workflows)==null?void 0:f.update(p,{name:m.name})),m}catch(y){return console.error(`Error creating file <${p}> at "${u}"`,y),alert(`Error creating file <${p}> at "${u}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:u,id:c}){const d=br(l??"",u+".json");try{const h=await(await Se("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return h.error&&(console.error(`Error getting file <${c}> at "${d}"`,h.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function Ws(t,e=!1,n=!1){try{return await(await Se("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Pt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function Xf(t,e){const n=Pt(t??""),o=(await Ws(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");if(Qf(a))return{id:Pt(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()};{const d=await((c=ce.workflows)==null?void 0:c.get(a.id).catch(h=>(console.error("Error getting workflow from indexdb",a.id,u,h),null)));return{cloudID:a.cloudID,coverMediaPath:a.coverMediaPath,saveLock:a.saveLock,...d,id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime,updateTime:a.updateTime}}}),s=await Promise.all(o);ce.workflows.bulkPut(s.filter(a=>!nh(a)));const i=s.filter(a=>a!=null);return wr(i,e??it.RECENTLY_MODIFIED)}function Qf(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Yt{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 ce.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(Y==null?void 0:Y.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(Y==null?void 0:Y.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,u=!0;for(;u;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,u=!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??Fn(),json:n.json??JSON.stringify(nl),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ce.workflows.add(i),this.saveDiskDB(),await(Y==null?void 0:Y.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):i}async update(n,r){throw new Error("Method not allowed.")}async updateTopFields(n,r){return this._update(n,r)}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ce.workflows.update(n,r);const o=await ce.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){const o=await(Y==null?void 0:Y.getSetting("twoWaySync")),s=await this.get(n);!await this.updateMetaInfo(n,r)||!s||o&&await Je.moveWorkflow(s,r.parentFolderID)}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(Y==null?void 0:Y.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(Y==null?void 0:Y.getSetting("twoWaySync"))&&a&&await Je.saveWorkflow(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const u=l.name&&r?l.name:await this.generateUniqueName(l.name,o),c=Fn(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Y==null?void 0:Y.getSetting("twoWaySync")))try{const b=JSON.parse(l.json),f=(a=(i=b==null?void 0:b.extra)==null?void 0:i[Ue])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(b){console.error("batchCreateFlows error",b)}}try{await ce.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&await(Y==null?void 0:Y.getSetting("twoWaySync"))&&await Je.deleteWorkflow(r),await ce.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ce.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Y==null?void 0:Y.getSetting("twoWaySync"))&&await Je.deleteWorkflow(o)}await ce.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Y==null?void 0:Y.getSetting("twoWaySync"))){const l=await Xf(n??null);return wr(l,r??it.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(He==null?void 0:He.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return wr(a,r??it.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Y==null?void 0:Y.getSetting("twoWaySync")),s=await ce.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)}}async listAll(n){const r=await(Y==null?void 0:Y.getSetting("twoWaySync"));let o;if(r){const i=(await Ws("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ce.workflows.get(a.id);return a.updateTime=(l==null?void 0:l.updateTime)??Date.now(),l!=null&&l.lastOpenedTime&&(a.lastOpenedTime=l==null?void 0:l.lastOpenedTime),a});o=await Promise.all(i)}else o=await ce.workflows.toArray();return n?wr(o,n):o}async updateLastOpenedTime(n){await ce.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Br,"TABLE_NAME","workflows");let Qo=Br;var Ct;(t=>{async function e({parentFolderID:a,name:l}){return Pt(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await Se("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Pt(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await Se("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();c.error&&alert("Failed to move folder: "+c.error)}t.moveFolder=r;async function o(a){try{return await(await Se("/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 u=await(await Se("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return u.error&&console.error("Error counting files:",u.error),u.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const c=await(await Se("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();c.error&&alert("Failed to rename folder: "+c.error)}catch(u){console.error("Error renaming file:",u)}}t.renameFolder=i})(Ct||(Ct={}));const Mr=class Mr extends Yt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Y==null?void 0:Y.getSetting("twoWaySync")),o=await Ct.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 Ct.createFolder(s):(await ce.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Y==null?void 0:Y.getSetting("twoWaySync")))return"parentFolderID"in n&&await Ct.moveFolder(e,n.parentFolderID??""),"name"in n&&await Ct.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;"name"in n&&n.name!=o.name;const s="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),s&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await ce.folders.update(e,n),this.saveDiskDB(),i}async deleteFolder(e,n=gr.DELETE){if(await(Y==null?void 0:Y.getSetting("twoWaySync"))){await Ws(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await Ct.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 u of o)if(u.parentFolderID===a)switch(n){case gr.DELETE:await(q==null?void 0:q.deleteFlow(u.id));break;case gr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(u.id,{parentFolderID:void 0}));break}await ce.folders.delete(a);const l=s.filter(u=>u.parentFolderID===a).map(u=>u.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Y==null?void 0:Y.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 es=Mr;class rl extends Yt{constructor(){super("media")}async listByWorkflowID(e){return await ce.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){if(e.localPath.split(".").pop()==null)return null;const r={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now()};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:r.localPath})),ce.media.put(r),this.saveDiskDB(),r}async delete(e){var n,r;super.delete(e),((n=q==null?void 0:q.curWorkflow)==null?void 0:n.coverMediaPath)===e&&(q==null||q.updateMetaInfo(q.curWorkflow.id,{coverMediaPath:void 0})),((r=q==null?void 0:q.curWorkflow)==null?void 0:r.latestImage)===e&&(q==null||q.updateMetaInfo(q.curWorkflow.id,{latestImage:void 0}))}}Ie(rl,"TABLE_NAME","media");const wp=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],bp=2,eh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function _p(t){return t.modelVersions!==void 0}function th(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function xp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return th(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 Yt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);Ie(this,"_settings");this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S",openSpotlightSearch:"Control+P"},defaultFolders:eh,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.co",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return n==="shortcuts"&&(r!=null&&r.shortcuts)?{...this.defaultSettings.shortcuts,...r.shortcuts}:(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),await Se("/workspace/save_settings",{method:"POST",body:JSON.stringify(this._settings),headers:{"Content-Type":"application/json"}}),this._settings={...this.defaultSettings,...o}}static async load(){const n=new zr,r=await Vd();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(o=>{n._autoSave=(o==null?void 0:o.autoSave)??!1,n._settings={...n.defaultSettings,...o}}),(n.defaultSettings.cloudHost.includes("nodecafe.org")||n.defaultSettings.cloudHost.includes("comfyspace.art"))&&await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(zr,"TABLE_NAME","userSettings");let ts=zr;const Lr=class Lr extends Yt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let ns=Lr;const Wr=class Wr extends Yt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ce[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 rs=Wr;function nh(t){return"type"in t&&t.type==="folder"}let q=null,_r=null,Y=null,He=null,Ve=null,$t=null,ge=null;async function rh(){const t=async()=>{q=await Qo.load()},e=async()=>{_r=await ns.load()},n=async()=>{Y=await ts.load()},r=async()=>{He=await es.load()},o=async()=>{Ve=await Xo.load()},s=async()=>{$t=new rl},i=async()=>{ge=await rs.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await oh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function oh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ce.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(He==null?void 0:He.getRecords());a&&await ce.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await($t==null?void 0:$t.getRecords());a&&await ce.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ce.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(_r==null?void 0:_r.getRecords());a&&await ce.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Y,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ce.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(ge==null?void 0:ge.getRecords());a&&await ce.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const bt=j.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:async()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{},setCurFlowIDAndName:()=>{}}),kp=j.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),vo={x:0,y:0};function sh({children:t,onDragEnd:e,dragIconId:n}){const r=j.useRef(vo),o=j.useRef(!1),[s,i]=j.useState(vo),a=d=>{var p,h,b;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(b=(h=d.target)==null?void 0:h.parentNode)==null?void 0:b.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=j.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=j.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),vo)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",u)},[e,l]),c={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return I.jsx("div",{style:c,onMouseDown:a,children:t})}var ah={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"},ih=Object.defineProperty,lh=Object.defineProperties,ch=Object.getOwnPropertyDescriptors,Fr=Object.getOwnPropertySymbols,ol=Object.prototype.hasOwnProperty,sl=Object.prototype.propertyIsEnumerable,_a=(t,e,n)=>e in t?ih(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xa=(t,e)=>{for(var n in e||(e={}))ol.call(e,n)&&_a(t,n,e[n]);if(Fr)for(var n of Fr(e))sl.call(e,n)&&_a(t,n,e[n]);return t},uh=(t,e)=>lh(t,ch(e)),dh=(t,e)=>{var n={};for(var r in t)ol.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Fr)for(var r of Fr(t))e.indexOf(r)<0&&sl.call(t,r)&&(n[r]=t[r]);return n},Re=(t,e,n)=>{const r=j.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=dh(i,["color","size","stroke","children"]);return j.createElement("svg",xa(uh(xa({ref:s},ah),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>j.createElement(p,h)),...c||[]])});return r.propTypes={color:Ft.string,size:Ft.oneOfType([Ft.string,Ft.number]),stroke:Ft.oneOfType([Ft.string,Ft.number])},r.displayName=`${e}`,r},fh=Re("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"}]]),hh=Re("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),Rr=Re("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"}]]),ph=Re("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"}]]),mh=Re("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"}]]),yh=Re("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"}]]),vh=Re("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"}]]),gh=Re("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"}]]),wh=Re("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"}]]),al=Re("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"}]]),bh=Re("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"}]]),_h=Re("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),xh=Re("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"}]]),kh=Re("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"}]]),il=Re("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"}]]),Eh=Re("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"}]]),Ch=Re("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"}]]),Sh=Re("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Ih(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return I.jsx(ui,{isLazy:!0,placement:"auto",gutter:0,children:({onClose:i})=>I.jsxs(I.Fragment,{children:[I.jsx(ci,{children:I.jsx(St,{children:I.jsx(Ht,{hasArrow:!0,label:s,placement:"bottom",children:I.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:I.jsx(kh,{color:"#F56565",size:"20px"}),isDisabled:o,variant:n})})})}),I.jsxs(pi,{children:[I.jsx(fi,{onClick:i}),I.jsxs(di,{children:[I.jsx(Mt,{mb:4,pr:4,fontWeight:600,children:e}),I.jsx(Le,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Oh({onClose:t}){ja();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=j.useContext(bt),[s,i]=j.useState(0),[a,l]=j.useState(null),[u,c]=j.useState([]),[d,p]=j.useState([]),h=async y=>{var k;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));c(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),x=(k=_==null?void 0:_[0])==null?void 0:k.id;x&&l(x)},b=async()=>{const y=await(ge==null?void 0:ge.listByWorkflowID(e))??[];p(y)},f=y=>{ge==null||ge.delete(y).then(()=>{b()})};return j.useEffect(()=>{switch(s){case 0:b();break;case 1:h(e);break}},[s]),j.useEffect(()=>(Pe.canvasEl.addEventListener("click",t),()=>{Pe.canvasEl.removeEventListener("click",t)}),[s]),I.jsxs(Hl,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[I.jsx(ql,{pb:1,mb:0,children:I.jsxs(kn,{justifyContent:"space-between",alignItems:"center",children:[I.jsx(ps,{size:"md",children:"Version History"}),I.jsx(jn,{size:"sm",icon:I.jsx(Sh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),I.jsx($l,{overflowY:"auto",gap:0,children:I.jsxs(vi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[I.jsxs(gi,{mb:"1em",children:[I.jsx(Co,{children:"Versions"}),I.jsx(Co,{children:"Change History"})]}),I.jsxs(wi,{children:[I.jsx(Eo,{children:I.jsx(rn,{divider:I.jsx(bo,{}),spacing:2,children:d==null?void 0:d.map(y=>I.jsxs(kn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[I.jsxs(rn,{textAlign:"left",gap:0,children:[I.jsx(Mt,{fontWeight:"500",children:y.name??"untitled"}),I.jsxs(Mt,{color:"GrayText",fontSize:"sm",children:["Created: ",el(y.createTime)]})]}),I.jsxs(kn,{alignItems:"center",gap:2,children:[I.jsx(Le,{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}Pe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),I.jsx(Ih,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),I.jsxs(Eo,{children:[I.jsx(Mt,{mb:4,children:"All the saved changes of this workflow"}),I.jsx(rn,{divider:I.jsx(bo,{}),spacing:2,children:u==null?void 0:u.map(y=>I.jsxs(zt,{justifyContent:"space-between",children:[I.jsxs(Le,{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}Pe.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?I.jsx(Xr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function Dh({workflowId:t,onClose:e}){const[n,r]=j.useState(""),[o,s]=j.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(ge==null?void 0:ge.listByWorkflowID(t))??[]).some(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(Pe.graph.serialize());await(ge==null?void 0:ge.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return I.jsxs(as,{isOpen:!0,onClose:e,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Create Version"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!o,children:[I.jsx(Vr,{children:"Name"}),I.jsx(Un,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&I.jsx(Hr,{children:o})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),I.jsx(Le,{onClick:e,children:"Cancel"})]})]})]})}function Ph({options:t,menuButton:e,isOpen:n,onClose:r}){const o=j.useRef(null);return vc({ref:o,handler:()=>r()}),I.jsxs(St,{position:"relative",children:[I.jsx(St,{children:e}),n&&I.jsx(St,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function jh({menuButton:t,menuContent:e,onClose:n}){const r=j.useRef(),[o,s]=j.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return I.jsx(Ph,{isOpen:o,onClose:i,menuButton:I.jsx(St,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:I.jsx(Cs,{isOpen:!0,children:I.jsx(Ss,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}function Ah(t,e){const n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}function Ep(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Cp=[{label:"Private",value:"PRIVATE",icon:I.jsx(al,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:I.jsx(wh,{})},{label:"Public",value:"PUBLIC",icon:I.jsx(Ch,{})}],Sp=()=>{const t=Pe.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 Nh(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 Ip({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")),I.jsx("span",{children:n})}function Fh({}){const[t,e]=j.useState(),[n,r]=j.useState(),{curFlowID:o}=j.useContext(bt);return j.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Nh(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?I.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:I.jsx(Ia,{children:I.jsx(Xr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}const Rh=j.lazy(()=>At(()=>import("./ShareDialog-7hYnIR9_.js"),__vite__mapDeps([0,1,2,3,4,5])));function Th(){var x;const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=j.useContext(bt),[i,a]=j.useState(!1),[l,u]=j.useState(""),[c,d]=j.useState(""),[p,h]=j.useState(),[b,f]=j.useState({save:"",saveAs:""});j.useEffect(()=>{t&&(q==null||q.get(t).then(k=>{u((k==null?void 0:k.name)??""),h(k)})),Y==null||Y.getSetting("shortcuts").then(k=>{f(k)})},[t]);const y=k=>{u(k.target.value),c&&d("")},m=async()=>{if(!t){alert("Flow ID is required");return}const k=JSON.stringify(Pe.graph.serialize()),O=await(q==null?void 0:q.createFlow({json:k,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));O&&await e(O.id,null,!0),w()},w=()=>{o("root")},_=j.useCallback(async()=>{const k=q==null?void 0:q.curWorkflow;if(!k){alert("No current workflow!");return}const O=Pe.graph.serialize(),E=JSON.stringify(O,null,2);Ah(E,k.name)},[t]);return I.jsxs(I.Fragment,{children:[I.jsx(jh,{menuButton:I.jsx(Ia,{children:I.jsxs(Le,{px:1,height:Ls+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",I.jsx(hh,{size:20})]})}),menuContent:I.jsx(Cs,{isOpen:!0,children:I.jsxs(Ss,{minWidth:150,zIndex:1e3,children:[I.jsx(_t,{onClick:()=>r(),icon:I.jsx(Rr,{size:20}),iconSpacing:1,command:b.save,children:"Save"}),!((x=Y==null?void 0:Y.settings)!=null&&x.autoSave)&&I.jsx(Ht,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:I.jsx(_t,{onClick:n,icon:I.jsx(fh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),I.jsx(_t,{onClick:_,icon:I.jsx(ph,{size:20}),iconSpacing:1,children:"Download"}),I.jsx(_t,{onClick:()=>o("saveAsModal"),icon:I.jsx(Rr,{size:20}),iconSpacing:1,command:b.saveAs,children:"Save As"}),I.jsx(_t,{onClick:()=>a(!0),icon:I.jsx(Eh,{size:20}),iconSpacing:1,children:"Create Version"}),I.jsx(_t,{onClick:()=>o("versionHistory"),icon:I.jsx(gh,{size:20}),iconSpacing:1,children:"Versions History"}),I.jsx(_t,{onClick:()=>o("share"),icon:I.jsx(xh,{size:20}),iconSpacing:1,alignItems:"center",children:I.jsxs(zt,{children:[I.jsx("p",{children:"Share"})," ",I.jsx(Xr,{size:"sm",children:"🧪beta"}),I.jsx(Fh,{})]})})]})})}),s==="share"&&I.jsx(Rh,{onClose:()=>o("root")}),s=="versionHistory"&&I.jsx(Oh,{onClose:()=>o("root")}),s==="saveAsModal"&&I.jsxs(as,{isOpen:!0,onClose:w,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Save As"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!c,children:[I.jsx(Vr,{children:"Workflow name"}),I.jsx(Un,{value:l,onChange:y,autoFocus:!0,onKeyUp:k=>{k.code==="Enter"&&!c&&l&&m()}}),c&&I.jsx(Hr,{children:c})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:m,isDisabled:!l||!!c,children:"Save"}),I.jsx(Le,{onClick:w,children:"Cancel"})]})]})]}),i&&I.jsx(Dh,{workflowId:t,onClose:()=>a(!1)})]})}function Bh({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=bc(),{curFlowID:i}=j.useContext(bt),[a,l]=j.useState(t),[u,c]=j.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),u&&c("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return b();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?c("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),b())}},b=()=>{c(""),s()};return i==null?null:I.jsxs(zt,{children:[I.jsx(Ht,{label:t,placement:"bottom",children:I.jsxs(Mt,{as:"div",color:"white",onClick:d,maxW:160,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[I.jsx("div",{style:{width:8,display:"inline-block"},children:I.jsx(Mt,{as:"span",children:n&&"* "})}),t]})}),I.jsxs(as,{isOpen:r,onClose:b,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Edit workflow name"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!u,children:[I.jsx(Vr,{children:"Workflow name"}),I.jsx(Un,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!u&&a&&h()}}),u&&I.jsx(Hr,{children:u})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!u,children:"Save"}),I.jsx(Le,{onClick:b,children:"Cancel"})]})]})]})]})}function Mh({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=j.useContext(bt);return j.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?I.jsx(kn,{alignItems:"center",children:I.jsx(Ra,{size:"sm",isAttached:!0,variant:"outline",children:I.jsx(Le,{rightIcon:I.jsx(il,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}function zh(){const{loadNewWorkflow:t,setCurFlowIDAndName:e,curFlowID:n}=j.useContext(bt),r=async()=>{const o=JSON.stringify(Pe.graph.serialize()),s=prompt("Enter workflow name","Untitled");if(!s)return;const i=await(q==null?void 0:q.createFlow({json:o,name:s}));i&&e(i)};return I.jsx(Ht,{label:n?"New workflow":"Save workflow",children:I.jsx(Le,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:Ls+"px",onClick:()=>n?t():r(),px:1,children:n?I.jsx(_h,{size:16,color:"white"}):I.jsx(Rr,{size:16,color:"white"})})})}const Lh=j.lazy(()=>At(()=>import("./AppIsDirtyEventListener-ZV5NPDCI.js"),__vite__mapDeps([6,1,7]))),Wh=j.lazy(()=>At(()=>import("./ModelManagerTopbar-azmEV7gi.js"),__vite__mapDeps([8,1,3,2,9,10,11]))),Uh=j.lazy(()=>At(()=>import("./SpotlightSearch-z3bKfoPZ.js"),__vite__mapDeps([12,1,7,13,14])));function Kh({curFlowName:t,setCurFlowName:e}){var c;const{isDirty:n,saveCurWorkflow:r,setRoute:o,curFlowID:s,route:i}=j.useContext(bt),[a,l]=j.useState(),u=j.useCallback((d,p=!1)=>{const{top:h=0,left:b=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=b;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),x=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+x>=m&&(y=m-x),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Y==null||Y.upsert({topBarStyle:{top:f,left:y}}))},[a]);return j.useEffect(()=>{Y==null||Y.getSetting("topBarStyle").then(d=>{u(d,!1)})},[]),a?I.jsx(sh,{onDragEnd:d=>{u({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:I.jsxs(zt,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[I.jsx(Le,{size:"sm","aria-label":"workspace folder",height:Ls+"px",onClick:()=>o("recentFlows"),px:2,children:I.jsxs(zt,{gap:1,children:[I.jsx(yh,{size:21}),I.jsx(il,{size:8})]})}),I.jsx(j.Suspense,{fallback:I.jsx("div",{style:{width:"60px"}}),children:I.jsx(Wh,{})}),I.jsx(zh,{}),I.jsx(Bh,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{u()})}}),((c=q==null?void 0:q.curWorkflow)==null?void 0:c.saveLock)&&I.jsx(al,{color:"#FFF",size:20}),s&&I.jsxs(zt,{gap:"4px",children:[I.jsx(Ht,{label:"Open gallery",children:I.jsx(jn,{onClick:()=>o("gallery"),icon:I.jsx(bh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),I.jsx(Th,{})]}),s&&n?I.jsx(Ht,{label:"Save workflow",children:I.jsx(jn,{onClick:()=>r(),icon:I.jsx(Rr,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):I.jsx("div",{style:{width:1}}),I.jsx(Mh,{}),I.jsx(Lh,{}),I.jsx(vh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),i==="spotlightSearch"&&I.jsx(Uh,{})]})}):null}function $h(){const{showDialog:t}=Oa(),{loadWorkflowID:e}=j.useContext(bt),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(ge==null?void 0:ge.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(d)await e(l.id,d.id);else{const p=await(ge==null?void 0:ge.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json,api_prompt:null}));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(ge==null?void 0:ge.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,api_prompt:null,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(qh(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 j.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function qh(t){return t.type==="workspace_open_workflow"}const Hh=t=>typeof t=="function",Vh=t=>{const[e,n]=j.useState(t),r=j.useRef(e),o=j.useCallback(s=>{r.current=Hh(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function lr(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 ll={exports:{}};/*! + `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await Ee("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:yo(l),deleteEmptyFolder:!1})})).text()}catch(u){alert("Error deleting workflow .json file: "+u),console.error("Error deleting file:",u)}}t.deleteWorkflow=s;async function i(l){var f;const{parentFolderID:u,name:c,json:d,id:p}=l;let h=JSON.parse(d);h.extra==null&&(h.extra={}),h.extra[Ue]==null&&(h.extra[Ue]={}),h.extra[Ue].id=p,h.extra[Ue].saveLock=l.saveLock,h.extra[Ue].cloudID=l.cloudID,h.extra[Ue].coverMediaPath=l.coverMediaPath;const b={parentFolderPath:Pt(u??""),name:c,json:JSON.stringify(h)};try{const m=await(await Ee("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})).json();return m.name&&await((f=ce.workflows)==null?void 0:f.update(p,{name:m.name})),m}catch(y){return console.error(`Error creating file <${p}> at "${u}"`,y),alert(`Error creating file <${p}> at "${u}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:u,id:c}){const d=br(l??"",u+".json");try{const h=await(await Ee("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return h.error&&(console.error(`Error getting file <${c}> at "${d}"`,h.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function Us(t,e=!1,n=!1){try{return await(await Ee("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Pt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function Qf(t,e){const n=Pt(t??""),o=(await Us(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");if(eh(a))return{id:Pt(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()};{const d=await((c=ce.workflows)==null?void 0:c.get(a.id).catch(h=>(console.error("Error getting workflow from indexdb",a.id,u,h),null)));return{cloudID:a.cloudID,coverMediaPath:a.coverMediaPath,saveLock:a.saveLock,...d,id:a.id,json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime,updateTime:a.updateTime}}}),s=await Promise.all(o);ce.workflows.bulkPut(s.filter(a=>!rh(a)));const i=s.filter(a=>a!=null);return wr(i,e??it.RECENTLY_MODIFIED)}function eh(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Yt{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 ce.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(Y==null?void 0:Y.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(Y==null?void 0:Y.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,u=!0;for(;u;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,u=!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??Fn(),json:n.json??JSON.stringify(rl),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ce.workflows.add(i),this.saveDiskDB(),await(Y==null?void 0:Y.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):i}async update(n,r){throw new Error("Method not allowed.")}async updateTopFields(n,r){return this._update(n,r)}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ce.workflows.update(n,r);const o=await ce.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){const o=await(Y==null?void 0:Y.getSetting("twoWaySync")),s=await this.get(n);!await this.updateMetaInfo(n,r)||!s||o&&await Je.moveWorkflow(s,r.parentFolderID)}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(Y==null?void 0:Y.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(Y==null?void 0:Y.getSetting("twoWaySync"))&&a&&await Je.saveWorkflow(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const u=l.name&&r?l.name:await this.generateUniqueName(l.name,o),c=Fn(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Y==null?void 0:Y.getSetting("twoWaySync")))try{const b=JSON.parse(l.json),f=(a=(i=b==null?void 0:b.extra)==null?void 0:i[Ue])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(b){console.error("batchCreateFlows error",b)}}try{await ce.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&await(Y==null?void 0:Y.getSetting("twoWaySync"))&&await Je.deleteWorkflow(r),await ce.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ce.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Y==null?void 0:Y.getSetting("twoWaySync"))&&await Je.deleteWorkflow(o)}await ce.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Y==null?void 0:Y.getSetting("twoWaySync"))){const l=await Qf(n??null);return wr(l,r??it.RECENTLY_MODIFIED)}const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(He==null?void 0:He.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return wr(a,r??it.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Y==null?void 0:Y.getSetting("twoWaySync")),s=await ce.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)}}async listAll(n){const r=await(Y==null?void 0:Y.getSetting("twoWaySync"));let o;if(r){const i=(await Us("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ce.workflows.get(a.id);return a.updateTime=(l==null?void 0:l.updateTime)??Date.now(),l!=null&&l.lastOpenedTime&&(a.lastOpenedTime=l==null?void 0:l.lastOpenedTime),a});o=await Promise.all(i)}else o=await ce.workflows.toArray();return n?wr(o,n):o}async updateLastOpenedTime(n){await ce.workflows.update(n,{lastOpenedTime:Date.now()})}};Ie(Br,"TABLE_NAME","workflows");let Qo=Br;var Ct;(t=>{async function e({parentFolderID:a,name:l}){return Pt(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await Ee("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Pt(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await Ee("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();c.error&&alert("Failed to move folder: "+c.error)}t.moveFolder=r;async function o(a){try{return await(await Ee("/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 u=await(await Ee("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return u.error&&console.error("Error counting files:",u.error),u.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const c=await(await Ee("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();c.error&&alert("Failed to rename folder: "+c.error)}catch(u){console.error("Error renaming file:",u)}}t.renameFolder=i})(Ct||(Ct={}));const Mr=class Mr extends Yt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Y==null?void 0:Y.getSetting("twoWaySync")),o=await Ct.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 Ct.createFolder(s):(await ce.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Y==null?void 0:Y.getSetting("twoWaySync")))return"parentFolderID"in n&&await Ct.moveFolder(e,n.parentFolderID??""),"name"in n&&await Ct.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;"name"in n&&n.name!=o.name;const s="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),s&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await ce.folders.update(e,n),this.saveDiskDB(),i}async deleteFolder(e,n=gr.DELETE){if(await(Y==null?void 0:Y.getSetting("twoWaySync"))){await Us(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await Ct.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 u of o)if(u.parentFolderID===a)switch(n){case gr.DELETE:await(q==null?void 0:q.deleteFlow(u.id));break;case gr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(u.id,{parentFolderID:void 0}));break}await ce.folders.delete(a);const l=s.filter(u=>u.parentFolderID===a).map(u=>u.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Y==null?void 0:Y.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 es=Mr;class ol extends Yt{constructor(){super("media")}async listByWorkflowID(e){return await ce.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){if(e.localPath.split(".").pop()==null)return null;const r={id:e.localPath,localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now()};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:r.localPath})),ce.media.put(r),this.saveDiskDB(),r}async delete(e){var n,r;super.delete(e),((n=q==null?void 0:q.curWorkflow)==null?void 0:n.coverMediaPath)===e&&(q==null||q.updateMetaInfo(q.curWorkflow.id,{coverMediaPath:void 0})),((r=q==null?void 0:q.curWorkflow)==null?void 0:r.latestImage)===e&&(q==null||q.updateMetaInfo(q.curWorkflow.id,{latestImage:void 0}))}}Ie(ol,"TABLE_NAME","media");const _p=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],xp=2,th={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function kp(t){return t.modelVersions!==void 0}function nh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Ep(t,e){var r,o,s,i,a,l;if(!t)return;let n;return nh(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 Yt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);Ie(this,"_settings");this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S",openSpotlightSearch:"Control+P"},defaultFolders:th,autoSave:!1,autoSaveDuration:3,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.co",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:80,hideCoverImage:!1,disableUnsavedWarning:!1}}get settings(){return this._settings}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return n==="shortcuts"&&(r!=null&&r.shortcuts)?{...this.defaultSettings.shortcuts,...r.shortcuts}:(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),await Ee("/workspace/save_settings",{method:"POST",body:JSON.stringify(this._settings),headers:{"Content-Type":"application/json"}}),this._settings={...this.defaultSettings,...o}}static async load(){const n=new zr,r=await Zd();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(o=>{n._autoSave=(o==null?void 0:o.autoSave)??!1,n._settings={...n.defaultSettings,...o}}),(n.defaultSettings.cloudHost.includes("nodecafe.org")||n.defaultSettings.cloudHost.includes("comfyspace.art"))&&await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Ie(zr,"TABLE_NAME","userSettings");let ts=zr;const Lr=class Lr extends Yt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let ns=Lr;const Wr=class Wr extends Yt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ce[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 rs=Wr;function rh(t){return"type"in t&&t.type==="folder"}let q=null,_r=null,Y=null,He=null,Ve=null,$t=null,ge=null;async function oh(){const t=async()=>{q=await Qo.load()},e=async()=>{_r=await ns.load()},n=async()=>{Y=await ts.load()},r=async()=>{He=await es.load()},o=async()=>{Ve=await Xo.load()},s=async()=>{$t=new ol},i=async()=>{ge=await rs.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await sh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function sh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ce.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(He==null?void 0:He.getRecords());a&&await ce.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await($t==null?void 0:$t.getRecords());a&&await ce.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ce.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(_r==null?void 0:_r.getRecords());a&&await ce.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Y,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ce.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(ge==null?void 0:ge.getRecords());a&&await ce.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const bt=j.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:async()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{},setCurFlowIDAndName:()=>{}}),Cp=j.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),vo={x:0,y:0};function ah({children:t,onDragEnd:e,dragIconId:n}){const r=j.useRef(vo),o=j.useRef(!1),[s,i]=j.useState(vo),a=d=>{var p,h,b;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(b=(h=d.target)==null?void 0:h.parentNode)==null?void 0:b.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=j.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=j.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),vo)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",u)},[e,l]),c={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return I.jsx("div",{style:c,onMouseDown:a,children:t})}var ih={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"},lh=Object.defineProperty,ch=Object.defineProperties,uh=Object.getOwnPropertyDescriptors,Fr=Object.getOwnPropertySymbols,sl=Object.prototype.hasOwnProperty,al=Object.prototype.propertyIsEnumerable,xa=(t,e,n)=>e in t?lh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ka=(t,e)=>{for(var n in e||(e={}))sl.call(e,n)&&xa(t,n,e[n]);if(Fr)for(var n of Fr(e))al.call(e,n)&&xa(t,n,e[n]);return t},dh=(t,e)=>ch(t,uh(e)),fh=(t,e)=>{var n={};for(var r in t)sl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Fr)for(var r of Fr(t))e.indexOf(r)<0&&al.call(t,r)&&(n[r]=t[r]);return n},Re=(t,e,n)=>{const r=j.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=fh(i,["color","size","stroke","children"]);return j.createElement("svg",ka(dh(ka({ref:s},ih),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>j.createElement(p,h)),...c||[]])});return r.propTypes={color:Ft.string,size:Ft.oneOfType([Ft.string,Ft.number]),stroke:Ft.oneOfType([Ft.string,Ft.number])},r.displayName=`${e}`,r},hh=Re("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"}]]),ph=Re("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),Rr=Re("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"}]]),mh=Re("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"}]]),yh=Re("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"}]]),vh=Re("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"}]]),gh=Re("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"}]]),wh=Re("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"}]]),bh=Re("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"}]]),il=Re("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"}]]),_h=Re("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"}]]),xh=Re("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),kh=Re("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"}]]),Eh=Re("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"}]]),ll=Re("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"}]]),Ch=Re("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"}]]),Sh=Re("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"}]]),Ih=Re("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Oh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return I.jsx(di,{isLazy:!0,placement:"auto",gutter:0,children:({onClose:i})=>I.jsxs(I.Fragment,{children:[I.jsx(ui,{children:I.jsx(St,{children:I.jsx(Ht,{hasArrow:!0,label:s,placement:"bottom",children:I.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:I.jsx(Eh,{color:"#F56565",size:"20px"}),isDisabled:o,variant:n})})})}),I.jsxs(mi,{children:[I.jsx(hi,{onClick:i}),I.jsxs(fi,{children:[I.jsx(Mt,{mb:4,pr:4,fontWeight:600,children:e}),I.jsx(Le,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Dh({onClose:t}){Aa();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=j.useContext(bt),[s,i]=j.useState(0),[a,l]=j.useState(null),[u,c]=j.useState([]),[d,p]=j.useState([]),h=async y=>{var k;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));c(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),x=(k=_==null?void 0:_[0])==null?void 0:k.id;x&&l(x)},b=async()=>{const y=await(ge==null?void 0:ge.listByWorkflowID(e))??[];p(y)},f=y=>{ge==null||ge.delete(y).then(()=>{b()})};return j.useEffect(()=>{switch(s){case 0:b();break;case 1:h(e);break}},[s]),j.useEffect(()=>(Pe.canvasEl.addEventListener("click",t),()=>{Pe.canvasEl.removeEventListener("click",t)}),[s]),I.jsxs(Vl,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[I.jsx(Hl,{pb:1,mb:0,children:I.jsxs(kn,{justifyContent:"space-between",alignItems:"center",children:[I.jsx(ps,{size:"md",children:"Version History"}),I.jsx(jn,{size:"sm",icon:I.jsx(Ih,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),I.jsx(ql,{overflowY:"auto",gap:0,children:I.jsxs(gi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[I.jsxs(wi,{mb:"1em",children:[I.jsx(Co,{children:"Versions"}),I.jsx(Co,{children:"Change History"})]}),I.jsxs(bi,{children:[I.jsx(Eo,{children:I.jsx(rn,{divider:I.jsx(bo,{}),spacing:2,children:d==null?void 0:d.map(y=>I.jsxs(kn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[I.jsxs(rn,{textAlign:"left",gap:0,children:[I.jsx(Mt,{fontWeight:"500",children:y.name??"untitled"}),I.jsxs(Mt,{color:"GrayText",fontSize:"sm",children:["Created: ",tl(y.createTime)]})]}),I.jsxs(kn,{alignItems:"center",gap:2,children:[I.jsx(Le,{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}Pe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),I.jsx(Oh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),I.jsxs(Eo,{children:[I.jsx(Mt,{mb:4,children:"All the saved changes of this workflow"}),I.jsx(rn,{divider:I.jsx(bo,{}),spacing:2,children:u==null?void 0:u.map(y=>I.jsxs(zt,{justifyContent:"space-between",children:[I.jsxs(Le,{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}Pe.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?I.jsx(Xr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function Ph({workflowId:t,onClose:e}){const[n,r]=j.useState(""),[o,s]=j.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(ge==null?void 0:ge.listByWorkflowID(t))??[]).some(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(Pe.graph.serialize());await(ge==null?void 0:ge.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return I.jsxs(as,{isOpen:!0,onClose:e,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Create Version"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!o,children:[I.jsx(Vr,{children:"Name"}),I.jsx(Un,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&I.jsx(Hr,{children:o})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),I.jsx(Le,{onClick:e,children:"Cancel"})]})]})]})}function jh({options:t,menuButton:e,isOpen:n,onClose:r}){const o=j.useRef(null);return gc({ref:o,handler:()=>r()}),I.jsxs(St,{position:"relative",children:[I.jsx(St,{children:e}),n&&I.jsx(St,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function Ah({menuButton:t,menuContent:e,onClose:n}){const r=j.useRef(),[o,s]=j.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return I.jsx(jh,{isOpen:o,onClose:i,menuButton:I.jsx(St,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:I.jsx(Cs,{isOpen:!0,children:I.jsx(Ss,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}function Nh(t,e){const n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}function Sp(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Ip=[{label:"Private",value:"PRIVATE",icon:I.jsx(il,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:I.jsx(bh,{})},{label:"Public",value:"PUBLIC",icon:I.jsx(Sh,{})}],Op=()=>{const t=Pe.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 Fh(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 Dp({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")),I.jsx("span",{children:n})}function Rh({}){const[t,e]=j.useState(),[n,r]=j.useState(),{curFlowID:o}=j.useContext(bt);return j.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Fh(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?I.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:I.jsx(Oa,{children:I.jsx(Xr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}const Th=j.lazy(()=>At(()=>import("./ShareDialog-opv28tSj.js"),__vite__mapDeps([0,1,2,3,4,5])));function Bh(){var x;const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=j.useContext(bt),[i,a]=j.useState(!1),[l,u]=j.useState(""),[c,d]=j.useState(""),[p,h]=j.useState(),[b,f]=j.useState({save:"",saveAs:""});j.useEffect(()=>{t&&(q==null||q.get(t).then(k=>{u((k==null?void 0:k.name)??""),h(k)})),Y==null||Y.getSetting("shortcuts").then(k=>{f(k)})},[t]);const y=k=>{u(k.target.value),c&&d("")},m=async()=>{if(!t){alert("Flow ID is required");return}const k=JSON.stringify(Pe.graph.serialize()),O=await(q==null?void 0:q.createFlow({json:k,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));O&&await e(O.id,null,!0),w()},w=()=>{o("root")},_=j.useCallback(async()=>{const k=q==null?void 0:q.curWorkflow;if(!k){alert("No current workflow!");return}const O=Pe.graph.serialize(),E=JSON.stringify(O,null,2);Nh(E,k.name)},[t]);return I.jsxs(I.Fragment,{children:[I.jsx(Ah,{menuButton:I.jsx(Oa,{children:I.jsxs(Le,{px:1,height:Ls+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",I.jsx(ph,{size:20})]})}),menuContent:I.jsx(Cs,{isOpen:!0,children:I.jsxs(Ss,{minWidth:150,zIndex:1e3,children:[I.jsx(_t,{onClick:()=>r(),icon:I.jsx(Rr,{size:20}),iconSpacing:1,command:b.save,children:"Save"}),!((x=Y==null?void 0:Y.settings)!=null&&x.autoSave)&&I.jsx(Ht,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:I.jsx(_t,{onClick:n,icon:I.jsx(hh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),I.jsx(_t,{onClick:_,icon:I.jsx(mh,{size:20}),iconSpacing:1,children:"Download"}),I.jsx(_t,{onClick:()=>o("saveAsModal"),icon:I.jsx(Rr,{size:20}),iconSpacing:1,command:b.saveAs,children:"Save As"}),I.jsx(_t,{onClick:()=>a(!0),icon:I.jsx(Ch,{size:20}),iconSpacing:1,children:"Create Version"}),I.jsx(_t,{onClick:()=>o("versionHistory"),icon:I.jsx(wh,{size:20}),iconSpacing:1,children:"Versions History"}),I.jsx(_t,{onClick:()=>o("share"),icon:I.jsx(kh,{size:20}),iconSpacing:1,alignItems:"center",children:I.jsxs(zt,{children:[I.jsx("p",{children:"Share"})," ",I.jsx(Xr,{size:"sm",children:"🧪beta"}),I.jsx(Rh,{})]})})]})})}),s==="share"&&I.jsx(Th,{onClose:()=>o("root")}),s=="versionHistory"&&I.jsx(Dh,{onClose:()=>o("root")}),s==="saveAsModal"&&I.jsxs(as,{isOpen:!0,onClose:w,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Save As"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!c,children:[I.jsx(Vr,{children:"Workflow name"}),I.jsx(Un,{value:l,onChange:y,autoFocus:!0,onKeyUp:k=>{k.code==="Enter"&&!c&&l&&m()}}),c&&I.jsx(Hr,{children:c})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:m,isDisabled:!l||!!c,children:"Save"}),I.jsx(Le,{onClick:w,children:"Cancel"})]})]})]}),i&&I.jsx(Ph,{workflowId:t,onClose:()=>a(!1)})]})}function Mh({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=_c(),{curFlowID:i}=j.useContext(bt),[a,l]=j.useState(t),[u,c]=j.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),u&&c("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return b();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?c("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),b())}},b=()=>{c(""),s()};return i==null?null:I.jsxs(zt,{children:[I.jsx(Ht,{label:t,placement:"bottom",children:I.jsxs(Mt,{as:"div",color:"white",onClick:d,maxW:160,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[I.jsx("div",{style:{width:8,display:"inline-block"},children:I.jsx(Mt,{as:"span",children:n&&"* "})}),t]})}),I.jsxs(as,{isOpen:r,onClose:b,children:[I.jsx(is,{}),I.jsxs(ls,{children:[I.jsx(cs,{children:"Edit workflow name"}),I.jsx(us,{}),I.jsx(ds,{children:I.jsxs(qr,{isInvalid:!!u,children:[I.jsx(Vr,{children:"Workflow name"}),I.jsx(Un,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!u&&a&&h()}}),u&&I.jsx(Hr,{children:u})]})}),I.jsxs(fs,{children:[I.jsx(Le,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!u,children:"Save"}),I.jsx(Le,{onClick:b,children:"Cancel"})]})]})]})]})}function zh({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=j.useContext(bt);return j.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?I.jsx(kn,{alignItems:"center",children:I.jsx(Ta,{size:"sm",isAttached:!0,variant:"outline",children:I.jsx(Le,{rightIcon:I.jsx(ll,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}function Lh(){const{loadNewWorkflow:t,setCurFlowIDAndName:e,curFlowID:n}=j.useContext(bt),r=async()=>{const o=JSON.stringify(Pe.graph.serialize()),s=prompt("Enter workflow name","Untitled");if(!s)return;const i=await(q==null?void 0:q.createFlow({json:o,name:s}));i&&e(i)};return I.jsx(Ht,{label:n?"New workflow":"Save workflow",children:I.jsx(Le,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:Ls+"px",onClick:()=>n?t():r(),px:1,children:n?I.jsx(xh,{size:16,color:"white"}):I.jsx(Rr,{size:16,color:"white"})})})}const Wh=j.lazy(()=>At(()=>import("./AppIsDirtyEventListener-HyyIaWmp.js"),__vite__mapDeps([6,1,7]))),Uh=j.lazy(()=>At(()=>import("./ModelManagerTopbar-_rZ5F_Jv.js"),__vite__mapDeps([8,1,3,2,9,10,11]))),Kh=j.lazy(()=>At(()=>import("./SpotlightSearch-NM7L9eNM.js"),__vite__mapDeps([12,1,7,13,14])));function $h({curFlowName:t,setCurFlowName:e}){var c;const{isDirty:n,saveCurWorkflow:r,setRoute:o,curFlowID:s,route:i}=j.useContext(bt),[a,l]=j.useState(),u=j.useCallback((d,p=!1)=>{const{top:h=0,left:b=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=b;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),x=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+x>=m&&(y=m-x),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Y==null||Y.upsert({topBarStyle:{top:f,left:y}}))},[a]);return j.useEffect(()=>{Y==null||Y.getSetting("topBarStyle").then(d=>{u(d,!1)})},[]),a?I.jsx(ah,{onDragEnd:d=>{u({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:I.jsxs(zt,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[I.jsx(Le,{size:"sm","aria-label":"workspace folder",height:Ls+"px",onClick:()=>o("recentFlows"),px:2,children:I.jsxs(zt,{gap:1,children:[I.jsx(vh,{size:21}),I.jsx(ll,{size:8})]})}),I.jsx(j.Suspense,{fallback:I.jsx("div",{style:{width:"60px"}}),children:I.jsx(Uh,{})}),I.jsx(Lh,{}),I.jsx(Mh,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{u()})}}),((c=q==null?void 0:q.curWorkflow)==null?void 0:c.saveLock)&&I.jsx(il,{color:"#FFF",size:20}),s&&I.jsxs(zt,{gap:"4px",children:[I.jsx(Ht,{label:"Open gallery",children:I.jsx(jn,{onClick:()=>o("gallery"),icon:I.jsx(_h,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),I.jsx(Bh,{})]}),s&&n?I.jsx(Ht,{label:"Save workflow",children:I.jsx(jn,{onClick:()=>r(),icon:I.jsx(Rr,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):I.jsx("div",{style:{width:1}}),I.jsx(zh,{}),I.jsx(Wh,{}),I.jsx(gh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),i==="spotlightSearch"&&I.jsx(Kh,{})]})}):null}function qh(){const{showDialog:t}=Da(),{loadWorkflowID:e}=j.useContext(bt),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(ge==null?void 0:ge.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(d)await e(l.id,d.id);else{const p=await(ge==null?void 0:ge.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json,api_prompt:null}));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(ge==null?void 0:ge.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,api_prompt:null,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(Hh(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 j.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Hh(t){return t.type==="workspace_open_workflow"}const Vh=t=>typeof t=="function",Zh=t=>{const[e,n]=j.useState(t),r=j.useRef(e),o=j.useCallback(s=>{r.current=Vh(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function lr(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 cl={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(u,c){if(!o[u]){if(!r[u]){var d=typeof lr=="function"&&lr;if(!c&&d)return d(u,!0);if(a)return a(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[u]={exports:{}};r[u][0].call(h.exports,function(b){var f=r[u][1][b];return i(f||b)},h,h.exports,n,r,o,s)}return o[u].exports}for(var a=typeof lr=="function"&&lr,l=0;l>2,h=(3&u)<<4|c>>4,b=1<_?(15&c)<<2|d>>6:64,f=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(h)+a.charAt(b)+a.charAt(f));return y.join("")},o.decode=function(l){var u,c,d,p,h,b,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,c=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(b=a.indexOf(l.charAt(f++))),w[y++]=u,h!==64&&(w[y++]=c),b!==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 u(c,d,p,h,b){this.compressedSize=c,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=b}u.prototype={getContentWorker:function(){var c=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return c.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},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)}},u.createWorkerFrom=function(c,d,p){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=u},{"./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=[],u=0;u<256;u++){a=u;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(u,c,d,p){var h=i,b=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c[f])];return-1^u}(0|l,a,a.length,0):function(u,c,d,p){var h=i,b=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c.charCodeAt(f))];return-1^u}(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"),u=s?"uint8array":"array";function c(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,d.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.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 c("Deflate",d)},o.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,b){var f,y="";for(f=0;f>>=8;return y}function i(h,b,f,y,m,w){var _,x,k=h.file,O=h.compression,E=w!==u.utf8encode,N=a.transformTo("string",w(k.name)),D=a.transformTo("string",u.utf8encode(k.name)),R=k.comment,$=a.transformTo("string",w(R)),P=a.transformTo("string",u.utf8encode(R)),B=D.length!==k.name.length,v=P.length!==R.length,T="",H="",A="",X=k.dir,K=k.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};b&&!f||(ne.crc32=h.crc32,ne.compressedSize=h.compressedSize,ne.uncompressedSize=h.uncompressedSize);var z=0;b&&(z|=8),E||!B&&!v||(z|=2048);var M=0,te=0;X&&(M|=16),m==="UNIX"?(te=798,M|=function(G,me){var we=G;return G||(we=me?16893:33204),(65535&we)<<16}(k.unixPermissions,X)):(te=20,M|=function(G){return 63&(G||0)}(k.dosPermissions)),_=K.getUTCHours(),_<<=6,_|=K.getUTCMinutes(),_<<=5,_|=K.getUTCSeconds()/2,x=K.getUTCFullYear()-1980,x<<=4,x|=K.getUTCMonth()+1,x<<=5,x|=K.getUTCDate(),B&&(H=s(1,1)+s(c(N),4)+D,T+="up"+s(H.length,2)+H),v&&(A=s(1,1)+s(c($),4)+P,T+="uc"+s(A.length,2)+A);var J="";return J+=` -\0`,J+=s(z,2),J+=O.magic,J+=s(_,2),J+=s(x,2),J+=s(ne.crc32,4),J+=s(ne.compressedSize,4),J+=s(ne.uncompressedSize,4),J+=s(N.length,2),J+=s(T.length,2),{fileRecord:d.LOCAL_FILE_HEADER+J+N+T,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+J+s($.length,2)+"\0\0\0\0"+s(M,4)+s(y,4)+N+T+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(h,b,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,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 b=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?(b+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var b=this.streamFiles&&!h.file.dir;if(b){var f=i(h,b,!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 b=this.streamFiles&&!h.file.dir,f=i(h,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),b)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,b=0;b=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},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"),u=n("./NodeBufferReader"),c=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(d):i.uint8array?new c(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 u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+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 u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){u.dataIsReady=!0,u.data=c,u.max=c&&c.length||0,u.type=s.getTypeOf(c),u.isPaused||u._tickAndRepeat()},function(c){u.error(c)})}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,u=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,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,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"),u=n("../support"),c=n("../external"),d=null;if(u.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,f){return new c.Promise(function(y,m){var w=[],_=b._internalType,x=b._outputType,k=b._mimeType;b.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,D){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),D);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(x,function(E,N){var D,R=0,$=null,P=0;for(D=0;D"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"),u=new Array(256),c=0;c<256;c++)u[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;u[254]=u[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(b){var f,y,m,w,_,x=b.length,k=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(b){var f,y,m,w,_=b.length,x=new Array(2*_);for(f=y=0;f<_;)if((m=b[f++])<128)x[y++]=m;else if(4<(w=u[m]))x[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,x[y++]=56320|1023&m)}return x.length!==y&&(x.subarray?x=x.subarray(0,y):x.length=y),s.applyFromCharCode(x)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var b=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=b;(b=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),b.set(f,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var y=function(w,_){var x;for((_=_||w.length)>w.length&&(_=w.length),x=_-1;0<=x&&(192&w[x])==128;)x--;return x<0||x===0?_:x+u[w[x]]>_?x:_}(b),m=b;y!==b.length&&(i.uint8array?(m=b.subarray(0,y),this.leftOver=b.subarray(y,b.length)):(m=b.slice(0,y),this.leftOver=b.slice(y,b.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 u(f){return f}function c(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 b,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 c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,b=p.length;h>10&1023,w[b++]=56320|1023&f)}return c(w,b)},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 u=65535&s|0,c=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,u){var c=s,d=u+l;i^=-1;for(var p=u;p>>8^c[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),c=n("./messages"),d=0,p=4,h=0,b=-2,f=-1,y=4,m=2,w=8,_=9,x=286,k=30,O=19,E=2*x+1,N=15,D=3,R=258,$=R+D+1,P=42,B=113,v=1,T=2,H=3,A=4;function X(g,U){return g.msg=c[U],U}function K(g){return(g<<1)-(4g.avail_out&&(W=g.avail_out),W!==0&&(i.arraySet(g.output,U.pending_buf,U.pending_out,W,g.next_out),g.next_out+=W,U.pending_out+=W,g.total_out+=W,g.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function M(g,U){a._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,U),g.block_start=g.strstart,z(g.strm)}function te(g,U){g.pending_buf[g.pending++]=U}function J(g,U){g.pending_buf[g.pending++]=U>>>8&255,g.pending_buf[g.pending++]=255&U}function G(g,U){var W,S,C=g.max_chain_length,F=g.strstart,V=g.prev_length,Z=g.nice_match,L=g.strstart>g.w_size-$?g.strstart-(g.w_size-$):0,Q=g.window,re=g.w_mask,ee=g.prev,se=g.strstart+R,ve=Q[F+V-1],he=Q[F+V];g.prev_length>=g.good_match&&(C>>=2),Z>g.lookahead&&(Z=g.lookahead);do if(Q[(W=U)+V]===he&&Q[W+V-1]===ve&&Q[W]===Q[F]&&Q[++W]===Q[F+1]){F+=2,W++;do;while(Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&FL&&--C!=0);return V<=g.lookahead?V:g.lookahead}function me(g){var U,W,S,C,F,V,Z,L,Q,re,ee=g.w_size;do{if(C=g.window_size-g.lookahead-g.strstart,g.strstart>=ee+(ee-$)){for(i.arraySet(g.window,g.window,ee,ee,0),g.match_start-=ee,g.strstart-=ee,g.block_start-=ee,U=W=g.hash_size;S=g.head[--U],g.head[U]=ee<=S?S-ee:0,--W;);for(U=W=ee;S=g.prev[--U],g.prev[U]=ee<=S?S-ee:0,--W;);C+=ee}if(g.strm.avail_in===0)break;if(V=g.strm,Z=g.window,L=g.strstart+g.lookahead,Q=C,re=void 0,re=V.avail_in,Q=D)for(F=g.strstart-g.insert,g.ins_h=g.window[F],g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D)if(S=a._tr_tally(g,g.strstart-g.match_start,g.match_length-D),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=D){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D&&g.match_length<=g.prev_length){for(C=g.strstart+g.lookahead-D,S=a._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-D),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=C&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(W=g.pending_buf_size-5);;){if(g.lookahead<=1){if(me(g),g.lookahead===0&&U===d)return v;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var S=g.block_start+W;if((g.strstart===0||g.strstart>=S)&&(g.lookahead=g.strstart-S,g.strstart=S,M(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-$&&(M(g,!1),g.strm.avail_out===0))return v}return g.insert=0,U===p?(M(g,!0),g.strm.avail_out===0?H:A):(g.strstart>g.block_start&&(M(g,!1),g.strm.avail_out),v)}),new ue(4,4,8,4,we),new ue(4,5,16,8,we),new ue(4,6,32,32,we),new ue(4,4,16,16,ie),new ue(8,16,32,32,ie),new ue(8,16,128,128,ie),new ue(8,32,128,256,ie),new ue(32,128,258,1024,ie),new ue(32,258,258,4096,ie)],o.deflateInit=function(g,U){return ke(g,U,w,15,8,0)},o.deflateInit2=ke,o.deflateReset=pe,o.deflateResetKeep=ye,o.deflateSetHeader=function(g,U){return g&&g.state?g.state.wrap!==2?b:(g.state.gzhead=U,h):b},o.deflate=function(g,U){var W,S,C,F;if(!g||!g.state||5>8&255),te(S,S.gzhead.time>>16&255),te(S,S.gzhead.time>>24&255),te(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),te(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(te(S,255&S.gzhead.extra.length),te(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(g.adler=u(g.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(te(S,0),te(S,0),te(S,0),te(S,0),te(S,0),te(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),te(S,3),S.status=B);else{var V=w+(S.w_bits-8<<4)<<8;V|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(V|=32),V+=31-V%31,S.status=B,J(S,V),S.strstart!==0&&(J(S,g.adler>>>16),J(S,65535&g.adler)),g.adler=1}if(S.status===69)if(S.gzhead.extra){for(C=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending!==S.pending_buf_size));)te(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending===S.pending_buf_size)){F=1;break}F=S.gzindexC&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),F===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending===S.pending_buf_size)){F=1;break}F=S.gzindexC&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),F===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&z(g),S.pending+2<=S.pending_buf_size&&(te(S,255&g.adler),te(S,g.adler>>8&255),g.adler=0,S.status=B)):S.status=B),S.pending!==0){if(z(g),g.avail_out===0)return S.last_flush=-1,h}else if(g.avail_in===0&&K(U)<=K(W)&&U!==p)return X(g,-5);if(S.status===666&&g.avail_in!==0)return X(g,-5);if(g.avail_in!==0||S.lookahead!==0||U!==d&&S.status!==666){var Z=S.strategy===2?function(L,Q){for(var re;;){if(L.lookahead===0&&(me(L),L.lookahead===0)){if(Q===d)return v;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(M(L,!1),L.strm.avail_out===0))return v}return L.insert=0,Q===p?(M(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(M(L,!1),L.strm.avail_out===0)?v:T}(S,U):S.strategy===3?function(L,Q){for(var re,ee,se,ve,he=L.window;;){if(L.lookahead<=R){if(me(L),L.lookahead<=R&&Q===d)return v;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=D&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=D?(re=a._tr_tally(L,1,L.match_length-D),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&&(M(L,!1),L.strm.avail_out===0))return v}return L.insert=0,Q===p?(M(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(M(L,!1),L.strm.avail_out===0)?v:T}(S,U):s[S.level].func(S,U);if(Z!==H&&Z!==A||(S.status=666),Z===v||Z===H)return g.avail_out===0&&(S.last_flush=-1),h;if(Z===T&&(U===1?a._tr_align(S):U!==5&&(a._tr_stored_block(S,0,0,!1),U===3&&(ne(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),z(g),g.avail_out===0))return S.last_flush=-1,h}return U!==p?h:S.wrap<=0?1:(S.wrap===2?(te(S,255&g.adler),te(S,g.adler>>8&255),te(S,g.adler>>16&255),te(S,g.adler>>24&255),te(S,255&g.total_in),te(S,g.total_in>>8&255),te(S,g.total_in>>16&255),te(S,g.total_in>>24&255)):(J(S,g.adler>>>16),J(S,65535&g.adler)),z(g),0=W.w_size&&(F===0&&(ne(W.head),W.strstart=0,W.block_start=0,W.insert=0),Q=new i.Buf8(W.w_size),i.arraySet(Q,U,re-W.w_size,W.w_size,0),U=Q,re=W.w_size),V=g.avail_in,Z=g.next_in,L=g.input,g.avail_in=re,g.next_in=0,g.input=U,me(W);W.lookahead>=D;){for(S=W.strstart,C=W.lookahead-(D-1);W.ins_h=(W.ins_h<>>=D=N>>>24,_-=D,(D=N>>>16&255)===0)T[c++]=65535&N;else{if(!(16&D)){if(!(64&D)){N=x[(65535&N)+(w&(1<>>=D,_-=D),_<15&&(w+=v[l++]<<_,_+=8,w+=v[l++]<<_,_+=8),N=k[w&E];n:for(;;){if(w>>>=D=N>>>24,_-=D,!(16&(D=N>>>16&255))){if(!(64&D)){N=k[(65535&N)+(w&(1<>>=D,_-=D,(D=c-d)<$){if(f<(D=$-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(P=0)===y){if(P+=b-D,D>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<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 _(P){var B;return P&&P.state?(B=P.state,P.total_in=P.total_out=B.total=0,P.msg="",B.wrap&&(P.adler=1&B.wrap),B.mode=b,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 x(P){var B;return P&&P.state?((B=P.state).wsize=0,B.whave=0,B.wnext=0,_(P)):h}function k(P,B){var v,T;return P&&P.state?(T=P.state,B<0?(v=0,B=-B):(v=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=A.wsize?(s.arraySet(A.window,B,v-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(T<(H=A.wsize-A.wnext)&&(H=T),s.arraySet(A.window,B,v-T,H,A.wnext),(T-=H)?(s.arraySet(A.window,B,v-T,T,0),A.wnext=T,A.whave=A.wsize):(A.wnext+=H,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,v.check=a(v.check,F,2,0),M=z=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&z)<<8)+(z>>8))%31){P.msg="incorrect header check",v.mode=30;break}if((15&z)!=8){P.msg="unknown compression method",v.mode=30;break}if(M-=4,g=8+(15&(z>>>=4)),v.wbits===0)v.wbits=g;else if(g>v.wbits){P.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(F[0]=255&z,F[1]=z>>>8&255,v.check=a(v.check,F,2,0)),M=z=0,v.mode=3;case 3:for(;M<32;){if(K===0)break e;K--,z+=T[A++]<>>8&255,F[2]=z>>>16&255,F[3]=z>>>24&255,v.check=a(v.check,F,4,0)),M=z=0,v.mode=4;case 4:for(;M<16;){if(K===0)break e;K--,z+=T[A++]<>8),512&v.flags&&(F[0]=255&z,F[1]=z>>>8&255,v.check=a(v.check,F,2,0)),M=z=0,v.mode=5;case 5:if(1024&v.flags){for(;M<16;){if(K===0)break e;K--,z+=T[A++]<>>8&255,v.check=a(v.check,F,2,0)),M=z=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(K<(G=v.length)&&(G=K),G&&(v.head&&(g=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,T,A,G,g)),512&v.flags&&(v.check=a(v.check,T,G,A)),K-=G,A+=G,v.length-=G),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(K===0)break e;for(G=0;g=T[A+G++],v.head&&g&&v.length<65536&&(v.head.name+=String.fromCharCode(g)),g&&G>9&1,v.head.done=!0),P.adler=v.check=0,v.mode=12;break;case 10:for(;M<32;){if(K===0)break e;K--,z+=T[A++]<>>=7&M,M-=7&M,v.mode=27;break}for(;M<3;){if(K===0)break e;K--,z+=T[A++]<>>=1)){case 0:v.mode=14;break;case 1:if(R(v),v.mode=20,B!==6)break;z>>>=2,M-=2;break e;case 2:v.mode=17;break;case 3:P.msg="invalid block type",v.mode=30}z>>>=2,M-=2;break;case 14:for(z>>>=7&M,M-=7&M;M<32;){if(K===0)break e;K--,z+=T[A++]<>>16^65535)){P.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&z,M=z=0,v.mode=15,B===6)break e;case 15:v.mode=16;case 16:if(G=v.length){if(K>>=5,M-=5,v.ndist=1+(31&z),z>>>=5,M-=5,v.ncode=4+(15&z),z>>>=4,M-=4,286>>=3,M-=3}for(;v.have<19;)v.lens[V[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W={bits:v.lenbits},U=u(0,v.lens,0,19,v.lencode,0,v.work,W),v.lenbits=W.bits,U){P.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ie,M-=ie,v.lens[v.have++]=_e;else{if(_e===16){for(S=ie+2;M>>=ie,M-=ie,v.have===0){P.msg="invalid bit length repeat",v.mode=30;break}g=v.lens[v.have-1],G=3+(3&z),z>>>=2,M-=2}else if(_e===17){for(S=ie+3;M>>=ie)),z>>>=3,M-=3}else{for(S=ie+7;M>>=ie)),z>>>=7,M-=7}if(v.have+G>v.nlen+v.ndist){P.msg="invalid bit length repeat",v.mode=30;break}for(;G--;)v.lens[v.have++]=g}}if(v.mode===30)break;if(v.lens[256]===0){P.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W={bits:v.lenbits},U=u(c,v.lens,0,v.nlen,v.lencode,0,v.work,W),v.lenbits=W.bits,U){P.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W={bits:v.distbits},U=u(d,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,W),v.distbits=W.bits,U){P.msg="invalid distances set",v.mode=30;break}if(v.mode=20,B===6)break e;case 20:v.mode=21;case 21:if(6<=K&&258<=ne){P.next_out=X,P.avail_out=ne,P.next_in=A,P.avail_in=K,v.hold=z,v.bits=M,l(P,J),X=P.next_out,H=P.output,ne=P.avail_out,A=P.next_in,T=P.input,K=P.avail_in,z=v.hold,M=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;ue=(C=v.lencode[z&(1<>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>ye)])>>>16&255,_e=65535&C,!(ye+(ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ye,M-=ye,v.back+=ye}if(z>>>=ie,M-=ie,v.back+=ie,v.length=_e,ue===0){v.mode=26;break}if(32&ue){v.back=-1,v.mode=12;break}if(64&ue){P.msg="invalid literal/length code",v.mode=30;break}v.extra=15&ue,v.mode=22;case 22:if(v.extra){for(S=v.extra;M>>=v.extra,M-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;ue=(C=v.distcode[z&(1<>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>ye)])>>>16&255,_e=65535&C,!(ye+(ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ye,M-=ye,v.back+=ye}if(z>>>=ie,M-=ie,v.back+=ie,64&ue){P.msg="invalid distance code",v.mode=30;break}v.offset=_e,v.extra=15&ue,v.mode=24;case 24:if(v.extra){for(S=v.extra;M>>=v.extra,M-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){P.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(ne===0)break e;if(G=J-ne,v.offset>G){if((G=v.offset-G)>v.whave&&v.sane){P.msg="invalid distance too far back",v.mode=30;break}me=G>v.wnext?(G-=v.wnext,v.wsize-G):v.wnext-G,G>v.length&&(G=v.length),we=v.window}else we=H,me=X-v.offset,G=v.length;for(neE?(D=me[we+y[B]],M[te+y[B]]):(D=96,0),w=1<>X)+(_-=w)]=N<<24|D<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(z&=w-1,z+=w):z=0,B++,--J[P]==0){if(P===T)break;P=d[p+y[B]]}if(H>>7)]}function te(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function J(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 we(C,F,V){var Z,L,Q=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)Q[Z]=re=re+V[Z-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=me(Q[ee]++,ee))}}function ie(C){var F;for(F=0;F>1;1<=V;V--)ye(C,Q,V);for(L=se;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ye(C,Q,1),Z=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=Z,Q[2*L]=Q[2*V]+Q[2*Z],C.depth[L]=(C.depth[V]>=C.depth[Z]?C.depth[V]:C.depth[Z])+1,Q[2*V+1]=Q[2*Z+1]=L,C.heap[1]=L++,ye(C,Q,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(he,Ye){var yn,ot,vn,je,Yn,to,dt=Ye.dyn_tree,Us=Ye.max_code,cl=Ye.stat_desc.static_tree,ul=Ye.stat_desc.has_stree,dl=Ye.stat_desc.extra_bits,Ks=Ye.stat_desc.extra_base,gn=Ye.stat_desc.max_length,Jn=0;for(je=0;je<=y;je++)he.bl_count[je]=0;for(dt[2*he.heap[he.heap_max]+1]=0,yn=he.heap_max+1;yn>=7;L>>=1)if(1&ve&&ee.dyn_ltree[2*se]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(se=32;se>>3,(Q=C.static_len+3+7>>>3)<=L&&(L=Q)):L=Q=V+5,V+4<=L&&F!==-1?S(C,F,V,Z):C.strategy===4||Q===L?(J(C,2+(Z?1:0),3),pe(C,$,P)):(J(C,4+(Z?1:0),3),function(ee,se,ve,he){var Ye;for(J(ee,se-257,5),J(ee,ve-1,5),J(ee,he-4,4),Ye=0;Ye>>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*(v[V]+d+1)]++,C.dyn_dtree[2*M(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){J(C,2,3),G(C,_,$),function(F){F.bi_valid===16?(te(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)}(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,u,c,d,p=1,h={},b=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){w(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,k=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=k,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){w(x.data)},function(x){c.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(u=f.documentElement,function(x){var k=f.createElement("script");k.onreadystatechange=function(){w(x),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(x){setTimeout(w,0,x)},y.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var k=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ll);var Zh=ll.exports;const Gh=ka(Zh);async function Yh(t){let e="",n=t;for(;n!=null;){const r=await(He==null?void 0:He.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Op(t){if(await(Y==null?void 0:Y.getSetting("twoWaySync")))return await Ct.genFilesCountInFolder(t)??0;const n=await(q==null?void 0:q.listAll())??[],r=await(He==null?void 0:He.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}const Jh=async t=>{const e=`ComfyUI workspace workflows ${el(Date.now())}`,n=new Gh,r=await(Y==null?void 0:Y.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await Yh(o.parentFolderID??null).then(async a=>Pt(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 Xh({myWorkflowsDir:t}){return I.jsxs(rn,{gap:3,children:[I.jsx(ps,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),I.jsx("p",{children:"Your workflows will be synced to and from path:"}),I.jsx("p",{children:I.jsx("b",{children:t})}),I.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"]}),I.jsxs("p",{children:[I.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."]}),I.jsx(Le,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());Jh(e??[])},children:"👉 Download All My Workflows"})]})}const Qh=Da.lazy(()=>At(()=>import("./RecentFilesDrawer-BJDDVyUO.js"),__vite__mapDeps([15,1,9,2,14,16,13,5]))),ep=Da.lazy(()=>At(()=>import("./GalleryModal-qNnfNTjL.js"),__vite__mapDeps([17,1,16,13,2,10,9,4])));function tp(){const[t,e]=j.useState(null),[n,r]=j.useState("root"),[o,s]=j.useState(!0),[i,a]=j.useState(null),l=j.useRef(null),[u,c]=j.useState(!1),d=j.useRef(null),{showDialog:p}=Oa(),[h,b]=j.useState(!1);j.useRef(!1);const f=ja(),[y,m]=Vh(null),w=j.useCallback(async(v=!1)=>{var H,A;const T=q==null?void 0:q.curWorkflow;if(T){if(!v&&((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const X=JSON.stringify(Pe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(T.id,{json:X}),Ve==null?void 0:Ve.create({workflowID:T.id,json:X,isAutoSave:!1})]),(A=Y==null?void 0:Y.settings)!=null&&A.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),c(!1)}},[]),_=async()=>{var T,H,A;if((T=Y==null?void 0:Y.settings)!=null&&T.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const X=(H=q==null?void 0:q.curWorkflow)==null?void 0:H.id;if(X==null)return;const K=(A=await(q==null?void 0:q.get(X)))==null?void 0:A.json;K?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:K}),await Pe.loadGraphData(JSON.parse(K)),c(!1)):alert("Error: No last saved version found")}},x=v=>{const T=(v==null?void 0:v.id)??null;if(q==null||q.updateCurWorkflow(v),l.current=T,a(T),e((v==null?void 0:v.name)??""),T==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(wa()){const H=tl(T);window.location.hash=H,document.title=v.name+" - ComfyUI"}else localStorage.setItem("curFlowID",T),document.title="ComfyUI - "+v.name;v&&(q==null||q.updateLastOpenedTime(v.id))},k=async()=>{var H,A;localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await rh()}catch(X){console.error("error loading db",X)}s(!1);const v=wa();if(v==null){const X=localStorage.getItem("workflow");if(X){const ne=(A=(H=JSON.parse(X).extra)==null?void 0:H[Ue])==null?void 0:A.id;if(ne){const z=await(q==null?void 0:q.get(ne));z&&x(z),!(z!=null&&z.saveLock)&&z&&z.json!=X&&c(!0)}}}else O(v);if(Se("/workspace/deduplicate_workflow_ids"),!await(Y==null?void 0:Y.getSetting("twoWaySync"))){if(await ce.workflows.count()==0){await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await ce.cache.put({id:ba,value:"true"});return}const K=await(Y==null?void 0:Y.getSetting("myWorkflowsDir"));p(I.jsx(Xh,{myWorkflowsDir:K??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await(Y==null?void 0:Y.getSetting("twoWaySync"))&&(ce.cache.put({id:ba,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}},O=async(v,T)=>{if(Pe.graph==null)return;const H=await(q==null?void 0:q.get(v));if(H==null){alert("Error: Workflow not found! id: "+v),x(null);return}const A=T?await(ge==null?void 0:ge.get(T)):null;Pe.ui.dialog.close(),A?(m(A),x({...H,json:A.json}),Pe.loadGraphData(JSON.parse(A.json))):(x(H),m(null),Pe.loadGraphData(JSON.parse(H.json))),r("root"),u&&c(!1)},E=async(v,T,H=!1)=>{var A;if(v===null){x(null),Pe.graph.clear();return}if(!u||H||(A=Y==null?void 0:Y.settings)!=null&&A.autoSave||(q==null?void 0:q.curWorkflow)==null){O(v,T);return}N(v)},N=async v=>{var H;const T=[v?{label:"Open in new tab",icon:I.jsx(mh,{}),onClick:()=>{Yf(v)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),v&&O(v)}}];T.push({label:"Discard",colorScheme:"red",onClick:async()=>{v&&O(v)}}),p(`Please save or discard your changes to "${(H=q==null?void 0:q.curWorkflow)==null?void 0:H.name}" before leaving, or your changes will be lost.`,T)},D=async v=>{const T=(v==null?void 0:v.json)??JSON.stringify(nl),H=await(q==null?void 0:q.createFlow({json:T,name:v==null?void 0:v.name}));H&&await E(H.id),r("root")},R=async(v,T=!1)=>{const H=v.split("/").pop()??v;T?w():D({name:H});const A=await fetch(Gf(v)),X=await A.blob(),K=new File([X],H,{type:A.headers.get("Content-Type")||""});await Pe.handleFile(K),r("root")},$=async(v,T)=>{const H=await(q==null?void 0:q.get(v));if(H==null)return;const A=await(q==null?void 0:q.createFlow({json:H.json,name:T||H.name,parentFolderID:H.parentFolderID}));A&&await E(A.id)},P=j.useCallback(v=>{if(l.current==null)return;let T=v.filename;v.subfolder!=null&&v.subfolder!==""&&(T=v.subfolder+"/"+T),$t==null||$t.create({workflowID:l.current,localPath:T})},[]),B=j.useCallback(()=>{r("root")},[]);return j.useEffect(()=>{k(),b(!0);const v=T=>{var H,A,X,K,ne,z;(X=(A=(H=T.detail)==null?void 0:H.output)==null?void 0:A.images)==null||X.forEach(M=>{M.type==="output"&&P(M)}),(z=(ne=(K=T.detail)==null?void 0:K.output)==null?void 0:ne.gifs)==null||z.forEach(M=>{M.type==="output"&&P(M)})};return Er.addEventListener("executed",v),()=>{window.removeEventListener("executed",v)}},[]),o?null:I.jsx(bt.Provider,{value:{curFlowID:i,onDuplicateWorkflow:$,loadWorkflowID:E,discardUnsavedChanges:_,saveCurWorkflow:w,isDirty:u,setIsDirty:c,loadNewWorkflow:D,loadFilePath:R,setRoute:r,route:n,curVersion:y,setCurVersion:m,setCurFlowIDAndName:x},children:I.jsx("div",{ref:d,className:"workspace_manager",children:I.jsxs(Sa,{containerRef:d,children:[I.jsxs(St,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Jf,draggable:!1,children:[I.jsx(Kh,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&I.jsx(j.Suspense,{children:I.jsx(Qh,{onClose:B,onClickNewFlow:()=>{D(),r("root")}})}),n==="gallery"&&I.jsx(j.Suspense,{children:I.jsx(ep,{onclose:()=>r("root")})})]}),I.jsx($h,{})]})})})}const Dp=Object.freeze(Object.defineProperty({__proto__:null,default:tp},Symbol.toStringTag,{value:"Module"}));export{Se as $,hh as A,St as B,pp as C,Ih as D,$f as E,kn as F,yh as G,zt as H,jn as I,He as J,qr as K,Vr as L,li as M,Hr as N,_h as O,nl as P,Op as Q,kp as R,dd as S,Xr as T,gr as U,nh as V,hp as W,bt as X,mh as Y,Yf as Z,al as _,ap as a,$t as a0,el as a1,it as a2,Pe as a3,Hl as a4,Jf as a5,lp as a6,wr as a7,mp as a8,Fa as a9,eh as aA,wp as aB,Ls as aC,hs as aD,Cp as aE,Ep as aF,Sp as aG,Fn as aH,Nh as aI,Ip as aJ,Dp as aK,ec as aa,vp as ab,ps as ac,nn as ad,tc as ae,Ue as af,gp as ag,yp as ah,Ve as ai,Nl as aj,Hn as ak,Is as al,ce as am,cp as an,_p as ao,xp as ap,up as aq,Er as ar,dp as as,bc as at,ui as au,ci as av,pi as aw,fi as ax,bp as ay,Vh as az,op as b,sp as c,Re as d,kh as e,ja as f,rn as g,Mt as h,Ht as i,Un as j,Y as k,Xh as l,_c as m,Vd as n,ip as o,fp as p,bo as q,Cs as r,Ss as s,_r as t,Gr as u,_t as v,ph as w,q as x,Sh as y,Jh as z}; +\0`,J+=s(z,2),J+=O.magic,J+=s(_,2),J+=s(x,2),J+=s(ne.crc32,4),J+=s(ne.compressedSize,4),J+=s(ne.uncompressedSize,4),J+=s(N.length,2),J+=s(T.length,2),{fileRecord:d.LOCAL_FILE_HEADER+J+N+T,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+J+s($.length,2)+"\0\0\0\0"+s(M,4)+s(y,4)+N+T+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(h,b,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,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 b=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?(b+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var b=this.streamFiles&&!h.file.dir;if(b){var f=i(h,b,!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 b=this.streamFiles&&!h.file.dir,f=i(h,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),b)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,b=0;b=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},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"),u=n("./NodeBufferReader"),c=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(d):i.uint8array?new c(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 u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+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 u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){u.dataIsReady=!0,u.data=c,u.max=c&&c.length||0,u.type=s.getTypeOf(c),u.isPaused||u._tickAndRepeat()},function(c){u.error(c)})}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,u=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,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,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"),u=n("../support"),c=n("../external"),d=null;if(u.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,f){return new c.Promise(function(y,m){var w=[],_=b._internalType,x=b._outputType,k=b._mimeType;b.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,D){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),D);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(x,function(E,N){var D,R=0,$=null,P=0;for(D=0;D"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"),u=new Array(256),c=0;c<256;c++)u[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;u[254]=u[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(b){var f,y,m,w,_,x=b.length,k=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(b){var f,y,m,w,_=b.length,x=new Array(2*_);for(f=y=0;f<_;)if((m=b[f++])<128)x[y++]=m;else if(4<(w=u[m]))x[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,x[y++]=56320|1023&m)}return x.length!==y&&(x.subarray?x=x.subarray(0,y):x.length=y),s.applyFromCharCode(x)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var b=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=b;(b=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),b.set(f,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var y=function(w,_){var x;for((_=_||w.length)>w.length&&(_=w.length),x=_-1;0<=x&&(192&w[x])==128;)x--;return x<0||x===0?_:x+u[w[x]]>_?x:_}(b),m=b;y!==b.length&&(i.uint8array?(m=b.subarray(0,y),this.leftOver=b.subarray(y,b.length)):(m=b.slice(0,y),this.leftOver=b.slice(y,b.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 u(f){return f}function c(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 b,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 c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,b=p.length;h>10&1023,w[b++]=56320|1023&f)}return c(w,b)},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 u=65535&s|0,c=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,u){var c=s,d=u+l;i^=-1;for(var p=u;p>>8^c[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),c=n("./messages"),d=0,p=4,h=0,b=-2,f=-1,y=4,m=2,w=8,_=9,x=286,k=30,O=19,E=2*x+1,N=15,D=3,R=258,$=R+D+1,P=42,B=113,v=1,T=2,H=3,A=4;function X(g,U){return g.msg=c[U],U}function K(g){return(g<<1)-(4g.avail_out&&(W=g.avail_out),W!==0&&(i.arraySet(g.output,U.pending_buf,U.pending_out,W,g.next_out),g.next_out+=W,U.pending_out+=W,g.total_out+=W,g.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function M(g,U){a._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,U),g.block_start=g.strstart,z(g.strm)}function te(g,U){g.pending_buf[g.pending++]=U}function J(g,U){g.pending_buf[g.pending++]=U>>>8&255,g.pending_buf[g.pending++]=255&U}function G(g,U){var W,S,C=g.max_chain_length,F=g.strstart,V=g.prev_length,Z=g.nice_match,L=g.strstart>g.w_size-$?g.strstart-(g.w_size-$):0,Q=g.window,re=g.w_mask,ee=g.prev,se=g.strstart+R,ve=Q[F+V-1],he=Q[F+V];g.prev_length>=g.good_match&&(C>>=2),Z>g.lookahead&&(Z=g.lookahead);do if(Q[(W=U)+V]===he&&Q[W+V-1]===ve&&Q[W]===Q[F]&&Q[++W]===Q[F+1]){F+=2,W++;do;while(Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&Q[++F]===Q[++W]&&FL&&--C!=0);return V<=g.lookahead?V:g.lookahead}function me(g){var U,W,S,C,F,V,Z,L,Q,re,ee=g.w_size;do{if(C=g.window_size-g.lookahead-g.strstart,g.strstart>=ee+(ee-$)){for(i.arraySet(g.window,g.window,ee,ee,0),g.match_start-=ee,g.strstart-=ee,g.block_start-=ee,U=W=g.hash_size;S=g.head[--U],g.head[U]=ee<=S?S-ee:0,--W;);for(U=W=ee;S=g.prev[--U],g.prev[U]=ee<=S?S-ee:0,--W;);C+=ee}if(g.strm.avail_in===0)break;if(V=g.strm,Z=g.window,L=g.strstart+g.lookahead,Q=C,re=void 0,re=V.avail_in,Q=D)for(F=g.strstart-g.insert,g.ins_h=g.window[F],g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D)if(S=a._tr_tally(g,g.strstart-g.match_start,g.match_length-D),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=D){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=D&&(g.ins_h=(g.ins_h<=D&&g.match_length<=g.prev_length){for(C=g.strstart+g.lookahead-D,S=a._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-D),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=C&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(W=g.pending_buf_size-5);;){if(g.lookahead<=1){if(me(g),g.lookahead===0&&U===d)return v;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var S=g.block_start+W;if((g.strstart===0||g.strstart>=S)&&(g.lookahead=g.strstart-S,g.strstart=S,M(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-$&&(M(g,!1),g.strm.avail_out===0))return v}return g.insert=0,U===p?(M(g,!0),g.strm.avail_out===0?H:A):(g.strstart>g.block_start&&(M(g,!1),g.strm.avail_out),v)}),new ue(4,4,8,4,we),new ue(4,5,16,8,we),new ue(4,6,32,32,we),new ue(4,4,16,16,ie),new ue(8,16,32,32,ie),new ue(8,16,128,128,ie),new ue(8,32,128,256,ie),new ue(32,128,258,1024,ie),new ue(32,258,258,4096,ie)],o.deflateInit=function(g,U){return ke(g,U,w,15,8,0)},o.deflateInit2=ke,o.deflateReset=pe,o.deflateResetKeep=ye,o.deflateSetHeader=function(g,U){return g&&g.state?g.state.wrap!==2?b:(g.state.gzhead=U,h):b},o.deflate=function(g,U){var W,S,C,F;if(!g||!g.state||5>8&255),te(S,S.gzhead.time>>16&255),te(S,S.gzhead.time>>24&255),te(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),te(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(te(S,255&S.gzhead.extra.length),te(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(g.adler=u(g.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(te(S,0),te(S,0),te(S,0),te(S,0),te(S,0),te(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),te(S,3),S.status=B);else{var V=w+(S.w_bits-8<<4)<<8;V|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(V|=32),V+=31-V%31,S.status=B,J(S,V),S.strstart!==0&&(J(S,g.adler>>>16),J(S,65535&g.adler)),g.adler=1}if(S.status===69)if(S.gzhead.extra){for(C=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending!==S.pending_buf_size));)te(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending===S.pending_buf_size)){F=1;break}F=S.gzindexC&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),F===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),z(g),C=S.pending,S.pending===S.pending_buf_size)){F=1;break}F=S.gzindexC&&(g.adler=u(g.adler,S.pending_buf,S.pending-C,C)),F===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&z(g),S.pending+2<=S.pending_buf_size&&(te(S,255&g.adler),te(S,g.adler>>8&255),g.adler=0,S.status=B)):S.status=B),S.pending!==0){if(z(g),g.avail_out===0)return S.last_flush=-1,h}else if(g.avail_in===0&&K(U)<=K(W)&&U!==p)return X(g,-5);if(S.status===666&&g.avail_in!==0)return X(g,-5);if(g.avail_in!==0||S.lookahead!==0||U!==d&&S.status!==666){var Z=S.strategy===2?function(L,Q){for(var re;;){if(L.lookahead===0&&(me(L),L.lookahead===0)){if(Q===d)return v;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(M(L,!1),L.strm.avail_out===0))return v}return L.insert=0,Q===p?(M(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(M(L,!1),L.strm.avail_out===0)?v:T}(S,U):S.strategy===3?function(L,Q){for(var re,ee,se,ve,he=L.window;;){if(L.lookahead<=R){if(me(L),L.lookahead<=R&&Q===d)return v;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=D&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=D?(re=a._tr_tally(L,1,L.match_length-D),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&&(M(L,!1),L.strm.avail_out===0))return v}return L.insert=0,Q===p?(M(L,!0),L.strm.avail_out===0?H:A):L.last_lit&&(M(L,!1),L.strm.avail_out===0)?v:T}(S,U):s[S.level].func(S,U);if(Z!==H&&Z!==A||(S.status=666),Z===v||Z===H)return g.avail_out===0&&(S.last_flush=-1),h;if(Z===T&&(U===1?a._tr_align(S):U!==5&&(a._tr_stored_block(S,0,0,!1),U===3&&(ne(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),z(g),g.avail_out===0))return S.last_flush=-1,h}return U!==p?h:S.wrap<=0?1:(S.wrap===2?(te(S,255&g.adler),te(S,g.adler>>8&255),te(S,g.adler>>16&255),te(S,g.adler>>24&255),te(S,255&g.total_in),te(S,g.total_in>>8&255),te(S,g.total_in>>16&255),te(S,g.total_in>>24&255)):(J(S,g.adler>>>16),J(S,65535&g.adler)),z(g),0=W.w_size&&(F===0&&(ne(W.head),W.strstart=0,W.block_start=0,W.insert=0),Q=new i.Buf8(W.w_size),i.arraySet(Q,U,re-W.w_size,W.w_size,0),U=Q,re=W.w_size),V=g.avail_in,Z=g.next_in,L=g.input,g.avail_in=re,g.next_in=0,g.input=U,me(W);W.lookahead>=D;){for(S=W.strstart,C=W.lookahead-(D-1);W.ins_h=(W.ins_h<>>=D=N>>>24,_-=D,(D=N>>>16&255)===0)T[c++]=65535&N;else{if(!(16&D)){if(!(64&D)){N=x[(65535&N)+(w&(1<>>=D,_-=D),_<15&&(w+=v[l++]<<_,_+=8,w+=v[l++]<<_,_+=8),N=k[w&E];n:for(;;){if(w>>>=D=N>>>24,_-=D,!(16&(D=N>>>16&255))){if(!(64&D)){N=k[(65535&N)+(w&(1<>>=D,_-=D,(D=c-d)<$){if(f<(D=$-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(P=0)===y){if(P+=b-D,D>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<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 _(P){var B;return P&&P.state?(B=P.state,P.total_in=P.total_out=B.total=0,P.msg="",B.wrap&&(P.adler=1&B.wrap),B.mode=b,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 x(P){var B;return P&&P.state?((B=P.state).wsize=0,B.whave=0,B.wnext=0,_(P)):h}function k(P,B){var v,T;return P&&P.state?(T=P.state,B<0?(v=0,B=-B):(v=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=A.wsize?(s.arraySet(A.window,B,v-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(T<(H=A.wsize-A.wnext)&&(H=T),s.arraySet(A.window,B,v-T,H,A.wnext),(T-=H)?(s.arraySet(A.window,B,v-T,T,0),A.wnext=T,A.whave=A.wsize):(A.wnext+=H,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,v.check=a(v.check,F,2,0),M=z=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&z)<<8)+(z>>8))%31){P.msg="incorrect header check",v.mode=30;break}if((15&z)!=8){P.msg="unknown compression method",v.mode=30;break}if(M-=4,g=8+(15&(z>>>=4)),v.wbits===0)v.wbits=g;else if(g>v.wbits){P.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(F[0]=255&z,F[1]=z>>>8&255,v.check=a(v.check,F,2,0)),M=z=0,v.mode=3;case 3:for(;M<32;){if(K===0)break e;K--,z+=T[A++]<>>8&255,F[2]=z>>>16&255,F[3]=z>>>24&255,v.check=a(v.check,F,4,0)),M=z=0,v.mode=4;case 4:for(;M<16;){if(K===0)break e;K--,z+=T[A++]<>8),512&v.flags&&(F[0]=255&z,F[1]=z>>>8&255,v.check=a(v.check,F,2,0)),M=z=0,v.mode=5;case 5:if(1024&v.flags){for(;M<16;){if(K===0)break e;K--,z+=T[A++]<>>8&255,v.check=a(v.check,F,2,0)),M=z=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(K<(G=v.length)&&(G=K),G&&(v.head&&(g=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,T,A,G,g)),512&v.flags&&(v.check=a(v.check,T,G,A)),K-=G,A+=G,v.length-=G),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(K===0)break e;for(G=0;g=T[A+G++],v.head&&g&&v.length<65536&&(v.head.name+=String.fromCharCode(g)),g&&G>9&1,v.head.done=!0),P.adler=v.check=0,v.mode=12;break;case 10:for(;M<32;){if(K===0)break e;K--,z+=T[A++]<>>=7&M,M-=7&M,v.mode=27;break}for(;M<3;){if(K===0)break e;K--,z+=T[A++]<>>=1)){case 0:v.mode=14;break;case 1:if(R(v),v.mode=20,B!==6)break;z>>>=2,M-=2;break e;case 2:v.mode=17;break;case 3:P.msg="invalid block type",v.mode=30}z>>>=2,M-=2;break;case 14:for(z>>>=7&M,M-=7&M;M<32;){if(K===0)break e;K--,z+=T[A++]<>>16^65535)){P.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&z,M=z=0,v.mode=15,B===6)break e;case 15:v.mode=16;case 16:if(G=v.length){if(K>>=5,M-=5,v.ndist=1+(31&z),z>>>=5,M-=5,v.ncode=4+(15&z),z>>>=4,M-=4,286>>=3,M-=3}for(;v.have<19;)v.lens[V[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W={bits:v.lenbits},U=u(0,v.lens,0,19,v.lencode,0,v.work,W),v.lenbits=W.bits,U){P.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ie,M-=ie,v.lens[v.have++]=_e;else{if(_e===16){for(S=ie+2;M>>=ie,M-=ie,v.have===0){P.msg="invalid bit length repeat",v.mode=30;break}g=v.lens[v.have-1],G=3+(3&z),z>>>=2,M-=2}else if(_e===17){for(S=ie+3;M>>=ie)),z>>>=3,M-=3}else{for(S=ie+7;M>>=ie)),z>>>=7,M-=7}if(v.have+G>v.nlen+v.ndist){P.msg="invalid bit length repeat",v.mode=30;break}for(;G--;)v.lens[v.have++]=g}}if(v.mode===30)break;if(v.lens[256]===0){P.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W={bits:v.lenbits},U=u(c,v.lens,0,v.nlen,v.lencode,0,v.work,W),v.lenbits=W.bits,U){P.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W={bits:v.distbits},U=u(d,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,W),v.distbits=W.bits,U){P.msg="invalid distances set",v.mode=30;break}if(v.mode=20,B===6)break e;case 20:v.mode=21;case 21:if(6<=K&&258<=ne){P.next_out=X,P.avail_out=ne,P.next_in=A,P.avail_in=K,v.hold=z,v.bits=M,l(P,J),X=P.next_out,H=P.output,ne=P.avail_out,A=P.next_in,T=P.input,K=P.avail_in,z=v.hold,M=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;ue=(C=v.lencode[z&(1<>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>ye)])>>>16&255,_e=65535&C,!(ye+(ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ye,M-=ye,v.back+=ye}if(z>>>=ie,M-=ie,v.back+=ie,v.length=_e,ue===0){v.mode=26;break}if(32&ue){v.back=-1,v.mode=12;break}if(64&ue){P.msg="invalid literal/length code",v.mode=30;break}v.extra=15&ue,v.mode=22;case 22:if(v.extra){for(S=v.extra;M>>=v.extra,M-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;ue=(C=v.distcode[z&(1<>>16&255,_e=65535&C,!((ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>ye)])>>>16&255,_e=65535&C,!(ye+(ie=C>>>24)<=M);){if(K===0)break e;K--,z+=T[A++]<>>=ye,M-=ye,v.back+=ye}if(z>>>=ie,M-=ie,v.back+=ie,64&ue){P.msg="invalid distance code",v.mode=30;break}v.offset=_e,v.extra=15&ue,v.mode=24;case 24:if(v.extra){for(S=v.extra;M>>=v.extra,M-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){P.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(ne===0)break e;if(G=J-ne,v.offset>G){if((G=v.offset-G)>v.whave&&v.sane){P.msg="invalid distance too far back",v.mode=30;break}me=G>v.wnext?(G-=v.wnext,v.wsize-G):v.wnext-G,G>v.length&&(G=v.length),we=v.window}else we=H,me=X-v.offset,G=v.length;for(neE?(D=me[we+y[B]],M[te+y[B]]):(D=96,0),w=1<>X)+(_-=w)]=N<<24|D<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(z&=w-1,z+=w):z=0,B++,--J[P]==0){if(P===T)break;P=d[p+y[B]]}if(H>>7)]}function te(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function J(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 we(C,F,V){var Z,L,Q=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)Q[Z]=re=re+V[Z-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=me(Q[ee]++,ee))}}function ie(C){var F;for(F=0;F>1;1<=V;V--)ye(C,Q,V);for(L=se;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ye(C,Q,1),Z=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=Z,Q[2*L]=Q[2*V]+Q[2*Z],C.depth[L]=(C.depth[V]>=C.depth[Z]?C.depth[V]:C.depth[Z])+1,Q[2*V+1]=Q[2*Z+1]=L,C.heap[1]=L++,ye(C,Q,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(he,Ye){var yn,ot,vn,je,Yn,to,dt=Ye.dyn_tree,Ks=Ye.max_code,ul=Ye.stat_desc.static_tree,dl=Ye.stat_desc.has_stree,fl=Ye.stat_desc.extra_bits,$s=Ye.stat_desc.extra_base,gn=Ye.stat_desc.max_length,Jn=0;for(je=0;je<=y;je++)he.bl_count[je]=0;for(dt[2*he.heap[he.heap_max]+1]=0,yn=he.heap_max+1;yn>=7;L>>=1)if(1&ve&&ee.dyn_ltree[2*se]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(se=32;se>>3,(Q=C.static_len+3+7>>>3)<=L&&(L=Q)):L=Q=V+5,V+4<=L&&F!==-1?S(C,F,V,Z):C.strategy===4||Q===L?(J(C,2+(Z?1:0),3),pe(C,$,P)):(J(C,4+(Z?1:0),3),function(ee,se,ve,he){var Ye;for(J(ee,se-257,5),J(ee,ve-1,5),J(ee,he-4,4),Ye=0;Ye>>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*(v[V]+d+1)]++,C.dyn_dtree[2*M(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){J(C,2,3),G(C,_,$),function(F){F.bi_valid===16?(te(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)}(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,u,c,d,p=1,h={},b=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(x){process.nextTick(function(){w(x)})}:function(){if(i.postMessage&&!i.importScripts){var x=!0,k=i.onmessage;return i.onmessage=function(){x=!1},i.postMessage("","*"),i.onmessage=k,x}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(x){i.postMessage(d+x,"*")}):i.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){w(x.data)},function(x){c.port2.postMessage(x)}):f&&"onreadystatechange"in f.createElement("script")?(u=f.documentElement,function(x){var k=f.createElement("script");k.onreadystatechange=function(){w(x),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(x){setTimeout(w,0,x)},y.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var k=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(cl);var Gh=cl.exports;const Yh=Ea(Gh);async function Jh(t){let e="",n=t;for(;n!=null;){const r=await(He==null?void 0:He.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Pp(t){if(await(Y==null?void 0:Y.getSetting("twoWaySync")))return await Ct.genFilesCountInFolder(t)??0;const n=await(q==null?void 0:q.listAll())??[],r=await(He==null?void 0:He.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}const Xh=async t=>{const e=`ComfyUI workspace workflows ${tl(Date.now())}`,n=new Yh,r=await(Y==null?void 0:Y.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await Jh(o.parentFolderID??null).then(async a=>Pt(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 Qh({myWorkflowsDir:t}){return I.jsxs(rn,{gap:3,children:[I.jsx(ps,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),I.jsx("p",{children:"Your workflows will be synced to and from path:"}),I.jsx("p",{children:I.jsx("b",{children:t})}),I.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"]}),I.jsxs("p",{children:[I.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."]}),I.jsx(Le,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());Xh(e??[])},children:"👉 Download All My Workflows"})]})}const ep=Pa.lazy(()=>At(()=>import("./RecentFilesDrawer-o2YKsAW_.js"),__vite__mapDeps([15,1,9,2,14,16,13,5]))),tp=Pa.lazy(()=>At(()=>import("./GalleryModal-H7PcxDl8.js"),__vite__mapDeps([17,1,16,13,2,10,9,4])));function np(){const[t,e]=j.useState(null),[n,r]=j.useState("root"),[o,s]=j.useState(!0),[i,a]=j.useState(null),l=j.useRef(null),[u,c]=j.useState(!1),d=j.useRef(null),{showDialog:p}=Da(),[h,b]=j.useState(!1);j.useRef(!1);const f=Aa(),[y,m]=Zh(null),w=j.useCallback(async(v=!1)=>{var H,A;const T=q==null?void 0:q.curWorkflow;if(T){if(!v&&((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const X=JSON.stringify(Pe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(T.id,{json:X}),Ve==null?void 0:Ve.create({workflowID:T.id,json:X,isAutoSave:!1})]),(A=Y==null?void 0:Y.settings)!=null&&A.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),c(!1)}},[]),_=async()=>{var T,H,A;if((T=Y==null?void 0:Y.settings)!=null&&T.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const X=(H=q==null?void 0:q.curWorkflow)==null?void 0:H.id;if(X==null)return;const K=(A=await(q==null?void 0:q.get(X)))==null?void 0:A.json;K?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:K}),await Pe.loadGraphData(JSON.parse(K)),c(!1)):alert("Error: No last saved version found")}},x=v=>{const T=(v==null?void 0:v.id)??null;if(q==null||q.updateCurWorkflow(v),l.current=T,a(T),e((v==null?void 0:v.name)??""),T==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ba()){const H=nl(T);window.location.hash=H,document.title=v.name+" - ComfyUI"}else localStorage.setItem("curFlowID",T),document.title="ComfyUI - "+v.name;v&&(q==null||q.updateLastOpenedTime(v.id))},k=async()=>{var H,A;localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await oh()}catch(X){console.error("error loading db",X)}s(!1);const v=ba();if(v==null){const X=localStorage.getItem("workflow");if(X){const ne=(A=(H=JSON.parse(X).extra)==null?void 0:H[Ue])==null?void 0:A.id;if(ne){const z=await(q==null?void 0:q.get(ne));z&&x(z),!(z!=null&&z.saveLock)&&z&&z.json!=X&&c(!0)}}}else O(v);if(Ee("/workspace/deduplicate_workflow_ids"),Ee("/workspace/get_os").then(X=>X.json()).then(X=>{X.os&&(Ws.os=X.os)}),!await(Y==null?void 0:Y.getSetting("twoWaySync"))){if(await ce.workflows.count()==0){await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await ce.cache.put({id:_a,value:"true"});return}const K=await(Y==null?void 0:Y.getSetting("myWorkflowsDir"));p(I.jsx(Qh,{myWorkflowsDir:K??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Y==null?void 0:Y.upsert({twoWaySync:!0})),await(Y==null?void 0:Y.getSetting("twoWaySync"))&&(ce.cache.put({id:_a,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}},O=async(v,T)=>{if(Pe.graph==null)return;const H=await(q==null?void 0:q.get(v));if(H==null){alert("Error: Workflow not found! id: "+v),x(null);return}const A=T?await(ge==null?void 0:ge.get(T)):null;Pe.ui.dialog.close(),A?(m(A),x({...H,json:A.json}),Pe.loadGraphData(JSON.parse(A.json))):(x(H),m(null),Pe.loadGraphData(JSON.parse(H.json))),r("root"),u&&c(!1)},E=async(v,T,H=!1)=>{var A;if(v===null){x(null),Pe.graph.clear();return}if(!u||H||(A=Y==null?void 0:Y.settings)!=null&&A.autoSave||(q==null?void 0:q.curWorkflow)==null){O(v,T);return}N(v)},N=async v=>{var H;const T=[v?{label:"Open in new tab",icon:I.jsx(yh,{}),onClick:()=>{Jf(v)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),v&&O(v)}}];T.push({label:"Discard",colorScheme:"red",onClick:async()=>{v&&O(v)}}),p(`Please save or discard your changes to "${(H=q==null?void 0:q.curWorkflow)==null?void 0:H.name}" before leaving, or your changes will be lost.`,T)},D=async v=>{const T=(v==null?void 0:v.json)??JSON.stringify(rl),H=await(q==null?void 0:q.createFlow({json:T,name:v==null?void 0:v.name}));H&&await E(H.id),r("root")},R=async(v,T=!1)=>{const H=v.split("/").pop()??v;T?w():D({name:H});const A=await fetch(Yf(v)),X=await A.blob(),K=new File([X],H,{type:A.headers.get("Content-Type")||""});await Pe.handleFile(K),r("root")},$=async(v,T)=>{const H=await(q==null?void 0:q.get(v));if(H==null)return;const A=await(q==null?void 0:q.createFlow({json:H.json,name:T||H.name,parentFolderID:H.parentFolderID}));A&&await E(A.id)},P=j.useCallback(v=>{if(l.current==null)return;let T=v.filename;v.subfolder!=null&&v.subfolder!==""&&(T=v.subfolder+"/"+T),$t==null||$t.create({workflowID:l.current,localPath:T})},[]),B=j.useCallback(()=>{r("root")},[]);return j.useEffect(()=>{k(),b(!0);const v=T=>{var H,A,X,K,ne,z;(X=(A=(H=T.detail)==null?void 0:H.output)==null?void 0:A.images)==null||X.forEach(M=>{M.type==="output"&&P(M)}),(z=(ne=(K=T.detail)==null?void 0:K.output)==null?void 0:ne.gifs)==null||z.forEach(M=>{M.type==="output"&&P(M)})};return Er.addEventListener("executed",v),()=>{window.removeEventListener("executed",v)}},[]),o?null:I.jsx(bt.Provider,{value:{curFlowID:i,onDuplicateWorkflow:$,loadWorkflowID:E,discardUnsavedChanges:_,saveCurWorkflow:w,isDirty:u,setIsDirty:c,loadNewWorkflow:D,loadFilePath:R,setRoute:r,route:n,curVersion:y,setCurVersion:m,setCurFlowIDAndName:x},children:I.jsx("div",{ref:d,className:"workspace_manager",children:I.jsxs(Ia,{containerRef:d,children:[I.jsxs(St,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Xf,draggable:!1,children:[I.jsx($h,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&I.jsx(j.Suspense,{children:I.jsx(ep,{onClose:B,onClickNewFlow:()=>{D(),r("root")}})}),n==="gallery"&&I.jsx(j.Suspense,{children:I.jsx(tp,{onclose:()=>r("root")})})]}),I.jsx(qh,{})]})})})}const jp=Object.freeze(Object.defineProperty({__proto__:null,default:np},Symbol.toStringTag,{value:"Module"}));export{il as $,ph as A,St as B,mp as C,Oh as D,qf as E,kn as F,vh as G,zt as H,jn as I,He as J,qr as K,Vr as L,ci as M,Hr as N,xh as O,rl as P,Pp as Q,Cp as R,fd as S,Xr as T,gr as U,bp as V,rh as W,pp as X,bt as Y,yh as Z,Jf as _,ip as a,Ee as a0,$t as a1,tl as a2,it as a3,Pe as a4,Vl as a5,Xf as a6,cp as a7,wr as a8,yp as a9,Zh as aA,th as aB,_p as aC,Ls as aD,hs as aE,Ip as aF,Sp as aG,Op as aH,Fn as aI,Fh as aJ,Dp as aK,jp as aL,Ra as aa,tc as ab,gp as ac,ps as ad,nn as ae,nc as af,Ue as ag,wp as ah,vp as ai,Ve as aj,Fl as ak,Hn as al,Is as am,ce as an,up as ao,kp as ap,Ep as aq,dp as ar,Er as as,fp as at,_c as au,di as av,ui as aw,mi as ax,hi as ay,xp as az,sp as b,ap as c,Re as d,Eh as e,Aa as f,rn as g,Mt as h,Ht as i,Un as j,Y as k,Qh as l,xc as m,Zd as n,lp as o,hp as p,bo as q,Cs as r,Ss as s,_r as t,Gr as u,_t as v,mh as w,q as x,Ih as y,Xh as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-7hYnIR9_.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-QyxxCI30.js","workspace_web/civitUtils-7bf079LQ.js","workspace_web/chunk-VTV6N5LE-KWHHQVVF.js","workspace_web/IconCopy-KNYgQ4PQ.js","workspace_web/AppIsDirtyEventListener-ZV5NPDCI.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-azmEV7gi.js","workspace_web/chunk-JARCRF6W-J2YFxPIJ.js","workspace_web/chunk-3RSXBRAN-yfOR3kNT.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-z3bKfoPZ.js","workspace_web/IconSearch-6vngoIPw.js","workspace_web/chunk-NTCQBYKE-PRXQGfLv.js","workspace_web/RecentFilesDrawer-BJDDVyUO.js","workspace_web/MediaPreview-QD6yX7R-.js","workspace_web/GalleryModal-qNnfNTjL.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-opv28tSj.js","workspace_web/input.js","workspace_web/chunk-7D6N5TE5-Bj67hFEP.js","workspace_web/civitUtils-Ao2r5rP5.js","workspace_web/chunk-VTV6N5LE-iPEvTIe2.js","workspace_web/IconCopy-pJEV5GIP.js","workspace_web/AppIsDirtyEventListener-HyyIaWmp.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-_rZ5F_Jv.js","workspace_web/chunk-JARCRF6W-OdkdCK_9.js","workspace_web/chunk-3RSXBRAN-Ge4h6OPg.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-NM7L9eNM.js","workspace_web/IconSearch-w32ReMy0.js","workspace_web/chunk-NTCQBYKE-hyXDv1Bs.js","workspace_web/RecentFilesDrawer-o2YKsAW_.js","workspace_web/MediaPreview-aZ3slqVC.js","workspace_web/GalleryModal-H7PcxDl8.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-ZV5NPDCI.js b/dist/workspace_web/AppIsDirtyEventListener-HyyIaWmp.js similarity index 82% rename from dist/workspace_web/AppIsDirtyEventListener-ZV5NPDCI.js rename to dist/workspace_web/AppIsDirtyEventListener-HyyIaWmp.js index d7b0fea..c107f5c 100644 --- a/dist/workspace_web/AppIsDirtyEventListener-ZV5NPDCI.js +++ b/dist/workspace_web/AppIsDirtyEventListener-HyyIaWmp.js @@ -1 +1 @@ -import{r as u,j as E}from"./input.js";import{X as x,a3 as r,af as C,x as a,i as W,T as A,E as d,ag as L,ah as R,k as h,ai as j}from"./App-rR1IBjvq.js";import{u as O}from"./useDebounceFn-ld478fd0.js";function M(){const{isDirty:p,setIsDirty:k,setRoute:v,saveCurWorkflow:T,setCurFlowIDAndName:b}=u.useContext(x),w=u.useRef(p),[S,D]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{w.current=p},[p]),u.useEffect(()=>{var n,i;const c=e=>{var s;if(document.visibilityState==="hidden")return;const t=R(e);if(t)switch(t===d.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(L,{detail:{shortcutType:t}})),t){case d.SAVE:T();break;case d.SAVE_AS:v("saveAsModal");break;case d.openSpotlightSearch:v("spotlightSearch");break}else(s=e.target)!=null&&s.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,s,l,f;const e=(s=(t=r.graph.extra)==null?void 0:t[C])==null?void 0:s.id;(e==null||e!=((f=(l=a)==null?void 0:l.curWorkflow)==null?void 0:f.id))&&b(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),(i=(n=h)==null?void 0:n.settings)!=null&&i.autoSave&&h.settings.autoSaveDuration&&(g.current=setInterval(()=>{_()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",c),g.current&&clearInterval(g.current)}},[]);const _=async()=>{var o,n,i,e,t,s;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||!((e=(i=a)==null?void 0:i.curWorkflow)!=null&&e.id)||!w.current)return;const c=JSON.stringify(r.graph.serialize());await((t=a)==null?void 0:t.updateFlow(a.curWorkflow.id,{json:c})),(s=j)==null||s.create({workflowID:a.curWorkflow.id,isAutoSave:!0,json:c}),k(!1)},I=async()=>{var o,n,i,e,t,s,l,f,y;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||w.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((e=(i=a)==null?void 0:i.curWorkflow)==null?void 0:e.json)&&(k(!0),(s=(t=h)==null?void 0:t.settings)!=null&&s.autoSave&&((f=(l=a)==null?void 0:l.curWorkflow)!=null&&f.id)&&!S&&(await((y=a)==null?void 0:y.latestVersionCheck())||D(!0)))},[m,N]=O(I,900);return S?E.jsx(W,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:E.jsx(A,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{M as default}; +import{r as u,j as E}from"./input.js";import{Y as x,a4 as r,ag as C,x as a,i as W,T as j,E as d,ah as A,ai as L,k as h,aj as R}from"./App-HFfBS8qf.js";import{u as O}from"./useDebounceFn-ld478fd0.js";function M(){const{isDirty:p,setIsDirty:k,setRoute:v,saveCurWorkflow:T,setCurFlowIDAndName:b}=u.useContext(x),w=u.useRef(p),[S,D]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{w.current=p},[p]),u.useEffect(()=>{var n,i;const c=e=>{var s;if(document.visibilityState==="hidden")return;const t=L(e);if(t)switch(t===d.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(A,{detail:{shortcutType:t}})),t){case d.SAVE:T();break;case d.SAVE_AS:v("saveAsModal");break;case d.openSpotlightSearch:v("spotlightSearch");break}else(s=e.target)!=null&&s.matches("input, textarea")&&Object.keys(r.canvas.selected_nodes??{}).length&&m()},o=r.graph.onConfigure;return r.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,s,l,f;const e=(s=(t=r.graph.extra)==null?void 0:t[C])==null?void 0:s.id;(e==null||e!=((f=(l=a)==null?void 0:l.curWorkflow)==null?void 0:f.id))&&b(null)},500)},document.addEventListener("click",e=>{Object.keys(r.canvas.selected_nodes??{}).length&&(r.canvas.node_over!=null||r.canvas.node_capturing_input!=null||r.canvas.node_widget!=null)&&m()}),document.addEventListener("keydown",c),(i=(n=h)==null?void 0:n.settings)!=null&&i.autoSave&&h.settings.autoSaveDuration&&(g.current=setInterval(()=>{_()},h.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",c),g.current&&clearInterval(g.current)}},[]);const _=async()=>{var o,n,i,e,t,s;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||!((e=(i=a)==null?void 0:i.curWorkflow)!=null&&e.id)||!w.current)return;const c=JSON.stringify(r.graph.serialize());await((t=a)==null?void 0:t.updateFlow(a.curWorkflow.id,{json:c})),(s=R)==null||s.create({workflowID:a.curWorkflow.id,isAutoSave:!0,json:c}),k(!1)},I=async()=>{var o,n,i,e,t,s,l,f,y;if((n=(o=a)==null?void 0:o.curWorkflow)!=null&&n.saveLock||w.current)return;const c=r.graph.serialize();JSON.stringify(c)!==((e=(i=a)==null?void 0:i.curWorkflow)==null?void 0:e.json)&&(k(!0),(s=(t=h)==null?void 0:t.settings)!=null&&s.autoSave&&((f=(l=a)==null?void 0:l.curWorkflow)!=null&&f.id)&&!S&&(await((y=a)==null?void 0:y.latestVersionCheck())||D(!0)))},[m,N]=O(I,900);return S?E.jsx(W,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:E.jsx(j,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{M as default}; diff --git a/dist/workspace_web/GalleryModal-qNnfNTjL.js b/dist/workspace_web/GalleryModal-H7PcxDl8.js similarity index 98% rename from dist/workspace_web/GalleryModal-qNnfNTjL.js rename to dist/workspace_web/GalleryModal-H7PcxDl8.js index 57f0a35..ee455c9 100644 --- a/dist/workspace_web/GalleryModal-qNnfNTjL.js +++ b/dist/workspace_web/GalleryModal-H7PcxDl8.js @@ -1 +1 @@ -import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Kt,o as ct,E as Wt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{a9 as nn,aa as sn,d as Re,F as m,ab as rn,I as E,j as on,g as Ee,B as ht,h as W,X as oe,a3 as tt,H as Y,x as K,i as D,w as ft,a1 as xt,e as pt,a0 as R,ac as an,y as ln}from"./App-rR1IBjvq.js";import{c as je,p as cn,r as nt,v as st,I as un,i as dn,b as hn,d as fn,g as xn,N as pn,a as gn,e as mn,f as vn,h as yn,M as gt,u as wn,S as Sn}from"./MediaPreview-QD6yX7R-.js";import{I as bn}from"./chunk-7D6N5TE5-QyxxCI30.js";import{S as jn}from"./chunk-3RSXBRAN-yfOR3kNT.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-J2YFxPIJ.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-KWHHQVVF.js";import"./IconSearch-6vngoIPw.js";const mt=1/60*1e3,Pn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Pn()),mt);function Cn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=Cn(()=>X=!0),e),{}),Tn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Mn(),s.schedule(n,o,a)),e},{}),En=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function _n(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,g=[0,o?100-s[0]:s[0]],f=u?g:s;let x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Rn(e){const t=Fn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function An(e){return wt(e)&&e.touches.length>1}function Fn(e){var t;return(t=e.view)!=null?t:window}function $n(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Vn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?$n(e,t):Vn(e,t)}function Bn(e){return t=>{const s=Rn(t);(!s||s&&t.button===0)&&e(t)}}function On(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Bn(s):s}function ne(e,t,s,n){return Dn(e,t,On(s,t==="pointerdown"),n)}var Ln=Object.defineProperty,Gn=(e,t,s)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Yn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:g,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!g||!this.startEvent)&&(g==null||g(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,An(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Wn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),En.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Kn(t,.1)}}var Hn=e=>e*1e3;function Kn(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Hn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Wn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Yn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Xn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Zn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var qn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Jn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function Qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return qn(()=>{const l=e(),c=l.map((i,u)=>Zn(i,g=>{n(f=>[...f.slice(0,u),g,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Jn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function es(e){return typeof e=="object"&&e!==null&&"current"in e}function ts(e){const[t]=Qn({observeMutation:!1,getNodes(){return[es(e)?e.current:e]}});return t}function ns(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({isReversed:c,direction:i,orientation:u}),[_t,de]=nn({value:a,defaultValue:l??rs(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Oe]=d.useState(!1),xe=!(f||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,Ke]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),We=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:Ke,"data-disabled":$(f),style:{...h.style,...qe}}),[f,Ke,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,We),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,We]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Ot}}function ss(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function rs(e,t){return t"}),[as,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Kt("Slider",n),a=ct(n),{direction:l}=Wt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{value:o,children:r.jsxs(O.div,{...g,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=B((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=B((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=B((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ls=B((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});ls.displayName="SliderMark";function is(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var cs=["h","minH","height","minHeight"],It=B((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?is(s,cs):s;return r.jsx(O.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var us=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Et=Re("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const ds=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(m,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(bn,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(us,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null};function hs(e){const t=e.split(".").pop();return fetch(e).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.blob()}).then(async s=>{const n=e.split("/").pop()??"",o=new File([s],n);if(dn(e))return hn(o);if(t==="webp")return fn(o);const a=await xn(o),l=JSON.parse(a==null?void 0:a.prompt),c=JSON.parse(a==null?void 0:a.workflow);return{prompt:l,workflow:c}})}const fs=({inputItem:e})=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(on,{value:e.inputValue,onChange:t=>{}})]}),xs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(pn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(gn,{}),r.jsxs(mn,{children:[r.jsx(vn,{}),r.jsx(yn,{})]})]})]}),r.jsx(m,{children:r.jsxs(jt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ps=e=>{var s;const{inputItem:t}=e;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(jn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},gs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsx(m,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const ms=e=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(m,{children:"No Support"})]}),vs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ys={[P.Input]:fs,[P.InputSlider]:xs,[P.Select]:ps,[P.Textarea]:gs,[P.Checkbox]:vs,NoSupport:ms},ws=LiteGraph.registered_node_types;function Ss(e,t){var o,a,l,c,i;const s=(o=ws[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:P.Select}:{type:P.NoSupport}}const ze=({inputItem:e})=>{const t=Ss(e.classType,e.inputName),[s,n]=d.useState(!1),o=ys[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(m,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(E,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function bs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(m,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function js(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(ks,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(m,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function ks({title:e,children:t}){return r.jsxs(ht,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function Ps(e){se=[],De=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Nt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function Cs({media:e}){const[t,s]=d.useState([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},children:r.jsxs(m,{direction:"column",align:"stretch",gap:5,children:[r.jsx(bs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&r.jsx(js,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Is=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=K)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(m,{flexWrap:"wrap",gap:3,children:[r.jsx(m,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(E,{size:"sm",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(m,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=K)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=K)==null?void 0:i.updateMetaInfo(K.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ts=({media:e})=>r.jsxs(m,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(Is,{media:e}),r.jsx(Cs,{media:e??null})]}),Te=120;function Es({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(m,{gap:3,h:"100%",children:[r.jsxs(kn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(ds,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(m,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(gt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=R)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ts,{media:t??void 0})]})}const Ns=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(gt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var g;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((g=R)==null?void 0:g.delete(e.id))}})})]})]})},Ms=Ns;function _s({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==null||i.filter(u=>{var g;return((g=u.workflowJSON)==null?void 0:g.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ms,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Gs({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=K)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(an,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(Sn,{searchValue:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(_s,{searchQuery:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default}; +import{r as d,d as Se,x as Ht,m as be,b as it,f as B,k as Kt,o as ct,E as Wt,j as r,g as O,n as Yt,e as Xt,V as ut,h as dt,M as Zt,N as qt,O as Jt,Q as Qt,R as en,S as tn}from"./input.js";import{aa as nn,ab as sn,d as Re,F as m,ac as rn,I as E,j as on,g as Ee,B as ht,h as W,Y as oe,a4 as tt,H as Y,x as K,i as D,w as ft,a2 as xt,e as pt,a1 as R,ad as an,y as ln}from"./App-HFfBS8qf.js";import{c as je,p as cn,r as nt,v as st,I as un,i as dn,b as hn,d as fn,g as xn,N as pn,a as gn,e as mn,f as vn,h as yn,M as gt,u as wn,S as Sn}from"./MediaPreview-aZ3slqVC.js";import{I as bn}from"./chunk-7D6N5TE5-Bj67hFEP.js";import{S as jn}from"./chunk-3RSXBRAN-Ge4h6OPg.js";import{C as Ae,G as kn}from"./chunk-JARCRF6W-OdkdCK_9.js";import{S as rt,L as Ne}from"./chunk-VTV6N5LE-iPEvTIe2.js";import"./IconSearch-w32ReMy0.js";const mt=1/60*1e3,Pn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Pn()),mt);function Cn(e){let t=[],s=[],n=0,o=!1,a=!1;const l=new WeakSet,c={schedule:(i,u=!1,g=!1)=>{const f=g&&o,x=f?t:s;return u&&l.add(i),x.indexOf(i)===-1&&(x.push(i),f&&o&&(n=t.length)),i},cancel:i=>{const u=s.indexOf(i);u!==-1&&s.splice(u,1),l.delete(i)},process:i=>{if(o){a=!0;return}if(o=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let u=0;u(e[t]=Cn(()=>X=!0),e),{}),Tn=Z.reduce((e,t)=>{const s=ae[t];return e[t]=(n,o=!1,a=!1)=>(X||Mn(),s.schedule(n,o,a)),e},{}),En=Z.reduce((e,t)=>(e[t]=ae[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>ae[t].process(V),e),{});const Nn=e=>ae[e].process(V),yt=e=>{X=!1,V.delta=Me?mt:Math.max(Math.min(e-V.timestamp,In),1),V.timestamp=e,_e=!0,Z.forEach(Nn),_e=!1,X&&(Me=!1,vt(yt))},Mn=()=>{X=!0,Me=!0,_e||vt(yt)},ot=()=>V;var $=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function Q(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var te={width:0,height:0},ee=e=>e||te;function _n(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:o}=e,a=y=>{var j;const A=(j=n[y])!=null?j:te;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...Q({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${A.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${A.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,j)=>ee(y).height>ee(j).height?y:j,te):n.reduce((y,j)=>ee(y).width>ee(j).width?y:j,te),c={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...Q({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},i={position:"absolute",...Q({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},u=s.length===1,g=[0,o?100-s[0]:s[0]],f=u?g:s;let x=f[0];!u&&o&&(x=100-x);const b=Math.abs(f[f.length-1]-f[0]),N={...i,...Q({orientation:t,vertical:o?{height:`${b}%`,top:`${x}%`}:{height:`${b}%`,bottom:`${x}%`},horizontal:o?{width:`${b}%`,right:`${x}%`}:{width:`${b}%`,left:`${x}%`}})};return{trackStyle:i,innerTrackStyle:N,rootStyle:c,getThumbStyle:a}}function zn(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Dn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function Rn(e){const t=Fn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function wt(e){return!!e.touches}function An(e){return wt(e)&&e.touches.length>1}function Fn(e){var t;return(t=e.view)!=null?t:window}function $n(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function Vn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function St(e,t="page"){return wt(e)?$n(e,t):Vn(e,t)}function Bn(e){return t=>{const s=Rn(t);(!s||s&&t.button===0)&&e(t)}}function On(e,t=!1){function s(o){e(o,{point:St(o)})}return t?Bn(s):s}function ne(e,t,s,n){return Dn(e,t,On(s,t==="pointerdown"),n)}var Ln=Object.defineProperty,Gn=(e,t,s)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,I=(e,t,s)=>(Gn(e,typeof t!="symbol"?t+"":t,s),s),Un=class{constructor(e,t,s){I(this,"history",[]),I(this,"startEvent",null),I(this,"lastEvent",null),I(this,"lastEventInfo",null),I(this,"handlers",{}),I(this,"removeListeners",()=>{}),I(this,"threshold",3),I(this,"win"),I(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const c=Ce(this.lastEventInfo,this.history),i=this.startEvent!==null,u=Yn(c.offset,{x:0,y:0})>=this.threshold;if(!i&&!u)return;const{timestamp:g}=ot();this.history.push({...c.point,timestamp:g});const{onStart:f,onMove:x}=this.handlers;i||(f==null||f(this.lastEvent,c),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,c)}),I(this,"onPointerMove",(c,i)=>{this.lastEvent=c,this.lastEventInfo=i,Tn.update(this.updatePoint,!0)}),I(this,"onPointerUp",(c,i)=>{const u=Ce(i,this.history),{onEnd:g,onSessionEnd:f}=this.handlers;f==null||f(c,u),this.end(),!(!g||!this.startEvent)&&(g==null||g(c,u))});var n;if(this.win=(n=e.view)!=null?n:window,An(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const o={point:St(e)},{timestamp:a}=ot();this.history=[{...o.point,timestamp:a}];const{onSessionStart:l}=t;l==null||l(e,Ce(o,this.history)),this.removeListeners=Wn(ne(this.win,"pointermove",this.onPointerMove),ne(this.win,"pointerup",this.onPointerUp),ne(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),En.update(this.updatePoint)}};function at(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:at(e.point,t[t.length-1]),offset:at(e.point,t[0]),velocity:Kn(t,.1)}}var Hn=e=>e*1e3;function Kn(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const o=e[e.length-1];for(;s>=0&&(n=e[s],!(o.timestamp-n.timestamp>Hn(t)));)s--;if(!n)return{x:0,y:0};const a=(o.timestamp-n.timestamp)/1e3;if(a===0)return{x:0,y:0};const l={x:(o.x-n.x)/a,y:(o.y-n.y)/a};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Wn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function lt(e){return"x"in e&&"y"in e}function Yn(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(lt(e)&<(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function bt(e){const t=d.useRef(null);return t.current=e,t}function Xn(e,t){const{onPan:s,onPanStart:n,onPanEnd:o,onPanSessionStart:a,onPanSessionEnd:l,threshold:c}=t,i=!!(s||n||o||a||l),u=d.useRef(null),g=bt({onSessionStart:a,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,x){u.current=null,o==null||o(f,x)}});d.useEffect(()=>{var f;(f=u.current)==null||f.updateHandlers(g.current)}),d.useEffect(()=>{const f=e.current;if(!f||!i)return;function x(b){u.current=new Un(b,g.current,c)}return ne(f,"pointerdown",x)},[e,i,g,c]),d.useEffect(()=>()=>{var f;(f=u.current)==null||f.end(),u.current=null},[])}function Zn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[a]=o;let l,c;if("borderBoxSize"in a){const i=a.borderBoxSize,u=Array.isArray(i)?i[0]:i;l=u.inlineSize,c=u.blockSize}else l=e.offsetWidth,c=e.offsetHeight;t({width:l,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var qn=globalThis!=null&&globalThis.document?d.useLayoutEffect:d.useEffect;function Jn(e,t){var s,n;if(!e||!e.parentElement)return;const o=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,a=new o.MutationObserver(()=>{t()});return a.observe(e.parentElement,{childList:!0}),()=>{a.disconnect()}}function Qn({getNodes:e,observeMutation:t=!0}){const[s,n]=d.useState([]),[o,a]=d.useState(0);return qn(()=>{const l=e(),c=l.map((i,u)=>Zn(i,g=>{n(f=>[...f.slice(0,u),g,...f.slice(u+1)])}));if(t){const i=l[0];c.push(Jn(i,()=>{a(u=>u+1)}))}return()=>{c.forEach(i=>{i==null||i()})}},[o]),s}function es(e){return typeof e=="object"&&e!==null&&"current"in e}function ts(e){const[t]=Qn({observeMutation:!1,getNodes(){return[es(e)?e.current:e]}});return t}function ns(e){var t;const{min:s=0,max:n=100,onChange:o,value:a,defaultValue:l,isReversed:c,direction:i="ltr",orientation:u="horizontal",id:g,isDisabled:f,isReadOnly:x,onChangeStart:b,onChangeEnd:N,step:y=1,getAriaValueText:j,"aria-valuetext":A,"aria-label":F,"aria-labelledby":w,name:M,focusThumbOnChange:Mt=!0,...Fe}=e,$e=Se(b),L=Se(N),Ve=Se(j),C=zn({isReversed:c,direction:i,orientation:u}),[_t,de]=nn({value:a,defaultValue:l??rs(s,n),onChange:o}),[he,Be]=d.useState(!1),[fe,Oe]=d.useState(!1),xe=!(f||x),pe=(n-s)/10,G=y||(n-s)/100,v=je(_t,s,n),zt=n-v+s,Le=st(C?zt:v,s,n),J=u==="vertical",S=bt({min:s,max:n,step:y,isDisabled:f,value:v,isInteractive:xe,isReversed:C,isVertical:J,eventSource:null,focusThumbOnChange:Mt,orientation:u}),ge=d.useRef(null),me=d.useRef(null),Ge=d.useRef(null),Dt=d.useId(),Ue=g??Dt,[He,Ke]=[`slider-thumb-${Ue}`,`slider-track-${Ue}`],Rt=d.useCallback(h=>{var p,U;if(!ge.current)return;const k=S.current;k.eventSource="pointer";const T=ge.current.getBoundingClientRect(),{clientX:ye,clientY:Lt}=(U=(p=h.touches)==null?void 0:p[0])!=null?U:h,Gt=J?T.bottom-Lt:ye-T.left,Ut=J?T.height:T.width;let we=Gt/Ut;C&&(we=1-we);let H=cn(we,k.min,k.max);return k.step&&(H=parseFloat(nt(H,k.min,k.step))),H=je(H,k.min,k.max),H},[J,C,S]),_=d.useCallback(h=>{const p=S.current;p.isInteractive&&(h=parseFloat(nt(h,p.min,G)),h=je(h,p.min,p.max),de(h))},[G,de,S]),z=d.useMemo(()=>({stepUp(h=G){const p=C?v-h:v+h;_(p)},stepDown(h=G){const p=C?v+h:v-h;_(p)},reset(){_(l||0)},stepTo(h){_(h)}}),[_,C,v,G,l]),We=d.useCallback(h=>{const p=S.current,k={ArrowRight:()=>z.stepUp(),ArrowUp:()=>z.stepUp(),ArrowLeft:()=>z.stepDown(),ArrowDown:()=>z.stepDown(),PageUp:()=>z.stepUp(pe),PageDown:()=>z.stepDown(pe),Home:()=>_(p.min),End:()=>_(p.max)}[h.key];k&&(h.preventDefault(),h.stopPropagation(),k(h),p.eventSource="keyboard")},[z,_,pe,S]),Ye=(t=Ve==null?void 0:Ve(v))!=null?t:A,ve=ts(me),{getThumbStyle:Xe,rootStyle:Ze,trackStyle:qe,innerTrackStyle:Je}=d.useMemo(()=>{const h=S.current,p=ve??{width:0,height:0};return _n({isReversed:C,orientation:h.orientation,thumbRects:[p],thumbPercents:[Le]})},[C,ve,Le,S]),Qe=d.useCallback(()=>{S.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=me.current)==null?void 0:p.focus()})},[S]);Ht(()=>{const h=S.current;Qe(),h.eventSource==="keyboard"&&(L==null||L(h.value))},[v,L]);function et(h){const p=Rt(h);p!=null&&p!==S.current.value&&de(p)}Xn(Ge,{onPanSessionStart(h){const p=S.current;p.isInteractive&&(Be(!0),Qe(),et(h),$e==null||$e(p.value))},onPanSessionEnd(){const h=S.current;h.isInteractive&&(Be(!1),L==null||L(h.value))},onPan(h){S.current.isInteractive&&et(h)}});const At=d.useCallback((h={},p=null)=>({...h,...Fe,ref:be(p,Ge),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...h.style,...Ze}}),[Fe,f,fe,Ze]),Ft=d.useCallback((h={},p=null)=>({...h,ref:be(p,ge),id:Ke,"data-disabled":$(f),style:{...h.style,...qe}}),[f,Ke,qe]),$t=d.useCallback((h={},p=null)=>({...h,ref:p,style:{...h.style,...Je}}),[Je]),Vt=d.useCallback((h={},p=null)=>({...h,ref:be(p,me),role:"slider",tabIndex:xe?0:void 0,id:He,"data-active":$(he),"aria-valuetext":Ye,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":v,"aria-orientation":u,"aria-disabled":ke(f),"aria-readonly":ke(x),"aria-label":F,"aria-labelledby":F?void 0:w,style:{...h.style,...Xe(0)},onKeyDown:Pe(h.onKeyDown,We),onFocus:Pe(h.onFocus,()=>Oe(!0)),onBlur:Pe(h.onBlur,()=>Oe(!1))}),[xe,He,he,Ye,s,n,v,u,f,x,F,w,Xe,We]),Bt=d.useCallback((h,p=null)=>{const U=!(h.valuen),k=v>=h.value,T=st(h.value,s,n),ye={position:"absolute",pointerEvents:"none",...ss({orientation:u,vertical:{bottom:C?`${100-T}%`:`${T}%`},horizontal:{left:C?`${100-T}%`:`${T}%`}})};return{...h,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!U),"data-highlighted":$(k),style:{...h.style,...ye}}},[f,C,n,s,u,v]),Ot=d.useCallback((h={},p=null)=>({...h,ref:p,type:"hidden",value:v,name:M}),[M,v]);return{state:{value:v,isFocused:fe,isDragging:he},actions:z,getRootProps:At,getTrackProps:Ft,getInnerTrackProps:$t,getThumbProps:Vt,getMarkerProps:Bt,getInputProps:Ot}}function ss(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function rs(e,t){return t"}),[as,ie]=it({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=B((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},o=Kt("Slider",n),a=ct(n),{direction:l}=Wt();a.direction=l;const{getInputProps:c,getRootProps:i,...u}=ns(a),g=i(),f=c({},t);return r.jsx(os,{value:u,children:r.jsx(as,{value:o,children:r.jsxs(O.div,{...g,className:q("chakra-slider",n.className),__css:o.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=B((e,t)=>{const{getThumbProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=B((e,t)=>{const{getTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=B((e,t)=>{const{getInnerTrackProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ls=B((e,t)=>{const{getMarkerProps:s}=le(),n=ie(),o=s(e,t);return r.jsx(O.div,{...o,className:q("chakra-slider__marker",e.className),__css:n.mark})});ls.displayName="SliderMark";function is(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var cs=["h","minH","height","minHeight"],It=B((e,t)=>{const s=Yt("Textarea",e),{className:n,rows:o,...a}=ct(e),l=sn(a),c=o?is(s,cs):s;return r.jsx(O.textarea,{ref:t,rows:o,...l,className:Xt("chakra-textarea",n),__css:c})});It.displayName="Textarea";var us=Re("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Tt=Re("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Et=Re("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const ds=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const c=(s+l+t.length)%t.length;e&&e(t[c])},o={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const a=t.at(s);return a?r.jsxs(m,{justifyContent:"center",alignItems:"center",position:"relative",width:o.width,height:o.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(a.imageUrl)},children:rn(a.imageUrl)?r.jsx(bn,{src:a.imageUrl,alt:`image-${a.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:a.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},a.id),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(us,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(E,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null};function hs(e){const t=e.split(".").pop();return fetch(e).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.blob()}).then(async s=>{const n=e.split("/").pop()??"",o=new File([s],n);if(dn(e))return hn(o);if(t==="webp")return fn(o);const a=await xn(o),l=JSON.parse(a==null?void 0:a.prompt),c=JSON.parse(a==null?void 0:a.workflow);return{prompt:l,workflow:c}})}const fs=({inputItem:e})=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(on,{value:e.inputValue,onChange:t=>{}})]}),xs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(pn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(gn,{}),r.jsxs(mn,{children:[r.jsx(vn,{}),r.jsx(yn,{})]})]})]}),r.jsx(m,{children:r.jsxs(jt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},ps=e=>{var s;const{inputItem:t}=e;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(jn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,o)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${o}`))})]})},gs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:1,direction:"column",children:[r.jsx(m,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var P=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(P||{});const ms=e=>r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(m,{children:"No Support"})]}),vs=e=>{const t=e.inputItem;return r.jsxs(m,{gap:2,children:[r.jsx(m,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ae,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ce=d.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),ys={[P.Input]:fs,[P.InputSlider]:xs,[P.Select]:ps,[P.Textarea]:gs,[P.Checkbox]:vs,NoSupport:ms},ws=LiteGraph.registered_node_types;function Ss(e,t){var o,a,l,c,i;const s=(o=ws[e])==null?void 0:o.nodeData,n={...((a=s==null?void 0:s.input)==null?void 0:a.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(c=n==null?void 0:n[1])!=null&&c.multiline?{type:P.Textarea}:{type:P.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:P.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:P.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((i=n==null?void 0:n[0])!=null&&i.every(u=>typeof u=="string"))?{options:n==null?void 0:n[0],type:P.Select}:{type:P.NoSupport}}const ze=({inputItem:e})=>{const t=Ss(e.classType,e.inputName),[s,n]=d.useState(!1),o=ys[t.type??"Input"],{updateTopField:a,topFields:l}=d.useContext(ce),c=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",i={...e,label:e.label??e.inputName+c};return r.jsxs(m,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(E,{size:"xs",onClick:()=>a==null?void 0:a({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:re(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(Tt,{size:14}):r.jsx(Et,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(o,{inputItem:i,...t})})]})};function bs(){const{topFields:e,updateTopField:t,calcInputList:s}=d.useContext(ce);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(m,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const o=s.find(a=>a.nodeID==n.promptKey&&a.inputName===n.name&&a.classType===n.class_type);return!n.class_type||!o?null:r.jsx(ze,{inputItem:o},`formTopField${n.promptKey}${n.name}`)})})})}function js(){const{topFields:e,calcInputList:t,showNodeName:s}=d.useContext(ce),n=d.useCallback(a=>{const l=[];return a.forEach(c=>{const i=l[l.length-1];!i||i[0].nodeID!==c.nodeID||i[0].classType!==c.classType?l.push([c]):i.push(c)}),l},[]);if(d.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(a=>re(e,{name:a.inputName,promptKey:a.nodeID,classType:a.classType})?null:r.jsx(ze,{inputItem:a},`form${a.nodeID}${a.inputName}`))});const o=n(t);return r.jsx(Ee,{children:o.map(a=>a[0]?r.jsx(ks,{title:a[0].classType+" #"+a[0].nodeID,children:r.jsx(m,{px:2,gap:1,direction:"column",children:a.map(l=>re(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(ze,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},a[0].nodeID):null)})}function ks({title:e,children:t}){return r.jsxs(ht,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(W,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let se=[],De=new Set;function Nt(e,t){if(!De.has(e.nodeID))return De.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0];Nt(t[o],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||se.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),se}function Ps(e){se=[],De=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const o=n[0],a=e[o];a.children||(a.children=[]),a.children.push(s)}});for(const t of Object.keys(e))Nt(e[t],e);return se}const re=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function Cs({media:e}){const[t,s]=d.useState([]);d.useContext(oe);const[n,o]=d.useState(),[a,l]=d.useState(!0),[c,i]=d.useState(!0);d.useEffect(()=>{e?hs(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):tt.graphToPrompt(tt.graph).then(x=>{o(x.output)})},[e]),d.useEffect(()=>{if(!n)return;const x=Ps(n);s(x)},[n]);const[u,g]=d.useState([]),f=x=>{if(re(u,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const b=u.filter(N=>N.name!==x.name||N.promptKey!==x.promptKey);g(b)}else{const b=[...u,x];g(b)}};return r.jsx(ce.Provider,{value:{topFields:u,showNodeName:c,calcInputList:t,updateTopField:f},children:r.jsxs(m,{direction:"column",align:"stretch",gap:5,children:[r.jsx(bs,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(rt,{isChecked:a,onChange:x=>l(!a)}),r.jsx("p",{children:"Show node names"}),r.jsx(rt,{isChecked:c,onChange:x=>i(!c)})]}),a&&r.jsx(js,{})]})})}const ue=d.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Is=({media:e})=>{var l,c;const[t,s]=d.useState(!1),{setMediaList:n}=d.useContext(ue),{loadFilePath:o}=d.useContext(oe),{showDialog:a}=ut();return d.useEffect(()=>{var i,u;s((e==null?void 0:e.localPath)!=null&&((u=(i=K)==null?void 0:i.curWorkflow)==null?void 0:u.coverMediaPath)===(e==null?void 0:e.localPath))},[e]),e?r.jsxs(m,{flexWrap:"wrap",gap:3,children:[r.jsx(m,{alignItems:"center",gap:2,children:e.localPath&&r.jsxs(r.Fragment,{children:[r.jsx(W,{children:e==null?void 0:e.localPath}),r.jsx(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(E,{size:"sm",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(m,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsx(W,{children:xt((e==null?void 0:e.createTime)??0,!0)})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var u;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((u=R)==null?void 0:u.delete(e.id)),n(g=>g.filter(f=>f.id!==e.id)))}})}),((c=(l=K)==null?void 0:l.curWorkflow)==null?void 0:c.id)&&r.jsx(D,{label:"Set as cover",children:r.jsx(E,{size:"sm",variant:"ghost",icon:t?r.jsx(Tt,{size:19}):r.jsx(Et,{size:19}),"aria-label":"set as cover",onClick:async()=>{var i;await((i=K)==null?void 0:i.updateMetaInfo(K.curWorkflow.id,{coverMediaPath:t?void 0:e.localPath})),s(!t)}})}),r.jsx(dt,{onClick:()=>a("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{o(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>o(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"})]}):null},Ts=({media:e})=>r.jsxs(m,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsx(Is,{media:e}),r.jsx(Cs,{media:e??null})]}),Te=120;function Es({mediaList:e}){const{curMedia:t,setCurMedia:s}=d.useContext(ue);return r.jsxs(m,{gap:3,h:"100%",children:[r.jsxs(kn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx("div",{style:{height:"56vh"},children:r.jsx(ds,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(o=>o.id===n.id))??null)})}),r.jsx(m,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ht,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(gt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var o;(o=R)==null||o.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(Ts,{media:t??void 0})]})}const Ns=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:a,loadFilePath:l}=d.useContext(oe),{showDialog:c}=ut();if(e.localPath==null||a==null)return null;const i=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ae,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(gt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var u;(u=R)==null||u.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(D,{label:xt(e.createTime,!0),children:i}),r.jsx(D,{label:e.localPath,children:r.jsx(W,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(dt,{flexGrow:1,onClick:()=>c("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(D,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(D,{label:"Remove image from gallery",children:r.jsx(E,{size:"sm",variant:"ghost",icon:r.jsx(pt,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var g;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((g=R)==null?void 0:g.delete(e.id))}})})]})]})},Ms=Ns;function _s({searchQuery:e}){const[t,s]=d.useState([]),{setCurMedia:n,setShowAllImages:o,setMediaList:a}=d.useContext(ue);d.useEffect(()=>{var c,i;e===""?(c=R)==null||c.listAll().then(u=>{s(u.slice(0,50)??[])}):(i=R)==null||i.filter(u=>{var g;return((g=u.workflowJSON)==null?void 0:g.includes(e))??!1}).then(u=>{s(u)})},[e]);const l=c=>{a([c].concat(t.filter(i=>i.id!==c.id))),n(c),o(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(c=>r.jsx(Ms,{selectedID:[],media:c,isSelecting:!1,onClickMedia:l},c.id))})}function Gs({onclose:e}){const{curFlowID:t}=d.useContext(oe),[s,n]=d.useState(""),[o,a]=d.useState([]),[l,c]=d.useState(!1),[i,u]=d.useState([]),[g,f]=d.useState(),[x,b]=d.useState(""),N=wn(x,300),[y,j]=d.useState(!1),A=async()=>{var M;if(t==null)return;const w=await((M=R)==null?void 0:M.listByWorkflowID(t));u(w??[]),w!=null&&w.length&&f(w[0])};if(d.useEffect(()=>{var w;A(),t&&((w=K)==null||w.get(t).then(M=>{M&&n(M.name)}))},[]),t==null)return null;const F=i.length>0&&o.length===i.length;return r.jsx(ue.Provider,{value:{curMedia:g??null,setCurMedia:f,setMediaList:u,showAllImages:y,setShowAllImages:j},children:r.jsxs(Zt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(qt,{}),r.jsxs(Jt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Qt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(an,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(Sn,{searchValue:x,onUpdateSearchValue:w=>{b(w),y||j(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ae,{isChecked:F,onChange:()=>{a(F?[]:i.map(w=>w.id))},children:"All"}),r.jsxs(W,{fontSize:16,children:[o.length," Selected"]}),r.jsx(E,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>c(!1),"aria-label":"cancel"})]})]}),r.jsx(en,{}),r.jsx(tn,{overflowY:"auto",children:y?r.jsx(_s,{searchQuery:N}):r.jsx(Es,{mediaList:i})})]})]})})}export{Gs as default}; diff --git a/dist/workspace_web/IconCopy-KNYgQ4PQ.js b/dist/workspace_web/IconCopy-pJEV5GIP.js similarity index 83% rename from dist/workspace_web/IconCopy-KNYgQ4PQ.js rename to dist/workspace_web/IconCopy-pJEV5GIP.js index 604679a..634b370 100644 --- a/dist/workspace_web/IconCopy-KNYgQ4PQ.js +++ b/dist/workspace_web/IconCopy-pJEV5GIP.js @@ -1 +1 @@ -import{d as a}from"./App-rR1IBjvq.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; +import{d as a}from"./App-HFfBS8qf.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; diff --git a/dist/workspace_web/IconSearch-6vngoIPw.js b/dist/workspace_web/IconSearch-w32ReMy0.js similarity index 67% rename from dist/workspace_web/IconSearch-6vngoIPw.js rename to dist/workspace_web/IconSearch-w32ReMy0.js index c5761c9..8d25a5e 100644 --- a/dist/workspace_web/IconSearch-6vngoIPw.js +++ b/dist/workspace_web/IconSearch-w32ReMy0.js @@ -1 +1 @@ -import{d as a}from"./App-rR1IBjvq.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I}; +import{d as a}from"./App-HFfBS8qf.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I}; diff --git a/dist/workspace_web/MediaPreview-QD6yX7R-.js b/dist/workspace_web/MediaPreview-aZ3slqVC.js similarity index 98% rename from dist/workspace_web/MediaPreview-QD6yX7R-.js rename to dist/workspace_web/MediaPreview-aZ3slqVC.js index 15f8410..8de4ea4 100644 --- a/dist/workspace_web/MediaPreview-QD6yX7R-.js +++ b/dist/workspace_web/MediaPreview-aZ3slqVC.js @@ -1 +1 @@ -import{d as D,r as l,j as v,I as Ee,x as Te,y as je,m as ae,q as _,p as se,b as Pe,f as T,g as Y,k as Be,o as Ke,e as Ve}from"./input.js";import{ad as Ge,ae as We,d as Le,B as qe,I as ze,y as He,j as Xe,ab as $e}from"./App-rR1IBjvq.js";import{I as Ye}from"./IconSearch-6vngoIPw.js";import{I as Je}from"./chunk-7D6N5TE5-QyxxCI30.js";function Qe(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function ie(t,e){let r=Qe(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function ue(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Ct(t,e,r){return(t-e)*100/(r-e)}function It(t,e,r){return(r-e)*t+e}function St(t,e,r){const a=Math.round((t-e)/r)*r+e,i=ue(r);return ie(a,i)}function Ze(t,e,r){return t==null?t:(r{var g;return a==null?"":(g=oe(a,s,r))!=null?g:""}),x=typeof i<"u",h=x?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(x||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,x,h]),k=l.useCallback(g=>{let b=g;return f&&(b=Ze(b,u,o)),ie(b,S)},[S,f,o,u]),j=l.useCallback((g=s)=>{let b;h===""?b=P(g):b=P(h)+g,b=k(b),A(b)},[k,s,A,h]),B=l.useCallback((g=s)=>{let b;h===""?b=P(-g):b=P(h)-g,b=k(b),A(b)},[k,s,A,h]),K=l.useCallback(()=>{var g;let b;a==null?b="":b=(g=oe(a,s,r))!=null?g:u,A(b)},[a,r,s,A,u]),Q=l.useCallback(g=>{var b;const ee=(b=oe(g,s,S))!=null?b:u;A(ee)},[S,s,A,u]),V=P(h);return{isOutOfRange:V>o||Vv.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=t=>v.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function _e(t,e,r,a){l.useEffect(()=>{var i;if(!t.current||!a)return;const s=(i=t.current.ownerDocument.defaultView)!=null?i:window,u=Array.isArray(e)?e:[e],o=new s.MutationObserver(f=>{for(const c of f)c.type==="attributes"&&c.attributeName&&u.includes(c.attributeName)&&r(c)});return o.observe(t.current,{attributes:!0,attributeFilter:u}),()=>o.disconnect()})}function rt(t,e){const r=D(t);l.useEffect(()=>{let a=null;const i=()=>r();return e!==null&&(a=window.setInterval(i,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(t,e){const[r,a]=l.useState(!1),[i,s]=l.useState(null),[u,o]=l.useState(!0),f=l.useRef(null),c=()=>clearTimeout(f.current);rt(()=>{i==="increment"&&t(),i==="decrement"&&e()},r?at:null);const m=l.useCallback(()=>{u&&t(),f.current=setTimeout(()=>{o(!1),a(!0),s("increment")},ke)},[t,u]),w=l.useCallback(()=>{u&&e(),f.current=setTimeout(()=>{o(!1),a(!0),s("decrement")},ke)},[e,u]),x=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:x,isSpinning:r}}var ot=/^[Ee0-9+\-.]$/;function ut(t){return ot.test(t)}function it(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function lt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:i=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER,step:u=1,isReadOnly:o,isDisabled:f,isRequired:c,isInvalid:m,pattern:w="[0-9]*(.[0-9]+)?",inputMode:x="decimal",allowMouseWheel:h,id:I,onChange:S,precision:A,name:k,"aria-describedby":j,"aria-label":B,"aria-labelledby":K,onFocus:Q,onBlur:V,onInvalid:ce,getAriaValueText:fe,isValidCharacter:Z,format:g,parse:b,...ee}=t,te=D(Q),de=D(V),R=D(ce),G=D(Z??ut),ne=D(fe),d=et(t),{update:U,increment:pe,decrement:me}=d,[Fe,re]=l.useState(!1),W=!(o||f),E=l.useRef(null),L=l.useRef(null),be=l.useRef(null),ge=l.useRef(null),q=l.useCallback(n=>n.split("").filter(G).join(""),[G]),z=l.useCallback(n=>{var p;return(p=b==null?void 0:b(n))!=null?p:n},[b]),F=l.useCallback(n=>{var p;return((p=g==null?void 0:g(n))!=null?p:n).toString()},[g]);Te(()=>{(d.valueAsNumber>s||d.valueAsNumber{if(!E.current)return;if(E.current.value!=d.value){const p=z(E.current.value);d.setValue(q(p))}},[z,q]);const H=l.useCallback((n=u)=>{W&&pe(n)},[pe,W,u]),X=l.useCallback((n=u)=>{W&&me(n)},[me,W,u]),N=st(H,X);_e(be,"disabled",N.stop,N.isSpinning),_e(ge,"disabled",N.stop,N.isSpinning);const he=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;const y=z(n.currentTarget.value);U(q(y)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,y,C;te==null||te(n),L.current&&(n.target.selectionStart=(y=L.current.start)!=null?y:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),ye=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,y=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[y];M&&(n.preventDefault(),M(n))},[G,u,H,X,U,i,s]),we=n=>{let p=1;return(n.metaKey||n.ctrlKey)&&(p=.1),n.shiftKey&&(p=10),p},xe=l.useMemo(()=>{const n=ne==null?void 0:ne(d.value);if(n!=null)return n;const p=d.value.toString();return p||void 0},[d.value,ne]),Ne=l.useCallback(()=>{let n=d.value;if(d.value==="")return;/^[eE]/.test(d.value.toString())?d.setValue(""):(d.valueAsNumbers&&(n=s),d.cast(n))},[d,s,i]),Ce=l.useCallback(()=>{re(!1),r&&Ne()},[r,re,Ne]),$=l.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=E.current)==null||n.focus()})},[e]),Ie=l.useCallback(n=>{n.preventDefault(),N.up(),$()},[$,N]),Se=l.useCallback(n=>{n.preventDefault(),N.down(),$()},[$,N]);Ge(()=>E.current,"wheel",n=>{var p,y;const M=((y=(p=E.current)==null?void 0:p.ownerDocument)!=null?y:document).activeElement===E.current;if(!h||!M)return;n.preventDefault();const O=we(n)*u,Ae=Math.sign(n.deltaY);Ae===-1?H(O):Ae===1&&X(O)},{passive:!1});const Re=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var y,C,M,O;return{name:k,inputMode:x,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(y=n.readOnly)!=null?y:o,"aria-readonly":(C=n.readOnly)!=null?C:o,"aria-required":(M=n.required)!=null?M:c,required:(O=n.required)!=null?O:c,ref:ae(E,p),value:F(d.value),role:"spinbutton","aria-valuemin":i,"aria-valuemax":s,"aria-valuenow":Number.isNaN(d.valueAsNumber)?void 0:d.valueAsNumber,"aria-invalid":se(m??d.isOutOfRange),"aria-valuetext":xe,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,ye),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,x,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,xe,he,ye,ve,de,Ce]);return{value:F(d.value),valueAsNumber:d.valueAsNumber,isFocused:Fe,isDisabled:f,isReadOnly:o,getIncrementButtonProps:Re,getDecrementButtonProps:Ue,getInputProps:Oe,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[ft,le]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),dt=T(function(e,r){const a=Be("NumberInput",e),i=Ke(e),s=We(i),{htmlProps:u,...o}=lt(s),f=l.useMemo(()=>o,[o]);return v.jsx(ft,{value:f,children:v.jsx(ct,{value:a,children:v.jsx(Y.div,{...u,ref:r,className:Ve("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});dt.displayName="NumberInput";var pt=T(function(e,r){const a=J();return v.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});pt.displayName="NumberInputStepper";var mt=T(function(e,r){const{getInputProps:a}=le(),i=a(e,r),s=J();return v.jsx(Y.input,{...i,className:Ve("chakra-numberinput__field",e.className),__css:{width:"100%",...s.field}})});mt.displayName="NumberInputField";var De=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=T(function(e,r){var a;const i=J(),{getDecrementButtonProps:s}=le(),u=s(e,r);return v.jsx(De,{...u,__css:i.stepper,children:(a=e.children)!=null?a:v.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var gt=T(function(e,r){var a;const{getIncrementButtonProps:i}=le(),s=i(e,r),u=J();return v.jsx(De,{...s,__css:u.stepper,children:(a=e.children)!=null?a:v.jsx(nt,{})})});gt.displayName="NumberIncrementStepper";var At=Le("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const _t=(t,e)=>{const[r,a]=l.useState(t);return l.useEffect(()=>{const i=setTimeout(()=>{a(t)},e);return()=>{clearTimeout(i)}},[t,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function kt(t){const{searchValue:e,onUpdateSearchValue:r,style:a}=t,i=e!=="";return v.jsxs(qe,{style:{position:"relative",...a},mb:2,children:[v.jsx(Ye,{style:ht}),i&&v.jsx(ze,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:v.jsx(He,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),v.jsx(Xe,{placeholder:t.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:s})=>r(s.value)})]})}function Et(t){return new Promise((e,r)=>{const a=new FileReader;a.onload=i=>{const s=new Uint8Array(i.target.result),u=new DataView(s.buffer);u.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),r());let o=8;const f={};for(;oString.fromCharCode(S)).join("");f[x]=I}o+=12+c}e(f)},a.readAsArrayBuffer(t)})}function vt(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function r(u,o,f){const c=t.slice(u,u+f);if(f===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,o);if(f===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,o)}const a=r(4,e,4);function i(u){const o=r(u,e,2),f={};for(let c=0;c{const r=new FileReader;r.onload=a=>{var f;const i=new Uint8Array((f=a==null?void 0:a.target)==null?void 0:f.result),s=new DataView(i.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let u=12;const o={};for(;u{const r=new FileReader;r.onload=a=>{const i=new Uint8Array(a.target.result),s=new DataView(i.buffer),u=new TextDecoder;if(s.getUint32(0)==440786851){let o=12;for(;o>8*(4-m)&~(1<<7*m),x=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(x);e(h);return}}o+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let o=i.length-4;for(;o>16;){if(s.getUint32(o)==1684108385&&s.getUint32(o-8)==2841865588){s.getUint32(o+4),s.getUint32(o+8);const f=s.getUint32(o-4)-4*4,c=u.decode(i.slice(o+12,o+12+f)),m=JSON.parse(c);e(m);return}o-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},r.readAsArrayBuffer(t)})}function Dt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:i,objectFit:s,onBrokenLink:u}){const[o,f]=l.useState(!0);return l.useEffect(()=>{i&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).status==404){f(!1),u==null||u();return}}catch(m){console.error("Error checking media exists",m)}})()},[]),o?$e(t)?v.jsx(Je,{borderRadius:3,boxSize:`${e}px`,objectFit:s??"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):v.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:v.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:v.jsx("track",{kind:"captions"})})}):null}export{At as I,Dt as M,dt as N,kt as S,mt as a,Mt as b,Ze as c,Pt as d,pt as e,gt as f,Et as g,bt as h,Vt as i,It as p,St as r,_t as u,Ct as v}; +import{d as D,r as l,j as v,I as Ee,x as Te,y as je,m as ae,q as _,p as se,b as Pe,f as T,g as Y,k as Be,o as Ke,e as Ve}from"./input.js";import{ae as Ge,af as We,d as Le,B as qe,I as ze,y as He,j as Xe,ac as $e}from"./App-HFfBS8qf.js";import{I as Ye}from"./IconSearch-w32ReMy0.js";import{I as Je}from"./chunk-7D6N5TE5-Bj67hFEP.js";function Qe(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function ie(t,e){let r=Qe(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function ue(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Ct(t,e,r){return(t-e)*100/(r-e)}function It(t,e,r){return(r-e)*t+e}function St(t,e,r){const a=Math.round((t-e)/r)*r+e,i=ue(r);return ie(a,i)}function Ze(t,e,r){return t==null?t:(r{var g;return a==null?"":(g=oe(a,s,r))!=null?g:""}),x=typeof i<"u",h=x?i:m,I=Me(P(h),s),S=r??I,A=l.useCallback(g=>{g!==h&&(x||w(g.toString()),c==null||c(g.toString(),P(g)))},[c,x,h]),k=l.useCallback(g=>{let b=g;return f&&(b=Ze(b,u,o)),ie(b,S)},[S,f,o,u]),j=l.useCallback((g=s)=>{let b;h===""?b=P(g):b=P(h)+g,b=k(b),A(b)},[k,s,A,h]),B=l.useCallback((g=s)=>{let b;h===""?b=P(-g):b=P(h)-g,b=k(b),A(b)},[k,s,A,h]),K=l.useCallback(()=>{var g;let b;a==null?b="":b=(g=oe(a,s,r))!=null?g:u,A(b)},[a,r,s,A,u]),Q=l.useCallback(g=>{var b;const ee=(b=oe(g,s,S))!=null?b:u;A(ee)},[S,s,A,u]),V=P(h);return{isOutOfRange:V>o||Vv.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=t=>v.jsx(Ee,{viewBox:"0 0 24 24",...t,children:v.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function _e(t,e,r,a){l.useEffect(()=>{var i;if(!t.current||!a)return;const s=(i=t.current.ownerDocument.defaultView)!=null?i:window,u=Array.isArray(e)?e:[e],o=new s.MutationObserver(f=>{for(const c of f)c.type==="attributes"&&c.attributeName&&u.includes(c.attributeName)&&r(c)});return o.observe(t.current,{attributes:!0,attributeFilter:u}),()=>o.disconnect()})}function rt(t,e){const r=D(t);l.useEffect(()=>{let a=null;const i=()=>r();return e!==null&&(a=window.setInterval(i,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(t,e){const[r,a]=l.useState(!1),[i,s]=l.useState(null),[u,o]=l.useState(!0),f=l.useRef(null),c=()=>clearTimeout(f.current);rt(()=>{i==="increment"&&t(),i==="decrement"&&e()},r?at:null);const m=l.useCallback(()=>{u&&t(),f.current=setTimeout(()=>{o(!1),a(!0),s("increment")},ke)},[t,u]),w=l.useCallback(()=>{u&&e(),f.current=setTimeout(()=>{o(!1),a(!0),s("decrement")},ke)},[e,u]),x=l.useCallback(()=>{o(!0),a(!1),c()},[]);return l.useEffect(()=>()=>c(),[]),{up:m,down:w,stop:x,isSpinning:r}}var ot=/^[Ee0-9+\-.]$/;function ut(t){return ot.test(t)}function it(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function lt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:i=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER,step:u=1,isReadOnly:o,isDisabled:f,isRequired:c,isInvalid:m,pattern:w="[0-9]*(.[0-9]+)?",inputMode:x="decimal",allowMouseWheel:h,id:I,onChange:S,precision:A,name:k,"aria-describedby":j,"aria-label":B,"aria-labelledby":K,onFocus:Q,onBlur:V,onInvalid:ce,getAriaValueText:fe,isValidCharacter:Z,format:g,parse:b,...ee}=t,te=D(Q),de=D(V),R=D(ce),G=D(Z??ut),ne=D(fe),d=et(t),{update:U,increment:pe,decrement:me}=d,[Fe,re]=l.useState(!1),W=!(o||f),E=l.useRef(null),L=l.useRef(null),be=l.useRef(null),ge=l.useRef(null),q=l.useCallback(n=>n.split("").filter(G).join(""),[G]),z=l.useCallback(n=>{var p;return(p=b==null?void 0:b(n))!=null?p:n},[b]),F=l.useCallback(n=>{var p;return((p=g==null?void 0:g(n))!=null?p:n).toString()},[g]);Te(()=>{(d.valueAsNumber>s||d.valueAsNumber{if(!E.current)return;if(E.current.value!=d.value){const p=z(E.current.value);d.setValue(q(p))}},[z,q]);const H=l.useCallback((n=u)=>{W&&pe(n)},[pe,W,u]),X=l.useCallback((n=u)=>{W&&me(n)},[me,W,u]),N=st(H,X);_e(be,"disabled",N.stop,N.isSpinning),_e(ge,"disabled",N.stop,N.isSpinning);const he=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;const y=z(n.currentTarget.value);U(q(y)),L.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[U,q,z]),ve=l.useCallback(n=>{var p,y,C;te==null||te(n),L.current&&(n.target.selectionStart=(y=L.current.start)!=null?y:(p=n.currentTarget.value)==null?void 0:p.length,n.currentTarget.selectionEnd=(C=L.current.end)!=null?C:n.currentTarget.selectionStart)},[te]),ye=l.useCallback(n=>{if(n.nativeEvent.isComposing)return;it(n,G)||n.preventDefault();const p=we(n)*u,y=n.key,M={ArrowUp:()=>H(p),ArrowDown:()=>X(p),Home:()=>U(i),End:()=>U(s)}[y];M&&(n.preventDefault(),M(n))},[G,u,H,X,U,i,s]),we=n=>{let p=1;return(n.metaKey||n.ctrlKey)&&(p=.1),n.shiftKey&&(p=10),p},xe=l.useMemo(()=>{const n=ne==null?void 0:ne(d.value);if(n!=null)return n;const p=d.value.toString();return p||void 0},[d.value,ne]),Ne=l.useCallback(()=>{let n=d.value;if(d.value==="")return;/^[eE]/.test(d.value.toString())?d.setValue(""):(d.valueAsNumbers&&(n=s),d.cast(n))},[d,s,i]),Ce=l.useCallback(()=>{re(!1),r&&Ne()},[r,re,Ne]),$=l.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=E.current)==null||n.focus()})},[e]),Ie=l.useCallback(n=>{n.preventDefault(),N.up(),$()},[$,N]),Se=l.useCallback(n=>{n.preventDefault(),N.down(),$()},[$,N]);Ge(()=>E.current,"wheel",n=>{var p,y;const M=((y=(p=E.current)==null?void 0:p.ownerDocument)!=null?y:document).activeElement===E.current;if(!h||!M)return;n.preventDefault();const O=we(n)*u,Ae=Math.sign(n.deltaY);Ae===-1?H(O):Ae===1&&X(O)},{passive:!1});const Re=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMax;return{...n,ref:ae(p,be),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Ie(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMax,a,Ie,N.stop,f]),Ue=l.useCallback((n={},p=null)=>{const y=f||a&&d.isAtMin;return{...n,ref:ae(p,ge),role:"button",tabIndex:-1,onPointerDown:_(n.onPointerDown,C=>{C.button!==0||y||Se(C)}),onPointerLeave:_(n.onPointerLeave,N.stop),onPointerUp:_(n.onPointerUp,N.stop),disabled:y,"aria-disabled":se(y)}},[d.isAtMin,a,Se,N.stop,f]),Oe=l.useCallback((n={},p=null)=>{var y,C,M,O;return{name:k,inputMode:x,type:"text",pattern:w,"aria-labelledby":K,"aria-label":B,"aria-describedby":j,id:I,disabled:f,...n,readOnly:(y=n.readOnly)!=null?y:o,"aria-readonly":(C=n.readOnly)!=null?C:o,"aria-required":(M=n.required)!=null?M:c,required:(O=n.required)!=null?O:c,ref:ae(E,p),value:F(d.value),role:"spinbutton","aria-valuemin":i,"aria-valuemax":s,"aria-valuenow":Number.isNaN(d.valueAsNumber)?void 0:d.valueAsNumber,"aria-invalid":se(m??d.isOutOfRange),"aria-valuetext":xe,autoComplete:"off",autoCorrect:"off",onChange:_(n.onChange,he),onKeyDown:_(n.onKeyDown,ye),onFocus:_(n.onFocus,ve,()=>re(!0)),onBlur:_(n.onBlur,de,Ce)}},[k,x,w,K,B,F,j,I,f,c,o,m,d.value,d.valueAsNumber,d.isOutOfRange,i,s,xe,he,ye,ve,de,Ce]);return{value:F(d.value),valueAsNumber:d.valueAsNumber,isFocused:Fe,isDisabled:f,isReadOnly:o,getIncrementButtonProps:Re,getDecrementButtonProps:Ue,getInputProps:Oe,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[ft,le]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),dt=T(function(e,r){const a=Be("NumberInput",e),i=Ke(e),s=We(i),{htmlProps:u,...o}=lt(s),f=l.useMemo(()=>o,[o]);return v.jsx(ft,{value:f,children:v.jsx(ct,{value:a,children:v.jsx(Y.div,{...u,ref:r,className:Ve("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});dt.displayName="NumberInput";var pt=T(function(e,r){const a=J();return v.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});pt.displayName="NumberInputStepper";var mt=T(function(e,r){const{getInputProps:a}=le(),i=a(e,r),s=J();return v.jsx(Y.input,{...i,className:Ve("chakra-numberinput__field",e.className),__css:{width:"100%",...s.field}})});mt.displayName="NumberInputField";var De=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=T(function(e,r){var a;const i=J(),{getDecrementButtonProps:s}=le(),u=s(e,r);return v.jsx(De,{...u,__css:i.stepper,children:(a=e.children)!=null?a:v.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var gt=T(function(e,r){var a;const{getIncrementButtonProps:i}=le(),s=i(e,r),u=J();return v.jsx(De,{...s,__css:u.stepper,children:(a=e.children)!=null?a:v.jsx(nt,{})})});gt.displayName="NumberIncrementStepper";var At=Le("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const _t=(t,e)=>{const[r,a]=l.useState(t);return l.useEffect(()=>{const i=setTimeout(()=>{a(t)},e);return()=>{clearTimeout(i)}},[t,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function kt(t){const{searchValue:e,onUpdateSearchValue:r,style:a}=t,i=e!=="";return v.jsxs(qe,{style:{position:"relative",...a},mb:2,children:[v.jsx(Ye,{style:ht}),i&&v.jsx(ze,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:v.jsx(He,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),v.jsx(Xe,{placeholder:t.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:s})=>r(s.value)})]})}function Et(t){return new Promise((e,r)=>{const a=new FileReader;a.onload=i=>{const s=new Uint8Array(i.target.result),u=new DataView(s.buffer);u.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),r());let o=8;const f={};for(;oString.fromCharCode(S)).join("");f[x]=I}o+=12+c}e(f)},a.readAsArrayBuffer(t)})}function vt(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function r(u,o,f){const c=t.slice(u,u+f);if(f===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,o);if(f===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,o)}const a=r(4,e,4);function i(u){const o=r(u,e,2),f={};for(let c=0;c{const r=new FileReader;r.onload=a=>{var f;const i=new Uint8Array((f=a==null?void 0:a.target)==null?void 0:f.result),s=new DataView(i.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let u=12;const o={};for(;u{const r=new FileReader;r.onload=a=>{const i=new Uint8Array(a.target.result),s=new DataView(i.buffer),u=new TextDecoder;if(s.getUint32(0)==440786851){let o=12;for(;o>8*(4-m)&~(1<<7*m),x=u.decode(i.slice(o+2+m,o+2+m+w)),h=JSON.parse(x);e(h);return}}o+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let o=i.length-4;for(;o>16;){if(s.getUint32(o)==1684108385&&s.getUint32(o-8)==2841865588){s.getUint32(o+4),s.getUint32(o+8);const f=s.getUint32(o-4)-4*4,c=u.decode(i.slice(o+12,o+12+f)),m=JSON.parse(c);e(m);return}o-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},r.readAsArrayBuffer(t)})}function Dt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:i,objectFit:s,onBrokenLink:u}){const[o,f]=l.useState(!0);return l.useEffect(()=>{i&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).status==404){f(!1),u==null||u();return}}catch(m){console.error("Error checking media exists",m)}})()},[]),o?$e(t)?v.jsx(Je,{borderRadius:3,boxSize:`${e}px`,objectFit:s??"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):v.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:v.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:v.jsx("track",{kind:"captions"})})}):null}export{At as I,Dt as M,dt as N,kt as S,mt as a,Mt as b,Ze as c,Pt as d,pt as e,gt as f,Et as g,bt as h,Vt as i,It as p,St as r,_t as u,Ct as v}; diff --git a/dist/workspace_web/ModelManagerTopbar-azmEV7gi.js b/dist/workspace_web/ModelManagerTopbar-_rZ5F_Jv.js similarity index 94% rename from dist/workspace_web/ModelManagerTopbar-azmEV7gi.js rename to dist/workspace_web/ModelManagerTopbar-_rZ5F_Jv.js index a16e528..08cb7f0 100644 --- a/dist/workspace_web/ModelManagerTopbar-azmEV7gi.js +++ b/dist/workspace_web/ModelManagerTopbar-_rZ5F_Jv.js @@ -1 +1 @@ -import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as qe,k as Ye,h as A,a0 as ae,P as Qe,a1 as Je,N as be,a2 as Xe,Q as Ie,S as Le,T as Ze,Z as et,M as tt,O as st,R as nt}from"./input.js";import{aj as ot,m as it,ak as rt,al as at,am as P,B as oe,F as W,h as D,i as ie,X as Ee,an as lt,k as H,a3 as U,a4 as Ae,a5 as ct,ac as Ne,j as X,H as $,ao as De,ap as xe,g as q,w as dt,aq as Te,f as Fe,ar as ye,as as ht,at as Pe,au as ut,av as mt,aw as ft,ax as pt,ay as gt,az as xt,aA as ee,aB as yt,aC as wt}from"./App-rR1IBjvq.js";import{f as le,s as vt,g as jt}from"./civitUtils-7bf079LQ.js";import{I as Oe}from"./chunk-7D6N5TE5-QyxxCI30.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-J2YFxPIJ.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-yfOR3kNT.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...h})});Be.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Re(t){var e;const{bg:s,bgColor:o,backgroundColor:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Ct=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),kt=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function bt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[It,Lt]=Ve({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=V((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=bt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=qe(t),M=Ye("Progress",t),k=d??((s=M.track)==null?void 0:s.borderRadius),b={animation:`${kt} 1s linear infinite`},T={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Ct} 1s ease infinite normal none running`}},C={overflow:"hidden",position:"relative",...M.track};return n.jsx(B.div,{ref:e,borderRadius:k,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:k,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ge(t){let e=null,s=null,o=null,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function je(t){return K(t)?t:t.split(".")}function Me(t){return K(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ue(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(k[w+1]|k[w])<<1|1|k[w+1]),y[w]&Y&&(b=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;k=y}const T={isMatch:p>=0,score:Math.max(.001,b)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:k,indices:b}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=k,M&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function $t(t,e){e.score=t.score}class G{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(h?1:p))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&g.push(Wt),u&&g.push($t),d.map(p=>{const{idx:x}=p,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(p,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const m=await le(t.file_hash),u=m.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Ht({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Be,{children:n.jsx(Ut,{data:e})},e.model_name+e.date.getTime()))})}function Vt(){const{setRoute:t}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const qt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Yt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{isChecked:t,onChange:o,children:"Show NSFW"})}function Qt(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=qt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(k=>k.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(k=>k.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Yt,{})]}),!o.length&&n.jsx(Kt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Ht,{list:u}),c&&n.jsx(W,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Qt,{})]})})}const Xt=async t=>{try{const s=await(await ce.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function Ce(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function ke(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,r,i,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=ke(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=ke((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(A,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Je,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(be,{children:n.jsxs(Xe,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Le,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Ze,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(mt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&Y(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=b.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=b.current)==null?void 0:fe.id}`,_=(pe=b.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=b.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),k(void 0),j()},z=async(y,w)=>{const S=T[w.type];k(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(tt,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(st,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs($,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs($,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),yt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,b.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:wt+"px",children:"Models"}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}export{fs as default}; +import{f as V,r as f,j as n,g as B,e as re,$ as J,b as Ve,o as Ye,k as qe,h as A,a0 as ae,P as Qe,a1 as Je,N as be,a2 as Xe,Q as Ie,S as Le,T as Ze,Z as et,M as tt,O as st,R as nt}from"./input.js";import{ak as ot,m as it,al as rt,am as at,an as P,B as oe,F as W,h as D,i as ie,Y as Ee,ao as lt,k as H,a4 as U,a5 as Ae,a6 as ct,ad as Ne,j as X,H as $,ap as De,aq as xe,g as Y,w as dt,ar as Te,f as Fe,as as ye,at as ht,au as Pe,av as ut,aw as mt,ax as ft,ay as pt,az as gt,aA as xt,aB as ee,aC as yt,aD as wt}from"./App-HFfBS8qf.js";import{f as le,s as vt,g as jt}from"./civitUtils-Ao2r5rP5.js";import{I as Oe}from"./chunk-7D6N5TE5-Bj67hFEP.js";import{G as Mt,C as St}from"./chunk-JARCRF6W-OdkdCK_9.js";import{api as ce}from"/scripts/api.js";import{S as Z}from"./chunk-3RSXBRAN-Ge4h6OPg.js";var ze=V(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:m,...u}=e,g=f.useMemo(()=>m?f.Children.map(a,(p,x)=>n.jsx(de,{children:p},x)):a,[a,m]);return n.jsx(B.div,{ref:s,className:re("chakra-wrap",h),...u,children:n.jsx(B.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});ze.displayName="Wrap";var de=V(function(e,s){const{className:o,...r}=e;return n.jsx(B.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:re("chakra-wrap__listitem",o),...r})});de.displayName="WrapItem";function we(t){return it(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Be=V(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,m=ot({gridArea:o,gridColumn:we(r),gridRow:we(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx(B.div,{ref:s,__css:m,...h})});Be.displayName="GridItem";var te=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Re(t){var e;const{bg:s,bgColor:o,backgroundColor:r,shadow:i,boxShadow:a,shadowColor:c}=t,{getArrowProps:l,getArrowInnerProps:d}=rt(),h=at(),m=(e=s??o)!=null?e:r,u=i??a;return n.jsx(B.div,{...l(),className:"chakra-popover__arrow-positioner",children:n.jsx(B.div,{className:re("chakra-popover__arrow",t.className),...d(t),__css:{"--popper-arrow-shadow-color":te("colors",c),"--popper-arrow-bg":te("colors",m),"--popper-arrow-shadow":te("shadows",u),...h.arrow}})})}Re.displayName="PopoverArrow";function _t(t,e,s){return(t-e)*100/(s-e)}J({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});J({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Ct=J({"0%":{left:"-40%"},"100%":{left:"100%"}}),kt=J({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function bt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=_t(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[It,Lt]=Ve({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Et=V((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=bt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Lt().filledTrack};return n.jsx(B.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),We=V((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ye(t),M=qe("Progress",t),k=d??((s=M.track)==null?void 0:s.borderRadius),b={animation:`${kt} 1s linear infinite`},T={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Ct} 1s ease infinite normal none running`}},C={overflow:"hidden",position:"relative",...M.track};return n.jsx(B.div,{ref:e,borderRadius:k,__css:C,...j,children:n.jsxs(It,{value:M,children:[n.jsx(Et,{"aria-label":m,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:T,borderRadius:k,title:p,role:x}),l]})})});We.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Ke(t)==="[object Array]"}const At=1/0;function Nt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-At?"-0":s}(t)}function F(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function Dt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Ke(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Ke(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tt=t=>`Missing ${t} property in key`,Ft=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class Pt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Ge(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ge(t){let e=null,s=null,o=null,r=1,i=null;if(F(t)||K(t))o=t,e=je(t),s=Me(t);else{if(!ve.call(t,"name"))throw new Error(Tt("name"));const a=t.name;if(o=a,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(Ft(a));e=je(a),s=Me(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function je(t){return K(t)?t:t.split(".")}function Me(t){return K(t)?t.join("."):t}var v={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(F(l)||$e(l)||Dt(l)))s.push(Nt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(F(h)&&!se(h)){let m={v:h,i:d,n:this.norm.get(h)};c.push(m)}else K(h)&&h.forEach((m,u)=>{l.push({nestedArrIndex:u,value:m})})}o.$[i]=c}else if(F(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ue(t,e,{getFn:s=v.getFn,fieldNormWeight:o=v.fieldNormWeight}={}){const r=new he({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Ge)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=v.distance,ignoreLocation:i=v.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function zt(t,e,s,{location:o=v.location,distance:r=v.distance,threshold:i=v.threshold,findAllMatches:a=v.findAllMatches,minMatchCharLength:c=v.minMatchCharLength,includeMatches:l=v.includeMatches,ignoreLocation:d=v.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,m=t.length,u=Math.max(0,Math.min(o,m));let g=i,p=u;const x=c>1||l,j=x?Array(m):[];let M;for(;(M=t.indexOf(e,p))>-1;){let C=Q(e,{currentLocation:M,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(C,g),p=M+h,x){let I=0;for(;I=z;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(j[S]=+!!_),y[w]=(y[w+1]<<1|1)&_,C&&(y[w]|=(k[w+1]|k[w])<<1|1|k[w+1]),y[w]&q&&(b=Q(e,{errors:C,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;z=Math.max(1,2*u-p)}}if(Q(e,{errors:C+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;k=y}const T={isMatch:p>=0,score:Math.max(.001,b)};if(x){const C=function(I=[],L=v.minMatchCharLength){let z=[],E=-1,y=-1,w=0;for(let S=I.length;w=L&&z.push([E,y]),E=-1)}return I[w-1]&&w-E>=L&&z.push([E,w-1]),z}(j,c);C.length?l&&(T.indices=C):T.isMatch=!1}return T}function Bt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Bt(u),startIndex:g})},m=this.pattern.length;if(m>R){let u=0;const g=m%R,p=m-g;for(;u{const{isMatch:M,score:k,indices:b}=zt(e,p,x,{location:r+j,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});M&&(u=!0),m+=k,M&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?m/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const Se=[];function _e(t,e){for(let s=0,o=Se.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function $t(t,e){e.score=t.score}class G{constructor(e,s={},o){if(this.options={...v,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Pt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof he))throw new Error("Incorrect 'index' type");this._myIndex=s||Ue(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;m.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(h?1:p))}),m.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),$e(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:m=v.includeMatches,includeScore:u=v.includeScore}={}){const g=[];return m&&g.push(Wt),u&&g.push($t),d.map(p=>{const{idx:x}=p,j={item:h[x],refIndex:x};return g.length&&g.forEach(M=>{M(p,j)}),j})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=_e(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=_e(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}G.version="7.0.0",G.createIndex=Ue,G.parseIndex=function(t,{getFn:e=v.getFn,fieldNormWeight:s=v.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new he({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},G.config=v;function Kt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(ze,{children:s.map(r=>n.jsx(de,{children:n.jsx(A,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Gt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Ut({data:t}){const[e,s]=f.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=f.useState(!t.file_hash),[i,a]=f.useState();f.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),!(d!=null&&d.imageUrl)&&t.file_hash!=null)try{const m=await le(t.file_hash),u=m.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:m.modelName??null,civitModelID:m.civitModelID,civitModelVersionID:m.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Gt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(W,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(ae,{})}):n.jsx(Oe,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Ht({list:t}){return n.jsx(Mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Be,{children:n.jsx(Ut,{data:e})},e.model_name+e.date.getTime()))})}function Vt(){const{setRoute:t}=f.useContext(Ee);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const Yt=()=>{const[t,e]=f.useState(["checkpoints"]),[s,o]=f.useState([]),[r,i]=f.useState(!0);f.useEffect(()=>{a(),ce.addEventListener("model_list",async l=>{c(l.detail)})},[]);const a=async()=>{const l=await lt();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(m=>m.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(m=>({...m,date:new Date(m.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function qt(){const[t,e]=f.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(c=>{e(c??!1)})};f.useEffect(()=>{s()},[]);const o=a=>{var l;const c=a.target.checked;(l=H)==null||l.upsert({showNsfwModelThumbnail:c}).then(()=>{s(),r(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},r=async()=>{const a=await P.models.toArray();for(let c=0;c{try{if(a.fileHash==null)return;const l=(await le(a.fileHash)).imageUrl;P.models.update(a.id,{imageUrl:l??null})}catch{}};return n.jsx(St,{isChecked:t,onChange:o,children:"Show NSFW"})}function Qt(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),U.graph.add(i)};return f.useEffect(()=>(U.canvasEl.addEventListener("drop",t),()=>{U.canvasEl.removeEventListener("drop",t)}),[]),null}function Jt({onClose:t}){const[e,s]=f.useState("checkpoints"),[o,r]=f.useState(""),[i,a]=f.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=Yt(),[h,m]=f.useState([]),[u,g]=f.useState([]);f.useEffect(()=>{x();async function x(){const j=await P.models.toArray();m(d.map(M=>({...M,db:j.find(k=>k.id===M.model_name+"@"+M.model_type)})))}},[d]),f.useEffect(()=>{let x=[];o.length?x=new G(h,{keys:["model_name","db.modelName"]}).search(o).map(k=>k.item):x=d.filter(j=>j.model_type===e).sort((j,M)=>i==="name"?j.model_name.localeCompare(M.model_name):M.date.getTime()-j.date.getTime()),g(x)},[e,d,o,i,h]),f.useEffect(()=>(U.canvasEl.addEventListener("click",t),()=>{U.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Qe,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ae,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ct,overflowY:"auto",children:[n.jsxs(W,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Vt,{})]}),n.jsx(W,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(X,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(W,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs($,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(Z,{value:i,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(qt,{})]}),!o.length&&n.jsx(Kt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Ht,{list:u}),c&&n.jsx(W,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(ae,{})})]}),n.jsx(Qt,{})]})})}const Xt=async t=>{try{const s=await(await ce.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function Ce(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function ke(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None"||o.nsfwLevel===1);return e&&(s=s??t[0]),s}function Zt(t,e=280,s){var o,r,i,a;if(t){if(t.images)return`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(o=ke(t.images,s))==null?void 0:o.url}/width=${e}/`;if(De(t))return(a=ke((i=(r=t.modelVersions)==null?void 0:r.at(0))==null?void 0:i.images,s))==null?void 0:a.url}}const ne=280;function es({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=f.useState();f.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));r(Zt(t,ne,x))}},[t]);const i=De(t)?t.modelVersions:t.versions,[a,c]=f.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=f.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(xe(l,t.name),t)},[a]),m=(g=xe(l))==null?void 0:g.sizeKB;return n.jsxs(Ae,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Oe,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(W,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(A,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(dt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs($,{children:[n.jsx(Z,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),m&&n.jsx(ie,{label:Ce(m),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:Ce(m)})})]})]})]})}function ts({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(W,{gap:1,alignItems:"center",grow:1,children:[n.jsx(X,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function ss({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=f.useState(""),[a,c]=f.useState([]),[l,d]=f.useState(""),h=f.useRef(null);f.useEffect(()=>{m()},[]);const m=async()=>{const u=await Te();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(Je,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(be,{children:n.jsxs(Xe,{children:[n.jsx(Ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Le,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(X,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(Z,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Ze,{children:[n.jsx(A,{ref:h,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function ns(){const{colorMode:t}=et(),e=Fe(),[s,o]=f.useState([]);return f.useEffect(()=>{ye.addEventListener("download_progress",r=>{o(r.detail)}),ye.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:r,progress:i})=>n.jsxs($,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(We,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>ht(r),children:"Cancel"})]},r))})}function os(){const[t,e]=f.useState(""),{onOpen:s,onClose:o,isOpen:r}=Pe(),i=()=>{vt(t),o()};return n.jsxs(ut,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(mt,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(ft,{p:5,children:[n.jsx(Re,{}),n.jsx(pt,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(D,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(X,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function is(t,e){var l;const s={limit:"30",types:t};e&&(s.query=e);const r=`https://civitai.com/api/v1/models?${new URLSearchParams(s).toString()}`,i=await((l=P.cache)==null?void 0:l.get(r));if((i==null?void 0:i.value)!=null)try{const{data:d,timestamp:h}=JSON.parse(i==null?void 0:i.value);if((Date.now()-h)/(1e3*60*60*24){var _;a(!0);const y=await is(c,u);r(y);const w=await Te();w&&q(w);const S=await((_=H)==null?void 0:_.getSetting("defaultFolders"));S&&C(S),a(!1)},[u,c]),L=(y,w)=>{var me,fe,pe,ge;if(!((me=b.current)!=null&&me.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(fe=b.current)==null?void 0:fe.id}`,_=(pe=b.current)==null?void 0:pe.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&m(He=>[...He,_??""]);const ue=jt();ue&&(S+=`?token=${ue}`),Xt({file_hash:(ge=b.current)==null?void 0:ge.SHA256,filename:_,save_path:y,url:S}),k(void 0),j()},z=async(y,w)=>{const S=T[w.type];k(y),S==null?x():L(S)},E=async(y,w)=>{var _;const S={...T,[y]:w};await((_=H)==null?void 0:_.upsert({defaultFolders:S})),C(S)};return f.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(tt,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(st,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ie,{pb:1,children:[n.jsxs($,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(ts,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(os,{})]}),n.jsxs($,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),yt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:c===y,onClick:()=>{l(y)},children:y},y)),c&&O[ee[c]]&&n.jsxs($,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(Z,{value:T[c],onChange:y=>E(c,y.target.value),children:O[ee[c]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),i&&n.jsx(ae,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(nt,{}),n.jsxs(Le,{overflowY:"auto",children:[n.jsx($,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(es,{model:y,onClickInstallModel:z,installing:h},y.id))}),n.jsx(ns,{})]})]})]}),n.jsx(ss,{fileSelected:!!M,isOpen:p,onClose:j,selectFolder:(y,w)=>{L(y,b.current?void 0:w)}})]})}function fs(){const{setRoute:t,route:e}=f.useContext(Ee);return f.useEffect(()=>{ce.addEventListener("model_list",async s=>{var i;const o=(i=s.detail)==null?void 0:i.map(async a=>{const c=await P.models.get(a.model_name+"@"+a.model_type);if(c!=null&&c.fileHash)return c;let l={id:a.model_name+"@"+a.model_type,modelName:null,fileHash:a.file_hash??null,fileFolder:a.model_type,fileName:a.model_name+a.model_extension};if(!a.file_hash)return l;const d=await le(a.file_hash);return l={...l,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},l}),r=(await Promise.all(o)).filter(a=>a!=null);await P.models.clear(),await P.models.bulkPut(r.filter(a=>a!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))})},[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(A,{size:"sm",backgroundColor:"#434554",color:"white",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,height:wt+"px",children:"Models"}),e==="modelList"&&n.jsx(Jt,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(rs,{modelType:"Checkpoint",onclose:()=>t("root")})]})}export{fs as default}; diff --git a/dist/workspace_web/RecentFilesDrawer-BJDDVyUO.js b/dist/workspace_web/RecentFilesDrawer-BJDDVyUO.js deleted file mode 100644 index 074a907..0000000 --- a/dist/workspace_web/RecentFilesDrawer-BJDDVyUO.js +++ /dev/null @@ -1,5 +0,0 @@ -import{f as Q,E as qe,j as e,Y as Je,e as ie,g as we,r as i,M as re,N as le,O as ce,Q as de,R as ue,S as he,V as ve,h as A,Z as ke,T as Qe}from"./input.js";import{m as Le,u as We,a as et,b as tt,c as st,S as nt,M as at,d as W,H as z,T as Ae,I as P,t as je,e as Ne,f as Y,E as me,g as B,h as L,i as R,j as pe,k as C,R as G,l as ot,n as Me,B as _,F as Z,o as Fe,p as it,q as rt,r as ee,s as te,v as N,w as lt,D as Pe,x as T,y as Re,z as ct,A as Se,C as dt,G as _e,J as K,K as ut,L as ht,N as pt,O as Be,P as gt,Q as mt,U as ft,V as U,W as ye,X as Ce,Y as xt,Z as jt,_ as $e,$ as yt,a0 as wt,a1 as vt,a2 as J,a3 as oe,a4 as kt,a5 as St,a6 as Ct,a7 as fe,a8 as bt}from"./App-rR1IBjvq.js";import{G as It,C as q}from"./chunk-JARCRF6W-J2YFxPIJ.js";import{V as He}from"./chunk-NTCQBYKE-PRXQGfLv.js";import{N as Mt,a as Ft,g as Dt,I as Et,M as Tt,u as Ot,S as zt}from"./MediaPreview-QD6yX7R-.js";import{I as Lt}from"./IconCopy-KNYgQ4PQ.js";import"./chunk-7D6N5TE5-QyxxCI30.js";import"./IconSearch-6vngoIPw.js";var Ke=Q(function(t,r){const{columns:l,spacingX:o,spacingY:s,spacing:d,minChildWidth:p,...n}=t,h=qe(),u=p?At(p,h):Nt(l);return e.jsx(It,{ref:r,gap:d,columnGap:o,rowGap:s,templateColumns:u,...n})});Ke.displayName="SimpleGrid";function Wt(a){return typeof a=="number"?`${a}px`:a}function At(a,t){return Le(a,r=>{const l=Je("sizes",r,Wt(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function Nt(a){return Le(a,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ge=Q((a,t)=>{const{title:r,children:l,className:o,...s}=a,d=ie("chakra-menu__group__title",o),p=We();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(we.p,{className:d,...s,__css:p.groupTitle,children:r}),l]})});Ge.displayName="MenuGroup";var Ve=a=>{const{className:t,title:r,...l}=a,o=et(l);return e.jsx(Ge,{title:r,className:ie("chakra-menu__option-group",t),...o})};Ve.displayName="MenuOptionGroup";var Pt=Q((a,t)=>{const r=We();return e.jsx(we.button,{ref:t,...a,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),se=Q((a,t)=>{const{children:r,as:l,...o}=a,s=tt(o,t),d=l||Pt;return e.jsx(d,{...s,className:ie("chakra-menu__menu-button",a.className),children:e.jsx(we.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:a.children})})});se.displayName="MenuButton";var Rt=a=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...a,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=Q((a,t)=>{const{icon:r,iconSpacing:l="0.75rem",...o}=a,s=st(o,t);return e.jsxs(nt,{...s,className:ie("chakra-menu__menuitem-option",o.className),children:[r!==null&&e.jsx(at,{fontSize:"0.8em",marginEnd:l,opacity:a.isChecked?1:0,children:r||e.jsx(Rt,{})}),e.jsx("span",{style:{flex:1},children:s.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var _t=W("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Bt=W("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),$t=W("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),De=W("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Ht=W("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),Ue=W("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Kt=W("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Gt=W("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Vt=W("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Ut=W("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Zt=W("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),Yt=W("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),Xt=W("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),qt=W("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Jt=W("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function Qt({onclose:a}){const[t,r]=i.useState([]),l=async()=>{var s;const o=await((s=je)==null?void 0:s.listAll());r(o??[])};return i.useEffect(()=>{l()},[]),e.jsxs(re,{isOpen:!0,onClose:a,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"My Tags"}),e.jsx(ue,{}),e.jsx(he,{children:t.map(o=>e.jsxs(z,{children:[e.jsx(Ae,{children:o.name}),e.jsx(P,{onClick:async()=>{var s;await((s=je)==null?void 0:s.delete(o.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Ne,{})})]}))})]})]})}function es(){const a=Y(),t=i.useRef([{title:"Save current workflow",key:me.SAVE},{title:"Save as current workflow",key:me.SAVE_AS},{title:"Open spotlight search",key:me.openSpotlightSearch}]),[r,l]=i.useState({save:"",saveAs:"",openSpotlightSearch:""}),[o,s]=i.useState(),d=async(n,h)=>{var g;n.preventDefault();let u="";if(n.ctrlKey&&(u+="Control+"),n.metaKey&&(u+="Command+"),n.shiftKey&&(u+="Shift+"),n.altKey&&(u+="Alt+"),u.length>0&&!["Control","Shift","Alt","Meta"].includes(n.key)){u+=n.key.toUpperCase();const m={...r};delete m[h],Object.values(m).includes(u)?a({title:"Shortcut key conflict",description:`The shortcut key 「${u}」 is already used, please - modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...r,[h]:u}})),p())}},p=()=>{var n;(n=C)==null||n.getSetting("shortcuts").then(h=>{var g;const u=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...r,...u})})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(n=>e.jsxs(z,{children:[e.jsx(L,{fontSize:"sm",w:170,children:n.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:o===n.key,children:e.jsx(pe,{value:r[n.key],onKeyDown:h=>{d(h,n.key)},onFocus:()=>{s(n.key)},onBlur:()=>{s(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},n.key))]})}function ts(){const{setRefreshFolderStamp:a}=i.useContext(G),[t,r]=i.useState(!1),l=()=>{var s;(s=C)==null||s.getSetting("foldersOnTop").then(d=>{r(!!d)})},o=s=>{var p;const d=s.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),a(Date.now())})};return i.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:t,onChange:o,children:"Folders always on top"})})}function ss(){const[a,t]=i.useState(!1),[r,l]=i.useState(""),{showDialog:o}=ve(),s=()=>{var p,n;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(n=C)==null||n.getSetting("twoWaySync").then(h=>{t(h??!1)})};i.useEffect(()=>{s()},[]);const d=async p=>{var h,u;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),s();return}const n=await((u=C)==null?void 0:u.getSetting("myWorkflowsDir"));o(e.jsx(ot,{myWorkflowsDir:n??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),s()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(L,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(q,{isChecked:a,onChange:d,children:"Enable two way sync"})]})}function Ee({settingKey:a,text:t,defaultChecked:r=!1}){const[l,o]=i.useState(r),s=Y(),d=()=>{var p;(p=C)==null||p.getSetting(a).then(n=>{o(!!n)})};return i.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:l,onChange:async p=>{var n;await((n=C)==null?void 0:n.upsert({[a]:p.target.checked})),d(),s({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function ns(){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),[o,s]=i.useState([]),[d,p]=i.useState(""),[n,h]=i.useState([]),[u,g]=i.useState(!1),[m,c]=i.useState(!1),[f,v]=i.useState(!1),S=i.useRef(null),w=Y();ve();const b=f?"\\":"/";i.useEffect(()=>{var j;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(j=C)==null||j.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async j=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Fe(j??"");return V.includes("Operation not permitted")?(c(!0),O(),{isError:!0}):{dirList:E,dirPath:k}},y=async()=>{const{isError:j=!1,dirList:k=[]}=await F(d);j||(s(k),l(!0),h(d&&d.split(b).filter(E=>!!E)||[]))},O=()=>{l(!1),t(!1),h([])},$=async(j,k=!1,E=!1)=>{var x,I;if(k){const{path:M}=await Me();M&&await it(M,j)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:j}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&c(!1),O()},H=async j=>{if(j){const{error:E=""}=await Fe(j);if(E.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=j??`${f?"":b}${n.join(b)}`;$(k,!1,!!j)},X=async()=>{const{dirPath:j,dirList:k}=await F("");h(j.split(b).filter(E=>!!E)),s(k)},ne=async(j,k)=>{var I;let E="";j===-1&&k?E=`${f?"":b}${n.concat([k]).join(b)}`:E=`${f?"":b}${n.slice(0,j+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(s(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},ae=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(pe,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(A,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var j,k;(j=S==null?void 0:S.current)!=null&&j.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ge=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?a?ae:e.jsxs(He,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:n.map((j,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(A,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ne(k)},children:j},`${j}-${k}`)]},j))}),e.jsx(Ke,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:o.map((j,k)=>e.jsx(A,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{ne(-1,j)},children:j},`${j}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(A,{colorScheme:"teal",size:"sm",onClick:()=>{H()},children:"Save"}),e.jsx(A,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(A,{size:"sm",onClick:O,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(Ae,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:u?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(P,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!u,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:y})}),e.jsx(R,{label:u?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(P,{isDisabled:!u,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx($t,{size:19}),onClick:ge,variant:"ghost"})})]})]}),e.jsxs(re,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Kind tips"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(_,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(L,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(A,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos - -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(L,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ae]})})]})]})]})}function Ze({label:a,settingKey:t}){const[r,l]=i.useState(200),o=Y(),s=n=>{if(!n.length){l(0);return}l(parseInt(n))},d=async()=>{var n;r<0&&l(0),await((n=C)==null?void 0:n.upsert({[t]:Number(r)})),o({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var n;(n=C)==null||n.getSetting(t).then(h=>{l(h)})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:a}),e.jsx(Mt,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:n=>s(n),onBlur:()=>{d()},onKeyUp:n=>{n.key==="Enter"&&d()},children:e.jsx(Ft,{})})]})}function as(){const[a,t]=i.useState(!1),r=Y(),l=()=>{var o;(o=C)==null||o.getSetting("autoSave").then(s=>{t(!!s)})};return i.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(q,{isChecked:a,onChange:async o=>{var s;await((s=C)==null?void 0:s.upsert({autoSave:o.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),a&&e.jsx(Ze,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function os(){const a=Y(),[t,r]=i.useState(""),l=()=>{var s;(s=C)==null||s.getSetting("cloudHost").then(d=>{r(d??"")})};i.useEffect(()=>{l()},[]);const o=async s=>{var d;s=s.trim(),s.endsWith("/")&&(s=s.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:s})),l(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(L,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(Z,{gap:2,alignItems:"center",children:[e.jsx(pe,{value:t,onChange:s=>r(s.target.value),onBlur:()=>o(t)}),e.jsx(A,{size:"sm",onClick:()=>{var d;const s=(d=C)==null?void 0:d.defaultSettings.cloudHost;r(s),o(s)},children:"Reset"})]})]})}function is({onClose:a}){return e.jsx(e.Fragment,{children:e.jsxs(re,{isOpen:!0,onClose:a,size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Settings"}),e.jsx(ue,{}),e.jsx(he,{pb:14,children:e.jsx(z,{children:e.jsxs(He,{divider:e.jsx(rt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(ns,{}),e.jsx(as,{}),e.jsx(es,{}),e.jsx(ss,{}),e.jsx(ts,{}),e.jsx(Ee,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ze,{label:`Maximum number of save change history to store. This does not include - versions that you created by "Create Version", which are always stored - and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Ee,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(os,{})]})})})]})]})})}const xe=16;function rs({}){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),{colorMode:o,toggleColorMode:s}=ke();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(se,{as:P,"aria-label":"Options",icon:e.jsx(Vt,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(N,{onClick:()=>l(!0),icon:e.jsx(Yt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(N,{onClick:()=>t(!0),icon:e.jsx(qt,{size:xe}),fontSize:16,children:"Manage Tags"}),e.jsxs(N,{onClick:s,icon:o==="light"?e.jsx(Ut,{size:xe}):e.jsx(Xt,{size:xe}),fontSize:16,children:[o==="light"?"Dark":"Light"," Mode"]})]})]}),a&&e.jsx(Qt,{onclose:()=>t(!1)}),r&&e.jsx(is,{onClose:()=>l(!1)})]})}function ls(a){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:o,batchOperationCallback:s}=a,d=async()=>{var h;const n=await((h=T)==null?void 0:h.batchQuery(l))??[];ct(n)},p=l.length===0;return e.jsx(z,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(q,{isChecked:o,onChange:n=>{s("selectAll",n.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(P,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(lt,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Pe,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var n;await((n=T)==null?void 0:n.batchDeleteFlow(l)),s("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(P,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{r(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(P,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Kt,{size:21}),onClick:()=>{r(!0)}})})})}const Te=6;function cs({setSelectedTag:a,selectedTag:t}){const[r,l]=i.useState(!1),[o,s]=i.useState([]);return i.useEffect(()=>{var d;(d=je)==null||d.listAll().then(p=>{s(p)})},[]),e.jsxs(z,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(P,{"aria-label":"Close",size:"sm",icon:e.jsx(Re,{}),onClick:()=>{a(void 0)}}),o.slice(0,r?void 0:Te).map(d=>e.jsx(A,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{a(d.name)},isActive:t===d.name,children:d.name},d.name)),(o.length??0)>Te&&e.jsx(P,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(_t,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Ye({parentFolderID:a,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=i.useContext(G),[l,o]=i.useState("file"),s=i.useRef(null),d=u=>{var g;o(u),u==="folder"?s.current.setAttribute("webkitdirectory",""):s.current.removeAttribute("webkitdirectory"),(g=s.current)==null||g.click()},p=async u=>{var g;if(u.type==="image/png"){const m=await Dt(u),c=m==null?void 0:m.workflow;if(c)return{json:c,name:u.name.replace(".png","")}}else if(u.type==="application/json"||(g=u.name)!=null&&g.endsWith(".json"))return await new Promise((m,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?m({json:w,name:u.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(u)});return null},n=async u=>{var m,c;const g=[u];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=K)==null?void 0:m.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,g.push(w))}),S.length&&await((c=T)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async u=>{var m;const g=u.target.files;if(g)if(l==="folder"){const c={name:g[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of g)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wy.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const y=await p(f);y&&(F.file=y)}S.push(F)}F&&!F.isFile&&(S=F.children)}}n(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=T)==null?void 0:m.batchCreateFlows(c,void 0,a)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(N,{onClick:u=>{u.stopPropagation(),d("file")},icon:e.jsx(De,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:A,leftIcon:e.jsx(De,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:dt.map((u,g)=>e.jsx(N,{onClick:()=>{d(u.type)},iconSpacing:2,icon:u.type==="folder"?e.jsx(_e,{size:18}):e.jsx(Ht,{size:18}),children:u.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:s,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:u=>{u.stopPropagation()}})]})}function ds({folder:a,onclose:t}){const[r,l]=i.useState(a.name),[o,s]=i.useState(""),{onRefreshFilesList:d}=i.useContext(G),p=h=>{l(h.target.value),o&&s("")},n=async()=>{var g,m;const h=r.trim();if(l(h),h===a.name)return t();await((g=K)==null?void 0:g.generateUniqueName(h,a.parentFolderID??""))!==h?s("The name is duplicated, please modify it and submit again."):(await((m=K)==null?void 0:m.update(a.id,{name:h})),d&&d(),t())};return e.jsxs(re,{isOpen:!0,onClose:t,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Edit folder name"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(ut,{isInvalid:!!o,children:[e.jsx(ht,{children:"Folder name"}),e.jsx(pe,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!o&&r&&n()}}),o&&e.jsx(pt,{children:o})]})}),e.jsxs(Qe,{children:[e.jsx(A,{colorScheme:"teal",mr:3,onClick:n,isDisabled:!r||!!o,children:"Save"}),e.jsx(A,{onClick:t,children:"Cancel"})]})]})]})}function us({menuPosition:a,isopen:t,folder:r,onClose:l}){const[o,s]=i.useState(!1),{onRefreshFilesList:d}=i.useContext(G),{showDialog:p}=ve(),n=async m=>{var c;m.stopPropagation(),await((c=K)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),d&&d()},h=async m=>{var c;m.stopPropagation(),await((c=T)==null?void 0:c.createFlow({json:JSON.stringify(gt),parentFolderID:r.id})),d&&d()},u=async m=>{m.stopPropagation();const c=await mt(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(ft.DELETE)}}])},g=async m=>{var c;await((c=K)==null?void 0:c.deleteFolder(r.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:a.y,left:a.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(N,{icon:e.jsx(Zt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),s(!0)},children:"Rename"}),e.jsx(N,{icon:e.jsx(Ne,{size:19}),onClick:u,children:"Delete"}),e.jsx(N,{onClick:n,icon:e.jsx(Ue,{size:19}),children:"New folder"}),e.jsx(N,{onClick:h,icon:e.jsx(Be,{size:19}),children:"New file"}),e.jsx(Ye,{parentFolderID:r.id,onlyImportFile:!0})]})})}),o&&e.jsx(ds,{folder:r,onclose:()=>s(!1)})]})}const Oe=i.memo(function({folder:t}){const[r,l]=i.useState(!1),[o,s]=i.useState(t.isCollapse??!0),[d,p]=i.useState([]),[n,h]=i.useState({x:0,y:0}),[u,g]=i.useState(!1),{colorMode:m}=ke(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=i.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};i.useEffect(()=>{var y;o||(y=T)==null||y.listFolderContent(t.id,window.localStorage.getItem(ye)).then(O=>{p(O)})},[t.id,v,o]);const b=y=>{y.preventDefault(),h({x:y.clientX,y:y.clientY}),g(!0)},F=async y=>{var O,$;if(y.preventDefault(),y.stopPropagation(),!c)return l(!1);if(U(c)){if(c.id===t.id)return l(!1);await((O=K)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else U(c)||await(($=T)==null?void 0:$.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return i.useEffect(()=>{var y;!!t.isCollapse!==o&&((y=K)==null||y.update(t.id,{isCollapse:o}))},[o]),i.useEffect(()=>{var X;const y=(X=T)==null?void 0:X.curWorkflow,O=(y==null?void 0:y.parentFolderID)+"/",$=t.id+"/";O.startsWith($)&&s(!1)},[]),e.jsxs(B,{children:[e.jsxs(z,{w:"100%",as:"button",py:1,onClick:()=>{s(!o)},onContextMenu:b,draggable:"true",onDragOver:y=>{y.preventDefault(),y.stopPropagation(),l(!0)},onDragLeave:y=>{y.preventDefault(),y.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:r||u?w:void 0,className:"droppable",children:[e.jsxs(z,{gap:1,children:[o?e.jsx(Et,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(L,{children:t.name})]}),e.jsx(us,{isopen:u,menuPosition:n,onClose:()=>g(!1),folder:t}),!o&&e.jsx(B,{ml:4,gap:0,children:e.jsx(Xe,{items:d})})]})});function hs({workflow:a}){const t=i.useRef(null),r=Y(),{onDuplicateWorkflow:l}=i.useContext(Ce),[o,s]=i.useState(a.saveLock??!1),d=async()=>{var h;const n=!o;s(n),await((h=T)==null?void 0:h.updateMetaInfo(a.id,{saveLock:n})),r({title:`${n?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async n=>{const h=n.target.files;if(!h)return;const u=new FormData;Array.from(h).forEach((g,m)=>{u.append(`images[${m}]`,g,g.name)}),u.append("subfolder","workspace_manager"),await yt("/workspace/images/save",{method:"POST",body:u}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=wt)==null||c.create({workflowID:a.id,localPath:m}),(f=T)==null||f.updateMetaInfo(a.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(se,{border:0,as:P,"aria-label":"Options",icon:e.jsx(Bt,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(N,{icon:e.jsx(Lt,{}),onClick:()=>l&&l(a.id),children:"Duplicate"}),e.jsx(N,{icon:e.jsx(xt,{size:20}),onClick:()=>jt(a.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:o?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(N,{icon:o?e.jsx($e,{}):e.jsx(Gt,{}),onClick:d,children:o?"Unlock":"Lock"})}),e.jsx(N,{icon:e.jsx(Jt,{}),onClick:()=>{var n;(n=t.current)==null||n.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:n=>{n.stopPropagation()}})]})}function ps({workflow:a}){const{onDeleteFlow:t}=i.useContext(G);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Pe,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(a.id)}}),e.jsx(hs,{workflow:a})]})}const ze=i.memo(function({workflow:t}){var v,S,w,b;const{colorMode:r}=ke(),{setDraggingFile:l,isMultiSelecting:o,onMultiSelectFlow:s,multiSelectedFlowsID:d}=i.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:n,loadWorkflowID:h}=i.useContext(Ce),u=n===t.id,g=r==="light"?"gray.200":"#4A5568",[m,c]=i.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:u?"teal.200":void 0,color:u&&!o?"#333":void 0,draggable:!o,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!o&&h(t.id)},_hover:{bg:g},children:e.jsxs(z,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(Tt,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx($e,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(z,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:r=="dark"?"gray.700":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:o?e.jsx(q,{isChecked:p,spacing:4,onChange:F=>{s&&s(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(ps,{workflow:t}):e.jsx(L,{color:"GrayText",fontSize:"sm",children:vt(t.updateTime,!1,!1,"/")})})]})})});function Xe({items:a}){var m;const[t,r]=i.useState(!1),l=a.filter(U),o=a.filter(c=>!U(c)),s=(m=o[0])==null?void 0:m.parentFolderID,[d,p]=i.useState(!1),{onRefreshFilesList:n,draggingFile:h,refreshFolderStamp:u}=i.useContext(G),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(U(h)){if(h.id===s)return p(!1);await((f=K)==null?void 0:f.update(h.id,{parentFolderID:s}))}else await((v=T)==null?void 0:v.updateFolder(h.id,{parentFolderID:s}));await(n==null?void 0:n()),p(!1)};return i.useEffect(()=>{var c;(c=C)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[u]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(Oe,{folder:c},c.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?o.map(c=>e.jsx(ze,{workflow:c},c.id)):a.map(c=>U(c)?e.jsx(Oe,{folder:c},c.id):e.jsx(ze,{workflow:c},c.id))})]})}function ks({onClose:a,onClickNewFlow:t}){const[r,l]=i.useState([]),o=i.useRef([]),{loadWorkflowID:s,curFlowID:d}=i.useContext(Ce),[p,n]=i.useState(),[h,u]=i.useState(!1),[g,m]=i.useState([]),[c,f]=i.useState(0),[v,S]=i.useState(""),w=Ot(v,400),b=i.useRef(null),[F,y]=i.useState(null),O=i.useRef(window.localStorage.getItem(ye)??J.RECENTLY_MODIFIED),$=!!p||!!w.length,H=async()=>{var I,M;const x=await((I=T)==null?void 0:I.listFolderContent())??[];l(fe(x,O.current)),f(Date.now()),o.current=await((M=T)==null?void 0:M.listAll())??[]},X=()=>{const x=o.current.filter(I=>{var Ie;let M=!0,D=!0;return p&&(M=!!((Ie=I.tags)!=null&&Ie.includes(p))),w&&(D=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),M&&D});l(fe(x,O.current))},ne=x=>{l(fe(r,x)),O.current=x,window.localStorage.setItem(ye,x),!$&&f(Date.now())};i.useEffect(()=>{$?X():H()},[w,p]);const ae=i.useCallback(async x=>{var I,M,D;await((I=T)==null?void 0:I.deleteFlow(x)),((D=(M=T)==null?void 0:M.curWorkflow)==null?void 0:D.id)===x&&await(s==null?void 0:s(null)),await H()},[p,w]);i.useEffect(()=>{const x=async I=>{var M;if(b.current){const D=await((M=T)==null?void 0:M.get(b.current));D&&D.json&&bt(D.json,[I.canvasX,I.canvasY])}};return oe.canvasEl.addEventListener("drop",x),oe.canvasEl.addEventListener("click",a),()=>{oe.canvasEl.removeEventListener("drop",x),oe.canvasEl.removeEventListener("click",a)}},[]);const ge=i.useCallback((x,I)=>{m(M=>{const D=[...M];return I?D.push(x):D.splice(D.indexOf(x),1),D})},[]),j=(x,I)=>{var M;switch(x){case"batchDelete":d&&((M=T)==null||M.get(d).then(D=>{D||s==null||s(null)})),H(),u(!1),m([]);return;case"selectAll":m(I?o.current.map(D=>D.id):[]);return}},k=x=>{y(x),U(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:H,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:h,onMultiSelectFlow:ge,multiSelectedFlowsID:g,onDeleteFlow:ae,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(kt,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:St,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(z,{gap:4,children:[e.jsx(z,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Ye,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(P,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(_e,{}),variant:"outline",colorScheme:"teal",onClick:()=>Ct()})}),e.jsx(R,{label:"New workflow",children:e.jsx(P,{"aria-label":"New workflow",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(z,{alignItems:"center",children:e.jsx(rs,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(cs,{selectedTag:p,setSelectedTag:n}),e.jsxs(z,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(z,{children:[e.jsx(ls,{multipleState:h,changeMultipleState:x=>{u(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===o.current.length,batchOperationCallback:j}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(P,{size:"sm",variant:"outline",icon:e.jsx(Ue,{size:21}),onClick:async()=>{var x;await((x=K)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:A,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(z,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(te,{children:e.jsx(Ve,{value:O.current,type:"radio",onChange:x=>ne(x),children:[J.RECENTLY_MODIFIED,J.OLDEST_MODIFIED,J.AZ,J.ZA].map((x,I)=>e.jsx(be,{value:x,children:x},I))})})]})]}),e.jsx(zt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(Xe,{items:r})})]})]})})})}export{ks as default}; diff --git a/dist/workspace_web/RecentFilesDrawer-o2YKsAW_.js b/dist/workspace_web/RecentFilesDrawer-o2YKsAW_.js new file mode 100644 index 0000000..8c32da4 --- /dev/null +++ b/dist/workspace_web/RecentFilesDrawer-o2YKsAW_.js @@ -0,0 +1,5 @@ +import{f as Q,E as Je,j as e,Y as Qe,e as ie,g as we,r as i,M as re,N as le,O as ce,Q as de,R as ue,S as he,V as ve,h as A,Z as ke,T as et}from"./input.js";import{m as We,u as Ae,a as tt,b as st,c as nt,S as at,M as ot,d as W,H as z,T as Ne,I as P,t as je,e as Pe,f as Y,E as me,g as B,h as L,i as R,j as pe,k as C,R as G,l as it,n as Me,B as _,F as Z,o as Fe,p as rt,q as lt,r as ee,s as te,v as N,w as ct,D as Re,x as T,y as _e,z as dt,A as Se,C as ut,G as Be,J as K,K as ht,L as pt,N as gt,O as $e,P as mt,Q as ft,U as xt,V as De,W as U,X as ye,Y as Ce,Z as jt,_ as yt,$ as He,a0 as wt,a1 as vt,a2 as kt,a3 as J,a4 as oe,a5 as St,a6 as Ct,a7 as bt,a8 as fe,a9 as It}from"./App-HFfBS8qf.js";import{G as Mt,C as q}from"./chunk-JARCRF6W-OdkdCK_9.js";import{V as Ke}from"./chunk-NTCQBYKE-hyXDv1Bs.js";import{N as Ft,a as Dt,g as Et,I as Tt,M as Ot,u as zt,S as Lt}from"./MediaPreview-aZ3slqVC.js";import{I as Wt}from"./IconCopy-pJEV5GIP.js";import"./chunk-7D6N5TE5-Bj67hFEP.js";import"./IconSearch-w32ReMy0.js";var Ge=Q(function(t,r){const{columns:l,spacingX:o,spacingY:s,spacing:d,minChildWidth:p,...n}=t,h=Je(),u=p?Nt(p,h):Pt(l);return e.jsx(Mt,{ref:r,gap:d,columnGap:o,rowGap:s,templateColumns:u,...n})});Ge.displayName="SimpleGrid";function At(a){return typeof a=="number"?`${a}px`:a}function Nt(a,t){return We(a,r=>{const l=Qe("sizes",r,At(r))(t);return r===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function Pt(a){return We(a,t=>t===null?null:`repeat(${t}, minmax(0, 1fr))`)}var Ve=Q((a,t)=>{const{title:r,children:l,className:o,...s}=a,d=ie("chakra-menu__group__title",o),p=Ae();return e.jsxs("div",{ref:t,className:"chakra-menu__group",role:"group",children:[r&&e.jsx(we.p,{className:d,...s,__css:p.groupTitle,children:r}),l]})});Ve.displayName="MenuGroup";var Ue=a=>{const{className:t,title:r,...l}=a,o=tt(l);return e.jsx(Ve,{title:r,className:ie("chakra-menu__option-group",t),...o})};Ue.displayName="MenuOptionGroup";var Rt=Q((a,t)=>{const r=Ae();return e.jsx(we.button,{ref:t,...a,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...r.button}})}),se=Q((a,t)=>{const{children:r,as:l,...o}=a,s=st(o,t),d=l||Rt;return e.jsx(d,{...s,className:ie("chakra-menu__menu-button",a.className),children:e.jsx(we.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:a.children})})});se.displayName="MenuButton";var _t=a=>e.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...a,children:e.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),be=Q((a,t)=>{const{icon:r,iconSpacing:l="0.75rem",...o}=a,s=nt(o,t);return e.jsxs(at,{...s,className:ie("chakra-menu__menuitem-option",o.className),children:[r!==null&&e.jsx(ot,{fontSize:"0.8em",marginEnd:l,opacity:a.isChecked?1:0,children:r||e.jsx(_t,{})}),e.jsx("span",{style:{flex:1},children:s.children})]})});be.id="MenuItemOption";be.displayName="MenuItemOption";var Bt=W("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),$t=W("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),Ht=W("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"}]]),Ee=W("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),Kt=W("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"}]]),Ze=W("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),Gt=W("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Vt=W("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),Ut=W("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Zt=W("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Yt=W("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"}]]),Xt=W("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),qt=W("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Jt=W("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Qt=W("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function es({onclose:a}){const[t,r]=i.useState([]),l=async()=>{var s;const o=await((s=je)==null?void 0:s.listAll());r(o??[])};return i.useEffect(()=>{l()},[]),e.jsxs(re,{isOpen:!0,onClose:a,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"My Tags"}),e.jsx(ue,{}),e.jsx(he,{children:t.map(o=>e.jsxs(z,{children:[e.jsx(Ne,{children:o.name}),e.jsx(P,{onClick:async()=>{var s;await((s=je)==null?void 0:s.delete(o.name)),l()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:e.jsx(Pe,{})})]}))})]})]})}function ts(){const a=Y(),t=i.useRef([{title:"Save current workflow",key:me.SAVE},{title:"Save as current workflow",key:me.SAVE_AS},{title:"Open spotlight search",key:me.openSpotlightSearch}]),[r,l]=i.useState({save:"",saveAs:"",openSpotlightSearch:""}),[o,s]=i.useState(),d=async(n,h)=>{var g;n.preventDefault();let u="";if(n.ctrlKey&&(u+="Control+"),n.metaKey&&(u+="Command+"),n.shiftKey&&(u+="Shift+"),n.altKey&&(u+="Alt+"),u.length>0&&!["Control","Shift","Alt","Meta"].includes(n.key)){u+=n.key.toUpperCase();const m={...r};delete m[h],Object.values(m).includes(u)?a({title:"Shortcut key conflict",description:`The shortcut key 「${u}」 is already used, please + modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((g=C)==null?void 0:g.upsert({shortcuts:{...r,[h]:u}})),p())}},p=()=>{var n;(n=C)==null||n.getSetting("shortcuts").then(h=>{var g;const u=h??((g=C)==null?void 0:g.defaultSettings.shortcuts);l({...r,...u})})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:"Keyboard Shortcut"}),t.current.map(n=>e.jsxs(z,{children:[e.jsx(L,{fontSize:"sm",w:170,children:n.title}),e.jsx(R,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:o===n.key,children:e.jsx(pe,{value:r[n.key],onKeyDown:h=>{d(h,n.key)},onFocus:()=>{s(n.key)},onBlur:()=>{s(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},n.key))]})}function ss(){const{setRefreshFolderStamp:a}=i.useContext(G),[t,r]=i.useState(!1),l=()=>{var s;(s=C)==null||s.getSetting("foldersOnTop").then(d=>{r(!!d)})},o=s=>{var p;const d=s.target.checked;(p=C)==null||p.upsert({foldersOnTop:d}).then(()=>{l(),a(Date.now())})};return i.useEffect(()=>{l()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:t,onChange:o,children:"Folders always on top"})})}function ns(){const[a,t]=i.useState(!1),[r,l]=i.useState(""),{showDialog:o}=ve(),s=()=>{var p,n;(p=C)==null||p.getSetting("myWorkflowsDir").then(h=>{l(h??"undefined")}),(n=C)==null||n.getSetting("twoWaySync").then(h=>{t(h??!1)})};i.useEffect(()=>{s()},[]);const d=async p=>{var h,u;if(!p.target.checked){await((h=C)==null?void 0:h.upsert({twoWaySync:p.target.checked})),s();return}const n=await((u=C)==null?void 0:u.getSetting("myWorkflowsDir"));o(e.jsx(it,{myWorkflowsDir:n??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var g;await((g=C)==null?void 0:g.upsert({twoWaySync:!0})),s()},colorScheme:"red"}])};return e.jsxs(B,{children:[e.jsx(L,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),e.jsx(q,{isChecked:a,onChange:d,children:"Enable two way sync"})]})}function Te({settingKey:a,text:t,defaultChecked:r=!1}){const[l,o]=i.useState(r),s=Y(),d=()=>{var p;(p=C)==null||p.getSetting(a).then(n=>{o(!!n)})};return i.useEffect(()=>{d()},[]),e.jsx(B,{children:e.jsx(q,{isChecked:l,onChange:async p=>{var n;await((n=C)==null?void 0:n.upsert({[a]:p.target.checked})),d(),s({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:3e3,isClosable:!0})},children:t})})}function as(){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),[o,s]=i.useState([]),[d,p]=i.useState(""),[n,h]=i.useState([]),[u,g]=i.useState(!1),[m,c]=i.useState(!1),[f,v]=i.useState(!1),S=i.useRef(null),w=Y();ve();const b=f?"\\":"/";i.useEffect(()=>{var j;Me().then(k=>{p(k.path??""),v(k.os==="win32")}),(j=C)==null||j.getSetting("twoWaySync").then(k=>{g(k??!1)})},[]);const F=async j=>{const{dir_path:k="",dir_contents:E=[],error:V=""}=await Fe(j??"");return V.includes("Operation not permitted")?(c(!0),O(),{isError:!0}):{dirList:E,dirPath:k}},y=async()=>{const{isError:j=!1,dirList:k=[]}=await F(d);j||(s(k),l(!0),h(d&&d.split(b).filter(E=>!!E)||[]))},O=()=>{l(!1),t(!1),h([])},$=async(j,k=!1,E=!1)=>{var x,I;if(k){const{path:M}=await Me();M&&await rt(M,j)}await((x=C)==null?void 0:x.upsert({myWorkflowsDir:j}));const V=await((I=C)==null?void 0:I.getSetting("myWorkflowsDir"))??"";p(V),E&&c(!1),O()},H=async j=>{if(j){const{error:E=""}=await Fe(j);if(E.includes("Not a directory")){w({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const k=j??`${f?"":b}${n.join(b)}`;$(k,!1,!!j)},X=async()=>{const{dirPath:j,dirList:k}=await F("");h(j.split(b).filter(E=>!!E)),s(k)},ne=async(j,k)=>{var I;let E="";j===-1&&k?E=`${f?"":b}${n.concat([k]).join(b)}`:E=`${f?"":b}${n.slice(0,j+1).join(b)}`;const{isError:V=!1,dirList:x=[]}=await F(E);V||(s(x),h(f?E.split(b):(I=E.slice(1))==null?void 0:I.split(b)))},ae=e.jsxs(_,{textAlign:"end",mb:4,children:[e.jsx(pe,{placeholder:"Please enter the absolute path directory address",ref:S,mt:2,mb:2}),e.jsx(A,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var j,k;(j=S==null?void 0:S.current)!=null&&j.value&&H((k=S==null?void 0:S.current)==null?void 0:k.value)},children:"Save"})]}),ge=()=>{l(!0),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{mb:4,children:[e.jsx(L,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),r?a?ae:e.jsxs(Ke,{spacing:2,alignItems:"start",children:[e.jsx(B,{spacing:"2px",direction:"row",wrap:"wrap",children:n.map((j,k)=>e.jsxs("span",{children:[k>0&&b,e.jsx(A,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{ne(k)},children:j},`${j}-${k}`)]},j))}),e.jsx(Ge,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:o.map((j,k)=>e.jsx(A,{size:"sm",leftIcon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{ne(-1,j)},children:j},`${j}-${k}`))}),e.jsxs(_,{w:"100%",textAlign:"end",children:[e.jsx(A,{colorScheme:"teal",size:"sm",onClick:()=>{H()},children:"Save"}),e.jsx(A,{size:"sm",onClick:X,mr:2,ml:2,children:"Reset"}),e.jsx(A,{size:"sm",onClick:O,children:"Cancel"})]})]}):e.jsxs(Z,{children:[e.jsx(Ne,{overflowWrap:"anywhere",children:d}),e.jsx(R,{label:u?"Choose folder":"Enable two way sync to link local folder",children:e.jsx(P,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!u,icon:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:y})}),e.jsx(R,{label:u?"Input absolute path":"Enable two way sync to link local folder",children:e.jsx(P,{isDisabled:!u,"aria-label":"Enter folder address",size:"sm",ml:2,icon:e.jsx(Ht,{size:19}),onClick:ge,variant:"ghost"})})]})]}),e.jsxs(re,{isOpen:m,onClose:()=>c(!1),size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Kind tips"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(_,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?e.jsxs(L,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",e.jsx(A,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos\r + -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):e.jsx(L,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),ae]})})]})]})]})}function Ye({label:a,settingKey:t}){const[r,l]=i.useState(200),o=Y(),s=n=>{if(!n.length){l(0);return}l(parseInt(n))},d=async()=>{var n;r<0&&l(0),await((n=C)==null?void 0:n.upsert({[t]:Number(r)})),o({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},p=()=>{var n;(n=C)==null||n.getSetting(t).then(h=>{l(h)})};return i.useEffect(()=>{p()},[]),e.jsxs(B,{children:[e.jsx(L,{children:a}),e.jsx(Ft,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:r,onChange:n=>s(n),onBlur:()=>{d()},onKeyUp:n=>{n.key==="Enter"&&d()},children:e.jsx(Dt,{})})]})}function os(){const[a,t]=i.useState(!1),r=Y(),l=()=>{var o;(o=C)==null||o.getSetting("autoSave").then(s=>{t(!!s)})};return i.useEffect(()=>{l()},[]),e.jsxs(B,{children:[e.jsx(q,{isChecked:a,onChange:async o=>{var s;await((s=C)==null?void 0:s.upsert({autoSave:o.target.checked})),l(),r({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),a&&e.jsx(Ye,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function is(){const a=Y(),[t,r]=i.useState(""),l=()=>{var s;(s=C)==null||s.getSetting("cloudHost").then(d=>{r(d??"")})};i.useEffect(()=>{l()},[]);const o=async s=>{var d;s=s.trim(),s.endsWith("/")&&(s=s.slice(0,-1)),await((d=C)==null?void 0:d.upsert({cloudHost:s})),l(),a({title:"Setting saved. Please refresh to see the changes.",status:"success",duration:4e3})};return e.jsxs(B,{children:[e.jsx(L,{children:"For enterprise paid user only. Hosting site of the shared workflow."}),e.jsxs(Z,{gap:2,alignItems:"center",children:[e.jsx(pe,{value:t,onChange:s=>r(s.target.value),onBlur:()=>o(t)}),e.jsx(A,{size:"sm",onClick:()=>{var d;const s=(d=C)==null?void 0:d.defaultSettings.cloudHost;r(s),o(s)},children:"Reset"})]})]})}function rs({onClose:a}){return e.jsx(e.Fragment,{children:e.jsxs(re,{isOpen:!0,onClose:a,size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Settings"}),e.jsx(ue,{}),e.jsx(he,{pb:14,children:e.jsx(z,{children:e.jsxs(Ke,{divider:e.jsx(lt,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[e.jsx(as,{}),e.jsx(os,{}),e.jsx(ts,{}),e.jsx(ns,{}),e.jsx(ss,{}),e.jsx(Te,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),e.jsx(Ye,{label:`Maximum number of save change history to store. This does not include + versions that you created by "Create Version", which are always stored + and has no limit.`,settingKey:"maximumChangelogNumber"}),e.jsx(Te,{settingKey:"hideCoverImage",text:"Hide thumbnail image in workflow list"}),e.jsx(is,{})]})})})]})]})})}const xe=16;function ls({}){const[a,t]=i.useState(!1),[r,l]=i.useState(!1),{colorMode:o,toggleColorMode:s}=ke();return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,children:[e.jsx(se,{as:P,"aria-label":"Options",icon:e.jsx(Ut,{}),size:"sm",variant:"outline"}),e.jsxs(te,{children:[e.jsx(N,{onClick:()=>l(!0),icon:e.jsx(Xt,{size:16}),fontSize:16,children:"Settings"}),e.jsx(N,{onClick:()=>t(!0),icon:e.jsx(Jt,{size:xe}),fontSize:16,children:"Manage Tags"}),e.jsxs(N,{onClick:s,icon:o==="light"?e.jsx(Zt,{size:xe}):e.jsx(qt,{size:xe}),fontSize:16,children:[o==="light"?"Dark":"Light"," Mode"]})]})]}),a&&e.jsx(es,{onclose:()=>t(!1)}),r&&e.jsx(rs,{onClose:()=>l(!1)})]})}function cs(a){const{multipleState:t,changeMultipleState:r,selectedKeys:l,isSelectedAll:o,batchOperationCallback:s}=a,d=async()=>{var h;const n=await((h=T)==null?void 0:h.batchQuery(l))??[];dt(n)},p=l.length===0;return e.jsx(z,{spacing:2,wrap:"wrap",mb:0,children:t?e.jsxs(e.Fragment,{children:[e.jsx(q,{isChecked:o,onChange:n=>{s("selectAll",n.target.checked)}}),e.jsx(R,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:e.jsx(P,{isDisabled:p,"aria-label":"Batch export",size:"sm",icon:e.jsx(ct,{size:21}),onClick:d})}),e.jsx(R,{hasArrow:!0,label:"Batch deletion",children:e.jsx(Re,{isDisabled:p,variant:"solid",promptMessage:`Are you sure you want to delete these ${l.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var n;await((n=T)==null?void 0:n.batchDeleteFlow(l)),s("batchDelete")}})}),l.length>0&&e.jsx(L,{fontWeight:600,children:`Selected ${l.length}`}),e.jsx(R,{hasArrow:!0,label:"Exit multi-select",children:e.jsx(P,{"aria-label":"Close multi-select operation",size:"sm",icon:e.jsx(_e,{}),onClick:()=>{r(!1)}})})]}):e.jsx(R,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:e.jsx(P,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:e.jsx(Gt,{size:21}),onClick:()=>{r(!0)}})})})}const Oe=6;function ds({setSelectedTag:a,selectedTag:t}){const[r,l]=i.useState(!1),[o,s]=i.useState([]);return i.useEffect(()=>{var d;(d=je)==null||d.listAll().then(p=>{s(p)})},[]),e.jsxs(z,{spacing:2,wrap:"wrap",mb:0,children:[t!=null&&e.jsx(P,{"aria-label":"Close",size:"sm",icon:e.jsx(_e,{}),onClick:()=>{a(void 0)}}),o.slice(0,r?void 0:Oe).map(d=>e.jsx(A,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{a(d.name)},isActive:t===d.name,children:d.name},d.name)),(o.length??0)>Oe&&e.jsx(P,{"aria-label":"Show-all-tags",size:"sm",icon:r?e.jsx(Bt,{}):e.jsx(Se,{}),onClick:()=>l(!r)})]})}function Xe({parentFolderID:a,onlyImportFile:t=!1}){const{onRefreshFilesList:r}=i.useContext(G),[l,o]=i.useState("file"),s=i.useRef(null),d=u=>{var g;o(u),u==="folder"?s.current.setAttribute("webkitdirectory",""):s.current.removeAttribute("webkitdirectory"),(g=s.current)==null||g.click()},p=async u=>{var g;if(u.type==="image/png"){const m=await Et(u),c=m==null?void 0:m.workflow;if(c)return{json:c,name:u.name.replace(".png","")}}else if(u.type==="application/json"||(g=u.name)!=null&&g.endsWith(".json"))return await new Promise((m,c)=>{const f=new FileReader;f.onload=v=>{var S;try{const w=(S=v.target)==null?void 0:S.result;typeof w=="string"?m({json:w,name:u.name.replace(".json","")}):c(new Error("File content is not a string"))}catch(w){c(w)}},f.onerror=c,f.readAsText(u)});return null},n=async u=>{var m,c;const g=[u];for(;g.length>0;){const f=g.shift();if(f&&!f.isFile){const v=await((m=K)==null?void 0:m.create({name:f.name,parentFolderID:f.parentFolderID}));if(f.children&&f.children.length){const S=[];f.children.forEach(w=>{w.isFile&&w.file?S.push(w.file):(w.parentFolderID=v==null?void 0:v.id,g.push(w))}),S.length&&await((c=T)==null?void 0:c.batchCreateFlows(S,void 0,v==null?void 0:v.id))}}}r==null||r()},h=async u=>{var m;const g=u.target.files;if(g)if(l==="folder"){const c={name:g[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const f of g)if(f.name!==".DS_Store"){const v=f.webkitRelativePath.split("/");let S=c.children??[];for(let w=1;wy.name===b);if(!F){if(F={name:b,isFile:w===v.length-1,children:w===v.length-1?void 0:[]},F.isFile){const y=await p(f);y&&(F.file=y)}S.push(F)}F&&!F.isFile&&(S=F.children)}}n(c)}else{const c=[];for(const f of g){const v=await p(f);v&&c.push(v)}c.length&&(await((m=T)==null?void 0:m.batchCreateFlows(c,void 0,a)),r&&r())}};return e.jsxs(e.Fragment,{children:[t?e.jsx(N,{onClick:u=>{u.stopPropagation(),d("file")},icon:e.jsx(Ee,{size:19}),children:"Import workflows"}):e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:A,leftIcon:e.jsx(Ee,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),e.jsx(te,{children:ut.map((u,g)=>e.jsx(N,{onClick:()=>{d(u.type)},iconSpacing:2,icon:u.type==="folder"?e.jsx(Be,{size:18}):e.jsx(Kt,{size:18}),children:u.title},g))})]}),e.jsx("input",{style:{display:"none"},ref:s,type:"file",accept:".json,image/png",multiple:!0,onChange:h,onClick:u=>{u.stopPropagation()}})]})}function us({folder:a,onclose:t}){const[r,l]=i.useState(a.name),[o,s]=i.useState(""),{onRefreshFilesList:d}=i.useContext(G),p=h=>{l(h.target.value),o&&s("")},n=async()=>{var g,m;const h=r.trim();if(l(h),h===a.name)return t();await((g=K)==null?void 0:g.generateUniqueName(h,a.parentFolderID??""))!==h?s("The name is duplicated, please modify it and submit again."):(await((m=K)==null?void 0:m.update(a.id,{name:h})),d&&d(),t())};return e.jsxs(re,{isOpen:!0,onClose:t,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(de,{children:"Edit folder name"}),e.jsx(ue,{}),e.jsx(he,{children:e.jsxs(ht,{isInvalid:!!o,children:[e.jsx(pt,{children:"Folder name"}),e.jsx(pe,{value:r,onChange:p,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!o&&r&&n()}}),o&&e.jsx(gt,{children:o})]})}),e.jsxs(et,{children:[e.jsx(A,{colorScheme:"teal",mr:3,onClick:n,isDisabled:!r||!!o,children:"Save"}),e.jsx(A,{onClick:t,children:"Cancel"})]})]})]})}function hs({menuPosition:a,isopen:t,folder:r,onClose:l}){const[o,s]=i.useState(!1),{onRefreshFilesList:d}=i.useContext(G),{showDialog:p}=ve(),n=async m=>{var c;m.stopPropagation(),await((c=K)==null?void 0:c.create({name:"New Folder",parentFolderID:r.id})),d&&d()},h=async m=>{var c;m.stopPropagation(),await((c=T)==null?void 0:c.createFlow({json:JSON.stringify(mt),parentFolderID:r.id})),d&&d()},u=async m=>{m.stopPropagation();const c=await ft(r.id);p(`Do you want to delete the ${c} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{g(xt.DELETE)}}])},g=async m=>{var c;await((c=K)==null?void 0:c.deleteFolder(r.id,m)),l(),d&&d()};return e.jsxs(e.Fragment,{children:[e.jsx(_,{position:"absolute",top:a.y,left:a.x,children:e.jsx(ee,{isOpen:t,onClose:l,isLazy:!0,lazyBehavior:"keepMounted",children:e.jsxs(te,{children:[e.jsx(N,{icon:e.jsx(Yt,{size:19}),onClick:m=>{m.preventDefault(),m.stopPropagation(),s(!0)},children:"Rename"}),e.jsx(N,{icon:e.jsx(Pe,{size:19}),onClick:u,children:"Delete"}),e.jsx(N,{onClick:n,icon:e.jsx(Ze,{size:19}),children:"New folder"}),e.jsx(N,{onClick:h,icon:e.jsx($e,{size:19}),children:"New file"}),e.jsx(Xe,{parentFolderID:r.id,onlyImportFile:!0})]})})}),o&&e.jsx(us,{folder:r,onclose:()=>s(!1)})]})}const ze=i.memo(function({folder:t}){const[r,l]=i.useState(!1),[o,s]=i.useState(t.isCollapse??!0),[d,p]=i.useState([]),[n,h]=i.useState({x:0,y:0}),[u,g]=i.useState(!1),{colorMode:m}=ke(),{draggingFile:c,setDraggingFile:f,refreshFolderStamp:v,onRefreshFilesList:S}=i.useContext(G),w=m==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};i.useEffect(()=>{var y;o||(y=T)==null||y.listFolderContent(t.id,window.localStorage.getItem(ye)).then(O=>{p(O)})},[t.id,v,o]);const b=y=>{y.preventDefault(),h({x:y.clientX,y:y.clientY}),g(!0)},F=async y=>{var O,$;if(y.preventDefault(),y.stopPropagation(),!c)return l(!1);if(U(c)){if(c.id===t.id)return l(!1);await((O=K)==null?void 0:O.update(c.id,{parentFolderID:t.id}))}else U(c)||await(($=T)==null?void 0:$.updateFolder(c.id,{parentFolderID:t.id}));await(S==null?void 0:S()),l(!1)};return i.useEffect(()=>{var y;!!t.isCollapse!==o&&((y=K)==null||y.update(t.id,{isCollapse:o}))},[o]),i.useEffect(()=>{var X;const y=(X=T)==null?void 0:X.curWorkflow,O=(y==null?void 0:y.parentFolderID)+De(),$=t.id+De();O.startsWith($)&&s(!1)},[]),e.jsxs(B,{children:[e.jsxs(z,{w:"100%",as:"button",py:1,onClick:()=>{s(!o)},onContextMenu:b,draggable:"true",onDragOver:y=>{y.preventDefault(),y.stopPropagation(),l(!0)},onDragLeave:y=>{y.preventDefault(),y.stopPropagation(),l(!1)},onDragStart:()=>f==null?void 0:f(t),onDrop:F,_hover:w,style:r||u?w:void 0,className:"droppable",children:[e.jsxs(z,{gap:1,children:[o?e.jsx(Tt,{size:20}):e.jsx(Se,{size:20}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:e.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),e.jsx(L,{children:t.name})]}),e.jsx(hs,{isopen:u,menuPosition:n,onClose:()=>g(!1),folder:t}),!o&&e.jsx(B,{ml:4,gap:0,children:e.jsx(qe,{items:d})})]})});function ps({workflow:a}){const t=i.useRef(null),r=Y(),{onDuplicateWorkflow:l}=i.useContext(Ce),[o,s]=i.useState(a.saveLock??!1),d=async()=>{var h;const n=!o;s(n),await((h=T)==null?void 0:h.updateMetaInfo(a.id,{saveLock:n})),r({title:`${n?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},p=async n=>{const h=n.target.files;if(!h)return;const u=new FormData;Array.from(h).forEach((g,m)=>{u.append(`images[${m}]`,g,g.name)}),u.append("subfolder","workspace_manager"),await wt("/workspace/images/save",{method:"POST",body:u}),Array.from(h).forEach(async g=>{var c,f;const m=`workspace_manager/${g.name}`;(c=vt)==null||c.create({workflowID:a.id,localPath:m}),(f=T)==null||f.updateMetaInfo(a.id,{coverMediaPath:m})})};return e.jsxs(e.Fragment,{children:[e.jsxs(ee,{isLazy:!0,closeOnSelect:!1,placement:"right",gutter:0,children:[e.jsx(se,{border:0,as:P,"aria-label":"Options",icon:e.jsx($t,{size:20}),size:"sm",variant:"outline"}),e.jsxs(te,{zIndex:101,children:[e.jsx(N,{icon:e.jsx(Wt,{}),onClick:()=>l&&l(a.id),children:"Duplicate"}),e.jsx(N,{icon:e.jsx(jt,{size:20}),onClick:()=>yt(a.id),children:"Open in new tab"}),e.jsx(R,{hasArrow:!0,label:o?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:e.jsx(N,{icon:o?e.jsx(He,{}):e.jsx(Vt,{}),onClick:d,children:o?"Unlock":"Lock"})}),e.jsx(N,{icon:e.jsx(Qt,{}),onClick:()=>{var n;(n=t.current)==null||n.click()},children:"Upload Thumbnail Image"})]})]}),e.jsx("input",{style:{display:"none"},ref:t,type:"file",accept:".json,image/png",multiple:!0,onChange:p,onClick:n=>{n.stopPropagation()}})]})}function gs({workflow:a}){const{onDeleteFlow:t}=i.useContext(G);return e.jsxs(Z,{justifyContent:"flex-end",children:[e.jsx(Re,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{t&&t(a.id)}}),e.jsx(ps,{workflow:a})]})}const Le=i.memo(function({workflow:t}){var v,S,w,b;const{colorMode:r}=ke(),{setDraggingFile:l,isMultiSelecting:o,onMultiSelectFlow:s,multiSelectedFlowsID:d}=i.useContext(G),p=d&&d.length>0&&d.includes(t.id),{curFlowID:n,loadWorkflowID:h}=i.useContext(Ce),u=n===t.id,g=r==="light"?"gray.200":"#4A5568",[m,c]=i.useState(!1),f=e.jsx(_,{flexShrink:1,flexGrow:1,backgroundColor:u?"teal.200":void 0,color:u&&!o?"#333":void 0,draggable:!o,onDragStart:()=>l==null?void 0:l(t),borderRadius:6,px:1,py:"5px",onClick:()=>{!o&&h(t.id)},_hover:{bg:g},children:e.jsxs(z,{flexGrow:1,children:[!((S=(v=C)==null?void 0:v.settings)!=null&&S.hideCoverImage)&&(((w=t.coverMediaPath)==null?void 0:w.length)||((b=t.latestImage)==null?void 0:b.length))&&e.jsx(Ot,{mediaLocalPath:t.coverMediaPath??t.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),e.jsx(_,{textAlign:"left",gap:0,justifyContent:"space-between",flexGrow:1,children:e.jsxs(Z,{alignItems:"center",children:[e.jsx(L,{fontWeight:"500",noOfLines:1,wordBreak:"break-all",children:t.name??"untitled"}),t.saveLock&&e.jsx(He,{size:18,style:{display:"inline-block"}})]})})]})});return e.jsx(z,{w:"100%",justify:"space-between",borderBottom:"1px solid",borderColor:r=="dark"?"gray.700":"gray.200",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:o?e.jsx(q,{isChecked:p,spacing:4,onChange:F=>{s&&s(t.id,F.target.checked)},children:f}):e.jsxs(e.Fragment,{children:[f,e.jsx(_,{width:"fit-content",children:m?e.jsx(gs,{workflow:t}):e.jsx(L,{color:"GrayText",fontSize:"sm",children:kt(t.updateTime,!1,!1,"/")})})]})})});function qe({items:a}){var m;const[t,r]=i.useState(!1),l=a.filter(U),o=a.filter(c=>!U(c)),s=(m=o[0])==null?void 0:m.parentFolderID,[d,p]=i.useState(!1),{onRefreshFilesList:n,draggingFile:h,refreshFolderStamp:u}=i.useContext(G),g=async c=>{var f,v;if(c.preventDefault(),c.stopPropagation(),!h)return p(!1);if(U(h)){if(h.id===s)return p(!1);await((f=K)==null?void 0:f.update(h.id,{parentFolderID:s}))}else await((v=T)==null?void 0:v.updateFolder(h.id,{parentFolderID:s}));await(n==null?void 0:n()),p(!1)};return i.useEffect(()=>{var c;(c=C)==null||c.getSetting("foldersOnTop").then(f=>{r(f??!1)})},[u]),e.jsxs(e.Fragment,{children:[t&&l.map(c=>e.jsx(ze,{folder:c},c.id)),e.jsx(_,{border:d?"2px dashed #718096":"2px dashed transparent",onDragOver:c=>{c.preventDefault(),c.stopPropagation(),p(!0)},onDragLeave:c=>{c.preventDefault(),c.stopPropagation(),p(!1)},onDrop:g,className:"droppable",children:t?o.map(c=>e.jsx(Le,{workflow:c},c.id)):a.map(c=>U(c)?e.jsx(ze,{folder:c},c.id):e.jsx(Le,{workflow:c},c.id))})]})}function Ss({onClose:a,onClickNewFlow:t}){const[r,l]=i.useState([]),o=i.useRef([]),{loadWorkflowID:s,curFlowID:d}=i.useContext(Ce),[p,n]=i.useState(),[h,u]=i.useState(!1),[g,m]=i.useState([]),[c,f]=i.useState(0),[v,S]=i.useState(""),w=zt(v,400),b=i.useRef(null),[F,y]=i.useState(null),O=i.useRef(window.localStorage.getItem(ye)??J.RECENTLY_MODIFIED),$=!!p||!!w.length,H=async()=>{var I,M;const x=await((I=T)==null?void 0:I.listFolderContent())??[];l(fe(x,O.current)),f(Date.now()),o.current=await((M=T)==null?void 0:M.listAll())??[]},X=()=>{const x=o.current.filter(I=>{var Ie;let M=!0,D=!0;return p&&(M=!!((Ie=I.tags)!=null&&Ie.includes(p))),w&&(D=!!I.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),M&&D});l(fe(x,O.current))},ne=x=>{l(fe(r,x)),O.current=x,window.localStorage.setItem(ye,x),!$&&f(Date.now())};i.useEffect(()=>{$?X():H()},[w,p]);const ae=i.useCallback(async x=>{var I,M,D;await((I=T)==null?void 0:I.deleteFlow(x)),((D=(M=T)==null?void 0:M.curWorkflow)==null?void 0:D.id)===x&&await(s==null?void 0:s(null)),await H()},[p,w]);i.useEffect(()=>{const x=async I=>{var M;if(b.current){const D=await((M=T)==null?void 0:M.get(b.current));D&&D.json&&It(D.json,[I.canvasX,I.canvasY])}};return oe.canvasEl.addEventListener("drop",x),oe.canvasEl.addEventListener("click",a),()=>{oe.canvasEl.removeEventListener("drop",x),oe.canvasEl.removeEventListener("click",a)}},[]);const ge=i.useCallback((x,I)=>{m(M=>{const D=[...M];return I?D.push(x):D.splice(D.indexOf(x),1),D})},[]),j=(x,I)=>{var M;switch(x){case"batchDelete":d&&((M=T)==null||M.get(d).then(D=>{D||s==null||s(null)})),H(),u(!1),m([]);return;case"selectAll":m(I?o.current.map(D=>D.id):[]);return}},k=x=>{y(x),U(x)||(b.current=x.id)},E=x=>{S(x)},V=450;return e.jsx(G.Provider,{value:{onRefreshFilesList:H,draggingFile:F??void 0,setDraggingFile:k,isMultiSelecting:h,onMultiSelectFlow:ge,multiSelectedFlowsID:g,onDeleteFlow:ae,refreshFolderStamp:c,setRefreshFolderStamp:f},children:e.jsx(_,{style:{width:V},children:e.jsxs(St,{width:V,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Ct,children:[e.jsxs(Z,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(z,{gap:4,children:[e.jsx(z,{gap:2,children:e.jsx(L,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),e.jsx(Xe,{}),e.jsx(R,{label:"Open workspace save directory",children:e.jsx(P,{"aria-label":"Open workspace save directory",size:"sm",icon:e.jsx(Be,{}),variant:"outline",colorScheme:"teal",onClick:()=>bt()})}),e.jsx(R,{label:"New workflow",children:e.jsx(P,{"aria-label":"New workflow",size:"sm",icon:e.jsx($e,{}),variant:"outline",colorScheme:"teal",onClick:t})})]}),e.jsx(z,{alignItems:"center",children:e.jsx(ls,{})})]}),e.jsxs(Z,{direction:"column",h:"calc(100% - 64px)",children:[e.jsx(ds,{selectedTag:p,setSelectedTag:n}),e.jsxs(z,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[e.jsxs(z,{children:[e.jsx(cs,{multipleState:h,changeMultipleState:x=>{u(x),!x&&m([])},selectedKeys:g,isSelectedAll:g.length===o.current.length,batchOperationCallback:j}),!h&&e.jsx(R,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:e.jsx(P,{size:"sm",variant:"outline",icon:e.jsx(Ze,{size:21}),onClick:async()=>{var x;await((x=K)==null?void 0:x.create({name:"New Folder"})),H()},"aria-label":"new folder button"})})]}),e.jsxs(ee,{closeOnSelect:!0,children:[e.jsx(se,{as:A,variant:"ghost",size:"xs",pr:0,rightIcon:e.jsx(Se,{size:"16"}),children:e.jsxs(z,{children:[e.jsx(L,{children:"Sort by:"}),e.jsx(L,{display:"inline-block",children:O.current})]})}),e.jsx(te,{children:e.jsx(Ue,{value:O.current,type:"radio",onChange:x=>ne(x),children:[J.RECENTLY_MODIFIED,J.OLDEST_MODIFIED,J.AZ,J.ZA].map((x,I)=>e.jsx(be,{value:x,children:x},I))})})]})]}),e.jsx(Lt,{searchValue:v,onUpdateSearchValue:E}),e.jsx(Z,{overflowY:"auto",overflowX:"hidden",direction:"column",style:{overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsx(qe,{items:r})})]})]})})})}export{Ss as default}; diff --git a/dist/workspace_web/ShareDialog-7hYnIR9_.js b/dist/workspace_web/ShareDialog-7hYnIR9_.js deleted file mode 100644 index 15bd4a9..0000000 --- a/dist/workspace_web/ShareDialog-7hYnIR9_.js +++ /dev/null @@ -1 +0,0 @@ -import{f as te,n as ge,o as we,j as e,g as ae,e as ne,r as u,m as xe,w as X,b as je,h as z,a0 as Z,M as ve,N as ye,O as be,Q as ke,S as Se}from"./input.js";import{B as Ce,A as Ie,a4 as De,g as T,H as A,ac as Re,a3 as R,af as M,am as Ee,az as ee,X as Ne,f as Pe,F as oe,aE as Te,j as Oe,k as se,x as _,$ as We,aF as _e,aG as Fe,aH as Me,aI as ze,h as Le,T as Ae,aJ as Ge,Y as He}from"./App-rR1IBjvq.js";import{I as $e}from"./chunk-7D6N5TE5-QyxxCI30.js";import{a as Be}from"./civitUtils-7bf079LQ.js";import{S as Ue,L as Ve}from"./chunk-VTV6N5LE-KWHHQVVF.js";import{I as Je}from"./IconCopy-KNYgQ4PQ.js";var re=te(function(i,l){const r=ge("Badge",i),{className:t,...o}=we(i);return e.jsx(ae.span,{ref:l,className:ne("chakra-badge",i.className),...o,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});re.displayName="Badge";function Ke(s){return s&&X(s)&&X(s.target)}function qe(s={}){const{onChange:i,value:l,defaultValue:r,name:t,isDisabled:o,isFocusable:f,isNative:y,...d}=s,[b,v]=u.useState(r||""),p=typeof l<"u",w=p?l:b,x=u.useRef(null),a=u.useCallback(()=>{const m=x.current;if(!m)return;let g="input:not(:disabled):checked";const O=m.querySelector(g);if(O){O.focus();return}g="input:not(:disabled)";const E=m.querySelector(g);E==null||E.focus()},[]),j=`radio-${u.useId()}`,h=t||j,C=u.useCallback(m=>{const g=Ke(m)?m.target.value:m;p||v(g),i==null||i(String(g))},[i,p]),k=u.useCallback((m={},g=null)=>({...m,ref:xe(g,x),role:"radiogroup"}),[]),L=u.useCallback((m={},g=null)=>({...m,ref:g,name:h,[y?"checked":"isChecked"]:w!=null?m.value===w:void 0,onChange(E){C(E)},"data-radiogroup":!0}),[y,h,C,w]);return{getRootProps:k,getRadioProps:L,name:h,ref:x,focus:a,setValue:v,value:w,onChange:C,isDisabled:o,isFocusable:f,htmlProps:d}}var[Ye,lo]=je({name:"RadioGroupContext",strict:!1}),ie=te((s,i)=>{const{colorScheme:l,size:r,variant:t,children:o,className:f,isDisabled:y,isFocusable:d,...b}=s,{value:v,onChange:p,getRootProps:w,name:x,htmlProps:a}=qe(b),I=u.useMemo(()=>({name:x,size:r,onChange:p,colorScheme:l,value:v,variant:t,isDisabled:y,isFocusable:d}),[x,r,p,l,v,t,y,d]);return e.jsx(Ye,{value:I,children:e.jsx(ae.div,{...w(a,i),className:ne("chakra-radio-group",f),children:o})})});ie.displayName="RadioGroup";function Qe({options:s,value:i,onChange:l}){const[r,t]=u.useState(!1),o=u.useRef(null),f=s.find(d=>d.value===i);u.useEffect(()=>{const d=b=>{o.current&&!o.current.contains(b.target)&&t(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[o]);const y=()=>t(!r);return e.jsxs(Ce,{position:"relative",children:[e.jsx(z,{onClick:y,rightIcon:e.jsx(Ie,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),r&&e.jsx(De,{gap:4,ref:o,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:s.map(d=>e.jsx(z,{onClick:()=>{t(!1),l(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Xe({deps:s,uploadingImage:i}){const l=Object.values((s==null?void 0:s.images)??{});return s?e.jsx(T,{gap:5,children:l.length>0&&e.jsxs(T,{children:[e.jsxs(A,{children:[e.jsxs(Re,{size:"sm",children:["Images (",l.length,")"]}),e.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&e.jsxs("span",{children:[e.jsx(Z,{size:"md",color:"teal.400"})," Uploading"]}),l.map(r=>e.jsxs(T,{children:[e.jsx("p",{children:r.filename}),e.jsx($e,{width:250,src:`/workspace/view_media?filename=${r.filename}&isPreview=true&isInput=true`})]},r.filename))]})}):e.jsx(Z,{size:"md",color:"teal.400"})}async function Ze(s,i,l){const r=await Ee.models.where("fileName").equals(s).toArray()??[];console.log("fetch modeldata",r);const t=r.at(0);return{name:s,nodeType:i,hash:(t==null?void 0:t.fileHash)??null,folder:(t==null?void 0:t.fileFolder)??null,url:t!=null&&t.civitModelVersionID?Be(t.civitModelVersionID):(t==null?void 0:t.downloadUrl)??null,inputName:l,length:r.length}}async function eo(s){var w,x;let i=[],l={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],t=[".jpeg",".jpg",".png",".gif",".webp"],o=(x=(w=R.graph.extra)==null?void 0:w[M])==null?void 0:x.deps,f=await R.graphToPrompt();Object.values(f.output).forEach(a=>{a.inputs&&Object.keys(a.inputs).forEach(I=>{var h,C;const j=(h=a.inputs)==null?void 0:h[I];typeof j=="string"&&(r.some(k=>j.endsWith(k))&&i.push(Ze(j,a.class_type,I)),t.some(k=>j.endsWith(k))&&(l[j]=((C=o==null?void 0:o.images)==null?void 0:C[j])??{filename:j,nodeType:a.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:s.map(a=>a.type)})}).then(a=>a.ok?a.json():[]).catch(a=>(console.error("Error fetching node repos",a),[])),b=await Promise.all(i),v={};b.forEach(a=>{v[a.name]=a});const p={};return Object.values(d).forEach(a=>{p[a.gitRepo]=a}),{models:v,images:l,nodeRepos:Object.values(p)}}function co({onClose:s}){var G,H,$,B,U;const[i,l,r]=ee("v"+oo()),{saveCurWorkflow:t}=u.useContext(Ne),[o,f]=u.useState(),[y,d]=u.useState(!1),[b,v]=u.useState(!1),p=(H=(G=se)==null?void 0:G.settings)==null?void 0:H.cloudHost,[w,x,a]=ee("PRIVATE"),[I,j]=u.useState("new_version"),h=($=_)==null?void 0:$.curWorkflow,C=Pe(),[k,L]=u.useState(!0),m=async n=>{var P;const c=n.data;if(c.type!=="share_workflow_success")return;const D=c.localWorkflowID,N=c.version.id,S=c.version.workflowID;S&&D&&await((P=_)==null?void 0:P.updateMetaInfo(D,{cloudID:S,privacy:a.current})),g(),window.open(p+"/workflow/"+S+"/"+N,"_blank"),v(!1)};u.useEffect(()=>{g();const n=R.graph.serialize();return eo(n.nodes??[]).then(c=>{f(c)}),window.addEventListener("message",m),()=>{window.removeEventListener("message",m)}},[]);const g=async()=>{h!=null&&h.cloudID&&h.cloudOrigin&&ze(h).then(n=>{x(n)})},O=n=>{navigator.clipboard.writeText(n).then(()=>{C({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},E=async n=>{var K,q,Y;const c=R.graph.serialize();(K=c.extra||(c.extra={}))[q=M]||(K[q]={}),c.extra[M].deps={models:(o==null?void 0:o.models)??{},images:n??{},nodeRepos:(o==null?void 0:o.nodeRepos)??[]},await t();const D=await R.graphToPrompt(R.graph).then(W=>(c.extra[M].apiPrompt=W.output,W.output)),N=JSON.stringify(c);v(!0);const S=_e(32),P=await((Y=se)==null?void 0:Y.getSetting("cloudHost"));let V;V=Fe();const ce={id:Me(),workflowID:h.id,name:r.current,createTime:Date.now(),api_prompt:JSON.stringify(D),json:N??JSON.stringify(R.graph.serialize())},de=window.location.protocol,ue=window.location.host,pe=`${de}//${ue}`,he=P+`/share_workflow_confirm/${S}?redirectUrl=${pe}`,fe=window.open(he,"Share Workflow","width=800,height=800"),J=W=>{var Q;if(W.origin===P&&W.data==="child_ready"){const me=(Q=_)==null?void 0:Q.curWorkflow;fe.postMessage({workflow:me,version:ce,nodeDefs:V,privacy:a.current},P),window.removeEventListener("message",J)}};window.addEventListener("message",J)},le=async()=>{const n=(o==null?void 0:o.images)??{};if(k){d(!0);const c=Object.values((o==null?void 0:o.images)??{}).map(D=>D.filename);if(c.length){const N=await(await We("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(N).forEach(S=>{n!=null&&n[S]&&(n[S].url=N[S])})}d(!1)}E(n)},F=(U=(B=_)==null?void 0:B.curWorkflow)==null?void 0:U.cloudID;return e.jsxs(ve,{isOpen:!0,onClose:s,size:"lg",children:[e.jsx(ye,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ke,{children:[e.jsxs(oe,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',h==null?void 0:h.name,'"']}),e.jsx(z,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:b,children:b?"Sharing":"Share"})]}),p&&e.jsxs(Le,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(p).host]})]}),e.jsx(Se,{pb:10,children:e.jsxs(T,{gap:5,children:[F==null?e.jsx(Qe,{options:Te,value:w,onChange:n=>{x(n)}}):e.jsx(Ae,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ge,{privacy:w,showEmoji:!0})}),F&&e.jsxs(A,{spacing:2,color:"teal.400",children:[e.jsxs(Ve,{wordBreak:"break-all",href:p+"/workflow/"+F,isExternal:!0,children:[p+"/workflow/"+F," ",e.jsx(He,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(z,{size:"sm",leftIcon:e.jsx(Je,{size:18}),onClick:()=>{var n,c;O(p+"/workflow/"+((c=(n=_)==null?void 0:n.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:n=>{j(n)},value:I,children:e.jsx(T,{children:e.jsxs(A,{mb:5,alignItems:"center",children:[e.jsx(Oe,{value:i,width:"60%",onFocus:()=>{j("new_version")},onChange:n=>{l(n.target.value)}}),e.jsx(oe,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((o==null?void 0:o.images)??{}).length>0&&e.jsxs(T,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Ue,{isChecked:k,onChange:()=>L(!k),fontWeight:"600",children:"Share input images"}),e.jsxs("span",{style:{color:"GrayText"},children:["If enabled your input images will be uploaded and shared to"," ",p]}),k&&e.jsx(Xe,{deps:o??null,setDeps:f,uploadingImage:y})]})]})})]})]})}function oo(){const s=new Date,i=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),r=String(s.getDate()).padStart(2,"0");return`${i}-${l}-${r}`}export{co as default}; diff --git a/dist/workspace_web/ShareDialog-opv28tSj.js b/dist/workspace_web/ShareDialog-opv28tSj.js new file mode 100644 index 0000000..1d13141 --- /dev/null +++ b/dist/workspace_web/ShareDialog-opv28tSj.js @@ -0,0 +1 @@ +import{f as te,n as ge,o as we,j as e,g as ae,e as ne,r as u,m as xe,w as Z,b as je,h as z,a0 as X,M as ve,N as ye,O as be,Q as ke,S as Se}from"./input.js";import{B as Ce,A as Ie,a5 as De,g as T,H as L,ad as Re,a4 as R,ag as M,an as Ee,aA as ee,Y as Ne,f as Pe,F as se,aF as Te,j as Oe,k as oe,x as _,a0 as We,aG as _e,aH as Fe,aI as Me,aJ as ze,h as Ae,T as Le,aK as Ge,Z as He}from"./App-HFfBS8qf.js";import{I as Be}from"./chunk-7D6N5TE5-Bj67hFEP.js";import{a as Ue}from"./civitUtils-Ao2r5rP5.js";import{S as Ve,L as $e}from"./chunk-VTV6N5LE-iPEvTIe2.js";import{I as Je}from"./IconCopy-pJEV5GIP.js";var re=te(function(r,i){const l=ge("Badge",r),{className:t,...s}=we(r);return e.jsx(ae.span,{ref:i,className:ne("chakra-badge",r.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...l}})});re.displayName="Badge";function Ke(o){return o&&Z(o)&&Z(o.target)}function qe(o={}){const{onChange:r,value:i,defaultValue:l,name:t,isDisabled:s,isFocusable:f,isNative:y,...d}=o,[b,v]=u.useState(l||""),p=typeof i<"u",w=p?i:b,x=u.useRef(null),a=u.useCallback(()=>{const m=x.current;if(!m)return;let g="input:not(:disabled):checked";const O=m.querySelector(g);if(O){O.focus();return}g="input:not(:disabled)";const E=m.querySelector(g);E==null||E.focus()},[]),j=`radio-${u.useId()}`,h=t||j,C=u.useCallback(m=>{const g=Ke(m)?m.target.value:m;p||v(g),r==null||r(String(g))},[r,p]),k=u.useCallback((m={},g=null)=>({...m,ref:xe(g,x),role:"radiogroup"}),[]),A=u.useCallback((m={},g=null)=>({...m,ref:g,name:h,[y?"checked":"isChecked"]:w!=null?m.value===w:void 0,onChange(E){C(E)},"data-radiogroup":!0}),[y,h,C,w]);return{getRootProps:k,getRadioProps:A,name:h,ref:x,focus:a,setValue:v,value:w,onChange:C,isDisabled:s,isFocusable:f,htmlProps:d}}var[Ye,ls]=je({name:"RadioGroupContext",strict:!1}),ie=te((o,r)=>{const{colorScheme:i,size:l,variant:t,children:s,className:f,isDisabled:y,isFocusable:d,...b}=o,{value:v,onChange:p,getRootProps:w,name:x,htmlProps:a}=qe(b),I=u.useMemo(()=>({name:x,size:l,onChange:p,colorScheme:i,value:v,variant:t,isDisabled:y,isFocusable:d}),[x,l,p,i,v,t,y,d]);return e.jsx(Ye,{value:I,children:e.jsx(ae.div,{...w(a,r),className:ne("chakra-radio-group",f),children:s})})});ie.displayName="RadioGroup";function Qe({options:o,value:r,onChange:i}){const[l,t]=u.useState(!1),s=u.useRef(null),f=o.find(d=>d.value===r);u.useEffect(()=>{const d=b=>{s.current&&!s.current.contains(b.target)&&t(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]);const y=()=>t(!l);return e.jsxs(Ce,{position:"relative",children:[e.jsx(z,{onClick:y,rightIcon:e.jsx(Ie,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),l&&e.jsx(De,{gap:4,ref:s,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:o.map(d=>e.jsx(z,{onClick:()=>{t(!1),i(d.value)},leftIcon:d.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:d.label},d.label))})]})}function Ze({deps:o,uploadingImage:r}){const i=Object.values((o==null?void 0:o.images)??{});return o?e.jsx(T,{gap:5,children:i.length>0&&e.jsxs(T,{children:[e.jsxs(L,{children:[e.jsxs(Re,{size:"sm",children:["Images (",i.length,")"]}),e.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),r&&e.jsxs("span",{children:[e.jsx(X,{size:"md",color:"teal.400"})," Uploading"]}),i.map(l=>e.jsxs(T,{children:[e.jsx("p",{children:l.filename}),e.jsx(Be,{width:250,src:`/workspace/view_media?filename=${l.filename}&isPreview=true&isInput=true`})]},l.filename))]})}):e.jsx(X,{size:"md",color:"teal.400"})}async function Xe(o,r,i){const l=await Ee.models.where("fileName").equals(o).toArray()??[],t=l.at(0);return{name:o,nodeType:r,hash:(t==null?void 0:t.fileHash)??null,folder:(t==null?void 0:t.fileFolder)??null,url:t!=null&&t.civitModelVersionID?Ue(t.civitModelVersionID):(t==null?void 0:t.downloadUrl)??null,inputName:i,length:l.length}}async function es(o){var w,x;let r=[],i={};const l=[".ckpt",".pt",".bin",".pth",".safetensors"],t=[".jpeg",".jpg",".png",".gif",".webp"],s=(x=(w=R.graph.extra)==null?void 0:w[M])==null?void 0:x.deps,f=await R.graphToPrompt();Object.values(f.output).forEach(a=>{a.inputs&&Object.keys(a.inputs).forEach(I=>{var h,C;const j=(h=a.inputs)==null?void 0:h[I];typeof j=="string"&&(l.some(k=>j.endsWith(k))&&r.push(Xe(j,a.class_type,I)),t.some(k=>j.endsWith(k))&&(i[j]=((C=s==null?void 0:s.images)==null?void 0:C[j])??{filename:j,nodeType:a.class_type}))})});const d=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:o.map(a=>a.type)})}).then(a=>a.ok?a.json():[]).catch(a=>(console.error("Error fetching node repos",a),[])),b=await Promise.all(r),v={};b.forEach(a=>{v[a.name]=a});const p={};return Object.values(d).forEach(a=>{p[a.gitRepo]=a}),{models:v,images:i,nodeRepos:Object.values(p)}}function cs({onClose:o}){var G,H,B,U,V;const[r,i,l]=ee("v"+ss()),{saveCurWorkflow:t}=u.useContext(Ne),[s,f]=u.useState(),[y,d]=u.useState(!1),[b,v]=u.useState(!1),p=(H=(G=oe)==null?void 0:G.settings)==null?void 0:H.cloudHost,[w,x,a]=ee("PRIVATE"),[I,j]=u.useState("new_version"),h=(B=_)==null?void 0:B.curWorkflow,C=Pe(),[k,A]=u.useState(!0),m=async n=>{var P;const c=n.data;if(c.type!=="share_workflow_success")return;const D=c.localWorkflowID,N=c.version.id,S=c.version.workflowID;S&&D&&await((P=_)==null?void 0:P.updateMetaInfo(D,{cloudID:S,privacy:a.current})),g(),window.open(p+"/workflow/"+S+"/"+N,"_blank"),v(!1)};u.useEffect(()=>{g();const n=R.graph.serialize();return es(n.nodes??[]).then(c=>{f(c)}),window.addEventListener("message",m),()=>{window.removeEventListener("message",m)}},[]);const g=async()=>{h!=null&&h.cloudID&&h.cloudOrigin&&ze(h).then(n=>{x(n)})},O=n=>{navigator.clipboard.writeText(n).then(()=>{C({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},E=async n=>{var K,q,Y;const c=R.graph.serialize();(K=c.extra||(c.extra={}))[q=M]||(K[q]={}),c.extra[M].deps={models:(s==null?void 0:s.models)??{},images:n??{},nodeRepos:(s==null?void 0:s.nodeRepos)??[]},await t();const D=await R.graphToPrompt(R.graph).then(W=>(c.extra[M].apiPrompt=W.output,W.output)),N=JSON.stringify(c);v(!0);const S=_e(32),P=await((Y=oe)==null?void 0:Y.getSetting("cloudHost"));let $;$=Fe();const ce={id:Me(),workflowID:h.id,name:l.current,createTime:Date.now(),api_prompt:JSON.stringify(D),json:N??JSON.stringify(R.graph.serialize())},de=window.location.protocol,ue=window.location.host,pe=`${de}//${ue}`,he=P+`/share_workflow_confirm/${S}?redirectUrl=${pe}`,fe=window.open(he,"Share Workflow","width=800,height=800"),J=W=>{var Q;if(W.origin===P&&W.data==="child_ready"){const me=(Q=_)==null?void 0:Q.curWorkflow;fe.postMessage({workflow:me,version:ce,nodeDefs:$,privacy:a.current},P),window.removeEventListener("message",J)}};window.addEventListener("message",J)},le=async()=>{const n=(s==null?void 0:s.images)??{};if(k){d(!0);const c=Object.values((s==null?void 0:s.images)??{}).map(D=>D.filename);if(c.length){const N=await(await We("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:c})})).json();Object.keys(N).forEach(S=>{n!=null&&n[S]&&(n[S].url=N[S])})}d(!1)}E(n)},F=(V=(U=_)==null?void 0:U.curWorkflow)==null?void 0:V.cloudID;return e.jsxs(ve,{isOpen:!0,onClose:o,size:"lg",children:[e.jsx(ye,{}),e.jsxs(be,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ke,{children:[e.jsxs(se,{justifyContent:"space-between",children:[e.jsxs("p",{children:['Share "',h==null?void 0:h.name,'"']}),e.jsx(z,{colorScheme:"teal",onClick:le,size:"sm",isDisabled:b,children:b?"Sharing":"Share"})]}),p&&e.jsxs(Ae,{fontSize:16,color:"GrayText",fontWeight:400,children:["Share to ",new URL(p).host]})]}),e.jsx(Se,{pb:10,children:e.jsxs(T,{gap:5,children:[F==null?e.jsx(Qe,{options:Te,value:w,onChange:n=>{x(n)}}):e.jsx(Le,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ge,{privacy:w,showEmoji:!0})}),F&&e.jsxs(L,{spacing:2,color:"teal.400",children:[e.jsxs($e,{wordBreak:"break-all",href:p+"/workflow/"+F,isExternal:!0,children:[p+"/workflow/"+F," ",e.jsx(He,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(z,{size:"sm",leftIcon:e.jsx(Je,{size:18}),onClick:()=>{var n,c;O(p+"/workflow/"+((c=(n=_)==null?void 0:n.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(ie,{gap:4,onChange:n=>{j(n)},value:I,children:e.jsx(T,{children:e.jsxs(L,{mb:5,alignItems:"center",children:[e.jsx(Oe,{value:r,width:"60%",onFocus:()=>{j("new_version")},onChange:n=>{i(n.target.value)}}),e.jsx(se,{color:"green",children:e.jsx(re,{colorScheme:"purple",children:"Version Name"})})]})})}),Object.keys((s==null?void 0:s.images)??{}).length>0&&e.jsxs(T,{borderRadius:6,borderWidth:"1px",p:2,children:[e.jsx(Ve,{isChecked:k,onChange:()=>A(!k),fontWeight:"600",children:"Share input images"}),e.jsxs("span",{style:{color:"GrayText"},children:["If enabled your input images will be uploaded and shared to"," ",p]}),k&&e.jsx(Ze,{deps:s??null,setDeps:f,uploadingImage:y})]})]})})]})]})}function ss(){const o=new Date,r=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),l=String(o.getDate()).padStart(2,"0");return`${r}-${i}-${l}`}export{cs as default}; diff --git a/dist/workspace_web/SpotlightSearch-z3bKfoPZ.js b/dist/workspace_web/SpotlightSearch-NM7L9eNM.js similarity index 74% rename from dist/workspace_web/SpotlightSearch-z3bKfoPZ.js rename to dist/workspace_web/SpotlightSearch-NM7L9eNM.js index 828a788..6d24e20 100644 --- a/dist/workspace_web/SpotlightSearch-z3bKfoPZ.js +++ b/dist/workspace_web/SpotlightSearch-NM7L9eNM.js @@ -1 +1 @@ -import{b as X,f as L,k as Z,o as $,e as w,r as g,j as n,g as A,Z as q,M as J,O as Q,a0 as ee,h as te}from"./input.js";import{aD as ne,aj as se,X as re,az as T,ag as D,H as ae,j as oe,h as G,a1 as ie,x as ce,a2 as le,E as ue,k as O}from"./App-rR1IBjvq.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-6vngoIPw.js";import{V as he}from"./chunk-NTCQBYKE-PRXQGfLv.js";var[me,ge]=X({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=L(function(a,u){const r=Z("Input",a),{children:c,className:l,...I}=$(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=L(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=L(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=L(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function Ie(){const{colorMode:S}=q(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},H=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[U,W]=pe(H,300),V=e=>{I(e.target.value),e.target.value?(U(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(G,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(G,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=O)==null||k.getSetting("shortcuts").then(h=>{var F;const j=(h.openSpotlightSearch??((F=O)==null?void 0:F.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=j[0]==="Command"?"Meta":j[0],v.current.spotlightSearchShortcutLastKey=j[j.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(D,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(D,d)}},[]),n.jsx(J,{isOpen:!0,onClose:z,size:"xl",children:n.jsxs(Q,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{Ie as default}; +import{b as Z,f as j,k as $,o as q,e as w,r as g,j as n,g as A,Z as J,M as Q,O as X,a0 as ee,h as te}from"./input.js";import{aE as ne,ak as se,Y as re,aA as T,ah as G,H as ae,j as oe,h as O,a2 as ie,x as ce,a3 as le,E as ue,k as D}from"./App-HFfBS8qf.js";import{u as pe}from"./useDebounceFn-ld478fd0.js";import{I as de}from"./IconSearch-w32ReMy0.js";import{V as he}from"./chunk-NTCQBYKE-hyXDv1Bs.js";var[me,ge]=Z({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),M=j(function(a,u){const r=$("Input",a),{children:c,className:l,...I}=q(a),x=w("chakra-input__group",l),t={},E=ne(c),o=r.field;E.forEach(s=>{var p,y;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(y=o.height)!=null?y:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const f=E.map(s=>{var p,y;const R=se({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((y=s.props)==null?void 0:y.variant)||a.variant});return s.type.id!=="Input"?g.cloneElement(s,R):g.cloneElement(s,Object.assign(R,t,s.props))});return n.jsx(A.div,{className:x,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(me,{value:r,children:f})})});M.displayName="InputGroup";var Se=A("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,x=ge(),t=x.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...x.element};return n.jsx(Se,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var P=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});P.id="InputLeftElement";P.displayName="InputLeftElement";var K=j(function(a,u){const{className:r,...c}=a,l=w("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});K.id="InputRightElement";K.displayName="InputRightElement";function Ie(){const{colorMode:S}=J(),{loadWorkflowID:a,setRoute:u}=g.useContext(re),[r,c]=g.useState([]),[l,I,x]=T(""),t=g.useRef([]),[E,o,f]=T([]),[s,p]=g.useState(!1),[y,R,b]=T(0),v=g.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),z=()=>{u("root")},_=e=>{a(e.id),z()},H=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(x.current.toLocaleLowerCase()));o(e),R(0),p(!1)},[U,W]=pe(H,300),V=e=>{I(e.target.value),e.target.value?(U(),!s&&p(!0)):(p(!1),W(),o(t.current))},B=()=>s?null:l&&E.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:E.map((e,i)=>n.jsxs(te,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:S==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===y,children:[e.name,e.updateTime&&n.jsxs(O,{color:S==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ie(e.updateTime)]})]},e.id))}),Y=async()=>{var k;const e=h=>h.map(m=>({type:"workflow",updateTime:(m==null?void 0:m.updateTime)??Date.now(),id:m.id,name:m.name.replace(/\.json$/,"")}))??[],i=await((k=ce)==null?void 0:k.listAll(le.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},N=e=>{R(i=>{const d=i+e;return d<0?f.current.length-1:d>f.current.length-1?0:d})};return g.useEffect(()=>{var k;Y(),(k=D)==null||k.getSetting("shortcuts").then(h=>{var F;const L=(h.openSpotlightSearch??((F=D)==null?void 0:F.defaultSettings.shortcuts.openSpotlightSearch)).split("+");v.current.spotlightSearchShortcutFirstKey=L[0]==="Command"?"Meta":L[0],v.current.spotlightSearchShortcutLastKey=L[L.length-1]});const e=h=>{h.key===v.current.spotlightSearchShortcutFirstKey&&v.current.lastPressedKey===v.current.spotlightSearchShortcutLastKey&&b.current>0&&f.current[b.current]&&_(f.current[b.current])},i=h=>{const m=h.key.toUpperCase();switch(v.current.lastPressedKey=m,m){case"ARROWDOWN":N(1);break;case"ARROWUP":N(-1);break;case"ENTER":_(f.current[b.current]);break}},d=h=>{switch(h.detail.shortcutType){case ue.openSpotlightSearch:N(1);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(G,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(G,d)}},[]),n.jsx(Q,{isOpen:!0,onClose:z,size:"xl",children:n.jsxs(X,{bg:S==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(ae,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(de,{size:20}),n.jsxs(M,{children:[n.jsx(oe,{value:l,onChange:V,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(K,{h:"27px",children:n.jsx(ee,{size:"sm"})})]})]}),n.jsx(he,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:B()})]})})}export{Ie as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-yfOR3kNT.js b/dist/workspace_web/chunk-3RSXBRAN-Ge4h6OPg.js similarity index 81% rename from dist/workspace_web/chunk-3RSXBRAN-yfOR3kNT.js rename to dist/workspace_web/chunk-3RSXBRAN-Ge4h6OPg.js index 735e714..70fc991 100644 --- a/dist/workspace_web/chunk-3RSXBRAN-yfOR3kNT.js +++ b/dist/workspace_web/chunk-3RSXBRAN-Ge4h6OPg.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,a3 as P}from"./input.js";import{aa as z}from"./App-rR1IBjvq.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 w,k as C,o as E,l as I,r as f,a3 as P}from"./input.js";import{ab as z}from"./App-HFfBS8qf.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:w("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},b={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:b,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; diff --git a/dist/workspace_web/chunk-7D6N5TE5-QyxxCI30.js b/dist/workspace_web/chunk-7D6N5TE5-Bj67hFEP.js similarity index 98% rename from dist/workspace_web/chunk-7D6N5TE5-QyxxCI30.js rename to dist/workspace_web/chunk-7D6N5TE5-Bj67hFEP.js index ecdee5f..012bed0 100644 --- a/dist/workspace_web/chunk-7D6N5TE5-QyxxCI30.js +++ b/dist/workspace_web/chunk-7D6N5TE5-Bj67hFEP.js @@ -1 +1 @@ -import{f as ce,j as W,r as i,y as A,g as oe,d as T,x as ye,l as r,q as m,m as re}from"./input.js";import{ae as pe}from"./App-rR1IBjvq.js";var z=ce(function(n,t){const{htmlWidth:o,htmlHeight:d,alt:l,...v}=n;return W.jsx("img",{width:o,height:d,ref:t,alt:l,...v})});z.displayName="NativeImage";function Ee(e){const{loading:n,src:t,srcSet:o,onLoad:d,onError:l,crossOrigin:v,sizes:w,ignoreFallback:L}=e,[h,k]=i.useState("pending");i.useEffect(()=>{k(t?"loading":"pending")},[t]);const f=i.useRef(),I=i.useCallback(()=>{if(!t)return;y();const s=new Image;s.src=t,v&&(s.crossOrigin=v),o&&(s.srcset=o),w&&(s.sizes=w),n&&(s.loading=n),s.onload=p=>{y(),k("loaded"),d==null||d(p)},s.onerror=p=>{y(),k("failed"),l==null||l(p)},f.current=s},[t,v,o,w,d,l,n]),y=()=>{f.current&&(f.current.onload=null,f.current.onerror=null,f.current=null)};return A(()=>{if(!L)return h==="loading"&&I(),()=>{y()}},[h,I,L]),L?"loaded":h}var we=(e,n)=>e!=="loaded"&&n==="beforeLoadOrError"||e==="failed"&&n==="onError";function Le(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}var Ce=ce(function(n,t){const{fallbackSrc:o,fallback:d,src:l,srcSet:v,align:w,fit:L,loading:h,ignoreFallback:k,crossOrigin:f,fallbackStrategy:I="beforeLoadOrError",referrerPolicy:y,...s}=n,p=o!==void 0||d!==void 0,P=h!=null||k||!p,B=Ee({...n,crossOrigin:f,ignoreFallback:P}),K=we(B,I),D={ref:t,objectFit:L,objectPosition:w,...P?s:Le(s,["onError","onLoad"])};return K?d||W.jsx(oe.img,{as:z,className:"chakra-image__placeholder",src:o,...D}):W.jsx(oe.img,{as:z,src:l,srcSet:v,crossOrigin:f,loading:h,referrerPolicy:y,className:"chakra-image",...D})});Ce.displayName="Image";var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Fe=()=>typeof document<"u",se=!1,M=null,C=!1,$=!1,G=new Set;function J(e,n){G.forEach(t=>t(e,n))}var Se=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function Pe(e){return!(e.metaKey||!Se&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ie(e){C=!0,Pe(e)&&(M="keyboard",J("keyboard",e))}function S(e){if(M="pointer",e.type==="mousedown"||e.type==="pointerdown"){C=!0;const n=e.composedPath?e.composedPath()[0]:e.target;let t=!1;try{t=n.matches(":focus-visible")}catch{}if(t)return;J("pointer",e)}}function De(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Re(e){De(e)&&(C=!0,M="virtual")}function xe(e){e.target===window||e.target===document||(!C&&!$&&(M="virtual",J("virtual",e)),C=!1,$=!1)}function Me(){C=!1,$=!0}function le(){return M!=="pointer"}function Be(){if(!Fe()||se)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...t){C=!0,e.apply(this,t)},document.addEventListener("keydown",ie,!0),document.addEventListener("keyup",ie,!0),document.addEventListener("click",Re,!0),window.addEventListener("focus",xe,!0),window.addEventListener("blur",Me,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",S,!0),document.addEventListener("pointermove",S,!0),document.addEventListener("pointerup",S,!0)):(document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",S,!0),document.addEventListener("mouseup",S,!0)),se=!0}function Ke(e){Be(),e(le());const n=()=>e(le());return G.add(n),()=>{G.delete(n)}}function Oe(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}function Ue(e={}){const n=pe(e),{isDisabled:t,isReadOnly:o,isRequired:d,isInvalid:l,id:v,onBlur:w,onFocus:L,"aria-describedby":h}=n,{defaultChecked:k,isChecked:f,isFocusable:I,onChange:y,isIndeterminate:s,name:p,value:P,tabIndex:B=void 0,"aria-label":K,"aria-labelledby":D,"aria-invalid":U,...de}=e,V=Oe(de,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),q=T(y),Q=T(w),X=T(L),[O,ue]=i.useState(!1),[E,j]=i.useState(!1),[R,Y]=i.useState(!1),[x,F]=i.useState(!1);i.useEffect(()=>Ke(ue),[]);const b=i.useRef(null),[Z,fe]=i.useState(!0),[me,N]=i.useState(!!k),_=f!==void 0,c=_?f:me,ee=i.useCallback(a=>{if(o||t){a.preventDefault();return}_||N(c?a.target.checked:s?!0:a.target.checked),q==null||q(a)},[o,t,c,_,s,q]);A(()=>{b.current&&(b.current.indeterminate=!!s)},[s]),ye(()=>{t&&j(!1)},[t,j]),A(()=>{const a=b.current;if(!(a!=null&&a.form))return;const u=()=>{N(!!k)};return a.form.addEventListener("reset",u),()=>{var g;return(g=a.form)==null?void 0:g.removeEventListener("reset",u)}},[]);const te=t&&!I,ae=i.useCallback(a=>{a.key===" "&&F(!0)},[F]),ne=i.useCallback(a=>{a.key===" "&&F(!1)},[F]);A(()=>{if(!b.current)return;b.current.checked!==c&&N(b.current.checked)},[b.current]);const ve=i.useCallback((a={},u=null)=>{const g=H=>{E&&H.preventDefault(),F(!0)};return{...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o),"aria-hidden":!0,onMouseDown:m(a.onMouseDown,g),onMouseUp:m(a.onMouseUp,()=>F(!1)),onMouseEnter:m(a.onMouseEnter,()=>Y(!0)),onMouseLeave:m(a.onMouseLeave,()=>Y(!1))}},[x,c,t,E,O,R,s,l,o]),be=i.useCallback((a={},u=null)=>({...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o)}),[x,c,t,E,O,R,s,l,o]),ge=i.useCallback((a={},u=null)=>({...V,...a,ref:re(u,g=>{g&&fe(g.tagName==="LABEL")}),onClick:m(a.onClick,()=>{var g;Z||((g=b.current)==null||g.click(),requestAnimationFrame(()=>{var H;(H=b.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[V,t,c,l,Z]),he=i.useCallback((a={},u=null)=>({...a,ref:re(b,u),type:"checkbox",name:p,value:P,id:v,tabIndex:B,onChange:m(a.onChange,ee),onBlur:m(a.onBlur,Q,()=>j(!1)),onFocus:m(a.onFocus,X,()=>j(!0)),onKeyDown:m(a.onKeyDown,ae),onKeyUp:m(a.onKeyUp,ne),required:d,checked:c,disabled:te,readOnly:o,"aria-label":K,"aria-labelledby":D,"aria-invalid":U?!!U:l,"aria-describedby":h,"aria-disabled":t,style:Ie}),[p,P,v,ee,Q,X,ae,ne,d,c,te,o,K,D,U,l,h,t,B]),ke=i.useCallback((a={},u=null)=>({...a,ref:u,onMouseDown:m(a.onMouseDown,je),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[c,t,l]);return{state:{isInvalid:l,isFocused:E,isChecked:c,isActive:x,isHovered:R,isIndeterminate:s,isDisabled:t,isReadOnly:o,isRequired:d},getRootProps:ge,getCheckboxProps:ve,getIndicatorProps:be,getInputProps:he,getLabelProps:ke,htmlProps:V}}function je(e){e.preventDefault(),e.stopPropagation()}export{Ce as I,Ue as u}; +import{f as ce,j as W,r as i,y as A,g as oe,d as T,x as ye,l as r,q as m,m as re}from"./input.js";import{af as pe}from"./App-HFfBS8qf.js";var z=ce(function(n,t){const{htmlWidth:o,htmlHeight:d,alt:l,...v}=n;return W.jsx("img",{width:o,height:d,ref:t,alt:l,...v})});z.displayName="NativeImage";function Ee(e){const{loading:n,src:t,srcSet:o,onLoad:d,onError:l,crossOrigin:v,sizes:w,ignoreFallback:L}=e,[h,k]=i.useState("pending");i.useEffect(()=>{k(t?"loading":"pending")},[t]);const f=i.useRef(),I=i.useCallback(()=>{if(!t)return;y();const s=new Image;s.src=t,v&&(s.crossOrigin=v),o&&(s.srcset=o),w&&(s.sizes=w),n&&(s.loading=n),s.onload=p=>{y(),k("loaded"),d==null||d(p)},s.onerror=p=>{y(),k("failed"),l==null||l(p)},f.current=s},[t,v,o,w,d,l,n]),y=()=>{f.current&&(f.current.onload=null,f.current.onerror=null,f.current=null)};return A(()=>{if(!L)return h==="loading"&&I(),()=>{y()}},[h,I,L]),L?"loaded":h}var we=(e,n)=>e!=="loaded"&&n==="beforeLoadOrError"||e==="failed"&&n==="onError";function Le(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}var Ce=ce(function(n,t){const{fallbackSrc:o,fallback:d,src:l,srcSet:v,align:w,fit:L,loading:h,ignoreFallback:k,crossOrigin:f,fallbackStrategy:I="beforeLoadOrError",referrerPolicy:y,...s}=n,p=o!==void 0||d!==void 0,P=h!=null||k||!p,B=Ee({...n,crossOrigin:f,ignoreFallback:P}),K=we(B,I),D={ref:t,objectFit:L,objectPosition:w,...P?s:Le(s,["onError","onLoad"])};return K?d||W.jsx(oe.img,{as:z,className:"chakra-image__placeholder",src:o,...D}):W.jsx(oe.img,{as:z,src:l,srcSet:v,crossOrigin:f,loading:h,referrerPolicy:y,className:"chakra-image",...D})});Ce.displayName="Image";var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Fe=()=>typeof document<"u",se=!1,M=null,C=!1,$=!1,G=new Set;function J(e,n){G.forEach(t=>t(e,n))}var Se=typeof window<"u"&&window.navigator!=null?/^Mac/.test(window.navigator.platform):!1;function Pe(e){return!(e.metaKey||!Se&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ie(e){C=!0,Pe(e)&&(M="keyboard",J("keyboard",e))}function S(e){if(M="pointer",e.type==="mousedown"||e.type==="pointerdown"){C=!0;const n=e.composedPath?e.composedPath()[0]:e.target;let t=!1;try{t=n.matches(":focus-visible")}catch{}if(t)return;J("pointer",e)}}function De(e){return e.mozInputSource===0&&e.isTrusted?!0:e.detail===0&&!e.pointerType}function Re(e){De(e)&&(C=!0,M="virtual")}function xe(e){e.target===window||e.target===document||(!C&&!$&&(M="virtual",J("virtual",e)),C=!1,$=!1)}function Me(){C=!1,$=!0}function le(){return M!=="pointer"}function Be(){if(!Fe()||se)return;const{focus:e}=HTMLElement.prototype;HTMLElement.prototype.focus=function(...t){C=!0,e.apply(this,t)},document.addEventListener("keydown",ie,!0),document.addEventListener("keyup",ie,!0),document.addEventListener("click",Re,!0),window.addEventListener("focus",xe,!0),window.addEventListener("blur",Me,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",S,!0),document.addEventListener("pointermove",S,!0),document.addEventListener("pointerup",S,!0)):(document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",S,!0),document.addEventListener("mouseup",S,!0)),se=!0}function Ke(e){Be(),e(le());const n=()=>e(le());return G.add(n),()=>{G.delete(n)}}function Oe(e,n=[]){const t=Object.assign({},e);for(const o of n)o in t&&delete t[o];return t}function Ue(e={}){const n=pe(e),{isDisabled:t,isReadOnly:o,isRequired:d,isInvalid:l,id:v,onBlur:w,onFocus:L,"aria-describedby":h}=n,{defaultChecked:k,isChecked:f,isFocusable:I,onChange:y,isIndeterminate:s,name:p,value:P,tabIndex:B=void 0,"aria-label":K,"aria-labelledby":D,"aria-invalid":U,...de}=e,V=Oe(de,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),q=T(y),Q=T(w),X=T(L),[O,ue]=i.useState(!1),[E,j]=i.useState(!1),[R,Y]=i.useState(!1),[x,F]=i.useState(!1);i.useEffect(()=>Ke(ue),[]);const b=i.useRef(null),[Z,fe]=i.useState(!0),[me,N]=i.useState(!!k),_=f!==void 0,c=_?f:me,ee=i.useCallback(a=>{if(o||t){a.preventDefault();return}_||N(c?a.target.checked:s?!0:a.target.checked),q==null||q(a)},[o,t,c,_,s,q]);A(()=>{b.current&&(b.current.indeterminate=!!s)},[s]),ye(()=>{t&&j(!1)},[t,j]),A(()=>{const a=b.current;if(!(a!=null&&a.form))return;const u=()=>{N(!!k)};return a.form.addEventListener("reset",u),()=>{var g;return(g=a.form)==null?void 0:g.removeEventListener("reset",u)}},[]);const te=t&&!I,ae=i.useCallback(a=>{a.key===" "&&F(!0)},[F]),ne=i.useCallback(a=>{a.key===" "&&F(!1)},[F]);A(()=>{if(!b.current)return;b.current.checked!==c&&N(b.current.checked)},[b.current]);const ve=i.useCallback((a={},u=null)=>{const g=H=>{E&&H.preventDefault(),F(!0)};return{...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o),"aria-hidden":!0,onMouseDown:m(a.onMouseDown,g),onMouseUp:m(a.onMouseUp,()=>F(!1)),onMouseEnter:m(a.onMouseEnter,()=>Y(!0)),onMouseLeave:m(a.onMouseLeave,()=>Y(!1))}},[x,c,t,E,O,R,s,l,o]),be=i.useCallback((a={},u=null)=>({...a,ref:u,"data-active":r(x),"data-hover":r(R),"data-checked":r(c),"data-focus":r(E),"data-focus-visible":r(E&&O),"data-indeterminate":r(s),"data-disabled":r(t),"data-invalid":r(l),"data-readonly":r(o)}),[x,c,t,E,O,R,s,l,o]),ge=i.useCallback((a={},u=null)=>({...V,...a,ref:re(u,g=>{g&&fe(g.tagName==="LABEL")}),onClick:m(a.onClick,()=>{var g;Z||((g=b.current)==null||g.click(),requestAnimationFrame(()=>{var H;(H=b.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[V,t,c,l,Z]),he=i.useCallback((a={},u=null)=>({...a,ref:re(b,u),type:"checkbox",name:p,value:P,id:v,tabIndex:B,onChange:m(a.onChange,ee),onBlur:m(a.onBlur,Q,()=>j(!1)),onFocus:m(a.onFocus,X,()=>j(!0)),onKeyDown:m(a.onKeyDown,ae),onKeyUp:m(a.onKeyUp,ne),required:d,checked:c,disabled:te,readOnly:o,"aria-label":K,"aria-labelledby":D,"aria-invalid":U?!!U:l,"aria-describedby":h,"aria-disabled":t,style:Ie}),[p,P,v,ee,Q,X,ae,ne,d,c,te,o,K,D,U,l,h,t,B]),ke=i.useCallback((a={},u=null)=>({...a,ref:u,onMouseDown:m(a.onMouseDown,je),"data-disabled":r(t),"data-checked":r(c),"data-invalid":r(l)}),[c,t,l]);return{state:{isInvalid:l,isFocused:E,isChecked:c,isActive:x,isHovered:R,isIndeterminate:s,isDisabled:t,isReadOnly:o,isRequired:d},getRootProps:ge,getCheckboxProps:ve,getIndicatorProps:be,getInputProps:he,getLabelProps:ke,htmlProps:V}}function je(e){e.preventDefault(),e.stopPropagation()}export{Ce as I,Ue as u}; diff --git a/dist/workspace_web/chunk-JARCRF6W-J2YFxPIJ.js b/dist/workspace_web/chunk-JARCRF6W-OdkdCK_9.js similarity index 97% rename from dist/workspace_web/chunk-JARCRF6W-J2YFxPIJ.js rename to dist/workspace_web/chunk-JARCRF6W-OdkdCK_9.js index e58d119..9e68198 100644 --- a/dist/workspace_web/chunk-JARCRF6W-J2YFxPIJ.js +++ b/dist/workspace_web/chunk-JARCRF6W-OdkdCK_9.js @@ -1 +1 @@ -import{b as D,r as h,j as t,g as i,$ as v,f as j,k as T,o as $,H as B,e as E}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-QyxxCI30.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=$(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=B(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:E("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G}; +import{b as D,r as h,j as t,g as i,$ as v,f as j,k as T,o as $,H as B,e as E}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-Bj67hFEP.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=$(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=B(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:E("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-PRXQGfLv.js b/dist/workspace_web/chunk-NTCQBYKE-hyXDv1Bs.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-PRXQGfLv.js rename to dist/workspace_web/chunk-NTCQBYKE-hyXDv1Bs.js index 21ba4cb..95e1843 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-PRXQGfLv.js +++ b/dist/workspace_web/chunk-NTCQBYKE-hyXDv1Bs.js @@ -1 +1 @@ -import{g as t}from"./App-rR1IBjvq.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; +import{g as t}from"./App-HFfBS8qf.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/chunk-VTV6N5LE-KWHHQVVF.js b/dist/workspace_web/chunk-VTV6N5LE-iPEvTIe2.js similarity index 95% rename from dist/workspace_web/chunk-VTV6N5LE-KWHHQVVF.js rename to dist/workspace_web/chunk-VTV6N5LE-iPEvTIe2.js index 60cdc53..967166e 100644 --- a/dist/workspace_web/chunk-VTV6N5LE-KWHHQVVF.js +++ b/dist/workspace_web/chunk-VTV6N5LE-iPEvTIe2.js @@ -1 +1 @@ -import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-QyxxCI30.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S}; +import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-Bj67hFEP.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S}; diff --git a/dist/workspace_web/civitUtils-7bf079LQ.js b/dist/workspace_web/civitUtils-Ao2r5rP5.js similarity index 91% rename from dist/workspace_web/civitUtils-7bf079LQ.js rename to dist/workspace_web/civitUtils-Ao2r5rP5.js index 93bd340..eff719d 100644 --- a/dist/workspace_web/civitUtils-7bf079LQ.js +++ b/dist/workspace_web/civitUtils-Ao2r5rP5.js @@ -1 +1 @@ -import{k as m}from"./App-rR1IBjvq.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function g(){return localStorage.getItem(r)}function h(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,g,h as s}; +import{k as m}from"./App-HFfBS8qf.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function g(){return localStorage.getItem(r)}function h(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,g,h as s}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index c3e0e2c..270bbdc 100644 --- a/dist/workspace_web/input.js +++ b/dist/workspace_web/input.js @@ -679,10 +679,10 @@ Error generating stack: `+i.message+` } ${aB} - `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-rR1IBjvq.js").then(e=>e.aK),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({config:{initialColorMode:"dark",useSystemColorMode:!1},zIndices:uB,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{vP as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,xb as U,EB as V,os as W,Ar as X,pB as Y,Qh as Z,Xk as _,kB as a,Tp as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Be as e,pt as f,_e as g,Mx as h,SB as i,E as j,Xb as k,_v as l,If as m,Bu as n,Iu as o,mB as p,Ei as q,S as r,Gf as s,uw as t,IP as u,bB as v,Kt as w,yg as x,Bl as y,uO as z}; + `}),zw=document.createElement("div");document.body.append(zw);const lB=Ar.lazy(()=>Xk(()=>import("./App-HFfBS8qf.js").then(e=>e.aL),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),uB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},cB=Pz({config:{initialColorMode:"dark",useSystemColorMode:!1},zIndices:uB,components:{Card:{baseStyle:e=>({container:{backgroundColor:e.colorMode==="dark"?"#171B21":"#F6F8FA"}})}}});gd.createRoot(zw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(BI,{resetCSS:!1,disableGlobalStyle:!0,theme:cB,children:[E.jsx(sB,{scope:".workspace_manager"}),E.jsx(DP,{initialColorMode:"dark"}),E.jsx(iB,{children:E.jsx(S.Suspense,{children:E.jsx(lB,{})})})]})}));const Hf=document.body,dB={attributes:!0,attributeFilter:["class"]},fB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Hf.classList)o.includes("chakra")&&Hf.classList.remove(o)},hB=new MutationObserver(fB);hB.observe(Hf,dB);export{vP as $,PB as A,CB as B,TB as C,_B as D,TP as E,lr as F,oi as G,vB as H,Ya as I,Ap as J,yB as K,Ka as L,yw as M,Ew as N,_w as O,ja as P,Tw as Q,Aw as R,$w as S,Pw as T,xb as U,EB as V,os as W,Ar as X,pB as Y,Qh as Z,Xk as _,kB as a,Tp as a0,rB as a1,nB as a2,gB as a3,mn as b,wB as c,i3 as d,Be as e,pt as f,_e as g,Mx as h,SB as i,E as j,Xb as k,_v as l,If as m,Bu as n,Iu as o,mB as p,Ei as q,S as r,Gf as s,uw as t,IP as u,bB as v,Kt as w,yg as x,Bl as y,uO as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-rR1IBjvq.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-HFfBS8qf.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file