import{a as pe}from"./chunk-HUICIZ5O.js";import{c as oe,f as ce,i as de}from"./chunk-CFHNCEOZ.js";import{a as me}from"./chunk-AEQJSWCP.js";import{c as Dt,f as Ut,i as kt,k as qt,l as Bt}from"./chunk-7UB464BM.js";import{c as Jt,e as Kt,g as Wt,l as L,m as Xt,n as V,o as F,p as Yt,q as j}from"./chunk-KLX7UCPH.js";import{b as ne}from"./chunk-YICBAQ54.js";import{m as Rt}from"./chunk-S6VYT6EF.js";import{b as H,v as ue}from"./chunk-MOFR7S7Z.js";import{p as bt}from"./chunk-W7Q3ZR5P.js";import{i as Tt,o as Ot,r as wt,u as vt,y as Nt}from"./chunk-JKWGET3C.js";import{$ as zt,P as xt,S as Gt,V as Qt,ca as Ht,f as Lt,j as Vt,r as Ft,z as jt}from"./chunk-YLJZO3O6.js";import{B as I,e as x,g as Zt,m as _t,o as te,r as ee,t as re,u as ie,v as se,w as G,x as Q,y as z,z as l}from"./chunk-AWPNCRQB.js";import{f as Et}from"./chunk-RRWMTQIW.js";import{o as ae}from"./chunk-JGKGTLYA.js";import{B as pt,C as ct,Ca as lt,D as y,E as A,Ea as ft,Ha as ht,I as dt,Va as yt,Wa as Ct,a as g,b as tt,c as et,d as $,e as N,f as rt,fb as B,g as it,h as E,i as st,j as M,k as b,kb as Pt,l as at,lb as St,ma as ut,n,o as T,p as O,q as w,s as R,t as D,tb as At,u as ot,v as U,x as k,xa as mt,xb as It,y as nt,z as q}from"./chunk-MHFCLVAZ.js";import{b as i,c as Mt,d as s}from"./chunk-XA6AU52H.js";import{b as gt,s as $t}from"./chunk-YFWLORNM.js";import{s as _}from"./chunk-VYUKN3XQ.js";import{k as Z}from"./chunk-AWMJHCA7.js";import{Da as a,Ga as f,K as u,Na as X,P as o,Sa as h,Ta as Y,W as K,_ as W,ca as c,ia as v}from"./chunk-XNQ3RS5P.js";var ye=()=>t=>t.data&&t.data.clearCart&&!t.errors?[rt()]:t.errors?[N({errors:t.errors})]:[N({errors:[new Error("handleClearCartResponse communication error")]}),n({failedAction:$.type})],Ce=t=>t.data&&!t.errors?M():t.errors?st({errors:t.errors}):n({failedAction:E.type}),Pe=t=>{var r,J,C;if((r=t==null?void 0:t.errors)!=null&&r.length)return u(tt({errors:t.errors}));if((J=t==null?void 0:t.data)!=null&&J.cartV2){let P=[et({cart:t.data.cartV2}),te({quantity:dt((C=t==null?void 0:t.data)==null?void 0:C.cartV2)})];return u(...P)}return u(n({failedAction:g.type}))},Se=t=>t.data&&t.data.setTelewebInfo&&!t.errors?q():t.errors?nt({errors:t.errors}):n({failedAction:k.type}),Ae=t=>r=>r.data&&r.data.setOtyConsumption&&!r.errors?w({oty:t}):r.errors?O({errors:r.errors}):n({failedAction:T.type}),Ie=t=>t.data&&t.data.setPayment&&!t.errors?U():t.errors?ot({errors:t.errors}):n({failedAction:D.type}),d=t=>r=>u(n({failedAction:t.type,error:r})),ge=()=>t=>t.data&&t.data.generateNewAddressOTP&&!t.errors?V({data:t.data}):t.data&&t.errors?Xt({errors:t.errors}):n({failedAction:L.type}),$e=()=>t=>t.data&&t.data.verifyNewAddressOTP&&!t.errors?j({data:t.data}):t.data&&t.errors?Yt({errors:t.errors}):n({failedAction:F.type}),Te=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?l.updatePpy2PpdMsisdnSuccess({msisdn:t}):r.data&&r.errors?l.updatePpy2PpdMsisdnError({errors:r.errors}):n({failedAction:l.updatePpy2PpdMsisdn.type}),Oe=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?I.updatePpyPrepayMsisdnSuccess({msisdn:t}):r.data&&r.errors?I.updatePpyPrepayMsisdnError({errors:r.errors}):n({failedAction:I.updatePpyPrepayMsisdn.type}),sr=(()=>{let r=class r{constructor(C,P,le,fe,he){this.actions$=C,this.cartApolloClient=P,this.router=le,this.store=fe,this.snackBar=he,this.otpService=Y(me),this.dismissNotification$=i(()=>this.actions$.pipe(s(E)).pipe(a(e=>this.cartApolloClient.mutate({mutation:lt,variables:{notifications:[{notificationId:e.notification.id,cartItemId:e.notification.itemRef&&e.notification.itemRef.itemId}]}}).pipe(o(Ce))))),this.eShopCartChange$=i(()=>K(window,"message").pipe(W(e=>e.data==="eShopCartChange")).pipe(v(b()))),this.getCart$=i(()=>this.actions$.pipe(s(g),a(e=>this.cartApolloClient.query({query:ft}).pipe(a(Pe)).pipe(c(d(e)))))),this.logCommunicationError$=i(()=>this.actions$.pipe(s(n),f(console.error)),{dispatch:!1}),this.reloadCart$=i(()=>this.actions$.pipe(s(x,bt,Dt,ce,de,kt,oe,Ut,M,b,Jt,Wt,ee,w,U,Bt,q,$t,Ft,Qt,Vt,Tt,Ot,wt,vt,V,j,y.updateInstallmentPeriodSuccess,y.updateInstallmentPeriodError,G.updateSimOptionSuccess,G.updateSimOptionError,Q.updatePrepayProductTypeSuccess,Q.updatePrepayProductTypeError,z.updateSubscriptionTypeSuccess,l.updatePpy2PpdMsisdnSuccess,zt,Ht,jt,Nt),a(e=>e.type===x.type&&e.triggerGetCart===!1?[A.getItemIds()]:[g(),Rt()]))),this.updateCartStateFromResponse=i(()=>this.actions$.pipe(s(ie,Zt,_t),o(e=>e.cart?se({cart:e.cart}):ae()))),this.reloadCartFromLocalStore$=i(()=>this.actions$.pipe(s(O,qt,re),o(()=>at()))),this.reloadCartOnProfileChange$=i(()=>this.actions$.pipe(s(gt)).pipe(v(it()))),this.resetCart$=i(()=>this.actions$.pipe(s($)).pipe(a(()=>this.cartApolloClient.mutate({mutation:mt}))).pipe(a(ye())).pipe(c(()=>u(n({failedAction:$.type}))))),this.setCartImpersonation$=i(()=>this.actions$.pipe(s(k),a(e=>this.cartApolloClient.mutate({mutation:At,variables:{teleweb:{callType:e.callType,userType:e.userType}}}).pipe(o(Se)).pipe(c(d(e)))))),this.updateInstallmentPeriod$=i(()=>this.actions$.pipe(s(y.updateInstallmentPeriod),a(e=>this.cartApolloClient.mutate({mutation:It,variables:{term:e.period}}).pipe(o(p=>p.data?y.updateInstallmentPeriodSuccess():y.updateInstallmentPeriodError()),c(d(e)))))),this.setOtyConsumption$=i(()=>this.actions$.pipe(s(T),a(e=>this.cartApolloClient.mutate({mutation:Pt,variables:{value:e.oty,unit:ut.Fix}}).pipe(o(Ae(e.oty))).pipe(c(d(e)))))),this.setOtyConsumptionError$=i(()=>this.actions$.pipe(s(O),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())?T({oty:0}):pe()))),this.setOtyConsumptionSuccess$=i(()=>this.actions$.pipe(s(w),f(e=>{(e==null?void 0:e.oty)>=1&&this.store.dispatch(R())})),{dispatch:!1}),this.openShowUseOtyMessageNotification$=i(()=>this.actions$.pipe(s(R),f(()=>{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(D),a(e=>this.cartApolloClient.mutate({mutation:St,variables:{method:e.method,parameters:e.parameters||[]}}).pipe(o(Ie)).pipe(c(d(e)))))),this.setTab$=i(()=>this.actions$.pipe(s(pt,ct),a(e=>u(Kt({shippingTypeSelection:e.shippingTypeSelection}))))),this.generateNewAddressOTP$=i(()=>this.actions$.pipe(s(L),a(e=>this.cartApolloClient.mutate({mutation:yt}).pipe(o(ge())).pipe(c(d(e)))))),this.verifyNewAddressOTP$=i(()=>this.actions$.pipe(s(F),a(e=>{let p={code:e.code};return e.forced&&(p.forced=e.forced),this.cartApolloClient.mutate({mutation:Ct,variables:p}).pipe(o($e())).pipe(c(d(e)))}))),this.updatePpy2PpdNotLoggedMsisdn$=i(()=>this.actions$.pipe(s(l.updatePpy2PpdMsisdn),a(e=>this.cartApolloClient.mutate({mutation:B,variables:{msisdn:e.msisdn}}).pipe(o(Te(e.msisdn))).pipe(c(d(e)))))),this.updatePpyPrepayMsisdn$=i(()=>this.actions$.pipe(s(I.updatePpyPrepayMsisdn),a(e=>this.cartApolloClient.mutate({mutation:B,variables:{msisdn:e.msisdn}}).pipe(o(Oe(e.msisdn))).pipe(c(d(e)))))),this.getUnofferedCartItemIds$=i(()=>this.actions$.pipe(s(A.getItemIds,H),a(e=>e.type===H.type&&e.recommendationsRequest.type!==ue.BoughtTogether?u():this.cartApolloClient.query({query:ht}).pipe(o(p=>p.data&&p.data.unofferedCart&&p.data.unofferedCart.__typename!=="EmptyCartResource"?A.getItemIdsSuccess({ids:p.data.unofferedCart.items.filter(m=>{var S;return!!((S=m==null?void 0:m.product)!=null&&S.id)}).map(m=>{var S;return(S=m==null?void 0:m.product)==null?void 0:S.id})}):A.getItemIdsError()))))),this.startOTPCountDown$=i(()=>this.actions$.pipe(s(Gt,xt,Lt),f(()=>{this.otpService.startCountDown(60)})),{dispatch:!1}),this.clearOTPInterval$=i(()=>this.actions$.pipe(s(z.updateSubscriptionTypeSuccess,l.updatePpy2PpdMsisdnSuccess),f(()=>{this.otpService.clearInterval()})),{dispatch:!1})}};r.\u0275fac=function(P){return new(P||r)(h(Mt),h(ne),h(Z),h(_),h(Et))},r.\u0275prov=X({token:r,factory:r.\u0275fac});let t=r;return t})();export{d as a,sr as b};