(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7122],{2355:(e,s,t)=>{"use strict";t.d(s,{d:()=>o,t:()=>a});var n=t(5155),l=t(2115);let r=(0,l.createContext)(void 0);function a(e){let{children:s}=e,[t,a]=(0,l.useState)([]),o=(0,l.useCallback)(e=>{a(s=>s.filter(s=>s.id!==e))},[]),i=(0,l.useCallback)(e=>{var s;let t=Math.random().toString(36).substr(2,9),n=5e3;switch(e.type){case"success":n=4e3;break;case"error":n=7e3;break;case"warning":n=6e3;break;case"info":n=5e3}let l={id:t,duration:null!=(s=e.duration)?s:n,...e};a(e=>{let s=[...e,l];return s.length>5?s.slice(-5):s}),l.duration&&l.duration>0&&setTimeout(()=>{o(t)},l.duration)},[o]),u=(0,l.useCallback)((e,s)=>{i({type:"success",message:e,title:s})},[i]),c=(0,l.useCallback)((e,s)=>{i({type:"error",message:e,title:s})},[i]),d=(0,l.useCallback)((e,s)=>{i({type:"warning",message:e,title:s})},[i]),g=(0,l.useCallback)((e,s)=>{i({type:"info",message:e,title:s})},[i]);return(0,n.jsx)(r.Provider,{value:{toasts:t,addToast:i,removeToast:o,showSuccess:u,showError:c,showWarning:d,showInfo:g},children:s})}function o(){let e=(0,l.useContext)(r);if(!e)throw Error("useToast must be used within a ToastProvider");return e}},2454:(e,s,t)=>{Promise.resolve().then(t.bind(t,7404))},7404:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>u});var n=t(5155),l=t(2108),r=t(5695),a=t(2115),o=t(2355),i=t(8687);function u(e){let{children:s,params:t}=e,{data:u,status:c}=(0,l.useSession)(),d=(0,r.useRouter)(),{showError:g}=(0,o.d)(),[h,f]=(0,a.useState)(""),[C,p]=(0,a.useState)(!0);return((0,a.useEffect)(()=>{(async()=>{f((await t).locale)})()},[t]),(0,a.useEffect)(()=>{var e;if(console.log("\uD83C\uDFE0 Client Layout - Session check:",{status:c,hasSession:!!u,userRole:(null==u?void 0:u.user)?u.user.role:"no-session",userName:null==u||null==(e=u.user)?void 0:e.name}),"loading"===c)return;if(!(null==u?void 0:u.user)){console.log("❌ Client Layout - No session, redirecting to login"),g("Please login to access this page","Access Denied"),d.push("/".concat(h,"/login"));return}let s=u.user.role;if(console.log("\uD83D\uDC64 Client Layout - User role:",s),"CLIENT"!==s){console.log("❌ Client Layout - Wrong role, redirecting"),g("This page is only accessible to clients","Access Denied"),"FREELANCER"===s?d.push("/".concat(h,"/freelancer/my-projects")):d.push("/".concat(h));return}console.log("✅ Client Layout - Access granted"),p(!1)},[u,c,d,h,g]),"loading"===c||C)?(0,n.jsx)("div",{className:"d-flex align-items-center justify-content-center loading-container",children:(0,n.jsx)("div",{className:"spinner-border text-primary",role:"status",children:(0,n.jsx)("span",{className:"visually-hidden",children:"Loading..."})})}):(null==u?void 0:u.user)&&"CLIENT"===u.user.role?(0,n.jsxs)(n.Fragment,{children:[s,(0,n.jsx)(i.default,{locale:h})]}):null}}},e=>{e.O(0,[2108,9942,8687,8441,5964,7358],()=>e(e.s=2454)),_N_E=e.O()}]);