import{r as u}from"./index-BP8_t0zE.js";import{$ as P,o as S,b,e as d,q as C,ah as U}from"./defaultI18nProvider-C_r1y4tu.js";import{A as w}from"./Button-C3j8Wgdd.js";var y={loginUrl:"/login",afterLoginUrl:"/"},q=function(){return u.useContext(w)};function E(e,a){return typeof e=="function"?e(...a):!!e}function L(){}var A=function(){var e=P().reset;return e},N=function(){var e=q(),a=S(),r=A(),o=b(),i=u.useRef(o),l=d(),t=u.useRef(l),x=C(),c=U("".concat(x,"/").concat(y.loginUrl));u.useEffect(function(){t.current=l,i.current=o},[l,o]);var R=u.useCallback(function(f,s,v){return f===void 0&&(f={}),s===void 0&&(s=c),v===void 0&&(v=!0),e?e.logout(f).then(function(h){if(h===!1||s===!1){r(),a.clear();return}var n=h||s;if(n!=null&&n.startsWith("http"))return r(),a.clear(),window.location.href=n,n;var m=n.split("?"),p={pathname:m[0]},g={};return v&&t.current&&t.current.pathname&&(g={state:{nextPathname:t.current.pathname,nextSearch:t.current.search}}),m[1]&&(p.search=m[1]),i.current(p,g),r(),a.clear(),h}):(i.current({pathname:c},{state:{nextPathname:t.current&&t.current.pathname}}),r(),a.clear(),Promise.resolve())},[e,r,c,a]);return R};export{N as a,y as d,L as n,E as s,q as u};
