import{a as re}from"./chunk-NDP6HZZJ.js";import{c as te,f as ie,i as se}from"./chunk-WYGUJUUK.js";import{A as L,B as Qt,C as V,c as Nt,f as Mt,i as bt,k as Rt,l as Dt,o as Ft,q as xt,s as jt,x as q,y as Gt,z as B}from"./chunk-EEUSJGKN.js";import{b as ee}from"./chunk-YS6HBWHP.js";import{m as vt}from"./chunk-ELBRF33D.js";import{b as G,v as ae}from"./chunk-XGB2C2LU.js";import{p as Et}from"./chunk-D2IW66IV.js";import{c as At,i as gt,l as It,o as $t,s as Tt}from"./chunk-SFDJZTYR.js";import{U as Bt,_ as Lt,ba as Vt,i as Ut,q as kt,y as qt}from"./chunk-5BKAF643.js";import{A as y,d as F,f as zt,l as Ht,n as Jt,q as Kt,s as Wt,t as Xt,u as Yt,v as x,w as j,x as Zt,y as f}from"./chunk-G5KLVBJF.js";import{f as wt}from"./chunk-SGVVBT4Z.js";import{o as _t}from"./chunk-ZN6KIBAH.js";import{B as st,C as at,Ca as ct,D as l,E as h,Ea as dt,Ha as ut,I as ot,Va as mt,Wa as lt,a as P,b as X,c as Y,d as S,e as O,f as Z,fb as k,g as _,h as E,i as tt,j as v,k as N,kb as ft,l as et,lb as ht,ma as nt,n,o as A,p as g,q as I,s as M,t as b,tb as yt,u as rt,v as R,x as D,xa as pt,xb as Ct,y as it,z as U}from"./chunk-OD6CMNJH.js";import{b as i,c as Ot,d as s}from"./chunk-O7JFACMN.js";import{b as Pt,s as St}from"./chunk-Y4LLAK7R.js";import{s as W}from"./chunk-QUA65JBC.js";import{k as K}from"./chunk-LUW5RRY5.js";import{Ca as a,Fa as C,J as u,Ma as J,O as o,Ra as m,V as z,Z as H,ba as c,ha as w}from"./chunk-NRAZ4AKM.js";var ce=()=>t=>t.data&&t.data.clearCart&&!t.errors?[Z()]:t.errors?[O({errors:t.errors})]:[O({errors:[new Error("handleClearCartResponse communication error")]}),n({failedAction:S.type})],de=t=>t.data&&!t.errors?v():t.errors?tt({errors:t.errors}):n({failedAction:E.type}),ue=t=>{if(t?.errors?.length)return u(X({errors:t.errors}));if(t?.data?.cartV2){let r=[Y({cart:t.data.cartV2}),Jt({quantity:ot(t?.data?.cartV2)})];return u(...r)}return u(n({failedAction:P.type}))},me=t=>t.data&&t.data.setTelewebInfo&&!t.errors?U():t.errors?it({errors:t.errors}):n({failedAction:D.type}),le=t=>r=>r.data&&r.data.setOtyConsumption&&!r.errors?I({oty:t}):r.errors?g({errors:r.errors}):n({failedAction:A.type}),fe=t=>t.data&&t.data.setPayment&&!t.errors?R():t.errors?rt({errors:t.errors}):n({failedAction:b.type}),d=t=>r=>u(n({failedAction:t.type,error:r})),he=()=>t=>t.data&&t.data.generateNewAddressOTP&&!t.errors?B({data:t.data}):t.data&&t.errors?Gt({errors:t.errors}):n({failedAction:q.type}),ye=()=>t=>t.data&&t.data.verifyNewAddressOTP&&!t.errors?V({data:t.data}):t.data&&t.errors?Qt({errors:t.errors}):n({failedAction:L.type}),Ce=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?f.updatePpy2PpdMsisdnSuccess({msisdn:t}):r.data&&r.errors?f.updatePpy2PpdMsisdnError({errors:r.errors}):n({failedAction:f.updatePpy2PpdMsisdn.type}),Pe=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?y.updatePpyPrepayMsisdnSuccess({msisdn:t}):r.data&&r.errors?y.updatePpyPrepayMsisdnError({errors:r.errors}):n({failedAction:y.updatePpyPrepayMsisdn.type}),Ke=(()=>{let r=class r{constructor(Q,$,oe,ne,pe){this.actions$=Q,this.cartApolloClient=$,this.router=oe,this.store=ne,this.snackBar=pe,this.dismissNotification$=i(()=>this.actions$.pipe(s(E)).pipe(a(e=>this.cartApolloClient.mutate({mutation:ct,variables:{notifications:[{notificationId:e.notification.id,cartItemId:e.notification.itemRef&&e.notification.itemRef.itemId}]}}).pipe(o(de))))),this.eShopCartChange$=i(()=>z(window,"message").pipe(H(e=>e.data==="eShopCartChange")).pipe(w(N()))),this.getCart$=i(()=>this.actions$.pipe(s(P),a(e=>this.cartApolloClient.query({query:dt}).pipe(a(ue)).pipe(c(d(e)))))),this.logCommunicationError$=i(()=>this.actions$.pipe(s(n),C(console.error)),{dispatch:!1}),this.reloadCart$=i(()=>this.actions$.pipe(s(F,Et,Nt,ie,se,bt,te,Mt,v,N,Ft,jt,Kt,I,R,Dt,U,St,kt,Bt,Ut,At,gt,It,$t,B,V,l.updateInstallmentPeriodSuccess,l.updateInstallmentPeriodError,x.updateSimOptionSuccess,x.updateSimOptionError,j.updatePrepayProductTypeSuccess,j.updatePrepayProductTypeError,Zt.updateSubscriptionTypeSuccess,f.updatePpy2PpdMsisdnSuccess,Lt,Vt,qt,Tt),a(e=>e.type===F.type&&e.triggerGetCart===!1?[h.getItemIds()]:[P(),vt()]))),this.updateCartStateFromResponse=i(()=>this.actions$.pipe(s(Xt,zt,Ht),o(e=>e.cart?Yt({cart:e.cart}):_t()))),this.reloadCartFromLocalStore$=i(()=>this.actions$.pipe(s(g,Rt,Wt),o(()=>et()))),this.reloadCartOnProfileChange$=i(()=>this.actions$.pipe(s(Pt)).pipe(w(_()))),this.resetCart$=i(()=>this.actions$.pipe(s(S)).pipe(a(()=>this.cartApolloClient.mutate({mutation:pt}))).pipe(a(ce())).pipe(c(()=>u(n({failedAction:S.type}))))),this.setCartImpersonation$=i(()=>this.actions$.pipe(s(D),a(e=>this.cartApolloClient.mutate({mutation:yt,variables:{teleweb:{callType:e.callType,userType:e.userType}}}).pipe(o(me)).pipe(c(d(e)))))),this.updateInstallmentPeriod$=i(()=>this.actions$.pipe(s(l.updateInstallmentPeriod),a(e=>this.cartApolloClient.mutate({mutation:Ct,variables:{term:e.period}}).pipe(o(p=>p.data?l.updateInstallmentPeriodSuccess():l.updateInstallmentPeriodError()),c(d(e)))))),this.setOtyConsumption$=i(()=>this.actions$.pipe(s(A),a(e=>this.cartApolloClient.mutate({mutation:ft,variables:{value:e.oty,unit:nt.Fix}}).pipe(o(le(e.oty))).pipe(c(d(e)))))),this.setOtyConsumptionError$=i(()=>this.actions$.pipe(s(g),o(e=>e.errors.find(p=>p.message.toLowerCase().trim()==="Value provided for oty consumption thresholds:1 exceeds maximum allowed oty points: 0".toLowerCase().trim())?A({oty:0}):re()))),this.setOtyConsumptionSuccess$=i(()=>this.actions$.pipe(s(I),C(e=>{e?.oty>=1&&this.store.dispatch(M())})),{dispatch:!1}),this.openShowUseOtyMessageNotification$=i(()=>this.actions$.pipe(s(M),C(()=>{this.snackBar.open("Valoarea punctelor a fost sc\u0103zut\u0103 din totalul de plat\u0103.","x",{horizontalPosition:"center",verticalPosition:"top",duration:5e3})})),{dispatch:!1}),this.setPayment$=i(()=>this.actions$.pipe(s(b),a(e=>this.cartApolloClient.mutate({mutation:ht,variables:{method:e.method,parameters:e.parameters||[]}}).pipe(o(fe)).pipe(c(d(e)))))),this.setTab$=i(()=>this.actions$.pipe(s(st,at),a(e=>u(xt({shippingTypeSelection:e.shippingTypeSelection}))))),this.generateNewAddressOTP$=i(()=>this.actions$.pipe(s(q),a(e=>this.cartApolloClient.mutate({mutation:mt}).pipe(o(he())).pipe(c(d(e)))))),this.verifyNewAddressOTP$=i(()=>this.actions$.pipe(s(L),a(e=>{let p={code:e.code};return e.forced&&(p.forced=e.forced),this.cartApolloClient.mutate({mutation:lt,variables:p}).pipe(o(ye())).pipe(c(d(e)))}))),this.updatePpy2PpdNotLoggedMsisdn$=i(()=>this.actions$.pipe(s(f.updatePpy2PpdMsisdn),a(e=>this.cartApolloClient.mutate({mutation:k,variables:{msisdn:e.msisdn}}).pipe(o(Ce(e.msisdn))).pipe(c(d(e)))))),this.updatePpyPrepayMsisdn$=i(()=>this.actions$.pipe(s(y.updatePpyPrepayMsisdn),a(e=>this.cartApolloClient.mutate({mutation:k,variables:{msisdn:e.msisdn}}).pipe(o(Pe(e.msisdn))).pipe(c(d(e)))))),this.getUnofferedCartItemIds$=i(()=>this.actions$.pipe(s(h.getItemIds,G),a(e=>e.type===G.type&&e.recommendationsRequest.type!==ae.BoughtTogether?u():this.cartApolloClient.query({query:ut}).pipe(o(p=>p.data&&p.data.unofferedCart&&p.data.unofferedCart.__typename!=="EmptyCartResource"?h.getItemIdsSuccess({ids:p.data.unofferedCart.items.filter(T=>!!T?.product?.id).map(T=>T?.product?.id)}):h.getItemIdsError())))))}};r.\u0275fac=function($){return new($||r)(m(Ot),m(ee),m(K),m(W),m(wt))},r.\u0275prov=J({token:r,factory:r.\u0275fac});let t=r;return t})();export{d as a,Ke as b};