diff --git a/dist/workspace_web/App-olu4rPJF.js b/dist/workspace_web/App-olu4rPJF.js deleted file mode 100644 index 618f3a2..0000000 --- a/dist/workspace_web/App-olu4rPJF.js +++ /dev/null @@ -1,29 +0,0 @@ -var Al=Object.defineProperty;var Nl=(t,e,n)=>e in t?Al(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Oe=(t,e,n)=>(Nl(t,typeof e!="symbol"?e+"":e,n),n);import{u as Fl,a as Rl,r as A,c as Tl,b as nt,m as Be,d as Lt,f as he,j as x,e as Fa,g as de,h as be,B as Bl,i as Te,k as Ml,o as Ze,l as Rt,n as it,I as Hr,p as qn,q as lo,s as Ie,t as Ra,v as zl,w as Ll,x as Wl,y as qr,z as Ul,A as Kl,C as $l,D as Vl,E as vs,F as Ta,G as gs,H as Ba,J as Hl,K as ql,L as Gl,P as Ma,M as Gr,N as ws,O as Jr,Q as bs,R as _s,S as Zr,T as xs,U as Xs,_ as mn,V as za,W as La,X as nr,Y as Wa}from"./input.js";import{app as _e}from"/scripts/app.js";import{api as Qs}from"/scripts/api.js";function Jl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function Ua(t){var e;return Jl(t)&&(e=t.ownerDocument)!=null?e:document}function Zl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Yl=Zl();function Xl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function Ka(t){const{theme:e}=Fl(),n=Rl();return A.useMemo(()=>Tl(e.direction,{...n,...t}),[t,e.direction,n])}var Ql=Object.defineProperty,ec=(t,e,n)=>e in t?Ql(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n)=>(ec(t,typeof e!="symbol"?e+"":e,n),n);function ea(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 tc=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function ta(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function na(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var Oo=typeof window<"u"?A.useLayoutEffect:A.useEffect,Ir=t=>t,nc=class{constructor(){De(this,"descendants",new Map),De(this,"register",t=>{if(t!=null)return tc(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),De(this,"unregister",t=>{this.descendants.delete(t);const e=ea(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=ta(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=ta(r,this.enabledCount(),e);return this.enabledItem(o)}),De(this,"prev",(t,e=!0)=>{const n=na(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=na(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=ea(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 rc(){const t=A.useRef(new nc);return Oo(()=>()=>t.current.destroy()),t.current}var[oc,$a]=nt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function sc(t){const e=$a(),[n,r]=A.useState(-1),o=A.useRef(null);Oo(()=>()=>{o.current&&e.unregister(o.current)},[]),Oo(()=>{if(!o.current)return;const i=Number(o.current.dataset.index);n!=i&&!Number.isNaN(i)&&r(i)});const s=Ir(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Be(s,o)}}function Va(){return[Ir(oc),()=>Ir($a()),()=>rc(),o=>sc(o)]}function Ha(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(p,h)=>p!==h}=t,s=Lt(r),i=Lt(o),[a,l]=A.useState(n),u=e!==void 0,c=u?e:a,d=Lt(p=>{const v=typeof p=="function"?p(c):p;i(c,v)&&(u||l(v),s(v))},[u,s,c,i]);return[c,d]}var Io=he(function(e,n){const{htmlWidth:r,htmlHeight:o,alt:s,...i}=e;return x.jsx("img",{width:r,height:o,ref:n,alt:s,...i})});Io.displayName="NativeImage";function ac(t){const{loading:e,src:n,srcSet:r,onLoad:o,onError:s,crossOrigin:i,sizes:a,ignoreFallback:l}=t,[u,c]=A.useState("pending");A.useEffect(()=>{c(n?"loading":"pending")},[n]);const d=A.useRef(),p=A.useCallback(()=>{if(!n)return;h();const v=new Image;v.src=n,i&&(v.crossOrigin=i),r&&(v.srcset=r),a&&(v.sizes=a),e&&(v.loading=e),v.onload=f=>{h(),c("loaded"),o==null||o(f)},v.onerror=f=>{h(),c("failed"),s==null||s(f)},d.current=v},[n,i,r,a,o,s,e]),h=()=>{d.current&&(d.current.onload=null,d.current.onerror=null,d.current=null)};return Fa(()=>{if(!l)return u==="loading"&&p(),()=>{h()}},[u,p,l]),l?"loaded":u}var ic=(t,e)=>t!=="loaded"&&e==="beforeLoadOrError"||t==="failed"&&e==="onError";function lc(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}var qa=he(function(e,n){const{fallbackSrc:r,fallback:o,src:s,srcSet:i,align:a,fit:l,loading:u,ignoreFallback:c,crossOrigin:d,fallbackStrategy:p="beforeLoadOrError",referrerPolicy:h,...v}=e,f=r!==void 0||o!==void 0,y=u!=null||c||!f,m=ac({...e,crossOrigin:d,ignoreFallback:y}),g=ic(m,p),_={ref:n,objectFit:l,objectPosition:a,...y?v:lc(v,["onError","onLoad"])};return g?o||x.jsx(de.img,{as:Io,className:"chakra-image__placeholder",src:r,..._}):x.jsx(de.img,{as:Io,src:s,srcSet:i,crossOrigin:d,loading:u,referrerPolicy:h,className:"chakra-image",..._})});qa.displayName="Image";function ks(t){return A.Children.toArray(t).filter(e=>A.isValidElement(e))}var cc={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}}},uc={horizontal:t=>({"& > *:not(style) ~ *:not(style)":{marginStart:t}}),vertical:t=>({"& > *:not(style) ~ *:not(style)":{marginTop:t}})},Ga=he(function(e,n){const{size:r,colorScheme:o,variant:s,className:i,spacing:a="0.5rem",isAttached:l,isDisabled:u,orientation:c="horizontal",...d}=e,p=be("chakra-button__group",i),h=A.useMemo(()=>({size:r,colorScheme:o,variant:s,isDisabled:u}),[r,o,s,u]);let v={display:"inline-flex",...l?cc[c]:uc[c](a)};const f=c==="vertical";return x.jsx(Bl,{value:h,children:x.jsx(de.div,{ref:n,role:"group",__css:v,className:p,"data-attached":l?"":void 0,"data-orientation":c,flexDir:f?"column":void 0,...d})})});Ga.displayName="ButtonGroup";var Tn=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 x.jsx(Te,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...i,children:l})});Tn.displayName="IconButton";var[dc,Ja]=Ml("Card"),fc=he(function(e,n){const{className:r,...o}=e,s=Ja();return x.jsx(de.div,{ref:n,className:be("chakra-card__body",r),__css:s.body,...o})}),hc=he(function(e,n){const{className:r,...o}=e,s=Ja();return x.jsx(de.div,{ref:n,className:be("chakra-card__header",r),__css:s.header,...o})}),pc=he(function(e,n){const{className:r,children:o,direction:s="column",justify:i,align:a,...l}=Ze(e),u=Rt("Card",e);return x.jsx(de.div,{ref:n,className:be("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:i,alignItems:a,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:x.jsx(dc,{value:u,children:o})})}),[mc,Za]=nt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[yc,yn]=nt({strict:!1,name:"FormControlContext"});function vc(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...i}=t,a=A.useId(),l=e||`field-${a}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[p,h]=A.useState(!1),[v,f]=A.useState(!1),[y,m]=A.useState(!1),g=A.useCallback((E={},N=null)=>({id:d,...E,ref:Be(N,I=>{I&&f(!0)})}),[d]),_=A.useCallback((E={},N=null)=>({...E,ref:N,"data-focus":it(y),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s),id:E.id!==void 0?E.id:u,htmlFor:E.htmlFor!==void 0?E.htmlFor:l}),[l,o,y,r,s,u]),k=A.useCallback((E={},N=null)=>({id:c,...E,ref:Be(N,I=>{I&&h(!0)}),"aria-live":"polite"}),[c]),C=A.useCallback((E={},N=null)=>({...E,...i,ref:N,role:"group","data-focus":it(y),"data-disabled":it(o),"data-invalid":it(r),"data-readonly":it(s)}),[i,o,y,r,s]),j=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:v,setHasHelpText:f,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:i,getHelpTextProps:g,getErrorMessageProps:k,getRootProps:C,getLabelProps:_,getRequiredIndicatorProps:j}}var Yr=he(function(e,n){const r=Rt("Form",e),o=Ze(e),{getRootProps:s,htmlProps:i,...a}=vc(o),l=be("chakra-form-control",e.className);return x.jsx(yc,{value:a,children:x.jsx(mc,{value:r,children:x.jsx(de.div,{...s({},n),className:l,__css:r.container})})})});Yr.displayName="FormControl";var gc=he(function(e,n){const r=yn(),o=Za(),s=be("chakra-form__helper-text",e.className);return x.jsx(de.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});gc.displayName="FormHelperText";var[wc,bc]=nt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xr=he((t,e)=>{const n=Rt("FormError",t),r=Ze(t),o=yn();return o!=null&&o.isInvalid?x.jsx(wc,{value:n,children:x.jsx(de.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:be("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Xr.displayName="FormErrorMessage";var _c=he((t,e)=>{const n=bc(),r=yn();if(!(r!=null&&r.isInvalid))return null;const o=be("chakra-form__error-icon",t.className);return x.jsx(Hr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:x.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"})})});_c.displayName="FormErrorIcon";var Qr=he(function(e,n){var r;const o=qn("FormLabel",e),s=Ze(e),{className:i,children:a,requiredIndicator:l=x.jsx(Ya,{}),optionalIndicator:u=null,...c}=s,d=yn(),p=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return x.jsxs(de.label,{...p,className:be("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[a,d!=null&&d.isRequired?l:u]})});Qr.displayName="FormLabel";var Ya=he(function(e,n){const r=yn(),o=Za();if(!(r!=null&&r.isRequired))return null;const s=be("chakra-form__required-indicator",e.className);return x.jsx(de.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Ya.displayName="RequiredIndicator";function xc(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=kc(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":lo(n),"aria-required":lo(o),"aria-readonly":lo(r)}}function kc(t){var e,n,r;const o=yn(),{id:s,disabled:i,readOnly:a,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:p,onFocus:h,onBlur:v,...f}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...f,"aria-describedby":y.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=i??p)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=a??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??u)!=null?r:o==null?void 0:o.isRequired,isInvalid:c??(o==null?void 0:o.isInvalid),onFocus:Ie(o==null?void 0:o.onFocus,h),onBlur:Ie(o==null?void 0:o.onBlur,v)}}function on(t,e,n,r){const o=Lt(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 Ec(t){return"current"in t}var Xa=()=>typeof window<"u";function Cc(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Sc=t=>Xa()&&t.test(navigator.vendor),Oc=t=>Xa()&&t.test(Cc()),Ic=()=>Oc(/mac|iphone|ipad|ipod/i),Dc=()=>Ic()&&Sc(/apple/i);function jc(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};on(o,"pointerdown",s=>{if(!Dc()||!r)return;const i=s.target,l=(n??[e]).some(u=>{const c=Ec(u)?u.current:u;return(c==null?void 0:c.contains(i))||c===i});o().activeElement!==i&&l&&(s.preventDefault(),i.focus())})}var Qa={exports:{}},Pc="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Ac=Pc,Nc=Ac;function ei(){}function ti(){}ti.resetWarningCache=ei;var Fc=function(){function t(r,o,s,i,a,l){if(l!==Nc){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:ti,resetWarningCache:ei};return n.PropTypes=n,n};Qa.exports=Fc();var Rc=Qa.exports;const Bt=Ra(Rc);function Tc(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 Bc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function ni(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:zl(t)&&Tc(t)?t:ni(Bc(t))}var Mc=Yl?A.useLayoutEffect:A.useEffect;function Do(t,e=[]){const n=A.useRef(t);return Mc(()=>{n.current=t}),A.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function zc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Do(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{co(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&co(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&co(d,e)&&(i.isPointerDown=!1,o(d))},c=Ua(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function co(t,e){var n;const r=t.target;return r&&!Ua(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Lc(t,e){const n=A.useId();return A.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Wc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Uc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Do(n),i=Do(e),[a,l]=A.useState(t.defaultIsOpen||!1),[u,c]=Wc(r,a),d=Lc(o,"disclosure"),p=A.useCallback(()=>{u||l(!1),i==null||i()},[u,i]),h=A.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),v=A.useCallback(()=>{(c?p:h)()},[c,h,p]);return{isOpen:!!c,onOpen:h,onClose:p,onToggle:v,isControlled:u,getButtonProps:(f={})=>({...f,"aria-expanded":c,"aria-controls":d,onClick:Ll(f.onClick,v)}),getDisclosureProps:(f={})=>({...f,hidden:!c,id:d})}}var vn=he(function(e,n){const{htmlSize:r,...o}=e,s=Rt("Input",o),i=Ze(o),a=xc(i),l=be("chakra-input",e.className);return x.jsx(de.input,{size:r,...a,__css:s.field,ref:n,className:l})});vn.displayName="Input";vn.id="Input";var Kc=Object.freeze(["base","sm","md","lg","xl","2xl"]);function $c(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):Wl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function Yp(t,e=Kc){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var wt=he(function(e,n){const r=qn("Text",e),{className:o,align:s,decoration:i,casing:a,...l}=Ze(e),u=Xl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return x.jsx(de.p,{ref:n,className:be("chakra-text",e.className),...u,...l,__css:r})});wt.displayName="Text";var jo=t=>x.jsx(de.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});jo.displayName="StackDivider";var ri=t=>x.jsx(de.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});ri.displayName="StackItem";function Vc(t){const{spacing:e,direction:n}=t,r={column:{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},"column-reverse":{my:e,mx:0,borderLeftWidth:0,borderBottomWidth:"1px"},row:{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0},"row-reverse":{mx:e,my:0,borderLeftWidth:"1px",borderBottomWidth:0}};return{"&":$c(n,o=>r[o])}}var He=he((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:i="0.5rem",wrap:a,children:l,divider:u,className:c,shouldWrapChildren:d,...p}=t,h=n?"row":r??"column",v=A.useMemo(()=>Vc({spacing:i,direction:h}),[i,h]),f=!!u,y=!d&&!f,m=A.useMemo(()=>{const _=ks(l);return y?_:_.map((k,C)=>{const j=typeof k.key<"u"?k.key:C,E=C+1===_.length,I=d?x.jsx(ri,{children:k},j):k;if(!f)return I;const F=A.cloneElement(u,{__css:v}),$=E?null:F;return x.jsxs(A.Fragment,{children:[I,$]},j)})},[u,v,f,y,d,l]),g=be("chakra-stack",c);return x.jsx(de.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:h,flexWrap:a,gap:f?void 0:i,className:g,...p,children:m})});He.displayName="Stack";var rt=he((t,e)=>x.jsx(He,{align:"center",...t,direction:"row",ref:e}));rt.displayName="HStack";var sn=he(function(e,n){const r=qn("Heading",e),{className:o,...s}=Ze(e);return x.jsx(de.h2,{ref:n,className:be("chakra-heading",e.className),...s,__css:r})});sn.displayName="Heading";var jt=de("div");jt.displayName="Box";var oi=he(function(e,n){const{size:r,centerContent:o=!0,...s}=e,i=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return x.jsx(jt,{ref:n,boxSize:r,__css:{...i,flexShrink:0,flexGrow:0},...s})});oi.displayName="Square";var Hc=he(function(e,n){const{size:r,...o}=e;return x.jsx(oi,{size:r,ref:n,borderRadius:"9999px",...o})});Hc.displayName="Circle";var si=he(function(e,n){const r=qn("Badge",e),{className:o,...s}=Ze(e);return x.jsx(de.span,{ref:n,className:be("chakra-badge",e.className),...s,__css:{display:"inline-block",whiteSpace:"nowrap",verticalAlign:"middle",...r}})});si.displayName="Badge";var Wt=he(function(e,n){const{direction:r,align:o,justify:s,wrap:i,basis:a,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:i,flexBasis:a,flexGrow:l,flexShrink:u};return x.jsx(de.div,{ref:n,__css:d,...c})});Wt.displayName="Flex";function qc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function Gc(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(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(qc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),a()}}}return l}function Jc(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 Zc(){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 uo(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function ai(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:i,onMouseUp:a,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:p,onMouseLeave:h,...v}=t,[f,y]=A.useState(!0),[m,g]=A.useState(!1),_=Zc(),k=O=>{O&&O.tagName!=="BUTTON"&&y(!1)},C=f?d:d||0,j=n&&!r,E=A.useCallback(O=>{if(n){O.stopPropagation(),O.preventDefault();return}O.currentTarget.focus(),l==null||l(O)},[n,l]),N=A.useCallback(O=>{m&&uo(O)&&(O.preventDefault(),O.stopPropagation(),g(!1),_.remove(document,"keyup",N,!1))},[m,_]),I=A.useCallback(O=>{if(u==null||u(O),n||O.defaultPrevented||O.metaKey||!uo(O.nativeEvent)||f)return;const J=o&&O.key==="Enter";s&&O.key===" "&&(O.preventDefault(),g(!0)),J&&(O.preventDefault(),O.currentTarget.click()),_.add(document,"keyup",N,!1)},[n,f,u,o,s,_,N]),F=A.useCallback(O=>{if(c==null||c(O),n||O.defaultPrevented||O.metaKey||!uo(O.nativeEvent)||f)return;s&&O.key===" "&&(O.preventDefault(),g(!1),O.currentTarget.click())},[s,f,n,c]),$=A.useCallback(O=>{O.button===0&&(g(!1),_.remove(document,"mouseup",$,!1))},[_]),P=A.useCallback(O=>{if(O.button!==0)return;if(n){O.stopPropagation(),O.preventDefault();return}f||g(!0),O.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",$,!1),i==null||i(O)},[n,f,i,_,$]),B=A.useCallback(O=>{O.button===0&&(f||g(!1),a==null||a(O))},[a,f]),b=A.useCallback(O=>{if(n){O.preventDefault();return}p==null||p(O)},[n,p]),K=A.useCallback(O=>{m&&(O.preventDefault(),g(!1)),h==null||h(O)},[m,h]),te=Be(e,k);return f?{...v,ref:te,type:"button","aria-disabled":j?void 0:n,disabled:j,onClick:E,onMouseDown:i,onMouseUp:a,onKeyUp:c,onKeyDown:u,onMouseOver:p,onMouseLeave:h}:{...v,ref:te,role:"button","data-active":it(m),"aria-disabled":n?"true":void 0,tabIndex:j?void 0:C,onClick:E,onMouseDown:P,onMouseUp:B,onKeyUp:F,onKeyDown:I,onMouseOver:b,onMouseLeave:K}}function Yc(t){const e=t.current;if(!e)return!1;const n=Kl(e);return!n||e.contains(n)?!1:!!$l(n)}function ii(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;qr(()=>{if(!s||Yc(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 Xc={preventScroll:!0,shouldFocus:!1};function Qc(t,e=Xc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,i=eu(t)?t.current:t,a=o&&s,l=A.useRef(a),u=A.useRef(s);Fa(()=>{!u.current&&s&&(l.current=a),u.current=s},[s,a]);const c=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=Ul(i);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,i,n]);qr(()=>{c()},[c]),on(i,"transitionend",c)}function eu(t){return"current"in t}var Qt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),Pe={arrowShadowColor:Qt("--popper-arrow-shadow-color"),arrowSize:Qt("--popper-arrow-size","8px"),arrowSizeHalf:Qt("--popper-arrow-size-half"),arrowBg:Qt("--popper-arrow-bg"),transformOrigin:Qt("--popper-transform-origin"),arrowOffset:Qt("--popper-arrow-offset")};function tu(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 nu={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"},ru=t=>nu[t],ra={scroll:!0,resize:!0};function ou(t){let e;return typeof t=="object"?e={enabled:!0,options:{...ra,...t}}:e={enabled:t,options:ra},e}var su={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`}},au={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{oa(t)},effect:({state:t})=>()=>{oa(t)}},oa=t=>{t.elements.popper.style.setProperty(Pe.transformOrigin.var,ru(t.placement))},iu={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{lu(t)}},lu=t=>{var e;if(!t.placement)return;const n=cu(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:Pe.arrowSize.varRef,height:Pe.arrowSize.varRef,zIndex:-1});const r={[Pe.arrowSizeHalf.var]:`calc(${Pe.arrowSize.varRef} / 2 - 1px)`,[Pe.arrowOffset.var]:`calc(${Pe.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},cu=t=>{if(t.startsWith("top"))return{property:"bottom",value:Pe.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:Pe.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:Pe.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:Pe.arrowOffset.varRef}},uu={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{sa(t)},effect:({state:t})=>()=>{sa(t)}},sa=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=tu(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:Pe.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},du={"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"}},fu={"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 hu(t,e="ltr"){var n,r;const o=((n=du[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=fu[t])!=null?r:o}var Ke="top",et="bottom",tt="right",$e="left",Es="auto",Gn=[Ke,et,tt,$e],un="start",Bn="end",pu="clippingParents",li="viewport",En="popper",mu="reference",aa=Gn.reduce(function(t,e){return t.concat([e+"-"+un,e+"-"+Bn])},[]),ci=[].concat(Gn,[Es]).reduce(function(t,e){return t.concat([e,e+"-"+un,e+"-"+Bn])},[]),yu="beforeRead",vu="read",gu="afterRead",wu="beforeMain",bu="main",_u="afterMain",xu="beforeWrite",ku="write",Eu="afterWrite",Cu=[yu,vu,gu,wu,bu,_u,xu,ku,Eu];function ut(t){return t?(t.nodeName||"").toLowerCase():null}function Ge(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function qt(t){var e=Ge(t).Element;return t instanceof e||t instanceof Element}function Qe(t){var e=Ge(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Cs(t){if(typeof ShadowRoot>"u")return!1;var e=Ge(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Su(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];!Qe(s)||!ut(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function Ou(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,u){return l[u]="",l},{});!Qe(o)||!ut(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Iu={name:"applyStyles",enabled:!0,phase:"write",fn:Su,effect:Ou,requires:["computeStyles"]};function ct(t){return t.split("-")[0]}var Ut=Math.max,Dr=Math.min,dn=Math.round;function Po(){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 ui(){return!/^((?!chrome|android).)*safari/i.test(Po())}function fn(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Qe(t)&&(o=t.offsetWidth>0&&dn(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&dn(r.height)/t.offsetHeight||1);var i=qt(t)?Ge(t):window,a=i.visualViewport,l=!ui()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/o,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,p=r.height/s;return{width:d,height:p,top:c,right:u+d,bottom:c+p,left:u,x:u,y:c}}function Ss(t){var e=fn(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 di(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Cs(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function kt(t){return Ge(t).getComputedStyle(t)}function Du(t){return["table","td","th"].indexOf(ut(t))>=0}function Tt(t){return((qt(t)?t.ownerDocument:t.document)||window.document).documentElement}function eo(t){return ut(t)==="html"?t:t.assignedSlot||t.parentNode||(Cs(t)?t.host:null)||Tt(t)}function ia(t){return!Qe(t)||kt(t).position==="fixed"?null:t.offsetParent}function ju(t){var e=/firefox/i.test(Po()),n=/Trident/i.test(Po());if(n&&Qe(t)){var r=kt(t);if(r.position==="fixed")return null}var o=eo(t);for(Cs(o)&&(o=o.host);Qe(o)&&["html","body"].indexOf(ut(o))<0;){var s=kt(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 Jn(t){for(var e=Ge(t),n=ia(t);n&&Du(n)&&kt(n).position==="static";)n=ia(n);return n&&(ut(n)==="html"||ut(n)==="body"&&kt(n).position==="static")?e:n||ju(t)||e}function Os(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Dn(t,e,n){return Ut(t,Dr(e,n))}function Pu(t,e,n){var r=Dn(t,e,n);return r>n?n:r}function fi(){return{top:0,right:0,bottom:0,left:0}}function hi(t){return Object.assign({},fi(),t)}function pi(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Au=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,hi(typeof e!="number"?e:pi(e,Gn))};function Nu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=ct(n.placement),l=Os(a),u=[$e,tt].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!i)){var d=Au(o.padding,n),p=Ss(s),h=l==="y"?Ke:$e,v=l==="y"?et:tt,f=n.rects.reference[c]+n.rects.reference[l]-i[l]-n.rects.popper[c],y=i[l]-n.rects.reference[l],m=Jn(s),g=m?l==="y"?m.clientHeight||0:m.clientWidth||0:0,_=f/2-y/2,k=d[h],C=g-p[c]-d[v],j=g/2-p[c]/2+_,E=Dn(k,j,C),N=l;n.modifiersData[r]=(e={},e[N]=E,e.centerOffset=E-j,e)}}function Fu(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||di(e.elements.popper,o)&&(e.elements.arrow=o))}const Ru={name:"arrow",enabled:!0,phase:"main",fn:Nu,effect:Fu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function hn(t){return t.split("-")[1]}var Tu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Bu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:dn(n*o)/o||0,y:dn(r*o)/o||0}}function la(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,p=i.x,h=p===void 0?0:p,v=i.y,f=v===void 0?0:v,y=typeof c=="function"?c({x:h,y:f}):{x:h,y:f};h=y.x,f=y.y;var m=i.hasOwnProperty("x"),g=i.hasOwnProperty("y"),_=$e,k=Ke,C=window;if(u){var j=Jn(n),E="clientHeight",N="clientWidth";if(j===Ge(n)&&(j=Tt(n),kt(j).position!=="static"&&a==="absolute"&&(E="scrollHeight",N="scrollWidth")),j=j,o===Ke||(o===$e||o===tt)&&s===Bn){k=et;var I=d&&j===C&&C.visualViewport?C.visualViewport.height:j[E];f-=I-r.height,f*=l?1:-1}if(o===$e||(o===Ke||o===et)&&s===Bn){_=tt;var F=d&&j===C&&C.visualViewport?C.visualViewport.width:j[N];h-=F-r.width,h*=l?1:-1}}var $=Object.assign({position:a},u&&Tu),P=c===!0?Bu({x:h,y:f},Ge(n)):{x:h,y:f};if(h=P.x,f=P.y,l){var B;return Object.assign({},$,(B={},B[k]=g?"0":"",B[_]=m?"0":"",B.transform=(C.devicePixelRatio||1)<=1?"translate("+h+"px, "+f+"px)":"translate3d("+h+"px, "+f+"px, 0)",B))}return Object.assign({},$,(e={},e[k]=g?f+"px":"",e[_]=m?h+"px":"",e.transform="",e))}function Mu(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:ct(e.placement),variation:hn(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,la(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,la(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const zu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Mu,data:{}};var rr={passive:!0};function Lu(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=Ge(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,rr)}),a&&l.addEventListener("resize",n.update,rr),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,rr)}),a&&l.removeEventListener("resize",n.update,rr)}}const Wu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Lu,data:{}};var Uu={left:"right",right:"left",bottom:"top",top:"bottom"};function pr(t){return t.replace(/left|right|bottom|top/g,function(e){return Uu[e]})}var Ku={start:"end",end:"start"};function ca(t){return t.replace(/start|end/g,function(e){return Ku[e]})}function Is(t){var e=Ge(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Ds(t){return fn(Tt(t)).left+Is(t).scrollLeft}function $u(t,e){var n=Ge(t),r=Tt(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var u=ui();(u||!u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Ds(t),y:l}}function Vu(t){var e,n=Tt(t),r=Is(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Ut(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Ut(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Ds(t),l=-r.scrollTop;return kt(o||n).direction==="rtl"&&(a+=Ut(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function js(t){var e=kt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function mi(t){return["html","body","#document"].indexOf(ut(t))>=0?t.ownerDocument.body:Qe(t)&&js(t)?t:mi(eo(t))}function jn(t,e){var n;e===void 0&&(e=[]);var r=mi(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ge(r),i=o?[s].concat(s.visualViewport||[],js(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(jn(eo(i)))}function Ao(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Hu(t,e){var n=fn(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 ua(t,e,n){return e===li?Ao($u(t,n)):qt(e)?Hu(e,n):Ao(Vu(Tt(t)))}function qu(t){var e=jn(eo(t)),n=["absolute","fixed"].indexOf(kt(t).position)>=0,r=n&&Qe(t)?Jn(t):t;return qt(r)?e.filter(function(o){return qt(o)&&di(o,r)&&ut(o)!=="body"}):[]}function Gu(t,e,n,r){var o=e==="clippingParents"?qu(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,u){var c=ua(t,u,r);return l.top=Ut(c.top,l.top),l.right=Dr(c.right,l.right),l.bottom=Dr(c.bottom,l.bottom),l.left=Ut(c.left,l.left),l},ua(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 yi(t){var e=t.reference,n=t.element,r=t.placement,o=r?ct(r):null,s=r?hn(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 et:l={x:i,y:e.y+e.height};break;case tt:l={x:e.x+e.width,y:a};break;case $e:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=o?Os(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case un:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Bn:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function Mn(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?pu:a,u=n.rootBoundary,c=u===void 0?li:u,d=n.elementContext,p=d===void 0?En:d,h=n.altBoundary,v=h===void 0?!1:h,f=n.padding,y=f===void 0?0:f,m=hi(typeof y!="number"?y:pi(y,Gn)),g=p===En?mu:En,_=t.rects.popper,k=t.elements[v?g:p],C=Gu(qt(k)?k:k.contextElement||Tt(t.elements.popper),l,c,i),j=fn(t.elements.reference),E=yi({reference:j,element:_,strategy:"absolute",placement:o}),N=Ao(Object.assign({},_,E)),I=p===En?N:j,F={top:C.top-I.top+m.top,bottom:I.bottom-C.bottom+m.bottom,left:C.left-I.left+m.left,right:I.right-C.right+m.right},$=t.modifiersData.offset;if(p===En&&$){var P=$[o];Object.keys(F).forEach(function(B){var b=[tt,et].indexOf(B)>=0?1:-1,K=[Ke,et].indexOf(B)>=0?"y":"x";F[B]+=P[K]*b})}return F}function Ju(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?ci:l,c=hn(r),d=c?a?aa:aa.filter(function(v){return hn(v)===c}):Gn,p=d.filter(function(v){return u.indexOf(v)>=0});p.length===0&&(p=d);var h=p.reduce(function(v,f){return v[f]=Mn(t,{placement:f,boundary:o,rootBoundary:s,padding:i})[ct(f)],v},{});return Object.keys(h).sort(function(v,f){return h[v]-h[f]})}function Zu(t){if(ct(t)===Es)return[];var e=pr(t);return[ca(t),e,ca(e)]}function Yu(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,p=n.altBoundary,h=n.flipVariations,v=h===void 0?!0:h,f=n.allowedAutoPlacements,y=e.options.placement,m=ct(y),g=m===y,_=l||(g||!v?[pr(y)]:Zu(y)),k=[y].concat(_).reduce(function(Y,G){return Y.concat(ct(G)===Es?Ju(e,{placement:G,boundary:c,rootBoundary:d,padding:u,flipVariations:v,allowedAutoPlacements:f}):G)},[]),C=e.rects.reference,j=e.rects.popper,E=new Map,N=!0,I=k[0],F=0;F=0,K=b?"width":"height",te=Mn(e,{placement:$,boundary:c,rootBoundary:d,altBoundary:p,padding:u}),O=b?B?tt:$e:B?et:Ke;C[K]>j[K]&&(O=pr(O));var J=pr(O),M=[];if(s&&M.push(te[P]<=0),a&&M.push(te[O]<=0,te[J]<=0),M.every(function(Y){return Y})){I=$,N=!1;break}E.set($,M)}if(N)for(var Q=v?3:1,z=function(G){var fe=k.find(function(ye){var se=E.get(ye);if(se)return se.slice(0,G).every(function(le){return le})});if(fe)return I=fe,"break"},T=Q;T>0;T--){var ne=z(T);if(ne==="break")break}e.placement!==I&&(e.modifiersData[r]._skip=!0,e.placement=I,e.reset=!0)}}const Xu={name:"flip",enabled:!0,phase:"main",fn:Yu,requiresIfExists:["offset"],data:{_skip:!1}};function da(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 fa(t){return[Ke,tt,et,$e].some(function(e){return t[e]>=0})}function Qu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Mn(e,{elementContext:"reference"}),a=Mn(e,{altBoundary:!0}),l=da(i,r),u=da(a,o,s),c=fa(l),d=fa(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const ed={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Qu};function td(t,e,n){var r=ct(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,tt].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function nd(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=ci.reduce(function(c,d){return c[d]=td(d,e.rects,s),c},{}),a=i[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=i}const rd={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:nd};function od(t){var e=t.state,n=t.name;e.modifiersData[n]=yi({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const sd={name:"popperOffsets",enabled:!0,phase:"read",fn:od,data:{}};function ad(t){return t==="x"?"y":"x"}function id(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,p=n.tether,h=p===void 0?!0:p,v=n.tetherOffset,f=v===void 0?0:v,y=Mn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),m=ct(e.placement),g=hn(e.placement),_=!g,k=Os(m),C=ad(k),j=e.modifiersData.popperOffsets,E=e.rects.reference,N=e.rects.popper,I=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,F=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(j){if(s){var B,b=k==="y"?Ke:$e,K=k==="y"?et:tt,te=k==="y"?"height":"width",O=j[k],J=O+y[b],M=O-y[K],Q=h?-N[te]/2:0,z=g===un?E[te]:N[te],T=g===un?-N[te]:-E[te],ne=e.elements.arrow,Y=h&&ne?Ss(ne):{width:0,height:0},G=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:fi(),fe=G[b],ye=G[K],se=Dn(0,E[te],Y[te]),le=_?E[te]/2-Q-se-fe-F.mainAxis:z-se-fe-F.mainAxis,ke=_?-E[te]/2+Q+se+ye+F.mainAxis:T+se+ye+F.mainAxis,ve=e.elements.arrow&&Jn(e.elements.arrow),me=ve?k==="y"?ve.clientTop||0:ve.clientLeft||0:0,Ee=(B=$==null?void 0:$[k])!=null?B:0,w=O+le-Ee-me,U=O+ke-Ee,W=Dn(h?Dr(J,w):J,O,h?Ut(M,U):M);j[k]=W,P[k]=W-O}if(a){var D,S=k==="x"?Ke:$e,R=k==="x"?et:tt,H=j[C],Z=C==="y"?"height":"width",L=H+y[S],X=H-y[R],re=[Ke,$e].indexOf(m)!==-1,ee=(D=$==null?void 0:$[C])!=null?D:0,ae=re?L:H-E[Z]-N[Z]-ee+F.altAxis,ge=re?H+E[Z]+N[Z]-ee-F.altAxis:X,pe=h&&re?Pu(ae,H,ge):Dn(h?ae:L,H,h?ge:X);j[C]=pe,P[C]=pe-H}e.modifiersData[r]=P}}const ld={name:"preventOverflow",enabled:!0,phase:"main",fn:id,requiresIfExists:["offset"]};function cd(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function ud(t){return t===Ge(t)||!Qe(t)?Is(t):cd(t)}function dd(t){var e=t.getBoundingClientRect(),n=dn(e.width)/t.offsetWidth||1,r=dn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function fd(t,e,n){n===void 0&&(n=!1);var r=Qe(e),o=Qe(e)&&dd(e),s=Tt(e),i=fn(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((ut(e)!=="body"||js(s))&&(a=ud(e)),Qe(e)?(l=fn(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Ds(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function hd(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 pd(t){var e=hd(t);return Cu.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function md(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function yd(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 ha={placement:"bottom",modifiers:[],strategy:"absolute"};function pa(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=A.useCallback(()=>{var F;!e||!v.current||!f.current||((F=g.current)==null||F.call(g),y.current=wd(v.current,f.current,{placement:m,modifiers:[uu,iu,au,{...su,enabled:!!p},{name:"eventListeners",...ou(i)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:a??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),y.current.forceUpdate(),g.current=y.current.destroy)},[m,e,n,p,i,s,a,l,u,d,c,o]);A.useEffect(()=>()=>{var F;!v.current&&!f.current&&((F=y.current)==null||F.destroy(),y.current=null)},[]);const k=A.useCallback(F=>{v.current=F,_()},[_]),C=A.useCallback((F={},$=null)=>({...F,ref:Be(k,$)}),[k]),j=A.useCallback(F=>{f.current=F,_()},[_]),E=A.useCallback((F={},$=null)=>({...F,ref:Be(j,$),style:{...F.style,position:o,minWidth:p?void 0:"max-content",inset:"0 auto auto 0"}}),[o,j,p]),N=A.useCallback((F={},$=null)=>{const{size:P,shadowColor:B,bg:b,style:K,...te}=F;return{...te,ref:$,"data-popper-arrow":"",style:bd(F)}},[]),I=A.useCallback((F={},$=null)=>({...F,ref:$,"data-popper-arrow-inner":""}),[]);return{update(){var F;(F=y.current)==null||F.update()},forceUpdate(){var F;(F=y.current)==null||F.forceUpdate()},transformOrigin:Pe.transformOrigin.varRef,referenceRef:k,popperRef:j,getPopperProps:E,getArrowProps:N,getArrowInnerProps:I,getReferenceProps:C}}function bd(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 As(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Lt(n),i=Lt(e),[a,l]=A.useState(t.defaultIsOpen||!1),u=r!==void 0?r:a,c=r!==void 0,d=A.useId(),p=o??`disclosure-${d}`,h=A.useCallback(()=>{c||l(!1),i==null||i()},[c,i]),v=A.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),f=A.useCallback(()=>{u?h():v()},[u,v,h]);function y(g={}){return{...g,"aria-expanded":u,"aria-controls":p,onClick(_){var k;(k=g.onClick)==null||k.call(g,_),f()}}}function m(g={}){return{...g,hidden:!u,id:p}}return{isOpen:u,onOpen:v,onClose:h,onToggle:f,isControlled:c,getButtonProps:y,getDisclosureProps:m}}function _d(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Lt(n),i=A.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;A.useEffect(()=>{if(!r)return;const a=d=>{fo(d,e)&&(i.isPointerDown=!0)},l=d=>{if(i.ignoreEmulatedMouseEvents){i.ignoreEmulatedMouseEvents=!1;return}i.isPointerDown&&n&&fo(d,e)&&(i.isPointerDown=!1,o(d))},u=d=>{i.ignoreEmulatedMouseEvents=!0,n&&i.isPointerDown&&fo(d,e)&&(i.isPointerDown=!1,o(d))},c=vi(e.current);return c.addEventListener("mousedown",a,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",a,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",a,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",a,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,i,r])}function fo(t,e){var n;const r=t.target;return r&&!vi(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function vi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function gi(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]),on(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=Vl(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function Ns(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[xd,kd,Ed,Cd]=Va(),[Sd,Zn]=nt({strict:!1,name:"MenuContext"});function Od(t,...e){const n=A.useId(),r=t||n;return A.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function wi(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function ma(t){return wi(t).activeElement===t}function Id(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:i,isOpen:a,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:p="unmount",direction:h,computePositionOnMount:v=!1,...f}=t,y=A.useRef(null),m=A.useRef(null),g=Ed(),_=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 G=g.firstEnabled();G&&B(G.index)}});J.current.add(ne)},[g,o]),C=A.useCallback(()=>{const ne=setTimeout(()=>{const Y=g.lastEnabled();Y&&B(Y.index)});J.current.add(ne)},[g]),j=A.useCallback(()=>{c==null||c(),s?k():_()},[s,k,_,c]),{isOpen:E,onOpen:N,onClose:I,onToggle:F}=As({isOpen:a,defaultIsOpen:l,onClose:u,onOpen:j});_d({enabled:E&&r,ref:y,handler:ne=>{var Y;(Y=m.current)!=null&&Y.contains(ne.target)||I()}});const $=Ps({...f,enabled:E||v,placement:d,direction:h}),[P,B]=A.useState(-1);qr(()=>{E||B(-1)},[E]),ii(y,{focusRef:m,visible:E,shouldFocus:!0});const b=gi({isOpen:E,ref:y}),[K,te]=Od(e,"menu-button","menu-list"),O=A.useCallback(()=>{N(),_()},[N,_]),J=A.useRef(new Set([]));A.useEffect(()=>{const ne=J.current;return()=>{ne.forEach(Y=>clearTimeout(Y)),ne.clear()}},[]);const M=A.useCallback(()=>{N(),k()},[k,N]),Q=A.useCallback(()=>{N(),C()},[N,C]),z=A.useCallback(()=>{var ne,Y;const G=wi(y.current),fe=(ne=y.current)==null?void 0:ne.contains(G.activeElement);if(!(E&&!fe))return;const se=(Y=g.item(P))==null?void 0:Y.node;se==null||se.focus({preventScroll:!0})},[E,P,g]),T=A.useRef(null);return{openAndFocusMenu:O,openAndFocusFirstItem:M,openAndFocusLastItem:Q,onTransitionEnd:z,unstable__animationState:b,descendants:g,popper:$,buttonId:K,menuId:te,forceUpdate:$.forceUpdate,orientation:"vertical",isOpen:E,onToggle:F,onOpen:N,onClose:I,menuRef:y,buttonRef:m,focusedIndex:P,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:B,isLazy:i,lazyBehavior:p,initialFocusRef:o,rafId:T}}function Xp(t={},e=null){const n=Zn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:i}=n,a=A.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:i}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,i]);return{...t,ref:Be(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":it(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:Ie(t.onClick,r),onKeyDown:Ie(t.onKeyDown,a)}}function No(t){var e;return Pd(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Dd(t={},e=null){const n=Zn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:i,onClose:a,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,p=kd(),h=Gc({preventDefault:m=>m.key!==" "&&No(m.target)}),v=A.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const g=m.key,k={Tab:j=>j.preventDefault(),Escape:a,ArrowDown:()=>{const j=p.nextEnabled(r);j&&o(j.index)},ArrowUp:()=>{const j=p.prevEnabled(r);j&&o(j.index)}}[g];if(k){m.preventDefault(),k(m);return}const C=h(j=>{const E=Jc(p.values(),j,N=>{var I,F;return(F=(I=N==null?void 0:N.node)==null?void 0:I.textContent)!=null?F:""},p.item(r));if(E){const N=p.indexOf(E.node);o(N)}});No(m.target)&&C(m)},[p,r,h,a,o]),f=A.useRef(!1);i&&(f.current=!0);const y=Ns({wasSelected:f.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:Be(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:Ie(t.onKeyDown,v)}}function jd(t={}){const{popper:e,isOpen:n}=Zn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function bi(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:i,isDisabled:a,isFocusable:l,closeOnSelect:u,type:c,...d}=t,p=Zn(),{setFocusedIndex:h,focusedIndex:v,closeOnSelect:f,onClose:y,menuRef:m,isOpen:g,menuId:_,rafId:k}=p,C=A.useRef(null),j=`${_}-menuitem-${A.useId()}`,{index:E,register:N}=Cd({disabled:a&&!l}),I=A.useCallback(O=>{n==null||n(O),!a&&h(E)},[h,E,a,n]),F=A.useCallback(O=>{r==null||r(O),C.current&&!ma(C.current)&&I(O)},[I,r]),$=A.useCallback(O=>{o==null||o(O),!a&&h(-1)},[h,a,o]),P=A.useCallback(O=>{s==null||s(O),No(O.currentTarget)&&(u??f)&&y()},[y,s,f,u]),B=A.useCallback(O=>{i==null||i(O),h(E)},[h,i,E]),b=E===v,K=a&&!l;qr(()=>{if(g)return b&&!K&&C.current?(k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{var O;(O=C.current)==null||O.focus({preventScroll:!0}),k.current=null})):m.current&&!ma(m.current)&&m.current.focus({preventScroll:!0}),()=>{k.current&&cancelAnimationFrame(k.current)}},[b,K,m,g]);const te=ai({onClick:P,onFocus:B,onMouseEnter:I,onMouseMove:F,onMouseLeave:$,ref:Be(N,C,e),isDisabled:a,isFocusable:l});return{...d,...te,type:c??te.type,id:j,role:"menuitem",tabIndex:b?0:-1}}function Qp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...bi(o,e),role:`menuitem${n}`,"aria-checked":r}}function em(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...i}=t,l=n==="radio"?"":[],[u,c]=Ha({defaultValue:o??l,value:r,onChange:s}),d=A.useCallback(v=>{if(n==="radio"&&typeof u=="string"&&c(v),n==="checkbox"&&Array.isArray(u)){const f=u.includes(v)?u.filter(y=>y!==v):u.concat(v);c(f)}},[u,c,n]),h=ks(e).map(v=>{if(v.type.id!=="MenuItemOption")return v;const f=m=>{var g,_;d(v.props.value),(_=(g=v.props).onClick)==null||_.call(g,m)},y=n==="radio"?v.props.value===u:u.includes(v.props.value);return A.cloneElement(v,{type:n,onClick:f,isChecked:y})});return{...i,children:h}}function Pd(t){var e;if(!Ad(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function Ad(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Nd,to]=nt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Fs=t=>{const{children:e}=t,n=Rt("Menu",t),r=Ze(t),{direction:o}=vs(),{descendants:s,...i}=Id({...r,direction:o}),a=A.useMemo(()=>i,[i]),{isOpen:l,onClose:u,forceUpdate:c}=a;return x.jsx(xd,{value:s,children:x.jsx(Sd,{value:a,children:x.jsx(Nd,{value:n,children:Ta(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};Fs.displayName="Menu";var _i=he((t,e)=>{const n=to();return x.jsx(de.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});_i.displayName="MenuCommand";var Fd=he((t,e)=>{const{type:n,...r}=t,o=to(),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 x.jsx(de.button,{ref:e,type:s,...r,__css:i})}),xi=t=>{const{className:e,children:n,...r}=t,o=to(),s=A.Children.only(n),i=A.isValidElement(s)?A.cloneElement(s,{focusable:"false","aria-hidden":!0,className:be("chakra-menu__icon",s.props.className)}):null,a=be("chakra-menu__icon-wrapper",e);return x.jsx(de.span,{className:a,...r,__css:o.icon,children:i})};xi.displayName="MenuIcon";var pt=he((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:i,...a}=t,l=bi(a,e),c=n||o?x.jsx("span",{style:{pointerEvents:"none",flex:1},children:i}):i;return x.jsxs(Fd,{...l,className:be("chakra-menu__menuitem",l.className),children:[n&&x.jsx(xi,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&x.jsx(_i,{marginStart:s,children:o})]})});pt.displayName="MenuItem";var Rd={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"}}},Td=de(gs.div),Rs=he(function(e,n){var r,o;const{rootProps:s,motionProps:i,...a}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Zn(),d=Dd(a,n),p=jd(s),h=to();return x.jsx(de.div,{...p,__css:{zIndex:(o=e.zIndex)!=null?o:(r=h.list)==null?void 0:r.zIndex},children:x.jsx(Td,{variants:Rd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...h.list},...i,className:be("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:Ba(c.onComplete,d.onAnimationComplete)})})});Rs.displayName="MenuList";var[Bd,gn]=nt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Md,no]=nt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ki(t){const e=A.Children.only(t.children),{getTriggerProps:n}=gn();return A.cloneElement(e,n(e.props,e.ref))}ki.displayName="PopoverTrigger";var en={click:"click",hover:"hover"};function zd(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:i=!0,arrowSize:a,arrowShadowColor:l,trigger:u=en.click,openDelay:c=200,closeDelay:d=200,isLazy:p,lazyBehavior:h="unmount",computePositionOnMount:v,...f}=t,{isOpen:y,onClose:m,onOpen:g,onToggle:_}=As(t),k=A.useRef(null),C=A.useRef(null),j=A.useRef(null),E=A.useRef(!1),N=A.useRef(!1);y&&(N.current=!0);const[I,F]=A.useState(!1),[$,P]=A.useState(!1),B=A.useId(),b=o??B,[K,te,O,J]=["popover-trigger","popover-content","popover-header","popover-body"].map(U=>`${U}-${b}`),{referenceRef:M,getArrowProps:Q,getPopperProps:z,getArrowInnerProps:T,forceUpdate:ne}=Ps({...f,enabled:y||!!v}),Y=gi({isOpen:y,ref:j});jc({enabled:y,ref:C}),ii(j,{focusRef:C,visible:y,shouldFocus:s&&u===en.click}),Qc(j,{focusRef:r,visible:y,shouldFocus:i&&u===en.click});const G=Ns({wasSelected:N.current,enabled:p,mode:h,isSelected:Y.present}),fe=A.useCallback((U={},W=null)=>{const D={...U,style:{...U.style,transformOrigin:Pe.transformOrigin.varRef,[Pe.arrowSize.var]:a?`${a}px`:void 0,[Pe.arrowShadowColor.var]:l},ref:Be(j,W),children:G?U.children:null,id:te,tabIndex:-1,role:"dialog",onKeyDown:Ie(U.onKeyDown,S=>{n&&S.key==="Escape"&&m()}),onBlur:Ie(U.onBlur,S=>{const R=ya(S),H=ho(j.current,R),Z=ho(C.current,R);y&&e&&(!H&&!Z)&&m()}),"aria-labelledby":I?O:void 0,"aria-describedby":$?J:void 0};return u===en.hover&&(D.role="tooltip",D.onMouseEnter=Ie(U.onMouseEnter,()=>{E.current=!0}),D.onMouseLeave=Ie(U.onMouseLeave,S=>{S.nativeEvent.relatedTarget!==null&&(E.current=!1,setTimeout(()=>m(),d))})),D},[G,te,I,O,$,J,u,n,m,y,e,d,l,a]),ye=A.useCallback((U={},W=null)=>z({...U,style:{visibility:y?"visible":"hidden",...U.style}},W),[y,z]),se=A.useCallback((U,W=null)=>({...U,ref:Be(W,k,M)}),[k,M]),le=A.useRef(),ke=A.useRef(),ve=A.useCallback(U=>{k.current==null&&M(U)},[M]),me=A.useCallback((U={},W=null)=>{const D={...U,ref:Be(C,W,ve),id:K,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":te};return u===en.click&&(D.onClick=Ie(U.onClick,_)),u===en.hover&&(D.onFocus=Ie(U.onFocus,()=>{le.current===void 0&&g()}),D.onBlur=Ie(U.onBlur,S=>{const R=ya(S),H=!ho(j.current,R);y&&e&&H&&m()}),D.onKeyDown=Ie(U.onKeyDown,S=>{S.key==="Escape"&&m()}),D.onMouseEnter=Ie(U.onMouseEnter,()=>{E.current=!0,le.current=window.setTimeout(()=>g(),c)}),D.onMouseLeave=Ie(U.onMouseLeave,()=>{E.current=!1,le.current&&(clearTimeout(le.current),le.current=void 0),ke.current=window.setTimeout(()=>{E.current===!1&&m()},d)})),D},[K,y,te,u,ve,_,g,e,m,c,d]);A.useEffect(()=>()=>{le.current&&clearTimeout(le.current),ke.current&&clearTimeout(ke.current)},[]);const Ee=A.useCallback((U={},W=null)=>({...U,id:O,ref:Be(W,D=>{F(!!D)})}),[O]),w=A.useCallback((U={},W=null)=>({...U,id:J,ref:Be(W,D=>{P(!!D)})}),[J]);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:w}}function ho(t,e){return t===e||(t==null?void 0:t.contains(e))}function ya(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function Ei(t){const e=Rt("Popover",t),{children:n,...r}=Ze(t),o=vs(),s=zd({...r,direction:o.direction});return x.jsx(Bd,{value:s,children:x.jsx(Md,{value:e,children:Ta(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}Ei.displayName="Popover";var po=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function Ci(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:i,shadowColor:a}=t,{getArrowProps:l,getArrowInnerProps:u}=gn(),c=no(),d=(e=n??r)!=null?e:o,p=s??i;return x.jsx(de.div,{...l(),className:"chakra-popover__arrow-positioner",children:x.jsx(de.div,{className:be("chakra-popover__arrow",t.className),...u(t),__css:{"--popper-arrow-shadow-color":po("colors",a),"--popper-arrow-bg":po("colors",d),"--popper-arrow-shadow":po("shadows",p),...c.arrow}})})}Ci.displayName="PopoverArrow";var Si=he(function(e,n){const{getBodyProps:r}=gn(),o=no();return x.jsx(de.div,{...r(e,n),className:be("chakra-popover__body",e.className),__css:o.body})});Si.displayName="PopoverBody";var Oi=he(function(e,n){const{onClose:r}=gn(),o=no();return x.jsx(Hl,{size:"sm",onClick:r,className:be("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});Oi.displayName="PopoverCloseButton";function Ld(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var Wd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},Ud=de(gs.section),Ii=he(function(e,n){const{variants:r=Wd,...o}=e,{isOpen:s}=gn();return x.jsx(Ud,{ref:n,variants:Ld(r),initial:!1,animate:s?"enter":"exit",...o})});Ii.displayName="PopoverTransition";var Di=he(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:i,getPopoverPositionerProps:a,onAnimationComplete:l}=gn(),u=no(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return x.jsx(de.div,{...a(r),__css:u.popper,className:"chakra-popover__popper",children:x.jsx(Ii,{...o,...i(s,n),onAnimationComplete:Ba(l,s.onAnimationComplete),className:be("chakra-popover__content",e.className),__css:c})})});Di.displayName="PopoverContent";var[Kd,$d,Vd,Hd]=Va();function qd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:i,lazyBehavior:a="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,p]=A.useState(n??0),[h,v]=Ha({defaultValue:n??0,value:o,onChange:r});A.useEffect(()=>{o!=null&&p(o)},[o]);const f=Vd(),y=A.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:h,focusedIndex:d,setSelectedIndex:v,setFocusedIndex:p,isManual:s,isLazy:i,lazyBehavior:a,orientation:l,descendants:f,direction:u,htmlProps:c}}var[Gd,ro]=nt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function Jd(t){const{focusedIndex:e,orientation:n,direction:r}=ro(),o=$d(),s=A.useCallback(i=>{const a=()=>{var g;const _=o.nextEnabled(e);_&&((g=_.node)==null||g.focus())},l=()=>{var g;const _=o.prevEnabled(e);_&&((g=_.node)==null||g.focus())},u=()=>{var g;const _=o.firstEnabled();_&&((g=_.node)==null||g.focus())},c=()=>{var g;const _=o.lastEnabled();_&&((g=_.node)==null||g.focus())},d=n==="horizontal",p=n==="vertical",h=i.key,v=r==="ltr"?"ArrowLeft":"ArrowRight",f=r==="ltr"?"ArrowRight":"ArrowLeft",m={[v]:()=>d&&l(),[f]:()=>d&&a(),ArrowDown:()=>p&&a(),ArrowUp:()=>p&&l(),Home:u,End:c}[h];m&&(i.preventDefault(),m(i))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:Ie(t.onKeyDown,s)}}function Zd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:i,setFocusedIndex:a,selectedIndex:l}=ro(),{index:u,register:c}=Hd({disabled:e&&!n}),d=u===l,p=()=>{o(u)},h=()=>{a(u),!s&&!(e&&n)&&o(u)},v=ai({...r,ref:Be(c,t.ref),isDisabled:e,isFocusable:n,onClick:Ie(t.onClick,p)}),f="button";return{...v,id:ji(i,u),role:"tab",tabIndex:d?0:-1,type:f,"aria-selected":d,"aria-controls":Pi(i,u),onFocus:e?void 0:Ie(t.onFocus,h)}}var[Yd,Xd]=nt({});function Qd(t){const e=ro(),{id:n,selectedIndex:r}=e,s=ks(t.children).map((i,a)=>A.createElement(Yd,{key:a,value:{isSelected:a===r,id:Pi(n,a),tabId:ji(n,a),selectedIndex:r}},i));return{...t,children:s}}function ef(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=ro(),{isSelected:s,id:i,tabId:a}=Xd(),l=A.useRef(!1);s&&(l.current=!0);const u=Ns({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":a,hidden:!s,id:i}}function ji(t,e){return`${t}--tab-${e}`}function Pi(t,e){return`${t}--tabpanel-${e}`}var[tf,oo]=nt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ai=he(function(e,n){const r=Rt("Tabs",e),{children:o,className:s,...i}=Ze(e),{htmlProps:a,descendants:l,...u}=qd(i),c=A.useMemo(()=>u,[u]),{isFitted:d,...p}=a,h={position:"relative",...r.root};return x.jsx(Kd,{value:l,children:x.jsx(Gd,{value:c,children:x.jsx(tf,{value:r,children:x.jsx(de.div,{className:be("chakra-tabs",s),ref:n,...p,__css:h,children:o})})})})});Ai.displayName="Tabs";var Ni=he(function(e,n){const r=Jd({...e,ref:n}),s={display:"flex",...oo().tablist};return x.jsx(de.div,{...r,className:be("chakra-tabs__tablist",e.className),__css:s})});Ni.displayName="TabList";var Fo=he(function(e,n){const r=ef({...e,ref:n}),o=oo();return x.jsx(de.div,{outline:"0",...r,className:be("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});Fo.displayName="TabPanel";var Fi=he(function(e,n){const r=Qd(e),o=oo();return x.jsx(de.div,{...r,width:"100%",ref:n,className:be("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Fi.displayName="TabPanels";var Ro=he(function(e,n){const r=oo(),o=Zd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return x.jsx(de.button,{...o,className:be("chakra-tabs__tab",e.className),__css:s})});Ro.displayName="Tab";var[nf,Ri]=nt({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Gt=he((t,e)=>{const n=Rt("Tag",t),r=Ze(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return x.jsx(nf,{value:n,children:x.jsx(de.span,{ref:e,...r,__css:o})})});Gt.displayName="Tag";var rf=he((t,e)=>{const n=Ri();return x.jsx(de.span,{ref:e,noOfLines:1,...t,__css:n.label})});rf.displayName="TagLabel";var of=he((t,e)=>x.jsx(Hr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));of.displayName="TagLeftIcon";var sf=he((t,e)=>x.jsx(Hr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));sf.displayName="TagRightIcon";var Ti=t=>x.jsx(Hr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:x.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"})});Ti.displayName="TagCloseIcon";var af=he((t,e)=>{const{isDisabled:n,children:r,...o}=t,i={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...Ri().closeButton};return x.jsx(de.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:i,children:r||x.jsx(Ti,{})})});af.displayName="TagCloseButton";var lf={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]}}}},To=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},mr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function cf(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:i=o,closeOnEsc:a=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:p,defaultIsOpen:h,arrowSize:v=10,arrowShadowColor:f,arrowPadding:y,modifiers:m,isDisabled:g,gutter:_,offset:k,direction:C,...j}=t,{isOpen:E,onOpen:N,onClose:I}=As({isOpen:p,defaultIsOpen:h,onOpen:l,onClose:u}),{referenceRef:F,getPopperProps:$,getArrowInnerProps:P,getArrowProps:B}=Ps({enabled:E,placement:c,arrowPadding:y,modifiers:m,gutter:_,offset:k,direction:C}),b=A.useId(),te=`tooltip-${d??b}`,O=A.useRef(null),J=A.useRef(),M=A.useCallback(()=>{J.current&&(clearTimeout(J.current),J.current=void 0)},[]),Q=A.useRef(),z=A.useCallback(()=>{Q.current&&(clearTimeout(Q.current),Q.current=void 0)},[]),T=A.useCallback(()=>{z(),I()},[I,z]),ne=uf(O,T),Y=A.useCallback(()=>{if(!g&&!J.current){E&&ne();const me=mr(O);J.current=me.setTimeout(N,e)}},[ne,g,E,N,e]),G=A.useCallback(()=>{M();const me=mr(O);Q.current=me.setTimeout(T,n)},[n,T,M]),fe=A.useCallback(()=>{E&&r&&G()},[r,G,E]),ye=A.useCallback(()=>{E&&i&&G()},[i,G,E]),se=A.useCallback(me=>{E&&me.key==="Escape"&&G()},[E,G]);on(()=>To(O),"keydown",a?se:void 0),on(()=>{if(!s)return null;const me=O.current;if(!me)return null;const Ee=ni(me);return Ee.localName==="body"?mr(O):Ee},"scroll",()=>{E&&s&&T()},{passive:!0,capture:!0}),A.useEffect(()=>{g&&(M(),E&&I())},[g,E,I,M]),A.useEffect(()=>()=>{M(),z()},[M,z]),on(()=>O.current,"pointerleave",G);const le=A.useCallback((me={},Ee=null)=>({...me,ref:Be(O,Ee,F),onPointerEnter:Ie(me.onPointerEnter,U=>{U.pointerType!=="touch"&&Y()}),onClick:Ie(me.onClick,fe),onPointerDown:Ie(me.onPointerDown,ye),onFocus:Ie(me.onFocus,Y),onBlur:Ie(me.onBlur,G),"aria-describedby":E?te:void 0}),[Y,G,ye,E,te,fe,F]),ke=A.useCallback((me={},Ee=null)=>$({...me,style:{...me.style,[Pe.arrowSize.var]:v?`${v}px`:void 0,[Pe.arrowShadowColor.var]:f}},Ee),[$,v,f]),ve=A.useCallback((me={},Ee=null)=>{const w={...me.style,position:"relative",transformOrigin:Pe.transformOrigin.varRef};return{ref:Ee,...j,...me,id:te,role:"tooltip",style:w}},[j,te]);return{isOpen:E,show:Y,hide:G,getTriggerProps:le,getTooltipProps:ve,getTooltipPositionerProps:ke,getArrowProps:B,getArrowInnerProps:P}}var mo="chakra-ui:close-tooltip";function uf(t,e){return A.useEffect(()=>{const n=To(t);return n.addEventListener(mo,e),()=>n.removeEventListener(mo,e)},[e,t]),()=>{const n=To(t),r=mr(t);n.dispatchEvent(new r.CustomEvent(mo))}}function df(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function ff(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var hf=de(gs.div),bt=he((t,e)=>{var n,r;const o=qn("Tooltip",t),s=Ze(t),i=vs(),{children:a,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:p,portalProps:h,background:v,backgroundColor:f,bgColor:y,motionProps:m,...g}=s,_=(r=(n=v??f)!=null?n:p)!=null?r:y;if(_){o.bg=_;const $=ql(i,"colors",_);o[Pe.arrowBg.var]=$}const k=cf({...g,direction:i.direction}),C=typeof a=="string"||u;let j;if(C)j=x.jsx(de.span,{display:"inline-block",tabIndex:0,...k.getTriggerProps(),children:a});else{const $=A.Children.only(a);j=A.cloneElement($,k.getTriggerProps($.props,$.ref))}const E=!!c,N=k.getTooltipProps({},e),I=E?df(N,["role","id"]):N,F=ff(N,["role","id"]);return l?x.jsxs(x.Fragment,{children:[j,x.jsx(Gl,{children:k.isOpen&&x.jsx(Ma,{...h,children:x.jsx(de.div,{...k.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:x.jsxs(hf,{variants:lf,initial:"exit",animate:"enter",exit:"exit",...m,...I,__css:o,children:[l,E&&x.jsx(de.span,{srOnly:!0,...F,children:c}),d&&x.jsx(de.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:x.jsx(de.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):x.jsx(x.Fragment,{children:a})});bt.displayName="Tooltip";let or;const pf=new Uint8Array(16);function mf(){if(!or&&(or=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!or))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return or(pf)}const Re=[];for(let t=0;t<256;++t)Re.push((t+256).toString(16).slice(1));function yf(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 vf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),va={randomUUID:vf};function zn(t,e,n){if(va.randomUUID&&!e&&!t)return va.randomUUID();t=t||{};const r=t.random||(t.rng||mf)();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 yf(r)}async function gf(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 wf(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 bf(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 Bi(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 tm(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 nm(){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 _f(){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 xf(){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 rm(){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 om(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 sm(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 kf="backup",jr="workspace";let sr=null;function Ef(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(jr)||o.createObjectStore(jr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Cf(){try{return sr==null&&(sr=await Ef()),new Promise((t,e)=>{if(sr==null)return e("indexDB is null");const o=sr.transaction([jr],"readonly").objectStore(jr).get(kf);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 Sf(){try{return await Cf()}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,ze=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 Ln=Object.getPrototypeOf,Of={}.hasOwnProperty;function Je(t,e){return Of.call(t,e)}function pn(t,e){typeof e=="function"&&(e=e(Ln(t))),(typeof Reflect>"u"?Ae:Reflect.ownKeys)(e).forEach(n=>{_t(t,n,e[n])})}const Mi=Object.defineProperty;function _t(t,e,n,r){Mi(t,e,Ue(n&&Je(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function an(t){return{from:function(e){return t.prototype=Object.create(e.prototype),_t(t.prototype,"constructor",t),{extend:pn.bind(null,t.prototype)}}}}const If=Object.getOwnPropertyDescriptor;function Ts(t,e){let n;return If(t,e)||(n=Ln(t))&&Ts(n,e)}const Df=[].slice;function Pr(t,e,n){return Df.call(t,e,n)}function zi(t,e){return e(t)}function Sn(t){if(!t)throw new Error("Assertion Failed")}function Li(t){Ce.setImmediate?setImmediate(t):setTimeout(t,0)}function Wi(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function xt(t,e){if(Je(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]),Pf=$i.map(t=>Ce[t]);Wi($i,t=>[t,!0]);let Ot=null;function Yn(t){Ot=typeof WeakMap<"u"&&new WeakMap;const e=Bo(t);return Ot=null,e}function Bo(t){if(!t||typeof t!="object")return t;let e=Ot&&Ot.get(t);if(e)return e;if(ze(t)){e=[],Ot&&Ot.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Ln(t);for(var o in e=s===Object.prototype?{}:Object.create(s),Ot&&Ot.set(t,e),t)Je(t,o)&&(e[o]=Bo(t[o]))}return e}const{toString:Af}={};function Mo(t){return Af.call(t).slice(8,-1)}const zo=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Nf=typeof zo=="symbol"?function(t){var e;return t!=null&&(e=t[zo])&&e.apply(t)}:function(){return null},rn={};function vt(t){var e,n,r,o;if(arguments.length===1){if(ze(t))return t.slice();if(this===rn&&typeof t=="string")return[t];if(o=Nf(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 Bs=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var dt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Vi(t,e){dt=t,Hi=e}var Hi=()=>!0;const Ff=!new Error("").stack;function Yt(){if(Ff)try{throw Yt.arguments,new Error}catch(t){return t}return new Error}function Lo(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(Hi).map(r=>` -`+r).join("")):""}var qi=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ms=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(qi),Rf={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 ln(t,e){this._e=Yt(),this.name=t,this.message=e}function Gi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function Ar(t,e,n,r){this._e=Yt(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Gi(t,e)}function Pn(t,e){this._e=Yt(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Gi(t,e)}an(ln).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Lo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),an(Ar).from(ln),an(Pn).from(ln);var zs=Ms.reduce((t,e)=>(t[e]=e+"Error",t),{});const Tf=ln;var ue=Ms.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Yt(),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=Rf[e]||n,this.inner=null)}return an(r).from(Tf),t[e]=r,t},{});ue.Syntax=SyntaxError,ue.Type=TypeError,ue.Range=RangeError;var ga=qi.reduce((t,e)=>(t[e+"Error"]=ue[e],t),{}),yr=Ms.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=ue[e]),t),{});function xe(){}function Wn(t){return t}function Bf(t,e){return t==null||t===Wn?e:function(n){return e(t(n))}}function Jt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Mf(t,e){return t===xe?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?Jt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Jt(o,this.onerror):o),s!==void 0?s:n}}function zf(t,e){return t===xe?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?Jt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Jt(r,this.onerror):r)}}function Lf(t,e){return t===xe?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?Jt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Jt(s,this.onerror):s),r===void 0?i===void 0?void 0:i:Ue(r,i)}}function Wf(t,e){return t===xe?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ls(t,e){return t===xe?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)}}yr.ModifyError=Ar,yr.DexieError=ln,yr.BulkError=Pn;var Un={};const Ji=100,[Wo,Nr,Uo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Ln(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Ln(e),t]})(),Zi=Nr&&Nr.then,vr=Wo&&Wo.constructor,Ws=!!Uo;var Ko=!1,Uf=Uo?()=>{Uo.then(ar)}:Ce.setImmediate?setImmediate.bind(null,ar):Ce.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{ar(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(ar,0)},An=function(t,e){On.push([t,e]),Fr&&(Uf(),Fr=!1)},$o=!0,Fr=!0,Kt=[],gr=[],Vo=null,Ho=Wn,cn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:_a,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{_a(t[0],t[1])}catch{}})}},ie=cn,On=[],$t=0,wr=[];function oe(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=xe,this._lib=!1;var e=this._PSD=ie;if(dt&&(this._stackHolder=Yt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Un)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Go(this,this._value))}this._state=null,this._value=null,++e.ref,Xi(this,t)}const qo={get:function(){var t=ie,e=Rr;function n(r,o){var s=!t.global&&(t!==ie||e!==Rr);const i=s&&!Et();var a=new oe((l,u)=>{Us(this,new Yi(Tr(r,t,s,i),Tr(o,t,s,i),l,u,t))});return dt&&tl(a,this),a}return n.prototype=Un,n},set:function(t){_t(this,"then",t&&t.prototype===Un?qo:{get:function(){return t},set:qo.set})}};function Yi(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 Xi(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&&Xn();n&&typeof n.then=="function"?Xi(t,(o,s)=>{n instanceof oe?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,Qi(t)),r&&Qn()}},Go.bind(null,t))}catch(n){Go(t,n)}}function Go(t,e){if(gr.push(e),t._state===null){var n=t._lib&&Xn();e=Ho(e),t._state=!1,t._value=e,dt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(i){o&&o(i)}}(()=>{var r=Ts(e,"stack");e._promise=t,_t(e,"stack",{get:()=>Ko?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Kt.some(o=>o._value===r._value)||Kt.push(r)}(t),Qi(t),n&&Qn()}}function Qi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--$t==0&&Ks()},[]))}function Us(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,++$t,An(Kf,[n,t,e])}else t._listeners.push(e)}function Kf(t,e,n){try{Vo=e;var r,o=e._value;e._state?r=t(o):(gr.length&&(gr=[]),r=t(o),gr.indexOf(o)===-1&&function(s){for(var i=Kt.length;i;)if(Kt[--i]._value===s._value)return void Kt.splice(i,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Vo=null,--$t==0&&Ks(),--n.psd.ref||n.psd.finalize()}}function el(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=Lo(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+r)}return dt&&((r=Lo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&el(t._prev,e,n)),e}function tl(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function ar(){Xn()&&Qn()}function Xn(){var t=$o;return $o=!1,Fr=!1,t}function Qn(){var t,e,n;do for(;On.length>0;)for(t=On,On=[],n=t.length,e=0;e0);$o=!0,Fr=!0}function Ks(){var t=Kt;Kt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=wr.slice(0),n=e.length;n;)e[--n]()}function ir(t){return new oe(Un,!1,t)}function Se(t,e){var n=ie;return function(){var r=Xn(),o=ie;try{return At(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{At(o,!1),r&&Qn()}}}pn(oe.prototype,{then:qo,_then:function(t,e){Us(this,new Yi(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):ir(r)):this.then(null,r=>r&&r.name===e?n(r):ir(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),ir(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Ko=!0;var t=el(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{Ko=!1}}},timeout:function(t,e){return t<1/0?new oe((n,r)=>{var o=setTimeout(()=>r(new ue.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&_t(oe.prototype,Symbol.toStringTag,"Dexie.Promise"),cn.env=nl(),pn(oe,{all:function(){var t=vt.apply(null,arguments).map(lr);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(Un,!0,t);return tl(e,Vo),e},reject:ir,race:function(){var t=vt.apply(null,arguments).map(lr);return new oe((e,n)=>{t.map(r=>oe.resolve(r).then(e,n))})},PSD:{get:()=>ie,set:t=>ie=t},totalEchoes:{get:()=>Rr},newPSD:Pt,usePSD:bn,scheduler:{get:()=>An,set:t=>{An=t}},rejectionMapper:{get:()=>Ho,set:t=>{Ho=t}},follow:(t,e)=>new oe((n,r)=>Pt((o,s)=>{var i=ie;i.unhandleds=[],i.onunhandled=s,i.finalize=Jt(function(){(function(a){function l(){a(),wr.splice(wr.indexOf(l),1)}wr.push(l),++$t,An(()=>{--$t==0&&Ks()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},i.finalize),t()},e,n,r))}),vr&&(vr.allSettled&&_t(oe,"allSettled",function(){const t=vt.apply(null,arguments).map(lr);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)))})}),vr.any&&typeof AggregateError<"u"&&_t(oe,"any",function(){const t=vt.apply(null,arguments).map(lr);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 Me={awaits:0,echoes:0,id:0};var $f=0,br=[],yo=0,Rr=0,Vf=0;function Pt(t,e,n,r){var o=ie,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Vf;var i=cn.env;s.env=Ws?{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:wa(i.nthen,s),gthen:wa(i.gthen,s)}:{},e&&Ue(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=bn(s,t,n,r);return s.ref===0&&s.finalize(),a}function wn(){return Me.id||(Me.id=++$f),++Me.awaits,Me.echoes+=Ji,Me.id}function Et(){return!!Me.awaits&&(--Me.awaits==0&&(Me.id=0),Me.echoes=Me.awaits*Ji,!0)}function lr(t){return Me.echoes&&t&&t.constructor===vr?(wn(),t.then(e=>(Et(),e),e=>(Et(),Fe(e)))):t}function Hf(t){++Rr,Me.echoes&&--Me.echoes!=0||(Me.echoes=Me.id=0),br.push(ie),At(t,!0)}function qf(){var t=br[br.length-1];br.pop(),At(t,!1)}function At(t,e){var n=ie;if((e?!Me.echoes||yo++&&t===ie:!yo||--yo&&t===ie)||rl(e?Hf.bind(null,t):qf),t!==ie&&(ie=t,n===cn&&(cn.env=nl()),Ws)){var r=cn.env.Promise,o=t.env;Nr.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 nl(){var t=Ce.Promise;return Ws?{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:Nr.then,gthen:t.prototype.then}:{}}function bn(t,e,n,r,o){var s=ie;try{return At(t,!0),e(n,r,o)}finally{At(s,!1)}}function rl(t){Zi.call(Wo,t)}function Tr(t,e,n,r){return typeof t!="function"?t:function(){var o=ie;n&&wn(),At(e,!0);try{return t.apply(this,arguments)}finally{At(o,!1),r&&rl(Et)}}}function wa(t,e){return function(n,r){return t.call(this,Tr(n,e),Tr(r,e))}}(""+Zi).indexOf("[native code]")===-1&&(wn=Et=xe);const ba="unhandledrejection";function _a(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(ba,!0,!0),Ue(r,o)):Ce.CustomEvent&&Ue(r=new CustomEvent(ba,{detail:o}),o),r&&Ce.dispatchEvent&&(dispatchEvent(r),!Ce.PromiseRejectionEvent&&Ce.onunhandledrejection))try{Ce.onunhandledrejection(r)}catch{}dt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Fe=oe.reject;function Jo(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===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Jo(t,e,n,r))):Fe(s)}return o._promise(e,(s,i)=>Pt(()=>(ie.trans=o,r(s,i,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Fe(new ue.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Fe(new ue.DatabaseClosed);t.open().catch(xe)}return t._state.dbReadyPromise.then(()=>Jo(t,e,n,r))}const xa="3.2.4",zt="￿",Zo=-1/0,ht="Invalid key provided. Keys must be of type string, number, Date or Array.",ol="String expected.",Nn=[],so=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Gf=so,Jf=so,sl=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),ao="__dbnames",vo="readonly",go="readwrite";function Zt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const al={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cr(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Yn(e))[t],e)}class Zf{_trans(e,n,r){const o=this._tx||ie.trans,s=this.name;function i(l,u,c){if(!c.schema[s])throw new ue.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const a=Xn();try{return o&&o.db===this.db?o===ie.trans?o._promise(e,i,r):Pt(()=>o._promise(e,i,r),{trans:o,transless:ie.transless||ie}):Jo(this.db,e,[this.name],i)}finally{a&&Qn()}}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(ze(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(u=>u.compound&&n.every(c=>u.keyPath.indexOf(c)>=0)&&u.keyPath.every(c=>n.indexOf(c)>=0))[0];if(r&&this.db._maxKey!==zt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&dt&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function i(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[a,l]=n.reduce(([u,c],d)=>{const p=o[d],h=e[d];return[u||p,u||!p?Zt(c,p&&p.multi?v=>{const f=xt(v,d);return ze(f)&&f.some(y=>i(h,y))}:v=>i(h,xt(v,d))):c]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):r?this.filter(l):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ze(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(Je(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=cr(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{st(e,o,i)}catch{}return i})}update(e,n){if(typeof e!="object"||ze(e))return this.where(":id").equals(e).modify(n);{const r=xt(e,this.schema.primKey.keyPath);if(r===void 0)return Fe(new ue.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Ae(n).forEach(o=>{st(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=cr(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{st(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:al})).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 ue.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ue.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(cr(l)):e;return this.core.mutate({trans:i,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new Pn(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,v)})})}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 ue.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new ue.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&a?e.map(cr(l)):e;return this.core.mutate({trans:i,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:v})=>{if(d===0)return s?p:h;throw new Pn(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,v)})})}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 Pn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function Fn(t){var e={},n=function(i,a){if(a){for(var l=arguments.length,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[i].subscribe.apply(null,u),t}if(typeof i=="string")return e[i]};n.addEventType=s;for(var r=1,o=arguments.length;rZt(r(),e()):e,t.justLimit=n&&!r}function _r(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new ue.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function ka(t,e,n){const r=_r(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 ur(t,e,n,r){const o=t.replayFilter?Zt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},i=(a,l,u)=>{if(!o||o(l,u,p=>l.stop(p),p=>l.fail(p))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Je(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(i,n),Ea(ka(t,r,n),t.algorithm,i,!t.keysOnly&&t.valueMapper)])}return Ea(ka(t,r,n),Zt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function Ea(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=xe},a=>{s.fail(a),i=xe})||o(s.value,s,a=>i=a),i()})})}function We(t,e){try{const n=Ca(t),r=Ca(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:tur(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(tn(r,!0))return o.count({trans:n,query:{index:_r(r,o.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var s=0;return ur(r,()=>(++s,!1),n,o).then(()=>s)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],s=r.length-1;function i(u,c){return c?i(u[r[c]],c-1):u[o]}var a=this._ctx.dir==="next"?1:-1;function l(u,c){var d=i(u,s),p=i(c,s);return dp?a:0}return this.toArray(function(u){return u.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&tn(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=_r(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 ur(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,tn(n)?bo(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):bo(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),bo(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return wo(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 wo(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Zt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&tn(n,!0)&&n.limit>0)return this._read(o=>{var s=_r(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 wo(this._ctx,function(o){var s=o.primaryKey.toString(),i=Je(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:g}=y;p+=f-g;for(let _ of Ae(m))d.push(m[_])};return this.clone().primaryKeys().then(f=>{const y=m=>{const g=Math.min(c,f.length-m);return a.getMany({trans:r,keys:f.slice(m,m+g),cache:"immutable"}).then(_=>{const k=[],C=[],j=l?[]:null,E=[];for(let I=0;I0&&a.mutate({trans:r,type:"add",values:k}).then(I=>{for(let F in I.failures)E.splice(parseInt(F),1);v(k.length,I)})).then(()=>(C.length>0||N&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:j,values:C,criteria:N,changeSpec:typeof e!="function"&&e}).then(I=>v(C.length,I))).then(()=>(E.length>0||N&&e===_o)&&a.mutate({trans:r,type:"delete",keys:E,criteria:N}).then(I=>v(E.length,I))).then(()=>f.length>m+g&&y(m+c))})};return y(0).then(()=>{if(d.length>0)throw new Ar("Error modifying one or more objects",d,p,h);return f.length})})})}delete(){var e=this._ctx,n=e.range;return tn(e)&&(e.isPrimKey&&!Jf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,s=n;return e.table.core.count({trans:r,query:{index:o,range:s}}).then(i=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:u,numFailures:c})=>{if(c)throw new Ar("Could not delete some values",Object.keys(a).map(d=>a[d]),i-c);return i-c}))}):this.modify(_o)}}const _o=(t,e)=>e.value=null;function Xf(t,e){return te?-1:t===e?0:1}function Ve(t,e,n){var r=t instanceof ll?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function nn(t){return new t.Collection(t,()=>il("")).limit(0)}function eh(t,e,n,r,o,s){for(var i=Math.min(t.length,r.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+n.substr(a+1):null;o(t[l],u)<0&&(a=l)}return itypeof f=="string"))return Ve(t,ol);function p(f){o=function(m){return m==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(f),s=function(m){return m==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(f),i=f==="next"?Xf:Qf;var y=n.map(function(m){return{lower:s(m),upper:o(m)}}).sort(function(m,g){return i(m.lower,g.lower)});a=y.map(function(m){return m.upper}),l=y.map(function(m){return m.lower}),u=f,c=f==="next"?"":r}p("next");var h=new t.Collection(t,()=>St(a[0],l[d-1]+r));h._ondirectionchange=function(f){p(f)};var v=0;return h._addAlgorithm(function(f,y,m){var g=f.key;if(typeof g!="string")return!1;var _=s(g);if(e(_,l,v))return!0;for(var k=null,C=v;C0)&&(k=j)}return y(k!==null?function(){f.continue(k+c)}:m),!1}),h}function St(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function il(t){return{type:1,lower:t,upper:t}}class ll{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)?nn(this):new this.Collection(this,()=>St(e,n,!r,!o))}catch{return Ve(this,ht)}}equals(e){return e==null?Ve(this,ht):new this.Collection(this,()=>il(e))}above(e){return e==null?Ve(this,ht):new this.Collection(this,()=>St(e,void 0,!0))}aboveOrEqual(e){return e==null?Ve(this,ht):new this.Collection(this,()=>St(e,void 0,!1))}below(e){return e==null?Ve(this,ht):new this.Collection(this,()=>St(void 0,e,!1,!0))}belowOrEqual(e){return e==null?Ve(this,ht):new this.Collection(this,()=>St(void 0,e))}startsWith(e){return typeof e!="string"?Ve(this,ol):this.between(e,e+zt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):dr(this,(n,r)=>n.indexOf(r[0])===0,[e],zt)}equalsIgnoreCase(e){return dr(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):dr(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=vt.apply(rn,arguments);return e.length===0?nn(this):dr(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,zt)}anyOf(){const e=vt.apply(rn,arguments);let n=this._cmp;try{e.sort(n)}catch{return Ve(this,ht)}if(e.length===0)return nn(this);const r=new this.Collection(this,()=>St(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([[Zo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=vt.apply(rn,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Ve(this,ht)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Zo,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 nn(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&o(g[0],g[1])<=0))return Ve(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ue.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function p(g,_){return d(g[0],_[0])}try{c=e.reduce(function(g,_){let k=0,C=g.length;for(;k0){j[0]=i(j[0],_[0]),j[1]=a(j[1],_[1]);break}}return k===C&&g.push(_),g},[]),c.sort(p)}catch{return Ve(this,ht)}let h=0;const v=u?g=>o(g,c[h][1])>0:g=>o(g,c[h][1])>=0,f=l?g=>s(g,c[h][0])>0:g=>s(g,c[h][0])>=0;let y=v;const m=new this.Collection(this,()=>St(c[0][0],c[c.length-1][1],!l,!u));return m._ondirectionchange=g=>{g==="next"?(y=v,d=o):(y=f,d=s),c.sort(p)},m._addAlgorithm((g,_,k)=>{for(var C=g.key;y(C);)if(++h,h===c.length)return _(k),!1;return!!function(j){return!v(j)&&!f(j)}(C)||(this._cmp(C,c[h][1])===0||this._cmp(C,c[h][0])===0||_(()=>{d===o?g.continue(c[h][0]):g.continue(c[h][1])}),!1)}),m}startsWithAnyOf(){const e=vt.apply(rn,arguments);return e.every(n=>typeof n=="string")?e.length===0?nn(this):this.inAnyRange(e.map(n=>[n,n+zt])):Ve(this,"startsWithAnyOf() only works with strings")}}function lt(t){return Se(function(e){return Kn(e),t(e.target.error),!1})}function Kn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const $n="storagemutated",It="x-storagemutated-1",Nt=Fn(null,$n);class th{_lock(){return Sn(!ie.global),++this._reculock,this._reculock!==1||ie.global||(ie.lockOwnerFor=this),this}_unlock(){if(Sn(!ie.global),--this._reculock==0)for(ie.global||(ie.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{bn(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(Sn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new ue.DatabaseClosed(r);case"MissingAPIError":throw new ue.MissingAPI(r.message,r);default:throw new ue.OpenFailed(r)}if(!this.active)throw new ue.TransactionInactive;return Sn(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=>{Kn(o),this._reject(e.error)}),e.onabort=Se(o=>{Kn(o),this.active&&this._reject(new ue.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=Se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Nt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Fe(new ue.ReadOnly("Transaction is readonly"));if(!this.active)return Fe(new ue.TransactionInactive);if(this._locked())return new oe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,i)},ie])});if(r)return Pt(()=>{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 ue.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Je(n,e))return n[e];const r=this.schema[e];if(!r)throw new ue.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 Yo(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?"++":"")+cl(e)}}function cl(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function ul(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Wi(n,r=>[r.name,r])}}let Vn=t=>{try{return t.only([[]]),Vn=()=>[[]],[[]]}catch{return Vn=()=>zt,zt}};function Xo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>xt(r,e)}(t):e=>xt(e,t)}function Oa(t){return[].slice.call(t)}let nh=0;function Rn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function rh(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:u,upper:c,lowerOpen:d,upperOpen:p}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!p):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!p)}const{schema:o,hasGetAll:s}=function(l,u){const c=Oa(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,v=ze(p),f=p==null,y={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:v,keyPath:p,autoIncrement:h,unique:!0,extractKey:Xo(p)},indexes:Oa(d.indexNames).map(g=>d.index(g)).map(g=>{const{name:_,unique:k,multiEntry:C,keyPath:j}=g,E={name:_,compound:ze(j),keyPath:j,unique:k,multiEntry:C,extractKey:Xo(j)};return y[Rn(j)]=E,E}),getIndexByKeyPath:g=>y[Rn(g)]};return y[":id"]=m.primaryKey,p!=null&&(y[Rn(p)]=m.primaryKey),m})},hasGetAll:c.length>0&&"getAll"in u.objectStore(c[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),i=o.tables.map(l=>function(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:p,keys:h,values:v,range:f}){return new Promise((y,m)=>{y=Se(y);const g=d.objectStore(c),_=g.keyPath==null,k=p==="put"||p==="add";if(!k&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:C}=h||v||{length:1};if(h&&v&&h.length!==v.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let j;const E=[],N=[];let I=0;const F=P=>{++I,Kn(P)};if(p==="deleteRange"){if(f.type===4)return y({numFailures:I,failures:N,results:[],lastResult:void 0});f.type===3?E.push(j=g.clear()):E.push(j=g.delete(r(f)))}else{const[P,B]=k?_?[v,h]:[v,null]:[h,null];if(k)for(let b=0;b{const B=P.target.result;E.forEach((b,K)=>b.error!=null&&(N[K]=b.error)),y({numFailures:I,failures:N,results:p==="delete"?h:E.map(b=>b.result),lastResult:B})};j.onerror=P=>{F(P),$(P)},j.onsuccess=$})},getMany:({trans:d,keys:p})=>new Promise((h,v)=>{h=Se(h);const f=d.objectStore(c),y=p.length,m=new Array(y);let g,_=0,k=0;const C=E=>{const N=E.target;m[N._pos]=N.result,++k===_&&h(m)},j=lt(v);for(let E=0;Enew Promise((h,v)=>{h=Se(h);const f=d.objectStore(c).get(p);f.onsuccess=y=>h(y.target.result),f.onerror=lt(v)}),query:function(d){return p=>new Promise((h,v)=>{h=Se(h);const{trans:f,values:y,limit:m,query:g}=p,_=m===1/0?void 0:m,{index:k,range:C}=g,j=f.objectStore(c),E=k.isPrimaryKey?j:j.index(k.name),N=r(C);if(m===0)return h({result:[]});if(d){const I=y?E.getAll(N,_):E.getAllKeys(N,_);I.onsuccess=F=>h({result:F.target.result}),I.onerror=lt(v)}else{let I=0;const F=y||!("openKeyCursor"in E)?E.openCursor(N):E.openKeyCursor(N),$=[];F.onsuccess=P=>{const B=F.result;return B?($.push(y?B.value:B.primaryKey),++I===m?h({result:$}):void B.continue()):h({result:$})},F.onerror=lt(v)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:v,unique:f}){return new Promise((y,m)=>{y=Se(y);const{index:g,range:_}=h,k=d.objectStore(c),C=g.isPrimaryKey?k:k.index(g.name),j=v?f?"prevunique":"prev":f?"nextunique":"next",E=p||!("openKeyCursor"in C)?C.openCursor(r(_),j):C.openKeyCursor(r(_),j);E.onerror=lt(m),E.onsuccess=Se(N=>{const I=E.result;if(!I)return void y(null);I.___id=++nh,I.done=!1;const F=I.continue.bind(I);let $=I.continuePrimaryKey;$&&($=$.bind(I));const P=I.advance.bind(I),B=()=>{throw new Error("Cursor not stopped")};I.trans=d,I.stop=I.continue=I.continuePrimaryKey=I.advance=()=>{throw new Error("Cursor not started")},I.fail=Se(m),I.next=function(){let b=1;return this.start(()=>b--?this.continue():this.stop()).then(()=>this)},I.start=b=>{const K=new Promise((O,J)=>{O=Se(O),E.onerror=lt(J),I.fail=J,I.stop=M=>{I.stop=I.continue=I.continuePrimaryKey=I.advance=B,O(M)}}),te=()=>{if(E.result)try{b()}catch(O){I.fail(O)}else I.done=!0,I.start=()=>{throw new Error("Cursor behind last entry")},I.stop()};return E.onsuccess=Se(O=>{E.onsuccess=te,te()}),I.continue=F,I.continuePrimaryKey=$,I.advance=P,te(),K},y(I)},m)})},count({query:d,trans:p}){const{index:h,range:v}=d;return new Promise((f,y)=>{const m=p.objectStore(c),g=h.isPrimaryKey?m:m.index(h.name),_=r(v),k=_?g.count(_):g.count();k.onsuccess=Se(C=>f(C.target.result)),k.onerror=lt(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:Vn(e),schema:o}}function Qo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:i,indexedDB:a},l){return{dbcore:function(c,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),c)}(rh(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 Br({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(i=>{const a=Ts(i,o);(!a||"value"in a&&a.value===void 0)&&(i===t.Transaction.prototype||i instanceof t.Transaction?_t(i,o,{get(){return this.table(o)},set(l){Mi(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):i[o]=new t.Table(o,s))})})}function es({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function oh(t,e){return t._cfg.version-e._cfg.version}function sh(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;Pt(()=>{ie.trans=s,ie.transless=a,e===0?(Ae(o).forEach(l=>{xo(n,l,o[l].primKey,o[l].indexes)}),Qo(t,n),oe.follow(()=>t.on.populate.fire(s)).catch(i)):function({_novip:l},u,c,d){const p=[],h=l._versions;let v=l._dbSchema=ns(l,l.idbdb,d),f=!1;const y=h.filter(g=>g._cfg.version>=u);function m(){return p.length?oe.resolve(p.shift()(c.idbtrans)).then(m):oe.resolve()}return y.forEach(g=>{p.push(()=>{const _=v,k=g._cfg.dbschema;rs(l,_,d),rs(l,k,d),v=l._dbSchema=k;const C=dl(_,k);C.add.forEach(E=>{xo(d,E[0],E[1].primKey,E[1].indexes)}),C.change.forEach(E=>{if(E.recreate)throw new ue.Upgrade("Not yet support for changing primary key");{const N=d.objectStore(E.name);E.add.forEach(I=>ts(N,I)),E.change.forEach(I=>{N.deleteIndex(I.name),ts(N,I)}),E.del.forEach(I=>N.deleteIndex(I))}});const j=g._cfg.contentUpgrade;if(j&&g._cfg.version>u){Qo(l,d),c._memoizedTables={},f=!0;let E=Ui(k);C.del.forEach($=>{E[$]=_[$]}),es(l,[l.Transaction.prototype]),Br(l,[l.Transaction.prototype],Ae(E),E),c.schema=E;const N=Bs(j);let I;N&&wn();const F=oe.follow(()=>{if(I=j(c),I&&N){var $=Et.bind(null,null);I.then($,$)}});return I&&typeof I.then=="function"?oe.resolve(I):F.then(()=>I)}}),p.push(_=>{(!f||!Gf)&&function(k,C){[].slice.call(C.db.objectStoreNames).forEach(j=>k[j]==null&&C.db.deleteObjectStore(j))}(g._cfg.dbschema,_),es(l,[l.Transaction.prototype]),Br(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),m().then(()=>{var g,_;_=d,Ae(g=v).forEach(k=>{_.db.objectStoreNames.contains(k)||xo(_,k,g[k].primKey,g[k].indexes)})})}(t,e,s,n).catch(i)})}function dl(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&&!so)i.recreate=!0,n.change.push(i);else{const a=o.idxByName,l=s.idxByName;let u;for(u in a)l[u]||i.del.push(u);for(u in l){const c=a[u],d=l[u];c?c.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,s])}return n}function xo(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=>ts(o,s)),o}function ts(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function ns(t,e,n){const r={};return Pr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let i=s.keyPath;const a=Yo(cl(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((i,a)=>{const l=(i=i.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Yo(l,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ze(u),a===0)}),s=o.shift();if(s.multi)throw new ue.Schema("Primary key cannot be multi-valued");o.forEach(i=>{if(i.auto)throw new ue.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new ue.Schema("Index must have a name and cannot be an empty string")}),n[r]=ul(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,es(n,[n._allTables,n,n.Transaction.prototype]),Br(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Ae(s),s),n._storeNames=Ae(s),this}upgrade(e){return this._cfg.contentUpgrade=Ls(this._cfg.contentUpgrade||xe,e),this}}function $s(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Vt(ao,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Vs(t){return t&&typeof t.databases=="function"}function os(t){return Pt(function(){return ie.letThrough=!0,t()})}function ih(){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 lh(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Fe(e.dbOpenError):t);dt&&(e.openCanceller._stackHolder=Yt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new ue.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,i=null,a=!1;return oe.race([r,(typeof navigator>"u"?oe.resolve():ih()).then(()=>new oe((l,u)=>{if(o(),!n)throw new ue.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new ue.MissingAPI;d.onerror=lt(u),d.onblocked=Se(t._fireOnBlocked),d.onupgradeneeded=Se(p=>{if(i=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Kn,i.abort(),d.result.close();const v=n.deleteDatabase(c);v.onsuccess=v.onerror=Se(()=>{u(new ue.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{i.onerror=lt(u);var h=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=h<1,t._novip.idbdb=d.result,sh(t,h/10,i,u)}},u),d.onsuccess=Se(()=>{i=null;const p=t._novip.idbdb=d.result,h=Pr(p.objectStoreNames);if(h.length>0)try{const f=p.transaction((v=h).length===1?v[0]:v,"readonly");e.autoSchema?function({_novip:y},m,g){y.verno=m.version/10;const _=y._dbSchema=ns(0,m,g);y._storeNames=Pr(m.objectStoreNames,0),Br(y,[y._allTables],Ae(_),_)}(t,p,f):(rs(t,t._dbSchema,f),function(y,m){const g=dl(ns(0,y.idbdb,m),y._dbSchema);return!(g.add.length||g.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.")),Qo(t,f)}catch{}var v;Nn.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){!Vs(f)&&m!==ao&&$s(f,y).put({name:m}).catch(xe)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],oe.resolve(os(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Ls,xe);return e.onReadyBeingFired=[],oe.resolve(os(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{i&&i.abort()}catch{}return r===e.openCanceller&&t._close(),Fe(l)}).finally(()=>{e.openComplete=!0,s()})}function ss(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):ze(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function ch(t,e,n){var r=arguments.length;if(r<2)throw new ue.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Ki(o),n]}function fl(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===zs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>fl(t,e,n,null,o))):Fe(d)}const l=Bs(o);let u;l&&wn();const c=oe.follow(()=>{if(u=o.call(i,i),u)if(l){var d=Et.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=ss(u))},a);return(u&&typeof u.then=="function"?oe.resolve(u).then(d=>i.active?d:Fe(new ue.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Fe(d)))})}function fr(t,e,n){const r=ze(t)?t.slice():[t];for(let o=0;o0,m={...p,isVirtual:y,keyTail:d,keyLength:f,extractKey:Xo(c),unique:!y&&p.unique};return v.push(m),m.isPrimaryKey||s.push(m),f>1&&i(f===2?c[0]:c.slice(0,f-1),d+1,p),v.sort((g,_)=>g.keyTail-_.keyTail),m}const a=i(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const c of r.indexes)i(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(p=c.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:fr(p.lower,p.lowerOpen?t.MAX_KEY:t.MIN_KEY,h),lowerOpen:!0,upper:fr(p.upper,p.upperOpen?t.MIN_KEY:t.MAX_KEY,h),upperOpen:!0})}}:c;var p,h}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:function(c){const d=o[Rn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:p,keyLength:h}=c.query.index;return p?n.openCursor(l(c)).then(v=>v&&function(f){return Object.create(f,{continue:{value:function(m){m!=null?f.continue(fr(m,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?f.continue(f.key.slice(0,h).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):f.continue()}},continuePrimaryKey:{value(m,g){f.continuePrimaryKey(fr(m,t.MAX_KEY,d),g)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const m=f.key;return h===1?m[0]:m.slice(0,h)}},value:{get:()=>f.value}})}(v)):n.openCursor(c)}}}}}};function Hs(t,e,n,r){return n=n||{},r=r||"",Ae(t).forEach(o=>{if(Je(e,o)){var s=t[o],i=e[o];if(typeof s=="object"&&typeof i=="object"&&s&&i){const a=Mo(s);a!==Mo(i)?n[r+o]=e[o]:a==="Object"?Hs(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=>{Je(t,o)||(n[r+o]=e[o])}),n}const dh={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:u}=i.table(e).hook;switch(s.type){case"add":if(l.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===xe&&u.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===xe)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(a.fire===xe)break;return i._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function c(p){const h=ie.trans,v=p.keys||function(f,y){return y.type==="delete"?y.keys:y.keys||y.values.map(f.extractKey)}(r,p);if(!v)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:v}:{...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,v).then(f=>{const y=v.map((m,g)=>{const _=f[g],k={onerror:null,onsuccess:null};if(p.type==="delete")a.fire.call(k,m,_,h);else if(p.type==="add"||_===void 0){const C=l.fire.call(k,m,p.values[g],h);m==null&&C!=null&&(m=C,p.keys[g]=m,r.outbound||st(p.values[g],r.keyPath,m))}else{const C=Hs(_,p.values[g]),j=u.fire.call(k,C,m,_,h);if(j){const E=p.values[g];Object.keys(j).forEach(N=>{Je(E,N)?E[N]=j[N]:st(E,N,j[N])})}}return k});return n.mutate(p).then(({failures:m,results:g,numFailures:_,lastResult:k})=>{for(let C=0;C(y.forEach(g=>g.onerror&&g.onerror(m)),Promise.reject(m)))})}function d(p,h,v){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:v}).then(({result:f})=>c({type:"delete",keys:f,trans:p}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):f.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=hl(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"?Yn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function qs(t){return!("from"in t)}const mt=function(t,e){if(!this){const n=new mt;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 Hn(t,e,n){const r=We(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(We(n,t.from)<0)return o?Hn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Ia(t);if(We(e,t.to)>0)return s?Hn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Ia(t);We(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),We(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&&Mr(t,o),s&&i&&Mr(t,s)}function Mr(t,e){qs(e)||function n(r,{from:o,to:s,l:i,r:a}){Hn(r,o,s),i&&n(r,i),a&&n(r,a)}(t,e)}function hh(t,e){const n=as(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=as(t);let i=s.next(o.from),a=i.value;for(;!r.done&&!i.done;){if(We(a.from,o.to)<=0&&We(a.to,o.from)>=0)return!0;We(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(i=s.next(o.from)).value}return!1}function as(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&&We(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||We(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 Ia(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=Da(i)}t.d=Da(t)}function Da({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}pn(mt.prototype,{add(t){return Mr(this,t),this},addKey(t){return Hn(this,t,t),this},addKeys(t){return t.forEach(e=>Hn(this,e,e)),this},[zo](){return as(this)}});const ph={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new mt(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:i}=s,{extractKey:a,outbound:l}=i,u={...o,mutate:p=>{const h=p.trans,v=h.mutatedParts||(h.mutatedParts={}),f=j=>{const E=`idb://${e}/${r}/${j}`;return v[E]||(v[E]=new mt)},y=f(""),m=f(":dels"),{type:g}=p;let[_,k]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const C=p.trans._cache;return o.mutate(p).then(j=>{if(ze(_)){g!=="delete"&&(_=j.results),y.addKeys(_);const E=hl(_,C);E||g==="add"||m.addKeys(_),(E||k)&&function(N,I,F,$){function P(B){const b=N(B.name||"");function K(O){return O!=null?B.extractKey(O):null}const te=O=>B.multiEntry&&ze(O)?O.forEach(J=>b.addKey(J)):b.addKey(O);(F||$).forEach((O,J)=>{const M=F&&K(F[J]),Q=$&&K($[J]);We(M,Q)!==0&&(M!=null&&te(M),Q!=null&&te(Q))})}I.indexes.forEach(P)}(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 j})}},c=({query:{index:p,range:h}})=>{var v,f;return[p,new mt((v=h.lower)!==null&&v!==void 0?v:t.MIN_KEY,(f=h.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},d={get:p=>[i,new mt(p.key)],getMany:p=>[i,new mt().addKeys(p.keys)],count:c,query:c,openCursor:c};return Ae(d).forEach(p=>{u[p]=function(h){const{subscr:v}=ie;if(v){const f=k=>{const C=`idb://${e}/${r}/${k}`;return v[C]||(v[C]=new mt)},y=f(""),m=f(":dels"),[g,_]=d[p](h);if(f(g.name||"").add(_),!g.isPrimaryKey){if(p!=="count"){const k=p==="query"&&l&&h.values&&o.query({...h,values:!1});return o[p].apply(this,arguments).then(C=>{if(p==="query"){if(l&&h.values)return k.then(({result:E})=>(y.addKeys(E),C));const j=h.values?C.result.map(a):C.result;h.values?y.addKeys(j):m.addKeys(j)}else if(p==="openCursor"){const j=C,E=h.values;return j&&Object.create(j,{key:{get:()=>(m.addKey(j.primaryKey),j.key)},primaryKey:{get(){const N=j.primaryKey;return m.addKey(N),N}},value:{get:()=>(E&&y.addKey(j.primaryKey),j.value)}})}return C})}m.add(n)}}return o[p].apply(this,arguments)}}),u}}}};class Vt{constructor(e,n){this._middlewares={},this.verno=0;const r=Vt.dependencies;this._options=n={addons:Vt.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:xe,dbReadyPromise:null,cancelOpen:xe,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=Fn(this,"populate","blocked","versionchange","close",{ready:[Ls,xe]}),this.on.ready.subscribe=zi(this.on.ready.subscribe,a=>(l,u)=>{Vt.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||oe.resolve().then(l),u&&a(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&a(l);else{a(l);const d=this;u||a(function p(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(p)})}})}),this.Collection=(i=this,Cn(Yf.prototype,function(a,l){this.db=i;let u=al,c=null;if(l)try{u=l()}catch(v){c=v}const d=a._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:c,or:d.or,valueMapper:h!==Wn?h:null}})),this.Table=function(a){return Cn(Zf.prototype,function(l,u,c){this.db=a,this._tx=c,this.name=l,this.schema=u,this.hook=a._allTables[l]?a._allTables[l].hook:Fn(null,{creating:[Mf,xe],reading:[Bf,Wn],updating:[Lf,xe],deleting:[zf,xe]})})}(this),this.Transaction=function(a){return Cn(th.prototype,function(l,u,c,d,p){this.db=a,this.mode=l,this.storeNames=u,this.schema=c,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Fn(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,v)=>{this._resolve=h,this._reject=v}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var v=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):v&&this.idbtrans&&this.idbtrans.abort(),Fe(h)})})}(this),this.Version=function(a){return Cn(ah.prototype,function(l){this.db=a,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return Cn(ll.prototype,function(l,u,c){this.db=a,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=a._deps.indexedDB;if(!d)throw new ue.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,l,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=a=>{this.on("blocked").fire(a),Nn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(a))},this.use(uh),this.use(dh),this.use(ph),this.use(fh),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new ue.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ue.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(oh),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 ue.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new ue.DatabaseClosed);this.open().catch(xe)}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 lh(this)}_close(){const e=this._state,n=Nn.indexOf(this);if(n>=0&&Nn.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 ue.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new oe((r,o)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Se(()=>{(function({indexedDB:a,IDBKeyRange:l},u){!Vs(a)&&u!==ao&&$s(a,l).delete(u).catch(xe)})(this._deps,this.name),r()}),i.onerror=lt(o),i.onblocked=this._fireOnBlocked};if(e)throw new ue.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=ch.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(u=>{var c=u instanceof this.Table?u.name:u;if(typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===vo)i=vo;else{if(e!="rw"&&e!=go)throw new ue.InvalidArgument("Invalid transaction mode: "+e);i=go}if(o){if(o.mode===vo&&i===go){if(!s)throw new ue.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new ue.SubTransaction("Table "+u+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(u){return o?o._promise(null,(c,d)=>{d(u)}):Fe(u)}const l=fl.bind(null,this,i,a,o,r);return o?o._promise(i,l,"lock"):ie.trans?bn(ie.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Je(this._allTables,e))throw new ue.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const mh=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class yh{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[mh](){return this}}function pl(t,e){return Ae(e).forEach(n=>{Mr(t[n]||(t[n]=new mt),e[n])}),t}function vh(t){let e,n=!1;const r=new yh(o=>{const s=Bs(t);let i=!1,a={},l={};const u={get closed(){return i},unsubscribe:()=>{i=!0,Nt.storagemutated.unsubscribe(h)}};o.start&&o.start(u);let c=!1,d=!1;function p(){return Ae(l).some(f=>a[f]&&hh(a[f],l[f]))}const h=f=>{pl(a,f),p()&&v()},v=()=>{if(c||i)return;a={};const f={},y=function(m){s&&wn();const g=()=>Pt(t,{subscr:m,trans:null}),_=ie.trans?bn(ie.transless,g):g();return s&&_.then(Et,Et),_}(f);d||(Nt($n,h),d=!0),c=!0,Promise.resolve(y).then(m=>{n=!0,e=m,c=!1,i||(p()?v():(a={},l=f,o.next&&o.next(m)))},m=>{c=!1,n=!1,o.error&&o.error(m),u.unsubscribe()})};return v(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let is;try{is={indexedDB:Ce.indexedDB||Ce.mozIndexedDB||Ce.webkitIndexedDB||Ce.msIndexedDB,IDBKeyRange:Ce.IDBKeyRange||Ce.webkitIDBKeyRange}}catch{is={indexedDB:null,IDBKeyRange:null}}const Mt=Vt;function xr(t){let e=gt;try{gt=!0,Nt.storagemutated.fire(t)}finally{gt=e}}pn(Mt,{...yr,delete:t=>new Mt(t,{addons:[]}).delete(),exists:t=>new Mt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Vs(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==ao)):$s(e,n).toCollection().primaryKeys()}(Mt.dependencies).then(t)}catch{return Fe(new ue.MissingAPI)}},defineClass:()=>function(t){Ue(this,t)},ignoreTransaction:t=>ie.trans?bn(ie.transless,t):t(),vip:os,async:function(t){return function(){try{var e=ss(t.apply(this,arguments));return e&&typeof e.then=="function"?e:oe.resolve(e)}catch(n){return Fe(n)}}},spawn:function(t,e,n){try{var r=ss(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:oe.resolve(r)}catch(o){return Fe(o)}},currentTransaction:{get:()=>ie.trans||null},waitFor:function(t,e){const n=oe.resolve(typeof t=="function"?Mt.ignoreTransaction(t):t).timeout(e||6e4);return ie.trans?ie.trans.waitFor(n):n},Promise:oe,debug:{get:()=>dt,set:t=>{Vi(t,t==="dexie"?()=>!0:sl)}},derive:an,extend:Ue,props:pn,override:zi,Events:Fn,on:Nt,liveQuery:vh,extendObservabilitySet:pl,getByKeyPath:xt,setByKeyPath:st,delByKeyPath:function(t,e){typeof e=="string"?st(t,e,void 0):"length"in e&&[].map.call(e,function(n){st(t,n,void 0)})},shallowClone:Ui,deepClone:Yn,getObjectDiff:Hs,cmp:We,asap:Li,minKey:Zo,addons:[],connections:Nn,errnames:zs,dependencies:is,semVer:xa,version:xa.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Mt.maxKey=Vn(Mt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Nt($n,t=>{if(!gt){let e;so?(e=document.createEvent("CustomEvent"),e.initCustomEvent(It,!0,!0,t)):e=new CustomEvent(It,{detail:t}),gt=!0,dispatchEvent(e),gt=!1}}),addEventListener(It,({detail:t})=>{gt||xr(t)}));let gt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(It);typeof t.unref=="function"&&t.unref(),Nt($n,e=>{gt||t.postMessage(e)}),t.onmessage=e=>{e.data&&xr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Nt($n,e=>{try{gt||(typeof localStorage<"u"&&localStorage.setItem(It,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:It,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===It){const n=JSON.parse(e.newValue);n&&xr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===It&&xr(e.changedParts)})}oe.rejectionMapper=function(t,e){if(!t||t instanceof ln||t instanceof TypeError||t instanceof SyntaxError||!t.name||!ga[t.name])return t;var n=new ga[t.name](e||t.message,t);return"stack"in t&&_t(n,"stack",{get:function(){return this.inner.stack}}),n},Vi(dt,sl);var gh=(t=>(t.SAVE="save",t.SAVE_AS="saveAs",t.openSpotlightSearch="openSpotlightSearch",t))(gh||{}),kr=(t=>(t.ArrowUp="ArrowUp",t.ArrowDown="ArrowDown",t.Enter="Enter",t))(kr||{}),Er=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(Er||{});const wh="comfyui_workspace_db";class bh extends Vt{constructor(){super(wh);Oe(this,"workflows");Oe(this,"changelogs");Oe(this,"media");Oe(this,"folders");Oe(this,"tags");Oe(this,"userSettings");Oe(this,"models");Oe(this,"cache");Oe(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const ce=new bh,_h="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ls=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=_h[n[t]&63];return e};class Xt{constructor(e){Oe(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await ce[this.tableName].toArray(),n={};e.forEach(r=>{r.id?n[r.id]=r:r.name?n[r.name]=r:console.error("TableBaseModel should have id or name")}),wf(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=ls()),e.createTime||(e.createTime=Date.now()),await ce[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await ce[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await ce[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await ce[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await ce[this.tableName].toArray()}async filter(e){return await ce[this.tableName].filter(e).toArray()}async batchQuery(e){return await ce[this.tableName].bulkGet(e)}async getRecords(){console.warn("[DEPRECATED] getRecords() call, should only be used for one-time backfill for indexdb",this.tableName);const e=await gf(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Sf()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await ce[this.tableName].get(e)}async delete(e){await ce[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await ce[this.tableName].where(e).equals(n).toArray()}}const xh=150,Lr=class Lr extends Xt{constructor(){super("changelogs")}static async load(){return new Lr}async listByWorkflowID(e){return await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime")}async getLastestByWorkflowID(e){return(await this.listByWorkflowID(e))[0]}async create(e){const n=await this.getLastestByWorkflowID(e.workflowID);if(n!=null&&n.json===e.json)return null;const r={id:zn(),json:e.json,workflowID:e.workflowID,createTime:Date.now(),isAutoSave:e.isAutoSave};return this.deleteLogsExceedLimit(e.workflowID),await ce.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e){const n=await ce.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),r=await(q==null?void 0:q.getSetting("maximumChangelogNumber"))??xh;if(n.length>r){const o=n.slice(r);await ce.changelogs.bulkDelete(o.map(s=>s.id)),await this.saveDiskDB()}}};Oe(Lr,"TABLE_NAME","changelogs");let cs=Lr;const am="CWM_WORKFLOWS_SORT_TYPE";var yt=(t=>(t.RECENTLY_OPENED="recentlyOpened",t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(yt||{});const im=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],kh="comfyspace_tracking",ot="workspace_info",Eh=9999999,ko="upgrade_to_2way_sync",ml=29,lm="SHORTCUT_TRIGGER_EVENT";function Cr(...t){const e=t.filter(n=>n!=="").join("/");return Ft(e)}function Ft(t){let n=t.split("/").filter(r=>r!=="").join("/").replace(/\\/g,"/");return n=n.replace(/^\/+/,""),n}function Eo(t){return Cr(t.parentFolderID??"",t.name+".json")}var Dt;(t=>{async function e({parentFolderID:a,name:l}){return Ft(`${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:Ft(a.id)})})}t.createFolder=n;async function r(a,l){const c=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:a,newParentPath:l})})).json();c.error&&alert("Failed to move folder: "+c.error)}t.moveFolder=r;async function o(a){try{return await(await 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 u=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})).json();return u.error&&console.error("Error counting files:",u.error),u.count}catch(l){console.error("Error renaming file:",l)}return null}t.genFilesCountInFolder=s;async function i(a,l){try{const c=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:a,newName:l})})).json();c.error&&alert("Failed to rename folder: "+c.error)}catch(u){console.error("Error renaming file:",u)}}t.renameFolder=i})(Dt||(Dt={}));async function In(t){const e=await Gs(t);if(e==null)return;const n=await yl(t);await(V==null?void 0:V.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[ot]={id:t.id,name:t.name},delete o.extra[kh],await bf(e,JSON.stringify(o))}async function Co(t){if(t.name==null)return;const e=await Gs(t);e!=null&&Bi(e)}async function Gs(t){let e=Sh(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function Ch(t){let e="",n=t;for(;n!=null;){const r=await(Le==null?void 0:Le.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function yl(t){const e=await Gs(t);let n=await(q==null?void 0:q.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function cm(t){if(await(q==null?void 0:q.getSetting("twoWaySync")))return await Dt.genFilesCountInFolder(t)??0;const n=await(V==null?void 0:V.listAll())??[],r=await(Le==null?void 0:Le.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 Sh(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function vl(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"),u=String(r.getSeconds()).padStart(2,"0"),c=`${s}-${o}-${i}`;return e?c+` ${a}:${l}`:n?c+`:${u}`:c}async function Oh(t=!1){if(await(q==null?void 0:q.getSetting("twoWaySync")))return;const n=await(V==null?void 0:V.listAll())??[];for(const r of n){const o=await yl(r);r.filePath!=o&&(r.filePath!=null&&await Bi(r.filePath,t),await In(r))}}const us=(t,e=yt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case yt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case yt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case yt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case yt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break;case yt.RECENTLY_OPENED:n.sort((r,o)=>(o.lastOpenedTime??0)-(r.lastOpenedTime??0));break}return n};function Ih(t){const e=t.nodes,n=new Array,r=new Map,o=new Array;for(let s=0;s{var n;const e=(n=q==null?void 0:q.settings)==null?void 0:n.shortcuts;if(!e)return!1;Object.assign(e,{[kr.ArrowDown]:"ARROWDOWN",[kr.ArrowUp]:"ARROWUP",[kr.Enter]:"ENTER"});for(const r in e){const s=e[r].split("+"),i={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};for(const a in i)i[a]||delete i[a];if(s.length===Object.keys(i).length&&s.every(a=>i[a]))return r}};function fm(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function Dh(t){return`/workspace/view_media?filename=${t}`}function ja(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function gl(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 jh=t=>{const e=gl(t);window.open(`${window.location.origin}/#${e}`)},Sr={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 Xe;(t=>{async function e(l,u){try{const d=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),newParentPath:u})})).json();return d.error?(alert("Error moving file: "+d.error),!1):!0}catch(c){console.error("Error deleting file:",c)}}t.moveWorkflow=e;async function n(l,u){try{const d=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Cr(u??"",l)})})).json();return d.error?(console.error("Error getting unique name:",d.error),null):d.uniqueName}catch(c){console.error("Error deleting file:",c)}return null}t.genFileUniqueName=n;async function r({parentFolderID:l,name:u},c){try{const p=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Cr(l??"",u+".json"),newName:c})})).json();return p.error?(alert("Error rename file: "+p.error),!1):!0}catch(d){console.error("Error deleting file:",d)}}t.renameWorkflow=r;async function o(l){const u=l.json,c=JSON.parse(u);c.extra[ot]==null&&(c.extra[ot]={}),c.extra[ot].id=l.id;const p=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Eo(l),json:JSON.stringify(c)})})).json();if(p.error)throw console.error("Error saving file:",p.error),alert(`"Error saving file: ${p.error} - - 👉Please try "Save as" from "Files" dropdown menu - `),new Error(p.error);return p}t.saveWorkflow=o;async function s(l){try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:Eo(l),deleteEmptyFolder:!1})})).text()}catch(u){alert("Error deleting workflow .json file: "+u),console.error("Error deleting file:",u)}}t.deleteWorkflow=s;async function i({parentFolderID:l,name:u,json:c,id:d}){var v;let p=JSON.parse(c);p={...p,extra:{[ot]:{id:d}}};const h={parentFolderPath:Ft(l??""),name:u,json:JSON.stringify(p)};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((v=ce.workflows)==null?void 0:v.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:u,id:c}){const d=Cr(l??"",u+".json");try{const h=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,id:c})})).json();return h.error&&(console.error(`Error getting file <${c}> at "${d}"`,h.error),alert({message:`Error getting file <${c}> at "${d}"`,level:"error"})),h}catch(p){return console.error(`Erro finding file <${c}> at "${d}"`,p),{}}}t.getFile=a})(Xe||(Xe={}));async function Js(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:Ft(t),recursive:e,metaInfoOnly:n})})).json()}catch(r){return console.error("Error scan local new files:",r),[]}}async function Ph(t,e){const n=Ft(t??""),o=(await Js(n)).map(async a=>{var c;const l=a.name,u=[n,l].join("/");return Ah(a)?{id:Ft(u),name:a.name,parentFolderID:n,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((c=ce.workflows)==null?void 0:c.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);ce.workflows.bulkPut(s.filter(a=>!Wh(a)));const i=s.filter(a=>a!=null);return us(i,e??yt.RECENTLY_MODIFIED)}function Ah(t){return"type"in t&&t.type==="folder"}const Wr=class Wr extends Xt{constructor(){super("workflows");Oe(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Wr}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await ce.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async listByIndex(n,r){const o=await super.listByIndex(n,r);return await(q==null?void 0:q.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(q==null?void 0:q.getSetting("twoWaySync"))){const l=await Xe.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(a.includes(s)){let l=2,u=!0;for(;u;)a.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,u=!1)}return s}async createFlow(n){const{name:r}=n,o=await this.generateUniqueName(r,n.parentFolderID??void 0),s=Date.now(),i={...n,id:n.id??ls(),json:n.json??JSON.stringify(Sr),name:o,updateTime:n.updateTime??s,createTime:n.createTime??s};return await ce.workflows.add(i),this.saveDiskDB(),await(q==null?void 0:q.getSetting("twoWaySync"))?(await Xe.createWorkflow(i),await this.get(i.id)):(In(i),i)}async update(n,r){throw new Error("Method not allowed.")}async updateTopFields(n,r){return this._update(n,r)}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await ce.workflows.update(n,r);const o=await ce.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var a;const o=await(q==null?void 0:q.getSetting("twoWaySync")),s=await this.get(n),i=await this.updateMetaInfo(n,r);!i||!s||(o?await Xe.moveWorkflow(s,r.parentFolderID):(await In(i),await Co(s),(i==null?void 0:i.parentFolderID)!=null&&await((a=ce.folders)==null?void 0:a.update(i.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(qe==null?void 0:qe.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(q==null?void 0:q.getSetting("twoWaySync"))&&o&&await Xe.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(q==null?void 0:q.getSetting("twoWaySync"))?a&&await Xe.saveWorkflow(a):a&&await In(a)}async batchCreateFlows(n=[],r=!1,o){var i,a;const s=[];for(const l of n){const u=l.name&&r?l.name:await this.generateUniqueName(l.name,o),c=ls(),d=Date.now(),p={id:c,name:u,json:l.json,parentFolderID:o,updateTime:d,createTime:d,tags:[]};if(s.push(p),await(q==null?void 0:q.getSetting("twoWaySync")))try{const v=JSON.parse(l.json),f=(a=(i=v==null?void 0:v.extra)==null?void 0:i[ot])==null?void 0:a.id;f&&(await this.get(f)||(p.id=f)),Xe.createWorkflow(p)}catch(v){console.error("batchCreateFlows error",v)}else await In(p)}try{await ce.workflows.bulkAdd(s),this.saveDiskDB()}catch(l){console.error("batchCreateFlows error",l)}}async deleteFlow(n){const r=await this.get(n);r&&(await(q==null?void 0:q.getSetting("twoWaySync"))?await Xe.deleteWorkflow(r):Co({...r})),await ce.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await ce.workflows.bulkGet(n);for(const o of r){if(!o)return;await(q==null?void 0:q.getSetting("twoWaySync"))?await Xe.deleteWorkflow(o):Co({...o})}await ce.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(q==null?void 0:q.getSetting("twoWaySync")))return await Ph(n??null);const s=await this.listAll().then(l=>l.filter(u=>u.parentFolderID==n))??[],i=await(Le==null?void 0:Le.listAll().then(l=>l.filter(u=>u.parentFolderID==n)))??[],a=[...s,...i];return us(a,r??yt.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(q==null?void 0:q.getSetting("twoWaySync")),s=await ce.workflows.get(n);if(!o||!r)return s;if(s==null)return;const i=await Xe.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(i.json)return{...s,json:JSON.stringify(i.json)}}async listAll(n){const r=await(q==null?void 0:q.getSetting("twoWaySync"));let o;if(r){const i=(await Js("",!0)).filter(a=>(a==null?void 0:a.type)==="workflow").map(async a=>{const l=await ce.workflows.get(a.id);return a.updateTime=(l==null?void 0:l.updateTime)??Date.now(),l!=null&&l.lastOpenedTime&&(a.lastOpenedTime=l==null?void 0:l.lastOpenedTime),a});o=await Promise.all(i)}else o=await ce.workflows.toArray();return n?us(o,n):o}async updateLastOpenedTime(n){await ce.workflows.update(n,{lastOpenedTime:Date.now()})}};Oe(Wr,"TABLE_NAME","workflows");let ds=Wr;const Ur=class Ur extends Xt{constructor(){super("folders")}static async load(){return new Ur}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(q==null?void 0:q.getSetting("twoWaySync")),o=await Dt.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:zn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await Dt.createFolder(s):(await ce.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(q==null?void 0:q.getSetting("twoWaySync")))return"parentFolderID"in n&&await Dt.moveFolder(e,n.parentFolderID??""),"name"in n&&await Dt.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 ce.folders.update(e,n),this.saveDiskDB(),(s||i)&&Oh(!0),a}async deleteFolder(e,n=Er.DELETE){if(await(q==null?void 0:q.getSetting("twoWaySync"))){await Js(e,!0,!0).then(a=>{a.forEach(l=>{l.type==="workflow"&&(V==null||V.deleteFlow(l.id))})}),await Dt.deleteFolder(e);return}const o=await(V==null?void 0:V.listAll())??[],s=await this.listAll(),i=[e];for(;i.length>0;){const a=i.shift();if(a){for(const u of o)if(u.parentFolderID===a)switch(n){case Er.DELETE:await(V==null?void 0:V.deleteFlow(u.id));break;case Er.MOVE_TO_ROOT_FOLDER:await(V==null?void 0:V.updateFolder(u.id,{parentFolderID:void 0}));break}await ce.folders.delete(a);const l=s.filter(u=>u.parentFolderID===a).map(u=>u.id);l.length&&i.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(q==null?void 0:q.getSetting("twoWaySync")))return await Xe.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}};Oe(Ur,"TABLE_NAME","folders");let fs=Ur;function Nh(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]=v}a+=12+u}e(l)},r.readAsArrayBuffer(t)})}function Fh(t){const e=new Uint16Array(t.slice(0,2))[0]===18761;function n(i,a,l){const u=t.slice(i,i+l);if(l===2)return new DataView(u.buffer,u.byteOffset,u.byteLength).getUint16(0,a);if(l===4)return new DataView(u.buffer,u.byteOffset,u.byteLength).getUint32(0,a)}const r=n(4,e,4);function o(i){const a=n(i,e,2),l={};for(let u=0;u{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-c)&~(1<<7*c),p=i.decode(o.slice(a+2+c,a+2+c+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,u=i.decode(o.slice(a+12,a+12+l)),c=JSON.parse(u);e(c);return}a-=1}}else{console.error("Unknown magic: "+s.getUint32(0)),e();return}},n.readAsArrayBuffer(t)})}function Mh(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(Th(t))return Bh(o);if(e==="webp")return Rh(o);const s=await Nh(o),i=JSON.parse(s==null?void 0:s.prompt),a=JSON.parse(s==null?void 0:s.workflow);return{prompt:i,workflow:a}})}class wl extends Xt{constructor(){super("media")}async listByWorkflowID(e){return await ce.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 Mh(`/workspace/view_media?filename=${e.localPath}`).catch(s=>(console.error("get meta error:",s),{prompt:""})),o={id:zn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),workflowJSON:JSON.stringify(r==null?void 0:r.prompt),format:n};return await(V==null?void 0:V.updateMetaInfo(e.workflowID,{latestImage:o.localPath})),ce.media.add(o),this.saveDiskDB(),o}}Oe(wl,"TABLE_NAME","media");const hm=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],zh={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function pm(t){return t.modelVersions!==void 0}function Lh(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function mm(t,e){var r,o,s,i,a,l;if(!t)return;let n;return Lh(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 Kr=class Kr extends Xt{constructor(){super("userSettings");Oe(this,"defaultSettings");Oe(this,"DEFAULT_USER","guest");Oe(this,"_autoSave",!1);Oe(this,"_settings");this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S",saveAs:"Control+Alt+S",openSpotlightSearch:"Control+P"},defaultFolders:zh,autoSave:!0,autoSaveDuration:5,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.nodecafe.org",overwriteCurWorkflowWhenDroppingFileToCanvas:!1,maximumChangelogNumber:200}}get settings(){return this._settings}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return n==="shortcuts"&&(r!=null&&r.shortcuts)?{...this.defaultSettings.shortcuts,...r.shortcuts}:(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),this._settings={...this.defaultSettings,...o}}static async load(){const n=new Kr,r=await _f();return n.defaultSettings.myWorkflowsDir=r.path,await n.get(n.DEFAULT_USER).then(o=>{n._autoSave=(o==null?void 0:o.autoSave)??!0,n._settings={...n.defaultSettings,...o}}),await n.upsert({cloudHost:n.defaultSettings.cloudHost}),n}};Oe(Kr,"TABLE_NAME","userSettings");let hs=Kr;const $r=class $r extends Xt{constructor(){super("tags")}static async load(){return new $r}};Oe($r,"TABLE_NAME","tags");let ps=$r;const Vr=class Vr extends Xt{constructor(){super("workflowVersions")}static async load(){return new Vr}async listByWorkflowID(e){return await ce[this.tableName].where("workflowID").equals(e).reverse().sortBy("createTime")??[]}async getLatestByWorkflowID(e){const n=await this.listByWorkflowID(e);return n!=null&&n.length?n[0]:null}};Oe(Vr,"TABLE_NAME","workflowVersions");let ms=Vr;function Wh(t){return"type"in t&&t.type==="folder"}let V=null,Or=null,q=null,Le=null,qe=null,Ht=null,we=null;async function Uh(){const t=async()=>{V=await ds.load()},e=async()=>{Or=await ps.load()},n=async()=>{q=await hs.load()},r=async()=>{Le=await fs.load()},o=async()=>{qe=await cs.load()},s=async()=>{Ht=new wl},i=async()=>{we=await ms.load()};await Promise.all([t(),e(),n(),r(),o(),s(),i()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Kh(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Kh(){const t=async()=>{try{const a=await(V==null?void 0:V.getRecords());a&&await ce.workflows.bulkPut(Object.values(a))}catch(a){console.error(a)}},e=async()=>{try{const a=await(Le==null?void 0:Le.getRecords());a&&await ce.folders.bulkPut(Object.values(a))}catch(a){console.error(a)}},n=async()=>{try{const a=await(Ht==null?void 0:Ht.getRecords());a&&await ce.media.bulkPut(Object.values(a))}catch(a){console.error(a)}},r=async()=>{try{const a=await(qe==null?void 0:qe.getRecords());a&&await ce.changelogs.bulkPut(Object.values(a))}catch(a){console.error(a)}},o=async()=>{try{const a=await(Or==null?void 0:Or.getRecords());a&&await ce.tags.bulkPut(Object.values(a))}catch(a){console.error(a)}},s=async()=>{try{const a=q,l=await a.getRecords().then(u=>u[a.DEFAULT_USER]?u[a.DEFAULT_USER]:u);await ce.userSettings.put({...a.defaultSettings,...l})}catch(a){console.error(a)}},i=async()=>{try{const a=await(we==null?void 0:we.getRecords());a&&await ce.workflowVersions.bulkPut(Object.values(a))}catch(a){console.error(a)}};await Promise.all([t(),e(),n(),r(),o(),s(),i()])}const Ct=A.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},route:"root",curVersion:null,setIsDirty:()=>{},setCurVersion:()=>{}}),ym=A.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),So={x:0,y:0};function $h({children:t,onDragEnd:e,dragIconId:n}){const r=A.useRef(So),o=A.useRef(!1),[s,i]=A.useState(So),a=d=>{var p,h,v;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(p=d.target)==null?void 0:p.id,(v=(h=d.target)==null?void 0:h.parentNode)==null?void 0:v.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const f=document.getElementsByTagName("body")[0];f.style.userSelect="none"}},l=A.useCallback(d=>{const p={x:d.clientX-r.current.x,y:d.clientY-r.current.y};i(p)},[]),u=A.useCallback(()=>{i(p=>(setTimeout(()=>{e(p)},0),So)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",u)},[e,l]),c={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return x.jsx("div",{style:c,onMouseDown:a,children:t})}var Vh={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"},Hh=Object.defineProperty,qh=Object.defineProperties,Gh=Object.getOwnPropertyDescriptors,zr=Object.getOwnPropertySymbols,bl=Object.prototype.hasOwnProperty,_l=Object.prototype.propertyIsEnumerable,Pa=(t,e,n)=>e in t?Hh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Aa=(t,e)=>{for(var n in e||(e={}))bl.call(e,n)&&Pa(t,n,e[n]);if(zr)for(var n of zr(e))_l.call(e,n)&&Pa(t,n,e[n]);return t},Jh=(t,e)=>qh(t,Gh(e)),Zh=(t,e)=>{var n={};for(var r in t)bl.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&zr)for(var r of zr(t))e.indexOf(r)<0&&_l.call(t,r)&&(n[r]=t[r]);return n},Ne=(t,e,n)=>{const r=A.forwardRef((o,s)=>{var i=o,{color:a="currentColor",size:l=24,stroke:u=2,children:c}=i,d=Zh(i,["color","size","stroke","children"]);return A.createElement("svg",Aa(Jh(Aa({ref:s},Vh),{width:l,height:l,stroke:a,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([p,h])=>A.createElement(p,h)),...c||[]])});return r.propTypes={color:Bt.string,size:Bt.oneOfType([Bt.string,Bt.number]),stroke:Bt.oneOfType([Bt.string,Bt.number])},r.displayName=`${e}`,r},Yh=Ne("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"}]]),Xh=Ne("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),ys=Ne("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"}]]),Na=Ne("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"}]]),xl=Ne("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"}]]),Qh=Ne("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"}]]),ep=Ne("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"}]]),tp=Ne("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"}]]),np=Ne("info-circle","IconInfoCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]]),rp=Ne("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"}]]),kl=Ne("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"}]]),op=Ne("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"}]]),sp=Ne("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),ap=Ne("refresh","IconRefresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]),ip=Ne("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"}]]),lp=Ne("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"}]]),El=Ne("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"}]]),cp=Ne("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"}]]),up=Ne("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"}]]),dp=Ne("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function fp(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return x.jsx(Ei,{isLazy:!0,placement:"auto",children:({onClose:i})=>x.jsxs(x.Fragment,{children:[x.jsx(ki,{children:x.jsx(jt,{children:x.jsx(bt,{hasArrow:!0,label:s,placement:"bottom",children:x.jsx(Tn,{"aria-label":"Delete confirm",size:"sm",icon:x.jsx(lp,{color:"#F56565"}),isDisabled:o,variant:n})})})}),x.jsxs(Di,{children:[x.jsx(Ci,{}),x.jsx(Oi,{onClick:i}),x.jsxs(Si,{children:[x.jsx(wt,{mb:4,pr:4,fontWeight:600,children:e}),x.jsx(Te,{colorScheme:"red",size:"sm",onClick:()=>{r(),i()},children:"Yes, delete"})]})]})]})})}function hp({onClose:t}){Ka();const{curFlowID:e,isDirty:n,loadWorkflowID:r,curVersion:o}=A.useContext(Ct),[s,i]=A.useState(0),[a,l]=A.useState(null),[u,c]=A.useState([]),[d,p]=A.useState([]),h=async y=>{var C;const m=await(V==null?void 0:V.get(y)),g=await(qe==null?void 0:qe.listByWorkflowID(y));c(g??[]);const _=g==null?void 0:g.filter(j=>j.json===(m==null?void 0:m.json)),k=(C=_==null?void 0:_[0])==null?void 0:C.id;k&&l(k)},v=async()=>{const y=await(we==null?void 0:we.listByWorkflowID(e))??[];p(y)},f=y=>{we==null||we.delete(y).then(()=>{v()})};return A.useEffect(()=>{switch(s){case 0:v();break;case 1:h(e);break}},[s]),A.useEffect(()=>(_e.canvasEl.addEventListener("click",t),()=>{_e.canvasEl.removeEventListener("click",t)}),[s]),x.jsxs(pc,{width:430,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[x.jsx(hc,{pb:1,mb:0,children:x.jsxs(Wt,{justifyContent:"space-between",alignItems:"center",children:[x.jsx(sn,{size:"md",children:"Version History"}),x.jsx(Tn,{size:"sm",icon:x.jsx(dp,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),x.jsx(fc,{overflowY:"auto",gap:0,children:x.jsxs(Ai,{isFitted:!0,variant:"enclosed",onChange:i,colorScheme:"teal",children:[x.jsxs(Ni,{mb:"1em",children:[x.jsx(Ro,{children:"Versions"}),x.jsx(Ro,{children:"Change History"})]}),x.jsxs(Fi,{children:[x.jsx(Fo,{children:x.jsx(He,{divider:x.jsx(jo,{}),spacing:2,children:d==null?void 0:d.map(y=>x.jsxs(Wt,{w:"100%",mb:1,justify:"space-between",backgroundColor:y.id===(o==null?void 0:o.id)?"teal.300":void 0,borderRadius:4,children:[x.jsxs(He,{textAlign:"left",gap:0,children:[x.jsx(wt,{fontWeight:"500",children:y.name??"untitled"}),x.jsxs(wt,{color:"GrayText",fontSize:"sm",children:["Created: ",vl(y.createTime)]})]}),x.jsxs(Wt,{alignItems:"center",gap:2,children:[x.jsx(Te,{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}_e.loadGraphData(JSON.parse(y.json)),r(e,y.id),t()},children:"Load"}),x.jsx(fp,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{f(y.id)}})]})]},y.id))})}),x.jsxs(Fo,{children:[x.jsx(wt,{mb:4,children:"All the saved changes of this workflow"}),x.jsx(He,{divider:x.jsx(jo,{}),spacing:2,children:u==null?void 0:u.map(y=>x.jsxs(rt,{justifyContent:"space-between",children:[x.jsxs(Te,{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}_e.loadGraphData(JSON.parse(y.json)),V==null||V.updateFlow(e,{json:y.json}),t()},isActive:y.id===a,children:["Saved at ",new Date(y.createTime).toLocaleString()]},y.id),y.isAutoSave?x.jsx(Gt,{colorScheme:"teal",size:"sm",children:"Auto save"}):null]},y.id))})]})]})]})})]})}function pp({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(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(_e.graph.serialize());await(we==null?void 0:we.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return x.jsxs(Gr,{isOpen:!0,onClose:e,children:[x.jsx(ws,{}),x.jsxs(Jr,{children:[x.jsx(bs,{children:"Create Version"}),x.jsx(_s,{}),x.jsx(Zr,{children:x.jsxs(Yr,{isInvalid:!!o,children:[x.jsx(Qr,{children:"Name"}),x.jsx(vn,{value:n,onChange:i,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&a()}}),o&&x.jsx(Xr,{children:o})]})}),x.jsxs(xs,{children:[x.jsx(Te,{colorScheme:"teal",mr:3,onClick:a,isDisabled:!n||!!o,children:"Create"}),x.jsx(Te,{onClick:e,children:"Cancel"})]})]})]})}function mp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=A.useRef(null);return zc({ref:o,handler:()=>r()}),x.jsxs(jt,{position:"relative",children:[x.jsx(jt,{children:e}),n&&x.jsx(jt,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function yp({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 x.jsx(mp,{isOpen:o,onClose:i,menuButton:x.jsx(jt,{"aria-label":"menu",onClick:a,onMouseEnter:a,onMouseLeave:i,children:t}),options:x.jsx(Fs,{isOpen:!0,children:x.jsx(Rs,{minWidth:150,zIndex:1e3,onMouseEnter:a,onMouseLeave:i,children:e})})})}const Cl="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function vm(){return localStorage.getItem(Cl)}function gm(t){localStorage.setItem(Cl,t)}function vp(t){return`https://civitai.com/api/download/models/${t}`}function gp(t,e){return e?`https://civitai.com/models/${t}?modelVersionId=${e}`:`https://civitai.com/models/${t}`}function Sl(t){return t.includes("huggingface")?t.replace("/resolve/","/blob/"):void 0}async function wm(t){var e,n;try{const r=`https://civitai.com/api/v1/model-versions/by-hash/${t}`,s=await(await fetch(r)).json();let i;if(await(q==null?void 0:q.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(e=s==null?void 0:s.images)==null?void 0:e[0])==null?void 0:n.url;else if(!s.model.nsfw){const l=s.images.find(u=>u.nsfwLevel==1);i=l==null?void 0:l.url}return{modelName:s.model.name,civitModelID:String(s.modelId),civitModelVersionID:String(s.id),imageUrl:i??void 0}}catch{return{}}}async function wp(t,e){const n=await ce.models.where("fileName").equals(t).toArray()??[],r=n.at(0);return{filename:t,nodeType:e,fileHash:(r==null?void 0:r.fileHash)??null,fileFolder:(r==null?void 0:r.fileFolder)??null,downloadUrl:r!=null&&r.civitModelVersionID?vp(r.civitModelVersionID):(r==null?void 0:r.downloadUrl)??null,length:n.length,infoUrl:r!=null&&r.civitModelID?gp(r.civitModelID,r.civitModelVersionID):Sl((r==null?void 0:r.downloadUrl)??"")??null}}async function bp(t){var u,c;let e=[],n={};const r=[".ckpt",".pt",".bin",".pth",".safetensors"],o=[".jpeg",".jpg",".png",".gif",".webp"],s=(c=(u=_e.graph.extra)==null?void 0:u[ot])==null?void 0:c.deps;t.forEach(d=>{d.widgets_values&&Array.isArray(d.widgets_values)&&d.widgets_values.forEach(p=>{var h,v;typeof p=="string"&&(r.some(f=>p.endsWith(f))&&((h=s==null?void 0:s.models)!=null&&h[p]?e.push(Promise.resolve(s.models[p])):e.push(wp(p,d.type))),o.some(f=>p.endsWith(f))&&(n[p]=((v=s==null?void 0:s.images)==null?void 0:v[p])??{filename:p,nodeType:d.type}))})});const i=await fetch("workspace/fetch_node_repos",{method:"POST",body:JSON.stringify({nodes:t.map(d=>d.type)})}).then(d=>d.ok?d.json():[]).catch(d=>(console.error("Error fetching node repos",d),[])),a=await Promise.all(e),l={};return a.forEach(d=>{l[d.filename]=d}),{models:l,images:n,nodeRepos:i}}function Ol(t,e){const n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}function _p(){const{setRoute:t,saveCurWorkflow:e}=A.useContext(Ct),[n,r]=A.useState(),[o,s]=A.useState({}),[i,a]=A.useState(!1),l=A.useCallback(async()=>{const f=_e.graph.serialize();bp(f.nodes??[]).then(y=>{r(y)})},[]),u=A.useCallback(async()=>{r(void 0),await xf(),window.addEventListener("model_list_updated",()=>{l(),window.removeEventListener("model_list_updated",()=>{})})},[]);A.useEffect(()=>{l()},[]);const c=f=>!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(f),d=A.useCallback(f=>{let y=!0;return f.forEach(m=>{const g=m.filename+m.nodeType;if(!m.downloadUrl){s(_=>({..._,[g]:"Invalid URL"})),y=!1;return}if(!c(m.downloadUrl)){s(_=>({..._,[g]:"Invalid URL"})),y=!1;return}if(!m.fileFolder){s(_=>({..._,[g]:"Model file not found, please re-scan models folder"})),y=!1;return}}),y},[]),p=async f=>{var E,N;f.preventDefault();const y=new FormData(f.target),m=Object.values((n==null?void 0:n.models)??{}).map(async I=>{var P,B;const F=(P=y.get(I.filename))==null?void 0:P.toString();if(F){const b=xp(I.filename);await ce.models.update(b+"@"+I.fileFolder,{downloadUrl:F})}const $=(B=I.infoUrl)!=null&&B.length?I.infoUrl:F?Sl(F):null;return{filename:I.filename,nodeType:I.nodeType,fileHash:I.fileHash,fileFolder:I.fileFolder,downloadUrl:I.downloadUrl??F??null,infoUrl:$??null}})??[],g=await Promise.all(m);if(!d(g))return;s({}),a(!0);const _=Object.values((n==null?void 0:n.images)??{}).filter(I=>!I.url).map(I=>I.filename),k=(n==null?void 0:n.images)??{};if(_.length){const F=await(await fetch("/workspace/upload_image",{method:"POST",body:JSON.stringify({images:_})})).json();Object.keys(F).forEach($=>{k!=null&&k[$]&&(k[$].url=F[$])})}a(!1);const C={};g.forEach(I=>{C[I.filename]=I});const j=_e.graph.serialize();(E=j.extra||(j.extra={}))[ot]||(E[ot]={}),j.extra[ot].deps={models:C,images:k??{},nodeRepos:(n==null?void 0:n.nodeRepos)??[]},e(),Ol(JSON.stringify(j,null,2),(((N=V==null?void 0:V.curWorkflow)==null?void 0:N.name)??"unknown")+".runner")},h=Object.values((n==null?void 0:n.images)??{}),v=Object.values((n==null?void 0:n.models)??[]);return x.jsx(Gr,{isOpen:!0,onClose:()=>t("root"),size:"xl",children:x.jsx(Jr,{children:x.jsxs(Zr,{p:5,gap:5,children:[x.jsxs(rt,{children:[x.jsx(sn,{size:"md",children:"Workflow Resouce Dependencies"}),x.jsx(bt,{label:`.runner.json workflows include all resource dependecy download urls - (models, cursom nodes, input images) and can be one-click - installed and run in any ComfyUI with workpace-manager installed.`,children:x.jsx(si,{borderRadius:10,children:x.jsx(np,{size:20})})})]}),x.jsx(wt,{color:"GrayText",children:"Export one-click installable workflow"}),n==null&&x.jsx(Xs,{size:"md",color:"teal.400"}),n&&x.jsx("form",{onSubmit:p,children:x.jsxs(He,{gap:5,mt:5,children:[x.jsxs(He,{children:[x.jsxs(sn,{size:"sm",children:["Models (",v.length,")"]}),v.map((f,y)=>x.jsx(kp,{modelFile:f,errors:o,onClickRefetchModelList:u},y))]}),h.length>0&&x.jsxs(He,{children:[x.jsxs(rt,{children:[x.jsxs(sn,{size:"sm",children:["Images (",h.length,")"]}),x.jsx("p",{style:{color:"GrayText"},children:"Will be uploaded as url"})]}),i&&x.jsxs("span",{children:[x.jsx(Xs,{size:"md",color:"teal.400"})," Uploading"]}),h.map(f=>x.jsxs(He,{children:[x.jsx("p",{children:f.filename}),x.jsx(qa,{width:250,src:`/workspace/view_media?filename=${f.filename}&isPreview=true&isInput=true`})]},f.filename))]}),x.jsx(Te,{width:"fit-content",colorScheme:"teal",type:"submit",mt:4,children:"Download .runner.json"})]})})]})})})}function xp(t){const e=t.split(".");return e.length>1?(e.pop(),e.join(".")):t}function kp({modelFile:t,errors:e,onClickRefetchModelList:n}){const r=t.filename;return t.fileFolder?x.jsx(He,{ml:2,children:x.jsxs(Wt,{gap:2,children:[x.jsx(Gt,{height:"fit-content",colorScheme:"teal",children:t.fileFolder}),t.downloadUrl?x.jsxs(rt,{children:[x.jsx("a",{href:t.infoUrl??t.downloadUrl,target:"_blank",children:t.filename}),x.jsx(xl,{size:18})]}):x.jsxs(He,{children:[x.jsxs("span",{children:[t.filename," ",x.jsx("span",{children:"❓"})]}),x.jsx(bt,{label:"Model download link, supports Huggingface and Civitai",children:x.jsx(vn,{name:r,size:"sm",isInvalid:e[r]!=null,placeholder:"https://civitai.com/api/download/models/324524"})}),x.jsx(wt,{color:"red.400",children:e[r]})]})]},t.filename+t.nodeType)}):x.jsxs(He,{children:[x.jsxs(Wt,{gap:2,children:[x.jsx("p",{children:t.filename}),x.jsx(Gt,{size:"sm",colorScheme:"red",children:"Model file not found"})]}),x.jsx(Te,{size:"sm",leftIcon:x.jsx(ap,{}),width:"fit-content",borderColor:"red",borderWidth:e[r]!=null?2:0,onClick:n,children:"Fetch model file"})]})}const Ep=A.lazy(()=>mn(()=>import("./ShareDialog-T1peQu-u.js"),__vite__mapDeps([0,1,2,3,4])));function Cp(){var j;const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r,setRoute:o,route:s}=A.useContext(Ct),[i,a]=A.useState(!1),[l,u]=A.useState(""),[c,d]=A.useState(""),[p,h]=A.useState(),[v,f]=A.useState({save:"",saveAs:""}),[y,m]=A.useState(!1);A.useEffect(()=>{t&&(V==null||V.get(t).then(E=>{u((E==null?void 0:E.name)??""),h(E)})),q==null||q.getSetting("shortcuts").then(E=>{f(E)})},[t]);const g=E=>{u(E.target.value),c&&d("")},_=async()=>{if(!t){alert("Flow ID is required");return}const E=JSON.stringify(_e.graph.serialize()),N=await(V==null?void 0:V.createFlow({json:E,lastSavedJson:E,name:l,parentFolderID:p==null?void 0:p.parentFolderID}));N&&await e(N.id,null,!0),k()},k=()=>{o("root")},C=A.useCallback(async()=>{const E=V==null?void 0:V.curWorkflow;if(!E){alert("No current workflow!");return}const N=_e.graph.serialize(),I=JSON.stringify(N,null,2);Ol(I,E.name)},[t]);return x.jsxs(x.Fragment,{children:[x.jsx(yp,{menuButton:x.jsx(za,{children:x.jsxs(Te,{px:1,height:ml+"px","aria-label":"menu",size:"sm",backgroundColor:"#434554",children:["File",x.jsx(Xh,{size:20})]})}),menuContent:x.jsx(Fs,{isOpen:!0,children:x.jsxs(Rs,{minWidth:150,zIndex:1e3,children:[x.jsx(pt,{onClick:r,icon:x.jsx(ys,{size:20}),iconSpacing:1,command:v.save,children:"Save"}),!((j=q==null?void 0:q.settings)!=null&&j.autoSave)&&x.jsx(bt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:x.jsx(pt,{onClick:n,icon:x.jsx(Yh,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),x.jsx(pt,{onClick:C,icon:x.jsx(Na,{size:20}),iconSpacing:1,children:"Download"}),x.jsxs(pt,{onClick:()=>o("downloadSpaceJson"),icon:x.jsx(Na,{size:20}),iconSpacing:1,children:["Download .runner.json ",x.jsx(Gt,{size:"sm",children:"🧪beta"})]}),x.jsx(pt,{onClick:()=>o("saveAsModal"),icon:x.jsx(ys,{size:20}),iconSpacing:1,command:v.saveAs,children:"Save As"}),x.jsx(pt,{onClick:()=>a(!0),icon:x.jsx(cp,{size:20}),iconSpacing:1,children:"Create Version"}),x.jsx(pt,{onClick:()=>o("versionHistory"),icon:x.jsx(tp,{size:20}),iconSpacing:1,children:"Versions History"}),x.jsx(pt,{onClick:()=>m(!0),icon:x.jsx(ip,{size:20}),iconSpacing:1,alignItems:"center",children:x.jsxs(rt,{children:[x.jsx("p",{children:"Share"})," ",x.jsx(Gt,{size:"sm",children:"🧪beta"})]})})]})})}),y&&x.jsx(Ep,{onClose:()=>m(!1)}),s=="versionHistory"&&x.jsx(hp,{onClose:()=>o("root")}),s=="downloadSpaceJson"&&x.jsx(_p,{}),s==="saveAsModal"&&x.jsxs(Gr,{isOpen:!0,onClose:k,children:[x.jsx(ws,{}),x.jsxs(Jr,{children:[x.jsx(bs,{children:"Save As"}),x.jsx(_s,{}),x.jsx(Zr,{children:x.jsxs(Yr,{isInvalid:!!c,children:[x.jsx(Qr,{children:"Workflow name"}),x.jsx(vn,{value:l,onChange:g,autoFocus:!0,onKeyUp:E=>{E.code==="Enter"&&!c&&l&&_()}}),c&&x.jsx(Xr,{children:c})]})}),x.jsxs(xs,{children:[x.jsx(Te,{colorScheme:"teal",mr:3,onClick:_,isDisabled:!l||!!c,children:"Save"}),x.jsx(Te,{onClick:k,children:"Cancel"})]})]})]}),i&&x.jsx(pp,{workflowId:t,onClose:()=>a(!1)})]})}function Sp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Uc(),{curFlowID:i}=A.useContext(Ct),[a,l]=A.useState(t),[u,c]=A.useState(""),d=()=>{l(t),o()},p=f=>{l(f.target.value),u&&c("")},h=async()=>{var f;if(i){const y=a.trim();if(l(y),t===y)return v();await(V==null?void 0:V.generateUniqueName(y,((f=V.curWorkflow)==null?void 0:f.parentFolderID)??""))!==y?c("The name is duplicated, please modify it and submit again."):(await(V==null?void 0:V.updateName(i,{name:y})),e(y),v())}},v=()=>{c(""),s()};return i==null?null:x.jsxs(rt,{children:[x.jsx(bt,{label:t,placement:"bottom",children:x.jsxs(wt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[x.jsx("div",{style:{width:8,display:"inline-block"},children:x.jsx(wt,{as:"span",children:n&&"* "})}),t]})}),x.jsxs(Gr,{isOpen:r,onClose:v,children:[x.jsx(ws,{}),x.jsxs(Jr,{children:[x.jsx(bs,{children:"Edit workflow name"}),x.jsx(_s,{}),x.jsx(Zr,{children:x.jsxs(Yr,{isInvalid:!!u,children:[x.jsx(Qr,{children:"Workflow name"}),x.jsx(vn,{value:a,onChange:p,autoFocus:!0,onKeyUp:f=>{f.code==="Enter"&&!u&&a&&h()}}),u&&x.jsx(Xr,{children:u})]})}),x.jsxs(xs,{children:[x.jsx(Te,{colorScheme:"teal",mr:3,onClick:h,isDisabled:!a||!!u,children:"Save"}),x.jsx(Te,{onClick:v,children:"Cancel"})]})]})]})]})}function bm(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const _m=[{label:"Private",value:"PRIVATE",icon:x.jsx(kl,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:x.jsx(rp,{})},{label:"Public",value:"PUBLIC",icon:x.jsx(up,{})}],xm=()=>{const t=_e.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 Op(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 km({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")),x.jsx("span",{children:n})}function Ip({}){const[t,e]=A.useState(),[n,r]=A.useState(),{curFlowID:o}=A.useContext(Ct);return A.useEffect(()=>{o&&(V==null||V.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),Op(s).then(i=>{r(i)})):e(void 0)}))},[o]),t?x.jsx("a",{href:t,style:{textDecoration:"none"},target:"_blank",children:x.jsx(za,{children:x.jsx(Gt,{children:n==="PUBLIC"?"🌐":n==="UNLISTED"?"🔗":"🔒"})})}):null}function Dp({}){const{setRoute:t,curVersion:e,isDirty:n,setCurVersion:r}=A.useContext(Ct);return A.useEffect(()=>{n&&e&&(e==null?void 0:e.name.endsWith("*"))===!1&&(r==null||r({...e,name:e.name+"*"}))},[n]),e?x.jsx(Wt,{alignItems:"center",children:x.jsx(Ga,{size:"sm",isAttached:!0,variant:"outline",children:x.jsx(Te,{rightIcon:x.jsx(El,{size:10}),onClick:()=>t("versionHistory"),children:e.name})})}):null}const jp=A.lazy(()=>mn(()=>import("./AppIsDirtyEventListener-TdXJ5J_h.js"),__vite__mapDeps([5,1,6]))),Pp=A.lazy(()=>mn(()=>import("./ModelManagerTopbar-7VH-2Gbw.js").then(t=>t.M),__vite__mapDeps([7,1,8,2,9,10]))),Ap=A.lazy(()=>mn(()=>import("./SpotlightSearch-BOOXnLDY.js"),__vite__mapDeps([11,1,6,12,13])));function Np({curFlowName:t,setCurFlowName:e}){var d;const{isDirty:n,loadNewWorkflow:r,saveCurWorkflow:o,setRoute:s,curFlowID:i,route:a}=A.useContext(Ct),[l,u]=A.useState(),c=A.useCallback((p,h=!1)=>{const{top:v=0,left:f=0}=l||{};let{top:y=0,left:m=0}=p??{};y+=v,m+=f;const g=document.documentElement.clientWidth,_=document.documentElement.clientHeight,k=document.getElementById("workspaceManagerPanel"),C=(k==null?void 0:k.offsetWidth)||392;y+36>_&&(y=_-36),m+C>=g&&(m=g-C),u({top:Math.max(0,y),left:Math.max(0,m)}),h&&(q==null||q.upsert({topBarStyle:{top:y,left:m}}))},[l]);return A.useEffect(()=>{q==null||q.getSetting("topBarStyle").then(p=>{c(p,!1)})},[]),l?x.jsx($h,{onDragEnd:p=>{c({top:p.y,left:p.x},!0)},dragIconId:"dragPanelIcon",children:x.jsxs(rt,{style:{padding:2,position:"fixed",...l},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[x.jsx(Te,{size:"sm","aria-label":"workspace folder",onClick:()=>s("recentFlows"),px:2,children:x.jsxs(rt,{gap:1,children:[x.jsx(Qh,{size:21}),x.jsx(El,{size:8})]})}),x.jsx(A.Suspense,{fallback:x.jsx("div",{style:{width:"60px"}}),children:x.jsx(Pp,{})}),x.jsx(bt,{label:"New workflow",children:x.jsx(Te,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",height:ml+"px",onClick:()=>r(),px:2,py:2,children:x.jsx(rt,{gap:0,children:x.jsx(sp,{size:16,color:"white"})})})}),x.jsx(Sp,{isDirty:n,displayName:t??"",updateFlowName:p=>{e(p),requestAnimationFrame(()=>{c()})}}),((d=V==null?void 0:V.curWorkflow)==null?void 0:d.saveLock)&&x.jsx(kl,{color:"#FFF",size:20}),i&&x.jsxs(rt,{gap:"4px",children:[x.jsx(bt,{label:"Open gallery",children:x.jsx(Tn,{onClick:()=>s("gallery"),icon:x.jsx(op,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),x.jsx(Cp,{})]}),i&&n?x.jsx(bt,{label:"Save workflow",children:x.jsx(Tn,{onClick:o,icon:x.jsx(ys,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):x.jsx("div",{style:{width:1}}),x.jsx(Ip,{}),x.jsx(Dp,{}),x.jsx(jp,{}),x.jsx(ep,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"}),a==="spotlightSearch"&&x.jsx(Ap,{})]})}):null}function Fp(){const{showDialog:t}=La(),{loadWorkflowID:e}=A.useContext(Ct),n=async(o,s)=>{var u,c;const{workflow:i,version:a}=o.detail;if(!i.id||!a.id)return;const l=(u=await(V==null?void 0:V.listByIndex("cloudID",i.id)))==null?void 0:u.at(0);if(l){const d=(c=await(we==null?void 0:we.listByIndex("cloudID",a.id)))==null?void 0:c.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(V==null?void 0:V.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(Rp(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 Rp(t){return t.type==="workspace_open_workflow"}const Tp=t=>typeof t=="function",Bp=t=>{const[e,n]=A.useState(t),r=A.useRef(e),o=A.useCallback(s=>{r.current=Tp(s)?s(r.current):s,n(r.current)},[]);return[e,o,r]};function hr(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 Il={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(u,c){if(!o[u]){if(!r[u]){var d=typeof hr=="function"&&hr;if(!c&&d)return d(u,!0);if(a)return a(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var h=o[u]={exports:{}};r[u][0].call(h.exports,function(v){var f=r[u][1][v];return i(f||v)},h,h.exports,n,r,o,s)}return o[u].exports}for(var a=typeof hr=="function"&&hr,l=0;l>2,h=(3&u)<<4|c>>4,v=1<_?(15&c)<<2|d>>6:64,f=2<_?63&d:64,y.push(a.charAt(p)+a.charAt(h)+a.charAt(v)+a.charAt(f));return y.join("")},o.decode=function(l){var u,c,d,p,h,v,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 g,_=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(g=i.uint8array?new Uint8Array(0|_):new Array(0|_);f>4,c=(15&p)<<4|(h=a.indexOf(l.charAt(f++)))>>2,d=(3&h)<<6|(v=a.indexOf(l.charAt(f++))),g[y++]=u,h!==64&&(g[y++]=c),v!==64&&(g[y++]=d);return g}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function u(c,d,p,h,v){this.compressedSize=c,this.uncompressedSize=d,this.crc32=p,this.compression=h,this.compressedContent=v}u.prototype={getContentWorker:function(){var c=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return c.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(c,d,p){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=function(){for(var a,l=[],u=0;u<256;u++){a=u;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(u,c,d,p){var h=i,v=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c[f])];return-1^u}(0|l,a,a.length,0):function(u,c,d,p){var h=i,v=p+d;u^=-1;for(var f=p;f>>8^h[255&(u^c.charCodeAt(f))];return-1^u}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),u=s?"uint8array":"array";function c(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,d.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},o.compressWorker=function(d){return new c("Deflate",d)},o.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(h,v){var f,y="";for(f=0;f>>=8;return y}function i(h,v,f,y,m,g){var _,k,C=h.file,j=h.compression,E=g!==u.utf8encode,N=a.transformTo("string",g(C.name)),I=a.transformTo("string",u.utf8encode(C.name)),F=C.comment,$=a.transformTo("string",g(F)),P=a.transformTo("string",u.utf8encode(F)),B=I.length!==C.name.length,b=P.length!==F.length,K="",te="",O="",J=C.dir,M=C.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};v&&!f||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var z=0;v&&(z|=8),E||!B&&!b||(z|=2048);var T=0,ne=0;J&&(T|=16),m==="UNIX"?(ne=798,T|=function(G,fe){var ye=G;return G||(ye=fe?16893:33204),(65535&ye)<<16}(C.unixPermissions,J)):(ne=20,T|=function(G){return 63&(G||0)}(C.dosPermissions)),_=M.getUTCHours(),_<<=6,_|=M.getUTCMinutes(),_<<=5,_|=M.getUTCSeconds()/2,k=M.getUTCFullYear()-1980,k<<=4,k|=M.getUTCMonth()+1,k<<=5,k|=M.getUTCDate(),B&&(te=s(1,1)+s(c(N),4)+I,K+="up"+s(te.length,2)+te),b&&(O=s(1,1)+s(c($),4)+P,K+="uc"+s(O.length,2)+O);var Y="";return Y+=` -\0`,Y+=s(z,2),Y+=j.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"),u=n("../utf8"),c=n("../crc32"),d=n("../signature");function p(h,v,f,y){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,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 v=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?(v+100*(f-y-1))/f:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var v=this.streamFiles&&!h.file.dir;if(v){var f=i(h,v,!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 v=this.streamFiles&&!h.file.dir,f=i(h,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),v)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,v=0;v=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),c=n("./Uint8ArrayReader");r.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(d):i.uint8array?new c(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){var s=n("./GenericWorker"),i=n("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}i.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:i.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=i(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,i),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}i.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(l){i.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){u.dataIsReady=!0,u.data=c,u.max=c&&c.length||0,u.type=s.getTypeOf(c),u.isPaused||u._tickAndRepeat()},function(c){u.error(c)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var l=0;l "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),u=n("../support"),c=n("../external"),d=null;if(u.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(v,f){return new c.Promise(function(y,m){var g=[],_=v._internalType,k=v._outputType,C=v._mimeType;v.on("data",function(j,E){g.push(j),f&&f(E)}).on("error",function(j){g=[],m(j)}).on("end",function(){try{var j=function(E,N,I){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",N),I);case"base64":return l.encode(N);default:return s.transformTo(E,N)}}(k,function(E,N){var I,F=0,$=null,P=0;for(I=0;I"u")o.blob=!1;else{var s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){for(var s=n("./utils"),i=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),c=0;c<256;c++)u[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;u[254]=u[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(h){return i.nodebuffer?a.newBufferFrom(h,"utf-8"):function(v){var f,y,m,g,_,k=v.length,C=0;for(g=0;g>>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(v){var f,y,m,g,_=v.length,k=new Array(2*_);for(f=y=0;f<_;)if((m=v[f++])<128)k[y++]=m;else if(4<(g=u[m]))k[y++]=65533,f+=g-1;else{for(m&=g===2?31:g===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 v=s.transformTo(i.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var f=v;(v=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),v.set(f,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var y=function(g,_){var k;for((_=_||g.length)>g.length&&(_=g.length),k=_-1;0<=k&&(192&g[k])==128;)k--;return k<0||k===0?_:k+u[g[k]]>_?k:_}(v),m=v;y!==v.length&&(i.uint8array?(m=v.subarray(0,y),this.leftOver=v.subarray(y,v.length)):(m=v.slice(0,y),this.leftOver=v.slice(y,v.length))),this.push({data:o.utf8decode(m),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function u(f){return f}function c(f,y){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var v,f,y,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?p[y++]=224|h>>>12:(p[y++]=240|h>>>18,p[y++]=128|h>>>12&63),p[y++]=128|h>>>6&63),p[y++]=128|63&h);return p},o.buf2binstring=function(d){return c(d,d.length)},o.binstring2buf=function(d){for(var p=new s.Buf8(d.length),h=0,v=p.length;h>10&1023,g[v++]=56320|1023&f)}return c(g,v)},o.utf8border=function(d,p){var h;for((p=p||d.length)>d.length&&(p=d.length),h=p-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?p:h+l[d[h]]>p?h:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,l){for(var u=65535&s|0,c=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3>>1:i>>>1;a[l]=i}return a}();r.exports=function(i,a,l,u){var c=s,d=u+l;i^=-1;for(var p=u;p>>8^c[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),c=n("./messages"),d=0,p=4,h=0,v=-2,f=-1,y=4,m=2,g=8,_=9,k=286,C=30,j=19,E=2*k+1,N=15,I=3,F=258,$=F+I+1,P=42,B=113,b=1,K=2,te=3,O=4;function J(w,U){return w.msg=c[U],U}function M(w){return(w<<1)-(4w.avail_out&&(W=w.avail_out),W!==0&&(i.arraySet(w.output,U.pending_buf,U.pending_out,W,w.next_out),w.next_out+=W,U.pending_out+=W,w.total_out+=W,w.avail_out-=W,U.pending-=W,U.pending===0&&(U.pending_out=0))}function T(w,U){a._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,U),w.block_start=w.strstart,z(w.strm)}function ne(w,U){w.pending_buf[w.pending++]=U}function Y(w,U){w.pending_buf[w.pending++]=U>>>8&255,w.pending_buf[w.pending++]=255&U}function G(w,U){var W,D,S=w.max_chain_length,R=w.strstart,H=w.prev_length,Z=w.nice_match,L=w.strstart>w.w_size-$?w.strstart-(w.w_size-$):0,X=w.window,re=w.w_mask,ee=w.prev,ae=w.strstart+F,ge=X[R+H-1],pe=X[R+H];w.prev_length>=w.good_match&&(S>>=2),Z>w.lookahead&&(Z=w.lookahead);do if(X[(W=U)+H]===pe&&X[W+H-1]===ge&&X[W]===X[R]&&X[++W]===X[R+1]){R+=2,W++;do;while(X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&X[++R]===X[++W]&&RL&&--S!=0);return H<=w.lookahead?H:w.lookahead}function fe(w){var U,W,D,S,R,H,Z,L,X,re,ee=w.w_size;do{if(S=w.window_size-w.lookahead-w.strstart,w.strstart>=ee+(ee-$)){for(i.arraySet(w.window,w.window,ee,ee,0),w.match_start-=ee,w.strstart-=ee,w.block_start-=ee,U=W=w.hash_size;D=w.head[--U],w.head[U]=ee<=D?D-ee:0,--W;);for(U=W=ee;D=w.prev[--U],w.prev[U]=ee<=D?D-ee:0,--W;);S+=ee}if(w.strm.avail_in===0)break;if(H=w.strm,Z=w.window,L=w.strstart+w.lookahead,X=S,re=void 0,re=H.avail_in,X=I)for(R=w.strstart-w.insert,w.ins_h=w.window[R],w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I)if(D=a._tr_tally(w,w.strstart-w.match_start,w.match_length-I),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=I){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<=I&&(w.ins_h=(w.ins_h<=I&&w.match_length<=w.prev_length){for(S=w.strstart+w.lookahead-I,D=a._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-I),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=S&&(w.ins_h=(w.ins_h<w.pending_buf_size-5&&(W=w.pending_buf_size-5);;){if(w.lookahead<=1){if(fe(w),w.lookahead===0&&U===d)return b;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var D=w.block_start+W;if((w.strstart===0||w.strstart>=D)&&(w.lookahead=w.strstart-D,w.strstart=D,T(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-$&&(T(w,!1),w.strm.avail_out===0))return b}return w.insert=0,U===p?(T(w,!0),w.strm.avail_out===0?te:O):(w.strstart>w.block_start&&(T(w,!1),w.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(w,U){return Ee(w,U,g,15,8,0)},o.deflateInit2=Ee,o.deflateReset=me,o.deflateResetKeep=ve,o.deflateSetHeader=function(w,U){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=U,h):v},o.deflate=function(w,U){var W,D,S,R;if(!w||!w.state||5>8&255),ne(D,D.gzhead.time>>16&255),ne(D,D.gzhead.time>>24&255),ne(D,D.level===9?2:2<=D.strategy||D.level<2?4:0),ne(D,255&D.gzhead.os),D.gzhead.extra&&D.gzhead.extra.length&&(ne(D,255&D.gzhead.extra.length),ne(D,D.gzhead.extra.length>>8&255)),D.gzhead.hcrc&&(w.adler=u(w.adler,D.pending_buf,D.pending,0)),D.gzindex=0,D.status=69):(ne(D,0),ne(D,0),ne(D,0),ne(D,0),ne(D,0),ne(D,D.level===9?2:2<=D.strategy||D.level<2?4:0),ne(D,3),D.status=B);else{var H=g+(D.w_bits-8<<4)<<8;H|=(2<=D.strategy||D.level<2?0:D.level<6?1:D.level===6?2:3)<<6,D.strstart!==0&&(H|=32),H+=31-H%31,D.status=B,Y(D,H),D.strstart!==0&&(Y(D,w.adler>>>16),Y(D,65535&w.adler)),w.adler=1}if(D.status===69)if(D.gzhead.extra){for(S=D.pending;D.gzindex<(65535&D.gzhead.extra.length)&&(D.pending!==D.pending_buf_size||(D.gzhead.hcrc&&D.pending>S&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),z(w),S=D.pending,D.pending!==D.pending_buf_size));)ne(D,255&D.gzhead.extra[D.gzindex]),D.gzindex++;D.gzhead.hcrc&&D.pending>S&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),D.gzindex===D.gzhead.extra.length&&(D.gzindex=0,D.status=73)}else D.status=73;if(D.status===73)if(D.gzhead.name){S=D.pending;do{if(D.pending===D.pending_buf_size&&(D.gzhead.hcrc&&D.pending>S&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),z(w),S=D.pending,D.pending===D.pending_buf_size)){R=1;break}R=D.gzindexS&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),R===0&&(D.gzindex=0,D.status=91)}else D.status=91;if(D.status===91)if(D.gzhead.comment){S=D.pending;do{if(D.pending===D.pending_buf_size&&(D.gzhead.hcrc&&D.pending>S&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),z(w),S=D.pending,D.pending===D.pending_buf_size)){R=1;break}R=D.gzindexS&&(w.adler=u(w.adler,D.pending_buf,D.pending-S,S)),R===0&&(D.status=103)}else D.status=103;if(D.status===103&&(D.gzhead.hcrc?(D.pending+2>D.pending_buf_size&&z(w),D.pending+2<=D.pending_buf_size&&(ne(D,255&w.adler),ne(D,w.adler>>8&255),w.adler=0,D.status=B)):D.status=B),D.pending!==0){if(z(w),w.avail_out===0)return D.last_flush=-1,h}else if(w.avail_in===0&&M(U)<=M(W)&&U!==p)return J(w,-5);if(D.status===666&&w.avail_in!==0)return J(w,-5);if(w.avail_in!==0||D.lookahead!==0||U!==d&&D.status!==666){var Z=D.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:O):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(D,U):D.strategy===3?function(L,X){for(var re,ee,ae,ge,pe=L.window;;){if(L.lookahead<=F){if(fe(L),L.lookahead<=F&&X===d)return b;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=I&&0L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=I?(re=a._tr_tally(L,1,L.match_length-I),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:O):L.last_lit&&(T(L,!1),L.strm.avail_out===0)?b:K}(D,U):s[D.level].func(D,U);if(Z!==te&&Z!==O||(D.status=666),Z===b||Z===te)return w.avail_out===0&&(D.last_flush=-1),h;if(Z===K&&(U===1?a._tr_align(D):U!==5&&(a._tr_stored_block(D,0,0,!1),U===3&&(Q(D.head),D.lookahead===0&&(D.strstart=0,D.block_start=0,D.insert=0))),z(w),w.avail_out===0))return D.last_flush=-1,h}return U!==p?h:D.wrap<=0?1:(D.wrap===2?(ne(D,255&w.adler),ne(D,w.adler>>8&255),ne(D,w.adler>>16&255),ne(D,w.adler>>24&255),ne(D,255&w.total_in),ne(D,w.total_in>>8&255),ne(D,w.total_in>>16&255),ne(D,w.total_in>>24&255)):(Y(D,w.adler>>>16),Y(D,65535&w.adler)),z(w),0=W.w_size&&(R===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),H=w.avail_in,Z=w.next_in,L=w.input,w.avail_in=re,w.next_in=0,w.input=U,fe(W);W.lookahead>=I;){for(D=W.strstart,S=W.lookahead-(I-1);W.ins_h=(W.ins_h<>>=I=N>>>24,_-=I,(I=N>>>16&255)===0)K[c++]=65535&N;else{if(!(16&I)){if(!(64&I)){N=k[(65535&N)+(g&(1<>>=I,_-=I),_<15&&(g+=b[l++]<<_,_+=8,g+=b[l++]<<_,_+=8),N=C[g&E];n:for(;;){if(g>>>=I=N>>>24,_-=I,!(16&(I=N>>>16&255))){if(!(64&I)){N=C[(65535&N)+(g&(1<>>=I,_-=I,(I=c-d)<$){if(f<(I=$-I)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=m,(P=0)===y){if(P+=v-I,I>3,g&=(1<<(_-=F<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(P){var B;return P&&P.state?(B=P.state,P.total_in=P.total_out=B.total=0,P.msg="",B.wrap&&(P.adler=1&B.wrap),B.mode=v,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(P){var B;return P&&P.state?((B=P.state).wsize=0,B.whave=0,B.wnext=0,_(P)):h}function C(P,B){var b,K;return P&&P.state?(K=P.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15=O.wsize?(s.arraySet(O.window,B,b-O.wsize,O.wsize,0),O.wnext=0,O.whave=O.wsize):(K<(te=O.wsize-O.wnext)&&(te=K),s.arraySet(O.window,B,b-K,te,O.wnext),(K-=te)?(s.arraySet(O.window,B,b-K,K,0),O.wnext=K,O.whave=O.wsize):(O.wnext+=te,O.wnext===O.wsize&&(O.wnext=0),O.whave>>8&255,b.check=a(b.check,R,2,0),T=z=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&z)<<8)+(z>>8))%31){P.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){P.msg="unknown compression method",b.mode=30;break}if(T-=4,w=8+(15&(z>>>=4)),b.wbits===0)b.wbits=w;else if(w>b.wbits){P.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(R[0]=255&z,R[1]=z>>>8&255,b.check=a(b.check,R,2,0)),T=z=0,b.mode=3;case 3:for(;T<32;){if(M===0)break e;M--,z+=K[O++]<>>8&255,R[2]=z>>>16&255,R[3]=z>>>24&255,b.check=a(b.check,R,4,0)),T=z=0,b.mode=4;case 4:for(;T<16;){if(M===0)break e;M--,z+=K[O++]<>8),512&b.flags&&(R[0]=255&z,R[1]=z>>>8&255,b.check=a(b.check,R,2,0)),T=z=0,b.mode=5;case 5:if(1024&b.flags){for(;T<16;){if(M===0)break e;M--,z+=K[O++]<>>8&255,b.check=a(b.check,R,2,0)),T=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(M<(G=b.length)&&(G=M),G&&(b.head&&(w=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,K,O,G,w)),512&b.flags&&(b.check=a(b.check,K,G,O)),M-=G,O+=G,b.length-=G),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(M===0)break e;for(G=0;w=K[O+G++],b.head&&w&&b.length<65536&&(b.head.name+=String.fromCharCode(w)),w&&G>9&1,b.head.done=!0),P.adler=b.check=0,b.mode=12;break;case 10:for(;T<32;){if(M===0)break e;M--,z+=K[O++]<>>=7&T,T-=7&T,b.mode=27;break}for(;T<3;){if(M===0)break e;M--,z+=K[O++]<>>=1)){case 0:b.mode=14;break;case 1:if(F(b),b.mode=20,B!==6)break;z>>>=2,T-=2;break e;case 2:b.mode=17;break;case 3:P.msg="invalid block type",b.mode=30}z>>>=2,T-=2;break;case 14:for(z>>>=7&T,T-=7&T;T<32;){if(M===0)break e;M--,z+=K[O++]<>>16^65535)){P.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,T=z=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(G=b.length){if(M>>=5,T-=5,b.ndist=1+(31&z),z>>>=5,T-=5,b.ncode=4+(15&z),z>>>=4,T-=4,286>>=3,T-=3}for(;b.have<19;)b.lens[H[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},U=u(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,U){P.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,ke=65535&S,!((se=S>>>24)<=T);){if(M===0)break e;M--,z+=K[O++]<>>=se,T-=se,b.lens[b.have++]=ke;else{if(ke===16){for(D=se+2;T>>=se,T-=se,b.have===0){P.msg="invalid bit length repeat",b.mode=30;break}w=b.lens[b.have-1],G=3+(3&z),z>>>=2,T-=2}else if(ke===17){for(D=se+3;T>>=se)),z>>>=3,T-=3}else{for(D=se+7;T>>=se)),z>>>=7,T-=7}if(b.have+G>b.nlen+b.ndist){P.msg="invalid bit length repeat",b.mode=30;break}for(;G--;)b.lens[b.have++]=w}}if(b.mode===30)break;if(b.lens[256]===0){P.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},U=u(c,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,U){P.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},U=u(d,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,U){P.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<=M&&258<=Q){P.next_out=J,P.avail_out=Q,P.next_in=O,P.avail_in=M,b.hold=z,b.bits=T,l(P,Y),J=P.next_out,te=P.output,Q=P.avail_out,O=P.next_in,K=P.input,M=P.avail_in,z=b.hold,T=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;le=(S=b.lencode[z&(1<>>16&255,ke=65535&S,!((se=S>>>24)<=T);){if(M===0)break e;M--,z+=K[O++]<>ve)])>>>16&255,ke=65535&S,!(ve+(se=S>>>24)<=T);){if(M===0)break e;M--,z+=K[O++]<>>=ve,T-=ve,b.back+=ve}if(z>>>=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){P.msg="invalid literal/length code",b.mode=30;break}b.extra=15&le,b.mode=22;case 22:if(b.extra){for(D=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;le=(S=b.distcode[z&(1<>>16&255,ke=65535&S,!((se=S>>>24)<=T);){if(M===0)break e;M--,z+=K[O++]<>ve)])>>>16&255,ke=65535&S,!(ve+(se=S>>>24)<=T);){if(M===0)break e;M--,z+=K[O++]<>>=ve,T-=ve,b.back+=ve}if(z>>>=se,T-=se,b.back+=se,64&le){P.msg="invalid distance code",b.mode=30;break}b.offset=ke,b.extra=15&le,b.mode=24;case 24:if(b.extra){for(D=b.extra;T>>=b.extra,T-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){P.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(Q===0)break e;if(G=Y-Q,b.offset>G){if((G=b.offset-G)>b.whave&&b.sane){P.msg="invalid distance too far back",b.mode=30;break}fe=G>b.wnext?(G-=b.wnext,b.wsize-G):b.wnext-G,G>b.length&&(G=b.length),ye=b.window}else ye=te,fe=J-b.offset,G=b.length;for(QE?(I=fe[ye+y[B]],T[ne+y[B]]):(I=96,0),g=1<>J)+(_-=g)]=N<<24|I<<16|F|0,_!==0;);for(g=1<>=1;if(g!==0?(z&=g-1,z+=g):z=0,B++,--Y[P]==0){if(P===K)break;P=d[p+y[B]]}if(te>>7)]}function ne(S,R){S.pending_buf[S.pending++]=255&R,S.pending_buf[S.pending++]=R>>>8&255}function Y(S,R,H){S.bi_valid>m-H?(S.bi_buf|=R<>m-S.bi_valid,S.bi_valid+=H-m):(S.bi_buf|=R<>>=1,H<<=1,0<--R;);return H>>>1}function ye(S,R,H){var Z,L,X=new Array(y+1),re=0;for(Z=1;Z<=y;Z++)X[Z]=re=re+H[Z-1]<<1;for(L=0;L<=R;L++){var ee=S[2*L+1];ee!==0&&(S[2*L]=fe(X[ee]++,ee))}}function se(S){var R;for(R=0;R>1;1<=H;H--)ve(S,X,H);for(L=ae;H=S.heap[1],S.heap[1]=S.heap[S.heap_len--],ve(S,X,1),Z=S.heap[1],S.heap[--S.heap_max]=H,S.heap[--S.heap_max]=Z,X[2*L]=X[2*H]+X[2*Z],S.depth[L]=(S.depth[H]>=S.depth[Z]?S.depth[H]:S.depth[Z])+1,X[2*H+1]=X[2*Z+1]=L,S.heap[1]=L++,ve(S,X,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(pe,Ye){var _n,at,xn,je,er,io,ft=Ye.dyn_tree,Zs=Ye.max_code,Dl=Ye.stat_desc.static_tree,jl=Ye.stat_desc.has_stree,Pl=Ye.stat_desc.extra_bits,Ys=Ye.stat_desc.extra_base,kn=Ye.stat_desc.max_length,tr=0;for(je=0;je<=y;je++)pe.bl_count[je]=0;for(ft[2*pe.heap[pe.heap_max]+1]=0,_n=pe.heap_max+1;_n>=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=S.static_len+3+7>>>3)<=L&&(L=X)):L=X=H+5,H+4<=L&&R!==-1?D(S,R,H,Z):S.strategy===4||X===L?(Y(S,2+(Z?1:0),3),me(S,$,P)):(Y(S,4+(Z?1:0),3),function(ee,ae,ge,pe){var Ye;for(Y(ee,ae-257,5),Y(ee,ge-1,5),Y(ee,pe-4,4),Ye=0;Ye>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&R,S.pending_buf[S.l_buf+S.last_lit]=255&H,S.last_lit++,R===0?S.dyn_ltree[2*H]++:(S.matches++,R--,S.dyn_ltree[2*(b[H]+d+1)]++,S.dyn_dtree[2*T(R)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){Y(S,2,3),G(S,_,$),function(R){R.bi_valid===16?(ne(R,R.bi_buf),R.bi_buf=0,R.bi_valid=0):8<=R.bi_valid&&(R.pending_buf[R.pending++]=255&R.bi_buf,R.bi_buf>>=8,R.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,r,o){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(s){(function(i,a){if(!i.setImmediate){var l,u,c,d,p=1,h={},v=!1,f=i.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(i);y=y&&y.setTimeout?y:i,l={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){g(k)})}:function(){if(i.postMessage&&!i.importScripts){var k=!0,C=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=C,k}}()?(d="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",_,!1):i.attachEvent("onmessage",_),function(k){i.postMessage(d+k,"*")}):i.MessageChannel?((c=new MessageChannel).port1.onmessage=function(k){g(k.data)},function(k){c.port2.postMessage(k)}):f&&"onreadystatechange"in f.createElement("script")?(u=f.documentElement,function(k){var C=f.createElement("script");C.onreadystatechange=function(){g(k),C.onreadystatechange=null,u.removeChild(C),C=null},u.appendChild(C)}):function(k){setTimeout(g,0,k)},y.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var C=new Array(arguments.length-1),j=0;j"u"?s===void 0?this:s:self)}).call(this,typeof nr<"u"?nr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Il);var Mp=Il.exports;const zp=Ra(Mp),Lp=async t=>{const e=`ComfyUI workspace workflows ${vl(Date.now())}`,n=new zp,r=await(q==null?void 0:q.getSetting("twoWaySync"));for(const o of t){let s;r?s=o.parentFolderID??"":s=await Ch(o.parentFolderID??null).then(async a=>Ft(a??""));const i=n.folder(s);i==null||i.file(`${o.name}.json`,o.json)}n.generateAsync({type:"blob"}).then(function(o){const s=document.createElement("a");s.href=window.URL.createObjectURL(o),s.download=`${e}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s)})};function Wp({myWorkflowsDir:t}){return x.jsxs(He,{gap:3,children:[x.jsx(sn,{size:"md",children:"🦄 Upgrade to 2.0 - enable two way sync!"}),x.jsx("p",{children:"Your workflows will be synced to and from path:"}),x.jsx("p",{children:x.jsx("b",{children:t})}),x.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"]}),x.jsxs("p",{children:[x.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."]}),x.jsx(Te,{colorScheme:"teal",variant:"outline",width:"fit-content",onClick:async()=>{const e=await(V==null?void 0:V.listAll());Lp(e??[])},children:"👉 Download All My Workflows"})]})}const Up=(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 u=l.order,c=l.pos;return delete l.order,delete l.pos,a.set(l.id,JSON.stringify(l)),a.set(l.id+"_pos",c),l.order=u,l.pos=c,a},i=(a,l,u)=>Math.abs(a-l)>u;if(n.length==r.length){const a=n.reduce(s,new Map),l=r.reduce(s,new Map);for(let[u,c]of a){if(!l.has(u)){o=!1;break}if(typeof u=="string"&&u.includes("_pos")){const d=l.get(u);if(d==null||c==null||i(d[0],c[0],5)||i(d[1],c[1],5)){o=!1;break}}else if(l.get(u)!==c){o=!1;break}}}}return t.nodes=n,e.nodes=r,o},Kp=Wa.lazy(()=>mn(()=>import("./RecentFilesDrawer-O5CnaDXe.js"),__vite__mapDeps([14,1,8,2,13,15,12,4]))),$p=Wa.lazy(()=>mn(()=>import("./GalleryModal-Rpu1lZvh.js"),__vite__mapDeps([16,1,15,12,9,8,2,3]))),Vp=["download_progress","download_error","model_list"];function Hp(){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),[u,c]=A.useState(!1),d=A.useRef(null),{showDialog:p}=La(),[h,v]=A.useState(!1);A.useRef(!1);const f=Ka(),[y,m]=Bp(null),g=A.useCallback(async()=>{var O,J;if(l.current){if((O=V==null?void 0:V.curWorkflow)!=null&&O.saveLock){f({title:"The workflow is locked and cannot be saved",status:"warning",duration:3e3});return}const M=JSON.stringify(_e.graph.serialize());await Promise.all([V==null?void 0:V.updateFlow(l.current,{json:M}),qe==null?void 0:qe.create({workflowID:l.current,json:M,isAutoSave:!1})]),(J=q==null?void 0:q.settings)!=null&&J.autoSave&&f({title:"Saved",status:"success",duration:1e3,isClosable:!0}),c(!1)}},[]),_=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(V==null?void 0:V.delete(l.current)),C(null))},k=async()=>{var J,M,Q;if((J=q==null?void 0:q.settings)!=null&&J.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 z=(M=V==null?void 0:V.curWorkflow)==null?void 0:M.id;if(z==null)return;const T=(Q=await(V==null?void 0:V.get(z)))==null?void 0:Q.json;T?(V==null||V.updateCurWorkflow({...V.curWorkflow,json:T}),await _e.loadGraphData(JSON.parse(T)),c(!1)):alert("Error: No last saved version found")}},C=O=>{const J=(O==null?void 0:O.id)??null;if(V==null||V.updateCurWorkflow(O),l.current=J,a(J),e((O==null?void 0:O.name)??""),J==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ja()){const M=gl(J);window.location.hash=M,document.title=O.name+" - ComfyUI"}else localStorage.setItem("curFlowID",J),document.title="ComfyUI - "+O.name;O&&(V==null||V.updateLastOpenedTime(O.id))},j=async()=>{E(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Uh()}catch(M){console.error("error loading db",M)}s(!1);let O=null;O=ja(),O==null&&(O=localStorage.getItem("curFlowID")),O&&I(O),!await(q==null?void 0:q.getSetting("twoWaySync"))&&ce.cache.get(ko).then(async M=>{if((M==null?void 0:M.value)!=="true"){if(await ce.workflows.count()==0){await(q==null?void 0:q.upsert({twoWaySync:!0})),await ce.cache.put({id:ko,value:"true"});return}const z=await(q==null?void 0:q.getSetting("myWorkflowsDir"));p(x.jsx(Wp,{myWorkflowsDir:z??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{await(q==null?void 0:q.upsert({twoWaySync:!0})),await(q==null?void 0:q.getSetting("twoWaySync"))&&(ce.cache.put({id:ko,value:"true"}),location.reload())},colorScheme:"red"}],{closeOnOverlayClick:!1})}})},E=()=>{Vp.forEach(O=>{Qs.addEventListener(O,()=>null)})},N=()=>{if(l.current==null)return!1;const O=V==null?void 0:V.curWorkflow;if(O==null)return!1;if(O.json==null)return!0;const J=_e.graph.serialize()??{};let M={};try{M=O!=null&&O.json?JSON.parse(O==null?void 0:O.json):{}}catch(z){console.error("error parsing json",z)}return!Up(J,M)},I=async(O,J)=>{if(_e.graph==null)return;const M=await(V==null?void 0:V.get(O));if(M==null){alert("Error: Workflow not found! id: "+O),C(null);return}const Q=J?await(we==null?void 0:we.get(J)):null;_e.ui.dialog.close(),Q?(m(Q),C({...M,json:Q.json}),_e.loadGraphData(JSON.parse(Q.json))):(C(M),m(null),_e.loadGraphData(JSON.parse(M.json))),r("root"),u&&c(!1)},F=async(O,J,M=!1)=>{if(O===null){C(null),_e.graph.clear();return}if(!u||M||await(q==null?void 0:q.getSetting("autoSave"))){I(O,J);return}$(O)},$=async O=>{var M,Q;const J=[O?{label:"Open in new tab",icon:x.jsx(xl,{}),onClick:()=>{jh(O)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await g(),O&&I(O)}}];((M=V==null?void 0:V.curWorkflow)==null?void 0:M.lastSavedJson)!=null?J.push({label:"Discard",colorScheme:"red",onClick:async()=>{O&&I(O)}}):J.push({label:"Delete",colorScheme:"red",onClick:async()=>{await _(),O&&I(O)}}),p(`Please save or discard your changes to "${(Q=V==null?void 0:V.curWorkflow)==null?void 0:Q.name}" before leaving, or your changes will be lost.`,J)},P=async O=>{const J=(O==null?void 0:O.json)??JSON.stringify(Sr),M=await(V==null?void 0:V.createFlow({json:J,name:O==null?void 0:O.name}));M&&await F(M.id),r("root")},B=async(O,J=!1)=>{const M=O.split("/").pop()??O;J?g():P({name:M});const Q=await fetch(Dh(O)),z=await Q.blob(),T=new File([z],M,{type:Q.headers.get("Content-Type")||""});await _e.handleFile(T),r("root")},b=async(O,J)=>{const M=await(V==null?void 0:V.get(O));if(M==null)return;const Q=await(V==null?void 0:V.createFlow({json:M.json,lastSavedJson:M.lastSavedJson,name:J||M.name,parentFolderID:M.parentFolderID,tags:M.tags}));Q&&await F(Q.id)},K=A.useCallback(O=>{if(l.current==null)return;let J=O.filename;O.subfolder!=null&&O.subfolder!==""&&(J=O.subfolder+"/"+J),Ht==null||Ht.create({workflowID:l.current,localPath:J})},[]),te=A.useCallback(()=>{r("root")},[]);return A.useEffect(()=>{j(),v(!0);const O=document.getElementById("comfy-file-input"),J=async()=>{if(O&&O.files&&O.files.length>0){const T={id:zn(),name:O.files[0].name,json:JSON.stringify(Sr),updateTime:Date.now(),createTime:Date.now()};C(T),await(V==null?void 0:V.createFlow(T))}};O==null||O.addEventListener("change",J);const M=T=>{var G,fe;const ne=((G=q==null?void 0:q.settings)==null?void 0:G.autoSave)??!0;if((fe=V==null?void 0:V.curWorkflow)!=null&&fe.saveLock)return;const Y=N();!ne&&Y&&(T.preventDefault(),T.returnValue="You have unsaved changes!",$())};window.addEventListener("beforeunload",M);const Q=T=>{var ne,Y,G,fe,ye,se;(G=(Y=(ne=T.detail)==null?void 0:ne.output)==null?void 0:Y.images)==null||G.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)})};Qs.addEventListener("executed",Q);const z=async T=>{var fe,ye;const ne=(ye=(fe=T.dataTransfer)==null?void 0:fe.files[0])==null?void 0:ye.name,Y=_e.dragOverNode;if(Y&&Y.onDragDrop)return;if(!(await(q==null?void 0:q.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ne){const se={id:zn(),name:ne,json:JSON.stringify(Sr),updateTime:Date.now(),createTime:Date.now()};C(se),await(V==null?void 0:V.createFlow(se))}};return _e.canvasEl.addEventListener("drop",z),()=>{window.removeEventListener("change",J),window.removeEventListener("beforeunload",M),window.removeEventListener("executed",Q),_e.canvasEl.removeEventListener("drop",z)}},[]),o?null:x.jsx(Ct.Provider,{value:{curFlowID:i,onDuplicateWorkflow:b,loadWorkflowID:F,discardUnsavedChanges:k,saveCurWorkflow:g,isDirty:u,setIsDirty:c,loadNewWorkflow:P,loadFilePath:B,setRoute:r,route:n,curVersion:y,setCurVersion:m},children:x.jsx("div",{ref:d,className:"workspace_manager",children:x.jsxs(Ma,{containerRef:d,children:[x.jsxs(jt,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Eh,draggable:!1,children:[x.jsx(Np,{curFlowName:t,setCurFlowName:e}),h&&n==="recentFlows"&&x.jsx(A.Suspense,{children:x.jsx(Kp,{onClose:te,onClickNewFlow:()=>{P(),r("root")}})}),n==="gallery"&&x.jsx(A.Suspense,{children:x.jsx($p,{onclose:()=>r("root")})})]}),x.jsx(Fp,{})]})})})}const Em=Object.freeze(Object.defineProperty({__proto__:null,default:Hp},Symbol.toStringTag,{value:"Module"}));export{am as $,Na as A,jt as B,V as C,fp as D,gh as E,Wt as F,dp as G,rt as H,Tn as I,Lp as J,Xh as K,im as L,xi as M,Qh as N,Nh as O,Le as P,Yr as Q,ym as R,Fd as S,Gt as T,Qr as U,Xr as V,sp as W,Sr as X,cm as Y,Er as Z,Wh as _,Yp as a,xc as a0,Ei as a1,ki as a2,Di as a3,Ci as a4,Oi as a5,Si as a6,Ct as a7,kl as a8,Ht as a9,rm as aA,om as aB,Uc as aC,gm as aD,Bp as aE,zh as aF,hm as aG,vm as aH,ks as aI,kr as aJ,yn as aK,_m as aL,si as aM,we as aN,bm as aO,xm as aP,Op as aQ,km as aR,ot as aS,hc as aT,Em as aU,jh as aa,xl as ab,vl as ac,yt as ad,pc as ae,Eh as af,nm as ag,us as ah,um as ai,Ha as aj,fm as ak,qa as al,Mh as am,sn as an,on as ao,kc as ap,Up as aq,lm as ar,dm as as,qe as at,Xl as au,ce as av,wm as aw,xf as ax,pm as ay,mm as az,Kc as b,em as c,Xp as d,Qp as e,gn as f,no as g,Ne as h,lp as i,Ka as j,He as k,wt as l,$c as m,bt as n,vn as o,q as p,Wp as q,_f as r,tm as s,Or as t,to as u,sm as v,jo as w,Fs as x,Rs as y,pt as z}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-T1peQu-u.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-K7XRJ7NL-Vyo84f0U.js","workspace_web/IconCopy-JFcpuy1G.js","workspace_web/AppIsDirtyEventListener-TdXJ5J_h.js","workspace_web/useDebounceFn-ld478fd0.js","workspace_web/ModelManagerTopbar-7VH-2Gbw.js","workspace_web/chunk-JARCRF6W-au6_4y-J.js","workspace_web/chunk-3RSXBRAN-FQauAkwt.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css","workspace_web/SpotlightSearch-BOOXnLDY.js","workspace_web/IconSearch-UuijGRkv.js","workspace_web/chunk-NTCQBYKE-3mwSHd_c.js","workspace_web/RecentFilesDrawer-O5CnaDXe.js","workspace_web/MediaPreview-6zXFhr_g.js","workspace_web/GalleryModal-Rpu1lZvh.js"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file diff --git a/dist/workspace_web/AppIsDirtyEventListener-TdXJ5J_h.js b/dist/workspace_web/AppIsDirtyEventListener-TdXJ5J_h.js deleted file mode 100644 index ac04deb..0000000 --- a/dist/workspace_web/AppIsDirtyEventListener-TdXJ5J_h.js +++ /dev/null @@ -1 +0,0 @@ -import{r as l,j as m}from"./input.js";import{app as t}from"/scripts/app.js";import{a7 as C,j as D,aq as j,n as W,T as _,ar as x,E as p,as as I,C as n,p as d,at as R}from"./App-olu4rPJF.js";import{u as L}from"./useDebounceFn-ld478fd0.js";import"/scripts/api.js";function F(){const{isDirty:w,setIsDirty:v,setRoute:k,saveCurWorkflow:S}=l.useContext(C),y=l.useRef(w),[g,E]=l.useState(!1);D();const h=l.useRef(null);l.useEffect(()=>{var i,c;const s=e=>{var u;if(document.visibilityState==="hidden")return;const r=I(e);if(r)switch(e.preventDefault(),window.dispatchEvent(new CustomEvent(x,{detail:{shortcutType:r}})),r){case p.SAVE:S();break;case p.SAVE_AS:k("saveAsModal");break;case p.openSpotlightSearch:k("spotlightSearch");break}else(u=e.target)!=null&&u.matches("input, textarea")&&Object.keys(t.canvas.selected_nodes??{}).length&&f()},o=t.canvas.onAfterChange;t.graph.onAfterChange=function(){o==null||o.apply(this,arguments),f()};const a=t.graph.onConfigure;return t.graph.onConfigure=function(){a==null||a.apply(this,arguments),setTimeout(()=>{var r,u;j(t.graph.serialize(),JSON.parse(((u=(r=n)==null?void 0:r.curWorkflow)==null?void 0:u.json)??"{}"))||f()},1e3)},document.addEventListener("click",e=>{Object.keys(t.canvas.selected_nodes??{}).length&&(t.canvas.node_over!=null||t.canvas.node_capturing_input!=null||t.canvas.node_widget!=null)&&f()}),document.addEventListener("keydown",s),(c=(i=d)==null?void 0:i.settings)!=null&&c.autoSave&&d.settings.autoSaveDuration&&(h.current=setInterval(()=>{T()},d.settings.autoSaveDuration*1e3)),()=>{document.removeEventListener("keydown",s),h.current&&clearInterval(h.current)}},[]);const T=async()=>{var o,a,i,c,e;if(!((a=(o=n)==null?void 0:o.curWorkflow)!=null&&a.id))return;const s=JSON.stringify(t.graph.serialize());s!==((i=n)==null?void 0:i.curWorkflow.json)&&(await((c=n)==null?void 0:c.updateFlow(n.curWorkflow.id,{json:s})),(e=R)==null||e.create({workflowID:n.curWorkflow.id,isAutoSave:!0,json:s}),v(!1))},b=async()=>{var s,o,a,i,c,e,r;(o=(s=n)==null?void 0:s.curWorkflow)!=null&&o.saveLock||(!w&&v(!0),y.current=!0,(i=(a=d)==null?void 0:a.settings)!=null&&i.autoSave&&((e=(c=n)==null?void 0:c.curWorkflow)!=null&&e.id)&&!g&&(await((r=n)==null?void 0:r.latestVersionCheck())||E(!0)))},[f,A]=L(b,500);return g?m.jsx(W,{label:"This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.",children:m.jsx(_,{colorScheme:"yellow",children:"⚠️Outdated version"})}):null}export{F as default}; diff --git a/dist/workspace_web/GalleryModal-Rpu1lZvh.js b/dist/workspace_web/GalleryModal-Rpu1lZvh.js deleted file mode 100644 index ac1ffef..0000000 --- a/dist/workspace_web/GalleryModal-Rpu1lZvh.js +++ /dev/null @@ -1 +0,0 @@ -import{r as u,d as be,y as Ot,m as we,b as ut,f as A,l as dt,o as Ae,E as Gt,j as r,g as _,h as ht,p as Ut,W as Ht,i as Kt,M as Wt,N as Yt,O as Xt,Q as Zt,R as qt,S as Jt}from"./input.js";import{aj as Qt,a0 as en,h as Fe,F as v,ak as tn,al as nn,I as z,o as sn,k as Ee,B as ft,l as V,a7 as $e,am as rn,C as ne,H as Y,n as W,A as mt,ac as pt,a9 as L,i as an,an as on,G as ln}from"./App-olu4rPJF.js";import{c as je,p as cn,r as rt,v as at,I as un,N as dn,a as hn,b as fn,d as mn,e as pn,M as xt,u as xn,S as gn}from"./MediaPreview-6zXFhr_g.js";import{S as vn}from"./chunk-3RSXBRAN-FQauAkwt.js";import{u as yn,C as Ve,G as Sn}from"./chunk-JARCRF6W-au6_4y-J.js";import{app as ot}from"/scripts/app.js";import{L as Ne}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import"/scripts/api.js";import"./IconSearch-UuijGRkv.js";import"./index-pz0vT7Or.js";const gt=1/60*1e3,bn=typeof performance<"u"?()=>performance.now():()=>Date.now(),vt=typeof window<"u"?e=>window.requestAnimationFrame(e):e=>setTimeout(()=>e(bn()),gt);function wn(e){let t=[],s=[],n=0,a=!1,o=!1;const l=new WeakSet,i={schedule:(c,h=!1,m=!1)=>{const f=m&&a,g=f?t:s;return h&&l.add(c),g.indexOf(c)===-1&&(g.push(c),f&&a&&(n=t.length)),c},cancel:c=>{const h=s.indexOf(c);h!==-1&&s.splice(h,1),l.delete(c)},process:c=>{if(a){o=!0;return}if(a=!0,[t,s]=[s,t],s.length=0,n=t.length,n)for(let h=0;h(e[t]=wn(()=>X=!0),e),{}),kn=Z.reduce((e,t)=>{const s=le[t];return e[t]=(n,a=!1,o=!1)=>(X||In(),s.schedule(n,a,o)),e},{}),Pn=Z.reduce((e,t)=>(e[t]=le[t].cancel,e),{});Z.reduce((e,t)=>(e[t]=()=>le[t].process(B),e),{});const Cn=e=>le[e].process(B),yt=e=>{X=!1,B.delta=_e?gt:Math.max(Math.min(e-B.timestamp,jn),1),B.timestamp=e,Me=!0,Z.forEach(Cn),Me=!1,X&&(_e=!1,vt(yt))},In=()=>{X=!0,_e=!0,Me||vt(yt)},lt=()=>B;var $=e=>e?"":void 0,ke=e=>e?!0:void 0,q=(...e)=>e.filter(Boolean).join(" ");function Pe(...e){return function(s){e.some(n=>(n==null||n(s),s==null?void 0:s.defaultPrevented))}}function ee(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}var se={width:0,height:0},te=e=>e||se;function Tn(e){const{orientation:t,thumbPercents:s,thumbRects:n,isReversed:a}=e,o=y=>{var S;const E=(S=n[y])!=null?S:se;return{position:"absolute",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",touchAction:"none",...ee({orientation:t,vertical:{bottom:`calc(${s[y]}% - ${E.height/2}px)`},horizontal:{left:`calc(${s[y]}% - ${E.width/2}px)`}})}},l=t==="vertical"?n.reduce((y,S)=>te(y).height>te(S).height?y:S,se):n.reduce((y,S)=>te(y).width>te(S).width?y:S,se),i={position:"relative",touchAction:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",userSelect:"none",outline:0,...ee({orientation:t,vertical:l?{paddingLeft:l.width/2,paddingRight:l.width/2}:{},horizontal:l?{paddingTop:l.height/2,paddingBottom:l.height/2}:{}})},c={position:"absolute",...ee({orientation:t,vertical:{left:"50%",transform:"translateX(-50%)",height:"100%"},horizontal:{top:"50%",transform:"translateY(-50%)",width:"100%"}})},h=s.length===1,m=[0,a?100-s[0]:s[0]],f=h?m:s;let g=f[0];!h&&a&&(g=100-g);const x=Math.abs(f[f.length-1]-f[0]),j={...c,...ee({orientation:t,vertical:a?{height:`${x}%`,top:`${g}%`}:{height:`${x}%`,bottom:`${g}%`},horizontal:a?{width:`${x}%`,right:`${g}%`}:{width:`${x}%`,left:`${g}%`}})};return{trackStyle:c,innerTrackStyle:j,rootStyle:i,getThumbStyle:o}}function En(e){const{isReversed:t,direction:s,orientation:n}=e;return s==="ltr"||n==="vertical"?t:!t}function Nn(e,t,s,n){return e.addEventListener(t,s,n),()=>{e.removeEventListener(t,s,n)}}function _n(e){const t=Dn(e);return typeof t.PointerEvent<"u"&&e instanceof t.PointerEvent?e.pointerType==="mouse":e instanceof t.MouseEvent}function St(e){return!!e.touches}function Mn(e){return St(e)&&e.touches.length>1}function Dn(e){var t;return(t=e.view)!=null?t:window}function Rn(e,t="page"){const s=e.touches[0]||e.changedTouches[0];return{x:s[`${t}X`],y:s[`${t}Y`]}}function zn(e,t="page"){return{x:e[`${t}X`],y:e[`${t}Y`]}}function bt(e,t="page"){return St(e)?Rn(e,t):zn(e,t)}function An(e){return t=>{const s=_n(t);(!s||s&&t.button===0)&&e(t)}}function Fn(e,t=!1){function s(a){e(a,{point:bt(a)})}return t?An(s):s}function re(e,t,s,n){return Nn(e,t,Fn(s,t==="pointerdown"),n)}var $n=Object.defineProperty,Vn=(e,t,s)=>t in e?$n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,N=(e,t,s)=>(Vn(e,typeof t!="symbol"?t+"":t,s),s),Bn=class{constructor(e,t,s){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 i=Ce(this.lastEventInfo,this.history),c=this.startEvent!==null,h=Un(i.offset,{x:0,y:0})>=this.threshold;if(!c&&!h)return;const{timestamp:m}=lt();this.history.push({...i.point,timestamp:m});const{onStart:f,onMove:g}=this.handlers;c||(f==null||f(this.lastEvent,i),this.startEvent=this.lastEvent),g==null||g(this.lastEvent,i)}),N(this,"onPointerMove",(i,c)=>{this.lastEvent=i,this.lastEventInfo=c,kn.update(this.updatePoint,!0)}),N(this,"onPointerUp",(i,c)=>{const h=Ce(c,this.history),{onEnd:m,onSessionEnd:f}=this.handlers;f==null||f(i,h),this.end(),!(!m||!this.startEvent)&&(m==null||m(i,h))});var n;if(this.win=(n=e.view)!=null?n:window,Mn(e))return;this.handlers=t,s&&(this.threshold=s),e.stopPropagation(),e.preventDefault();const a={point:bt(e)},{timestamp:o}=lt();this.history=[{...a.point,timestamp:o}];const{onSessionStart:l}=t;l==null||l(e,Ce(a,this.history)),this.removeListeners=Gn(re(this.win,"pointermove",this.onPointerMove),re(this.win,"pointerup",this.onPointerUp),re(this.win,"pointercancel",this.onPointerUp))}updateHandlers(e){this.handlers=e}end(){var e;(e=this.removeListeners)==null||e.call(this),Pn.update(this.updatePoint)}};function it(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ce(e,t){return{point:e.point,delta:it(e.point,t[t.length-1]),offset:it(e.point,t[0]),velocity:On(t,.1)}}var Ln=e=>e*1e3;function On(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const a=e[e.length-1];for(;s>=0&&(n=e[s],!(a.timestamp-n.timestamp>Ln(t)));)s--;if(!n)return{x:0,y:0};const o=(a.timestamp-n.timestamp)/1e3;if(o===0)return{x:0,y:0};const l={x:(a.x-n.x)/o,y:(a.y-n.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function Gn(...e){return t=>e.reduce((s,n)=>n(s),t)}function Ie(e,t){return Math.abs(e-t)}function ct(e){return"x"in e&&"y"in e}function Un(e,t){if(typeof e=="number"&&typeof t=="number")return Ie(e,t);if(ct(e)&&ct(t)){const s=Ie(e.x,t.x),n=Ie(e.y,t.y);return Math.sqrt(s**2+n**2)}return 0}function wt(e){const t=u.useRef(null);return t.current=e,t}function Hn(e,t){const{onPan:s,onPanStart:n,onPanEnd:a,onPanSessionStart:o,onPanSessionEnd:l,threshold:i}=t,c=!!(s||n||a||o||l),h=u.useRef(null),m=wt({onSessionStart:o,onSessionEnd:l,onStart:n,onMove:s,onEnd(f,g){h.current=null,a==null||a(f,g)}});u.useEffect(()=>{var f;(f=h.current)==null||f.updateHandlers(m.current)}),u.useEffect(()=>{const f=e.current;if(!f||!c)return;function g(x){h.current=new Bn(x,m.current,i)}return re(f,"pointerdown",g)},[e,c,m,i]),u.useEffect(()=>()=>{var f;(f=h.current)==null||f.end(),h.current=null},[])}function Kn(e,t){if(!e){t(void 0);return}t({width:e.offsetWidth,height:e.offsetHeight});const s=e.ownerDocument.defaultView??window,n=new s.ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const[o]=a;let l,i;if("borderBoxSize"in o){const c=o.borderBoxSize,h=Array.isArray(c)?c[0]:c;l=h.inlineSize,i=h.blockSize}else l=e.offsetWidth,i=e.offsetHeight;t({width:l,height:i})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}var Wn=globalThis!=null&&globalThis.document?u.useLayoutEffect:u.useEffect;function Yn(e,t){var s,n;if(!e||!e.parentElement)return;const a=(n=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?n:window,o=new a.MutationObserver(()=>{t()});return o.observe(e.parentElement,{childList:!0}),()=>{o.disconnect()}}function Xn({getNodes:e,observeMutation:t=!0}){const[s,n]=u.useState([]),[a,o]=u.useState(0);return Wn(()=>{const l=e(),i=l.map((c,h)=>Kn(c,m=>{n(f=>[...f.slice(0,h),m,...f.slice(h+1)])}));if(t){const c=l[0];i.push(Yn(c,()=>{o(h=>h+1)}))}return()=>{i.forEach(c=>{c==null||c()})}},[a]),s}function Zn(e){return typeof e=="object"&&e!==null&&"current"in e}function qn(e){const[t]=Xn({observeMutation:!1,getNodes(){return[Zn(e)?e.current:e]}});return t}function Jn(e){var t;const{min:s=0,max:n=100,onChange:a,value:o,defaultValue:l,isReversed:i,direction:c="ltr",orientation:h="horizontal",id:m,isDisabled:f,isReadOnly:g,onChangeStart:x,onChangeEnd:j,step:y=1,getAriaValueText:S,"aria-valuetext":E,"aria-label":F,"aria-labelledby":J,name:O,focusThumbOnChange:k=!0,...P}=e,Le=be(x),G=be(j),Oe=be(S),T=En({isReversed:i,direction:c,orientation:h}),[Et,de]=Qt({value:o,defaultValue:l??es(s,n),onChange:a}),[he,Ge]=u.useState(!1),[fe,Ue]=u.useState(!1),me=!(f||g),pe=(n-s)/10,U=y||(n-s)/100,b=je(Et,s,n),Nt=n-b+s,He=at(T?Nt:b,s,n),Q=h==="vertical",w=wt({min:s,max:n,step:y,isDisabled:f,value:b,isInteractive:me,isReversed:T,isVertical:Q,eventSource:null,focusThumbOnChange:k,orientation:h}),xe=u.useRef(null),ge=u.useRef(null),Ke=u.useRef(null),_t=u.useId(),We=m??_t,[Ye,Xe]=[`slider-thumb-${We}`,`slider-track-${We}`],Mt=u.useCallback(d=>{var p,H;if(!xe.current)return;const C=w.current;C.eventSource="pointer";const M=xe.current.getBoundingClientRect(),{clientX:ye,clientY:Vt}=(H=(p=d.touches)==null?void 0:p[0])!=null?H:d,Bt=Q?M.bottom-Vt:ye-M.left,Lt=Q?M.height:M.width;let Se=Bt/Lt;T&&(Se=1-Se);let K=cn(Se,C.min,C.max);return C.step&&(K=parseFloat(rt(K,C.min,C.step))),K=je(K,C.min,C.max),K},[Q,T,w]),D=u.useCallback(d=>{const p=w.current;p.isInteractive&&(d=parseFloat(rt(d,p.min,U)),d=je(d,p.min,p.max),de(d))},[U,de,w]),R=u.useMemo(()=>({stepUp(d=U){const p=T?b-d:b+d;D(p)},stepDown(d=U){const p=T?b+d:b-d;D(p)},reset(){D(l||0)},stepTo(d){D(d)}}),[D,T,b,U,l]),Ze=u.useCallback(d=>{const p=w.current,C={ArrowRight:()=>R.stepUp(),ArrowUp:()=>R.stepUp(),ArrowLeft:()=>R.stepDown(),ArrowDown:()=>R.stepDown(),PageUp:()=>R.stepUp(pe),PageDown:()=>R.stepDown(pe),Home:()=>D(p.min),End:()=>D(p.max)}[d.key];C&&(d.preventDefault(),d.stopPropagation(),C(d),p.eventSource="keyboard")},[R,D,pe,w]),qe=(t=Oe==null?void 0:Oe(b))!=null?t:E,ve=qn(ge),{getThumbStyle:Je,rootStyle:Qe,trackStyle:et,innerTrackStyle:tt}=u.useMemo(()=>{const d=w.current,p=ve??{width:0,height:0};return Tn({isReversed:T,orientation:d.orientation,thumbRects:[p],thumbPercents:[He]})},[T,ve,He,w]),nt=u.useCallback(()=>{w.current.focusThumbOnChange&&setTimeout(()=>{var p;return(p=ge.current)==null?void 0:p.focus()})},[w]);Ot(()=>{const d=w.current;nt(),d.eventSource==="keyboard"&&(G==null||G(d.value))},[b,G]);function st(d){const p=Mt(d);p!=null&&p!==w.current.value&&de(p)}Hn(Ke,{onPanSessionStart(d){const p=w.current;p.isInteractive&&(Ge(!0),nt(),st(d),Le==null||Le(p.value))},onPanSessionEnd(){const d=w.current;d.isInteractive&&(Ge(!1),G==null||G(d.value))},onPan(d){w.current.isInteractive&&st(d)}});const Dt=u.useCallback((d={},p=null)=>({...d,...P,ref:we(p,Ke),tabIndex:-1,"aria-disabled":ke(f),"data-focused":$(fe),style:{...d.style,...Qe}}),[P,f,fe,Qe]),Rt=u.useCallback((d={},p=null)=>({...d,ref:we(p,xe),id:Xe,"data-disabled":$(f),style:{...d.style,...et}}),[f,Xe,et]),zt=u.useCallback((d={},p=null)=>({...d,ref:p,style:{...d.style,...tt}}),[tt]),At=u.useCallback((d={},p=null)=>({...d,ref:we(p,ge),role:"slider",tabIndex:me?0:void 0,id:Ye,"data-active":$(he),"aria-valuetext":qe,"aria-valuemin":s,"aria-valuemax":n,"aria-valuenow":b,"aria-orientation":h,"aria-disabled":ke(f),"aria-readonly":ke(g),"aria-label":F,"aria-labelledby":F?void 0:J,style:{...d.style,...Je(0)},onKeyDown:Pe(d.onKeyDown,Ze),onFocus:Pe(d.onFocus,()=>Ue(!0)),onBlur:Pe(d.onBlur,()=>Ue(!1))}),[me,Ye,he,qe,s,n,b,h,f,g,F,J,Je,Ze]),Ft=u.useCallback((d,p=null)=>{const H=!(d.valuen),C=b>=d.value,M=at(d.value,s,n),ye={position:"absolute",pointerEvents:"none",...Qn({orientation:h,vertical:{bottom:T?`${100-M}%`:`${M}%`},horizontal:{left:T?`${100-M}%`:`${M}%`}})};return{...d,ref:p,role:"presentation","aria-hidden":!0,"data-disabled":$(f),"data-invalid":$(!H),"data-highlighted":$(C),style:{...d.style,...ye}}},[f,T,n,s,h,b]),$t=u.useCallback((d={},p=null)=>({...d,ref:p,type:"hidden",value:b,name:O}),[O,b]);return{state:{value:b,isFocused:fe,isDragging:he},actions:R,getRootProps:Dt,getTrackProps:Rt,getInnerTrackProps:zt,getThumbProps:At,getMarkerProps:Ft,getInputProps:$t}}function Qn(e){const{orientation:t,vertical:s,horizontal:n}=e;return t==="vertical"?s:n}function es(e,t){return t"}),[ns,ce]=ut({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:""}),jt=A((e,t)=>{var s;const n={...e,orientation:(s=e==null?void 0:e.orientation)!=null?s:"horizontal"},a=dt("Slider",n),o=Ae(n),{direction:l}=Gt();o.direction=l;const{getInputProps:i,getRootProps:c,...h}=Jn(o),m=c(),f=i({},t);return r.jsx(ts,{value:h,children:r.jsx(ns,{value:a,children:r.jsxs(_.div,{...m,className:q("chakra-slider",n.className),__css:a.container,children:[n.children,r.jsx("input",{...f})]})})})});jt.displayName="Slider";var kt=A((e,t)=>{const{getThumbProps:s}=ie(),n=ce(),a=s(e,t);return r.jsx(_.div,{...a,className:q("chakra-slider__thumb",e.className),__css:n.thumb})});kt.displayName="SliderThumb";var Pt=A((e,t)=>{const{getTrackProps:s}=ie(),n=ce(),a=s(e,t);return r.jsx(_.div,{...a,className:q("chakra-slider__track",e.className),__css:n.track})});Pt.displayName="SliderTrack";var Ct=A((e,t)=>{const{getInnerTrackProps:s}=ie(),n=ce(),a=s(e,t);return r.jsx(_.div,{...a,className:q("chakra-slider__filled-track",e.className),__css:n.filledTrack})});Ct.displayName="SliderFilledTrack";var ss=A((e,t)=>{const{getMarkerProps:s}=ie(),n=ce(),a=s(e,t);return r.jsx(_.div,{...a,className:q("chakra-slider__marker",e.className),__css:n.mark})});ss.displayName="SliderMark";var De=A(function(t,s){const n=dt("Switch",t),{spacing:a="0.5rem",children:o,...l}=Ae(t),{getIndicatorProps:i,getInputProps:c,getCheckboxProps:h,getRootProps:m,getLabelProps:f}=yn(l),g=u.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...n.container}),[n.container]),x=u.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...n.track}),[n.track]),j=u.useMemo(()=>({userSelect:"none",marginStart:a,...n.label}),[a,n.label]);return r.jsxs(_.label,{...m(),className:ht("chakra-switch",t.className),__css:g,children:[r.jsx("input",{className:"chakra-switch__input",...c({},s)}),r.jsx(_.span,{...h(),className:"chakra-switch__track",__css:x,children:r.jsx(_.span,{__css:n.thumb,className:"chakra-switch__thumb",...i()})}),o&&r.jsx(_.span,{className:"chakra-switch__label",...f(),__css:j,children:o})]})});De.displayName="Switch";function rs(e,t=[]){const s=Object.assign({},e);for(const n of t)n in s&&delete s[n];return s}var as=["h","minH","height","minHeight"],It=A((e,t)=>{const s=Ut("Textarea",e),{className:n,rows:a,...o}=Ae(e),l=en(o),i=a?rs(s,as):s;return r.jsx(_.textarea,{ref:t,rows:a,...l,className:ht("chakra-textarea",n),__css:i})});It.displayName="Textarea";var os=Fe("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),ls=Fe("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"}]]),is=Fe("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 cs=({setMediaAct:e,media:t,currentNum:s})=>{const n=l=>{const i=(s+l+t.length)%t.length;e&&e(t[i])},a={width:"100%",height:"100%"};if(t.length===0)return r.jsx("p",{children:"No images found, let's start generating 🪄"});const o=t.at(s);return o?r.jsxs(v,{justifyContent:"center",alignItems:"center",position:"relative",width:a.width,height:a.height,overflow:"hidden",children:[r.jsx("div",{style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%"},onClick:()=>{window.open(o.imageUrl)},children:tn(o.imageUrl)?r.jsx(nn,{src:o.imageUrl,alt:`image-${o.id}`,width:"100%",height:"100%",objectFit:"contain"}):r.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:o.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:r.jsx("track",{kind:"captions"})})},o.id),r.jsx(z,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:r.jsx(os,{}),onClick:()=>n(-1),position:"absolute",left:"0",zIndex:"2"}),r.jsx(z,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:r.jsx(un,{}),onClick:()=>n(1),position:"absolute",right:"0",zIndex:"2"})]}):null},us=({inputItem:e})=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.label??e.inputName}),r.jsx(sn,{value:e.inputValue,onChange:t=>{}})]}),ds=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsxs(dn,{width:"100%",step:e==null?void 0:e.step,value:t.inputValue,min:e==null?void 0:e.min,max:e==null?void 0:e.max,onChange:s=>{},children:[r.jsx(hn,{}),r.jsxs(fn,{children:[r.jsx(mn,{}),r.jsx(pn,{})]})]})]}),r.jsx(v,{children:r.jsxs(jt,{maxWidth:"400px",step:e==null?void 0:e.step,value:Number(t.inputValue),min:(e==null?void 0:e.min)??0,max:(e==null?void 0:e.max)??100,onChange:s=>{},children:[r.jsx(Pt,{children:r.jsx(Ct,{})}),r.jsx(kt,{})]})})]})},hs=e=>{var s;const{inputItem:t}=e;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(vn,{value:t.inputValue,onChange:n=>{},children:(s=e==null?void 0:e.options)==null?void 0:s.map((n,a)=>r.jsx("option",{value:n,children:n},`select${t.nodeID}${t.inputName}${a}`))})]})},fs=e=>{const t=e.inputItem;return r.jsxs(v,{gap:1,direction:"column",children:[r.jsx(v,{children:t.label??t.inputName}),r.jsx(It,{value:t.inputValue,onChange:s=>{},rows:5})]})};var I=(e=>(e.Input="Input",e.InputSlider="InputSlider",e.Select="Select",e.Textarea="Textarea",e.Checkbox="Checkbox",e.NoSupport="NoSupport",e))(I||{});const ms=e=>r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:e.inputItem.label??e.inputItem.inputName}),r.jsx(v,{children:"No Support"})]}),ps=e=>{const t=e.inputItem;return r.jsxs(v,{gap:2,children:[r.jsx(v,{gap:1,alignItems:"center",flexBasis:"200px",children:t.label??t.inputName}),r.jsx(Ve,{defaultChecked:!!t.inputValue,onChange:s=>{var n;(n=e==null?void 0:e.updateMetaData)==null||n.call(e,{promptKey:e.promptKey,name:e.name,value:s.target.checked})}})]})},ue=u.createContext({topFields:[],calcInputList:[],showNodeName:!1,updateTopField(){}}),xs={[I.Input]:us,[I.InputSlider]:ds,[I.Select]:hs,[I.Textarea]:fs,[I.Checkbox]:ps,NoSupport:ms},gs=LiteGraph.registered_node_types;function vs(e,t){var a,o,l,i,c;const s=(a=gs[e])==null?void 0:a.nodeData,n={...((o=s==null?void 0:s.input)==null?void 0:o.required)??{},...((l=s==null?void 0:s.input)==null?void 0:l.optional)??{}}[t];return(n==null?void 0:n[0])==="STRING"?(i=n==null?void 0:n[1])!=null&&i.multiline?{type:I.Textarea}:{type:I.Input}:(n==null?void 0:n[0])==="BOOLEAN"?{type:I.Checkbox}:(n==null?void 0:n[0])==="FLOAT"?{...(n==null?void 0:n[1])??{},type:I.InputSlider}:(n==null?void 0:n[0])==="INT"?{...(n==null?void 0:n[1])??{},type:I.InputSlider}:Array.isArray(n==null?void 0:n[0])&&((c=n==null?void 0:n[0])!=null&&c.every(h=>typeof h=="string"))?{options:n==null?void 0:n[0],type:I.Select}:{type:I.NoSupport}}const Re=({inputItem:e})=>{const t=vs(e.classType,e.inputName),[s,n]=u.useState(!1),a=xs[t.type??"Input"],{updateTopField:o,topFields:l}=u.useContext(ue),i=e.children[0]==="negative"||e.children[0]==="positive"?`-${e.children[0]}`:"",c={...e,label:e.label??e.inputName+i};return r.jsxs(v,{alignItems:"center",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx(z,{size:"xs",onClick:()=>o==null?void 0:o({name:e.inputName,promptKey:e.nodeID,class_type:e.classType}),variant:"ghost",icon:oe(l,{name:e.inputName,promptKey:e.nodeID,classType:e.classType})?r.jsx(ls,{size:14}):r.jsx(is,{size:14}),"aria-label":"pin"}),r.jsx("div",{style:{flex:1},children:r.jsx(a,{inputItem:c,...t})})]})};function ys(){const{topFields:e,updateTopField:t,calcInputList:s}=u.useContext(ue);return e.length===0?null:r.jsx(r.Fragment,{children:r.jsx(v,{px:2,gap:2,direction:"column",children:e==null?void 0:e.map(n=>{const a=s.find(o=>o.nodeID==n.promptKey&&o.inputName===n.name&&o.classType===n.class_type);return!n.class_type||!a?null:r.jsx(Re,{inputItem:a},`formTopField${n.promptKey}${n.name}`)})})})}function Ss(){const{topFields:e,calcInputList:t,showNodeName:s}=u.useContext(ue),n=u.useCallback(o=>{const l=[];return o.forEach(i=>{const c=l[l.length-1];!c||c[0].nodeID!==i.nodeID||c[0].classType!==i.classType?l.push([i]):c.push(i)}),l},[]);if(u.useEffect(()=>{},[s]),!s)return r.jsx(Ee,{children:t.map(o=>oe(e,{name:o.inputName,promptKey:o.nodeID,classType:o.classType})?null:r.jsx(Re,{inputItem:o},`form${o.nodeID}${o.inputName}`))});const a=n(t);return r.jsx(Ee,{children:a.map(o=>o[0]?r.jsx(bs,{title:o[0].classType+" #"+o[0].nodeID,children:r.jsx(v,{px:2,gap:1,direction:"column",children:o.map(l=>oe(e,{name:l.inputName,promptKey:l.nodeID,classType:l.classType})?null:r.jsx(Re,{inputItem:l},`form${l.nodeID}${l.inputName}`))})},o[0].nodeID):null)})}function bs({title:e,children:t}){return r.jsxs(ft,{border:"1px",borderColor:"gray.500",borderRadius:"md",p:4,children:[r.jsx(V,{size:"sm",mb:1,color:"GrayText",children:e}),r.jsx("div",{children:t})]})}let ae=[],ze=new Set;function Tt(e,t){if(!ze.has(e.nodeID))return ze.add(e.nodeID),Object.entries(e.inputs).forEach(([s,n])=>{if(Array.isArray(n)){const a=n[0];Tt(t[a],t)}}),Object.entries(e.inputs).forEach(([s,n])=>{Array.isArray(n)||ae.push({classType:e.class_type,inputName:s,inputValue:n,nodeID:e.nodeID,children:e.children||[]})}),ae}function ws(e){ae=[],ze=new Set;for(const t of Object.keys(e))e[t].nodeID=t,Object.entries(e[t].inputs).forEach(([s,n])=>{if(Array.isArray(n)){const a=n[0],o=e[a];o.children||(o.children=[]),o.children.push(s)}});for(const t of Object.keys(e))Tt(e[t],e);return ae}const oe=(e,t)=>e==null?void 0:e.some(s=>s.promptKey===(t==null?void 0:t.promptKey)&&s.name===(t==null?void 0:t.name)&&s.class_type===t.classType);function js({media:e}){const[t,s]=u.useState([]),{curFlowID:n}=u.useContext($e),[a,o]=u.useState(),[l,i]=u.useState(!0),[c,h]=u.useState(!0);u.useEffect(()=>{e?rn(`/workspace/view_media?filename=${e.localPath}`).then(x=>{o(x.prompt)}):ot.graphToPrompt(ot.graph).then(x=>{o(x.output)})},[e]),u.useEffect(()=>{if(!a)return;const x=ws(a);s(x)},[a]);const[m,f]=u.useState([]);u.useEffect(()=>{(async()=>{var x,j;if(n){const y=(j=await((x=ne)==null?void 0:x.get(n)))==null?void 0:j.topFieldsConfig;y&&(f(y),i(!1))}})()},[n]);const g=x=>{var j,y;if(oe(m,{name:x.name,promptKey:x==null?void 0:x.promptKey,classType:(x==null?void 0:x.class_type)??""})){const S=m.filter(E=>E.name!==x.name||E.promptKey!==x.promptKey);f(S),n&&((j=ne)==null||j.updateTopFields(n,{topFieldsConfig:S}))}else{const S=[...m,x];f(S),n&&((y=ne)==null||y.updateTopFields(n,{topFieldsConfig:S}))}};return r.jsx(ue.Provider,{value:{topFields:m,showNodeName:c,calcInputList:t,updateTopField:g},children:r.jsxs(v,{direction:"column",align:"stretch",gap:5,children:[r.jsx(ys,{}),r.jsxs(Y,{children:[r.jsx("p",{children:"Show all inputs"}),r.jsx(De,{isChecked:l,onChange:x=>i(!l)}),r.jsx("p",{children:"Show node names"}),r.jsx(De,{isChecked:c,onChange:x=>h(!c)})]}),l&&r.jsx(Ss,{})]})})}const ks=({media:e})=>r.jsxs(v,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[r.jsxs(v,{flexWrap:"wrap",gap:3,children:[r.jsx(v,{alignItems:"center",gap:2,children:(e==null?void 0:e.localPath)&&r.jsxs(r.Fragment,{children:[r.jsx(V,{children:e==null?void 0:e.localPath}),r.jsx(W,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e==null?void 0:e.localPath}`,download:e==null?void 0:e.localPath,children:r.jsx(z,{size:"sm",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})})]})}),r.jsx(v,{gap:1,alignItems:"center",color:"GrayText",children:!!(e!=null&&e.createTime)&&r.jsxs(r.Fragment,{children:[r.jsx(V,{children:"Created:"}),r.jsx(V,{children:pt((e==null?void 0:e.createTime)??0,!0)})]})})]}),r.jsx(js,{media:e??null})]}),Be=u.createContext({showAllImages:!1,curMedia:null,setCurMedia(){},setMediaList(){},setShowAllImages(){}}),Te=120;function Ps({mediaList:e}){const{curMedia:t,setCurMedia:s}=u.useContext(Be);return r.jsxs(v,{gap:3,h:"100%",children:[r.jsxs(Sn,{gridTemplateRows:e.length<=6?"1fr 20%":"1fr",flex:1,gap:2,children:[r.jsx(cs,{media:e.map(n=>({id:n.id,imageUrl:`/workspace/view_media?filename=${n.localPath}`})),currentNum:(e==null?void 0:e.findIndex(n=>n.id===(t==null?void 0:t.id)))??0,setMediaAct:n=>s((e==null?void 0:e.find(a=>a.id===n.id))??null)}),r.jsx(v,{wrap:"wrap",children:e==null?void 0:e.map(n=>r.jsx(ft,{display:"inline-block",p:1,borderRadius:"4px",width:`${Te+3}px`,height:`${Te+3}px`,cursor:"pointer",border:(t==null?void 0:t.id)===n.id?"1px solid gray":"",onClick:()=>s(n),children:r.jsx(xt,{mediaLocalPath:n.localPath,size:Te,objectFit:"contain",hideBrokenImage:!0,onBrokenLink:()=>{var a;(a=L)==null||a.delete(n.id)}})},`image-bottom-${n.id}`))})]}),r.jsx(ks,{media:t??void 0})]})}const Cs=({media:e,isSelecting:t,selectedID:s,onClickMedia:n})=>{const{curFlowID:o,loadFilePath:l}=u.useContext($e),{showDialog:i}=Ht();if(e.localPath==null||o==null)return null;const c=r.jsxs(Ne,{isExternal:!0,onClick:()=>n(e),position:"relative",children:[t&&r.jsx(Ve,{isChecked:s.includes(e.id),position:"absolute",top:2,left:2}),r.jsx(xt,{mediaLocalPath:e.localPath,size:180,onBrokenLink:()=>{var h;(h=L)==null||h.delete(e.id)},hideBrokenImage:!0,autoPlay:!0,isPreview:!0})]});return r.jsxs(Ee,{width:180,mb:2,children:[r.jsx(W,{label:pt(e.createTime,!0),children:c}),r.jsx(W,{label:e.localPath,children:r.jsx(V,{color:"GrayText",noOfLines:1,children:e.localPath})}),r.jsxs(Y,{hidden:t,gap:0,children:[r.jsx(Kt,{flexGrow:1,onClick:()=>i("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{l(e.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>l(e.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),r.jsx(W,{label:"Donwload image from gallery",children:r.jsx(Ne,{href:`/workspace/view_media?filename=${e.localPath}`,download:e.localPath,children:r.jsx(z,{size:"sm",variant:"ghost",icon:r.jsx(mt,{size:19}),"aria-label":"donwload image from gallery"})})}),r.jsx(W,{label:"Remove image from gallery",children:r.jsx(z,{size:"sm",variant:"ghost",icon:r.jsx(an,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var m;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&await((m=L)==null?void 0:m.delete(e.id))}})})]})]})},Is=Cs;function Ts({searchQuery:e}){const[t,s]=u.useState([]),{setCurMedia:n,setShowAllImages:a,setMediaList:o}=u.useContext(Be);u.useEffect(()=>{var i,c;e===""?(i=L)==null||i.listAll().then(h=>{s(h.slice(0,50)??[])}):(c=L)==null||c.filter(h=>{var m;return((m=h.workflowJSON)==null?void 0:m.includes(e))??!1}).then(h=>{s(h)})},[e]);const l=i=>{o([i].concat(t.filter(c=>c.id!==i.id))),n(i),a(!1)};return r.jsx(Y,{wrap:"wrap",children:t.map(i=>r.jsx(Is,{selectedID:[],media:i,isSelecting:!1,onClickMedia:l},i.id))})}function Ls({onclose:e}){const{curFlowID:t}=u.useContext($e),[s,n]=u.useState(""),[a,o]=u.useState([]),[l,i]=u.useState(!1),[c,h]=u.useState(""),[m,f]=u.useState([]),[g,x]=u.useState(),[j,y]=u.useState(""),S=xn(j,300),[E,F]=u.useState(!1),J=async()=>{var P;if(t==null)return;const k=await((P=L)==null?void 0:P.listByWorkflowID(t));f(k??[]),k!=null&&k.length&&x(k[0])};if(u.useEffect(()=>{var k;J(),t&&((k=ne)==null||k.get(t).then(P=>{P&&(n(P.name),P!=null&&P.coverMediaPath&&h(P==null?void 0:P.coverMediaPath))}))},[]),t==null)return null;const O=m.length>0&&a.length===m.length;return r.jsx(Be.Provider,{value:{curMedia:g??null,setCurMedia:x,setMediaList:f,showAllImages:E,setShowAllImages:F},children:r.jsxs(Wt,{isOpen:!0,onClose:e,blockScrollOnMount:!0,children:[r.jsx(Yt,{}),r.jsxs(Xt,{width:"90%",maxWidth:"90vw",height:"90vh",children:[r.jsxs(Zt,{children:[r.jsxs(Y,{gap:2,mb:2,children:[r.jsxs(on,{size:"md",mr:2,children:["Gallery - ",s]}),r.jsx(gn,{searchValue:j,onUpdateSearchValue:k=>{y(k),E||F(!0)},placeholder:"Search prompt, model name, etc.",style:{width:"300px"}})]}),l&&r.jsxs(Y,{gap:3,children:[r.jsx(Ve,{isChecked:O,onChange:()=>{o(O?[]:m.map(k=>k.id))},children:"All"}),r.jsxs(V,{fontSize:16,children:[a.length," Selected"]}),r.jsx(z,{size:"sm",icon:r.jsx(ln,{size:19}),onClick:()=>i(!1),"aria-label":"cancel"})]})]}),r.jsx(qt,{}),r.jsx(Jt,{overflowY:"auto",children:E?r.jsx(Ts,{searchQuery:S}):r.jsx(Ps,{mediaList:m})})]})]})})}export{Ls as default}; diff --git a/dist/workspace_web/IconCopy-JFcpuy1G.js b/dist/workspace_web/IconCopy-JFcpuy1G.js deleted file mode 100644 index f4da2c7..0000000 --- a/dist/workspace_web/IconCopy-JFcpuy1G.js +++ /dev/null @@ -1 +0,0 @@ -import{h as a}from"./App-olu4rPJF.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I}; diff --git a/dist/workspace_web/IconSearch-UuijGRkv.js b/dist/workspace_web/IconSearch-UuijGRkv.js deleted file mode 100644 index 9e07eaa..0000000 --- a/dist/workspace_web/IconSearch-UuijGRkv.js +++ /dev/null @@ -1 +0,0 @@ -import{h as a}from"./App-olu4rPJF.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I}; diff --git a/dist/workspace_web/InstallMissingModelsButton-3G15Fvk5.js b/dist/workspace_web/InstallMissingModelsButton-3G15Fvk5.js deleted file mode 100644 index eeae501..0000000 --- a/dist/workspace_web/InstallMissingModelsButton-3G15Fvk5.js +++ /dev/null @@ -1 +0,0 @@ -import{r as o,j as e,i as C,P as F}from"./input.js";import{app as x}from"/scripts/app.js";import{aS as k,k as I,l as v,H as y,n as S,al as E,ab as b,av as A,a7 as D,aA as z,j as H,B as L,ae as T,af as P,aT as R,F as G,an as O,aH as N}from"./App-olu4rPJF.js";import{G as U,i as W}from"./ModelManagerTopbar-7VH-2Gbw.js";import{C as q,G as B}from"./chunk-JARCRF6W-au6_4y-J.js";import{S as K}from"./chunk-3RSXBRAN-FQauAkwt.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";const Y="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png",$="https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa";function V({model:l,selectedModelDeps:c,setSelectedModelDeps:n,foldersList:d,setFoldersList:h}){var m,t,a,g,_;const[s,u]=o.useState(),p=(a=(t=(m=x.graph.extra)==null?void 0:m[k])==null?void 0:t.deps)==null?void 0:a.models;o.useEffect(()=>{(async()=>{var f;if(p){const M=p[l.received_value];if((f=p[l.received_value])!=null&&f.downloadUrl){const w=await A.models.where({fileHash:M.fileHash}).toArray();w[0]?u({existingModel:w[0].fileName}):u(M)}}})()},[]);const j=c.map(i=>i.filename);function r(i){return i.existingModel!=null}return e.jsx(U,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(I,{align:"start",children:[e.jsx(v,{children:l.class_type}),e.jsx(y,{ml:3,children:e.jsx(v,{color:"red.400",children:l.received_value})}),s&&r(s)&&e.jsxs(v,{children:["This model is already installed as"," ",e.jsx(v,{as:"span",color:"blue.400",fontWeight:600,children:s.existingModel})]}),s&&!r(s)&&s.fileFolder&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{children:[e.jsx(q,{size:"sm",isChecked:j.includes(s.filename),onChange:i=>{i.target.checked?n([...c,p[l.received_value]]):n(c.filter(f=>f.filename!==s.filename))}},s.filename),e.jsx(S,{label:s.infoUrl,children:e.jsx(C,{size:"sm",onClick:i=>{i.stopPropagation(),window.open(s.infoUrl??"","_blank")},leftIcon:e.jsx(E,{width:5,src:(g=s.downloadUrl)!=null&&g.includes("huggingface")?Y:$}),rightIcon:e.jsx(b,{size:20}),children:s.filename})})]}),e.jsxs(I,{children:[e.jsx(v,{width:"fit-content",children:"Install path:"}),((_=d[s.fileFolder])==null?void 0:_.length)&&e.jsx(K,{value:d[s.fileFolder].at(0),onChange:i=>{const f={...d},M=f[s.fileFolder].filter(w=>w!==i.target.value);f[s.fileFolder]=[i.target.value,...M],h(f)},children:d[s.fileFolder].map(i=>e.jsx("option",{value:i,children:i},i))})]})]}),!s&&e.jsx(C,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(b,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v7&query=${l.received_value}`,"_blank")},children:"Search in CivitAI"})]})})}function X({onClose:l,missingModels:c}){o.useEffect(()=>(x.canvasEl.addEventListener("click",l),()=>{x.canvasEl.removeEventListener("click",l)}),[]);const[n,d]=o.useState([]),[h,s]=o.useState({}),{setRoute:u}=o.useContext(D),p=o.useCallback(async()=>{const t=await z();t&&s(t)},[]),j=H();o.useEffect(()=>{p()},[]);const r=480,m=()=>{n.forEach(t=>{let a=t.downloadUrl;if(!a||!t.fileFolder||!h[t.fileFolder][0]){j({title:"Error",description:a?"Model install folder path is missing":"Download URL is missing",status:"error",duration:4e3,isClosable:!0});return}if(a.includes("civitai")){const g=N();g&&(a+=`?token=${g}`)}W({file_hash:t.fileHash??void 0,filename:t.filename,save_path:h[t.fileFolder][0],url:a,force_filename:!0})}),j({title:"Installing...Please open Install Models modal or python terminal to view progress.",description:n.map(t=>t.filename).join(", "),status:"info",duration:4e3,isClosable:!0}),u("installModels")};return e.jsx(F,{children:e.jsx(L,{style:{width:r},children:e.jsxs(T,{width:r,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:P,overflowY:"auto",children:[e.jsx(R,{children:e.jsx(G,{justifyContent:"space-between",alignContent:"center",children:e.jsx(O,{size:"md",mr:2,children:"Missing Models"})})}),e.jsxs(C,{width:"fit-content",colorScheme:"teal",size:"sm",onClick:m,children:["Install Selected (",n.length,")"]}),e.jsx(B,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:c.map(t=>e.jsx(V,{model:t,setSelectedModelDeps:d,selectedModelDeps:n,foldersList:h,setFoldersList:s},t.received_value))})]})})})}function le({}){const[l,c]=o.useState(!1),[n,d]=o.useState([]);return o.useEffect(()=>{const h=x.queuePrompt;x.queuePrompt=async function(){var s,u;try{await h.apply(this,arguments)}finally{if(!((u=(s=x.graph.extra)==null?void 0:s[k])==null?void 0:u.deps))return;const j=x.lastNodeErrors??{};d(Object.values(j).flatMap(r=>{var m,t;return(t=(m=r==null?void 0:r.errors)==null?void 0:m.filter(a=>(a==null?void 0:a.type)==="value_not_in_list"))==null?void 0:t.map(a=>{const{input_name:g,received_value:_}=a.extra_info;return{class_type:r.class_type,input_name:g,received_value:_}})}))}}},[]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(C,{size:"sm","aria-label":"missing models",px:2,onClick:()=>c(!0),colorScheme:"teal",children:["Install Missing (",n.length,")"]}),l&&e.jsx(X,{onClose:()=>c(!1),missingModels:n})]})}export{le as default}; diff --git a/dist/workspace_web/MediaPreview-6zXFhr_g.js b/dist/workspace_web/MediaPreview-6zXFhr_g.js deleted file mode 100644 index a183768..0000000 --- a/dist/workspace_web/MediaPreview-6zXFhr_g.js +++ /dev/null @@ -1 +0,0 @@ -import{d as M,r as s,j as f,I as Ee,y as Oe,e as Be,m as ae,s as C,q as se,b as Pe,f as j,g as Y,l as Ke,o as Ue,h as Me}from"./input.js";import{ao as Ge,ap as qe,h as He,B as Le,I as $e,G as ze,o as We,ak as Xe,al as Ye}from"./App-olu4rPJF.js";import{I as Je}from"./IconSearch-UuijGRkv.js";function Qe(n){const e=parseFloat(n);return typeof e!="number"||Number.isNaN(e)?0:e}function le(n,e){let r=Qe(n);const a=10**(e??10);return r=Math.round(r*a)/a,e?r.toFixed(e):r.toString()}function oe(n){if(!Number.isFinite(n))return 0;let e=1,r=0;for(;Math.round(n*e)/e!==n;)e*=10,r+=1;return r}function It(n,e,r){return(n-e)*100/(r-e)}function yt(n,e,r){return(r-e)*n+e}function Ct(n,e,r){const a=Math.round((n-e)/r)*r+e,u=oe(r);return le(a,u)}function Ze(n,e,r){return n==null?n:(r{var p;return a==null?"":(p=ue(a,o,r))!=null?p:""}),S=typeof u<"u",x=S?u:I,O=Fe(A(x),o),F=r??O,y=s.useCallback(p=>{p!==x&&(S||k(p.toString()),h==null||h(p.toString(),A(p)))},[h,S,x]),w=s.useCallback(p=>{let d=p;return b&&(d=Ze(d,i,m)),le(d,F)},[F,b,m,i]),B=s.useCallback((p=o)=>{let d;x===""?d=A(p):d=A(x)+p,d=w(d),y(d)},[w,o,y,x]),K=s.useCallback((p=o)=>{let d;x===""?d=A(-p):d=A(x)-p,d=w(d),y(d)},[w,o,y,x]),U=s.useCallback(()=>{var p;let d;a==null?d="":d=(p=ue(a,o,r))!=null?p:i,y(d)},[a,r,o,y,i]),Q=s.useCallback(p=>{var d;const ee=(d=ue(p,o,F))!=null?d:i;y(ee)},[F,o,y,i]),E=A(x);return{isOutOfRange:E>m||Ef.jsx(Ee,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M21,5H3C2.621,5,2.275,5.214,2.105,5.553C1.937,5.892,1.973,6.297,2.2,6.6l9,12 c0.188,0.252,0.485,0.4,0.8,0.4s0.611-0.148,0.8-0.4l9-12c0.228-0.303,0.264-0.708,0.095-1.047C21.725,5.214,21.379,5,21,5z"})}),nt=n=>f.jsx(Ee,{viewBox:"0 0 24 24",...n,children:f.jsx("path",{fill:"currentColor",d:"M12.8,5.4c-0.377-0.504-1.223-0.504-1.6,0l-9,12c-0.228,0.303-0.264,0.708-0.095,1.047 C2.275,18.786,2.621,19,3,19h18c0.379,0,0.725-0.214,0.895-0.553c0.169-0.339,0.133-0.744-0.095-1.047L12.8,5.4z"})});function Ae(n,e,r,a){s.useEffect(()=>{var u;if(!n.current||!a)return;const o=(u=n.current.ownerDocument.defaultView)!=null?u:window,i=Array.isArray(e)?e:[e],m=new o.MutationObserver(b=>{for(const h of b)h.type==="attributes"&&h.attributeName&&i.includes(h.attributeName)&&r(h)});return m.observe(n.current,{attributes:!0,attributeFilter:i}),()=>m.disconnect()})}function rt(n,e){const r=M(n);s.useEffect(()=>{let a=null;const u=()=>r();return e!==null&&(a=window.setInterval(u,e)),()=>{a&&window.clearInterval(a)}},[e,r])}var at=50,ke=300;function st(n,e){const[r,a]=s.useState(!1),[u,o]=s.useState(null),[i,m]=s.useState(!0),b=s.useRef(null),h=()=>clearTimeout(b.current);rt(()=>{u==="increment"&&n(),u==="decrement"&&e()},r?at:null);const I=s.useCallback(()=>{i&&n(),b.current=setTimeout(()=>{m(!1),a(!0),o("increment")},ke)},[n,i]),k=s.useCallback(()=>{i&&e(),b.current=setTimeout(()=>{m(!1),a(!0),o("decrement")},ke)},[e,i]),S=s.useCallback(()=>{m(!0),a(!1),h()},[]);return s.useEffect(()=>()=>h(),[]),{up:I,down:k,stop:S,isSpinning:r}}var ut=/^[Ee0-9+\-.]$/;function ot(n){return ut.test(n)}function lt(n,e){if(n.key==null)return!0;const r=n.ctrlKey||n.altKey||n.metaKey;return!(n.key.length===1)||r?!0:e(n.key)}function it(n={}){const{focusInputOnChange:e=!0,clampValueOnBlur:r=!0,keepWithinRange:a=!0,min:u=Number.MIN_SAFE_INTEGER,max:o=Number.MAX_SAFE_INTEGER,step:i=1,isReadOnly:m,isDisabled:b,isRequired:h,isInvalid:I,pattern:k="[0-9]*(.[0-9]+)?",inputMode:S="decimal",allowMouseWheel:x,id:O,onChange:F,precision:y,name:w,"aria-describedby":B,"aria-label":K,"aria-labelledby":U,onFocus:Q,onBlur:E,onInvalid:ce,getAriaValueText:de,isValidCharacter:Z,format:p,parse:d,...ee}=n,te=M(Q),pe=M(E),V=M(ce),G=M(Z??ot),ne=M(de),l=et(n),{update:T,increment:me,decrement:fe}=l,[Ve,re]=s.useState(!1),q=!(m||b),_=s.useRef(null),H=s.useRef(null),be=s.useRef(null),ve=s.useRef(null),L=s.useCallback(t=>t.split("").filter(G).join(""),[G]),$=s.useCallback(t=>{var c;return(c=d==null?void 0:d(t))!=null?c:t},[d]),R=s.useCallback(t=>{var c;return((c=p==null?void 0:p(t))!=null?c:t).toString()},[p]);Oe(()=>{(l.valueAsNumber>o||l.valueAsNumber{if(!_.current)return;if(_.current.value!=l.value){const c=$(_.current.value);l.setValue(L(c))}},[$,L]);const z=s.useCallback((t=i)=>{q&&me(t)},[me,q,i]),W=s.useCallback((t=i)=>{q&&fe(t)},[fe,q,i]),g=st(z,W);Ae(be,"disabled",g.stop,g.isSpinning),Ae(ve,"disabled",g.stop,g.isSpinning);const he=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;const v=$(t.currentTarget.value);T(L(v)),H.current={start:t.currentTarget.selectionStart,end:t.currentTarget.selectionEnd}},[T,L,$]),ge=s.useCallback(t=>{var c,v,N;te==null||te(t),H.current&&(t.target.selectionStart=(v=H.current.start)!=null?v:(c=t.currentTarget.value)==null?void 0:c.length,t.currentTarget.selectionEnd=(N=H.current.end)!=null?N:t.currentTarget.selectionStart)},[te]),xe=s.useCallback(t=>{if(t.nativeEvent.isComposing)return;lt(t,G)||t.preventDefault();const c=Ne(t)*i,v=t.key,P={ArrowUp:()=>z(c),ArrowDown:()=>W(c),Home:()=>T(u),End:()=>T(o)}[v];P&&(t.preventDefault(),P(t))},[G,i,z,W,T,u,o]),Ne=t=>{let c=1;return(t.metaKey||t.ctrlKey)&&(c=.1),t.shiftKey&&(c=10),c},Ie=s.useMemo(()=>{const t=ne==null?void 0:ne(l.value);if(t!=null)return t;const c=l.value.toString();return c||void 0},[l.value,ne]),ye=s.useCallback(()=>{let t=l.value;if(l.value==="")return;/^[eE]/.test(l.value.toString())?l.setValue(""):(l.valueAsNumbero&&(t=o),l.cast(t))},[l,o,u]),Ce=s.useCallback(()=>{re(!1),r&&ye()},[r,re,ye]),X=s.useCallback(()=>{e&&requestAnimationFrame(()=>{var t;(t=_.current)==null||t.focus()})},[e]),Se=s.useCallback(t=>{t.preventDefault(),g.up(),X()},[X,g]),we=s.useCallback(t=>{t.preventDefault(),g.down(),X()},[X,g]);Ge(()=>_.current,"wheel",t=>{var c,v;const P=((v=(c=_.current)==null?void 0:c.ownerDocument)!=null?v:document).activeElement===_.current;if(!x||!P)return;t.preventDefault();const D=Ne(t)*i,_e=Math.sign(t.deltaY);_e===-1?z(D):_e===1&&W(D)},{passive:!1});const Te=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMax;return{...t,ref:ae(c,be),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||Se(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMax,a,Se,g.stop,b]),De=s.useCallback((t={},c=null)=>{const v=b||a&&l.isAtMin;return{...t,ref:ae(c,ve),role:"button",tabIndex:-1,onPointerDown:C(t.onPointerDown,N=>{N.button!==0||v||we(N)}),onPointerLeave:C(t.onPointerLeave,g.stop),onPointerUp:C(t.onPointerUp,g.stop),disabled:v,"aria-disabled":se(v)}},[l.isAtMin,a,we,g.stop,b]),je=s.useCallback((t={},c=null)=>{var v,N,P,D;return{name:w,inputMode:S,type:"text",pattern:k,"aria-labelledby":U,"aria-label":K,"aria-describedby":B,id:O,disabled:b,...t,readOnly:(v=t.readOnly)!=null?v:m,"aria-readonly":(N=t.readOnly)!=null?N:m,"aria-required":(P=t.required)!=null?P:h,required:(D=t.required)!=null?D:h,ref:ae(_,c),value:R(l.value),role:"spinbutton","aria-valuemin":u,"aria-valuemax":o,"aria-valuenow":Number.isNaN(l.valueAsNumber)?void 0:l.valueAsNumber,"aria-invalid":se(I??l.isOutOfRange),"aria-valuetext":Ie,autoComplete:"off",autoCorrect:"off",onChange:C(t.onChange,he),onKeyDown:C(t.onKeyDown,xe),onFocus:C(t.onFocus,ge,()=>re(!0)),onBlur:C(t.onBlur,pe,Ce)}},[w,S,k,U,K,R,B,O,b,h,m,I,l.value,l.valueAsNumber,l.isOutOfRange,u,o,Ie,he,xe,ge,pe,Ce]);return{value:R(l.value),valueAsNumber:l.valueAsNumber,isFocused:Ve,isDisabled:b,isReadOnly:m,getIncrementButtonProps:Te,getDecrementButtonProps:De,getInputProps:je,htmlProps:ee}}var[ct,J]=Pe({name:"NumberInputStylesContext",errorMessage:`useNumberInputStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[dt,ie]=Pe({name:"NumberInputContext",errorMessage:"useNumberInputContext: `context` is undefined. Seems you forgot to wrap number-input's components within "}),pt=j(function(e,r){const a=Ke("NumberInput",e),u=Ue(e),o=qe(u),{htmlProps:i,...m}=it(o),b=s.useMemo(()=>m,[m]);return f.jsx(dt,{value:b,children:f.jsx(ct,{value:a,children:f.jsx(Y.div,{...i,ref:r,className:Me("chakra-numberinput",e.className),__css:{position:"relative",zIndex:0,...a.root}})})})});pt.displayName="NumberInput";var mt=j(function(e,r){const a=J();return f.jsx(Y.div,{"aria-hidden":!0,ref:r,...e,__css:{display:"flex",flexDirection:"column",position:"absolute",top:"0",insetEnd:"0px",margin:"1px",height:"calc(100% - 2px)",zIndex:1,...a.stepperGroup}})});mt.displayName="NumberInputStepper";var ft=j(function(e,r){const{getInputProps:a}=ie(),u=a(e,r),o=J();return f.jsx(Y.input,{...u,className:Me("chakra-numberinput__field",e.className),__css:{width:"100%",...o.field}})});ft.displayName="NumberInputField";var Re=Y("div",{baseStyle:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,transitionProperty:"common",transitionDuration:"normal",userSelect:"none",cursor:"pointer",lineHeight:"normal"}}),bt=j(function(e,r){var a;const u=J(),{getDecrementButtonProps:o}=ie(),i=o(e,r);return f.jsx(Re,{...i,__css:u.stepper,children:(a=e.children)!=null?a:f.jsx(tt,{})})});bt.displayName="NumberDecrementStepper";var vt=j(function(e,r){var a;const{getIncrementButtonProps:u}=ie(),o=u(e,r),i=J();return f.jsx(Re,{...o,__css:i.stepper,children:(a=e.children)!=null?a:f.jsx(nt,{})})});vt.displayName="NumberIncrementStepper";var St=He("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);const wt=(n,e)=>{const[r,a]=s.useState(n);return s.useEffect(()=>{const u=setTimeout(()=>{a(n)},e);return()=>{clearTimeout(u)}},[n,e]),r},ht={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function _t(n){const{searchValue:e,onUpdateSearchValue:r,style:a}=n,u=e!=="";return f.jsxs(Le,{style:{position:"relative",...a},mb:2,children:[f.jsx(Je,{style:ht}),u&&f.jsx($e,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:f.jsx(ze,{width:15,height:15}),onClick:()=>r(""),"aria-label":"clear input button"}),f.jsx(We,{placeholder:n.placeholder??"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:o})=>r(o.value)})]})}function At({mediaLocalPath:n,size:e,isPreview:r,autoPlay:a,hideBrokenImage:u,objectFit:o,onBrokenLink:i}){const[m,b]=s.useState(!0);return s.useEffect(()=>{u&&(async()=>{try{if((await fetch(r?`/workspace/preview_media?filename=${n}`:`/workspace/view_media?filename=${n}`)).status==404){b(!1),i==null||i();return}}catch(I){console.error("Error checking media exists",I)}})()},[]),m?Xe(n)?f.jsx(Ye,{borderRadius:3,boxSize:`${e}px`,objectFit:o??"cover",src:`/workspace/view_media?filename=${n}`,alt:"workflow image renamed or moved from output folder"}):f.jsx("div",{style:{width:e+"px",height:e+"px",overflow:"hidden",position:"relative"},children:f.jsx("video",{width:e,height:e,src:`/workspace/view_media?filename=${n}`,loop:!0,autoPlay:a??!1,muted:!0,style:{objectFit:"cover",width:"100%",height:"100%"},children:f.jsx("track",{kind:"captions"})})}):null}export{St as I,At as M,pt as N,_t as S,ft as a,mt as b,Ze as c,vt as d,bt as e,yt as p,Ct as r,wt as u,It as v}; diff --git a/dist/workspace_web/ModelManagerTopbar-7VH-2Gbw.js b/dist/workspace_web/ModelManagerTopbar-7VH-2Gbw.js deleted file mode 100644 index 47cc257..0000000 --- a/dist/workspace_web/ModelManagerTopbar-7VH-2Gbw.js +++ /dev/null @@ -1,7 +0,0 @@ -import{f as q,r as m,j as n,g as $,h as Se,a6 as X,b as $e,o as Ue,l as He,i as A,U as re,P as Ve,ac as qe,N as be,ad as Ye,Q as Ce,S as ke,T as Qe,a0 as Je,M as Xe,O as Ze,R as et,_ as tt}from"./input.js";import{au as st,m as nt,av as G,aw as ae,B as oe,F as R,al as Le,l as N,n as ie,a7 as Ie,ax as ot,p as H,ae as Ee,af as it,an as Ae,o as Z,H as W,ay as Te,az as pe,k as Y,A as rt,aA as Ne,j as De,aB as at,aC as Fe,a1 as lt,a2 as ct,a3 as dt,a4 as ht,a5 as ut,aD as ft,aE as mt,aF as te,aG as pt,aH as gt}from"./App-olu4rPJF.js";import{G as xt,C as yt}from"./chunk-JARCRF6W-au6_4y-J.js";import{app as z}from"/scripts/app.js";import{api as V}from"/scripts/api.js";import{S as ee}from"./chunk-3RSXBRAN-FQauAkwt.js";var Pe=q(function(e,s){const{spacing:o="0.5rem",spacingX:i,spacingY:r,children:a,justify:l,direction:c,align:h,className:d,shouldWrapChildren:f,...u}=e,g=m.useMemo(()=>f?m.Children.map(a,(p,x)=>n.jsx(le,{children:p},x)):a,[a,f]);return n.jsx($.div,{ref:s,className:Se("chakra-wrap",d),...u,children:n.jsx($.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:h,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:r,padding:"0"},children:g})})});Pe.displayName="Wrap";var le=q(function(e,s){const{className:o,...i}=e;return n.jsx($.li,{ref:s,__css:{display:"flex",alignItems:"flex-start"},className:Se("chakra-wrap__listitem",o),...i})});le.displayName="WrapItem";function ge(t){return nt(t,e=>e==="auto"?"auto":`span ${e}/span ${e}`)}var Oe=q(function(e,s){const{area:o,colSpan:i,colStart:r,colEnd:a,rowEnd:l,rowSpan:c,rowStart:h,...d}=e,f=st({gridArea:o,gridColumn:ge(i),gridRow:ge(c),gridColumnStart:r,gridColumnEnd:a,gridRowStart:h,gridRowEnd:l});return n.jsx($.div,{ref:s,__css:f,...d})});Oe.displayName="GridItem";function vt(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 Mt=X({"0%":{left:"-40%"},"100%":{left:"100%"}}),jt=X({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function wt(t){const{value:e=0,min:s,max:o,valueText:i,getValueText:r,isIndeterminate:a,role:l="progressbar"}=t,c=vt(e,s,o);return{bind:{"data-indeterminate":a?"":void 0,"aria-valuemax":o,"aria-valuemin":s,"aria-valuenow":a?void 0:e,"aria-valuetext":(()=>{if(e!=null)return typeof r=="function"?r(e,c):i})(),role:l},percent:c,value:e}}var[_t,St]=$e({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),bt=q((t,e)=>{const{min:s,max:o,value:i,isIndeterminate:r,role:a,...l}=t,c=wt({value:i,min:s,max:o,isIndeterminate:r,role:a}),d={height:"100%",...St().filledTrack};return n.jsx($.div,{ref:e,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:d})}),ze=q((t,e)=>{var s;const{value:o,min:i=0,max:r=100,hasStripe:a,isAnimated:l,children:c,borderRadius:h,isIndeterminate:d,"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,title:p,role:x,...j}=Ue(t),w=He("Progress",t),C=h??((s=w.track)==null?void 0:s.borderRadius),k={animation:`${jt} 1s linear infinite`},D={...!d&&a&&l&&k,...d&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Mt} 1s ease infinite normal none running`}},b={overflow:"hidden",position:"relative",...w.track};return n.jsx($.div,{ref:e,borderRadius:C,__css:b,...j,children:n.jsxs(_t,{value:w,children:[n.jsx(bt,{"aria-label":f,"aria-labelledby":u,"aria-valuetext":g,min:i,max:r,value:o,isIndeterminate:d,css:D,borderRadius:C,title:p,role:x}),c]})})});ze.displayName="Progress";function K(t){return Array.isArray?Array.isArray(t):Re(t)==="[object Array]"}const Ct=1/0;function kt(t){return t==null?"":function(e){if(typeof e=="string")return e;let s=e+"";return s=="0"&&1/e==-Ct?"-0":s}(t)}function F(t){return typeof t=="string"}function Be(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||function(e){return function(s){return typeof s=="object"}(e)&&e!==null}(t)&&Re(t)=="[object Boolean]"}function T(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 It=t=>`Missing ${t} property in key`,Et=t=>`Property 'weight' in key '${t}' must be a positive integer`,xe=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(o=>{let i=We(o);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(o=>{o.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function We(t){let e=null,s=null,o=null,i=1,r=null;if(F(t)||K(t))o=t,e=ye(t),s=ve(t);else{if(!xe.call(t,"name"))throw new Error(It("name"));const a=t.name;if(o=a,xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Et(a));e=ye(a),s=ve(a),r=t.getFn}return{path:e,id:s,weight:i,src:o,getFn:r}}function ye(t){return K(t)?t:t.split(".")}function ve(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(T(r))if(a[l]){const c=r[a[l]];if(!T(c))return;if(l===a.length-1&&(F(c)||Be(c)||Lt(c)))s.push(kt(c));else if(K(c)){o=!0;for(let h=0,d=c.length;h{this._keysMap[s.id]=o})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,F(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();F(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,o=this.size();s{let a=i.getFn?i.getFn(e):this.getFn(e,i.path);if(T(a)){if(K(a)){let l=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:h,value:d}=c.pop();if(T(d))if(F(d)&&!se(d)){let f={v:d,i:h,n:this.norm.get(d)};l.push(f)}else K(d)&&d.forEach((f,u)=>{c.push({nestedArrIndex:u,value:f})})}o.$[r]=l}else if(F(a)&&!se(a)){let l={v:a,n:this.norm.get(a)};o.$[r]=l}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Ge(t,e,{getFn:s=M.getFn,fieldNormWeight:o=M.fieldNormWeight}={}){const i=new ce({getFn:s,fieldNormWeight:o});return i.setKeys(t.map(We)),i.setSources(e),i.create(),i}function J(t,{errors:e=0,currentLocation:s=0,expectedLocation:o=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const a=e/t.length;if(r)return a;const l=Math.abs(o-s);return i?a+l/i:l?1:a}const B=32;function Nt(t,e,s,{location:o=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:a=M.findAllMatches,minMatchCharLength:l=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:h=M.ignoreLocation}={}){if(e.length>B)throw new Error(`Pattern length exceeds max of ${B}.`);const d=e.length,f=t.length,u=Math.max(0,Math.min(o,f));let g=r,p=u;const x=l>1||c,j=x?Array(f):[];let w;for(;(w=t.indexOf(e,p))>-1;){let b=J(e,{currentLocation:w,expectedLocation:u,distance:i,ignoreLocation:h});if(g=Math.min(b,g),p=w+d,x){let L=0;for(;L=O;v-=1){let _=v-1,S=s[t.charAt(_)];if(x&&(j[_]=+!!S),y[v]=(y[v+1]<<1|1)&S,b&&(y[v]|=(C[v+1]|C[v])<<1|1|C[v+1]),y[v]&Q&&(k=J(e,{errors:b,currentLocation:_,expectedLocation:u,distance:i,ignoreLocation:h}),k<=g)){if(g=k,p=_,p<=u)break;O=Math.max(1,2*u-p)}}if(J(e,{errors:b+1,currentLocation:u,expectedLocation:u,distance:i,ignoreLocation:h})>g)break;C=y}const D={isMatch:p>=0,score:Math.max(.001,k)};if(x){const b=function(L=[],I=M.minMatchCharLength){let O=[],E=-1,y=-1,v=0;for(let _=L.length;v<_;v+=1){let S=L[v];S&&E===-1?E=v:S||E===-1||(y=v-1,y-E+1>=I&&O.push([E,y]),E=-1)}return L[v-1]&&v-E>=I&&O.push([E,v-1]),O}(j,l);b.length?c&&(D.indices=b):D.isMatch=!1}return D}function Dt(t){let e={};for(let s=0,o=t.length;s{this.chunks.push({pattern:u,alphabet:Dt(u),startIndex:g})},f=this.pattern.length;if(f>B){let u=0;const g=f%B,p=f-g;for(;u{const{isMatch:w,score:C,indices:k}=Nt(e,p,x,{location:i+j,distance:r,threshold:a,findAllMatches:l,minMatchCharLength:c,includeMatches:o,ignoreLocation:h});w&&(u=!0),f+=C,w&&k&&(d=[...d,...k])});let g={isMatch:u,score:u?f/this.chunks.length:1};return u&&o&&(g.indices=d),g}}const Me=[];function je(t,e){for(let s=0,o=Me.length;s{if(!T(o.indices)||!o.indices.length)return;const{indices:i,value:r}=o;let a={indices:i,value:r};o.key&&(a.key=o.key.src),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)})}function Ot(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 At(this.options.keys),this.setCollection(e,o)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof ce))throw new Error("Incorrect 'index' type");this._myIndex=s||Ge(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){T(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let o=0,i=this._docs.length;o{let u=1;f.matches.forEach(({key:g,norm:p,score:x})=>{const j=g?g.weight:null;u*=Math.pow(x===0&&j?Number.EPSILON:x,(j||1)*(d?1:p))}),f.score=u})}(c,{ignoreFieldNorm:l}),r&&c.sort(a),Be(s)&&s>-1&&(c=c.slice(0,s)),function(h,d,{includeMatches:f=M.includeMatches,includeScore:u=M.includeScore}={}){const g=[];return f&&g.push(Pt),u&&g.push(Ot),h.map(p=>{const{idx:x}=p,j={item:d[x],refIndex:x};return g.length&&g.forEach(w=>{w(p,j)}),j})}(c,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(e){const s=je(e,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:a,n:l})=>{if(!T(r))return;const{isMatch:c,score:h,indices:d}=s.searchIn(r);c&&i.push({item:r,idx:a,matches:[{score:h,value:r,norm:l,indices:d}]})}),i}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e){const s=je(e,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:a,i:l})=>{if(!T(a))return;let c=[];o.forEach((h,d)=>{c.push(...this._findMatches({key:h,value:a[d],searcher:s}))}),c.length&&r.push({idx:l,item:a,matches:c})}),r}_findMatches({key:e,value:s,searcher:o}){if(!T(s))return[];let i=[];if(K(s))s.forEach(({v:r,i:a,n:l})=>{if(!T(r))return;const{isMatch:c,score:h,indices:d}=o.searchIn(r);c&&i.push({score:h,key:e,value:r,idx:a,norm:l,indices:d})});else{const{v:r,n:a}=s,{isMatch:l,score:c,indices:h}=o.searchIn(r);l&&i.push({score:c,key:e,value:r,norm:a,indices:h})}return i}}U.version="7.0.0",U.createIndex=Ge,U.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new ce({getFn:e,fieldNormWeight:s});return r.setKeys(o),r.setIndexRecords(i),r},U.config=M;function zt({selectedModel:t,setSelectedModel:e,modelTypeList:s}){const o=i=>{e(i)};return n.jsx(Pe,{children:s.map(i=>n.jsx(le,{children:n.jsx(A,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const Bt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function Rt({data:t}){const[e,s]=m.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=m.useState(!t.file_hash),[r,a]=m.useState();m.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var d;const h=await G.models.get(t.model_name+"@"+t.model_type);if(h!=null&&(a(h),(d=h.imageUrl)!=null&&d.length&&s(h.imageUrl)),!(h!=null&&h.imageUrl)&&t.file_hash!=null)try{const f=await ae(t.file_hash),u=f.imageUrl;u&&s(u);const g={id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,modelName:f.modelName??null,civitModelID:f.civitModelID,civitModelVersionID:f.civitModelVersionID,imageUrl:u??null};a(g)}catch{}t.preview&&s(t.preview)},c=h=>{const d=Bt[t.model_type];d&&(h.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),h.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),h.dataTransfer.setData("nodeType",d))};return n.jsxs(oe,{children:[n.jsxs(oe,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[o?n.jsx(R,{bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:n.jsx(re,{})}):n.jsx(Le,{src:e,draggable:!1,boxSize:"100%",height:150,objectFit:"cover",borderRadius:4,cursor:(r==null?void 0:r.civitModelID)!=null?"pointer":"auto",onClick:()=>{(r==null?void 0:r.civitModelID)==null||(r==null?void 0:r.civitModelVersionID)==null||window.open(`https://civitai.com/models/${r==null?void 0:r.civitModelID}?modelVersionId=${r==null?void 0:r.civitModelVersionID}`)}}),n.jsx(N,{position:"absolute",bottom:"0",left:"0",right:"0",color:"white",fontSize:14})]}),n.jsx(ie,{label:n.jsxs("span",{children:[t.model_name+t.model_extension,n.jsx("br",{}),t.date.toLocaleDateString()]}),children:n.jsx(N,{textAlign:"center",p:"1",fontSize:14,noOfLines:2,children:t.model_name+t.model_extension})})]})}function Wt({list:t}){return n.jsx(xt,{templateColumns:"repeat(3, minmax(0, 1fr))",gap:1,marginTop:2,children:t.map(e=>n.jsx(Oe,{children:n.jsx(Rt,{data:e})},e.model_name+e.date.getTime()))})}function Gt(){const{setRoute:t}=m.useContext(Ie);return n.jsx(n.Fragment,{children:n.jsx(A,{size:"sm",colorScheme:"teal",onClick:()=>t("installModels"),children:"Install Models"})})}const Kt=()=>{const[t,e]=m.useState(["checkpoints"]),[s,o]=m.useState([]),[i,r]=m.useState(!0);m.useEffect(()=>{a(),V.addEventListener("model_list",async c=>{l(c.detail)})},[]);const a=async()=>{const c=await ot();l(c)},l=async c=>{if(!c)return;r(!1);const h=Array.from(new Set(c.map(f=>f.model_type))),d=h.indexOf("checkpoints");d>=0&&h.splice(d,1),h.unshift("checkpoints"),e(h),o(c.map(f=>({...f,date:new Date(f.date*1e3)})))};return{modelTypeList:t,modelsList:s,loading:i}};function $t(){const[t,e]=m.useState(!1),s=()=>{var a;(a=H)==null||a.getSetting("showNsfwModelThumbnail").then(l=>{e(l??!1)})};m.useEffect(()=>{s()},[]);const o=a=>{var c;const l=a.target.checked;(c=H)==null||c.upsert({showNsfwModelThumbnail:l}).then(()=>{s(),i(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},i=async()=>{const a=await G.models.toArray();for(let l=0;l{try{if(a.fileHash==null)return;const c=(await ae(a.fileHash)).imageUrl;G.models.update(a.id,{imageUrl:c??null})}catch{}};return n.jsx(yt,{isChecked:t,onChange:o,children:"Show NSFW"})}function Ut(){const t=async e=>{if(e.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const o=e.dataTransfer.getData("modelRelativePath"),i=e.dataTransfer.getData("nodeType"),r=LiteGraph.createNode(i);r.pos=[e.canvasX,e.canvasY],r.configure({widgets_values:[o]}),z.graph.add(r)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",t),()=>{z.canvasEl.removeEventListener("drop",t)}),[]),null}function Ht({onClose:t}){const[e,s]=m.useState("checkpoints"),[o,i]=m.useState(""),[r,a]=m.useState("name"),{loading:l,modelTypeList:c,modelsList:h}=Kt(),[d,f]=m.useState([]),[u,g]=m.useState([]);m.useEffect(()=>{x();async function x(){const j=await G.models.toArray();f(h.map(w=>({...w,db:j.find(C=>C.id===w.model_name+"@"+w.model_type)})))}},[h]),m.useEffect(()=>{let x=[];o.length?x=new U(d,{keys:["model_name","db.modelName"]}).search(o).map(C=>C.item):x=h.filter(j=>j.model_type===e).sort((j,w)=>r==="name"?j.model_name.localeCompare(w.model_name):w.date.getTime()-j.date.getTime()),g(x)},[e,h,o,r,d]),m.useEffect(()=>(z.canvasEl.addEventListener("click",t),()=>{z.canvasEl.removeEventListener("click",t)}),[t]);const p=440;return n.jsx(Ve,{children:n.jsxs(oe,{style:{width:p},children:[n.jsxs(Ee,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:it,overflowY:"auto",children:[n.jsxs(R,{justifyContent:"space-between",alignContent:"center",py:3,children:[n.jsx(Ae,{size:"md",mr:2,children:"Models"}),n.jsx(Gt,{})]}),n.jsx(R,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:n.jsx(Z,{size:"sm",placeholder:"Search",value:o,onChange:x=>i(x.target.value)})}),n.jsxs(R,{gap:4,justifyContent:"space-between",alignItems:"center",mb:1,children:[!o.length&&n.jsxs(W,{children:[n.jsx("span",{children:"Sort By"}),n.jsxs(ee,{value:r,size:"sm",width:"120px",onChange:x=>a(x.target.value),children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Date"})]})]}),n.jsx($t,{})]}),!o.length&&n.jsx(zt,{modelTypeList:c,setSelectedModel:s,selectedModel:e}),n.jsx(Wt,{list:u}),l&&n.jsx(R,{justifyContent:"center",alignItems:"center",height:"100%",children:n.jsx(re,{})})]}),n.jsx(Ut,{})]})})}const Vt=async t=>{try{const s=await(await V.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 we(t,e=1){const i=t/1024;return i>=1024?(i/1024).toFixed(e)+" GB":i.toFixed(e)+" MB"}function _e(t,e){if(!t||t.length===0)return;let s=t.find(o=>o.nsfw==="None");return e&&(s=s??t[0]),s}function qt(t,e=280,s){var o,i,r,a;if(t)return Te(t)?(r=_e((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,s))==null?void 0:r.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(a=_e(t.images,s))==null?void 0:a.url}/width=${e}/`}const ne=280;function Yt({model:t,onClickInstallModel:e,installing:s}){var u,g;const[o,i]=m.useState();m.useEffect(()=>{p();async function p(){var j;const x=await((j=H)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(qt(t,ne,x))}},[t]);const r=Te(t)?t.modelVersions:t.versions,[a,l]=m.useState(((u=r==null?void 0:r[0])==null?void 0:u.name)??""),c=r==null?void 0:r.find(p=>(p==null?void 0:p.name)===a),h=()=>{window.open(`https://civitai.com/models/${t.id}`)},d=m.useCallback(()=>{if(c==null){console.error("no file is find by name",a);return}e(pe(c,t.name),t)},[a]),f=(g=pe(c))==null?void 0:g.sizeKB;return n.jsxs(Ee,{width:ne,justifyContent:"space-between",mb:2,gap:1,children:[n.jsx(Le,{borderRadius:3,boxSize:ne+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>h()}),n.jsxs(Y,{p:1,children:[n.jsx(ie,{label:t.name,children:n.jsx(N,{fontWeight:500,noOfLines:1,children:t.name})}),n.jsxs(R,{justifyContent:"space-between",alignItems:"center",children:[n.jsx(A,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:n.jsx(N,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),n.jsx(A,{leftIcon:n.jsx(rt,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>d(),isDisabled:!!(a&&s.includes(a)),children:"Install"})]}),n.jsxs(W,{children:[n.jsx(ee,{size:"md",style:{paddingLeft:4},onChange:p=>{l(p.target.value)},children:r==null?void 0:r.map(p=>{const x=p==null?void 0:p.name;return x?n.jsx("option",{value:x,style:{padding:0},children:x},p.id):null})}),f&&n.jsx(ie,{label:we(f),children:n.jsx(N,{flexShrink:1,noOfLines:1,width:"40%",children:we(f)})})]})]})]})}function Qt({searchQuery:t,setSearchQuery:e,onSearch:s}){return n.jsxs(R,{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(A,{size:"sm",onClick:()=>s(),colorScheme:"teal",children:"Search"})]})}function Jt({isOpen:t,fileSelected:e,onClose:s,selectFolder:o}){const[i,r]=m.useState(""),[a,l]=m.useState([]),[c,h]=m.useState(""),d=m.useRef(null);m.useEffect(()=>{f()},[]);const f=async()=>{const u=await Ne();u&&(["custom_nodes","config","saved_prompts"].forEach(g=>{delete u[g]}),l(Object.values(u).flatMap(g=>g)))};return n.jsx(qe,{isOpen:t,leastDestructiveRef:d,onClose:s,children:n.jsx(be,{children:n.jsxs(Ye,{children:[n.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),n.jsx(ke,{children:n.jsxs(Y,{spacing:4,children:[!e&&n.jsxs(n.Fragment,{children:[n.jsx(N,{children:"Model download url"}),n.jsx(Z,{placeholder:"https://civitai.com/api/download/models/311399",onChange:u=>h(u.target.value),value:c})]}),n.jsx(N,{children:"Choose model install folder"}),n.jsx(ee,{placeholder:"Select option",value:i,onChange:u=>r(u.target.value),children:a.map(u=>n.jsx("option",{value:u,children:u},u))})]})}),n.jsxs(Qe,{children:[n.jsx(A,{ref:d,onClick:s,children:"Cancel"}),n.jsx(A,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function Xt(){const{colorMode:t}=Je(),e=De(),[s,o]=m.useState([]);return m.useEffect(()=>{V.addEventListener("download_progress",i=>{o(i.detail)}),V.addEventListener("download_error",i=>{e({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),n.jsx(Y,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,pt:2,children:s.map(({save_path:i,progress:r})=>n.jsxs(W,{children:[n.jsx(N,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),n.jsx(ze,{isIndeterminate:!r,hasStripe:!0,width:"50%",value:r}),n.jsxs(N,{fontSize:16,width:"10%",children:[r.toFixed(1),"%"]}),n.jsx(A,{variant:"outline",size:"sm",colorScheme:"red",onClick:()=>at(i),children:"Cancel"})]},i))})}function Zt(){const[t,e]=m.useState(""),{onOpen:s,onClose:o,isOpen:i}=Fe(),r=()=>{ft(t),o()};return n.jsxs(lt,{isOpen:i,onOpen:s,onClose:o,placement:"right",closeOnBlur:!1,children:[n.jsx(ct,{children:n.jsx(A,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),n.jsxs(dt,{p:5,children:[n.jsx(ht,{}),n.jsx(ut,{}),n.jsxs(Y,{spacing:4,children:[n.jsx(N,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),n.jsx(Z,{value:t,onChange:a=>e(a.target.value),placeholder:"API Key"}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:r,children:"Save"})]})]})]})}async function es(t,e){var a,l;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}"`]]),((l=(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:l.at(0)).hits??[]}function ts({onclose:t,searchQuery:e="",modelType:s}){const[o,i]=m.useState([]),[r,a]=m.useState(!1),[l,c]=m.useState(s),h=De(),[d,f]=m.useState([]),[u,g]=m.useState(e),{isOpen:p,onOpen:x,onClose:j}=Fe(),[w,C,k]=mt(),[P,Q]=m.useState({}),[D,b]=m.useState(te),L=m.useCallback(async()=>{var S;a(!0);const y=await es(u,l);i(y);const v=await Ne();v&&Q(v);const _=await((S=H)==null?void 0:S.getSetting("defaultFolders"));_&&b(_),a(!1)},[u,l]),I=(y,v)=>{var he,ue,fe,me;if(!((he=k.current)!=null&&he.id)&&!v){console.error("no url to download");return}let _=v??`https://civitai.com/api/download/models/${(ue=k.current)==null?void 0:ue.id}`,S=(fe=k.current)==null?void 0:fe.name;if(!S&&(S=_.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}h({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&f(Ke=>[...Ke,S??""]);const de=gt();de&&(_+=`?token=${de}`),Vt({file_hash:(me=k.current)==null?void 0:me.SHA256,filename:S,save_path:y,url:_}),C(void 0),j()},O=async(y,v)=>{const _=D[v.type];C(y),_==null?x():I(_)},E=async(y,v)=>{var S;const _={...D,[y]:v};await((S=H)==null?void 0:S.upsert({defaultFolders:_})),b(_)};return m.useEffect(()=>{L()},[l]),n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[n.jsx(be,{}),n.jsxs(Ze,{width:"90%",maxWidth:"90vw",height:"90vh",children:[n.jsxs(Ce,{pb:1,children:[n.jsxs(W,{gap:2,mb:2,alignItems:"center",children:[n.jsx(Ae,{size:"md",mr:2,children:"Models"}),n.jsx(Qt,{searchQuery:u,setSearchQuery:g,onSearch:L}),n.jsx(A,{size:"sm",py:1,mr:8,onClick:x,children:"Custom URL Install"}),n.jsx(Zt,{})]}),n.jsxs(W,{gap:2,wrap:"wrap",children:[n.jsx(A,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),pt.map(y=>n.jsx(A,{size:"sm",py:1,isActive:l===y,onClick:()=>{c(y)},children:y},y)),l&&P[te[l]]&&n.jsxs(W,{ml:"auto",children:[n.jsx(N,{fontSize:17,whiteSpace:"nowrap",children:"Default Download Folder:"}),n.jsx(ee,{value:D[l],onChange:y=>E(l,y.target.value),children:P[te[l]].map(y=>n.jsx("option",{value:y,children:y},y))})]})]}),r&&n.jsx(re,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),n.jsx(et,{}),n.jsxs(ke,{overflowY:"auto",children:[n.jsx(W,{wrap:"wrap",children:o==null?void 0:o.map(y=>n.jsx(Yt,{model:y,onClickInstallModel:O,installing:d},y.id))}),n.jsx(Xt,{})]})]})]}),n.jsx(Jt,{fileSelected:!!w,isOpen:p,onClose:j,selectFolder:(y,v)=>{I(y,k.current?void 0:v)}})]})}const ss=m.lazy(()=>tt(()=>import("./InstallMissingModelsButton-3G15Fvk5.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function ns(){const{setRoute:t,route:e}=m.useContext(Ie),s=async o=>{if(o.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const r=o.dataTransfer.getData("modelRelativePath"),a=o.dataTransfer.getData("nodeType"),l=LiteGraph.createNode(a);l.pos=[o.canvasX,o.canvasY],l.configure({widgets_values:[r]}),z.graph.add(l)};return m.useEffect(()=>(z.canvasEl.addEventListener("drop",s),V.addEventListener("model_list",async o=>{var a;const i=(a=o.detail)==null?void 0:a.map(async l=>{const c=await G.models.get(l.model_name+"@"+l.model_type);if(c!=null&&c.fileHash)return c;let h={id:l.model_name+"@"+l.model_type,modelName:null,fileHash:l.file_hash??null,fileFolder:l.model_type,fileName:l.model_name+l.model_extension};if(!l.file_hash)return h;const d=await ae(l.file_hash);return h={...h,modelName:d.modelName??null,civitModelID:d.civitModelID,civitModelVersionID:d.civitModelVersionID,imageUrl:d.imageUrl??null},h}),r=(await Promise.all(i)).filter(l=>l!=null);await G.models.clear(),await G.models.bulkPut(r.filter(l=>l!=null)),window.dispatchEvent(new CustomEvent("model_list_updated"))}),()=>{z.canvasEl.removeEventListener("drop",s)}),[]),n.jsxs(Y,{style:{position:"relative"},children:[n.jsx(A,{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(m.Suspense,{children:n.jsx(ss,{})})}),e==="modelList"&&n.jsx(Ht,{onClose:()=>t("root")}),e==="installModels"&&n.jsx(ts,{modelType:"Checkpoint",onclose:()=>t("root")})]})}const ds=Object.freeze(Object.defineProperty({__proto__:null,default:ns},Symbol.toStringTag,{value:"Module"}));export{Oe as G,ds as M,Vt as i}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-3G15Fvk5.js","workspace_web/input.js","workspace_web/App-olu4rPJF.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-JARCRF6W-au6_4y-J.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-3RSXBRAN-FQauAkwt.js"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-O5CnaDXe.js b/dist/workspace_web/RecentFilesDrawer-O5CnaDXe.js deleted file mode 100644 index a3490af..0000000 --- a/dist/workspace_web/RecentFilesDrawer-O5CnaDXe.js +++ /dev/null @@ -1,10 +0,0 @@ -import{f as ye,E as Le,j as c,Z as ma,p as dn,o as va,g as be,h as Ie,$ as ga,r as v,x as fn,M as Ze,N as Je,O as Qe,Q as et,R as tt,S as nt,W as wt,i as ee,a0 as Ot,T as ba,a1 as Ee,a2 as Sa,a3 as xa,a4 as ya,a5 as pn,a6 as Ca,a7 as P,a8 as E,a9 as wa,aa as hn,Y as F,l as ge,U as Oa,I as It,ab as Nt}from"./input.js";import{m as mn,b as Ia,a as Ma,u as vn,c as ka,d as Pa,e as ja,S as Da,M as gn,f as Va,g as Ea,h as q,H as K,T as bn,I as Z,t as Se,i as Sn,j as Me,E as it,k as ue,l as J,n as ne,o as at,p as U,R as de,q as Fa,r as $t,B as z,F as we,s as zt,v as La,w as Ra,x as ke,y as Re,z as te,A as Ta,D as xn,C as G,G as yn,J as Na,K as Mt,L as $a,N as Cn,O as za,P as pe,Q as Aa,U as _a,V as Ha,W as kt,X as Ba,Y as Wa,Z as Ua,_ as xe,$ as ht,a0 as Ga,a1 as Ya,a2 as Ka,a3 as qa,a4 as Xa,a5 as Za,a6 as Ja,a7 as Pt,a8 as wn,a9 as Qa,aa as er,ab as tr,ac as nr,ad as De,ae as ar,af as rr,ag as ir,ah as ot,ai as or}from"./App-olu4rPJF.js";import{G as sr,C as Pe}from"./chunk-JARCRF6W-au6_4y-J.js";import{V as On}from"./chunk-NTCQBYKE-3mwSHd_c.js";import{N as lr,a as cr,I as ur,M as dr,u as fr,S as pr}from"./MediaPreview-6zXFhr_g.js";import{app as $e}from"/scripts/app.js";import{I as hr}from"./IconCopy-JFcpuy1G.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";import"./IconSearch-UuijGRkv.js";var In=ye(function(e,a){const{columns:r,spacingX:t,spacingY:i,spacing:l,minChildWidth:o,...s}=e,u=Le(),d=o?vr(o,u):gr(r);return c.jsx(sr,{ref:a,gap:l,columnGap:t,rowGap:i,templateColumns:d,...s})});In.displayName="SimpleGrid";function mr(n){return typeof n=="number"?`${n}px`:n}function vr(n,e){return mn(n,a=>{const r=ma("sizes",a,mr(a))(e);return a===null?null:`repeat(auto-fit, minmax(${r}, 1fr))`})}function gr(n){return mn(n,e=>e===null?null:`repeat(${e}, minmax(0, 1fr))`)}var Mn=ye(function(e,a){const{borderLeftWidth:r,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:l,borderWidth:o,borderStyle:s,borderColor:u,...d}=dn("Divider",e),{className:f,orientation:h="horizontal",__css:p,...m}=va(e),b={vertical:{borderLeftWidth:r||l||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:s,...b[h],...p},className:Ie("chakra-divider",f)})});Mn.displayName="Divider";function br(n,e={}){const{ssr:a=!0,fallback:r}=e,{getWindow:t}=ga(),i=Array.isArray(n)?n:[n];let l=Array.isArray(r)?r:[r];l=l.filter(u=>u!=null);const[o,s]=v.useState(()=>i.map((u,d)=>({media:u,matches:a?!!l[d]:t().matchMedia(u).matches})));return v.useEffect(()=>{const u=t();s(i.map(h=>({media:h,matches:u.matchMedia(h).matches})));const d=i.map(h=>u.matchMedia(h)),f=h=>{s(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 Sr(n,e,a=Ia){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 xr(n){var e,a;const r=fn(n)?n:{fallback:n??"base"},i=Le().__breakpoints.details.map(({minMaxQuery:u,breakpoint:d})=>({breakpoint:d,query:u.replace("@media screen and ","")})),l=i.map(u=>u.breakpoint===r.fallback),s=br(i.map(u=>u.query),{fallback:l,ssr:r.ssr}).findIndex(u=>u==!0);return(a=(e=i[s])==null?void 0:e.breakpoint)!=null?a:r.fallback}function yr(n,e){var a;const r=fn(e)?e:{fallback:e??"base"},t=xr(r),i=Le();if(!t)return;const l=Array.from(((a=i.__breakpoints)==null?void 0:a.keys)||[]),o=Array.isArray(n)?Object.fromEntries(Object.entries(Ma(n,l)).map(([s,u])=>[s,u])):n;return Sr(o,t,l)}var kn=ye((n,e)=>{const{title:a,children:r,className:t,...i}=n,l=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:l,...i,__css:o.groupTitle,children:a}),r]})});kn.displayName="MenuGroup";var Pn=n=>{const{className:e,title:a,...r}=n,t=ka(r);return c.jsx(kn,{title:a,className:Ie("chakra-menu__option-group",e),...t})};Pn.displayName="MenuOptionGroup";var Cr=ye((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}})}),Te=ye((n,e)=>{const{children:a,as:r,...t}=n,i=Pa(t,e),l=r||Cr;return c.jsx(l,{...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})})});Te.displayName="MenuButton";var wr=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"})}),jt=ye((n,e)=>{const{icon:a,iconSpacing:r="0.75rem",...t}=n,i=ja(t,e);return c.jsxs(Da,{...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(wr,{})}),c.jsx("span",{style:{flex:1},children:i.children})]})});jt.id="MenuItemOption";jt.displayName="MenuItemOption";var jn=ye(function(e,a){const{getHeaderProps:r}=Va(),t=Ea();return c.jsx(be.header,{...r(e,a),className:Ie("chakra-popover__header",e.className),__css:t.header})});jn.displayName="PopoverHeader";var Or=q("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Ir=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"}]]),Mr=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"}]]),kr=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"}]]),Dn=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"}]]),Pr=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"}]]),jr=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"}]]),Dr=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"}]]),Vr=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"}]]),Er=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"}]]),Fr=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"}]]),Lr=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"}]]),Vn=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"}]]),Rr=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 Tr({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(Ze,{isOpen:!0,onClose:n,children:[c.jsx(Je,{}),c.jsxs(Qe,{children:[c.jsx(et,{children:"My Tags"}),c.jsx(tt,{}),c.jsx(nt,{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 Nr(){const n=Me(),e=v.useRef([{title:"Save current workflow",key:it.SAVE},{title:"Save as current workflow",key:it.SAVE_AS},{title:"Open spotlight search",key:it.openSpotlightSearch}]),[a,r]=v.useState({save:"",saveAs:"",openSpotlightSearch:""}),[t,i]=v.useState(),l=async(s,u)=>{var f;s.preventDefault();let d="";if(s.ctrlKey&&(d+="Control+"),s.metaKey&&(d+="Command+"),s.shiftKey&&(d+="Shift+"),s.altKey&&(d+="Alt+"),d.length>0&&!["Control","Shift","Alt","Meta"].includes(s.key)){d+=s.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 s;(s=U)==null||s.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(ue,{children:[c.jsx(J,{children:"Keyboard Shortcut"}),e.current.map(s=>c.jsxs(K,{children:[c.jsx(J,{fontSize:"sm",w:170,children:s.title}),c.jsx(ne,{label:"Press shortcut key combinations to setup",placement:"bottom",hasArrow:!0,isOpen:t===s.key,children:c.jsx(at,{value:a[s.key],onKeyDown:u=>{l(u,s.key)},onFocus:()=>{i(s.key)},onBlur:()=>{i(void 0)},placeholder:"Press a key combination",readOnly:!0,width:"auto",flex:1})})]},s.key))]})}function $r(){const{setRefreshFolderStamp:n}=v.useContext(de),[e,a]=v.useState(!1),r=()=>{var i;(i=U)==null||i.getSetting("foldersOnTop").then(l=>{a(!!l)})},t=i=>{var o;const l=i.target.checked;(o=U)==null||o.upsert({foldersOnTop:l}).then(()=>{r(),n(Date.now())})};return v.useEffect(()=>{r()},[]),c.jsx(ue,{children:c.jsx(Pe,{isChecked:e,onChange:t,children:"Folders always on top"})})}function zr(){const[n,e]=v.useState(!1),[a,r]=v.useState(""),{showDialog:t}=wt(),i=()=>{var o,s;(o=U)==null||o.getSetting("myWorkflowsDir").then(u=>{r(u??"undefined")}),(s=U)==null||s.getSetting("twoWaySync").then(u=>{e(u??!1)})};v.useEffect(()=>{i()},[]);const l=async o=>{var u,d;if(!o.target.checked){await((u=U)==null?void 0:u.upsert({twoWaySync:o.target.checked})),i();return}const s=await((d=U)==null?void 0:d.getSetting("myWorkflowsDir"));t(c.jsx(Fa,{myWorkflowsDir:s??"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(ue,{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(Pe,{isChecked:n,onChange:l,children:"Enable two way sync"})]})}function Ar({settingKey:n,text:e,defaultChecked:a=!1}){const[r,t]=v.useState(a),i=Me(),l=()=>{var o;(o=U)==null||o.getSetting(n).then(s=>{t(!!s)})};return v.useEffect(()=>{l()},[]),c.jsx(ue,{children:c.jsx(Pe,{isChecked:r,onChange:async o=>{var s;await((s=U)==null?void 0:s.upsert({[n]:o.target.checked})),l(),i({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:e})})}function _r(){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),[t,i]=v.useState([]),[l,o]=v.useState(""),[s,u]=v.useState([]),[d,f]=v.useState(!1),[h,p]=v.useState(!1),[m,b]=v.useState(!1),g=v.useRef(null),S=Me(),{showDialog:w}=wt(),y=m?"\\":"/";v.useEffect(()=>{var D;$t().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 zt(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(l);D||(i(O),r(!0),u(l&&l.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 $t();N&&await La(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 zt(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}${s.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}${s.concat([O]).join(y)}`:L=`${m?"":y}${s.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(at,{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(ue,{spacing:"2px",direction:"row",wrap:"wrap",children:s.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(In,{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(we,{children:[c.jsx(bn,{overflowWrap:"anywhere",children:l}),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(Mr,{size:19}),onClick:H,variant:"ghost"})})]})]}),c.jsxs(Ze,{isOpen:h,onClose:()=>p(!1),size:"xl",children:[c.jsx(Je,{}),c.jsxs(Qe,{children:[c.jsx(et,{children:"Kind tips"}),c.jsx(tt,{}),c.jsx(nt,{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 En({label:n,settingKey:e}){const[a,r]=v.useState(200),t=Me(),i=s=>{if(!s.length){r(0);return}r(parseInt(s))},l=async()=>{var s;a<0&&r(0),await((s=U)==null?void 0:s.upsert({[e]:Number(a)})),t({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},o=()=>{var s;(s=U)==null||s.getSetting(e).then(u=>{r(u)})};return v.useEffect(()=>{o()},[]),c.jsxs(ue,{children:[c.jsx(J,{children:n}),c.jsx(lr,{defaultValue:200,min:0,keepWithinRange:!0,placeholder:"Enter a number",maxWidth:"300px",value:a,onChange:s=>i(s),onBlur:()=>{l()},onKeyUp:s=>{s.key==="Enter"&&l()},children:c.jsx(cr,{})})]})}function Hr(){const[n,e]=v.useState(!1),a=Me(),r=()=>{var t;(t=U)==null||t.getSetting("autoSave").then(i=>{e(!!i)})};return v.useEffect(()=>{r()},[]),c.jsxs(ue,{children:[c.jsx(Pe,{isChecked:n,onChange:async t=>{var i;await((i=U)==null?void 0:i.upsert({autoSave:t.target.checked})),r(),a({title:"Setting saved",status:"success",duration:3e3,isClosable:!0})},children:"Enable auto save workflow"}),n&&c.jsx(En,{label:"Auto save duration (auto save workflow every X seconds)",settingKey:"autoSaveDuration"})]})}function Br({onClose:n}){return c.jsx(c.Fragment,{children:c.jsxs(Ze,{isOpen:!0,onClose:n,size:"xl",children:[c.jsx(Je,{}),c.jsxs(Qe,{children:[c.jsx(et,{children:"Settings"}),c.jsx(tt,{}),c.jsx(nt,{pb:14,children:c.jsx(K,{children:c.jsxs(On,{divider:c.jsx(Ra,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[c.jsx(_r,{}),c.jsx(Hr,{}),c.jsx(Nr,{}),c.jsx(zr,{}),c.jsx($r,{}),c.jsx(Ar,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"}),c.jsx(En,{label:`Maximum number of save change history to store. This does not include - versions that you created by "Create Version", which are always stored - and has no limit.`,settingKey:"maximumChangelogNumber"})]})})})]})]})})}const st=16;function Wr({}){const[n,e]=v.useState(!1),[a,r]=v.useState(!1),{colorMode:t,toggleColorMode:i}=Ot();return c.jsxs(c.Fragment,{children:[c.jsxs(ke,{isLazy:!0,children:[c.jsx(Te,{as:Z,"aria-label":"Options",icon:c.jsx(Dr,{}),size:"sm",variant:"outline"}),c.jsxs(Re,{children:[c.jsx(te,{onClick:()=>r(!0),icon:c.jsx(Fr,{size:16}),fontSize:16,children:"Settings"}),c.jsx(te,{onClick:()=>e(!0),icon:c.jsx(Vn,{size:st}),fontSize:16,children:"Manage Tags"}),c.jsxs(te,{onClick:i,icon:t==="light"?c.jsx(Vr,{size:st}):c.jsx(Lr,{size:st}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),n&&c.jsx(Tr,{onclose:()=>e(!1)}),a&&c.jsx(Br,{onClose:()=>r(!1)})]})}function Ur(n){const{multipleState:e,changeMultipleState:a,selectedKeys:r,isSelectedAll:t,batchOperationCallback:i}=n,l=async()=>{var u;const s=await((u=G)==null?void 0:u.batchQuery(r))??[];Na(s)},o=r.length===0;return c.jsx(K,{spacing:2,wrap:"wrap",mb:0,children:e?c.jsxs(c.Fragment,{children:[c.jsx(Pe,{isChecked:t,onChange:s=>{i("selectAll",s.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(Ta,{size:21}),onClick:l})}),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 s;await((s=G)==null?void 0:s.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(Pr,{size:21}),onClick:()=>{a(!0)}})})})}const _t=6;function Gr({setSelectedTag:n,selectedTag:e}){const[a,r]=v.useState(!1),[t,i]=v.useState([]);return v.useEffect(()=>{var l;(l=Se)==null||l.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:_t).map(l=>c.jsx(ee,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{n(l.name)},isActive:e===l.name,children:l.name},l.name)),(t.length??0)>_t&&c.jsx(Z,{"aria-label":"Show-all-tags",size:"sm",icon:a?c.jsx(Or,{}):c.jsx(Mt,{}),onClick:()=>r(!a)})]})}function Fn({parentFolderID:n,onlyImportFile:e=!1}){const{onRefreshFilesList:a}=v.useContext(de),[r,t]=v.useState("file"),i=v.useRef(null),l=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 za(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},s=async d=>{var h,p;const f=[d];for(;f.length>0;){const m=f.shift();if(m&&!m.isFile){const b=await((h=pe)==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)}}s(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(),l("file")},icon:c.jsx(At,{size:19}),children:"Import workflows"}):c.jsxs(ke,{closeOnSelect:!0,children:[c.jsx(Te,{as:ee,leftIcon:c.jsx(At,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),c.jsx(Re,{children:$a.map((d,f)=>c.jsx(te,{onClick:()=>{l(d.type)},iconSpacing:2,icon:d.type==="folder"?c.jsx(Cn,{size:18}):c.jsx(kr,{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 Yr({folder:n,onclose:e}){const[a,r]=v.useState(n.name),[t,i]=v.useState(""),{onRefreshFilesList:l}=v.useContext(de),o=u=>{r(u.target.value),t&&i("")},s=async()=>{var f,h;const u=a.trim();if(r(u),u===n.name)return e();await((f=pe)==null?void 0:f.generateUniqueName(u,n.parentFolderID??""))!==u?i("The name is duplicated, please modify it and submit again."):(await((h=pe)==null?void 0:h.update(n.id,{name:u})),l&&l(),e())};return c.jsxs(Ze,{isOpen:!0,onClose:e,children:[c.jsx(Je,{}),c.jsxs(Qe,{children:[c.jsx(et,{children:"Edit folder name"}),c.jsx(tt,{}),c.jsx(nt,{children:c.jsxs(Aa,{isInvalid:!!t,children:[c.jsx(_a,{children:"Folder name"}),c.jsx(at,{value:a,onChange:o,autoFocus:!0,onKeyUp:u=>{u.code==="Enter"&&!t&&a&&s()}}),t&&c.jsx(Ha,{children:t})]})}),c.jsxs(ba,{children:[c.jsx(ee,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!a||!!t,children:"Save"}),c.jsx(ee,{onClick:e,children:"Cancel"})]})]})]})}function Kr({menuPosition:n,isopen:e,folder:a,onClose:r}){const[t,i]=v.useState(!1),{onRefreshFilesList:l}=v.useContext(de),{showDialog:o}=wt(),s=async h=>{var p;h.stopPropagation(),await((p=pe)==null?void 0:p.create({name:"New Folder",parentFolderID:a.id})),l&&l()},u=async h=>{var p;h.stopPropagation(),await((p=G)==null?void 0:p.createFlow({json:JSON.stringify(Ba),parentFolderID:a.id})),l&&l()},d=async h=>{h.stopPropagation();const p=await Wa(a.id);o(`Do you want to delete the ${p} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{f(Ua.DELETE)}}])},f=async h=>{var p;await((p=pe)==null?void 0:p.deleteFolder(a.id,h)),r(),l&&l()};return c.jsxs(c.Fragment,{children:[c.jsx(z,{position:"absolute",top:n.y,left:n.x,children:c.jsx(ke,{isOpen:e,onClose:r,isLazy:!0,lazyBehavior:"keepMounted",children:c.jsxs(Re,{children:[c.jsx(te,{icon:c.jsx(Er,{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:s,icon:c.jsx(Dn,{size:19}),children:"New folder"}),c.jsx(te,{onClick:u,icon:c.jsx(kt,{size:19}),children:"New file"}),c.jsx(Fn,{parentFolderID:a.id,onlyImportFile:!0})]})})}),t&&c.jsx(Yr,{folder:a,onclose:()=>i(!1)})]})}const Ht=v.memo(function({folder:e}){const[a,r]=v.useState(!1),[t,i]=v.useState(e.isCollapse??!0),[l,o]=v.useState([]),[s,u]=v.useState({x:0,y:0}),[d,f]=v.useState(!1),{colorMode:h}=Ot(),{draggingFile:p,setDraggingFile:m,refreshFolderStamp:b,onRefreshFilesList:g}=v.useContext(de),S=h==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};v.useEffect(()=>{var x;t||(x=G)==null||x.listFolderContent(e.id,window.localStorage.getItem(ht)).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=pe)==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=pe)==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(ue,{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(ur,{size:20}):c.jsx(Mt,{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(Kr,{isopen:d,menuPosition:s,onClose:()=>f(!1),folder:e}),!t&&c.jsx(ue,{ml:4,gap:0,children:c.jsx(da,{items:l})})]})});function Bt(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 Jr=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function Qr(n){var e=n.defaultInputValue,a=e===void 0?"":e,r=n.defaultMenuIsOpen,t=r===void 0?!1:r,i=n.defaultValue,l=i===void 0?null:i,o=n.inputValue,s=n.menuIsOpen,u=n.onChange,d=n.onInputChange,f=n.onMenuClose,h=n.onMenuOpen,p=n.value,m=he(n,Jr),b=v.useState(o!==void 0?o:a),g=fe(b,2),S=g[0],w=g[1],y=v.useState(s!==void 0?s:t),x=fe(y,2),j=x[0],C=x[1],V=v.useState(p!==void 0?p:l),M=fe(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,_=s!==void 0?s: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 ei(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Wt(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 ri(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ii(n,e){if(e&&(pn(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ri(n)}function oi(n){var e=ai();return function(){var r=Be(n),t;if(e){var i=Be(this).constructor;t=Reflect.construct(r,arguments,i)}else t=r.apply(this,arguments);return ii(this,t)}}function si(n){if(Array.isArray(n))return mt(n)}function li(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ci(){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 Rn(n){return si(n)||li(n)||Ln(n)||ci()}function ui(n,e){return e||(e=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(e)}}))}const di=Math.min,fi=Math.max,We=Math.round,ze=Math.floor,Ue=n=>({x:n,y:n});function pi(n){return{...n,top:n.y,left:n.x,right:n.x+n.width,bottom:n.y+n.height}}function Tn(n){return $n(n)?(n.nodeName||"").toLowerCase():"#document"}function ie(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Nn(n){var e;return(e=($n(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function $n(n){return n instanceof Node||n instanceof ie(n).Node}function vt(n){return n instanceof Element||n instanceof ie(n).Element}function Dt(n){return n instanceof HTMLElement||n instanceof ie(n).HTMLElement}function Ut(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof ie(n).ShadowRoot}function zn(n){const{overflow:e,overflowX:a,overflowY:r,display:t}=Vt(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+a)&&!["inline","contents"].includes(t)}function hi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function mi(n){return["html","body","#document"].includes(Tn(n))}function Vt(n){return ie(n).getComputedStyle(n)}function vi(n){if(Tn(n)==="html")return n;const e=n.assignedSlot||n.parentNode||Ut(n)&&n.host||Nn(n);return Ut(e)?e.host:e}function An(n){const e=vi(n);return mi(e)?n.ownerDocument?n.ownerDocument.body:n.body:Dt(e)&&zn(e)?e:An(e)}function Ge(n,e,a){var r;e===void 0&&(e=[]),a===void 0&&(a=!0);const t=An(n),i=t===((r=n.ownerDocument)==null?void 0:r.body),l=ie(t);return i?e.concat(l,l.visualViewport||[],zn(t)?t:[],l.frameElement&&a?Ge(l.frameElement):[]):e.concat(t,Ge(t,[],a))}function gi(n){const e=Vt(n);let a=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const t=Dt(n),i=t?n.offsetWidth:a,l=t?n.offsetHeight:r,o=We(a)!==i||We(r)!==l;return o&&(a=i,r=l),{width:a,height:r,$:o}}function Et(n){return vt(n)?n:n.contextElement}function lt(n){const e=Et(n);if(!Dt(e))return Ue(1);const a=e.getBoundingClientRect(),{width:r,height:t,$:i}=gi(e);let l=(i?We(a.width):a.width)/r,o=(i?We(a.height):a.height)/t;return(!l||!Number.isFinite(l))&&(l=1),(!o||!Number.isFinite(o))&&(o=1),{x:l,y:o}}const bi=Ue(0);function Si(n){const e=ie(n);return!hi()||!e.visualViewport?bi:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function xi(n,e,a){return e===void 0&&(e=!1),!a||e&&a!==ie(n)?!1:e}function Gt(n,e,a,r){e===void 0&&(e=!1),a===void 0&&(a=!1);const t=n.getBoundingClientRect(),i=Et(n);let l=Ue(1);e&&(r?vt(r)&&(l=lt(r)):l=lt(n));const o=xi(i,a,r)?Si(i):Ue(0);let s=(t.left+o.x)/l.x,u=(t.top+o.y)/l.y,d=t.width/l.x,f=t.height/l.y;if(i){const h=ie(i),p=r&&vt(r)?ie(r):r;let m=h.frameElement;for(;m&&r&&p!==h;){const b=lt(m),g=m.getBoundingClientRect(),S=Vt(m),w=g.left+(m.clientLeft+parseFloat(S.paddingLeft))*b.x,y=g.top+(m.clientTop+parseFloat(S.paddingTop))*b.y;s*=b.x,u*=b.y,d*=b.x,f*=b.y,s+=w,u+=y,m=ie(m).frameElement}}return pi({width:d,height:f,x:s,y:u})}function yi(n,e){let a=null,r;const t=Nn(n);function i(){clearTimeout(r),a&&a.disconnect(),a=null}function l(o,s){o===void 0&&(o=!1),s===void 0&&(s=1),i();const{left:u,top:d,width:f,height:h}=n.getBoundingClientRect();if(o||e(),!f||!h)return;const p=ze(d),m=ze(t.clientWidth-(u+f)),b=ze(t.clientHeight-(d+h)),g=ze(u),w={rootMargin:-p+"px "+-m+"px "+-b+"px "+-g+"px",threshold:fi(0,di(1,s))||1};let y=!0;function x(j){const C=j[0].intersectionRatio;if(C!==s){if(!y)return l();C?l(!1,C):r=setTimeout(()=>{l(!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 l(!0),i}function Ci(n,e,a,r){r===void 0&&(r={});const{ancestorScroll:t=!0,ancestorResize:i=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:s=!1}=r,u=Et(n),d=t||i?[...u?Ge(u):[],...Ge(e)]:[];d.forEach(S=>{t&&S.addEventListener("scroll",a,{passive:!0}),i&&S.addEventListener("resize",a)});const f=u&&o?yi(u,a):null;let h=-1,p=null;l&&(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&&!s&&p.observe(u),p.observe(e));let m,b=s?Gt(n):null;s&&g();function g(){const S=Gt(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,s&&cancelAnimationFrame(m)}}var gt=v.useLayoutEffect,wi=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],Ye=function(){};function Oi(n,e){return e?e[0]==="-"?n+e:n+"__"+e:n}function Ii(n,e){for(var a=arguments.length,r=new Array(a>2?a-2:0),t=2;t-1}function Mi(n){return rt(n)?window.innerHeight:n.clientHeight}function Hn(n){return rt(n)?window.pageYOffset:n.scrollTop}function Ke(n,e){if(rt(n)){window.scrollTo(0,e);return}n.scrollTop=e}function ki(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 Pi(n,e,a,r){return a*((n=n/r-1)*n*n+1)+e}function Ae(n,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ye,t=Hn(n),i=e-t,l=10,o=0;function s(){o+=l;var u=Pi(o,t,i,a);Ke(n,u),oa.bottom?Ke(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&&!l)return i&&Ae(s,A,H),{placement:"bottom",maxHeight:e};if(!l&&T>=r||l&&V>=r){i&&Ae(s,A,H);var D=l?V-x:T-x;return{placement:"bottom",maxHeight:D}}if(t==="auto"||l){var O=e,L=l?C:M;return L>=r&&(O=Math.min(L-x-o,e)),{placement:"top",maxHeight:O}}if(t==="bottom")return i&&Ke(s,A),{placement:"bottom",maxHeight:e};break;case"top":if(C>=m)return{placement:"top",maxHeight:e};if(M>=m&&!l)return i&&Ae(s,W,H),{placement:"top",maxHeight:e};if(!l&&M>=r||l&&C>=r){var _=e;return(!l&&M>=r||l&&C>=r)&&(_=l?C-j:M-j),i&&Ae(s,W,H),{placement:"top",maxHeight:_}}return{placement:"bottom",maxHeight:e};default:throw new Error('Invalid placement provided "'.concat(t,'".'))}return u}function zi(n){var e={bottom:"top",top:"bottom"};return n?e[n]:"bottom"}var Wn=function(e){return e==="auto"?"bottom":e},Ai=function(e,a){var r,t=e.placement,i=e.theme,l=i.borderRadius,o=i.spacing,s=i.colors;return k((r={label:"menu"},Ee(r,zi(t),"100%"),Ee(r,"position","absolute"),Ee(r,"width","100%"),Ee(r,"zIndex",1),r),a?{}:{backgroundColor:s.neutral0,borderRadius:l,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})},Un=v.createContext(null),_i=function(e){var a=e.children,r=e.minMenuHeight,t=e.maxMenuHeight,i=e.menuPlacement,l=e.menuPosition,o=e.menuShouldScrollIntoView,s=e.theme,u=v.useContext(Un)||{},d=u.setPortalPlacement,f=v.useRef(null),h=v.useState(t),p=fe(h,2),m=p[0],b=p[1],g=v.useState(null),S=fe(g,2),w=S[0],y=S[1],x=s.spacing.controlHeight;return gt(function(){var j=f.current;if(j){var C=l==="fixed",V=o&&!C,M=$i({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,l,o,r,d,x]),a({ref:f,placerProps:k(k({},e),{},{placement:w||Wn(i),maxHeight:m})})},Hi=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)},Bi=Hi,Wi=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})},Ui=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)},Gn=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")})},Gi=Gn,Yi=Gn,Ki=function(e){var a=e.children,r=a===void 0?"No options":a,t=e.innerProps,i=he(e,Ti);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),t),r)},qi=function(e){var a=e.children,r=a===void 0?"Loading...":a,t=e.innerProps,i=he(e,Ni);return P("div",E({},B(k(k({},i),{},{children:r,innerProps:t}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),t),r)},Xi=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}},Zi=function(e){var a=e.appendTo,r=e.children,t=e.controlElement,i=e.innerProps,l=e.menuPlacement,o=e.menuPosition,s=v.useRef(null),u=v.useRef(null),d=v.useState(Wn(l)),f=fe(d,2),h=f[0],p=f[1],m=v.useMemo(function(){return{setPortalPlacement:p}},[]),b=v.useState(null),g=fe(b,2),S=g[0],w=g[1],y=v.useCallback(function(){if(t){var V=ji(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]);gt(function(){y()},[y]);var x=v.useCallback(function(){typeof u.current=="function"&&(u.current(),u.current=null),t&&s.current&&(u.current=Ci(t,s.current,y,{elementResize:"ResizeObserver"in window}))},[t,y]);gt(function(){x()},[x]);var j=v.useCallback(function(V){s.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(Un.Provider,{value:m},a?wa.createPortal(C,a):C)},Ji=function(e){var a=e.isDisabled,r=e.isRtl;return{label:"container",direction:r?"rtl":void 0,pointerEvents:a?"none":void 0,position:"relative"}},Qi=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)},eo=function(e,a){var r=e.theme.spacing,t=e.isMulti,i=e.hasValue,l=e.selectProps.controlShouldRenderValue;return k({alignItems:"center",display:t&&i&&l?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},a?{}:{padding:"".concat(r.baseUnit/2,"px ").concat(r.baseUnit*2,"px")})},to=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)},no=function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},ao=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"indicatorsContainer",{indicators:!0}),r),a)},Xt,ro=["size"],io=["innerProps","isRtl","size"],oo={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},Yn=function(e){var a=e.size,r=he(e,ro);return P("svg",E({height:a,width:a,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:oo},r))},Ft=function(e){return P(Yn,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"}))},Kn=function(e){return P(Yn,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"}))},qn=function(e,a){var r=e.isFocused,t=e.theme,i=t.spacing.baseUnit,l=t.colors;return k({label:"indicatorContainer",display:"flex",transition:"color 150ms"},a?{}:{color:r?l.neutral60:l.neutral20,padding:i*2,":hover":{color:r?l.neutral80:l.neutral40}})},so=qn,lo=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),r),a||P(Kn,null))},co=qn,uo=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),r),a||P(Ft,null))},fo=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing.baseUnit,l=t.colors;return k({label:"indicatorSeparator",alignSelf:"stretch",width:1},a?{}:{backgroundColor:r?l.neutral10:l.neutral20,marginBottom:i*2,marginTop:i*2})},po=function(e){var a=e.innerProps;return P("span",E({},a,B(e,"indicatorSeparator",{"indicator-separator":!0})))},ho=Ca(Xt||(Xt=ui([` - 0%, 80%, 100% { opacity: 0; } - 40% { opacity: 1; } -`]))),mo=function(e,a){var r=e.isFocused,t=e.size,i=e.theme,l=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?l.neutral60:l.neutral20,padding:o*2})},ct=function(e){var a=e.delay,r=e.offset;return P("span",{css:hn({animation:"".concat(ho," 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"},"","")})},vo=function(e){var a=e.innerProps,r=e.isRtl,t=e.size,i=t===void 0?4:t,l=he(e,io);return P("div",E({},B(k(k({},l),{},{innerProps:a,isRtl:r,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),a),P(ct,{delay:0,offset:r}),P(ct,{delay:160,offset:!0}),P(ct,{delay:320,offset:!r}))},go=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.theme,l=i.colors,o=i.borderRadius,s=i.spacing;return k({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:s.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},a?{}:{backgroundColor:r?l.neutral5:l.neutral0,borderColor:r?l.neutral10:t?l.primary:l.neutral20,borderRadius:o,borderStyle:"solid",borderWidth:1,boxShadow:t?"0 0 0 1px ".concat(l.primary):void 0,"&:hover":{borderColor:t?l.primary:l.neutral30}})},bo=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.innerRef,l=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}),l,{"aria-disabled":r||void 0}),a)},So=bo,xo=["data"],yo=function(e,a){var r=e.theme.spacing;return a?{}:{paddingBottom:r.baseUnit*2,paddingTop:r.baseUnit*2}},Co=function(e){var a=e.children,r=e.cx,t=e.getStyles,i=e.getClassNames,l=e.Heading,o=e.headingProps,s=e.innerProps,u=e.label,d=e.theme,f=e.selectProps;return P("div",E({},B(e,"group",{group:!0}),s),P(l,E({},o,{selectProps:f,theme:d,getStyles:t,getClassNames:i,cx:r}),u),P("div",null,a))},wo=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"})},Oo=function(e){var a=_n(e);a.data;var r=he(a,xo);return P("div",E({},B(e,"groupHeading",{"group-heading":!0}),r))},Io=Co,Mo=["innerRef","isDisabled","isHidden","inputClassName"],ko=function(e,a){var r=e.isDisabled,t=e.value,i=e.theme,l=i.spacing,o=i.colors;return k(k({visibility:r?"hidden":"visible",transform:t?"translateZ(0)":""},Po),a?{}:{margin:l.baseUnit/2,paddingBottom:l.baseUnit/2,paddingTop:l.baseUnit/2,color:o.neutral80})},Xn={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Po={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"},Xn)},jo=function(e){return k({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Xn)},Do=function(e){var a=e.cx,r=e.value,t=_n(e),i=t.innerRef,l=t.isDisabled,o=t.isHidden,s=t.inputClassName,u=he(t,Mo);return P("div",E({},B(e,"input",{"input-container":!0}),{"data-value":r||""}),P("input",E({className:a({input:!0},s),ref:i,style:jo(o),disabled:l},u)))},Vo=Do,Eo=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,l=r.colors;return k({label:"multiValue",display:"flex",minWidth:0},a?{}:{backgroundColor:l.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Fo=function(e,a){var r=e.theme,t=r.borderRadius,i=r.colors,l=e.cropWithEllipsis;return k({overflow:"hidden",textOverflow:l||l===void 0?"ellipsis":void 0,whiteSpace:"nowrap"},a?{}:{borderRadius:t/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},Lo=function(e,a){var r=e.theme,t=r.spacing,i=r.borderRadius,l=r.colors,o=e.isFocused;return k({alignItems:"center",display:"flex"},a?{}:{borderRadius:i/2,backgroundColor:o?l.dangerLight:void 0,paddingLeft:t.baseUnit,paddingRight:t.baseUnit,":hover":{backgroundColor:l.dangerLight,color:l.danger}})},Zn=function(e){var a=e.children,r=e.innerProps;return P("div",r,a)},Ro=Zn,To=Zn;function No(n){var e=n.children,a=n.innerProps;return P("div",E({role:"button"},a),e||P(Ft,{size:14}))}var $o=function(e){var a=e.children,r=e.components,t=e.data,i=e.innerProps,l=e.isDisabled,o=e.removeProps,s=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":l})),i),selectProps:s},P(d,{data:t,innerProps:k({},B(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:s},a),P(f,{data:t,innerProps:k(k({},B(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(a||"option")},o),selectProps:s}))},zo=$o,Ao=function(e,a){var r=e.isDisabled,t=e.isFocused,i=e.isSelected,l=e.theme,o=l.spacing,s=l.colors;return k({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},a?{}:{backgroundColor:i?s.primary:t?s.primary25:"transparent",color:r?s.neutral20:i?s.neutral0:"inherit",padding:"".concat(o.baseUnit*2,"px ").concat(o.baseUnit*3,"px"),":active":{backgroundColor:r?void 0:i?s.primary:s.primary50}})},_o=function(e){var a=e.children,r=e.isDisabled,t=e.isFocused,i=e.isSelected,l=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:l,"aria-disabled":r},o),a)},Ho=_o,Bo=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})},Wo=function(e){var a=e.children,r=e.innerProps;return P("div",E({},B(e,"placeholder",{placeholder:!0}),r),a)},Uo=Wo,Go=function(e,a){var r=e.isDisabled,t=e.theme,i=t.spacing,l=t.colors;return k({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},a?{}:{color:r?l.neutral40:l.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},Yo=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)},Ko=Yo,qo={ClearIndicator:uo,Control:So,DropdownIndicator:lo,DownChevron:Kn,CrossIcon:Ft,Group:Io,GroupHeading:Oo,IndicatorsContainer:ao,IndicatorSeparator:po,Input:Vo,LoadingIndicator:vo,Menu:Bi,MenuList:Ui,MenuPortal:Zi,LoadingMessage:qi,NoOptionsMessage:Ki,MultiValue:zo,MultiValueContainer:Ro,MultiValueLabel:To,MultiValueRemove:No,Option:Ho,Placeholder:Uo,SelectContainer:Qi,SingleValue:Ko,ValueContainer:to},Xo=function(e){return k(k({},qo),e.components)},Zt=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function Zo(n,e){return!!(n===e||Zt(n)&&Zt(e))}function Jo(n,e){if(n.length!==e.length)return!1;for(var a=0;a1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return l?"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,l=i===void 0?"":i,o=e.selectValue,s=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(l," focused, ").concat(d(o,r),".");if(a==="menu"){var f=s?" disabled":"",h="".concat(u?"selected":"focused").concat(f);return"option ".concat(l," ").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:"",".")}},as=function(e){var a=e.ariaSelection,r=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,l=e.isFocused,o=e.selectValue,s=e.selectProps,u=e.id,d=s.ariaLiveMessages,f=s.getOptionLabel,h=s.inputValue,p=s.isMulti,m=s.isOptionDisabled,b=s.isSearchable,g=s.menuIsOpen,S=s.options,w=s.screenReaderStatus,y=s.tabSelectsValue,x=s["aria-label"],j=s["aria-live"],C=v.useMemo(function(){return k(k({},ns),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(Jt,{id:u},D&&H),P(Jt,{"aria-live":j,"aria-atomic":"false","aria-relevant":"additions text"},l&&!D&&H))},rs=as,bt=[{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źẑżžẓẕƶȥɀⱬꝣ"}],is=new RegExp("["+bt.map(function(n){return n.letters}).join("")+"]","g"),Jn={};for(var ut=0;ut-1}},cs=["innerRef"];function us(n){var e=n.innerRef,a=he(n,cs),r=Ri(a,"onExited","in","enter","exit","appear");return P("input",E({ref:e},r,{css:hn({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 ds=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function fs(n){var e=n.isEnabled,a=n.onBottomArrive,r=n.onBottomLeave,t=n.onTopArrive,i=n.onTopLeave,l=v.useRef(!1),o=v.useRef(!1),s=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&&l.current&&(r&&r(g),l.current=!1),V&&o.current&&(i&&i(g),o.current=!1),V&&S>M?(a&&!l.current&&a(g),C.scrollTop=x,T=!0,l.current=!0):!V&&-S>y&&(t&&!o.current&&t(g),C.scrollTop=0,T=!0,o.current=!0),T&&ds(g)}},[a,r,t,i]),f=v.useCallback(function(g){d(g,g.deltaY)},[d]),h=v.useCallback(function(g){s.current=g.changedTouches[0].clientY},[]),p=v.useCallback(function(g){var S=s.current-g.changedTouches[0].clientY;d(g,S)},[d]),m=v.useCallback(function(g){if(g){var S=Ei?{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 en=["boxSizing","height","overflow","paddingRight","position"],tn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function nn(n){n.preventDefault()}function an(n){n.stopPropagation()}function rn(){var n=this.scrollTop,e=this.scrollHeight,a=n+this.offsetHeight;n===0?this.scrollTop=1:a===e&&(this.scrollTop=n-1)}function on(){return"ontouchstart"in window||navigator.maxTouchPoints}var sn=!!(typeof window<"u"&&window.document&&window.document.createElement),Ve=0,Ce={capture:!1,passive:!1};function ps(n){var e=n.isEnabled,a=n.accountForScrollbars,r=a===void 0?!0:a,t=v.useRef({}),i=v.useRef(null),l=v.useCallback(function(s){if(sn){var u=document.body,d=u&&u.style;if(r&&en.forEach(function(m){var b=d&&d[m];t.current[m]=b}),r&&Ve<1){var f=parseInt(t.current.paddingRight,10)||0,h=document.body?document.body.clientWidth:0,p=window.innerWidth-h+f||0;Object.keys(tn).forEach(function(m){var b=tn[m];d&&(d[m]=b)}),d&&(d.paddingRight="".concat(p,"px"))}u&&on()&&(u.addEventListener("touchmove",nn,Ce),s&&(s.addEventListener("touchstart",rn,Ce),s.addEventListener("touchmove",an,Ce))),Ve+=1}},[r]),o=v.useCallback(function(s){if(sn){var u=document.body,d=u&&u.style;Ve=Math.max(Ve-1,0),r&&Ve<1&&en.forEach(function(f){var h=t.current[f];d&&(d[f]=h)}),u&&on()&&(u.removeEventListener("touchmove",nn,Ce),s&&(s.removeEventListener("touchstart",rn,Ce),s.removeEventListener("touchmove",an,Ce)))}},[r]);return v.useEffect(function(){if(e){var s=i.current;return l(s),function(){o(s)}}},[e,l,o]),function(s){i.current=s}}var hs=function(e){var a=e.target;return a.ownerDocument.activeElement&&a.ownerDocument.activeElement.blur()},ms={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function vs(n){var e=n.children,a=n.lockEnabled,r=n.captureEnabled,t=r===void 0?!0:r,i=n.onBottomArrive,l=n.onBottomLeave,o=n.onTopArrive,s=n.onTopLeave,u=fs({isEnabled:t,onBottomArrive:i,onBottomLeave:l,onTopArrive:o,onTopLeave:s}),d=ps({isEnabled:a}),f=function(p){u(p),d(p)};return P(v.Fragment,null,a&&P("div",{onClick:hs,css:ms}),e(f))}var gs={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},bs=function(e){var a=e.name,r=e.onFocus;return P("input",{required:!0,name:a,tabIndex:-1,"aria-hidden":"true",onFocus:r,css:gs,value:"",onChange:function(){}})},Ss=bs,xs=function(e){return e.label},ys=function(e){return e.label},Cs=function(e){return e.value},ws=function(e){return!!e.isDisabled},Os={clearIndicator:co,container:Ji,control:go,dropdownIndicator:so,group:yo,groupHeading:wo,indicatorsContainer:no,indicatorSeparator:fo,input:ko,loadingIndicator:mo,loadingMessage:Yi,menu:Ai,menuList:Wi,menuPortal:Xi,multiValue:Eo,multiValueLabel:Fo,multiValueRemove:Lo,noOptionsMessage:Gi,option:Ao,placeholder:Bo,singleValue:Go,valueContainer:eo},Is={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%)"},Ms=4,ea=4,ks=38,Ps=ea*2,js={baseUnit:ea,controlHeight:ks,menuGutter:Ps},pt={borderRadius:Ms,colors:Is,spacing:js},Ds={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:qt(),captureMenuScroll:!qt(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:ls(),formatGroupLabel:xs,getOptionLabel:ys,getOptionValue:Cs,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:ws,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!Di(),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 ln(n,e,a,r){var t=ra(n,e,a),i=ia(n,e,a),l=aa(n,e),o=qe(n,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:l,value:o,index:r}}function ta(n,e){return n.options.map(function(a,r){if("options"in a){var t=a.options.map(function(l,o){return ln(n,l,e,o)}).filter(function(l){return cn(n,l)});return t.length>0?{type:"group",data:a,options:t,index:r}:void 0}var i=ln(n,a,e,r);return cn(n,i)?i:void 0}).filter(Fi)}function na(n){return n.reduce(function(e,a){return a.type==="group"?e.push.apply(e,Rn(a.options.map(function(r){return r.data}))):e.push(a.data),e},[])}function Vs(n,e){return na(ta(n,e))}function cn(n,e){var a=n.inputValue,r=a===void 0?"":a,t=e.data,i=e.isSelected,l=e.label,o=e.value;return(!sa(n)||!i)&&oa(n,{label:l,value:o,data:t},r)}function Es(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 aa=function(e,a){return e.getOptionLabel(a)},qe=function(e,a){return e.getOptionValue(a)};function ra(n,e,a){return typeof n.isOptionDisabled=="function"?n.isOptionDisabled(e,a):!1}function ia(n,e,a){if(a.indexOf(e)>-1)return!0;if(typeof n.isOptionSelected=="function")return n.isOptionSelected(e,a);var r=qe(n,e);return a.some(function(t){return qe(n,t)===r})}function oa(n,e,a){return n.filterOption?n.filterOption(e,a):!0}var sa=function(e){var a=e.hideSelectedOptions,r=e.isMulti;return a===void 0?r:a},Ls=1,la=function(n){ni(a,n);var e=oi(a);function a(r){var t;if(ei(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,s){var u=t.props,d=u.onChange,f=u.name;s.name=f,t.ariaOnChange(o,s),d(o,s)},t.setValue=function(o,s,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:s,option:u})},t.selectOption=function(o){var s=t.props,u=s.blurInputOnSelect,d=s.isMulti,f=s.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(Rn(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 s=t.props.isMulti,u=t.state.selectValue,d=t.getOptionValue(o),f=u.filter(function(p){return t.getOptionValue(p)!==d}),h=He(s,f,f[0]||null);t.onChange(h,{action:"remove-value",removedValue:o}),t.focusInput()},t.clearValue=function(){var o=t.state.selectValue;t.onChange(He(t.props.isMulti,[],null),{action:"clear",removedValues:o})},t.popValue=function(){var o=t.props.isMulti,s=t.state.selectValue,u=s[s.length-1],d=s.slice(0,s.length-1),f=He(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,s=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 s=t.props.inputValue,u=o.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(u,{action:"input-change",prevInputValue:s}),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 s=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:s}),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 sa(t.props)},t.onValueInputFocus=function(o){o.preventDefault(),o.stopPropagation(),t.focus()},t.onKeyDown=function(o){var s=t.props,u=s.isMulti,d=s.backspaceRemovesValue,f=s.escapeClearsValue,h=s.inputValue,p=s.isClearable,m=s.isDisabled,b=s.menuIsOpen,g=s.onKeyDown,S=s.tabSelectsValue,w=s.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||++Ls),t.state.selectValue=Yt(r.value),r.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),l=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[l]}return t}return ti(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&&Kt(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,l=i.isDisabled,o=i.menuIsOpen,s=this.state.isFocused;(s&&!l&&t.isDisabled||s&&o&&!t.menuIsOpen)&&this.focusInput(),s&&l&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!s&&!l&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Kt(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,l=this.state,o=l.selectValue,s=l.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=!(s&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:u[d]},function(){return i.onMenuOpen()})}},{key:"focusValue",value:function(t){var i=this.state,l=i.selectValue,o=i.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var s=l.indexOf(o);o||(s=-1);var u=l.length-1,d=-1;if(l.length){switch(t){case"previous":s===0?d=0:s===-1?d=u:d=s-1;break;case"next":s>-1&&s0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,l=this.state.focusedOption,o=this.getFocusableOptions();if(o.length){var s=0,u=o.indexOf(l);l||(u=-1),t==="up"?s=u>0?u-1:o.length-1:t==="down"?s=(u+1)%o.length:t==="pageup"?(s=u-i,s<0&&(s=0)):t==="pagedown"?(s=u+i,s>o.length-1&&(s=o.length-1)):t==="last"&&(s=o.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:o[s],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme(pt):k(k({},pt),this.props.theme):pt}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,l=this.getStyles,o=this.getClassNames,s=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:l,getClassNames:o,getValue:s,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,l=t.isMulti;return i===void 0?l:i}},{key:"isOptionDisabled",value:function(t,i){return ra(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return ia(this.props,t,i)}},{key:"filterOption",value:function(t,i){return oa(this.props,t,i)}},{key:"formatOptionLabel",value:function(t,i){if(typeof this.props.formatOptionLabel=="function"){var l=this.props.inputValue,o=this.state.selectValue;return this.props.formatOptionLabel(t,{context:i,inputValue:l,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,l=t.isSearchable,o=t.inputId,s=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")}),!l&&{"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 l?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:s},x)):v.createElement(us,E({id:y,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:Ye,onFocus:this.onInputFocus,disabled:i,tabIndex:u,inputMode:"none",form:d,value:""},x))}},{key:"renderPlaceholderOrValue",value:function(){var t=this,i=this.getComponents(),l=i.MultiValue,o=i.MultiValueContainer,s=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(l,E({},h,{components:{Container:o,Label:s,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,l=this.commonProps,o=this.props,s=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!this.isClearable()||!i||s||!this.hasValue()||u)return null;var f={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},l,{innerProps:f,isFocused:d}))}},{key:"renderLoadingIndicator",value:function(){var t=this.getComponents(),i=t.LoadingIndicator,l=this.commonProps,o=this.props,s=o.isDisabled,u=o.isLoading,d=this.state.isFocused;if(!i||!u)return null;var f={"aria-hidden":"true"};return v.createElement(i,E({},l,{innerProps:f,isDisabled:s,isFocused:d}))}},{key:"renderIndicatorSeparator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator,l=t.IndicatorSeparator;if(!i||!l)return null;var o=this.commonProps,s=this.props.isDisabled,u=this.state.isFocused;return v.createElement(l,E({},o,{isDisabled:s,isFocused:u}))}},{key:"renderDropdownIndicator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator;if(!i)return null;var l=this.commonProps,o=this.props.isDisabled,s=this.state.isFocused,u={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return v.createElement(i,E({},l,{innerProps:u,isDisabled:o,isFocused:s}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),l=i.Group,o=i.GroupHeading,s=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,je=X.isSelected,Ne=X.label,fa=X.value,Lt=b===le,Rt=ce?void 0:function(){return t.onOptionHover(le)},pa=ce?void 0:function(){return t.selectOption(le)},Tt="".concat(t.getElementId("option"),"-").concat(me),ha={id:Tt,onClick:pa,onMouseMove:Rt,onMouseOver:Rt,tabIndex:-1};return v.createElement(p,E({},m,{innerProps:ha,data:le,isDisabled:ce,isSelected:je,key:Tt,label:Ne,type:ve,value:fa,isFocused:Lt,innerRef:Lt?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(l,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(je){return _(je,"".concat(ve,"-").concat(je.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(_i,E({},m,$),function(Y){var X=Y.ref,me=Y.placerProps,ve=me.placement,le=me.maxHeight;return v.createElement(s,E({},m,$,{innerRef:X,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:y,placement:ve}),v.createElement(vs,{captureEnabled:S,onTopArrive:O,onBottomArrive:L,lockEnabled:W},function(ce){return v.createElement(u,E({},m,{innerRef:function(Ne){t.getMenuListRef(Ne),ce(Ne)},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,l=i.delimiter,o=i.isDisabled,s=i.isMulti,u=i.name,d=i.required,f=this.state.selectValue;if(d&&!this.hasValue()&&!o)return v.createElement(Ss,{name:u,onFocus:this.onValueInputFocus});if(!(!u||o))if(s)if(l){var h=f.map(function(b){return t.getOptionValue(b)}).join(l);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,l=i.ariaSelection,o=i.focusedOption,s=i.focusedValue,u=i.isFocused,d=i.selectValue,f=this.getFocusableOptions();return v.createElement(rs,E({},t,{id:this.getElementId("live-region"),ariaSelection:l,focusedOption:o,focusedValue:s,isFocused:u,selectValue:d,focusableOptions:f}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,l=t.IndicatorsContainer,o=t.SelectContainer,s=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(s,E({},b,{isDisabled:h}),this.renderPlaceholderOrValue(),this.renderInput()),v.createElement(l,E({},b,{isDisabled:h}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}],[{key:"getDerivedStateFromProps",value:function(t,i){var l=i.prevProps,o=i.clearFocusValueOnUpdate,s=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=Yt(p),w={};if(l&&(p!==l.value||h!==l.options||m!==l.menuIsOpen||b!==l.inputValue)){var y=m?Vs(t,S):[],x=o?Es(i,S):null,j=Fs(i,y);w={selectValue:S,focusedOption:j,focusedValue:x,clearFocusValueOnUpdate:!1}}var C=s!=null&&t!==l?{inputIsHidden:s,inputIsHiddenAfterUpdate:void 0}:{},V=u,M=d&&f;return d&&!M&&(V={value:He(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);la.defaultProps=Ds;var Rs=v.forwardRef(function(n,e){var a=Qr(n);return v.createElement(la,E({ref:e},a))}),Ts=Rs,Ns=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function St(){return St=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var ca=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=$s(e,Ns);return St({},a)},zs=function(e){var a=typeof e=="string";return a&&["sm","md","lg"].includes(e)},As=function(e){return zs(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},oe=function(e){var a=Le(),r=As(a.components.Input.defaultProps.size),t=e??r,i=yr(typeof t=="string"?[t]:t,{fallback:"md"})||r;return i};function Oe(){return Oe=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var Gs=function(e){var a=e.className,r=e.cx,t=e.children,i=e.innerRef,l=e.innerProps,o=e.isDisabled,s=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=Us(x,Ws),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":s,"control--menu-is-open":u},a),sx:A},l,{"data-focus":s?!0:void 0,"data-focus-visible":s?!0:void 0,"data-invalid":g?!0:void 0,"data-disabled":o?!0:void 0,"data-readonly":S?!0:void 0}),t)},Ys=function(e){var a=e.className,r=e.cx,t=e.selectProps,i=t.chakraStyles,l=t.useBasicStyles,o=t.variant,s=ae({opacity:1},l||o!=="outline"?{display:"none"}:{}),u=i!=null&&i.indicatorSeparator?i.indicatorSeparator(s,e):s;return F.createElement(Mn,{className:r({"indicator-separator":!0},a),sx:u,orientation:"vertical"})},Ks=function(e){return F.createElement(It,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"}))},qs=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,l=e.selectProps,o=l.chakraStyles,s=l.useBasicStyles,u=l.size,d=l.focusBorderColor,f=l.errorBorderColor,h=l.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},s&&{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(Ks,{sx:x}))},Xs=function(e){return F.createElement(It,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"}))},Zs=function(e){var a=e.children,r=e.className,t=e.cx,i=e.innerProps,l=e.selectProps,o=l.chakraStyles,s=l.size,u=oe(s),d=dn("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(Xs,{sx:m}))},Js=function(e){var a=e.className,r=e.cx,t=e.innerProps,i=e.selectProps,l=i.chakraStyles,o=i.size,s=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=l!=null&&l.loadingIndicator?l.loadingIndicator(g,e):g;return F.createElement(Oa,ae({className:r({indicator:!0,"loading-indicator":!0},a),sx:S},t,{size:h||b,color:s,emptyColor:u,speed:d,thickness:f}))};const Qs=Gs;var el=["innerRef","isDisabled","isHidden","inputClassName"];function Fe(){return Fe=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0)&&(a[t]=n[t]);return a}var nl=function(e){var a=e.className,r=e.cx,t=e.value,i=e.selectProps,l=i.chakraStyles,o=i.isReadOnly,s=ca(e),u=s.innerRef,d=s.isDisabled,f=s.isHidden,h=s.inputClassName,p=tl(s,el),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:Fe({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre",padding:0},m)},g=l!=null&&l.inputContainer?l.inputContainer(b,e):b,S=Fe({background:0,opacity:f?0:1,width:"100%"},m),w=l!=null&&l.input?l.input(S,e):S;return F.createElement(z,{className:r({"input-container":!0},a),"data-value":t||"",sx:g},F.createElement(be.input,Fe({className:r({input:!0},h),ref:u,sx:w,disabled:d,readOnly:o?!0:void 0},p)))};const al=nl;var rl=["data"];function il(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 El=function(e){var a,r=e.components,t=r===void 0?{}:r;e.theme;var i=e.size,l=e.colorScheme,o=l===void 0?"gray":l,s=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=Vl(e,Dl),H=Le(),D=H.components.Input.defaultProps.variant,O=Ga({id:p,isDisabled:s,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=Xe({components:Xe({},jl,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 Fl=El;function Ct(){return Ct=Object.assign?Object.assign.bind():function(n){for(var e=1;e({value:m,label:m})))??[],[o,s]=v.useState(l),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(Ya,{isLazy:!0,onOpen:d,closeOnBlur:!1,placement:"auto",children:[c.jsx(Ka,{children:c.jsx(te,{icon:c.jsx(Vn,{}),children:"Add Tag"})}),c.jsxs(qa,{children:[c.jsx(Xa,{}),c.jsx(Za,{}),c.jsx(jn,{children:c.jsx("b",{children:n.name})}),c.jsxs(Ja,{children:[c.jsx(Rl,{isMulti:!0,name:"tags",options:f,menuIsOpen:!0,value:o,onChange:async m=>{var b;s(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(at,{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(kt,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:u,children:"New Tag"})]})]})]})]})}function Nl({workflow:n}){const e=v.useRef(null),a=Me(),{onDuplicateWorkflow:r}=v.useContext(Pt),[t,i]=v.useState(n.saveLock??!1),l=async()=>{var u;const s=!t;i(s),await((u=G)==null?void 0:u.updateMetaInfo(n.id,{saveLock:s})),a({title:`${s?"Locked":"Unlocked"} successfully`,status:"success",duration:2e3})},o=async s=>{const u=s.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=Qa)==null||h.create({workflowID:n.id,localPath:`workspace_manager/${f.name}`})})};return c.jsxs(c.Fragment,{children:[c.jsxs(ke,{isLazy:!0,closeOnSelect:!1,children:[c.jsx(Te,{border:0,as:Z,"aria-label":"Options",icon:c.jsx(Ir,{size:20}),size:"sm",variant:"outline"}),c.jsxs(Re,{zIndex:101,children:[c.jsx(te,{icon:c.jsx(hr,{}),onClick:()=>r&&r(n.id),children:"Duplicate"}),c.jsx(Tl,{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(jr,{}),onClick:l,children:t?"Unlock":"Lock"})}),c.jsx(te,{icon:c.jsx(Rr,{}),onClick:()=>{var s;(s=e.current)==null||s.click()},children:"Upload Thumbnail Image"})]})]}),c.jsx("input",{style:{display:"none"},ref:e,type:"file",accept:".json,image/png",multiple:!0,onChange:o,onClick:s=>{s.stopPropagation()}})]})}function $l({workflow:n}){const{onDeleteFlow:e}=v.useContext(de);return c.jsxs(we,{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:()=>er(n.id),icon:c.jsx(tr,{color:"#718096",size:23})})}),c.jsx(xn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{e&&e(n.id)}}),c.jsx(Nl,{workflow:n})]})}const un=v.memo(function({workflow:e}){var b,g;const{colorMode:a}=Ot(),{setDraggingFile:r,isMultiSelecting:t,onMultiSelectFlow:i,multiSelectedFlowsID:l}=v.useContext(de),o=l&&l.length>0&&l.includes(e.id),{curFlowID:s,loadWorkflowID:u}=v.useContext(Pt),d=s===e.id,f=a==="light"?"gray.200":"#4A5568",[h,p]=v.useState(!1),m=c.jsx(z,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":void 0,color:d&&!t?"#333":void 0,draggable:!t,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:"3px",onClick:()=>{!t&&u(e.id)},_hover:{bg:f},children:c.jsxs(K,{children:[(((b=e.coverMediaPath)==null?void 0:b.length)||((g=e.latestImage)==null?void 0:g.length))&&c.jsx(dr,{mediaLocalPath:e.coverMediaPath??e.latestImage??"",size:60,hideBrokenImage:!0,isPreview:!0}),c.jsxs(ue,{textAlign:"left",gap:0,children:[c.jsxs(we,{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: ",nr(e.updateTime)]})]})]})});return c.jsx(K,{w:"100%",mb:1,justify:"space-between",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:t?c.jsx(Pe,{isChecked:o,spacing:4,onChange:S=>{i&&i(e.id,S.target.checked)},children:m}):c.jsxs(c.Fragment,{children:[m,h&&c.jsx($l,{workflow:e})]})})});function da({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,[l,o]=v.useState(!1),{onRefreshFilesList:s,draggingFile:u,refreshFolderStamp:d}=v.useContext(de),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=pe)==null?void 0:m.update(u.id,{parentFolderID:i}))}else await((b=G)==null?void 0:b.updateFolder(u.id,{parentFolderID:i}));await(s==null?void 0:s()),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(Ht,{folder:p},p.id)),c.jsx(z,{border:l?"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(un,{workflow:p},p.id)):n.map(p=>xe(p)?c.jsx(Ht,{folder:p},p.id):c.jsx(un,{workflow:p},p.id))})]})}function ql({onClose:n,onClickNewFlow:e}){const[a,r]=v.useState([]),t=v.useRef([]),i=v.useRef([]),{loadWorkflowID:l,curFlowID:o}=v.useContext(Pt),[s,u]=v.useState(),[d,f]=v.useState(!1),[h,p]=v.useState([]),[m,b]=v.useState(0),[g,S]=v.useState(""),w=fr(g,400),y=v.useRef(null),[x,j]=v.useState(null),C=v.useRef(window.localStorage.getItem(ht)??De.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=!!s||!!w,T=()=>{if(M){const I=i.current.filter(R=>{var se;let N=!0,$=!0;return s&&(N=!!((se=R.tags)!=null&&se.includes(s))),w&&($=!!R.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),N&&$});r(ot(I,C.current))}else r(ot(t.current,C.current))},A=I=>{r(ot(a,I)),C.current=I,window.localStorage.setItem(ht,I),!M&&b(Date.now())};v.useEffect(()=>{T()},[w,s]);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(l==null?void 0:l(null)),await V()},[s,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&&or($.json,[R.canvasX,R.canvasY])}};return $e.canvasEl.addEventListener("drop",I),$e.canvasEl.addEventListener("click",n),()=>{$e.canvasEl.removeEventListener("drop",I),$e.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($=>{$||l==null||l(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(de.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(ar,{width:_,height:"100vh",pl:2,pr:2,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:rr,children:[c.jsxs(we,{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(Fn,{}),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:()=>ir()})}),c.jsx(ne,{label:"New workflow",children:c.jsx(Z,{"aria-label":"New workflow",size:"sm",icon:c.jsx(kt,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),c.jsx(K,{alignItems:"center",children:c.jsx(Wr,{})})]}),c.jsxs(we,{direction:"column",h:"calc(100% - 64px)",children:[c.jsx(Gr,{selectedTag:s,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(Ur,{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(Dn,{size:21}),onClick:async()=>{var I;await((I=pe)==null?void 0:I.create({name:"New Folder"})),V()},"aria-label":"new folder button"})})]}),c.jsxs(ke,{closeOnSelect:!0,children:[c.jsx(Te,{as:ee,variant:"ghost",size:"xs",pr:0,rightIcon:c.jsx(Mt,{size:"16"}),children:c.jsxs(K,{children:[c.jsx(J,{children:"Sort by:"}),c.jsx(J,{display:"inline-block",children:C.current})]})}),c.jsx(Re,{children:c.jsx(Pn,{value:C.current,type:"radio",onChange:I=>A(I),children:[De.RECENTLY_MODIFIED,De.OLDEST_MODIFIED,De.AZ,De.ZA].map((I,R)=>c.jsx(jt,{value:I,children:I},R))})})]})]}),c.jsx(pr,{searchValue:g,onUpdateSearchValue:L}),c.jsx(we,{overflowY:"auto",overflowX:"hidden",direction:"column",children:c.jsx(da,{items:a})})]})]})})})}export{ql as default}; diff --git a/dist/workspace_web/ShareDialog-T1peQu-u.js b/dist/workspace_web/ShareDialog-T1peQu-u.js deleted file mode 100644 index 1e46452..0000000 --- a/dist/workspace_web/ShareDialog-T1peQu-u.js +++ /dev/null @@ -1 +0,0 @@ -import{r as a,m as he,x as ae,b as fe,f as re,j as e,g as Q,h as pe,n as y,s as M,q as Y,l as ge,o as me,H as ve,ae as we,i as A,M as be,N as ke,O as xe,Q as ye,S as Ce}from"./input.js";import{aK as je,h as Se,B as Ie,K as De,ae as Pe,H as J,l as X,ac as Re,ab as ie,j as _e,p as ne,k as le,aL as Fe,o as Me,F as Ee,aM as Ne,C as q,aN as U,aO as Le,aP as We,aQ as Te,T as Oe,aR as Ve}from"./App-olu4rPJF.js";import{app as He}from"/scripts/app.js";import{t as Ke}from"./index-pz0vT7Or.js";import{L as Be}from"./chunk-K7XRJ7NL-Vyo84f0U.js";import{I as qe}from"./IconCopy-JFcpuy1G.js";import"/scripts/api.js";function Ae(t){return t&&ae(t)&&ae(t.target)}function $e(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[w,C]=a.useState(s||""),b=typeof c<"u",j=b?c:w,k=a.useRef(null),S=a.useCallback(()=>{const n=k.current;if(!n)return;let i="input:not(:disabled):checked";const I=n.querySelector(i);if(I){I.focus();return}i="input:not(:disabled)";const o=n.querySelector(i);o==null||o.focus()},[]),m=`radio-${a.useId()}`,N=d||m,R=a.useCallback(n=>{const i=Ae(n)?n.target.value:n;b||C(i),p==null||p(String(i))},[p,b]),H=a.useCallback((n={},i=null)=>({...n,ref:he(i,k),role:"radiogroup"}),[]),_=a.useCallback((n={},i=null)=>({...n,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?n.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:H,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[Ge,ce]=fe({name:"RadioGroupContext",strict:!1}),de=re((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...w}=t,{value:C,onChange:b,getRootProps:j,name:k,htmlProps:S}=$e(w),E=a.useMemo(()=>({name:k,size:s,onChange:b,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,b,c,C,d,g,f]);return e.jsx(Ge,{value:E,children:e.jsx(Q.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var ze={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Ue(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:w,value:C,id:b,"data-radiogroup":j,"aria-describedby":k,...S}=t,E=`radio-${a.useId()}`,m=je(),R=!!ce()||!!j;let _=!!m&&!R?m.id:E;_=b??_;const n=d??(m==null?void 0:m.isDisabled),i=h??(m==null?void 0:m.isReadOnly),I=u??(m==null?void 0:m.isRequired),o=f??(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),[$,G]=a.useState(!!p),K=typeof c<"u",F=K?c:$;a.useEffect(()=>Ke(P),[]);const O=a.useCallback(r=>{if(i||n){r.preventDefault();return}K||G(r.target.checked),g==null||g(r)},[K,n,i,g]),B=a.useCallback(r=>{r.key===" "&&T(!0)},[T]),z=a.useCallback(r=>{r.key===" "&&T(!1)},[T]),ee=a.useCallback((r={},V=null)=>({...r,ref:V,"data-active":y(W),"data-hover":y(x),"data-disabled":y(n),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(v),"data-focus-visible":y(v&&l),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:M(r.onMouseDown,()=>T(!0)),onMouseUp:M(r.onMouseUp,()=>T(!1)),onMouseEnter:M(r.onMouseEnter,()=>L(!0)),onMouseLeave:M(r.onMouseLeave,()=>L(!1))}),[W,x,n,o,F,v,i,l]),{onFocus:oe,onBlur:se}=m??{},ue=a.useCallback((r={},V=null)=>{const te=n&&!s;return{...r,id:_,ref:V,type:"radio",name:w,value:C,onChange:M(r.onChange,O),onBlur:M(se,r.onBlur,()=>D(!1)),onFocus:M(oe,r.onFocus,()=>D(!0)),onKeyDown:M(r.onKeyDown,B),onKeyUp:M(r.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:I,"aria-invalid":Y(o),"aria-disabled":Y(te),"aria-required":Y(I),"data-readonly":y(i),"aria-describedby":k,style:ze}},[n,s,_,w,C,O,se,oe,B,z,F,i,I,o,k]);return{state:{isInvalid:o,isFocused:v,isChecked:F,isActive:W,isHovered:x,isDisabled:n,isReadOnly:i,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(r={},V=null)=>({...r,ref:V,onMouseDown:M(r.onMouseDown,Qe),"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(r,V=null)=>({...r,ref:V,"data-disabled":y(n),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Qe(t){t.preventDefault(),t.stopPropagation()}function Je(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=re((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=me(t),{spacing:f="0.5rem",children:w,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:b=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let E=d;s!=null&&s.onChange&&h!=null&&(E=ve(s.onChange,d));const m=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:H,getRootProps:_,htmlProps:n}=Ue({...k,isChecked:S,isFocusable:b,isDisabled:C,onChange:E,name:m}),[i,I]=Je(n,we),o=R(I),l=N(j,p),P=H(),v=Object.assign({},i,_()),D={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},L={userSelect:"none",marginStart:f,...u.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",...o,__css:x}),w&&e.jsx(Q.span,{className:"chakra-radio__label",...P,__css:L,children:w})]})});Z.displayName="Radio";var Ye=Se("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 Xe({options:t,value:p,onChange:c}){const[s,d]=a.useState(!1),h=a.useRef(null),u=t.find(f=>f.value===p);a.useEffect(()=>{const f=w=>{h.current&&!h.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Ie,{position:"relative",children:[e.jsx(A,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Pe,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(A,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Ze({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(J,{spacing:4,alignItems:"center",children:[e.jsx(X,{children:s.name}),e.jsx(X,{color:"GrayText",children:Re(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(A,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ye,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ho({onClose:t}){var i,I;const[p,c]=a.useState("v"+eo()),[s,d]=a.useState([]),[h,u]=a.useState(!1),[g,f]=a.useState(""),[w,C]=a.useState("PRIVATE"),[b,j]=a.useState("new_version"),k=a.useRef(""),[S,E]=a.useState(),m=_e(),N=async o=>{var L,W;const l=o.data;if(o.origin!==k.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=q)==null?void 0:L.updateMetaInfo(P,{cloudID:x,cloudOrigin:o.origin,privacy:w})),v&&D&&await((W=U)==null?void 0:W.update(v,{cloudID:D,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+x+"/"+D,"_blank"),u(!1)};a.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,v,D;const o=await((P=ne)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const l=((v=q)==null?void 0:v.curWorkflow)??void 0;E(l),l!=null&&l.cloudID&&l.cloudOrigin&&Te(l).then(x=>{C(x)}),(D=U)==null||D.listByWorkflowID(l.id).then(x=>{d(x)})},H=o=>{navigator.clipboard.writeText(o).then(()=>{m({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var G,K,F;u(!0);const o=Le(32),l=await((G=ne)==null?void 0:G.getSetting("cloudHost"));let P,v;try{if(P=We(),b==="new_version"?v=await((K=U)==null?void 0:K.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(He.graph.serialize())})):v=await((F=U)==null?void 0:F.get(b)),!v){alert(`Failed to find version: ${b}, please try again.`),u(!1);return}}catch(O){console.error(O),u(!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/${o}?redirectUrl=${L}`,T=window.open(W,"Share Workflow","width=800,height=800"),$=O=>{var B;if(O.origin===l&&O.data==="child_ready"){const z=(B=q)==null?void 0:B.curWorkflow;T.postMessage({workflow:z,version:v,nodeDefs:P,privacy:w},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},n=(I=(i=q)==null?void 0:i.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(be,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(xe,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(le,{gap:5,children:[n==null?e.jsx(Xe,{options:Fe,value:w,onChange:o=>{C(o)}}):e.jsx(Oe,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:w,showEmoji:!0})}),n&&e.jsxs(J,{spacing:2,color:"teal.400",children:[e.jsxs(Be,{href:g+"/workflow/"+n,isExternal:!0,children:[g+"/workflow/"+n," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(A,{width:"180px",size:"sm",leftIcon:e.jsx(qe,{}),onClick:()=>{var o,l;H(g+"/workflow/"+((l=(o=q)==null?void 0:o.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(X,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{j(o)},value:b,children:e.jsxs(le,{children:[e.jsxs(J,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Me,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Ne,{colorScheme:"purple",children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Ze,{version:o,cloudHost:g,cloudWorkflowID:n??null},o.id))]})})]}),e.jsx(J,{justifyContent:"flex-end",mt:16,children:e.jsx(A,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function eo(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ho as default}; diff --git a/dist/workspace_web/SpotlightSearch-BOOXnLDY.js b/dist/workspace_web/SpotlightSearch-BOOXnLDY.js deleted file mode 100644 index 73e015d..0000000 --- a/dist/workspace_web/SpotlightSearch-BOOXnLDY.js +++ /dev/null @@ -1 +0,0 @@ -import{b as $,f as j,l as q,o as Q,h as K,r as m,j as n,g as M,a0 as X,M as Z,O as ee,U as te,i as ne}from"./input.js";import{aI as se,au as re,a7 as ae,aE as T,ar as D,H as oe,o as ie,l as O,ac as ce,C as le,ad as ue,aJ as N,E as pe,p as A}from"./App-olu4rPJF.js";import{u as de}from"./useDebounceFn-ld478fd0.js";import{I as he}from"./IconSearch-UuijGRkv.js";import{V as me}from"./chunk-NTCQBYKE-3mwSHd_c.js";import"/scripts/app.js";import"/scripts/api.js";var[ge,Se]=$({name:"InputGroupStylesContext",errorMessage:`useInputGroupStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),P=j(function(a,u){const r=q("Input",a),{children:c,className:l,...I}=Q(a),y=K("chakra-input__group",l),t={},x=se(c),o=r.field;x.forEach(s=>{var p,f;r&&(o&&s.type.id==="InputLeftElement"&&(t.paddingStart=(p=o.height)!=null?p:o.h),o&&s.type.id==="InputRightElement"&&(t.paddingEnd=(f=o.height)!=null?f:o.h),s.type.id==="InputRightAddon"&&(t.borderEndRadius=0),s.type.id==="InputLeftAddon"&&(t.borderStartRadius=0))});const S=x.map(s=>{var p,f;const b=re({size:((p=s.props)==null?void 0:p.size)||a.size,variant:((f=s.props)==null?void 0:f.variant)||a.variant});return s.type.id!=="Input"?m.cloneElement(s,b):m.cloneElement(s,Object.assign(b,t,s.props))});return n.jsx(M.div,{className:y,ref:u,__css:{width:"100%",display:"flex",position:"relative",isolation:"isolate",...r.group},"data-group":!0,...I,children:n.jsx(ge,{value:r,children:S})})});P.displayName="InputGroup";var fe=M("div",{baseStyle:{display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"0",zIndex:2}}),C=j(function(a,u){var r,c;const{placement:l="left",...I}=a,y=Se(),t=y.field,o={[l==="left"?"insetStart":"insetEnd"]:"0",width:(r=t==null?void 0:t.height)!=null?r:t==null?void 0:t.h,height:(c=t==null?void 0:t.height)!=null?c:t==null?void 0:t.h,fontSize:t==null?void 0:t.fontSize,...y.element};return n.jsx(fe,{ref:u,__css:o,...I})});C.id="InputElement";C.displayName="InputElement";var U=j(function(a,u){const{className:r,...c}=a,l=K("chakra-input__left-element",r);return n.jsx(C,{ref:u,placement:"left",className:l,...c})});U.id="InputLeftElement";U.displayName="InputLeftElement";var z=j(function(a,u){const{className:r,...c}=a,l=K("chakra-input__right-element",r);return n.jsx(C,{ref:u,placement:"right",className:l,...c})});z.id="InputRightElement";z.displayName="InputRightElement";function Le(){const{colorMode:g}=X(),{loadWorkflowID:a,setRoute:u}=m.useContext(ae),[r,c]=m.useState([]),[l,I,y]=T(""),t=m.useRef([]),[x,o,S]=T([]),[s,p]=m.useState(!1),[f,b,L]=T(0),E=m.useRef({lastPressedKey:"",spotlightSearchShortcutFirstKey:"",spotlightSearchShortcutLastKey:""}),F=()=>{u("root")},_=e=>{a(e.id),F()},H=()=>{const e=r.filter(i=>!!i.name.toLocaleLowerCase().includes(y.current.toLocaleLowerCase()));o(e),b(0),p(!1)},[V,B]=de(H,300),W=e=>{I(e.target.value),e.target.value?(V(),!s&&p(!0)):(p(!1),B(),o(t.current))},Y=()=>s?null:l&&x.length===0?n.jsx(O,{ml:2,children:"No matching results"}):n.jsx(n.Fragment,{children:x.map((e,i)=>n.jsxs(ne,{colorScheme:"teal",variant:"ghost",size:"sm",justifyContent:"start",px:2,color:g==="light"?"#1A202C":"rgba(255, 255, 255, 0.92)",onClick:()=>{_(e)},minH:"26px",isActive:i===f,children:[e.name,e.updateTime&&n.jsxs(O,{color:g==="light"?"GrayText":"rgb(255, 255, 255, 0.6)",ml:2,fontSize:"sm",children:["Updated: ",ce(e.updateTime)]})]},e.id))}),J=async()=>{var k;const e=h=>h.map(v=>({type:"workflow",updateTime:(v==null?void 0:v.updateTime)??Date.now(),id:v.id,name:v.name.replace(/\.json$/,"")}))??[],i=await((k=le)==null?void 0:k.listAll(ue.RECENTLY_OPENED))??[];c(e(i));const d=e(i.slice(0,20));t.current=d,o(d)},w=e=>{b(i=>{const d=i+e;return d<0?S.current.length-1:d>S.current.length-1?0:d})};return m.useEffect(()=>{var k;J(),(k=A)==null||k.getSetting("shortcuts").then(h=>{var G;const R=(h.openSpotlightSearch??((G=A)==null?void 0:G.defaultSettings.shortcuts.openSpotlightSearch)).split("+");E.current.spotlightSearchShortcutFirstKey=R[0]==="Command"?"Meta":R[0],E.current.spotlightSearchShortcutLastKey=R[R.length-1]});const e=h=>{h.key===E.current.spotlightSearchShortcutFirstKey&&E.current.lastPressedKey===E.current.spotlightSearchShortcutLastKey&&L.current>0&&S.current[L.current]&&_(S.current[L.current])},i=h=>{E.current.lastPressedKey=h.key.toUpperCase()},d=h=>{switch(h.detail.shortcutType){case pe.openSpotlightSearch:w(1);break;case N.ArrowDown:w(1);break;case N.ArrowUp:w(-1);break;case N.Enter:_(S.current[L.current]);break}};return document.addEventListener("keyup",e),document.addEventListener("keydown",i),window.addEventListener(D,d),()=>{document.removeEventListener("keyup",e),document.removeEventListener("keydown",i),window.removeEventListener(D,d)}},[]),n.jsx(Z,{isOpen:!0,onClose:F,size:"xl",children:n.jsxs(ee,{bg:g==="light"?"rgba(255, 255, 255, 0.8)":"rgb(45, 55, 72, 0.8)",backdropFilter:"auto",backdropBlur:"8px",children:[n.jsxs(oe,{spacing:1,px:4,py:2,borderBottom:"1px",borderColor:"gray.400",children:[n.jsx(he,{size:20}),n.jsxs(P,{children:[n.jsx(ie,{value:l,onChange:W,autoFocus:!0,variant:"unstyled",fontSize:18}),s&&n.jsx(z,{h:"27px",children:n.jsx(te,{size:"sm"})})]})]}),n.jsx(me,{spacing:1,align:"stretch",px:2,py:2,maxHeight:"calc(100vh - 200px)",overflowY:"auto",children:Y()})]})})}export{Le as default}; diff --git a/dist/workspace_web/chunk-3RSXBRAN-FQauAkwt.js b/dist/workspace_web/chunk-3RSXBRAN-FQauAkwt.js deleted file mode 100644 index 06e38ea..0000000 --- a/dist/workspace_web/chunk-3RSXBRAN-FQauAkwt.js +++ /dev/null @@ -1 +0,0 @@ -import{f as x,j as l,g as i,h as b,l as C,o as E,n as I,r as f,ae as P}from"./input.js";import{a0 as z}from"./App-olu4rPJF.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-au6_4y-J.js b/dist/workspace_web/chunk-JARCRF6W-au6_4y-J.js deleted file mode 100644 index 0fef7f8..0000000 --- a/dist/workspace_web/chunk-JARCRF6W-au6_4y-J.js +++ /dev/null @@ -1 +0,0 @@ -import{b as de,r as o,j as u,g as I,d as $,e as z,y as ue,n,s as m,m as te,a6 as W,f as ae,l as fe,o as me,H as he,h as ke}from"./input.js";import{ap as be}from"./App-olu4rPJF.js";import{t as pe}from"./index-pz0vT7Or.js";var[Ne,ve]=de({name:"CheckboxGroupContext",strict:!1});function Ce(s){const[l,t]=o.useState(s),[a,f]=o.useState(!1);return s!==l&&(f(!0),t(s)),a}function ye(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...s,children:u.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function ge(s){return u.jsx(I.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...s,children:u.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function xe(s){const{isIndeterminate:l,isChecked:t,...a}=s,f=l?ge:ye;return t||l?u.jsx(I.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:u.jsx(f,{...a})}):null}var Ie={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function we(s,l=[]){const t=Object.assign({},s);for(const a of l)a in t&&delete t[a];return t}function Se(s={}){const l=be(s),{isDisabled:t,isReadOnly:a,isRequired:f,isInvalid:r,id:b,onBlur:P,onFocus:A,"aria-describedby":C}=l,{defaultChecked:y,isChecked:g,isFocusable:D,onChange:R,isIndeterminate:c,name:x,value:M,tabIndex:N=void 0,"aria-label":_,"aria-labelledby":j,"aria-invalid":p,...q}=s,F=we(q,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),E=$(R),K=$(P),L=$(A),[w,T]=o.useState(!1),[v,U]=o.useState(!1),[B,X]=o.useState(!1),[G,S]=o.useState(!1);o.useEffect(()=>pe(T),[]);const h=o.useRef(null),[J,ne]=o.useState(!0),[oe,H]=o.useState(!!y),V=g!==void 0,i=V?g:oe,Q=o.useCallback(e=>{if(a||t){e.preventDefault();return}V||H(i?e.target.checked:c?!0:e.target.checked),E==null||E(e)},[a,t,i,V,c,E]);z(()=>{h.current&&(h.current.indeterminate=!!c)},[c]),ue(()=>{t&&U(!1)},[t,U]),z(()=>{const e=h.current;if(!(e!=null&&e.form))return;const d=()=>{H(!!y)};return e.form.addEventListener("reset",d),()=>{var k;return(k=e.form)==null?void 0:k.removeEventListener("reset",d)}},[]);const Y=t&&!D,Z=o.useCallback(e=>{e.key===" "&&S(!0)},[S]),ee=o.useCallback(e=>{e.key===" "&&S(!1)},[S]);z(()=>{if(!h.current)return;h.current.checked!==i&&H(h.current.checked)},[h.current]);const se=o.useCallback((e={},d=null)=>{const k=O=>{v&&O.preventDefault(),S(!0)};return{...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(v),"data-focus-visible":n(v&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a),"aria-hidden":!0,onMouseDown:m(e.onMouseDown,k),onMouseUp:m(e.onMouseUp,()=>S(!1)),onMouseEnter:m(e.onMouseEnter,()=>X(!0)),onMouseLeave:m(e.onMouseLeave,()=>X(!1))}},[G,i,t,v,w,B,c,r,a]),re=o.useCallback((e={},d=null)=>({...e,ref:d,"data-active":n(G),"data-hover":n(B),"data-checked":n(i),"data-focus":n(v),"data-focus-visible":n(v&&w),"data-indeterminate":n(c),"data-disabled":n(t),"data-invalid":n(r),"data-readonly":n(a)}),[G,i,t,v,w,B,c,r,a]),ie=o.useCallback((e={},d=null)=>({...F,...e,ref:te(d,k=>{k&&ne(k.tagName==="LABEL")}),onClick:m(e.onClick,()=>{var k;J||((k=h.current)==null||k.click(),requestAnimationFrame(()=>{var O;(O=h.current)==null||O.focus({preventScroll:!0})}))}),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[F,t,i,r,J]),le=o.useCallback((e={},d=null)=>({...e,ref:te(h,d),type:"checkbox",name:x,value:M,id:b,tabIndex:N,onChange:m(e.onChange,Q),onBlur:m(e.onBlur,K,()=>U(!1)),onFocus:m(e.onFocus,L,()=>U(!0)),onKeyDown:m(e.onKeyDown,Z),onKeyUp:m(e.onKeyUp,ee),required:f,checked:i,disabled:Y,readOnly:a,"aria-label":_,"aria-labelledby":j,"aria-invalid":p?!!p:r,"aria-describedby":C,"aria-disabled":t,style:Ie}),[x,M,b,Q,K,L,Z,ee,f,i,Y,a,_,j,p,r,C,t,N]),ce=o.useCallback((e={},d=null)=>({...e,ref:d,onMouseDown:m(e.onMouseDown,Pe),"data-disabled":n(t),"data-checked":n(i),"data-invalid":n(r)}),[i,t,r]);return{state:{isInvalid:r,isFocused:v,isChecked:i,isActive:G,isHovered:B,isIndeterminate:c,isDisabled:t,isReadOnly:a,isRequired:f},getRootProps:ie,getCheckboxProps:se,getIndicatorProps:re,getInputProps:le,getLabelProps:ce,htmlProps:F}}function Pe(s){s.preventDefault(),s.stopPropagation()}var Ae={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},De={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Re=W({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),_e=W({from:{opacity:0},to:{opacity:1}}),je=W({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Fe=ae(function(l,t){const a=ve(),f={...a,...l},r=fe("Checkbox",f),b=me(l),{spacing:P="0.5rem",className:A,children:C,iconColor:y,iconSize:g,icon:D=u.jsx(xe,{}),isChecked:R,isDisabled:c=a==null?void 0:a.isDisabled,onChange:x,inputProps:M,...N}=b;let _=R;a!=null&&a.value&&b.value&&(_=a.value.includes(b.value));let j=x;a!=null&&a.onChange&&b.value&&(j=he(a.onChange,x));const{state:p,getInputProps:q,getCheckboxProps:F,getLabelProps:E,getRootProps:K}=Se({...N,isDisabled:c,isChecked:_,onChange:j}),L=Ce(p.isChecked),w=o.useMemo(()=>({animation:L?p.isIndeterminate?`${_e} 20ms linear, ${je} 200ms linear`:`${Re} 200ms linear`:void 0,fontSize:g,color:y,...r.icon}),[y,g,L,p.isIndeterminate,r.icon]),T=o.cloneElement(D,{__css:w,isIndeterminate:p.isIndeterminate,isChecked:p.isChecked});return u.jsxs(I.label,{__css:{...De,...r.container},className:ke("chakra-checkbox",A),...K(),children:[u.jsx("input",{className:"chakra-checkbox__input",...q(M,t)}),u.jsx(I.span,{__css:{...Ae,...r.control},className:"chakra-checkbox__control",...F(),children:T}),C&&u.jsx(I.span,{className:"chakra-checkbox__label",...E(),__css:{marginStart:P,...r.label},children:C})]})});Fe.displayName="Checkbox";var Ee=ae(function(l,t){const{templateAreas:a,gap:f,rowGap:r,columnGap:b,column:P,row:A,autoFlow:C,autoRows:y,templateRows:g,autoColumns:D,templateColumns:R,...c}=l,x={display:"grid",gridTemplateAreas:a,gridGap:f,gridRowGap:r,gridColumnGap:b,gridAutoColumns:D,gridColumn:P,gridRow:A,gridAutoFlow:C,gridAutoRows:y,gridTemplateRows:g,gridTemplateColumns:R};return u.jsx(I.div,{ref:t,__css:x,...c})});Ee.displayName="Grid";export{Fe as C,Ee as G,Se as u}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-3mwSHd_c.js b/dist/workspace_web/chunk-NTCQBYKE-3mwSHd_c.js deleted file mode 100644 index ef86901..0000000 --- a/dist/workspace_web/chunk-NTCQBYKE-3mwSHd_c.js +++ /dev/null @@ -1 +0,0 @@ -import{k as t}from"./App-olu4rPJF.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};