InvokeAI/invokeai/frontend/web/dist/assets/storeHooks-0eed8e9f.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

10 lines
108 KiB
JavaScript
Raw Normal View History

2023-03-14 18:11:42 +00:00
import{cY as zt,cZ as Ji,r as m,j as C,G as Cs,R as Ss,c as G,t as Te,f as Mt,a as Dt,e as As,S as Qi,o as Vs,d as to,c_ as eo}from"./index-d64f4654.js";function ws(t=zt){const e=t===zt?Ji:()=>m.useContext(t);return function(){const{store:s}=e();return s}}const no=ws();function so(t=zt){const e=t===zt?no:ws(t);return function(){return e().dispatch}}const io=so();function oo(t,e){return`${t} returned \`undefined\`. Seems you forgot to wrap component within ${e}`}function Rt(t={}){const{name:e,strict:n=!0,hookName:s="useContext",providerName:i="Provider",errorMessage:r}=t,o=m.createContext(void 0);o.displayName=e;function a(){var c;const l=m.useContext(o);if(!l&&n){const u=new Error(r??oo(s,i));throw u.name="ContextError",(c=Error.captureStackTrace)==null||c.call(Error,u,a),u}return l}return[o.Provider,a,o]}var[ro,ao]=Rt({strict:!1,name:"PortalManagerContext"});function co(t){const{children:e,zIndex:n}=t;return C.jsx(ro,{value:{zIndex:n},children:e})}co.displayName="PortalManager";var Ce=Boolean(globalThis==null?void 0:globalThis.document)?m.useLayoutEffect:m.useEffect,[Ms,lo]=Rt({strict:!1,name:"PortalContext"}),ze="chakra-portal",uo=".chakra-portal",fo=t=>C.jsx("div",{className:"chakra-portal-zIndex",style:{position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0},children:t.children}),ho=t=>{const{appendToParentPortal:e,children:n}=t,[s,i]=m.useState(null),r=m.useRef(null),[,o]=m.useState({});m.useEffect(()=>o({}),[]);const a=lo(),c=ao();Ce(()=>{if(!s)return;const u=s.ownerDocument,f=e?a??u.body:u.body;if(!f)return;r.current=u.createElement("div"),r.current.className=ze,f.appendChild(r.current),o({});const h=r.current;return()=>{f.contains(h)&&f.removeChild(h)}},[s]);const l=c!=null&&c.zIndex?C.jsx(fo,{zIndex:c==null?void 0:c.zIndex,children:n}):n;return r.current?Cs.createPortal(C.jsx(Ms,{value:r.current,children:l}),r.current):C.jsx("span",{ref:u=>{u&&i(u)}})},po=t=>{const{children:e,containerRef:n,appendToParentPortal:s}=t,i=n.current,r=i??(typeof window<"u"?document.body:void 0),o=m.useMemo(()=>{const c=i==null?void 0:i.ownerDocument.createElement("div");return c&&(c.className=ze),c},[i]),[,a]=m.useState({});return Ce(()=>a({}),[]),Ce(()=>{if(!(!o||!r))return r.appendChild(o),()=>{r.removeChild(o)}},[o,r]),r&&o?Cs.createPortal(C.jsx(Ms,{value:s?o:null,children:e}),o):null};function Jt(t){const e={appendToParentPortal:!0,...t},{containerRef:n,...s}=e;return n?C.jsx(po,{containerRef:n,...s}):C.jsx(ho,{...s})}Jt.className=ze;Jt.selector=uo;Jt.displayName="Portal";var mo=(t,e)=>t.find(n=>n.id===e);function yn(t,e){const n=Ds(t,e),s=n?t[n].findIndex(i=>i.id===e):-1;return{position:n,index:s}}function Ds(t,e){for(const[n,s]of Object.entries(t))if(mo(s,e))return n}function go(t){const e=t.includes("right"),n=t.includes("left");let s="center";return e&&(s="flex-end"),n&&(s="flex-start"),{display:"flex",flexDirection:"column",alignItems:s}}function yo(t){const n=t==="top"||t==="bottom"?"0 auto":void 0,s=t.includes("top")?"env(safe-area-inset-top, 0px)":void 0,i=t.includes("bottom")?"env(safe-area-inset-bottom, 0px)":void 0,r=t.includes("left")?void 0:"env(safe-area-inset-right, 0px)",o=t.includes("right")?void 0:"env(safe-area-inset-left, 0px)";return{position:"fixed",zIndex:5500,pointerEvents:"none",display:"flex",flexDirection:"column",margin:n,top:s,bottom:i,right:r,left:o}}function vo(t,e=[]){const n=m.useRef(t);return m.useEffect(()=>{n.current=t}),m.useCallback((...s)=>{var i;return(i=n.current)==null?void 0:i.call(n,...s)},e)}function xo(t,e){const n=vo(t);m.useEffect(()=>{if(e==null)return;let s=null;return s=window.setTimeout(()=>{n()},e),()=>{s&&window.clearTimeout(s)}},[e,n])}function vn(t,e){const n=m.useRef(!1),s=m.useRef(!1);m.useEffect(()=>{if(n.current&&s.current)return t();s.current=!0},e),m.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[])}const Rs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),Qt=m.createContext({});function Po(){return m.useContext(Qt).visualElement}const Et=m.createContext(null),te=typeof document<"u",$t=te?m.useLayoutEffect:m.useEffect,Es=m.createContext
[data-motion-pop-id="${n}"] {
position: absolute !important;
width: ${r}px !important;
height: ${o}px !important;
top: ${a}px !important;
left: ${c}px !important;
}
`),()=>{document.head.removeChild(l)}},[e]),m.createElement(Bl,{isPresent:e,childRef:s,sizeRef:i},m.cloneElement(t,{ref:s}))}const be=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o})=>{const a=We(Fl),c=m.useId(),l=m.useMemo(()=>({id:c,initial:e,isPresent:n,custom:i,onExitComplete:u=>{a.set(u,!0);for(const f of a.values())if(!f)return;s&&s()},register:u=>(a.set(u,!1),()=>a.delete(u))}),r?void 0:[n]);return m.useMemo(()=>{a.forEach((u,f)=>a.set(f,!1))},[n]),m.useEffect(()=>{!n&&!a.size&&s&&s()},[n]),o==="popLayout"&&(t=m.createElement(kl,{isPresent:n},t)),m.createElement(Et.Provider,{value:l},t)};function Fl(){return new Map}function Il(t){return m.useEffect(()=>()=>t(),[])}const ct=t=>t.key||"";function Ol(t,e){t.forEach(n=>{const s=ct(n);e.set(s,n)})}function Nl(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ul=({children:t,custom:e,initial:n=!0,onExitComplete:s,exitBeforeEnter:i,presenceAffectsLayout:r=!0,mode:o="sync"})=>{i&&(o="wait");let[a]=jl();const c=m.useContext(Ge).forceRender;c&&(a=c);const l=zi(),u=Nl(t);let f=u;const h=new Set,d=m.useRef(f),p=m.useRef(new Map).current,g=m.useRef(!0);if($t(()=>{g.current=!1,Ol(u,p),d.current=f}),Il(()=>{g.current=!0,p.clear(),h.clear()}),g.current)return m.createElement(m.Fragment,null,f.map(y=>m.createElement(be,{key:ct(y),isPresent:!0,initial:n?void 0:!1,presenceAffectsLayout:r,mode:o},y)));f=[...f];const T=d.current.map(ct),P=u.map(ct),x=T.length;for(let y=0;y<x;y++){const v=T[y];P.indexOf(v)===-1&&h.add(v)}return o==="wait"&&h.size&&(f=[]),h.forEach(y=>{if(P.indexOf(y)!==-1)return;const v=p.get(y);if(!v)return;const S=T.indexOf(y),w=()=>{p.delete(y),h.delete(y);const D=d.current.findIndex(N=>N.key===y);if(d.current.splice(D,1),!h.size){if(d.current=u,l.current===!1)return;a(),s&&s()}};f.splice(S,0,m.createElement(be,{key:ct(v),isPresent:!1,onExitComplete:w,custom:e,presenceAffectsLayout:r,mode:o},v))}),f=f.map(y=>{const v=y.key;return h.has(v)?y:m.createElement(be,{key:ct(y),isPresent:!0,presenceAffectsLayout:r,mode:o},y)}),m.createElement(m.Fragment,null,h.size?f:f.map(y=>m.cloneElement(y)))};var _l={initial:t=>{const{position:e}=t,n=["top","bottom"].includes(e)?"y":"x";let s=["top-right","bottom-right"].includes(e)?1:-1;return e==="bottom"&&(s=1),{opacity:0,[n]:s*24}},animate:{opacity:1,y:0,x:0,scale:1,transition:{duration:.4,ease:[.4,0,.2,1]}},exit:{opacity:0,scale:.85,transition:{duration:.2,ease:[.4,0,1,1]}}},$i=m.memo(t=>{const{id:e,message:n,onCloseComplete:s,onRequestRemove:i,requestClose:r=!1,position:o="bottom",duration:a=5e3,containerStyle:c,motionVariants:l=_l,toastSpacing:u="0.5rem"}=t,[f,h]=m.useState(a),d=Dc();vn(()=>{d||s==null||s()},[d]),vn(()=>{h(a)},[a]);const p=()=>h(null),g=()=>h(a),T=()=>{d&&i()};m.useEffect(()=>{d&&r&&i()},[d,r,i]),xo(T,f);const P=m.useMemo(()=>({pointerEvents:"auto",maxWidth:560,minWidth:300,margin:u,...c}),[c,u]),x=m.useMemo(()=>go(o),[o]);return C.jsx(Ll.li,{layout:!0,className:"chakra-toast",variants:l,initial:"initial",animate:"animate",exit:"exit",onHoverStart:p,onHoverEnd:g,custom:{position:o},style:x,children:C.jsx(G.div,{role:"status","aria-atomic":"true",className:"chakra-toast__inner",__css:P,children:Te(n,{id:e,onClose:T})})})});$i.displayName="ToastComponent";function zl(t,e){var n;const s=t??"bottom",r={"top-start":{ltr:"top-left",rtl:"top-right"},"top-end":{ltr:"top-right",rtl:"top-left"},"bottom-start":{ltr:"bottom-left",rtl:"bottom-right"},"bottom-end":{ltr:"bottom-right",rtl:"bottom-left"}}[s];return(n=r==null?void 0:r[e])!=null?n:s}var Ps={path:C.jsxs("g",{stroke:"currentColor",strokeWidth:"1.5",children:[C.jsx("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),C.jsx("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),C.jsx("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},kt=Mt((t,e)=>{const{as:n,viewBox:s,color:i="currentColor",focusable:r=!1,children:o,className:a,