"use strict";(self.webpackChunkrichie_education=self.webpackChunkrichie_education||[]).push([[39117],{39117:function(e,r,n){n.r(r),n(32390),n(18183),n(19985),n(10853),n(35054);var t=n(89526),u=n(70488),o=n(5615),i=n(95418),s=n(47080),c=n(15462),a=n(67557);function f(e,r,n,t,u,o,i){try{var s=e[o](i),c=s.value}catch(e){return void n(e)}s.done?r(c):Promise.resolve(c).then(t,u)}function l(e){return function(){var r=this,n=arguments;return new Promise((function(t,u){var o=e.apply(r,n);function i(e){f(o,t,u,i,s,"next",e)}function s(e){f(o,t,u,i,s,"throw",e)}i(void 0)}))}}r.default=function(e){var r=e.children,n=(0,o.useQuery)("user",u.$.me,{refetchOnWindowFocus:!0,staleTime:i.o9.staleTimes.session}).data,f=(0,s.Z)(n),v=(0,o.useQueryClient)(),d=(0,t.useCallback)((function(){v.clear(),sessionStorage.removeItem(i.o9.cacheStorage.key),u.$.login()}),[v]),y=(0,t.useCallback)((function(){v.clear(),sessionStorage.removeItem(i.o9.cacheStorage.key),u.$.register()}),[v]),h=(0,t.useCallback)((function(){v.removeQueries({predicate:function(e){return e.options.queryKey.includes("user")&&"user"!==e.options.queryKey}}),v.setQueryData("user",null)}),[v]),m=(0,t.useCallback)(l(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.$.logout();case 2:h();case 3:case"end":return e.stop()}}),e)}))),[h]),p=(0,t.useMemo)((function(){return{user:n,destroy:m,invalidate:h,login:d,register:y}}),[n,m,d,y]);return(0,t.useEffect)((function(){f!==n&&v.removeQueries({predicate:function(e){return e.options.queryKey.includes("user")&&"user"!==e.options.queryKey}})}),[n]),(0,a.jsx)(c.z.Provider,{value:p,children:r})}},47080:function(e,r,n){var t=n(89526);r.Z=function(e){var r=(0,t.useRef)(e);return(0,t.useEffect)((function(){r.current=e}),[e]),r.current}}}]);
//# sourceMappingURL=39117.7e8e1b24cfb893b4e2e3.index.js.map