From 8dff03932afaca8a30dea47bbf5fce5a8b176262 Mon Sep 17 00:00:00 2001 From: Weixuan Fu Date: Fri, 1 Mar 2024 21:32:08 +0800 Subject: [PATCH] fix some styling --- dist/workspace_web/App-Fl7cObcs.js | 182 ------------------ dist/workspace_web/App-GluzE5n7.js | 182 ++++++++++++++++++ ...l-yOnENaqH.js => GalleryModal-GhVpJqWk.js} | 2 +- ...=> InstallMissingModelsButton-KOf9hKlm.js} | 2 +- ...w-Z5nSvSr_.js => MediaPreview-EfKQfEU-.js} | 2 +- .../ModelManagerTopbar-K_yJKYUe.js | 7 - .../ModelManagerTopbar-rP-1MCD8.js | 7 + ...jZV5O.js => RecentFilesDrawer-B74sdP_1.js} | 8 +- dist/workspace_web/ShareDialog-17qMdssr.js | 1 + dist/workspace_web/ShareDialog-yZ9MQqaN.js | 1 - ...aHchqwnR.js => chunk-JARCRF6W-IwBcFM3i.js} | 2 +- ...EEXlKSMU.js => chunk-NTCQBYKE-ZsMy4OBB.js} | 2 +- dist/workspace_web/chunk-RPO2WXNL-dt-e86vT.js | 1 - dist/workspace_web/input.js | 4 +- ui/src/apis/TwowaySyncApi.ts | 1 - ui/src/components/DropdownTitle.tsx | 11 +- ui/src/settings/TwoWaySyncSettings.tsx | 2 +- 17 files changed, 210 insertions(+), 207 deletions(-) delete mode 100644 dist/workspace_web/App-Fl7cObcs.js create mode 100644 dist/workspace_web/App-GluzE5n7.js rename dist/workspace_web/{GalleryModal-yOnENaqH.js => GalleryModal-GhVpJqWk.js} (75%) rename dist/workspace_web/{InstallMissingModelsButton-L5lG4CMZ.js => InstallMissingModelsButton-KOf9hKlm.js} (61%) rename dist/workspace_web/{MediaPreview-Z5nSvSr_.js => MediaPreview-EfKQfEU-.js} (95%) delete mode 100644 dist/workspace_web/ModelManagerTopbar-K_yJKYUe.js create mode 100644 dist/workspace_web/ModelManagerTopbar-rP-1MCD8.js rename dist/workspace_web/{RecentFilesDrawer-pKqjZV5O.js => RecentFilesDrawer-B74sdP_1.js} (92%) create mode 100644 dist/workspace_web/ShareDialog-17qMdssr.js delete mode 100644 dist/workspace_web/ShareDialog-yZ9MQqaN.js rename dist/workspace_web/{chunk-JARCRF6W-aHchqwnR.js => chunk-JARCRF6W-IwBcFM3i.js} (99%) rename dist/workspace_web/{chunk-NTCQBYKE-EEXlKSMU.js => chunk-NTCQBYKE-ZsMy4OBB.js} (65%) delete mode 100644 dist/workspace_web/chunk-RPO2WXNL-dt-e86vT.js diff --git a/dist/workspace_web/App-Fl7cObcs.js b/dist/workspace_web/App-Fl7cObcs.js deleted file mode 100644 index 8dd6593..0000000 --- a/dist/workspace_web/App-Fl7cObcs.js +++ /dev/null @@ -1,182 +0,0 @@ -var el=Object.defineProperty;var tl=(t,e,n)=>e in t?el(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ke=(t,e,n)=>(tl(t,typeof e!="symbol"?e+"":e,n),n);import{u as nl,a as rl,r as b,c as ol,b as rt,m as Ae,d as Mt,f as oe,j as v,B as Ke,e as al,g as Z,h as pe,o as Qe,i as Vt,k as ot,I as sl,l as Wn,n as Gr,p as xe,q as vs,s as il,t as ll,v as cl,w as Mr,x as ul,y as dl,z as fl,A as pl,C as hl,D as ea,E as ys,F as ta,G as gs,H as ml,J as vl,K as yl,P as ws,M as Rr,L as na,N as Tr,O as ra,Q as oa,R as aa,S as sa,_ as Lr,T as gl,U as bs,V as ia}from"./input.js";import{app as ge}from"/scripts/app.js";import{api as Ma}from"/scripts/api.js";function wl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function xs(t){var e;return wl(t)&&(e=t.ownerDocument)!=null?e:document}function bl(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var xl=bl();function kl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function ks(t){const{theme:e}=nl(),n=rl();return b.useMemo(()=>ol(e.direction,{...n,...t}),[t,e.direction,n])}var _l=Object.defineProperty,El=(t,e,n)=>e in t?_l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(El(t,typeof e!="symbol"?e+"":e,n),n);function Ra(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 Cl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Ta(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function La(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var fo=typeof window<"u"?b.useLayoutEffect:b.useEffect,vr=t=>t,Sl=class{constructor(){_e(this,"descendants",new Map),_e(this,"register",t=>{if(t!=null)return Cl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),_e(this,"unregister",t=>{this.descendants.delete(t);const e=Ra(Array.from(this.descendants.keys()));this.assignIndex(e)}),_e(this,"destroy",()=>{this.descendants.clear()}),_e(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),_e(this,"count",()=>this.descendants.size),_e(this,"enabledCount",()=>this.enabledValues().length),_e(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),_e(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),_e(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),_e(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),_e(this,"first",()=>this.item(0)),_e(this,"firstEnabled",()=>this.enabledItem(0)),_e(this,"last",()=>this.item(this.descendants.size-1)),_e(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),_e(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),_e(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),_e(this,"next",(t,e=!0)=>{const n=Ta(t,this.count(),e);return this.item(n)}),_e(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Ta(r,this.enabledCount(),e);return this.enabledItem(o)}),_e(this,"prev",(t,e=!0)=>{const n=La(t,this.count()-1,e);return this.item(n)}),_e(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=La(r,this.enabledCount()-1,e);return this.enabledItem(o)}),_e(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Ra(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 Dl(){const t=b.useRef(new Sl);return fo(()=>()=>t.current.destroy()),t.current}var[jl,_s]=rt({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Ol(t){const e=_s(),[n,r]=b.useState(-1),o=b.useRef(null);fo(()=>()=>{o.current&&e.unregister(o.current)},[]),fo(()=>{if(!o.current)return;const s=Number(o.current.dataset.index);n!=s&&!Number.isNaN(s)&&r(s)});const a=vr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Ae(a,o)}}function Es(){return[vr(jl),()=>vr(_s()),()=>Dl(),o=>Ol(o)]}function Cs(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(f,p)=>f!==p}=t,a=Mt(r),s=Mt(o),[i,l]=b.useState(n),c=e!==void 0,u=c?e:i,d=Mt(f=>{const m=typeof f=="function"?f(u):f;s(u,m)&&(c||l(m),a(m))},[c,a,u,s]);return[u,d]}function la(t){return b.Children.toArray(t).filter(e=>b.isValidElement(e))}var on=oe((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":a,...s}=t,i=n||r,l=b.isValidElement(i)?b.cloneElement(i,{"aria-hidden":!0,focusable:!1}):null;return v.jsx(Ke,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":a,...s,children:l})});on.displayName="IconButton";var[Il,Ss]=al("Card"),Pl=oe(function(e,n){const{className:r,...o}=e,a=Ss();return v.jsx(Z.div,{ref:n,className:pe("chakra-card__body",r),__css:a.body,...o})}),Nl=oe(function(e,n){const{className:r,...o}=e,a=Ss();return v.jsx(Z.div,{ref:n,className:pe("chakra-card__header",r),__css:a.header,...o})}),Fl=oe(function(e,n){const{className:r,children:o,direction:a="column",justify:s,align:i,...l}=Qe(e),c=Vt("Card",e);return v.jsx(Z.div,{ref:n,className:pe("chakra-card",r),__css:{display:"flex",flexDirection:a,justifyContent:s,alignItems:i,position:"relative",minWidth:0,wordWrap:"break-word",...c.container},...l,children:v.jsx(Il,{value:c,children:o})})}),[Al,Ds]=rt({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Ml,dn]=rt({strict:!1,name:"FormControlContext"});function Rl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:a,...s}=t,i=b.useId(),l=e||`field-${i}`,c=`${l}-label`,u=`${l}-feedback`,d=`${l}-helptext`,[f,p]=b.useState(!1),[m,h]=b.useState(!1),[y,w]=b.useState(!1),g=b.useCallback((k={},j=null)=>({id:d,...k,ref:Ae(j,D=>{D&&h(!0)})}),[d]),x=b.useCallback((k={},j=null)=>({...k,ref:j,"data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(a),id:k.id!==void 0?k.id:c,htmlFor:k.htmlFor!==void 0?k.htmlFor:l}),[l,o,y,r,a,c]),E=b.useCallback((k={},j=null)=>({id:u,...k,ref:Ae(j,D=>{D&&p(!0)}),"aria-live":"polite"}),[u]),S=b.useCallback((k={},j=null)=>({...k,...s,ref:j,role:"group","data-focus":ot(y),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(a)}),[s,o,y,r,a]),C=b.useCallback((k={},j=null)=>({...k,ref:j,role:"presentation","aria-hidden":!0,children:k.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!a,isDisabled:!!o,isFocused:!!y,onFocus:()=>w(!0),onBlur:()=>w(!1),hasFeedbackText:f,setHasFeedbackText:p,hasHelpText:m,setHasHelpText:h,id:l,labelId:c,feedbackId:u,helpTextId:d,htmlProps:s,getHelpTextProps:g,getErrorMessageProps:E,getRootProps:S,getLabelProps:x,getRequiredIndicatorProps:C}}var Wr=oe(function(e,n){const r=Vt("Form",e),o=Qe(e),{getRootProps:a,htmlProps:s,...i}=Rl(o),l=pe("chakra-form-control",e.className);return v.jsx(Ml,{value:i,children:v.jsx(Al,{value:r,children:v.jsx(Z.div,{...a({},n),className:l,__css:r.container})})})});Wr.displayName="FormControl";var Tl=oe(function(e,n){const r=dn(),o=Ds(),a=pe("chakra-form__helper-text",e.className);return v.jsx(Z.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:a})});Tl.displayName="FormHelperText";var[Ll,Wl]=rt({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),Br=oe((t,e)=>{const n=Vt("FormError",t),r=Qe(t),o=dn();return o!=null&&o.isInvalid?v.jsx(Ll,{value:n,children:v.jsx(Z.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:pe("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});Br.displayName="FormErrorMessage";var Bl=oe((t,e)=>{const n=Wl(),r=dn();if(!(r!=null&&r.isInvalid))return null;const o=pe("chakra-form__error-icon",t.className);return v.jsx(sl,{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"})})});Bl.displayName="FormErrorIcon";var $r=oe(function(e,n){var r;const o=Wn("FormLabel",e),a=Qe(e),{className:s,children:i,requiredIndicator:l=v.jsx(js,{}),optionalIndicator:c=null,...u}=a,d=dn(),f=(r=d==null?void 0:d.getLabelProps(u,n))!=null?r:{ref:n,...u};return v.jsxs(Z.label,{...f,className:pe("chakra-form__label",a.className),__css:{display:"block",textAlign:"start",...o},children:[i,d!=null&&d.isRequired?l:c]})});$r.displayName="FormLabel";var js=oe(function(e,n){const r=dn(),o=Ds();if(!(r!=null&&r.isRequired))return null;const a=pe("chakra-form__required-indicator",e.className);return v.jsx(Z.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:a})});js.displayName="RequiredIndicator";function $l(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...a}=Kl(t);return{...a,disabled:e,readOnly:r,required:o,"aria-invalid":Gr(n),"aria-required":Gr(o),"aria-readonly":Gr(r)}}function Kl(t){var e,n,r;const o=dn(),{id:a,disabled:s,readOnly:i,required:l,isRequired:c,isInvalid:u,isReadOnly:d,isDisabled:f,onFocus:p,onBlur:m,...h}=t,y=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&y.push(o.feedbackId),o!=null&&o.hasHelpText&&y.push(o.helpTextId),{...h,"aria-describedby":y.join(" ")||void 0,id:a??(o==null?void 0:o.id),isDisabled:(e=s??f)!=null?e:o==null?void 0:o.isDisabled,isReadOnly:(n=i??d)!=null?n:o==null?void 0:o.isReadOnly,isRequired:(r=l??c)!=null?r:o==null?void 0:o.isRequired,isInvalid:u??(o==null?void 0:o.isInvalid),onFocus:xe(o==null?void 0:o.onFocus,p),onBlur:xe(o==null?void 0:o.onBlur,m)}}function en(t,e,n,r){const o=Mt(n);return b.useEffect(()=>{const a=typeof t=="function"?t():t??document;if(!(!n||!a))return a.addEventListener(e,o,r),()=>{a.removeEventListener(e,o,r)}},[e,t,r,o,n]),()=>{const a=typeof t=="function"?t():t??document;a==null||a.removeEventListener(e,o,r)}}function Ul(t){return"current"in t}var Os=()=>typeof window<"u";function zl(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var ql=t=>Os()&&t.test(navigator.vendor),Vl=t=>Os()&&t.test(zl()),Hl=()=>Vl(/mac|iphone|ipad|ipod/i),Jl=()=>Hl()&&ql(/apple/i);function Gl(t){const{ref:e,elements:n,enabled:r}=t,o=()=>{var a,s;return(s=(a=e.current)==null?void 0:a.ownerDocument)!=null?s:document};en(o,"pointerdown",a=>{if(!Jl()||!r)return;const s=a.target,l=(n??[e]).some(c=>{const u=Ul(c)?c.current:c;return(u==null?void 0:u.contains(s))||u===s});o().activeElement!==s&&l&&(a.preventDefault(),s.focus())})}var Is={exports:{}},Yl="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Xl=Yl,Zl=Xl;function Ps(){}function Ns(){}Ns.resetWarningCache=Ps;var Ql=function(){function t(r,o,a,s,i,l){if(l!==Zl){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Ns,resetWarningCache:Ps};return n.PropTypes=n,n};Is.exports=Ql();var ec=Is.exports;const It=vs(ec);function tc(t){const e=t.ownerDocument.defaultView||window,{overflow:n,overflowX:r,overflowY:o}=e.getComputedStyle(t);return/auto|scroll|overlay|hidden/.test(n+o+r)}function nc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function Fs(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:il(t)&&tc(t)?t:Fs(nc(t))}var rc=xl?b.useLayoutEffect:b.useEffect;function po(t,e=[]){const n=b.useRef(t);return rc(()=>{n.current=t}),b.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function oc(t){const{ref:e,handler:n,enabled:r=!0}=t,o=po(n),s=b.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;b.useEffect(()=>{if(!r)return;const i=d=>{Yr(d,e)&&(s.isPointerDown=!0)},l=d=>{if(s.ignoreEmulatedMouseEvents){s.ignoreEmulatedMouseEvents=!1;return}s.isPointerDown&&n&&Yr(d,e)&&(s.isPointerDown=!1,o(d))},c=d=>{s.ignoreEmulatedMouseEvents=!0,n&&s.isPointerDown&&Yr(d,e)&&(s.isPointerDown=!1,o(d))},u=xs(e.current);return u.addEventListener("mousedown",i,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",i,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",i,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",i,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,s,r])}function Yr(t,e){var n;const r=t.target;return r&&!xs(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function ac(t,e){const n=b.useId();return b.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function sc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function ic(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,a=po(n),s=po(e),[i,l]=b.useState(t.defaultIsOpen||!1),[c,u]=sc(r,i),d=ac(o,"disclosure"),f=b.useCallback(()=>{c||l(!1),s==null||s()},[c,s]),p=b.useCallback(()=>{c||l(!0),a==null||a()},[c,a]),m=b.useCallback(()=>{(u?f:p)()},[u,p,f]);return{isOpen:!!u,onOpen:p,onClose:f,onToggle:m,isControlled:c,getButtonProps:(h={})=>({...h,"aria-expanded":u,"aria-controls":d,onClick:ll(h.onClick,m)}),getDisclosureProps:(h={})=>({...h,hidden:!u,id:d})}}var Bn=oe(function(e,n){const{htmlSize:r,...o}=e,a=Vt("Input",o),s=Qe(o),i=$l(s),l=pe("chakra-input",e.className);return v.jsx(Z.input,{size:r,...i,__css:a.field,ref:n,className:l})});Bn.displayName="Input";Bn.id="Input";var As=oe(function(e,n){const r=Wn("Link",e),{className:o,isExternal:a,...s}=Qe(e);return v.jsx(Z.a,{target:a?"_blank":void 0,rel:a?"noopener":void 0,ref:n,className:pe("chakra-link",o),...s,__css:r})});As.displayName="Link";var lc=Object.freeze(["base","sm","md","lg","xl","2xl"]);function cc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):cl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function Jp(t,e=lc){const n={};return t.forEach((r,o)=>{const a=e[o];r!=null&&(n[a]=r)}),n}var Rt=oe(function(e,n){const r=Wn("Text",e),{className:o,align:a,decoration:s,casing:i,...l}=Qe(e),c=kl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return v.jsx(Z.p,{ref:n,className:pe("chakra-text",e.className),...c,...l,__css:r})});Rt.displayName="Text";var ho=t=>v.jsx(Z.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});ho.displayName="StackDivider";var Ms=t=>v.jsx(Z.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ms.displayName="StackItem";function uc(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{"&":cc(n,o=>r[o])}}var xn=oe((t,e)=>{const{isInline:n,direction:r,align:o,justify:a,spacing:s="0.5rem",wrap:i,children:l,divider:c,className:u,shouldWrapChildren:d,...f}=t,p=n?"row":r??"column",m=b.useMemo(()=>uc({spacing:s,direction:p}),[s,p]),h=!!c,y=!d&&!h,w=b.useMemo(()=>{const x=la(l);return y?x:x.map((E,S)=>{const C=typeof E.key<"u"?E.key:S,k=S+1===x.length,D=d?v.jsx(Ms,{children:E},C):E;if(!h)return D;const F=b.cloneElement(c,{__css:m}),A=k?null:F;return v.jsxs(b.Fragment,{children:[D,A]},C)})},[c,m,h,y,d,l]),g=pe("chakra-stack",u);return v.jsx(Z.div,{ref:e,display:"flex",alignItems:o,justifyContent:a,flexDirection:p,flexWrap:i,gap:h?void 0:s,className:g,...f,children:w})});xn.displayName="Stack";var Ft=oe((t,e)=>v.jsx(xn,{align:"center",...t,direction:"row",ref:e}));Ft.displayName="HStack";var Rs=oe(function(e,n){const r=Wn("Heading",e),{className:o,...a}=Qe(e);return v.jsx(Z.h2,{ref:n,className:pe("chakra-heading",e.className),...a,__css:r})});Rs.displayName="Heading";var ht=Z("div");ht.displayName="Box";var Ts=oe(function(e,n){const{size:r,centerContent:o=!0,...a}=e,s=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return v.jsx(ht,{ref:n,boxSize:r,__css:{...s,flexShrink:0,flexGrow:0},...a})});Ts.displayName="Square";var dc=oe(function(e,n){const{size:r,...o}=e;return v.jsx(Ts,{size:r,ref:n,borderRadius:"9999px",...o})});dc.displayName="Circle";var rr=oe(function(e,n){const{direction:r,align:o,justify:a,wrap:s,basis:i,grow:l,shrink:c,...u}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:a,flexWrap:s,flexBasis:i,flexGrow:l,flexShrink:c};return v.jsx(Z.div,{ref:n,__css:d,...u})});rr.displayName="Flex";function fc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function pc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=b.useState([]),a=b.useRef(),s=()=>{a.current&&(clearTimeout(a.current),a.current=null)},i=()=>{s(),a.current=setTimeout(()=>{o([]),a.current=null},e)};b.useEffect(()=>s,[]);function l(c){return u=>{if(u.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(fc(u)){const d=r.concat(u.key);n(u)&&(u.preventDefault(),u.stopPropagation()),o(d),c(d.join("")),i()}}}return l}function hc(t,e,n,r){if(e==null)return r;if(!r)return t.find(s=>n(s).toLowerCase().startsWith(e.toLowerCase()));const o=t.filter(a=>n(a).toLowerCase().startsWith(e.toLowerCase()));if(o.length>0){let a;return o.includes(r)?(a=o.indexOf(r)+1,a===o.length&&(a=0),o[a]):(a=t.indexOf(o[0]),t[a])}return r}function mc(){const t=b.useRef(new Map),e=t.current,n=b.useCallback((o,a,s,i)=>{t.current.set(s,{type:a,el:o,options:i}),o.addEventListener(a,s,i)},[]),r=b.useCallback((o,a,s,i)=>{o.removeEventListener(a,s,i),t.current.delete(s)},[]);return b.useEffect(()=>()=>{e.forEach((o,a)=>{r(o.el,o.type,a,o.options)})},[r,e]),{add:n,remove:r}}function Xr(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Ls(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:a=!0,onMouseDown:s,onMouseUp:i,onClick:l,onKeyDown:c,onKeyUp:u,tabIndex:d,onMouseOver:f,onMouseLeave:p,...m}=t,[h,y]=b.useState(!0),[w,g]=b.useState(!1),x=mc(),E=I=>{I&&I.tagName!=="BUTTON"&&y(!1)},S=h?d:d||0,C=n&&!r,k=b.useCallback(I=>{if(n){I.stopPropagation(),I.preventDefault();return}I.currentTarget.focus(),l==null||l(I)},[n,l]),j=b.useCallback(I=>{w&&Xr(I)&&(I.preventDefault(),I.stopPropagation(),g(!1),x.remove(document,"keyup",j,!1))},[w,x]),D=b.useCallback(I=>{if(c==null||c(I),n||I.defaultPrevented||I.metaKey||!Xr(I.nativeEvent)||h)return;const X=o&&I.key==="Enter";a&&I.key===" "&&(I.preventDefault(),g(!0)),X&&(I.preventDefault(),I.currentTarget.click()),x.add(document,"keyup",j,!1)},[n,h,c,o,a,x,j]),F=b.useCallback(I=>{if(u==null||u(I),n||I.defaultPrevented||I.metaKey||!Xr(I.nativeEvent)||h)return;a&&I.key===" "&&(I.preventDefault(),g(!1),I.currentTarget.click())},[a,h,n,u]),A=b.useCallback(I=>{I.button===0&&(g(!1),x.remove(document,"mouseup",A,!1))},[x]),q=b.useCallback(I=>{if(I.button!==0)return;if(n){I.stopPropagation(),I.preventDefault();return}h||g(!0),I.currentTarget.focus({preventScroll:!0}),x.add(document,"mouseup",A,!1),s==null||s(I)},[n,h,s,x,A]),$=b.useCallback(I=>{I.button===0&&(h||g(!1),i==null||i(I))},[i,h]),K=b.useCallback(I=>{if(n){I.preventDefault();return}f==null||f(I)},[n,f]),le=b.useCallback(I=>{w&&(I.preventDefault(),g(!1)),p==null||p(I)},[w,p]),z=Ae(e,E);return h?{...m,ref:z,type:"button","aria-disabled":C?void 0:n,disabled:C,onClick:k,onMouseDown:s,onMouseUp:i,onKeyUp:u,onKeyDown:c,onMouseOver:f,onMouseLeave:p}:{...m,ref:z,role:"button","data-active":ot(w),"aria-disabled":n?"true":void 0,tabIndex:C?void 0:S,onClick:k,onMouseDown:q,onMouseUp:$,onKeyUp:F,onKeyDown:D,onMouseOver:K,onMouseLeave:le}}function vc(t){const e=t.current;if(!e)return!1;const n=fl(e);return!n||e.contains(n)?!1:!!pl(n)}function Ws(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,a=n&&!r;Mr(()=>{if(!a||vc(t))return;const s=(o==null?void 0:o.current)||t.current;let i;if(s)return i=requestAnimationFrame(()=>{s.focus({preventScroll:!0})}),()=>{cancelAnimationFrame(i)}},[a,t,o])}var yc={preventScroll:!0,shouldFocus:!1};function gc(t,e=yc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:a}=e,s=wc(t)?t.current:t,i=o&&a,l=b.useRef(i),c=b.useRef(a);ul(()=>{!c.current&&a&&(l.current=i),c.current=a},[a,i]);const u=b.useCallback(()=>{if(!(!a||!s||!l.current)&&(l.current=!1,!s.contains(document.activeElement)))if(n!=null&&n.current)requestAnimationFrame(()=>{var d;(d=n.current)==null||d.focus({preventScroll:r})});else{const d=dl(s);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[a,r,s,n]);Mr(()=>{u()},[u]),en(s,"transitionend",u)}function wc(t){return"current"in t}var Gt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),De={arrowShadowColor:Gt("--popper-arrow-shadow-color"),arrowSize:Gt("--popper-arrow-size","8px"),arrowSizeHalf:Gt("--popper-arrow-size-half"),arrowBg:Gt("--popper-arrow-bg"),transformOrigin:Gt("--popper-transform-origin"),arrowOffset:Gt("--popper-arrow-offset")};function bc(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 xc={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"},kc=t=>xc[t],Wa={scroll:!0,resize:!0};function _c(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Wa,...t}}:e={enabled:t,options:Wa},e}var Ec={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`}},Cc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{Ba(t)},effect:({state:t})=>()=>{Ba(t)}},Ba=t=>{t.elements.popper.style.setProperty(De.transformOrigin.var,kc(t.placement))},Sc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Dc(t)}},Dc=t=>{var e;if(!t.placement)return;const n=jc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:De.arrowSize.varRef,height:De.arrowSize.varRef,zIndex:-1});const r={[De.arrowSizeHalf.var]:`calc(${De.arrowSize.varRef} / 2 - 1px)`,[De.arrowOffset.var]:`calc(${De.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},jc=t=>{if(t.startsWith("top"))return{property:"bottom",value:De.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:De.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:De.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:De.arrowOffset.varRef}},Oc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{$a(t)},effect:({state:t})=>()=>{$a(t)}},$a=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=bc(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:De.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Ic={"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"}},Pc={"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 Nc(t,e="ltr"){var n,r;const o=((n=Ic[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=Pc[t])!=null?r:o}var Ue="top",Xe="bottom",Ze="right",ze="left",ca="auto",$n=[Ue,Xe,Ze,ze],an="start",On="end",Fc="clippingParents",Bs="viewport",vn="popper",Ac="reference",Ka=$n.reduce(function(t,e){return t.concat([e+"-"+an,e+"-"+On])},[]),$s=[].concat($n,[ca]).reduce(function(t,e){return t.concat([e,e+"-"+an,e+"-"+On])},[]),Mc="beforeRead",Rc="read",Tc="afterRead",Lc="beforeMain",Wc="main",Bc="afterMain",$c="beforeWrite",Kc="write",Uc="afterWrite",zc=[Mc,Rc,Tc,Lc,Wc,Bc,$c,Kc,Uc];function it(t){return t?(t.nodeName||"").toLowerCase():null}function Ve(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Ut(t){var e=Ve(t).Element;return t instanceof e||t instanceof Element}function Ye(t){var e=Ve(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ua(t){if(typeof ShadowRoot>"u")return!1;var e=Ve(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function qc(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},a=e.elements[n];!Ye(a)||!it(a)||(Object.assign(a.style,r),Object.keys(o).forEach(function(s){var i=o[s];i===!1?a.removeAttribute(s):a.setAttribute(s,i===!0?"":i)}))})}function Vc(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],a=e.attributes[r]||{},s=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),i=s.reduce(function(l,c){return l[c]="",l},{});!Ye(o)||!it(o)||(Object.assign(o.style,i),Object.keys(a).forEach(function(l){o.removeAttribute(l)}))})}}const Hc={name:"applyStyles",enabled:!0,phase:"write",fn:qc,effect:Vc,requires:["computeStyles"]};function st(t){return t.split("-")[0]}var Tt=Math.max,yr=Math.min,sn=Math.round;function mo(){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 Ks(){return!/^((?!chrome|android).)*safari/i.test(mo())}function ln(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,a=1;e&&Ye(t)&&(o=t.offsetWidth>0&&sn(r.width)/t.offsetWidth||1,a=t.offsetHeight>0&&sn(r.height)/t.offsetHeight||1);var s=Ut(t)?Ve(t):window,i=s.visualViewport,l=!Ks()&&n,c=(r.left+(l&&i?i.offsetLeft:0))/o,u=(r.top+(l&&i?i.offsetTop:0))/a,d=r.width/o,f=r.height/a;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function da(t){var e=ln(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function Us(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ua(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function yt(t){return Ve(t).getComputedStyle(t)}function Jc(t){return["table","td","th"].indexOf(it(t))>=0}function jt(t){return((Ut(t)?t.ownerDocument:t.document)||window.document).documentElement}function Kr(t){return it(t)==="html"?t:t.assignedSlot||t.parentNode||(ua(t)?t.host:null)||jt(t)}function Ua(t){return!Ye(t)||yt(t).position==="fixed"?null:t.offsetParent}function Gc(t){var e=/firefox/i.test(mo()),n=/Trident/i.test(mo());if(n&&Ye(t)){var r=yt(t);if(r.position==="fixed")return null}var o=Kr(t);for(ua(o)&&(o=o.host);Ye(o)&&["html","body"].indexOf(it(o))<0;){var a=yt(o);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||e&&a.willChange==="filter"||e&&a.filter&&a.filter!=="none")return o;o=o.parentNode}return null}function Kn(t){for(var e=Ve(t),n=Ua(t);n&&Jc(n)&&yt(n).position==="static";)n=Ua(n);return n&&(it(n)==="html"||it(n)==="body"&&yt(n).position==="static")?e:n||Gc(t)||e}function fa(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function kn(t,e,n){return Tt(t,yr(e,n))}function Yc(t,e,n){var r=kn(t,e,n);return r>n?n:r}function zs(){return{top:0,right:0,bottom:0,left:0}}function qs(t){return Object.assign({},zs(),t)}function Vs(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Xc=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,qs(typeof e!="number"?e:Vs(e,$n))};function Zc(t){var e,n=t.state,r=t.name,o=t.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,i=st(n.placement),l=fa(i),c=[ze,Ze].indexOf(i)>=0,u=c?"height":"width";if(!(!a||!s)){var d=Xc(o.padding,n),f=da(a),p=l==="y"?Ue:ze,m=l==="y"?Xe:Ze,h=n.rects.reference[u]+n.rects.reference[l]-s[l]-n.rects.popper[u],y=s[l]-n.rects.reference[l],w=Kn(a),g=w?l==="y"?w.clientHeight||0:w.clientWidth||0:0,x=h/2-y/2,E=d[p],S=g-f[u]-d[m],C=g/2-f[u]/2+x,k=kn(E,C,S),j=l;n.modifiersData[r]=(e={},e[j]=k,e.centerOffset=k-C,e)}}function Qc(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)||Us(e.elements.popper,o)&&(e.elements.arrow=o))}const eu={name:"arrow",enabled:!0,phase:"main",fn:Zc,effect:Qc,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function cn(t){return t.split("-")[1]}var tu={top:"auto",right:"auto",bottom:"auto",left:"auto"};function nu(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:sn(n*o)/o||0,y:sn(r*o)/o||0}}function za(t){var e,n=t.popper,r=t.popperRect,o=t.placement,a=t.variation,s=t.offsets,i=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,f=s.x,p=f===void 0?0:f,m=s.y,h=m===void 0?0:m,y=typeof u=="function"?u({x:p,y:h}):{x:p,y:h};p=y.x,h=y.y;var w=s.hasOwnProperty("x"),g=s.hasOwnProperty("y"),x=ze,E=Ue,S=window;if(c){var C=Kn(n),k="clientHeight",j="clientWidth";if(C===Ve(n)&&(C=jt(n),yt(C).position!=="static"&&i==="absolute"&&(k="scrollHeight",j="scrollWidth")),C=C,o===Ue||(o===ze||o===Ze)&&a===On){E=Xe;var D=d&&C===S&&S.visualViewport?S.visualViewport.height:C[k];h-=D-r.height,h*=l?1:-1}if(o===ze||(o===Ue||o===Xe)&&a===On){x=Ze;var F=d&&C===S&&S.visualViewport?S.visualViewport.width:C[j];p-=F-r.width,p*=l?1:-1}}var A=Object.assign({position:i},c&&tu),q=u===!0?nu({x:p,y:h},Ve(n)):{x:p,y:h};if(p=q.x,h=q.y,l){var $;return Object.assign({},A,($={},$[E]=g?"0":"",$[x]=w?"0":"",$.transform=(S.devicePixelRatio||1)<=1?"translate("+p+"px, "+h+"px)":"translate3d("+p+"px, "+h+"px, 0)",$))}return Object.assign({},A,(e={},e[E]=g?h+"px":"",e[x]=w?p+"px":"",e.transform="",e))}function ru(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,a=n.adaptive,s=a===void 0?!0:a,i=n.roundOffsets,l=i===void 0?!0:i,c={placement:st(e.placement),variation:cn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,za(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,za(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const ou={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ru,data:{}};var Hn={passive:!0};function au(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,a=o===void 0?!0:o,s=r.resize,i=s===void 0?!0:s,l=Ve(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return a&&c.forEach(function(u){u.addEventListener("scroll",n.update,Hn)}),i&&l.addEventListener("resize",n.update,Hn),function(){a&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Hn)}),i&&l.removeEventListener("resize",n.update,Hn)}}const su={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:au,data:{}};var iu={left:"right",right:"left",bottom:"top",top:"bottom"};function or(t){return t.replace(/left|right|bottom|top/g,function(e){return iu[e]})}var lu={start:"end",end:"start"};function qa(t){return t.replace(/start|end/g,function(e){return lu[e]})}function pa(t){var e=Ve(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function ha(t){return ln(jt(t)).left+pa(t).scrollLeft}function cu(t,e){var n=Ve(t),r=jt(t),o=n.visualViewport,a=r.clientWidth,s=r.clientHeight,i=0,l=0;if(o){a=o.width,s=o.height;var c=Ks();(c||!c&&e==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:a,height:s,x:i+ha(t),y:l}}function uu(t){var e,n=jt(t),r=pa(t),o=(e=t.ownerDocument)==null?void 0:e.body,a=Tt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=Tt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),i=-r.scrollLeft+ha(t),l=-r.scrollTop;return yt(o||n).direction==="rtl"&&(i+=Tt(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:i,y:l}}function ma(t){var e=yt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function Hs(t){return["html","body","#document"].indexOf(it(t))>=0?t.ownerDocument.body:Ye(t)&&ma(t)?t:Hs(Kr(t))}function _n(t,e){var n;e===void 0&&(e=[]);var r=Hs(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),a=Ve(r),s=o?[a].concat(a.visualViewport||[],ma(r)?r:[]):r,i=e.concat(s);return o?i:i.concat(_n(Kr(s)))}function vo(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function du(t,e){var n=ln(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function Va(t,e,n){return e===Bs?vo(cu(t,n)):Ut(e)?du(e,n):vo(uu(jt(t)))}function fu(t){var e=_n(Kr(t)),n=["absolute","fixed"].indexOf(yt(t).position)>=0,r=n&&Ye(t)?Kn(t):t;return Ut(r)?e.filter(function(o){return Ut(o)&&Us(o,r)&&it(o)!=="body"}):[]}function pu(t,e,n,r){var o=e==="clippingParents"?fu(t):[].concat(e),a=[].concat(o,[n]),s=a[0],i=a.reduce(function(l,c){var u=Va(t,c,r);return l.top=Tt(u.top,l.top),l.right=yr(u.right,l.right),l.bottom=yr(u.bottom,l.bottom),l.left=Tt(u.left,l.left),l},Va(t,s,r));return i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}function Js(t){var e=t.reference,n=t.element,r=t.placement,o=r?st(r):null,a=r?cn(r):null,s=e.x+e.width/2-n.width/2,i=e.y+e.height/2-n.height/2,l;switch(o){case Ue:l={x:s,y:e.y-n.height};break;case Xe:l={x:s,y:e.y+e.height};break;case Ze:l={x:e.x+e.width,y:i};break;case ze:l={x:e.x-n.width,y:i};break;default:l={x:e.x,y:e.y}}var c=o?fa(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(a){case an:l[c]=l[c]-(e[u]/2-n[u]/2);break;case On:l[c]=l[c]+(e[u]/2-n[u]/2);break}}return l}function In(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,a=n.strategy,s=a===void 0?t.strategy:a,i=n.boundary,l=i===void 0?Fc:i,c=n.rootBoundary,u=c===void 0?Bs:c,d=n.elementContext,f=d===void 0?vn:d,p=n.altBoundary,m=p===void 0?!1:p,h=n.padding,y=h===void 0?0:h,w=qs(typeof y!="number"?y:Vs(y,$n)),g=f===vn?Ac:vn,x=t.rects.popper,E=t.elements[m?g:f],S=pu(Ut(E)?E:E.contextElement||jt(t.elements.popper),l,u,s),C=ln(t.elements.reference),k=Js({reference:C,element:x,strategy:"absolute",placement:o}),j=vo(Object.assign({},x,k)),D=f===vn?j:C,F={top:S.top-D.top+w.top,bottom:D.bottom-S.bottom+w.bottom,left:S.left-D.left+w.left,right:D.right-S.right+w.right},A=t.modifiersData.offset;if(f===vn&&A){var q=A[o];Object.keys(F).forEach(function($){var K=[Ze,Xe].indexOf($)>=0?1:-1,le=[Ue,Xe].indexOf($)>=0?"y":"x";F[$]+=q[le]*K})}return F}function hu(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,a=n.rootBoundary,s=n.padding,i=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?$s:l,u=cn(r),d=u?i?Ka:Ka.filter(function(m){return cn(m)===u}):$n,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var p=f.reduce(function(m,h){return m[h]=In(t,{placement:h,boundary:o,rootBoundary:a,padding:s})[st(h)],m},{});return Object.keys(p).sort(function(m,h){return p[m]-p[h]})}function mu(t){if(st(t)===ca)return[];var e=or(t);return[qa(t),e,qa(e)]}function vu(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,a=o===void 0?!0:o,s=n.altAxis,i=s===void 0?!0:s,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0?!0:p,h=n.allowedAutoPlacements,y=e.options.placement,w=st(y),g=w===y,x=l||(g||!m?[or(y)]:mu(y)),E=[y].concat(x).reduce(function(ae,_){return ae.concat(st(_)===ca?hu(e,{placement:_,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:h}):_)},[]),S=e.rects.reference,C=e.rects.popper,k=new Map,j=!0,D=E[0],F=0;F=0,le=K?"width":"height",z=In(e,{placement:A,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),I=K?$?Ze:ze:$?Xe:Ue;S[le]>C[le]&&(I=or(I));var X=or(I),re=[];if(a&&re.push(z[q]<=0),i&&re.push(z[I]<=0,z[X]<=0),re.every(function(ae){return ae})){D=A,j=!1;break}k.set(A,re)}if(j)for(var he=m?3:1,be=function(_){var N=E.find(function(M){var L=k.get(M);if(L)return L.slice(0,_).every(function(Y){return Y})});if(N)return D=N,"break"},Ee=he;Ee>0;Ee--){var ce=be(Ee);if(ce==="break")break}e.placement!==D&&(e.modifiersData[r]._skip=!0,e.placement=D,e.reset=!0)}}const yu={name:"flip",enabled:!0,phase:"main",fn:vu,requiresIfExists:["offset"],data:{_skip:!1}};function Ha(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 Ja(t){return[Ue,Ze,Xe,ze].some(function(e){return t[e]>=0})}function gu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,a=e.modifiersData.preventOverflow,s=In(e,{elementContext:"reference"}),i=In(e,{altBoundary:!0}),l=Ha(s,r),c=Ha(i,o,a),u=Ja(l),d=Ja(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const wu={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:gu};function bu(t,e,n){var r=st(t),o=[ze,Ue].indexOf(r)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,s=a[0],i=a[1];return s=s||0,i=(i||0)*o,[ze,Ze].indexOf(r)>=0?{x:i,y:s}:{x:s,y:i}}function xu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,a=o===void 0?[0,0]:o,s=$s.reduce(function(u,d){return u[d]=bu(d,e.rects,a),u},{}),i=s[e.placement],l=i.x,c=i.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=s}const ku={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:xu};function _u(t){var e=t.state,n=t.name;e.modifiersData[n]=Js({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Eu={name:"popperOffsets",enabled:!0,phase:"read",fn:_u,data:{}};function Cu(t){return t==="x"?"y":"x"}function Su(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,a=o===void 0?!0:o,s=n.altAxis,i=s===void 0?!1:s,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,m=n.tetherOffset,h=m===void 0?0:m,y=In(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),w=st(e.placement),g=cn(e.placement),x=!g,E=fa(w),S=Cu(E),C=e.modifiersData.popperOffsets,k=e.rects.reference,j=e.rects.popper,D=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,F=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),A=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,q={x:0,y:0};if(C){if(a){var $,K=E==="y"?Ue:ze,le=E==="y"?Xe:Ze,z=E==="y"?"height":"width",I=C[E],X=I+y[K],re=I-y[le],he=p?-j[z]/2:0,be=g===an?k[z]:j[z],Ee=g===an?-j[z]:-k[z],ce=e.elements.arrow,ae=p&&ce?da(ce):{width:0,height:0},_=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:zs(),N=_[K],M=_[le],L=kn(0,k[z],ae[z]),Y=x?k[z]/2-he-L-N-F.mainAxis:be-L-N-F.mainAxis,J=x?-k[z]/2+he+L+M+F.mainAxis:Ee+L+M+F.mainAxis,se=e.elements.arrow&&Kn(e.elements.arrow),V=se?E==="y"?se.clientTop||0:se.clientLeft||0:0,W=($=A==null?void 0:A[E])!=null?$:0,Q=I+Y-W-V,T=I+J-W,ee=kn(p?yr(X,Q):X,I,p?Tt(re,T):re);C[E]=ee,q[E]=ee-I}if(i){var te,ie=E==="x"?Ue:ze,Ie=E==="x"?Xe:Ze,G=C[S],de=S==="y"?"height":"width",Ce=G+y[ie],$e=G-y[Ie],ue=[Ue,ze].indexOf(w)!==-1,Se=(te=A==null?void 0:A[S])!=null?te:0,ye=ue?Ce:G-k[de]-j[de]-Se+F.altAxis,et=ue?G+k[de]+j[de]-Se-F.altAxis:$e,Je=p&&ue?Yc(ye,G,et):kn(p?ye:Ce,G,p?et:$e);C[S]=Je,q[S]=Je-G}e.modifiersData[r]=q}}const Du={name:"preventOverflow",enabled:!0,phase:"main",fn:Su,requiresIfExists:["offset"]};function ju(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Ou(t){return t===Ve(t)||!Ye(t)?pa(t):ju(t)}function Iu(t){var e=t.getBoundingClientRect(),n=sn(e.width)/t.offsetWidth||1,r=sn(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Pu(t,e,n){n===void 0&&(n=!1);var r=Ye(e),o=Ye(e)&&Iu(e),a=jt(e),s=ln(t,o,n),i={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((it(e)!=="body"||ma(a))&&(i=Ou(e)),Ye(e)?(l=ln(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):a&&(l.x=ha(a))),{x:s.left+i.scrollLeft-l.x,y:s.top+i.scrollTop-l.y,width:s.width,height:s.height}}function Nu(t){var e=new Map,n=new Set,r=[];t.forEach(function(a){e.set(a.name,a)});function o(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(i){if(!n.has(i)){var l=e.get(i);l&&o(l)}}),r.push(a)}return t.forEach(function(a){n.has(a.name)||o(a)}),r}function Fu(t){var e=Nu(t);return zc.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Au(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Mu(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 Ga={placement:"bottom",modifiers:[],strategy:"absolute"};function Ya(){for(var t=arguments.length,e=new Array(t),n=0;n{}),x=b.useCallback(()=>{var F;!e||!m.current||!h.current||((F=g.current)==null||F.call(g),y.current=Lu(m.current,h.current,{placement:w,modifiers:[Oc,Sc,Cc,{...Ec,enabled:!!f},{name:"eventListeners",..._c(s)},{name:"arrow",options:{padding:a}},{name:"offset",options:{offset:i??[0,l]}},{name:"flip",enabled:!!c,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:u}},...n??[]],strategy:o}),y.current.forceUpdate(),g.current=y.current.destroy)},[w,e,n,f,s,a,i,l,c,d,u,o]);b.useEffect(()=>()=>{var F;!m.current&&!h.current&&((F=y.current)==null||F.destroy(),y.current=null)},[]);const E=b.useCallback(F=>{m.current=F,x()},[x]),S=b.useCallback((F={},A=null)=>({...F,ref:Ae(E,A)}),[E]),C=b.useCallback(F=>{h.current=F,x()},[x]),k=b.useCallback((F={},A=null)=>({...F,ref:Ae(C,A),style:{...F.style,position:o,minWidth:f?void 0:"max-content",inset:"0 auto auto 0"}}),[o,C,f]),j=b.useCallback((F={},A=null)=>{const{size:q,shadowColor:$,bg:K,style:le,...z}=F;return{...z,ref:A,"data-popper-arrow":"",style:Wu(F)}},[]),D=b.useCallback((F={},A=null)=>({...F,ref:A,"data-popper-arrow-inner":""}),[]);return{update(){var F;(F=y.current)==null||F.update()},forceUpdate(){var F;(F=y.current)==null||F.forceUpdate()},transformOrigin:De.transformOrigin.varRef,referenceRef:E,popperRef:C,getPopperProps:k,getArrowProps:j,getArrowInnerProps:D,getReferenceProps:S}}function Wu(t){const{size:e,shadowColor:n,bg:r,style:o}=t,a={...o,position:"absolute"};return e&&(a["--popper-arrow-size"]=e),n&&(a["--popper-arrow-shadow-color"]=n),r&&(a["--popper-arrow-bg"]=r),a}function ya(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,a=Mt(n),s=Mt(e),[i,l]=b.useState(t.defaultIsOpen||!1),c=r!==void 0?r:i,u=r!==void 0,d=b.useId(),f=o??`disclosure-${d}`,p=b.useCallback(()=>{u||l(!1),s==null||s()},[u,s]),m=b.useCallback(()=>{u||l(!0),a==null||a()},[u,a]),h=b.useCallback(()=>{c?p():m()},[c,m,p]);function y(g={}){return{...g,"aria-expanded":c,"aria-controls":f,onClick(x){var E;(E=g.onClick)==null||E.call(g,x),h()}}}function w(g={}){return{...g,hidden:!c,id:f}}return{isOpen:c,onOpen:m,onClose:p,onToggle:h,isControlled:u,getButtonProps:y,getDisclosureProps:w}}function Bu(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Mt(n),s=b.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;b.useEffect(()=>{if(!r)return;const i=d=>{Zr(d,e)&&(s.isPointerDown=!0)},l=d=>{if(s.ignoreEmulatedMouseEvents){s.ignoreEmulatedMouseEvents=!1;return}s.isPointerDown&&n&&Zr(d,e)&&(s.isPointerDown=!1,o(d))},c=d=>{s.ignoreEmulatedMouseEvents=!0,n&&s.isPointerDown&&Zr(d,e)&&(s.isPointerDown=!1,o(d))},u=Gs(e.current);return u.addEventListener("mousedown",i,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",i,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",i,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",i,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,s,r])}function Zr(t,e){var n;const r=t.target;return r&&!Gs(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Gs(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Ys(t){const{isOpen:e,ref:n}=t,[r,o]=b.useState(e),[a,s]=b.useState(!1);return b.useEffect(()=>{a||(o(e),s(!0))},[e,a,r]),en(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const c=hl(n.current),u=new c.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(u)}}}function ga(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[$u,Ku,Uu,zu]=Es(),[qu,Un]=rt({strict:!1,name:"MenuContext"});function Vu(t,...e){const n=b.useId(),r=t||n;return b.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function Xs(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Xa(t){return Xs(t).activeElement===t}function Hu(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:a=!0,isLazy:s,isOpen:i,defaultIsOpen:l,onClose:c,onOpen:u,placement:d="bottom-start",lazyBehavior:f="unmount",direction:p,computePositionOnMount:m=!1,...h}=t,y=b.useRef(null),w=b.useRef(null),g=Uu(),x=b.useCallback(()=>{requestAnimationFrame(()=>{var ce;(ce=y.current)==null||ce.focus({preventScroll:!1})})},[]),E=b.useCallback(()=>{const ce=setTimeout(()=>{var ae;if(o)(ae=o.current)==null||ae.focus();else{const _=g.firstEnabled();_&&$(_.index)}});X.current.add(ce)},[g,o]),S=b.useCallback(()=>{const ce=setTimeout(()=>{const ae=g.lastEnabled();ae&&$(ae.index)});X.current.add(ce)},[g]),C=b.useCallback(()=>{u==null||u(),a?E():x()},[a,E,x,u]),{isOpen:k,onOpen:j,onClose:D,onToggle:F}=ya({isOpen:i,defaultIsOpen:l,onClose:c,onOpen:C});Bu({enabled:k&&r,ref:y,handler:ce=>{var ae;(ae=w.current)!=null&&ae.contains(ce.target)||D()}});const A=va({...h,enabled:k||m,placement:d,direction:p}),[q,$]=b.useState(-1);Mr(()=>{k||$(-1)},[k]),Ws(y,{focusRef:w,visible:k,shouldFocus:!0});const K=Ys({isOpen:k,ref:y}),[le,z]=Vu(e,"menu-button","menu-list"),I=b.useCallback(()=>{j(),x()},[j,x]),X=b.useRef(new Set([]));b.useEffect(()=>{const ce=X.current;return()=>{ce.forEach(ae=>clearTimeout(ae)),ce.clear()}},[]);const re=b.useCallback(()=>{j(),E()},[E,j]),he=b.useCallback(()=>{j(),S()},[j,S]),be=b.useCallback(()=>{var ce,ae;const _=Xs(y.current),N=(ce=y.current)==null?void 0:ce.contains(_.activeElement);if(!(k&&!N))return;const L=(ae=g.item(q))==null?void 0:ae.node;L==null||L.focus({preventScroll:!0})},[k,q,g]),Ee=b.useRef(null);return{openAndFocusMenu:I,openAndFocusFirstItem:re,openAndFocusLastItem:he,onTransitionEnd:be,unstable__animationState:K,descendants:g,popper:A,buttonId:le,menuId:z,forceUpdate:A.forceUpdate,orientation:"vertical",isOpen:k,onToggle:F,onOpen:j,onClose:D,menuRef:y,buttonRef:w,focusedIndex:q,closeOnSelect:n,closeOnBlur:r,autoSelect:a,setFocusedIndex:$,isLazy:s,lazyBehavior:f,initialFocusRef:o,rafId:Ee}}function Gp(t={},e=null){const n=Un(),{onToggle:r,popper:o,openAndFocusFirstItem:a,openAndFocusLastItem:s}=n,i=b.useCallback(l=>{const c=l.key,d={Enter:a,ArrowDown:a,ArrowUp:s}[c];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[a,s]);return{...t,ref:Ae(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":ot(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:xe(t.onClick,r),onKeyDown:xe(t.onKeyDown,i)}}function yo(t){var e;return Yu(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Ju(t={},e=null){const n=Un();if(!n)throw new Error("useMenuContext: context is undefined. Seems you forgot to wrap component within ");const{focusedIndex:r,setFocusedIndex:o,menuRef:a,isOpen:s,onClose:i,menuId:l,isLazy:c,lazyBehavior:u,unstable__animationState:d}=n,f=Ku(),p=pc({preventDefault:w=>w.key!==" "&&yo(w.target)}),m=b.useCallback(w=>{if(!w.currentTarget.contains(w.target))return;const g=w.key,E={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)}}[g];if(E){w.preventDefault(),E(w);return}const S=p(C=>{const k=hc(f.values(),C,j=>{var D,F;return(F=(D=j==null?void 0:j.node)==null?void 0:D.textContent)!=null?F:""},f.item(r));if(k){const j=f.indexOf(k.node);o(j)}});yo(w.target)&&S(w)},[f,r,p,i,o]),h=b.useRef(!1);s&&(h.current=!0);const y=ga({wasSelected:h.current,enabled:c,mode:u,isSelected:d.present});return{...t,ref:Ae(a,e),children:y?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:xe(t.onKeyDown,m)}}function Gu(t={}){const{popper:e,isOpen:n}=Un();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function Zs(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:a,onFocus:s,isDisabled:i,isFocusable:l,closeOnSelect:c,type:u,...d}=t,f=Un(),{setFocusedIndex:p,focusedIndex:m,closeOnSelect:h,onClose:y,menuRef:w,isOpen:g,menuId:x,rafId:E}=f,S=b.useRef(null),C=`${x}-menuitem-${b.useId()}`,{index:k,register:j}=zu({disabled:i&&!l}),D=b.useCallback(I=>{n==null||n(I),!i&&p(k)},[p,k,i,n]),F=b.useCallback(I=>{r==null||r(I),S.current&&!Xa(S.current)&&D(I)},[D,r]),A=b.useCallback(I=>{o==null||o(I),!i&&p(-1)},[p,i,o]),q=b.useCallback(I=>{a==null||a(I),yo(I.currentTarget)&&(c??h)&&y()},[y,a,h,c]),$=b.useCallback(I=>{s==null||s(I),p(k)},[p,s,k]),K=k===m,le=i&&!l;Mr(()=>{if(g)return K&&!le&&S.current?(E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(()=>{var I;(I=S.current)==null||I.focus({preventScroll:!0}),E.current=null})):w.current&&!Xa(w.current)&&w.current.focus({preventScroll:!0}),()=>{E.current&&cancelAnimationFrame(E.current)}},[K,le,w,g]);const z=Ls({onClick:q,onFocus:$,onMouseEnter:D,onMouseMove:F,onMouseLeave:A,ref:Ae(j,S,e),isDisabled:i,isFocusable:l});return{...d,...z,type:u??z.type,id:C,role:"menuitem",tabIndex:K?0:-1}}function Yp(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...Zs(o,e),role:`menuitem${n}`,"aria-checked":r}}function Xp(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:a,...s}=t,l=n==="radio"?"":[],[c,u]=Cs({defaultValue:o??l,value:r,onChange:a}),d=b.useCallback(m=>{if(n==="radio"&&typeof c=="string"&&u(m),n==="checkbox"&&Array.isArray(c)){const h=c.includes(m)?c.filter(y=>y!==m):c.concat(m);u(h)}},[c,u,n]),p=la(e).map(m=>{if(m.type.id!=="MenuItemOption")return m;const h=w=>{var g,x;d(m.props.value),(x=(g=m.props).onClick)==null||x.call(g,w)},y=n==="radio"?m.props.value===c:c.includes(m.props.value);return b.cloneElement(m,{type:n,onClick:h,isChecked:y})});return{...s,children:p}}function Yu(t){var e;if(!Xu(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function Xu(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[Zu,Ur]=rt({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),wa=t=>{const{children:e}=t,n=Vt("Menu",t),r=Qe(t),{direction:o}=ea(),{descendants:a,...s}=Hu({...r,direction:o}),i=b.useMemo(()=>s,[s]),{isOpen:l,onClose:c,forceUpdate:u}=i;return v.jsx($u,{value:a,children:v.jsx(qu,{value:i,children:v.jsx(Zu,{value:n,children:ys(e,{isOpen:l,onClose:c,forceUpdate:u})})})})};wa.displayName="Menu";var Qs=oe((t,e)=>{const n=Ur();return v.jsx(Z.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});Qs.displayName="MenuCommand";var Qu=oe((t,e)=>{const{type:n,...r}=t,o=Ur(),a=r.as||n?n??void 0:"button",s=b.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(Z.button,{ref:e,type:a,...r,__css:s})}),ei=t=>{const{className:e,children:n,...r}=t,o=Ur(),a=b.Children.only(n),s=b.isValidElement(a)?b.cloneElement(a,{focusable:"false","aria-hidden":!0,className:pe("chakra-menu__icon",a.props.className)}):null,i=pe("chakra-menu__icon-wrapper",e);return v.jsx(Z.span,{className:i,...r,__css:o.icon,children:s})};ei.displayName="MenuIcon";var wt=oe((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:a="0.75rem",children:s,...i}=t,l=Zs(i,e),u=n||o?v.jsx("span",{style:{pointerEvents:"none",flex:1},children:s}):s;return v.jsxs(Qu,{...l,className:pe("chakra-menu__menuitem",l.className),children:[n&&v.jsx(ei,{fontSize:"0.8em",marginEnd:r,children:n}),u,o&&v.jsx(Qs,{marginStart:a,children:o})]})});wt.displayName="MenuItem";var ed={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},td=Z(ta.div),ba=oe(function(e,n){var r,o;const{rootProps:a,motionProps:s,...i}=e,{isOpen:l,onTransitionEnd:c,unstable__animationState:u}=Un(),d=Ju(i,n),f=Gu(a),p=Ur();return v.jsx(Z.div,{...f,__css:{zIndex:(o=e.zIndex)!=null?o:(r=p.list)==null?void 0:r.zIndex},children:v.jsx(td,{variants:ed,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...p.list},...s,className:pe("chakra-menu__menu-list",d.className),...d,onUpdate:c,onAnimationComplete:gs(u.onComplete,d.onAnimationComplete)})})});ba.displayName="MenuList";var[nd,fn]=rt({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[rd,zr]=rt({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ti(t){const e=b.Children.only(t.children),{getTriggerProps:n}=fn();return b.cloneElement(e,n(e.props,e.ref))}ti.displayName="PopoverTrigger";var Yt={click:"click",hover:"hover"};function od(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:a=!0,autoFocus:s=!0,arrowSize:i,arrowShadowColor:l,trigger:c=Yt.click,openDelay:u=200,closeDelay:d=200,isLazy:f,lazyBehavior:p="unmount",computePositionOnMount:m,...h}=t,{isOpen:y,onClose:w,onOpen:g,onToggle:x}=ya(t),E=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(!1),j=b.useRef(!1);y&&(j.current=!0);const[D,F]=b.useState(!1),[A,q]=b.useState(!1),$=b.useId(),K=o??$,[le,z,I,X]=["popover-trigger","popover-content","popover-header","popover-body"].map(T=>`${T}-${K}`),{referenceRef:re,getArrowProps:he,getPopperProps:be,getArrowInnerProps:Ee,forceUpdate:ce}=va({...h,enabled:y||!!m}),ae=Ys({isOpen:y,ref:C});Gl({enabled:y,ref:S}),Ws(C,{focusRef:S,visible:y,shouldFocus:a&&c===Yt.click}),gc(C,{focusRef:r,visible:y,shouldFocus:s&&c===Yt.click});const _=ga({wasSelected:j.current,enabled:f,mode:p,isSelected:ae.present}),N=b.useCallback((T={},ee=null)=>{const te={...T,style:{...T.style,transformOrigin:De.transformOrigin.varRef,[De.arrowSize.var]:i?`${i}px`:void 0,[De.arrowShadowColor.var]:l},ref:Ae(C,ee),children:_?T.children:null,id:z,tabIndex:-1,role:"dialog",onKeyDown:xe(T.onKeyDown,ie=>{n&&ie.key==="Escape"&&w()}),onBlur:xe(T.onBlur,ie=>{const Ie=Za(ie),G=Qr(C.current,Ie),de=Qr(S.current,Ie);y&&e&&(!G&&!de)&&w()}),"aria-labelledby":D?I:void 0,"aria-describedby":A?X:void 0};return c===Yt.hover&&(te.role="tooltip",te.onMouseEnter=xe(T.onMouseEnter,()=>{k.current=!0}),te.onMouseLeave=xe(T.onMouseLeave,ie=>{ie.nativeEvent.relatedTarget!==null&&(k.current=!1,setTimeout(()=>w(),d))})),te},[_,z,D,I,A,X,c,n,w,y,e,d,l,i]),M=b.useCallback((T={},ee=null)=>be({...T,style:{visibility:y?"visible":"hidden",...T.style}},ee),[y,be]),L=b.useCallback((T,ee=null)=>({...T,ref:Ae(ee,E,re)}),[E,re]),Y=b.useRef(),J=b.useRef(),se=b.useCallback(T=>{E.current==null&&re(T)},[re]),V=b.useCallback((T={},ee=null)=>{const te={...T,ref:Ae(S,ee,se),id:le,"aria-haspopup":"dialog","aria-expanded":y,"aria-controls":z};return c===Yt.click&&(te.onClick=xe(T.onClick,x)),c===Yt.hover&&(te.onFocus=xe(T.onFocus,()=>{Y.current===void 0&&g()}),te.onBlur=xe(T.onBlur,ie=>{const Ie=Za(ie),G=!Qr(C.current,Ie);y&&e&&G&&w()}),te.onKeyDown=xe(T.onKeyDown,ie=>{ie.key==="Escape"&&w()}),te.onMouseEnter=xe(T.onMouseEnter,()=>{k.current=!0,Y.current=window.setTimeout(()=>g(),u)}),te.onMouseLeave=xe(T.onMouseLeave,()=>{k.current=!1,Y.current&&(clearTimeout(Y.current),Y.current=void 0),J.current=window.setTimeout(()=>{k.current===!1&&w()},d)})),te},[le,y,z,c,se,x,g,e,w,u,d]);b.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current),J.current&&clearTimeout(J.current)},[]);const W=b.useCallback((T={},ee=null)=>({...T,id:I,ref:Ae(ee,te=>{F(!!te)})}),[I]),Q=b.useCallback((T={},ee=null)=>({...T,id:X,ref:Ae(ee,te=>{q(!!te)})}),[X]);return{forceUpdate:ce,isOpen:y,onAnimationComplete:ae.onComplete,onClose:w,getAnchorProps:L,getArrowProps:he,getArrowInnerProps:Ee,getPopoverPositionerProps:M,getPopoverProps:N,getTriggerProps:V,getHeaderProps:W,getBodyProps:Q}}function Qr(t,e){return t===e||(t==null?void 0:t.contains(e))}function Za(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function ni(t){const e=Vt("Popover",t),{children:n,...r}=Qe(t),o=ea(),a=od({...r,direction:o.direction});return v.jsx(nd,{value:a,children:v.jsx(rd,{value:e,children:ys(n,{isOpen:a.isOpen,onClose:a.onClose,forceUpdate:a.forceUpdate})})})}ni.displayName="Popover";var eo=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function ri(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:a,boxShadow:s,shadowColor:i}=t,{getArrowProps:l,getArrowInnerProps:c}=fn(),u=zr(),d=(e=n??r)!=null?e:o,f=a??s;return v.jsx(Z.div,{...l(),className:"chakra-popover__arrow-positioner",children:v.jsx(Z.div,{className:pe("chakra-popover__arrow",t.className),...c(t),__css:{"--popper-arrow-shadow-color":eo("colors",i),"--popper-arrow-bg":eo("colors",d),"--popper-arrow-shadow":eo("shadows",f),...u.arrow}})})}ri.displayName="PopoverArrow";var oi=oe(function(e,n){const{getBodyProps:r}=fn(),o=zr();return v.jsx(Z.div,{...r(e,n),className:pe("chakra-popover__body",e.className),__css:o.body})});oi.displayName="PopoverBody";var ai=oe(function(e,n){const{onClose:r}=fn(),o=zr();return v.jsx(ml,{size:"sm",onClick:r,className:pe("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});ai.displayName="PopoverCloseButton";function ad(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var sd={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]}}},id=Z(ta.section),si=oe(function(e,n){const{variants:r=sd,...o}=e,{isOpen:a}=fn();return v.jsx(id,{ref:n,variants:ad(r),initial:!1,animate:a?"enter":"exit",...o})});si.displayName="PopoverTransition";var ii=oe(function(e,n){const{rootProps:r,motionProps:o,...a}=e,{getPopoverProps:s,getPopoverPositionerProps:i,onAnimationComplete:l}=fn(),c=zr(),u={position:"relative",display:"flex",flexDirection:"column",...c.content};return v.jsx(Z.div,{...i(r),__css:c.popper,className:"chakra-popover__popper",children:v.jsx(si,{...o,...s(a,n),onAnimationComplete:gs(l,a.onAnimationComplete),className:pe("chakra-popover__content",e.className),__css:u})})});ii.displayName="PopoverContent";var[ld,cd,ud,dd]=Es();function fd(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:a,isLazy:s,lazyBehavior:i="unmount",orientation:l="horizontal",direction:c="ltr",...u}=t,[d,f]=b.useState(n??0),[p,m]=Cs({defaultValue:n??0,value:o,onChange:r});b.useEffect(()=>{o!=null&&f(o)},[o]);const h=ud(),y=b.useId();return{id:`tabs-${(e=t.id)!=null?e:y}`,selectedIndex:p,focusedIndex:d,setSelectedIndex:m,setFocusedIndex:f,isManual:a,isLazy:s,lazyBehavior:i,orientation:l,descendants:h,direction:c,htmlProps:u}}var[pd,qr]=rt({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function hd(t){const{focusedIndex:e,orientation:n,direction:r}=qr(),o=cd(),a=b.useCallback(s=>{const i=()=>{var g;const x=o.nextEnabled(e);x&&((g=x.node)==null||g.focus())},l=()=>{var g;const x=o.prevEnabled(e);x&&((g=x.node)==null||g.focus())},c=()=>{var g;const x=o.firstEnabled();x&&((g=x.node)==null||g.focus())},u=()=>{var g;const x=o.lastEnabled();x&&((g=x.node)==null||g.focus())},d=n==="horizontal",f=n==="vertical",p=s.key,m=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",w={[m]:()=>d&&l(),[h]:()=>d&&i(),ArrowDown:()=>f&&i(),ArrowUp:()=>f&&l(),Home:c,End:u}[p];w&&(s.preventDefault(),w(s))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:xe(t.onKeyDown,a)}}function md(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:a,id:s,setFocusedIndex:i,selectedIndex:l}=qr(),{index:c,register:u}=dd({disabled:e&&!n}),d=c===l,f=()=>{o(c)},p=()=>{i(c),!a&&!(e&&n)&&o(c)},m=Ls({...r,ref:Ae(u,t.ref),isDisabled:e,isFocusable:n,onClick:xe(t.onClick,f)}),h="button";return{...m,id:li(s,c),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":ci(s,c),onFocus:e?void 0:xe(t.onFocus,p)}}var[vd,yd]=rt({});function gd(t){const e=qr(),{id:n,selectedIndex:r}=e,a=la(t.children).map((s,i)=>b.createElement(vd,{key:i,value:{isSelected:i===r,id:ci(n,i),tabId:li(n,i),selectedIndex:r}},s));return{...t,children:a}}function wd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=qr(),{isSelected:a,id:s,tabId:i}=yd(),l=b.useRef(!1);a&&(l.current=!0);const c=ga({wasSelected:l.current,isSelected:a,enabled:r,mode:o});return{tabIndex:0,...n,children:c?e:null,role:"tabpanel","aria-labelledby":i,hidden:!a,id:s}}function li(t,e){return`${t}--tab-${e}`}function ci(t,e){return`${t}--tabpanel-${e}`}var[bd,Vr]=rt({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),ui=oe(function(e,n){const r=Vt("Tabs",e),{children:o,className:a,...s}=Qe(e),{htmlProps:i,descendants:l,...c}=fd(s),u=b.useMemo(()=>c,[c]),{isFitted:d,...f}=i,p={position:"relative",...r.root};return v.jsx(ld,{value:l,children:v.jsx(pd,{value:u,children:v.jsx(bd,{value:r,children:v.jsx(Z.div,{className:pe("chakra-tabs",a),ref:n,...f,__css:p,children:o})})})})});ui.displayName="Tabs";var di=oe(function(e,n){const r=hd({...e,ref:n}),a={display:"flex",...Vr().tablist};return v.jsx(Z.div,{...r,className:pe("chakra-tabs__tablist",e.className),__css:a})});di.displayName="TabList";var go=oe(function(e,n){const r=wd({...e,ref:n}),o=Vr();return v.jsx(Z.div,{outline:"0",...r,className:pe("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});go.displayName="TabPanel";var fi=oe(function(e,n){const r=gd(e),o=Vr();return v.jsx(Z.div,{...r,width:"100%",ref:n,className:pe("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});fi.displayName="TabPanels";var wo=oe(function(e,n){const r=Vr(),o=md({...e,ref:n}),a={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return v.jsx(Z.button,{...o,className:pe("chakra-tabs__tab",e.className),__css:a})});wo.displayName="Tab";var xd={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]}}}},bo=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},ar=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function kd(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:a,closeOnPointerDown:s=o,closeOnEsc:i=!0,onOpen:l,onClose:c,placement:u,id:d,isOpen:f,defaultIsOpen:p,arrowSize:m=10,arrowShadowColor:h,arrowPadding:y,modifiers:w,isDisabled:g,gutter:x,offset:E,direction:S,...C}=t,{isOpen:k,onOpen:j,onClose:D}=ya({isOpen:f,defaultIsOpen:p,onOpen:l,onClose:c}),{referenceRef:F,getPopperProps:A,getArrowInnerProps:q,getArrowProps:$}=va({enabled:k,placement:u,arrowPadding:y,modifiers:w,gutter:x,offset:E,direction:S}),K=b.useId(),z=`tooltip-${d??K}`,I=b.useRef(null),X=b.useRef(),re=b.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=void 0)},[]),he=b.useRef(),be=b.useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=void 0)},[]),Ee=b.useCallback(()=>{be(),D()},[D,be]),ce=_d(I,Ee),ae=b.useCallback(()=>{if(!g&&!X.current){k&&ce();const V=ar(I);X.current=V.setTimeout(j,e)}},[ce,g,k,j,e]),_=b.useCallback(()=>{re();const V=ar(I);he.current=V.setTimeout(Ee,n)},[n,Ee,re]),N=b.useCallback(()=>{k&&r&&_()},[r,_,k]),M=b.useCallback(()=>{k&&s&&_()},[s,_,k]),L=b.useCallback(V=>{k&&V.key==="Escape"&&_()},[k,_]);en(()=>bo(I),"keydown",i?L:void 0),en(()=>{if(!a)return null;const V=I.current;if(!V)return null;const W=Fs(V);return W.localName==="body"?ar(I):W},"scroll",()=>{k&&a&&Ee()},{passive:!0,capture:!0}),b.useEffect(()=>{g&&(re(),k&&D())},[g,k,D,re]),b.useEffect(()=>()=>{re(),be()},[re,be]),en(()=>I.current,"pointerleave",_);const Y=b.useCallback((V={},W=null)=>({...V,ref:Ae(I,W,F),onPointerEnter:xe(V.onPointerEnter,T=>{T.pointerType!=="touch"&&ae()}),onClick:xe(V.onClick,N),onPointerDown:xe(V.onPointerDown,M),onFocus:xe(V.onFocus,ae),onBlur:xe(V.onBlur,_),"aria-describedby":k?z:void 0}),[ae,_,M,k,z,N,F]),J=b.useCallback((V={},W=null)=>A({...V,style:{...V.style,[De.arrowSize.var]:m?`${m}px`:void 0,[De.arrowShadowColor.var]:h}},W),[A,m,h]),se=b.useCallback((V={},W=null)=>{const Q={...V.style,position:"relative",transformOrigin:De.transformOrigin.varRef};return{ref:W,...C,...V,id:z,role:"tooltip",style:Q}},[C,z]);return{isOpen:k,show:ae,hide:_,getTriggerProps:Y,getTooltipProps:se,getTooltipPositionerProps:J,getArrowProps:$,getArrowInnerProps:q}}var to="chakra-ui:close-tooltip";function _d(t,e){return b.useEffect(()=>{const n=bo(t);return n.addEventListener(to,e),()=>n.removeEventListener(to,e)},[e,t]),()=>{const n=bo(t),r=ar(t);n.dispatchEvent(new r.CustomEvent(to))}}function Ed(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Cd(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var Sd=Z(ta.div),Lt=oe((t,e)=>{var n,r;const o=Wn("Tooltip",t),a=Qe(t),s=ea(),{children:i,label:l,shouldWrapChildren:c,"aria-label":u,hasArrow:d,bg:f,portalProps:p,background:m,backgroundColor:h,bgColor:y,motionProps:w,...g}=a,x=(r=(n=m??h)!=null?n:f)!=null?r:y;if(x){o.bg=x;const A=vl(s,"colors",x);o[De.arrowBg.var]=A}const E=kd({...g,direction:s.direction}),S=typeof i=="string"||c;let C;if(S)C=v.jsx(Z.span,{display:"inline-block",tabIndex:0,...E.getTriggerProps(),children:i});else{const A=b.Children.only(i);C=b.cloneElement(A,E.getTriggerProps(A.props,A.ref))}const k=!!u,j=E.getTooltipProps({},e),D=k?Ed(j,["role","id"]):j,F=Cd(j,["role","id"]);return l?v.jsxs(v.Fragment,{children:[C,v.jsx(yl,{children:E.isOpen&&v.jsx(ws,{...p,children:v.jsx(Z.div,{...E.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:v.jsxs(Sd,{variants:xd,initial:"exit",animate:"enter",exit:"exit",...w,...D,__css:o,children:[l,k&&v.jsx(Z.span,{srOnly:!0,...F,children:u}),d&&v.jsx(Z.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:v.jsx(Z.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):v.jsx(v.Fragment,{children:i})});Lt.displayName="Tooltip";let Jn;const Dd=new Uint8Array(16);function jd(){if(!Jn&&(Jn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Jn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Jn(Dd)}const Ne=[];for(let t=0;t<256;++t)Ne.push((t+256).toString(16).slice(1));function Od(t,e=0){return Ne[t[e+0]]+Ne[t[e+1]]+Ne[t[e+2]]+Ne[t[e+3]]+"-"+Ne[t[e+4]]+Ne[t[e+5]]+"-"+Ne[t[e+6]]+Ne[t[e+7]]+"-"+Ne[t[e+8]]+Ne[t[e+9]]+"-"+Ne[t[e+10]]+Ne[t[e+11]]+Ne[t[e+12]]+Ne[t[e+13]]+Ne[t[e+14]]+Ne[t[e+15]]}const Id=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Qa={randomUUID:Id};function Pn(t,e,n){if(Qa.randomUUID&&!e&&!t)return Qa.randomUUID();t=t||{};const r=t.random||(t.rng||jd)();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 Od(r)}async function Pd(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 Nd(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 pi(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 hi(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 Fd(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 Zp(){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 Qp(){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 eh(){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)}}const Ad="backup",gr="workspace";let Gn=null;function Md(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(gr)||o.createObjectStore(gr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function Rd(){try{return Gn==null&&(Gn=await Md()),new Promise((t,e)=>{if(Gn==null)return e("indexDB is null");const o=Gn.transaction([gr],"readonly").objectStore(gr).get(Ad);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 Td(){try{return await Rd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const ve=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,je=Object.keys,Re=Array.isArray;function Be(t,e){return typeof e!="object"||je(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||ve.Promise||(ve.Promise=Promise);const Nn=Object.getPrototypeOf,Ld={}.hasOwnProperty;function He(t,e){return Ld.call(t,e)}function un(t,e){typeof e=="function"&&(e=e(Nn(t))),(typeof Reflect>"u"?je:Reflect.ownKeys)(e).forEach(n=>{mt(t,n,e[n])})}const mi=Object.defineProperty;function mt(t,e,n,r){mi(t,e,Be(n&&He(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function tn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),mt(t.prototype,"constructor",t),{extend:un.bind(null,t.prototype)}}}}const Wd=Object.getOwnPropertyDescriptor;function xa(t,e){let n;return Wd(t,e)||(n=Nn(t))&&xa(n,e)}const Bd=[].slice;function wr(t,e,n){return Bd.call(t,e,n)}function vi(t,e){return e(t)}function gn(t){if(!t)throw new Error("Assertion Failed")}function yi(t){ve.setImmediate?setImmediate(t):setTimeout(t,0)}function gi(t,e){return t.reduce((n,r,o)=>{var a=e(r,o);return a&&(n[a[0]]=a[1]),n},{})}function vt(t,e){if(He(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=>ve[t]),Kd=xi.map(t=>ve[t]);gi(xi,t=>[t,!0]);let xt=null;function zn(t){xt=typeof WeakMap<"u"&&new WeakMap;const e=xo(t);return xt=null,e}function xo(t){if(!t||typeof t!="object")return t;let e=xt&&xt.get(t);if(e)return e;if(Re(t)){e=[],xt&&xt.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const a=Nn(t);for(var o in e=a===Object.prototype?{}:Object.create(a),xt&&xt.set(t,e),t)He(t,o)&&(e[o]=xo(t[o]))}return e}const{toString:Ud}={};function ko(t){return Ud.call(t).slice(8,-1)}const _o=typeof Symbol<"u"?Symbol.iterator:"@@iterator",zd=typeof _o=="symbol"?function(t){var e;return t!=null&&(e=t[_o])&&e.apply(t)}:function(){return null},Qt={};function dt(t){var e,n,r,o;if(arguments.length===1){if(Re(t))return t.slice();if(this===Qt&&typeof t=="string")return[t];if(o=zd(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 ka=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var lt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ki(t,e){lt=t,_i=e}var _i=()=>!0;const qd=!new Error("").stack;function Ht(){if(qd)try{throw Ht.arguments,new Error}catch(t){return t}return new Error}function Eo(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(_i).map(r=>` -`+r).join("")):""}var Ei=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],_a=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ei),Vd={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 nn(t,e){this._e=Ht(),this.name=t,this.message=e}function Ci(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` -`)}function br(t,e,n,r){this._e=Ht(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Ci(t,e)}function En(t,e){this._e=Ht(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Ci(t,e)}tn(nn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Eo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),tn(br).from(nn),tn(En).from(nn);var Ea=_a.reduce((t,e)=>(t[e]=e+"Error",t),{});const Hd=nn;var U=_a.reduce((t,e)=>{var n=e+"Error";function r(o,a){this._e=Ht(),this.name=n,o?typeof o=="string"?(this.message=`${o}${a?` - `+a:""}`,this.inner=a||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=Vd[e]||n,this.inner=null)}return tn(r).from(Hd),t[e]=r,t},{});U.Syntax=SyntaxError,U.Type=TypeError,U.Range=RangeError;var es=Ei.reduce((t,e)=>(t[e+"Error"]=U[e],t),{}),sr=_a.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=U[e]),t),{});function fe(){}function Fn(t){return t}function Jd(t,e){return t==null||t===Fn?e:function(n){return e(t(n))}}function zt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Gd(t,e){return t===fe?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 a=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?zt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?zt(o,this.onerror):o),a!==void 0?a:n}}function Yd(t,e){return t===fe?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?zt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?zt(r,this.onerror):r)}}function Xd(t,e){return t===fe?e:function(n){var r=t.apply(this,arguments);Be(n,r);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?zt(o,this.onsuccess):o),a&&(this.onerror=this.onerror?zt(a,this.onerror):a),r===void 0?s===void 0?void 0:s:Be(r,s)}}function Zd(t,e){return t===fe?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ca(t,e){return t===fe?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,o=arguments.length,a=new Array(o);o--;)a[o]=arguments[o];return n.then(function(){return e.apply(r,a)})}return e.apply(this,arguments)}}sr.ModifyError=br,sr.DexieError=nn,sr.BulkError=En;var An={};const Si=100,[Co,xr,So]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Nn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Nn(e),t]})(),Di=xr&&xr.then,ir=Co&&Co.constructor,Sa=!!So;var Do=!1,Qd=So?()=>{So.then(Yn)}:ve.setImmediate?setImmediate.bind(null,Yn):ve.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Yn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Yn,0)},Cn=function(t,e){wn.push([t,e]),kr&&(Qd(),kr=!1)},jo=!0,kr=!0,Wt=[],lr=[],Oo=null,Io=Fn,rn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:rs,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{rs(t[0],t[1])}catch{}})}},B=rn,wn=[],Bt=0,cr=[];function R(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=fe,this._lib=!1;var e=this._PSD=B;if(lt&&(this._stackHolder=Ht(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==An)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&No(this,this._value))}this._state=null,this._value=null,++e.ref,Oi(this,t)}const Po={get:function(){var t=B,e=_r;function n(r,o){var a=!t.global&&(t!==B||e!==_r);const s=a&&!gt();var i=new R((l,c)=>{Da(this,new ji(Er(r,t,a,s),Er(o,t,a,s),l,c,t))});return lt&&Ni(i,this),i}return n.prototype=An,n},set:function(t){mt(this,"then",t&&t.prototype===An?Po:{get:function(){return t},set:Po.set})}};function ji(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 Oi(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&&qn();n&&typeof n.then=="function"?Oi(t,(o,a)=>{n instanceof R?n._then(o,a):n.then(o,a)}):(t._state=!0,t._value=n,Ii(t)),r&&Vn()}},No.bind(null,t))}catch(n){No(t,n)}}function No(t,e){if(lr.push(e),t._state===null){var n=t._lib&&qn();e=Io(e),t._state=!1,t._value=e,lt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,a){try{r.apply(null,a)}catch(s){o&&o(s)}}(()=>{var r=xa(e,"stack");e._promise=t,mt(e,"stack",{get:()=>Do?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Wt.some(o=>o._value===r._value)||Wt.push(r)}(t),Ii(t),n&&Vn()}}function Ii(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Bt==0&&ja()},[]))}function Da(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,++Bt,Cn(ef,[n,t,e])}else t._listeners.push(e)}function ef(t,e,n){try{Oo=e;var r,o=e._value;e._state?r=t(o):(lr.length&&(lr=[]),r=t(o),lr.indexOf(o)===-1&&function(a){for(var s=Wt.length;s;)if(Wt[--s]._value===a._value)return void Wt.splice(s,1)}(e)),n.resolve(r)}catch(a){n.reject(a)}finally{Oo=null,--Bt==0&&ja(),--n.psd.ref||n.psd.finalize()}}function Pi(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var o,a,s=t._value;s!=null?(o=s.name||"Error",a=s.message||s,r=Eo(s,0)):(o=s,a=""),e.push(o+(a?": "+a:"")+r)}return lt&&((r=Eo(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Pi(t._prev,e,n)),e}function Ni(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Yn(){qn()&&Vn()}function qn(){var t=jo;return jo=!1,kr=!1,t}function Vn(){var t,e,n;do for(;wn.length>0;)for(t=wn,wn=[],n=t.length,e=0;e0);jo=!0,kr=!0}function ja(){var t=Wt;Wt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=cr.slice(0),n=e.length;n;)e[--n]()}function Xn(t){return new R(An,!1,t)}function we(t,e){var n=B;return function(){var r=qn(),o=B;try{return St(n,!0),t.apply(this,arguments)}catch(a){e&&e(a)}finally{St(o,!1),r&&Vn()}}}un(R.prototype,{then:Po,_then:function(t,e){Da(this,new ji(null,null,t,e,B))},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):Xn(r)):this.then(null,r=>r&&r.name===e?n(r):Xn(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Xn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Do=!0;var t=Pi(this,[],20).join(` -From previous: `);return this._state!==null&&(this._stack=t),t}finally{Do=!1}}},timeout:function(t,e){return t<1/0?new R((n,r)=>{var o=setTimeout(()=>r(new U.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&mt(R.prototype,Symbol.toStringTag,"Dexie.Promise"),rn.env=Fi(),un(R,{all:function(){var t=dt.apply(null,arguments).map(Zn);return new R(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,a)=>R.resolve(o).then(s=>{t[a]=s,--r||e(t)},n))})},resolve:t=>{if(t instanceof R)return t;if(t&&typeof t.then=="function")return new R((n,r)=>{t.then(n,r)});var e=new R(An,!0,t);return Ni(e,Oo),e},reject:Xn,race:function(){var t=dt.apply(null,arguments).map(Zn);return new R((e,n)=>{t.map(r=>R.resolve(r).then(e,n))})},PSD:{get:()=>B,set:t=>B=t},totalEchoes:{get:()=>_r},newPSD:Ct,usePSD:hn,scheduler:{get:()=>Cn,set:t=>{Cn=t}},rejectionMapper:{get:()=>Io,set:t=>{Io=t}},follow:(t,e)=>new R((n,r)=>Ct((o,a)=>{var s=B;s.unhandleds=[],s.onunhandled=a,s.finalize=zt(function(){(function(i){function l(){i(),cr.splice(cr.indexOf(l),1)}cr.push(l),++Bt,Cn(()=>{--Bt==0&&ja()},[])})(()=>{this.unhandleds.length===0?o():a(this.unhandleds[0])})},s.finalize),t()},e,n,r))}),ir&&(ir.allSettled&&mt(R,"allSettled",function(){const t=dt.apply(null,arguments).map(Zn);return new R(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,a)=>R.resolve(o).then(s=>r[a]={status:"fulfilled",value:s},s=>r[a]={status:"rejected",reason:s}).then(()=>--n||e(r)))})}),ir.any&&typeof AggregateError<"u"&&mt(R,"any",function(){const t=dt.apply(null,arguments).map(Zn);return new R((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((a,s)=>R.resolve(a).then(i=>e(i),i=>{o[s]=i,--r||n(new AggregateError(o))}))})}));const Me={awaits:0,echoes:0,id:0};var tf=0,ur=[],no=0,_r=0,nf=0;function Ct(t,e,n,r){var o=B,a=Object.create(o);a.parent=o,a.ref=0,a.global=!1,a.id=++nf;var s=rn.env;a.env=Sa?{Promise:R,PromiseProp:{value:R,configurable:!0,writable:!0},all:R.all,race:R.race,allSettled:R.allSettled,any:R.any,resolve:R.resolve,reject:R.reject,nthen:ts(s.nthen,a),gthen:ts(s.gthen,a)}:{},e&&Be(a,e),++o.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var i=hn(a,t,n,r);return a.ref===0&&a.finalize(),i}function pn(){return Me.id||(Me.id=++tf),++Me.awaits,Me.echoes+=Si,Me.id}function gt(){return!!Me.awaits&&(--Me.awaits==0&&(Me.id=0),Me.echoes=Me.awaits*Si,!0)}function Zn(t){return Me.echoes&&t&&t.constructor===ir?(pn(),t.then(e=>(gt(),e),e=>(gt(),Pe(e)))):t}function rf(t){++_r,Me.echoes&&--Me.echoes!=0||(Me.echoes=Me.id=0),ur.push(B),St(t,!0)}function of(){var t=ur[ur.length-1];ur.pop(),St(t,!1)}function St(t,e){var n=B;if((e?!Me.echoes||no++&&t===B:!no||--no&&t===B)||Ai(e?rf.bind(null,t):of),t!==B&&(B=t,n===rn&&(rn.env=Fi()),Sa)){var r=rn.env.Promise,o=t.env;xr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(ve,"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 Fi(){var t=ve.Promise;return Sa?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(ve,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:xr.then,gthen:t.prototype.then}:{}}function hn(t,e,n,r,o){var a=B;try{return St(t,!0),e(n,r,o)}finally{St(a,!1)}}function Ai(t){Di.call(Co,t)}function Er(t,e,n,r){return typeof t!="function"?t:function(){var o=B;n&&pn(),St(e,!0);try{return t.apply(this,arguments)}finally{St(o,!1),r&&Ai(gt)}}}function ts(t,e){return function(n,r){return t.call(this,Er(n,e),Er(r,e))}}(""+Di).indexOf("[native code]")===-1&&(pn=gt=fe);const ns="unhandledrejection";function rs(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(ve.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ns,!0,!0),Be(r,o)):ve.CustomEvent&&Be(r=new CustomEvent(ns,{detail:o}),o),r&&ve.dispatchEvent&&(dispatchEvent(r),!ve.PromiseRejectionEvent&&ve.onunhandledrejection))try{ve.onunhandledrejection(r)}catch{}lt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Pe=R.reject;function Fo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||B.letThrough||t._vip)){var o=t._createTransaction(e,n,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(a){return a.name===Ea.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Fo(t,e,n,r))):Pe(a)}return o._promise(e,(a,s)=>Ct(()=>(B.trans=o,r(a,s,o)))).then(a=>o._completion.then(()=>a))}if(t._state.openComplete)return Pe(new U.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Pe(new U.DatabaseClosed);t.open().catch(fe)}return t._state.dbReadyPromise.then(()=>Fo(t,e,n,r))}const os="3.2.4",At="￿",Ao=-1/0,ct="Invalid key provided. Keys must be of type string, number, Date or Array.",Mi="String expected.",Sn=[],Hr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),af=Hr,sf=Hr,Ri=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Jr="__dbnames",ro="readonly",oo="readwrite";function qt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Ti={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Qn(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=zn(e))[t],e)}class lf{_trans(e,n,r){const o=this._tx||B.trans,a=this.name;function s(l,c,u){if(!u.schema[a])throw new U.NotFound("Table "+a+" not part of transaction");return n(u.idbtrans,u)}const i=qn();try{return o&&o.db===this.db?o===B.trans?o._promise(e,s,r):Ct(()=>o._promise(e,s,r),{trans:o,transless:B.transless||B}):Fo(this.db,e,[this.name],s)}finally{i&&Vn()}}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(Re(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=je(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==At)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&<&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,a=this.db._deps.indexedDB;function s(c,u){try{return a.cmp(c,u)===0}catch{return!1}}const[i,l]=n.reduce(([c,u],d)=>{const f=o[d],p=e[d];return[c||f,c||!f?qt(u,f&&f.multi?m=>{const h=vt(m,d);return Re(h)&&h.some(y=>s(p,y))}:m=>s(p,vt(m,d))):u]},[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,Re(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 a in r)if(He(r,a))try{o[a]=r[a]}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){Be(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let a=e;return o&&r&&(a=Qn(o)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:n!=null?[n]:null,values:[a]})).then(s=>s.numFailures?R.reject(s.failures[0]):s.lastResult).then(s=>{if(o)try{nt(e,o,s)}catch{}return s})}update(e,n){if(typeof e!="object"||Re(e))return this.where(":id").equals(e).modify(n);{const r=vt(e,this.schema.primKey.keyPath);if(r===void 0)return Pe(new U.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?je(n).forEach(o=>{nt(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let a=e;return o&&r&&(a=Qn(o)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[a],keys:n!=null?[n]:null})).then(s=>s.numFailures?R.reject(s.failures[0]):s.lastResult).then(s=>{if(o)try{nt(e,o,s)}catch{}return s})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?R.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Ti})).then(e=>e.numFailures?R.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,a=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",s=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new U.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&i?e.map(Qn(l)):e;return this.core.mutate({trans:s,type:"add",keys:o,values:u,wantResults:a}).then(({numFailures:d,results:f,lastResult:p,failures:m})=>{if(d===0)return a?f:p;throw new En(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,m)})})}bulkPut(e,n,r){const o=Array.isArray(n)?n:void 0,a=(r=r||(o?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",s=>{const{auto:i,keyPath:l}=this.schema.primKey;if(l&&o)throw new U.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&i?e.map(Qn(l)):e;return this.core.mutate({trans:s,type:"put",keys:o,values:u,wantResults:a}).then(({numFailures:d,results:f,lastResult:p,failures:m})=>{if(d===0)return a?f:p;throw new En(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,m)})})}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:a})=>{if(r===0)return o;throw new En(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,a)})}}function Dn(t){var e={},n=function(s,i){if(i){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[s].subscribe.apply(null,c),t}if(typeof s=="string")return e[s]};n.addEventType=a;for(var r=1,o=arguments.length;rqt(r(),e()):e,t.justLimit=n&&!r}function dr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new U.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function as(t,e,n){const r=dr(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 er(t,e,n,r){const o=t.replayFilter?qt(t.filter,t.replayFilter()):t.filter;if(t.or){const a={},s=(i,l,c)=>{if(!o||o(l,c,f=>l.stop(f),f=>l.fail(f))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),He(a,d)||(a[d]=!0,e(i,l,c))}};return Promise.all([t.or._iterate(s,n),ss(as(t,r,n),t.algorithm,s,!t.keysOnly&&t.valueMapper)])}return ss(as(t,r,n),qt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ss(t,e,n,r){var o=we(r?(a,s,i)=>n(r(a),s,i):n);return t.then(a=>{if(a)return a.start(()=>{var s=()=>a.continue();e&&!e(a,i=>s=i,i=>{a.stop(i),s=fe},i=>{a.fail(i),s=fe})||o(a.value,a,i=>s=i),s()})})}function We(t,e){try{const n=is(t),r=is(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:ter(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Xt(r,!0))return o.count({trans:n,query:{index:dr(r,o.schema),range:r.range}}).then(s=>Math.min(s,r.limit));var a=0;return er(r,()=>(++a,!1),n,o).then(()=>a)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),o=r[0],a=r.length-1;function s(c,u){return u?s(c[r[u]],u-1):c[o]}var i=this._ctx.dir==="next"?1:-1;function l(c,u){var d=s(c,a),f=s(u,a);return df?i:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Xt(r,!0)&&r.limit>0){const{valueMapper:o}=r,a=dr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:a,range:r.range}}).then(({result:s})=>o?s.map(o):s)}{const o=[];return er(r,a=>o.push(a),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Xt(n)?so(n,()=>{var r=e;return(o,a)=>r===0||(r===1?(--r,!1):(a(()=>{o.advance(r),r=0}),!1))}):so(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),so(this._ctx,()=>{var n=e;return function(r,o,a){return--n<=0&&o(a),n>=0}},!0),this}until(e,n){return ao(this._ctx,function(r,o,a){return!e(r.value)||(o(a),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 ao(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=qt(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,a){r.push(a.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Xt(n,!0)&&n.limit>0)return this._read(o=>{var a=dr(n,n.table.core.schema);return n.table.core.query({trans:o,values:!1,limit:n.limit,query:{index:a,range:n.range}})}).then(({result:o})=>o).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,a){r.push(a.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 ao(this._ctx,function(o){var a=o.primaryKey.toString(),s=He(r,a);return r[a]=!0,!s}),this}modify(e){var n=this._ctx;return this._write(r=>{var o;if(typeof e=="function")o=e;else{var a=je(e),s=a.length;o=function(h){for(var y=!1,w=0;w{const{failures:w,numFailures:g}=y;f+=h-g;for(let x of je(w))d.push(w[x])};return this.clone().primaryKeys().then(h=>{const y=w=>{const g=Math.min(u,h.length-w);return i.getMany({trans:r,keys:h.slice(w,w+g),cache:"immutable"}).then(x=>{const E=[],S=[],C=l?[]:null,k=[];for(let D=0;D0&&i.mutate({trans:r,type:"add",values:E}).then(D=>{for(let F in D.failures)k.splice(parseInt(F),1);m(E.length,D)})).then(()=>(S.length>0||j&&typeof e=="object")&&i.mutate({trans:r,type:"put",keys:C,values:S,criteria:j,changeSpec:typeof e!="function"&&e}).then(D=>m(S.length,D))).then(()=>(k.length>0||j&&e===io)&&i.mutate({trans:r,type:"delete",keys:k,criteria:j}).then(D=>m(k.length,D))).then(()=>h.length>w+g&&y(w+u))})};return y(0).then(()=>{if(d.length>0)throw new br("Error modifying one or more objects",d,f,p);return h.length})})})}delete(){var e=this._ctx,n=e.range;return Xt(e)&&(e.isPrimKey&&!sf||n.type===3)?this._write(r=>{const{primaryKey:o}=e.table.core.schema,a=n;return e.table.core.count({trans:r,query:{index:o,range:a}}).then(s=>e.table.core.mutate({trans:r,type:"deleteRange",range:a}).then(({failures:i,lastResult:l,results:c,numFailures:u})=>{if(u)throw new br("Could not delete some values",Object.keys(i).map(d=>i[d]),s-u);return s-u}))}):this.modify(io)}}const io=(t,e)=>e.value=null;function uf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Wi?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Zt(t){return new t.Collection(t,()=>Li("")).limit(0)}function ff(t,e,n,r,o,a){for(var s=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],c)<0&&(i=l)}return stypeof h=="string"))return qe(t,Mi);function f(h){o=function(w){return w==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(h),a=function(w){return w==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(h),s=h==="next"?uf:df;var y=n.map(function(w){return{lower:a(w),upper:o(w)}}).sort(function(w,g){return s(w.lower,g.lower)});i=y.map(function(w){return w.upper}),l=y.map(function(w){return w.lower}),c=h,u=h==="next"?"":r}f("next");var p=new t.Collection(t,()=>bt(i[0],l[d-1]+r));p._ondirectionchange=function(h){f(h)};var m=0;return p._addAlgorithm(function(h,y,w){var g=h.key;if(typeof g!="string")return!1;var x=a(g);if(e(x,l,m))return!0;for(var E=null,S=m;S0)&&(E=C)}return y(E!==null?function(){h.continue(E+u)}:w),!1}),p}function bt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Li(t){return{type:1,lower:t,upper:t}}class Wi{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)?Zt(this):new this.Collection(this,()=>bt(e,n,!r,!o))}catch{return qe(this,ct)}}equals(e){return e==null?qe(this,ct):new this.Collection(this,()=>Li(e))}above(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(e,void 0,!1))}below(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Mi):this.between(e,e+At,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):tr(this,(n,r)=>n.indexOf(r[0])===0,[e],At)}equalsIgnoreCase(e){return tr(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=dt.apply(Qt,arguments);return e.length===0?Zt(this):tr(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=dt.apply(Qt,arguments);return e.length===0?Zt(this):tr(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,At)}anyOf(){const e=dt.apply(Qt,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ct)}if(e.length===0)return Zt(this);const r=new this.Collection(this,()=>bt(e[0],e[e.length-1]));r._ondirectionchange=a=>{n=a==="next"?this._ascending:this._descending,e.sort(n)};let o=0;return r._addAlgorithm((a,s,i)=>{const l=a.key;for(;n(l,e[o])>0;)if(++o,o===e.length)return s(i),!1;return n(l,e[o])===0||(s(()=>{a.continue(e[o])}),!1)}),r}notEqual(e){return this.inAnyRange([[Ao,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=dt.apply(Qt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ct)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Ao,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,a=this._descending,s=this._min,i=this._max;if(e.length===0)return Zt(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&o(g[0],g[1])<=0))return qe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",U.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function f(g,x){return d(g[0],x[0])}try{u=e.reduce(function(g,x){let E=0,S=g.length;for(;E0){C[0]=s(C[0],x[0]),C[1]=i(C[1],x[1]);break}}return E===S&&g.push(x),g},[]),u.sort(f)}catch{return qe(this,ct)}let p=0;const m=c?g=>o(g,u[p][1])>0:g=>o(g,u[p][1])>=0,h=l?g=>a(g,u[p][0])>0:g=>a(g,u[p][0])>=0;let y=m;const w=new this.Collection(this,()=>bt(u[0][0],u[u.length-1][1],!l,!c));return w._ondirectionchange=g=>{g==="next"?(y=m,d=o):(y=h,d=a),u.sort(f)},w._addAlgorithm((g,x,E)=>{for(var S=g.key;y(S);)if(++p,p===u.length)return x(E),!1;return!!function(C){return!m(C)&&!h(C)}(S)||(this._cmp(S,u[p][1])===0||this._cmp(S,u[p][0])===0||x(()=>{d===o?g.continue(u[p][0]):g.continue(u[p][1])}),!1)}),w}startsWithAnyOf(){const e=dt.apply(Qt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Zt(this):this.inAnyRange(e.map(n=>[n,n+At])):qe(this,"startsWithAnyOf() only works with strings")}}function at(t){return we(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Rn="storagemutated",kt="x-storagemutated-1",Dt=Dn(null,Rn);class pf{_lock(){return gn(!B.global),++this._reculock,this._reculock!==1||B.global||(B.lockOwnerFor=this),this}_unlock(){if(gn(!B.global),--this._reculock==0)for(B.global||(B.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{hn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&B.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(gn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new U.DatabaseClosed(r);case"MissingAPIError":throw new U.MissingAPI(r.message,r);default:throw new U.OpenFailed(r)}if(!this.active)throw new U.TransactionInactive;return gn(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=we(o=>{Mn(o),this._reject(e.error)}),e.onabort=we(o=>{Mn(o),this.active&&this._reject(new U.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=we(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Dt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Pe(new U.ReadOnly("Transaction is readonly"));if(!this.active)return Pe(new U.TransactionInactive);if(this._locked())return new R((a,s)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(a,s)},B])});if(r)return Ct(()=>{var a=new R((s,i)=>{this._lock();const l=n(s,i,this);l&&l.then&&l.then(s,i)});return a.finally(()=>this._unlock()),a._lib=!0,a});var o=new R((a,s)=>{var i=n(a,s,this);i&&i.then&&i.then(a,s)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=R.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 s(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=s)})()}var a=n._waitingFor;return new R((s,i)=>{r.then(l=>n._waitingQueue.push(we(s.bind(null,l))),l=>n._waitingQueue.push(we(i.bind(null,l)))).finally(()=>{n._waitingFor===a&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new U.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(He(n,e))return n[e];const r=this.schema[e];if(!r)throw new U.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 Mo(t,e,n,r,o,a,s){return{name:t,keyPath:e,unique:n,multi:r,auto:o,compound:a,src:(n&&!s?"&":"")+(r?"*":"")+(o?"++":"")+Bi(e)}}function Bi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function $i(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:gi(n,r=>[r.name,r])}}let Tn=t=>{try{return t.only([[]]),Tn=()=>[[]],[[]]}catch{return Tn=()=>At,At}};function Ro(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>vt(r,e)}(t):e=>vt(e,t)}function cs(t){return[].slice.call(t)}let hf=0;function jn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function mf(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:f}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!f):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!f)}const{schema:o,hasGetAll:a}=function(l,c){const u=cs(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:f,autoIncrement:p}=d,m=Re(f),h=f==null,y={},w={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:m,keyPath:f,autoIncrement:p,unique:!0,extractKey:Ro(f)},indexes:cs(d.indexNames).map(g=>d.index(g)).map(g=>{const{name:x,unique:E,multiEntry:S,keyPath:C}=g,k={name:x,compound:Re(C),keyPath:C,unique:E,multiEntry:S,extractKey:Ro(C)};return y[jn(C)]=k,k}),getIndexByKeyPath:g=>y[jn(g)]};return y[":id"]=w.primaryKey,f!=null&&(y[jn(f)]=w.primaryKey),w})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),s=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:f,keys:p,values:m,range:h}){return new Promise((y,w)=>{y=we(y);const g=d.objectStore(u),x=g.keyPath==null,E=f==="put"||f==="add";if(!E&&f!=="delete"&&f!=="deleteRange")throw new Error("Invalid operation type: "+f);const{length:S}=p||m||{length:1};if(p&&m&&p.length!==m.length)throw new Error("Given keys array must have same length as given values array.");if(S===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const k=[],j=[];let D=0;const F=q=>{++D,Mn(q)};if(f==="deleteRange"){if(h.type===4)return y({numFailures:D,failures:j,results:[],lastResult:void 0});h.type===3?k.push(C=g.clear()):k.push(C=g.delete(r(h)))}else{const[q,$]=E?x?[m,p]:[m,null]:[p,null];if(E)for(let K=0;K{const $=q.target.result;k.forEach((K,le)=>K.error!=null&&(j[le]=K.error)),y({numFailures:D,failures:j,results:f==="delete"?p:k.map(K=>K.result),lastResult:$})};C.onerror=q=>{F(q),A(q)},C.onsuccess=A})},getMany:({trans:d,keys:f})=>new Promise((p,m)=>{p=we(p);const h=d.objectStore(u),y=f.length,w=new Array(y);let g,x=0,E=0;const S=k=>{const j=k.target;w[j._pos]=j.result,++E===x&&p(w)},C=at(m);for(let k=0;knew Promise((p,m)=>{p=we(p);const h=d.objectStore(u).get(f);h.onsuccess=y=>p(y.target.result),h.onerror=at(m)}),query:function(d){return f=>new Promise((p,m)=>{p=we(p);const{trans:h,values:y,limit:w,query:g}=f,x=w===1/0?void 0:w,{index:E,range:S}=g,C=h.objectStore(u),k=E.isPrimaryKey?C:C.index(E.name),j=r(S);if(w===0)return p({result:[]});if(d){const D=y?k.getAll(j,x):k.getAllKeys(j,x);D.onsuccess=F=>p({result:F.target.result}),D.onerror=at(m)}else{let D=0;const F=y||!("openKeyCursor"in k)?k.openCursor(j):k.openKeyCursor(j),A=[];F.onsuccess=q=>{const $=F.result;return $?(A.push(y?$.value:$.primaryKey),++D===w?p({result:A}):void $.continue()):p({result:A})},F.onerror=at(m)}})}(a),openCursor:function({trans:d,values:f,query:p,reverse:m,unique:h}){return new Promise((y,w)=>{y=we(y);const{index:g,range:x}=p,E=d.objectStore(u),S=g.isPrimaryKey?E:E.index(g.name),C=m?h?"prevunique":"prev":h?"nextunique":"next",k=f||!("openKeyCursor"in S)?S.openCursor(r(x),C):S.openKeyCursor(r(x),C);k.onerror=at(w),k.onsuccess=we(j=>{const D=k.result;if(!D)return void y(null);D.___id=++hf,D.done=!1;const F=D.continue.bind(D);let A=D.continuePrimaryKey;A&&(A=A.bind(D));const q=D.advance.bind(D),$=()=>{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=we(w),D.next=function(){let K=1;return this.start(()=>K--?this.continue():this.stop()).then(()=>this)},D.start=K=>{const le=new Promise((I,X)=>{I=we(I),k.onerror=at(X),D.fail=X,D.stop=re=>{D.stop=D.continue=D.continuePrimaryKey=D.advance=$,I(re)}}),z=()=>{if(k.result)try{K()}catch(I){D.fail(I)}else D.done=!0,D.start=()=>{throw new Error("Cursor behind last entry")},D.stop()};return k.onsuccess=we(I=>{k.onsuccess=z,z()}),D.continue=F,D.continuePrimaryKey=A,D.advance=q,z(),le},y(D)},w)})},count({query:d,trans:f}){const{index:p,range:m}=d;return new Promise((h,y)=>{const w=f.objectStore(u),g=p.isPrimaryKey?w:w.index(p.name),x=r(m),E=x?g.count(x):g.count();E.onsuccess=we(S=>h(S.target.result)),E.onerror=at(y)})}}}(l)),i={};return s.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:Tn(e),schema:o}}function To({_novip:t},e){const n=e.db,r=function(o,a,{IDBKeyRange:s,indexedDB:i},l){return{dbcore:function(u,d){return d.reduce((f,{create:p})=>({...f,...p(f)}),u)}(mf(a,s,l),o.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(o=>{const a=o.name;t.core.schema.tables.some(s=>s.name===a)&&(o.core=t.core.table(a),t[a]instanceof t.Table&&(t[a].core=o.core))})}function Cr({_novip:t},e,n,r){n.forEach(o=>{const a=r[o];e.forEach(s=>{const i=xa(s,o);(!i||"value"in i&&i.value===void 0)&&(s===t.Transaction.prototype||s instanceof t.Transaction?mt(s,o,{get(){return this.table(o)},set(l){mi(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):s[o]=new t.Table(o,a))})})}function Lo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function vf(t,e){return t._cfg.version-e._cfg.version}function yf(t,e,n,r){const o=t._dbSchema,a=t._createTransaction("readwrite",t._storeNames,o);a.create(n),a._completion.catch(r);const s=a._reject.bind(a),i=B.transless||B;Ct(()=>{B.trans=a,B.transless=i,e===0?(je(o).forEach(l=>{lo(n,l,o[l].primKey,o[l].indexes)}),To(t,n),R.follow(()=>t.on.populate.fire(a)).catch(s)):function({_novip:l},c,u,d){const f=[],p=l._versions;let m=l._dbSchema=Bo(l,l.idbdb,d),h=!1;const y=p.filter(g=>g._cfg.version>=c);function w(){return f.length?R.resolve(f.shift()(u.idbtrans)).then(w):R.resolve()}return y.forEach(g=>{f.push(()=>{const x=m,E=g._cfg.dbschema;$o(l,x,d),$o(l,E,d),m=l._dbSchema=E;const S=Ki(x,E);S.add.forEach(k=>{lo(d,k[0],k[1].primKey,k[1].indexes)}),S.change.forEach(k=>{if(k.recreate)throw new U.Upgrade("Not yet support for changing primary key");{const j=d.objectStore(k.name);k.add.forEach(D=>Wo(j,D)),k.change.forEach(D=>{j.deleteIndex(D.name),Wo(j,D)}),k.del.forEach(D=>j.deleteIndex(D))}});const C=g._cfg.contentUpgrade;if(C&&g._cfg.version>c){To(l,d),u._memoizedTables={},h=!0;let k=wi(E);S.del.forEach(A=>{k[A]=x[A]}),Lo(l,[l.Transaction.prototype]),Cr(l,[l.Transaction.prototype],je(k),k),u.schema=k;const j=ka(C);let D;j&&pn();const F=R.follow(()=>{if(D=C(u),D&&j){var A=gt.bind(null,null);D.then(A,A)}});return D&&typeof D.then=="function"?R.resolve(D):F.then(()=>D)}}),f.push(x=>{(!h||!af)&&function(E,S){[].slice.call(S.db.objectStoreNames).forEach(C=>E[C]==null&&S.db.deleteObjectStore(C))}(g._cfg.dbschema,x),Lo(l,[l.Transaction.prototype]),Cr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),w().then(()=>{var g,x;x=d,je(g=m).forEach(E=>{x.db.objectStoreNames.contains(E)||lo(x,E,g[E].primKey,g[E].indexes)})})}(t,e,a,n).catch(s)})}function Ki(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],a=e[r];if(o){const s={name:r,def:a,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(a.primKey.keyPath||"")||o.primKey.auto!==a.primKey.auto&&!Hr)s.recreate=!0,n.change.push(s);else{const i=o.idxByName,l=a.idxByName;let c;for(c in i)l[c]||s.del.push(c);for(c in l){const u=i[c],d=l[c];u?u.src!==d.src&&s.change.push(d):s.add.push(d)}(s.del.length>0||s.add.length>0||s.change.length>0)&&n.change.push(s)}}else n.add.push([r,a])}return n}function lo(t,e,n,r){const o=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(a=>Wo(o,a)),o}function Wo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Bo(t,e,n){const r={};return wr(e.objectStoreNames,0).forEach(o=>{const a=n.objectStore(o);let s=a.keyPath;const i=Mo(Bi(s),s||"",!1,!1,!!a.autoIncrement,s&&typeof s!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((s,i)=>{const l=(s=s.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Mo(l,c||null,/\&/.test(s),/\*/.test(s),/\+\+/.test(s),Re(c),i===0)}),a=o.shift();if(a.multi)throw new U.Schema("Primary key cannot be multi-valued");o.forEach(s=>{if(s.auto)throw new U.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new U.Schema("Index must have a name and cannot be an empty string")}),n[r]=$i(r,a,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Be(this._cfg.storesSource,e):e;const r=n._versions,o={};let a={};return r.forEach(s=>{Be(o,s._cfg.storesSource),a=s._cfg.dbschema={},s._parseStoresSpec(o,a)}),n._dbSchema=a,Lo(n,[n._allTables,n,n.Transaction.prototype]),Cr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],je(a),a),n._storeNames=je(a),this}upgrade(e){return this._cfg.contentUpgrade=Ca(this._cfg.contentUpgrade||fe,e),this}}function Oa(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new $t(Jr,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ia(t){return t&&typeof t.databases=="function"}function Ko(t){return Ct(function(){return B.letThrough=!0,t()})}function wf(){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 bf(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Pe(e.dbOpenError):t);lt&&(e.openCanceller._stackHolder=Ht()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new U.DatabaseClosed("db.open() was cancelled")}let a=e.dbReadyResolve,s=null,i=!1;return R.race([r,(typeof navigator>"u"?R.resolve():wf()).then(()=>new R((l,c)=>{if(o(),!n)throw new U.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new U.MissingAPI;d.onerror=at(c),d.onblocked=we(t._fireOnBlocked),d.onupgradeneeded=we(f=>{if(s=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,s.abort(),d.result.close();const m=n.deleteDatabase(u);m.onsuccess=m.onerror=we(()=>{c(new U.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{s.onerror=at(c);var p=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;i=p<1,t._novip.idbdb=d.result,yf(t,p/10,s,c)}},c),d.onsuccess=we(()=>{s=null;const f=t._novip.idbdb=d.result,p=wr(f.objectStoreNames);if(p.length>0)try{const h=f.transaction((m=p).length===1?m[0]:m,"readonly");e.autoSchema?function({_novip:y},w,g){y.verno=w.version/10;const x=y._dbSchema=Bo(0,w,g);y._storeNames=wr(w.objectStoreNames,0),Cr(y,[y._allTables],je(x),x)}(t,f,h):($o(t,t._dbSchema,h),function(y,w){const g=Ki(Bo(0,y.idbdb,w),y._dbSchema);return!(g.add.length||g.change.some(x=>x.add.length||x.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),To(t,h)}catch{}var m;Sn.push(t),f.onversionchange=we(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),f.onclose=we(h=>{t.on("close").fire(h)}),i&&function({indexedDB:h,IDBKeyRange:y},w){!Ia(h)&&w!==Jr&&Oa(h,y).put({name:w}).catch(fe)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],R.resolve(Ko(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ca,fe);return e.onReadyBeingFired=[],R.resolve(Ko(()=>c(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{s&&s.abort()}catch{}return r===e.openCanceller&&t._close(),Pe(l)}).finally(()=>{e.openComplete=!0,a()})}function Uo(t){var e=a=>t.next(a),n=o(e),r=o(a=>t.throw(a));function o(a){return s=>{var i=a(s),l=i.value;return i.done?l:l&&typeof l.then=="function"?l.then(n,r):Re(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function xf(t,e,n){var r=arguments.length;if(r<2)throw new U.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,bi(o),n]}function Ui(t,e,n,r,o){return R.resolve().then(()=>{const a=B.transless||B,s=t._createTransaction(e,n,t._dbSchema,r),i={trans:s,transless:a};if(r)s.idbtrans=r.idbtrans;else try{s.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===Ea.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ui(t,e,n,null,o))):Pe(d)}const l=ka(o);let c;l&&pn();const u=R.follow(()=>{if(c=o.call(s,s),c)if(l){var d=gt.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Uo(c))},i);return(c&&typeof c.then=="function"?R.resolve(c).then(d=>s.active?d:Pe(new U.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&s._resolve(),s._completion.then(()=>d))).catch(d=>(s._reject(d),Pe(d)))})}function nr(t,e,n){const r=Re(t)?t.slice():[t];for(let o=0;o0,w={...f,isVirtual:y,keyTail:d,keyLength:h,extractKey:Ro(u),unique:!y&&f.unique};return m.push(w),w.isPrimaryKey||a.push(w),h>1&&s(h===2?u[0]:u.slice(0,h-1),d+1,f),m.sort((g,x)=>g.keyTail-x.keyTail),w}const i=s(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[i];for(const u of r.indexes)s(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(f=u.query.range,p=d.keyTail,{type:f.type===1?2:f.type,lower:nr(f.lower,f.lowerOpen?t.MAX_KEY:t.MIN_KEY,p),lowerOpen:!0,upper:nr(f.upper,f.upperOpen?t.MIN_KEY:t.MAX_KEY,p),upperOpen:!0})}}:u;var f,p}return{...n,schema:{...r,primaryKey:i,indexes:a,getIndexByKeyPath:function(u){const d=o[jn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:f,keyLength:p}=u.query.index;return f?n.openCursor(l(u)).then(m=>m&&function(h){return Object.create(h,{continue:{value:function(w){w!=null?h.continue(nr(w,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?h.continue(h.key.slice(0,p).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(w,g){h.continuePrimaryKey(nr(w,t.MAX_KEY,d),g)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const w=h.key;return p===1?w[0]:w.slice(0,p)}},value:{get:()=>h.value}})}(m)):n.openCursor(u)}}}}}};function Pa(t,e,n,r){return n=n||{},r=r||"",je(t).forEach(o=>{if(He(e,o)){var a=t[o],s=e[o];if(typeof a=="object"&&typeof s=="object"&&a&&s){const i=ko(a);i!==ko(s)?n[r+o]=e[o]:i==="Object"?Pa(a,s,n,r+o+"."):a!==s&&(n[r+o]=e[o])}else a!==s&&(n[r+o]=e[o])}else n[r+o]=void 0}),je(e).forEach(o=>{He(t,o)||(n[r+o]=e[o])}),n}const _f={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(a){const s=B.trans,{deleting:i,creating:l,updating:c}=s.table(e).hook;switch(a.type){case"add":if(l.fire===fe)break;return s._promise("readwrite",()=>u(a),!0);case"put":if(l.fire===fe&&c.fire===fe)break;return s._promise("readwrite",()=>u(a),!0);case"delete":if(i.fire===fe)break;return s._promise("readwrite",()=>u(a),!0);case"deleteRange":if(i.fire===fe)break;return s._promise("readwrite",()=>function(f){return d(f.trans,f.range,1e4)}(a),!0)}return n.mutate(a);function u(f){const p=B.trans,m=f.keys||function(h,y){return y.type==="delete"?y.keys:y.keys||y.values.map(h.extractKey)}(r,f);if(!m)throw new Error("Keys missing");return(f=f.type==="add"||f.type==="put"?{...f,keys:m}:{...f}).type!=="delete"&&(f.values=[...f.values]),f.keys&&(f.keys=[...f.keys]),function(h,y,w){return y.type==="add"?Promise.resolve([]):h.getMany({trans:y.trans,keys:w,cache:"immutable"})}(n,f,m).then(h=>{const y=m.map((w,g)=>{const x=h[g],E={onerror:null,onsuccess:null};if(f.type==="delete")i.fire.call(E,w,x,p);else if(f.type==="add"||x===void 0){const S=l.fire.call(E,w,f.values[g],p);w==null&&S!=null&&(w=S,f.keys[g]=w,r.outbound||nt(f.values[g],r.keyPath,w))}else{const S=Pa(x,f.values[g]),C=c.fire.call(E,S,w,x,p);if(C){const k=f.values[g];Object.keys(C).forEach(j=>{He(k,j)?k[j]=C[j]:nt(k,j,C[j])})}}return E});return n.mutate(f).then(({failures:w,results:g,numFailures:x,lastResult:E})=>{for(let S=0;S(y.forEach(g=>g.onerror&&g.onerror(w)),Promise.reject(w)))})}function d(f,p,m){return n.query({trans:f,values:!1,query:{index:r,range:p},limit:m}).then(({result:h})=>u({type:"delete",keys:h,trans:f}).then(y=>y.numFailures>0?Promise.reject(y.failures[0]):h.length({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const o=zi(r.keys,r.trans._cache,r.cache==="clone");return o?R.resolve(o):n.getMany(r).then(a=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?zn(a):a},a))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function Na(t){return!("from"in t)}const ut=function(t,e){if(!this){const n=new ut;return t&&"d"in t&&Be(n,t),n}Be(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Ln(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(Na(t))return Be(t,{from:e,to:n,d:1});const o=t.l,a=t.r;if(We(n,t.from)<0)return o?Ln(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},us(t);if(We(e,t.to)>0)return a?Ln(a,e,n):t.r={from:e,to:n,d:1,l:null,r:null},us(t);We(e,t.from)<0&&(t.from=e,t.l=null,t.d=a?a.d+1:1),We(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const s=!t.r;o&&!t.l&&Sr(t,o),a&&s&&Sr(t,a)}function Sr(t,e){Na(e)||function n(r,{from:o,to:a,l:s,r:i}){Ln(r,o,a),s&&n(r,s),i&&n(r,i)}(t,e)}function Cf(t,e){const n=zo(e);let r=n.next();if(r.done)return!1;let o=r.value;const a=zo(t);let s=a.next(o.from),i=s.value;for(;!r.done&&!s.done;){if(We(i.from,o.to)<=0&&We(i.to,o.from)>=0)return!0;We(o.from,i.from)<0?o=(r=n.next(i.from)).value:i=(s=a.next(o.from)).value}return!1}function zo(t){let e=Na(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&We(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||We(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function us(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 a=o==="r"?"l":"r",s={...t},i=t[o];t.from=i.from,t.to=i.to,t[o]=i[o],s[o]=i[a],t[a]=s,s.d=ds(s)}t.d=ds(t)}function ds({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}un(ut.prototype,{add(t){return Sr(this,t),this},addKey(t){return Ln(this,t,t),this},addKeys(t){return t.forEach(e=>Ln(this,e,e)),this},[_o](){return zo(this)}});const Sf={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new ut(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const o=t.table(r),{schema:a}=o,{primaryKey:s}=a,{extractKey:i,outbound:l}=s,c={...o,mutate:f=>{const p=f.trans,m=p.mutatedParts||(p.mutatedParts={}),h=C=>{const k=`idb://${e}/${r}/${C}`;return m[k]||(m[k]=new ut)},y=h(""),w=h(":dels"),{type:g}=f;let[x,E]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[];const S=f.trans._cache;return o.mutate(f).then(C=>{if(Re(x)){g!=="delete"&&(x=C.results),y.addKeys(x);const k=zi(x,S);k||g==="add"||w.addKeys(x),(k||E)&&function(j,D,F,A){function q($){const K=j($.name||"");function le(I){return I!=null?$.extractKey(I):null}const z=I=>$.multiEntry&&Re(I)?I.forEach(X=>K.addKey(X)):K.addKey(I);(F||A).forEach((I,X)=>{const re=F&&le(F[X]),he=A&&le(A[X]);We(re,he)!==0&&(re!=null&&z(re),he!=null&&z(he))})}D.indexes.forEach(q)}(h,a,k,E)}else if(x){const k={from:x.lower,to:x.upper};w.add(k),y.add(k)}else y.add(n),w.add(n),a.indexes.forEach(k=>h(k.name).add(n));return C})}},u=({query:{index:f,range:p}})=>{var m,h;return[f,new ut((m=p.lower)!==null&&m!==void 0?m:t.MIN_KEY,(h=p.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:f=>[s,new ut(f.key)],getMany:f=>[s,new ut().addKeys(f.keys)],count:u,query:u,openCursor:u};return je(d).forEach(f=>{c[f]=function(p){const{subscr:m}=B;if(m){const h=E=>{const S=`idb://${e}/${r}/${E}`;return m[S]||(m[S]=new ut)},y=h(""),w=h(":dels"),[g,x]=d[f](p);if(h(g.name||"").add(x),!g.isPrimaryKey){if(f!=="count"){const E=f==="query"&&l&&p.values&&o.query({...p,values:!1});return o[f].apply(this,arguments).then(S=>{if(f==="query"){if(l&&p.values)return E.then(({result:k})=>(y.addKeys(k),S));const C=p.values?S.result.map(i):S.result;p.values?y.addKeys(C):w.addKeys(C)}else if(f==="openCursor"){const C=S,k=p.values;return C&&Object.create(C,{key:{get:()=>(w.addKey(C.primaryKey),C.key)},primaryKey:{get(){const j=C.primaryKey;return w.addKey(j),j}},value:{get:()=>(k&&y.addKey(C.primaryKey),C.value)}})}return S})}w.add(n)}}return o[f].apply(this,arguments)}}),c}}}};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 a={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:fe,dbReadyPromise:null,cancelOpen:fe,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var s;a.dbReadyPromise=new R(i=>{a.dbReadyResolve=i}),a.openCanceller=new R((i,l)=>{a.cancelOpen=l}),this._state=a,this.name=e,this.on=Dn(this,"populate","blocked","versionchange","close",{ready:[Ca,fe]}),this.on.ready.subscribe=vi(this.on.ready.subscribe,i=>(l,c)=>{$t.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||R.resolve().then(l),c&&i(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&i(l);else{i(l);const d=this;c||i(function f(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(f)})}})}),this.Collection=(s=this,yn(cf.prototype,function(i,l){this.db=s;let c=Ti,u=null;if(l)try{c=l()}catch(m){u=m}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:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:p!==Fn?p:null}})),this.Table=function(i){return yn(lf.prototype,function(l,c,u){this.db=i,this._tx=u,this.name=l,this.schema=c,this.hook=i._allTables[l]?i._allTables[l].hook:Dn(null,{creating:[Gd,fe],reading:[Jd,Fn],updating:[Xd,fe],deleting:[Yd,fe]})})}(this),this.Transaction=function(i){return yn(pf.prototype,function(l,c,u,d,f){this.db=i,this.mode=l,this.storeNames=c,this.schema=u,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 R((p,m)=>{this._resolve=p,this._reject=m}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var m=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):m&&this.idbtrans&&this.idbtrans.abort(),Pe(p)})})}(this),this.Version=function(i){return yn(gf.prototype,function(l){this.db=i,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(i){return yn(Wi.prototype,function(l,c,u){this.db=i,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=i._deps.indexedDB;if(!d)throw new U.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,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=i=>{this.on("blocked").fire(i),Sn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(i))},this.use(kf),this.use(_f),this.use(Sf),this.use(Ef),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(i=>i(this))}version(e){if(isNaN(e)||e<.1)throw new U.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new U.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(vf),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||B.letThrough||this._vip)?e():new R((n,r)=>{if(this._state.openComplete)return r(new U.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new U.DatabaseClosed);this.open().catch(fe)}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 a=this._middlewares[e]||(this._middlewares[e]=[]);return a.push({stack:e,create:n,level:r??10,name:o}),a.sort((s,i)=>s.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 bf(this)}_close(){const e=this._state,n=Sn.indexOf(this);if(n>=0&&Sn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new R(r=>{e.dbReadyResolve=r}),e.openCanceller=new R((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new U.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new R((r,o)=>{const a=()=>{this.close();var s=this._deps.indexedDB.deleteDatabase(this.name);s.onsuccess=we(()=>{(function({indexedDB:i,IDBKeyRange:l},c){!Ia(i)&&c!==Jr&&Oa(i,l).delete(c).catch(fe)})(this._deps,this.name),r()}),s.onerror=at(o),s.onblocked=this._fireOnBlocked};if(e)throw new U.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(a):a()})}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 je(this._allTables).map(e=>this._allTables[e])}transaction(){const e=xf.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=B.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);const a=e.indexOf("?")!==-1;let s,i;e=e.replace("!","").replace("?","");try{if(i=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===ro)s=ro;else{if(e!="rw"&&e!=oo)throw new U.InvalidArgument("Invalid transaction mode: "+e);s=oo}if(o){if(o.mode===ro&&s===oo){if(!a)throw new U.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!a)throw new U.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),a&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Pe(c)}const l=Ui.bind(null,this,s,i,o,r);return o?o._promise(s,l,"lock"):B.trans?hn(B.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!He(this._allTables,e))throw new U.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Df=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class jf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Df](){return this}}function qi(t,e){return je(e).forEach(n=>{Sr(t[n]||(t[n]=new ut),e[n])}),t}function Of(t){let e,n=!1;const r=new jf(o=>{const a=ka(t);let s=!1,i={},l={};const c={get closed(){return s},unsubscribe:()=>{s=!0,Dt.storagemutated.unsubscribe(p)}};o.start&&o.start(c);let u=!1,d=!1;function f(){return je(l).some(h=>i[h]&&Cf(i[h],l[h]))}const p=h=>{qi(i,h),f()&&m()},m=()=>{if(u||s)return;i={};const h={},y=function(w){a&&pn();const g=()=>Ct(t,{subscr:w,trans:null}),x=B.trans?hn(B.transless,g):g();return a&&x.then(gt,gt),x}(h);d||(Dt(Rn,p),d=!0),u=!0,Promise.resolve(y).then(w=>{n=!0,e=w,u=!1,s||(f()?m():(i={},l=h,o.next&&o.next(w)))},w=>{u=!1,n=!1,o.error&&o.error(w),c.unsubscribe()})};return m(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let qo;try{qo={indexedDB:ve.indexedDB||ve.mozIndexedDB||ve.webkitIndexedDB||ve.msIndexedDB,IDBKeyRange:ve.IDBKeyRange||ve.webkitIDBKeyRange}}catch{qo={indexedDB:null,IDBKeyRange:null}}const Pt=$t;function fr(t){let e=pt;try{pt=!0,Dt.storagemutated.fire(t)}finally{pt=e}}un(Pt,{...sr,delete:t=>new Pt(t,{addons:[]}).delete(),exists:t=>new Pt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Ia(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==Jr)):Oa(e,n).toCollection().primaryKeys()}(Pt.dependencies).then(t)}catch{return Pe(new U.MissingAPI)}},defineClass:()=>function(t){Be(this,t)},ignoreTransaction:t=>B.trans?hn(B.transless,t):t(),vip:Ko,async:function(t){return function(){try{var e=Uo(t.apply(this,arguments));return e&&typeof e.then=="function"?e:R.resolve(e)}catch(n){return Pe(n)}}},spawn:function(t,e,n){try{var r=Uo(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:R.resolve(r)}catch(o){return Pe(o)}},currentTransaction:{get:()=>B.trans||null},waitFor:function(t,e){const n=R.resolve(typeof t=="function"?Pt.ignoreTransaction(t):t).timeout(e||6e4);return B.trans?B.trans.waitFor(n):n},Promise:R,debug:{get:()=>lt,set:t=>{ki(t,t==="dexie"?()=>!0:Ri)}},derive:tn,extend:Be,props:un,override:vi,Events:Dn,on:Dt,liveQuery:Of,extendObservabilitySet:qi,getByKeyPath:vt,setByKeyPath:nt,delByKeyPath:function(t,e){typeof e=="string"?nt(t,e,void 0):"length"in e&&[].map.call(e,function(n){nt(t,n,void 0)})},shallowClone:wi,deepClone:zn,getObjectDiff:Pa,cmp:We,asap:yi,minKey:Ao,addons:[],connections:Sn,errnames:Ea,dependencies:qo,semVer:os,version:os.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),Pt.maxKey=Tn(Pt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Dt(Rn,t=>{if(!pt){let e;Hr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(kt,!0,!0,t)):e=new CustomEvent(kt,{detail:t}),pt=!0,dispatchEvent(e),pt=!1}}),addEventListener(kt,({detail:t})=>{pt||fr(t)}));let pt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(kt);typeof t.unref=="function"&&t.unref(),Dt(Rn,e=>{pt||t.postMessage(e)}),t.onmessage=e=>{e.data&&fr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Dt(Rn,e=>{try{pt||(typeof localStorage<"u"&&localStorage.setItem(kt,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:kt,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===kt){const n=JSON.parse(e.newValue);n&&fr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===kt&&fr(e.changedParts)})}R.rejectionMapper=function(t,e){if(!t||t instanceof nn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!es[t.name])return t;var n=new es[t.name](e||t.message,t);return"stack"in t&&mt(n,"stack",{get:function(){return this.inner.stack}}),n},ki(lt,Ri);var pr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(pr||{});const If="comfyui_workspace_db";class Pf extends $t{constructor(){super(If);ke(this,"workflows");ke(this,"changelogs");ke(this,"media");ke(this,"folders");ke(this,"tags");ke(this,"userSettings");ke(this,"models");ke(this,"cache");ke(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const H=new Pf,Nf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Vo=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Nf[n[t]&63];return e};class Jt{constructor(e){ke(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await H[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")}),Nd(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=Vo()),e.createTime||(e.createTime=Date.now()),await H[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await H[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await H[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await H[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await H[this.tableName].toArray()}async batchQuery(e){return await H[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 Pd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await Td()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await H[this.tableName].get(e)}async delete(e){await H[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await H[this.tableName].where(e).equals(n).toArray()}}const Ff=150,Or=class Or extends Jt{constructor(){super("changelogs")}static async load(){return new Or}async listByWorkflowID(e){return await H.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:Pn(),json:e.json,workflowID:e.workflowID,createTime:Date.now()};return await H.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e,n=Ff){const r=await H.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),o=r.filter(s=>s.isAutoSave===!0),a=r.filter(s=>s.isAutoSave==null||s.isAutoSave==!1);if(o.length>n){const s=o.slice(n);await H.changelogs.bulkDelete(s.map(i=>i.id)),await this.saveDiskDB()}if(a.length>n){const s=a.slice(n);await H.changelogs.bulkDelete(s.map(i=>i.id)),await this.saveDiskDB()}}};ke(Or,"TABLE_NAME","changelogs");let Ho=Or;const th="CWM_WORKFLOWS_SORT_TYPE";var _t=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(_t||{});const nh=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],Vi="comfyspace_tracking",Dr="workspace_info",Af=9999999;function ft(t){return"/"+t.split("/").filter(n=>n!=="").join("/")}function Mf(t){return t.split("/").filter(n=>n!=="").join("/")}async function Nt(t){const e=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${e}/${t}`)}var Et;(t=>{async function e({parentFolderID:l,name:c}){return Mf(`${l??""}/${c}`)}t.genFolderRelPath=e;async function n({parentFolderID:l,name:c}){const u=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${u}/${l??""}/${c}`)}t.genFolderAbsPath=n;async function r(l){const c=await n(l);await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})}t.createFolder=r;async function o(l,c){const u=await Nt(l),d=await Nt(c),p=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:u,newParentPath:d})})).json();p.error&&alert("Failed to move folder: "+p.error)}t.moveFolder=o;async function a(l){const c=await Nt(l);try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})).text()}catch(u){console.error("Error deleting file:",u)}}t.deleteFolder=a;async function s(l){const c=await Nt(l);try{const d=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})).json();return d.error&&console.error("Error counting files:",d.error),d.count}catch(u){console.error("Error renaming file:",u)}return null}t.genFilesCountInFolder=s;async function i(l,c){const u=await Nt(l);try{const f=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:u,newName:c})})).json();f.error&&alert("Failed to rename folder: "+f.error)}catch(d){console.error("Error renaming file:",d)}}t.renameFolder=i})(Et||(Et={}));async function bn(t){console.warn("saveJsonFileMyWorkflows",t);const e=await Fa(t);if(e==null)return;const n=await Aa(t);await(O==null?void 0:O.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[Dr]={id:t.id,name:t.name},delete o.extra[Vi],await pi(e,JSON.stringify(o))}async function co(t){if(t.name==null)return;const e=await Fa(t);e!=null&&hi(e)}async function Fa(t){let e=Rf(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(Te==null?void 0:Te.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function rh(t){let e="",n=t;for(;n!=null;){const r=await(Te==null?void 0:Te.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Aa(t){const e=await Fa(t);let n=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function oh(t){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await Et.genFilesCountInFolder(t)??0;const n=await(O==null?void 0:O.listAll())??[],r=await(Te==null?void 0:Te.listAll())??[],o=[t];let a=0;for(;o.length>0;){const s=o.shift();if(s){for(const l of n)l.parentFolderID===s&&a++;const i=r.filter(l=>l.parentFolderID===s).map(l=>l.id);i.length&&o.push(...i)}}return a}function Rf(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function fs(t,e=!0,n=!1){const r=new Date(t),o=String(r.getDate()).padStart(2,"0"),a=String(r.getMonth()+1).padStart(2,"0"),s=r.getFullYear(),i=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=String(r.getSeconds()).padStart(2,"0"),u=`${a}-${o}-${s}`;return e?u+` ${i}:${l}`:n?u+`:${c}`:u}async function Tf(t=!1){const e=await(O==null?void 0:O.listAll())??[];for(const n of e){const r=await Aa(n);n.filePath!=r&&(n.filePath!=null&&await hi(n.filePath,t),await bn(n))}}const Hi=(t,e=_t.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case _t.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case _t.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case _t.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case _t.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n};function ah(t,e){let n=JSON.parse(t);typeof structuredClone>"u"?n=JSON.parse(JSON.stringify(n)):n=structuredClone(n);let r=new LGraph;r.configure(n);const o=localStorage.getItem("litegrapheditor_clipboard"),a=document.createElement("canvas");let s=new LGraphCanvas(a,r);s.selectNodes(r._nodes),s.copyToClipboard(r._nodes);const i=ge.canvas.graph_mouse;e&&(e[0]-=15,e[1]-=15,ge.canvas.graph_mouse=e),ge.canvas.pasteFromClipboard(),ge.canvas.graph_mouse=i,o&&localStorage.setItem("litegrapheditor_clipboard",o),r=null,s=null}const Lf=async t=>{const e=await(P==null?void 0:P.getSetting("shortcuts").then(n=>n==null?void 0:n.save));return e?Wf(t,e):!1},Wf=(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 Bf(t){return`/workspace/view_media?filename=${t}`}function ps(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function Ji(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 $f=t=>{const e=Ji(t);window.open(`${window.location.origin}/#${e}`)};async function Kf(){const t=await(O==null?void 0:O.listAll())??[];for(const e of t)try{const n=await Aa(e),r=JSON.parse(e.json);r.extra[Dr]={id:e.id,name:e.name},delete r.extra[Vi],n&&await pi(n,JSON.stringify(r))}catch(n){console.error(n)}}const hr={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Ge;(t=>{async function e({parentFolderID:u,name:d}){const f=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${f}/${u??""}/${d}.json`)}async function n(u,d){const f=await e(u),p=await Nt(d);try{const h=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f,newParentPath:p})})).json();return h.error?(alert("Error moving file: "+h.error),!1):!0}catch(m){console.error("Error deleting file:",m)}}t.moveWorkflow=n;async function r(u,d){const f=await Nt(`${d}/${u}`);try{const m=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f})})).json();return m.error?(console.error("Error getting unique name:",m.error),null):m.uniqueName}catch(p){console.error("Error deleting file:",p)}return null}t.genFileUniqueName=r;async function o({parentFolderID:u,name:d},f){const p=await(P==null?void 0:P.getSetting("myWorkflowsDir")),m=ft(`${p}/${u??""}/${d}.json`);try{const y=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:m,newName:f})})).json();return y.error?(alert("Error moving file: "+y.error),!1):!0}catch(h){console.error("Error deleting file:",h)}}t.renameWorkflow=o;async function a(){const u=await(P==null?void 0:P.getSetting("myWorkflowsDir")),d=ft(u);try{const p=await(await fetch("/workspace/file/scan_dup_id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d})})).json();return!0}catch(f){console.error("Error deleting file:",f)}}t.scanMyWorkflowsDupId=a;async function s(u){const d=await e(u),f=u.json,p=JSON.parse(f);p.extra[Dr]={id:u.id};const h=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,json:JSON.stringify(p)})})).json();if(h.error)throw console.error("Error saving file:",h.error),alert(`"Error saving file: ${h.error} - - 👉Please try "Save as" from "Files" dropdown menu - `),new Error(h.error);return h}t.saveWorkflow=s;async function i(u){const d=await e(u);try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:d,deleteEmptyFolder:!1})})).text()}catch(f){alert("Error deleting workflow .json file: "+f),console.error("Error deleting file:",f)}}t.deleteWorkflow=i;async function l({parentFolderID:u,name:d,json:f,id:p}){var g;const m=await(P==null?void 0:P.getSetting("myWorkflowsDir")),h=ft(`${m}/${u??""}`);let y=JSON.parse(f);y={...y,extra:{[Dr]:{id:p}}};const w={parentFolderPath:h,name:d,json:JSON.stringify(y)};try{const E=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)})).json();return E.name&&await((g=H.workflows)==null?void 0:g.update(p,{filePath:`${h}/${d}.json`,name:E.name})),E}catch(x){return console.error(`Error creating file <${p}> at "${h}"`,x),alert(`Error creating file <${p}> at "${h}"`),{}}}t.creatWorkflow=l;async function c({parentFolderID:u,name:d,id:f}){const p=await(P==null?void 0:P.getSetting("myWorkflowsDir")),m=ft(`${p}/${u??""}/${d}.json`);console.warn("get abs path 🔥 workfoow",m);try{const y=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:m,id:f})})).json();return y.error&&(console.error(`Error getting file <${f}> at "${m}"`,y.error),alert({message:`Error getting file <${f}> at "${m}"`,level:"error"})),y}catch(h){return console.error(`Erro finding file <${f}> at "${m}"`,h),{}}}t.getFile=c})(Ge||(Ge={}));async function Uf(t){try{return await(await fetch("/workspace/scan_my_workflows_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ft(t)})})).json()}catch(e){return console.error("Error scan local new files:",e),[]}}async function zf(t,e){const n=await(P==null?void 0:P.getSetting("myWorkflowsDir"));if(n==null||n==="")return alert("No Workspace saving directory found, please go to Settings."),[];const r=t??"",o=`${n}/${r}`,s=(await Uf(o)).map(async c=>{var p;const u=c.name,d=ft([o,u].join("/")),f=[r,u].join("/");return qf(c)?{id:f,name:c.name,parentFolderID:r,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((p=H.workflows)==null?void 0:p.get(c.id))??{createTime:Date.now(),updateTime:Date.now()},id:c.id,filePath:d,lastSavedJson:c.json??"{}",json:c.json??"{}",name:u.replace(/\.json$/,""),parentFolderID:r,createTime:c.createTime}}),i=await Promise.all(s);H.workflows.bulkPut(i.filter(c=>!Jf(c)));const l=i.filter(c=>c!=null);return Hi(l,e??_t.RECENTLY_MODIFIED)}function qf(t){return"type"in t&&t.type==="folder"}const Ir=class Ir extends Jt{constructor(){super("workflows");ke(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Ir}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await H.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async generateUniqueName(n,r){if(await(P==null?void 0:P.getSetting("twoWaySync"))){const l=await Ge.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let a=n??"Untitled Flow";const i=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(i.includes(a)){let l=2,c=!0;for(;c;)i.includes(`${a} ${l}`)?l++:(a=`${a} ${l}`,c=!1)}return a}async createFlow(n){const{id:r,json:o,name:a}=n,s=await this.generateUniqueName(a,n.parentFolderID??void 0),i=r??Vo(),l=Date.now(),c={...n,id:i,json:o??JSON.stringify(hr),name:s,updateTime:l,createTime:l};return await H.workflows.add(c),this.saveDiskDB(),await(P==null?void 0:P.getSetting("twoWaySync"))?(await Ge.creatWorkflow(c),await this.get(c.id)):(bn(c),c)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await H.workflows.update(n,r);const o=await H.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var i;const o=await(P==null?void 0:P.getSetting("twoWaySync")),a=await this.get(n),s=await this.updateMetaInfo(n,r);!s||!a||(o?await Ge.moveWorkflow(a,r.parentFolderID):(await bn(s),await co(a),(s==null?void 0:s.parentFolderID)!=null&&await((i=H.folders)==null?void 0:i.update(s.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Fe==null?void 0:Fe.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(P==null?void 0:P.getSetting("twoWaySync"))&&o&&await Ge.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const a=JSON.stringify(o.json),s=JSON.stringify(r.json);if(a===s)return;const i=await this._update(n,{updateTime:Date.now(),json:r.json});await(P==null?void 0:P.getSetting("twoWaySync"))?i&&await Ge.saveWorkflow(i):i&&await bn(i)}async batchCreateFlows(n=[],r=!1,o){const a=[];for(const s of n){const i=s.name&&r?s.name:await this.generateUniqueName(s.name,o),l=Vo(),c=Date.now(),u={id:l,name:i,json:s.json,parentFolderID:o,updateTime:c,createTime:c,tags:[]};a.push(u),await(P==null?void 0:P.getSetting("twoWaySync"))?Ge.creatWorkflow(u):await bn(u)}await H.workflows.bulkAdd(a),this.saveDiskDB()}async deleteFlow(n){const r=await this.get(n);r&&(await(P==null?void 0:P.getSetting("twoWaySync"))?await Ge.deleteWorkflow(r):co({...r})),await H.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await H.workflows.bulkGet(n);for(const o of r){if(!o)return;await(P==null?void 0:P.getSetting("twoWaySync"))?await Ge.deleteWorkflow(o):co({...o})}await H.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await zf(n??null);const a=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],s=await(Te==null?void 0:Te.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],i=[...a,...s];return Hi(i,r??_t.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(P==null?void 0:P.getSetting("twoWaySync")),a=await H.workflows.get(n);if(!o||!r)return a;if(a==null)return;const s=await Ge.getFile({parentFolderID:a.parentFolderID??null,name:a.name,id:a.id});if(s.json)return{...a,json:JSON.stringify(s.json)}}};ke(Ir,"TABLE_NAME","workflows");let Jo=Ir;const Pr=class Pr extends Jt{constructor(){super("folders")}static async load(){return new Pr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(P==null?void 0:P.getSetting("twoWaySync")),o=await Et.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),a={id:r?o:Pn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await Et.createFolder(a):(await H.folders.add(a),this.saveDiskDB()),a}async update(e,n){if(await(P==null?void 0:P.getSetting("twoWaySync")))return"parentFolderID"in n&&await Et.moveFolder(e,n.parentFolderID??""),"name"in n&&await Et.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const a="name"in n&&n.name!=o.name,s="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),s&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await H.folders.update(e,n),this.saveDiskDB(),(a||s)&&Tf(!0),i}async deleteFolder(e,n=pr.DELETE){await(P==null?void 0:P.getSetting("twoWaySync"))&&await Et.deleteFolder(e);const o=await(O==null?void 0:O.listAll())??[],a=await this.listAll(),s=[e];for(;s.length>0;){const i=s.shift();if(i){for(const c of o)if(c.parentFolderID===i)switch(n){case pr.DELETE:await(O==null?void 0:O.deleteFlow(c.id));break;case pr.MOVE_TO_ROOT_FOLDER:await(O==null?void 0:O.updateFolder(c.id,{parentFolderID:void 0}));break}await H.folders.delete(i);const l=a.filter(c=>c.parentFolderID===i).map(c=>c.id);l.length&&s.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await Ge.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const a=await this.listAll().then(s=>s.filter(i=>i.parentFolderID==n).map(i=>i.name));if(a.includes(o)){let s=2,i=!0;for(;i;)a.includes(`${o} ${s}`)?s++:(o=`${o} ${s}`,i=!1)}return o}};ke(Pr,"TABLE_NAME","folders");let Go=Pr;class Gi extends Jt{constructor(){super("media")}async listByWorkflowID(e){return await H.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:Pn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),format:n},o=await(O==null?void 0:O.get(e.workflowID)),a=new Set((o==null?void 0:o.mediaIDs)??[]).add(r.id);return await(O==null?void 0:O.updateMetaInfo(e.workflowID,{mediaIDs:Array.from(a),coverMediaPath:r.localPath})),H.media.add(r),this.saveDiskDB(),r}}ke(Gi,"TABLE_NAME","media");const ih=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],Vf={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function lh(t){return t.modelVersions!==void 0}function Hf(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function ch(t,e){var r,o,a,s,i,l;if(!t)return;let n;return Hf(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(a=t.files)==null?void 0:a[0].name,sizeKB:(i=(s=t.files)==null?void 0:s[0])==null?void 0:i.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const Nr=class Nr extends Jt{constructor(){super("userSettings");ke(this,"defaultSettings");ke(this,"DEFAULT_USER","guest");ke(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S"},defaultFolders:Vf,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.comfyspace.art",overwriteCurWorkflowWhenDroppingFileToCanvas:!1}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSettings(){const n=await this.get(this.DEFAULT_USER);return{...this.defaultSettings,...n}}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 Nr,r=await Fd();return n.defaultSettings.myWorkflowsDir=`${r.dir_path}/my_workflows`,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};ke(Nr,"TABLE_NAME","userSettings");let Yo=Nr;const Fr=class Fr extends Jt{constructor(){super("tags")}static async load(){return new Fr}};ke(Fr,"TABLE_NAME","tags");let Xo=Fr;const Ar=class Ar extends Jt{constructor(){super("workflowVersions")}static async load(){return new Ar}async listByWorkflowID(e){return await H[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}};ke(Ar,"TABLE_NAME","workflowVersions");let Zo=Ar;function Jf(t){return"type"in t&&t.type==="folder"}let O=null,mr=null,P=null,Te=null,Fe=null,Kt=null,me=null;async function Gf(){const t=async()=>{O=await Jo.load()},e=async()=>{mr=await Xo.load()},n=async()=>{P=await Yo.load()},r=async()=>{Te=await Go.load()},o=async()=>{Fe=await Ho.load()},a=async()=>{Kt=new Gi},s=async()=>{me=await Zo.load()};await Promise.all([t(),e(),n(),r(),o(),a(),s()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await Yf(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function Yf(){const t=async()=>{try{const i=await(O==null?void 0:O.getRecords());i&&await H.workflows.bulkAdd(Object.values(i))}catch(i){console.error(i)}},e=async()=>{try{const i=await(Te==null?void 0:Te.getRecords());i&&await H.folders.bulkAdd(Object.values(i))}catch(i){console.error(i)}},n=async()=>{try{const i=await(Kt==null?void 0:Kt.getRecords());i&&await H.media.bulkAdd(Object.values(i))}catch(i){console.error(i)}},r=async()=>{try{const i=await(Fe==null?void 0:Fe.getRecords());i&&await H.changelogs.bulkAdd(Object.values(i))}catch(i){console.error(i)}},o=async()=>{try{const i=await(mr==null?void 0:mr.getRecords());i&&await H.tags.bulkAdd(Object.values(i))}catch(i){console.error(i)}},a=async()=>{try{const i=P,l=await i.getRecords().then(c=>c[i.DEFAULT_USER]?c[i.DEFAULT_USER]:c);await H.userSettings.put({...i.defaultSettings,...l})}catch(i){console.error(i)}},s=async()=>{try{const i=await(me==null?void 0:me.getRecords());i&&await H.workflowVersions.bulkAdd(Object.values(i))}catch(i){console.error(i)}};await Promise.all([t(),e(),n(),r(),o(),a(),s()])}const Ot=b.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},jsonDiff:null,compareJson:()=>{}}),uh=b.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),uo={x:0,y:0};function Xf({children:t,onDragEnd:e,dragIconId:n}){const r=b.useRef(uo),o=b.useRef(!1),[a,s]=b.useState(uo),i=d=>{var f,p,m;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(f=d.target)==null?void 0:f.id,(m=(p=d.target)==null?void 0:p.parentNode)==null?void 0:m.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=b.useCallback(d=>{const f={x:d.clientX-r.current.x,y:d.clientY-r.current.y};s(f)},[]),c=b.useCallback(()=>{s(f=>(e(f),uo)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${a.x}px, ${a.y}px)`,zIndex:o.current?1e3:1};return v.jsx("div",{style:u,onMouseDown:i,children:t})}var Zf={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"},Qf=Object.defineProperty,ep=Object.defineProperties,tp=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertySymbols,Yi=Object.prototype.hasOwnProperty,Xi=Object.prototype.propertyIsEnumerable,hs=(t,e,n)=>e in t?Qf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ms=(t,e)=>{for(var n in e||(e={}))Yi.call(e,n)&&hs(t,n,e[n]);if(jr)for(var n of jr(e))Xi.call(e,n)&&hs(t,n,e[n]);return t},np=(t,e)=>ep(t,tp(e)),rp=(t,e)=>{var n={};for(var r in t)Yi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&jr)for(var r of jr(t))e.indexOf(r)<0&&Xi.call(t,r)&&(n[r]=t[r]);return n},Oe=(t,e,n)=>{const r=b.forwardRef((o,a)=>{var s=o,{color:i="currentColor",size:l=24,stroke:c=2,children:u}=s,d=rp(s,["color","size","stroke","children"]);return b.createElement("svg",ms(np(ms({ref:a},Zf),{width:l,height:l,stroke:i,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([f,p])=>b.createElement(f,p)),...u||[]])});return r.propTypes={color:It.string,size:It.oneOfType([It.string,It.number]),stroke:It.oneOfType([It.string,It.number])},r.displayName=`${e}`,r},op=Oe("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"}]]),ap=Oe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),sp=Oe("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"}]]),ip=Oe("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"}]]),Qo=Oe("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"}]]),lp=Oe("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"}]]),cp=Oe("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"}]]),up=Oe("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"}]]),dp=Oe("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"}]]),fp=Oe("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"}]]),pp=Oe("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"}]]),hp=Oe("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"}]]),mp=Oe("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"}]]),vp=Oe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),yp=Oe("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"}]]),gp=Oe("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"}]]),wp=Oe("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"}]]),bp=Oe("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"}]]),xp=Oe("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"}]]),kp=Oe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function _p(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:a}=t;return v.jsx(ni,{isLazy:!0,placement:"auto",children:({onClose:s})=>v.jsxs(v.Fragment,{children:[v.jsx(ti,{children:v.jsx(ht,{children:v.jsx(Lt,{hasArrow:!0,label:a,placement:"bottom",children:v.jsx(on,{"aria-label":"Delete confirm",size:"sm",icon:v.jsx(gp,{color:"#F56565"}),isDisabled:o,variant:n})})})}),v.jsxs(ii,{children:[v.jsx(ri,{}),v.jsx(ai,{onClick:s}),v.jsxs(oi,{children:[v.jsx(Rt,{mb:4,pr:4,fontWeight:600,children:e}),v.jsx(Ke,{colorScheme:"red",size:"sm",onClick:()=>{r(),s()},children:"Yes, delete"})]})]})]})})}function Ep({onClose:t}){const e=ks(),{curFlowID:n,isDirty:r}=b.useContext(Ot),[o,a]=b.useState(0),[s,i]=b.useState(null),[l,c]=b.useState([]),[u,d]=b.useState([]),f=async h=>{var E;const y=await(O==null?void 0:O.get(h)),w=await(Fe==null?void 0:Fe.listByWorkflowID(h));c(w??[]);const g=w==null?void 0:w.filter(S=>S.json===(y==null?void 0:y.json)),x=(E=g==null?void 0:g[0])==null?void 0:E.id;x&&i(x)},p=async()=>{var x;const h=await(me==null?void 0:me.listByWorkflowID(n))??[];d(h);const y=JSON.stringify(ge.graph.serialize()),w=h==null?void 0:h.filter(E=>E.json===y),g=(x=w==null?void 0:w[0])==null?void 0:x.id;g&&i(g)},m=h=>{me==null||me.delete(h).then(()=>{p()})};return b.useEffect(()=>{switch(o){case 0:p();break;case 1:f(n);break}},[o]),b.useEffect(()=>(ge.canvasEl.addEventListener("click",t),()=>{ge.canvasEl.removeEventListener("click",t)}),[o]),v.jsxs(Fl,{width:400,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[v.jsx(Nl,{pb:1,mb:0,children:v.jsxs(rr,{justifyContent:"space-between",alignItems:"center",children:[v.jsx(Rs,{size:"md",children:"Version History"}),v.jsx(on,{size:"sm",icon:v.jsx(kp,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),v.jsx(Pl,{overflowY:"auto",gap:0,children:v.jsxs(ui,{isFitted:!0,variant:"enclosed",onChange:a,children:[v.jsxs(di,{mb:"1em",children:[v.jsx(wo,{children:"Versions"}),v.jsx(wo,{children:"Change History"})]}),v.jsxs(fi,{children:[v.jsx(go,{children:v.jsx(xn,{divider:v.jsx(ho,{}),spacing:2,children:u==null?void 0:u.map(h=>v.jsxs(rr,{w:"100%",mb:1,justify:"space-between",backgroundColor:h.id===s?"teal.300":void 0,borderRadius:4,children:[v.jsxs(xn,{textAlign:"left",gap:0,children:[v.jsx(Rt,{fontWeight:"500",children:h.name??"untitled"}),v.jsxs(Rt,{color:"GrayText",fontSize:"sm",children:["Created: ",fs(h.createTime)]})]}),v.jsxs(rr,{alignItems:"center",gap:2,children:[v.jsx(Ke,{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}ge.loadGraphData(JSON.parse(h.json)),O==null||O.updateFlow(n,{json:h.json}),e({title:`Switched to version "${h.name}"`,status:"success",duration:3e3,isClosable:!0}),t()},children:"Load"}),v.jsx(_p,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{m(h.id)}})]})]},h.id))})}),v.jsxs(go,{children:[v.jsx(Rt,{mb:4,children:"All the saved changes of this workflow"}),v.jsx(xn,{divider:v.jsx(ho,{}),spacing:2,children:l==null?void 0:l.map(h=>v.jsxs(Ke,{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}ge.loadGraphData(JSON.parse(h.json)),O==null||O.updateFlow(n,{json:h.json}),t()},isActive:h.id===s,children:["Saved at ",fs(h.createTime,!0)]},h.id))})]})]})]})})]})}function Cp({workflowId:t,onClose:e}){const[n,r]=b.useState(""),[o,a]=b.useState(""),s=l=>{r(l.target.value),o&&a("")},i=async()=>{const l=n.trim();if(r(l),(await(me==null?void 0:me.listByWorkflowID(t))??[]).some(u=>u.name===l))a("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(ge.graph.serialize());await(me==null?void 0:me.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return v.jsxs(Rr,{isOpen:!0,onClose:e,children:[v.jsx(na,{}),v.jsxs(Tr,{children:[v.jsx(ra,{children:"Create Version"}),v.jsx(oa,{}),v.jsx(aa,{children:v.jsxs(Wr,{isInvalid:!!o,children:[v.jsx($r,{children:"Name"}),v.jsx(Bn,{value:n,onChange:s,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&i()}}),o&&v.jsx(Br,{children:o})]})}),v.jsxs(sa,{children:[v.jsx(Ke,{colorScheme:"teal",mr:3,onClick:i,isDisabled:!n||!!o,children:"Create"}),v.jsx(Ke,{onClick:e,children:"Cancel"})]})]})]})}function Sp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=b.useRef(null);return oc({ref:o,handler:()=>r()}),v.jsxs(ht,{position:"relative",children:[v.jsx(ht,{children:e}),n&&v.jsx(ht,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function Zi({menuButton:t,menuContent:e,onClose:n}){const r=b.useRef(),[o,a]=b.useState(!1),s=()=>{r.current=setTimeout(()=>a(!1),400)},i=()=>{a(!0),clearTimeout(r.current),r.current=void 0};return v.jsx(Sp,{isOpen:o,onClose:s,menuButton:v.jsx(ht,{"aria-label":"menu",onClick:i,onMouseEnter:i,onMouseLeave:s,children:t}),options:v.jsx(wa,{isOpen:!0,children:v.jsx(ba,{minWidth:150,zIndex:1e3,onMouseEnter:i,onMouseLeave:s,children:e})})})}var Qi={exports:{}};(function(t,e){(function(n,r){t.exports=r(b)})(self,function(n){return(()=>{var r={579:(i,l,c)=>{var u=c(84);i.exports=u},84:(i,l,c)=>{c.r(l),c.d(l,{default:()=>ae});var u=c(250),d=c.n(u),f=function(_){return _==="array"||Object.prototype.toString.call(_)==="[object Array]"},p=function(_){return Object.prototype.toString.call(_)==="[object Object]"},m=function(_){return _===1?{textIndent:"20px"}:{textIndent:"".concat(20*_,"px")}},h=function(_){var N=Object.prototype.toString.call(_);return(N=N.match(/(?!\[).+(?=\])/g)[0].split(" ")[1]).toLowerCase()},y=function(_){return p(_)||f(_)},w=function(_,N){return Object.prototype.toString.call(_)===Object.prototype.toString.call(N)};function g(_,N,M){return N in _?Object.defineProperty(_,N,{value:M,enumerable:!0,configurable:!0,writable:!0}):_[N]=M,_}function x(){return x=Object.assign||function(_){for(var N=1;N_.length)&&(N=_.length);for(var M=0,L=new Array(N);M_.length)&&(N=_.length);for(var M=0,L=new Array(N);M{c.d(l,{Z:()=>m});var u=c(81),d=c.n(u),f=c(645),p=c.n(f)()(d());p.push([i.id,`.c-json-view { - display: block; - width: 100%; - padding: 10px 10px 10px 40px; - background-color: #fbfbfb; - box-sizing: border-box; - white-space: pre-wrap; - word-wrap: break-word; - overflow: hidden; -} - -.c-json-line, -.c-json-p, -.c-json-feet { - position: relative; - text-align: left; - padding: 0; - margin: 0; - padding: 2px 0; -} - -.c-json-line { - padding: 0; -} - -.c-line-del { - background-color: #ffeef0; -} - -.c-line-add { - background-color: #e6ffed; -} - -.c-line-none {} - -.c-of-del:after { - content: '-'; - position: absolute; - left: 5px; - top: 3px; - width: 10px; - height: 15px; - z-index: 5; - text-indent: 0; - color: #ff6f6f; -} - -.c-of-add:after { - content: '+'; - position: absolute; - left: 5px; - top: 3px; - width: 10px; - height: 15px; - z-index: 5; - color: #3eb93e; - text-indent: 0; -} - -.c-json-p { - cursor: pointer; -} - -.c-json-outter { - transform: translateX(-35px); -} - -.c-json-mark { - position: absolute; - left: -30px; - top: 2px; - text-indent: 0; - font-size: 12px; - color: #545454; - z-index: 5; - user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -webkit-user-select: none; -} - -.c-json-content { - font-size: 14px; -} - -.c-json-content .c-json-key { - font-size: 15px; - color: #5cadff; -} - -.c-json-items { - color: #b1b1b1; -} - -.c-json-comma { - color: #5cadff; -} - -.c-json-pt { - color: #5cadff; -} - -.c-json-number { - color: #ae81ff; -} - -.c-json-string { - color: #a6e22e; -} - -.c-json-null, -.c-json-boolean, -.c-json-undefined, -.c-json-regexp, -.c-json-date, -.c-json-set, -.c-json-map, -.c-json-error, -.c-json-symbol, -.c-json-function { - background-color: #f7f7f7; - border-radius: 3px; - padding: 0px 2px; - border: 1px solid #dedede; -} - -.c-json-boolean { - color: #6f73ff; -} - -.c-json-null { - color: #66d9ef; -} - -.c-json-undefined { - color: #f92672; -} - -.c-json-date { - color: #09d3ac; -} - -.c-json-regexp { - color: #2ea021; -} - -.c-json-function { - color: #a2af3d; -} - -.c-json-symbol { - color: #fd3db8; -} - -.c-json-error { - color: #afafaf; -} - -.c-json-set, -.c-json-map { - color: #f56847; -}`,""]);const m=p},645:i=>{i.exports=function(l){var c=[];return c.toString=function(){return this.map(function(u){var d="",f=u[5]!==void 0;return u[4]&&(d+="@supports (".concat(u[4],") {")),u[2]&&(d+="@media ".concat(u[2]," {")),f&&(d+="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {")),d+=l(u),f&&(d+="}"),u[2]&&(d+="}"),u[4]&&(d+="}"),d}).join("")},c.i=function(u,d,f,p,m){typeof u=="string"&&(u=[[null,u,void 0]]);var h={};if(f)for(var y=0;y0?" ".concat(x[5]):""," {").concat(x[1],"}")),x[5]=m),d&&(x[2]&&(x[1]="@media ".concat(x[2]," {").concat(x[1],"}")),x[2]=d),p&&(x[4]?(x[1]="@supports (".concat(x[4],") {").concat(x[1],"}"),x[4]=p):x[4]="".concat(p)),c.push(x))}},c}},81:i=>{i.exports=function(l){return l[1]}},379:i=>{var l=[];function c(f){for(var p=-1,m=0;m{var l={};i.exports=function(c,u){var d=function(f){if(l[f]===void 0){var p=document.querySelector(f);if(window.HTMLIFrameElement&&p instanceof window.HTMLIFrameElement)try{p=p.contentDocument.head}catch{p=null}l[f]=p}return l[f]}(c);if(!d)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");d.appendChild(u)}},216:i=>{i.exports=function(l){var c=document.createElement("style");return l.setAttributes(c,l.attributes),l.insert(c,l.options),c}},565:(i,l,c)=>{i.exports=function(u){var d=c.nc;d&&u.setAttribute("nonce",d)}},795:i=>{i.exports=function(l){var c=l.insertStyleElement(l);return{update:function(u){(function(d,f,p){var m="";p.supports&&(m+="@supports (".concat(p.supports,") {")),p.media&&(m+="@media ".concat(p.media," {"));var h=p.layer!==void 0;h&&(m+="@layer".concat(p.layer.length>0?" ".concat(p.layer):""," {")),m+=p.css,h&&(m+="}"),p.media&&(m+="}"),p.supports&&(m+="}");var y=p.sourceMap;y&&typeof btoa<"u"&&(m+=` -/*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(y))))," */")),f.styleTagTransform(m,d,f.options)})(c,l,u)},remove:function(){(function(u){if(u.parentNode===null)return!1;u.parentNode.removeChild(u)})(c)}}}},589:i=>{i.exports=function(l,c){if(c.styleSheet)c.styleSheet.cssText=l;else{for(;c.firstChild;)c.removeChild(c.firstChild);c.appendChild(document.createTextNode(l))}}},250:i=>{i.exports=n}},o={};function a(i){var l=o[i];if(l!==void 0)return l.exports;var c=o[i]={id:i,exports:{}};return r[i](c,c.exports,a),c.exports}a.n=i=>{var l=i&&i.__esModule?()=>i.default:()=>i;return a.d(l,{a:l}),l},a.d=(i,l)=>{for(var c in l)a.o(l,c)&&!a.o(i,c)&&Object.defineProperty(i,c,{enumerable:!0,get:l[c]})},a.o=(i,l)=>Object.prototype.hasOwnProperty.call(i,l),a.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var s=a(579);return s.default})()})})(Qi);var Dp=Qi.exports;const jp=vs(Dp);function Op(){const{jsonDiff:t,compareJson:e}=b.useContext(Ot);return t==null?null:v.jsx(Rr,{isOpen:!0,onClose:()=>{e(null)},children:v.jsx(Tr,{children:v.jsx(ht,{height:"80vh",width:"90%",overflow:"scroll",children:v.jsx(jp,{oldData:t==null?void 0:t.old,newData:t==null?void 0:t.new})})})})}const Ip=b.lazy(()=>Lr(()=>import("./ShareDialog-yZ9MQqaN.js"),__vite__mapDeps([0,1,2,3])));function Pp(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r}=b.useContext(Ot),[o,a]=b.useState(!1),[s,i]=b.useState(!1),[l,c]=b.useState(!1),[u,d]=b.useState(""),[f,p]=b.useState(""),[m,h]=b.useState(),[y,w]=b.useState(""),[g,x]=b.useState(!1);b.useEffect(()=>{t&&(O==null||O.get(t).then(j=>{d((j==null?void 0:j.name)??""),h(j)})),P==null||P.getSetting("shortcuts").then(j=>{w(j==null?void 0:j.save)})},[t]);const E=j=>{d(j.target.value),f&&p("")},S=async()=>{if(!t){alert("Flow ID is required");return}const j=JSON.stringify(ge.graph.serialize()),D=await(O==null?void 0:O.createFlow({json:j,lastSavedJson:j,name:u,parentFolderID:m==null?void 0:m.parentFolderID}));D&&await e(D.id,!0),C()},C=()=>{i(!1)},k=b.useCallback(async()=>{const j=t?await(O==null?void 0:O.get(t)):null;if(!j){alert("Workspace does not exist");return}const D=new Blob([j.json],{type:"application/json"}),F=URL.createObjectURL(D),A=document.createElement("a");A.href=F,A.download=`${j.name}.json`,document.body.appendChild(A),A.click(),document.body.removeChild(A),URL.revokeObjectURL(F)},[t]);return v.jsxs(v.Fragment,{children:[v.jsx(Zi,{menuButton:v.jsx(gl,{children:v.jsxs(Ke,{px:1,height:"29px","aria-label":"menu",size:"sm",colorScheme:"gray",backgroundColor:"gray.700",children:["File",v.jsx(ap,{size:20})]})}),menuContent:v.jsx(wa,{isOpen:!0,children:v.jsxs(ba,{minWidth:150,zIndex:1e3,children:[v.jsx(wt,{onClick:r,icon:v.jsx(Qo,{size:20}),iconSpacing:1,command:y,children:"Save"}),v.jsx(Lt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:v.jsx(wt,{onClick:n,icon:v.jsx(op,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),v.jsx(wt,{onClick:k,icon:v.jsx(lp,{size:20}),iconSpacing:1,children:"Download"}),v.jsx(wt,{onClick:()=>i(!0),icon:v.jsx(Qo,{size:20}),iconSpacing:1,children:"Save As"}),v.jsx(wt,{onClick:()=>a(!0),icon:v.jsx(bp,{size:20}),iconSpacing:1,children:"Create Version"}),v.jsx(wt,{onClick:()=>c(!0),icon:v.jsx(fp,{size:20}),iconSpacing:1,children:"Versions History"}),v.jsx(wt,{onClick:()=>x(!0),icon:v.jsx(yp,{size:20}),iconSpacing:1,children:"Share"})]})})}),g&&v.jsx(Ip,{onClose:()=>x(!1)}),l&&v.jsx(Ep,{onClose:()=>c(!1)}),v.jsx(Op,{}),s&&v.jsxs(Rr,{isOpen:!0,onClose:C,children:[v.jsx(na,{}),v.jsxs(Tr,{children:[v.jsx(ra,{children:"Save As"}),v.jsx(oa,{}),v.jsx(aa,{children:v.jsxs(Wr,{isInvalid:!!f,children:[v.jsx($r,{children:"Workflow name"}),v.jsx(Bn,{value:u,onChange:E,autoFocus:!0,onKeyUp:j=>{j.code==="Enter"&&!f&&u&&S()}}),f&&v.jsx(Br,{children:f})]})}),v.jsxs(sa,{children:[v.jsx(Ke,{colorScheme:"teal",mr:3,onClick:S,isDisabled:!u||!!f,children:"Save"}),v.jsx(Ke,{onClick:C,children:"Cancel"})]})]})]}),o&&v.jsx(Cp,{workflowId:t,onClose:()=>a(!1)})]})}function Np({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:a}=ic(),{curFlowID:s}=b.useContext(Ot),[i,l]=b.useState(t),[c,u]=b.useState(""),d=()=>{l(t),o()},f=h=>{l(h.target.value),c&&u("")},p=async()=>{var h;if(s){const y=i.trim();if(l(y),t===y)return m();await(O==null?void 0:O.generateUniqueName(y,((h=O.curWorkflow)==null?void 0:h.parentFolderID)??""))!==y?u("The name is duplicated, please modify it and submit again."):(await(O==null?void 0:O.updateName(s,{name:y})),e(y),m())}},m=()=>{u(""),a()};return s==null?null:v.jsxs(Ft,{children:[v.jsx(Lt,{label:t,placement:"bottom",children:v.jsxs(Rt,{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(Rt,{as:"span",children:n&&"* "})}),t]})}),v.jsxs(Rr,{isOpen:r,onClose:m,children:[v.jsx(na,{}),v.jsxs(Tr,{children:[v.jsx(ra,{children:"Edit workflow name"}),v.jsx(oa,{}),v.jsx(aa,{children:v.jsxs(Wr,{isInvalid:!!c,children:[v.jsx($r,{children:"Workflow name"}),v.jsx(Bn,{value:i,onChange:f,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!c&&i&&p()}}),c&&v.jsx(Br,{children:c})]})}),v.jsxs(sa,{children:[v.jsx(Ke,{colorScheme:"teal",mr:3,onClick:p,isDisabled:!i||!!c,children:"Save"}),v.jsx(Ke,{onClick:m,children:"Cancel"})]})]})]})]})}function dh(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const fh=[{label:"Private",value:"PRIVATE",icon:v.jsx(hp,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:v.jsx(pp,{})},{label:"Public",value:"PUBLIC",icon:v.jsx(xp,{})}],ph=()=>{const t=ge.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 a=r.input[o];for(let s in a){const i=a[s];Array.isArray(i[0])&&(i[0]=["value_1","value_2"])}}e[n.type]=r}return e};async function Fp(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Ap({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")),v.jsx("span",{children:n})}function Mp({}){const[t,e]=b.useState(),[n,r]=b.useState(),{curFlowID:o}=b.useContext(Ot);return b.useEffect(()=>{o&&(O==null||O.get(o).then(a=>{a!=null&&a.cloudID?(e(a.cloudOrigin+"/workflow/"+a.cloudID),Fp(a).then(s=>{r(s)})):e(void 0)}))},[o]),t?v.jsx(v.Fragment,{children:v.jsx(Zi,{menuButton:v.jsx(Ke,{onClick:()=>{window.open(t)},variant:"ghost","aria-label":"Shared",size:"xs",iconSpacing:"2px",leftIcon:v.jsx(sp,{}),height:"26px",px:1,children:n?v.jsx(Ap,{privacy:n}):"Shared"}),menuContent:v.jsxs(Ft,{width:"200px",p:1,color:"blue.400",children:[v.jsx(As,{href:t,noOfLines:1,isExternal:!0,children:t.replace("https://www.","")}),v.jsx(on,{size:"xs",variant:"ghost",icon:v.jsx(ip,{size:19}),"aria-label":"copy link"})]})})}):null}function Rp({updatePanelPosition:t,positionStyle:e,curFlowName:n,setCurFlowName:r}){const{isDirty:o,loadNewWorkflow:a,saveCurWorkflow:s,setRoute:i,curFlowID:l}=b.useContext(Ot);return v.jsx(Xf,{onDragEnd:c=>{t({top:c.y,left:c.x},!0)},dragIconId:"dragPanelIcon",children:v.jsxs(Ft,{style:{padding:2,position:"fixed",...e},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[v.jsx(Ke,{size:"sm","aria-label":"workspace folder",onClick:()=>i("recentFlows"),px:2,children:v.jsxs(Ft,{gap:1,children:[v.jsx(up,{size:21}),v.jsx(wp,{size:8})]})}),v.jsx(Lt,{label:"New workflow",children:v.jsx(Ke,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",onClick:()=>a(),px:2,py:2,children:v.jsx(Ft,{gap:0,children:v.jsx(vp,{size:16,color:"white"})})})}),v.jsx(Np,{isDirty:o,displayName:n??"",updateFlowName:c=>{r(c),requestAnimationFrame(()=>{t()})}}),l&&v.jsxs(Ft,{gap:"4px",children:[v.jsx(Lt,{label:"Open gallery",children:v.jsx(on,{onClick:()=>i("gallery"),icon:v.jsx(mp,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),v.jsx(Pp,{})]}),v.jsx(Mp,{}),l&&o?v.jsx(Lt,{label:"Save workflow",children:v.jsx(on,{onClick:s,icon:v.jsx(Qo,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):v.jsx("div",{style:{width:1}}),v.jsx(dp,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})})}function Tp(){const{showDialog:t}=bs(),{loadWorkflowID:e}=b.useContext(Ot),n=async(o,a)=>{var c,u;const{workflow:s,version:i}=o.detail;if(!s.id||!i.id)return;const l=(c=await(O==null?void 0:O.listByIndex("cloudID",s.id)))==null?void 0:c.at(0);if(console.log("existingWorkflow",l),l)((u=await(me==null?void 0:me.listByIndex("cloudID",i.id)))==null?void 0:u.at(0))?await e(l.id):await(me==null?void 0:me.add({id:i.id,cloudID:i.id,workflowID:l.id,cloudOrigin:a,name:i.name,authorID:i.authorID,json:i.json}));else{const d=await(O==null?void 0:O.createFlow({cloudID:s.id,cloudOrigin:a,name:s.name,json:i.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}await(me==null?void 0:me.add({id:i.id,cloudID:i.id,workflowID:d.id,cloudOrigin:a,name:i.name,json:i.json})),await e(d.id)}},r=async o=>{const a=o.data;if(Lp(a)){const s=o.origin;t(`Open workflow "${a.detail.workflow.name}", version "${a.detail.version.name}" from ${s}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(a,s)}}])}};return b.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Lp(t){return t.type==="workspace_open_workflow"}const Wp=ia.lazy(()=>Lr(()=>import("./RecentFilesDrawer-pKqjZV5O.js"),__vite__mapDeps([4,1,3,5,2,6,7]))),Bp=ia.lazy(()=>Lr(()=>import("./GalleryModal-yOnENaqH.js"),__vite__mapDeps([8,1,7,5,2,6]))),$p=ia.lazy(()=>Lr(()=>import("./ModelManagerTopbar-K_yJKYUe.js").then(t=>t.M),__vite__mapDeps([9,1,5,2,10]))),Kp=["download_progress","download_error","model_list"];function Up(){const[t,e]=b.useState(null),[n,r]=b.useState("root"),[o,a]=b.useState(!0),[s,i]=b.useState(null),l=b.useRef(null),[c,u]=b.useState(),[d,f]=b.useState(!1),p=b.useRef(null),{showDialog:m}=bs(),[h,y]=b.useState(!1);b.useRef(!1);const w=b.useRef(0),g=ks(),x=b.useRef("hide"),[E,S]=b.useState(null),C=b.useCallback(async()=>{if(l.current){const _=JSON.stringify(ge.graph.serialize());await Promise.all([O==null?void 0:O.updateFlow(l.current,{json:_}),Fe==null?void 0:Fe.create({workflowID:l.current,json:_})]),P!=null&&P.autoSave&&g({title:"Saved",status:"success",duration:1e3,isClosable:!0})}},[]),k=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(O==null?void 0:O.delete(l.current)),D(null))},j=async()=>{var N,M,L;if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const Y=(N=O==null?void 0:O.curWorkflow)==null?void 0:N.id;if(Y==null)return;let J;P!=null&&P.autoSave?J=(M=await(Fe==null?void 0:Fe.getLastestByWorkflowID(Y)))==null?void 0:M.json:J=(L=await(O==null?void 0:O.get(Y)))==null?void 0:L.json,J?await ge.loadGraphData(JSON.parse(J)):alert("Error: No last saved version found")}},D=_=>{const N=(_==null?void 0:_.id)??null;if(O==null||O.updateCurWorkflow(_),l.current=N,i(N),e((_==null?void 0:_.name)??""),N==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ps()){const M=Ji(N);window.location.hash=M,document.title=name+" - ComfyUI"}else localStorage.setItem("curFlowID",N),document.title="ComfyUI - "+name},F=async()=>{A(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await Gf(),await(P==null?void 0:P.getSetting("topBarStyle").then(N=>{be(N,!1)}))}catch(N){console.error("error loading db",N)}a(!1);let _=null;_=ps(),_==null&&(_=localStorage.getItem("curFlowID")),_&&K(_),localStorage.getItem("REWRITTEN_ALL_LOCAL_DISK_FILE")==="true"||(await Kf(),localStorage.setItem("REWRITTEN_ALL_LOCAL_DISK_FILE","true"))},A=()=>{Kp.forEach(_=>{Ma.addEventListener(_,()=>null)})},q=async()=>{if(l.current!=null){const _=O==null?void 0:O.curWorkflow;return!!_&&$(_)}return!1},$=_=>{if(_.json==null)return!0;const N=ge.graph.serialize()??{};let M={};try{M=_!=null&&_.json?JSON.parse(_==null?void 0:_.json):{}}catch(Y){console.error("error parsing json",Y)}return!(JSON.stringify(N)===JSON.stringify(M))},K=async _=>{if(ge.graph==null){console.error("app.graph is null cannot load workflow");return}const N=await(O==null?void 0:O.get(_));if(N==null){alert("Error: Workflow not found! id: "+_),D(null);return}D(N),ge.ui.dialog.close(),ge.loadGraphData(JSON.parse(N.json)),r("root")},le=_=>{S(_)},z=async(_,N=!1)=>{if(_===null){D(null),ge.graph.clear();return}if((await(P==null?void 0:P.getSetting("autoSave"))??!0)||!d||N){K(_);return}I(_)},I=async _=>{var M,L;const N=[_?{label:"Open in new tab",icon:v.jsx(cp,{}),onClick:()=>{$f(_)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await C(),_&&K(_)}}];((M=O==null?void 0:O.curWorkflow)==null?void 0:M.lastSavedJson)!=null?N.push({label:"Discard",colorScheme:"red",onClick:async()=>{await j(),_&&K(_)}}):N.push({label:"Delete",colorScheme:"red",onClick:async()=>{await k(),_&&K(_)}}),m(`Please save or discard your changes to "${(L=O==null?void 0:O.curWorkflow)==null?void 0:L.name}" before leaving, or your changes will be lost.`,N)},X=async _=>{const N=(_==null?void 0:_.json)??JSON.stringify(hr),M=await(O==null?void 0:O.createFlow({json:N,name:_==null?void 0:_.name}));M&&await z(M.id),r("root")},re=async(_,N=!1)=>{const M=_.split("/").pop()??_;N?C():X({name:M});const L=await fetch(Bf(_)),Y=await L.blob(),J=new File([Y],M,{type:L.headers.get("Content-Type")||""});await ge.handleFile(J),r("root")},he=async(_,N)=>{const M=await(O==null?void 0:O.get(_));if(M==null)return;const L=await(O==null?void 0:O.createFlow({json:M.json,lastSavedJson:M.lastSavedJson,name:N||M.name,parentFolderID:M.parentFolderID,tags:M.tags}));L&&await z(L.id)},be=b.useCallback((_,N=!1)=>{const{top:M=0,left:L=0}=c||{};let{top:Y=0,left:J=0}=_??{};Y+=M,J+=L;const se=document.documentElement.clientWidth,V=document.documentElement.clientHeight,W=document.getElementById("workspaceManagerPanel"),Q=(W==null?void 0:W.offsetWidth)||392;Y+36>V&&(Y=V-36),J+Q>=se&&(J=se-Q),u({top:Math.max(0,Y),left:Math.max(0,J)}),N&&(P==null||P.upsert({topBarStyle:{top:Y,left:J}}))},[c]),Ee=async _=>{await Lf(_)&&C()},ce=b.useCallback(_=>{if(l.current==null)return;let N=_.filename;_.subfolder!=null&&_.subfolder!==""&&(N=_.subfolder+"/"+N),Kt==null||Kt.create({workflowID:l.current,localPath:N})},[]),ae=b.useCallback(()=>{r("root")},[]);return b.useEffect(()=>{F(),y(!0),w.current=setInterval(async()=>{const J=P==null?void 0:P.autoSave,se=await q();if(f(!!se),!!se&&l.current!=null&&J){const V=await(O==null?void 0:O.latestVersionCheck());if(x.current!=="disabled"&&!V)x.current="show",m(`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:()=>{x.current="disabled"}},{label:"Disable Auto-Save",colorScheme:"teal",onClick:()=>{P==null||P.upsert({autoSave:!1})}}],!0);else{const W=JSON.stringify(ge.graph.serialize());W!=null&&await(O==null?void 0:O.updateFlow(l.current,{json:W}))}}},1e3),window.addEventListener("keydown",Ee);const _=document.getElementById("comfy-file-input"),N=async()=>{if(_&&_.files&&_.files.length>0){const J={id:Pn(),name:_.files[0].name,json:JSON.stringify(hr),updateTime:Date.now(),createTime:Date.now()};D(J),await(O==null?void 0:O.createFlow(J))}};_==null||_.addEventListener("change",N);const M=J=>{const se=(P==null?void 0:P.autoSave)??!0,V=!!(O!=null&&O.curWorkflow)&&$(O==null?void 0:O.curWorkflow);!se&&V&&(J.preventDefault(),J.returnValue="You have unsaved changes!",I())};window.addEventListener("beforeunload",M);const L=J=>{var se,V,W,Q,T,ee;(W=(V=(se=J.detail)==null?void 0:se.output)==null?void 0:V.images)==null||W.forEach(te=>{te.type==="output"&&ce(te)}),(ee=(T=(Q=J.detail)==null?void 0:Q.output)==null?void 0:T.gifs)==null||ee.forEach(te=>{te.type==="output"&&ce(te)})};Ma.addEventListener("executed",L);const Y=async J=>{var Q,T;const se=(T=(Q=J.dataTransfer)==null?void 0:Q.files[0])==null?void 0:T.name,V=ge.dragOverNode;if(V&&V.onDragDrop)return;if(!(await(P==null?void 0:P.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&se){const ee={id:Pn(),name:se,json:JSON.stringify(hr),updateTime:Date.now(),createTime:Date.now()};D(ee),await(O==null?void 0:O.createFlow(ee))}};return ge.canvasEl.addEventListener("drop",Y),()=>{window.removeEventListener("keydown",Ee),window.removeEventListener("change",N),window.removeEventListener("beforeunload",M),window.removeEventListener("executed",L),ge.canvasEl.removeEventListener("drop",Y),clearInterval(w.current)}},[]),o||!c?null:v.jsx(Ot.Provider,{value:{curFlowID:s,onDuplicateWorkflow:he,loadWorkflowID:z,discardUnsavedChanges:j,saveCurWorkflow:C,isDirty:d,loadNewWorkflow:X,loadFilePath:re,setRoute:r,jsonDiff:E,compareJson:le},children:v.jsx("div",{ref:p,className:"workspace_manager",children:v.jsxs(ws,{containerRef:p,children:[v.jsxs(ht,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Af,draggable:!1,children:[v.jsx(Rp,{curFlowName:t,setCurFlowName:e,updatePanelPosition:be,positionStyle:c}),h&&v.jsx(b.Suspense,{children:v.jsx($p,{})}),h&&n==="recentFlows"&&v.jsx(b.Suspense,{children:v.jsx(Wp,{onClose:ae,onClickNewFlow:()=>{X(),r("root")}})}),n==="gallery"&&v.jsx(Bp,{onclose:()=>r("root")})]}),v.jsx(Tp,{})]})})})}const hh=Object.freeze(Object.defineProperty({__proto__:null,default:Up},Symbol.toStringTag,{value:"Module"}));export{ii as $,lp as A,ht as B,kp as C,_p as D,ap as E,rr as F,nh as G,Ft as H,on as I,up as J,Te as K,Wr as L,ei as M,$r as N,Br as O,vp as P,hr as Q,uh as R,Qu as S,Rt as T,oh as U,pr as V,Jf as W,th as X,$l as Y,ni as Z,ti as _,Jp as a,ri as a0,ai as a1,oi as a2,Ot as a3,$f as a4,cp as a5,_t as a6,Fl as a7,Af as a8,Zp as a9,Fp as aA,Ap as aB,Nl as aC,hh as aD,Hi as aa,ah as ab,sh as ac,ip as ad,As as ae,Kt as af,Rs as ag,cc as ah,kl as ai,H as aj,lh as ak,ch as al,eh as am,ic as an,Vf as ao,ih as ap,Qp as aq,Xf as ar,dp as as,Kl as at,dn as au,sp as av,fh as aw,me as ax,dh as ay,ph as az,lc as b,Xp as c,Gp as d,Yp as e,fn as f,zr as g,Oe as h,gp as i,xn as j,Bn as k,P as l,fs as m,rh as n,ks as o,ho as p,Lt as q,Fd as r,Mf as s,mr as t,Ur as u,Tf as v,O as w,wa as x,ba as y,wt as z}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-yZ9MQqaN.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/chunk-RPO2WXNL-dt-e86vT.js","workspace_web/RecentFilesDrawer-pKqjZV5O.js","workspace_web/chunk-JARCRF6W-aHchqwnR.js","workspace_web/chunk-NTCQBYKE-EEXlKSMU.js","workspace_web/MediaPreview-Z5nSvSr_.js","workspace_web/GalleryModal-yOnENaqH.js","workspace_web/ModelManagerTopbar-K_yJKYUe.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-GluzE5n7.js b/dist/workspace_web/App-GluzE5n7.js new file mode 100644 index 0000000..63d871a --- /dev/null +++ b/dist/workspace_web/App-GluzE5n7.js @@ -0,0 +1,182 @@ +var ol=Object.defineProperty;var sl=(t,e,n)=>e in t?ol(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ke=(t,e,n)=>(sl(t,typeof e!="symbol"?e+"":e,n),n);import{u as al,a as il,r as b,c as ll,b as et,m as Fe,d as Rt,f as Q,j as m,B as Ke,e as cl,g as J,h as pe,o as Je,i as Ot,k as ot,I as Mr,l as Wn,n as Yr,p as xe,q as va,s as ul,t as dl,v as fl,w as Rr,x as pl,y as hl,z as ml,A as yl,C as vl,D as ts,E as ga,F as ns,G as wa,H as gl,J as wl,K as bl,P as ba,M as Tr,L as rs,N as Lr,O as os,Q as ss,R as as,S as is,_ as Wr,T as xl,U as xa,V as ls}from"./input.js";import{app as ge}from"/scripts/app.js";import{api as Rs}from"/scripts/api.js";function kl(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}function ka(t){var e;return kl(t)&&(e=t.ownerDocument)!=null?e:document}function _l(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var El=_l();function Cl(t){const e=Object.assign({},t);for(let n in e)e[n]===void 0&&delete e[n];return e}function _a(t){const{theme:e}=al(),n=il();return b.useMemo(()=>ll(e.direction,{...n,...t}),[t,e.direction,n])}var Sl=Object.defineProperty,jl=(t,e,n)=>e in t?Sl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(jl(t,typeof e!="symbol"?e+"":e,n),n);function Ts(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 Dl=t=>typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE;function Ls(t,e,n){let r=t+1;return n&&r>=e&&(r=0),r}function Ws(t,e,n){let r=t-1;return n&&r<0&&(r=e),r}var po=typeof window<"u"?b.useLayoutEffect:b.useEffect,yr=t=>t,Ol=class{constructor(){_e(this,"descendants",new Map),_e(this,"register",t=>{if(t!=null)return Dl(t)?this.registerNode(t):e=>{this.registerNode(e,t)}}),_e(this,"unregister",t=>{this.descendants.delete(t);const e=Ts(Array.from(this.descendants.keys()));this.assignIndex(e)}),_e(this,"destroy",()=>{this.descendants.clear()}),_e(this,"assignIndex",t=>{this.descendants.forEach(e=>{const n=t.indexOf(e.node);e.index=n,e.node.dataset.index=e.index.toString()})}),_e(this,"count",()=>this.descendants.size),_e(this,"enabledCount",()=>this.enabledValues().length),_e(this,"values",()=>Array.from(this.descendants.values()).sort((e,n)=>e.index-n.index)),_e(this,"enabledValues",()=>this.values().filter(t=>!t.disabled)),_e(this,"item",t=>{if(this.count()!==0)return this.values()[t]}),_e(this,"enabledItem",t=>{if(this.enabledCount()!==0)return this.enabledValues()[t]}),_e(this,"first",()=>this.item(0)),_e(this,"firstEnabled",()=>this.enabledItem(0)),_e(this,"last",()=>this.item(this.descendants.size-1)),_e(this,"lastEnabled",()=>{const t=this.enabledValues().length-1;return this.enabledItem(t)}),_e(this,"indexOf",t=>{var e,n;return t&&(n=(e=this.descendants.get(t))==null?void 0:e.index)!=null?n:-1}),_e(this,"enabledIndexOf",t=>t==null?-1:this.enabledValues().findIndex(e=>e.node.isSameNode(t))),_e(this,"next",(t,e=!0)=>{const n=Ls(t,this.count(),e);return this.item(n)}),_e(this,"nextEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Ls(r,this.enabledCount(),e);return this.enabledItem(o)}),_e(this,"prev",(t,e=!0)=>{const n=Ws(t,this.count()-1,e);return this.item(n)}),_e(this,"prevEnabled",(t,e=!0)=>{const n=this.item(t);if(!n)return;const r=this.enabledIndexOf(n.node),o=Ws(r,this.enabledCount()-1,e);return this.enabledItem(o)}),_e(this,"registerNode",(t,e)=>{if(!t||this.descendants.has(t))return;const n=Array.from(this.descendants.keys()).concat(t),r=Ts(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 Il(){const t=b.useRef(new Ol);return po(()=>()=>t.current.destroy()),t.current}var[Pl,Ea]=et({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function Nl(t){const e=Ea(),[n,r]=b.useState(-1),o=b.useRef(null);po(()=>()=>{o.current&&e.unregister(o.current)},[]),po(()=>{if(!o.current)return;const a=Number(o.current.dataset.index);n!=a&&!Number.isNaN(a)&&r(a)});const s=yr(t?e.register(t):e.register);return{descendants:e,index:n,enabledIndex:e.enabledIndexOf(o.current),register:Fe(s,o)}}function Ca(){return[yr(Pl),()=>yr(Ea()),()=>Il(),o=>Nl(o)]}function Sa(t){const{value:e,defaultValue:n,onChange:r,shouldUpdate:o=(f,p)=>f!==p}=t,s=Rt(r),a=Rt(o),[i,l]=b.useState(n),c=e!==void 0,u=c?e:i,d=Rt(f=>{const y=typeof f=="function"?f(u):f;a(u,y)&&(c||l(y),s(y))},[c,s,u,a]);return[u,d]}function cs(t){return b.Children.toArray(t).filter(e=>b.isValidElement(e))}var on=Q((t,e)=>{const{icon:n,children:r,isRound:o,"aria-label":s,...a}=t,i=n||r,l=b.isValidElement(i)?b.cloneElement(i,{"aria-hidden":!0,focusable:!1}):null;return m.jsx(Ke,{padding:"0",borderRadius:o?"full":void 0,ref:e,"aria-label":s,...a,children:l})});on.displayName="IconButton";var[Al,ja]=cl("Card"),Fl=Q(function(e,n){const{className:r,...o}=e,s=ja();return m.jsx(J.div,{ref:n,className:pe("chakra-card__body",r),__css:s.body,...o})}),Ml=Q(function(e,n){const{className:r,...o}=e,s=ja();return m.jsx(J.div,{ref:n,className:pe("chakra-card__header",r),__css:s.header,...o})}),Rl=Q(function(e,n){const{className:r,children:o,direction:s="column",justify:a,align:i,...l}=Je(e),c=Ot("Card",e);return m.jsx(J.div,{ref:n,className:pe("chakra-card",r),__css:{display:"flex",flexDirection:s,justifyContent:a,alignItems:i,position:"relative",minWidth:0,wordWrap:"break-word",...c.container},...l,children:m.jsx(Al,{value:c,children:o})})}),[Tl,Da]=et({name:"FormControlStylesContext",errorMessage:`useFormControlStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),[Ll,dn]=et({strict:!1,name:"FormControlContext"});function Wl(t){const{id:e,isRequired:n,isInvalid:r,isDisabled:o,isReadOnly:s,...a}=t,i=b.useId(),l=e||`field-${i}`,c=`${l}-label`,u=`${l}-feedback`,d=`${l}-helptext`,[f,p]=b.useState(!1),[y,h]=b.useState(!1),[v,w]=b.useState(!1),g=b.useCallback((k={},D=null)=>({id:d,...k,ref:Fe(D,j=>{j&&h(!0)})}),[d]),x=b.useCallback((k={},D=null)=>({...k,ref:D,"data-focus":ot(v),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s),id:k.id!==void 0?k.id:c,htmlFor:k.htmlFor!==void 0?k.htmlFor:l}),[l,o,v,r,s,c]),E=b.useCallback((k={},D=null)=>({id:u,...k,ref:Fe(D,j=>{j&&p(!0)}),"aria-live":"polite"}),[u]),S=b.useCallback((k={},D=null)=>({...k,...a,ref:D,role:"group","data-focus":ot(v),"data-disabled":ot(o),"data-invalid":ot(r),"data-readonly":ot(s)}),[a,o,v,r,s]),C=b.useCallback((k={},D=null)=>({...k,ref:D,role:"presentation","aria-hidden":!0,children:k.children||"*"}),[]);return{isRequired:!!n,isInvalid:!!r,isReadOnly:!!s,isDisabled:!!o,isFocused:!!v,onFocus:()=>w(!0),onBlur:()=>w(!1),hasFeedbackText:f,setHasFeedbackText:p,hasHelpText:y,setHasHelpText:h,id:l,labelId:c,feedbackId:u,helpTextId:d,htmlProps:a,getHelpTextProps:g,getErrorMessageProps:E,getRootProps:S,getLabelProps:x,getRequiredIndicatorProps:C}}var Br=Q(function(e,n){const r=Ot("Form",e),o=Je(e),{getRootProps:s,htmlProps:a,...i}=Wl(o),l=pe("chakra-form-control",e.className);return m.jsx(Ll,{value:i,children:m.jsx(Tl,{value:r,children:m.jsx(J.div,{...s({},n),className:l,__css:r.container})})})});Br.displayName="FormControl";var Bl=Q(function(e,n){const r=dn(),o=Da(),s=pe("chakra-form__helper-text",e.className);return m.jsx(J.div,{...r==null?void 0:r.getHelpTextProps(e,n),__css:o.helperText,className:s})});Bl.displayName="FormHelperText";var[$l,Kl]=et({name:"FormErrorStylesContext",errorMessage:`useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),$r=Q((t,e)=>{const n=Ot("FormError",t),r=Je(t),o=dn();return o!=null&&o.isInvalid?m.jsx($l,{value:n,children:m.jsx(J.div,{...o==null?void 0:o.getErrorMessageProps(r,e),className:pe("chakra-form__error-message",t.className),__css:{display:"flex",alignItems:"center",...n.text}})}):null});$r.displayName="FormErrorMessage";var Ul=Q((t,e)=>{const n=Kl(),r=dn();if(!(r!=null&&r.isInvalid))return null;const o=pe("chakra-form__error-icon",t.className);return m.jsx(Mr,{ref:e,"aria-hidden":!0,...t,__css:n.icon,className:o,children:m.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"})})});Ul.displayName="FormErrorIcon";var Kr=Q(function(e,n){var r;const o=Wn("FormLabel",e),s=Je(e),{className:a,children:i,requiredIndicator:l=m.jsx(Oa,{}),optionalIndicator:c=null,...u}=s,d=dn(),f=(r=d==null?void 0:d.getLabelProps(u,n))!=null?r:{ref:n,...u};return m.jsxs(J.label,{...f,className:pe("chakra-form__label",s.className),__css:{display:"block",textAlign:"start",...o},children:[i,d!=null&&d.isRequired?l:c]})});Kr.displayName="FormLabel";var Oa=Q(function(e,n){const r=dn(),o=Da();if(!(r!=null&&r.isRequired))return null;const s=pe("chakra-form__required-indicator",e.className);return m.jsx(J.span,{...r==null?void 0:r.getRequiredIndicatorProps(e,n),__css:o.requiredIndicator,className:s})});Oa.displayName="RequiredIndicator";function zl(t){const{isDisabled:e,isInvalid:n,isReadOnly:r,isRequired:o,...s}=ql(t);return{...s,disabled:e,readOnly:r,required:o,"aria-invalid":Yr(n),"aria-required":Yr(o),"aria-readonly":Yr(r)}}function ql(t){var e,n,r;const o=dn(),{id:s,disabled:a,readOnly:i,required:l,isRequired:c,isInvalid:u,isReadOnly:d,isDisabled:f,onFocus:p,onBlur:y,...h}=t,v=t["aria-describedby"]?[t["aria-describedby"]]:[];return o!=null&&o.hasFeedbackText&&(o!=null&&o.isInvalid)&&v.push(o.feedbackId),o!=null&&o.hasHelpText&&v.push(o.helpTextId),{...h,"aria-describedby":v.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??c)!=null?r:o==null?void 0:o.isRequired,isInvalid:u??(o==null?void 0:o.isInvalid),onFocus:xe(o==null?void 0:o.onFocus,p),onBlur:xe(o==null?void 0:o.onBlur,y)}}function en(t,e,n,r){const o=Rt(n);return b.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 Vl(t){return"current"in t}var Ia=()=>typeof window<"u";function Hl(){var t;const e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}var Jl=t=>Ia()&&t.test(navigator.vendor),Gl=t=>Ia()&&t.test(Hl()),Yl=()=>Gl(/mac|iphone|ipad|ipod/i),Xl=()=>Yl()&&Jl(/apple/i);function Zl(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};en(o,"pointerdown",s=>{if(!Xl()||!r)return;const a=s.target,l=(n??[e]).some(c=>{const u=Vl(c)?c.current:c;return(u==null?void 0:u.contains(a))||u===a});o().activeElement!==a&&l&&(s.preventDefault(),a.focus())})}var Pa={exports:{}},Ql="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ec=Ql,tc=ec;function Na(){}function Aa(){}Aa.resetWarningCache=Na;var nc=function(){function t(r,o,s,a,i,l){if(l!==tc){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Aa,resetWarningCache:Na};return n.PropTypes=n,n};Pa.exports=nc();var rc=Pa.exports;const Nt=va(rc);function oc(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 sc(t){return t.localName==="html"?t:t.assignedSlot||t.parentElement||t.ownerDocument.documentElement}function Fa(t){return["html","body","#document"].includes(t.localName)?t.ownerDocument.body:ul(t)&&oc(t)?t:Fa(sc(t))}var ac=El?b.useLayoutEffect:b.useEffect;function ho(t,e=[]){const n=b.useRef(t);return ac(()=>{n.current=t}),b.useCallback((...r)=>{var o;return(o=n.current)==null?void 0:o.call(n,...r)},e)}function ic(t){const{ref:e,handler:n,enabled:r=!0}=t,o=ho(n),a=b.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;b.useEffect(()=>{if(!r)return;const i=d=>{Xr(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Xr(d,e)&&(a.isPointerDown=!1,o(d))},c=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Xr(d,e)&&(a.isPointerDown=!1,o(d))},u=ka(e.current);return u.addEventListener("mousedown",i,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",i,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",i,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",i,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,a,r])}function Xr(t,e){var n;const r=t.target;return r&&!ka(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function lc(t,e){const n=b.useId();return b.useMemo(()=>t||[e,n].filter(Boolean).join("-"),[t,e,n])}function cc(t,e){const n=t!==void 0;return[n,n&&typeof t<"u"?t:e]}function uc(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=ho(n),a=ho(e),[i,l]=b.useState(t.defaultIsOpen||!1),[c,u]=cc(r,i),d=lc(o,"disclosure"),f=b.useCallback(()=>{c||l(!1),a==null||a()},[c,a]),p=b.useCallback(()=>{c||l(!0),s==null||s()},[c,s]),y=b.useCallback(()=>{(u?f:p)()},[u,p,f]);return{isOpen:!!u,onOpen:p,onClose:f,onToggle:y,isControlled:c,getButtonProps:(h={})=>({...h,"aria-expanded":u,"aria-controls":d,onClick:dl(h.onClick,y)}),getDisclosureProps:(h={})=>({...h,hidden:!u,id:d})}}var Bn=Q(function(e,n){const{htmlSize:r,...o}=e,s=Ot("Input",o),a=Je(o),i=zl(a),l=pe("chakra-input",e.className);return m.jsx(J.input,{size:r,...i,__css:s.field,ref:n,className:l})});Bn.displayName="Input";Bn.id="Input";var Ma=Q(function(e,n){const r=Wn("Link",e),{className:o,isExternal:s,...a}=Je(e);return m.jsx(J.a,{target:s?"_blank":void 0,rel:s?"noopener":void 0,ref:n,className:pe("chakra-link",o),...a,__css:r})});Ma.displayName="Link";var dc=Object.freeze(["base","sm","md","lg","xl","2xl"]);function fc(t,e){return Array.isArray(t)?t.map(n=>n===null?null:e(n)):fl(t)?Object.keys(t).reduce((n,r)=>(n[r]=e(t[r]),n),{}):t!=null?e(t):null}function nh(t,e=dc){const n={};return t.forEach((r,o)=>{const s=e[o];r!=null&&(n[s]=r)}),n}var Tt=Q(function(e,n){const r=Wn("Text",e),{className:o,align:s,decoration:a,casing:i,...l}=Je(e),c=Cl({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return m.jsx(J.p,{ref:n,className:pe("chakra-text",e.className),...c,...l,__css:r})});Tt.displayName="Text";var mo=t=>m.jsx(J.div,{className:"chakra-stack__divider",...t,__css:{...t.__css,borderWidth:0,alignSelf:"stretch",borderColor:"inherit",width:"auto",height:"auto"}});mo.displayName="StackDivider";var Ra=t=>m.jsx(J.div,{className:"chakra-stack__item",...t,__css:{display:"inline-block",flex:"0 0 auto",minWidth:0,...t.__css}});Ra.displayName="StackItem";function pc(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{"&":fc(n,o=>r[o])}}var xn=Q((t,e)=>{const{isInline:n,direction:r,align:o,justify:s,spacing:a="0.5rem",wrap:i,children:l,divider:c,className:u,shouldWrapChildren:d,...f}=t,p=n?"row":r??"column",y=b.useMemo(()=>pc({spacing:a,direction:p}),[a,p]),h=!!c,v=!d&&!h,w=b.useMemo(()=>{const x=cs(l);return v?x:x.map((E,S)=>{const C=typeof E.key<"u"?E.key:S,k=S+1===x.length,j=d?m.jsx(Ra,{children:E},C):E;if(!h)return j;const A=b.cloneElement(c,{__css:y}),F=k?null:A;return m.jsxs(b.Fragment,{children:[j,F]},C)})},[c,y,h,v,d,l]),g=pe("chakra-stack",u);return m.jsx(J.div,{ref:e,display:"flex",alignItems:o,justifyContent:s,flexDirection:p,flexWrap:i,gap:h?void 0:a,className:g,...f,children:w})});xn.displayName="Stack";var Ct=Q((t,e)=>m.jsx(xn,{align:"center",...t,direction:"row",ref:e}));Ct.displayName="HStack";var Ta=Q(function(e,n){const r=Wn("Heading",e),{className:o,...s}=Je(e);return m.jsx(J.h2,{ref:n,className:pe("chakra-heading",e.className),...s,__css:r})});Ta.displayName="Heading";var ht=J("div");ht.displayName="Box";var La=Q(function(e,n){const{size:r,centerContent:o=!0,...s}=e,a=o?{display:"flex",alignItems:"center",justifyContent:"center"}:{};return m.jsx(ht,{ref:n,boxSize:r,__css:{...a,flexShrink:0,flexGrow:0},...s})});La.displayName="Square";var hc=Q(function(e,n){const{size:r,...o}=e;return m.jsx(La,{size:r,ref:n,borderRadius:"9999px",...o})});hc.displayName="Circle";var rr=Q(function(e,n){const{direction:r,align:o,justify:s,wrap:a,basis:i,grow:l,shrink:c,...u}=e,d={display:"flex",flexDirection:r,alignItems:o,justifyContent:s,flexWrap:a,flexBasis:i,flexGrow:l,flexShrink:c};return m.jsx(J.div,{ref:n,__css:d,...u})});rr.displayName="Flex";function mc(t){const{key:e}=t;return e.length===1||e.length>1&&/[^a-zA-Z0-9]/.test(e)}function yc(t={}){const{timeout:e=300,preventDefault:n=()=>!0}=t,[r,o]=b.useState([]),s=b.useRef(),a=()=>{s.current&&(clearTimeout(s.current),s.current=null)},i=()=>{a(),s.current=setTimeout(()=>{o([]),s.current=null},e)};b.useEffect(()=>a,[]);function l(c){return u=>{if(u.key==="Backspace"){const d=[...r];d.pop(),o(d);return}if(mc(u)){const d=r.concat(u.key);n(u)&&(u.preventDefault(),u.stopPropagation()),o(d),c(d.join("")),i()}}}return l}function vc(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 gc(){const t=b.useRef(new Map),e=t.current,n=b.useCallback((o,s,a,i)=>{t.current.set(a,{type:s,el:o,options:i}),o.addEventListener(s,a,i)},[]),r=b.useCallback((o,s,a,i)=>{o.removeEventListener(s,a,i),t.current.delete(a)},[]);return b.useEffect(()=>()=>{e.forEach((o,s)=>{r(o.el,o.type,s,o.options)})},[r,e]),{add:n,remove:r}}function Zr(t){const e=t.target,{tagName:n,isContentEditable:r}=e;return n!=="INPUT"&&n!=="TEXTAREA"&&r!==!0}function Wa(t={}){const{ref:e,isDisabled:n,isFocusable:r,clickOnEnter:o=!0,clickOnSpace:s=!0,onMouseDown:a,onMouseUp:i,onClick:l,onKeyDown:c,onKeyUp:u,tabIndex:d,onMouseOver:f,onMouseLeave:p,...y}=t,[h,v]=b.useState(!0),[w,g]=b.useState(!1),x=gc(),E=I=>{I&&I.tagName!=="BUTTON"&&v(!1)},S=h?d:d||0,C=n&&!r,k=b.useCallback(I=>{if(n){I.stopPropagation(),I.preventDefault();return}I.currentTarget.focus(),l==null||l(I)},[n,l]),D=b.useCallback(I=>{w&&Zr(I)&&(I.preventDefault(),I.stopPropagation(),g(!1),x.remove(document,"keyup",D,!1))},[w,x]),j=b.useCallback(I=>{if(c==null||c(I),n||I.defaultPrevented||I.metaKey||!Zr(I.nativeEvent)||h)return;const Z=o&&I.key==="Enter";s&&I.key===" "&&(I.preventDefault(),g(!0)),Z&&(I.preventDefault(),I.currentTarget.click()),x.add(document,"keyup",D,!1)},[n,h,c,o,s,x,D]),A=b.useCallback(I=>{if(u==null||u(I),n||I.defaultPrevented||I.metaKey||!Zr(I.nativeEvent)||h)return;s&&I.key===" "&&(I.preventDefault(),g(!1),I.currentTarget.click())},[s,h,n,u]),F=b.useCallback(I=>{I.button===0&&(g(!1),x.remove(document,"mouseup",F,!1))},[x]),q=b.useCallback(I=>{if(I.button!==0)return;if(n){I.stopPropagation(),I.preventDefault();return}h||g(!0),I.currentTarget.focus({preventScroll:!0}),x.add(document,"mouseup",F,!1),a==null||a(I)},[n,h,a,x,F]),$=b.useCallback(I=>{I.button===0&&(h||g(!1),i==null||i(I))},[i,h]),K=b.useCallback(I=>{if(n){I.preventDefault();return}f==null||f(I)},[n,f]),le=b.useCallback(I=>{w&&(I.preventDefault(),g(!1)),p==null||p(I)},[w,p]),z=Fe(e,E);return h?{...y,ref:z,type:"button","aria-disabled":C?void 0:n,disabled:C,onClick:k,onMouseDown:a,onMouseUp:i,onKeyUp:u,onKeyDown:c,onMouseOver:f,onMouseLeave:p}:{...y,ref:z,role:"button","data-active":ot(w),"aria-disabled":n?"true":void 0,tabIndex:C?void 0:S,onClick:k,onMouseDown:q,onMouseUp:$,onKeyUp:A,onKeyDown:j,onMouseOver:K,onMouseLeave:le}}function wc(t){const e=t.current;if(!e)return!1;const n=ml(e);return!n||e.contains(n)?!1:!!yl(n)}function Ba(t,e){const{shouldFocus:n,visible:r,focusRef:o}=e,s=n&&!r;Rr(()=>{if(!s||wc(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 bc={preventScroll:!0,shouldFocus:!1};function xc(t,e=bc){const{focusRef:n,preventScroll:r,shouldFocus:o,visible:s}=e,a=kc(t)?t.current:t,i=o&&s,l=b.useRef(i),c=b.useRef(s);pl(()=>{!c.current&&s&&(l.current=i),c.current=s},[s,i]);const u=b.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=hl(a);d.length>0&&requestAnimationFrame(()=>{d[0].focus({preventScroll:r})})}},[s,r,a,n]);Rr(()=>{u()},[u]),en(a,"transitionend",u)}function kc(t){return"current"in t}var Gt=(t,e)=>({var:t,varRef:e?`var(${t}, ${e})`:`var(${t})`}),je={arrowShadowColor:Gt("--popper-arrow-shadow-color"),arrowSize:Gt("--popper-arrow-size","8px"),arrowSizeHalf:Gt("--popper-arrow-size-half"),arrowBg:Gt("--popper-arrow-bg"),transformOrigin:Gt("--popper-transform-origin"),arrowOffset:Gt("--popper-arrow-offset")};function _c(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 Ec={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"},Cc=t=>Ec[t],Bs={scroll:!0,resize:!0};function Sc(t){let e;return typeof t=="object"?e={enabled:!0,options:{...Bs,...t}}:e={enabled:t,options:Bs},e}var jc={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`}},Dc={name:"transformOrigin",enabled:!0,phase:"write",fn:({state:t})=>{$s(t)},effect:({state:t})=>()=>{$s(t)}},$s=t=>{t.elements.popper.style.setProperty(je.transformOrigin.var,Cc(t.placement))},Oc={name:"positionArrow",enabled:!0,phase:"afterWrite",fn:({state:t})=>{Ic(t)}},Ic=t=>{var e;if(!t.placement)return;const n=Pc(t.placement);if((e=t.elements)!=null&&e.arrow&&n){Object.assign(t.elements.arrow.style,{[n.property]:n.value,width:je.arrowSize.varRef,height:je.arrowSize.varRef,zIndex:-1});const r={[je.arrowSizeHalf.var]:`calc(${je.arrowSize.varRef} / 2 - 1px)`,[je.arrowOffset.var]:`calc(${je.arrowSizeHalf.varRef} * -1)`};for(const o in r)t.elements.arrow.style.setProperty(o,r[o])}},Pc=t=>{if(t.startsWith("top"))return{property:"bottom",value:je.arrowOffset.varRef};if(t.startsWith("bottom"))return{property:"top",value:je.arrowOffset.varRef};if(t.startsWith("left"))return{property:"right",value:je.arrowOffset.varRef};if(t.startsWith("right"))return{property:"left",value:je.arrowOffset.varRef}},Nc={name:"innerArrow",enabled:!0,phase:"main",requires:["arrow"],fn:({state:t})=>{Ks(t)},effect:({state:t})=>()=>{Ks(t)}},Ks=t=>{if(!t.elements.arrow)return;const e=t.elements.arrow.querySelector("[data-popper-arrow-inner]");if(!e)return;const n=_c(t.placement);n&&e.style.setProperty("--popper-arrow-default-shadow",n),Object.assign(e.style,{transform:"rotate(45deg)",background:je.arrowBg.varRef,top:0,left:0,width:"100%",height:"100%",position:"absolute",zIndex:"inherit",boxShadow:"var(--popper-arrow-shadow, var(--popper-arrow-default-shadow))"})},Ac={"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"}},Fc={"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 Mc(t,e="ltr"){var n,r;const o=((n=Ac[t])==null?void 0:n[e])||t;return e==="ltr"?o:(r=Fc[t])!=null?r:o}var Ue="top",Ze="bottom",Qe="right",ze="left",us="auto",$n=[Ue,Ze,Qe,ze],sn="start",On="end",Rc="clippingParents",$a="viewport",yn="popper",Tc="reference",Us=$n.reduce(function(t,e){return t.concat([e+"-"+sn,e+"-"+On])},[]),Ka=[].concat($n,[us]).reduce(function(t,e){return t.concat([e,e+"-"+sn,e+"-"+On])},[]),Lc="beforeRead",Wc="read",Bc="afterRead",$c="beforeMain",Kc="main",Uc="afterMain",zc="beforeWrite",qc="write",Vc="afterWrite",Hc=[Lc,Wc,Bc,$c,Kc,Uc,zc,qc,Vc];function it(t){return t?(t.nodeName||"").toLowerCase():null}function Ve(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function zt(t){var e=Ve(t).Element;return t instanceof e||t instanceof Element}function Xe(t){var e=Ve(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ds(t){if(typeof ShadowRoot>"u")return!1;var e=Ve(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Jc(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!Xe(s)||!it(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 Gc(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,c){return l[c]="",l},{});!Xe(o)||!it(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Yc={name:"applyStyles",enabled:!0,phase:"write",fn:Jc,effect:Gc,requires:["computeStyles"]};function at(t){return t.split("-")[0]}var Lt=Math.max,vr=Math.min,an=Math.round;function yo(){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 Ua(){return!/^((?!chrome|android).)*safari/i.test(yo())}function ln(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xe(t)&&(o=t.offsetWidth>0&&an(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&an(r.height)/t.offsetHeight||1);var a=zt(t)?Ve(t):window,i=a.visualViewport,l=!Ua()&&n,c=(r.left+(l&&i?i.offsetLeft:0))/o,u=(r.top+(l&&i?i.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function fs(t){var e=ln(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function za(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ds(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function vt(t){return Ve(t).getComputedStyle(t)}function Xc(t){return["table","td","th"].indexOf(it(t))>=0}function It(t){return((zt(t)?t.ownerDocument:t.document)||window.document).documentElement}function Ur(t){return it(t)==="html"?t:t.assignedSlot||t.parentNode||(ds(t)?t.host:null)||It(t)}function zs(t){return!Xe(t)||vt(t).position==="fixed"?null:t.offsetParent}function Zc(t){var e=/firefox/i.test(yo()),n=/Trident/i.test(yo());if(n&&Xe(t)){var r=vt(t);if(r.position==="fixed")return null}var o=Ur(t);for(ds(o)&&(o=o.host);Xe(o)&&["html","body"].indexOf(it(o))<0;){var s=vt(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 Kn(t){for(var e=Ve(t),n=zs(t);n&&Xc(n)&&vt(n).position==="static";)n=zs(n);return n&&(it(n)==="html"||it(n)==="body"&&vt(n).position==="static")?e:n||Zc(t)||e}function ps(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function kn(t,e,n){return Lt(t,vr(e,n))}function Qc(t,e,n){var r=kn(t,e,n);return r>n?n:r}function qa(){return{top:0,right:0,bottom:0,left:0}}function Va(t){return Object.assign({},qa(),t)}function Ha(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var eu=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,Va(typeof e!="number"?e:Ha(e,$n))};function tu(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,a=n.modifiersData.popperOffsets,i=at(n.placement),l=ps(i),c=[ze,Qe].indexOf(i)>=0,u=c?"height":"width";if(!(!s||!a)){var d=eu(o.padding,n),f=fs(s),p=l==="y"?Ue:ze,y=l==="y"?Ze:Qe,h=n.rects.reference[u]+n.rects.reference[l]-a[l]-n.rects.popper[u],v=a[l]-n.rects.reference[l],w=Kn(s),g=w?l==="y"?w.clientHeight||0:w.clientWidth||0:0,x=h/2-v/2,E=d[p],S=g-f[u]-d[y],C=g/2-f[u]/2+x,k=kn(E,C,S),D=l;n.modifiersData[r]=(e={},e[D]=k,e.centerOffset=k-C,e)}}function nu(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)||za(e.elements.popper,o)&&(e.elements.arrow=o))}const ru={name:"arrow",enabled:!0,phase:"main",fn:tu,effect:nu,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function cn(t){return t.split("-")[1]}var ou={top:"auto",right:"auto",bottom:"auto",left:"auto"};function su(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:an(n*o)/o||0,y:an(r*o)/o||0}}function qs(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,a=t.offsets,i=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,f=a.x,p=f===void 0?0:f,y=a.y,h=y===void 0?0:y,v=typeof u=="function"?u({x:p,y:h}):{x:p,y:h};p=v.x,h=v.y;var w=a.hasOwnProperty("x"),g=a.hasOwnProperty("y"),x=ze,E=Ue,S=window;if(c){var C=Kn(n),k="clientHeight",D="clientWidth";if(C===Ve(n)&&(C=It(n),vt(C).position!=="static"&&i==="absolute"&&(k="scrollHeight",D="scrollWidth")),C=C,o===Ue||(o===ze||o===Qe)&&s===On){E=Ze;var j=d&&C===S&&S.visualViewport?S.visualViewport.height:C[k];h-=j-r.height,h*=l?1:-1}if(o===ze||(o===Ue||o===Ze)&&s===On){x=Qe;var A=d&&C===S&&S.visualViewport?S.visualViewport.width:C[D];p-=A-r.width,p*=l?1:-1}}var F=Object.assign({position:i},c&&ou),q=u===!0?su({x:p,y:h},Ve(n)):{x:p,y:h};if(p=q.x,h=q.y,l){var $;return Object.assign({},F,($={},$[E]=g?"0":"",$[x]=w?"0":"",$.transform=(S.devicePixelRatio||1)<=1?"translate("+p+"px, "+h+"px)":"translate3d("+p+"px, "+h+"px, 0)",$))}return Object.assign({},F,(e={},e[E]=g?h+"px":"",e[x]=w?p+"px":"",e.transform="",e))}function au(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,c={placement:at(e.placement),variation:cn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,qs(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,qs(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const iu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:au,data:{}};var Hn={passive:!0};function lu(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=Ve(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,Hn)}),i&&l.addEventListener("resize",n.update,Hn),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Hn)}),i&&l.removeEventListener("resize",n.update,Hn)}}const cu={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:lu,data:{}};var uu={left:"right",right:"left",bottom:"top",top:"bottom"};function or(t){return t.replace(/left|right|bottom|top/g,function(e){return uu[e]})}var du={start:"end",end:"start"};function Vs(t){return t.replace(/start|end/g,function(e){return du[e]})}function hs(t){var e=Ve(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function ms(t){return ln(It(t)).left+hs(t).scrollLeft}function fu(t,e){var n=Ve(t),r=It(t),o=n.visualViewport,s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;var c=Ua();(c||!c&&e==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:i+ms(t),y:l}}function pu(t){var e,n=It(t),r=hs(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Lt(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=Lt(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),i=-r.scrollLeft+ms(t),l=-r.scrollTop;return vt(o||n).direction==="rtl"&&(i+=Lt(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:a,x:i,y:l}}function ys(t){var e=vt(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function Ja(t){return["html","body","#document"].indexOf(it(t))>=0?t.ownerDocument.body:Xe(t)&&ys(t)?t:Ja(Ur(t))}function _n(t,e){var n;e===void 0&&(e=[]);var r=Ja(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Ve(r),a=o?[s].concat(s.visualViewport||[],ys(r)?r:[]):r,i=e.concat(a);return o?i:i.concat(_n(Ur(a)))}function vo(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function hu(t,e){var n=ln(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function Hs(t,e,n){return e===$a?vo(fu(t,n)):zt(e)?hu(e,n):vo(pu(It(t)))}function mu(t){var e=_n(Ur(t)),n=["absolute","fixed"].indexOf(vt(t).position)>=0,r=n&&Xe(t)?Kn(t):t;return zt(r)?e.filter(function(o){return zt(o)&&za(o,r)&&it(o)!=="body"}):[]}function yu(t,e,n,r){var o=e==="clippingParents"?mu(t):[].concat(e),s=[].concat(o,[n]),a=s[0],i=s.reduce(function(l,c){var u=Hs(t,c,r);return l.top=Lt(u.top,l.top),l.right=vr(u.right,l.right),l.bottom=vr(u.bottom,l.bottom),l.left=Lt(u.left,l.left),l},Hs(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 Ga(t){var e=t.reference,n=t.element,r=t.placement,o=r?at(r):null,s=r?cn(r):null,a=e.x+e.width/2-n.width/2,i=e.y+e.height/2-n.height/2,l;switch(o){case Ue:l={x:a,y:e.y-n.height};break;case Ze:l={x:a,y:e.y+e.height};break;case Qe:l={x:e.x+e.width,y:i};break;case ze:l={x:e.x-n.width,y:i};break;default:l={x:e.x,y:e.y}}var c=o?ps(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case sn:l[c]=l[c]-(e[u]/2-n[u]/2);break;case On:l[c]=l[c]+(e[u]/2-n[u]/2);break}}return l}function In(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?Rc:i,c=n.rootBoundary,u=c===void 0?$a:c,d=n.elementContext,f=d===void 0?yn:d,p=n.altBoundary,y=p===void 0?!1:p,h=n.padding,v=h===void 0?0:h,w=Va(typeof v!="number"?v:Ha(v,$n)),g=f===yn?Tc:yn,x=t.rects.popper,E=t.elements[y?g:f],S=yu(zt(E)?E:E.contextElement||It(t.elements.popper),l,u,a),C=ln(t.elements.reference),k=Ga({reference:C,element:x,strategy:"absolute",placement:o}),D=vo(Object.assign({},x,k)),j=f===yn?D:C,A={top:S.top-j.top+w.top,bottom:j.bottom-S.bottom+w.bottom,left:S.left-j.left+w.left,right:j.right-S.right+w.right},F=t.modifiersData.offset;if(f===yn&&F){var q=F[o];Object.keys(A).forEach(function($){var K=[Qe,Ze].indexOf($)>=0?1:-1,le=[Ue,Ze].indexOf($)>=0?"y":"x";A[$]+=q[le]*K})}return A}function vu(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,c=l===void 0?Ka:l,u=cn(r),d=u?i?Us:Us.filter(function(y){return cn(y)===u}):$n,f=d.filter(function(y){return c.indexOf(y)>=0});f.length===0&&(f=d);var p=f.reduce(function(y,h){return y[h]=In(t,{placement:h,boundary:o,rootBoundary:s,padding:a})[at(h)],y},{});return Object.keys(p).sort(function(y,h){return p[y]-p[h]})}function gu(t){if(at(t)===us)return[];var e=or(t);return[Vs(t),e,Vs(e)]}function wu(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,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,y=p===void 0?!0:p,h=n.allowedAutoPlacements,v=e.options.placement,w=at(v),g=w===v,x=l||(g||!y?[or(v)]:gu(v)),E=[v].concat(x).reduce(function(se,_){return se.concat(at(_)===us?vu(e,{placement:_,boundary:u,rootBoundary:d,padding:c,flipVariations:y,allowedAutoPlacements:h}):_)},[]),S=e.rects.reference,C=e.rects.popper,k=new Map,D=!0,j=E[0],A=0;A=0,le=K?"width":"height",z=In(e,{placement:F,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),I=K?$?Qe:ze:$?Ze:Ue;S[le]>C[le]&&(I=or(I));var Z=or(I),oe=[];if(s&&oe.push(z[q]<=0),i&&oe.push(z[I]<=0,z[Z]<=0),oe.every(function(se){return se})){j=F,D=!1;break}k.set(F,oe)}if(D)for(var he=y?3:1,be=function(_){var N=E.find(function(M){var L=k.get(M);if(L)return L.slice(0,_).every(function(X){return X})});if(N)return j=N,"break"},Ee=he;Ee>0;Ee--){var ce=be(Ee);if(ce==="break")break}e.placement!==j&&(e.modifiersData[r]._skip=!0,e.placement=j,e.reset=!0)}}const bu={name:"flip",enabled:!0,phase:"main",fn:wu,requiresIfExists:["offset"],data:{_skip:!1}};function Js(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 Gs(t){return[Ue,Qe,Ze,ze].some(function(e){return t[e]>=0})}function xu(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,a=In(e,{elementContext:"reference"}),i=In(e,{altBoundary:!0}),l=Js(a,r),c=Js(i,o,s),u=Gs(l),d=Gs(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const ku={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:xu};function _u(t,e,n){var r=at(t),o=[ze,Ue].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,[ze,Qe].indexOf(r)>=0?{x:i,y:a}:{x:a,y:i}}function Eu(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,a=Ka.reduce(function(u,d){return u[d]=_u(d,e.rects,s),u},{}),i=a[e.placement],l=i.x,c=i.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=a}const Cu={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Eu};function Su(t){var e=t.state,n=t.name;e.modifiersData[n]=Ga({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const ju={name:"popperOffsets",enabled:!0,phase:"read",fn:Su,data:{}};function Du(t){return t==="x"?"y":"x"}function Ou(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,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,y=n.tetherOffset,h=y===void 0?0:y,v=In(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),w=at(e.placement),g=cn(e.placement),x=!g,E=ps(w),S=Du(E),C=e.modifiersData.popperOffsets,k=e.rects.reference,D=e.rects.popper,j=typeof h=="function"?h(Object.assign({},e.rects,{placement:e.placement})):h,A=typeof j=="number"?{mainAxis:j,altAxis:j}:Object.assign({mainAxis:0,altAxis:0},j),F=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,q={x:0,y:0};if(C){if(s){var $,K=E==="y"?Ue:ze,le=E==="y"?Ze:Qe,z=E==="y"?"height":"width",I=C[E],Z=I+v[K],oe=I-v[le],he=p?-D[z]/2:0,be=g===sn?k[z]:D[z],Ee=g===sn?-D[z]:-k[z],ce=e.elements.arrow,se=p&&ce?fs(ce):{width:0,height:0},_=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:qa(),N=_[K],M=_[le],L=kn(0,k[z],se[z]),X=x?k[z]/2-he-L-N-A.mainAxis:be-L-N-A.mainAxis,G=x?-k[z]/2+he+L+M+A.mainAxis:Ee+L+M+A.mainAxis,ae=e.elements.arrow&&Kn(e.elements.arrow),V=ae?E==="y"?ae.clientTop||0:ae.clientLeft||0:0,W=($=F==null?void 0:F[E])!=null?$:0,ee=I+X-W-V,T=I+G-W,te=kn(p?vr(Z,ee):Z,I,p?Lt(oe,T):oe);C[E]=te,q[E]=te-I}if(i){var ne,ie=E==="x"?Ue:ze,Ie=E==="x"?Ze:Qe,Y=C[S],de=S==="y"?"height":"width",Ce=Y+v[ie],$e=Y-v[Ie],ue=[Ue,ze].indexOf(w)!==-1,Se=(ne=F==null?void 0:F[S])!=null?ne:0,ve=ue?Ce:Y-k[de]-D[de]-Se+A.altAxis,tt=ue?Y+k[de]+D[de]-Se-A.altAxis:$e,Ge=p&&ue?Qc(ve,Y,tt):kn(p?ve:Ce,Y,p?tt:$e);C[S]=Ge,q[S]=Ge-Y}e.modifiersData[r]=q}}const Iu={name:"preventOverflow",enabled:!0,phase:"main",fn:Ou,requiresIfExists:["offset"]};function Pu(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Nu(t){return t===Ve(t)||!Xe(t)?hs(t):Pu(t)}function Au(t){var e=t.getBoundingClientRect(),n=an(e.width)/t.offsetWidth||1,r=an(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Fu(t,e,n){n===void 0&&(n=!1);var r=Xe(e),o=Xe(e)&&Au(e),s=It(e),a=ln(t,o,n),i={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((it(e)!=="body"||ys(s))&&(i=Nu(e)),Xe(e)?(l=ln(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=ms(s))),{x:a.left+i.scrollLeft-l.x,y:a.top+i.scrollTop-l.y,width:a.width,height:a.height}}function Mu(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 Ru(t){var e=Mu(t);return Hc.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function Tu(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Lu(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 Ys={placement:"bottom",modifiers:[],strategy:"absolute"};function Xs(){for(var t=arguments.length,e=new Array(t),n=0;n{}),x=b.useCallback(()=>{var A;!e||!y.current||!h.current||((A=g.current)==null||A.call(g),v.current=$u(y.current,h.current,{placement:w,modifiers:[Nc,Oc,Dc,{...jc,enabled:!!f},{name:"eventListeners",...Sc(a)},{name:"arrow",options:{padding:s}},{name:"offset",options:{offset:i??[0,l]}},{name:"flip",enabled:!!c,options:{padding:8}},{name:"preventOverflow",enabled:!!d,options:{boundary:u}},...n??[]],strategy:o}),v.current.forceUpdate(),g.current=v.current.destroy)},[w,e,n,f,a,s,i,l,c,d,u,o]);b.useEffect(()=>()=>{var A;!y.current&&!h.current&&((A=v.current)==null||A.destroy(),v.current=null)},[]);const E=b.useCallback(A=>{y.current=A,x()},[x]),S=b.useCallback((A={},F=null)=>({...A,ref:Fe(E,F)}),[E]),C=b.useCallback(A=>{h.current=A,x()},[x]),k=b.useCallback((A={},F=null)=>({...A,ref:Fe(C,F),style:{...A.style,position:o,minWidth:f?void 0:"max-content",inset:"0 auto auto 0"}}),[o,C,f]),D=b.useCallback((A={},F=null)=>{const{size:q,shadowColor:$,bg:K,style:le,...z}=A;return{...z,ref:F,"data-popper-arrow":"",style:Ku(A)}},[]),j=b.useCallback((A={},F=null)=>({...A,ref:F,"data-popper-arrow-inner":""}),[]);return{update(){var A;(A=v.current)==null||A.update()},forceUpdate(){var A;(A=v.current)==null||A.forceUpdate()},transformOrigin:je.transformOrigin.varRef,referenceRef:E,popperRef:C,getPopperProps:k,getArrowProps:D,getArrowInnerProps:j,getReferenceProps:S}}function Ku(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 gs(t={}){const{onClose:e,onOpen:n,isOpen:r,id:o}=t,s=Rt(n),a=Rt(e),[i,l]=b.useState(t.defaultIsOpen||!1),c=r!==void 0?r:i,u=r!==void 0,d=b.useId(),f=o??`disclosure-${d}`,p=b.useCallback(()=>{u||l(!1),a==null||a()},[u,a]),y=b.useCallback(()=>{u||l(!0),s==null||s()},[u,s]),h=b.useCallback(()=>{c?p():y()},[c,y,p]);function v(g={}){return{...g,"aria-expanded":c,"aria-controls":f,onClick(x){var E;(E=g.onClick)==null||E.call(g,x),h()}}}function w(g={}){return{...g,hidden:!c,id:f}}return{isOpen:c,onOpen:y,onClose:p,onToggle:h,isControlled:u,getButtonProps:v,getDisclosureProps:w}}function Uu(t){const{ref:e,handler:n,enabled:r=!0}=t,o=Rt(n),a=b.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}).current;b.useEffect(()=>{if(!r)return;const i=d=>{Qr(d,e)&&(a.isPointerDown=!0)},l=d=>{if(a.ignoreEmulatedMouseEvents){a.ignoreEmulatedMouseEvents=!1;return}a.isPointerDown&&n&&Qr(d,e)&&(a.isPointerDown=!1,o(d))},c=d=>{a.ignoreEmulatedMouseEvents=!0,n&&a.isPointerDown&&Qr(d,e)&&(a.isPointerDown=!1,o(d))},u=Ya(e.current);return u.addEventListener("mousedown",i,!0),u.addEventListener("mouseup",l,!0),u.addEventListener("touchstart",i,!0),u.addEventListener("touchend",c,!0),()=>{u.removeEventListener("mousedown",i,!0),u.removeEventListener("mouseup",l,!0),u.removeEventListener("touchstart",i,!0),u.removeEventListener("touchend",c,!0)}},[n,e,o,a,r])}function Qr(t,e){var n;const r=t.target;return r&&!Ya(r).contains(r)?!1:!((n=e.current)!=null&&n.contains(r))}function Ya(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Xa(t){const{isOpen:e,ref:n}=t,[r,o]=b.useState(e),[s,a]=b.useState(!1);return b.useEffect(()=>{s||(o(e),a(!0))},[e,s,r]),en(()=>n.current,"animationend",()=>{o(e)}),{present:!(e?!1:!r),onComplete(){var l;const c=vl(n.current),u=new c.CustomEvent("animationend",{bubbles:!0});(l=n.current)==null||l.dispatchEvent(u)}}}function ws(t){const{wasSelected:e,enabled:n,isSelected:r,mode:o="unmount"}=t;return!!(!n||r||o==="keepMounted"&&e)}var[zu,qu,Vu,Hu]=Ca(),[Ju,Un]=et({strict:!1,name:"MenuContext"});function Gu(t,...e){const n=b.useId(),r=t||n;return b.useMemo(()=>e.map(o=>`${o}-${r}`),[r,e])}function Za(t){var e;return(e=t==null?void 0:t.ownerDocument)!=null?e:document}function Zs(t){return Za(t).activeElement===t}function Yu(t={}){const{id:e,closeOnSelect:n=!0,closeOnBlur:r=!0,initialFocusRef:o,autoSelect:s=!0,isLazy:a,isOpen:i,defaultIsOpen:l,onClose:c,onOpen:u,placement:d="bottom-start",lazyBehavior:f="unmount",direction:p,computePositionOnMount:y=!1,...h}=t,v=b.useRef(null),w=b.useRef(null),g=Vu(),x=b.useCallback(()=>{requestAnimationFrame(()=>{var ce;(ce=v.current)==null||ce.focus({preventScroll:!1})})},[]),E=b.useCallback(()=>{const ce=setTimeout(()=>{var se;if(o)(se=o.current)==null||se.focus();else{const _=g.firstEnabled();_&&$(_.index)}});Z.current.add(ce)},[g,o]),S=b.useCallback(()=>{const ce=setTimeout(()=>{const se=g.lastEnabled();se&&$(se.index)});Z.current.add(ce)},[g]),C=b.useCallback(()=>{u==null||u(),s?E():x()},[s,E,x,u]),{isOpen:k,onOpen:D,onClose:j,onToggle:A}=gs({isOpen:i,defaultIsOpen:l,onClose:c,onOpen:C});Uu({enabled:k&&r,ref:v,handler:ce=>{var se;(se=w.current)!=null&&se.contains(ce.target)||j()}});const F=vs({...h,enabled:k||y,placement:d,direction:p}),[q,$]=b.useState(-1);Rr(()=>{k||$(-1)},[k]),Ba(v,{focusRef:w,visible:k,shouldFocus:!0});const K=Xa({isOpen:k,ref:v}),[le,z]=Gu(e,"menu-button","menu-list"),I=b.useCallback(()=>{D(),x()},[D,x]),Z=b.useRef(new Set([]));b.useEffect(()=>{const ce=Z.current;return()=>{ce.forEach(se=>clearTimeout(se)),ce.clear()}},[]);const oe=b.useCallback(()=>{D(),E()},[E,D]),he=b.useCallback(()=>{D(),S()},[D,S]),be=b.useCallback(()=>{var ce,se;const _=Za(v.current),N=(ce=v.current)==null?void 0:ce.contains(_.activeElement);if(!(k&&!N))return;const L=(se=g.item(q))==null?void 0:se.node;L==null||L.focus({preventScroll:!0})},[k,q,g]),Ee=b.useRef(null);return{openAndFocusMenu:I,openAndFocusFirstItem:oe,openAndFocusLastItem:he,onTransitionEnd:be,unstable__animationState:K,descendants:g,popper:F,buttonId:le,menuId:z,forceUpdate:F.forceUpdate,orientation:"vertical",isOpen:k,onToggle:A,onOpen:D,onClose:j,menuRef:v,buttonRef:w,focusedIndex:q,closeOnSelect:n,closeOnBlur:r,autoSelect:s,setFocusedIndex:$,isLazy:a,lazyBehavior:f,initialFocusRef:o,rafId:Ee}}function rh(t={},e=null){const n=Un(),{onToggle:r,popper:o,openAndFocusFirstItem:s,openAndFocusLastItem:a}=n,i=b.useCallback(l=>{const c=l.key,d={Enter:s,ArrowDown:s,ArrowUp:a}[c];d&&(l.preventDefault(),l.stopPropagation(),d(l))},[s,a]);return{...t,ref:Fe(n.buttonRef,e,o.referenceRef),id:n.buttonId,"data-active":ot(n.isOpen),"aria-expanded":n.isOpen,"aria-haspopup":"menu","aria-controls":n.menuId,onClick:xe(t.onClick,r),onKeyDown:xe(t.onKeyDown,i)}}function go(t){var e;return Qu(t)&&!!((e=t==null?void 0:t.getAttribute("role"))!=null&&e.startsWith("menuitem"))}function Xu(t={},e=null){const n=Un();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:c,lazyBehavior:u,unstable__animationState:d}=n,f=qu(),p=yc({preventDefault:w=>w.key!==" "&&go(w.target)}),y=b.useCallback(w=>{if(!w.currentTarget.contains(w.target))return;const g=w.key,E={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)}}[g];if(E){w.preventDefault(),E(w);return}const S=p(C=>{const k=vc(f.values(),C,D=>{var j,A;return(A=(j=D==null?void 0:D.node)==null?void 0:j.textContent)!=null?A:""},f.item(r));if(k){const D=f.indexOf(k.node);o(D)}});go(w.target)&&S(w)},[f,r,p,i,o]),h=b.useRef(!1);a&&(h.current=!0);const v=ws({wasSelected:h.current,enabled:c,mode:u,isSelected:d.present});return{...t,ref:Fe(s,e),children:v?t.children:null,tabIndex:-1,role:"menu",id:l,style:{...t.style,transformOrigin:"var(--popper-transform-origin)"},"aria-orientation":"vertical",onKeyDown:xe(t.onKeyDown,y)}}function Zu(t={}){const{popper:e,isOpen:n}=Un();return e.getPopperProps({...t,style:{visibility:n?"visible":"hidden",...t.style}})}function Qa(t={},e=null){const{onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onClick:s,onFocus:a,isDisabled:i,isFocusable:l,closeOnSelect:c,type:u,...d}=t,f=Un(),{setFocusedIndex:p,focusedIndex:y,closeOnSelect:h,onClose:v,menuRef:w,isOpen:g,menuId:x,rafId:E}=f,S=b.useRef(null),C=`${x}-menuitem-${b.useId()}`,{index:k,register:D}=Hu({disabled:i&&!l}),j=b.useCallback(I=>{n==null||n(I),!i&&p(k)},[p,k,i,n]),A=b.useCallback(I=>{r==null||r(I),S.current&&!Zs(S.current)&&j(I)},[j,r]),F=b.useCallback(I=>{o==null||o(I),!i&&p(-1)},[p,i,o]),q=b.useCallback(I=>{s==null||s(I),go(I.currentTarget)&&(c??h)&&v()},[v,s,h,c]),$=b.useCallback(I=>{a==null||a(I),p(k)},[p,a,k]),K=k===y,le=i&&!l;Rr(()=>{if(g)return K&&!le&&S.current?(E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(()=>{var I;(I=S.current)==null||I.focus({preventScroll:!0}),E.current=null})):w.current&&!Zs(w.current)&&w.current.focus({preventScroll:!0}),()=>{E.current&&cancelAnimationFrame(E.current)}},[K,le,w,g]);const z=Wa({onClick:q,onFocus:$,onMouseEnter:j,onMouseMove:A,onMouseLeave:F,ref:Fe(D,S,e),isDisabled:i,isFocusable:l});return{...d,...z,type:u??z.type,id:C,role:"menuitem",tabIndex:K?0:-1}}function oh(t={},e=null){const{type:n="radio",isChecked:r,...o}=t;return{...Qa(o,e),role:`menuitem${n}`,"aria-checked":r}}function sh(t={}){const{children:e,type:n="radio",value:r,defaultValue:o,onChange:s,...a}=t,l=n==="radio"?"":[],[c,u]=Sa({defaultValue:o??l,value:r,onChange:s}),d=b.useCallback(y=>{if(n==="radio"&&typeof c=="string"&&u(y),n==="checkbox"&&Array.isArray(c)){const h=c.includes(y)?c.filter(v=>v!==y):c.concat(y);u(h)}},[c,u,n]),p=cs(e).map(y=>{if(y.type.id!=="MenuItemOption")return y;const h=w=>{var g,x;d(y.props.value),(x=(g=y.props).onClick)==null||x.call(g,w)},v=n==="radio"?y.props.value===c:c.includes(y.props.value);return b.cloneElement(y,{type:n,onClick:h,isChecked:v})});return{...a,children:p}}function Qu(t){var e;if(!ed(t))return!1;const n=(e=t.ownerDocument.defaultView)!=null?e:window;return t instanceof n.HTMLElement}function ed(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&t.nodeType===Node.ELEMENT_NODE}var[td,zr]=et({name:"MenuStylesContext",errorMessage:`useMenuStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),bs=t=>{const{children:e}=t,n=Ot("Menu",t),r=Je(t),{direction:o}=ts(),{descendants:s,...a}=Yu({...r,direction:o}),i=b.useMemo(()=>a,[a]),{isOpen:l,onClose:c,forceUpdate:u}=i;return m.jsx(zu,{value:s,children:m.jsx(Ju,{value:i,children:m.jsx(td,{value:n,children:ga(e,{isOpen:l,onClose:c,forceUpdate:u})})})})};bs.displayName="Menu";var ei=Q((t,e)=>{const n=zr();return m.jsx(J.span,{ref:e,...t,__css:n.command,className:"chakra-menu__command"})});ei.displayName="MenuCommand";var nd=Q((t,e)=>{const{type:n,...r}=t,o=zr(),s=r.as||n?n??void 0:"button",a=b.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 m.jsx(J.button,{ref:e,type:s,...r,__css:a})}),ti=t=>{const{className:e,children:n,...r}=t,o=zr(),s=b.Children.only(n),a=b.isValidElement(s)?b.cloneElement(s,{focusable:"false","aria-hidden":!0,className:pe("chakra-menu__icon",s.props.className)}):null,i=pe("chakra-menu__icon-wrapper",e);return m.jsx(J.span,{className:i,...r,__css:o.icon,children:a})};ti.displayName="MenuIcon";var wt=Q((t,e)=>{const{icon:n,iconSpacing:r="0.75rem",command:o,commandSpacing:s="0.75rem",children:a,...i}=t,l=Qa(i,e),u=n||o?m.jsx("span",{style:{pointerEvents:"none",flex:1},children:a}):a;return m.jsxs(nd,{...l,className:pe("chakra-menu__menuitem",l.className),children:[n&&m.jsx(ti,{fontSize:"0.8em",marginEnd:r,children:n}),u,o&&m.jsx(ei,{marginStart:s,children:o})]})});wt.displayName="MenuItem";var rd={enter:{visibility:"visible",opacity:1,scale:1,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{transitionEnd:{visibility:"hidden"},opacity:0,scale:.8,transition:{duration:.1,easings:"easeOut"}}},od=J(ns.div),xs=Q(function(e,n){var r,o;const{rootProps:s,motionProps:a,...i}=e,{isOpen:l,onTransitionEnd:c,unstable__animationState:u}=Un(),d=Xu(i,n),f=Zu(s),p=zr();return m.jsx(J.div,{...f,__css:{zIndex:(o=e.zIndex)!=null?o:(r=p.list)==null?void 0:r.zIndex},children:m.jsx(od,{variants:rd,initial:!1,animate:l?"enter":"exit",__css:{outline:0,...p.list},...a,className:pe("chakra-menu__menu-list",d.className),...d,onUpdate:c,onAnimationComplete:wa(u.onComplete,d.onAnimationComplete)})})});xs.displayName="MenuList";var[sd,fn]=et({name:"PopoverContext",errorMessage:"usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within ``"}),[ad,qr]=et({name:"PopoverStylesContext",errorMessage:`usePopoverStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `});function ni(t){const e=b.Children.only(t.children),{getTriggerProps:n}=fn();return b.cloneElement(e,n(e.props,e.ref))}ni.displayName="PopoverTrigger";var Yt={click:"click",hover:"hover"};function id(t={}){const{closeOnBlur:e=!0,closeOnEsc:n=!0,initialFocusRef:r,id:o,returnFocusOnClose:s=!0,autoFocus:a=!0,arrowSize:i,arrowShadowColor:l,trigger:c=Yt.click,openDelay:u=200,closeDelay:d=200,isLazy:f,lazyBehavior:p="unmount",computePositionOnMount:y,...h}=t,{isOpen:v,onClose:w,onOpen:g,onToggle:x}=gs(t),E=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(!1),D=b.useRef(!1);v&&(D.current=!0);const[j,A]=b.useState(!1),[F,q]=b.useState(!1),$=b.useId(),K=o??$,[le,z,I,Z]=["popover-trigger","popover-content","popover-header","popover-body"].map(T=>`${T}-${K}`),{referenceRef:oe,getArrowProps:he,getPopperProps:be,getArrowInnerProps:Ee,forceUpdate:ce}=vs({...h,enabled:v||!!y}),se=Xa({isOpen:v,ref:C});Zl({enabled:v,ref:S}),Ba(C,{focusRef:S,visible:v,shouldFocus:s&&c===Yt.click}),xc(C,{focusRef:r,visible:v,shouldFocus:a&&c===Yt.click});const _=ws({wasSelected:D.current,enabled:f,mode:p,isSelected:se.present}),N=b.useCallback((T={},te=null)=>{const ne={...T,style:{...T.style,transformOrigin:je.transformOrigin.varRef,[je.arrowSize.var]:i?`${i}px`:void 0,[je.arrowShadowColor.var]:l},ref:Fe(C,te),children:_?T.children:null,id:z,tabIndex:-1,role:"dialog",onKeyDown:xe(T.onKeyDown,ie=>{n&&ie.key==="Escape"&&w()}),onBlur:xe(T.onBlur,ie=>{const Ie=Qs(ie),Y=eo(C.current,Ie),de=eo(S.current,Ie);v&&e&&(!Y&&!de)&&w()}),"aria-labelledby":j?I:void 0,"aria-describedby":F?Z:void 0};return c===Yt.hover&&(ne.role="tooltip",ne.onMouseEnter=xe(T.onMouseEnter,()=>{k.current=!0}),ne.onMouseLeave=xe(T.onMouseLeave,ie=>{ie.nativeEvent.relatedTarget!==null&&(k.current=!1,setTimeout(()=>w(),d))})),ne},[_,z,j,I,F,Z,c,n,w,v,e,d,l,i]),M=b.useCallback((T={},te=null)=>be({...T,style:{visibility:v?"visible":"hidden",...T.style}},te),[v,be]),L=b.useCallback((T,te=null)=>({...T,ref:Fe(te,E,oe)}),[E,oe]),X=b.useRef(),G=b.useRef(),ae=b.useCallback(T=>{E.current==null&&oe(T)},[oe]),V=b.useCallback((T={},te=null)=>{const ne={...T,ref:Fe(S,te,ae),id:le,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":z};return c===Yt.click&&(ne.onClick=xe(T.onClick,x)),c===Yt.hover&&(ne.onFocus=xe(T.onFocus,()=>{X.current===void 0&&g()}),ne.onBlur=xe(T.onBlur,ie=>{const Ie=Qs(ie),Y=!eo(C.current,Ie);v&&e&&Y&&w()}),ne.onKeyDown=xe(T.onKeyDown,ie=>{ie.key==="Escape"&&w()}),ne.onMouseEnter=xe(T.onMouseEnter,()=>{k.current=!0,X.current=window.setTimeout(()=>g(),u)}),ne.onMouseLeave=xe(T.onMouseLeave,()=>{k.current=!1,X.current&&(clearTimeout(X.current),X.current=void 0),G.current=window.setTimeout(()=>{k.current===!1&&w()},d)})),ne},[le,v,z,c,ae,x,g,e,w,u,d]);b.useEffect(()=>()=>{X.current&&clearTimeout(X.current),G.current&&clearTimeout(G.current)},[]);const W=b.useCallback((T={},te=null)=>({...T,id:I,ref:Fe(te,ne=>{A(!!ne)})}),[I]),ee=b.useCallback((T={},te=null)=>({...T,id:Z,ref:Fe(te,ne=>{q(!!ne)})}),[Z]);return{forceUpdate:ce,isOpen:v,onAnimationComplete:se.onComplete,onClose:w,getAnchorProps:L,getArrowProps:he,getArrowInnerProps:Ee,getPopoverPositionerProps:M,getPopoverProps:N,getTriggerProps:V,getHeaderProps:W,getBodyProps:ee}}function eo(t,e){return t===e||(t==null?void 0:t.contains(e))}function Qs(t){var e;const n=t.currentTarget.ownerDocument.activeElement;return(e=t.relatedTarget)!=null?e:n}function ri(t){const e=Ot("Popover",t),{children:n,...r}=Je(t),o=ts(),s=id({...r,direction:o.direction});return m.jsx(sd,{value:s,children:m.jsx(ad,{value:e,children:ga(n,{isOpen:s.isOpen,onClose:s.onClose,forceUpdate:s.forceUpdate})})})}ri.displayName="Popover";var to=(t,e)=>e?`${t}.${e}, ${e}`:void 0;function oi(t){var e;const{bg:n,bgColor:r,backgroundColor:o,shadow:s,boxShadow:a,shadowColor:i}=t,{getArrowProps:l,getArrowInnerProps:c}=fn(),u=qr(),d=(e=n??r)!=null?e:o,f=s??a;return m.jsx(J.div,{...l(),className:"chakra-popover__arrow-positioner",children:m.jsx(J.div,{className:pe("chakra-popover__arrow",t.className),...c(t),__css:{"--popper-arrow-shadow-color":to("colors",i),"--popper-arrow-bg":to("colors",d),"--popper-arrow-shadow":to("shadows",f),...u.arrow}})})}oi.displayName="PopoverArrow";var si=Q(function(e,n){const{getBodyProps:r}=fn(),o=qr();return m.jsx(J.div,{...r(e,n),className:pe("chakra-popover__body",e.className),__css:o.body})});si.displayName="PopoverBody";var ai=Q(function(e,n){const{onClose:r}=fn(),o=qr();return m.jsx(gl,{size:"sm",onClick:r,className:pe("chakra-popover__close-btn",e.className),__css:o.closeButton,ref:n,...e})});ai.displayName="PopoverCloseButton";function ld(t){if(t)return{enter:{...t.enter,visibility:"visible"},exit:{...t.exit,transitionEnd:{visibility:"hidden"}}}}var cd={exit:{opacity:0,scale:.95,transition:{duration:.1,ease:[.4,0,1,1]}},enter:{scale:1,opacity:1,transition:{duration:.15,ease:[0,0,.2,1]}}},ud=J(ns.section),ii=Q(function(e,n){const{variants:r=cd,...o}=e,{isOpen:s}=fn();return m.jsx(ud,{ref:n,variants:ld(r),initial:!1,animate:s?"enter":"exit",...o})});ii.displayName="PopoverTransition";var li=Q(function(e,n){const{rootProps:r,motionProps:o,...s}=e,{getPopoverProps:a,getPopoverPositionerProps:i,onAnimationComplete:l}=fn(),c=qr(),u={position:"relative",display:"flex",flexDirection:"column",...c.content};return m.jsx(J.div,{...i(r),__css:c.popper,className:"chakra-popover__popper",children:m.jsx(ii,{...o,...a(s,n),onAnimationComplete:wa(l,s.onAnimationComplete),className:pe("chakra-popover__content",e.className),__css:u})})});li.displayName="PopoverContent";var[dd,fd,pd,hd]=Ca();function md(t){var e;const{defaultIndex:n,onChange:r,index:o,isManual:s,isLazy:a,lazyBehavior:i="unmount",orientation:l="horizontal",direction:c="ltr",...u}=t,[d,f]=b.useState(n??0),[p,y]=Sa({defaultValue:n??0,value:o,onChange:r});b.useEffect(()=>{o!=null&&f(o)},[o]);const h=pd(),v=b.useId();return{id:`tabs-${(e=t.id)!=null?e:v}`,selectedIndex:p,focusedIndex:d,setSelectedIndex:y,setFocusedIndex:f,isManual:s,isLazy:a,lazyBehavior:i,orientation:l,descendants:h,direction:c,htmlProps:u}}var[yd,Vr]=et({name:"TabsContext",errorMessage:"useTabsContext: `context` is undefined. Seems you forgot to wrap all tabs components within "});function vd(t){const{focusedIndex:e,orientation:n,direction:r}=Vr(),o=fd(),s=b.useCallback(a=>{const i=()=>{var g;const x=o.nextEnabled(e);x&&((g=x.node)==null||g.focus())},l=()=>{var g;const x=o.prevEnabled(e);x&&((g=x.node)==null||g.focus())},c=()=>{var g;const x=o.firstEnabled();x&&((g=x.node)==null||g.focus())},u=()=>{var g;const x=o.lastEnabled();x&&((g=x.node)==null||g.focus())},d=n==="horizontal",f=n==="vertical",p=a.key,y=r==="ltr"?"ArrowLeft":"ArrowRight",h=r==="ltr"?"ArrowRight":"ArrowLeft",w={[y]:()=>d&&l(),[h]:()=>d&&i(),ArrowDown:()=>f&&i(),ArrowUp:()=>f&&l(),Home:c,End:u}[p];w&&(a.preventDefault(),w(a))},[o,e,n,r]);return{...t,role:"tablist","aria-orientation":n,onKeyDown:xe(t.onKeyDown,s)}}function gd(t){const{isDisabled:e=!1,isFocusable:n=!1,...r}=t,{setSelectedIndex:o,isManual:s,id:a,setFocusedIndex:i,selectedIndex:l}=Vr(),{index:c,register:u}=hd({disabled:e&&!n}),d=c===l,f=()=>{o(c)},p=()=>{i(c),!s&&!(e&&n)&&o(c)},y=Wa({...r,ref:Fe(u,t.ref),isDisabled:e,isFocusable:n,onClick:xe(t.onClick,f)}),h="button";return{...y,id:ci(a,c),role:"tab",tabIndex:d?0:-1,type:h,"aria-selected":d,"aria-controls":ui(a,c),onFocus:e?void 0:xe(t.onFocus,p)}}var[wd,bd]=et({});function xd(t){const e=Vr(),{id:n,selectedIndex:r}=e,s=cs(t.children).map((a,i)=>b.createElement(wd,{key:i,value:{isSelected:i===r,id:ui(n,i),tabId:ci(n,i),selectedIndex:r}},a));return{...t,children:s}}function kd(t){const{children:e,...n}=t,{isLazy:r,lazyBehavior:o}=Vr(),{isSelected:s,id:a,tabId:i}=bd(),l=b.useRef(!1);s&&(l.current=!0);const c=ws({wasSelected:l.current,isSelected:s,enabled:r,mode:o});return{tabIndex:0,...n,children:c?e:null,role:"tabpanel","aria-labelledby":i,hidden:!s,id:a}}function ci(t,e){return`${t}--tab-${e}`}function ui(t,e){return`${t}--tabpanel-${e}`}var[_d,Hr]=et({name:"TabsStylesContext",errorMessage:`useTabsStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),di=Q(function(e,n){const r=Ot("Tabs",e),{children:o,className:s,...a}=Je(e),{htmlProps:i,descendants:l,...c}=md(a),u=b.useMemo(()=>c,[c]),{isFitted:d,...f}=i,p={position:"relative",...r.root};return m.jsx(dd,{value:l,children:m.jsx(yd,{value:u,children:m.jsx(_d,{value:r,children:m.jsx(J.div,{className:pe("chakra-tabs",s),ref:n,...f,__css:p,children:o})})})})});di.displayName="Tabs";var fi=Q(function(e,n){const r=vd({...e,ref:n}),s={display:"flex",...Hr().tablist};return m.jsx(J.div,{...r,className:pe("chakra-tabs__tablist",e.className),__css:s})});fi.displayName="TabList";var wo=Q(function(e,n){const r=kd({...e,ref:n}),o=Hr();return m.jsx(J.div,{outline:"0",...r,className:pe("chakra-tabs__tab-panel",e.className),__css:o.tabpanel})});wo.displayName="TabPanel";var pi=Q(function(e,n){const r=xd(e),o=Hr();return m.jsx(J.div,{...r,width:"100%",ref:n,className:pe("chakra-tabs__tab-panels",e.className),__css:o.tabpanels})});pi.displayName="TabPanels";var bo=Q(function(e,n){const r=Hr(),o=gd({...e,ref:n}),s={outline:"0",display:"flex",alignItems:"center",justifyContent:"center",...r.tab};return m.jsx(J.button,{...o,className:pe("chakra-tabs__tab",e.className),__css:s})});bo.displayName="Tab";var[Ed,hi]=et({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),mi=Q((t,e)=>{const n=Ot("Tag",t),r=Je(t),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...n.container};return m.jsx(Ed,{value:n,children:m.jsx(J.span,{ref:e,...r,__css:o})})});mi.displayName="Tag";var Cd=Q((t,e)=>{const n=hi();return m.jsx(J.span,{ref:e,noOfLines:1,...t,__css:n.label})});Cd.displayName="TagLabel";var Sd=Q((t,e)=>m.jsx(Mr,{ref:e,verticalAlign:"top",marginEnd:"0.5rem",...t}));Sd.displayName="TagLeftIcon";var jd=Q((t,e)=>m.jsx(Mr,{ref:e,verticalAlign:"top",marginStart:"0.5rem",...t}));jd.displayName="TagRightIcon";var yi=t=>m.jsx(Mr,{verticalAlign:"inherit",viewBox:"0 0 512 512",...t,children:m.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});yi.displayName="TagCloseIcon";var Dd=Q((t,e)=>{const{isDisabled:n,children:r,...o}=t,a={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...hi().closeButton};return m.jsx(J.button,{ref:e,"aria-label":"close",...o,type:"button",disabled:n,__css:a,children:r||m.jsx(yi,{})})});Dd.displayName="TagCloseButton";var Od={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]}}}},xo=t=>{var e;return((e=t.current)==null?void 0:e.ownerDocument)||document},sr=t=>{var e,n;return((n=(e=t.current)==null?void 0:e.ownerDocument)==null?void 0:n.defaultView)||window};function Id(t={}){const{openDelay:e=0,closeDelay:n=0,closeOnClick:r=!0,closeOnMouseDown:o,closeOnScroll:s,closeOnPointerDown:a=o,closeOnEsc:i=!0,onOpen:l,onClose:c,placement:u,id:d,isOpen:f,defaultIsOpen:p,arrowSize:y=10,arrowShadowColor:h,arrowPadding:v,modifiers:w,isDisabled:g,gutter:x,offset:E,direction:S,...C}=t,{isOpen:k,onOpen:D,onClose:j}=gs({isOpen:f,defaultIsOpen:p,onOpen:l,onClose:c}),{referenceRef:A,getPopperProps:F,getArrowInnerProps:q,getArrowProps:$}=vs({enabled:k,placement:u,arrowPadding:v,modifiers:w,gutter:x,offset:E,direction:S}),K=b.useId(),z=`tooltip-${d??K}`,I=b.useRef(null),Z=b.useRef(),oe=b.useCallback(()=>{Z.current&&(clearTimeout(Z.current),Z.current=void 0)},[]),he=b.useRef(),be=b.useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=void 0)},[]),Ee=b.useCallback(()=>{be(),j()},[j,be]),ce=Pd(I,Ee),se=b.useCallback(()=>{if(!g&&!Z.current){k&&ce();const V=sr(I);Z.current=V.setTimeout(D,e)}},[ce,g,k,D,e]),_=b.useCallback(()=>{oe();const V=sr(I);he.current=V.setTimeout(Ee,n)},[n,Ee,oe]),N=b.useCallback(()=>{k&&r&&_()},[r,_,k]),M=b.useCallback(()=>{k&&a&&_()},[a,_,k]),L=b.useCallback(V=>{k&&V.key==="Escape"&&_()},[k,_]);en(()=>xo(I),"keydown",i?L:void 0),en(()=>{if(!s)return null;const V=I.current;if(!V)return null;const W=Fa(V);return W.localName==="body"?sr(I):W},"scroll",()=>{k&&s&&Ee()},{passive:!0,capture:!0}),b.useEffect(()=>{g&&(oe(),k&&j())},[g,k,j,oe]),b.useEffect(()=>()=>{oe(),be()},[oe,be]),en(()=>I.current,"pointerleave",_);const X=b.useCallback((V={},W=null)=>({...V,ref:Fe(I,W,A),onPointerEnter:xe(V.onPointerEnter,T=>{T.pointerType!=="touch"&&se()}),onClick:xe(V.onClick,N),onPointerDown:xe(V.onPointerDown,M),onFocus:xe(V.onFocus,se),onBlur:xe(V.onBlur,_),"aria-describedby":k?z:void 0}),[se,_,M,k,z,N,A]),G=b.useCallback((V={},W=null)=>F({...V,style:{...V.style,[je.arrowSize.var]:y?`${y}px`:void 0,[je.arrowShadowColor.var]:h}},W),[F,y,h]),ae=b.useCallback((V={},W=null)=>{const ee={...V.style,position:"relative",transformOrigin:je.transformOrigin.varRef};return{ref:W,...C,...V,id:z,role:"tooltip",style:ee}},[C,z]);return{isOpen:k,show:se,hide:_,getTriggerProps:X,getTooltipProps:ae,getTooltipPositionerProps:G,getArrowProps:$,getArrowInnerProps:q}}var no="chakra-ui:close-tooltip";function Pd(t,e){return b.useEffect(()=>{const n=xo(t);return n.addEventListener(no,e),()=>n.removeEventListener(no,e)},[e,t]),()=>{const n=xo(t),r=sr(t);n.dispatchEvent(new r.CustomEvent(no))}}function Nd(t,e=[]){const n=Object.assign({},t);for(const r of e)r in n&&delete n[r];return n}function Ad(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}var Fd=J(ns.div),Wt=Q((t,e)=>{var n,r;const o=Wn("Tooltip",t),s=Je(t),a=ts(),{children:i,label:l,shouldWrapChildren:c,"aria-label":u,hasArrow:d,bg:f,portalProps:p,background:y,backgroundColor:h,bgColor:v,motionProps:w,...g}=s,x=(r=(n=y??h)!=null?n:f)!=null?r:v;if(x){o.bg=x;const F=wl(a,"colors",x);o[je.arrowBg.var]=F}const E=Id({...g,direction:a.direction}),S=typeof i=="string"||c;let C;if(S)C=m.jsx(J.span,{display:"inline-block",tabIndex:0,...E.getTriggerProps(),children:i});else{const F=b.Children.only(i);C=b.cloneElement(F,E.getTriggerProps(F.props,F.ref))}const k=!!u,D=E.getTooltipProps({},e),j=k?Nd(D,["role","id"]):D,A=Ad(D,["role","id"]);return l?m.jsxs(m.Fragment,{children:[C,m.jsx(bl,{children:E.isOpen&&m.jsx(ba,{...p,children:m.jsx(J.div,{...E.getTooltipPositionerProps(),__css:{zIndex:o.zIndex,pointerEvents:"none"},children:m.jsxs(Fd,{variants:Od,initial:"exit",animate:"enter",exit:"exit",...w,...j,__css:o,children:[l,k&&m.jsx(J.span,{srOnly:!0,...A,children:u}),d&&m.jsx(J.div,{"data-popper-arrow":!0,className:"chakra-tooltip__arrow-wrapper",children:m.jsx(J.div,{"data-popper-arrow-inner":!0,className:"chakra-tooltip__arrow",__css:{bg:o.bg}})})]})})})})]}):m.jsx(m.Fragment,{children:i})});Wt.displayName="Tooltip";let Jn;const Md=new Uint8Array(16);function Rd(){if(!Jn&&(Jn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Jn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Jn(Md)}const Ne=[];for(let t=0;t<256;++t)Ne.push((t+256).toString(16).slice(1));function Td(t,e=0){return Ne[t[e+0]]+Ne[t[e+1]]+Ne[t[e+2]]+Ne[t[e+3]]+"-"+Ne[t[e+4]]+Ne[t[e+5]]+"-"+Ne[t[e+6]]+Ne[t[e+7]]+"-"+Ne[t[e+8]]+Ne[t[e+9]]+"-"+Ne[t[e+10]]+Ne[t[e+11]]+Ne[t[e+12]]+Ne[t[e+13]]+Ne[t[e+14]]+Ne[t[e+15]]}const Ld=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ea={randomUUID:Ld};function Pn(t,e,n){if(ea.randomUUID&&!e&&!t)return ea.randomUUID();t=t||{};const r=t.random||(t.rng||Rd)();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 Td(r)}async function Wd(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 Bd(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 vi(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 gi(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 ah(){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 ih(){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 lh(){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)}}const Kd="backup",gr="workspace";let Gn=null;function Ud(){return new Promise((t,e)=>{const n=indexedDB.open("WorkspaceDB",3);n.onupgradeneeded=r=>{const o=r.target.result;o.objectStoreNames.contains(gr)||o.createObjectStore(gr,{keyPath:"id"})},n.onsuccess=r=>{t(r.target.result)},n.onerror=r=>{e(r.target.error)}})}async function zd(){try{return Gn==null&&(Gn=await Ud()),new Promise((t,e)=>{if(Gn==null)return e("indexDB is null");const o=Gn.transaction([gr],"readonly").objectStore(gr).get(Kd);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 qd(){try{return await zd()}catch(t){console.error("Error retrieving data from IndexedDB:",t)}}const ye=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,De=Object.keys,Re=Array.isArray;function Be(t,e){return typeof e!="object"||De(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||ye.Promise||(ye.Promise=Promise);const Nn=Object.getPrototypeOf,Vd={}.hasOwnProperty;function He(t,e){return Vd.call(t,e)}function un(t,e){typeof e=="function"&&(e=e(Nn(t))),(typeof Reflect>"u"?De:Reflect.ownKeys)(e).forEach(n=>{mt(t,n,e[n])})}const wi=Object.defineProperty;function mt(t,e,n,r){wi(t,e,Be(n&&He(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function tn(t){return{from:function(e){return t.prototype=Object.create(e.prototype),mt(t.prototype,"constructor",t),{extend:un.bind(null,t.prototype)}}}}const Hd=Object.getOwnPropertyDescriptor;function ks(t,e){let n;return Hd(t,e)||(n=Nn(t))&&ks(n,e)}const Jd=[].slice;function wr(t,e,n){return Jd.call(t,e,n)}function bi(t,e){return e(t)}function gn(t){if(!t)throw new Error("Assertion Failed")}function xi(t){ye.setImmediate?setImmediate(t):setTimeout(t,0)}function ki(t,e){return t.reduce((n,r,o)=>{var s=e(r,o);return s&&(n[s[0]]=s[1]),n},{})}function yt(t,e){if(He(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=>ye[t]),Yd=Ci.map(t=>ye[t]);ki(Ci,t=>[t,!0]);let xt=null;function zn(t){xt=typeof WeakMap<"u"&&new WeakMap;const e=ko(t);return xt=null,e}function ko(t){if(!t||typeof t!="object")return t;let e=xt&&xt.get(t);if(e)return e;if(Re(t)){e=[],xt&&xt.set(t,e);for(var n=0,r=t.length;n=0)e=t;else{const s=Nn(t);for(var o in e=s===Object.prototype?{}:Object.create(s),xt&&xt.set(t,e),t)He(t,o)&&(e[o]=ko(t[o]))}return e}const{toString:Xd}={};function _o(t){return Xd.call(t).slice(8,-1)}const Eo=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Zd=typeof Eo=="symbol"?function(t){var e;return t!=null&&(e=t[Eo])&&e.apply(t)}:function(){return null},Qt={};function dt(t){var e,n,r,o;if(arguments.length===1){if(Re(t))return t.slice();if(this===Qt&&typeof t=="string")return[t];if(o=Zd(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 _s=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var lt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Si(t,e){lt=t,ji=e}var ji=()=>!0;const Qd=!new Error("").stack;function Ht(){if(Qd)try{throw Ht.arguments,new Error}catch(t){return t}return new Error}function Co(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` +`).length),n.split(` +`).slice(e).filter(ji).map(r=>` +`+r).join("")):""}var Di=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Es=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Di),ef={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 nn(t,e){this._e=Ht(),this.name=t,this.message=e}function Oi(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,o)=>o.indexOf(n)===r).join(` +`)}function br(t,e,n,r){this._e=Ht(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Oi(t,e)}function En(t,e){this._e=Ht(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Oi(t,e)}tn(nn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Co(this._e,2))}},toString:function(){return this.name+": "+this.message}}),tn(br).from(nn),tn(En).from(nn);var Cs=Es.reduce((t,e)=>(t[e]=e+"Error",t),{});const tf=nn;var U=Es.reduce((t,e)=>{var n=e+"Error";function r(o,s){this._e=Ht(),this.name=n,o?typeof o=="string"?(this.message=`${o}${s?` + `+s:""}`,this.inner=s||null):typeof o=="object"&&(this.message=`${o.name} ${o.message}`,this.inner=o):(this.message=ef[e]||n,this.inner=null)}return tn(r).from(tf),t[e]=r,t},{});U.Syntax=SyntaxError,U.Type=TypeError,U.Range=RangeError;var ta=Di.reduce((t,e)=>(t[e+"Error"]=U[e],t),{}),ar=Es.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=U[e]),t),{});function fe(){}function An(t){return t}function nf(t,e){return t==null||t===An?e:function(n){return e(t(n))}}function qt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function rf(t,e){return t===fe?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?qt(r,this.onsuccess):r),o&&(this.onerror=this.onerror?qt(o,this.onerror):o),s!==void 0?s:n}}function of(t,e){return t===fe?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?qt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?qt(r,this.onerror):r)}}function sf(t,e){return t===fe?e:function(n){var r=t.apply(this,arguments);Be(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?qt(o,this.onsuccess):o),s&&(this.onerror=this.onerror?qt(s,this.onerror):s),r===void 0?a===void 0?void 0:a:Be(r,a)}}function af(t,e){return t===fe?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Ss(t,e){return t===fe?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)}}ar.ModifyError=br,ar.DexieError=nn,ar.BulkError=En;var Fn={};const Ii=100,[So,xr,jo]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Nn(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Nn(e),t]})(),Pi=xr&&xr.then,ir=So&&So.constructor,js=!!jo;var Do=!1,lf=jo?()=>{jo.then(Yn)}:ye.setImmediate?setImmediate.bind(null,Yn):ye.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Yn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Yn,0)},Cn=function(t,e){wn.push([t,e]),kr&&(lf(),kr=!1)},Oo=!0,kr=!0,Bt=[],lr=[],Io=null,Po=An,rn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:oa,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{oa(t[0],t[1])}catch{}})}},B=rn,wn=[],$t=0,cr=[];function R(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=fe,this._lib=!1;var e=this._PSD=B;if(lt&&(this._stackHolder=Ht(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Fn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Ao(this,this._value))}this._state=null,this._value=null,++e.ref,Ai(this,t)}const No={get:function(){var t=B,e=_r;function n(r,o){var s=!t.global&&(t!==B||e!==_r);const a=s&&!gt();var i=new R((l,c)=>{Ds(this,new Ni(Er(r,t,s,a),Er(o,t,s,a),l,c,t))});return lt&&Ri(i,this),i}return n.prototype=Fn,n},set:function(t){mt(this,"then",t&&t.prototype===Fn?No:{get:function(){return t},set:No.set})}};function Ni(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 Ai(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&&qn();n&&typeof n.then=="function"?Ai(t,(o,s)=>{n instanceof R?n._then(o,s):n.then(o,s)}):(t._state=!0,t._value=n,Fi(t)),r&&Vn()}},Ao.bind(null,t))}catch(n){Ao(t,n)}}function Ao(t,e){if(lr.push(e),t._state===null){var n=t._lib&&qn();e=Po(e),t._state=!1,t._value=e,lt&&e!==null&&typeof e=="object"&&!e._promise&&function(r,o,s){try{r.apply(null,s)}catch(a){o&&o(a)}}(()=>{var r=ks(e,"stack");e._promise=t,mt(e,"stack",{get:()=>Do?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){Bt.some(o=>o._value===r._value)||Bt.push(r)}(t),Fi(t),n&&Vn()}}function Fi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--$t==0&&Os()},[]))}function Ds(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,Cn(cf,[n,t,e])}else t._listeners.push(e)}function cf(t,e,n){try{Io=e;var r,o=e._value;e._state?r=t(o):(lr.length&&(lr=[]),r=t(o),lr.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{Io=null,--$t==0&&Os(),--n.psd.ref||n.psd.finalize()}}function Mi(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=Co(a,0)):(o=a,s=""),e.push(o+(s?": "+s:"")+r)}return lt&&((r=Co(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Mi(t._prev,e,n)),e}function Ri(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Yn(){qn()&&Vn()}function qn(){var t=Oo;return Oo=!1,kr=!1,t}function Vn(){var t,e,n;do for(;wn.length>0;)for(t=wn,wn=[],n=t.length,e=0;e0);Oo=!0,kr=!0}function Os(){var t=Bt;Bt=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=cr.slice(0),n=e.length;n;)e[--n]()}function Xn(t){return new R(Fn,!1,t)}function we(t,e){var n=B;return function(){var r=qn(),o=B;try{return jt(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{jt(o,!1),r&&Vn()}}}un(R.prototype,{then:No,_then:function(t,e){Ds(this,new Ni(null,null,t,e,B))},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):Xn(r)):this.then(null,r=>r&&r.name===e?n(r):Xn(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Xn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Do=!0;var t=Mi(this,[],20).join(` +From previous: `);return this._state!==null&&(this._stack=t),t}finally{Do=!1}}},timeout:function(t,e){return t<1/0?new R((n,r)=>{var o=setTimeout(()=>r(new U.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&mt(R.prototype,Symbol.toStringTag,"Dexie.Promise"),rn.env=Ti(),un(R,{all:function(){var t=dt.apply(null,arguments).map(Zn);return new R(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((o,s)=>R.resolve(o).then(a=>{t[s]=a,--r||e(t)},n))})},resolve:t=>{if(t instanceof R)return t;if(t&&typeof t.then=="function")return new R((n,r)=>{t.then(n,r)});var e=new R(Fn,!0,t);return Ri(e,Io),e},reject:Xn,race:function(){var t=dt.apply(null,arguments).map(Zn);return new R((e,n)=>{t.map(r=>R.resolve(r).then(e,n))})},PSD:{get:()=>B,set:t=>B=t},totalEchoes:{get:()=>_r},newPSD:St,usePSD:hn,scheduler:{get:()=>Cn,set:t=>{Cn=t}},rejectionMapper:{get:()=>Po,set:t=>{Po=t}},follow:(t,e)=>new R((n,r)=>St((o,s)=>{var a=B;a.unhandleds=[],a.onunhandled=s,a.finalize=qt(function(){(function(i){function l(){i(),cr.splice(cr.indexOf(l),1)}cr.push(l),++$t,Cn(()=>{--$t==0&&Os()},[])})(()=>{this.unhandleds.length===0?o():s(this.unhandleds[0])})},a.finalize),t()},e,n,r))}),ir&&(ir.allSettled&&mt(R,"allSettled",function(){const t=dt.apply(null,arguments).map(Zn);return new R(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((o,s)=>R.resolve(o).then(a=>r[s]={status:"fulfilled",value:a},a=>r[s]={status:"rejected",reason:a}).then(()=>--n||e(r)))})}),ir.any&&typeof AggregateError<"u"&&mt(R,"any",function(){const t=dt.apply(null,arguments).map(Zn);return new R((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const o=new Array(r);t.forEach((s,a)=>R.resolve(s).then(i=>e(i),i=>{o[a]=i,--r||n(new AggregateError(o))}))})}));const Me={awaits:0,echoes:0,id:0};var uf=0,ur=[],ro=0,_r=0,df=0;function St(t,e,n,r){var o=B,s=Object.create(o);s.parent=o,s.ref=0,s.global=!1,s.id=++df;var a=rn.env;s.env=js?{Promise:R,PromiseProp:{value:R,configurable:!0,writable:!0},all:R.all,race:R.race,allSettled:R.allSettled,any:R.any,resolve:R.resolve,reject:R.reject,nthen:na(a.nthen,s),gthen:na(a.gthen,s)}:{},e&&Be(s,e),++o.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var i=hn(s,t,n,r);return s.ref===0&&s.finalize(),i}function pn(){return Me.id||(Me.id=++uf),++Me.awaits,Me.echoes+=Ii,Me.id}function gt(){return!!Me.awaits&&(--Me.awaits==0&&(Me.id=0),Me.echoes=Me.awaits*Ii,!0)}function Zn(t){return Me.echoes&&t&&t.constructor===ir?(pn(),t.then(e=>(gt(),e),e=>(gt(),Pe(e)))):t}function ff(t){++_r,Me.echoes&&--Me.echoes!=0||(Me.echoes=Me.id=0),ur.push(B),jt(t,!0)}function pf(){var t=ur[ur.length-1];ur.pop(),jt(t,!1)}function jt(t,e){var n=B;if((e?!Me.echoes||ro++&&t===B:!ro||--ro&&t===B)||Li(e?ff.bind(null,t):pf),t!==B&&(B=t,n===rn&&(rn.env=Ti()),js)){var r=rn.env.Promise,o=t.env;xr.then=o.nthen,r.prototype.then=o.gthen,(n.global||t.global)&&(Object.defineProperty(ye,"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 Ti(){var t=ye.Promise;return js?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(ye,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:xr.then,gthen:t.prototype.then}:{}}function hn(t,e,n,r,o){var s=B;try{return jt(t,!0),e(n,r,o)}finally{jt(s,!1)}}function Li(t){Pi.call(So,t)}function Er(t,e,n,r){return typeof t!="function"?t:function(){var o=B;n&&pn(),jt(e,!0);try{return t.apply(this,arguments)}finally{jt(o,!1),r&&Li(gt)}}}function na(t,e){return function(n,r){return t.call(this,Er(n,e),Er(r,e))}}(""+Pi).indexOf("[native code]")===-1&&(pn=gt=fe);const ra="unhandledrejection";function oa(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,o={promise:e,reason:t};if(ye.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ra,!0,!0),Be(r,o)):ye.CustomEvent&&Be(r=new CustomEvent(ra,{detail:o}),o),r&&ye.dispatchEvent&&(dispatchEvent(r),!ye.PromiseRejectionEvent&&ye.onunhandledrejection))try{ye.onunhandledrejection(r)}catch{}lt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Pe=R.reject;function Fo(t,e,n,r){if(t.idbdb&&(t._state.openComplete||B.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(()=>Fo(t,e,n,r))):Pe(s)}return o._promise(e,(s,a)=>St(()=>(B.trans=o,r(s,a,o)))).then(s=>o._completion.then(()=>s))}if(t._state.openComplete)return Pe(new U.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Pe(new U.DatabaseClosed);t.open().catch(fe)}return t._state.dbReadyPromise.then(()=>Fo(t,e,n,r))}const sa="3.2.4",Mt="￿",Mo=-1/0,ct="Invalid key provided. Keys must be of type string, number, Date or Array.",Wi="String expected.",Sn=[],Jr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),hf=Jr,mf=Jr,Bi=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Gr="__dbnames",oo="readonly",so="readwrite";function Vt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const $i={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Qn(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=zn(e))[t],e)}class yf{_trans(e,n,r){const o=this._tx||B.trans,s=this.name;function a(l,c,u){if(!u.schema[s])throw new U.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const i=qn();try{return o&&o.db===this.db?o===B.trans?o._promise(e,a,r):St(()=>o._promise(e,a,r),{trans:o,transless:B.transless||B}):Fo(this.db,e,[this.name],a)}finally{i&&Vn()}}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(Re(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=De(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)&&c.keyPath.every(u=>n.indexOf(u)>=0))[0];if(r&&this.db._maxKey!==Mt)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&<&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:o}=this.schema,s=this.db._deps.indexedDB;function a(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[i,l]=n.reduce(([c,u],d)=>{const f=o[d],p=e[d];return[c||f,c||!f?Vt(u,f&&f.multi?y=>{const h=yt(y,d);return Re(h)&&h.some(v=>a(p,v))}:y=>a(p,yt(y,d))):u]},[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,Re(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(He(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){Be(this,e)})}add(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=Qn(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"add",keys:n!=null?[n]:null,values:[s]})).then(a=>a.numFailures?R.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{rt(e,o,a)}catch{}return a})}update(e,n){if(typeof e!="object"||Re(e))return this.where(":id").equals(e).modify(n);{const r=yt(e,this.schema.primKey.keyPath);if(r===void 0)return Pe(new U.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?De(n).forEach(o=>{rt(e,o,n[o])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:o}=this.schema.primKey;let s=e;return o&&r&&(s=Qn(o)(e)),this._trans("readwrite",a=>this.core.mutate({trans:a,type:"put",values:[s],keys:n!=null?[n]:null})).then(a=>a.numFailures?R.reject(a.failures[0]):a.lastResult).then(a=>{if(o)try{rt(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?R.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:$i})).then(e=>e.numFailures?R.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 U.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&i?e.map(Qn(l)):e;return this.core.mutate({trans:a,type:"add",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:f,lastResult:p,failures:y})=>{if(d===0)return s?f:p;throw new En(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,y)})})}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 U.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let u=l&&i?e.map(Qn(l)):e;return this.core.mutate({trans:a,type:"put",keys:o,values:u,wantResults:s}).then(({numFailures:d,results:f,lastResult:p,failures:y})=>{if(d===0)return s?f:p;throw new En(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,y)})})}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 En(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function jn(t){var e={},n=function(a,i){if(i){for(var l=arguments.length,c=new Array(l-1);--l;)c[l-1]=arguments[l];return e[a].subscribe.apply(null,c),t}if(typeof a=="string")return e[a]};n.addEventType=s;for(var r=1,o=arguments.length;rVt(r(),e()):e,t.justLimit=n&&!r}function dr(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new U.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function aa(t,e,n){const r=dr(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 er(t,e,n,r){const o=t.replayFilter?Vt(t.filter,t.replayFilter()):t.filter;if(t.or){const s={},a=(i,l,c)=>{if(!o||o(l,c,f=>l.stop(f),f=>l.fail(f))){var u=l.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),He(s,d)||(s[d]=!0,e(i,l,c))}};return Promise.all([t.or._iterate(a,n),ia(aa(t,r,n),t.algorithm,a,!t.keysOnly&&t.valueMapper)])}return ia(aa(t,r,n),Vt(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function ia(t,e,n,r){var o=we(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=fe},i=>{s.fail(i),a=fe})||o(s.value,s,i=>a=i),a()})})}function We(t,e){try{const n=la(t),r=la(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:ter(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,o=r.table.core;if(Xt(r,!0))return o.count({trans:n,query:{index:dr(r,o.schema),range:r.range}}).then(a=>Math.min(a,r.limit));var s=0;return er(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(c,u){return u?a(c[r[u]],u-1):c[o]}var i=this._ctx.dir==="next"?1:-1;function l(c,u){var d=a(c,s),f=a(u,s);return df?i:0}return this.toArray(function(c){return c.sort(l)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Xt(r,!0)&&r.limit>0){const{valueMapper:o}=r,s=dr(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 er(r,s=>o.push(s),n,r.table.core).then(()=>o)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Xt(n)?io(n,()=>{var r=e;return(o,s)=>r===0||(r===1?(--r,!1):(s(()=>{o.advance(r),r=0}),!1))}):io(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),io(this._ctx,()=>{var n=e;return function(r,o,s){return--n<=0&&o(s),n>=0}},!0),this}until(e,n){return ao(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 ao(this._ctx,function(o){return e(o.value)}),n=this._ctx,r=e,n.isMatch=Vt(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.key,o)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,o){e(o.primaryKey,o)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(o,s){r.push(s.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Xt(n,!0)&&n.limit>0)return this._read(o=>{var s=dr(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 ao(this._ctx,function(o){var s=o.primaryKey.toString(),a=He(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=De(e),a=s.length;o=function(h){for(var v=!1,w=0;w{const{failures:w,numFailures:g}=v;f+=h-g;for(let x of De(w))d.push(w[x])};return this.clone().primaryKeys().then(h=>{const v=w=>{const g=Math.min(u,h.length-w);return i.getMany({trans:r,keys:h.slice(w,w+g),cache:"immutable"}).then(x=>{const E=[],S=[],C=l?[]:null,k=[];for(let j=0;j0&&i.mutate({trans:r,type:"add",values:E}).then(j=>{for(let A in j.failures)k.splice(parseInt(A),1);y(E.length,j)})).then(()=>(S.length>0||D&&typeof e=="object")&&i.mutate({trans:r,type:"put",keys:C,values:S,criteria:D,changeSpec:typeof e!="function"&&e}).then(j=>y(S.length,j))).then(()=>(k.length>0||D&&e===lo)&&i.mutate({trans:r,type:"delete",keys:k,criteria:D}).then(j=>y(k.length,j))).then(()=>h.length>w+g&&v(w+u))})};return v(0).then(()=>{if(d.length>0)throw new br("Error modifying one or more objects",d,f,p);return h.length})})})}delete(){var e=this._ctx,n=e.range;return Xt(e)&&(e.isPrimKey&&!mf||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:c,numFailures:u})=>{if(u)throw new br("Could not delete some values",Object.keys(i).map(d=>i[d]),a-u);return a-u}))}):this.modify(lo)}}const lo=(t,e)=>e.value=null;function gf(t,e){return te?-1:t===e?0:1}function qe(t,e,n){var r=t instanceof Ui?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Zt(t){return new t.Collection(t,()=>Ki("")).limit(0)}function bf(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],c)<0&&(i=l)}return atypeof h=="string"))return qe(t,Wi);function f(h){o=function(w){return w==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(h),s=function(w){return w==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(h),a=h==="next"?gf:wf;var v=n.map(function(w){return{lower:s(w),upper:o(w)}}).sort(function(w,g){return a(w.lower,g.lower)});i=v.map(function(w){return w.upper}),l=v.map(function(w){return w.lower}),c=h,u=h==="next"?"":r}f("next");var p=new t.Collection(t,()=>bt(i[0],l[d-1]+r));p._ondirectionchange=function(h){f(h)};var y=0;return p._addAlgorithm(function(h,v,w){var g=h.key;if(typeof g!="string")return!1;var x=s(g);if(e(x,l,y))return!0;for(var E=null,S=y;S0)&&(E=C)}return v(E!==null?function(){h.continue(E+u)}:w),!1}),p}function bt(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Ki(t){return{type:1,lower:t,upper:t}}class Ui{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)?Zt(this):new this.Collection(this,()=>bt(e,n,!r,!o))}catch{return qe(this,ct)}}equals(e){return e==null?qe(this,ct):new this.Collection(this,()=>Ki(e))}above(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(e,void 0,!0))}aboveOrEqual(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(e,void 0,!1))}below(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(void 0,e,!1,!0))}belowOrEqual(e){return e==null?qe(this,ct):new this.Collection(this,()=>bt(void 0,e))}startsWith(e){return typeof e!="string"?qe(this,Wi):this.between(e,e+Mt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):tr(this,(n,r)=>n.indexOf(r[0])===0,[e],Mt)}equalsIgnoreCase(e){return tr(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=dt.apply(Qt,arguments);return e.length===0?Zt(this):tr(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=dt.apply(Qt,arguments);return e.length===0?Zt(this):tr(this,(n,r)=>r.some(o=>n.indexOf(o)===0),e,Mt)}anyOf(){const e=dt.apply(Qt,arguments);let n=this._cmp;try{e.sort(n)}catch{return qe(this,ct)}if(e.length===0)return Zt(this);const r=new this.Collection(this,()=>bt(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([[Mo,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=dt.apply(Qt,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return qe(this,ct)}const n=e.reduce((r,o)=>r?r.concat([[r[r.length-1][1],o]]):[[Mo,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 Zt(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&o(g[0],g[1])<=0))return qe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",U.InvalidArgument);const l=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=o;function f(g,x){return d(g[0],x[0])}try{u=e.reduce(function(g,x){let E=0,S=g.length;for(;E0){C[0]=a(C[0],x[0]),C[1]=i(C[1],x[1]);break}}return E===S&&g.push(x),g},[]),u.sort(f)}catch{return qe(this,ct)}let p=0;const y=c?g=>o(g,u[p][1])>0:g=>o(g,u[p][1])>=0,h=l?g=>s(g,u[p][0])>0:g=>s(g,u[p][0])>=0;let v=y;const w=new this.Collection(this,()=>bt(u[0][0],u[u.length-1][1],!l,!c));return w._ondirectionchange=g=>{g==="next"?(v=y,d=o):(v=h,d=s),u.sort(f)},w._addAlgorithm((g,x,E)=>{for(var S=g.key;v(S);)if(++p,p===u.length)return x(E),!1;return!!function(C){return!y(C)&&!h(C)}(S)||(this._cmp(S,u[p][1])===0||this._cmp(S,u[p][0])===0||x(()=>{d===o?g.continue(u[p][0]):g.continue(u[p][1])}),!1)}),w}startsWithAnyOf(){const e=dt.apply(Qt,arguments);return e.every(n=>typeof n=="string")?e.length===0?Zt(this):this.inAnyRange(e.map(n=>[n,n+Mt])):qe(this,"startsWithAnyOf() only works with strings")}}function st(t){return we(function(e){return Mn(e),t(e.target.error),!1})}function Mn(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Rn="storagemutated",kt="x-storagemutated-1",Dt=jn(null,Rn);class xf{_lock(){return gn(!B.global),++this._reculock,this._reculock!==1||B.global||(B.lockOwnerFor=this),this}_unlock(){if(gn(!B.global),--this._reculock==0)for(B.global||(B.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{hn(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&B.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(gn(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new U.DatabaseClosed(r);case"MissingAPIError":throw new U.MissingAPI(r.message,r);default:throw new U.OpenFailed(r)}if(!this.active)throw new U.TransactionInactive;return gn(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=we(o=>{Mn(o),this._reject(e.error)}),e.onabort=we(o=>{Mn(o),this.active&&this._reject(new U.Abort(e.error)),this.active=!1,this.on("abort").fire(o)}),e.oncomplete=we(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Dt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return Pe(new U.ReadOnly("Transaction is readonly"));if(!this.active)return Pe(new U.TransactionInactive);if(this._locked())return new R((s,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(s,a)},B])});if(r)return St(()=>{var s=new R((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 R((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=R.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 R((a,i)=>{r.then(l=>n._waitingQueue.push(we(a.bind(null,l))),l=>n._waitingQueue.push(we(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 U.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(He(n,e))return n[e];const r=this.schema[e];if(!r)throw new U.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 Ro(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?"++":"")+zi(e)}}function zi(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function qi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:ki(n,r=>[r.name,r])}}let Tn=t=>{try{return t.only([[]]),Tn=()=>[[]],[[]]}catch{return Tn=()=>Mt,Mt}};function To(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>yt(r,e)}(t):e=>yt(e,t)}function ua(t){return[].slice.call(t)}let kf=0;function Dn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function _f(t,e,n){function r(l){if(l.type===3)return null;if(l.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:f}=l;return c===void 0?u===void 0?null:e.upperBound(u,!!f):u===void 0?e.lowerBound(c,!!d):e.bound(c,u,!!d,!!f)}const{schema:o,hasGetAll:s}=function(l,c){const u=ua(l.objectStoreNames);return{schema:{name:l.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:f,autoIncrement:p}=d,y=Re(f),h=f==null,v={},w={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:y,keyPath:f,autoIncrement:p,unique:!0,extractKey:To(f)},indexes:ua(d.indexNames).map(g=>d.index(g)).map(g=>{const{name:x,unique:E,multiEntry:S,keyPath:C}=g,k={name:x,compound:Re(C),keyPath:C,unique:E,multiEntry:S,extractKey:To(C)};return v[Dn(C)]=k,k}),getIndexByKeyPath:g=>v[Dn(g)]};return v[":id"]=w.primaryKey,f!=null&&(v[Dn(f)]=w.primaryKey),w})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),a=o.tables.map(l=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:f,keys:p,values:y,range:h}){return new Promise((v,w)=>{v=we(v);const g=d.objectStore(u),x=g.keyPath==null,E=f==="put"||f==="add";if(!E&&f!=="delete"&&f!=="deleteRange")throw new Error("Invalid operation type: "+f);const{length:S}=p||y||{length:1};if(p&&y&&p.length!==y.length)throw new Error("Given keys array must have same length as given values array.");if(S===0)return v({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const k=[],D=[];let j=0;const A=q=>{++j,Mn(q)};if(f==="deleteRange"){if(h.type===4)return v({numFailures:j,failures:D,results:[],lastResult:void 0});h.type===3?k.push(C=g.clear()):k.push(C=g.delete(r(h)))}else{const[q,$]=E?x?[y,p]:[y,null]:[p,null];if(E)for(let K=0;K{const $=q.target.result;k.forEach((K,le)=>K.error!=null&&(D[le]=K.error)),v({numFailures:j,failures:D,results:f==="delete"?p:k.map(K=>K.result),lastResult:$})};C.onerror=q=>{A(q),F(q)},C.onsuccess=F})},getMany:({trans:d,keys:f})=>new Promise((p,y)=>{p=we(p);const h=d.objectStore(u),v=f.length,w=new Array(v);let g,x=0,E=0;const S=k=>{const D=k.target;w[D._pos]=D.result,++E===x&&p(w)},C=st(y);for(let k=0;knew Promise((p,y)=>{p=we(p);const h=d.objectStore(u).get(f);h.onsuccess=v=>p(v.target.result),h.onerror=st(y)}),query:function(d){return f=>new Promise((p,y)=>{p=we(p);const{trans:h,values:v,limit:w,query:g}=f,x=w===1/0?void 0:w,{index:E,range:S}=g,C=h.objectStore(u),k=E.isPrimaryKey?C:C.index(E.name),D=r(S);if(w===0)return p({result:[]});if(d){const j=v?k.getAll(D,x):k.getAllKeys(D,x);j.onsuccess=A=>p({result:A.target.result}),j.onerror=st(y)}else{let j=0;const A=v||!("openKeyCursor"in k)?k.openCursor(D):k.openKeyCursor(D),F=[];A.onsuccess=q=>{const $=A.result;return $?(F.push(v?$.value:$.primaryKey),++j===w?p({result:F}):void $.continue()):p({result:F})},A.onerror=st(y)}})}(s),openCursor:function({trans:d,values:f,query:p,reverse:y,unique:h}){return new Promise((v,w)=>{v=we(v);const{index:g,range:x}=p,E=d.objectStore(u),S=g.isPrimaryKey?E:E.index(g.name),C=y?h?"prevunique":"prev":h?"nextunique":"next",k=f||!("openKeyCursor"in S)?S.openCursor(r(x),C):S.openKeyCursor(r(x),C);k.onerror=st(w),k.onsuccess=we(D=>{const j=k.result;if(!j)return void v(null);j.___id=++kf,j.done=!1;const A=j.continue.bind(j);let F=j.continuePrimaryKey;F&&(F=F.bind(j));const q=j.advance.bind(j),$=()=>{throw new Error("Cursor not stopped")};j.trans=d,j.stop=j.continue=j.continuePrimaryKey=j.advance=()=>{throw new Error("Cursor not started")},j.fail=we(w),j.next=function(){let K=1;return this.start(()=>K--?this.continue():this.stop()).then(()=>this)},j.start=K=>{const le=new Promise((I,Z)=>{I=we(I),k.onerror=st(Z),j.fail=Z,j.stop=oe=>{j.stop=j.continue=j.continuePrimaryKey=j.advance=$,I(oe)}}),z=()=>{if(k.result)try{K()}catch(I){j.fail(I)}else j.done=!0,j.start=()=>{throw new Error("Cursor behind last entry")},j.stop()};return k.onsuccess=we(I=>{k.onsuccess=z,z()}),j.continue=A,j.continuePrimaryKey=F,j.advance=q,z(),le},v(j)},w)})},count({query:d,trans:f}){const{index:p,range:y}=d;return new Promise((h,v)=>{const w=f.objectStore(u),g=p.isPrimaryKey?w:w.index(p.name),x=r(y),E=x?g.count(x):g.count();E.onsuccess=we(S=>h(S.target.result)),E.onerror=st(v)})}}}(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:Tn(e),schema:o}}function Lo({_novip:t},e){const n=e.db,r=function(o,s,{IDBKeyRange:a,indexedDB:i},l){return{dbcore:function(u,d){return d.reduce((f,{create:p})=>({...f,...p(f)}),u)}(_f(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=ks(a,o);(!i||"value"in i&&i.value===void 0)&&(a===t.Transaction.prototype||a instanceof t.Transaction?mt(a,o,{get(){return this.table(o)},set(l){wi(this,o,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):a[o]=new t.Table(o,s))})})}function Wo({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Ef(t,e){return t._cfg.version-e._cfg.version}function Cf(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=B.transless||B;St(()=>{B.trans=s,B.transless=i,e===0?(De(o).forEach(l=>{co(n,l,o[l].primKey,o[l].indexes)}),Lo(t,n),R.follow(()=>t.on.populate.fire(s)).catch(a)):function({_novip:l},c,u,d){const f=[],p=l._versions;let y=l._dbSchema=$o(l,l.idbdb,d),h=!1;const v=p.filter(g=>g._cfg.version>=c);function w(){return f.length?R.resolve(f.shift()(u.idbtrans)).then(w):R.resolve()}return v.forEach(g=>{f.push(()=>{const x=y,E=g._cfg.dbschema;Ko(l,x,d),Ko(l,E,d),y=l._dbSchema=E;const S=Vi(x,E);S.add.forEach(k=>{co(d,k[0],k[1].primKey,k[1].indexes)}),S.change.forEach(k=>{if(k.recreate)throw new U.Upgrade("Not yet support for changing primary key");{const D=d.objectStore(k.name);k.add.forEach(j=>Bo(D,j)),k.change.forEach(j=>{D.deleteIndex(j.name),Bo(D,j)}),k.del.forEach(j=>D.deleteIndex(j))}});const C=g._cfg.contentUpgrade;if(C&&g._cfg.version>c){Lo(l,d),u._memoizedTables={},h=!0;let k=_i(E);S.del.forEach(F=>{k[F]=x[F]}),Wo(l,[l.Transaction.prototype]),Cr(l,[l.Transaction.prototype],De(k),k),u.schema=k;const D=_s(C);let j;D&&pn();const A=R.follow(()=>{if(j=C(u),j&&D){var F=gt.bind(null,null);j.then(F,F)}});return j&&typeof j.then=="function"?R.resolve(j):A.then(()=>j)}}),f.push(x=>{(!h||!hf)&&function(E,S){[].slice.call(S.db.objectStoreNames).forEach(C=>E[C]==null&&S.db.deleteObjectStore(C))}(g._cfg.dbschema,x),Wo(l,[l.Transaction.prototype]),Cr(l,[l.Transaction.prototype],l._storeNames,l._dbSchema),u.schema=l._dbSchema})}),w().then(()=>{var g,x;x=d,De(g=y).forEach(E=>{x.db.objectStoreNames.contains(E)||co(x,E,g[E].primKey,g[E].indexes)})})}(t,e,s,n).catch(a)})}function Vi(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&&!Jr)a.recreate=!0,n.change.push(a);else{const i=o.idxByName,l=s.idxByName;let c;for(c in i)l[c]||a.del.push(c);for(c in l){const u=i[c],d=l[c];u?u.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 co(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=>Bo(o,s)),o}function Bo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function $o(t,e,n){const r={};return wr(e.objectStoreNames,0).forEach(o=>{const s=n.objectStore(o);let a=s.keyPath;const i=Ro(zi(a),a||"",!1,!1,!!s.autoIncrement,a&&typeof a!="string",!0),l=[];for(let u=0;u{if(e[r]!==null){var o=e[r].split(",").map((a,i)=>{const l=(a=a.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(l)?l.match(/^\[(.*)\]$/)[1].split("+"):l;return Ro(l,c||null,/\&/.test(a),/\*/.test(a),/\+\+/.test(a),Re(c),i===0)}),s=o.shift();if(s.multi)throw new U.Schema("Primary key cannot be multi-valued");o.forEach(a=>{if(a.auto)throw new U.Schema("Only primary key can be marked as autoIncrement (++)");if(!a.keyPath)throw new U.Schema("Index must have a name and cannot be an empty string")}),n[r]=qi(r,s,o)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?Be(this._cfg.storesSource,e):e;const r=n._versions,o={};let s={};return r.forEach(a=>{Be(o,a._cfg.storesSource),s=a._cfg.dbschema={},a._parseStoresSpec(o,s)}),n._dbSchema=s,Wo(n,[n._allTables,n,n.Transaction.prototype]),Cr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],De(s),s),n._storeNames=De(s),this}upgrade(e){return this._cfg.contentUpgrade=Ss(this._cfg.contentUpgrade||fe,e),this}}function Is(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Kt(Gr,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ps(t){return t&&typeof t.databases=="function"}function Uo(t){return St(function(){return B.letThrough=!0,t()})}function jf(){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?Pe(e.dbOpenError):t);lt&&(e.openCanceller._stackHolder=Ht()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function o(){if(e.openCanceller!==r)throw new U.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,a=null,i=!1;return R.race([r,(typeof navigator>"u"?R.resolve():jf()).then(()=>new R((l,c)=>{if(o(),!n)throw new U.MissingAPI;const u=t.name,d=e.autoSchema?n.open(u):n.open(u,Math.round(10*t.verno));if(!d)throw new U.MissingAPI;d.onerror=st(c),d.onblocked=we(t._fireOnBlocked),d.onupgradeneeded=we(f=>{if(a=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Mn,a.abort(),d.result.close();const y=n.deleteDatabase(u);y.onsuccess=y.onerror=we(()=>{c(new U.NoSuchDatabase(`Database ${u} doesnt exist`))})}else{a.onerror=st(c);var p=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;i=p<1,t._novip.idbdb=d.result,Cf(t,p/10,a,c)}},c),d.onsuccess=we(()=>{a=null;const f=t._novip.idbdb=d.result,p=wr(f.objectStoreNames);if(p.length>0)try{const h=f.transaction((y=p).length===1?y[0]:y,"readonly");e.autoSchema?function({_novip:v},w,g){v.verno=w.version/10;const x=v._dbSchema=$o(0,w,g);v._storeNames=wr(w.objectStoreNames,0),Cr(v,[v._allTables],De(x),x)}(t,f,h):(Ko(t,t._dbSchema,h),function(v,w){const g=Vi($o(0,v.idbdb,w),v._dbSchema);return!(g.add.length||g.change.some(x=>x.add.length||x.change.length))}(t,h)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Lo(t,h)}catch{}var y;Sn.push(t),f.onversionchange=we(h=>{e.vcFired=!0,t.on("versionchange").fire(h)}),f.onclose=we(h=>{t.on("close").fire(h)}),i&&function({indexedDB:h,IDBKeyRange:v},w){!Ps(h)&&w!==Gr&&Is(h,v).put({name:w}).catch(fe)}(t._deps,u),l()},c)}))]).then(()=>(o(),e.onReadyBeingFired=[],R.resolve(Uo(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(Ss,fe);return e.onReadyBeingFired=[],R.resolve(Uo(()=>c(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(),Pe(l)}).finally(()=>{e.openComplete=!0,s()})}function zo(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):Re(l)?Promise.all(l).then(n,r):n(l)}}return o(e)()}function Of(t,e,n){var r=arguments.length;if(r<2)throw new U.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[t,Ei(o),n]}function Hi(t,e,n,r,o){return R.resolve().then(()=>{const s=B.transless||B,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(()=>Hi(t,e,n,null,o))):Pe(d)}const l=_s(o);let c;l&&pn();const u=R.follow(()=>{if(c=o.call(a,a),c)if(l){var d=gt.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=zo(c))},i);return(c&&typeof c.then=="function"?R.resolve(c).then(d=>a.active?d:Pe(new U.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&a._resolve(),a._completion.then(()=>d))).catch(d=>(a._reject(d),Pe(d)))})}function nr(t,e,n){const r=Re(t)?t.slice():[t];for(let o=0;o0,w={...f,isVirtual:v,keyTail:d,keyLength:h,extractKey:To(u),unique:!v&&f.unique};return y.push(w),w.isPrimaryKey||s.push(w),h>1&&a(h===2?u[0]:u.slice(0,h-1),d+1,f),y.sort((g,x)=>g.keyTail-x.keyTail),w}const i=a(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[i];for(const u of r.indexes)a(u.keyPath,0,u);function l(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(f=u.query.range,p=d.keyTail,{type:f.type===1?2:f.type,lower:nr(f.lower,f.lowerOpen?t.MAX_KEY:t.MIN_KEY,p),lowerOpen:!0,upper:nr(f.upper,f.upperOpen?t.MIN_KEY:t.MAX_KEY,p),upperOpen:!0})}}:u;var f,p}return{...n,schema:{...r,primaryKey:i,indexes:s,getIndexByKeyPath:function(u){const d=o[Dn(u)];return d&&d[0]}},count:u=>n.count(l(u)),query:u=>n.query(l(u)),openCursor(u){const{keyTail:d,isVirtual:f,keyLength:p}=u.query.index;return f?n.openCursor(l(u)).then(y=>y&&function(h){return Object.create(h,{continue:{value:function(w){w!=null?h.continue(nr(w,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?h.continue(h.key.slice(0,p).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(w,g){h.continuePrimaryKey(nr(w,t.MAX_KEY,d),g)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const w=h.key;return p===1?w[0]:w.slice(0,p)}},value:{get:()=>h.value}})}(y)):n.openCursor(u)}}}}}};function Ns(t,e,n,r){return n=n||{},r=r||"",De(t).forEach(o=>{if(He(e,o)){var s=t[o],a=e[o];if(typeof s=="object"&&typeof a=="object"&&s&&a){const i=_o(s);i!==_o(a)?n[r+o]=e[o]:i==="Object"?Ns(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}),De(e).forEach(o=>{He(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=B.trans,{deleting:i,creating:l,updating:c}=a.table(e).hook;switch(s.type){case"add":if(l.fire===fe)break;return a._promise("readwrite",()=>u(s),!0);case"put":if(l.fire===fe&&c.fire===fe)break;return a._promise("readwrite",()=>u(s),!0);case"delete":if(i.fire===fe)break;return a._promise("readwrite",()=>u(s),!0);case"deleteRange":if(i.fire===fe)break;return a._promise("readwrite",()=>function(f){return d(f.trans,f.range,1e4)}(s),!0)}return n.mutate(s);function u(f){const p=B.trans,y=f.keys||function(h,v){return v.type==="delete"?v.keys:v.keys||v.values.map(h.extractKey)}(r,f);if(!y)throw new Error("Keys missing");return(f=f.type==="add"||f.type==="put"?{...f,keys:y}:{...f}).type!=="delete"&&(f.values=[...f.values]),f.keys&&(f.keys=[...f.keys]),function(h,v,w){return v.type==="add"?Promise.resolve([]):h.getMany({trans:v.trans,keys:w,cache:"immutable"})}(n,f,y).then(h=>{const v=y.map((w,g)=>{const x=h[g],E={onerror:null,onsuccess:null};if(f.type==="delete")i.fire.call(E,w,x,p);else if(f.type==="add"||x===void 0){const S=l.fire.call(E,w,f.values[g],p);w==null&&S!=null&&(w=S,f.keys[g]=w,r.outbound||rt(f.values[g],r.keyPath,w))}else{const S=Ns(x,f.values[g]),C=c.fire.call(E,S,w,x,p);if(C){const k=f.values[g];Object.keys(C).forEach(D=>{He(k,D)?k[D]=C[D]:rt(k,D,C[D])})}}return E});return n.mutate(f).then(({failures:w,results:g,numFailures:x,lastResult:E})=>{for(let S=0;S(v.forEach(g=>g.onerror&&g.onerror(w)),Promise.reject(w)))})}function d(f,p,y){return n.query({trans:f,values:!1,query:{index:r,range:p},limit:y}).then(({result:h})=>u({type:"delete",keys:h,trans:f}).then(v=>v.numFailures>0?Promise.reject(v.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?R.resolve(o):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?zn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function As(t){return!("from"in t)}const ut=function(t,e){if(!this){const n=new ut;return t&&"d"in t&&Be(n,t),n}Be(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Ln(t,e,n){const r=We(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(As(t))return Be(t,{from:e,to:n,d:1});const o=t.l,s=t.r;if(We(n,t.from)<0)return o?Ln(o,e,n):t.l={from:e,to:n,d:1,l:null,r:null},da(t);if(We(e,t.to)>0)return s?Ln(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},da(t);We(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),We(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const a=!t.r;o&&!t.l&&Sr(t,o),s&&a&&Sr(t,s)}function Sr(t,e){As(e)||function n(r,{from:o,to:s,l:a,r:i}){Ln(r,o,s),a&&n(r,a),i&&n(r,i)}(t,e)}function Af(t,e){const n=qo(e);let r=n.next();if(r.done)return!1;let o=r.value;const s=qo(t);let a=s.next(o.from),i=a.value;for(;!r.done&&!a.done;){if(We(i.from,o.to)<=0&&We(i.to,o.from)>=0)return!0;We(o.from,i.from)<0?o=(r=n.next(i.from)).value:i=(a=s.next(o.from)).value}return!1}function qo(t){let e=As(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&We(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||We(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function da(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=fa(a)}t.d=fa(t)}function fa({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}un(ut.prototype,{add(t){return Sr(this,t),this},addKey(t){return Ln(this,t,t),this},addKeys(t){return t.forEach(e=>Ln(this,e,e)),this},[Eo](){return qo(this)}});const Ff={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new ut(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,c={...o,mutate:f=>{const p=f.trans,y=p.mutatedParts||(p.mutatedParts={}),h=C=>{const k=`idb://${e}/${r}/${C}`;return y[k]||(y[k]=new ut)},v=h(""),w=h(":dels"),{type:g}=f;let[x,E]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[];const S=f.trans._cache;return o.mutate(f).then(C=>{if(Re(x)){g!=="delete"&&(x=C.results),v.addKeys(x);const k=Ji(x,S);k||g==="add"||w.addKeys(x),(k||E)&&function(D,j,A,F){function q($){const K=D($.name||"");function le(I){return I!=null?$.extractKey(I):null}const z=I=>$.multiEntry&&Re(I)?I.forEach(Z=>K.addKey(Z)):K.addKey(I);(A||F).forEach((I,Z)=>{const oe=A&&le(A[Z]),he=F&&le(F[Z]);We(oe,he)!==0&&(oe!=null&&z(oe),he!=null&&z(he))})}j.indexes.forEach(q)}(h,s,k,E)}else if(x){const k={from:x.lower,to:x.upper};w.add(k),v.add(k)}else v.add(n),w.add(n),s.indexes.forEach(k=>h(k.name).add(n));return C})}},u=({query:{index:f,range:p}})=>{var y,h;return[f,new ut((y=p.lower)!==null&&y!==void 0?y:t.MIN_KEY,(h=p.upper)!==null&&h!==void 0?h:t.MAX_KEY)]},d={get:f=>[a,new ut(f.key)],getMany:f=>[a,new ut().addKeys(f.keys)],count:u,query:u,openCursor:u};return De(d).forEach(f=>{c[f]=function(p){const{subscr:y}=B;if(y){const h=E=>{const S=`idb://${e}/${r}/${E}`;return y[S]||(y[S]=new ut)},v=h(""),w=h(":dels"),[g,x]=d[f](p);if(h(g.name||"").add(x),!g.isPrimaryKey){if(f!=="count"){const E=f==="query"&&l&&p.values&&o.query({...p,values:!1});return o[f].apply(this,arguments).then(S=>{if(f==="query"){if(l&&p.values)return E.then(({result:k})=>(v.addKeys(k),S));const C=p.values?S.result.map(i):S.result;p.values?v.addKeys(C):w.addKeys(C)}else if(f==="openCursor"){const C=S,k=p.values;return C&&Object.create(C,{key:{get:()=>(w.addKey(C.primaryKey),C.key)},primaryKey:{get(){const D=C.primaryKey;return w.addKey(D),D}},value:{get:()=>(k&&v.addKey(C.primaryKey),C.value)}})}return S})}w.add(n)}}return o[f].apply(this,arguments)}}),c}}}};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:fe,dbReadyPromise:null,cancelOpen:fe,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var a;s.dbReadyPromise=new R(i=>{s.dbReadyResolve=i}),s.openCanceller=new R((i,l)=>{s.cancelOpen=l}),this._state=s,this.name=e,this.on=jn(this,"populate","blocked","versionchange","close",{ready:[Ss,fe]}),this.on.ready.subscribe=bi(this.on.ready.subscribe,i=>(l,c)=>{Kt.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||R.resolve().then(l),c&&i(l);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(l),c&&i(l);else{i(l);const d=this;c||i(function f(){d.on.ready.unsubscribe(l),d.on.ready.unsubscribe(f)})}})}),this.Collection=(a=this,vn(vf.prototype,function(i,l){this.db=a;let c=$i,u=null;if(l)try{c=l()}catch(y){u=y}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:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:p!==An?p:null}})),this.Table=function(i){return vn(yf.prototype,function(l,c,u){this.db=i,this._tx=u,this.name=l,this.schema=c,this.hook=i._allTables[l]?i._allTables[l].hook:jn(null,{creating:[rf,fe],reading:[nf,An],updating:[sf,fe],deleting:[of,fe]})})}(this),this.Transaction=function(i){return vn(xf.prototype,function(l,c,u,d,f){this.db=i,this.mode=l,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=jn(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 R((p,y)=>{this._resolve=p,this._reject=y}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var y=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):y&&this.idbtrans&&this.idbtrans.abort(),Pe(p)})})}(this),this.Version=function(i){return vn(Sf.prototype,function(l){this.db=i,this._cfg={version:l,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(i){return vn(Ui.prototype,function(l,c,u){this.db=i,this._ctx={table:l,index:c===":id"?null:c,or:u};const d=i._deps.indexedDB;if(!d)throw new U.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,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=i=>{this.on("blocked").fire(i),Sn.filter(l=>l.name===this.name&&l!==this&&!l._state.vcFired).map(l=>l.on("versionchange").fire(i))},this.use(If),this.use(Pf),this.use(Ff),this.use(Nf),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(i=>i(this))}version(e){if(isNaN(e)||e<.1)throw new U.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new U.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(Ef),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||B.letThrough||this._vip)?e():new R((n,r)=>{if(this._state.openComplete)return r(new U.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new U.DatabaseClosed);this.open().catch(fe)}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=Sn.indexOf(this);if(n>=0&&Sn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new R(r=>{e.dbReadyResolve=r}),e.openCanceller=new R((r,o)=>{e.cancelOpen=o})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new U.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new R((r,o)=>{const s=()=>{this.close();var a=this._deps.indexedDB.deleteDatabase(this.name);a.onsuccess=we(()=>{(function({indexedDB:i,IDBKeyRange:l},c){!Ps(i)&&c!==Gr&&Is(i,l).delete(c).catch(fe)})(this._deps,this.name),r()}),a.onerror=st(o),a.onblocked=this._fireOnBlocked};if(e)throw new U.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 De(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Of.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let o=B.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(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===oo)a=oo;else{if(e!="rw"&&e!=so)throw new U.InvalidArgument("Invalid transaction mode: "+e);a=so}if(o){if(o.mode===oo&&a===so){if(!s)throw new U.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&i.forEach(c=>{if(o&&o.storeNames.indexOf(c)===-1){if(!s)throw new U.SubTransaction("Table "+c+" not included in parent transaction.");o=null}}),s&&o&&!o.active&&(o=null)}}catch(c){return o?o._promise(null,(u,d)=>{d(c)}):Pe(c)}const l=Hi.bind(null,this,a,i,o,r);return o?o._promise(a,l,"lock"):B.trans?hn(B.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!He(this._allTables,e))throw new U.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Mf=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Rf{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Mf](){return this}}function Gi(t,e){return De(e).forEach(n=>{Sr(t[n]||(t[n]=new ut),e[n])}),t}function Tf(t){let e,n=!1;const r=new Rf(o=>{const s=_s(t);let a=!1,i={},l={};const c={get closed(){return a},unsubscribe:()=>{a=!0,Dt.storagemutated.unsubscribe(p)}};o.start&&o.start(c);let u=!1,d=!1;function f(){return De(l).some(h=>i[h]&&Af(i[h],l[h]))}const p=h=>{Gi(i,h),f()&&y()},y=()=>{if(u||a)return;i={};const h={},v=function(w){s&&pn();const g=()=>St(t,{subscr:w,trans:null}),x=B.trans?hn(B.transless,g):g();return s&&x.then(gt,gt),x}(h);d||(Dt(Rn,p),d=!0),u=!0,Promise.resolve(v).then(w=>{n=!0,e=w,u=!1,a||(f()?y():(i={},l=h,o.next&&o.next(w)))},w=>{u=!1,n=!1,o.error&&o.error(w),c.unsubscribe()})};return y(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let Vo;try{Vo={indexedDB:ye.indexedDB||ye.mozIndexedDB||ye.webkitIndexedDB||ye.msIndexedDB,IDBKeyRange:ye.IDBKeyRange||ye.webkitIDBKeyRange}}catch{Vo={indexedDB:null,IDBKeyRange:null}}const At=Kt;function fr(t){let e=pt;try{pt=!0,Dt.storagemutated.fire(t)}finally{pt=e}}un(At,{...ar,delete:t=>new At(t,{addons:[]}).delete(),exists:t=>new At(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return Ps(e)?Promise.resolve(e.databases()).then(r=>r.map(o=>o.name).filter(o=>o!==Gr)):Is(e,n).toCollection().primaryKeys()}(At.dependencies).then(t)}catch{return Pe(new U.MissingAPI)}},defineClass:()=>function(t){Be(this,t)},ignoreTransaction:t=>B.trans?hn(B.transless,t):t(),vip:Uo,async:function(t){return function(){try{var e=zo(t.apply(this,arguments));return e&&typeof e.then=="function"?e:R.resolve(e)}catch(n){return Pe(n)}}},spawn:function(t,e,n){try{var r=zo(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:R.resolve(r)}catch(o){return Pe(o)}},currentTransaction:{get:()=>B.trans||null},waitFor:function(t,e){const n=R.resolve(typeof t=="function"?At.ignoreTransaction(t):t).timeout(e||6e4);return B.trans?B.trans.waitFor(n):n},Promise:R,debug:{get:()=>lt,set:t=>{Si(t,t==="dexie"?()=>!0:Bi)}},derive:tn,extend:Be,props:un,override:bi,Events:jn,on:Dt,liveQuery:Tf,extendObservabilitySet:Gi,getByKeyPath:yt,setByKeyPath:rt,delByKeyPath:function(t,e){typeof e=="string"?rt(t,e,void 0):"length"in e&&[].map.call(e,function(n){rt(t,n,void 0)})},shallowClone:_i,deepClone:zn,getObjectDiff:Ns,cmp:We,asap:xi,minKey:Mo,addons:[],connections:Sn,errnames:Cs,dependencies:Vo,semVer:sa,version:sa.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),At.maxKey=Tn(At.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Dt(Rn,t=>{if(!pt){let e;Jr?(e=document.createEvent("CustomEvent"),e.initCustomEvent(kt,!0,!0,t)):e=new CustomEvent(kt,{detail:t}),pt=!0,dispatchEvent(e),pt=!1}}),addEventListener(kt,({detail:t})=>{pt||fr(t)}));let pt=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(kt);typeof t.unref=="function"&&t.unref(),Dt(Rn,e=>{pt||t.postMessage(e)}),t.onmessage=e=>{e.data&&fr(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Dt(Rn,e=>{try{pt||(typeof localStorage<"u"&&localStorage.setItem(kt,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:kt,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===kt){const n=JSON.parse(e.newValue);n&&fr(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===kt&&fr(e.changedParts)})}R.rejectionMapper=function(t,e){if(!t||t instanceof nn||t instanceof TypeError||t instanceof SyntaxError||!t.name||!ta[t.name])return t;var n=new ta[t.name](e||t.message,t);return"stack"in t&&mt(n,"stack",{get:function(){return this.inner.stack}}),n},Si(lt,Bi);var pr=(t=>(t.MOVE_TO_ROOT_FOLDER="moveToRootFolder",t.DELETE="delete",t))(pr||{});const Lf="comfyui_workspace_db";class Wf extends Kt{constructor(){super(Lf);ke(this,"workflows");ke(this,"changelogs");ke(this,"media");ke(this,"folders");ke(this,"tags");ke(this,"userSettings");ke(this,"models");ke(this,"cache");ke(this,"workflowVersions");this.version(1).stores({workflows:"&id, name, parentFolderID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id"}).upgrade(n=>{}),this.version(2).stores({workflows:"&id, name, parentFolderID,cloudID",changelogs:"&id, workflowID",media:"&id, workflowID",folders:"&id, name, parentFolderID",tags:"&name",userSettings:"&id",models:"&id, fileName, fileHash",cache:"&id",workflowVersions:"&id, name, workflowID,cloudID"}).upgrade(n=>{})}}const H=new Wf,Bf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ho=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Bf[n[t]&63];return e};class Jt{constructor(e){ke(this,"tableName");this.tableName=e}async saveDiskDB(){const e=await H[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")}),Bd(this.tableName,JSON.stringify(n))}async add(e){return e.id||(e.id=Ho()),e.createTime||(e.createTime=Date.now()),await H[this.tableName].add(e),await this.saveDiskDB(),e}async put(e){return await H[this.tableName].put(e),await this.saveDiskDB(),e}async bulkPut(e){await H[this.tableName].bulkPut(e),this.saveDiskDB()}async update(e,n){return await H[this.tableName].update(e,n),await this.saveDiskDB(),await this.get(e)??null}async listAll(){return await H[this.tableName].toArray()}async batchQuery(e){return await H[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 Wd(this.tableName);let n;try{n=e!=null?JSON.parse(e):null}catch{}if(n==null){const r=await qd()??"{}";n=JSON.parse(r)[this.tableName]}return n??{}}async get(e){return await H[this.tableName].get(e)}async delete(e){await H[this.tableName].delete(e),await this.saveDiskDB()}async listByIndex(e,n){return await H[this.tableName].where(e).equals(n).toArray()}}const $f=150,Or=class Or extends Jt{constructor(){super("changelogs")}static async load(){return new Or}async listByWorkflowID(e){return await H.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:Pn(),json:e.json,workflowID:e.workflowID,createTime:Date.now()};return await H.changelogs.add(r),await this.saveDiskDB(),r}async deleteLogsExceedLimit(e,n=$f){const r=await H.changelogs.where("workflowID").equals(e).reverse().sortBy("createTime"),o=r.filter(a=>a.isAutoSave===!0),s=r.filter(a=>a.isAutoSave==null||a.isAutoSave==!1);if(o.length>n){const a=o.slice(n);await H.changelogs.bulkDelete(a.map(i=>i.id)),await this.saveDiskDB()}if(s.length>n){const a=s.slice(n);await H.changelogs.bulkDelete(a.map(i=>i.id)),await this.saveDiskDB()}}};ke(Or,"TABLE_NAME","changelogs");let Jo=Or;const ch="CWM_WORKFLOWS_SORT_TYPE";var _t=(t=>(t.RECENTLY_MODIFIED="newest",t.OLDEST_MODIFIED="oldest",t.AZ="name A-Z",t.ZA="name Z-A",t))(_t||{});const uh=[{title:"Import Workflows",type:"file"},{title:"Import Folder",type:"folder"}],Yi="comfyspace_tracking",jr="workspace_info",Kf=9999999;function ft(t){return"/"+t.split("/").filter(n=>n!=="").join("/")}function Uf(t){return t.split("/").filter(n=>n!=="").join("/")}async function Ft(t){const e=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${e}/${t}`)}var Et;(t=>{async function e({parentFolderID:l,name:c}){return Uf(`${l??""}/${c}`)}t.genFolderRelPath=e;async function n({parentFolderID:l,name:c}){const u=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${u}/${l??""}/${c}`)}t.genFolderAbsPath=n;async function r(l){const c=await n(l);await fetch("/workspace/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})}t.createFolder=r;async function o(l,c){const u=await Ft(l),d=await Ft(c),p=await(await fetch("/workspace/folder/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:u,newParentPath:d})})).json();p.error&&alert("Failed to move folder: "+p.error)}t.moveFolder=o;async function s(l){const c=await Ft(l);try{return await(await fetch("/workspace/folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})).text()}catch(u){console.error("Error deleting file:",u)}}t.deleteFolder=s;async function a(l){const c=await Ft(l);try{const d=await(await fetch("/workspace/file/count_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})})).json();return d.error&&console.error("Error counting files:",d.error),d.count}catch(u){console.error("Error renaming file:",u)}return null}t.genFilesCountInFolder=a;async function i(l,c){const u=await Ft(l);try{const f=await(await fetch("/workspace/folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:u,newName:c})})).json();f.error&&alert("Failed to rename folder: "+f.error)}catch(d){console.error("Error renaming file:",d)}}t.renameFolder=i})(Et||(Et={}));async function bn(t){console.warn("saveJsonFileMyWorkflows",t);const e=await Fs(t);if(e==null)return;const n=await Ms(t);await(O==null?void 0:O.updateMetaInfo(t.id,{filePath:n??void 0}));const r=t.json,o=JSON.parse(r);o.extra[jr]={id:t.id,name:t.name},delete o.extra[Yi],await vi(e,JSON.stringify(o))}async function uo(t){if(t.name==null)return;const e=await Fs(t);e!=null&&gi(e)}async function Fs(t){let e=zf(t.name)+".json",n=t.parentFolderID;for(;n!=null;){const r=await(Te==null?void 0:Te.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??void 0}return e??null}async function dh(t){let e="",n=t;for(;n!=null;){const r=await(Te==null?void 0:Te.get(n));if(r==null)break;e=`${r.name}/${e}`,n=r.parentFolderID??null}return e}async function Ms(t){const e=await Fs(t);let n=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return n?(n.endsWith("/")||(n=n+"/"),n+e):(console.error("myWorkflowsDir is not set"),null)}async function fh(t){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await Et.genFilesCountInFolder(t)??0;const n=await(O==null?void 0:O.listAll())??[],r=await(Te==null?void 0:Te.listAll())??[],o=[t];let s=0;for(;o.length>0;){const a=o.shift();if(a){for(const l of n)l.parentFolderID===a&&s++;const i=r.filter(l=>l.parentFolderID===a).map(l=>l.id);i.length&&o.push(...i)}}return s}function zf(t){return t=t.replace(/[\\/:*?"<>|]/g,"_"),t.trim()}function pa(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"),c=String(r.getSeconds()).padStart(2,"0"),u=`${s}-${o}-${a}`;return e?u+` ${i}:${l}`:n?u+`:${c}`:u}async function qf(t=!1){const e=await(O==null?void 0:O.listAll())??[];for(const n of e){const r=await Ms(n);n.filePath!=r&&(n.filePath!=null&&await gi(n.filePath,t),await bn(n))}}const Xi=(t,e=_t.RECENTLY_MODIFIED)=>{const n=[...t];switch(e){case _t.AZ:n.sort((r,o)=>r.name.localeCompare(o.name));break;case _t.ZA:n.sort((r,o)=>o.name.localeCompare(r.name));break;case _t.RECENTLY_MODIFIED:n.sort((r,o)=>o.updateTime-r.updateTime);break;case _t.OLDEST_MODIFIED:n.sort((r,o)=>r.updateTime-o.updateTime);break}return n};function ph(t,e){let n=JSON.parse(t);typeof structuredClone>"u"?n=JSON.parse(JSON.stringify(n)):n=structuredClone(n);let r=new LGraph;r.configure(n);const o=localStorage.getItem("litegrapheditor_clipboard"),s=document.createElement("canvas");let a=new LGraphCanvas(s,r);a.selectNodes(r._nodes),a.copyToClipboard(r._nodes);const i=ge.canvas.graph_mouse;e&&(e[0]-=15,e[1]-=15,ge.canvas.graph_mouse=e),ge.canvas.pasteFromClipboard(),ge.canvas.graph_mouse=i,o&&localStorage.setItem("litegrapheditor_clipboard",o),r=null,a=null}const Vf=async t=>{const e=await(P==null?void 0:P.getSetting("shortcuts").then(n=>n==null?void 0:n.save));return e?Hf(t,e):!1},Hf=(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 hh(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}`}function ha(){const e=window.location.hash.slice(1).split("/").find(n=>n.includes("workspaceId@"));return e?e.split("@")[1]:null}function Zi(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 Gf=t=>{const e=Zi(t);window.open(`${window.location.origin}/#${e}`)};async function Yf(){const t=await(O==null?void 0:O.listAll())??[];for(const e of t)try{const n=await Ms(e),r=JSON.parse(e.json);r.extra[jr]={id:e.id,name:e.name},delete r.extra[Yi],n&&await vi(n,JSON.stringify(r))}catch(n){console.error(n)}}const hr={last_node_id:9,last_link_id:9,nodes:[{id:7,type:"CLIPTextEncode",pos:[413,389],size:{0:425.27801513671875,1:180.6060791015625},flags:{},order:3,mode:0,inputs:[{name:"clip",type:"CLIP",link:5}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[6],slot_index:0}],properties:{},widgets_values:["text, watermark"]},{id:6,type:"CLIPTextEncode",pos:[415,186],size:{0:422.84503173828125,1:164.31304931640625},flags:{},order:2,mode:0,inputs:[{name:"clip",type:"CLIP",link:3}],outputs:[{name:"CONDITIONING",type:"CONDITIONING",links:[4],slot_index:0}],properties:{},widgets_values:["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{id:5,type:"EmptyLatentImage",pos:[473,609],size:{0:315,1:106},flags:{},order:1,mode:0,outputs:[{name:"LATENT",type:"LATENT",links:[2],slot_index:0}],properties:{},widgets_values:[512,512,1]},{id:3,type:"KSampler",pos:[863,186],size:{0:315,1:262},flags:{},order:4,mode:0,inputs:[{name:"model",type:"MODEL",link:1},{name:"positive",type:"CONDITIONING",link:4},{name:"negative",type:"CONDITIONING",link:6},{name:"latent_image",type:"LATENT",link:2}],outputs:[{name:"LATENT",type:"LATENT",links:[7],slot_index:0}],properties:{},widgets_values:[0x8e7ff42ed37e,!0,20,8,"euler","normal",1]},{id:8,type:"VAEDecode",pos:[1209,188],size:{0:210,1:46},flags:{},order:5,mode:0,inputs:[{name:"samples",type:"LATENT",link:7},{name:"vae",type:"VAE",link:8}],outputs:[{name:"IMAGE",type:"IMAGE",links:[9],slot_index:0}],properties:{}},{id:9,type:"SaveImage",pos:[1451,189],size:{0:210,1:26},flags:{},order:6,mode:0,inputs:[{name:"images",type:"IMAGE",link:9}],properties:{}},{id:4,type:"CheckpointLoaderSimple",pos:[26,474],size:{0:315,1:98},flags:{},order:0,mode:0,outputs:[{name:"MODEL",type:"MODEL",links:[1],slot_index:0},{name:"CLIP",type:"CLIP",links:[3,5],slot_index:1},{name:"VAE",type:"VAE",links:[8],slot_index:2}],properties:{},widgets_values:["v1-5-pruned-emaonly.ckpt"]}],links:[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],groups:[],config:{},extra:{},version:.4};var Ye;(t=>{async function e({parentFolderID:u,name:d}){const f=await(P==null?void 0:P.getSetting("myWorkflowsDir"));return ft(`${f}/${u??""}/${d}.json`)}async function n(u,d){const f=await e(u),p=await Ft(d);try{const h=await(await fetch("/workspace/file/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f,newParentPath:p})})).json();return h.error?(alert("Error moving file: "+h.error),!1):!0}catch(y){console.error("Error deleting file:",y)}}t.moveWorkflow=n;async function r(u,d){const f=await Ft(`${d}/${u}`);try{const y=await(await fetch("/workspace/file/gen_unique_name",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f})})).json();return y.error?(console.error("Error getting unique name:",y.error),null):y.uniqueName}catch(p){console.error("Error deleting file:",p)}return null}t.genFileUniqueName=r;async function o({parentFolderID:u,name:d},f){const p=await(P==null?void 0:P.getSetting("myWorkflowsDir")),y=ft(`${p}/${u??""}/${d}.json`);try{const v=await(await fetch("/workspace/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:y,newName:f})})).json();return v.error?(alert("Error moving file: "+v.error),!1):!0}catch(h){console.error("Error deleting file:",h)}}t.renameWorkflow=o;async function s(){const u=await(P==null?void 0:P.getSetting("myWorkflowsDir")),d=ft(u);try{const p=await(await fetch("/workspace/file/scan_dup_id",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d})})).json();return!0}catch(f){console.error("Error deleting file:",f)}}t.scanMyWorkflowsDupId=s;async function a(u){const d=await e(u),f=u.json,p=JSON.parse(f);p.extra[jr]={id:u.id};const h=await(await fetch("/workspace/file/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,json:JSON.stringify(p)})})).json();if(h.error)throw console.error("Error saving file:",h.error),alert(`"Error saving file: ${h.error} + + 👉Please try "Save as" from "Files" dropdown menu + `),new Error(h.error);return h}t.saveWorkflow=a;async function i(u){const d=await e(u);try{return await(await fetch("/workspace/delete_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:d,deleteEmptyFolder:!1})})).text()}catch(f){alert("Error deleting workflow .json file: "+f),console.error("Error deleting file:",f)}}t.deleteWorkflow=i;async function l({parentFolderID:u,name:d,json:f,id:p}){var g;const y=await(P==null?void 0:P.getSetting("myWorkflowsDir")),h=ft(`${y}/${u??""}`);let v=JSON.parse(f);v={...v,extra:{[jr]:{id:p}}};const w={parentFolderPath:h,name:d,json:JSON.stringify(v)};try{const E=await(await fetch("/workspace/create_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)})).json();return E.name&&await((g=H.workflows)==null?void 0:g.update(p,{filePath:`${h}/${d}.json`,name:E.name})),E}catch(x){return console.error(`Error creating file <${p}> at "${h}"`,x),alert(`Error creating file <${p}> at "${h}"`),{}}}t.creatWorkflow=l;async function c({parentFolderID:u,name:d,id:f}){const p=await(P==null?void 0:P.getSetting("myWorkflowsDir")),y=ft(`${p}/${u??""}/${d}.json`);try{const v=await(await fetch("/workspace/get_workflow_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:y,id:f})})).json();return v.error&&(console.error(`Error getting file <${f}> at "${y}"`,v.error),alert({message:`Error getting file <${f}> at "${y}"`,level:"error"})),v}catch(h){return console.error(`Erro finding file <${f}> at "${y}"`,h),{}}}t.getFile=c})(Ye||(Ye={}));async function Xf(t){try{return await(await fetch("/workspace/scan_my_workflows_files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ft(t)})})).json()}catch(e){return console.error("Error scan local new files:",e),[]}}async function Zf(t,e){const n=await(P==null?void 0:P.getSetting("myWorkflowsDir"));if(n==null||n==="")return alert("No Workspace saving directory found, please go to Settings."),[];const r=t??"",o=`${n}/${r}`,a=(await Xf(o)).map(async c=>{var p;const u=c.name,d=ft([o,u].join("/")),f=[r,u].join("/");return Qf(c)?{id:f,name:c.name,parentFolderID:r,type:"folder",createTime:Date.now(),updateTime:Date.now()}:{...await((p=H.workflows)==null?void 0:p.get(c.id))??{createTime:Date.now(),updateTime:Date.now()},id:c.id,filePath:d,lastSavedJson:c.json??"{}",json:c.json??"{}",name:u.replace(/\.json$/,""),parentFolderID:r,createTime:c.createTime}}),i=await Promise.all(a);H.workflows.bulkPut(i.filter(c=>!np(c)));const l=i.filter(c=>c!=null);return Xi(l,e??_t.RECENTLY_MODIFIED)}function Qf(t){return"type"in t&&t.type==="folder"}const Ir=class Ir extends Jt{constructor(){super("workflows");ke(this,"_curWorkflow",null)}get curWorkflow(){return this._curWorkflow}static async load(){return new Ir}updateCurWorkflowID(n){if(n==null){this._curWorkflow=null;return}this.get(n).then(r=>{this._curWorkflow=r??null})}updateCurWorkflow(n){this._curWorkflow=n}async latestVersionCheck(){if(this._curWorkflow){const n=await H.workflows.get(this._curWorkflow.id);return n?(n==null?void 0:n.updateTime)===this._curWorkflow.updateTime:!0}return!0}async generateUniqueName(n,r){if(await(P==null?void 0:P.getSetting("twoWaySync"))){const l=await Ye.genFileUniqueName((n??"Untitled Flow")+".json",r??"");return(l==null?void 0:l.replace(/\.json$/,""))??"Untitled Flow"}let s=n??"Untitled Flow";const i=(await this.listAll()??[]).filter(l=>l.parentFolderID==r).map(l=>l.name);if(i.includes(s)){let l=2,c=!0;for(;c;)i.includes(`${s} ${l}`)?l++:(s=`${s} ${l}`,c=!1)}return s}async createFlow(n){const{id:r,json:o,name:s}=n,a=await this.generateUniqueName(s,n.parentFolderID??void 0),i=r??Ho(),l=Date.now(),c={...n,id:i,json:o??JSON.stringify(hr),name:a,updateTime:l,createTime:l};return await H.workflows.add(c),this.saveDiskDB(),await(P==null?void 0:P.getSetting("twoWaySync"))?(await Ye.creatWorkflow(c),await this.get(c.id)):(bn(c),c)}async update(n,r){throw new Error("Method not allowed.")}async updateMetaInfo(n,r){return this._update(n,r)}async _update(n,r){await H.workflows.update(n,r);const o=await H.workflows.get(n)??null;return this._curWorkflow&&this._curWorkflow.id===n&&(this._curWorkflow=o),this.saveDiskDB(),o}async updateFolder(n,r){var i;const o=await(P==null?void 0:P.getSetting("twoWaySync")),s=await this.get(n),a=await this.updateMetaInfo(n,r);!a||!s||(o?await Ye.moveWorkflow(s,r.parentFolderID):(await bn(a),await uo(s),(a==null?void 0:a.parentFolderID)!=null&&await((i=H.folders)==null?void 0:i.update(a.parentFolderID,{updateTime:Date.now()}))))}async genLastManualSavedJson(n){const r=await(Ae==null?void 0:Ae.getLastestByWorkflowID(n));return r==null?void 0:r.json}async updateName(n,r){const o=await this.get(n);return await(P==null?void 0:P.getSetting("twoWaySync"))&&o&&await Ye.renameWorkflow(o,r.name+".json"),await this.updateMetaInfo(n,r)}async updateFlow(n,r){const o=await this.get(n,!1);if(o==null)return;const s=JSON.stringify(o.json),a=JSON.stringify(r.json);if(s===a)return;const i=await this._update(n,{updateTime:Date.now(),json:r.json});await(P==null?void 0:P.getSetting("twoWaySync"))?i&&await Ye.saveWorkflow(i):i&&await bn(i)}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=Ho(),c=Date.now(),u={id:l,name:i,json:a.json,parentFolderID:o,updateTime:c,createTime:c,tags:[]};s.push(u),await(P==null?void 0:P.getSetting("twoWaySync"))?Ye.creatWorkflow(u):await bn(u)}await H.workflows.bulkAdd(s),this.saveDiskDB()}async deleteFlow(n){const r=await this.get(n);r&&(await(P==null?void 0:P.getSetting("twoWaySync"))?await Ye.deleteWorkflow(r):uo({...r})),await H.workflows.delete(n),this.saveDiskDB()}async batchDeleteFlow(n){const r=await H.workflows.bulkGet(n);for(const o of r){if(!o)return;await(P==null?void 0:P.getSetting("twoWaySync"))?await Ye.deleteWorkflow(o):uo({...o})}await H.workflows.bulkDelete(n),this.saveDiskDB()}async listFolderContent(n,r){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await Zf(n??null);const s=await this.listAll().then(l=>l.filter(c=>c.parentFolderID==n))??[],a=await(Te==null?void 0:Te.listAll().then(l=>l.filter(c=>c.parentFolderID==n)))??[],i=[...s,...a];return Xi(i,r??_t.RECENTLY_MODIFIED)}async get(n,r=!0){const o=await(P==null?void 0:P.getSetting("twoWaySync")),s=await H.workflows.get(n);if(!o||!r)return s;if(s==null)return;const a=await Ye.getFile({parentFolderID:s.parentFolderID??null,name:s.name,id:s.id});if(a.json)return{...s,json:JSON.stringify(a.json)}}};ke(Ir,"TABLE_NAME","workflows");let Go=Ir;const Pr=class Pr extends Jt{constructor(){super("folders")}static async load(){return new Pr}async create(e){const n=await this.generateUniqueName(e.name,e.parentFolderID),r=await(P==null?void 0:P.getSetting("twoWaySync")),o=await Et.genFolderRelPath({name:n,parentFolderID:e.parentFolderID??""}),s={id:r?o:Pn(),name:n,parentFolderID:e.parentFolderID??null,updateTime:Date.now(),createTime:Date.now(),type:"folder"};return r?await Et.createFolder(s):(await H.folders.add(s),this.saveDiskDB()),s}async update(e,n){if(await(P==null?void 0:P.getSetting("twoWaySync")))return"parentFolderID"in n&&await Et.moveFolder(e,n.parentFolderID??""),"name"in n&&await Et.renameFolder(e,n.name??""),null;const o=await this.get(e);if(o==null)return null;const s="name"in n&&n.name!=o.name,a="parentFolderID"in n&&n.parentFolderID!=o.parentFolderID,i={...o,...n};return n.name!=null&&(i.updateTime=Date.now()),a&&(n.name=await this.generateUniqueName(i.name,i.parentFolderID??void 0)),await H.folders.update(e,n),this.saveDiskDB(),(s||a)&&qf(!0),i}async deleteFolder(e,n=pr.DELETE){await(P==null?void 0:P.getSetting("twoWaySync"))&&await Et.deleteFolder(e);const o=await(O==null?void 0:O.listAll())??[],s=await this.listAll(),a=[e];for(;a.length>0;){const i=a.shift();if(i){for(const c of o)if(c.parentFolderID===i)switch(n){case pr.DELETE:await(O==null?void 0:O.deleteFlow(c.id));break;case pr.MOVE_TO_ROOT_FOLDER:await(O==null?void 0:O.updateFolder(c.id,{parentFolderID:void 0}));break}await H.folders.delete(i);const l=s.filter(c=>c.parentFolderID===i).map(c=>c.id);l.length&&a.push(...l)}}this.saveDiskDB()}async generateUniqueName(e,n){if(await(P==null?void 0:P.getSetting("twoWaySync")))return await Ye.genFileUniqueName(e??"New folder",n??"")??"New folder";let o=e??"New folder";const s=await this.listAll().then(a=>a.filter(i=>i.parentFolderID==n).map(i=>i.name));if(s.includes(o)){let a=2,i=!0;for(;i;)s.includes(`${o} ${a}`)?a++:(o=`${o} ${a}`,i=!1)}return o}};ke(Pr,"TABLE_NAME","folders");let Yo=Pr;class Qi extends Jt{constructor(){super("media")}async listByWorkflowID(e){return await H.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:Pn(),localPath:e.localPath,workflowID:e.workflowID,createTime:Date.now(),format:n},o=await(O==null?void 0:O.get(e.workflowID)),s=new Set((o==null?void 0:o.mediaIDs)??[]).add(r.id);return await(O==null?void 0:O.updateMetaInfo(e.workflowID,{mediaIDs:Array.from(s),coverMediaPath:r.localPath})),H.media.add(r),this.saveDiskDB(),r}}ke(Qi,"TABLE_NAME","media");const mh=["Checkpoint","TextualInversion","Hypernetwork","LORA","Controlnet","Upscaler","VAE"],ep={Checkpoint:"checkpoints",TextualInversion:"embeddings",Hypernetwork:"hypernetworks",LORA:"loras",Controlnet:"controlnet",Upscaler:"upscale_models",VAE:"vae"};function yh(t){return t.modelVersions!==void 0}function tp(t){var e;return((e=t.files)==null?void 0:e[0])!==void 0}function vh(t,e){var r,o,s,a,i,l;if(!t)return;let n;return tp(t)?n={id:t.id,SHA256:(o=(r=t.files)==null?void 0:r[0].hashes)==null?void 0:o.SHA256,name:(s=t.files)==null?void 0:s[0].name,sizeKB:(i=(a=t.files)==null?void 0:a[0])==null?void 0:i.sizeKB}:n={id:t.id,SHA256:(l=t.hashes)==null?void 0:l[2],name:`${e} ${t.name}`},n}const Nr=class Nr extends Jt{constructor(){super("userSettings");ke(this,"defaultSettings");ke(this,"DEFAULT_USER","guest");ke(this,"_autoSave",!1);this.defaultSettings={id:this.DEFAULT_USER,topBarStyle:{top:0,left:0},modelManagerTopBarStyle:{top:0,right:0},myWorkflowsDir:"",shortcuts:{save:"Shift+S"},defaultFolders:ep,autoSave:!0,twoWaySync:!1,foldersOnTop:!1,cloudHost:"https://www.comfyspace.art",overwriteCurWorkflowWhenDroppingFileToCanvas:!1}}get autoSave(){return this._autoSave}__TEMP_OVERRIDE_ONLY_disableAutoSave(){this._autoSave&&(this._autoSave=!1,setTimeout(async()=>{this._autoSave=await this.getSetting("autoSave")??this.defaultSettings.autoSave??!0},3e3))}async getSettings(){const n=await this.get(this.DEFAULT_USER);return{...this.defaultSettings,...n}}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 Nr,r=await $d();return n.defaultSettings.myWorkflowsDir=`${r.dir_path}/my_workflows`,await n.getSetting("autoSave").then(o=>{n._autoSave=o??!0}),n}};ke(Nr,"TABLE_NAME","userSettings");let Xo=Nr;const Ar=class Ar extends Jt{constructor(){super("tags")}static async load(){return new Ar}};ke(Ar,"TABLE_NAME","tags");let Zo=Ar;const Fr=class Fr extends Jt{constructor(){super("workflowVersions")}static async load(){return new Fr}async listByWorkflowID(e){return await H[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}};ke(Fr,"TABLE_NAME","workflowVersions");let Qo=Fr;function np(t){return"type"in t&&t.type==="folder"}let O=null,mr=null,P=null,Te=null,Ae=null,Ut=null,me=null;async function rp(){const t=async()=>{O=await Go.load()},e=async()=>{mr=await Zo.load()},n=async()=>{P=await Xo.load()},r=async()=>{Te=await Yo.load()},o=async()=>{Ae=await Jo.load()},s=async()=>{Ut=new Qi},a=async()=>{me=await Qo.load()};await Promise.all([t(),e(),n(),r(),o(),s(),a()]),localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL")!=="true"&&(await op(),localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL","true"))}async function op(){const t=async()=>{try{const i=await(O==null?void 0:O.getRecords());i&&await H.workflows.bulkAdd(Object.values(i))}catch(i){console.error(i)}},e=async()=>{try{const i=await(Te==null?void 0:Te.getRecords());i&&await H.folders.bulkAdd(Object.values(i))}catch(i){console.error(i)}},n=async()=>{try{const i=await(Ut==null?void 0:Ut.getRecords());i&&await H.media.bulkAdd(Object.values(i))}catch(i){console.error(i)}},r=async()=>{try{const i=await(Ae==null?void 0:Ae.getRecords());i&&await H.changelogs.bulkAdd(Object.values(i))}catch(i){console.error(i)}},o=async()=>{try{const i=await(mr==null?void 0:mr.getRecords());i&&await H.tags.bulkAdd(Object.values(i))}catch(i){console.error(i)}},s=async()=>{try{const i=P,l=await i.getRecords().then(c=>c[i.DEFAULT_USER]?c[i.DEFAULT_USER]:c);await H.userSettings.put({...i.defaultSettings,...l})}catch(i){console.error(i)}},a=async()=>{try{const i=await(me==null?void 0:me.getRecords());i&&await H.workflowVersions.bulkAdd(Object.values(i))}catch(i){console.error(i)}};await Promise.all([t(),e(),n(),r(),o(),s(),a()])}const Pt=b.createContext({curFlowID:null,loadWorkflowID:()=>{},saveCurWorkflow:()=>{},discardUnsavedChanges:async()=>{},isDirty:!1,loadNewWorkflow:()=>{},loadFilePath:()=>{},setRoute:()=>{},jsonDiff:null,compareJson:()=>{}}),gh=b.createContext({refreshFolderStamp:0,setRefreshFolderStamp:()=>{}}),fo={x:0,y:0};function sp({children:t,onDragEnd:e,dragIconId:n}){const r=b.useRef(fo),o=b.useRef(!1),[s,a]=b.useState(fo),i=d=>{var f,p,y;if(!(!(d.target instanceof Element)||!(d.target.parentNode instanceof Element))&&[(f=d.target)==null?void 0:f.id,(y=(p=d.target)==null?void 0:p.parentNode)==null?void 0:y.id].includes(n)){r.current={x:d.clientX,y:d.clientY},o.current=!0,window.addEventListener("mousemove",l),window.addEventListener("mouseup",c);const h=document.getElementsByTagName("body")[0];h.style.userSelect="none"}},l=b.useCallback(d=>{const f={x:d.clientX-r.current.x,y:d.clientY-r.current.y};a(f)},[]),c=b.useCallback(()=>{a(f=>(e(f),fo)),o.current=!1;const d=document.getElementsByTagName("body")[0];d.style.userSelect="auto",window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",c)},[e,l]),u={transform:`translate(${s.x}px, ${s.y}px)`,zIndex:o.current?1e3:1};return m.jsx("div",{style:u,onMouseDown:i,children:t})}var ap={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"},ip=Object.defineProperty,lp=Object.defineProperties,cp=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,el=Object.prototype.hasOwnProperty,tl=Object.prototype.propertyIsEnumerable,ma=(t,e,n)=>e in t?ip(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ya=(t,e)=>{for(var n in e||(e={}))el.call(e,n)&&ma(t,n,e[n]);if(Dr)for(var n of Dr(e))tl.call(e,n)&&ma(t,n,e[n]);return t},up=(t,e)=>lp(t,cp(e)),dp=(t,e)=>{var n={};for(var r in t)el.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&&tl.call(t,r)&&(n[r]=t[r]);return n},Oe=(t,e,n)=>{const r=b.forwardRef((o,s)=>{var a=o,{color:i="currentColor",size:l=24,stroke:c=2,children:u}=a,d=dp(a,["color","size","stroke","children"]);return b.createElement("svg",ya(up(ya({ref:s},ap),{width:l,height:l,stroke:i,strokeWidth:c,className:`tabler-icon tabler-icon-${t}`}),d),[...n.map(([f,p])=>b.createElement(f,p)),...u||[]])});return r.propTypes={color:Nt.string,size:Nt.oneOfType([Nt.string,Nt.number]),stroke:Nt.oneOfType([Nt.string,Nt.number])},r.displayName=`${e}`,r},fp=Oe("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"}]]),pp=Oe("chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),hp=Oe("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"}]]),mp=Oe("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"}]]),es=Oe("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"}]]),yp=Oe("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"}]]),vp=Oe("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"}]]),gp=Oe("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"}]]),wp=Oe("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"}]]),bp=Oe("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"}]]),xp=Oe("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"}]]),kp=Oe("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"}]]),_p=Oe("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"}]]),Ep=Oe("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),Cp=Oe("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"}]]),Sp=Oe("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"}]]),jp=Oe("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"}]]),Dp=Oe("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"}]]),Op=Oe("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"}]]),Ip=Oe("x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);function Pp(t){const{promptMessage:e="Are you sure you want to delete this?",variant:n="ghost",onDelete:r,isDisabled:o=!1,tooltipText:s}=t;return m.jsx(ri,{isLazy:!0,placement:"auto",children:({onClose:a})=>m.jsxs(m.Fragment,{children:[m.jsx(ni,{children:m.jsx(ht,{children:m.jsx(Wt,{hasArrow:!0,label:s,placement:"bottom",children:m.jsx(on,{"aria-label":"Delete confirm",size:"sm",icon:m.jsx(Sp,{color:"#F56565"}),isDisabled:o,variant:n})})})}),m.jsxs(li,{children:[m.jsx(oi,{}),m.jsx(ai,{onClick:a}),m.jsxs(si,{children:[m.jsx(Tt,{mb:4,pr:4,fontWeight:600,children:e}),m.jsx(Ke,{colorScheme:"red",size:"sm",onClick:()=>{r(),a()},children:"Yes, delete"})]})]})]})})}function Np({onClose:t}){const e=_a(),{curFlowID:n,isDirty:r}=b.useContext(Pt),[o,s]=b.useState(0),[a,i]=b.useState(null),[l,c]=b.useState([]),[u,d]=b.useState([]),f=async h=>{var E;const v=await(O==null?void 0:O.get(h)),w=await(Ae==null?void 0:Ae.listByWorkflowID(h));c(w??[]);const g=w==null?void 0:w.filter(S=>S.json===(v==null?void 0:v.json)),x=(E=g==null?void 0:g[0])==null?void 0:E.id;x&&i(x)},p=async()=>{var x;const h=await(me==null?void 0:me.listByWorkflowID(n))??[];d(h);const v=JSON.stringify(ge.graph.serialize()),w=h==null?void 0:h.filter(E=>E.json===v),g=(x=w==null?void 0:w[0])==null?void 0:x.id;g&&i(g)},y=h=>{me==null||me.delete(h).then(()=>{p()})};return b.useEffect(()=>{switch(o){case 0:p();break;case 1:f(n);break}},[o]),b.useEffect(()=>(ge.canvasEl.addEventListener("click",t),()=>{ge.canvasEl.removeEventListener("click",t)}),[o]),m.jsxs(Rl,{width:400,height:"100vh",gap:0,position:"fixed",top:0,left:0,zIndex:1e3,children:[m.jsx(Ml,{pb:1,mb:0,children:m.jsxs(rr,{justifyContent:"space-between",alignItems:"center",children:[m.jsx(Ta,{size:"md",children:"Version History"}),m.jsx(on,{size:"sm",icon:m.jsx(Ip,{}),onClick:t,variant:"ghost","aria-label":"close version history"})]})}),m.jsx(Fl,{overflowY:"auto",gap:0,children:m.jsxs(di,{isFitted:!0,variant:"enclosed",onChange:s,children:[m.jsxs(fi,{mb:"1em",children:[m.jsx(bo,{children:"Versions"}),m.jsx(bo,{children:"Change History"})]}),m.jsxs(pi,{children:[m.jsx(wo,{children:m.jsx(xn,{divider:m.jsx(mo,{}),spacing:2,children:u==null?void 0:u.map(h=>m.jsxs(rr,{w:"100%",mb:1,justify:"space-between",backgroundColor:h.id===a?"teal.300":void 0,borderRadius:4,children:[m.jsxs(xn,{textAlign:"left",gap:0,children:[m.jsx(Tt,{fontWeight:"500",children:h.name??"untitled"}),m.jsxs(Tt,{color:"GrayText",fontSize:"sm",children:["Created: ",pa(h.createTime)]})]}),m.jsxs(rr,{alignItems:"center",gap:2,children:[m.jsx(Ke,{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}ge.loadGraphData(JSON.parse(h.json)),O==null||O.updateFlow(n,{json:h.json}),e({title:`Switched to version "${h.name}"`,status:"success",duration:3e3,isClosable:!0}),t()},children:"Load"}),m.jsx(Pp,{promptMessage:"Are you sure you want to delete this version?",onDelete:()=>{y(h.id)}})]})]},h.id))})}),m.jsxs(wo,{children:[m.jsx(Tt,{mb:4,children:"All the saved changes of this workflow"}),m.jsx(xn,{divider:m.jsx(mo,{}),spacing:2,children:l==null?void 0:l.map(h=>m.jsxs(Ke,{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}ge.loadGraphData(JSON.parse(h.json)),O==null||O.updateFlow(n,{json:h.json}),t()},isActive:h.id===a,children:["Saved at ",pa(h.createTime,!0)]},h.id))})]})]})]})})]})}function Ap({workflowId:t,onClose:e}){const[n,r]=b.useState(""),[o,s]=b.useState(""),a=l=>{r(l.target.value),o&&s("")},i=async()=>{const l=n.trim();if(r(l),(await(me==null?void 0:me.listByWorkflowID(t))??[]).some(u=>u.name===l))s("The name is duplicated, please modify it and submit again.");else{const u=JSON.stringify(ge.graph.serialize());await(me==null?void 0:me.add({name:n,workflowID:t,createTime:Date.now(),json:u})),e()}};return m.jsxs(Tr,{isOpen:!0,onClose:e,children:[m.jsx(rs,{}),m.jsxs(Lr,{children:[m.jsx(os,{children:"Create Version"}),m.jsx(ss,{}),m.jsx(as,{children:m.jsxs(Br,{isInvalid:!!o,children:[m.jsx(Kr,{children:"Name"}),m.jsx(Bn,{value:n,onChange:a,autoFocus:!0,onKeyUp:l=>{l.code==="Enter"&&!o&&n&&i()}}),o&&m.jsx($r,{children:o})]})}),m.jsxs(is,{children:[m.jsx(Ke,{colorScheme:"teal",mr:3,onClick:i,isDisabled:!n||!!o,children:"Create"}),m.jsx(Ke,{onClick:e,children:"Cancel"})]})]})]})}function Fp({options:t,menuButton:e,isOpen:n,onClose:r}){const o=b.useRef(null);return ic({ref:o,handler:()=>r()}),m.jsxs(ht,{position:"relative",children:[m.jsx(ht,{children:e}),n&&m.jsx(ht,{ref:o,mt:"8px",shadow:"md",p:"2",position:"absolute",zIndex:"dropdown",children:t})]})}function nl({menuButton:t,menuContent:e,onClose:n}){const r=b.useRef(),[o,s]=b.useState(!1),a=()=>{r.current=setTimeout(()=>s(!1),400)},i=()=>{s(!0),clearTimeout(r.current),r.current=void 0};return m.jsx(Fp,{isOpen:o,onClose:a,menuButton:m.jsx(ht,{"aria-label":"menu",onClick:i,onMouseEnter:i,onMouseLeave:a,children:t}),options:m.jsx(bs,{isOpen:!0,children:m.jsx(xs,{minWidth:150,zIndex:1e3,onMouseEnter:i,onMouseLeave:a,children:e})})})}var rl={exports:{}};(function(t,e){(function(n,r){t.exports=r(b)})(self,function(n){return(()=>{var r={579:(i,l,c)=>{var u=c(84);i.exports=u},84:(i,l,c)=>{c.r(l),c.d(l,{default:()=>se});var u=c(250),d=c.n(u),f=function(_){return _==="array"||Object.prototype.toString.call(_)==="[object Array]"},p=function(_){return Object.prototype.toString.call(_)==="[object Object]"},y=function(_){return _===1?{textIndent:"20px"}:{textIndent:"".concat(20*_,"px")}},h=function(_){var N=Object.prototype.toString.call(_);return(N=N.match(/(?!\[).+(?=\])/g)[0].split(" ")[1]).toLowerCase()},v=function(_){return p(_)||f(_)},w=function(_,N){return Object.prototype.toString.call(_)===Object.prototype.toString.call(N)};function g(_,N,M){return N in _?Object.defineProperty(_,N,{value:M,enumerable:!0,configurable:!0,writable:!0}):_[N]=M,_}function x(){return x=Object.assign||function(_){for(var N=1;N_.length)&&(N=_.length);for(var M=0,L=new Array(N);M_.length)&&(N=_.length);for(var M=0,L=new Array(N);M{c.d(l,{Z:()=>y});var u=c(81),d=c.n(u),f=c(645),p=c.n(f)()(d());p.push([i.id,`.c-json-view { + display: block; + width: 100%; + padding: 10px 10px 10px 40px; + background-color: #fbfbfb; + box-sizing: border-box; + white-space: pre-wrap; + word-wrap: break-word; + overflow: hidden; +} + +.c-json-line, +.c-json-p, +.c-json-feet { + position: relative; + text-align: left; + padding: 0; + margin: 0; + padding: 2px 0; +} + +.c-json-line { + padding: 0; +} + +.c-line-del { + background-color: #ffeef0; +} + +.c-line-add { + background-color: #e6ffed; +} + +.c-line-none {} + +.c-of-del:after { + content: '-'; + position: absolute; + left: 5px; + top: 3px; + width: 10px; + height: 15px; + z-index: 5; + text-indent: 0; + color: #ff6f6f; +} + +.c-of-add:after { + content: '+'; + position: absolute; + left: 5px; + top: 3px; + width: 10px; + height: 15px; + z-index: 5; + color: #3eb93e; + text-indent: 0; +} + +.c-json-p { + cursor: pointer; +} + +.c-json-outter { + transform: translateX(-35px); +} + +.c-json-mark { + position: absolute; + left: -30px; + top: 2px; + text-indent: 0; + font-size: 12px; + color: #545454; + z-index: 5; + user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -webkit-user-select: none; +} + +.c-json-content { + font-size: 14px; +} + +.c-json-content .c-json-key { + font-size: 15px; + color: #5cadff; +} + +.c-json-items { + color: #b1b1b1; +} + +.c-json-comma { + color: #5cadff; +} + +.c-json-pt { + color: #5cadff; +} + +.c-json-number { + color: #ae81ff; +} + +.c-json-string { + color: #a6e22e; +} + +.c-json-null, +.c-json-boolean, +.c-json-undefined, +.c-json-regexp, +.c-json-date, +.c-json-set, +.c-json-map, +.c-json-error, +.c-json-symbol, +.c-json-function { + background-color: #f7f7f7; + border-radius: 3px; + padding: 0px 2px; + border: 1px solid #dedede; +} + +.c-json-boolean { + color: #6f73ff; +} + +.c-json-null { + color: #66d9ef; +} + +.c-json-undefined { + color: #f92672; +} + +.c-json-date { + color: #09d3ac; +} + +.c-json-regexp { + color: #2ea021; +} + +.c-json-function { + color: #a2af3d; +} + +.c-json-symbol { + color: #fd3db8; +} + +.c-json-error { + color: #afafaf; +} + +.c-json-set, +.c-json-map { + color: #f56847; +}`,""]);const y=p},645:i=>{i.exports=function(l){var c=[];return c.toString=function(){return this.map(function(u){var d="",f=u[5]!==void 0;return u[4]&&(d+="@supports (".concat(u[4],") {")),u[2]&&(d+="@media ".concat(u[2]," {")),f&&(d+="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {")),d+=l(u),f&&(d+="}"),u[2]&&(d+="}"),u[4]&&(d+="}"),d}).join("")},c.i=function(u,d,f,p,y){typeof u=="string"&&(u=[[null,u,void 0]]);var h={};if(f)for(var v=0;v0?" ".concat(x[5]):""," {").concat(x[1],"}")),x[5]=y),d&&(x[2]&&(x[1]="@media ".concat(x[2]," {").concat(x[1],"}")),x[2]=d),p&&(x[4]?(x[1]="@supports (".concat(x[4],") {").concat(x[1],"}"),x[4]=p):x[4]="".concat(p)),c.push(x))}},c}},81:i=>{i.exports=function(l){return l[1]}},379:i=>{var l=[];function c(f){for(var p=-1,y=0;y{var l={};i.exports=function(c,u){var d=function(f){if(l[f]===void 0){var p=document.querySelector(f);if(window.HTMLIFrameElement&&p instanceof window.HTMLIFrameElement)try{p=p.contentDocument.head}catch{p=null}l[f]=p}return l[f]}(c);if(!d)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");d.appendChild(u)}},216:i=>{i.exports=function(l){var c=document.createElement("style");return l.setAttributes(c,l.attributes),l.insert(c,l.options),c}},565:(i,l,c)=>{i.exports=function(u){var d=c.nc;d&&u.setAttribute("nonce",d)}},795:i=>{i.exports=function(l){var c=l.insertStyleElement(l);return{update:function(u){(function(d,f,p){var y="";p.supports&&(y+="@supports (".concat(p.supports,") {")),p.media&&(y+="@media ".concat(p.media," {"));var h=p.layer!==void 0;h&&(y+="@layer".concat(p.layer.length>0?" ".concat(p.layer):""," {")),y+=p.css,h&&(y+="}"),p.media&&(y+="}"),p.supports&&(y+="}");var v=p.sourceMap;v&&typeof btoa<"u"&&(y+=` +/*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(v))))," */")),f.styleTagTransform(y,d,f.options)})(c,l,u)},remove:function(){(function(u){if(u.parentNode===null)return!1;u.parentNode.removeChild(u)})(c)}}}},589:i=>{i.exports=function(l,c){if(c.styleSheet)c.styleSheet.cssText=l;else{for(;c.firstChild;)c.removeChild(c.firstChild);c.appendChild(document.createTextNode(l))}}},250:i=>{i.exports=n}},o={};function s(i){var l=o[i];if(l!==void 0)return l.exports;var c=o[i]={id:i,exports:{}};return r[i](c,c.exports,s),c.exports}s.n=i=>{var l=i&&i.__esModule?()=>i.default:()=>i;return s.d(l,{a:l}),l},s.d=(i,l)=>{for(var c in l)s.o(l,c)&&!s.o(i,c)&&Object.defineProperty(i,c,{enumerable:!0,get:l[c]})},s.o=(i,l)=>Object.prototype.hasOwnProperty.call(i,l),s.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var a=s(579);return a.default})()})})(rl);var Mp=rl.exports;const Rp=va(Mp);function Tp(){const{jsonDiff:t,compareJson:e}=b.useContext(Pt);return t==null?null:m.jsx(Tr,{isOpen:!0,onClose:()=>{e(null)},children:m.jsx(Lr,{children:m.jsx(ht,{height:"80vh",width:"90%",overflow:"scroll",children:m.jsx(Rp,{oldData:t==null?void 0:t.old,newData:t==null?void 0:t.new})})})})}const Lp=b.lazy(()=>Wr(()=>import("./ShareDialog-17qMdssr.js"),__vite__mapDeps([0,1,2])));function Wp(){const{curFlowID:t,loadWorkflowID:e,discardUnsavedChanges:n,saveCurWorkflow:r}=b.useContext(Pt),[o,s]=b.useState(!1),[a,i]=b.useState(!1),[l,c]=b.useState(!1),[u,d]=b.useState(""),[f,p]=b.useState(""),[y,h]=b.useState(),[v,w]=b.useState(""),[g,x]=b.useState(!1);b.useEffect(()=>{t&&(O==null||O.get(t).then(D=>{d((D==null?void 0:D.name)??""),h(D)})),P==null||P.getSetting("shortcuts").then(D=>{w(D==null?void 0:D.save)})},[t]);const E=D=>{d(D.target.value),f&&p("")},S=async()=>{if(!t){alert("Flow ID is required");return}const D=JSON.stringify(ge.graph.serialize()),j=await(O==null?void 0:O.createFlow({json:D,lastSavedJson:D,name:u,parentFolderID:y==null?void 0:y.parentFolderID}));j&&await e(j.id,!0),C()},C=()=>{i(!1)},k=b.useCallback(async()=>{const D=t?await(O==null?void 0:O.get(t)):null;if(!D){alert("Workspace does not exist");return}const j=new Blob([D.json],{type:"application/json"}),A=URL.createObjectURL(j),F=document.createElement("a");F.href=A,F.download=`${D.name}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(A)},[t]);return m.jsxs(m.Fragment,{children:[m.jsx(nl,{menuButton:m.jsx(xl,{children:m.jsxs(Ke,{px:1,height:"29px","aria-label":"menu",size:"sm",backgroundColor:"teal.600",children:["File",m.jsx(pp,{size:20})]})}),menuContent:m.jsx(bs,{isOpen:!0,children:m.jsxs(xs,{minWidth:150,zIndex:1e3,children:[m.jsx(wt,{onClick:r,icon:m.jsx(es,{size:20}),iconSpacing:1,command:v,children:"Save"}),m.jsx(Wt,{label:"Revert workflow to your last saved version. You will lose all changes made since your last save.",children:m.jsx(wt,{onClick:n,icon:m.jsx(fp,{size:20}),iconSpacing:1,children:"Discard unsaved changes"})}),m.jsx(wt,{onClick:k,icon:m.jsx(yp,{size:20}),iconSpacing:1,children:"Download"}),m.jsx(wt,{onClick:()=>i(!0),icon:m.jsx(es,{size:20}),iconSpacing:1,children:"Save As"}),m.jsx(wt,{onClick:()=>s(!0),icon:m.jsx(Dp,{size:20}),iconSpacing:1,children:"Create Version"}),m.jsx(wt,{onClick:()=>c(!0),icon:m.jsx(bp,{size:20}),iconSpacing:1,children:"Versions History"}),m.jsx(wt,{onClick:()=>x(!0),icon:m.jsx(Cp,{size:20}),iconSpacing:1,alignItems:"center",children:m.jsxs(Ct,{children:[m.jsx("p",{children:"Share"})," ",m.jsx(mi,{size:"sm",children:"🧪🧪beta"})]})})]})})}),g&&m.jsx(Lp,{onClose:()=>x(!1)}),l&&m.jsx(Np,{onClose:()=>c(!1)}),m.jsx(Tp,{}),a&&m.jsxs(Tr,{isOpen:!0,onClose:C,children:[m.jsx(rs,{}),m.jsxs(Lr,{children:[m.jsx(os,{children:"Save As"}),m.jsx(ss,{}),m.jsx(as,{children:m.jsxs(Br,{isInvalid:!!f,children:[m.jsx(Kr,{children:"Workflow name"}),m.jsx(Bn,{value:u,onChange:E,autoFocus:!0,onKeyUp:D=>{D.code==="Enter"&&!f&&u&&S()}}),f&&m.jsx($r,{children:f})]})}),m.jsxs(is,{children:[m.jsx(Ke,{colorScheme:"teal",mr:3,onClick:S,isDisabled:!u||!!f,children:"Save"}),m.jsx(Ke,{onClick:C,children:"Cancel"})]})]})]}),o&&m.jsx(Ap,{workflowId:t,onClose:()=>s(!1)})]})}function Bp({displayName:t,updateFlowName:e,isDirty:n}){const{isOpen:r,onOpen:o,onClose:s}=uc(),{curFlowID:a}=b.useContext(Pt),[i,l]=b.useState(t),[c,u]=b.useState(""),d=()=>{l(t),o()},f=h=>{l(h.target.value),c&&u("")},p=async()=>{var h;if(a){const v=i.trim();if(l(v),t===v)return y();await(O==null?void 0:O.generateUniqueName(v,((h=O.curWorkflow)==null?void 0:h.parentFolderID)??""))!==v?u("The name is duplicated, please modify it and submit again."):(await(O==null?void 0:O.updateName(a,{name:v})),e(v),y())}},y=()=>{u(""),s()};return a==null?null:m.jsxs(Ct,{children:[m.jsx(Wt,{label:t,placement:"bottom",children:m.jsxs(Tt,{as:"div",color:"white",onClick:d,maxW:200,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:[m.jsx("div",{style:{width:8,display:"inline-block"},children:m.jsx(Tt,{as:"span",children:n&&"* "})}),t]})}),m.jsxs(Tr,{isOpen:r,onClose:y,children:[m.jsx(rs,{}),m.jsxs(Lr,{children:[m.jsx(os,{children:"Edit workflow name"}),m.jsx(ss,{}),m.jsx(as,{children:m.jsxs(Br,{isInvalid:!!c,children:[m.jsx(Kr,{children:"Workflow name"}),m.jsx(Bn,{value:i,onChange:f,autoFocus:!0,onKeyUp:h=>{h.code==="Enter"&&!c&&i&&p()}}),c&&m.jsx($r,{children:c})]})}),m.jsxs(is,{children:[m.jsx(Ke,{colorScheme:"teal",mr:3,onClick:p,isDisabled:!i||!!c,children:"Save"}),m.jsx(Ke,{onClick:y,children:"Cancel"})]})]})]})]})}function wh(t){const e=new Uint8Array(t);return window.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}const bh=[{label:"Private",value:"PRIVATE",icon:m.jsx(kp,{})},{label:"Unlisted, anyone with the link can view",value:"UNLISTED",icon:m.jsx(xp,{})},{label:"Public",value:"PUBLIC",icon:m.jsx(Op,{})}],xh=()=>{const t=ge.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 $p(t){const e=t.cloudOrigin;if(!e)throw Error("cloudURL is required");return fetch(e+`/api/getWorkflow?id=${t.cloudID}`).then(n=>n.json()).then(n=>{var o;return((o=n.data)==null?void 0:o.privacy)??"PRIVATE"})}function Kp({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")),m.jsx("span",{children:n})}function Up({}){const[t,e]=b.useState(),[n,r]=b.useState(),{curFlowID:o}=b.useContext(Pt);return b.useEffect(()=>{o&&(O==null||O.get(o).then(s=>{s!=null&&s.cloudID?(e(s.cloudOrigin+"/workflow/"+s.cloudID),$p(s).then(a=>{r(a)})):e(void 0)}))},[o]),t?m.jsx(m.Fragment,{children:m.jsx(nl,{menuButton:m.jsx(Ke,{onClick:()=>{window.open(t)},variant:"ghost","aria-label":"Shared",size:"xs",iconSpacing:"2px",leftIcon:m.jsx(hp,{}),height:"26px",px:1,children:n?m.jsx(Kp,{privacy:n}):"Shared"}),menuContent:m.jsxs(Ct,{width:"200px",p:1,color:"blue.400",children:[m.jsx(Ma,{href:t,noOfLines:1,isExternal:!0,children:t.replace("https://www.","")}),m.jsx(on,{size:"xs",variant:"ghost",icon:m.jsx(mp,{size:19}),"aria-label":"copy link"})]})})}):null}function zp({updatePanelPosition:t,positionStyle:e,curFlowName:n,setCurFlowName:r}){const{isDirty:o,loadNewWorkflow:s,saveCurWorkflow:a,setRoute:i,curFlowID:l}=b.useContext(Pt);return m.jsx(sp,{onDragEnd:c=>{t({top:c.y,left:c.x},!0)},dragIconId:"dragPanelIcon",children:m.jsxs(Ct,{style:{padding:2,position:"fixed",...e},justifyContent:"space-between",alignItems:"center",gap:2,draggable:!1,id:"workspaceManagerPanel",className:"workspaceManagerPanel",children:[m.jsx(Ke,{size:"sm","aria-label":"workspace folder",onClick:()=>i("recentFlows"),px:2,children:m.jsxs(Ct,{gap:1,children:[m.jsx(gp,{size:21}),m.jsx(jp,{size:8})]})}),m.jsx(Wt,{label:"New workflow",children:m.jsx(Ke,{size:"sm",variant:"outline",colorScheme:"teal","aria-label":"new workflow",onClick:()=>s(),px:2,py:2,children:m.jsx(Ct,{gap:0,children:m.jsx(Ep,{size:16,color:"white"})})})}),m.jsx(Bp,{isDirty:o,displayName:n??"",updateFlowName:c=>{r(c),requestAnimationFrame(()=>{t()})}}),l&&m.jsxs(Ct,{gap:"4px",children:[m.jsx(Wt,{label:"Open gallery",children:m.jsx(on,{onClick:()=>i("gallery"),icon:m.jsx(_p,{size:22,color:"white"}),size:"sm","aria-label":"open gallery",variant:"ghost"})}),m.jsx(Wp,{})]}),m.jsx(Up,{}),l&&o?m.jsx(Wt,{label:"Save workflow",children:m.jsx(on,{onClick:a,icon:m.jsx(es,{size:23,color:"white"}),size:"xs",paddingY:4,"aria-label":"save workspace",variant:"ghost"})}):m.jsx("div",{style:{width:1}}),m.jsx(wp,{id:"dragPanelIcon",className:"dragPanelIcon",cursor:"move",size:15,color:"#FFF"})]})})}function qp(){const{showDialog:t}=xa(),{loadWorkflowID:e}=b.useContext(Pt),n=async(o,s)=>{var c,u;const{workflow:a,version:i}=o.detail;if(!a.id||!i.id)return;const l=(c=await(O==null?void 0:O.listByIndex("cloudID",a.id)))==null?void 0:c.at(0);if(console.log("existingWorkflow",l),l)((u=await(me==null?void 0:me.listByIndex("cloudID",i.id)))==null?void 0:u.at(0))?await e(l.id):await(me==null?void 0:me.add({id:i.id,cloudID:i.id,workflowID:l.id,cloudOrigin:s,name:i.name,authorID:i.authorID,json:i.json}));else{const d=await(O==null?void 0:O.createFlow({cloudID:a.id,cloudOrigin:s,name:a.name,json:i.json,updateTime:Date.now()}));if(!d){alert("Failed to add workflow to local db");return}await(me==null?void 0:me.add({id:i.id,cloudID:i.id,workflowID:d.id,cloudOrigin:s,name:i.name,json:i.json})),await e(d.id)}},r=async o=>{const s=o.data;if(Vp(s)){const a=o.origin;t(`Open workflow "${s.detail.workflow.name}", version "${s.detail.version.name}" from ${a}`,[{label:"Open",colorScheme:"teal",onClick:()=>{n(s,a)}}])}};return b.useEffect(()=>{window.opener&&window.opener.postMessage("comfyui_workspace_manager_connected","*"),window.addEventListener("message",r)},[]),null}function Vp(t){return t.type==="workspace_open_workflow"}const Hp=ls.lazy(()=>Wr(()=>import("./RecentFilesDrawer-B74sdP_1.js"),__vite__mapDeps([3,1,4,2,5,6]))),Jp=ls.lazy(()=>Wr(()=>import("./GalleryModal-GhVpJqWk.js"),__vite__mapDeps([7,1,6,4,2,5]))),Gp=ls.lazy(()=>Wr(()=>import("./ModelManagerTopbar-rP-1MCD8.js").then(t=>t.M),__vite__mapDeps([8,1,4,2,9]))),Yp=["download_progress","download_error","model_list"];function Xp(){const[t,e]=b.useState(null),[n,r]=b.useState("root"),[o,s]=b.useState(!0),[a,i]=b.useState(null),l=b.useRef(null),[c,u]=b.useState(),[d,f]=b.useState(!1),p=b.useRef(null),{showDialog:y}=xa(),[h,v]=b.useState(!1);b.useRef(!1);const w=b.useRef(0),g=_a(),x=b.useRef("hide"),[E,S]=b.useState(null),C=b.useCallback(async()=>{if(l.current){const _=JSON.stringify(ge.graph.serialize());await Promise.all([O==null?void 0:O.updateFlow(l.current,{json:_}),Ae==null?void 0:Ae.create({workflowID:l.current,json:_})]),P!=null&&P.autoSave&&g({title:"Saved",status:"success",duration:1e3,isClosable:!0})}},[]),k=async()=>{l.current&&confirm("Are you sure you want to delete this workflow?")&&(await(O==null?void 0:O.delete(l.current)),j(null))},D=async()=>{var N,M,L;if(confirm("Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.")){const X=(N=O==null?void 0:O.curWorkflow)==null?void 0:N.id;if(X==null)return;let G;P!=null&&P.autoSave?G=(M=await(Ae==null?void 0:Ae.getLastestByWorkflowID(X)))==null?void 0:M.json:G=(L=await(O==null?void 0:O.get(X)))==null?void 0:L.json,G?await ge.loadGraphData(JSON.parse(G)):alert("Error: No last saved version found")}},j=_=>{const N=(_==null?void 0:_.id)??null;if(O==null||O.updateCurWorkflow(_),l.current=N,i(N),e((_==null?void 0:_.name)??""),N==null){document.title="ComfyUI",window.location.hash="",localStorage.removeItem("curFlowID");return}if(ha()){const M=Zi(N);window.location.hash=M,document.title=name+" - ComfyUI"}else localStorage.setItem("curFlowID",N),document.title="ComfyUI - "+name},A=async()=>{F(),localStorage.removeItem("workspace"),localStorage.removeItem("comfyspace");try{await rp(),await(P==null?void 0:P.getSetting("topBarStyle").then(N=>{be(N,!1)}))}catch(N){console.error("error loading db",N)}s(!1);let _=null;_=ha(),_==null&&(_=localStorage.getItem("curFlowID")),_&&K(_),localStorage.getItem("REWRITTEN_ALL_LOCAL_DISK_FILE")==="true"||(await Yf(),localStorage.setItem("REWRITTEN_ALL_LOCAL_DISK_FILE","true"))},F=()=>{Yp.forEach(_=>{Rs.addEventListener(_,()=>null)})},q=async()=>{if(l.current!=null){const _=O==null?void 0:O.curWorkflow;return!!_&&$(_)}return!1},$=_=>{if(_.json==null)return!0;const N=ge.graph.serialize()??{};let M={};try{M=_!=null&&_.json?JSON.parse(_==null?void 0:_.json):{}}catch(X){console.error("error parsing json",X)}return!(JSON.stringify(N)===JSON.stringify(M))},K=async _=>{if(ge.graph==null){console.error("app.graph is null cannot load workflow");return}const N=await(O==null?void 0:O.get(_));if(N==null){alert("Error: Workflow not found! id: "+_),j(null);return}j(N),ge.ui.dialog.close(),ge.loadGraphData(JSON.parse(N.json)),r("root")},le=_=>{S(_)},z=async(_,N=!1)=>{if(_===null){j(null),ge.graph.clear();return}if((await(P==null?void 0:P.getSetting("autoSave"))??!0)||!d||N){K(_);return}I(_)},I=async _=>{var M,L;const N=[_?{label:"Open in new tab",icon:m.jsx(vp,{}),onClick:()=>{Gf(_)}}:null,{label:"Save",colorScheme:"teal",onClick:async()=>{await C(),_&&K(_)}}];((M=O==null?void 0:O.curWorkflow)==null?void 0:M.lastSavedJson)!=null?N.push({label:"Discard",colorScheme:"red",onClick:async()=>{await D(),_&&K(_)}}):N.push({label:"Delete",colorScheme:"red",onClick:async()=>{await k(),_&&K(_)}}),y(`Please save or discard your changes to "${(L=O==null?void 0:O.curWorkflow)==null?void 0:L.name}" before leaving, or your changes will be lost.`,N)},Z=async _=>{const N=(_==null?void 0:_.json)??JSON.stringify(hr),M=await(O==null?void 0:O.createFlow({json:N,name:_==null?void 0:_.name}));M&&await z(M.id),r("root")},oe=async(_,N=!1)=>{const M=_.split("/").pop()??_;N?C():Z({name:M});const L=await fetch(Jf(_)),X=await L.blob(),G=new File([X],M,{type:L.headers.get("Content-Type")||""});await ge.handleFile(G),r("root")},he=async(_,N)=>{const M=await(O==null?void 0:O.get(_));if(M==null)return;const L=await(O==null?void 0:O.createFlow({json:M.json,lastSavedJson:M.lastSavedJson,name:N||M.name,parentFolderID:M.parentFolderID,tags:M.tags}));L&&await z(L.id)},be=b.useCallback((_,N=!1)=>{const{top:M=0,left:L=0}=c||{};let{top:X=0,left:G=0}=_??{};X+=M,G+=L;const ae=document.documentElement.clientWidth,V=document.documentElement.clientHeight,W=document.getElementById("workspaceManagerPanel"),ee=(W==null?void 0:W.offsetWidth)||392;X+36>V&&(X=V-36),G+ee>=ae&&(G=ae-ee),u({top:Math.max(0,X),left:Math.max(0,G)}),N&&(P==null||P.upsert({topBarStyle:{top:X,left:G}}))},[c]),Ee=async _=>{await Vf(_)&&C()},ce=b.useCallback(_=>{if(l.current==null)return;let N=_.filename;_.subfolder!=null&&_.subfolder!==""&&(N=_.subfolder+"/"+N),Ut==null||Ut.create({workflowID:l.current,localPath:N})},[]),se=b.useCallback(()=>{r("root")},[]);return b.useEffect(()=>{A(),v(!0),w.current=setInterval(async()=>{const G=P==null?void 0:P.autoSave,ae=await q();if(f(!!ae),!!ae&&l.current!=null&&G){const V=await(O==null?void 0:O.latestVersionCheck());if(x.current!=="disabled"&&!V)x.current="show",y(`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:()=>{x.current="disabled"}},{label:"Disable Auto-Save",colorScheme:"teal",onClick:()=>{P==null||P.upsert({autoSave:!1})}}],!0);else{const W=JSON.stringify(ge.graph.serialize());W!=null&&await(O==null?void 0:O.updateFlow(l.current,{json:W}))}}},1e3),window.addEventListener("keydown",Ee);const _=document.getElementById("comfy-file-input"),N=async()=>{if(_&&_.files&&_.files.length>0){const G={id:Pn(),name:_.files[0].name,json:JSON.stringify(hr),updateTime:Date.now(),createTime:Date.now()};j(G),await(O==null?void 0:O.createFlow(G))}};_==null||_.addEventListener("change",N);const M=G=>{const ae=(P==null?void 0:P.autoSave)??!0,V=!!(O!=null&&O.curWorkflow)&&$(O==null?void 0:O.curWorkflow);!ae&&V&&(G.preventDefault(),G.returnValue="You have unsaved changes!",I())};window.addEventListener("beforeunload",M);const L=G=>{var ae,V,W,ee,T,te;(W=(V=(ae=G.detail)==null?void 0:ae.output)==null?void 0:V.images)==null||W.forEach(ne=>{ne.type==="output"&&ce(ne)}),(te=(T=(ee=G.detail)==null?void 0:ee.output)==null?void 0:T.gifs)==null||te.forEach(ne=>{ne.type==="output"&&ce(ne)})};Rs.addEventListener("executed",L);const X=async G=>{var ee,T;const ae=(T=(ee=G.dataTransfer)==null?void 0:ee.files[0])==null?void 0:T.name,V=ge.dragOverNode;if(V&&V.onDragDrop)return;if(!(await(P==null?void 0:P.getSetting("overwriteCurWorkflowWhenDroppingFileToCanvas"))??!1)&&ae){const te={id:Pn(),name:ae,json:JSON.stringify(hr),updateTime:Date.now(),createTime:Date.now()};j(te),await(O==null?void 0:O.createFlow(te))}};return ge.canvasEl.addEventListener("drop",X),()=>{window.removeEventListener("keydown",Ee),window.removeEventListener("change",N),window.removeEventListener("beforeunload",M),window.removeEventListener("executed",L),ge.canvasEl.removeEventListener("drop",X),clearInterval(w.current)}},[]),o||!c?null:m.jsx(Pt.Provider,{value:{curFlowID:a,onDuplicateWorkflow:he,loadWorkflowID:z,discardUnsavedChanges:D,saveCurWorkflow:C,isDirty:d,loadNewWorkflow:Z,loadFilePath:oe,setRoute:r,jsonDiff:E,compareJson:le},children:m.jsx("div",{ref:p,className:"workspace_manager",children:m.jsxs(ba,{containerRef:p,children:[m.jsxs(ht,{style:{position:"absolute",top:0,right:0,left:0},zIndex:Kf,draggable:!1,children:[m.jsx(zp,{curFlowName:t,setCurFlowName:e,updatePanelPosition:be,positionStyle:c}),h&&m.jsx(b.Suspense,{children:m.jsx(Gp,{})}),h&&n==="recentFlows"&&m.jsx(b.Suspense,{children:m.jsx(Hp,{onClose:se,onClickNewFlow:()=>{Z(),r("root")}})}),n==="gallery"&&m.jsx(Jp,{onclose:()=>r("root")})]}),m.jsx(qp,{})]})})})}const kh=Object.freeze(Object.defineProperty({__proto__:null,default:Xp},Symbol.toStringTag,{value:"Module"}));export{ni as $,wt as A,ht as B,yp as C,Pp as D,Ip as E,rr as F,pp as G,Ct as H,on as I,uh as J,gp as K,Te as L,ti as M,Br as N,Kr as O,$r as P,Ep as Q,gh as R,nd as S,mi as T,hr as U,fh as V,pr as W,np as X,ch as Y,zl as Z,ri as _,nh as a,li as a0,oi as a1,ai as a2,si as a3,Pt as a4,Gf as a5,vp as a6,_t as a7,Rl as a8,Kf as a9,xh as aA,$p as aB,Kp as aC,Ml as aD,kh as aE,ah as aa,Xi as ab,ph as ac,hh as ad,mp as ae,Ma as af,Ut as ag,Ta as ah,fc as ai,Cl as aj,H as ak,yh as al,vh as am,lh as an,uc as ao,ep as ap,mh as aq,ih as ar,sp as as,wp as at,ql as au,dn as av,hp as aw,bh as ax,me as ay,wh as az,dc as b,sh as c,rh as d,oh as e,fn as f,qr as g,Oe as h,Sp as i,xn as j,Tt as k,Bn as l,P as m,pa as n,dh as o,_a as p,mo as q,Wt as r,Uf as s,mr as t,zr as u,$d as v,O as w,qf as x,bs as y,xs as z}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["workspace_web/ShareDialog-17qMdssr.js","workspace_web/input.js","workspace_web/index-pz0vT7Or.js","workspace_web/RecentFilesDrawer-B74sdP_1.js","workspace_web/chunk-JARCRF6W-IwBcFM3i.js","workspace_web/chunk-NTCQBYKE-ZsMy4OBB.js","workspace_web/MediaPreview-EfKQfEU-.js","workspace_web/GalleryModal-GhVpJqWk.js","workspace_web/ModelManagerTopbar-rP-1MCD8.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-yOnENaqH.js b/dist/workspace_web/GalleryModal-GhVpJqWk.js similarity index 75% rename from dist/workspace_web/GalleryModal-yOnENaqH.js rename to dist/workspace_web/GalleryModal-GhVpJqWk.js index 41e84ed..93c6dab 100644 --- a/dist/workspace_web/GalleryModal-yOnENaqH.js +++ b/dist/workspace_web/GalleryModal-GhVpJqWk.js @@ -1 +1 @@ -import{f as se,l as te,o as ne,j as t,g as oe,h as le,r as x,K as ie,F as re,B as N,U as ce,M as ae,L as he,N as ue,O as xe,Q as de,R as ge}from"./input.js";import{Y as fe,h as F,F as j,ac as je,I as w,B as J,ad as L,k as Y,T as M,q as C,ae as _,A as Z,m as q,a3 as Q,j as we,H as S,i as ve,af as X,w as E,ag as ye,C as pe}from"./App-Fl7cObcs.js";import{I as be,i as Ie,a as Ce,b as ke,g as Pe,S as Me,M as ze}from"./MediaPreview-Z5nSvSr_.js";import{I as Oe,C as V}from"./chunk-JARCRF6W-aHchqwnR.js";import{V as D}from"./chunk-NTCQBYKE-EEXlKSMU.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 Te=["h","minH","height","minHeight"],B=se((s,e)=>{const n=te("Textarea",s),{className:l,rows:o,...i}=ne(s),r=fe(i),d=o?Se(n,Te):n;return t.jsx(oe.textarea,{ref:e,rows:o,...r,className:le("chakra-textarea",l),__css:d})});B.displayName="Textarea";var Fe=F("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=F("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),Ee=F("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=F("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]=x.useState(0);x.useEffect(()=>{n!==void 0&&o(n)},[n]);const i=c=>{const h=(l+c+e.length)%e.length;o(h),s&&s(e[h])},r={width:"100%",height:"100%"},d={enter:c=>({x:c>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:c=>({x:c<0?500:-500,opacity:1})};return t.jsxs(j,{justifyContent:"center",alignItems:"center",position:"relative",width:r.width,height:r.height,overflow:"hidden",children:[t.jsx(ie,{custom:l,children:e.map((c,h)=>t.jsx(re.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(c.imageUrl)},children:je(c.imageUrl)?t.jsx(Oe,{src:c.imageUrl,alt:`image-${c.id}`,width:"100%",height:"100%",objectFit:"contain"}):t.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:c.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:t.jsx("track",{kind:"captions"})})},c.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),r=JSON.parse(i==null?void 0:i.prompt),d=JSON.parse(i==null?void 0:i.workflow);return{prompt:r,workflow:d}})}const O=s=>{if(typeof s=="string")return s};function T(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,u,A,K,G,$,U,H,R,m;const n=O((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)??O((b=(p=s==null?void 0:s[((v=Object.keys(s))==null?void 0:v.find(z=>{var I,P;return(P=(I=s[z])==null?void 0:I.inputs)==null?void 0:P.ckpt_name}))??""])==null?void 0:p.inputs)==null?void 0:b.ckpt_name)??"",l=O((A=(u=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:u.inputs)==null?void 0:A.text),o=O((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((z,I)=>{var P,W;return(P=e==null?void 0:e.inputs)!=null&&P[I]?{...z,[I]:(W=e==null?void 0:e.inputs)==null?void 0:W[I]}:z},{}),r=(m=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:m.inputs,d=r==null?void 0:r.width,c=r==null?void 0:r.height;return{ckptName:n,positive:l,negative:o,...i,width:d,height:c}}const Ke=s=>{var o;const{prompt:e,workflow:n}=s,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:()=>T(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:()=>T((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(Y,{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,r;return((r=(i=s==null?void 0:s.prompt)==null?void 0:i[o])==null?void 0:r.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,r)=>{const d=e==null?void 0:e[i],c=ee(e,d),h=Object.keys(c).reduce((g,f)=>({...g,[`${f}_${r+1}`]:c==null?void 0:c[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:()=>T(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:()=>T((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(Y,{readOnly:!0,value:e==null?void 0:e[l]})]},`meta${l}`)})]})},Re=({media:s})=>{const[e,n]=x.useState(),l=async o=>{try{const i=await Ae(`/workspace/view_media?filename=${o.localPath}`);n(i)}catch(i){console.error(i)}};return x.useEffect(()=>{s&&l(s)},[s]),t.jsxs(j,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[t.jsxs(Me,{alignItems:"center",columns:2,spacing:2,children:[t.jsxs(j,{alignItems:"center",gap:1,children:[t.jsx(M,{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(Z,{size:19}),"aria-label":"donwload image from gallery"})})})]}),t.jsxs(j,{gap:1,alignItems:"center",children:[t.jsx(M,{children:"Create Time:"}),t.jsx(M,{children:q((s==null?void 0:s.createTime)??0,!0)})]})]}),(()=>{if(!s||!e)return null;const o={metaData:e,media:s};return $e(e)&&t.jsx(He,{...o})||t.jsx(Ge,{...o})})()]})},me=({mediaList:s,media:e})=>{const[n,l]=x.useState();return x.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})]})},We=({media:s,isSelecting:e,selectedID:n,onClickMedia:l,onRefreshImagesList:o,coverPath:i,setCoverPath:r})=>{const{curFlowID:c,loadFilePath:h}=x.useContext(Q),{showDialog:g}=ce();if(s.localPath==null)return null;const f=i!=null&&i===s.localPath;if(c==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(ze,{mediaLocalPath:s.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!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(M,{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.updateMetaInfo(c,{coverMediaPath:s.localPath}),r(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(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=E)==null?void 0:b.updateMetaInfo(c,{coverMediaPath:void 0})),r("")),o())}})})]})]})},Je=We;function es({onclose:s}){const{curFlowID:e}=x.useContext(Q),[n,l]=x.useState(""),[o,i]=x.useState([]),[r,d]=x.useState(!1),[c,h]=x.useState(""),[g,f]=x.useState([]),[y,v]=x.useState(),p=async()=>{var u;if(e==null)return;const a=await((u=X)==null?void 0:u.listByWorkflowID(e));f(a??[])};if(x.useEffect(()=>{var a;p(),e&&((a=E)==null||a.get(e).then(u=>{u&&(l(u.name),u!=null&&u.coverMediaPath&&h(u==null?void 0:u.coverMediaPath))}))},[]),e==null)return null;const b=a=>{if(r){o.includes(a.id)?i(o.filter(u=>u!==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(ue,{width:"90%",maxWidth:"90vw",height:"90vh",children:[t.jsxs(xe,{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(Fe,{})}),"Gallery - ",n]})}),r&&t.jsxs(S,{gap:3,children:[t.jsx(V,{isChecked:k,onChange:()=>{i(k?[]:g.map(a=>a.id))},children:"All"}),t.jsxs(M,{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(me,{mediaList:g,media:y}):t.jsx(S,{wrap:"wrap",children:g.map(a=>t.jsx(Je,{selectedID:o,media:a,isSelecting:r,onClickMedia:b,onRefreshImagesList:p,coverPath:c,setCoverPath:h},a.id))})})]})]})}export{es as default}; +import{f as se,l as te,o as ne,j as t,g as oe,h as le,r as x,K as ie,F as re,B as N,U as ce,M as ae,L as he,N as ue,O as xe,Q as de,R as ge}from"./input.js";import{Z as fe,h as F,F as j,ad as je,I as w,B as J,ae as Z,l as L,k as M,r as C,af as T,C as Y,n as Q,a4 as X,j as we,H as S,i as ve,ag as q,w as _,ah as ye,E as pe}from"./App-GluzE5n7.js";import{I as be,i as Ie,a as Ce,b as ke,g as Pe,S as Me,M as ze}from"./MediaPreview-EfKQfEU-.js";import{I as Oe,C as V}from"./chunk-JARCRF6W-IwBcFM3i.js";import{V as D}from"./chunk-NTCQBYKE-ZsMy4OBB.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 Ee=["h","minH","height","minHeight"],B=se((s,e)=>{const n=te("Textarea",s),{className:l,rows:o,...i}=ne(s),r=fe(i),d=o?Se(n,Ee):n;return t.jsx(oe.textarea,{ref:e,rows:o,...r,className:le("chakra-textarea",l),__css:d})});B.displayName="Textarea";var Fe=F("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"}]]),Te=F("chevron-left","IconChevronLeft",[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]]),_e=F("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=F("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]=x.useState(0);x.useEffect(()=>{n!==void 0&&o(n)},[n]);const i=c=>{const h=(l+c+e.length)%e.length;o(h),s&&s(e[h])},r={width:"100%",height:"100%"},d={enter:c=>({x:c>0?500:-500,opacity:1}),center:{x:0,opacity:1},exit:c=>({x:c<0?500:-500,opacity:1})};return t.jsxs(j,{justifyContent:"center",alignItems:"center",position:"relative",width:r.width,height:r.height,overflow:"hidden",children:[t.jsx(ie,{custom:l,children:e.map((c,h)=>t.jsx(re.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(c.imageUrl)},children:je(c.imageUrl)?t.jsx(Oe,{src:c.imageUrl,alt:`image-${c.id}`,width:"100%",height:"100%",objectFit:"contain"}):t.jsx("video",{style:{objectFit:"contain"},width:"100%",height:"100%",src:c.imageUrl,loop:!0,autoPlay:!0,muted:!0,children:t.jsx("track",{kind:"captions"})})},c.id))}),t.jsx(w,{size:"sm",color:"white",bgColor:"whiteAlpha.400","aria-label":"Previous image",icon:t.jsx(Te,{}),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),r=JSON.parse(i==null?void 0:i.prompt),d=JSON.parse(i==null?void 0:i.workflow);return{prompt:r,workflow:d}})}const O=s=>{if(typeof s=="string")return s};function E(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,u,A,K,G,$,U,H,R,W;const n=O((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)??O((b=(p=s==null?void 0:s[((v=Object.keys(s))==null?void 0:v.find(z=>{var I,P;return(P=(I=s[z])==null?void 0:I.inputs)==null?void 0:P.ckpt_name}))??""])==null?void 0:p.inputs)==null?void 0:b.ckpt_name)??"",l=O((A=(u=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:u.inputs)==null?void 0:A.text),o=O((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((z,I)=>{var P,m;return(P=e==null?void 0:e.inputs)!=null&&P[I]?{...z,[I]:(m=e==null?void 0:e.inputs)==null?void 0:m[I]}:z},{}),r=(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=r==null?void 0:r.width,c=r==null?void 0:r.height;return{ckptName:n,positive:l,negative:o,...i,width:d,height:c}}const Ke=s=>{var o;const{prompt:e,workflow:n}=s,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:()=>E(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:()=>E((e==null?void 0:e[n])??""),"aria-label":"copy text",icon:t.jsx(Z,{}),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,r;return((r=(i=s==null?void 0:s.prompt)==null?void 0:i[o])==null?void 0:r.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,r)=>{const d=e==null?void 0:e[i],c=ee(e,d),h=Object.keys(c).reduce((g,f)=>({...g,[`${f}_${r+1}`]:c==null?void 0:c[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:()=>E(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:()=>E((e==null?void 0:e[l])??""),"aria-label":"copy text",icon:t.jsx(Z,{}),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}`)})]})},Re=({media:s})=>{const[e,n]=x.useState(),l=async o=>{try{const i=await Ae(`/workspace/view_media?filename=${o.localPath}`);n(i)}catch(i){console.error(i)}};return x.useEffect(()=>{s&&l(s)},[s]),t.jsxs(j,{overflowY:"auto",mb:4,direction:"column",gap:2,flex:1,children:[t.jsxs(Me,{alignItems:"center",columns:2,spacing:2,children:[t.jsxs(j,{alignItems:"center",gap:1,children:[t.jsx(M,{children:s==null?void 0:s.localPath}),t.jsx(C,{label:"Donwload image from gallery",children:t.jsx(T,{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(M,{children:"Create Time:"}),t.jsx(M,{children:Q((s==null?void 0:s.createTime)??0,!0)})]})]}),(()=>{if(!s||!e)return null;const o={metaData:e,media:s};return $e(e)&&t.jsx(He,{...o})||t.jsx(Ge,{...o})})()]})},We=({mediaList:s,media:e})=>{const[n,l]=x.useState();return x.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:r})=>{const{curFlowID:c,loadFilePath:h}=x.useContext(X),{showDialog:g}=ce();if(s.localPath==null)return null;const f=i!=null&&i===s.localPath;if(c==null)return null;const y=t.jsxs(T,{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(ze,{mediaLocalPath:s.localPath,size:180,onBrokenLink:()=>{},autoPlay:!0,isPreview:!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(M,{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(_e,{size:19}):t.jsx(Ne,{size:19}),"aria-label":"set as cover",onClick:()=>{var v;(v=_)==null||v.updateMetaInfo(c,{coverMediaPath:s.localPath}),r(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(T,{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 p,b;confirm("Are you sure to remove this image from gallery? (won't delete image on your disk)")&&(await((p=q)==null?void 0:p.delete(s.id)),f&&(await((b=_)==null?void 0:b.updateMetaInfo(c,{coverMediaPath:void 0})),r("")),o())}})})]})]})},Je=me;function es({onclose:s}){const{curFlowID:e}=x.useContext(X),[n,l]=x.useState(""),[o,i]=x.useState([]),[r,d]=x.useState(!1),[c,h]=x.useState(""),[g,f]=x.useState([]),[y,v]=x.useState(),p=async()=>{var u;if(e==null)return;const a=await((u=q)==null?void 0:u.listByWorkflowID(e));f(a??[])};if(x.useEffect(()=>{var a;p(),e&&((a=_)==null||a.get(e).then(u=>{u&&(l(u.name),u!=null&&u.coverMediaPath&&h(u==null?void 0:u.coverMediaPath))}))},[]),e==null)return null;const b=a=>{if(r){o.includes(a.id)?i(o.filter(u=>u!==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(ue,{width:"90%",maxWidth:"90vw",height:"90vh",children:[t.jsxs(xe,{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(Fe,{})}),"Gallery - ",n]})}),r&&t.jsxs(S,{gap:3,children:[t.jsx(V,{isChecked:k,onChange:()=>{i(k?[]:g.map(a=>a.id))},children:"All"}),t.jsxs(M,{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(We,{mediaList:g,media:y}):t.jsx(S,{wrap:"wrap",children:g.map(a=>t.jsx(Je,{selectedID:o,media:a,isSelecting:r,onClickMedia:b,onRefreshImagesList:p,coverPath:c,setCoverPath:h},a.id))})})]})]})}export{es as default}; diff --git a/dist/workspace_web/InstallMissingModelsButton-L5lG4CMZ.js b/dist/workspace_web/InstallMissingModelsButton-KOf9hKlm.js similarity index 61% rename from dist/workspace_web/InstallMissingModelsButton-L5lG4CMZ.js rename to dist/workspace_web/InstallMissingModelsButton-KOf9hKlm.js index e871907..bf26ac8 100644 --- a/dist/workspace_web/InstallMissingModelsButton-L5lG4CMZ.js +++ b/dist/workspace_web/InstallMissingModelsButton-KOf9hKlm.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-K_yJKYUe.js";import{T as h,H as v,a5 as g,B as w,a7 as M,a8 as y,aC as E,F as I,ag as S}from"./App-Fl7cObcs.js";import{V as b}from"./chunk-NTCQBYKE-EEXlKSMU.js";import{I as C,G as k}from"./chunk-JARCRF6W-aHchqwnR.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(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(C,{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(k,{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}; +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-rP-1MCD8.js";import{k as d,H as v,a6 as g,B as w,a8 as M,a9 as y,aD as E,F as I,ah as S}from"./App-GluzE5n7.js";import{V as b}from"./chunk-NTCQBYKE-ZsMy4OBB.js";import{I as k,G as C}from"./chunk-JARCRF6W-IwBcFM3i.js";import"/scripts/api.js";import"./index-pz0vT7Or.js";function D({model:s}){const[l,t]=u.useState([]),o=z(s.received_value),h=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(()=>{h(),p()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(b,{align:"start",children:[e.jsx(d,{children:s.class_type}),e.jsxs(v,{ml:3,children:[e.jsxs(d,{children:[s.input_name,": "]}),e.jsx(d,{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 z(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(D,{model:o},o.received_value))})]})})})}function U({}){const[s,l]=u.useState(!1),[t,o]=u.useState([]);return u.useEffect(()=>{const h=c.queuePrompt;c.queuePrompt=async function(){try{await h.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{U as default}; diff --git a/dist/workspace_web/MediaPreview-Z5nSvSr_.js b/dist/workspace_web/MediaPreview-EfKQfEU-.js similarity index 95% rename from dist/workspace_web/MediaPreview-Z5nSvSr_.js rename to dist/workspace_web/MediaPreview-EfKQfEU-.js index ce8d027..682060b 100644 --- a/dist/workspace_web/MediaPreview-Z5nSvSr_.js +++ b/dist/workspace_web/MediaPreview-EfKQfEU-.js @@ -1 +1 @@ -import{G as U,I as C}from"./chunk-JARCRF6W-aHchqwnR.js";import{f as x,D as b,j as p,aa as v,r as h}from"./input.js";import{ah as y,h as S,ac as k}from"./App-Fl7cObcs.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}; +import{G as U,I as C}from"./chunk-JARCRF6W-IwBcFM3i.js";import{f as x,D as b,j as p,aa as v,r as h}from"./input.js";import{ai as y,h as S,ad as k}from"./App-GluzE5n7.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-K_yJKYUe.js b/dist/workspace_web/ModelManagerTopbar-K_yJKYUe.js deleted file mode 100644 index 15d52fd..0000000 --- a/dist/workspace_web/ModelManagerTopbar-K_yJKYUe.js +++ /dev/null @@ -1,7 +0,0 @@ -import{f as P,r as d,j as e,g as T,h as V,a3 as z,b as Ee,o as re,i as le,k as Pe,ab as Le,B as _,a8 as $,ac as Ae,L as ce,ad as De,O as de,R as ue,S as Ne,Y as Be,M as Fe,N as Re,Q as ze,P as Oe,_ as We}from"./input.js";import{ai as Ge,ah as Ke,Y as He,aj as F,l as k,F as L,T as I,B as he,ak as pe,al as se,a7 as me,j as O,q as ne,A as Ve,H as E,k as W,am as fe,o as ge,an as xe,Z as $e,_ as Ye,$ as Ue,a0 as qe,a1 as Qe,ao as K,ag as je,ap as Xe,aq as Ze,a8 as Je,ar as et,as as tt}from"./App-Fl7cObcs.js";import{I as ve,G as st,C as nt}from"./chunk-JARCRF6W-aHchqwnR.js";import{app as N}from"/scripts/app.js";import{api as R}from"/scripts/api.js";var ye=P(function(s,n){const{spacing:o="0.5rem",spacingX:i,spacingY:a,children:r,justify:l,direction:c,align:u,className:p,shouldWrapChildren:g,...h}=s,m=d.useMemo(()=>g?d.Children.map(r,(f,v)=>e.jsx(Y,{children:f},v)):r,[r,g]);return e.jsx(T.div,{ref:n,className:V("chakra-wrap",p),...h,children:e.jsx(T.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:u,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:a,padding:"0"},children:m})})});ye.displayName="Wrap";var Y=P(function(s,n){const{className:o,...i}=s;return e.jsx(T.li,{ref:n,__css:{display:"flex",alignItems:"flex-start"},className:V("chakra-wrap__listitem",o),...i})});Y.displayName="WrapItem";function oe(t){return Ke(t,s=>s==="auto"?"auto":`span ${s}/span ${s}`)}var we=P(function(s,n){const{area:o,colSpan:i,colStart:a,colEnd:r,rowEnd:l,rowSpan:c,rowStart:u,...p}=s,g=Ge({gridArea:o,gridColumn:oe(i),gridRow:oe(c),gridColumnStart:a,gridColumnEnd:r,gridRowStart:u,gridRowEnd:l});return e.jsx(T.div,{ref:n,__css:g,...p})});we.displayName="GridItem";function ot(t,s,n){return(t-s)*100/(n-s)}z({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});z({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var at=z({"0%":{left:"-40%"},"100%":{left:"100%"}}),it=z({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function rt(t){const{value:s=0,min:n,max:o,valueText:i,getValueText:a,isIndeterminate:r,role:l="progressbar"}=t,c=ot(s,n,o);return{bind:{"data-indeterminate":r?"":void 0,"aria-valuemax":o,"aria-valuemin":n,"aria-valuenow":r?void 0:s,"aria-valuetext":(()=>{if(s!=null)return typeof a=="function"?a(s,c):i})(),role:l},percent:c,value:s}}var[lt,ct]=Ee({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),dt=P((t,s)=>{const{min:n,max:o,value:i,isIndeterminate:a,role:r,...l}=t,c=rt({value:i,min:n,max:o,isIndeterminate:a,role:r}),p={height:"100%",...ct().filledTrack};return e.jsx(T.div,{ref:s,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:p})}),Se=P((t,s)=>{var n;const{value:o,min:i=0,max:a=100,hasStripe:r,isAnimated:l,children:c,borderRadius:u,isIndeterminate:p,"aria-label":g,"aria-labelledby":h,"aria-valuetext":m,title:f,role:v,...j}=re(t),y=le("Progress",t),M=u??((n=y.track)==null?void 0:n.borderRadius),w={animation:`${it} 1s linear infinite`},D={...!p&&r&&l&&w,...p&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${at} 1s ease infinite normal none running`}},B={overflow:"hidden",position:"relative",...y.track};return e.jsx(T.div,{ref:s,borderRadius:M,__css:B,...j,children:e.jsxs(lt,{value:y,children:[e.jsx(dt,{"aria-label":g,"aria-labelledby":h,"aria-valuetext":m,min:i,max:a,value:o,isIndeterminate:p,css:D,borderRadius:M,title:f,role:v}),c]})})});Se.displayName="Progress";var _e=P(function(s,n){const{children:o,placeholder:i,className:a,...r}=s;return e.jsxs(T.select,{...r,ref:n,className:V("chakra-select",a),children:[i&&e.jsx("option",{value:"",children:i}),o]})});_e.displayName="SelectField";function ut(t,s){const n={},o={};for(const[i,a]of Object.entries(t))s.includes(i)?n[i]=a:o[i]=a;return[n,o]}var G=P((t,s)=>{var n;const o=le("Select",t),{rootProps:i,placeholder:a,icon:r,color:l,height:c,h:u,minH:p,minHeight:g,iconColor:h,iconSize:m,...f}=re(t),[v,j]=ut(f,Le),y=He(j),M={width:"100%",height:"fit-content",position:"relative",color:l},w={paddingEnd:"2rem",...o.field,_focus:{zIndex:"unset",...(n=o.field)==null?void 0:n._focus}};return e.jsxs(T.div,{className:"chakra-select__wrapper",__css:M,...v,...i,children:[e.jsx(_e,{ref:s,height:u??c,minH:p??g,placeholder:a,...y,__css:w,children:t.children}),e.jsx(be,{"data-disabled":Pe(y.disabled),...(h||l)&&{color:h||l},__css:o.icon,...m&&{fontSize:m},children:r})]})});G.displayName="Select";var ht=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"})}),pt=T("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),be=t=>{const{children:s=e.jsx(ht,{}),...n}=t,o=d.cloneElement(s,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return e.jsx(pt,{...n,className:"chakra-select__icon-wrapper",children:d.isValidElement(s)?o:null})};be.displayName="SelectIcon";function mt({selectedModel:t,setSelectedModel:s,modelTypeList:n}){const o=i=>{s(i)};return e.jsx(ye,{children:n.map(i=>e.jsx(Y,{children:e.jsx(_,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const ft={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function gt({data:t}){const[s,n]=d.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=d.useState(!t.file_hash),[a,r]=d.useState();d.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var p,g,h,m;const u=await F.models.get(t.model_name+"@"+t.model_type);if(u!=null)r(u),(p=u.imageUrl)!=null&&p.length&&n(u.imageUrl);else if(t.file_hash!=null)try{const f=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,j=await(await fetch(f)).json();let y;if(await((g=k)==null?void 0:g.getSetting("showNsfwModelThumbnail"))===!0)y=(m=(h=j==null?void 0:j.images)==null?void 0:h[0])==null?void 0:m.url;else if(!j.model.nsfw){const w=j.images.find(A=>A.nsfw==="None");y=w==null?void 0:w.url}y&&n(y),F.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(j.modelId),civitModelVersionID:String(j.id),imageUrl:y??null})}catch{}t.preview&&n(t.preview)},c=u=>{const p=ft[t.model_type];p&&(u.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),u.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),u.dataTransfer.setData("nodeType",p))};return o?e.jsxs(L,{position:"relative",borderRadius:4,bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:[o&&e.jsx($,{}),e.jsx(I,{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(he,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[e.jsx(ve,{src:s,draggable:!1,boxSize:"100%",height:178,objectFit:"cover",borderRadius:4,cursor:(a==null?void 0:a.civitModelID)!=null?"pointer":"auto",onClick:()=>{(a==null?void 0:a.civitModelID)==null||(a==null?void 0:a.civitModelVersionID)==null||window.open(`https://civitai.com/models/${a==null?void 0:a.civitModelID}?modelVersionId=${a==null?void 0:a.civitModelVersionID}`)}}),e.jsx(I,{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 xt({list:t}){return e.jsx(st,{templateColumns:"repeat(3, 1fr)",gap:1,marginTop:2,children:t.map(s=>e.jsx(we,{children:e.jsx(gt,{data:s})},s.model_name))})}const jt=async t=>{try{const n=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:n}))}catch(s){console.error("Failed to connect to the server:",s)}};function ae(t,s=1){const i=t/1024;return i>=1024?(i/1024).toFixed(s)+" GB":i.toFixed(s)+" MB"}function ie(t,s){if(!t||t.length===0)return;let n=t.find(o=>o.nsfw==="None");return s&&(n=n??t[0]),n}function vt(t,s=280,n){var o,i,a,r;if(t)return pe(t)?(a=ie((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,n))==null?void 0:a.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(r=ie(t.images,n))==null?void 0:r.url}/width=${s}/`}const H=280;function yt({model:t,onClickInstallModel:s,installing:n}){var h,m;const[o,i]=d.useState();d.useEffect(()=>{f();async function f(){var j;const v=await((j=k)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(vt(t,H,v))}},[t]);const a=pe(t)?t.modelVersions:t.versions,[r,l]=d.useState(((h=a==null?void 0:a[0])==null?void 0:h.name)??""),c=a==null?void 0:a.find(f=>(f==null?void 0:f.name)===r),u=()=>{window.open(`https://civitai.com/models/${t.id}`)},p=d.useCallback(()=>{if(c==null){console.error("no file is find by name",r);return}s(se(c,t.name),t)},[r]),g=(m=se(c))==null?void 0:m.sizeKB;return e.jsxs(me,{width:H,justifyContent:"space-between",mb:2,gap:1,children:[e.jsx(ve,{borderRadius:3,boxSize:H+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>u()}),e.jsxs(O,{p:1,children:[e.jsx(ne,{label:t.name,children:e.jsx(I,{fontWeight:500,noOfLines:1,children:t.name})}),e.jsxs(L,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(_,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:e.jsx(I,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),e.jsx(_,{leftIcon:e.jsx(Ve,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>p(),isDisabled:!!(r&&n.includes(r)),children:"Install"})]}),e.jsxs(E,{children:[e.jsx(G,{size:"md",style:{paddingLeft:4},onChange:f=>{l(f.target.value)},children:a==null?void 0:a.map(f=>{const v=f==null?void 0:f.name;return v?e.jsx("option",{value:v,style:{padding:0},children:v},f.id):null})}),g&&e.jsx(ne,{label:ae(g),children:e.jsx(I,{flexShrink:1,noOfLines:1,width:"40%",children:ae(g)})})]})]})]})}function wt({searchQuery:t,setSearchQuery:s,onSearch:n}){return e.jsxs(L,{gap:1,alignItems:"center",grow:1,children:[e.jsx(W,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>s(o.target.value),onKeyUp:o=>{o.code==="Enter"&&n()}}),e.jsx(_,{size:"sm",onClick:()=>n(),colorScheme:"teal",children:"Search"})]})}function St({isOpen:t,fileSelected:s,onClose:n,selectFolder:o}){const[i,a]=d.useState(""),[r,l]=d.useState([]),[c,u]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{g()},[]);const g=async()=>{const h=await fe();h&&(["custom_nodes","config","saved_prompts"].forEach(m=>{delete h[m]}),l(Object.values(h).flatMap(m=>m)))};return e.jsx(Ae,{isOpen:t,leastDestructiveRef:p,onClose:n,children:e.jsx(ce,{children:e.jsxs(De,{children:[e.jsx(de,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),e.jsx(ue,{children:e.jsxs(O,{spacing:4,children:[!s&&e.jsxs(e.Fragment,{children:[e.jsx(I,{children:"Model download url"}),e.jsx(W,{placeholder:"https://civitai.com/api/download/models/311399",onChange:h=>u(h.target.value),value:c})]}),e.jsx(I,{children:"Choose model install folder"}),e.jsx(G,{placeholder:"Select option",value:i,onChange:h=>a(h.target.value),children:r.map(h=>e.jsx("option",{value:h,children:h},h))})]})}),e.jsxs(Ne,{children:[e.jsx(_,{ref:p,onClick:n,children:"Cancel"}),e.jsx(_,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function _t(){const{colorMode:t}=Be(),s=ge(),[n,o]=d.useState([]);return d.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(O,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,children:n.map(({save_path:i,progress:a})=>e.jsxs(E,{children:[e.jsx(I,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),e.jsx(Se,{isIndeterminate:!a,hasStripe:!0,width:"50%",value:a}),e.jsxs(I,{fontSize:16,width:"10%",children:[a.toFixed(1),"%"]})]},i))})}const Me="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function bt(){return localStorage.getItem(Me)}function Mt(t){localStorage.setItem(Me,t)}function Ct(){const[t,s]=d.useState(""),{onOpen:n,onClose:o,isOpen:i}=xe(),a=()=>{Mt(t),o()};return e.jsxs($e,{isOpen:i,onOpen:n,onClose:o,placement:"right",closeOnBlur:!1,children:[e.jsx(Ye,{children:e.jsx(_,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),e.jsxs(Ue,{p:5,children:[e.jsx(qe,{}),e.jsx(Qe,{}),e.jsxs(O,{spacing:4,children:[e.jsx(I,{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(W,{value:t,onChange:r=>s(r.target.value),placeholder:"API Key"}),e.jsx(_,{size:"sm",py:1,mr:8,onClick:a,children:"Save"})]})]})]})}const It=t=>typeof t=="function",Ce=t=>{const[s,n]=d.useState(t),o=d.useRef(s),i=d.useCallback(a=>{o.current=It(a)?a(o.current):a,n(o.current)},[]);return[s,i,o]};async function Tt(t,s){var r,l;const n={queries:[{q:t,indexUid:"models_v5",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return s&&(n.queries[0].filter=[[`"type"="${s}"`]]),((l=(r=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(n)})).json())==null?void 0:r.results)==null?void 0:l.at(0)).hits??[]}function kt({onclose:t,searchQuery:s="",modelType:n}){const[o,i]=d.useState([]),[a,r]=d.useState(!1),[l,c]=d.useState(n),u=ge(),[p,g]=d.useState([]),[h,m]=d.useState(s),{isOpen:f,onOpen:v,onClose:j}=xe(),[y,M,w]=Ce(),[A,U]=d.useState({}),[D,B]=d.useState(K),q=d.useCallback(async()=>{var S;r(!0);const x=await Tt(h,l);i(x);const C=await fe();C&&U(C);const b=await((S=k)==null?void 0:S.getSetting("defaultFolders"));b&&B(b),r(!1)},[h,l]),Q=(x,C)=>{var Z,J,ee,te;if(!((Z=w.current)!=null&&Z.id)&&!C){console.error("no url to download");return}let b=C??`https://civitai.com/api/download/models/${(J=w.current)==null?void 0:J.id}`,S=(ee=w.current)==null?void 0:ee.name;if(!S&&(S=b.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}u({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&g(ke=>[...ke,S??""]);const X=bt();X&&(b+=`?token=${X}`),jt({file_hash:(te=w.current)==null?void 0:te.SHA256,filename:S,save_path:x,url:b}),M(void 0),j()},Ie=async(x,C)=>{const b=D[C.type];M(x),b==null?v():Q(b)},Te=async(x,C)=>{var S;const b={...D,[x]:C};await((S=k)==null?void 0:S.upsert({defaultFolders:b})),B(b)};return d.useEffect(()=>{q()},[l]),e.jsxs(e.Fragment,{children:[e.jsxs(Fe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[e.jsx(ce,{}),e.jsxs(Re,{width:"90%",maxWidth:"90vw",height:"90vh",children:[e.jsxs(de,{children:[e.jsxs(E,{gap:2,mb:2,alignItems:"center",children:[e.jsx(je,{size:"md",mr:2,children:"Models"}),e.jsx(wt,{searchQuery:h,setSearchQuery:m,onSearch:q}),e.jsx(_,{size:"sm",py:1,mr:8,onClick:v,children:"Custom URL Install"}),e.jsx(Ct,{})]}),e.jsxs(E,{gap:2,mb:2,wrap:"wrap",children:[e.jsx(_,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),Xe.map(x=>e.jsx(_,{size:"sm",py:1,isActive:l===x,onClick:()=>{c(x)},children:x},x)),l&&A[K[l]]&&e.jsxs(E,{ml:"auto",children:[e.jsx(I,{whiteSpace:"nowrap",children:"Default Download Folder:"}),e.jsx(G,{value:D[l],onChange:x=>Te(l,x.target.value),children:A[K[l]].map(x=>e.jsx("option",{value:x,children:x}))})]})]}),a&&e.jsx($,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),e.jsx(ze,{}),e.jsxs(ue,{overflowY:"auto",children:[e.jsx(E,{wrap:"wrap",children:o==null?void 0:o.map(x=>e.jsx(yt,{model:x,onClickInstallModel:Ie,installing:p},x.id))}),e.jsx(_t,{})]})]})]}),e.jsx(St,{fileSelected:!!y,isOpen:f,onClose:j,selectFolder:(x,C)=>{Q(x,w.current?void 0:C)}})]})}function Et(){const[t,s]=d.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(_,{size:"sm",colorScheme:"teal",onClick:()=>s(!0),children:"Install Models"}),t&&e.jsx(kt,{modelType:"Checkpoint",onclose:()=>s(!1)})]})}const Pt=()=>{const[t,s]=d.useState(["checkpoints"]),[n,o]=d.useState([]),[i,a]=d.useState(!0);d.useEffect(()=>{r(),R.addEventListener("model_list",c=>{l(c.detail)})},[]);const r=async()=>{const c=await Ze();l(c)},l=async c=>{if(!c)return;a(!1);const u=Array.from(new Set(c.map(g=>g.model_type))),p=u.indexOf("checkpoints");p>=0&&u.splice(p,1),u.unshift("checkpoints"),s(u),o(c)};return{modelTypeList:t,modelsList:n,loading:i}};function Lt(){const[t,s,n]=Ce(!1),o=()=>{var l;(l=k)==null||l.getSetting("showNsfwModelThumbnail").then(c=>{s(c??!1)})};d.useEffect(()=>{o()},[]);const i=l=>{var u;const c=l.target.checked;(u=k)==null||u.upsert({showNsfwModelThumbnail:c}).then(()=>{o(),a(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},a=async()=>{const l=await F.models.toArray();for(let c=0;c{var c,u;try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${l.fileHash}`,h=await(await fetch(p)).json();let m;if(n.current)m=(u=(c=h==null?void 0:h.images)==null?void 0:c[0])==null?void 0:u.url;else if(!h.model.nsfw){const f=h.images.find(v=>v.nsfw==="None");m=f==null?void 0:f.url}F.models.update(l.id,{imageUrl:m??null})}catch{}};return e.jsx(nt,{isChecked:t,onChange:i,width:"100px",children:"Show NSFW"})}function At({onClose:t}){const[s,n]=d.useState("checkpoints"),[o,i]=d.useState(""),{loading:a,modelTypeList:r,modelsList:l}=Pt(),[c,u]=d.useState([]);d.useEffect(()=>{const h=l.filter(m=>o.length?m.model_name.toLowerCase().includes(o.toLowerCase()):m.model_type===s);u(h)},[s,l,o]),d.useEffect(()=>(N.canvasEl.addEventListener("click",t),()=>{N.canvasEl.removeEventListener("click",t)}),[]);const p=440,g=()=>e.jsxs(e.Fragment,{children:[e.jsxs(L,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:[e.jsx(W,{size:"sm",placeholder:"Search",value:o,onChange:h=>i(h.target.value)}),e.jsx(Lt,{})]}),!o.length&&e.jsx(mt,{modelTypeList:r,setSelectedModel:n,selectedModel:s}),e.jsx(xt,{list:c}),a&&e.jsx(L,{justifyContent:"center",alignItems:"center",height:"100%",children:e.jsx($,{})})]});return e.jsx(Oe,{children:e.jsx(he,{style:{width:p},children:e.jsxs(me,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:Je,overflowY:"auto",children:[e.jsxs(L,{justifyContent:"space-between",alignContent:"center",py:3,children:[e.jsx(je,{size:"md",mr:2,children:"Models"}),e.jsx(Et,{})]}),g()]})})})}const Dt=d.lazy(()=>We(()=>import("./InstallMissingModelsButton-L5lG4CMZ.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function Nt(){const[t,s]=d.useState(!1),[n,o]=d.useState(),i=async r=>{if(r.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const c=r.dataTransfer.getData("modelRelativePath"),u=r.dataTransfer.getData("nodeType"),p=LiteGraph.createNode(u);p.pos=[r.canvasX,r.canvasY],p.configure({widgets_values:[c]}),N.graph.add(p)};d.useEffect(()=>{var r;return(r=k)==null||r.getSetting("modelManagerTopBarStyle").then(l=>{a(l,!1)}),N.canvasEl.addEventListener("drop",i),()=>{N.canvasEl.removeEventListener("drop",i)}},[]);const a=(r,l=!1)=>{var M;const{top:c=0,right:u=0}=n||{},{top:p=0,right:g=0}=r??{};let h=c+p,m=n===void 0?g:u-g;const f=document.documentElement.clientWidth,v=document.documentElement.clientHeight,j=document.getElementById("modelManagerTopBar"),y=(j==null?void 0:j.offsetWidth)||224;h+32>v&&(h=v-38),m+y>f&&(m=f-y-4),o({top:Math.max(4,h),right:Math.max(4,m)}),l&&((M=k)==null||M.upsert({modelManagerTopBarStyle:{top:h,right:m}}))};return e.jsx(et,{onDragEnd:r=>{a({top:r.y,right:r.x},!0)},dragIconId:"dragModelManagerTopBarIcon",children:n?e.jsxs(E,{style:{position:"fixed",...n},gap:2,draggable:!1,id:"modelManagerTopBar",className:"model-manager-top-bar",children:[e.jsx(tt,{id:"dragModelManagerTopBarIcon",className:"drag-model-manager-top-bar-icon",cursor:"move",size:15,color:"#FFF"}),e.jsx(Dt,{}),e.jsx(_,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>s(!0),px:1,children:"Models"}),t&&e.jsx(At,{onClose:()=>s(!1)})]}):""})}const Wt=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"}));export{we as G,Et as I,Wt as M,Tt as g}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-L5lG4CMZ.js","workspace_web/input.js","workspace_web/App-Fl7cObcs.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-EEXlKSMU.js","workspace_web/chunk-JARCRF6W-aHchqwnR.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/ModelManagerTopbar-rP-1MCD8.js b/dist/workspace_web/ModelManagerTopbar-rP-1MCD8.js new file mode 100644 index 0000000..eeebe35 --- /dev/null +++ b/dist/workspace_web/ModelManagerTopbar-rP-1MCD8.js @@ -0,0 +1,7 @@ +import{f as P,r as d,j as e,g as T,h as V,a3 as z,b as Ee,o as re,i as le,k as Pe,ab as Le,B as _,a8 as $,ac as De,L as ce,ad as Ne,O as de,R as ue,S as Ae,Y as Be,M as Fe,N as Re,Q as ze,P as Oe,_ as We}from"./input.js";import{aj as Ge,ai as Ke,Z as He,ak as F,m as k,F as L,k as I,B as he,al as pe,am as se,a8 as me,j as O,r as ne,C as Ve,H as E,l as W,an as fe,p as ge,ao as xe,_ as $e,$ as Ye,a0 as Ue,a1 as qe,a2 as Qe,ap as K,ah as je,aq as Xe,ar as Ze,a9 as Je,as as et,at as tt}from"./App-GluzE5n7.js";import{I as ve,G as st,C as nt}from"./chunk-JARCRF6W-IwBcFM3i.js";import{app as A}from"/scripts/app.js";import{api as R}from"/scripts/api.js";var ye=P(function(s,n){const{spacing:o="0.5rem",spacingX:i,spacingY:a,children:r,justify:l,direction:c,align:u,className:p,shouldWrapChildren:g,...h}=s,m=d.useMemo(()=>g?d.Children.map(r,(f,v)=>e.jsx(Y,{children:f},v)):r,[r,g]);return e.jsx(T.div,{ref:n,className:V("chakra-wrap",p),...h,children:e.jsx(T.ul,{className:"chakra-wrap__list",__css:{display:"flex",flexWrap:"wrap",justifyContent:l,alignItems:u,flexDirection:c,listStyleType:"none",gap:o,columnGap:i,rowGap:a,padding:"0"},children:m})})});ye.displayName="Wrap";var Y=P(function(s,n){const{className:o,...i}=s;return e.jsx(T.li,{ref:n,__css:{display:"flex",alignItems:"flex-start"},className:V("chakra-wrap__listitem",o),...i})});Y.displayName="WrapItem";function oe(t){return Ke(t,s=>s==="auto"?"auto":`span ${s}/span ${s}`)}var we=P(function(s,n){const{area:o,colSpan:i,colStart:a,colEnd:r,rowEnd:l,rowSpan:c,rowStart:u,...p}=s,g=Ge({gridArea:o,gridColumn:oe(i),gridRow:oe(c),gridColumnStart:a,gridColumnEnd:r,gridRowStart:u,gridRowEnd:l});return e.jsx(T.div,{ref:n,__css:g,...p})});we.displayName="GridItem";function ot(t,s,n){return(t-s)*100/(n-s)}z({"0%":{strokeDasharray:"1, 400",strokeDashoffset:"0"},"50%":{strokeDasharray:"400, 400",strokeDashoffset:"-100"},"100%":{strokeDasharray:"400, 400",strokeDashoffset:"-260"}});z({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}});var at=z({"0%":{left:"-40%"},"100%":{left:"100%"}}),it=z({from:{backgroundPosition:"1rem 0"},to:{backgroundPosition:"0 0"}});function rt(t){const{value:s=0,min:n,max:o,valueText:i,getValueText:a,isIndeterminate:r,role:l="progressbar"}=t,c=ot(s,n,o);return{bind:{"data-indeterminate":r?"":void 0,"aria-valuemax":o,"aria-valuemin":n,"aria-valuenow":r?void 0:s,"aria-valuetext":(()=>{if(s!=null)return typeof a=="function"?a(s,c):i})(),role:l},percent:c,value:s}}var[lt,ct]=Ee({name:"ProgressStylesContext",errorMessage:`useProgressStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),dt=P((t,s)=>{const{min:n,max:o,value:i,isIndeterminate:a,role:r,...l}=t,c=rt({value:i,min:n,max:o,isIndeterminate:a,role:r}),p={height:"100%",...ct().filledTrack};return e.jsx(T.div,{ref:s,style:{width:`${c.percent}%`,...l.style},...c.bind,...l,__css:p})}),Se=P((t,s)=>{var n;const{value:o,min:i=0,max:a=100,hasStripe:r,isAnimated:l,children:c,borderRadius:u,isIndeterminate:p,"aria-label":g,"aria-labelledby":h,"aria-valuetext":m,title:f,role:v,...j}=re(t),y=le("Progress",t),M=u??((n=y.track)==null?void 0:n.borderRadius),w={animation:`${it} 1s linear infinite`},N={...!p&&r&&l&&w,...p&&{position:"absolute",willChange:"left",minWidth:"50%",animation:`${at} 1s ease infinite normal none running`}},B={overflow:"hidden",position:"relative",...y.track};return e.jsx(T.div,{ref:s,borderRadius:M,__css:B,...j,children:e.jsxs(lt,{value:y,children:[e.jsx(dt,{"aria-label":g,"aria-labelledby":h,"aria-valuetext":m,min:i,max:a,value:o,isIndeterminate:p,css:N,borderRadius:M,title:f,role:v}),c]})})});Se.displayName="Progress";var _e=P(function(s,n){const{children:o,placeholder:i,className:a,...r}=s;return e.jsxs(T.select,{...r,ref:n,className:V("chakra-select",a),children:[i&&e.jsx("option",{value:"",children:i}),o]})});_e.displayName="SelectField";function ut(t,s){const n={},o={};for(const[i,a]of Object.entries(t))s.includes(i)?n[i]=a:o[i]=a;return[n,o]}var G=P((t,s)=>{var n;const o=le("Select",t),{rootProps:i,placeholder:a,icon:r,color:l,height:c,h:u,minH:p,minHeight:g,iconColor:h,iconSize:m,...f}=re(t),[v,j]=ut(f,Le),y=He(j),M={width:"100%",height:"fit-content",position:"relative",color:l},w={paddingEnd:"2rem",...o.field,_focus:{zIndex:"unset",...(n=o.field)==null?void 0:n._focus}};return e.jsxs(T.div,{className:"chakra-select__wrapper",__css:M,...v,...i,children:[e.jsx(_e,{ref:s,height:u??c,minH:p??g,placeholder:a,...y,__css:w,children:t.children}),e.jsx(be,{"data-disabled":Pe(y.disabled),...(h||l)&&{color:h||l},__css:o.icon,...m&&{fontSize:m},children:r})]})});G.displayName="Select";var ht=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"})}),pt=T("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),be=t=>{const{children:s=e.jsx(ht,{}),...n}=t,o=d.cloneElement(s,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return e.jsx(pt,{...n,className:"chakra-select__icon-wrapper",children:d.isValidElement(s)?o:null})};be.displayName="SelectIcon";function mt({selectedModel:t,setSelectedModel:s,modelTypeList:n}){const o=i=>{s(i)};return e.jsx(ye,{children:n.map(i=>e.jsx(Y,{children:e.jsx(_,{colorScheme:"blue",variant:t===i?"solid":"outline",onClick:()=>o(i),size:"sm",children:i})},i))})}const ft={checkpoints:"CheckpointLoaderSimple",vae:"VAELoader",loras:"LoraLoader",controlnet:"ControlNetLoader",upscale_models:"UpscaleModelLoader"};function gt({data:t}){const[s,n]=d.useState("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/27fd7433-cb0a-4a87-88c1-21ccb2b1a842/width=450/00060-881622046.jpeg"),[o,i]=d.useState(!t.file_hash),[a,r]=d.useState();d.useEffect(()=>{i(!t.file_hash),l()},[t.file_hash]);const l=async()=>{var p,g,h,m;const u=await F.models.get(t.model_name+"@"+t.model_type);if(u!=null)r(u),(p=u.imageUrl)!=null&&p.length&&n(u.imageUrl);else if(t.file_hash!=null)try{const f=`https://civitai.com/api/v1/model-versions/by-hash/${t.file_hash}`,j=await(await fetch(f)).json();let y;if(await((g=k)==null?void 0:g.getSetting("showNsfwModelThumbnail"))===!0)y=(m=(h=j==null?void 0:j.images)==null?void 0:h[0])==null?void 0:m.url;else if(!j.model.nsfw){const w=j.images.find(D=>D.nsfw==="None");y=w==null?void 0:w.url}y&&n(y),F.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(j.modelId),civitModelVersionID:String(j.id),imageUrl:y??null})}catch{}t.preview&&n(t.preview)},c=u=>{const p=ft[t.model_type];p&&(u.dataTransfer.setData("eventName","WorkspaceManagerAddNode"),u.dataTransfer.setData("modelRelativePath",t.model_name+t.model_extension),u.dataTransfer.setData("nodeType",p))};return o?e.jsxs(L,{position:"relative",borderRadius:4,bg:"rgba(0, 0, 0, 0.5)",height:178,justifyContent:"center",alignItems:"center",children:[o&&e.jsx($,{}),e.jsx(I,{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(he,{position:"relative",borderRadius:4,draggable:!0,onDragStart:c,children:[e.jsx(ve,{src:s,draggable:!1,boxSize:"100%",height:178,objectFit:"cover",borderRadius:4,cursor:(a==null?void 0:a.civitModelID)!=null?"pointer":"auto",onClick:()=>{(a==null?void 0:a.civitModelID)==null||(a==null?void 0:a.civitModelVersionID)==null||window.open(`https://civitai.com/models/${a==null?void 0:a.civitModelID}?modelVersionId=${a==null?void 0:a.civitModelVersionID}`)}}),e.jsx(I,{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 xt({list:t}){return e.jsx(st,{templateColumns:"repeat(3, 1fr)",gap:1,marginTop:2,children:t.map(s=>e.jsx(we,{children:e.jsx(gt,{data:s})},s.model_name))})}const jt=async t=>{try{const n=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:n}))}catch(s){console.error("Failed to connect to the server:",s)}};function ae(t,s=1){const i=t/1024;return i>=1024?(i/1024).toFixed(s)+" GB":i.toFixed(s)+" MB"}function ie(t,s){if(!t||t.length===0)return;let n=t.find(o=>o.nsfw==="None");return s&&(n=n??t[0]),n}function vt(t,s=280,n){var o,i,a,r;if(t)return pe(t)?(a=ie((i=(o=t.modelVersions)==null?void 0:o.at(0))==null?void 0:i.images,n))==null?void 0:a.url:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${(r=ie(t.images,n))==null?void 0:r.url}/width=${s}/`}const H=280;function yt({model:t,onClickInstallModel:s,installing:n}){var h,m;const[o,i]=d.useState();d.useEffect(()=>{f();async function f(){var j;const v=await((j=k)==null?void 0:j.getSetting("showNsfwModelThumbnail"));i(vt(t,H,v))}},[t]);const a=pe(t)?t.modelVersions:t.versions,[r,l]=d.useState(((h=a==null?void 0:a[0])==null?void 0:h.name)??""),c=a==null?void 0:a.find(f=>(f==null?void 0:f.name)===r),u=()=>{window.open(`https://civitai.com/models/${t.id}`)},p=d.useCallback(()=>{if(c==null){console.error("no file is find by name",r);return}s(se(c,t.name),t)},[r]),g=(m=se(c))==null?void 0:m.sizeKB;return e.jsxs(me,{width:H,justifyContent:"space-between",mb:2,gap:1,children:[e.jsx(ve,{borderRadius:3,boxSize:H+"px",objectFit:"cover",src:o,alt:"model cover image",cursor:"pointer",onClick:()=>u()}),e.jsxs(O,{p:1,children:[e.jsx(ne,{label:t.name,children:e.jsx(I,{fontWeight:500,noOfLines:1,children:t.name})}),e.jsxs(L,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(_,{borderRadius:14,noOfLines:1,size:"xs",colorScheme:"teal",maxWidth:"40%",flexShrink:1,variant:"outline",px:1,cursor:"text",children:e.jsx(I,{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:t.type})}),e.jsx(_,{leftIcon:e.jsx(Ve,{size:18}),iconSpacing:1,borderRadius:10,size:"sm",py:1,colorScheme:"teal",type:"submit",onClick:()=>p(),isDisabled:!!(r&&n.includes(r)),children:"Install"})]}),e.jsxs(E,{children:[e.jsx(G,{size:"md",style:{paddingLeft:4},onChange:f=>{l(f.target.value)},children:a==null?void 0:a.map(f=>{const v=f==null?void 0:f.name;return v?e.jsx("option",{value:v,style:{padding:0},children:v},f.id):null})}),g&&e.jsx(ne,{label:ae(g),children:e.jsx(I,{flexShrink:1,noOfLines:1,width:"40%",children:ae(g)})})]})]})]})}function wt({searchQuery:t,setSearchQuery:s,onSearch:n}){return e.jsxs(L,{gap:1,alignItems:"center",grow:1,children:[e.jsx(W,{placeholder:"Search models in CivitAI",width:"60%",value:t,onChange:o=>s(o.target.value),onKeyUp:o=>{o.code==="Enter"&&n()}}),e.jsx(_,{size:"sm",onClick:()=>n(),colorScheme:"teal",children:"Search"})]})}function St({isOpen:t,fileSelected:s,onClose:n,selectFolder:o}){const[i,a]=d.useState(""),[r,l]=d.useState([]),[c,u]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{g()},[]);const g=async()=>{const h=await fe();h&&(["custom_nodes","config","saved_prompts"].forEach(m=>{delete h[m]}),l(Object.values(h).flatMap(m=>m)))};return e.jsx(De,{isOpen:t,leastDestructiveRef:p,onClose:n,children:e.jsx(ce,{children:e.jsxs(Ne,{children:[e.jsx(de,{fontSize:"lg",fontWeight:"bold",children:"Choose Folder"}),e.jsx(ue,{children:e.jsxs(O,{spacing:4,children:[!s&&e.jsxs(e.Fragment,{children:[e.jsx(I,{children:"Model download url"}),e.jsx(W,{placeholder:"https://civitai.com/api/download/models/311399",onChange:h=>u(h.target.value),value:c})]}),e.jsx(I,{children:"Choose model install folder"}),e.jsx(G,{placeholder:"Select option",value:i,onChange:h=>a(h.target.value),children:r.map(h=>e.jsx("option",{value:h,children:h},h))})]})}),e.jsxs(Ae,{children:[e.jsx(_,{ref:p,onClick:n,children:"Cancel"}),e.jsx(_,{onClick:()=>o(i,c),ml:3,isDisabled:c.length===0,children:"Confirm"})]})]})})})}function _t(){const{colorMode:t}=Be(),s=ge(),[n,o]=d.useState([]);return d.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(O,{spacing:5,pos:"absolute",bottom:"0",left:"0",width:"50%",zIndex:80,backgroundColor:t==="light"?"white":"#242424",paddingX:5,children:n.map(({save_path:i,progress:a})=>e.jsxs(E,{children:[e.jsx(I,{fontSize:16,width:"40%",children:i.replace(/^.*[\\/]/,"")}),e.jsx(Se,{isIndeterminate:!a,hasStripe:!0,width:"50%",value:a}),e.jsxs(I,{fontSize:16,width:"10%",children:[a.toFixed(1),"%"]})]},i))})}const Me="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function bt(){return localStorage.getItem(Me)}function Mt(t){localStorage.setItem(Me,t)}function Ct(){const[t,s]=d.useState(""),{onOpen:n,onClose:o,isOpen:i}=xe(),a=()=>{Mt(t),o()};return e.jsxs($e,{isOpen:i,onOpen:n,onClose:o,placement:"right",closeOnBlur:!1,children:[e.jsx(Ye,{children:e.jsx(_,{size:"sm",py:1,mr:8,children:"Set Civitai API Key"})}),e.jsxs(Ue,{p:5,children:[e.jsx(qe,{}),e.jsx(Qe,{}),e.jsxs(O,{spacing:4,children:[e.jsx(I,{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(W,{value:t,onChange:r=>s(r.target.value),placeholder:"API Key"}),e.jsx(_,{size:"sm",py:1,mr:8,onClick:a,children:"Save"})]})]})]})}const It=t=>typeof t=="function",Ce=t=>{const[s,n]=d.useState(t),o=d.useRef(s),i=d.useCallback(a=>{o.current=It(a)?a(o.current):a,n(o.current)},[]);return[s,i,o]};async function Tt(t,s){var r,l;const n={queries:[{q:t,indexUid:"models_v5",facets:["category.name","checkpointType","fileFormats","lastVersionAtUnix","tags.name","type","user.username","version.baseModel"],attributesToHighlight:["*"],highlightPreTag:"__ais-highlight__",highlightPostTag:"__/ais-highlight__",limit:80,offset:0}]};return s&&(n.queries[0].filter=[[`"type"="${s}"`]]),((l=(r=await(await fetch("https://meilisearch-v1-6.civitai.com/multi-search",{headers:{"Content-Type":"application/json",Authorization:"Bearer 102312c2b83ea0ef9ac32e7858f742721bbfd7319a957272e746f84fd1e974af"},method:"POST",body:JSON.stringify(n)})).json())==null?void 0:r.results)==null?void 0:l.at(0)).hits??[]}function kt({onclose:t,searchQuery:s="",modelType:n}){const[o,i]=d.useState([]),[a,r]=d.useState(!1),[l,c]=d.useState(n),u=ge(),[p,g]=d.useState([]),[h,m]=d.useState(s),{isOpen:f,onOpen:v,onClose:j}=xe(),[y,M,w]=Ce(),[D,U]=d.useState({}),[N,B]=d.useState(K),q=d.useCallback(async()=>{var S;r(!0);const x=await Tt(h,l);i(x);const C=await fe();C&&U(C);const b=await((S=k)==null?void 0:S.getSetting("defaultFolders"));b&&B(b),r(!1)},[h,l]),Q=(x,C)=>{var Z,J,ee,te;if(!((Z=w.current)!=null&&Z.id)&&!C){console.error("no url to download");return}let b=C??`https://civitai.com/api/download/models/${(J=w.current)==null?void 0:J.id}`,S=(ee=w.current)==null?void 0:ee.name;if(!S&&(S=b.split("/").pop(),!S)){console.error("downloadUrl is malformed");return}u({title:"Installing...",description:S,status:"info",duration:4e3,isClosable:!0}),S!=null&&g(ke=>[...ke,S??""]);const X=bt();X&&(b+=`?token=${X}`),jt({file_hash:(te=w.current)==null?void 0:te.SHA256,filename:S,save_path:x,url:b}),M(void 0),j()},Ie=async(x,C)=>{const b=N[C.type];M(x),b==null?v():Q(b)},Te=async(x,C)=>{var S;const b={...N,[x]:C};await((S=k)==null?void 0:S.upsert({defaultFolders:b})),B(b)};return d.useEffect(()=>{q()},[l]),e.jsxs(e.Fragment,{children:[e.jsxs(Fe,{isOpen:!0,onClose:t,blockScrollOnMount:!0,children:[e.jsx(ce,{}),e.jsxs(Re,{width:"90%",maxWidth:"90vw",height:"90vh",children:[e.jsxs(de,{children:[e.jsxs(E,{gap:2,mb:2,alignItems:"center",children:[e.jsx(je,{size:"md",mr:2,children:"Models"}),e.jsx(wt,{searchQuery:h,setSearchQuery:m,onSearch:q}),e.jsx(_,{size:"sm",py:1,mr:8,onClick:v,children:"Custom URL Install"}),e.jsx(Ct,{})]}),e.jsxs(E,{gap:2,mb:2,wrap:"wrap",children:[e.jsx(_,{size:"sm",py:1,onClick:()=>{c(void 0)},isActive:l==null,children:"All"}),Xe.map(x=>e.jsx(_,{size:"sm",py:1,isActive:l===x,onClick:()=>{c(x)},children:x},x)),l&&D[K[l]]&&e.jsxs(E,{ml:"auto",children:[e.jsx(I,{whiteSpace:"nowrap",children:"Default Download Folder:"}),e.jsx(G,{value:N[l],onChange:x=>Te(l,x.target.value),children:D[K[l]].map(x=>e.jsx("option",{value:x,children:x}))})]})]}),a&&e.jsx($,{thickness:"4px",emptyColor:"gray.200",color:"pink.500",size:"lg"})]}),e.jsx(ze,{}),e.jsxs(ue,{overflowY:"auto",children:[e.jsx(E,{wrap:"wrap",children:o==null?void 0:o.map(x=>e.jsx(yt,{model:x,onClickInstallModel:Ie,installing:p},x.id))}),e.jsx(_t,{})]})]})]}),e.jsx(St,{fileSelected:!!y,isOpen:f,onClose:j,selectFolder:(x,C)=>{Q(x,w.current?void 0:C)}})]})}function Et(){const[t,s]=d.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(_,{size:"sm",colorScheme:"teal",onClick:()=>s(!0),children:"Install Models"}),t&&e.jsx(kt,{modelType:"Checkpoint",onclose:()=>s(!1)})]})}const Pt=()=>{const[t,s]=d.useState(["checkpoints"]),[n,o]=d.useState([]),[i,a]=d.useState(!0);d.useEffect(()=>{r(),R.addEventListener("model_list",c=>{l(c.detail)})},[]);const r=async()=>{const c=await Ze();l(c)},l=async c=>{if(!c)return;a(!1);const u=Array.from(new Set(c.map(g=>g.model_type))),p=u.indexOf("checkpoints");p>=0&&u.splice(p,1),u.unshift("checkpoints"),s(u),o(c)};return{modelTypeList:t,modelsList:n,loading:i}};function Lt(){const[t,s,n]=Ce(!1),o=()=>{var l;(l=k)==null||l.getSetting("showNsfwModelThumbnail").then(c=>{s(c??!1)})};d.useEffect(()=>{o()},[]);const i=l=>{var u;const c=l.target.checked;(u=k)==null||u.upsert({showNsfwModelThumbnail:c}).then(()=>{o(),a(),window.dispatchEvent(new Event("showNsfwModelThumbnail"))})},a=async()=>{const l=await F.models.toArray();for(let c=0;c{var c,u;try{const p=`https://civitai.com/api/v1/model-versions/by-hash/${l.fileHash}`,h=await(await fetch(p)).json();let m;if(n.current)m=(u=(c=h==null?void 0:h.images)==null?void 0:c[0])==null?void 0:u.url;else if(!h.model.nsfw){const f=h.images.find(v=>v.nsfw==="None");m=f==null?void 0:f.url}F.models.update(l.id,{imageUrl:m??null})}catch{}};return e.jsx(nt,{isChecked:t,onChange:i,width:"100px",children:"Show NSFW"})}function Dt({onClose:t}){const[s,n]=d.useState("checkpoints"),[o,i]=d.useState(""),{loading:a,modelTypeList:r,modelsList:l}=Pt(),[c,u]=d.useState([]);d.useEffect(()=>{const h=l.filter(m=>o.length?m.model_name.toLowerCase().includes(o.toLowerCase()):m.model_type===s);u(h)},[s,l,o]),d.useEffect(()=>(A.canvasEl.addEventListener("click",t),()=>{A.canvasEl.removeEventListener("click",t)}),[]);const p=440,g=()=>e.jsxs(e.Fragment,{children:[e.jsxs(L,{gap:4,justifyContent:"center",alignItems:"center",mb:1,children:[e.jsx(W,{size:"sm",placeholder:"Search",value:o,onChange:h=>i(h.target.value)}),e.jsx(Lt,{})]}),!o.length&&e.jsx(mt,{modelTypeList:r,setSelectedModel:n,selectedModel:s}),e.jsx(xt,{list:c}),a&&e.jsx(L,{justifyContent:"center",alignItems:"center",height:"100%",children:e.jsx($,{})})]});return e.jsx(Oe,{children:e.jsx(he,{style:{width:p},children:e.jsxs(me,{width:p,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:Je,overflowY:"auto",children:[e.jsxs(L,{justifyContent:"space-between",alignContent:"center",py:3,children:[e.jsx(je,{size:"md",mr:2,children:"Models"}),e.jsx(Et,{})]}),g()]})})})}const Nt=d.lazy(()=>We(()=>import("./InstallMissingModelsButton-KOf9hKlm.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function At(){const[t,s]=d.useState(!1),[n,o]=d.useState(),i=async r=>{if(r.dataTransfer.getData("eventName")!=="WorkspaceManagerAddNode")return;const c=r.dataTransfer.getData("modelRelativePath"),u=r.dataTransfer.getData("nodeType"),p=LiteGraph.createNode(u);p.pos=[r.canvasX,r.canvasY],p.configure({widgets_values:[c]}),A.graph.add(p)};d.useEffect(()=>{var r;return(r=k)==null||r.getSetting("modelManagerTopBarStyle").then(l=>{a(l,!1)}),A.canvasEl.addEventListener("drop",i),()=>{A.canvasEl.removeEventListener("drop",i)}},[]);const a=(r,l=!1)=>{var M;const{top:c=0,right:u=0}=n||{},{top:p=0,right:g=0}=r??{};let h=c+p,m=n===void 0?g:u-g;const f=document.documentElement.clientWidth,v=document.documentElement.clientHeight,j=document.getElementById("modelManagerTopBar"),y=(j==null?void 0:j.offsetWidth)||224;h+32>v&&(h=v-38),m+y>f&&(m=f-y-4),o({top:Math.max(4,h),right:Math.max(4,m)}),l&&((M=k)==null||M.upsert({modelManagerTopBarStyle:{top:h,right:m}}))};return e.jsx(et,{onDragEnd:r=>{a({top:r.y,right:r.x},!0)},dragIconId:"dragModelManagerTopBarIcon",children:n?e.jsxs(E,{style:{position:"fixed",...n},gap:2,draggable:!1,id:"modelManagerTopBar",className:"model-manager-top-bar",children:[e.jsx(tt,{id:"dragModelManagerTopBarIcon",className:"drag-model-manager-top-bar-icon",cursor:"move",size:15,color:"#FFF"}),e.jsx(Nt,{}),e.jsx(_,{size:"sm",colorScheme:"blue","aria-label":"My models",onClick:()=>s(!0),px:1,children:"Models"}),t&&e.jsx(Dt,{onClose:()=>s(!1)})]}):""})}const Wt=Object.freeze(Object.defineProperty({__proto__:null,default:At},Symbol.toStringTag,{value:"Module"}));export{we as G,Et as I,Wt as M,Tt as g}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["workspace_web/InstallMissingModelsButton-KOf9hKlm.js","workspace_web/input.js","workspace_web/App-GluzE5n7.js","workspace_web/assets/App-JXePnJiV.css","workspace_web/chunk-NTCQBYKE-ZsMy4OBB.js","workspace_web/chunk-JARCRF6W-IwBcFM3i.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-pKqjZV5O.js b/dist/workspace_web/RecentFilesDrawer-B74sdP_1.js similarity index 92% rename from dist/workspace_web/RecentFilesDrawer-pKqjZV5O.js rename to dist/workspace_web/RecentFilesDrawer-B74sdP_1.js index 9f7d75d..328e5a7 100644 --- a/dist/workspace_web/RecentFilesDrawer-pKqjZV5O.js +++ b/dist/workspace_web/RecentFilesDrawer-B74sdP_1.js @@ -1,4 +1,4 @@ -import{f as Ye,l as Bn,o as $r,j as x,g as Ue,h as Ke,W as Ur,r as F,D as Mt,v as Nn,M as vt,L as gt,N as bt,O as yt,Q as wt,R as xt,X as ut,q as Wr,U as $n,B as Se,Y as qt,S as Hr,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 Wn,V as oe,i as $e,a8 as qr,I as Jt,a9 as dn}from"./input.js";import{b as Jr,a as Qr,u as Hn,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 we,I as xe,t as We,i as Gn,j as Le,T as Oe,k as it,l as ye,R as Be,m as Yn,n as oi,s as si,w as be,o as li,p as ui,B as de,F as nt,q as Fe,r as hn,v as ci,x as Xe,y as at,z as Re,A as di,D as Kn,C as Qt,E as en,G as hi,J as Xn,K as Ve,L as fi,N as pi,O as mi,P as tn,Q as vi,U as gi,V as bi,W as He,X as $t,Y as yi,Z as wi,_ as xi,$ as Si,a0 as _i,a1 as Ci,a2 as ki,a3 as nn,a4 as Oi,a5 as Ii,a6 as fn,a7 as Ei,a8 as Pi,a9 as Mi,aa as Ft,ab as ji}from"./App-Fl7cObcs.js";import{T as qn}from"./chunk-RPO2WXNL-dt-e86vT.js";import{C as ot}from"./chunk-JARCRF6W-aHchqwnR.js";import{V as pn}from"./chunk-NTCQBYKE-EEXlKSMU.js";import{S as Di,g as zi,I as Fi,M as Ri}from"./MediaPreview-Z5nSvSr_.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:o,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:a,borderWidth:r,borderStyle:s,borderColor:c,...f}=Bn("Divider",e),{className:p,orientation:y="horizontal",__css:u,...g}=$r(e),d={vertical:{borderLeftWidth:o||a||r||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||r||"1px",width:"100%"}};return x.jsx(Ue.hr,{ref:n,"aria-orientation":y,...g,__css:{...f,border:"0",borderColor:c,borderStyle:s,...d[y],...u},className:Ke("chakra-divider",p)})});Jn.displayName="Divider";function Ai(l,e={}){const{ssr:n=!0,fallback:o}=e,{getWindow:t}=Ur(),i=Array.isArray(l)?l:[l];let a=Array.isArray(o)?o:[o];a=a.filter(c=>c!=null);const[r,s]=F.useState(()=>i.map((c,f)=>({media:c,matches:n?!!a[f]:t().matchMedia(c).matches})));return F.useEffect(()=>{const c=t();s(i.map(y=>({media:y,matches:c.matchMedia(y).matches})));const f=i.map(y=>c.matchMedia(y)),p=y=>{s(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 Ti(l,e,n=Jr){let o=Object.keys(l).indexOf(e);if(o!==-1)return l[e];let t=n.indexOf(e);for(;t>=0;){const i=n[t];if(l.hasOwnProperty(i)){o=t;break}t-=1}if(o!==-1){const i=n[o];return l[i]}}function Li(l){var e,n;const o=Nn(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===o.fallback),s=Ai(i.map(c=>c.query),{fallback:a,ssr:o.ssr}).findIndex(c=>c==!0);return(n=(e=i[s])==null?void 0:e.breakpoint)!=null?n:o.fallback}function Vi(l,e){var n;const o=Nn(e)?e:{fallback:e??"base"},t=Li(o),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(([s,c])=>[s,c])):l;return Ti(r,t,a)}var Qn=Ye((l,e)=>{const{title:n,children:o,className:t,...i}=l,a=Ke("chakra-menu__group__title",t),r=Hn();return x.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[n&&x.jsx(Ue.p,{className:a,...i,__css:r.groupTitle,children:n}),o]})});Qn.displayName="MenuGroup";var er=l=>{const{className:e,title:n,...o}=l,t=ei(o);return x.jsx(Qn,{title:n,className:Ke("chakra-menu__option-group",e),...t})};er.displayName="MenuOptionGroup";var Bi=Ye((l,e)=>{const n=Hn();return x.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:o,...t}=l,i=ti(t,e),a=o||Bi;return x.jsx(a,{...i,className:Ke("chakra-menu__menu-button",l.className),children:x.jsx(Ue.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:l.children})})});jt.displayName="MenuButton";var Ni=l=>x.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...l,children:x.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"})}),rn=Ye((l,e)=>{const{icon:n,iconSpacing:o="0.75rem",...t}=l,i=ni(t,e);return x.jsxs(ri,{...i,className:Ke("chakra-menu__menuitem-option",t.className),children:[n!==null&&x.jsx(Zn,{fontSize:"0.8em",marginEnd:o,opacity:l.isChecked?1:0,children:n||x.jsx(Ni,{})}),x.jsx("span",{style:{flex:1},children:i.children})]})});rn.id="MenuItemOption";rn.displayName="MenuItemOption";var tr=Ye(function(e,n){const{getHeaderProps:o}=ii(),t=ai();return x.jsx(Ue.header,{...o(e,n),className:Ke("chakra-popover__header",e.className),__css:t.header})});tr.displayName="PopoverHeader";var $i=Ie("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Ui=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"}]]),mn=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"}]]),Wi=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"}]]),Hi=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"}]]),Zi=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"}]]),Gi=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"}]]),Yi=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"}]]),Ki=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"}]]),Xi=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"}]]),qi=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 Ji({onclose:l}){const[e,n]=F.useState([]),o=async()=>{var i;const t=await((i=We)==null?void 0:i.listAll());n(t??[])};return F.useEffect(()=>{o()},[]),x.jsxs(vt,{isOpen:!0,onClose:l,children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"My Tags"}),x.jsx(wt,{}),x.jsx(xt,{children:e.map(t=>x.jsxs(we,{children:[x.jsx(qn,{children:t.name}),x.jsx(xe,{onClick:async()=>{var i;await((i=We)==null?void 0:i.delete(t.name)),o()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:x.jsx(Gn,{})})]}))})]})]})}function Qi(){const[l,e]=F.useState(""),[n,o]=F.useState(!1),t=()=>o(!0),i=()=>o(!1),a=async s=>{var f;s.preventDefault();let c="";s.ctrlKey&&(c+="Control+"),s.shiftKey&&(c+="Shift+"),s.altKey&&(c+="Alt+"),c.length>0&&!["Control","Shift","Alt"].includes(s.key)&&(c+=s.key.toUpperCase(),await((f=ye)==null?void 0:f.upsert({shortcuts:{save:c}})),r())},r=()=>{var s;(s=ye)==null||s.getSetting("shortcuts").then(c=>{var f;e((c==null?void 0:c.save)??((f=ye)==null?void 0:f.defaultSettings.shortcuts))})};return F.useEffect(()=>{r()},[]),x.jsxs(Le,{children:[x.jsx(Oe,{children:"Keyboard Shortcut - Save current workflow"}),n&&x.jsx(Oe,{color:"gray.500",children:"Press shortcut key combinations to setup"}),x.jsx(it,{value:l,onKeyDown:a,onFocus:t,onBlur:i,placeholder:"Press a key combination",readOnly:!0})]})}function ea(){const{setRefreshFolderStamp:l}=F.useContext(Be),[e,n]=F.useState(!1),o=()=>{var i;(i=ye)==null||i.getSetting("foldersOnTop").then(a=>{n(!!a)})},t=i=>{var r;const a=i.target.checked;(r=ye)==null||r.upsert({foldersOnTop:a}).then(()=>{o(),l(Date.now())})};return F.useEffect(()=>{o()},[]),x.jsx(Le,{children:x.jsx(ot,{isChecked:e,onChange:t,children:"Folders always on top"})})}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:{}};/*! +import{f as Ye,l as Bn,o as $r,j as x,g as Ue,h as Ke,W as Ur,r as F,D as Mt,v as Nn,M as vt,L as gt,N as bt,O as yt,Q as wt,R as xt,X as ut,q as Wr,U as $n,B as Se,Y as qt,S as Hr,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 Wn,V as oe,i as $e,a8 as qr,I as Jt,a9 as dn}from"./input.js";import{b as Jr,a as Qr,u as Hn,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 we,T as Gn,I as xe,t as We,i as Yn,j as Le,k as Oe,l as it,m as ye,R as Be,n as Kn,o as oi,s as si,w as be,p as li,q as ui,B as de,F as nt,r as Fe,v as hn,x as ci,y as Xe,z as at,A as Re,C as di,D as Xn,E as Qt,G as en,J as hi,K as qn,L as Ve,N as fi,O as pi,P as mi,Q as tn,U as vi,V as gi,W as bi,X as He,Y as $t,Z as yi,_ as wi,$ as xi,a0 as Si,a1 as _i,a2 as Ci,a3 as ki,a4 as nn,a5 as Oi,a6 as Ii,a7 as fn,a8 as Ei,a9 as Pi,aa as Mi,ab as Ft,ac as ji}from"./App-GluzE5n7.js";import{C as ot}from"./chunk-JARCRF6W-IwBcFM3i.js";import{V as pn}from"./chunk-NTCQBYKE-ZsMy4OBB.js";import{S as Di,g as zi,I as Fi,M as Ri}from"./MediaPreview-EfKQfEU-.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:o,borderBottomWidth:t,borderTopWidth:i,borderRightWidth:a,borderWidth:r,borderStyle:s,borderColor:c,...f}=Bn("Divider",e),{className:p,orientation:y="horizontal",__css:u,...g}=$r(e),d={vertical:{borderLeftWidth:o||a||r||"1px",height:"100%"},horizontal:{borderBottomWidth:t||i||r||"1px",width:"100%"}};return x.jsx(Ue.hr,{ref:n,"aria-orientation":y,...g,__css:{...f,border:"0",borderColor:c,borderStyle:s,...d[y],...u},className:Ke("chakra-divider",p)})});Jn.displayName="Divider";function Ai(l,e={}){const{ssr:n=!0,fallback:o}=e,{getWindow:t}=Ur(),i=Array.isArray(l)?l:[l];let a=Array.isArray(o)?o:[o];a=a.filter(c=>c!=null);const[r,s]=F.useState(()=>i.map((c,f)=>({media:c,matches:n?!!a[f]:t().matchMedia(c).matches})));return F.useEffect(()=>{const c=t();s(i.map(y=>({media:y,matches:c.matchMedia(y).matches})));const f=i.map(y=>c.matchMedia(y)),p=y=>{s(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 Ti(l,e,n=Jr){let o=Object.keys(l).indexOf(e);if(o!==-1)return l[e];let t=n.indexOf(e);for(;t>=0;){const i=n[t];if(l.hasOwnProperty(i)){o=t;break}t-=1}if(o!==-1){const i=n[o];return l[i]}}function Li(l){var e,n;const o=Nn(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===o.fallback),s=Ai(i.map(c=>c.query),{fallback:a,ssr:o.ssr}).findIndex(c=>c==!0);return(n=(e=i[s])==null?void 0:e.breakpoint)!=null?n:o.fallback}function Vi(l,e){var n;const o=Nn(e)?e:{fallback:e??"base"},t=Li(o),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(([s,c])=>[s,c])):l;return Ti(r,t,a)}var Qn=Ye((l,e)=>{const{title:n,children:o,className:t,...i}=l,a=Ke("chakra-menu__group__title",t),r=Hn();return x.jsxs("div",{ref:e,className:"chakra-menu__group",role:"group",children:[n&&x.jsx(Ue.p,{className:a,...i,__css:r.groupTitle,children:n}),o]})});Qn.displayName="MenuGroup";var er=l=>{const{className:e,title:n,...o}=l,t=ei(o);return x.jsx(Qn,{title:n,className:Ke("chakra-menu__option-group",e),...t})};er.displayName="MenuOptionGroup";var Bi=Ye((l,e)=>{const n=Hn();return x.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:o,...t}=l,i=ti(t,e),a=o||Bi;return x.jsx(a,{...i,className:Ke("chakra-menu__menu-button",l.className),children:x.jsx(Ue.span,{__css:{pointerEvents:"none",flex:"1 1 auto",minW:0},children:l.children})})});jt.displayName="MenuButton";var Ni=l=>x.jsx("svg",{viewBox:"0 0 14 14",width:"1em",height:"1em",...l,children:x.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"})}),rn=Ye((l,e)=>{const{icon:n,iconSpacing:o="0.75rem",...t}=l,i=ni(t,e);return x.jsxs(ri,{...i,className:Ke("chakra-menu__menuitem-option",t.className),children:[n!==null&&x.jsx(Zn,{fontSize:"0.8em",marginEnd:o,opacity:l.isChecked?1:0,children:n||x.jsx(Ni,{})}),x.jsx("span",{style:{flex:1},children:i.children})]})});rn.id="MenuItemOption";rn.displayName="MenuItemOption";var tr=Ye(function(e,n){const{getHeaderProps:o}=ii(),t=ai();return x.jsx(Ue.header,{...o(e,n),className:Ke("chakra-popover__header",e.className),__css:t.header})});tr.displayName="PopoverHeader";var $i=Ie("chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),Ui=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"}]]),mn=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"}]]),Wi=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"}]]),Hi=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"}]]),Zi=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"}]]),Gi=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"}]]),Yi=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"}]]),Ki=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"}]]),Xi=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"}]]),qi=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 Ji({onclose:l}){const[e,n]=F.useState([]),o=async()=>{var i;const t=await((i=We)==null?void 0:i.listAll());n(t??[])};return F.useEffect(()=>{o()},[]),x.jsxs(vt,{isOpen:!0,onClose:l,children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"My Tags"}),x.jsx(wt,{}),x.jsx(xt,{children:e.map(t=>x.jsxs(we,{children:[x.jsx(Gn,{children:t.name}),x.jsx(xe,{onClick:async()=>{var i;await((i=We)==null?void 0:i.delete(t.name)),o()},"aria-label":"delete-tag",colorScheme:"red",variant:"ghost",icon:x.jsx(Yn,{})})]}))})]})]})}function Qi(){const[l,e]=F.useState(""),[n,o]=F.useState(!1),t=()=>o(!0),i=()=>o(!1),a=async s=>{var f;s.preventDefault();let c="";s.ctrlKey&&(c+="Control+"),s.shiftKey&&(c+="Shift+"),s.altKey&&(c+="Alt+"),c.length>0&&!["Control","Shift","Alt"].includes(s.key)&&(c+=s.key.toUpperCase(),await((f=ye)==null?void 0:f.upsert({shortcuts:{save:c}})),r())},r=()=>{var s;(s=ye)==null||s.getSetting("shortcuts").then(c=>{var f;e((c==null?void 0:c.save)??((f=ye)==null?void 0:f.defaultSettings.shortcuts))})};return F.useEffect(()=>{r()},[]),x.jsxs(Le,{children:[x.jsx(Oe,{children:"Keyboard Shortcut - Save current workflow"}),n&&x.jsx(Oe,{color:"gray.500",children:"Press shortcut key combinations to setup"}),x.jsx(it,{value:l,onKeyDown:a,onFocus:t,onBlur:i,placeholder:"Press a key combination",readOnly:!0})]})}function ea(){const{setRefreshFolderStamp:l}=F.useContext(Be),[e,n]=F.useState(!1),o=()=>{var i;(i=ye)==null||i.getSetting("foldersOnTop").then(a=>{n(!!a)})},t=i=>{var r;const a=i.target.checked;(r=ye)==null||r.upsert({foldersOnTop:a}).then(()=>{o(),l(Date.now())})};return F.useEffect(()=>{o()},[]),x.jsx(Le,{children:x.jsx(ot,{isChecked:e,onChange:t,children:"Folders always on top"})})}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 @@ -9,10 +9,10 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(l,e){(function(n){l.exports=n()})(function(){return function n(o,t,i){function a(c,f){if(!t[c]){if(!o[c]){var p=typeof dt=="function"&&dt;if(!f&&p)return p(c,!0);if(r)return r(c,!0);var y=new Error("Cannot find module '"+c+"'");throw y.code="MODULE_NOT_FOUND",y}var u=t[c]={exports:{}};o[c][0].call(u.exports,function(g){var d=o[c][1][g];return a(d||g)},u,u.exports,n,o,t,i)}return t[c].exports}for(var r=typeof dt=="function"&&dt,s=0;s>2,u=(3&c)<<4|f>>4,g=1<_?(15&f)<<2|p>>6:64,d=2<_?63&p:64,b.push(r.charAt(y)+r.charAt(u)+r.charAt(g)+r.charAt(d));return b.join("")},t.decode=function(s){var c,f,p,y,u,g,d=0,b=0,m="data:";if(s.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var w,_=3*(s=s.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(s.charAt(s.length-1)===r.charAt(64)&&_--,s.charAt(s.length-2)===r.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=a.uint8array?new Uint8Array(0|_):new Array(0|_);d>4,f=(15&y)<<4|(u=r.indexOf(s.charAt(d++)))>>2,p=(3&u)<<6|(g=r.indexOf(s.charAt(d++))),w[b++]=c,u!==64&&(w[b++]=f),g!==64&&(w[b++]=p);return w}},{"./support":30,"./utils":32}],2:[function(n,o,t){var i=n("./external"),a=n("./stream/DataWorker"),r=n("./stream/Crc32Probe"),s=n("./stream/DataLengthProbe");function c(f,p,y,u,g){this.compressedSize=f,this.uncompressedSize=p,this.crc32=y,this.compression=u,this.compressedContent=g}c.prototype={getContentWorker:function(){var f=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),p=this;return f.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(f,p,y){return f.pipe(new r).pipe(new s("uncompressedSize")).pipe(p.compressWorker(y)).pipe(new s("compressedSize")).withStreamInfo("compression",p)},o.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,o,t){var i=n("./stream/GenericWorker");t.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},t.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,o,t){var i=n("./utils"),a=function(){for(var r,s=[],c=0;c<256;c++){r=c;for(var f=0;f<8;f++)r=1&r?3988292384^r>>>1:r>>>1;s[c]=r}return s}();o.exports=function(r,s){return r!==void 0&&r.length?i.getTypeOf(r)!=="string"?function(c,f,p,y){var u=a,g=y+p;c^=-1;for(var d=y;d>>8^u[255&(c^f[d])];return-1^c}(0|s,r,r.length,0):function(c,f,p,y){var u=a,g=y+p;c^=-1;for(var d=y;d>>8^u[255&(c^f.charCodeAt(d))];return-1^c}(0|s,r,r.length,0):0}},{"./utils":32}],5:[function(n,o,t){t.base64=!1,t.binary=!1,t.dir=!1,t.createFolders=!0,t.date=null,t.compression=null,t.compressionOptions=null,t.comment=null,t.unixPermissions=null,t.dosPermissions=null},{}],6:[function(n,o,t){var i=null;i=typeof Promise<"u"?Promise:n("lie"),o.exports={Promise:i}},{lie:37}],7:[function(n,o,t){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),r=n("./utils"),s=n("./stream/GenericWorker"),c=i?"uint8array":"array";function f(p,y){s.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=y,this.meta={}}t.magic="\b\0",r.inherits(f,s),f.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(r.transformTo(c,p.data),!1)},f.prototype.flush=function(){s.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(y){p.push({data:y,meta:p.meta})}},t.compressWorker=function(p){return new f("Deflate",p)},t.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,o,t){function i(u,g){var d,b="";for(d=0;d>>=8;return b}function a(u,g,d,b,m,w){var _,C,I=u.file,P=u.compression,E=w!==c.utf8encode,D=r.transformTo("string",w(I.name)),j=r.transformTo("string",c.utf8encode(I.name)),U=I.comment,q=r.transformTo("string",w(U)),O=r.transformTo("string",c.utf8encode(U)),L=j.length!==I.name.length,v=O.length!==U.length,B="",te="",T="",J=I.dir,N=I.date,K={crc32:0,compressedSize:0,uncompressedSize:0};g&&!d||(K.crc32=u.crc32,K.compressedSize=u.compressedSize,K.uncompressedSize=u.uncompressedSize);var A=0;g&&(A|=8),E||!L&&!v||(A|=2048);var z=0,ee=0;J&&(z|=16),m==="UNIX"?(ee=798,z|=function(Z,ce){var he=Z;return Z||(he=ce?16893:33204),(65535&he)<<16}(I.unixPermissions,J)):(ee=20,z|=function(Z){return 63&(Z||0)}(I.dosPermissions)),_=N.getUTCHours(),_<<=6,_|=N.getUTCMinutes(),_<<=5,_|=N.getUTCSeconds()/2,C=N.getUTCFullYear()-1980,C<<=4,C|=N.getUTCMonth()+1,C<<=5,C|=N.getUTCDate(),L&&(te=i(1,1)+i(f(D),4)+j,B+="up"+i(te.length,2)+te),v&&(T=i(1,1)+i(f(q),4)+O,B+="uc"+i(T.length,2)+T);var X="";return X+=` -\0`,X+=i(A,2),X+=P.magic,X+=i(_,2),X+=i(C,2),X+=i(K.crc32,4),X+=i(K.compressedSize,4),X+=i(K.uncompressedSize,4),X+=i(D.length,2),X+=i(B.length,2),{fileRecord:p.LOCAL_FILE_HEADER+X+D+B,dirRecord:p.CENTRAL_FILE_HEADER+i(ee,2)+X+i(q.length,2)+"\0\0\0\0"+i(z,4)+i(b,4)+D+B+q}}var r=n("../utils"),s=n("../stream/GenericWorker"),c=n("../utf8"),f=n("../crc32"),p=n("../signature");function y(u,g,d,b){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=d,this.encodeFileName=b,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(y,s),y.prototype.push=function(u){var g=u.meta.percent||0,d=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,s.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:d?(g+100*(d-b-1))/d:100}}))},y.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var g=this.streamFiles&&!u.file.dir;if(g){var d=a(u,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(u){this.accumulate=!1;var g=this.streamFiles&&!u.file.dir,d=a(u,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),g)this.push({data:function(b){return p.DATA_DESCRIPTOR+i(b.crc32,4)+i(b.compressedSize,4)+i(b.uncompressedSize,4)}(u),meta:{percent:100}});else for(this.push({data:d.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var u=this.bytesWritten,g=0;g=this.index;s--)c=(c<<8)+this.byteAt(s);return this.index+=r,c},readString:function(r){return i.transformTo("string",this.readData(r))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var r=this.readInt(4);return new Date(Date.UTC(1980+(r>>25&127),(r>>21&15)-1,r>>16&31,r>>11&31,r>>5&63,(31&r)<<1))}},o.exports=a},{"../utils":32}],19:[function(n,o,t){var i=n("./Uint8ArrayReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.readData=function(r){this.checkOffset(r);var s=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,o,t){var i=n("./DataReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.byteAt=function(r){return this.data.charCodeAt(this.zero+r)},a.prototype.lastIndexOfSignature=function(r){return this.data.lastIndexOf(r)-this.zero},a.prototype.readAndCheckSignature=function(r){return r===this.readData(4)},a.prototype.readData=function(r){this.checkOffset(r);var s=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,o,t){var i=n("./ArrayReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.readData=function(r){if(this.checkOffset(r),r===0)return new Uint8Array(0);var s=this.data.subarray(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,o,t){var i=n("../utils"),a=n("../support"),r=n("./ArrayReader"),s=n("./StringReader"),c=n("./NodeBufferReader"),f=n("./Uint8ArrayReader");o.exports=function(p){var y=i.getTypeOf(p);return i.checkSupport(y),y!=="string"||a.uint8array?y==="nodebuffer"?new c(p):a.uint8array?new f(i.transformTo("uint8array",p)):new r(i.transformTo("array",p)):new s(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,o,t){t.LOCAL_FILE_HEADER="PK",t.CENTRAL_FILE_HEADER="PK",t.CENTRAL_DIRECTORY_END="PK",t.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",t.ZIP64_CENTRAL_DIRECTORY_END="PK",t.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,o,t){var i=n("./GenericWorker"),a=n("../utils");function r(s){i.call(this,"ConvertWorker to "+s),this.destType=s}a.inherits(r,i),r.prototype.processChunk=function(s){this.push({data:a.transformTo(this.destType,s.data),meta:s.meta})},o.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(n,o,t){var i=n("./GenericWorker"),a=n("../crc32");function r(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(r,i),r.prototype.processChunk=function(s){this.streamInfo.crc32=a(s.data,this.streamInfo.crc32||0),this.push(s)},o.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,o,t){var i=n("../utils"),a=n("./GenericWorker");function r(s){a.call(this,"DataLengthProbe for "+s),this.propName=s,this.withStreamInfo(s,0)}i.inherits(r,a),r.prototype.processChunk=function(s){if(s){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+s.data.length}a.prototype.processChunk.call(this,s)},o.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(n,o,t){var i=n("../utils"),a=n("./GenericWorker");function r(s){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,s.then(function(f){c.dataIsReady=!0,c.data=f,c.max=f&&f.length||0,c.type=i.getTypeOf(f),c.isPaused||c._tickAndRepeat()},function(f){c.error(f)})}i.inherits(r,a),r.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var s=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":s=this.data.substring(this.index,c);break;case"uint8array":s=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":s=this.data.slice(this.index,c)}return this.index=c,this.push({data:s,meta:{percent:this.max?this.index/this.max*100:0}})},o.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(n,o,t){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,r){return this._listeners[a].push(r),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,r){if(this._listeners[a])for(var s=0;s "+a:a}},o.exports=i},{}],29:[function(n,o,t){var i=n("../utils"),a=n("./ConvertWorker"),r=n("./GenericWorker"),s=n("../base64"),c=n("../support"),f=n("../external"),p=null;if(c.nodestream)try{p=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(g,d){return new f.Promise(function(b,m){var w=[],_=g._internalType,C=g._outputType,I=g._mimeType;g.on("data",function(P,E){w.push(P),d&&d(E)}).on("error",function(P){w=[],m(P)}).on("end",function(){try{var P=function(E,D,j){switch(E){case"blob":return i.newBlob(i.transformTo("arraybuffer",D),j);case"base64":return s.encode(D);default:return i.transformTo(E,D)}}(C,function(E,D){var j,U=0,q=null,O=0;for(j=0;j"u")t.blob=!1;else{var i=new ArrayBuffer(0);try{t.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),t.blob=a.getBlob("application/zip").size===0}catch{t.blob=!1}}}try{t.nodestream=!!n("readable-stream").Readable}catch{t.nodestream=!1}},{"readable-stream":16}],31:[function(n,o,t){for(var i=n("./utils"),a=n("./support"),r=n("./nodejsUtils"),s=n("./stream/GenericWorker"),c=new Array(256),f=0;f<256;f++)c[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;c[254]=c[254]=1;function p(){s.call(this,"utf-8 decode"),this.leftOver=null}function y(){s.call(this,"utf-8 encode")}t.utf8encode=function(u){return a.nodebuffer?r.newBufferFrom(u,"utf-8"):function(g){var d,b,m,w,_,C=g.length,I=0;for(w=0;w>>6:(b<65536?d[_++]=224|b>>>12:(d[_++]=240|b>>>18,d[_++]=128|b>>>12&63),d[_++]=128|b>>>6&63),d[_++]=128|63&b);return d}(u)},t.utf8decode=function(u){return a.nodebuffer?i.transformTo("nodebuffer",u).toString("utf-8"):function(g){var d,b,m,w,_=g.length,C=new Array(2*_);for(d=b=0;d<_;)if((m=g[d++])<128)C[b++]=m;else if(4<(w=c[m]))C[b++]=65533,d+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,C[b++]=56320|1023&m)}return C.length!==b&&(C.subarray?C=C.subarray(0,b):C.length=b),i.applyFromCharCode(C)}(u=i.transformTo(a.uint8array?"uint8array":"array",u))},i.inherits(p,s),p.prototype.processChunk=function(u){var g=i.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var d=g;(g=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),g.set(d,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var b=function(w,_){var C;for((_=_||w.length)>w.length&&(_=w.length),C=_-1;0<=C&&(192&w[C])==128;)C--;return C<0||C===0?_:C+c[w[C]]>_?C:_}(g),m=g;b!==g.length&&(a.uint8array?(m=g.subarray(0,b),this.leftOver=g.subarray(b,g.length)):(m=g.slice(0,b),this.leftOver=g.slice(b,g.length))),this.push({data:t.utf8decode(m),meta:u.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:t.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},t.Utf8DecodeWorker=p,i.inherits(y,s),y.prototype.processChunk=function(u){this.push({data:t.utf8encode(u.data),meta:u.meta})},t.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,o,t){var i=n("./support"),a=n("./base64"),r=n("./nodejsUtils"),s=n("./external");function c(d){return d}function f(d,b){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var g,d,b,m=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4>>6:(u<65536?y[b++]=224|u>>>12:(y[b++]=240|u>>>18,y[b++]=128|u>>>12&63),y[b++]=128|u>>>6&63),y[b++]=128|63&u);return y},t.buf2binstring=function(p){return f(p,p.length)},t.binstring2buf=function(p){for(var y=new i.Buf8(p.length),u=0,g=y.length;u>10&1023,w[g++]=56320|1023&d)}return f(w,g)},t.utf8border=function(p,y){var u;for((y=y||p.length)>p.length&&(y=p.length),u=y-1;0<=u&&(192&p[u])==128;)u--;return u<0||u===0?y:u+s[p[u]]>y?u:y}},{"./common":41}],43:[function(n,o,t){o.exports=function(i,a,r,s){for(var c=65535&i|0,f=i>>>16&65535|0,p=0;r!==0;){for(r-=p=2e3>>1:a>>>1;r[s]=a}return r}();o.exports=function(a,r,s,c){var f=i,p=c+s;a^=-1;for(var y=c;y>>8^f[255&(a^r[y])];return-1^a}},{}],46:[function(n,o,t){var i,a=n("../utils/common"),r=n("./trees"),s=n("./adler32"),c=n("./crc32"),f=n("./messages"),p=0,y=4,u=0,g=-2,d=-1,b=4,m=2,w=8,_=9,C=286,I=30,P=19,E=2*C+1,D=15,j=3,U=258,q=U+j+1,O=42,L=113,v=1,B=2,te=3,T=4;function J(h,$){return h.msg=f[$],$}function N(h){return(h<<1)-(4h.avail_out&&(V=h.avail_out),V!==0&&(a.arraySet(h.output,$.pending_buf,$.pending_out,V,h.next_out),h.next_out+=V,$.pending_out+=V,h.total_out+=V,h.avail_out-=V,$.pending-=V,$.pending===0&&($.pending_out=0))}function z(h,$){r._tr_flush_block(h,0<=h.block_start?h.block_start:-1,h.strstart-h.block_start,$),h.block_start=h.strstart,A(h.strm)}function ee(h,$){h.pending_buf[h.pending++]=$}function X(h,$){h.pending_buf[h.pending++]=$>>>8&255,h.pending_buf[h.pending++]=255&$}function Z(h,$){var V,k,S=h.max_chain_length,M=h.strstart,W=h.prev_length,H=h.nice_match,R=h.strstart>h.w_size-q?h.strstart-(h.w_size-q):0,G=h.window,Q=h.w_mask,Y=h.prev,ne=h.strstart+U,fe=G[M+W-1],ue=G[M+W];h.prev_length>=h.good_match&&(S>>=2),H>h.lookahead&&(H=h.lookahead);do if(G[(V=$)+W]===ue&&G[V+W-1]===fe&&G[V]===G[M]&&G[++V]===G[M+1]){M+=2,V++;do;while(G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&MR&&--S!=0);return W<=h.lookahead?W:h.lookahead}function ce(h){var $,V,k,S,M,W,H,R,G,Q,Y=h.w_size;do{if(S=h.window_size-h.lookahead-h.strstart,h.strstart>=Y+(Y-q)){for(a.arraySet(h.window,h.window,Y,Y,0),h.match_start-=Y,h.strstart-=Y,h.block_start-=Y,$=V=h.hash_size;k=h.head[--$],h.head[$]=Y<=k?k-Y:0,--V;);for($=V=Y;k=h.prev[--$],h.prev[$]=Y<=k?k-Y:0,--V;);S+=Y}if(h.strm.avail_in===0)break;if(W=h.strm,H=h.window,R=h.strstart+h.lookahead,G=S,Q=void 0,Q=W.avail_in,G=j)for(M=h.strstart-h.insert,h.ins_h=h.window[M],h.ins_h=(h.ins_h<=j&&(h.ins_h=(h.ins_h<=j)if(k=r._tr_tally(h,h.strstart-h.match_start,h.match_length-j),h.lookahead-=h.match_length,h.match_length<=h.max_lazy_match&&h.lookahead>=j){for(h.match_length--;h.strstart++,h.ins_h=(h.ins_h<=j&&(h.ins_h=(h.ins_h<=j&&h.match_length<=h.prev_length){for(S=h.strstart+h.lookahead-j,k=r._tr_tally(h,h.strstart-1-h.prev_match,h.prev_length-j),h.lookahead-=h.prev_length-1,h.prev_length-=2;++h.strstart<=S&&(h.ins_h=(h.ins_h<h.pending_buf_size-5&&(V=h.pending_buf_size-5);;){if(h.lookahead<=1){if(ce(h),h.lookahead===0&&$===p)return v;if(h.lookahead===0)break}h.strstart+=h.lookahead,h.lookahead=0;var k=h.block_start+V;if((h.strstart===0||h.strstart>=k)&&(h.lookahead=h.strstart-k,h.strstart=k,z(h,!1),h.strm.avail_out===0)||h.strstart-h.block_start>=h.w_size-q&&(z(h,!1),h.strm.avail_out===0))return v}return h.insert=0,$===y?(z(h,!0),h.strm.avail_out===0?te:T):(h.strstart>h.block_start&&(z(h,!1),h.strm.avail_out),v)}),new le(4,4,8,4,he),new le(4,5,16,8,he),new le(4,6,32,32,he),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],t.deflateInit=function(h,$){return ke(h,$,w,15,8,0)},t.deflateInit2=ke,t.deflateReset=Ce,t.deflateResetKeep=pe,t.deflateSetHeader=function(h,$){return h&&h.state?h.state.wrap!==2?g:(h.state.gzhead=$,u):g},t.deflate=function(h,$){var V,k,S,M;if(!h||!h.state||5<$||$<0)return h?J(h,g):g;if(k=h.state,!h.output||!h.input&&h.avail_in!==0||k.status===666&&$!==y)return J(h,h.avail_out===0?-5:g);if(k.strm=h,V=k.last_flush,k.last_flush=$,k.status===O)if(k.wrap===2)h.adler=0,ee(k,31),ee(k,139),ee(k,8),k.gzhead?(ee(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),ee(k,255&k.gzhead.time),ee(k,k.gzhead.time>>8&255),ee(k,k.gzhead.time>>16&255),ee(k,k.gzhead.time>>24&255),ee(k,k.level===9?2:2<=k.strategy||k.level<2?4:0),ee(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(ee(k,255&k.gzhead.extra.length),ee(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(h.adler=c(h.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(ee(k,0),ee(k,0),ee(k,0),ee(k,0),ee(k,0),ee(k,k.level===9?2:2<=k.strategy||k.level<2?4:0),ee(k,3),k.status=L);else{var W=w+(k.w_bits-8<<4)<<8;W|=(2<=k.strategy||k.level<2?0:k.level<6?1:k.level===6?2:3)<<6,k.strstart!==0&&(W|=32),W+=31-W%31,k.status=L,X(k,W),k.strstart!==0&&(X(k,h.adler>>>16),X(k,65535&h.adler)),h.adler=1}if(k.status===69)if(k.gzhead.extra){for(S=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending!==k.pending_buf_size));)ee(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(k.status===73)if(k.gzhead.name){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending===k.pending_buf_size)){M=1;break}M=k.gzindexS&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),M===0&&(k.gzindex=0,k.status=91)}else k.status=91;if(k.status===91)if(k.gzhead.comment){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending===k.pending_buf_size)){M=1;break}M=k.gzindexS&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),M===0&&(k.status=103)}else k.status=103;if(k.status===103&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&A(h),k.pending+2<=k.pending_buf_size&&(ee(k,255&h.adler),ee(k,h.adler>>8&255),h.adler=0,k.status=L)):k.status=L),k.pending!==0){if(A(h),h.avail_out===0)return k.last_flush=-1,u}else if(h.avail_in===0&&N($)<=N(V)&&$!==y)return J(h,-5);if(k.status===666&&h.avail_in!==0)return J(h,-5);if(h.avail_in!==0||k.lookahead!==0||$!==p&&k.status!==666){var H=k.strategy===2?function(R,G){for(var Q;;){if(R.lookahead===0&&(ce(R),R.lookahead===0)){if(G===p)return v;break}if(R.match_length=0,Q=r._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++,Q&&(z(R,!1),R.strm.avail_out===0))return v}return R.insert=0,G===y?(z(R,!0),R.strm.avail_out===0?te:T):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?v:B}(k,$):k.strategy===3?function(R,G){for(var Q,Y,ne,fe,ue=R.window;;){if(R.lookahead<=U){if(ce(R),R.lookahead<=U&&G===p)return v;if(R.lookahead===0)break}if(R.match_length=0,R.lookahead>=j&&0R.lookahead&&(R.match_length=R.lookahead)}if(R.match_length>=j?(Q=r._tr_tally(R,1,R.match_length-j),R.lookahead-=R.match_length,R.strstart+=R.match_length,R.match_length=0):(Q=r._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++),Q&&(z(R,!1),R.strm.avail_out===0))return v}return R.insert=0,G===y?(z(R,!0),R.strm.avail_out===0?te:T):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?v:B}(k,$):i[k.level].func(k,$);if(H!==te&&H!==T||(k.status=666),H===v||H===te)return h.avail_out===0&&(k.last_flush=-1),u;if(H===B&&($===1?r._tr_align(k):$!==5&&(r._tr_stored_block(k,0,0,!1),$===3&&(K(k.head),k.lookahead===0&&(k.strstart=0,k.block_start=0,k.insert=0))),A(h),h.avail_out===0))return k.last_flush=-1,u}return $!==y?u:k.wrap<=0?1:(k.wrap===2?(ee(k,255&h.adler),ee(k,h.adler>>8&255),ee(k,h.adler>>16&255),ee(k,h.adler>>24&255),ee(k,255&h.total_in),ee(k,h.total_in>>8&255),ee(k,h.total_in>>16&255),ee(k,h.total_in>>24&255)):(X(k,h.adler>>>16),X(k,65535&h.adler)),A(h),0=V.w_size&&(M===0&&(K(V.head),V.strstart=0,V.block_start=0,V.insert=0),G=new a.Buf8(V.w_size),a.arraySet(G,$,Q-V.w_size,V.w_size,0),$=G,Q=V.w_size),W=h.avail_in,H=h.next_in,R=h.input,h.avail_in=Q,h.next_in=0,h.input=$,ce(V);V.lookahead>=j;){for(k=V.strstart,S=V.lookahead-(j-1);V.ins_h=(V.ins_h<>>=j=D>>>24,_-=j,(j=D>>>16&255)===0)B[f++]=65535&D;else{if(!(16&j)){if(!(64&j)){D=C[(65535&D)+(w&(1<>>=j,_-=j),_<15&&(w+=v[s++]<<_,_+=8,w+=v[s++]<<_,_+=8),D=I[w&E];n:for(;;){if(w>>>=j=D>>>24,_-=j,!(16&(j=D>>>16&255))){if(!(64&j)){D=I[(65535&D)+(w&(1<>>=j,_-=j,(j=f-p)>3,w&=(1<<(_-=U<<3))-1,i.next_in=s,i.next_out=f,i.avail_in=s>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(O){var L;return O&&O.state?(L=O.state,O.total_in=O.total_out=L.total=0,O.msg="",L.wrap&&(O.adler=1&L.wrap),L.mode=g,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(d),L.distcode=L.distdyn=new i.Buf32(b),L.sane=1,L.back=-1,y):u}function C(O){var L;return O&&O.state?((L=O.state).wsize=0,L.whave=0,L.wnext=0,_(O)):u}function I(O,L){var v,B;return O&&O.state?(B=O.state,L<0?(v=0,L=-L):(v=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15=T.wsize?(i.arraySet(T.window,L,v-T.wsize,T.wsize,0),T.wnext=0,T.whave=T.wsize):(B<(te=T.wsize-T.wnext)&&(te=B),i.arraySet(T.window,L,v-B,te,T.wnext),(B-=te)?(i.arraySet(T.window,L,v-B,B,0),T.wnext=B,T.whave=T.wsize):(T.wnext+=te,T.wnext===T.wsize&&(T.wnext=0),T.whave>>8&255,v.check=r(v.check,M,2,0),z=A=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&A)<<8)+(A>>8))%31){O.msg="incorrect header check",v.mode=30;break}if((15&A)!=8){O.msg="unknown compression method",v.mode=30;break}if(z-=4,h=8+(15&(A>>>=4)),v.wbits===0)v.wbits=h;else if(h>v.wbits){O.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(M[0]=255&A,M[1]=A>>>8&255,v.check=r(v.check,M,2,0)),z=A=0,v.mode=3;case 3:for(;z<32;){if(N===0)break e;N--,A+=B[T++]<>>8&255,M[2]=A>>>16&255,M[3]=A>>>24&255,v.check=r(v.check,M,4,0)),z=A=0,v.mode=4;case 4:for(;z<16;){if(N===0)break e;N--,A+=B[T++]<>8),512&v.flags&&(M[0]=255&A,M[1]=A>>>8&255,v.check=r(v.check,M,2,0)),z=A=0,v.mode=5;case 5:if(1024&v.flags){for(;z<16;){if(N===0)break e;N--,A+=B[T++]<>>8&255,v.check=r(v.check,M,2,0)),z=A=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(N<(Z=v.length)&&(Z=N),Z&&(v.head&&(h=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),i.arraySet(v.head.extra,B,T,Z,h)),512&v.flags&&(v.check=r(v.check,B,Z,T)),N-=Z,T+=Z,v.length-=Z),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(N===0)break e;for(Z=0;h=B[T+Z++],v.head&&h&&v.length<65536&&(v.head.name+=String.fromCharCode(h)),h&&Z>9&1,v.head.done=!0),O.adler=v.check=0,v.mode=12;break;case 10:for(;z<32;){if(N===0)break e;N--,A+=B[T++]<>>=7&z,z-=7&z,v.mode=27;break}for(;z<3;){if(N===0)break e;N--,A+=B[T++]<>>=1)){case 0:v.mode=14;break;case 1:if(U(v),v.mode=20,L!==6)break;A>>>=2,z-=2;break e;case 2:v.mode=17;break;case 3:O.msg="invalid block type",v.mode=30}A>>>=2,z-=2;break;case 14:for(A>>>=7&z,z-=7&z;z<32;){if(N===0)break e;N--,A+=B[T++]<>>16^65535)){O.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&A,z=A=0,v.mode=15,L===6)break e;case 15:v.mode=16;case 16:if(Z=v.length){if(N>>=5,z-=5,v.ndist=1+(31&A),A>>>=5,z-=5,v.ncode=4+(15&A),A>>>=4,z-=4,286>>=3,z-=3}for(;v.have<19;)v.lens[W[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,V={bits:v.lenbits},$=c(0,v.lens,0,19,v.lencode,0,v.work,V),v.lenbits=V.bits,$){O.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=se,z-=se,v.lens[v.have++]=ge;else{if(ge===16){for(k=se+2;z>>=se,z-=se,v.have===0){O.msg="invalid bit length repeat",v.mode=30;break}h=v.lens[v.have-1],Z=3+(3&A),A>>>=2,z-=2}else if(ge===17){for(k=se+3;z>>=se)),A>>>=3,z-=3}else{for(k=se+7;z>>=se)),A>>>=7,z-=7}if(v.have+Z>v.nlen+v.ndist){O.msg="invalid bit length repeat",v.mode=30;break}for(;Z--;)v.lens[v.have++]=h}}if(v.mode===30)break;if(v.lens[256]===0){O.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,V={bits:v.lenbits},$=c(f,v.lens,0,v.nlen,v.lencode,0,v.work,V),v.lenbits=V.bits,$){O.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,V={bits:v.distbits},$=c(p,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,V),v.distbits=V.bits,$){O.msg="invalid distances set",v.mode=30;break}if(v.mode=20,L===6)break e;case 20:v.mode=21;case 21:if(6<=N&&258<=K){O.next_out=J,O.avail_out=K,O.next_in=T,O.avail_in=N,v.hold=A,v.bits=z,s(O,X),J=O.next_out,te=O.output,K=O.avail_out,T=O.next_in,B=O.input,N=O.avail_in,A=v.hold,z=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;le=(S=v.lencode[A&(1<>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>pe)])>>>16&255,ge=65535&S,!(pe+(se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=pe,z-=pe,v.back+=pe}if(A>>>=se,z-=se,v.back+=se,v.length=ge,le===0){v.mode=26;break}if(32&le){v.back=-1,v.mode=12;break}if(64&le){O.msg="invalid literal/length code",v.mode=30;break}v.extra=15&le,v.mode=22;case 22:if(v.extra){for(k=v.extra;z>>=v.extra,z-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;le=(S=v.distcode[A&(1<>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>pe)])>>>16&255,ge=65535&S,!(pe+(se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=pe,z-=pe,v.back+=pe}if(A>>>=se,z-=se,v.back+=se,64&le){O.msg="invalid distance code",v.mode=30;break}v.offset=ge,v.extra=15&le,v.mode=24;case 24:if(v.extra){for(k=v.extra;z>>=v.extra,z-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){O.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(K===0)break e;if(Z=X-K,v.offset>Z){if((Z=v.offset-Z)>v.whave&&v.sane){O.msg="invalid distance too far back",v.mode=30;break}ce=Z>v.wnext?(Z-=v.wnext,v.wsize-Z):v.wnext-Z,Z>v.length&&(Z=v.length),he=v.window}else he=te,ce=J-v.offset,Z=v.length;for(KE?(j=ce[he+b[L]],z[ee+b[L]]):(j=96,0),w=1<>J)+(_-=w)]=D<<24|j<<16|U|0,_!==0;);for(w=1<>=1;if(w!==0?(A&=w-1,A+=w):A=0,L++,--X[O]==0){if(O===B)break;O=p[y+b[L]]}if(te>>7)]}function ee(S,M){S.pending_buf[S.pending++]=255&M,S.pending_buf[S.pending++]=M>>>8&255}function X(S,M,W){S.bi_valid>m-W?(S.bi_buf|=M<>m-S.bi_valid,S.bi_valid+=W-m):(S.bi_buf|=M<>>=1,W<<=1,0<--M;);return W>>>1}function he(S,M,W){var H,R,G=new Array(b+1),Q=0;for(H=1;H<=b;H++)G[H]=Q=Q+W[H-1]<<1;for(R=0;R<=M;R++){var Y=S[2*R+1];Y!==0&&(S[2*R]=ce(G[Y]++,Y))}}function se(S){var M;for(M=0;M>1;1<=W;W--)pe(S,G,W);for(R=ne;W=S.heap[1],S.heap[1]=S.heap[S.heap_len--],pe(S,G,1),H=S.heap[1],S.heap[--S.heap_max]=W,S.heap[--S.heap_max]=H,G[2*R]=G[2*W]+G[2*H],S.depth[R]=(S.depth[W]>=S.depth[H]?S.depth[W]:S.depth[H])+1,G[2*W+1]=G[2*H+1]=R,S.heap[1]=R++,pe(S,G,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(ue,Ee){var qe,ze,Je,ve,st,zt,Ae=Ee.dyn_tree,un=Ee.max_code,Vr=Ee.stat_desc.static_tree,Br=Ee.stat_desc.has_stree,Nr=Ee.stat_desc.extra_bits,cn=Ee.stat_desc.extra_base,Qe=Ee.stat_desc.max_length,lt=0;for(ve=0;ve<=b;ve++)ue.bl_count[ve]=0;for(Ae[2*ue.heap[ue.heap_max]+1]=0,qe=ue.heap_max+1;qe>=7;R>>=1)if(1&fe&&Y.dyn_ltree[2*ne]!==0)return a;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return r;for(ne=32;ne>>3,(G=S.static_len+3+7>>>3)<=R&&(R=G)):R=G=W+5,W+4<=R&&M!==-1?k(S,M,W,H):S.strategy===4||G===R?(X(S,2+(H?1:0),3),Ce(S,q,O)):(X(S,4+(H?1:0),3),function(Y,ne,fe,ue){var Ee;for(X(Y,ne-257,5),X(Y,fe-1,5),X(Y,ue-4,4),Ee=0;Ee>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&M,S.pending_buf[S.l_buf+S.last_lit]=255&W,S.last_lit++,M===0?S.dyn_ltree[2*W]++:(S.matches++,M--,S.dyn_ltree[2*(v[W]+p+1)]++,S.dyn_dtree[2*z(M)]++),S.last_lit===S.lit_bufsize-1},t._tr_align=function(S){X(S,2,3),Z(S,_,q),function(M){M.bi_valid===16?(ee(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):8<=M.bi_valid&&(M.pending_buf[M.pending++]=255&M.bi_buf,M.bi_buf>>=8,M.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,o,t){o.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,o,t){(function(i){(function(a,r){if(!a.setImmediate){var s,c,f,p,y=1,u={},g=!1,d=a.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(a);b=b&&b.setTimeout?b:a,s={}.toString.call(a.process)==="[object process]"?function(C){process.nextTick(function(){w(C)})}:function(){if(a.postMessage&&!a.importScripts){var C=!0,I=a.onmessage;return a.onmessage=function(){C=!1},a.postMessage("","*"),a.onmessage=I,C}}()?(p="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",_,!1):a.attachEvent("onmessage",_),function(C){a.postMessage(p+C,"*")}):a.MessageChannel?((f=new MessageChannel).port1.onmessage=function(C){w(C.data)},function(C){f.port2.postMessage(C)}):d&&"onreadystatechange"in d.createElement("script")?(c=d.documentElement,function(C){var I=d.createElement("script");I.onreadystatechange=function(){w(C),I.onreadystatechange=null,c.removeChild(I),I=null},c.appendChild(I)}):function(C){setTimeout(w,0,C)},b.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var I=new Array(arguments.length-1),P=0;P"u"?i===void 0?this:i:self)}).call(this,typeof ut<"u"?ut:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ir);var ta=ir.exports;const na=Wr(ta),ar=async l=>{var t;const e=`ComfyUI workspace workflows ${Yn(Date.now())}`,n=new na,o=await((t=ye)==null?void 0:t.getSetting("twoWaySync"));for(const i of l){let a;o?a=i.parentFolderID??"":a=await oi(i.parentFolderID??null).then(async s=>si(s??""));const r=n.folder(a);r==null||r.file(`${i.name}.json`,i.json)}n.generateAsync({type:"blob"}).then(function(i){const a=document.createElement("a");a.href=window.URL.createObjectURL(i),a.download=`${e}.zip`,document.body.appendChild(a),a.click(),document.body.removeChild(a)})};function ra(){const[l,e]=F.useState(!1),[n,o]=F.useState(""),{showDialog:t}=$n(),i=()=>{var r;(r=ye)==null||r.getSettings().then(s=>{o((s==null?void 0:s.myWorkflowsDir)??"undefined"),e(!!(s!=null&&s.twoWaySync))})};F.useEffect(()=>{i()},[]);const a=async r=>{var c,f;if(!r.target.checked){await((c=ye)==null?void 0:c.upsert({twoWaySync:r.target.checked})),i();return}const s=await((f=ye)==null?void 0:f.getSetting("myWorkflowsDir"));t(x.jsx(ia,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var p;await((p=ye)==null?void 0:p.upsert({twoWaySync:!0})),i()}}])};return x.jsxs(Le,{children:[x.jsxs(Oe,{children:["If enabled, your workflows will be synced to and from ",x.jsx("b",{children:n}),x.jsx("br",{}),"You can manually move files into this folder using File Explorer or Finder to import them into your workspace."]}),x.jsx(ot,{isChecked:l,onChange:a,children:"Enable two way sync (DO NOT USE!! EXPERIMENTAL!)"})]})}function ia({myWorkflowsDir:l}){return x.jsxs(Le,{gap:3,children:[x.jsx("p",{children:"Your workflows will be synced to and from path:"}),x.jsx("p",{children:x.jsx("b",{children:l})}),x.jsxs("p",{children:["Please make sure this path is valid. You can change this path anytime in Settings ",">"," Workspace Save Direcotry"]}),x.jsxs("p",{children:[x.jsx("b",{children:"Please download all your workflows before enabling two way sync!"})," ","So you can manually import some workflows into your my_workflows/ directory on your disk in case something unexpected happens."]}),x.jsx(Se,{colorScheme:"teal",variant:"outline",width:"fit-content",size:"sm",onClick:async()=>{var n;const e=await((n=be)==null?void 0:n.listAll());ar(e??[])},children:"Download All My Workflows"})]})}function vn({settingKey:l,text:e,defaultChecked:n=!1}){const[o,t]=F.useState(n),i=()=>{var a;(a=ye)==null||a.getSetting(l).then(r=>{t(!!r)})};return F.useEffect(()=>{i()},[]),x.jsx(Le,{children:x.jsx(ot,{isChecked:o,onChange:async a=>{var r;await((r=ye)==null?void 0:r.upsert({[l]:a.target.checked})),i()},children:e})})}function aa({onClose:l}){const[e,n]=F.useState(!1),[o,t]=F.useState(!1),[i,a]=F.useState(""),[r,s]=F.useState([]),[c,f]=F.useState([]),[p,y]=F.useState(!1),u=F.useRef(null),g=li();F.useEffect(()=>{var E;(E=ye)==null||E.getSetting("myWorkflowsDir").then(D=>{a(D)})},[]);const d=async E=>{const{dir_path:D="",dir_contents:j=[],error:U=""}=await hn(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),s(i&&i.split("/").filter(j=>!!j)||[]))},m=()=>{t(!1),n(!1),s([])},w=async E=>{var q,O,L;if(E){const{error:v=""}=await hn(E);if(v.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((q=ye)==null?void 0:q.upsert({myWorkflowsDir:D}));const j=await((O=ye)==null?void 0:O.getSetting("myWorkflowsDir"))??"";a(j),E&&y(!1),m(),await((L=ye)==null?void 0:L.getSetting("twoWaySync"))||ci()},_=async()=>{const{dirPath:E,dirList:D}=await d("");s(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),s((O=j.slice(1))==null?void 0:O.split("/")))},I=()=>{t(!0),n(!0)},P=x.jsxs(de,{textAlign:"end",mb:4,children:[x.jsx(it,{placeholder:"Please enter the absolute path directory address",ref:u,mt:2,mb:2}),x.jsx(Se,{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 x.jsxs(x.Fragment,{children:[x.jsxs(vt,{isOpen:!0,onClose:l,size:"xl",children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Settings"}),x.jsx(wt,{}),x.jsx(xt,{pb:14,children:x.jsx(we,{children:x.jsxs(pn,{divider:x.jsx(ui,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[x.jsxs(de,{mb:4,children:[x.jsx(Oe,{mb:2,fontWeight:500,children:"Workspace Save Directory"}),o?e?P:x.jsxs(pn,{spacing:2,alignItems:"start",children:[x.jsx(Le,{spacing:"2px",direction:"row",wrap:"wrap",children:r.map((E,D)=>x.jsxs(x.Fragment,{children:["/",x.jsx(Se,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{C(D)},children:E},`${E}-${D}`)]}))}),x.jsx(Di,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((E,D)=>x.jsx(Se,{size:"sm",leftIcon:x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:x.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}`))}),x.jsxs(de,{w:"100%",textAlign:"end",children:[x.jsx(Se,{colorScheme:"teal",size:"sm",onClick:()=>{w()},children:"Save"}),x.jsx(Se,{size:"sm",onClick:_,mr:2,ml:2,children:"Reset"}),x.jsx(Se,{size:"sm",onClick:m,children:"Cancel"})]})]}):x.jsxs(nt,{children:[x.jsx(qn,{overflowWrap:"anywhere",children:i}),x.jsx(Fe,{label:"Choose folder",children:x.jsx(xe,{"aria-label":"Select folder",size:"sm",ml:2,icon:x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:x.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})}),x.jsx(Fe,{label:"Input absolute path",children:x.jsx(xe,{"aria-label":"Enter folder address",size:"sm",ml:2,icon:x.jsx(Ui,{size:19}),onClick:I,variant:"ghost"})})]})]}),x.jsx(Qi,{}),x.jsx(vn,{settingKey:"autoSave",text:"Enable auto save workflow"}),x.jsx(ra,{}),x.jsx(ea,{}),x.jsx(vn,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"})]})})})]})]}),x.jsxs(vt,{isOpen:p,onClose:()=>y(!1),size:"xl",children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Kind tips"}),x.jsx(wt,{}),x.jsx(xt,{children:x.jsxs(de,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?x.jsxs(Oe,{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",x.jsx(Se,{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."]}):x.jsx(Oe,{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 Rt=16;function oa({}){const[l,e]=F.useState(!1),[n,o]=F.useState(!1),{colorMode:t,toggleColorMode:i}=qt();return x.jsxs(x.Fragment,{children:[x.jsxs(Xe,{isLazy:!0,children:[x.jsx(jt,{as:xe,"aria-label":"Options",icon:x.jsx(Zi,{}),size:"sm",variant:"outline"}),x.jsxs(at,{children:[x.jsx(Re,{onClick:()=>o(!0),icon:x.jsx(Xi,{size:16}),fontSize:16,children:"Settings"}),x.jsx(Re,{onClick:()=>e(!0),icon:x.jsx(rr,{size:Rt}),fontSize:16,children:"Manage Tags"}),x.jsxs(Re,{onClick:i,icon:t==="light"?x.jsx(Gi,{size:Rt}):x.jsx(qi,{size:Rt}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),l&&x.jsx(Ji,{onclose:()=>e(!1)}),n&&x.jsx(aa,{onClose:()=>o(!1)})]})}function sa(l){const{multipleState:e,changeMultipleState:n,selectedKeys:o,isSelectedAll:t,batchOperationCallback:i}=l,a=async()=>{var c;const s=await((c=be)==null?void 0:c.batchQuery(o))??[];ar(s)},r=o.length===0;return x.jsx(we,{spacing:2,wrap:"wrap",mb:0,children:e?x.jsxs(x.Fragment,{children:[x.jsx(ot,{isChecked:t,onChange:s=>{i("selectAll",s.target.checked)}}),x.jsx(Fe,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:x.jsx(xe,{isDisabled:r,"aria-label":"Batch export",size:"sm",icon:x.jsx(di,{size:21}),onClick:a})}),x.jsx(Fe,{hasArrow:!0,label:"Batch deletion",children:x.jsx(Kn,{isDisabled:r,variant:"solid",promptMessage:`Are you sure you want to delete these ${o.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=be)==null?void 0:s.batchDeleteFlow(o)),i("batchDelete")}})}),o.length>0&&x.jsx(Oe,{fontWeight:600,children:`Selected ${o.length}`}),x.jsx(Fe,{hasArrow:!0,label:"Exit multi-select",children:x.jsx(xe,{"aria-label":"Close multi-select operation",size:"sm",icon:x.jsx(Qt,{}),onClick:()=>{n(!1)}})})]}):x.jsx(Fe,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:x.jsx(xe,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:x.jsx(Hi,{size:21}),onClick:()=>{n(!0)}})})})}const la=(l,e)=>{const[n,o]=F.useState(l);return F.useEffect(()=>{const t=setTimeout(()=>{o(l)},e);return()=>{clearTimeout(t)}},[l,e]),n},ua={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function ca(l){const{searchValue:e,onUpdateSearchValue:n}=l,o=e!=="";return x.jsxs(de,{style:{position:"relative"},mb:2,children:[x.jsx(Ki,{style:ua}),o&&x.jsx(xe,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:x.jsx(Qt,{width:15,height:15}),onClick:()=>n(""),"aria-label":"clear input button"}),x.jsx(it,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:t})=>n(t.value)})]})}const gn=6;function da({setSelectedTag:l,selectedTag:e}){const[n,o]=F.useState(!1),[t,i]=F.useState([]);return F.useEffect(()=>{var a;(a=We)==null||a.listAll().then(r=>{i(r)})},[]),x.jsxs(we,{spacing:2,wrap:"wrap",mb:0,children:[e!=null&&x.jsx(xe,{"aria-label":"Close",size:"sm",icon:x.jsx(Qt,{}),onClick:()=>{l(void 0)}}),t.slice(0,n?void 0:gn).map(a=>x.jsx(Se,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{l(a.name)},isActive:e===a.name,children:a.name},a.name)),(t.length??0)>gn&&x.jsx(xe,{"aria-label":"Show-all-tags",size:"sm",icon:n?x.jsx($i,{}):x.jsx(en,{}),onClick:()=>o(!n)})]})}function or({parentFolderID:l,onlyImportFile:e=!1}){const{onRefreshFilesList:n}=F.useContext(Be),[o,t]=F.useState("file"),i=F.useRef(null),a=f=>{var p;t(f),f==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(p=i.current)==null||p.click()},r=async f=>{var p;if(f.type==="image/png"){const y=await zi(f),u=y==null?void 0:y.workflow;if(u)return{json:u,name:f.name.replace(".png","")}}else if(f.type==="application/json"||(p=f.name)!=null&&p.endsWith(".json"))return await new Promise((y,u)=>{const g=new FileReader;g.onload=d=>{var b;try{const m=(b=d.target)==null?void 0:b.result;typeof m=="string"?y({json:m,name:f.name.replace(".json","")}):u(new Error("File content is not a string"))}catch(m){u(m)}},g.onerror=u,g.readAsText(f)});return null},s=async f=>{var y,u;const p=[f];for(;p.length>0;){const g=p.shift();if(g&&!g.isFile){const d=await((y=Ve)==null?void 0:y.create({name:g.name,parentFolderID:g.parentFolderID}));if(g.children&&g.children.length){const b=[];g.children.forEach(m=>{m.isFile&&m.file?b.push(m.file):(m.parentFolderID=d==null?void 0:d.id,p.push(m))}),b.length&&await((u=be)==null?void 0:u.batchCreateFlows(b,void 0,d==null?void 0:d.id))}}}n==null||n()},c=async f=>{var y;const p=f.target.files;if(p)if(o==="folder"){const u={name:p[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const g of p)if(g.name!==".DS_Store"){const d=g.webkitRelativePath.split("/");let b=u.children??[];for(let m=1;mC.name===w);if(!_){if(_={name:w,isFile:m===d.length-1,children:m===d.length-1?void 0:[]},_.isFile){const C=await r(g);C&&(_.file=C)}b.push(_)}_&&!_.isFile&&(b=_.children)}}s(u)}else{const u=[];for(const g of p){const d=await r(g);d&&u.push(d)}u.length&&(await((y=be)==null?void 0:y.batchCreateFlows(u,void 0,l)),n&&n())}};return x.jsxs(x.Fragment,{children:[e?x.jsx(Re,{onClick:f=>{f.stopPropagation(),a("file")},icon:x.jsx(mn,{size:19}),children:"Import workflows"}):x.jsxs(Xe,{closeOnSelect:!0,children:[x.jsx(jt,{as:Se,leftIcon:x.jsx(mn,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),x.jsx(at,{children:hi.map((f,p)=>x.jsx(Re,{onClick:()=>{a(f.type)},iconSpacing:2,icon:f.type==="folder"?x.jsx(Xn,{size:18}):x.jsx(Wi,{size:18}),children:f.title},p))})]}),x.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:c,onClick:f=>{f.stopPropagation()}})]})}function ha({folder:l,onclose:e}){const[n,o]=F.useState(l.name),[t,i]=F.useState(""),{onRefreshFilesList:a}=F.useContext(Be),r=c=>{o(c.target.value),t&&i("")},s=async()=>{var p,y;const c=n.trim();if(o(c),c===l.name)return e();await((p=Ve)==null?void 0:p.generateUniqueName(c,l.parentFolderID??""))!==c?i("The name is duplicated, please modify it and submit again."):(await((y=Ve)==null?void 0:y.update(l.id,{name:c})),a&&a(),e())};return x.jsxs(vt,{isOpen:!0,onClose:e,children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Edit folder name"}),x.jsx(wt,{}),x.jsx(xt,{children:x.jsxs(fi,{isInvalid:!!t,children:[x.jsx(pi,{children:"Folder name"}),x.jsx(it,{value:n,onChange:r,autoFocus:!0,onKeyUp:c=>{c.code==="Enter"&&!t&&n&&s()}}),t&&x.jsx(mi,{children:t})]})}),x.jsxs(Hr,{children:[x.jsx(Se,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!n||!!t,children:"Save"}),x.jsx(Se,{onClick:e,children:"Cancel"})]})]})]})}function fa({menuPosition:l,isopen:e,folder:n,onClose:o}){const[t,i]=F.useState(!1),{onRefreshFilesList:a}=F.useContext(Be),{showDialog:r}=$n(),s=async y=>{var u;y.stopPropagation(),await((u=Ve)==null?void 0:u.create({name:"New Folder",parentFolderID:n.id})),a&&a()},c=async y=>{var u;y.stopPropagation(),await((u=be)==null?void 0:u.createFlow({json:JSON.stringify(vi),parentFolderID:n.id})),a&&a()},f=async y=>{y.stopPropagation();const u=await gi(n.id);r(`Do you want to delete the ${u} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{p(bi.DELETE)}}])},p=async y=>{var u;await((u=Ve)==null?void 0:u.deleteFolder(n.id,y)),o(),a&&a()};return x.jsxs(x.Fragment,{children:[x.jsx(de,{position:"absolute",top:l.y,left:l.x,children:x.jsx(Xe,{isOpen:e,onClose:o,isLazy:!0,lazyBehavior:"keepMounted",children:x.jsxs(at,{children:[x.jsx(Re,{icon:x.jsx(Yi,{size:19}),onClick:y=>{y.preventDefault(),y.stopPropagation(),i(!0)},children:"Rename"}),x.jsx(Re,{icon:x.jsx(Gn,{size:19}),onClick:f,children:"Delete"}),x.jsx(Re,{onClick:s,icon:x.jsx(nr,{size:19}),children:"New folder"}),x.jsx(Re,{onClick:c,icon:x.jsx(tn,{size:19}),children:"New file"}),x.jsx(or,{parentFolderID:n.id,onlyImportFile:!0})]})})}),t&&x.jsx(ha,{folder:n,onclose:()=>i(!1)})]})}const bn=F.memo(function({folder:e}){const[n,o]=F.useState(!1),[t,i]=F.useState(e.isCollapse??!0),[a,r]=F.useState([]),[s,c]=F.useState({x:0,y:0}),[f,p]=F.useState(!1),{colorMode:y}=qt(),{draggingFile:u,setDraggingFile:g,refreshFolderStamp:d,onRefreshFilesList:b}=F.useContext(Be),m=y==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};F.useEffect(()=>{var C;t||(C=be)==null||C.listFolderContent(e.id,window.localStorage.getItem($t)).then(I=>{r(I)})},[e.id,d,t]);const w=C=>{C.preventDefault(),c({x:C.clientX,y:C.clientY}),p(!0)},_=async C=>{var I,P;if(C.preventDefault(),C.stopPropagation(),!u)return o(!1);if(He(u)){if(u.id===e.id)return o(!1);await((I=Ve)==null?void 0:I.update(u.id,{parentFolderID:e.id}))}else He(u)||await((P=be)==null?void 0:P.updateFolder(u.id,{parentFolderID:e.id}));await(b==null?void 0:b()),o(!1)};return F.useEffect(()=>{var C;!!e.isCollapse!==t&&((C=Ve)==null||C.update(e.id,{isCollapse:t}))},[t]),F.useEffect(()=>{var D;const C=(D=be)==null?void 0:D.curWorkflow,I=(C==null?void 0:C.parentFolderID)+"/",P=e.id+"/";I.startsWith(P)&&i(!1)},[]),x.jsxs(Le,{children:[x.jsxs(we,{w:"100%",as:"button",py:1,onClick:()=>{i(!t)},onContextMenu:w,draggable:"true",onDragOver:C=>{C.preventDefault(),C.stopPropagation(),o(!0)},onDragLeave:C=>{C.preventDefault(),C.stopPropagation(),o(!1)},onDragStart:()=>g==null?void 0:g(e),onDrop:_,_hover:m,style:n||f?m:void 0,className:"droppable",children:[x.jsxs(we,{gap:1,children:[t?x.jsx(Fi,{size:20}):x.jsx(en,{size:20}),x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:x.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"})})]}),x.jsx(Oe,{children:e.name})]}),x.jsx(fa,{isopen:f,menuPosition:s,onClose:()=>p(!1),folder:e}),!t&&x.jsx(Le,{ml:4,gap:0,children:x.jsx(Lr,{items:a})})]})});function yn(l,e){var n=Object.keys(l);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(l);e&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(l,t).enumerable})),n.push.apply(n,o)}return n}function re(l){for(var e=1;el.length)&&(e=l.length);for(var n=0,o=new Array(e);n=this.index;s--)c=(c<<8)+this.byteAt(s);return this.index+=r,c},readString:function(r){return i.transformTo("string",this.readData(r))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var r=this.readInt(4);return new Date(Date.UTC(1980+(r>>25&127),(r>>21&15)-1,r>>16&31,r>>11&31,r>>5&63,(31&r)<<1))}},o.exports=a},{"../utils":32}],19:[function(n,o,t){var i=n("./Uint8ArrayReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.readData=function(r){this.checkOffset(r);var s=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,o,t){var i=n("./DataReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.byteAt=function(r){return this.data.charCodeAt(this.zero+r)},a.prototype.lastIndexOfSignature=function(r){return this.data.lastIndexOf(r)-this.zero},a.prototype.readAndCheckSignature=function(r){return r===this.readData(4)},a.prototype.readData=function(r){this.checkOffset(r);var s=this.data.slice(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,o,t){var i=n("./ArrayReader");function a(r){i.call(this,r)}n("../utils").inherits(a,i),a.prototype.readData=function(r){if(this.checkOffset(r),r===0)return new Uint8Array(0);var s=this.data.subarray(this.zero+this.index,this.zero+this.index+r);return this.index+=r,s},o.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,o,t){var i=n("../utils"),a=n("../support"),r=n("./ArrayReader"),s=n("./StringReader"),c=n("./NodeBufferReader"),f=n("./Uint8ArrayReader");o.exports=function(p){var y=i.getTypeOf(p);return i.checkSupport(y),y!=="string"||a.uint8array?y==="nodebuffer"?new c(p):a.uint8array?new f(i.transformTo("uint8array",p)):new r(i.transformTo("array",p)):new s(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,o,t){t.LOCAL_FILE_HEADER="PK",t.CENTRAL_FILE_HEADER="PK",t.CENTRAL_DIRECTORY_END="PK",t.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",t.ZIP64_CENTRAL_DIRECTORY_END="PK",t.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,o,t){var i=n("./GenericWorker"),a=n("../utils");function r(s){i.call(this,"ConvertWorker to "+s),this.destType=s}a.inherits(r,i),r.prototype.processChunk=function(s){this.push({data:a.transformTo(this.destType,s.data),meta:s.meta})},o.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(n,o,t){var i=n("./GenericWorker"),a=n("../crc32");function r(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(r,i),r.prototype.processChunk=function(s){this.streamInfo.crc32=a(s.data,this.streamInfo.crc32||0),this.push(s)},o.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,o,t){var i=n("../utils"),a=n("./GenericWorker");function r(s){a.call(this,"DataLengthProbe for "+s),this.propName=s,this.withStreamInfo(s,0)}i.inherits(r,a),r.prototype.processChunk=function(s){if(s){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+s.data.length}a.prototype.processChunk.call(this,s)},o.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(n,o,t){var i=n("../utils"),a=n("./GenericWorker");function r(s){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,s.then(function(f){c.dataIsReady=!0,c.data=f,c.max=f&&f.length||0,c.type=i.getTypeOf(f),c.isPaused||c._tickAndRepeat()},function(f){c.error(f)})}i.inherits(r,a),r.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var s=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":s=this.data.substring(this.index,c);break;case"uint8array":s=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":s=this.data.slice(this.index,c)}return this.index=c,this.push({data:s,meta:{percent:this.max?this.index/this.max*100:0}})},o.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(n,o,t){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,r){return this._listeners[a].push(r),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,r){if(this._listeners[a])for(var s=0;s "+a:a}},o.exports=i},{}],29:[function(n,o,t){var i=n("../utils"),a=n("./ConvertWorker"),r=n("./GenericWorker"),s=n("../base64"),c=n("../support"),f=n("../external"),p=null;if(c.nodestream)try{p=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(g,d){return new f.Promise(function(b,m){var w=[],_=g._internalType,C=g._outputType,I=g._mimeType;g.on("data",function(P,E){w.push(P),d&&d(E)}).on("error",function(P){w=[],m(P)}).on("end",function(){try{var P=function(E,D,j){switch(E){case"blob":return i.newBlob(i.transformTo("arraybuffer",D),j);case"base64":return s.encode(D);default:return i.transformTo(E,D)}}(C,function(E,D){var j,U=0,q=null,O=0;for(j=0;j"u")t.blob=!1;else{var i=new ArrayBuffer(0);try{t.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),t.blob=a.getBlob("application/zip").size===0}catch{t.blob=!1}}}try{t.nodestream=!!n("readable-stream").Readable}catch{t.nodestream=!1}},{"readable-stream":16}],31:[function(n,o,t){for(var i=n("./utils"),a=n("./support"),r=n("./nodejsUtils"),s=n("./stream/GenericWorker"),c=new Array(256),f=0;f<256;f++)c[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;c[254]=c[254]=1;function p(){s.call(this,"utf-8 decode"),this.leftOver=null}function y(){s.call(this,"utf-8 encode")}t.utf8encode=function(u){return a.nodebuffer?r.newBufferFrom(u,"utf-8"):function(g){var d,b,m,w,_,C=g.length,I=0;for(w=0;w>>6:(b<65536?d[_++]=224|b>>>12:(d[_++]=240|b>>>18,d[_++]=128|b>>>12&63),d[_++]=128|b>>>6&63),d[_++]=128|63&b);return d}(u)},t.utf8decode=function(u){return a.nodebuffer?i.transformTo("nodebuffer",u).toString("utf-8"):function(g){var d,b,m,w,_=g.length,C=new Array(2*_);for(d=b=0;d<_;)if((m=g[d++])<128)C[b++]=m;else if(4<(w=c[m]))C[b++]=65533,d+=w-1;else{for(m&=w===2?31:w===3?15:7;1>10&1023,C[b++]=56320|1023&m)}return C.length!==b&&(C.subarray?C=C.subarray(0,b):C.length=b),i.applyFromCharCode(C)}(u=i.transformTo(a.uint8array?"uint8array":"array",u))},i.inherits(p,s),p.prototype.processChunk=function(u){var g=i.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var d=g;(g=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),g.set(d,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var b=function(w,_){var C;for((_=_||w.length)>w.length&&(_=w.length),C=_-1;0<=C&&(192&w[C])==128;)C--;return C<0||C===0?_:C+c[w[C]]>_?C:_}(g),m=g;b!==g.length&&(a.uint8array?(m=g.subarray(0,b),this.leftOver=g.subarray(b,g.length)):(m=g.slice(0,b),this.leftOver=g.slice(b,g.length))),this.push({data:t.utf8decode(m),meta:u.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:t.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},t.Utf8DecodeWorker=p,i.inherits(y,s),y.prototype.processChunk=function(u){this.push({data:t.utf8encode(u.data),meta:u.meta})},t.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,o,t){var i=n("./support"),a=n("./base64"),r=n("./nodejsUtils"),s=n("./external");function c(d){return d}function f(d,b){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var g,d,b,m=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4>>6:(u<65536?y[b++]=224|u>>>12:(y[b++]=240|u>>>18,y[b++]=128|u>>>12&63),y[b++]=128|u>>>6&63),y[b++]=128|63&u);return y},t.buf2binstring=function(p){return f(p,p.length)},t.binstring2buf=function(p){for(var y=new i.Buf8(p.length),u=0,g=y.length;u>10&1023,w[g++]=56320|1023&d)}return f(w,g)},t.utf8border=function(p,y){var u;for((y=y||p.length)>p.length&&(y=p.length),u=y-1;0<=u&&(192&p[u])==128;)u--;return u<0||u===0?y:u+s[p[u]]>y?u:y}},{"./common":41}],43:[function(n,o,t){o.exports=function(i,a,r,s){for(var c=65535&i|0,f=i>>>16&65535|0,p=0;r!==0;){for(r-=p=2e3>>1:a>>>1;r[s]=a}return r}();o.exports=function(a,r,s,c){var f=i,p=c+s;a^=-1;for(var y=c;y>>8^f[255&(a^r[y])];return-1^a}},{}],46:[function(n,o,t){var i,a=n("../utils/common"),r=n("./trees"),s=n("./adler32"),c=n("./crc32"),f=n("./messages"),p=0,y=4,u=0,g=-2,d=-1,b=4,m=2,w=8,_=9,C=286,I=30,P=19,E=2*C+1,D=15,j=3,U=258,q=U+j+1,O=42,L=113,v=1,B=2,te=3,T=4;function J(h,$){return h.msg=f[$],$}function N(h){return(h<<1)-(4h.avail_out&&(V=h.avail_out),V!==0&&(a.arraySet(h.output,$.pending_buf,$.pending_out,V,h.next_out),h.next_out+=V,$.pending_out+=V,h.total_out+=V,h.avail_out-=V,$.pending-=V,$.pending===0&&($.pending_out=0))}function z(h,$){r._tr_flush_block(h,0<=h.block_start?h.block_start:-1,h.strstart-h.block_start,$),h.block_start=h.strstart,A(h.strm)}function ee(h,$){h.pending_buf[h.pending++]=$}function X(h,$){h.pending_buf[h.pending++]=$>>>8&255,h.pending_buf[h.pending++]=255&$}function Z(h,$){var V,k,S=h.max_chain_length,M=h.strstart,W=h.prev_length,H=h.nice_match,R=h.strstart>h.w_size-q?h.strstart-(h.w_size-q):0,G=h.window,Q=h.w_mask,Y=h.prev,ne=h.strstart+U,fe=G[M+W-1],ue=G[M+W];h.prev_length>=h.good_match&&(S>>=2),H>h.lookahead&&(H=h.lookahead);do if(G[(V=$)+W]===ue&&G[V+W-1]===fe&&G[V]===G[M]&&G[++V]===G[M+1]){M+=2,V++;do;while(G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&G[++M]===G[++V]&&MR&&--S!=0);return W<=h.lookahead?W:h.lookahead}function ce(h){var $,V,k,S,M,W,H,R,G,Q,Y=h.w_size;do{if(S=h.window_size-h.lookahead-h.strstart,h.strstart>=Y+(Y-q)){for(a.arraySet(h.window,h.window,Y,Y,0),h.match_start-=Y,h.strstart-=Y,h.block_start-=Y,$=V=h.hash_size;k=h.head[--$],h.head[$]=Y<=k?k-Y:0,--V;);for($=V=Y;k=h.prev[--$],h.prev[$]=Y<=k?k-Y:0,--V;);S+=Y}if(h.strm.avail_in===0)break;if(W=h.strm,H=h.window,R=h.strstart+h.lookahead,G=S,Q=void 0,Q=W.avail_in,G=j)for(M=h.strstart-h.insert,h.ins_h=h.window[M],h.ins_h=(h.ins_h<=j&&(h.ins_h=(h.ins_h<=j)if(k=r._tr_tally(h,h.strstart-h.match_start,h.match_length-j),h.lookahead-=h.match_length,h.match_length<=h.max_lazy_match&&h.lookahead>=j){for(h.match_length--;h.strstart++,h.ins_h=(h.ins_h<=j&&(h.ins_h=(h.ins_h<=j&&h.match_length<=h.prev_length){for(S=h.strstart+h.lookahead-j,k=r._tr_tally(h,h.strstart-1-h.prev_match,h.prev_length-j),h.lookahead-=h.prev_length-1,h.prev_length-=2;++h.strstart<=S&&(h.ins_h=(h.ins_h<h.pending_buf_size-5&&(V=h.pending_buf_size-5);;){if(h.lookahead<=1){if(ce(h),h.lookahead===0&&$===p)return v;if(h.lookahead===0)break}h.strstart+=h.lookahead,h.lookahead=0;var k=h.block_start+V;if((h.strstart===0||h.strstart>=k)&&(h.lookahead=h.strstart-k,h.strstart=k,z(h,!1),h.strm.avail_out===0)||h.strstart-h.block_start>=h.w_size-q&&(z(h,!1),h.strm.avail_out===0))return v}return h.insert=0,$===y?(z(h,!0),h.strm.avail_out===0?te:T):(h.strstart>h.block_start&&(z(h,!1),h.strm.avail_out),v)}),new le(4,4,8,4,he),new le(4,5,16,8,he),new le(4,6,32,32,he),new le(4,4,16,16,se),new le(8,16,32,32,se),new le(8,16,128,128,se),new le(8,32,128,256,se),new le(32,128,258,1024,se),new le(32,258,258,4096,se)],t.deflateInit=function(h,$){return ke(h,$,w,15,8,0)},t.deflateInit2=ke,t.deflateReset=Ce,t.deflateResetKeep=pe,t.deflateSetHeader=function(h,$){return h&&h.state?h.state.wrap!==2?g:(h.state.gzhead=$,u):g},t.deflate=function(h,$){var V,k,S,M;if(!h||!h.state||5<$||$<0)return h?J(h,g):g;if(k=h.state,!h.output||!h.input&&h.avail_in!==0||k.status===666&&$!==y)return J(h,h.avail_out===0?-5:g);if(k.strm=h,V=k.last_flush,k.last_flush=$,k.status===O)if(k.wrap===2)h.adler=0,ee(k,31),ee(k,139),ee(k,8),k.gzhead?(ee(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),ee(k,255&k.gzhead.time),ee(k,k.gzhead.time>>8&255),ee(k,k.gzhead.time>>16&255),ee(k,k.gzhead.time>>24&255),ee(k,k.level===9?2:2<=k.strategy||k.level<2?4:0),ee(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(ee(k,255&k.gzhead.extra.length),ee(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(h.adler=c(h.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(ee(k,0),ee(k,0),ee(k,0),ee(k,0),ee(k,0),ee(k,k.level===9?2:2<=k.strategy||k.level<2?4:0),ee(k,3),k.status=L);else{var W=w+(k.w_bits-8<<4)<<8;W|=(2<=k.strategy||k.level<2?0:k.level<6?1:k.level===6?2:3)<<6,k.strstart!==0&&(W|=32),W+=31-W%31,k.status=L,X(k,W),k.strstart!==0&&(X(k,h.adler>>>16),X(k,65535&h.adler)),h.adler=1}if(k.status===69)if(k.gzhead.extra){for(S=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending!==k.pending_buf_size));)ee(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(k.status===73)if(k.gzhead.name){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending===k.pending_buf_size)){M=1;break}M=k.gzindexS&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),M===0&&(k.gzindex=0,k.status=91)}else k.status=91;if(k.status===91)if(k.gzhead.comment){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),A(h),S=k.pending,k.pending===k.pending_buf_size)){M=1;break}M=k.gzindexS&&(h.adler=c(h.adler,k.pending_buf,k.pending-S,S)),M===0&&(k.status=103)}else k.status=103;if(k.status===103&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&A(h),k.pending+2<=k.pending_buf_size&&(ee(k,255&h.adler),ee(k,h.adler>>8&255),h.adler=0,k.status=L)):k.status=L),k.pending!==0){if(A(h),h.avail_out===0)return k.last_flush=-1,u}else if(h.avail_in===0&&N($)<=N(V)&&$!==y)return J(h,-5);if(k.status===666&&h.avail_in!==0)return J(h,-5);if(h.avail_in!==0||k.lookahead!==0||$!==p&&k.status!==666){var H=k.strategy===2?function(R,G){for(var Q;;){if(R.lookahead===0&&(ce(R),R.lookahead===0)){if(G===p)return v;break}if(R.match_length=0,Q=r._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++,Q&&(z(R,!1),R.strm.avail_out===0))return v}return R.insert=0,G===y?(z(R,!0),R.strm.avail_out===0?te:T):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?v:B}(k,$):k.strategy===3?function(R,G){for(var Q,Y,ne,fe,ue=R.window;;){if(R.lookahead<=U){if(ce(R),R.lookahead<=U&&G===p)return v;if(R.lookahead===0)break}if(R.match_length=0,R.lookahead>=j&&0R.lookahead&&(R.match_length=R.lookahead)}if(R.match_length>=j?(Q=r._tr_tally(R,1,R.match_length-j),R.lookahead-=R.match_length,R.strstart+=R.match_length,R.match_length=0):(Q=r._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++),Q&&(z(R,!1),R.strm.avail_out===0))return v}return R.insert=0,G===y?(z(R,!0),R.strm.avail_out===0?te:T):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?v:B}(k,$):i[k.level].func(k,$);if(H!==te&&H!==T||(k.status=666),H===v||H===te)return h.avail_out===0&&(k.last_flush=-1),u;if(H===B&&($===1?r._tr_align(k):$!==5&&(r._tr_stored_block(k,0,0,!1),$===3&&(K(k.head),k.lookahead===0&&(k.strstart=0,k.block_start=0,k.insert=0))),A(h),h.avail_out===0))return k.last_flush=-1,u}return $!==y?u:k.wrap<=0?1:(k.wrap===2?(ee(k,255&h.adler),ee(k,h.adler>>8&255),ee(k,h.adler>>16&255),ee(k,h.adler>>24&255),ee(k,255&h.total_in),ee(k,h.total_in>>8&255),ee(k,h.total_in>>16&255),ee(k,h.total_in>>24&255)):(X(k,h.adler>>>16),X(k,65535&h.adler)),A(h),0=V.w_size&&(M===0&&(K(V.head),V.strstart=0,V.block_start=0,V.insert=0),G=new a.Buf8(V.w_size),a.arraySet(G,$,Q-V.w_size,V.w_size,0),$=G,Q=V.w_size),W=h.avail_in,H=h.next_in,R=h.input,h.avail_in=Q,h.next_in=0,h.input=$,ce(V);V.lookahead>=j;){for(k=V.strstart,S=V.lookahead-(j-1);V.ins_h=(V.ins_h<>>=j=D>>>24,_-=j,(j=D>>>16&255)===0)B[f++]=65535&D;else{if(!(16&j)){if(!(64&j)){D=C[(65535&D)+(w&(1<>>=j,_-=j),_<15&&(w+=v[s++]<<_,_+=8,w+=v[s++]<<_,_+=8),D=I[w&E];n:for(;;){if(w>>>=j=D>>>24,_-=j,!(16&(j=D>>>16&255))){if(!(64&j)){D=I[(65535&D)+(w&(1<>>=j,_-=j,(j=f-p)>3,w&=(1<<(_-=U<<3))-1,i.next_in=s,i.next_out=f,i.avail_in=s>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(O){var L;return O&&O.state?(L=O.state,O.total_in=O.total_out=L.total=0,O.msg="",L.wrap&&(O.adler=1&L.wrap),L.mode=g,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(d),L.distcode=L.distdyn=new i.Buf32(b),L.sane=1,L.back=-1,y):u}function C(O){var L;return O&&O.state?((L=O.state).wsize=0,L.whave=0,L.wnext=0,_(O)):u}function I(O,L){var v,B;return O&&O.state?(B=O.state,L<0?(v=0,L=-L):(v=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15=T.wsize?(i.arraySet(T.window,L,v-T.wsize,T.wsize,0),T.wnext=0,T.whave=T.wsize):(B<(te=T.wsize-T.wnext)&&(te=B),i.arraySet(T.window,L,v-B,te,T.wnext),(B-=te)?(i.arraySet(T.window,L,v-B,B,0),T.wnext=B,T.whave=T.wsize):(T.wnext+=te,T.wnext===T.wsize&&(T.wnext=0),T.whave>>8&255,v.check=r(v.check,M,2,0),z=A=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&A)<<8)+(A>>8))%31){O.msg="incorrect header check",v.mode=30;break}if((15&A)!=8){O.msg="unknown compression method",v.mode=30;break}if(z-=4,h=8+(15&(A>>>=4)),v.wbits===0)v.wbits=h;else if(h>v.wbits){O.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(M[0]=255&A,M[1]=A>>>8&255,v.check=r(v.check,M,2,0)),z=A=0,v.mode=3;case 3:for(;z<32;){if(N===0)break e;N--,A+=B[T++]<>>8&255,M[2]=A>>>16&255,M[3]=A>>>24&255,v.check=r(v.check,M,4,0)),z=A=0,v.mode=4;case 4:for(;z<16;){if(N===0)break e;N--,A+=B[T++]<>8),512&v.flags&&(M[0]=255&A,M[1]=A>>>8&255,v.check=r(v.check,M,2,0)),z=A=0,v.mode=5;case 5:if(1024&v.flags){for(;z<16;){if(N===0)break e;N--,A+=B[T++]<>>8&255,v.check=r(v.check,M,2,0)),z=A=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(N<(Z=v.length)&&(Z=N),Z&&(v.head&&(h=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),i.arraySet(v.head.extra,B,T,Z,h)),512&v.flags&&(v.check=r(v.check,B,Z,T)),N-=Z,T+=Z,v.length-=Z),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(N===0)break e;for(Z=0;h=B[T+Z++],v.head&&h&&v.length<65536&&(v.head.name+=String.fromCharCode(h)),h&&Z>9&1,v.head.done=!0),O.adler=v.check=0,v.mode=12;break;case 10:for(;z<32;){if(N===0)break e;N--,A+=B[T++]<>>=7&z,z-=7&z,v.mode=27;break}for(;z<3;){if(N===0)break e;N--,A+=B[T++]<>>=1)){case 0:v.mode=14;break;case 1:if(U(v),v.mode=20,L!==6)break;A>>>=2,z-=2;break e;case 2:v.mode=17;break;case 3:O.msg="invalid block type",v.mode=30}A>>>=2,z-=2;break;case 14:for(A>>>=7&z,z-=7&z;z<32;){if(N===0)break e;N--,A+=B[T++]<>>16^65535)){O.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&A,z=A=0,v.mode=15,L===6)break e;case 15:v.mode=16;case 16:if(Z=v.length){if(N>>=5,z-=5,v.ndist=1+(31&A),A>>>=5,z-=5,v.ncode=4+(15&A),A>>>=4,z-=4,286>>=3,z-=3}for(;v.have<19;)v.lens[W[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,V={bits:v.lenbits},$=c(0,v.lens,0,19,v.lencode,0,v.work,V),v.lenbits=V.bits,$){O.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=se,z-=se,v.lens[v.have++]=ge;else{if(ge===16){for(k=se+2;z>>=se,z-=se,v.have===0){O.msg="invalid bit length repeat",v.mode=30;break}h=v.lens[v.have-1],Z=3+(3&A),A>>>=2,z-=2}else if(ge===17){for(k=se+3;z>>=se)),A>>>=3,z-=3}else{for(k=se+7;z>>=se)),A>>>=7,z-=7}if(v.have+Z>v.nlen+v.ndist){O.msg="invalid bit length repeat",v.mode=30;break}for(;Z--;)v.lens[v.have++]=h}}if(v.mode===30)break;if(v.lens[256]===0){O.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,V={bits:v.lenbits},$=c(f,v.lens,0,v.nlen,v.lencode,0,v.work,V),v.lenbits=V.bits,$){O.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,V={bits:v.distbits},$=c(p,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,V),v.distbits=V.bits,$){O.msg="invalid distances set",v.mode=30;break}if(v.mode=20,L===6)break e;case 20:v.mode=21;case 21:if(6<=N&&258<=K){O.next_out=J,O.avail_out=K,O.next_in=T,O.avail_in=N,v.hold=A,v.bits=z,s(O,X),J=O.next_out,te=O.output,K=O.avail_out,T=O.next_in,B=O.input,N=O.avail_in,A=v.hold,z=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;le=(S=v.lencode[A&(1<>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>pe)])>>>16&255,ge=65535&S,!(pe+(se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=pe,z-=pe,v.back+=pe}if(A>>>=se,z-=se,v.back+=se,v.length=ge,le===0){v.mode=26;break}if(32&le){v.back=-1,v.mode=12;break}if(64&le){O.msg="invalid literal/length code",v.mode=30;break}v.extra=15&le,v.mode=22;case 22:if(v.extra){for(k=v.extra;z>>=v.extra,z-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;le=(S=v.distcode[A&(1<>>16&255,ge=65535&S,!((se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>pe)])>>>16&255,ge=65535&S,!(pe+(se=S>>>24)<=z);){if(N===0)break e;N--,A+=B[T++]<>>=pe,z-=pe,v.back+=pe}if(A>>>=se,z-=se,v.back+=se,64&le){O.msg="invalid distance code",v.mode=30;break}v.offset=ge,v.extra=15&le,v.mode=24;case 24:if(v.extra){for(k=v.extra;z>>=v.extra,z-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){O.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(K===0)break e;if(Z=X-K,v.offset>Z){if((Z=v.offset-Z)>v.whave&&v.sane){O.msg="invalid distance too far back",v.mode=30;break}ce=Z>v.wnext?(Z-=v.wnext,v.wsize-Z):v.wnext-Z,Z>v.length&&(Z=v.length),he=v.window}else he=te,ce=J-v.offset,Z=v.length;for(KE?(j=ce[he+b[L]],z[ee+b[L]]):(j=96,0),w=1<>J)+(_-=w)]=D<<24|j<<16|U|0,_!==0;);for(w=1<>=1;if(w!==0?(A&=w-1,A+=w):A=0,L++,--X[O]==0){if(O===B)break;O=p[y+b[L]]}if(te>>7)]}function ee(S,M){S.pending_buf[S.pending++]=255&M,S.pending_buf[S.pending++]=M>>>8&255}function X(S,M,W){S.bi_valid>m-W?(S.bi_buf|=M<>m-S.bi_valid,S.bi_valid+=W-m):(S.bi_buf|=M<>>=1,W<<=1,0<--M;);return W>>>1}function he(S,M,W){var H,R,G=new Array(b+1),Q=0;for(H=1;H<=b;H++)G[H]=Q=Q+W[H-1]<<1;for(R=0;R<=M;R++){var Y=S[2*R+1];Y!==0&&(S[2*R]=ce(G[Y]++,Y))}}function se(S){var M;for(M=0;M>1;1<=W;W--)pe(S,G,W);for(R=ne;W=S.heap[1],S.heap[1]=S.heap[S.heap_len--],pe(S,G,1),H=S.heap[1],S.heap[--S.heap_max]=W,S.heap[--S.heap_max]=H,G[2*R]=G[2*W]+G[2*H],S.depth[R]=(S.depth[W]>=S.depth[H]?S.depth[W]:S.depth[H])+1,G[2*W+1]=G[2*H+1]=R,S.heap[1]=R++,pe(S,G,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(ue,Ee){var qe,ze,Je,ve,st,zt,Ae=Ee.dyn_tree,un=Ee.max_code,Vr=Ee.stat_desc.static_tree,Br=Ee.stat_desc.has_stree,Nr=Ee.stat_desc.extra_bits,cn=Ee.stat_desc.extra_base,Qe=Ee.stat_desc.max_length,lt=0;for(ve=0;ve<=b;ve++)ue.bl_count[ve]=0;for(Ae[2*ue.heap[ue.heap_max]+1]=0,qe=ue.heap_max+1;qe>=7;R>>=1)if(1&fe&&Y.dyn_ltree[2*ne]!==0)return a;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return r;for(ne=32;ne>>3,(G=S.static_len+3+7>>>3)<=R&&(R=G)):R=G=W+5,W+4<=R&&M!==-1?k(S,M,W,H):S.strategy===4||G===R?(X(S,2+(H?1:0),3),Ce(S,q,O)):(X(S,4+(H?1:0),3),function(Y,ne,fe,ue){var Ee;for(X(Y,ne-257,5),X(Y,fe-1,5),X(Y,ue-4,4),Ee=0;Ee>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&M,S.pending_buf[S.l_buf+S.last_lit]=255&W,S.last_lit++,M===0?S.dyn_ltree[2*W]++:(S.matches++,M--,S.dyn_ltree[2*(v[W]+p+1)]++,S.dyn_dtree[2*z(M)]++),S.last_lit===S.lit_bufsize-1},t._tr_align=function(S){X(S,2,3),Z(S,_,q),function(M){M.bi_valid===16?(ee(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):8<=M.bi_valid&&(M.pending_buf[M.pending++]=255&M.bi_buf,M.bi_buf>>=8,M.bi_valid-=8)}(S)}},{"../utils/common":41}],53:[function(n,o,t){o.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,o,t){(function(i){(function(a,r){if(!a.setImmediate){var s,c,f,p,y=1,u={},g=!1,d=a.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(a);b=b&&b.setTimeout?b:a,s={}.toString.call(a.process)==="[object process]"?function(C){process.nextTick(function(){w(C)})}:function(){if(a.postMessage&&!a.importScripts){var C=!0,I=a.onmessage;return a.onmessage=function(){C=!1},a.postMessage("","*"),a.onmessage=I,C}}()?(p="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",_,!1):a.attachEvent("onmessage",_),function(C){a.postMessage(p+C,"*")}):a.MessageChannel?((f=new MessageChannel).port1.onmessage=function(C){w(C.data)},function(C){f.port2.postMessage(C)}):d&&"onreadystatechange"in d.createElement("script")?(c=d.documentElement,function(C){var I=d.createElement("script");I.onreadystatechange=function(){w(C),I.onreadystatechange=null,c.removeChild(I),I=null},c.appendChild(I)}):function(C){setTimeout(w,0,C)},b.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var I=new Array(arguments.length-1),P=0;P"u"?i===void 0?this:i:self)}).call(this,typeof ut<"u"?ut:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ir);var ta=ir.exports;const na=Wr(ta),ar=async l=>{var t;const e=`ComfyUI workspace workflows ${Kn(Date.now())}`,n=new na,o=await((t=ye)==null?void 0:t.getSetting("twoWaySync"));for(const i of l){let a;o?a=i.parentFolderID??"":a=await oi(i.parentFolderID??null).then(async s=>si(s??""));const r=n.folder(a);r==null||r.file(`${i.name}.json`,i.json)}n.generateAsync({type:"blob"}).then(function(i){const a=document.createElement("a");a.href=window.URL.createObjectURL(i),a.download=`${e}.zip`,document.body.appendChild(a),a.click(),document.body.removeChild(a)})};function ra(){const[l,e]=F.useState(!1),[n,o]=F.useState(""),{showDialog:t}=$n(),i=()=>{var r;(r=ye)==null||r.getSettings().then(s=>{o((s==null?void 0:s.myWorkflowsDir)??"undefined"),e(!!(s!=null&&s.twoWaySync))})};F.useEffect(()=>{i()},[]);const a=async r=>{var c,f;if(!r.target.checked){await((c=ye)==null?void 0:c.upsert({twoWaySync:r.target.checked})),i();return}const s=await((f=ye)==null?void 0:f.getSetting("myWorkflowsDir"));t(x.jsx(ia,{myWorkflowsDir:s??"undefined"}),[{label:"I have downloaded all my workflows and ready to enable",onClick:async()=>{var p;await((p=ye)==null?void 0:p.upsert({twoWaySync:!0})),i()}}])};return x.jsxs(Le,{children:[x.jsxs(Oe,{children:["If enabled, your workflows will be synced to and from ",x.jsx("b",{children:n}),x.jsx("br",{}),"You can manually move files into this folder using File Explorer or Finder to import them into your workspace."]}),x.jsx(ot,{isChecked:l,onChange:a,children:"Enable two way sync (🧪🧪beta)"})]})}function ia({myWorkflowsDir:l}){return x.jsxs(Le,{gap:3,children:[x.jsx("p",{children:"Your workflows will be synced to and from path:"}),x.jsx("p",{children:x.jsx("b",{children:l})}),x.jsxs("p",{children:["Please make sure this path is valid. You can change this path anytime in Settings ",">"," Workspace Save Direcotry"]}),x.jsxs("p",{children:[x.jsx("b",{children:"Please download all your workflows before enabling two way sync!"})," ","So you can manually import some workflows into your my_workflows/ directory on your disk in case something unexpected happens."]}),x.jsx(Se,{colorScheme:"teal",variant:"outline",width:"fit-content",size:"sm",onClick:async()=>{var n;const e=await((n=be)==null?void 0:n.listAll());ar(e??[])},children:"Download All My Workflows"})]})}function vn({settingKey:l,text:e,defaultChecked:n=!1}){const[o,t]=F.useState(n),i=()=>{var a;(a=ye)==null||a.getSetting(l).then(r=>{t(!!r)})};return F.useEffect(()=>{i()},[]),x.jsx(Le,{children:x.jsx(ot,{isChecked:o,onChange:async a=>{var r;await((r=ye)==null?void 0:r.upsert({[l]:a.target.checked})),i()},children:e})})}function aa({onClose:l}){const[e,n]=F.useState(!1),[o,t]=F.useState(!1),[i,a]=F.useState(""),[r,s]=F.useState([]),[c,f]=F.useState([]),[p,y]=F.useState(!1),u=F.useRef(null),g=li();F.useEffect(()=>{var E;(E=ye)==null||E.getSetting("myWorkflowsDir").then(D=>{a(D)})},[]);const d=async E=>{const{dir_path:D="",dir_contents:j=[],error:U=""}=await hn(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),s(i&&i.split("/").filter(j=>!!j)||[]))},m=()=>{t(!1),n(!1),s([])},w=async E=>{var q,O,L;if(E){const{error:v=""}=await hn(E);if(v.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((q=ye)==null?void 0:q.upsert({myWorkflowsDir:D}));const j=await((O=ye)==null?void 0:O.getSetting("myWorkflowsDir"))??"";a(j),E&&y(!1),m(),await((L=ye)==null?void 0:L.getSetting("twoWaySync"))||ci()},_=async()=>{const{dirPath:E,dirList:D}=await d("");s(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),s((O=j.slice(1))==null?void 0:O.split("/")))},I=()=>{t(!0),n(!0)},P=x.jsxs(de,{textAlign:"end",mb:4,children:[x.jsx(it,{placeholder:"Please enter the absolute path directory address",ref:u,mt:2,mb:2}),x.jsx(Se,{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 x.jsxs(x.Fragment,{children:[x.jsxs(vt,{isOpen:!0,onClose:l,size:"xl",children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Settings"}),x.jsx(wt,{}),x.jsx(xt,{pb:14,children:x.jsx(we,{children:x.jsxs(pn,{divider:x.jsx(ui,{borderColor:"gray.500"}),spacing:4,align:"stretch",w:"100%",children:[x.jsxs(de,{mb:4,children:[x.jsx(Oe,{mb:2,fontWeight:500,children:"Workspace Save Directory"}),o?e?P:x.jsxs(pn,{spacing:2,alignItems:"start",children:[x.jsx(Le,{spacing:"2px",direction:"row",wrap:"wrap",children:r.map((E,D)=>x.jsxs(x.Fragment,{children:["/",x.jsx(Se,{colorScheme:"teal",variant:"link",minW:1,onClick:()=>{C(D)},children:E},`${E}-${D}`)]}))}),x.jsx(Di,{columns:2,spacing:3,maxHeight:500,width:"100%",overflowY:"auto",children:c.map((E,D)=>x.jsx(Se,{size:"sm",leftIcon:x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:x.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}`))}),x.jsxs(de,{w:"100%",textAlign:"end",children:[x.jsx(Se,{colorScheme:"teal",size:"sm",onClick:()=>{w()},children:"Save"}),x.jsx(Se,{size:"sm",onClick:_,mr:2,ml:2,children:"Reset"}),x.jsx(Se,{size:"sm",onClick:m,children:"Cancel"})]})]}):x.jsxs(nt,{children:[x.jsx(Gn,{overflowWrap:"anywhere",children:i}),x.jsx(Fe,{label:"Choose folder",children:x.jsx(xe,{"aria-label":"Select folder",size:"sm",ml:2,icon:x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.4rem",height:"1.4srem"},children:x.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})}),x.jsx(Fe,{label:"Input absolute path",children:x.jsx(xe,{"aria-label":"Enter folder address",size:"sm",ml:2,icon:x.jsx(Ui,{size:19}),onClick:I,variant:"ghost"})})]})]}),x.jsx(Qi,{}),x.jsx(vn,{settingKey:"autoSave",text:"Enable auto save workflow"}),x.jsx(ra,{}),x.jsx(ea,{}),x.jsx(vn,{settingKey:"overwriteCurWorkflowWhenDroppingFileToCanvas",text:"Overwrite current workflow when drag and drop workflow file to canvas"})]})})})]})]}),x.jsxs(vt,{isOpen:p,onClose:()=>y(!1),size:"xl",children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Kind tips"}),x.jsx(wt,{}),x.jsx(xt,{children:x.jsxs(de,{children:[navigator.userAgent.indexOf("Mac OS X")!==-1?x.jsxs(Oe,{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",x.jsx(Se,{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."]}):x.jsx(Oe,{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 Rt=16;function oa({}){const[l,e]=F.useState(!1),[n,o]=F.useState(!1),{colorMode:t,toggleColorMode:i}=qt();return x.jsxs(x.Fragment,{children:[x.jsxs(Xe,{isLazy:!0,children:[x.jsx(jt,{as:xe,"aria-label":"Options",icon:x.jsx(Zi,{}),size:"sm",variant:"outline"}),x.jsxs(at,{children:[x.jsx(Re,{onClick:()=>o(!0),icon:x.jsx(Xi,{size:16}),fontSize:16,children:"Settings"}),x.jsx(Re,{onClick:()=>e(!0),icon:x.jsx(rr,{size:Rt}),fontSize:16,children:"Manage Tags"}),x.jsxs(Re,{onClick:i,icon:t==="light"?x.jsx(Gi,{size:Rt}):x.jsx(qi,{size:Rt}),fontSize:16,children:[t==="light"?"Dark":"Light"," Mode"]})]})]}),l&&x.jsx(Ji,{onclose:()=>e(!1)}),n&&x.jsx(aa,{onClose:()=>o(!1)})]})}function sa(l){const{multipleState:e,changeMultipleState:n,selectedKeys:o,isSelectedAll:t,batchOperationCallback:i}=l,a=async()=>{var c;const s=await((c=be)==null?void 0:c.batchQuery(o))??[];ar(s)},r=o.length===0;return x.jsx(we,{spacing:2,wrap:"wrap",mb:0,children:e?x.jsxs(x.Fragment,{children:[x.jsx(ot,{isChecked:t,onChange:s=>{i("selectAll",s.target.checked)}}),x.jsx(Fe,{hasArrow:!0,label:"Download Zip",placement:"bottom",children:x.jsx(xe,{isDisabled:r,"aria-label":"Batch export",size:"sm",icon:x.jsx(di,{size:21}),onClick:a})}),x.jsx(Fe,{hasArrow:!0,label:"Batch deletion",children:x.jsx(Xn,{isDisabled:r,variant:"solid",promptMessage:`Are you sure you want to delete these ${o.length} checked workflows?`,tooltipText:"Delete selected",onDelete:async()=>{var s;await((s=be)==null?void 0:s.batchDeleteFlow(o)),i("batchDelete")}})}),o.length>0&&x.jsx(Oe,{fontWeight:600,children:`Selected ${o.length}`}),x.jsx(Fe,{hasArrow:!0,label:"Exit multi-select",children:x.jsx(xe,{"aria-label":"Close multi-select operation",size:"sm",icon:x.jsx(Qt,{}),onClick:()=>{n(!1)}})})]}):x.jsx(Fe,{hasArrow:!0,label:"Select multiple",placement:"bottom-start",children:x.jsx(xe,{"aria-label":"Start multi-select operation",size:"sm",variant:"outline",icon:x.jsx(Hi,{size:21}),onClick:()=>{n(!0)}})})})}const la=(l,e)=>{const[n,o]=F.useState(l);return F.useEffect(()=>{const t=setTimeout(()=>{o(l)},e);return()=>{clearTimeout(t)}},[l,e]),n},ua={position:"absolute",marginLeft:"10px",width:"20px",height:"20px",top:"50%",color:"#A0AEC0",transform:"translateY(-50%)"};function ca(l){const{searchValue:e,onUpdateSearchValue:n}=l,o=e!=="";return x.jsxs(de,{style:{position:"relative"},mb:2,children:[x.jsx(Ki,{style:ua}),o&&x.jsx(xe,{size:"xs",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"none",zIndex:"100",icon:x.jsx(Qt,{width:15,height:15}),onClick:()=>n(""),"aria-label":"clear input button"}),x.jsx(it,{placeholder:"Search",size:"sm",paddingLeft:"35px",paddingBlock:"5px",value:e,onChange:({target:t})=>n(t.value)})]})}const gn=6;function da({setSelectedTag:l,selectedTag:e}){const[n,o]=F.useState(!1),[t,i]=F.useState([]);return F.useEffect(()=>{var a;(a=We)==null||a.listAll().then(r=>{i(r)})},[]),x.jsxs(we,{spacing:2,wrap:"wrap",mb:0,children:[e!=null&&x.jsx(xe,{"aria-label":"Close",size:"sm",icon:x.jsx(Qt,{}),onClick:()=>{l(void 0)}}),t.slice(0,n?void 0:gn).map(a=>x.jsx(Se,{variant:"solid",width:"auto",flexShrink:0,size:"sm",borderRadius:15,py:4,onClick:()=>{l(a.name)},isActive:e===a.name,children:a.name},a.name)),(t.length??0)>gn&&x.jsx(xe,{"aria-label":"Show-all-tags",size:"sm",icon:n?x.jsx($i,{}):x.jsx(en,{}),onClick:()=>o(!n)})]})}function or({parentFolderID:l,onlyImportFile:e=!1}){const{onRefreshFilesList:n}=F.useContext(Be),[o,t]=F.useState("file"),i=F.useRef(null),a=f=>{var p;t(f),f==="folder"?i.current.setAttribute("webkitdirectory",""):i.current.removeAttribute("webkitdirectory"),(p=i.current)==null||p.click()},r=async f=>{var p;if(f.type==="image/png"){const y=await zi(f),u=y==null?void 0:y.workflow;if(u)return{json:u,name:f.name.replace(".png","")}}else if(f.type==="application/json"||(p=f.name)!=null&&p.endsWith(".json"))return await new Promise((y,u)=>{const g=new FileReader;g.onload=d=>{var b;try{const m=(b=d.target)==null?void 0:b.result;typeof m=="string"?y({json:m,name:f.name.replace(".json","")}):u(new Error("File content is not a string"))}catch(m){u(m)}},g.onerror=u,g.readAsText(f)});return null},s=async f=>{var y,u;const p=[f];for(;p.length>0;){const g=p.shift();if(g&&!g.isFile){const d=await((y=Ve)==null?void 0:y.create({name:g.name,parentFolderID:g.parentFolderID}));if(g.children&&g.children.length){const b=[];g.children.forEach(m=>{m.isFile&&m.file?b.push(m.file):(m.parentFolderID=d==null?void 0:d.id,p.push(m))}),b.length&&await((u=be)==null?void 0:u.batchCreateFlows(b,void 0,d==null?void 0:d.id))}}}n==null||n()},c=async f=>{var y;const p=f.target.files;if(p)if(o==="folder"){const u={name:p[0].webkitRelativePath.split("/")[0],isFile:!1,children:[]};for(const g of p)if(g.name!==".DS_Store"){const d=g.webkitRelativePath.split("/");let b=u.children??[];for(let m=1;mC.name===w);if(!_){if(_={name:w,isFile:m===d.length-1,children:m===d.length-1?void 0:[]},_.isFile){const C=await r(g);C&&(_.file=C)}b.push(_)}_&&!_.isFile&&(b=_.children)}}s(u)}else{const u=[];for(const g of p){const d=await r(g);d&&u.push(d)}u.length&&(await((y=be)==null?void 0:y.batchCreateFlows(u,void 0,l)),n&&n())}};return x.jsxs(x.Fragment,{children:[e?x.jsx(Re,{onClick:f=>{f.stopPropagation(),a("file")},icon:x.jsx(mn,{size:19}),children:"Import workflows"}):x.jsxs(Xe,{closeOnSelect:!0,children:[x.jsx(jt,{as:Se,leftIcon:x.jsx(mn,{size:18}),variant:"outline",iconSpacing:1,size:"sm",colorScheme:"teal",children:"Import"}),x.jsx(at,{children:hi.map((f,p)=>x.jsx(Re,{onClick:()=>{a(f.type)},iconSpacing:2,icon:f.type==="folder"?x.jsx(qn,{size:18}):x.jsx(Wi,{size:18}),children:f.title},p))})]}),x.jsx("input",{style:{display:"none"},ref:i,type:"file",accept:".json,image/png",multiple:!0,onChange:c,onClick:f=>{f.stopPropagation()}})]})}function ha({folder:l,onclose:e}){const[n,o]=F.useState(l.name),[t,i]=F.useState(""),{onRefreshFilesList:a}=F.useContext(Be),r=c=>{o(c.target.value),t&&i("")},s=async()=>{var p,y;const c=n.trim();if(o(c),c===l.name)return e();await((p=Ve)==null?void 0:p.generateUniqueName(c,l.parentFolderID??""))!==c?i("The name is duplicated, please modify it and submit again."):(await((y=Ve)==null?void 0:y.update(l.id,{name:c})),a&&a(),e())};return x.jsxs(vt,{isOpen:!0,onClose:e,children:[x.jsx(gt,{}),x.jsxs(bt,{children:[x.jsx(yt,{children:"Edit folder name"}),x.jsx(wt,{}),x.jsx(xt,{children:x.jsxs(fi,{isInvalid:!!t,children:[x.jsx(pi,{children:"Folder name"}),x.jsx(it,{value:n,onChange:r,autoFocus:!0,onKeyUp:c=>{c.code==="Enter"&&!t&&n&&s()}}),t&&x.jsx(mi,{children:t})]})}),x.jsxs(Hr,{children:[x.jsx(Se,{colorScheme:"teal",mr:3,onClick:s,isDisabled:!n||!!t,children:"Save"}),x.jsx(Se,{onClick:e,children:"Cancel"})]})]})]})}function fa({menuPosition:l,isopen:e,folder:n,onClose:o}){const[t,i]=F.useState(!1),{onRefreshFilesList:a}=F.useContext(Be),{showDialog:r}=$n(),s=async y=>{var u;y.stopPropagation(),await((u=Ve)==null?void 0:u.create({name:"New Folder",parentFolderID:n.id})),a&&a()},c=async y=>{var u;y.stopPropagation(),await((u=be)==null?void 0:u.createFlow({json:JSON.stringify(vi),parentFolderID:n.id})),a&&a()},f=async y=>{y.stopPropagation();const u=await gi(n.id);r(`Do you want to delete the ${u} files inside the folder too?`,[{label:"Delete all files",colorScheme:"red",onClick:()=>{p(bi.DELETE)}}])},p=async y=>{var u;await((u=Ve)==null?void 0:u.deleteFolder(n.id,y)),o(),a&&a()};return x.jsxs(x.Fragment,{children:[x.jsx(de,{position:"absolute",top:l.y,left:l.x,children:x.jsx(Xe,{isOpen:e,onClose:o,isLazy:!0,lazyBehavior:"keepMounted",children:x.jsxs(at,{children:[x.jsx(Re,{icon:x.jsx(Yi,{size:19}),onClick:y=>{y.preventDefault(),y.stopPropagation(),i(!0)},children:"Rename"}),x.jsx(Re,{icon:x.jsx(Yn,{size:19}),onClick:f,children:"Delete"}),x.jsx(Re,{onClick:s,icon:x.jsx(nr,{size:19}),children:"New folder"}),x.jsx(Re,{onClick:c,icon:x.jsx(tn,{size:19}),children:"New file"}),x.jsx(or,{parentFolderID:n.id,onlyImportFile:!0})]})})}),t&&x.jsx(ha,{folder:n,onclose:()=>i(!1)})]})}const bn=F.memo(function({folder:e}){const[n,o]=F.useState(!1),[t,i]=F.useState(e.isCollapse??!0),[a,r]=F.useState([]),[s,c]=F.useState({x:0,y:0}),[f,p]=F.useState(!1),{colorMode:y}=qt(),{draggingFile:u,setDraggingFile:g,refreshFolderStamp:d,onRefreshFilesList:b}=F.useContext(Be),m=y==="light"?{backgroundColor:"#E2E8F0"}:{backgroundColor:"#4A5568"};F.useEffect(()=>{var C;t||(C=be)==null||C.listFolderContent(e.id,window.localStorage.getItem($t)).then(I=>{r(I)})},[e.id,d,t]);const w=C=>{C.preventDefault(),c({x:C.clientX,y:C.clientY}),p(!0)},_=async C=>{var I,P;if(C.preventDefault(),C.stopPropagation(),!u)return o(!1);if(He(u)){if(u.id===e.id)return o(!1);await((I=Ve)==null?void 0:I.update(u.id,{parentFolderID:e.id}))}else He(u)||await((P=be)==null?void 0:P.updateFolder(u.id,{parentFolderID:e.id}));await(b==null?void 0:b()),o(!1)};return F.useEffect(()=>{var C;!!e.isCollapse!==t&&((C=Ve)==null||C.update(e.id,{isCollapse:t}))},[t]),F.useEffect(()=>{var D;const C=(D=be)==null?void 0:D.curWorkflow,I=(C==null?void 0:C.parentFolderID)+"/",P=e.id+"/";I.startsWith(P)&&i(!1)},[]),x.jsxs(Le,{children:[x.jsxs(we,{w:"100%",as:"button",py:1,onClick:()=>{i(!t)},onContextMenu:w,draggable:"true",onDragOver:C=>{C.preventDefault(),C.stopPropagation(),o(!0)},onDragLeave:C=>{C.preventDefault(),C.stopPropagation(),o(!1)},onDragStart:()=>g==null?void 0:g(e),onDrop:_,_hover:m,style:n||f?m:void 0,className:"droppable",children:[x.jsxs(we,{gap:1,children:[t?x.jsx(Fi,{size:20}):x.jsx(en,{size:20}),x.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#EFC54D",style:{width:"1.2rem",height:"1.2rem"},children:x.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"})})]}),x.jsx(Oe,{children:e.name})]}),x.jsx(fa,{isopen:f,menuPosition:s,onClose:()=>p(!1),folder:e}),!t&&x.jsx(Le,{ml:4,gap:0,children:x.jsx(Lr,{items:a})})]})});function yn(l,e){var n=Object.keys(l);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(l);e&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(l,t).enumerable})),n.push.apply(n,o)}return n}function re(l){for(var e=1;el.length)&&(e=l.length);for(var n=0,o=new Array(e);n=0)&&Object.prototype.propertyIsEnumerable.call(l,o)&&(n[o]=l[o])}return n}var ga=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function ba(l){var e=l.defaultInputValue,n=e===void 0?"":e,o=l.defaultMenuIsOpen,t=o===void 0?!1:o,i=l.defaultValue,a=i===void 0?null:i,r=l.inputValue,s=l.menuIsOpen,c=l.onChange,f=l.onInputChange,p=l.onMenuClose,y=l.onMenuOpen,u=l.value,g=Ne(l,ga),d=F.useState(r!==void 0?r:n),b=Te(d,2),m=b[0],w=b[1],_=F.useState(s!==void 0?s:t),C=Te(_,2),I=C[0],P=C[1],E=F.useState(u!==void 0?u:a),D=Te(E,2),j=D[0],U=D[1],q=F.useCallback(function(J,N){typeof c=="function"&&c(J,N),U(J)},[c]),O=F.useCallback(function(J,N){var K;typeof f=="function"&&(K=f(J,N)),w(K!==void 0?K:J)},[f]),L=F.useCallback(function(){typeof y=="function"&&y(),P(!0)},[y]),v=F.useCallback(function(){typeof p=="function"&&p(),P(!1)},[p]),B=r!==void 0?r:m,te=s!==void 0?s:I,T=u!==void 0?u:j;return re(re({},g),{},{inputValue:B,menuIsOpen:te,onChange:q,onInputChange:O,onMenuClose:v,onMenuOpen:L,value:T})}function ya(l,e){if(!(l instanceof e))throw new TypeError("Cannot call a class as a function")}function wn(l,e){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _a(l){if(l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l}function Ca(l,e){if(e&&(Un(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _a(l)}function ka(l){var e=Sa();return function(){var o=St(l),t;if(e){var i=St(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return Ca(this,t)}}function Oa(l){if(Array.isArray(l))return Ut(l)}function Ia(l){if(typeof Symbol<"u"&&l[Symbol.iterator]!=null||l["@@iterator"]!=null)return Array.from(l)}function Ea(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lr(l){return Oa(l)||Ia(l)||sr(l)||Ea()}function Pa(l,e){return e||(e=l.slice(0)),Object.freeze(Object.defineProperties(l,{raw:{value:Object.freeze(e)}}))}const Ma=Math.min,ja=Math.max,_t=Math.round,ht=Math.floor,Ct=l=>({x:l,y:l});function Da(l){return{...l,top:l.y,left:l.x,right:l.x+l.width,bottom:l.y+l.height}}function ur(l){return dr(l)?(l.nodeName||"").toLowerCase():"#document"}function je(l){var e;return(l==null||(e=l.ownerDocument)==null?void 0:e.defaultView)||window}function cr(l){var e;return(e=(dr(l)?l.ownerDocument:l.document)||window.document)==null?void 0:e.documentElement}function dr(l){return l instanceof Node||l instanceof je(l).Node}function Wt(l){return l instanceof Element||l instanceof je(l).Element}function an(l){return l instanceof HTMLElement||l instanceof je(l).HTMLElement}function xn(l){return typeof ShadowRoot>"u"?!1:l instanceof ShadowRoot||l instanceof je(l).ShadowRoot}function hr(l){const{overflow:e,overflowX:n,overflowY:o,display:t}=on(l);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(t)}function za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Fa(l){return["html","body","#document"].includes(ur(l))}function on(l){return je(l).getComputedStyle(l)}function Ra(l){if(ur(l)==="html")return l;const e=l.assignedSlot||l.parentNode||xn(l)&&l.host||cr(l);return xn(e)?e.host:e}function fr(l){const e=Ra(l);return Fa(e)?l.ownerDocument?l.ownerDocument.body:l.body:an(e)&&hr(e)?e:fr(e)}function kt(l,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const t=fr(l),i=t===((o=l.ownerDocument)==null?void 0:o.body),a=je(t);return i?e.concat(a,a.visualViewport||[],hr(t)?t:[],a.frameElement&&n?kt(a.frameElement):[]):e.concat(t,kt(t,[],n))}function Aa(l){const e=on(l);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const t=an(l),i=t?l.offsetWidth:n,a=t?l.offsetHeight:o,r=_t(n)!==i||_t(o)!==a;return r&&(n=i,o=a),{width:n,height:o,$:r}}function sn(l){return Wt(l)?l:l.contextElement}function At(l){const e=sn(l);if(!an(e))return Ct(1);const n=e.getBoundingClientRect(),{width:o,height:t,$:i}=Aa(e);let a=(i?_t(n.width):n.width)/o,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 Ta=Ct(0);function La(l){const e=je(l);return!za()||!e.visualViewport?Ta:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Va(l,e,n){return e===void 0&&(e=!1),!n||e&&n!==je(l)?!1:e}function Sn(l,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const t=l.getBoundingClientRect(),i=sn(l);let a=Ct(1);e&&(o?Wt(o)&&(a=At(o)):a=At(l));const r=Va(i,n,o)?La(i):Ct(0);let s=(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=o&&Wt(o)?je(o):o;let g=y.frameElement;for(;g&&o&&u!==y;){const d=At(g),b=g.getBoundingClientRect(),m=on(g),w=b.left+(g.clientLeft+parseFloat(m.paddingLeft))*d.x,_=b.top+(g.clientTop+parseFloat(m.paddingTop))*d.y;s*=d.x,c*=d.y,f*=d.x,p*=d.y,s+=w,c+=_,g=je(g).frameElement}}return Da({width:f,height:p,x:s,y:c})}function Ba(l,e){let n=null,o;const t=cr(l);function i(){clearTimeout(o),n&&n.disconnect(),n=null}function a(r,s){r===void 0&&(r=!1),s===void 0&&(s=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:ja(0,Ma(1,s))||1};let _=!0;function C(I){const P=I[0].intersectionRatio;if(P!==s){if(!_)return a();P?a(!1,P):o=setTimeout(()=>{a(!1,1e-7)},100)}_=!1}try{n=new IntersectionObserver(C,{...w,root:t.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(l)}return a(!0),i}function Na(l,e,n,o){o===void 0&&(o={});const{ancestorScroll:t=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:s=!1}=o,c=sn(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?Ba(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&&!s&&u.observe(c),u.observe(e));let g,d=s?Sn(l):null;s&&b();function b(){const m=Sn(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,s&&cancelAnimationFrame(g)}}var Ht=F.useLayoutEffect,$a=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],Ot=function(){};function Ua(l,e){return e?e[0]==="-"?l+e:l+"__"+e:l}function Wa(l,e){for(var n=arguments.length,o=new Array(n>2?n-2:0),t=2;t-1}function Ha(l){return Dt(l)?window.innerHeight:l.clientHeight}function mr(l){return Dt(l)?window.pageYOffset:l.scrollTop}function It(l,e){if(Dt(l)){window.scrollTo(0,e);return}l.scrollTop=e}function Za(l){var e=getComputedStyle(l),n=e.position==="absolute",o=/(auto|scroll)/;if(e.position==="fixed")return document.documentElement;for(var t=l;t=t.parentElement;)if(e=getComputedStyle(t),!(n&&e.position==="static")&&o.test(e.overflow+e.overflowY+e.overflowX))return t;return document.documentElement}function Ga(l,e,n,o){return n*((l=l/o-1)*l*l+1)+e}function ft(l,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:200,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ot,t=mr(l),i=e-t,a=10,r=0;function s(){r+=a;var c=Ga(r,t,i,n);It(l,c),rn.bottom?It(l,Math.min(e.offsetTop+e.clientHeight-l.offsetHeight+t,l.scrollHeight)):o.top-t1?n-1:0),t=1;t=g)return{placement:"bottom",maxHeight:e};if(j>=g&&!a)return i&&ft(s,U,O),{placement:"bottom",maxHeight:e};if(!a&&j>=o||a&&E>=o){i&&ft(s,U,O);var L=a?E-C:j-C;return{placement:"bottom",maxHeight:L}}if(t==="auto"||a){var v=e,B=a?P:D;return B>=o&&(v=Math.min(B-C-r,e)),{placement:"top",maxHeight:v}}if(t==="bottom")return i&&It(s,U),{placement:"bottom",maxHeight:e};break;case"top":if(P>=g)return{placement:"top",maxHeight:e};if(D>=g&&!a)return i&&ft(s,q,O),{placement:"top",maxHeight:e};if(!a&&D>=o||a&&P>=o){var te=e;return(!a&&D>=o||a&&P>=o)&&(te=a?P-I:D-I),i&&ft(s,q,O),{placement:"top",maxHeight:te}}return{placement:"bottom",maxHeight:e};default:throw new Error('Invalid placement provided "'.concat(t,'".'))}return c}function io(l){var e={bottom:"top",top:"bottom"};return l?e[l]:"bottom"}var gr=function(e){return e==="auto"?"bottom":e},ao=function(e,n){var o,t=e.placement,i=e.theme,a=i.borderRadius,r=i.spacing,s=i.colors;return re((o={label:"menu"},tt(o,io(t),"100%"),tt(o,"position","absolute"),tt(o,"width","100%"),tt(o,"zIndex",1),o),n?{}:{backgroundColor:s.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})},br=F.createContext(null),oo=function(e){var n=e.children,o=e.minMenuHeight,t=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,r=e.menuShouldScrollIntoView,s=e.theme,c=F.useContext(br)||{},f=c.setPortalPlacement,p=F.useRef(null),y=F.useState(t),u=Te(y,2),g=u[0],d=u[1],b=F.useState(null),m=Te(b,2),w=m[0],_=m[1],C=s.spacing.controlHeight;return Ht(function(){var I=p.current;if(I){var P=a==="fixed",E=r&&!P,D=ro({maxHeight:t,menuEl:I,minHeight:o,placement:i,shouldScroll:E,isFixedPosition:P,controlHeight:C});d(D.maxHeight),_(D.placement),f==null||f(D.placement)}},[t,i,a,r,o,f,C]),n({ref:p,placerProps:re(re({},e),{},{placement:w||gr(i),maxHeight:g})})},so=function(e){var n=e.children,o=e.innerRef,t=e.innerProps;return ie("div",ae({},me(e,"menu",{menu:!0}),{ref:o},t),n)},lo=so,uo=function(e,n){var o=e.maxHeight,t=e.theme.spacing.baseUnit;return re({maxHeight:o,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},n?{}:{paddingBottom:t,paddingTop:t})},co=function(e){var n=e.children,o=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},o),n)},yr=function(e,n){var o=e.theme,t=o.spacing.baseUnit,i=o.colors;return re({textAlign:"center"},n?{}:{color:i.neutral40,padding:"".concat(t*2,"px ").concat(t*3,"px")})},ho=yr,fo=yr,po=function(e){var n=e.children,o=n===void 0?"No options":n,t=e.innerProps,i=Ne(e,to);return ie("div",ae({},me(re(re({},i),{},{children:o,innerProps:t}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),t),o)},mo=function(e){var n=e.children,o=n===void 0?"Loading...":n,t=e.innerProps,i=Ne(e,no);return ie("div",ae({},me(re(re({},i),{},{children:o,innerProps:t}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),t),o)},vo=function(e){var n=e.rect,o=e.offset,t=e.position;return{left:n.left,position:t,top:o,width:n.width,zIndex:1}},go=function(e){var n=e.appendTo,o=e.children,t=e.controlElement,i=e.innerProps,a=e.menuPlacement,r=e.menuPosition,s=F.useRef(null),c=F.useRef(null),f=F.useState(gr(a)),p=Te(f,2),y=p[0],u=p[1],g=F.useMemo(function(){return{setPortalPlacement:u}},[]),d=F.useState(null),b=Te(d,2),m=b[0],w=b[1],_=F.useCallback(function(){if(t){var E=Ya(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]);Ht(function(){_()},[_]);var C=F.useCallback(function(){typeof c.current=="function"&&(c.current(),c.current=null),t&&s.current&&(c.current=Na(t,s.current,_,{elementResize:"ResizeObserver"in window}))},[t,_]);Ht(function(){C()},[C]);var I=F.useCallback(function(E){s.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),o);return ie(br.Provider,{value:g},n?Xr.createPortal(P,n):P)},bo=function(e){var n=e.isDisabled,o=e.isRtl;return{label:"container",direction:o?"rtl":void 0,pointerEvents:n?"none":void 0,position:"relative"}},yo=function(e){var n=e.children,o=e.innerProps,t=e.isDisabled,i=e.isRtl;return ie("div",ae({},me(e,"container",{"--is-disabled":t,"--is-rtl":i}),o),n)},wo=function(e,n){var o=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(o.baseUnit/2,"px ").concat(o.baseUnit*2,"px")})},xo=function(e){var n=e.children,o=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}),o),n)},So=function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},_o=function(e){var n=e.children,o=e.innerProps;return ie("div",ae({},me(e,"indicatorsContainer",{indicators:!0}),o),n)},On,Co=["size"],ko=["innerProps","isRtl","size"],Oo={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},wr=function(e){var n=e.size,o=Ne(e,Co);return ie("svg",ae({height:n,width:n,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:Oo},o))},ln=function(e){return ie(wr,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"}))},xr=function(e){return ie(wr,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"}))},Sr=function(e,n){var o=e.isFocused,t=e.theme,i=t.spacing.baseUnit,a=t.colors;return re({label:"indicatorContainer",display:"flex",transition:"color 150ms"},n?{}:{color:o?a.neutral60:a.neutral20,padding:i*2,":hover":{color:o?a.neutral80:a.neutral40}})},Io=Sr,Eo=function(e){var n=e.children,o=e.innerProps;return ie("div",ae({},me(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),o),n||ie(xr,null))},Po=Sr,Mo=function(e){var n=e.children,o=e.innerProps;return ie("div",ae({},me(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),o),n||ie(ln,null))},jo=function(e,n){var o=e.isDisabled,t=e.theme,i=t.spacing.baseUnit,a=t.colors;return re({label:"indicatorSeparator",alignSelf:"stretch",width:1},n?{}:{backgroundColor:o?a.neutral10:a.neutral20,marginBottom:i*2,marginTop:i*2})},Do=function(e){var n=e.innerProps;return ie("span",ae({},n,me(e,"indicatorSeparator",{"indicator-separator":!0})))},zo=Kr(On||(On=Pa([` 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } -`]))),Fo=function(e,n){var o=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:o?a.neutral60:a.neutral20,padding:r*2})},Tt=function(e){var n=e.delay,o=e.offset;return ie("span",{css:Wn({animation:"".concat(zo," 1s ease-in-out ").concat(n,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:o?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Ro=function(e){var n=e.innerProps,o=e.isRtl,t=e.size,i=t===void 0?4:t,a=Ne(e,ko);return ie("div",ae({},me(re(re({},a),{},{innerProps:n,isRtl:o,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),n),ie(Tt,{delay:0,offset:o}),ie(Tt,{delay:160,offset:!0}),ie(Tt,{delay:320,offset:!o}))},Ao=function(e,n){var o=e.isDisabled,t=e.isFocused,i=e.theme,a=i.colors,r=i.borderRadius,s=i.spacing;return re({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:s.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},n?{}:{backgroundColor:o?a.neutral5:a.neutral0,borderColor:o?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}})},To=function(e){var n=e.children,o=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":o,"control--is-focused":t,"control--menu-is-open":r}),a,{"aria-disabled":o||void 0}),n)},Lo=To,Vo=["data"],Bo=function(e,n){var o=e.theme.spacing;return n?{}:{paddingBottom:o.baseUnit*2,paddingTop:o.baseUnit*2}},No=function(e){var n=e.children,o=e.cx,t=e.getStyles,i=e.getClassNames,a=e.Heading,r=e.headingProps,s=e.innerProps,c=e.label,f=e.theme,p=e.selectProps;return ie("div",ae({},me(e,"group",{group:!0}),s),ie(a,ae({},r,{selectProps:p,theme:f,getStyles:t,getClassNames:i,cx:o}),c),ie("div",null,n))},$o=function(e,n){var o=e.theme,t=o.colors,i=o.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"})},Uo=function(e){var n=pr(e);n.data;var o=Ne(n,Vo);return ie("div",ae({},me(e,"groupHeading",{"group-heading":!0}),o))},Wo=No,Ho=["innerRef","isDisabled","isHidden","inputClassName"],Zo=function(e,n){var o=e.isDisabled,t=e.value,i=e.theme,a=i.spacing,r=i.colors;return re(re({visibility:o?"hidden":"visible",transform:t?"translateZ(0)":""},Go),n?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:r.neutral80})},_r={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Go={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"},_r)},Yo=function(e){return re({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},_r)},Ko=function(e){var n=e.cx,o=e.value,t=pr(e),i=t.innerRef,a=t.isDisabled,r=t.isHidden,s=t.inputClassName,c=Ne(t,Ho);return ie("div",ae({},me(e,"input",{"input-container":!0}),{"data-value":o||""}),ie("input",ae({className:n({input:!0},s),ref:i,style:Yo(r),disabled:a},c)))},Xo=Ko,qo=function(e,n){var o=e.theme,t=o.spacing,i=o.borderRadius,a=o.colors;return re({label:"multiValue",display:"flex",minWidth:0},n?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Jo=function(e,n){var o=e.theme,t=o.borderRadius,i=o.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})},Qo=function(e,n){var o=e.theme,t=o.spacing,i=o.borderRadius,a=o.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}})},Cr=function(e){var n=e.children,o=e.innerProps;return ie("div",o,n)},es=Cr,ts=Cr;function ns(l){var e=l.children,n=l.innerProps;return ie("div",ae({role:"button"},n),e||ie(ln,{size:14}))}var rs=function(e){var n=e.children,o=e.components,t=e.data,i=e.innerProps,a=e.isDisabled,r=e.removeProps,s=e.selectProps,c=o.Container,f=o.Label,p=o.Remove;return ie(c,{data:t,innerProps:re(re({},me(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:s},ie(f,{data:t,innerProps:re({},me(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:s},n),ie(p,{data:t,innerProps:re(re({},me(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(n||"option")},r),selectProps:s}))},is=rs,as=function(e,n){var o=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.theme,r=a.spacing,s=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?s.primary:t?s.primary25:"transparent",color:o?s.neutral20:i?s.neutral0:"inherit",padding:"".concat(r.baseUnit*2,"px ").concat(r.baseUnit*3,"px"),":active":{backgroundColor:o?void 0:i?s.primary:s.primary50}})},os=function(e){var n=e.children,o=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":o,"option--is-focused":t,"option--is-selected":i}),{ref:a,"aria-disabled":o},r),n)},ss=os,ls=function(e,n){var o=e.theme,t=o.spacing,i=o.colors;return re({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},n?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},us=function(e){var n=e.children,o=e.innerProps;return ie("div",ae({},me(e,"placeholder",{placeholder:!0}),o),n)},cs=us,ds=function(e,n){var o=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:o?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},hs=function(e){var n=e.children,o=e.isDisabled,t=e.innerProps;return ie("div",ae({},me(e,"singleValue",{"single-value":!0,"single-value--is-disabled":o}),t),n)},fs=hs,ps={ClearIndicator:Mo,Control:Lo,DropdownIndicator:Eo,DownChevron:xr,CrossIcon:ln,Group:Wo,GroupHeading:Uo,IndicatorsContainer:_o,IndicatorSeparator:Do,Input:Xo,LoadingIndicator:Ro,Menu:lo,MenuList:co,MenuPortal:go,LoadingMessage:mo,NoOptionsMessage:po,MultiValue:is,MultiValueContainer:es,MultiValueLabel:ts,MultiValueRemove:ns,Option:ss,Placeholder:cs,SelectContainer:yo,SingleValue:fs,ValueContainer:xo},ms=function(e){return re(re({},ps),e.components)},In=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function vs(l,e){return!!(l===e||In(l)&&In(e))}function gs(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,o=e.focused,t=e.options,i=e.label,a=i===void 0?"":i,r=e.selectValue,s=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,o),".");if(n==="menu"){var p=s?" disabled":"",y="".concat(c?"selected":"focused").concat(p);return"option ".concat(a," ").concat(y,", ").concat(f(t,o),".")}return""},onFilter:function(e){var n=e.inputValue,o=e.resultsMessage;return"".concat(o).concat(n?" for search term "+n:"",".")}},Ss=function(e){var n=e.ariaSelection,o=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,a=e.isFocused,r=e.selectValue,s=e.selectProps,c=e.id,f=s.ariaLiveMessages,p=s.getOptionLabel,y=s.inputValue,u=s.isMulti,g=s.isOptionDisabled,d=s.isSearchable,b=s.menuIsOpen,m=s.options,w=s.screenReaderStatus,_=s.tabSelectsValue,C=s["aria-label"],I=s["aria-live"],P=F.useMemo(function(){return re(re({},xs),f||{})},[f]),E=F.useMemo(function(){var v="";if(n&&P.onChange){var B=n.option,te=n.options,T=n.removedValue,J=n.removedValues,N=n.value,K=function(he){return Array.isArray(he)?null:he},A=T||B||K(N),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=F.useMemo(function(){var v="",B=o||t,te=!!(o&&r&&r.includes(o));if(B&&P.onFocus){var T={focused:B,label:p(B),isDisabled:g(B,r),isSelected:te,options:i,context:B===o?"menu":"value",selectValue:r};v=P.onFocus(T)}return v},[o,t,p,g,P,i,r]),j=F.useMemo(function(){var v="";if(b&&m.length&&P.onFilter){var B=w({count:i.length});v=P.onFilter({inputValue:y,resultsMessage:B})}return v},[i,y,b,P,m,w]),U=F.useMemo(function(){var v="";if(P.guidance){var B=t?"value":b?"menu":"input";v=P.guidance({"aria-label":C,context:B,isDisabled:o&&g(o,r),isMulti:u,isSearchable:d,tabSelectsValue:_})}return v},[C,o,t,u,g,d,b,P,r,_]),q="".concat(D," ").concat(j," ").concat(U),O=ie(F.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(F.Fragment,null,ie(En,{id:c},L&&O),ie(En,{"aria-live":I,"aria-atomic":"false","aria-relevant":"additions text"},a&&!L&&O))},_s=Ss,Zt=[{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źẑżžẓẕƶȥɀⱬꝣ"}],Cs=new RegExp("["+Zt.map(function(l){return l.letters}).join("")+"]","g"),kr={};for(var Lt=0;Lt-1}},Es=["innerRef"];function Ps(l){var e=l.innerRef,n=Ne(l,Es),o=eo(n,"onExited","in","enter","exit","appear");return ie("input",ae({ref:e},o,{css:Wn({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 Ms=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function js(l){var e=l.isEnabled,n=l.onBottomArrive,o=l.onBottomLeave,t=l.onTopArrive,i=l.onTopLeave,a=F.useRef(!1),r=F.useRef(!1),s=F.useRef(0),c=F.useRef(null),f=F.useCallback(function(b,m){if(c.current!==null){var w=c.current,_=w.scrollTop,C=w.scrollHeight,I=w.clientHeight,P=c.current,E=m>0,D=C-I-_,j=!1;D>m&&a.current&&(o&&o(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>_&&(t&&!r.current&&t(b),P.scrollTop=0,j=!0,r.current=!0),j&&Ms(b)}},[n,o,t,i]),p=F.useCallback(function(b){f(b,b.deltaY)},[f]),y=F.useCallback(function(b){s.current=b.changedTouches[0].clientY},[]),u=F.useCallback(function(b){var m=s.current-b.changedTouches[0].clientY;f(b,m)},[f]),g=F.useCallback(function(b){if(b){var m=qa?{passive:!1}:!1;b.addEventListener("wheel",p,m),b.addEventListener("touchstart",y,m),b.addEventListener("touchmove",u,m)}},[u,y,p]),d=F.useCallback(function(b){b&&(b.removeEventListener("wheel",p,!1),b.removeEventListener("touchstart",y,!1),b.removeEventListener("touchmove",u,!1))},[u,y,p]);return F.useEffect(function(){if(e){var b=c.current;return g(b),function(){d(b)}}},[e,g,d]),function(b){c.current=b}}var Mn=["boxSizing","height","overflow","paddingRight","position"],jn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function Dn(l){l.preventDefault()}function zn(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 Rn(){return"ontouchstart"in window||navigator.maxTouchPoints}var An=!!(typeof window<"u"&&window.document&&window.document.createElement),et=0,Ze={capture:!1,passive:!1};function Ds(l){var e=l.isEnabled,n=l.accountForScrollbars,o=n===void 0?!0:n,t=F.useRef({}),i=F.useRef(null),a=F.useCallback(function(s){if(An){var c=document.body,f=c&&c.style;if(o&&Mn.forEach(function(g){var d=f&&f[g];t.current[g]=d}),o&&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(jn).forEach(function(g){var d=jn[g];f&&(f[g]=d)}),f&&(f.paddingRight="".concat(u,"px"))}c&&Rn()&&(c.addEventListener("touchmove",Dn,Ze),s&&(s.addEventListener("touchstart",Fn,Ze),s.addEventListener("touchmove",zn,Ze))),et+=1}},[o]),r=F.useCallback(function(s){if(An){var c=document.body,f=c&&c.style;et=Math.max(et-1,0),o&&et<1&&Mn.forEach(function(p){var y=t.current[p];f&&(f[p]=y)}),c&&Rn()&&(c.removeEventListener("touchmove",Dn,Ze),s&&(s.removeEventListener("touchstart",Fn,Ze),s.removeEventListener("touchmove",zn,Ze)))}},[o]);return F.useEffect(function(){if(e){var s=i.current;return a(s),function(){r(s)}}},[e,a,r]),function(s){i.current=s}}var zs=function(e){var n=e.target;return n.ownerDocument.activeElement&&n.ownerDocument.activeElement.blur()},Fs={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function Rs(l){var e=l.children,n=l.lockEnabled,o=l.captureEnabled,t=o===void 0?!0:o,i=l.onBottomArrive,a=l.onBottomLeave,r=l.onTopArrive,s=l.onTopLeave,c=js({isEnabled:t,onBottomArrive:i,onBottomLeave:a,onTopArrive:r,onTopLeave:s}),f=Ds({isEnabled:n}),p=function(u){c(u),f(u)};return ie(F.Fragment,null,n&&ie("div",{onClick:zs,css:Fs}),e(p))}var As={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},Ts=function(e){var n=e.name,o=e.onFocus;return ie("input",{required:!0,name:n,tabIndex:-1,"aria-hidden":"true",onFocus:o,css:As,value:"",onChange:function(){}})},Ls=Ts,Vs=function(e){return e.label},Bs=function(e){return e.label},Ns=function(e){return e.value},$s=function(e){return!!e.isDisabled},Us={clearIndicator:Po,container:bo,control:Ao,dropdownIndicator:Io,group:Bo,groupHeading:$o,indicatorsContainer:So,indicatorSeparator:jo,input:Zo,loadingIndicator:Fo,loadingMessage:fo,menu:ao,menuList:uo,menuPortal:vo,multiValue:qo,multiValueLabel:Jo,multiValueRemove:Qo,noOptionsMessage:ho,option:as,placeholder:ls,singleValue:ds,valueContainer:wo},Ws={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%)"},Hs=4,Ir=4,Zs=38,Gs=Ir*2,Ys={baseUnit:Ir,controlHeight:Zs,menuGutter:Gs},Nt={borderRadius:Hs,colors:Ws,spacing:Ys},Ks={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:kn(),captureMenuScroll:!kn(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:Is(),formatGroupLabel:Vs,getOptionLabel:Bs,getOptionValue:Ns,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:$s,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!Ka(),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 Tn(l,e,n,o){var t=jr(l,e,n),i=Dr(l,e,n),a=Mr(l,e),r=Et(l,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:a,value:r,index:o}}function Er(l,e){return l.options.map(function(n,o){if("options"in n){var t=n.options.map(function(a,r){return Tn(l,a,e,r)}).filter(function(a){return Ln(l,a)});return t.length>0?{type:"group",data:n,options:t,index:o}:void 0}var i=Tn(l,n,e,o);return Ln(l,i)?i:void 0}).filter(Ja)}function Pr(l){return l.reduce(function(e,n){return n.type==="group"?e.push.apply(e,lr(n.options.map(function(o){return o.data}))):e.push(n.data),e},[])}function Xs(l,e){return Pr(Er(l,e))}function Ln(l,e){var n=l.inputValue,o=n===void 0?"":n,t=e.data,i=e.isSelected,a=e.label,r=e.value;return(!Fr(l)||!i)&&zr(l,{label:a,value:r,data:t},o)}function qs(l,e){var n=l.focusedValue,o=l.selectValue,t=o.indexOf(n);if(t>-1){var i=e.indexOf(n);if(i>-1)return n;if(t-1?n:e[0]}var Mr=function(e,n){return e.getOptionLabel(n)},Et=function(e,n){return e.getOptionValue(n)};function jr(l,e,n){return typeof l.isOptionDisabled=="function"?l.isOptionDisabled(e,n):!1}function Dr(l,e,n){if(n.indexOf(e)>-1)return!0;if(typeof l.isOptionSelected=="function")return l.isOptionSelected(e,n);var o=Et(l,e);return n.some(function(t){return Et(l,t)===o})}function zr(l,e,n){return l.filterOption?l.filterOption(e,n):!0}var Fr=function(e){var n=e.hideSelectedOptions,o=e.isMulti;return n===void 0?o:n},Qs=1,Rr=function(l){xa(n,l);var e=ka(n);function n(o){var t;if(ya(this,n),t=e.call(this,o),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,s){var c=t.props,f=c.onChange,p=c.name;s.name=p,t.ariaOnChange(r,s),f(r,s)},t.setValue=function(r,s,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:s,option:c})},t.selectOption=function(r){var s=t.props,c=s.blurInputOnSelect,f=s.isMulti,p=s.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(lr(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 s=t.props.isMulti,c=t.state.selectValue,f=t.getOptionValue(r),p=c.filter(function(u){return t.getOptionValue(u)!==f}),y=mt(s,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,s=t.state.selectValue,c=s[s.length-1],f=s.slice(0,s.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,s=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 s=t.props.inputValue,c=r.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(c,{action:"input-change",prevInputValue:s}),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 s=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:s}),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 Fr(t.props)},t.onValueInputFocus=function(r){r.preventDefault(),r.stopPropagation(),t.focus()},t.onKeyDown=function(r){var s=t.props,c=s.isMulti,f=s.backspaceRemovesValue,p=s.escapeClearsValue,y=s.inputValue,u=s.isClearable,g=s.isDisabled,d=s.menuIsOpen,b=s.onKeyDown,m=s.tabSelectsValue,w=s.openMenuOnFocus,_=t.state,C=_.focusedOption,I=_.focusedValue,P=_.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||++Qs),t.state.selectValue=_n(o.value),o.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),a=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[a]}return t}return wa(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&&Cn(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,a=i.isDisabled,r=i.menuIsOpen,s=this.state.isFocused;(s&&!a&&t.isDisabled||s&&r&&!t.menuIsOpen)&&this.focusInput(),s&&a&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!s&&!a&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Cn(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,s=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=!(s&&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 s=a.indexOf(r);r||(s=-1);var c=a.length-1,f=-1;if(a.length){switch(t){case"previous":s===0?f=0:s===-1?f=c:f=s-1;break;case"next":s>-1&&s0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,a=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var s=0,c=r.indexOf(a);a||(c=-1),t==="up"?s=c>0?c-1:r.length-1:t==="down"?s=(c+1)%r.length:t==="pageup"?(s=c-i,s<0&&(s=0)):t==="pagedown"?(s=c+i,s>r.length-1&&(s=r.length-1)):t==="last"&&(s=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[s],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme(Nt):re(re({},Nt),this.props.theme):Nt}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,a=this.getStyles,r=this.getClassNames,s=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:s,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 jr(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return Dr(this.props,t,i)}},{key:"filterOption",value:function(t,i){return zr(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,s=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,_=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?F.createElement(g,ae({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:_,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:s},C)):F.createElement(Ps,ae({id:_,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,s=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,_=this.state,C=_.selectValue,I=_.focusedValue,P=_.isFocused;if(!this.hasValue()||!g)return m?null:F.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 F.createElement(a,ae({},y,{components:{Container:r,Label:s,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 F.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,s=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!this.isClearable()||!i||s||!this.hasValue()||c)return null;var p={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return F.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,s=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!i||!c)return null;var p={"aria-hidden":"true"};return F.createElement(i,ae({},a,{innerProps:p,isDisabled:s,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,s=this.props.isDisabled,c=this.state.isFocused;return F.createElement(a,ae({},r,{isDisabled:s,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,s=this.state.isFocused,c={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return F.createElement(i,ae({},a,{innerProps:c,isDisabled:r,isFocused:s}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),a=i.Group,r=i.GroupHeading,s=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,_=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,B=b.onMenuScrollToBottom;if(!E)return null;var te=function(ee,X){var Z=ee.type,ce=ee.data,he=ee.isDisabled,se=ee.isSelected,le=ee.label,ge=ee.value,pe=d===ce,Ce=he?void 0:function(){return t.onOptionHover(ce)},ke=he?void 0:function(){return t.selectOption(ce)},h="".concat(t.getElementId("option"),"-").concat(X),$={id:h,onClick:ke,onMouseMove:Ce,onMouseOver:Ce,tabIndex:-1};return F.createElement(u,ae({},g,{innerProps:$,data:ce,isDisabled:he,isSelected:se,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 F.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(se){return te(se,"".concat(Z,"-").concat(se.index))}))}else if(z.type==="option")return te(z,"".concat(z.index))});else if(_){var J=C({inputValue:w});if(J===null)return null;T=F.createElement(p,g,J)}else{var N=L({inputValue:w});if(N===null)return null;T=F.createElement(y,g,N)}var K={minMenuHeight:I,maxMenuHeight:P,menuPlacement:D,menuPosition:j,menuShouldScrollIntoView:O},A=F.createElement(oo,ae({},g,K),function(z){var ee=z.ref,X=z.placerProps,Z=X.placement,ce=X.maxHeight;return F.createElement(s,ae({},g,K,{innerRef:ee,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:_,placement:Z}),F.createElement(Rs,{captureEnabled:m,onTopArrive:v,onBottomArrive:B,lockEnabled:q},function(he){return F.createElement(c,ae({},g,{innerRef:function(le){t.getMenuListRef(le),he(le)},isLoading:_,maxHeight:ce,focusedOption:d}),T)}))});return U||j==="fixed"?F.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,s=i.isMulti,c=i.name,f=i.required,p=this.state.selectValue;if(f&&!this.hasValue()&&!r)return F.createElement(Ls,{name:c,onFocus:this.onValueInputFocus});if(!(!c||r))if(s)if(a){var y=p.map(function(d){return t.getOptionValue(d)}).join(a);return F.createElement("input",{name:c,type:"hidden",value:y})}else{var u=p.length>0?p.map(function(d,b){return F.createElement("input",{key:"i-".concat(b),name:c,type:"hidden",value:t.getOptionValue(d)})}):F.createElement("input",{name:c,type:"hidden",value:""});return F.createElement("div",null,u)}else{var g=p[0]?this.getOptionValue(p[0]):"";return F.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,s=i.focusedValue,c=i.isFocused,f=i.selectValue,p=this.getFocusableOptions();return F.createElement(_s,ae({},t,{id:this.getElementId("live-region"),ariaSelection:a,focusedOption:r,focusedValue:s,isFocused:c,selectValue:f,focusableOptions:p}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,a=t.IndicatorsContainer,r=t.SelectContainer,s=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 F.createElement(r,ae({},d,{className:f,innerProps:{id:p,onKeyDown:this.onKeyDown},isDisabled:y,isFocused:g}),this.renderLiveRegion(),F.createElement(i,ae({},d,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:y,isFocused:g,menuIsOpen:u}),F.createElement(s,ae({},d,{isDisabled:y}),this.renderPlaceholderOrValue(),this.renderInput()),F.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,s=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=_n(u),w={};if(a&&(u!==a.value||y!==a.options||g!==a.menuIsOpen||d!==a.inputValue)){var _=g?Xs(t,m):[],C=r?qs(i,m):null,I=Js(i,_);w={selectValue:m,focusedOption:I,focusedValue:C,clearFocusValueOnUpdate:!1}}var P=s!=null&&t!==a?{inputIsHidden:s,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}(F.Component);Rr.defaultProps=Ks;var el=F.forwardRef(function(l,e){var n=ba(l);return F.createElement(Rr,ae({ref:e},n))}),tl=el,nl=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function Gt(){return Gt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Ar=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=rl(e,nl);return Gt({},n)},il=function(e){var n=typeof e=="string";return n&&["sm","md","lg"].includes(e)},al=function(e){return il(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},De=function(e){var n=Mt(),o=al(n.components.Input.defaultProps.size),t=e??o,i=Vi(typeof t=="string"?[t]:t,{fallback:"md"})||o;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 dl=function(e){var n=e.className,o=e.cx,t=e.children,i=e.innerRef,a=e.innerProps,r=e.isDisabled,s=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),_=$e("Input",{size:w,variant:u,focusBorderColor:g,errorBorderColor:d}),C=_.field,I=C.height,P=C.h,E=cl(C,ul),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 oe.createElement(de,Pe({ref:i,className:o({control:!0,"control--is-disabled":r,"control--is-focused":s,"control--menu-is-open":c},n),sx:U},a,{"data-focus":s?!0:void 0,"data-focus-visible":s?!0:void 0,"data-invalid":b?!0:void 0,"data-disabled":r?!0:void 0,"data-readonly":m?!0:void 0}),t)},hl=function(e){var n=e.className,o=e.cx,t=e.selectProps,i=t.chakraStyles,a=t.useBasicStyles,r=t.variant,s=Pe({opacity:1},a||r!=="outline"?{display:"none"}:{}),c=i!=null&&i.indicatorSeparator?i.indicatorSeparator(s,e):s;return oe.createElement(Jn,{className:o({"indicator-separator":!0},n),sx:c,orientation:"vertical"})},fl=function(e){return oe.createElement(Jt,Pe({role:"presentation",focusable:"false","aria-hidden":"true"},e),oe.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},pl=function(e){var n=e.children,o=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,s=a.useBasicStyles,c=a.size,f=a.focusBorderColor,p=a.errorBorderColor,y=a.variant,u=De(c),g=$e("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},s&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=r!=null&&r.dropdownIndicator?r.dropdownIndicator(m,e):m,_={height:"1em",width:"1em"},C=r!=null&&r.downChevron?r.downChevron(_,e):_;return oe.createElement(de,Pe({},i,{className:t({indicator:!0,"dropdown-indicator":!0},o),sx:w}),n||oe.createElement(fl,{sx:C}))},ml=function(e){return oe.createElement(Jt,Pe({focusable:"false","aria-hidden":!0},e),oe.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"}))},vl=function(e){var n=e.children,o=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,s=a.size,c=De(s),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 oe.createElement(de,Pe({role:"button",className:t({indicator:!0,"clear-indicator":!0},o),sx:y,"aria-label":"Clear selected options"},i),n||oe.createElement(ml,{sx:g}))},gl=function(e){var n=e.className,o=e.cx,t=e.innerProps,i=e.selectProps,a=i.chakraStyles,r=i.size,s=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 oe.createElement(qr,Pe({className:o({indicator:!0,"loading-indicator":!0},n),sx:m},t,{size:y||d,color:s,emptyColor:c,speed:f,thickness:p}))};const bl=dl;var yl=["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 xl=function(e){var n=e.className,o=e.cx,t=e.value,i=e.selectProps,a=i.chakraStyles,r=i.isReadOnly,s=Ar(e),c=s.innerRef,f=s.isDisabled,p=s.isHidden,y=s.inputClassName,u=wl(s,yl),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 oe.createElement(de,{className:o({"input-container":!0},n),"data-value":t||"",sx:b},oe.createElement(Ue.input,rt({className:o({input:!0},y),ref:c,sx:w,disabled:f,readOnly:r?!0:void 0},u)))};const Sl=xl;var _l=["data"];function Cl(l,e){if(l==null)return{};var n={},o=Object.keys(l),t,i;for(i=0;i=0)&&(n[t]=l[t]);return n}function _e(){return _e=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var ql=function(e){var n,o=e.components,t=o===void 0?{}:o;e.theme;var i=e.size,a=e.colorScheme,r=a===void 0?"gray":a,s=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,_=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=Xl(e,Kl),O=Mt(),L=O.components.Input.defaultProps.variant,v=yi({id:u,isDisabled:s,isInvalid:c,isRequired:y,isReadOnly:f,onFocus:D,onBlur:j}),B=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 N=Pt({components:Pt({},Yl,t),colorScheme:r,size:i,tagVariant:g,selectedOptionStyle:te,selectedOptionColorScheme:J,variant:_??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:B},q,{"aria-invalid":(n=q["aria-invalid"])!=null?n:v["aria-invalid"]});return N};const Jl=ql;function Xt(){return Xt=Object.assign?Object.assign.bind():function(l){for(var e=1;e({value:g,label:g})))??[],[r,s]=F.useState(a),c=async()=>{var g,d;await((g=We)==null?void 0:g.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((d=We)==null?void 0:d.listAll().then(b=>o(b??[]))),i("")},f=async()=>{var d;const g=await((d=We)==null?void 0:d.listAll());o(g??[])};if(We==null)return alert("Error: TagsTable is not loaded"),null;const p=n.map(g=>({value:g.name,label:g.name})),y=37*5;return x.jsxs(wi,{isLazy:!0,onOpen:f,children:[x.jsx(xi,{children:x.jsx(xe,{"aria-label":"Delete confirm",size:"sm",variant:"ghost",icon:x.jsx(rr,{color:"#718096"})})}),x.jsxs(Si,{children:[x.jsx(_i,{}),x.jsx(Ci,{}),x.jsx(tr,{children:x.jsx("b",{children:l.name})}),x.jsxs(ki,{children:[x.jsx(eu,{isMulti:!0,name:"tags",options:p,menuIsOpen:!0,value:r,onChange:async g=>{var d;s(g),await((d=be)==null?void 0:d.updateMetaInfo(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}),x.jsxs(we,{gap:4,mt:Math.min(y,Math.max(n.length,3)*37),children:[x.jsx(it,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:g=>{i(g.target.value.trim())}}),x.jsx(Se,{iconSpacing:1,leftIcon:x.jsx(tn,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:c,children:"New Tag"})]})]})]})]})}function nu({menuPosition:l,workflowID:e,onClose:n}){const{onDuplicateWorkflow:o}=F.useContext(nn);return x.jsx(x.Fragment,{children:x.jsx(de,{position:"absolute",top:l.y,left:l.x,children:x.jsx(Xe,{isOpen:!0,onClose:n,children:x.jsx(at,{children:x.jsx(Re,{onClick:()=>o&&o(e),children:"Duplicate"})})})})})}const Vn=F.memo(function({workflow:e}){const{colorMode:n}=qt(),[o,t]=F.useState({x:0,y:0}),[i,a]=F.useState(!1),{setDraggingFile:r,isMultiSelecting:s,onMultiSelectFlow:c,onDeleteFlow:f,multiSelectedFlowsID:p}=F.useContext(Be),y=p&&p.length>0&&p.includes(e.id),{curFlowID:u,loadWorkflowID:g}=F.useContext(nn),d=u===e.id,b=P=>{P.preventDefault(),t({x:P.clientX,y:P.clientY}),a(!0)},[m,w]=F.useState(!1),_=()=>{a(!1)},C=n==="light"?"gray.200":"#4A5568",I=x.jsx(de,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":i?C:void 0,color:d&&!s?"#333":void 0,draggable:!s,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:1,onClick:()=>{!s&&g(e.id)},_hover:{bg:C},children:x.jsxs(we,{children:[e.coverMediaPath!=null&&x.jsx(Ri,{mediaLocalPath:e.coverMediaPath,size:60,hideBrokenImage:!0,isPreview:!0}),x.jsxs(Le,{textAlign:"left",gap:0,children:[x.jsx(Oe,{fontWeight:"500",children:e.name??"untitled"}),x.jsxs(Oe,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Yn(e.updateTime)]})]})]})});return x.jsxs(we,{w:"100%",mb:1,justify:"space-between",onContextMenu:b,onMouseEnter:()=>{w(!0)},onMouseLeave:()=>{w(!1)},children:[s?x.jsx(ot,{isChecked:y,spacing:4,onChange:P=>{c&&c(e.id,P.target.checked)},children:I}):x.jsxs(x.Fragment,{children:[I,x.jsxs(nt,{width:"90px",justifyContent:"flex-end",children:[m&&x.jsx(tu,{workflow:e}),x.jsx(Fe,{label:"Open in new tab",children:x.jsx(xe,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>Oi(e.id),icon:x.jsx(Ii,{color:"#718096",size:23})})}),x.jsx(Kn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{f&&f(e.id)}})]})]}),i&&x.jsx(nu,{menuPosition:o,onClose:_,workflowID:e.id})]})});function Lr({items:l}){var y;const[e,n]=F.useState(!1),o=l.filter(He),t=l.filter(u=>!He(u)),i=(y=t[0])==null?void 0:y.parentFolderID,[a,r]=F.useState(!1),{onRefreshFilesList:s,draggingFile:c,refreshFolderStamp:f}=F.useContext(Be),p=async u=>{var g,d;if(u.preventDefault(),u.stopPropagation(),!c)return r(!1);if(He(c)){if(c.id===i)return r(!1);await((g=Ve)==null?void 0:g.update(c.id,{parentFolderID:i}))}else await((d=be)==null?void 0:d.updateFolder(c.id,{parentFolderID:i}));await(s==null?void 0:s()),r(!1)};return F.useEffect(()=>{var u;(u=ye)==null||u.getSetting("foldersOnTop").then(g=>{n(g??!1)})},[f]),x.jsxs(x.Fragment,{children:[e&&o.map(u=>x.jsx(bn,{folder:u},u.id)),x.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=>x.jsx(Vn,{workflow:u},u.id)):l.map(u=>He(u)?x.jsx(bn,{folder:u},u.id):x.jsx(Vn,{workflow:u},u.id))})]})}function hu({onClose:l,onClickNewFlow:e}){const[n,o]=F.useState([]),t=F.useRef([]),i=F.useRef([]),{loadWorkflowID:a,curFlowID:r}=F.useContext(nn),[s,c]=F.useState(),[f,p]=F.useState(!1),[y,u]=F.useState([]),[g,d]=F.useState(0),[b,m]=F.useState(""),w=la(b,400),_=F.useRef(null),[C,I]=F.useState(null),P=F.useRef(window.localStorage.getItem($t)??fn.RECENTLY_MODIFIED),E=async()=>{var J,N;const T=await((J=be)==null?void 0:J.listFolderContent())??[];t.current=T,await((N=be)==null?void 0:N.listAll().then(K=>{i.current=K})),j(),d(Date.now())},D=!!s||!!w,j=()=>{if(D){const T=i.current.filter(J=>{var A;let N=!0,K=!0;return s&&(N=!!((A=J.tags)!=null&&A.includes(s))),w&&(K=!!J.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),N&&K});o(Ft(T,P.current))}else o(Ft(t.current,P.current))},U=T=>{o(Ft(n,T)),P.current=T,window.localStorage.setItem($t,T),!D&&d(Date.now())};F.useEffect(()=>{j()},[w,s]);const q=F.useCallback(async T=>{var J,N,K;await((J=be)==null?void 0:J.deleteFlow(T)),((K=(N=be)==null?void 0:N.curWorkflow)==null?void 0:K.id)===T&&await(a==null?void 0:a(null)),await E()},[s,w]);F.useEffect(()=>{E();const T=async J=>{var N;if(_.current){const K=await((N=be)==null?void 0:N.get(_.current));K&&K.json&&ji(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=F.useCallback((T,J)=>{u(N=>{const K=[...N];return J?K.push(T):K.splice(K.indexOf(T),1),K})},[]),L=(T,J)=>{var N;switch(T){case"batchDelete":r&&((N=be)==null||N.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),He(T)||(_.current=T.id)},B=T=>{m(T)},te=450;return x.jsx(Be.Provider,{value:{onRefreshFilesList:E,draggingFile:C??void 0,setDraggingFile:v,isMultiSelecting:f,onMultiSelectFlow:O,multiSelectedFlowsID:y,onDeleteFlow:q,refreshFolderStamp:g,setRefreshFolderStamp:d},children:x.jsx(de,{style:{width:te},children:x.jsxs(Ei,{width:te,height:"100vh",pl:4,pr:5,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Pi,children:[x.jsxs(nt,{alignItems:"center",justifyContent:"space-between",children:[x.jsxs(we,{gap:4,children:[x.jsx(we,{gap:2,children:x.jsx(Oe,{fontSize:19,fontWeight:600,children:"☕️Workspace"})}),x.jsx(or,{}),x.jsx(Fe,{label:"Open workspace save directory",children:x.jsx(xe,{"aria-label":"Open workspace save directory",size:"sm",icon:x.jsx(Xn,{}),variant:"outline",colorScheme:"teal",onClick:()=>Mi()})}),x.jsx(Fe,{label:"New workflow",children:x.jsx(xe,{"aria-label":"New workflow",size:"sm",icon:x.jsx(tn,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),x.jsx(we,{alignItems:"center",children:x.jsx(oa,{})})]}),x.jsxs(nt,{direction:"column",h:"calc(100% - 64px)",children:[x.jsx(da,{selectedTag:s,setSelectedTag:c}),x.jsxs(we,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[x.jsxs(we,{children:[i.current.length>0?x.jsx(sa,{multipleState:f,changeMultipleState:T=>{p(T),!T&&u([])},selectedKeys:y,isSelectedAll:y.length===i.current.length,batchOperationCallback:L}):x.jsx(de,{}),!f&&x.jsx(Fe,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:x.jsx(xe,{size:"sm",variant:"outline",icon:x.jsx(nr,{size:21}),onClick:async()=>{var T;await((T=Ve)==null?void 0:T.create({name:"New Folder"})),E()},"aria-label":"new folder button"})})]}),x.jsxs(Xe,{closeOnSelect:!0,children:[x.jsx(jt,{as:Se,variant:"ghost",size:"xs",pr:0,rightIcon:x.jsx(en,{size:"16"}),children:x.jsxs(we,{children:[x.jsx(Oe,{children:"Sort by:"}),x.jsx(Oe,{display:"inline-block",children:P.current})]})}),x.jsx(at,{children:x.jsx(er,{value:P.current,type:"radio",onChange:T=>U(T),children:Object.values(fn).map((T,J)=>x.jsx(rn,{value:T,children:T},J))})})]})]}),x.jsx(ca,{searchValue:b,onUpdateSearchValue:B}),x.jsx(nt,{overflowY:"auto",overflowX:"hidden",direction:"column",children:x.jsx(Lr,{items:n})})]})]})})})}export{hu as default}; +`]))),Fo=function(e,n){var o=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:o?a.neutral60:a.neutral20,padding:r*2})},Tt=function(e){var n=e.delay,o=e.offset;return ie("span",{css:Wn({animation:"".concat(zo," 1s ease-in-out ").concat(n,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:o?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Ro=function(e){var n=e.innerProps,o=e.isRtl,t=e.size,i=t===void 0?4:t,a=Ne(e,ko);return ie("div",ae({},me(re(re({},a),{},{innerProps:n,isRtl:o,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),n),ie(Tt,{delay:0,offset:o}),ie(Tt,{delay:160,offset:!0}),ie(Tt,{delay:320,offset:!o}))},Ao=function(e,n){var o=e.isDisabled,t=e.isFocused,i=e.theme,a=i.colors,r=i.borderRadius,s=i.spacing;return re({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:s.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},n?{}:{backgroundColor:o?a.neutral5:a.neutral0,borderColor:o?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}})},To=function(e){var n=e.children,o=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":o,"control--is-focused":t,"control--menu-is-open":r}),a,{"aria-disabled":o||void 0}),n)},Lo=To,Vo=["data"],Bo=function(e,n){var o=e.theme.spacing;return n?{}:{paddingBottom:o.baseUnit*2,paddingTop:o.baseUnit*2}},No=function(e){var n=e.children,o=e.cx,t=e.getStyles,i=e.getClassNames,a=e.Heading,r=e.headingProps,s=e.innerProps,c=e.label,f=e.theme,p=e.selectProps;return ie("div",ae({},me(e,"group",{group:!0}),s),ie(a,ae({},r,{selectProps:p,theme:f,getStyles:t,getClassNames:i,cx:o}),c),ie("div",null,n))},$o=function(e,n){var o=e.theme,t=o.colors,i=o.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"})},Uo=function(e){var n=pr(e);n.data;var o=Ne(n,Vo);return ie("div",ae({},me(e,"groupHeading",{"group-heading":!0}),o))},Wo=No,Ho=["innerRef","isDisabled","isHidden","inputClassName"],Zo=function(e,n){var o=e.isDisabled,t=e.value,i=e.theme,a=i.spacing,r=i.colors;return re(re({visibility:o?"hidden":"visible",transform:t?"translateZ(0)":""},Go),n?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:r.neutral80})},_r={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Go={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"},_r)},Yo=function(e){return re({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},_r)},Ko=function(e){var n=e.cx,o=e.value,t=pr(e),i=t.innerRef,a=t.isDisabled,r=t.isHidden,s=t.inputClassName,c=Ne(t,Ho);return ie("div",ae({},me(e,"input",{"input-container":!0}),{"data-value":o||""}),ie("input",ae({className:n({input:!0},s),ref:i,style:Yo(r),disabled:a},c)))},Xo=Ko,qo=function(e,n){var o=e.theme,t=o.spacing,i=o.borderRadius,a=o.colors;return re({label:"multiValue",display:"flex",minWidth:0},n?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:t.baseUnit/2})},Jo=function(e,n){var o=e.theme,t=o.borderRadius,i=o.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})},Qo=function(e,n){var o=e.theme,t=o.spacing,i=o.borderRadius,a=o.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}})},Cr=function(e){var n=e.children,o=e.innerProps;return ie("div",o,n)},es=Cr,ts=Cr;function ns(l){var e=l.children,n=l.innerProps;return ie("div",ae({role:"button"},n),e||ie(ln,{size:14}))}var rs=function(e){var n=e.children,o=e.components,t=e.data,i=e.innerProps,a=e.isDisabled,r=e.removeProps,s=e.selectProps,c=o.Container,f=o.Label,p=o.Remove;return ie(c,{data:t,innerProps:re(re({},me(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:s},ie(f,{data:t,innerProps:re({},me(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:s},n),ie(p,{data:t,innerProps:re(re({},me(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(n||"option")},r),selectProps:s}))},is=rs,as=function(e,n){var o=e.isDisabled,t=e.isFocused,i=e.isSelected,a=e.theme,r=a.spacing,s=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?s.primary:t?s.primary25:"transparent",color:o?s.neutral20:i?s.neutral0:"inherit",padding:"".concat(r.baseUnit*2,"px ").concat(r.baseUnit*3,"px"),":active":{backgroundColor:o?void 0:i?s.primary:s.primary50}})},os=function(e){var n=e.children,o=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":o,"option--is-focused":t,"option--is-selected":i}),{ref:a,"aria-disabled":o},r),n)},ss=os,ls=function(e,n){var o=e.theme,t=o.spacing,i=o.colors;return re({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},n?{}:{color:i.neutral50,marginLeft:t.baseUnit/2,marginRight:t.baseUnit/2})},us=function(e){var n=e.children,o=e.innerProps;return ie("div",ae({},me(e,"placeholder",{placeholder:!0}),o),n)},cs=us,ds=function(e,n){var o=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:o?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},hs=function(e){var n=e.children,o=e.isDisabled,t=e.innerProps;return ie("div",ae({},me(e,"singleValue",{"single-value":!0,"single-value--is-disabled":o}),t),n)},fs=hs,ps={ClearIndicator:Mo,Control:Lo,DropdownIndicator:Eo,DownChevron:xr,CrossIcon:ln,Group:Wo,GroupHeading:Uo,IndicatorsContainer:_o,IndicatorSeparator:Do,Input:Xo,LoadingIndicator:Ro,Menu:lo,MenuList:co,MenuPortal:go,LoadingMessage:mo,NoOptionsMessage:po,MultiValue:is,MultiValueContainer:es,MultiValueLabel:ts,MultiValueRemove:ns,Option:ss,Placeholder:cs,SelectContainer:yo,SingleValue:fs,ValueContainer:xo},ms=function(e){return re(re({},ps),e.components)},In=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function vs(l,e){return!!(l===e||In(l)&&In(e))}function gs(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,o=e.focused,t=e.options,i=e.label,a=i===void 0?"":i,r=e.selectValue,s=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,o),".");if(n==="menu"){var p=s?" disabled":"",y="".concat(c?"selected":"focused").concat(p);return"option ".concat(a," ").concat(y,", ").concat(f(t,o),".")}return""},onFilter:function(e){var n=e.inputValue,o=e.resultsMessage;return"".concat(o).concat(n?" for search term "+n:"",".")}},Ss=function(e){var n=e.ariaSelection,o=e.focusedOption,t=e.focusedValue,i=e.focusableOptions,a=e.isFocused,r=e.selectValue,s=e.selectProps,c=e.id,f=s.ariaLiveMessages,p=s.getOptionLabel,y=s.inputValue,u=s.isMulti,g=s.isOptionDisabled,d=s.isSearchable,b=s.menuIsOpen,m=s.options,w=s.screenReaderStatus,_=s.tabSelectsValue,C=s["aria-label"],I=s["aria-live"],P=F.useMemo(function(){return re(re({},xs),f||{})},[f]),E=F.useMemo(function(){var v="";if(n&&P.onChange){var B=n.option,te=n.options,T=n.removedValue,J=n.removedValues,N=n.value,K=function(he){return Array.isArray(he)?null:he},A=T||B||K(N),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=F.useMemo(function(){var v="",B=o||t,te=!!(o&&r&&r.includes(o));if(B&&P.onFocus){var T={focused:B,label:p(B),isDisabled:g(B,r),isSelected:te,options:i,context:B===o?"menu":"value",selectValue:r};v=P.onFocus(T)}return v},[o,t,p,g,P,i,r]),j=F.useMemo(function(){var v="";if(b&&m.length&&P.onFilter){var B=w({count:i.length});v=P.onFilter({inputValue:y,resultsMessage:B})}return v},[i,y,b,P,m,w]),U=F.useMemo(function(){var v="";if(P.guidance){var B=t?"value":b?"menu":"input";v=P.guidance({"aria-label":C,context:B,isDisabled:o&&g(o,r),isMulti:u,isSearchable:d,tabSelectsValue:_})}return v},[C,o,t,u,g,d,b,P,r,_]),q="".concat(D," ").concat(j," ").concat(U),O=ie(F.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(F.Fragment,null,ie(En,{id:c},L&&O),ie(En,{"aria-live":I,"aria-atomic":"false","aria-relevant":"additions text"},a&&!L&&O))},_s=Ss,Zt=[{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źẑżžẓẕƶȥɀⱬꝣ"}],Cs=new RegExp("["+Zt.map(function(l){return l.letters}).join("")+"]","g"),kr={};for(var Lt=0;Lt-1}},Es=["innerRef"];function Ps(l){var e=l.innerRef,n=Ne(l,Es),o=eo(n,"onExited","in","enter","exit","appear");return ie("input",ae({ref:e},o,{css:Wn({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 Ms=function(e){e.cancelable&&e.preventDefault(),e.stopPropagation()};function js(l){var e=l.isEnabled,n=l.onBottomArrive,o=l.onBottomLeave,t=l.onTopArrive,i=l.onTopLeave,a=F.useRef(!1),r=F.useRef(!1),s=F.useRef(0),c=F.useRef(null),f=F.useCallback(function(b,m){if(c.current!==null){var w=c.current,_=w.scrollTop,C=w.scrollHeight,I=w.clientHeight,P=c.current,E=m>0,D=C-I-_,j=!1;D>m&&a.current&&(o&&o(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>_&&(t&&!r.current&&t(b),P.scrollTop=0,j=!0,r.current=!0),j&&Ms(b)}},[n,o,t,i]),p=F.useCallback(function(b){f(b,b.deltaY)},[f]),y=F.useCallback(function(b){s.current=b.changedTouches[0].clientY},[]),u=F.useCallback(function(b){var m=s.current-b.changedTouches[0].clientY;f(b,m)},[f]),g=F.useCallback(function(b){if(b){var m=qa?{passive:!1}:!1;b.addEventListener("wheel",p,m),b.addEventListener("touchstart",y,m),b.addEventListener("touchmove",u,m)}},[u,y,p]),d=F.useCallback(function(b){b&&(b.removeEventListener("wheel",p,!1),b.removeEventListener("touchstart",y,!1),b.removeEventListener("touchmove",u,!1))},[u,y,p]);return F.useEffect(function(){if(e){var b=c.current;return g(b),function(){d(b)}}},[e,g,d]),function(b){c.current=b}}var Mn=["boxSizing","height","overflow","paddingRight","position"],jn={boxSizing:"border-box",overflow:"hidden",position:"relative",height:"100%"};function Dn(l){l.preventDefault()}function zn(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 Rn(){return"ontouchstart"in window||navigator.maxTouchPoints}var An=!!(typeof window<"u"&&window.document&&window.document.createElement),et=0,Ze={capture:!1,passive:!1};function Ds(l){var e=l.isEnabled,n=l.accountForScrollbars,o=n===void 0?!0:n,t=F.useRef({}),i=F.useRef(null),a=F.useCallback(function(s){if(An){var c=document.body,f=c&&c.style;if(o&&Mn.forEach(function(g){var d=f&&f[g];t.current[g]=d}),o&&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(jn).forEach(function(g){var d=jn[g];f&&(f[g]=d)}),f&&(f.paddingRight="".concat(u,"px"))}c&&Rn()&&(c.addEventListener("touchmove",Dn,Ze),s&&(s.addEventListener("touchstart",Fn,Ze),s.addEventListener("touchmove",zn,Ze))),et+=1}},[o]),r=F.useCallback(function(s){if(An){var c=document.body,f=c&&c.style;et=Math.max(et-1,0),o&&et<1&&Mn.forEach(function(p){var y=t.current[p];f&&(f[p]=y)}),c&&Rn()&&(c.removeEventListener("touchmove",Dn,Ze),s&&(s.removeEventListener("touchstart",Fn,Ze),s.removeEventListener("touchmove",zn,Ze)))}},[o]);return F.useEffect(function(){if(e){var s=i.current;return a(s),function(){r(s)}}},[e,a,r]),function(s){i.current=s}}var zs=function(e){var n=e.target;return n.ownerDocument.activeElement&&n.ownerDocument.activeElement.blur()},Fs={name:"1kfdb0e",styles:"position:fixed;left:0;bottom:0;right:0;top:0"};function Rs(l){var e=l.children,n=l.lockEnabled,o=l.captureEnabled,t=o===void 0?!0:o,i=l.onBottomArrive,a=l.onBottomLeave,r=l.onTopArrive,s=l.onTopLeave,c=js({isEnabled:t,onBottomArrive:i,onBottomLeave:a,onTopArrive:r,onTopLeave:s}),f=Ds({isEnabled:n}),p=function(u){c(u),f(u)};return ie(F.Fragment,null,n&&ie("div",{onClick:zs,css:Fs}),e(p))}var As={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},Ts=function(e){var n=e.name,o=e.onFocus;return ie("input",{required:!0,name:n,tabIndex:-1,"aria-hidden":"true",onFocus:o,css:As,value:"",onChange:function(){}})},Ls=Ts,Vs=function(e){return e.label},Bs=function(e){return e.label},Ns=function(e){return e.value},$s=function(e){return!!e.isDisabled},Us={clearIndicator:Po,container:bo,control:Ao,dropdownIndicator:Io,group:Bo,groupHeading:$o,indicatorsContainer:So,indicatorSeparator:jo,input:Zo,loadingIndicator:Fo,loadingMessage:fo,menu:ao,menuList:uo,menuPortal:vo,multiValue:qo,multiValueLabel:Jo,multiValueRemove:Qo,noOptionsMessage:ho,option:as,placeholder:ls,singleValue:ds,valueContainer:wo},Ws={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%)"},Hs=4,Ir=4,Zs=38,Gs=Ir*2,Ys={baseUnit:Ir,controlHeight:Zs,menuGutter:Gs},Nt={borderRadius:Hs,colors:Ws,spacing:Ys},Ks={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:kn(),captureMenuScroll:!kn(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:Is(),formatGroupLabel:Vs,getOptionLabel:Bs,getOptionValue:Ns,isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:$s,loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!Ka(),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 Tn(l,e,n,o){var t=jr(l,e,n),i=Dr(l,e,n),a=Mr(l,e),r=Et(l,e);return{type:"option",data:e,isDisabled:t,isSelected:i,label:a,value:r,index:o}}function Er(l,e){return l.options.map(function(n,o){if("options"in n){var t=n.options.map(function(a,r){return Tn(l,a,e,r)}).filter(function(a){return Ln(l,a)});return t.length>0?{type:"group",data:n,options:t,index:o}:void 0}var i=Tn(l,n,e,o);return Ln(l,i)?i:void 0}).filter(Ja)}function Pr(l){return l.reduce(function(e,n){return n.type==="group"?e.push.apply(e,lr(n.options.map(function(o){return o.data}))):e.push(n.data),e},[])}function Xs(l,e){return Pr(Er(l,e))}function Ln(l,e){var n=l.inputValue,o=n===void 0?"":n,t=e.data,i=e.isSelected,a=e.label,r=e.value;return(!Fr(l)||!i)&&zr(l,{label:a,value:r,data:t},o)}function qs(l,e){var n=l.focusedValue,o=l.selectValue,t=o.indexOf(n);if(t>-1){var i=e.indexOf(n);if(i>-1)return n;if(t-1?n:e[0]}var Mr=function(e,n){return e.getOptionLabel(n)},Et=function(e,n){return e.getOptionValue(n)};function jr(l,e,n){return typeof l.isOptionDisabled=="function"?l.isOptionDisabled(e,n):!1}function Dr(l,e,n){if(n.indexOf(e)>-1)return!0;if(typeof l.isOptionSelected=="function")return l.isOptionSelected(e,n);var o=Et(l,e);return n.some(function(t){return Et(l,t)===o})}function zr(l,e,n){return l.filterOption?l.filterOption(e,n):!0}var Fr=function(e){var n=e.hideSelectedOptions,o=e.isMulti;return n===void 0?o:n},Qs=1,Rr=function(l){xa(n,l);var e=ka(n);function n(o){var t;if(ya(this,n),t=e.call(this,o),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,s){var c=t.props,f=c.onChange,p=c.name;s.name=p,t.ariaOnChange(r,s),f(r,s)},t.setValue=function(r,s,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:s,option:c})},t.selectOption=function(r){var s=t.props,c=s.blurInputOnSelect,f=s.isMulti,p=s.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(lr(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 s=t.props.isMulti,c=t.state.selectValue,f=t.getOptionValue(r),p=c.filter(function(u){return t.getOptionValue(u)!==f}),y=mt(s,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,s=t.state.selectValue,c=s[s.length-1],f=s.slice(0,s.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,s=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 s=t.props.inputValue,c=r.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(c,{action:"input-change",prevInputValue:s}),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 s=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:s}),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 Fr(t.props)},t.onValueInputFocus=function(r){r.preventDefault(),r.stopPropagation(),t.focus()},t.onKeyDown=function(r){var s=t.props,c=s.isMulti,f=s.backspaceRemovesValue,p=s.escapeClearsValue,y=s.inputValue,u=s.isClearable,g=s.isDisabled,d=s.menuIsOpen,b=s.onKeyDown,m=s.tabSelectsValue,w=s.openMenuOnFocus,_=t.state,C=_.focusedOption,I=_.focusedValue,P=_.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||++Qs),t.state.selectValue=_n(o.value),o.menuIsOpen&&t.state.selectValue.length){var i=t.buildFocusableOptions(),a=i.indexOf(t.state.selectValue[0]);t.state.focusedOption=i[a]}return t}return wa(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&&Cn(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(t){var i=this.props,a=i.isDisabled,r=i.menuIsOpen,s=this.state.isFocused;(s&&!a&&t.isDisabled||s&&r&&!t.menuIsOpen)&&this.focusInput(),s&&a&&!t.isDisabled?this.setState({isFocused:!1},this.onMenuClose):!s&&!a&&t.isDisabled&&this.inputRef===document.activeElement&&this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Cn(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,s=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=!(s&&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 s=a.indexOf(r);r||(s=-1);var c=a.length-1,f=-1;if(a.length){switch(t){case"previous":s===0?f=0:s===-1?f=c:f=s-1;break;case"next":s>-1&&s0&&arguments[0]!==void 0?arguments[0]:"first",i=this.props.pageSize,a=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var s=0,c=r.indexOf(a);a||(c=-1),t==="up"?s=c>0?c-1:r.length-1:t==="down"?s=(c+1)%r.length:t==="pageup"?(s=c-i,s<0&&(s=0)):t==="pagedown"?(s=c+i,s>r.length-1&&(s=r.length-1)):t==="last"&&(s=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[s],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?typeof this.props.theme=="function"?this.props.theme(Nt):re(re({},Nt),this.props.theme):Nt}},{key:"getCommonProps",value:function(){var t=this.clearValue,i=this.cx,a=this.getStyles,r=this.getClassNames,s=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:s,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 jr(this.props,t,i)}},{key:"isOptionSelected",value:function(t,i){return Dr(this.props,t,i)}},{key:"filterOption",value:function(t,i){return zr(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,s=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,_=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?F.createElement(g,ae({},w,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:_,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:s},C)):F.createElement(Ps,ae({id:_,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,s=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,_=this.state,C=_.selectValue,I=_.focusedValue,P=_.isFocused;if(!this.hasValue()||!g)return m?null:F.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 F.createElement(a,ae({},y,{components:{Container:r,Label:s,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 F.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,s=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!this.isClearable()||!i||s||!this.hasValue()||c)return null;var p={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return F.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,s=r.isDisabled,c=r.isLoading,f=this.state.isFocused;if(!i||!c)return null;var p={"aria-hidden":"true"};return F.createElement(i,ae({},a,{innerProps:p,isDisabled:s,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,s=this.props.isDisabled,c=this.state.isFocused;return F.createElement(a,ae({},r,{isDisabled:s,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,s=this.state.isFocused,c={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return F.createElement(i,ae({},a,{innerProps:c,isDisabled:r,isFocused:s}))}},{key:"renderMenu",value:function(){var t=this,i=this.getComponents(),a=i.Group,r=i.GroupHeading,s=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,_=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,B=b.onMenuScrollToBottom;if(!E)return null;var te=function(ee,X){var Z=ee.type,ce=ee.data,he=ee.isDisabled,se=ee.isSelected,le=ee.label,ge=ee.value,pe=d===ce,Ce=he?void 0:function(){return t.onOptionHover(ce)},ke=he?void 0:function(){return t.selectOption(ce)},h="".concat(t.getElementId("option"),"-").concat(X),$={id:h,onClick:ke,onMouseMove:Ce,onMouseOver:Ce,tabIndex:-1};return F.createElement(u,ae({},g,{innerProps:$,data:ce,isDisabled:he,isSelected:se,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 F.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(se){return te(se,"".concat(Z,"-").concat(se.index))}))}else if(z.type==="option")return te(z,"".concat(z.index))});else if(_){var J=C({inputValue:w});if(J===null)return null;T=F.createElement(p,g,J)}else{var N=L({inputValue:w});if(N===null)return null;T=F.createElement(y,g,N)}var K={minMenuHeight:I,maxMenuHeight:P,menuPlacement:D,menuPosition:j,menuShouldScrollIntoView:O},A=F.createElement(oo,ae({},g,K),function(z){var ee=z.ref,X=z.placerProps,Z=X.placement,ce=X.maxHeight;return F.createElement(s,ae({},g,K,{innerRef:ee,innerProps:{onMouseDown:t.onMenuMouseDown,onMouseMove:t.onMenuMouseMove,id:t.getElementId("listbox")},isLoading:_,placement:Z}),F.createElement(Rs,{captureEnabled:m,onTopArrive:v,onBottomArrive:B,lockEnabled:q},function(he){return F.createElement(c,ae({},g,{innerRef:function(le){t.getMenuListRef(le),he(le)},isLoading:_,maxHeight:ce,focusedOption:d}),T)}))});return U||j==="fixed"?F.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,s=i.isMulti,c=i.name,f=i.required,p=this.state.selectValue;if(f&&!this.hasValue()&&!r)return F.createElement(Ls,{name:c,onFocus:this.onValueInputFocus});if(!(!c||r))if(s)if(a){var y=p.map(function(d){return t.getOptionValue(d)}).join(a);return F.createElement("input",{name:c,type:"hidden",value:y})}else{var u=p.length>0?p.map(function(d,b){return F.createElement("input",{key:"i-".concat(b),name:c,type:"hidden",value:t.getOptionValue(d)})}):F.createElement("input",{name:c,type:"hidden",value:""});return F.createElement("div",null,u)}else{var g=p[0]?this.getOptionValue(p[0]):"";return F.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,s=i.focusedValue,c=i.isFocused,f=i.selectValue,p=this.getFocusableOptions();return F.createElement(_s,ae({},t,{id:this.getElementId("live-region"),ariaSelection:a,focusedOption:r,focusedValue:s,isFocused:c,selectValue:f,focusableOptions:p}))}},{key:"render",value:function(){var t=this.getComponents(),i=t.Control,a=t.IndicatorsContainer,r=t.SelectContainer,s=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 F.createElement(r,ae({},d,{className:f,innerProps:{id:p,onKeyDown:this.onKeyDown},isDisabled:y,isFocused:g}),this.renderLiveRegion(),F.createElement(i,ae({},d,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:y,isFocused:g,menuIsOpen:u}),F.createElement(s,ae({},d,{isDisabled:y}),this.renderPlaceholderOrValue(),this.renderInput()),F.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,s=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=_n(u),w={};if(a&&(u!==a.value||y!==a.options||g!==a.menuIsOpen||d!==a.inputValue)){var _=g?Xs(t,m):[],C=r?qs(i,m):null,I=Js(i,_);w={selectValue:m,focusedOption:I,focusedValue:C,clearFocusValueOnUpdate:!1}}var P=s!=null&&t!==a?{inputIsHidden:s,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}(F.Component);Rr.defaultProps=Ks;var el=F.forwardRef(function(l,e){var n=ba(l);return F.createElement(Rr,ae({ref:e},n))}),tl=el,nl=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"];function Gt(){return Gt=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var Ar=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=rl(e,nl);return Gt({},n)},il=function(e){var n=typeof e=="string";return n&&["sm","md","lg"].includes(e)},al=function(e){return il(e)?e:e==="xs"?"sm":e==="xl"?"lg":"md"},De=function(e){var n=Mt(),o=al(n.components.Input.defaultProps.size),t=e??o,i=Vi(typeof t=="string"?[t]:t,{fallback:"md"})||o;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 dl=function(e){var n=e.className,o=e.cx,t=e.children,i=e.innerRef,a=e.innerProps,r=e.isDisabled,s=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),_=$e("Input",{size:w,variant:u,focusBorderColor:g,errorBorderColor:d}),C=_.field,I=C.height,P=C.h,E=cl(C,ul),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 oe.createElement(de,Pe({ref:i,className:o({control:!0,"control--is-disabled":r,"control--is-focused":s,"control--menu-is-open":c},n),sx:U},a,{"data-focus":s?!0:void 0,"data-focus-visible":s?!0:void 0,"data-invalid":b?!0:void 0,"data-disabled":r?!0:void 0,"data-readonly":m?!0:void 0}),t)},hl=function(e){var n=e.className,o=e.cx,t=e.selectProps,i=t.chakraStyles,a=t.useBasicStyles,r=t.variant,s=Pe({opacity:1},a||r!=="outline"?{display:"none"}:{}),c=i!=null&&i.indicatorSeparator?i.indicatorSeparator(s,e):s;return oe.createElement(Jn,{className:o({"indicator-separator":!0},n),sx:c,orientation:"vertical"})},fl=function(e){return oe.createElement(Jt,Pe({role:"presentation",focusable:"false","aria-hidden":"true"},e),oe.createElement("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}))},pl=function(e){var n=e.children,o=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,s=a.useBasicStyles,c=a.size,f=a.focusBorderColor,p=a.errorBorderColor,y=a.variant,u=De(c),g=$e("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},s&&{background:"transparent",padding:0,width:6,marginRight:2,marginLeft:1,cursor:"inherit"}),w=r!=null&&r.dropdownIndicator?r.dropdownIndicator(m,e):m,_={height:"1em",width:"1em"},C=r!=null&&r.downChevron?r.downChevron(_,e):_;return oe.createElement(de,Pe({},i,{className:t({indicator:!0,"dropdown-indicator":!0},o),sx:w}),n||oe.createElement(fl,{sx:C}))},ml=function(e){return oe.createElement(Jt,Pe({focusable:"false","aria-hidden":!0},e),oe.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"}))},vl=function(e){var n=e.children,o=e.className,t=e.cx,i=e.innerProps,a=e.selectProps,r=a.chakraStyles,s=a.size,c=De(s),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 oe.createElement(de,Pe({role:"button",className:t({indicator:!0,"clear-indicator":!0},o),sx:y,"aria-label":"Clear selected options"},i),n||oe.createElement(ml,{sx:g}))},gl=function(e){var n=e.className,o=e.cx,t=e.innerProps,i=e.selectProps,a=i.chakraStyles,r=i.size,s=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 oe.createElement(qr,Pe({className:o({indicator:!0,"loading-indicator":!0},n),sx:m},t,{size:y||d,color:s,emptyColor:c,speed:f,thickness:p}))};const bl=dl;var yl=["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 xl=function(e){var n=e.className,o=e.cx,t=e.value,i=e.selectProps,a=i.chakraStyles,r=i.isReadOnly,s=Ar(e),c=s.innerRef,f=s.isDisabled,p=s.isHidden,y=s.inputClassName,u=wl(s,yl),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 oe.createElement(de,{className:o({"input-container":!0},n),"data-value":t||"",sx:b},oe.createElement(Ue.input,rt({className:o({input:!0},y),ref:c,sx:w,disabled:f,readOnly:r?!0:void 0},u)))};const Sl=xl;var _l=["data"];function Cl(l,e){if(l==null)return{};var n={},o=Object.keys(l),t,i;for(i=0;i=0)&&(n[t]=l[t]);return n}function _e(){return _e=Object.assign?Object.assign.bind():function(l){for(var e=1;e=0)&&(n[t]=l[t]);return n}var ql=function(e){var n,o=e.components,t=o===void 0?{}:o;e.theme;var i=e.size,a=e.colorScheme,r=a===void 0?"gray":a,s=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,_=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=Xl(e,Kl),O=Mt(),L=O.components.Input.defaultProps.variant,v=yi({id:u,isDisabled:s,isInvalid:c,isRequired:y,isReadOnly:f,onFocus:D,onBlur:j}),B=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 N=Pt({components:Pt({},Yl,t),colorScheme:r,size:i,tagVariant:g,selectedOptionStyle:te,selectedOptionColorScheme:J,variant:_??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:B},q,{"aria-invalid":(n=q["aria-invalid"])!=null?n:v["aria-invalid"]});return N};const Jl=ql;function Xt(){return Xt=Object.assign?Object.assign.bind():function(l){for(var e=1;e({value:g,label:g})))??[],[r,s]=F.useState(a),c=async()=>{var g,d;await((g=We)==null?void 0:g.put({name:t,workflowIDs:[],updateTime:Date.now()})),await((d=We)==null?void 0:d.listAll().then(b=>o(b??[]))),i("")},f=async()=>{var d;const g=await((d=We)==null?void 0:d.listAll());o(g??[])};if(We==null)return alert("Error: TagsTable is not loaded"),null;const p=n.map(g=>({value:g.name,label:g.name})),y=37*5;return x.jsxs(wi,{isLazy:!0,onOpen:f,children:[x.jsx(xi,{children:x.jsx(xe,{"aria-label":"Delete confirm",size:"sm",variant:"ghost",icon:x.jsx(rr,{color:"#718096"})})}),x.jsxs(Si,{children:[x.jsx(_i,{}),x.jsx(Ci,{}),x.jsx(tr,{children:x.jsx("b",{children:l.name})}),x.jsxs(ki,{children:[x.jsx(eu,{isMulti:!0,name:"tags",options:p,menuIsOpen:!0,value:r,onChange:async g=>{var d;s(g),await((d=be)==null?void 0:d.updateMetaInfo(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}),x.jsxs(we,{gap:4,mt:Math.min(y,Math.max(n.length,3)*37),children:[x.jsx(it,{placeholder:"New tag name",size:"sm",mt:6,mb:6,variant:"flushed",value:t,onChange:g=>{i(g.target.value.trim())}}),x.jsx(Se,{iconSpacing:1,leftIcon:x.jsx(tn,{size:16}),colorScheme:"teal",variant:"solid",size:"xs",px:5,isDisabled:t.length===0,onClick:c,children:"New Tag"})]})]})]})]})}function nu({menuPosition:l,workflowID:e,onClose:n}){const{onDuplicateWorkflow:o}=F.useContext(nn);return x.jsx(x.Fragment,{children:x.jsx(de,{position:"absolute",top:l.y,left:l.x,children:x.jsx(Xe,{isOpen:!0,onClose:n,children:x.jsx(at,{children:x.jsx(Re,{onClick:()=>o&&o(e),children:"Duplicate"})})})})})}const Vn=F.memo(function({workflow:e}){const{colorMode:n}=qt(),[o,t]=F.useState({x:0,y:0}),[i,a]=F.useState(!1),{setDraggingFile:r,isMultiSelecting:s,onMultiSelectFlow:c,onDeleteFlow:f,multiSelectedFlowsID:p}=F.useContext(Be),y=p&&p.length>0&&p.includes(e.id),{curFlowID:u,loadWorkflowID:g}=F.useContext(nn),d=u===e.id,b=P=>{P.preventDefault(),t({x:P.clientX,y:P.clientY}),a(!0)},[m,w]=F.useState(!1),_=()=>{a(!1)},C=n==="light"?"gray.200":"#4A5568",I=x.jsx(de,{flexShrink:1,flexGrow:1,backgroundColor:d?"teal.200":i?C:void 0,color:d&&!s?"#333":void 0,draggable:!s,onDragStart:()=>r==null?void 0:r(e),borderRadius:6,px:1,py:1,onClick:()=>{!s&&g(e.id)},_hover:{bg:C},children:x.jsxs(we,{children:[e.coverMediaPath!=null&&x.jsx(Ri,{mediaLocalPath:e.coverMediaPath,size:60,hideBrokenImage:!0,isPreview:!0}),x.jsxs(Le,{textAlign:"left",gap:0,children:[x.jsx(Oe,{fontWeight:"500",children:e.name??"untitled"}),x.jsxs(Oe,{color:"GrayText",ml:2,fontSize:"sm",children:["Updated: ",Kn(e.updateTime)]})]})]})});return x.jsxs(we,{w:"100%",mb:1,justify:"space-between",onContextMenu:b,onMouseEnter:()=>{w(!0)},onMouseLeave:()=>{w(!1)},children:[s?x.jsx(ot,{isChecked:y,spacing:4,onChange:P=>{c&&c(e.id,P.target.checked)},children:I}):x.jsxs(x.Fragment,{children:[I,x.jsxs(nt,{width:"90px",justifyContent:"flex-end",children:[m&&x.jsx(tu,{workflow:e}),x.jsx(Fe,{label:"Open in new tab",children:x.jsx(xe,{"aria-label":"Open in new tab",size:"sm",variant:"ghost",onClick:()=>Oi(e.id),icon:x.jsx(Ii,{color:"#718096",size:23})})}),x.jsx(Xn,{promptMessage:"Are you sure you want to delete this workflow?",onDelete:()=>{f&&f(e.id)}})]})]}),i&&x.jsx(nu,{menuPosition:o,onClose:_,workflowID:e.id})]})});function Lr({items:l}){var y;const[e,n]=F.useState(!1),o=l.filter(He),t=l.filter(u=>!He(u)),i=(y=t[0])==null?void 0:y.parentFolderID,[a,r]=F.useState(!1),{onRefreshFilesList:s,draggingFile:c,refreshFolderStamp:f}=F.useContext(Be),p=async u=>{var g,d;if(u.preventDefault(),u.stopPropagation(),!c)return r(!1);if(He(c)){if(c.id===i)return r(!1);await((g=Ve)==null?void 0:g.update(c.id,{parentFolderID:i}))}else await((d=be)==null?void 0:d.updateFolder(c.id,{parentFolderID:i}));await(s==null?void 0:s()),r(!1)};return F.useEffect(()=>{var u;(u=ye)==null||u.getSetting("foldersOnTop").then(g=>{n(g??!1)})},[f]),x.jsxs(x.Fragment,{children:[e&&o.map(u=>x.jsx(bn,{folder:u},u.id)),x.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=>x.jsx(Vn,{workflow:u},u.id)):l.map(u=>He(u)?x.jsx(bn,{folder:u},u.id):x.jsx(Vn,{workflow:u},u.id))})]})}function du({onClose:l,onClickNewFlow:e}){const[n,o]=F.useState([]),t=F.useRef([]),i=F.useRef([]),{loadWorkflowID:a,curFlowID:r}=F.useContext(nn),[s,c]=F.useState(),[f,p]=F.useState(!1),[y,u]=F.useState([]),[g,d]=F.useState(0),[b,m]=F.useState(""),w=la(b,400),_=F.useRef(null),[C,I]=F.useState(null),P=F.useRef(window.localStorage.getItem($t)??fn.RECENTLY_MODIFIED),E=async()=>{var J,N;const T=await((J=be)==null?void 0:J.listFolderContent())??[];t.current=T,await((N=be)==null?void 0:N.listAll().then(K=>{i.current=K})),j(),d(Date.now())},D=!!s||!!w,j=()=>{if(D){const T=i.current.filter(J=>{var A;let N=!0,K=!0;return s&&(N=!!((A=J.tags)!=null&&A.includes(s))),w&&(K=!!J.name.toLocaleLowerCase().includes(w.toLocaleLowerCase())),N&&K});o(Ft(T,P.current))}else o(Ft(t.current,P.current))},U=T=>{o(Ft(n,T)),P.current=T,window.localStorage.setItem($t,T),!D&&d(Date.now())};F.useEffect(()=>{j()},[w,s]);const q=F.useCallback(async T=>{var J,N,K;await((J=be)==null?void 0:J.deleteFlow(T)),((K=(N=be)==null?void 0:N.curWorkflow)==null?void 0:K.id)===T&&await(a==null?void 0:a(null)),await E()},[s,w]);F.useEffect(()=>{E();const T=async J=>{var N;if(_.current){const K=await((N=be)==null?void 0:N.get(_.current));K&&K.json&&ji(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=F.useCallback((T,J)=>{u(N=>{const K=[...N];return J?K.push(T):K.splice(K.indexOf(T),1),K})},[]),L=(T,J)=>{var N;switch(T){case"batchDelete":r&&((N=be)==null||N.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),He(T)||(_.current=T.id)},B=T=>{m(T)},te=450;return x.jsx(Be.Provider,{value:{onRefreshFilesList:E,draggingFile:C??void 0,setDraggingFile:v,isMultiSelecting:f,onMultiSelectFlow:O,multiSelectedFlowsID:y,onDeleteFlow:q,refreshFolderStamp:g,setRefreshFolderStamp:d},children:x.jsx(de,{style:{width:te},children:x.jsxs(Ei,{width:te,height:"100vh",pl:4,pr:5,pt:4,gap:4,position:"absolute",top:0,left:0,shadow:"xl",zIndex:Pi,children:[x.jsxs(nt,{alignItems:"center",justifyContent:"space-between",children:[x.jsxs(we,{gap:4,children:[x.jsx(we,{gap:2,children:x.jsx(Oe,{fontSize:19,fontWeight:600,children:"☕️Workspace"})}),x.jsx(or,{}),x.jsx(Fe,{label:"Open workspace save directory",children:x.jsx(xe,{"aria-label":"Open workspace save directory",size:"sm",icon:x.jsx(qn,{}),variant:"outline",colorScheme:"teal",onClick:()=>Mi()})}),x.jsx(Fe,{label:"New workflow",children:x.jsx(xe,{"aria-label":"New workflow",size:"sm",icon:x.jsx(tn,{}),variant:"outline",colorScheme:"teal",onClick:e})})]}),x.jsx(we,{alignItems:"center",children:x.jsx(oa,{})})]}),x.jsxs(nt,{direction:"column",h:"calc(100% - 64px)",children:[x.jsx(da,{selectedTag:s,setSelectedTag:c}),x.jsxs(we,{mb:2,mt:2,p:0,justifyContent:"space-between",children:[x.jsxs(we,{children:[i.current.length>0?x.jsx(sa,{multipleState:f,changeMultipleState:T=>{p(T),!T&&u([])},selectedKeys:y,isSelectedAll:y.length===i.current.length,batchOperationCallback:L}):x.jsx(de,{}),!f&&x.jsx(Fe,{hasArrow:!0,label:"New folder",placement:"bottom-start",children:x.jsx(xe,{size:"sm",variant:"outline",icon:x.jsx(nr,{size:21}),onClick:async()=>{var T;await((T=Ve)==null?void 0:T.create({name:"New Folder"})),E()},"aria-label":"new folder button"})})]}),x.jsxs(Xe,{closeOnSelect:!0,children:[x.jsx(jt,{as:Se,variant:"ghost",size:"xs",pr:0,rightIcon:x.jsx(en,{size:"16"}),children:x.jsxs(we,{children:[x.jsx(Oe,{children:"Sort by:"}),x.jsx(Oe,{display:"inline-block",children:P.current})]})}),x.jsx(at,{children:x.jsx(er,{value:P.current,type:"radio",onChange:T=>U(T),children:Object.values(fn).map((T,J)=>x.jsx(rn,{value:T,children:T},J))})})]})]}),x.jsx(ca,{searchValue:b,onUpdateSearchValue:B}),x.jsx(nt,{overflowY:"auto",overflowX:"hidden",direction:"column",children:x.jsx(Lr,{items:n})})]})]})})})}export{du as default}; diff --git a/dist/workspace_web/ShareDialog-17qMdssr.js b/dist/workspace_web/ShareDialog-17qMdssr.js new file mode 100644 index 0000000..d4ad791 --- /dev/null +++ b/dist/workspace_web/ShareDialog-17qMdssr.js @@ -0,0 +1 @@ +import{r as n,m as he,v as ne,b as fe,f as re,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 K,M as be,L as ke,N as xe,O as ye,R as Ce}from"./input.js";import{av as je,B as Se,G as De,a8 as Ie,H as Y,k as Q,n as Pe,aw as Re,a6 as ie,p as _e,m as ae,j as le,ax as Fe,l as Ee,F as Me,w as G,ay as U,az as Ne,aA as We,aB as Le,T as Te,aC as Ve,af as Oe,ae as He}from"./App-GluzE5n7.js";import{app as Be}from"/scripts/app.js";import{t as Ae}from"./index-pz0vT7Or.js";import"/scripts/api.js";function Ge(t){return t&&ne(t)&&ne(t.target)}function Ke(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[b,C]=n.useState(s||""),m=typeof c<"u",j=m?c:b,k=n.useRef(null),S=n.useCallback(()=>{const a=k.current;if(!a)return;let i="input:not(:disabled):checked";const D=a.querySelector(i);if(D){D.focus();return}i="input:not(:disabled)";const o=a.querySelector(i);o==null||o.focus()},[]),v=`radio-${n.useId()}`,N=d||v,R=n.useCallback(a=>{const i=Ge(a)?a.target.value:a;m||C(i),p==null||p(String(i))},[p,m]),H=n.useCallback((a={},i=null)=>({...a,ref:he(i,k),role:"radiogroup"}),[]),_=n.useCallback((a={},i=null)=>({...a,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?a.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:H,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=re((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...b}=t,{value:C,onChange:m,getRootProps:j,name:k,htmlProps:S}=Ke(b),M=n.useMemo(()=>({name:k,size:s,onChange:m,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,m,c,C,d,g,f]);return e.jsx($e,{value:M,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var qe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function ze(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:b,value:C,id:m,"data-radiogroup":j,"aria-describedby":k,...S}=t,M=`radio-${n.useId()}`,v=je(),R=!!ce()||!!j;let _=!!v&&!R?v.id:M;_=m??_;const a=d??(v==null?void 0:v.isDisabled),i=h??(v==null?void 0:v.isReadOnly),D=u??(v==null?void 0:v.isRequired),o=f??(v==null?void 0:v.isInvalid),[l,P]=n.useState(!1),[w,I]=n.useState(!1),[x,W]=n.useState(!1),[L,T]=n.useState(!1),[$,q]=n.useState(!!p),B=typeof c<"u",F=B?c:$;n.useEffect(()=>Ae(P),[]);const V=n.useCallback(r=>{if(i||a){r.preventDefault();return}B||q(r.target.checked),g==null||g(r)},[B,a,i,g]),A=n.useCallback(r=>{r.key===" "&&T(!0)},[T]),z=n.useCallback(r=>{r.key===" "&&T(!1)},[T]),ee=n.useCallback((r={},O=null)=>({...r,ref:O,"data-active":y(L),"data-hover":y(x),"data-disabled":y(a),"data-invalid":y(o),"data-checked":y(F),"data-focus":y(w),"data-focus-visible":y(w&&l),"data-readonly":y(i),"aria-hidden":!0,onMouseDown:E(r.onMouseDown,()=>T(!0)),onMouseUp:E(r.onMouseUp,()=>T(!1)),onMouseEnter:E(r.onMouseEnter,()=>W(!0)),onMouseLeave:E(r.onMouseLeave,()=>W(!1))}),[L,x,a,o,F,w,i,l]),{onFocus:oe,onBlur:se}=v??{},ue=n.useCallback((r={},O=null)=>{const te=a&&!s;return{...r,id:_,ref:O,type:"radio",name:b,value:C,onChange:E(r.onChange,V),onBlur:E(se,r.onBlur,()=>I(!1)),onFocus:E(oe,r.onFocus,()=>I(!0)),onKeyDown:E(r.onKeyDown,A),onKeyUp:E(r.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:D,"aria-invalid":X(o),"aria-disabled":X(te),"aria-required":X(D),"data-readonly":y(i),"aria-describedby":k,style:qe}},[a,s,_,b,C,V,se,oe,A,z,F,i,D,o,k]);return{state:{isInvalid:o,isFocused:w,isChecked:F,isActive:L,isHovered:x,isDisabled:a,isReadOnly:i,isRequired:D},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(r={},O=null)=>({...r,ref:O,onMouseDown:E(r.onMouseDown,Ue),"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(r,O=null)=>({...r,ref:O,"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Ue(t){t.preventDefault(),t.stopPropagation()}function Je(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=re((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=ve(t),{spacing:f="0.5rem",children:b,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:m=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let M=d;s!=null&&s.onChange&&h!=null&&(M=we(s.onChange,d));const v=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:H,getRootProps:_,htmlProps:a}=ze({...k,isChecked:S,isFocusable:m,isDisabled:C,onChange:M,name:v}),[i,D]=Je(a,me),o=R(D),l=N(j,p),P=H(),w=Object.assign({},i,_()),I={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},W={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...w,__css:I,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:W,children:b})]})});Z.displayName="Radio";function Ye({options:t,value:p,onChange:c}){const[s,d]=n.useState(!1),h=n.useRef(null),u=t.find(f=>f.value===p);n.useEffect(()=>{const f=b=>{h.current&&!h.current.contains(b.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Se,{position:"relative",children:[e.jsx(K,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Ie,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(K,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Qe({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Y,{spacing:4,alignItems:"center",children:[e.jsx(Q,{children:s.name}),e.jsx(Q,{color:"GrayText",children:Pe(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(K,{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:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function ro({onClose:t}){var i,D;const[p,c]=n.useState("version "+Xe()),[s,d]=n.useState([]),[h,u]=n.useState(!1),[g,f]=n.useState(""),[b,C]=n.useState("PRIVATE"),[m,j]=n.useState("new_version"),k=n.useRef(""),[S,M]=n.useState(),v=_e(),N=async o=>{var W,L;const l=o.data;if(o.origin!==k.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,w=l.localVersionID,I=l.version.id,x=l.version.workflowID;x&&P&&await((W=G)==null?void 0:W.updateMetaInfo(P,{cloudID:x,cloudOrigin:o.origin})),w&&I&&await((L=U)==null?void 0:L.update(w,{cloudID:I,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+x+"/"+I,"_blank"),u(!1)};n.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,w,I;const o=await((P=ae)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const l=((w=G)==null?void 0:w.curWorkflow)??void 0;M(l),l!=null&&l.cloudID&&l.cloudOrigin&&Le(l).then(x=>{C(x)}),(I=U)==null||I.listByWorkflowID(l.id).then(x=>{d(x)})},H=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 q,B,F;u(!0);const o=Ne(32),l=await((q=ae)==null?void 0:q.getSetting("cloudHost"));let P,w;try{if(P=We(),m==="new_version"?w=await((B=U)==null?void 0:B.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(Be.graph.serialize())})):w=await((F=U)==null?void 0:F.get(m)),!w){alert(`Failed to find version: ${m}, please try again.`),u(!1);return}}catch(V){console.error(V),u(!1),alert("Failed to share workflow, please try again.");return}const I=window.location.protocol,x=window.location.host,W=`${I}//${x}`,L=l+`/share_workflow_confirm/${o}?redirectUrl=${W}`,T=window.open(L,"Share Workflow","width=800,height=800"),$=V=>{var A;if(V.origin===l&&V.data==="child_ready"){const z=(A=G)==null?void 0:A.curWorkflow;T.postMessage({workflow:z,version:w,nodeDefs:P,privacy:b},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},a=(D=(i=G)==null?void 0:i.curWorkflow)==null?void 0:D.cloudID;return e.jsxs(be,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(xe,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(le,{gap:5,children:[a==null?e.jsx(Ye,{options:Fe,value:b,onChange:o=>{C(o)}}):e.jsx(Te,{variant:"outline",borderRadius:"full",width:"fit-content",children:e.jsx(Ve,{privacy:b,showEmoji:!0})}),a&&e.jsxs(Y,{spacing:2,color:"teal.400",children:[e.jsxs(Oe,{href:g+"/workflow/"+a,isExternal:!0,children:[g+"/workflow/"+a," ",e.jsx(ie,{size:20,style:{display:"inline-block",verticalAlign:"middle"}})]}),e.jsx(K,{width:"180px",size:"sm",leftIcon:e.jsx(He,{}),onClick:()=>{var o,l;H(g+"/workflow/"+((l=(o=G)==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=>{j(o)},value:m,children:e.jsxs(le,{children:[e.jsxs(Y,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Ee,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Me,{color:"green",children:e.jsx(Q,{children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Qe,{version:o,cloudHost:g,cloudWorkflowID:a??null},o.id))]})})]}),e.jsx(Y,{justifyContent:"flex-end",mt:16,children:e.jsx(K,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function Xe(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{ro as default}; diff --git a/dist/workspace_web/ShareDialog-yZ9MQqaN.js b/dist/workspace_web/ShareDialog-yZ9MQqaN.js deleted file mode 100644 index 13981d6..0000000 --- a/dist/workspace_web/ShareDialog-yZ9MQqaN.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,m as he,v as ne,b as fe,f as re,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 me,ab as we,B as K,M as be,L as ke,N as xe,O as ye,R as Ce}from"./input.js";import{au as je,B as Se,E as De,a7 as Ie,H as Y,T as Q,m as Pe,av as Re,a5 as ie,o as _e,l as ae,j as le,aw as Fe,k as Ee,F as Me,w as G,ax as U,ay as Ne,az as We,aA as Le,aB as Te,ae as Ve,ad as Oe}from"./App-Fl7cObcs.js";import{app as He}from"/scripts/app.js";import{t as Be}from"./index-pz0vT7Or.js";import{T as Ae}from"./chunk-RPO2WXNL-dt-e86vT.js";import"/scripts/api.js";function Ge(t){return t&&ne(t)&&ne(t.target)}function Ke(t={}){const{onChange:p,value:c,defaultValue:s,name:d,isDisabled:h,isFocusable:u,isNative:g,...f}=t,[b,C]=n.useState(s||""),w=typeof c<"u",j=w?c:b,k=n.useRef(null),S=n.useCallback(()=>{const a=k.current;if(!a)return;let i="input:not(:disabled):checked";const D=a.querySelector(i);if(D){D.focus();return}i="input:not(:disabled)";const o=a.querySelector(i);o==null||o.focus()},[]),v=`radio-${n.useId()}`,N=d||v,R=n.useCallback(a=>{const i=Ge(a)?a.target.value:a;w||C(i),p==null||p(String(i))},[p,w]),H=n.useCallback((a={},i=null)=>({...a,ref:he(i,k),role:"radiogroup"}),[]),_=n.useCallback((a={},i=null)=>({...a,ref:i,name:N,[g?"checked":"isChecked"]:j!=null?a.value===j:void 0,onChange(o){R(o)},"data-radiogroup":!0}),[g,N,R,j]);return{getRootProps:H,getRadioProps:_,name:N,ref:k,focus:S,setValue:C,value:j,onChange:R,isDisabled:h,isFocusable:u,htmlProps:f}}var[$e,ce]=fe({name:"RadioGroupContext",strict:!1}),de=re((t,p)=>{const{colorScheme:c,size:s,variant:d,children:h,className:u,isDisabled:g,isFocusable:f,...b}=t,{value:C,onChange:w,getRootProps:j,name:k,htmlProps:S}=Ke(b),M=n.useMemo(()=>({name:k,size:s,onChange:w,colorScheme:c,value:C,variant:d,isDisabled:g,isFocusable:f}),[k,s,w,c,C,d,g,f]);return e.jsx($e,{value:M,children:e.jsx(J.div,{...j(S,p),className:pe("chakra-radio-group",u),children:h})})});de.displayName="RadioGroup";var qe={border:"0",clip:"rect(0, 0, 0, 0)",height:"1px",width:"1px",margin:"-1px",padding:"0",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"};function ze(t={}){const{defaultChecked:p,isChecked:c,isFocusable:s,isDisabled:d,isReadOnly:h,isRequired:u,onChange:g,isInvalid:f,name:b,value:C,id:w,"data-radiogroup":j,"aria-describedby":k,...S}=t,M=`radio-${n.useId()}`,v=je(),R=!!ce()||!!j;let _=!!v&&!R?v.id:M;_=w??_;const a=d??(v==null?void 0:v.isDisabled),i=h??(v==null?void 0:v.isReadOnly),D=u??(v==null?void 0:v.isRequired),o=f??(v==null?void 0:v.isInvalid),[l,P]=n.useState(!1),[m,I]=n.useState(!1),[x,W]=n.useState(!1),[L,T]=n.useState(!1),[$,q]=n.useState(!!p),B=typeof c<"u",F=B?c:$;n.useEffect(()=>Be(P),[]);const V=n.useCallback(r=>{if(i||a){r.preventDefault();return}B||q(r.target.checked),g==null||g(r)},[B,a,i,g]),A=n.useCallback(r=>{r.key===" "&&T(!0)},[T]),z=n.useCallback(r=>{r.key===" "&&T(!1)},[T]),ee=n.useCallback((r={},O=null)=>({...r,ref:O,"data-active":y(L),"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(i),"aria-hidden":!0,onMouseDown:E(r.onMouseDown,()=>T(!0)),onMouseUp:E(r.onMouseUp,()=>T(!1)),onMouseEnter:E(r.onMouseEnter,()=>W(!0)),onMouseLeave:E(r.onMouseLeave,()=>W(!1))}),[L,x,a,o,F,m,i,l]),{onFocus:oe,onBlur:se}=v??{},ue=n.useCallback((r={},O=null)=>{const te=a&&!s;return{...r,id:_,ref:O,type:"radio",name:b,value:C,onChange:E(r.onChange,V),onBlur:E(se,r.onBlur,()=>I(!1)),onFocus:E(oe,r.onFocus,()=>I(!0)),onKeyDown:E(r.onKeyDown,A),onKeyUp:E(r.onKeyUp,z),checked:F,disabled:te,readOnly:i,required:D,"aria-invalid":X(o),"aria-disabled":X(te),"aria-required":X(D),"data-readonly":y(i),"aria-describedby":k,style:qe}},[a,s,_,b,C,V,se,oe,A,z,F,i,D,o,k]);return{state:{isInvalid:o,isFocused:m,isChecked:F,isActive:L,isHovered:x,isDisabled:a,isReadOnly:i,isRequired:D},getCheckboxProps:ee,getRadioProps:ee,getInputProps:ue,getLabelProps:(r={},O=null)=>({...r,ref:O,onMouseDown:E(r.onMouseDown,Ue),"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),getRootProps:(r,O=null)=>({...r,ref:O,"data-disabled":y(a),"data-checked":y(F),"data-invalid":y(o)}),htmlProps:S}}function Ue(t){t.preventDefault(),t.stopPropagation()}function Je(t,p){const c={},s={};for(const[d,h]of Object.entries(t))p.includes(d)?c[d]=h:s[d]=h;return[c,s]}var Z=re((t,p)=>{var c;const s=ce(),{onChange:d,value:h}=t,u=ge("Radio",{...s,...t}),g=ve(t),{spacing:f="0.5rem",children:b,isDisabled:C=s==null?void 0:s.isDisabled,isFocusable:w=s==null?void 0:s.isFocusable,inputProps:j,...k}=g;let S=t.isChecked;(s==null?void 0:s.value)!=null&&h!=null&&(S=s.value===h);let M=d;s!=null&&s.onChange&&h!=null&&(M=me(s.onChange,d));const v=(c=t==null?void 0:t.name)!=null?c:s==null?void 0:s.name,{getInputProps:N,getCheckboxProps:R,getLabelProps:H,getRootProps:_,htmlProps:a}=ze({...k,isChecked:S,isFocusable:w,isDisabled:C,onChange:M,name:v}),[i,D]=Je(a,we),o=R(D),l=N(j,p),P=H(),m=Object.assign({},i,_()),I={display:"inline-flex",alignItems:"center",verticalAlign:"top",cursor:"pointer",position:"relative",...u.container},x={display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...u.control},W={userSelect:"none",marginStart:f,...u.label};return e.jsxs(J.label,{className:"chakra-radio",...m,__css:I,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:W,children:b})]})});Z.displayName="Radio";function Ye({options:t,value:p,onChange:c}){const[s,d]=n.useState(!1),h=n.useRef(null),u=t.find(f=>f.value===p);n.useEffect(()=>{const f=b=>{h.current&&!h.current.contains(b.target)&&d(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[h]);const g=()=>d(!s);return e.jsxs(Se,{position:"relative",children:[e.jsx(K,{onClick:g,rightIcon:e.jsx(De,{}),leftIcon:u==null?void 0:u.icon,children:u==null?void 0:u.label}),s&&e.jsx(Ie,{gap:4,ref:h,mt:"2",shadow:"md",borderWidth:"1px",p:"2",position:"absolute",zIndex:100,children:t.map(f=>e.jsx(K,{onClick:()=>{d(!1),c(f.value)},leftIcon:f.icon,justifyContent:"flex-start",variant:"ghost",width:"full",children:f.label},f.label))})]})}function Qe({version:t,cloudHost:p,cloudWorkflowID:c}){const s=t,d=e.jsxs(Y,{spacing:4,alignItems:"center",children:[e.jsx(Q,{children:s.name}),e.jsx(Q,{color:"GrayText",children:Pe(s.createTime,!1)}),s.cloudID&&c&&e.jsx("a",{href:p+"/workflow/"+c+"/"+s.cloudID,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(K,{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:d}):e.jsx(Z,{value:s.id,mb:5,children:d},s.id)}function io({onClose:t}){var i,D;const[p,c]=n.useState("version "+Xe()),[s,d]=n.useState([]),[h,u]=n.useState(!1),[g,f]=n.useState(""),[b,C]=n.useState("PRIVATE"),[w,j]=n.useState("new_version"),k=n.useRef(""),[S,M]=n.useState(),v=_e(),N=async o=>{var W,L;const l=o.data;if(o.origin!==k.current||l.type!=="share_workflow_success")return;const P=l.localWorkflowID,m=l.localVersionID,I=l.version.id,x=l.version.workflowID;x&&P&&await((W=G)==null?void 0:W.updateMetaInfo(P,{cloudID:x,cloudOrigin:o.origin})),m&&I&&await((L=U)==null?void 0:L.update(m,{cloudID:I,cloudOrigin:o.origin})),R(),window.open(k.current+"/workflow/"+x+"/"+I,"_blank"),u(!1)};n.useEffect(()=>(R(),window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[]);const R=async()=>{var P,m,I;const o=await((P=ae)==null?void 0:P.getSetting("cloudHost"));o&&(f(o),k.current=o);const l=((m=G)==null?void 0:m.curWorkflow)??void 0;M(l),l!=null&&l.cloudID&&l.cloudOrigin&&Le(l).then(x=>{C(x)}),(I=U)==null||I.listByWorkflowID(l.id).then(x=>{d(x)})},H=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 q,B,F;u(!0);const o=Ne(32),l=await((q=ae)==null?void 0:q.getSetting("cloudHost"));let P,m;try{if(P=We(),w==="new_version"?m=await((B=U)==null?void 0:B.add({workflowID:S.id,name:p,createTime:Date.now(),json:JSON.stringify(He.graph.serialize())})):m=await((F=U)==null?void 0:F.get(w)),!m){alert(`Failed to find version: ${w}, please try again.`),u(!1);return}}catch(V){console.error(V),u(!1),alert("Failed to share workflow, please try again.");return}const I=window.location.protocol,x=window.location.host,W=`${I}//${x}`,L=l+`/share_workflow_confirm/${o}?redirectUrl=${W}`,T=window.open(L,"Share Workflow","width=800,height=800"),$=V=>{var A;if(V.origin===l&&V.data==="child_ready"){const z=(A=G)==null?void 0:A.curWorkflow;T.postMessage({workflow:z,version:m,nodeDefs:P,privacy:b},l),window.removeEventListener("message",$)}};window.addEventListener("message",$)},a=(D=(i=G)==null?void 0:i.curWorkflow)==null?void 0:D.cloudID;return e.jsxs(be,{isOpen:!0,onClose:t,size:"lg",children:[e.jsx(ke,{}),e.jsxs(xe,{width:["98%","90%","50%"],maxWidth:"600px",children:[e.jsxs(ye,{children:['Share "',S==null?void 0:S.name,'"']}),e.jsxs(Ce,{pb:10,children:[e.jsxs(le,{gap:5,children:[a==null?e.jsx(Ye,{options:Fe,value:b,onChange:o=>{C(o)}}):e.jsx(Ae,{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(K,{width:"180px",size:"sm",leftIcon:e.jsx(Oe,{}),onClick:()=>{var o,l;H(g+"/workflow/"+((l=(o=G)==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=>{j(o)},value:w,children:e.jsxs(le,{children:[e.jsxs(Y,{mb:5,alignItems:"center",children:[e.jsx(Z,{value:"new_version"},"new_version"),e.jsx(Ee,{value:p,width:"60%",onFocus:()=>{j("new_version")},onChange:o=>{c(o.target.value)}}),e.jsx(Me,{color:"green",children:e.jsx(Q,{children:"New version"})})]}),s.slice(0,4).map(o=>e.jsx(Qe,{version:o,cloudHost:g,cloudWorkflowID:a??null},o.id))]})})]}),e.jsx(Y,{justifyContent:"flex-end",mt:16,children:e.jsx(K,{colorScheme:"teal",onClick:_,isDisabled:h,children:h?"Sharing":"Share"})})]})]})]})}function Xe(){const t=new Date,p=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${p}-${c}-${s}`}export{io as default}; diff --git a/dist/workspace_web/chunk-JARCRF6W-aHchqwnR.js b/dist/workspace_web/chunk-JARCRF6W-IwBcFM3i.js similarity index 99% rename from dist/workspace_web/chunk-JARCRF6W-aHchqwnR.js rename to dist/workspace_web/chunk-JARCRF6W-IwBcFM3i.js index 643983f..48f5f6d 100644 --- a/dist/workspace_web/chunk-JARCRF6W-aHchqwnR.js +++ b/dist/workspace_web/chunk-JARCRF6W-IwBcFM3i.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{at as ke}from"./App-Fl7cObcs.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 be}from"./input.js";import{au as ke}from"./App-GluzE5n7.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}; diff --git a/dist/workspace_web/chunk-NTCQBYKE-EEXlKSMU.js b/dist/workspace_web/chunk-NTCQBYKE-ZsMy4OBB.js similarity index 65% rename from dist/workspace_web/chunk-NTCQBYKE-EEXlKSMU.js rename to dist/workspace_web/chunk-NTCQBYKE-ZsMy4OBB.js index f97e0ff..ad19976 100644 --- a/dist/workspace_web/chunk-NTCQBYKE-EEXlKSMU.js +++ b/dist/workspace_web/chunk-NTCQBYKE-ZsMy4OBB.js @@ -1 +1 @@ -import{j as t}from"./App-Fl7cObcs.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-GluzE5n7.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V}; diff --git a/dist/workspace_web/chunk-RPO2WXNL-dt-e86vT.js b/dist/workspace_web/chunk-RPO2WXNL-dt-e86vT.js deleted file mode 100644 index fc91c18..0000000 --- a/dist/workspace_web/chunk-RPO2WXNL-dt-e86vT.js +++ /dev/null @@ -1 +0,0 @@ -import{b as y,f as n,i as m,o as p,j as s,g as r,I as i}from"./input.js";var[u,c]=y({name:"TagStylesContext",errorMessage:`useTagStyles returned is 'undefined'. Seems you forgot to wrap the components in "" `}),T=n((e,a)=>{const t=m("Tag",e),l=p(e),o={display:"inline-flex",verticalAlign:"top",alignItems:"center",maxWidth:"100%",...t.container};return s.jsx(u,{value:t,children:s.jsx(r.span,{ref:a,...l,__css:o})})});T.displayName="Tag";var x=n((e,a)=>{const t=c();return s.jsx(r.span,{ref:a,noOfLines:1,...e,__css:t.label})});x.displayName="TagLabel";var f=n((e,a)=>s.jsx(i,{ref:a,verticalAlign:"top",marginEnd:"0.5rem",...e}));f.displayName="TagLeftIcon";var v=n((e,a)=>s.jsx(i,{ref:a,verticalAlign:"top",marginStart:"0.5rem",...e}));v.displayName="TagRightIcon";var g=e=>s.jsx(i,{verticalAlign:"inherit",viewBox:"0 0 512 512",...e,children:s.jsx("path",{fill:"currentColor",d:"M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"})});g.displayName="TagCloseIcon";var h=n((e,a)=>{const{isDisabled:t,children:l,...o}=e,d={display:"flex",alignItems:"center",justifyContent:"center",outline:"0",...c().closeButton};return s.jsx(r.button,{ref:a,"aria-label":"close",...o,type:"button",disabled:t,__css:d,children:l||s.jsx(g,{})})});h.displayName="TagCloseButton";export{T}; diff --git a/dist/workspace_web/input.js b/dist/workspace_web/input.js index 1f702b8..b8c30c0 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-Fl7cObcs.js").then(e=>e.aD),__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,is as X,Du 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-GluzE5n7.js").then(e=>e.aE),__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,is as X,Du 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-Fl7cObcs.js","workspace_web/assets/App-JXePnJiV.css"] + __vite__mapDeps.viteFileDeps = ["workspace_web/App-GluzE5n7.js","workspace_web/assets/App-JXePnJiV.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } \ No newline at end of file diff --git a/ui/src/apis/TwowaySyncApi.ts b/ui/src/apis/TwowaySyncApi.ts index 31a6c14..8824eaa 100644 --- a/ui/src/apis/TwowaySyncApi.ts +++ b/ui/src/apis/TwowaySyncApi.ts @@ -247,7 +247,6 @@ export namespace TwowaySyncAPI { const absPath = sanitizeAbsPath( `${myWorkflowsDir}/${parentFolderID ?? ""}/${name}.json`, ); - console.warn("get abs path 🔥 workfoow", absPath); try { const response = await fetch("/workspace/get_workflow_file", { method: "POST", diff --git a/ui/src/components/DropdownTitle.tsx b/ui/src/components/DropdownTitle.tsx index ffdb2e9..39a4c5a 100644 --- a/ui/src/components/DropdownTitle.tsx +++ b/ui/src/components/DropdownTitle.tsx @@ -24,6 +24,8 @@ import { Input, Tooltip, DarkMode, + Tag, + HStack, } from "@chakra-ui/react"; import { IconArrowBackUpDouble, @@ -127,8 +129,8 @@ export default function DropdownTitle() { height={"29px"} aria-label="menu" size={"sm"} - colorScheme="gray" - backgroundColor={"gray.700"} + // backgroundColor={"gray.700"} + backgroundColor={"teal.600"} > File @@ -187,8 +189,11 @@ export default function DropdownTitle() { onClick={() => setIsShareOpen(true)} icon={} iconSpacing={1} + alignItems={"center"} > - Share + +

Share

🧪🧪beta +
diff --git a/ui/src/settings/TwoWaySyncSettings.tsx b/ui/src/settings/TwoWaySyncSettings.tsx index d74faab..ff70431 100644 --- a/ui/src/settings/TwoWaySyncSettings.tsx +++ b/ui/src/settings/TwoWaySyncSettings.tsx @@ -52,7 +52,7 @@ export default function TwoWaySyncSettings() { Finder to import them into your workspace. - Enable two way sync (DO NOT USE!! EXPERIMENTAL!) + Enable two way sync (🧪🧪beta) );