import{c as K}from"./chunk-HWKNHJSR.js";import{e as X,h as Y}from"./chunk-DIIZQCCX.js";import{a as g,b as I}from"./chunk-33DRKEJ4.js";import{a as w}from"./chunk-IEJODBFI.js";import{b as W}from"./chunk-O3R6UXT6.js";import{a as P,d as L,k as U}from"./chunk-ZT24ABBQ.js";import{R as j}from"./chunk-XWXMKY5I.js";import{a as _}from"./chunk-JWAFQ6PQ.js";import{i as T}from"./chunk-GVZRBRU2.js";import{a as V}from"./chunk-XHCLFCJS.js";import{l as $,n as q}from"./chunk-SZDOCCE5.js";import{D as M,d as c,e as i,s as F,v as s,w as k}from"./chunk-QZAKNZ5J.js";import{Ba as v,La as N,O as D,Qa as G,Z as C,s as f}from"./chunk-WNE7PXNE.js";var o=function(e){return e.GET_SMALL_RELATED_PRODUCTS="[Recommendation] Get small related products",e.GET_SMALL_RELATED_PRODUCTS_ERROR="[Recommendation] Get small related products [Error]",e.GET_SMALL_RELATED_PRODUCTS_SUCCESS="[Recommendation] Get small related products [Success]",e.SET_RELATED_PRODUCTS_SLIDER="[Recommendation] Set related slider products",e.FILTER_RELATED_PRODUCTS_SLIDER="[Recommendation] Filter related slider products",e.GET_RELATED_PRODUCTS_SLIDER_PRICE="[Recommendation] Get related slider price",e.GET_RELATED_PRODUCTS_SLIDER_PRICE_ERROR="[Recommendation] Get related slider price [Error]",e.GET_RELATED_PRODUCTS_SLIDER_PRICE_SUCCESS="[Recommendation] Get related slider price [Success]",e.FILTER_BOUGHT_TOGETHER="[Recommendation] Filter bought together",e.GET_BOUGHT_TOGETHER="[Recommendation] Get bought together",e.GET_BOUGHT_TOGETHER_ERROR="[Recommendation] Get bought together [Error]",e.GET_BOUGHT_TOGETHER_SUCCESS="[Recommendation] Get bought together [Success]",e.SET_BOUGHT_TOGETHER_ALL_PRICE="[Recommendation] Get bought together all price",e.GET_BOUGHT_TOGETHER_PRICE="[Recommendation] Get bought together price",e.GET_BOUGHT_TOGETHER_PRICE_ERROR="[Recommendation] Get bought together price [Error]",e.GET_BOUGHT_TOGETHER_PRICE_SUCCESS="[Recommendation] Get bought together price [Success]",e.LOAD_MORE_BOUGHT_TOGETHER_PRODUCTS="[Recommendation] Load more bought together products",e.LOAD_MORE_BOUGHT_TOGETHER_PRODUCTS_SUCCESS="[Recommendation] Load more bought together products [Success]",e.SET_DISPLAYED_COUNT_BOUGHT_TOGETHER_PRODUCTS="[Recommendation] Set displayed count bought together products",e.SET_IS_LOADED_BOUGHT_TOGETHER_PRODUCTS="[Recommendation] Set is loaded bought together products",e.CLEAR_RELATED_PRODUCTS_SLIDER_PRICES="[Recommendation] Clear related products slider prices",e}(o||{});var he=c(o.FILTER_BOUGHT_TOGETHER,i()),fe=c(o.GET_BOUGHT_TOGETHER,i()),De=c(o.GET_BOUGHT_TOGETHER_ERROR,i()),Ce=c(o.GET_BOUGHT_TOGETHER_SUCCESS,i()),Ge=c(o.SET_BOUGHT_TOGETHER_ALL_PRICE,i()),Le=c(o.GET_BOUGHT_TOGETHER_PRICE,i()),Ue=c(o.GET_BOUGHT_TOGETHER_PRICE_ERROR,i()),Ie=c(o.GET_BOUGHT_TOGETHER_PRICE_SUCCESS,i()),xe=c(o.LOAD_MORE_BOUGHT_TOGETHER_PRODUCTS,i()),be=c(o.LOAD_MORE_BOUGHT_TOGETHER_PRODUCTS_SUCCESS,i()),He=c(o.SET_DISPLAYED_COUNT_BOUGHT_TOGETHER_PRODUCTS,i()),Be=c(o.SET_IS_LOADED_BOUGHT_TOGETHER_PRODUCTS,i()),Q=c(o.GET_SMALL_RELATED_PRODUCTS,i()),ye=c(o.GET_SMALL_RELATED_PRODUCTS_ERROR,i()),Ae=c(o.GET_SMALL_RELATED_PRODUCTS_SUCCESS,i()),ve=c(o.FILTER_RELATED_PRODUCTS_SLIDER,i()),Ne=c(o.SET_RELATED_PRODUCTS_SLIDER,i()),Fe=c(o.GET_RELATED_PRODUCTS_SLIDER_PRICE),ke=c(o.GET_RELATED_PRODUCTS_SLIDER_PRICE_ERROR,i()),Me=c(o.GET_RELATED_PRODUCTS_SLIDER_PRICE_SUCCESS,i()),$e=c(o.CLEAR_RELATED_PRODUCTS_SLIDER_PRICES);var z=k("recommendation"),R=s(z,e=>e.boughtTogetherState),se=s(R,e=>e.allProducts),Ve=s(R,e=>e.status),We=s(R,e=>e.displayedProducts),Xe=s(R,e=>e.displayedCount),Ye=s(R,e=>e.isLoaded),x=s(R,e=>e.productsPrice),J=s(z,e=>e.relatedProductsState),ae=s(J,e=>e.products),b=s(J,e=>e.productsPrice),Ke=s(ae,b,(e,a)=>e?.map(d=>({product:d,price:a?.find(t=>t.id===d.productId)})).filter(d=>d.price)),de=s(se,x,(e,a)=>e?.map(d=>({product:d,price:a?.find(t=>t.id===d.productId)})).filter(d=>d.price)),Qe=e=>s(de,a=>a?.find(d=>d.product.productId===e)),ze=s(R,e=>{if(e.status===M.loading||e.error||!e?.displayedProducts||!e?.productsPrice)return;let d=e.displayedProducts?.length>=2,t=e.productsPrice?.length>=2;return d&&t});var H=function(e){return e.InStock="IN_STOCK",e.LimitedStock="LIMITED_STOCK",e.OutOfStock="OUT_OF_STOCK",e.Preorder="PREORDER",e}(H||{});var h=function(e){return e.BoughtTogether="BOUGHT_TOGETHER",e.RelatedProducts="RELATED_PRODUCTS",e}(h||{});var Z=T` fragment Money on Money { currency displayValue value valueWithoutVat } `,ue=T` fragment SalePriceDiscount on SalePriceDiscount { fixValue { ...Money } offerName percentageValue type period periodType } ${Z}`,me=T` fragment RecommendationPrice on RecommendationPrice { amount { ...Money } discount { ...SalePriceDiscount } } ${Z} ${ue}`,le=T` fragment DotDiscount on DotDiscount { oaCode type text filters value start end campaignId campaignTitle } `,Ee=T` fragment RecommendationResponse on RecommendationResponse { productId productCode title subTitle href brand imageURL variantColorCodes price { ...RecommendationPrice } dotDiscount { ...DotDiscount } hardDisk color stockState carouselPicturesNew { __typename displayOrder pictures { __typename rel href } } } ${me} ${le}`,tt=T` query GetRecommendationsQuery($recommendationsRequest: RecommendationsRequest) { getRecommendations(recommendationsRequest: $recommendationsRequest) { ...RecommendationResponse } } ${Ee}`;var Ot=(()=>{let a=class a extends w{constructor(t,r){super(),this.store=t,this.storeSelector=r,this.activeTabNotFrequentlyBoughtTogether$=new f,this.destroyedProductPage$=new f}convertProductsToSmallProducts(t){return t.map(r=>({id:r.productId,alt:r.brand+" "+r.title,href:r.href?r.href:"",picture:V.getHrefAndFallbackFromCarousel({carouselPictures:r.carouselPicturesNew,relType:"100x100"})}))}destroyedProductPage(){this.destroyedProductPage$.next(!0),this.destroyedProductPage$.complete()}getProductPrices(t,r){let u=r===h.RelatedProducts?b:x;return this.store.select(u).pipe(C(Boolean),D(l=>l?.find(m=>m.id===t)?.priceVariants))}getRelatedProducts(t,r){let u={msisdn:r||"",productId:t,shouldOffer:!1,type:h.RelatedProducts};this.store.dispatch(Q({recommendationsRequest:u}))}isLoggedIn$(){return this.storeSelector.getWithSelector($)}isPostPaidUser$(){return this.isLoggedIn$().pipe(C(Boolean),v(()=>this.storeSelector.getWithSelector(j)),D(W))}mapRecommendedProductToRecommendedProductTracking(t,r,u,l,m,O){let{product:n,price:p}=t,{installmentPrice:ee,acquisitionPrice:te,standardPrice:B}=this.processPriceVariants(p.priceVariants),y=`${n.href?.split("/")[n.href?.split("/").length-1].split("-").join(" ")}`,E=this.getRecommendedProductTrackingInfoBasedOnAvailableSellingOptionsAndUserType(ee,te,B,r,u,p),re=E?.displayedPrice?.find(S=>S?.currency===_.EUR)?.value,oe=E?.basePrice?.find(S=>S?.currency===_.EUR)?.value,ce=B?.referenceAmount?.find(S=>S?.currency===_.EUR)?.value,ie=n.stockState===H.OutOfStock?I.outOfStock:I.inStock,ne=m?.item?.stockState===U.InStock||m?.item?.stockState===U.Preorder?"bottom-instock":"middle-outofstock",A=`product-${O}-${m?`${ne}-`:""}${K()}`;return sessionStorage.setItem(n.productCode?.toString()??"0",A),{abonamentAtasat:E?.attachedSubscription,availability:ie,base_price:Number(oe),brand:n.brand?.toLowerCase()??Y.brand,category:"telefoane",color:n.color.toLowerCase(),file:"related-products.service.ts:167",id:n.productCode?.toString()??"0",img_url:n.imageURL,installments:E?.installmentsPeriod??X,item_name_full:y,list:A,memory:n.hardDisk?.toString()??"",name:y.toLowerCase(),period:E?.transactionType===g.standard?0:24,position:l,price:Number(re),promotion_name:E?.promotionName,retail_price:Number(ce),transactionSubType:E?.transactionSubType,transactionType:E?.transactionType,reviews:null}}processPriceVariants(t){let r,u,l;return t?.allPriceVariants?.forEach(m=>{m.discriminator.acquisition===P.Loyalty&&m.discriminator.installment===L.Oro&&(r=this.extractRecommendedPrice(m)),m.discriminator.acquisition===P.Acquisition&&(u=this.extractRecommendedPrice(m))}),l=t?.standardPrice,{installmentPrice:r,acquisitionPrice:u,standardPrice:l}}extractRecommendedPrice(t){return t.items?t.items[0].price:void 0}getRecommendedProductTrackingInfoBasedOnAvailableSellingOptionsAndUserType(t,r,u,l,m,O){if(t?.installmentAmount&&!l||t?.installmentAmount&&l&&m){let n=O.priceVariants?.allPriceVariants?.find(p=>p.discriminator.acquisition===P.Loyalty&&p.discriminator.installment===L.Oro)?.items[0].salePackage;return{basePrice:t.referenceAmount,displayedPrice:t.amount,installmentsPeriod:t?.installmentPeriod||void 0,promotionName:t.discount?.offerName,transactionType:g.installment,attachedSubscription:{base_price:n?.price?.value||0,id:n?.ref||"",name:n?.displayName||"",period:24,price:n?.price?.value||0,discounted_subscription:!1}}}if(!t?.installmentAmount&&!l&&r||!t?.installmentAmount&&r&&l){let n=O.priceVariants?.allPriceVariants?.find(p=>p.discriminator.acquisition===P.Acquisition)?.items[0].salePackage;return{basePrice:r.referenceAmount,displayedPrice:r.amount,promotionName:r.discount?.offerName,transactionSubType:"acquisition_new_package",transactionType:g.acquisition,attachedSubscription:{base_price:n?.price?.value||0,id:n?.ref||"",name:n?.displayName||"",period:24,price:n?.price?.value||0,discounted_subscription:!1}}}if(u&&!t?.installmentAmount&&!r?.amount)return{basePrice:u.referenceAmount,displayedPrice:u?.amount,promotionName:u.discount?.offerName,transactionType:g.standard}}};a.\u0275fac=function(r){return new(r||a)(G(F),G(q))},a.\u0275prov=N({token:a,factory:a.\u0275fac,providedIn:"root"});let e=a;return e})();export{he as a,fe as b,De as c,Ce as d,Le as e,Ue as f,Ie as g,xe as h,be as i,He as j,Be as k,Q as l,ye as m,Ae as n,ve as o,Ne as p,Fe as q,ke as r,Me as s,$e as t,h as u,tt as v,R as w,se as x,Ve as y,We as z,Xe as A,Ye as B,x as C,J as D,ae as E,b as F,Ke as G,de as H,Qe as I,ze as J,Ot as K};