diff --git a/__init__.py b/__init__.py index c3c4795..d388bc9 100644 --- a/__init__.py +++ b/__init__.py @@ -16,7 +16,7 @@ import json from .version_control import update_version_if_outdated from .service.model_manager.model_installer import download_url_with_wget from .service.model_manager.model_list import get_model_list -from .service.model_manager.model_preview import get_thumbnail_for_image_file +from .service.media_service import * WEB_DIRECTORY = "entry" DEFAULT_USER = "guest" @@ -205,46 +205,6 @@ async def rename_file(request): else: return web.Response(text="File not found", status=404) -image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'] -video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv'] -@server.PromptServer.instance.routes.get("/workspace/view_media") -async def api_view_file(request): - filename = request.query.get("filename", None) - if not filename: - return web.Response(status=404) - - # validation for security: prevent accessing arbitrary path - if filename[0] == '/' or '..' in filename: - return web.Response(status=400) - - output_path = folder_paths.get_output_directory() - file_path = os.path.join(output_path, filename) - - if not os.path.exists(file_path): - return web.Response(status=404) - - file_extension = os.path.splitext(filename)[1].lower() - if file_extension in image_extensions: - return web.json_response( - body=get_thumbnail_for_image_file(file_path), - content_type='image/jpeg', - headers={"Content-Disposition": f"filename=\"{filename}.jpg\""} - ) - - with open(file_path, 'rb') as f: - media_file = f.read() - - content_type = 'application/json' - if file_extension in video_extensions: - content_type = f'video/{file_extension[1:]}' - - return web.Response( - body=media_file, - content_type=content_type, - headers={"Content-Disposition": f"filename=\"{filename}\""} - ) - - @server.PromptServer.instance.routes.post("/workspace/open_workflow_file_browser") async def open_workflow_file_browser(request): my_workflows_dir = get_my_workflows_dir() diff --git a/dist/workspace_web/App-09wdM9e8.js b/dist/workspace_web/App-09wdM9e8.js new file mode 100644 index 0000000..572e683 --- /dev/null +++ b/dist/workspace_web/App-09wdM9e8.js @@ -0,0 +1,15 @@ +var Wi=Object.defineProperty;var Ki=(t,e,n)=>e in t?Wi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ce=(t,e,n)=>(Ki(t,typeof e!="symbol"?e+"":e,n),n);import{u as $i,a as zi,r as y,c as Ui,b as Ke,m as xe,d as vt,f as G,j as v,B as Ne,e as qi,g as V,h as oe,o as $e,i as Ot,k as ze,I as Vi,l as yr,n as Nr,p as le,q as Hi,s as Ji,t as Yi,v as Gi,w as gr,x as Xi,y as Zi,z as Qi,A as el,C as tl,D as To,E as aa,F as Bo,G as ia,H as nl,J as rl,K as ol,P as la,M as Lo,L as Wo,N as Ko,O as $o,Q as zo,R as Uo,S as qo,_ as wr,T as sl,U as al,V as Vo}from"./input.js";import{app as ye}from"/scripts/app.js";import{api as Es}from"/scripts/api.js";function il(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function ca(t){var e;return il(t)&&(e=t.ownerDocument)!=null?e:document}function ll(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var cl=ll();function ul(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function dl(t){const{theme:e}=$i(),n=zi();return y.useMemo(()=>Ui(e.direction,{...n,...t}),[t,e.direction,n])}var fl=Object.defineProperty,hl=(t,e,n)=>e in t?fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ue=(t,e,n)=>(hl(t,typeof e!="symbol"?e+"":e,n),n);function Ds(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 pl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Os(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Ss(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var Jr=typeof window<"u"?y.useLayoutEffect:y.useEffect,Qn=t=>t,ml=class{constructor(){ue(this,"descendants",new Map),ue(this,"register",t=>{if(t!=null)return pl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),ue(this,"unregister",t=>{this.descendants.delete(t);const e=Ds(Array.from(this.descendants.keys()));this.assignIndex(e)}),ue(this,"destroy",()=>{this.descendants.clear()}),ue(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),ue(this,"count",()=>this.descendants.size),ue(this,"enabledCount",()=>this.enabledValues().length),ue(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),ue(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),ue(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),ue(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),ue(this,"first",()=>this.item(0)),ue(this,"firstEnabled",()=>this.enabledItem(0)),ue(this,"last",()=>this.item(this.descendants.size-1)),ue(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),ue(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),ue(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),ue(this,"next",(t,e=!0)=>{const n=Os(t,this.count(),e);return this.item(n)}),ue(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Os(r,this.enabledCount(),e);return this.enabledItem(o)}),ue(this,"prev",(t,e=!0)=>{const n=Ss(t,this.count()-1,e);return this.item(n)}),ue(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Ss(r,this.enabledCount()-1,e);return this.enabledItem(o)}),ue(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Ds(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 vl(){const t=y.useRef(new ml);return Jr(()=>()=>t.current.destroy()),t.current}var[yl,ua]=Ke({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function gl(t){const e=ua(),[n,r]=y.useState(-1),o=y.useRef(null);Jr(()=>()=>{o.current&&e.unregister(o.current)},[]),Jr(()=>{if(!o.current)return;const a=Number(o.current.dataset.index);n!=a&&!Number.isNaN(a)&&r(a)});const s=Qn(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:xe(s,o)}}function da(){return[Qn(yl),()=>Qn(ua()),()=>vl(),o=>gl(o)]}function fa(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(f,p)=>f!==p}=t,s=vt(r),a=vt(o),[i,l]=y.useState(n),u=e!==void 0,c=u?e:i,d=vt(f=>{const b=typeof f=="function"?f(c):f;a(c,b)&&(u||l(b),s(b))},[u,s,c,a]);return[c,d]}function Ho(t){return y.Children.toArray(t).filter(e=>y.isValidElement(e))}var hn=G((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...a}=t,i=n||r,l=y.isValidElement(i)?y.cloneElement(i,{"aria-hidden":!0,focusable:!1}):null;return v.jsx(Ne,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...a,children:l})});hn.displayName="IconButton";var[wl,ha]=qi("Card"),bl=G(function(e,n){const{className:r,...o}=e,s=ha();return v.jsx(V.div,{ref:n,className:oe("chakra-card__body",r),__css:s.body,...o})}),xl=G(function(e,n){const{className:r,...o}=e,s=ha();return v.jsx(V.div,{ref:n,className:oe("chakra-card__header",r),__css:s.header,...o})}),_l=G(function(e,n){const{className:r,children:o,direction:s="column",justify:a,align:i,...l}=$e(e),u=Ot("Card",e);return v.jsx(V.div,{ref:n,className:oe("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:a,alignItems:i,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:v.jsx(wl,{value:u,children:o})})}),[kl,pa]=Ke({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Cl,Yt]=Ke({strict:!1,name:"FormControlContext"});function El(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...a}=t,i=y.useId(),l=e||`field-${i}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[f,p]=y.useState(!1),[b,h]=y.useState(!1),[w,g]=y.useState(!1),m=y.useCallback((x={},O=null)=>({id:d,...x,ref:xe(O,D=>{D&&h(!0)})}),[d]),_=y.useCallback((x={},O=null)=>({...x,ref:O,"data-focus":ze(w),"data-disabled":ze(o),"data-invalid":ze(r),"data-readonly":ze(s),id:x.id!==void 0?x.id:u,htmlFor:x.htmlFor!==void 0?x.htmlFor:l}),[l,o,w,r,s,u]),k=y.useCallback((x={},O=null)=>({id:c,...x,ref:xe(O,D=>{D&&p(!0)}),"aria-live":"polite"}),[c]),E=y.useCallback((x={},O=null)=>({...x,...a,ref:O,role:"group","data-focus":ze(w),"data-disabled":ze(o),"data-invalid":ze(r),"data-readonly":ze(s)}),[a,o,w,r,s]),C=y.useCallback((x={},O=null)=>({...x,ref:O,role:"presentation","aria-hidden":!0,children:x.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!w,onFocus:()=>g(!0),onBlur:()=>g(!1),hasFeedbackText:f,setHasFeedbackText:p,hasHelpText:b,setHasHelpText:h,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:a,getHelpTextProps:m,getErrorMessageProps:k,getRootProps:E,getLabelProps:_,getRequiredIndicatorProps:C}}var br=G(function(e,n){const r=Ot("Form",e),o=$e(e),{getRootProps:s,htmlProps:a,...i}=El(o),l=oe("chakra-form-control",e.className);return v.jsx(Cl,{value:i,children:v.jsx(kl,{value:r,children:v.jsx(V.div,{...s({},n),className:l,__css:r.container})})})});br.displayName="FormControl";var Dl=G(function(e,n){const r=Yt(),o=pa(),s=oe("chakra-form__helper-text",e.className);return v.jsx(V.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Dl.displayName="FormHelperText";var[Ol,Sl]=Ke({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),xr=G((t,e)=>{const n=Ot("FormError",t),r=$e(t),o=Yt();return o!=null&&o.isInvalid?v.jsx(Ol,{value:n,children:v.jsx(V.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:oe("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});xr.displayName="FormErrorMessage";var Il=G((t,e)=>{const n=Sl(),r=Yt();if(!(r!=null&&r.isInvalid))return null;const o=oe("chakra-form__error-icon",t.className);return v.jsx(Vi,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:v.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"})})});Il.displayName="FormErrorIcon";var _r=G(function(e,n){var r;const o=yr("FormLabel",e),s=$e(e),{className:a,children:i,requiredIndicator:l=v.jsx(ma,{}),optionalIndicator:u=null,...c}=s,d=Yt(),f=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return v.jsxs(V.label,{...f,className:oe("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[i,d!=null&&d.isRequired?l:u]})});_r.displayName="FormLabel";var ma=G(function(e,n){const r=Yt(),o=pa();if(!(r!=null&&r.isRequired))return null;const s=oe("chakra-form__required-indicator",e.className);return v.jsx(V.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});ma.displayName="RequiredIndicator";function Pl(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=jl(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":Nr(n),"aria-required":Nr(o),"aria-readonly":Nr(r)}}function jl(t){var e,n,r;const o=Yt(),{id:s,disabled:a,readOnly:i,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:f,onFocus:p,onBlur:b,...h}=t,w=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&w.push(o.feedbackId),o!=null&&o.hasHelpText&&w.push(o.helpTextId),{...h,"aria-describedby":w.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=a??f)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=i??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:le(o==null?void 0:o.onFocus,p),onBlur:le(o==null?void 0:o.onBlur,b)}}function Lt(t,e,n,r){const o=vt(n);return y.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 Nl(t){return"current"in t}var va=()=>typeof window<"u";function Al(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Fl=t=>va()&&t.test(navigator.vendor),Ml=t=>va()&&t.test(Al()),Rl=()=>Ml(/mac|iphone|ipad|ipod/i),Tl=()=>Rl()&&Fl(/apple/i);function Bl(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,a;return(a=(s=e.current)==null?void 0:s.ownerDocument)!=null?a:document};Lt(o,"pointerdown",s=>{if(!Tl()||!r)return;const a=s.target,l=(n??[e]).some(u=>{const c=Nl(u)?u.current:u;return(c==null?void 0:c.contains(a))||c===a});o().activeElement!==a&&l&&(s.preventDefault(),a.focus())})}var ya={exports:{}},Ll="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Wl=Ll,Kl=Wl;function ga(){}function wa(){}wa.resetWarningCache=ga;var $l=function(){function t(r,o,s,a,i,l){if(l!==Kl){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:wa,resetWarningCache:ga};return n.PropTypes=n,n};ya.exports=$l();var zl=ya.exports;const dt=Hi(zl);function Ul(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 ql(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function ba(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Ji(t)&&Ul(t)?t:ba(ql(t))}var Vl=cl?y.useLayoutEffect:y.useEffect;function Yr(t,e=[]){const n=y.useRef(t);return Vl(()=>{n.current=t}),y.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Hl(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Yr(n),a=y.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;y.useEffect(()=>{if(!r)return;const i=d=>{Ar(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Ar(d,e)&&(a.isPointerDown=!1,o(d))},u=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Ar(d,e)&&(a.isPointerDown=!1,o(d))},c=ca(e.current);return c.addEventListener("mousedown",i,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",i,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",i,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",i,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,a,r])}function Ar(t,e){var n;const r=t.target;return r&&!ca(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Jl(t,e){const n=y.useId();return y.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Yl(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Gl(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Yr(n),a=Yr(e),[i,l]=y.useState(t.defaultIsOpen||!1),[u,c]=Yl(r,i),d=Jl(o,"disclosure"),f=y.useCallback(()=>{u||l(!1),a==null||a()},[u,a]),p=y.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),b=y.useCallback(()=>{(c?f:p)()},[c,p,f]);return{isOpen:!!c,onOpen:p,onClose:f,onToggle:b,isControlled:u,getButtonProps:(h={})=>({...h,"aria-expanded":c,"aria-controls":d,onClick:Yi(h.onClick,b)}),getDisclosureProps:(h={})=>({...h,hidden:!c,id:d})}}var kn=G(function(e,n){const{htmlSize:r,...o}=e,s=Ot("Input",o),a=$e(o),i=Pl(a),l=oe("chakra-input",e.className);return v.jsx(V.input,{size:r,...i,__css:s.field,ref:n,className:l})});kn.displayName="Input";kn.id="Input";var Xl=Object.freeze(["base","sm","md","lg","xl","2xl"]);function Zl(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):Gi(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function gh(t,e=Xl){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var yt=G(function(e,n){const r=yr("Text",e),{className:o,align:s,decoration:a,casing:i,...l}=$e(e),u=ul({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return v.jsx(V.p,{ref:n,className:oe("chakra-text",e.className),...u,...l,__css:r})});yt.displayName="Text";var Gr=t=>v.jsx(V.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});Gr.displayName="StackDivider";var xa=t=>v.jsx(V.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});xa.displayName="StackItem";function Ql(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{"&":Zl(n,o=>r[o])}}var on=G((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:a="0.5rem",wrap:i,children:l,divider:u,className:c,shouldWrapChildren:d,...f}=t,p=n?"row":r??"column",b=y.useMemo(()=>Ql({spacing:a,direction:p}),[a,p]),h=!!u,w=!d&&!h,g=y.useMemo(()=>{const _=Ho(l);return w?_:_.map((k,E)=>{const C=typeof k.key<"u"?k.key:E,x=E+1===_.length,D=d?v.jsx(xa,{children:k},C):k;if(!h)return D;const P=y.cloneElement(u,{__css:b}),N=x?null:P;return v.jsxs(y.Fragment,{children:[D,N]},C)})},[u,b,h,w,d,l]),m=oe("chakra-stack",c);return v.jsx(V.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:p,flexWrap:i,gap:h?void 0:a,className:m,...f,children:g})});on.displayName="Stack";var Bt=G((t,e)=>v.jsx(on,{align:"center",...t,direction:"row",ref:e}));Bt.displayName="HStack";var _a=G(function(e,n){const r=yr("Heading",e),{className:o,...s}=$e(e);return v.jsx(V.h2,{ref:n,className:oe("chakra-heading",e.className),...s,__css:r})});_a.displayName="Heading";var at=V("div");at.displayName="Box";var ka=G(function(e,n){const{size:r,centerContent:o=!0,...s}=e,a=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return v.jsx(at,{ref:n,boxSize:r,__css:{...a,flexShrink:0,flexGrow:0},...s})});ka.displayName="Square";var ec=G(function(e,n){const{size:r,...o}=e;return v.jsx(ka,{size:r,ref:n,borderRadius:"9999px",...o})});ec.displayName="Circle";var Kn=G(function(e,n){const{direction:r,align:o,justify:s,wrap:a,basis:i,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:a,flexBasis:i,flexGrow:l,flexShrink:u};return v.jsx(V.div,{ref:n,__css:d,...c})});Kn.displayName="Flex";function tc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function nc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=y.useState([]),s=y.useRef(),a=()=>{s.current&&(clearTimeout(s.current),s.current=null)},i=()=>{a(),s.current=setTimeout(()=>{o([]),s.current=null},e)};y.useEffect(()=>a,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(tc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),i()}}}return l}function rc(t,e,n,r){if(e==null)return r;if(!r)return t.find(a=>n(a).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let s;return o.includes(r)?(s=o.indexOf(r)+1,s===o.length&&(s=0),o[s]):(s=t.indexOf(o[0]),t[s])}return r}function oc(){const t=y.useRef(new Map),e=t.current,n=y.useCallback((o,s,a,i)=>{t.current.set(a,{type:s,el:o,options:i}),o.addEventListener(s,a,i)},[]),r=y.useCallback((o,s,a,i)=>{o.removeEventListener(s,a,i),t.current.delete(a)},[]);return y.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function Fr(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ca(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:a,onMouseUp:i,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:f,onMouseLeave:p,...b}=t,[h,w]=y.useState(!0),[g,m]=y.useState(!1),_=oc(),k=I=>{I&&I.tagName!=="BUTTON"&&w(!1)},E=h?d:d||0,C=n&&!r,x=y.useCallback(I=>{if(n){I.stopPropagation(),I.preventDefault();return}I.currentTarget.focus(),l==null||l(I)},[n,l]),O=y.useCallback(I=>{g&&Fr(I)&&(I.preventDefault(),I.stopPropagation(),m(!1),_.remove(document,"keyup",O,!1))},[g,_]),D=y.useCallback(I=>{if(u==null||u(I),n||I.defaultPrevented||I.metaKey||!Fr(I.nativeEvent)||h)return;const H=o&&I.key==="Enter";s&&I.key===" "&&(I.preventDefault(),m(!0)),H&&(I.preventDefault(),I.currentTarget.click()),_.add(document,"keyup",O,!1)},[n,h,u,o,s,_,O]),P=y.useCallback(I=>{if(c==null||c(I),n||I.defaultPrevented||I.metaKey||!Fr(I.nativeEvent)||h)return;s&&I.key===" "&&(I.preventDefault(),m(!1),I.currentTarget.click())},[s,h,n,c]),N=y.useCallback(I=>{I.button===0&&(m(!1),_.remove(document,"mouseup",N,!1))},[_]),K=y.useCallback(I=>{if(I.button!==0)return;if(n){I.stopPropagation(),I.preventDefault();return}h||m(!0),I.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",N,!1),a==null||a(I)},[n,h,a,_,N]),T=y.useCallback(I=>{I.button===0&&(h||m(!1),i==null||i(I))},[i,h]),L=y.useCallback(I=>{if(n){I.preventDefault();return}f==null||f(I)},[n,f]),Z=y.useCallback(I=>{g&&(I.preventDefault(),m(!1)),p==null||p(I)},[g,p]),$=xe(e,k);return h?{...b,ref:$,type:"button","aria-disabled":C?void 0:n,disabled:C,onClick:x,onMouseDown:a,onMouseUp:i,onKeyUp:c,onKeyDown:u,onMouseOver:f,onMouseLeave:p}:{...b,ref:$,role:"button","data-active":ze(g),"aria-disabled":n?"true":void 0,tabIndex:C?void 0:E,onClick:x,onMouseDown:K,onMouseUp:T,onKeyUp:P,onKeyDown:D,onMouseOver:L,onMouseLeave:Z}}function sc(t){const e=t.current;if(!e)return!1;const n=Qi(e);return!n||e.contains(n)?!1:!!el(n)}function Ea(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;gr(()=>{if(!s||sc(t))return;const a=(o==null?void 0:o.current)||t.current;let i;if(a)return i=requestAnimationFrame(()=>{a.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(i)}},[s,t,o])}var ac={preventScroll:!0,shouldFocus:!1};function ic(t,e=ac){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,a=lc(t)?t.current:t,i=o&&s,l=y.useRef(i),u=y.useRef(s);Xi(()=>{!u.current&&s&&(l.current=i),u.current=s},[s,i]);const c=y.useCallback(()=>{if(!(!s||!a||!l.current)&&(l.current=!1,!a.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=Zi(a);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,a,n]);gr(()=>{c()},[c]),Lt(a,"transitionend",c)}function lc(t){return"current"in t}var At=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),fe={arrowShadowColor:At("--popper-arrow-shadow-color"),arrowSize:At("--popper-arrow-size","8px"),arrowSizeHalf:At("--popper-arrow-size-half"),arrowBg:At("--popper-arrow-bg"),transformOrigin:At("--popper-transform-origin"),arrowOffset:At("--popper-arrow-offset")};function cc(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 uc={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"},dc=t=>uc[t],Is={scroll:!0,resize:!0};function fc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Is,...t}}:e={enabled:t,options:Is},e}var hc={name:"matchWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:({state:t})=>{t.styles.popper.width=`${t.rects.reference.width}px`},effect:({state:t})=>()=>{const e=t.elements.reference;t.elements.popper.style.width=`${e.offsetWidth}px`}},pc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Ps(t)},effect:({state:t})=>()=>{Ps(t)}},Ps=t=>{t.elements.popper.style.setProperty(fe.transformOrigin.var,dc(t.placement))},mc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{vc(t)}},vc=t=>{var e;if(!t.placement)return;const n=yc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:fe.arrowSize.varRef,height:fe.arrowSize.varRef,zIndex:-1});const r={[fe.arrowSizeHalf.var]:`calc(${fe.arrowSize.varRef} / 2 - 1px)`,[fe.arrowOffset.var]:`calc(${fe.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},yc=t=>{if(t.startsWith("top"))return{property:"bottom",value:fe.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:fe.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:fe.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:fe.arrowOffset.varRef}},gc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{js(t)},effect:({state:t})=>()=>{js(t)}},js=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=cc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:fe.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},wc={"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"}},bc={"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 xc(t,e="ltr"){var n,r;const o=((n=wc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=bc[t])!=null?r:o}var Se="top",Re="bottom",Te="right",Ie="left",Jo="auto",Cn=[Se,Re,Te,Ie],zt="start",pn="end",_c="clippingParents",Da="viewport",Qt="popper",kc="reference",Ns=Cn.reduce(function(t,e){return t.concat([e+"-"+zt,e+"-"+pn])},[]),Oa=[].concat(Cn,[Jo]).reduce(function(t,e){return t.concat([e,e+"-"+zt,e+"-"+pn])},[]),Cc="beforeRead",Ec="read",Dc="afterRead",Oc="beforeMain",Sc="main",Ic="afterMain",Pc="beforeWrite",jc="write",Nc="afterWrite",Ac=[Cc,Ec,Dc,Oc,Sc,Ic,Pc,jc,Nc];function He(t){return t?(t.nodeName||"").toLowerCase():null}function Ae(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Ct(t){var e=Ae(t).Element;return t instanceof e||t instanceof Element}function Me(t){var e=Ae(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Yo(t){if(typeof ShadowRoot>"u")return!1;var e=Ae(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Fc(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];!Me(s)||!He(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(a){var i=o[a];i===!1?s.removeAttribute(a):s.setAttribute(a,i===!0?"":i)}))})}function Mc(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]||{},a=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),i=a.reduce(function(l,u){return l[u]="",l},{});!Me(o)||!He(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Rc={name:"applyStyles",enabled:!0,phase:"write",fn:Fc,effect:Mc,requires:["computeStyles"]};function qe(t){return t.split("-")[0]}var gt=Math.max,er=Math.min,Ut=Math.round;function Xr(){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 Sa(){return!/^((?!chrome|android).)*safari/i.test(Xr())}function qt(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Me(t)&&(o=t.offsetWidth>0&&Ut(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&Ut(r.height)/t.offsetHeight||1);var a=Ct(t)?Ae(t):window,i=a.visualViewport,l=!Sa()&&n,u=(r.left+(l&&i?i.offsetLeft:0))/o,c=(r.top+(l&&i?i.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:c,right:u+d,bottom:c+f,left:u,x:u,y:c}}function Go(t){var e=qt(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 Ia(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Yo(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function tt(t){return Ae(t).getComputedStyle(t)}function Tc(t){return["table","td","th"].indexOf(He(t))>=0}function ut(t){return((Ct(t)?t.ownerDocument:t.document)||window.document).documentElement}function kr(t){return He(t)==="html"?t:t.assignedSlot||t.parentNode||(Yo(t)?t.host:null)||ut(t)}function As(t){return!Me(t)||tt(t).position==="fixed"?null:t.offsetParent}function Bc(t){var e=/firefox/i.test(Xr()),n=/Trident/i.test(Xr());if(n&&Me(t)){var r=tt(t);if(r.position==="fixed")return null}var o=kr(t);for(Yo(o)&&(o=o.host);Me(o)&&["html","body"].indexOf(He(o))<0;){var s=tt(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 En(t){for(var e=Ae(t),n=As(t);n&&Tc(n)&&tt(n).position==="static";)n=As(n);return n&&(He(n)==="html"||He(n)==="body"&&tt(n).position==="static")?e:n||Bc(t)||e}function Xo(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function sn(t,e,n){return gt(t,er(e,n))}function Lc(t,e,n){var r=sn(t,e,n);return r>n?n:r}function Pa(){return{top:0,right:0,bottom:0,left:0}}function ja(t){return Object.assign({},Pa(),t)}function Na(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Wc=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,ja(typeof e!="number"?e:Na(e,Cn))};function Kc(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,a=n.modifiersData.popperOffsets,i=qe(n.placement),l=Xo(i),u=[Ie,Te].indexOf(i)>=0,c=u?"height":"width";if(!(!s||!a)){var d=Wc(o.padding,n),f=Go(s),p=l==="y"?Se:Ie,b=l==="y"?Re:Te,h=n.rects.reference[c]+n.rects.reference[l]-a[l]-n.rects.popper[c],w=a[l]-n.rects.reference[l],g=En(s),m=g?l==="y"?g.clientHeight||0:g.clientWidth||0:0,_=h/2-w/2,k=d[p],E=m-f[c]-d[b],C=m/2-f[c]/2+_,x=sn(k,C,E),O=l;n.modifiersData[r]=(e={},e[O]=x,e.centerOffset=x-C,e)}}function $c(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)||Ia(e.elements.popper,o)&&(e.elements.arrow=o))}const zc={name:"arrow",enabled:!0,phase:"main",fn:Kc,effect:$c,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Vt(t){return t.split("-")[1]}var Uc={top:"auto",right:"auto",bottom:"auto",left:"auto"};function qc(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:Ut(n*o)/o||0,y:Ut(r*o)/o||0}}function Fs(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,a=t.offsets,i=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,f=a.x,p=f===void 0?0:f,b=a.y,h=b===void 0?0:b,w=typeof c=="function"?c({x:p,y:h}):{x:p,y:h};p=w.x,h=w.y;var g=a.hasOwnProperty("x"),m=a.hasOwnProperty("y"),_=Ie,k=Se,E=window;if(u){var C=En(n),x="clientHeight",O="clientWidth";if(C===Ae(n)&&(C=ut(n),tt(C).position!=="static"&&i==="absolute"&&(x="scrollHeight",O="scrollWidth")),C=C,o===Se||(o===Ie||o===Te)&&s===pn){k=Re;var D=d&&C===E&&E.visualViewport?E.visualViewport.height:C[x];h-=D-r.height,h*=l?1:-1}if(o===Ie||(o===Se||o===Re)&&s===pn){_=Te;var P=d&&C===E&&E.visualViewport?E.visualViewport.width:C[O];p-=P-r.width,p*=l?1:-1}}var N=Object.assign({position:i},u&&Uc),K=c===!0?qc({x:p,y:h},Ae(n)):{x:p,y:h};if(p=K.x,h=K.y,l){var T;return Object.assign({},N,(T={},T[k]=m?"0":"",T[_]=g?"0":"",T.transform=(E.devicePixelRatio||1)<=1?"translate("+p+"px, "+h+"px)":"translate3d("+p+"px, "+h+"px, 0)",T))}return Object.assign({},N,(e={},e[k]=m?h+"px":"",e[_]=g?p+"px":"",e.transform="",e))}function Vc(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,a=s===void 0?!0:s,i=n.roundOffsets,l=i===void 0?!0:i,u={placement:qe(e.placement),variation:Vt(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,Fs(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Fs(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 Hc={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Vc,data:{}};var jn={passive:!0};function Jc(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,a=r.resize,i=a===void 0?!0:a,l=Ae(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,jn)}),i&&l.addEventListener("resize",n.update,jn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,jn)}),i&&l.removeEventListener("resize",n.update,jn)}}const Yc={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Jc,data:{}};var Gc={left:"right",right:"left",bottom:"top",top:"bottom"};function $n(t){return t.replace(/left|right|bottom|top/g,function(e){return Gc[e]})}var Xc={start:"end",end:"start"};function Ms(t){return t.replace(/start|end/g,function(e){return Xc[e]})}function Zo(t){var e=Ae(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Qo(t){return qt(ut(t)).left+Zo(t).scrollLeft}function Zc(t,e){var n=Ae(t),r=ut(t),o=n.visualViewport,s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;var u=Sa();(u||!u&&e==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:i+Qo(t),y:l}}function Qc(t){var e,n=ut(t),r=Zo(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=gt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=gt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),i=-r.scrollLeft+Qo(t),l=-r.scrollTop;return tt(o||n).direction==="rtl"&&(i+=gt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:a,x:i,y:l}}function es(t){var e=tt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function Aa(t){return["html","body","#document"].indexOf(He(t))>=0?t.ownerDocument.body:Me(t)&&es(t)?t:Aa(kr(t))}function an(t,e){var n;e===void 0&&(e=[]);var r=Aa(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ae(r),a=o?[s].concat(s.visualViewport||[],es(r)?r:[]):r,i=e.concat(a);return o?i:i.concat(an(kr(a)))}function Zr(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function eu(t,e){var n=qt(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 Rs(t,e,n){return e===Da?Zr(Zc(t,n)):Ct(e)?eu(e,n):Zr(Qc(ut(t)))}function tu(t){var e=an(kr(t)),n=["absolute","fixed"].indexOf(tt(t).position)>=0,r=n&&Me(t)?En(t):t;return Ct(r)?e.filter(function(o){return Ct(o)&&Ia(o,r)&&He(o)!=="body"}):[]}function nu(t,e,n,r){var o=e==="clippingParents"?tu(t):[].concat(e),s=[].concat(o,[n]),a=s[0],i=s.reduce(function(l,u){var c=Rs(t,u,r);return l.top=gt(c.top,l.top),l.right=er(c.right,l.right),l.bottom=er(c.bottom,l.bottom),l.left=gt(c.left,l.left),l},Rs(t,a,r));return i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}function Fa(t){var e=t.reference,n=t.element,r=t.placement,o=r?qe(r):null,s=r?Vt(r):null,a=e.x+e.width/2-n.width/2,i=e.y+e.height/2-n.height/2,l;switch(o){case Se:l={x:a,y:e.y-n.height};break;case Re:l={x:a,y:e.y+e.height};break;case Te:l={x:e.x+e.width,y:i};break;case Ie:l={x:e.x-n.width,y:i};break;default:l={x:e.x,y:e.y}}var u=o?Xo(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case zt:l[u]=l[u]-(e[c]/2-n[c]/2);break;case pn: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,a=s===void 0?t.strategy:s,i=n.boundary,l=i===void 0?_c:i,u=n.rootBoundary,c=u===void 0?Da:u,d=n.elementContext,f=d===void 0?Qt:d,p=n.altBoundary,b=p===void 0?!1:p,h=n.padding,w=h===void 0?0:h,g=ja(typeof w!="number"?w:Na(w,Cn)),m=f===Qt?kc:Qt,_=t.rects.popper,k=t.elements[b?m:f],E=nu(Ct(k)?k:k.contextElement||ut(t.elements.popper),l,c,a),C=qt(t.elements.reference),x=Fa({reference:C,element:_,strategy:"absolute",placement:o}),O=Zr(Object.assign({},_,x)),D=f===Qt?O:C,P={top:E.top-D.top+g.top,bottom:D.bottom-E.bottom+g.bottom,left:E.left-D.left+g.left,right:D.right-E.right+g.right},N=t.modifiersData.offset;if(f===Qt&&N){var K=N[o];Object.keys(P).forEach(function(T){var L=[Te,Re].indexOf(T)>=0?1:-1,Z=[Se,Re].indexOf(T)>=0?"y":"x";P[T]+=K[Z]*L})}return P}function ru(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,a=n.padding,i=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?Oa:l,c=Vt(r),d=c?i?Ns:Ns.filter(function(b){return Vt(b)===c}):Cn,f=d.filter(function(b){return u.indexOf(b)>=0});f.length===0&&(f=d);var p=f.reduce(function(b,h){return b[h]=mn(t,{placement:h,boundary:o,rootBoundary:s,padding:a})[qe(h)],b},{});return Object.keys(p).sort(function(b,h){return p[b]-p[h]})}function ou(t){if(qe(t)===Jo)return[];var e=$n(t);return[Ms(t),e,Ms(e)]}function su(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,a=n.altAxis,i=a===void 0?!0:a,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,b=p===void 0?!0:p,h=n.allowedAutoPlacements,w=e.options.placement,g=qe(w),m=g===w,_=l||(m||!b?[$n(w)]:ou(w)),k=[w].concat(_).reduce(function(W,z){return W.concat(qe(z)===Jo?ru(e,{placement:z,boundary:c,rootBoundary:d,padding:u,flipVariations:b,allowedAutoPlacements:h}):z)},[]),E=e.rects.reference,C=e.rects.popper,x=new Map,O=!0,D=k[0],P=0;P=0,Z=L?"width":"height",$=mn(e,{placement:N,boundary:c,rootBoundary:d,altBoundary:f,padding:u}),I=L?T?Te:Ie:T?Re:Se;E[Z]>C[Z]&&(I=$n(I));var H=$n(I),J=[];if(s&&J.push($[K]<=0),i&&J.push($[I]<=0,$[H]<=0),J.every(function(W){return W})){D=N,O=!1;break}x.set(N,J)}if(O)for(var de=b?3:1,j=function(z){var q=k.find(function(te){var re=x.get(te);if(re)return re.slice(0,z).every(function(ie){return ie})});if(q)return D=q,"break"},R=de;R>0;R--){var F=j(R);if(F==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const au={name:"flip",enabled:!0,phase:"main",fn:su,requiresIfExists:["offset"],data:{_skip:!1}};function Ts(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 Bs(t){return[Se,Te,Re,Ie].some(function(e){return t[e]>=0})}function iu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,a=mn(e,{elementContext:"reference"}),i=mn(e,{altBoundary:!0}),l=Ts(a,r),u=Ts(i,o,s),c=Bs(l),d=Bs(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 lu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:iu};function cu(t,e,n){var r=qe(t),o=[Ie,Se].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,a=s[0],i=s[1];return a=a||0,i=(i||0)*o,[Ie,Te].indexOf(r)>=0?{x:i,y:a}:{x:a,y:i}}function uu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,a=Oa.reduce(function(c,d){return c[d]=cu(d,e.rects,s),c},{}),i=a[e.placement],l=i.x,u=i.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=a}const du={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:uu};function fu(t){var e=t.state,n=t.name;e.modifiersData[n]=Fa({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const hu={name:"popperOffsets",enabled:!0,phase:"read",fn:fu,data:{}};function pu(t){return t==="x"?"y":"x"}function mu(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,a=n.altAxis,i=a===void 0?!1:a,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,b=n.tetherOffset,h=b===void 0?0:b,w=mn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),g=qe(e.placement),m=Vt(e.placement),_=!m,k=Xo(g),E=pu(k),C=e.modifiersData.popperOffsets,x=e.rects.reference,O=e.rects.popper,D=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,P=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),N=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,K={x:0,y:0};if(C){if(s){var T,L=k==="y"?Se:Ie,Z=k==="y"?Re:Te,$=k==="y"?"height":"width",I=C[k],H=I+w[L],J=I-w[Z],de=p?-O[$]/2:0,j=m===zt?x[$]:O[$],R=m===zt?-O[$]:-x[$],F=e.elements.arrow,W=p&&F?Go(F):{width:0,height:0},z=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Pa(),q=z[L],te=z[Z],re=sn(0,x[$],W[$]),ie=_?x[$]/2-de-re-q-P.mainAxis:j-re-q-P.mainAxis,we=_?-x[$]/2+de+re+te+P.mainAxis:R+re+te+P.mainAxis,Ce=e.elements.arrow&&En(e.elements.arrow),Q=Ce?k==="y"?Ce.clientTop||0:Ce.clientLeft||0:0,pe=(T=N==null?void 0:N[k])!=null?T:0,Pt=I+ie-pe-Q,Y=I+we-pe,Oe=sn(p?er(H,Pt):H,I,p?gt(J,Y):J);C[k]=Oe,K[k]=Oe-I}if(i){var me,Be=k==="x"?Se:Ie,jt=k==="x"?Re:Te,Le=C[E],Nt=E==="y"?"height":"width",Pr=Le+w[Be],bs=Le-w[jt],jr=[Se,Ie].indexOf(g)!==-1,xs=(me=N==null?void 0:N[E])!=null?me:0,_s=jr?Pr:Le-x[Nt]-O[Nt]-xs+P.altAxis,ks=jr?Le+x[Nt]+O[Nt]-xs-P.altAxis:bs,Cs=p&&jr?Lc(_s,Le,ks):sn(p?_s:Pr,Le,p?ks:bs);C[E]=Cs,K[E]=Cs-Le}e.modifiersData[r]=K}}const vu={name:"preventOverflow",enabled:!0,phase:"main",fn:mu,requiresIfExists:["offset"]};function yu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function gu(t){return t===Ae(t)||!Me(t)?Zo(t):yu(t)}function wu(t){var e=t.getBoundingClientRect(),n=Ut(e.width)/t.offsetWidth||1,r=Ut(e.height)/t.offsetHeight||1;return n!==1||r!==1}function bu(t,e,n){n===void 0&&(n=!1);var r=Me(e),o=Me(e)&&wu(e),s=ut(e),a=qt(t,o,n),i={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((He(e)!=="body"||es(s))&&(i=gu(e)),Me(e)?(l=qt(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Qo(s))),{x:a.left+i.scrollLeft-l.x,y:a.top+i.scrollTop-l.y,width:a.width,height:a.height}}function xu(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 a=[].concat(s.requires||[],s.requiresIfExists||[]);a.forEach(function(i){if(!n.has(i)){var l=e.get(i);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function _u(t){var e=xu(t);return Ac.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function ku(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Cu(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 Ls={placement:"bottom",modifiers:[],strategy:"absolute"};function Ws(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=y.useCallback(()=>{var P;!e||!b.current||!h.current||((P=m.current)==null||P.call(m),w.current=Ou(b.current,h.current,{placement:g,modifiers:[gc,mc,pc,{...hc,enabled:!!f},{name:"eventListeners",...fc(a)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:i??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),w.current.forceUpdate(),m.current=w.current.destroy)},[g,e,n,f,a,s,i,l,u,d,c,o]);y.useEffect(()=>()=>{var P;!b.current&&!h.current&&((P=w.current)==null||P.destroy(),w.current=null)},[]);const k=y.useCallback(P=>{b.current=P,_()},[_]),E=y.useCallback((P={},N=null)=>({...P,ref:xe(k,N)}),[k]),C=y.useCallback(P=>{h.current=P,_()},[_]),x=y.useCallback((P={},N=null)=>({...P,ref:xe(C,N),style:{...P.style,position:o,minWidth:f?void 0:"max-content",inset:"0 auto auto 0"}}),[o,C,f]),O=y.useCallback((P={},N=null)=>{const{size:K,shadowColor:T,bg:L,style:Z,...$}=P;return{...$,ref:N,"data-popper-arrow":"",style:Su(P)}},[]),D=y.useCallback((P={},N=null)=>({...P,ref:N,"data-popper-arrow-inner":""}),[]);return{update(){var P;(P=w.current)==null||P.update()},forceUpdate(){var P;(P=w.current)==null||P.forceUpdate()},transformOrigin:fe.transformOrigin.varRef,referenceRef:k,popperRef:C,getPopperProps:x,getArrowProps:O,getArrowInnerProps:D,getReferenceProps:E}}function Su(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 ns(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=vt(n),a=vt(e),[i,l]=y.useState(t.defaultIsOpen||!1),u=r!==void 0?r:i,c=r!==void 0,d=y.useId(),f=o??`disclosure-${d}`,p=y.useCallback(()=>{c||l(!1),a==null||a()},[c,a]),b=y.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),h=y.useCallback(()=>{u?p():b()},[u,b,p]);function w(m={}){return{...m,"aria-expanded":u,"aria-controls":f,onClick(_){var k;(k=m.onClick)==null||k.call(m,_),h()}}}function g(m={}){return{...m,hidden:!u,id:f}}return{isOpen:u,onOpen:b,onClose:p,onToggle:h,isControlled:c,getButtonProps:w,getDisclosureProps:g}}function Iu(t){const{ref:e,handler:n,enabled:r=!0}=t,o=vt(n),a=y.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;y.useEffect(()=>{if(!r)return;const i=d=>{Mr(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Mr(d,e)&&(a.isPointerDown=!1,o(d))},u=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Mr(d,e)&&(a.isPointerDown=!1,o(d))},c=Ma(e.current);return c.addEventListener("mousedown",i,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",i,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",i,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",i,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,a,r])}function Mr(t,e){var n;const r=t.target;return r&&!Ma(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Ma(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Ra(t){const{isOpen:e,ref:n}=t,[r,o]=y.useState(e),[s,a]=y.useState(!1);return y.useEffect(()=>{s||(o(e),a(!0))},[e,s,r]),Lt(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=tl(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function rs(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[Pu,ju,Nu,Au]=da(),[Fu,Dn]=Ke({strict:!1,name:"MenuContext"});function Mu(t,...e){const n=y.useId(),r=t||n;return y.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function Ta(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Ks(t){return Ta(t).activeElement===t}function Ru(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:a,isOpen:i,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:f="unmount",direction:p,computePositionOnMount:b=!1,...h}=t,w=y.useRef(null),g=y.useRef(null),m=Nu(),_=y.useCallback(()=>{requestAnimationFrame(()=>{var F;(F=w.current)==null||F.focus({preventScroll:!1})})},[]),k=y.useCallback(()=>{const F=setTimeout(()=>{var W;if(o)(W=o.current)==null||W.focus();else{const z=m.firstEnabled();z&&T(z.index)}});H.current.add(F)},[m,o]),E=y.useCallback(()=>{const F=setTimeout(()=>{const W=m.lastEnabled();W&&T(W.index)});H.current.add(F)},[m]),C=y.useCallback(()=>{c==null||c(),s?k():_()},[s,k,_,c]),{isOpen:x,onOpen:O,onClose:D,onToggle:P}=ns({isOpen:i,defaultIsOpen:l,onClose:u,onOpen:C});Iu({enabled:x&&r,ref:w,handler:F=>{var W;(W=g.current)!=null&&W.contains(F.target)||D()}});const N=ts({...h,enabled:x||b,placement:d,direction:p}),[K,T]=y.useState(-1);gr(()=>{x||T(-1)},[x]),Ea(w,{focusRef:g,visible:x,shouldFocus:!0});const L=Ra({isOpen:x,ref:w}),[Z,$]=Mu(e,"menu-button","menu-list"),I=y.useCallback(()=>{O(),_()},[O,_]),H=y.useRef(new Set([]));y.useEffect(()=>{const F=H.current;return()=>{F.forEach(W=>clearTimeout(W)),F.clear()}},[]);const J=y.useCallback(()=>{O(),k()},[k,O]),de=y.useCallback(()=>{O(),E()},[O,E]),j=y.useCallback(()=>{var F,W;const z=Ta(w.current),q=(F=w.current)==null?void 0:F.contains(z.activeElement);if(!(x&&!q))return;const re=(W=m.item(K))==null?void 0:W.node;re==null||re.focus({preventScroll:!0})},[x,K,m]),R=y.useRef(null);return{openAndFocusMenu:I,openAndFocusFirstItem:J,openAndFocusLastItem:de,onTransitionEnd:j,unstable__animationState:L,descendants:m,popper:N,buttonId:Z,menuId:$,forceUpdate:N.forceUpdate,orientation:"vertical",isOpen:x,onToggle:P,onOpen:O,onClose:D,menuRef:w,buttonRef:g,focusedIndex:K,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:T,isLazy:a,lazyBehavior:f,initialFocusRef:o,rafId:R}}function wh(t={},e=null){const n=Dn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:a}=n,i=y.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:a}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,a]);return{...t,ref:xe(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":ze(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:le(t.onClick,r),onKeyDown:le(t.onKeyDown,i)}}function Qr(t){var e;return Lu(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Tu(t={},e=null){const n=Dn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:a,onClose:i,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,f=ju(),p=nc({preventDefault:g=>g.key!==" "&&Qr(g.target)}),b=y.useCallback(g=>{if(!g.currentTarget.contains(g.target))return;const m=g.key,k={Tab:C=>C.preventDefault(),Escape:i,ArrowDown:()=>{const C=f.nextEnabled(r);C&&o(C.index)},ArrowUp:()=>{const C=f.prevEnabled(r);C&&o(C.index)}}[m];if(k){g.preventDefault(),k(g);return}const E=p(C=>{const x=rc(f.values(),C,O=>{var D,P;return(P=(D=O==null?void 0:O.node)==null?void 0:D.textContent)!=null?P:""},f.item(r));if(x){const O=f.indexOf(x.node);o(O)}});Qr(g.target)&&E(g)},[f,r,p,i,o]),h=y.useRef(!1);a&&(h.current=!0);const w=rs({wasSelected:h.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:xe(s,e),children:w?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:le(t.onKeyDown,b)}}function Bu(t={}){const{popper:e,isOpen:n}=Dn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function Ba(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:a,isDisabled:i,isFocusable:l,closeOnSelect:u,type:c,...d}=t,f=Dn(),{setFocusedIndex:p,focusedIndex:b,closeOnSelect:h,onClose:w,menuRef:g,isOpen:m,menuId:_,rafId:k}=f,E=y.useRef(null),C=`${_}-menuitem-${y.useId()}`,{index:x,register:O}=Au({disabled:i&&!l}),D=y.useCallback(I=>{n==null||n(I),!i&&p(x)},[p,x,i,n]),P=y.useCallback(I=>{r==null||r(I),E.current&&!Ks(E.current)&&D(I)},[D,r]),N=y.useCallback(I=>{o==null||o(I),!i&&p(-1)},[p,i,o]),K=y.useCallback(I=>{s==null||s(I),Qr(I.currentTarget)&&(u??h)&&w()},[w,s,h,u]),T=y.useCallback(I=>{a==null||a(I),p(x)},[p,a,x]),L=x===b,Z=i&&!l;gr(()=>{if(m)return L&&!Z&&E.current?(k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{var I;(I=E.current)==null||I.focus({preventScroll:!0}),k.current=null})):g.current&&!Ks(g.current)&&g.current.focus({preventScroll:!0}),()=>{k.current&&cancelAnimationFrame(k.current)}},[L,Z,g,m]);const $=Ca({onClick:K,onFocus:T,onMouseEnter:D,onMouseMove:P,onMouseLeave:N,ref:xe(O,E,e),isDisabled:i,isFocusable:l});return{...d,...$,type:c??$.type,id:C,role:"menuitem",tabIndex:L?0:-1}}function bh(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...Ba(o,e),role:`menuitem${n}`,"aria-checked":r}}function xh(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...a}=t,l=n==="radio"?"":[],[u,c]=fa({defaultValue:o??l,value:r,onChange:s}),d=y.useCallback(b=>{if(n==="radio"&&typeof u=="string"&&c(b),n==="checkbox"&&Array.isArray(u)){const h=u.includes(b)?u.filter(w=>w!==b):u.concat(b);c(h)}},[u,c,n]),p=Ho(e).map(b=>{if(b.type.id!=="MenuItemOption")return b;const h=g=>{var m,_;d(b.props.value),(_=(m=b.props).onClick)==null||_.call(m,g)},w=n==="radio"?b.props.value===u:u.includes(b.props.value);return y.cloneElement(b,{type:n,onClick:h,isChecked:w})});return{...a,children:p}}function Lu(t){var e;if(!Wu(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function Wu(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Ku,Cr]=Ke({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),os=t=>{const{children:e}=t,n=Ot("Menu",t),r=$e(t),{direction:o}=To(),{descendants:s,...a}=Ru({...r,direction:o}),i=y.useMemo(()=>a,[a]),{isOpen:l,onClose:u,forceUpdate:c}=i;return v.jsx(Pu,{value:s,children:v.jsx(Fu,{value:i,children:v.jsx(Ku,{value:n,children:aa(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};os.displayName="Menu";var La=G((t,e)=>{const n=Cr();return v.jsx(V.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});La.displayName="MenuCommand";var $u=G((t,e)=>{const{type:n,...r}=t,o=Cr(),s=r.as||n?n??void 0:"button",a=y.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 v.jsx(V.button,{ref:e,type:s,...r,__css:a})}),Wa=t=>{const{className:e,children:n,...r}=t,o=Cr(),s=y.Children.only(n),a=y.isValidElement(s)?y.cloneElement(s,{focusable:"false","aria-hidden":!0,className:oe("chakra-menu__icon",s.props.className)}):null,i=oe("chakra-menu__icon-wrapper",e);return v.jsx(V.span,{className:i,...r,__css:o.icon,children:a})};Wa.displayName="MenuIcon";var ht=G((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:a,...i}=t,l=Ba(i,e),c=n||o?v.jsx("span",{style:{pointerEvents:"none",flex:1},children:a}):a;return v.jsxs($u,{...l,className:oe("chakra-menu__menuitem",l.className),children:[n&&v.jsx(Wa,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&v.jsx(La,{marginStart:s,children:o})]})});ht.displayName="MenuItem";var zu={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"}}},Uu=V(Bo.div),ss=G(function(e,n){var r,o;const{rootProps:s,motionProps:a,...i}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Dn(),d=Tu(i,n),f=Bu(s),p=Cr();return v.jsx(V.div,{...f,__css:{zIndex:(o=e.zIndex)!=null?o:(r=p.list)==null?void 0:r.zIndex},children:v.jsx(Uu,{variants:zu,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...p.list},...a,className:oe("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:ia(c.onComplete,d.onAnimationComplete)})})});ss.displayName="MenuList";var[qu,Gt]=Ke({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Vu,Er]=Ke({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function Ka(t){const e=y.Children.only(t.children),{getTriggerProps:n}=Gt();return y.cloneElement(e,n(e.props,e.ref))}Ka.displayName="PopoverTrigger";var Ft={click:"click",hover:"hover"};function Hu(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:a=!0,arrowSize:i,arrowShadowColor:l,trigger:u=Ft.click,openDelay:c=200,closeDelay:d=200,isLazy:f,lazyBehavior:p="unmount",computePositionOnMount:b,...h}=t,{isOpen:w,onClose:g,onOpen:m,onToggle:_}=ns(t),k=y.useRef(null),E=y.useRef(null),C=y.useRef(null),x=y.useRef(!1),O=y.useRef(!1);w&&(O.current=!0);const[D,P]=y.useState(!1),[N,K]=y.useState(!1),T=y.useId(),L=o??T,[Z,$,I,H]=["popover-trigger","popover-content","popover-header","popover-body"].map(Y=>`${Y}-${L}`),{referenceRef:J,getArrowProps:de,getPopperProps:j,getArrowInnerProps:R,forceUpdate:F}=ts({...h,enabled:w||!!b}),W=Ra({isOpen:w,ref:C});Bl({enabled:w,ref:E}),Ea(C,{focusRef:E,visible:w,shouldFocus:s&&u===Ft.click}),ic(C,{focusRef:r,visible:w,shouldFocus:a&&u===Ft.click});const z=rs({wasSelected:O.current,enabled:f,mode:p,isSelected:W.present}),q=y.useCallback((Y={},Oe=null)=>{const me={...Y,style:{...Y.style,transformOrigin:fe.transformOrigin.varRef,[fe.arrowSize.var]:i?`${i}px`:void 0,[fe.arrowShadowColor.var]:l},ref:xe(C,Oe),children:z?Y.children:null,id:$,tabIndex:-1,role:"dialog",onKeyDown:le(Y.onKeyDown,Be=>{n&&Be.key==="Escape"&&g()}),onBlur:le(Y.onBlur,Be=>{const jt=$s(Be),Le=Rr(C.current,jt),Nt=Rr(E.current,jt);w&&e&&(!Le&&!Nt)&&g()}),"aria-labelledby":D?I:void 0,"aria-describedby":N?H:void 0};return u===Ft.hover&&(me.role="tooltip",me.onMouseEnter=le(Y.onMouseEnter,()=>{x.current=!0}),me.onMouseLeave=le(Y.onMouseLeave,Be=>{Be.nativeEvent.relatedTarget!==null&&(x.current=!1,setTimeout(()=>g(),d))})),me},[z,$,D,I,N,H,u,n,g,w,e,d,l,i]),te=y.useCallback((Y={},Oe=null)=>j({...Y,style:{visibility:w?"visible":"hidden",...Y.style}},Oe),[w,j]),re=y.useCallback((Y,Oe=null)=>({...Y,ref:xe(Oe,k,J)}),[k,J]),ie=y.useRef(),we=y.useRef(),Ce=y.useCallback(Y=>{k.current==null&&J(Y)},[J]),Q=y.useCallback((Y={},Oe=null)=>{const me={...Y,ref:xe(E,Oe,Ce),id:Z,"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":$};return u===Ft.click&&(me.onClick=le(Y.onClick,_)),u===Ft.hover&&(me.onFocus=le(Y.onFocus,()=>{ie.current===void 0&&m()}),me.onBlur=le(Y.onBlur,Be=>{const jt=$s(Be),Le=!Rr(C.current,jt);w&&e&&Le&&g()}),me.onKeyDown=le(Y.onKeyDown,Be=>{Be.key==="Escape"&&g()}),me.onMouseEnter=le(Y.onMouseEnter,()=>{x.current=!0,ie.current=window.setTimeout(()=>m(),c)}),me.onMouseLeave=le(Y.onMouseLeave,()=>{x.current=!1,ie.current&&(clearTimeout(ie.current),ie.current=void 0),we.current=window.setTimeout(()=>{x.current===!1&&g()},d)})),me},[Z,w,$,u,Ce,_,m,e,g,c,d]);y.useEffect(()=>()=>{ie.current&&clearTimeout(ie.current),we.current&&clearTimeout(we.current)},[]);const pe=y.useCallback((Y={},Oe=null)=>({...Y,id:I,ref:xe(Oe,me=>{P(!!me)})}),[I]),Pt=y.useCallback((Y={},Oe=null)=>({...Y,id:H,ref:xe(Oe,me=>{K(!!me)})}),[H]);return{forceUpdate:F,isOpen:w,onAnimationComplete:W.onComplete,onClose:g,getAnchorProps:re,getArrowProps:de,getArrowInnerProps:R,getPopoverPositionerProps:te,getPopoverProps:q,getTriggerProps:Q,getHeaderProps:pe,getBodyProps:Pt}}function Rr(t,e){return t===e||(t==null?void 0:t.contains(e))}function $s(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function $a(t){const e=Ot("Popover",t),{children:n,...r}=$e(t),o=To(),s=Hu({...r,direction:o.direction});return v.jsx(qu,{value:s,children:v.jsx(Vu,{value:e,children:aa(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}$a.displayName="Popover";var Tr=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function za(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:a,shadowColor:i}=t,{getArrowProps:l,getArrowInnerProps:u}=Gt(),c=Er(),d=(e=n??r)!=null?e:o,f=s??a;return v.jsx(V.div,{...l(),className:"chakra-popover__arrow-positioner",children:v.jsx(V.div,{className:oe("chakra-popover__arrow",t.className),...u(t),__css:{"--popper-arrow-shadow-color":Tr("colors",i),"--popper-arrow-bg":Tr("colors",d),"--popper-arrow-shadow":Tr("shadows",f),...c.arrow}})})}za.displayName="PopoverArrow";var Ua=G(function(e,n){const{getBodyProps:r}=Gt(),o=Er();return v.jsx(V.div,{...r(e,n),className:oe("chakra-popover__body",e.className),__css:o.body})});Ua.displayName="PopoverBody";var qa=G(function(e,n){const{onClose:r}=Gt(),o=Er();return v.jsx(nl,{size:"sm",onClick:r,className:oe("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});qa.displayName="PopoverCloseButton";function Ju(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var Yu={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]}}},Gu=V(Bo.section),Va=G(function(e,n){const{variants:r=Yu,...o}=e,{isOpen:s}=Gt();return v.jsx(Gu,{ref:n,variants:Ju(r),initial:!1,animate:s?"enter":"exit",...o})});Va.displayName="PopoverTransition";var Ha=G(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:a,getPopoverPositionerProps:i,onAnimationComplete:l}=Gt(),u=Er(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return v.jsx(V.div,{...i(r),__css:u.popper,className:"chakra-popover__popper",children:v.jsx(Va,{...o,...a(s,n),onAnimationComplete:ia(l,s.onAnimationComplete),className:oe("chakra-popover__content",e.className),__css:c})})});Ha.displayName="PopoverContent";var[Xu,Zu,Qu,ed]=da();function td(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:a,lazyBehavior:i="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,f]=y.useState(n??0),[p,b]=fa({defaultValue:n??0,value:o,onChange:r});y.useEffect(()=>{o!=null&&f(o)},[o]);const h=Qu(),w=y.useId();return{id:`tabs-${(e=t.id)!=null?e:w}`,selectedIndex:p,focusedIndex:d,setSelectedIndex:b,setFocusedIndex:f,isManual:s,isLazy:a,lazyBehavior:i,orientation:l,descendants:h,direction:u,htmlProps:c}}var[nd,Dr]=Ke({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function rd(t){const{focusedIndex:e,orientation:n,direction:r}=Dr(),o=Zu(),s=y.useCallback(a=>{const i=()=>{var m;const _=o.nextEnabled(e);_&&((m=_.node)==null||m.focus())},l=()=>{var m;const _=o.prevEnabled(e);_&&((m=_.node)==null||m.focus())},u=()=>{var m;const _=o.firstEnabled();_&&((m=_.node)==null||m.focus())},c=()=>{var m;const _=o.lastEnabled();_&&((m=_.node)==null||m.focus())},d=n==="horizontal",f=n==="vertical",p=a.key,b=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",g={[b]:()=>d&&l(),[h]:()=>d&&i(),ArrowDown:()=>f&&i(),ArrowUp:()=>f&&l(),Home:u,End:c}[p];g&&(a.preventDefault(),g(a))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:le(t.onKeyDown,s)}}function od(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:a,setFocusedIndex:i,selectedIndex:l}=Dr(),{index:u,register:c}=ed({disabled:e&&!n}),d=u===l,f=()=>{o(u)},p=()=>{i(u),!s&&!(e&&n)&&o(u)},b=Ca({...r,ref:xe(c,t.ref),isDisabled:e,isFocusable:n,onClick:le(t.onClick,f)}),h="button";return{...b,id:Ja(a,u),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":Ya(a,u),onFocus:e?void 0:le(t.onFocus,p)}}var[sd,ad]=Ke({});function id(t){const e=Dr(),{id:n,selectedIndex:r}=e,s=Ho(t.children).map((a,i)=>y.createElement(sd,{key:i,value:{isSelected:i===r,id:Ya(n,i),tabId:Ja(n,i),selectedIndex:r}},a));return{...t,children:s}}function ld(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Dr(),{isSelected:s,id:a,tabId:i}=ad(),l=y.useRef(!1);s&&(l.current=!0);const u=rs({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":i,hidden:!s,id:a}}function Ja(t,e){return`${t}--tab-${e}`}function Ya(t,e){return`${t}--tabpanel-${e}`}var[cd,Or]=Ke({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Ga=G(function(e,n){const r=Ot("Tabs",e),{children:o,className:s,...a}=$e(e),{htmlProps:i,descendants:l,...u}=td(a),c=y.useMemo(()=>u,[u]),{isFitted:d,...f}=i,p={position:"relative",...r.root};return v.jsx(Xu,{value:l,children:v.jsx(nd,{value:c,children:v.jsx(cd,{value:r,children:v.jsx(V.div,{className:oe("chakra-tabs",s),ref:n,...f,__css:p,children:o})})})})});Ga.displayName="Tabs";var Xa=G(function(e,n){const r=rd({...e,ref:n}),s={display:"flex",...Or().tablist};return v.jsx(V.div,{...r,className:oe("chakra-tabs__tablist",e.className),__css:s})});Xa.displayName="TabList";var eo=G(function(e,n){const r=ld({...e,ref:n}),o=Or();return v.jsx(V.div,{outline:"0",...r,className:oe("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});eo.displayName="TabPanel";var Za=G(function(e,n){const r=id(e),o=Or();return v.jsx(V.div,{...r,width:"100%",ref:n,className:oe("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Za.displayName="TabPanels";var to=G(function(e,n){const r=Or(),o=od({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return v.jsx(V.button,{...o,className:oe("chakra-tabs__tab",e.className),__css:s})});to.displayName="Tab";var ud={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]}}}},no=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},zn=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function dd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:a=o,closeOnEsc:i=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:f,defaultIsOpen:p,arrowSize:b=10,arrowShadowColor:h,arrowPadding:w,modifiers:g,isDisabled:m,gutter:_,offset:k,direction:E,...C}=t,{isOpen:x,onOpen:O,onClose:D}=ns({isOpen:f,defaultIsOpen:p,onOpen:l,onClose:u}),{referenceRef:P,getPopperProps:N,getArrowInnerProps:K,getArrowProps:T}=ts({enabled:x,placement:c,arrowPadding:w,modifiers:g,gutter:_,offset:k,direction:E}),L=y.useId(),$=`tooltip-${d??L}`,I=y.useRef(null),H=y.useRef(),J=y.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=void 0)},[]),de=y.useRef(),j=y.useCallback(()=>{de.current&&(clearTimeout(de.current),de.current=void 0)},[]),R=y.useCallback(()=>{j(),D()},[D,j]),F=fd(I,R),W=y.useCallback(()=>{if(!m&&!H.current){x&&F();const Q=zn(I);H.current=Q.setTimeout(O,e)}},[F,m,x,O,e]),z=y.useCallback(()=>{J();const Q=zn(I);de.current=Q.setTimeout(R,n)},[n,R,J]),q=y.useCallback(()=>{x&&r&&z()},[r,z,x]),te=y.useCallback(()=>{x&&a&&z()},[a,z,x]),re=y.useCallback(Q=>{x&&Q.key==="Escape"&&z()},[x,z]);Lt(()=>no(I),"keydown",i?re:void 0),Lt(()=>{if(!s)return null;const Q=I.current;if(!Q)return null;const pe=ba(Q);return pe.localName==="body"?zn(I):pe},"scroll",()=>{x&&s&&R()},{passive:!0,capture:!0}),y.useEffect(()=>{m&&(J(),x&&D())},[m,x,D,J]),y.useEffect(()=>()=>{J(),j()},[J,j]),Lt(()=>I.current,"pointerleave",z);const ie=y.useCallback((Q={},pe=null)=>({...Q,ref:xe(I,pe,P),onPointerEnter:le(Q.onPointerEnter,Y=>{Y.pointerType!=="touch"&&W()}),onClick:le(Q.onClick,q),onPointerDown:le(Q.onPointerDown,te),onFocus:le(Q.onFocus,W),onBlur:le(Q.onBlur,z),"aria-describedby":x?$:void 0}),[W,z,te,x,$,q,P]),we=y.useCallback((Q={},pe=null)=>N({...Q,style:{...Q.style,[fe.arrowSize.var]:b?`${b}px`:void 0,[fe.arrowShadowColor.var]:h}},pe),[N,b,h]),Ce=y.useCallback((Q={},pe=null)=>{const Pt={...Q.style,position:"relative",transformOrigin:fe.transformOrigin.varRef};return{ref:pe,...C,...Q,id:$,role:"tooltip",style:Pt}},[C,$]);return{isOpen:x,show:W,hide:z,getTriggerProps:ie,getTooltipProps:Ce,getTooltipPositionerProps:we,getArrowProps:T,getArrowInnerProps:K}}var Br="chakra-ui:close-tooltip";function fd(t,e){return y.useEffect(()=>{const n=no(t);return n.addEventListener(Br,e),()=>n.removeEventListener(Br,e)},[e,t]),()=>{const n=no(t),r=zn(t);n.dispatchEvent(new r.CustomEvent(Br))}}function hd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function pd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var md=V(Bo.div),wt=G((t,e)=>{var n,r;const o=yr("Tooltip",t),s=$e(t),a=To(),{children:i,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:f,portalProps:p,background:b,backgroundColor:h,bgColor:w,motionProps:g,...m}=s,_=(r=(n=b??h)!=null?n:f)!=null?r:w;if(_){o.bg=_;const N=rl(a,"colors",_);o[fe.arrowBg.var]=N}const k=dd({...m,direction:a.direction}),E=typeof i=="string"||u;let C;if(E)C=v.jsx(V.span,{display:"inline-block",tabIndex:0,...k.getTriggerProps(),children:i});else{const N=y.Children.only(i);C=y.cloneElement(N,k.getTriggerProps(N.props,N.ref))}const x=!!c,O=k.getTooltipProps({},e),D=x?hd(O,["role","id"]):O,P=pd(O,["role","id"]);return l?v.jsxs(v.Fragment,{children:[C,v.jsx(ol,{children:k.isOpen&&v.jsx(la,{...p,children:v.jsx(V.div,{...k.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:v.jsxs(md,{variants:ud,initial:"exit",animate:"enter",exit:"exit",...g,...D,__css:o,children:[l,x&&v.jsx(V.span,{srOnly:!0,...P,children:c}),d&&v.jsx(V.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:v.jsx(V.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):v.jsx(v.Fragment,{children:i})});wt.displayName="Tooltip";let Nn;const vd=new Uint8Array(16);function yd(){if(!Nn&&(Nn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Nn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Nn(vd)}const ge=[];for(let t=0;t<256;++t)ge.push((t+256).toString(16).slice(1));function gd(t,e=0){return ge[t[e+0]]+ge[t[e+1]]+ge[t[e+2]]+ge[t[e+3]]+"-"+ge[t[e+4]]+ge[t[e+5]]+"-"+ge[t[e+6]]+ge[t[e+7]]+"-"+ge[t[e+8]]+ge[t[e+9]]+"-"+ge[t[e+10]]+ge[t[e+11]]+ge[t[e+12]]+ge[t[e+13]]+ge[t[e+14]]+ge[t[e+15]]}const wd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),zs={randomUUID:wd};function Ht(t,e,n){if(zs.randomUUID&&!e&&!t)return zs.randomUUID();t=t||{};const r=t.random||(t.rng||yd)();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 gd(r)}async function bd(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 xd(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 Qa(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 ei(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 _d(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 _h(){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 kd(t,e){try{return await(await fetch("/workspace/scan_local_new_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,existFlowIds:e})})).json()}catch(n){console.error("Error scan local new files:",n)}}async function kh(){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 Ch(){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 Cd(t){try{return await(await fetch("/workspace/delete_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_path:t})})).text()}catch(e){console.error("Error move file:",e)}}const Ed="backup",tr="workspace";let An=null;function Dd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(tr)||o.createObjectStore(tr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Od(){try{return An==null&&(An=await Dd()),new Promise((t,e)=>{if(An==null)return e("indexDB is null");const o=An.transaction([tr],"readonly").objectStore(tr).get(Ed);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 Sd(){try{return await Od()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const se=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,he=Object.keys,ke=Array.isArray;function De(t,e){return typeof e!="object"||he(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||se.Promise||(se.Promise=Promise);const vn=Object.getPrototypeOf,Id={}.hasOwnProperty;function Fe(t,e){return Id.call(t,e)}function Jt(t,e){typeof e=="function"&&(e=e(vn(t))),(typeof Reflect>"u"?he:Reflect.ownKeys)(e).forEach(n=>{Qe(t,n,e[n])})}const ti=Object.defineProperty;function Qe(t,e,n,r){ti(t,e,De(n&&Fe(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Wt(t){return{from:function(e){return t.prototype=Object.create(e.prototype),Qe(t.prototype,"constructor",t),{extend:Jt.bind(null,t.prototype)}}}}const Pd=Object.getOwnPropertyDescriptor;function as(t,e){let n;return Pd(t,e)||(n=vn(t))&&as(n,e)}const jd=[].slice;function nr(t,e,n){return jd.call(t,e,n)}function ni(t,e){return e(t)}function tn(t){if(!t)throw new Error("Assertion Failed")}function ri(t){se.setImmediate?setImmediate(t):setTimeout(t,0)}function oi(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function et(t,e){if(Fe(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=>se[t]),Ad=ii.map(t=>se[t]);oi(ii,t=>[t,!0]);let ot=null;function On(t){ot=typeof WeakMap<"u"&&new WeakMap;const e=ro(t);return ot=null,e}function ro(t){if(!t||typeof t!="object")return t;let e=ot&&ot.get(t);if(e)return e;if(ke(t)){e=[],ot&&ot.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=vn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),ot&&ot.set(t,e),t)Fe(t,o)&&(e[o]=ro(t[o]))}return e}const{toString:Fd}={};function oo(t){return Fd.call(t).slice(8,-1)}const so=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Md=typeof so=="symbol"?function(t){var e;return t!=null&&(e=t[so])&&e.apply(t)}:function(){return null},Tt={};function Xe(t){var e,n,r,o;if(arguments.length===1){if(ke(t))return t.slice();if(this===Tt&&typeof t=="string")return[t];if(o=Md(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 is=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var Je=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function li(t,e){Je=t,ci=e}var ci=()=>!0;const Rd=!new Error("").stack;function St(){if(Rd)try{throw St.arguments,new Error}catch(t){return t}return new Error}function ao(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(ci).map(r=>` +`+r).join("")):""}var ui=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ls=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ui),Td={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 Kt(t,e){this._e=St(),this.name=t,this.message=e}function di(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` +`)}function rr(t,e,n,r){this._e=St(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=di(t,e)}function ln(t,e){this._e=St(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=di(t,e)}Wt(Kt).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ao(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Wt(rr).from(Kt),Wt(ln).from(Kt);var cs=ls.reduce((t,e)=>(t[e]=e+"Error",t),{});const Bd=Kt;var B=ls.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=St(),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=Td[e]||n,this.inner=null)}return Wt(r).from(Bd),t[e]=r,t},{});B.Syntax=SyntaxError,B.Type=TypeError,B.Range=RangeError;var Us=ui.reduce((t,e)=>(t[e+"Error"]=B[e],t),{}),Un=ls.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=B[e]),t),{});function ne(){}function yn(t){return t}function Ld(t,e){return t==null||t===yn?e:function(n){return e(t(n))}}function Et(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Wd(t,e){return t===ne?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?Et(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Et(o,this.onerror):o),s!==void 0?s:n}}function Kd(t,e){return t===ne?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?Et(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Et(r,this.onerror):r)}}function $d(t,e){return t===ne?e:function(n){var r=t.apply(this,arguments);De(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Et(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Et(s,this.onerror):s),r===void 0?a===void 0?void 0:a:De(r,a)}}function zd(t,e){return t===ne?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function us(t,e){return t===ne?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)}}Un.ModifyError=rr,Un.DexieError=Kt,Un.BulkError=ln;var gn={};const fi=100,[io,or,lo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,vn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,vn(e),t]})(),hi=or&&or.then,qn=io&&io.constructor,ds=!!lo;var co=!1,Ud=lo?()=>{lo.then(Fn)}:se.setImmediate?setImmediate.bind(null,Fn):se.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Fn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Fn,0)},cn=function(t,e){nn.push([t,e]),sr&&(Ud(),sr=!1)},uo=!0,sr=!0,bt=[],Vn=[],fo=null,ho=yn,$t={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Hs,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Hs(t[0],t[1])}catch{}})}},M=$t,nn=[],xt=0,Hn=[];function A(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ne,this._lib=!1;var e=this._PSD=M;if(Je&&(this._stackHolder=St(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==gn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&mo(this,this._value))}this._state=null,this._value=null,++e.ref,mi(this,t)}const po={get:function(){var t=M,e=ar;function n(r,o){var s=!t.global&&(t!==M||e!==ar);const a=s&&!nt();var i=new A((l,u)=>{fs(this,new pi(ir(r,t,s,a),ir(o,t,s,a),l,u,t))});return Je&&gi(i,this),i}return n.prototype=gn,n},set:function(t){Qe(this,"then",t&&t.prototype===gn?po:{get:function(){return t},set:po.set})}};function pi(t,e,n,r,o){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=o}function mi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Sn();n&&typeof n.then=="function"?mi(t,(o,s)=>{n instanceof A?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,vi(t)),r&&In()}},mo.bind(null,t))}catch(n){mo(t,n)}}function mo(t,e){if(Vn.push(e),t._state===null){var n=t._lib&&Sn();e=ho(e),t._state=!1,t._value=e,Je&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(a){o&&o(a)}}(()=>{var r=as(e,"stack");e._promise=t,Qe(e,"stack",{get:()=>co?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){bt.some(o=>o._value===r._value)||bt.push(r)}(t),vi(t),n&&In()}}function vi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--xt==0&&hs()},[]))}function fs(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++xt,cn(qd,[n,t,e])}else t._listeners.push(e)}function qd(t,e,n){try{fo=e;var r,o=e._value;e._state?r=t(o):(Vn.length&&(Vn=[]),r=t(o),Vn.indexOf(o)===-1&&function(s){for(var a=bt.length;a;)if(bt[--a]._value===s._value)return void bt.splice(a,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{fo=null,--xt==0&&hs(),--n.psd.ref||n.psd.finalize()}}function yi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,a=t._value;a!=null?(o=a.name||"Error",s=a.message||a,r=ao(a,0)):(o=a,s=""),e.push(o+(s?": "+s:"")+r)}return Je&&((r=ao(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&yi(t._prev,e,n)),e}function gi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Fn(){Sn()&&In()}function Sn(){var t=uo;return uo=!1,sr=!1,t}function In(){var t,e,n;do for(;nn.length>0;)for(t=nn,nn=[],n=t.length,e=0;e0);uo=!0,sr=!0}function hs(){var t=bt;bt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=Hn.slice(0),n=e.length;n;)e[--n]()}function Mn(t){return new A(gn,!1,t)}function ae(t,e){var n=M;return function(){var r=Sn(),o=M;try{return lt(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{lt(o,!1),r&&In()}}}Jt(A.prototype,{then:po,_then:function(t,e){fs(this,new pi(null,null,t,e,M))},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):Mn(r)):this.then(null,r=>r&&r.name===e?n(r):Mn(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Mn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{co=!0;var t=yi(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{co=!1}}},timeout:function(t,e){return t<1/0?new A((n,r)=>{var o=setTimeout(()=>r(new B.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&Qe(A.prototype,Symbol.toStringTag,"Dexie.Promise"),$t.env=wi(),Jt(A,{all:function(){var t=Xe.apply(null,arguments).map(Rn);return new A(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>A.resolve(o).then(a=>{t[s]=a,--r||e(t)},n))})},resolve:t=>{if(t instanceof A)return t;if(t&&typeof t.then=="function")return new A((n,r)=>{t.then(n,r)});var e=new A(gn,!0,t);return gi(e,fo),e},reject:Mn,race:function(){var t=Xe.apply(null,arguments).map(Rn);return new A((e,n)=>{t.map(r=>A.resolve(r).then(e,n))})},PSD:{get:()=>M,set:t=>M=t},totalEchoes:{get:()=>ar},newPSD:it,usePSD:Zt,scheduler:{get:()=>cn,set:t=>{cn=t}},rejectionMapper:{get:()=>ho,set:t=>{ho=t}},follow:(t,e)=>new A((n,r)=>it((o,s)=>{var a=M;a.unhandleds=[],a.onunhandled=s,a.finalize=Et(function(){(function(i){function l(){i(),Hn.splice(Hn.indexOf(l),1)}Hn.push(l),++xt,cn(()=>{--xt==0&&hs()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},a.finalize),t()},e,n,r))}),qn&&(qn.allSettled&&Qe(A,"allSettled",function(){const t=Xe.apply(null,arguments).map(Rn);return new A(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>A.resolve(o).then(a=>r[s]={status:"fulfilled",value:a},a=>r[s]={status:"rejected",reason:a}).then(()=>--n||e(r)))})}),qn.any&&typeof AggregateError<"u"&&Qe(A,"any",function(){const t=Xe.apply(null,arguments).map(Rn);return new A((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,a)=>A.resolve(s).then(i=>e(i),i=>{o[a]=i,--r||n(new AggregateError(o))}))})}));const _e={awaits:0,echoes:0,id:0};var Vd=0,Jn=[],Lr=0,ar=0,Hd=0;function it(t,e,n,r){var o=M,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Hd;var a=$t.env;s.env=ds?{Promise:A,PromiseProp:{value:A,configurable:!0,writable:!0},all:A.all,race:A.race,allSettled:A.allSettled,any:A.any,resolve:A.resolve,reject:A.reject,nthen:qs(a.nthen,s),gthen:qs(a.gthen,s)}:{},e&&De(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var i=Zt(s,t,n,r);return s.ref===0&&s.finalize(),i}function Xt(){return _e.id||(_e.id=++Vd),++_e.awaits,_e.echoes+=fi,_e.id}function nt(){return!!_e.awaits&&(--_e.awaits==0&&(_e.id=0),_e.echoes=_e.awaits*fi,!0)}function Rn(t){return _e.echoes&&t&&t.constructor===qn?(Xt(),t.then(e=>(nt(),e),e=>(nt(),ve(e)))):t}function Jd(t){++ar,_e.echoes&&--_e.echoes!=0||(_e.echoes=_e.id=0),Jn.push(M),lt(t,!0)}function Yd(){var t=Jn[Jn.length-1];Jn.pop(),lt(t,!1)}function lt(t,e){var n=M;if((e?!_e.echoes||Lr++&&t===M:!Lr||--Lr&&t===M)||bi(e?Jd.bind(null,t):Yd),t!==M&&(M=t,n===$t&&($t.env=wi()),ds)){var r=$t.env.Promise,o=t.env;or.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(se,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function wi(){var t=se.Promise;return ds?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(se,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:or.then,gthen:t.prototype.then}:{}}function Zt(t,e,n,r,o){var s=M;try{return lt(t,!0),e(n,r,o)}finally{lt(s,!1)}}function bi(t){hi.call(io,t)}function ir(t,e,n,r){return typeof t!="function"?t:function(){var o=M;n&&Xt(),lt(e,!0);try{return t.apply(this,arguments)}finally{lt(o,!1),r&&bi(nt)}}}function qs(t,e){return function(n,r){return t.call(this,ir(n,e),ir(r,e))}}(""+hi).indexOf("[native code]")===-1&&(Xt=nt=ne);const Vs="unhandledrejection";function Hs(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(se.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Vs,!0,!0),De(r,o)):se.CustomEvent&&De(r=new CustomEvent(Vs,{detail:o}),o),r&&se.dispatchEvent&&(dispatchEvent(r),!se.PromiseRejectionEvent&&se.onunhandledrejection))try{se.onunhandledrejection(r)}catch{}Je&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var ve=A.reject;function vo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||M.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===cs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>vo(t,e,n,r))):ve(s)}return o._promise(e,(s,a)=>it(()=>(M.trans=o,r(s,a,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return ve(new B.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return ve(new B.DatabaseClosed);t.open().catch(ne)}return t._state.dbReadyPromise.then(()=>vo(t,e,n,r))}const Js="3.2.4",mt="￿",yo=-1/0,Ye="Invalid key provided. Keys must be of type string, number, Date or Array.",xi="String expected.",un=[],Sr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Gd=Sr,Xd=Sr,_i=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Ir="__dbnames",Wr="readonly",Kr="readwrite";function Dt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const ki={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Tn(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=On(e))[t],e)}class Zd{_trans(e,n,r){const o=this._tx||M.trans,s=this.name;function a(l,u,c){if(!c.schema[s])throw new B.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const i=Sn();try{return o&&o.db===this.db?o===M.trans?o._promise(e,a,r):it(()=>o._promise(e,a,r),{trans:o,transless:M.transless||M}):vo(this.db,e,[this.name],a)}finally{i&&In()}}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(ke(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=he(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!==mt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&Je&&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 a(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[i,l]=n.reduce(([u,c],d)=>{const f=o[d],p=e[d];return[u||f,u||!f?Dt(c,f&&f.multi?b=>{const h=et(b,d);return ke(h)&&h.some(w=>a(p,w))}:b=>a(p,et(b,d))):c]},[null,null]);return i?this.where(i.name).equals(e[i.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,ke(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(Fe(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){De(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=Tn(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"add",keys:n!=null?[n]:null,values:[s]})).then(a=>a.numFailures?A.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{We(e,o,a)}catch{}return a})}update(e,n){if(typeof e!="object"||ke(e))return this.where(":id").equals(e).modify(n);{const r=et(e,this.schema.primKey.keyPath);if(r===void 0)return ve(new B.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?he(n).forEach(o=>{We(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=Tn(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"put",values:[s],keys:n!=null?[n]:null})).then(a=>a.numFailures?A.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{We(e,o,a)}catch{}return a})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?A.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:ki})).then(e=>e.numFailures?A.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",a=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new B.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new B.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&i?e.map(Tn(l)):e;return this.core.mutate({trans:a,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:p,failures:b})=>{if(d===0)return s?f:p;throw new ln(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,b)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",a=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new B.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new B.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&i?e.map(Tn(l)):e;return this.core.mutate({trans:a,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:p,failures:b})=>{if(d===0)return s?f:p;throw new ln(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,b)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new ln(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function dn(t){var e={},n=function(a,i){if(i){for(var l=arguments.length,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[a].subscribe.apply(null,u),t}if(typeof a=="string")return e[a]};n.addEventType=s;for(var r=1,o=arguments.length;rDt(r(),e()):e,t.justLimit=n&&!r}function Yn(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new B.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function Ys(t,e,n){const r=Yn(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 Bn(t,e,n,r){const o=t.replayFilter?Dt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},a=(i,l,u)=>{if(!o||o(l,u,f=>l.stop(f),f=>l.fail(f))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Fe(s,d)||(s[d]=!0,e(i,l,u))}};return Promise.all([t.or._iterate(a,n),Gs(Ys(t,r,n),t.algorithm,a,!t.keysOnly&&t.valueMapper)])}return Gs(Ys(t,r,n),Dt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function Gs(t,e,n,r){var o=ae(r?(s,a,i)=>n(r(s),a,i):n);return t.then(s=>{if(s)return s.start(()=>{var a=()=>s.continue();e&&!e(s,i=>a=i,i=>{s.stop(i),a=ne},i=>{s.fail(i),a=ne})||o(s.value,s,i=>a=i),a()})})}function Ee(t,e){try{const n=Xs(t),r=Xs(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:tBn(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Mt(r,!0))return o.count({trans:n,query:{index:Yn(r,o.schema),range:r.range}}).then(a=>Math.min(a,r.limit));var s=0;return Bn(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 a(u,c){return c?a(u[r[c]],c-1):u[o]}var i=this._ctx.dir==="next"?1:-1;function l(u,c){var d=a(u,s),f=a(c,s);return df?i: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"&&Mt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=Yn(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:a})=>o?a.map(o):a)}{const o=[];return Bn(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Mt(n)?zr(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):zr(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),zr(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return $r(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 $r(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Dt(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"&&Mt(n,!0)&&n.limit>0)return this._read(o=>{var s=Yn(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 $r(this._ctx,function(o){var s=o.primaryKey.toString(),a=Fe(r,s);return r[s]=!0,!a}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=he(e),a=s.length;o=function(h){for(var w=!1,g=0;g{const{failures:g,numFailures:m}=w;f+=h-m;for(let _ of he(g))d.push(g[_])};return this.clone().primaryKeys().then(h=>{const w=g=>{const m=Math.min(c,h.length-g);return i.getMany({trans:r,keys:h.slice(g,g+m),cache:"immutable"}).then(_=>{const k=[],E=[],C=l?[]:null,x=[];for(let D=0;D0&&i.mutate({trans:r,type:"add",values:k}).then(D=>{for(let P in D.failures)x.splice(parseInt(P),1);b(k.length,D)})).then(()=>(E.length>0||O&&typeof e=="object")&&i.mutate({trans:r,type:"put",keys:C,values:E,criteria:O,changeSpec:typeof e!="function"&&e}).then(D=>b(E.length,D))).then(()=>(x.length>0||O&&e===Ur)&&i.mutate({trans:r,type:"delete",keys:x,criteria:O}).then(D=>b(x.length,D))).then(()=>h.length>g+m&&w(g+c))})};return w(0).then(()=>{if(d.length>0)throw new rr("Error modifying one or more objects",d,f,p);return h.length})})})}delete(){var e=this._ctx,n=e.range;return Mt(e)&&(e.isPrimKey&&!Xd||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(a=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:i,lastResult:l,results:u,numFailures:c})=>{if(c)throw new rr("Could not delete some values",Object.keys(i).map(d=>i[d]),a-c);return a-c}))}):this.modify(Ur)}}const Ur=(t,e)=>e.value=null;function ef(t,e){return te?-1:t===e?0:1}function je(t,e,n){var r=t instanceof Ei?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Rt(t){return new t.Collection(t,()=>Ci("")).limit(0)}function nf(t,e,n,r,o,s){for(var a=Math.min(t.length,r.length),i=-1,l=0;l=0?t.substr(0,i)+e[i]+n.substr(i+1):null;o(t[l],u)<0&&(i=l)}return atypeof h=="string"))return je(t,xi);function f(h){o=function(g){return g==="next"?m=>m.toUpperCase():m=>m.toLowerCase()}(h),s=function(g){return g==="next"?m=>m.toLowerCase():m=>m.toUpperCase()}(h),a=h==="next"?ef:tf;var w=n.map(function(g){return{lower:s(g),upper:o(g)}}).sort(function(g,m){return a(g.lower,m.lower)});i=w.map(function(g){return g.upper}),l=w.map(function(g){return g.lower}),u=h,c=h==="next"?"":r}f("next");var p=new t.Collection(t,()=>rt(i[0],l[d-1]+r));p._ondirectionchange=function(h){f(h)};var b=0;return p._addAlgorithm(function(h,w,g){var m=h.key;if(typeof m!="string")return!1;var _=s(m);if(e(_,l,b))return!0;for(var k=null,E=b;E0)&&(k=C)}return w(k!==null?function(){h.continue(k+c)}:g),!1}),p}function rt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Ci(t){return{type:1,lower:t,upper:t}}class Ei{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)?Rt(this):new this.Collection(this,()=>rt(e,n,!r,!o))}catch{return je(this,Ye)}}equals(e){return e==null?je(this,Ye):new this.Collection(this,()=>Ci(e))}above(e){return e==null?je(this,Ye):new this.Collection(this,()=>rt(e,void 0,!0))}aboveOrEqual(e){return e==null?je(this,Ye):new this.Collection(this,()=>rt(e,void 0,!1))}below(e){return e==null?je(this,Ye):new this.Collection(this,()=>rt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?je(this,Ye):new this.Collection(this,()=>rt(void 0,e))}startsWith(e){return typeof e!="string"?je(this,xi):this.between(e,e+mt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):Ln(this,(n,r)=>n.indexOf(r[0])===0,[e],mt)}equalsIgnoreCase(e){return Ln(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=Xe.apply(Tt,arguments);return e.length===0?Rt(this):Ln(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=Xe.apply(Tt,arguments);return e.length===0?Rt(this):Ln(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,mt)}anyOf(){const e=Xe.apply(Tt,arguments);let n=this._cmp;try{e.sort(n)}catch{return je(this,Ye)}if(e.length===0)return Rt(this);const r=new this.Collection(this,()=>rt(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,a,i)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return a(i),!1;return n(l,e[o])===0||(a(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[yo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=Xe.apply(Tt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return je(this,Ye)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[yo,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,a=this._min,i=this._max;if(e.length===0)return Rt(this);if(!e.every(m=>m[0]!==void 0&&m[1]!==void 0&&o(m[0],m[1])<=0))return je(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",B.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function f(m,_){return d(m[0],_[0])}try{c=e.reduce(function(m,_){let k=0,E=m.length;for(;k0){C[0]=a(C[0],_[0]),C[1]=i(C[1],_[1]);break}}return k===E&&m.push(_),m},[]),c.sort(f)}catch{return je(this,Ye)}let p=0;const b=u?m=>o(m,c[p][1])>0:m=>o(m,c[p][1])>=0,h=l?m=>s(m,c[p][0])>0:m=>s(m,c[p][0])>=0;let w=b;const g=new this.Collection(this,()=>rt(c[0][0],c[c.length-1][1],!l,!u));return g._ondirectionchange=m=>{m==="next"?(w=b,d=o):(w=h,d=s),c.sort(f)},g._addAlgorithm((m,_,k)=>{for(var E=m.key;w(E);)if(++p,p===c.length)return _(k),!1;return!!function(C){return!b(C)&&!h(C)}(E)||(this._cmp(E,c[p][1])===0||this._cmp(E,c[p][0])===0||_(()=>{d===o?m.continue(c[p][0]):m.continue(c[p][1])}),!1)}),g}startsWithAnyOf(){const e=Xe.apply(Tt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Rt(this):this.inAnyRange(e.map(n=>[n,n+mt])):je(this,"startsWithAnyOf() only works with strings")}}function Ue(t){return ae(function(e){return wn(e),t(e.target.error),!1})}function wn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const bn="storagemutated",st="x-storagemutated-1",ct=dn(null,bn);class rf{_lock(){return tn(!M.global),++this._reculock,this._reculock!==1||M.global||(M.lockOwnerFor=this),this}_unlock(){if(tn(!M.global),--this._reculock==0)for(M.global||(M.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Zt(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&M.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(tn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new B.DatabaseClosed(r);case"MissingAPIError":throw new B.MissingAPI(r.message,r);default:throw new B.OpenFailed(r)}if(!this.active)throw new B.TransactionInactive;return tn(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=ae(o=>{wn(o),this._reject(e.error)}),e.onabort=ae(o=>{wn(o),this.active&&this._reject(new B.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=ae(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&ct.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return ve(new B.ReadOnly("Transaction is readonly"));if(!this.active)return ve(new B.TransactionInactive);if(this._locked())return new A((s,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,a)},M])});if(r)return it(()=>{var s=new A((a,i)=>{this._lock();const l=n(a,i,this);l&&l.then&&l.then(a,i)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new A((s,a)=>{var i=n(s,a,this);i&&i.then&&i.then(s,a)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=A.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 a(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=a)})()}var s=n._waitingFor;return new A((a,i)=>{r.then(l=>n._waitingQueue.push(ae(a.bind(null,l))),l=>n._waitingQueue.push(ae(i.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new B.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Fe(n,e))return n[e];const r=this.schema[e];if(!r)throw new B.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 go(t,e,n,r,o,s,a){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+Di(e)}}function Di(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Oi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:oi(n,r=>[r.name,r])}}let xn=t=>{try{return t.only([[]]),xn=()=>[[]],[[]]}catch{return xn=()=>mt,mt}};function wo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>et(r,e)}(t):e=>et(e,t)}function Qs(t){return[].slice.call(t)}let of=0;function fn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function sf(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:f}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!f):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!f)}const{schema:o,hasGetAll:s}=function(l,u){const c=Qs(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:f,autoIncrement:p}=d,b=ke(f),h=f==null,w={},g={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:b,keyPath:f,autoIncrement:p,unique:!0,extractKey:wo(f)},indexes:Qs(d.indexNames).map(m=>d.index(m)).map(m=>{const{name:_,unique:k,multiEntry:E,keyPath:C}=m,x={name:_,compound:ke(C),keyPath:C,unique:k,multiEntry:E,extractKey:wo(C)};return w[fn(C)]=x,x}),getIndexByKeyPath:m=>w[fn(m)]};return w[":id"]=g.primaryKey,f!=null&&(w[fn(f)]=g.primaryKey),g})},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),a=o.tables.map(l=>function(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:f,keys:p,values:b,range:h}){return new Promise((w,g)=>{w=ae(w);const m=d.objectStore(c),_=m.keyPath==null,k=f==="put"||f==="add";if(!k&&f!=="delete"&&f!=="deleteRange")throw new Error("Invalid operation type: "+f);const{length:E}=p||b||{length:1};if(p&&b&&p.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(E===0)return w({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const x=[],O=[];let D=0;const P=K=>{++D,wn(K)};if(f==="deleteRange"){if(h.type===4)return w({numFailures:D,failures:O,results:[],lastResult:void 0});h.type===3?x.push(C=m.clear()):x.push(C=m.delete(r(h)))}else{const[K,T]=k?_?[b,p]:[b,null]:[p,null];if(k)for(let L=0;L{const T=K.target.result;x.forEach((L,Z)=>L.error!=null&&(O[Z]=L.error)),w({numFailures:D,failures:O,results:f==="delete"?p:x.map(L=>L.result),lastResult:T})};C.onerror=K=>{P(K),N(K)},C.onsuccess=N})},getMany:({trans:d,keys:f})=>new Promise((p,b)=>{p=ae(p);const h=d.objectStore(c),w=f.length,g=new Array(w);let m,_=0,k=0;const E=x=>{const O=x.target;g[O._pos]=O.result,++k===_&&p(g)},C=Ue(b);for(let x=0;xnew Promise((p,b)=>{p=ae(p);const h=d.objectStore(c).get(f);h.onsuccess=w=>p(w.target.result),h.onerror=Ue(b)}),query:function(d){return f=>new Promise((p,b)=>{p=ae(p);const{trans:h,values:w,limit:g,query:m}=f,_=g===1/0?void 0:g,{index:k,range:E}=m,C=h.objectStore(c),x=k.isPrimaryKey?C:C.index(k.name),O=r(E);if(g===0)return p({result:[]});if(d){const D=w?x.getAll(O,_):x.getAllKeys(O,_);D.onsuccess=P=>p({result:P.target.result}),D.onerror=Ue(b)}else{let D=0;const P=w||!("openKeyCursor"in x)?x.openCursor(O):x.openKeyCursor(O),N=[];P.onsuccess=K=>{const T=P.result;return T?(N.push(w?T.value:T.primaryKey),++D===g?p({result:N}):void T.continue()):p({result:N})},P.onerror=Ue(b)}})}(s),openCursor:function({trans:d,values:f,query:p,reverse:b,unique:h}){return new Promise((w,g)=>{w=ae(w);const{index:m,range:_}=p,k=d.objectStore(c),E=m.isPrimaryKey?k:k.index(m.name),C=b?h?"prevunique":"prev":h?"nextunique":"next",x=f||!("openKeyCursor"in E)?E.openCursor(r(_),C):E.openKeyCursor(r(_),C);x.onerror=Ue(g),x.onsuccess=ae(O=>{const D=x.result;if(!D)return void w(null);D.___id=++of,D.done=!1;const P=D.continue.bind(D);let N=D.continuePrimaryKey;N&&(N=N.bind(D));const K=D.advance.bind(D),T=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=ae(g),D.next=function(){let L=1;return this.start(()=>L--?this.continue():this.stop()).then(()=>this)},D.start=L=>{const Z=new Promise((I,H)=>{I=ae(I),x.onerror=Ue(H),D.fail=H,D.stop=J=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=T,I(J)}}),$=()=>{if(x.result)try{L()}catch(I){D.fail(I)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return x.onsuccess=ae(I=>{x.onsuccess=$,$()}),D.continue=P,D.continuePrimaryKey=N,D.advance=K,$(),Z},w(D)},g)})},count({query:d,trans:f}){const{index:p,range:b}=d;return new Promise((h,w)=>{const g=f.objectStore(c),m=p.isPrimaryKey?g:g.index(p.name),_=r(b),k=_?m.count(_):m.count();k.onsuccess=ae(E=>h(E.target.result)),k.onerror=Ue(w)})}}}(l)),i={};return a.forEach(l=>i[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!i[l])throw new Error(`Table '${l}' not found`);return i[l]},MIN_KEY:-1/0,MAX_KEY:xn(e),schema:o}}function bo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:a,indexedDB:i},l){return{dbcore:function(c,d){return d.reduce((f,{create:p})=>({...f,...p(f)}),c)}(sf(s,a,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(a=>a.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function lr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(a=>{const i=as(a,o);(!i||"value"in i&&i.value===void 0)&&(a===t.Transaction.prototype||a instanceof t.Transaction?Qe(a,o,{get(){return this.table(o)},set(l){ti(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):a[o]=new t.Table(o,s))})})}function xo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function af(t,e){return t._cfg.version-e._cfg.version}function lf(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const a=s._reject.bind(s),i=M.transless||M;it(()=>{M.trans=s,M.transless=i,e===0?(he(o).forEach(l=>{qr(n,l,o[l].primKey,o[l].indexes)}),bo(t,n),A.follow(()=>t.on.populate.fire(s)).catch(a)):function({_novip:l},u,c,d){const f=[],p=l._versions;let b=l._dbSchema=ko(l,l.idbdb,d),h=!1;const w=p.filter(m=>m._cfg.version>=u);function g(){return f.length?A.resolve(f.shift()(c.idbtrans)).then(g):A.resolve()}return w.forEach(m=>{f.push(()=>{const _=b,k=m._cfg.dbschema;Co(l,_,d),Co(l,k,d),b=l._dbSchema=k;const E=Si(_,k);E.add.forEach(x=>{qr(d,x[0],x[1].primKey,x[1].indexes)}),E.change.forEach(x=>{if(x.recreate)throw new B.Upgrade("Not yet support for changing primary key");{const O=d.objectStore(x.name);x.add.forEach(D=>_o(O,D)),x.change.forEach(D=>{O.deleteIndex(D.name),_o(O,D)}),x.del.forEach(D=>O.deleteIndex(D))}});const C=m._cfg.contentUpgrade;if(C&&m._cfg.version>u){bo(l,d),c._memoizedTables={},h=!0;let x=si(k);E.del.forEach(N=>{x[N]=_[N]}),xo(l,[l.Transaction.prototype]),lr(l,[l.Transaction.prototype],he(x),x),c.schema=x;const O=is(C);let D;O&&Xt();const P=A.follow(()=>{if(D=C(c),D&&O){var N=nt.bind(null,null);D.then(N,N)}});return D&&typeof D.then=="function"?A.resolve(D):P.then(()=>D)}}),f.push(_=>{(!h||!Gd)&&function(k,E){[].slice.call(E.db.objectStoreNames).forEach(C=>k[C]==null&&E.db.deleteObjectStore(C))}(m._cfg.dbschema,_),xo(l,[l.Transaction.prototype]),lr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),g().then(()=>{var m,_;_=d,he(m=b).forEach(k=>{_.db.objectStoreNames.contains(k)||qr(_,k,m[k].primKey,m[k].indexes)})})}(t,e,s,n).catch(a)})}function Si(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 a={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!Sr)a.recreate=!0,n.change.push(a);else{const i=o.idxByName,l=s.idxByName;let u;for(u in i)l[u]||a.del.push(u);for(u in l){const c=i[u],d=l[u];c?c.src!==d.src&&a.change.push(d):a.add.push(d)}(a.del.length>0||a.add.length>0||a.change.length>0)&&n.change.push(a)}}else n.add.push([r,s])}return n}function qr(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=>_o(o,s)),o}function _o(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function ko(t,e,n){const r={};return nr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let a=s.keyPath;const i=go(Di(a),a||"",!1,!1,!!s.autoIncrement,a&&typeof a!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((a,i)=>{const l=(a=a.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return go(l,u||null,/\&/.test(a),/\*/.test(a),/\+\+/.test(a),ke(u),i===0)}),s=o.shift();if(s.multi)throw new B.Schema("Primary key cannot be multi-valued");o.forEach(a=>{if(a.auto)throw new B.Schema("Only primary key can be marked as autoIncrement (++)");if(!a.keyPath)throw new B.Schema("Index must have a name and cannot be an empty string")}),n[r]=Oi(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?De(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(a=>{De(o,a._cfg.storesSource),s=a._cfg.dbschema={},a._parseStoresSpec(o,s)}),n._dbSchema=s,xo(n,[n._allTables,n,n.Transaction.prototype]),lr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],he(s),s),n._storeNames=he(s),this}upgrade(e){return this._cfg.contentUpgrade=us(this._cfg.contentUpgrade||ne,e),this}}function ps(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new _t(Ir,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function ms(t){return t&&typeof t.databases=="function"}function Eo(t){return it(function(){return M.letThrough=!0,t()})}function uf(){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 df(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?ve(e.dbOpenError):t);Je&&(e.openCanceller._stackHolder=St()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new B.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,a=null,i=!1;return A.race([r,(typeof navigator>"u"?A.resolve():uf()).then(()=>new A((l,u)=>{if(o(),!n)throw new B.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new B.MissingAPI;d.onerror=Ue(u),d.onblocked=ae(t._fireOnBlocked),d.onupgradeneeded=ae(f=>{if(a=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=wn,a.abort(),d.result.close();const b=n.deleteDatabase(c);b.onsuccess=b.onerror=ae(()=>{u(new B.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{a.onerror=Ue(u);var p=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;i=p<1,t._novip.idbdb=d.result,lf(t,p/10,a,u)}},u),d.onsuccess=ae(()=>{a=null;const f=t._novip.idbdb=d.result,p=nr(f.objectStoreNames);if(p.length>0)try{const h=f.transaction((b=p).length===1?b[0]:b,"readonly");e.autoSchema?function({_novip:w},g,m){w.verno=g.version/10;const _=w._dbSchema=ko(0,g,m);w._storeNames=nr(g.objectStoreNames,0),lr(w,[w._allTables],he(_),_)}(t,f,h):(Co(t,t._dbSchema,h),function(w,g){const m=Si(ko(0,w.idbdb,g),w._dbSchema);return!(m.add.length||m.change.some(_=>_.add.length||_.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),bo(t,h)}catch{}var b;un.push(t),f.onversionchange=ae(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),f.onclose=ae(h=>{t.on("close").fire(h)}),i&&function({indexedDB:h,IDBKeyRange:w},g){!ms(h)&&g!==Ir&&ps(h,w).put({name:g}).catch(ne)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],A.resolve(Eo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(us,ne);return e.onReadyBeingFired=[],A.resolve(Eo(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{a&&a.abort()}catch{}return r===e.openCanceller&&t._close(),ve(l)}).finally(()=>{e.openComplete=!0,s()})}function Do(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return a=>{var i=s(a),l=i.value;return i.done?l:l&&typeof l.then=="function"?l.then(n,r):ke(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function ff(t,e,n){var r=arguments.length;if(r<2)throw new B.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,ai(o),n]}function Ii(t,e,n,r,o){return A.resolve().then(()=>{const s=M.transless||M,a=t._createTransaction(e,n,t._dbSchema,r),i={trans:a,transless:s};if(r)a.idbtrans=r.idbtrans;else try{a.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===cs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ii(t,e,n,null,o))):ve(d)}const l=is(o);let u;l&&Xt();const c=A.follow(()=>{if(u=o.call(a,a),u)if(l){var d=nt.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Do(u))},i);return(u&&typeof u.then=="function"?A.resolve(u).then(d=>a.active?d:ve(new B.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&a._resolve(),a._completion.then(()=>d))).catch(d=>(a._reject(d),ve(d)))})}function Wn(t,e,n){const r=ke(t)?t.slice():[t];for(let o=0;o0,g={...f,isVirtual:w,keyTail:d,keyLength:h,extractKey:wo(c),unique:!w&&f.unique};return b.push(g),g.isPrimaryKey||s.push(g),h>1&&a(h===2?c[0]:c.slice(0,h-1),d+1,f),b.sort((m,_)=>m.keyTail-_.keyTail),g}const i=a(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[i];for(const c of r.indexes)a(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(f=c.query.range,p=d.keyTail,{type:f.type===1?2:f.type,lower:Wn(f.lower,f.lowerOpen?t.MAX_KEY:t.MIN_KEY,p),lowerOpen:!0,upper:Wn(f.upper,f.upperOpen?t.MIN_KEY:t.MAX_KEY,p),upperOpen:!0})}}:c;var f,p}return{...n,schema:{...r,primaryKey:i,indexes:s,getIndexByKeyPath:function(c){const d=o[fn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:f,keyLength:p}=c.query.index;return f?n.openCursor(l(c)).then(b=>b&&function(h){return Object.create(h,{continue:{value:function(g){g!=null?h.continue(Wn(g,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?h.continue(h.key.slice(0,p).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(g,m){h.continuePrimaryKey(Wn(g,t.MAX_KEY,d),m)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const g=h.key;return p===1?g[0]:g.slice(0,p)}},value:{get:()=>h.value}})}(b)):n.openCursor(c)}}}}}};function vs(t,e,n,r){return n=n||{},r=r||"",he(t).forEach(o=>{if(Fe(e,o)){var s=t[o],a=e[o];if(typeof s=="object"&&typeof a=="object"&&s&&a){const i=oo(s);i!==oo(a)?n[r+o]=e[o]:i==="Object"?vs(s,a,n,r+o+"."):s!==a&&(n[r+o]=e[o])}else s!==a&&(n[r+o]=e[o])}else n[r+o]=void 0}),he(e).forEach(o=>{Fe(t,o)||(n[r+o]=e[o])}),n}const pf={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 a=M.trans,{deleting:i,creating:l,updating:u}=a.table(e).hook;switch(s.type){case"add":if(l.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===ne&&u.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"delete":if(i.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"deleteRange":if(i.fire===ne)break;return a._promise("readwrite",()=>function(f){return d(f.trans,f.range,1e4)}(s),!0)}return n.mutate(s);function c(f){const p=M.trans,b=f.keys||function(h,w){return w.type==="delete"?w.keys:w.keys||w.values.map(h.extractKey)}(r,f);if(!b)throw new Error("Keys missing");return(f=f.type==="add"||f.type==="put"?{...f,keys:b}:{...f}).type!=="delete"&&(f.values=[...f.values]),f.keys&&(f.keys=[...f.keys]),function(h,w,g){return w.type==="add"?Promise.resolve([]):h.getMany({trans:w.trans,keys:g,cache:"immutable"})}(n,f,b).then(h=>{const w=b.map((g,m)=>{const _=h[m],k={onerror:null,onsuccess:null};if(f.type==="delete")i.fire.call(k,g,_,p);else if(f.type==="add"||_===void 0){const E=l.fire.call(k,g,f.values[m],p);g==null&&E!=null&&(g=E,f.keys[m]=g,r.outbound||We(f.values[m],r.keyPath,g))}else{const E=vs(_,f.values[m]),C=u.fire.call(k,E,g,_,p);if(C){const x=f.values[m];Object.keys(C).forEach(O=>{Fe(x,O)?x[O]=C[O]:We(x,O,C[O])})}}return k});return n.mutate(f).then(({failures:g,results:m,numFailures:_,lastResult:k})=>{for(let E=0;E(w.forEach(m=>m.onerror&&m.onerror(g)),Promise.reject(g)))})}function d(f,p,b){return n.query({trans:f,values:!1,query:{index:r,range:p},limit:b}).then(({result:h})=>c({type:"delete",keys:h,trans:f}).then(w=>w.numFailures>0?Promise.reject(w.failures[0]):h.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=Pi(r.keys,r.trans._cache,r.cache==="clone");return o?A.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?On(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function ys(t){return!("from"in t)}const Ge=function(t,e){if(!this){const n=new Ge;return t&&"d"in t&&De(n,t),n}De(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function _n(t,e,n){const r=Ee(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(ys(t))return De(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(Ee(n,t.from)<0)return o?_n(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},ea(t);if(Ee(e,t.to)>0)return s?_n(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},ea(t);Ee(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),Ee(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const a=!t.r;o&&!t.l&&cr(t,o),s&&a&&cr(t,s)}function cr(t,e){ys(e)||function n(r,{from:o,to:s,l:a,r:i}){_n(r,o,s),a&&n(r,a),i&&n(r,i)}(t,e)}function vf(t,e){const n=Oo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Oo(t);let a=s.next(o.from),i=a.value;for(;!r.done&&!a.done;){if(Ee(i.from,o.to)<=0&&Ee(i.to,o.from)>=0)return!0;Ee(o.from,i.from)<0?o=(r=n.next(i.from)).value:i=(a=s.next(o.from)).value}return!1}function Oo(t){let e=ys(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&&Ee(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||Ee(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function ea(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",a={...t},i=t[o];t.from=i.from,t.to=i.to,t[o]=i[o],a[o]=i[s],t[s]=a,a.d=ta(a)}t.d=ta(t)}function ta({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}Jt(Ge.prototype,{add(t){return cr(this,t),this},addKey(t){return _n(this,t,t),this},addKeys(t){return t.forEach(e=>_n(this,e,e)),this},[so](){return Oo(this)}});const yf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new Ge(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:a}=s,{extractKey:i,outbound:l}=a,u={...o,mutate:f=>{const p=f.trans,b=p.mutatedParts||(p.mutatedParts={}),h=C=>{const x=`idb://${e}/${r}/${C}`;return b[x]||(b[x]=new Ge)},w=h(""),g=h(":dels"),{type:m}=f;let[_,k]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[];const E=f.trans._cache;return o.mutate(f).then(C=>{if(ke(_)){m!=="delete"&&(_=C.results),w.addKeys(_);const x=Pi(_,E);x||m==="add"||g.addKeys(_),(x||k)&&function(O,D,P,N){function K(T){const L=O(T.name||"");function Z(I){return I!=null?T.extractKey(I):null}const $=I=>T.multiEntry&&ke(I)?I.forEach(H=>L.addKey(H)):L.addKey(I);(P||N).forEach((I,H)=>{const J=P&&Z(P[H]),de=N&&Z(N[H]);Ee(J,de)!==0&&(J!=null&&$(J),de!=null&&$(de))})}D.indexes.forEach(K)}(h,s,x,k)}else if(_){const x={from:_.lower,to:_.upper};g.add(x),w.add(x)}else w.add(n),g.add(n),s.indexes.forEach(x=>h(x.name).add(n));return C})}},c=({query:{index:f,range:p}})=>{var b,h;return[f,new Ge((b=p.lower)!==null&&b!==void 0?b:t.MIN_KEY,(h=p.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:f=>[a,new Ge(f.key)],getMany:f=>[a,new Ge().addKeys(f.keys)],count:c,query:c,openCursor:c};return he(d).forEach(f=>{u[f]=function(p){const{subscr:b}=M;if(b){const h=k=>{const E=`idb://${e}/${r}/${k}`;return b[E]||(b[E]=new Ge)},w=h(""),g=h(":dels"),[m,_]=d[f](p);if(h(m.name||"").add(_),!m.isPrimaryKey){if(f!=="count"){const k=f==="query"&&l&&p.values&&o.query({...p,values:!1});return o[f].apply(this,arguments).then(E=>{if(f==="query"){if(l&&p.values)return k.then(({result:x})=>(w.addKeys(x),E));const C=p.values?E.result.map(i):E.result;p.values?w.addKeys(C):g.addKeys(C)}else if(f==="openCursor"){const C=E,x=p.values;return C&&Object.create(C,{key:{get:()=>(g.addKey(C.primaryKey),C.key)},primaryKey:{get(){const O=C.primaryKey;return g.addKey(O),O}},value:{get:()=>(x&&w.addKey(C.primaryKey),C.value)}})}return E})}g.add(n)}}return o[f].apply(this,arguments)}}),u}}}};class _t{constructor(e,n){this._middlewares={},this.verno=0;const r=_t.dependencies;this._options=n={addons:_t.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:ne,dbReadyPromise:null,cancelOpen:ne,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var a;s.dbReadyPromise=new A(i=>{s.dbReadyResolve=i}),s.openCanceller=new A((i,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=dn(this,"populate","blocked","versionchange","close",{ready:[us,ne]}),this.on.ready.subscribe=ni(this.on.ready.subscribe,i=>(l,u)=>{_t.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||A.resolve().then(l),u&&i(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&i(l);else{i(l);const d=this;u||i(function f(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(f)})}})}),this.Collection=(a=this,en(Qd.prototype,function(i,l){this.db=a;let u=ki,c=null;if(l)try{u=l()}catch(b){c=b}const d=i._ctx,f=d.table,p=f.hook.reading.fire;this._ctx={table:f,index:d.index,isPrimKey:!d.index||f.schema.primKey.keyPath&&d.index===f.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:p!==yn?p:null}})),this.Table=function(i){return en(Zd.prototype,function(l,u,c){this.db=i,this._tx=c,this.name=l,this.schema=u,this.hook=i._allTables[l]?i._allTables[l].hook:dn(null,{creating:[Wd,ne],reading:[Ld,yn],updating:[$d,ne],deleting:[Kd,ne]})})}(this),this.Transaction=function(i){return en(rf.prototype,function(l,u,c,d,f){this.db=i,this.mode=l,this.storeNames=u,this.schema=c,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=dn(this,"complete","error","abort"),this.parent=f||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 A((p,b)=>{this._resolve=p,this._reject=b}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var b=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):b&&this.idbtrans&&this.idbtrans.abort(),ve(p)})})}(this),this.Version=function(i){return en(cf.prototype,function(l){this.db=i,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(i){return en(Ei.prototype,function(l,u,c){this.db=i,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=i._deps.indexedDB;if(!d)throw new B.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(f,p)=>d.cmp(p,f),this._max=(f,p)=>d.cmp(f,p)>0?f:p,this._min=(f,p)=>d.cmp(f,p)<0?f:p,this._IDBKeyRange=i._deps.IDBKeyRange})}(this),this.on("versionchange",i=>{i.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",i=>{!i.newVersion||i.newVersionnew this.Transaction(i,l,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=i=>{this.on("blocked").fire(i),un.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(i))},this.use(hf),this.use(pf),this.use(yf),this.use(mf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(i=>i(this))}version(e){if(isNaN(e)||e<.1)throw new B.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new B.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(af),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||M.letThrough||this._vip)?e():new A((n,r)=>{if(this._state.openComplete)return r(new B.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new B.DatabaseClosed);this.open().catch(ne)}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((a,i)=>a.level-i.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 df(this)}_close(){const e=this._state,n=un.indexOf(this);if(n>=0&&un.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new A(r=>{e.dbReadyResolve=r}),e.openCanceller=new A((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new B.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new A((r,o)=>{const s=()=>{this.close();var a=this._deps.indexedDB.deleteDatabase(this.name);a.onsuccess=ae(()=>{(function({indexedDB:i,IDBKeyRange:l},u){!ms(i)&&u!==Ir&&ps(i,l).delete(u).catch(ne)})(this._deps,this.name),r()}),a.onerror=Ue(o),a.onblocked=this._fireOnBlocked};if(e)throw new B.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 he(this._allTables).map(e=>this._allTables[e])}transaction(){const e=ff.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=M.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let a,i;e=e.replace("!","").replace("?","");try{if(i=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===Wr)a=Wr;else{if(e!="rw"&&e!=Kr)throw new B.InvalidArgument("Invalid transaction mode: "+e);a=Kr}if(o){if(o.mode===Wr&&a===Kr){if(!s)throw new B.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new B.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)}):ve(u)}const l=Ii.bind(null,this,a,i,o,r);return o?o._promise(a,l,"lock"):M.trans?Zt(M.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Fe(this._allTables,e))throw new B.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const gf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class wf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[gf](){return this}}function ji(t,e){return he(e).forEach(n=>{cr(t[n]||(t[n]=new Ge),e[n])}),t}function bf(t){let e,n=!1;const r=new wf(o=>{const s=is(t);let a=!1,i={},l={};const u={get closed(){return a},unsubscribe:()=>{a=!0,ct.storagemutated.unsubscribe(p)}};o.start&&o.start(u);let c=!1,d=!1;function f(){return he(l).some(h=>i[h]&&vf(i[h],l[h]))}const p=h=>{ji(i,h),f()&&b()},b=()=>{if(c||a)return;i={};const h={},w=function(g){s&&Xt();const m=()=>it(t,{subscr:g,trans:null}),_=M.trans?Zt(M.transless,m):m();return s&&_.then(nt,nt),_}(h);d||(ct(bn,p),d=!0),c=!0,Promise.resolve(w).then(g=>{n=!0,e=g,c=!1,a||(f()?b():(i={},l=h,o.next&&o.next(g)))},g=>{c=!1,n=!1,o.error&&o.error(g),u.unsubscribe()})};return b(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let So;try{So={indexedDB:se.indexedDB||se.mozIndexedDB||se.webkitIndexedDB||se.msIndexedDB,IDBKeyRange:se.IDBKeyRange||se.webkitIDBKeyRange}}catch{So={indexedDB:null,IDBKeyRange:null}}const ft=_t;function Gn(t){let e=Ze;try{Ze=!0,ct.storagemutated.fire(t)}finally{Ze=e}}Jt(ft,{...Un,delete:t=>new ft(t,{addons:[]}).delete(),exists:t=>new ft(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return ms(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==Ir)):ps(e,n).toCollection().primaryKeys()}(ft.dependencies).then(t)}catch{return ve(new B.MissingAPI)}},defineClass:()=>function(t){De(this,t)},ignoreTransaction:t=>M.trans?Zt(M.transless,t):t(),vip:Eo,async:function(t){return function(){try{var e=Do(t.apply(this,arguments));return e&&typeof e.then=="function"?e:A.resolve(e)}catch(n){return ve(n)}}},spawn:function(t,e,n){try{var r=Do(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:A.resolve(r)}catch(o){return ve(o)}},currentTransaction:{get:()=>M.trans||null},waitFor:function(t,e){const n=A.resolve(typeof t=="function"?ft.ignoreTransaction(t):t).timeout(e||6e4);return M.trans?M.trans.waitFor(n):n},Promise:A,debug:{get:()=>Je,set:t=>{li(t,t==="dexie"?()=>!0:_i)}},derive:Wt,extend:De,props:Jt,override:ni,Events:dn,on:ct,liveQuery:bf,extendObservabilitySet:ji,getByKeyPath:et,setByKeyPath:We,delByKeyPath:function(t,e){typeof e=="string"?We(t,e,void 0):"length"in e&&[].map.call(e,function(n){We(t,n,void 0)})},shallowClone:si,deepClone:On,getObjectDiff:vs,cmp:Ee,asap:ri,minKey:yo,addons:[],connections:un,errnames:cs,dependencies:So,semVer:Js,version:Js.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),ft.maxKey=xn(ft.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ct(bn,t=>{if(!Ze){let e;Sr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(st,!0,!0,t)):e=new CustomEvent(st,{detail:t}),Ze=!0,dispatchEvent(e),Ze=!1}}),addEventListener(st,({detail:t})=>{Ze||Gn(t)}));let Ze=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(st);typeof t.unref=="function"&&t.unref(),ct(bn,e=>{Ze||t.postMessage(e)}),t.onmessage=e=>{e.data&&Gn(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ct(bn,e=>{try{Ze||(typeof localStorage<"u"&&localStorage.setItem(st,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:st,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===st){const n=JSON.parse(e.newValue);n&&Gn(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===st&&Gn(e.changedParts)})}A.rejectionMapper=function(t,e){if(!t||t instanceof Kt||t instanceof TypeError||t instanceof SyntaxError||!t.name||!Us[t.name])return t;var n=new Us[t.name](e||t.message,t);return"stack"in t&&Qe(n,"stack",{get:function(){return this.inner.stack}}),n},li(Je,_i);var Xn=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(Xn||{});const xf="comfyui_workspace_db";class _f extends _t{constructor(){super(xf);ce(this,"workflows");ce(this,"changelogs");ce(this,"media");ce(this,"folders");ce(this,"tags");ce(this,"userSettings");ce(this,"models");ce(this,"cache");ce(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",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID"}).upgrade(n=>{})}}const X=new _f;class It{constructor(e){ce(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await X[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")}),xd(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=Ht()),e.createTime||(e.createTime=Date.now()),await X[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await X[this.tableName].put(e),await this.saveDiskDB(),e}async update(e,n){return await X[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await X[this.tableName].toArray()}async batchQuery(e){return await X[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 bd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Sd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await X[this.tableName].get(e)}async delete(e){await X[this.tableName].delete(e),await this.saveDiskDB()}}const dr=class dr extends It{constructor(){super("changelogs")}static async load(){return new dr}async listByWorkflowID(e){return await X.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:Ht(),json:e.json,workflowID:e.workflowID,createTime:Date.now()};return await X.changelogs.add(r),await this.saveDiskDB(),r}};ce(dr,"TABLE_NAME","changelogs");let Io=dr;const Eh="CWM_WORKFLOWS_SORT_TYPE";var pt=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(pt||{});const Dh=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],Ni="comfyspace_tracking",Ai="workspace_info",kf=9999999;async function rn(t){const e=await gs(t);if(e==null)return;const n=await ws(t);await(S==null?void 0:S.updateFlow(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Ai]={id:t.id,name:t.name},delete o.extra[Ni],await Qa(e,JSON.stringify(o))}async function Vr(t){if(t.name==null)return;const e=await gs(t);e!=null&&ei(e)}async function gs(t){let e=Ef(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(ee==null?void 0:ee.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function ws(t){const e=await gs(t);let n=await(U==null?void 0:U.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function Cf(t){const e=await(ee==null?void 0:ee.get(t));let n=e==null?void 0:e.parentFolderID,r=e==null?void 0:e.name;for(;n;){const s=await(ee==null?void 0:ee.get(n));if(s==null)break;r=`${s.name}/${r}`,n=s.parentFolderID??void 0}let o=await(U==null?void 0:U.getSetting("myWorkflowsDir"));return o?(o.endsWith("/")||(o=o+"/"),o+r):(console.error("myWorkflowsDir is not set"),null)}async function Oh(t){const e=await(S==null?void 0:S.listAll())??[],n=await(ee==null?void 0:ee.listAll())??[],r=[t];let o=0;for(;r.length>0;){const s=r.shift();if(s){for(const i of e)i.parentFolderID===s&&o++;const a=n.filter(i=>i.parentFolderID===s).map(i=>i.id);a.length&&r.push(...a)}}return o}function Ef(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function na(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"),a=r.getFullYear(),i=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),u=String(r.getSeconds()).padStart(2,"0"),c=`${s}-${o}-${a}`;return e?c+` ${i}:${l}`:n?c+`:${u}`:c}async function Fi(t=!1){const e=await(S==null?void 0:S.listAll())??[];for(const n of e){const r=await ws(n);n.filePath!=r&&(n.filePath!=null&&await ei(n.filePath,t),await rn(n))}}const Df=(t,e=pt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case pt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case pt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case pt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case pt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n},Of=async t=>{const e=await(U==null?void 0:U.getSetting("shortcuts").then(n=>n==null?void 0:n.save));return e?Sf(t,e):!1},Sf=(t,e)=>{const n=e.split("+"),r={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};return n.every(o=>r[o])};function Sh(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function If(t){return`/workspace/view_media?filename=${t}`}async function Mi(t,e){const n=t.filter(o=>"json"in o);n.length&&await(S==null?void 0:S.batchCreateFlows(n,!0,e));const r=t.filter(o=>"list"in o);if(r.length){const o=await(ee==null?void 0:ee.listAll());for(const s of r){const a=o==null?void 0:o.find(l=>l.name===s.name);let i;if(a)i=a.id;else{const l=await(ee==null?void 0:ee.create({name:s.name,parentFolderID:e}));i=l==null?void 0:l.id}await Mi(s.list,i)}}}function ra(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function Ri(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 Pf=t=>{const e=Ri(t);window.open(`${window.location.origin}/#${e}`)};async function jf(){const t=await(S==null?void 0:S.listAll())??[];for(const e of t)try{const n=await ws(e),r=JSON.parse(e.json);r.extra[Ai]={id:e.id,name:e.name},delete r.extra[Ni],n&&await Qa(n,JSON.stringify(r))}catch(n){console.error(n)}}const Po={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},fr=class fr extends It{constructor(){super("workflows");ce(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new fr}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}async latestVersionCheck(){if(this._curWorkflow){const n=await this.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async generateUniqueName(n,r){let o=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(i=>i.parentFolderID==r).map(i=>i.name);if(a.includes(o)){let i=2,l=!0;for(;l;)a.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,l=!1)}return o}async createFlow(n){const{id:r,json:o,name:s}=n,a=await this.generateUniqueName(s,n.parentFolderID),i=r??Ht(),l=Date.now(),u={...n,id:i,json:o??JSON.stringify(Po),name:a,updateTime:l,createTime:l};return await X.workflows.add(u),this.saveDiskDB(),rn(u),u}async updateFlow(n,r){const o=await this.get(n);if(o==null)return;const s={...o,...r,id:n},a=JSON.stringify(o),i=JSON.stringify(s);if(a===i)return;const l=s,u=Object.keys(r);if(u.length===1&&["tags","parentFolderID"].includes(u[0])||(l.updateTime=Date.now(),l.parentFolderID!=null&&await(ee==null?void 0:ee.update({id:l.parentFolderID,updateTime:Date.now()}))),await X.workflows.update(n,l),this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=l),await this.saveDiskDB(),"name"in r||"parentFolderID"in r){await Vr(o),await rn(s);return}r.json!=null&&await rn(s)}async batchCreateFlows(n=[],r=!1,o){const s=[];for(const a of n){const i=a.name&&r?a.name:await this.generateUniqueName(a.name,o),l=Ht(),u=Date.now(),c={id:l,name:i,json:a.json,parentFolderID:o,updateTime:u,createTime:u,tags:[]};s.push(c),await rn(c)}await X.workflows.bulkAdd(s),this.saveDiskDB()}async deleteFlow(n){const r=await this.get(n);r&&Vr({...r}),await X.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await X.workflows.bulkGet(n);for(const o of r)o&&await Vr(o);await X.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){const o=await this.listAll().then(i=>i.filter(l=>l.parentFolderID==n))??[],s=await(ee==null?void 0:ee.listAll().then(i=>i.filter(l=>l.parentFolderID==n)))??[],a=[...o,...s];return Df(a,r??pt.RECENTLY_MODIFIED)}};ce(fr,"TABLE_NAME","workflows");let jo=fr;const hr=class hr extends It{constructor(){super("folders")}static async load(){return new hr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r={id:Ht(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return await X.folders.add(r),this.saveDiskDB(),r}async update(e){const n=await this.get(e.id);if(n==null)return;const r="name"in e&&e.name!=n.name,o="parentFolderID"in e&&e.parentFolderID!=n.parentFolderID,s={...n,...e};e.name!=null&&(s.updateTime=Date.now()),o&&(e.name=await this.generateUniqueName(s.name,s.parentFolderID??void 0)),await X.folders.update(e.id,e),this.saveDiskDB(),(r||o)&&Fi(!0)}async deleteFolder(e,n=Xn.DELETE){const r=await Cf(e),o=await(S==null?void 0:S.listAll())??[],s=await this.listAll(),a=[e];for(;a.length>0;){const i=a.shift();if(i){for(const u of o)if(u.parentFolderID===i)switch(n){case Xn.DELETE:await(S==null?void 0:S.deleteFlow(u.id));break;case Xn.MOVE_TO_ROOT_FOLDER:await(S==null?void 0:S.updateFlow(u.id,{parentFolderID:void 0}));break}await X.folders.delete(i);const l=s.filter(u=>u.parentFolderID===i).map(u=>u.id);l.length&&a.push(...l)}}r&&await Cd(r),this.saveDiskDB()}async generateUniqueName(e,n){let r=e??"New folder";const o=await this.listAll().then(s=>s.filter(a=>a.parentFolderID==n).map(a=>a.name));if(o.includes(r)){let s=2,a=!0;for(;a;)o.includes(`${r} ${s}`)?s++:(r=`${r} ${s}`,a=!1)}return r}};ce(hr,"TABLE_NAME","folders");let No=hr;class Ti extends It{constructor(){super("media")}async listByWorkflowID(e){return await X.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r={id:Ht(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),format:n},o=await(S==null?void 0:S.get(e.workflowID)),s=new Set((o==null?void 0:o.mediaIDs)??[]).add(r.id);return await(S==null?void 0:S.updateFlow(e.workflowID,{mediaIDs:Array.from(s),coverMediaPath:r.localPath})),X.media.add(r),this.saveDiskDB(),r}}ce(Ti,"TABLE_NAME","media");const pr=class pr extends It{constructor(){super("userSettings");ce(this,"defaultSettings");ce(this,"DEFAULT_USER","guest");ce(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S"},autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.comfyspace.art",overwriteCurWorkflowWhenDroppingFileToCanvas:!1}}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new pr,r=await _d();return n.defaultSettings.myWorkflowsDir=`${r.dir_path}/my_workflows`,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};ce(pr,"TABLE_NAME","userSettings");let Ao=pr;const mr=class mr extends It{constructor(){super("tags")}static async load(){return new mr}};ce(mr,"TABLE_NAME","tags");let Fo=mr;const vr=class vr extends It{constructor(){super("workflowVersions")}static async load(){return new vr}async listByWorkflowID(e){return await X[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}};ce(vr,"TABLE_NAME","workflowVersions");let Mo=vr;function Ih(t){return"type"in t&&t.type==="folder"}let S=null,Zn=null,U=null,ee=null,Ve=null,kt=null,be=null;async function Nf(){const t=async()=>{S=await jo.load()},e=async()=>{Zn=await Fo.load()},n=async()=>{U=await Ao.load()},r=async()=>{ee=await No.load()},o=async()=>{Ve=await Io.load()},s=async()=>{kt=new Ti},a=async()=>{be=await Mo.load()};await Promise.all([t(),e(),n(),r(),o(),s(),a()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Af(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Af(){const t=async()=>{try{const i=await(S==null?void 0:S.getRecords());i&&await X.workflows.bulkAdd(Object.values(i))}catch(i){console.error(i)}},e=async()=>{try{const i=await(ee==null?void 0:ee.getRecords());i&&await X.folders.bulkAdd(Object.values(i))}catch(i){console.error(i)}},n=async()=>{try{const i=await(kt==null?void 0:kt.getRecords());i&&await X.media.bulkAdd(Object.values(i))}catch(i){console.error(i)}},r=async()=>{try{const i=await(Ve==null?void 0:Ve.getRecords());i&&await X.changelogs.bulkAdd(Object.values(i))}catch(i){console.error(i)}},o=async()=>{try{const i=await(Zn==null?void 0:Zn.getRecords());i&&await X.tags.bulkAdd(Object.values(i))}catch(i){console.error(i)}},s=async()=>{try{const i=U,l=await i.getRecords().then(u=>u[i.DEFAULT_USER]?u[i.DEFAULT_USER]:u);await X.userSettings.put({...i.defaultSettings,...l})}catch(i){console.error(i)}},a=async()=>{try{const i=await(be==null?void 0:be.getRecords());i&&await X.workflowVersions.bulkAdd(Object.values(i))}catch(i){console.error(i)}};await Promise.all([t(),e(),n(),r(),o(),s(),a()])}const Pn=y.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{}}),Ph=y.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),Hr={x:0,y:0};function Ff({children:t,onDragEnd:e,dragIconId:n}){const r=y.useRef(Hr),o=y.useRef(!1),[s,a]=y.useState(Hr),i=d=>{var f,p,b;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(f=d.target)==null?void 0:f.id,(b=(p=d.target)==null?void 0:p.parentNode)==null?void 0:b.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=y.useCallback(d=>{const f={x:d.clientX-r.current.x,y:d.clientY-r.current.y};a(f)},[]),u=y.useCallback(()=>{a(f=>(e(f),Hr)),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 v.jsx("div",{style:c,onMouseDown:i,children:t})}var Mf={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"},Rf=Object.defineProperty,Tf=Object.defineProperties,Bf=Object.getOwnPropertyDescriptors,ur=Object.getOwnPropertySymbols,Bi=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable,oa=(t,e,n)=>e in t?Rf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,sa=(t,e)=>{for(var n in e||(e={}))Bi.call(e,n)&&oa(t,n,e[n]);if(ur)for(var n of ur(e))Li.call(e,n)&&oa(t,n,e[n]);return t},Lf=(t,e)=>Tf(t,Bf(e)),Wf=(t,e)=>{var n={};for(var r in t)Bi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&ur)for(var r of ur(t))e.indexOf(r)<0&&Li.call(t,r)&&(n[r]=t[r]);return n},Pe=(t,e,n)=>{const r=y.forwardRef((o,s)=>{var a=o,{color:i="currentColor",size:l=24,stroke:u=2,children:c}=a,d=Wf(a,["color","size","stroke","children"]);return y.createElement("svg",sa(Lf(sa({ref:s},Mf),{width:l,height:l,stroke:i,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([f,p])=>y.createElement(f,p)),...c||[]])});return r.propTypes={color:dt.string,size:dt.oneOfType([dt.string,dt.number]),stroke:dt.oneOfType([dt.string,dt.number])},r.displayName=`${e}`,r},Kf=Pe("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"}]]),$f=Pe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),Ro=Pe("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"}]]),zf=Pe("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"}]]),Uf=Pe("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"}]]),qf=Pe("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"}]]),Vf=Pe("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"}]]),Hf=Pe("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"}]]),Jf=Pe("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"}]]),Yf=Pe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Gf=Pe("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"}]]),Xf=Pe("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"}]]),Zf=Pe("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"}]]),Qf=Pe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function eh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return v.jsx($a,{isLazy:!0,placement:"auto",children:({onClose:a})=>v.jsxs(v.Fragment,{children:[v.jsx(Ka,{children:v.jsx(at,{children:v.jsx(wt,{hasArrow:!0,label:s,placement:"bottom",children:v.jsx(hn,{"aria-label":"Delete confirm",size:"sm",icon:v.jsx(Gf,{color:"#F56565"}),isDisabled:o,variant:n})})})}),v.jsxs(Ha,{children:[v.jsx(za,{}),v.jsx(qa,{onClick:a}),v.jsxs(Ua,{children:[v.jsx(yt,{mb:4,pr:4,fontWeight:600,children:e}),v.jsx(Ne,{colorScheme:"red",size:"sm",onClick:()=>{r(),a()},children:"Yes, delete"})]})]})]})})}function th({onClose:t}){const e=dl(),{curFlowID:n,isDirty:r}=y.useContext(Pn),[o,s]=y.useState(0),[a,i]=y.useState(null),[l,u]=y.useState([]),[c,d]=y.useState([]),f=async h=>{var k;const w=await(S==null?void 0:S.get(h)),g=await(Ve==null?void 0:Ve.listByWorkflowID(h));u(g??[]);const m=g==null?void 0:g.filter(E=>E.json===(w==null?void 0:w.lastSavedJson)),_=(k=m==null?void 0:m[0])==null?void 0:k.id;_&&i(_)},p=async()=>{var _;const h=await(be==null?void 0:be.listByWorkflowID(n))??[];d(h);const w=JSON.stringify(ye.graph.serialize()),g=h==null?void 0:h.filter(k=>k.json===w),m=(_=g==null?void 0:g[0])==null?void 0:_.id;m&&i(m)},b=h=>{be==null||be.delete(h).then(()=>{p()})};return y.useEffect(()=>{switch(o){case 0:p();break;case 1:f(n);break}},[o]),y.useEffect(()=>(ye.canvasEl.addEventListener("click",t),()=>{ye.canvasEl.removeEventListener("click",t)}),[o]),v.jsxs(_l,{width:400,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[v.jsx(xl,{pb:1,mb:0,children:v.jsxs(Kn,{justifyContent:"space-between",alignItems:"center",children:[v.jsx(_a,{size:"md",children:"Version History"}),v.jsx(hn,{size:"sm",icon:v.jsx(Qf,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),v.jsx(bl,{overflowY:"auto",gap:0,children:v.jsxs(Ga,{isFitted:!0,variant:"enclosed",onChange:s,children:[v.jsxs(Xa,{mb:"1em",children:[v.jsx(to,{children:"Versions"}),v.jsx(to,{children:"Change History"})]}),v.jsxs(Za,{children:[v.jsx(eo,{children:v.jsx(on,{divider:v.jsx(Gr,{}),spacing:2,children:c==null?void 0:c.map(h=>v.jsxs(Kn,{w:"100%",mb:1,justify:"space-between",backgroundColor:h.id===a?"teal.300":void 0,borderRadius:4,children:[v.jsxs(on,{textAlign:"left",gap:0,children:[v.jsx(yt,{fontWeight:"500",children:h.name??"untitled"}),v.jsxs(yt,{color:"GrayText",fontSize:"sm",children:["Created: ",na(h.createTime)]})]}),v.jsxs(Kn,{alignItems:"center",gap:2,children:[v.jsx(Ne,{size:"sm",onClick:()=>{if(r){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}ye.loadGraphData(JSON.parse(h.json)),S==null||S.updateFlow(n,{lastSavedJson:h.json,json:h.json}),e({title:`Switched to version "${h.name}"`,status:"success",duration:3e3,isClosable:!0}),t()},children:"Load"}),v.jsx(eh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{b(h.id)}})]})]},h.id))})}),v.jsxs(eo,{children:[v.jsx(yt,{mb:4,children:"All the saved changes of this workflow"}),v.jsx(on,{divider:v.jsx(Gr,{}),spacing:2,children:l==null?void 0:l.map(h=>v.jsxs(Ne,{size:"sm",variant:"ghost",onClick:()=>{if(r){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}ye.loadGraphData(JSON.parse(h.json)),S==null||S.updateFlow(n,{lastSavedJson:h.json}),t()},isActive:h.id===a,children:["Saved at ",na(h.createTime,!0)]},h.id))})]})]})]})})]})}function nh({workflowId:t,onClose:e}){const[n,r]=y.useState(""),[o,s]=y.useState(""),a=l=>{r(l.target.value),o&&s("")},i=async()=>{const l=n.trim();if(r(l),(await(be==null?void 0:be.listByWorkflowID(t))??[]).some(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(ye.graph.serialize());await(be==null?void 0:be.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return v.jsxs(Lo,{isOpen:!0,onClose:e,children:[v.jsx(Wo,{}),v.jsxs(Ko,{children:[v.jsx($o,{children:"Create Version"}),v.jsx(zo,{}),v.jsx(Uo,{children:v.jsxs(br,{isInvalid:!!o,children:[v.jsx(_r,{children:"Name"}),v.jsx(kn,{value:n,onChange:a,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&i()}}),o&&v.jsx(xr,{children:o})]})}),v.jsxs(qo,{children:[v.jsx(Ne,{colorScheme:"teal",mr:3,onClick:i,isDisabled:!n||!!o,children:"Create"}),v.jsx(Ne,{onClick:e,children:"Cancel"})]})]})]})}function rh({options:t,menuButton:e,isOpen:n,onClose:r}){const o=y.useRef(null);return Hl({ref:o,handler:()=>r()}),v.jsxs(at,{position:"relative",children:[v.jsx(at,{children:e}),n&&v.jsx(at,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function oh({menuButton:t,menuContent:e,onClose:n}){const r=y.useRef(),[o,s]=y.useState(!1),a=()=>{r.current=setTimeout(()=>s(!1),400)},i=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return v.jsx(rh,{isOpen:o,onClose:a,menuButton:v.jsx(at,{"aria-label":"menu",onClick:i,onMouseEnter:i,onMouseLeave:a,children:t}),options:v.jsx(os,{isOpen:!0,children:v.jsx(ss,{minWidth:150,zIndex:1e3,onMouseEnter:i,onMouseLeave:a,children:e})})})}const sh=y.lazy(()=>wr(()=>import("./ShareDialog-uZbltl_0.js"),__vite__mapDeps([0,1,2,3,4])));function ah(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r}=y.useContext(Pn),[o,s]=y.useState(!1),[a,i]=y.useState(!1),[l,u]=y.useState(!1),[c,d]=y.useState(""),[f,p]=y.useState(""),[b,h]=y.useState(),[w,g]=y.useState(""),[m,_]=y.useState(!1);y.useEffect(()=>{t&&(S==null||S.get(t).then(O=>{d((O==null?void 0:O.name)??""),h(O)})),U==null||U.getSetting("shortcuts").then(O=>{g(O==null?void 0:O.save)})},[t]);const k=O=>{d(O.target.value),f&&p("")},E=async()=>{if(!t){alert("Flow ID is required");return}const O=JSON.stringify(ye.graph.serialize()),D=await(S==null?void 0:S.createFlow({json:O,lastSavedJson:O,name:c,parentFolderID:b==null?void 0:b.parentFolderID}));D&&await e(D.id,!0),C()},C=()=>{i(!1)},x=y.useCallback(async()=>{const O=t?await(S==null?void 0:S.get(t)):null;if(!O){alert("Workspace does not exist");return}const D=new Blob([O.json],{type:"application/json"}),P=URL.createObjectURL(D),N=document.createElement("a");N.href=P,N.download=`${O.name}.json`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(P)},[t]);return v.jsxs(v.Fragment,{children:[v.jsx(oh,{menuButton:v.jsx(sl,{children:v.jsxs(Ne,{px:1,height:"29px","aria-label":"menu",size:"sm",colorScheme:"gray",backgroundColor:"gray.700",children:["File",v.jsx($f,{size:20})]})}),menuContent:v.jsx(os,{isOpen:!0,children:v.jsxs(ss,{minWidth:150,zIndex:1e3,children:[v.jsx(ht,{onClick:r,icon:v.jsx(Ro,{size:20}),iconSpacing:1,command:w,children:"Save"}),v.jsx(wt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:v.jsx(ht,{onClick:n,icon:v.jsx(Kf,{size:20}),iconSpacing:1,isDisabled:(b==null?void 0:b.lastSavedJson)==null,children:"Discard unsaved changes"})}),v.jsx(ht,{onClick:x,icon:v.jsx(zf,{size:20}),iconSpacing:1,children:"Download"}),v.jsx(ht,{onClick:()=>i(!0),icon:v.jsx(Ro,{size:20}),iconSpacing:1,children:"Save As"}),v.jsx(ht,{onClick:()=>s(!0),icon:v.jsx(Zf,{size:20}),iconSpacing:1,children:"Create Version"}),v.jsx(ht,{onClick:()=>u(!0),icon:v.jsx(Hf,{size:20}),iconSpacing:1,children:"Versions History"})]})})}),m&&v.jsx(sh,{onClose:()=>_(!1)}),l&&v.jsx(th,{onClose:()=>u(!1)}),a&&v.jsxs(Lo,{isOpen:!0,onClose:C,children:[v.jsx(Wo,{}),v.jsxs(Ko,{children:[v.jsx($o,{children:"Save As"}),v.jsx(zo,{}),v.jsx(Uo,{children:v.jsxs(br,{isInvalid:!!f,children:[v.jsx(_r,{children:"Workflow name"}),v.jsx(kn,{value:c,onChange:k,autoFocus:!0,onKeyUp:O=>{O.code==="Enter"&&!f&&c&&E()}}),f&&v.jsx(xr,{children:f})]})}),v.jsxs(qo,{children:[v.jsx(Ne,{colorScheme:"teal",mr:3,onClick:E,isDisabled:!c||!!f,children:"Save"}),v.jsx(Ne,{onClick:C,children:"Cancel"})]})]})]}),o&&v.jsx(nh,{workflowId:t,onClose:()=>s(!1)})]})}function ih({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Gl(),{curFlowID:a}=y.useContext(Pn),[i,l]=y.useState(t),[u,c]=y.useState(""),d=()=>{l(t),o()},f=h=>{l(h.target.value),u&&c("")},p=async()=>{if(a){const h=i.trim();if(l(h),t===h)return b();const w=await(S==null?void 0:S.listAll())??[];(w==null?void 0:w.map(m=>m.name)).includes(h)?c("The name is duplicated, please modify it and submit again."):(await(S==null?void 0:S.updateFlow(a,{name:h})),e(h),b())}},b=()=>{c(""),s()};return a==null?null:v.jsxs(Bt,{children:[v.jsx(wt,{label:t,placement:"bottom",children:v.jsxs(yt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[v.jsx("div",{style:{width:8,display:"inline-block"},children:v.jsx(yt,{as:"span",children:n&&"* "})}),t]})}),v.jsxs(Lo,{isOpen:r,onClose:b,children:[v.jsx(Wo,{}),v.jsxs(Ko,{children:[v.jsx($o,{children:"Edit workflow name"}),v.jsx(zo,{}),v.jsx(Uo,{children:v.jsxs(br,{isInvalid:!!u,children:[v.jsx(_r,{children:"Workflow name"}),v.jsx(kn,{value:i,onChange:f,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!u&&i&&p()}}),u&&v.jsx(xr,{children:u})]})}),v.jsxs(qo,{children:[v.jsx(Ne,{colorScheme:"teal",mr:3,onClick:p,isDisabled:!i||!!u,children:"Save"}),v.jsx(Ne,{onClick:b,children:"Cancel"})]})]})]})]})}function lh({updatePanelPosition:t,positionStyle:e,curFlowName:n,setCurFlowName:r}){const{isDirty:o,loadNewWorkflow:s,saveCurWorkflow:a,setRoute:i,curFlowID:l}=y.useContext(Pn);return v.jsx(Ff,{onDragEnd:u=>{t({top:u.y,left:u.x},!0)},dragIconId:"dragPanelIcon",children:v.jsxs(Bt,{style:{padding:2,position:"fixed",...e},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[v.jsx(Ne,{size:"sm","aria-label":"workspace folder",onClick:()=>i("recentFlows"),px:2,children:v.jsxs(Bt,{gap:1,children:[v.jsx(qf,{size:21}),v.jsx(Xf,{size:8})]})}),v.jsx(wt,{label:"New workflow",children:v.jsx(Ne,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",onClick:()=>s(),px:2,py:2,children:v.jsx(Bt,{gap:0,children:v.jsx(Yf,{size:16,color:"white"})})})}),v.jsx(ih,{isDirty:o,displayName:n??"",updateFlowName:u=>{r(u),requestAnimationFrame(()=>{t()})}}),l&&v.jsxs(Bt,{gap:"4px",children:[v.jsx(wt,{label:"Open gallery",children:v.jsx(hn,{onClick:()=>i("gallery"),icon:v.jsx(Jf,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),v.jsx(ah,{})]}),l&&o?v.jsx(wt,{label:"Save workflow",children:v.jsx(hn,{onClick:a,icon:v.jsx(Ro,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):v.jsx("div",{style:{width:1}}),v.jsx(Vf,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})})}const ch=Vo.lazy(()=>wr(()=>import("./RecentFilesDrawer-KtfWyPT6.js"),__vite__mapDeps([5,1,3,6,2,7,8]))),uh=Vo.lazy(()=>wr(()=>import("./GalleryModal-SJS3r_wH.js"),__vite__mapDeps([9,1,8,6,2,4,7]))),dh=Vo.lazy(()=>wr(()=>import("./ModelManagerTopbar-O1ybaI8q.js").then(t=>t.M),__vite__mapDeps([10,1,6,2,11]))),fh=["download_progress","download_error","model_list"];function hh(){const[t,e]=y.useState(null),[n,r]=y.useState("root"),[o,s]=y.useState(!0),[a,i]=y.useState(null),l=y.useRef(null),[u,c]=y.useState(),[d,f]=y.useState(!1),p=y.useRef(null),{showDialog:b}=al(),[h,w]=y.useState(!1);y.useRef(!1);const g=y.useRef(0),m=y.useRef("hide"),_=y.useCallback(async()=>{if(l.current){const j=JSON.stringify(ye.graph.serialize());await Promise.all([S==null?void 0:S.updateFlow(l.current,{lastSavedJson:j,json:j}),Ve==null?void 0:Ve.create({workflowID:l.current,json:j})])}},[]),k=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(S==null?void 0:S.delete(l.current)),C(null,""))},E=async()=>{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.")&&l.current){const R=await(S==null?void 0:S.get(l.current));R&&R.lastSavedJson&&await ye.loadGraphData(JSON.parse(R.lastSavedJson))}},C=(j,R)=>{if(l.current=j,i(j),e(R),S==null||S.updateCurWorkflowID(j),j==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ra()){const F=Ri(j);window.location.hash=F,document.title=R+" - ComfyUI"}else localStorage.setItem("curFlowID",j),document.title="ComfyUI - "+R},x=async()=>{O(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Nf(),await(U==null?void 0:U.getSetting("topBarStyle").then(F=>{I(F,!1)}))}catch(F){console.error("error loading db",F)}s(!1);let j=null;if(j=ra(),j==null&&(j=localStorage.getItem("curFlowID")),j&&N(j),localStorage.getItem("REWRITTEN_ALL_LOCAL_DISK_FILE")==="true"?await Fi():(await jf(),localStorage.setItem("REWRITTEN_ALL_LOCAL_DISK_FILE","true")),await(U==null?void 0:U.getSetting("twoWaySync"))){const F=await(U==null?void 0:U.getSetting("myWorkflowsDir")),W=await(S==null?void 0:S.listAll()),z=W&&W.map(te=>te.id)||[],q=await kd(F,z);if(!q||q.length===0)return;await Mi(q)}},O=()=>{fh.forEach(j=>{Es.addEventListener(j,()=>null)})},D=async()=>{if(l.current!=null){const j=await(S==null?void 0:S.get(l.current));return!!j&&P(j)}return!1},P=j=>{if(j.lastSavedJson==null)return!0;const R=ye.graph.serialize()??{};let F={};try{F=j!=null&&j.lastSavedJson?JSON.parse(j==null?void 0:j.lastSavedJson):{}}catch(z){console.error("error parsing json",z)}return!(JSON.stringify(R)===JSON.stringify(F))},N=async j=>{if(ye.graph==null){console.error("app.graph is null cannot load workflow");return}const R=await(S==null?void 0:S.get(j));if(R==null){alert("Error: Workflow not found! id: "+j),C(null,"");return}C(j,R.name),ye.ui.dialog.close(),ye.loadGraphData(JSON.parse(R.json)),r("root")},K=async(j,R=!1)=>{if(j===null){C(null,""),ye.graph.clear();return}if((await(U==null?void 0:U.getSetting("autoSave"))??!0)||!d||R){N(j);return}T(j)},T=async j=>{var F,W;const R=[j?{label:"Open in new tab",icon:v.jsx(Uf,{}),onClick:()=>{Pf(j)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await _(),j&&N(j)}}];((F=S==null?void 0:S.curWorkflow)==null?void 0:F.lastSavedJson)!=null?R.push({label:"Discard",colorScheme:"red",onClick:async()=>{await E(),j&&N(j)}}):R.push({label:"Delete",colorScheme:"red",onClick:async()=>{await k(),j&&N(j)}}),b(`Please save or discard your changes to "${(W=S==null?void 0:S.curWorkflow)==null?void 0:W.name}" before leaving, or your changes will be lost.`,R)},L=async j=>{const R=(j==null?void 0:j.json)??JSON.stringify(Po),F=await(S==null?void 0:S.createFlow({json:R,name:j==null?void 0:j.name}));F&&await K(F.id),r("root")},Z=async(j,R=!1)=>{const F=j.split("/").pop()??j;R?_():L({name:F});const W=await fetch(If(j)),z=await W.blob(),q=new File([z],F,{type:W.headers.get("Content-Type")||""});await ye.handleFile(q),r("root")},$=async(j,R)=>{const F=await(S==null?void 0:S.get(j));if(F==null)return;const W=await(S==null?void 0:S.createFlow({json:F.json,lastSavedJson:F.lastSavedJson,name:R||F.name,parentFolderID:F.parentFolderID,tags:F.tags}));W&&await K(W.id)},I=y.useCallback((j,R=!1)=>{const{top:F=0,left:W=0}=u||{};let{top:z=0,left:q=0}=j??{};z+=F,q+=W;const te=document.documentElement.clientWidth,re=document.documentElement.clientHeight,ie=document.getElementById("workspaceManagerPanel"),we=(ie==null?void 0:ie.offsetWidth)||392;z+36>re&&(z=re-36),q+we>=te&&(q=te-we),c({top:Math.max(0,z),left:Math.max(0,q)}),R&&(U==null||U.upsert({topBarStyle:{top:z,left:q}}))},[u]),H=async j=>{await Of(j)&&_()},J=y.useCallback(j=>{if(l.current==null)return;let R=j.filename;j.subfolder!=null&&j.subfolder!==""&&(R=j.subfolder+"/"+R),kt==null||kt.create({workflowID:l.current,localPath:R})},[]),de=y.useCallback(()=>{r("root")},[]);return y.useEffect(()=>{x(),w(!0),g.current=setInterval(async()=>{const q=await(U==null?void 0:U.getSetting("autoSave"))??!0;if(l.current!=null&&q){const te=await(S==null?void 0:S.latestVersionCheck());if(m.current!=="disabled"&&!te)m.current="show",b(`This notification is to inform you that it appears you've opened the same workflow in multiple tabs. If all tabs are set to auto-save, this may lead to conflicts and potential data loss. + +You might want to consider disabling auto-save to prevent this. We will remind you to save changes if you leave a page with unsaved work.`,[{label:"Do Not Remind Again",onClick:()=>{m.current="disabled"}},{label:"Disable Auto-Save",colorScheme:"teal",onClick:()=>{U==null||U.upsert({autoSave:!1})}}],!0);else{const re=JSON.stringify(ye.graph.serialize());re!=null&&await(S==null?void 0:S.updateFlow(l.current,{json:re}))}}D().then(te=>{f(te)})},1e3),window.addEventListener("keydown",H);const j=document.getElementById("comfy-file-input"),R=async()=>{if(j&&j.files&&j.files.length>0){const q=await(S==null?void 0:S.createFlow({name:j.files[0].name,json:JSON.stringify(Po)}));q&&C(q.id,q.name??"Unknown name")}};j==null||j.addEventListener("change",R);const F=q=>{const te=(U==null?void 0:U.autoSave)??!0,re=!!(S!=null&&S.curWorkflow)&&P(S==null?void 0:S.curWorkflow);!te&&re&&(q.preventDefault(),q.returnValue="You have unsaved changes!",T())};window.addEventListener("beforeunload",F);const W=q=>{var te,re,ie,we,Ce,Q;(ie=(re=(te=q.detail)==null?void 0:te.output)==null?void 0:re.images)==null||ie.forEach(pe=>{pe.type==="output"&&J(pe)}),(Q=(Ce=(we=q.detail)==null?void 0:we.output)==null?void 0:Ce.gifs)==null||Q.forEach(pe=>{pe.type==="output"&&J(pe)})};Es.addEventListener("executed",W);const z=async q=>{var ie,we;const te=(we=(ie=q.dataTransfer)==null?void 0:ie.files[0])==null?void 0:we.name;if(!(await(U==null?void 0:U.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&te){const Ce=await(S==null?void 0:S.createFlow({name:te}));Ce&&C(Ce.id,Ce.name)}};return ye.canvasEl.addEventListener("drop",z),()=>{window.removeEventListener("keydown",H),window.removeEventListener("change",R),window.removeEventListener("beforeunload",F),window.removeEventListener("executed",W),ye.canvasEl.removeEventListener("drop",z),clearInterval(g.current)}},[]),o||!u?null:v.jsx(Pn.Provider,{value:{curFlowID:a,onDuplicateWorkflow:$,loadWorkflowID:K,discardUnsavedChanges:E,saveCurWorkflow:_,isDirty:d,loadNewWorkflow:L,loadFilePath:Z,setRoute:r},children:v.jsx("div",{ref:p,className:"workspace_manager",children:v.jsx(la,{containerRef:p,children:v.jsxs(at,{style:{position:"absolute",top:0,right:0,left:0},zIndex:kf,draggable:!1,children:[v.jsx(lh,{curFlowName:t,setCurFlowName:e,updatePanelPosition:I,positionStyle:u}),h&&v.jsx(y.Suspense,{children:v.jsx(dh,{})}),h&&n==="recentFlows"&&v.jsx(y.Suspense,{children:v.jsx(ch,{onClose:de,onClickNewFlow:()=>{L(),r("root")}})}),n==="gallery"&&v.jsx(uh,{onclose:()=>r("root")})]})})})})}const jh=Object.freeze(Object.defineProperty({__proto__:null,default:hh},Symbol.toStringTag,{value:"Module"}));export{qa as $,$f as A,at as B,Dh as C,eh as D,qf as E,Kn as F,ee as G,Bt as H,hn as I,br as J,_r as K,xr as L,Wa as M,Yf as N,Po as O,Oh as P,Xn as Q,Ph as R,$u as S,yt as T,Ih as U,Eh as V,Pl as W,$a as X,Ka as Y,Ha as Z,za as _,gh as a,Ua as a0,Pn as a1,Pf as a2,Uf as a3,pt as a4,_l as a5,kf as a6,_h as a7,Df as a8,Sh as a9,kt as aa,_a as ab,Zl as ac,ul as ad,X as ae,Ch as af,Gl as ag,kh as ah,Ff as ai,Vf as aj,jl as ak,Yt as al,be as am,xl as an,jh as ao,Xl as b,xh as c,wh as d,bh as e,Gt as f,Er as g,Pe as h,Gf as i,on as j,kn as k,U as l,dl as m,Gr as n,wt as o,_d as p,os as q,ss as r,ht as s,Zn as t,Cr as u,Fi as v,zf as w,S as x,Qf as y,na as z}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-uZbltl_0.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-RPO2WXNL-dt-e86vT.js","workspace_web/IconCopy-48H4n38O.js","workspace_web/RecentFilesDrawer-KtfWyPT6.js","workspace_web/chunk-JARCRF6W-1wZ_35Xk.js","workspace_web/chunk-NTCQBYKE-NnaP5ESt.js","workspace_web/MediaPreview-nO-IKtd3.js","workspace_web/GalleryModal-SJS3r_wH.js","workspace_web/ModelManagerTopbar-O1ybaI8q.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css"] + } + return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) +} \ No newline at end of file diff --git a/dist/workspace_web/App-iJ8dSmpT.js b/dist/workspace_web/App-iJ8dSmpT.js deleted file mode 100644 index 9b4face..0000000 --- a/dist/workspace_web/App-iJ8dSmpT.js +++ /dev/null @@ -1,15 +0,0 @@ -var $i=Object.defineProperty;var Ui=(t,e,n)=>e in t?$i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ce=(t,e,n)=>(Ui(t,typeof e!="symbol"?e+"":e,n),n);import{u as zi,a as qi,r as v,c as Vi,b as $e,m as _e,d as yt,f as J,j as p,B as Oe,e as Hi,g as V,h as re,o as Le,i as St,k as Ue,I as Ji,l as Cn,n as Nr,p as le,q as Gi,s as Yi,t as Xi,v as Zi,w as gr,x as Qi,y as el,z as tl,A as nl,C as rl,D as To,E as aa,F as Lo,G as ia,H as ol,J as sl,K as al,P as la,M as Bo,L as Wo,N as Ko,O as $o,Q as Uo,R as zo,S as qo,_ as wr,T as il,U as ll,V as Vo}from"./input.js";import{app as ye}from"/scripts/app.js";import{api as Es}from"/scripts/api.js";function cl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function ca(t){var e;return cl(t)&&(e=t.ownerDocument)!=null?e:document}function ul(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var dl=ul();function fl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function hl(t){const{theme:e}=zi(),n=qi();return v.useMemo(()=>Vi(e.direction,{...n,...t}),[t,e.direction,n])}var pl=Object.defineProperty,ml=(t,e,n)=>e in t?pl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ue=(t,e,n)=>(ml(t,typeof e!="symbol"?e+"":e,n),n);function Ds(t){return t.sort((e,n)=>{const r=e.compareDocumentPosition(n);if(r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY)return-1;if(r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS)return 1;if(r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC)throw Error("Cannot sort the given nodes.");return 0})}var vl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Is(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Ss(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var Jr=typeof window<"u"?v.useLayoutEffect:v.useEffect,er=t=>t,yl=class{constructor(){ue(this,"descendants",new Map),ue(this,"register",t=>{if(t!=null)return vl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),ue(this,"unregister",t=>{this.descendants.delete(t);const e=Ds(Array.from(this.descendants.keys()));this.assignIndex(e)}),ue(this,"destroy",()=>{this.descendants.clear()}),ue(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),ue(this,"count",()=>this.descendants.size),ue(this,"enabledCount",()=>this.enabledValues().length),ue(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),ue(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),ue(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),ue(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),ue(this,"first",()=>this.item(0)),ue(this,"firstEnabled",()=>this.enabledItem(0)),ue(this,"last",()=>this.item(this.descendants.size-1)),ue(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),ue(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),ue(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),ue(this,"next",(t,e=!0)=>{const n=Is(t,this.count(),e);return this.item(n)}),ue(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Is(r,this.enabledCount(),e);return this.enabledItem(o)}),ue(this,"prev",(t,e=!0)=>{const n=Ss(t,this.count()-1,e);return this.item(n)}),ue(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Ss(r,this.enabledCount()-1,e);return this.enabledItem(o)}),ue(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Ds(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 gl(){const t=v.useRef(new yl);return Jr(()=>()=>t.current.destroy()),t.current}var[wl,ua]=$e({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function bl(t){const e=ua(),[n,r]=v.useState(-1),o=v.useRef(null);Jr(()=>()=>{o.current&&e.unregister(o.current)},[]),Jr(()=>{if(!o.current)return;const a=Number(o.current.dataset.index);n!=a&&!Number.isNaN(a)&&r(a)});const s=er(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:_e(s,o)}}function da(){return[er(wl),()=>er(ua()),()=>gl(),o=>bl(o)]}function fa(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(f,m)=>f!==m}=t,s=yt(r),a=yt(o),[i,l]=v.useState(n),u=e!==void 0,c=u?e:i,d=yt(f=>{const b=typeof f=="function"?f(c):f;a(c,b)&&(u||l(b),s(b))},[u,s,c,a]);return[c,d]}function Ho(t){return v.Children.toArray(t).filter(e=>v.isValidElement(e))}var Ut=J((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...a}=t,i=n||r,l=v.isValidElement(i)?v.cloneElement(i,{"aria-hidden":!0,focusable:!1}):null;return p.jsx(Oe,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...a,children:l})});Ut.displayName="IconButton";var[xl,ha]=Hi("Card"),_l=J(function(e,n){const{className:r,...o}=e,s=ha();return p.jsx(V.div,{ref:n,className:re("chakra-card__body",r),__css:s.body,...o})}),kl=J(function(e,n){const{className:r,...o}=e,s=ha();return p.jsx(V.div,{ref:n,className:re("chakra-card__header",r),__css:s.header,...o})}),Cl=J(function(e,n){const{className:r,children:o,direction:s="column",justify:a,align:i,...l}=Le(e),u=St("Card",e);return p.jsx(V.div,{ref:n,className:re("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:a,alignItems:i,position:"relative",minWidth:0,wordWrap:"break-word",...u.container},...l,children:p.jsx(xl,{value:u,children:o})})}),[El,pa]=$e({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Dl,Yt]=$e({strict:!1,name:"FormControlContext"});function Il(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...a}=t,i=v.useId(),l=e||`field-${i}`,u=`${l}-label`,c=`${l}-feedback`,d=`${l}-helptext`,[f,m]=v.useState(!1),[b,h]=v.useState(!1),[w,g]=v.useState(!1),y=v.useCallback((x={},I=null)=>({id:d,...x,ref:_e(I,D=>{D&&h(!0)})}),[d]),_=v.useCallback((x={},I=null)=>({...x,ref:I,"data-focus":Ue(w),"data-disabled":Ue(o),"data-invalid":Ue(r),"data-readonly":Ue(s),id:x.id!==void 0?x.id:u,htmlFor:x.htmlFor!==void 0?x.htmlFor:l}),[l,o,w,r,s,u]),k=v.useCallback((x={},I=null)=>({id:c,...x,ref:_e(I,D=>{D&&m(!0)}),"aria-live":"polite"}),[c]),E=v.useCallback((x={},I=null)=>({...x,...a,ref:I,role:"group","data-focus":Ue(w),"data-disabled":Ue(o),"data-invalid":Ue(r),"data-readonly":Ue(s)}),[a,o,w,r,s]),C=v.useCallback((x={},I=null)=>({...x,ref:I,role:"presentation","aria-hidden":!0,children:x.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!w,onFocus:()=>g(!0),onBlur:()=>g(!1),hasFeedbackText:f,setHasFeedbackText:m,hasHelpText:b,setHasHelpText:h,id:l,labelId:u,feedbackId:c,helpTextId:d,htmlProps:a,getHelpTextProps:y,getErrorMessageProps:k,getRootProps:E,getLabelProps:_,getRequiredIndicatorProps:C}}var br=J(function(e,n){const r=St("Form",e),o=Le(e),{getRootProps:s,htmlProps:a,...i}=Il(o),l=re("chakra-form-control",e.className);return p.jsx(Dl,{value:i,children:p.jsx(El,{value:r,children:p.jsx(V.div,{...s({},n),className:l,__css:r.container})})})});br.displayName="FormControl";var Sl=J(function(e,n){const r=Yt(),o=pa(),s=re("chakra-form__helper-text",e.className);return p.jsx(V.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Sl.displayName="FormHelperText";var[Ol,Pl]=$e({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),xr=J((t,e)=>{const n=St("FormError",t),r=Le(t),o=Yt();return o!=null&&o.isInvalid?p.jsx(Ol,{value:n,children:p.jsx(V.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:re("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});xr.displayName="FormErrorMessage";var jl=J((t,e)=>{const n=Pl(),r=Yt();if(!(r!=null&&r.isInvalid))return null;const o=re("chakra-form__error-icon",t.className);return p.jsx(Ji,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:p.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"})})});jl.displayName="FormErrorIcon";var _r=J(function(e,n){var r;const o=Cn("FormLabel",e),s=Le(e),{className:a,children:i,requiredIndicator:l=p.jsx(ma,{}),optionalIndicator:u=null,...c}=s,d=Yt(),f=(r=d==null?void 0:d.getLabelProps(c,n))!=null?r:{ref:n,...c};return p.jsxs(V.label,{...f,className:re("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[i,d!=null&&d.isRequired?l:u]})});_r.displayName="FormLabel";var ma=J(function(e,n){const r=Yt(),o=pa();if(!(r!=null&&r.isRequired))return null;const s=re("chakra-form__required-indicator",e.className);return p.jsx(V.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});ma.displayName="RequiredIndicator";function Nl(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=Al(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":Nr(n),"aria-required":Nr(o),"aria-readonly":Nr(r)}}function Al(t){var e,n,r;const o=Yt(),{id:s,disabled:a,readOnly:i,required:l,isRequired:u,isInvalid:c,isReadOnly:d,isDisabled:f,onFocus:m,onBlur:b,...h}=t,w=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&w.push(o.feedbackId),o!=null&&o.hasHelpText&&w.push(o.helpTextId),{...h,"aria-describedby":w.join(" ")||void 0,id:s??(o==null?void 0:o.id),isDisabled:(e=a??f)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=i??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:le(o==null?void 0:o.onFocus,m),onBlur:le(o==null?void 0:o.onBlur,b)}}function Bt(t,e,n,r){const o=yt(n);return v.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 Fl(t){return"current"in t}var va=()=>typeof window<"u";function Ml(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Rl=t=>va()&&t.test(navigator.vendor),Tl=t=>va()&&t.test(Ml()),Ll=()=>Tl(/mac|iphone|ipad|ipod/i),Bl=()=>Ll()&&Rl(/apple/i);function Wl(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var s,a;return(a=(s=e.current)==null?void 0:s.ownerDocument)!=null?a:document};Bt(o,"pointerdown",s=>{if(!Bl()||!r)return;const a=s.target,l=(n??[e]).some(u=>{const c=Fl(u)?u.current:u;return(c==null?void 0:c.contains(a))||c===a});o().activeElement!==a&&l&&(s.preventDefault(),a.focus())})}var ya={exports:{}},Kl="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",$l=Kl,Ul=$l;function ga(){}function wa(){}wa.resetWarningCache=ga;var zl=function(){function t(r,o,s,a,i,l){if(l!==Ul){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:wa,resetWarningCache:ga};return n.PropTypes=n,n};ya.exports=zl();var ql=ya.exports;const ft=Gi(ql);function Vl(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 Hl(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function ba(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:Yi(t)&&Vl(t)?t:ba(Hl(t))}var Jl=dl?v.useLayoutEffect:v.useEffect;function Gr(t,e=[]){const n=v.useRef(t);return Jl(()=>{n.current=t}),v.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function Gl(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Gr(n),a=v.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;v.useEffect(()=>{if(!r)return;const i=d=>{Ar(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Ar(d,e)&&(a.isPointerDown=!1,o(d))},u=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Ar(d,e)&&(a.isPointerDown=!1,o(d))},c=ca(e.current);return c.addEventListener("mousedown",i,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",i,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",i,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",i,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,a,r])}function Ar(t,e){var n;const r=t.target;return r&&!ca(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Yl(t,e){const n=v.useId();return v.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function Xl(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function Zl(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Gr(n),a=Gr(e),[i,l]=v.useState(t.defaultIsOpen||!1),[u,c]=Xl(r,i),d=Yl(o,"disclosure"),f=v.useCallback(()=>{u||l(!1),a==null||a()},[u,a]),m=v.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),b=v.useCallback(()=>{(c?f:m)()},[c,m,f]);return{isOpen:!!c,onOpen:m,onClose:f,onToggle:b,isControlled:u,getButtonProps:(h={})=>({...h,"aria-expanded":c,"aria-controls":d,onClick:Xi(h.onClick,b)}),getDisclosureProps:(h={})=>({...h,hidden:!c,id:d})}}var En=J(function(e,n){const{htmlSize:r,...o}=e,s=St("Input",o),a=Le(o),i=Nl(a),l=re("chakra-input",e.className);return p.jsx(V.input,{size:r,...i,__css:s.field,ref:n,className:l})});En.displayName="Input";En.id="Input";var xa=J(function(e,n){const r=Cn("Link",e),{className:o,isExternal:s,...a}=Le(e);return p.jsx(V.a,{target:s?"_blank":void 0,rel:s?"noopener":void 0,ref:n,className:re("chakra-link",o),...a,__css:r})});xa.displayName="Link";var Ql=Object.freeze(["base","sm","md","lg","xl","2xl"]);function ec(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):Zi(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function Sh(t,e=Ql){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var gt=J(function(e,n){const r=Cn("Text",e),{className:o,align:s,decoration:a,casing:i,...l}=Le(e),u=fl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return p.jsx(V.p,{ref:n,className:re("chakra-text",e.className),...u,...l,__css:r})});gt.displayName="Text";var Yr=t=>p.jsx(V.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});Yr.displayName="StackDivider";var _a=t=>p.jsx(V.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});_a.displayName="StackItem";function tc(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{"&":ec(n,o=>r[o])}}var an=J((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:a="0.5rem",wrap:i,children:l,divider:u,className:c,shouldWrapChildren:d,...f}=t,m=n?"row":r??"column",b=v.useMemo(()=>tc({spacing:a,direction:m}),[a,m]),h=!!u,w=!d&&!h,g=v.useMemo(()=>{const _=Ho(l);return w?_:_.map((k,E)=>{const C=typeof k.key<"u"?k.key:E,x=E+1===_.length,D=d?p.jsx(_a,{children:k},C):k;if(!h)return D;const P=v.cloneElement(u,{__css:b}),N=x?null:P;return p.jsxs(v.Fragment,{children:[D,N]},C)})},[u,b,h,w,d,l]),y=re("chakra-stack",c);return p.jsx(V.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:m,flexWrap:i,gap:h?void 0:a,className:y,...f,children:g})});an.displayName="Stack";var mt=J((t,e)=>p.jsx(an,{align:"center",...t,direction:"row",ref:e}));mt.displayName="HStack";var ka=J(function(e,n){const r=Cn("Heading",e),{className:o,...s}=Le(e);return p.jsx(V.h2,{ref:n,className:re("chakra-heading",e.className),...s,__css:r})});ka.displayName="Heading";var it=V("div");it.displayName="Box";var Ca=J(function(e,n){const{size:r,centerContent:o=!0,...s}=e,a=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return p.jsx(it,{ref:n,boxSize:r,__css:{...a,flexShrink:0,flexGrow:0},...s})});Ca.displayName="Square";var nc=J(function(e,n){const{size:r,...o}=e;return p.jsx(Ca,{size:r,ref:n,borderRadius:"9999px",...o})});nc.displayName="Circle";var $n=J(function(e,n){const{direction:r,align:o,justify:s,wrap:a,basis:i,grow:l,shrink:u,...c}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:a,flexBasis:i,flexGrow:l,flexShrink:u};return p.jsx(V.div,{ref:n,__css:d,...c})});$n.displayName="Flex";function rc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function oc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=v.useState([]),s=v.useRef(),a=()=>{s.current&&(clearTimeout(s.current),s.current=null)},i=()=>{a(),s.current=setTimeout(()=>{o([]),s.current=null},e)};v.useEffect(()=>a,[]);function l(u){return c=>{if(c.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(rc(c)){const d=r.concat(c.key);n(c)&&(c.preventDefault(),c.stopPropagation()),o(d),u(d.join("")),i()}}}return l}function sc(t,e,n,r){if(e==null)return r;if(!r)return t.find(a=>n(a).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 ac(){const t=v.useRef(new Map),e=t.current,n=v.useCallback((o,s,a,i)=>{t.current.set(a,{type:s,el:o,options:i}),o.addEventListener(s,a,i)},[]),r=v.useCallback((o,s,a,i)=>{o.removeEventListener(s,a,i),t.current.delete(a)},[]);return v.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function Fr(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ea(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:a,onMouseUp:i,onClick:l,onKeyDown:u,onKeyUp:c,tabIndex:d,onMouseOver:f,onMouseLeave:m,...b}=t,[h,w]=v.useState(!0),[g,y]=v.useState(!1),_=ac(),k=O=>{O&&O.tagName!=="BUTTON"&&w(!1)},E=h?d:d||0,C=n&&!r,x=v.useCallback(O=>{if(n){O.stopPropagation(),O.preventDefault();return}O.currentTarget.focus(),l==null||l(O)},[n,l]),I=v.useCallback(O=>{g&&Fr(O)&&(O.preventDefault(),O.stopPropagation(),y(!1),_.remove(document,"keyup",I,!1))},[g,_]),D=v.useCallback(O=>{if(u==null||u(O),n||O.defaultPrevented||O.metaKey||!Fr(O.nativeEvent)||h)return;const H=o&&O.key==="Enter";s&&O.key===" "&&(O.preventDefault(),y(!0)),H&&(O.preventDefault(),O.currentTarget.click()),_.add(document,"keyup",I,!1)},[n,h,u,o,s,_,I]),P=v.useCallback(O=>{if(c==null||c(O),n||O.defaultPrevented||O.metaKey||!Fr(O.nativeEvent)||h)return;s&&O.key===" "&&(O.preventDefault(),y(!1),O.currentTarget.click())},[s,h,n,c]),N=v.useCallback(O=>{O.button===0&&(y(!1),_.remove(document,"mouseup",N,!1))},[_]),K=v.useCallback(O=>{if(O.button!==0)return;if(n){O.stopPropagation(),O.preventDefault();return}h||y(!0),O.currentTarget.focus({preventScroll:!0}),_.add(document,"mouseup",N,!1),a==null||a(O)},[n,h,a,_,N]),T=v.useCallback(O=>{O.button===0&&(h||y(!1),i==null||i(O))},[i,h]),B=v.useCallback(O=>{if(n){O.preventDefault();return}f==null||f(O)},[n,f]),Z=v.useCallback(O=>{g&&(O.preventDefault(),y(!1)),m==null||m(O)},[g,m]),$=_e(e,k);return h?{...b,ref:$,type:"button","aria-disabled":C?void 0:n,disabled:C,onClick:x,onMouseDown:a,onMouseUp:i,onKeyUp:c,onKeyDown:u,onMouseOver:f,onMouseLeave:m}:{...b,ref:$,role:"button","data-active":Ue(g),"aria-disabled":n?"true":void 0,tabIndex:C?void 0:E,onClick:x,onMouseDown:K,onMouseUp:T,onKeyUp:P,onKeyDown:D,onMouseOver:B,onMouseLeave:Z}}function ic(t){const e=t.current;if(!e)return!1;const n=tl(e);return!n||e.contains(n)?!1:!!nl(n)}function Da(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;gr(()=>{if(!s||ic(t))return;const a=(o==null?void 0:o.current)||t.current;let i;if(a)return i=requestAnimationFrame(()=>{a.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(i)}},[s,t,o])}var lc={preventScroll:!0,shouldFocus:!1};function cc(t,e=lc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,a=uc(t)?t.current:t,i=o&&s,l=v.useRef(i),u=v.useRef(s);Qi(()=>{!u.current&&s&&(l.current=i),u.current=s},[s,i]);const c=v.useCallback(()=>{if(!(!s||!a||!l.current)&&(l.current=!1,!a.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=el(a);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,a,n]);gr(()=>{c()},[c]),Bt(a,"transitionend",c)}function uc(t){return"current"in t}var Ft=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),fe={arrowShadowColor:Ft("--popper-arrow-shadow-color"),arrowSize:Ft("--popper-arrow-size","8px"),arrowSizeHalf:Ft("--popper-arrow-size-half"),arrowBg:Ft("--popper-arrow-bg"),transformOrigin:Ft("--popper-transform-origin"),arrowOffset:Ft("--popper-arrow-offset")};function dc(t){if(t.includes("top"))return"1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("bottom"))return"-1px -1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("right"))return"-1px 1px 0px 0 var(--popper-arrow-shadow-color)";if(t.includes("left"))return"1px -1px 0px 0 var(--popper-arrow-shadow-color)"}var fc={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},hc=t=>fc[t],Os={scroll:!0,resize:!0};function pc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Os,...t}}:e={enabled:t,options:Os},e}var mc={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`}},vc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Ps(t)},effect:({state:t})=>()=>{Ps(t)}},Ps=t=>{t.elements.popper.style.setProperty(fe.transformOrigin.var,hc(t.placement))},yc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{gc(t)}},gc=t=>{var e;if(!t.placement)return;const n=wc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:fe.arrowSize.varRef,height:fe.arrowSize.varRef,zIndex:-1});const r={[fe.arrowSizeHalf.var]:`calc(${fe.arrowSize.varRef} / 2 - 1px)`,[fe.arrowOffset.var]:`calc(${fe.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},wc=t=>{if(t.startsWith("top"))return{property:"bottom",value:fe.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:fe.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:fe.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:fe.arrowOffset.varRef}},bc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{js(t)},effect:({state:t})=>()=>{js(t)}},js=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=dc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:fe.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},xc={"start-start":{ltr:"left-start",rtl:"right-start"},"start-end":{ltr:"left-end",rtl:"right-end"},"end-start":{ltr:"right-start",rtl:"left-start"},"end-end":{ltr:"right-end",rtl:"left-end"},start:{ltr:"left",rtl:"right"},end:{ltr:"right",rtl:"left"}},_c={"auto-start":"auto-end","auto-end":"auto-start","top-start":"top-end","top-end":"top-start","bottom-start":"bottom-end","bottom-end":"bottom-start"};function kc(t,e="ltr"){var n,r;const o=((n=xc[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=_c[t])!=null?r:o}var Pe="top",Re="bottom",Te="right",je="left",Jo="auto",Dn=[Pe,Re,Te,je],zt="start",mn="end",Cc="clippingParents",Ia="viewport",tn="popper",Ec="reference",Ns=Dn.reduce(function(t,e){return t.concat([e+"-"+zt,e+"-"+mn])},[]),Sa=[].concat(Dn,[Jo]).reduce(function(t,e){return t.concat([e,e+"-"+zt,e+"-"+mn])},[]),Dc="beforeRead",Ic="read",Sc="afterRead",Oc="beforeMain",Pc="main",jc="afterMain",Nc="beforeWrite",Ac="write",Fc="afterWrite",Mc=[Dc,Ic,Sc,Oc,Pc,jc,Nc,Ac,Fc];function He(t){return t?(t.nodeName||"").toLowerCase():null}function Ae(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Et(t){var e=Ae(t).Element;return t instanceof e||t instanceof Element}function Me(t){var e=Ae(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Go(t){if(typeof ShadowRoot>"u")return!1;var e=Ae(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Rc(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];!Me(s)||!He(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(a){var i=o[a];i===!1?s.removeAttribute(a):s.setAttribute(a,i===!0?"":i)}))})}function Tc(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]||{},a=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),i=a.reduce(function(l,u){return l[u]="",l},{});!Me(o)||!He(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Lc={name:"applyStyles",enabled:!0,phase:"write",fn:Rc,effect:Tc,requires:["computeStyles"]};function qe(t){return t.split("-")[0]}var wt=Math.max,tr=Math.min,qt=Math.round;function Xr(){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 Oa(){return!/^((?!chrome|android).)*safari/i.test(Xr())}function Vt(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Me(t)&&(o=t.offsetWidth>0&&qt(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&qt(r.height)/t.offsetHeight||1);var a=Et(t)?Ae(t):window,i=a.visualViewport,l=!Oa()&&n,u=(r.left+(l&&i?i.offsetLeft:0))/o,c=(r.top+(l&&i?i.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:c,right:u+d,bottom:c+f,left:u,x:u,y:c}}function Yo(t){var e=Vt(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 Pa(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Go(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function tt(t){return Ae(t).getComputedStyle(t)}function Bc(t){return["table","td","th"].indexOf(He(t))>=0}function dt(t){return((Et(t)?t.ownerDocument:t.document)||window.document).documentElement}function kr(t){return He(t)==="html"?t:t.assignedSlot||t.parentNode||(Go(t)?t.host:null)||dt(t)}function As(t){return!Me(t)||tt(t).position==="fixed"?null:t.offsetParent}function Wc(t){var e=/firefox/i.test(Xr()),n=/Trident/i.test(Xr());if(n&&Me(t)){var r=tt(t);if(r.position==="fixed")return null}var o=kr(t);for(Go(o)&&(o=o.host);Me(o)&&["html","body"].indexOf(He(o))<0;){var s=tt(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 In(t){for(var e=Ae(t),n=As(t);n&&Bc(n)&&tt(n).position==="static";)n=As(n);return n&&(He(n)==="html"||He(n)==="body"&&tt(n).position==="static")?e:n||Wc(t)||e}function Xo(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function ln(t,e,n){return wt(t,tr(e,n))}function Kc(t,e,n){var r=ln(t,e,n);return r>n?n:r}function ja(){return{top:0,right:0,bottom:0,left:0}}function Na(t){return Object.assign({},ja(),t)}function Aa(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var $c=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,Na(typeof e!="number"?e:Aa(e,Dn))};function Uc(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,a=n.modifiersData.popperOffsets,i=qe(n.placement),l=Xo(i),u=[je,Te].indexOf(i)>=0,c=u?"height":"width";if(!(!s||!a)){var d=$c(o.padding,n),f=Yo(s),m=l==="y"?Pe:je,b=l==="y"?Re:Te,h=n.rects.reference[c]+n.rects.reference[l]-a[l]-n.rects.popper[c],w=a[l]-n.rects.reference[l],g=In(s),y=g?l==="y"?g.clientHeight||0:g.clientWidth||0:0,_=h/2-w/2,k=d[m],E=y-f[c]-d[b],C=y/2-f[c]/2+_,x=ln(k,C,E),I=l;n.modifiersData[r]=(e={},e[I]=x,e.centerOffset=x-C,e)}}function zc(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)||Pa(e.elements.popper,o)&&(e.elements.arrow=o))}const qc={name:"arrow",enabled:!0,phase:"main",fn:Uc,effect:zc,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ht(t){return t.split("-")[1]}var Vc={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Hc(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:qt(n*o)/o||0,y:qt(r*o)/o||0}}function Fs(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,a=t.offsets,i=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,f=a.x,m=f===void 0?0:f,b=a.y,h=b===void 0?0:b,w=typeof c=="function"?c({x:m,y:h}):{x:m,y:h};m=w.x,h=w.y;var g=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),_=je,k=Pe,E=window;if(u){var C=In(n),x="clientHeight",I="clientWidth";if(C===Ae(n)&&(C=dt(n),tt(C).position!=="static"&&i==="absolute"&&(x="scrollHeight",I="scrollWidth")),C=C,o===Pe||(o===je||o===Te)&&s===mn){k=Re;var D=d&&C===E&&E.visualViewport?E.visualViewport.height:C[x];h-=D-r.height,h*=l?1:-1}if(o===je||(o===Pe||o===Re)&&s===mn){_=Te;var P=d&&C===E&&E.visualViewport?E.visualViewport.width:C[I];m-=P-r.width,m*=l?1:-1}}var N=Object.assign({position:i},u&&Vc),K=c===!0?Hc({x:m,y:h},Ae(n)):{x:m,y:h};if(m=K.x,h=K.y,l){var T;return Object.assign({},N,(T={},T[k]=y?"0":"",T[_]=g?"0":"",T.transform=(E.devicePixelRatio||1)<=1?"translate("+m+"px, "+h+"px)":"translate3d("+m+"px, "+h+"px, 0)",T))}return Object.assign({},N,(e={},e[k]=y?h+"px":"",e[_]=g?m+"px":"",e.transform="",e))}function Jc(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,a=s===void 0?!0:s,i=n.roundOffsets,l=i===void 0?!0:i,u={placement:qe(e.placement),variation:Ht(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,Fs(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Fs(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 Gc={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Jc,data:{}};var Nn={passive:!0};function Yc(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,a=r.resize,i=a===void 0?!0:a,l=Ae(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Nn)}),i&&l.addEventListener("resize",n.update,Nn),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Nn)}),i&&l.removeEventListener("resize",n.update,Nn)}}const Xc={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Yc,data:{}};var Zc={left:"right",right:"left",bottom:"top",top:"bottom"};function Un(t){return t.replace(/left|right|bottom|top/g,function(e){return Zc[e]})}var Qc={start:"end",end:"start"};function Ms(t){return t.replace(/start|end/g,function(e){return Qc[e]})}function Zo(t){var e=Ae(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Qo(t){return Vt(dt(t)).left+Zo(t).scrollLeft}function eu(t,e){var n=Ae(t),r=dt(t),o=n.visualViewport,s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;var u=Oa();(u||!u&&e==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:i+Qo(t),y:l}}function tu(t){var e,n=dt(t),r=Zo(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=wt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=wt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),i=-r.scrollLeft+Qo(t),l=-r.scrollTop;return tt(o||n).direction==="rtl"&&(i+=wt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:a,x:i,y:l}}function es(t){var e=tt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function Fa(t){return["html","body","#document"].indexOf(He(t))>=0?t.ownerDocument.body:Me(t)&&es(t)?t:Fa(kr(t))}function cn(t,e){var n;e===void 0&&(e=[]);var r=Fa(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ae(r),a=o?[s].concat(s.visualViewport||[],es(r)?r:[]):r,i=e.concat(a);return o?i:i.concat(cn(kr(a)))}function Zr(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function nu(t,e){var n=Vt(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 Rs(t,e,n){return e===Ia?Zr(eu(t,n)):Et(e)?nu(e,n):Zr(tu(dt(t)))}function ru(t){var e=cn(kr(t)),n=["absolute","fixed"].indexOf(tt(t).position)>=0,r=n&&Me(t)?In(t):t;return Et(r)?e.filter(function(o){return Et(o)&&Pa(o,r)&&He(o)!=="body"}):[]}function ou(t,e,n,r){var o=e==="clippingParents"?ru(t):[].concat(e),s=[].concat(o,[n]),a=s[0],i=s.reduce(function(l,u){var c=Rs(t,u,r);return l.top=wt(c.top,l.top),l.right=tr(c.right,l.right),l.bottom=tr(c.bottom,l.bottom),l.left=wt(c.left,l.left),l},Rs(t,a,r));return i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}function Ma(t){var e=t.reference,n=t.element,r=t.placement,o=r?qe(r):null,s=r?Ht(r):null,a=e.x+e.width/2-n.width/2,i=e.y+e.height/2-n.height/2,l;switch(o){case Pe:l={x:a,y:e.y-n.height};break;case Re:l={x:a,y:e.y+e.height};break;case Te:l={x:e.x+e.width,y:i};break;case je:l={x:e.x-n.width,y:i};break;default:l={x:e.x,y:e.y}}var u=o?Xo(o):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case zt:l[u]=l[u]-(e[c]/2-n[c]/2);break;case mn:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function vn(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,a=s===void 0?t.strategy:s,i=n.boundary,l=i===void 0?Cc:i,u=n.rootBoundary,c=u===void 0?Ia:u,d=n.elementContext,f=d===void 0?tn:d,m=n.altBoundary,b=m===void 0?!1:m,h=n.padding,w=h===void 0?0:h,g=Na(typeof w!="number"?w:Aa(w,Dn)),y=f===tn?Ec:tn,_=t.rects.popper,k=t.elements[b?y:f],E=ou(Et(k)?k:k.contextElement||dt(t.elements.popper),l,c,a),C=Vt(t.elements.reference),x=Ma({reference:C,element:_,strategy:"absolute",placement:o}),I=Zr(Object.assign({},_,x)),D=f===tn?I:C,P={top:E.top-D.top+g.top,bottom:D.bottom-E.bottom+g.bottom,left:E.left-D.left+g.left,right:D.right-E.right+g.right},N=t.modifiersData.offset;if(f===tn&&N){var K=N[o];Object.keys(P).forEach(function(T){var B=[Te,Re].indexOf(T)>=0?1:-1,Z=[Pe,Re].indexOf(T)>=0?"y":"x";P[T]+=K[Z]*B})}return P}function su(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,a=n.padding,i=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?Sa:l,c=Ht(r),d=c?i?Ns:Ns.filter(function(b){return Ht(b)===c}):Dn,f=d.filter(function(b){return u.indexOf(b)>=0});f.length===0&&(f=d);var m=f.reduce(function(b,h){return b[h]=vn(t,{placement:h,boundary:o,rootBoundary:s,padding:a})[qe(h)],b},{});return Object.keys(m).sort(function(b,h){return m[b]-m[h]})}function au(t){if(qe(t)===Jo)return[];var e=Un(t);return[Ms(t),e,Ms(e)]}function iu(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,a=n.altAxis,i=a===void 0?!0:a,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,f=n.altBoundary,m=n.flipVariations,b=m===void 0?!0:m,h=n.allowedAutoPlacements,w=e.options.placement,g=qe(w),y=g===w,_=l||(y||!b?[Un(w)]:au(w)),k=[w].concat(_).reduce(function(W,U){return W.concat(qe(U)===Jo?su(e,{placement:U,boundary:c,rootBoundary:d,padding:u,flipVariations:b,allowedAutoPlacements:h}):U)},[]),E=e.rects.reference,C=e.rects.popper,x=new Map,I=!0,D=k[0],P=0;P=0,Z=B?"width":"height",$=vn(e,{placement:N,boundary:c,rootBoundary:d,altBoundary:f,padding:u}),O=B?T?Te:je:T?Re:Pe;E[Z]>C[Z]&&(O=Un(O));var H=Un(O),G=[];if(s&&G.push($[K]<=0),i&&G.push($[O]<=0,$[H]<=0),G.every(function(W){return W})){D=N,I=!1;break}x.set(N,G)}if(I)for(var de=b?3:1,j=function(U){var q=k.find(function(te){var oe=x.get(te);if(oe)return oe.slice(0,U).every(function(ie){return ie})});if(q)return D=q,"break"},R=de;R>0;R--){var F=j(R);if(F==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const lu={name:"flip",enabled:!0,phase:"main",fn:iu,requiresIfExists:["offset"],data:{_skip:!1}};function Ts(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 Ls(t){return[Pe,Te,Re,je].some(function(e){return t[e]>=0})}function cu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,a=vn(e,{elementContext:"reference"}),i=vn(e,{altBoundary:!0}),l=Ts(a,r),u=Ts(i,o,s),c=Ls(l),d=Ls(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 uu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:cu};function du(t,e,n){var r=qe(t),o=[je,Pe].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,a=s[0],i=s[1];return a=a||0,i=(i||0)*o,[je,Te].indexOf(r)>=0?{x:i,y:a}:{x:a,y:i}}function fu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,a=Sa.reduce(function(c,d){return c[d]=du(d,e.rects,s),c},{}),i=a[e.placement],l=i.x,u=i.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=a}const hu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:fu};function pu(t){var e=t.state,n=t.name;e.modifiersData[n]=Ma({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const mu={name:"popperOffsets",enabled:!0,phase:"read",fn:pu,data:{}};function vu(t){return t==="x"?"y":"x"}function yu(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,a=n.altAxis,i=a===void 0?!1:a,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,f=n.tether,m=f===void 0?!0:f,b=n.tetherOffset,h=b===void 0?0:b,w=vn(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),g=qe(e.placement),y=Ht(e.placement),_=!y,k=Xo(g),E=vu(k),C=e.modifiersData.popperOffsets,x=e.rects.reference,I=e.rects.popper,D=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,P=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),N=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,K={x:0,y:0};if(C){if(s){var T,B=k==="y"?Pe:je,Z=k==="y"?Re:Te,$=k==="y"?"height":"width",O=C[k],H=O+w[B],G=O-w[Z],de=m?-I[$]/2:0,j=y===zt?x[$]:I[$],R=y===zt?-I[$]:-x[$],F=e.elements.arrow,W=m&&F?Yo(F):{width:0,height:0},U=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ja(),q=U[B],te=U[Z],oe=ln(0,x[$],W[$]),ie=_?x[$]/2-de-oe-q-P.mainAxis:j-oe-q-P.mainAxis,be=_?-x[$]/2+de+oe+te+P.mainAxis:R+oe+te+P.mainAxis,Ee=e.elements.arrow&&In(e.elements.arrow),Q=Ee?k==="y"?Ee.clientTop||0:Ee.clientLeft||0:0,me=(T=N==null?void 0:N[k])!=null?T:0,jt=O+ie-me-Q,Y=O+be-me,Se=ln(m?tr(H,jt):H,O,m?wt(G,Y):G);C[k]=Se,K[k]=Se-O}if(i){var ve,Be=k==="x"?Pe:je,Nt=k==="x"?Re:Te,We=C[E],At=E==="y"?"height":"width",Pr=We+w[Be],bs=We-w[Nt],jr=[Pe,je].indexOf(g)!==-1,xs=(ve=N==null?void 0:N[E])!=null?ve:0,_s=jr?Pr:We-x[At]-I[At]-xs+P.altAxis,ks=jr?We+x[At]+I[At]-xs-P.altAxis:bs,Cs=m&&jr?Kc(_s,We,ks):ln(m?_s:Pr,We,m?ks:bs);C[E]=Cs,K[E]=Cs-We}e.modifiersData[r]=K}}const gu={name:"preventOverflow",enabled:!0,phase:"main",fn:yu,requiresIfExists:["offset"]};function wu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function bu(t){return t===Ae(t)||!Me(t)?Zo(t):wu(t)}function xu(t){var e=t.getBoundingClientRect(),n=qt(e.width)/t.offsetWidth||1,r=qt(e.height)/t.offsetHeight||1;return n!==1||r!==1}function _u(t,e,n){n===void 0&&(n=!1);var r=Me(e),o=Me(e)&&xu(e),s=dt(e),a=Vt(t,o,n),i={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((He(e)!=="body"||es(s))&&(i=bu(e)),Me(e)?(l=Vt(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Qo(s))),{x:a.left+i.scrollLeft-l.x,y:a.top+i.scrollTop-l.y,width:a.width,height:a.height}}function ku(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 a=[].concat(s.requires||[],s.requiresIfExists||[]);a.forEach(function(i){if(!n.has(i)){var l=e.get(i);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function Cu(t){var e=ku(t);return Mc.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Eu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Du(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 Bs={placement:"bottom",modifiers:[],strategy:"absolute"};function Ws(){for(var t=arguments.length,e=new Array(t),n=0;n{}),_=v.useCallback(()=>{var P;!e||!b.current||!h.current||((P=y.current)==null||P.call(y),w.current=Ou(b.current,h.current,{placement:g,modifiers:[bc,yc,vc,{...mc,enabled:!!f},{name:"eventListeners",...pc(a)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:i??[0,l]}},{name:"flip",enabled:!!u,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:c}},...n??[]],strategy:o}),w.current.forceUpdate(),y.current=w.current.destroy)},[g,e,n,f,a,s,i,l,u,d,c,o]);v.useEffect(()=>()=>{var P;!b.current&&!h.current&&((P=w.current)==null||P.destroy(),w.current=null)},[]);const k=v.useCallback(P=>{b.current=P,_()},[_]),E=v.useCallback((P={},N=null)=>({...P,ref:_e(k,N)}),[k]),C=v.useCallback(P=>{h.current=P,_()},[_]),x=v.useCallback((P={},N=null)=>({...P,ref:_e(C,N),style:{...P.style,position:o,minWidth:f?void 0:"max-content",inset:"0 auto auto 0"}}),[o,C,f]),I=v.useCallback((P={},N=null)=>{const{size:K,shadowColor:T,bg:B,style:Z,...$}=P;return{...$,ref:N,"data-popper-arrow":"",style:Pu(P)}},[]),D=v.useCallback((P={},N=null)=>({...P,ref:N,"data-popper-arrow-inner":""}),[]);return{update(){var P;(P=w.current)==null||P.update()},forceUpdate(){var P;(P=w.current)==null||P.forceUpdate()},transformOrigin:fe.transformOrigin.varRef,referenceRef:k,popperRef:C,getPopperProps:x,getArrowProps:I,getArrowInnerProps:D,getReferenceProps:E}}function Pu(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 ns(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=yt(n),a=yt(e),[i,l]=v.useState(t.defaultIsOpen||!1),u=r!==void 0?r:i,c=r!==void 0,d=v.useId(),f=o??`disclosure-${d}`,m=v.useCallback(()=>{c||l(!1),a==null||a()},[c,a]),b=v.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),h=v.useCallback(()=>{u?m():b()},[u,b,m]);function w(y={}){return{...y,"aria-expanded":u,"aria-controls":f,onClick(_){var k;(k=y.onClick)==null||k.call(y,_),h()}}}function g(y={}){return{...y,hidden:!u,id:f}}return{isOpen:u,onOpen:b,onClose:m,onToggle:h,isControlled:c,getButtonProps:w,getDisclosureProps:g}}function ju(t){const{ref:e,handler:n,enabled:r=!0}=t,o=yt(n),a=v.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;v.useEffect(()=>{if(!r)return;const i=d=>{Mr(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Mr(d,e)&&(a.isPointerDown=!1,o(d))},u=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Mr(d,e)&&(a.isPointerDown=!1,o(d))},c=Ra(e.current);return c.addEventListener("mousedown",i,!0),c.addEventListener("mouseup",l,!0),c.addEventListener("touchstart",i,!0),c.addEventListener("touchend",u,!0),()=>{c.removeEventListener("mousedown",i,!0),c.removeEventListener("mouseup",l,!0),c.removeEventListener("touchstart",i,!0),c.removeEventListener("touchend",u,!0)}},[n,e,o,a,r])}function Mr(t,e){var n;const r=t.target;return r&&!Ra(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Ra(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Ta(t){const{isOpen:e,ref:n}=t,[r,o]=v.useState(e),[s,a]=v.useState(!1);return v.useEffect(()=>{s||(o(e),a(!0))},[e,s,r]),Bt(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const u=rl(n.current),c=new u.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(c)}}}function rs(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[Nu,Au,Fu,Mu]=da(),[Ru,Sn]=$e({strict:!1,name:"MenuContext"});function Tu(t,...e){const n=v.useId(),r=t||n;return v.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function La(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Ks(t){return La(t).activeElement===t}function Lu(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:a,isOpen:i,defaultIsOpen:l,onClose:u,onOpen:c,placement:d="bottom-start",lazyBehavior:f="unmount",direction:m,computePositionOnMount:b=!1,...h}=t,w=v.useRef(null),g=v.useRef(null),y=Fu(),_=v.useCallback(()=>{requestAnimationFrame(()=>{var F;(F=w.current)==null||F.focus({preventScroll:!1})})},[]),k=v.useCallback(()=>{const F=setTimeout(()=>{var W;if(o)(W=o.current)==null||W.focus();else{const U=y.firstEnabled();U&&T(U.index)}});H.current.add(F)},[y,o]),E=v.useCallback(()=>{const F=setTimeout(()=>{const W=y.lastEnabled();W&&T(W.index)});H.current.add(F)},[y]),C=v.useCallback(()=>{c==null||c(),s?k():_()},[s,k,_,c]),{isOpen:x,onOpen:I,onClose:D,onToggle:P}=ns({isOpen:i,defaultIsOpen:l,onClose:u,onOpen:C});ju({enabled:x&&r,ref:w,handler:F=>{var W;(W=g.current)!=null&&W.contains(F.target)||D()}});const N=ts({...h,enabled:x||b,placement:d,direction:m}),[K,T]=v.useState(-1);gr(()=>{x||T(-1)},[x]),Da(w,{focusRef:g,visible:x,shouldFocus:!0});const B=Ta({isOpen:x,ref:w}),[Z,$]=Tu(e,"menu-button","menu-list"),O=v.useCallback(()=>{I(),_()},[I,_]),H=v.useRef(new Set([]));v.useEffect(()=>{const F=H.current;return()=>{F.forEach(W=>clearTimeout(W)),F.clear()}},[]);const G=v.useCallback(()=>{I(),k()},[k,I]),de=v.useCallback(()=>{I(),E()},[I,E]),j=v.useCallback(()=>{var F,W;const U=La(w.current),q=(F=w.current)==null?void 0:F.contains(U.activeElement);if(!(x&&!q))return;const oe=(W=y.item(K))==null?void 0:W.node;oe==null||oe.focus({preventScroll:!0})},[x,K,y]),R=v.useRef(null);return{openAndFocusMenu:O,openAndFocusFirstItem:G,openAndFocusLastItem:de,onTransitionEnd:j,unstable__animationState:B,descendants:y,popper:N,buttonId:Z,menuId:$,forceUpdate:N.forceUpdate,orientation:"vertical",isOpen:x,onToggle:P,onOpen:I,onClose:D,menuRef:w,buttonRef:g,focusedIndex:K,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:T,isLazy:a,lazyBehavior:f,initialFocusRef:o,rafId:R}}function Oh(t={},e=null){const n=Sn(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:a}=n,i=v.useCallback(l=>{const u=l.key,d={Enter:s,ArrowDown:s,ArrowUp:a}[u];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,a]);return{...t,ref:_e(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":Ue(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:le(t.onClick,r),onKeyDown:le(t.onKeyDown,i)}}function Qr(t){var e;return Ku(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Bu(t={},e=null){const n=Sn();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:s,isOpen:a,onClose:i,menuId:l,isLazy:u,lazyBehavior:c,unstable__animationState:d}=n,f=Au(),m=oc({preventDefault:g=>g.key!==" "&&Qr(g.target)}),b=v.useCallback(g=>{if(!g.currentTarget.contains(g.target))return;const y=g.key,k={Tab:C=>C.preventDefault(),Escape:i,ArrowDown:()=>{const C=f.nextEnabled(r);C&&o(C.index)},ArrowUp:()=>{const C=f.prevEnabled(r);C&&o(C.index)}}[y];if(k){g.preventDefault(),k(g);return}const E=m(C=>{const x=sc(f.values(),C,I=>{var D,P;return(P=(D=I==null?void 0:I.node)==null?void 0:D.textContent)!=null?P:""},f.item(r));if(x){const I=f.indexOf(x.node);o(I)}});Qr(g.target)&&E(g)},[f,r,m,i,o]),h=v.useRef(!1);a&&(h.current=!0);const w=rs({wasSelected:h.current,enabled:u,mode:c,isSelected:d.present});return{...t,ref:_e(s,e),children:w?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:le(t.onKeyDown,b)}}function Wu(t={}){const{popper:e,isOpen:n}=Sn();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function Ba(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:a,isDisabled:i,isFocusable:l,closeOnSelect:u,type:c,...d}=t,f=Sn(),{setFocusedIndex:m,focusedIndex:b,closeOnSelect:h,onClose:w,menuRef:g,isOpen:y,menuId:_,rafId:k}=f,E=v.useRef(null),C=`${_}-menuitem-${v.useId()}`,{index:x,register:I}=Mu({disabled:i&&!l}),D=v.useCallback(O=>{n==null||n(O),!i&&m(x)},[m,x,i,n]),P=v.useCallback(O=>{r==null||r(O),E.current&&!Ks(E.current)&&D(O)},[D,r]),N=v.useCallback(O=>{o==null||o(O),!i&&m(-1)},[m,i,o]),K=v.useCallback(O=>{s==null||s(O),Qr(O.currentTarget)&&(u??h)&&w()},[w,s,h,u]),T=v.useCallback(O=>{a==null||a(O),m(x)},[m,a,x]),B=x===b,Z=i&&!l;gr(()=>{if(y)return B&&!Z&&E.current?(k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(()=>{var O;(O=E.current)==null||O.focus({preventScroll:!0}),k.current=null})):g.current&&!Ks(g.current)&&g.current.focus({preventScroll:!0}),()=>{k.current&&cancelAnimationFrame(k.current)}},[B,Z,g,y]);const $=Ea({onClick:K,onFocus:T,onMouseEnter:D,onMouseMove:P,onMouseLeave:N,ref:_e(I,E,e),isDisabled:i,isFocusable:l});return{...d,...$,type:c??$.type,id:C,role:"menuitem",tabIndex:B?0:-1}}function Ph(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...Ba(o,e),role:`menuitem${n}`,"aria-checked":r}}function jh(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...a}=t,l=n==="radio"?"":[],[u,c]=fa({defaultValue:o??l,value:r,onChange:s}),d=v.useCallback(b=>{if(n==="radio"&&typeof u=="string"&&c(b),n==="checkbox"&&Array.isArray(u)){const h=u.includes(b)?u.filter(w=>w!==b):u.concat(b);c(h)}},[u,c,n]),m=Ho(e).map(b=>{if(b.type.id!=="MenuItemOption")return b;const h=g=>{var y,_;d(b.props.value),(_=(y=b.props).onClick)==null||_.call(y,g)},w=n==="radio"?b.props.value===u:u.includes(b.props.value);return v.cloneElement(b,{type:n,onClick:h,isChecked:w})});return{...a,children:m}}function Ku(t){var e;if(!$u(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function $u(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Uu,Cr]=$e({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),os=t=>{const{children:e}=t,n=St("Menu",t),r=Le(t),{direction:o}=To(),{descendants:s,...a}=Lu({...r,direction:o}),i=v.useMemo(()=>a,[a]),{isOpen:l,onClose:u,forceUpdate:c}=i;return p.jsx(Nu,{value:s,children:p.jsx(Ru,{value:i,children:p.jsx(Uu,{value:n,children:aa(e,{isOpen:l,onClose:u,forceUpdate:c})})})})};os.displayName="Menu";var Wa=J((t,e)=>{const n=Cr();return p.jsx(V.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});Wa.displayName="MenuCommand";var zu=J((t,e)=>{const{type:n,...r}=t,o=Cr(),s=r.as||n?n??void 0:"button",a=v.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 p.jsx(V.button,{ref:e,type:s,...r,__css:a})}),Ka=t=>{const{className:e,children:n,...r}=t,o=Cr(),s=v.Children.only(n),a=v.isValidElement(s)?v.cloneElement(s,{focusable:"false","aria-hidden":!0,className:re("chakra-menu__icon",s.props.className)}):null,i=re("chakra-menu__icon-wrapper",e);return p.jsx(V.span,{className:i,...r,__css:o.icon,children:a})};Ka.displayName="MenuIcon";var rt=J((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:a,...i}=t,l=Ba(i,e),c=n||o?p.jsx("span",{style:{pointerEvents:"none",flex:1},children:a}):a;return p.jsxs(zu,{...l,className:re("chakra-menu__menuitem",l.className),children:[n&&p.jsx(Ka,{fontSize:"0.8em",marginEnd:r,children:n}),c,o&&p.jsx(Wa,{marginStart:s,children:o})]})});rt.displayName="MenuItem";var qu={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"}}},Vu=V(Lo.div),ss=J(function(e,n){var r,o;const{rootProps:s,motionProps:a,...i}=e,{isOpen:l,onTransitionEnd:u,unstable__animationState:c}=Sn(),d=Bu(i,n),f=Wu(s),m=Cr();return p.jsx(V.div,{...f,__css:{zIndex:(o=e.zIndex)!=null?o:(r=m.list)==null?void 0:r.zIndex},children:p.jsx(Vu,{variants:qu,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...m.list},...a,className:re("chakra-menu__menu-list",d.className),...d,onUpdate:u,onAnimationComplete:ia(c.onComplete,d.onAnimationComplete)})})});ss.displayName="MenuList";var[Hu,Xt]=$e({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[Ju,Er]=$e({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function $a(t){const e=v.Children.only(t.children),{getTriggerProps:n}=Xt();return v.cloneElement(e,n(e.props,e.ref))}$a.displayName="PopoverTrigger";var Mt={click:"click",hover:"hover"};function Gu(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:a=!0,arrowSize:i,arrowShadowColor:l,trigger:u=Mt.click,openDelay:c=200,closeDelay:d=200,isLazy:f,lazyBehavior:m="unmount",computePositionOnMount:b,...h}=t,{isOpen:w,onClose:g,onOpen:y,onToggle:_}=ns(t),k=v.useRef(null),E=v.useRef(null),C=v.useRef(null),x=v.useRef(!1),I=v.useRef(!1);w&&(I.current=!0);const[D,P]=v.useState(!1),[N,K]=v.useState(!1),T=v.useId(),B=o??T,[Z,$,O,H]=["popover-trigger","popover-content","popover-header","popover-body"].map(Y=>`${Y}-${B}`),{referenceRef:G,getArrowProps:de,getPopperProps:j,getArrowInnerProps:R,forceUpdate:F}=ts({...h,enabled:w||!!b}),W=Ta({isOpen:w,ref:C});Wl({enabled:w,ref:E}),Da(C,{focusRef:E,visible:w,shouldFocus:s&&u===Mt.click}),cc(C,{focusRef:r,visible:w,shouldFocus:a&&u===Mt.click});const U=rs({wasSelected:I.current,enabled:f,mode:m,isSelected:W.present}),q=v.useCallback((Y={},Se=null)=>{const ve={...Y,style:{...Y.style,transformOrigin:fe.transformOrigin.varRef,[fe.arrowSize.var]:i?`${i}px`:void 0,[fe.arrowShadowColor.var]:l},ref:_e(C,Se),children:U?Y.children:null,id:$,tabIndex:-1,role:"dialog",onKeyDown:le(Y.onKeyDown,Be=>{n&&Be.key==="Escape"&&g()}),onBlur:le(Y.onBlur,Be=>{const Nt=$s(Be),We=Rr(C.current,Nt),At=Rr(E.current,Nt);w&&e&&(!We&&!At)&&g()}),"aria-labelledby":D?O:void 0,"aria-describedby":N?H:void 0};return u===Mt.hover&&(ve.role="tooltip",ve.onMouseEnter=le(Y.onMouseEnter,()=>{x.current=!0}),ve.onMouseLeave=le(Y.onMouseLeave,Be=>{Be.nativeEvent.relatedTarget!==null&&(x.current=!1,setTimeout(()=>g(),d))})),ve},[U,$,D,O,N,H,u,n,g,w,e,d,l,i]),te=v.useCallback((Y={},Se=null)=>j({...Y,style:{visibility:w?"visible":"hidden",...Y.style}},Se),[w,j]),oe=v.useCallback((Y,Se=null)=>({...Y,ref:_e(Se,k,G)}),[k,G]),ie=v.useRef(),be=v.useRef(),Ee=v.useCallback(Y=>{k.current==null&&G(Y)},[G]),Q=v.useCallback((Y={},Se=null)=>{const ve={...Y,ref:_e(E,Se,Ee),id:Z,"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":$};return u===Mt.click&&(ve.onClick=le(Y.onClick,_)),u===Mt.hover&&(ve.onFocus=le(Y.onFocus,()=>{ie.current===void 0&&y()}),ve.onBlur=le(Y.onBlur,Be=>{const Nt=$s(Be),We=!Rr(C.current,Nt);w&&e&&We&&g()}),ve.onKeyDown=le(Y.onKeyDown,Be=>{Be.key==="Escape"&&g()}),ve.onMouseEnter=le(Y.onMouseEnter,()=>{x.current=!0,ie.current=window.setTimeout(()=>y(),c)}),ve.onMouseLeave=le(Y.onMouseLeave,()=>{x.current=!1,ie.current&&(clearTimeout(ie.current),ie.current=void 0),be.current=window.setTimeout(()=>{x.current===!1&&g()},d)})),ve},[Z,w,$,u,Ee,_,y,e,g,c,d]);v.useEffect(()=>()=>{ie.current&&clearTimeout(ie.current),be.current&&clearTimeout(be.current)},[]);const me=v.useCallback((Y={},Se=null)=>({...Y,id:O,ref:_e(Se,ve=>{P(!!ve)})}),[O]),jt=v.useCallback((Y={},Se=null)=>({...Y,id:H,ref:_e(Se,ve=>{K(!!ve)})}),[H]);return{forceUpdate:F,isOpen:w,onAnimationComplete:W.onComplete,onClose:g,getAnchorProps:oe,getArrowProps:de,getArrowInnerProps:R,getPopoverPositionerProps:te,getPopoverProps:q,getTriggerProps:Q,getHeaderProps:me,getBodyProps:jt}}function Rr(t,e){return t===e||(t==null?void 0:t.contains(e))}function $s(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function Ua(t){const e=St("Popover",t),{children:n,...r}=Le(t),o=To(),s=Gu({...r,direction:o.direction});return p.jsx(Hu,{value:s,children:p.jsx(Ju,{value:e,children:aa(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}Ua.displayName="Popover";var Tr=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function za(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:a,shadowColor:i}=t,{getArrowProps:l,getArrowInnerProps:u}=Xt(),c=Er(),d=(e=n??r)!=null?e:o,f=s??a;return p.jsx(V.div,{...l(),className:"chakra-popover__arrow-positioner",children:p.jsx(V.div,{className:re("chakra-popover__arrow",t.className),...u(t),__css:{"--popper-arrow-shadow-color":Tr("colors",i),"--popper-arrow-bg":Tr("colors",d),"--popper-arrow-shadow":Tr("shadows",f),...c.arrow}})})}za.displayName="PopoverArrow";var qa=J(function(e,n){const{getBodyProps:r}=Xt(),o=Er();return p.jsx(V.div,{...r(e,n),className:re("chakra-popover__body",e.className),__css:o.body})});qa.displayName="PopoverBody";var Va=J(function(e,n){const{onClose:r}=Xt(),o=Er();return p.jsx(ol,{size:"sm",onClick:r,className:re("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});Va.displayName="PopoverCloseButton";function Yu(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var Xu={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]}}},Zu=V(Lo.section),Ha=J(function(e,n){const{variants:r=Xu,...o}=e,{isOpen:s}=Xt();return p.jsx(Zu,{ref:n,variants:Yu(r),initial:!1,animate:s?"enter":"exit",...o})});Ha.displayName="PopoverTransition";var Ja=J(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:a,getPopoverPositionerProps:i,onAnimationComplete:l}=Xt(),u=Er(),c={position:"relative",display:"flex",flexDirection:"column",...u.content};return p.jsx(V.div,{...i(r),__css:u.popper,className:"chakra-popover__popper",children:p.jsx(Ha,{...o,...a(s,n),onAnimationComplete:ia(l,s.onAnimationComplete),className:re("chakra-popover__content",e.className),__css:c})})});Ja.displayName="PopoverContent";var[Qu,ed,td,nd]=da();function rd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:a,lazyBehavior:i="unmount",orientation:l="horizontal",direction:u="ltr",...c}=t,[d,f]=v.useState(n??0),[m,b]=fa({defaultValue:n??0,value:o,onChange:r});v.useEffect(()=>{o!=null&&f(o)},[o]);const h=td(),w=v.useId();return{id:`tabs-${(e=t.id)!=null?e:w}`,selectedIndex:m,focusedIndex:d,setSelectedIndex:b,setFocusedIndex:f,isManual:s,isLazy:a,lazyBehavior:i,orientation:l,descendants:h,direction:u,htmlProps:c}}var[od,Dr]=$e({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function sd(t){const{focusedIndex:e,orientation:n,direction:r}=Dr(),o=ed(),s=v.useCallback(a=>{const i=()=>{var y;const _=o.nextEnabled(e);_&&((y=_.node)==null||y.focus())},l=()=>{var y;const _=o.prevEnabled(e);_&&((y=_.node)==null||y.focus())},u=()=>{var y;const _=o.firstEnabled();_&&((y=_.node)==null||y.focus())},c=()=>{var y;const _=o.lastEnabled();_&&((y=_.node)==null||y.focus())},d=n==="horizontal",f=n==="vertical",m=a.key,b=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",g={[b]:()=>d&&l(),[h]:()=>d&&i(),ArrowDown:()=>f&&i(),ArrowUp:()=>f&&l(),Home:u,End:c}[m];g&&(a.preventDefault(),g(a))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:le(t.onKeyDown,s)}}function ad(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:a,setFocusedIndex:i,selectedIndex:l}=Dr(),{index:u,register:c}=nd({disabled:e&&!n}),d=u===l,f=()=>{o(u)},m=()=>{i(u),!s&&!(e&&n)&&o(u)},b=Ea({...r,ref:_e(c,t.ref),isDisabled:e,isFocusable:n,onClick:le(t.onClick,f)}),h="button";return{...b,id:Ga(a,u),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":Ya(a,u),onFocus:e?void 0:le(t.onFocus,m)}}var[id,ld]=$e({});function cd(t){const e=Dr(),{id:n,selectedIndex:r}=e,s=Ho(t.children).map((a,i)=>v.createElement(id,{key:i,value:{isSelected:i===r,id:Ya(n,i),tabId:Ga(n,i),selectedIndex:r}},a));return{...t,children:s}}function ud(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Dr(),{isSelected:s,id:a,tabId:i}=ld(),l=v.useRef(!1);s&&(l.current=!0);const u=rs({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:u?e:null,role:"tabpanel","aria-labelledby":i,hidden:!s,id:a}}function Ga(t,e){return`${t}--tab-${e}`}function Ya(t,e){return`${t}--tabpanel-${e}`}var[dd,Ir]=$e({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Xa=J(function(e,n){const r=St("Tabs",e),{children:o,className:s,...a}=Le(e),{htmlProps:i,descendants:l,...u}=rd(a),c=v.useMemo(()=>u,[u]),{isFitted:d,...f}=i,m={position:"relative",...r.root};return p.jsx(Qu,{value:l,children:p.jsx(od,{value:c,children:p.jsx(dd,{value:r,children:p.jsx(V.div,{className:re("chakra-tabs",s),ref:n,...f,__css:m,children:o})})})})});Xa.displayName="Tabs";var Za=J(function(e,n){const r=sd({...e,ref:n}),s={display:"flex",...Ir().tablist};return p.jsx(V.div,{...r,className:re("chakra-tabs__tablist",e.className),__css:s})});Za.displayName="TabList";var eo=J(function(e,n){const r=ud({...e,ref:n}),o=Ir();return p.jsx(V.div,{outline:"0",...r,className:re("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});eo.displayName="TabPanel";var Qa=J(function(e,n){const r=cd(e),o=Ir();return p.jsx(V.div,{...r,width:"100%",ref:n,className:re("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});Qa.displayName="TabPanels";var to=J(function(e,n){const r=Ir(),o=ad({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return p.jsx(V.button,{...o,className:re("chakra-tabs__tab",e.className),__css:s})});to.displayName="Tab";var fd={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]}}}},no=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},zn=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function hd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:a=o,closeOnEsc:i=!0,onOpen:l,onClose:u,placement:c,id:d,isOpen:f,defaultIsOpen:m,arrowSize:b=10,arrowShadowColor:h,arrowPadding:w,modifiers:g,isDisabled:y,gutter:_,offset:k,direction:E,...C}=t,{isOpen:x,onOpen:I,onClose:D}=ns({isOpen:f,defaultIsOpen:m,onOpen:l,onClose:u}),{referenceRef:P,getPopperProps:N,getArrowInnerProps:K,getArrowProps:T}=ts({enabled:x,placement:c,arrowPadding:w,modifiers:g,gutter:_,offset:k,direction:E}),B=v.useId(),$=`tooltip-${d??B}`,O=v.useRef(null),H=v.useRef(),G=v.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=void 0)},[]),de=v.useRef(),j=v.useCallback(()=>{de.current&&(clearTimeout(de.current),de.current=void 0)},[]),R=v.useCallback(()=>{j(),D()},[D,j]),F=pd(O,R),W=v.useCallback(()=>{if(!y&&!H.current){x&&F();const Q=zn(O);H.current=Q.setTimeout(I,e)}},[F,y,x,I,e]),U=v.useCallback(()=>{G();const Q=zn(O);de.current=Q.setTimeout(R,n)},[n,R,G]),q=v.useCallback(()=>{x&&r&&U()},[r,U,x]),te=v.useCallback(()=>{x&&a&&U()},[a,U,x]),oe=v.useCallback(Q=>{x&&Q.key==="Escape"&&U()},[x,U]);Bt(()=>no(O),"keydown",i?oe:void 0),Bt(()=>{if(!s)return null;const Q=O.current;if(!Q)return null;const me=ba(Q);return me.localName==="body"?zn(O):me},"scroll",()=>{x&&s&&R()},{passive:!0,capture:!0}),v.useEffect(()=>{y&&(G(),x&&D())},[y,x,D,G]),v.useEffect(()=>()=>{G(),j()},[G,j]),Bt(()=>O.current,"pointerleave",U);const ie=v.useCallback((Q={},me=null)=>({...Q,ref:_e(O,me,P),onPointerEnter:le(Q.onPointerEnter,Y=>{Y.pointerType!=="touch"&&W()}),onClick:le(Q.onClick,q),onPointerDown:le(Q.onPointerDown,te),onFocus:le(Q.onFocus,W),onBlur:le(Q.onBlur,U),"aria-describedby":x?$:void 0}),[W,U,te,x,$,q,P]),be=v.useCallback((Q={},me=null)=>N({...Q,style:{...Q.style,[fe.arrowSize.var]:b?`${b}px`:void 0,[fe.arrowShadowColor.var]:h}},me),[N,b,h]),Ee=v.useCallback((Q={},me=null)=>{const jt={...Q.style,position:"relative",transformOrigin:fe.transformOrigin.varRef};return{ref:me,...C,...Q,id:$,role:"tooltip",style:jt}},[C,$]);return{isOpen:x,show:W,hide:U,getTriggerProps:ie,getTooltipProps:Ee,getTooltipPositionerProps:be,getArrowProps:T,getArrowInnerProps:K}}var Lr="chakra-ui:close-tooltip";function pd(t,e){return v.useEffect(()=>{const n=no(t);return n.addEventListener(Lr,e),()=>n.removeEventListener(Lr,e)},[e,t]),()=>{const n=no(t),r=zn(t);n.dispatchEvent(new r.CustomEvent(Lr))}}function md(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function vd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var yd=V(Lo.div),bt=J((t,e)=>{var n,r;const o=Cn("Tooltip",t),s=Le(t),a=To(),{children:i,label:l,shouldWrapChildren:u,"aria-label":c,hasArrow:d,bg:f,portalProps:m,background:b,backgroundColor:h,bgColor:w,motionProps:g,...y}=s,_=(r=(n=b??h)!=null?n:f)!=null?r:w;if(_){o.bg=_;const N=sl(a,"colors",_);o[fe.arrowBg.var]=N}const k=hd({...y,direction:a.direction}),E=typeof i=="string"||u;let C;if(E)C=p.jsx(V.span,{display:"inline-block",tabIndex:0,...k.getTriggerProps(),children:i});else{const N=v.Children.only(i);C=v.cloneElement(N,k.getTriggerProps(N.props,N.ref))}const x=!!c,I=k.getTooltipProps({},e),D=x?md(I,["role","id"]):I,P=vd(I,["role","id"]);return l?p.jsxs(p.Fragment,{children:[C,p.jsx(al,{children:k.isOpen&&p.jsx(la,{...m,children:p.jsx(V.div,{...k.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:p.jsxs(yd,{variants:fd,initial:"exit",animate:"enter",exit:"exit",...g,...D,__css:o,children:[l,x&&p.jsx(V.span,{srOnly:!0,...P,children:c}),d&&p.jsx(V.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:p.jsx(V.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):p.jsx(p.Fragment,{children:i})});bt.displayName="Tooltip";let An;const gd=new Uint8Array(16);function wd(){if(!An&&(An=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!An))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return An(gd)}const we=[];for(let t=0;t<256;++t)we.push((t+256).toString(16).slice(1));function bd(t,e=0){return we[t[e+0]]+we[t[e+1]]+we[t[e+2]]+we[t[e+3]]+"-"+we[t[e+4]]+we[t[e+5]]+"-"+we[t[e+6]]+we[t[e+7]]+"-"+we[t[e+8]]+we[t[e+9]]+"-"+we[t[e+10]]+we[t[e+11]]+we[t[e+12]]+we[t[e+13]]+we[t[e+14]]+we[t[e+15]]}const xd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Us={randomUUID:xd};function Jt(t,e,n){if(Us.randomUUID&&!e&&!t)return Us.randomUUID();t=t||{};const r=t.random||(t.rng||wd)();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 bd(r)}async function _d(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 kd(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 ei(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 ti(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 Cd(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 Nh(){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 Ed(t,e){try{return await(await fetch("/workspace/scan_local_new_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,existFlowIds:e})})).json()}catch(n){console.error("Error scan local new files:",n)}}async function Ah(){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 Fh(){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 Dd(t){try{return await(await fetch("/workspace/delete_folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_path:t})})).text()}catch(e){console.error("Error move file:",e)}}const Id="backup",nr="workspace";let Fn=null;function Sd(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(nr)||o.createObjectStore(nr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Od(){try{return Fn==null&&(Fn=await Sd()),new Promise((t,e)=>{if(Fn==null)return e("indexDB is null");const o=Fn.transaction([nr],"readonly").objectStore(nr).get(Id);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 Pd(){try{return await Od()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const se=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,he=Object.keys,Ce=Array.isArray;function Ie(t,e){return typeof e!="object"||he(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||se.Promise||(se.Promise=Promise);const yn=Object.getPrototypeOf,jd={}.hasOwnProperty;function Fe(t,e){return jd.call(t,e)}function Gt(t,e){typeof e=="function"&&(e=e(yn(t))),(typeof Reflect>"u"?he:Reflect.ownKeys)(e).forEach(n=>{Qe(t,n,e[n])})}const ni=Object.defineProperty;function Qe(t,e,n,r){ni(t,e,Ie(n&&Fe(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Wt(t){return{from:function(e){return t.prototype=Object.create(e.prototype),Qe(t.prototype,"constructor",t),{extend:Gt.bind(null,t.prototype)}}}}const Nd=Object.getOwnPropertyDescriptor;function as(t,e){let n;return Nd(t,e)||(n=yn(t))&&as(n,e)}const Ad=[].slice;function rr(t,e,n){return Ad.call(t,e,n)}function ri(t,e){return e(t)}function rn(t){if(!t)throw new Error("Assertion Failed")}function oi(t){se.setImmediate?setImmediate(t):setTimeout(t,0)}function si(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function et(t,e){if(Fe(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=>se[t]),Md=li.map(t=>se[t]);si(li,t=>[t,!0]);let st=null;function On(t){st=typeof WeakMap<"u"&&new WeakMap;const e=ro(t);return st=null,e}function ro(t){if(!t||typeof t!="object")return t;let e=st&&st.get(t);if(e)return e;if(Ce(t)){e=[],st&&st.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=yn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),st&&st.set(t,e),t)Fe(t,o)&&(e[o]=ro(t[o]))}return e}const{toString:Rd}={};function oo(t){return Rd.call(t).slice(8,-1)}const so=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Td=typeof so=="symbol"?function(t){var e;return t!=null&&(e=t[so])&&e.apply(t)}:function(){return null},Lt={};function Xe(t){var e,n,r,o;if(arguments.length===1){if(Ce(t))return t.slice();if(this===Lt&&typeof t=="string")return[t];if(o=Td(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 is=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var Je=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ci(t,e){Je=t,ui=e}var ui=()=>!0;const Ld=!new Error("").stack;function Ot(){if(Ld)try{throw Ot.arguments,new Error}catch(t){return t}return new Error}function ao(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(ui).map(r=>` -`+r).join("")):""}var di=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],ls=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(di),Bd={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 Kt(t,e){this._e=Ot(),this.name=t,this.message=e}function fi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function or(t,e,n,r){this._e=Ot(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=fi(t,e)}function un(t,e){this._e=Ot(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=fi(t,e)}Wt(Kt).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ao(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Wt(or).from(Kt),Wt(un).from(Kt);var cs=ls.reduce((t,e)=>(t[e]=e+"Error",t),{});const Wd=Kt;var L=ls.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Ot(),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=Bd[e]||n,this.inner=null)}return Wt(r).from(Wd),t[e]=r,t},{});L.Syntax=SyntaxError,L.Type=TypeError,L.Range=RangeError;var zs=di.reduce((t,e)=>(t[e+"Error"]=L[e],t),{}),qn=ls.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=L[e]),t),{});function ne(){}function gn(t){return t}function Kd(t,e){return t==null||t===gn?e:function(n){return e(t(n))}}function Dt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function $d(t,e){return t===ne?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?Dt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?Dt(o,this.onerror):o),s!==void 0?s:n}}function Ud(t,e){return t===ne?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?Dt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Dt(r,this.onerror):r)}}function zd(t,e){return t===ne?e:function(n){var r=t.apply(this,arguments);Ie(n,r);var o=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?Dt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?Dt(s,this.onerror):s),r===void 0?a===void 0?void 0:a:Ie(r,a)}}function qd(t,e){return t===ne?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function us(t,e){return t===ne?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)}}qn.ModifyError=or,qn.DexieError=Kt,qn.BulkError=un;var wn={};const hi=100,[io,sr,lo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,yn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,yn(e),t]})(),pi=sr&&sr.then,Vn=io&&io.constructor,ds=!!lo;var co=!1,Vd=lo?()=>{lo.then(Mn)}:se.setImmediate?setImmediate.bind(null,Mn):se.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Mn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Mn,0)},dn=function(t,e){on.push([t,e]),ar&&(Vd(),ar=!1)},uo=!0,ar=!0,xt=[],Hn=[],fo=null,ho=gn,$t={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Hs,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Hs(t[0],t[1])}catch{}})}},M=$t,on=[],_t=0,Jn=[];function A(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ne,this._lib=!1;var e=this._PSD=M;if(Je&&(this._stackHolder=Ot(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==wn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&mo(this,this._value))}this._state=null,this._value=null,++e.ref,vi(this,t)}const po={get:function(){var t=M,e=ir;function n(r,o){var s=!t.global&&(t!==M||e!==ir);const a=s&&!nt();var i=new A((l,u)=>{fs(this,new mi(lr(r,t,s,a),lr(o,t,s,a),l,u,t))});return Je&&wi(i,this),i}return n.prototype=wn,n},set:function(t){Qe(this,"then",t&&t.prototype===wn?po:{get:function(){return t},set:po.set})}};function mi(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 vi(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&&Pn();n&&typeof n.then=="function"?vi(t,(o,s)=>{n instanceof A?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,yi(t)),r&&jn()}},mo.bind(null,t))}catch(n){mo(t,n)}}function mo(t,e){if(Hn.push(e),t._state===null){var n=t._lib&&Pn();e=ho(e),t._state=!1,t._value=e,Je&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(a){o&&o(a)}}(()=>{var r=as(e,"stack");e._promise=t,Qe(e,"stack",{get:()=>co?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){xt.some(o=>o._value===r._value)||xt.push(r)}(t),yi(t),n&&jn()}}function yi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--_t==0&&hs()},[]))}function fs(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++_t,dn(Hd,[n,t,e])}else t._listeners.push(e)}function Hd(t,e,n){try{fo=e;var r,o=e._value;e._state?r=t(o):(Hn.length&&(Hn=[]),r=t(o),Hn.indexOf(o)===-1&&function(s){for(var a=xt.length;a;)if(xt[--a]._value===s._value)return void xt.splice(a,1)}(e)),n.resolve(r)}catch(s){n.reject(s)}finally{fo=null,--_t==0&&hs(),--n.psd.ref||n.psd.finalize()}}function gi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,s,a=t._value;a!=null?(o=a.name||"Error",s=a.message||a,r=ao(a,0)):(o=a,s=""),e.push(o+(s?": "+s:"")+r)}return Je&&((r=ao(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&gi(t._prev,e,n)),e}function wi(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Mn(){Pn()&&jn()}function Pn(){var t=uo;return uo=!1,ar=!1,t}function jn(){var t,e,n;do for(;on.length>0;)for(t=on,on=[],n=t.length,e=0;e0);uo=!0,ar=!0}function hs(){var t=xt;xt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=Jn.slice(0),n=e.length;n;)e[--n]()}function Rn(t){return new A(wn,!1,t)}function ae(t,e){var n=M;return function(){var r=Pn(),o=M;try{return ct(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{ct(o,!1),r&&jn()}}}Gt(A.prototype,{then:po,_then:function(t,e){fs(this,new mi(null,null,t,e,M))},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):Rn(r)):this.then(null,r=>r&&r.name===e?n(r):Rn(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Rn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{co=!0;var t=gi(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{co=!1}}},timeout:function(t,e){return t<1/0?new A((n,r)=>{var o=setTimeout(()=>r(new L.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&Qe(A.prototype,Symbol.toStringTag,"Dexie.Promise"),$t.env=bi(),Gt(A,{all:function(){var t=Xe.apply(null,arguments).map(Tn);return new A(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>A.resolve(o).then(a=>{t[s]=a,--r||e(t)},n))})},resolve:t=>{if(t instanceof A)return t;if(t&&typeof t.then=="function")return new A((n,r)=>{t.then(n,r)});var e=new A(wn,!0,t);return wi(e,fo),e},reject:Rn,race:function(){var t=Xe.apply(null,arguments).map(Tn);return new A((e,n)=>{t.map(r=>A.resolve(r).then(e,n))})},PSD:{get:()=>M,set:t=>M=t},totalEchoes:{get:()=>ir},newPSD:lt,usePSD:Qt,scheduler:{get:()=>dn,set:t=>{dn=t}},rejectionMapper:{get:()=>ho,set:t=>{ho=t}},follow:(t,e)=>new A((n,r)=>lt((o,s)=>{var a=M;a.unhandleds=[],a.onunhandled=s,a.finalize=Dt(function(){(function(i){function l(){i(),Jn.splice(Jn.indexOf(l),1)}Jn.push(l),++_t,dn(()=>{--_t==0&&hs()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},a.finalize),t()},e,n,r))}),Vn&&(Vn.allSettled&&Qe(A,"allSettled",function(){const t=Xe.apply(null,arguments).map(Tn);return new A(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>A.resolve(o).then(a=>r[s]={status:"fulfilled",value:a},a=>r[s]={status:"rejected",reason:a}).then(()=>--n||e(r)))})}),Vn.any&&typeof AggregateError<"u"&&Qe(A,"any",function(){const t=Xe.apply(null,arguments).map(Tn);return new A((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,a)=>A.resolve(s).then(i=>e(i),i=>{o[a]=i,--r||n(new AggregateError(o))}))})}));const ke={awaits:0,echoes:0,id:0};var Jd=0,Gn=[],Br=0,ir=0,Gd=0;function lt(t,e,n,r){var o=M,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++Gd;var a=$t.env;s.env=ds?{Promise:A,PromiseProp:{value:A,configurable:!0,writable:!0},all:A.all,race:A.race,allSettled:A.allSettled,any:A.any,resolve:A.resolve,reject:A.reject,nthen:qs(a.nthen,s),gthen:qs(a.gthen,s)}:{},e&&Ie(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var i=Qt(s,t,n,r);return s.ref===0&&s.finalize(),i}function Zt(){return ke.id||(ke.id=++Jd),++ke.awaits,ke.echoes+=hi,ke.id}function nt(){return!!ke.awaits&&(--ke.awaits==0&&(ke.id=0),ke.echoes=ke.awaits*hi,!0)}function Tn(t){return ke.echoes&&t&&t.constructor===Vn?(Zt(),t.then(e=>(nt(),e),e=>(nt(),ge(e)))):t}function Yd(t){++ir,ke.echoes&&--ke.echoes!=0||(ke.echoes=ke.id=0),Gn.push(M),ct(t,!0)}function Xd(){var t=Gn[Gn.length-1];Gn.pop(),ct(t,!1)}function ct(t,e){var n=M;if((e?!ke.echoes||Br++&&t===M:!Br||--Br&&t===M)||xi(e?Yd.bind(null,t):Xd),t!==M&&(M=t,n===$t&&($t.env=bi()),ds)){var r=$t.env.Promise,o=t.env;sr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(se,"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 bi(){var t=se.Promise;return ds?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(se,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:sr.then,gthen:t.prototype.then}:{}}function Qt(t,e,n,r,o){var s=M;try{return ct(t,!0),e(n,r,o)}finally{ct(s,!1)}}function xi(t){pi.call(io,t)}function lr(t,e,n,r){return typeof t!="function"?t:function(){var o=M;n&&Zt(),ct(e,!0);try{return t.apply(this,arguments)}finally{ct(o,!1),r&&xi(nt)}}}function qs(t,e){return function(n,r){return t.call(this,lr(n,e),lr(r,e))}}(""+pi).indexOf("[native code]")===-1&&(Zt=nt=ne);const Vs="unhandledrejection";function Hs(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(se.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Vs,!0,!0),Ie(r,o)):se.CustomEvent&&Ie(r=new CustomEvent(Vs,{detail:o}),o),r&&se.dispatchEvent&&(dispatchEvent(r),!se.PromiseRejectionEvent&&se.onunhandledrejection))try{se.onunhandledrejection(r)}catch{}Je&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var ge=A.reject;function vo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||M.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===cs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>vo(t,e,n,r))):ge(s)}return o._promise(e,(s,a)=>lt(()=>(M.trans=o,r(s,a,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return ge(new L.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return ge(new L.DatabaseClosed);t.open().catch(ne)}return t._state.dbReadyPromise.then(()=>vo(t,e,n,r))}const Js="3.2.4",vt="￿",yo=-1/0,Ge="Invalid key provided. Keys must be of type string, number, Date or Array.",_i="String expected.",fn=[],Sr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Zd=Sr,Qd=Sr,ki=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Or="__dbnames",Wr="readonly",Kr="readwrite";function It(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Ci={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ln(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=On(e))[t],e)}class ef{_trans(e,n,r){const o=this._tx||M.trans,s=this.name;function a(l,u,c){if(!c.schema[s])throw new L.NotFound("Table "+s+" not part of transaction");return n(c.idbtrans,c)}const i=Pn();try{return o&&o.db===this.db?o===M.trans?o._promise(e,a,r):lt(()=>o._promise(e,a,r),{trans:o,transless:M.transless||M}):vo(this.db,e,[this.name],a)}finally{i&&jn()}}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(Ce(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=he(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!==vt)return this.where(r.name).equals(r.keyPath.map(u=>e[u]));!r&&Je&&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 a(u,c){try{return s.cmp(u,c)===0}catch{return!1}}const[i,l]=n.reduce(([u,c],d)=>{const f=o[d],m=e[d];return[u||f,u||!f?It(c,f&&f.multi?b=>{const h=et(b,d);return Ce(h)&&h.some(w=>a(m,w))}:b=>a(m,et(b,d))):c]},[null,null]);return i?this.where(i.name).equals(e[i.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,Ce(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(Fe(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){Ie(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=Ln(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"add",keys:n!=null?[n]:null,values:[s]})).then(a=>a.numFailures?A.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{Ke(e,o,a)}catch{}return a})}update(e,n){if(typeof e!="object"||Ce(e))return this.where(":id").equals(e).modify(n);{const r=et(e,this.schema.primKey.keyPath);if(r===void 0)return ge(new L.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?he(n).forEach(o=>{Ke(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=Ln(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"put",values:[s],keys:n!=null?[n]:null})).then(a=>a.numFailures?A.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{Ke(e,o,a)}catch{}return a})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?A.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Ci})).then(e=>e.numFailures?A.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",a=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new L.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&i?e.map(Ln(l)):e;return this.core.mutate({trans:a,type:"add",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:m,failures:b})=>{if(d===0)return s?f:m;throw new un(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,b)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,s=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",a=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new L.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");const u=e.length;let c=l&&i?e.map(Ln(l)):e;return this.core.mutate({trans:a,type:"put",keys:o,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:m,failures:b})=>{if(d===0)return s?f:m;throw new un(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,b)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:o,failures:s})=>{if(r===0)return o;throw new un(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function hn(t){var e={},n=function(a,i){if(i){for(var l=arguments.length,u=new Array(l-1);--l;)u[l-1]=arguments[l];return e[a].subscribe.apply(null,u),t}if(typeof a=="string")return e[a]};n.addEventType=s;for(var r=1,o=arguments.length;rIt(r(),e()):e,t.justLimit=n&&!r}function Yn(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new L.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function Gs(t,e,n){const r=Yn(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 Bn(t,e,n,r){const o=t.replayFilter?It(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},a=(i,l,u)=>{if(!o||o(l,u,f=>l.stop(f),f=>l.fail(f))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Fe(s,d)||(s[d]=!0,e(i,l,u))}};return Promise.all([t.or._iterate(a,n),Ys(Gs(t,r,n),t.algorithm,a,!t.keysOnly&&t.valueMapper)])}return Ys(Gs(t,r,n),It(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function Ys(t,e,n,r){var o=ae(r?(s,a,i)=>n(r(s),a,i):n);return t.then(s=>{if(s)return s.start(()=>{var a=()=>s.continue();e&&!e(s,i=>a=i,i=>{s.stop(i),a=ne},i=>{s.fail(i),a=ne})||o(s.value,s,i=>a=i),a()})})}function De(t,e){try{const n=Xs(t),r=Xs(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:tBn(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Rt(r,!0))return o.count({trans:n,query:{index:Yn(r,o.schema),range:r.range}}).then(a=>Math.min(a,r.limit));var s=0;return Bn(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 a(u,c){return c?a(u[r[c]],c-1):u[o]}var i=this._ctx.dir==="next"?1:-1;function l(u,c){var d=a(u,s),f=a(c,s);return df?i: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"&&Rt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=Yn(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:a})=>o?a.map(o):a)}{const o=[];return Bn(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Rt(n)?Ur(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):Ur(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ur(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return $r(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 $r(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=It(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"&&Rt(n,!0)&&n.limit>0)return this._read(o=>{var s=Yn(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 $r(this._ctx,function(o){var s=o.primaryKey.toString(),a=Fe(r,s);return r[s]=!0,!a}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var s=he(e),a=s.length;o=function(h){for(var w=!1,g=0;g{const{failures:g,numFailures:y}=w;f+=h-y;for(let _ of he(g))d.push(g[_])};return this.clone().primaryKeys().then(h=>{const w=g=>{const y=Math.min(c,h.length-g);return i.getMany({trans:r,keys:h.slice(g,g+y),cache:"immutable"}).then(_=>{const k=[],E=[],C=l?[]:null,x=[];for(let D=0;D0&&i.mutate({trans:r,type:"add",values:k}).then(D=>{for(let P in D.failures)x.splice(parseInt(P),1);b(k.length,D)})).then(()=>(E.length>0||I&&typeof e=="object")&&i.mutate({trans:r,type:"put",keys:C,values:E,criteria:I,changeSpec:typeof e!="function"&&e}).then(D=>b(E.length,D))).then(()=>(x.length>0||I&&e===zr)&&i.mutate({trans:r,type:"delete",keys:x,criteria:I}).then(D=>b(x.length,D))).then(()=>h.length>g+y&&w(g+c))})};return w(0).then(()=>{if(d.length>0)throw new or("Error modifying one or more objects",d,f,m);return h.length})})})}delete(){var e=this._ctx,n=e.range;return Rt(e)&&(e.isPrimKey&&!Qd||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(a=>e.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:i,lastResult:l,results:u,numFailures:c})=>{if(c)throw new or("Could not delete some values",Object.keys(i).map(d=>i[d]),a-c);return a-c}))}):this.modify(zr)}}const zr=(t,e)=>e.value=null;function nf(t,e){return te?-1:t===e?0:1}function Ne(t,e,n){var r=t instanceof Di?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Tt(t){return new t.Collection(t,()=>Ei("")).limit(0)}function of(t,e,n,r,o,s){for(var a=Math.min(t.length,r.length),i=-1,l=0;l=0?t.substr(0,i)+e[i]+n.substr(i+1):null;o(t[l],u)<0&&(i=l)}return atypeof h=="string"))return Ne(t,_i);function f(h){o=function(g){return g==="next"?y=>y.toUpperCase():y=>y.toLowerCase()}(h),s=function(g){return g==="next"?y=>y.toLowerCase():y=>y.toUpperCase()}(h),a=h==="next"?nf:rf;var w=n.map(function(g){return{lower:s(g),upper:o(g)}}).sort(function(g,y){return a(g.lower,y.lower)});i=w.map(function(g){return g.upper}),l=w.map(function(g){return g.lower}),u=h,c=h==="next"?"":r}f("next");var m=new t.Collection(t,()=>ot(i[0],l[d-1]+r));m._ondirectionchange=function(h){f(h)};var b=0;return m._addAlgorithm(function(h,w,g){var y=h.key;if(typeof y!="string")return!1;var _=s(y);if(e(_,l,b))return!0;for(var k=null,E=b;E0)&&(k=C)}return w(k!==null?function(){h.continue(k+c)}:g),!1}),m}function ot(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Ei(t){return{type:1,lower:t,upper:t}}class Di{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)?Tt(this):new this.Collection(this,()=>ot(e,n,!r,!o))}catch{return Ne(this,Ge)}}equals(e){return e==null?Ne(this,Ge):new this.Collection(this,()=>Ei(e))}above(e){return e==null?Ne(this,Ge):new this.Collection(this,()=>ot(e,void 0,!0))}aboveOrEqual(e){return e==null?Ne(this,Ge):new this.Collection(this,()=>ot(e,void 0,!1))}below(e){return e==null?Ne(this,Ge):new this.Collection(this,()=>ot(void 0,e,!1,!0))}belowOrEqual(e){return e==null?Ne(this,Ge):new this.Collection(this,()=>ot(void 0,e))}startsWith(e){return typeof e!="string"?Ne(this,_i):this.between(e,e+vt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):Wn(this,(n,r)=>n.indexOf(r[0])===0,[e],vt)}equalsIgnoreCase(e){return Wn(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=Xe.apply(Lt,arguments);return e.length===0?Tt(this):Wn(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=Xe.apply(Lt,arguments);return e.length===0?Tt(this):Wn(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,vt)}anyOf(){const e=Xe.apply(Lt,arguments);let n=this._cmp;try{e.sort(n)}catch{return Ne(this,Ge)}if(e.length===0)return Tt(this);const r=new this.Collection(this,()=>ot(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,a,i)=>{const l=s.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return a(i),!1;return n(l,e[o])===0||(a(()=>{s.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[yo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=Xe.apply(Lt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Ne(this,Ge)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[yo,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,a=this._min,i=this._max;if(e.length===0)return Tt(this);if(!e.every(y=>y[0]!==void 0&&y[1]!==void 0&&o(y[0],y[1])<=0))return Ne(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",L.InvalidArgument);const l=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let c,d=o;function f(y,_){return d(y[0],_[0])}try{c=e.reduce(function(y,_){let k=0,E=y.length;for(;k0){C[0]=a(C[0],_[0]),C[1]=i(C[1],_[1]);break}}return k===E&&y.push(_),y},[]),c.sort(f)}catch{return Ne(this,Ge)}let m=0;const b=u?y=>o(y,c[m][1])>0:y=>o(y,c[m][1])>=0,h=l?y=>s(y,c[m][0])>0:y=>s(y,c[m][0])>=0;let w=b;const g=new this.Collection(this,()=>ot(c[0][0],c[c.length-1][1],!l,!u));return g._ondirectionchange=y=>{y==="next"?(w=b,d=o):(w=h,d=s),c.sort(f)},g._addAlgorithm((y,_,k)=>{for(var E=y.key;w(E);)if(++m,m===c.length)return _(k),!1;return!!function(C){return!b(C)&&!h(C)}(E)||(this._cmp(E,c[m][1])===0||this._cmp(E,c[m][0])===0||_(()=>{d===o?y.continue(c[m][0]):y.continue(c[m][1])}),!1)}),g}startsWithAnyOf(){const e=Xe.apply(Lt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Tt(this):this.inAnyRange(e.map(n=>[n,n+vt])):Ne(this,"startsWithAnyOf() only works with strings")}}function ze(t){return ae(function(e){return bn(e),t(e.target.error),!1})}function bn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const xn="storagemutated",at="x-storagemutated-1",ut=hn(null,xn);class sf{_lock(){return rn(!M.global),++this._reculock,this._reculock!==1||M.global||(M.lockOwnerFor=this),this}_unlock(){if(rn(!M.global),--this._reculock==0)for(M.global||(M.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Qt(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&M.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(rn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new L.DatabaseClosed(r);case"MissingAPIError":throw new L.MissingAPI(r.message,r);default:throw new L.OpenFailed(r)}if(!this.active)throw new L.TransactionInactive;return rn(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=ae(o=>{bn(o),this._reject(e.error)}),e.onabort=ae(o=>{bn(o),this.active&&this._reject(new L.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=ae(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&ut.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return ge(new L.ReadOnly("Transaction is readonly"));if(!this.active)return ge(new L.TransactionInactive);if(this._locked())return new A((s,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,a)},M])});if(r)return lt(()=>{var s=new A((a,i)=>{this._lock();const l=n(a,i,this);l&&l.then&&l.then(a,i)});return s.finally(()=>this._unlock()),s._lib=!0,s});var o=new A((s,a)=>{var i=n(s,a,this);i&&i.then&&i.then(s,a)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=A.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 a(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=a)})()}var s=n._waitingFor;return new A((a,i)=>{r.then(l=>n._waitingQueue.push(ae(a.bind(null,l))),l=>n._waitingQueue.push(ae(i.bind(null,l)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new L.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(Fe(n,e))return n[e];const r=this.schema[e];if(!r)throw new L.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 go(t,e,n,r,o,s,a){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:s,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+Ii(e)}}function Ii(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Si(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:si(n,r=>[r.name,r])}}let _n=t=>{try{return t.only([[]]),_n=()=>[[]],[[]]}catch{return _n=()=>vt,vt}};function wo(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>et(r,e)}(t):e=>et(e,t)}function Qs(t){return[].slice.call(t)}let af=0;function pn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function lf(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:f}=l;return u===void 0?c===void 0?null:e.upperBound(c,!!f):c===void 0?e.lowerBound(u,!!d):e.bound(u,c,!!d,!!f)}const{schema:o,hasGetAll:s}=function(l,u){const c=Qs(l.objectStoreNames);return{schema:{name:l.name,tables:c.map(d=>u.objectStore(d)).map(d=>{const{keyPath:f,autoIncrement:m}=d,b=Ce(f),h=f==null,w={},g={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:b,keyPath:f,autoIncrement:m,unique:!0,extractKey:wo(f)},indexes:Qs(d.indexNames).map(y=>d.index(y)).map(y=>{const{name:_,unique:k,multiEntry:E,keyPath:C}=y,x={name:_,compound:Ce(C),keyPath:C,unique:k,multiEntry:E,extractKey:wo(C)};return w[pn(C)]=x,x}),getIndexByKeyPath:y=>w[pn(y)]};return w[":id"]=g.primaryKey,f!=null&&(w[pn(f)]=g.primaryKey),g})},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),a=o.tables.map(l=>function(u){const c=u.name;return{name:c,schema:u,mutate:function({trans:d,type:f,keys:m,values:b,range:h}){return new Promise((w,g)=>{w=ae(w);const y=d.objectStore(c),_=y.keyPath==null,k=f==="put"||f==="add";if(!k&&f!=="delete"&&f!=="deleteRange")throw new Error("Invalid operation type: "+f);const{length:E}=m||b||{length:1};if(m&&b&&m.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(E===0)return w({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const x=[],I=[];let D=0;const P=K=>{++D,bn(K)};if(f==="deleteRange"){if(h.type===4)return w({numFailures:D,failures:I,results:[],lastResult:void 0});h.type===3?x.push(C=y.clear()):x.push(C=y.delete(r(h)))}else{const[K,T]=k?_?[b,m]:[b,null]:[m,null];if(k)for(let B=0;B{const T=K.target.result;x.forEach((B,Z)=>B.error!=null&&(I[Z]=B.error)),w({numFailures:D,failures:I,results:f==="delete"?m:x.map(B=>B.result),lastResult:T})};C.onerror=K=>{P(K),N(K)},C.onsuccess=N})},getMany:({trans:d,keys:f})=>new Promise((m,b)=>{m=ae(m);const h=d.objectStore(c),w=f.length,g=new Array(w);let y,_=0,k=0;const E=x=>{const I=x.target;g[I._pos]=I.result,++k===_&&m(g)},C=ze(b);for(let x=0;xnew Promise((m,b)=>{m=ae(m);const h=d.objectStore(c).get(f);h.onsuccess=w=>m(w.target.result),h.onerror=ze(b)}),query:function(d){return f=>new Promise((m,b)=>{m=ae(m);const{trans:h,values:w,limit:g,query:y}=f,_=g===1/0?void 0:g,{index:k,range:E}=y,C=h.objectStore(c),x=k.isPrimaryKey?C:C.index(k.name),I=r(E);if(g===0)return m({result:[]});if(d){const D=w?x.getAll(I,_):x.getAllKeys(I,_);D.onsuccess=P=>m({result:P.target.result}),D.onerror=ze(b)}else{let D=0;const P=w||!("openKeyCursor"in x)?x.openCursor(I):x.openKeyCursor(I),N=[];P.onsuccess=K=>{const T=P.result;return T?(N.push(w?T.value:T.primaryKey),++D===g?m({result:N}):void T.continue()):m({result:N})},P.onerror=ze(b)}})}(s),openCursor:function({trans:d,values:f,query:m,reverse:b,unique:h}){return new Promise((w,g)=>{w=ae(w);const{index:y,range:_}=m,k=d.objectStore(c),E=y.isPrimaryKey?k:k.index(y.name),C=b?h?"prevunique":"prev":h?"nextunique":"next",x=f||!("openKeyCursor"in E)?E.openCursor(r(_),C):E.openKeyCursor(r(_),C);x.onerror=ze(g),x.onsuccess=ae(I=>{const D=x.result;if(!D)return void w(null);D.___id=++af,D.done=!1;const P=D.continue.bind(D);let N=D.continuePrimaryKey;N&&(N=N.bind(D));const K=D.advance.bind(D),T=()=>{throw new Error("Cursor not stopped")};D.trans=d,D.stop=D.continue=D.continuePrimaryKey=D.advance=()=>{throw new Error("Cursor not started")},D.fail=ae(g),D.next=function(){let B=1;return this.start(()=>B--?this.continue():this.stop()).then(()=>this)},D.start=B=>{const Z=new Promise((O,H)=>{O=ae(O),x.onerror=ze(H),D.fail=H,D.stop=G=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=T,O(G)}}),$=()=>{if(x.result)try{B()}catch(O){D.fail(O)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return x.onsuccess=ae(O=>{x.onsuccess=$,$()}),D.continue=P,D.continuePrimaryKey=N,D.advance=K,$(),Z},w(D)},g)})},count({query:d,trans:f}){const{index:m,range:b}=d;return new Promise((h,w)=>{const g=f.objectStore(c),y=m.isPrimaryKey?g:g.index(m.name),_=r(b),k=_?y.count(_):y.count();k.onsuccess=ae(E=>h(E.target.result)),k.onerror=ze(w)})}}}(l)),i={};return a.forEach(l=>i[l.name]=l),{stack:"dbcore",transaction:t.transaction.bind(t),table(l){if(!i[l])throw new Error(`Table '${l}' not found`);return i[l]},MIN_KEY:-1/0,MAX_KEY:_n(e),schema:o}}function bo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:a,indexedDB:i},l){return{dbcore:function(c,d){return d.reduce((f,{create:m})=>({...f,...m(f)}),c)}(lf(s,a,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(a=>a.name===s)&&(o.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=o.core))})}function cr({_novip:t},e,n,r){n.forEach(o=>{const s=r[o];e.forEach(a=>{const i=as(a,o);(!i||"value"in i&&i.value===void 0)&&(a===t.Transaction.prototype||a instanceof t.Transaction?Qe(a,o,{get(){return this.table(o)},set(l){ni(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):a[o]=new t.Table(o,s))})})}function xo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function cf(t,e){return t._cfg.version-e._cfg.version}function uf(t,e,n,r){const o=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,o);s.create(n),s._completion.catch(r);const a=s._reject.bind(s),i=M.transless||M;lt(()=>{M.trans=s,M.transless=i,e===0?(he(o).forEach(l=>{qr(n,l,o[l].primKey,o[l].indexes)}),bo(t,n),A.follow(()=>t.on.populate.fire(s)).catch(a)):function({_novip:l},u,c,d){const f=[],m=l._versions;let b=l._dbSchema=ko(l,l.idbdb,d),h=!1;const w=m.filter(y=>y._cfg.version>=u);function g(){return f.length?A.resolve(f.shift()(c.idbtrans)).then(g):A.resolve()}return w.forEach(y=>{f.push(()=>{const _=b,k=y._cfg.dbschema;Co(l,_,d),Co(l,k,d),b=l._dbSchema=k;const E=Oi(_,k);E.add.forEach(x=>{qr(d,x[0],x[1].primKey,x[1].indexes)}),E.change.forEach(x=>{if(x.recreate)throw new L.Upgrade("Not yet support for changing primary key");{const I=d.objectStore(x.name);x.add.forEach(D=>_o(I,D)),x.change.forEach(D=>{I.deleteIndex(D.name),_o(I,D)}),x.del.forEach(D=>I.deleteIndex(D))}});const C=y._cfg.contentUpgrade;if(C&&y._cfg.version>u){bo(l,d),c._memoizedTables={},h=!0;let x=ai(k);E.del.forEach(N=>{x[N]=_[N]}),xo(l,[l.Transaction.prototype]),cr(l,[l.Transaction.prototype],he(x),x),c.schema=x;const I=is(C);let D;I&&Zt();const P=A.follow(()=>{if(D=C(c),D&&I){var N=nt.bind(null,null);D.then(N,N)}});return D&&typeof D.then=="function"?A.resolve(D):P.then(()=>D)}}),f.push(_=>{(!h||!Zd)&&function(k,E){[].slice.call(E.db.objectStoreNames).forEach(C=>k[C]==null&&E.db.deleteObjectStore(C))}(y._cfg.dbschema,_),xo(l,[l.Transaction.prototype]),cr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),c.schema=l._dbSchema})}),g().then(()=>{var y,_;_=d,he(y=b).forEach(k=>{_.db.objectStoreNames.contains(k)||qr(_,k,y[k].primKey,y[k].indexes)})})}(t,e,s,n).catch(a)})}function Oi(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 a={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||o.primKey.auto!==s.primKey.auto&&!Sr)a.recreate=!0,n.change.push(a);else{const i=o.idxByName,l=s.idxByName;let u;for(u in i)l[u]||a.del.push(u);for(u in l){const c=i[u],d=l[u];c?c.src!==d.src&&a.change.push(d):a.add.push(d)}(a.del.length>0||a.add.length>0||a.change.length>0)&&n.change.push(a)}}else n.add.push([r,s])}return n}function qr(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=>_o(o,s)),o}function _o(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function ko(t,e,n){const r={};return rr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let a=s.keyPath;const i=go(Ii(a),a||"",!1,!1,!!s.autoIncrement,a&&typeof a!="string",!0),l=[];for(let c=0;c{if(e[r]!==null){var o=e[r].split(",").map((a,i)=>{const l=(a=a.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return go(l,u||null,/\&/.test(a),/\*/.test(a),/\+\+/.test(a),Ce(u),i===0)}),s=o.shift();if(s.multi)throw new L.Schema("Primary key cannot be multi-valued");o.forEach(a=>{if(a.auto)throw new L.Schema("Only primary key can be marked as autoIncrement (++)");if(!a.keyPath)throw new L.Schema("Index must have a name and cannot be an empty string")}),n[r]=Si(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Ie(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(a=>{Ie(o,a._cfg.storesSource),s=a._cfg.dbschema={},a._parseStoresSpec(o,s)}),n._dbSchema=s,xo(n,[n._allTables,n,n.Transaction.prototype]),cr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],he(s),s),n._storeNames=he(s),this}upgrade(e){return this._cfg.contentUpgrade=us(this._cfg.contentUpgrade||ne,e),this}}function ps(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new kt(Or,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function ms(t){return t&&typeof t.databases=="function"}function Eo(t){return lt(function(){return M.letThrough=!0,t()})}function ff(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function hf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?ge(e.dbOpenError):t);Je&&(e.openCanceller._stackHolder=Ot()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new L.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,a=null,i=!1;return A.race([r,(typeof navigator>"u"?A.resolve():ff()).then(()=>new A((l,u)=>{if(o(),!n)throw new L.MissingAPI;const c=t.name,d=e.autoSchema?n.open(c):n.open(c,Math.round(10*t.verno));if(!d)throw new L.MissingAPI;d.onerror=ze(u),d.onblocked=ae(t._fireOnBlocked),d.onupgradeneeded=ae(f=>{if(a=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=bn,a.abort(),d.result.close();const b=n.deleteDatabase(c);b.onsuccess=b.onerror=ae(()=>{u(new L.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{a.onerror=ze(u);var m=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;i=m<1,t._novip.idbdb=d.result,uf(t,m/10,a,u)}},u),d.onsuccess=ae(()=>{a=null;const f=t._novip.idbdb=d.result,m=rr(f.objectStoreNames);if(m.length>0)try{const h=f.transaction((b=m).length===1?b[0]:b,"readonly");e.autoSchema?function({_novip:w},g,y){w.verno=g.version/10;const _=w._dbSchema=ko(0,g,y);w._storeNames=rr(g.objectStoreNames,0),cr(w,[w._allTables],he(_),_)}(t,f,h):(Co(t,t._dbSchema,h),function(w,g){const y=Oi(ko(0,w.idbdb,g),w._dbSchema);return!(y.add.length||y.change.some(_=>_.add.length||_.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),bo(t,h)}catch{}var b;fn.push(t),f.onversionchange=ae(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),f.onclose=ae(h=>{t.on("close").fire(h)}),i&&function({indexedDB:h,IDBKeyRange:w},g){!ms(h)&&g!==Or&&ps(h,w).put({name:g}).catch(ne)}(t._deps,c),l()},u)}))]).then(()=>(o(),e.onReadyBeingFired=[],A.resolve(Eo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(us,ne);return e.onReadyBeingFired=[],A.resolve(Eo(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{a&&a.abort()}catch{}return r===e.openCanceller&&t._close(),ge(l)}).finally(()=>{e.openComplete=!0,s()})}function Do(t){var e=s=>t.next(s),n=o(e),r=o(s=>t.throw(s));function o(s){return a=>{var i=s(a),l=i.value;return i.done?l:l&&typeof l.then=="function"?l.then(n,r):Ce(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function pf(t,e,n){var r=arguments.length;if(r<2)throw new L.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,ii(o),n]}function Pi(t,e,n,r,o){return A.resolve().then(()=>{const s=M.transless||M,a=t._createTransaction(e,n,t._dbSchema,r),i={trans:a,transless:s};if(r)a.idbtrans=r.idbtrans;else try{a.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===cs.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Pi(t,e,n,null,o))):ge(d)}const l=is(o);let u;l&&Zt();const c=A.follow(()=>{if(u=o.call(a,a),u)if(l){var d=nt.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Do(u))},i);return(u&&typeof u.then=="function"?A.resolve(u).then(d=>a.active?d:ge(new L.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(r&&a._resolve(),a._completion.then(()=>d))).catch(d=>(a._reject(d),ge(d)))})}function Kn(t,e,n){const r=Ce(t)?t.slice():[t];for(let o=0;o0,g={...f,isVirtual:w,keyTail:d,keyLength:h,extractKey:wo(c),unique:!w&&f.unique};return b.push(g),g.isPrimaryKey||s.push(g),h>1&&a(h===2?c[0]:c.slice(0,h-1),d+1,f),b.sort((y,_)=>y.keyTail-_.keyTail),g}const i=a(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[i];for(const c of r.indexes)a(c.keyPath,0,c);function l(c){const d=c.query.index;return d.isVirtual?{...c,query:{index:d,range:(f=c.query.range,m=d.keyTail,{type:f.type===1?2:f.type,lower:Kn(f.lower,f.lowerOpen?t.MAX_KEY:t.MIN_KEY,m),lowerOpen:!0,upper:Kn(f.upper,f.upperOpen?t.MIN_KEY:t.MAX_KEY,m),upperOpen:!0})}}:c;var f,m}return{...n,schema:{...r,primaryKey:i,indexes:s,getIndexByKeyPath:function(c){const d=o[pn(c)];return d&&d[0]}},count:c=>n.count(l(c)),query:c=>n.query(l(c)),openCursor(c){const{keyTail:d,isVirtual:f,keyLength:m}=c.query.index;return f?n.openCursor(l(c)).then(b=>b&&function(h){return Object.create(h,{continue:{value:function(g){g!=null?h.continue(Kn(g,c.reverse?t.MAX_KEY:t.MIN_KEY,d)):c.unique?h.continue(h.key.slice(0,m).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(g,y){h.continuePrimaryKey(Kn(g,t.MAX_KEY,d),y)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const g=h.key;return m===1?g[0]:g.slice(0,m)}},value:{get:()=>h.value}})}(b)):n.openCursor(c)}}}}}};function vs(t,e,n,r){return n=n||{},r=r||"",he(t).forEach(o=>{if(Fe(e,o)){var s=t[o],a=e[o];if(typeof s=="object"&&typeof a=="object"&&s&&a){const i=oo(s);i!==oo(a)?n[r+o]=e[o]:i==="Object"?vs(s,a,n,r+o+"."):s!==a&&(n[r+o]=e[o])}else s!==a&&(n[r+o]=e[o])}else n[r+o]=void 0}),he(e).forEach(o=>{Fe(t,o)||(n[r+o]=e[o])}),n}const vf={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 a=M.trans,{deleting:i,creating:l,updating:u}=a.table(e).hook;switch(s.type){case"add":if(l.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===ne&&u.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"delete":if(i.fire===ne)break;return a._promise("readwrite",()=>c(s),!0);case"deleteRange":if(i.fire===ne)break;return a._promise("readwrite",()=>function(f){return d(f.trans,f.range,1e4)}(s),!0)}return n.mutate(s);function c(f){const m=M.trans,b=f.keys||function(h,w){return w.type==="delete"?w.keys:w.keys||w.values.map(h.extractKey)}(r,f);if(!b)throw new Error("Keys missing");return(f=f.type==="add"||f.type==="put"?{...f,keys:b}:{...f}).type!=="delete"&&(f.values=[...f.values]),f.keys&&(f.keys=[...f.keys]),function(h,w,g){return w.type==="add"?Promise.resolve([]):h.getMany({trans:w.trans,keys:g,cache:"immutable"})}(n,f,b).then(h=>{const w=b.map((g,y)=>{const _=h[y],k={onerror:null,onsuccess:null};if(f.type==="delete")i.fire.call(k,g,_,m);else if(f.type==="add"||_===void 0){const E=l.fire.call(k,g,f.values[y],m);g==null&&E!=null&&(g=E,f.keys[y]=g,r.outbound||Ke(f.values[y],r.keyPath,g))}else{const E=vs(_,f.values[y]),C=u.fire.call(k,E,g,_,m);if(C){const x=f.values[y];Object.keys(C).forEach(I=>{Fe(x,I)?x[I]=C[I]:Ke(x,I,C[I])})}}return k});return n.mutate(f).then(({failures:g,results:y,numFailures:_,lastResult:k})=>{for(let E=0;E(w.forEach(y=>y.onerror&&y.onerror(g)),Promise.reject(g)))})}function d(f,m,b){return n.query({trans:f,values:!1,query:{index:r,range:m},limit:b}).then(({result:h})=>c({type:"delete",keys:h,trans:f}).then(w=>w.numFailures>0?Promise.reject(w.failures[0]):h.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=ji(r.keys,r.trans._cache,r.cache==="clone");return o?A.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?On(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function ys(t){return!("from"in t)}const Ye=function(t,e){if(!this){const n=new Ye;return t&&"d"in t&&Ie(n,t),n}Ie(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function kn(t,e,n){const r=De(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(ys(t))return Ie(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(De(n,t.from)<0)return o?kn(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},ea(t);if(De(e,t.to)>0)return s?kn(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},ea(t);De(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),De(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const a=!t.r;o&&!t.l&&ur(t,o),s&&a&&ur(t,s)}function ur(t,e){ys(e)||function n(r,{from:o,to:s,l:a,r:i}){kn(r,o,s),a&&n(r,a),i&&n(r,i)}(t,e)}function gf(t,e){const n=Io(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=Io(t);let a=s.next(o.from),i=a.value;for(;!r.done&&!a.done;){if(De(i.from,o.to)<=0&&De(i.to,o.from)>=0)return!0;De(o.from,i.from)<0?o=(r=n.next(i.from)).value:i=(a=s.next(o.from)).value}return!1}function Io(t){let e=ys(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&&De(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||De(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function ea(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const s=o==="r"?"l":"r",a={...t},i=t[o];t.from=i.from,t.to=i.to,t[o]=i[o],a[o]=i[s],t[s]=a,a.d=ta(a)}t.d=ta(t)}function ta({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}Gt(Ye.prototype,{add(t){return ur(this,t),this},addKey(t){return kn(this,t,t),this},addKeys(t){return t.forEach(e=>kn(this,e,e)),this},[so](){return Io(this)}});const wf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new Ye(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:s}=o,{primaryKey:a}=s,{extractKey:i,outbound:l}=a,u={...o,mutate:f=>{const m=f.trans,b=m.mutatedParts||(m.mutatedParts={}),h=C=>{const x=`idb://${e}/${r}/${C}`;return b[x]||(b[x]=new Ye)},w=h(""),g=h(":dels"),{type:y}=f;let[_,k]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[];const E=f.trans._cache;return o.mutate(f).then(C=>{if(Ce(_)){y!=="delete"&&(_=C.results),w.addKeys(_);const x=ji(_,E);x||y==="add"||g.addKeys(_),(x||k)&&function(I,D,P,N){function K(T){const B=I(T.name||"");function Z(O){return O!=null?T.extractKey(O):null}const $=O=>T.multiEntry&&Ce(O)?O.forEach(H=>B.addKey(H)):B.addKey(O);(P||N).forEach((O,H)=>{const G=P&&Z(P[H]),de=N&&Z(N[H]);De(G,de)!==0&&(G!=null&&$(G),de!=null&&$(de))})}D.indexes.forEach(K)}(h,s,x,k)}else if(_){const x={from:_.lower,to:_.upper};g.add(x),w.add(x)}else w.add(n),g.add(n),s.indexes.forEach(x=>h(x.name).add(n));return C})}},c=({query:{index:f,range:m}})=>{var b,h;return[f,new Ye((b=m.lower)!==null&&b!==void 0?b:t.MIN_KEY,(h=m.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:f=>[a,new Ye(f.key)],getMany:f=>[a,new Ye().addKeys(f.keys)],count:c,query:c,openCursor:c};return he(d).forEach(f=>{u[f]=function(m){const{subscr:b}=M;if(b){const h=k=>{const E=`idb://${e}/${r}/${k}`;return b[E]||(b[E]=new Ye)},w=h(""),g=h(":dels"),[y,_]=d[f](m);if(h(y.name||"").add(_),!y.isPrimaryKey){if(f!=="count"){const k=f==="query"&&l&&m.values&&o.query({...m,values:!1});return o[f].apply(this,arguments).then(E=>{if(f==="query"){if(l&&m.values)return k.then(({result:x})=>(w.addKeys(x),E));const C=m.values?E.result.map(i):E.result;m.values?w.addKeys(C):g.addKeys(C)}else if(f==="openCursor"){const C=E,x=m.values;return C&&Object.create(C,{key:{get:()=>(g.addKey(C.primaryKey),C.key)},primaryKey:{get(){const I=C.primaryKey;return g.addKey(I),I}},value:{get:()=>(x&&w.addKey(C.primaryKey),C.value)}})}return E})}g.add(n)}}return o[f].apply(this,arguments)}}),u}}}};class kt{constructor(e,n){this._middlewares={},this.verno=0;const r=kt.dependencies;this._options=n={addons:kt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ne,dbReadyPromise:null,cancelOpen:ne,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var a;s.dbReadyPromise=new A(i=>{s.dbReadyResolve=i}),s.openCanceller=new A((i,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=hn(this,"populate","blocked","versionchange","close",{ready:[us,ne]}),this.on.ready.subscribe=ri(this.on.ready.subscribe,i=>(l,u)=>{kt.vip(()=>{const c=this._state;if(c.openComplete)c.dbOpenError||A.resolve().then(l),u&&i(l);else if(c.onReadyBeingFired)c.onReadyBeingFired.push(l),u&&i(l);else{i(l);const d=this;u||i(function f(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(f)})}})}),this.Collection=(a=this,nn(tf.prototype,function(i,l){this.db=a;let u=Ci,c=null;if(l)try{u=l()}catch(b){c=b}const d=i._ctx,f=d.table,m=f.hook.reading.fire;this._ctx={table:f,index:d.index,isPrimKey:!d.index||f.schema.primKey.keyPath&&d.index===f.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:m!==gn?m:null}})),this.Table=function(i){return nn(ef.prototype,function(l,u,c){this.db=i,this._tx=c,this.name=l,this.schema=u,this.hook=i._allTables[l]?i._allTables[l].hook:hn(null,{creating:[$d,ne],reading:[Kd,gn],updating:[zd,ne],deleting:[Ud,ne]})})}(this),this.Transaction=function(i){return nn(sf.prototype,function(l,u,c,d,f){this.db=i,this.mode=l,this.storeNames=u,this.schema=c,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=hn(this,"complete","error","abort"),this.parent=f||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 A((m,b)=>{this._resolve=m,this._reject=b}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},m=>{var b=this.active;return this.active=!1,this.on.error.fire(m),this.parent?this.parent._reject(m):b&&this.idbtrans&&this.idbtrans.abort(),ge(m)})})}(this),this.Version=function(i){return nn(df.prototype,function(l){this.db=i,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(i){return nn(Di.prototype,function(l,u,c){this.db=i,this._ctx={table:l,index:u===":id"?null:u,or:c};const d=i._deps.indexedDB;if(!d)throw new L.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(f,m)=>d.cmp(m,f),this._max=(f,m)=>d.cmp(f,m)>0?f:m,this._min=(f,m)=>d.cmp(f,m)<0?f:m,this._IDBKeyRange=i._deps.IDBKeyRange})}(this),this.on("versionchange",i=>{i.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",i=>{!i.newVersion||i.newVersionnew this.Transaction(i,l,u,this._options.chromeTransactionDurability,c),this._fireOnBlocked=i=>{this.on("blocked").fire(i),fn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(i))},this.use(mf),this.use(vf),this.use(wf),this.use(yf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(i=>i(this))}version(e){if(isNaN(e)||e<.1)throw new L.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new L.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(cf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||M.letThrough||this._vip)?e():new A((n,r)=>{if(this._state.openComplete)return r(new L.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new L.DatabaseClosed);this.open().catch(ne)}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((a,i)=>a.level-i.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 hf(this)}_close(){const e=this._state,n=fn.indexOf(this);if(n>=0&&fn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new A(r=>{e.dbReadyResolve=r}),e.openCanceller=new A((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new L.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new A((r,o)=>{const s=()=>{this.close();var a=this._deps.indexedDB.deleteDatabase(this.name);a.onsuccess=ae(()=>{(function({indexedDB:i,IDBKeyRange:l},u){!ms(i)&&u!==Or&&ps(i,l).delete(u).catch(ne)})(this._deps,this.name),r()}),a.onerror=ze(o),a.onblocked=this._fireOnBlocked};if(e)throw new L.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 he(this._allTables).map(e=>this._allTables[e])}transaction(){const e=pf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=M.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const s=e.indexOf("?")!==-1;let a,i;e=e.replace("!","").replace("?","");try{if(i=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===Wr)a=Wr;else{if(e!="rw"&&e!=Kr)throw new L.InvalidArgument("Invalid transaction mode: "+e);a=Kr}if(o){if(o.mode===Wr&&a===Kr){if(!s)throw new L.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(u=>{if(o&&o.storeNames.indexOf(u)===-1){if(!s)throw new L.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)}):ge(u)}const l=Pi.bind(null,this,a,i,o,r);return o?o._promise(a,l,"lock"):M.trans?Qt(M.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Fe(this._allTables,e))throw new L.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const bf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class xf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[bf](){return this}}function Ni(t,e){return he(e).forEach(n=>{ur(t[n]||(t[n]=new Ye),e[n])}),t}function _f(t){let e,n=!1;const r=new xf(o=>{const s=is(t);let a=!1,i={},l={};const u={get closed(){return a},unsubscribe:()=>{a=!0,ut.storagemutated.unsubscribe(m)}};o.start&&o.start(u);let c=!1,d=!1;function f(){return he(l).some(h=>i[h]&&gf(i[h],l[h]))}const m=h=>{Ni(i,h),f()&&b()},b=()=>{if(c||a)return;i={};const h={},w=function(g){s&&Zt();const y=()=>lt(t,{subscr:g,trans:null}),_=M.trans?Qt(M.transless,y):y();return s&&_.then(nt,nt),_}(h);d||(ut(xn,m),d=!0),c=!0,Promise.resolve(w).then(g=>{n=!0,e=g,c=!1,a||(f()?b():(i={},l=h,o.next&&o.next(g)))},g=>{c=!1,n=!1,o.error&&o.error(g),u.unsubscribe()})};return b(),u});return r.hasValue=()=>n,r.getValue=()=>e,r}let So;try{So={indexedDB:se.indexedDB||se.mozIndexedDB||se.webkitIndexedDB||se.msIndexedDB,IDBKeyRange:se.IDBKeyRange||se.webkitIDBKeyRange}}catch{So={indexedDB:null,IDBKeyRange:null}}const ht=kt;function Xn(t){let e=Ze;try{Ze=!0,ut.storagemutated.fire(t)}finally{Ze=e}}Gt(ht,{...qn,delete:t=>new ht(t,{addons:[]}).delete(),exists:t=>new ht(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return ms(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==Or)):ps(e,n).toCollection().primaryKeys()}(ht.dependencies).then(t)}catch{return ge(new L.MissingAPI)}},defineClass:()=>function(t){Ie(this,t)},ignoreTransaction:t=>M.trans?Qt(M.transless,t):t(),vip:Eo,async:function(t){return function(){try{var e=Do(t.apply(this,arguments));return e&&typeof e.then=="function"?e:A.resolve(e)}catch(n){return ge(n)}}},spawn:function(t,e,n){try{var r=Do(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:A.resolve(r)}catch(o){return ge(o)}},currentTransaction:{get:()=>M.trans||null},waitFor:function(t,e){const n=A.resolve(typeof t=="function"?ht.ignoreTransaction(t):t).timeout(e||6e4);return M.trans?M.trans.waitFor(n):n},Promise:A,debug:{get:()=>Je,set:t=>{ci(t,t==="dexie"?()=>!0:ki)}},derive:Wt,extend:Ie,props:Gt,override:ri,Events:hn,on:ut,liveQuery:_f,extendObservabilitySet:Ni,getByKeyPath:et,setByKeyPath:Ke,delByKeyPath:function(t,e){typeof e=="string"?Ke(t,e,void 0):"length"in e&&[].map.call(e,function(n){Ke(t,n,void 0)})},shallowClone:ai,deepClone:On,getObjectDiff:vs,cmp:De,asap:oi,minKey:yo,addons:[],connections:fn,errnames:cs,dependencies:So,semVer:Js,version:Js.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),ht.maxKey=_n(ht.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ut(xn,t=>{if(!Ze){let e;Sr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(at,!0,!0,t)):e=new CustomEvent(at,{detail:t}),Ze=!0,dispatchEvent(e),Ze=!1}}),addEventListener(at,({detail:t})=>{Ze||Xn(t)}));let Ze=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(at);typeof t.unref=="function"&&t.unref(),ut(xn,e=>{Ze||t.postMessage(e)}),t.onmessage=e=>{e.data&&Xn(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ut(xn,e=>{try{Ze||(typeof localStorage<"u"&&localStorage.setItem(at,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:at,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===at){const n=JSON.parse(e.newValue);n&&Xn(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===at&&Xn(e.changedParts)})}A.rejectionMapper=function(t,e){if(!t||t instanceof Kt||t instanceof TypeError||t instanceof SyntaxError||!t.name||!zs[t.name])return t;var n=new zs[t.name](e||t.message,t);return"stack"in t&&Qe(n,"stack",{get:function(){return this.inner.stack}}),n},ci(Je,ki);var Zn=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(Zn||{});const kf="comfyui_workspace_db";class Cf extends kt{constructor(){super(kf);ce(this,"workflows");ce(this,"changelogs");ce(this,"media");ce(this,"folders");ce(this,"tags");ce(this,"userSettings");ce(this,"models");ce(this,"cache");ce(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",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID"}).upgrade(n=>{})}}const X=new Cf;class Pt{constructor(e){ce(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await X[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")}),kd(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=Jt()),e.createTime||(e.createTime=Date.now()),await X[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await X[this.tableName].put(e),await this.saveDiskDB(),e}async update(e,n){return await X[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await X[this.tableName].toArray()}async batchQuery(e){return await X[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 _d(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Pd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await X[this.tableName].get(e)}async delete(e){await X[this.tableName].delete(e),await this.saveDiskDB()}}const fr=class fr extends Pt{constructor(){super("changelogs")}static async load(){return new fr}async listByWorkflowID(e){return await X.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:Jt(),json:e.json,workflowID:e.workflowID,createTime:Date.now()};return await X.changelogs.add(r),await this.saveDiskDB(),r}};ce(fr,"TABLE_NAME","changelogs");let Oo=fr;const Mh="CWM_WORKFLOWS_SORT_TYPE";var pt=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(pt||{});const Rh=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],Ai="comfyspace_tracking",Fi="workspace_info",Ef=9999999;async function sn(t){const e=await gs(t);if(e==null)return;const n=await ws(t);await(S==null?void 0:S.updateFlow(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Fi]={id:t.id,name:t.name},delete o.extra[Ai],await ei(e,JSON.stringify(o))}async function Vr(t){if(t.name==null)return;const e=await gs(t);e!=null&&ti(e)}async function gs(t){let e=If(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(ee==null?void 0:ee.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function ws(t){const e=await gs(t);let n=await(z==null?void 0:z.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function Df(t){const e=await(ee==null?void 0:ee.get(t));let n=e==null?void 0:e.parentFolderID,r=e==null?void 0:e.name;for(;n;){const s=await(ee==null?void 0:ee.get(n));if(s==null)break;r=`${s.name}/${r}`,n=s.parentFolderID??void 0}let o=await(z==null?void 0:z.getSetting("myWorkflowsDir"));return o?(o.endsWith("/")||(o=o+"/"),o+r):(console.error("myWorkflowsDir is not set"),null)}async function Th(t){const e=await(S==null?void 0:S.listAll())??[],n=await(ee==null?void 0:ee.listAll())??[],r=[t];let o=0;for(;r.length>0;){const s=r.shift();if(s){for(const i of e)i.parentFolderID===s&&o++;const a=n.filter(i=>i.parentFolderID===s).map(i=>i.id);a.length&&r.push(...a)}}return o}function If(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function na(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"),a=r.getFullYear(),i=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),u=String(r.getSeconds()).padStart(2,"0"),c=`${s}-${o}-${a}`;return e?c+` ${i}:${l}`:n?c+`:${u}`:c}async function Mi(t=!1){const e=await(S==null?void 0:S.listAll())??[];for(const n of e){const r=await ws(n);n.filePath!=r&&(n.filePath!=null&&await ti(n.filePath,t),await sn(n))}}const Sf=(t,e=pt.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case pt.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case pt.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case pt.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case pt.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n},Of=async t=>{const e=await(z==null?void 0:z.getSetting("shortcuts").then(n=>n==null?void 0:n.save));return e?Pf(t,e):!1},Pf=(t,e)=>{const n=e.split("+"),r={Control:t.ctrlKey,Shift:t.shiftKey,Alt:t.altKey,Command:t.metaKey,[t.key.toUpperCase()]:!0};return n.every(o=>r[o])};function Lh(t){const e=["png","jpg","jpeg","gif","bmp","webp"],n=t.split(".").pop();return n!=null&&e.includes(n)}function jf(t){return`/workspace/view_media?filename=${t}`}async function Ri(t,e){const n=t.filter(o=>"json"in o);n.length&&await(S==null?void 0:S.batchCreateFlows(n,!0,e));const r=t.filter(o=>"list"in o);if(r.length){const o=await(ee==null?void 0:ee.listAll());for(const s of r){const a=o==null?void 0:o.find(l=>l.name===s.name);let i;if(a)i=a.id;else{const l=await(ee==null?void 0:ee.create({name:s.name,parentFolderID:e}));i=l==null?void 0:l.id}await Ri(s.list,i)}}}function ra(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function Ti(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 Nf=t=>{const e=Ti(t);window.open(`${window.location.origin}/#${e}`)};async function Af(){const t=await(S==null?void 0:S.listAll())??[];for(const e of t)try{const n=await ws(e),r=JSON.parse(e.json);r.extra[Fi]={id:e.id,name:e.name},delete r.extra[Ai],n&&await ei(n,JSON.stringify(r))}catch(n){console.error(n)}}const Po={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},hr=class hr extends Pt{constructor(){super("workflows");ce(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new hr}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}async latestVersionCheck(){if(this._curWorkflow){const n=await this.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async generateUniqueName(n,r){let o=n??"Untitled Flow";const a=(await this.listAll()??[]).filter(i=>i.parentFolderID==r).map(i=>i.name);if(a.includes(o)){let i=2,l=!0;for(;l;)a.includes(`${o} ${i}`)?i++:(o=`${o} ${i}`,l=!1)}return o}async createFlow(n){const{id:r,json:o,name:s}=n,a=await this.generateUniqueName(s,n.parentFolderID),i=r??Jt(),l=Date.now(),u={...n,id:i,json:o??JSON.stringify(Po),name:a,updateTime:l,createTime:l};return await X.workflows.add(u),this.saveDiskDB(),sn(u),u}async updateFlow(n,r){const o=await this.get(n);if(o==null)return;const s={...o,...r,id:n},a=JSON.stringify(o),i=JSON.stringify(s);if(a===i)return;const l=s,u=Object.keys(r);if(u.length===1&&["tags","parentFolderID"].includes(u[0])||(l.updateTime=Date.now(),l.parentFolderID!=null&&await(ee==null?void 0:ee.update({id:l.parentFolderID,updateTime:Date.now()}))),await X.workflows.update(n,l),this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=l),await this.saveDiskDB(),"name"in r||"parentFolderID"in r){await Vr(o),await sn(s);return}r.json!=null&&await sn(s)}async batchCreateFlows(n=[],r=!1,o){const s=[];for(const a of n){const i=a.name&&r?a.name:await this.generateUniqueName(a.name,o),l=Jt(),u=Date.now(),c={id:l,name:i,json:a.json,parentFolderID:o,updateTime:u,createTime:u,tags:[]};s.push(c),await sn(c)}await X.workflows.bulkAdd(s),this.saveDiskDB()}async deleteFlow(n){const r=await this.get(n);r&&Vr({...r}),await X.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await X.workflows.bulkGet(n);for(const o of r)o&&await Vr(o);await X.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){const o=await this.listAll().then(i=>i.filter(l=>l.parentFolderID==n))??[],s=await(ee==null?void 0:ee.listAll().then(i=>i.filter(l=>l.parentFolderID==n)))??[],a=[...o,...s];return Sf(a,r??pt.RECENTLY_MODIFIED)}};ce(hr,"TABLE_NAME","workflows");let jo=hr;const pr=class pr extends Pt{constructor(){super("folders")}static async load(){return new pr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r={id:Jt(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return await X.folders.add(r),this.saveDiskDB(),r}async update(e){const n=await this.get(e.id);if(n==null)return;const r="name"in e&&e.name!=n.name,o="parentFolderID"in e&&e.parentFolderID!=n.parentFolderID,s={...n,...e};e.name!=null&&(s.updateTime=Date.now()),o&&(e.name=await this.generateUniqueName(s.name,s.parentFolderID??void 0)),await X.folders.update(e.id,e),this.saveDiskDB(),(r||o)&&Mi(!0)}async deleteFolder(e,n=Zn.DELETE){const r=await Df(e),o=await(S==null?void 0:S.listAll())??[],s=await this.listAll(),a=[e];for(;a.length>0;){const i=a.shift();if(i){for(const u of o)if(u.parentFolderID===i)switch(n){case Zn.DELETE:await(S==null?void 0:S.deleteFlow(u.id));break;case Zn.MOVE_TO_ROOT_FOLDER:await(S==null?void 0:S.updateFlow(u.id,{parentFolderID:void 0}));break}await X.folders.delete(i);const l=s.filter(u=>u.parentFolderID===i).map(u=>u.id);l.length&&a.push(...l)}}r&&await Dd(r),this.saveDiskDB()}async generateUniqueName(e,n){let r=e??"New folder";const o=await this.listAll().then(s=>s.filter(a=>a.parentFolderID==n).map(a=>a.name));if(o.includes(r)){let s=2,a=!0;for(;a;)o.includes(`${r} ${s}`)?s++:(r=`${r} ${s}`,a=!1)}return r}};ce(pr,"TABLE_NAME","folders");let No=pr;class Li extends Pt{constructor(){super("media")}async listByWorkflowID(e){return await X.media.where("workflowID").equals(e).reverse().sortBy("createTime")}async create(e){const n=e.localPath.split(".").pop();if(n==null)return null;const r={id:Jt(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),format:n},o=await(S==null?void 0:S.get(e.workflowID)),s=new Set((o==null?void 0:o.mediaIDs)??[]).add(r.id);return await(S==null?void 0:S.updateFlow(e.workflowID,{mediaIDs:Array.from(s),coverMediaPath:r.localPath})),X.media.add(r),this.saveDiskDB(),r}}ce(Li,"TABLE_NAME","media");const mr=class mr extends Pt{constructor(){super("userSettings");ce(this,"defaultSettings");ce(this,"DEFAULT_USER","guest");ce(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S"},autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.comfyspace.art",overwriteCurWorkflowWhenDroppingFileToCanvas:!1}}get autoSave(){return this._autoSave}async getSetting(n){const r=await this.get(this.DEFAULT_USER);return(r==null?void 0:r[n])??this.defaultSettings[n]}async upsert(n){const o={...await this.get(this.DEFAULT_USER)??this.defaultSettings,...n};await this.put(o),Object.hasOwn(n,"autoSave")&&n.autoSave!==void 0&&(this._autoSave=n.autoSave)}static async load(){const n=new mr,r=await Cd();return n.defaultSettings.myWorkflowsDir=`${r.dir_path}/my_workflows`,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};ce(mr,"TABLE_NAME","userSettings");let Ao=mr;const vr=class vr extends Pt{constructor(){super("tags")}static async load(){return new vr}};ce(vr,"TABLE_NAME","tags");let Fo=vr;const yr=class yr extends Pt{constructor(){super("workflowVersions")}static async load(){return new yr}async listByWorkflowID(e){return await X[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}};ce(yr,"TABLE_NAME","workflowVersions");let Mo=yr;function Bh(t){return"type"in t&&t.type==="folder"}let S=null,Qn=null,z=null,ee=null,Ve=null,Ct=null,xe=null;async function Ff(){const t=async()=>{S=await jo.load()},e=async()=>{Qn=await Fo.load()},n=async()=>{z=await Ao.load()},r=async()=>{ee=await No.load()},o=async()=>{Ve=await Oo.load()},s=async()=>{Ct=new Li},a=async()=>{xe=await Mo.load()};await Promise.all([t(),e(),n(),r(),o(),s(),a()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Mf(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Mf(){const t=async()=>{try{const i=await(S==null?void 0:S.getRecords());i&&await X.workflows.bulkAdd(Object.values(i))}catch(i){console.error(i)}},e=async()=>{try{const i=await(ee==null?void 0:ee.getRecords());i&&await X.folders.bulkAdd(Object.values(i))}catch(i){console.error(i)}},n=async()=>{try{const i=await(Ct==null?void 0:Ct.getRecords());i&&await X.media.bulkAdd(Object.values(i))}catch(i){console.error(i)}},r=async()=>{try{const i=await(Ve==null?void 0:Ve.getRecords());i&&await X.changelogs.bulkAdd(Object.values(i))}catch(i){console.error(i)}},o=async()=>{try{const i=await(Qn==null?void 0:Qn.getRecords());i&&await X.tags.bulkAdd(Object.values(i))}catch(i){console.error(i)}},s=async()=>{try{const i=z,l=await i.getRecords().then(u=>u[i.DEFAULT_USER]?u[i.DEFAULT_USER]:u);await X.userSettings.put({...i.defaultSettings,...l})}catch(i){console.error(i)}},a=async()=>{try{const i=await(xe==null?void 0:xe.getRecords());i&&await X.workflowVersions.bulkAdd(Object.values(i))}catch(i){console.error(i)}};await Promise.all([t(),e(),n(),r(),o(),s(),a()])}const en=v.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{}}),Wh=v.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),Hr={x:0,y:0};function Rf({children:t,onDragEnd:e,dragIconId:n}){const r=v.useRef(Hr),o=v.useRef(!1),[s,a]=v.useState(Hr),i=d=>{var f,m,b;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(f=d.target)==null?void 0:f.id,(b=(m=d.target)==null?void 0:m.parentNode)==null?void 0:b.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",u);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=v.useCallback(d=>{const f={x:d.clientX-r.current.x,y:d.clientY-r.current.y};a(f)},[]),u=v.useCallback(()=>{a(f=>(e(f),Hr)),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 p.jsx("div",{style:c,onMouseDown:i,children:t})}var Tf={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"},Lf=Object.defineProperty,Bf=Object.defineProperties,Wf=Object.getOwnPropertyDescriptors,dr=Object.getOwnPropertySymbols,Bi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,oa=(t,e,n)=>e in t?Lf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,sa=(t,e)=>{for(var n in e||(e={}))Bi.call(e,n)&&oa(t,n,e[n]);if(dr)for(var n of dr(e))Wi.call(e,n)&&oa(t,n,e[n]);return t},Kf=(t,e)=>Bf(t,Wf(e)),$f=(t,e)=>{var n={};for(var r in t)Bi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&dr)for(var r of dr(t))e.indexOf(r)<0&&Wi.call(t,r)&&(n[r]=t[r]);return n},pe=(t,e,n)=>{const r=v.forwardRef((o,s)=>{var a=o,{color:i="currentColor",size:l=24,stroke:u=2,children:c}=a,d=$f(a,["color","size","stroke","children"]);return v.createElement("svg",sa(Kf(sa({ref:s},Tf),{width:l,height:l,stroke:i,strokeWidth:u,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([f,m])=>v.createElement(f,m)),...c||[]])});return r.propTypes={color:ft.string,size:ft.oneOfType([ft.string,ft.number]),stroke:ft.oneOfType([ft.string,ft.number])},r.displayName=`${e}`,r},Uf=pe("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"}]]),zf=pe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),qf=pe("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"}]]),Vf=pe("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"}]]),Ro=pe("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"}]]),Hf=pe("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"}]]),Jf=pe("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"}]]),Gf=pe("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"}]]),Yf=pe("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"}]]),Xf=pe("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"}]]),Zf=pe("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"}]]),Qf=pe("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"}]]),eh=pe("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"}]]),th=pe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),nh=pe("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"}]]),rh=pe("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"}]]),oh=pe("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"}]]),sh=pe("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"}]]),ah=pe("world","IconWorld",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]),ih=pe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function lh(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return p.jsx(Ua,{isLazy:!0,placement:"auto",children:({onClose:a})=>p.jsxs(p.Fragment,{children:[p.jsx($a,{children:p.jsx(it,{children:p.jsx(bt,{hasArrow:!0,label:s,placement:"bottom",children:p.jsx(Ut,{"aria-label":"Delete confirm",size:"sm",icon:p.jsx(rh,{color:"#F56565"}),isDisabled:o,variant:n})})})}),p.jsxs(Ja,{children:[p.jsx(za,{}),p.jsx(Va,{onClick:a}),p.jsxs(qa,{children:[p.jsx(gt,{mb:4,pr:4,fontWeight:600,children:e}),p.jsx(Oe,{colorScheme:"red",size:"sm",onClick:()=>{r(),a()},children:"Yes, delete"})]})]})]})})}function ch({onClose:t}){const e=hl(),{curFlowID:n,isDirty:r}=v.useContext(en),[o,s]=v.useState(0),[a,i]=v.useState(null),[l,u]=v.useState([]),[c,d]=v.useState([]),f=async h=>{var k;const w=await(S==null?void 0:S.get(h)),g=await(Ve==null?void 0:Ve.listByWorkflowID(h));u(g??[]);const y=g==null?void 0:g.filter(E=>E.json===(w==null?void 0:w.lastSavedJson)),_=(k=y==null?void 0:y[0])==null?void 0:k.id;_&&i(_)},m=async()=>{var _;const h=await(xe==null?void 0:xe.listByWorkflowID(n))??[];d(h);const w=JSON.stringify(ye.graph.serialize()),g=h==null?void 0:h.filter(k=>k.json===w),y=(_=g==null?void 0:g[0])==null?void 0:_.id;y&&i(y)},b=h=>{xe==null||xe.delete(h).then(()=>{m()})};return v.useEffect(()=>{switch(o){case 0:m();break;case 1:f(n);break}},[o]),v.useEffect(()=>(ye.canvasEl.addEventListener("click",t),()=>{ye.canvasEl.removeEventListener("click",t)}),[o]),p.jsxs(Cl,{width:400,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[p.jsx(kl,{pb:1,mb:0,children:p.jsxs($n,{justifyContent:"space-between",alignItems:"center",children:[p.jsx(ka,{size:"md",children:"Version History"}),p.jsx(Ut,{size:"sm",icon:p.jsx(ih,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),p.jsx(_l,{overflowY:"auto",gap:0,children:p.jsxs(Xa,{isFitted:!0,variant:"enclosed",onChange:s,children:[p.jsxs(Za,{mb:"1em",children:[p.jsx(to,{children:"Versions"}),p.jsx(to,{children:"Change History"})]}),p.jsxs(Qa,{children:[p.jsx(eo,{children:p.jsx(an,{divider:p.jsx(Yr,{}),spacing:2,children:c==null?void 0:c.map(h=>p.jsxs($n,{w:"100%",mb:1,justify:"space-between",backgroundColor:h.id===a?"teal.300":void 0,borderRadius:4,children:[p.jsxs(an,{textAlign:"left",gap:0,children:[p.jsx(gt,{fontWeight:"500",children:h.name??"untitled"}),p.jsxs(gt,{color:"GrayText",fontSize:"sm",children:["Created: ",na(h.createTime)]})]}),p.jsxs($n,{alignItems:"center",gap:2,children:[p.jsx(Oe,{size:"sm",onClick:()=>{if(r){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}ye.loadGraphData(JSON.parse(h.json)),S==null||S.updateFlow(n,{lastSavedJson:h.json,json:h.json}),e({title:`Switched to version "${h.name}"`,status:"success",duration:3e3,isClosable:!0}),t()},children:"Load"}),p.jsx(lh,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{b(h.id)}})]})]},h.id))})}),p.jsxs(eo,{children:[p.jsx(gt,{mb:4,children:"All the saved changes of this workflow"}),p.jsx(an,{divider:p.jsx(Yr,{}),spacing:2,children:l==null?void 0:l.map(h=>p.jsxs(Oe,{size:"sm",variant:"ghost",onClick:()=>{if(r){alert("You have unsaved changes, please save or discard your changes to proceed switching version, in case losing your changes.");return}ye.loadGraphData(JSON.parse(h.json)),S==null||S.updateFlow(n,{lastSavedJson:h.json}),t()},isActive:h.id===a,children:["Saved at ",na(h.createTime,!0)]},h.id))})]})]})]})})]})}function uh({workflowId:t,onClose:e}){const[n,r]=v.useState(""),[o,s]=v.useState(""),a=l=>{r(l.target.value),o&&s("")},i=async()=>{const l=n.trim();if(r(l),(await(xe==null?void 0:xe.listByWorkflowID(t))??[]).some(c=>c.name===l))s("The name is duplicated, please modify it and submit again.");else{const c=JSON.stringify(ye.graph.serialize());await(xe==null?void 0:xe.add({name:n,workflowID:t,createTime:Date.now(),json:c})),e()}};return p.jsxs(Bo,{isOpen:!0,onClose:e,children:[p.jsx(Wo,{}),p.jsxs(Ko,{children:[p.jsx($o,{children:"Create Version"}),p.jsx(Uo,{}),p.jsx(zo,{children:p.jsxs(br,{isInvalid:!!o,children:[p.jsx(_r,{children:"Name"}),p.jsx(En,{value:n,onChange:a,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&i()}}),o&&p.jsx(xr,{children:o})]})}),p.jsxs(qo,{children:[p.jsx(Oe,{colorScheme:"teal",mr:3,onClick:i,isDisabled:!n||!!o,children:"Create"}),p.jsx(Oe,{onClick:e,children:"Cancel"})]})]})]})}function dh({options:t,menuButton:e,isOpen:n,onClose:r}){const o=v.useRef(null);return Gl({ref:o,handler:()=>r()}),p.jsxs(it,{position:"relative",children:[p.jsx(it,{children:e}),n&&p.jsx(it,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function Ki({menuButton:t,menuContent:e,onClose:n}){const r=v.useRef(),[o,s]=v.useState(!1),a=()=>{r.current=setTimeout(()=>s(!1),400)},i=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return p.jsx(dh,{isOpen:o,onClose:a,menuButton:p.jsx(it,{"aria-label":"menu",onClick:i,onMouseEnter:i,onMouseLeave:a,children:t}),options:p.jsx(os,{isOpen:!0,children:p.jsx(ss,{minWidth:150,zIndex:1e3,onMouseEnter:i,onMouseLeave:a,children:e})})})}const fh=v.lazy(()=>wr(()=>import("./ShareDialog-TS-2UrPz.js"),__vite__mapDeps([0,1,2,3])));function hh(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r}=v.useContext(en),[o,s]=v.useState(!1),[a,i]=v.useState(!1),[l,u]=v.useState(!1),[c,d]=v.useState(""),[f,m]=v.useState(""),[b,h]=v.useState(),[w,g]=v.useState(""),[y,_]=v.useState(!1);v.useEffect(()=>{t&&(S==null||S.get(t).then(I=>{d((I==null?void 0:I.name)??""),h(I)})),z==null||z.getSetting("shortcuts").then(I=>{g(I==null?void 0:I.save)})},[t]);const k=I=>{d(I.target.value),f&&m("")},E=async()=>{if(!t){alert("Flow ID is required");return}const I=JSON.stringify(ye.graph.serialize()),D=await(S==null?void 0:S.createFlow({json:I,lastSavedJson:I,name:c,parentFolderID:b==null?void 0:b.parentFolderID}));D&&await e(D.id,!0),C()},C=()=>{i(!1)},x=v.useCallback(async()=>{const I=t?await(S==null?void 0:S.get(t)):null;if(!I){alert("Workspace does not exist");return}const D=new Blob([I.json],{type:"application/json"}),P=URL.createObjectURL(D),N=document.createElement("a");N.href=P,N.download=`${I.name}.json`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(P)},[t]);return p.jsxs(p.Fragment,{children:[p.jsx(Ki,{menuButton:p.jsx(il,{children:p.jsxs(Oe,{px:1,height:"29px","aria-label":"menu",size:"sm",colorScheme:"gray",backgroundColor:"gray.700",children:["File",p.jsx(zf,{size:20})]})}),menuContent:p.jsx(os,{isOpen:!0,children:p.jsxs(ss,{minWidth:150,zIndex:1e3,children:[p.jsx(rt,{onClick:r,icon:p.jsx(Ro,{size:20}),iconSpacing:1,command:w,children:"Save"}),p.jsx(bt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:p.jsx(rt,{onClick:n,icon:p.jsx(Uf,{size:20}),iconSpacing:1,isDisabled:(b==null?void 0:b.lastSavedJson)==null,children:"Discard unsaved changes"})}),p.jsx(rt,{onClick:x,icon:p.jsx(Hf,{size:20}),iconSpacing:1,children:"Download"}),p.jsx(rt,{onClick:()=>i(!0),icon:p.jsx(Ro,{size:20}),iconSpacing:1,children:"Save As"}),p.jsx(rt,{onClick:()=>s(!0),icon:p.jsx(sh,{size:20}),iconSpacing:1,children:"Create Version"}),p.jsx(rt,{onClick:()=>u(!0),icon:p.jsx(Xf,{size:20}),iconSpacing:1,children:"Versions History"}),p.jsx(rt,{onClick:()=>_(!0),icon:p.jsx(nh,{size:20}),iconSpacing:1,children:"Share"})]})})}),y&&p.jsx(fh,{onClose:()=>_(!1)}),l&&p.jsx(ch,{onClose:()=>u(!1)}),a&&p.jsxs(Bo,{isOpen:!0,onClose:C,children:[p.jsx(Wo,{}),p.jsxs(Ko,{children:[p.jsx($o,{children:"Save As"}),p.jsx(Uo,{}),p.jsx(zo,{children:p.jsxs(br,{isInvalid:!!f,children:[p.jsx(_r,{children:"Workflow name"}),p.jsx(En,{value:c,onChange:k,autoFocus:!0,onKeyUp:I=>{I.code==="Enter"&&!f&&c&&E()}}),f&&p.jsx(xr,{children:f})]})}),p.jsxs(qo,{children:[p.jsx(Oe,{colorScheme:"teal",mr:3,onClick:E,isDisabled:!c||!!f,children:"Save"}),p.jsx(Oe,{onClick:C,children:"Cancel"})]})]})]}),o&&p.jsx(uh,{workflowId:t,onClose:()=>s(!1)})]})}function ph({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=Zl(),{curFlowID:a}=v.useContext(en),[i,l]=v.useState(t),[u,c]=v.useState(""),d=()=>{l(t),o()},f=h=>{l(h.target.value),u&&c("")},m=async()=>{if(a){const h=i.trim();if(l(h),t===h)return b();const w=await(S==null?void 0:S.listAll())??[];(w==null?void 0:w.map(y=>y.name)).includes(h)?c("The name is duplicated, please modify it and submit again."):(await(S==null?void 0:S.updateFlow(a,{name:h})),e(h),b())}},b=()=>{c(""),s()};return a==null?null:p.jsxs(mt,{children:[p.jsx(bt,{label:t,placement:"bottom",children:p.jsxs(gt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[p.jsx("div",{style:{width:8,display:"inline-block"},children:p.jsx(gt,{as:"span",children:n&&"* "})}),t]})}),p.jsxs(Bo,{isOpen:r,onClose:b,children:[p.jsx(Wo,{}),p.jsxs(Ko,{children:[p.jsx($o,{children:"Edit workflow name"}),p.jsx(Uo,{}),p.jsx(zo,{children:p.jsxs(br,{isInvalid:!!u,children:[p.jsx(_r,{children:"Workflow name"}),p.jsx(En,{value:i,onChange:f,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!u&&i&&m()}}),u&&p.jsx(xr,{children:u})]})}),p.jsxs(qo,{children:[p.jsx(Oe,{colorScheme:"teal",mr:3,onClick:m,isDisabled:!i||!!u,children:"Save"}),p.jsx(Oe,{onClick:b,children:"Cancel"})]})]})]})]})}function Kh(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const $h=[{label:"Private",value:"PRIVATE",icon:p.jsx(Qf,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:p.jsx(Zf,{})},{label:"Public",value:"PUBLIC",icon:p.jsx(ah,{})}],Uh=()=>{const t=ye.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 a in s){const i=s[a];Array.isArray(i[0])&&(i[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function mh(t){const e=t.cloudURL;if(!e)throw Error("cloudURL is required");const r=new URL(e).origin;return fetch(r+`/api/getWorkflow?id=${t.cloudID}`).then(o=>o.json()).then(o=>{var a;return((a=o.data)==null?void 0:a.privacy)??"PRIVATE"})}function vh({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")),p.jsx("span",{children:n})}function yh({}){const[t,e]=v.useState(),[n,r]=v.useState(),{curFlowID:o}=v.useContext(en);return v.useEffect(()=>{o&&(S==null||S.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudURL),mh(s).then(a=>{r(a)})):e(void 0)}))},[o]),t?p.jsx(p.Fragment,{children:p.jsx(Ki,{menuButton:p.jsx(Oe,{onClick:()=>{var s;window.open((s=S==null?void 0:S.curWorkflow)==null?void 0:s.cloudURL)},"aria-label":"Shared",size:"xs",iconSpacing:"2px",leftIcon:p.jsx(qf,{}),height:"26px",px:1,children:n?p.jsx(vh,{privacy:n}):"Shared"}),menuContent:p.jsxs(mt,{width:"200px",p:1,color:"blue.400",children:[p.jsx(xa,{href:t,noOfLines:1,isExternal:!0,children:t}),p.jsx(Ut,{size:"xs",variant:"ghost",icon:p.jsx(Vf,{size:19}),"aria-label":"copy link"})]})})}):null}function gh({updatePanelPosition:t,positionStyle:e,curFlowName:n,setCurFlowName:r}){const{isDirty:o,loadNewWorkflow:s,saveCurWorkflow:a,setRoute:i,curFlowID:l}=v.useContext(en);return p.jsx(Rf,{onDragEnd:u=>{t({top:u.y,left:u.x},!0)},dragIconId:"dragPanelIcon",children:p.jsxs(mt,{style:{padding:2,position:"fixed",...e},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[p.jsx(Oe,{size:"sm","aria-label":"workspace folder",onClick:()=>i("recentFlows"),px:2,children:p.jsxs(mt,{gap:1,children:[p.jsx(Gf,{size:21}),p.jsx(oh,{size:8})]})}),p.jsx(bt,{label:"New workflow",children:p.jsx(Oe,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",onClick:()=>s(),px:2,py:2,children:p.jsx(mt,{gap:0,children:p.jsx(th,{size:16,color:"white"})})})}),p.jsx(ph,{isDirty:o,displayName:n??"",updateFlowName:u=>{r(u),requestAnimationFrame(()=>{t()})}}),l&&p.jsxs(mt,{gap:"4px",children:[p.jsx(bt,{label:"Open gallery",children:p.jsx(Ut,{onClick:()=>i("gallery"),icon:p.jsx(eh,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),p.jsx(hh,{})]}),p.jsx(yh,{}),l&&o?p.jsx(bt,{label:"Save workflow",children:p.jsx(Ut,{onClick:a,icon:p.jsx(Ro,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):p.jsx("div",{style:{width:1}}),p.jsx(Yf,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})})}const wh=Vo.lazy(()=>wr(()=>import("./RecentFilesDrawer-5V6-n8KY.js"),__vite__mapDeps([4,1,3,5,2,6,7]))),bh=Vo.lazy(()=>wr(()=>import("./GalleryModal-u2j2EpOc.js"),__vite__mapDeps([8,1,7,5,2,6]))),xh=Vo.lazy(()=>wr(()=>import("./ModelManagerTopbar-SdEpIAUx.js").then(t=>t.M),__vite__mapDeps([9,1,5,2,10]))),_h=["download_progress","download_error","model_list"];function kh(){const[t,e]=v.useState(null),[n,r]=v.useState("root"),[o,s]=v.useState(!0),[a,i]=v.useState(null),l=v.useRef(null),[u,c]=v.useState(),[d,f]=v.useState(!1),m=v.useRef(null),{showDialog:b}=ll(),[h,w]=v.useState(!1);v.useRef(!1);const g=v.useRef(0),y=v.useRef("hide"),_=v.useCallback(async()=>{if(l.current){const j=JSON.stringify(ye.graph.serialize());await Promise.all([S==null?void 0:S.updateFlow(l.current,{lastSavedJson:j,json:j}),Ve==null?void 0:Ve.create({workflowID:l.current,json:j})])}},[]),k=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(S==null?void 0:S.delete(l.current)),C(null,""))},E=async()=>{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.")&&l.current){const R=await(S==null?void 0:S.get(l.current));R&&R.lastSavedJson&&await ye.loadGraphData(JSON.parse(R.lastSavedJson))}},C=(j,R)=>{if(l.current=j,i(j),e(R),S==null||S.updateCurWorkflowID(j),j==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ra()){const F=Ti(j);window.location.hash=F,document.title=R+" - ComfyUI"}else localStorage.setItem("curFlowID",j),document.title="ComfyUI - "+R},x=async()=>{I(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Ff(),await(z==null?void 0:z.getSetting("topBarStyle").then(F=>{O(F,!1)}))}catch(F){console.error("error loading db",F)}s(!1);let j=null;if(j=ra(),j==null&&(j=localStorage.getItem("curFlowID")),j&&N(j),localStorage.getItem("REWRITTEN_ALL_LOCAL_DISK_FILE")==="true"?await Mi():(await Af(),localStorage.setItem("REWRITTEN_ALL_LOCAL_DISK_FILE","true")),await(z==null?void 0:z.getSetting("twoWaySync"))){const F=await(z==null?void 0:z.getSetting("myWorkflowsDir")),W=await(S==null?void 0:S.listAll()),U=W&&W.map(te=>te.id)||[],q=await Ed(F,U);if(!q||q.length===0)return;await Ri(q)}},I=()=>{_h.forEach(j=>{Es.addEventListener(j,()=>null)})},D=async()=>{if(l.current!=null){const j=await(S==null?void 0:S.get(l.current));return!!j&&P(j)}return!1},P=j=>{if(j.lastSavedJson==null)return!0;const R=ye.graph.serialize()??{};let F={};try{F=j!=null&&j.lastSavedJson?JSON.parse(j==null?void 0:j.lastSavedJson):{}}catch(U){console.error("error parsing json",U)}return!(JSON.stringify(R)===JSON.stringify(F))},N=async j=>{if(ye.graph==null){console.error("app.graph is null cannot load workflow");return}const R=await(S==null?void 0:S.get(j));if(R==null){alert("Error: Workflow not found! id: "+j),C(null,"");return}C(j,R.name),ye.ui.dialog.close(),ye.loadGraphData(JSON.parse(R.json)),r("root")},K=async(j,R=!1)=>{if(j===null){C(null,""),ye.graph.clear();return}if((await(z==null?void 0:z.getSetting("autoSave"))??!0)||!d||R){N(j);return}T(j)},T=async j=>{var F,W;const R=[j?{label:"Open in new tab",icon:p.jsx(Jf,{}),onClick:()=>{Nf(j)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await _(),j&&N(j)}}];((F=S==null?void 0:S.curWorkflow)==null?void 0:F.lastSavedJson)!=null?R.push({label:"Discard",colorScheme:"red",onClick:async()=>{await E(),j&&N(j)}}):R.push({label:"Delete",colorScheme:"red",onClick:async()=>{await k(),j&&N(j)}}),b(`Please save or discard your changes to "${(W=S==null?void 0:S.curWorkflow)==null?void 0:W.name}" before leaving, or your changes will be lost.`,R)},B=async j=>{const R=(j==null?void 0:j.json)??JSON.stringify(Po),F=await(S==null?void 0:S.createFlow({json:R,name:j==null?void 0:j.name}));F&&await K(F.id),r("root")},Z=async(j,R=!1)=>{const F=j.split("/").pop()??j;R?_():B({name:F});const W=await fetch(jf(j)),U=await W.blob(),q=new File([U],F,{type:W.headers.get("Content-Type")||""});await ye.handleFile(q),r("root")},$=async(j,R)=>{const F=await(S==null?void 0:S.get(j));if(F==null)return;const W=await(S==null?void 0:S.createFlow({json:F.json,lastSavedJson:F.lastSavedJson,name:R||F.name,parentFolderID:F.parentFolderID,tags:F.tags}));W&&await K(W.id)},O=v.useCallback((j,R=!1)=>{const{top:F=0,left:W=0}=u||{};let{top:U=0,left:q=0}=j??{};U+=F,q+=W;const te=document.documentElement.clientWidth,oe=document.documentElement.clientHeight,ie=document.getElementById("workspaceManagerPanel"),be=(ie==null?void 0:ie.offsetWidth)||392;U+36>oe&&(U=oe-36),q+be>=te&&(q=te-be),c({top:Math.max(0,U),left:Math.max(0,q)}),R&&(z==null||z.upsert({topBarStyle:{top:U,left:q}}))},[u]),H=async j=>{await Of(j)&&_()},G=v.useCallback(j=>{if(l.current==null)return;let R=j.filename;j.subfolder!=null&&j.subfolder!==""&&(R=j.subfolder+"/"+R),Ct==null||Ct.create({workflowID:l.current,localPath:R})},[]),de=v.useCallback(()=>{r("root")},[]);return v.useEffect(()=>{x(),w(!0),g.current=setInterval(async()=>{const q=await(z==null?void 0:z.getSetting("autoSave"))??!0;if(l.current!=null&&q){const te=await(S==null?void 0:S.latestVersionCheck());if(y.current!=="disabled"&&!te)y.current="show",b(`This notification is to inform you that it appears you've opened the same workflow in multiple tabs. If all tabs are set to auto-save, this may lead to conflicts and potential data loss. - -You might want to consider disabling auto-save to prevent this. We will remind you to save changes if you leave a page with unsaved work.`,[{label:"Do Not Remind Again",onClick:()=>{y.current="disabled"}},{label:"Disable Auto-Save",colorScheme:"teal",onClick:()=>{z==null||z.upsert({autoSave:!1})}}],!0);else{const oe=JSON.stringify(ye.graph.serialize());oe!=null&&await(S==null?void 0:S.updateFlow(l.current,{json:oe}))}}D().then(te=>{f(te)})},1e3),window.addEventListener("keydown",H);const j=document.getElementById("comfy-file-input"),R=async()=>{if(j&&j.files&&j.files.length>0){const q=await(S==null?void 0:S.createFlow({name:j.files[0].name,json:JSON.stringify(Po)}));q&&C(q.id,q.name??"Unknown name")}};j==null||j.addEventListener("change",R);const F=q=>{const te=(z==null?void 0:z.autoSave)??!0,oe=!!(S!=null&&S.curWorkflow)&&P(S==null?void 0:S.curWorkflow);!te&&oe&&(q.preventDefault(),q.returnValue="You have unsaved changes!",T())};window.addEventListener("beforeunload",F);const W=q=>{var te,oe,ie,be,Ee,Q;(ie=(oe=(te=q.detail)==null?void 0:te.output)==null?void 0:oe.images)==null||ie.forEach(me=>{me.type==="output"&&G(me)}),(Q=(Ee=(be=q.detail)==null?void 0:be.output)==null?void 0:Ee.gifs)==null||Q.forEach(me=>{me.type==="output"&&G(me)})};Es.addEventListener("executed",W);const U=async q=>{var ie,be;const te=(be=(ie=q.dataTransfer)==null?void 0:ie.files[0])==null?void 0:be.name;if(!(await(z==null?void 0:z.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&te){const Ee=await(S==null?void 0:S.createFlow({name:te}));Ee&&C(Ee.id,Ee.name)}};return ye.canvasEl.addEventListener("drop",U),()=>{window.removeEventListener("keydown",H),window.removeEventListener("change",R),window.removeEventListener("beforeunload",F),window.removeEventListener("executed",W),ye.canvasEl.removeEventListener("drop",U),clearInterval(g.current)}},[]),o||!u?null:p.jsx(en.Provider,{value:{curFlowID:a,onDuplicateWorkflow:$,loadWorkflowID:K,discardUnsavedChanges:E,saveCurWorkflow:_,isDirty:d,loadNewWorkflow:B,loadFilePath:Z,setRoute:r},children:p.jsx("div",{ref:m,className:"workspace_manager",children:p.jsx(la,{containerRef:m,children:p.jsxs(it,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Ef,draggable:!1,children:[p.jsx(gh,{curFlowName:t,setCurFlowName:e,updatePanelPosition:O,positionStyle:u}),h&&p.jsx(v.Suspense,{children:p.jsx(xh,{})}),h&&n==="recentFlows"&&p.jsx(v.Suspense,{children:p.jsx(wh,{onClose:de,onClickNewFlow:()=>{B(),r("root")}})}),n==="gallery"&&p.jsx(bh,{onclose:()=>r("root")})]})})})})}const zh=Object.freeze(Object.defineProperty({__proto__:null,default:kh},Symbol.toStringTag,{value:"Module"}));export{Va as $,zf as A,it as B,Rh as C,lh as D,Gf as E,$n as F,ee as G,mt as H,Ut as I,br as J,_r as K,xr as L,Ka as M,th as N,Po as O,Th as P,Zn as Q,Wh as R,zu as S,gt as T,Bh as U,Mh as V,Nl as W,Ua as X,$a as Y,Ja as Z,za as _,Sh as a,qa as a0,en as a1,Nf as a2,Jf as a3,pt as a4,Cl as a5,Ef as a6,Nh as a7,Sf as a8,Lh as a9,Vf as aa,xa as ab,Ct as ac,ka as ad,ec as ae,fl as af,X as ag,Fh as ah,Zl as ai,Ah as aj,Rf as ak,Yf as al,Al as am,Yt as an,qf as ao,$h as ap,xe as aq,Kh as ar,Uh as as,mh as at,vh as au,kl as av,zh as aw,Ql as b,jh as c,Oh as d,Ph as e,Xt as f,Er as g,pe as h,rh as i,an as j,En as k,z as l,hl as m,Yr as n,bt as o,Cd as p,os as q,ss as r,rt as s,Qn as t,Cr as u,Mi as v,Hf as w,S as x,ih as y,na as z}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-TS-2UrPz.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-RPO2WXNL-dt-e86vT.js","workspace_web/RecentFilesDrawer-5V6-n8KY.js","workspace_web/chunk-JARCRF6W-yaymqCZ5.js","workspace_web/chunk-NTCQBYKE-7NPzADNj.js","workspace_web/MediaPreview-Dl36eUT2.js","workspace_web/GalleryModal-u2j2EpOc.js","workspace_web/ModelManagerTopbar-SdEpIAUx.js","workspace_web/assets/ModelManagerTopbar--iv3sdjQ.css"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file diff --git a/dist/workspace_web/GalleryModal-SJS3r_wH.js b/dist/workspace_web/GalleryModal-SJS3r_wH.js new file mode 100644 index 0000000..9b72abf --- /dev/null +++ b/dist/workspace_web/GalleryModal-SJS3r_wH.js @@ -0,0 +1 @@ +import{f as se,l as te,o as ne,j as t,g as oe,h as le,r as u,K as ie,F as ce,B as N,U as re,M as ae,L as he,N as xe,O as ue,Q as de,R as ge}from"./input.js";import{W as fe,h as T,F as j,a9 as je,I as w,B as J,k as L,T as z,o as C,w as Z,z as Y,a1 as Q,j as we,H as S,i as ve,aa as X,x as _,ab as ye,y as pe}from"./App-09wdM9e8.js";import{I as be,i as Ie,a as Ce,b as ke,g as Pe,S as ze,M as Oe}from"./MediaPreview-nO-IKtd3.js";import{I as Me,C as q}from"./chunk-JARCRF6W-1wZ_35Xk.js";import{I as V,L as E}from"./IconCopy-48H4n38O.js";import{V as D}from"./chunk-NTCQBYKE-NnaP5ESt.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";function Se(s,e=[]){const n=Object.assign({},s);for(const l of e)l in n&&delete n[l];return n}var Fe=["h","minH","height","minHeight"],B=se((s,e)=>{const n=te("Textarea",s),{className:l,rows:o,...i}=ne(s),c=fe(i),d=o?Se(n,Fe):n;return t.jsx(oe.textarea,{ref:e,rows:o,...c,className:le("chakra-textarea",l),__css:d})});B.displayName="Textarea";var Te=T("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]),_e=T("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Ee=T("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"}]]),Ne=T("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 Be=({setMediaAct:s,media:e,currentNum:n})=>{const[l,o]=u.useState(0);u.useEffect(()=>{n!==void 0&&o(n)},[n]);const i=r=>{const h=(l+r+e.length)%e.length;o(h),s&&s(e[h])},c={width:"100%",height:"100%"},d={enter:r=>({x:r>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:r=>({x:r<0?500:-500,opacity:1})};return t.jsxs(j,{justifyContent:"center",alignItems:"center",position:"relative",width:c.width,height:c.height,overflow:"hidden",children:[t.jsx(ie,{custom:l,children:e.map((r,h)=>t.jsx(ce.div,{custom:h-l,variants:d,initial:"enter",animate:"center",exit:"exit",transition:{x:{type:"spring",stiffness:300,damping:30},opacity:{duration:.2}},style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%",display:h===l?"block":"none"},onClick:()=>{window.open(r.imageUrl)},children:je(r.imageUrl)?t.jsx(Me,{src:r.imageUrl,alt:`image-${r.id}`,width:"100%",height:"100%",objectFit:"contain"}):t.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:r.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:t.jsx("track",{kind:"captions"})})},r.id))}),t.jsx(w,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:t.jsx(_e,{}),onClick:()=>i(-1),position:"absolute",left:"0",zIndex:"2"}),t.jsx(w,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:t.jsx(be,{}),onClick:()=>i(1),position:"absolute",right:"0",zIndex:"2"})]})};function Ae(s){const e=s.split(".").pop();return fetch(s).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const l=s.split("/").pop()??"",o=new File([n],l);if(Ie(s))return Ce(o);if(e==="webp")return ke(o);const i=await Pe(o),c=JSON.parse(i==null?void 0:i.prompt),d=JSON.parse(i==null?void 0:i.workflow);return{prompt:c,workflow:d}})}const M=s=>{if(typeof s=="string")return s};function F(s){navigator.clipboard.writeText(s).then(function(){}).catch(function(e){console.error("Unable to copy to clipboard: ",e)})}function ee(s,e){var h,g,f,y,v,p,b,k,a,x,A,K,G,$,U,m,H,R;const n=M((y=(f=s==null?void 0:s[(g=(h=e==null?void 0:e.inputs)==null?void 0:h.model)==null?void 0:g[0]])==null?void 0:f.inputs)==null?void 0:y.ckpt_name)??M((b=(p=s==null?void 0:s[((v=Object.keys(s))==null?void 0:v.find(O=>{var I,P;return(P=(I=s[O])==null?void 0:I.inputs)==null?void 0:P.ckpt_name}))??""])==null?void 0:p.inputs)==null?void 0:b.ckpt_name)??"",l=M((A=(x=s==null?void 0:s[(a=(k=e==null?void 0:e.inputs)==null?void 0:k.positive)==null?void 0:a[0]])==null?void 0:x.inputs)==null?void 0:A.text),o=M((U=($=s==null?void 0:s[(G=(K=e==null?void 0:e.inputs)==null?void 0:K.negative)==null?void 0:G[0]])==null?void 0:$.inputs)==null?void 0:U.text),i=["seed","sampler_name","scheduler","steps","cfg"].reduce((O,I)=>{var P,W;return(P=e==null?void 0:e.inputs)!=null&&P[I]?{...O,[I]:(W=e==null?void 0:e.inputs)==null?void 0:W[I]}:O},{}),c=(R=s==null?void 0:s[(H=(m=e==null?void 0:e.inputs)==null?void 0:m.latent_image)==null?void 0:H[0]])==null?void 0:R.inputs,d=c==null?void 0:c.width,r=c==null?void 0:c.height;return{ckptName:n,positive:l,negative:o,...i,width:d,height:r}}const Ke=s=>{var o;const{prompt:e,workflow:n}=s;console.log(n);const l=e==null?void 0:e[((o=Object.keys(e))==null?void 0:o.find(i=>e[i].class_type==="KSampler"))??""];return ee(e,l)},Ge=({metaData:s})=>{const e=Ke(s);return t.jsxs(D,{spacing:2,align:"stretch",children:[t.jsx(J,{children:t.jsx(N,{size:"sm",onClick:()=>F(JSON.stringify(e)),children:"Copy all"})}),Object.keys(e??{}).map(n=>{var l,o;return t.jsxs(j,{gap:2,children:[t.jsxs(j,{gap:1,alignItems:"center",flexBasis:"200px",children:[n,t.jsx(w,{size:"xm",onClick:()=>F((e==null?void 0:e[n])??""),"aria-label":"copy text",icon:t.jsx(V,{}),variant:"ghost"})]}),(l=e==null?void 0:e[n])!=null&&l.length&&((o=e==null?void 0:e[n])==null?void 0:o.length)>300?t.jsx(B,{readOnly:!0,value:e==null?void 0:e[n]}):t.jsx(L,{readOnly:!0,value:e==null?void 0:e[n]})]},`meta${n}`)})]})},$e=s=>{var e,n,l;return((l=(n=(e=Object.keys(s==null?void 0:s.prompt))==null?void 0:e.filter)==null?void 0:n.call(e,o=>{var i,c;return((c=(i=s==null?void 0:s.prompt)==null?void 0:i[o])==null?void 0:c.class_type)==="KSampler"}))==null?void 0:l.length)>1},Ue=s=>{const{prompt:e}=s,n=Object.keys(e);return(n==null?void 0:n.filter(o=>{var i;return((i=e==null?void 0:e[o])==null?void 0:i.class_type)==="KSampler"})).reduce((o,i,c)=>{const d=e==null?void 0:e[i],r=ee(e,d),h=Object.keys(r).reduce((g,f)=>({...g,[`${f}_${c+1}`]:r==null?void 0:r[f]}),{});return{...o,...h}},{})},me=({metaData:s})=>{var n;const e=Ue(s);return t.jsxs(D,{spacing:2,align:"stretch",children:[t.jsx(J,{children:t.jsx(N,{size:"sm",onClick:()=>F(JSON.stringify(e)),children:"Copy all"})}),(n=Object.keys(e??{}))==null?void 0:n.filter(l=>!!(e!=null&&e[l])).map(l=>{var o,i;return t.jsxs(j,{gap:2,children:[t.jsxs(j,{gap:1,alignItems:"center",flexBasis:"200px",children:[l,t.jsx(w,{size:"xm",onClick:()=>F((e==null?void 0:e[l])??""),"aria-label":"copy text",icon:t.jsx(V,{}),variant:"ghost"})]}),(o=e==null?void 0:e[l])!=null&&o.length&&((i=e==null?void 0:e[l])==null?void 0:i.length)>300?t.jsx(B,{readOnly:!0,value:e==null?void 0:e[l]}):t.jsx(L,{readOnly:!0,value:e==null?void 0:e[l]})]},`meta${l}`)})]})},He=({media:s})=>{const[e,n]=u.useState(),l=async o=>{try{const i=await Ae(`/workspace/view_media?filename=${o.localPath}`);n(i)}catch(i){console.log(i)}};return u.useEffect(()=>{s&&l(s)},[s]),t.jsxs(j,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[t.jsxs(ze,{alignItems:"center",columns:2,spacing:2,children:[t.jsxs(j,{alignItems:"center",gap:1,children:[t.jsx(z,{children:s==null?void 0:s.localPath}),t.jsx(C,{label:"Donwload image from gallery",children:t.jsx(E,{href:`/workspace/view_media?filename=${s==null?void 0:s.localPath}`,download:s==null?void 0:s.localPath,children:t.jsx(w,{size:"sm",icon:t.jsx(Z,{size:19}),"aria-label":"donwload image from gallery"})})})]}),t.jsxs(j,{gap:1,alignItems:"center",children:[t.jsx(z,{children:"Create Time:"}),t.jsx(z,{children:Y((s==null?void 0:s.createTime)??0,!0)})]})]}),(()=>{if(!s||!e)return null;const o={metaData:e,media:s};return $e(e)&&t.jsx(me,{...o})||t.jsx(Ge,{...o})})()]})},Re=({mediaList:s,media:e})=>{const[n,l]=u.useState();return u.useEffect(()=>{e&&l(e)},[e]),t.jsxs(j,{gap:3,h:"100%",children:[t.jsx(j,{flex:1,children:t.jsx(Be,{media:s.map(o=>({id:o.id,imageUrl:`/workspace/view_media?filename=${o.localPath}`})),currentNum:s==null?void 0:s.findIndex(o=>o.id===(n==null?void 0:n.id)),setMediaAct:o=>l(s==null?void 0:s.find(i=>i.id===o.id))})}),t.jsx(He,{media:n})]})},We=({media:s,isSelecting:e,selectedID:n,onClickMedia:l,onRefreshImagesList:o,coverPath:i,setCoverPath:c})=>{const{curFlowID:r,loadFilePath:h}=u.useContext(Q),{showDialog:g}=re();if(s.localPath==null)return null;const f=i!=null&&i===s.localPath;if(r==null)return null;const y=t.jsxs(E,{isExternal:!0,onClick:()=>l(s),position:"relative",children:[e&&t.jsx(q,{isChecked:n.includes(s.id),position:"absolute",top:2,left:2}),t.jsx(Oe,{mediaLocalPath:s.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!0})]});return t.jsxs(we,{width:180,mb:2,children:[t.jsx(C,{label:Y(s.createTime,!0),children:y}),t.jsx(C,{label:s.localPath,children:t.jsx(z,{color:"GrayText",noOfLines:1,children:s.localPath})}),t.jsxs(S,{hidden:e,gap:0,children:[t.jsx(C,{label:"Set as cover",children:t.jsx(w,{size:"sm",variant:"ghost",icon:f?t.jsx(Ee,{size:19}):t.jsx(Ne,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=_)==null||v.updateFlow(r,{coverMediaPath:s.localPath}),c(s.localPath)}})}),t.jsx(N,{flexGrow:1,onClick:()=>g("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{h(s.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>h(s.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),t.jsx(C,{label:"Donwload image from gallery",children:t.jsx(E,{href:`/workspace/view_media?filename=${s.localPath}`,download:s.localPath,children:t.jsx(w,{size:"sm",variant:"ghost",icon:t.jsx(Z,{size:19}),"aria-label":"donwload image from gallery"})})}),t.jsx(C,{label:"Remove image from gallery",children:t.jsx(w,{size:"sm",variant:"ghost",icon:t.jsx(ve,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var p,b;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((p=X)==null?void 0:p.delete(s.id)),f&&(await((b=_)==null?void 0:b.updateFlow(r,{coverMediaPath:void 0})),c("")),o())}})})]})]})},Je=We;function ss({onclose:s}){const{curFlowID:e}=u.useContext(Q),[n,l]=u.useState(""),[o,i]=u.useState([]),[c,d]=u.useState(!1),[r,h]=u.useState(""),[g,f]=u.useState([]),[y,v]=u.useState(),p=async()=>{var x;if(e==null)return;const a=await((x=X)==null?void 0:x.listByWorkflowID(e));f(a??[])};if(u.useEffect(()=>{var a;p(),e&&((a=_)==null||a.get(e).then(x=>{x&&(l(x.name),x!=null&&x.coverMediaPath&&h(x==null?void 0:x.coverMediaPath))}))},[]),e==null)return null;const b=a=>{if(c){o.includes(a.id)?i(o.filter(x=>x!==a.id)):i([...o,a.id]);return}v(a)},k=g.length>0&&o.length===g.length;return t.jsxs(ae,{isOpen:!0,onClose:s,blockScrollOnMount:!0,children:[t.jsx(he,{}),t.jsxs(xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[t.jsxs(ue,{children:[t.jsx(S,{gap:2,mb:2,children:t.jsxs(ye,{size:"md",mr:2,children:[!!y&&t.jsx(w,{onClick:()=>v(void 0),variant:"ghost",mr:1,"aria-label":"back",icon:t.jsx(Te,{})}),"Gallery - ",n]})}),c&&t.jsxs(S,{gap:3,children:[t.jsx(q,{isChecked:k,onChange:()=>{i(k?[]:g.map(a=>a.id))},children:"All"}),t.jsxs(z,{fontSize:16,children:[o.length," Selected"]}),t.jsx(w,{size:"sm",icon:t.jsx(pe,{size:19}),onClick:()=>d(!1),"aria-label":"cancel"})]})]}),t.jsx(de,{}),t.jsx(ge,{overflowY:"auto",children:y?t.jsx(Re,{mediaList:g,media:y}):t.jsx(S,{wrap:"wrap",children:g.map(a=>t.jsx(Je,{selectedID:o,media:a,isSelecting:c,onClickMedia:b,onRefreshImagesList:p,coverPath:r,setCoverPath:h},a.id))})})]})]})}export{ss as default}; diff --git a/dist/workspace_web/GalleryModal-u2j2EpOc.js b/dist/workspace_web/GalleryModal-u2j2EpOc.js deleted file mode 100644 index f0fa56a..0000000 --- a/dist/workspace_web/GalleryModal-u2j2EpOc.js +++ /dev/null @@ -1 +0,0 @@ -import{f as se,l as te,o as ne,j as t,g as oe,h as le,r as u,K as ie,F as ce,B as N,U as re,M as ae,L as he,N as xe,O as ue,Q as de,R as ge}from"./input.js";import{W as fe,h as T,F as j,a9 as je,I as w,B as J,aa as L,k as Z,T as z,o as C,ab as _,w as Y,z as Q,a1 as X,j as we,H as S,i as ve,ac as q,x as E,ad as ye,y as be}from"./App-iJ8dSmpT.js";import{I as pe,i as Ie,a as Ce,b as ke,g as Pe,S as ze,M as Oe}from"./MediaPreview-Dl36eUT2.js";import{I as Me,C as V}from"./chunk-JARCRF6W-yaymqCZ5.js";import{V as D}from"./chunk-NTCQBYKE-7NPzADNj.js";import"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";function Se(s,e=[]){const n=Object.assign({},s);for(const l of e)l in n&&delete n[l];return n}var Fe=["h","minH","height","minHeight"],B=se((s,e)=>{const n=te("Textarea",s),{className:l,rows:o,...i}=ne(s),c=fe(i),d=o?Se(n,Fe):n;return t.jsx(oe.textarea,{ref:e,rows:o,...c,className:le("chakra-textarea",l),__css:d})});B.displayName="Textarea";var Te=T("arrow-left","IconArrowLeft",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M5 12l6 6",key:"svg-1"}],["path",{d:"M5 12l6 -6",key:"svg-2"}]]),_e=T("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Ee=T("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"}]]),Ne=T("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 Be=({setMediaAct:s,media:e,currentNum:n})=>{const[l,o]=u.useState(0);u.useEffect(()=>{n!==void 0&&o(n)},[n]);const i=r=>{const h=(l+r+e.length)%e.length;o(h),s&&s(e[h])},c={width:"100%",height:"100%"},d={enter:r=>({x:r>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:r=>({x:r<0?500:-500,opacity:1})};return t.jsxs(j,{justifyContent:"center",alignItems:"center",position:"relative",width:c.width,height:c.height,overflow:"hidden",children:[t.jsx(ie,{custom:l,children:e.map((r,h)=>t.jsx(ce.div,{custom:h-l,variants:d,initial:"enter",animate:"center",exit:"exit",transition:{x:{type:"spring",stiffness:300,damping:30},opacity:{duration:.2}},style:{position:"absolute",cursor:"pointer",width:"100%",height:"100%",display:h===l?"block":"none"},onClick:()=>{window.open(r.imageUrl)},children:je(r.imageUrl)?t.jsx(Me,{src:r.imageUrl,alt:`image-${r.id}`,width:"100%",height:"100%",objectFit:"contain"}):t.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:r.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:t.jsx("track",{kind:"captions"})})},r.id))}),t.jsx(w,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:t.jsx(_e,{}),onClick:()=>i(-1),position:"absolute",left:"0",zIndex:"2"}),t.jsx(w,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Next image",icon:t.jsx(pe,{}),onClick:()=>i(1),position:"absolute",right:"0",zIndex:"2"})]})};function Ae(s){const e=s.split(".").pop();return fetch(s).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.blob()}).then(async n=>{const l=s.split("/").pop()??"",o=new File([n],l);if(Ie(s))return Ce(o);if(e==="webp")return ke(o);const i=await Pe(o),c=JSON.parse(i==null?void 0:i.prompt),d=JSON.parse(i==null?void 0:i.workflow);return{prompt:c,workflow:d}})}const M=s=>{if(typeof s=="string")return s};function F(s){navigator.clipboard.writeText(s).then(function(){}).catch(function(e){console.error("Unable to copy to clipboard: ",e)})}function ee(s,e){var h,g,f,y,v,b,p,k,a,x,A,K,$,G,U,H,R,W;const n=M((y=(f=s==null?void 0:s[(g=(h=e==null?void 0:e.inputs)==null?void 0:h.model)==null?void 0:g[0]])==null?void 0:f.inputs)==null?void 0:y.ckpt_name)??M((p=(b=s==null?void 0:s[((v=Object.keys(s))==null?void 0:v.find(O=>{var I,P;return(P=(I=s[O])==null?void 0:I.inputs)==null?void 0:P.ckpt_name}))??""])==null?void 0:b.inputs)==null?void 0:p.ckpt_name)??"",l=M((A=(x=s==null?void 0:s[(a=(k=e==null?void 0:e.inputs)==null?void 0:k.positive)==null?void 0:a[0]])==null?void 0:x.inputs)==null?void 0:A.text),o=M((U=(G=s==null?void 0:s[($=(K=e==null?void 0:e.inputs)==null?void 0:K.negative)==null?void 0:$[0]])==null?void 0:G.inputs)==null?void 0:U.text),i=["seed","sampler_name","scheduler","steps","cfg"].reduce((O,I)=>{var P,m;return(P=e==null?void 0:e.inputs)!=null&&P[I]?{...O,[I]:(m=e==null?void 0:e.inputs)==null?void 0:m[I]}:O},{}),c=(W=s==null?void 0:s[(R=(H=e==null?void 0:e.inputs)==null?void 0:H.latent_image)==null?void 0:R[0]])==null?void 0:W.inputs,d=c==null?void 0:c.width,r=c==null?void 0:c.height;return{ckptName:n,positive:l,negative:o,...i,width:d,height:r}}const Ke=s=>{var o;const{prompt:e,workflow:n}=s;console.log(n);const l=e==null?void 0:e[((o=Object.keys(e))==null?void 0:o.find(i=>e[i].class_type==="KSampler"))??""];return ee(e,l)},$e=({metaData:s})=>{const e=Ke(s);return t.jsxs(D,{spacing:2,align:"stretch",children:[t.jsx(J,{children:t.jsx(N,{size:"sm",onClick:()=>F(JSON.stringify(e)),children:"Copy all"})}),Object.keys(e??{}).map(n=>{var l,o;return t.jsxs(j,{gap:2,children:[t.jsxs(j,{gap:1,alignItems:"center",flexBasis:"200px",children:[n,t.jsx(w,{size:"xm",onClick:()=>F((e==null?void 0:e[n])??""),"aria-label":"copy text",icon:t.jsx(L,{}),variant:"ghost"})]}),(l=e==null?void 0:e[n])!=null&&l.length&&((o=e==null?void 0:e[n])==null?void 0:o.length)>300?t.jsx(B,{readOnly:!0,value:e==null?void 0:e[n]}):t.jsx(Z,{readOnly:!0,value:e==null?void 0:e[n]})]},`meta${n}`)})]})},Ge=s=>{var e,n,l;return((l=(n=(e=Object.keys(s==null?void 0:s.prompt))==null?void 0:e.filter)==null?void 0:n.call(e,o=>{var i,c;return((c=(i=s==null?void 0:s.prompt)==null?void 0:i[o])==null?void 0:c.class_type)==="KSampler"}))==null?void 0:l.length)>1},Ue=s=>{const{prompt:e}=s,n=Object.keys(e);return(n==null?void 0:n.filter(o=>{var i;return((i=e==null?void 0:e[o])==null?void 0:i.class_type)==="KSampler"})).reduce((o,i,c)=>{const d=e==null?void 0:e[i],r=ee(e,d),h=Object.keys(r).reduce((g,f)=>({...g,[`${f}_${c+1}`]:r==null?void 0:r[f]}),{});return{...o,...h}},{})},He=({metaData:s})=>{var n;const e=Ue(s);return t.jsxs(D,{spacing:2,align:"stretch",children:[t.jsx(J,{children:t.jsx(N,{size:"sm",onClick:()=>F(JSON.stringify(e)),children:"Copy all"})}),(n=Object.keys(e??{}))==null?void 0:n.filter(l=>!!(e!=null&&e[l])).map(l=>{var o,i;return t.jsxs(j,{gap:2,children:[t.jsxs(j,{gap:1,alignItems:"center",flexBasis:"200px",children:[l,t.jsx(w,{size:"xm",onClick:()=>F((e==null?void 0:e[l])??""),"aria-label":"copy text",icon:t.jsx(L,{}),variant:"ghost"})]}),(o=e==null?void 0:e[l])!=null&&o.length&&((i=e==null?void 0:e[l])==null?void 0:i.length)>300?t.jsx(B,{readOnly:!0,value:e==null?void 0:e[l]}):t.jsx(Z,{readOnly:!0,value:e==null?void 0:e[l]})]},`meta${l}`)})]})},Re=({media:s})=>{const[e,n]=u.useState(),l=async o=>{try{const i=await Ae(`/workspace/view_media?filename=${o.localPath}`);n(i)}catch(i){console.log(i)}};return u.useEffect(()=>{s&&l(s)},[s]),t.jsxs(j,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[t.jsxs(ze,{alignItems:"center",columns:2,spacing:2,children:[t.jsxs(j,{alignItems:"center",gap:1,children:[t.jsx(z,{children:s==null?void 0:s.localPath}),t.jsx(C,{label:"Donwload image from gallery",children:t.jsx(_,{href:`/workspace/view_media?filename=${s==null?void 0:s.localPath}`,download:s==null?void 0:s.localPath,children:t.jsx(w,{size:"sm",icon:t.jsx(Y,{size:19}),"aria-label":"donwload image from gallery"})})})]}),t.jsxs(j,{gap:1,alignItems:"center",children:[t.jsx(z,{children:"Create Time:"}),t.jsx(z,{children:Q((s==null?void 0:s.createTime)??0,!0)})]})]}),(()=>{if(!s||!e)return null;const o={metaData:e,media:s};return Ge(e)&&t.jsx(He,{...o})||t.jsx($e,{...o})})()]})},We=({mediaList:s,media:e})=>{const[n,l]=u.useState();return u.useEffect(()=>{e&&l(e)},[e]),t.jsxs(j,{gap:3,h:"100%",children:[t.jsx(j,{flex:1,children:t.jsx(Be,{media:s.map(o=>({id:o.id,imageUrl:`/workspace/view_media?filename=${o.localPath}`})),currentNum:s==null?void 0:s.findIndex(o=>o.id===(n==null?void 0:n.id)),setMediaAct:o=>l(s==null?void 0:s.find(i=>i.id===o.id))})}),t.jsx(Re,{media:n})]})},me=({media:s,isSelecting:e,selectedID:n,onClickMedia:l,onRefreshImagesList:o,coverPath:i,setCoverPath:c})=>{const{curFlowID:r,loadFilePath:h}=u.useContext(X),{showDialog:g}=re();if(s.localPath==null)return null;const f=i!=null&&i===s.localPath;if(r==null)return null;const y=t.jsxs(_,{isExternal:!0,onClick:()=>l(s),position:"relative",children:[e&&t.jsx(V,{isChecked:n.includes(s.id),position:"absolute",top:2,left:2}),t.jsx(Oe,{mediaLocalPath:s.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0})]});return t.jsxs(we,{width:180,mb:2,children:[t.jsx(C,{label:Q(s.createTime,!0),children:y}),t.jsx(C,{label:s.localPath,children:t.jsx(z,{color:"GrayText",noOfLines:1,children:s.localPath})}),t.jsxs(S,{hidden:e,gap:0,children:[t.jsx(C,{label:"Set as cover",children:t.jsx(w,{size:"sm",variant:"ghost",icon:f?t.jsx(Ee,{size:19}):t.jsx(Ne,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=E)==null||v.updateFlow(r,{coverMediaPath:s.localPath}),c(s.localPath)}})}),t.jsx(N,{flexGrow:1,onClick:()=>g("How do you want to load this workflow?",[{label:"Load in new workflow",onClick:()=>{h(s.localPath)},colorScheme:"teal"},{label:"Overwrite current workflow",onClick:()=>h(s.localPath,!0),colorScheme:"red"}]),size:"sm",children:"Load"}),t.jsx(C,{label:"Donwload image from gallery",children:t.jsx(_,{href:`/workspace/view_media?filename=${s.localPath}`,download:s.localPath,children:t.jsx(w,{size:"sm",variant:"ghost",icon:t.jsx(Y,{size:19}),"aria-label":"donwload image from gallery"})})}),t.jsx(C,{label:"Remove image from gallery",children:t.jsx(w,{size:"sm",variant:"ghost",icon:t.jsx(ve,{size:19}),"aria-label":"remove image from gallery",colorScheme:"red",onClick:async()=>{var b,p;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((b=q)==null?void 0:b.delete(s.id)),f&&(await((p=E)==null?void 0:p.updateFlow(r,{coverMediaPath:void 0})),c("")),o())}})})]})]})},Je=me;function es({onclose:s}){const{curFlowID:e}=u.useContext(X),[n,l]=u.useState(""),[o,i]=u.useState([]),[c,d]=u.useState(!1),[r,h]=u.useState(""),[g,f]=u.useState([]),[y,v]=u.useState(),b=async()=>{var x;if(e==null)return;const a=await((x=q)==null?void 0:x.listByWorkflowID(e));f(a??[])};if(u.useEffect(()=>{var a;b(),e&&((a=E)==null||a.get(e).then(x=>{x&&(l(x.name),x!=null&&x.coverMediaPath&&h(x==null?void 0:x.coverMediaPath))}))},[]),e==null)return null;const p=a=>{if(c){o.includes(a.id)?i(o.filter(x=>x!==a.id)):i([...o,a.id]);return}v(a)},k=g.length>0&&o.length===g.length;return t.jsxs(ae,{isOpen:!0,onClose:s,blockScrollOnMount:!0,children:[t.jsx(he,{}),t.jsxs(xe,{width:"90%",maxWidth:"90vw",height:"90vh",children:[t.jsxs(ue,{children:[t.jsx(S,{gap:2,mb:2,children:t.jsxs(ye,{size:"md",mr:2,children:[!!y&&t.jsx(w,{onClick:()=>v(void 0),variant:"ghost",mr:1,"aria-label":"back",icon:t.jsx(Te,{})}),"Gallery - ",n]})}),c&&t.jsxs(S,{gap:3,children:[t.jsx(V,{isChecked:k,onChange:()=>{i(k?[]:g.map(a=>a.id))},children:"All"}),t.jsxs(z,{fontSize:16,children:[o.length," Selected"]}),t.jsx(w,{size:"sm",icon:t.jsx(be,{size:19}),onClick:()=>d(!1),"aria-label":"cancel"})]})]}),t.jsx(de,{}),t.jsx(ge,{overflowY:"auto",children:y?t.jsx(We,{mediaList:g,media:y}):t.jsx(S,{wrap:"wrap",children:g.map(a=>t.jsx(Je,{selectedID:o,media:a,isSelecting:c,onClickMedia:p,onRefreshImagesList:b,coverPath:r,setCoverPath:h},a.id))})})]})]})}export{es as default}; diff --git a/dist/workspace_web/IconCopy-48H4n38O.js b/dist/workspace_web/IconCopy-48H4n38O.js new file mode 100644 index 0000000..7c14594 --- /dev/null +++ b/dist/workspace_web/IconCopy-48H4n38O.js @@ -0,0 +1 @@ +import{f as r,l as c,o as i,j as m,g as p,h}from"./input.js";import{h as k}from"./App-09wdM9e8.js";var l=r(function(a,o){const e=c("Link",a),{className:n,isExternal:s,...t}=i(a);return m.jsx(p.a,{target:s?"_blank":void 0,rel:s?"noopener":void 0,ref:o,className:h("chakra-link",n),...t,__css:e})});l.displayName="Link";var d=k("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{d as I,l as L}; diff --git a/dist/workspace_web/InstallMissingModelsButton-iTYBbpS-.js b/dist/workspace_web/InstallMissingModelsButton-7QH17Yv3.js similarity index 76% rename from dist/workspace_web/InstallMissingModelsButton-iTYBbpS-.js rename to dist/workspace_web/InstallMissingModelsButton-7QH17Yv3.js index 7b469ba..d519930 100644 --- a/dist/workspace_web/InstallMissingModelsButton-iTYBbpS-.js +++ b/dist/workspace_web/InstallMissingModelsButton-7QH17Yv3.js @@ -1 +1 @@ -import{r as u,j as e,B as m,P as f}from"./input.js";import{app as c}from"/scripts/app.js";import{G as x,g as j,I as _}from"./ModelManagerTopbar-SdEpIAUx.js";import{T as h,H as v,a3 as g,B as w,a5 as M,a6 as y,av as E,F as I,ad as S}from"./App-iJ8dSmpT.js";import{V as b}from"./chunk-NTCQBYKE-7NPzADNj.js";import{I as k,G as C}from"./chunk-JARCRF6W-yaymqCZ5.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";function z({model:s}){const[l,t]=u.useState([]),o=D(s.received_value),d=async()=>{const n=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${o}&full=true`)).json(),i=[];n.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},p=async()=>{const a=await j(o);t(n=>[...n,...a==null?void 0:a.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return u.useEffect(()=>{d(),p()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(b,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(v,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),l.map(({url:a,name:n,icon:i})=>e.jsx(m,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(a,"_blank")},leftIcon:e.jsx(k,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:n})),e.jsx(m,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${o}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:l}){u.useEffect(()=>(c.canvasEl.addEventListener("click",s),()=>{c.canvasEl.removeEventListener("click",s)}),[]);const t=440;return e.jsx(f,{children:e.jsx(w,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:y,overflowY:"auto",children:[e.jsx(E,{children:e.jsxs(I,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(S,{size:"md",mr:2,children:["Missing Models (",l.length,")"]}),e.jsx(_,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,children:l.map(o=>e.jsx(z,{model:o},o.received_value))})]})})})}function T({}){const[s,l]=u.useState(!1),[t,o]=u.useState([]);return u.useEffect(()=>{const d=c.queuePrompt;c.queuePrompt=async function(){try{await d.apply(c,[...arguments])}finally{const p=c.lastNodeErrors??{};o(Object.values(p).flatMap(a=>a.errors.filter(n=>n.type==="value_not_in_list").map(n=>{const{input_name:i,received_value:r}=n.extra_info;return{class_type:a.class_type,input_name:i,received_value:r}})))}}},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(m,{size:"sm","aria-label":"missing models",px:2,onClick:()=>l(!0),children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>l(!1),missingModels:t})]})}export{T as default}; +import{r as u,j as e,B as m,P as f}from"./input.js";import{app as c}from"/scripts/app.js";import{G as x,g as j,I as _}from"./ModelManagerTopbar-O1ybaI8q.js";import{T as h,H as v,a3 as g,B as w,a5 as M,a6 as y,an as E,F as I,ab as b}from"./App-09wdM9e8.js";import{V as S}from"./chunk-NTCQBYKE-NnaP5ESt.js";import{I as k,G as C}from"./chunk-JARCRF6W-1wZ_35Xk.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";function z({model:s}){const[l,t]=u.useState([]),o=D(s.received_value),p=async()=>{const n=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${o}&full=true`)).json(),i=[];n.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},d=async()=>{const a=await j(o);t(n=>[...n,...a==null?void 0:a.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return u.useEffect(()=>{p(),d()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(S,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(v,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),l.map(({url:a,name:n,icon:i})=>e.jsx(m,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(a,"_blank")},leftIcon:e.jsx(k,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:n})),e.jsx(m,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${o}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:l}){u.useEffect(()=>(c.canvasEl.addEventListener("click",s),()=>{c.canvasEl.removeEventListener("click",s)}),[]);const t=440;return e.jsx(f,{children:e.jsx(w,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:y,overflowY:"auto",children:[e.jsx(E,{children:e.jsxs(I,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",l.length,")"]}),e.jsx(_,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,children:l.map(o=>e.jsx(z,{model:o},o.received_value))})]})})})}function T({}){const[s,l]=u.useState(!1),[t,o]=u.useState([]);return u.useEffect(()=>{const p=c.queuePrompt;c.queuePrompt=async function(){try{await p.apply(c,[...arguments])}finally{const d=c.lastNodeErrors??{};o(Object.values(d).flatMap(a=>a.errors.filter(n=>n.type==="value_not_in_list").map(n=>{const{input_name:i,received_value:r}=n.extra_info;return{class_type:a.class_type,input_name:i,received_value:r}})))}}},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(m,{size:"sm","aria-label":"missing models",px:2,onClick:()=>l(!0),children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>l(!1),missingModels:t})]})}export{T as default}; diff --git a/dist/workspace_web/MediaPreview-Dl36eUT2.js b/dist/workspace_web/MediaPreview-Dl36eUT2.js deleted file mode 100644 index 9f24e63..0000000 --- a/dist/workspace_web/MediaPreview-Dl36eUT2.js +++ /dev/null @@ -1 +0,0 @@ -import{G as U,I as C}from"./chunk-JARCRF6W-yaymqCZ5.js";import{f as x,D as b,j as p,aa as S,r as h}from"./input.js";import{ae as y,h as v,a9 as E}from"./App-iJ8dSmpT.js";var V=x(function(o,s){const{columns:l,spacingX:a,spacingY:n,spacing:r,minChildWidth:e,...c}=o,i=b(),f=e?A(e,i):M(l);return p.jsx(U,{ref:s,gap:r,columnGap:a,rowGap:n,templateColumns:f,...c})});V.displayName="SimpleGrid";function k(t){return typeof t=="number"?`${t}px`:t}function A(t,o){return y(t,s=>{const l=S("sizes",s,k(s))(o);return s===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function M(t){return y(t,o=>o===null?null:`repeat(${o}, minmax(0, 1fr))`)}var R=v("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);function O(t){return new Promise((o,s)=>{const l=new FileReader;l.onload=a=>{const n=new Uint8Array(a.target.result),r=new DataView(n.buffer);r.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),s());let e=8;const c={};for(;eString.fromCharCode(w)).join("");c[g]=m}e+=12+i}o(c)},l.readAsArrayBuffer(t)})}function D(t){const o=new Uint16Array(t.slice(0,2))[0]===18761;function s(r,e,c){const i=t.slice(r,r+c);if(c===2)return new DataView(i.buffer,i.byteOffset,i.byteLength).getUint16(0,e);if(c===4)return new DataView(i.buffer,i.byteOffset,i.byteLength).getUint32(0,e)}const l=s(4,o,4);function a(r){const e=s(r,o,2),c={};for(let i=0;i{const s=new FileReader;s.onload=l=>{var c;const a=new Uint8Array((c=l==null?void 0:l.target)==null?void 0:c.result),n=new DataView(a.buffer);if(n.getUint32(0)!==1380533830||n.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),o();return}let r=12;const e={};for(;r{const s=new FileReader;s.onload=l=>{const a=new Uint8Array(l.target.result),n=new DataView(a.buffer),r=new TextDecoder;if(n.getUint32(0)==440786851){let e=12;for(;e>8*(4-f)&~(1<<7*f),g=r.decode(a.slice(e+2+f,e+2+f+u)),d=JSON.parse(g);o(d);return}}e+=1}}else if(n.getUint32(4)==1718909296&&n.getUint32(8)==1769172845){let e=a.length-4;for(;e>16;){if(n.getUint32(e)==1684108385&&n.getUint32(e-8)==2841865588){n.getUint32(e+4),n.getUint32(e+8);const c=n.getUint32(e-4)-4*4,i=r.decode(a.slice(e+12,e+12+c)),f=JSON.parse(i);o(f);return}e-=1}}else{console.error("Unknown magic: "+n.getUint32(0)),o();return}},s.readAsArrayBuffer(t)})}function $({mediaLocalPath:t,size:o,autoPlay:s,hideBrokenImage:l,onBrokenLink:a}){const[n,r]=h.useState(!0);return h.useEffect(()=>{l&&(async()=>{try{if(!(await fetch(`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");r(!0)}catch{r(!1),a==null||a()}})()},[]),n?E(t)?p.jsx(C,{borderRadius:3,boxSize:`${o}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):p.jsx("video",{width:o,height:o,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:s??!1,muted:!0,children:p.jsx("track",{kind:"captions"})}):null}export{R as I,$ as M,V as S,F as a,G as b,O as g,N as i}; diff --git a/dist/workspace_web/MediaPreview-nO-IKtd3.js b/dist/workspace_web/MediaPreview-nO-IKtd3.js new file mode 100644 index 0000000..5d28713 --- /dev/null +++ b/dist/workspace_web/MediaPreview-nO-IKtd3.js @@ -0,0 +1 @@ +import{G as U,I as C}from"./chunk-JARCRF6W-1wZ_35Xk.js";import{f as x,D as b,j as p,aa as v,r as h}from"./input.js";import{ac as y,h as S,a9 as k}from"./App-09wdM9e8.js";var E=x(function(r,s){const{columns:l,spacingX:a,spacingY:n,spacing:i,minChildWidth:e,...c}=r,o=b(),f=e?A(e,o):M(l);return p.jsx(U,{ref:s,gap:i,columnGap:a,rowGap:n,templateColumns:f,...c})});E.displayName="SimpleGrid";function V(t){return typeof t=="number"?`${t}px`:t}function A(t,r){return y(t,s=>{const l=v("sizes",s,V(s))(r);return s===null?null:`repeat(auto-fit, minmax(${l}, 1fr))`})}function M(t){return y(t,r=>r===null?null:`repeat(${r}, minmax(0, 1fr))`)}var R=S("chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]]);function O(t){return new Promise((r,s)=>{const l=new FileReader;l.onload=a=>{const n=new Uint8Array(a.target.result),i=new DataView(n.buffer);i.getUint32(0)!==2303741511&&(console.error("Not a valid PNG file"),s());let e=8;const c={};for(;eString.fromCharCode(w)).join("");c[g]=m}e+=12+o}r(c)},l.readAsArrayBuffer(t)})}function _(t){const r=new Uint16Array(t.slice(0,2))[0]===18761;function s(i,e,c){const o=t.slice(i,i+c);if(c===2)return new DataView(o.buffer,o.byteOffset,o.byteLength).getUint16(0,e);if(c===4)return new DataView(o.buffer,o.byteOffset,o.byteLength).getUint32(0,e)}const l=s(4,r,4);function a(i){const e=s(i,r,2),c={};for(let o=0;o{const s=new FileReader;s.onload=l=>{var c;const a=new Uint8Array((c=l==null?void 0:l.target)==null?void 0:c.result),n=new DataView(a.buffer);if(n.getUint32(0)!==1380533830||n.getUint32(8)!==1464156752){console.error("Not a valid WEBP file"),r();return}let i=12;const e={};for(;i{const s=new FileReader;s.onload=l=>{const a=new Uint8Array(l.target.result),n=new DataView(a.buffer),i=new TextDecoder;if(n.getUint32(0)==440786851){let e=12;for(;e>8*(4-f)&~(1<<7*f),g=i.decode(a.slice(e+2+f,e+2+f+u)),d=JSON.parse(g);r(d);return}}e+=1}}else if(n.getUint32(4)==1718909296&&n.getUint32(8)==1769172845){let e=a.length-4;for(;e>16;){if(n.getUint32(e)==1684108385&&n.getUint32(e-8)==2841865588){n.getUint32(e+4),n.getUint32(e+8);const c=n.getUint32(e-4)-4*4,o=i.decode(a.slice(e+12,e+12+c)),f=JSON.parse(o);r(f);return}e-=1}}else{console.error("Unknown magic: "+n.getUint32(0)),r();return}},s.readAsArrayBuffer(t)})}function F({mediaLocalPath:t,size:r,isPreview:s,autoPlay:l,hideBrokenImage:a,onBrokenLink:n}){const[i,e]=h.useState(!0);return h.useEffect(()=>{a&&(async()=>{try{if(!(await fetch(s?`/workspace/preview_media?filename=${t}`:`/workspace/view_media?filename=${t}`)).ok)throw new Error("Media not found");e(!0)}catch{e(!1),n==null||n()}})()},[]),i?k(t)?p.jsx(C,{borderRadius:3,boxSize:`${r}px`,objectFit:"cover",src:`/workspace/view_media?filename=${t}`,alt:"workflow image renamed or moved from output folder"}):p.jsx("video",{width:r,height:r,src:`/workspace/view_media?filename=${t}`,loop:!0,autoPlay:l??!1,muted:!0,children:p.jsx("track",{kind:"captions"})}):null}export{R as I,F as M,E as S,$ as a,G as b,O as g,N as i}; diff --git a/dist/workspace_web/ModelManagerTopbar-SdEpIAUx.js b/dist/workspace_web/ModelManagerTopbar-O1ybaI8q.js similarity index 97% rename from dist/workspace_web/ModelManagerTopbar-SdEpIAUx.js rename to dist/workspace_web/ModelManagerTopbar-O1ybaI8q.js index 585627a..aad62c4 100644 --- a/dist/workspace_web/ModelManagerTopbar-SdEpIAUx.js +++ b/dist/workspace_web/ModelManagerTopbar-O1ybaI8q.js @@ -1,7 +1,7 @@ -import{f as T,r as u,j as e,g as M,h as K,a3 as B,b as be,o as ne,i as oe,k as _e,ab as Me,B as v,a8 as H,ac as Ce,L as ae,ad as Ie,O as ie,R as re,S as Te,X as ke,M as Ee,N as Ae,Q as Ne,P as Pe,_ as De}from"./input.js";import{af as Le,ae as Re,W as Be,ag as P,l as C,F as A,T as _,B as le,a5 as ce,j as z,o as J,w as ze,H as N,k as O,ah as Oe,m as de,ai as ue,X as Fe,Y as We,Z as Ge,_ as Ke,$ as He,ad as he,aj as $e,a6 as Ve,ak as Ye,al as Ue}from"./App-iJ8dSmpT.js";import{I as me,G as qe,C as Qe}from"./chunk-JARCRF6W-yaymqCZ5.js";import{app as L}from"/scripts/app.js";import{api as R}from"/scripts/api.js";var pe=T(function(s,a){const{spacing:o="0.5rem",spacingX:i,spacingY:n,children:r,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...m}=s,g=u.useMemo(()=>f?u.Children.map(r,(p,w)=>e.jsx($,{children:p},w)):r,[r,f]);return e.jsx(M.div,{ref:a,className:K("chakra-wrap",h),...m,children:e.jsx(M.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:i,rowGap:n,padding:"0"},children:g})})});pe.displayName="Wrap";var $=T(function(s,a){const{className:o,...i}=s;return e.jsx(M.li,{ref:a,__css:{display:"flex",alignItems:"flex-start"},className:K("chakra-wrap__listitem",o),...i})});$.displayName="WrapItem";function Z(t){return Re(t,s=>s==="auto"?"auto":`span ${s}/span ${s}`)}var fe=T(function(s,a){const{area:o,colSpan:i,colStart:n,colEnd:r,rowEnd:c,rowSpan:l,rowStart:d,...h}=s,f=Le({gridArea:o,gridColumn:Z(i),gridRow:Z(l),gridColumnStart:n,gridColumnEnd:r,gridRowStart:d,gridRowEnd:c});return e.jsx(M.div,{ref:a,__css:f,...h})});fe.displayName="GridItem";function Xe(t,s,a){return(t-s)*100/(a-s)}B({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});B({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Je=B({"0%":{left:"-40%"},"100%":{left:"100%"}}),Ze=B({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function et(t){const{value:s=0,min:a,max:o,valueText:i,getValueText:n,isIndeterminate:r,role:c="progressbar"}=t,l=Xe(s,a,o);return{bind:{"data-indeterminate":r?"":void 0,"aria-valuemax":o,"aria-valuemin":a,"aria-valuenow":r?void 0:s,"aria-valuetext":(()=>{if(s!=null)return typeof n=="function"?n(s,l):i})(),role:c},percent:l,value:s}}var[tt,st]=be({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),nt=T((t,s)=>{const{min:a,max:o,value:i,isIndeterminate:n,role:r,...c}=t,l=et({value:i,min:a,max:o,isIndeterminate:n,role:r}),h={height:"100%",...st().filledTrack};return e.jsx(M.div,{ref:s,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),ge=T((t,s)=>{var a;const{value:o,min:i=0,max:n=100,hasStripe:r,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":m,"aria-valuetext":g,title:p,role:w,...x}=ne(t),y=oe("Progress",t),b=d??((a=y.track)==null?void 0:a.borderRadius),j={animation:`${Ze} 1s linear infinite`},W={...!h&&r&&c&&j,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Je} 1s ease infinite normal none running`}},S={overflow:"hidden",position:"relative",...y.track};return e.jsx(M.div,{ref:s,borderRadius:b,__css:S,...x,children:e.jsxs(tt,{value:y,children:[e.jsx(nt,{"aria-label":f,"aria-labelledby":m,"aria-valuetext":g,min:i,max:n,value:o,isIndeterminate:h,css:W,borderRadius:b,title:p,role:w}),l]})})});ge.displayName="Progress";var xe=T(function(s,a){const{children:o,placeholder:i,className:n,...r}=s;return e.jsxs(M.select,{...r,ref:a,className:K("chakra-select",n),children:[i&&e.jsx("option",{value:"",children:i}),o]})});xe.displayName="SelectField";function ot(t,s){const a={},o={};for(const[i,n]of Object.entries(t))s.includes(i)?a[i]=n:o[i]=n;return[a,o]}var V=T((t,s)=>{var a;const o=oe("Select",t),{rootProps:i,placeholder:n,icon:r,color:c,height:l,h:d,minH:h,minHeight:f,iconColor:m,iconSize:g,...p}=ne(t),[w,x]=ot(p,Me),y=Be(x),b={width:"100%",height:"fit-content",position:"relative",color:c},j={paddingEnd:"2rem",...o.field,_focus:{zIndex:"unset",...(a=o.field)==null?void 0:a._focus}};return e.jsxs(M.div,{className:"chakra-select__wrapper",__css:b,...w,...i,children:[e.jsx(xe,{ref:s,height:d??l,minH:h??f,placeholder:n,...y,__css:j,children:t.children}),e.jsx(we,{"data-disabled":_e(y.disabled),...(m||c)&&{color:m||c},__css:o.icon,...g&&{fontSize:g},children:r})]})});V.displayName="Select";var at=t=>e.jsx("svg",{viewBox:"0 0 24 24",...t,children:e.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),it=M("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),we=t=>{const{children:s=e.jsx(at,{}),...a}=t,o=u.cloneElement(s,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return e.jsx(it,{...a,className:"chakra-select__icon-wrapper",children:u.isValidElement(s)?o:null})};we.displayName="SelectIcon";function rt({selectedModel:t,setSelectedModel:s,modelTypeList:a}){const o=i=>{s(i)};return e.jsx(pe,{children:a.map(i=>e.jsx($,{children:e.jsx(v,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const lt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function ct({data:t}){const[s,a]=u.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=u.useState(!t.file_hash),[n,r]=u.useState();u.useEffect(()=>{i(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,m,g;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null)r(d),(h=d.imageUrl)!=null&&h.length&&a(d.imageUrl);else if(t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,x=await(await fetch(p)).json();let y;if(await((f=C)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)y=(g=(m=x==null?void 0:x.images)==null?void 0:m[0])==null?void 0:g.url;else if(!x.model.nsfw){const j=x.images.find(D=>D.nsfw==="None");y=j==null?void 0:j.url}y&&a(y),P.models.add({id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,civitModelID:String(x.modelId),civitModelVersionID:String(x.id),imageUrl:y??null})}catch{}t.preview&&a(t.preview)},l=d=>{const h=lt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return o?e.jsxs(A,{position:"relative",borderRadius:4,bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:[o&&e.jsx(H,{}),e.jsx(_,{position:"absolute",bottom:"0",left:"0",right:"0",bg:"rgba(0, 0, 0, 0.5)",color:"white",textAlign:"center",p:"0",fontSize:12,borderBottomRightRadius:4,borderBottomLeftRadius:4,children:t.model_name})]}):e.jsxs(le,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[e.jsx(me,{src:s,draggable:!1,boxSize:"100%",height:178,objectFit:"cover",borderRadius:4,cursor:(n==null?void 0:n.civitModelID)!=null?"pointer":"auto",onClick:()=>{(n==null?void 0:n.civitModelID)==null||(n==null?void 0:n.civitModelVersionID)==null||window.open(`https://civitai.com/models/${n==null?void 0:n.civitModelID}?modelVersionId=${n==null?void 0:n.civitModelVersionID}`)}}),e.jsx(_,{position:"absolute",bottom:"0",left:"0",right:"0",bg:"rgba(0, 0, 0, 0.5)",color:"white",textAlign:"center",p:"0",fontSize:14,borderBottomRightRadius:4,borderBottomLeftRadius:4,children:t.model_name})]})}function dt({list:t}){return e.jsx(qe,{templateColumns:"repeat(3, 1fr)",gap:1,marginTop:2,children:t.map(s=>e.jsx(fe,{children:e.jsx(ct,{data:s})},s.model_name))})}const ut=async t=>{try{const a=await(await R.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:a}))}catch(s){console.error("Failed to connect to the server:",s)}},ht=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],mt=2,pt={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Se(t){return t.modelVersions!==void 0}function ft(t){var s;return((s=t.files)==null?void 0:s[0])!==void 0}function ee(t,s){var o,i,n,r,c,l;if(!t)return;let a;return ft(t)?a={id:t.id,SHA256:(i=(o=t.files)==null?void 0:o[0].hashes)==null?void 0:i.SHA256,name:(n=t.files)==null?void 0:n[0].name,sizeKB:(c=(r=t.files)==null?void 0:r[0])==null?void 0:c.sizeKB}:a={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${s} ${t.name}`},a}function te(t,s=1){const i=t/1024;return i>=1024?(i/1024).toFixed(s)+" GB":i.toFixed(s)+" MB"}function se(t,s){if(!t||t.length===0)return;let a=t.find(o=>o.nsfw==="None");return s&&(a=a??t[0]),a}function gt(t,s=280,a){var o,i,n,r;if(t)return Se(t)?(n=se((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,a))==null?void 0:n.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(r=se(t.images,a))==null?void 0:r.url}/width=${s}/`}const G=280;function xt({model:t,onClickInstallModel:s,installing:a}){var m,g;const[o,i]=u.useState();u.useEffect(()=>{p();async function p(){var x;const w=await((x=C)==null?void 0:x.getSetting("showNsfwModelThumbnail"));i(gt(t,G,w))}},[t]);const n=Se(t)?t.modelVersions:t.versions,[r,c]=u.useState(((m=n==null?void 0:n[0])==null?void 0:m.name)??""),l=n==null?void 0:n.find(p=>(p==null?void 0:p.name)===r),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=u.useCallback(()=>{if(l==null){console.error("no file is find by name",r);return}s(ee(l),t)},[r]),f=(g=ee(l))==null?void 0:g.sizeKB;return e.jsxs(ce,{width:G,justifyContent:"space-between",mb:2,gap:1,children:[e.jsx(me,{borderRadius:3,boxSize:G+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),e.jsxs(z,{p:1,children:[e.jsx(J,{label:t.name,children:e.jsx(_,{fontWeight:500,noOfLines:1,children:t.name})}),e.jsxs(A,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(v,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:e.jsx(_,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),e.jsx(v,{leftIcon:e.jsx(ze,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(r&&a.includes(r)),children:"Install"})]}),e.jsxs(N,{children:[e.jsx(V,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:n==null?void 0:n.map(p=>{const w=p==null?void 0:p.name;return w?e.jsx("option",{value:w,style:{padding:0},children:w},p.id):null})}),f&&e.jsx(J,{label:te(f),children:e.jsx(_,{flexShrink:1,noOfLines:1,width:"40%",children:te(f)})})]})]})]})}function wt({searchQuery:t,setSearchQuery:s,onSearch:a}){return e.jsxs(A,{gap:1,alignItems:"center",grow:1,children:[e.jsx(O,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>s(o.target.value),onKeyUp:o=>{o.code==="Enter"&&a()}}),e.jsx(v,{size:"sm",onClick:()=>a(),colorScheme:"teal",children:"Search"})]})}function St({isOpen:t,fileSelected:s,onClose:a,selectFolder:o}){const[i,n]=u.useState(""),[r,c]=u.useState([]),[l,d]=u.useState(""),h=u.useRef(null);u.useEffect(()=>{f()},[]);const f=async()=>{const m=await Oe();m&&c(m.filter(g=>!["custom_nodes","config","saved_prompts"].includes(g)))};return e.jsx(Ce,{isOpen:t,leastDestructiveRef:h,onClose:a,children:e.jsx(ae,{children:e.jsxs(Ie,{children:[e.jsx(ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),e.jsx(re,{children:e.jsxs(z,{spacing:4,children:[!s&&e.jsxs(e.Fragment,{children:[e.jsx(_,{children:"Model download url"}),e.jsx(O,{placeholder:"https://civitai.com/api/download/models/311399",onChange:m=>d(m.target.value),value:l})]}),e.jsx(_,{children:"Choose model install folder"}),e.jsx(V,{placeholder:"Select option",value:i,onChange:m=>n(m.target.value),children:r.map(m=>e.jsx("option",{value:m,children:m},m))})]})}),e.jsxs(Te,{children:[e.jsx(v,{ref:h,onClick:a,children:"Cancel"}),e.jsx(v,{onClick:()=>o(i,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function yt(){const{colorMode:t}=ke(),s=de(),[a,o]=u.useState([]);return u.useEffect(()=>{R.addEventListener("download_progress",i=>{o(i.detail)}),R.addEventListener("download_error",i=>{s({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),e.jsx(z,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,children:a.map(({save_path:i,progress:n})=>e.jsxs(N,{children:[e.jsx(_,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),e.jsx(ge,{isIndeterminate:!n,hasStripe:!0,width:"50%",value:n}),e.jsxs(_,{fontSize:16,width:"10%",children:[n.toFixed(1),"%"]})]},i))})}const ye="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function jt(){return localStorage.getItem(ye)}function vt(t){localStorage.setItem(ye,t)}function bt(){const[t,s]=u.useState(""),{onOpen:a,onClose:o,isOpen:i}=ue(),n=()=>{vt(t),o()};return e.jsxs(Fe,{isOpen:i,onOpen:a,onClose:o,placement:"right",closeOnBlur:!1,children:[e.jsx(We,{children:e.jsx(v,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),e.jsxs(Ge,{p:5,children:[e.jsx(Ke,{}),e.jsx(He,{}),e.jsxs(z,{spacing:4,children:[e.jsx(_,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),e.jsx(O,{value:t,onChange:r=>s(r.target.value),placeholder:"API Key"}),e.jsx(v,{size:"sm",py:1,mr:8,onClick:n,children:"Save"})]})]})]})}const _t=t=>typeof t=="function",je=t=>{const[s,a]=u.useState(t),o=u.useRef(s),i=u.useCallback(n=>{o.current=_t(n)?n(o.current):n,a(o.current)},[]);return[s,i,o]};async function Mt(t){var l,d;const a={limit:"30",nsfw:await((l=C)==null?void 0:l.getSetting("showNsfwModelThumbnail"))??!1,types:t},i=`https://civitai.com/api/v1/models?${new URLSearchParams(a).toString()}`,n=await((d=P.cache)==null?void 0:d.get(i));if((n==null?void 0:n.value)!=null)try{const{data:h,timestamp:f}=JSON.parse(n==null?void 0:n.value);if((Date.now()-f)/(1e3*60*60*24){if(r(!0),m){const S=await Ct(m,c);i(S)}else{const S=await Mt(c);i(S)}r(!1)},[m,c]),F=(S,k)=>{var U,q,Q,X;if(!((U=j.current)!=null&&U.id)&&!k){console.error("no url to download");return}let E=k??`https://civitai.com/api/download/models/${(q=j.current)==null?void 0:q.id}`,I=(Q=j.current)==null?void 0:Q.name;if(!I&&(I=E.split("/").pop(),!I)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:I,status:"info",duration:4e3,isClosable:!0}),I!=null&&f(ve=>[...ve,I??""]);const Y=jt();Y&&(E+=`?token=${Y}`),ut({file_hash:(X=j.current)==null?void 0:X.SHA256,filename:I,save_path:S,url:E}),b(void 0),x()},W=(S,k)=>{const E=pt[k.type];b(S),E==null?w():F(E)};return u.useEffect(()=>{D()},[c]),e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[e.jsx(ae,{}),e.jsxs(Ae,{width:"90%",maxWidth:"90vw",height:"90vh",children:[e.jsxs(ie,{children:[e.jsxs(N,{gap:2,mb:2,alignItems:"center",children:[e.jsx(he,{size:"md",mr:2,children:"Models"}),e.jsx(wt,{searchQuery:m,setSearchQuery:g,onSearch:D}),e.jsx(v,{size:"sm",py:1,mr:8,onClick:w,children:"Custom URL Install"}),e.jsx(bt,{})]}),e.jsxs(N,{gap:2,mb:2,wrap:"wrap",children:[e.jsx(v,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(S=>e.jsx(v,{size:"sm",py:1,isActive:c===S,onClick:()=>{l(S)},children:S},S))]}),n&&e.jsx(H,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),e.jsx(Ne,{}),e.jsxs(re,{overflowY:"auto",children:[e.jsx(N,{wrap:"wrap",children:o==null?void 0:o.map(S=>e.jsx(xt,{model:S,onClickInstallModel:W,installing:h},S.id))}),e.jsx(yt,{})]})]})]}),e.jsx(St,{fileSelected:!!y,isOpen:p,onClose:x,selectFolder:(S,k)=>{F(S,j.current?void 0:k)}})]})}function Tt(){const[t,s]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{size:"sm",colorScheme:"teal",onClick:()=>s(!0),children:"Install Models"}),t&&e.jsx(It,{modelType:"Checkpoint",onclose:()=>s(!1)})]})}const kt=()=>{const[t,s]=u.useState(["checkpoints"]),[a,o]=u.useState([]),[i,n]=u.useState(!0);u.useEffect(()=>{r(),R.addEventListener("model_list",l=>{c(l.detail)})},[]);const r=async()=>{const l=await $e();c(l)},c=async l=>{if(!l)return;n(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),s(d),o(l)};return{modelTypeList:t,modelsList:a,loading:i}};function Et(){const[t,s,a]=je(!1),o=()=>{var c;(c=C)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{s(l??!1)})};u.useEffect(()=>{o()},[]);const i=c=>{var d;const l=c.target.checked;(d=C)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),n(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},n=async()=>{const c=await P.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,m=await(await fetch(h)).json();let g;if(a.current)g=(d=(l=m==null?void 0:m.images)==null?void 0:l[0])==null?void 0:d.url;else if(!m.model.nsfw){const p=m.images.find(w=>w.nsfw==="None");g=p==null?void 0:p.url}P.models.update(c.id,{imageUrl:g??null})}catch{}};return e.jsx(Qe,{isChecked:t,onChange:i,width:"100px",children:"Show NSFW"})}function At({onClose:t}){const[s,a]=u.useState("checkpoints"),[o,i]=u.useState(""),{loading:n,modelTypeList:r,modelsList:c}=kt(),[l,d]=u.useState([]);u.useEffect(()=>{const m=c.filter(g=>o.length?g.model_name.toLowerCase().includes(o.toLowerCase()):g.model_type===s);d(m)},[s,c,o]),u.useEffect(()=>(L.canvasEl.addEventListener("click",t),()=>{L.canvasEl.removeEventListener("click",t)}),[]);const h=440,f=()=>e.jsxs(e.Fragment,{children:[e.jsxs(A,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:[e.jsx(O,{size:"sm",placeholder:"Search",value:o,onChange:m=>i(m.target.value)}),e.jsx(Et,{})]}),!o.length&&e.jsx(rt,{modelTypeList:r,setSelectedModel:a,selectedModel:s}),e.jsx(dt,{list:l}),n&&e.jsx(A,{justifyContent:"center",alignItems:"center",height:"100%",children:e.jsx(H,{})})]});return e.jsx(Pe,{children:e.jsx(le,{style:{width:h},children:e.jsxs(ce,{width:h,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:Ve,overflowY:"auto",children:[e.jsxs(A,{justifyContent:"space-between",alignContent:"center",py:3,children:[e.jsx(he,{size:"md",mr:2,children:"Models"}),e.jsx(Tt,{})]}),f()]})})})}const Nt=u.lazy(()=>De(()=>import("./InstallMissingModelsButton-iTYBbpS-.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function Pt(){const[t,s]=u.useState(!1),[a,o]=u.useState(),i=async r=>{if(r.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const l=r.dataTransfer.getData("modelRelativePath"),d=r.dataTransfer.getData("nodeType"),h=LiteGraph.createNode(d);h.pos=[r.canvasX,r.canvasY],h.configure({widgets_values:[l]}),L.graph.add(h)};u.useEffect(()=>{var r;return(r=C)==null||r.getSetting("modelManagerTopBarStyle").then(c=>{n(c,!1)}),L.canvasEl.addEventListener("drop",i),()=>{L.canvasEl.removeEventListener("drop",i)}},[]);const n=(r,c=!1)=>{var b;const{top:l=0,right:d=0}=a||{},{top:h=0,right:f=0}=r??{};let m=l+h,g=a===void 0?f:d-f;const p=document.documentElement.clientWidth,w=document.documentElement.clientHeight,x=document.getElementById("modelManagerTopBar"),y=(x==null?void 0:x.offsetWidth)||224;m+32>w&&(m=w-38),g+y>p&&(g=p-y-4),o({top:Math.max(4,m),right:Math.max(4,g)}),c&&((b=C)==null||b.upsert({modelManagerTopBarStyle:{top:m,right:g}}))};return e.jsx(Ye,{onDragEnd:r=>{n({top:r.y,right:r.x},!0)},dragIconId:"dragModelManagerTopBarIcon",children:a?e.jsxs(N,{style:{position:"fixed",...a},gap:2,draggable:!1,id:"modelManagerTopBar",className:"model-manager-top-bar",children:[e.jsx(Ue,{id:"dragModelManagerTopBarIcon",className:"drag-model-manager-top-bar-icon",cursor:"move",size:15,color:"#FFF"}),e.jsx(Nt,{}),e.jsx(v,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>s(!0),px:1,children:"Models"}),t&&e.jsx(At,{onClose:()=>s(!1)})]}):""})}const Ot=Object.freeze(Object.defineProperty({__proto__:null,default:Pt},Symbol.toStringTag,{value:"Module"}));export{fe as G,Tt as I,Ot as M,Ct as g}; +import{f as T,r as u,j as e,g as M,h as K,a3 as B,b as be,o as ne,i as oe,k as _e,ab as Me,B as v,a8 as H,ac as Ce,L as ae,ad as Ie,O as ie,R as re,S as Te,X as ke,M as Ee,N as Ae,Q as Ne,P as Pe,_ as De}from"./input.js";import{ad as Le,ac as Re,W as Be,ae as P,l as C,F as A,T as _,B as le,a5 as ce,j as z,o as J,w as ze,H as N,k as O,af as Oe,m as de,ag as ue,X as Fe,Y as We,Z as Ge,_ as Ke,$ as He,ab as he,ah as $e,a6 as Ve,ai as Ye,aj as Ue}from"./App-09wdM9e8.js";import{I as me,G as qe,C as Qe}from"./chunk-JARCRF6W-1wZ_35Xk.js";import{app as L}from"/scripts/app.js";import{api as R}from"/scripts/api.js";var pe=T(function(s,a){const{spacing:o="0.5rem",spacingX:i,spacingY:n,children:r,justify:c,direction:l,align:d,className:h,shouldWrapChildren:f,...m}=s,g=u.useMemo(()=>f?u.Children.map(r,(p,w)=>e.jsx($,{children:p},w)):r,[r,f]);return e.jsx(M.div,{ref:a,className:K("chakra-wrap",h),...m,children:e.jsx(M.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:c,alignItems:d,flexDirection:l,listStyleType:"none",gap:o,columnGap:i,rowGap:n,padding:"0"},children:g})})});pe.displayName="Wrap";var $=T(function(s,a){const{className:o,...i}=s;return e.jsx(M.li,{ref:a,__css:{display:"flex",alignItems:"flex-start"},className:K("chakra-wrap__listitem",o),...i})});$.displayName="WrapItem";function Z(t){return Re(t,s=>s==="auto"?"auto":`span ${s}/span ${s}`)}var fe=T(function(s,a){const{area:o,colSpan:i,colStart:n,colEnd:r,rowEnd:c,rowSpan:l,rowStart:d,...h}=s,f=Le({gridArea:o,gridColumn:Z(i),gridRow:Z(l),gridColumnStart:n,gridColumnEnd:r,gridRowStart:d,gridRowEnd:c});return e.jsx(M.div,{ref:a,__css:f,...h})});fe.displayName="GridItem";function Xe(t,s,a){return(t-s)*100/(a-s)}B({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});B({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var Je=B({"0%":{left:"-40%"},"100%":{left:"100%"}}),Ze=B({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function et(t){const{value:s=0,min:a,max:o,valueText:i,getValueText:n,isIndeterminate:r,role:c="progressbar"}=t,l=Xe(s,a,o);return{bind:{"data-indeterminate":r?"":void 0,"aria-valuemax":o,"aria-valuemin":a,"aria-valuenow":r?void 0:s,"aria-valuetext":(()=>{if(s!=null)return typeof n=="function"?n(s,l):i})(),role:c},percent:l,value:s}}var[tt,st]=be({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),nt=T((t,s)=>{const{min:a,max:o,value:i,isIndeterminate:n,role:r,...c}=t,l=et({value:i,min:a,max:o,isIndeterminate:n,role:r}),h={height:"100%",...st().filledTrack};return e.jsx(M.div,{ref:s,style:{width:`${l.percent}%`,...c.style},...l.bind,...c,__css:h})}),ge=T((t,s)=>{var a;const{value:o,min:i=0,max:n=100,hasStripe:r,isAnimated:c,children:l,borderRadius:d,isIndeterminate:h,"aria-label":f,"aria-labelledby":m,"aria-valuetext":g,title:p,role:w,...x}=ne(t),y=oe("Progress",t),b=d??((a=y.track)==null?void 0:a.borderRadius),j={animation:`${Ze} 1s linear infinite`},W={...!h&&r&&c&&j,...h&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${Je} 1s ease infinite normal none running`}},S={overflow:"hidden",position:"relative",...y.track};return e.jsx(M.div,{ref:s,borderRadius:b,__css:S,...x,children:e.jsxs(tt,{value:y,children:[e.jsx(nt,{"aria-label":f,"aria-labelledby":m,"aria-valuetext":g,min:i,max:n,value:o,isIndeterminate:h,css:W,borderRadius:b,title:p,role:w}),l]})})});ge.displayName="Progress";var xe=T(function(s,a){const{children:o,placeholder:i,className:n,...r}=s;return e.jsxs(M.select,{...r,ref:a,className:K("chakra-select",n),children:[i&&e.jsx("option",{value:"",children:i}),o]})});xe.displayName="SelectField";function ot(t,s){const a={},o={};for(const[i,n]of Object.entries(t))s.includes(i)?a[i]=n:o[i]=n;return[a,o]}var V=T((t,s)=>{var a;const o=oe("Select",t),{rootProps:i,placeholder:n,icon:r,color:c,height:l,h:d,minH:h,minHeight:f,iconColor:m,iconSize:g,...p}=ne(t),[w,x]=ot(p,Me),y=Be(x),b={width:"100%",height:"fit-content",position:"relative",color:c},j={paddingEnd:"2rem",...o.field,_focus:{zIndex:"unset",...(a=o.field)==null?void 0:a._focus}};return e.jsxs(M.div,{className:"chakra-select__wrapper",__css:b,...w,...i,children:[e.jsx(xe,{ref:s,height:d??l,minH:h??f,placeholder:n,...y,__css:j,children:t.children}),e.jsx(we,{"data-disabled":_e(y.disabled),...(m||c)&&{color:m||c},__css:o.icon,...g&&{fontSize:g},children:r})]})});V.displayName="Select";var at=t=>e.jsx("svg",{viewBox:"0 0 24 24",...t,children:e.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),it=M("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),we=t=>{const{children:s=e.jsx(at,{}),...a}=t,o=u.cloneElement(s,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return e.jsx(it,{...a,className:"chakra-select__icon-wrapper",children:u.isValidElement(s)?o:null})};we.displayName="SelectIcon";function rt({selectedModel:t,setSelectedModel:s,modelTypeList:a}){const o=i=>{s(i)};return e.jsx(pe,{children:a.map(i=>e.jsx($,{children:e.jsx(v,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const lt={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function ct({data:t}){const[s,a]=u.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=u.useState(!t.file_hash),[n,r]=u.useState();u.useEffect(()=>{i(!t.file_hash),c()},[t.file_hash]);const c=async()=>{var h,f,m,g;const d=await P.models.get(t.model_name+"@"+t.model_type);if(d!=null)r(d),(h=d.imageUrl)!=null&&h.length&&a(d.imageUrl);else if(t.file_hash!=null)try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,x=await(await fetch(p)).json();let y;if(await((f=C)==null?void 0:f.getSetting("showNsfwModelThumbnail"))===!0)y=(g=(m=x==null?void 0:x.images)==null?void 0:m[0])==null?void 0:g.url;else if(!x.model.nsfw){const j=x.images.find(D=>D.nsfw==="None");y=j==null?void 0:j.url}y&&a(y),P.models.add({id:t.model_name+"@"+t.model_type,fileHash:t.file_hash,fileFolder:t.model_type,fileName:t.model_name+t.model_extension,civitModelID:String(x.modelId),civitModelVersionID:String(x.id),imageUrl:y??null})}catch{}t.preview&&a(t.preview)},l=d=>{const h=lt[t.model_type];h&&(d.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),d.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),d.dataTransfer.setData("nodeType",h))};return o?e.jsxs(A,{position:"relative",borderRadius:4,bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:[o&&e.jsx(H,{}),e.jsx(_,{position:"absolute",bottom:"0",left:"0",right:"0",bg:"rgba(0, 0, 0, 0.5)",color:"white",textAlign:"center",p:"0",fontSize:12,borderBottomRightRadius:4,borderBottomLeftRadius:4,children:t.model_name})]}):e.jsxs(le,{position:"relative",borderRadius:4,draggable:!0,onDragStart:l,children:[e.jsx(me,{src:s,draggable:!1,boxSize:"100%",height:178,objectFit:"cover",borderRadius:4,cursor:(n==null?void 0:n.civitModelID)!=null?"pointer":"auto",onClick:()=>{(n==null?void 0:n.civitModelID)==null||(n==null?void 0:n.civitModelVersionID)==null||window.open(`https://civitai.com/models/${n==null?void 0:n.civitModelID}?modelVersionId=${n==null?void 0:n.civitModelVersionID}`)}}),e.jsx(_,{position:"absolute",bottom:"0",left:"0",right:"0",bg:"rgba(0, 0, 0, 0.5)",color:"white",textAlign:"center",p:"0",fontSize:14,borderBottomRightRadius:4,borderBottomLeftRadius:4,children:t.model_name})]})}function dt({list:t}){return e.jsx(qe,{templateColumns:"repeat(3, 1fr)",gap:1,marginTop:2,children:t.map(s=>e.jsx(fe,{children:e.jsx(ct,{data:s})},s.model_name))})}const ut=async t=>{try{const a=await(await R.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:a}))}catch(s){console.error("Failed to connect to the server:",s)}},ht=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],mt=2,pt={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function Se(t){return t.modelVersions!==void 0}function ft(t){var s;return((s=t.files)==null?void 0:s[0])!==void 0}function ee(t,s){var o,i,n,r,c,l;if(!t)return;let a;return ft(t)?a={id:t.id,SHA256:(i=(o=t.files)==null?void 0:o[0].hashes)==null?void 0:i.SHA256,name:(n=t.files)==null?void 0:n[0].name,sizeKB:(c=(r=t.files)==null?void 0:r[0])==null?void 0:c.sizeKB}:a={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${s} ${t.name}`},a}function te(t,s=1){const i=t/1024;return i>=1024?(i/1024).toFixed(s)+" GB":i.toFixed(s)+" MB"}function se(t,s){if(!t||t.length===0)return;let a=t.find(o=>o.nsfw==="None");return s&&(a=a??t[0]),a}function gt(t,s=280,a){var o,i,n,r;if(t)return Se(t)?(n=se((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,a))==null?void 0:n.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(r=se(t.images,a))==null?void 0:r.url}/width=${s}/`}const G=280;function xt({model:t,onClickInstallModel:s,installing:a}){var m,g;const[o,i]=u.useState();u.useEffect(()=>{p();async function p(){var x;const w=await((x=C)==null?void 0:x.getSetting("showNsfwModelThumbnail"));i(gt(t,G,w))}},[t]);const n=Se(t)?t.modelVersions:t.versions,[r,c]=u.useState(((m=n==null?void 0:n[0])==null?void 0:m.name)??""),l=n==null?void 0:n.find(p=>(p==null?void 0:p.name)===r),d=()=>{window.open(`https://civitai.com/models/${t.id}`)},h=u.useCallback(()=>{if(l==null){console.error("no file is find by name",r);return}s(ee(l),t)},[r]),f=(g=ee(l))==null?void 0:g.sizeKB;return e.jsxs(ce,{width:G,justifyContent:"space-between",mb:2,gap:1,children:[e.jsx(me,{borderRadius:3,boxSize:G+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>d()}),e.jsxs(z,{p:1,children:[e.jsx(J,{label:t.name,children:e.jsx(_,{fontWeight:500,noOfLines:1,children:t.name})}),e.jsxs(A,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(v,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:e.jsx(_,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),e.jsx(v,{leftIcon:e.jsx(ze,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>h(),isDisabled:!!(r&&a.includes(r)),children:"Install"})]}),e.jsxs(N,{children:[e.jsx(V,{size:"md",style:{paddingLeft:4},onChange:p=>{c(p.target.value)},children:n==null?void 0:n.map(p=>{const w=p==null?void 0:p.name;return w?e.jsx("option",{value:w,style:{padding:0},children:w},p.id):null})}),f&&e.jsx(J,{label:te(f),children:e.jsx(_,{flexShrink:1,noOfLines:1,width:"40%",children:te(f)})})]})]})]})}function wt({searchQuery:t,setSearchQuery:s,onSearch:a}){return e.jsxs(A,{gap:1,alignItems:"center",grow:1,children:[e.jsx(O,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>s(o.target.value),onKeyUp:o=>{o.code==="Enter"&&a()}}),e.jsx(v,{size:"sm",onClick:()=>a(),colorScheme:"teal",children:"Search"})]})}function St({isOpen:t,fileSelected:s,onClose:a,selectFolder:o}){const[i,n]=u.useState(""),[r,c]=u.useState([]),[l,d]=u.useState(""),h=u.useRef(null);u.useEffect(()=>{f()},[]);const f=async()=>{const m=await Oe();m&&c(m.filter(g=>!["custom_nodes","config","saved_prompts"].includes(g)))};return e.jsx(Ce,{isOpen:t,leastDestructiveRef:h,onClose:a,children:e.jsx(ae,{children:e.jsxs(Ie,{children:[e.jsx(ie,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),e.jsx(re,{children:e.jsxs(z,{spacing:4,children:[!s&&e.jsxs(e.Fragment,{children:[e.jsx(_,{children:"Model download url"}),e.jsx(O,{placeholder:"https://civitai.com/api/download/models/311399",onChange:m=>d(m.target.value),value:l})]}),e.jsx(_,{children:"Choose model install folder"}),e.jsx(V,{placeholder:"Select option",value:i,onChange:m=>n(m.target.value),children:r.map(m=>e.jsx("option",{value:m,children:m},m))})]})}),e.jsxs(Te,{children:[e.jsx(v,{ref:h,onClick:a,children:"Cancel"}),e.jsx(v,{onClick:()=>o(i,l),ml:3,isDisabled:l.length===0,children:"Confirm"})]})]})})})}function yt(){const{colorMode:t}=ke(),s=de(),[a,o]=u.useState([]);return u.useEffect(()=>{R.addEventListener("download_progress",i=>{o(i.detail)}),R.addEventListener("download_error",i=>{s({title:"Download Error",description:i.detail,status:"error",duration:4e3,isClosable:!0})})},[]),e.jsx(z,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,children:a.map(({save_path:i,progress:n})=>e.jsxs(N,{children:[e.jsx(_,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),e.jsx(ge,{isIndeterminate:!n,hasStripe:!0,width:"50%",value:n}),e.jsxs(_,{fontSize:16,width:"10%",children:[n.toFixed(1),"%"]})]},i))})}const ye="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function jt(){return localStorage.getItem(ye)}function vt(t){localStorage.setItem(ye,t)}function bt(){const[t,s]=u.useState(""),{onOpen:a,onClose:o,isOpen:i}=ue(),n=()=>{vt(t),o()};return e.jsxs(Fe,{isOpen:i,onOpen:a,onClose:o,placement:"right",closeOnBlur:!1,children:[e.jsx(We,{children:e.jsx(v,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),e.jsxs(Ge,{p:5,children:[e.jsx(Ke,{}),e.jsx(He,{}),e.jsxs(z,{spacing:4,children:[e.jsx(_,{fontSize:14,children:"Some Civitai.com models require user login to download, you will nedd a Civitai API key to download in that case"}),e.jsx(O,{value:t,onChange:r=>s(r.target.value),placeholder:"API Key"}),e.jsx(v,{size:"sm",py:1,mr:8,onClick:n,children:"Save"})]})]})]})}const _t=t=>typeof t=="function",je=t=>{const[s,a]=u.useState(t),o=u.useRef(s),i=u.useCallback(n=>{o.current=_t(n)?n(o.current):n,a(o.current)},[]);return[s,i,o]};async function Mt(t){var l,d;const a={limit:"30",nsfw:await((l=C)==null?void 0:l.getSetting("showNsfwModelThumbnail"))??!1,types:t},i=`https://civitai.com/api/v1/models?${new URLSearchParams(a).toString()}`,n=await((d=P.cache)==null?void 0:d.get(i));if((n==null?void 0:n.value)!=null)try{const{data:h,timestamp:f}=JSON.parse(n==null?void 0:n.value);if((Date.now()-f)/(1e3*60*60*24){if(r(!0),m){const S=await Ct(m,c);i(S)}else{const S=await Mt(c);i(S)}r(!1)},[m,c]),F=(S,k)=>{var U,q,Q,X;if(!((U=j.current)!=null&&U.id)&&!k){console.error("no url to download");return}let E=k??`https://civitai.com/api/download/models/${(q=j.current)==null?void 0:q.id}`,I=(Q=j.current)==null?void 0:Q.name;if(!I&&(I=E.split("/").pop(),!I)){console.error("downloadUrl is malformed");return}d({title:"Installing...",description:I,status:"info",duration:4e3,isClosable:!0}),I!=null&&f(ve=>[...ve,I??""]);const Y=jt();Y&&(E+=`?token=${Y}`),ut({file_hash:(X=j.current)==null?void 0:X.SHA256,filename:I,save_path:S,url:E}),b(void 0),x()},W=(S,k)=>{const E=pt[k.type];b(S),E==null?w():F(E)};return u.useEffect(()=>{D()},[c]),e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[e.jsx(ae,{}),e.jsxs(Ae,{width:"90%",maxWidth:"90vw",height:"90vh",children:[e.jsxs(ie,{children:[e.jsxs(N,{gap:2,mb:2,alignItems:"center",children:[e.jsx(he,{size:"md",mr:2,children:"Models"}),e.jsx(wt,{searchQuery:m,setSearchQuery:g,onSearch:D}),e.jsx(v,{size:"sm",py:1,mr:8,onClick:w,children:"Custom URL Install"}),e.jsx(bt,{})]}),e.jsxs(N,{gap:2,mb:2,wrap:"wrap",children:[e.jsx(v,{size:"sm",py:1,onClick:()=>{l(void 0)},isActive:c==null,children:"All"}),ht.map(S=>e.jsx(v,{size:"sm",py:1,isActive:c===S,onClick:()=>{l(S)},children:S},S))]}),n&&e.jsx(H,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),e.jsx(Ne,{}),e.jsxs(re,{overflowY:"auto",children:[e.jsx(N,{wrap:"wrap",children:o==null?void 0:o.map(S=>e.jsx(xt,{model:S,onClickInstallModel:W,installing:h},S.id))}),e.jsx(yt,{})]})]})]}),e.jsx(St,{fileSelected:!!y,isOpen:p,onClose:x,selectFolder:(S,k)=>{F(S,j.current?void 0:k)}})]})}function Tt(){const[t,s]=u.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{size:"sm",colorScheme:"teal",onClick:()=>s(!0),children:"Install Models"}),t&&e.jsx(It,{modelType:"Checkpoint",onclose:()=>s(!1)})]})}const kt=()=>{const[t,s]=u.useState(["checkpoints"]),[a,o]=u.useState([]),[i,n]=u.useState(!0);u.useEffect(()=>{r(),R.addEventListener("model_list",l=>{c(l.detail)})},[]);const r=async()=>{const l=await $e();c(l)},c=async l=>{if(!l)return;n(!1);const d=Array.from(new Set(l.map(f=>f.model_type))),h=d.indexOf("checkpoints");h>=0&&d.splice(h,1),d.unshift("checkpoints"),s(d),o(l)};return{modelTypeList:t,modelsList:a,loading:i}};function Et(){const[t,s,a]=je(!1),o=()=>{var c;(c=C)==null||c.getSetting("showNsfwModelThumbnail").then(l=>{s(l??!1)})};u.useEffect(()=>{o()},[]);const i=c=>{var d;const l=c.target.checked;(d=C)==null||d.upsert({showNsfwModelThumbnail:l}).then(()=>{o(),n(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},n=async()=>{const c=await P.models.toArray();for(let l=0;l{var l,d;try{const h=`https://civitai.com/api/v1/model-versions/by-hash/${c.fileHash}`,m=await(await fetch(h)).json();let g;if(a.current)g=(d=(l=m==null?void 0:m.images)==null?void 0:l[0])==null?void 0:d.url;else if(!m.model.nsfw){const p=m.images.find(w=>w.nsfw==="None");g=p==null?void 0:p.url}P.models.update(c.id,{imageUrl:g??null})}catch{}};return e.jsx(Qe,{isChecked:t,onChange:i,width:"100px",children:"Show NSFW"})}function At({onClose:t}){const[s,a]=u.useState("checkpoints"),[o,i]=u.useState(""),{loading:n,modelTypeList:r,modelsList:c}=kt(),[l,d]=u.useState([]);u.useEffect(()=>{const m=c.filter(g=>o.length?g.model_name.toLowerCase().includes(o.toLowerCase()):g.model_type===s);d(m)},[s,c,o]),u.useEffect(()=>(L.canvasEl.addEventListener("click",t),()=>{L.canvasEl.removeEventListener("click",t)}),[]);const h=440,f=()=>e.jsxs(e.Fragment,{children:[e.jsxs(A,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:[e.jsx(O,{size:"sm",placeholder:"Search",value:o,onChange:m=>i(m.target.value)}),e.jsx(Et,{})]}),!o.length&&e.jsx(rt,{modelTypeList:r,setSelectedModel:a,selectedModel:s}),e.jsx(dt,{list:l}),n&&e.jsx(A,{justifyContent:"center",alignItems:"center",height:"100%",children:e.jsx(H,{})})]});return e.jsx(Pe,{children:e.jsx(le,{style:{width:h},children:e.jsxs(ce,{width:h,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:Ve,overflowY:"auto",children:[e.jsxs(A,{justifyContent:"space-between",alignContent:"center",py:3,children:[e.jsx(he,{size:"md",mr:2,children:"Models"}),e.jsx(Tt,{})]}),f()]})})})}const Nt=u.lazy(()=>De(()=>import("./InstallMissingModelsButton-7QH17Yv3.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function Pt(){const[t,s]=u.useState(!1),[a,o]=u.useState(),i=async r=>{if(r.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const l=r.dataTransfer.getData("modelRelativePath"),d=r.dataTransfer.getData("nodeType"),h=LiteGraph.createNode(d);h.pos=[r.canvasX,r.canvasY],h.configure({widgets_values:[l]}),L.graph.add(h)};u.useEffect(()=>{var r;return(r=C)==null||r.getSetting("modelManagerTopBarStyle").then(c=>{n(c,!1)}),L.canvasEl.addEventListener("drop",i),()=>{L.canvasEl.removeEventListener("drop",i)}},[]);const n=(r,c=!1)=>{var b;const{top:l=0,right:d=0}=a||{},{top:h=0,right:f=0}=r??{};let m=l+h,g=a===void 0?f:d-f;const p=document.documentElement.clientWidth,w=document.documentElement.clientHeight,x=document.getElementById("modelManagerTopBar"),y=(x==null?void 0:x.offsetWidth)||224;m+32>w&&(m=w-38),g+y>p&&(g=p-y-4),o({top:Math.max(4,m),right:Math.max(4,g)}),c&&((b=C)==null||b.upsert({modelManagerTopBarStyle:{top:m,right:g}}))};return e.jsx(Ye,{onDragEnd:r=>{n({top:r.y,right:r.x},!0)},dragIconId:"dragModelManagerTopBarIcon",children:a?e.jsxs(N,{style:{position:"fixed",...a},gap:2,draggable:!1,id:"modelManagerTopBar",className:"model-manager-top-bar",children:[e.jsx(Ue,{id:"dragModelManagerTopBarIcon",className:"drag-model-manager-top-bar-icon",cursor:"move",size:15,color:"#FFF"}),e.jsx(Nt,{}),e.jsx(v,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>s(!0),px:1,children:"Models"}),t&&e.jsx(At,{onClose:()=>s(!1)})]}):""})}const Ot=Object.freeze(Object.defineProperty({__proto__:null,default:Pt},Symbol.toStringTag,{value:"Module"}));export{fe as G,Tt as I,Ot as M,Ct as g}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-iTYBbpS-.js","workspace_web/input.js","workspace_web/App-iJ8dSmpT.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-7NPzADNj.js","workspace_web/chunk-JARCRF6W-yaymqCZ5.js","workspace_web/index-pz0vT7Or.js"] + __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-7QH17Yv3.js","workspace_web/input.js","workspace_web/App-09wdM9e8.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-NnaP5ESt.js","workspace_web/chunk-JARCRF6W-1wZ_35Xk.js","workspace_web/index-pz0vT7Or.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/dist/workspace_web/RecentFilesDrawer-5V6-n8KY.js b/dist/workspace_web/RecentFilesDrawer-KtfWyPT6.js similarity index 97% rename from dist/workspace_web/RecentFilesDrawer-5V6-n8KY.js rename to dist/workspace_web/RecentFilesDrawer-KtfWyPT6.js index 0755837..050bd74 100644 --- a/dist/workspace_web/RecentFilesDrawer-5V6-n8KY.js +++ b/dist/workspace_web/RecentFilesDrawer-KtfWyPT6.js @@ -1,4 +1,4 @@ -import{f as Ye,l as Bn,o as Br,j as _,g as Ue,h as Ke,W as $r,r as R,D as Mt,v as $n,M as vt,L as gt,N as bt,O as yt,Q as wt,R as xt,B as Ce,X as Jt,Y as ut,q as Ur,S as Hr,U as Wr,Z as tt,$ as Zr,a0 as Gr,a1 as Yr,a2 as Un,a3 as Kr,a4 as ie,a5 as ae,a6 as Xr,a7 as Hn,V as se,i as Be,a8 as qr,I as Qt,a9 as hn}from"./input.js";import{b as Jr,a as Qr,u as Wn,c as ei,d as ti,e as ni,S as ri,M as Zn,f as ii,g as ai,h as Ie,H as be,I as we,t as He,i as Gn,j as $e,T as ke,k as it,l as Oe,R as Ve,m as si,n as oi,B as de,F as nt,o as Re,p as fn,v as li,q as Xe,r as at,s as Fe,w as ui,D as Yn,x as ye,y as en,z as Kn,A as tn,C as ci,E as Xn,G as Le,J as di,K as hi,L as fi,N as nn,O as pi,P as mi,Q as Rt,U as We,V as Ut,W as vi,X as gi,Y as bi,Z as yi,_ as wi,$ as xi,a0 as Si,a1 as rn,a2 as _i,a3 as Ci,a4 as pn,a5 as ki,a6 as Oi,a7 as Ii,a8 as Ft}from"./App-iJ8dSmpT.js";import{T as qn}from"./chunk-RPO2WXNL-dt-e86vT.js";import{C as st}from"./chunk-JARCRF6W-yaymqCZ5.js";import{V as mn}from"./chunk-NTCQBYKE-7NPzADNj.js";import{S as Ei,g as Pi,I as Mi,M as ji}from"./MediaPreview-Dl36eUT2.js";import{app as ct}from"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var Jn=Ye(function(e,n){const{borderLeftWidth:s,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:a,borderWidth:r,borderStyle:o,borderColor:c,...f}=Bn("Divider",e),{className:p,orientation:y="horizontal",__css:u,...g}=Br(e),d={vertical:{borderLeftWidth:s||a||r||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||r||"1px",width:"100%"}};return _.jsx(Ue.hr,{ref:n,"aria-orientation":y,...g,__css:{...f,border:"0",borderColor:c,borderStyle:o,...d[y],...u},className:Ke("chakra-divider",p)})});Jn.displayName="Divider";function Di(l,e={}){const{ssr:n=!0,fallback:s}=e,{getWindow:t}=$r(),i=Array.isArray(l)?l:[l];let a=Array.isArray(s)?s:[s];a=a.filter(c=>c!=null);const[r,o]=R.useState(()=>i.map((c,f)=>({media:c,matches:n?!!a[f]:t().matchMedia(c).matches})));return R.useEffect(()=>{const c=t();o(i.map(y=>({media:y,matches:c.matchMedia(y).matches})));const f=i.map(y=>c.matchMedia(y)),p=y=>{o(u=>u.slice().map(g=>g.media===y.media?{...g,matches:y.matches}:g))};return f.forEach(y=>{typeof y.addListener=="function"?y.addListener(p):y.addEventListener("change",p)}),()=>{f.forEach(y=>{typeof y.removeListener=="function"?y.removeListener(p):y.removeEventListener("change",p)})}},[t]),r.map(c=>c.matches)}function zi(l,e,n=Jr){let s=Object.keys(l).indexOf(e);if(s!==-1)return l[e];let t=n.indexOf(e);for(;t>=0;){const i=n[t];if(l.hasOwnProperty(i)){s=t;break}t-=1}if(s!==-1){const i=n[s];return l[i]}}function Ri(l){var e,n;const s=$n(l)?l:{fallback:l??"base"},i=Mt().__breakpoints.details.map(({minMaxQuery:c,breakpoint:f})=>({breakpoint:f,query:c.replace("@media screen and ","")})),a=i.map(c=>c.breakpoint===s.fallback),o=Di(i.map(c=>c.query),{fallback:a,ssr:s.ssr}).findIndex(c=>c==!0);return(n=(e=i[o])==null?void 0:e.breakpoint)!=null?n:s.fallback}function Fi(l,e){var n;const s=$n(e)?e:{fallback:e??"base"},t=Ri(s),i=Mt();if(!t)return;const a=Array.from(((n=i.__breakpoints)==null?void 0:n.keys)||[]),r=Array.isArray(l)?Object.fromEntries(Object.entries(Qr(l,a)).map(([o,c])=>[o,c])):l;return zi(r,t,a)}var Qn=Ye((l,e)=>{const{title:n,children:s,className:t,...i}=l,a=Ke("chakra-menu__group__title",t),r=Wn();return _.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[n&&_.jsx(Ue.p,{className:a,...i,__css:r.groupTitle,children:n}),s]})});Qn.displayName="MenuGroup";var er=l=>{const{className:e,title:n,...s}=l,t=ei(s);return _.jsx(Qn,{title:n,className:Ke("chakra-menu__option-group",e),...t})};er.displayName="MenuOptionGroup";var Ai=Ye((l,e)=>{const n=Wn();return _.jsx(Ue.button,{ref:e,...l,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...n.button}})}),jt=Ye((l,e)=>{const{children:n,as:s,...t}=l,i=ti(t,e),a=s||Ai;return _.jsx(a,{...i,className:Ke("chakra-menu__menu-button",l.className),children:_.jsx(Ue.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:l.children})})});jt.displayName="MenuButton";var Ti=l=>_.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...l,children:_.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"})}),an=Ye((l,e)=>{const{icon:n,iconSpacing:s="0.75rem",...t}=l,i=ni(t,e);return _.jsxs(ri,{...i,className:Ke("chakra-menu__menuitem-option",t.className),children:[n!==null&&_.jsx(Zn,{fontSize:"0.8em",marginEnd:s,opacity:l.isChecked?1:0,children:n||_.jsx(Ti,{})}),_.jsx("span",{style:{flex:1},children:i.children})]})});an.id="MenuItemOption";an.displayName="MenuItemOption";var tr=Ye(function(e,n){const{getHeaderProps:s}=ii(),t=ai();return _.jsx(Ue.header,{...s(e,n),className:Ke("chakra-popover__header",e.className),__css:t.header})});tr.displayName="PopoverHeader";var Li=Ie("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Vi=Ie("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"}]]),vn=Ie("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"}]]),Ni=Ie("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"}]]),nr=Ie("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"}]]),Bi=Ie("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"}]]),$i=Ie("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"}]]),Ui=Ie("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"}]]),Hi=Ie("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"}]]),Wi=Ie("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"}]]),Zi=Ie("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"}]]),Gi=Ie("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"}]]),rr=Ie("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"}]]);function Yi({onclose:l}){const[e,n]=R.useState([]),s=async()=>{var i;const t=await((i=He)==null?void 0:i.listAll());n(t??[])};return R.useEffect(()=>{s()},[]),_.jsxs(vt,{isOpen:!0,onClose:l,children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"My Tags"}),_.jsx(wt,{}),_.jsx(xt,{children:e.map(t=>_.jsxs(be,{children:[_.jsx(qn,{children:t.name}),_.jsx(we,{onClick:async()=>{var i;await((i=He)==null?void 0:i.delete(t.name)),s()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:_.jsx(Gn,{})})]}))})]})]})}function Ki(){const[l,e]=R.useState(""),[n,s]=R.useState(!1),t=()=>s(!0),i=()=>s(!1),a=async o=>{var f;o.preventDefault();let c="";o.ctrlKey&&(c+="Control+"),o.shiftKey&&(c+="Shift+"),o.altKey&&(c+="Alt+"),c.length>0&&!["Control","Shift","Alt"].includes(o.key)&&(c+=o.key.toUpperCase(),await((f=Oe)==null?void 0:f.upsert({shortcuts:{save:c}})),r())},r=()=>{var o;(o=Oe)==null||o.getSetting("shortcuts").then(c=>{var f;e((c==null?void 0:c.save)??((f=Oe)==null?void 0:f.defaultSettings.shortcuts))})};return R.useEffect(()=>{r()},[]),_.jsxs($e,{children:[_.jsx(ke,{children:"Keyboard Shortcut - Save current workflow"}),n&&_.jsx(ke,{color:"gray.500",children:"Press shortcut key combinations to setup"}),_.jsx(it,{value:l,onKeyDown:a,onFocus:t,onBlur:i,placeholder:"Press a key combination",readOnly:!0})]})}function Xi(){const{setRefreshFolderStamp:l}=R.useContext(Ve),[e,n]=R.useState(!1),s=()=>{var i;(i=Oe)==null||i.getSetting("foldersOnTop").then(a=>{n(!!a)})},t=i=>{var r;const a=i.target.checked;(r=Oe)==null||r.upsert({foldersOnTop:a}).then(()=>{s(),l(Date.now())})};return R.useEffect(()=>{s()},[]),_.jsx($e,{children:_.jsx(st,{isChecked:e,onChange:t,children:"Folders always on top"})})}function qi(){const[l,e]=R.useState(!1),n=()=>{var s;(s=Oe)==null||s.getSetting("twoWaySync").then(t=>{e(!!t)})};return R.useEffect(()=>{n()},[]),_.jsxs($e,{children:[_.jsx(ke,{color:"GrayText",children:"If true this will auto detect when you have new .json files added to your workspace saving directory in your disk and automatically import them into your workspace for you"}),_.jsx(st,{isChecked:l,onChange:async s=>{var t;await((t=Oe)==null?void 0:t.upsert({twoWaySync:s.target.checked})),n()},children:"Enable two way sync (DO NOT USE!! EXPERIMENTAL!)"})]})}function gn({settingKey:l,text:e,defaultChecked:n=!1}){const[s,t]=R.useState(n),i=()=>{var a;(a=Oe)==null||a.getSetting(l).then(r=>{t(!!r)})};return R.useEffect(()=>{i()},[]),_.jsx($e,{children:_.jsx(st,{isChecked:s,onChange:async a=>{var r;await((r=Oe)==null?void 0:r.upsert({[l]:a.target.checked})),i()},children:e})})}function Ji({onClose:l}){const[e,n]=R.useState(!1),[s,t]=R.useState(!1),[i,a]=R.useState(""),[r,o]=R.useState([]),[c,f]=R.useState([]),[p,y]=R.useState(!1),u=R.useRef(null),g=si();R.useEffect(()=>{var E;(E=Oe)==null||E.getSetting("myWorkflowsDir").then(D=>{a(D)})},[]);const d=async E=>{const{dir_path:D="",dir_contents:j=[],error:U=""}=await fn(E??"");return U.includes("Operation not permitted")?(y(!0),m(),{isError:!0}):{dirList:j,dirPath:D}},b=async()=>{const{isError:E=!1,dirList:D=[]}=await d(i);E||(f(D),t(!0),o(i&&i.split("/").filter(j=>!!j)||[]))},m=()=>{t(!1),n(!1),o([])},w=async E=>{var U,q;if(E){const{error:O=""}=await fn(E);if(O.includes("Not a directory")){g({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const D=E??`/${r.join("/")}`;await((U=Oe)==null?void 0:U.upsert({myWorkflowsDir:D}));const j=await((q=Oe)==null?void 0:q.getSetting("myWorkflowsDir"))??"";a(j),E&&y(!1),m(),li()},x=async()=>{const{dirPath:E,dirList:D}=await d("");o(E.split("/").filter(j=>!!j)),f(D)},C=async(E,D)=>{var O;let j="";E===-1&&D?j=`/${r.concat([D]).join("/")}`:j=`/${r.slice(0,E+1).join("/")}`;const{isError:U=!1,dirList:q=[]}=await d(j);U||(f(q),o((O=j.slice(1))==null?void 0:O.split("/")))},I=()=>{t(!0),n(!0)},P=_.jsxs(de,{textAlign:"end",mb:4,children:[_.jsx(it,{placeholder:"Please enter the absolute path directory address",ref:u,mt:2,mb:2}),_.jsx(Ce,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var E,D;(E=u==null?void 0:u.current)!=null&&E.value&&w((D=u==null?void 0:u.current)==null?void 0:D.value)},children:"Save"})]});return _.jsxs(_.Fragment,{children:[_.jsxs(vt,{isOpen:!0,onClose:l,size:"xl",children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"Settings"}),_.jsx(wt,{}),_.jsx(xt,{pb:14,children:_.jsx(be,{children:_.jsxs(mn,{divider:_.jsx(oi,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[_.jsxs(de,{mb:4,children:[_.jsx(ke,{mb:2,fontWeight:500,children:"Workspace Save Directory"}),s?e?P:_.jsxs(mn,{spacing:2,alignItems:"start",children:[_.jsx($e,{spacing:"2px",direction:"row",wrap:"wrap",children:r.map((E,D)=>_.jsxs(_.Fragment,{children:["/",_.jsx(Ce,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{C(D)},children:E},`${E}-${D}`)]}))}),_.jsx(Ei,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((E,D)=>_.jsx(Ce,{size:"sm",leftIcon:_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:_.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:()=>{C(-1,E)},children:E},`${E}-${D}`))}),_.jsxs(de,{w:"100%",textAlign:"end",children:[_.jsx(Ce,{colorScheme:"teal",size:"sm",onClick:()=>{w()},children:"Save"}),_.jsx(Ce,{size:"sm",onClick:x,mr:2,ml:2,children:"Reset"}),_.jsx(Ce,{size:"sm",onClick:m,children:"Cancel"})]})]}):_.jsxs(nt,{children:[_.jsx(qn,{overflowWrap:"anywhere",children:i}),_.jsx(Re,{label:"Choose folder",children:_.jsx(we,{"aria-label":"Select folder",size:"sm",ml:2,icon:_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:_.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:b})}),_.jsx(Re,{label:"Input absolute path",children:_.jsx(we,{"aria-label":"Enter folder address",size:"sm",ml:2,icon:_.jsx(Vi,{size:19}),onClick:I,variant:"ghost"})})]})]}),_.jsx(Ki,{}),_.jsx(gn,{settingKey:"autoSave",text:"Enable auto save workflow"}),_.jsx(qi,{}),_.jsx(Xi,{}),_.jsx(gn,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"})]})})})]})]}),_.jsxs(vt,{isOpen:p,onClose:()=>y(!1),size:"xl",children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"Kind tips"}),_.jsx(wt,{}),_.jsx(xt,{children:_.jsxs(de,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?_.jsxs(ke,{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",_.jsx(Ce,{colorScheme:"teal",variant:"link",as:"a",ml:2,target:"_block",href:`https://stackoverflow.com/questions/58479686/permissionerror-errno-1-operation-not-permitted-after-macos +import{f as Ye,l as Bn,o as Br,j as _,g as Ue,h as Ke,W as $r,r as R,D as Mt,v as $n,M as vt,L as gt,N as bt,O as yt,Q as wt,R as xt,B as Ce,X as Jt,Y as ut,q as Ur,S as Hr,U as Wr,Z as tt,$ as Zr,a0 as Gr,a1 as Yr,a2 as Un,a3 as Kr,a4 as ie,a5 as ae,a6 as Xr,a7 as Hn,V as se,i as Be,a8 as qr,I as Qt,a9 as hn}from"./input.js";import{b as Jr,a as Qr,u as Wn,c as ei,d as ti,e as ni,S as ri,M as Zn,f as ii,g as ai,h as Ie,H as be,I as we,t as He,i as Gn,j as $e,T as ke,k as it,l as Oe,R as Ve,m as si,n as oi,B as de,F as nt,o as Re,p as fn,v as li,q as Xe,r as at,s as Fe,w as ui,D as Yn,x as ye,y as en,z as Kn,A as tn,C as ci,E as Xn,G as Le,J as di,K as hi,L as fi,N as nn,O as pi,P as mi,Q as Rt,U as We,V as Ut,W as vi,X as gi,Y as bi,Z as yi,_ as wi,$ as xi,a0 as Si,a1 as rn,a2 as _i,a3 as Ci,a4 as pn,a5 as ki,a6 as Oi,a7 as Ii,a8 as Ft}from"./App-09wdM9e8.js";import{T as qn}from"./chunk-RPO2WXNL-dt-e86vT.js";import{C as st}from"./chunk-JARCRF6W-1wZ_35Xk.js";import{V as mn}from"./chunk-NTCQBYKE-NnaP5ESt.js";import{S as Ei,g as Pi,I as Mi,M as ji}from"./MediaPreview-nO-IKtd3.js";import{app as ct}from"/scripts/app.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";var Jn=Ye(function(e,n){const{borderLeftWidth:s,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:a,borderWidth:r,borderStyle:o,borderColor:c,...f}=Bn("Divider",e),{className:p,orientation:y="horizontal",__css:u,...g}=Br(e),d={vertical:{borderLeftWidth:s||a||r||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||r||"1px",width:"100%"}};return _.jsx(Ue.hr,{ref:n,"aria-orientation":y,...g,__css:{...f,border:"0",borderColor:c,borderStyle:o,...d[y],...u},className:Ke("chakra-divider",p)})});Jn.displayName="Divider";function Di(l,e={}){const{ssr:n=!0,fallback:s}=e,{getWindow:t}=$r(),i=Array.isArray(l)?l:[l];let a=Array.isArray(s)?s:[s];a=a.filter(c=>c!=null);const[r,o]=R.useState(()=>i.map((c,f)=>({media:c,matches:n?!!a[f]:t().matchMedia(c).matches})));return R.useEffect(()=>{const c=t();o(i.map(y=>({media:y,matches:c.matchMedia(y).matches})));const f=i.map(y=>c.matchMedia(y)),p=y=>{o(u=>u.slice().map(g=>g.media===y.media?{...g,matches:y.matches}:g))};return f.forEach(y=>{typeof y.addListener=="function"?y.addListener(p):y.addEventListener("change",p)}),()=>{f.forEach(y=>{typeof y.removeListener=="function"?y.removeListener(p):y.removeEventListener("change",p)})}},[t]),r.map(c=>c.matches)}function zi(l,e,n=Jr){let s=Object.keys(l).indexOf(e);if(s!==-1)return l[e];let t=n.indexOf(e);for(;t>=0;){const i=n[t];if(l.hasOwnProperty(i)){s=t;break}t-=1}if(s!==-1){const i=n[s];return l[i]}}function Ri(l){var e,n;const s=$n(l)?l:{fallback:l??"base"},i=Mt().__breakpoints.details.map(({minMaxQuery:c,breakpoint:f})=>({breakpoint:f,query:c.replace("@media screen and ","")})),a=i.map(c=>c.breakpoint===s.fallback),o=Di(i.map(c=>c.query),{fallback:a,ssr:s.ssr}).findIndex(c=>c==!0);return(n=(e=i[o])==null?void 0:e.breakpoint)!=null?n:s.fallback}function Fi(l,e){var n;const s=$n(e)?e:{fallback:e??"base"},t=Ri(s),i=Mt();if(!t)return;const a=Array.from(((n=i.__breakpoints)==null?void 0:n.keys)||[]),r=Array.isArray(l)?Object.fromEntries(Object.entries(Qr(l,a)).map(([o,c])=>[o,c])):l;return zi(r,t,a)}var Qn=Ye((l,e)=>{const{title:n,children:s,className:t,...i}=l,a=Ke("chakra-menu__group__title",t),r=Wn();return _.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[n&&_.jsx(Ue.p,{className:a,...i,__css:r.groupTitle,children:n}),s]})});Qn.displayName="MenuGroup";var er=l=>{const{className:e,title:n,...s}=l,t=ei(s);return _.jsx(Qn,{title:n,className:Ke("chakra-menu__option-group",e),...t})};er.displayName="MenuOptionGroup";var Ai=Ye((l,e)=>{const n=Wn();return _.jsx(Ue.button,{ref:e,...l,__css:{display:"inline-flex",appearance:"none",alignItems:"center",outline:0,...n.button}})}),jt=Ye((l,e)=>{const{children:n,as:s,...t}=l,i=ti(t,e),a=s||Ai;return _.jsx(a,{...i,className:Ke("chakra-menu__menu-button",l.className),children:_.jsx(Ue.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:l.children})})});jt.displayName="MenuButton";var Ti=l=>_.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...l,children:_.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"})}),an=Ye((l,e)=>{const{icon:n,iconSpacing:s="0.75rem",...t}=l,i=ni(t,e);return _.jsxs(ri,{...i,className:Ke("chakra-menu__menuitem-option",t.className),children:[n!==null&&_.jsx(Zn,{fontSize:"0.8em",marginEnd:s,opacity:l.isChecked?1:0,children:n||_.jsx(Ti,{})}),_.jsx("span",{style:{flex:1},children:i.children})]})});an.id="MenuItemOption";an.displayName="MenuItemOption";var tr=Ye(function(e,n){const{getHeaderProps:s}=ii(),t=ai();return _.jsx(Ue.header,{...s(e,n),className:Ke("chakra-popover__header",e.className),__css:t.header})});tr.displayName="PopoverHeader";var Li=Ie("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Vi=Ie("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"}]]),vn=Ie("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"}]]),Ni=Ie("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"}]]),nr=Ie("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"}]]),Bi=Ie("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"}]]),$i=Ie("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"}]]),Ui=Ie("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"}]]),Hi=Ie("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"}]]),Wi=Ie("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"}]]),Zi=Ie("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"}]]),Gi=Ie("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"}]]),rr=Ie("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"}]]);function Yi({onclose:l}){const[e,n]=R.useState([]),s=async()=>{var i;const t=await((i=He)==null?void 0:i.listAll());n(t??[])};return R.useEffect(()=>{s()},[]),_.jsxs(vt,{isOpen:!0,onClose:l,children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"My Tags"}),_.jsx(wt,{}),_.jsx(xt,{children:e.map(t=>_.jsxs(be,{children:[_.jsx(qn,{children:t.name}),_.jsx(we,{onClick:async()=>{var i;await((i=He)==null?void 0:i.delete(t.name)),s()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:_.jsx(Gn,{})})]}))})]})]})}function Ki(){const[l,e]=R.useState(""),[n,s]=R.useState(!1),t=()=>s(!0),i=()=>s(!1),a=async o=>{var f;o.preventDefault();let c="";o.ctrlKey&&(c+="Control+"),o.shiftKey&&(c+="Shift+"),o.altKey&&(c+="Alt+"),c.length>0&&!["Control","Shift","Alt"].includes(o.key)&&(c+=o.key.toUpperCase(),await((f=Oe)==null?void 0:f.upsert({shortcuts:{save:c}})),r())},r=()=>{var o;(o=Oe)==null||o.getSetting("shortcuts").then(c=>{var f;e((c==null?void 0:c.save)??((f=Oe)==null?void 0:f.defaultSettings.shortcuts))})};return R.useEffect(()=>{r()},[]),_.jsxs($e,{children:[_.jsx(ke,{children:"Keyboard Shortcut - Save current workflow"}),n&&_.jsx(ke,{color:"gray.500",children:"Press shortcut key combinations to setup"}),_.jsx(it,{value:l,onKeyDown:a,onFocus:t,onBlur:i,placeholder:"Press a key combination",readOnly:!0})]})}function Xi(){const{setRefreshFolderStamp:l}=R.useContext(Ve),[e,n]=R.useState(!1),s=()=>{var i;(i=Oe)==null||i.getSetting("foldersOnTop").then(a=>{n(!!a)})},t=i=>{var r;const a=i.target.checked;(r=Oe)==null||r.upsert({foldersOnTop:a}).then(()=>{s(),l(Date.now())})};return R.useEffect(()=>{s()},[]),_.jsx($e,{children:_.jsx(st,{isChecked:e,onChange:t,children:"Folders always on top"})})}function qi(){const[l,e]=R.useState(!1),n=()=>{var s;(s=Oe)==null||s.getSetting("twoWaySync").then(t=>{e(!!t)})};return R.useEffect(()=>{n()},[]),_.jsxs($e,{children:[_.jsx(ke,{color:"GrayText",children:"If true this will auto detect when you have new .json files added to your workspace saving directory in your disk and automatically import them into your workspace for you"}),_.jsx(st,{isChecked:l,onChange:async s=>{var t;await((t=Oe)==null?void 0:t.upsert({twoWaySync:s.target.checked})),n()},children:"Enable two way sync (DO NOT USE!! EXPERIMENTAL!)"})]})}function gn({settingKey:l,text:e,defaultChecked:n=!1}){const[s,t]=R.useState(n),i=()=>{var a;(a=Oe)==null||a.getSetting(l).then(r=>{t(!!r)})};return R.useEffect(()=>{i()},[]),_.jsx($e,{children:_.jsx(st,{isChecked:s,onChange:async a=>{var r;await((r=Oe)==null?void 0:r.upsert({[l]:a.target.checked})),i()},children:e})})}function Ji({onClose:l}){const[e,n]=R.useState(!1),[s,t]=R.useState(!1),[i,a]=R.useState(""),[r,o]=R.useState([]),[c,f]=R.useState([]),[p,y]=R.useState(!1),u=R.useRef(null),g=si();R.useEffect(()=>{var E;(E=Oe)==null||E.getSetting("myWorkflowsDir").then(D=>{a(D)})},[]);const d=async E=>{const{dir_path:D="",dir_contents:j=[],error:U=""}=await fn(E??"");return U.includes("Operation not permitted")?(y(!0),m(),{isError:!0}):{dirList:j,dirPath:D}},b=async()=>{const{isError:E=!1,dirList:D=[]}=await d(i);E||(f(D),t(!0),o(i&&i.split("/").filter(j=>!!j)||[]))},m=()=>{t(!1),n(!1),o([])},w=async E=>{var U,q;if(E){const{error:O=""}=await fn(E);if(O.includes("Not a directory")){g({title:"The directory address you entered is invalid, please re-enter it.",status:"warning",duration:5e3,position:"top",isClosable:!0});return}}const D=E??`/${r.join("/")}`;await((U=Oe)==null?void 0:U.upsert({myWorkflowsDir:D}));const j=await((q=Oe)==null?void 0:q.getSetting("myWorkflowsDir"))??"";a(j),E&&y(!1),m(),li()},x=async()=>{const{dirPath:E,dirList:D}=await d("");o(E.split("/").filter(j=>!!j)),f(D)},C=async(E,D)=>{var O;let j="";E===-1&&D?j=`/${r.concat([D]).join("/")}`:j=`/${r.slice(0,E+1).join("/")}`;const{isError:U=!1,dirList:q=[]}=await d(j);U||(f(q),o((O=j.slice(1))==null?void 0:O.split("/")))},I=()=>{t(!0),n(!0)},P=_.jsxs(de,{textAlign:"end",mb:4,children:[_.jsx(it,{placeholder:"Please enter the absolute path directory address",ref:u,mt:2,mb:2}),_.jsx(Ce,{colorScheme:"teal",mr:3,size:"sm",onClick:()=>{var E,D;(E=u==null?void 0:u.current)!=null&&E.value&&w((D=u==null?void 0:u.current)==null?void 0:D.value)},children:"Save"})]});return _.jsxs(_.Fragment,{children:[_.jsxs(vt,{isOpen:!0,onClose:l,size:"xl",children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"Settings"}),_.jsx(wt,{}),_.jsx(xt,{pb:14,children:_.jsx(be,{children:_.jsxs(mn,{divider:_.jsx(oi,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[_.jsxs(de,{mb:4,children:[_.jsx(ke,{mb:2,fontWeight:500,children:"Workspace Save Directory"}),s?e?P:_.jsxs(mn,{spacing:2,alignItems:"start",children:[_.jsx($e,{spacing:"2px",direction:"row",wrap:"wrap",children:r.map((E,D)=>_.jsxs(_.Fragment,{children:["/",_.jsx(Ce,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{C(D)},children:E},`${E}-${D}`)]}))}),_.jsx(Ei,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((E,D)=>_.jsx(Ce,{size:"sm",leftIcon:_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:_.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:()=>{C(-1,E)},children:E},`${E}-${D}`))}),_.jsxs(de,{w:"100%",textAlign:"end",children:[_.jsx(Ce,{colorScheme:"teal",size:"sm",onClick:()=>{w()},children:"Save"}),_.jsx(Ce,{size:"sm",onClick:x,mr:2,ml:2,children:"Reset"}),_.jsx(Ce,{size:"sm",onClick:m,children:"Cancel"})]})]}):_.jsxs(nt,{children:[_.jsx(qn,{overflowWrap:"anywhere",children:i}),_.jsx(Re,{label:"Choose folder",children:_.jsx(we,{"aria-label":"Select folder",size:"sm",ml:2,icon:_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:_.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:b})}),_.jsx(Re,{label:"Input absolute path",children:_.jsx(we,{"aria-label":"Enter folder address",size:"sm",ml:2,icon:_.jsx(Vi,{size:19}),onClick:I,variant:"ghost"})})]})]}),_.jsx(Ki,{}),_.jsx(gn,{settingKey:"autoSave",text:"Enable auto save workflow"}),_.jsx(qi,{}),_.jsx(Xi,{}),_.jsx(gn,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"})]})})})]})]}),_.jsxs(vt,{isOpen:p,onClose:()=>y(!1),size:"xl",children:[_.jsx(gt,{}),_.jsxs(bt,{children:[_.jsx(yt,{children:"Kind tips"}),_.jsx(wt,{}),_.jsx(xt,{children:_.jsxs(de,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?_.jsxs(ke,{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",_.jsx(Ce,{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."]}):_.jsx(ke,{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."}),P]})})]})]})]})}const At=16;function Qi({}){const[l,e]=R.useState(!1),[n,s]=R.useState(!1),{colorMode:t,toggleColorMode:i}=Jt();return _.jsxs(_.Fragment,{children:[_.jsxs(Xe,{isLazy:!0,children:[_.jsx(jt,{as:we,"aria-label":"Options",icon:_.jsx($i,{}),size:"sm",variant:"outline"}),_.jsxs(at,{children:[_.jsx(Fe,{onClick:()=>s(!0),icon:_.jsx(Zi,{size:16}),fontSize:16,children:"Settings"}),_.jsx(Fe,{onClick:()=>e(!0),icon:_.jsx(rr,{size:At}),fontSize:16,children:"Manage Tags"}),_.jsxs(Fe,{onClick:i,icon:t==="light"?_.jsx(Ui,{size:At}):_.jsx(Gi,{size:At}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),l&&_.jsx(Yi,{onclose:()=>e(!1)}),n&&_.jsx(Ji,{onClose:()=>s(!1)})]})}function dt(l){throw new Error('Could not dynamically require "'+l+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ir={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -15,4 +15,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function or(l){return Sa(l)||_a(l)||sr(l)||Ca()}function ka(l,e){return e||(e=l.slice(0)),Object.freeze(Object.defineProperties(l,{raw:{value:Object.freeze(e)}}))}const Oa=Math.min,Ia=Math.max,_t=Math.round,ht=Math.floor,Ct=l=>({x:l,y:l});function Ea(l){return{...l,top:l.y,left:l.x,right:l.x+l.width,bottom:l.y+l.height}}function lr(l){return cr(l)?(l.nodeName||"").toLowerCase():"#document"}function je(l){var e;return(l==null||(e=l.ownerDocument)==null?void 0:e.defaultView)||window}function ur(l){var e;return(e=(cr(l)?l.ownerDocument:l.document)||window.document)==null?void 0:e.documentElement}function cr(l){return l instanceof Node||l instanceof je(l).Node}function Wt(l){return l instanceof Element||l instanceof je(l).Element}function sn(l){return l instanceof HTMLElement||l instanceof je(l).HTMLElement}function Sn(l){return typeof ShadowRoot>"u"?!1:l instanceof ShadowRoot||l instanceof je(l).ShadowRoot}function dr(l){const{overflow:e,overflowX:n,overflowY:s,display:t}=on(l);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!["inline","contents"].includes(t)}function Pa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ma(l){return["html","body","#document"].includes(lr(l))}function on(l){return je(l).getComputedStyle(l)}function ja(l){if(lr(l)==="html")return l;const e=l.assignedSlot||l.parentNode||Sn(l)&&l.host||ur(l);return Sn(e)?e.host:e}function hr(l){const e=ja(l);return Ma(e)?l.ownerDocument?l.ownerDocument.body:l.body:sn(e)&&dr(e)?e:hr(e)}function kt(l,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const t=hr(l),i=t===((s=l.ownerDocument)==null?void 0:s.body),a=je(t);return i?e.concat(a,a.visualViewport||[],dr(t)?t:[],a.frameElement&&n?kt(a.frameElement):[]):e.concat(t,kt(t,[],n))}function Da(l){const e=on(l);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const t=sn(l),i=t?l.offsetWidth:n,a=t?l.offsetHeight:s,r=_t(n)!==i||_t(s)!==a;return r&&(n=i,s=a),{width:n,height:s,$:r}}function ln(l){return Wt(l)?l:l.contextElement}function Tt(l){const e=ln(l);if(!sn(e))return Ct(1);const n=e.getBoundingClientRect(),{width:s,height:t,$:i}=Da(e);let a=(i?_t(n.width):n.width)/s,r=(i?_t(n.height):n.height)/t;return(!a||!Number.isFinite(a))&&(a=1),(!r||!Number.isFinite(r))&&(r=1),{x:a,y:r}}const za=Ct(0);function Ra(l){const e=je(l);return!Pa()||!e.visualViewport?za:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Fa(l,e,n){return e===void 0&&(e=!1),!n||e&&n!==je(l)?!1:e}function _n(l,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const t=l.getBoundingClientRect(),i=ln(l);let a=Ct(1);e&&(s?Wt(s)&&(a=Tt(s)):a=Tt(l));const r=Fa(i,n,s)?Ra(i):Ct(0);let o=(t.left+r.x)/a.x,c=(t.top+r.y)/a.y,f=t.width/a.x,p=t.height/a.y;if(i){const y=je(i),u=s&&Wt(s)?je(s):s;let g=y.frameElement;for(;g&&s&&u!==y;){const d=Tt(g),b=g.getBoundingClientRect(),m=on(g),w=b.left+(g.clientLeft+parseFloat(m.paddingLeft))*d.x,x=b.top+(g.clientTop+parseFloat(m.paddingTop))*d.y;o*=d.x,c*=d.y,f*=d.x,p*=d.y,o+=w,c+=x,g=je(g).frameElement}}return Ea({width:f,height:p,x:o,y:c})}function Aa(l,e){let n=null,s;const t=ur(l);function i(){clearTimeout(s),n&&n.disconnect(),n=null}function a(r,o){r===void 0&&(r=!1),o===void 0&&(o=1),i();const{left:c,top:f,width:p,height:y}=l.getBoundingClientRect();if(r||e(),!p||!y)return;const u=ht(f),g=ht(t.clientWidth-(c+p)),d=ht(t.clientHeight-(f+y)),b=ht(c),w={rootMargin:-u+"px "+-g+"px "+-d+"px "+-b+"px",threshold:Ia(0,Oa(1,o))||1};let x=!0;function C(I){const P=I[0].intersectionRatio;if(P!==o){if(!x)return a();P?a(!1,P):s=setTimeout(()=>{a(!1,1e-7)},100)}x=!1}try{n=new IntersectionObserver(C,{...w,root:t.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(l)}return a(!0),i}function Ta(l,e,n,s){s===void 0&&(s={});const{ancestorScroll:t=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:o=!1}=s,c=ln(l),f=t||i?[...c?kt(c):[],...kt(e)]:[];f.forEach(m=>{t&&m.addEventListener("scroll",n,{passive:!0}),i&&m.addEventListener("resize",n)});const p=c&&r?Aa(c,n):null;let y=-1,u=null;a&&(u=new ResizeObserver(m=>{let[w]=m;w&&w.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{u&&u.observe(e)})),n()}),c&&!o&&u.observe(c),u.observe(e));let g,d=o?_n(l):null;o&&b();function b(){const m=_n(l);d&&(m.x!==d.x||m.y!==d.y||m.width!==d.width||m.height!==d.height)&&n(),d=m,g=requestAnimationFrame(b)}return n(),()=>{f.forEach(m=>{t&&m.removeEventListener("scroll",n),i&&m.removeEventListener("resize",n)}),p&&p(),u&&u.disconnect(),u=null,o&&cancelAnimationFrame(g)}}var Zt=R.useLayoutEffect,La=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],Ot=function(){};function Va(l,e){return e?e[0]==="-"?l+e:l+"__"+e:l}function Na(l,e){for(var n=arguments.length,s=new Array(n>2?n-2:0),t=2;t-1}function Ba(l){return Dt(l)?window.innerHeight:l.clientHeight}function pr(l){return Dt(l)?window.pageYOffset:l.scrollTop}function It(l,e){if(Dt(l)){window.scrollTo(0,e);return}l.scrollTop=e}function $a(l){var e=getComputedStyle(l),n=e.position==="absolute",s=/(auto|scroll)/;if(e.position==="fixed")return document.documentElement;for(var t=l;t=t.parentElement;)if(e=getComputedStyle(t),!(n&&e.position==="static")&&s.test(e.overflow+e.overflowY+e.overflowX))return t;return document.documentElement}function Ua(l,e,n,s){return n*((l=l/s-1)*l*l+1)+e}function ft(l,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ot,t=pr(l),i=e-t,a=10,r=0;function o(){r+=a;var c=Ua(r,t,i,n);It(l,c),rn.bottom?It(l,Math.min(e.offsetTop+e.clientHeight-l.offsetHeight+t,l.scrollHeight)):s.top-t1?n-1:0),t=1;t=g)return{placement:"bottom",maxHeight:e};if(j>=g&&!a)return i&&ft(o,U,O),{placement:"bottom",maxHeight:e};if(!a&&j>=s||a&&E>=s){i&&ft(o,U,O);var L=a?E-C:j-C;return{placement:"bottom",maxHeight:L}}if(t==="auto"||a){var v=e,N=a?P:D;return N>=s&&(v=Math.min(N-C-r,e)),{placement:"top",maxHeight:v}}if(t==="bottom")return i&&It(o,U),{placement:"bottom",maxHeight:e};break;case"top":if(P>=g)return{placement:"top",maxHeight:e};if(D>=g&&!a)return i&&ft(o,q,O),{placement:"top",maxHeight:e};if(!a&&D>=s||a&&P>=s){var te=e;return(!a&&D>=s||a&&P>=s)&&(te=a?P-I:D-I),i&&ft(o,q,O),{placement:"top",maxHeight:te}}return{placement:"bottom",maxHeight:e};default:throw new Error('Invalid placement provided "'.concat(t,'".'))}return c}function es(l){var e={bottom:"top",top:"bottom"};return l?e[l]:"bottom"}var vr=function(e){return e==="auto"?"bottom":e},ts=function(e,n){var s,t=e.placement,i=e.theme,a=i.borderRadius,r=i.spacing,o=i.colors;return re((s={label:"menu"},tt(s,es(t),"100%"),tt(s,"position","absolute"),tt(s,"width","100%"),tt(s,"zIndex",1),s),n?{}:{backgroundColor:o.neutral0,borderRadius:a,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:r.menuGutter,marginTop:r.menuGutter})},gr=R.createContext(null),ns=function(e){var n=e.children,s=e.minMenuHeight,t=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,r=e.menuShouldScrollIntoView,o=e.theme,c=R.useContext(gr)||{},f=c.setPortalPlacement,p=R.useRef(null),y=R.useState(t),u=Te(y,2),g=u[0],d=u[1],b=R.useState(null),m=Te(b,2),w=m[0],x=m[1],C=o.spacing.controlHeight;return Zt(function(){var I=p.current;if(I){var P=a==="fixed",E=r&&!P,D=Qa({maxHeight:t,menuEl:I,minHeight:s,placement:i,shouldScroll:E,isFixedPosition:P,controlHeight:C});d(D.maxHeight),x(D.placement),f==null||f(D.placement)}},[t,i,a,r,s,f,C]),n({ref:p,placerProps:re(re({},e),{},{placement:w||vr(i),maxHeight:g})})},rs=function(e){var n=e.children,s=e.innerRef,t=e.innerProps;return ie("div",ae({},me(e,"menu",{menu:!0}),{ref:s},t),n)},is=rs,as=function(e,n){var s=e.maxHeight,t=e.theme.spacing.baseUnit;return re({maxHeight:s,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},n?{}:{paddingBottom:t,paddingTop:t})},ss=function(e){var n=e.children,s=e.innerProps,t=e.innerRef,i=e.isMulti;return ie("div",ae({},me(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:t},s),n)},br=function(e,n){var s=e.theme,t=s.spacing.baseUnit,i=s.colors;return re({textAlign:"center"},n?{}:{color:i.neutral40,padding:"".concat(t*2,"px ").concat(t*3,"px")})},os=br,ls=br,us=function(e){var n=e.children,s=n===void 0?"No options":n,t=e.innerProps,i=Ne(e,qa);return ie("div",ae({},me(re(re({},i),{},{children:s,innerProps:t}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),t),s)},cs=function(e){var n=e.children,s=n===void 0?"Loading...":n,t=e.innerProps,i=Ne(e,Ja);return ie("div",ae({},me(re(re({},i),{},{children:s,innerProps:t}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),t),s)},ds=function(e){var n=e.rect,s=e.offset,t=e.position;return{left:n.left,position:t,top:s,width:n.width,zIndex:1}},hs=function(e){var n=e.appendTo,s=e.children,t=e.controlElement,i=e.innerProps,a=e.menuPlacement,r=e.menuPosition,o=R.useRef(null),c=R.useRef(null),f=R.useState(vr(a)),p=Te(f,2),y=p[0],u=p[1],g=R.useMemo(function(){return{setPortalPlacement:u}},[]),d=R.useState(null),b=Te(d,2),m=b[0],w=b[1],x=R.useCallback(function(){if(t){var E=Ha(t),D=r==="fixed"?0:window.pageYOffset,j=E[y]+D;(j!==(m==null?void 0:m.offset)||E.left!==(m==null?void 0:m.rect.left)||E.width!==(m==null?void 0:m.rect.width))&&w({offset:j,rect:E})}},[t,r,y,m==null?void 0:m.offset,m==null?void 0:m.rect.left,m==null?void 0:m.rect.width]);Zt(function(){x()},[x]);var C=R.useCallback(function(){typeof c.current=="function"&&(c.current(),c.current=null),t&&o.current&&(c.current=Ta(t,o.current,x,{elementResize:"ResizeObserver"in window}))},[t,x]);Zt(function(){C()},[C]);var I=R.useCallback(function(E){o.current=E,C()},[C]);if(!n&&r!=="fixed"||!m)return null;var P=ie("div",ae({ref:I},me(re(re({},e),{},{offset:m.offset,position:r,rect:m.rect}),"menuPortal",{"menu-portal":!0}),i),s);return ie(gr.Provider,{value:g},n?Xr.createPortal(P,n):P)},fs=function(e){var n=e.isDisabled,s=e.isRtl;return{label:"container",direction:s?"rtl":void 0,pointerEvents:n?"none":void 0,position:"relative"}},ps=function(e){var n=e.children,s=e.innerProps,t=e.isDisabled,i=e.isRtl;return ie("div",ae({},me(e,"container",{"--is-disabled":t,"--is-rtl":i}),s),n)},ms=function(e,n){var s=e.theme.spacing,t=e.isMulti,i=e.hasValue,a=e.selectProps.controlShouldRenderValue;return re({alignItems:"center",display:t&&i&&a?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},n?{}:{padding:"".concat(s.baseUnit/2,"px ").concat(s.baseUnit*2,"px")})},vs=function(e){var n=e.children,s=e.innerProps,t=e.isMulti,i=e.hasValue;return ie("div",ae({},me(e,"valueContainer",{"value-container":!0,"value-container--is-multi":t,"value-container--has-value":i}),s),n)},gs=function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},bs=function(e){var n=e.children,s=e.innerProps;return ie("div",ae({},me(e,"indicatorsContainer",{indicators:!0}),s),n)},In,ys=["size"],ws=["innerProps","isRtl","size"],xs={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},yr=function(e){var n=e.size,s=Ne(e,ys);return ie("svg",ae({height:n,width:n,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:xs},s))},un=function(e){return ie(yr,ae({size:20},e),ie("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"}))},wr=function(e){return ie(yr,ae({size:20},e),ie("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"}))},xr=function(e,n){var s=e.isFocused,t=e.theme,i=t.spacing.baseUnit,a=t.colors;return re({label:"indicatorContainer",display:"flex",transition:"color 150ms"},n?{}:{color:s?a.neutral60:a.neutral20,padding:i*2,":hover":{color:s?a.neutral80:a.neutral40}})},Ss=xr,_s=function(e){var n=e.children,s=e.innerProps;return ie("div",ae({},me(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),s),n||ie(wr,null))},Cs=xr,ks=function(e){var n=e.children,s=e.innerProps;return ie("div",ae({},me(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),s),n||ie(un,null))},Os=function(e,n){var s=e.isDisabled,t=e.theme,i=t.spacing.baseUnit,a=t.colors;return re({label:"indicatorSeparator",alignSelf:"stretch",width:1},n?{}:{backgroundColor:s?a.neutral10:a.neutral20,marginBottom:i*2,marginTop:i*2})},Is=function(e){var n=e.innerProps;return ie("span",ae({},n,me(e,"indicatorSeparator",{"indicator-separator":!0})))},Es=Kr(In||(In=ka([` 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } -`]))),Ps=function(e,n){var s=e.isFocused,t=e.size,i=e.theme,a=i.colors,r=i.spacing.baseUnit;return re({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:t,lineHeight:1,marginRight:t,textAlign:"center",verticalAlign:"middle"},n?{}:{color:s?a.neutral60:a.neutral20,padding:r*2})},Lt=function(e){var n=e.delay,s=e.offset;return ie("span",{css:Hn({animation:"".concat(Es," 1s ease-in-out ").concat(n,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:s?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Ms=function(e){var n=e.innerProps,s=e.isRtl,t=e.size,i=t===void 0?4:t,a=Ne(e,ws);return ie("div",ae({},me(re(re({},a),{},{innerProps:n,isRtl:s,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),n),ie(Lt,{delay:0,offset:s}),ie(Lt,{delay:160,offset:!0}),ie(Lt,{delay:320,offset:!s}))},js=function(e,n){var s=e.isDisabled,t=e.isFocused,i=e.theme,a=i.colors,r=i.borderRadius,o=i.spacing;return re({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:o.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},n?{}:{backgroundColor:s?a.neutral5:a.neutral0,borderColor:s?a.neutral10:t?a.primary:a.neutral20,borderRadius:r,borderStyle:"solid",borderWidth:1,boxShadow:t?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:t?a.primary:a.neutral30}})},Ds=function(e){var n=e.children,s=e.isDisabled,t=e.isFocused,i=e.innerRef,a=e.innerProps,r=e.menuIsOpen;return ie("div",ae({ref:i},me(e,"control",{control:!0,"control--is-disabled":s,"control--is-focused":t,"control--menu-is-open":r}),a,{"aria-disabled":s||void 0}),n)},zs=Ds,Rs=["data"],Fs=function(e,n){var s=e.theme.spacing;return n?{}:{paddingBottom:s.baseUnit*2,paddingTop:s.baseUnit*2}},As=function(e){var n=e.children,s=e.cx,t=e.getStyles,i=e.getClassNames,a=e.Heading,r=e.headingProps,o=e.innerProps,c=e.label,f=e.theme,p=e.selectProps;return ie("div",ae({},me(e,"group",{group:!0}),o),ie(a,ae({},r,{selectProps:p,theme:f,getStyles:t,getClassNames:i,cx:s}),c),ie("div",null,n))},Ts=function(e,n){var s=e.theme,t=s.colors,i=s.spacing;return re({label:"group",cursor:"default",display:"block"},n?{}:{color:t.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:i.baseUnit*3,paddingRight:i.baseUnit*3,textTransform:"uppercase"})},Ls=function(e){var n=fr(e);n.data;var s=Ne(n,Rs);return ie("div",ae({},me(e,"groupHeading",{"group-heading":!0}),s))},Vs=As,Ns=["innerRef","isDisabled","isHidden","inputClassName"],Bs=function(e,n){var s=e.isDisabled,t=e.value,i=e.theme,a=i.spacing,r=i.colors;return re(re({visibility:s?"hidden":"visible",transform:t?"translateZ(0)":""},$s),n?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:r.neutral80})},Sr={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},$s={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":re({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Sr)},Us=function(e){return re({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Sr)},Hs=function(e){var n=e.cx,s=e.value,t=fr(e),i=t.innerRef,a=t.isDisabled,r=t.isHidden,o=t.inputClassName,c=Ne(t,Ns);return ie("div",ae({},me(e,"input",{"input-container":!0}),{"data-value":s||""}),ie("input",ae({className:n({input:!0},o),ref:i,style:Us(r),disabled:a},c)))},Ws=Hs,Zs=function(e,n){var s=e.theme,t=s.spacing,i=s.borderRadius,a=s.colors;return re({label:"multiValue",display:"flex",minWidth:0},n?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Gs=function(e,n){var s=e.theme,t=s.borderRadius,i=s.colors,a=e.cropWithEllipsis;return re({overflow:"hidden",textOverflow:a||a===void 0?"ellipsis":void 0,whiteSpace:"nowrap"},n?{}:{borderRadius:t/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},Ys=function(e,n){var s=e.theme,t=s.spacing,i=s.borderRadius,a=s.colors,r=e.isFocused;return re({alignItems:"center",display:"flex"},n?{}:{borderRadius:i/2,backgroundColor:r?a.dangerLight:void 0,paddingLeft:t.baseUnit,paddingRight:t.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},_r=function(e){var n=e.children,s=e.innerProps;return ie("div",s,n)},Ks=_r,Xs=_r;function qs(l){var e=l.children,n=l.innerProps;return ie("div",ae({role:"button"},n),e||ie(un,{size:14}))}var Js=function(e){var n=e.children,s=e.components,t=e.data,i=e.innerProps,a=e.isDisabled,r=e.removeProps,o=e.selectProps,c=s.Container,f=s.Label,p=s.Remove;return ie(c,{data:t,innerProps:re(re({},me(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:o},ie(f,{data:t,innerProps:re({},me(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:o},n),ie(p,{data:t,innerProps:re(re({},me(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(n||"option")},r),selectProps:o}))},Qs=Js,eo=function(e,n){var s=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.theme,r=a.spacing,o=a.colors;return re({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},n?{}:{backgroundColor:i?o.primary:t?o.primary25:"transparent",color:s?o.neutral20:i?o.neutral0:"inherit",padding:"".concat(r.baseUnit*2,"px ").concat(r.baseUnit*3,"px"),":active":{backgroundColor:s?void 0:i?o.primary:o.primary50}})},to=function(e){var n=e.children,s=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.innerRef,r=e.innerProps;return ie("div",ae({},me(e,"option",{option:!0,"option--is-disabled":s,"option--is-focused":t,"option--is-selected":i}),{ref:a,"aria-disabled":s},r),n)},no=to,ro=function(e,n){var s=e.theme,t=s.spacing,i=s.colors;return re({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},n?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},io=function(e){var n=e.children,s=e.innerProps;return ie("div",ae({},me(e,"placeholder",{placeholder:!0}),s),n)},ao=io,so=function(e,n){var s=e.isDisabled,t=e.theme,i=t.spacing,a=t.colors;return re({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},n?{}:{color:s?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},oo=function(e){var n=e.children,s=e.isDisabled,t=e.innerProps;return ie("div",ae({},me(e,"singleValue",{"single-value":!0,"single-value--is-disabled":s}),t),n)},lo=oo,uo={ClearIndicator:ks,Control:zs,DropdownIndicator:_s,DownChevron:wr,CrossIcon:un,Group:Vs,GroupHeading:Ls,IndicatorsContainer:bs,IndicatorSeparator:Is,Input:Ws,LoadingIndicator:Ms,Menu:is,MenuList:ss,MenuPortal:hs,LoadingMessage:cs,NoOptionsMessage:us,MultiValue:Qs,MultiValueContainer:Ks,MultiValueLabel:Xs,MultiValueRemove:qs,Option:no,Placeholder:ao,SelectContainer:ps,SingleValue:lo,ValueContainer:vs},co=function(e){return re(re({},uo),e.components)},En=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function ho(l,e){return!!(l===e||En(l)&&En(e))}function fo(l,e){if(l.length!==e.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return a?"option ".concat(t," is disabled. Select another option."):"option ".concat(t,", selected.");default:return""}},onFocus:function(e){var n=e.context,s=e.focused,t=e.options,i=e.label,a=i===void 0?"":i,r=e.selectValue,o=e.isDisabled,c=e.isSelected,f=function(g,d){return g&&g.length?"".concat(g.indexOf(d)+1," of ").concat(g.length):""};if(n==="value"&&r)return"value ".concat(a," focused, ").concat(f(r,s),".");if(n==="menu"){var p=o?" disabled":"",y="".concat(c?"selected":"focused").concat(p);return"option ".concat(a," ").concat(y,", ").concat(f(t,s),".")}return""},onFilter:function(e){var n=e.inputValue,s=e.resultsMessage;return"".concat(s).concat(n?" for search term "+n:"",".")}},bo=function(e){var n=e.ariaSelection,s=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,a=e.isFocused,r=e.selectValue,o=e.selectProps,c=e.id,f=o.ariaLiveMessages,p=o.getOptionLabel,y=o.inputValue,u=o.isMulti,g=o.isOptionDisabled,d=o.isSearchable,b=o.menuIsOpen,m=o.options,w=o.screenReaderStatus,x=o.tabSelectsValue,C=o["aria-label"],I=o["aria-live"],P=R.useMemo(function(){return re(re({},go),f||{})},[f]),E=R.useMemo(function(){var v="";if(n&&P.onChange){var N=n.option,te=n.options,T=n.removedValue,J=n.removedValues,B=n.value,K=function(he){return Array.isArray(he)?null:he},A=T||N||K(B),z=A?p(A):"",ee=te||J||void 0,X=ee?ee.map(p):[],Z=re({isDisabled:A&&g(A,r),label:z,labels:X},n);v=P.onChange(Z)}return v},[n,P,g,r,p]),D=R.useMemo(function(){var v="",N=s||t,te=!!(s&&r&&r.includes(s));if(N&&P.onFocus){var T={focused:N,label:p(N),isDisabled:g(N,r),isSelected:te,options:i,context:N===s?"menu":"value",selectValue:r};v=P.onFocus(T)}return v},[s,t,p,g,P,i,r]),j=R.useMemo(function(){var v="";if(b&&m.length&&P.onFilter){var N=w({count:i.length});v=P.onFilter({inputValue:y,resultsMessage:N})}return v},[i,y,b,P,m,w]),U=R.useMemo(function(){var v="";if(P.guidance){var N=t?"value":b?"menu":"input";v=P.guidance({"aria-label":C,context:N,isDisabled:s&&g(s,r),isMulti:u,isSearchable:d,tabSelectsValue:x})}return v},[C,s,t,u,g,d,b,P,r,x]),q="".concat(D," ").concat(j," ").concat(U),O=ie(R.Fragment,null,ie("span",{id:"aria-selection"},E),ie("span",{id:"aria-context"},q)),L=(n==null?void 0:n.action)==="initial-input-focus";return ie(R.Fragment,null,ie(Pn,{id:c},L&&O),ie(Pn,{"aria-live":I,"aria-atomic":"false","aria-relevant":"additions text"},a&&!L&&O))},yo=bo,Gt=[{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źẑżžẓẕƶȥɀⱬꝣ"}],wo=new RegExp("["+Gt.map(function(l){return l.letters}).join("")+"]","g"),Cr={};for(var Vt=0;Vt-1}},Co=["innerRef"];function ko(l){var e=l.innerRef,n=Ne(l,Co),s=Xa(n,"onExited","in","enter","exit","appear");return ie("input",ae({ref:e},s,{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 Oo=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function Io(l){var e=l.isEnabled,n=l.onBottomArrive,s=l.onBottomLeave,t=l.onTopArrive,i=l.onTopLeave,a=R.useRef(!1),r=R.useRef(!1),o=R.useRef(0),c=R.useRef(null),f=R.useCallback(function(b,m){if(c.current!==null){var w=c.current,x=w.scrollTop,C=w.scrollHeight,I=w.clientHeight,P=c.current,E=m>0,D=C-I-x,j=!1;D>m&&a.current&&(s&&s(b),a.current=!1),E&&r.current&&(i&&i(b),r.current=!1),E&&m>D?(n&&!a.current&&n(b),P.scrollTop=C,j=!0,a.current=!0):!E&&-m>x&&(t&&!r.current&&t(b),P.scrollTop=0,j=!0,r.current=!0),j&&Oo(b)}},[n,s,t,i]),p=R.useCallback(function(b){f(b,b.deltaY)},[f]),y=R.useCallback(function(b){o.current=b.changedTouches[0].clientY},[]),u=R.useCallback(function(b){var m=o.current-b.changedTouches[0].clientY;f(b,m)},[f]),g=R.useCallback(function(b){if(b){var m=Ga?{passive:!1}:!1;b.addEventListener("wheel",p,m),b.addEventListener("touchstart",y,m),b.addEventListener("touchmove",u,m)}},[u,y,p]),d=R.useCallback(function(b){b&&(b.removeEventListener("wheel",p,!1),b.removeEventListener("touchstart",y,!1),b.removeEventListener("touchmove",u,!1))},[u,y,p]);return R.useEffect(function(){if(e){var b=c.current;return g(b),function(){d(b)}}},[e,g,d]),function(b){c.current=b}}var jn=["boxSizing","height","overflow","paddingRight","position"],Dn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function zn(l){l.preventDefault()}function Rn(l){l.stopPropagation()}function Fn(){var l=this.scrollTop,e=this.scrollHeight,n=l+this.offsetHeight;l===0?this.scrollTop=1:n===e&&(this.scrollTop=l-1)}function An(){return"ontouchstart"in window||navigator.maxTouchPoints}var Tn=!!(typeof window<"u"&&window.document&&window.document.createElement),et=0,Ze={capture:!1,passive:!1};function Eo(l){var e=l.isEnabled,n=l.accountForScrollbars,s=n===void 0?!0:n,t=R.useRef({}),i=R.useRef(null),a=R.useCallback(function(o){if(Tn){var c=document.body,f=c&&c.style;if(s&&jn.forEach(function(g){var d=f&&f[g];t.current[g]=d}),s&&et<1){var p=parseInt(t.current.paddingRight,10)||0,y=document.body?document.body.clientWidth:0,u=window.innerWidth-y+p||0;Object.keys(Dn).forEach(function(g){var d=Dn[g];f&&(f[g]=d)}),f&&(f.paddingRight="".concat(u,"px"))}c&&An()&&(c.addEventListener("touchmove",zn,Ze),o&&(o.addEventListener("touchstart",Fn,Ze),o.addEventListener("touchmove",Rn,Ze))),et+=1}},[s]),r=R.useCallback(function(o){if(Tn){var c=document.body,f=c&&c.style;et=Math.max(et-1,0),s&&et<1&&jn.forEach(function(p){var y=t.current[p];f&&(f[p]=y)}),c&&An()&&(c.removeEventListener("touchmove",zn,Ze),o&&(o.removeEventListener("touchstart",Fn,Ze),o.removeEventListener("touchmove",Rn,Ze)))}},[s]);return R.useEffect(function(){if(e){var o=i.current;return a(o),function(){r(o)}}},[e,a,r]),function(o){i.current=o}}var Po=function(e){var n=e.target;return n.ownerDocument.activeElement&&n.ownerDocument.activeElement.blur()},Mo={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function jo(l){var e=l.children,n=l.lockEnabled,s=l.captureEnabled,t=s===void 0?!0:s,i=l.onBottomArrive,a=l.onBottomLeave,r=l.onTopArrive,o=l.onTopLeave,c=Io({isEnabled:t,onBottomArrive:i,onBottomLeave:a,onTopArrive:r,onTopLeave:o}),f=Eo({isEnabled:n}),p=function(u){c(u),f(u)};return ie(R.Fragment,null,n&&ie("div",{onClick:Po,css:Mo}),e(p))}var Do={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},zo=function(e){var n=e.name,s=e.onFocus;return ie("input",{required:!0,name:n,tabIndex:-1,"aria-hidden":"true",onFocus:s,css:Do,value:"",onChange:function(){}})},Ro=zo,Fo=function(e){return e.label},Ao=function(e){return e.label},To=function(e){return e.value},Lo=function(e){return!!e.isDisabled},Vo={clearIndicator:Cs,container:fs,control:js,dropdownIndicator:Ss,group:Fs,groupHeading:Ts,indicatorsContainer:gs,indicatorSeparator:Os,input:Bs,loadingIndicator:Ps,loadingMessage:ls,menu:ts,menuList:as,menuPortal:ds,multiValue:Zs,multiValueLabel:Gs,multiValueRemove:Ys,noOptionsMessage:os,option:eo,placeholder:ro,singleValue:so,valueContainer:ms},No={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%)"},Bo=4,Or=4,$o=38,Uo=Or*2,Ho={baseUnit:Or,controlHeight:$o,menuGutter:Uo},$t={borderRadius:Bo,colors:No,spacing:Ho},Wo={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:On(),captureMenuScroll:!On(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:_o(),formatGroupLabel:Fo,getOptionLabel:Ao,getOptionValue:To,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:Lo,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!Wa(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var n=e.count;return"".concat(n," result").concat(n!==1?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function Ln(l,e,n,s){var t=Mr(l,e,n),i=jr(l,e,n),a=Pr(l,e),r=Et(l,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:a,value:r,index:s}}function Ir(l,e){return l.options.map(function(n,s){if("options"in n){var t=n.options.map(function(a,r){return Ln(l,a,e,r)}).filter(function(a){return Vn(l,a)});return t.length>0?{type:"group",data:n,options:t,index:s}:void 0}var i=Ln(l,n,e,s);return Vn(l,i)?i:void 0}).filter(Ya)}function Er(l){return l.reduce(function(e,n){return n.type==="group"?e.push.apply(e,or(n.options.map(function(s){return s.data}))):e.push(n.data),e},[])}function Zo(l,e){return Er(Ir(l,e))}function Vn(l,e){var n=l.inputValue,s=n===void 0?"":n,t=e.data,i=e.isSelected,a=e.label,r=e.value;return(!zr(l)||!i)&&Dr(l,{label:a,value:r,data:t},s)}function Go(l,e){var n=l.focusedValue,s=l.selectValue,t=s.indexOf(n);if(t>-1){var i=e.indexOf(n);if(i>-1)return n;if(t-1?n:e[0]}var Pr=function(e,n){return e.getOptionLabel(n)},Et=function(e,n){return e.getOptionValue(n)};function Mr(l,e,n){return typeof l.isOptionDisabled=="function"?l.isOptionDisabled(e,n):!1}function jr(l,e,n){if(n.indexOf(e)>-1)return!0;if(typeof l.isOptionSelected=="function")return l.isOptionSelected(e,n);var s=Et(l,e);return n.some(function(t){return Et(l,t)===s})}function Dr(l,e,n){return l.filterOption?l.filterOption(e,n):!0}var zr=function(e){var n=e.hideSelectedOptions,s=e.isMulti;return n===void 0?s:n},Ko=1,Rr=function(l){ga(n,l);var e=xa(n);function n(s){var t;if(ma(this,n),t=e.call(this,s),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(r){t.controlRef=r},t.focusedOptionRef=null,t.getFocusedOptionRef=function(r){t.focusedOptionRef=r},t.menuListRef=null,t.getMenuListRef=function(r){t.menuListRef=r},t.inputRef=null,t.getInputRef=function(r){t.inputRef=r},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(r,o){var c=t.props,f=c.onChange,p=c.name;o.name=p,t.ariaOnChange(r,o),f(r,o)},t.setValue=function(r,o,c){var f=t.props,p=f.closeMenuOnSelect,y=f.isMulti,u=f.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:u}),p&&(t.setState({inputIsHiddenAfterUpdate:!y}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(r,{action:o,option:c})},t.selectOption=function(r){var o=t.props,c=o.blurInputOnSelect,f=o.isMulti,p=o.name,y=t.state.selectValue,u=f&&t.isOptionSelected(r,y),g=t.isOptionDisabled(r,y);if(u){var d=t.getOptionValue(r);t.setValue(y.filter(function(b){return t.getOptionValue(b)!==d}),"deselect-option",r)}else if(!g)f?t.setValue([].concat(or(y),[r]),"select-option",r):t.setValue(r,"select-option");else{t.ariaOnChange(r,{action:"select-option",option:r,name:p});return}c&&t.blurInput()},t.removeValue=function(r){var o=t.props.isMulti,c=t.state.selectValue,f=t.getOptionValue(r),p=c.filter(function(u){return t.getOptionValue(u)!==f}),y=mt(o,p,p[0]||null);t.onChange(y,{action:"remove-value",removedValue:r}),t.focusInput()},t.clearValue=function(){var r=t.state.selectValue;t.onChange(mt(t.props.isMulti,[],null),{action:"clear",removedValues:r})},t.popValue=function(){var r=t.props.isMulti,o=t.state.selectValue,c=o[o.length-1],f=o.slice(0,o.length-1),p=mt(r,f,f[0]||null);t.onChange(p,{action:"pop-value",removedValue:c})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var r=arguments.length,o=new Array(r),c=0;cy||p>y}},t.onTouchEnd=function(r){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(r.target)&&t.menuListRef&&!t.menuListRef.contains(r.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(r){t.userIsDragging||t.onControlMouseDown(r)},t.onClearIndicatorTouchEnd=function(r){t.userIsDragging||t.onClearIndicatorMouseDown(r)},t.onDropdownIndicatorTouchEnd=function(r){t.userIsDragging||t.onDropdownIndicatorMouseDown(r)},t.handleInputChange=function(r){var o=t.props.inputValue,c=r.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(c,{action:"input-change",prevInputValue:o}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(r){t.props.onFocus&&t.props.onFocus(r),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(r){var o=t.props.inputValue;if(t.menuListRef&&t.menuListRef.contains(document.activeElement)){t.inputRef.focus();return}t.props.onBlur&&t.props.onBlur(r),t.onInputChange("",{action:"input-blur",prevInputValue:o}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1})},t.onOptionHover=function(r){t.blockOptionHover||t.state.focusedOption===r||t.setState({focusedOption:r})},t.shouldHideSelectedOptions=function(){return zr(t.props)},t.onValueInputFocus=function(r){r.preventDefault(),r.stopPropagation(),t.focus()},t.onKeyDown=function(r){var o=t.props,c=o.isMulti,f=o.backspaceRemovesValue,p=o.escapeClearsValue,y=o.inputValue,u=o.isClearable,g=o.isDisabled,d=o.menuIsOpen,b=o.onKeyDown,m=o.tabSelectsValue,w=o.openMenuOnFocus,x=t.state,C=x.focusedOption,I=x.focusedValue,P=x.selectValue;if(!g&&!(typeof b=="function"&&(b(r),r.defaultPrevented))){switch(t.blockOptionHover=!0,r.key){case"ArrowLeft":if(!c||y)return;t.focusValue("previous");break;case"ArrowRight":if(!c||y)return;t.focusValue("next");break;case"Delete":case"Backspace":if(y)return;if(I)t.removeValue(I);else{if(!f)return;c?t.popValue():u&&t.clearValue()}break;case"Tab":if(t.isComposing||r.shiftKey||!d||!m||!C||w&&t.isOptionSelected(C,P))return;t.selectOption(C);break;case"Enter":if(r.keyCode===229)break;if(d){if(!C||t.isComposing)return;t.selectOption(C);break}return;case"Escape":d?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:y}),t.onMenuClose()):u&&p&&t.clearValue();break;case" ":if(y)return;if(!d){t.openMenu("first");break}if(!C)return;t.selectOption(C);break;case"ArrowUp":d?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":d?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!d)return;t.focusOption("pageup");break;case"PageDown":if(!d)return;t.focusOption("pagedown");break;case"Home":if(!d)return;t.focusOption("first");break;case"End":if(!d)return;t.focusOption("last");break;default:return}r.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++Ko),t.state.selectValue=Cn(s.value),s.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),a=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[a]}return t}return va(n,[{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&&kn(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,a=i.isDisabled,r=i.menuIsOpen,o=this.state.isFocused;(o&&!a&&t.isDisabled||o&&r&&!t.menuIsOpen)&&this.focusInput(),o&&a&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!o&&!a&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(kn(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,a=this.state,r=a.selectValue,o=a.isFocused,c=this.buildFocusableOptions(),f=t==="first"?0:c.length-1;if(!this.props.isMulti){var p=c.indexOf(r[0]);p>-1&&(f=p)}this.scrollToFocusedOptionOnUpdate=!(o&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:c[f]},function(){return i.onMenuOpen()})}},{key:"focusValue",value:function(t){var i=this.state,a=i.selectValue,r=i.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var o=a.indexOf(r);r||(o=-1);var c=a.length-1,f=-1;if(a.length){switch(t){case"previous":o===0?f=0:o===-1?f=c:f=o-1;break;case"next":o>-1&&o0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,a=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var o=0,c=r.indexOf(a);a||(c=-1),t==="up"?o=c>0?c-1:r.length-1:t==="down"?o=(c+1)%r.length:t==="pageup"?(o=c-i,o<0&&(o=0)):t==="pagedown"?(o=c+i,o>r.length-1&&(o=r.length-1)):t==="last"&&(o=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[o],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme($t):re(re({},$t),this.props.theme):$t}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,a=this.getStyles,r=this.getClassNames,o=this.getValue,c=this.selectOption,f=this.setValue,p=this.props,y=p.isMulti,u=p.isRtl,g=p.options,d=this.hasValue();return{clearValue:t,cx:i,getStyles:a,getClassNames:r,getValue:o,hasValue:d,isMulti:y,isRtl:u,options:g,selectOption:c,selectProps:p,setValue:f,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,a=t.isMulti;return i===void 0?a:i}},{key:"isOptionDisabled",value:function(t,i){return Mr(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return jr(this.props,t,i)}},{key:"filterOption",value:function(t,i){return Dr(this.props,t,i)}},{key:"formatOptionLabel",value:function(t,i){if(typeof this.props.formatOptionLabel=="function"){var a=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(t,{context:i,inputValue:a,selectValue:r})}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,a=t.isSearchable,r=t.inputId,o=t.inputValue,c=t.tabIndex,f=t.form,p=t.menuIsOpen,y=t.required,u=this.getComponents(),g=u.Input,d=this.state,b=d.inputIsHidden,m=d.ariaSelection,w=this.commonProps,x=r||this.getElementId("input"),C=re(re(re({"aria-autocomplete":"list","aria-expanded":p,"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":y,role:"combobox"},p&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!a&&{"aria-readonly":!0}),this.hasValue()?(m==null?void 0:m.action)==="initial-input-focus"&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return a?R.createElement(g,ae({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:x,innerRef:this.getInputRef,isDisabled:i,isHidden:b,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:c,form:f,type:"text",value:o},C)):R.createElement(ko,ae({id:x,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:Ot,onFocus:this.onInputFocus,disabled:i,tabIndex:c,inputMode:"none",form:f,value:""},C))}},{key:"renderPlaceholderOrValue",value:function(){var t=this,i=this.getComponents(),a=i.MultiValue,r=i.MultiValueContainer,o=i.MultiValueLabel,c=i.MultiValueRemove,f=i.SingleValue,p=i.Placeholder,y=this.commonProps,u=this.props,g=u.controlShouldRenderValue,d=u.isDisabled,b=u.isMulti,m=u.inputValue,w=u.placeholder,x=this.state,C=x.selectValue,I=x.focusedValue,P=x.isFocused;if(!this.hasValue()||!g)return m?null:R.createElement(p,ae({},y,{key:"placeholder",isDisabled:d,isFocused:P,innerProps:{id:this.getElementId("placeholder")}}),w);if(b)return C.map(function(D,j){var U=D===I,q="".concat(t.getOptionLabel(D),"-").concat(t.getOptionValue(D));return R.createElement(a,ae({},y,{components:{Container:r,Label:o,Remove:c},isFocused:U,isDisabled:d,key:q,index:j,removeProps:{onClick:function(){return t.removeValue(D)},onTouchEnd:function(){return t.removeValue(D)},onMouseDown:function(L){L.preventDefault()}},data:D}),t.formatOptionLabel(D,"value"))});if(m)return null;var E=C[0];return R.createElement(f,ae({},y,{data:E,isDisabled:d}),this.formatOptionLabel(E,"value"))}},{key:"renderClearIndicator",value:function(){var t=this.getComponents(),i=t.ClearIndicator,a=this.commonProps,r=this.props,o=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!this.isClearable()||!i||o||!this.hasValue()||c)return null;var p={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:p,isFocused:f}))}},{key:"renderLoadingIndicator",value:function(){var t=this.getComponents(),i=t.LoadingIndicator,a=this.commonProps,r=this.props,o=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!i||!c)return null;var p={"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:p,isDisabled:o,isFocused:f}))}},{key:"renderIndicatorSeparator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator,a=t.IndicatorSeparator;if(!i||!a)return null;var r=this.commonProps,o=this.props.isDisabled,c=this.state.isFocused;return R.createElement(a,ae({},r,{isDisabled:o,isFocused:c}))}},{key:"renderDropdownIndicator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator;if(!i)return null;var a=this.commonProps,r=this.props.isDisabled,o=this.state.isFocused,c={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:c,isDisabled:r,isFocused:o}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),a=i.Group,r=i.GroupHeading,o=i.Menu,c=i.MenuList,f=i.MenuPortal,p=i.LoadingMessage,y=i.NoOptionsMessage,u=i.Option,g=this.commonProps,d=this.state.focusedOption,b=this.props,m=b.captureMenuScroll,w=b.inputValue,x=b.isLoading,C=b.loadingMessage,I=b.minMenuHeight,P=b.maxMenuHeight,E=b.menuIsOpen,D=b.menuPlacement,j=b.menuPosition,U=b.menuPortalTarget,q=b.menuShouldBlockScroll,O=b.menuShouldScrollIntoView,L=b.noOptionsMessage,v=b.onMenuScrollToTop,N=b.onMenuScrollToBottom;if(!E)return null;var te=function(ee,X){var Z=ee.type,ce=ee.data,he=ee.isDisabled,oe=ee.isSelected,le=ee.label,ge=ee.value,pe=d===ce,Se=he?void 0:function(){return t.onOptionHover(ce)},_e=he?void 0:function(){return t.selectOption(ce)},h="".concat(t.getElementId("option"),"-").concat(X),$={id:h,onClick:_e,onMouseMove:Se,onMouseOver:Se,tabIndex:-1};return R.createElement(u,ae({},g,{innerProps:$,data:ce,isDisabled:he,isSelected:oe,key:h,label:le,type:Z,value:ge,isFocused:pe,innerRef:pe?t.getFocusedOptionRef:void 0}),t.formatOptionLabel(ee.data,"menu"))},T;if(this.hasOptions())T=this.getCategorizedOptions().map(function(z){if(z.type==="group"){var ee=z.data,X=z.options,Z=z.index,ce="".concat(t.getElementId("group"),"-").concat(Z),he="".concat(ce,"-heading");return R.createElement(a,ae({},g,{key:ce,data:ee,options:X,Heading:r,headingProps:{id:he,data:z.data},label:t.formatGroupLabel(z.data)}),z.options.map(function(oe){return te(oe,"".concat(Z,"-").concat(oe.index))}))}else if(z.type==="option")return te(z,"".concat(z.index))});else if(x){var J=C({inputValue:w});if(J===null)return null;T=R.createElement(p,g,J)}else{var B=L({inputValue:w});if(B===null)return null;T=R.createElement(y,g,B)}var K={minMenuHeight:I,maxMenuHeight:P,menuPlacement:D,menuPosition:j,menuShouldScrollIntoView:O},A=R.createElement(ns,ae({},g,K),function(z){var ee=z.ref,X=z.placerProps,Z=X.placement,ce=X.maxHeight;return R.createElement(o,ae({},g,K,{innerRef:ee,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:x,placement:Z}),R.createElement(jo,{captureEnabled:m,onTopArrive:v,onBottomArrive:N,lockEnabled:q},function(he){return R.createElement(c,ae({},g,{innerRef:function(le){t.getMenuListRef(le),he(le)},isLoading:x,maxHeight:ce,focusedOption:d}),T)}))});return U||j==="fixed"?R.createElement(f,ae({},g,{appendTo:U,controlElement:this.controlRef,menuPlacement:D,menuPosition:j}),A):A}},{key:"renderFormField",value:function(){var t=this,i=this.props,a=i.delimiter,r=i.isDisabled,o=i.isMulti,c=i.name,f=i.required,p=this.state.selectValue;if(f&&!this.hasValue()&&!r)return R.createElement(Ro,{name:c,onFocus:this.onValueInputFocus});if(!(!c||r))if(o)if(a){var y=p.map(function(d){return t.getOptionValue(d)}).join(a);return R.createElement("input",{name:c,type:"hidden",value:y})}else{var u=p.length>0?p.map(function(d,b){return R.createElement("input",{key:"i-".concat(b),name:c,type:"hidden",value:t.getOptionValue(d)})}):R.createElement("input",{name:c,type:"hidden",value:""});return R.createElement("div",null,u)}else{var g=p[0]?this.getOptionValue(p[0]):"";return R.createElement("input",{name:c,type:"hidden",value:g})}}},{key:"renderLiveRegion",value:function(){var t=this.commonProps,i=this.state,a=i.ariaSelection,r=i.focusedOption,o=i.focusedValue,c=i.isFocused,f=i.selectValue,p=this.getFocusableOptions();return R.createElement(yo,ae({},t,{id:this.getElementId("live-region"),ariaSelection:a,focusedOption:r,focusedValue:o,isFocused:c,selectValue:f,focusableOptions:p}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,a=t.IndicatorsContainer,r=t.SelectContainer,o=t.ValueContainer,c=this.props,f=c.className,p=c.id,y=c.isDisabled,u=c.menuIsOpen,g=this.state.isFocused,d=this.commonProps=this.getCommonProps();return R.createElement(r,ae({},d,{className:f,innerProps:{id:p,onKeyDown:this.onKeyDown},isDisabled:y,isFocused:g}),this.renderLiveRegion(),R.createElement(i,ae({},d,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:y,isFocused:g,menuIsOpen:u}),R.createElement(o,ae({},d,{isDisabled:y}),this.renderPlaceholderOrValue(),this.renderInput()),R.createElement(a,ae({},d,{isDisabled:y}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}],[{key:"getDerivedStateFromProps",value:function(t,i){var a=i.prevProps,r=i.clearFocusValueOnUpdate,o=i.inputIsHiddenAfterUpdate,c=i.ariaSelection,f=i.isFocused,p=i.prevWasFocused,y=t.options,u=t.value,g=t.menuIsOpen,d=t.inputValue,b=t.isMulti,m=Cn(u),w={};if(a&&(u!==a.value||y!==a.options||g!==a.menuIsOpen||d!==a.inputValue)){var x=g?Zo(t,m):[],C=r?Go(i,m):null,I=Yo(i,x);w={selectValue:m,focusedOption:I,focusedValue:C,clearFocusValueOnUpdate:!1}}var P=o!=null&&t!==a?{inputIsHidden:o,inputIsHiddenAfterUpdate:void 0}:{},E=c,D=f&&p;return f&&!D&&(E={value:mt(b,m,m[0]||null),options:m,action:"initial-input-focus"},D=!p),(c==null?void 0:c.action)==="initial-input-focus"&&(E=null),re(re(re({},w),P),{},{prevProps:t,ariaSelection:E,prevWasFocused:D})}}]),n}(R.Component);Rr.defaultProps=Wo;var Xo=R.forwardRef(function(l,e){var n=pa(l);return R.createElement(Rr,ae({ref:e},n))}),qo=Xo,Jo=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function Yt(){return Yt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Fr=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 n=Qo(e,Jo);return Yt({},n)},el=function(e){var n=typeof e=="string";return n&&["sm","md","lg"].includes(e)},tl=function(e){return el(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},De=function(e){var n=Mt(),s=tl(n.components.Input.defaultProps.size),t=e??s,i=Fi(typeof t=="string"?[t]:t,{fallback:"md"})||s;return i};function Ge(){return Ge=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var ol=function(e){var n=e.className,s=e.cx,t=e.children,i=e.innerRef,a=e.innerProps,r=e.isDisabled,o=e.isFocused,c=e.menuIsOpen,f=e.selectProps,p=f.chakraStyles,y=f.size,u=f.variant,g=f.focusBorderColor,d=f.errorBorderColor,b=f.isInvalid,m=f.isReadOnly,w=De(y),x=Be("Input",{size:w,variant:u,focusBorderColor:g,errorBorderColor:d}),C=x.field,I=C.height,P=C.h,E=sl(C,al),D=I||P,j=Pe({},E,{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",padding:0,overflow:"hidden",height:"auto",minH:D},r?{pointerEvents:"none"}:{}),U=p!=null&&p.control?p.control(j,e):j;return se.createElement(de,Pe({ref:i,className:s({control:!0,"control--is-disabled":r,"control--is-focused":o,"control--menu-is-open":c},n),sx:U},a,{"data-focus":o?!0:void 0,"data-focus-visible":o?!0:void 0,"data-invalid":b?!0:void 0,"data-disabled":r?!0:void 0,"data-readonly":m?!0:void 0}),t)},ll=function(e){var n=e.className,s=e.cx,t=e.selectProps,i=t.chakraStyles,a=t.useBasicStyles,r=t.variant,o=Pe({opacity:1},a||r!=="outline"?{display:"none"}:{}),c=i!=null&&i.indicatorSeparator?i.indicatorSeparator(o,e):o;return se.createElement(Jn,{className:s({"indicator-separator":!0},n),sx:c,orientation:"vertical"})},ul=function(e){return se.createElement(Qt,Pe({role:"presentation",focusable:"false","aria-hidden":"true"},e),se.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},cl=function(e){var n=e.children,s=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,o=a.useBasicStyles,c=a.size,f=a.focusBorderColor,p=a.errorBorderColor,y=a.variant,u=De(c),g=Be("Input",{size:u,variant:y,focusBorderColor:f,errorBorderColor:p}),d={sm:"16px",md:"20px",lg:"24px"},b=d[u],m=Pe({},g.addon,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",borderRadius:0,borderWidth:0,fontSize:b},o&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=r!=null&&r.dropdownIndicator?r.dropdownIndicator(m,e):m,x={height:"1em",width:"1em"},C=r!=null&&r.downChevron?r.downChevron(x,e):x;return se.createElement(de,Pe({},i,{className:t({indicator:!0,"dropdown-indicator":!0},s),sx:w}),n||se.createElement(ul,{sx:C}))},dl=function(e){return se.createElement(Qt,Pe({focusable:"false","aria-hidden":!0},e),se.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"}))},hl=function(e){var n=e.children,s=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,o=a.size,c=De(o),f=Bn("CloseButton",{size:c}),p=Pe({},f,{marginX:1,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer"}),y=r!=null&&r.clearIndicator?r.clearIndicator(p,e):p,u={width:"1em",height:"1em"},g=r!=null&&r.crossIcon?r.crossIcon(u,e):u;return se.createElement(de,Pe({role:"button",className:t({indicator:!0,"clear-indicator":!0},s),sx:y,"aria-label":"Clear selected options"},i),n||se.createElement(dl,{sx:g}))},fl=function(e){var n=e.className,s=e.cx,t=e.innerProps,i=e.selectProps,a=i.chakraStyles,r=i.size,o=e.color,c=e.emptyColor,f=e.speed,p=e.thickness,y=e.spinnerSize,u=De(r),g={sm:"xs",md:"sm",lg:"md"},d=g[u],b={marginRight:3},m=a!=null&&a.loadingIndicator?a.loadingIndicator(b,e):b;return se.createElement(qr,Pe({className:s({indicator:!0,"loading-indicator":!0},n),sx:m},t,{size:y||d,color:o,emptyColor:c,speed:f,thickness:p}))};const pl=ol;var ml=["innerRef","isDisabled","isHidden","inputClassName"];function rt(){return rt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var gl=function(e){var n=e.className,s=e.cx,t=e.value,i=e.selectProps,a=i.chakraStyles,r=i.isReadOnly,o=Fr(e),c=o.innerRef,f=o.isDisabled,p=o.isHidden,y=o.inputClassName,u=vl(o,ml),g={gridArea:"1 / 2",minW:"2px",border:0,margin:0,outline:0,padding:0},d={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:f?"hidden":"visible",transform:t?"translateZ(0)":"",_after:rt({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre",padding:0},g)},b=a!=null&&a.inputContainer?a.inputContainer(d,e):d,m=rt({background:0,opacity:p?0:1,width:"100%"},g),w=a!=null&&a.input?a.input(m,e):m;return se.createElement(de,{className:s({"input-container":!0},n),"data-value":t||"",sx:b},se.createElement(Ue.input,rt({className:s({input:!0},y),ref:c,sx:w,disabled:f,readOnly:r?!0:void 0},u)))};const bl=gl;var yl=["data"];function wl(l,e){if(l==null)return{};var n={},s=Object.keys(l),t,i;for(i=0;i=0)&&(n[t]=l[t]);return n}function xe(){return xe=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Gl=function(e){var n,s=e.components,t=s===void 0?{}:s;e.theme;var i=e.size,a=e.colorScheme,r=a===void 0?"gray":a,o=e.isDisabled,c=e.isInvalid,f=e.isReadOnly,p=e.required,y=e.isRequired,u=e.inputId,g=e.tagVariant,d=e.selectedOptionStyle,b=d===void 0?"color":d,m=e.selectedOptionColorScheme,w=e.selectedOptionColor,x=e.variant,C=e.focusBorderColor,I=e.errorBorderColor,P=e.chakraStyles,E=P===void 0?{}:P,D=e.onFocus,j=e.onBlur,U=e.menuIsOpen,q=Zl(e,Wl),O=Mt(),L=O.components.Input.defaultProps.variant,v=vi({id:u,isDisabled:o,isInvalid:c,isRequired:y,isReadOnly:f,onFocus:D,onBlur:j}),N=U??(v.readOnly?!1:void 0),te=b,T=["color","check"];T.includes(b)||(te="color");var J=m||w||"blue";typeof J!="string"&&(J="blue");var B=Pt({components:Pt({},Hl,t),colorScheme:r,size:i,tagVariant:g,selectedOptionStyle:te,selectedOptionColorScheme:J,variant:x??L,chakraStyles:E,focusBorderColor:C,errorBorderColor:I,onFocus:v.onFocus,onBlur:v.onBlur,isDisabled:v.disabled,isInvalid:!!v["aria-invalid"],inputId:v.id,isReadOnly:v.readOnly,required:p??v.required,menuIsOpen:N},q,{"aria-invalid":(n=q["aria-invalid"])!=null?n:v["aria-invalid"]});return B};const Yl=Gl;function qt(){return qt=Object.assign?Object.assign.bind():function(l){for(var e=1;e({value:g,label:g})))??[],[r,o]=R.useState(a),c=async()=>{var g,d;await((g=He)==null?void 0:g.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((d=He)==null?void 0:d.listAll().then(b=>s(b??[]))),i("")},f=async()=>{var d;const g=await((d=He)==null?void 0:d.listAll());s(g??[])};if(He==null)return alert("Error: TagsTable is not loaded"),null;const p=n.map(g=>({value:g.name,label:g.name})),y=37*5;return _.jsxs(gi,{isLazy:!0,onOpen:f,children:[_.jsx(bi,{children:_.jsx(we,{"aria-label":"Delete confirm",size:"sm",variant:"ghost",icon:_.jsx(rr,{color:"#718096"})})}),_.jsxs(yi,{children:[_.jsx(wi,{}),_.jsx(xi,{}),_.jsx(tr,{children:_.jsx("b",{children:l.name})}),_.jsxs(Si,{children:[_.jsx(Xl,{isMulti:!0,name:"tags",options:p,menuIsOpen:!0,value:r,onChange:async g=>{var d;o(g),await((d=ye)==null?void 0:d.updateFlow(l.id,{tags:g.map(b=>b.value)})),await(e==null?void 0:e())},chakraStyles:{dropdownIndicator:g=>({...g,p:0,w:"30px"}),menuList:g=>({...g,shadow:"none",pt:0})},placeholder:"Select tags",closeMenuOnSelect:!1,maxMenuHeight:y}),_.jsxs(be,{gap:4,mt:Math.min(y,Math.max(n.length,3)*37),children:[_.jsx(it,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:g=>{i(g.target.value.trim())}}),_.jsx(Ce,{iconSpacing:1,leftIcon:_.jsx(nn,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:c,children:"New Tag"})]})]})]})]})}function Jl({menuPosition:l,workflowID:e,onClose:n}){const{onDuplicateWorkflow:s}=R.useContext(rn);return _.jsx(_.Fragment,{children:_.jsx(de,{position:"absolute",top:l.y,left:l.x,children:_.jsx(Xe,{isOpen:!0,onClose:n,children:_.jsx(at,{children:_.jsx(Fe,{onClick:()=>s&&s(e),children:"Duplicate"})})})})})}const Nn=R.memo(function({workflow:e}){const{colorMode:n}=Jt(),[s,t]=R.useState({x:0,y:0}),[i,a]=R.useState(!1),{setDraggingFile:r,isMultiSelecting:o,onMultiSelectFlow:c,onDeleteFlow:f,multiSelectedFlowsID:p}=R.useContext(Ve),y=p&&p.length>0&&p.includes(e.id),{curFlowID:u,loadWorkflowID:g}=R.useContext(rn),d=u===e.id,b=P=>{P.preventDefault(),t({x:P.clientX,y:P.clientY}),a(!0)},[m,w]=R.useState(!1),x=()=>{a(!1)},C=n==="light"?"gray.200":"#4A5568",I=_.jsx(de,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":i?C:void 0,color:d&&!o?"#333":void 0,draggable:!o,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:1,onClick:()=>{!o&&g(e.id)},_hover:{bg:C},children:_.jsxs(be,{children:[e.coverMediaPath!=null&&_.jsx(ji,{mediaLocalPath:e.coverMediaPath,size:60,hideBrokenImage:!0}),_.jsxs($e,{textAlign:"left",gap:0,children:[_.jsx(ke,{fontWeight:"500",children:e.name??"untitled"}),_.jsxs(ke,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Kn(e.updateTime)]})]})]})});return _.jsxs(be,{w:"100%",mb:1,justify:"space-between",onContextMenu:b,onMouseEnter:()=>{w(!0)},onMouseLeave:()=>{w(!1)},children:[o?_.jsx(st,{isChecked:y,spacing:4,onChange:P=>{c&&c(e.id,P.target.checked)},children:I}):_.jsxs(_.Fragment,{children:[I,_.jsxs(nt,{width:"90px",justifyContent:"flex-end",children:[m&&_.jsx(ql,{workflow:e}),_.jsx(Re,{label:"Open in new tab",children:_.jsx(we,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>_i(e.id),icon:_.jsx(Ci,{color:"#718096",size:23})})}),_.jsx(Yn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{f&&f(e.id)}})]})]}),i&&_.jsx(Jl,{menuPosition:s,onClose:x,workflowID:e.id})]})});function Tr({items:l}){var y;const[e,n]=R.useState(!1),s=l.filter(We),t=l.filter(u=>!We(u)),i=(y=t[0])==null?void 0:y.parentFolderID,[a,r]=R.useState(!1),{onRefreshFilesList:o,draggingFile:c,refreshFolderStamp:f}=R.useContext(Ve),p=async u=>{var g,d;if(u.preventDefault(),u.stopPropagation(),!c)return r(!1);if(We(c)){if(c.id===i)return r(!1);await((g=Le)==null?void 0:g.update({id:c.id,parentFolderID:i}))}else await((d=ye)==null?void 0:d.updateFlow(c.id,{parentFolderID:i}));await(o==null?void 0:o()),r(!1)};return R.useEffect(()=>{var u;(u=Oe)==null||u.getSetting("foldersOnTop").then(g=>{n(g??!1)})},[f]),_.jsxs(_.Fragment,{children:[e&&s.map(u=>_.jsx(yn,{folder:u},u.id)),_.jsx(de,{border:a?"2px dashed #718096":"2px dashed transparent",onDragOver:u=>{u.preventDefault(),u.stopPropagation(),r(!0)},onDragLeave:u=>{u.preventDefault(),u.stopPropagation(),r(!1)},onDrop:p,className:"droppable",children:e?t.map(u=>_.jsx(Nn,{workflow:u},u.id)):l.map(u=>We(u)?_.jsx(yn,{folder:u},u.id):_.jsx(Nn,{workflow:u},u.id))})]})}function lu({onClose:l,onClickNewFlow:e}){const[n,s]=R.useState([]),t=R.useRef([]),i=R.useRef([]),{loadWorkflowID:a,curFlowID:r}=R.useContext(rn),[o,c]=R.useState(),[f,p]=R.useState(!1),[y,u]=R.useState([]),[g,d]=R.useState(0),[b,m]=R.useState(""),w=ia(b,400),x=R.useRef(null),[C,I]=R.useState(null),P=R.useRef(window.localStorage.getItem(Ut)??pn.RECENTLY_MODIFIED),E=async()=>{var J,B;const T=await((J=ye)==null?void 0:J.listFolderContent())??[];t.current=T,await((B=ye)==null?void 0:B.listAll().then(K=>{i.current=K})),j(),d(Date.now())},D=!!o||!!w,j=()=>{if(D){const T=i.current.filter(J=>{var A;let B=!0,K=!0;return o&&(B=!!((A=J.tags)!=null&&A.includes(o))),w&&(K=!!J.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),B&&K});s(Ft(T,P.current))}else s(Ft(t.current,P.current))},U=T=>{s(Ft(n,T)),P.current=T,window.localStorage.setItem(Ut,T),!D&&d(Date.now())};R.useEffect(()=>{j()},[w,o]);const q=R.useCallback(async T=>{var J,B,K;await((J=ye)==null?void 0:J.deleteFlow(T)),((K=(B=ye)==null?void 0:B.curWorkflow)==null?void 0:K.id)===T&&await(a==null?void 0:a(null)),await E()},[o,w]);R.useEffect(()=>{E();const T=async J=>{var B;if(x.current){const K=await((B=ye)==null?void 0:B.get(x.current));K&&K.json&&ra(K.json,[J.canvasX,J.canvasY])}};return ct.canvasEl.addEventListener("drop",T),ct.canvasEl.addEventListener("click",l),()=>{ct.canvasEl.removeEventListener("drop",T),ct.canvasEl.removeEventListener("click",l)}},[]);const O=R.useCallback((T,J)=>{u(B=>{const K=[...B];return J?K.push(T):K.splice(K.indexOf(T),1),K})},[]),L=(T,J)=>{var B;switch(T){case"batchDelete":r&&((B=ye)==null||B.get(r).then(K=>{K||a==null||a(null)})),E(),p(!1),u([]);return;case"selectAll":u(J?i.current.map(K=>K.id):[]);return}},v=T=>{I(T),We(T)||(x.current=T.id)},N=T=>{m(T)},te=450;return _.jsx(Ve.Provider,{value:{onRefreshFilesList:E,draggingFile:C??void 0,setDraggingFile:v,isMultiSelecting:f,onMultiSelectFlow:O,multiSelectedFlowsID:y,onDeleteFlow:q,refreshFolderStamp:g,setRefreshFolderStamp:d},children:_.jsx(de,{style:{width:te},children:_.jsxs(ki,{width:te,height:"100vh",pl:4,pr:5,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Oi,children:[_.jsxs(nt,{alignItems:"center",justifyContent:"space-between",children:[_.jsxs(be,{gap:4,children:[_.jsx(be,{gap:2,children:_.jsx(ke,{fontSize:19,fontWeight:600,children:"☕️Workspace"})}),_.jsx(ar,{}),_.jsx(Re,{label:"Open workspace save directory",children:_.jsx(we,{"aria-label":"Open workspace save directory",size:"sm",icon:_.jsx(Xn,{}),variant:"outline",colorScheme:"teal",onClick:()=>Ii()})}),_.jsx(Re,{label:"New workflow",children:_.jsx(we,{"aria-label":"New workflow",size:"sm",icon:_.jsx(nn,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),_.jsx(be,{alignItems:"center",children:_.jsx(Qi,{})})]}),_.jsxs(nt,{direction:"column",h:"calc(100% - 64px)",children:[_.jsx(oa,{selectedTag:o,setSelectedTag:c}),_.jsxs(be,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[_.jsxs(be,{children:[i.current.length>0?_.jsx(na,{multipleState:f,changeMultipleState:T=>{p(T),!T&&u([])},selectedKeys:y,isSelectedAll:y.length===i.current.length,batchOperationCallback:L}):_.jsx(de,{}),!f&&_.jsx(Re,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:_.jsx(we,{size:"sm",variant:"outline",icon:_.jsx(nr,{size:21}),onClick:async()=>{var T;await((T=Le)==null?void 0:T.create({name:"New Folder"})),E()},"aria-label":"new folder button"})})]}),_.jsxs(Xe,{closeOnSelect:!0,children:[_.jsx(jt,{as:Ce,variant:"ghost",size:"xs",pr:0,rightIcon:_.jsx(tn,{size:"16"}),children:_.jsxs(be,{children:[_.jsx(ke,{children:"Sort by:"}),_.jsx(ke,{display:"inline-block",children:P.current})]})}),_.jsx(at,{children:_.jsx(er,{value:P.current,type:"radio",onChange:T=>U(T),children:Object.values(pn).map((T,J)=>_.jsx(an,{value:T,children:T},J))})})]})]}),_.jsx(sa,{searchValue:b,onUpdateSearchValue:N}),_.jsx(nt,{overflowY:"auto",overflowX:"hidden",direction:"column",children:_.jsx(Tr,{items:n})})]})]})})})}export{lu as default}; +`]))),Ps=function(e,n){var s=e.isFocused,t=e.size,i=e.theme,a=i.colors,r=i.spacing.baseUnit;return re({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:t,lineHeight:1,marginRight:t,textAlign:"center",verticalAlign:"middle"},n?{}:{color:s?a.neutral60:a.neutral20,padding:r*2})},Lt=function(e){var n=e.delay,s=e.offset;return ie("span",{css:Hn({animation:"".concat(Es," 1s ease-in-out ").concat(n,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:s?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Ms=function(e){var n=e.innerProps,s=e.isRtl,t=e.size,i=t===void 0?4:t,a=Ne(e,ws);return ie("div",ae({},me(re(re({},a),{},{innerProps:n,isRtl:s,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),n),ie(Lt,{delay:0,offset:s}),ie(Lt,{delay:160,offset:!0}),ie(Lt,{delay:320,offset:!s}))},js=function(e,n){var s=e.isDisabled,t=e.isFocused,i=e.theme,a=i.colors,r=i.borderRadius,o=i.spacing;return re({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:o.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},n?{}:{backgroundColor:s?a.neutral5:a.neutral0,borderColor:s?a.neutral10:t?a.primary:a.neutral20,borderRadius:r,borderStyle:"solid",borderWidth:1,boxShadow:t?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:t?a.primary:a.neutral30}})},Ds=function(e){var n=e.children,s=e.isDisabled,t=e.isFocused,i=e.innerRef,a=e.innerProps,r=e.menuIsOpen;return ie("div",ae({ref:i},me(e,"control",{control:!0,"control--is-disabled":s,"control--is-focused":t,"control--menu-is-open":r}),a,{"aria-disabled":s||void 0}),n)},zs=Ds,Rs=["data"],Fs=function(e,n){var s=e.theme.spacing;return n?{}:{paddingBottom:s.baseUnit*2,paddingTop:s.baseUnit*2}},As=function(e){var n=e.children,s=e.cx,t=e.getStyles,i=e.getClassNames,a=e.Heading,r=e.headingProps,o=e.innerProps,c=e.label,f=e.theme,p=e.selectProps;return ie("div",ae({},me(e,"group",{group:!0}),o),ie(a,ae({},r,{selectProps:p,theme:f,getStyles:t,getClassNames:i,cx:s}),c),ie("div",null,n))},Ts=function(e,n){var s=e.theme,t=s.colors,i=s.spacing;return re({label:"group",cursor:"default",display:"block"},n?{}:{color:t.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:i.baseUnit*3,paddingRight:i.baseUnit*3,textTransform:"uppercase"})},Ls=function(e){var n=fr(e);n.data;var s=Ne(n,Rs);return ie("div",ae({},me(e,"groupHeading",{"group-heading":!0}),s))},Vs=As,Ns=["innerRef","isDisabled","isHidden","inputClassName"],Bs=function(e,n){var s=e.isDisabled,t=e.value,i=e.theme,a=i.spacing,r=i.colors;return re(re({visibility:s?"hidden":"visible",transform:t?"translateZ(0)":""},$s),n?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:r.neutral80})},Sr={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},$s={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":re({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Sr)},Us=function(e){return re({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Sr)},Hs=function(e){var n=e.cx,s=e.value,t=fr(e),i=t.innerRef,a=t.isDisabled,r=t.isHidden,o=t.inputClassName,c=Ne(t,Ns);return ie("div",ae({},me(e,"input",{"input-container":!0}),{"data-value":s||""}),ie("input",ae({className:n({input:!0},o),ref:i,style:Us(r),disabled:a},c)))},Ws=Hs,Zs=function(e,n){var s=e.theme,t=s.spacing,i=s.borderRadius,a=s.colors;return re({label:"multiValue",display:"flex",minWidth:0},n?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Gs=function(e,n){var s=e.theme,t=s.borderRadius,i=s.colors,a=e.cropWithEllipsis;return re({overflow:"hidden",textOverflow:a||a===void 0?"ellipsis":void 0,whiteSpace:"nowrap"},n?{}:{borderRadius:t/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},Ys=function(e,n){var s=e.theme,t=s.spacing,i=s.borderRadius,a=s.colors,r=e.isFocused;return re({alignItems:"center",display:"flex"},n?{}:{borderRadius:i/2,backgroundColor:r?a.dangerLight:void 0,paddingLeft:t.baseUnit,paddingRight:t.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},_r=function(e){var n=e.children,s=e.innerProps;return ie("div",s,n)},Ks=_r,Xs=_r;function qs(l){var e=l.children,n=l.innerProps;return ie("div",ae({role:"button"},n),e||ie(un,{size:14}))}var Js=function(e){var n=e.children,s=e.components,t=e.data,i=e.innerProps,a=e.isDisabled,r=e.removeProps,o=e.selectProps,c=s.Container,f=s.Label,p=s.Remove;return ie(c,{data:t,innerProps:re(re({},me(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:o},ie(f,{data:t,innerProps:re({},me(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:o},n),ie(p,{data:t,innerProps:re(re({},me(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(n||"option")},r),selectProps:o}))},Qs=Js,eo=function(e,n){var s=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.theme,r=a.spacing,o=a.colors;return re({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},n?{}:{backgroundColor:i?o.primary:t?o.primary25:"transparent",color:s?o.neutral20:i?o.neutral0:"inherit",padding:"".concat(r.baseUnit*2,"px ").concat(r.baseUnit*3,"px"),":active":{backgroundColor:s?void 0:i?o.primary:o.primary50}})},to=function(e){var n=e.children,s=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.innerRef,r=e.innerProps;return ie("div",ae({},me(e,"option",{option:!0,"option--is-disabled":s,"option--is-focused":t,"option--is-selected":i}),{ref:a,"aria-disabled":s},r),n)},no=to,ro=function(e,n){var s=e.theme,t=s.spacing,i=s.colors;return re({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},n?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},io=function(e){var n=e.children,s=e.innerProps;return ie("div",ae({},me(e,"placeholder",{placeholder:!0}),s),n)},ao=io,so=function(e,n){var s=e.isDisabled,t=e.theme,i=t.spacing,a=t.colors;return re({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},n?{}:{color:s?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},oo=function(e){var n=e.children,s=e.isDisabled,t=e.innerProps;return ie("div",ae({},me(e,"singleValue",{"single-value":!0,"single-value--is-disabled":s}),t),n)},lo=oo,uo={ClearIndicator:ks,Control:zs,DropdownIndicator:_s,DownChevron:wr,CrossIcon:un,Group:Vs,GroupHeading:Ls,IndicatorsContainer:bs,IndicatorSeparator:Is,Input:Ws,LoadingIndicator:Ms,Menu:is,MenuList:ss,MenuPortal:hs,LoadingMessage:cs,NoOptionsMessage:us,MultiValue:Qs,MultiValueContainer:Ks,MultiValueLabel:Xs,MultiValueRemove:qs,Option:no,Placeholder:ao,SelectContainer:ps,SingleValue:lo,ValueContainer:vs},co=function(e){return re(re({},uo),e.components)},En=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function ho(l,e){return!!(l===e||En(l)&&En(e))}function fo(l,e){if(l.length!==e.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return a?"option ".concat(t," is disabled. Select another option."):"option ".concat(t,", selected.");default:return""}},onFocus:function(e){var n=e.context,s=e.focused,t=e.options,i=e.label,a=i===void 0?"":i,r=e.selectValue,o=e.isDisabled,c=e.isSelected,f=function(g,d){return g&&g.length?"".concat(g.indexOf(d)+1," of ").concat(g.length):""};if(n==="value"&&r)return"value ".concat(a," focused, ").concat(f(r,s),".");if(n==="menu"){var p=o?" disabled":"",y="".concat(c?"selected":"focused").concat(p);return"option ".concat(a," ").concat(y,", ").concat(f(t,s),".")}return""},onFilter:function(e){var n=e.inputValue,s=e.resultsMessage;return"".concat(s).concat(n?" for search term "+n:"",".")}},bo=function(e){var n=e.ariaSelection,s=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,a=e.isFocused,r=e.selectValue,o=e.selectProps,c=e.id,f=o.ariaLiveMessages,p=o.getOptionLabel,y=o.inputValue,u=o.isMulti,g=o.isOptionDisabled,d=o.isSearchable,b=o.menuIsOpen,m=o.options,w=o.screenReaderStatus,x=o.tabSelectsValue,C=o["aria-label"],I=o["aria-live"],P=R.useMemo(function(){return re(re({},go),f||{})},[f]),E=R.useMemo(function(){var v="";if(n&&P.onChange){var N=n.option,te=n.options,T=n.removedValue,J=n.removedValues,B=n.value,K=function(he){return Array.isArray(he)?null:he},A=T||N||K(B),z=A?p(A):"",ee=te||J||void 0,X=ee?ee.map(p):[],Z=re({isDisabled:A&&g(A,r),label:z,labels:X},n);v=P.onChange(Z)}return v},[n,P,g,r,p]),D=R.useMemo(function(){var v="",N=s||t,te=!!(s&&r&&r.includes(s));if(N&&P.onFocus){var T={focused:N,label:p(N),isDisabled:g(N,r),isSelected:te,options:i,context:N===s?"menu":"value",selectValue:r};v=P.onFocus(T)}return v},[s,t,p,g,P,i,r]),j=R.useMemo(function(){var v="";if(b&&m.length&&P.onFilter){var N=w({count:i.length});v=P.onFilter({inputValue:y,resultsMessage:N})}return v},[i,y,b,P,m,w]),U=R.useMemo(function(){var v="";if(P.guidance){var N=t?"value":b?"menu":"input";v=P.guidance({"aria-label":C,context:N,isDisabled:s&&g(s,r),isMulti:u,isSearchable:d,tabSelectsValue:x})}return v},[C,s,t,u,g,d,b,P,r,x]),q="".concat(D," ").concat(j," ").concat(U),O=ie(R.Fragment,null,ie("span",{id:"aria-selection"},E),ie("span",{id:"aria-context"},q)),L=(n==null?void 0:n.action)==="initial-input-focus";return ie(R.Fragment,null,ie(Pn,{id:c},L&&O),ie(Pn,{"aria-live":I,"aria-atomic":"false","aria-relevant":"additions text"},a&&!L&&O))},yo=bo,Gt=[{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źẑżžẓẕƶȥɀⱬꝣ"}],wo=new RegExp("["+Gt.map(function(l){return l.letters}).join("")+"]","g"),Cr={};for(var Vt=0;Vt-1}},Co=["innerRef"];function ko(l){var e=l.innerRef,n=Ne(l,Co),s=Xa(n,"onExited","in","enter","exit","appear");return ie("input",ae({ref:e},s,{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 Oo=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function Io(l){var e=l.isEnabled,n=l.onBottomArrive,s=l.onBottomLeave,t=l.onTopArrive,i=l.onTopLeave,a=R.useRef(!1),r=R.useRef(!1),o=R.useRef(0),c=R.useRef(null),f=R.useCallback(function(b,m){if(c.current!==null){var w=c.current,x=w.scrollTop,C=w.scrollHeight,I=w.clientHeight,P=c.current,E=m>0,D=C-I-x,j=!1;D>m&&a.current&&(s&&s(b),a.current=!1),E&&r.current&&(i&&i(b),r.current=!1),E&&m>D?(n&&!a.current&&n(b),P.scrollTop=C,j=!0,a.current=!0):!E&&-m>x&&(t&&!r.current&&t(b),P.scrollTop=0,j=!0,r.current=!0),j&&Oo(b)}},[n,s,t,i]),p=R.useCallback(function(b){f(b,b.deltaY)},[f]),y=R.useCallback(function(b){o.current=b.changedTouches[0].clientY},[]),u=R.useCallback(function(b){var m=o.current-b.changedTouches[0].clientY;f(b,m)},[f]),g=R.useCallback(function(b){if(b){var m=Ga?{passive:!1}:!1;b.addEventListener("wheel",p,m),b.addEventListener("touchstart",y,m),b.addEventListener("touchmove",u,m)}},[u,y,p]),d=R.useCallback(function(b){b&&(b.removeEventListener("wheel",p,!1),b.removeEventListener("touchstart",y,!1),b.removeEventListener("touchmove",u,!1))},[u,y,p]);return R.useEffect(function(){if(e){var b=c.current;return g(b),function(){d(b)}}},[e,g,d]),function(b){c.current=b}}var jn=["boxSizing","height","overflow","paddingRight","position"],Dn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function zn(l){l.preventDefault()}function Rn(l){l.stopPropagation()}function Fn(){var l=this.scrollTop,e=this.scrollHeight,n=l+this.offsetHeight;l===0?this.scrollTop=1:n===e&&(this.scrollTop=l-1)}function An(){return"ontouchstart"in window||navigator.maxTouchPoints}var Tn=!!(typeof window<"u"&&window.document&&window.document.createElement),et=0,Ze={capture:!1,passive:!1};function Eo(l){var e=l.isEnabled,n=l.accountForScrollbars,s=n===void 0?!0:n,t=R.useRef({}),i=R.useRef(null),a=R.useCallback(function(o){if(Tn){var c=document.body,f=c&&c.style;if(s&&jn.forEach(function(g){var d=f&&f[g];t.current[g]=d}),s&&et<1){var p=parseInt(t.current.paddingRight,10)||0,y=document.body?document.body.clientWidth:0,u=window.innerWidth-y+p||0;Object.keys(Dn).forEach(function(g){var d=Dn[g];f&&(f[g]=d)}),f&&(f.paddingRight="".concat(u,"px"))}c&&An()&&(c.addEventListener("touchmove",zn,Ze),o&&(o.addEventListener("touchstart",Fn,Ze),o.addEventListener("touchmove",Rn,Ze))),et+=1}},[s]),r=R.useCallback(function(o){if(Tn){var c=document.body,f=c&&c.style;et=Math.max(et-1,0),s&&et<1&&jn.forEach(function(p){var y=t.current[p];f&&(f[p]=y)}),c&&An()&&(c.removeEventListener("touchmove",zn,Ze),o&&(o.removeEventListener("touchstart",Fn,Ze),o.removeEventListener("touchmove",Rn,Ze)))}},[s]);return R.useEffect(function(){if(e){var o=i.current;return a(o),function(){r(o)}}},[e,a,r]),function(o){i.current=o}}var Po=function(e){var n=e.target;return n.ownerDocument.activeElement&&n.ownerDocument.activeElement.blur()},Mo={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function jo(l){var e=l.children,n=l.lockEnabled,s=l.captureEnabled,t=s===void 0?!0:s,i=l.onBottomArrive,a=l.onBottomLeave,r=l.onTopArrive,o=l.onTopLeave,c=Io({isEnabled:t,onBottomArrive:i,onBottomLeave:a,onTopArrive:r,onTopLeave:o}),f=Eo({isEnabled:n}),p=function(u){c(u),f(u)};return ie(R.Fragment,null,n&&ie("div",{onClick:Po,css:Mo}),e(p))}var Do={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},zo=function(e){var n=e.name,s=e.onFocus;return ie("input",{required:!0,name:n,tabIndex:-1,"aria-hidden":"true",onFocus:s,css:Do,value:"",onChange:function(){}})},Ro=zo,Fo=function(e){return e.label},Ao=function(e){return e.label},To=function(e){return e.value},Lo=function(e){return!!e.isDisabled},Vo={clearIndicator:Cs,container:fs,control:js,dropdownIndicator:Ss,group:Fs,groupHeading:Ts,indicatorsContainer:gs,indicatorSeparator:Os,input:Bs,loadingIndicator:Ps,loadingMessage:ls,menu:ts,menuList:as,menuPortal:ds,multiValue:Zs,multiValueLabel:Gs,multiValueRemove:Ys,noOptionsMessage:os,option:eo,placeholder:ro,singleValue:so,valueContainer:ms},No={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%)"},Bo=4,Or=4,$o=38,Uo=Or*2,Ho={baseUnit:Or,controlHeight:$o,menuGutter:Uo},$t={borderRadius:Bo,colors:No,spacing:Ho},Wo={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:On(),captureMenuScroll:!On(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:_o(),formatGroupLabel:Fo,getOptionLabel:Ao,getOptionValue:To,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:Lo,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!Wa(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var n=e.count;return"".concat(n," result").concat(n!==1?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function Ln(l,e,n,s){var t=Mr(l,e,n),i=jr(l,e,n),a=Pr(l,e),r=Et(l,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:a,value:r,index:s}}function Ir(l,e){return l.options.map(function(n,s){if("options"in n){var t=n.options.map(function(a,r){return Ln(l,a,e,r)}).filter(function(a){return Vn(l,a)});return t.length>0?{type:"group",data:n,options:t,index:s}:void 0}var i=Ln(l,n,e,s);return Vn(l,i)?i:void 0}).filter(Ya)}function Er(l){return l.reduce(function(e,n){return n.type==="group"?e.push.apply(e,or(n.options.map(function(s){return s.data}))):e.push(n.data),e},[])}function Zo(l,e){return Er(Ir(l,e))}function Vn(l,e){var n=l.inputValue,s=n===void 0?"":n,t=e.data,i=e.isSelected,a=e.label,r=e.value;return(!zr(l)||!i)&&Dr(l,{label:a,value:r,data:t},s)}function Go(l,e){var n=l.focusedValue,s=l.selectValue,t=s.indexOf(n);if(t>-1){var i=e.indexOf(n);if(i>-1)return n;if(t-1?n:e[0]}var Pr=function(e,n){return e.getOptionLabel(n)},Et=function(e,n){return e.getOptionValue(n)};function Mr(l,e,n){return typeof l.isOptionDisabled=="function"?l.isOptionDisabled(e,n):!1}function jr(l,e,n){if(n.indexOf(e)>-1)return!0;if(typeof l.isOptionSelected=="function")return l.isOptionSelected(e,n);var s=Et(l,e);return n.some(function(t){return Et(l,t)===s})}function Dr(l,e,n){return l.filterOption?l.filterOption(e,n):!0}var zr=function(e){var n=e.hideSelectedOptions,s=e.isMulti;return n===void 0?s:n},Ko=1,Rr=function(l){ga(n,l);var e=xa(n);function n(s){var t;if(ma(this,n),t=e.call(this,s),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(r){t.controlRef=r},t.focusedOptionRef=null,t.getFocusedOptionRef=function(r){t.focusedOptionRef=r},t.menuListRef=null,t.getMenuListRef=function(r){t.menuListRef=r},t.inputRef=null,t.getInputRef=function(r){t.inputRef=r},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(r,o){var c=t.props,f=c.onChange,p=c.name;o.name=p,t.ariaOnChange(r,o),f(r,o)},t.setValue=function(r,o,c){var f=t.props,p=f.closeMenuOnSelect,y=f.isMulti,u=f.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:u}),p&&(t.setState({inputIsHiddenAfterUpdate:!y}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(r,{action:o,option:c})},t.selectOption=function(r){var o=t.props,c=o.blurInputOnSelect,f=o.isMulti,p=o.name,y=t.state.selectValue,u=f&&t.isOptionSelected(r,y),g=t.isOptionDisabled(r,y);if(u){var d=t.getOptionValue(r);t.setValue(y.filter(function(b){return t.getOptionValue(b)!==d}),"deselect-option",r)}else if(!g)f?t.setValue([].concat(or(y),[r]),"select-option",r):t.setValue(r,"select-option");else{t.ariaOnChange(r,{action:"select-option",option:r,name:p});return}c&&t.blurInput()},t.removeValue=function(r){var o=t.props.isMulti,c=t.state.selectValue,f=t.getOptionValue(r),p=c.filter(function(u){return t.getOptionValue(u)!==f}),y=mt(o,p,p[0]||null);t.onChange(y,{action:"remove-value",removedValue:r}),t.focusInput()},t.clearValue=function(){var r=t.state.selectValue;t.onChange(mt(t.props.isMulti,[],null),{action:"clear",removedValues:r})},t.popValue=function(){var r=t.props.isMulti,o=t.state.selectValue,c=o[o.length-1],f=o.slice(0,o.length-1),p=mt(r,f,f[0]||null);t.onChange(p,{action:"pop-value",removedValue:c})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var r=arguments.length,o=new Array(r),c=0;cy||p>y}},t.onTouchEnd=function(r){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(r.target)&&t.menuListRef&&!t.menuListRef.contains(r.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(r){t.userIsDragging||t.onControlMouseDown(r)},t.onClearIndicatorTouchEnd=function(r){t.userIsDragging||t.onClearIndicatorMouseDown(r)},t.onDropdownIndicatorTouchEnd=function(r){t.userIsDragging||t.onDropdownIndicatorMouseDown(r)},t.handleInputChange=function(r){var o=t.props.inputValue,c=r.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(c,{action:"input-change",prevInputValue:o}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(r){t.props.onFocus&&t.props.onFocus(r),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(r){var o=t.props.inputValue;if(t.menuListRef&&t.menuListRef.contains(document.activeElement)){t.inputRef.focus();return}t.props.onBlur&&t.props.onBlur(r),t.onInputChange("",{action:"input-blur",prevInputValue:o}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1})},t.onOptionHover=function(r){t.blockOptionHover||t.state.focusedOption===r||t.setState({focusedOption:r})},t.shouldHideSelectedOptions=function(){return zr(t.props)},t.onValueInputFocus=function(r){r.preventDefault(),r.stopPropagation(),t.focus()},t.onKeyDown=function(r){var o=t.props,c=o.isMulti,f=o.backspaceRemovesValue,p=o.escapeClearsValue,y=o.inputValue,u=o.isClearable,g=o.isDisabled,d=o.menuIsOpen,b=o.onKeyDown,m=o.tabSelectsValue,w=o.openMenuOnFocus,x=t.state,C=x.focusedOption,I=x.focusedValue,P=x.selectValue;if(!g&&!(typeof b=="function"&&(b(r),r.defaultPrevented))){switch(t.blockOptionHover=!0,r.key){case"ArrowLeft":if(!c||y)return;t.focusValue("previous");break;case"ArrowRight":if(!c||y)return;t.focusValue("next");break;case"Delete":case"Backspace":if(y)return;if(I)t.removeValue(I);else{if(!f)return;c?t.popValue():u&&t.clearValue()}break;case"Tab":if(t.isComposing||r.shiftKey||!d||!m||!C||w&&t.isOptionSelected(C,P))return;t.selectOption(C);break;case"Enter":if(r.keyCode===229)break;if(d){if(!C||t.isComposing)return;t.selectOption(C);break}return;case"Escape":d?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:y}),t.onMenuClose()):u&&p&&t.clearValue();break;case" ":if(y)return;if(!d){t.openMenu("first");break}if(!C)return;t.selectOption(C);break;case"ArrowUp":d?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":d?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!d)return;t.focusOption("pageup");break;case"PageDown":if(!d)return;t.focusOption("pagedown");break;case"Home":if(!d)return;t.focusOption("first");break;case"End":if(!d)return;t.focusOption("last");break;default:return}r.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++Ko),t.state.selectValue=Cn(s.value),s.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),a=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[a]}return t}return va(n,[{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&&kn(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,a=i.isDisabled,r=i.menuIsOpen,o=this.state.isFocused;(o&&!a&&t.isDisabled||o&&r&&!t.menuIsOpen)&&this.focusInput(),o&&a&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!o&&!a&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(kn(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,a=this.state,r=a.selectValue,o=a.isFocused,c=this.buildFocusableOptions(),f=t==="first"?0:c.length-1;if(!this.props.isMulti){var p=c.indexOf(r[0]);p>-1&&(f=p)}this.scrollToFocusedOptionOnUpdate=!(o&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:c[f]},function(){return i.onMenuOpen()})}},{key:"focusValue",value:function(t){var i=this.state,a=i.selectValue,r=i.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var o=a.indexOf(r);r||(o=-1);var c=a.length-1,f=-1;if(a.length){switch(t){case"previous":o===0?f=0:o===-1?f=c:f=o-1;break;case"next":o>-1&&o0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,a=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var o=0,c=r.indexOf(a);a||(c=-1),t==="up"?o=c>0?c-1:r.length-1:t==="down"?o=(c+1)%r.length:t==="pageup"?(o=c-i,o<0&&(o=0)):t==="pagedown"?(o=c+i,o>r.length-1&&(o=r.length-1)):t==="last"&&(o=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[o],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme($t):re(re({},$t),this.props.theme):$t}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,a=this.getStyles,r=this.getClassNames,o=this.getValue,c=this.selectOption,f=this.setValue,p=this.props,y=p.isMulti,u=p.isRtl,g=p.options,d=this.hasValue();return{clearValue:t,cx:i,getStyles:a,getClassNames:r,getValue:o,hasValue:d,isMulti:y,isRtl:u,options:g,selectOption:c,selectProps:p,setValue:f,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,a=t.isMulti;return i===void 0?a:i}},{key:"isOptionDisabled",value:function(t,i){return Mr(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return jr(this.props,t,i)}},{key:"filterOption",value:function(t,i){return Dr(this.props,t,i)}},{key:"formatOptionLabel",value:function(t,i){if(typeof this.props.formatOptionLabel=="function"){var a=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(t,{context:i,inputValue:a,selectValue:r})}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,a=t.isSearchable,r=t.inputId,o=t.inputValue,c=t.tabIndex,f=t.form,p=t.menuIsOpen,y=t.required,u=this.getComponents(),g=u.Input,d=this.state,b=d.inputIsHidden,m=d.ariaSelection,w=this.commonProps,x=r||this.getElementId("input"),C=re(re(re({"aria-autocomplete":"list","aria-expanded":p,"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":y,role:"combobox"},p&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!a&&{"aria-readonly":!0}),this.hasValue()?(m==null?void 0:m.action)==="initial-input-focus"&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return a?R.createElement(g,ae({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:x,innerRef:this.getInputRef,isDisabled:i,isHidden:b,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:c,form:f,type:"text",value:o},C)):R.createElement(ko,ae({id:x,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:Ot,onFocus:this.onInputFocus,disabled:i,tabIndex:c,inputMode:"none",form:f,value:""},C))}},{key:"renderPlaceholderOrValue",value:function(){var t=this,i=this.getComponents(),a=i.MultiValue,r=i.MultiValueContainer,o=i.MultiValueLabel,c=i.MultiValueRemove,f=i.SingleValue,p=i.Placeholder,y=this.commonProps,u=this.props,g=u.controlShouldRenderValue,d=u.isDisabled,b=u.isMulti,m=u.inputValue,w=u.placeholder,x=this.state,C=x.selectValue,I=x.focusedValue,P=x.isFocused;if(!this.hasValue()||!g)return m?null:R.createElement(p,ae({},y,{key:"placeholder",isDisabled:d,isFocused:P,innerProps:{id:this.getElementId("placeholder")}}),w);if(b)return C.map(function(D,j){var U=D===I,q="".concat(t.getOptionLabel(D),"-").concat(t.getOptionValue(D));return R.createElement(a,ae({},y,{components:{Container:r,Label:o,Remove:c},isFocused:U,isDisabled:d,key:q,index:j,removeProps:{onClick:function(){return t.removeValue(D)},onTouchEnd:function(){return t.removeValue(D)},onMouseDown:function(L){L.preventDefault()}},data:D}),t.formatOptionLabel(D,"value"))});if(m)return null;var E=C[0];return R.createElement(f,ae({},y,{data:E,isDisabled:d}),this.formatOptionLabel(E,"value"))}},{key:"renderClearIndicator",value:function(){var t=this.getComponents(),i=t.ClearIndicator,a=this.commonProps,r=this.props,o=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!this.isClearable()||!i||o||!this.hasValue()||c)return null;var p={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:p,isFocused:f}))}},{key:"renderLoadingIndicator",value:function(){var t=this.getComponents(),i=t.LoadingIndicator,a=this.commonProps,r=this.props,o=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!i||!c)return null;var p={"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:p,isDisabled:o,isFocused:f}))}},{key:"renderIndicatorSeparator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator,a=t.IndicatorSeparator;if(!i||!a)return null;var r=this.commonProps,o=this.props.isDisabled,c=this.state.isFocused;return R.createElement(a,ae({},r,{isDisabled:o,isFocused:c}))}},{key:"renderDropdownIndicator",value:function(){var t=this.getComponents(),i=t.DropdownIndicator;if(!i)return null;var a=this.commonProps,r=this.props.isDisabled,o=this.state.isFocused,c={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return R.createElement(i,ae({},a,{innerProps:c,isDisabled:r,isFocused:o}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),a=i.Group,r=i.GroupHeading,o=i.Menu,c=i.MenuList,f=i.MenuPortal,p=i.LoadingMessage,y=i.NoOptionsMessage,u=i.Option,g=this.commonProps,d=this.state.focusedOption,b=this.props,m=b.captureMenuScroll,w=b.inputValue,x=b.isLoading,C=b.loadingMessage,I=b.minMenuHeight,P=b.maxMenuHeight,E=b.menuIsOpen,D=b.menuPlacement,j=b.menuPosition,U=b.menuPortalTarget,q=b.menuShouldBlockScroll,O=b.menuShouldScrollIntoView,L=b.noOptionsMessage,v=b.onMenuScrollToTop,N=b.onMenuScrollToBottom;if(!E)return null;var te=function(ee,X){var Z=ee.type,ce=ee.data,he=ee.isDisabled,oe=ee.isSelected,le=ee.label,ge=ee.value,pe=d===ce,Se=he?void 0:function(){return t.onOptionHover(ce)},_e=he?void 0:function(){return t.selectOption(ce)},h="".concat(t.getElementId("option"),"-").concat(X),$={id:h,onClick:_e,onMouseMove:Se,onMouseOver:Se,tabIndex:-1};return R.createElement(u,ae({},g,{innerProps:$,data:ce,isDisabled:he,isSelected:oe,key:h,label:le,type:Z,value:ge,isFocused:pe,innerRef:pe?t.getFocusedOptionRef:void 0}),t.formatOptionLabel(ee.data,"menu"))},T;if(this.hasOptions())T=this.getCategorizedOptions().map(function(z){if(z.type==="group"){var ee=z.data,X=z.options,Z=z.index,ce="".concat(t.getElementId("group"),"-").concat(Z),he="".concat(ce,"-heading");return R.createElement(a,ae({},g,{key:ce,data:ee,options:X,Heading:r,headingProps:{id:he,data:z.data},label:t.formatGroupLabel(z.data)}),z.options.map(function(oe){return te(oe,"".concat(Z,"-").concat(oe.index))}))}else if(z.type==="option")return te(z,"".concat(z.index))});else if(x){var J=C({inputValue:w});if(J===null)return null;T=R.createElement(p,g,J)}else{var B=L({inputValue:w});if(B===null)return null;T=R.createElement(y,g,B)}var K={minMenuHeight:I,maxMenuHeight:P,menuPlacement:D,menuPosition:j,menuShouldScrollIntoView:O},A=R.createElement(ns,ae({},g,K),function(z){var ee=z.ref,X=z.placerProps,Z=X.placement,ce=X.maxHeight;return R.createElement(o,ae({},g,K,{innerRef:ee,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:x,placement:Z}),R.createElement(jo,{captureEnabled:m,onTopArrive:v,onBottomArrive:N,lockEnabled:q},function(he){return R.createElement(c,ae({},g,{innerRef:function(le){t.getMenuListRef(le),he(le)},isLoading:x,maxHeight:ce,focusedOption:d}),T)}))});return U||j==="fixed"?R.createElement(f,ae({},g,{appendTo:U,controlElement:this.controlRef,menuPlacement:D,menuPosition:j}),A):A}},{key:"renderFormField",value:function(){var t=this,i=this.props,a=i.delimiter,r=i.isDisabled,o=i.isMulti,c=i.name,f=i.required,p=this.state.selectValue;if(f&&!this.hasValue()&&!r)return R.createElement(Ro,{name:c,onFocus:this.onValueInputFocus});if(!(!c||r))if(o)if(a){var y=p.map(function(d){return t.getOptionValue(d)}).join(a);return R.createElement("input",{name:c,type:"hidden",value:y})}else{var u=p.length>0?p.map(function(d,b){return R.createElement("input",{key:"i-".concat(b),name:c,type:"hidden",value:t.getOptionValue(d)})}):R.createElement("input",{name:c,type:"hidden",value:""});return R.createElement("div",null,u)}else{var g=p[0]?this.getOptionValue(p[0]):"";return R.createElement("input",{name:c,type:"hidden",value:g})}}},{key:"renderLiveRegion",value:function(){var t=this.commonProps,i=this.state,a=i.ariaSelection,r=i.focusedOption,o=i.focusedValue,c=i.isFocused,f=i.selectValue,p=this.getFocusableOptions();return R.createElement(yo,ae({},t,{id:this.getElementId("live-region"),ariaSelection:a,focusedOption:r,focusedValue:o,isFocused:c,selectValue:f,focusableOptions:p}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,a=t.IndicatorsContainer,r=t.SelectContainer,o=t.ValueContainer,c=this.props,f=c.className,p=c.id,y=c.isDisabled,u=c.menuIsOpen,g=this.state.isFocused,d=this.commonProps=this.getCommonProps();return R.createElement(r,ae({},d,{className:f,innerProps:{id:p,onKeyDown:this.onKeyDown},isDisabled:y,isFocused:g}),this.renderLiveRegion(),R.createElement(i,ae({},d,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:y,isFocused:g,menuIsOpen:u}),R.createElement(o,ae({},d,{isDisabled:y}),this.renderPlaceholderOrValue(),this.renderInput()),R.createElement(a,ae({},d,{isDisabled:y}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}],[{key:"getDerivedStateFromProps",value:function(t,i){var a=i.prevProps,r=i.clearFocusValueOnUpdate,o=i.inputIsHiddenAfterUpdate,c=i.ariaSelection,f=i.isFocused,p=i.prevWasFocused,y=t.options,u=t.value,g=t.menuIsOpen,d=t.inputValue,b=t.isMulti,m=Cn(u),w={};if(a&&(u!==a.value||y!==a.options||g!==a.menuIsOpen||d!==a.inputValue)){var x=g?Zo(t,m):[],C=r?Go(i,m):null,I=Yo(i,x);w={selectValue:m,focusedOption:I,focusedValue:C,clearFocusValueOnUpdate:!1}}var P=o!=null&&t!==a?{inputIsHidden:o,inputIsHiddenAfterUpdate:void 0}:{},E=c,D=f&&p;return f&&!D&&(E={value:mt(b,m,m[0]||null),options:m,action:"initial-input-focus"},D=!p),(c==null?void 0:c.action)==="initial-input-focus"&&(E=null),re(re(re({},w),P),{},{prevProps:t,ariaSelection:E,prevWasFocused:D})}}]),n}(R.Component);Rr.defaultProps=Wo;var Xo=R.forwardRef(function(l,e){var n=pa(l);return R.createElement(Rr,ae({ref:e},n))}),qo=Xo,Jo=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function Yt(){return Yt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Fr=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 n=Qo(e,Jo);return Yt({},n)},el=function(e){var n=typeof e=="string";return n&&["sm","md","lg"].includes(e)},tl=function(e){return el(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},De=function(e){var n=Mt(),s=tl(n.components.Input.defaultProps.size),t=e??s,i=Fi(typeof t=="string"?[t]:t,{fallback:"md"})||s;return i};function Ge(){return Ge=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var ol=function(e){var n=e.className,s=e.cx,t=e.children,i=e.innerRef,a=e.innerProps,r=e.isDisabled,o=e.isFocused,c=e.menuIsOpen,f=e.selectProps,p=f.chakraStyles,y=f.size,u=f.variant,g=f.focusBorderColor,d=f.errorBorderColor,b=f.isInvalid,m=f.isReadOnly,w=De(y),x=Be("Input",{size:w,variant:u,focusBorderColor:g,errorBorderColor:d}),C=x.field,I=C.height,P=C.h,E=sl(C,al),D=I||P,j=Pe({},E,{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",padding:0,overflow:"hidden",height:"auto",minH:D},r?{pointerEvents:"none"}:{}),U=p!=null&&p.control?p.control(j,e):j;return se.createElement(de,Pe({ref:i,className:s({control:!0,"control--is-disabled":r,"control--is-focused":o,"control--menu-is-open":c},n),sx:U},a,{"data-focus":o?!0:void 0,"data-focus-visible":o?!0:void 0,"data-invalid":b?!0:void 0,"data-disabled":r?!0:void 0,"data-readonly":m?!0:void 0}),t)},ll=function(e){var n=e.className,s=e.cx,t=e.selectProps,i=t.chakraStyles,a=t.useBasicStyles,r=t.variant,o=Pe({opacity:1},a||r!=="outline"?{display:"none"}:{}),c=i!=null&&i.indicatorSeparator?i.indicatorSeparator(o,e):o;return se.createElement(Jn,{className:s({"indicator-separator":!0},n),sx:c,orientation:"vertical"})},ul=function(e){return se.createElement(Qt,Pe({role:"presentation",focusable:"false","aria-hidden":"true"},e),se.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},cl=function(e){var n=e.children,s=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,o=a.useBasicStyles,c=a.size,f=a.focusBorderColor,p=a.errorBorderColor,y=a.variant,u=De(c),g=Be("Input",{size:u,variant:y,focusBorderColor:f,errorBorderColor:p}),d={sm:"16px",md:"20px",lg:"24px"},b=d[u],m=Pe({},g.addon,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",borderRadius:0,borderWidth:0,fontSize:b},o&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=r!=null&&r.dropdownIndicator?r.dropdownIndicator(m,e):m,x={height:"1em",width:"1em"},C=r!=null&&r.downChevron?r.downChevron(x,e):x;return se.createElement(de,Pe({},i,{className:t({indicator:!0,"dropdown-indicator":!0},s),sx:w}),n||se.createElement(ul,{sx:C}))},dl=function(e){return se.createElement(Qt,Pe({focusable:"false","aria-hidden":!0},e),se.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"}))},hl=function(e){var n=e.children,s=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,o=a.size,c=De(o),f=Bn("CloseButton",{size:c}),p=Pe({},f,{marginX:1,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,cursor:"pointer"}),y=r!=null&&r.clearIndicator?r.clearIndicator(p,e):p,u={width:"1em",height:"1em"},g=r!=null&&r.crossIcon?r.crossIcon(u,e):u;return se.createElement(de,Pe({role:"button",className:t({indicator:!0,"clear-indicator":!0},s),sx:y,"aria-label":"Clear selected options"},i),n||se.createElement(dl,{sx:g}))},fl=function(e){var n=e.className,s=e.cx,t=e.innerProps,i=e.selectProps,a=i.chakraStyles,r=i.size,o=e.color,c=e.emptyColor,f=e.speed,p=e.thickness,y=e.spinnerSize,u=De(r),g={sm:"xs",md:"sm",lg:"md"},d=g[u],b={marginRight:3},m=a!=null&&a.loadingIndicator?a.loadingIndicator(b,e):b;return se.createElement(qr,Pe({className:s({indicator:!0,"loading-indicator":!0},n),sx:m},t,{size:y||d,color:o,emptyColor:c,speed:f,thickness:p}))};const pl=ol;var ml=["innerRef","isDisabled","isHidden","inputClassName"];function rt(){return rt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var gl=function(e){var n=e.className,s=e.cx,t=e.value,i=e.selectProps,a=i.chakraStyles,r=i.isReadOnly,o=Fr(e),c=o.innerRef,f=o.isDisabled,p=o.isHidden,y=o.inputClassName,u=vl(o,ml),g={gridArea:"1 / 2",minW:"2px",border:0,margin:0,outline:0,padding:0},d={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:f?"hidden":"visible",transform:t?"translateZ(0)":"",_after:rt({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre",padding:0},g)},b=a!=null&&a.inputContainer?a.inputContainer(d,e):d,m=rt({background:0,opacity:p?0:1,width:"100%"},g),w=a!=null&&a.input?a.input(m,e):m;return se.createElement(de,{className:s({"input-container":!0},n),"data-value":t||"",sx:b},se.createElement(Ue.input,rt({className:s({input:!0},y),ref:c,sx:w,disabled:f,readOnly:r?!0:void 0},u)))};const bl=gl;var yl=["data"];function wl(l,e){if(l==null)return{};var n={},s=Object.keys(l),t,i;for(i=0;i=0)&&(n[t]=l[t]);return n}function xe(){return xe=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Gl=function(e){var n,s=e.components,t=s===void 0?{}:s;e.theme;var i=e.size,a=e.colorScheme,r=a===void 0?"gray":a,o=e.isDisabled,c=e.isInvalid,f=e.isReadOnly,p=e.required,y=e.isRequired,u=e.inputId,g=e.tagVariant,d=e.selectedOptionStyle,b=d===void 0?"color":d,m=e.selectedOptionColorScheme,w=e.selectedOptionColor,x=e.variant,C=e.focusBorderColor,I=e.errorBorderColor,P=e.chakraStyles,E=P===void 0?{}:P,D=e.onFocus,j=e.onBlur,U=e.menuIsOpen,q=Zl(e,Wl),O=Mt(),L=O.components.Input.defaultProps.variant,v=vi({id:u,isDisabled:o,isInvalid:c,isRequired:y,isReadOnly:f,onFocus:D,onBlur:j}),N=U??(v.readOnly?!1:void 0),te=b,T=["color","check"];T.includes(b)||(te="color");var J=m||w||"blue";typeof J!="string"&&(J="blue");var B=Pt({components:Pt({},Hl,t),colorScheme:r,size:i,tagVariant:g,selectedOptionStyle:te,selectedOptionColorScheme:J,variant:x??L,chakraStyles:E,focusBorderColor:C,errorBorderColor:I,onFocus:v.onFocus,onBlur:v.onBlur,isDisabled:v.disabled,isInvalid:!!v["aria-invalid"],inputId:v.id,isReadOnly:v.readOnly,required:p??v.required,menuIsOpen:N},q,{"aria-invalid":(n=q["aria-invalid"])!=null?n:v["aria-invalid"]});return B};const Yl=Gl;function qt(){return qt=Object.assign?Object.assign.bind():function(l){for(var e=1;e({value:g,label:g})))??[],[r,o]=R.useState(a),c=async()=>{var g,d;await((g=He)==null?void 0:g.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((d=He)==null?void 0:d.listAll().then(b=>s(b??[]))),i("")},f=async()=>{var d;const g=await((d=He)==null?void 0:d.listAll());s(g??[])};if(He==null)return alert("Error: TagsTable is not loaded"),null;const p=n.map(g=>({value:g.name,label:g.name})),y=37*5;return _.jsxs(gi,{isLazy:!0,onOpen:f,children:[_.jsx(bi,{children:_.jsx(we,{"aria-label":"Delete confirm",size:"sm",variant:"ghost",icon:_.jsx(rr,{color:"#718096"})})}),_.jsxs(yi,{children:[_.jsx(wi,{}),_.jsx(xi,{}),_.jsx(tr,{children:_.jsx("b",{children:l.name})}),_.jsxs(Si,{children:[_.jsx(Xl,{isMulti:!0,name:"tags",options:p,menuIsOpen:!0,value:r,onChange:async g=>{var d;o(g),await((d=ye)==null?void 0:d.updateFlow(l.id,{tags:g.map(b=>b.value)})),await(e==null?void 0:e())},chakraStyles:{dropdownIndicator:g=>({...g,p:0,w:"30px"}),menuList:g=>({...g,shadow:"none",pt:0})},placeholder:"Select tags",closeMenuOnSelect:!1,maxMenuHeight:y}),_.jsxs(be,{gap:4,mt:Math.min(y,Math.max(n.length,3)*37),children:[_.jsx(it,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:g=>{i(g.target.value.trim())}}),_.jsx(Ce,{iconSpacing:1,leftIcon:_.jsx(nn,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:c,children:"New Tag"})]})]})]})]})}function Jl({menuPosition:l,workflowID:e,onClose:n}){const{onDuplicateWorkflow:s}=R.useContext(rn);return _.jsx(_.Fragment,{children:_.jsx(de,{position:"absolute",top:l.y,left:l.x,children:_.jsx(Xe,{isOpen:!0,onClose:n,children:_.jsx(at,{children:_.jsx(Fe,{onClick:()=>s&&s(e),children:"Duplicate"})})})})})}const Nn=R.memo(function({workflow:e}){const{colorMode:n}=Jt(),[s,t]=R.useState({x:0,y:0}),[i,a]=R.useState(!1),{setDraggingFile:r,isMultiSelecting:o,onMultiSelectFlow:c,onDeleteFlow:f,multiSelectedFlowsID:p}=R.useContext(Ve),y=p&&p.length>0&&p.includes(e.id),{curFlowID:u,loadWorkflowID:g}=R.useContext(rn),d=u===e.id,b=P=>{P.preventDefault(),t({x:P.clientX,y:P.clientY}),a(!0)},[m,w]=R.useState(!1),x=()=>{a(!1)},C=n==="light"?"gray.200":"#4A5568",I=_.jsx(de,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":i?C:void 0,color:d&&!o?"#333":void 0,draggable:!o,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:1,onClick:()=>{!o&&g(e.id)},_hover:{bg:C},children:_.jsxs(be,{children:[e.coverMediaPath!=null&&_.jsx(ji,{mediaLocalPath:e.coverMediaPath,size:60,hideBrokenImage:!0,isPreview:!0}),_.jsxs($e,{textAlign:"left",gap:0,children:[_.jsx(ke,{fontWeight:"500",children:e.name??"untitled"}),_.jsxs(ke,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Kn(e.updateTime)]})]})]})});return _.jsxs(be,{w:"100%",mb:1,justify:"space-between",onContextMenu:b,onMouseEnter:()=>{w(!0)},onMouseLeave:()=>{w(!1)},children:[o?_.jsx(st,{isChecked:y,spacing:4,onChange:P=>{c&&c(e.id,P.target.checked)},children:I}):_.jsxs(_.Fragment,{children:[I,_.jsxs(nt,{width:"90px",justifyContent:"flex-end",children:[m&&_.jsx(ql,{workflow:e}),_.jsx(Re,{label:"Open in new tab",children:_.jsx(we,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>_i(e.id),icon:_.jsx(Ci,{color:"#718096",size:23})})}),_.jsx(Yn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{f&&f(e.id)}})]})]}),i&&_.jsx(Jl,{menuPosition:s,onClose:x,workflowID:e.id})]})});function Tr({items:l}){var y;const[e,n]=R.useState(!1),s=l.filter(We),t=l.filter(u=>!We(u)),i=(y=t[0])==null?void 0:y.parentFolderID,[a,r]=R.useState(!1),{onRefreshFilesList:o,draggingFile:c,refreshFolderStamp:f}=R.useContext(Ve),p=async u=>{var g,d;if(u.preventDefault(),u.stopPropagation(),!c)return r(!1);if(We(c)){if(c.id===i)return r(!1);await((g=Le)==null?void 0:g.update({id:c.id,parentFolderID:i}))}else await((d=ye)==null?void 0:d.updateFlow(c.id,{parentFolderID:i}));await(o==null?void 0:o()),r(!1)};return R.useEffect(()=>{var u;(u=Oe)==null||u.getSetting("foldersOnTop").then(g=>{n(g??!1)})},[f]),_.jsxs(_.Fragment,{children:[e&&s.map(u=>_.jsx(yn,{folder:u},u.id)),_.jsx(de,{border:a?"2px dashed #718096":"2px dashed transparent",onDragOver:u=>{u.preventDefault(),u.stopPropagation(),r(!0)},onDragLeave:u=>{u.preventDefault(),u.stopPropagation(),r(!1)},onDrop:p,className:"droppable",children:e?t.map(u=>_.jsx(Nn,{workflow:u},u.id)):l.map(u=>We(u)?_.jsx(yn,{folder:u},u.id):_.jsx(Nn,{workflow:u},u.id))})]})}function lu({onClose:l,onClickNewFlow:e}){const[n,s]=R.useState([]),t=R.useRef([]),i=R.useRef([]),{loadWorkflowID:a,curFlowID:r}=R.useContext(rn),[o,c]=R.useState(),[f,p]=R.useState(!1),[y,u]=R.useState([]),[g,d]=R.useState(0),[b,m]=R.useState(""),w=ia(b,400),x=R.useRef(null),[C,I]=R.useState(null),P=R.useRef(window.localStorage.getItem(Ut)??pn.RECENTLY_MODIFIED),E=async()=>{var J,B;const T=await((J=ye)==null?void 0:J.listFolderContent())??[];t.current=T,await((B=ye)==null?void 0:B.listAll().then(K=>{i.current=K})),j(),d(Date.now())},D=!!o||!!w,j=()=>{if(D){const T=i.current.filter(J=>{var A;let B=!0,K=!0;return o&&(B=!!((A=J.tags)!=null&&A.includes(o))),w&&(K=!!J.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),B&&K});s(Ft(T,P.current))}else s(Ft(t.current,P.current))},U=T=>{s(Ft(n,T)),P.current=T,window.localStorage.setItem(Ut,T),!D&&d(Date.now())};R.useEffect(()=>{j()},[w,o]);const q=R.useCallback(async T=>{var J,B,K;await((J=ye)==null?void 0:J.deleteFlow(T)),((K=(B=ye)==null?void 0:B.curWorkflow)==null?void 0:K.id)===T&&await(a==null?void 0:a(null)),await E()},[o,w]);R.useEffect(()=>{E();const T=async J=>{var B;if(x.current){const K=await((B=ye)==null?void 0:B.get(x.current));K&&K.json&&ra(K.json,[J.canvasX,J.canvasY])}};return ct.canvasEl.addEventListener("drop",T),ct.canvasEl.addEventListener("click",l),()=>{ct.canvasEl.removeEventListener("drop",T),ct.canvasEl.removeEventListener("click",l)}},[]);const O=R.useCallback((T,J)=>{u(B=>{const K=[...B];return J?K.push(T):K.splice(K.indexOf(T),1),K})},[]),L=(T,J)=>{var B;switch(T){case"batchDelete":r&&((B=ye)==null||B.get(r).then(K=>{K||a==null||a(null)})),E(),p(!1),u([]);return;case"selectAll":u(J?i.current.map(K=>K.id):[]);return}},v=T=>{I(T),We(T)||(x.current=T.id)},N=T=>{m(T)},te=450;return _.jsx(Ve.Provider,{value:{onRefreshFilesList:E,draggingFile:C??void 0,setDraggingFile:v,isMultiSelecting:f,onMultiSelectFlow:O,multiSelectedFlowsID:y,onDeleteFlow:q,refreshFolderStamp:g,setRefreshFolderStamp:d},children:_.jsx(de,{style:{width:te},children:_.jsxs(ki,{width:te,height:"100vh",pl:4,pr:5,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Oi,children:[_.jsxs(nt,{alignItems:"center",justifyContent:"space-between",children:[_.jsxs(be,{gap:4,children:[_.jsx(be,{gap:2,children:_.jsx(ke,{fontSize:19,fontWeight:600,children:"☕️Workspace"})}),_.jsx(ar,{}),_.jsx(Re,{label:"Open workspace save directory",children:_.jsx(we,{"aria-label":"Open workspace save directory",size:"sm",icon:_.jsx(Xn,{}),variant:"outline",colorScheme:"teal",onClick:()=>Ii()})}),_.jsx(Re,{label:"New workflow",children:_.jsx(we,{"aria-label":"New workflow",size:"sm",icon:_.jsx(nn,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),_.jsx(be,{alignItems:"center",children:_.jsx(Qi,{})})]}),_.jsxs(nt,{direction:"column",h:"calc(100% - 64px)",children:[_.jsx(oa,{selectedTag:o,setSelectedTag:c}),_.jsxs(be,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[_.jsxs(be,{children:[i.current.length>0?_.jsx(na,{multipleState:f,changeMultipleState:T=>{p(T),!T&&u([])},selectedKeys:y,isSelectedAll:y.length===i.current.length,batchOperationCallback:L}):_.jsx(de,{}),!f&&_.jsx(Re,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:_.jsx(we,{size:"sm",variant:"outline",icon:_.jsx(nr,{size:21}),onClick:async()=>{var T;await((T=Le)==null?void 0:T.create({name:"New Folder"})),E()},"aria-label":"new folder button"})})]}),_.jsxs(Xe,{closeOnSelect:!0,children:[_.jsx(jt,{as:Ce,variant:"ghost",size:"xs",pr:0,rightIcon:_.jsx(tn,{size:"16"}),children:_.jsxs(be,{children:[_.jsx(ke,{children:"Sort by:"}),_.jsx(ke,{display:"inline-block",children:P.current})]})}),_.jsx(at,{children:_.jsx(er,{value:P.current,type:"radio",onChange:T=>U(T),children:Object.values(pn).map((T,J)=>_.jsx(an,{value:T,children:T},J))})})]})]}),_.jsx(sa,{searchValue:b,onUpdateSearchValue:N}),_.jsx(nt,{overflowY:"auto",overflowX:"hidden",direction:"column",children:_.jsx(Tr,{items:n})})]})]})})})}export{lu as default}; diff --git a/dist/workspace_web/ShareDialog-TS-2UrPz.js b/dist/workspace_web/ShareDialog-TS-2UrPz.js deleted file mode 100644 index 9aa13f6..0000000 --- a/dist/workspace_web/ShareDialog-TS-2UrPz.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,m as he,v as ne,b as fe,f as le,j as e,g as J,h as pe,k as y,p as E,n as X,i as ge,o as ve,G as we,ab as me,B as q,M as ke,L as be,N as xe,O as ye,R as Ce}from"./input.js";import{an as je,B as Se,A as De,a5 as Ie,H as Y,T as Q,z as Pe,ao as Re,a3 as ie,m as _e,l as ae,j as re,ap as Fe,k as Ee,F as Le,x as U,aq as z,ar as Me,as as Ne,at as We,au as Te,ab as Ve,aa as He}from"./App-iJ8dSmpT.js";import{app as Ae}from"/scripts/app.js";import{t as Be}from"./index-pz0vT7Or.js";import{T as Oe}from"./chunk-RPO2WXNL-dt-e86vT.js";import"/scripts/api.js";function Ue(t){return t&&ne(t)&&ne(t.target)}function qe(t={}){const{onChange:f,value:r,defaultValue:s,name:p,isDisabled:u,isFocusable:d,isNative:g,...h}=t,[b,j]=n.useState(s||""),k=typeof r<"u",S=k?r:b,w=n.useRef(null),D=n.useCallback(()=>{const a=w.current;if(!a)return;let c="input:not(:disabled):checked";const I=a.querySelector(c);if(I){I.focus();return}c="input:not(:disabled)";const o=a.querySelector(c);o==null||o.focus()},[]),v=`radio-${n.useId()}`,M=p||v,R=n.useCallback(a=>{const c=Ue(a)?a.target.value:a;k||j(c),f==null||f(String(c))},[f,k]),A=n.useCallback((a={},c=null)=>({...a,ref:he(c,w),role:"radiogroup"}),[]),_=n.useCallback((a={},c=null)=>({...a,ref:c,name:M,[g?"checked":"isChecked"]:S!=null?a.value===S:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,M,R,S]);return{getRootProps:A,getRadioProps:_,name:M,ref:w,focus:D,setValue:j,value:S,onChange:R,isDisabled:u,isFocusable:d,htmlProps:h}}var[Ge,ce]=fe({name:"RadioGroupContext",strict:!1}),de=le((t,f)=>{const{colorScheme:r,size:s,variant:p,children:u,className:d,isDisabled:g,isFocusable:h,...b}=t,{value:j,onChange:k,getRootProps:S,name:w,htmlProps:D}=qe(b),L=n.useMemo(()=>({name:w,size:s,onChange:k,colorScheme:r,value:j,variant:p,isDisabled:g,isFocusable:h}),[w,s,k,r,j,p,g,h]);return e.jsx(Ge,{value:L,children:e.jsx(J.div,{...S(D,f),className:pe("chakra-radio-group",d),children:u})})});de.displayName="RadioGroup";var Ke={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function $e(t={}){const{defaultChecked:f,isChecked:r,isFocusable:s,isDisabled:p,isReadOnly:u,isRequired:d,onChange:g,isInvalid:h,name:b,value:j,id:k,"data-radiogroup":S,"aria-describedby":w,...D}=t,L=`radio-${n.useId()}`,v=je(),R=!!ce()||!!S;let _=!!v&&!R?v.id:L;_=k??_;const a=p??(v==null?void 0:v.isDisabled),c=u??(v==null?void 0:v.isReadOnly),I=d??(v==null?void 0:v.isRequired),o=h??(v==null?void 0:v.isInvalid),[l,P]=n.useState(!1),[m,C]=n.useState(!1),[x,N]=n.useState(!1),[W,T]=n.useState(!1),[G,K]=n.useState(!!f),B=typeof r<"u",F=B?r:G;n.useEffect(()=>Be(P),[]);const V=n.useCallback(i=>{if(c||a){i.preventDefault();return}B||K(i.target.checked),g==null||g(i)},[B,a,c,g]),O=n.useCallback(i=>{i.key===" "&&T(!0)},[T]),$=n.useCallback(i=>{i.key===" "&&T(!1)},[T]),ee=n.useCallback((i={},H=null)=>({...i,ref:H,"data-active":y(W),"data-hover":y(x),"data-disabled":y(a),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(m),"data-focus-visible":y(m&&l),"data-readonly":y(c),"aria-hidden":!0,onMouseDown:E(i.onMouseDown,()=>T(!0)),onMouseUp:E(i.onMouseUp,()=>T(!1)),onMouseEnter:E(i.onMouseEnter,()=>N(!0)),onMouseLeave:E(i.onMouseLeave,()=>N(!1))}),[W,x,a,o,F,m,c,l]),{onFocus:oe,onBlur:se}=v??{},ue=n.useCallback((i={},H=null)=>{const te=a&&!s;return{...i,id:_,ref:H,type:"radio",name:b,value:j,onChange:E(i.onChange,V),onBlur:E(se,i.onBlur,()=>C(!1)),onFocus:E(oe,i.onFocus,()=>C(!0)),onKeyDown:E(i.onKeyDown,O),onKeyUp:E(i.onKeyUp,$),checked:F,disabled:te,readOnly:c,required:I,"aria-invalid":X(o),"aria-disabled":X(te),"aria-required":X(I),"data-readonly":y(c),"aria-describedby":w,style:Ke}},[a,s,_,b,j,V,se,oe,O,$,F,c,I,o,w]);return{state:{isInvalid:o,isFocused:m,isChecked:F,isActive:W,isHovered:x,isDisabled:a,isReadOnly:c,isRequired:I},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(i={},H=null)=>({...i,ref:H,onMouseDown:E(i.onMouseDown,ze),"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(i,H=null)=>({...i,ref:H,"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:D}}function ze(t){t.preventDefault(),t.stopPropagation()}function Je(t,f){const r={},s={};for(const[p,u]of Object.entries(t))f.includes(p)?r[p]=u:s[p]=u;return[r,s]}var Z=le((t,f)=>{var r;const s=ce(),{onChange:p,value:u}=t,d=ge("Radio",{...s,...t}),g=ve(t),{spacing:h="0.5rem",children:b,isDisabled:j=s==null?void 0:s.isDisabled,isFocusable:k=s==null?void 0:s.isFocusable,inputProps:S,...w}=g;let D=t.isChecked;(s==null?void 0:s.value)!=null&&u!=null&&(D=s.value===u);let L=p;s!=null&&s.onChange&&u!=null&&(L=we(s.onChange,p));const v=(r=t==null?void 0:t.name)!=null?r:s==null?void 0:s.name,{getInputProps:M,getCheckboxProps:R,getLabelProps:A,getRootProps:_,htmlProps:a}=$e({...w,isChecked:D,isFocusable:k,isDisabled:j,onChange:L,name:v}),[c,I]=Je(a,me),o=R(I),l=M(S,f),P=A(),m=Object.assign({},c,_()),C={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...d.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...d.control},N={userSelect:"none",marginStart:h,...d.label};return e.jsxs(J.label,{className:"chakra-radio",...m,__css:C,children:[e.jsx("input",{className:"chakra-radio__input",...l}),e.jsx(J.span,{className:"chakra-radio__control",...o,__css:x}),b&&e.jsx(J.span,{className:"chakra-radio__label",...P,__css:N,children:b})]})});Z.displayName="Radio";function Ye({options:t,value:f,onChange:r}){const[s,p]=n.useState(!1),u=n.useRef(null),d=t.find(h=>h.value===f);n.useEffect(()=>{const h=b=>{u.current&&!u.current.contains(b.target)&&p(!1)};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[u]);const g=()=>p(!s);return e.jsxs(Se,{position:"relative",children:[e.jsx(q,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:d==null?void 0:d.icon,children:d==null?void 0:d.label}),s&&e.jsx(Ie,{gap:4,ref:u,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(h=>e.jsx(q,{onClick:()=>{p(!1),r(h.value)},leftIcon:h.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:h.label},h.label))})]})}function Qe({version:t,cloudHost:f}){const r=t,s=e.jsxs(Y,{spacing:4,alignItems:"center",children:[e.jsx(Q,{children:r.name}),e.jsx(Q,{color:"GrayText",children:Pe(r.createTime,!1)}),r.cloudID&&e.jsx("a",{href:f+"/workflow_ver/"+r.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(q,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Re,{}),rightIcon:e.jsx(ie,{size:18}),children:"Shared"})})]});return t.cloudID?e.jsx(e.Fragment,{children:s}):e.jsx(Z,{value:r.id,mb:5,children:s},r.id)}function io({onClose:t}){var c,I;const[f,r]=n.useState("version "+Xe()),[s,p]=n.useState([]),[u,d]=n.useState(!1),[g,h]=n.useState(""),[b,j]=n.useState("PRIVATE"),[k,S]=n.useState("new_version"),w=n.useRef(""),[D,L]=n.useState(),v=_e(),M=async o=>{var N,W;const l=o.data;if(o.origin!==w.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,m=l.localVersionID,C=l.version.id,x=l.version.workflowID;x&&P&&await((N=U)==null?void 0:N.updateFlow(P,{cloudID:x,cloudURL:w.current+"/workflow/"+x})),m&&C&&await((W=z)==null?void 0:W.update(m,{cloudID:C,cloudURL:w.current+"/workflow_ver/"+C})),R(),window.open(w.current+"/workflow_ver/"+C,"_blank"),d(!1)};n.useEffect(()=>(R(),window.addEventListener("message",M),()=>{window.removeEventListener("message",M)}),[]);const R=async()=>{var P,m,C;const o=await((P=ae)==null?void 0:P.getSetting("cloudHost"));o&&(h(o),w.current=o);const l=((m=U)==null?void 0:m.curWorkflow)??void 0;L(l),l!=null&&l.cloudID&&l.cloudURL&&We(l).then(x=>{j(x)}),(C=z)==null||C.listByWorkflowID(l.id).then(x=>{p(x)})},A=o=>{navigator.clipboard.writeText(o).then(()=>{v({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(l=>{console.error("Failed to copy text: ",l)})},_=async()=>{var K,B,F;d(!0);const o=Me(32),l=await((K=ae)==null?void 0:K.getSetting("cloudHost"));let P,m;try{if(P=Ne(),k==="new_version"?m=await((B=z)==null?void 0:B.add({workflowID:D.id,name:f,createTime:Date.now(),json:JSON.stringify(Ae.graph.serialize())})):m=await((F=z)==null?void 0:F.get(k)),!m){alert(`Failed to find version: ${k}, please try again.`),d(!1);return}}catch(V){console.error(V),d(!1),alert("Failed to share workflow, please try again.");return}const C=window.location.protocol,x=window.location.host,N=`${C}//${x}`,W=l+`/share_workflow_confirm/${o}?redirectUrl=${N}`,T=window.open(W,"Share Workflow","width=800,height=800"),G=V=>{var O;if(V.origin===l&&V.data==="child_ready"){const $=(O=U)==null?void 0:O.curWorkflow;T.postMessage({workflow:$,version:m,nodeDefs:P,privacy:b},l),window.removeEventListener("message",G)}};window.addEventListener("message",G)},a=(I=(c=U)==null?void 0:c.curWorkflow)==null?void 0:I.cloudID;return e.jsxs(ke,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(be,{}),e.jsxs(xe,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',D==null?void 0:D.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(re,{gap:5,children:[a==null?e.jsx(Ye,{options:Fe,value:b,onChange:o=>{j(o)}}):e.jsx(Oe,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Te,{privacy:b,showEmoji:!0})}),a&&e.jsxs(Y,{spacing:2,color:"teal.400",children:[e.jsxs(Ve,{href:g+"/workflow/"+a,isExternal:!0,children:[g+"/workflow/"+a," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(q,{width:"180px",size:"sm",leftIcon:e.jsx(He,{}),onClick:()=>{var o,l;A(g+"/workflow/"+((l=(o=U)==null?void 0:o.curWorkflow)==null?void 0:l.cloudID))},children:"Copy link"})]}),e.jsx(Q,{children:"Choose a version to share:"}),e.jsx(de,{gap:4,onChange:o=>{S(o)},value:k,children:e.jsxs(re,{children:[e.jsxs(Y,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Ee,{value:f,width:"60%",onFocus:()=>{S("new_version")},onChange:o=>{r(o.target.value)}}),e.jsx(Le,{color:"green",children:e.jsx(Q,{children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Qe,{version:o,cloudHost:g},o.id))]})})]}),e.jsx(Y,{justifyContent:"flex-end",mt:16,children:e.jsx(q,{colorScheme:"teal",onClick:_,isDisabled:u,children:u?"Sharing":"Share"})})]})]})]})}function Xe(){const t=new Date,f=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${f}-${r}-${s}`}export{io as default}; diff --git a/dist/workspace_web/ShareDialog-uZbltl_0.js b/dist/workspace_web/ShareDialog-uZbltl_0.js new file mode 100644 index 0000000..20b3977 --- /dev/null +++ b/dist/workspace_web/ShareDialog-uZbltl_0.js @@ -0,0 +1 @@ +import{r,m as pe,v as ae,b as ge,f as ie,j as e,g as J,h as ve,k as x,p as M,n as Z,i as ke,o as ye,G as we,ab as me,B as G,M as be,L as xe,N as Ce,O as Ie,R as je}from"./input.js";import{al as Pe,h as X,B as Se,A as De,a5 as Re,H as Y,T as Q,z as Le,a3 as ce,m as _e,l as re,j as le,k as Me,F as Ee,x as O,am as z}from"./App-09wdM9e8.js";import{app as de}from"/scripts/app.js";import{t as Fe}from"./index-pz0vT7Or.js";import{T as Ue}from"./chunk-RPO2WXNL-dt-e86vT.js";import{L as Te,I as Ne}from"./IconCopy-48H4n38O.js";import"/scripts/api.js";function We(o){return o&&ae(o)&&ae(o.target)}function Ve(o={}){const{onChange:a,value:t,defaultValue:n,name:d,isDisabled:u,isFocusable:i,isNative:p,...g}=o,[m,I]=r.useState(n||""),w=typeof t<"u",j=w?t:m,k=r.useRef(null),P=r.useCallback(()=>{const l=k.current;if(!l)return;let f="input:not(:disabled):checked";const S=l.querySelector(f);if(S){S.focus();return}f="input:not(:disabled)";const s=l.querySelector(f);s==null||s.focus()},[]),v=`radio-${r.useId()}`,F=d||v,R=r.useCallback(l=>{const f=We(l)?l.target.value:l;w||I(f),a==null||a(String(f))},[a,w]),A=r.useCallback((l={},f=null)=>({...l,ref:pe(f,k),role:"radiogroup"}),[]),L=r.useCallback((l={},f=null)=>({...l,ref:f,name:F,[p?"checked":"isChecked"]:j!=null?l.value===j:void 0,onChange(s){R(s)},"data-radiogroup":!0}),[p,F,R,j]);return{getRootProps:A,getRadioProps:L,name:F,ref:k,focus:P,setValue:I,value:j,onChange:R,isDisabled:u,isFocusable:i,htmlProps:g}}var[Ae,ue]=ge({name:"RadioGroupContext",strict:!1}),he=ie((o,a)=>{const{colorScheme:t,size:n,variant:d,children:u,className:i,isDisabled:p,isFocusable:g,...m}=o,{value:I,onChange:w,getRootProps:j,name:k,htmlProps:P}=Ve(m),E=r.useMemo(()=>({name:k,size:n,onChange:w,colorScheme:t,value:I,variant:d,isDisabled:p,isFocusable:g}),[k,n,w,t,I,d,p,g]);return e.jsx(Ae,{value:E,children:e.jsx(J.div,{...j(P,a),className:ve("chakra-radio-group",i),children:u})})});he.displayName="RadioGroup";var Be={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function He(o={}){const{defaultChecked:a,isChecked:t,isFocusable:n,isDisabled:d,isReadOnly:u,isRequired:i,onChange:p,isInvalid:g,name:m,value:I,id:w,"data-radiogroup":j,"aria-describedby":k,...P}=o,E=`radio-${r.useId()}`,v=Pe(),R=!!ue()||!!j;let L=!!v&&!R?v.id:E;L=w??L;const l=d??(v==null?void 0:v.isDisabled),f=u??(v==null?void 0:v.isReadOnly),S=i??(v==null?void 0:v.isRequired),s=g??(v==null?void 0:v.isInvalid),[c,D]=r.useState(!1),[y,C]=r.useState(!1),[b,U]=r.useState(!1),[T,N]=r.useState(!1),[K,$]=r.useState(!!a),B=typeof t<"u",_=B?t:K;r.useEffect(()=>Fe(D),[]);const W=r.useCallback(h=>{if(f||l){h.preventDefault();return}B||$(h.target.checked),p==null||p(h)},[B,l,f,p]),H=r.useCallback(h=>{h.key===" "&&N(!0)},[N]),q=r.useCallback(h=>{h.key===" "&&N(!1)},[N]),oe=r.useCallback((h={},V=null)=>({...h,ref:V,"data-active":x(T),"data-hover":x(b),"data-disabled":x(l),"data-invalid":x(s),"data-checked":x(_),"data-focus":x(y),"data-focus-visible":x(y&&c),"data-readonly":x(f),"aria-hidden":!0,onMouseDown:M(h.onMouseDown,()=>N(!0)),onMouseUp:M(h.onMouseUp,()=>N(!1)),onMouseEnter:M(h.onMouseEnter,()=>U(!0)),onMouseLeave:M(h.onMouseLeave,()=>U(!1))}),[T,b,l,s,_,y,f,c]),{onFocus:te,onBlur:ne}=v??{},fe=r.useCallback((h={},V=null)=>{const se=l&&!n;return{...h,id:L,ref:V,type:"radio",name:m,value:I,onChange:M(h.onChange,W),onBlur:M(ne,h.onBlur,()=>C(!1)),onFocus:M(te,h.onFocus,()=>C(!0)),onKeyDown:M(h.onKeyDown,H),onKeyUp:M(h.onKeyUp,q),checked:_,disabled:se,readOnly:f,required:S,"aria-invalid":Z(s),"aria-disabled":Z(se),"aria-required":Z(S),"data-readonly":x(f),"aria-describedby":k,style:Be}},[l,n,L,m,I,W,ne,te,H,q,_,f,S,s,k]);return{state:{isInvalid:s,isFocused:y,isChecked:_,isActive:T,isHovered:b,isDisabled:l,isReadOnly:f,isRequired:S},getCheckboxProps:oe,getRadioProps:oe,getInputProps:fe,getLabelProps:(h={},V=null)=>({...h,ref:V,onMouseDown:M(h.onMouseDown,Oe),"data-disabled":x(l),"data-checked":x(_),"data-invalid":x(s)}),getRootProps:(h,V=null)=>({...h,ref:V,"data-disabled":x(l),"data-checked":x(_),"data-invalid":x(s)}),htmlProps:P}}function Oe(o){o.preventDefault(),o.stopPropagation()}function Ge(o,a){const t={},n={};for(const[d,u]of Object.entries(o))a.includes(d)?t[d]=u:n[d]=u;return[t,n]}var ee=ie((o,a)=>{var t;const n=ue(),{onChange:d,value:u}=o,i=ke("Radio",{...n,...o}),p=ye(o),{spacing:g="0.5rem",children:m,isDisabled:I=n==null?void 0:n.isDisabled,isFocusable:w=n==null?void 0:n.isFocusable,inputProps:j,...k}=p;let P=o.isChecked;(n==null?void 0:n.value)!=null&&u!=null&&(P=n.value===u);let E=d;n!=null&&n.onChange&&u!=null&&(E=we(n.onChange,d));const v=(t=o==null?void 0:o.name)!=null?t:n==null?void 0:n.name,{getInputProps:F,getCheckboxProps:R,getLabelProps:A,getRootProps:L,htmlProps:l}=He({...k,isChecked:P,isFocusable:w,isDisabled:I,onChange:E,name:v}),[f,S]=Ge(l,me),s=R(S),c=F(j,a),D=A(),y=Object.assign({},f,L()),C={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...i.container},b={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...i.control},U={userSelect:"none",marginStart:g,...i.label};return e.jsxs(J.label,{className:"chakra-radio",...y,__css:C,children:[e.jsx("input",{className:"chakra-radio__input",...c}),e.jsx(J.span,{className:"chakra-radio__control",...s,__css:b}),m&&e.jsx(J.span,{className:"chakra-radio__label",...D,__css:U,children:m})]})});ee.displayName="Radio";var Ke=X("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"}]]),$e=X("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"}]]),qe=X("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"}]]),ze=X("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"}]]);function Je({options:o,value:a,onChange:t}){const[n,d]=r.useState(!1),u=r.useRef(null),i=o.find(g=>g.value===a);r.useEffect(()=>{const g=m=>{u.current&&!u.current.contains(m.target)&&d(!1)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[u]);const p=()=>d(!n);return e.jsxs(Se,{position:"relative",children:[e.jsx(G,{onClick:p,rightIcon:e.jsx(De,{}),leftIcon:i==null?void 0:i.icon,children:i==null?void 0:i.label}),n&&e.jsx(Re,{gap:4,ref:u,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:o.map(g=>e.jsx(G,{onClick:()=>{d(!1),t(g.value)},leftIcon:g.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:g.label},g.label))})]})}function Ye(o){const a=new Uint8Array(o);return window.crypto.getRandomValues(a),Array.from(a,t=>t.toString(16).padStart(2,"0")).join("")}const Qe=[{label:"Private",value:"PRIVATE",icon:e.jsx(qe,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:e.jsx($e,{})},{label:"Public",value:"PUBLIC",icon:e.jsx(ze,{})}],Xe=()=>{const o=de.graph._nodes,a={};for(let t of o)if(t.type in LiteGraph.registered_node_types){const n=structuredClone(LiteGraph.registered_node_types[t.type].nodeData);if(n==null)continue;for(let d in n.input){const u=n.input[d];for(let i in u){const p=u[i];Array.isArray(p[0])&&(p[0]=["value_1","value_2"])}}a[t.type]=n}return a};async function Ze(o){const a=o.cloudURL;if(!a)throw Error("cloudURL is required");const n=new URL(a).origin;return fetch(n+`/api/getWorkflow?id=${o.cloudID}`).then(d=>d.json()).then(d=>{var i;return((i=d.data)==null?void 0:i.privacy)??"PRIVATE"})}function eo({privacy:o,showEmoji:a=!1}){let t;return o==="PRIVATE"?(t="Private",a&&(t="🔒 Private")):o==="UNLISTED"?(t="Unlisted",a&&(t="🔗 Unlisted")):o==="PUBLIC"&&(t="Public",a&&(t="🌐 Public")),e.jsx("span",{children:t})}function oo({version:o,cloudHost:a}){const t=o,n=e.jsxs(Y,{spacing:4,alignItems:"center",children:[e.jsx(Q,{children:t.name}),e.jsx(Q,{color:"GrayText",children:Le(t.createTime,!1)}),t.cloudID&&e.jsx("a",{href:a+"/workflow_ver/"+t.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(G,{size:"xs",colorScheme:"teal",variant:"outline",leftIcon:e.jsx(Ke,{}),rightIcon:e.jsx(ce,{size:18}),children:"Shared"})})]});return o.cloudID?e.jsx(e.Fragment,{children:n}):e.jsx(ee,{value:t.id,mb:5,children:n},t.id)}function po({onClose:o}){var f,S;const[a,t]=r.useState("version "+to()),[n,d]=r.useState([]),[u,i]=r.useState(!1),[p,g]=r.useState(""),[m,I]=r.useState("PRIVATE"),[w,j]=r.useState("new_version"),k=r.useRef(""),[P,E]=r.useState(),v=_e(),F=async s=>{var U,T;const c=s.data;if(s.origin!==k.current||c.type!=="share_workflow_success")return;const D=c.localWorkflowID,y=c.localVersionID,C=c.version.id,b=c.version.workflowID;b&&D&&await((U=O)==null?void 0:U.updateFlow(D,{cloudID:b,cloudURL:k.current+"/workflow/"+b})),y&&C&&await((T=z)==null?void 0:T.update(y,{cloudID:C,cloudURL:k.current+"/workflow_ver/"+C})),R(),window.open(k.current+"/workflow_ver/"+C,"_blank"),i(!1)};r.useEffect(()=>(R(),window.addEventListener("message",F),()=>{window.removeEventListener("message",F)}),[]);const R=async()=>{var D,y,C;const s=await((D=re)==null?void 0:D.getSetting("cloudHost"));s&&(g(s),k.current=s);const c=((y=O)==null?void 0:y.curWorkflow)??void 0;E(c),c!=null&&c.cloudID&&c.cloudURL&&Ze(c).then(b=>{I(b)}),(C=z)==null||C.listByWorkflowID(c.id).then(b=>{d(b)})},A=s=>{navigator.clipboard.writeText(s).then(()=>{v({title:"Copied to clipboard",status:"success",duration:2e3,isClosable:!0})}).catch(c=>{console.error("Failed to copy text: ",c)})},L=async()=>{var $,B,_;i(!0);const s=Ye(32),c=await(($=re)==null?void 0:$.getSetting("cloudHost"));let D,y;try{if(D=Xe(),w==="new_version"?y=await((B=z)==null?void 0:B.add({workflowID:P.id,name:a,createTime:Date.now(),json:JSON.stringify(de.graph.serialize())})):y=await((_=z)==null?void 0:_.get(w)),!y){alert(`Failed to find version: ${w}, please try again.`),i(!1);return}}catch(W){console.error(W),i(!1),alert("Failed to share workflow, please try again.");return}const C=window.location.protocol,b=window.location.host,U=`${C}//${b}`,T=c+`/share_workflow_confirm/${s}?redirectUrl=${U}`,N=window.open(T,"Share Workflow","width=800,height=800"),K=W=>{var H;if(W.origin===c&&W.data==="child_ready"){const q=(H=O)==null?void 0:H.curWorkflow;N.postMessage({workflow:q,version:y,nodeDefs:D,privacy:m},c),window.removeEventListener("message",K)}};window.addEventListener("message",K)},l=(S=(f=O)==null?void 0:f.curWorkflow)==null?void 0:S.cloudID;return e.jsxs(be,{isOpen:!0,onClose:o,size:"lg",children:[e.jsx(xe,{}),e.jsxs(Ce,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(Ie,{children:['Share "',P==null?void 0:P.name,'"']}),e.jsxs(je,{pb:10,children:[e.jsxs(le,{gap:5,children:[l==null?e.jsx(Je,{options:Qe,value:m,onChange:s=>{I(s)}}):e.jsx(Ue,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(eo,{privacy:m,showEmoji:!0})}),l&&e.jsxs(Y,{spacing:2,color:"teal.400",children:[e.jsxs(Te,{href:p+"/workflow/"+l,isExternal:!0,children:[p+"/workflow/"+l," ",e.jsx(ce,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(G,{width:"180px",size:"sm",leftIcon:e.jsx(Ne,{}),onClick:()=>{var s,c;A(p+"/workflow/"+((c=(s=O)==null?void 0:s.curWorkflow)==null?void 0:c.cloudID))},children:"Copy link"})]}),e.jsx(Q,{children:"Choose a version to share:"}),e.jsx(he,{gap:4,onChange:s=>{j(s)},value:w,children:e.jsxs(le,{children:[e.jsxs(Y,{mb:5,alignItems:"center",children:[e.jsx(ee,{value:"new_version"},"new_version"),e.jsx(Me,{value:a,width:"60%",onFocus:()=>{j("new_version")},onChange:s=>{t(s.target.value)}}),e.jsx(Ee,{color:"green",children:e.jsx(Q,{children:"New version"})})]}),n.slice(0,4).map(s=>e.jsx(oo,{version:s,cloudHost:p},s.id))]})})]}),e.jsx(Y,{justifyContent:"flex-end",mt:16,children:e.jsx(G,{colorScheme:"teal",onClick:L,isDisabled:u,children:u?"Sharing":"Share"})})]})]})]})}function to(){const o=new Date,a=o.getFullYear(),t=String(o.getMonth()+1).padStart(2,"0"),n=String(o.getDate()).padStart(2,"0");return`${a}-${t}-${n}`}export{po as default}; diff --git a/dist/workspace_web/chunk-JARCRF6W-yaymqCZ5.js b/dist/workspace_web/chunk-JARCRF6W-1wZ_35Xk.js similarity index 82% rename from dist/workspace_web/chunk-JARCRF6W-yaymqCZ5.js rename to dist/workspace_web/chunk-JARCRF6W-1wZ_35Xk.js index 7e0abd2..ffaf41e 100644 --- a/dist/workspace_web/chunk-JARCRF6W-yaymqCZ5.js +++ b/dist/workspace_web/chunk-JARCRF6W-1wZ_35Xk.js @@ -1 +1 @@ -import{f as q,j as f,r as l,x as $,g as P,b as ue,d as W,w as fe,k as i,p as y,m as oe,a3 as J,i as me,o as he,G as ge,h as be}from"./input.js";import{am as ke}from"./App-iJ8dSmpT.js";import{t as ve}from"./index-pz0vT7Or.js";var X=q(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;k();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=b=>{k(),g("loaded"),c==null||c(b)},r.onerror=b=>{k(),g("failed"),s==null||s(b)},u.current=r},[e,d,a,p,c,s,n]),k=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return $(()=>{if(!C)return m==="loading"&&x(),()=>{k()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=q(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:k,...r}=n,b=a!==void 0||c!==void 0,R=m!=null||g||!b,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:k,className:"chakra-image",...j})});xe.displayName="Image";var[$e,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=ke(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:k,isIndeterminate:r,name:b,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(k),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,K]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,U]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||U(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);$(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&K(!1)},[e,K]),$(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{U(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);$(()=>{if(!I.current)return;I.current.checked!==h&&U(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=H=>{F&&H.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var H;(H=I.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:b,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>K(!1)),onFocus:y(t.onFocus,B,()=>K(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[b,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=q(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:k,isDisabled:r=a==null?void 0:a.isDisabled,onChange:b,inputProps:R,..._}=d;let A=k;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=b;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,b));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:be("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=q(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:k,...r}=n,b={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:k};return f.jsx(P.div,{ref:e,__css:b,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; +import{f as q,j as f,r as l,x as $,g as P,b as ue,d as W,w as fe,k as i,p as y,m as oe,a3 as J,i as me,o as he,G as ge,h as ke}from"./input.js";import{ak as be}from"./App-09wdM9e8.js";import{t as ve}from"./index-pz0vT7Or.js";var X=q(function(n,e){const{htmlWidth:a,htmlHeight:c,alt:s,...d}=n;return f.jsx("img",{width:a,height:c,ref:e,alt:s,...d})});X.displayName="NativeImage";function pe(o){const{loading:n,src:e,srcSet:a,onLoad:c,onError:s,crossOrigin:d,sizes:p,ignoreFallback:C}=o,[m,g]=l.useState("pending");l.useEffect(()=>{g(e?"loading":"pending")},[e]);const u=l.useRef(),x=l.useCallback(()=>{if(!e)return;b();const r=new Image;r.src=e,d&&(r.crossOrigin=d),a&&(r.srcset=a),p&&(r.sizes=p),n&&(r.loading=n),r.onload=k=>{b(),g("loaded"),c==null||c(k)},r.onerror=k=>{b(),g("failed"),s==null||s(k)},u.current=r},[e,d,a,p,c,s,n]),b=()=>{u.current&&(u.current.onload=null,u.current.onerror=null,u.current=null)};return $(()=>{if(!C)return m==="loading"&&x(),()=>{b()}},[m,x,C]),C?"loaded":m}var Ce=(o,n)=>o!=="loaded"&&n==="beforeLoadOrError"||o==="failed"&&n==="onError";function ye(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}var xe=q(function(n,e){const{fallbackSrc:a,fallback:c,src:s,srcSet:d,align:p,fit:C,loading:m,ignoreFallback:g,crossOrigin:u,fallbackStrategy:x="beforeLoadOrError",referrerPolicy:b,...r}=n,k=a!==void 0||c!==void 0,R=m!=null||g||!k,_=pe({...n,crossOrigin:u,ignoreFallback:R}),A=Ce(_,x),j={ref:e,objectFit:C,objectPosition:p,...R?r:ye(r,["onError","onLoad"])};return A?c||f.jsx(P.img,{as:X,className:"chakra-image__placeholder",src:a,...j}):f.jsx(P.img,{as:X,src:s,srcSet:d,crossOrigin:u,loading:m,referrerPolicy:b,className:"chakra-image",...j})});xe.displayName="Image";var[$e,Ie]=ue({name:"CheckboxGroupContext",strict:!1});function Se(o){const[n,e]=l.useState(o),[a,c]=l.useState(!1);return o!==n&&(c(!0),e(o)),a}function we(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:f.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function Pe(o){return f.jsx(P.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:f.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function je(o){const{isIndeterminate:n,isChecked:e,...a}=o,c=n?Pe:we;return e||n?f.jsx(P.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:f.jsx(c,{...a})}):null}var Fe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function Re(o,n=[]){const e=Object.assign({},o);for(const a of n)a in e&&delete e[a];return e}function Ae(o={}){const n=be(o),{isDisabled:e,isReadOnly:a,isRequired:c,isInvalid:s,id:d,onBlur:p,onFocus:C,"aria-describedby":m}=n,{defaultChecked:g,isChecked:u,isFocusable:x,onChange:b,isIndeterminate:r,name:k,value:R,tabIndex:_=void 0,"aria-label":A,"aria-labelledby":j,"aria-invalid":w,...z}=o,L=Re(z,["isDisabled","isReadOnly","isRequired","isInvalid","id","onBlur","onFocus","aria-describedby"]),N=W(b),O=W(p),B=W(C),[D,T]=l.useState(!1),[F,K]=l.useState(!1),[G,Q]=l.useState(!1),[M,E]=l.useState(!1);l.useEffect(()=>ve(T),[]);const I=l.useRef(null),[Y,ne]=l.useState(!0),[se,U]=l.useState(!!g),V=u!==void 0,h=V?u:se,Z=l.useCallback(t=>{if(a||e){t.preventDefault();return}V||U(h?t.target.checked:r?!0:t.target.checked),N==null||N(t)},[a,e,h,V,r,N]);$(()=>{I.current&&(I.current.indeterminate=!!r)},[r]),fe(()=>{e&&K(!1)},[e,K]),$(()=>{const t=I.current;if(!(t!=null&&t.form))return;const v=()=>{U(!!g)};return t.form.addEventListener("reset",v),()=>{var S;return(S=t.form)==null?void 0:S.removeEventListener("reset",v)}},[]);const ee=e&&!x,ae=l.useCallback(t=>{t.key===" "&&E(!0)},[E]),te=l.useCallback(t=>{t.key===" "&&E(!1)},[E]);$(()=>{if(!I.current)return;I.current.checked!==h&&U(I.current.checked)},[I.current]);const re=l.useCallback((t={},v=null)=>{const S=H=>{F&&H.preventDefault(),E(!0)};return{...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a),"aria-hidden":!0,onMouseDown:y(t.onMouseDown,S),onMouseUp:y(t.onMouseUp,()=>E(!1)),onMouseEnter:y(t.onMouseEnter,()=>Q(!0)),onMouseLeave:y(t.onMouseLeave,()=>Q(!1))}},[M,h,e,F,D,G,r,s,a]),ie=l.useCallback((t={},v=null)=>({...t,ref:v,"data-active":i(M),"data-hover":i(G),"data-checked":i(h),"data-focus":i(F),"data-focus-visible":i(F&&D),"data-indeterminate":i(r),"data-disabled":i(e),"data-invalid":i(s),"data-readonly":i(a)}),[M,h,e,F,D,G,r,s,a]),le=l.useCallback((t={},v=null)=>({...L,...t,ref:oe(v,S=>{S&&ne(S.tagName==="LABEL")}),onClick:y(t.onClick,()=>{var S;Y||((S=I.current)==null||S.click(),requestAnimationFrame(()=>{var H;(H=I.current)==null||H.focus({preventScroll:!0})}))}),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[L,e,h,s,Y]),ce=l.useCallback((t={},v=null)=>({...t,ref:oe(I,v),type:"checkbox",name:k,value:R,id:d,tabIndex:_,onChange:y(t.onChange,Z),onBlur:y(t.onBlur,O,()=>K(!1)),onFocus:y(t.onFocus,B,()=>K(!0)),onKeyDown:y(t.onKeyDown,ae),onKeyUp:y(t.onKeyUp,te),required:c,checked:h,disabled:ee,readOnly:a,"aria-label":A,"aria-labelledby":j,"aria-invalid":w?!!w:s,"aria-describedby":m,"aria-disabled":e,style:Fe}),[k,R,d,Z,O,B,ae,te,c,h,ee,a,A,j,w,s,m,e,_]),de=l.useCallback((t={},v=null)=>({...t,ref:v,onMouseDown:y(t.onMouseDown,_e),"data-disabled":i(e),"data-checked":i(h),"data-invalid":i(s)}),[h,e,s]);return{state:{isInvalid:s,isFocused:F,isChecked:h,isActive:M,isHovered:G,isIndeterminate:r,isDisabled:e,isReadOnly:a,isRequired:c},getRootProps:le,getCheckboxProps:re,getIndicatorProps:ie,getInputProps:ce,getLabelProps:de,htmlProps:L}}function _e(o){o.preventDefault(),o.stopPropagation()}var De={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},Ee={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},Le=J({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),Ne=J({from:{opacity:0},to:{opacity:1}}),Be=J({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Ge=q(function(n,e){const a=Ie(),c={...a,...n},s=me("Checkbox",c),d=he(n),{spacing:p="0.5rem",className:C,children:m,iconColor:g,iconSize:u,icon:x=f.jsx(je,{}),isChecked:b,isDisabled:r=a==null?void 0:a.isDisabled,onChange:k,inputProps:R,..._}=d;let A=b;a!=null&&a.value&&d.value&&(A=a.value.includes(d.value));let j=k;a!=null&&a.onChange&&d.value&&(j=ge(a.onChange,k));const{state:w,getInputProps:z,getCheckboxProps:L,getLabelProps:N,getRootProps:O}=Ae({..._,isDisabled:r,isChecked:A,onChange:j}),B=Se(w.isChecked),D=l.useMemo(()=>({animation:B?w.isIndeterminate?`${Ne} 20ms linear, ${Be} 200ms linear`:`${Le} 200ms linear`:void 0,fontSize:u,color:g,...s.icon}),[g,u,B,w.isIndeterminate,s.icon]),T=l.cloneElement(x,{__css:D,isIndeterminate:w.isIndeterminate,isChecked:w.isChecked});return f.jsxs(P.label,{__css:{...Ee,...s.container},className:ke("chakra-checkbox",C),...O(),children:[f.jsx("input",{className:"chakra-checkbox__input",...z(R,e)}),f.jsx(P.span,{__css:{...De,...s.control},className:"chakra-checkbox__control",...L(),children:T}),m&&f.jsx(P.span,{className:"chakra-checkbox__label",...N(),__css:{marginStart:p,...s.label},children:m})]})});Ge.displayName="Checkbox";var Me=q(function(n,e){const{templateAreas:a,gap:c,rowGap:s,columnGap:d,column:p,row:C,autoFlow:m,autoRows:g,templateRows:u,autoColumns:x,templateColumns:b,...r}=n,k={display:"grid",gridTemplateAreas:a,gridGap:c,gridRowGap:s,gridColumnGap:d,gridAutoColumns:x,gridColumn:p,gridRow:C,gridAutoFlow:m,gridAutoRows:g,gridTemplateRows:u,gridTemplateColumns:b};return f.jsx(P.div,{ref:e,__css:k,...r})});Me.displayName="Grid";export{Ge as C,Me as G,xe as I}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-7NPzADNj.js b/dist/workspace_web/chunk-NTCQBYKE-NnaP5ESt.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-7NPzADNj.js rename to dist/workspace_web/chunk-NTCQBYKE-NnaP5ESt.js index 63cf182..02a4b9a 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-7NPzADNj.js +++ b/dist/workspace_web/chunk-NTCQBYKE-NnaP5ESt.js @@ -1 +1 @@ -import{j as t}from"./App-iJ8dSmpT.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; +import{j as t}from"./App-09wdM9e8.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index fdb8217..a8da281 100644 --- a/dist/workspace_web/input.js +++ b/dist/workspace_web/input.js @@ -679,10 +679,10 @@ Error generating stack: `+i.message+` } ${fB} - `}),Lw=document.createElement("div");document.body.append(Lw);const pB=Ar.lazy(()=>Jk(()=>import("./App-iJ8dSmpT.js").then(e=>e.aw),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),mB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},vB=Mz({zIndices:mB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(HI,{resetCSS:!1,disableGlobalStyle:!0,theme:vB,children:[E.jsx(hB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(dB,{children:E.jsx(S.Suspense,{children:E.jsx(pB,{})})})]})}));const Yf=document.body,gB={attributes:!0,attributeFilter:["class"]},yB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},bB=new MutationObserver(yB);bB.observe(Yf,gB);export{rL as $,IB as A,Ix as B,FB as C,zP as D,lr as E,ii as F,CB as G,Ip as H,Xa as I,PB as J,Ya as K,Mw as L,ww as M,$w as N,Rw as O,Na as P,Fw as Q,zw as R,Aw as S,Pb as T,LB as U,Ar as V,$B as W,Du as X,is as Y,vL as Z,Jk as _,MB as a,mL as a0,Wf as a1,Ra as a2,wP as a3,SB as a4,Hn as a5,Uh as a6,xP as a7,zp as a8,xB as a9,wB as aa,_B as ab,lB as ac,uB as ad,mn as b,RB as c,d3 as d,EB as e,pt as f,_e as g,Be as h,eS as i,E as j,Rv as k,Nu as l,Bf as m,kB as n,Ou as o,$i as p,Xf as q,S as r,hw as s,TB as t,VP as u,Kt as v,Cg as w,ka as x,mO as y,DB as z}; + `}),Lw=document.createElement("div");document.body.append(Lw);const pB=Ar.lazy(()=>Jk(()=>import("./App-09wdM9e8.js").then(e=>e.ao),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),mB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},vB=Mz({zIndices:mB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(HI,{resetCSS:!1,disableGlobalStyle:!0,theme:vB,children:[E.jsx(hB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(dB,{children:E.jsx(S.Suspense,{children:E.jsx(pB,{})})})]})}));const Yf=document.body,gB={attributes:!0,attributeFilter:["class"]},yB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},bB=new MutationObserver(yB);bB.observe(Yf,gB);export{rL as $,IB as A,Ix as B,FB as C,zP as D,lr as E,ii as F,CB as G,Ip as H,Xa as I,PB as J,Ya as K,Mw as L,ww as M,$w as N,Rw as O,Na as P,Fw as Q,zw as R,Aw as S,Pb as T,LB as U,Ar as V,$B as W,Du as X,is as Y,vL as Z,Jk as _,MB as a,mL as a0,Wf as a1,Ra as a2,wP as a3,SB as a4,Hn as a5,Uh as a6,xP as a7,zp as a8,xB as a9,wB as aa,_B as ab,lB as ac,uB as ad,mn as b,RB as c,d3 as d,EB as e,pt as f,_e as g,Be as h,eS as i,E as j,Rv as k,Nu as l,Bf as m,kB as n,Ou as o,$i as p,Xf as q,S as r,hw as s,TB as t,VP as u,Kt as v,Cg as w,ka as x,mO as y,DB as z}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/App-iJ8dSmpT.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-09wdM9e8.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/service/media_service.py b/service/media_service.py new file mode 100644 index 0000000..d0c96cf --- /dev/null +++ b/service/media_service.py @@ -0,0 +1,57 @@ + +import server +from aiohttp import web +import folder_paths +import os +from .model_manager.model_preview import get_thumbnail_for_image_file + +image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'] +video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv'] + +async def view_media(filename, isPreview = False): + if not filename: + return web.Response(status=404) + + # validation for security: prevent accessing arbitrary path + if filename[0] == '/' or '..' in filename: + return web.Response(status=400) + + output_path = folder_paths.get_output_directory() + file_path = os.path.join(output_path, filename) + + if not os.path.exists(file_path): + return web.Response(status=404) + + file_extension = os.path.splitext(filename)[1].lower() + if isPreview and file_extension in image_extensions: + return web.json_response( + body=get_thumbnail_for_image_file(file_path), + content_type='image/jpeg', + headers={"Content-Disposition": f"filename=\"{filename}.jpg\""} + ) + + with open(file_path, 'rb') as f: + media_file = f.read() + + content_type = 'application/json' + + if file_extension in image_extensions: + content_type = f'image/{file_extension[1:]}' + if file_extension in video_extensions: + content_type = f'video/{file_extension[1:]}' + + return web.Response( + body=media_file, + content_type=content_type, + headers={"Content-Disposition": f"filename=\"{filename}\""} + ) + +@server.PromptServer.instance.routes.get("/workspace/preview_media") +async def preview_file(request): + filename = request.query.get("filename", None) + return await view_media(filename, True) + +@server.PromptServer.instance.routes.get("/workspace/view_media") +async def view_file(request): + filename = request.query.get("filename", None) + return await view_media(filename, False) \ No newline at end of file diff --git a/ui/src/RecentFilesDrawer/WorkflowListItem.tsx b/ui/src/RecentFilesDrawer/WorkflowListItem.tsx index 6436a5a..983a6cc 100644 --- a/ui/src/RecentFilesDrawer/WorkflowListItem.tsx +++ b/ui/src/RecentFilesDrawer/WorkflowListItem.tsx @@ -77,6 +77,7 @@ export default memo(function WorkflowListItem({ workflow }: Props) { mediaLocalPath={workflow.coverMediaPath} size={60} hideBrokenImage + isPreview /> )} diff --git a/ui/src/components/DropdownTitle.tsx b/ui/src/components/DropdownTitle.tsx index 166645b..4b693ef 100644 --- a/ui/src/components/DropdownTitle.tsx +++ b/ui/src/components/DropdownTitle.tsx @@ -183,13 +183,13 @@ export default function DropdownTitle() { > Versions History - setIsShareOpen(true)} icon={} iconSpacing={1} > Share - + */} } diff --git a/ui/src/components/MediaPreview.tsx b/ui/src/components/MediaPreview.tsx index 5981638..fd686b4 100644 --- a/ui/src/components/MediaPreview.tsx +++ b/ui/src/components/MediaPreview.tsx @@ -8,10 +8,12 @@ type Props = { autoPlay?: boolean; onBrokenLink?: () => void; hideBrokenImage?: boolean; + isPreview?: boolean; }; export default function MediaPreview({ mediaLocalPath, size, + isPreview, autoPlay, hideBrokenImage, onBrokenLink, @@ -22,7 +24,9 @@ export default function MediaPreview({ const checkMediaExists = async () => { try { const response = await fetch( - `/workspace/view_media?filename=${mediaLocalPath}`, + isPreview + ? `/workspace/preview_media?filename=${mediaLocalPath}` + : `/workspace/view_media?filename=${mediaLocalPath}`, ); if (!response.ok) throw new Error("Media not found"); setIsVisible(true); diff --git a/ui/src/gallery/GalleryModal.tsx b/ui/src/gallery/GalleryModal.tsx index 03d2a97..00cffb3 100644 --- a/ui/src/gallery/GalleryModal.tsx +++ b/ui/src/gallery/GalleryModal.tsx @@ -17,7 +17,7 @@ import { IconArrowLeft, IconX } from "@tabler/icons-react"; import { WorkspaceContext } from "../WorkspaceContext"; import { Media } from "../types/dbTypes"; import { MetaDataInfo } from "./components/MetaDataInfo.tsx"; -import MediaPreview from "./components/GalleryMediaItem.tsx"; +import GalleryMediaItem from "./components/GalleryMediaItem.tsx"; export default function GalleryModal({ onclose }: { onclose: () => void }) { const { curFlowID } = useContext(WorkspaceContext); @@ -123,7 +123,7 @@ export default function GalleryModal({ onclose }: { onclose: () => void }) { {images.map((media) => { return ( - void; } -const GalleryMediaItem: React.FC = ({ +const GalleryMediaItem: React.FC = ({ media, isSelecting, selectedID, @@ -68,6 +68,7 @@ const GalleryMediaItem: React.FC = ({ // setIsVisible(false); }} autoPlay={true} + isPreview /> ); diff --git a/ui/src/topbar/Topbar.tsx b/ui/src/topbar/Topbar.tsx index 1cf440e..e3f8604 100644 --- a/ui/src/topbar/Topbar.tsx +++ b/ui/src/topbar/Topbar.tsx @@ -104,7 +104,7 @@ export function Topbar({ )} - + {/* */} {curFlowID && isDirty ? (