(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2638],{4328:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>o});var n=r(95155),a=r(35695),s=r(79018),l=r(12115),u=r(27805);function o(e){let{children:t}=e,r=(0,a.useRouter)(),o=(0,s.d)(e=>e.token),i=(0,s.d)(e=>e.user),d=(0,s.d)(e=>e.isHydrated),c=!!o&&!!i;return((0,l.useEffect)(()=>{d&&!c&&r.replace("/login")},[d,c,r]),d)?c?(0,n.jsx)(n.Fragment,{children:t}):null:(0,n.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:(0,n.jsx)(u.y,{className:"h-12 w-12 border-[#6EA8FF] border-t-transparent"})})}},27805:(e,t,r)=>{"use strict";r.d(t,{y:()=>s});var n=r(95155),a=r(59434);function s(e){let{className:t,...r}=e;return(0,n.jsx)("div",{className:(0,a.cn)("h-5 w-5 animate-spin rounded-full border-2 border-gray-300 border-t-transparent",t),...r})}},35695:(e,t,r)=>{"use strict";var n=r(18999);r.o(n,"useParams")&&r.d(t,{useParams:function(){return n.useParams}}),r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},46786:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>a});let n=e=>t=>{try{let r=e(t);if(r instanceof Promise)return r;return{then:e=>n(e)(r),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>n(t)(e)}}},a=(e,t)=>(r,a,s)=>{let l,u={storage:function(e,t){let r;try{r=e()}catch(e){return}return{getItem:e=>{var t;let n=e=>null===e?null:JSON.parse(e,void 0),a=null!=(t=r.getItem(e))?t:null;return a instanceof Promise?a.then(n):n(a)},setItem:(e,t)=>r.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>r.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,i=0,d=new Set,c=new Set,m=u.storage;if(!m)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${u.name}', the given storage is currently unavailable.`),r(...e)},a,s);let v=()=>{let e=u.partialize({...a()});return m.setItem(u.name,{state:e,version:u.version})},h=s.setState;s.setState=(e,t)=>(h(e,t),v());let f=e((...e)=>(r(...e),v()),a,s);s.getInitialState=()=>f;let g=()=>{var e,t;if(!m)return;let s=++i;o=!1,d.forEach(e=>{var t;return e(null!=(t=a())?t:f)});let h=(null==(t=u.onRehydrateStorage)?void 0:t.call(u,null!=(e=a())?e:f))||void 0;return n(m.getItem.bind(m))(u.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===u.version)return[!1,e.state];else{if(u.migrate){let t=u.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(s!==i)return;let[n,o]=e;if(r(l=u.merge(o,null!=(t=a())?t:f),!0),n)return v()}).then(()=>{s===i&&(null==h||h(l,void 0),l=a(),o=!0,c.forEach(e=>e(l)))}).catch(e=>{s===i&&(null==h||h(void 0,e))})};return s.persist={setOptions:e=>{u={...u,...e},e.storage&&(m=e.storage)},clearStorage:()=>{null==m||m.removeItem(u.name)},getOptions:()=>u,rehydrate:()=>g(),hasHydrated:()=>o,onHydrate:e=>(d.add(e),()=>{d.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},u.skipHydration||g(),l||f}},59434:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var n=r(52596),a=r(39688);function s(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,a.QP)((0,n.$)(t))}},65453:(e,t,r)=>{"use strict";r.d(t,{v:()=>o});var n=r(12115);let a=e=>{let t,r=new Set,n=(e,n)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=n?n:"object"!=typeof a||null===a)?a:Object.assign({},t,a),r.forEach(r=>r(t,e))}},a=()=>t,s={setState:n,getState:a,getInitialState:()=>l,subscribe:e=>(r.add(e),()=>r.delete(e))},l=t=e(n,a,s);return s},s=e=>e?a(e):a,l=e=>e,u=e=>{let t=s(e),r=e=>(function(e,t=l){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},o=e=>e?u(e):u},70711:(e,t,r)=>{Promise.resolve().then(r.bind(r,4328))},79018:(e,t,r)=>{"use strict";r.d(t,{d:()=>s});var n=r(65453),a=r(46786);let s=(0,n.v)()((0,a.Zr)(e=>({token:null,user:null,selectedCompany:null,serviceCode:null,walletSolde:null,setWalletSolde:t=>e({walletSolde:t}),setAuth:(t,r)=>e({token:t,user:r}),setSelectedCompany:t=>e({selectedCompany:t}),setServiceCode:t=>e({serviceCode:t}),logout:()=>e({token:null,user:null,selectedCompany:null,serviceCode:null}),isHydrated:!1,setHydrated:t=>e({isHydrated:t})}),{name:"auth-storage",partialize:e=>({token:e.token,user:e.user,selectedCompany:e.selectedCompany,serviceCode:e.serviceCode}),onRehydrateStorage:()=>e=>{null==e||e.setHydrated(!0)}}))}},e=>{var t=t=>e(e.s=t);e.O(0,[4277,8441,1684,7358],()=>t(70711)),_N_E=e.O()}]);