PageSourceSearch

https://softcollie.ai/chunk-6AT5A2BN.js

js softcollie.ai collected 2026-10-05 15:02:50 UTC 5,739 bytes, 1 lines download raw bytes

1import{k}from"./chunk-5VBVN4XO.js";import{c as I}from"./chunk-MOXDLQT4.js";import{a}from"./chunk-ZACTTJ4S.js";import{d as b}from"./chunk-V2PPMFND.js";import{Da as f,Ha as w,Jc as m,X as g,ba as u,md as n,p as o}from"./chunk-5SAOKRHL.js";import{a as h,b as c,c as y,g as r}from"./chunk-NZN5XTIE.js";var p="wr-customer-token",d="wr-customer-profile",A=(()=>{class l{constructor(){this.http=u(b),this.platformId=u(w),this.siteStore=u(I),this.wishlist=u(k),this.profile=f(null),this.isLoggedIn=m(()=>this.profile()!==null),this.isMember=m(()=>this.profile()?.membership?.active===!0),this.memberTier=m(()=>this.profile()?.membership?.tier??0),this.busy=f(!1),this.error=f(null),this.orders=f([]),this.token=null}sessionToken(){return this.token}hydrate(){return r(this,null,function*(){if(!n(this.platformId)||(this.token=this.read(p),!this.token))return;let e=this.read(d);if(e)try{this.profile.set(JSON.parse(e))}catch{}yield this.refreshProfile()})}refreshProfile(){return r(this,null,function*(){if(this.token)try{let e=yield o(this.http.get(`${a.apiUrl}/api/public/site/auth/me`,{headers:this.authHeaders()}));this.applyMe(e?.payload)}catch{this.forget()}})}applyMe(e){if(!e?.customerId)return;let t=this.profile();this.remember({customerId:e.customerId,displayName:t?.displayName||e.email,email:e.email,emailVerified:t?.emailVerified??!0,avatarUrl:t?.avatarUrl??null,membership:e.membership??null})}applyAccountSummary(e){this.remember({customerId:e.profile.customerId,displayName:e.profile.displayName||e.profile.email,email:e.profile.email,emailVerified:e.profile.emailVerified,avatarUrl:e.profile.avatarUrl,membership:e.membership})}clearSession(){this.forget()}consumeOAuthFragment(){if(!n(this.platformId))return!1;let e=/[#&]oauth_tokens=([^&]+)/.exec(window.location.hash);if(!e)return!1;try{let t=JSON.parse(decodeURIComponent(e[1]));return this.adopt({token:t.accessToken,customerId:t.profile.customerId,displayName:t.profile.displayName??t.profile.name??t.profile.email,email:t.profile.email,emailVerified:t.profile.emailVerified??!0,avatarUrl:t.profile.avatarUrl??null}),this.refreshProfile(),!0}catch{return!1}finally{history.replaceState(null,"",window.location.pathname+window.location.search)}}register(e){return r(this,null,function*(){return this.post("register",c(h({},e),{acceptsPrivacy:!0,cartToken:this.cartToken()}))})}login(e,t){return r(this,null,function*(){return this.post("login",{email:e,password:t,cartToken:this.cartToken()})})}loginWithGoogle(e){if(!n(this.platformId))return;let t=new URLSearchParams({client:"storefront",origin:window.location.origin,returnTo:e??window.location.pathname}),i=this.siteStore.effective()?.slug;i&&t.set("slug",i),window.location.assign(`${a.apiUrl}/api/auth/google/start?${t}`)}logout(){return r(this,null,function*(){let e=this.token;if(this.forget(),!!e)try{yield o(this.http.post(`${a.apiUrl}/api/public/site/auth/logout`,{},{headers:{"X-Portal-Token":e}}))}catch{}})}forgotPassword(e){return r(this,null,function*(){return this.fireAndForget("forgot-password",{email:e})})}resetPassword(e,t){return r(this,null,function*(){return this.fireAndForget("reset-password",{token:e,password:t})})}verifyEmail(e){return r(this,null,function*(){let t=yield this.fireAndForget("verify-email",{token:e});if(t){let i=this.profile();i&&this.remember(c(h({},i),{emailVerified:!0}))}return t})}resendVerification(e){return r(this,null,function*(){return this.fireAndForget("resend-verification",{email:e})})}loadOrders(){return r(this,null,function*(){if(this.token){this.busy.set(!0),this.error.set(null);try{let e=yield o(this.http.get(`${a.apiUrl}/api/public/site/auth/orders`,{headers:this.authHeaders()}));this.orders.set(e?.payload??[])}catch(e){this.error.set(this.describe(e))}finally{this.busy.set(!1)}}})}post(e,t){return r(this,null,function*(){this.busy.set(!0),this.error.set(null);try{let s=(yield o(this.http.post(`${a.apiUrl}/api/public/site/auth/${e}`,c(h({},t),{slug:this.siteStore.effective()?.slug??void 0}))))?.payload;if(!s)throw new Error("Respuesta vac\xEDa");return this.adopt({token:s.token,customerId:s.customerId,displayName:s.displayName,email:s.email,emailVerified:s.emailVerified,avatarUrl:s.avatarUrl??null}),this.refreshProfile(),!0}catch(i){return this.error.set(this.describe(i)),!1}finally{this.busy.set(!1)}})}fireAndForget(e,t){return r(this,null,function*(){this.busy.set(!0),this.error.set(null);try{return yield o(this.http.post(`${a.apiUrl}/api/public/site/auth/${e}`,c(h({},t),{slug:this.siteStore.effective()?.slug??void 0}))),!0}catch(i){return this.error.set(this.describe(i)),!1}finally{this.busy.set(!1)}})}adopt(e){let s=e,{token:t}=s,i=y(s,["token"]);this.token=t,this.write(p,t),this.remember(i),this.wishlist.claimGuestList()}remember(e){this.profile.set(e),this.write(d,JSON.stringify(e))}forget(){this.token=null,this.profile.set(null),this.orders.set([]),this.write(p,null),this.write(d,null)}authHeaders(){return this.token?{"X-Portal-Token":this.token}:{}}cartToken(){return this.read("wr-cart-token")??void 0}describe(e){switch(e?.status){case 401:return"Email o contrase\xF1a incorrectos.";case 409:return"Ya existe una cuenta con este email.";case 429:return"Demasiados intentos. Prueba de nuevo en unos minutos.";case 404:return"Esta tienda no permite crear cuenta ahora mismo.";default:return"No se ha podido completar la operaci\xF3n. Int\xE9ntalo de nuevo."}}read(e){if(!n(this.platformId))return null;try{return localStorage.getItem(e)}catch{return null}}write(e,t){if(n(this.platformId))try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}static{this.\u0275fac=function(t){return new(t||l)}}static{this.\u0275prov=g({token:l,factory:l.\u0275fac,providedIn:"root"})}}return l})();export{A as a};

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.