PageSourceSearch

https://gosbi.com/es/chunk-2I5RPMO2.js

js gosbi.com collected 2026-10-04 07:46:11 UTC 12,051 bytes, 2 lines download raw bytes

1import{a as Z,b as J}from"./chunk-FBYJA5X5.js";import{a as z}from"./chunk-SMKJCAN6.js";import{a as G}from"./chunk-NNIZTJHA.js";import{a as K}from"./chunk-LRQDQCAP.js";import{a as M}from"./chunk-SLAHZF67.js";import{a as T}from"./chunk-JKKMRTGY.js";import{a as Q}from"./chunk-6QH73XGE.js";import{b as O}from"./chunk-HWUAPOG4.js";import{a as E}from"./chunk-2JDFIY2D.js";import{a as C}from"./chunk-P3JVUKFE.js";import{a as $,b as w}from"./chunk-WEEOC2P5.js";import{a as D,b as F,c as W,d as H,e as _}from"./chunk-JAZSYRLX.js";import{a as l}from"./chunk-F5HBV2KF.js";import{e as b}from"./chunk-MAHCQHCQ.js";import{Ec as I,Lc as B,P as g,U as v,V as u}from"./chunk-POW3FRHD.js";import{a as S,b as f,g as m}from"./chunk-OAJD7WE5.js";var et=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),A={randomUUID:et};var q,it=new Uint8Array(16);function L(){if(!q){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");q=crypto.getRandomValues.bind(crypto)}return q(it)}var p=[];for(let a=0;a<256;++a)p.push((a+256).toString(16).slice(1));function X(a,t=0){return(p[a[t+0]]+p[a[t+1]]+p[a[t+2]]+p[a[t+3]]+"-"+p[a[t+4]]+p[a[t+5]]+"-"+p[a[t+6]]+p[a[t+7]]+"-"+p[a[t+8]]+p[a[t+9]]+"-"+p[a[t+10]]+p[a[t+11]]+p[a[t+12]]+p[a[t+13]]+p[a[t+14]]+p[a[t+15]]).toLowerCase()}function at(a,t,r){if(A.randomUUID&&!t&&!a)return A.randomUUID();a=a||{};let e=a.random??a.rng?.()??L();if(e.length<16)throw new Error("Random bytes length must be >= 16");if(e[6]=e[6]&15|64,e[8]=e[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=e[i];return t}return X(e)}var R=at;var j="jwtToken",Y=F({providedIn:"root"},_(()=>({token:u(C).get(j)||null})),W(a=>({isAuthenticated:B(()=>a.token()!==null)})),H(a=>{let t=u(C),r=i=>{t.set(j,i)},e=()=>{t.remove(j)};return{setToken(i){D(a,{token:i}),i?r(i):e()}}}));var x=class a{constructor(t){this.http=t}apiUrl=`${l.apiUserUrl}/shopping-cart`;getCart(){return this.http.get(`${this.apiUrl}`)}saveCart(t){return this.http.post(`${this.apiUrl}/items`,t)}removeCartItem(t){return this.http.delete(`${this.apiUrl}/items`,{body:t})}static \u0275fac=function(r){return new(r||a)(v(b))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})};var V=class a{constructor(t,r){this.repository=t;this.notificationsService=r}getCart(){return m(this,null,function*(){return E(this.repository.getCart(),this.notificationsService,w.GET_CART)})}saveCart(t){return m(this,null,function*(){return E(this.repository.saveCart(t),this.notificationsService,w.SAVE_CART)})}removeCartItem(t){return m(this,null,function*(){return E(this.repository.removeCartItem(t),this.notificationsService,w.DELETE_CART)})}static \u0275fac=function(r){return new(r||a)(v(x),v($))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})};var k=class a{constructor(t){this.productsService=t}zoneCode=u(T);languageCode=u(I);findSlotIndex(t,r){return t.findIndex(e=>e.id===r)}addToCart(t,r,e,i,o,c=0){let d=[...t],n=d.findIndex(s=>s.variant.id===i.id&&s.type===c);return n!==-1?d[n]=f(S({},d[n]),{quantity:d[n].quantity+o}):d.push({id:R(),product:e,variant:i,quantity:o,type:c}),d}removeFromCart(t,r,e){let i=this.findSlotIndex(t,r);if(i===-1)return t;let o=[...t],c=o[i];return c.quantity<=e?o.splice(i,1):o[i]=f(S({},c),{quantity:c.quantity-e}),o}transformBackendCart(t,r){return m(this,null,function*(){let e=t.items.map(i=>i.productId);try{let i=this.buildCartProductsParamsPayload(e),o=yield this.productsService.getAllByZone(i);return this.mergeCartSlots(t,r,o)}catch(i){return l.production||console.error("Error cart-logic service - transformBackendCart",i),r}})}getMatchingVariant(t,r){return t.productVariants.find(e=>e.id===r)}buildCartProductsParamsPayload(t){return{languageCode:this.languageCode,zoneCode:this.zoneCode,pv:t}}mergeCartSlots(t,r,e){let i=[...r];for(let o of e){let c=t.items.filter(d=>o.productVariants.some(n=>n.id===d.productId));for(let d of c){let n=this.getMatchingVariant(o,d.productId);if(!n)continue;let s=d.type??0,y=i.find(h=>h.variant.id===n.id&&h.type===s);y?i=i.map(h=>h===y?f(S({},h),{quantity:h.quantity+d.quantity}):h):i.push({id:R(),product:o,variant:n,quantity:d.quantity,type:s})}}return i}static \u0275fac=function(r){return new(r||a)(v(G))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})};var tt=class a{constructor(t,r){this.cartService=t;this.cartLogicService=r}cartStore=u(M);subscriptionStore=u(K);authStore=u(Y);trackingService=u(z);localStorageService=u(C);urlBuildService=u(Q);http=u(b);languageCode=u(I);zoneCode=u(T);removingSlotIds=new Set;rangesPromise=null;getCart(){return m(this,null,function*(){return yield this.cartService.getCart()})}getCartFromBackendWithoutPrevious(){return m(this,null,function*(){let t=yield this.cartService.getCart();yield this.cartLogicService.transformBackendCart(t,[]),this.cartStore.clearCart()})}initializeCartFromBackend(){return m(this,null,function*(){let t=yield this.cartService.getCart();yield this.setCartFromBackend(t),this.cartStore.setCartId(t.id)})}clearBackendCart(){return m(this,null,function*(){if(!this.authStore.isAuthenticated()){this.cartStore.clearCart();return}try{let t=yield this.cartService.getCart();if(t.items?.length)for(let r of t.items)try{yield this.cartService.removeCartItem({productId:r.productId,type:r.type})}catch(e){l.production||console.error("Error removing cart item",r,e),t=yield this.cartService.getCart()}this.cartStore.clearCart()}catch(t){l.production||console.error("Error clearing backend cart",t)}})}setCartFromBackend(t){return m(this,null,function*(){let r=this.cartStore.cartSlots(),e=yield this.cartLogicService.transformBackendCart(t,r);
1if(this.cartStore.setCartSlots(e),r.length)for(let i of e)try{let o=yield this.cartService.saveCart({productId:i.variant.id,quantity:i.quantity,type:i.type});this.cartStore.setCartId(o.id)}catch(o){l.production||console.error("Error saving slot",i,o)}})}addToCart(c,d,n,s){return m(this,arguments,function*(t,r,e,i,o=0){let y=this.cartStore.cartSlots(),h=this.cartLogicService.addToCart(y,t,r,e,i,o);this.cartStore.setCartSlots(h);let rt=this.cartStore.cartSlots().find(P=>P.id===t&&P.type===o)?.quantity??i;if(this.authStore.isAuthenticated()){let P=yield this.mapProductsToEnriched();try{let U=yield this.cartService.saveCart({productId:e.id,quantity:rt,type:o,enrichedCart:P});this.cartStore.setCartId(U.id)}catch(U){l.production||console.error("Error saving product on cart",U)}}this.sendTrackingAddToCartEvent(r,e,i)})}mapProductsToEnriched(){return m(this,null,function*(){let t=JSON.parse(this.localStorageService.get("user")),r=`${l.baseUrl}${this.urlBuildService.getAbsoluteLangZoneUrl()}/${O("cart-summary")}`,e=this.cartStore.cartSlots(),i=yield Promise.all(e.map(d=>m(this,[d],function*({product:o,variant:c}){let n=typeof o.brand=="string"?o.brand:o.brand.name,s=yield this.resolveRangeName(o);return{brand:n,range:s,name:o.name,price:c.price??0,currency:o.currencySymbol,urlImage:o.productImageUrl}})));return{email:t.email,firstName:t.name,lastName:t.surname,urlCompleteOrder:r,products:i,langCode:this.languageCode,zoneCode:this.zoneCode}})}removeFromCart(t,r,e,i,o){return m(this,null,function*(){if(!this.removingSlotIds.has(t)){this.removingSlotIds.add(t);try{let c=this.cartStore.cartSlots(),d=this.cartLogicService.removeFromCart(c,t,i);this.cartStore.setCartSlots(d);let n=this.cartStore.cartSlots().find(s=>s.id===t&&s.type===o)?.quantity??0;if(this.authStore.isAuthenticated()){let s=yield this.mapProductsToEnriched();try{n>0?yield this.cartService.saveCart({productId:e.id,quantity:n,type:o,enrichedCart:s}):yield this.cartService.removeCartItem(this.getCartRemoveItemPayload(e.id,o,s))}catch(y){l.production||console.error("Error saving product on cart",y)}}}finally{this.removingSlotIds.delete(t)}}})}updateCartSlotType(t,r){return m(this,null,function*(){let e=this.cartStore.cartSlots(),i=[],o=!1;for(let n of e)n.variant.id===t.variant.id&&n.type===r?(i.push(f(S({},n),{quantity:n.quantity+t.quantity})),o=!0):n.id===t.id?o||(i.push(f(S({},n),{type:r})),o=!0):i.push(n);o||i.push(f(S({},t),{type:r})),this.cartStore.setCartSlots(i);let d=i.find(n=>n.variant.id===t.variant.id&&n.type===r)?.quantity??0;if(this.authStore.isAuthenticated())try{yield this.cartService.removeCartItem(this.getCartRemoveItemPayload(t.variant.id,t.type)),yield this.cartService.saveCart({productId:t.variant.id,quantity:d,type:r})}catch(n){l.production||console.error("Error saving product on cart",n)}})}assignSubscriptionTarget(t,r){return m(this,null,function*(){let e=r.type==="purchase"?0:1,o=this.cartStore.cartSlots().map(c=>c.id===t.id?f(S({},c),{type:e,subscriptionTarget:r}):c);if(this.cartStore.setCartSlots(o),this.authStore.isAuthenticated())try{e!==t.type&&(yield this.cartService.removeCartItem(this.getCartRemoveItemPayload(t.variant.id,t.type))),yield this.cartService.saveCart({productId:t.variant.id,quantity:t.quantity,type:e})}catch(c){l.production||console.error("Error saving subscription target on cart",c)}})}assignSubscriptionTargetToMany(t,r){return m(this,null,function*(){yield Promise.all(t.map(e=>this.assignSubscriptionTarget(e,r)))})}resolvePendingSubscriptionSlots(){return m(this,null,function*(){try{let t=this.cartStore.cartSlots().filter(e=>e.type===1&&!e.subscriptionTarget);if(t.length===0)return;let r=this.subscriptionStore.subscriptions().filter(e=>e.status==="ACTIVE"||e.status==="PAUSED");if(r.length===0){let e=this.cartStore.newSubscriptionDrafts()[0]?.draftId;if(!e)return;yield this.assignSubscriptionTargetToMany(t,{type:"new",draftId:e})}else if(r.length===1)yield this.assignSubscriptionTargetToMany(t,{type:"existing",subscriptionId:r[0].id});else for(let e of t)this.cartStore.setSlotSubscriptionPending(e.id,!0)}finally{this.cartStore.setPendingSubscriptionSlotsResolved(!0)}})}swapCartSlotVariant(t,r){return m(this,null,function*(){let e=this.cartStore.cartSlots(),i=e.find(s=>
1s.id===t.id),o=i?.product.productVariants.find(s=>s.id===r);if(!i||!o)return;let c=e.find(s=>s.id!==i.id&&s.variant.id===r&&s.type===i.type),d,n=i.quantity;if(c?(n=c.quantity+i.quantity,d=e.filter(s=>s.id!==i.id).map(s=>s.id===c.id?f(S({},s),{quantity:n,unavailable:!1}):s)):d=e.map(s=>s.id===i.id?f(S({},s),{variant:o,unavailable:!1}):s),this.cartStore.setCartSlots(d),this.authStore.isAuthenticated())try{yield this.cartService.removeCartItem(this.getCartRemoveItemPayload(t.variant.id,t.type)),yield this.cartService.saveCart({productId:o.id,quantity:n,type:t.type})}catch(s){l.production||console.error("Error saving product on cart",s)}})}getCartRemoveItemPayload(t,r,e){return S({productId:t,type:r},e?{enrichedCart:e}:{})}sendTrackingAddToCartEvent=(t,r,e)=>{this.trackingService.push({ecommerce:null});let i=t.categories,o=i.length?i.reduce((n,s)=>s.categoryLevel>n.categoryLevel?s:n):null,c={item_id:r.id,item_name:t.name,item_brand:typeof t.brand=="string"?t.brand:t.brand.name,item_category:i.find(n=>n.categoryLevel===1)?.name||"",item_category2:o?.name||"",item_variant:r.name,price:r.price,quantity:e},d={event:"add_to_cart",ecommerce:{currency:t.currencyCode||"EUR",value:r.price*e,items:[c]}};this.trackingService.push(d)};loadRanges=()=>(this.rangesPromise||(this.rangesPromise=Z(J(this.http))(this.languageCode).catch(t=>{throw this.rangesPromise=null,t})),this.rangesPromise);resolveRangeName(t){return m(this,null,function*(){if(typeof t.range=="string")return t.range;if(t.range&&typeof t.range=="object"&&"name"in t.range)return t.range.name;if("rangeName"in t&&t.rangeName)return t.rangeName;let r="rangeId"in t?t.rangeId:void 0;if(r==null)return"";try{return(yield this.loadRanges()).find(i=>i.id===r)?.name??""}catch{return""}})}static \u0275fac=function(r){return new(r||a)(v(V),v(k))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})};export{Y as a,R as b,tt as c};
2/**i18n:823fe18dcb7916ede78f62290696ecc6d1371ad468a3df5ed6bf7ead1dd24313*/

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.