mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
10 lines
108 KiB
JavaScript
10 lines
108 KiB
JavaScript
|
import{cY as zt,cZ as no,r as m,j as C,a5 as Vs,R as ws,c as K,t as Ae,f as Mt,a as Rt,e as Ms,S as so,o as Rs,d as io,c_ as oo}from"./index-bcc89564.js";function Es(t=zt){const e=t===zt?no:()=>m.useContext(t);return function(){const{store:s}=e();return s}}const ro=Es();function ao(t=zt){const e=t===zt?ro:Es(t);return function(){return e().dispatch}}const co=ao();function lo(t,e){return`${t} returned \`undefined\`. Seems you forgot to wrap component within ${e}`}function Et(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??lo(s,i));throw u.name="ContextError",(c=Error.captureStackTrace)==null||c.call(Error,u,a),u}return l}return[o.Provider,a,o]}var[uo,fo]=Et({strict:!1,name:"PortalManagerContext"});function ho(t){const{children:e,zIndex:n}=t;return C.jsx(uo,{value:{zIndex:n},children:e})}ho.displayName="PortalManager";var Ve=Boolean(globalThis==null?void 0:globalThis.document)?m.useLayoutEffect:m.useEffect,[Ls,po]=Et({strict:!1,name:"PortalContext"}),He="chakra-portal",mo=".chakra-portal",go=t=>C.jsx("div",{className:"chakra-portal-zIndex",style:{position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0},children:t.children}),yo=t=>{const{appendToParentPortal:e,children:n}=t,[s,i]=m.useState(null),r=m.useRef(null),[,o]=m.useState({});m.useEffect(()=>o({}),[]);const a=po(),c=fo();Ve(()=>{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=He,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(go,{zIndex:c==null?void 0:c.zIndex,children:n}):n;return r.current?Vs.createPortal(C.jsx(Ls,{value:r.current,children:l}),r.current):C.jsx("span",{ref:u=>{u&&i(u)}})},vo=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=He),c},[i]),[,a]=m.useState({});return Ve(()=>a({}),[]),Ve(()=>{if(!(!o||!r))return r.appendChild(o),()=>{r.removeChild(o)}},[o,r]),r&&o?Vs.createPortal(C.jsx(Ls,{value:s?o:null,children:e}),o):null};function te(t){const e={appendToParentPortal:!0,...t},{containerRef:n,...s}=e;return n?C.jsx(vo,{containerRef:n,...s}):C.jsx(yo,{...s})}te.className=He;te.selector=mo;te.displayName="Portal";var xo=(t,e)=>t.find(n=>n.id===e);function vn(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(xo(s,e))return n}function bo(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 Po(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 To(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 Co(t,e){const n=To(t);m.useEffect(()=>{if(e==null)return;let s=null;return s=window.setTimeout(()=>{n()},e),()=>{s&&window.clearTimeout(s)}},[e,n])}function xn(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 ks=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),ee=m.createContext({});function So(){return m.useContext(ee).visualElement}const Lt=m.createContext(null),ne=typeof document<"u",Ht=ne?m.useLayoutEffect:m.useEffect,Bs=m.createContex
|
||
|
[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(kl,{isPresent:e,childRef:s,sizeRef:i},m.cloneElement(t,{ref:s}))}const Se=({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(Bl,{isPresent:n},t)),m.createElement(Lt.Provider,{value:l},t)};function Fl(){return new Map}function Il(t){return m.useEffect(()=>()=>t(),[])}const ct=t=>t.key||"";function jl(t,e){t.forEach(n=>{const s=ct(n);e.set(s,n)})}function Ol(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Nl=({children:t,custom:e,initial:n=!0,onExitComplete:s,exitBeforeEnter:i,presenceAffectsLayout:r=!0,mode:o="sync"})=>{i&&(o="wait");let[a]=Dl();const c=m.useContext(Ge).forceRender;c&&(a=c);const l=Gi(),u=Ol(t);let f=u;const h=new Set,d=m.useRef(f),p=m.useRef(new Map).current,g=m.useRef(!0);if(Ht(()=>{g.current=!1,jl(u,p),d.current=f}),Il(()=>{g.current=!0,p.clear(),h.clear()}),g.current)return m.createElement(m.Fragment,null,f.map(v=>m.createElement(Se,{key:ct(v),isPresent:!0,initial:n?void 0:!1,presenceAffectsLayout:r,mode:o},v)));f=[...f];const T=d.current.map(ct),b=u.map(ct),x=T.length;for(let v=0;v<x;v++){const y=T[v];b.indexOf(y)===-1&&h.add(y)}return o==="wait"&&h.size&&(f=[]),h.forEach(v=>{if(b.indexOf(v)!==-1)return;const y=p.get(v);if(!y)return;const S=T.indexOf(v),M=()=>{p.delete(v),h.delete(v);const E=d.current.findIndex(N=>N.key===v);if(d.current.splice(E,1),!h.size){if(d.current=u,l.current===!1)return;a(),s&&s()}};f.splice(S,0,m.createElement(Se,{key:ct(y),isPresent:!1,onExitComplete:M,custom:e,presenceAffectsLayout:r,mode:o},y))}),f=f.map(v=>{const y=v.key;return h.has(y)?v:m.createElement(Se,{key:ct(v),isPresent:!0,presenceAffectsLayout:r,mode:o},v)}),m.createElement(m.Fragment,null,h.size?f:f.map(v=>m.cloneElement(v)))};var Ul={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]}}},Ki=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=Ul,toastSpacing:u="0.5rem"}=t,[f,h]=m.useState(a),d=Ec();xn(()=>{d||s==null||s()},[d]),xn(()=>{h(a)},[a]);const p=()=>h(null),g=()=>h(a),T=()=>{d&&i()};m.useEffect(()=>{d&&r&&i()},[d,r,i]),Co(T,f);const b=m.useMemo(()=>({pointerEvents:"auto",maxWidth:560,minWidth:300,margin:u,...c}),[c,u]),x=m.useMemo(()=>bo(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(K.div,{role:"status","aria-atomic":"true",className:"chakra-toast__inner",__css:b,children:Ae(n,{id:e,onClose:T})})})});Ki.displayName="ToastComponent";function _l(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 Cs={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"},Ft=Mt((t,e)=>{const{as:n,viewBox:s,color:i="currentColor",focusable:r=!1,children:o,className:a,
|