1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8375],{7705:(e,t,r)=>{r.d(t,{ON:()=>u,X6:()=>i,qQ:()=>c});var a=r(74376),n=r(74275),o=r(85521),s=r(3069);function i(e){return Object.entries(a.getNames(e,{select:"official"})).map(e=>{let[t,r]=e;return{name:r,code3:a.alpha2ToAlpha3(t)}})}a.registerLocale(n),a.registerLocale(o);let c=(e,t)=>{let r=a.alpha3ToAlpha2(e);return r&&a.getNames(t,{select:"official"})[r]||null},u=e=>{let t=a.alpha3ToAlpha2(e.toUpperCase()),r=(0,s.K)(t);return"+".concat(r)}},9063:(e,t,r)=>{r.r(t),r.d(t,{AuthProvider:()=>u,useAuth:()=>l});var a=r(95155),n=r(12115),o=r(61005),s=r(7705),i=r(95704);let c=(0,n.createContext)(void 0);function u(e){let{children:t,initialUser:r}=e,[u,l]=(0,n.useState)({user:null!=r?r:null,isAuthenticated:!!r,isLoading:!r,error:null});(0,n.useEffect)(()=>{r||d()},[]);let d=async()=>{try{let e=await fetch("/api/auth/user");if(e.ok){let t=await e.json();l({user:t.user,isAuthenticated:!0,isLoading:!1,error:null});return}if(401===e.status)try{let e=await fetch("/api/auth/refresh",{method:"POST"});if(e.ok){let t=await e.json();l({user:t.user,isAuthenticated:!0,isLoading:!1,error:null});return}}catch(e){}l({user:null,isAuthenticated:!1,isLoading:!1,error:null})}catch(e){console.error("Auth check failed:",e),l({user:null,isAuthenticated:!1,isLoading:!1,error:{message:"Failed to check authentication status"}})}},h=async(e,t)=>{try{l(e=>({...e,isLoading:!0,error:null}));let r=await fetch("/api/auth/sign-in",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!r.ok){let e=await r.json();throw Error(e.error||"Sign-in failed")}let a=await r.json();return l({user:a.user,isAuthenticated:!0,isLoading:!1,error:null}),a.user}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Sign-in failed"}})),e}},p=async e=>{try{l(e=>({...e,isLoading:!0,error:null}));let t=await fetch("/api/auth/user-email-exists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(l(e=>({...e,isLoading:!1})),t.ok)return await t.json()}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Email existence check failed"}})),e}},f=async e=>{try{l(e=>({...e,isLoading:!0,error:null}));let t=await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(l(e=>({...e,isLoading:!1})),t.ok)return await t.json()}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Email existence check failed"}})),e}},g=async e=>{try{l(e=>({...e,isLoading:!0,error:null}));let t=await fetch("/api/auth/check-reset-password-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})});if(l(e=>({...e,isLoading:!1})),t.ok)return await t.json()}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Token check failed"}})),e}},m=async(e,t,r,a)=>{try{l(e=>({...e,isLoading:!0,error:null}));let n=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,token:t,newPassword:r,confirmNewPassword:a})});if(l(e=>({...e,isLoading:!1})),n.ok)return await n.json()}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Email existence check failed"}})),e}},y=async(e,t,r,a,n,o)=>{try{l(e=>({...e,isLoading:!0,error:null}));let s=await fetch("/api/auth/sign-up-customer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,firstName:t,lastName:r,password:a,country:n,locale:o})});if(!s.ok){let e=await s.json();throw Error(e.error||"Sign-up failed")}l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Sign-up failed"}})),e}},w=async(e,t,r,a)=>{let n=Number("1");try{l(e=>({...e,isLoading:!0,error:null}));let o=await fetch("/api/auth/create-partner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,firstName:t,lastName:r,password:a,roleName:1,channelId:n})});if(!o.ok){let e=await o.json();throw Error(e.error||"Sign-up failed")}l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Sign-up failed"}})),e}},T=async(e,t,r,a)=>{let n=Number("1");try{l(e=>({...e,isLoading:!0,error:null}));let o=await fetch("/api/auth/create-partner",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,firstName:t,lastName:r,password:a,partnerRole:7,channelId:n})});if(!o.ok){let e=await o.json();throw Error(e.error||"Sign-up failed")}l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Sign-up failed"}})),e}},S=async(e,t,r,a,n,o,c,d,h,p)=>{l(e=>({...e,isLoading:!0,error:null}));let f=(0,s.ON)(t),g=i.env.NEXT_PUBLIC_INSTITUTION_CATEGORY_ID?Number(i.env.
1NEXT_PUBLIC_INSTITUTION_CATEGORY_ID):35;try{var m,y,w,T;let s={city:{el:d},name:{el:a},email:h,icon:"",taxId:r,status:0,address:{el:o},country:t,zipCode:c,categoryId:g,lastName:null!=(w=null==(m=u.user)?void 0:m.familyName)?w:"",taxOfficeId:n,firstName:null!=(T=null==(y=u.user)?void 0:y.givenName)?T:"",regNumber:"",postalCode:c,type:3,mobileNumber:f+p,sendInvitation:!0,category:{id:g,name:{el:"Institution"},type:3},preferredLanguage:1,consentToNewsletter:!1},i=await fetch("/api/auth/add-school-details",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({institutionAdminEmail:e,credentials:s})}),S=await i.json();if(!i.ok)throw Error(S.error||"Submission failed");return l(e=>({...e,isLoading:!1})),S}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Submission failed"}})),e}},O=async(e,t,r,a,n,o,i,c,u,d,h,p,f,g,m)=>{l(e=>({...e,isLoading:!0,error:null}));let y=(0,s.ON)(r);try{let s=await fetch("/api/auth/add-business-details",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({partnerAdminEmail:e,credentials:{city:{el:i},name:{el:t},address:{el:c},email:h,taxId:n,country:r,zipCode:u,taxOfficeId:o,regNumber:f,type:2,mobileNumber:y+p,registeredCompanyName:a,legalRepresentative:d,preferredLanguage:g,consentToNewsLetter:m,registrationNumber:f}})});return l(e=>({...e,isLoading:!1})),await s.json()}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Sign-up failed"}})),e}},N=async()=>{l(e=>({...e,isLoading:!0,error:null}));try{let e=await fetch("/api/auth/get-marketplace-roles",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){let t=await e.json();throw Error(t.error||"Fetching roles failed")}let t=await e.json();return l(e=>({...e,isLoading:!1})),t}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Fetching roles failed"}})),e}},L=async(e,t,r,a,n)=>{try{l(e=>({...e,isLoading:!0,error:null}));let o=await fetch("/api/auth/update-business-member",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,firstName:t,lastName:r,email:a,roleId:n})});if(!o.ok){let e=await o.json();throw Error(e.error||"Update failed")}l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Member update failed"}})),e}},b=async(e,t,r,a)=>{try{l(e=>({...e,isLoading:!0,error:null}));let n=await fetch("/api/auth/update-institution-member",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,firstName:t,lastName:r,email:a})});if(!n.ok){let e=await n.json();throw Error(e.error||"Update failed")}l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Member update failed"}})),e}},k=async(e,t)=>{try{l(e=>({...e,isLoading:!0,error:null}));let r=await fetch("/api/auth/verify-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,otp:t})});if(!r.ok){let e=await r.json();throw Error(e.error||"Otp verification failed")}let a=await r.json();l({user:a.user,isAuthenticated:!0,isLoading:!1,error:null})}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Otp verification failed"}})),e}},P=async(e,t)=>{try{l(e=>({...e,isLoading:!0,error:null}));let r=await fetch("/api/auth/verify-account",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,sId:t})});if(!r.ok){let e=await r.json();throw Error(e.error||"Otp verification failed")}let a=await r.json();l({user:a.user,isAuthenticated:!0,isLoading:!1,error:null})}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Otp verification failed"}})),e}},E=async e=>{try{l(e=>({...e,error:null}));let t=await fetch("/api/auth/resend-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok){let e=await t.json();throw Error(e.error||"Otp resend failed")}l(e=>({...e,error:null}))}catch(e){throw l(t=>({...t,error:{message:e instanceof Error?e.message:"Otp resend failed"}})),e}},v=async e=>{try{l(e=>({...e,isLoading:!0,error:null}));let t=await fetch("/api/auth/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(l(e=>({...e,isLoading:!1})),t.ok)return await t.json();l(e=>({...e,isLoading:!1}))}catch(e){throw l(t=>({...t,isLoading:!1,error:{message:e instanceof Error?e.message:"Account activation failed"}})),e}},j=async()=>{try{await fetch("/api/auth/sign-out",{method:"POST"})}catch(e){console.error("Sign-out request failed:",e)}finally{l({user:null,isAuthenticated:!1,isLoading:!1,error:null})}},A=async()=>{try{let e=await fetch("/api/auth/refresh",{method:"POST"});if(!e.ok)throw Error("Token refresh failed");let t=await e.json();l(e=>({...e,user:t.user,isAuthenticated:!0,error:null}))}catch(e){throw console.error("Token refresh failed:",e),l({user:null,isAuthenticated:!1,isLoading:!1,error:{message:"Session expired"}}),e}},I={...u,signIn:h,checkEmailExists:p,forgotPassword:f,checkResetPasswordToken:g,resetPassword:m,signUpCustomer:y,signUpPartnerOwner:w,signUpSchoolOwner:T,addSchoolDetails:S,verifyOtp:k,resendOtp:E,verifyAccount:P,signOut:j,refreshToken:A,updateBusinessMember:L,updateInstitutionMember:b,getMarketplaceRoles:N,activate:v,addBusinessDetail
1s:O,hasRole:e=>!!u.user&&(0,o.hf)(u.user.roles,e),clearError:()=>{l(e=>({...e,error:null}))}};return(0,a.jsx)(c.Provider,{value:I,children:t})}function l(){let e=(0,n.useContext)(c);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},11496:(e,t,r)=>{r.d(t,{Z:()=>n,d:()=>a});let a=["el","en"];function n(e){return a.includes(e)}},20200:(e,t,r)=>{r.d(t,{j$:()=>a,Dr:()=>n,fv:()=>o,VR:()=>l,xW:()=>i});class a extends Error{constructor(e,t,r){super(t),this.status=e,this.data=r}}class n extends Error{constructor(e="Network error",t){super(e),this.status=503,this.name="NetworkError",this.cause=t}}class o extends Error{constructor(e){super("Unexpected response from API"),this.status=502,this.name="SchemaValidationError",this.issues=e}}r(34663);var s=r(26541);function i(e){{var t;let r=null!=(t=window.location.pathname.split("/").filter(Boolean)[0])?t:"",i=s.D.locales.includes(r)?"/".concat(r):"";window.location.href="".concat(i).concat(function(e){let t=e instanceof a?e.message:e instanceof n?"Unable to connect. Please check your connection and try again.":e instanceof o?"Unexpected response from the server.":"Something went wrong. Please try again.";return"".concat("/error-page","?message=").concat(encodeURIComponent(t))}(e))}}var c=r(9923);let u=c.Ay$.object({isError:c.Ay$.boolean().optional(),messages:c.Ay$.array(c.Ay$.object({messageType:c.Ay$.string(),message:c.Ay$.string()})).optional()});function l(e){var t;let r=u.safeParse(e);if(!r.success||!r.data.isError)return null;let a=null!=(t=r.data.messages)?t:[];return a.length?a[0].message:null}},26541:(e,t,r)=>{r.d(t,{D:()=>o});var a=r(84497),n=r(11496);let o=(0,a.A)({locales:n.d,defaultLocale:"el",localePrefix:"as-needed",localeDetection:!1})},34663:(e,t,r)=>{r.d(t,{N_:()=>s,Ym:()=>d,a8:()=>c,rd:()=>u});var a=r(36809),n=r(55251),o=r(26541);let{Link:s,redirect:i,usePathname:c,useRouter:u,getPathname:l}=(0,n.A)(o.D);function d(){return(0,a.Ym)()}},61005:(e,t,r)=>{function a(e,t){return e.includes(t)}function n(e,t){return t.some(t=>e.includes(t))}r.d(t,{Ii:()=>n,hf:()=>a})},78375:(e,t,r)=>{r.d(t,{is:()=>u.is,Ii:()=>c.Ii,NJ:()=>u.NJ,$V:()=>u.$V,$x:()=>u.$x,sP:()=>u.sP,As:()=>i.useAuth});var a=r(20200),n=r(86600),o=r(95704);class s{async sendRequest(e){var t,r,n;let o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="".concat("http://api-clients.hh.gr:5004").concat(e),c=crypto.randomUUID(),u={"Content-Type":"application/json","X-Trace-Id":c,ClientId:"marketplace",...s.headers};try{o=await fetch(i,{...s,headers:u})}catch(e){throw console.error("[".concat(c,"] Network error: ").concat(null!=(r=s.method)?r:"GET"," ").concat(i)),{message:"Unable to reach authentication service",status:503,code:"SERVICE_UNAVAILABLE"}}if(!o.ok){let e=await o.json().catch(()=>({})),t=(0,a.VR)(e);throw console.error("[".concat(c,"] HTTP ").concat(o.status,": ").concat(null!=(n=s.method)?n:"GET"," ").concat(i)),{message:t||e.message||"HTTP ".concat(o.status,": ").concat(o.statusText),status:o.status,code:e.error||o.statusText}}let l=null==o||null==(t=o.headers)?void 0:t.get("content-type");if(null==l?void 0:l.includes("application/json"))return o.json()}async createCustomer(e){let t=o.env.BASE_URL||"http://localhost:3000",{email:r,password:a,firstName:n,lastName:s,country:i,locale:c}=e,u="".concat(t,"/").concat(null!=c?c:"en","/register/member/verify-account?email=").concat(e.email);return this.sendRequest("/api/auth/sign-up-customer-marketplace?redirectUrl=".concat(u),{method:"POST",body:JSON.stringify({email:r,password:a,firstName:n,lastName:s,country:i})})}async createPartner(e){return this.sendRequest("/api/auth/create-partner",{method:"POST",body:JSON.stringify(e)})}async createSchoolOwner(e){return this.sendRequest("/api/auth/create-school-owner",{method:"POST",body:JSON.stringify(e)})}async addSchoolDetails(e,t,r){let a=encodeURIComponent(e);return this.sendRequest("/api/auth/create-institution-partner/".concat(a),{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer ".concat(r)}})}async createInstitutionAccount(e,t){return this.sendRequest("/api/auth/create-institution-account",{method:"POST",body:JSON.stringify(e),headers:{Authorization:"Bearer ".concat(t)}})}
1async addBusinessDetails(e,t,r){let a=encodeURIComponent(e);return this.sendRequest("/api/auth/create-partner/".concat(a),{method:"POST",body:JSON.stringify(t),headers:{Authorization:"Bearer ".concat(r)}})}async updateBusinessMember(e,t){let{userId:r,firstName:a,lastName:n,email:o,roleId:s}=e;return this.sendRequest("/api/auth/update-user-profile?userId=".concat(encodeURIComponent(r)),{method:"PUT",body:JSON.stringify({firstName:a,lastName:n,email:o,roleId:s}),headers:{Authorization:"Bearer ".concat(t)}})}async updateInstitutionMember(e,t){let{userId:r,firstName:a,lastName:n,email:o}=e;return this.sendRequest("/api/auth/update-user-profile?userId=".concat(encodeURIComponent(r)),{method:"PUT",body:JSON.stringify({firstName:a,lastName:n,email:o}),headers:{Authorization:"Bearer ".concat(t)}})}async verifyOtp(e){return this.sendRequest("/api/auth/verify-otp",{method:"POST",body:JSON.stringify(e)})}async verifyAccount(e){return this.sendRequest("/api/auth/verify-account?email=".concat(e.email,"&sId=").concat(e.sId),{method:"GET"})}async resendOtp(e){return this.sendRequest("/api/auth/resend-otp",{method:"POST",body:JSON.stringify(e)})}async signIn(e){return this.sendRequest("/api/auth/sign-in",{method:"POST",body:JSON.stringify(e)})}async signInGuest(){return this.sendRequest("/api/auth/sign-in-marketplace-guest",{method:"POST"})}async userEmailExists(e){let t=encodeURIComponent(e.email);return this.sendRequest("/api/auth/user-email-exists/".concat(t))}async forgotPassword(e){return this.sendRequest("/api/auth/forgot-password",{method:"POST",body:JSON.stringify(e)})}async checkResetPasswordToken(e){return this.sendRequest("/api/auth/check-reset-password-token",{method:"POST",body:JSON.stringify(e)})}async resetPassword(e){return this.sendRequest("/api/auth/reset-password",{method:"PUT",body:JSON.stringify(e)})}async checkActivationToken(e){return this.sendRequest("/api/auth/check-activation-token",{method:"POST",body:e})}async getMarketplaceRoles(e){return this.sendRequest("/api/auth/marketplace-roles",{headers:{Authorization:"Bearer ".concat(e)}})}async activate(e){return this.sendRequest("/api/auth/activate",{method:"POST",body:JSON.stringify(e)})}async refreshToken(e){return this.sendRequest("/api/auth/refresh-token",{method:"POST",body:JSON.stringify(e)})}decodeToken(e){try{return(0,n.s)(e)}catch(e){throw Error("Invalid JWT token")}}extractUserFromToken(e){var t,r;return{id:e.sub,username:e.preferred_username,email:e.email,name:e.name,givenName:e.given_name,familyName:e.family_name,emailVerified:e.email_verified,roles:(null==(r=e.resource_access)||null==(t=r.marketplace)?void 0:t.roles)||[]}}isTokenExpired(e){try{let t=this.decodeToken(e),r=Math.floor(Date.now()/1e3);return t.exp<r}catch(e){return!0}}getTokenExpiration(e){try{let t=this.decodeToken(e);return 1e3*t.exp}catch(e){return 0}}}new s;var i=r(9063),c=r(61005),u=r(86755)},86755:(e,t,r)=>{r.d(t,{$V:()=>c,$x:()=>u,NJ:()=>h,X2:()=>d,ai:()=>i,is:()=>p,sP:()=>l});let a=["PartnerOwner","PartnerSeller","PartnerAdmin"],n=["School"],o=[...n,"InstitutOwner","InstitutionPartnerOwner","InstitutUser","InstitutionPartnerUser"],s=(e,t)=>e.some(e=>t.includes(e));function i(e){if(u(e))return"INSTITUTION";let t=e.some(e=>a.includes(e))?"partner":e.includes("Customer")?"customer":"guest";return"partner"===t?"PARTNER":"customer"===t||"guest"===t?"INDIVIDUAL":void 0}function c(e){return e.some(e=>a.includes(e))}function u(e){return s(e,o)||e.includes("InstitutOwnerPending")}function l(e){return s(e,n)}function d(e){return e.includes("Guest")||0===e.length}function h(e){return c(e)||u(e)}function p(e){return c(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.