import{ac as S,ad as h,ae as C,j as U,r as f,af as T,ag as _,S as m,ah as b,ai as j}from"./D5FvQ40u.js";import{i as x}from"./Cp4gbRW8.js";const y=(r="en")=>{var o,a;const{public:s}=h(),t=(a=Object.values((o=s==null?void 0:s.shopwarePlugin)==null?void 0:o.salesChannel))==null?void 0:a.find(i=>i.locales.includes(r));return{apiClient:S({baseURL:t==null?void 0:t.endpoint,accessToken:t==null?void 0:t.accessToken})}},P=C(async r=>{var w;let s,t;const{$localePath:o,$i18n:a}=j(),{apiClient:i}=y(a.locale.value),l=U("swSessionContext",f()),u=f(!1),e=r.meta.authGuard,g=e==null?void 0:e.redirectAuthenticated,v=e==null?void 0:e.redirectUnauthenticated,k=!!(e!=null&&e.allowUnauthenticated),A=!!(e!=null&&e.allowGuest),p=n=>{const c=!!n,d=(n==null?void 0:n.guest)??!1;return c&&!d?!0:c&&d&&A};if(l.value)u.value=p((w=l==null?void 0:l.value)==null?void 0:w.customer);else{const n=T("sw-context-token");i.defaultHeaders["sw-context-token"]=String(n.value);const c=f();try{c.value=([s,t]=_(()=>i.invoke("readCustomer post /account/customer",{})),s=await s,t(),s)}catch{}u.value=p(c.value)}if(u.value){if(x(g))return m(o(g,a.locale.value))}else{if(x(v))return m(o(v,a.locale.value));if(!k)throw b({status:401,message:"You need to be logged in to access this page!"})}});export{P as default};
