From 7a17e934967711dfd2ca6e9882cce925d383b826 Mon Sep 17 00:00:00 2001 From: Weixuan Fu Date: Sat, 23 Mar 2024 02:23:06 +0800 Subject: [PATCH 1/2] build civit api change --- dist/workspace_web/App-bqAziDgv.js | 27 ------------------- .../AppIsDirtyEventListener-4vtCCyCS.js | 1 - dist/workspace_web/GalleryModal-mtYV1YJE.js | 2 -- dist/workspace_web/IconCopy-Vm3ws_0T.js | 1 - .../InstallMissingModelsButton-g1lfodpY.js | 1 - dist/workspace_web/MediaPreview-cVvL6fHO.js | 1 - .../ModelManagerTopbar--uE4bw7I.js | 7 ----- .../RecentFilesDrawer-4bh_pwSS.js | 8 ------ dist/workspace_web/ShareDialog-o8m3m3T9.js | 1 - dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js | 1 - dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js | 1 - dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js | 1 - dist/workspace_web/input.js | 4 +-- 13 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 dist/workspace_web/App-bqAziDgv.js delete mode 100644 dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js delete mode 100644 dist/workspace_web/GalleryModal-mtYV1YJE.js delete mode 100644 dist/workspace_web/IconCopy-Vm3ws_0T.js delete mode 100644 dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js delete mode 100644 dist/workspace_web/MediaPreview-cVvL6fHO.js delete mode 100644 dist/workspace_web/ModelManagerTopbar--uE4bw7I.js delete mode 100644 dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js delete mode 100644 dist/workspace_web/ShareDialog-o8m3m3T9.js delete mode 100644 dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js delete mode 100644 dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js delete mode 100644 dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js diff --git a/dist/workspace_web/App-bqAziDgv.js b/dist/workspace_web/App-bqAziDgv.js deleted file mode 100644 index dcd38d7..0000000 --- a/dist/workspace_web/App-bqAziDgv.js +++ /dev/null @@ -1,27 +0,0 @@ -var kl=Object.defineProperty;var xl=(t,e,n)=>e in t?kl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(xl(t,typeof e!="symbol"?e+"":e,n),n);import{u as El,a as Cl,r as A,c as Sl,b as et,m as Te,d as Tt,f as he,e as _e,j as D,B as Ol,g as de,h as We,i as Il,o as tt,k as Pt,l as ot,I as Ur,n as Kr,p as ro,q as Oe,s as Da,t as Dl,v as Pl,w as jl,x as $r,y as Al,z as Nl,A as Fl,C as Rl,D as Tl,E as us,F as Pa,G as ds,H as ja,J as Bl,K as Ml,L as zl,P as Aa,M as fs,N as hs,O as ps,Q as ms,R as ys,S as vs,T as gs,_ as Un,U as Na,V as Fa,W as Xn,X as ws}from"./input.js";import{app as xe}from"/scripts/app.js";import{api as Gs}from"/scripts/api.js";function Ll(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Ra(t){var e;return Ll(t)&&(e=t.ownerDocument)!=null?e:document}function Wl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Ul=Wl();function Kl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Ta(t){const{theme:e}=El(),n=Cl();return A.useMemo(()=>Sl(e.direction,{...n,...t}),[t,e.direction,n])}var $l=Object.defineProperty,ql=(t,e,n)=>e in t?$l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(ql(t,typeof e!="symbol"?e+"":e,n),n);function Js(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 Vl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Ys(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Xs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var ko=typeof window<"u"?A.useLayoutEffect:A.useEffect,xr=t=>t,Hl=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return Vl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=Js(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=Ys(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=Ys(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=Xs(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=Xs(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=Js(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=A.useRef(new Hl);return ko(()=>()=>t.current.destroy()),t.current}var[Gl,Ba]=et({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Jl(t){const e=Ba(),[n,r]=A.useState(-1),o=A.useRef(null);ko(()=>()=>{o.current&&e.unregister(o.current)},[]),ko(()=>{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 Ma(){return[xr(Gl),()=>xr(Ba()),()=>Zl(),o=>Jl(o)]}function za(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Tt(r),i=Tt(o),[a,l]=A.useState(n),c=e!==void 0,u=c?e:a,d=Tt(p=>{const g=typeof p=="function"?p(u):p;i(u,g)&&(c||l(g),s(g))},[c,s,u,i]);return[u,d]}function bs(t){return A.Children.toArray(t).filter(e=>A.isValidElement(e))}var Yl={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}}},Xl={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},La=he(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:c,orientation:u="horizontal",...d}=e,p=_e("chakra-button__group",i),h=A.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:c}),[r,o,s,c]);let g={display:"inline-flex",...l?Yl[u]:Xl[u](a)};const f=u==="vertical";return D.jsx(Ol,{value:h,children:D.jsx(de.div,{ref:n,role:"group",__css:g,className:p,"data-attached":l?"":void 0,"data-orientation":u,flexDir:f?"column":void 0,...d})})});La.displayName="ButtonGroup";var jn=he((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=A.isValidElement(a)?A.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return D.jsx(We,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});jn.displayName="IconButton";var[Ql,Wa]=Il("Card"),ec=he(function(e,n){const{className:r,...o}=e,s=Wa();return D.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),tc=he(function(e,n){const{className:r,...o}=e,s=Wa();return D.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),nc=he(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=tt(e),c=Pt("Card",e);return D.jsx(de.div,{ref:n,className:_e("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...c.container},...l,children:D.jsx(Ql,{value:c,children:o})})}),[rc,Ua]=et({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[oc,dn]=et({strict:!1,name:"FormControlContext"});function sc(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=A.useId(),l=e||`field-${a}`,c=`${l}-label`,u=`${l}-feedback`,d=`${l}-helptext`,[p,h]=A.useState(!1),[g,f]=A.useState(!1),[y,m]=A.useState(!1),w=A.useCallback((E={},N=null)=>({id:d,...E,ref:Te(N,P=>{P&&f(!0)})}),[d]),_=A.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s),id:E.id!==void 0?E.id:c,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,c]),k=A.useCallback((E={},N=null)=>({id:u,...E,ref:Te(N,P=>{P&&h(!0)}),"aria-live":"polite"}),[u]),x=A.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s)}),[i,o,y,r,s]),O=A.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:g,setHasHelpText:f,id:l,labelId:c,feedbackId:u,helpTextId:d,htmlProps:i,getHelpTextProps:w,getErrorMessageProps:k,getRootProps:x,getLabelProps:_,getRequiredIndicatorProps:O}}var qr=he(function(e,n){const r=Pt("Form",e),o=tt(e),{getRootProps:s,htmlProps:i,...a}=sc(o),l=_e("chakra-form-control",e.className);return D.jsx(oc,{value:a,children:D.jsx(rc,{value:r,children:D.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});qr.displayName="FormControl";var ac=he(function(e,n){const r=dn(),o=Ua(),s=_e("chakra-form__helper-text",e.className);return D.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});ac.displayName="FormHelperText";var[ic,lc]=et({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Vr=he((t,e)=>{const n=Pt("FormError",t),r=tt(t),o=dn();return o!=null&&o.isInvalid?D.jsx(ic,{value:n,children:D.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:_e("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Vr.displayName="FormErrorMessage";var cc=he((t,e)=>{const n=lc(),r=dn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return D.jsx(Ur,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:D.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"})})});cc.displayName="FormErrorIcon";var Hr=he(function(e,n){var r;const o=Kr("FormLabel",e),s=tt(e),{className:i,children:a,requiredIndicator:l=D.jsx(Ka,{}),optionalIndicator:c=null,...u}=s,d=dn(),p=(r=d==null?void 0:d.getLabelProps(u,n))!=null?r:{ref:n,...u};return D.jsxs(de.label,{...p,className:_e("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:c]})});Hr.displayName="FormLabel";var Ka=he(function(e,n){const r=dn(),o=Ua();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return D.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ka.displayName="RequiredIndicator";function uc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=dc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":ro(n),"aria-required":ro(o),"aria-readonly":ro(r)}}function dc(t){var e,n,r;const o=dn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:c,isInvalid:u,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:g,...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??c)!=null?r:o==null?void 0:o.isRequired,isInvalid:u??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,g)}}function en(t,e,n,r){const o=Tt(n);return A.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 fc(t){return"current"in t}var $a=()=>typeof window<"u";function hc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var pc=t=>$a()&&t.test(navigator.vendor),mc=t=>$a()&&t.test(hc()),yc=()=>mc(/mac|iphone|ipad|ipod/i),vc=()=>yc()&&pc(/apple/i);function gc(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};en(o,"pointerdown",s=>{if(!vc()||!r)return;const i=s.target,l=(n??[e]).some(c=>{const u=fc(c)?c.current:c;return(u==null?void 0:u.contains(i))||u===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var qa={exports:{}},wc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",bc=wc,_c=bc;function Va(){}function Ha(){}Ha.resetWarningCache=Va;var kc=function(){function t(r,o,s,i,a,l){if(l!==_c){var c=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 c.name="Invariant Violation",c}}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:Ha,resetWarningCache:Va};return n.PropTypes=n,n};qa.exports=kc();var xc=qa.exports;const Nt=Da(xc);function Ec(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 Cc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function Za(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Dl(t)&&Ec(t)?t:Za(Cc(t))}var Sc=Ul?A.useLayoutEffect:A.useEffect;function xo(t,e=[]){const n=A.useRef(t);return Sc(()=>{n.current=t}),A.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Oc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=xo(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{oo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&oo(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&oo(d,e)&&(i.isPointerDown=!1,o(d))},u=Ra(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function oo(t,e){var n;const r=t.target;return r&&!Ra(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Ic(t,e){const n=A.useId();return A.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Dc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Pc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=xo(n),i=xo(e),[a,l]=A.useState(t.defaultIsOpen||!1),[c,u]=Dc(r,a),d=Ic(o,"disclosure"),p=A.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),h=A.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),g=A.useCallback(()=>{(u?p:h)()},[u,h,p]);return{isOpen:!!u,onOpen:h,onClose:p,onToggle:g,isControlled:c,getButtonProps:(f={})=>({...f,"aria-expanded":u,"aria-controls":d,onClick:Pl(f.onClick,g)}),getDisclosureProps:(f={})=>({...f,hidden:!u,id:d})}}var Kn=he(function(e,n){const{htmlSize:r,...o}=e,s=Pt("Input",o),i=tt(o),a=uc(i),l=_e("chakra-input",e.className);return D.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});Kn.displayName="Input";Kn.id="Input";var jc=Object.freeze(["base","sm","md","lg","xl","2xl"]);function Ac(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):jl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function Dp(t,e=jc){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var Bt=he(function(e,n){const r=Kr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=tt(e),c=Kl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return D.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...c,...l,__css:r})});Bt.displayName="Text";var Eo=t=>D.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});Eo.displayName="StackDivider";var Ga=t=>D.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ga.displayName="StackItem";function Nc(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{"&":Ac(n,o=>r[o])}}var tn=he((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:c,className:u,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",g=A.useMemo(()=>Nc({spacing:i,direction:h}),[i,h]),f=!!c,y=!d&&!f,m=A.useMemo(()=>{const _=bs(l);return y?_:_.map((k,x)=>{const O=typeof k.key<"u"?k.key:x,E=x+1===_.length,P=d?D.jsx(Ga,{children:k},O):k;if(!f)return P;const R=A.cloneElement(c,{__css:g}),$=E?null:R;return D.jsxs(A.Fragment,{children:[P,$]},O)})},[c,g,f,y,d,l]),w=_e("chakra-stack",u);return D.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})});tn.displayName="Stack";var Et=he((t,e)=>D.jsx(tn,{align:"center",...t,direction:"row",ref:e}));Et.displayName="HStack";var _s=he(function(e,n){const r=Kr("Heading",e),{className:o,...s}=tt(e);return D.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});_s.displayName="Heading";var Ct=de("div");Ct.displayName="Box";var Ja=he(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return D.jsx(Ct,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});Ja.displayName="Square";var Fc=he(function(e,n){const{size:r,...o}=e;return D.jsx(Ja,{size:r,ref:n,borderRadius:"9999px",...o})});Fc.displayName="Circle";var xn=he(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:c,...u}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:c};return D.jsx(de.div,{ref:n,__css:d,...u})});xn.displayName="Flex";function Rc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Tc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=A.useState([]),s=A.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};A.useEffect(()=>i,[]);function l(c){return u=>{if(u.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Rc(u)){const d=r.concat(u.key);n(u)&&(u.preventDefault(),u.stopPropagation()),o(d),c(d.join("")),a()}}}return l}function Bc(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 Mc(){const t=A.useRef(new Map),e=t.current,n=A.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=A.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return A.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function so(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ya(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:c,onKeyUp:u,tabIndex:d,onMouseOver:p,onMouseLeave:h,...g}=t,[f,y]=A.useState(!0),[m,w]=A.useState(!1),_=Mc(),k=S=>{S&&S.tagName!=="BUTTON"&&y(!1)},x=f?d:d||0,O=n&&!r,E=A.useCallback(S=>{if(n){S.stopPropagation(),S.preventDefault();return}S.currentTarget.focus(),l==null||l(S)},[n,l]),N=A.useCallback(S=>{m&&so(S)&&(S.preventDefault(),S.stopPropagation(),w(!1),_.remove(document,"keyup",N,!1))},[m,_]),P=A.useCallback(S=>{if(c==null||c(S),n||S.defaultPrevented||S.metaKey||!so(S.nativeEvent)||f)return;const G=o&&S.key==="Enter";s&&S.key===" "&&(S.preventDefault(),w(!0)),G&&(S.preventDefault(),S.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,f,c,o,s,_,N]),R=A.useCallback(S=>{if(u==null||u(S),n||S.defaultPrevented||S.metaKey||!so(S.nativeEvent)||f)return;s&&S.key===" "&&(S.preventDefault(),w(!1),S.currentTarget.click())},[s,f,n,u]),$=A.useCallback(S=>{S.button===0&&(w(!1),_.remove(document,"mouseup",$,!1))},[_]),j=A.useCallback(S=>{if(S.button!==0)return;if(n){S.stopPropagation(),S.preventDefault();return}f||w(!0),S.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",$,!1),i==null||i(S)},[n,f,i,_,$]),B=A.useCallback(S=>{S.button===0&&(f||w(!1),a==null||a(S))},[a,f]),b=A.useCallback(S=>{if(n){S.preventDefault();return}p==null||p(S)},[n,p]),K=A.useCallback(S=>{m&&(S.preventDefault(),w(!1)),h==null||h(S)},[m,h]),te=Te(e,k);return f?{...g,ref:te,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:u,onKeyDown:c,onMouseOver:p,onMouseLeave:h}:{...g,ref:te,role:"button","data-active":ot(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:x,onClick:E,onMouseDown:j,onMouseUp:B,onKeyUp:R,onKeyDown:P,onMouseOver:b,onMouseLeave:K}}function zc(t){const e=t.current;if(!e)return!1;const n=Fl(e);return!n||e.contains(n)?!1:!!Rl(n)}function Xa(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;$r(()=>{if(!s||zc(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 Lc={preventScroll:!0,shouldFocus:!1};function Wc(t,e=Lc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Uc(t)?t.current:t,a=o&&s,l=A.useRef(a),c=A.useRef(s);Al(()=>{!c.current&&s&&(l.current=a),c.current=s},[s,a]);const u=A.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=Nl(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);$r(()=>{u()},[u]),en(i,"transitionend",u)}function Uc(t){return"current"in t}var Gt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),je={arrowShadowColor:Gt("--popper-arrow-shadow-color"),arrowSize:Gt("--popper-arrow-size","8px"),arrowSizeHalf:Gt("--popper-arrow-size-half"),arrowBg:Gt("--popper-arrow-bg"),transformOrigin:Gt("--popper-transform-origin"),arrowOffset:Gt("--popper-arrow-offset")};function Kc(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 $c={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"},qc=t=>$c[t],Qs={scroll:!0,resize:!0};function Vc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Qs,...t}}:e={enabled:t,options:Qs},e}var Hc={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`}},Zc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{ea(t)},effect:({state:t})=>()=>{ea(t)}},ea=t=>{t.elements.popper.style.setProperty(je.transformOrigin.var,qc(t.placement))},Gc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Jc(t)}},Jc=t=>{var e;if(!t.placement)return;const n=Yc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:je.arrowSize.varRef,height:je.arrowSize.varRef,zIndex:-1});const r={[je.arrowSizeHalf.var]:`calc(${je.arrowSize.varRef} / 2 - 1px)`,[je.arrowOffset.var]:`calc(${je.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},Yc=t=>{if(t.startsWith("top"))return{property:"bottom",value:je.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:je.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:je.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:je.arrowOffset.varRef}},Xc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{ta(t)},effect:({state:t})=>()=>{ta(t)}},ta=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Kc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:je.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Qc={"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"}},eu={"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 tu(t,e="ltr"){var n,r;const o=((n=Qc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=eu[t])!=null?r:o}var Ke="top",Xe="bottom",Qe="right",$e="left",ks="auto",$n=[Ke,Xe,Qe,$e],sn="start",An="end",nu="clippingParents",Qa="viewport",gn="popper",ru="reference",na=$n.reduce(function(t,e){return t.concat([e+"-"+sn,e+"-"+An])},[]),ei=[].concat($n,[ks]).reduce(function(t,e){return t.concat([e,e+"-"+sn,e+"-"+An])},[]),ou="beforeRead",su="read",au="afterRead",iu="beforeMain",lu="main",cu="afterMain",uu="beforeWrite",du="write",fu="afterWrite",hu=[ou,su,au,iu,lu,cu,uu,du,fu];function it(t){return t?(t.nodeName||"").toLowerCase():null}function He(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function $t(t){var e=He(t).Element;return t instanceof e||t instanceof Element}function Ye(t){var e=He(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function xs(t){if(typeof ShadowRoot>"u")return!1;var e=He(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function pu(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];!Ye(s)||!it(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 mu(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,c){return l[c]="",l},{});!Ye(o)||!it(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const yu={name:"applyStyles",enabled:!0,phase:"write",fn:pu,effect:mu,requires:["computeStyles"]};function at(t){return t.split("-")[0]}var Mt=Math.max,Er=Math.min,an=Math.round;function Co(){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 ti(){return!/^((?!chrome|android).)*safari/i.test(Co())}function ln(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Ye(t)&&(o=t.offsetWidth>0&&an(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&an(r.height)/t.offsetHeight||1);var i=$t(t)?He(t):window,a=i.visualViewport,l=!ti()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c,x:c,y:u}}function Es(t){var e=ln(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 ni(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&xs(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function yt(t){return He(t).getComputedStyle(t)}function vu(t){return["table","td","th"].indexOf(it(t))>=0}function jt(t){return(($t(t)?t.ownerDocument:t.document)||window.document).documentElement}function Zr(t){return it(t)==="html"?t:t.assignedSlot||t.parentNode||(xs(t)?t.host:null)||jt(t)}function ra(t){return!Ye(t)||yt(t).position==="fixed"?null:t.offsetParent}function gu(t){var e=/firefox/i.test(Co()),n=/Trident/i.test(Co());if(n&&Ye(t)){var r=yt(t);if(r.position==="fixed")return null}var o=Zr(t);for(xs(o)&&(o=o.host);Ye(o)&&["html","body"].indexOf(it(o))<0;){var s=yt(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 qn(t){for(var e=He(t),n=ra(t);n&&vu(n)&&yt(n).position==="static";)n=ra(n);return n&&(it(n)==="html"||it(n)==="body"&&yt(n).position==="static")?e:n||gu(t)||e}function Cs(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function En(t,e,n){return Mt(t,Er(e,n))}function wu(t,e,n){var r=En(t,e,n);return r>n?n:r}function ri(){return{top:0,right:0,bottom:0,left:0}}function oi(t){return Object.assign({},ri(),t)}function si(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var bu=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,oi(typeof e!="number"?e:si(e,$n))};function _u(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=at(n.placement),l=Cs(a),c=[$e,Qe].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=bu(o.padding,n),p=Es(s),h=l==="y"?Ke:$e,g=l==="y"?Xe:Qe,f=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],y=i[l]-n.rects.reference[l],m=qn(s),w=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=f/2-y/2,k=d[h],x=w-p[u]-d[g],O=w/2-p[u]/2+_,E=En(k,O,x),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function ku(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)||ni(e.elements.popper,o)&&(e.elements.arrow=o))}const xu={name:"arrow",enabled:!0,phase:"main",fn:_u,effect:ku,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function cn(t){return t.split("-")[1]}var Eu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Cu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:an(n*o)/o||0,y:an(r*o)/o||0}}function oa(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,g=i.y,f=g===void 0?0:g,y=typeof u=="function"?u({x:h,y:f}):{x:h,y:f};h=y.x,f=y.y;var m=i.hasOwnProperty("x"),w=i.hasOwnProperty("y"),_=$e,k=Ke,x=window;if(c){var O=qn(n),E="clientHeight",N="clientWidth";if(O===He(n)&&(O=jt(n),yt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===Qe)&&s===An){k=Xe;var P=d&&O===x&&x.visualViewport?x.visualViewport.height:O[E];f-=P-r.height,f*=l?1:-1}if(o===$e||(o===Ke||o===Xe)&&s===An){_=Qe;var R=d&&O===x&&x.visualViewport?x.visualViewport.width:O[N];h-=R-r.width,h*=l?1:-1}}var $=Object.assign({position:a},c&&Eu),j=u===!0?Cu({x:h,y:f},He(n)):{x:h,y:f};if(h=j.x,f=j.y,l){var B;return Object.assign({},$,(B={},B[k]=w?"0":"",B[_]=m?"0":"",B.transform=(x.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",B))}return Object.assign({},$,(e={},e[k]=w?f+"px":"",e[_]=m?h+"px":"",e.transform="",e))}function Su(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,c={placement:at(e.placement),variation:cn(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,oa(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,oa(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Ou={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Su,data:{}};var Qn={passive:!0};function Iu(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=He(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const Du={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Iu,data:{}};var Pu={left:"right",right:"left",bottom:"top",top:"bottom"};function ur(t){return t.replace(/left|right|bottom|top/g,function(e){return Pu[e]})}var ju={start:"end",end:"start"};function sa(t){return t.replace(/start|end/g,function(e){return ju[e]})}function Ss(t){var e=He(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Os(t){return ln(jt(t)).left+Ss(t).scrollLeft}function Au(t,e){var n=He(t),r=jt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=ti();(c||!c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Os(t),y:l}}function Nu(t){var e,n=jt(t),r=Ss(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Mt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Mt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Os(t),l=-r.scrollTop;return yt(o||n).direction==="rtl"&&(a+=Mt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function Is(t){var e=yt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ai(t){return["html","body","#document"].indexOf(it(t))>=0?t.ownerDocument.body:Ye(t)&&Is(t)?t:ai(Zr(t))}function Cn(t,e){var n;e===void 0&&(e=[]);var r=ai(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=He(r),i=o?[s].concat(s.visualViewport||[],Is(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Cn(Zr(i)))}function So(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Fu(t,e){var n=ln(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 aa(t,e,n){return e===Qa?So(Au(t,n)):$t(e)?Fu(e,n):So(Nu(jt(t)))}function Ru(t){var e=Cn(Zr(t)),n=["absolute","fixed"].indexOf(yt(t).position)>=0,r=n&&Ye(t)?qn(t):t;return $t(r)?e.filter(function(o){return $t(o)&&ni(o,r)&&it(o)!=="body"}):[]}function Tu(t,e,n,r){var o=e==="clippingParents"?Ru(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=aa(t,c,r);return l.top=Mt(u.top,l.top),l.right=Er(u.right,l.right),l.bottom=Er(u.bottom,l.bottom),l.left=Mt(u.left,l.left),l},aa(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 ii(t){var e=t.reference,n=t.element,r=t.placement,o=r?at(r):null,s=r?cn(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 Xe:l={x:i,y:e.y+e.height};break;case Qe: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 c=o?Cs(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case sn:l[c]=l[c]-(e[u]/2-n[u]/2);break;case An:l[c]=l[c]+(e[u]/2-n[u]/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?nu:a,c=n.rootBoundary,u=c===void 0?Qa:c,d=n.elementContext,p=d===void 0?gn:d,h=n.altBoundary,g=h===void 0?!1:h,f=n.padding,y=f===void 0?0:f,m=oi(typeof y!="number"?y:si(y,$n)),w=p===gn?ru:gn,_=t.rects.popper,k=t.elements[g?w:p],x=Tu($t(k)?k:k.contextElement||jt(t.elements.popper),l,u,i),O=ln(t.elements.reference),E=ii({reference:O,element:_,strategy:"absolute",placement:o}),N=So(Object.assign({},_,E)),P=p===gn?N:O,R={top:x.top-P.top+m.top,bottom:P.bottom-x.bottom+m.bottom,left:x.left-P.left+m.left,right:P.right-x.right+m.right},$=t.modifiersData.offset;if(p===gn&&$){var j=$[o];Object.keys(R).forEach(function(B){var b=[Qe,Xe].indexOf(B)>=0?1:-1,K=[Ke,Xe].indexOf(B)>=0?"y":"x";R[B]+=j[K]*b})}return R}function Bu(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,c=l===void 0?ei:l,u=cn(r),d=u?a?na:na.filter(function(g){return cn(g)===u}):$n,p=d.filter(function(g){return c.indexOf(g)>=0});p.length===0&&(p=d);var h=p.reduce(function(g,f){return g[f]=Nn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[at(f)],g},{});return Object.keys(h).sort(function(g,f){return h[g]-h[f]})}function Mu(t){if(at(t)===ks)return[];var e=ur(t);return[sa(t),e,sa(e)]}function zu(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,c=n.padding,u=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,g=h===void 0?!0:h,f=n.allowedAutoPlacements,y=e.options.placement,m=at(y),w=m===y,_=l||(w||!g?[ur(y)]:Mu(y)),k=[y].concat(_).reduce(function(Y,H){return Y.concat(at(H)===ks?Bu(e,{placement:H,boundary:u,rootBoundary:d,padding:c,flipVariations:g,allowedAutoPlacements:f}):H)},[]),x=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,P=k[0],R=0;R=0,K=b?"width":"height",te=Nn(e,{placement:$,boundary:u,rootBoundary:d,altBoundary:p,padding:c}),S=b?B?Qe:$e:B?Xe:Ke;x[K]>O[K]&&(S=ur(S));var G=ur(S),z=[];if(s&&z.push(te[j]<=0),a&&z.push(te[S]<=0,te[G]<=0),z.every(function(Y){return Y})){P=$,N=!1;break}E.set($,z)}if(N)for(var Q=g?3:1,M=function(H){var fe=k.find(function(ye){var se=E.get(ye);if(se)return se.slice(0,H).every(function(le){return le})});if(fe)return P=fe,"break"},T=Q;T>0;T--){var ne=M(T);if(ne==="break")break}e.placement!==P&&(e.modifiersData[r]._skip=!0,e.placement=P,e.reset=!0)}}const Lu={name:"flip",enabled:!0,phase:"main",fn:zu,requiresIfExists:["offset"],data:{_skip:!1}};function ia(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 la(t){return[Ke,Qe,Xe,$e].some(function(e){return t[e]>=0})}function Wu(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=ia(i,r),c=ia(a,o,s),u=la(l),d=la(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const Uu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Wu};function Ku(t,e,n){var r=at(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,Qe].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function $u(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=ei.reduce(function(u,d){return u[d]=Ku(d,e.rects,s),u},{}),a=i[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=i}const qu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:$u};function Vu(t){var e=t.state,n=t.name;e.modifiersData[n]=ii({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Hu={name:"popperOffsets",enabled:!0,phase:"read",fn:Vu,data:{}};function Zu(t){return t==="x"?"y":"x"}function Gu(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,c=n.rootBoundary,u=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,g=n.tetherOffset,f=g===void 0?0:g,y=Nn(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),m=at(e.placement),w=cn(e.placement),_=!w,k=Cs(m),x=Zu(k),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,P=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof P=="number"?{mainAxis:P,altAxis:P}:Object.assign({mainAxis:0,altAxis:0},P),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,j={x:0,y:0};if(O){if(s){var B,b=k==="y"?Ke:$e,K=k==="y"?Xe:Qe,te=k==="y"?"height":"width",S=O[k],G=S+y[b],z=S-y[K],Q=h?-N[te]/2:0,M=w===sn?E[te]:N[te],T=w===sn?-N[te]:-E[te],ne=e.elements.arrow,Y=h&&ne?Es(ne):{width:0,height:0},H=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ri(),fe=H[b],ye=H[K],se=En(0,E[te],Y[te]),le=_?E[te]/2-Q-se-fe-R.mainAxis:M-se-fe-R.mainAxis,ke=_?-E[te]/2+Q+se+ye+R.mainAxis:T+se+ye+R.mainAxis,ve=e.elements.arrow&&qn(e.elements.arrow),me=ve?k==="y"?ve.clientTop||0:ve.clientLeft||0:0,Ee=(B=$==null?void 0:$[k])!=null?B:0,v=S+le-Ee-me,U=S+ke-Ee,W=En(h?Er(G,v):G,S,h?Mt(z,U):z);O[k]=W,j[k]=W-S}if(a){var I,C=k==="x"?Ke:$e,F=k==="x"?Xe:Qe,V=O[x],J=x==="y"?"height":"width",L=V+y[C],X=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(I=$==null?void 0:$[x])!=null?I:0,ae=re?L:V-E[J]-N[J]-ee+R.altAxis,ge=re?V+E[J]+N[J]-ee-R.altAxis:X,pe=h&&re?wu(ae,V,ge):En(h?ae:L,V,h?ge:X);O[x]=pe,j[x]=pe-V}e.modifiersData[r]=j}}const Ju={name:"preventOverflow",enabled:!0,phase:"main",fn:Gu,requiresIfExists:["offset"]};function Yu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Xu(t){return t===He(t)||!Ye(t)?Ss(t):Yu(t)}function Qu(t){var e=t.getBoundingClientRect(),n=an(e.width)/t.offsetWidth||1,r=an(e.height)/t.offsetHeight||1;return n!==1||r!==1}function ed(t,e,n){n===void 0&&(n=!1);var r=Ye(e),o=Ye(e)&&Qu(e),s=jt(e),i=ln(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((it(e)!=="body"||Is(s))&&(a=Xu(e)),Ye(e)?(l=ln(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Os(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function td(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 nd(t){var e=td(t);return hu.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function rd(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function od(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 ca={placement:"bottom",modifiers:[],strategy:"absolute"};function ua(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=A.useCallback(()=>{var R;!e||!g.current||!f.current||((R=w.current)==null||R.call(w),y.current=id(g.current,f.current,{placement:m,modifiers:[Xc,Gc,Zc,{...Hc,enabled:!!p},{name:"eventListeners",...Vc(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!c,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:u}},...n??[]],strategy:o}),y.current.forceUpdate(),w.current=y.current.destroy)},[m,e,n,p,i,s,a,l,c,d,u,o]);A.useEffect(()=>()=>{var R;!g.current&&!f.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const k=A.useCallback(R=>{g.current=R,_()},[_]),x=A.useCallback((R={},$=null)=>({...R,ref:Te(k,$)}),[k]),O=A.useCallback(R=>{f.current=R,_()},[_]),E=A.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=A.useCallback((R={},$=null)=>{const{size:j,shadowColor:B,bg:b,style:K,...te}=R;return{...te,ref:$,"data-popper-arrow":"",style:ld(R)}},[]),P=A.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:je.transformOrigin.varRef,referenceRef:k,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:P,getReferenceProps:x}}function ld(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 Ps(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Tt(n),i=Tt(e),[a,l]=A.useState(t.defaultIsOpen||!1),c=r!==void 0?r:a,u=r!==void 0,d=A.useId(),p=o??`disclosure-${d}`,h=A.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),g=A.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),f=A.useCallback(()=>{c?h():g()},[c,g,h]);function y(w={}){return{...w,"aria-expanded":c,"aria-controls":p,onClick(_){var k;(k=w.onClick)==null||k.call(w,_),f()}}}function m(w={}){return{...w,hidden:!c,id:p}}return{isOpen:c,onOpen:g,onClose:h,onToggle:f,isControlled:u,getButtonProps:y,getDisclosureProps:m}}function cd(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Tt(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{ao(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ao(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ao(d,e)&&(i.isPointerDown=!1,o(d))},u=li(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function ao(t,e){var n;const r=t.target;return r&&!li(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function li(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function ci(t){const{isOpen:e,ref:n}=t,[r,o]=A.useState(e),[s,i]=A.useState(!1);return A.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),en(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const c=Tl(n.current),u=new c.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(u)}}}function js(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[ud,dd,fd,hd]=Ma(),[pd,Vn]=et({strict:!1,name:"MenuContext"});function md(t,...e){const n=A.useId(),r=t||n;return A.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function ui(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function da(t){return ui(t).activeElement===t}function yd(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:c,onOpen:u,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:g=!1,...f}=t,y=A.useRef(null),m=A.useRef(null),w=fd(),_=A.useCallback(()=>{requestAnimationFrame(()=>{var ne;(ne=y.current)==null||ne.focus({preventScroll:!1})})},[]),k=A.useCallback(()=>{const ne=setTimeout(()=>{var Y;if(o)(Y=o.current)==null||Y.focus();else{const H=w.firstEnabled();H&&B(H.index)}});G.current.add(ne)},[w,o]),x=A.useCallback(()=>{const ne=setTimeout(()=>{const Y=w.lastEnabled();Y&&B(Y.index)});G.current.add(ne)},[w]),O=A.useCallback(()=>{u==null||u(),s?k():_()},[s,k,_,u]),{isOpen:E,onOpen:N,onClose:P,onToggle:R}=Ps({isOpen:a,defaultIsOpen:l,onClose:c,onOpen:O});cd({enabled:E&&r,ref:y,handler:ne=>{var Y;(Y=m.current)!=null&&Y.contains(ne.target)||P()}});const $=Ds({...f,enabled:E||g,placement:d,direction:h}),[j,B]=A.useState(-1);$r(()=>{E||B(-1)},[E]),Xa(y,{focusRef:m,visible:E,shouldFocus:!0});const b=ci({isOpen:E,ref:y}),[K,te]=md(e,"menu-button","menu-list"),S=A.useCallback(()=>{N(),_()},[N,_]),G=A.useRef(new Set([]));A.useEffect(()=>{const ne=G.current;return()=>{ne.forEach(Y=>clearTimeout(Y)),ne.clear()}},[]);const z=A.useCallback(()=>{N(),k()},[k,N]),Q=A.useCallback(()=>{N(),x()},[N,x]),M=A.useCallback(()=>{var ne,Y;const H=ui(y.current),fe=(ne=y.current)==null?void 0:ne.contains(H.activeElement);if(!(E&&!fe))return;const se=(Y=w.item(j))==null?void 0:Y.node;se==null||se.focus({preventScroll:!0})},[E,j,w]),T=A.useRef(null);return{openAndFocusMenu:S,openAndFocusFirstItem:z,openAndFocusLastItem:Q,onTransitionEnd:M,unstable__animationState:b,descendants:w,popper:$,buttonId:K,menuId:te,forceUpdate:$.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:P,menuRef:y,buttonRef:m,focusedIndex:j,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:B,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:T}}function Pp(t={},e=null){const n=Vn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=A.useCallback(l=>{const c=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[c];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Te(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":ot(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function Oo(t){var e;return wd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function vd(t={},e=null){const n=Vn();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:c,lazyBehavior:u,unstable__animationState:d}=n,p=dd(),h=Tc({preventDefault:m=>m.key!==" "&&Oo(m.target)}),g=A.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const w=m.key,k={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(k){m.preventDefault(),k(m);return}const x=h(O=>{const E=Bc(p.values(),O,N=>{var P,R;return(R=(P=N==null?void 0:N.node)==null?void 0:P.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});Oo(m.target)&&x(m)},[p,r,h,a,o]),f=A.useRef(!1);i&&(f.current=!0);const y=js({wasSelected:f.current,enabled:c,mode:u,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,g)}}function gd(t={}){const{popper:e,isOpen:n}=Vn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function di(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:c,type:u,...d}=t,p=Vn(),{setFocusedIndex:h,focusedIndex:g,closeOnSelect:f,onClose:y,menuRef:m,isOpen:w,menuId:_,rafId:k}=p,x=A.useRef(null),O=`${_}-menuitem-${A.useId()}`,{index:E,register:N}=hd({disabled:a&&!l}),P=A.useCallback(S=>{n==null||n(S),!a&&h(E)},[h,E,a,n]),R=A.useCallback(S=>{r==null||r(S),x.current&&!da(x.current)&&P(S)},[P,r]),$=A.useCallback(S=>{o==null||o(S),!a&&h(-1)},[h,a,o]),j=A.useCallback(S=>{s==null||s(S),Oo(S.currentTarget)&&(c??f)&&y()},[y,s,f,c]),B=A.useCallback(S=>{i==null||i(S),h(E)},[h,i,E]),b=E===g,K=a&&!l;$r(()=>{if(w)return b&&!K&&x.current?(k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{var S;(S=x.current)==null||S.focus({preventScroll:!0}),k.current=null})):m.current&&!da(m.current)&&m.current.focus({preventScroll:!0}),()=>{k.current&&cancelAnimationFrame(k.current)}},[b,K,m,w]);const te=Ya({onClick:j,onFocus:B,onMouseEnter:P,onMouseMove:R,onMouseLeave:$,ref:Te(N,x,e),isDisabled:a,isFocusable:l});return{...d,...te,type:u??te.type,id:O,role:"menuitem",tabIndex:b?0:-1}}function jp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...di(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"?"":[],[c,u]=za({defaultValue:o??l,value:r,onChange:s}),d=A.useCallback(g=>{if(n==="radio"&&typeof c=="string"&&u(g),n==="checkbox"&&Array.isArray(c)){const f=c.includes(g)?c.filter(y=>y!==g):c.concat(g);u(f)}},[c,u,n]),h=bs(e).map(g=>{if(g.type.id!=="MenuItemOption")return g;const f=m=>{var w,_;d(g.props.value),(_=(w=g.props).onClick)==null||_.call(w,m)},y=n==="radio"?g.props.value===c:c.includes(g.props.value);return A.cloneElement(g,{type:n,onClick:f,isChecked:y})});return{...i,children:h}}function wd(t){var e;if(!bd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function bd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[_d,Gr]=et({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),As=t=>{const{children:e}=t,n=Pt("Menu",t),r=tt(t),{direction:o}=us(),{descendants:s,...i}=yd({...r,direction:o}),a=A.useMemo(()=>i,[i]),{isOpen:l,onClose:c,forceUpdate:u}=a;return D.jsx(ud,{value:s,children:D.jsx(pd,{value:a,children:D.jsx(_d,{value:n,children:Pa(e,{isOpen:l,onClose:c,forceUpdate:u})})})})};As.displayName="Menu";var fi=he((t,e)=>{const n=Gr();return D.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});fi.displayName="MenuCommand";var kd=he((t,e)=>{const{type:n,...r}=t,o=Gr(),s=r.as||n?n??void 0:"button",i=A.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 D.jsx(de.button,{ref:e,type:s,...r,__css:i})}),hi=t=>{const{className:e,children:n,...r}=t,o=Gr(),s=A.Children.only(n),i=A.isValidElement(s)?A.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return D.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};hi.displayName="MenuIcon";var gt=he((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=di(a,e),u=n||o?D.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return D.jsxs(kd,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&D.jsx(hi,{fontSize:"0.8em",marginEnd:r,children:n}),u,o&&D.jsx(fi,{marginStart:s,children:o})]})});gt.displayName="MenuItem";var xd={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"}}},Ed=de(ds.div),Ns=he(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:c,unstable__animationState:u}=Vn(),d=vd(a,n),p=gd(s),h=Gr();return D.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:D.jsx(Ed,{variants:xd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:c,onAnimationComplete:ja(u.onComplete,d.onAnimationComplete)})})});Ns.displayName="MenuList";var[Cd,fn]=et({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Sd,Jr]=et({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function pi(t){const e=A.Children.only(t.children),{getTriggerProps:n}=fn();return A.cloneElement(e,n(e.props,e.ref))}pi.displayName="PopoverTrigger";var Jt={click:"click",hover:"hover"};function Od(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:c=Jt.click,openDelay:u=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:g,...f}=t,{isOpen:y,onClose:m,onOpen:w,onToggle:_}=Ps(t),k=A.useRef(null),x=A.useRef(null),O=A.useRef(null),E=A.useRef(!1),N=A.useRef(!1);y&&(N.current=!0);const[P,R]=A.useState(!1),[$,j]=A.useState(!1),B=A.useId(),b=o??B,[K,te,S,G]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:z,getArrowProps:Q,getPopperProps:M,getArrowInnerProps:T,forceUpdate:ne}=Ds({...f,enabled:y||!!g}),Y=ci({isOpen:y,ref:O});gc({enabled:y,ref:x}),Xa(O,{focusRef:x,visible:y,shouldFocus:s&&c===Jt.click}),Wc(O,{focusRef:r,visible:y,shouldFocus:i&&c===Jt.click});const H=js({wasSelected:N.current,enabled:p,mode:h,isSelected:Y.present}),fe=A.useCallback((U={},W=null)=>{const I={...U,style:{...U.style,transformOrigin:je.transformOrigin.varRef,[je.arrowSize.var]:a?`${a}px`:void 0,[je.arrowShadowColor.var]:l},ref:Te(O,W),children:H?U.children:null,id:te,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,C=>{n&&C.key==="Escape"&&m()}),onBlur:Oe(U.onBlur,C=>{const F=fa(C),V=io(O.current,F),J=io(x.current,F);y&&e&&(!V&&!J)&&m()}),"aria-labelledby":P?S:void 0,"aria-describedby":$?G:void 0};return c===Jt.hover&&(I.role="tooltip",I.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),I.onMouseLeave=Oe(U.onMouseLeave,C=>{C.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),I},[H,te,P,S,$,G,c,n,m,y,e,d,l,a]),ye=A.useCallback((U={},W=null)=>M({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,M]),se=A.useCallback((U,W=null)=>({...U,ref:Te(W,k,z)}),[k,z]),le=A.useRef(),ke=A.useRef(),ve=A.useCallback(U=>{k.current==null&&z(U)},[z]),me=A.useCallback((U={},W=null)=>{const I={...U,ref:Te(x,W,ve),id:K,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":te};return c===Jt.click&&(I.onClick=Oe(U.onClick,_)),c===Jt.hover&&(I.onFocus=Oe(U.onFocus,()=>{le.current===void 0&&w()}),I.onBlur=Oe(U.onBlur,C=>{const F=fa(C),V=!io(O.current,F);y&&e&&V&&m()}),I.onKeyDown=Oe(U.onKeyDown,C=>{C.key==="Escape"&&m()}),I.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,le.current=window.setTimeout(()=>w(),u)}),I.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,le.current&&(clearTimeout(le.current),le.current=void 0),ke.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),I},[K,y,te,c,ve,_,w,e,m,u,d]);A.useEffect(()=>()=>{le.current&&clearTimeout(le.current),ke.current&&clearTimeout(ke.current)},[]);const Ee=A.useCallback((U={},W=null)=>({...U,id:S,ref:Te(W,I=>{R(!!I)})}),[S]),v=A.useCallback((U={},W=null)=>({...U,id:G,ref:Te(W,I=>{j(!!I)})}),[G]);return{forceUpdate:ne,isOpen:y,onAnimationComplete:Y.onComplete,onClose:m,getAnchorProps:se,getArrowProps:Q,getArrowInnerProps:T,getPopoverPositionerProps:ye,getPopoverProps:fe,getTriggerProps:me,getHeaderProps:Ee,getBodyProps:v}}function io(t,e){return t===e||(t==null?void 0:t.contains(e))}function fa(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function mi(t){const e=Pt("Popover",t),{children:n,...r}=tt(t),o=us(),s=Od({...r,direction:o.direction});return D.jsx(Cd,{value:s,children:D.jsx(Sd,{value:e,children:Pa(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}mi.displayName="Popover";var lo=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function yi(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:i,shadowColor:a}=t,{getArrowProps:l,getArrowInnerProps:c}=fn(),u=Jr(),d=(e=n??r)!=null?e:o,p=s??i;return D.jsx(de.div,{...l(),className:"chakra-popover__arrow-positioner",children:D.jsx(de.div,{className:_e("chakra-popover__arrow",t.className),...c(t),__css:{"--popper-arrow-shadow-color":lo("colors",a),"--popper-arrow-bg":lo("colors",d),"--popper-arrow-shadow":lo("shadows",p),...u.arrow}})})}yi.displayName="PopoverArrow";var vi=he(function(e,n){const{getBodyProps:r}=fn(),o=Jr();return D.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});vi.displayName="PopoverBody";var gi=he(function(e,n){const{onClose:r}=fn(),o=Jr();return D.jsx(Bl,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});gi.displayName="PopoverCloseButton";function Id(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var Dd={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]}}},Pd=de(ds.section),wi=he(function(e,n){const{variants:r=Dd,...o}=e,{isOpen:s}=fn();return D.jsx(Pd,{ref:n,variants:Id(r),initial:!1,animate:s?"enter":"exit",...o})});wi.displayName="PopoverTransition";var bi=he(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=fn(),c=Jr(),u={position:"relative",display:"flex",flexDirection:"column",...c.content};return D.jsx(de.div,{...a(r),__css:c.popper,className:"chakra-popover__popper",children:D.jsx(wi,{...o,...i(s,n),onAnimationComplete:ja(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:u})})});bi.displayName="PopoverContent";var[jd,Ad,Nd,Fd]=Ma();function Rd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:c="ltr",...u}=t,[d,p]=A.useState(n??0),[h,g]=za({defaultValue:n??0,value:o,onChange:r});A.useEffect(()=>{o!=null&&p(o)},[o]);const f=Nd(),y=A.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:g,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:c,htmlProps:u}}var[Td,Yr]=et({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Bd(t){const{focusedIndex:e,orientation:n,direction:r}=Yr(),o=Ad(),s=A.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())},c=()=>{var w;const _=o.firstEnabled();_&&((w=_.node)==null||w.focus())},u=()=>{var w;const _=o.lastEnabled();_&&((w=_.node)==null||w.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,g=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",m={[g]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:c,End:u}[h];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Md(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Yr(),{index:c,register:u}=Fd({disabled:e&&!n}),d=c===l,p=()=>{o(c)},h=()=>{a(c),!s&&!(e&&n)&&o(c)},g=Ya({...r,ref:Te(u,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...g,id:_i(i,c),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":ki(i,c),onFocus:e?void 0:Oe(t.onFocus,h)}}var[zd,Ld]=et({});function Wd(t){const e=Yr(),{id:n,selectedIndex:r}=e,s=bs(t.children).map((i,a)=>A.createElement(zd,{key:a,value:{isSelected:a===r,id:ki(n,a),tabId:_i(n,a),selectedIndex:r}},i));return{...t,children:s}}function Ud(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Yr(),{isSelected:s,id:i,tabId:a}=Ld(),l=A.useRef(!1);s&&(l.current=!0);const c=js({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:c?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function _i(t,e){return`${t}--tab-${e}`}function ki(t,e){return`${t}--tabpanel-${e}`}var[Kd,Xr]=et({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),xi=he(function(e,n){const r=Pt("Tabs",e),{children:o,className:s,...i}=tt(e),{htmlProps:a,descendants:l,...c}=Rd(i),u=A.useMemo(()=>c,[c]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return D.jsx(jd,{value:l,children:D.jsx(Td,{value:u,children:D.jsx(Kd,{value:r,children:D.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});xi.displayName="Tabs";var Ei=he(function(e,n){const r=Bd({...e,ref:n}),s={display:"flex",...Xr().tablist};return D.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});Ei.displayName="TabList";var Io=he(function(e,n){const r=Ud({...e,ref:n}),o=Xr();return D.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Io.displayName="TabPanel";var Ci=he(function(e,n){const r=Wd(e),o=Xr();return D.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Ci.displayName="TabPanels";var Do=he(function(e,n){const r=Xr(),o=Md({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return D.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Do.displayName="Tab";var[$d,Si]=et({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Qr=he((t,e)=>{const n=Pt("Tag",t),r=tt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return D.jsx($d,{value:n,children:D.jsx(de.span,{ref:e,...r,__css:o})})});Qr.displayName="Tag";var qd=he((t,e)=>{const n=Si();return D.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});qd.displayName="TagLabel";var Vd=he((t,e)=>D.jsx(Ur,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Vd.displayName="TagLeftIcon";var Hd=he((t,e)=>D.jsx(Ur,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Hd.displayName="TagRightIcon";var Oi=t=>D.jsx(Ur,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:D.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"})});Oi.displayName="TagCloseIcon";var Zd=he((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...Si().closeButton};return D.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||D.jsx(Oi,{})})});Zd.displayName="TagCloseButton";var Gd={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]}}}},Po=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},dr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Jd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:c,placement:u,id:d,isOpen:p,defaultIsOpen:h,arrowSize:g=10,arrowShadowColor:f,arrowPadding:y,modifiers:m,isDisabled:w,gutter:_,offset:k,direction:x,...O}=t,{isOpen:E,onOpen:N,onClose:P}=Ps({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:c}),{referenceRef:R,getPopperProps:$,getArrowInnerProps:j,getArrowProps:B}=Ds({enabled:E,placement:u,arrowPadding:y,modifiers:m,gutter:_,offset:k,direction:x}),b=A.useId(),te=`tooltip-${d??b}`,S=A.useRef(null),G=A.useRef(),z=A.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=void 0)},[]),Q=A.useRef(),M=A.useCallback(()=>{Q.current&&(clearTimeout(Q.current),Q.current=void 0)},[]),T=A.useCallback(()=>{M(),P()},[P,M]),ne=Yd(S,T),Y=A.useCallback(()=>{if(!w&&!G.current){E&&ne();const me=dr(S);G.current=me.setTimeout(N,e)}},[ne,w,E,N,e]),H=A.useCallback(()=>{z();const me=dr(S);Q.current=me.setTimeout(T,n)},[n,T,z]),fe=A.useCallback(()=>{E&&r&&H()},[r,H,E]),ye=A.useCallback(()=>{E&&i&&H()},[i,H,E]),se=A.useCallback(me=>{E&&me.key==="Escape"&&H()},[E,H]);en(()=>Po(S),"keydown",a?se:void 0),en(()=>{if(!s)return null;const me=S.current;if(!me)return null;const Ee=Za(me);return Ee.localName==="body"?dr(S):Ee},"scroll",()=>{E&&s&&T()},{passive:!0,capture:!0}),A.useEffect(()=>{w&&(z(),E&&P())},[w,E,P,z]),A.useEffect(()=>()=>{z(),M()},[z,M]),en(()=>S.current,"pointerleave",H);const le=A.useCallback((me={},Ee=null)=>({...me,ref:Te(S,Ee,R),onPointerEnter:Oe(me.onPointerEnter,U=>{U.pointerType!=="touch"&&Y()}),onClick:Oe(me.onClick,fe),onPointerDown:Oe(me.onPointerDown,ye),onFocus:Oe(me.onFocus,Y),onBlur:Oe(me.onBlur,H),"aria-describedby":E?te:void 0}),[Y,H,ye,E,te,fe,R]),ke=A.useCallback((me={},Ee=null)=>$({...me,style:{...me.style,[je.arrowSize.var]:g?`${g}px`:void 0,[je.arrowShadowColor.var]:f}},Ee),[$,g,f]),ve=A.useCallback((me={},Ee=null)=>{const v={...me.style,position:"relative",transformOrigin:je.transformOrigin.varRef};return{ref:Ee,...O,...me,id:te,role:"tooltip",style:v}},[O,te]);return{isOpen:E,show:Y,hide:H,getTriggerProps:le,getTooltipProps:ve,getTooltipPositionerProps:ke,getArrowProps:B,getArrowInnerProps:j}}var co="chakra-ui:close-tooltip";function Yd(t,e){return A.useEffect(()=>{const n=Po(t);return n.addEventListener(co,e),()=>n.removeEventListener(co,e)},[e,t]),()=>{const n=Po(t),r=dr(t);n.dispatchEvent(new r.CustomEvent(co))}}function Xd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Qd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var ef=de(ds.div),zt=he((t,e)=>{var n,r;const o=Kr("Tooltip",t),s=tt(t),i=us(),{children:a,label:l,shouldWrapChildren:c,"aria-label":u,hasArrow:d,bg:p,portalProps:h,background:g,backgroundColor:f,bgColor:y,motionProps:m,...w}=s,_=(r=(n=g??f)!=null?n:p)!=null?r:y;if(_){o.bg=_;const $=Ml(i,"colors",_);o[je.arrowBg.var]=$}const k=Jd({...w,direction:i.direction}),x=typeof a=="string"||c;let O;if(x)O=D.jsx(de.span,{display:"inline-block",tabIndex:0,...k.getTriggerProps(),children:a});else{const $=A.Children.only(a);O=A.cloneElement($,k.getTriggerProps($.props,$.ref))}const E=!!u,N=k.getTooltipProps({},e),P=E?Xd(N,["role","id"]):N,R=Qd(N,["role","id"]);return l?D.jsxs(D.Fragment,{children:[O,D.jsx(zl,{children:k.isOpen&&D.jsx(Aa,{...h,children:D.jsx(de.div,{...k.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:D.jsxs(ef,{variants:Gd,initial:"exit",animate:"enter",exit:"exit",...m,...P,__css:o,children:[l,E&&D.jsx(de.span,{srOnly:!0,...R,children:u}),d&&D.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:D.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):D.jsx(D.Fragment,{children:a})});zt.displayName="Tooltip";let er;const tf=new Uint8Array(16);function nf(){if(!er&&(er=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!er))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return er(tf)}const Re=[];for(let t=0;t<256;++t)Re.push((t+256).toString(16).slice(1));function rf(t,e=0){return Re[t[e+0]]+Re[t[e+1]]+Re[t[e+2]]+Re[t[e+3]]+"-"+Re[t[e+4]]+Re[t[e+5]]+"-"+Re[t[e+6]]+Re[t[e+7]]+"-"+Re[t[e+8]]+Re[t[e+9]]+"-"+Re[t[e+10]]+Re[t[e+11]]+Re[t[e+12]]+Re[t[e+13]]+Re[t[e+14]]+Re[t[e+15]]}const of=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ha={randomUUID:of};function Fn(t,e,n){if(ha.randomUUID&&!e&&!t)return ha.randomUUID();t=t||{};const r=t.random||(t.rng||nf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=r[o];return e}return rf(r)}async function sf(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await fetch(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function af(t,e){try{return await(await fetch("/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 lf(t,e){try{return await(await fetch("/workspace/update_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,json_str:e})})).text()}catch(n){alert("Error saving workflow .json file: "+n),console.error("Error saving workspace:",n)}}async function Ii(t,e=!1){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,deleteEmptyFolder:e})})).text()}catch(n){console.error("Error deleting file:",n)}}async function Np(t){try{return await(await fetch("/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 Fp(){try{return await(await fetch("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function cf(){const e=await(await fetch("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function Rp(){try{return await(await fetch("/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 Tp(){try{return await(await fetch("/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 Bp(t){try{return await(await fetch("/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 Mp(t,e){try{return await(await fetch("/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 uf="backup",Cr="workspace";let tr=null;function df(){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 ff(){try{return tr==null&&(tr=await df()),new Promise((t,e)=>{if(tr==null)return e("indexDB is null");const o=tr.transaction([Cr],"readonly").objectStore(Cr).get(uf);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 hf(){try{return await ff()}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,Ae=Object.keys,Me=Array.isArray;function Ue(t,e){return typeof e!="object"||Ae(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ce.Promise||(Ce.Promise=Promise);const Rn=Object.getPrototypeOf,pf={}.hasOwnProperty;function Ze(t,e){return pf.call(t,e)}function un(t,e){typeof e=="function"&&(e=e(Rn(t))),(typeof Reflect>"u"?Ae:Reflect.ownKeys)(e).forEach(n=>{pt(t,n,e[n])})}const Di=Object.defineProperty;function pt(t,e,n,r){Di(t,e,Ue(n&&Ze(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function nn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),pt(t.prototype,"constructor",t),{extend:un.bind(null,t.prototype)}}}}const mf=Object.getOwnPropertyDescriptor;function Fs(t,e){let n;return mf(t,e)||(n=Rn(t))&&Fs(n,e)}const yf=[].slice;function Sr(t,e,n){return yf.call(t,e,n)}function Pi(t,e){return e(t)}function bn(t){if(!t)throw new Error("Assertion Failed")}function ji(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Ai(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function mt(t,e){if(Ze(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]),gf=Ri.map(t=>Ce[t]);Ai(Ri,t=>[t,!0]);let bt=null;function Hn(t){bt=typeof WeakMap<"u"&&new WeakMap;const e=jo(t);return bt=null,e}function jo(t){if(!t||typeof t!="object")return t;let e=bt&&bt.get(t);if(e)return e;if(Me(t)){e=[],bt&&bt.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),bt&&bt.set(t,e),t)Ze(t,o)&&(e[o]=jo(t[o]))}return e}const{toString:wf}={};function Ao(t){return wf.call(t).slice(8,-1)}const No=typeof Symbol<"u"?Symbol.iterator:"@@iterator",bf=typeof No=="symbol"?function(t){var e;return t!=null&&(e=t[No])&&e.apply(t)}:function(){return null},Qt={};function ft(t){var e,n,r,o;if(arguments.length===1){if(Me(t))return t.slice();if(this===Qt&&typeof t=="string")return[t];if(o=bf(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 Rs=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var lt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ti(t,e){lt=t,Bi=e}var Bi=()=>!0;const _f=!new Error("").stack;function Ht(){if(_f)try{throw Ht.arguments,new Error}catch(t){return t}return new Error}function Fo(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(Bi).map(r=>` -`+r).join("")):""}var Mi=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ts=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Mi),kf={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 rn(t,e){this._e=Ht(),this.name=t,this.message=e}function zi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function Or(t,e,n,r){this._e=Ht(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=zi(t,e)}function Sn(t,e){this._e=Ht(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=zi(t,e)}nn(rn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Fo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),nn(Or).from(rn),nn(Sn).from(rn);var Bs=Ts.reduce((t,e)=>(t[e]=e+"Error",t),{});const xf=rn;var ce=Ts.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Ht(),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=kf[e]||n,this.inner=null)}return nn(r).from(xf),t[e]=r,t},{});ce.Syntax=SyntaxError,ce.Type=TypeError,ce.Range=RangeError;var pa=Mi.reduce((t,e)=>(t[e+"Error"]=ce[e],t),{}),fr=Ts.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=ce[e]),t),{});function be(){}function Tn(t){return t}function Ef(t,e){return t==null||t===Tn?e:function(n){return e(t(n))}}function qt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Cf(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?qt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?qt(o,this.onerror):o),s!==void 0?s:n}}function Sf(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?qt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?qt(r,this.onerror):r)}}function Of(t,e){return t===be?e:function(n){var r=t.apply(this,arguments);Ue(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?qt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?qt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function If(t,e){return t===be?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ms(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)}}fr.ModifyError=Or,fr.DexieError=rn,fr.BulkError=Sn;var Bn={};const Li=100,[Ro,Ir,To]=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]})(),Wi=Ir&&Ir.then,hr=Ro&&Ro.constructor,zs=!!To;var Bo=!1,Df=To?()=>{To.then(nr)}:Ce.setImmediate?setImmediate.bind(null,nr):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{nr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(nr,0)},On=function(t,e){_n.push([t,e]),Dr&&(Df(),Dr=!1)},Mo=!0,Dr=!0,Lt=[],pr=[],zo=null,Lo=Tn,on={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:va,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{va(t[0],t[1])}catch{}})}},ie=on,_n=[],Wt=0,mr=[];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=ie;if(lt&&(this._stackHolder=Ht(),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&&Uo(this,this._value))}this._state=null,this._value=null,++e.ref,Ki(this,t)}const Wo={get:function(){var t=ie,e=Pr;function n(r,o){var s=!t.global&&(t!==ie||e!==Pr);const i=s&&!vt();var a=new oe((l,c)=>{Ls(this,new Ui(jr(r,t,s,i),jr(o,t,s,i),l,c,t))});return lt&&Vi(a,this),a}return n.prototype=Bn,n},set:function(t){pt(this,"then",t&&t.prototype===Bn?Wo:{get:function(){return t},set:Wo.set})}};function Ui(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 Ki(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"?Ki(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,$i(t)),r&&Gn()}},Uo.bind(null,t))}catch(n){Uo(t,n)}}function Uo(t,e){if(pr.push(e),t._state===null){var n=t._lib&&Zn();e=Lo(e),t._state=!1,t._value=e,lt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Fs(e,"stack");e._promise=t,pt(e,"stack",{get:()=>Bo?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Lt.some(o=>o._value===r._value)||Lt.push(r)}(t),$i(t),n&&Gn()}}function $i(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Wt==0&&Ws()},[]))}function Ls(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,++Wt,On(Pf,[n,t,e])}else t._listeners.push(e)}function Pf(t,e,n){try{zo=e;var r,o=e._value;e._state?r=t(o):(pr.length&&(pr=[]),r=t(o),pr.indexOf(o)===-1&&function(s){for(var i=Lt.length;i;)if(Lt[--i]._value===s._value)return void Lt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{zo=null,--Wt==0&&Ws(),--n.psd.ref||n.psd.finalize()}}function qi(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=Fo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return lt&&((r=Fo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&qi(t._prev,e,n)),e}function Vi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function nr(){Zn()&&Gn()}function Zn(){var t=Mo;return Mo=!1,Dr=!1,t}function Gn(){var t,e,n;do for(;_n.length>0;)for(t=_n,_n=[],n=t.length,e=0;e0);Mo=!0,Dr=!0}function Ws(){var t=Lt;Lt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=mr.slice(0),n=e.length;n;)e[--n]()}function rr(t){return new oe(Bn,!1,t)}function Se(t,e){var n=ie;return function(){var r=Zn(),o=ie;try{return Ot(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Ot(o,!1),r&&Gn()}}}un(oe.prototype,{then:Wo,_then:function(t,e){Ls(this,new Ui(null,null,t,e,ie))},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):rr(r)):this.then(null,r=>r&&r.name===e?n(r):rr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),rr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Bo=!0;var t=qi(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{Bo=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ce.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&pt(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),on.env=Hi(),un(oe,{all:function(){var t=ft.apply(null,arguments).map(or);return new oe(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>oe.resolve(o).then(i=>{t[s]=i,--r||e(t)},n))})},resolve:t=>{if(t instanceof oe)return t;if(t&&typeof t.then=="function")return new oe((n,r)=>{t.then(n,r)});var e=new oe(Bn,!0,t);return Vi(e,zo),e},reject:rr,race:function(){var t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ie,set:t=>ie=t},totalEchoes:{get:()=>Pr},newPSD:St,usePSD:pn,scheduler:{get:()=>On,set:t=>{On=t}},rejectionMapper:{get:()=>Lo,set:t=>{Lo=t}},follow:(t,e)=>new oe((n,r)=>St((o,s)=>{var i=ie;i.unhandleds=[],i.onunhandled=s,i.finalize=qt(function(){(function(a){function l(){a(),mr.splice(mr.indexOf(l),1)}mr.push(l),++Wt,On(()=>{--Wt==0&&Ws()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),hr&&(hr.allSettled&&pt(oe,"allSettled",function(){const t=ft.apply(null,arguments).map(or);return new oe(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>oe.resolve(o).then(i=>r[s]={status:"fulfilled",value:i},i=>r[s]={status:"rejected",reason:i}).then(()=>--n||e(r)))})}),hr.any&&typeof AggregateError<"u"&&pt(oe,"any",function(){const t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,i)=>oe.resolve(s).then(a=>e(a),a=>{o[i]=a,--r||n(new AggregateError(o))}))})}));const Be={awaits:0,echoes:0,id:0};var jf=0,yr=[],uo=0,Pr=0,Af=0;function St(t,e,n,r){var o=ie,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Af;var i=on.env;s.env=zs?{Promise:oe,PromiseProp:{value:oe,configurable:!0,writable:!0},all:oe.all,race:oe.race,allSettled:oe.allSettled,any:oe.any,resolve:oe.resolve,reject:oe.reject,nthen:ma(i.nthen,s),gthen:ma(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=pn(s,t,n,r);return s.ref===0&&s.finalize(),a}function hn(){return Be.id||(Be.id=++jf),++Be.awaits,Be.echoes+=Li,Be.id}function vt(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Li,!0)}function or(t){return Be.echoes&&t&&t.constructor===hr?(hn(),t.then(e=>(vt(),e),e=>(vt(),Ne(e)))):t}function Nf(t){++Pr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),yr.push(ie),Ot(t,!0)}function Ff(){var t=yr[yr.length-1];yr.pop(),Ot(t,!1)}function Ot(t,e){var n=ie;if((e?!Be.echoes||uo++&&t===ie:!uo||--uo&&t===ie)||Zi(e?Nf.bind(null,t):Ff),t!==ie&&(ie=t,n===on&&(on.env=Hi()),zs)){var r=on.env.Promise,o=t.env;Ir.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ce,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function Hi(){var t=Ce.Promise;return zs?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ce,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Ir.then,gthen:t.prototype.then}:{}}function pn(t,e,n,r,o){var s=ie;try{return Ot(t,!0),e(n,r,o)}finally{Ot(s,!1)}}function Zi(t){Wi.call(Ro,t)}function jr(t,e,n,r){return typeof t!="function"?t:function(){var o=ie;n&&hn(),Ot(e,!0);try{return t.apply(this,arguments)}finally{Ot(o,!1),r&&Zi(vt)}}}function ma(t,e){return function(n,r){return t.call(this,jr(n,e),jr(r,e))}}(""+Wi).indexOf("[native code]")===-1&&(hn=vt=be);const ya="unhandledrejection";function va(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ce.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ya,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(ya,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}lt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Ne=oe.reject;function Ko(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ie.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ko(t,e,n,r))):Ne(s)}return o._promise(e,(s,i)=>St(()=>(ie.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Ne(new ce.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Ne(new ce.DatabaseClosed);t.open().catch(be)}return t._state.dbReadyPromise.then(()=>Ko(t,e,n,r))}const ga="3.2.4",Rt="￿",$o=-1/0,ut="Invalid key provided. Keys must be of type string, number, Date or Array.",Gi="String expected.",In=[],eo=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Rf=eo,Tf=eo,Ji=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),to="__dbnames",fo="readonly",ho="readwrite";function Vt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Yi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Hn(e))[t],e)}class Bf{_trans(e,n,r){const o=this._tx||ie.trans,s=this.name;function i(l,c,u){if(!u.schema[s])throw new ce.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const a=Zn();try{return o&&o.db===this.db?o===ie.trans?o._promise(e,i,r):St(()=>o._promise(e,i,r),{trans:o,transless:ie.transless||ie}):Ko(this.db,e,[this.name],i)}finally{a&&Gn()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(o=>this.hook.reading.fire(o))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(Me(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=Ae(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==Rt)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&<&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[a,l]=n.reduce(([c,u],d)=>{const p=o[d],h=e[d];return[c||p,c||!p?Vt(u,p&&p.multi?g=>{const f=mt(g,d);return Me(f)&&f.some(y=>i(h,y))}:g=>i(h,mt(g,d))):u]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,Me(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const o=Object.create(e.prototype);for(var s in r)if(Ze(r,s))try{o[s]=r[s]}catch{}return o};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){Ue(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[s]})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||Me(e))return this.where(":id").equals(e).modify(n);{const r=mt(e,this.schema.primKey.keyPath);if(r===void 0)return Ne(new ce.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ae(n).forEach(o=>{nt(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:n!=null?[n]:null})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?oe.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Yi})).then(e=>e.numFailures?oe.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(o=>this.hook.reading.fire(o))))}bulkAdd(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,g)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,g)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new Sn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Dn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[i].subscribe.apply(null,c),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rVt(r(),e()):e,t.justLimit=n&&!r}function vr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ce.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function wa(t,e,n){const r=vr(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function ar(t,e,n,r){const o=t.replayFilter?Vt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,c)=>{if(!o||o(l,c,p=>l.stop(p),p=>l.fail(p))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Ze(s,d)||(s[d]=!0,e(a,l,c))}};return Promise.all([t.or._iterate(i,n),ba(wa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ba(wa(t,r,n),Vt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ba(t,e,n,r){var o=Se(r?(s,i,a)=>n(r(s),i,a):n);return t.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();e&&!e(s,a=>i=a,a=>{s.stop(a),i=be},a=>{s.fail(a),i=be})||o(s.value,s,a=>i=a),i()})})}function Le(t,e){try{const n=_a(t),r=_a(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tar(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Yt(r,!0))return o.count({trans:n,query:{index:vr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return ar(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(c,u){return u?i(c[r[u]],u-1):c[o]}var a=this._ctx.dir==="next"?1:-1;function l(c,u){var d=i(c,s),p=i(u,s);return dp?a:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Yt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=vr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:i})=>o?i.map(o):i)}{const o=[];return ar(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Yt(n)?mo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):mo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),mo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return po(this._ctx,function(r,o,s){return!e(r.value)||(o(s),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return po(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Vt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Yt(n,!0)&&n.limit>0)return this._read(o=>{var s=vr(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return po(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ze(r,s);return r[s]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=Ae(e),i=s.length;o=function(f){for(var y=!1,m=0;m{const{failures:m,numFailures:w}=y;p+=f-w;for(let _ of Ae(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const w=Math.min(u,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+w),cache:"immutable"}).then(_=>{const k=[],x=[],O=l?[]:null,E=[];for(let P=0;P0&&a.mutate({trans:r,type:"add",values:k}).then(P=>{for(let R in P.failures)E.splice(parseInt(R),1);g(k.length,P)})).then(()=>(x.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:x,criteria:N,changeSpec:typeof e!="function"&&e}).then(P=>g(x.length,P))).then(()=>(E.length>0||N&&e===yo)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(P=>g(E.length,P))).then(()=>f.length>m+w&&y(m+u))})};return y(0).then(()=>{if(d.length>0)throw new Or("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return Yt(e)&&(e.isPrimKey&&!Tf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:c,numFailures:u})=>{if(u)throw new Or("Could not delete some values",Object.keys(a).map(d=>a[d]),i-u);return i-u}))}):this.modify(yo)}}const yo=(t,e)=>e.value=null;function zf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Qi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Xt(t){return new t.Collection(t,()=>Xi("")).limit(0)}function Wf(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],c)<0&&(a=l)}return itypeof f=="string"))return qe(t,Gi);function p(f){o=function(m){return m==="next"?w=>w.toUpperCase():w=>w.toLowerCase()}(f),s=function(m){return m==="next"?w=>w.toLowerCase():w=>w.toUpperCase()}(f),i=f==="next"?zf:Lf;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,w){return i(m.lower,w.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),c=f,u=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>wt(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var g=0;return h._addAlgorithm(function(f,y,m){var w=f.key;if(typeof w!="string")return!1;var _=s(w);if(e(_,l,g))return!0;for(var k=null,x=g;x0)&&(k=O)}return y(k!==null?function(){f.continue(k+u)}:m),!1}),h}function wt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Xi(t){return{type:1,lower:t,upper:t}}class Qi{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,o){r=r!==!1,o=o===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||o)&&(!r||!o)?Xt(this):new this.Collection(this,()=>wt(e,n,!r,!o))}catch{return qe(this,ut)}}equals(e){return e==null?qe(this,ut):new this.Collection(this,()=>Xi(e))}above(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!1))}below(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Gi):this.between(e,e+Rt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ir(this,(n,r)=>n.indexOf(r[0])===0,[e],Rt)}equalsIgnoreCase(e){return ir(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Rt)}anyOf(){const e=ft.apply(Qt,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ut)}if(e.length===0)return Xt(this);const r=new this.Collection(this,()=>wt(e[0],e[e.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((s,i,a)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return i(a),!1;return n(l,e[o])===0||(i(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[$o,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=ft.apply(Qt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ut)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[$o,o]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,o=this._ascending,s=this._descending,i=this._min,a=this._max;if(e.length===0)return Xt(this);if(!e.every(w=>w[0]!==void 0&&w[1]!==void 0&&o(w[0],w[1])<=0))return qe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ce.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function p(w,_){return d(w[0],_[0])}try{u=e.reduce(function(w,_){let k=0,x=w.length;for(;k0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return k===x&&w.push(_),w},[]),u.sort(p)}catch{return qe(this,ut)}let h=0;const g=c?w=>o(w,u[h][1])>0:w=>o(w,u[h][1])>=0,f=l?w=>s(w,u[h][0])>0:w=>s(w,u[h][0])>=0;let y=g;const m=new this.Collection(this,()=>wt(u[0][0],u[u.length-1][1],!l,!c));return m._ondirectionchange=w=>{w==="next"?(y=g,d=o):(y=f,d=s),u.sort(p)},m._addAlgorithm((w,_,k)=>{for(var x=w.key;y(x);)if(++h,h===u.length)return _(k),!1;return!!function(O){return!g(O)&&!f(O)}(x)||(this._cmp(x,u[h][1])===0||this._cmp(x,u[h][0])===0||_(()=>{d===o?w.continue(u[h][0]):w.continue(u[h][1])}),!1)}),m}startsWithAnyOf(){const e=ft.apply(Qt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Xt(this):this.inAnyRange(e.map(n=>[n,n+Rt])):qe(this,"startsWithAnyOf() only works with strings")}}function st(t){return Se(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const zn="storagemutated",_t="x-storagemutated-1",It=Dn(null,zn);class Uf{_lock(){return bn(!ie.global),++this._reculock,this._reculock!==1||ie.global||(ie.lockOwnerFor=this),this}_unlock(){if(bn(!ie.global),--this._reculock==0)for(ie.global||(ie.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{pn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ie.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(bn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ce.DatabaseClosed(r);case"MissingAPIError":throw new ce.MissingAPI(r.message,r);default:throw new ce.OpenFailed(r)}if(!this.active)throw new ce.TransactionInactive;return bn(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Se(o=>{Mn(o),this._reject(e.error)}),e.onabort=Se(o=>{Mn(o),this.active&&this._reject(new ce.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&It.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Ne(new ce.ReadOnly("Transaction is readonly"));if(!this.active)return Ne(new ce.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ie])});if(r)return St(()=>{var s=new oe((i,a)=>{this._lock();const l=n(i,a,this);l&&l.then&&l.then(i,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new oe((s,i)=>{var a=n(s,i,this);a&&a.then&&a.then(s,i)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=oe.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=i)})()}var s=n._waitingFor;return new oe((i,a)=>{r.then(l=>n._waitingQueue.push(Se(i.bind(null,l))),l=>n._waitingQueue.push(Se(a.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ce.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ze(n,e))return n[e];const r=this.schema[e];if(!r)throw new ce.NotFound("Table "+e+" not part of transaction");const o=new this.db.Table(e,r,this);return o.core=this.db.core.table(e),n[e]=o,o}}function qo(t,e,n,r,o,s,i){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+el(e)}}function el(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function tl(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ai(n,r=>[r.name,r])}}let Ln=t=>{try{return t.only([[]]),Ln=()=>[[]],[[]]}catch{return Ln=()=>Rt,Rt}};function Vo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>mt(r,e)}(t):e=>mt(e,t)}function xa(t){return[].slice.call(t)}let Kf=0;function Pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function $f(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:p}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!p):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,c){const u=xa(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,g=Me(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:g,keyPath:p,autoIncrement:h,unique:!0,extractKey:Vo(p)},indexes:xa(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:_,unique:k,multiEntry:x,keyPath:O}=w,E={name:_,compound:Me(O),keyPath:O,unique:k,multiEntry:x,extractKey:Vo(O)};return y[Pn(O)]=E,E}),getIndexByKeyPath:w=>y[Pn(w)]};return y[":id"]=m.primaryKey,p!=null&&(y[Pn(p)]=m.primaryKey),m})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:p,keys:h,values:g,range:f}){return new Promise((y,m)=>{y=Se(y);const w=d.objectStore(u),_=w.keyPath==null,k=p==="put"||p==="add";if(!k&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:x}=h||g||{length:1};if(h&&g&&h.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(x===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let P=0;const R=j=>{++P,Mn(j)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:P,failures:N,results:[],lastResult:void 0});f.type===3?E.push(O=w.clear()):E.push(O=w.delete(r(f)))}else{const[j,B]=k?_?[g,h]:[g,null]:[h,null];if(k)for(let b=0;b{const B=j.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:P,failures:N,results:p==="delete"?h:E.map(b=>b.result),lastResult:B})};O.onerror=j=>{R(j),$(j)},O.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,g)=>{h=Se(h);const f=d.objectStore(u),y=p.length,m=new Array(y);let w,_=0,k=0;const x=E=>{const N=E.target;m[N._pos]=N.result,++k===_&&h(m)},O=st(g);for(let E=0;Enew Promise((h,g)=>{h=Se(h);const f=d.objectStore(u).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=st(g)}),query:function(d){return p=>new Promise((h,g)=>{h=Se(h);const{trans:f,values:y,limit:m,query:w}=p,_=m===1/0?void 0:m,{index:k,range:x}=w,O=f.objectStore(u),E=k.isPrimaryKey?O:O.index(k.name),N=r(x);if(m===0)return h({result:[]});if(d){const P=y?E.getAll(N,_):E.getAllKeys(N,_);P.onsuccess=R=>h({result:R.target.result}),P.onerror=st(g)}else{let P=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];R.onsuccess=j=>{const B=R.result;return B?($.push(y?B.value:B.primaryKey),++P===m?h({result:$}):void B.continue()):h({result:$})},R.onerror=st(g)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:g,unique:f}){return new Promise((y,m)=>{y=Se(y);const{index:w,range:_}=h,k=d.objectStore(u),x=w.isPrimaryKey?k:k.index(w.name),O=g?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in x)?x.openCursor(r(_),O):x.openKeyCursor(r(_),O);E.onerror=st(m),E.onsuccess=Se(N=>{const P=E.result;if(!P)return void y(null);P.___id=++Kf,P.done=!1;const R=P.continue.bind(P);let $=P.continuePrimaryKey;$&&($=$.bind(P));const j=P.advance.bind(P),B=()=>{throw new Error("Cursor not stopped")};P.trans=d,P.stop=P.continue=P.continuePrimaryKey=P.advance=()=>{throw new Error("Cursor not started")},P.fail=Se(m),P.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},P.start=b=>{const K=new Promise((S,G)=>{S=Se(S),E.onerror=st(G),P.fail=G,P.stop=z=>{P.stop=P.continue=P.continuePrimaryKey=P.advance=B,S(z)}}),te=()=>{if(E.result)try{b()}catch(S){P.fail(S)}else P.done=!0,P.start=()=>{throw new Error("Cursor behind last entry")},P.stop()};return E.onsuccess=Se(S=>{E.onsuccess=te,te()}),P.continue=R,P.continuePrimaryKey=$,P.advance=j,te(),K},y(P)},m)})},count({query:d,trans:p}){const{index:h,range:g}=d;return new Promise((f,y)=>{const m=p.objectStore(u),w=h.isPrimaryKey?m:m.index(h.name),_=r(g),k=_?w.count(_):w.count();k.onsuccess=Se(x=>f(x.target.result)),k.onerror=st(y)})}}}(l)),a={};return i.forEach(l=>a[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!a[l])throw new Error(`Table '${l}' not found`);return a[l]},MIN_KEY:-1/0,MAX_KEY:Ln(e),schema:o}}function Ho({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(u,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),u)}($f(s,i,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const s=o.name;t.core.schema.tables.some(i=>i.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function Ar({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Fs(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?pt(i,o,{get(){return this.table(o)},set(l){Di(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function Zo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function qf(t,e){return t._cfg.version-e._cfg.version}function Vf(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const i=s._reject.bind(s),a=ie.transless||ie;St(()=>{ie.trans=s,ie.transless=a,e===0?(Ae(o).forEach(l=>{vo(n,l,o[l].primKey,o[l].indexes)}),Ho(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},c,u,d){const p=[],h=l._versions;let g=l._dbSchema=Jo(l,l.idbdb,d),f=!1;const y=h.filter(w=>w._cfg.version>=c);function m(){return p.length?oe.resolve(p.shift()(u.idbtrans)).then(m):oe.resolve()}return y.forEach(w=>{p.push(()=>{const _=g,k=w._cfg.dbschema;Yo(l,_,d),Yo(l,k,d),g=l._dbSchema=k;const x=nl(_,k);x.add.forEach(E=>{vo(d,E[0],E[1].primKey,E[1].indexes)}),x.change.forEach(E=>{if(E.recreate)throw new ce.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(P=>Go(N,P)),E.change.forEach(P=>{N.deleteIndex(P.name),Go(N,P)}),E.del.forEach(P=>N.deleteIndex(P))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>c){Ho(l,d),u._memoizedTables={},f=!0;let E=Ni(k);x.del.forEach($=>{E[$]=_[$]}),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],Ae(E),E),u.schema=E;const N=Rs(O);let P;N&&hn();const R=oe.follow(()=>{if(P=O(u),P&&N){var $=vt.bind(null,null);P.then($,$)}});return P&&typeof P.then=="function"?oe.resolve(P):R.then(()=>P)}}),p.push(_=>{(!f||!Rf)&&function(k,x){[].slice.call(x.db.objectStoreNames).forEach(O=>k[O]==null&&x.db.deleteObjectStore(O))}(w._cfg.dbschema,_),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),m().then(()=>{var w,_;_=d,Ae(w=g).forEach(k=>{_.db.objectStoreNames.contains(k)||vo(_,k,w[k].primKey,w[k].indexes)})})}(t,e,s,n).catch(i)})}function nl(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const o=t[r],s=e[r];if(o){const i={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!eo)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let c;for(c in a)l[c]||i.del.push(c);for(c in l){const u=a[c],d=l[c];u?u.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function vo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>Go(o,s)),o}function Go(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Jo(t,e,n){const r={};return Sr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=qo(el(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return qo(l,c||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Me(c),a===0)}),s=o.shift();if(s.multi)throw new ce.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ce.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ce.Schema("Index must have a name and cannot be an empty string")}),n[r]=tl(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ue(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{Ue(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,Zo(n,[n._allTables,n,n.Transaction.prototype]),Ar(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ae(s),s),n._storeNames=Ae(s),this}upgrade(e){return this._cfg.contentUpgrade=Ms(this._cfg.contentUpgrade||be,e),this}}function Us(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Ut(to,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ks(t){return t&&typeof t.databases=="function"}function Xo(t){return St(function(){return ie.letThrough=!0,t()})}function Zf(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Gf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Ne(e.dbOpenError):t);lt&&(e.openCanceller._stackHolder=Ht()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ce.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Zf()).then(()=>new oe((l,c)=>{if(o(),!n)throw new ce.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new ce.MissingAPI;d.onerror=st(c),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,i.abort(),d.result.close();const g=n.deleteDatabase(u);g.onsuccess=g.onerror=Se(()=>{c(new ce.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{i.onerror=st(c);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,Vf(t,h/10,i,c)}},c),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Sr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((g=h).length===1?g[0]:g,"readonly");e.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const _=y._dbSchema=Jo(0,m,w);y._storeNames=Sr(m.objectStoreNames,0),Ar(y,[y._allTables],Ae(_),_)}(t,p,f):(Yo(t,t._dbSchema,f),function(y,m){const w=nl(Jo(0,y.idbdb,m),y._dbSchema);return!(w.add.length||w.change.some(_=>_.add.length||_.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ho(t,f)}catch{}var g;In.push(t),p.onversionchange=Se(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Se(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:y},m){!Ks(f)&&m!==to&&Us(f,y).put({name:m}).catch(be)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Xo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ms,be);return e.onReadyBeingFired=[],oe.resolve(Xo(()=>c(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Ne(l)}).finally(()=>{e.openComplete=!0,s()})}function Qo(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return i=>{var a=s(i),l=a.value;return a.done?l:l&&typeof l.then=="function"?l.then(n,r):Me(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function Jf(t,e,n){var r=arguments.length;if(r<2)throw new ce.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Fi(o),n]}function rl(t,e,n,r,o){return oe.resolve().then(()=>{const s=ie.transless||ie,i=t._createTransaction(e,n,t._dbSchema,r),a={trans:i,transless:s};if(r)i.idbtrans=r.idbtrans;else try{i.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>rl(t,e,n,null,o))):Ne(d)}const l=Rs(o);let c;l&&hn();const u=oe.follow(()=>{if(c=o.call(i,i),c)if(l){var d=vt.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Qo(c))},a);return(c&&typeof c.then=="function"?oe.resolve(c).then(d=>i.active?d:Ne(new ce.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Ne(d)))})}function lr(t,e,n){const r=Me(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Vo(u),unique:!y&&p.unique};return g.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?u[0]:u.slice(0,f-1),d+1,p),g.sort((w,_)=>w.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const u of r.indexes)i(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(p=u.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:lr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:lr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:u;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(u){const d=o[Pn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:p,keyLength:h}=u.query.index;return p?n.openCursor(l(u)).then(g=>g&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(lr(m,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?f.continue(f.key.slice(0,h).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,w){f.continuePrimaryKey(lr(m,t.MAX_KEY,d),w)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const m=f.key;return h===1?m[0]:m.slice(0,h)}},value:{get:()=>f.value}})}(g)):n.openCursor(u)}}}}}};function $s(t,e,n,r){return n=n||{},r=r||"",Ae(t).forEach(o=>{if(Ze(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Ao(s);a!==Ao(i)?n[r+o]=e[o]:a==="Object"?$s(s,i,n,r+o+"."):s!==i&&(n[r+o]=e[o])}else s!==i&&(n[r+o]=e[o])}else n[r+o]=void 0}),Ae(e).forEach(o=>{Ze(t,o)||(n[r+o]=e[o])}),n}const Xf={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=ie.trans,{deleting:a,creating:l,updating:c}=i.table(e).hook;switch(s.type){case"add":if(l.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"put":if(l.fire===be&&c.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"delete":if(a.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"deleteRange":if(a.fire===be)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function u(p){const h=ie.trans,g=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!g)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:g}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(f,y,m){return y.type==="add"?Promise.resolve([]):f.getMany({trans:y.trans,keys:m,cache:"immutable"})}(n,p,g).then(f=>{const y=g.map((m,w)=>{const _=f[w],k={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(k,m,_,h);else if(p.type==="add"||_===void 0){const x=l.fire.call(k,m,p.values[w],h);m==null&&x!=null&&(m=x,p.keys[w]=m,r.outbound||nt(p.values[w],r.keyPath,m))}else{const x=$s(_,p.values[w]),O=c.fire.call(k,x,m,_,h);if(O){const E=p.values[w];Object.keys(O).forEach(N=>{Ze(E,N)?E[N]=O[N]:nt(E,N,O[N])})}}return k});return n.mutate(p).then(({failures:m,results:w,numFailures:_,lastResult:k})=>{for(let x=0;x(y.forEach(w=>w.onerror&&w.onerror(m)),Promise.reject(m)))})}function d(p,h,g){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:g}).then(({result:f})=>u({type:"delete",keys:f,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=ol(r.keys,r.trans._cache,r.cache==="clone");return o?oe.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Hn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const dt=function(t,e){if(!this){const n=new dt;return t&&"d"in t&&Ue(n,t),n}Ue(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Wn(t,e,n){const r=Le(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(qs(t))return Ue(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(Le(n,t.from)<0)return o?Wn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ea(t);if(Le(e,t.to)>0)return s?Wn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ea(t);Le(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),Le(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const i=!t.r;o&&!t.l&&Nr(t,o),s&&i&&Nr(t,s)}function Nr(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Wn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function eh(t,e){const n=es(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=es(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(Le(a.from,o.to)<=0&&Le(a.to,o.from)>=0)return!0;Le(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function es(t){let e=qs(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&Le(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||Le(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ea(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",i={...t},a=t[o];t.from=a.from,t.to=a.to,t[o]=a[o],i[o]=a[s],t[s]=i,i.d=Ca(i)}t.d=Ca(t)}function Ca({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}un(dt.prototype,{add(t){return Nr(this,t),this},addKey(t){return Wn(this,t,t),this},addKeys(t){return t.forEach(e=>Wn(this,e,e)),this},[No](){return es(this)}});const th={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new dt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,c={...o,mutate:p=>{const h=p.trans,g=h.mutatedParts||(h.mutatedParts={}),f=O=>{const E=`idb://${e}/${r}/${O}`;return g[E]||(g[E]=new dt)},y=f(""),m=f(":dels"),{type:w}=p;let[_,k]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const x=p.trans._cache;return o.mutate(p).then(O=>{if(Me(_)){w!=="delete"&&(_=O.results),y.addKeys(_);const E=ol(_,x);E||w==="add"||m.addKeys(_),(E||k)&&function(N,P,R,$){function j(B){const b=N(B.name||"");function K(S){return S!=null?B.extractKey(S):null}const te=S=>B.multiEntry&&Me(S)?S.forEach(G=>b.addKey(G)):b.addKey(S);(R||$).forEach((S,G)=>{const z=R&&K(R[G]),Q=$&&K($[G]);Le(z,Q)!==0&&(z!=null&&te(z),Q!=null&&te(Q))})}P.indexes.forEach(j)}(f,s,E,k)}else if(_){const E={from:_.lower,to:_.upper};m.add(E),y.add(E)}else y.add(n),m.add(n),s.indexes.forEach(E=>f(E.name).add(n));return O})}},u=({query:{index:p,range:h}})=>{var g,f;return[p,new dt((g=h.lower)!==null&&g!==void 0?g:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new dt(p.key)],getMany:p=>[i,new dt().addKeys(p.keys)],count:u,query:u,openCursor:u};return Ae(d).forEach(p=>{c[p]=function(h){const{subscr:g}=ie;if(g){const f=k=>{const x=`idb://${e}/${r}/${k}`;return g[x]||(g[x]=new dt)},y=f(""),m=f(":dels"),[w,_]=d[p](h);if(f(w.name||"").add(_),!w.isPrimaryKey){if(p!=="count"){const k=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(x=>{if(p==="query"){if(l&&h.values)return k.then(({result:E})=>(y.addKeys(E),x));const O=h.values?x.result.map(a):x.result;h.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=x,E=h.values;return O&&Object.create(O,{key:{get:()=>(m.addKey(O.primaryKey),O.key)},primaryKey:{get(){const N=O.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(O.primaryKey),O.value)}})}return x})}m.add(n)}}return o[p].apply(this,arguments)}}),c}}}};class Ut{constructor(e,n){this._middlewares={},this.verno=0;const r=Ut.dependencies;this._options=n={addons:Ut.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:be,dbReadyPromise:null,cancelOpen:be,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new oe(a=>{s.dbReadyResolve=a}),s.openCanceller=new oe((a,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=Dn(this,"populate","blocked","versionchange","close",{ready:[Ms,be]}),this.on.ready.subscribe=Pi(this.on.ready.subscribe,a=>(l,c)=>{Ut.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||oe.resolve().then(l),c&&a(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&a(l);else{a(l);const d=this;c||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,wn(Mf.prototype,function(a,l){this.db=i;let c=Yi,u=null;if(l)try{c=l()}catch(g){u=g}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:h!==Tn?h:null}})),this.Table=function(a){return wn(Bf.prototype,function(l,c,u){this.db=a,this._tx=u,this.name=l,this.schema=c,this.hook=a._allTables[l]?a._allTables[l].hook:Dn(null,{creating:[Cf,be],reading:[Ef,Tn],updating:[Of,be],deleting:[Sf,be]})})}(this),this.Transaction=function(a){return wn(Uf.prototype,function(l,c,u,d,p){this.db=a,this.mode=l,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Dn(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new oe((h,g)=>{this._resolve=h,this._reject=g}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var g=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):g&&this.idbtrans&&this.idbtrans.abort(),Ne(h)})})}(this),this.Version=function(a){return wn(Hf.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return wn(Qi.prototype,function(l,c,u){this.db=a,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=a._deps.indexedDB;if(!d)throw new ce.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),In.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Yf),this.use(Xf),this.use(th),this.use(Qf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ce.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ce.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(o=>o._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(qf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ie.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new ce.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ce.DatabaseClosed);this.open().catch(be)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:o}){o&&this.unuse({stack:e,name:o});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:o}),s.sort((i,a)=>i.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(o=>r?o.create!==r:!!n&&o.name!==n)),this}open(){return Gf(this)}_close(){const e=this._state,n=In.indexOf(this);if(n>=0&&In.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new oe(r=>{e.dbReadyResolve=r}),e.openCanceller=new oe((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ce.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},c){!Ks(a)&&c!==to&&Us(a,l).delete(c).catch(be)})(this._deps,this.name),r()}),i.onerror=st(o),i.onblocked=this._fireOnBlocked};if(e)throw new ce.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ae(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Jf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ie.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let i,a;e=e.replace("!","").replace("?","");try{if(a=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===fo)i=fo;else{if(e!="rw"&&e!=ho)throw new ce.InvalidArgument("Invalid transaction mode: "+e);i=ho}if(o){if(o.mode===fo&&i===ho){if(!s)throw new ce.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!s)throw new ce.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Ne(c)}const l=rl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ie.trans?pn(ie.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ze(this._allTables,e))throw new ce.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const nh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class rh{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[nh](){return this}}function sl(t,e){return Ae(e).forEach(n=>{Nr(t[n]||(t[n]=new dt),e[n])}),t}function oh(t){let e,n=!1;const r=new rh(o=>{const s=Rs(t);let i=!1,a={},l={};const c={get closed(){return i},unsubscribe:()=>{i=!0,It.storagemutated.unsubscribe(h)}};o.start&&o.start(c);let u=!1,d=!1;function p(){return Ae(l).some(f=>a[f]&&eh(a[f],l[f]))}const h=f=>{sl(a,f),p()&&g()},g=()=>{if(u||i)return;a={};const f={},y=function(m){s&&hn();const w=()=>St(t,{subscr:m,trans:null}),_=ie.trans?pn(ie.transless,w):w();return s&&_.then(vt,vt),_}(f);d||(It(zn,h),d=!0),u=!0,Promise.resolve(y).then(m=>{n=!0,e=m,u=!1,i||(p()?g():(a={},l=f,o.next&&o.next(m)))},m=>{u=!1,n=!1,o.error&&o.error(m),c.unsubscribe()})};return g(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let ts;try{ts={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{ts={indexedDB:null,IDBKeyRange:null}}const Ft=Ut;function gr(t){let e=ht;try{ht=!0,It.storagemutated.fire(t)}finally{ht=e}}un(Ft,{...fr,delete:t=>new Ft(t,{addons:[]}).delete(),exists:t=>new Ft(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Ks(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==to)):Us(e,n).toCollection().primaryKeys()}(Ft.dependencies).then(t)}catch{return Ne(new ce.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ie.trans?pn(ie.transless,t):t(),vip:Xo,async:function(t){return function(){try{var e=Qo(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Ne(n)}}},spawn:function(t,e,n){try{var r=Qo(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Ne(o)}},currentTransaction:{get:()=>ie.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Ft.ignoreTransaction(t):t).timeout(e||6e4);return ie.trans?ie.trans.waitFor(n):n},Promise:oe,debug:{get:()=>lt,set:t=>{Ti(t,t==="dexie"?()=>!0:Ji)}},derive:nn,extend:Ue,props:un,override:Pi,Events:Dn,on:It,liveQuery:oh,extendObservabilitySet:sl,getByKeyPath:mt,setByKeyPath:nt,delByKeyPath:function(t,e){typeof e=="string"?nt(t,e,void 0):"length"in e&&[].map.call(e,function(n){nt(t,n,void 0)})},shallowClone:Ni,deepClone:Hn,getObjectDiff:$s,cmp:Le,asap:ji,minKey:$o,addons:[],connections:In,errnames:Bs,dependencies:ts,semVer:ga,version:ga.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Ft.maxKey=Ln(Ft.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(It(zn,t=>{if(!ht){let e;eo?(e=document.createEvent("CustomEvent"),e.initCustomEvent(_t,!0,!0,t)):e=new CustomEvent(_t,{detail:t}),ht=!0,dispatchEvent(e),ht=!1}}),addEventListener(_t,({detail:t})=>{ht||gr(t)}));let ht=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(_t);typeof t.unref=="function"&&t.unref(),It(zn,e=>{ht||t.postMessage(e)}),t.onmessage=e=>{e.data&&gr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){It(zn,e=>{try{ht||(typeof localStorage<"u"&&localStorage.setItem(_t,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:_t,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===_t){const n=JSON.parse(e.newValue);n&&gr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===_t&&gr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof rn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!pa[t.name])return t;var n=new pa[t.name](e||t.message,t);return"stack"in t&&pt(n,"stack",{get:function(){return this.inner.stack}}),n},Ti(lt,Ji);var sh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t))(sh||{}),wr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(wr||{});const ah="comfyui_workspace_db";class ih extends Ut{constructor(){super(ah);Ie(this,"workflows");Ie(this,"changelogs");Ie(this,"media");Ie(this,"folders");Ie(this,"tags");Ie(this,"userSettings");Ie(this,"models");Ie(this,"cache");Ie(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ue=new ih,lh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=lh[n[t]&63];return e};class Zt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ue[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")}),af(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=ns()),e.createTime||(e.createTime=Date.now()),await ue[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ue[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ue[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ue[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ue[this.tableName].toArray()}async batchQuery(e){return await ue[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await sf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await hf()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ue[this.tableName].get(e)}async delete(e){await ue[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await ue[this.tableName].where(e).equals(n).toArray()}}const ch=150,Tr=class Tr extends Zt{constructor(){super("changelogs")}static async load(){return new Tr}async listByWorkflowID(e){return await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:Fn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return this.deleteLogsExceedLimit(e.workflowID),await ue.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e){const n=await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=await(Z==null?void 0:Z.getSetting("maximumChangelogNumber"))??ch;if(n.length>r){const o=n.slice(r);await ue.changelogs.bulkDelete(o.map(s=>s.id)),await this.saveDiskDB()}}};Ie(Tr,"TABLE_NAME","changelogs");let rs=Tr;const zp="CWM_WORKFLOWS_SORT_TYPE";var kt=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(kt||{});const Lp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],uh="comfyspace_tracking",Fr="workspace_info",dh=9999999,go="upgrade_to_2way_sync",al=29;function br(...t){const e=t.filter(n=>n!=="").join("/");return Dt(e)}function Dt(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function wo(t){return br(t.parentFolderID??"",t.name+".json")}var xt;(t=>{async function e({parentFolderID:a,name:l}){return Dt(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(a.id)})})}t.createFolder=n;async function r(a,l){const u=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();u.error&&alert("Failed to move folder: "+u.error)}t.moveFolder=r;async function o(a){try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).text()}catch(l){console.error("Error deleting file:",l)}}t.deleteFolder=o;async function s(a){try{const c=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return c.error&&console.error("Error counting files:",c.error),c.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const u=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();u.error&&alert("Failed to rename folder: "+u.error)}catch(c){console.error("Error renaming file:",c)}}t.renameFolder=i})(xt||(xt={}));async function kn(t){const e=await Vs(t);if(e==null)return;const n=await il(t);await(q==null?void 0:q.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Fr]={id:t.id,name:t.name},delete o.extra[uh],await lf(e,JSON.stringify(o))}async function bo(t){if(t.name==null)return;const e=await Vs(t);e!=null&&Ii(e)}async function Vs(t){let e=hh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function fh(t){let e="",n=t;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function il(t){const e=await Vs(t);let n=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function Wp(t){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await xt.genFilesCountInFolder(t)??0;const n=await(q==null?void 0:q.listAll())??[],r=await(ze==null?void 0:ze.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}function hh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function ll(t,e=!0,n=!1){const r=new Date(t),o=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0"),i=r.getFullYear(),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=String(r.getSeconds()).padStart(2,"0"),u=`${s}-${o}-${i}`;return e?u+` ${a}:${l}`:n?u+`:${c}`:u}async function cl(t=!1){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return;const n=await(q==null?void 0:q.listAll())??[];for(const r of n){const o=await il(r);r.filePath!=o&&(r.filePath!=null&&await Ii(r.filePath,t),await kn(r))}}const ul=(t,e=kt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case kt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case kt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case kt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case kt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n};function ph(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{const e=await(Z==null?void 0:Z.getSetting("shortcuts"))??(Z==null?void 0:Z.defaultSettings.shortcuts);if(!e)return!1;for(const n in e){const o=e[n].split("+"),s={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const i in s)s[i]||delete s[i];if(o.length===Object.keys(s).length&&o.every(i=>s[i]))return n}};function $p(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function mh(t){return`/workspace/view_media?filename=${t}`}function Sa(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function dl(t){const e=window.location.hash.slice(1).split("/"),n=e.findIndex(o=>o.includes("workspaceId@")),r=`workspaceId@${t}`;return n>=0?e[n]=r:e.push(r),`${e.join("/")}`}const yh=t=>{const e=dl(t);window.open(`${window.location.origin}/#${e}`)},_r={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Je;(t=>{async function e(l,c){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),newParentPath:c})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(u){console.error("Error deleting file:",u)}}t.moveWorkflow=e;async function n(l,c){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(c??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(u){console.error("Error deleting file:",u)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:c},u){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(l??"",c+".json"),newName:u})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const c=l.json,u=JSON.parse(c);u.extra[Fr]={id:l.id};const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),json:JSON.stringify(u)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} - - 👉Please try "Save as" from "Files" dropdown menu - `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(l),deleteEmptyFolder:!1})})).text()}catch(c){alert("Error deleting workflow .json file: "+c),console.error("Error deleting file:",c)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:c,json:u,id:d}){var g;let p=JSON.parse(u);p={...p,extra:{[Fr]:{id:d}}};const h={parentFolderPath:Dt(l??""),name:c,json:JSON.stringify(p)};console.log("createWorkflow",h);try{const y=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return y.name&&await((g=ue.workflows)==null?void 0:g.update(d,{name:y.name})),y}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:c,id:u}){const d=br(l??"",c+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:u})})).json();return h.error&&(console.error(`Error getting file <${u}> at "${d}"`,h.error),alert({message:`Error getting file <${u}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${u}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function fl(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function vh(t,e){const n=Dt(t??""),o=(await fl(n)).map(async a=>{var u;const l=a.name,c=[n,l].join("/");return gh(a)?{id:Dt(c),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((u=ue.workflows)==null?void 0:u.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,lastSavedJson:a.json??"{}",json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ue.workflows.bulkPut(s.filter(a=>!Oh(a)));const i=s.filter(a=>a!=null);return ul(i,e??kt.RECENTLY_MODIFIED)}function gh(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Zt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Br}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ue.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){const l=await Je.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,c=!0;for(;c;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ns(),json:n.json??JSON.stringify(_r),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ue.workflows.add(i),this.saveDiskDB(),await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):(kn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ue.workflows.update(n,r);const o=await ue.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Je.moveWorkflow(s,r.parentFolderID):(await kn(i),await bo(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ue.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(Z==null?void 0:Z.getSetting("twoWaySync"))&&o&&await Je.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(Z==null?void 0:Z.getSetting("twoWaySync"))?a&&await Je.saveWorkflow(a):a&&await kn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const c=l.name&&r?l.name:await this.generateUniqueName(l.name,o),u=ns(),d=Date.now(),p={id:u,name:c,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Z==null?void 0:Z.getSetting("twoWaySync")))try{const g=JSON.parse(l.json),f=(a=(i=g==null?void 0:g.extra)==null?void 0:i[Fr])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(g){console.error("batchCreateFlows error",g)}else await kn(p)}try{await ue.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(r):bo({...r})),await ue.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ue.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(o):bo({...o})}await ue.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await vh(n??null);const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],i=await(ze==null?void 0:ze.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],a=[...s,...i];return ul(a,r??kt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await ue.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}};Ie(Br,"TABLE_NAME","workflows");let os=Br;const Mr=class Mr extends Zt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Z==null?void 0:Z.getSetting("twoWaySync")),o=await xt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Fn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await xt.createFolder(s):(await ue.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return"parentFolderID"in n&&await xt.moveFolder(e,n.parentFolderID??""),"name"in n&&await xt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ue.folders.update(e,n),this.saveDiskDB(),(s||i)&&cl(!0),a}async deleteFolder(e,n=wr.DELETE){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){await fl(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await xt.deleteFolder(e);return}const o=await(q==null?void 0:q.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const c of o)if(c.parentFolderID===a)switch(n){case wr.DELETE:await(q==null?void 0:q.deleteFlow(c.id));break;case wr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(c.id,{parentFolderID:void 0}));break}await ue.folders.delete(a);const l=s.filter(c=>c.parentFolderID===a).map(c=>c.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await Je.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Mr,"TABLE_NAME","folders");let ss=Mr;function wh(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=g}a+=12+c}e(l)},r.readAsArrayBuffer(t)})}function bh(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const c=t.slice(i,i+l);if(l===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,a);if(l===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let c=0;c{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-u)&~(1<<7*u),p=i.decode(o.slice(a+2+u,a+2+u+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,c=i.decode(o.slice(a+12,a+12+l)),u=JSON.parse(c);e(u);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Eh(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(kh(t))return xh(o);if(e==="webp")return _h(o);const s=await wh(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}function qp(){return LiteGraph.registered_node_types}class hl extends Zt{constructor(){super("media")}async listByWorkflowID(e){return await ue.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Eh(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:Fn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ue.media.add(o),this.saveDiskDB(),o}}Ie(hl,"TABLE_NAME","media");const Vp=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Ch={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Hp(t){return t.modelVersions!==void 0}function Sh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Zp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Sh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const zr=class zr extends Zt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S"},defaultFolders:Ch,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:200}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new zr,r=await cf();return n.defaultSettings.myWorkflowsDir=r.path,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};Ie(zr,"TABLE_NAME","userSettings");let as=zr;const Lr=class Lr extends Zt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let is=Lr;const Wr=class Wr extends Zt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ue[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Wr,"TABLE_NAME","workflowVersions");let ls=Wr;function Oh(t){return"type"in t&&t.type==="folder"}let q=null,kr=null,Z=null,ze=null,Ve=null,Kt=null,we=null;async function Ih(){const t=async()=>{q=await os.load()},e=async()=>{kr=await is.load()},n=async()=>{Z=await as.load()},r=async()=>{ze=await ss.load()},o=async()=>{Ve=await rs.load()},s=async()=>{Kt=new hl},i=async()=>{we=await ls.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Dh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Dh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ue.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(ze==null?void 0:ze.getRecords());a&&await ue.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Kt==null?void 0:Kt.getRecords());a&&await ue.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ue.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(kr==null?void 0:kr.getRecords());a&&await ue.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Z,l=await a.getRecords().then(c=>c[a.DEFAULT_USER]?c[a.DEFAULT_USER]:c);await ue.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(we==null?void 0:we.getRecords());a&&await ue.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const At=A.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),Gp=A.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),_o={x:0,y:0};function Ph({children:t,onDragEnd:e,dragIconId:n}){const r=A.useRef(_o),o=A.useRef(!1),[s,i]=A.useState(_o),a=d=>{var p,h,g;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(g=(h=d.target)==null?void 0:h.parentNode)==null?void 0:g.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=A.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),c=A.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),_o)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return D.jsx("div",{style:u,onMouseDown:a,children:t})}var jh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ah=Object.defineProperty,Nh=Object.defineProperties,Fh=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,pl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,Oa=(t,e,n)=>e in t?Ah(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ia=(t,e)=>{for(var n in e||(e={}))pl.call(e,n)&&Oa(t,n,e[n]);if(Rr)for(var n of Rr(e))ml.call(e,n)&&Oa(t,n,e[n]);return t},Rh=(t,e)=>Nh(t,Fh(e)),Th=(t,e)=>{var n={};for(var r in t)pl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Rr)for(var r of Rr(t))e.indexOf(r)<0&&ml.call(t,r)&&(n[r]=t[r]);return n},Fe=(t,e,n)=>{const r=A.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:c=2,children:u}=i,d=Th(i,["color","size","stroke","children"]);return A.createElement("svg",Ia(Rh(Ia({ref:s},jh),{width:l,height:l,stroke:a,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>A.createElement(p,h)),...u||[]])});return r.propTypes={color:Nt.string,size:Nt.oneOfType([Nt.string,Nt.number]),stroke:Nt.oneOfType([Nt.string,Nt.number])},r.displayName=`${e}`,r},Bh=Fe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Mh=Fe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),cs=Fe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),zh=Fe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),Lh=Fe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Wh=Fe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Uh=Fe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Kh=Fe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),$h=Fe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),yl=Fe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),qh=Fe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),Vh=Fe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Hh=Fe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),Zh=Fe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),vl=Fe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Gh=Fe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),Jh=Fe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),Yh=Fe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Xh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return D.jsx(mi,{isLazy:!0,placement:"auto",children:({onClose:i})=>D.jsxs(D.Fragment,{children:[D.jsx(pi,{children:D.jsx(Ct,{children:D.jsx(zt,{hasArrow:!0,label:s,placement:"bottom",children:D.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:D.jsx(Zh,{color:"#F56565"}),isDisabled:o,variant:n})})})}),D.jsxs(bi,{children:[D.jsx(yi,{}),D.jsx(gi,{onClick:i}),D.jsxs(vi,{children:[D.jsx(Bt,{mb:4,pr:4,fontWeight:600,children:e}),D.jsx(We,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Qh({onClose:t}){Ta();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=A.useContext(At),[s,i]=A.useState(0),[a,l]=A.useState(null),[c,u]=A.useState([]),[d,p]=A.useState([]),h=async y=>{var x;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));u(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),k=(x=_==null?void 0:_[0])==null?void 0:x.id;k&&l(k)},g=async()=>{const y=await(we==null?void 0:we.listByWorkflowID(e))??[];p(y)},f=y=>{we==null||we.delete(y).then(()=>{g()})};return A.useEffect(()=>{switch(s){case 0:g();break;case 1:h(e);break}},[s]),A.useEffect(()=>(xe.canvasEl.addEventListener("click",t),()=>{xe.canvasEl.removeEventListener("click",t)}),[s]),D.jsxs(nc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[D.jsx(tc,{pb:1,mb:0,children:D.jsxs(xn,{justifyContent:"space-between",alignItems:"center",children:[D.jsx(_s,{size:"md",children:"Version History"}),D.jsx(jn,{size:"sm",icon:D.jsx(Yh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),D.jsx(ec,{overflowY:"auto",gap:0,children:D.jsxs(xi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[D.jsxs(Ei,{mb:"1em",children:[D.jsx(Do,{children:"Versions"}),D.jsx(Do,{children:"Change History"})]}),D.jsxs(Ci,{children:[D.jsx(Io,{children:D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:d==null?void 0:d.map(y=>D.jsxs(xn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[D.jsxs(tn,{textAlign:"left",gap:0,children:[D.jsx(Bt,{fontWeight:"500",children:y.name??"untitled"}),D.jsxs(Bt,{color:"GrayText",fontSize:"sm",children:["Created: ",ll(y.createTime)]})]}),D.jsxs(xn,{alignItems:"center",gap:2,children:[D.jsx(We,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),D.jsx(Xh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),D.jsxs(Io,{children:[D.jsx(Bt,{mb:4,children:"All the saved changes of this workflow"}),D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:c==null?void 0:c.map(y=>D.jsxs(Et,{justifyContent:"space-between",children:[D.jsxs(We,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),q==null||q.updateFlow(e,{json:y.json}),t()},isActive:y.id===a,children:["Saved at ",new Date(y.createTime).toLocaleString()]},y.id),y.isAutoSave?D.jsx(Qr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function ep({workflowId:t,onClose:e}){const[n,r]=A.useState(""),[o,s]=A.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(we==null?void 0:we.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(xe.graph.serialize());await(we==null?void 0:we.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return D.jsxs(fs,{isOpen:!0,onClose:e,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Create Version"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!o,children:[D.jsx(Hr,{children:"Name"}),D.jsx(Kn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&D.jsx(Vr,{children:o})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),D.jsx(We,{onClick:e,children:"Cancel"})]})]})]})}function tp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=A.useRef(null);return Oc({ref:o,handler:()=>r()}),D.jsxs(Ct,{position:"relative",children:[D.jsx(Ct,{children:e}),n&&D.jsx(Ct,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function np({menuButton:t,menuContent:e,onClose:n}){const r=A.useRef(),[o,s]=A.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return D.jsx(tp,{isOpen:o,onClose:i,menuButton:D.jsx(Ct,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:D.jsx(As,{isOpen:!0,children:D.jsx(Ns,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const rp=A.lazy(()=>Un(()=>import("./ShareDialog-o8m3m3T9.js"),__vite__mapDeps([0,1,2,3,4])));function op(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=A.useContext(At),[i,a]=A.useState(!1),[l,c]=A.useState(""),[u,d]=A.useState(""),[p,h]=A.useState(),[g,f]=A.useState({save:"",saveAs:""}),[y,m]=A.useState(!1);A.useEffect(()=>{t&&(q==null||q.get(t).then(O=>{c((O==null?void 0:O.name)??""),h(O)})),Z==null||Z.getSetting("shortcuts").then(O=>{f(O)})},[t]);const w=O=>{c(O.target.value),u&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const O=JSON.stringify(xe.graph.serialize()),E=await(q==null?void 0:q.createFlow({json:O,lastSavedJson:O,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));E&&await e(E.id,null,!0),k()},k=()=>{o("root")},x=A.useCallback(async()=>{const O=q==null?void 0:q.curWorkflow;if(!O){alert("No current workflow!");return}const E=xe.graph.serialize(),N=JSON.stringify(E),P=new Blob([N],{type:"application/json"}),R=URL.createObjectURL(P),$=document.createElement("a");$.href=R,$.download=`${O.name}.json`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(R)},[t]);return A.useCallback(async()=>{console.log("app.graph",xe.graph);const O=xe.graph.serialize();console.log("graph serialize",O)},[]),D.jsxs(D.Fragment,{children:[D.jsx(np,{menuButton:D.jsx(Na,{children:D.jsxs(We,{px:1,height:al+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",D.jsx(Mh,{size:20})]})}),menuContent:D.jsx(As,{isOpen:!0,children:D.jsxs(Ns,{minWidth:150,zIndex:1e3,children:[D.jsx(gt,{onClick:r,icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.save,children:"Save"}),!(Z!=null&&Z.autoSave)&&D.jsx(zt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:D.jsx(gt,{onClick:n,icon:D.jsx(Bh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),D.jsx(gt,{onClick:x,icon:D.jsx(zh,{size:20}),iconSpacing:1,children:"Download"}),D.jsx(gt,{onClick:()=>o("saveAsModal"),icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.saveAs,children:"Save As"}),D.jsx(gt,{onClick:()=>a(!0),icon:D.jsx(Gh,{size:20}),iconSpacing:1,children:"Create Version"}),D.jsx(gt,{onClick:()=>o("versionHistory"),icon:D.jsx(Kh,{size:20}),iconSpacing:1,children:"Versions History"}),D.jsx(gt,{onClick:()=>m(!0),icon:D.jsx(Hh,{size:20}),iconSpacing:1,alignItems:"center",children:D.jsxs(Et,{children:[D.jsx("p",{children:"Share"})," ",D.jsx(Qr,{size:"sm",children:"🧪🧪beta"})]})})]})})}),y&&D.jsx(rp,{onClose:()=>m(!1)}),s=="versionHistory"&&D.jsx(Qh,{onClose:()=>o("root")}),s==="saveAsModal"&&D.jsxs(fs,{isOpen:!0,onClose:k,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Save As"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!u,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:l,onChange:w,autoFocus:!0,onKeyUp:O=>{O.code==="Enter"&&!u&&l&&_()}}),u&&D.jsx(Vr,{children:u})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!u,children:"Save"}),D.jsx(We,{onClick:k,children:"Cancel"})]})]})]}),i&&D.jsx(ep,{workflowId:t,onClose:()=>a(!1)})]})}function sp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Pc(),{curFlowID:i}=A.useContext(At),[a,l]=A.useState(t),[c,u]=A.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),c&&u("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return g();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?u("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),g())}},g=()=>{u(""),s()};return i==null?null:D.jsxs(Et,{children:[D.jsx(zt,{label:t,placement:"bottom",children:D.jsxs(Bt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[D.jsx("div",{style:{width:8,display:"inline-block"},children:D.jsx(Bt,{as:"span",children:n&&"* "})}),t]})}),D.jsxs(fs,{isOpen:r,onClose:g,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Edit workflow name"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!c,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!c&&a&&h()}}),c&&D.jsx(Vr,{children:c})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!c,children:"Save"}),D.jsx(We,{onClick:g,children:"Cancel"})]})]})]})]})}function Jp(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Yp=[{label:"Private",value:"PRIVATE",icon:D.jsx(yl,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:D.jsx($h,{})},{label:"Public",value:"PUBLIC",icon:D.jsx(Jh,{})}],Xp=()=>{const t=xe.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function ap(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Qp({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),D.jsx("span",{children:n})}function ip({}){const[t,e]=A.useState(),[n,r]=A.useState(),{curFlowID:o}=A.useContext(At);return A.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),ap(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?D.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:D.jsx(Na,{children:D.jsx(Qr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function lp({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=A.useContext(At);return A.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?D.jsx(xn,{alignItems:"center",children:D.jsx(La,{size:"sm",isAttached:!0,variant:"outline",children:D.jsx(We,{rightIcon:D.jsx(vl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const cp=A.lazy(()=>Un(()=>import("./ModelManagerTopbar--uE4bw7I.js").then(t=>t.M),__vite__mapDeps([5,1,6,2,7,8])));function up({curFlowName:t,setCurFlowName:e}){var u;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i}=A.useContext(At),[a,l]=A.useState(),c=A.useCallback((d,p=!1)=>{const{top:h=0,left:g=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=g;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),k=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+k>=m&&(y=m-k),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Z==null||Z.upsert({topBarStyle:{top:f,left:y}}))},[a]);return A.useEffect(()=>{Z==null||Z.getSetting("topBarStyle").then(d=>{c(d,!1)})},[]),a?D.jsx(Ph,{onDragEnd:d=>{c({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:D.jsxs(Et,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[D.jsx(We,{size:"sm","aria-label":"workspace folder",onClick:()=>s("recentFlows"),px:2,children:D.jsxs(Et,{gap:1,children:[D.jsx(Wh,{size:21}),D.jsx(vl,{size:8})]})}),D.jsx(cp,{}),D.jsx(zt,{label:"New workflow",children:D.jsx(We,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:al+"px",onClick:()=>r(),px:2,py:2,children:D.jsx(Et,{gap:0,children:D.jsx(Vh,{size:16,color:"white"})})})}),D.jsx(sp,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{c()})}}),((u=q==null?void 0:q.curWorkflow)==null?void 0:u.saveLock)&&D.jsx(yl,{color:"#FFF",size:20}),i&&D.jsxs(Et,{gap:"4px",children:[D.jsx(zt,{label:"Open gallery",children:D.jsx(jn,{onClick:()=>s("gallery"),icon:D.jsx(qh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),D.jsx(op,{})]}),i&&n?D.jsx(zt,{label:"Save workflow",children:D.jsx(jn,{onClick:o,icon:D.jsx(cs,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):D.jsx("div",{style:{width:1}}),D.jsx(ip,{}),D.jsx(lp,{}),D.jsx(Uh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})}):null}function dp(){const{showDialog:t}=Fa(),{loadWorkflowID:e}=A.useContext(At),n=async(o,s)=>{var c,u;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(c=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:c.at(0);if(l){const d=(u=await(we==null?void 0:we.listByIndex("cloudID",a.id)))==null?void 0:u.at(0);if(d)await e(l.id,d.id);else{const p=await(we==null?void 0:we.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await(q==null?void 0:q.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(we==null?void 0:we.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return A.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function fp(t){return t.type==="workspace_open_workflow"}const hp=t=>typeof t=="function",pp=t=>{const[e,n]=A.useState(t),r=A.useRef(e),o=A.useCallback(s=>{r.current=hp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function cr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var gl={exports:{}};/*! - -JSZip v3.10.1 - A JavaScript class for generating and reading zip files - - -(c) 2009-2016 Stuart Knightley -Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. - -JSZip uses the library pako released under the MIT license : -https://github.com/nodeca/pako/blob/main/LICENSE -*/(function(t,e){(function(n){t.exports=n()})(function(){return function n(r,o,s){function i(c,u){if(!o[c]){if(!r[c]){var d=typeof cr=="function"&&cr;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[c]={exports:{}};r[c][0].call(h.exports,function(g){var f=r[c][1][g];return i(f||g)},h,h.exports,n,r,o,s)}return o[c].exports}for(var a=typeof cr=="function"&&cr,l=0;l>2,h=(3&c)<<4|u>>4,g=1<_?(15&u)<<2|d>>6:64,f=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(h)+a.charAt(g)+a.charAt(f));return y.join("")},o.decode=function(l){var c,u,d,p,h,g,f=0,y=0,m="data:";if(l.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var w,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,u=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(g=a.indexOf(l.charAt(f++))),w[y++]=c,h!==64&&(w[y++]=u),g!==64&&(w[y++]=d);return w}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,p,h,g){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=g}c.prototype={getContentWorker:function(){var u=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,p){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u[f])];return-1^c}(0|l,a,a.length,0):function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u.charCodeAt(f))];return-1^c}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function u(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new u("Deflate",d)},o.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,g){var f,y="";for(f=0;f>>=8;return y}function i(h,g,f,y,m,w){var _,k,x=h.file,O=h.compression,E=w!==c.utf8encode,N=a.transformTo("string",w(x.name)),P=a.transformTo("string",c.utf8encode(x.name)),R=x.comment,$=a.transformTo("string",w(R)),j=a.transformTo("string",c.utf8encode(R)),B=P.length!==x.name.length,b=j.length!==R.length,K="",te="",S="",G=x.dir,z=x.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};g&&!f||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var M=0;g&&(M|=8),E||!B&&!b||(M|=2048);var T=0,ne=0;G&&(T|=16),m==="UNIX"?(ne=798,T|=function(H,fe){var ye=H;return H||(ye=fe?16893:33204),(65535&ye)<<16}(x.unixPermissions,G)):(ne=20,T|=function(H){return 63&(H||0)}(x.dosPermissions)),_=z.getUTCHours(),_<<=6,_|=z.getUTCMinutes(),_<<=5,_|=z.getUTCSeconds()/2,k=z.getUTCFullYear()-1980,k<<=4,k|=z.getUTCMonth()+1,k<<=5,k|=z.getUTCDate(),B&&(te=s(1,1)+s(u(N),4)+P,K+="up"+s(te.length,2)+te),b&&(S=s(1,1)+s(u($),4)+j,K+="uc"+s(S.length,2)+S);var Y="";return Y+=` -\0`,Y+=s(M,2),Y+=O.magic,Y+=s(_,2),Y+=s(k,2),Y+=s(Q.crc32,4),Y+=s(Q.compressedSize,4),Y+=s(Q.uncompressedSize,4),Y+=s(N.length,2),Y+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s($.length,2)+"\0\0\0\0"+s(T,4)+s(y,4)+N+K+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function p(h,g,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=y,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var g=h.meta.percent||0,f=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var g=this.streamFiles&&!h.file.dir;if(g){var f=i(h,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var g=this.streamFiles&&!h.file.dir,f=i(h,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new c(d):i.uint8array?new u(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,f){return new u.Promise(function(y,m){var w=[],_=g._internalType,k=g._outputType,x=g._mimeType;g.on("data",function(O,E){w.push(O),f&&f(E)}).on("error",function(O){w=[],m(O)}).on("end",function(){try{var O=function(E,N,P){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),P);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(k,function(E,N){var P,R=0,$=null,j=0;for(P=0;P"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(g){var f,y,m,w,_,k=g.length,x=0;for(w=0;w>>6:(y<65536?f[_++]=224|y>>>12:(f[_++]=240|y>>>18,f[_++]=128|y>>>12&63),f[_++]=128|y>>>6&63),f[_++]=128|63&y);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(g){var f,y,m,w,_=g.length,k=new Array(2*_);for(f=y=0;f<_;)if((m=g[f++])<128)k[y++]=m;else if(4<(w=c[m]))k[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,k[y++]=56320|1023&m)}return k.length!==y&&(k.subarray?k=k.subarray(0,y):k.length=y),s.applyFromCharCode(k)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var g=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var y=function(w,_){var k;for((_=_||w.length)>w.length&&(_=w.length),k=_-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?_:k+c[w[k]]>_?k:_}(g),m=g;y!==g.length&&(i.uint8array?(m=g.subarray(0,y),this.leftOver=g.subarray(y,g.length)):(m=g.slice(0,y),this.leftOver=g.slice(y,g.length))),this.push({data:o.utf8decode(m),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(f){return f}function u(f,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var g,f,y,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[y++]=224|h>>>12:(p[y++]=240|h>>>18,p[y++]=128|h>>>12&63),p[y++]=128|h>>>6&63),p[y++]=128|63&h);return p},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,g=p.length;h>10&1023,w[g++]=56320|1023&f)}return u(w,g)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var c=65535&s|0,u=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,c){var u=s,d=c+l;i^=-1;for(var p=c;p>>8^u[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,p=4,h=0,g=-2,f=-1,y=4,m=2,w=8,_=9,k=286,x=30,O=19,E=2*k+1,N=15,P=3,R=258,$=R+P+1,j=42,B=113,b=1,K=2,te=3,S=4;function G(v,U){return v.msg=u[U],U}function z(v){return(v<<1)-(4v.avail_out&&(W=v.avail_out),W!==0&&(i.arraySet(v.output,U.pending_buf,U.pending_out,W,v.next_out),v.next_out+=W,U.pending_out+=W,v.total_out+=W,v.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function T(v,U){a._tr_flush_block(v,0<=v.block_start?v.block_start:-1,v.strstart-v.block_start,U),v.block_start=v.strstart,M(v.strm)}function ne(v,U){v.pending_buf[v.pending++]=U}function Y(v,U){v.pending_buf[v.pending++]=U>>>8&255,v.pending_buf[v.pending++]=255&U}function H(v,U){var W,I,C=v.max_chain_length,F=v.strstart,V=v.prev_length,J=v.nice_match,L=v.strstart>v.w_size-$?v.strstart-(v.w_size-$):0,X=v.window,re=v.w_mask,ee=v.prev,ae=v.strstart+R,ge=X[F+V-1],pe=X[F+V];v.prev_length>=v.good_match&&(C>>=2),J>v.lookahead&&(J=v.lookahead);do if(X[(W=U)+V]===pe&&X[W+V-1]===ge&&X[W]===X[F]&&X[++W]===X[F+1]){F+=2,W++;do;while(X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&FL&&--C!=0);return V<=v.lookahead?V:v.lookahead}function fe(v){var U,W,I,C,F,V,J,L,X,re,ee=v.w_size;do{if(C=v.window_size-v.lookahead-v.strstart,v.strstart>=ee+(ee-$)){for(i.arraySet(v.window,v.window,ee,ee,0),v.match_start-=ee,v.strstart-=ee,v.block_start-=ee,U=W=v.hash_size;I=v.head[--U],v.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=v.prev[--U],v.prev[U]=ee<=I?I-ee:0,--W;);C+=ee}if(v.strm.avail_in===0)break;if(V=v.strm,J=v.window,L=v.strstart+v.lookahead,X=C,re=void 0,re=V.avail_in,X=P)for(F=v.strstart-v.insert,v.ins_h=v.window[F],v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P)if(I=a._tr_tally(v,v.strstart-v.match_start,v.match_length-P),v.lookahead-=v.match_length,v.match_length<=v.max_lazy_match&&v.lookahead>=P){for(v.match_length--;v.strstart++,v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P&&v.match_length<=v.prev_length){for(C=v.strstart+v.lookahead-P,I=a._tr_tally(v,v.strstart-1-v.prev_match,v.prev_length-P),v.lookahead-=v.prev_length-1,v.prev_length-=2;++v.strstart<=C&&(v.ins_h=(v.ins_h<v.pending_buf_size-5&&(W=v.pending_buf_size-5);;){if(v.lookahead<=1){if(fe(v),v.lookahead===0&&U===d)return b;if(v.lookahead===0)break}v.strstart+=v.lookahead,v.lookahead=0;var I=v.block_start+W;if((v.strstart===0||v.strstart>=I)&&(v.lookahead=v.strstart-I,v.strstart=I,T(v,!1),v.strm.avail_out===0)||v.strstart-v.block_start>=v.w_size-$&&(T(v,!1),v.strm.avail_out===0))return b}return v.insert=0,U===p?(T(v,!0),v.strm.avail_out===0?te:S):(v.strstart>v.block_start&&(T(v,!1),v.strm.avail_out),b)}),new le(4,4,8,4,ye),new le(4,5,16,8,ye),new le(4,6,32,32,ye),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],o.deflateInit=function(v,U){return Ee(v,U,w,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(v,U){return v&&v.state?v.state.wrap!==2?g:(v.state.gzhead=U,h):g},o.deflate=function(v,U){var W,I,C,F;if(!v||!v.state||5>8&255),ne(I,I.gzhead.time>>16&255),ne(I,I.gzhead.time>>24&255),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ne(I,255&I.gzhead.extra.length),ne(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(v.adler=c(v.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,3),I.status=B);else{var V=w+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=B,Y(I,V),I.strstart!==0&&(Y(I,v.adler>>>16),Y(I,65535&v.adler)),v.adler=1}if(I.status===69)if(I.gzhead.extra){for(C=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending!==I.pending_buf_size));)ne(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&M(v),I.pending+2<=I.pending_buf_size&&(ne(I,255&v.adler),ne(I,v.adler>>8&255),v.adler=0,I.status=B)):I.status=B),I.pending!==0){if(M(v),v.avail_out===0)return I.last_flush=-1,h}else if(v.avail_in===0&&z(U)<=z(W)&&U!==p)return G(v,-5);if(I.status===666&&v.avail_in!==0)return G(v,-5);if(v.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var J=I.strategy===2?function(L,X){for(var re;;){if(L.lookahead===0&&(fe(L),L.lookahead===0)){if(X===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(L,X){for(var re,ee,ae,ge,pe=L.window;;){if(L.lookahead<=R){if(fe(L),L.lookahead<=R&&X===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=P&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=P?(re=a._tr_tally(L,1,L.match_length-P),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(J!==te&&J!==S||(I.status=666),J===b||J===te)return v.avail_out===0&&(I.last_flush=-1),h;if(J===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(Q(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),M(v),v.avail_out===0))return I.last_flush=-1,h}return U!==p?h:I.wrap<=0?1:(I.wrap===2?(ne(I,255&v.adler),ne(I,v.adler>>8&255),ne(I,v.adler>>16&255),ne(I,v.adler>>24&255),ne(I,255&v.total_in),ne(I,v.total_in>>8&255),ne(I,v.total_in>>16&255),ne(I,v.total_in>>24&255)):(Y(I,v.adler>>>16),Y(I,65535&v.adler)),M(v),0=W.w_size&&(F===0&&(Q(W.head),W.strstart=0,W.block_start=0,W.insert=0),X=new i.Buf8(W.w_size),i.arraySet(X,U,re-W.w_size,W.w_size,0),U=X,re=W.w_size),V=v.avail_in,J=v.next_in,L=v.input,v.avail_in=re,v.next_in=0,v.input=U,fe(W);W.lookahead>=P;){for(I=W.strstart,C=W.lookahead-(P-1);W.ins_h=(W.ins_h<>>=P=N>>>24,_-=P,(P=N>>>16&255)===0)K[u++]=65535&N;else{if(!(16&P)){if(!(64&P)){N=k[(65535&N)+(w&(1<>>=P,_-=P),_<15&&(w+=b[l++]<<_,_+=8,w+=b[l++]<<_,_+=8),N=x[w&E];n:for(;;){if(w>>>=P=N>>>24,_-=P,!(16&(P=N>>>16&255))){if(!(64&P)){N=x[(65535&N)+(w&(1<>>=P,_-=P,(P=u-d)<$){if(f<(P=$-P)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(j=0)===y){if(j+=g-P,P>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var B;return j&&j.state?(B=j.state,j.total_in=j.total_out=B.total=0,j.msg="",B.wrap&&(j.adler=1&B.wrap),B.mode=g,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(f),B.distcode=B.distdyn=new s.Buf32(y),B.sane=1,B.back=-1,p):h}function k(j){var B;return j&&j.state?((B=j.state).wsize=0,B.whave=0,B.wnext=0,_(j)):h}function x(j,B){var b,K;return j&&j.state?(K=j.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=S.wsize?(s.arraySet(S.window,B,b-S.wsize,S.wsize,0),S.wnext=0,S.whave=S.wsize):(K<(te=S.wsize-S.wnext)&&(te=K),s.arraySet(S.window,B,b-K,te,S.wnext),(K-=te)?(s.arraySet(S.window,B,b-K,K,0),S.wnext=K,S.whave=S.wsize):(S.wnext+=te,S.wnext===S.wsize&&(S.wnext=0),S.whave>>8&255,b.check=a(b.check,F,2,0),T=M=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&M)<<8)+(M>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&M)!=8){j.msg="unknown compression method",b.mode=30;break}if(T-=4,v=8+(15&(M>>>=4)),b.wbits===0)b.wbits=v;else if(v>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=3;case 3:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>8&255,F[2]=M>>>16&255,F[3]=M>>>24&255,b.check=a(b.check,F,4,0)),T=M=0,b.mode=4;case 4:for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>8),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=5;case 5:if(1024&b.flags){for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>>8&255,b.check=a(b.check,F,2,0)),T=M=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(z<(H=b.length)&&(H=z),H&&(b.head&&(v=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,S,H,v)),512&b.flags&&(b.check=a(b.check,K,H,S)),z-=H,S+=H,b.length-=H),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(z===0)break e;for(H=0;v=K[S+H++],b.head&&v&&b.length<65536&&(b.head.name+=String.fromCharCode(v)),v&&H>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>=7&T,T-=7&T,b.mode=27;break}for(;T<3;){if(z===0)break e;z--,M+=K[S++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,B!==6)break;M>>>=2,T-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}M>>>=2,T-=2;break;case 14:for(M>>>=7&T,T-=7&T;T<32;){if(z===0)break e;z--,M+=K[S++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&M,T=M=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(H=b.length){if(z>>=5,T-=5,b.ndist=1+(31&M),M>>>=5,T-=5,b.ncode=4+(15&M),M>>>=4,T-=4,286>>=3,T-=3}for(;b.have<19;)b.lens[V[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=se,T-=se,b.lens[b.have++]=ke;else{if(ke===16){for(I=se+2;T>>=se,T-=se,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}v=b.lens[b.have-1],H=3+(3&M),M>>>=2,T-=2}else if(ke===17){for(I=se+3;T>>=se)),M>>>=3,T-=3}else{for(I=se+7;T>>=se)),M>>>=7,T-=7}if(b.have+H>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;H--;)b.lens[b.have++]=v}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=c(u,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=c(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,B===6)break e;case 20:b.mode=21;case 21:if(6<=z&&258<=Q){j.next_out=G,j.avail_out=Q,j.next_in=S,j.avail_in=z,b.hold=M,b.bits=T,l(j,Y),G=j.next_out,te=j.output,Q=j.avail_out,S=j.next_in,K=j.input,z=j.avail_in,M=b.hold,T=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;le=(C=b.lencode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,b.length=ke,le===0){b.mode=26;break}if(32&le){b.back=-1,b.mode=12;break}if(64&le){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&le,b.mode=22;case 22:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;le=(C=b.distcode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,64&le){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&le,b.mode=24;case 24:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(Q===0)break e;if(H=Y-Q,b.offset>H){if((H=b.offset-H)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}fe=H>b.wnext?(H-=b.wnext,b.wsize-H):b.wnext-H,H>b.length&&(H=b.length),ye=b.window}else ye=te,fe=G-b.offset,H=b.length;for(QE?(P=fe[ye+y[B]],T[ne+y[B]]):(P=96,0),w=1<>G)+(_-=w)]=N<<24|P<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(M&=w-1,M+=w):M=0,B++,--Y[j]==0){if(j===K)break;j=d[p+y[B]]}if(te>>7)]}function ne(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function Y(C,F,V){C.bi_valid>m-V?(C.bi_buf|=F<>m-C.bi_valid,C.bi_valid+=V-m):(C.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ye(C,F,V){var J,L,X=new Array(y+1),re=0;for(J=1;J<=y;J++)X[J]=re=re+V[J-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=fe(X[ee]++,ee))}}function se(C){var F;for(F=0;F>1;1<=V;V--)ve(C,X,V);for(L=ae;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ve(C,X,1),J=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=J,X[2*L]=X[2*V]+X[2*J],C.depth[L]=(C.depth[V]>=C.depth[J]?C.depth[V]:C.depth[J])+1,X[2*V+1]=X[2*J+1]=L,C.heap[1]=L++,ve(C,X,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(pe,Ge){var mn,rt,yn,Pe,Jn,no,ct=Ge.dyn_tree,Hs=Ge.max_code,wl=Ge.stat_desc.static_tree,bl=Ge.stat_desc.has_stree,_l=Ge.stat_desc.extra_bits,Zs=Ge.stat_desc.extra_base,vn=Ge.stat_desc.max_length,Yn=0;for(Pe=0;Pe<=y;Pe++)pe.bl_count[Pe]=0;for(ct[2*pe.heap[pe.heap_max]+1]=0,mn=pe.heap_max+1;mn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*ae]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(ae=32;ae>>3,(X=C.static_len+3+7>>>3)<=L&&(L=X)):L=X=V+5,V+4<=L&&F!==-1?I(C,F,V,J):C.strategy===4||X===L?(Y(C,2+(J?1:0),3),me(C,$,j)):(Y(C,4+(J?1:0),3),function(ee,ae,ge,pe){var Ge;for(Y(ee,ae-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Ge=0;Ge>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&F,C.pending_buf[C.l_buf+C.last_lit]=255&V,C.last_lit++,F===0?C.dyn_ltree[2*V]++:(C.matches++,F--,C.dyn_ltree[2*(b[V]+d+1)]++,C.dyn_dtree[2*T(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){Y(C,2,3),H(C,_,$),function(F){F.bi_valid===16?(ne(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)}(C)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},g=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:function(){if(i.postMessage&&!i.importScripts){var k=!0,x=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=x,k}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(k){i.postMessage(d+k,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){u.port2.postMessage(k)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(k){var x=f.createElement("script");x.onreadystatechange=function(){w(k),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(k){setTimeout(w,0,k)},y.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gl);var mp=gl.exports;const yp=Da(mp),vp=async t=>{const e=`ComfyUI workspace workflows ${ll(Date.now())}`,n=new yp,r=await(Z==null?void 0:Z.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await fh(o.parentFolderID??null).then(async a=>Dt(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function gp({myWorkflowsDir:t}){return D.jsxs(tn,{gap:3,children:[D.jsx(_s,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),D.jsx("p",{children:"Your workflows will be synced to and from path:"}),D.jsx("p",{children:D.jsx("b",{children:t})}),D.jsxs("p",{children:["You can manually put workflow files into this folder using File Explorer to sync them with your workspace. You can change this path anytime in Settings ",">"," Workspace Save Directory"]}),D.jsxs("p",{children:[D.jsx("b",{children:"Please download all your workflows before enabling two way sync as a backup!"})," ","So you can manually import some workflows into your workspace in case something unexpected happens."]}),D.jsx(We,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());vp(e??[])},children:"👉 Download All My Workflows"})]})}const wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},bp=ws.lazy(()=>Un(()=>import("./RecentFilesDrawer-4bh_pwSS.js"),__vite__mapDeps([9,1,6,2,10,11,4]))),_p=ws.lazy(()=>Un(()=>import("./GalleryModal-mtYV1YJE.js"),__vite__mapDeps([12,1,11,6,2,7,3]))),kp=ws.lazy(()=>Un(()=>import("./AppIsDirtyEventListener-4vtCCyCS.js"),__vite__mapDeps([13,1]))),xp=["download_progress","download_error","model_list"];function Ep(){const[t,e]=A.useState(null),[n,r]=A.useState("root"),[o,s]=A.useState(!0),[i,a]=A.useState(null),l=A.useRef(null),[c,u]=A.useState(!1),d=A.useRef(null),{showDialog:p}=Fa(),[h,g]=A.useState(!1);A.useRef(!1);const f=Ta(),[y,m]=pp(null),w=A.useCallback(async()=>{var S;if(l.current){if((S=q==null?void 0:q.curWorkflow)!=null&&S.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const G=JSON.stringify(xe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(l.current,{json:G}),Ve==null?void 0:Ve.create({workflowID:l.current,json:G,isAutoSave:!1})]),Z!=null&&Z.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(q==null?void 0:q.delete(l.current)),x(null))},k=async()=>{var G,z;if(Z!=null&&Z.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const Q=(G=q==null?void 0:q.curWorkflow)==null?void 0:G.id;if(Q==null)return;const M=(z=await(q==null?void 0:q.get(Q)))==null?void 0:z.json;M?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:M}),await xe.loadGraphData(JSON.parse(M)),u(!1)):alert("Error: No last saved version found")}},x=S=>{const G=(S==null?void 0:S.id)??null;if(q==null||q.updateCurWorkflow(S),l.current=G,a(G),e((S==null?void 0:S.name)??""),G==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Sa()){const z=dl(G);window.location.hash=z,document.title=S.name+" - ComfyUI"}else localStorage.setItem("curFlowID",G),document.title="ComfyUI - "+S.name},O=async()=>{E(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Ih()}catch(z){console.error("error loading db",z)}s(!1);let S=null;S=Sa(),S==null&&(S=localStorage.getItem("curFlowID")),S&&P(S),await cl(),!await(Z==null?void 0:Z.getSetting("twoWaySync"))&&ue.cache.get(go).then(async z=>{if((z==null?void 0:z.value)!=="true"){if(await ue.workflows.count()==0){await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await ue.cache.put({id:go,value:"true"});return}const M=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));p(D.jsx(gp,{myWorkflowsDir:M??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await(Z==null?void 0:Z.getSetting("twoWaySync"))&&(ue.cache.put({id:go,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},E=()=>{xp.forEach(S=>{Gs.addEventListener(S,()=>null)})},N=()=>{if(l.current==null)return!1;const S=q==null?void 0:q.curWorkflow;if(S==null)return!1;if(S.json==null)return!0;const G=xe.graph.serialize()??{};let z={};try{z=S!=null&&S.json?JSON.parse(S==null?void 0:S.json):{}}catch(M){console.error("error parsing json",M)}return!wp(G,z)},P=async(S,G)=>{if(xe.graph==null)return;const z=await(q==null?void 0:q.get(S));if(z==null){alert("Error: Workflow not found! id: "+S),x(null);return}const Q=G?await(we==null?void 0:we.get(G)):null;xe.ui.dialog.close(),Q?(m(Q),x({...z,json:Q.json}),xe.loadGraphData(JSON.parse(Q.json))):(x(z),m(null),xe.loadGraphData(JSON.parse(z.json))),r("root"),c&&u(!1)},R=async(S,G,z=!1)=>{if(S===null){x(null),xe.graph.clear();return}if(!c||z||await(Z==null?void 0:Z.getSetting("autoSave"))){P(S,G);return}$(S)},$=async S=>{var z,Q;const G=[S?{label:"Open in new tab",icon:D.jsx(Lh,{}),onClick:()=>{yh(S)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),S&&P(S)}}];((z=q==null?void 0:q.curWorkflow)==null?void 0:z.lastSavedJson)!=null?G.push({label:"Discard",colorScheme:"red",onClick:async()=>{S&&P(S)}}):G.push({label:"Delete",colorScheme:"red",onClick:async()=>{await _(),S&&P(S)}}),p(`Please save or discard your changes to "${(Q=q==null?void 0:q.curWorkflow)==null?void 0:Q.name}" before leaving, or your changes will be lost.`,G)},j=async S=>{const G=(S==null?void 0:S.json)??JSON.stringify(_r),z=await(q==null?void 0:q.createFlow({json:G,name:S==null?void 0:S.name}));z&&await R(z.id),r("root")},B=async(S,G=!1)=>{const z=S.split("/").pop()??S;G?w():j({name:z});const Q=await fetch(mh(S)),M=await Q.blob(),T=new File([M],z,{type:Q.headers.get("Content-Type")||""});await xe.handleFile(T),r("root")},b=async(S,G)=>{const z=await(q==null?void 0:q.get(S));if(z==null)return;const Q=await(q==null?void 0:q.createFlow({json:z.json,lastSavedJson:z.lastSavedJson,name:G||z.name,parentFolderID:z.parentFolderID,tags:z.tags}));Q&&await R(Q.id)},K=A.useCallback(S=>{if(l.current==null)return;let G=S.filename;S.subfolder!=null&&S.subfolder!==""&&(G=S.subfolder+"/"+G),Kt==null||Kt.create({workflowID:l.current,localPath:G})},[]),te=A.useCallback(()=>{r("root")},[]);return A.useEffect(()=>{O(),g(!0);const S=document.getElementById("comfy-file-input"),G=async()=>{if(S&&S.files&&S.files.length>0){const T={id:Fn(),name:S.files[0].name,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(T),await(q==null?void 0:q.createFlow(T))}};S==null||S.addEventListener("change",G);const z=T=>{var H;const ne=(Z==null?void 0:Z.autoSave)??!0;if((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)return;const Y=N();!ne&&Y&&(T.preventDefault(),T.returnValue="You have unsaved changes!",$())};window.addEventListener("beforeunload",z);const Q=T=>{var ne,Y,H,fe,ye,se;(H=(Y=(ne=T.detail)==null?void 0:ne.output)==null?void 0:Y.images)==null||H.forEach(le=>{le.type==="output"&&K(le)}),(se=(ye=(fe=T.detail)==null?void 0:fe.output)==null?void 0:ye.gifs)==null||se.forEach(le=>{le.type==="output"&&K(le)})};Gs.addEventListener("executed",Q);const M=async T=>{var fe,ye;const ne=(ye=(fe=T.dataTransfer)==null?void 0:fe.files[0])==null?void 0:ye.name,Y=xe.dragOverNode;if(Y&&Y.onDragDrop)return;if(!(await(Z==null?void 0:Z.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ne){const se={id:Fn(),name:ne,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(se),await(q==null?void 0:q.createFlow(se))}};return xe.canvasEl.addEventListener("drop",M),()=>{window.removeEventListener("change",G),window.removeEventListener("beforeunload",z),window.removeEventListener("executed",Q),xe.canvasEl.removeEventListener("drop",M)}},[]),o?null:D.jsx(At.Provider,{value:{curFlowID:i,onDuplicateWorkflow:b,loadWorkflowID:R,discardUnsavedChanges:k,saveCurWorkflow:w,isDirty:c,setIsDirty:u,loadNewWorkflow:j,loadFilePath:B,setRoute:r,route:n,curVersion:y,setCurVersion:m},children:D.jsx("div",{ref:d,className:"workspace_manager",children:D.jsxs(Aa,{containerRef:d,children:[D.jsxs(Ct,{style:{position:"absolute",top:0,right:0,left:0},zIndex:dh,draggable:!1,children:[D.jsx(up,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&D.jsx(A.Suspense,{children:D.jsx(bp,{onClose:te,onClickNewFlow:()=>{j(),r("root")}})}),n==="gallery"&&D.jsx(A.Suspense,{children:D.jsx(_p,{onclose:()=>r("root")})})]}),D.jsx(dp,{}),D.jsx(kp,{})]})})})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"}));export{uc as $,q as A,Ct as B,Yh as C,Xh as D,sh as E,xn as F,vp as G,Et as H,jn as I,Mh as J,Lp as K,Wh as L,hi as M,wh as N,ze as O,qr as P,Hr as Q,Gp as R,kd as S,Qr as T,Vr as U,Vh as V,_r as W,Wp as X,wr as Y,Oh as Z,zp as _,Dp as a,mi as a0,pi as a1,bi as a2,yi as a3,gi as a4,vi as a5,At as a6,yl as a7,Kt as a8,ll as a9,Pc as aA,pp as aB,Ch as aC,Vp as aD,Rp as aE,dn as aF,Yp as aG,we as aH,Jp as aI,Xp as aJ,ap as aK,Qp as aL,tc as aM,em as aN,yh as aa,Lh as ab,kt as ac,nc as ad,dh as ae,Fp as af,ul as ag,Up as ah,Ma as ai,za as aj,$p as ak,qp as al,Eh as am,_s as an,Ac as ao,en as ap,dc as aq,wp as ar,Kp as as,Ve as at,Kl as au,ue as av,Hp as aw,Zp as ax,Tp as ay,Bp as az,jc as b,Ap as c,Pp as d,jp as e,fn as f,Jr as g,Fe as h,Zh as i,Ta as j,tn as k,Bt as l,zt as m,Kn as n,Z as o,gp as p,cf as q,Np as r,Mp as s,kr as t,Gr as u,Eo as v,As as w,Ns as x,gt as y,zh as z}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-o8m3m3T9.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-DRLDc1uk.js","workspace_web/IconCopy-Vm3ws_0T.js","workspace_web/ModelManagerTopbar--uE4bw7I.js","workspace_web/chunk-JARCRF6W-fNDfXRta.js","workspace_web/chunk-3RSXBRAN-ajfTuIGC.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/RecentFilesDrawer-4bh_pwSS.js","workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js","workspace_web/MediaPreview-cVvL6fHO.js","workspace_web/GalleryModal-mtYV1YJE.js","workspace_web/AppIsDirtyEventListener-4vtCCyCS.js"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js b/dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js deleted file mode 100644 index 43c17f7..0000000 --- a/dist/workspace_web/AppIsDirtyEventListener-4vtCCyCS.js +++ /dev/null @@ -1 +0,0 @@ -import{r as l,j as y}from"./input.js";import{app as o}from"/scripts/app.js";import{a6 as S,j as C,ar as E,as as A,E as g,o as W,A as c,at as j,B as x}from"./App-bqAziDgv.js";import"/scripts/api.js";function v(d,f){const i=l.useRef(0),u=l.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=0)},[]),p=l.useCallback((...k)=>{u(),i.current=setTimeout(()=>d(...k),f)},[d,f,u]);return l.useEffect(()=>()=>{u()},[]),[p,u]}function F(){const{isDirty:d,setIsDirty:f,setRoute:i,saveCurWorkflow:u}=l.useContext(S),p=C();l.useEffect(()=>{const a=async e=>{switch(e){case g.SAVE:u();break;case g.SAVE_AS:i("saveAsModal");break}},s=o.canvas.onAfterChange;o.graph.onAfterChange=function(){s==null||s.apply(this,arguments),h()};const n=o.graph.onConfigure;o.graph.onConfigure=function(){n==null||n.apply(this,arguments),setTimeout(()=>{var t,r;E(o.graph.serialize(),JSON.parse(((r=(t=c)==null?void 0:t.curWorkflow)==null?void 0:r.json)??"{}"))||h()},1e3)},document.addEventListener("click",e=>{Object.keys(o.canvas.selected_nodes??{}).length&&(o.canvas.node_over!=null||o.canvas.node_capturing_input!=null||o.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var r;if(document.visibilityState==="hidden")return;const t=await A(e);t?a(t):(r=e.target)!=null&&r.matches("input, textarea")&&Object.keys(o.canvas.selected_nodes??{}).length&&h()})},[]);const k=async()=>{var s,n,e,t;if(!((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.id))return;const a=JSON.stringify(o.graph.serialize());a!=null&&await((e=c)==null?void 0:e.updateFlow(c.curWorkflow.id,{json:a})),(t=j)==null||t.create({workflowID:c.curWorkflow.id,isAutoSave:!0,json:a}),f(!1),p({position:"bottom-left",duration:1e3,render:()=>y.jsx(x,{color:"white",p:3,children:"Auto saved"})})},[b,D]=v(k,1e3),m=async()=>{var s,n,e,t,r,w;if((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.saveLock)return;const a=await((e=W)==null?void 0:e.getSetting("autoSave"));if(!a){!d&&f(!0);return}(r=(t=c)==null?void 0:t.curWorkflow)!=null&&r.id&&a&&(await((w=c)==null?void 0:w.latestVersionCheck())?b():p({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))},[h,_]=v(m,500);return null}export{F as default}; diff --git a/dist/workspace_web/GalleryModal-mtYV1YJE.js b/dist/workspace_web/GalleryModal-mtYV1YJE.js deleted file mode 100644 index e17dcd9..0000000 --- a/dist/workspace_web/GalleryModal-mtYV1YJE.js +++ /dev/null @@ -1,2 +0,0 @@ -import{b as Z,f as R,j as s,g as z,e as L,r as m,m as le,q as Ce,ab as Q,I as qt,L as ut,G as dt,ac as at,ad as se,k as ht,o as Oe,d as Te,x as Jt,E as Zt,n as Qt,V as en,h as tn,M as nn,N as an,O as sn,Q as on,R as rn,S as ln}from"./input.js";import{ai as cn,aj as mt,$ as un,h as he,F as b,ak as dn,I as O,n as hn,al as mn,B as fn,l as q,m as H,z as ft,a9 as xt,am as xn,a6 as gt,k as gn,H as ie,i as vn,a8 as vt,A as De,an as yn,C as bn}from"./App-bqAziDgv.js";import{c as Ae,p as Sn,r as st,v as ot,I as wn,N as pn,a as Pn,d as jn,e as kn,f as In,S as Cn,M as Tn,b as An}from"./MediaPreview-cVvL6fHO.js";import{I as Mn,C as Be,G as _n}from"./chunk-JARCRF6W-fNDfXRta.js";import{S as En}from"./chunk-3RSXBRAN-ajfTuIGC.js";import{L as Re}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,Nn=typeof performance<"u"?()=>performance.now():()=>Date.now(),bt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Nn()),yt);function Dn(e){let t=[],n=[],a=0,o=!1,l=!1;const i=new WeakSet,h={schedule:(r,c=!1,d=!1)=>{const u=d&&o,x=u?t:n;return c&&i.add(r),x.indexOf(r)===-1&&(x.push(r),u&&o&&(a=t.length)),r},cancel:r=>{const c=n.indexOf(r);c!==-1&&n.splice(c,1),i.delete(r)},process:r=>{if(o){l=!0;return}if(o=!0,[t,n]=[n,t],n.length=0,a=t.length,a)for(let c=0;c(e[t]=Dn(()=>J=!0),e),{}),zn=ee.reduce((e,t)=>{const n=me[t];return e[t]=(a,o=!1,l=!1)=>(J||Bn(),n.schedule(a,o,l)),e},{}),$n=ee.reduce((e,t)=>(e[t]=me[t].cancel,e),{});ee.reduce((e,t)=>(e[t]=()=>me[t].process(G),e),{});const On=e=>me[e].process(G),St=e=>{J=!1,G.delta=ze?yt:Math.max(Math.min(e-G.timestamp,Rn),1),G.timestamp=e,$e=!0,ee.forEach(On),$e=!1,J&&(ze=!1,bt(St))},Bn=()=>{J=!0,ze=!0,$e||bt(St)},rt=()=>G;var[Fn,fe]=Z({name:"AccordionStylesContext",hookName:"useAccordionStyles",providerName:""}),[Kn,Fe]=Z({name:"AccordionItemContext",hookName:"useAccordionItemContext",providerName:""}),[Vn,cs,Ln,Un]=cn(),wt=R(function(t,n){const{getButtonProps:a}=Fe(),o=a(t,n),i={display:"flex",alignItems:"center",width:"100%",outline:0,...fe().button};return s.jsx(z.button,{...o,className:L("chakra-accordion__button",t.className),__css:i})});wt.displayName="AccordionButton";function Hn(e){const{onChange:t,defaultIndex:n,index:a,allowMultiple:o,allowToggle:l,...i}=e;Yn(e),Xn(e);const h=Ln(),[r,c]=m.useState(-1);m.useEffect(()=>()=>{c(-1)},[]);const[d,u]=mt({value:a,defaultValue(){return o?n??[]:n??-1},onChange:t});return{index:d,setIndex:u,htmlProps:i,getAccordionItemProps:v=>{let w=!1;return v!==null&&(w=Array.isArray(d)?d.includes(v):d===v),{isOpen:w,onChange:S=>{if(v!==null)if(o&&Array.isArray(d)){const C=S?d.concat(v):d.filter(_=>_!==v);u(C)}else S?u(v):l&&u(-1)}}},focusedIndex:r,setFocusedIndex:c,descendants:h}}var[Gn,Ke]=Z({name:"AccordionContext",hookName:"useAccordionContext",providerName:"Accordion"});function Wn(e){const{isDisabled:t,isFocusable:n,id:a,...o}=e,{getAccordionItemProps:l,setFocusedIndex:i}=Ke(),h=m.useRef(null),r=m.useId(),c=a??r,d=`accordion-button-${c}`,u=`accordion-panel-${c}`;qn(e);const{register:x,index:v,descendants:w}=Un({disabled:t&&!n}),{isOpen:y,onChange:S}=l(v===-1?null:v);Jn({isOpen:y,isDisabled:t});const C=()=>{S==null||S(!0)},_=()=>{S==null||S(!1)},V=m.useCallback(()=>{S==null||S(!y),i(v)},[v,i,y,S]),B=m.useCallback(E=>{const j={ArrowDown:()=>{const T=w.nextEnabled(v);T==null||T.node.focus()},ArrowUp:()=>{const T=w.prevEnabled(v);T==null||T.node.focus()},Home:()=>{const T=w.firstEnabled();T==null||T.node.focus()},End:()=>{const T=w.lastEnabled();T==null||T.node.focus()}}[E.key];j&&(E.preventDefault(),j(E))},[w,v]),p=m.useCallback(()=>{i(v)},[i,v]),P=m.useCallback(function(D={},j=null){return{...D,type:"button",ref:le(x,h,j),id:d,disabled:!!t,"aria-expanded":!!y,"aria-controls":u,onClick:Ce(D.onClick,V),onFocus:Ce(D.onFocus,p),onKeyDown:Ce(D.onKeyDown,B)}},[d,t,y,V,p,B,u,x]),ne=m.useCallback(function(D={},j=null){return{...D,ref:j,role:"region",id:u,"aria-labelledby":d,hidden:!y}},[d,y,u]);return{isOpen:y,isDisabled:t,isFocusable:n,onOpen:C,onClose:_,getButtonProps:P,getPanelProps:ne,htmlProps:o}}function Yn(e){const t=e.index||e.defaultIndex,n=t!=null&&!Array.isArray(t)&&e.allowMultiple;Q({condition:!!n,message:`If 'allowMultiple' is passed, then 'index' or 'defaultIndex' must be an array. You passed: ${typeof t},`})}function Xn(e){Q({condition:!!(e.allowMultiple&&e.allowToggle),message:"If 'allowMultiple' is passed, 'allowToggle' will be ignored. Either remove 'allowToggle' or 'allowMultiple' depending on whether you want multiple accordions visible or not"})}function qn(e){Q({condition:!!(e.isFocusable&&!e.isDisabled),message:`Using only 'isFocusable', this prop is reserved for situations where you pass 'isDisabled' but you still want the element to receive focus (A11y). Either remove it or pass 'isDisabled' as well. - `})}function Jn(e){Q({condition:e.isOpen&&!!e.isDisabled,message:"Cannot open a disabled accordion item"})}function pt(e){const{isOpen:t,isDisabled:n}=Fe(),{reduceMotion:a}=Ke(),o=L("chakra-accordion__icon",e.className),l=fe(),i={opacity:n?.4:1,transform:t?"rotate(-180deg)":void 0,transition:a?void 0:"transform 0.2s",transformOrigin:"center",...l.icon};return s.jsx(qt,{viewBox:"0 0 24 24","aria-hidden":!0,className:o,__css:i,...e,children:s.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})})}pt.displayName="AccordionIcon";var Pt=R(function(t,n){const{children:a,className:o}=t,{htmlProps:l,...i}=Wn(t),r={...fe().container,overflowAnchor:"none"},c=m.useMemo(()=>i,[i]);return s.jsx(Kn,{value:c,children:s.jsx(z.div,{ref:n,...l,className:L("chakra-accordion__item",o),__css:r,children:typeof a=="function"?a({isExpanded:!!i.isOpen,isDisabled:!!i.isDisabled}):a})})});Pt.displayName="AccordionItem";var Zn=e=>e!=null&&parseInt(e.toString(),10)>0,lt={exit:{height:{duration:.2,ease:se.ease},opacity:{duration:.3,ease:se.ease}},enter:{height:{duration:.3,ease:se.ease},opacity:{duration:.4,ease:se.ease}}},Qn={exit:({animateOpacity:e,startingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:Zn(t)?1:0},height:t,transitionEnd:a==null?void 0:a.exit,transition:(l=n==null?void 0:n.exit)!=null?l:at.exit(lt.exit,o)}},enter:({animateOpacity:e,endingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:1},height:t,transitionEnd:a==null?void 0:a.enter,transition:(l=n==null?void 0:n.enter)!=null?l:at.enter(lt.enter,o)}}},jt=m.forwardRef((e,t)=>{const{in:n,unmountOnExit:a,animateOpacity:o=!0,startingHeight:l=0,endingHeight:i="auto",style:h,className:r,transition:c,transitionEnd:d,...u}=e,[x,v]=m.useState(!1);m.useEffect(()=>{const _=setTimeout(()=>{v(!0)});return()=>clearTimeout(_)},[]),Q({condition:Number(l)>0&&!!a,message:"startingHeight and unmountOnExit are mutually exclusive. You can't use them together"});const w=parseFloat(l.toString())>0,y={startingHeight:l,endingHeight:i,animateOpacity:o,transition:x?c:{enter:{duration:0}},transitionEnd:{enter:d==null?void 0:d.enter,exit:a?d==null?void 0:d.exit:{...d==null?void 0:d.exit,display:w?"block":"none"}}},S=a?n:!0,C=n||a?"enter":"exit";return s.jsx(ut,{initial:!1,custom:y,children:S&&s.jsx(dt.div,{ref:t,...u,className:L("chakra-collapse",r),style:{overflow:"hidden",display:"block",...h},custom:y,variants:Qn,initial:a?"exit":!1,animate:C,exit:"exit"})})});jt.displayName="Collapse";var kt=R(function(t,n){const{className:a,motionProps:o,...l}=t,{reduceMotion:i}=Ke(),{getPanelProps:h,isOpen:r}=Fe(),c=h(l,n),d=L("chakra-accordion__panel",a),u=fe();i||delete c.hidden;const x=s.jsx(z.div,{...c,__css:u.panel,className:d});return i?x:s.jsx(jt,{in:r,...o,children:x})});kt.displayName="AccordionPanel";var It=R(function({children:t,reduceMotion:n,...a},o){const l=ht("Accordion",a),i=Oe(a),{htmlProps:h,descendants:r,...c}=Hn(i),d=m.useMemo(()=>({...c,reduceMotion:!!n}),[c,n]);return s.jsx(Vn,{value:r,children:s.jsx(Gn,{value:d,children:s.jsx(Fn,{value:l,children:s.jsx(z.div,{ref:o,...h,className:L("chakra-accordion",a.className),__css:l.root,children:t})})})})});It.displayName="Accordion";var U=e=>e?"":void 0,Me=e=>e?!0:void 0,te=(...e)=>e.filter(Boolean).join(" ");function _e(...e){return function(n){e.some(a=>(a==null||a(n),n==null?void 0:n.defaultPrevented))}}function oe(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}var ce={width:0,height:0},re=e=>e||ce;function ea(e){const{orientation:t,thumbPercents:n,thumbRects:a,isReversed:o}=e,l=y=>{var S;const C=(S=a[y])!=null?S:ce;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...oe({orientation:t,vertical:{bottom:`calc(${n[y]}% - ${C.height/2}px)`},horizontal:{left:`calc(${n[y]}% - ${C.width/2}px)`}})}},i=t==="vertical"?a.reduce((y,S)=>re(y).height>re(S).height?y:S,ce):a.reduce((y,S)=>re(y).width>re(S).width?y:S,ce),h={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...oe({orientation:t,vertical:i?{paddingLeft:i.width/2,paddingRight:i.width/2}:{},horizontal:i?{paddingTop:i.height/2,paddingBottom:i.height/2}:{}})},r={position:"absolute",...oe({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},c=n.length===1,d=[0,o?100-n[0]:n[0]],u=c?d:n;let x=u[0];!c&&o&&(x=100-x);const v=Math.abs(u[u.length-1]-u[0]),w={...r,...oe({orientation:t,vertical:o?{height:`${v}%`,top:`${x}%`}:{height:`${v}%`,bottom:`${x}%`},horizontal:o?{width:`${v}%`,right:`${x}%`}:{width:`${v}%`,left:`${x}%`}})};return{trackStyle:r,innerTrackStyle:w,rootStyle:h,getThumbStyle:l}}function ta(e){const{isReversed:t,direction:n,orientation:a}=e;return n==="ltr"||a==="vertical"?t:!t}function na(e,t,n,a){return e.addEventListener(t,n,a),()=>{e.removeEventListener(t,n,a)}}function aa(e){const t=oa(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function Ct(e){return!!e.touches}function sa(e){return Ct(e)&&e.touches.length>1}function oa(e){var t;return(t=e.view)!=null?t:window}function ra(e,t="page"){const n=e.touches[0]||e.changedTouches[0];return{x:n[`${t}X`],y:n[`${t}Y`]}}function la(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function Tt(e,t="page"){return Ct(e)?ra(e,t):la(e,t)}function ia(e){return t=>{const n=aa(t);(!n||n&&t.button===0)&&e(t)}}function ca(e,t=!1){function n(o){e(o,{point:Tt(o)})}return t?ia(n):n}function ue(e,t,n,a){return na(e,t,ca(n,t==="pointerdown"),a)}var ua=Object.defineProperty,da=(e,t,n)=>t in e?ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(da(e,typeof t!="symbol"?t+"":t,n),n),ha=class{constructor(e,t,n){N(this,"history",[]),N(this,"startEvent",null),N(this,"lastEvent",null),N(this,"lastEventInfo",null),N(this,"handlers",{}),N(this,"removeListeners",()=>{}),N(this,"threshold",3),N(this,"win"),N(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const h=Ee(this.lastEventInfo,this.history),r=this.startEvent!==null,c=ga(h.offset,{x:0,y:0})>=this.threshold;if(!r&&!c)return;const{timestamp:d}=rt();this.history.push({...h.point,timestamp:d});const{onStart:u,onMove:x}=this.handlers;r||(u==null||u(this.lastEvent,h),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,h)}),N(this,"onPointerMove",(h,r)=>{this.lastEvent=h,this.lastEventInfo=r,zn.update(this.updatePoint,!0)}),N(this,"onPointerUp",(h,r)=>{const c=Ee(r,this.history),{onEnd:d,onSessionEnd:u}=this.handlers;u==null||u(h,c),this.end(),!(!d||!this.startEvent)&&(d==null||d(h,c))});var a;if(this.win=(a=e.view)!=null?a:window,sa(e))return;this.handlers=t,n&&(this.threshold=n),e.stopPropagation(),e.preventDefault();const o={point:Tt(e)},{timestamp:l}=rt();this.history=[{...o.point,timestamp:l}];const{onSessionStart:i}=t;i==null||i(e,Ee(o,this.history)),this.removeListeners=xa(ue(this.win,"pointermove",this.onPointerMove),ue(this.win,"pointerup",this.onPointerUp),ue(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),$n.update(this.updatePoint)}};function it(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ee(e,t){return{point:e.point,delta:it(e.point,t[t.length-1]),offset:it(e.point,t[0]),velocity:fa(t,.1)}}var ma=e=>e*1e3;function fa(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const o=e[e.length-1];for(;n>=0&&(a=e[n],!(o.timestamp-a.timestamp>ma(t)));)n--;if(!a)return{x:0,y:0};const l=(o.timestamp-a.timestamp)/1e3;if(l===0)return{x:0,y:0};const i={x:(o.x-a.x)/l,y:(o.y-a.y)/l};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function xa(...e){return t=>e.reduce((n,a)=>a(n),t)}function Ne(e,t){return Math.abs(e-t)}function ct(e){return"x"in e&&"y"in e}function ga(e,t){if(typeof e=="number"&&typeof t=="number")return Ne(e,t);if(ct(e)&&ct(t)){const n=Ne(e.x,t.x),a=Ne(e.y,t.y);return Math.sqrt(n**2+a**2)}return 0}function At(e){const t=m.useRef(null);return t.current=e,t}function va(e,t){const{onPan:n,onPanStart:a,onPanEnd:o,onPanSessionStart:l,onPanSessionEnd:i,threshold:h}=t,r=!!(n||a||o||l||i),c=m.useRef(null),d=At({onSessionStart:l,onSessionEnd:i,onStart:a,onMove:n,onEnd(u,x){c.current=null,o==null||o(u,x)}});m.useEffect(()=>{var u;(u=c.current)==null||u.updateHandlers(d.current)}),m.useEffect(()=>{const u=e.current;if(!u||!r)return;function x(v){c.current=new ha(v,d.current,h)}return ue(u,"pointerdown",x)},[e,r,d,h]),m.useEffect(()=>()=>{var u;(u=c.current)==null||u.end(),c.current=null},[])}function ya(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const n=e.ownerDocument.defaultView??window,a=new n.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[l]=o;let i,h;if("borderBoxSize"in l){const r=l.borderBoxSize,c=Array.isArray(r)?r[0]:r;i=c.inlineSize,h=c.blockSize}else i=e.offsetWidth,h=e.offsetHeight;t({width:i,height:h})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}var ba=globalThis!=null&&globalThis.document?m.useLayoutEffect:m.useEffect;function Sa(e,t){var n,a;if(!e||!e.parentElement)return;const o=(a=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?a:window,l=new o.MutationObserver(()=>{t()});return l.observe(e.parentElement,{childList:!0}),()=>{l.disconnect()}}function wa({getNodes:e,observeMutation:t=!0}){const[n,a]=m.useState([]),[o,l]=m.useState(0);return ba(()=>{const i=e(),h=i.map((r,c)=>ya(r,d=>{a(u=>[...u.slice(0,c),d,...u.slice(c+1)])}));if(t){const r=i[0];h.push(Sa(r,()=>{l(c=>c+1)}))}return()=>{h.forEach(r=>{r==null||r()})}},[o]),n}function pa(e){return typeof e=="object"&&e!==null&&"current"in e}function Pa(e){const[t]=wa({observeMutation:!1,getNodes(){return[pa(e)?e.current:e]}});return t}function ja(e){var t;const{min:n=0,max:a=100,onChange:o,value:l,defaultValue:i,isReversed:h,direction:r="ltr",orientation:c="horizontal",id:d,isDisabled:u,isReadOnly:x,onChangeStart:v,onChangeEnd:w,step:y=1,getAriaValueText:S,"aria-valuetext":C,"aria-label":_,"aria-labelledby":V,name:B,focusThumbOnChange:p=!0,...P}=e,ne=Te(v),E=Te(w),D=Te(S),j=ta({isReversed:h,direction:r,orientation:c}),[T,ve]=mt({value:l,defaultValue:i??Ia(n,a),onChange:o}),[ye,Ve]=m.useState(!1),[be,Le]=m.useState(!1),Se=!(u||x),we=(a-n)/10,W=y||(a-n)/100,k=Ae(T,n,a),Ot=a-k+n,Ue=ot(j?Ot:k,n,a),ae=c==="vertical",I=At({min:n,max:a,step:y,isDisabled:u,value:k,isInteractive:Se,isReversed:j,isVertical:ae,eventSource:null,focusThumbOnChange:p,orientation:c}),pe=m.useRef(null),Pe=m.useRef(null),He=m.useRef(null),Bt=m.useId(),Ge=d??Bt,[We,Ye]=[`slider-thumb-${Ge}`,`slider-track-${Ge}`],Ft=m.useCallback(f=>{var g,Y;if(!pe.current)return;const A=I.current;A.eventSource="pointer";const $=pe.current.getBoundingClientRect(),{clientX:ke,clientY:Wt}=(Y=(g=f.touches)==null?void 0:g[0])!=null?Y:f,Yt=ae?$.bottom-Wt:ke-$.left,Xt=ae?$.height:$.width;let Ie=Yt/Xt;j&&(Ie=1-Ie);let X=Sn(Ie,A.min,A.max);return A.step&&(X=parseFloat(st(X,A.min,A.step))),X=Ae(X,A.min,A.max),X},[ae,j,I]),F=m.useCallback(f=>{const g=I.current;g.isInteractive&&(f=parseFloat(st(f,g.min,W)),f=Ae(f,g.min,g.max),ve(f))},[W,ve,I]),K=m.useMemo(()=>({stepUp(f=W){const g=j?k-f:k+f;F(g)},stepDown(f=W){const g=j?k+f:k-f;F(g)},reset(){F(i||0)},stepTo(f){F(f)}}),[F,j,k,W,i]),Xe=m.useCallback(f=>{const g=I.current,A={ArrowRight:()=>K.stepUp(),ArrowUp:()=>K.stepUp(),ArrowLeft:()=>K.stepDown(),ArrowDown:()=>K.stepDown(),PageUp:()=>K.stepUp(we),PageDown:()=>K.stepDown(we),Home:()=>F(g.min),End:()=>F(g.max)}[f.key];A&&(f.preventDefault(),f.stopPropagation(),A(f),g.eventSource="keyboard")},[K,F,we,I]),qe=(t=D==null?void 0:D(k))!=null?t:C,je=Pa(Pe),{getThumbStyle:Je,rootStyle:Ze,trackStyle:Qe,innerTrackStyle:et}=m.useMemo(()=>{const f=I.current,g=je??{width:0,height:0};return ea({isReversed:j,orientation:f.orientation,thumbRects:[g],thumbPercents:[Ue]})},[j,je,Ue,I]),tt=m.useCallback(()=>{I.current.focusThumbOnChange&&setTimeout(()=>{var g;return(g=Pe.current)==null?void 0:g.focus()})},[I]);Jt(()=>{const f=I.current;tt(),f.eventSource==="keyboard"&&(E==null||E(f.value))},[k,E]);function nt(f){const g=Ft(f);g!=null&&g!==I.current.value&&ve(g)}va(He,{onPanSessionStart(f){const g=I.current;g.isInteractive&&(Ve(!0),tt(),nt(f),ne==null||ne(g.value))},onPanSessionEnd(){const f=I.current;f.isInteractive&&(Ve(!1),E==null||E(f.value))},onPan(f){I.current.isInteractive&&nt(f)}});const Kt=m.useCallback((f={},g=null)=>({...f,...P,ref:le(g,He),tabIndex:-1,"aria-disabled":Me(u),"data-focused":U(be),style:{...f.style,...Ze}}),[P,u,be,Ze]),Vt=m.useCallback((f={},g=null)=>({...f,ref:le(g,pe),id:Ye,"data-disabled":U(u),style:{...f.style,...Qe}}),[u,Ye,Qe]),Lt=m.useCallback((f={},g=null)=>({...f,ref:g,style:{...f.style,...et}}),[et]),Ut=m.useCallback((f={},g=null)=>({...f,ref:le(g,Pe),role:"slider",tabIndex:Se?0:void 0,id:We,"data-active":U(ye),"aria-valuetext":qe,"aria-valuemin":n,"aria-valuemax":a,"aria-valuenow":k,"aria-orientation":c,"aria-disabled":Me(u),"aria-readonly":Me(x),"aria-label":_,"aria-labelledby":_?void 0:V,style:{...f.style,...Je(0)},onKeyDown:_e(f.onKeyDown,Xe),onFocus:_e(f.onFocus,()=>Le(!0)),onBlur:_e(f.onBlur,()=>Le(!1))}),[Se,We,ye,qe,n,a,k,c,u,x,_,V,Je,Xe]),Ht=m.useCallback((f,g=null)=>{const Y=!(f.valuea),A=k>=f.value,$=ot(f.value,n,a),ke={position:"absolute",pointerEvents:"none",...ka({orientation:c,vertical:{bottom:j?`${100-$}%`:`${$}%`},horizontal:{left:j?`${100-$}%`:`${$}%`}})};return{...f,ref:g,role:"presentation","aria-hidden":!0,"data-disabled":U(u),"data-invalid":U(!Y),"data-highlighted":U(A),style:{...f.style,...ke}}},[u,j,a,n,c,k]),Gt=m.useCallback((f={},g=null)=>({...f,ref:g,type:"hidden",value:k,name:B}),[B,k]);return{state:{value:k,isFocused:be,isDragging:ye},actions:K,getRootProps:Kt,getTrackProps:Vt,getInnerTrackProps:Lt,getThumbProps:Ut,getMarkerProps:Ht,getInputProps:Gt}}function ka(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}function Ia(e,t){return t"}),[Ta,ge]=Z({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Mt=R((e,t)=>{var n;const a={...e,orientation:(n=e==null?void 0:e.orientation)!=null?n:"horizontal"},o=ht("Slider",a),l=Oe(a),{direction:i}=Zt();l.direction=i;const{getInputProps:h,getRootProps:r,...c}=ja(l),d=r(),u=h({},t);return s.jsx(Ca,{value:c,children:s.jsx(Ta,{value:o,children:s.jsxs(z.div,{...d,className:te("chakra-slider",a.className),__css:o.container,children:[a.children,s.jsx("input",{...u})]})})})});Mt.displayName="Slider";var _t=R((e,t)=>{const{getThumbProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__thumb",e.className),__css:a.thumb})});_t.displayName="SliderThumb";var Et=R((e,t)=>{const{getTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__track",e.className),__css:a.track})});Et.displayName="SliderTrack";var Nt=R((e,t)=>{const{getInnerTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__filled-track",e.className),__css:a.filledTrack})});Nt.displayName="SliderFilledTrack";var Aa=R((e,t)=>{const{getMarkerProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__marker",e.className),__css:a.mark})});Aa.displayName="SliderMark";function Ma(e,t=[]){const n=Object.assign({},e);for(const a of t)a in n&&delete n[a];return n}var _a=["h","minH","height","minHeight"],Dt=R((e,t)=>{const n=Qt("Textarea",e),{className:a,rows:o,...l}=Oe(e),i=un(l),h=o?Ma(n,_a):n;return s.jsx(z.textarea,{ref:t,rows:o,...i,className:L("chakra-textarea",a),__css:h})});Dt.displayName="Textarea";var Ea=he("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]),Na=he("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Rt=he("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),zt=he("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const Da=({setMediaAct:e,media:t,currentNum:n})=>{const[a,o]=m.useState(0);m.useEffect(()=>{n!==void 0&&o(n)},[n]);const l=r=>{const c=(a+r+t.length)%t.length;o(c),e&&e(t[c])},i={width:"100%",height:"100%"},h={enter:r=>({x:r>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:r=>({x:r<0?500:-500,opacity:1})};return s.jsxs(b,{justifyContent:"center",alignItems:"center",position:"relative",width:i.width,height:i.height,overflow:"hidden",children:[s.jsx(ut,{custom:a,children:t.map((r,c)=>s.jsx(dt.div,{custom:c-a,variants:h,initial:"enter",animate:"center",exit:"exit",transition:{x:{type:"spring",stiffness:300,damping:30},opacity:{duration:.2}},style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%",display:c===a?"block":"none"},onClick:()=>{window.open(r.imageUrl)},children:dn(r.imageUrl)?s.jsx(Mn,{src:r.imageUrl,alt:`image-${r.id}`,width:"100%",height:"100%",objectFit:"contain"}):s.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:r.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:s.jsx("track",{kind:"captions"})})},r.id))}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:s.jsx(Na,{}),onClick:()=>l(-1),position:"absolute",left:"0",zIndex:"2"}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:s.jsx(wn,{}),onClick:()=>l(1),position:"absolute",right:"0",zIndex:"2"})]})},Ra=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(hn,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})}})]}),za=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsxs(pn,{width:"100%",step:e==null?void 0:e.step,value:e.value,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Pn,{}),s.jsxs(jn,{children:[s.jsx(kn,{}),s.jsx(In,{})]})]})]}),s.jsx(b,{children:s.jsxs(Mt,{step:e==null?void 0:e.step,value:Number(e.value),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Et,{children:s.jsx(Nt,{})}),s.jsx(_t,{})]})})]}),$a=e=>{var t;return s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(En,{value:e.value,onChange:n=>{var a;return(a=e==null?void 0:e.updateMetaData)==null?void 0:a.call(e,{promptKey:e.promptKey,name:e.name,value:n.target.value})},children:(t=e==null?void 0:e.options)==null?void 0:t.map((n,a)=>s.jsx("option",{value:n,children:n},`select${e.promptKey}${e.classType}${e.name}${a}`))})]})},Oa=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsx(b,{children:e.label??e.name}),s.jsx(Dt,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})},rows:5})]});var M=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(M||{});const Ba=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(b,{children:"No Support"})]}),Fa=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(Be,{isChecked:!!e.value,onChange:t=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.checked})}})]}),Ka={[M.Input]:Ra,[M.InputSlider]:za,[M.Select]:$a,[M.Textarea]:Oa,[M.Checkbox]:Fa,NoSupport:Ba},Va=mn();function La(e){var a,o,l,i,h;const t=(a=Va[e.classType])==null?void 0:a.nodeData,n={...((o=t==null?void 0:t.input)==null?void 0:o.required)??{},...((l=t==null?void 0:t.input)==null?void 0:l.optional)??{}}[e.name];return(n==null?void 0:n[0])==="STRING"?(i=n==null?void 0:n[1])!=null&&i.multiline?{type:M.Textarea}:{type:M.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:M.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((h=n==null?void 0:n[0])!=null&&h.every(r=>typeof r=="string"))?{options:n==null?void 0:n[0],type:M.Select}:{type:M.NoSupport}}const $t=e=>{const t=La(e),n=Ka[t.type??"Input"];return s.jsxs(_n,{templateColumns:"max-content 1fr",gap:1,children:[s.jsx(b,{children:s.jsx(O,{onClick:()=>{var a;return(a=e==null?void 0:e.updateTopField)==null?void 0:a.call(e,{name:e.name,promptKey:e.promptKey,class_type:e.classType})},variant:"text",icon:de(e.topFields,{name:e.name,promptKey:e.promptKey,classType:e.classType})?s.jsx(Rt,{}):s.jsx(zt,{}),"aria-label":"pin"})}),s.jsx(n,{...e,...t})]})};function Ua({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){if(n.length===0)return null;const o=e.prompt;return s.jsx(s.Fragment,{children:s.jsx(b,{px:2,gap:2,direction:"column",children:n==null?void 0:n.map((l,i)=>{var d,u,x;const h=(d=o==null?void 0:o[l.promptKey])==null?void 0:d.inputs;if(!h||((u=o==null?void 0:o[l.promptKey])==null?void 0:u.class_type)!==l.class_type)return null;const c=h==null?void 0:h[l.name];return s.jsx($t,{promptKey:l.promptKey,classType:(x=o==null?void 0:o[l.promptKey])==null?void 0:x.class_type,name:l.name,value:c,updateMetaData:t,updateTopField:a,topFields:n},`formTop${l.name}${i}`)})})})}function Ha({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){const o=e.prompt,[l,i]=m.useState([]);return m.useEffect(()=>{i(Object.keys(o).map((h,r)=>r))},[o]),s.jsx(It,{index:l,onChange:h=>i(h),allowMultiple:!0,children:Object.keys(o).map(h=>{const r=o[h],c=r.inputs,d=Object.keys(c).filter(u=>!Array.isArray(c[u])&&!de(n,{name:u,promptKey:h,classType:r.class_type}));return d.length===0?null:s.jsxs(Pt,{borderWidth:1,borderRadius:8,my:2,children:[s.jsxs(wt,{children:[s.jsx(fn,{as:"span",flex:"1",textAlign:"left",children:r.class_type}),s.jsx(pt,{})]}),s.jsx(kt,{children:s.jsx(b,{px:2,gap:1,direction:"column",children:d==null?void 0:d.map(u=>{const x=c[u];return de(n,{name:u,promptKey:h,classType:r.class_type})?null:s.jsx($t,{promptKey:h,classType:r==null?void 0:r.class_type,value:x,name:u,updateMetaData:t,updateTopField:a,topFields:n,metaData:e},`form${u}`)})})})]},`AccordionItem${h}`)})})}const Ga=[{promptKey:"4",name:"ckpt_name",class_type:"CheckpointLoaderSimple"},{promptKey:"6",name:"text",class_type:"CLIPTextEncode"},{promptKey:"7",name:"text",class_type:"CLIPTextEncode"},{promptKey:"5",name:"width",class_type:"EmptyLatentImage"},{promptKey:"5",name:"height",class_type:"EmptyLatentImage"},{promptKey:"3",name:"steps",class_type:"KSampler"},{promptKey:"3",name:"sampler_name",class_type:"KSampler"},{promptKey:"3",name:"cfg",class_type:"KSampler"}],de=(e,t)=>e==null?void 0:e.some(n=>n.promptKey===(t==null?void 0:t.promptKey)&&n.name===(t==null?void 0:t.name)&&n.class_type===t.classType);function Wa({metaData:e}){const t=JSON.parse(JSON.stringify(e)),[n,a]=m.useState(Ga),[o,l]=m.useState(t),i=({promptKey:r,name:c,value:d})=>{l(u=>{var x,v,w;return{...u??{},prompt:{...(u==null?void 0:u.prompt)??{},[r]:{...((x=u==null?void 0:u.prompt)==null?void 0:x[r])??{},inputs:{...((w=(v=u.prompt)==null?void 0:v[r])==null?void 0:w.inputs)??{},[c]:d}}}}})},h=r=>{de(n,{name:r.name,promptKey:r==null?void 0:r.promptKey,classType:(r==null?void 0:r.class_type)??""})?a(c=>c.filter(d=>d.name!==r.name||d.promptKey!==r.promptKey)):a(c=>[...c,r])};return s.jsxs(b,{direction:"column",align:"stretch",children:[s.jsx(Ua,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h}),s.jsx(Ha,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h})]})}const Ya=({media:e})=>{const[t,n]=m.useState(),a=async o=>{try{const l=await xn(`/workspace/view_media?filename=${o.localPath}`);n(l)}catch(l){console.error(l)}};return m.useEffect(()=>{e&&a(e)},[e]),s.jsxs(b,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[s.jsxs(Cn,{alignItems:"center",columns:2,spacing:2,children:[s.jsxs(b,{alignItems:"center",gap:1,children:[s.jsx(q,{children:e==null?void 0:e.localPath}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:s.jsx(O,{size:"sm",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]}),s.jsxs(b,{gap:1,alignItems:"center",children:[s.jsx(q,{children:"Create Time:"}),s.jsx(q,{children:xt((e==null?void 0:e.createTime)??0,!0)})]})]}),e&&t&&s.jsx(Wa,{metaData:t,media:e})]})},Xa=({mediaList:e,media:t})=>{const[n,a]=m.useState();return m.useEffect(()=>{t&&a(t)},[t]),s.jsxs(b,{gap:3,h:"100%",children:[s.jsx(b,{flex:1,children:s.jsx(Da,{media:e.map(o=>({id:o.id,imageUrl:`/workspace/view_media?filename=${o.localPath}`})),currentNum:e==null?void 0:e.findIndex(o=>o.id===(n==null?void 0:n.id)),setMediaAct:o=>a(e==null?void 0:e.find(l=>l.id===o.id))})}),s.jsx(Ya,{media:n})]})},qa=({media:e,isSelecting:t,selectedID:n,onClickMedia:a,onRefreshImagesList:o,coverPath:l,setCoverPath:i})=>{const{curFlowID:r,loadFilePath:c}=m.useContext(gt),{showDialog:d}=en();if(e.localPath==null)return null;const u=l!=null&&l===e.localPath;if(r==null)return null;const x=s.jsxs(Re,{isExternal:!0,onClick:()=>a(e),position:"relative",children:[t&&s.jsx(Be,{isChecked:n.includes(e.id),position:"absolute",top:2,left:2}),s.jsx(Tn,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!0})]});return s.jsxs(gn,{width:180,mb:2,children:[s.jsx(H,{label:xt(e.createTime,!0),children:x}),s.jsx(H,{label:e.localPath,children:s.jsx(q,{color:"GrayText",noOfLines:1,children:e.localPath})}),s.jsxs(ie,{hidden:t,gap:0,children:[s.jsx(H,{label:"Set as cover",children:s.jsx(O,{size:"sm",variant:"ghost",icon:u?s.jsx(Rt,{size:19}):s.jsx(zt,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=De)==null||v.updateMetaInfo(r,{coverMediaPath:e.localPath}),i(e.localPath)}})}),s.jsx(tn,{flexGrow:1,onClick:()=>d("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{c(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>c(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),s.jsx(H,{label:"Remove image from gallery",children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(vn,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var w,y;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((w=vt)==null?void 0:w.delete(e.id)),u&&(await((y=De)==null?void 0:y.updateMetaInfo(r,{coverMediaPath:void 0})),i("")),o())}})})]})]})},Ja=qa;function us({onclose:e}){const{curFlowID:t}=m.useContext(gt),[n,a]=m.useState(""),[o,l]=m.useState([]),[i,h]=m.useState(!1),[r,c]=m.useState(""),[d,u]=m.useState([]),[x,v]=m.useState(),[w,y]=m.useState(""),S=p=>{y(p)},C=async()=>{var P;if(t==null)return;const p=await((P=vt)==null?void 0:P.listByWorkflowID(t));u(p??[])};m.useEffect(()=>{var p;C(),t&&((p=De)==null||p.get(t).then(P=>{P&&(a(P.name),P!=null&&P.coverMediaPath&&c(P==null?void 0:P.coverMediaPath))}))},[]);const _=w.length?d==null?void 0:d.filter(p=>{var P;return(P=p.workflowJSON)==null?void 0:P.includes(w??"")}):d;if(t==null)return null;const V=p=>{if(i){o.includes(p.id)?l(o.filter(P=>P!==p.id)):l([...o,p.id]);return}v(p)},B=d.length>0&&o.length===d.length;return s.jsxs(nn,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[s.jsx(an,{}),s.jsxs(sn,{width:"90%",maxWidth:"90vw",height:"90vh",children:[s.jsxs(on,{children:[s.jsx(ie,{gap:2,mb:2,children:s.jsxs(yn,{size:"md",mr:2,children:[!!x&&s.jsx(O,{onClick:()=>v(void 0),variant:"ghost",mr:1,"aria-label":"back",icon:s.jsx(Ea,{})}),"Gallery - ",n,!x&&s.jsx(b,{gap:2,display:"inline-flex",ml:2,children:s.jsx(An,{searchValue:w,onUpdateSearchValue:S})})]})}),i&&s.jsxs(ie,{gap:3,children:[s.jsx(Be,{isChecked:B,onChange:()=>{l(B?[]:d.map(p=>p.id))},children:"All"}),s.jsxs(q,{fontSize:16,children:[o.length," Selected"]}),s.jsx(O,{size:"sm",icon:s.jsx(bn,{size:19}),onClick:()=>h(!1),"aria-label":"cancel"})]})]}),s.jsx(rn,{}),s.jsx(ln,{overflowY:"auto",children:x?s.jsx(Xa,{mediaList:d,media:x}):s.jsx(ie,{wrap:"wrap",children:_.map(p=>s.jsx(Ja,{selectedID:o,media:p,isSelecting:i,onClickMedia:V,onRefreshImagesList:C,coverPath:r,setCoverPath:c},p.id))})})]})]})}export{us as default}; diff --git a/dist/workspace_web/IconCopy-Vm3ws_0T.js b/dist/workspace_web/IconCopy-Vm3ws_0T.js deleted file mode 100644 index b6c56d0..0000000 --- a/dist/workspace_web/IconCopy-Vm3ws_0T.js +++ /dev/null @@ -1 +0,0 @@ -import{h as a}from"./App-bqAziDgv.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; diff --git a/dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js b/dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js deleted file mode 100644 index 12e03a5..0000000 --- a/dist/workspace_web/InstallMissingModelsButton-g1lfodpY.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar--uE4bw7I.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aM as I,F as S,an as b}from"./App-bqAziDgv.js";import{V as k}from"./chunk-NTCQBYKE-ZJqEVTS0.js";import{I as y,G as C}from"./chunk-JARCRF6W-fNDfXRta.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-ajfTuIGC.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default}; diff --git a/dist/workspace_web/MediaPreview-cVvL6fHO.js b/dist/workspace_web/MediaPreview-cVvL6fHO.js deleted file mode 100644 index 41c8a03..0000000 --- a/dist/workspace_web/MediaPreview-cVvL6fHO.js +++ /dev/null @@ -1 +0,0 @@ -import{G as Ge,I as Ke}from"./chunk-JARCRF6W-fNDfXRta.js";import{d as M,r as s,f as T,E as Ue,j as f,ae as $e,I as Ee,x as qe,y as ze,m as ae,q as y,p as se,b as Pe,g as Y,k as He,o as Le,e as Me}from"./input.js";import{ao as Fe,ap as We,aq as Xe,h as Re,B as Ye,I as Je,C as Qe,n as Ze,ak as et}from"./App-bqAziDgv.js";function tt(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function le(t,e){let r=tt(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Et(t,e,r){return(t-e)*100/(r-e)}function Pt(t,e,r){return(r-e)*t+e}function Mt(t,e,r){const a=Math.round((t-e)/r)*r+e,o=oe(r);return le(a,o)}function nt(t,e,r){return t==null?t:(r{var m;return a==null?"":(m=ue(a,u,r))!=null?m:""}),S=typeof o<"u",x=S?o:C,O=Te(k(x),u),F=r??O,I=s.useCallback(m=>{m!==x&&(S||A(m.toString()),h==null||h(m.toString(),k(m)))},[h,S,x]),w=s.useCallback(m=>{let d=m;return b&&(d=nt(d,i,p)),le(d,F)},[F,b,p,i]),B=s.useCallback((m=u)=>{let d;x===""?d=k(m):d=k(x)+m,d=w(d),I(d)},[w,u,I,x]),G=s.useCallback((m=u)=>{let d;x===""?d=k(-m):d=k(x)-m,d=w(d),I(d)},[w,u,I,x]),K=s.useCallback(()=>{var m;let d;a==null?d="":d=(m=ue(a,u,r))!=null?m:i,I(d)},[a,r,u,I,i]),Q=s.useCallback(m=>{var d;const ee=(d=ue(m,u,F))!=null?d:i;I(ee)},[F,u,I,i]),E=k(x);return{isOutOfRange:E>p||E{const a=$e("sizes",r,st(r))(e);return r===null?null:`repeat(auto-fit, minmax(${a}, 1fr))`})}function ot(t){return Fe(t,e=>e===null?null:`repeat(${e}, minmax(0, 1fr))`)}var lt=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),it=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function ke(t,e,r,a){s.useEffect(()=>{var o;if(!t.current||!a)return;const u=(o=t.current.ownerDocument.defaultView)!=null?o:window,i=Array.isArray(e)?e:[e],p=new u.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return p.observe(t.current,{attributes:!0,attributeFilter:i}),()=>p.disconnect()})}function ct(t,e){const r=M(t);s.useEffect(()=>{let a=null;const o=()=>r();return e!==null&&(a=window.setInterval(o,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var pt=50,Ae=300;function dt(t,e){const[r,a]=s.useState(!1),[o,u]=s.useState(null),[i,p]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);ct(()=>{o==="increment"&&t(),o==="decrement"&&e()},r?pt:null);const C=s.useCallback(()=>{i&&t(),b.current=setTimeout(()=>{p(!1),a(!0),u("increment")},Ae)},[t,i]),A=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{p(!1),a(!0),u("decrement")},Ae)},[e,i]),S=s.useCallback(()=>{p(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:C,down:A,stop:S,isSpinning:r}}var mt=/^[Ee0-9+\-.]$/;function ft(t){return mt.test(t)}function bt(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function vt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:o=Number.MIN_SAFE_INTEGER,max:u=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:p,isDisabled:b,isRequired:h,isInvalid:C,pattern:A="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:I,name:w,"aria-describedby":B,"aria-label":G,"aria-labelledby":K,onFocus:Q,onBlur:E,onInvalid:ce,getAriaValueText:pe,isValidCharacter:Z,format:m,parse:d,...ee}=t,te=M(Q),de=M(E),V=M(ce),U=M(Z??ft),ne=M(pe),l=rt(t),{update:j,increment:me,decrement:fe}=l,[je,re]=s.useState(!1),$=!(p||b),_=s.useRef(null),q=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),z=s.useCallback(n=>n.split("").filter(U).join(""),[U]),H=s.useCallback(n=>{var c;return(c=d==null?void 0:d(n))!=null?c:n},[d]),R=s.useCallback(n=>{var c;return((c=m==null?void 0:m(n))!=null?c:n).toString()},[m]);qe(()=>{(l.valueAsNumber>u||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=H(_.current.value);l.setValue(z(c))}},[H,z]);const L=s.useCallback((n=i)=>{$&&me(n)},[me,$,i]),W=s.useCallback((n=i)=>{$&&fe(n)},[fe,$,i]),g=dt(L,W);ke(be,"disabled",g.stop,g.isSpinning),ke(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;const v=H(n.currentTarget.value);j(z(v)),q.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[j,z,H]),ge=s.useCallback(n=>{var c,v,N;te==null||te(n),q.current&&(n.target.selectionStart=(v=q.current.start)!=null?v:(c=n.currentTarget.value)==null?void 0:c.length,n.currentTarget.selectionEnd=(N=q.current.end)!=null?N:n.currentTarget.selectionStart)},[te]),xe=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;bt(n,U)||n.preventDefault();const c=Ne(n)*i,v=n.key,P={ArrowUp:()=>L(c),ArrowDown:()=>W(c),Home:()=>j(o),End:()=>j(u)}[v];P&&(n.preventDefault(),P(n))},[U,i,L,W,j,o,u]),Ne=n=>{let c=1;return(n.metaKey||n.ctrlKey)&&(c=.1),n.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const n=ne==null?void 0:ne(l.value);if(n!=null)return n;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let n=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumberu&&(n=u),l.cast(n))},[l,u,o]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=_.current)==null||n.focus()})},[e]),Se=s.useCallback(n=>{n.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(n=>{n.preventDefault(),g.down(),X()},[X,g]);We(()=>_.current,"wheel",n=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;n.preventDefault();const D=Ne(n)*i,_e=Math.sign(n.deltaY);_e===-1?L(D):_e===1&&W(D)},{passive:!1});const De=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMax;return{...n,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),Oe=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMin;return{...n,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),Be=s.useCallback((n={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:A,"aria-labelledby":K,"aria-label":G,"aria-describedby":B,id:O,disabled:b,...n,readOnly:(v=n.readOnly)!=null?v:p,"aria-readonly":(N=n.readOnly)!=null?N:p,"aria-required":(P=n.required)!=null?P:h,required:(D=n.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":o,"aria-valuemax":u,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(C??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:y(n.onChange,he),onKeyDown:y(n.onKeyDown,xe),onFocus:y(n.onFocus,ge,()=>re(!0)),onBlur:y(n.onBlur,de,Ce)}},[w,S,A,K,G,R,B,O,b,h,p,C,l.value,l.valueAsNumber,l.isOutOfRange,o,u,Ie,he,xe,ge,de,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:je,isDisabled:b,isReadOnly:p,getIncrementButtonProps:De,getDecrementButtonProps:Oe,getInputProps:Be,htmlProps:ee}}var[ht,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[gt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),xt=T(function(e,r){const a=He("NumberInput",e),o=Le(e),u=Xe(o),{htmlProps:i,...p}=vt(u),b=s.useMemo(()=>p,[p]);return f.jsx(gt,{value:b,children:f.jsx(ht,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});xt.displayName="NumberInput";var Nt=T(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});Nt.displayName="NumberInputStepper";var It=T(function(e,r){const{getInputProps:a}=ie(),o=a(e,r),u=J();return f.jsx(Y.input,{...o,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...u.field}})});It.displayName="NumberInputField";var Ve=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),yt=T(function(e,r){var a;const o=J(),{getDecrementButtonProps:u}=ie(),i=u(e,r);return f.jsx(Ve,{...i,__css:o.stepper,children:(a=e.children)!=null?a:f.jsx(lt,{})})});yt.displayName="NumberDecrementStepper";var Ct=T(function(e,r){var a;const{getIncrementButtonProps:o}=ie(),u=o(e,r),i=J();return f.jsx(Ve,{...u,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(it,{})})});Ct.displayName="NumberIncrementStepper";var Ft=Re("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]),St=Re("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);const wt={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function Rt(t){const{searchValue:e,onUpdateSearchValue:r}=t,a=e!=="";return f.jsxs(Ye,{style:{position:"relative"},mb:2,children:[f.jsx(St,{style:wt}),a&&f.jsx(Je,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(Qe,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(Ze,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function Tt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:o,onBrokenLink:u}){const[i,p]=s.useState(!0);return s.useEffect(()=>{o&&(async()=>{try{if(!(await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");p(!0)}catch{p(!1),u==null||u()}})()},[]),i?et(t)?f.jsx(Ke,{borderRadius:3,boxSize:`${e}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{Ft as I,Tt as M,xt as N,at as S,It as a,Rt as b,nt as c,Nt as d,Ct as e,yt as f,Pt as p,Mt as r,Et as v}; diff --git a/dist/workspace_web/ModelManagerTopbar--uE4bw7I.js b/dist/workspace_web/ModelManagerTopbar--uE4bw7I.js deleted file mode 100644 index 2d785cf..0000000 --- a/dist/workspace_web/ModelManagerTopbar--uE4bw7I.js +++ /dev/null @@ -1,7 +0,0 @@ -import{f as Y,r as m,j as n,g as $,e as Se,a4 as X,b as $e,o as Ve,k as Ue,h as T,a9 as re,af as He,N as _e,ag as Ye,Q as be,S as Ce,T as qe,Z as Qe,M as Je,O as Xe,R as Ze,P as et,_ as tt}from"./input.js";import{au as st,ao as nt,av as H,o as V,B as oe,F as B,l as D,m as ie,aw as ke,ax as pe,ad as Ie,k as q,z as ot,H as W,n as Z,ay as Le,j as Ee,az as it,aA as Te,a0 as rt,a1 as at,a2 as lt,a3 as ct,a4 as dt,aB as Ae,aC as te,an as Ne,aD as ht,aE as ut,ae as ft,a6 as pt}from"./App-bqAziDgv.js";import{I as De,G as mt,C as gt}from"./chunk-JARCRF6W-fNDfXRta.js";import{app as z}from"/scripts/app.js";import{api as J}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-ajfTuIGC.js";var Fe=Y(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(ae,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",h),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});Fe.displayName="Wrap";var ae=Y(function(e,s){const{className:o,...r}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...r})});ae.displayName="WrapItem";function me(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Pe=Y(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=st({gridArea:o,gridColumn:me(r),gridRow:me(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx($.div,{ref:s,__css:f,...h})});Pe.displayName="GridItem";function xt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var yt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),vt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function wt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=xt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[jt,Mt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),St=Y((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=wt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Mt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),Oe=Y((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...y}=Ve(t),j=Ue("Progress",t),C=d??((s=j.track)==null?void 0:s.borderRadius),b={animation:`${vt} 1s linear infinite`},F={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${yt} 1s ease infinite normal none running`}},k={overflow:"hidden",position:"relative",...j.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:k,...y,children:n.jsxs(jt,{value:j,children:[n.jsx(St,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:F,borderRadius:C,title:p,role:x}),l]})})});Oe.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const _t=1/0;function bt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-_t?"-0":s}(t)}function P(t){return typeof t=="string"}function ze(t){return typeof t=="number"}function Ct(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kt=t=>`Missing ${t} property in key`,It=t=>`Property 'weight' in key '${t}' must be a positive integer`,ge=Object.prototype.hasOwnProperty;class Lt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Be(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Be(t){let e=null,s=null,o=null,r=1,i=null;if(P(t)||K(t))o=t,e=xe(t),s=ye(t);else{if(!ge.call(t,"name"))throw new Error(kt("name"));const a=t.name;if(o=a,ge.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(It(a));e=xe(a),s=ye(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function xe(t){return K(t)?t:t.split(".")}function ye(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(P(l)||ze(l)||Ct(l)))s.push(bt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,P(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();P(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(P(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else K(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[i]=c}else if(P(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function We(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const r=new le({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Be)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=M.distance,ignoreLocation:i=M.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function Tt(t,e,s,{location:o=M.location,distance:r=M.distance,threshold:i=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,includeMatches:l=M.includeMatches,ignoreLocation:d=M.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=i,p=u;const x=c>1||l,y=x?Array(f):[];let j;for(;(j=t.indexOf(e,p))>-1;){let k=Q(e,{currentLocation:j,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(k,g),p=j+h,x){let I=0;for(;I=O;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(y[S]=+!!_),v[w]=(v[w+1]<<1|1)&_,k&&(v[w]|=(C[w+1]|C[w])<<1|1|C[w+1]),v[w]&G&&(b=Q(e,{errors:k,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;O=Math.max(1,2*u-p)}}if(Q(e,{errors:k+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;C=v}const F={isMatch:p>=0,score:Math.max(.001,b)};if(x){const k=function(I=[],L=M.minMatchCharLength){let O=[],E=-1,v=-1,w=0;for(let S=I.length;w=L&&O.push([E,v]),E=-1)}return I[w-1]&&w-E>=L&&O.push([E,w-1]),O}(y,c);k.length?l&&(F.indices=k):F.isMatch=!1}return F}function At(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:At(u),startIndex:g})},f=this.pattern.length;if(f>R){let u=0;const g=f%R,p=f-g;for(;u{const{isMatch:j,score:C,indices:b}=Tt(e,p,x,{location:r+y,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});j&&(u=!0),f+=C,j&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const ve=[];function we(t,e){for(let s=0,o=ve.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function Ft(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Lt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof le))throw new Error("Incorrect 'index' type");this._myIndex=s||We(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const y=g?g.weight:null;u*=Math.pow(x===0&&y?Number.EPSILON:x,(y||1)*(h?1:p))}),f.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),ze(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Dt),u&&g.push(Ft),d.map(p=>{const{idx:x}=p,y={item:h[x],refIndex:x};return g.length&&g.forEach(j=>{j(p,y)}),y})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=we(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=we(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}U.version="7.0.0",U.createIndex=We,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new le({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},U.config=M;function Pt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(Fe,{children:s.map(r=>n.jsx(ae,{children:n.jsx(T,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Ot={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function zt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=m.useState(!t.file_hash),[i,a]=m.useState();m.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,u,g;const d=await H.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,y=await(await fetch(p)).json();let j;if(await((f=V)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)j=(g=(u=y==null?void 0:y.images)==null?void 0:u[0])==null?void 0:g.url;else if(!y.model.nsfw){const A=y.images.find(G=>G.nsfw==="None");j=A==null?void 0:A.url}j&&s(j);const b={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:y.model.name,civitModelID:String(y.modelId),civitModelVersionID:String(y.id),imageUrl:j??null};H.models.put(b),a(b)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Ot[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(B,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(De,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:(i==null?void 0:i.modelName)??t.model_name+t.model_extension})})]})}function Rt({list:t}){return n.jsx(mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Pe,{children:n.jsx(zt,{data:e})},e.model_name+e.date.getTime()))})}const Bt=async t=>{try{const s=await(await J.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function je(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function Me(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Wt(t,e=280,s){var o,r,i,a;if(t)return ke(t)?(i=Me((r=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:r.images,s))==null?void 0:i.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=Me(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Kt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=m.useState();m.useEffect(()=>{p();async function p(){var y;const x=await((y=V)==null?void 0:y.getSetting("showNsfwModelThumbnail"));r(Wt(t,ne,x))}},[t]);const i=ke(t)?t.modelVersions:t.versions,[a,c]=m.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=m.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(pe(l,t.name),t)},[a]),f=(g=pe(l))==null?void 0:g.sizeKB;return n.jsxs(Ie,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(De,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(B,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(ot,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:je(f),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:je(f)})})]})]})]})}function Gt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(B,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function $t({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=m.useState(""),[a,c]=m.useState([]),[l,d]=m.useState(""),h=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Le();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(He,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(_e,{children:n.jsxs(Ye,{children:[n.jsx(be,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Ce,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(qe,{children:[n.jsx(T,{ref:h,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function Vt(){const{colorMode:t}=Qe(),e=Ee(),[s,o]=m.useState([]);return m.useEffect(()=>{J.addEventListener("download_progress",r=>{o(r.detail)}),J.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:r,progress:i})=>n.jsxs(W,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(Oe,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>it(r),children:"Cancel"})]},r))})}const Ke="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function Ut(){return localStorage.getItem(Ke)}function Ht(t){localStorage.setItem(Ke,t)}function Yt(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:r}=Te(),i=()=>{Ht(t),o()};return n.jsxs(rt,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(at,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(lt,{p:5,children:[n.jsx(ct,{}),n.jsx(dt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function qt(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v5",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((c=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:c.at(0)).hits??[]}function Qt({onclose:t,searchQuery:e="",modelType:s}){const[o,r]=m.useState([]),[i,a]=m.useState(!1),[c,l]=m.useState(s),d=Ee(),[h,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:y}=Te(),[j,C,b]=Ae(),[A,G]=m.useState({}),[F,k]=m.useState(te),I=m.useCallback(async()=>{var _;a(!0);const v=await qt(u,c);r(v);const w=await Le();w&&G(w);const S=await((_=V)==null?void 0:_.getSetting("defaultFolders"));S&&k(S),a(!1)},[u,c]),L=(v,w)=>{var de,he,ue,fe;if(!((de=b.current)!=null&&de.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(he=b.current)==null?void 0:he.id}`,_=(ue=b.current)==null?void 0:ue.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&f(Ge=>[...Ge,_??""]);const ce=Ut();ce&&(S+=`?token=${ce}`),Bt({file_hash:(fe=b.current)==null?void 0:fe.SHA256,filename:_,save_path:v,url:S}),C(void 0),y()},O=async(v,w)=>{const S=F[w.type];C(v),S==null?x():L(S)},E=async(v,w)=>{var _;const S={...F,[v]:w};await((_=V)==null?void 0:_.upsert({defaultFolders:S})),k(S)};return m.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(Je,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(_e,{}),n.jsxs(Xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(be,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Gt,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(Yt,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(v=>n.jsx(T,{size:"sm",py:1,isActive:c===v,onClick:()=>{l(v)},children:v},v)),c&&A[te[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:F[c],onChange:v=>E(c,v.target.value),children:A[te[c]].map(v=>n.jsx("option",{value:v,children:v}))})]})]}),i&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(Ze,{}),n.jsxs(Ce,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(v=>n.jsx(Kt,{model:v,onClickInstallModel:O,installing:h},v.id))}),n.jsx(Vt,{})]})]})]}),n.jsx($t,{fileSelected:!!j,isOpen:p,onClose:y,selectFolder:(v,w)=>{L(v,b.current?void 0:w)}})]})}function Jt(){const[t,e]=m.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>e(!0),children:"Install Models"}),t&&n.jsx(Qt,{modelType:"Checkpoint",onclose:()=>e(!1)})]})}const Xt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{a(),J.addEventListener("model_list",l=>{c(l.detail)})},[]);const a=async()=>{const l=await ut();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Zt(){const[t,e,s]=Ae(!1),o=()=>{var c;(c=V)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{o()},[]);const r=c=>{var d;const l=c.target.checked;(d=V)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const c=await H.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,u=await(await fetch(h)).json();let g;if(s.current)g=(d=(l=u==null?void 0:u.images)==null?void 0:l[0])==null?void 0:d.url;else if(!u.model.nsfw){const p=u.images.find(x=>x.nsfw==="None");g=p==null?void 0:p.url}H.models.update(c.id,{imageUrl:g??null})}catch{}};return n.jsx(gt,{isChecked:t,onChange:r,children:"Show NSFW"})}function es(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),z.graph.add(i)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function ts({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,r]=m.useState(""),[i,a]=m.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=Xt(),[h,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const y=await H.models.toArray();f(d.map(j=>({...j,db:y.find(C=>C.id===j.model_name+"@"+j.model_type)})))}},[d]),m.useEffect(()=>{let x=[];o.length?x=new U(h,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=d.filter(y=>y.model_type===e).sort((y,j)=>i==="name"?y.model_name.localeCompare(j.model_name):j.date.getTime()-y.date.getTime()),g(x)},[e,d,o,i,h]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(et,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ie,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ft,overflowY:"auto",children:[n.jsxs(B,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{})]}),n.jsx(B,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(B,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:i,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Zt,{})]}),!o.length&&n.jsx(Pt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Rt,{list:u}),c&&n.jsx(B,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(es,{})]})})}const ss=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-g1lfodpY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function ns(){const{setRoute:t,route:e}=m.useContext(pt),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const i=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),c=LiteGraph.createNode(a);c.pos=[o.canvasX,o.canvasY],c.configure({widgets_values:[i]}),z.graph.add(c)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(ss,{})}),e==="modelList"&&n.jsx(ts,{onClose:()=>t("root")})]})}const ds=Object.freeze(Object.defineProperty({__proto__:null,default:ns},Symbol.toStringTag,{value:"Module"}));export{Pe as G,Jt as I,ds as M,qt as g}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-g1lfodpY.js","workspace_web/input.js","workspace_web/App-bqAziDgv.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js","workspace_web/chunk-JARCRF6W-fNDfXRta.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-ajfTuIGC.js"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js b/dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js deleted file mode 100644 index 9537555..0000000 --- a/dist/workspace_web/RecentFilesDrawer-4bh_pwSS.js +++ /dev/null @@ -1,8 +0,0 @@ -import{f as Oe,n as fn,o as pa,j as c,g as be,e as Ie,Y as ha,r as v,E as Ke,w as pn,M as qe,N as Xe,O as Ze,Q as Je,R as Qe,S as et,V as xt,h as ee,Z as yt,T as ma,$ as je,a0 as va,a1 as ga,a2 as ba,a3 as hn,a4 as Sa,a5 as P,a6 as E,a7 as xa,a8 as mn,X as F,k as ge,a9 as ya,I as Ct,aa as Rt}from"./input.js";import{b as Ca,a as wa,u as vn,c as Oa,d as Ia,e as Ma,S as ka,M as gn,f as Pa,g as ja,h as q,H as K,T as bn,I as Z,t as Se,i as Sn,j as wt,E as Tt,k as de,l as J,m as ne,n as tt,o as U,R as pe,p as Da,q as Nt,B as z,F as Ce,r as $t,s as Va,v as Ea,w as Me,x as Ve,y as te,z as Fa,D as xn,A as G,C as yn,G as La,J as Ot,K as Ra,L as Cn,N as Ta,O as fe,P as Na,Q as $a,U as za,V as It,W as Aa,X as _a,Y as Ha,Z as xe,_ as dt,$ as Ba,a0 as Wa,a1 as Ua,a2 as Ga,a3 as Ya,a4 as Ka,a5 as qa,a6 as Mt,a7 as wn,a8 as Xa,a9 as Za,aa as Ja,ab as Qa,ac as zt,ad as er,ae as tr,af as nr,ag as at,ah as ar}from"./App-bqAziDgv.js";import{C as Ee}from"./chunk-JARCRF6W-fNDfXRta.js";import{V as On}from"./chunk-NTCQBYKE-ZJqEVTS0.js";import{S as rr,N as ir,a as or,I as sr,M as lr,b as cr}from"./MediaPreview-cVvL6fHO.js";import{app as Re}from"/scripts/app.js";import{I as ur}from"./IconCopy-Vm3ws_0T.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var In=Oe(function(e,a){const{borderLeftWidth:r,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:s,borderWidth:o,borderStyle:l,borderColor:u,...d}=fn("Divider",e),{className:f,orientation:h="horizontal",__css:p,...m}=pa(e),b={vertical:{borderLeftWidth:r||s||o||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||o||"1px",width:"100%"}};return c.jsx(be.hr,{ref:a,"aria-orientation":h,...m,__css:{...d,border:"0",borderColor:u,borderStyle:l,...b[h],...p},className:Ie("chakra-divider",f)})});In.displayName="Divider";function dr(n,e={}){const{ssr:a=!0,fallback:r}=e,{getWindow:t}=ha(),i=Array.isArray(n)?n:[n];let s=Array.isArray(r)?r:[r];s=s.filter(u=>u!=null);const[o,l]=v.useState(()=>i.map((u,d)=>({media:u,matches:a?!!s[d]:t().matchMedia(u).matches})));return v.useEffect(()=>{const u=t();l(i.map(h=>({media:h,matches:u.matchMedia(h).matches})));const d=i.map(h=>u.matchMedia(h)),f=h=>{l(p=>p.slice().map(m=>m.media===h.media?{...m,matches:h.matches}:m))};return d.forEach(h=>{typeof h.addListener=="function"?h.addListener(f):h.addEventListener("change",f)}),()=>{d.forEach(h=>{typeof h.removeListener=="function"?h.removeListener(f):h.removeEventListener("change",f)})}},[t]),o.map(u=>u.matches)}function fr(n,e,a=Ca){let r=Object.keys(n).indexOf(e);if(r!==-1)return n[e];let t=a.indexOf(e);for(;t>=0;){const i=a[t];if(n.hasOwnProperty(i)){r=t;break}t-=1}if(r!==-1){const i=a[r];return n[i]}}function pr(n){var e,a;const r=pn(n)?n:{fallback:n??"base"},i=Ke().__breakpoints.details.map(({minMaxQuery:u,breakpoint:d})=>({breakpoint:d,query:u.replace("@media screen and ","")})),s=i.map(u=>u.breakpoint===r.fallback),l=dr(i.map(u=>u.query),{fallback:s,ssr:r.ssr}).findIndex(u=>u==!0);return(a=(e=i[l])==null?void 0:e.breakpoint)!=null?a:r.fallback}function hr(n,e){var a;const r=pn(e)?e:{fallback:e??"base"},t=pr(r),i=Ke();if(!t)return;const s=Array.from(((a=i.__breakpoints)==null?void 0:a.keys)||[]),o=Array.isArray(n)?Object.fromEntries(Object.entries(wa(n,s)).map(([l,u])=>[l,u])):n;return fr(o,t,s)}var Mn=Oe((n,e)=>{const{title:a,children:r,className:t,...i}=n,s=Ie("chakra-menu__group__title",t),o=vn();return c.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[a&&c.jsx(be.p,{className:s,...i,__css:o.groupTitle,children:a}),r]})});Mn.displayName="MenuGroup";var kn=n=>{const{className:e,title:a,...r}=n,t=Oa(r);return c.jsx(Mn,{title:a,className:Ie("chakra-menu__option-group",e),...t})};kn.displayName="MenuOptionGroup";var mr=Oe((n,e)=>{const a=vn();return c.jsx(be.button,{ref:e,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...a.button}})}),Fe=Oe((n,e)=>{const{children:a,as:r,...t}=n,i=Ia(t,e),s=r||mr;return c.jsx(s,{...i,className:Ie("chakra-menu__menu-button",n.className),children:c.jsx(be.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});Fe.displayName="MenuButton";var vr=n=>c.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:c.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),kt=Oe((n,e)=>{const{icon:a,iconSpacing:r="0.75rem",...t}=n,i=Ma(t,e);return c.jsxs(ka,{...i,className:Ie("chakra-menu__menuitem-option",t.className),children:[a!==null&&c.jsx(gn,{fontSize:"0.8em",marginEnd:r,opacity:n.isChecked?1:0,children:a||c.jsx(vr,{})}),c.jsx("span",{style:{flex:1},children:i.children})]})});kt.id="MenuItemOption";kt.displayName="MenuItemOption";var Pn=Oe(function(e,a){const{getHeaderProps:r}=Pa(),t=ja();return c.jsx(be.header,{...r(e,a),className:Ie("chakra-popover__header",e.className),__css:t.header})});Pn.displayName="PopoverHeader";var gr=q("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),br=q("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),Sr=q("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),At=q("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),xr=q("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),jn=q("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),yr=q("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Cr=q("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),wr=q("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Or=q("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Ir=q("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),Mr=q("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),kr=q("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Dn=q("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Pr=q("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function jr({onclose:n}){const[e,a]=v.useState([]),r=async()=>{var i;const t=await((i=Se)==null?void 0:i.listAll());a(t??[])};return v.useEffect(()=>{r()},[]),c.jsxs(qe,{isOpen:!0,onClose:n,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"My Tags"}),c.jsx(Qe,{}),c.jsx(et,{children:e.map(t=>c.jsxs(K,{children:[c.jsx(bn,{children:t.name}),c.jsx(Z,{onClick:async()=>{var i;await((i=Se)==null?void 0:i.delete(t.name)),r()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:c.jsx(Sn,{})})]}))})]})]})}function Dr(){const n=wt(),e=v.useRef([{title:"Save current workflow",key:Tt.SAVE},{title:"Save as current workflow",key:Tt.SAVE_AS}]),[a,r]=v.useState({save:"",saveAs:""}),[t,i]=v.useState(),s=async(l,u)=>{var f;l.preventDefault();let d="";if(l.ctrlKey&&(d+="Control+"),l.metaKey&&(d+="Command+"),l.shiftKey&&(d+="Shift+"),l.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt"].includes(l.key)){d+=l.key.toUpperCase();const h={...a};delete h[u],Object.values(h).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please - modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((f=U)==null?void 0:f.upsert({shortcuts:{...a,[u]:d}})),o())}},o=()=>{var l;(l=U)==null||l.getSetting("shortcuts").then(u=>{var f;const d=u??((f=U)==null?void 0:f.defaultSettings.shortcuts);r({...a,...d})})};return v.useEffect(()=>{o()},[]),c.jsxs(de,{children:[c.jsx(J,{children:"Keyboard Shortcut"}),e.current.map(l=>c.jsxs(K,{children:[c.jsx(J,{fontSize:"sm",w:170,children:l.title}),c.jsx(ne,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:t===l.key,children:c.jsx(tt,{value:a[l.key],onKeyDown:u=>{s(u,l.key)},onFocus:()=>{i(l.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},l.key))]})}function Vr(){const{setRefreshFolderStamp:n}=v.useContext(pe),[e,a]=v.useState(!1),r=()=>{var i;(i=U)==null||i.getSetting("foldersOnTop").then(s=>{a(!!s)})},t=i=>{var o;const s=i.target.checked;(o=U)==null||o.upsert({foldersOnTop:s}).then(()=>{r(),n(Date.now())})};return v.useEffect(()=>{r()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:e,onChange:t,children:"Folders always on top"})})}function Er(){const[n,e]=v.useState(!1),[a,r]=v.useState(""),{showDialog:t}=xt(),i=()=>{var o,l;(o=U)==null||o.getSetting("myWorkflowsDir").then(u=>{r(u??"undefined")}),(l=U)==null||l.getSetting("twoWaySync").then(u=>{e(u??!1)})};v.useEffect(()=>{i()},[]);const s=async o=>{var u,d;if(!o.target.checked){await((u=U)==null?void 0:u.upsert({twoWaySync:o.target.checked})),i();return}const l=await((d=U)==null?void 0:d.getSetting("myWorkflowsDir"));t(c.jsx(Da,{myWorkflowsDir:l??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var f;await((f=U)==null?void 0:f.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return c.jsxs(de,{children:[c.jsx(J,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),c.jsx(Ee,{isChecked:n,onChange:s,children:"Enable two way sync"})]})}function _t({settingKey:n,text:e,defaultChecked:a=!1}){const[r,t]=v.useState(a),i=()=>{var s;(s=U)==null||s.getSetting(n).then(o=>{t(!!o)})};return v.useEffect(()=>{i()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:r,onChange:async s=>{var o;await((o=U)==null?void 0:o.upsert({[n]:s.target.checked})),i()},children:e})})}function Fr(){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),[t,i]=v.useState([]),[s,o]=v.useState(""),[l,u]=v.useState([]),[d,f]=v.useState(!1),[h,p]=v.useState(!1),[m,b]=v.useState(!1),g=v.useRef(null),S=wt(),{showDialog:w}=xt(),y=m?"\\":"/";v.useEffect(()=>{var D;Nt().then(O=>{o(O.path??""),b(O.os==="win32")}),(D=U)==null||D.getSetting("twoWaySync").then(O=>{f(O??!1)})},[]);const x=async D=>{const{dir_path:O="",dir_contents:L=[],error:_=""}=await $t(D??"");return _.includes("Operation not permitted")?(p(!0),C(),{isError:!0}):{dirList:L,dirPath:O}},j=async()=>{const{isError:D=!1,dirList:O=[]}=await x(s);D||(i(O),r(!0),u(s&&s.split(y).filter(L=>!!L)||[]))},C=()=>{r(!1),e(!1),u([])},V=async(D,O=!1,L=!1)=>{var I,R;if(O){const{path:N}=await Nt();N&&await Va(N,D)}await((I=U)==null?void 0:I.upsert({myWorkflowsDir:D}));const _=await((R=U)==null?void 0:R.getSetting("myWorkflowsDir"))??"";o(_),L&&p(!1),C()},M=async D=>{if(D){const{error:L=""}=await $t(D);if(L.includes("Not a directory")){S({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const O=D??`${m?"":y}${l.join(y)}`;w("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{V(O,!0,!!D)}},{label:"No",onClick:()=>{V(O,!1,!!D)}}])},T=async()=>{const{dirPath:D,dirList:O}=await x("");u(D.split(y).filter(L=>!!L)),i(O)},A=async(D,O)=>{var R;let L="";D===-1&&O?L=`${m?"":y}${l.concat([O]).join(y)}`:L=`${m?"":y}${l.slice(0,D+1).join(y)}`;const{isError:_=!1,dirList:I=[]}=await x(L);_||(i(I),u(m?L.split(y):(R=L.slice(1))==null?void 0:R.split(y)))},W=c.jsxs(z,{textAlign:"end",mb:4,children:[c.jsx(tt,{placeholder:"Please enter the absolute path directory address",ref:g,mt:2,mb:2}),c.jsx(ee,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var D,O;(D=g==null?void 0:g.current)!=null&&D.value&&M((O=g==null?void 0:g.current)==null?void 0:O.value)},children:"Save"})]}),H=()=>{r(!0),e(!0)};return c.jsxs(c.Fragment,{children:[c.jsxs(z,{mb:4,children:[c.jsx(J,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),a?n?W:c.jsxs(On,{spacing:2,alignItems:"start",children:[c.jsx(de,{spacing:"2px",direction:"row",wrap:"wrap",children:l.map((D,O)=>c.jsxs("span",{children:[O>0&&y,c.jsx(ee,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{A(O)},children:D},`${D}-${O}`)]},D))}),c.jsx(rr,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:t.map((D,O)=>c.jsx(ee,{size:"sm",leftIcon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{A(-1,D)},children:D},`${D}-${O}`))}),c.jsxs(z,{w:"100%",textAlign:"end",children:[c.jsx(ee,{colorScheme:"teal",size:"sm",onClick:()=>{M()},children:"Save"}),c.jsx(ee,{size:"sm",onClick:T,mr:2,ml:2,children:"Reset"}),c.jsx(ee,{size:"sm",onClick:C,children:"Cancel"})]})]}):c.jsxs(Ce,{children:[c.jsx(bn,{overflowWrap:"anywhere",children:s}),c.jsx(ne,{label:d?"Choose folder":"Enable two way sync to link local folder",children:c.jsx(Z,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:j})}),c.jsx(ne,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:c.jsx(Z,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:c.jsx(Sr,{size:19}),onClick:H,variant:"ghost"})})]})]}),c.jsxs(qe,{isOpen:h,onClose:()=>p(!1),size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Kind tips"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(z,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?c.jsxs(J,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",c.jsx(ee,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos - -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):c.jsx(J,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),W]})})]})]})]})}function Lr(){const[n,e]=v.useState(200),a=i=>{if(!i.length){e(0);return}e(parseInt(i))},r=async()=>{var i;n<0&&e(0),await((i=U)==null?void 0:i.upsert({maximumChangelogNumber:Number(n)}))},t=()=>{var i;(i=U)==null||i.getSetting("maximumChangelogNumber").then(s=>{e(s)})};return v.useEffect(()=>{t()},[]),c.jsxs(de,{children:[c.jsx(J,{children:'Maximum number of save change history to store. This does not include versions that you created by "Create Version", which are always stored and has no limit.'}),c.jsx(ir,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:n,onChange:i=>a(i),onBlur:()=>{r()},onKeyUp:i=>{i.key==="Enter"&&r()},children:c.jsx(or,{})})]})}function Rr({onClose:n}){return c.jsx(c.Fragment,{children:c.jsxs(qe,{isOpen:!0,onClose:n,size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Settings"}),c.jsx(Qe,{}),c.jsx(et,{pb:14,children:c.jsx(K,{children:c.jsxs(On,{divider:c.jsx(Ea,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[c.jsx(Fr,{}),c.jsx(Dr,{}),c.jsx(_t,{settingKey:"autoSave",text:"Enable auto save workflow"}),c.jsx(Er,{}),c.jsx(Vr,{}),c.jsx(_t,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),c.jsx(Lr,{})]})})})]})]})})}const rt=16;function Tr({}){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),{colorMode:t,toggleColorMode:i}=yt();return c.jsxs(c.Fragment,{children:[c.jsxs(Me,{isLazy:!0,children:[c.jsx(Fe,{as:Z,"aria-label":"Options",icon:c.jsx(wr,{}),size:"sm",variant:"outline"}),c.jsxs(Ve,{children:[c.jsx(te,{onClick:()=>r(!0),icon:c.jsx(Mr,{size:16}),fontSize:16,children:"Settings"}),c.jsx(te,{onClick:()=>e(!0),icon:c.jsx(Dn,{size:rt}),fontSize:16,children:"Manage Tags"}),c.jsxs(te,{onClick:i,icon:t==="light"?c.jsx(Or,{size:rt}):c.jsx(kr,{size:rt}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),n&&c.jsx(jr,{onclose:()=>e(!1)}),a&&c.jsx(Rr,{onClose:()=>r(!1)})]})}function Nr(n){const{multipleState:e,changeMultipleState:a,selectedKeys:r,isSelectedAll:t,batchOperationCallback:i}=n,s=async()=>{var u;const l=await((u=G)==null?void 0:u.batchQuery(r))??[];La(l)},o=r.length===0;return c.jsx(K,{spacing:2,wrap:"wrap",mb:0,children:e?c.jsxs(c.Fragment,{children:[c.jsx(Ee,{isChecked:t,onChange:l=>{i("selectAll",l.target.checked)}}),c.jsx(ne,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:c.jsx(Z,{isDisabled:o,"aria-label":"Batch export",size:"sm",icon:c.jsx(Fa,{size:21}),onClick:s})}),c.jsx(ne,{hasArrow:!0,label:"Batch deletion",children:c.jsx(xn,{isDisabled:o,variant:"solid",promptMessage:`Are you sure you want to delete these ${r.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var l;await((l=G)==null?void 0:l.batchDeleteFlow(r)),i("batchDelete")}})}),r.length>0&&c.jsx(J,{fontWeight:600,children:`Selected ${r.length}`}),c.jsx(ne,{hasArrow:!0,label:"Exit multi-select",children:c.jsx(Z,{"aria-label":"Close multi-select operation",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{a(!1)}})})]}):c.jsx(ne,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:c.jsx(Z,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:c.jsx(yr,{size:21}),onClick:()=>{a(!0)}})})})}const $r=(n,e)=>{const[a,r]=v.useState(n);return v.useEffect(()=>{const t=setTimeout(()=>{r(n)},e);return()=>{clearTimeout(t)}},[n,e]),a},Ht=6;function zr({setSelectedTag:n,selectedTag:e}){const[a,r]=v.useState(!1),[t,i]=v.useState([]);return v.useEffect(()=>{var s;(s=Se)==null||s.listAll().then(o=>{i(o)})},[]),c.jsxs(K,{spacing:2,wrap:"wrap",mb:0,children:[e!=null&&c.jsx(Z,{"aria-label":"Close",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{n(void 0)}}),t.slice(0,a?void 0:Ht).map(s=>c.jsx(ee,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(s.name)},isActive:e===s.name,children:s.name},s.name)),(t.length??0)>Ht&&c.jsx(Z,{"aria-label":"Show-all-tags",size:"sm",icon:a?c.jsx(gr,{}):c.jsx(Ot,{}),onClick:()=>r(!a)})]})}function Vn({parentFolderID:n,onlyImportFile:e=!1}){const{onRefreshFilesList:a}=v.useContext(pe),[r,t]=v.useState("file"),i=v.useRef(null),s=d=>{var f;t(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(f=i.current)==null||f.click()},o=async d=>{var f;if(d.type==="image/png"){const h=await Ta(d),p=h==null?void 0:h.workflow;if(p)return{json:p,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(f=d.name)!=null&&f.endsWith(".json"))return await new Promise((h,p)=>{const m=new FileReader;m.onload=b=>{var g;try{const S=(g=b.target)==null?void 0:g.result;typeof S=="string"?h({json:S,name:d.name.replace(".json","")}):p(new Error("File content is not a string"))}catch(S){p(S)}},m.onerror=p,m.readAsText(d)});return null},l=async d=>{var h,p;const f=[d];for(;f.length>0;){const m=f.shift();if(m&&!m.isFile){const b=await((h=fe)==null?void 0:h.create({name:m.name,parentFolderID:m.parentFolderID}));if(m.children&&m.children.length){const g=[];m.children.forEach(S=>{S.isFile&&S.file?g.push(S.file):(S.parentFolderID=b==null?void 0:b.id,f.push(S))}),g.length&&await((p=G)==null?void 0:p.batchCreateFlows(g,void 0,b==null?void 0:b.id))}}}a==null||a()},u=async d=>{var h;const f=d.target.files;if(f)if(r==="folder"){const p={name:f[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const m of f)if(m.name!==".DS_Store"){const b=m.webkitRelativePath.split("/");let g=p.children??[];for(let S=1;Sx.name===w);if(!y){if(y={name:w,isFile:S===b.length-1,children:S===b.length-1?void 0:[]},y.isFile){const x=await o(m);x&&(y.file=x)}g.push(y)}y&&!y.isFile&&(g=y.children)}}l(p)}else{const p=[];for(const m of f){const b=await o(m);b&&p.push(b)}p.length&&(await((h=G)==null?void 0:h.batchCreateFlows(p,void 0,n)),a&&a())}};return c.jsxs(c.Fragment,{children:[e?c.jsx(te,{onClick:d=>{d.stopPropagation(),s("file")},icon:c.jsx(At,{size:19}),children:"Import workflows"}):c.jsxs(Me,{closeOnSelect:!0,children:[c.jsx(Fe,{as:ee,leftIcon:c.jsx(At,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),c.jsx(Ve,{children:Ra.map((d,f)=>c.jsx(te,{onClick:()=>{s(d.type)},iconSpacing:2,icon:d.type==="folder"?c.jsx(Cn,{size:18}):c.jsx(xr,{size:18}),children:d.title},f))})]}),c.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:u,onClick:d=>{d.stopPropagation()}})]})}function Ar({folder:n,onclose:e}){const[a,r]=v.useState(n.name),[t,i]=v.useState(""),{onRefreshFilesList:s}=v.useContext(pe),o=u=>{r(u.target.value),t&&i("")},l=async()=>{var f,h;const u=a.trim();if(r(u),u===n.name)return e();await((f=fe)==null?void 0:f.generateUniqueName(u,n.parentFolderID??""))!==u?i("The name is duplicated, please modify it and submit again."):(await((h=fe)==null?void 0:h.update(n.id,{name:u})),s&&s(),e())};return c.jsxs(qe,{isOpen:!0,onClose:e,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Edit folder name"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(Na,{isInvalid:!!t,children:[c.jsx($a,{children:"Folder name"}),c.jsx(tt,{value:a,onChange:o,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!t&&a&&l()}}),t&&c.jsx(za,{children:t})]})}),c.jsxs(ma,{children:[c.jsx(ee,{colorScheme:"teal",mr:3,onClick:l,isDisabled:!a||!!t,children:"Save"}),c.jsx(ee,{onClick:e,children:"Cancel"})]})]})]})}function _r({menuPosition:n,isopen:e,folder:a,onClose:r}){const[t,i]=v.useState(!1),{onRefreshFilesList:s}=v.useContext(pe),{showDialog:o}=xt(),l=async h=>{var p;h.stopPropagation(),await((p=fe)==null?void 0:p.create({name:"New Folder",parentFolderID:a.id})),s&&s()},u=async h=>{var p;h.stopPropagation(),await((p=G)==null?void 0:p.createFlow({json:JSON.stringify(Aa),parentFolderID:a.id})),s&&s()},d=async h=>{h.stopPropagation();const p=await _a(a.id);o(`Do you want to delete the ${p} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{f(Ha.DELETE)}}])},f=async h=>{var p;await((p=fe)==null?void 0:p.deleteFolder(a.id,h)),r(),s&&s()};return c.jsxs(c.Fragment,{children:[c.jsx(z,{position:"absolute",top:n.y,left:n.x,children:c.jsx(Me,{isOpen:e,onClose:r,isLazy:!0,lazyBehavior:"keepMounted",children:c.jsxs(Ve,{children:[c.jsx(te,{icon:c.jsx(Ir,{size:19}),onClick:h=>{h.preventDefault(),h.stopPropagation(),i(!0)},children:"Rename"}),c.jsx(te,{icon:c.jsx(Sn,{size:19}),onClick:d,children:"Delete"}),c.jsx(te,{onClick:l,icon:c.jsx(jn,{size:19}),children:"New folder"}),c.jsx(te,{onClick:u,icon:c.jsx(It,{size:19}),children:"New file"}),c.jsx(Vn,{parentFolderID:a.id,onlyImportFile:!0})]})})}),t&&c.jsx(Ar,{folder:a,onclose:()=>i(!1)})]})}const Bt=v.memo(function({folder:e}){const[a,r]=v.useState(!1),[t,i]=v.useState(e.isCollapse??!0),[s,o]=v.useState([]),[l,u]=v.useState({x:0,y:0}),[d,f]=v.useState(!1),{colorMode:h}=yt(),{draggingFile:p,setDraggingFile:m,refreshFolderStamp:b,onRefreshFilesList:g}=v.useContext(pe),S=h==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};v.useEffect(()=>{var x;t||(x=G)==null||x.listFolderContent(e.id,window.localStorage.getItem(dt)).then(j=>{o(j)})},[e.id,b,t]);const w=x=>{x.preventDefault(),u({x:x.clientX,y:x.clientY}),f(!0)},y=async x=>{var j,C;if(x.preventDefault(),x.stopPropagation(),!p)return r(!1);if(xe(p)){if(p.id===e.id)return r(!1);await((j=fe)==null?void 0:j.update(p.id,{parentFolderID:e.id}))}else xe(p)||await((C=G)==null?void 0:C.updateFolder(p.id,{parentFolderID:e.id}));await(g==null?void 0:g()),r(!1)};return v.useEffect(()=>{var x;!!e.isCollapse!==t&&((x=fe)==null||x.update(e.id,{isCollapse:t}))},[t]),v.useEffect(()=>{var M;const x=(M=G)==null?void 0:M.curWorkflow,j=(x==null?void 0:x.parentFolderID)+"/",C=e.id+"/";j.startsWith(C)&&i(!1)},[]),c.jsxs(de,{children:[c.jsxs(K,{w:"100%",as:"button",py:1,onClick:()=>{i(!t)},onContextMenu:w,draggable:"true",onDragOver:x=>{x.preventDefault(),x.stopPropagation(),r(!0)},onDragLeave:x=>{x.preventDefault(),x.stopPropagation(),r(!1)},onDragStart:()=>m==null?void 0:m(e),onDrop:y,_hover:S,style:a||d?S:void 0,className:"droppable",children:[c.jsxs(K,{gap:1,children:[t?c.jsx(sr,{size:20}):c.jsx(Ot,{size:20}),c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),c.jsx(J,{children:e.name})]}),c.jsx(_r,{isopen:d,menuPosition:l,onClose:()=>f(!1),folder:e}),!t&&c.jsx(de,{ml:4,gap:0,children:c.jsx(ca,{items:s})})]})});function Wt(n,e){var a=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),a.push.apply(a,r)}return a}function k(n){for(var e=1;en.length)&&(e=n.length);for(var a=0,r=new Array(e);a=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(a[r]=n[r])}return a}var Ur=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function Gr(n){var e=n.defaultInputValue,a=e===void 0?"":e,r=n.defaultMenuIsOpen,t=r===void 0?!1:r,i=n.defaultValue,s=i===void 0?null:i,o=n.inputValue,l=n.menuIsOpen,u=n.onChange,d=n.onInputChange,f=n.onMenuClose,h=n.onMenuOpen,p=n.value,m=he(n,Ur),b=v.useState(o!==void 0?o:a),g=ue(b,2),S=g[0],w=g[1],y=v.useState(l!==void 0?l:t),x=ue(y,2),j=x[0],C=x[1],V=v.useState(p!==void 0?p:s),M=ue(V,2),T=M[0],A=M[1],W=v.useCallback(function(R,N){typeof u=="function"&&u(R,N),A(R)},[u]),H=v.useCallback(function(R,N){var $;typeof d=="function"&&($=d(R,N)),w($!==void 0?$:R)},[d]),D=v.useCallback(function(){typeof h=="function"&&h(),C(!0)},[h]),O=v.useCallback(function(){typeof f=="function"&&f(),C(!1)},[f]),L=o!==void 0?o:S,_=l!==void 0?l:j,I=p!==void 0?p:T;return k(k({},m),{},{inputValue:L,menuIsOpen:_,onChange:W,onInputChange:H,onMenuClose:O,onMenuOpen:D,value:I})}function Yr(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ut(n,e){for(var a=0;a"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Zr(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Jr(n,e){if(e&&(hn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zr(n)}function Qr(n){var e=Xr();return function(){var r=Ae(n),t;if(e){var i=Ae(this).constructor;t=Reflect.construct(r,arguments,i)}else t=r.apply(this,arguments);return Jr(this,t)}}function ei(n){if(Array.isArray(n))return ft(n)}function ti(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ni(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fn(n){return ei(n)||ti(n)||En(n)||ni()}function ai(n,e){return e||(e=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(e)}}))}const ri=Math.min,ii=Math.max,_e=Math.round,Te=Math.floor,He=n=>({x:n,y:n});function oi(n){return{...n,top:n.y,left:n.x,right:n.x+n.width,bottom:n.y+n.height}}function Ln(n){return Tn(n)?(n.nodeName||"").toLowerCase():"#document"}function ie(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Rn(n){var e;return(e=(Tn(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Tn(n){return n instanceof Node||n instanceof ie(n).Node}function pt(n){return n instanceof Element||n instanceof ie(n).Element}function Pt(n){return n instanceof HTMLElement||n instanceof ie(n).HTMLElement}function Gt(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof ie(n).ShadowRoot}function Nn(n){const{overflow:e,overflowX:a,overflowY:r,display:t}=jt(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+a)&&!["inline","contents"].includes(t)}function si(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function li(n){return["html","body","#document"].includes(Ln(n))}function jt(n){return ie(n).getComputedStyle(n)}function ci(n){if(Ln(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Gt(n)&&n.host||Rn(n);return Gt(e)?e.host:e}function $n(n){const e=ci(n);return li(e)?n.ownerDocument?n.ownerDocument.body:n.body:Pt(e)&&Nn(e)?e:$n(e)}function Be(n,e,a){var r;e===void 0&&(e=[]),a===void 0&&(a=!0);const t=$n(n),i=t===((r=n.ownerDocument)==null?void 0:r.body),s=ie(t);return i?e.concat(s,s.visualViewport||[],Nn(t)?t:[],s.frameElement&&a?Be(s.frameElement):[]):e.concat(t,Be(t,[],a))}function ui(n){const e=jt(n);let a=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const t=Pt(n),i=t?n.offsetWidth:a,s=t?n.offsetHeight:r,o=_e(a)!==i||_e(r)!==s;return o&&(a=i,r=s),{width:a,height:r,$:o}}function Dt(n){return pt(n)?n:n.contextElement}function it(n){const e=Dt(n);if(!Pt(e))return He(1);const a=e.getBoundingClientRect(),{width:r,height:t,$:i}=ui(e);let s=(i?_e(a.width):a.width)/r,o=(i?_e(a.height):a.height)/t;return(!s||!Number.isFinite(s))&&(s=1),(!o||!Number.isFinite(o))&&(o=1),{x:s,y:o}}const di=He(0);function fi(n){const e=ie(n);return!si()||!e.visualViewport?di:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function pi(n,e,a){return e===void 0&&(e=!1),!a||e&&a!==ie(n)?!1:e}function Yt(n,e,a,r){e===void 0&&(e=!1),a===void 0&&(a=!1);const t=n.getBoundingClientRect(),i=Dt(n);let s=He(1);e&&(r?pt(r)&&(s=it(r)):s=it(n));const o=pi(i,a,r)?fi(i):He(0);let l=(t.left+o.x)/s.x,u=(t.top+o.y)/s.y,d=t.width/s.x,f=t.height/s.y;if(i){const h=ie(i),p=r&&pt(r)?ie(r):r;let m=h.frameElement;for(;m&&r&&p!==h;){const b=it(m),g=m.getBoundingClientRect(),S=jt(m),w=g.left+(m.clientLeft+parseFloat(S.paddingLeft))*b.x,y=g.top+(m.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,u*=b.y,d*=b.x,f*=b.y,l+=w,u+=y,m=ie(m).frameElement}}return oi({width:d,height:f,x:l,y:u})}function hi(n,e){let a=null,r;const t=Rn(n);function i(){clearTimeout(r),a&&a.disconnect(),a=null}function s(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),i();const{left:u,top:d,width:f,height:h}=n.getBoundingClientRect();if(o||e(),!f||!h)return;const p=Te(d),m=Te(t.clientWidth-(u+f)),b=Te(t.clientHeight-(d+h)),g=Te(u),w={rootMargin:-p+"px "+-m+"px "+-b+"px "+-g+"px",threshold:ii(0,ri(1,l))||1};let y=!0;function x(j){const C=j[0].intersectionRatio;if(C!==l){if(!y)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},100)}y=!1}try{a=new IntersectionObserver(x,{...w,root:t.ownerDocument})}catch{a=new IntersectionObserver(x,w)}a.observe(n)}return s(!0),i}function mi(n,e,a,r){r===void 0&&(r={});const{ancestorScroll:t=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Dt(n),d=t||i?[...u?Be(u):[],...Be(e)]:[];d.forEach(S=>{t&&S.addEventListener("scroll",a,{passive:!0}),i&&S.addEventListener("resize",a)});const f=u&&o?hi(u,a):null;let h=-1,p=null;s&&(p=new ResizeObserver(S=>{let[w]=S;w&&w.target===u&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{p&&p.observe(e)})),a()}),u&&!l&&p.observe(u),p.observe(e));let m,b=l?Yt(n):null;l&&g();function g(){const S=Yt(n);b&&(S.x!==b.x||S.y!==b.y||S.width!==b.width||S.height!==b.height)&&a(),b=S,m=requestAnimationFrame(g)}return a(),()=>{d.forEach(S=>{t&&S.removeEventListener("scroll",a),i&&S.removeEventListener("resize",a)}),f&&f(),p&&p.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var ht=v.useLayoutEffect,vi=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],We=function(){};function gi(n,e){return e?e[0]==="-"?n+e:n+"__"+e:n}function bi(n,e){for(var a=arguments.length,r=new Array(a>2?a-2:0),t=2;t-1}function Si(n){return nt(n)?window.innerHeight:n.clientHeight}function An(n){return nt(n)?window.pageYOffset:n.scrollTop}function Ue(n,e){if(nt(n)){window.scrollTo(0,e);return}n.scrollTop=e}function xi(n){var e=getComputedStyle(n),a=e.position==="absolute",r=/(auto|scroll)/;if(e.position==="fixed")return document.documentElement;for(var t=n;t=t.parentElement;)if(e=getComputedStyle(t),!(a&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return t;return document.documentElement}function yi(n,e,a,r){return a*((n=n/r-1)*n*n+1)+e}function Ne(n,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:We,t=An(n),i=e-t,s=10,o=0;function l(){o+=s;var u=yi(o,t,i,a);Ue(n,u),oa.bottom?Ue(n,Math.min(e.offsetTop+e.clientHeight-n.offsetHeight+t,n.scrollHeight)):r.top-t1?a-1:0),t=1;t=m)return{placement:"bottom",maxHeight:e};if(T>=m&&!s)return i&&Ne(l,A,H),{placement:"bottom",maxHeight:e};if(!s&&T>=r||s&&V>=r){i&&Ne(l,A,H);var D=s?V-x:T-x;return{placement:"bottom",maxHeight:D}}if(t==="auto"||s){var O=e,L=s?C:M;return L>=r&&(O=Math.min(L-x-o,e)),{placement:"top",maxHeight:O}}if(t==="bottom")return i&&Ue(l,A),{placement:"bottom",maxHeight:e};break;case"top":if(C>=m)return{placement:"top",maxHeight:e};if(M>=m&&!s)return i&&Ne(l,W,H),{placement:"top",maxHeight:e};if(!s&&M>=r||s&&C>=r){var _=e;return(!s&&M>=r||s&&C>=r)&&(_=s?C-j:M-j),i&&Ne(l,W,H),{placement:"top",maxHeight:_}}return{placement:"bottom",maxHeight:e};default:throw new Error('Invalid placement provided "'.concat(t,'".'))}return u}function Ei(n){var e={bottom:"top",top:"bottom"};return n?e[n]:"bottom"}var Hn=function(e){return e==="auto"?"bottom":e},Fi=function(e,a){var r,t=e.placement,i=e.theme,s=i.borderRadius,o=i.spacing,l=i.colors;return k((r={label:"menu"},je(r,Ei(t),"100%"),je(r,"position","absolute"),je(r,"width","100%"),je(r,"zIndex",1),r),a?{}:{backgroundColor:l.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:o.menuGutter,marginTop:o.menuGutter})},Bn=v.createContext(null),Li=function(e){var a=e.children,r=e.minMenuHeight,t=e.maxMenuHeight,i=e.menuPlacement,s=e.menuPosition,o=e.menuShouldScrollIntoView,l=e.theme,u=v.useContext(Bn)||{},d=u.setPortalPlacement,f=v.useRef(null),h=v.useState(t),p=ue(h,2),m=p[0],b=p[1],g=v.useState(null),S=ue(g,2),w=S[0],y=S[1],x=l.spacing.controlHeight;return ht(function(){var j=f.current;if(j){var C=s==="fixed",V=o&&!C,M=Vi({maxHeight:t,menuEl:j,minHeight:r,placement:i,shouldScroll:V,isFixedPosition:C,controlHeight:x});b(M.maxHeight),y(M.placement),d==null||d(M.placement)}},[t,i,s,o,r,d,x]),a({ref:f,placerProps:k(k({},e),{},{placement:w||Hn(i),maxHeight:m})})},Ri=function(e){var a=e.children,r=e.innerRef,t=e.innerProps;return P("div",E({},B(e,"menu",{menu:!0}),{ref:r},t),a)},Ti=Ri,Ni=function(e,a){var r=e.maxHeight,t=e.theme.spacing.baseUnit;return k({maxHeight:r,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a?{}:{paddingBottom:t,paddingTop:t})},$i=function(e){var a=e.children,r=e.innerProps,t=e.innerRef,i=e.isMulti;return P("div",E({},B(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:t},r),a)},Wn=function(e,a){var r=e.theme,t=r.spacing.baseUnit,i=r.colors;return k({textAlign:"center"},a?{}:{color:i.neutral40,padding:"".concat(t*2,"px ").concat(t*3,"px")})},zi=Wn,Ai=Wn,_i=function(e){var a=e.children,r=a===void 0?"No options":a,t=e.innerProps,i=he(e,ji);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),t),r)},Hi=function(e){var a=e.children,r=a===void 0?"Loading...":a,t=e.innerProps,i=he(e,Di);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),t),r)},Bi=function(e){var a=e.rect,r=e.offset,t=e.position;return{left:a.left,position:t,top:r,width:a.width,zIndex:1}},Wi=function(e){var a=e.appendTo,r=e.children,t=e.controlElement,i=e.innerProps,s=e.menuPlacement,o=e.menuPosition,l=v.useRef(null),u=v.useRef(null),d=v.useState(Hn(s)),f=ue(d,2),h=f[0],p=f[1],m=v.useMemo(function(){return{setPortalPlacement:p}},[]),b=v.useState(null),g=ue(b,2),S=g[0],w=g[1],y=v.useCallback(function(){if(t){var V=Ci(t),M=o==="fixed"?0:window.pageYOffset,T=V[h]+M;(T!==(S==null?void 0:S.offset)||V.left!==(S==null?void 0:S.rect.left)||V.width!==(S==null?void 0:S.rect.width))&&w({offset:T,rect:V})}},[t,o,h,S==null?void 0:S.offset,S==null?void 0:S.rect.left,S==null?void 0:S.rect.width]);ht(function(){y()},[y]);var x=v.useCallback(function(){typeof u.current=="function"&&(u.current(),u.current=null),t&&l.current&&(u.current=mi(t,l.current,y,{elementResize:"ResizeObserver"in window}))},[t,y]);ht(function(){x()},[x]);var j=v.useCallback(function(V){l.current=V,x()},[x]);if(!a&&o!=="fixed"||!S)return null;var C=P("div",E({ref:j},B(k(k({},e),{},{offset:S.offset,position:o,rect:S.rect}),"menuPortal",{"menu-portal":!0}),i),r);return P(Bn.Provider,{value:m},a?xa.createPortal(C,a):C)},Ui=function(e){var a=e.isDisabled,r=e.isRtl;return{label:"container",direction:r?"rtl":void 0,pointerEvents:a?"none":void 0,position:"relative"}},Gi=function(e){var a=e.children,r=e.innerProps,t=e.isDisabled,i=e.isRtl;return P("div",E({},B(e,"container",{"--is-disabled":t,"--is-rtl":i}),r),a)},Yi=function(e,a){var r=e.theme.spacing,t=e.isMulti,i=e.hasValue,s=e.selectProps.controlShouldRenderValue;return k({alignItems:"center",display:t&&i&&s?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},a?{}:{padding:"".concat(r.baseUnit/2,"px ").concat(r.baseUnit*2,"px")})},Ki=function(e){var a=e.children,r=e.innerProps,t=e.isMulti,i=e.hasValue;return P("div",E({},B(e,"valueContainer",{"value-container":!0,"value-container--is-multi":t,"value-container--has-value":i}),r),a)},qi=function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},Xi=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"indicatorsContainer",{indicators:!0}),r),a)},Zt,Zi=["size"],Ji=["innerProps","isRtl","size"],Qi={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},Un=function(e){var a=e.size,r=he(e,Zi);return P("svg",E({height:a,width:a,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:Qi},r))},Vt=function(e){return P(Un,E({size:20},e),P("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},Gn=function(e){return P(Un,E({size:20},e),P("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},Yn=function(e,a){var r=e.isFocused,t=e.theme,i=t.spacing.baseUnit,s=t.colors;return k({label:"indicatorContainer",display:"flex",transition:"color 150ms"},a?{}:{color:r?s.neutral60:s.neutral20,padding:i*2,":hover":{color:r?s.neutral80:s.neutral40}})},eo=Yn,to=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),r),a||P(Gn,null))},no=Yn,ao=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),r),a||P(Vt,null))},ro=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing.baseUnit,s=t.colors;return k({label:"indicatorSeparator",alignSelf:"stretch",width:1},a?{}:{backgroundColor:r?s.neutral10:s.neutral20,marginBottom:i*2,marginTop:i*2})},io=function(e){var a=e.innerProps;return P("span",E({},a,B(e,"indicatorSeparator",{"indicator-separator":!0})))},oo=Sa(Zt||(Zt=ai([` - 0%, 80%, 100% { opacity: 0; } - 40% { opacity: 1; } -`]))),so=function(e,a){var r=e.isFocused,t=e.size,i=e.theme,s=i.colors,o=i.spacing.baseUnit;return k({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:t,lineHeight:1,marginRight:t,textAlign:"center",verticalAlign:"middle"},a?{}:{color:r?s.neutral60:s.neutral20,padding:o*2})},ot=function(e){var a=e.delay,r=e.offset;return P("span",{css:mn({animation:"".concat(oo," 1s ease-in-out ").concat(a,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:r?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},lo=function(e){var a=e.innerProps,r=e.isRtl,t=e.size,i=t===void 0?4:t,s=he(e,Ji);return P("div",E({},B(k(k({},s),{},{innerProps:a,isRtl:r,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),a),P(ot,{delay:0,offset:r}),P(ot,{delay:160,offset:!0}),P(ot,{delay:320,offset:!r}))},co=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.theme,s=i.colors,o=i.borderRadius,l=i.spacing;return k({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:l.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},a?{}:{backgroundColor:r?s.neutral5:s.neutral0,borderColor:r?s.neutral10:t?s.primary:s.neutral20,borderRadius:o,borderStyle:"solid",borderWidth:1,boxShadow:t?"0 0 0 1px ".concat(s.primary):void 0,"&:hover":{borderColor:t?s.primary:s.neutral30}})},uo=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.innerRef,s=e.innerProps,o=e.menuIsOpen;return P("div",E({ref:i},B(e,"control",{control:!0,"control--is-disabled":r,"control--is-focused":t,"control--menu-is-open":o}),s,{"aria-disabled":r||void 0}),a)},fo=uo,po=["data"],ho=function(e,a){var r=e.theme.spacing;return a?{}:{paddingBottom:r.baseUnit*2,paddingTop:r.baseUnit*2}},mo=function(e){var a=e.children,r=e.cx,t=e.getStyles,i=e.getClassNames,s=e.Heading,o=e.headingProps,l=e.innerProps,u=e.label,d=e.theme,f=e.selectProps;return P("div",E({},B(e,"group",{group:!0}),l),P(s,E({},o,{selectProps:f,theme:d,getStyles:t,getClassNames:i,cx:r}),u),P("div",null,a))},vo=function(e,a){var r=e.theme,t=r.colors,i=r.spacing;return k({label:"group",cursor:"default",display:"block"},a?{}:{color:t.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:i.baseUnit*3,paddingRight:i.baseUnit*3,textTransform:"uppercase"})},go=function(e){var a=zn(e);a.data;var r=he(a,po);return P("div",E({},B(e,"groupHeading",{"group-heading":!0}),r))},bo=mo,So=["innerRef","isDisabled","isHidden","inputClassName"],xo=function(e,a){var r=e.isDisabled,t=e.value,i=e.theme,s=i.spacing,o=i.colors;return k(k({visibility:r?"hidden":"visible",transform:t?"translateZ(0)":""},yo),a?{}:{margin:s.baseUnit/2,paddingBottom:s.baseUnit/2,paddingTop:s.baseUnit/2,color:o.neutral80})},Kn={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},yo={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":k({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Kn)},Co=function(e){return k({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Kn)},wo=function(e){var a=e.cx,r=e.value,t=zn(e),i=t.innerRef,s=t.isDisabled,o=t.isHidden,l=t.inputClassName,u=he(t,So);return P("div",E({},B(e,"input",{"input-container":!0}),{"data-value":r||""}),P("input",E({className:a({input:!0},l),ref:i,style:Co(o),disabled:s},u)))},Oo=wo,Io=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,s=r.colors;return k({label:"multiValue",display:"flex",minWidth:0},a?{}:{backgroundColor:s.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Mo=function(e,a){var r=e.theme,t=r.borderRadius,i=r.colors,s=e.cropWithEllipsis;return k({overflow:"hidden",textOverflow:s||s===void 0?"ellipsis":void 0,whiteSpace:"nowrap"},a?{}:{borderRadius:t/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},ko=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,s=r.colors,o=e.isFocused;return k({alignItems:"center",display:"flex"},a?{}:{borderRadius:i/2,backgroundColor:o?s.dangerLight:void 0,paddingLeft:t.baseUnit,paddingRight:t.baseUnit,":hover":{backgroundColor:s.dangerLight,color:s.danger}})},qn=function(e){var a=e.children,r=e.innerProps;return P("div",r,a)},Po=qn,jo=qn;function Do(n){var e=n.children,a=n.innerProps;return P("div",E({role:"button"},a),e||P(Vt,{size:14}))}var Vo=function(e){var a=e.children,r=e.components,t=e.data,i=e.innerProps,s=e.isDisabled,o=e.removeProps,l=e.selectProps,u=r.Container,d=r.Label,f=r.Remove;return P(u,{data:t,innerProps:k(k({},B(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":s})),i),selectProps:l},P(d,{data:t,innerProps:k({},B(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},a),P(f,{data:t,innerProps:k(k({},B(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(a||"option")},o),selectProps:l}))},Eo=Vo,Fo=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.isSelected,s=e.theme,o=s.spacing,l=s.colors;return k({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},a?{}:{backgroundColor:i?l.primary:t?l.primary25:"transparent",color:r?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(o.baseUnit*2,"px ").concat(o.baseUnit*3,"px"),":active":{backgroundColor:r?void 0:i?l.primary:l.primary50}})},Lo=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.isSelected,s=e.innerRef,o=e.innerProps;return P("div",E({},B(e,"option",{option:!0,"option--is-disabled":r,"option--is-focused":t,"option--is-selected":i}),{ref:s,"aria-disabled":r},o),a)},Ro=Lo,To=function(e,a){var r=e.theme,t=r.spacing,i=r.colors;return k({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},a?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},No=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"placeholder",{placeholder:!0}),r),a)},$o=No,zo=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing,s=t.colors;return k({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},a?{}:{color:r?s.neutral40:s.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},Ao=function(e){var a=e.children,r=e.isDisabled,t=e.innerProps;return P("div",E({},B(e,"singleValue",{"single-value":!0,"single-value--is-disabled":r}),t),a)},_o=Ao,Ho={ClearIndicator:ao,Control:fo,DropdownIndicator:to,DownChevron:Gn,CrossIcon:Vt,Group:bo,GroupHeading:go,IndicatorsContainer:Xi,IndicatorSeparator:io,Input:Oo,LoadingIndicator:lo,Menu:Ti,MenuList:$i,MenuPortal:Wi,LoadingMessage:Hi,NoOptionsMessage:_i,MultiValue:Eo,MultiValueContainer:Po,MultiValueLabel:jo,MultiValueRemove:Do,Option:Ro,Placeholder:$o,SelectContainer:Gi,SingleValue:_o,ValueContainer:Ki},Bo=function(e){return k(k({},Ho),e.components)},Jt=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function Wo(n,e){return!!(n===e||Jt(n)&&Jt(e))}function Uo(n,e){if(n.length!==e.length)return!1;for(var a=0;a1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return s?"option ".concat(t," is disabled. Select another option."):"option ".concat(t,", selected.");default:return""}},onFocus:function(e){var a=e.context,r=e.focused,t=e.options,i=e.label,s=i===void 0?"":i,o=e.selectValue,l=e.isDisabled,u=e.isSelected,d=function(m,b){return m&&m.length?"".concat(m.indexOf(b)+1," of ").concat(m.length):""};if(a==="value"&&o)return"value ".concat(s," focused, ").concat(d(o,r),".");if(a==="menu"){var f=l?" disabled":"",h="".concat(u?"selected":"focused").concat(f);return"option ".concat(s," ").concat(h,", ").concat(d(t,r),".")}return""},onFilter:function(e){var a=e.inputValue,r=e.resultsMessage;return"".concat(r).concat(a?" for search term "+a:"",".")}},Xo=function(e){var a=e.ariaSelection,r=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,s=e.isFocused,o=e.selectValue,l=e.selectProps,u=e.id,d=l.ariaLiveMessages,f=l.getOptionLabel,h=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,b=l.isSearchable,g=l.menuIsOpen,S=l.options,w=l.screenReaderStatus,y=l.tabSelectsValue,x=l["aria-label"],j=l["aria-live"],C=v.useMemo(function(){return k(k({},qo),d||{})},[d]),V=v.useMemo(function(){var O="";if(a&&C.onChange){var L=a.option,_=a.options,I=a.removedValue,R=a.removedValues,N=a.value,$=function(ce){return Array.isArray(ce)?null:ce},se=I||L||$(N),Y=se?f(se):"",X=_||R||void 0,me=X?X.map(f):[],ve=k({isDisabled:se&&m(se,o),label:Y,labels:me},a);O=C.onChange(ve)}return O},[a,C,m,o,f]),M=v.useMemo(function(){var O="",L=r||t,_=!!(r&&o&&o.includes(r));if(L&&C.onFocus){var I={focused:L,label:f(L),isDisabled:m(L,o),isSelected:_,options:i,context:L===r?"menu":"value",selectValue:o};O=C.onFocus(I)}return O},[r,t,f,m,C,i,o]),T=v.useMemo(function(){var O="";if(g&&S.length&&C.onFilter){var L=w({count:i.length});O=C.onFilter({inputValue:h,resultsMessage:L})}return O},[i,h,g,C,S,w]),A=v.useMemo(function(){var O="";if(C.guidance){var L=t?"value":g?"menu":"input";O=C.guidance({"aria-label":x,context:L,isDisabled:r&&m(r,o),isMulti:p,isSearchable:b,tabSelectsValue:y})}return O},[x,r,t,p,m,b,g,C,o,y]),W="".concat(M," ").concat(T," ").concat(A),H=P(v.Fragment,null,P("span",{id:"aria-selection"},V),P("span",{id:"aria-context"},W)),D=(a==null?void 0:a.action)==="initial-input-focus";return P(v.Fragment,null,P(Qt,{id:u},D&&H),P(Qt,{"aria-live":j,"aria-atomic":"false","aria-relevant":"additions text"},s&&!D&&H))},Zo=Xo,mt=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],Jo=new RegExp("["+mt.map(function(n){return n.letters}).join("")+"]","g"),Xn={};for(var st=0;st-1}},ns=["innerRef"];function as(n){var e=n.innerRef,a=he(n,ns),r=Pi(a,"onExited","in","enter","exit","appear");return P("input",E({ref:e},r,{css:mn({label:"dummyInput",background:0,border:0,caretColor:"transparent",fontSize:"inherit",gridArea:"1 / 1 / 2 / 3",outline:0,padding:0,width:1,color:"transparent",left:-100,opacity:0,position:"relative",transform:"scale(.01)"},"","")}))}var rs=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function is(n){var e=n.isEnabled,a=n.onBottomArrive,r=n.onBottomLeave,t=n.onTopArrive,i=n.onTopLeave,s=v.useRef(!1),o=v.useRef(!1),l=v.useRef(0),u=v.useRef(null),d=v.useCallback(function(g,S){if(u.current!==null){var w=u.current,y=w.scrollTop,x=w.scrollHeight,j=w.clientHeight,C=u.current,V=S>0,M=x-j-y,T=!1;M>S&&s.current&&(r&&r(g),s.current=!1),V&&o.current&&(i&&i(g),o.current=!1),V&&S>M?(a&&!s.current&&a(g),C.scrollTop=x,T=!0,s.current=!0):!V&&-S>y&&(t&&!o.current&&t(g),C.scrollTop=0,T=!0,o.current=!0),T&&rs(g)}},[a,r,t,i]),f=v.useCallback(function(g){d(g,g.deltaY)},[d]),h=v.useCallback(function(g){l.current=g.changedTouches[0].clientY},[]),p=v.useCallback(function(g){var S=l.current-g.changedTouches[0].clientY;d(g,S)},[d]),m=v.useCallback(function(g){if(g){var S=Ii?{passive:!1}:!1;g.addEventListener("wheel",f,S),g.addEventListener("touchstart",h,S),g.addEventListener("touchmove",p,S)}},[p,h,f]),b=v.useCallback(function(g){g&&(g.removeEventListener("wheel",f,!1),g.removeEventListener("touchstart",h,!1),g.removeEventListener("touchmove",p,!1))},[p,h,f]);return v.useEffect(function(){if(e){var g=u.current;return m(g),function(){b(g)}}},[e,m,b]),function(g){u.current=g}}var tn=["boxSizing","height","overflow","paddingRight","position"],nn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function an(n){n.preventDefault()}function rn(n){n.stopPropagation()}function on(){var n=this.scrollTop,e=this.scrollHeight,a=n+this.offsetHeight;n===0?this.scrollTop=1:a===e&&(this.scrollTop=n-1)}function sn(){return"ontouchstart"in window||navigator.maxTouchPoints}var ln=!!(typeof window<"u"&&window.document&&window.document.createElement),Pe=0,ye={capture:!1,passive:!1};function os(n){var e=n.isEnabled,a=n.accountForScrollbars,r=a===void 0?!0:a,t=v.useRef({}),i=v.useRef(null),s=v.useCallback(function(l){if(ln){var u=document.body,d=u&&u.style;if(r&&tn.forEach(function(m){var b=d&&d[m];t.current[m]=b}),r&&Pe<1){var f=parseInt(t.current.paddingRight,10)||0,h=document.body?document.body.clientWidth:0,p=window.innerWidth-h+f||0;Object.keys(nn).forEach(function(m){var b=nn[m];d&&(d[m]=b)}),d&&(d.paddingRight="".concat(p,"px"))}u&&sn()&&(u.addEventListener("touchmove",an,ye),l&&(l.addEventListener("touchstart",on,ye),l.addEventListener("touchmove",rn,ye))),Pe+=1}},[r]),o=v.useCallback(function(l){if(ln){var u=document.body,d=u&&u.style;Pe=Math.max(Pe-1,0),r&&Pe<1&&tn.forEach(function(f){var h=t.current[f];d&&(d[f]=h)}),u&&sn()&&(u.removeEventListener("touchmove",an,ye),l&&(l.removeEventListener("touchstart",on,ye),l.removeEventListener("touchmove",rn,ye)))}},[r]);return v.useEffect(function(){if(e){var l=i.current;return s(l),function(){o(l)}}},[e,s,o]),function(l){i.current=l}}var ss=function(e){var a=e.target;return a.ownerDocument.activeElement&&a.ownerDocument.activeElement.blur()},ls={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function cs(n){var e=n.children,a=n.lockEnabled,r=n.captureEnabled,t=r===void 0?!0:r,i=n.onBottomArrive,s=n.onBottomLeave,o=n.onTopArrive,l=n.onTopLeave,u=is({isEnabled:t,onBottomArrive:i,onBottomLeave:s,onTopArrive:o,onTopLeave:l}),d=os({isEnabled:a}),f=function(p){u(p),d(p)};return P(v.Fragment,null,a&&P("div",{onClick:ss,css:ls}),e(f))}var us={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},ds=function(e){var a=e.name,r=e.onFocus;return P("input",{required:!0,name:a,tabIndex:-1,"aria-hidden":"true",onFocus:r,css:us,value:"",onChange:function(){}})},fs=ds,ps=function(e){return e.label},hs=function(e){return e.label},ms=function(e){return e.value},vs=function(e){return!!e.isDisabled},gs={clearIndicator:no,container:Ui,control:co,dropdownIndicator:eo,group:ho,groupHeading:vo,indicatorsContainer:qi,indicatorSeparator:ro,input:xo,loadingIndicator:so,loadingMessage:Ai,menu:Fi,menuList:Ni,menuPortal:Bi,multiValue:Io,multiValueLabel:Mo,multiValueRemove:ko,noOptionsMessage:zi,option:Fo,placeholder:To,singleValue:zo,valueContainer:Yi},bs={primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},Ss=4,Jn=4,xs=38,ys=Jn*2,Cs={baseUnit:Jn,controlHeight:xs,menuGutter:ys},ut={borderRadius:Ss,colors:bs,spacing:Cs},ws={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:Xt(),captureMenuScroll:!Xt(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:ts(),formatGroupLabel:ps,getOptionLabel:hs,getOptionValue:ms,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:vs,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!wi(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var a=e.count;return"".concat(a," result").concat(a!==1?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function cn(n,e,a,r){var t=na(n,e,a),i=aa(n,e,a),s=ta(n,e),o=Ge(n,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:s,value:o,index:r}}function Qn(n,e){return n.options.map(function(a,r){if("options"in a){var t=a.options.map(function(s,o){return cn(n,s,e,o)}).filter(function(s){return un(n,s)});return t.length>0?{type:"group",data:a,options:t,index:r}:void 0}var i=cn(n,a,e,r);return un(n,i)?i:void 0}).filter(Mi)}function ea(n){return n.reduce(function(e,a){return a.type==="group"?e.push.apply(e,Fn(a.options.map(function(r){return r.data}))):e.push(a.data),e},[])}function Os(n,e){return ea(Qn(n,e))}function un(n,e){var a=n.inputValue,r=a===void 0?"":a,t=e.data,i=e.isSelected,s=e.label,o=e.value;return(!ia(n)||!i)&&ra(n,{label:s,value:o,data:t},r)}function Is(n,e){var a=n.focusedValue,r=n.selectValue,t=r.indexOf(a);if(t>-1){var i=e.indexOf(a);if(i>-1)return a;if(t-1?a:e[0]}var ta=function(e,a){return e.getOptionLabel(a)},Ge=function(e,a){return e.getOptionValue(a)};function na(n,e,a){return typeof n.isOptionDisabled=="function"?n.isOptionDisabled(e,a):!1}function aa(n,e,a){if(a.indexOf(e)>-1)return!0;if(typeof n.isOptionSelected=="function")return n.isOptionSelected(e,a);var r=Ge(n,e);return a.some(function(t){return Ge(n,t)===r})}function ra(n,e,a){return n.filterOption?n.filterOption(e,a):!0}var ia=function(e){var a=e.hideSelectedOptions,r=e.isMulti;return a===void 0?r:a},ks=1,oa=function(n){qr(a,n);var e=Qr(a);function a(r){var t;if(Yr(this,a),t=e.call(this,r),t.state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(o){t.controlRef=o},t.focusedOptionRef=null,t.getFocusedOptionRef=function(o){t.focusedOptionRef=o},t.menuListRef=null,t.getMenuListRef=function(o){t.menuListRef=o},t.inputRef=null,t.getInputRef=function(o){t.inputRef=o},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(o,l){var u=t.props,d=u.onChange,f=u.name;l.name=f,t.ariaOnChange(o,l),d(o,l)},t.setValue=function(o,l,u){var d=t.props,f=d.closeMenuOnSelect,h=d.isMulti,p=d.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:p}),f&&(t.setState({inputIsHiddenAfterUpdate:!h}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(o,{action:l,option:u})},t.selectOption=function(o){var l=t.props,u=l.blurInputOnSelect,d=l.isMulti,f=l.name,h=t.state.selectValue,p=d&&t.isOptionSelected(o,h),m=t.isOptionDisabled(o,h);if(p){var b=t.getOptionValue(o);t.setValue(h.filter(function(g){return t.getOptionValue(g)!==b}),"deselect-option",o)}else if(!m)d?t.setValue([].concat(Fn(h),[o]),"select-option",o):t.setValue(o,"select-option");else{t.ariaOnChange(o,{action:"select-option",option:o,name:f});return}u&&t.blurInput()},t.removeValue=function(o){var l=t.props.isMulti,u=t.state.selectValue,d=t.getOptionValue(o),f=u.filter(function(p){return t.getOptionValue(p)!==d}),h=ze(l,f,f[0]||null);t.onChange(h,{action:"remove-value",removedValue:o}),t.focusInput()},t.clearValue=function(){var o=t.state.selectValue;t.onChange(ze(t.props.isMulti,[],null),{action:"clear",removedValues:o})},t.popValue=function(){var o=t.props.isMulti,l=t.state.selectValue,u=l[l.length-1],d=l.slice(0,l.length-1),f=ze(o,d,d[0]||null);t.onChange(f,{action:"pop-value",removedValue:u})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var o=arguments.length,l=new Array(o),u=0;uh||f>h}},t.onTouchEnd=function(o){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(o.target)&&t.menuListRef&&!t.menuListRef.contains(o.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(o){t.userIsDragging||t.onControlMouseDown(o)},t.onClearIndicatorTouchEnd=function(o){t.userIsDragging||t.onClearIndicatorMouseDown(o)},t.onDropdownIndicatorTouchEnd=function(o){t.userIsDragging||t.onDropdownIndicatorMouseDown(o)},t.handleInputChange=function(o){var l=t.props.inputValue,u=o.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(u,{action:"input-change",prevInputValue:l}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(o){t.props.onFocus&&t.props.onFocus(o),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(o){var l=t.props.inputValue;if(t.menuListRef&&t.menuListRef.contains(document.activeElement)){t.inputRef.focus();return}t.props.onBlur&&t.props.onBlur(o),t.onInputChange("",{action:"input-blur",prevInputValue:l}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1})},t.onOptionHover=function(o){t.blockOptionHover||t.state.focusedOption===o||t.setState({focusedOption:o})},t.shouldHideSelectedOptions=function(){return ia(t.props)},t.onValueInputFocus=function(o){o.preventDefault(),o.stopPropagation(),t.focus()},t.onKeyDown=function(o){var l=t.props,u=l.isMulti,d=l.backspaceRemovesValue,f=l.escapeClearsValue,h=l.inputValue,p=l.isClearable,m=l.isDisabled,b=l.menuIsOpen,g=l.onKeyDown,S=l.tabSelectsValue,w=l.openMenuOnFocus,y=t.state,x=y.focusedOption,j=y.focusedValue,C=y.selectValue;if(!m&&!(typeof g=="function"&&(g(o),o.defaultPrevented))){switch(t.blockOptionHover=!0,o.key){case"ArrowLeft":if(!u||h)return;t.focusValue("previous");break;case"ArrowRight":if(!u||h)return;t.focusValue("next");break;case"Delete":case"Backspace":if(h)return;if(j)t.removeValue(j);else{if(!d)return;u?t.popValue():p&&t.clearValue()}break;case"Tab":if(t.isComposing||o.shiftKey||!b||!S||!x||w&&t.isOptionSelected(x,C))return;t.selectOption(x);break;case"Enter":if(o.keyCode===229)break;if(b){if(!x||t.isComposing)return;t.selectOption(x);break}return;case"Escape":b?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:h}),t.onMenuClose()):p&&f&&t.clearValue();break;case" ":if(h)return;if(!b){t.openMenu("first");break}if(!x)return;t.selectOption(x);break;case"ArrowUp":b?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":b?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!b)return;t.focusOption("pageup");break;case"PageDown":if(!b)return;t.focusOption("pagedown");break;case"Home":if(!b)return;t.focusOption("first");break;case"End":if(!b)return;t.focusOption("last");break;default:return}o.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++ks),t.state.selectValue=Kt(r.value),r.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),s=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[s]}return t}return Kr(a,[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&qt(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,s=i.isDisabled,o=i.menuIsOpen,l=this.state.isFocused;(l&&!s&&t.isDisabled||l&&o&&!t.menuIsOpen)&&this.focusInput(),l&&s&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!l&&!s&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(qt(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(t,i){this.props.onInputChange(t,i)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(t){var i=this,s=this.state,o=s.selectValue,l=s.isFocused,u=this.buildFocusableOptions(),d=t==="first"?0:u.length-1;if(!this.props.isMulti){var f=u.indexOf(o[0]);f>-1&&(d=f)}this.scrollToFocusedOptionOnUpdate=!(l&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:u[d]},function(){return i.onMenuOpen()})}},{key:"focusValue",value:function(t){var i=this.state,s=i.selectValue,o=i.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var l=s.indexOf(o);o||(l=-1);var u=s.length-1,d=-1;if(s.length){switch(t){case"previous":l===0?d=0:l===-1?d=u:d=l-1;break;case"next":l>-1&&l0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,s=this.state.focusedOption,o=this.getFocusableOptions();if(o.length){var l=0,u=o.indexOf(s);s||(u=-1),t==="up"?l=u>0?u-1:o.length-1:t==="down"?l=(u+1)%o.length:t==="pageup"?(l=u-i,l<0&&(l=0)):t==="pagedown"?(l=u+i,l>o.length-1&&(l=o.length-1)):t==="last"&&(l=o.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:o[l],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme(ut):k(k({},ut),this.props.theme):ut}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,s=this.getStyles,o=this.getClassNames,l=this.getValue,u=this.selectOption,d=this.setValue,f=this.props,h=f.isMulti,p=f.isRtl,m=f.options,b=this.hasValue();return{clearValue:t,cx:i,getStyles:s,getClassNames:o,getValue:l,hasValue:b,isMulti:h,isRtl:p,options:m,selectOption:u,selectProps:f,setValue:d,theme:this.getTheme()}}},{key:"hasValue",value:function(){var t=this.state.selectValue;return t.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var t=this.props,i=t.isClearable,s=t.isMulti;return i===void 0?s:i}},{key:"isOptionDisabled",value:function(t,i){return na(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return aa(this.props,t,i)}},{key:"filterOption",value:function(t,i){return ra(this.props,t,i)}},{key:"formatOptionLabel",value:function(t,i){if(typeof this.props.formatOptionLabel=="function"){var s=this.props.inputValue,o=this.state.selectValue;return this.props.formatOptionLabel(t,{context:i,inputValue:s,selectValue:o})}else return this.getOptionLabel(t)}},{key:"formatGroupLabel",value:function(t){return this.props.formatGroupLabel(t)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var t=this.props,i=t.isDisabled,s=t.isSearchable,o=t.inputId,l=t.inputValue,u=t.tabIndex,d=t.form,f=t.menuIsOpen,h=t.required,p=this.getComponents(),m=p.Input,b=this.state,g=b.inputIsHidden,S=b.ariaSelection,w=this.commonProps,y=o||this.getElementId("input"),x=k(k(k({"aria-autocomplete":"list","aria-expanded":f,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":h,role:"combobox"},f&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!s&&{"aria-readonly":!0}),this.hasValue()?(S==null?void 0:S.action)==="initial-input-focus"&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return s?v.createElement(m,E({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:y,innerRef:this.getInputRef,isDisabled:i,isHidden:g,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:u,form:d,type:"text",value:l},x)):v.createElement(as,E({id:y,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:We,onFocus:this.onInputFocus,disabled:i,tabIndex:u,inputMode:"none",form:d,value:""},x))}},{key:"renderPlaceholderOrValue",value:function(){var t=this,i=this.getComponents(),s=i.MultiValue,o=i.MultiValueContainer,l=i.MultiValueLabel,u=i.MultiValueRemove,d=i.SingleValue,f=i.Placeholder,h=this.commonProps,p=this.props,m=p.controlShouldRenderValue,b=p.isDisabled,g=p.isMulti,S=p.inputValue,w=p.placeholder,y=this.state,x=y.selectValue,j=y.focusedValue,C=y.isFocused;if(!this.hasValue()||!m)return S?null:v.createElement(f,E({},h,{key:"placeholder",isDisabled:b,isFocused:C,innerProps:{id:this.getElementId("placeholder")}}),w);if(g)return x.map(function(M,T){var A=M===j,W="".concat(t.getOptionLabel(M),"-").concat(t.getOptionValue(M));return v.createElement(s,E({},h,{components:{Container:o,Label:l,Remove:u},isFocused:A,isDisabled:b,key:W,index:T,removeProps:{onClick:function(){return t.removeValue(M)},onTouchEnd:function(){return t.removeValue(M)},onMouseDown:function(D){D.preventDefault()}},data:M}),t.formatOptionLabel(M,"value"))});if(S)return null;var V=x[0];return v.createElement(d,E({},h,{data:V,isDisabled:b}),this.formatOptionLabel(V,"value"))}},{key:"renderClearIndicator",value:function(){var t=this.getComponents(),i=t.ClearIndicator,s=this.commonProps,o=this.props,l=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!this.isClearable()||!i||l||!this.hasValue()||u)return null;var f={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:f,isFocused:d}))}},{key:"renderLoadingIndicator",value:function(){var t=this.getComponents(),i=t.LoadingIndicator,s=this.commonProps,o=this.props,l=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!i||!u)return null;var f={"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:f,isDisabled:l,isFocused:d}))}},{key:"renderIndicatorSeparator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator,s=t.IndicatorSeparator;if(!i||!s)return null;var o=this.commonProps,l=this.props.isDisabled,u=this.state.isFocused;return v.createElement(s,E({},o,{isDisabled:l,isFocused:u}))}},{key:"renderDropdownIndicator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator;if(!i)return null;var s=this.commonProps,o=this.props.isDisabled,l=this.state.isFocused,u={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:u,isDisabled:o,isFocused:l}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),s=i.Group,o=i.GroupHeading,l=i.Menu,u=i.MenuList,d=i.MenuPortal,f=i.LoadingMessage,h=i.NoOptionsMessage,p=i.Option,m=this.commonProps,b=this.state.focusedOption,g=this.props,S=g.captureMenuScroll,w=g.inputValue,y=g.isLoading,x=g.loadingMessage,j=g.minMenuHeight,C=g.maxMenuHeight,V=g.menuIsOpen,M=g.menuPlacement,T=g.menuPosition,A=g.menuPortalTarget,W=g.menuShouldBlockScroll,H=g.menuShouldScrollIntoView,D=g.noOptionsMessage,O=g.onMenuScrollToTop,L=g.onMenuScrollToBottom;if(!V)return null;var _=function(X,me){var ve=X.type,le=X.data,ce=X.isDisabled,ke=X.isSelected,Le=X.label,ua=X.value,Et=b===le,Ft=ce?void 0:function(){return t.onOptionHover(le)},da=ce?void 0:function(){return t.selectOption(le)},Lt="".concat(t.getElementId("option"),"-").concat(me),fa={id:Lt,onClick:da,onMouseMove:Ft,onMouseOver:Ft,tabIndex:-1};return v.createElement(p,E({},m,{innerProps:fa,data:le,isDisabled:ce,isSelected:ke,key:Lt,label:Le,type:ve,value:ua,isFocused:Et,innerRef:Et?t.getFocusedOptionRef:void 0}),t.formatOptionLabel(X.data,"menu"))},I;if(this.hasOptions())I=this.getCategorizedOptions().map(function(Y){if(Y.type==="group"){var X=Y.data,me=Y.options,ve=Y.index,le="".concat(t.getElementId("group"),"-").concat(ve),ce="".concat(le,"-heading");return v.createElement(s,E({},m,{key:le,data:X,options:me,Heading:o,headingProps:{id:ce,data:Y.data},label:t.formatGroupLabel(Y.data)}),Y.options.map(function(ke){return _(ke,"".concat(ve,"-").concat(ke.index))}))}else if(Y.type==="option")return _(Y,"".concat(Y.index))});else if(y){var R=x({inputValue:w});if(R===null)return null;I=v.createElement(f,m,R)}else{var N=D({inputValue:w});if(N===null)return null;I=v.createElement(h,m,N)}var $={minMenuHeight:j,maxMenuHeight:C,menuPlacement:M,menuPosition:T,menuShouldScrollIntoView:H},se=v.createElement(Li,E({},m,$),function(Y){var X=Y.ref,me=Y.placerProps,ve=me.placement,le=me.maxHeight;return v.createElement(l,E({},m,$,{innerRef:X,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:y,placement:ve}),v.createElement(cs,{captureEnabled:S,onTopArrive:O,onBottomArrive:L,lockEnabled:W},function(ce){return v.createElement(u,E({},m,{innerRef:function(Le){t.getMenuListRef(Le),ce(Le)},isLoading:y,maxHeight:le,focusedOption:b}),I)}))});return A||T==="fixed"?v.createElement(d,E({},m,{appendTo:A,controlElement:this.controlRef,menuPlacement:M,menuPosition:T}),se):se}},{key:"renderFormField",value:function(){var t=this,i=this.props,s=i.delimiter,o=i.isDisabled,l=i.isMulti,u=i.name,d=i.required,f=this.state.selectValue;if(d&&!this.hasValue()&&!o)return v.createElement(fs,{name:u,onFocus:this.onValueInputFocus});if(!(!u||o))if(l)if(s){var h=f.map(function(b){return t.getOptionValue(b)}).join(s);return v.createElement("input",{name:u,type:"hidden",value:h})}else{var p=f.length>0?f.map(function(b,g){return v.createElement("input",{key:"i-".concat(g),name:u,type:"hidden",value:t.getOptionValue(b)})}):v.createElement("input",{name:u,type:"hidden",value:""});return v.createElement("div",null,p)}else{var m=f[0]?this.getOptionValue(f[0]):"";return v.createElement("input",{name:u,type:"hidden",value:m})}}},{key:"renderLiveRegion",value:function(){var t=this.commonProps,i=this.state,s=i.ariaSelection,o=i.focusedOption,l=i.focusedValue,u=i.isFocused,d=i.selectValue,f=this.getFocusableOptions();return v.createElement(Zo,E({},t,{id:this.getElementId("live-region"),ariaSelection:s,focusedOption:o,focusedValue:l,isFocused:u,selectValue:d,focusableOptions:f}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,s=t.IndicatorsContainer,o=t.SelectContainer,l=t.ValueContainer,u=this.props,d=u.className,f=u.id,h=u.isDisabled,p=u.menuIsOpen,m=this.state.isFocused,b=this.commonProps=this.getCommonProps();return v.createElement(o,E({},b,{className:d,innerProps:{id:f,onKeyDown:this.onKeyDown},isDisabled:h,isFocused:m}),this.renderLiveRegion(),v.createElement(i,E({},b,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:h,isFocused:m,menuIsOpen:p}),v.createElement(l,E({},b,{isDisabled:h}),this.renderPlaceholderOrValue(),this.renderInput()),v.createElement(s,E({},b,{isDisabled:h}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}],[{key:"getDerivedStateFromProps",value:function(t,i){var s=i.prevProps,o=i.clearFocusValueOnUpdate,l=i.inputIsHiddenAfterUpdate,u=i.ariaSelection,d=i.isFocused,f=i.prevWasFocused,h=t.options,p=t.value,m=t.menuIsOpen,b=t.inputValue,g=t.isMulti,S=Kt(p),w={};if(s&&(p!==s.value||h!==s.options||m!==s.menuIsOpen||b!==s.inputValue)){var y=m?Os(t,S):[],x=o?Is(i,S):null,j=Ms(i,y);w={selectValue:S,focusedOption:j,focusedValue:x,clearFocusValueOnUpdate:!1}}var C=l!=null&&t!==s?{inputIsHidden:l,inputIsHiddenAfterUpdate:void 0}:{},V=u,M=d&&f;return d&&!M&&(V={value:ze(g,S,S[0]||null),options:S,action:"initial-input-focus"},M=!f),(u==null?void 0:u.action)==="initial-input-focus"&&(V=null),k(k(k({},w),C),{},{prevProps:t,ariaSelection:V,prevWasFocused:M})}}]),a}(v.Component);oa.defaultProps=ws;var Ps=v.forwardRef(function(n,e){var a=Gr(n);return v.createElement(oa,E({ref:e},a))}),js=Ps,Ds=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function vt(){return vt=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var sa=function(e){e.className,e.clearValue,e.cx,e.getStyles,e.getClassNames,e.getValue,e.hasValue,e.isMulti,e.isRtl,e.options,e.selectOption,e.selectProps,e.setValue,e.theme;var a=Vs(e,Ds);return vt({},a)},Es=function(e){var a=typeof e=="string";return a&&["sm","md","lg"].includes(e)},Fs=function(e){return Es(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},oe=function(e){var a=Ke(),r=Fs(a.components.Input.defaultProps.size),t=e??r,i=hr(typeof t=="string"?[t]:t,{fallback:"md"})||r;return i};function we(){return we=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var zs=function(e){var a=e.className,r=e.cx,t=e.children,i=e.innerRef,s=e.innerProps,o=e.isDisabled,l=e.isFocused,u=e.menuIsOpen,d=e.selectProps,f=d.chakraStyles,h=d.size,p=d.variant,m=d.focusBorderColor,b=d.errorBorderColor,g=d.isInvalid,S=d.isReadOnly,w=oe(h),y=ge("Input",{size:w,variant:p,focusBorderColor:m,errorBorderColor:b}),x=y.field,j=x.height,C=x.h,V=$s(x,Ns),M=j||C,T=ae({},V,{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",padding:0,overflow:"hidden",height:"auto",minH:M},o?{pointerEvents:"none"}:{}),A=f!=null&&f.control?f.control(T,e):T;return F.createElement(z,ae({ref:i,className:r({control:!0,"control--is-disabled":o,"control--is-focused":l,"control--menu-is-open":u},a),sx:A},s,{"data-focus":l?!0:void 0,"data-focus-visible":l?!0:void 0,"data-invalid":g?!0:void 0,"data-disabled":o?!0:void 0,"data-readonly":S?!0:void 0}),t)},As=function(e){var a=e.className,r=e.cx,t=e.selectProps,i=t.chakraStyles,s=t.useBasicStyles,o=t.variant,l=ae({opacity:1},s||o!=="outline"?{display:"none"}:{}),u=i!=null&&i.indicatorSeparator?i.indicatorSeparator(l,e):l;return F.createElement(In,{className:r({"indicator-separator":!0},a),sx:u,orientation:"vertical"})},_s=function(e){return F.createElement(Ct,ae({role:"presentation",focusable:"false","aria-hidden":"true"},e),F.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},Hs=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,s=e.selectProps,o=s.chakraStyles,l=s.useBasicStyles,u=s.size,d=s.focusBorderColor,f=s.errorBorderColor,h=s.variant,p=oe(u),m=ge("Input",{size:p,variant:h,focusBorderColor:d,errorBorderColor:f}),b={sm:"16px",md:"20px",lg:"24px"},g=b[p],S=ae({},m.addon,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",borderRadius:0,borderWidth:0,fontSize:g},l&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=o!=null&&o.dropdownIndicator?o.dropdownIndicator(S,e):S,y={height:"1em",width:"1em"},x=o!=null&&o.downChevron?o.downChevron(y,e):y;return F.createElement(z,ae({},i,{className:t({indicator:!0,"dropdown-indicator":!0},r),sx:w}),a||F.createElement(_s,{sx:x}))},Bs=function(e){return F.createElement(Ct,ae({focusable:"false","aria-hidden":!0},e),F.createElement("path",{fill:"currentColor",d:"M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z"}))},Ws=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,s=e.selectProps,o=s.chakraStyles,l=s.size,u=oe(l),d=fn("CloseButton",{size:u}),f=ae({},d,{marginX:1,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer"}),h=o!=null&&o.clearIndicator?o.clearIndicator(f,e):f,p={width:"1em",height:"1em"},m=o!=null&&o.crossIcon?o.crossIcon(p,e):p;return F.createElement(z,ae({role:"button",className:t({indicator:!0,"clear-indicator":!0},r),sx:h,"aria-label":"Clear selected options"},i),a||F.createElement(Bs,{sx:m}))},Us=function(e){var a=e.className,r=e.cx,t=e.innerProps,i=e.selectProps,s=i.chakraStyles,o=i.size,l=e.color,u=e.emptyColor,d=e.speed,f=e.thickness,h=e.spinnerSize,p=oe(o),m={sm:"xs",md:"sm",lg:"md"},b=m[p],g={marginRight:3},S=s!=null&&s.loadingIndicator?s.loadingIndicator(g,e):g;return F.createElement(ya,ae({className:r({indicator:!0,"loading-indicator":!0},a),sx:S},t,{size:h||b,color:l,emptyColor:u,speed:d,thickness:f}))};const Gs=zs;var Ys=["innerRef","isDisabled","isHidden","inputClassName"];function De(){return De=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var qs=function(e){var a=e.className,r=e.cx,t=e.value,i=e.selectProps,s=i.chakraStyles,o=i.isReadOnly,l=sa(e),u=l.innerRef,d=l.isDisabled,f=l.isHidden,h=l.inputClassName,p=Ks(l,Ys),m={gridArea:"1 / 2",minW:"2px",border:0,margin:0,outline:0,padding:0},b={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content",color:"inherit",marginX:"0.125rem",paddingY:"0.125rem",visibility:d?"hidden":"visible",transform:t?"translateZ(0)":"",_after:De({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre",padding:0},m)},g=s!=null&&s.inputContainer?s.inputContainer(b,e):b,S=De({background:0,opacity:f?0:1,width:"100%"},m),w=s!=null&&s.input?s.input(S,e):S;return F.createElement(z,{className:r({"input-container":!0},a),"data-value":t||"",sx:g},F.createElement(be.input,De({className:r({input:!0},h),ref:u,sx:w,disabled:d,readOnly:o?!0:void 0},p)))};const Xs=qs;var Zs=["data"];function Js(n,e){if(n==null)return{};var a={},r=Object.keys(n),t,i;for(i=0;i=0)&&(a[t]=n[t]);return a}function Q(){return Q=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var Il=function(e){var a,r=e.components,t=r===void 0?{}:r;e.theme;var i=e.size,s=e.colorScheme,o=s===void 0?"gray":s,l=e.isDisabled,u=e.isInvalid,d=e.isReadOnly,f=e.required,h=e.isRequired,p=e.inputId,m=e.tagVariant,b=e.selectedOptionStyle,g=b===void 0?"color":b,S=e.selectedOptionColorScheme,w=e.selectedOptionColor,y=e.variant,x=e.focusBorderColor,j=e.errorBorderColor,C=e.chakraStyles,V=C===void 0?{}:C,M=e.onFocus,T=e.onBlur,A=e.menuIsOpen,W=Ol(e,wl),H=Ke(),D=H.components.Input.defaultProps.variant,O=Ba({id:p,isDisabled:l,isInvalid:u,isRequired:h,isReadOnly:d,onFocus:M,onBlur:T}),L=A??(O.readOnly?!1:void 0),_=g,I=["color","check"];I.includes(g)||(_="color");var R=S||w||"blue";typeof R!="string"&&(R="blue");var N=Ye({components:Ye({},Cl,t),colorScheme:o,size:i,tagVariant:m,selectedOptionStyle:_,selectedOptionColorScheme:R,variant:y??D,chakraStyles:V,focusBorderColor:x,errorBorderColor:j,onFocus:O.onFocus,onBlur:O.onBlur,isDisabled:O.disabled,isInvalid:!!O["aria-invalid"],inputId:O.id,isReadOnly:O.readOnly,required:f??O.required,menuIsOpen:L},W,{"aria-invalid":(a=W["aria-invalid"])!=null?a:O["aria-invalid"]});return N};const Ml=Il;function St(){return St=Object.assign?Object.assign.bind():function(n){for(var e=1;e({value:m,label:m})))??[],[o,l]=v.useState(s),u=async()=>{var m,b;await((m=Se)==null?void 0:m.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((b=Se)==null?void 0:b.listAll().then(g=>r(g??[]))),i("")},d=async()=>{var b;const m=await((b=Se)==null?void 0:b.listAll());r(m??[])};if(Se==null)return alert("Error: TagsTable is not loaded"),null;const f=a.map(m=>({value:m.name,label:m.name})),h=37*5;return c.jsxs(Wa,{isLazy:!0,onOpen:d,closeOnBlur:!1,placement:"auto",children:[c.jsx(Ua,{children:c.jsx(te,{icon:c.jsx(Dn,{}),children:"Add Tag"})}),c.jsxs(Ga,{children:[c.jsx(Ya,{}),c.jsx(Ka,{}),c.jsx(Pn,{children:c.jsx("b",{children:n.name})}),c.jsxs(qa,{children:[c.jsx(Pl,{isMulti:!0,name:"tags",options:f,menuIsOpen:!0,value:o,onChange:async m=>{var b;l(m),await((b=G)==null?void 0:b.updateMetaInfo(n.id,{tags:m.map(g=>g.value)})),await(e==null?void 0:e())},chakraStyles:{dropdownIndicator:m=>({...m,p:0,w:"30px"}),menuList:m=>({...m,shadow:"none",pt:0})},placeholder:"Select tags",closeMenuOnSelect:!1,maxMenuHeight:h}),c.jsxs(K,{gap:4,mt:Math.min(h,Math.max(a.length,3)*37),children:[c.jsx(tt,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:m=>{i(m.target.value.trim())}}),c.jsx(ee,{iconSpacing:1,leftIcon:c.jsx(It,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:u,children:"New Tag"})]})]})]})]})}function Dl({workflow:n}){const e=v.useRef(null),a=wt(),{onDuplicateWorkflow:r}=v.useContext(Mt),[t,i]=v.useState(n.saveLock??!1),s=async()=>{var u;const l=!t;i(l),await((u=G)==null?void 0:u.updateMetaInfo(n.id,{saveLock:l})),a({title:`${l?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},o=async l=>{const u=l.target.files;if(!u)return;const d=new FormData;Array.from(u).forEach((f,h)=>{d.append(`images[${h}]`,f,f.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(u).forEach(f=>{var h;(h=Xa)==null||h.create({workflowID:n.id,localPath:`workspace_manager/${f.name}`})})};return c.jsxs(c.Fragment,{children:[c.jsxs(Me,{isLazy:!0,closeOnSelect:!1,children:[c.jsx(Fe,{border:0,as:Z,"aria-label":"Options",icon:c.jsx(br,{size:20}),size:"sm",variant:"outline"}),c.jsxs(Ve,{zIndex:101,children:[c.jsx(te,{icon:c.jsx(ur,{}),onClick:()=>r&&r(n.id),children:"Duplicate"}),c.jsx(jl,{workflow:n}),c.jsx(ne,{hasArrow:!0,label:t?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:c.jsx(te,{icon:t?c.jsx(wn,{}):c.jsx(Cr,{}),onClick:s,children:t?"Unlock":"Lock"})}),c.jsx(te,{icon:c.jsx(Pr,{}),onClick:()=>{var l;(l=e.current)==null||l.click()},children:"Upload Thumbnail Image"})]})]}),c.jsx("input",{style:{display:"none"},ref:e,type:"file",accept:".json,image/png",multiple:!0,onChange:o,onClick:l=>{l.stopPropagation()}})]})}const dn=v.memo(function({workflow:e}){var m,b;const{colorMode:a}=yt(),{setDraggingFile:r,isMultiSelecting:t,onMultiSelectFlow:i,onDeleteFlow:s,multiSelectedFlowsID:o}=v.useContext(pe),l=o&&o.length>0&&o.includes(e.id),{curFlowID:u,loadWorkflowID:d}=v.useContext(Mt),f=u===e.id,h=a==="light"?"gray.200":"#4A5568",p=c.jsx(z,{flexShrink:1,flexGrow:1,backgroundColor:f?"teal.200":void 0,color:f&&!t?"#333":void 0,draggable:!t,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:"3px",onClick:()=>{!t&&d(e.id)},_hover:{bg:h},children:c.jsxs(K,{children:[(((m=e.coverMediaPath)==null?void 0:m.length)||((b=e.latestImage)==null?void 0:b.length))&&c.jsx(lr,{mediaLocalPath:e.coverMediaPath??e.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),c.jsxs(de,{textAlign:"left",gap:0,children:[c.jsxs(Ce,{alignItems:"center",children:[c.jsx(J,{fontWeight:"500",noOfLines:2,style:{display:"inline-block"},children:e.name??"untitled"}),e.saveLock&&c.jsx(wn,{size:18,style:{display:"inline-block"}})]}),c.jsxs(J,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Za(e.updateTime)]})]})]})});return c.jsx(K,{w:"100%",mb:1,justify:"space-between",children:t?c.jsx(Ee,{isChecked:l,spacing:4,onChange:g=>{i&&i(e.id,g.target.checked)},children:p}):c.jsxs(c.Fragment,{children:[p,c.jsxs(Ce,{width:"90px",justifyContent:"flex-end",children:[c.jsx(ne,{label:"Open in new tab",children:c.jsx(Z,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>Ja(e.id),icon:c.jsx(Qa,{color:"#718096",size:23})})}),c.jsx(xn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{s&&s(e.id)}}),c.jsx(Dl,{workflow:e})]})]})})});function ca({items:n}){var h;const[e,a]=v.useState(!1),r=n.filter(xe),t=n.filter(p=>!xe(p)),i=(h=t[0])==null?void 0:h.parentFolderID,[s,o]=v.useState(!1),{onRefreshFilesList:l,draggingFile:u,refreshFolderStamp:d}=v.useContext(pe),f=async p=>{var m,b;if(p.preventDefault(),p.stopPropagation(),!u)return o(!1);if(xe(u)){if(u.id===i)return o(!1);await((m=fe)==null?void 0:m.update(u.id,{parentFolderID:i}))}else await((b=G)==null?void 0:b.updateFolder(u.id,{parentFolderID:i}));await(l==null?void 0:l()),o(!1)};return v.useEffect(()=>{var p;(p=U)==null||p.getSetting("foldersOnTop").then(m=>{a(m??!1)})},[d]),c.jsxs(c.Fragment,{children:[e&&r.map(p=>c.jsx(Bt,{folder:p},p.id)),c.jsx(z,{border:s?"2px dashed #718096":"2px dashed transparent",onDragOver:p=>{p.preventDefault(),p.stopPropagation(),o(!0)},onDragLeave:p=>{p.preventDefault(),p.stopPropagation(),o(!1)},onDrop:f,className:"droppable",children:e?t.map(p=>c.jsx(dn,{workflow:p},p.id)):n.map(p=>xe(p)?c.jsx(Bt,{folder:p},p.id):c.jsx(dn,{workflow:p},p.id))})]})}function Al({onClose:n,onClickNewFlow:e}){const[a,r]=v.useState([]),t=v.useRef([]),i=v.useRef([]),{loadWorkflowID:s,curFlowID:o}=v.useContext(Mt),[l,u]=v.useState(),[d,f]=v.useState(!1),[h,p]=v.useState([]),[m,b]=v.useState(0),[g,S]=v.useState(""),w=$r(g,400),y=v.useRef(null),[x,j]=v.useState(null),C=v.useRef(window.localStorage.getItem(dt)??zt.RECENTLY_MODIFIED),V=async()=>{var I,R;t.current=await((I=G)==null?void 0:I.listFolderContent())??[],i.current=await((R=G)==null?void 0:R.listAll())??[],T(),b(Date.now())},M=!!l||!!w,T=()=>{if(M){const I=i.current.filter(R=>{var se;let N=!0,$=!0;return l&&(N=!!((se=R.tags)!=null&&se.includes(l))),w&&($=!!R.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),N&&$});r(at(I,C.current))}else r(at(t.current,C.current))},A=I=>{r(at(a,I)),C.current=I,window.localStorage.setItem(dt,I),!M&&b(Date.now())};v.useEffect(()=>{T()},[w,l]);const W=v.useCallback(async I=>{var R,N,$;await((R=G)==null?void 0:R.deleteFlow(I)),(($=(N=G)==null?void 0:N.curWorkflow)==null?void 0:$.id)===I&&await(s==null?void 0:s(null)),await V()},[l,w]);v.useEffect(()=>{V();const I=async R=>{var N;if(y.current){const $=await((N=G)==null?void 0:N.get(y.current));$&&$.json&&ar($.json,[R.canvasX,R.canvasY])}};return Re.canvasEl.addEventListener("drop",I),Re.canvasEl.addEventListener("click",n),()=>{Re.canvasEl.removeEventListener("drop",I),Re.canvasEl.removeEventListener("click",n)}},[]);const H=v.useCallback((I,R)=>{p(N=>{const $=[...N];return R?$.push(I):$.splice($.indexOf(I),1),$})},[]),D=(I,R)=>{var N;switch(I){case"batchDelete":o&&((N=G)==null||N.get(o).then($=>{$||s==null||s(null)})),V(),f(!1),p([]);return;case"selectAll":p(R?i.current.map($=>$.id):[]);return}},O=I=>{j(I),xe(I)||(y.current=I.id)},L=I=>{S(I)},_=450;return c.jsx(pe.Provider,{value:{onRefreshFilesList:V,draggingFile:x??void 0,setDraggingFile:O,isMultiSelecting:d,onMultiSelectFlow:H,multiSelectedFlowsID:h,onDeleteFlow:W,refreshFolderStamp:m,setRefreshFolderStamp:b},children:c.jsx(z,{style:{width:_},children:c.jsxs(er,{width:_,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:tr,children:[c.jsxs(Ce,{alignItems:"center",justifyContent:"space-between",children:[c.jsxs(K,{gap:4,children:[c.jsx(K,{gap:2,children:c.jsx(J,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),c.jsx(Vn,{}),c.jsx(ne,{label:"Open workspace save directory",children:c.jsx(Z,{"aria-label":"Open workspace save directory",size:"sm",icon:c.jsx(Cn,{}),variant:"outline",colorScheme:"teal",onClick:()=>nr()})}),c.jsx(ne,{label:"New workflow",children:c.jsx(Z,{"aria-label":"New workflow",size:"sm",icon:c.jsx(It,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),c.jsx(K,{alignItems:"center",children:c.jsx(Tr,{})})]}),c.jsxs(Ce,{direction:"column",h:"calc(100% - 64px)",children:[c.jsx(zr,{selectedTag:l,setSelectedTag:u}),c.jsxs(K,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[c.jsxs(K,{children:[i.current.length>0?c.jsx(Nr,{multipleState:d,changeMultipleState:I=>{f(I),!I&&p([])},selectedKeys:h,isSelectedAll:h.length===i.current.length,batchOperationCallback:D}):c.jsx(z,{}),!d&&c.jsx(ne,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:c.jsx(Z,{size:"sm",variant:"outline",icon:c.jsx(jn,{size:21}),onClick:async()=>{var I;await((I=fe)==null?void 0:I.create({name:"New Folder"})),V()},"aria-label":"new folder button"})})]}),c.jsxs(Me,{closeOnSelect:!0,children:[c.jsx(Fe,{as:ee,variant:"ghost",size:"xs",pr:0,rightIcon:c.jsx(Ot,{size:"16"}),children:c.jsxs(K,{children:[c.jsx(J,{children:"Sort by:"}),c.jsx(J,{display:"inline-block",children:C.current})]})}),c.jsx(Ve,{children:c.jsx(kn,{value:C.current,type:"radio",onChange:I=>A(I),children:Object.values(zt).map((I,R)=>c.jsx(kt,{value:I,children:I},R))})})]})]}),c.jsx(cr,{searchValue:g,onUpdateSearchValue:L}),c.jsx(Ce,{overflowY:"auto",overflowX:"hidden",direction:"column",children:c.jsx(ca,{items:a})})]})]})})})}export{Al as default}; diff --git a/dist/workspace_web/ShareDialog-o8m3m3T9.js b/dist/workspace_web/ShareDialog-o8m3m3T9.js deleted file mode 100644 index 06b4e47..0000000 --- a/dist/workspace_web/ShareDialog-o8m3m3T9.js +++ /dev/null @@ -1 +0,0 @@ -import{f as Z,n as ge,o as ie,j as e,g as q,e as ce,r as a,m as me,w as ne,b as ve,l as y,q as M,p as Y,k as we,H as ke,ah as be,h as G,M as xe,N as ye,O as Ce,Q as Se,S as je}from"./input.js";import{aF as Ie,h as De,B as Pe,J as Re,ad as _e,H as Q,l as X,a9 as Fe,ab as de,j as Me,o as le,k as re,aG as Ne,n as Ee,F as Le,A as K,aH as J,aI as We,aJ as Te,aK as He,T as Ve,aL as Be}from"./App-bqAziDgv.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Ke}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import{I as qe}from"./IconCopy-Vm3ws_0T.js";import"/scripts/api.js";var ue=Z(function(c,r){const o=ge("Badge",c),{className:d,...h}=ie(c);return e.jsx(q.span,{ref:r,className:ce("chakra-badge",c.className),...h,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...o}})});ue.displayName="Badge";function Ge(t){return t&&ne(t)&&ne(t.target)}function $e(t={}){const{onChange:c,value:r,defaultValue:o,name:d,isDisabled:h,isFocusable:f,isNative:g,...p}=t,[w,C]=a.useState(o||""),k=typeof r<"u",S=k?r:w,b=a.useRef(null),j=a.useCallback(()=>{const n=b.current;if(!n)return;let u="input:not(:disabled):checked";const I=n.querySelector(u);if(I){I.focus();return}u="input:not(:disabled)";const s=n.querySelector(u);s==null||s.focus()},[]),m=`radio-${a.useId()}`,E=d||m,R=a.useCallback(n=>{const u=Ge(n)?n.target.value:n;k||C(u),c==null||c(String(u))},[c,k]),B=a.useCallback((n={},u=null)=>({...n,ref:me(u,b),role:"radiogroup"}),[]),_=a.useCallback((n={},u=null)=>({...n,ref:u,name:E,[g?"checked":"isChecked"]:S!=null?n.value===S:void 0,onChange(s){R(s)},"data-radiogroup":!0}),[g,E,R,S]);return{getRootProps:B,getRadioProps:_,name:E,ref:b,focus:j,setValue:C,value:S,onChange:R,isDisabled:h,isFocusable:f,htmlProps:p}}var[ze,he]=ve({name:"RadioGroupContext",strict:!1}),fe=Z((t,c)=>{const{colorScheme:r,size:o,variant:d,children:h,className:f,isDisabled:g,isFocusable:p,...w}=t,{value:C,onChange:k,getRootProps:S,name:b,htmlProps:j}=$e(w),N=a.useMemo(()=>({name:b,size:o,onChange:k,colorScheme:r,value:C,variant:d,isDisabled:g,isFocusable:p}),[b,o,k,r,C,d,g,p]);return e.jsx(ze,{value:N,children:e.jsx(q.div,{...S(j,c),className:ce("chakra-radio-group",f),children:h})})});fe.displayName="RadioGroup";var Ue={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Je(t={}){const{defaultChecked:c,isChecked:r,isFocusable:o,isDisabled:d,isReadOnly:h,isRequired:f,onChange:g,isInvalid:p,name:w,value:C,id:k,"data-radiogroup":S,"aria-describedby":b,...j}=t,N=`radio-${a.useId()}`,m=Ie(),R=!!he()||!!S;let _=!!m&&!R?m.id:N;_=k??_;const n=d??(m==null?void 0:m.isDisabled),u=h??(m==null?void 0:m.isReadOnly),I=f??(m==null?void 0:m.isRequired),s=p??(m==null?void 0:m.isInvalid),[l,P]=a.useState(!1),[v,D]=a.useState(!1),[x,L]=a.useState(!1),[W,T]=a.useState(!1),[$,z]=a.useState(!!c),O=typeof r<"u",F=O?r:$;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(i=>{if(u||n){i.preventDefault();return}O||z(i.target.checked),g==null||g(i)},[O,n,u,g]),A=a.useCallback(i=>{i.key===" "&&T(!0)},[T]),U=a.useCallback(i=>{i.key===" "&&T(!1)},[T]),oe=a.useCallback((i={},V=null)=>({...i,ref:V,"data-active":y(W),"data-hover":y(x),"data-disabled":y(n),"data-invalid":y(s),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&l),"data-readonly":y(u),"aria-hidden":!0,onMouseDown:M(i.onMouseDown,()=>T(!0)),onMouseUp:M(i.onMouseUp,()=>T(!1)),onMouseEnter:M(i.onMouseEnter,()=>L(!0)),onMouseLeave:M(i.onMouseLeave,()=>L(!1))}),[W,x,n,s,F,v,u,l]),{onFocus:se,onBlur:te}=m??{},pe=a.useCallback((i={},V=null)=>{const ae=n&&!o;return{...i,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(i.onChange,H),onBlur:M(te,i.onBlur,()=>D(!1)),onFocus:M(se,i.onFocus,()=>D(!0)),onKeyDown:M(i.onKeyDown,A),onKeyUp:M(i.onKeyUp,U),checked:F,disabled:ae,readOnly:u,required:I,"aria-invalid":Y(s),"aria-disabled":Y(ae),"aria-required":Y(I),"data-readonly":y(u),"aria-describedby":b,style:Ue}},[n,o,_,w,C,H,te,se,A,U,F,u,I,s,b]);return{state:{isInvalid:s,isFocused:v,isChecked:F,isActive:W,isHovered:x,isDisabled:n,isReadOnly:u,isRequired:I},getCheckboxProps:oe,getRadioProps:oe,getInputProps:pe,getLabelProps:(i={},V=null)=>({...i,ref:V,onMouseDown:M(i.onMouseDown,Qe),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),getRootProps:(i,V=null)=>({...i,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),htmlProps:j}}function Qe(t){t.preventDefault(),t.stopPropagation()}function Ye(t,c){const r={},o={};for(const[d,h]of Object.entries(t))c.includes(d)?r[d]=h:o[d]=h;return[r,o]}var ee=Z((t,c)=>{var r;const o=he(),{onChange:d,value:h}=t,f=we("Radio",{...o,...t}),g=ie(t),{spacing:p="0.5rem",children:w,isDisabled:C=o==null?void 0:o.isDisabled,isFocusable:k=o==null?void 0:o.isFocusable,inputProps:S,...b}=g;let j=t.isChecked;(o==null?void 0:o.value)!=null&&h!=null&&(j=o.value===h);let N=d;o!=null&&o.onChange&&h!=null&&(N=ke(o.onChange,d));const m=(r=t==null?void 0:t.name)!=null?r:o==null?void 0:o.name,{getInputProps:E,getCheckboxProps:R,getLabelProps:B,getRootProps:_,htmlProps:n}=Je({...b,isChecked:j,isFocusable:k,isDisabled:C,onChange:N,name:m}),[u,I]=Ye(n,be),s=R(I),l=E(S,c),P=B(),v=Object.assign({},u,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...f.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...f.control},L={userSelect:"none",marginStart:p,...f.label};return e.jsxs(q.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...l}),e.jsx(q.span,{className:"chakra-radio__control",...s,__css:x}),w&&e.jsx(q.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});ee.displayName="Radio";var Xe=De("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Ze({options:t,value:c,onChange:r}){const[o,d]=a.useState(!1),h=a.useRef(null),f=t.find(p=>p.value===c);a.useEffect(()=>{const p=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[h]);const g=()=>d(!o);return e.jsxs(Pe,{position:"relative",children:[e.jsx(G,{onClick:g,rightIcon:e.jsx(Re,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),o&&e.jsx(_e,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(p=>e.jsx(G,{onClick:()=>{d(!1),r(p.value)},leftIcon:p.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:p.label},p.label))})]})}function eo({version:t,cloudHost:c,cloudWorkflowID:r}){const o=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:o.name}),e.jsx(X,{color:"GrayText",children:Fe(o.createTime,!1)}),o.cloudID&&r&&e.jsx("a",{href:c+"/workflow/"+r+"/"+o.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(G,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Xe,{}),rightIcon:e.jsx(de,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(ee,{value:o.id,mb:5,children:d},o.id)}function fo({onClose:t}){var u,I;const[c,r]=a.useState("version "+oo()),[o,d]=a.useState([]),[h,f]=a.useState(!1),[g,p]=a.useState(""),[w,C]=a.useState("PRIVATE"),[k,S]=a.useState("new_version"),b=a.useRef(""),[j,N]=a.useState(),m=Me(),E=async s=>{var L,W;const l=s.data;if(s.origin!==b.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,v=l.localVersionID,D=l.version.id,x=l.version.workflowID;x&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:x,cloudOrigin:s.origin,privacy:w})),v&&D&&await((W=J)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:s.origin})),R(),window.open(b.current+"/workflow/"+x+"/"+D,"_blank"),f(!1)};a.useEffect(()=>(R(),window.addEventListener("message",E),()=>{window.removeEventListener("message",E)}),[]);const R=async()=>{var P,v,D;const s=await((P=le)==null?void 0:P.getSetting("cloudHost"));s&&(p(s),b.current=s);const l=((v=K)==null?void 0:v.curWorkflow)??void 0;N(l),l!=null&&l.cloudID&&l.cloudOrigin&&He(l).then(x=>{C(x)}),(D=J)==null||D.listByWorkflowID(l.id).then(x=>{d(x)})},B=s=>{navigator.clipboard.writeText(s).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var z,O,F;f(!0);const s=We(32),l=await((z=le)==null?void 0:z.getSetting("cloudHost"));let P,v;try{if(P=Te(),k==="new_version"?v=await((O=J)==null?void 0:O.add({workflowID:j.id,name:c,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=J)==null?void 0:F.get(k)),!v){alert(`Failed to find version: ${k}, please try again.`),f(!1);return}}catch(H){console.error(H),f(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,x=window.location.host,L=`${D}//${x}`,W=l+`/share_workflow_confirm/${s}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),$=H=>{var A;if(H.origin===l&&H.data==="child_ready"){const U=(A=K)==null?void 0:A.curWorkflow;T.postMessage({workflow:U,version:v,nodeDefs:P,privacy:w},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},n=(I=(u=K)==null?void 0:u.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ye,{}),e.jsxs(Ce,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(Se,{children:['Share "',j==null?void 0:j.name,'"']}),e.jsxs(je,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Ze,{options:Ne,value:w,onChange:s=>{C(s)}}):e.jsx(Ve,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Be,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Ke,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(de,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(G,{width:"180px",size:"sm",leftIcon:e.jsx(qe,{}),onClick:()=>{var s,l;B(g+"/workflow/"+((l=(s=K)==null?void 0:s.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(fe,{gap:4,onChange:s=>{S(s)},value:k,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(ee,{value:"new_version"},"new_version"),e.jsx(Ee,{value:c,width:"60%",onFocus:()=>{S("new_version")},onChange:s=>{r(s.target.value)}}),e.jsx(Le,{color:"green",children:e.jsx(ue,{colorScheme:"purple",children:"New version"})})]}),o.slice(0,4).map(s=>e.jsx(eo,{version:s,cloudHost:g,cloudWorkflowID:n??null},s.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(G,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function oo(){const t=new Date,c=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${c}-${r}-${o}`}export{fo as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js b/dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js deleted file mode 100644 index 8ce198b..0000000 --- a/dist/workspace_web/chunk-3RSXBRAN-ajfTuIGC.js +++ /dev/null @@ -1 +0,0 @@ -import{f as x,j as l,g as i,e as b,k as C,o as E,l as I,r as f,ah as P}from"./input.js";import{$ as z}from"./App-bqAziDgv.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; diff --git a/dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js b/dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js deleted file mode 100644 index c514adb..0000000 --- a/dist/workspace_web/chunk-JARCRF6W-fNDfXRta.js +++ /dev/null @@ -1 +0,0 @@ -import{f as $,j as f,r as l,y as U,g as P,b as ue,d as W,x as fe,l as i,q as y,m as oe,a4 as J,k as me,o as he,H as ge,e as be}from"./input.js";import{aq as ke}from"./App-bqAziDgv.js";import{t as ve}from"./index-pz0vT7Or.js";var X=$(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;k();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=b=>{k(),g("loaded"),c==null||c(b)},r.onerror=b=>{k(),g("failed"),s==null||s(b)},u.current=r},[e,d,a,p,c,s,n]),k=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return U(()=>{if(!C)return m==="loading"&&x(),()=>{k()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=$(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:k,...r}=n,b=a!==void 0||c!==void 0,R=m!=null||g||!b,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:k,className:"chakra-image",...j})});xe.displayName="Image";var[Ue,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=ke(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:k,isIndeterminate:r,name:b,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(k),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,q]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,H]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||H(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);U(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&q(!1)},[e,q]),U(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{H(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);U(()=>{if(!I.current)return;I.current.checked!==h&&H(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=K=>{F&&K.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var K;(K=I.current)==null||K.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:b,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>q(!1)),onFocus:y(t.onFocus,B,()=>q(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[b,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=$(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:k,isDisabled:r=a==null?void 0:a.isDisabled,onChange:b,inputProps:R,..._}=d;let A=k;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=b;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,b));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:be("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=$(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:k,...r}=n,b={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:k};return f.jsx(P.div,{ref:e,__css:b,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js b/dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js deleted file mode 100644 index b14c30d..0000000 --- a/dist/workspace_web/chunk-NTCQBYKE-ZJqEVTS0.js +++ /dev/null @@ -1 +0,0 @@ -import{k as t}from"./App-bqAziDgv.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index fca58a7..63d351b 100644 --- a/dist/workspace_web/input.js +++ b/dist/workspace_web/input.js @@ -679,10 +679,10 @@ Error generating stack: `+i.message+` } ${hB} - `}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-bqAziDgv.js").then(e=>e.aN),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z}; + `}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-sgH6j00M.js").then(e=>e.aN),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-bqAziDgv.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-sgH6j00M.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file From 23adf59a2e49522d095ccab779d4394732b5fc0e Mon Sep 17 00:00:00 2001 From: Weixuan Fu Date: Sat, 23 Mar 2024 02:28:34 +0800 Subject: [PATCH 2/2] fix build again --- dist/workspace_web/App-sgH6j00M.js | 27 +++++++++++++++++++ .../AppIsDirtyEventListener-Cjpx6yXx.js | 1 + dist/workspace_web/GalleryModal-oZQWNmu9.js | 2 ++ dist/workspace_web/IconCopy-Hs60LgD8.js | 1 + .../InstallMissingModelsButton-sP7CX4K3.js | 1 + dist/workspace_web/MediaPreview-_sS52WD-.js | 1 + .../ModelManagerTopbar-4fKW20g4.js | 7 +++++ .../RecentFilesDrawer-UFHH0mIW.js | 8 ++++++ dist/workspace_web/ShareDialog-MoNpT1nG.js | 1 + dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js | 1 + dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js | 1 + dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js | 1 + 12 files changed, 52 insertions(+) create mode 100644 dist/workspace_web/App-sgH6j00M.js create mode 100644 dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js create mode 100644 dist/workspace_web/GalleryModal-oZQWNmu9.js create mode 100644 dist/workspace_web/IconCopy-Hs60LgD8.js create mode 100644 dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js create mode 100644 dist/workspace_web/MediaPreview-_sS52WD-.js create mode 100644 dist/workspace_web/ModelManagerTopbar-4fKW20g4.js create mode 100644 dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js create mode 100644 dist/workspace_web/ShareDialog-MoNpT1nG.js create mode 100644 dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js create mode 100644 dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js create mode 100644 dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js diff --git a/dist/workspace_web/App-sgH6j00M.js b/dist/workspace_web/App-sgH6j00M.js new file mode 100644 index 0000000..6964675 --- /dev/null +++ b/dist/workspace_web/App-sgH6j00M.js @@ -0,0 +1,27 @@ +var kl=Object.defineProperty;var xl=(t,e,n)=>e in t?kl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ie=(t,e,n)=>(xl(t,typeof e!="symbol"?e+"":e,n),n);import{u as El,a as Cl,r as A,c as Sl,b as et,m as Te,d as Tt,f as he,e as _e,j as D,B as Ol,g as de,h as We,i as Il,o as tt,k as Pt,l as ot,I as Ur,n as Kr,p as ro,q as Oe,s as Da,t as Dl,v as Pl,w as jl,x as $r,y as Al,z as Nl,A as Fl,C as Rl,D as Tl,E as us,F as Pa,G as ds,H as ja,J as Bl,K as Ml,L as zl,P as Aa,M as fs,N as hs,O as ps,Q as ms,R as ys,S as vs,T as gs,_ as Un,U as Na,V as Fa,W as Xn,X as ws}from"./input.js";import{app as xe}from"/scripts/app.js";import{api as Gs}from"/scripts/api.js";function Ll(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Ra(t){var e;return Ll(t)&&(e=t.ownerDocument)!=null?e:document}function Wl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Ul=Wl();function Kl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Ta(t){const{theme:e}=El(),n=Cl();return A.useMemo(()=>Sl(e.direction,{...n,...t}),[t,e.direction,n])}var $l=Object.defineProperty,ql=(t,e,n)=>e in t?$l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(ql(t,typeof e!="symbol"?e+"":e,n),n);function Js(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 Vl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Ys(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Xs(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var ko=typeof window<"u"?A.useLayoutEffect:A.useEffect,xr=t=>t,Hl=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return Vl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=Js(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=Ys(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=Ys(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=Xs(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=Xs(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=Js(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=A.useRef(new Hl);return ko(()=>()=>t.current.destroy()),t.current}var[Gl,Ba]=et({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Jl(t){const e=Ba(),[n,r]=A.useState(-1),o=A.useRef(null);ko(()=>()=>{o.current&&e.unregister(o.current)},[]),ko(()=>{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 Ma(){return[xr(Gl),()=>xr(Ba()),()=>Zl(),o=>Jl(o)]}function za(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Tt(r),i=Tt(o),[a,l]=A.useState(n),c=e!==void 0,u=c?e:a,d=Tt(p=>{const g=typeof p=="function"?p(u):p;i(u,g)&&(c||l(g),s(g))},[c,s,u,i]);return[u,d]}function bs(t){return A.Children.toArray(t).filter(e=>A.isValidElement(e))}var Yl={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}}},Xl={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},La=he(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:c,orientation:u="horizontal",...d}=e,p=_e("chakra-button__group",i),h=A.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:c}),[r,o,s,c]);let g={display:"inline-flex",...l?Yl[u]:Xl[u](a)};const f=u==="vertical";return D.jsx(Ol,{value:h,children:D.jsx(de.div,{ref:n,role:"group",__css:g,className:p,"data-attached":l?"":void 0,"data-orientation":u,flexDir:f?"column":void 0,...d})})});La.displayName="ButtonGroup";var jn=he((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...i}=t,a=n||r,l=A.isValidElement(a)?A.cloneElement(a,{"aria-hidden":!0,focusable:!1}):null;return D.jsx(We,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});jn.displayName="IconButton";var[Ql,Wa]=Il("Card"),ec=he(function(e,n){const{className:r,...o}=e,s=Wa();return D.jsx(de.div,{ref:n,className:_e("chakra-card__body",r),__css:s.body,...o})}),tc=he(function(e,n){const{className:r,...o}=e,s=Wa();return D.jsx(de.div,{ref:n,className:_e("chakra-card__header",r),__css:s.header,...o})}),nc=he(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=tt(e),c=Pt("Card",e);return D.jsx(de.div,{ref:n,className:_e("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...c.container},...l,children:D.jsx(Ql,{value:c,children:o})})}),[rc,Ua]=et({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[oc,dn]=et({strict:!1,name:"FormControlContext"});function sc(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=A.useId(),l=e||`field-${a}`,c=`${l}-label`,u=`${l}-feedback`,d=`${l}-helptext`,[p,h]=A.useState(!1),[g,f]=A.useState(!1),[y,m]=A.useState(!1),w=A.useCallback((E={},N=null)=>({id:d,...E,ref:Te(N,P=>{P&&f(!0)})}),[d]),_=A.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s),id:E.id!==void 0?E.id:c,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,c]),k=A.useCallback((E={},N=null)=>({id:u,...E,ref:Te(N,P=>{P&&h(!0)}),"aria-live":"polite"}),[u]),x=A.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s)}),[i,o,y,r,s]),O=A.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:g,setHasHelpText:f,id:l,labelId:c,feedbackId:u,helpTextId:d,htmlProps:i,getHelpTextProps:w,getErrorMessageProps:k,getRootProps:x,getLabelProps:_,getRequiredIndicatorProps:O}}var qr=he(function(e,n){const r=Pt("Form",e),o=tt(e),{getRootProps:s,htmlProps:i,...a}=sc(o),l=_e("chakra-form-control",e.className);return D.jsx(oc,{value:a,children:D.jsx(rc,{value:r,children:D.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});qr.displayName="FormControl";var ac=he(function(e,n){const r=dn(),o=Ua(),s=_e("chakra-form__helper-text",e.className);return D.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});ac.displayName="FormHelperText";var[ic,lc]=et({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Vr=he((t,e)=>{const n=Pt("FormError",t),r=tt(t),o=dn();return o!=null&&o.isInvalid?D.jsx(ic,{value:n,children:D.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:_e("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Vr.displayName="FormErrorMessage";var cc=he((t,e)=>{const n=lc(),r=dn();if(!(r!=null&&r.isInvalid))return null;const o=_e("chakra-form__error-icon",t.className);return D.jsx(Ur,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:D.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"})})});cc.displayName="FormErrorIcon";var Hr=he(function(e,n){var r;const o=Kr("FormLabel",e),s=tt(e),{className:i,children:a,requiredIndicator:l=D.jsx(Ka,{}),optionalIndicator:c=null,...u}=s,d=dn(),p=(r=d==null?void 0:d.getLabelProps(u,n))!=null?r:{ref:n,...u};return D.jsxs(de.label,{...p,className:_e("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:c]})});Hr.displayName="FormLabel";var Ka=he(function(e,n){const r=dn(),o=Ua();if(!(r!=null&&r.isRequired))return null;const s=_e("chakra-form__required-indicator",e.className);return D.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ka.displayName="RequiredIndicator";function uc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=dc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":ro(n),"aria-required":ro(o),"aria-readonly":ro(r)}}function dc(t){var e,n,r;const o=dn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:c,isInvalid:u,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:g,...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??c)!=null?r:o==null?void 0:o.isRequired,isInvalid:u??(o==null?void 0:o.isInvalid),onFocus:Oe(o==null?void 0:o.onFocus,h),onBlur:Oe(o==null?void 0:o.onBlur,g)}}function en(t,e,n,r){const o=Tt(n);return A.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 fc(t){return"current"in t}var $a=()=>typeof window<"u";function hc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var pc=t=>$a()&&t.test(navigator.vendor),mc=t=>$a()&&t.test(hc()),yc=()=>mc(/mac|iphone|ipad|ipod/i),vc=()=>yc()&&pc(/apple/i);function gc(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};en(o,"pointerdown",s=>{if(!vc()||!r)return;const i=s.target,l=(n??[e]).some(c=>{const u=fc(c)?c.current:c;return(u==null?void 0:u.contains(i))||u===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var qa={exports:{}},wc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",bc=wc,_c=bc;function Va(){}function Ha(){}Ha.resetWarningCache=Va;var kc=function(){function t(r,o,s,i,a,l){if(l!==_c){var c=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 c.name="Invariant Violation",c}}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:Ha,resetWarningCache:Va};return n.PropTypes=n,n};qa.exports=kc();var xc=qa.exports;const Nt=Da(xc);function Ec(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 Cc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function Za(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Dl(t)&&Ec(t)?t:Za(Cc(t))}var Sc=Ul?A.useLayoutEffect:A.useEffect;function xo(t,e=[]){const n=A.useRef(t);return Sc(()=>{n.current=t}),A.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Oc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=xo(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{oo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&oo(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&oo(d,e)&&(i.isPointerDown=!1,o(d))},u=Ra(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function oo(t,e){var n;const r=t.target;return r&&!Ra(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Ic(t,e){const n=A.useId();return A.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Dc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Pc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=xo(n),i=xo(e),[a,l]=A.useState(t.defaultIsOpen||!1),[c,u]=Dc(r,a),d=Ic(o,"disclosure"),p=A.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),h=A.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),g=A.useCallback(()=>{(u?p:h)()},[u,h,p]);return{isOpen:!!u,onOpen:h,onClose:p,onToggle:g,isControlled:c,getButtonProps:(f={})=>({...f,"aria-expanded":u,"aria-controls":d,onClick:Pl(f.onClick,g)}),getDisclosureProps:(f={})=>({...f,hidden:!u,id:d})}}var Kn=he(function(e,n){const{htmlSize:r,...o}=e,s=Pt("Input",o),i=tt(o),a=uc(i),l=_e("chakra-input",e.className);return D.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});Kn.displayName="Input";Kn.id="Input";var jc=Object.freeze(["base","sm","md","lg","xl","2xl"]);function Ac(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):jl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function Dp(t,e=jc){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var Bt=he(function(e,n){const r=Kr("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=tt(e),c=Kl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return D.jsx(de.p,{ref:n,className:_e("chakra-text",e.className),...c,...l,__css:r})});Bt.displayName="Text";var Eo=t=>D.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});Eo.displayName="StackDivider";var Ga=t=>D.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ga.displayName="StackItem";function Nc(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{"&":Ac(n,o=>r[o])}}var tn=he((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:c,className:u,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",g=A.useMemo(()=>Nc({spacing:i,direction:h}),[i,h]),f=!!c,y=!d&&!f,m=A.useMemo(()=>{const _=bs(l);return y?_:_.map((k,x)=>{const O=typeof k.key<"u"?k.key:x,E=x+1===_.length,P=d?D.jsx(Ga,{children:k},O):k;if(!f)return P;const R=A.cloneElement(c,{__css:g}),$=E?null:R;return D.jsxs(A.Fragment,{children:[P,$]},O)})},[c,g,f,y,d,l]),w=_e("chakra-stack",u);return D.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})});tn.displayName="Stack";var Et=he((t,e)=>D.jsx(tn,{align:"center",...t,direction:"row",ref:e}));Et.displayName="HStack";var _s=he(function(e,n){const r=Kr("Heading",e),{className:o,...s}=tt(e);return D.jsx(de.h2,{ref:n,className:_e("chakra-heading",e.className),...s,__css:r})});_s.displayName="Heading";var Ct=de("div");Ct.displayName="Box";var Ja=he(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return D.jsx(Ct,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});Ja.displayName="Square";var Fc=he(function(e,n){const{size:r,...o}=e;return D.jsx(Ja,{size:r,ref:n,borderRadius:"9999px",...o})});Fc.displayName="Circle";var xn=he(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:c,...u}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:c};return D.jsx(de.div,{ref:n,__css:d,...u})});xn.displayName="Flex";function Rc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Tc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=A.useState([]),s=A.useRef(),i=()=>{s.current&&(clearTimeout(s.current),s.current=null)},a=()=>{i(),s.current=setTimeout(()=>{o([]),s.current=null},e)};A.useEffect(()=>i,[]);function l(c){return u=>{if(u.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(Rc(u)){const d=r.concat(u.key);n(u)&&(u.preventDefault(),u.stopPropagation()),o(d),c(d.join("")),a()}}}return l}function Bc(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 Mc(){const t=A.useRef(new Map),e=t.current,n=A.useCallback((o,s,i,a)=>{t.current.set(i,{type:s,el:o,options:a}),o.addEventListener(s,i,a)},[]),r=A.useCallback((o,s,i,a)=>{o.removeEventListener(s,i,a),t.current.delete(i)},[]);return A.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function so(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ya(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:c,onKeyUp:u,tabIndex:d,onMouseOver:p,onMouseLeave:h,...g}=t,[f,y]=A.useState(!0),[m,w]=A.useState(!1),_=Mc(),k=S=>{S&&S.tagName!=="BUTTON"&&y(!1)},x=f?d:d||0,O=n&&!r,E=A.useCallback(S=>{if(n){S.stopPropagation(),S.preventDefault();return}S.currentTarget.focus(),l==null||l(S)},[n,l]),N=A.useCallback(S=>{m&&so(S)&&(S.preventDefault(),S.stopPropagation(),w(!1),_.remove(document,"keyup",N,!1))},[m,_]),P=A.useCallback(S=>{if(c==null||c(S),n||S.defaultPrevented||S.metaKey||!so(S.nativeEvent)||f)return;const G=o&&S.key==="Enter";s&&S.key===" "&&(S.preventDefault(),w(!0)),G&&(S.preventDefault(),S.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,f,c,o,s,_,N]),R=A.useCallback(S=>{if(u==null||u(S),n||S.defaultPrevented||S.metaKey||!so(S.nativeEvent)||f)return;s&&S.key===" "&&(S.preventDefault(),w(!1),S.currentTarget.click())},[s,f,n,u]),$=A.useCallback(S=>{S.button===0&&(w(!1),_.remove(document,"mouseup",$,!1))},[_]),j=A.useCallback(S=>{if(S.button!==0)return;if(n){S.stopPropagation(),S.preventDefault();return}f||w(!0),S.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",$,!1),i==null||i(S)},[n,f,i,_,$]),B=A.useCallback(S=>{S.button===0&&(f||w(!1),a==null||a(S))},[a,f]),b=A.useCallback(S=>{if(n){S.preventDefault();return}p==null||p(S)},[n,p]),K=A.useCallback(S=>{m&&(S.preventDefault(),w(!1)),h==null||h(S)},[m,h]),te=Te(e,k);return f?{...g,ref:te,type:"button","aria-disabled":O?void 0:n,disabled:O,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:u,onKeyDown:c,onMouseOver:p,onMouseLeave:h}:{...g,ref:te,role:"button","data-active":ot(m),"aria-disabled":n?"true":void 0,tabIndex:O?void 0:x,onClick:E,onMouseDown:j,onMouseUp:B,onKeyUp:R,onKeyDown:P,onMouseOver:b,onMouseLeave:K}}function zc(t){const e=t.current;if(!e)return!1;const n=Fl(e);return!n||e.contains(n)?!1:!!Rl(n)}function Xa(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;$r(()=>{if(!s||zc(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 Lc={preventScroll:!0,shouldFocus:!1};function Wc(t,e=Lc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=Uc(t)?t.current:t,a=o&&s,l=A.useRef(a),c=A.useRef(s);Al(()=>{!c.current&&s&&(l.current=a),c.current=s},[s,a]);const u=A.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=Nl(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);$r(()=>{u()},[u]),en(i,"transitionend",u)}function Uc(t){return"current"in t}var Gt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),je={arrowShadowColor:Gt("--popper-arrow-shadow-color"),arrowSize:Gt("--popper-arrow-size","8px"),arrowSizeHalf:Gt("--popper-arrow-size-half"),arrowBg:Gt("--popper-arrow-bg"),transformOrigin:Gt("--popper-transform-origin"),arrowOffset:Gt("--popper-arrow-offset")};function Kc(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 $c={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"},qc=t=>$c[t],Qs={scroll:!0,resize:!0};function Vc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Qs,...t}}:e={enabled:t,options:Qs},e}var Hc={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`}},Zc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{ea(t)},effect:({state:t})=>()=>{ea(t)}},ea=t=>{t.elements.popper.style.setProperty(je.transformOrigin.var,qc(t.placement))},Gc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Jc(t)}},Jc=t=>{var e;if(!t.placement)return;const n=Yc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:je.arrowSize.varRef,height:je.arrowSize.varRef,zIndex:-1});const r={[je.arrowSizeHalf.var]:`calc(${je.arrowSize.varRef} / 2 - 1px)`,[je.arrowOffset.var]:`calc(${je.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},Yc=t=>{if(t.startsWith("top"))return{property:"bottom",value:je.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:je.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:je.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:je.arrowOffset.varRef}},Xc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{ta(t)},effect:({state:t})=>()=>{ta(t)}},ta=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=Kc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:je.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Qc={"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"}},eu={"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 tu(t,e="ltr"){var n,r;const o=((n=Qc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=eu[t])!=null?r:o}var Ke="top",Xe="bottom",Qe="right",$e="left",ks="auto",$n=[Ke,Xe,Qe,$e],sn="start",An="end",nu="clippingParents",Qa="viewport",gn="popper",ru="reference",na=$n.reduce(function(t,e){return t.concat([e+"-"+sn,e+"-"+An])},[]),ei=[].concat($n,[ks]).reduce(function(t,e){return t.concat([e,e+"-"+sn,e+"-"+An])},[]),ou="beforeRead",su="read",au="afterRead",iu="beforeMain",lu="main",cu="afterMain",uu="beforeWrite",du="write",fu="afterWrite",hu=[ou,su,au,iu,lu,cu,uu,du,fu];function it(t){return t?(t.nodeName||"").toLowerCase():null}function He(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function $t(t){var e=He(t).Element;return t instanceof e||t instanceof Element}function Ye(t){var e=He(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function xs(t){if(typeof ShadowRoot>"u")return!1;var e=He(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function pu(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];!Ye(s)||!it(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 mu(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,c){return l[c]="",l},{});!Ye(o)||!it(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const yu={name:"applyStyles",enabled:!0,phase:"write",fn:pu,effect:mu,requires:["computeStyles"]};function at(t){return t.split("-")[0]}var Mt=Math.max,Er=Math.min,an=Math.round;function Co(){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 ti(){return!/^((?!chrome|android).)*safari/i.test(Co())}function ln(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Ye(t)&&(o=t.offsetWidth>0&&an(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&an(r.height)/t.offsetHeight||1);var i=$t(t)?He(t):window,a=i.visualViewport,l=!ti()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c,x:c,y:u}}function Es(t){var e=ln(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 ni(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&xs(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function yt(t){return He(t).getComputedStyle(t)}function vu(t){return["table","td","th"].indexOf(it(t))>=0}function jt(t){return(($t(t)?t.ownerDocument:t.document)||window.document).documentElement}function Zr(t){return it(t)==="html"?t:t.assignedSlot||t.parentNode||(xs(t)?t.host:null)||jt(t)}function ra(t){return!Ye(t)||yt(t).position==="fixed"?null:t.offsetParent}function gu(t){var e=/firefox/i.test(Co()),n=/Trident/i.test(Co());if(n&&Ye(t)){var r=yt(t);if(r.position==="fixed")return null}var o=Zr(t);for(xs(o)&&(o=o.host);Ye(o)&&["html","body"].indexOf(it(o))<0;){var s=yt(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 qn(t){for(var e=He(t),n=ra(t);n&&vu(n)&&yt(n).position==="static";)n=ra(n);return n&&(it(n)==="html"||it(n)==="body"&&yt(n).position==="static")?e:n||gu(t)||e}function Cs(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function En(t,e,n){return Mt(t,Er(e,n))}function wu(t,e,n){var r=En(t,e,n);return r>n?n:r}function ri(){return{top:0,right:0,bottom:0,left:0}}function oi(t){return Object.assign({},ri(),t)}function si(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var bu=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,oi(typeof e!="number"?e:si(e,$n))};function _u(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=at(n.placement),l=Cs(a),c=[$e,Qe].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=bu(o.padding,n),p=Es(s),h=l==="y"?Ke:$e,g=l==="y"?Xe:Qe,f=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],y=i[l]-n.rects.reference[l],m=qn(s),w=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=f/2-y/2,k=d[h],x=w-p[u]-d[g],O=w/2-p[u]/2+_,E=En(k,O,x),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-O,e)}}function ku(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)||ni(e.elements.popper,o)&&(e.elements.arrow=o))}const xu={name:"arrow",enabled:!0,phase:"main",fn:_u,effect:ku,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function cn(t){return t.split("-")[1]}var Eu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Cu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:an(n*o)/o||0,y:an(r*o)/o||0}}function oa(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,g=i.y,f=g===void 0?0:g,y=typeof u=="function"?u({x:h,y:f}):{x:h,y:f};h=y.x,f=y.y;var m=i.hasOwnProperty("x"),w=i.hasOwnProperty("y"),_=$e,k=Ke,x=window;if(c){var O=qn(n),E="clientHeight",N="clientWidth";if(O===He(n)&&(O=jt(n),yt(O).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),O=O,o===Ke||(o===$e||o===Qe)&&s===An){k=Xe;var P=d&&O===x&&x.visualViewport?x.visualViewport.height:O[E];f-=P-r.height,f*=l?1:-1}if(o===$e||(o===Ke||o===Xe)&&s===An){_=Qe;var R=d&&O===x&&x.visualViewport?x.visualViewport.width:O[N];h-=R-r.width,h*=l?1:-1}}var $=Object.assign({position:a},c&&Eu),j=u===!0?Cu({x:h,y:f},He(n)):{x:h,y:f};if(h=j.x,f=j.y,l){var B;return Object.assign({},$,(B={},B[k]=w?"0":"",B[_]=m?"0":"",B.transform=(x.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",B))}return Object.assign({},$,(e={},e[k]=w?f+"px":"",e[_]=m?h+"px":"",e.transform="",e))}function Su(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,c={placement:at(e.placement),variation:cn(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,oa(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,oa(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Ou={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Su,data:{}};var Qn={passive:!0};function Iu(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=He(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,Qn)}),a&&l.addEventListener("resize",n.update,Qn),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Qn)}),a&&l.removeEventListener("resize",n.update,Qn)}}const Du={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Iu,data:{}};var Pu={left:"right",right:"left",bottom:"top",top:"bottom"};function ur(t){return t.replace(/left|right|bottom|top/g,function(e){return Pu[e]})}var ju={start:"end",end:"start"};function sa(t){return t.replace(/start|end/g,function(e){return ju[e]})}function Ss(t){var e=He(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Os(t){return ln(jt(t)).left+Ss(t).scrollLeft}function Au(t,e){var n=He(t),r=jt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=ti();(c||!c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Os(t),y:l}}function Nu(t){var e,n=jt(t),r=Ss(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Mt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Mt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Os(t),l=-r.scrollTop;return yt(o||n).direction==="rtl"&&(a+=Mt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function Is(t){var e=yt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function ai(t){return["html","body","#document"].indexOf(it(t))>=0?t.ownerDocument.body:Ye(t)&&Is(t)?t:ai(Zr(t))}function Cn(t,e){var n;e===void 0&&(e=[]);var r=ai(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=He(r),i=o?[s].concat(s.visualViewport||[],Is(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Cn(Zr(i)))}function So(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Fu(t,e){var n=ln(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 aa(t,e,n){return e===Qa?So(Au(t,n)):$t(e)?Fu(e,n):So(Nu(jt(t)))}function Ru(t){var e=Cn(Zr(t)),n=["absolute","fixed"].indexOf(yt(t).position)>=0,r=n&&Ye(t)?qn(t):t;return $t(r)?e.filter(function(o){return $t(o)&&ni(o,r)&&it(o)!=="body"}):[]}function Tu(t,e,n,r){var o=e==="clippingParents"?Ru(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=aa(t,c,r);return l.top=Mt(u.top,l.top),l.right=Er(u.right,l.right),l.bottom=Er(u.bottom,l.bottom),l.left=Mt(u.left,l.left),l},aa(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 ii(t){var e=t.reference,n=t.element,r=t.placement,o=r?at(r):null,s=r?cn(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 Xe:l={x:i,y:e.y+e.height};break;case Qe: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 c=o?Cs(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case sn:l[c]=l[c]-(e[u]/2-n[u]/2);break;case An:l[c]=l[c]+(e[u]/2-n[u]/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?nu:a,c=n.rootBoundary,u=c===void 0?Qa:c,d=n.elementContext,p=d===void 0?gn:d,h=n.altBoundary,g=h===void 0?!1:h,f=n.padding,y=f===void 0?0:f,m=oi(typeof y!="number"?y:si(y,$n)),w=p===gn?ru:gn,_=t.rects.popper,k=t.elements[g?w:p],x=Tu($t(k)?k:k.contextElement||jt(t.elements.popper),l,u,i),O=ln(t.elements.reference),E=ii({reference:O,element:_,strategy:"absolute",placement:o}),N=So(Object.assign({},_,E)),P=p===gn?N:O,R={top:x.top-P.top+m.top,bottom:P.bottom-x.bottom+m.bottom,left:x.left-P.left+m.left,right:P.right-x.right+m.right},$=t.modifiersData.offset;if(p===gn&&$){var j=$[o];Object.keys(R).forEach(function(B){var b=[Qe,Xe].indexOf(B)>=0?1:-1,K=[Ke,Xe].indexOf(B)>=0?"y":"x";R[B]+=j[K]*b})}return R}function Bu(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,c=l===void 0?ei:l,u=cn(r),d=u?a?na:na.filter(function(g){return cn(g)===u}):$n,p=d.filter(function(g){return c.indexOf(g)>=0});p.length===0&&(p=d);var h=p.reduce(function(g,f){return g[f]=Nn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[at(f)],g},{});return Object.keys(h).sort(function(g,f){return h[g]-h[f]})}function Mu(t){if(at(t)===ks)return[];var e=ur(t);return[sa(t),e,sa(e)]}function zu(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,c=n.padding,u=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,g=h===void 0?!0:h,f=n.allowedAutoPlacements,y=e.options.placement,m=at(y),w=m===y,_=l||(w||!g?[ur(y)]:Mu(y)),k=[y].concat(_).reduce(function(Y,H){return Y.concat(at(H)===ks?Bu(e,{placement:H,boundary:u,rootBoundary:d,padding:c,flipVariations:g,allowedAutoPlacements:f}):H)},[]),x=e.rects.reference,O=e.rects.popper,E=new Map,N=!0,P=k[0],R=0;R=0,K=b?"width":"height",te=Nn(e,{placement:$,boundary:u,rootBoundary:d,altBoundary:p,padding:c}),S=b?B?Qe:$e:B?Xe:Ke;x[K]>O[K]&&(S=ur(S));var G=ur(S),z=[];if(s&&z.push(te[j]<=0),a&&z.push(te[S]<=0,te[G]<=0),z.every(function(Y){return Y})){P=$,N=!1;break}E.set($,z)}if(N)for(var Q=g?3:1,M=function(H){var fe=k.find(function(ye){var se=E.get(ye);if(se)return se.slice(0,H).every(function(le){return le})});if(fe)return P=fe,"break"},T=Q;T>0;T--){var ne=M(T);if(ne==="break")break}e.placement!==P&&(e.modifiersData[r]._skip=!0,e.placement=P,e.reset=!0)}}const Lu={name:"flip",enabled:!0,phase:"main",fn:zu,requiresIfExists:["offset"],data:{_skip:!1}};function ia(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 la(t){return[Ke,Qe,Xe,$e].some(function(e){return t[e]>=0})}function Wu(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=ia(i,r),c=ia(a,o,s),u=la(l),d=la(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const Uu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Wu};function Ku(t,e,n){var r=at(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,Qe].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function $u(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=ei.reduce(function(u,d){return u[d]=Ku(d,e.rects,s),u},{}),a=i[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=i}const qu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:$u};function Vu(t){var e=t.state,n=t.name;e.modifiersData[n]=ii({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Hu={name:"popperOffsets",enabled:!0,phase:"read",fn:Vu,data:{}};function Zu(t){return t==="x"?"y":"x"}function Gu(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,c=n.rootBoundary,u=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,g=n.tetherOffset,f=g===void 0?0:g,y=Nn(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),m=at(e.placement),w=cn(e.placement),_=!w,k=Cs(m),x=Zu(k),O=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,P=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,R=typeof P=="number"?{mainAxis:P,altAxis:P}:Object.assign({mainAxis:0,altAxis:0},P),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,j={x:0,y:0};if(O){if(s){var B,b=k==="y"?Ke:$e,K=k==="y"?Xe:Qe,te=k==="y"?"height":"width",S=O[k],G=S+y[b],z=S-y[K],Q=h?-N[te]/2:0,M=w===sn?E[te]:N[te],T=w===sn?-N[te]:-E[te],ne=e.elements.arrow,Y=h&&ne?Es(ne):{width:0,height:0},H=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ri(),fe=H[b],ye=H[K],se=En(0,E[te],Y[te]),le=_?E[te]/2-Q-se-fe-R.mainAxis:M-se-fe-R.mainAxis,ke=_?-E[te]/2+Q+se+ye+R.mainAxis:T+se+ye+R.mainAxis,ve=e.elements.arrow&&qn(e.elements.arrow),me=ve?k==="y"?ve.clientTop||0:ve.clientLeft||0:0,Ee=(B=$==null?void 0:$[k])!=null?B:0,v=S+le-Ee-me,U=S+ke-Ee,W=En(h?Er(G,v):G,S,h?Mt(z,U):z);O[k]=W,j[k]=W-S}if(a){var I,C=k==="x"?Ke:$e,F=k==="x"?Xe:Qe,V=O[x],J=x==="y"?"height":"width",L=V+y[C],X=V-y[F],re=[Ke,$e].indexOf(m)!==-1,ee=(I=$==null?void 0:$[x])!=null?I:0,ae=re?L:V-E[J]-N[J]-ee+R.altAxis,ge=re?V+E[J]+N[J]-ee-R.altAxis:X,pe=h&&re?wu(ae,V,ge):En(h?ae:L,V,h?ge:X);O[x]=pe,j[x]=pe-V}e.modifiersData[r]=j}}const Ju={name:"preventOverflow",enabled:!0,phase:"main",fn:Gu,requiresIfExists:["offset"]};function Yu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Xu(t){return t===He(t)||!Ye(t)?Ss(t):Yu(t)}function Qu(t){var e=t.getBoundingClientRect(),n=an(e.width)/t.offsetWidth||1,r=an(e.height)/t.offsetHeight||1;return n!==1||r!==1}function ed(t,e,n){n===void 0&&(n=!1);var r=Ye(e),o=Ye(e)&&Qu(e),s=jt(e),i=ln(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((it(e)!=="body"||Is(s))&&(a=Xu(e)),Ye(e)?(l=ln(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Os(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function td(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 nd(t){var e=td(t);return hu.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function rd(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function od(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 ca={placement:"bottom",modifiers:[],strategy:"absolute"};function ua(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=A.useCallback(()=>{var R;!e||!g.current||!f.current||((R=w.current)==null||R.call(w),y.current=id(g.current,f.current,{placement:m,modifiers:[Xc,Gc,Zc,{...Hc,enabled:!!p},{name:"eventListeners",...Vc(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!c,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:u}},...n??[]],strategy:o}),y.current.forceUpdate(),w.current=y.current.destroy)},[m,e,n,p,i,s,a,l,c,d,u,o]);A.useEffect(()=>()=>{var R;!g.current&&!f.current&&((R=y.current)==null||R.destroy(),y.current=null)},[]);const k=A.useCallback(R=>{g.current=R,_()},[_]),x=A.useCallback((R={},$=null)=>({...R,ref:Te(k,$)}),[k]),O=A.useCallback(R=>{f.current=R,_()},[_]),E=A.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=A.useCallback((R={},$=null)=>{const{size:j,shadowColor:B,bg:b,style:K,...te}=R;return{...te,ref:$,"data-popper-arrow":"",style:ld(R)}},[]),P=A.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:je.transformOrigin.varRef,referenceRef:k,popperRef:O,getPopperProps:E,getArrowProps:N,getArrowInnerProps:P,getReferenceProps:x}}function ld(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 Ps(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Tt(n),i=Tt(e),[a,l]=A.useState(t.defaultIsOpen||!1),c=r!==void 0?r:a,u=r!==void 0,d=A.useId(),p=o??`disclosure-${d}`,h=A.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),g=A.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),f=A.useCallback(()=>{c?h():g()},[c,g,h]);function y(w={}){return{...w,"aria-expanded":c,"aria-controls":p,onClick(_){var k;(k=w.onClick)==null||k.call(w,_),f()}}}function m(w={}){return{...w,hidden:!c,id:p}}return{isOpen:c,onOpen:g,onClose:h,onToggle:f,isControlled:u,getButtonProps:y,getDisclosureProps:m}}function cd(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Tt(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{ao(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&ao(d,e)&&(i.isPointerDown=!1,o(d))},c=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&ao(d,e)&&(i.isPointerDown=!1,o(d))},u=li(e.current);return u.addEventListener("mousedown",a,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",a,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",a,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",a,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,i,r])}function ao(t,e){var n;const r=t.target;return r&&!li(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function li(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function ci(t){const{isOpen:e,ref:n}=t,[r,o]=A.useState(e),[s,i]=A.useState(!1);return A.useEffect(()=>{s||(o(e),i(!0))},[e,s,r]),en(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const c=Tl(n.current),u=new c.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(u)}}}function js(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[ud,dd,fd,hd]=Ma(),[pd,Vn]=et({strict:!1,name:"MenuContext"});function md(t,...e){const n=A.useId(),r=t||n;return A.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function ui(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function da(t){return ui(t).activeElement===t}function yd(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:c,onOpen:u,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:g=!1,...f}=t,y=A.useRef(null),m=A.useRef(null),w=fd(),_=A.useCallback(()=>{requestAnimationFrame(()=>{var ne;(ne=y.current)==null||ne.focus({preventScroll:!1})})},[]),k=A.useCallback(()=>{const ne=setTimeout(()=>{var Y;if(o)(Y=o.current)==null||Y.focus();else{const H=w.firstEnabled();H&&B(H.index)}});G.current.add(ne)},[w,o]),x=A.useCallback(()=>{const ne=setTimeout(()=>{const Y=w.lastEnabled();Y&&B(Y.index)});G.current.add(ne)},[w]),O=A.useCallback(()=>{u==null||u(),s?k():_()},[s,k,_,u]),{isOpen:E,onOpen:N,onClose:P,onToggle:R}=Ps({isOpen:a,defaultIsOpen:l,onClose:c,onOpen:O});cd({enabled:E&&r,ref:y,handler:ne=>{var Y;(Y=m.current)!=null&&Y.contains(ne.target)||P()}});const $=Ds({...f,enabled:E||g,placement:d,direction:h}),[j,B]=A.useState(-1);$r(()=>{E||B(-1)},[E]),Xa(y,{focusRef:m,visible:E,shouldFocus:!0});const b=ci({isOpen:E,ref:y}),[K,te]=md(e,"menu-button","menu-list"),S=A.useCallback(()=>{N(),_()},[N,_]),G=A.useRef(new Set([]));A.useEffect(()=>{const ne=G.current;return()=>{ne.forEach(Y=>clearTimeout(Y)),ne.clear()}},[]);const z=A.useCallback(()=>{N(),k()},[k,N]),Q=A.useCallback(()=>{N(),x()},[N,x]),M=A.useCallback(()=>{var ne,Y;const H=ui(y.current),fe=(ne=y.current)==null?void 0:ne.contains(H.activeElement);if(!(E&&!fe))return;const se=(Y=w.item(j))==null?void 0:Y.node;se==null||se.focus({preventScroll:!0})},[E,j,w]),T=A.useRef(null);return{openAndFocusMenu:S,openAndFocusFirstItem:z,openAndFocusLastItem:Q,onTransitionEnd:M,unstable__animationState:b,descendants:w,popper:$,buttonId:K,menuId:te,forceUpdate:$.forceUpdate,orientation:"vertical",isOpen:E,onToggle:R,onOpen:N,onClose:P,menuRef:y,buttonRef:m,focusedIndex:j,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:B,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:T}}function Pp(t={},e=null){const n=Vn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=A.useCallback(l=>{const c=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[c];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Te(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":ot(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Oe(t.onClick,r),onKeyDown:Oe(t.onKeyDown,a)}}function Oo(t){var e;return wd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function vd(t={},e=null){const n=Vn();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:c,lazyBehavior:u,unstable__animationState:d}=n,p=dd(),h=Tc({preventDefault:m=>m.key!==" "&&Oo(m.target)}),g=A.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const w=m.key,k={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(k){m.preventDefault(),k(m);return}const x=h(O=>{const E=Bc(p.values(),O,N=>{var P,R;return(R=(P=N==null?void 0:N.node)==null?void 0:P.textContent)!=null?R:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});Oo(m.target)&&x(m)},[p,r,h,a,o]),f=A.useRef(!1);i&&(f.current=!0);const y=js({wasSelected:f.current,enabled:c,mode:u,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,g)}}function gd(t={}){const{popper:e,isOpen:n}=Vn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function di(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:c,type:u,...d}=t,p=Vn(),{setFocusedIndex:h,focusedIndex:g,closeOnSelect:f,onClose:y,menuRef:m,isOpen:w,menuId:_,rafId:k}=p,x=A.useRef(null),O=`${_}-menuitem-${A.useId()}`,{index:E,register:N}=hd({disabled:a&&!l}),P=A.useCallback(S=>{n==null||n(S),!a&&h(E)},[h,E,a,n]),R=A.useCallback(S=>{r==null||r(S),x.current&&!da(x.current)&&P(S)},[P,r]),$=A.useCallback(S=>{o==null||o(S),!a&&h(-1)},[h,a,o]),j=A.useCallback(S=>{s==null||s(S),Oo(S.currentTarget)&&(c??f)&&y()},[y,s,f,c]),B=A.useCallback(S=>{i==null||i(S),h(E)},[h,i,E]),b=E===g,K=a&&!l;$r(()=>{if(w)return b&&!K&&x.current?(k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{var S;(S=x.current)==null||S.focus({preventScroll:!0}),k.current=null})):m.current&&!da(m.current)&&m.current.focus({preventScroll:!0}),()=>{k.current&&cancelAnimationFrame(k.current)}},[b,K,m,w]);const te=Ya({onClick:j,onFocus:B,onMouseEnter:P,onMouseMove:R,onMouseLeave:$,ref:Te(N,x,e),isDisabled:a,isFocusable:l});return{...d,...te,type:u??te.type,id:O,role:"menuitem",tabIndex:b?0:-1}}function jp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...di(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"?"":[],[c,u]=za({defaultValue:o??l,value:r,onChange:s}),d=A.useCallback(g=>{if(n==="radio"&&typeof c=="string"&&u(g),n==="checkbox"&&Array.isArray(c)){const f=c.includes(g)?c.filter(y=>y!==g):c.concat(g);u(f)}},[c,u,n]),h=bs(e).map(g=>{if(g.type.id!=="MenuItemOption")return g;const f=m=>{var w,_;d(g.props.value),(_=(w=g.props).onClick)==null||_.call(w,m)},y=n==="radio"?g.props.value===c:c.includes(g.props.value);return A.cloneElement(g,{type:n,onClick:f,isChecked:y})});return{...i,children:h}}function wd(t){var e;if(!bd(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function bd(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[_d,Gr]=et({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),As=t=>{const{children:e}=t,n=Pt("Menu",t),r=tt(t),{direction:o}=us(),{descendants:s,...i}=yd({...r,direction:o}),a=A.useMemo(()=>i,[i]),{isOpen:l,onClose:c,forceUpdate:u}=a;return D.jsx(ud,{value:s,children:D.jsx(pd,{value:a,children:D.jsx(_d,{value:n,children:Pa(e,{isOpen:l,onClose:c,forceUpdate:u})})})})};As.displayName="Menu";var fi=he((t,e)=>{const n=Gr();return D.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});fi.displayName="MenuCommand";var kd=he((t,e)=>{const{type:n,...r}=t,o=Gr(),s=r.as||n?n??void 0:"button",i=A.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 D.jsx(de.button,{ref:e,type:s,...r,__css:i})}),hi=t=>{const{className:e,children:n,...r}=t,o=Gr(),s=A.Children.only(n),i=A.isValidElement(s)?A.cloneElement(s,{focusable:"false","aria-hidden":!0,className:_e("chakra-menu__icon",s.props.className)}):null,a=_e("chakra-menu__icon-wrapper",e);return D.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};hi.displayName="MenuIcon";var gt=he((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=di(a,e),u=n||o?D.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return D.jsxs(kd,{...l,className:_e("chakra-menu__menuitem",l.className),children:[n&&D.jsx(hi,{fontSize:"0.8em",marginEnd:r,children:n}),u,o&&D.jsx(fi,{marginStart:s,children:o})]})});gt.displayName="MenuItem";var xd={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"}}},Ed=de(ds.div),Ns=he(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:c,unstable__animationState:u}=Vn(),d=vd(a,n),p=gd(s),h=Gr();return D.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:D.jsx(Ed,{variants:xd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:_e("chakra-menu__menu-list",d.className),...d,onUpdate:c,onAnimationComplete:ja(u.onComplete,d.onAnimationComplete)})})});Ns.displayName="MenuList";var[Cd,fn]=et({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Sd,Jr]=et({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function pi(t){const e=A.Children.only(t.children),{getTriggerProps:n}=fn();return A.cloneElement(e,n(e.props,e.ref))}pi.displayName="PopoverTrigger";var Jt={click:"click",hover:"hover"};function Od(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:c=Jt.click,openDelay:u=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:g,...f}=t,{isOpen:y,onClose:m,onOpen:w,onToggle:_}=Ps(t),k=A.useRef(null),x=A.useRef(null),O=A.useRef(null),E=A.useRef(!1),N=A.useRef(!1);y&&(N.current=!0);const[P,R]=A.useState(!1),[$,j]=A.useState(!1),B=A.useId(),b=o??B,[K,te,S,G]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:z,getArrowProps:Q,getPopperProps:M,getArrowInnerProps:T,forceUpdate:ne}=Ds({...f,enabled:y||!!g}),Y=ci({isOpen:y,ref:O});gc({enabled:y,ref:x}),Xa(O,{focusRef:x,visible:y,shouldFocus:s&&c===Jt.click}),Wc(O,{focusRef:r,visible:y,shouldFocus:i&&c===Jt.click});const H=js({wasSelected:N.current,enabled:p,mode:h,isSelected:Y.present}),fe=A.useCallback((U={},W=null)=>{const I={...U,style:{...U.style,transformOrigin:je.transformOrigin.varRef,[je.arrowSize.var]:a?`${a}px`:void 0,[je.arrowShadowColor.var]:l},ref:Te(O,W),children:H?U.children:null,id:te,tabIndex:-1,role:"dialog",onKeyDown:Oe(U.onKeyDown,C=>{n&&C.key==="Escape"&&m()}),onBlur:Oe(U.onBlur,C=>{const F=fa(C),V=io(O.current,F),J=io(x.current,F);y&&e&&(!V&&!J)&&m()}),"aria-labelledby":P?S:void 0,"aria-describedby":$?G:void 0};return c===Jt.hover&&(I.role="tooltip",I.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0}),I.onMouseLeave=Oe(U.onMouseLeave,C=>{C.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),I},[H,te,P,S,$,G,c,n,m,y,e,d,l,a]),ye=A.useCallback((U={},W=null)=>M({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,M]),se=A.useCallback((U,W=null)=>({...U,ref:Te(W,k,z)}),[k,z]),le=A.useRef(),ke=A.useRef(),ve=A.useCallback(U=>{k.current==null&&z(U)},[z]),me=A.useCallback((U={},W=null)=>{const I={...U,ref:Te(x,W,ve),id:K,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":te};return c===Jt.click&&(I.onClick=Oe(U.onClick,_)),c===Jt.hover&&(I.onFocus=Oe(U.onFocus,()=>{le.current===void 0&&w()}),I.onBlur=Oe(U.onBlur,C=>{const F=fa(C),V=!io(O.current,F);y&&e&&V&&m()}),I.onKeyDown=Oe(U.onKeyDown,C=>{C.key==="Escape"&&m()}),I.onMouseEnter=Oe(U.onMouseEnter,()=>{E.current=!0,le.current=window.setTimeout(()=>w(),u)}),I.onMouseLeave=Oe(U.onMouseLeave,()=>{E.current=!1,le.current&&(clearTimeout(le.current),le.current=void 0),ke.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),I},[K,y,te,c,ve,_,w,e,m,u,d]);A.useEffect(()=>()=>{le.current&&clearTimeout(le.current),ke.current&&clearTimeout(ke.current)},[]);const Ee=A.useCallback((U={},W=null)=>({...U,id:S,ref:Te(W,I=>{R(!!I)})}),[S]),v=A.useCallback((U={},W=null)=>({...U,id:G,ref:Te(W,I=>{j(!!I)})}),[G]);return{forceUpdate:ne,isOpen:y,onAnimationComplete:Y.onComplete,onClose:m,getAnchorProps:se,getArrowProps:Q,getArrowInnerProps:T,getPopoverPositionerProps:ye,getPopoverProps:fe,getTriggerProps:me,getHeaderProps:Ee,getBodyProps:v}}function io(t,e){return t===e||(t==null?void 0:t.contains(e))}function fa(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function mi(t){const e=Pt("Popover",t),{children:n,...r}=tt(t),o=us(),s=Od({...r,direction:o.direction});return D.jsx(Cd,{value:s,children:D.jsx(Sd,{value:e,children:Pa(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}mi.displayName="Popover";var lo=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function yi(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:i,shadowColor:a}=t,{getArrowProps:l,getArrowInnerProps:c}=fn(),u=Jr(),d=(e=n??r)!=null?e:o,p=s??i;return D.jsx(de.div,{...l(),className:"chakra-popover__arrow-positioner",children:D.jsx(de.div,{className:_e("chakra-popover__arrow",t.className),...c(t),__css:{"--popper-arrow-shadow-color":lo("colors",a),"--popper-arrow-bg":lo("colors",d),"--popper-arrow-shadow":lo("shadows",p),...u.arrow}})})}yi.displayName="PopoverArrow";var vi=he(function(e,n){const{getBodyProps:r}=fn(),o=Jr();return D.jsx(de.div,{...r(e,n),className:_e("chakra-popover__body",e.className),__css:o.body})});vi.displayName="PopoverBody";var gi=he(function(e,n){const{onClose:r}=fn(),o=Jr();return D.jsx(Bl,{size:"sm",onClick:r,className:_e("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});gi.displayName="PopoverCloseButton";function Id(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var Dd={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]}}},Pd=de(ds.section),wi=he(function(e,n){const{variants:r=Dd,...o}=e,{isOpen:s}=fn();return D.jsx(Pd,{ref:n,variants:Id(r),initial:!1,animate:s?"enter":"exit",...o})});wi.displayName="PopoverTransition";var bi=he(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=fn(),c=Jr(),u={position:"relative",display:"flex",flexDirection:"column",...c.content};return D.jsx(de.div,{...a(r),__css:c.popper,className:"chakra-popover__popper",children:D.jsx(wi,{...o,...i(s,n),onAnimationComplete:ja(l,s.onAnimationComplete),className:_e("chakra-popover__content",e.className),__css:u})})});bi.displayName="PopoverContent";var[jd,Ad,Nd,Fd]=Ma();function Rd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:c="ltr",...u}=t,[d,p]=A.useState(n??0),[h,g]=za({defaultValue:n??0,value:o,onChange:r});A.useEffect(()=>{o!=null&&p(o)},[o]);const f=Nd(),y=A.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:g,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:c,htmlProps:u}}var[Td,Yr]=et({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Bd(t){const{focusedIndex:e,orientation:n,direction:r}=Yr(),o=Ad(),s=A.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())},c=()=>{var w;const _=o.firstEnabled();_&&((w=_.node)==null||w.focus())},u=()=>{var w;const _=o.lastEnabled();_&&((w=_.node)==null||w.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,g=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",m={[g]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:c,End:u}[h];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Oe(t.onKeyDown,s)}}function Md(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=Yr(),{index:c,register:u}=Fd({disabled:e&&!n}),d=c===l,p=()=>{o(c)},h=()=>{a(c),!s&&!(e&&n)&&o(c)},g=Ya({...r,ref:Te(u,t.ref),isDisabled:e,isFocusable:n,onClick:Oe(t.onClick,p)}),f="button";return{...g,id:_i(i,c),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":ki(i,c),onFocus:e?void 0:Oe(t.onFocus,h)}}var[zd,Ld]=et({});function Wd(t){const e=Yr(),{id:n,selectedIndex:r}=e,s=bs(t.children).map((i,a)=>A.createElement(zd,{key:a,value:{isSelected:a===r,id:ki(n,a),tabId:_i(n,a),selectedIndex:r}},i));return{...t,children:s}}function Ud(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Yr(),{isSelected:s,id:i,tabId:a}=Ld(),l=A.useRef(!1);s&&(l.current=!0);const c=js({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:c?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function _i(t,e){return`${t}--tab-${e}`}function ki(t,e){return`${t}--tabpanel-${e}`}var[Kd,Xr]=et({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),xi=he(function(e,n){const r=Pt("Tabs",e),{children:o,className:s,...i}=tt(e),{htmlProps:a,descendants:l,...c}=Rd(i),u=A.useMemo(()=>c,[c]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return D.jsx(jd,{value:l,children:D.jsx(Td,{value:u,children:D.jsx(Kd,{value:r,children:D.jsx(de.div,{className:_e("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});xi.displayName="Tabs";var Ei=he(function(e,n){const r=Bd({...e,ref:n}),s={display:"flex",...Xr().tablist};return D.jsx(de.div,{...r,className:_e("chakra-tabs__tablist",e.className),__css:s})});Ei.displayName="TabList";var Io=he(function(e,n){const r=Ud({...e,ref:n}),o=Xr();return D.jsx(de.div,{outline:"0",...r,className:_e("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Io.displayName="TabPanel";var Ci=he(function(e,n){const r=Wd(e),o=Xr();return D.jsx(de.div,{...r,width:"100%",ref:n,className:_e("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Ci.displayName="TabPanels";var Do=he(function(e,n){const r=Xr(),o=Md({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return D.jsx(de.button,{...o,className:_e("chakra-tabs__tab",e.className),__css:s})});Do.displayName="Tab";var[$d,Si]=et({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Qr=he((t,e)=>{const n=Pt("Tag",t),r=tt(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return D.jsx($d,{value:n,children:D.jsx(de.span,{ref:e,...r,__css:o})})});Qr.displayName="Tag";var qd=he((t,e)=>{const n=Si();return D.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});qd.displayName="TagLabel";var Vd=he((t,e)=>D.jsx(Ur,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Vd.displayName="TagLeftIcon";var Hd=he((t,e)=>D.jsx(Ur,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));Hd.displayName="TagRightIcon";var Oi=t=>D.jsx(Ur,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:D.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"})});Oi.displayName="TagCloseIcon";var Zd=he((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...Si().closeButton};return D.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||D.jsx(Oi,{})})});Zd.displayName="TagCloseButton";var Gd={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]}}}},Po=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},dr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Jd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:c,placement:u,id:d,isOpen:p,defaultIsOpen:h,arrowSize:g=10,arrowShadowColor:f,arrowPadding:y,modifiers:m,isDisabled:w,gutter:_,offset:k,direction:x,...O}=t,{isOpen:E,onOpen:N,onClose:P}=Ps({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:c}),{referenceRef:R,getPopperProps:$,getArrowInnerProps:j,getArrowProps:B}=Ds({enabled:E,placement:u,arrowPadding:y,modifiers:m,gutter:_,offset:k,direction:x}),b=A.useId(),te=`tooltip-${d??b}`,S=A.useRef(null),G=A.useRef(),z=A.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=void 0)},[]),Q=A.useRef(),M=A.useCallback(()=>{Q.current&&(clearTimeout(Q.current),Q.current=void 0)},[]),T=A.useCallback(()=>{M(),P()},[P,M]),ne=Yd(S,T),Y=A.useCallback(()=>{if(!w&&!G.current){E&&ne();const me=dr(S);G.current=me.setTimeout(N,e)}},[ne,w,E,N,e]),H=A.useCallback(()=>{z();const me=dr(S);Q.current=me.setTimeout(T,n)},[n,T,z]),fe=A.useCallback(()=>{E&&r&&H()},[r,H,E]),ye=A.useCallback(()=>{E&&i&&H()},[i,H,E]),se=A.useCallback(me=>{E&&me.key==="Escape"&&H()},[E,H]);en(()=>Po(S),"keydown",a?se:void 0),en(()=>{if(!s)return null;const me=S.current;if(!me)return null;const Ee=Za(me);return Ee.localName==="body"?dr(S):Ee},"scroll",()=>{E&&s&&T()},{passive:!0,capture:!0}),A.useEffect(()=>{w&&(z(),E&&P())},[w,E,P,z]),A.useEffect(()=>()=>{z(),M()},[z,M]),en(()=>S.current,"pointerleave",H);const le=A.useCallback((me={},Ee=null)=>({...me,ref:Te(S,Ee,R),onPointerEnter:Oe(me.onPointerEnter,U=>{U.pointerType!=="touch"&&Y()}),onClick:Oe(me.onClick,fe),onPointerDown:Oe(me.onPointerDown,ye),onFocus:Oe(me.onFocus,Y),onBlur:Oe(me.onBlur,H),"aria-describedby":E?te:void 0}),[Y,H,ye,E,te,fe,R]),ke=A.useCallback((me={},Ee=null)=>$({...me,style:{...me.style,[je.arrowSize.var]:g?`${g}px`:void 0,[je.arrowShadowColor.var]:f}},Ee),[$,g,f]),ve=A.useCallback((me={},Ee=null)=>{const v={...me.style,position:"relative",transformOrigin:je.transformOrigin.varRef};return{ref:Ee,...O,...me,id:te,role:"tooltip",style:v}},[O,te]);return{isOpen:E,show:Y,hide:H,getTriggerProps:le,getTooltipProps:ve,getTooltipPositionerProps:ke,getArrowProps:B,getArrowInnerProps:j}}var co="chakra-ui:close-tooltip";function Yd(t,e){return A.useEffect(()=>{const n=Po(t);return n.addEventListener(co,e),()=>n.removeEventListener(co,e)},[e,t]),()=>{const n=Po(t),r=dr(t);n.dispatchEvent(new r.CustomEvent(co))}}function Xd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Qd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var ef=de(ds.div),zt=he((t,e)=>{var n,r;const o=Kr("Tooltip",t),s=tt(t),i=us(),{children:a,label:l,shouldWrapChildren:c,"aria-label":u,hasArrow:d,bg:p,portalProps:h,background:g,backgroundColor:f,bgColor:y,motionProps:m,...w}=s,_=(r=(n=g??f)!=null?n:p)!=null?r:y;if(_){o.bg=_;const $=Ml(i,"colors",_);o[je.arrowBg.var]=$}const k=Jd({...w,direction:i.direction}),x=typeof a=="string"||c;let O;if(x)O=D.jsx(de.span,{display:"inline-block",tabIndex:0,...k.getTriggerProps(),children:a});else{const $=A.Children.only(a);O=A.cloneElement($,k.getTriggerProps($.props,$.ref))}const E=!!u,N=k.getTooltipProps({},e),P=E?Xd(N,["role","id"]):N,R=Qd(N,["role","id"]);return l?D.jsxs(D.Fragment,{children:[O,D.jsx(zl,{children:k.isOpen&&D.jsx(Aa,{...h,children:D.jsx(de.div,{...k.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:D.jsxs(ef,{variants:Gd,initial:"exit",animate:"enter",exit:"exit",...m,...P,__css:o,children:[l,E&&D.jsx(de.span,{srOnly:!0,...R,children:u}),d&&D.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:D.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):D.jsx(D.Fragment,{children:a})});zt.displayName="Tooltip";let er;const tf=new Uint8Array(16);function nf(){if(!er&&(er=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!er))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return er(tf)}const Re=[];for(let t=0;t<256;++t)Re.push((t+256).toString(16).slice(1));function rf(t,e=0){return Re[t[e+0]]+Re[t[e+1]]+Re[t[e+2]]+Re[t[e+3]]+"-"+Re[t[e+4]]+Re[t[e+5]]+"-"+Re[t[e+6]]+Re[t[e+7]]+"-"+Re[t[e+8]]+Re[t[e+9]]+"-"+Re[t[e+10]]+Re[t[e+11]]+Re[t[e+12]]+Re[t[e+13]]+Re[t[e+14]]+Re[t[e+15]]}const of=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ha={randomUUID:of};function Fn(t,e,n){if(ha.randomUUID&&!e&&!t)return ha.randomUUID();t=t||{};const r=t.random||(t.rng||nf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=r[o];return e}return rf(r)}async function sf(t){console.warn("[workspace deprecated] getDB is deprecated",t);try{const e=await fetch(`/workspace/get_db?table=${t}`);return e.ok?await e.json():void 0}catch(e){console.error("Error fetching workspace:",e);return}}async function af(t,e){try{return await(await fetch("/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 lf(t,e){try{return await(await fetch("/workspace/update_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,json_str:e})})).text()}catch(n){alert("Error saving workflow .json file: "+n),console.error("Error saving workspace:",n)}}async function Ii(t,e=!1){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,deleteEmptyFolder:e})})).text()}catch(n){console.error("Error deleting file:",n)}}async function Np(t){try{return await(await fetch("/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 Fp(){try{return await(await fetch("/workspace/open_workflow_file_browser",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}catch(t){console.error("Error open workflows folder:",t)}}async function cf(){const e=await(await fetch("/workspace/get_my_workflows_dir")).json();return e.error&&alert(`Failed to fetch my workflows path: ${e.error}`),e}async function Rp(){try{return await(await fetch("/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 Tp(){try{return await(await fetch("/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 Bp(t){try{return await(await fetch("/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 Mp(t,e){try{return await(await fetch("/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 uf="backup",Cr="workspace";let tr=null;function df(){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 ff(){try{return tr==null&&(tr=await df()),new Promise((t,e)=>{if(tr==null)return e("indexDB is null");const o=tr.transaction([Cr],"readonly").objectStore(Cr).get(uf);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 hf(){try{return await ff()}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,Ae=Object.keys,Me=Array.isArray;function Ue(t,e){return typeof e!="object"||Ae(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||Ce.Promise||(Ce.Promise=Promise);const Rn=Object.getPrototypeOf,pf={}.hasOwnProperty;function Ze(t,e){return pf.call(t,e)}function un(t,e){typeof e=="function"&&(e=e(Rn(t))),(typeof Reflect>"u"?Ae:Reflect.ownKeys)(e).forEach(n=>{pt(t,n,e[n])})}const Di=Object.defineProperty;function pt(t,e,n,r){Di(t,e,Ue(n&&Ze(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function nn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),pt(t.prototype,"constructor",t),{extend:un.bind(null,t.prototype)}}}}const mf=Object.getOwnPropertyDescriptor;function Fs(t,e){let n;return mf(t,e)||(n=Rn(t))&&Fs(n,e)}const yf=[].slice;function Sr(t,e,n){return yf.call(t,e,n)}function Pi(t,e){return e(t)}function bn(t){if(!t)throw new Error("Assertion Failed")}function ji(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Ai(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function mt(t,e){if(Ze(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]),gf=Ri.map(t=>Ce[t]);Ai(Ri,t=>[t,!0]);let bt=null;function Hn(t){bt=typeof WeakMap<"u"&&new WeakMap;const e=jo(t);return bt=null,e}function jo(t){if(!t||typeof t!="object")return t;let e=bt&&bt.get(t);if(e)return e;if(Me(t)){e=[],bt&&bt.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),bt&&bt.set(t,e),t)Ze(t,o)&&(e[o]=jo(t[o]))}return e}const{toString:wf}={};function Ao(t){return wf.call(t).slice(8,-1)}const No=typeof Symbol<"u"?Symbol.iterator:"@@iterator",bf=typeof No=="symbol"?function(t){var e;return t!=null&&(e=t[No])&&e.apply(t)}:function(){return null},Qt={};function ft(t){var e,n,r,o;if(arguments.length===1){if(Me(t))return t.slice();if(this===Qt&&typeof t=="string")return[t];if(o=bf(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 Rs=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var lt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ti(t,e){lt=t,Bi=e}var Bi=()=>!0;const _f=!new Error("").stack;function Ht(){if(_f)try{throw Ht.arguments,new Error}catch(t){return t}return new Error}function Fo(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(Bi).map(r=>` +`+r).join("")):""}var Mi=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ts=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Mi),kf={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 rn(t,e){this._e=Ht(),this.name=t,this.message=e}function zi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` +`)}function Or(t,e,n,r){this._e=Ht(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=zi(t,e)}function Sn(t,e){this._e=Ht(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=zi(t,e)}nn(rn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Fo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),nn(Or).from(rn),nn(Sn).from(rn);var Bs=Ts.reduce((t,e)=>(t[e]=e+"Error",t),{});const xf=rn;var ce=Ts.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Ht(),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=kf[e]||n,this.inner=null)}return nn(r).from(xf),t[e]=r,t},{});ce.Syntax=SyntaxError,ce.Type=TypeError,ce.Range=RangeError;var pa=Mi.reduce((t,e)=>(t[e+"Error"]=ce[e],t),{}),fr=Ts.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=ce[e]),t),{});function be(){}function Tn(t){return t}function Ef(t,e){return t==null||t===Tn?e:function(n){return e(t(n))}}function qt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Cf(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?qt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?qt(o,this.onerror):o),s!==void 0?s:n}}function Sf(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?qt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?qt(r,this.onerror):r)}}function Of(t,e){return t===be?e:function(n){var r=t.apply(this,arguments);Ue(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?qt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?qt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function If(t,e){return t===be?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ms(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)}}fr.ModifyError=Or,fr.DexieError=rn,fr.BulkError=Sn;var Bn={};const Li=100,[Ro,Ir,To]=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]})(),Wi=Ir&&Ir.then,hr=Ro&&Ro.constructor,zs=!!To;var Bo=!1,Df=To?()=>{To.then(nr)}:Ce.setImmediate?setImmediate.bind(null,nr):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{nr(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(nr,0)},On=function(t,e){_n.push([t,e]),Dr&&(Df(),Dr=!1)},Mo=!0,Dr=!0,Lt=[],pr=[],zo=null,Lo=Tn,on={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:va,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{va(t[0],t[1])}catch{}})}},ie=on,_n=[],Wt=0,mr=[];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=ie;if(lt&&(this._stackHolder=Ht(),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&&Uo(this,this._value))}this._state=null,this._value=null,++e.ref,Ki(this,t)}const Wo={get:function(){var t=ie,e=Pr;function n(r,o){var s=!t.global&&(t!==ie||e!==Pr);const i=s&&!vt();var a=new oe((l,c)=>{Ls(this,new Ui(jr(r,t,s,i),jr(o,t,s,i),l,c,t))});return lt&&Vi(a,this),a}return n.prototype=Bn,n},set:function(t){pt(this,"then",t&&t.prototype===Bn?Wo:{get:function(){return t},set:Wo.set})}};function Ui(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 Ki(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"?Ki(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,$i(t)),r&&Gn()}},Uo.bind(null,t))}catch(n){Uo(t,n)}}function Uo(t,e){if(pr.push(e),t._state===null){var n=t._lib&&Zn();e=Lo(e),t._state=!1,t._value=e,lt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Fs(e,"stack");e._promise=t,pt(e,"stack",{get:()=>Bo?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Lt.some(o=>o._value===r._value)||Lt.push(r)}(t),$i(t),n&&Gn()}}function $i(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Wt==0&&Ws()},[]))}function Ls(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,++Wt,On(Pf,[n,t,e])}else t._listeners.push(e)}function Pf(t,e,n){try{zo=e;var r,o=e._value;e._state?r=t(o):(pr.length&&(pr=[]),r=t(o),pr.indexOf(o)===-1&&function(s){for(var i=Lt.length;i;)if(Lt[--i]._value===s._value)return void Lt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{zo=null,--Wt==0&&Ws(),--n.psd.ref||n.psd.finalize()}}function qi(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=Fo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return lt&&((r=Fo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&qi(t._prev,e,n)),e}function Vi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function nr(){Zn()&&Gn()}function Zn(){var t=Mo;return Mo=!1,Dr=!1,t}function Gn(){var t,e,n;do for(;_n.length>0;)for(t=_n,_n=[],n=t.length,e=0;e0);Mo=!0,Dr=!0}function Ws(){var t=Lt;Lt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=mr.slice(0),n=e.length;n;)e[--n]()}function rr(t){return new oe(Bn,!1,t)}function Se(t,e){var n=ie;return function(){var r=Zn(),o=ie;try{return Ot(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Ot(o,!1),r&&Gn()}}}un(oe.prototype,{then:Wo,_then:function(t,e){Ls(this,new Ui(null,null,t,e,ie))},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):rr(r)):this.then(null,r=>r&&r.name===e?n(r):rr(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),rr(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Bo=!0;var t=qi(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{Bo=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ce.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&pt(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),on.env=Hi(),un(oe,{all:function(){var t=ft.apply(null,arguments).map(or);return new oe(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>oe.resolve(o).then(i=>{t[s]=i,--r||e(t)},n))})},resolve:t=>{if(t instanceof oe)return t;if(t&&typeof t.then=="function")return new oe((n,r)=>{t.then(n,r)});var e=new oe(Bn,!0,t);return Vi(e,zo),e},reject:rr,race:function(){var t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ie,set:t=>ie=t},totalEchoes:{get:()=>Pr},newPSD:St,usePSD:pn,scheduler:{get:()=>On,set:t=>{On=t}},rejectionMapper:{get:()=>Lo,set:t=>{Lo=t}},follow:(t,e)=>new oe((n,r)=>St((o,s)=>{var i=ie;i.unhandleds=[],i.onunhandled=s,i.finalize=qt(function(){(function(a){function l(){a(),mr.splice(mr.indexOf(l),1)}mr.push(l),++Wt,On(()=>{--Wt==0&&Ws()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),hr&&(hr.allSettled&&pt(oe,"allSettled",function(){const t=ft.apply(null,arguments).map(or);return new oe(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>oe.resolve(o).then(i=>r[s]={status:"fulfilled",value:i},i=>r[s]={status:"rejected",reason:i}).then(()=>--n||e(r)))})}),hr.any&&typeof AggregateError<"u"&&pt(oe,"any",function(){const t=ft.apply(null,arguments).map(or);return new oe((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,i)=>oe.resolve(s).then(a=>e(a),a=>{o[i]=a,--r||n(new AggregateError(o))}))})}));const Be={awaits:0,echoes:0,id:0};var jf=0,yr=[],uo=0,Pr=0,Af=0;function St(t,e,n,r){var o=ie,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Af;var i=on.env;s.env=zs?{Promise:oe,PromiseProp:{value:oe,configurable:!0,writable:!0},all:oe.all,race:oe.race,allSettled:oe.allSettled,any:oe.any,resolve:oe.resolve,reject:oe.reject,nthen:ma(i.nthen,s),gthen:ma(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=pn(s,t,n,r);return s.ref===0&&s.finalize(),a}function hn(){return Be.id||(Be.id=++jf),++Be.awaits,Be.echoes+=Li,Be.id}function vt(){return!!Be.awaits&&(--Be.awaits==0&&(Be.id=0),Be.echoes=Be.awaits*Li,!0)}function or(t){return Be.echoes&&t&&t.constructor===hr?(hn(),t.then(e=>(vt(),e),e=>(vt(),Ne(e)))):t}function Nf(t){++Pr,Be.echoes&&--Be.echoes!=0||(Be.echoes=Be.id=0),yr.push(ie),Ot(t,!0)}function Ff(){var t=yr[yr.length-1];yr.pop(),Ot(t,!1)}function Ot(t,e){var n=ie;if((e?!Be.echoes||uo++&&t===ie:!uo||--uo&&t===ie)||Zi(e?Nf.bind(null,t):Ff),t!==ie&&(ie=t,n===on&&(on.env=Hi()),zs)){var r=on.env.Promise,o=t.env;Ir.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(Ce,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function Hi(){var t=Ce.Promise;return zs?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(Ce,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:Ir.then,gthen:t.prototype.then}:{}}function pn(t,e,n,r,o){var s=ie;try{return Ot(t,!0),e(n,r,o)}finally{Ot(s,!1)}}function Zi(t){Wi.call(Ro,t)}function jr(t,e,n,r){return typeof t!="function"?t:function(){var o=ie;n&&hn(),Ot(e,!0);try{return t.apply(this,arguments)}finally{Ot(o,!1),r&&Zi(vt)}}}function ma(t,e){return function(n,r){return t.call(this,jr(n,e),jr(r,e))}}(""+Wi).indexOf("[native code]")===-1&&(hn=vt=be);const ya="unhandledrejection";function va(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(Ce.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ya,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(ya,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}lt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Ne=oe.reject;function Ko(t,e,n,r){if(t.idbdb&&(t._state.openComplete||ie.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ko(t,e,n,r))):Ne(s)}return o._promise(e,(s,i)=>St(()=>(ie.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Ne(new ce.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Ne(new ce.DatabaseClosed);t.open().catch(be)}return t._state.dbReadyPromise.then(()=>Ko(t,e,n,r))}const ga="3.2.4",Rt="￿",$o=-1/0,ut="Invalid key provided. Keys must be of type string, number, Date or Array.",Gi="String expected.",In=[],eo=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Rf=eo,Tf=eo,Ji=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),to="__dbnames",fo="readonly",ho="readwrite";function Vt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Yi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function sr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Hn(e))[t],e)}class Bf{_trans(e,n,r){const o=this._tx||ie.trans,s=this.name;function i(l,c,u){if(!u.schema[s])throw new ce.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const a=Zn();try{return o&&o.db===this.db?o===ie.trans?o._promise(e,i,r):St(()=>o._promise(e,i,r),{trans:o,transless:ie.transless||ie}):Ko(this.db,e,[this.name],i)}finally{a&&Gn()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(o=>this.hook.reading.fire(o))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(Me(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=Ae(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==Rt)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&<&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[a,l]=n.reduce(([c,u],d)=>{const p=o[d],h=e[d];return[c||p,c||!p?Vt(u,p&&p.multi?g=>{const f=mt(g,d);return Me(f)&&f.some(y=>i(h,y))}:g=>i(h,mt(g,d))):u]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,Me(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const o=Object.create(e.prototype);for(var s in r)if(Ze(r,s))try{o[s]=r[s]}catch{}return o};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){Ue(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[s]})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||Me(e))return this.where(":id").equals(e).modify(n);{const r=mt(e,this.schema.primKey.keyPath);if(r===void 0)return Ne(new ce.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ae(n).forEach(o=>{nt(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=sr(o)(e)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:n!=null?[n]:null})).then(i=>i.numFailures?oe.reject(i.failures[0]):i.lastResult).then(i=>{if(o)try{nt(e,o,i)}catch{}return i})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?oe.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Yi})).then(e=>e.numFailures?oe.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(o=>this.hook.reading.fire(o))))}bulkAdd(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,g)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:l}=this.schema.primKey;if(l&&o)throw new ce.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ce.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&a?e.map(sr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:g})=>{if(d===0)return s?p:h;throw new Sn(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,g)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new Sn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Dn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[i].subscribe.apply(null,c),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rVt(r(),e()):e,t.justLimit=n&&!r}function vr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ce.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function wa(t,e,n){const r=vr(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function ar(t,e,n,r){const o=t.replayFilter?Vt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,c)=>{if(!o||o(l,c,p=>l.stop(p),p=>l.fail(p))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Ze(s,d)||(s[d]=!0,e(a,l,c))}};return Promise.all([t.or._iterate(i,n),ba(wa(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return ba(wa(t,r,n),Vt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ba(t,e,n,r){var o=Se(r?(s,i,a)=>n(r(s),i,a):n);return t.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();e&&!e(s,a=>i=a,a=>{s.stop(a),i=be},a=>{s.fail(a),i=be})||o(s.value,s,a=>i=a),i()})})}function Le(t,e){try{const n=_a(t),r=_a(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tar(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Yt(r,!0))return o.count({trans:n,query:{index:vr(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return ar(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(c,u){return u?i(c[r[u]],u-1):c[o]}var a=this._ctx.dir==="next"?1:-1;function l(c,u){var d=i(c,s),p=i(u,s);return dp?a:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Yt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=vr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:i})=>o?i.map(o):i)}{const o=[];return ar(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Yt(n)?mo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):mo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),mo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return po(this._ctx,function(r,o,s){return!e(r.value)||(o(s),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return po(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Vt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Yt(n,!0)&&n.limit>0)return this._read(o=>{var s=vr(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return po(this._ctx,function(o){var s=o.primaryKey.toString(),i=Ze(r,s);return r[s]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=Ae(e),i=s.length;o=function(f){for(var y=!1,m=0;m{const{failures:m,numFailures:w}=y;p+=f-w;for(let _ of Ae(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const w=Math.min(u,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+w),cache:"immutable"}).then(_=>{const k=[],x=[],O=l?[]:null,E=[];for(let P=0;P0&&a.mutate({trans:r,type:"add",values:k}).then(P=>{for(let R in P.failures)E.splice(parseInt(R),1);g(k.length,P)})).then(()=>(x.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:O,values:x,criteria:N,changeSpec:typeof e!="function"&&e}).then(P=>g(x.length,P))).then(()=>(E.length>0||N&&e===yo)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(P=>g(E.length,P))).then(()=>f.length>m+w&&y(m+u))})};return y(0).then(()=>{if(d.length>0)throw new Or("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return Yt(e)&&(e.isPrimKey&&!Tf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:c,numFailures:u})=>{if(u)throw new Or("Could not delete some values",Object.keys(a).map(d=>a[d]),i-u);return i-u}))}):this.modify(yo)}}const yo=(t,e)=>e.value=null;function zf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Qi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Xt(t){return new t.Collection(t,()=>Xi("")).limit(0)}function Wf(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],c)<0&&(a=l)}return itypeof f=="string"))return qe(t,Gi);function p(f){o=function(m){return m==="next"?w=>w.toUpperCase():w=>w.toLowerCase()}(f),s=function(m){return m==="next"?w=>w.toLowerCase():w=>w.toUpperCase()}(f),i=f==="next"?zf:Lf;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,w){return i(m.lower,w.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),c=f,u=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>wt(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var g=0;return h._addAlgorithm(function(f,y,m){var w=f.key;if(typeof w!="string")return!1;var _=s(w);if(e(_,l,g))return!0;for(var k=null,x=g;x0)&&(k=O)}return y(k!==null?function(){f.continue(k+u)}:m),!1}),h}function wt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Xi(t){return{type:1,lower:t,upper:t}}class Qi{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,o){r=r!==!1,o=o===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||o)&&(!r||!o)?Xt(this):new this.Collection(this,()=>wt(e,n,!r,!o))}catch{return qe(this,ut)}}equals(e){return e==null?qe(this,ut):new this.Collection(this,()=>Xi(e))}above(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(e,void 0,!1))}below(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ut):new this.Collection(this,()=>wt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Gi):this.between(e,e+Rt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):ir(this,(n,r)=>n.indexOf(r[0])===0,[e],Rt)}equalsIgnoreCase(e){return ir(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=ft.apply(Qt,arguments);return e.length===0?Xt(this):ir(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Rt)}anyOf(){const e=ft.apply(Qt,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ut)}if(e.length===0)return Xt(this);const r=new this.Collection(this,()=>wt(e[0],e[e.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((s,i,a)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return i(a),!1;return n(l,e[o])===0||(i(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[$o,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=ft.apply(Qt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ut)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[$o,o]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,o=this._ascending,s=this._descending,i=this._min,a=this._max;if(e.length===0)return Xt(this);if(!e.every(w=>w[0]!==void 0&&w[1]!==void 0&&o(w[0],w[1])<=0))return qe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ce.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function p(w,_){return d(w[0],_[0])}try{u=e.reduce(function(w,_){let k=0,x=w.length;for(;k0){O[0]=i(O[0],_[0]),O[1]=a(O[1],_[1]);break}}return k===x&&w.push(_),w},[]),u.sort(p)}catch{return qe(this,ut)}let h=0;const g=c?w=>o(w,u[h][1])>0:w=>o(w,u[h][1])>=0,f=l?w=>s(w,u[h][0])>0:w=>s(w,u[h][0])>=0;let y=g;const m=new this.Collection(this,()=>wt(u[0][0],u[u.length-1][1],!l,!c));return m._ondirectionchange=w=>{w==="next"?(y=g,d=o):(y=f,d=s),u.sort(p)},m._addAlgorithm((w,_,k)=>{for(var x=w.key;y(x);)if(++h,h===u.length)return _(k),!1;return!!function(O){return!g(O)&&!f(O)}(x)||(this._cmp(x,u[h][1])===0||this._cmp(x,u[h][0])===0||_(()=>{d===o?w.continue(u[h][0]):w.continue(u[h][1])}),!1)}),m}startsWithAnyOf(){const e=ft.apply(Qt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Xt(this):this.inAnyRange(e.map(n=>[n,n+Rt])):qe(this,"startsWithAnyOf() only works with strings")}}function st(t){return Se(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const zn="storagemutated",_t="x-storagemutated-1",It=Dn(null,zn);class Uf{_lock(){return bn(!ie.global),++this._reculock,this._reculock!==1||ie.global||(ie.lockOwnerFor=this),this}_unlock(){if(bn(!ie.global),--this._reculock==0)for(ie.global||(ie.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{pn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&ie.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(bn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ce.DatabaseClosed(r);case"MissingAPIError":throw new ce.MissingAPI(r.message,r);default:throw new ce.OpenFailed(r)}if(!this.active)throw new ce.TransactionInactive;return bn(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Se(o=>{Mn(o),this._reject(e.error)}),e.onabort=Se(o=>{Mn(o),this.active&&this._reject(new ce.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&It.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Ne(new ce.ReadOnly("Transaction is readonly"));if(!this.active)return Ne(new ce.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ie])});if(r)return St(()=>{var s=new oe((i,a)=>{this._lock();const l=n(i,a,this);l&&l.then&&l.then(i,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new oe((s,i)=>{var a=n(s,i,this);a&&a.then&&a.then(s,i)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=oe.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=i)})()}var s=n._waitingFor;return new oe((i,a)=>{r.then(l=>n._waitingQueue.push(Se(i.bind(null,l))),l=>n._waitingQueue.push(Se(a.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ce.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Ze(n,e))return n[e];const r=this.schema[e];if(!r)throw new ce.NotFound("Table "+e+" not part of transaction");const o=new this.db.Table(e,r,this);return o.core=this.db.core.table(e),n[e]=o,o}}function qo(t,e,n,r,o,s,i){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+el(e)}}function el(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function tl(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Ai(n,r=>[r.name,r])}}let Ln=t=>{try{return t.only([[]]),Ln=()=>[[]],[[]]}catch{return Ln=()=>Rt,Rt}};function Vo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>mt(r,e)}(t):e=>mt(e,t)}function xa(t){return[].slice.call(t)}let Kf=0;function Pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function $f(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:p}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!p):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,c){const u=xa(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,g=Me(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:g,keyPath:p,autoIncrement:h,unique:!0,extractKey:Vo(p)},indexes:xa(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:_,unique:k,multiEntry:x,keyPath:O}=w,E={name:_,compound:Me(O),keyPath:O,unique:k,multiEntry:x,extractKey:Vo(O)};return y[Pn(O)]=E,E}),getIndexByKeyPath:w=>y[Pn(w)]};return y[":id"]=m.primaryKey,p!=null&&(y[Pn(p)]=m.primaryKey),m})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:p,keys:h,values:g,range:f}){return new Promise((y,m)=>{y=Se(y);const w=d.objectStore(u),_=w.keyPath==null,k=p==="put"||p==="add";if(!k&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:x}=h||g||{length:1};if(h&&g&&h.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(x===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let O;const E=[],N=[];let P=0;const R=j=>{++P,Mn(j)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:P,failures:N,results:[],lastResult:void 0});f.type===3?E.push(O=w.clear()):E.push(O=w.delete(r(f)))}else{const[j,B]=k?_?[g,h]:[g,null]:[h,null];if(k)for(let b=0;b{const B=j.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:P,failures:N,results:p==="delete"?h:E.map(b=>b.result),lastResult:B})};O.onerror=j=>{R(j),$(j)},O.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,g)=>{h=Se(h);const f=d.objectStore(u),y=p.length,m=new Array(y);let w,_=0,k=0;const x=E=>{const N=E.target;m[N._pos]=N.result,++k===_&&h(m)},O=st(g);for(let E=0;Enew Promise((h,g)=>{h=Se(h);const f=d.objectStore(u).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=st(g)}),query:function(d){return p=>new Promise((h,g)=>{h=Se(h);const{trans:f,values:y,limit:m,query:w}=p,_=m===1/0?void 0:m,{index:k,range:x}=w,O=f.objectStore(u),E=k.isPrimaryKey?O:O.index(k.name),N=r(x);if(m===0)return h({result:[]});if(d){const P=y?E.getAll(N,_):E.getAllKeys(N,_);P.onsuccess=R=>h({result:R.target.result}),P.onerror=st(g)}else{let P=0;const R=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];R.onsuccess=j=>{const B=R.result;return B?($.push(y?B.value:B.primaryKey),++P===m?h({result:$}):void B.continue()):h({result:$})},R.onerror=st(g)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:g,unique:f}){return new Promise((y,m)=>{y=Se(y);const{index:w,range:_}=h,k=d.objectStore(u),x=w.isPrimaryKey?k:k.index(w.name),O=g?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in x)?x.openCursor(r(_),O):x.openKeyCursor(r(_),O);E.onerror=st(m),E.onsuccess=Se(N=>{const P=E.result;if(!P)return void y(null);P.___id=++Kf,P.done=!1;const R=P.continue.bind(P);let $=P.continuePrimaryKey;$&&($=$.bind(P));const j=P.advance.bind(P),B=()=>{throw new Error("Cursor not stopped")};P.trans=d,P.stop=P.continue=P.continuePrimaryKey=P.advance=()=>{throw new Error("Cursor not started")},P.fail=Se(m),P.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},P.start=b=>{const K=new Promise((S,G)=>{S=Se(S),E.onerror=st(G),P.fail=G,P.stop=z=>{P.stop=P.continue=P.continuePrimaryKey=P.advance=B,S(z)}}),te=()=>{if(E.result)try{b()}catch(S){P.fail(S)}else P.done=!0,P.start=()=>{throw new Error("Cursor behind last entry")},P.stop()};return E.onsuccess=Se(S=>{E.onsuccess=te,te()}),P.continue=R,P.continuePrimaryKey=$,P.advance=j,te(),K},y(P)},m)})},count({query:d,trans:p}){const{index:h,range:g}=d;return new Promise((f,y)=>{const m=p.objectStore(u),w=h.isPrimaryKey?m:m.index(h.name),_=r(g),k=_?w.count(_):w.count();k.onsuccess=Se(x=>f(x.target.result)),k.onerror=st(y)})}}}(l)),a={};return i.forEach(l=>a[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!a[l])throw new Error(`Table '${l}' not found`);return a[l]},MIN_KEY:-1/0,MAX_KEY:Ln(e),schema:o}}function Ho({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(u,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),u)}($f(s,i,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const s=o.name;t.core.schema.tables.some(i=>i.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function Ar({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Fs(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?pt(i,o,{get(){return this.table(o)},set(l){Di(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function Zo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function qf(t,e){return t._cfg.version-e._cfg.version}function Vf(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const i=s._reject.bind(s),a=ie.transless||ie;St(()=>{ie.trans=s,ie.transless=a,e===0?(Ae(o).forEach(l=>{vo(n,l,o[l].primKey,o[l].indexes)}),Ho(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},c,u,d){const p=[],h=l._versions;let g=l._dbSchema=Jo(l,l.idbdb,d),f=!1;const y=h.filter(w=>w._cfg.version>=c);function m(){return p.length?oe.resolve(p.shift()(u.idbtrans)).then(m):oe.resolve()}return y.forEach(w=>{p.push(()=>{const _=g,k=w._cfg.dbschema;Yo(l,_,d),Yo(l,k,d),g=l._dbSchema=k;const x=nl(_,k);x.add.forEach(E=>{vo(d,E[0],E[1].primKey,E[1].indexes)}),x.change.forEach(E=>{if(E.recreate)throw new ce.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(P=>Go(N,P)),E.change.forEach(P=>{N.deleteIndex(P.name),Go(N,P)}),E.del.forEach(P=>N.deleteIndex(P))}});const O=w._cfg.contentUpgrade;if(O&&w._cfg.version>c){Ho(l,d),u._memoizedTables={},f=!0;let E=Ni(k);x.del.forEach($=>{E[$]=_[$]}),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],Ae(E),E),u.schema=E;const N=Rs(O);let P;N&&hn();const R=oe.follow(()=>{if(P=O(u),P&&N){var $=vt.bind(null,null);P.then($,$)}});return P&&typeof P.then=="function"?oe.resolve(P):R.then(()=>P)}}),p.push(_=>{(!f||!Rf)&&function(k,x){[].slice.call(x.db.objectStoreNames).forEach(O=>k[O]==null&&x.db.deleteObjectStore(O))}(w._cfg.dbschema,_),Zo(l,[l.Transaction.prototype]),Ar(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),m().then(()=>{var w,_;_=d,Ae(w=g).forEach(k=>{_.db.objectStoreNames.contains(k)||vo(_,k,w[k].primKey,w[k].indexes)})})}(t,e,s,n).catch(i)})}function nl(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const o=t[r],s=e[r];if(o){const i={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!eo)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let c;for(c in a)l[c]||i.del.push(c);for(c in l){const u=a[c],d=l[c];u?u.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function vo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>Go(o,s)),o}function Go(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Jo(t,e,n){const r={};return Sr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=qo(el(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return qo(l,c||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Me(c),a===0)}),s=o.shift();if(s.multi)throw new ce.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ce.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ce.Schema("Index must have a name and cannot be an empty string")}),n[r]=tl(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ue(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(i=>{Ue(o,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(o,s)}),n._dbSchema=s,Zo(n,[n._allTables,n,n.Transaction.prototype]),Ar(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ae(s),s),n._storeNames=Ae(s),this}upgrade(e){return this._cfg.contentUpgrade=Ms(this._cfg.contentUpgrade||be,e),this}}function Us(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Ut(to,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ks(t){return t&&typeof t.databases=="function"}function Xo(t){return St(function(){return ie.letThrough=!0,t()})}function Zf(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Gf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Ne(e.dbOpenError):t);lt&&(e.openCanceller._stackHolder=Ht()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ce.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():Zf()).then(()=>new oe((l,c)=>{if(o(),!n)throw new ce.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new ce.MissingAPI;d.onerror=st(c),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,i.abort(),d.result.close();const g=n.deleteDatabase(u);g.onsuccess=g.onerror=Se(()=>{c(new ce.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{i.onerror=st(c);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,Vf(t,h/10,i,c)}},c),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Sr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((g=h).length===1?g[0]:g,"readonly");e.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const _=y._dbSchema=Jo(0,m,w);y._storeNames=Sr(m.objectStoreNames,0),Ar(y,[y._allTables],Ae(_),_)}(t,p,f):(Yo(t,t._dbSchema,f),function(y,m){const w=nl(Jo(0,y.idbdb,m),y._dbSchema);return!(w.add.length||w.change.some(_=>_.add.length||_.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ho(t,f)}catch{}var g;In.push(t),p.onversionchange=Se(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),p.onclose=Se(f=>{t.on("close").fire(f)}),a&&function({indexedDB:f,IDBKeyRange:y},m){!Ks(f)&&m!==to&&Us(f,y).put({name:m}).catch(be)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(Xo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ms,be);return e.onReadyBeingFired=[],oe.resolve(Xo(()=>c(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Ne(l)}).finally(()=>{e.openComplete=!0,s()})}function Qo(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return i=>{var a=s(i),l=a.value;return a.done?l:l&&typeof l.then=="function"?l.then(n,r):Me(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function Jf(t,e,n){var r=arguments.length;if(r<2)throw new ce.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Fi(o),n]}function rl(t,e,n,r,o){return oe.resolve().then(()=>{const s=ie.transless||ie,i=t._createTransaction(e,n,t._dbSchema,r),a={trans:i,transless:s};if(r)i.idbtrans=r.idbtrans;else try{i.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===Bs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>rl(t,e,n,null,o))):Ne(d)}const l=Rs(o);let c;l&&hn();const u=oe.follow(()=>{if(c=o.call(i,i),c)if(l){var d=vt.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Qo(c))},a);return(c&&typeof c.then=="function"?oe.resolve(c).then(d=>i.active?d:Ne(new ce.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Ne(d)))})}function lr(t,e,n){const r=Me(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Vo(u),unique:!y&&p.unique};return g.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?u[0]:u.slice(0,f-1),d+1,p),g.sort((w,_)=>w.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const u of r.indexes)i(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(p=u.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:lr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:lr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:u;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(u){const d=o[Pn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:p,keyLength:h}=u.query.index;return p?n.openCursor(l(u)).then(g=>g&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(lr(m,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?f.continue(f.key.slice(0,h).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,w){f.continuePrimaryKey(lr(m,t.MAX_KEY,d),w)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const m=f.key;return h===1?m[0]:m.slice(0,h)}},value:{get:()=>f.value}})}(g)):n.openCursor(u)}}}}}};function $s(t,e,n,r){return n=n||{},r=r||"",Ae(t).forEach(o=>{if(Ze(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Ao(s);a!==Ao(i)?n[r+o]=e[o]:a==="Object"?$s(s,i,n,r+o+"."):s!==i&&(n[r+o]=e[o])}else s!==i&&(n[r+o]=e[o])}else n[r+o]=void 0}),Ae(e).forEach(o=>{Ze(t,o)||(n[r+o]=e[o])}),n}const Xf={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=ie.trans,{deleting:a,creating:l,updating:c}=i.table(e).hook;switch(s.type){case"add":if(l.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"put":if(l.fire===be&&c.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"delete":if(a.fire===be)break;return i._promise("readwrite",()=>u(s),!0);case"deleteRange":if(a.fire===be)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function u(p){const h=ie.trans,g=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!g)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:g}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(f,y,m){return y.type==="add"?Promise.resolve([]):f.getMany({trans:y.trans,keys:m,cache:"immutable"})}(n,p,g).then(f=>{const y=g.map((m,w)=>{const _=f[w],k={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(k,m,_,h);else if(p.type==="add"||_===void 0){const x=l.fire.call(k,m,p.values[w],h);m==null&&x!=null&&(m=x,p.keys[w]=m,r.outbound||nt(p.values[w],r.keyPath,m))}else{const x=$s(_,p.values[w]),O=c.fire.call(k,x,m,_,h);if(O){const E=p.values[w];Object.keys(O).forEach(N=>{Ze(E,N)?E[N]=O[N]:nt(E,N,O[N])})}}return k});return n.mutate(p).then(({failures:m,results:w,numFailures:_,lastResult:k})=>{for(let x=0;x(y.forEach(w=>w.onerror&&w.onerror(m)),Promise.reject(m)))})}function d(p,h,g){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:g}).then(({result:f})=>u({type:"delete",keys:f,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=ol(r.keys,r.trans._cache,r.cache==="clone");return o?oe.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Hn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const dt=function(t,e){if(!this){const n=new dt;return t&&"d"in t&&Ue(n,t),n}Ue(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Wn(t,e,n){const r=Le(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(qs(t))return Ue(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(Le(n,t.from)<0)return o?Wn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ea(t);if(Le(e,t.to)>0)return s?Wn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ea(t);Le(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),Le(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const i=!t.r;o&&!t.l&&Nr(t,o),s&&i&&Nr(t,s)}function Nr(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Wn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function eh(t,e){const n=es(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=es(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(Le(a.from,o.to)<=0&&Le(a.to,o.from)>=0)return!0;Le(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function es(t){let e=qs(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&Le(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||Le(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Ea(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",i={...t},a=t[o];t.from=a.from,t.to=a.to,t[o]=a[o],i[o]=a[s],t[s]=i,i.d=Ca(i)}t.d=Ca(t)}function Ca({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}un(dt.prototype,{add(t){return Nr(this,t),this},addKey(t){return Wn(this,t,t),this},addKeys(t){return t.forEach(e=>Wn(this,e,e)),this},[No](){return es(this)}});const th={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new dt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,c={...o,mutate:p=>{const h=p.trans,g=h.mutatedParts||(h.mutatedParts={}),f=O=>{const E=`idb://${e}/${r}/${O}`;return g[E]||(g[E]=new dt)},y=f(""),m=f(":dels"),{type:w}=p;let[_,k]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const x=p.trans._cache;return o.mutate(p).then(O=>{if(Me(_)){w!=="delete"&&(_=O.results),y.addKeys(_);const E=ol(_,x);E||w==="add"||m.addKeys(_),(E||k)&&function(N,P,R,$){function j(B){const b=N(B.name||"");function K(S){return S!=null?B.extractKey(S):null}const te=S=>B.multiEntry&&Me(S)?S.forEach(G=>b.addKey(G)):b.addKey(S);(R||$).forEach((S,G)=>{const z=R&&K(R[G]),Q=$&&K($[G]);Le(z,Q)!==0&&(z!=null&&te(z),Q!=null&&te(Q))})}P.indexes.forEach(j)}(f,s,E,k)}else if(_){const E={from:_.lower,to:_.upper};m.add(E),y.add(E)}else y.add(n),m.add(n),s.indexes.forEach(E=>f(E.name).add(n));return O})}},u=({query:{index:p,range:h}})=>{var g,f;return[p,new dt((g=h.lower)!==null&&g!==void 0?g:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new dt(p.key)],getMany:p=>[i,new dt().addKeys(p.keys)],count:u,query:u,openCursor:u};return Ae(d).forEach(p=>{c[p]=function(h){const{subscr:g}=ie;if(g){const f=k=>{const x=`idb://${e}/${r}/${k}`;return g[x]||(g[x]=new dt)},y=f(""),m=f(":dels"),[w,_]=d[p](h);if(f(w.name||"").add(_),!w.isPrimaryKey){if(p!=="count"){const k=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(x=>{if(p==="query"){if(l&&h.values)return k.then(({result:E})=>(y.addKeys(E),x));const O=h.values?x.result.map(a):x.result;h.values?y.addKeys(O):m.addKeys(O)}else if(p==="openCursor"){const O=x,E=h.values;return O&&Object.create(O,{key:{get:()=>(m.addKey(O.primaryKey),O.key)},primaryKey:{get(){const N=O.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(O.primaryKey),O.value)}})}return x})}m.add(n)}}return o[p].apply(this,arguments)}}),c}}}};class Ut{constructor(e,n){this._middlewares={},this.verno=0;const r=Ut.dependencies;this._options=n={addons:Ut.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:be,dbReadyPromise:null,cancelOpen:be,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new oe(a=>{s.dbReadyResolve=a}),s.openCanceller=new oe((a,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=Dn(this,"populate","blocked","versionchange","close",{ready:[Ms,be]}),this.on.ready.subscribe=Pi(this.on.ready.subscribe,a=>(l,c)=>{Ut.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||oe.resolve().then(l),c&&a(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&a(l);else{a(l);const d=this;c||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,wn(Mf.prototype,function(a,l){this.db=i;let c=Yi,u=null;if(l)try{c=l()}catch(g){u=g}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:h!==Tn?h:null}})),this.Table=function(a){return wn(Bf.prototype,function(l,c,u){this.db=a,this._tx=u,this.name=l,this.schema=c,this.hook=a._allTables[l]?a._allTables[l].hook:Dn(null,{creating:[Cf,be],reading:[Ef,Tn],updating:[Of,be],deleting:[Sf,be]})})}(this),this.Transaction=function(a){return wn(Uf.prototype,function(l,c,u,d,p){this.db=a,this.mode=l,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Dn(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new oe((h,g)=>{this._resolve=h,this._reject=g}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var g=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):g&&this.idbtrans&&this.idbtrans.abort(),Ne(h)})})}(this),this.Version=function(a){return wn(Hf.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return wn(Qi.prototype,function(l,c,u){this.db=a,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=a._deps.indexedDB;if(!d)throw new ce.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),In.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(Yf),this.use(Xf),this.use(th),this.use(Qf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ce.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ce.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(o=>o._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(qf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ie.letThrough||this._vip)?e():new oe((n,r)=>{if(this._state.openComplete)return r(new ce.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ce.DatabaseClosed);this.open().catch(be)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:o}){o&&this.unuse({stack:e,name:o});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:o}),s.sort((i,a)=>i.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(o=>r?o.create!==r:!!n&&o.name!==n)),this}open(){return Gf(this)}_close(){const e=this._state,n=In.indexOf(this);if(n>=0&&In.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new oe(r=>{e.dbReadyResolve=r}),e.openCanceller=new oe((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ce.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},c){!Ks(a)&&c!==to&&Us(a,l).delete(c).catch(be)})(this._deps,this.name),r()}),i.onerror=st(o),i.onblocked=this._fireOnBlocked};if(e)throw new ce.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ae(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Jf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=ie.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let i,a;e=e.replace("!","").replace("?","");try{if(a=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===fo)i=fo;else{if(e!="rw"&&e!=ho)throw new ce.InvalidArgument("Invalid transaction mode: "+e);i=ho}if(o){if(o.mode===fo&&i===ho){if(!s)throw new ce.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!s)throw new ce.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Ne(c)}const l=rl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ie.trans?pn(ie.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ze(this._allTables,e))throw new ce.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const nh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class rh{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[nh](){return this}}function sl(t,e){return Ae(e).forEach(n=>{Nr(t[n]||(t[n]=new dt),e[n])}),t}function oh(t){let e,n=!1;const r=new rh(o=>{const s=Rs(t);let i=!1,a={},l={};const c={get closed(){return i},unsubscribe:()=>{i=!0,It.storagemutated.unsubscribe(h)}};o.start&&o.start(c);let u=!1,d=!1;function p(){return Ae(l).some(f=>a[f]&&eh(a[f],l[f]))}const h=f=>{sl(a,f),p()&&g()},g=()=>{if(u||i)return;a={};const f={},y=function(m){s&&hn();const w=()=>St(t,{subscr:m,trans:null}),_=ie.trans?pn(ie.transless,w):w();return s&&_.then(vt,vt),_}(f);d||(It(zn,h),d=!0),u=!0,Promise.resolve(y).then(m=>{n=!0,e=m,u=!1,i||(p()?g():(a={},l=f,o.next&&o.next(m)))},m=>{u=!1,n=!1,o.error&&o.error(m),c.unsubscribe()})};return g(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let ts;try{ts={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{ts={indexedDB:null,IDBKeyRange:null}}const Ft=Ut;function gr(t){let e=ht;try{ht=!0,It.storagemutated.fire(t)}finally{ht=e}}un(Ft,{...fr,delete:t=>new Ft(t,{addons:[]}).delete(),exists:t=>new Ft(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Ks(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==to)):Us(e,n).toCollection().primaryKeys()}(Ft.dependencies).then(t)}catch{return Ne(new ce.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ie.trans?pn(ie.transless,t):t(),vip:Xo,async:function(t){return function(){try{var e=Qo(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Ne(n)}}},spawn:function(t,e,n){try{var r=Qo(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Ne(o)}},currentTransaction:{get:()=>ie.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Ft.ignoreTransaction(t):t).timeout(e||6e4);return ie.trans?ie.trans.waitFor(n):n},Promise:oe,debug:{get:()=>lt,set:t=>{Ti(t,t==="dexie"?()=>!0:Ji)}},derive:nn,extend:Ue,props:un,override:Pi,Events:Dn,on:It,liveQuery:oh,extendObservabilitySet:sl,getByKeyPath:mt,setByKeyPath:nt,delByKeyPath:function(t,e){typeof e=="string"?nt(t,e,void 0):"length"in e&&[].map.call(e,function(n){nt(t,n,void 0)})},shallowClone:Ni,deepClone:Hn,getObjectDiff:$s,cmp:Le,asap:ji,minKey:$o,addons:[],connections:In,errnames:Bs,dependencies:ts,semVer:ga,version:ga.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Ft.maxKey=Ln(Ft.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(It(zn,t=>{if(!ht){let e;eo?(e=document.createEvent("CustomEvent"),e.initCustomEvent(_t,!0,!0,t)):e=new CustomEvent(_t,{detail:t}),ht=!0,dispatchEvent(e),ht=!1}}),addEventListener(_t,({detail:t})=>{ht||gr(t)}));let ht=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(_t);typeof t.unref=="function"&&t.unref(),It(zn,e=>{ht||t.postMessage(e)}),t.onmessage=e=>{e.data&&gr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){It(zn,e=>{try{ht||(typeof localStorage<"u"&&localStorage.setItem(_t,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:_t,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===_t){const n=JSON.parse(e.newValue);n&&gr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===_t&&gr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof rn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!pa[t.name])return t;var n=new pa[t.name](e||t.message,t);return"stack"in t&&pt(n,"stack",{get:function(){return this.inner.stack}}),n},Ti(lt,Ji);var sh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t))(sh||{}),wr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(wr||{});const ah="comfyui_workspace_db";class ih extends Ut{constructor(){super(ah);Ie(this,"workflows");Ie(this,"changelogs");Ie(this,"media");Ie(this,"folders");Ie(this,"tags");Ie(this,"userSettings");Ie(this,"models");Ie(this,"cache");Ie(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ue=new ih,lh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=lh[n[t]&63];return e};class Zt{constructor(e){Ie(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ue[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")}),af(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=ns()),e.createTime||(e.createTime=Date.now()),await ue[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ue[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ue[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ue[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ue[this.tableName].toArray()}async batchQuery(e){return await ue[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await sf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await hf()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ue[this.tableName].get(e)}async delete(e){await ue[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await ue[this.tableName].where(e).equals(n).toArray()}}const ch=150,Tr=class Tr extends Zt{constructor(){super("changelogs")}static async load(){return new Tr}async listByWorkflowID(e){return await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:Fn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return this.deleteLogsExceedLimit(e.workflowID),await ue.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e){const n=await ue.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=await(Z==null?void 0:Z.getSetting("maximumChangelogNumber"))??ch;if(n.length>r){const o=n.slice(r);await ue.changelogs.bulkDelete(o.map(s=>s.id)),await this.saveDiskDB()}}};Ie(Tr,"TABLE_NAME","changelogs");let rs=Tr;const zp="CWM_WORKFLOWS_SORT_TYPE";var kt=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(kt||{});const Lp=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],uh="comfyspace_tracking",Fr="workspace_info",dh=9999999,go="upgrade_to_2way_sync",al=29;function br(...t){const e=t.filter(n=>n!=="").join("/");return Dt(e)}function Dt(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function wo(t){return br(t.parentFolderID??"",t.name+".json")}var xt;(t=>{async function e({parentFolderID:a,name:l}){return Dt(`${a??""}/${l}`)}t.genFolderRelPath=e;async function n(a){await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(a.id)})})}t.createFolder=n;async function r(a,l){const u=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();u.error&&alert("Failed to move folder: "+u.error)}t.moveFolder=r;async function o(a){try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).text()}catch(l){console.error("Error deleting file:",l)}}t.deleteFolder=o;async function s(a){try{const c=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return c.error&&console.error("Error counting files:",c.error),c.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const u=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();u.error&&alert("Failed to rename folder: "+u.error)}catch(c){console.error("Error renaming file:",c)}}t.renameFolder=i})(xt||(xt={}));async function kn(t){const e=await Vs(t);if(e==null)return;const n=await il(t);await(q==null?void 0:q.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Fr]={id:t.id,name:t.name},delete o.extra[uh],await lf(e,JSON.stringify(o))}async function bo(t){if(t.name==null)return;const e=await Vs(t);e!=null&&Ii(e)}async function Vs(t){let e=hh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function fh(t){let e="",n=t;for(;n!=null;){const r=await(ze==null?void 0:ze.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function il(t){const e=await Vs(t);let n=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function Wp(t){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await xt.genFilesCountInFolder(t)??0;const n=await(q==null?void 0:q.listAll())??[],r=await(ze==null?void 0:ze.listAll())??[],o=[t];let s=0;for(;o.length>0;){const i=o.shift();if(i){for(const l of n)l.parentFolderID===i&&s++;const a=r.filter(l=>l.parentFolderID===i).map(l=>l.id);a.length&&o.push(...a)}}return s}function hh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function ll(t,e=!0,n=!1){const r=new Date(t),o=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0"),i=r.getFullYear(),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=String(r.getSeconds()).padStart(2,"0"),u=`${s}-${o}-${i}`;return e?u+` ${a}:${l}`:n?u+`:${c}`:u}async function cl(t=!1){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return;const n=await(q==null?void 0:q.listAll())??[];for(const r of n){const o=await il(r);r.filePath!=o&&(r.filePath!=null&&await Ii(r.filePath,t),await kn(r))}}const ul=(t,e=kt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case kt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case kt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case kt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case kt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n};function ph(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{const e=await(Z==null?void 0:Z.getSetting("shortcuts"))??(Z==null?void 0:Z.defaultSettings.shortcuts);if(!e)return!1;for(const n in e){const o=e[n].split("+"),s={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const i in s)s[i]||delete s[i];if(o.length===Object.keys(s).length&&o.every(i=>s[i]))return n}};function $p(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function mh(t){return`/workspace/view_media?filename=${t}`}function Sa(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function dl(t){const e=window.location.hash.slice(1).split("/"),n=e.findIndex(o=>o.includes("workspaceId@")),r=`workspaceId@${t}`;return n>=0?e[n]=r:e.push(r),`${e.join("/")}`}const yh=t=>{const e=dl(t);window.open(`${window.location.origin}/#${e}`)},_r={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Je;(t=>{async function e(l,c){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),newParentPath:c})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(u){console.error("Error deleting file:",u)}}t.moveWorkflow=e;async function n(l,c){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(c??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(u){console.error("Error deleting file:",u)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:c},u){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:br(l??"",c+".json"),newName:u})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const c=l.json,u=JSON.parse(c);u.extra[Fr]={id:l.id};const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:wo(l),json:JSON.stringify(u)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} + + 👉Please try "Save as" from "Files" dropdown menu + `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:wo(l),deleteEmptyFolder:!1})})).text()}catch(c){alert("Error deleting workflow .json file: "+c),console.error("Error deleting file:",c)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:c,json:u,id:d}){var g;let p=JSON.parse(u);p={...p,extra:{[Fr]:{id:d}}};const h={parentFolderPath:Dt(l??""),name:c,json:JSON.stringify(p)};console.log("createWorkflow",h);try{const y=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).json();return y.name&&await((g=ue.workflows)==null?void 0:g.update(d,{name:y.name})),y}catch(f){return console.error(`Error creating file <${d}> at "${l}"`,f),alert(`Error creating file <${d}> at "${l}"`),{}}}t.createWorkflow=i;async function a({parentFolderID:l,name:c,id:u}){const d=br(l??"",c+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:u})})).json();return h.error&&(console.error(`Error getting file <${u}> at "${d}"`,h.error),alert({message:`Error getting file <${u}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${u}> at "${d}"`,p),{}}}t.getFile=a})(Je||(Je={}));async function fl(t,e=!1,n=!1){try{return await(await fetch("/workspace/file/scan_my_workflows_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Dt(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function vh(t,e){const n=Dt(t??""),o=(await fl(n)).map(async a=>{var u;const l=a.name,c=[n,l].join("/");return gh(a)?{id:Dt(c),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((u=ue.workflows)==null?void 0:u.get(a.id))??{createTime:Date.now(),updateTime:Date.now()},id:a.id,lastSavedJson:a.json??"{}",json:a.json??"{}",name:l.replace(/\.json$/,""),parentFolderID:n,createTime:a.createTime}}),s=await Promise.all(o);ue.workflows.bulkPut(s.filter(a=>!Oh(a)));const i=s.filter(a=>a!=null);return ul(i,e??kt.RECENTLY_MODIFIED)}function gh(t){return"type"in t&&t.type==="folder"}const Br=class Br extends Zt{constructor(){super("workflows");Ie(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Br}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ue.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Promise.all(o.map(async a=>await this.get(a.id)))).filter(a=>a!=null):o}async generateUniqueName(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){const l=await Je.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,c=!0;for(;c;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ns(),json:n.json??JSON.stringify(_r),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ue.workflows.add(i),this.saveDiskDB(),await(Z==null?void 0:Z.getSetting("twoWaySync"))?(await Je.createWorkflow(i),await this.get(i.id)):(kn(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ue.workflows.update(n,r);const o=await ue.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Je.moveWorkflow(s,r.parentFolderID):(await kn(i),await bo(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ue.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ve==null?void 0:Ve.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(Z==null?void 0:Z.getSetting("twoWaySync"))&&o&&await Je.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),i=JSON.stringify(r.json);if(s===i)return;const a=await this._update(n,{updateTime:Date.now(),json:r.json});await(Z==null?void 0:Z.getSetting("twoWaySync"))?a&&await Je.saveWorkflow(a):a&&await kn(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const c=l.name&&r?l.name:await this.generateUniqueName(l.name,o),u=ns(),d=Date.now(),p={id:u,name:c,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(Z==null?void 0:Z.getSetting("twoWaySync")))try{const g=JSON.parse(l.json),f=(a=(i=g==null?void 0:g.extra)==null?void 0:i[Fr])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Je.createWorkflow(p)}catch(g){console.error("batchCreateFlows error",g)}else await kn(p)}try{await ue.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(r):bo({...r})),await ue.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ue.workflows.bulkGet(n);for(const o of r){if(!o)return;await(Z==null?void 0:Z.getSetting("twoWaySync"))?await Je.deleteWorkflow(o):bo({...o})}await ue.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await vh(n??null);const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],i=await(ze==null?void 0:ze.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],a=[...s,...i];return ul(a,r??kt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(Z==null?void 0:Z.getSetting("twoWaySync")),s=await ue.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Je.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}};Ie(Br,"TABLE_NAME","workflows");let os=Br;const Mr=class Mr extends Zt{constructor(){super("folders")}static async load(){return new Mr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(Z==null?void 0:Z.getSetting("twoWaySync")),o=await xt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Fn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await xt.createFolder(s):(await ue.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return"parentFolderID"in n&&await xt.moveFolder(e,n.parentFolderID??""),"name"in n&&await xt.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,i="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,a={...o,...n};return n.name!=null&&(a.updateTime=Date.now()),i&&(n.name=await this.generateUniqueName(a.name,a.parentFolderID??void 0)),await ue.folders.update(e,n),this.saveDiskDB(),(s||i)&&cl(!0),a}async deleteFolder(e,n=wr.DELETE){if(await(Z==null?void 0:Z.getSetting("twoWaySync"))){await fl(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(q==null||q.deleteFlow(l.id))})}),await xt.deleteFolder(e);return}const o=await(q==null?void 0:q.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const c of o)if(c.parentFolderID===a)switch(n){case wr.DELETE:await(q==null?void 0:q.deleteFlow(c.id));break;case wr.MOVE_TO_ROOT_FOLDER:await(q==null?void 0:q.updateFolder(c.id,{parentFolderID:void 0}));break}await ue.folders.delete(a);const l=s.filter(c=>c.parentFolderID===a).map(c=>c.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(Z==null?void 0:Z.getSetting("twoWaySync")))return await Je.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(i=>i.filter(a=>a.parentFolderID==n).map(a=>a.name));if(s.includes(o)){let i=2,a=!0;for(;a;)s.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,a=!1)}return o}};Ie(Mr,"TABLE_NAME","folders");let ss=Mr;function wh(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=o=>{const s=new Uint8Array(o.target.result),i=new DataView(s.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),n());let a=8;const l={};for(;aString.fromCharCode(f)).join("");l[p]=g}a+=12+c}e(l)},r.readAsArrayBuffer(t)})}function bh(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const c=t.slice(i,i+l);if(l===2)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint16(0,a);if(l===4)return new DataView(c.buffer,c.byteOffset,c.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let c=0;c{const n=new FileReader;n.onload=r=>{var l;const o=new Uint8Array((l=r==null?void 0:r.target)==null?void 0:l.result),s=new DataView(o.buffer);if(s.getUint32(0)!==1380533830||s.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),e();return}let i=12;const a={};for(;i{const n=new FileReader;n.onload=r=>{const o=new Uint8Array(r.target.result),s=new DataView(o.buffer),i=new TextDecoder;if(s.getUint32(0)==440786851){let a=12;for(;a>8*(4-u)&~(1<<7*u),p=i.decode(o.slice(a+2+u,a+2+u+d)),h=JSON.parse(p);e(h);return}}a+=1}}else if(s.getUint32(4)==1718909296&&s.getUint32(8)==1769172845){let a=o.length-4;for(;a>16;){if(s.getUint32(a)==1684108385&&s.getUint32(a-8)==2841865588){s.getUint32(a+4),s.getUint32(a+8);const l=s.getUint32(a-4)-4*4,c=i.decode(o.slice(a+12,a+12+l)),u=JSON.parse(c);e(u);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Eh(t){const e=t.split(".").pop();return fetch(t).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const r=t.split("/").pop()??"",o=new File([n],r);if(kh(t))return xh(o);if(e==="webp")return _h(o);const s=await wh(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}function qp(){return LiteGraph.registered_node_types}class hl extends Zt{constructor(){super("media")}async listByWorkflowID(e){return await ue.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r=await Eh(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:Fn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await(q==null?void 0:q.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ue.media.add(o),this.saveDiskDB(),o}}Ie(hl,"TABLE_NAME","media");const Vp=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Ch={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Hp(t){return t.modelVersions!==void 0}function Sh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function Zp(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Sh(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(a=(i=t.files)==null?void 0:i[0])==null?void 0:a.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const zr=class zr extends Zt{constructor(){super("userSettings");Ie(this,"defaultSettings");Ie(this,"DEFAULT_USER","guest");Ie(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S"},defaultFolders:Ch,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:200}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new zr,r=await cf();return n.defaultSettings.myWorkflowsDir=r.path,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};Ie(zr,"TABLE_NAME","userSettings");let as=zr;const Lr=class Lr extends Zt{constructor(){super("tags")}static async load(){return new Lr}};Ie(Lr,"TABLE_NAME","tags");let is=Lr;const Wr=class Wr extends Zt{constructor(){super("workflowVersions")}static async load(){return new Wr}async listByWorkflowID(e){return await ue[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Ie(Wr,"TABLE_NAME","workflowVersions");let ls=Wr;function Oh(t){return"type"in t&&t.type==="folder"}let q=null,kr=null,Z=null,ze=null,Ve=null,Kt=null,we=null;async function Ih(){const t=async()=>{q=await os.load()},e=async()=>{kr=await is.load()},n=async()=>{Z=await as.load()},r=async()=>{ze=await ss.load()},o=async()=>{Ve=await rs.load()},s=async()=>{Kt=new hl},i=async()=>{we=await ls.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Dh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Dh(){const t=async()=>{try{const a=await(q==null?void 0:q.getRecords());a&&await ue.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(ze==null?void 0:ze.getRecords());a&&await ue.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Kt==null?void 0:Kt.getRecords());a&&await ue.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(Ve==null?void 0:Ve.getRecords());a&&await ue.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(kr==null?void 0:kr.getRecords());a&&await ue.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=Z,l=await a.getRecords().then(c=>c[a.DEFAULT_USER]?c[a.DEFAULT_USER]:c);await ue.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(we==null?void 0:we.getRecords());a&&await ue.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const At=A.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),Gp=A.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),_o={x:0,y:0};function Ph({children:t,onDragEnd:e,dragIconId:n}){const r=A.useRef(_o),o=A.useRef(!1),[s,i]=A.useState(_o),a=d=>{var p,h,g;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(g=(h=d.target)==null?void 0:h.parentNode)==null?void 0:g.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=A.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),c=A.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),_o)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return D.jsx("div",{style:u,onMouseDown:a,children:t})}var jh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ah=Object.defineProperty,Nh=Object.defineProperties,Fh=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,pl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,Oa=(t,e,n)=>e in t?Ah(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ia=(t,e)=>{for(var n in e||(e={}))pl.call(e,n)&&Oa(t,n,e[n]);if(Rr)for(var n of Rr(e))ml.call(e,n)&&Oa(t,n,e[n]);return t},Rh=(t,e)=>Nh(t,Fh(e)),Th=(t,e)=>{var n={};for(var r in t)pl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Rr)for(var r of Rr(t))e.indexOf(r)<0&&ml.call(t,r)&&(n[r]=t[r]);return n},Fe=(t,e,n)=>{const r=A.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:c=2,children:u}=i,d=Th(i,["color","size","stroke","children"]);return A.createElement("svg",Ia(Rh(Ia({ref:s},jh),{width:l,height:l,stroke:a,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>A.createElement(p,h)),...u||[]])});return r.propTypes={color:Nt.string,size:Nt.oneOfType([Nt.string,Nt.number]),stroke:Nt.oneOfType([Nt.string,Nt.number])},r.displayName=`${e}`,r},Bh=Fe("arrow-back-up-double","IconArrowBackUpDouble",[["path",{d:"M13 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M8 14l-4 -4l4 -4",key:"svg-1"}],["path",{d:"M9 10h7a4 4 0 1 1 0 8h-1",key:"svg-2"}]]),Mh=Fe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),cs=Fe("device-floppy","IconDeviceFloppy",[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]]),zh=Fe("download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]),Lh=Fe("external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]]),Wh=Fe("folder","IconFolder",[["path",{d:"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2",key:"svg-0"}]]),Uh=Fe("grip-vertical","IconGripVertical",[["path",{d:"M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]]),Kh=Fe("history","IconHistory",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),$h=Fe("link","IconLink",[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]]),yl=Fe("lock","IconLock",[["path",{d:"M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z",key:"svg-0"}],["path",{d:"M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-4a4 4 0 1 1 8 0v4",key:"svg-2"}]]),qh=Fe("photo","IconPhoto",[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12z",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]]),Vh=Fe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Hh=Fe("share-2","IconShare2",[["path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M12 14v-11",key:"svg-1"}],["path",{d:"M9 6l3 -3l3 3",key:"svg-2"}]]),Zh=Fe("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]),vl=Fe("triangle-inverted-filled","IconTriangleInvertedFilled",[["path",{d:"M20.118 3h-16.225a2.914 2.914 0 0 0 -2.503 4.371l8.116 13.549a2.917 2.917 0 0 0 4.987 .005l8.11 -13.539a2.914 2.914 0 0 0 -2.486 -4.386z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),Gh=Fe("versions","IconVersions",[["path",{d:"M10 5m0 2a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]]),Jh=Fe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),Yh=Fe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Xh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return D.jsx(mi,{isLazy:!0,placement:"auto",children:({onClose:i})=>D.jsxs(D.Fragment,{children:[D.jsx(pi,{children:D.jsx(Ct,{children:D.jsx(zt,{hasArrow:!0,label:s,placement:"bottom",children:D.jsx(jn,{"aria-label":"Delete confirm",size:"sm",icon:D.jsx(Zh,{color:"#F56565"}),isDisabled:o,variant:n})})})}),D.jsxs(bi,{children:[D.jsx(yi,{}),D.jsx(gi,{onClick:i}),D.jsxs(vi,{children:[D.jsx(Bt,{mb:4,pr:4,fontWeight:600,children:e}),D.jsx(We,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function Qh({onClose:t}){Ta();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=A.useContext(At),[s,i]=A.useState(0),[a,l]=A.useState(null),[c,u]=A.useState([]),[d,p]=A.useState([]),h=async y=>{var x;const m=await(q==null?void 0:q.get(y)),w=await(Ve==null?void 0:Ve.listByWorkflowID(y));u(w??[]);const _=w==null?void 0:w.filter(O=>O.json===(m==null?void 0:m.json)),k=(x=_==null?void 0:_[0])==null?void 0:x.id;k&&l(k)},g=async()=>{const y=await(we==null?void 0:we.listByWorkflowID(e))??[];p(y)},f=y=>{we==null||we.delete(y).then(()=>{g()})};return A.useEffect(()=>{switch(s){case 0:g();break;case 1:h(e);break}},[s]),A.useEffect(()=>(xe.canvasEl.addEventListener("click",t),()=>{xe.canvasEl.removeEventListener("click",t)}),[s]),D.jsxs(nc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[D.jsx(tc,{pb:1,mb:0,children:D.jsxs(xn,{justifyContent:"space-between",alignItems:"center",children:[D.jsx(_s,{size:"md",children:"Version History"}),D.jsx(jn,{size:"sm",icon:D.jsx(Yh,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),D.jsx(ec,{overflowY:"auto",gap:0,children:D.jsxs(xi,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[D.jsxs(Ei,{mb:"1em",children:[D.jsx(Do,{children:"Versions"}),D.jsx(Do,{children:"Change History"})]}),D.jsxs(Ci,{children:[D.jsx(Io,{children:D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:d==null?void 0:d.map(y=>D.jsxs(xn,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[D.jsxs(tn,{textAlign:"left",gap:0,children:[D.jsx(Bt,{fontWeight:"500",children:y.name??"untitled"}),D.jsxs(Bt,{color:"GrayText",fontSize:"sm",children:["Created: ",ll(y.createTime)]})]}),D.jsxs(xn,{alignItems:"center",gap:2,children:[D.jsx(We,{size:"sm",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),D.jsx(Xh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),D.jsxs(Io,{children:[D.jsx(Bt,{mb:4,children:"All the saved changes of this workflow"}),D.jsx(tn,{divider:D.jsx(Eo,{}),spacing:2,children:c==null?void 0:c.map(y=>D.jsxs(Et,{justifyContent:"space-between",children:[D.jsxs(We,{size:"sm",variant:"ghost",onClick:()=>{if(n){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}xe.loadGraphData(JSON.parse(y.json)),q==null||q.updateFlow(e,{json:y.json}),t()},isActive:y.id===a,children:["Saved at ",new Date(y.createTime).toLocaleString()]},y.id),y.isAutoSave?D.jsx(Qr,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function ep({workflowId:t,onClose:e}){const[n,r]=A.useState(""),[o,s]=A.useState(""),i=l=>{r(l.target.value),o&&s("")},a=async()=>{const l=n.trim();if(r(l),(await(we==null?void 0:we.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(xe.graph.serialize());await(we==null?void 0:we.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return D.jsxs(fs,{isOpen:!0,onClose:e,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Create Version"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!o,children:[D.jsx(Hr,{children:"Name"}),D.jsx(Kn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&D.jsx(Vr,{children:o})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),D.jsx(We,{onClick:e,children:"Cancel"})]})]})]})}function tp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=A.useRef(null);return Oc({ref:o,handler:()=>r()}),D.jsxs(Ct,{position:"relative",children:[D.jsx(Ct,{children:e}),n&&D.jsx(Ct,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function np({menuButton:t,menuContent:e,onClose:n}){const r=A.useRef(),[o,s]=A.useState(!1),i=()=>{r.current=setTimeout(()=>s(!1),400)},a=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return D.jsx(tp,{isOpen:o,onClose:i,menuButton:D.jsx(Ct,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:D.jsx(As,{isOpen:!0,children:D.jsx(Ns,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const rp=A.lazy(()=>Un(()=>import("./ShareDialog-MoNpT1nG.js"),__vite__mapDeps([0,1,2,3,4])));function op(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=A.useContext(At),[i,a]=A.useState(!1),[l,c]=A.useState(""),[u,d]=A.useState(""),[p,h]=A.useState(),[g,f]=A.useState({save:"",saveAs:""}),[y,m]=A.useState(!1);A.useEffect(()=>{t&&(q==null||q.get(t).then(O=>{c((O==null?void 0:O.name)??""),h(O)})),Z==null||Z.getSetting("shortcuts").then(O=>{f(O)})},[t]);const w=O=>{c(O.target.value),u&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const O=JSON.stringify(xe.graph.serialize()),E=await(q==null?void 0:q.createFlow({json:O,lastSavedJson:O,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));E&&await e(E.id,null,!0),k()},k=()=>{o("root")},x=A.useCallback(async()=>{const O=q==null?void 0:q.curWorkflow;if(!O){alert("No current workflow!");return}const E=xe.graph.serialize(),N=JSON.stringify(E),P=new Blob([N],{type:"application/json"}),R=URL.createObjectURL(P),$=document.createElement("a");$.href=R,$.download=`${O.name}.json`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(R)},[t]);return A.useCallback(async()=>{console.log("app.graph",xe.graph);const O=xe.graph.serialize();console.log("graph serialize",O)},[]),D.jsxs(D.Fragment,{children:[D.jsx(np,{menuButton:D.jsx(Na,{children:D.jsxs(We,{px:1,height:al+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",D.jsx(Mh,{size:20})]})}),menuContent:D.jsx(As,{isOpen:!0,children:D.jsxs(Ns,{minWidth:150,zIndex:1e3,children:[D.jsx(gt,{onClick:r,icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.save,children:"Save"}),!(Z!=null&&Z.autoSave)&&D.jsx(zt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:D.jsx(gt,{onClick:n,icon:D.jsx(Bh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),D.jsx(gt,{onClick:x,icon:D.jsx(zh,{size:20}),iconSpacing:1,children:"Download"}),D.jsx(gt,{onClick:()=>o("saveAsModal"),icon:D.jsx(cs,{size:20}),iconSpacing:1,command:g.saveAs,children:"Save As"}),D.jsx(gt,{onClick:()=>a(!0),icon:D.jsx(Gh,{size:20}),iconSpacing:1,children:"Create Version"}),D.jsx(gt,{onClick:()=>o("versionHistory"),icon:D.jsx(Kh,{size:20}),iconSpacing:1,children:"Versions History"}),D.jsx(gt,{onClick:()=>m(!0),icon:D.jsx(Hh,{size:20}),iconSpacing:1,alignItems:"center",children:D.jsxs(Et,{children:[D.jsx("p",{children:"Share"})," ",D.jsx(Qr,{size:"sm",children:"🧪🧪beta"})]})})]})})}),y&&D.jsx(rp,{onClose:()=>m(!1)}),s=="versionHistory"&&D.jsx(Qh,{onClose:()=>o("root")}),s==="saveAsModal"&&D.jsxs(fs,{isOpen:!0,onClose:k,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Save As"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!u,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:l,onChange:w,autoFocus:!0,onKeyUp:O=>{O.code==="Enter"&&!u&&l&&_()}}),u&&D.jsx(Vr,{children:u})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!u,children:"Save"}),D.jsx(We,{onClick:k,children:"Cancel"})]})]})]}),i&&D.jsx(ep,{workflowId:t,onClose:()=>a(!1)})]})}function sp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Pc(),{curFlowID:i}=A.useContext(At),[a,l]=A.useState(t),[c,u]=A.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),c&&u("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return g();await(q==null?void 0:q.generateUniqueName(y,((f=q.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?u("The name is duplicated, please modify it and submit again."):(await(q==null?void 0:q.updateName(i,{name:y})),e(y),g())}},g=()=>{u(""),s()};return i==null?null:D.jsxs(Et,{children:[D.jsx(zt,{label:t,placement:"bottom",children:D.jsxs(Bt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[D.jsx("div",{style:{width:8,display:"inline-block"},children:D.jsx(Bt,{as:"span",children:n&&"* "})}),t]})}),D.jsxs(fs,{isOpen:r,onClose:g,children:[D.jsx(hs,{}),D.jsxs(ps,{children:[D.jsx(ms,{children:"Edit workflow name"}),D.jsx(ys,{}),D.jsx(vs,{children:D.jsxs(qr,{isInvalid:!!c,children:[D.jsx(Hr,{children:"Workflow name"}),D.jsx(Kn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!c&&a&&h()}}),c&&D.jsx(Vr,{children:c})]})}),D.jsxs(gs,{children:[D.jsx(We,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!c,children:"Save"}),D.jsx(We,{onClick:g,children:"Cancel"})]})]})]})]})}function Jp(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const Yp=[{label:"Private",value:"PRIVATE",icon:D.jsx(yl,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:D.jsx($h,{})},{label:"Public",value:"PUBLIC",icon:D.jsx(Jh,{})}],Xp=()=>{const t=xe.graph._nodes,e={};for(let n of t)if(n.type in LiteGraph.registered_node_types){const r=structuredClone(LiteGraph.registered_node_types[n.type].nodeData);if(r==null)continue;for(let o in r.input){const s=r.input[o];for(let i in s){const a=s[i];Array.isArray(a[0])&&(a[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function ap(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Qp({privacy:t,showEmoji:e=!1}){let n;return t==="PRIVATE"?(n="Private",e&&(n="🔒 Private")):t==="UNLISTED"?(n="Unlisted",e&&(n="🔗 Unlisted")):t==="PUBLIC"&&(n="Public",e&&(n="🌐 Public")),D.jsx("span",{children:n})}function ip({}){const[t,e]=A.useState(),[n,r]=A.useState(),{curFlowID:o}=A.useContext(At);return A.useEffect(()=>{o&&(q==null||q.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),ap(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?D.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:D.jsx(Na,{children:D.jsx(Qr,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function lp({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=A.useContext(At);return A.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?D.jsx(xn,{alignItems:"center",children:D.jsx(La,{size:"sm",isAttached:!0,variant:"outline",children:D.jsx(We,{rightIcon:D.jsx(vl,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const cp=A.lazy(()=>Un(()=>import("./ModelManagerTopbar-4fKW20g4.js").then(t=>t.M),__vite__mapDeps([5,1,6,2,7,8])));function up({curFlowName:t,setCurFlowName:e}){var u;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i}=A.useContext(At),[a,l]=A.useState(),c=A.useCallback((d,p=!1)=>{const{top:h=0,left:g=0}=a||{};let{top:f=0,left:y=0}=d??{};f+=h,y+=g;const m=document.documentElement.clientWidth,w=document.documentElement.clientHeight,_=document.getElementById("workspaceManagerPanel"),k=(_==null?void 0:_.offsetWidth)||392;f+36>w&&(f=w-36),y+k>=m&&(y=m-k),l({top:Math.max(0,f),left:Math.max(0,y)}),p&&(Z==null||Z.upsert({topBarStyle:{top:f,left:y}}))},[a]);return A.useEffect(()=>{Z==null||Z.getSetting("topBarStyle").then(d=>{c(d,!1)})},[]),a?D.jsx(Ph,{onDragEnd:d=>{c({top:d.y,left:d.x},!0)},dragIconId:"dragPanelIcon",children:D.jsxs(Et,{style:{padding:2,position:"fixed",...a},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[D.jsx(We,{size:"sm","aria-label":"workspace folder",onClick:()=>s("recentFlows"),px:2,children:D.jsxs(Et,{gap:1,children:[D.jsx(Wh,{size:21}),D.jsx(vl,{size:8})]})}),D.jsx(cp,{}),D.jsx(zt,{label:"New workflow",children:D.jsx(We,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:al+"px",onClick:()=>r(),px:2,py:2,children:D.jsx(Et,{gap:0,children:D.jsx(Vh,{size:16,color:"white"})})})}),D.jsx(sp,{isDirty:n,displayName:t??"",updateFlowName:d=>{e(d),requestAnimationFrame(()=>{c()})}}),((u=q==null?void 0:q.curWorkflow)==null?void 0:u.saveLock)&&D.jsx(yl,{color:"#FFF",size:20}),i&&D.jsxs(Et,{gap:"4px",children:[D.jsx(zt,{label:"Open gallery",children:D.jsx(jn,{onClick:()=>s("gallery"),icon:D.jsx(qh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),D.jsx(op,{})]}),i&&n?D.jsx(zt,{label:"Save workflow",children:D.jsx(jn,{onClick:o,icon:D.jsx(cs,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):D.jsx("div",{style:{width:1}}),D.jsx(ip,{}),D.jsx(lp,{}),D.jsx(Uh,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})}):null}function dp(){const{showDialog:t}=Fa(),{loadWorkflowID:e}=A.useContext(At),n=async(o,s)=>{var c,u;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(c=await(q==null?void 0:q.listByIndex("cloudID",i.id)))==null?void 0:c.at(0);if(l){const d=(u=await(we==null?void 0:we.listByIndex("cloudID",a.id)))==null?void 0:u.at(0);if(d)await e(l.id,d.id);else{const p=await(we==null?void 0:we.add({id:a.id,cloudID:a.id,workflowID:l.id,cloudOrigin:s,name:a.name,authorID:a.authorID,json:a.json}));p&&e(l.id,p.id)}}else{const d=await(q==null?void 0:q.createFlow({cloudID:i.id,cloudOrigin:s,name:i.name,json:a.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}const p=await(we==null?void 0:we.put({id:a.id,cloudID:a.id,workflowID:d.id,cloudOrigin:s,name:a.name,json:a.json,authorID:a.authorID,createTime:Date.now()}));await e(d.id,p==null?void 0:p.id)}},r=async o=>{const s=o.data;if(fp(s)){const i=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${i}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,i)}}])}};return A.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function fp(t){return t.type==="workspace_open_workflow"}const hp=t=>typeof t=="function",pp=t=>{const[e,n]=A.useState(t),r=A.useRef(e),o=A.useCallback(s=>{r.current=hp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function cr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var gl={exports:{}};/*! + +JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/(function(t,e){(function(n){t.exports=n()})(function(){return function n(r,o,s){function i(c,u){if(!o[c]){if(!r[c]){var d=typeof cr=="function"&&cr;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[c]={exports:{}};r[c][0].call(h.exports,function(g){var f=r[c][1][g];return i(f||g)},h,h.exports,n,r,o,s)}return o[c].exports}for(var a=typeof cr=="function"&&cr,l=0;l>2,h=(3&c)<<4|u>>4,g=1<_?(15&u)<<2|d>>6:64,f=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(h)+a.charAt(g)+a.charAt(f));return y.join("")},o.decode=function(l){var c,u,d,p,h,g,f=0,y=0,m="data:";if(l.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var w,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,u=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(g=a.indexOf(l.charAt(f++))),w[y++]=c,h!==64&&(w[y++]=u),g!==64&&(w[y++]=d);return w}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,p,h,g){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=g}c.prototype={getContentWorker:function(){var u=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,p){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u[f])];return-1^c}(0|l,a,a.length,0):function(c,u,d,p){var h=i,g=p+d;c^=-1;for(var f=p;f>>8^h[255&(c^u.charCodeAt(f))];return-1^c}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function u(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new u("Deflate",d)},o.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,g){var f,y="";for(f=0;f>>=8;return y}function i(h,g,f,y,m,w){var _,k,x=h.file,O=h.compression,E=w!==c.utf8encode,N=a.transformTo("string",w(x.name)),P=a.transformTo("string",c.utf8encode(x.name)),R=x.comment,$=a.transformTo("string",w(R)),j=a.transformTo("string",c.utf8encode(R)),B=P.length!==x.name.length,b=j.length!==R.length,K="",te="",S="",G=x.dir,z=x.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};g&&!f||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var M=0;g&&(M|=8),E||!B&&!b||(M|=2048);var T=0,ne=0;G&&(T|=16),m==="UNIX"?(ne=798,T|=function(H,fe){var ye=H;return H||(ye=fe?16893:33204),(65535&ye)<<16}(x.unixPermissions,G)):(ne=20,T|=function(H){return 63&(H||0)}(x.dosPermissions)),_=z.getUTCHours(),_<<=6,_|=z.getUTCMinutes(),_<<=5,_|=z.getUTCSeconds()/2,k=z.getUTCFullYear()-1980,k<<=4,k|=z.getUTCMonth()+1,k<<=5,k|=z.getUTCDate(),B&&(te=s(1,1)+s(u(N),4)+P,K+="up"+s(te.length,2)+te),b&&(S=s(1,1)+s(u($),4)+j,K+="uc"+s(S.length,2)+S);var Y="";return Y+=` +\0`,Y+=s(M,2),Y+=O.magic,Y+=s(_,2),Y+=s(k,2),Y+=s(Q.crc32,4),Y+=s(Q.compressedSize,4),Y+=s(Q.uncompressedSize,4),Y+=s(N.length,2),Y+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Y+N+K,dirRecord:d.CENTRAL_FILE_HEADER+s(ne,2)+Y+s($.length,2)+"\0\0\0\0"+s(T,4)+s(y,4)+N+K+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function p(h,g,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=y,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(h){var g=h.meta.percent||0,f=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var g=this.streamFiles&&!h.file.dir;if(g){var f=i(h,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var g=this.streamFiles&&!h.file.dir,f=i(h,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:function(y){return d.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new c(d):i.uint8array?new u(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,f){return new u.Promise(function(y,m){var w=[],_=g._internalType,k=g._outputType,x=g._mimeType;g.on("data",function(O,E){w.push(O),f&&f(E)}).on("error",function(O){w=[],m(O)}).on("end",function(){try{var O=function(E,N,P){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),P);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(k,function(E,N){var P,R=0,$=null,j=0;for(P=0;P"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(g){var f,y,m,w,_,k=g.length,x=0;for(w=0;w>>6:(y<65536?f[_++]=224|y>>>12:(f[_++]=240|y>>>18,f[_++]=128|y>>>12&63),f[_++]=128|y>>>6&63),f[_++]=128|63&y);return f}(h)},o.utf8decode=function(h){return i.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(g){var f,y,m,w,_=g.length,k=new Array(2*_);for(f=y=0;f<_;)if((m=g[f++])<128)k[y++]=m;else if(4<(w=c[m]))k[y++]=65533,f+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,k[y++]=56320|1023&m)}return k.length!==y&&(k.subarray?k=k.subarray(0,y):k.length=y),s.applyFromCharCode(k)}(h=s.transformTo(i.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var g=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var y=function(w,_){var k;for((_=_||w.length)>w.length&&(_=w.length),k=_-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?_:k+c[w[k]]>_?k:_}(g),m=g;y!==g.length&&(i.uint8array?(m=g.subarray(0,y),this.leftOver=g.subarray(y,g.length)):(m=g.slice(0,y),this.leftOver=g.slice(y,g.length))),this.push({data:o.utf8decode(m),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(f){return f}function u(f,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var g,f,y,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[y++]=224|h>>>12:(p[y++]=240|h>>>18,p[y++]=128|h>>>12&63),p[y++]=128|h>>>6&63),p[y++]=128|63&h);return p},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,g=p.length;h>10&1023,w[g++]=56320|1023&f)}return u(w,g)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var c=65535&s|0,u=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,c){var u=s,d=c+l;i^=-1;for(var p=c;p>>8^u[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,p=4,h=0,g=-2,f=-1,y=4,m=2,w=8,_=9,k=286,x=30,O=19,E=2*k+1,N=15,P=3,R=258,$=R+P+1,j=42,B=113,b=1,K=2,te=3,S=4;function G(v,U){return v.msg=u[U],U}function z(v){return(v<<1)-(4v.avail_out&&(W=v.avail_out),W!==0&&(i.arraySet(v.output,U.pending_buf,U.pending_out,W,v.next_out),v.next_out+=W,U.pending_out+=W,v.total_out+=W,v.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function T(v,U){a._tr_flush_block(v,0<=v.block_start?v.block_start:-1,v.strstart-v.block_start,U),v.block_start=v.strstart,M(v.strm)}function ne(v,U){v.pending_buf[v.pending++]=U}function Y(v,U){v.pending_buf[v.pending++]=U>>>8&255,v.pending_buf[v.pending++]=255&U}function H(v,U){var W,I,C=v.max_chain_length,F=v.strstart,V=v.prev_length,J=v.nice_match,L=v.strstart>v.w_size-$?v.strstart-(v.w_size-$):0,X=v.window,re=v.w_mask,ee=v.prev,ae=v.strstart+R,ge=X[F+V-1],pe=X[F+V];v.prev_length>=v.good_match&&(C>>=2),J>v.lookahead&&(J=v.lookahead);do if(X[(W=U)+V]===pe&&X[W+V-1]===ge&&X[W]===X[F]&&X[++W]===X[F+1]){F+=2,W++;do;while(X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&X[++F]===X[++W]&&FL&&--C!=0);return V<=v.lookahead?V:v.lookahead}function fe(v){var U,W,I,C,F,V,J,L,X,re,ee=v.w_size;do{if(C=v.window_size-v.lookahead-v.strstart,v.strstart>=ee+(ee-$)){for(i.arraySet(v.window,v.window,ee,ee,0),v.match_start-=ee,v.strstart-=ee,v.block_start-=ee,U=W=v.hash_size;I=v.head[--U],v.head[U]=ee<=I?I-ee:0,--W;);for(U=W=ee;I=v.prev[--U],v.prev[U]=ee<=I?I-ee:0,--W;);C+=ee}if(v.strm.avail_in===0)break;if(V=v.strm,J=v.window,L=v.strstart+v.lookahead,X=C,re=void 0,re=V.avail_in,X=P)for(F=v.strstart-v.insert,v.ins_h=v.window[F],v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P)if(I=a._tr_tally(v,v.strstart-v.match_start,v.match_length-P),v.lookahead-=v.match_length,v.match_length<=v.max_lazy_match&&v.lookahead>=P){for(v.match_length--;v.strstart++,v.ins_h=(v.ins_h<=P&&(v.ins_h=(v.ins_h<=P&&v.match_length<=v.prev_length){for(C=v.strstart+v.lookahead-P,I=a._tr_tally(v,v.strstart-1-v.prev_match,v.prev_length-P),v.lookahead-=v.prev_length-1,v.prev_length-=2;++v.strstart<=C&&(v.ins_h=(v.ins_h<v.pending_buf_size-5&&(W=v.pending_buf_size-5);;){if(v.lookahead<=1){if(fe(v),v.lookahead===0&&U===d)return b;if(v.lookahead===0)break}v.strstart+=v.lookahead,v.lookahead=0;var I=v.block_start+W;if((v.strstart===0||v.strstart>=I)&&(v.lookahead=v.strstart-I,v.strstart=I,T(v,!1),v.strm.avail_out===0)||v.strstart-v.block_start>=v.w_size-$&&(T(v,!1),v.strm.avail_out===0))return b}return v.insert=0,U===p?(T(v,!0),v.strm.avail_out===0?te:S):(v.strstart>v.block_start&&(T(v,!1),v.strm.avail_out),b)}),new le(4,4,8,4,ye),new le(4,5,16,8,ye),new le(4,6,32,32,ye),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],o.deflateInit=function(v,U){return Ee(v,U,w,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(v,U){return v&&v.state?v.state.wrap!==2?g:(v.state.gzhead=U,h):g},o.deflate=function(v,U){var W,I,C,F;if(!v||!v.state||5>8&255),ne(I,I.gzhead.time>>16&255),ne(I,I.gzhead.time>>24&255),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ne(I,255&I.gzhead.extra.length),ne(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(v.adler=c(v.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,0),ne(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ne(I,3),I.status=B);else{var V=w+(I.w_bits-8<<4)<<8;V|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(V|=32),V+=31-V%31,I.status=B,Y(I,V),I.strstart!==0&&(Y(I,v.adler>>>16),Y(I,65535&v.adler)),v.adler=1}if(I.status===69)if(I.gzhead.extra){for(C=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending!==I.pending_buf_size));)ne(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){C=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>C&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),M(v),C=I.pending,I.pending===I.pending_buf_size)){F=1;break}F=I.gzindexC&&(v.adler=c(v.adler,I.pending_buf,I.pending-C,C)),F===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&M(v),I.pending+2<=I.pending_buf_size&&(ne(I,255&v.adler),ne(I,v.adler>>8&255),v.adler=0,I.status=B)):I.status=B),I.pending!==0){if(M(v),v.avail_out===0)return I.last_flush=-1,h}else if(v.avail_in===0&&z(U)<=z(W)&&U!==p)return G(v,-5);if(I.status===666&&v.avail_in!==0)return G(v,-5);if(v.avail_in!==0||I.lookahead!==0||U!==d&&I.status!==666){var J=I.strategy===2?function(L,X){for(var re;;){if(L.lookahead===0&&(fe(L),L.lookahead===0)){if(X===d)return b;break}if(L.match_length=0,re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):I.strategy===3?function(L,X){for(var re,ee,ae,ge,pe=L.window;;){if(L.lookahead<=R){if(fe(L),L.lookahead<=R&&X===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=P&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=P?(re=a._tr_tally(L,1,L.match_length-P),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(re=a._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),re&&(T(L,!1),L.strm.avail_out===0))return b}return L.insert=0,X===p?(T(L,!0),L.strm.avail_out===0?te:S):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(I,U):s[I.level].func(I,U);if(J!==te&&J!==S||(I.status=666),J===b||J===te)return v.avail_out===0&&(I.last_flush=-1),h;if(J===K&&(U===1?a._tr_align(I):U!==5&&(a._tr_stored_block(I,0,0,!1),U===3&&(Q(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),M(v),v.avail_out===0))return I.last_flush=-1,h}return U!==p?h:I.wrap<=0?1:(I.wrap===2?(ne(I,255&v.adler),ne(I,v.adler>>8&255),ne(I,v.adler>>16&255),ne(I,v.adler>>24&255),ne(I,255&v.total_in),ne(I,v.total_in>>8&255),ne(I,v.total_in>>16&255),ne(I,v.total_in>>24&255)):(Y(I,v.adler>>>16),Y(I,65535&v.adler)),M(v),0=W.w_size&&(F===0&&(Q(W.head),W.strstart=0,W.block_start=0,W.insert=0),X=new i.Buf8(W.w_size),i.arraySet(X,U,re-W.w_size,W.w_size,0),U=X,re=W.w_size),V=v.avail_in,J=v.next_in,L=v.input,v.avail_in=re,v.next_in=0,v.input=U,fe(W);W.lookahead>=P;){for(I=W.strstart,C=W.lookahead-(P-1);W.ins_h=(W.ins_h<>>=P=N>>>24,_-=P,(P=N>>>16&255)===0)K[u++]=65535&N;else{if(!(16&P)){if(!(64&P)){N=k[(65535&N)+(w&(1<>>=P,_-=P),_<15&&(w+=b[l++]<<_,_+=8,w+=b[l++]<<_,_+=8),N=x[w&E];n:for(;;){if(w>>>=P=N>>>24,_-=P,!(16&(P=N>>>16&255))){if(!(64&P)){N=x[(65535&N)+(w&(1<>>=P,_-=P,(P=u-d)<$){if(f<(P=$-P)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(j=0)===y){if(j+=g-P,P>3,w&=(1<<(_-=R<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(j){var B;return j&&j.state?(B=j.state,j.total_in=j.total_out=B.total=0,j.msg="",B.wrap&&(j.adler=1&B.wrap),B.mode=g,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(f),B.distcode=B.distdyn=new s.Buf32(y),B.sane=1,B.back=-1,p):h}function k(j){var B;return j&&j.state?((B=j.state).wsize=0,B.whave=0,B.wnext=0,_(j)):h}function x(j,B){var b,K;return j&&j.state?(K=j.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=S.wsize?(s.arraySet(S.window,B,b-S.wsize,S.wsize,0),S.wnext=0,S.whave=S.wsize):(K<(te=S.wsize-S.wnext)&&(te=K),s.arraySet(S.window,B,b-K,te,S.wnext),(K-=te)?(s.arraySet(S.window,B,b-K,K,0),S.wnext=K,S.whave=S.wsize):(S.wnext+=te,S.wnext===S.wsize&&(S.wnext=0),S.whave>>8&255,b.check=a(b.check,F,2,0),T=M=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&M)<<8)+(M>>8))%31){j.msg="incorrect header check",b.mode=30;break}if((15&M)!=8){j.msg="unknown compression method",b.mode=30;break}if(T-=4,v=8+(15&(M>>>=4)),b.wbits===0)b.wbits=v;else if(v>b.wbits){j.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=3;case 3:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>8&255,F[2]=M>>>16&255,F[3]=M>>>24&255,b.check=a(b.check,F,4,0)),T=M=0,b.mode=4;case 4:for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>8),512&b.flags&&(F[0]=255&M,F[1]=M>>>8&255,b.check=a(b.check,F,2,0)),T=M=0,b.mode=5;case 5:if(1024&b.flags){for(;T<16;){if(z===0)break e;z--,M+=K[S++]<>>8&255,b.check=a(b.check,F,2,0)),T=M=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(z<(H=b.length)&&(H=z),H&&(b.head&&(v=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,S,H,v)),512&b.flags&&(b.check=a(b.check,K,H,S)),z-=H,S+=H,b.length-=H),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(z===0)break e;for(H=0;v=K[S+H++],b.head&&v&&b.length<65536&&(b.head.name+=String.fromCharCode(v)),v&&H>9&1,b.head.done=!0),j.adler=b.check=0,b.mode=12;break;case 10:for(;T<32;){if(z===0)break e;z--,M+=K[S++]<>>=7&T,T-=7&T,b.mode=27;break}for(;T<3;){if(z===0)break e;z--,M+=K[S++]<>>=1)){case 0:b.mode=14;break;case 1:if(R(b),b.mode=20,B!==6)break;M>>>=2,T-=2;break e;case 2:b.mode=17;break;case 3:j.msg="invalid block type",b.mode=30}M>>>=2,T-=2;break;case 14:for(M>>>=7&T,T-=7&T;T<32;){if(z===0)break e;z--,M+=K[S++]<>>16^65535)){j.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&M,T=M=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(H=b.length){if(z>>=5,T-=5,b.ndist=1+(31&M),M>>>=5,T-=5,b.ncode=4+(15&M),M>>>=4,T-=4,286>>=3,T-=3}for(;b.have<19;)b.lens[V[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=se,T-=se,b.lens[b.have++]=ke;else{if(ke===16){for(I=se+2;T>>=se,T-=se,b.have===0){j.msg="invalid bit length repeat",b.mode=30;break}v=b.lens[b.have-1],H=3+(3&M),M>>>=2,T-=2}else if(ke===17){for(I=se+3;T>>=se)),M>>>=3,T-=3}else{for(I=se+7;T>>=se)),M>>>=7,T-=7}if(b.have+H>b.nlen+b.ndist){j.msg="invalid bit length repeat",b.mode=30;break}for(;H--;)b.lens[b.have++]=v}}if(b.mode===30)break;if(b.lens[256]===0){j.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=c(u,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){j.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=c(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){j.msg="invalid distances set",b.mode=30;break}if(b.mode=20,B===6)break e;case 20:b.mode=21;case 21:if(6<=z&&258<=Q){j.next_out=G,j.avail_out=Q,j.next_in=S,j.avail_in=z,b.hold=M,b.bits=T,l(j,Y),G=j.next_out,te=j.output,Q=j.avail_out,S=j.next_in,K=j.input,z=j.avail_in,M=b.hold,T=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;le=(C=b.lencode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,b.length=ke,le===0){b.mode=26;break}if(32&le){b.back=-1,b.mode=12;break}if(64&le){j.msg="invalid literal/length code",b.mode=30;break}b.extra=15&le,b.mode=22;case 22:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;le=(C=b.distcode[M&(1<>>16&255,ke=65535&C,!((se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>ve)])>>>16&255,ke=65535&C,!(ve+(se=C>>>24)<=T);){if(z===0)break e;z--,M+=K[S++]<>>=ve,T-=ve,b.back+=ve}if(M>>>=se,T-=se,b.back+=se,64&le){j.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&le,b.mode=24;case 24:if(b.extra){for(I=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){j.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(Q===0)break e;if(H=Y-Q,b.offset>H){if((H=b.offset-H)>b.whave&&b.sane){j.msg="invalid distance too far back",b.mode=30;break}fe=H>b.wnext?(H-=b.wnext,b.wsize-H):b.wnext-H,H>b.length&&(H=b.length),ye=b.window}else ye=te,fe=G-b.offset,H=b.length;for(QE?(P=fe[ye+y[B]],T[ne+y[B]]):(P=96,0),w=1<>G)+(_-=w)]=N<<24|P<<16|R|0,_!==0;);for(w=1<>=1;if(w!==0?(M&=w-1,M+=w):M=0,B++,--Y[j]==0){if(j===K)break;j=d[p+y[B]]}if(te>>7)]}function ne(C,F){C.pending_buf[C.pending++]=255&F,C.pending_buf[C.pending++]=F>>>8&255}function Y(C,F,V){C.bi_valid>m-V?(C.bi_buf|=F<>m-C.bi_valid,C.bi_valid+=V-m):(C.bi_buf|=F<>>=1,V<<=1,0<--F;);return V>>>1}function ye(C,F,V){var J,L,X=new Array(y+1),re=0;for(J=1;J<=y;J++)X[J]=re=re+V[J-1]<<1;for(L=0;L<=F;L++){var ee=C[2*L+1];ee!==0&&(C[2*L]=fe(X[ee]++,ee))}}function se(C){var F;for(F=0;F>1;1<=V;V--)ve(C,X,V);for(L=ae;V=C.heap[1],C.heap[1]=C.heap[C.heap_len--],ve(C,X,1),J=C.heap[1],C.heap[--C.heap_max]=V,C.heap[--C.heap_max]=J,X[2*L]=X[2*V]+X[2*J],C.depth[L]=(C.depth[V]>=C.depth[J]?C.depth[V]:C.depth[J])+1,X[2*V+1]=X[2*J+1]=L,C.heap[1]=L++,ve(C,X,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(pe,Ge){var mn,rt,yn,Pe,Jn,no,ct=Ge.dyn_tree,Hs=Ge.max_code,wl=Ge.stat_desc.static_tree,bl=Ge.stat_desc.has_stree,_l=Ge.stat_desc.extra_bits,Zs=Ge.stat_desc.extra_base,vn=Ge.stat_desc.max_length,Yn=0;for(Pe=0;Pe<=y;Pe++)pe.bl_count[Pe]=0;for(ct[2*pe.heap[pe.heap_max]+1]=0,mn=pe.heap_max+1;mn>=7;L>>=1)if(1&ge&&ee.dyn_ltree[2*ae]!==0)return i;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return a;for(ae=32;ae>>3,(X=C.static_len+3+7>>>3)<=L&&(L=X)):L=X=V+5,V+4<=L&&F!==-1?I(C,F,V,J):C.strategy===4||X===L?(Y(C,2+(J?1:0),3),me(C,$,j)):(Y(C,4+(J?1:0),3),function(ee,ae,ge,pe){var Ge;for(Y(ee,ae-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Ge=0;Ge>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&F,C.pending_buf[C.l_buf+C.last_lit]=255&V,C.last_lit++,F===0?C.dyn_ltree[2*V]++:(C.matches++,F--,C.dyn_ltree[2*(b[V]+d+1)]++,C.dyn_dtree[2*T(F)]++),C.last_lit===C.lit_bufsize-1},o._tr_align=function(C){Y(C,2,3),H(C,_,$),function(F){F.bi_valid===16?(ne(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)}(C)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,c,u,d,p=1,h={},g=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:function(){if(i.postMessage&&!i.importScripts){var k=!0,x=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=x,k}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(k){i.postMessage(d+k,"*")}):i.MessageChannel?((u=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){u.port2.postMessage(k)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(k){var x=f.createElement("script");x.onreadystatechange=function(){w(k),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(k){setTimeout(w,0,k)},y.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=new Array(arguments.length-1),O=0;O"u"?s===void 0?this:s:self)}).call(this,typeof Xn<"u"?Xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gl);var mp=gl.exports;const yp=Da(mp),vp=async t=>{const e=`ComfyUI workspace workflows ${ll(Date.now())}`,n=new yp,r=await(Z==null?void 0:Z.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await fh(o.parentFolderID??null).then(async a=>Dt(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function gp({myWorkflowsDir:t}){return D.jsxs(tn,{gap:3,children:[D.jsx(_s,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),D.jsx("p",{children:"Your workflows will be synced to and from path:"}),D.jsx("p",{children:D.jsx("b",{children:t})}),D.jsxs("p",{children:["You can manually put workflow files into this folder using File Explorer to sync them with your workspace. You can change this path anytime in Settings ",">"," Workspace Save Directory"]}),D.jsxs("p",{children:[D.jsx("b",{children:"Please download all your workflows before enabling two way sync as a backup!"})," ","So you can manually import some workflows into your workspace in case something unexpected happens."]}),D.jsx(We,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(q==null?void 0:q.listAll());vp(e??[])},children:"👉 Download All My Workflows"})]})}const wp=(t,e)=>{const n=t.nodes==null?[]:t.nodes,r=e.nodes==null?[]:e.nodes;t.nodes=[],e.nodes=[];let o=JSON.stringify(t)===JSON.stringify(e);if(o){const s=(a,l)=>{const c=l.order,u=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",u),l.order=c,l.pos=u,a},i=(a,l,c)=>Math.abs(a-l)>c;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[c,u]of a){if(!l.has(c)){o=!1;break}if(typeof c=="string"&&c.includes("_pos")){const d=l.get(c);if(d==null||u==null||i(d[0],u[0],5)||i(d[1],u[1],5)){o=!1;break}}else if(l.get(c)!==u){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},bp=ws.lazy(()=>Un(()=>import("./RecentFilesDrawer-UFHH0mIW.js"),__vite__mapDeps([9,1,6,2,10,11,4]))),_p=ws.lazy(()=>Un(()=>import("./GalleryModal-oZQWNmu9.js"),__vite__mapDeps([12,1,11,6,2,7,3]))),kp=ws.lazy(()=>Un(()=>import("./AppIsDirtyEventListener-Cjpx6yXx.js"),__vite__mapDeps([13,1]))),xp=["download_progress","download_error","model_list"];function Ep(){const[t,e]=A.useState(null),[n,r]=A.useState("root"),[o,s]=A.useState(!0),[i,a]=A.useState(null),l=A.useRef(null),[c,u]=A.useState(!1),d=A.useRef(null),{showDialog:p}=Fa(),[h,g]=A.useState(!1);A.useRef(!1);const f=Ta(),[y,m]=pp(null),w=A.useCallback(async()=>{var S;if(l.current){if((S=q==null?void 0:q.curWorkflow)!=null&&S.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const G=JSON.stringify(xe.graph.serialize());await Promise.all([q==null?void 0:q.updateFlow(l.current,{json:G}),Ve==null?void 0:Ve.create({workflowID:l.current,json:G,isAutoSave:!1})]),Z!=null&&Z.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),u(!1)}},[]),_=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(q==null?void 0:q.delete(l.current)),x(null))},k=async()=>{var G,z;if(Z!=null&&Z.autoSave){alert("You cannot discard unsaved changes when auto save is enabled");return}if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const Q=(G=q==null?void 0:q.curWorkflow)==null?void 0:G.id;if(Q==null)return;const M=(z=await(q==null?void 0:q.get(Q)))==null?void 0:z.json;M?(q==null||q.updateCurWorkflow({...q.curWorkflow,json:M}),await xe.loadGraphData(JSON.parse(M)),u(!1)):alert("Error: No last saved version found")}},x=S=>{const G=(S==null?void 0:S.id)??null;if(q==null||q.updateCurWorkflow(S),l.current=G,a(G),e((S==null?void 0:S.name)??""),G==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(Sa()){const z=dl(G);window.location.hash=z,document.title=S.name+" - ComfyUI"}else localStorage.setItem("curFlowID",G),document.title="ComfyUI - "+S.name},O=async()=>{E(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Ih()}catch(z){console.error("error loading db",z)}s(!1);let S=null;S=Sa(),S==null&&(S=localStorage.getItem("curFlowID")),S&&P(S),await cl(),!await(Z==null?void 0:Z.getSetting("twoWaySync"))&&ue.cache.get(go).then(async z=>{if((z==null?void 0:z.value)!=="true"){if(await ue.workflows.count()==0){await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await ue.cache.put({id:go,value:"true"});return}const M=await(Z==null?void 0:Z.getSetting("myWorkflowsDir"));p(D.jsx(gp,{myWorkflowsDir:M??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(Z==null?void 0:Z.upsert({twoWaySync:!0})),await(Z==null?void 0:Z.getSetting("twoWaySync"))&&(ue.cache.put({id:go,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},E=()=>{xp.forEach(S=>{Gs.addEventListener(S,()=>null)})},N=()=>{if(l.current==null)return!1;const S=q==null?void 0:q.curWorkflow;if(S==null)return!1;if(S.json==null)return!0;const G=xe.graph.serialize()??{};let z={};try{z=S!=null&&S.json?JSON.parse(S==null?void 0:S.json):{}}catch(M){console.error("error parsing json",M)}return!wp(G,z)},P=async(S,G)=>{if(xe.graph==null)return;const z=await(q==null?void 0:q.get(S));if(z==null){alert("Error: Workflow not found! id: "+S),x(null);return}const Q=G?await(we==null?void 0:we.get(G)):null;xe.ui.dialog.close(),Q?(m(Q),x({...z,json:Q.json}),xe.loadGraphData(JSON.parse(Q.json))):(x(z),m(null),xe.loadGraphData(JSON.parse(z.json))),r("root"),c&&u(!1)},R=async(S,G,z=!1)=>{if(S===null){x(null),xe.graph.clear();return}if(!c||z||await(Z==null?void 0:Z.getSetting("autoSave"))){P(S,G);return}$(S)},$=async S=>{var z,Q;const G=[S?{label:"Open in new tab",icon:D.jsx(Lh,{}),onClick:()=>{yh(S)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await w(),S&&P(S)}}];((z=q==null?void 0:q.curWorkflow)==null?void 0:z.lastSavedJson)!=null?G.push({label:"Discard",colorScheme:"red",onClick:async()=>{S&&P(S)}}):G.push({label:"Delete",colorScheme:"red",onClick:async()=>{await _(),S&&P(S)}}),p(`Please save or discard your changes to "${(Q=q==null?void 0:q.curWorkflow)==null?void 0:Q.name}" before leaving, or your changes will be lost.`,G)},j=async S=>{const G=(S==null?void 0:S.json)??JSON.stringify(_r),z=await(q==null?void 0:q.createFlow({json:G,name:S==null?void 0:S.name}));z&&await R(z.id),r("root")},B=async(S,G=!1)=>{const z=S.split("/").pop()??S;G?w():j({name:z});const Q=await fetch(mh(S)),M=await Q.blob(),T=new File([M],z,{type:Q.headers.get("Content-Type")||""});await xe.handleFile(T),r("root")},b=async(S,G)=>{const z=await(q==null?void 0:q.get(S));if(z==null)return;const Q=await(q==null?void 0:q.createFlow({json:z.json,lastSavedJson:z.lastSavedJson,name:G||z.name,parentFolderID:z.parentFolderID,tags:z.tags}));Q&&await R(Q.id)},K=A.useCallback(S=>{if(l.current==null)return;let G=S.filename;S.subfolder!=null&&S.subfolder!==""&&(G=S.subfolder+"/"+G),Kt==null||Kt.create({workflowID:l.current,localPath:G})},[]),te=A.useCallback(()=>{r("root")},[]);return A.useEffect(()=>{O(),g(!0);const S=document.getElementById("comfy-file-input"),G=async()=>{if(S&&S.files&&S.files.length>0){const T={id:Fn(),name:S.files[0].name,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(T),await(q==null?void 0:q.createFlow(T))}};S==null||S.addEventListener("change",G);const z=T=>{var H;const ne=(Z==null?void 0:Z.autoSave)??!0;if((H=q==null?void 0:q.curWorkflow)!=null&&H.saveLock)return;const Y=N();!ne&&Y&&(T.preventDefault(),T.returnValue="You have unsaved changes!",$())};window.addEventListener("beforeunload",z);const Q=T=>{var ne,Y,H,fe,ye,se;(H=(Y=(ne=T.detail)==null?void 0:ne.output)==null?void 0:Y.images)==null||H.forEach(le=>{le.type==="output"&&K(le)}),(se=(ye=(fe=T.detail)==null?void 0:fe.output)==null?void 0:ye.gifs)==null||se.forEach(le=>{le.type==="output"&&K(le)})};Gs.addEventListener("executed",Q);const M=async T=>{var fe,ye;const ne=(ye=(fe=T.dataTransfer)==null?void 0:fe.files[0])==null?void 0:ye.name,Y=xe.dragOverNode;if(Y&&Y.onDragDrop)return;if(!(await(Z==null?void 0:Z.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ne){const se={id:Fn(),name:ne,json:JSON.stringify(_r),updateTime:Date.now(),createTime:Date.now()};x(se),await(q==null?void 0:q.createFlow(se))}};return xe.canvasEl.addEventListener("drop",M),()=>{window.removeEventListener("change",G),window.removeEventListener("beforeunload",z),window.removeEventListener("executed",Q),xe.canvasEl.removeEventListener("drop",M)}},[]),o?null:D.jsx(At.Provider,{value:{curFlowID:i,onDuplicateWorkflow:b,loadWorkflowID:R,discardUnsavedChanges:k,saveCurWorkflow:w,isDirty:c,setIsDirty:u,loadNewWorkflow:j,loadFilePath:B,setRoute:r,route:n,curVersion:y,setCurVersion:m},children:D.jsx("div",{ref:d,className:"workspace_manager",children:D.jsxs(Aa,{containerRef:d,children:[D.jsxs(Ct,{style:{position:"absolute",top:0,right:0,left:0},zIndex:dh,draggable:!1,children:[D.jsx(up,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&D.jsx(A.Suspense,{children:D.jsx(bp,{onClose:te,onClickNewFlow:()=>{j(),r("root")}})}),n==="gallery"&&D.jsx(A.Suspense,{children:D.jsx(_p,{onclose:()=>r("root")})})]}),D.jsx(dp,{}),D.jsx(kp,{})]})})})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"}));export{uc as $,q as A,Ct as B,Yh as C,Xh as D,sh as E,xn as F,vp as G,Et as H,jn as I,Mh as J,Lp as K,Wh as L,hi as M,wh as N,ze as O,qr as P,Hr as Q,Gp as R,kd as S,Qr as T,Vr as U,Vh as V,_r as W,Wp as X,wr as Y,Oh as Z,zp as _,Dp as a,mi as a0,pi as a1,bi as a2,yi as a3,gi as a4,vi as a5,At as a6,yl as a7,Kt as a8,ll as a9,Pc as aA,pp as aB,Ch as aC,Vp as aD,Rp as aE,dn as aF,Yp as aG,we as aH,Jp as aI,Xp as aJ,ap as aK,Qp as aL,tc as aM,em as aN,yh as aa,Lh as ab,kt as ac,nc as ad,dh as ae,Fp as af,ul as ag,Up as ah,Ma as ai,za as aj,$p as ak,qp as al,Eh as am,_s as an,Ac as ao,en as ap,dc as aq,wp as ar,Kp as as,Ve as at,Kl as au,ue as av,Hp as aw,Zp as ax,Tp as ay,Bp as az,jc as b,Ap as c,Pp as d,jp as e,fn as f,Jr as g,Fe as h,Zh as i,Ta as j,tn as k,Bt as l,zt as m,Kn as n,Z as o,gp as p,cf as q,Np as r,Mp as s,kr as t,Gr as u,Eo as v,As as w,Ns as x,gt as y,zh as z}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-MoNpT1nG.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-DRLDc1uk.js","workspace_web/IconCopy-Hs60LgD8.js","workspace_web/ModelManagerTopbar-4fKW20g4.js","workspace_web/chunk-JARCRF6W-swAlFRrB.js","workspace_web/chunk-3RSXBRAN-hQn4Wngd.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/RecentFilesDrawer-UFHH0mIW.js","workspace_web/chunk-NTCQBYKE-4zMWD2m4.js","workspace_web/MediaPreview-_sS52WD-.js","workspace_web/GalleryModal-oZQWNmu9.js","workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js"] + } + return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) +} \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js b/dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js new file mode 100644 index 0000000..5e3f844 --- /dev/null +++ b/dist/workspace_web/AppIsDirtyEventListener-Cjpx6yXx.js @@ -0,0 +1 @@ +import{r as l,j as y}from"./input.js";import{app as o}from"/scripts/app.js";import{a6 as S,j as C,ar as E,as as A,E as g,o as W,A as c,at as j,B as x}from"./App-sgH6j00M.js";import"/scripts/api.js";function v(d,f){const i=l.useRef(0),u=l.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=0)},[]),p=l.useCallback((...k)=>{u(),i.current=setTimeout(()=>d(...k),f)},[d,f,u]);return l.useEffect(()=>()=>{u()},[]),[p,u]}function F(){const{isDirty:d,setIsDirty:f,setRoute:i,saveCurWorkflow:u}=l.useContext(S),p=C();l.useEffect(()=>{const a=async e=>{switch(e){case g.SAVE:u();break;case g.SAVE_AS:i("saveAsModal");break}},s=o.canvas.onAfterChange;o.graph.onAfterChange=function(){s==null||s.apply(this,arguments),h()};const n=o.graph.onConfigure;o.graph.onConfigure=function(){n==null||n.apply(this,arguments),setTimeout(()=>{var t,r;E(o.graph.serialize(),JSON.parse(((r=(t=c)==null?void 0:t.curWorkflow)==null?void 0:r.json)??"{}"))||h()},1e3)},document.addEventListener("click",e=>{Object.keys(o.canvas.selected_nodes??{}).length&&(o.canvas.node_over!=null||o.canvas.node_capturing_input!=null||o.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var r;if(document.visibilityState==="hidden")return;const t=await A(e);t?a(t):(r=e.target)!=null&&r.matches("input, textarea")&&Object.keys(o.canvas.selected_nodes??{}).length&&h()})},[]);const k=async()=>{var s,n,e,t;if(!((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.id))return;const a=JSON.stringify(o.graph.serialize());a!=null&&await((e=c)==null?void 0:e.updateFlow(c.curWorkflow.id,{json:a})),(t=j)==null||t.create({workflowID:c.curWorkflow.id,isAutoSave:!0,json:a}),f(!1),p({position:"bottom-left",duration:1e3,render:()=>y.jsx(x,{color:"white",p:3,children:"Auto saved"})})},[b,D]=v(k,1e3),m=async()=>{var s,n,e,t,r,w;if((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.saveLock)return;const a=await((e=W)==null?void 0:e.getSetting("autoSave"));if(!a){!d&&f(!0);return}(r=(t=c)==null?void 0:t.curWorkflow)!=null&&r.id&&a&&(await((w=c)==null?void 0:w.latestVersionCheck())?b():p({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))},[h,_]=v(m,500);return null}export{F as default}; diff --git a/dist/workspace_web/GalleryModal-oZQWNmu9.js b/dist/workspace_web/GalleryModal-oZQWNmu9.js new file mode 100644 index 0000000..52db179 --- /dev/null +++ b/dist/workspace_web/GalleryModal-oZQWNmu9.js @@ -0,0 +1,2 @@ +import{b as Z,f as R,j as s,g as z,e as L,r as m,m as le,q as Ce,ab as Q,I as qt,L as ut,G as dt,ac as at,ad as se,k as ht,o as Oe,d as Te,x as Jt,E as Zt,n as Qt,V as en,h as tn,M as nn,N as an,O as sn,Q as on,R as rn,S as ln}from"./input.js";import{ai as cn,aj as mt,$ as un,h as he,F as b,ak as dn,I as O,n as hn,al as mn,B as fn,l as q,m as H,z as ft,a9 as xt,am as xn,a6 as gt,k as gn,H as ie,i as vn,a8 as vt,A as De,an as yn,C as bn}from"./App-sgH6j00M.js";import{c as Ae,p as Sn,r as st,v as ot,I as wn,N as pn,a as Pn,d as jn,e as kn,f as In,S as Cn,M as Tn,b as An}from"./MediaPreview-_sS52WD-.js";import{I as Mn,C as Be,G as _n}from"./chunk-JARCRF6W-swAlFRrB.js";import{S as En}from"./chunk-3RSXBRAN-hQn4Wngd.js";import{L as Re}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const yt=1/60*1e3,Nn=typeof performance<"u"?()=>performance.now():()=>Date.now(),bt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(Nn()),yt);function Dn(e){let t=[],n=[],a=0,o=!1,l=!1;const i=new WeakSet,h={schedule:(r,c=!1,d=!1)=>{const u=d&&o,x=u?t:n;return c&&i.add(r),x.indexOf(r)===-1&&(x.push(r),u&&o&&(a=t.length)),r},cancel:r=>{const c=n.indexOf(r);c!==-1&&n.splice(c,1),i.delete(r)},process:r=>{if(o){l=!0;return}if(o=!0,[t,n]=[n,t],n.length=0,a=t.length,a)for(let c=0;c(e[t]=Dn(()=>J=!0),e),{}),zn=ee.reduce((e,t)=>{const n=me[t];return e[t]=(a,o=!1,l=!1)=>(J||Bn(),n.schedule(a,o,l)),e},{}),$n=ee.reduce((e,t)=>(e[t]=me[t].cancel,e),{});ee.reduce((e,t)=>(e[t]=()=>me[t].process(G),e),{});const On=e=>me[e].process(G),St=e=>{J=!1,G.delta=ze?yt:Math.max(Math.min(e-G.timestamp,Rn),1),G.timestamp=e,$e=!0,ee.forEach(On),$e=!1,J&&(ze=!1,bt(St))},Bn=()=>{J=!0,ze=!0,$e||bt(St)},rt=()=>G;var[Fn,fe]=Z({name:"AccordionStylesContext",hookName:"useAccordionStyles",providerName:""}),[Kn,Fe]=Z({name:"AccordionItemContext",hookName:"useAccordionItemContext",providerName:""}),[Vn,cs,Ln,Un]=cn(),wt=R(function(t,n){const{getButtonProps:a}=Fe(),o=a(t,n),i={display:"flex",alignItems:"center",width:"100%",outline:0,...fe().button};return s.jsx(z.button,{...o,className:L("chakra-accordion__button",t.className),__css:i})});wt.displayName="AccordionButton";function Hn(e){const{onChange:t,defaultIndex:n,index:a,allowMultiple:o,allowToggle:l,...i}=e;Yn(e),Xn(e);const h=Ln(),[r,c]=m.useState(-1);m.useEffect(()=>()=>{c(-1)},[]);const[d,u]=mt({value:a,defaultValue(){return o?n??[]:n??-1},onChange:t});return{index:d,setIndex:u,htmlProps:i,getAccordionItemProps:v=>{let w=!1;return v!==null&&(w=Array.isArray(d)?d.includes(v):d===v),{isOpen:w,onChange:S=>{if(v!==null)if(o&&Array.isArray(d)){const C=S?d.concat(v):d.filter(_=>_!==v);u(C)}else S?u(v):l&&u(-1)}}},focusedIndex:r,setFocusedIndex:c,descendants:h}}var[Gn,Ke]=Z({name:"AccordionContext",hookName:"useAccordionContext",providerName:"Accordion"});function Wn(e){const{isDisabled:t,isFocusable:n,id:a,...o}=e,{getAccordionItemProps:l,setFocusedIndex:i}=Ke(),h=m.useRef(null),r=m.useId(),c=a??r,d=`accordion-button-${c}`,u=`accordion-panel-${c}`;qn(e);const{register:x,index:v,descendants:w}=Un({disabled:t&&!n}),{isOpen:y,onChange:S}=l(v===-1?null:v);Jn({isOpen:y,isDisabled:t});const C=()=>{S==null||S(!0)},_=()=>{S==null||S(!1)},V=m.useCallback(()=>{S==null||S(!y),i(v)},[v,i,y,S]),B=m.useCallback(E=>{const j={ArrowDown:()=>{const T=w.nextEnabled(v);T==null||T.node.focus()},ArrowUp:()=>{const T=w.prevEnabled(v);T==null||T.node.focus()},Home:()=>{const T=w.firstEnabled();T==null||T.node.focus()},End:()=>{const T=w.lastEnabled();T==null||T.node.focus()}}[E.key];j&&(E.preventDefault(),j(E))},[w,v]),p=m.useCallback(()=>{i(v)},[i,v]),P=m.useCallback(function(D={},j=null){return{...D,type:"button",ref:le(x,h,j),id:d,disabled:!!t,"aria-expanded":!!y,"aria-controls":u,onClick:Ce(D.onClick,V),onFocus:Ce(D.onFocus,p),onKeyDown:Ce(D.onKeyDown,B)}},[d,t,y,V,p,B,u,x]),ne=m.useCallback(function(D={},j=null){return{...D,ref:j,role:"region",id:u,"aria-labelledby":d,hidden:!y}},[d,y,u]);return{isOpen:y,isDisabled:t,isFocusable:n,onOpen:C,onClose:_,getButtonProps:P,getPanelProps:ne,htmlProps:o}}function Yn(e){const t=e.index||e.defaultIndex,n=t!=null&&!Array.isArray(t)&&e.allowMultiple;Q({condition:!!n,message:`If 'allowMultiple' is passed, then 'index' or 'defaultIndex' must be an array. You passed: ${typeof t},`})}function Xn(e){Q({condition:!!(e.allowMultiple&&e.allowToggle),message:"If 'allowMultiple' is passed, 'allowToggle' will be ignored. Either remove 'allowToggle' or 'allowMultiple' depending on whether you want multiple accordions visible or not"})}function qn(e){Q({condition:!!(e.isFocusable&&!e.isDisabled),message:`Using only 'isFocusable', this prop is reserved for situations where you pass 'isDisabled' but you still want the element to receive focus (A11y). Either remove it or pass 'isDisabled' as well. + `})}function Jn(e){Q({condition:e.isOpen&&!!e.isDisabled,message:"Cannot open a disabled accordion item"})}function pt(e){const{isOpen:t,isDisabled:n}=Fe(),{reduceMotion:a}=Ke(),o=L("chakra-accordion__icon",e.className),l=fe(),i={opacity:n?.4:1,transform:t?"rotate(-180deg)":void 0,transition:a?void 0:"transform 0.2s",transformOrigin:"center",...l.icon};return s.jsx(qt,{viewBox:"0 0 24 24","aria-hidden":!0,className:o,__css:i,...e,children:s.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})})}pt.displayName="AccordionIcon";var Pt=R(function(t,n){const{children:a,className:o}=t,{htmlProps:l,...i}=Wn(t),r={...fe().container,overflowAnchor:"none"},c=m.useMemo(()=>i,[i]);return s.jsx(Kn,{value:c,children:s.jsx(z.div,{ref:n,...l,className:L("chakra-accordion__item",o),__css:r,children:typeof a=="function"?a({isExpanded:!!i.isOpen,isDisabled:!!i.isDisabled}):a})})});Pt.displayName="AccordionItem";var Zn=e=>e!=null&&parseInt(e.toString(),10)>0,lt={exit:{height:{duration:.2,ease:se.ease},opacity:{duration:.3,ease:se.ease}},enter:{height:{duration:.3,ease:se.ease},opacity:{duration:.4,ease:se.ease}}},Qn={exit:({animateOpacity:e,startingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:Zn(t)?1:0},height:t,transitionEnd:a==null?void 0:a.exit,transition:(l=n==null?void 0:n.exit)!=null?l:at.exit(lt.exit,o)}},enter:({animateOpacity:e,endingHeight:t,transition:n,transitionEnd:a,delay:o})=>{var l;return{...e&&{opacity:1},height:t,transitionEnd:a==null?void 0:a.enter,transition:(l=n==null?void 0:n.enter)!=null?l:at.enter(lt.enter,o)}}},jt=m.forwardRef((e,t)=>{const{in:n,unmountOnExit:a,animateOpacity:o=!0,startingHeight:l=0,endingHeight:i="auto",style:h,className:r,transition:c,transitionEnd:d,...u}=e,[x,v]=m.useState(!1);m.useEffect(()=>{const _=setTimeout(()=>{v(!0)});return()=>clearTimeout(_)},[]),Q({condition:Number(l)>0&&!!a,message:"startingHeight and unmountOnExit are mutually exclusive. You can't use them together"});const w=parseFloat(l.toString())>0,y={startingHeight:l,endingHeight:i,animateOpacity:o,transition:x?c:{enter:{duration:0}},transitionEnd:{enter:d==null?void 0:d.enter,exit:a?d==null?void 0:d.exit:{...d==null?void 0:d.exit,display:w?"block":"none"}}},S=a?n:!0,C=n||a?"enter":"exit";return s.jsx(ut,{initial:!1,custom:y,children:S&&s.jsx(dt.div,{ref:t,...u,className:L("chakra-collapse",r),style:{overflow:"hidden",display:"block",...h},custom:y,variants:Qn,initial:a?"exit":!1,animate:C,exit:"exit"})})});jt.displayName="Collapse";var kt=R(function(t,n){const{className:a,motionProps:o,...l}=t,{reduceMotion:i}=Ke(),{getPanelProps:h,isOpen:r}=Fe(),c=h(l,n),d=L("chakra-accordion__panel",a),u=fe();i||delete c.hidden;const x=s.jsx(z.div,{...c,__css:u.panel,className:d});return i?x:s.jsx(jt,{in:r,...o,children:x})});kt.displayName="AccordionPanel";var It=R(function({children:t,reduceMotion:n,...a},o){const l=ht("Accordion",a),i=Oe(a),{htmlProps:h,descendants:r,...c}=Hn(i),d=m.useMemo(()=>({...c,reduceMotion:!!n}),[c,n]);return s.jsx(Vn,{value:r,children:s.jsx(Gn,{value:d,children:s.jsx(Fn,{value:l,children:s.jsx(z.div,{ref:o,...h,className:L("chakra-accordion",a.className),__css:l.root,children:t})})})})});It.displayName="Accordion";var U=e=>e?"":void 0,Me=e=>e?!0:void 0,te=(...e)=>e.filter(Boolean).join(" ");function _e(...e){return function(n){e.some(a=>(a==null||a(n),n==null?void 0:n.defaultPrevented))}}function oe(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}var ce={width:0,height:0},re=e=>e||ce;function ea(e){const{orientation:t,thumbPercents:n,thumbRects:a,isReversed:o}=e,l=y=>{var S;const C=(S=a[y])!=null?S:ce;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...oe({orientation:t,vertical:{bottom:`calc(${n[y]}% - ${C.height/2}px)`},horizontal:{left:`calc(${n[y]}% - ${C.width/2}px)`}})}},i=t==="vertical"?a.reduce((y,S)=>re(y).height>re(S).height?y:S,ce):a.reduce((y,S)=>re(y).width>re(S).width?y:S,ce),h={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...oe({orientation:t,vertical:i?{paddingLeft:i.width/2,paddingRight:i.width/2}:{},horizontal:i?{paddingTop:i.height/2,paddingBottom:i.height/2}:{}})},r={position:"absolute",...oe({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},c=n.length===1,d=[0,o?100-n[0]:n[0]],u=c?d:n;let x=u[0];!c&&o&&(x=100-x);const v=Math.abs(u[u.length-1]-u[0]),w={...r,...oe({orientation:t,vertical:o?{height:`${v}%`,top:`${x}%`}:{height:`${v}%`,bottom:`${x}%`},horizontal:o?{width:`${v}%`,right:`${x}%`}:{width:`${v}%`,left:`${x}%`}})};return{trackStyle:r,innerTrackStyle:w,rootStyle:h,getThumbStyle:l}}function ta(e){const{isReversed:t,direction:n,orientation:a}=e;return n==="ltr"||a==="vertical"?t:!t}function na(e,t,n,a){return e.addEventListener(t,n,a),()=>{e.removeEventListener(t,n,a)}}function aa(e){const t=oa(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function Ct(e){return!!e.touches}function sa(e){return Ct(e)&&e.touches.length>1}function oa(e){var t;return(t=e.view)!=null?t:window}function ra(e,t="page"){const n=e.touches[0]||e.changedTouches[0];return{x:n[`${t}X`],y:n[`${t}Y`]}}function la(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function Tt(e,t="page"){return Ct(e)?ra(e,t):la(e,t)}function ia(e){return t=>{const n=aa(t);(!n||n&&t.button===0)&&e(t)}}function ca(e,t=!1){function n(o){e(o,{point:Tt(o)})}return t?ia(n):n}function ue(e,t,n,a){return na(e,t,ca(n,t==="pointerdown"),a)}var ua=Object.defineProperty,da=(e,t,n)=>t in e?ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(da(e,typeof t!="symbol"?t+"":t,n),n),ha=class{constructor(e,t,n){N(this,"history",[]),N(this,"startEvent",null),N(this,"lastEvent",null),N(this,"lastEventInfo",null),N(this,"handlers",{}),N(this,"removeListeners",()=>{}),N(this,"threshold",3),N(this,"win"),N(this,"updatePoint",()=>{if(!(this.lastEvent&&this.lastEventInfo))return;const h=Ee(this.lastEventInfo,this.history),r=this.startEvent!==null,c=ga(h.offset,{x:0,y:0})>=this.threshold;if(!r&&!c)return;const{timestamp:d}=rt();this.history.push({...h.point,timestamp:d});const{onStart:u,onMove:x}=this.handlers;r||(u==null||u(this.lastEvent,h),this.startEvent=this.lastEvent),x==null||x(this.lastEvent,h)}),N(this,"onPointerMove",(h,r)=>{this.lastEvent=h,this.lastEventInfo=r,zn.update(this.updatePoint,!0)}),N(this,"onPointerUp",(h,r)=>{const c=Ee(r,this.history),{onEnd:d,onSessionEnd:u}=this.handlers;u==null||u(h,c),this.end(),!(!d||!this.startEvent)&&(d==null||d(h,c))});var a;if(this.win=(a=e.view)!=null?a:window,sa(e))return;this.handlers=t,n&&(this.threshold=n),e.stopPropagation(),e.preventDefault();const o={point:Tt(e)},{timestamp:l}=rt();this.history=[{...o.point,timestamp:l}];const{onSessionStart:i}=t;i==null||i(e,Ee(o,this.history)),this.removeListeners=xa(ue(this.win,"pointermove",this.onPointerMove),ue(this.win,"pointerup",this.onPointerUp),ue(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),$n.update(this.updatePoint)}};function it(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ee(e,t){return{point:e.point,delta:it(e.point,t[t.length-1]),offset:it(e.point,t[0]),velocity:fa(t,.1)}}var ma=e=>e*1e3;function fa(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const o=e[e.length-1];for(;n>=0&&(a=e[n],!(o.timestamp-a.timestamp>ma(t)));)n--;if(!a)return{x:0,y:0};const l=(o.timestamp-a.timestamp)/1e3;if(l===0)return{x:0,y:0};const i={x:(o.x-a.x)/l,y:(o.y-a.y)/l};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function xa(...e){return t=>e.reduce((n,a)=>a(n),t)}function Ne(e,t){return Math.abs(e-t)}function ct(e){return"x"in e&&"y"in e}function ga(e,t){if(typeof e=="number"&&typeof t=="number")return Ne(e,t);if(ct(e)&&ct(t)){const n=Ne(e.x,t.x),a=Ne(e.y,t.y);return Math.sqrt(n**2+a**2)}return 0}function At(e){const t=m.useRef(null);return t.current=e,t}function va(e,t){const{onPan:n,onPanStart:a,onPanEnd:o,onPanSessionStart:l,onPanSessionEnd:i,threshold:h}=t,r=!!(n||a||o||l||i),c=m.useRef(null),d=At({onSessionStart:l,onSessionEnd:i,onStart:a,onMove:n,onEnd(u,x){c.current=null,o==null||o(u,x)}});m.useEffect(()=>{var u;(u=c.current)==null||u.updateHandlers(d.current)}),m.useEffect(()=>{const u=e.current;if(!u||!r)return;function x(v){c.current=new ha(v,d.current,h)}return ue(u,"pointerdown",x)},[e,r,d,h]),m.useEffect(()=>()=>{var u;(u=c.current)==null||u.end(),c.current=null},[])}function ya(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const n=e.ownerDocument.defaultView??window,a=new n.ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const[l]=o;let i,h;if("borderBoxSize"in l){const r=l.borderBoxSize,c=Array.isArray(r)?r[0]:r;i=c.inlineSize,h=c.blockSize}else i=e.offsetWidth,h=e.offsetHeight;t({width:i,height:h})});return a.observe(e,{box:"border-box"}),()=>a.unobserve(e)}var ba=globalThis!=null&&globalThis.document?m.useLayoutEffect:m.useEffect;function Sa(e,t){var n,a;if(!e||!e.parentElement)return;const o=(a=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?a:window,l=new o.MutationObserver(()=>{t()});return l.observe(e.parentElement,{childList:!0}),()=>{l.disconnect()}}function wa({getNodes:e,observeMutation:t=!0}){const[n,a]=m.useState([]),[o,l]=m.useState(0);return ba(()=>{const i=e(),h=i.map((r,c)=>ya(r,d=>{a(u=>[...u.slice(0,c),d,...u.slice(c+1)])}));if(t){const r=i[0];h.push(Sa(r,()=>{l(c=>c+1)}))}return()=>{h.forEach(r=>{r==null||r()})}},[o]),n}function pa(e){return typeof e=="object"&&e!==null&&"current"in e}function Pa(e){const[t]=wa({observeMutation:!1,getNodes(){return[pa(e)?e.current:e]}});return t}function ja(e){var t;const{min:n=0,max:a=100,onChange:o,value:l,defaultValue:i,isReversed:h,direction:r="ltr",orientation:c="horizontal",id:d,isDisabled:u,isReadOnly:x,onChangeStart:v,onChangeEnd:w,step:y=1,getAriaValueText:S,"aria-valuetext":C,"aria-label":_,"aria-labelledby":V,name:B,focusThumbOnChange:p=!0,...P}=e,ne=Te(v),E=Te(w),D=Te(S),j=ta({isReversed:h,direction:r,orientation:c}),[T,ve]=mt({value:l,defaultValue:i??Ia(n,a),onChange:o}),[ye,Ve]=m.useState(!1),[be,Le]=m.useState(!1),Se=!(u||x),we=(a-n)/10,W=y||(a-n)/100,k=Ae(T,n,a),Ot=a-k+n,Ue=ot(j?Ot:k,n,a),ae=c==="vertical",I=At({min:n,max:a,step:y,isDisabled:u,value:k,isInteractive:Se,isReversed:j,isVertical:ae,eventSource:null,focusThumbOnChange:p,orientation:c}),pe=m.useRef(null),Pe=m.useRef(null),He=m.useRef(null),Bt=m.useId(),Ge=d??Bt,[We,Ye]=[`slider-thumb-${Ge}`,`slider-track-${Ge}`],Ft=m.useCallback(f=>{var g,Y;if(!pe.current)return;const A=I.current;A.eventSource="pointer";const $=pe.current.getBoundingClientRect(),{clientX:ke,clientY:Wt}=(Y=(g=f.touches)==null?void 0:g[0])!=null?Y:f,Yt=ae?$.bottom-Wt:ke-$.left,Xt=ae?$.height:$.width;let Ie=Yt/Xt;j&&(Ie=1-Ie);let X=Sn(Ie,A.min,A.max);return A.step&&(X=parseFloat(st(X,A.min,A.step))),X=Ae(X,A.min,A.max),X},[ae,j,I]),F=m.useCallback(f=>{const g=I.current;g.isInteractive&&(f=parseFloat(st(f,g.min,W)),f=Ae(f,g.min,g.max),ve(f))},[W,ve,I]),K=m.useMemo(()=>({stepUp(f=W){const g=j?k-f:k+f;F(g)},stepDown(f=W){const g=j?k+f:k-f;F(g)},reset(){F(i||0)},stepTo(f){F(f)}}),[F,j,k,W,i]),Xe=m.useCallback(f=>{const g=I.current,A={ArrowRight:()=>K.stepUp(),ArrowUp:()=>K.stepUp(),ArrowLeft:()=>K.stepDown(),ArrowDown:()=>K.stepDown(),PageUp:()=>K.stepUp(we),PageDown:()=>K.stepDown(we),Home:()=>F(g.min),End:()=>F(g.max)}[f.key];A&&(f.preventDefault(),f.stopPropagation(),A(f),g.eventSource="keyboard")},[K,F,we,I]),qe=(t=D==null?void 0:D(k))!=null?t:C,je=Pa(Pe),{getThumbStyle:Je,rootStyle:Ze,trackStyle:Qe,innerTrackStyle:et}=m.useMemo(()=>{const f=I.current,g=je??{width:0,height:0};return ea({isReversed:j,orientation:f.orientation,thumbRects:[g],thumbPercents:[Ue]})},[j,je,Ue,I]),tt=m.useCallback(()=>{I.current.focusThumbOnChange&&setTimeout(()=>{var g;return(g=Pe.current)==null?void 0:g.focus()})},[I]);Jt(()=>{const f=I.current;tt(),f.eventSource==="keyboard"&&(E==null||E(f.value))},[k,E]);function nt(f){const g=Ft(f);g!=null&&g!==I.current.value&&ve(g)}va(He,{onPanSessionStart(f){const g=I.current;g.isInteractive&&(Ve(!0),tt(),nt(f),ne==null||ne(g.value))},onPanSessionEnd(){const f=I.current;f.isInteractive&&(Ve(!1),E==null||E(f.value))},onPan(f){I.current.isInteractive&&nt(f)}});const Kt=m.useCallback((f={},g=null)=>({...f,...P,ref:le(g,He),tabIndex:-1,"aria-disabled":Me(u),"data-focused":U(be),style:{...f.style,...Ze}}),[P,u,be,Ze]),Vt=m.useCallback((f={},g=null)=>({...f,ref:le(g,pe),id:Ye,"data-disabled":U(u),style:{...f.style,...Qe}}),[u,Ye,Qe]),Lt=m.useCallback((f={},g=null)=>({...f,ref:g,style:{...f.style,...et}}),[et]),Ut=m.useCallback((f={},g=null)=>({...f,ref:le(g,Pe),role:"slider",tabIndex:Se?0:void 0,id:We,"data-active":U(ye),"aria-valuetext":qe,"aria-valuemin":n,"aria-valuemax":a,"aria-valuenow":k,"aria-orientation":c,"aria-disabled":Me(u),"aria-readonly":Me(x),"aria-label":_,"aria-labelledby":_?void 0:V,style:{...f.style,...Je(0)},onKeyDown:_e(f.onKeyDown,Xe),onFocus:_e(f.onFocus,()=>Le(!0)),onBlur:_e(f.onBlur,()=>Le(!1))}),[Se,We,ye,qe,n,a,k,c,u,x,_,V,Je,Xe]),Ht=m.useCallback((f,g=null)=>{const Y=!(f.valuea),A=k>=f.value,$=ot(f.value,n,a),ke={position:"absolute",pointerEvents:"none",...ka({orientation:c,vertical:{bottom:j?`${100-$}%`:`${$}%`},horizontal:{left:j?`${100-$}%`:`${$}%`}})};return{...f,ref:g,role:"presentation","aria-hidden":!0,"data-disabled":U(u),"data-invalid":U(!Y),"data-highlighted":U(A),style:{...f.style,...ke}}},[u,j,a,n,c,k]),Gt=m.useCallback((f={},g=null)=>({...f,ref:g,type:"hidden",value:k,name:B}),[B,k]);return{state:{value:k,isFocused:be,isDragging:ye},actions:K,getRootProps:Kt,getTrackProps:Vt,getInnerTrackProps:Lt,getThumbProps:Ut,getMarkerProps:Ht,getInputProps:Gt}}function ka(e){const{orientation:t,vertical:n,horizontal:a}=e;return t==="vertical"?n:a}function Ia(e,t){return t"}),[Ta,ge]=Z({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),Mt=R((e,t)=>{var n;const a={...e,orientation:(n=e==null?void 0:e.orientation)!=null?n:"horizontal"},o=ht("Slider",a),l=Oe(a),{direction:i}=Zt();l.direction=i;const{getInputProps:h,getRootProps:r,...c}=ja(l),d=r(),u=h({},t);return s.jsx(Ca,{value:c,children:s.jsx(Ta,{value:o,children:s.jsxs(z.div,{...d,className:te("chakra-slider",a.className),__css:o.container,children:[a.children,s.jsx("input",{...u})]})})})});Mt.displayName="Slider";var _t=R((e,t)=>{const{getThumbProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__thumb",e.className),__css:a.thumb})});_t.displayName="SliderThumb";var Et=R((e,t)=>{const{getTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__track",e.className),__css:a.track})});Et.displayName="SliderTrack";var Nt=R((e,t)=>{const{getInnerTrackProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__filled-track",e.className),__css:a.filledTrack})});Nt.displayName="SliderFilledTrack";var Aa=R((e,t)=>{const{getMarkerProps:n}=xe(),a=ge(),o=n(e,t);return s.jsx(z.div,{...o,className:te("chakra-slider__marker",e.className),__css:a.mark})});Aa.displayName="SliderMark";function Ma(e,t=[]){const n=Object.assign({},e);for(const a of t)a in n&&delete n[a];return n}var _a=["h","minH","height","minHeight"],Dt=R((e,t)=>{const n=Qt("Textarea",e),{className:a,rows:o,...l}=Oe(e),i=un(l),h=o?Ma(n,_a):n;return s.jsx(z.textarea,{ref:t,rows:o,...i,className:L("chakra-textarea",a),__css:h})});Dt.displayName="Textarea";var Ea=he("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]),Na=he("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Rt=he("pin-filled","IconPinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",fill:"currentColor",key:"svg-0",strokeWidth:"0"}]]),zt=he("pin","IconPin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]);const Da=({setMediaAct:e,media:t,currentNum:n})=>{const[a,o]=m.useState(0);m.useEffect(()=>{n!==void 0&&o(n)},[n]);const l=r=>{const c=(a+r+t.length)%t.length;o(c),e&&e(t[c])},i={width:"100%",height:"100%"},h={enter:r=>({x:r>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:r=>({x:r<0?500:-500,opacity:1})};return s.jsxs(b,{justifyContent:"center",alignItems:"center",position:"relative",width:i.width,height:i.height,overflow:"hidden",children:[s.jsx(ut,{custom:a,children:t.map((r,c)=>s.jsx(dt.div,{custom:c-a,variants:h,initial:"enter",animate:"center",exit:"exit",transition:{x:{type:"spring",stiffness:300,damping:30},opacity:{duration:.2}},style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%",display:c===a?"block":"none"},onClick:()=>{window.open(r.imageUrl)},children:dn(r.imageUrl)?s.jsx(Mn,{src:r.imageUrl,alt:`image-${r.id}`,width:"100%",height:"100%",objectFit:"contain"}):s.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:r.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:s.jsx("track",{kind:"captions"})})},r.id))}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:s.jsx(Na,{}),onClick:()=>l(-1),position:"absolute",left:"0",zIndex:"2"}),s.jsx(O,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:s.jsx(wn,{}),onClick:()=>l(1),position:"absolute",right:"0",zIndex:"2"})]})},Ra=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(hn,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})}})]}),za=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsxs(pn,{width:"100%",step:e==null?void 0:e.step,value:e.value,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Pn,{}),s.jsxs(jn,{children:[s.jsx(kn,{}),s.jsx(In,{})]})]})]}),s.jsx(b,{children:s.jsxs(Mt,{step:e==null?void 0:e.step,value:Number(e.value),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t})},children:[s.jsx(Et,{children:s.jsx(Nt,{})}),s.jsx(_t,{})]})})]}),$a=e=>{var t;return s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(En,{value:e.value,onChange:n=>{var a;return(a=e==null?void 0:e.updateMetaData)==null?void 0:a.call(e,{promptKey:e.promptKey,name:e.name,value:n.target.value})},children:(t=e==null?void 0:e.options)==null?void 0:t.map((n,a)=>s.jsx("option",{value:n,children:n},`select${e.promptKey}${e.classType}${e.name}${a}`))})]})},Oa=e=>s.jsxs(b,{gap:1,direction:"column",children:[s.jsx(b,{children:e.label??e.name}),s.jsx(Dt,{value:e.value,onChange:t=>{var n;return(n=e==null?void 0:e.updateMetaData)==null?void 0:n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.value})},rows:5})]});var M=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(M||{});const Ba=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(b,{children:"No Support"})]}),Fa=e=>s.jsxs(b,{gap:2,children:[s.jsx(b,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.name}),s.jsx(Be,{isChecked:!!e.value,onChange:t=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:t.target.checked})}})]}),Ka={[M.Input]:Ra,[M.InputSlider]:za,[M.Select]:$a,[M.Textarea]:Oa,[M.Checkbox]:Fa,NoSupport:Ba},Va=mn();function La(e){var a,o,l,i,h;const t=(a=Va[e.classType])==null?void 0:a.nodeData,n={...((o=t==null?void 0:t.input)==null?void 0:o.required)??{},...((l=t==null?void 0:t.input)==null?void 0:l.optional)??{}}[e.name];return(n==null?void 0:n[0])==="STRING"?(i=n==null?void 0:n[1])!=null&&i.multiline?{type:M.Textarea}:{type:M.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:M.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:M.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((h=n==null?void 0:n[0])!=null&&h.every(r=>typeof r=="string"))?{options:n==null?void 0:n[0],type:M.Select}:{type:M.NoSupport}}const $t=e=>{const t=La(e),n=Ka[t.type??"Input"];return s.jsxs(_n,{templateColumns:"max-content 1fr",gap:1,children:[s.jsx(b,{children:s.jsx(O,{onClick:()=>{var a;return(a=e==null?void 0:e.updateTopField)==null?void 0:a.call(e,{name:e.name,promptKey:e.promptKey,class_type:e.classType})},variant:"text",icon:de(e.topFields,{name:e.name,promptKey:e.promptKey,classType:e.classType})?s.jsx(Rt,{}):s.jsx(zt,{}),"aria-label":"pin"})}),s.jsx(n,{...e,...t})]})};function Ua({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){if(n.length===0)return null;const o=e.prompt;return s.jsx(s.Fragment,{children:s.jsx(b,{px:2,gap:2,direction:"column",children:n==null?void 0:n.map((l,i)=>{var d,u,x;const h=(d=o==null?void 0:o[l.promptKey])==null?void 0:d.inputs;if(!h||((u=o==null?void 0:o[l.promptKey])==null?void 0:u.class_type)!==l.class_type)return null;const c=h==null?void 0:h[l.name];return s.jsx($t,{promptKey:l.promptKey,classType:(x=o==null?void 0:o[l.promptKey])==null?void 0:x.class_type,name:l.name,value:c,updateMetaData:t,updateTopField:a,topFields:n},`formTop${l.name}${i}`)})})})}function Ha({metaData:e,updateMetaData:t,topFields:n,updateTopField:a}){const o=e.prompt,[l,i]=m.useState([]);return m.useEffect(()=>{i(Object.keys(o).map((h,r)=>r))},[o]),s.jsx(It,{index:l,onChange:h=>i(h),allowMultiple:!0,children:Object.keys(o).map(h=>{const r=o[h],c=r.inputs,d=Object.keys(c).filter(u=>!Array.isArray(c[u])&&!de(n,{name:u,promptKey:h,classType:r.class_type}));return d.length===0?null:s.jsxs(Pt,{borderWidth:1,borderRadius:8,my:2,children:[s.jsxs(wt,{children:[s.jsx(fn,{as:"span",flex:"1",textAlign:"left",children:r.class_type}),s.jsx(pt,{})]}),s.jsx(kt,{children:s.jsx(b,{px:2,gap:1,direction:"column",children:d==null?void 0:d.map(u=>{const x=c[u];return de(n,{name:u,promptKey:h,classType:r.class_type})?null:s.jsx($t,{promptKey:h,classType:r==null?void 0:r.class_type,value:x,name:u,updateMetaData:t,updateTopField:a,topFields:n,metaData:e},`form${u}`)})})})]},`AccordionItem${h}`)})})}const Ga=[{promptKey:"4",name:"ckpt_name",class_type:"CheckpointLoaderSimple"},{promptKey:"6",name:"text",class_type:"CLIPTextEncode"},{promptKey:"7",name:"text",class_type:"CLIPTextEncode"},{promptKey:"5",name:"width",class_type:"EmptyLatentImage"},{promptKey:"5",name:"height",class_type:"EmptyLatentImage"},{promptKey:"3",name:"steps",class_type:"KSampler"},{promptKey:"3",name:"sampler_name",class_type:"KSampler"},{promptKey:"3",name:"cfg",class_type:"KSampler"}],de=(e,t)=>e==null?void 0:e.some(n=>n.promptKey===(t==null?void 0:t.promptKey)&&n.name===(t==null?void 0:t.name)&&n.class_type===t.classType);function Wa({metaData:e}){const t=JSON.parse(JSON.stringify(e)),[n,a]=m.useState(Ga),[o,l]=m.useState(t),i=({promptKey:r,name:c,value:d})=>{l(u=>{var x,v,w;return{...u??{},prompt:{...(u==null?void 0:u.prompt)??{},[r]:{...((x=u==null?void 0:u.prompt)==null?void 0:x[r])??{},inputs:{...((w=(v=u.prompt)==null?void 0:v[r])==null?void 0:w.inputs)??{},[c]:d}}}}})},h=r=>{de(n,{name:r.name,promptKey:r==null?void 0:r.promptKey,classType:(r==null?void 0:r.class_type)??""})?a(c=>c.filter(d=>d.name!==r.name||d.promptKey!==r.promptKey)):a(c=>[...c,r])};return s.jsxs(b,{direction:"column",align:"stretch",children:[s.jsx(Ua,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h}),s.jsx(Ha,{topFields:n,metaData:o,updateMetaData:i,updateTopField:h})]})}const Ya=({media:e})=>{const[t,n]=m.useState(),a=async o=>{try{const l=await xn(`/workspace/view_media?filename=${o.localPath}`);n(l)}catch(l){console.error(l)}};return m.useEffect(()=>{e&&a(e)},[e]),s.jsxs(b,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[s.jsxs(Cn,{alignItems:"center",columns:2,spacing:2,children:[s.jsxs(b,{alignItems:"center",gap:1,children:[s.jsx(q,{children:e==null?void 0:e.localPath}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:s.jsx(O,{size:"sm",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})})]}),s.jsxs(b,{gap:1,alignItems:"center",children:[s.jsx(q,{children:"Create Time:"}),s.jsx(q,{children:xt((e==null?void 0:e.createTime)??0,!0)})]})]}),e&&t&&s.jsx(Wa,{metaData:t,media:e})]})},Xa=({mediaList:e,media:t})=>{const[n,a]=m.useState();return m.useEffect(()=>{t&&a(t)},[t]),s.jsxs(b,{gap:3,h:"100%",children:[s.jsx(b,{flex:1,children:s.jsx(Da,{media:e.map(o=>({id:o.id,imageUrl:`/workspace/view_media?filename=${o.localPath}`})),currentNum:e==null?void 0:e.findIndex(o=>o.id===(n==null?void 0:n.id)),setMediaAct:o=>a(e==null?void 0:e.find(l=>l.id===o.id))})}),s.jsx(Ya,{media:n})]})},qa=({media:e,isSelecting:t,selectedID:n,onClickMedia:a,onRefreshImagesList:o,coverPath:l,setCoverPath:i})=>{const{curFlowID:r,loadFilePath:c}=m.useContext(gt),{showDialog:d}=en();if(e.localPath==null)return null;const u=l!=null&&l===e.localPath;if(r==null)return null;const x=s.jsxs(Re,{isExternal:!0,onClick:()=>a(e),position:"relative",children:[t&&s.jsx(Be,{isChecked:n.includes(e.id),position:"absolute",top:2,left:2}),s.jsx(Tn,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!0})]});return s.jsxs(gn,{width:180,mb:2,children:[s.jsx(H,{label:xt(e.createTime,!0),children:x}),s.jsx(H,{label:e.localPath,children:s.jsx(q,{color:"GrayText",noOfLines:1,children:e.localPath})}),s.jsxs(ie,{hidden:t,gap:0,children:[s.jsx(H,{label:"Set as cover",children:s.jsx(O,{size:"sm",variant:"ghost",icon:u?s.jsx(Rt,{size:19}):s.jsx(zt,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=De)==null||v.updateMetaInfo(r,{coverMediaPath:e.localPath}),i(e.localPath)}})}),s.jsx(tn,{flexGrow:1,onClick:()=>d("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{c(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>c(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),s.jsx(H,{label:"Donwload image from gallery",children:s.jsx(Re,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(ft,{size:19}),"aria-label":"donwload image from gallery"})})}),s.jsx(H,{label:"Remove image from gallery",children:s.jsx(O,{size:"sm",variant:"ghost",icon:s.jsx(vn,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var w,y;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((w=vt)==null?void 0:w.delete(e.id)),u&&(await((y=De)==null?void 0:y.updateMetaInfo(r,{coverMediaPath:void 0})),i("")),o())}})})]})]})},Ja=qa;function us({onclose:e}){const{curFlowID:t}=m.useContext(gt),[n,a]=m.useState(""),[o,l]=m.useState([]),[i,h]=m.useState(!1),[r,c]=m.useState(""),[d,u]=m.useState([]),[x,v]=m.useState(),[w,y]=m.useState(""),S=p=>{y(p)},C=async()=>{var P;if(t==null)return;const p=await((P=vt)==null?void 0:P.listByWorkflowID(t));u(p??[])};m.useEffect(()=>{var p;C(),t&&((p=De)==null||p.get(t).then(P=>{P&&(a(P.name),P!=null&&P.coverMediaPath&&c(P==null?void 0:P.coverMediaPath))}))},[]);const _=w.length?d==null?void 0:d.filter(p=>{var P;return(P=p.workflowJSON)==null?void 0:P.includes(w??"")}):d;if(t==null)return null;const V=p=>{if(i){o.includes(p.id)?l(o.filter(P=>P!==p.id)):l([...o,p.id]);return}v(p)},B=d.length>0&&o.length===d.length;return s.jsxs(nn,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[s.jsx(an,{}),s.jsxs(sn,{width:"90%",maxWidth:"90vw",height:"90vh",children:[s.jsxs(on,{children:[s.jsx(ie,{gap:2,mb:2,children:s.jsxs(yn,{size:"md",mr:2,children:[!!x&&s.jsx(O,{onClick:()=>v(void 0),variant:"ghost",mr:1,"aria-label":"back",icon:s.jsx(Ea,{})}),"Gallery - ",n,!x&&s.jsx(b,{gap:2,display:"inline-flex",ml:2,children:s.jsx(An,{searchValue:w,onUpdateSearchValue:S})})]})}),i&&s.jsxs(ie,{gap:3,children:[s.jsx(Be,{isChecked:B,onChange:()=>{l(B?[]:d.map(p=>p.id))},children:"All"}),s.jsxs(q,{fontSize:16,children:[o.length," Selected"]}),s.jsx(O,{size:"sm",icon:s.jsx(bn,{size:19}),onClick:()=>h(!1),"aria-label":"cancel"})]})]}),s.jsx(rn,{}),s.jsx(ln,{overflowY:"auto",children:x?s.jsx(Xa,{mediaList:d,media:x}):s.jsx(ie,{wrap:"wrap",children:_.map(p=>s.jsx(Ja,{selectedID:o,media:p,isSelecting:i,onClickMedia:V,onRefreshImagesList:C,coverPath:r,setCoverPath:c},p.id))})})]})]})}export{us as default}; diff --git a/dist/workspace_web/IconCopy-Hs60LgD8.js b/dist/workspace_web/IconCopy-Hs60LgD8.js new file mode 100644 index 0000000..2e6c4c8 --- /dev/null +++ b/dist/workspace_web/IconCopy-Hs60LgD8.js @@ -0,0 +1 @@ +import{h as a}from"./App-sgH6j00M.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; diff --git a/dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js b/dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js new file mode 100644 index 0000000..fdd3df9 --- /dev/null +++ b/dist/workspace_web/InstallMissingModelsButton-sP7CX4K3.js @@ -0,0 +1 @@ +import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar-4fKW20g4.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aM as I,F as S,an as b}from"./App-sgH6j00M.js";import{V as k}from"./chunk-NTCQBYKE-4zMWD2m4.js";import{I as y,G as C}from"./chunk-JARCRF6W-swAlFRrB.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-hQn4Wngd.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default}; diff --git a/dist/workspace_web/MediaPreview-_sS52WD-.js b/dist/workspace_web/MediaPreview-_sS52WD-.js new file mode 100644 index 0000000..3c967f8 --- /dev/null +++ b/dist/workspace_web/MediaPreview-_sS52WD-.js @@ -0,0 +1 @@ +import{G as Ge,I as Ke}from"./chunk-JARCRF6W-swAlFRrB.js";import{d as M,r as s,f as T,E as Ue,j as f,ae as $e,I as Ee,x as qe,y as ze,m as ae,q as y,p as se,b as Pe,g as Y,k as He,o as Le,e as Me}from"./input.js";import{ao as Fe,ap as We,aq as Xe,h as Re,B as Ye,I as Je,C as Qe,n as Ze,ak as et}from"./App-sgH6j00M.js";function tt(t){const e=parseFloat(t);return typeof e!="number"||Number.isNaN(e)?0:e}function le(t,e){let r=tt(t);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(t){if(!Number.isFinite(t))return 0;let e=1,r=0;for(;Math.round(t*e)/e!==t;)e*=10,r+=1;return r}function Et(t,e,r){return(t-e)*100/(r-e)}function Pt(t,e,r){return(r-e)*t+e}function Mt(t,e,r){const a=Math.round((t-e)/r)*r+e,o=oe(r);return le(a,o)}function nt(t,e,r){return t==null?t:(r{var m;return a==null?"":(m=ue(a,u,r))!=null?m:""}),S=typeof o<"u",x=S?o:C,O=Te(k(x),u),F=r??O,I=s.useCallback(m=>{m!==x&&(S||A(m.toString()),h==null||h(m.toString(),k(m)))},[h,S,x]),w=s.useCallback(m=>{let d=m;return b&&(d=nt(d,i,p)),le(d,F)},[F,b,p,i]),B=s.useCallback((m=u)=>{let d;x===""?d=k(m):d=k(x)+m,d=w(d),I(d)},[w,u,I,x]),G=s.useCallback((m=u)=>{let d;x===""?d=k(-m):d=k(x)-m,d=w(d),I(d)},[w,u,I,x]),K=s.useCallback(()=>{var m;let d;a==null?d="":d=(m=ue(a,u,r))!=null?m:i,I(d)},[a,r,u,I,i]),Q=s.useCallback(m=>{var d;const ee=(d=ue(m,u,F))!=null?d:i;I(ee)},[F,u,I,i]),E=k(x);return{isOutOfRange:E>p||E{const a=$e("sizes",r,st(r))(e);return r===null?null:`repeat(auto-fit, minmax(${a}, 1fr))`})}function ot(t){return Fe(t,e=>e===null?null:`repeat(${e}, minmax(0, 1fr))`)}var lt=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),it=t=>f.jsx(Ee,{viewBox:"0 0 24 24",...t,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function ke(t,e,r,a){s.useEffect(()=>{var o;if(!t.current||!a)return;const u=(o=t.current.ownerDocument.defaultView)!=null?o:window,i=Array.isArray(e)?e:[e],p=new u.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return p.observe(t.current,{attributes:!0,attributeFilter:i}),()=>p.disconnect()})}function ct(t,e){const r=M(t);s.useEffect(()=>{let a=null;const o=()=>r();return e!==null&&(a=window.setInterval(o,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var pt=50,Ae=300;function dt(t,e){const[r,a]=s.useState(!1),[o,u]=s.useState(null),[i,p]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);ct(()=>{o==="increment"&&t(),o==="decrement"&&e()},r?pt:null);const C=s.useCallback(()=>{i&&t(),b.current=setTimeout(()=>{p(!1),a(!0),u("increment")},Ae)},[t,i]),A=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{p(!1),a(!0),u("decrement")},Ae)},[e,i]),S=s.useCallback(()=>{p(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:C,down:A,stop:S,isSpinning:r}}var mt=/^[Ee0-9+\-.]$/;function ft(t){return mt.test(t)}function bt(t,e){if(t.key==null)return!0;const r=t.ctrlKey||t.altKey||t.metaKey;return!(t.key.length===1)||r?!0:e(t.key)}function vt(t={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:o=Number.MIN_SAFE_INTEGER,max:u=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:p,isDisabled:b,isRequired:h,isInvalid:C,pattern:A="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:I,name:w,"aria-describedby":B,"aria-label":G,"aria-labelledby":K,onFocus:Q,onBlur:E,onInvalid:ce,getAriaValueText:pe,isValidCharacter:Z,format:m,parse:d,...ee}=t,te=M(Q),de=M(E),V=M(ce),U=M(Z??ft),ne=M(pe),l=rt(t),{update:j,increment:me,decrement:fe}=l,[je,re]=s.useState(!1),$=!(p||b),_=s.useRef(null),q=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),z=s.useCallback(n=>n.split("").filter(U).join(""),[U]),H=s.useCallback(n=>{var c;return(c=d==null?void 0:d(n))!=null?c:n},[d]),R=s.useCallback(n=>{var c;return((c=m==null?void 0:m(n))!=null?c:n).toString()},[m]);qe(()=>{(l.valueAsNumber>u||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=H(_.current.value);l.setValue(z(c))}},[H,z]);const L=s.useCallback((n=i)=>{$&&me(n)},[me,$,i]),W=s.useCallback((n=i)=>{$&&fe(n)},[fe,$,i]),g=dt(L,W);ke(be,"disabled",g.stop,g.isSpinning),ke(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;const v=H(n.currentTarget.value);j(z(v)),q.current={start:n.currentTarget.selectionStart,end:n.currentTarget.selectionEnd}},[j,z,H]),ge=s.useCallback(n=>{var c,v,N;te==null||te(n),q.current&&(n.target.selectionStart=(v=q.current.start)!=null?v:(c=n.currentTarget.value)==null?void 0:c.length,n.currentTarget.selectionEnd=(N=q.current.end)!=null?N:n.currentTarget.selectionStart)},[te]),xe=s.useCallback(n=>{if(n.nativeEvent.isComposing)return;bt(n,U)||n.preventDefault();const c=Ne(n)*i,v=n.key,P={ArrowUp:()=>L(c),ArrowDown:()=>W(c),Home:()=>j(o),End:()=>j(u)}[v];P&&(n.preventDefault(),P(n))},[U,i,L,W,j,o,u]),Ne=n=>{let c=1;return(n.metaKey||n.ctrlKey)&&(c=.1),n.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const n=ne==null?void 0:ne(l.value);if(n!=null)return n;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let n=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumberu&&(n=u),l.cast(n))},[l,u,o]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var n;(n=_.current)==null||n.focus()})},[e]),Se=s.useCallback(n=>{n.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(n=>{n.preventDefault(),g.down(),X()},[X,g]);We(()=>_.current,"wheel",n=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;n.preventDefault();const D=Ne(n)*i,_e=Math.sign(n.deltaY);_e===-1?L(D):_e===1&&W(D)},{passive:!1});const De=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMax;return{...n,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),Oe=s.useCallback((n={},c=null)=>{const v=b||a&&l.isAtMin;return{...n,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:y(n.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:y(n.onPointerLeave,g.stop),onPointerUp:y(n.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),Be=s.useCallback((n={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:A,"aria-labelledby":K,"aria-label":G,"aria-describedby":B,id:O,disabled:b,...n,readOnly:(v=n.readOnly)!=null?v:p,"aria-readonly":(N=n.readOnly)!=null?N:p,"aria-required":(P=n.required)!=null?P:h,required:(D=n.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":o,"aria-valuemax":u,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(C??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:y(n.onChange,he),onKeyDown:y(n.onKeyDown,xe),onFocus:y(n.onFocus,ge,()=>re(!0)),onBlur:y(n.onBlur,de,Ce)}},[w,S,A,K,G,R,B,O,b,h,p,C,l.value,l.valueAsNumber,l.isOutOfRange,o,u,Ie,he,xe,ge,de,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:je,isDisabled:b,isReadOnly:p,getIncrementButtonProps:De,getDecrementButtonProps:Oe,getInputProps:Be,htmlProps:ee}}var[ht,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[gt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),xt=T(function(e,r){const a=He("NumberInput",e),o=Le(e),u=Xe(o),{htmlProps:i,...p}=vt(u),b=s.useMemo(()=>p,[p]);return f.jsx(gt,{value:b,children:f.jsx(ht,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});xt.displayName="NumberInput";var Nt=T(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});Nt.displayName="NumberInputStepper";var It=T(function(e,r){const{getInputProps:a}=ie(),o=a(e,r),u=J();return f.jsx(Y.input,{...o,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...u.field}})});It.displayName="NumberInputField";var Ve=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),yt=T(function(e,r){var a;const o=J(),{getDecrementButtonProps:u}=ie(),i=u(e,r);return f.jsx(Ve,{...i,__css:o.stepper,children:(a=e.children)!=null?a:f.jsx(lt,{})})});yt.displayName="NumberDecrementStepper";var Ct=T(function(e,r){var a;const{getIncrementButtonProps:o}=ie(),u=o(e,r),i=J();return f.jsx(Ve,{...u,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(it,{})})});Ct.displayName="NumberIncrementStepper";var Ft=Re("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]),St=Re("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);const wt={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function Rt(t){const{searchValue:e,onUpdateSearchValue:r}=t,a=e!=="";return f.jsxs(Ye,{style:{position:"relative"},mb:2,children:[f.jsx(St,{style:wt}),a&&f.jsx(Je,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(Qe,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(Ze,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function Tt({mediaLocalPath:t,size:e,isPreview:r,autoPlay:a,hideBrokenImage:o,onBrokenLink:u}){const[i,p]=s.useState(!0);return s.useEffect(()=>{o&&(async()=>{try{if(!(await fetch(r?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");p(!0)}catch{p(!1),u==null||u()}})()},[]),i?et(t)?f.jsx(Ke,{borderRadius:3,boxSize:`${e}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{Ft as I,Tt as M,xt as N,at as S,It as a,Rt as b,nt as c,Nt as d,Ct as e,yt as f,Pt as p,Mt as r,Et as v}; diff --git a/dist/workspace_web/ModelManagerTopbar-4fKW20g4.js b/dist/workspace_web/ModelManagerTopbar-4fKW20g4.js new file mode 100644 index 0000000..6fbe5aa --- /dev/null +++ b/dist/workspace_web/ModelManagerTopbar-4fKW20g4.js @@ -0,0 +1,7 @@ +import{f as Y,r as m,j as n,g as $,e as Se,a4 as X,b as $e,o as Ve,k as Ue,h as T,a9 as re,af as He,N as _e,ag as Ye,Q as be,S as Ce,T as qe,Z as Qe,M as Je,O as Xe,R as Ze,P as et,_ as tt}from"./input.js";import{au as st,ao as nt,av as H,o as V,B as oe,F as B,l as D,m as ie,aw as ke,ax as pe,ad as Ie,k as q,z as ot,H as W,n as Z,ay as Le,j as Ee,az as it,aA as Te,a0 as rt,a1 as at,a2 as lt,a3 as ct,a4 as dt,aB as Ae,aC as te,an as Ne,aD as ht,aE as ut,ae as ft,a6 as pt}from"./App-sgH6j00M.js";import{I as De,G as mt,C as gt}from"./chunk-JARCRF6W-swAlFRrB.js";import{app as z}from"/scripts/app.js";import{api as J}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-hQn4Wngd.js";var Fe=Y(function(e,s){const{spacing:o="0.5rem",spacingX:r,spacingY:i,children:a,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(ae,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",h),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:r,rowGap:i,padding:"0"},children:g})})});Fe.displayName="Wrap";var ae=Y(function(e,s){const{className:o,...r}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...r})});ae.displayName="WrapItem";function me(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Pe=Y(function(e,s){const{area:o,colSpan:r,colStart:i,colEnd:a,rowEnd:c,rowSpan:l,rowStart:d,...h}=e,f=st({gridArea:o,gridColumn:me(r),gridRow:me(l),gridColumnStart:i,gridColumnEnd:a,gridRowStart:d,gridRowEnd:c});return n.jsx($.div,{ref:s,__css:f,...h})});Pe.displayName="GridItem";function xt(t,e,s){return(t-e)*100/(s-e)}X({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});X({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var yt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),vt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function wt(t){const{value:e=0,min:s,max:o,valueText:r,getValueText:i,isIndeterminate:a,role:c="progressbar"}=t,l=xt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof i=="function"?i(e,l):r})(),role:c},percent:l,value:e}}var[jt,Mt]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),St=Y((t,e)=>{const{min:s,max:o,value:r,isIndeterminate:i,role:a,...c}=t,l=wt({value:r,min:s,max:o,isIndeterminate:i,role:a}),h={height:"100%",...Mt().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),Oe=Y((t,e)=>{var s;const{value:o,min:r=0,max:i=100,hasStripe:a,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...y}=Ve(t),j=Ue("Progress",t),C=d??((s=j.track)==null?void 0:s.borderRadius),b={animation:`${vt} 1s linear infinite`},F={...!h&&a&&c&&b,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${yt} 1s ease infinite normal none running`}},k={overflow:"hidden",position:"relative",...j.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:k,...y,children:n.jsxs(jt,{value:j,children:[n.jsx(St,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:r,max:i,value:o,isIndeterminate:h,css:F,borderRadius:C,title:p,role:x}),l]})})});Oe.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const _t=1/0;function bt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-_t?"-0":s}(t)}function P(t){return typeof t=="string"}function ze(t){return typeof t=="number"}function Ct(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function N(t){return t!=null}function se(t){return!t.trim().length}function Re(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kt=t=>`Missing ${t} property in key`,It=t=>`Property 'weight' in key '${t}' must be a positive integer`,ge=Object.prototype.hasOwnProperty;class Lt{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let r=Be(o);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Be(t){let e=null,s=null,o=null,r=1,i=null;if(P(t)||K(t))o=t,e=xe(t),s=ye(t);else{if(!ge.call(t,"name"))throw new Error(kt("name"));const a=t.name;if(o=a,ge.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(It(a));e=xe(a),s=ye(a),i=t.getFn}return{path:e,id:s,weight:r,src:o,getFn:i}}function xe(t){return K(t)?t:t.split(".")}function ye(t){return K(t)?t.join("."):t}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx{if(N(i))if(a[c]){const l=i[a[c]];if(!N(l))return;if(c===a.length-1&&(P(l)||ze(l)||Ct(l)))s.push(bt(l));else if(K(l)){o=!0;for(let d=0,h=l.length;d{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,P(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();P(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(N(a)){if(K(a)){let c=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:d,value:h}=l.pop();if(N(h))if(P(h)&&!se(h)){let f={v:h,i:d,n:this.norm.get(h)};c.push(f)}else K(h)&&h.forEach((f,u)=>{l.push({nestedArrIndex:u,value:f})})}o.$[i]=c}else if(P(a)&&!se(a)){let c={v:a,n:this.norm.get(a)};o.$[i]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function We(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const r=new le({getFn:s,fieldNormWeight:o});return r.setKeys(t.map(Be)),r.setSources(e),r.create(),r}function Q(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:r=M.distance,ignoreLocation:i=M.ignoreLocation}={}){const a=e/t.length;if(i)return a;const c=Math.abs(o-s);return r?a+c/r:c?1:a}const R=32;function Tt(t,e,s,{location:o=M.location,distance:r=M.distance,threshold:i=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,includeMatches:l=M.includeMatches,ignoreLocation:d=M.ignoreLocation}={}){if(e.length>R)throw new Error(`Pattern length exceeds max of ${R}.`);const h=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=i,p=u;const x=c>1||l,y=x?Array(f):[];let j;for(;(j=t.indexOf(e,p))>-1;){let k=Q(e,{currentLocation:j,expectedLocation:u,distance:r,ignoreLocation:d});if(g=Math.min(k,g),p=j+h,x){let I=0;for(;I=O;w-=1){let S=w-1,_=s[t.charAt(S)];if(x&&(y[S]=+!!_),v[w]=(v[w+1]<<1|1)&_,k&&(v[w]|=(C[w+1]|C[w])<<1|1|C[w+1]),v[w]&G&&(b=Q(e,{errors:k,currentLocation:S,expectedLocation:u,distance:r,ignoreLocation:d}),b<=g)){if(g=b,p=S,p<=u)break;O=Math.max(1,2*u-p)}}if(Q(e,{errors:k+1,currentLocation:u,expectedLocation:u,distance:r,ignoreLocation:d})>g)break;C=v}const F={isMatch:p>=0,score:Math.max(.001,b)};if(x){const k=function(I=[],L=M.minMatchCharLength){let O=[],E=-1,v=-1,w=0;for(let S=I.length;w=L&&O.push([E,v]),E=-1)}return I[w-1]&&w-E>=L&&O.push([E,w-1]),O}(y,c);k.length?l&&(F.indices=k):F.isMatch=!1}return F}function At(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:At(u),startIndex:g})},f=this.pattern.length;if(f>R){let u=0;const g=f%R,p=f-g;for(;u{const{isMatch:j,score:C,indices:b}=Tt(e,p,x,{location:r+y,distance:i,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:o,ignoreLocation:d});j&&(u=!0),f+=C,j&&b&&(h=[...h,...b])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=h),g}}const ve=[];function we(t,e){for(let s=0,o=ve.length;s{if(!N(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let a={indices:r,value:i};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function Ft(t,e){e.score=t.score}class U{constructor(e,s={},o){if(this.options={...M,...s},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new Lt(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof le))throw new Error("Incorrect 'index' type");this._myIndex=s||We(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){N(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,r=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const y=g?g.weight:null;u*=Math.pow(x===0&&y?Number.EPSILON:x,(y||1)*(h?1:p))}),f.score=u})}(l,{ignoreFieldNorm:c}),i&&l.sort(a),ze(s)&&s>-1&&(l=l.slice(0,s)),function(d,h,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Dt),u&&g.push(Ft),d.map(p=>{const{idx:x}=p,y={item:h[x],refIndex:x};return g.length&&g.forEach(j=>{j(p,y)}),y})}(l,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const s=we(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=s.searchIn(i);l&&r.push({item:i,idx:a,matches:[{score:d,value:i,norm:c,indices:h}]})}),r}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=we(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:a,i:c})=>{if(!N(a))return;let l=[];o.forEach((d,h)=>{l.push(...this._findMatches({key:d,value:a[h],searcher:s}))}),l.length&&i.push({idx:c,item:a,matches:l})}),i}_findMatches({key:e,value:s,searcher:o}){if(!N(s))return[];let r=[];if(K(s))s.forEach(({v:i,i:a,n:c})=>{if(!N(i))return;const{isMatch:l,score:d,indices:h}=o.searchIn(i);l&&r.push({score:d,key:e,value:i,idx:a,norm:c,indices:h})});else{const{v:i,n:a}=s,{isMatch:c,score:l,indices:d}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,norm:a,indices:d})}return r}}U.version="7.0.0",U.createIndex=We,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new le({getFn:e,fieldNormWeight:s});return i.setKeys(o),i.setIndexRecords(r),i},U.config=M;function Pt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=r=>{e(r)};return n.jsx(Fe,{children:s.map(r=>n.jsx(ae,{children:n.jsx(T,{colorScheme:"blue",variant:t===r?"solid":"outline",onClick:()=>o(r),size:"sm",children:r})},r))})}const Ot={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function zt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,r]=m.useState(!t.file_hash),[i,a]=m.useState();m.useEffect(()=>{r(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,u,g;const d=await H.models.get(t.model_name+"@"+t.model_type);if(d!=null&&(a(d),(h=d.imageUrl)!=null&&h.length&&s(d.imageUrl)),t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,y=await(await fetch(p)).json();let j;if(await((f=V)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)j=(g=(u=y==null?void 0:y.images)==null?void 0:u[0])==null?void 0:g.url;else if(!y.model.nsfw){const A=y.images.find(G=>G.nsfw==="None");j=A==null?void 0:A.url}j&&s(j);const b={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:y.model.name,civitModelID:String(y.modelId),civitModelVersionID:String(y.id),imageUrl:j??null};H.models.put(b),a(b)}catch{}t.preview&&s(t.preview)},l=d=>{const h=Ot[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[o?n.jsx(B,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(De,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(i==null?void 0:i.civitModelID)!=null?"pointer":"auto",onClick:()=>{(i==null?void 0:i.civitModelID)==null||(i==null?void 0:i.civitModelVersionID)==null||window.open(`https://civitai.com/models/${i==null?void 0:i.civitModelID}?modelVersionId=${i==null?void 0:i.civitModelVersionID}`)}}),n.jsx(D,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(D,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:(i==null?void 0:i.modelName)??t.model_name+t.model_extension})})]})}function Rt({list:t}){return n.jsx(mt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Pe,{children:n.jsx(zt,{data:e})},e.model_name+e.date.getTime()))})}const Bt=async t=>{try{const s=await(await J.fetchApi("/model_manager/install_model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).text();window.dispatchEvent(new CustomEvent("model_install_message",{detail:s}))}catch(e){console.error("Failed to connect to the server:",e)}};function je(t,e=1){const r=t/1024;return r>=1024?(r/1024).toFixed(e)+" GB":r.toFixed(e)+" MB"}function Me(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function Wt(t,e=280,s){var o,r,i,a;if(t)return ke(t)?(i=Me((r=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:r.images,s))==null?void 0:i.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=Me(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Kt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,r]=m.useState();m.useEffect(()=>{p();async function p(){var y;const x=await((y=V)==null?void 0:y.getSetting("showNsfwModelThumbnail"));r(Wt(t,ne,x))}},[t]);const i=ke(t)?t.modelVersions:t.versions,[a,c]=m.useState(((u=i==null?void 0:i[0])==null?void 0:u.name)??""),l=i==null?void 0:i.find(p=>(p==null?void 0:p.name)===a),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=m.useCallback(()=>{if(l==null){console.error("no file is find by name",a);return}e(pe(l,t.name),t)},[a]),f=(g=pe(l))==null?void 0:g.sizeKB;return n.jsxs(Ie,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(De,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),n.jsxs(q,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(D,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(B,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(T,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(D,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(T,{leftIcon:n.jsx(ot,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:i==null?void 0:i.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:je(f),children:n.jsx(D,{flexShrink:1,noOfLines:1,width:"40%",children:je(f)})})]})]})]})}function Gt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(B,{gap:1,alignItems:"center",grow:1,children:[n.jsx(Z,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>e(o.target.value),onKeyUp:o=>{o.code==="Enter"&&s()}}),n.jsx(T,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function $t({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[r,i]=m.useState(""),[a,c]=m.useState([]),[l,d]=m.useState(""),h=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Le();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),c(Object.values(u).flatMap(g=>g)))};return n.jsx(He,{isOpen:t,leastDestructiveRef:h,onClose:s,children:n.jsx(_e,{children:n.jsxs(Ye,{children:[n.jsx(be,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(Ce,{children:n.jsxs(q,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(D,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>d(u.target.value),value:l})]}),n.jsx(D,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:r,onChange:u=>i(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(qe,{children:[n.jsx(T,{ref:h,onClick:s,children:"Cancel"}),n.jsx(T,{onClick:()=>o(r,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function Vt(){const{colorMode:t}=Qe(),e=Ee(),[s,o]=m.useState([]);return m.useEffect(()=>{J.addEventListener("download_progress",r=>{o(r.detail)}),J.addEventListener("download_error",r=>{e({title:"Download Error",description:r.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(q,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:r,progress:i})=>n.jsxs(W,{children:[n.jsx(D,{fontSize:16,width:"40%",children:r.replace(/^.*[\\/]/,"")}),n.jsx(Oe,{isIndeterminate:!i,hasStripe:!0,width:"50%",value:i}),n.jsxs(D,{fontSize:16,width:"10%",children:[i.toFixed(1),"%"]}),n.jsx(T,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>it(r),children:"Cancel"})]},r))})}const Ke="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function Ut(){return localStorage.getItem(Ke)}function Ht(t){localStorage.setItem(Ke,t)}function Yt(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:r}=Te(),i=()=>{Ht(t),o()};return n.jsxs(rt,{isOpen:r,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(at,{children:n.jsx(T,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(lt,{p:5,children:[n.jsx(ct,{}),n.jsx(dt,{}),n.jsxs(q,{spacing:4,children:[n.jsx(D,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:i,children:"Save"})]})]})]})}async function qt(t,e){var a,c;const s={queries:[{q:t,indexUid:"models_v7",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return e&&(s.queries[0].filter=[[`"type"="${e}"`]]),((c=(a=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(s)})).json())==null?void 0:a.results)==null?void 0:c.at(0)).hits??[]}function Qt({onclose:t,searchQuery:e="",modelType:s}){const[o,r]=m.useState([]),[i,a]=m.useState(!1),[c,l]=m.useState(s),d=Ee(),[h,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:y}=Te(),[j,C,b]=Ae(),[A,G]=m.useState({}),[F,k]=m.useState(te),I=m.useCallback(async()=>{var _;a(!0);const v=await qt(u,c);r(v);const w=await Le();w&&G(w);const S=await((_=V)==null?void 0:_.getSetting("defaultFolders"));S&&k(S),a(!1)},[u,c]),L=(v,w)=>{var de,he,ue,fe;if(!((de=b.current)!=null&&de.id)&&!w){console.error("no url to download");return}let S=w??`https://civitai.com/api/download/models/${(he=b.current)==null?void 0:he.id}`,_=(ue=b.current)==null?void 0:ue.name;if(!_&&(_=S.split("/").pop(),!_)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:_,status:"info",duration:4e3,isClosable:!0}),_!=null&&f(Ge=>[...Ge,_??""]);const ce=Ut();ce&&(S+=`?token=${ce}`),Bt({file_hash:(fe=b.current)==null?void 0:fe.SHA256,filename:_,save_path:v,url:S}),C(void 0),y()},O=async(v,w)=>{const S=F[w.type];C(v),S==null?x():L(S)},E=async(v,w)=>{var _;const S={...F,[v]:w};await((_=V)==null?void 0:_.upsert({defaultFolders:S})),k(S)};return m.useEffect(()=>{I()},[c]),n.jsxs(n.Fragment,{children:[n.jsxs(Je,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(_e,{}),n.jsxs(Xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(be,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Gt,{searchQuery:u,setSearchQuery:g,onSearch:I}),n.jsx(T,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(Yt,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(T,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(v=>n.jsx(T,{size:"sm",py:1,isActive:c===v,onClick:()=>{l(v)},children:v},v)),c&&A[te[c]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(D,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:F[c],onChange:v=>E(c,v.target.value),children:A[te[c]].map(v=>n.jsx("option",{value:v,children:v}))})]})]}),i&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(Ze,{}),n.jsxs(Ce,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(v=>n.jsx(Kt,{model:v,onClickInstallModel:O,installing:h},v.id))}),n.jsx(Vt,{})]})]})]}),n.jsx($t,{fileSelected:!!j,isOpen:p,onClose:y,selectFolder:(v,w)=>{L(v,b.current?void 0:w)}})]})}function Jt(){const[t,e]=m.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",colorScheme:"teal",onClick:()=>e(!0),children:"Install Models"}),t&&n.jsx(Qt,{modelType:"Checkpoint",onclose:()=>e(!1)})]})}const Xt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{a(),J.addEventListener("model_list",l=>{c(l.detail)})},[]);const a=async()=>{const l=await ut();c(l)},c=async l=>{if(!l)return;i(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),e(d),o(l.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:r}};function Zt(){const[t,e,s]=Ae(!1),o=()=>{var c;(c=V)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{o()},[]);const r=c=>{var d;const l=c.target.checked;(d=V)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const c=await H.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,u=await(await fetch(h)).json();let g;if(s.current)g=(d=(l=u==null?void 0:u.images)==null?void 0:l[0])==null?void 0:d.url;else if(!u.model.nsfw){const p=u.images.find(x=>x.nsfw==="None");g=p==null?void 0:p.url}H.models.update(c.id,{imageUrl:g??null})}catch{}};return n.jsx(gt,{isChecked:t,onChange:r,children:"Show NSFW"})}function es(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),r=e.dataTransfer.getData("nodeType"),i=LiteGraph.createNode(r);i.pos=[e.canvasX,e.canvasY],i.configure({widgets_values:[o]}),z.graph.add(i)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function ts({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,r]=m.useState(""),[i,a]=m.useState("name"),{loading:c,modelTypeList:l,modelsList:d}=Xt(),[h,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const y=await H.models.toArray();f(d.map(j=>({...j,db:y.find(C=>C.id===j.model_name+"@"+j.model_type)})))}},[d]),m.useEffect(()=>{let x=[];o.length?x=new U(h,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=d.filter(y=>y.model_type===e).sort((y,j)=>i==="name"?y.model_name.localeCompare(j.model_name):j.date.getTime()-y.date.getTime()),g(x)},[e,d,o,i,h]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(et,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ie,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:ft,overflowY:"auto",children:[n.jsxs(B,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ne,{size:"md",mr:2,children:"Models"}),n.jsx(Jt,{})]}),n.jsx(B,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>r(x.target.value)})}),n.jsxs(B,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:i,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx(Zt,{})]}),!o.length&&n.jsx(Pt,{modelTypeList:l,setSelectedModel:s,selectedModel:e}),n.jsx(Rt,{list:u}),c&&n.jsx(B,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(es,{})]})})}const ss=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-sP7CX4K3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function ns(){const{setRoute:t,route:e}=m.useContext(pt),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const i=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),c=LiteGraph.createNode(a);c.pos=[o.canvasX,o.canvasY],c.configure({widgets_values:[i]}),z.graph.add(c)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(q,{style:{position:"relative"},children:[n.jsx(T,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>t("modelList"),px:1,children:"Models"}),n.jsx("div",{style:{position:"absolute",top:"38px",left:"0px"},children:n.jsx(ss,{})}),e==="modelList"&&n.jsx(ts,{onClose:()=>t("root")})]})}const ds=Object.freeze(Object.defineProperty({__proto__:null,default:ns},Symbol.toStringTag,{value:"Module"}));export{Pe as G,Jt as I,ds as M,qt as g}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-sP7CX4K3.js","workspace_web/input.js","workspace_web/App-sgH6j00M.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-4zMWD2m4.js","workspace_web/chunk-JARCRF6W-swAlFRrB.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-hQn4Wngd.js"] + } + return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) +} \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js b/dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js new file mode 100644 index 0000000..7dfc5e8 --- /dev/null +++ b/dist/workspace_web/RecentFilesDrawer-UFHH0mIW.js @@ -0,0 +1,8 @@ +import{f as Oe,n as fn,o as pa,j as c,g as be,e as Ie,Y as ha,r as v,E as Ke,w as pn,M as qe,N as Xe,O as Ze,Q as Je,R as Qe,S as et,V as xt,h as ee,Z as yt,T as ma,$ as je,a0 as va,a1 as ga,a2 as ba,a3 as hn,a4 as Sa,a5 as P,a6 as E,a7 as xa,a8 as mn,X as F,k as ge,a9 as ya,I as Ct,aa as Rt}from"./input.js";import{b as Ca,a as wa,u as vn,c as Oa,d as Ia,e as Ma,S as ka,M as gn,f as Pa,g as ja,h as q,H as K,T as bn,I as Z,t as Se,i as Sn,j as wt,E as Tt,k as de,l as J,m as ne,n as tt,o as U,R as pe,p as Da,q as Nt,B as z,F as Ce,r as $t,s as Va,v as Ea,w as Me,x as Ve,y as te,z as Fa,D as xn,A as G,C as yn,G as La,J as Ot,K as Ra,L as Cn,N as Ta,O as fe,P as Na,Q as $a,U as za,V as It,W as Aa,X as _a,Y as Ha,Z as xe,_ as dt,$ as Ba,a0 as Wa,a1 as Ua,a2 as Ga,a3 as Ya,a4 as Ka,a5 as qa,a6 as Mt,a7 as wn,a8 as Xa,a9 as Za,aa as Ja,ab as Qa,ac as zt,ad as er,ae as tr,af as nr,ag as at,ah as ar}from"./App-sgH6j00M.js";import{C as Ee}from"./chunk-JARCRF6W-swAlFRrB.js";import{V as On}from"./chunk-NTCQBYKE-4zMWD2m4.js";import{S as rr,N as ir,a as or,I as sr,M as lr,b as cr}from"./MediaPreview-_sS52WD-.js";import{app as Re}from"/scripts/app.js";import{I as ur}from"./IconCopy-Hs60LgD8.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var In=Oe(function(e,a){const{borderLeftWidth:r,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:s,borderWidth:o,borderStyle:l,borderColor:u,...d}=fn("Divider",e),{className:f,orientation:h="horizontal",__css:p,...m}=pa(e),b={vertical:{borderLeftWidth:r||s||o||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||o||"1px",width:"100%"}};return c.jsx(be.hr,{ref:a,"aria-orientation":h,...m,__css:{...d,border:"0",borderColor:u,borderStyle:l,...b[h],...p},className:Ie("chakra-divider",f)})});In.displayName="Divider";function dr(n,e={}){const{ssr:a=!0,fallback:r}=e,{getWindow:t}=ha(),i=Array.isArray(n)?n:[n];let s=Array.isArray(r)?r:[r];s=s.filter(u=>u!=null);const[o,l]=v.useState(()=>i.map((u,d)=>({media:u,matches:a?!!s[d]:t().matchMedia(u).matches})));return v.useEffect(()=>{const u=t();l(i.map(h=>({media:h,matches:u.matchMedia(h).matches})));const d=i.map(h=>u.matchMedia(h)),f=h=>{l(p=>p.slice().map(m=>m.media===h.media?{...m,matches:h.matches}:m))};return d.forEach(h=>{typeof h.addListener=="function"?h.addListener(f):h.addEventListener("change",f)}),()=>{d.forEach(h=>{typeof h.removeListener=="function"?h.removeListener(f):h.removeEventListener("change",f)})}},[t]),o.map(u=>u.matches)}function fr(n,e,a=Ca){let r=Object.keys(n).indexOf(e);if(r!==-1)return n[e];let t=a.indexOf(e);for(;t>=0;){const i=a[t];if(n.hasOwnProperty(i)){r=t;break}t-=1}if(r!==-1){const i=a[r];return n[i]}}function pr(n){var e,a;const r=pn(n)?n:{fallback:n??"base"},i=Ke().__breakpoints.details.map(({minMaxQuery:u,breakpoint:d})=>({breakpoint:d,query:u.replace("@media screen and ","")})),s=i.map(u=>u.breakpoint===r.fallback),l=dr(i.map(u=>u.query),{fallback:s,ssr:r.ssr}).findIndex(u=>u==!0);return(a=(e=i[l])==null?void 0:e.breakpoint)!=null?a:r.fallback}function hr(n,e){var a;const r=pn(e)?e:{fallback:e??"base"},t=pr(r),i=Ke();if(!t)return;const s=Array.from(((a=i.__breakpoints)==null?void 0:a.keys)||[]),o=Array.isArray(n)?Object.fromEntries(Object.entries(wa(n,s)).map(([l,u])=>[l,u])):n;return fr(o,t,s)}var Mn=Oe((n,e)=>{const{title:a,children:r,className:t,...i}=n,s=Ie("chakra-menu__group__title",t),o=vn();return c.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[a&&c.jsx(be.p,{className:s,...i,__css:o.groupTitle,children:a}),r]})});Mn.displayName="MenuGroup";var kn=n=>{const{className:e,title:a,...r}=n,t=Oa(r);return c.jsx(Mn,{title:a,className:Ie("chakra-menu__option-group",e),...t})};kn.displayName="MenuOptionGroup";var mr=Oe((n,e)=>{const a=vn();return c.jsx(be.button,{ref:e,...n,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...a.button}})}),Fe=Oe((n,e)=>{const{children:a,as:r,...t}=n,i=Ia(t,e),s=r||mr;return c.jsx(s,{...i,className:Ie("chakra-menu__menu-button",n.className),children:c.jsx(be.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:n.children})})});Fe.displayName="MenuButton";var vr=n=>c.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...n,children:c.jsx("polygon",{fill:"currentColor",points:"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"})}),kt=Oe((n,e)=>{const{icon:a,iconSpacing:r="0.75rem",...t}=n,i=Ma(t,e);return c.jsxs(ka,{...i,className:Ie("chakra-menu__menuitem-option",t.className),children:[a!==null&&c.jsx(gn,{fontSize:"0.8em",marginEnd:r,opacity:n.isChecked?1:0,children:a||c.jsx(vr,{})}),c.jsx("span",{style:{flex:1},children:i.children})]})});kt.id="MenuItemOption";kt.displayName="MenuItemOption";var Pn=Oe(function(e,a){const{getHeaderProps:r}=Pa(),t=ja();return c.jsx(be.header,{...r(e,a),className:Ie("chakra-popover__header",e.className),__css:t.header})});Pn.displayName="PopoverHeader";var gr=q("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),br=q("dots-vertical","IconDotsVertical",[["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]),Sr=q("edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),At=q("file-import","IconFileImport",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3",key:"svg-1"}]]),xr=q("file","IconFile",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}]]),jn=q("folder-plus","IconFolderPlus",[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),yr=q("list-check","IconListCheck",[["path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5",key:"svg-0"}],["path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5",key:"svg-1"}],["path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5",key:"svg-2"}],["path",{d:"M11 6l9 0",key:"svg-3"}],["path",{d:"M11 12l9 0",key:"svg-4"}],["path",{d:"M11 18l9 0",key:"svg-5"}]]),Cr=q("lock-open","IconLockOpen",[["path",{d:"M5 11m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M12 16m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 11v-5a4 4 0 0 1 8 0",key:"svg-2"}]]),wr=q("menu-2","IconMenu2",[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}],["path",{d:"M4 18l16 0",key:"svg-2"}]]),Or=q("moon","IconMoon",[["path",{d:"M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z",key:"svg-0"}]]),Ir=q("pencil","IconPencil",[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]]),Mr=q("settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]),kr=q("sun","IconSun",[["path",{d:"M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 12h1m8 -9v1m8 8h1m-9 8v1m-6.4 -15.4l.7 .7m12.1 -.7l-.7 .7m0 11.4l.7 .7m-12.1 -.7l-.7 .7",key:"svg-1"}]]),Dn=q("tag","IconTag",[["path",{d:"M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z",key:"svg-1"}]]),Pr=q("upload","IconUpload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);function jr({onclose:n}){const[e,a]=v.useState([]),r=async()=>{var i;const t=await((i=Se)==null?void 0:i.listAll());a(t??[])};return v.useEffect(()=>{r()},[]),c.jsxs(qe,{isOpen:!0,onClose:n,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"My Tags"}),c.jsx(Qe,{}),c.jsx(et,{children:e.map(t=>c.jsxs(K,{children:[c.jsx(bn,{children:t.name}),c.jsx(Z,{onClick:async()=>{var i;await((i=Se)==null?void 0:i.delete(t.name)),r()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:c.jsx(Sn,{})})]}))})]})]})}function Dr(){const n=wt(),e=v.useRef([{title:"Save current workflow",key:Tt.SAVE},{title:"Save as current workflow",key:Tt.SAVE_AS}]),[a,r]=v.useState({save:"",saveAs:""}),[t,i]=v.useState(),s=async(l,u)=>{var f;l.preventDefault();let d="";if(l.ctrlKey&&(d+="Control+"),l.metaKey&&(d+="Command+"),l.shiftKey&&(d+="Shift+"),l.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt"].includes(l.key)){d+=l.key.toUpperCase();const h={...a};delete h[u],Object.values(h).includes(d)?n({title:"Shortcut key conflict",description:`The shortcut key 「${d}」 is already used, please + modify it.`,status:"info",duration:3e3,position:"top",isClosable:!1}):(await((f=U)==null?void 0:f.upsert({shortcuts:{...a,[u]:d}})),o())}},o=()=>{var l;(l=U)==null||l.getSetting("shortcuts").then(u=>{var f;const d=u??((f=U)==null?void 0:f.defaultSettings.shortcuts);r({...a,...d})})};return v.useEffect(()=>{o()},[]),c.jsxs(de,{children:[c.jsx(J,{children:"Keyboard Shortcut"}),e.current.map(l=>c.jsxs(K,{children:[c.jsx(J,{fontSize:"sm",w:170,children:l.title}),c.jsx(ne,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:t===l.key,children:c.jsx(tt,{value:a[l.key],onKeyDown:u=>{s(u,l.key)},onFocus:()=>{i(l.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},l.key))]})}function Vr(){const{setRefreshFolderStamp:n}=v.useContext(pe),[e,a]=v.useState(!1),r=()=>{var i;(i=U)==null||i.getSetting("foldersOnTop").then(s=>{a(!!s)})},t=i=>{var o;const s=i.target.checked;(o=U)==null||o.upsert({foldersOnTop:s}).then(()=>{r(),n(Date.now())})};return v.useEffect(()=>{r()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:e,onChange:t,children:"Folders always on top"})})}function Er(){const[n,e]=v.useState(!1),[a,r]=v.useState(""),{showDialog:t}=xt(),i=()=>{var o,l;(o=U)==null||o.getSetting("myWorkflowsDir").then(u=>{r(u??"undefined")}),(l=U)==null||l.getSetting("twoWaySync").then(u=>{e(u??!1)})};v.useEffect(()=>{i()},[]);const s=async o=>{var u,d;if(!o.target.checked){await((u=U)==null?void 0:u.upsert({twoWaySync:o.target.checked})),i();return}const l=await((d=U)==null?void 0:d.getSetting("myWorkflowsDir"));t(c.jsx(Da,{myWorkflowsDir:l??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var f;await((f=U)==null?void 0:f.upsert({twoWaySync:!0})),i()},colorScheme:"red"}])};return c.jsxs(de,{children:[c.jsx(J,{children:"Only for legacy two way sync users to get back their data. Do not disable two way sync if you have already enabled it. It may cause some unexpected issues."}),c.jsx(Ee,{isChecked:n,onChange:s,children:"Enable two way sync"})]})}function _t({settingKey:n,text:e,defaultChecked:a=!1}){const[r,t]=v.useState(a),i=()=>{var s;(s=U)==null||s.getSetting(n).then(o=>{t(!!o)})};return v.useEffect(()=>{i()},[]),c.jsx(de,{children:c.jsx(Ee,{isChecked:r,onChange:async s=>{var o;await((o=U)==null?void 0:o.upsert({[n]:s.target.checked})),i()},children:e})})}function Fr(){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),[t,i]=v.useState([]),[s,o]=v.useState(""),[l,u]=v.useState([]),[d,f]=v.useState(!1),[h,p]=v.useState(!1),[m,b]=v.useState(!1),g=v.useRef(null),S=wt(),{showDialog:w}=xt(),y=m?"\\":"/";v.useEffect(()=>{var D;Nt().then(O=>{o(O.path??""),b(O.os==="win32")}),(D=U)==null||D.getSetting("twoWaySync").then(O=>{f(O??!1)})},[]);const x=async D=>{const{dir_path:O="",dir_contents:L=[],error:_=""}=await $t(D??"");return _.includes("Operation not permitted")?(p(!0),C(),{isError:!0}):{dirList:L,dirPath:O}},j=async()=>{const{isError:D=!1,dirList:O=[]}=await x(s);D||(i(O),r(!0),u(s&&s.split(y).filter(L=>!!L)||[]))},C=()=>{r(!1),e(!1),u([])},V=async(D,O=!1,L=!1)=>{var I,R;if(O){const{path:N}=await Nt();N&&await Va(N,D)}await((I=U)==null?void 0:I.upsert({myWorkflowsDir:D}));const _=await((R=U)==null?void 0:R.getSetting("myWorkflowsDir"))??"";o(_),L&&p(!1),C()},M=async D=>{if(D){const{error:L=""}=await $t(D);if(L.includes("Not a directory")){S({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const O=D??`${m?"":y}${l.join(y)}`;w("Do you want to copy all workflows to new directory?",[{label:"Yes",onClick:()=>{V(O,!0,!!D)}},{label:"No",onClick:()=>{V(O,!1,!!D)}}])},T=async()=>{const{dirPath:D,dirList:O}=await x("");u(D.split(y).filter(L=>!!L)),i(O)},A=async(D,O)=>{var R;let L="";D===-1&&O?L=`${m?"":y}${l.concat([O]).join(y)}`:L=`${m?"":y}${l.slice(0,D+1).join(y)}`;const{isError:_=!1,dirList:I=[]}=await x(L);_||(i(I),u(m?L.split(y):(R=L.slice(1))==null?void 0:R.split(y)))},W=c.jsxs(z,{textAlign:"end",mb:4,children:[c.jsx(tt,{placeholder:"Please enter the absolute path directory address",ref:g,mt:2,mb:2}),c.jsx(ee,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var D,O;(D=g==null?void 0:g.current)!=null&&D.value&&M((O=g==null?void 0:g.current)==null?void 0:O.value)},children:"Save"})]}),H=()=>{r(!0),e(!0)};return c.jsxs(c.Fragment,{children:[c.jsxs(z,{mb:4,children:[c.jsx(J,{mb:2,fontWeight:500,children:"My Workflows Save Directory"}),a?n?W:c.jsxs(On,{spacing:2,alignItems:"start",children:[c.jsx(de,{spacing:"2px",direction:"row",wrap:"wrap",children:l.map((D,O)=>c.jsxs("span",{children:[O>0&&y,c.jsx(ee,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{A(O)},children:D},`${D}-${O}`)]},D))}),c.jsx(rr,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:t.map((D,O)=>c.jsx(ee,{size:"sm",leftIcon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),justifyContent:"start",onClick:()=>{A(-1,D)},children:D},`${D}-${O}`))}),c.jsxs(z,{w:"100%",textAlign:"end",children:[c.jsx(ee,{colorScheme:"teal",size:"sm",onClick:()=>{M()},children:"Save"}),c.jsx(ee,{size:"sm",onClick:T,mr:2,ml:2,children:"Reset"}),c.jsx(ee,{size:"sm",onClick:C,children:"Cancel"})]})]}):c.jsxs(Ce,{children:[c.jsx(bn,{overflowWrap:"anywhere",children:s}),c.jsx(ne,{label:d?"Choose folder":"Enable two way sync to link local folder",children:c.jsx(Z,{"aria-label":"Select folder",size:"sm",ml:2,isDisabled:!d,icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})}),onClick:j})}),c.jsx(ne,{label:d?"Input absolute path":"Enable two way sync to link local folder",children:c.jsx(Z,{isDisabled:!d,"aria-label":"Enter folder address",size:"sm",ml:2,icon:c.jsx(Sr,{size:19}),onClick:H,variant:"ghost"})})]})]}),c.jsxs(qe,{isOpen:h,onClose:()=>p(!1),size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Kind tips"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(z,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?c.jsxs(J,{fontWeight:500,children:["There is no permission to access the folder. You need to grant full disk access permission to the terminal that starts the ComfyUI program. For details, refer to the",c.jsx(ee,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos + -catalina-update`,children:"Document"}),", or you can manually enter the absolute path of the folder in the input box below to save."]}):c.jsx(J,{fontWeight:500,children:"You do not have permission to access the folder. It is recommended that you manually enter the absolute path address of the required folder."}),W]})})]})]})]})}function Lr(){const[n,e]=v.useState(200),a=i=>{if(!i.length){e(0);return}e(parseInt(i))},r=async()=>{var i;n<0&&e(0),await((i=U)==null?void 0:i.upsert({maximumChangelogNumber:Number(n)}))},t=()=>{var i;(i=U)==null||i.getSetting("maximumChangelogNumber").then(s=>{e(s)})};return v.useEffect(()=>{t()},[]),c.jsxs(de,{children:[c.jsx(J,{children:'Maximum number of save change history to store. This does not include versions that you created by "Create Version", which are always stored and has no limit.'}),c.jsx(ir,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:n,onChange:i=>a(i),onBlur:()=>{r()},onKeyUp:i=>{i.key==="Enter"&&r()},children:c.jsx(or,{})})]})}function Rr({onClose:n}){return c.jsx(c.Fragment,{children:c.jsxs(qe,{isOpen:!0,onClose:n,size:"xl",children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Settings"}),c.jsx(Qe,{}),c.jsx(et,{pb:14,children:c.jsx(K,{children:c.jsxs(On,{divider:c.jsx(Ea,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[c.jsx(Fr,{}),c.jsx(Dr,{}),c.jsx(_t,{settingKey:"autoSave",text:"Enable auto save workflow"}),c.jsx(Er,{}),c.jsx(Vr,{}),c.jsx(_t,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),c.jsx(Lr,{})]})})})]})]})})}const rt=16;function Tr({}){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),{colorMode:t,toggleColorMode:i}=yt();return c.jsxs(c.Fragment,{children:[c.jsxs(Me,{isLazy:!0,children:[c.jsx(Fe,{as:Z,"aria-label":"Options",icon:c.jsx(wr,{}),size:"sm",variant:"outline"}),c.jsxs(Ve,{children:[c.jsx(te,{onClick:()=>r(!0),icon:c.jsx(Mr,{size:16}),fontSize:16,children:"Settings"}),c.jsx(te,{onClick:()=>e(!0),icon:c.jsx(Dn,{size:rt}),fontSize:16,children:"Manage Tags"}),c.jsxs(te,{onClick:i,icon:t==="light"?c.jsx(Or,{size:rt}):c.jsx(kr,{size:rt}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),n&&c.jsx(jr,{onclose:()=>e(!1)}),a&&c.jsx(Rr,{onClose:()=>r(!1)})]})}function Nr(n){const{multipleState:e,changeMultipleState:a,selectedKeys:r,isSelectedAll:t,batchOperationCallback:i}=n,s=async()=>{var u;const l=await((u=G)==null?void 0:u.batchQuery(r))??[];La(l)},o=r.length===0;return c.jsx(K,{spacing:2,wrap:"wrap",mb:0,children:e?c.jsxs(c.Fragment,{children:[c.jsx(Ee,{isChecked:t,onChange:l=>{i("selectAll",l.target.checked)}}),c.jsx(ne,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:c.jsx(Z,{isDisabled:o,"aria-label":"Batch export",size:"sm",icon:c.jsx(Fa,{size:21}),onClick:s})}),c.jsx(ne,{hasArrow:!0,label:"Batch deletion",children:c.jsx(xn,{isDisabled:o,variant:"solid",promptMessage:`Are you sure you want to delete these ${r.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var l;await((l=G)==null?void 0:l.batchDeleteFlow(r)),i("batchDelete")}})}),r.length>0&&c.jsx(J,{fontWeight:600,children:`Selected ${r.length}`}),c.jsx(ne,{hasArrow:!0,label:"Exit multi-select",children:c.jsx(Z,{"aria-label":"Close multi-select operation",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{a(!1)}})})]}):c.jsx(ne,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:c.jsx(Z,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:c.jsx(yr,{size:21}),onClick:()=>{a(!0)}})})})}const $r=(n,e)=>{const[a,r]=v.useState(n);return v.useEffect(()=>{const t=setTimeout(()=>{r(n)},e);return()=>{clearTimeout(t)}},[n,e]),a},Ht=6;function zr({setSelectedTag:n,selectedTag:e}){const[a,r]=v.useState(!1),[t,i]=v.useState([]);return v.useEffect(()=>{var s;(s=Se)==null||s.listAll().then(o=>{i(o)})},[]),c.jsxs(K,{spacing:2,wrap:"wrap",mb:0,children:[e!=null&&c.jsx(Z,{"aria-label":"Close",size:"sm",icon:c.jsx(yn,{}),onClick:()=>{n(void 0)}}),t.slice(0,a?void 0:Ht).map(s=>c.jsx(ee,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(s.name)},isActive:e===s.name,children:s.name},s.name)),(t.length??0)>Ht&&c.jsx(Z,{"aria-label":"Show-all-tags",size:"sm",icon:a?c.jsx(gr,{}):c.jsx(Ot,{}),onClick:()=>r(!a)})]})}function Vn({parentFolderID:n,onlyImportFile:e=!1}){const{onRefreshFilesList:a}=v.useContext(pe),[r,t]=v.useState("file"),i=v.useRef(null),s=d=>{var f;t(d),d==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(f=i.current)==null||f.click()},o=async d=>{var f;if(d.type==="image/png"){const h=await Ta(d),p=h==null?void 0:h.workflow;if(p)return{json:p,name:d.name.replace(".png","")}}else if(d.type==="application/json"||(f=d.name)!=null&&f.endsWith(".json"))return await new Promise((h,p)=>{const m=new FileReader;m.onload=b=>{var g;try{const S=(g=b.target)==null?void 0:g.result;typeof S=="string"?h({json:S,name:d.name.replace(".json","")}):p(new Error("File content is not a string"))}catch(S){p(S)}},m.onerror=p,m.readAsText(d)});return null},l=async d=>{var h,p;const f=[d];for(;f.length>0;){const m=f.shift();if(m&&!m.isFile){const b=await((h=fe)==null?void 0:h.create({name:m.name,parentFolderID:m.parentFolderID}));if(m.children&&m.children.length){const g=[];m.children.forEach(S=>{S.isFile&&S.file?g.push(S.file):(S.parentFolderID=b==null?void 0:b.id,f.push(S))}),g.length&&await((p=G)==null?void 0:p.batchCreateFlows(g,void 0,b==null?void 0:b.id))}}}a==null||a()},u=async d=>{var h;const f=d.target.files;if(f)if(r==="folder"){const p={name:f[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const m of f)if(m.name!==".DS_Store"){const b=m.webkitRelativePath.split("/");let g=p.children??[];for(let S=1;Sx.name===w);if(!y){if(y={name:w,isFile:S===b.length-1,children:S===b.length-1?void 0:[]},y.isFile){const x=await o(m);x&&(y.file=x)}g.push(y)}y&&!y.isFile&&(g=y.children)}}l(p)}else{const p=[];for(const m of f){const b=await o(m);b&&p.push(b)}p.length&&(await((h=G)==null?void 0:h.batchCreateFlows(p,void 0,n)),a&&a())}};return c.jsxs(c.Fragment,{children:[e?c.jsx(te,{onClick:d=>{d.stopPropagation(),s("file")},icon:c.jsx(At,{size:19}),children:"Import workflows"}):c.jsxs(Me,{closeOnSelect:!0,children:[c.jsx(Fe,{as:ee,leftIcon:c.jsx(At,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),c.jsx(Ve,{children:Ra.map((d,f)=>c.jsx(te,{onClick:()=>{s(d.type)},iconSpacing:2,icon:d.type==="folder"?c.jsx(Cn,{size:18}):c.jsx(xr,{size:18}),children:d.title},f))})]}),c.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:u,onClick:d=>{d.stopPropagation()}})]})}function Ar({folder:n,onclose:e}){const[a,r]=v.useState(n.name),[t,i]=v.useState(""),{onRefreshFilesList:s}=v.useContext(pe),o=u=>{r(u.target.value),t&&i("")},l=async()=>{var f,h;const u=a.trim();if(r(u),u===n.name)return e();await((f=fe)==null?void 0:f.generateUniqueName(u,n.parentFolderID??""))!==u?i("The name is duplicated, please modify it and submit again."):(await((h=fe)==null?void 0:h.update(n.id,{name:u})),s&&s(),e())};return c.jsxs(qe,{isOpen:!0,onClose:e,children:[c.jsx(Xe,{}),c.jsxs(Ze,{children:[c.jsx(Je,{children:"Edit folder name"}),c.jsx(Qe,{}),c.jsx(et,{children:c.jsxs(Na,{isInvalid:!!t,children:[c.jsx($a,{children:"Folder name"}),c.jsx(tt,{value:a,onChange:o,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!t&&a&&l()}}),t&&c.jsx(za,{children:t})]})}),c.jsxs(ma,{children:[c.jsx(ee,{colorScheme:"teal",mr:3,onClick:l,isDisabled:!a||!!t,children:"Save"}),c.jsx(ee,{onClick:e,children:"Cancel"})]})]})]})}function _r({menuPosition:n,isopen:e,folder:a,onClose:r}){const[t,i]=v.useState(!1),{onRefreshFilesList:s}=v.useContext(pe),{showDialog:o}=xt(),l=async h=>{var p;h.stopPropagation(),await((p=fe)==null?void 0:p.create({name:"New Folder",parentFolderID:a.id})),s&&s()},u=async h=>{var p;h.stopPropagation(),await((p=G)==null?void 0:p.createFlow({json:JSON.stringify(Aa),parentFolderID:a.id})),s&&s()},d=async h=>{h.stopPropagation();const p=await _a(a.id);o(`Do you want to delete the ${p} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{f(Ha.DELETE)}}])},f=async h=>{var p;await((p=fe)==null?void 0:p.deleteFolder(a.id,h)),r(),s&&s()};return c.jsxs(c.Fragment,{children:[c.jsx(z,{position:"absolute",top:n.y,left:n.x,children:c.jsx(Me,{isOpen:e,onClose:r,isLazy:!0,lazyBehavior:"keepMounted",children:c.jsxs(Ve,{children:[c.jsx(te,{icon:c.jsx(Ir,{size:19}),onClick:h=>{h.preventDefault(),h.stopPropagation(),i(!0)},children:"Rename"}),c.jsx(te,{icon:c.jsx(Sn,{size:19}),onClick:d,children:"Delete"}),c.jsx(te,{onClick:l,icon:c.jsx(jn,{size:19}),children:"New folder"}),c.jsx(te,{onClick:u,icon:c.jsx(It,{size:19}),children:"New file"}),c.jsx(Vn,{parentFolderID:a.id,onlyImportFile:!0})]})})}),t&&c.jsx(Ar,{folder:a,onclose:()=>i(!1)})]})}const Bt=v.memo(function({folder:e}){const[a,r]=v.useState(!1),[t,i]=v.useState(e.isCollapse??!0),[s,o]=v.useState([]),[l,u]=v.useState({x:0,y:0}),[d,f]=v.useState(!1),{colorMode:h}=yt(),{draggingFile:p,setDraggingFile:m,refreshFolderStamp:b,onRefreshFilesList:g}=v.useContext(pe),S=h==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};v.useEffect(()=>{var x;t||(x=G)==null||x.listFolderContent(e.id,window.localStorage.getItem(dt)).then(j=>{o(j)})},[e.id,b,t]);const w=x=>{x.preventDefault(),u({x:x.clientX,y:x.clientY}),f(!0)},y=async x=>{var j,C;if(x.preventDefault(),x.stopPropagation(),!p)return r(!1);if(xe(p)){if(p.id===e.id)return r(!1);await((j=fe)==null?void 0:j.update(p.id,{parentFolderID:e.id}))}else xe(p)||await((C=G)==null?void 0:C.updateFolder(p.id,{parentFolderID:e.id}));await(g==null?void 0:g()),r(!1)};return v.useEffect(()=>{var x;!!e.isCollapse!==t&&((x=fe)==null||x.update(e.id,{isCollapse:t}))},[t]),v.useEffect(()=>{var M;const x=(M=G)==null?void 0:M.curWorkflow,j=(x==null?void 0:x.parentFolderID)+"/",C=e.id+"/";j.startsWith(C)&&i(!1)},[]),c.jsxs(de,{children:[c.jsxs(K,{w:"100%",as:"button",py:1,onClick:()=>{i(!t)},onContextMenu:w,draggable:"true",onDragOver:x=>{x.preventDefault(),x.stopPropagation(),r(!0)},onDragLeave:x=>{x.preventDefault(),x.stopPropagation(),r(!1)},onDragStart:()=>m==null?void 0:m(e),onDrop:y,_hover:S,style:a||d?S:void 0,className:"droppable",children:[c.jsxs(K,{gap:1,children:[t?c.jsx(sr,{size:20}):c.jsx(Ot,{size:20}),c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:c.jsx("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"})})]}),c.jsx(J,{children:e.name})]}),c.jsx(_r,{isopen:d,menuPosition:l,onClose:()=>f(!1),folder:e}),!t&&c.jsx(de,{ml:4,gap:0,children:c.jsx(ca,{items:s})})]})});function Wt(n,e){var a=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),a.push.apply(a,r)}return a}function k(n){for(var e=1;en.length)&&(e=n.length);for(var a=0,r=new Array(e);a=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(a[r]=n[r])}return a}var Ur=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function Gr(n){var e=n.defaultInputValue,a=e===void 0?"":e,r=n.defaultMenuIsOpen,t=r===void 0?!1:r,i=n.defaultValue,s=i===void 0?null:i,o=n.inputValue,l=n.menuIsOpen,u=n.onChange,d=n.onInputChange,f=n.onMenuClose,h=n.onMenuOpen,p=n.value,m=he(n,Ur),b=v.useState(o!==void 0?o:a),g=ue(b,2),S=g[0],w=g[1],y=v.useState(l!==void 0?l:t),x=ue(y,2),j=x[0],C=x[1],V=v.useState(p!==void 0?p:s),M=ue(V,2),T=M[0],A=M[1],W=v.useCallback(function(R,N){typeof u=="function"&&u(R,N),A(R)},[u]),H=v.useCallback(function(R,N){var $;typeof d=="function"&&($=d(R,N)),w($!==void 0?$:R)},[d]),D=v.useCallback(function(){typeof h=="function"&&h(),C(!0)},[h]),O=v.useCallback(function(){typeof f=="function"&&f(),C(!1)},[f]),L=o!==void 0?o:S,_=l!==void 0?l:j,I=p!==void 0?p:T;return k(k({},m),{},{inputValue:L,menuIsOpen:_,onChange:W,onInputChange:H,onMenuClose:O,onMenuOpen:D,value:I})}function Yr(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ut(n,e){for(var a=0;a"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Zr(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Jr(n,e){if(e&&(hn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zr(n)}function Qr(n){var e=Xr();return function(){var r=Ae(n),t;if(e){var i=Ae(this).constructor;t=Reflect.construct(r,arguments,i)}else t=r.apply(this,arguments);return Jr(this,t)}}function ei(n){if(Array.isArray(n))return ft(n)}function ti(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ni(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fn(n){return ei(n)||ti(n)||En(n)||ni()}function ai(n,e){return e||(e=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(e)}}))}const ri=Math.min,ii=Math.max,_e=Math.round,Te=Math.floor,He=n=>({x:n,y:n});function oi(n){return{...n,top:n.y,left:n.x,right:n.x+n.width,bottom:n.y+n.height}}function Ln(n){return Tn(n)?(n.nodeName||"").toLowerCase():"#document"}function ie(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Rn(n){var e;return(e=(Tn(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Tn(n){return n instanceof Node||n instanceof ie(n).Node}function pt(n){return n instanceof Element||n instanceof ie(n).Element}function Pt(n){return n instanceof HTMLElement||n instanceof ie(n).HTMLElement}function Gt(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof ie(n).ShadowRoot}function Nn(n){const{overflow:e,overflowX:a,overflowY:r,display:t}=jt(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+a)&&!["inline","contents"].includes(t)}function si(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function li(n){return["html","body","#document"].includes(Ln(n))}function jt(n){return ie(n).getComputedStyle(n)}function ci(n){if(Ln(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Gt(n)&&n.host||Rn(n);return Gt(e)?e.host:e}function $n(n){const e=ci(n);return li(e)?n.ownerDocument?n.ownerDocument.body:n.body:Pt(e)&&Nn(e)?e:$n(e)}function Be(n,e,a){var r;e===void 0&&(e=[]),a===void 0&&(a=!0);const t=$n(n),i=t===((r=n.ownerDocument)==null?void 0:r.body),s=ie(t);return i?e.concat(s,s.visualViewport||[],Nn(t)?t:[],s.frameElement&&a?Be(s.frameElement):[]):e.concat(t,Be(t,[],a))}function ui(n){const e=jt(n);let a=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const t=Pt(n),i=t?n.offsetWidth:a,s=t?n.offsetHeight:r,o=_e(a)!==i||_e(r)!==s;return o&&(a=i,r=s),{width:a,height:r,$:o}}function Dt(n){return pt(n)?n:n.contextElement}function it(n){const e=Dt(n);if(!Pt(e))return He(1);const a=e.getBoundingClientRect(),{width:r,height:t,$:i}=ui(e);let s=(i?_e(a.width):a.width)/r,o=(i?_e(a.height):a.height)/t;return(!s||!Number.isFinite(s))&&(s=1),(!o||!Number.isFinite(o))&&(o=1),{x:s,y:o}}const di=He(0);function fi(n){const e=ie(n);return!si()||!e.visualViewport?di:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function pi(n,e,a){return e===void 0&&(e=!1),!a||e&&a!==ie(n)?!1:e}function Yt(n,e,a,r){e===void 0&&(e=!1),a===void 0&&(a=!1);const t=n.getBoundingClientRect(),i=Dt(n);let s=He(1);e&&(r?pt(r)&&(s=it(r)):s=it(n));const o=pi(i,a,r)?fi(i):He(0);let l=(t.left+o.x)/s.x,u=(t.top+o.y)/s.y,d=t.width/s.x,f=t.height/s.y;if(i){const h=ie(i),p=r&&pt(r)?ie(r):r;let m=h.frameElement;for(;m&&r&&p!==h;){const b=it(m),g=m.getBoundingClientRect(),S=jt(m),w=g.left+(m.clientLeft+parseFloat(S.paddingLeft))*b.x,y=g.top+(m.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,u*=b.y,d*=b.x,f*=b.y,l+=w,u+=y,m=ie(m).frameElement}}return oi({width:d,height:f,x:l,y:u})}function hi(n,e){let a=null,r;const t=Rn(n);function i(){clearTimeout(r),a&&a.disconnect(),a=null}function s(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),i();const{left:u,top:d,width:f,height:h}=n.getBoundingClientRect();if(o||e(),!f||!h)return;const p=Te(d),m=Te(t.clientWidth-(u+f)),b=Te(t.clientHeight-(d+h)),g=Te(u),w={rootMargin:-p+"px "+-m+"px "+-b+"px "+-g+"px",threshold:ii(0,ri(1,l))||1};let y=!0;function x(j){const C=j[0].intersectionRatio;if(C!==l){if(!y)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},100)}y=!1}try{a=new IntersectionObserver(x,{...w,root:t.ownerDocument})}catch{a=new IntersectionObserver(x,w)}a.observe(n)}return s(!0),i}function mi(n,e,a,r){r===void 0&&(r={});const{ancestorScroll:t=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Dt(n),d=t||i?[...u?Be(u):[],...Be(e)]:[];d.forEach(S=>{t&&S.addEventListener("scroll",a,{passive:!0}),i&&S.addEventListener("resize",a)});const f=u&&o?hi(u,a):null;let h=-1,p=null;s&&(p=new ResizeObserver(S=>{let[w]=S;w&&w.target===u&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{p&&p.observe(e)})),a()}),u&&!l&&p.observe(u),p.observe(e));let m,b=l?Yt(n):null;l&&g();function g(){const S=Yt(n);b&&(S.x!==b.x||S.y!==b.y||S.width!==b.width||S.height!==b.height)&&a(),b=S,m=requestAnimationFrame(g)}return a(),()=>{d.forEach(S=>{t&&S.removeEventListener("scroll",a),i&&S.removeEventListener("resize",a)}),f&&f(),p&&p.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var ht=v.useLayoutEffect,vi=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],We=function(){};function gi(n,e){return e?e[0]==="-"?n+e:n+"__"+e:n}function bi(n,e){for(var a=arguments.length,r=new Array(a>2?a-2:0),t=2;t-1}function Si(n){return nt(n)?window.innerHeight:n.clientHeight}function An(n){return nt(n)?window.pageYOffset:n.scrollTop}function Ue(n,e){if(nt(n)){window.scrollTo(0,e);return}n.scrollTop=e}function xi(n){var e=getComputedStyle(n),a=e.position==="absolute",r=/(auto|scroll)/;if(e.position==="fixed")return document.documentElement;for(var t=n;t=t.parentElement;)if(e=getComputedStyle(t),!(a&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return t;return document.documentElement}function yi(n,e,a,r){return a*((n=n/r-1)*n*n+1)+e}function Ne(n,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:We,t=An(n),i=e-t,s=10,o=0;function l(){o+=s;var u=yi(o,t,i,a);Ue(n,u),oa.bottom?Ue(n,Math.min(e.offsetTop+e.clientHeight-n.offsetHeight+t,n.scrollHeight)):r.top-t1?a-1:0),t=1;t=m)return{placement:"bottom",maxHeight:e};if(T>=m&&!s)return i&&Ne(l,A,H),{placement:"bottom",maxHeight:e};if(!s&&T>=r||s&&V>=r){i&&Ne(l,A,H);var D=s?V-x:T-x;return{placement:"bottom",maxHeight:D}}if(t==="auto"||s){var O=e,L=s?C:M;return L>=r&&(O=Math.min(L-x-o,e)),{placement:"top",maxHeight:O}}if(t==="bottom")return i&&Ue(l,A),{placement:"bottom",maxHeight:e};break;case"top":if(C>=m)return{placement:"top",maxHeight:e};if(M>=m&&!s)return i&&Ne(l,W,H),{placement:"top",maxHeight:e};if(!s&&M>=r||s&&C>=r){var _=e;return(!s&&M>=r||s&&C>=r)&&(_=s?C-j:M-j),i&&Ne(l,W,H),{placement:"top",maxHeight:_}}return{placement:"bottom",maxHeight:e};default:throw new Error('Invalid placement provided "'.concat(t,'".'))}return u}function Ei(n){var e={bottom:"top",top:"bottom"};return n?e[n]:"bottom"}var Hn=function(e){return e==="auto"?"bottom":e},Fi=function(e,a){var r,t=e.placement,i=e.theme,s=i.borderRadius,o=i.spacing,l=i.colors;return k((r={label:"menu"},je(r,Ei(t),"100%"),je(r,"position","absolute"),je(r,"width","100%"),je(r,"zIndex",1),r),a?{}:{backgroundColor:l.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:o.menuGutter,marginTop:o.menuGutter})},Bn=v.createContext(null),Li=function(e){var a=e.children,r=e.minMenuHeight,t=e.maxMenuHeight,i=e.menuPlacement,s=e.menuPosition,o=e.menuShouldScrollIntoView,l=e.theme,u=v.useContext(Bn)||{},d=u.setPortalPlacement,f=v.useRef(null),h=v.useState(t),p=ue(h,2),m=p[0],b=p[1],g=v.useState(null),S=ue(g,2),w=S[0],y=S[1],x=l.spacing.controlHeight;return ht(function(){var j=f.current;if(j){var C=s==="fixed",V=o&&!C,M=Vi({maxHeight:t,menuEl:j,minHeight:r,placement:i,shouldScroll:V,isFixedPosition:C,controlHeight:x});b(M.maxHeight),y(M.placement),d==null||d(M.placement)}},[t,i,s,o,r,d,x]),a({ref:f,placerProps:k(k({},e),{},{placement:w||Hn(i),maxHeight:m})})},Ri=function(e){var a=e.children,r=e.innerRef,t=e.innerProps;return P("div",E({},B(e,"menu",{menu:!0}),{ref:r},t),a)},Ti=Ri,Ni=function(e,a){var r=e.maxHeight,t=e.theme.spacing.baseUnit;return k({maxHeight:r,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a?{}:{paddingBottom:t,paddingTop:t})},$i=function(e){var a=e.children,r=e.innerProps,t=e.innerRef,i=e.isMulti;return P("div",E({},B(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:t},r),a)},Wn=function(e,a){var r=e.theme,t=r.spacing.baseUnit,i=r.colors;return k({textAlign:"center"},a?{}:{color:i.neutral40,padding:"".concat(t*2,"px ").concat(t*3,"px")})},zi=Wn,Ai=Wn,_i=function(e){var a=e.children,r=a===void 0?"No options":a,t=e.innerProps,i=he(e,ji);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),t),r)},Hi=function(e){var a=e.children,r=a===void 0?"Loading...":a,t=e.innerProps,i=he(e,Di);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),t),r)},Bi=function(e){var a=e.rect,r=e.offset,t=e.position;return{left:a.left,position:t,top:r,width:a.width,zIndex:1}},Wi=function(e){var a=e.appendTo,r=e.children,t=e.controlElement,i=e.innerProps,s=e.menuPlacement,o=e.menuPosition,l=v.useRef(null),u=v.useRef(null),d=v.useState(Hn(s)),f=ue(d,2),h=f[0],p=f[1],m=v.useMemo(function(){return{setPortalPlacement:p}},[]),b=v.useState(null),g=ue(b,2),S=g[0],w=g[1],y=v.useCallback(function(){if(t){var V=Ci(t),M=o==="fixed"?0:window.pageYOffset,T=V[h]+M;(T!==(S==null?void 0:S.offset)||V.left!==(S==null?void 0:S.rect.left)||V.width!==(S==null?void 0:S.rect.width))&&w({offset:T,rect:V})}},[t,o,h,S==null?void 0:S.offset,S==null?void 0:S.rect.left,S==null?void 0:S.rect.width]);ht(function(){y()},[y]);var x=v.useCallback(function(){typeof u.current=="function"&&(u.current(),u.current=null),t&&l.current&&(u.current=mi(t,l.current,y,{elementResize:"ResizeObserver"in window}))},[t,y]);ht(function(){x()},[x]);var j=v.useCallback(function(V){l.current=V,x()},[x]);if(!a&&o!=="fixed"||!S)return null;var C=P("div",E({ref:j},B(k(k({},e),{},{offset:S.offset,position:o,rect:S.rect}),"menuPortal",{"menu-portal":!0}),i),r);return P(Bn.Provider,{value:m},a?xa.createPortal(C,a):C)},Ui=function(e){var a=e.isDisabled,r=e.isRtl;return{label:"container",direction:r?"rtl":void 0,pointerEvents:a?"none":void 0,position:"relative"}},Gi=function(e){var a=e.children,r=e.innerProps,t=e.isDisabled,i=e.isRtl;return P("div",E({},B(e,"container",{"--is-disabled":t,"--is-rtl":i}),r),a)},Yi=function(e,a){var r=e.theme.spacing,t=e.isMulti,i=e.hasValue,s=e.selectProps.controlShouldRenderValue;return k({alignItems:"center",display:t&&i&&s?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},a?{}:{padding:"".concat(r.baseUnit/2,"px ").concat(r.baseUnit*2,"px")})},Ki=function(e){var a=e.children,r=e.innerProps,t=e.isMulti,i=e.hasValue;return P("div",E({},B(e,"valueContainer",{"value-container":!0,"value-container--is-multi":t,"value-container--has-value":i}),r),a)},qi=function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},Xi=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"indicatorsContainer",{indicators:!0}),r),a)},Zt,Zi=["size"],Ji=["innerProps","isRtl","size"],Qi={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},Un=function(e){var a=e.size,r=he(e,Zi);return P("svg",E({height:a,width:a,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:Qi},r))},Vt=function(e){return P(Un,E({size:20},e),P("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},Gn=function(e){return P(Un,E({size:20},e),P("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},Yn=function(e,a){var r=e.isFocused,t=e.theme,i=t.spacing.baseUnit,s=t.colors;return k({label:"indicatorContainer",display:"flex",transition:"color 150ms"},a?{}:{color:r?s.neutral60:s.neutral20,padding:i*2,":hover":{color:r?s.neutral80:s.neutral40}})},eo=Yn,to=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),r),a||P(Gn,null))},no=Yn,ao=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),r),a||P(Vt,null))},ro=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing.baseUnit,s=t.colors;return k({label:"indicatorSeparator",alignSelf:"stretch",width:1},a?{}:{backgroundColor:r?s.neutral10:s.neutral20,marginBottom:i*2,marginTop:i*2})},io=function(e){var a=e.innerProps;return P("span",E({},a,B(e,"indicatorSeparator",{"indicator-separator":!0})))},oo=Sa(Zt||(Zt=ai([` + 0%, 80%, 100% { opacity: 0; } + 40% { opacity: 1; } +`]))),so=function(e,a){var r=e.isFocused,t=e.size,i=e.theme,s=i.colors,o=i.spacing.baseUnit;return k({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:t,lineHeight:1,marginRight:t,textAlign:"center",verticalAlign:"middle"},a?{}:{color:r?s.neutral60:s.neutral20,padding:o*2})},ot=function(e){var a=e.delay,r=e.offset;return P("span",{css:mn({animation:"".concat(oo," 1s ease-in-out ").concat(a,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:r?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},lo=function(e){var a=e.innerProps,r=e.isRtl,t=e.size,i=t===void 0?4:t,s=he(e,Ji);return P("div",E({},B(k(k({},s),{},{innerProps:a,isRtl:r,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),a),P(ot,{delay:0,offset:r}),P(ot,{delay:160,offset:!0}),P(ot,{delay:320,offset:!r}))},co=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.theme,s=i.colors,o=i.borderRadius,l=i.spacing;return k({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:l.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},a?{}:{backgroundColor:r?s.neutral5:s.neutral0,borderColor:r?s.neutral10:t?s.primary:s.neutral20,borderRadius:o,borderStyle:"solid",borderWidth:1,boxShadow:t?"0 0 0 1px ".concat(s.primary):void 0,"&:hover":{borderColor:t?s.primary:s.neutral30}})},uo=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.innerRef,s=e.innerProps,o=e.menuIsOpen;return P("div",E({ref:i},B(e,"control",{control:!0,"control--is-disabled":r,"control--is-focused":t,"control--menu-is-open":o}),s,{"aria-disabled":r||void 0}),a)},fo=uo,po=["data"],ho=function(e,a){var r=e.theme.spacing;return a?{}:{paddingBottom:r.baseUnit*2,paddingTop:r.baseUnit*2}},mo=function(e){var a=e.children,r=e.cx,t=e.getStyles,i=e.getClassNames,s=e.Heading,o=e.headingProps,l=e.innerProps,u=e.label,d=e.theme,f=e.selectProps;return P("div",E({},B(e,"group",{group:!0}),l),P(s,E({},o,{selectProps:f,theme:d,getStyles:t,getClassNames:i,cx:r}),u),P("div",null,a))},vo=function(e,a){var r=e.theme,t=r.colors,i=r.spacing;return k({label:"group",cursor:"default",display:"block"},a?{}:{color:t.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:i.baseUnit*3,paddingRight:i.baseUnit*3,textTransform:"uppercase"})},go=function(e){var a=zn(e);a.data;var r=he(a,po);return P("div",E({},B(e,"groupHeading",{"group-heading":!0}),r))},bo=mo,So=["innerRef","isDisabled","isHidden","inputClassName"],xo=function(e,a){var r=e.isDisabled,t=e.value,i=e.theme,s=i.spacing,o=i.colors;return k(k({visibility:r?"hidden":"visible",transform:t?"translateZ(0)":""},yo),a?{}:{margin:s.baseUnit/2,paddingBottom:s.baseUnit/2,paddingTop:s.baseUnit/2,color:o.neutral80})},Kn={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},yo={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":k({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Kn)},Co=function(e){return k({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Kn)},wo=function(e){var a=e.cx,r=e.value,t=zn(e),i=t.innerRef,s=t.isDisabled,o=t.isHidden,l=t.inputClassName,u=he(t,So);return P("div",E({},B(e,"input",{"input-container":!0}),{"data-value":r||""}),P("input",E({className:a({input:!0},l),ref:i,style:Co(o),disabled:s},u)))},Oo=wo,Io=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,s=r.colors;return k({label:"multiValue",display:"flex",minWidth:0},a?{}:{backgroundColor:s.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Mo=function(e,a){var r=e.theme,t=r.borderRadius,i=r.colors,s=e.cropWithEllipsis;return k({overflow:"hidden",textOverflow:s||s===void 0?"ellipsis":void 0,whiteSpace:"nowrap"},a?{}:{borderRadius:t/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},ko=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,s=r.colors,o=e.isFocused;return k({alignItems:"center",display:"flex"},a?{}:{borderRadius:i/2,backgroundColor:o?s.dangerLight:void 0,paddingLeft:t.baseUnit,paddingRight:t.baseUnit,":hover":{backgroundColor:s.dangerLight,color:s.danger}})},qn=function(e){var a=e.children,r=e.innerProps;return P("div",r,a)},Po=qn,jo=qn;function Do(n){var e=n.children,a=n.innerProps;return P("div",E({role:"button"},a),e||P(Vt,{size:14}))}var Vo=function(e){var a=e.children,r=e.components,t=e.data,i=e.innerProps,s=e.isDisabled,o=e.removeProps,l=e.selectProps,u=r.Container,d=r.Label,f=r.Remove;return P(u,{data:t,innerProps:k(k({},B(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":s})),i),selectProps:l},P(d,{data:t,innerProps:k({},B(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},a),P(f,{data:t,innerProps:k(k({},B(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(a||"option")},o),selectProps:l}))},Eo=Vo,Fo=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.isSelected,s=e.theme,o=s.spacing,l=s.colors;return k({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},a?{}:{backgroundColor:i?l.primary:t?l.primary25:"transparent",color:r?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(o.baseUnit*2,"px ").concat(o.baseUnit*3,"px"),":active":{backgroundColor:r?void 0:i?l.primary:l.primary50}})},Lo=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.isSelected,s=e.innerRef,o=e.innerProps;return P("div",E({},B(e,"option",{option:!0,"option--is-disabled":r,"option--is-focused":t,"option--is-selected":i}),{ref:s,"aria-disabled":r},o),a)},Ro=Lo,To=function(e,a){var r=e.theme,t=r.spacing,i=r.colors;return k({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},a?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},No=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"placeholder",{placeholder:!0}),r),a)},$o=No,zo=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing,s=t.colors;return k({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},a?{}:{color:r?s.neutral40:s.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},Ao=function(e){var a=e.children,r=e.isDisabled,t=e.innerProps;return P("div",E({},B(e,"singleValue",{"single-value":!0,"single-value--is-disabled":r}),t),a)},_o=Ao,Ho={ClearIndicator:ao,Control:fo,DropdownIndicator:to,DownChevron:Gn,CrossIcon:Vt,Group:bo,GroupHeading:go,IndicatorsContainer:Xi,IndicatorSeparator:io,Input:Oo,LoadingIndicator:lo,Menu:Ti,MenuList:$i,MenuPortal:Wi,LoadingMessage:Hi,NoOptionsMessage:_i,MultiValue:Eo,MultiValueContainer:Po,MultiValueLabel:jo,MultiValueRemove:Do,Option:Ro,Placeholder:$o,SelectContainer:Gi,SingleValue:_o,ValueContainer:Ki},Bo=function(e){return k(k({},Ho),e.components)},Jt=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function Wo(n,e){return!!(n===e||Jt(n)&&Jt(e))}function Uo(n,e){if(n.length!==e.length)return!1;for(var a=0;a1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return s?"option ".concat(t," is disabled. Select another option."):"option ".concat(t,", selected.");default:return""}},onFocus:function(e){var a=e.context,r=e.focused,t=e.options,i=e.label,s=i===void 0?"":i,o=e.selectValue,l=e.isDisabled,u=e.isSelected,d=function(m,b){return m&&m.length?"".concat(m.indexOf(b)+1," of ").concat(m.length):""};if(a==="value"&&o)return"value ".concat(s," focused, ").concat(d(o,r),".");if(a==="menu"){var f=l?" disabled":"",h="".concat(u?"selected":"focused").concat(f);return"option ".concat(s," ").concat(h,", ").concat(d(t,r),".")}return""},onFilter:function(e){var a=e.inputValue,r=e.resultsMessage;return"".concat(r).concat(a?" for search term "+a:"",".")}},Xo=function(e){var a=e.ariaSelection,r=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,s=e.isFocused,o=e.selectValue,l=e.selectProps,u=e.id,d=l.ariaLiveMessages,f=l.getOptionLabel,h=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,b=l.isSearchable,g=l.menuIsOpen,S=l.options,w=l.screenReaderStatus,y=l.tabSelectsValue,x=l["aria-label"],j=l["aria-live"],C=v.useMemo(function(){return k(k({},qo),d||{})},[d]),V=v.useMemo(function(){var O="";if(a&&C.onChange){var L=a.option,_=a.options,I=a.removedValue,R=a.removedValues,N=a.value,$=function(ce){return Array.isArray(ce)?null:ce},se=I||L||$(N),Y=se?f(se):"",X=_||R||void 0,me=X?X.map(f):[],ve=k({isDisabled:se&&m(se,o),label:Y,labels:me},a);O=C.onChange(ve)}return O},[a,C,m,o,f]),M=v.useMemo(function(){var O="",L=r||t,_=!!(r&&o&&o.includes(r));if(L&&C.onFocus){var I={focused:L,label:f(L),isDisabled:m(L,o),isSelected:_,options:i,context:L===r?"menu":"value",selectValue:o};O=C.onFocus(I)}return O},[r,t,f,m,C,i,o]),T=v.useMemo(function(){var O="";if(g&&S.length&&C.onFilter){var L=w({count:i.length});O=C.onFilter({inputValue:h,resultsMessage:L})}return O},[i,h,g,C,S,w]),A=v.useMemo(function(){var O="";if(C.guidance){var L=t?"value":g?"menu":"input";O=C.guidance({"aria-label":x,context:L,isDisabled:r&&m(r,o),isMulti:p,isSearchable:b,tabSelectsValue:y})}return O},[x,r,t,p,m,b,g,C,o,y]),W="".concat(M," ").concat(T," ").concat(A),H=P(v.Fragment,null,P("span",{id:"aria-selection"},V),P("span",{id:"aria-context"},W)),D=(a==null?void 0:a.action)==="initial-input-focus";return P(v.Fragment,null,P(Qt,{id:u},D&&H),P(Qt,{"aria-live":j,"aria-atomic":"false","aria-relevant":"additions text"},s&&!D&&H))},Zo=Xo,mt=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],Jo=new RegExp("["+mt.map(function(n){return n.letters}).join("")+"]","g"),Xn={};for(var st=0;st-1}},ns=["innerRef"];function as(n){var e=n.innerRef,a=he(n,ns),r=Pi(a,"onExited","in","enter","exit","appear");return P("input",E({ref:e},r,{css:mn({label:"dummyInput",background:0,border:0,caretColor:"transparent",fontSize:"inherit",gridArea:"1 / 1 / 2 / 3",outline:0,padding:0,width:1,color:"transparent",left:-100,opacity:0,position:"relative",transform:"scale(.01)"},"","")}))}var rs=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function is(n){var e=n.isEnabled,a=n.onBottomArrive,r=n.onBottomLeave,t=n.onTopArrive,i=n.onTopLeave,s=v.useRef(!1),o=v.useRef(!1),l=v.useRef(0),u=v.useRef(null),d=v.useCallback(function(g,S){if(u.current!==null){var w=u.current,y=w.scrollTop,x=w.scrollHeight,j=w.clientHeight,C=u.current,V=S>0,M=x-j-y,T=!1;M>S&&s.current&&(r&&r(g),s.current=!1),V&&o.current&&(i&&i(g),o.current=!1),V&&S>M?(a&&!s.current&&a(g),C.scrollTop=x,T=!0,s.current=!0):!V&&-S>y&&(t&&!o.current&&t(g),C.scrollTop=0,T=!0,o.current=!0),T&&rs(g)}},[a,r,t,i]),f=v.useCallback(function(g){d(g,g.deltaY)},[d]),h=v.useCallback(function(g){l.current=g.changedTouches[0].clientY},[]),p=v.useCallback(function(g){var S=l.current-g.changedTouches[0].clientY;d(g,S)},[d]),m=v.useCallback(function(g){if(g){var S=Ii?{passive:!1}:!1;g.addEventListener("wheel",f,S),g.addEventListener("touchstart",h,S),g.addEventListener("touchmove",p,S)}},[p,h,f]),b=v.useCallback(function(g){g&&(g.removeEventListener("wheel",f,!1),g.removeEventListener("touchstart",h,!1),g.removeEventListener("touchmove",p,!1))},[p,h,f]);return v.useEffect(function(){if(e){var g=u.current;return m(g),function(){b(g)}}},[e,m,b]),function(g){u.current=g}}var tn=["boxSizing","height","overflow","paddingRight","position"],nn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function an(n){n.preventDefault()}function rn(n){n.stopPropagation()}function on(){var n=this.scrollTop,e=this.scrollHeight,a=n+this.offsetHeight;n===0?this.scrollTop=1:a===e&&(this.scrollTop=n-1)}function sn(){return"ontouchstart"in window||navigator.maxTouchPoints}var ln=!!(typeof window<"u"&&window.document&&window.document.createElement),Pe=0,ye={capture:!1,passive:!1};function os(n){var e=n.isEnabled,a=n.accountForScrollbars,r=a===void 0?!0:a,t=v.useRef({}),i=v.useRef(null),s=v.useCallback(function(l){if(ln){var u=document.body,d=u&&u.style;if(r&&tn.forEach(function(m){var b=d&&d[m];t.current[m]=b}),r&&Pe<1){var f=parseInt(t.current.paddingRight,10)||0,h=document.body?document.body.clientWidth:0,p=window.innerWidth-h+f||0;Object.keys(nn).forEach(function(m){var b=nn[m];d&&(d[m]=b)}),d&&(d.paddingRight="".concat(p,"px"))}u&&sn()&&(u.addEventListener("touchmove",an,ye),l&&(l.addEventListener("touchstart",on,ye),l.addEventListener("touchmove",rn,ye))),Pe+=1}},[r]),o=v.useCallback(function(l){if(ln){var u=document.body,d=u&&u.style;Pe=Math.max(Pe-1,0),r&&Pe<1&&tn.forEach(function(f){var h=t.current[f];d&&(d[f]=h)}),u&&sn()&&(u.removeEventListener("touchmove",an,ye),l&&(l.removeEventListener("touchstart",on,ye),l.removeEventListener("touchmove",rn,ye)))}},[r]);return v.useEffect(function(){if(e){var l=i.current;return s(l),function(){o(l)}}},[e,s,o]),function(l){i.current=l}}var ss=function(e){var a=e.target;return a.ownerDocument.activeElement&&a.ownerDocument.activeElement.blur()},ls={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function cs(n){var e=n.children,a=n.lockEnabled,r=n.captureEnabled,t=r===void 0?!0:r,i=n.onBottomArrive,s=n.onBottomLeave,o=n.onTopArrive,l=n.onTopLeave,u=is({isEnabled:t,onBottomArrive:i,onBottomLeave:s,onTopArrive:o,onTopLeave:l}),d=os({isEnabled:a}),f=function(p){u(p),d(p)};return P(v.Fragment,null,a&&P("div",{onClick:ss,css:ls}),e(f))}var us={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},ds=function(e){var a=e.name,r=e.onFocus;return P("input",{required:!0,name:a,tabIndex:-1,"aria-hidden":"true",onFocus:r,css:us,value:"",onChange:function(){}})},fs=ds,ps=function(e){return e.label},hs=function(e){return e.label},ms=function(e){return e.value},vs=function(e){return!!e.isDisabled},gs={clearIndicator:no,container:Ui,control:co,dropdownIndicator:eo,group:ho,groupHeading:vo,indicatorsContainer:qi,indicatorSeparator:ro,input:xo,loadingIndicator:so,loadingMessage:Ai,menu:Fi,menuList:Ni,menuPortal:Bi,multiValue:Io,multiValueLabel:Mo,multiValueRemove:ko,noOptionsMessage:zi,option:Fo,placeholder:To,singleValue:zo,valueContainer:Yi},bs={primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},Ss=4,Jn=4,xs=38,ys=Jn*2,Cs={baseUnit:Jn,controlHeight:xs,menuGutter:ys},ut={borderRadius:Ss,colors:bs,spacing:Cs},ws={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:Xt(),captureMenuScroll:!Xt(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:ts(),formatGroupLabel:ps,getOptionLabel:hs,getOptionValue:ms,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:vs,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!wi(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var a=e.count;return"".concat(a," result").concat(a!==1?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function cn(n,e,a,r){var t=na(n,e,a),i=aa(n,e,a),s=ta(n,e),o=Ge(n,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:s,value:o,index:r}}function Qn(n,e){return n.options.map(function(a,r){if("options"in a){var t=a.options.map(function(s,o){return cn(n,s,e,o)}).filter(function(s){return un(n,s)});return t.length>0?{type:"group",data:a,options:t,index:r}:void 0}var i=cn(n,a,e,r);return un(n,i)?i:void 0}).filter(Mi)}function ea(n){return n.reduce(function(e,a){return a.type==="group"?e.push.apply(e,Fn(a.options.map(function(r){return r.data}))):e.push(a.data),e},[])}function Os(n,e){return ea(Qn(n,e))}function un(n,e){var a=n.inputValue,r=a===void 0?"":a,t=e.data,i=e.isSelected,s=e.label,o=e.value;return(!ia(n)||!i)&&ra(n,{label:s,value:o,data:t},r)}function Is(n,e){var a=n.focusedValue,r=n.selectValue,t=r.indexOf(a);if(t>-1){var i=e.indexOf(a);if(i>-1)return a;if(t-1?a:e[0]}var ta=function(e,a){return e.getOptionLabel(a)},Ge=function(e,a){return e.getOptionValue(a)};function na(n,e,a){return typeof n.isOptionDisabled=="function"?n.isOptionDisabled(e,a):!1}function aa(n,e,a){if(a.indexOf(e)>-1)return!0;if(typeof n.isOptionSelected=="function")return n.isOptionSelected(e,a);var r=Ge(n,e);return a.some(function(t){return Ge(n,t)===r})}function ra(n,e,a){return n.filterOption?n.filterOption(e,a):!0}var ia=function(e){var a=e.hideSelectedOptions,r=e.isMulti;return a===void 0?r:a},ks=1,oa=function(n){qr(a,n);var e=Qr(a);function a(r){var t;if(Yr(this,a),t=e.call(this,r),t.state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(o){t.controlRef=o},t.focusedOptionRef=null,t.getFocusedOptionRef=function(o){t.focusedOptionRef=o},t.menuListRef=null,t.getMenuListRef=function(o){t.menuListRef=o},t.inputRef=null,t.getInputRef=function(o){t.inputRef=o},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(o,l){var u=t.props,d=u.onChange,f=u.name;l.name=f,t.ariaOnChange(o,l),d(o,l)},t.setValue=function(o,l,u){var d=t.props,f=d.closeMenuOnSelect,h=d.isMulti,p=d.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:p}),f&&(t.setState({inputIsHiddenAfterUpdate:!h}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(o,{action:l,option:u})},t.selectOption=function(o){var l=t.props,u=l.blurInputOnSelect,d=l.isMulti,f=l.name,h=t.state.selectValue,p=d&&t.isOptionSelected(o,h),m=t.isOptionDisabled(o,h);if(p){var b=t.getOptionValue(o);t.setValue(h.filter(function(g){return t.getOptionValue(g)!==b}),"deselect-option",o)}else if(!m)d?t.setValue([].concat(Fn(h),[o]),"select-option",o):t.setValue(o,"select-option");else{t.ariaOnChange(o,{action:"select-option",option:o,name:f});return}u&&t.blurInput()},t.removeValue=function(o){var l=t.props.isMulti,u=t.state.selectValue,d=t.getOptionValue(o),f=u.filter(function(p){return t.getOptionValue(p)!==d}),h=ze(l,f,f[0]||null);t.onChange(h,{action:"remove-value",removedValue:o}),t.focusInput()},t.clearValue=function(){var o=t.state.selectValue;t.onChange(ze(t.props.isMulti,[],null),{action:"clear",removedValues:o})},t.popValue=function(){var o=t.props.isMulti,l=t.state.selectValue,u=l[l.length-1],d=l.slice(0,l.length-1),f=ze(o,d,d[0]||null);t.onChange(f,{action:"pop-value",removedValue:u})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var o=arguments.length,l=new Array(o),u=0;uh||f>h}},t.onTouchEnd=function(o){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(o.target)&&t.menuListRef&&!t.menuListRef.contains(o.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(o){t.userIsDragging||t.onControlMouseDown(o)},t.onClearIndicatorTouchEnd=function(o){t.userIsDragging||t.onClearIndicatorMouseDown(o)},t.onDropdownIndicatorTouchEnd=function(o){t.userIsDragging||t.onDropdownIndicatorMouseDown(o)},t.handleInputChange=function(o){var l=t.props.inputValue,u=o.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(u,{action:"input-change",prevInputValue:l}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(o){t.props.onFocus&&t.props.onFocus(o),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(o){var l=t.props.inputValue;if(t.menuListRef&&t.menuListRef.contains(document.activeElement)){t.inputRef.focus();return}t.props.onBlur&&t.props.onBlur(o),t.onInputChange("",{action:"input-blur",prevInputValue:l}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1})},t.onOptionHover=function(o){t.blockOptionHover||t.state.focusedOption===o||t.setState({focusedOption:o})},t.shouldHideSelectedOptions=function(){return ia(t.props)},t.onValueInputFocus=function(o){o.preventDefault(),o.stopPropagation(),t.focus()},t.onKeyDown=function(o){var l=t.props,u=l.isMulti,d=l.backspaceRemovesValue,f=l.escapeClearsValue,h=l.inputValue,p=l.isClearable,m=l.isDisabled,b=l.menuIsOpen,g=l.onKeyDown,S=l.tabSelectsValue,w=l.openMenuOnFocus,y=t.state,x=y.focusedOption,j=y.focusedValue,C=y.selectValue;if(!m&&!(typeof g=="function"&&(g(o),o.defaultPrevented))){switch(t.blockOptionHover=!0,o.key){case"ArrowLeft":if(!u||h)return;t.focusValue("previous");break;case"ArrowRight":if(!u||h)return;t.focusValue("next");break;case"Delete":case"Backspace":if(h)return;if(j)t.removeValue(j);else{if(!d)return;u?t.popValue():p&&t.clearValue()}break;case"Tab":if(t.isComposing||o.shiftKey||!b||!S||!x||w&&t.isOptionSelected(x,C))return;t.selectOption(x);break;case"Enter":if(o.keyCode===229)break;if(b){if(!x||t.isComposing)return;t.selectOption(x);break}return;case"Escape":b?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:h}),t.onMenuClose()):p&&f&&t.clearValue();break;case" ":if(h)return;if(!b){t.openMenu("first");break}if(!x)return;t.selectOption(x);break;case"ArrowUp":b?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":b?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!b)return;t.focusOption("pageup");break;case"PageDown":if(!b)return;t.focusOption("pagedown");break;case"Home":if(!b)return;t.focusOption("first");break;case"End":if(!b)return;t.focusOption("last");break;default:return}o.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++ks),t.state.selectValue=Kt(r.value),r.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),s=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[s]}return t}return Kr(a,[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&qt(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,s=i.isDisabled,o=i.menuIsOpen,l=this.state.isFocused;(l&&!s&&t.isDisabled||l&&o&&!t.menuIsOpen)&&this.focusInput(),l&&s&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!l&&!s&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(qt(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(t,i){this.props.onInputChange(t,i)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(t){var i=this,s=this.state,o=s.selectValue,l=s.isFocused,u=this.buildFocusableOptions(),d=t==="first"?0:u.length-1;if(!this.props.isMulti){var f=u.indexOf(o[0]);f>-1&&(d=f)}this.scrollToFocusedOptionOnUpdate=!(l&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:u[d]},function(){return i.onMenuOpen()})}},{key:"focusValue",value:function(t){var i=this.state,s=i.selectValue,o=i.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var l=s.indexOf(o);o||(l=-1);var u=s.length-1,d=-1;if(s.length){switch(t){case"previous":l===0?d=0:l===-1?d=u:d=l-1;break;case"next":l>-1&&l0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,s=this.state.focusedOption,o=this.getFocusableOptions();if(o.length){var l=0,u=o.indexOf(s);s||(u=-1),t==="up"?l=u>0?u-1:o.length-1:t==="down"?l=(u+1)%o.length:t==="pageup"?(l=u-i,l<0&&(l=0)):t==="pagedown"?(l=u+i,l>o.length-1&&(l=o.length-1)):t==="last"&&(l=o.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:o[l],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme(ut):k(k({},ut),this.props.theme):ut}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,s=this.getStyles,o=this.getClassNames,l=this.getValue,u=this.selectOption,d=this.setValue,f=this.props,h=f.isMulti,p=f.isRtl,m=f.options,b=this.hasValue();return{clearValue:t,cx:i,getStyles:s,getClassNames:o,getValue:l,hasValue:b,isMulti:h,isRtl:p,options:m,selectOption:u,selectProps:f,setValue:d,theme:this.getTheme()}}},{key:"hasValue",value:function(){var t=this.state.selectValue;return t.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var t=this.props,i=t.isClearable,s=t.isMulti;return i===void 0?s:i}},{key:"isOptionDisabled",value:function(t,i){return na(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return aa(this.props,t,i)}},{key:"filterOption",value:function(t,i){return ra(this.props,t,i)}},{key:"formatOptionLabel",value:function(t,i){if(typeof this.props.formatOptionLabel=="function"){var s=this.props.inputValue,o=this.state.selectValue;return this.props.formatOptionLabel(t,{context:i,inputValue:s,selectValue:o})}else return this.getOptionLabel(t)}},{key:"formatGroupLabel",value:function(t){return this.props.formatGroupLabel(t)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var t=this.props,i=t.isDisabled,s=t.isSearchable,o=t.inputId,l=t.inputValue,u=t.tabIndex,d=t.form,f=t.menuIsOpen,h=t.required,p=this.getComponents(),m=p.Input,b=this.state,g=b.inputIsHidden,S=b.ariaSelection,w=this.commonProps,y=o||this.getElementId("input"),x=k(k(k({"aria-autocomplete":"list","aria-expanded":f,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":h,role:"combobox"},f&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!s&&{"aria-readonly":!0}),this.hasValue()?(S==null?void 0:S.action)==="initial-input-focus"&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return s?v.createElement(m,E({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:y,innerRef:this.getInputRef,isDisabled:i,isHidden:g,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:u,form:d,type:"text",value:l},x)):v.createElement(as,E({id:y,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:We,onFocus:this.onInputFocus,disabled:i,tabIndex:u,inputMode:"none",form:d,value:""},x))}},{key:"renderPlaceholderOrValue",value:function(){var t=this,i=this.getComponents(),s=i.MultiValue,o=i.MultiValueContainer,l=i.MultiValueLabel,u=i.MultiValueRemove,d=i.SingleValue,f=i.Placeholder,h=this.commonProps,p=this.props,m=p.controlShouldRenderValue,b=p.isDisabled,g=p.isMulti,S=p.inputValue,w=p.placeholder,y=this.state,x=y.selectValue,j=y.focusedValue,C=y.isFocused;if(!this.hasValue()||!m)return S?null:v.createElement(f,E({},h,{key:"placeholder",isDisabled:b,isFocused:C,innerProps:{id:this.getElementId("placeholder")}}),w);if(g)return x.map(function(M,T){var A=M===j,W="".concat(t.getOptionLabel(M),"-").concat(t.getOptionValue(M));return v.createElement(s,E({},h,{components:{Container:o,Label:l,Remove:u},isFocused:A,isDisabled:b,key:W,index:T,removeProps:{onClick:function(){return t.removeValue(M)},onTouchEnd:function(){return t.removeValue(M)},onMouseDown:function(D){D.preventDefault()}},data:M}),t.formatOptionLabel(M,"value"))});if(S)return null;var V=x[0];return v.createElement(d,E({},h,{data:V,isDisabled:b}),this.formatOptionLabel(V,"value"))}},{key:"renderClearIndicator",value:function(){var t=this.getComponents(),i=t.ClearIndicator,s=this.commonProps,o=this.props,l=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!this.isClearable()||!i||l||!this.hasValue()||u)return null;var f={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:f,isFocused:d}))}},{key:"renderLoadingIndicator",value:function(){var t=this.getComponents(),i=t.LoadingIndicator,s=this.commonProps,o=this.props,l=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!i||!u)return null;var f={"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:f,isDisabled:l,isFocused:d}))}},{key:"renderIndicatorSeparator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator,s=t.IndicatorSeparator;if(!i||!s)return null;var o=this.commonProps,l=this.props.isDisabled,u=this.state.isFocused;return v.createElement(s,E({},o,{isDisabled:l,isFocused:u}))}},{key:"renderDropdownIndicator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator;if(!i)return null;var s=this.commonProps,o=this.props.isDisabled,l=this.state.isFocused,u={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},s,{innerProps:u,isDisabled:o,isFocused:l}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),s=i.Group,o=i.GroupHeading,l=i.Menu,u=i.MenuList,d=i.MenuPortal,f=i.LoadingMessage,h=i.NoOptionsMessage,p=i.Option,m=this.commonProps,b=this.state.focusedOption,g=this.props,S=g.captureMenuScroll,w=g.inputValue,y=g.isLoading,x=g.loadingMessage,j=g.minMenuHeight,C=g.maxMenuHeight,V=g.menuIsOpen,M=g.menuPlacement,T=g.menuPosition,A=g.menuPortalTarget,W=g.menuShouldBlockScroll,H=g.menuShouldScrollIntoView,D=g.noOptionsMessage,O=g.onMenuScrollToTop,L=g.onMenuScrollToBottom;if(!V)return null;var _=function(X,me){var ve=X.type,le=X.data,ce=X.isDisabled,ke=X.isSelected,Le=X.label,ua=X.value,Et=b===le,Ft=ce?void 0:function(){return t.onOptionHover(le)},da=ce?void 0:function(){return t.selectOption(le)},Lt="".concat(t.getElementId("option"),"-").concat(me),fa={id:Lt,onClick:da,onMouseMove:Ft,onMouseOver:Ft,tabIndex:-1};return v.createElement(p,E({},m,{innerProps:fa,data:le,isDisabled:ce,isSelected:ke,key:Lt,label:Le,type:ve,value:ua,isFocused:Et,innerRef:Et?t.getFocusedOptionRef:void 0}),t.formatOptionLabel(X.data,"menu"))},I;if(this.hasOptions())I=this.getCategorizedOptions().map(function(Y){if(Y.type==="group"){var X=Y.data,me=Y.options,ve=Y.index,le="".concat(t.getElementId("group"),"-").concat(ve),ce="".concat(le,"-heading");return v.createElement(s,E({},m,{key:le,data:X,options:me,Heading:o,headingProps:{id:ce,data:Y.data},label:t.formatGroupLabel(Y.data)}),Y.options.map(function(ke){return _(ke,"".concat(ve,"-").concat(ke.index))}))}else if(Y.type==="option")return _(Y,"".concat(Y.index))});else if(y){var R=x({inputValue:w});if(R===null)return null;I=v.createElement(f,m,R)}else{var N=D({inputValue:w});if(N===null)return null;I=v.createElement(h,m,N)}var $={minMenuHeight:j,maxMenuHeight:C,menuPlacement:M,menuPosition:T,menuShouldScrollIntoView:H},se=v.createElement(Li,E({},m,$),function(Y){var X=Y.ref,me=Y.placerProps,ve=me.placement,le=me.maxHeight;return v.createElement(l,E({},m,$,{innerRef:X,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:y,placement:ve}),v.createElement(cs,{captureEnabled:S,onTopArrive:O,onBottomArrive:L,lockEnabled:W},function(ce){return v.createElement(u,E({},m,{innerRef:function(Le){t.getMenuListRef(Le),ce(Le)},isLoading:y,maxHeight:le,focusedOption:b}),I)}))});return A||T==="fixed"?v.createElement(d,E({},m,{appendTo:A,controlElement:this.controlRef,menuPlacement:M,menuPosition:T}),se):se}},{key:"renderFormField",value:function(){var t=this,i=this.props,s=i.delimiter,o=i.isDisabled,l=i.isMulti,u=i.name,d=i.required,f=this.state.selectValue;if(d&&!this.hasValue()&&!o)return v.createElement(fs,{name:u,onFocus:this.onValueInputFocus});if(!(!u||o))if(l)if(s){var h=f.map(function(b){return t.getOptionValue(b)}).join(s);return v.createElement("input",{name:u,type:"hidden",value:h})}else{var p=f.length>0?f.map(function(b,g){return v.createElement("input",{key:"i-".concat(g),name:u,type:"hidden",value:t.getOptionValue(b)})}):v.createElement("input",{name:u,type:"hidden",value:""});return v.createElement("div",null,p)}else{var m=f[0]?this.getOptionValue(f[0]):"";return v.createElement("input",{name:u,type:"hidden",value:m})}}},{key:"renderLiveRegion",value:function(){var t=this.commonProps,i=this.state,s=i.ariaSelection,o=i.focusedOption,l=i.focusedValue,u=i.isFocused,d=i.selectValue,f=this.getFocusableOptions();return v.createElement(Zo,E({},t,{id:this.getElementId("live-region"),ariaSelection:s,focusedOption:o,focusedValue:l,isFocused:u,selectValue:d,focusableOptions:f}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,s=t.IndicatorsContainer,o=t.SelectContainer,l=t.ValueContainer,u=this.props,d=u.className,f=u.id,h=u.isDisabled,p=u.menuIsOpen,m=this.state.isFocused,b=this.commonProps=this.getCommonProps();return v.createElement(o,E({},b,{className:d,innerProps:{id:f,onKeyDown:this.onKeyDown},isDisabled:h,isFocused:m}),this.renderLiveRegion(),v.createElement(i,E({},b,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:h,isFocused:m,menuIsOpen:p}),v.createElement(l,E({},b,{isDisabled:h}),this.renderPlaceholderOrValue(),this.renderInput()),v.createElement(s,E({},b,{isDisabled:h}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}],[{key:"getDerivedStateFromProps",value:function(t,i){var s=i.prevProps,o=i.clearFocusValueOnUpdate,l=i.inputIsHiddenAfterUpdate,u=i.ariaSelection,d=i.isFocused,f=i.prevWasFocused,h=t.options,p=t.value,m=t.menuIsOpen,b=t.inputValue,g=t.isMulti,S=Kt(p),w={};if(s&&(p!==s.value||h!==s.options||m!==s.menuIsOpen||b!==s.inputValue)){var y=m?Os(t,S):[],x=o?Is(i,S):null,j=Ms(i,y);w={selectValue:S,focusedOption:j,focusedValue:x,clearFocusValueOnUpdate:!1}}var C=l!=null&&t!==s?{inputIsHidden:l,inputIsHiddenAfterUpdate:void 0}:{},V=u,M=d&&f;return d&&!M&&(V={value:ze(g,S,S[0]||null),options:S,action:"initial-input-focus"},M=!f),(u==null?void 0:u.action)==="initial-input-focus"&&(V=null),k(k(k({},w),C),{},{prevProps:t,ariaSelection:V,prevWasFocused:M})}}]),a}(v.Component);oa.defaultProps=ws;var Ps=v.forwardRef(function(n,e){var a=Gr(n);return v.createElement(oa,E({ref:e},a))}),js=Ps,Ds=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function vt(){return vt=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var sa=function(e){e.className,e.clearValue,e.cx,e.getStyles,e.getClassNames,e.getValue,e.hasValue,e.isMulti,e.isRtl,e.options,e.selectOption,e.selectProps,e.setValue,e.theme;var a=Vs(e,Ds);return vt({},a)},Es=function(e){var a=typeof e=="string";return a&&["sm","md","lg"].includes(e)},Fs=function(e){return Es(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},oe=function(e){var a=Ke(),r=Fs(a.components.Input.defaultProps.size),t=e??r,i=hr(typeof t=="string"?[t]:t,{fallback:"md"})||r;return i};function we(){return we=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var zs=function(e){var a=e.className,r=e.cx,t=e.children,i=e.innerRef,s=e.innerProps,o=e.isDisabled,l=e.isFocused,u=e.menuIsOpen,d=e.selectProps,f=d.chakraStyles,h=d.size,p=d.variant,m=d.focusBorderColor,b=d.errorBorderColor,g=d.isInvalid,S=d.isReadOnly,w=oe(h),y=ge("Input",{size:w,variant:p,focusBorderColor:m,errorBorderColor:b}),x=y.field,j=x.height,C=x.h,V=$s(x,Ns),M=j||C,T=ae({},V,{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",padding:0,overflow:"hidden",height:"auto",minH:M},o?{pointerEvents:"none"}:{}),A=f!=null&&f.control?f.control(T,e):T;return F.createElement(z,ae({ref:i,className:r({control:!0,"control--is-disabled":o,"control--is-focused":l,"control--menu-is-open":u},a),sx:A},s,{"data-focus":l?!0:void 0,"data-focus-visible":l?!0:void 0,"data-invalid":g?!0:void 0,"data-disabled":o?!0:void 0,"data-readonly":S?!0:void 0}),t)},As=function(e){var a=e.className,r=e.cx,t=e.selectProps,i=t.chakraStyles,s=t.useBasicStyles,o=t.variant,l=ae({opacity:1},s||o!=="outline"?{display:"none"}:{}),u=i!=null&&i.indicatorSeparator?i.indicatorSeparator(l,e):l;return F.createElement(In,{className:r({"indicator-separator":!0},a),sx:u,orientation:"vertical"})},_s=function(e){return F.createElement(Ct,ae({role:"presentation",focusable:"false","aria-hidden":"true"},e),F.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},Hs=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,s=e.selectProps,o=s.chakraStyles,l=s.useBasicStyles,u=s.size,d=s.focusBorderColor,f=s.errorBorderColor,h=s.variant,p=oe(u),m=ge("Input",{size:p,variant:h,focusBorderColor:d,errorBorderColor:f}),b={sm:"16px",md:"20px",lg:"24px"},g=b[p],S=ae({},m.addon,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",borderRadius:0,borderWidth:0,fontSize:g},l&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=o!=null&&o.dropdownIndicator?o.dropdownIndicator(S,e):S,y={height:"1em",width:"1em"},x=o!=null&&o.downChevron?o.downChevron(y,e):y;return F.createElement(z,ae({},i,{className:t({indicator:!0,"dropdown-indicator":!0},r),sx:w}),a||F.createElement(_s,{sx:x}))},Bs=function(e){return F.createElement(Ct,ae({focusable:"false","aria-hidden":!0},e),F.createElement("path",{fill:"currentColor",d:"M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z"}))},Ws=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,s=e.selectProps,o=s.chakraStyles,l=s.size,u=oe(l),d=fn("CloseButton",{size:u}),f=ae({},d,{marginX:1,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer"}),h=o!=null&&o.clearIndicator?o.clearIndicator(f,e):f,p={width:"1em",height:"1em"},m=o!=null&&o.crossIcon?o.crossIcon(p,e):p;return F.createElement(z,ae({role:"button",className:t({indicator:!0,"clear-indicator":!0},r),sx:h,"aria-label":"Clear selected options"},i),a||F.createElement(Bs,{sx:m}))},Us=function(e){var a=e.className,r=e.cx,t=e.innerProps,i=e.selectProps,s=i.chakraStyles,o=i.size,l=e.color,u=e.emptyColor,d=e.speed,f=e.thickness,h=e.spinnerSize,p=oe(o),m={sm:"xs",md:"sm",lg:"md"},b=m[p],g={marginRight:3},S=s!=null&&s.loadingIndicator?s.loadingIndicator(g,e):g;return F.createElement(ya,ae({className:r({indicator:!0,"loading-indicator":!0},a),sx:S},t,{size:h||b,color:l,emptyColor:u,speed:d,thickness:f}))};const Gs=zs;var Ys=["innerRef","isDisabled","isHidden","inputClassName"];function De(){return De=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var qs=function(e){var a=e.className,r=e.cx,t=e.value,i=e.selectProps,s=i.chakraStyles,o=i.isReadOnly,l=sa(e),u=l.innerRef,d=l.isDisabled,f=l.isHidden,h=l.inputClassName,p=Ks(l,Ys),m={gridArea:"1 / 2",minW:"2px",border:0,margin:0,outline:0,padding:0},b={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content",color:"inherit",marginX:"0.125rem",paddingY:"0.125rem",visibility:d?"hidden":"visible",transform:t?"translateZ(0)":"",_after:De({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre",padding:0},m)},g=s!=null&&s.inputContainer?s.inputContainer(b,e):b,S=De({background:0,opacity:f?0:1,width:"100%"},m),w=s!=null&&s.input?s.input(S,e):S;return F.createElement(z,{className:r({"input-container":!0},a),"data-value":t||"",sx:g},F.createElement(be.input,De({className:r({input:!0},h),ref:u,sx:w,disabled:d,readOnly:o?!0:void 0},p)))};const Xs=qs;var Zs=["data"];function Js(n,e){if(n==null)return{};var a={},r=Object.keys(n),t,i;for(i=0;i=0)&&(a[t]=n[t]);return a}function Q(){return Q=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var Il=function(e){var a,r=e.components,t=r===void 0?{}:r;e.theme;var i=e.size,s=e.colorScheme,o=s===void 0?"gray":s,l=e.isDisabled,u=e.isInvalid,d=e.isReadOnly,f=e.required,h=e.isRequired,p=e.inputId,m=e.tagVariant,b=e.selectedOptionStyle,g=b===void 0?"color":b,S=e.selectedOptionColorScheme,w=e.selectedOptionColor,y=e.variant,x=e.focusBorderColor,j=e.errorBorderColor,C=e.chakraStyles,V=C===void 0?{}:C,M=e.onFocus,T=e.onBlur,A=e.menuIsOpen,W=Ol(e,wl),H=Ke(),D=H.components.Input.defaultProps.variant,O=Ba({id:p,isDisabled:l,isInvalid:u,isRequired:h,isReadOnly:d,onFocus:M,onBlur:T}),L=A??(O.readOnly?!1:void 0),_=g,I=["color","check"];I.includes(g)||(_="color");var R=S||w||"blue";typeof R!="string"&&(R="blue");var N=Ye({components:Ye({},Cl,t),colorScheme:o,size:i,tagVariant:m,selectedOptionStyle:_,selectedOptionColorScheme:R,variant:y??D,chakraStyles:V,focusBorderColor:x,errorBorderColor:j,onFocus:O.onFocus,onBlur:O.onBlur,isDisabled:O.disabled,isInvalid:!!O["aria-invalid"],inputId:O.id,isReadOnly:O.readOnly,required:f??O.required,menuIsOpen:L},W,{"aria-invalid":(a=W["aria-invalid"])!=null?a:O["aria-invalid"]});return N};const Ml=Il;function St(){return St=Object.assign?Object.assign.bind():function(n){for(var e=1;e({value:m,label:m})))??[],[o,l]=v.useState(s),u=async()=>{var m,b;await((m=Se)==null?void 0:m.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((b=Se)==null?void 0:b.listAll().then(g=>r(g??[]))),i("")},d=async()=>{var b;const m=await((b=Se)==null?void 0:b.listAll());r(m??[])};if(Se==null)return alert("Error: TagsTable is not loaded"),null;const f=a.map(m=>({value:m.name,label:m.name})),h=37*5;return c.jsxs(Wa,{isLazy:!0,onOpen:d,closeOnBlur:!1,placement:"auto",children:[c.jsx(Ua,{children:c.jsx(te,{icon:c.jsx(Dn,{}),children:"Add Tag"})}),c.jsxs(Ga,{children:[c.jsx(Ya,{}),c.jsx(Ka,{}),c.jsx(Pn,{children:c.jsx("b",{children:n.name})}),c.jsxs(qa,{children:[c.jsx(Pl,{isMulti:!0,name:"tags",options:f,menuIsOpen:!0,value:o,onChange:async m=>{var b;l(m),await((b=G)==null?void 0:b.updateMetaInfo(n.id,{tags:m.map(g=>g.value)})),await(e==null?void 0:e())},chakraStyles:{dropdownIndicator:m=>({...m,p:0,w:"30px"}),menuList:m=>({...m,shadow:"none",pt:0})},placeholder:"Select tags",closeMenuOnSelect:!1,maxMenuHeight:h}),c.jsxs(K,{gap:4,mt:Math.min(h,Math.max(a.length,3)*37),children:[c.jsx(tt,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:m=>{i(m.target.value.trim())}}),c.jsx(ee,{iconSpacing:1,leftIcon:c.jsx(It,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:u,children:"New Tag"})]})]})]})]})}function Dl({workflow:n}){const e=v.useRef(null),a=wt(),{onDuplicateWorkflow:r}=v.useContext(Mt),[t,i]=v.useState(n.saveLock??!1),s=async()=>{var u;const l=!t;i(l),await((u=G)==null?void 0:u.updateMetaInfo(n.id,{saveLock:l})),a({title:`${l?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},o=async l=>{const u=l.target.files;if(!u)return;const d=new FormData;Array.from(u).forEach((f,h)=>{d.append(`images[${h}]`,f,f.name)}),d.append("subfolder","workspace_manager"),await fetch("/workspace/images/save",{method:"POST",body:d}),Array.from(u).forEach(f=>{var h;(h=Xa)==null||h.create({workflowID:n.id,localPath:`workspace_manager/${f.name}`})})};return c.jsxs(c.Fragment,{children:[c.jsxs(Me,{isLazy:!0,closeOnSelect:!1,children:[c.jsx(Fe,{border:0,as:Z,"aria-label":"Options",icon:c.jsx(br,{size:20}),size:"sm",variant:"outline"}),c.jsxs(Ve,{zIndex:101,children:[c.jsx(te,{icon:c.jsx(ur,{}),onClick:()=>r&&r(n.id),children:"Duplicate"}),c.jsx(jl,{workflow:n}),c.jsx(ne,{hasArrow:!0,label:t?"Unlock workflow, allow modifying":"Lock workflow, prevent modifying",placement:"bottom",children:c.jsx(te,{icon:t?c.jsx(wn,{}):c.jsx(Cr,{}),onClick:s,children:t?"Unlock":"Lock"})}),c.jsx(te,{icon:c.jsx(Pr,{}),onClick:()=>{var l;(l=e.current)==null||l.click()},children:"Upload Thumbnail Image"})]})]}),c.jsx("input",{style:{display:"none"},ref:e,type:"file",accept:".json,image/png",multiple:!0,onChange:o,onClick:l=>{l.stopPropagation()}})]})}const dn=v.memo(function({workflow:e}){var m,b;const{colorMode:a}=yt(),{setDraggingFile:r,isMultiSelecting:t,onMultiSelectFlow:i,onDeleteFlow:s,multiSelectedFlowsID:o}=v.useContext(pe),l=o&&o.length>0&&o.includes(e.id),{curFlowID:u,loadWorkflowID:d}=v.useContext(Mt),f=u===e.id,h=a==="light"?"gray.200":"#4A5568",p=c.jsx(z,{flexShrink:1,flexGrow:1,backgroundColor:f?"teal.200":void 0,color:f&&!t?"#333":void 0,draggable:!t,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:"3px",onClick:()=>{!t&&d(e.id)},_hover:{bg:h},children:c.jsxs(K,{children:[(((m=e.coverMediaPath)==null?void 0:m.length)||((b=e.latestImage)==null?void 0:b.length))&&c.jsx(lr,{mediaLocalPath:e.coverMediaPath??e.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),c.jsxs(de,{textAlign:"left",gap:0,children:[c.jsxs(Ce,{alignItems:"center",children:[c.jsx(J,{fontWeight:"500",noOfLines:2,style:{display:"inline-block"},children:e.name??"untitled"}),e.saveLock&&c.jsx(wn,{size:18,style:{display:"inline-block"}})]}),c.jsxs(J,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Za(e.updateTime)]})]})]})});return c.jsx(K,{w:"100%",mb:1,justify:"space-between",children:t?c.jsx(Ee,{isChecked:l,spacing:4,onChange:g=>{i&&i(e.id,g.target.checked)},children:p}):c.jsxs(c.Fragment,{children:[p,c.jsxs(Ce,{width:"90px",justifyContent:"flex-end",children:[c.jsx(ne,{label:"Open in new tab",children:c.jsx(Z,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>Ja(e.id),icon:c.jsx(Qa,{color:"#718096",size:23})})}),c.jsx(xn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{s&&s(e.id)}}),c.jsx(Dl,{workflow:e})]})]})})});function ca({items:n}){var h;const[e,a]=v.useState(!1),r=n.filter(xe),t=n.filter(p=>!xe(p)),i=(h=t[0])==null?void 0:h.parentFolderID,[s,o]=v.useState(!1),{onRefreshFilesList:l,draggingFile:u,refreshFolderStamp:d}=v.useContext(pe),f=async p=>{var m,b;if(p.preventDefault(),p.stopPropagation(),!u)return o(!1);if(xe(u)){if(u.id===i)return o(!1);await((m=fe)==null?void 0:m.update(u.id,{parentFolderID:i}))}else await((b=G)==null?void 0:b.updateFolder(u.id,{parentFolderID:i}));await(l==null?void 0:l()),o(!1)};return v.useEffect(()=>{var p;(p=U)==null||p.getSetting("foldersOnTop").then(m=>{a(m??!1)})},[d]),c.jsxs(c.Fragment,{children:[e&&r.map(p=>c.jsx(Bt,{folder:p},p.id)),c.jsx(z,{border:s?"2px dashed #718096":"2px dashed transparent",onDragOver:p=>{p.preventDefault(),p.stopPropagation(),o(!0)},onDragLeave:p=>{p.preventDefault(),p.stopPropagation(),o(!1)},onDrop:f,className:"droppable",children:e?t.map(p=>c.jsx(dn,{workflow:p},p.id)):n.map(p=>xe(p)?c.jsx(Bt,{folder:p},p.id):c.jsx(dn,{workflow:p},p.id))})]})}function Al({onClose:n,onClickNewFlow:e}){const[a,r]=v.useState([]),t=v.useRef([]),i=v.useRef([]),{loadWorkflowID:s,curFlowID:o}=v.useContext(Mt),[l,u]=v.useState(),[d,f]=v.useState(!1),[h,p]=v.useState([]),[m,b]=v.useState(0),[g,S]=v.useState(""),w=$r(g,400),y=v.useRef(null),[x,j]=v.useState(null),C=v.useRef(window.localStorage.getItem(dt)??zt.RECENTLY_MODIFIED),V=async()=>{var I,R;t.current=await((I=G)==null?void 0:I.listFolderContent())??[],i.current=await((R=G)==null?void 0:R.listAll())??[],T(),b(Date.now())},M=!!l||!!w,T=()=>{if(M){const I=i.current.filter(R=>{var se;let N=!0,$=!0;return l&&(N=!!((se=R.tags)!=null&&se.includes(l))),w&&($=!!R.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),N&&$});r(at(I,C.current))}else r(at(t.current,C.current))},A=I=>{r(at(a,I)),C.current=I,window.localStorage.setItem(dt,I),!M&&b(Date.now())};v.useEffect(()=>{T()},[w,l]);const W=v.useCallback(async I=>{var R,N,$;await((R=G)==null?void 0:R.deleteFlow(I)),(($=(N=G)==null?void 0:N.curWorkflow)==null?void 0:$.id)===I&&await(s==null?void 0:s(null)),await V()},[l,w]);v.useEffect(()=>{V();const I=async R=>{var N;if(y.current){const $=await((N=G)==null?void 0:N.get(y.current));$&&$.json&&ar($.json,[R.canvasX,R.canvasY])}};return Re.canvasEl.addEventListener("drop",I),Re.canvasEl.addEventListener("click",n),()=>{Re.canvasEl.removeEventListener("drop",I),Re.canvasEl.removeEventListener("click",n)}},[]);const H=v.useCallback((I,R)=>{p(N=>{const $=[...N];return R?$.push(I):$.splice($.indexOf(I),1),$})},[]),D=(I,R)=>{var N;switch(I){case"batchDelete":o&&((N=G)==null||N.get(o).then($=>{$||s==null||s(null)})),V(),f(!1),p([]);return;case"selectAll":p(R?i.current.map($=>$.id):[]);return}},O=I=>{j(I),xe(I)||(y.current=I.id)},L=I=>{S(I)},_=450;return c.jsx(pe.Provider,{value:{onRefreshFilesList:V,draggingFile:x??void 0,setDraggingFile:O,isMultiSelecting:d,onMultiSelectFlow:H,multiSelectedFlowsID:h,onDeleteFlow:W,refreshFolderStamp:m,setRefreshFolderStamp:b},children:c.jsx(z,{style:{width:_},children:c.jsxs(er,{width:_,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:tr,children:[c.jsxs(Ce,{alignItems:"center",justifyContent:"space-between",children:[c.jsxs(K,{gap:4,children:[c.jsx(K,{gap:2,children:c.jsx(J,{fontSize:19,fontWeight:600,children:"🦄Workspace"})}),c.jsx(Vn,{}),c.jsx(ne,{label:"Open workspace save directory",children:c.jsx(Z,{"aria-label":"Open workspace save directory",size:"sm",icon:c.jsx(Cn,{}),variant:"outline",colorScheme:"teal",onClick:()=>nr()})}),c.jsx(ne,{label:"New workflow",children:c.jsx(Z,{"aria-label":"New workflow",size:"sm",icon:c.jsx(It,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),c.jsx(K,{alignItems:"center",children:c.jsx(Tr,{})})]}),c.jsxs(Ce,{direction:"column",h:"calc(100% - 64px)",children:[c.jsx(zr,{selectedTag:l,setSelectedTag:u}),c.jsxs(K,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[c.jsxs(K,{children:[i.current.length>0?c.jsx(Nr,{multipleState:d,changeMultipleState:I=>{f(I),!I&&p([])},selectedKeys:h,isSelectedAll:h.length===i.current.length,batchOperationCallback:D}):c.jsx(z,{}),!d&&c.jsx(ne,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:c.jsx(Z,{size:"sm",variant:"outline",icon:c.jsx(jn,{size:21}),onClick:async()=>{var I;await((I=fe)==null?void 0:I.create({name:"New Folder"})),V()},"aria-label":"new folder button"})})]}),c.jsxs(Me,{closeOnSelect:!0,children:[c.jsx(Fe,{as:ee,variant:"ghost",size:"xs",pr:0,rightIcon:c.jsx(Ot,{size:"16"}),children:c.jsxs(K,{children:[c.jsx(J,{children:"Sort by:"}),c.jsx(J,{display:"inline-block",children:C.current})]})}),c.jsx(Ve,{children:c.jsx(kn,{value:C.current,type:"radio",onChange:I=>A(I),children:Object.values(zt).map((I,R)=>c.jsx(kt,{value:I,children:I},R))})})]})]}),c.jsx(cr,{searchValue:g,onUpdateSearchValue:L}),c.jsx(Ce,{overflowY:"auto",overflowX:"hidden",direction:"column",children:c.jsx(ca,{items:a})})]})]})})})}export{Al as default}; diff --git a/dist/workspace_web/ShareDialog-MoNpT1nG.js b/dist/workspace_web/ShareDialog-MoNpT1nG.js new file mode 100644 index 0000000..a9bf05c --- /dev/null +++ b/dist/workspace_web/ShareDialog-MoNpT1nG.js @@ -0,0 +1 @@ +import{f as Z,n as ge,o as ie,j as e,g as q,e as ce,r as a,m as me,w as ne,b as ve,l as y,q as M,p as Y,k as we,H as ke,ah as be,h as G,M as xe,N as ye,O as Ce,Q as Se,S as je}from"./input.js";import{aF as Ie,h as De,B as Pe,J as Re,ad as _e,H as Q,l as X,a9 as Fe,ab as de,j as Me,o as le,k as re,aG as Ne,n as Ee,F as Le,A as K,aH as J,aI as We,aJ as Te,aK as He,T as Ve,aL as Be}from"./App-sgH6j00M.js";import{app as Oe}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import{L as Ke}from"./chunk-K7XRJ7NL-DRLDc1uk.js";import{I as qe}from"./IconCopy-Hs60LgD8.js";import"/scripts/api.js";var ue=Z(function(c,r){const o=ge("Badge",c),{className:d,...h}=ie(c);return e.jsx(q.span,{ref:r,className:ce("chakra-badge",c.className),...h,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...o}})});ue.displayName="Badge";function Ge(t){return t&&ne(t)&&ne(t.target)}function $e(t={}){const{onChange:c,value:r,defaultValue:o,name:d,isDisabled:h,isFocusable:f,isNative:g,...p}=t,[w,C]=a.useState(o||""),k=typeof r<"u",S=k?r:w,b=a.useRef(null),j=a.useCallback(()=>{const n=b.current;if(!n)return;let u="input:not(:disabled):checked";const I=n.querySelector(u);if(I){I.focus();return}u="input:not(:disabled)";const s=n.querySelector(u);s==null||s.focus()},[]),m=`radio-${a.useId()}`,E=d||m,R=a.useCallback(n=>{const u=Ge(n)?n.target.value:n;k||C(u),c==null||c(String(u))},[c,k]),B=a.useCallback((n={},u=null)=>({...n,ref:me(u,b),role:"radiogroup"}),[]),_=a.useCallback((n={},u=null)=>({...n,ref:u,name:E,[g?"checked":"isChecked"]:S!=null?n.value===S:void 0,onChange(s){R(s)},"data-radiogroup":!0}),[g,E,R,S]);return{getRootProps:B,getRadioProps:_,name:E,ref:b,focus:j,setValue:C,value:S,onChange:R,isDisabled:h,isFocusable:f,htmlProps:p}}var[ze,he]=ve({name:"RadioGroupContext",strict:!1}),fe=Z((t,c)=>{const{colorScheme:r,size:o,variant:d,children:h,className:f,isDisabled:g,isFocusable:p,...w}=t,{value:C,onChange:k,getRootProps:S,name:b,htmlProps:j}=$e(w),N=a.useMemo(()=>({name:b,size:o,onChange:k,colorScheme:r,value:C,variant:d,isDisabled:g,isFocusable:p}),[b,o,k,r,C,d,g,p]);return e.jsx(ze,{value:N,children:e.jsx(q.div,{...S(j,c),className:ce("chakra-radio-group",f),children:h})})});fe.displayName="RadioGroup";var Ue={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Je(t={}){const{defaultChecked:c,isChecked:r,isFocusable:o,isDisabled:d,isReadOnly:h,isRequired:f,onChange:g,isInvalid:p,name:w,value:C,id:k,"data-radiogroup":S,"aria-describedby":b,...j}=t,N=`radio-${a.useId()}`,m=Ie(),R=!!he()||!!S;let _=!!m&&!R?m.id:N;_=k??_;const n=d??(m==null?void 0:m.isDisabled),u=h??(m==null?void 0:m.isReadOnly),I=f??(m==null?void 0:m.isRequired),s=p??(m==null?void 0:m.isInvalid),[l,P]=a.useState(!1),[v,D]=a.useState(!1),[x,L]=a.useState(!1),[W,T]=a.useState(!1),[$,z]=a.useState(!!c),O=typeof r<"u",F=O?r:$;a.useEffect(()=>Ae(P),[]);const H=a.useCallback(i=>{if(u||n){i.preventDefault();return}O||z(i.target.checked),g==null||g(i)},[O,n,u,g]),A=a.useCallback(i=>{i.key===" "&&T(!0)},[T]),U=a.useCallback(i=>{i.key===" "&&T(!1)},[T]),oe=a.useCallback((i={},V=null)=>({...i,ref:V,"data-active":y(W),"data-hover":y(x),"data-disabled":y(n),"data-invalid":y(s),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&l),"data-readonly":y(u),"aria-hidden":!0,onMouseDown:M(i.onMouseDown,()=>T(!0)),onMouseUp:M(i.onMouseUp,()=>T(!1)),onMouseEnter:M(i.onMouseEnter,()=>L(!0)),onMouseLeave:M(i.onMouseLeave,()=>L(!1))}),[W,x,n,s,F,v,u,l]),{onFocus:se,onBlur:te}=m??{},pe=a.useCallback((i={},V=null)=>{const ae=n&&!o;return{...i,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(i.onChange,H),onBlur:M(te,i.onBlur,()=>D(!1)),onFocus:M(se,i.onFocus,()=>D(!0)),onKeyDown:M(i.onKeyDown,A),onKeyUp:M(i.onKeyUp,U),checked:F,disabled:ae,readOnly:u,required:I,"aria-invalid":Y(s),"aria-disabled":Y(ae),"aria-required":Y(I),"data-readonly":y(u),"aria-describedby":b,style:Ue}},[n,o,_,w,C,H,te,se,A,U,F,u,I,s,b]);return{state:{isInvalid:s,isFocused:v,isChecked:F,isActive:W,isHovered:x,isDisabled:n,isReadOnly:u,isRequired:I},getCheckboxProps:oe,getRadioProps:oe,getInputProps:pe,getLabelProps:(i={},V=null)=>({...i,ref:V,onMouseDown:M(i.onMouseDown,Qe),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),getRootProps:(i,V=null)=>({...i,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(s)}),htmlProps:j}}function Qe(t){t.preventDefault(),t.stopPropagation()}function Ye(t,c){const r={},o={};for(const[d,h]of Object.entries(t))c.includes(d)?r[d]=h:o[d]=h;return[r,o]}var ee=Z((t,c)=>{var r;const o=he(),{onChange:d,value:h}=t,f=we("Radio",{...o,...t}),g=ie(t),{spacing:p="0.5rem",children:w,isDisabled:C=o==null?void 0:o.isDisabled,isFocusable:k=o==null?void 0:o.isFocusable,inputProps:S,...b}=g;let j=t.isChecked;(o==null?void 0:o.value)!=null&&h!=null&&(j=o.value===h);let N=d;o!=null&&o.onChange&&h!=null&&(N=ke(o.onChange,d));const m=(r=t==null?void 0:t.name)!=null?r:o==null?void 0:o.name,{getInputProps:E,getCheckboxProps:R,getLabelProps:B,getRootProps:_,htmlProps:n}=Je({...b,isChecked:j,isFocusable:k,isDisabled:C,onChange:N,name:m}),[u,I]=Ye(n,be),s=R(I),l=E(S,c),P=B(),v=Object.assign({},u,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...f.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...f.control},L={userSelect:"none",marginStart:p,...f.label};return e.jsxs(q.label,{className:"chakra-radio",...v,__css:D,children:[e.jsx("input",{className:"chakra-radio__input",...l}),e.jsx(q.span,{className:"chakra-radio__control",...s,__css:x}),w&&e.jsx(q.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});ee.displayName="Radio";var Xe=De("cloud","IconCloud",[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]]);function Ze({options:t,value:c,onChange:r}){const[o,d]=a.useState(!1),h=a.useRef(null),f=t.find(p=>p.value===c);a.useEffect(()=>{const p=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[h]);const g=()=>d(!o);return e.jsxs(Pe,{position:"relative",children:[e.jsx(G,{onClick:g,rightIcon:e.jsx(Re,{}),leftIcon:f==null?void 0:f.icon,children:f==null?void 0:f.label}),o&&e.jsx(_e,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(p=>e.jsx(G,{onClick:()=>{d(!1),r(p.value)},leftIcon:p.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:p.label},p.label))})]})}function eo({version:t,cloudHost:c,cloudWorkflowID:r}){const o=t,d=e.jsxs(Q,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:o.name}),e.jsx(X,{color:"GrayText",children:Fe(o.createTime,!1)}),o.cloudID&&r&&e.jsx("a",{href:c+"/workflow/"+r+"/"+o.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(G,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Xe,{}),rightIcon:e.jsx(de,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(ee,{value:o.id,mb:5,children:d},o.id)}function fo({onClose:t}){var u,I;const[c,r]=a.useState("version "+oo()),[o,d]=a.useState([]),[h,f]=a.useState(!1),[g,p]=a.useState(""),[w,C]=a.useState("PRIVATE"),[k,S]=a.useState("new_version"),b=a.useRef(""),[j,N]=a.useState(),m=Me(),E=async s=>{var L,W;const l=s.data;if(s.origin!==b.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,v=l.localVersionID,D=l.version.id,x=l.version.workflowID;x&&P&&await((L=K)==null?void 0:L.updateMetaInfo(P,{cloudID:x,cloudOrigin:s.origin,privacy:w})),v&&D&&await((W=J)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:s.origin})),R(),window.open(b.current+"/workflow/"+x+"/"+D,"_blank"),f(!1)};a.useEffect(()=>(R(),window.addEventListener("message",E),()=>{window.removeEventListener("message",E)}),[]);const R=async()=>{var P,v,D;const s=await((P=le)==null?void 0:P.getSetting("cloudHost"));s&&(p(s),b.current=s);const l=((v=K)==null?void 0:v.curWorkflow)??void 0;N(l),l!=null&&l.cloudID&&l.cloudOrigin&&He(l).then(x=>{C(x)}),(D=J)==null||D.listByWorkflowID(l.id).then(x=>{d(x)})},B=s=>{navigator.clipboard.writeText(s).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var z,O,F;f(!0);const s=We(32),l=await((z=le)==null?void 0:z.getSetting("cloudHost"));let P,v;try{if(P=Te(),k==="new_version"?v=await((O=J)==null?void 0:O.add({workflowID:j.id,name:c,createTime:Date.now(),json:JSON.stringify(Oe.graph.serialize())})):v=await((F=J)==null?void 0:F.get(k)),!v){alert(`Failed to find version: ${k}, please try again.`),f(!1);return}}catch(H){console.error(H),f(!1),alert("Failed to share workflow, please try again.");return}const D=window.location.protocol,x=window.location.host,L=`${D}//${x}`,W=l+`/share_workflow_confirm/${s}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),$=H=>{var A;if(H.origin===l&&H.data==="child_ready"){const U=(A=K)==null?void 0:A.curWorkflow;T.postMessage({workflow:U,version:v,nodeDefs:P,privacy:w},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},n=(I=(u=K)==null?void 0:u.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(xe,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ye,{}),e.jsxs(Ce,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(Se,{children:['Share "',j==null?void 0:j.name,'"']}),e.jsxs(je,{pb:10,children:[e.jsxs(re,{gap:5,children:[n==null?e.jsx(Ze,{options:Ne,value:w,onChange:s=>{C(s)}}):e.jsx(Ve,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Be,{privacy:w,showEmoji:!0})}),n&&e.jsxs(Q,{spacing:2,color:"teal.400",children:[e.jsxs(Ke,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(de,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(G,{width:"180px",size:"sm",leftIcon:e.jsx(qe,{}),onClick:()=>{var s,l;B(g+"/workflow/"+((l=(s=K)==null?void 0:s.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(fe,{gap:4,onChange:s=>{S(s)},value:k,children:e.jsxs(re,{children:[e.jsxs(Q,{mb:5,alignItems:"center",children:[e.jsx(ee,{value:"new_version"},"new_version"),e.jsx(Ee,{value:c,width:"60%",onFocus:()=>{S("new_version")},onChange:s=>{r(s.target.value)}}),e.jsx(Le,{color:"green",children:e.jsx(ue,{colorScheme:"purple",children:"New version"})})]}),o.slice(0,4).map(s=>e.jsx(eo,{version:s,cloudHost:g,cloudWorkflowID:n??null},s.id))]})})]}),e.jsx(Q,{justifyContent:"flex-end",mt:16,children:e.jsx(G,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function oo(){const t=new Date,c=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${c}-${r}-${o}`}export{fo as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js b/dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js new file mode 100644 index 0000000..6171cfc --- /dev/null +++ b/dist/workspace_web/chunk-3RSXBRAN-hQn4Wngd.js @@ -0,0 +1 @@ +import{f as x,j as l,g as i,e as b,k as C,o as E,l as I,r as f,ah as P}from"./input.js";import{$ as z}from"./App-sgH6j00M.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S}; diff --git a/dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js b/dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js new file mode 100644 index 0000000..b929c5c --- /dev/null +++ b/dist/workspace_web/chunk-JARCRF6W-swAlFRrB.js @@ -0,0 +1 @@ +import{f as $,j as f,r as l,y as U,g as P,b as ue,d as W,x as fe,l as i,q as y,m as oe,a4 as J,k as me,o as he,H as ge,e as be}from"./input.js";import{aq as ke}from"./App-sgH6j00M.js";import{t as ve}from"./index-pz0vT7Or.js";var X=$(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;k();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=b=>{k(),g("loaded"),c==null||c(b)},r.onerror=b=>{k(),g("failed"),s==null||s(b)},u.current=r},[e,d,a,p,c,s,n]),k=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return U(()=>{if(!C)return m==="loading"&&x(),()=>{k()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=$(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:k,...r}=n,b=a!==void 0||c!==void 0,R=m!=null||g||!b,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:k,className:"chakra-image",...j})});xe.displayName="Image";var[Ue,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=ke(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:k,isIndeterminate:r,name:b,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(k),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,q]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,H]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||H(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);U(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&q(!1)},[e,q]),U(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{H(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);U(()=>{if(!I.current)return;I.current.checked!==h&&H(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=K=>{F&&K.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var K;(K=I.current)==null||K.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:b,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>q(!1)),onFocus:y(t.onFocus,B,()=>q(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[b,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=$(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:k,isDisabled:r=a==null?void 0:a.isDisabled,onChange:b,inputProps:R,..._}=d;let A=k;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=b;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,b));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:be("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=$(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:k,...r}=n,b={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:k};return f.jsx(P.div,{ref:e,__css:b,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js b/dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js new file mode 100644 index 0000000..345d1b3 --- /dev/null +++ b/dist/workspace_web/chunk-NTCQBYKE-4zMWD2m4.js @@ -0,0 +1 @@ +import{k as t}from"./App-sgH6j00M.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};