import{Tb as Or,Ub as _r}from"./chunk-FYPK2SIE.js";import{$ as ct,$a as Ie,Aa as Sr,Ba as Y,C as d,Ca as Rr,Ec as br,F as _,G as Cr,Gb as k,H as $,I as pr,Ia as ot,J as Q,Ja as Dt,K as ve,Pb as ye,Q as lr,Qb as dt,T as at,Tb as Dr,Ub as Mr,Va as mr,X as Er,Xb as Fr,b as le,c as cr,d as st,e as m,ea as vr,f as D,g as or,ga as H,h as dr,ha as gr,i as S,j as nt,jc as M,k as v,l as ur,pa as fr,q as hr,ra as Ir,sa as yr,ta as w,ua as Ar,v as Ee,va as Z,wa as ge,wb as Tr,za as fe}from"./chunk-O2LUBOWM.js";import{$ as T,Ca as u,Da as V,F as Je,Fa as O,Ha as o,Ia as it,J as l,L as tr,Q as b,Qa as j,S as rt,T as er,W as A,Ye as ar,a as Tt,aa as rr,bb as pe,fa as ir,h as Ze,ja as sr,n as L,o as x,pa as Ce,qd as nr,s as Xe,ta as E,v as c,w as et,wa as G,x as F,ya as I}from"./chunk-6DZ3MS4P.js";import{a as p,b as f}from"./chunk-FMXN7DFR.js";var wr="userProfile",ut="userProfileCore",Ae=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ut,methods:["get","update","close","getTitles"]}),providedIn:"root"});let e=t;return e})();function mi(){return{featureModules:{[wr]:{cmsComponents:["RegisterCustomerComponent","UpdateProfileComponent","UpdateEmailComponent","UpdatePasswordComponent","ForgotPasswordComponent","ResetPasswordComponent","CloseAccountComponent","AccountAddressBookComponent"]},[ut]:wr}}}var vs=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=j({type:t}),t.\u0275inj=V({providers:[Ee(mi),{provide:br,useExisting:Ae}]});let e=t;return e})(),gs=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ut,methods:["update"]}),providedIn:"root"});let e=t;return e})(),fs=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ut,methods:["update","reset","requestForgotPasswordEmail"]}),providedIn:"root"});let e=t;return e})(),Is=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ut,methods:["register","registerGuest","getTitles"]}),providedIn:"root"});let e=t;return e})();var Fs=Symbol("ORDER_ENTRIES_CONTEXT"),g=class extends ge{},Nr=(()=>{let t=class t extends g{};t.type="CreateCartEvent";let e=t;return e})(),Lr=(()=>{let t=class t extends g{};t.type="CreateCartSuccessEvent";let e=t;return e})(),xr=(()=>{let t=class t extends g{};t.type="CreateCartFailEvent";let e=t;return e})(),Vr=(()=>{let t=class t extends g{};t.type="CartAddEntryEvent";let e=t;return e})(),jr=(()=>{let t=class t extends g{};t.type="CartAddEntrySuccessEvent";let e=t;return e})(),$r=(()=>{let t=class t extends g{};t.type="CartAddEntryFailEvent";let e=t;return e})(),Pr=(()=>{let t=class t extends g{};t.type="CartRemoveEntryFailEvent";let e=t;return e})(),kr=(()=>{let t=class t extends g{};t.type="CartRemoveEntrySuccessEvent";let e=t;return e})(),Gr=(()=>{let t=class t extends g{};t.type="CartUpdateEntrySuccessEvent";let e=t;return e})(),Hr=(()=>{let t=class t extends g{};t.type="CartUpdateEntryFailEvent";let e=t;return e})(),bs=(()=>{let t=class t extends ge{};t.type="CartUiEventAddToCart";let e=t;return e})(),Yr=(()=>{let t=class t extends g{};t.type="MergeCartSuccessEvent";let e=t;return e})(),Os=(()=>{let t=class t extends g{};t.type="LoadCartEvent";let e=t;return e})(),_s=(()=>{let t=class t extends g{};t.type="RemoveCartEvent";let e=t;return e})(),Se=(()=>{let t=class t extends g{};t.type="DeleteCartEvent";let e=t;return e})(),Re=(()=>{let t=class t extends g{};t.type="DeleteCartSuccessEvent";let e=t;return e})(),me=(()=>{let t=class t extends g{};t.type="DeleteCartFailEvent";let e=t;return e})(),Mt=(()=>{let t=class t extends g{};t.type="AddCartVoucherEvent";let e=t;return e})(),Br=(()=>{let t=class t extends Mt{};t.type="AddCartVoucherSuccessEvent";let e=t;return e})(),Wr=(()=>{let t=class t extends Mt{};t.type="AddCartVoucherFailEvent";let e=t;return e})(),Ft=(()=>{let t=class t extends g{};t.type="RemoveCartVoucherEvent";let e=t;return e})(),Kr=(()=>{let t=class t extends Ft{};t.type="RemoveCartVoucherSuccessEvent";let e=t;return e})(),qr=(()=>{let t=class t extends Ft{};t.type="RemoveCartVoucherFailEvent";let e=t;return e})(),ws="cartBase",ht="cartBaseCore";var Ct=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ht,methods:["getCart","getCarts","getCartEntity","isStable","createCart","mergeToCurrentCart","loadCart","getEntries","getLastEntry","addEntry","addEntries","removeEntry","updateEntry","getEntry","assignEmail","removeCart","deleteCart","reloadCart","getCartIdByType"],async:!0}),providedIn:"root"});let e=t;return e})();var Us=new O("ActiveCartOrderEntriesContext");var zr=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:function(i){let s=null;return i?s=new(i||t):s=o(hr),s},providedIn:"root"});let e=t;return e})(),Te=(()=>{let t=class t extends _r{};t.type="CartPageEvent";let e=t;return e})(),X=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ht,methods:["getActive","takeActive","getActiveCartId","takeActiveCartId","getEntries","getLastEntry","getLoading","isStable","addEntry","removeEntry","updateEntry","getEntry","addEmail","getAssignedUser","isGuestCart","addEntries","requireLoadedCart","reloadActiveCart","hasPickupItems","hasDeliveryItems","getPickupEntries","getDeliveryEntries"],async:!0}),providedIn:"root"});let e=t;return e})(),De=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ht,methods:["validateCart","getValidationResults"]}),providedIn:"root"});let e=t;return e})(),Qr=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ht,methods:["addVoucher","removeVoucher","getAddVoucherResultError","getAddVoucherResultSuccess","getAddVoucherResultLoading","resetAddVoucherProcessingState"],async:!0}),providedIn:"root"});let e=t;return e})(),Zr=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:()=>M({facade:t,feature:ht,methods:["getCart","getEntries","isStable","addEntry","removeEntry","updateEntry","getEntry"],async:!0}),providedIn:"root"});let e=t;return e})(),Ns=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),Di=function(e){return e.ITEM="cx-cart-item",e.LIST_ITEM="cx-cart-item-list-row",e.ITEM_DETAILS="cx-cart-item.details",e.ITEM_CONFIGURATOR_ISSUES="cx-configurator-issues-notification",e.ITEM_BUNDLE_DETAILS="cx-cart-item.bundle-details",e.ITEM_DELIVERY_DETAILS="cx-cart-item.delivery-details",e.ORDER_SUMMARY="cx-order-summary",e.CART_ITEM_LIST="cx-cart-item-list",e.ADD_TO_CART_CONTAINER="cx-add-to-cart-container",e.PICKUP_INFO="cx-pickup-info",e.ADD_TO_CART_PICKUP_OPTION="cx-add-to-cart-pickup-option",e.DELIVERY_MODE="cx-delivery-mode",e.ORDER_OVERVIEW="cx-order-overview",e}(Di||{}),Mi=function(e){return e.ActiveCart="CART",e.Checkout="CHECKOUT",e.Order="ORDER",e.SaveForLater="SAVE_FOR_LATER",e.SavedCart="SAVED_CART",e}(Mi||{}),Fi=function(e){return e.CART="Cart",e.ORDER="Order",e.QUOTE="Quote",e.SAVED_CART="SavedCart",e}(Fi||{}),y=function(e){return e.ACTIVE="Active",e.WISH_LIST="WishList",e.SELECTIVE="Selective",e.NEW_CREATED="NewCreated",e}(y||{}),Xr=function(e){return e.NO_STOCK="noStock",e.LOW_STOCK="lowStock",e.REVIEW_CONFIGURATION="reviewConfiguration",e.PRICING_ERROR="pricingError",e.UNRESOLVABLE_ISSUES="unresolvableIssues",e}(Xr||{}),bi=function(e){return e.ACTIVE_CART="ACTIVE_CART",e.NEW_SAVED_CART="NEW_SAVED_CART",e.QUICK_ORDER="QUICK_ORDER",e.SAVED_CART="SAVED_CART",e.ORDER_CONFIRMATION="ORDER_CONFIRMATION",e.ORDER_DETAILS="ORDER_DETAILS",e.UNIT_ORDER_DETAILS="UNIT_ORDER_DETAILS",e}(bi||{}),B=function(e){return e.SUCCESS="success",e.LOW_STOCK="lowStock",e.NO_STOCK="noStock",e.UNKNOWN_IDENTIFIER="unknownIdentifier",e.UNKNOWN_ERROR="unknownError",e.LIMIT_EXCEEDED="limitExceeded",e}(B||{}),Ls=new O("CartNormalizer"),xs=new O("OrderEntryPromotionsNormalizer"),Vs=new O("CartModificationNormalizer"),js=new O("SaveCartNormalizer"),$s=new O("CartVoucherNormalizer");var ai="cart",h="[Multi Cart] Multi Cart Data",q="addVoucher",ie="[Cart-entry] Add Entry",St="[Cart-entry] Add Entry Success",se="[Cart-entry] Add Entry Fail",Ne="[Cart-entry] Remove Entry",ne="[Cart-entry] Remove Entry Success",Le="[Cart-entry] Remove Entry Fail",xe="[Cart-entry] Update Entry",ae="[Cart-entry] Update Entry Success",Ve="[Cart-entry] Update Entry Fail",lt=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=ie}},Et=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=St}},vt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=se}},bt=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=Ne}},Ot=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=ne}},_t=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=Le}},wt=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=xe}},Ut=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=ae}},Nt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=Ve}},Rt="[Cart-voucher] Add Cart Vouchers",je="[Cart-voucher] Add Cart Voucher Fail",ce="[Cart-voucher] Add Cart Voucher Success",ci="[Cart-voucher] Reset Add Cart Voucher",oe="[Cart-voucher] Remove Cart Voucher",$e="[Cart-voucher] Remove Cart Voucher Fail",de="[Cart-voucher] Remove Cart Voucher Success",Lt=class extends d.EntityLoadAction{constructor(t){super(ot,q),this.payload=t,this.type=Rt}},xt=class extends d.EntityFailAction{constructor(t){super(ot,q,t.error),this.payload=t,this.type=je}},Vt=class extends d.EntitySuccessAction{constructor(t){super(ot,q),this.payload=t,this.type=ce}},jt=class extends d.EntityLoaderResetAction{constructor(){super(ot,q),this.type=ci}},$t=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=oe}},Pt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=$e}},kt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=de}},J="[Cart] Create Cart",Pe="[Cart] Create Cart Fail",tt="[Cart] Create Cart Success",gt="[Cart] Load Cart",oi="[Cart] Load Cart Fail",W="[Cart] Load Cart Success",ke="[Cart] Load Carts Success",Ge="[Cart] Add Email to Cart",di="[Cart] Add Email to Cart Fail",ui="[Cart] Add Email to Cart Success",He="[Cart] Merge Cart",Ye="[Cart] Merge Cart Success",hi="[Cart] Reset Cart Details",Be="[Cart] Remove Cart",ue="[Cart] Delete Cart",he="[Cart] Delete Cart Success",We="[Cart] Delete Cart Fail",ft=class extends d.EntityLoadAction{constructor(t){super(h,t.tempCartId),this.payload=t,this.type=J}},Gt=class extends d.EntityFailAction{constructor(t){super(h,t.tempCartId),this.payload=t,this.type=Pe}},Ht=class extends d.EntitySuccessAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=tt}},Yt=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=Ge}},Bt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=di}},Wt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=ui}},R=class extends d.EntityLoadAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=gt}},It=class extends d.EntityFailAction{constructor(t){super(h,t.cartId,t.error),this.payload=t,this.type=oi}},Kt=class extends d.EntitySuccessAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=W}},Me=class extends d.EntitySuccessAction{constructor(t){super(h,t.map(P=>P?.code??"")),this.payload=t,this.type=ke}},qt=class{constructor(t){this.payload=t,this.type=He}},zt=class extends d.EntityRemoveAction{constructor(t){super(h,t.oldCartId),this.payload=t,this.type=Ye}},Qt=class extends d.ProcessesLoaderResetAction{constructor(){super(h),this.type=hi}},z=class extends d.EntityRemoveAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=Be}},Zt=class{constructor(t){this.payload=t,this.type=ue}},Xt=class extends d.EntityRemoveAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=he}},Jt=class{constructor(t){this.payload=t,this.type=We}},Ci="[Cart] Cart Processes Increment",pi="[Cart] Cart Processes Decrement",te="[Cart] Set Active Cart Id",Ke="[Cart] Clear Cart State",qe="[Cart] Set cart type index",ze="[Cart] Set cart data",ee=class extends d.EntityProcessesIncrementAction{constructor(t){super(h,t),this.payload=t,this.type=Ci}},yt=class extends d.EntityProcessesDecrementAction{constructor(t){super(h,t),this.payload=t,this.type=pi}},At=class{constructor(t){this.payload=t,this.type=te}},re=class extends d.EntityRemoveAllAction{constructor(){super(h),this.type=Ke}},U=class{constructor(t){this.payload=t,this.type=qe}},Fe=class extends d.EntitySuccessAction{constructor(t){super(h,t.cartId),this.payload=t,this.type=ze}},en=Object.freeze({__proto__:null,ADD_EMAIL_TO_CART:Ge,ADD_EMAIL_TO_CART_FAIL:di,ADD_EMAIL_TO_CART_SUCCESS:ui,AddEmailToCart:Yt,AddEmailToCartFail:Bt,AddEmailToCartSuccess:Wt,CART_ADD_ENTRY:ie,CART_ADD_ENTRY_FAIL:se,CART_ADD_ENTRY_SUCCESS:St,CART_ADD_VOUCHER:Rt,CART_ADD_VOUCHER_FAIL:je,CART_ADD_VOUCHER_SUCCESS:ce,CART_PROCESSES_DECREMENT:pi,CART_PROCESSES_INCREMENT:Ci,CART_REMOVE_ENTRY:Ne,CART_REMOVE_ENTRY_FAIL:Le,CART_REMOVE_ENTRY_SUCCESS:ne,CART_REMOVE_VOUCHER:oe,CART_REMOVE_VOUCHER_FAIL:$e,CART_REMOVE_VOUCHER_SUCCESS:de,CART_RESET_ADD_VOUCHER:ci,CART_UPDATE_ENTRY:xe,CART_UPDATE_ENTRY_FAIL:Ve,CART_UPDATE_ENTRY_SUCCESS:ae,CLEAR_CART_STATE:Ke,CREATE_CART:J,CREATE_CART_FAIL:Pe,CREATE_CART_SUCCESS:tt,CartAddEntry:lt,CartAddEntryFail:vt,CartAddEntrySuccess:Et,CartAddVoucher:Lt,CartAddVoucherFail:xt,CartAddVoucherSuccess:Vt,CartProcessesDecrement:yt,CartProcessesIncrement:ee,CartRemoveEntry:bt,CartRemoveEntryFail:_t,CartRemoveEntrySuccess:Ot,CartRemoveVoucher:$t,CartRemoveVoucherFail:Pt,CartRemoveVoucherSuccess:kt,CartResetAddVoucher:jt,CartUpdateEntry:wt,CartUpdateEntryFail:Nt,CartUpdateEntrySuccess:Ut,ClearCartState:re,CreateCart:ft,CreateCartFail:Gt,CreateCartSuccess:Ht,DELETE_CART:ue,DELETE_CART_FAIL:We,DELETE_CART_SUCCESS:he,DeleteCart:Zt,DeleteCartFail:Jt,DeleteCartSuccess:Xt,LOAD_CART:gt,LOAD_CARTS_SUCCESS:ke,LOAD_CART_FAIL:oi,LOAD_CART_SUCCESS:W,LoadCart:R,LoadCartFail:It,LoadCartSuccess:Kt,LoadCartsSuccess:Me,MERGE_CART:He,MERGE_CART_SUCCESS:Ye,MergeCart:qt,MergeCartSuccess:zt,REMOVE_CART:Be,RESET_CART_DETAILS:hi,RemoveCart:z,ResetCartDetails:Qt,SET_ACTIVE_CART_ID:te,SET_CART_DATA:ze,SET_CART_TYPE_INDEX:qe,SetActiveCartId:At,SetCartData:Fe,SetCartTypeIndex:U}),be=class{},li=(()=>{let t=class t{constructor(r){this.adapter=r}add(r,i,s,n,a){return this.adapter.add(r,i,s,n,a)}update(r,i,s,n,a,C=!1){return this.adapter.update(r,i,s,n,a,C)}remove(r,i,s){return this.adapter.remove(r,i,s)}};t.\u0275fac=function(i){return new(i||t)(o(be))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),_i=(()=>{let t=class t{constructor(r,i){this.actions$=r,this.cartEntryConnector=i,this.contextChange$=this.actions$.pipe(v(H.CURRENCY_CHANGE,H.LANGUAGE_CHANGE)),this.logger=it(at),this.addEntry$=S(()=>this.actions$.pipe(v(ie),c(s=>s.payload),rt(s=>this.cartEntryConnector.add(s.userId,s.cartId,s.productCode,s.quantity,s.pickupStore).pipe(c(n=>new Et(p(p({},s),n))),b(n=>L([new vt(f(p({},s),{error:w(n,this.logger)})),new R({cartId:s.cartId,userId:s.userId})])))),k(this.contextChange$))),this.removeEntry$=S(()=>this.actions$.pipe(v(Ne),c(s=>s.payload),rt(s=>this.cartEntryConnector.remove(s.userId,s.cartId,s.entryNumber).pipe(c(()=>new Ot(p({},s))),b(n=>L([new _t(f(p({},s),{error:w(n,this.logger)})),new R({cartId:s.cartId,userId:s.userId})])))),k(this.contextChange$))),this.updateEntry$=S(()=>this.actions$.pipe(v(xe),c(s=>s.payload),rt(s=>this.cartEntryConnector.update(s.userId,s.cartId,s.entryNumber,s.quantity,s.pickupStore,s.pickupToDelivery).pipe(c(()=>new Ut(p({},s))),b(n=>L([new Nt(f(p({},s),{error:w(n,this.logger)})),new R({cartId:s.cartId,userId:s.userId})])))),k(this.contextChange$)))}};t.\u0275fac=function(i){return new(i||t)(o(nt),o(li))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),Oe=class{},Ei=(()=>{let t=class t{constructor(r){this.adapter=r}add(r,i,s){return this.adapter.add(r,i,s)}remove(r,i,s){return this.adapter.remove(r,i,s)}};t.\u0275fac=function(i){return new(i||t)(o(Oe))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),wi=(()=>{let t=class t{constructor(r,i,s){this.actions$=r,this.cartVoucherConnector=i,this.messageService=s,this.logger=it(at),this.addCartVoucher$=S(()=>this.actions$.pipe(v(Rt),c(n=>n.payload),F(n=>this.cartVoucherConnector.add(n.userId,n.cartId,n.voucherId).pipe(c(()=>(this.showGlobalMessage("voucher.applyVoucherSuccess",n.voucherId,Y.MSG_TYPE_CONFIRMATION),new Vt(p({},n)))),b(a=>L([new xt(f(p({},n),{error:w(a,this.logger)})),new yt(n.cartId),new R({userId:n.userId,cartId:n.cartId})])))))),this.removeCartVoucher$=S(()=>this.actions$.pipe(v(oe),c(n=>n.payload),F(n=>this.cartVoucherConnector.remove(n.userId,n.cartId,n.voucherId).pipe(c(()=>(this.showGlobalMessage("voucher.removeVoucherSuccess",n.voucherId,Y.MSG_TYPE_INFO),new kt({userId:n.userId,cartId:n.cartId,voucherId:n.voucherId}))),b(a=>L([new Pt({error:w(a,this.logger),cartId:n.cartId,userId:n.userId,voucherId:n.voucherId}),new R({userId:n.userId,cartId:n.cartId})]))))))}showGlobalMessage(r,i,s){this.messageService.add({key:r,params:{voucherCode:i}},s)}};t.\u0275fac=function(i){return new(i||t)(o(nt),o(Ei),o(Rr))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})();function K(e,t){return t===_?e?.guid??"":e?.code??""}function vi(e=""){return e.startsWith("selectivecart")}function gi(e){return e.reason==="notFound"&&e.subjectType==="cart"&&!vi(e.subject)}function Ui(e){return e.message==="coupon.already.redeemed"}function Ni(e){return e.message==="coupon.invalid.code.provided"}function Li(e){return e.type==="VoucherOperationError"}function xi(e){return e.type==="CartError"||e.type==="CartAddressError"||e.type==="CartEntryError"||e.type==="CartEntryGroupError"}function Jr(e){return e.startsWith("temp-")}function pt(e){return!e||typeof e=="object"&&Object.keys(e).length===0}function Vi(e){return e?!!e.match(Fr):!1}function ji(e,t){return e!==_&&t!==e}var Qe=or(ai),mt=D(Qe,e=>e.carts),$i=e=>D(mt,t=>d.entityProcessesLoaderStateSelector(t,e)),fi=e=>D(mt,t=>d.entityValueSelector(t,e)),Pi=e=>D(mt,t=>d.entityIsStableSelector(t,e)),ki=e=>D(mt,t=>d.entityHasPendingProcessesSelector(t,e)),_e=e=>D(fi(e),t=>t&&t.entries?t.entries:[]),Gi=(e,t)=>D(_e(e),P=>P.find(r=>r.product?.code===t)),Hi=D(mt,e=>Object.keys(e.entities).map(t=>d.entityValueSelector(e,t))),Yi=D(Qe,e=>e.index),Bi=e=>D(Yi,t=>t&&t[e]),we=class{},Ii=(()=>{let t=class t{constructor(r){this.adapter=r}loadAll(r){return this.adapter.loadAll(r)}load(r,i){return this.adapter.load(r,i)}create(r,i,s){return this.adapter.create(r,i,s)}delete(r,i){return this.adapter.delete(r,i)}save(r,i,s,n){return this.adapter.save(r,i,s,n)}addEmail(r,i,s){return this.adapter.addEmail(r,i,s)}};t.\u0275fac=function(i){return new(i||t)(o(we))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),Wi=(()=>{let t=class t{handleLoadCartError(r,i){if(i?.error?.errors){if(i.error.errors.filter(a=>a.reason==="invalid").length>0)return x(new R(p({},r)));if(i.error.errors.filter(a=>gi(a)||a.reason==="UnknownResourceError").length>0)return x(new z({cartId:r.cartId}))}return x(new It(f(p({},r),{error:w(i,this.logger)})))}constructor(r,i,s){this.actions$=r,this.cartConnector=i,this.store=s,this.contextChange$=this.actions$.pipe(v(H.CURRENCY_CHANGE,H.LANGUAGE_CHANGE)),this.logger=it(at),this.loadCart$=S(()=>this.actions$.pipe(v(gt),c(n=>n.payload),ir(n=>n.cartId),F(n=>n.pipe(E(a=>x(a).pipe(I(this.store.pipe(m(ki(a.cartId)))))),l(([a,C])=>!C),c(([a])=>a),E(a=>this.cartConnector.load(a.userId,a.cartId).pipe(F(C=>{let N=[];return C?(N.push(new Kt(f(p({},a),{cart:C,cartId:K(C,a.userId)}))),a.cartId===$&&N.push(new z({cartId:$}))):N=[new It(f(p({},a),{error:{}}))],N}),b(C=>this.handleLoadCartError(a,C)))))),k(this.contextChange$))),this.createCart$=S(()=>this.actions$.pipe(v(J),c(n=>n.payload),F(n=>this.cartConnector.create(n.userId,n.oldCartId,n.toMergeCartGuid).pipe(E(a=>{let C=[];return n.oldCartId&&C.push(new zt({extraData:n.extraData,userId:n.userId,tempCartId:n.tempCartId,cartId:K(a,n.userId),oldCartId:n.oldCartId})),[new Ht(f(p({},n),{cart:a,cartId:K(a,n.userId)})),new z({cartId:n.tempCartId}),...C]}),b(a=>x(new Gt(f(p({},n),{error:w(a,this.logger)})))))),k(this.contextChange$))),this.mergeCart$=S(()=>this.actions$.pipe(v(He),c(n=>n.payload),E(n=>this.cartConnector.load(n.userId,$).pipe(c(a=>{if(a?.code!==n.cartId)return new ft({userId:n.userId,oldCartId:n.cartId,toMergeCartGuid:a?a.guid:void 0,extraData:n.extraData,tempCartId:n.tempCartId})}),l(ct))),k(this.contextChange$))),this.refresh$=S(()=>this.actions$.pipe(v(ce),c(n=>n.payload),rt(n=>L([new yt(n.cartId),new R({userId:n.userId,cartId:n.cartId})])))),this.refreshWithoutProcesses$=S(()=>this.actions$.pipe(v(St,ne,ae,de),c(n=>n.payload),c(n=>new R({userId:n.userId,cartId:n.cartId})))),this.resetCartDetailsOnSiteContextChange$=S(()=>this.actions$.pipe(v(H.LANGUAGE_CHANGE,H.CURRENCY_CHANGE),F(()=>[new Qt]))),this.addEmail$=S(()=>this.actions$.pipe(v(Ge),c(n=>n.payload),F(n=>this.cartConnector.addEmail(n.userId,n.cartId,n.email).pipe(F(()=>[new Wt(p({},n)),new R({userId:n.userId,cartId:n.cartId})]),b(a=>L([new Bt(f(p({},n),{error:w(a,this.logger)})),new R({userId:n.userId,cartId:n.cartId})])))),k(this.contextChange$))),this.deleteCart$=S(()=>this.actions$.pipe(v(ue),c(n=>n.payload),F(n=>this.cartConnector.delete(n.userId,n.cartId).pipe(c(()=>new Xt(p({},n))),b(a=>L([new Jt(f(p({},n),{error:w(a,this.logger)})),new R(p({},n))]))))))}};t.\u0275fac=function(i){return new(i||t)(o(nt),o(Ii),o(st))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),yi=(()=>{let t=class t{getActiveCartTypeOnLoadSuccess(r){if(r?.payload?.extraData?.active)return r.payload?.cart.saveTime?new U({cartType:y.ACTIVE,cartId:""}):new U({cartType:y.ACTIVE,cartId:r.meta.entityId})}};t.\u0275fac=function(i){return new(i||t)},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),Ki=(()=>{let t=class t{getActiveCartTypeOnLoad(r){if(r?.payload?.cartId===$)return new U({cartType:y.ACTIVE,cartId:""})}getActiveCartTypeOnLoadSuccess(r){return this.multiCartEffectsService.getActiveCartTypeOnLoadSuccess(r)}getActiveCartTypeOnCreate(r){if(r?.payload?.extraData?.active)return new U({cartType:y.ACTIVE,cartId:r.meta.entityId})}constructor(r,i){this.actions$=r,this.multiCartEffectsService=i,this.processesIncrement$=S(()=>this.actions$.pipe(v(Rt),c(s=>s.payload),c(s=>new ee(s.cartId)))),this.setSelectiveId$=S(()=>this.actions$.pipe(v(W),c(s=>{switch(s.type){case W:{let n=s.payload;if(vi(n.cartId))return new U({cartType:y.SELECTIVE,cartId:n.cartId});break}}}),l(ct))),this.setActiveCartId$=S(()=>this.actions$.pipe(v(W,gt,tt,J,te),c(s=>{switch(s.type){case gt:return this.getActiveCartTypeOnLoad(s);case W:return this.getActiveCartTypeOnLoadSuccess(s);case J:return this.getActiveCartTypeOnCreate(s);case tt:return new U({cartType:s?.payload?.extraData?.active?y.ACTIVE:y.NEW_CREATED,cartId:s.meta.entityId});case te:return new U({cartType:y.ACTIVE,cartId:s.payload})}}),l(ct)))}};t.\u0275fac=function(i){return new(i||t)(o(nt),o(yi))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),qi=[_i,wi,Wi,Ki],ti={[y.ACTIVE]:""};function zi(e=ti,t){switch(t.type){case qe:return f(p({},e),{[t.payload.cartType]:t.payload.cartId});case Be:case he:return t.payload?.cartId===e[y.ACTIVE]?f(p({},e),{[y.ACTIVE]:""}):e;case Ke:return ti}return e}var Qi=void 0;function Zi(e=Qi,t){switch(t.type){case ke:return t.payload;case W:case tt:case ze:return t.payload.cart}return e}function Xi(e){return function(t,P){return P.type===pr.LOGOUT&&(t=void 0),e(t,P)}}var Ji=[Xi],Ai=new O("MultiCartReducers");function ts(){return{carts:d.entityProcessesLoaderReducer(h,Zi),index:zi}}var es={provide:Ai,useFactory:ts};var rs=(()=>{let t=class t{constructor(r,i,s){this.statePersistenceService=r,this.store=i,this.siteContextParamsService=s,this.subscription=new Tt}initSync(){this.subscription.add(this.statePersistenceService.syncWithStorage({key:"cart",state$:this.getCartState(),context$:this.siteContextParamsService.getValues([vr]),storageType:fr.LOCAL_STORAGE,onRead:r=>this.onRead(r)}))}getCartState(){return this.store.pipe(l(r=>!!r.cart),m(Qe),l(r=>!!r),c(r=>r.index),rr("Active"),c(r=>({active:r[y.ACTIVE]??""})))}onRead(r){this.store.dispatch(new re),r?this.store.dispatch(new At(r.active)):this.store.dispatch(new At(""))}ngOnDestroy(){this.subscription.unsubscribe()}};t.\u0275fac=function(i){return new(i||t)(o(Ir),o(st),o(Tr))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function is(e,t){return()=>Xe(t.getStable("context").pipe(G(()=>{e.initSync()})))}function ss(){return t=>(P,r)=>{let i=p({},P);return r.type==="@ngrx/store/init"&&(i.cart=f(p({},i.cart),{index:{[y.ACTIVE]:void 0}})),t(i,r)}}var ns=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=j({type:t}),t.\u0275inj=V({providers:[{provide:mr,useFactory:is,deps:[rs,Ar],multi:!0},{provide:cr,useFactory:ss,multi:!0}]});let e=t;return e})(),Ue=class{},Si=(()=>{let t=class t{constructor(r){this.adapter=r}validate(r,i){return this.adapter.validate(r,i)}};t.\u0275fac=function(i){return new(i||t)(o(Ue))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),as=(()=>{let t=class t{constructor(r,i,s,n){this.actionsSubject=r,this.event=i,this.activeCartService=s,this.stateEventService=n,this.register()}register(){this.registerCreateCart(),this.registerAddEntry(),this.registerRemoveEntry(),this.registerUpdateEntry(),this.registerDeleteCart(),this.registerAddCartVoucher(),this.registerRemoveCartVoucher(),this.registerMergeCartSuccess()}registerAddEntry(){this.registerMapped({action:ie,event:Vr}),this.registerMapped({action:St,event:jr}),this.registerMapped({action:se,event:$r})}registerRemoveEntry(){this.registerMapped({action:ne,event:kr}),this.registerMapped({action:Le,event:Pr})}registerUpdateEntry(){this.registerMapped({action:ae,event:Gr}),this.registerMapped({action:Ve,event:Hr})}registerMergeCartSuccess(){this.registerMapped({action:Ye,event:Yr})}registerCreateCart(){this.stateEventService.register({action:J,event:Nr}),this.stateEventService.register({action:tt,event:Lr}),this.stateEventService.register({action:Pe,event:xr})}registerDeleteCart(){this.stateEventService.register({action:ue,event:Se,factory:r=>Z(Se,f(p({},r.payload),{cartCode:r.payload.cartId}))}),this.stateEventService.register({action:he,event:Re,factory:r=>Z(Re,f(p({},r.payload),{cartCode:r.payload.cartId}))}),this.stateEventService.register({action:We,event:me,factory:r=>Z(me,f(p({},r.payload),{cartCode:r.payload.cartId}))})}registerAddCartVoucher(){this.stateEventService.register({action:Rt,event:Mt}),this.stateEventService.register({action:ce,event:Br}),this.stateEventService.register({action:je,event:Wr})}registerRemoveCartVoucher(){this.stateEventService.register({action:oe,event:Ft}),this.stateEventService.register({action:de,event:Kr}),this.stateEventService.register({action:$e,event:qr})}registerMapped(r){let i=this.getAction(r.action).pipe(E(s=>x(s).pipe(I(this.activeCartService.getActive(),this.activeCartService.getActiveCartId()))),l(([s,n,a])=>s.payload.cartId===a),c(([s,n])=>Z(r.event,f(p({},s.payload),{cartCode:n.code,entry:s.payload.entry?s.payload.entry:n.entries?.[Number(s.payload.entryNumber)]}))));return this.event.register(r.event,i)}getAction(r){return this.actionsSubject.pipe(v(...[].concat(r)))}};t.\u0275fac=function(i){return new(i||t)(o(le),o(fe),o(X),o(Sr))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),cs=(()=>{let t=class t{constructor(r){}};t.\u0275fac=function(i){return new(i||t)(o(as))},t.\u0275mod=j({type:t}),t.\u0275inj=V({});let e=t;return e})(),os=(()=>{let t=class t{constructor(r){this.eventService=r,this.register()}register(){this.eventService.register(Te,this.buildCartPageEvent())}buildCartPageEvent(){return this.eventService.get(Or).pipe(l(r=>r.semanticRoute==="cart"),c(r=>Z(Te,{navigation:r})))}};t.\u0275fac=function(i){return new(i||t)(o(fe))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),ds=(()=>{let t=class t{constructor(r){}};t.\u0275fac=function(i){return new(i||t)(o(os))},t.\u0275mod=j({type:t}),t.\u0275inj=V({});let e=t;return e})(),ei=(()=>{let t=class t{constructor(r,i,s){this.multiCartFacade=r,this.userIdService=i,this.winRef=s,this.subscription=new Tt,this.activeCartId$=this.userIdService.getUserId().pipe(A(1),E(()=>this.multiCartFacade.getCartIdByType(y.ACTIVE)),l(n=>n!==void 0),c(n=>n===""?$:n)),this.cartEntity$=this.activeCartId$.pipe(E(n=>this.multiCartFacade.getCartEntity(n))),this.shouldLoadCartOnCodeFlow=!0,this.checkInitLoad=void 0,this.initActiveCart(),this.detectUserChange()}initActiveCart(){let r=this.cartEntity$.pipe(c(s=>({cart:s.value,isStable:!s.loading&&s.processesCount===0,loaded:!!((s.error||s.success)&&!s.loading)})),l(({isStable:s,cart:n})=>s||pt(n))),i=r.pipe(I(this.activeCartId$,this.userIdService.getUserId()),G(([{cart:s,loaded:n,isStable:a},C,N])=>{a&&pt(s)&&!n&&!Jr(C)&&this.shouldLoadCartOnCodeFlow&&this.load(C,N)}));this.activeCart$=tr(()=>i.subscribe(),()=>r).pipe(c(({cart:s})=>s||{}),T(),Ce({bufferSize:1,refCount:!0}))}detectUserChange(){this.subscription.add(this.userIdService.getUserId().pipe(sr(),I(this.activeCartId$)).subscribe(([[r,i],s])=>{ji(i,r)&&this.loadOrMerge(s,i,r)})),this.isLoggedInWithCodeFlow()&&(this.shouldLoadCartOnCodeFlow=!1,this.subscription.add(this.userIdService.getUserId().pipe(I(this.activeCartId$)).subscribe(([r,i])=>{this.loadOrMerge(i,r,_),this.winRef?.localStorage?.removeItem(ve)})))}getActive(){return this.activeCart$}takeActive(){return this.isStable().pipe(l(r=>r),E(()=>this.getActive()),l(r=>!!r),A(1))}getActiveCartId(){return this.activeCart$.pipe(I(this.userIdService.getUserId()),c(([r,i])=>K(r,i)),T())}takeActiveCartId(){return this.isStable().pipe(l(r=>r),E(()=>this.getActiveCartId()),l(r=>!!r),A(1))}getEntries(){return this.activeCartId$.pipe(E(r=>this.multiCartFacade.getEntries(r)),T())}getLastEntry(r){return this.activeCartId$.pipe(E(i=>this.multiCartFacade.getLastEntry(i,r)),T())}getLoading(){return this.cartEntity$.pipe(c(r=>!!r.loading),T())}isStable(){return this.activeCartId$.pipe(E(r=>this.multiCartFacade.isStable(r)))}load(r,i){i===_&&r===$||this.multiCartFacade.loadCart({userId:i,cartId:r,extraData:{active:!0}})}loadOrMerge(r,i,s){r===$||s!==_?this.multiCartFacade.loadCart({userId:i,cartId:r,extraData:{active:!0}}):Ie(this.isGuestCart())?this.guestCartMerge(r):this.multiCartFacade.mergeToCurrentCart({userId:i,cartId:r,extraData:{active:!0}})}guestCartMerge(r){this.getEntries().pipe(A(1)).subscribe(i=>{this.multiCartFacade.deleteCart(r,_),this.addEntriesGuestMerge(i)})}addEntriesGuestMerge(r){let i=r.map(s=>({productCode:s.product?.code??"",quantity:s.quantity??0}));this.requireLoadedCart(!0).pipe(I(this.userIdService.getUserId())).subscribe(([s,n])=>{this.multiCartFacade.addEntries(n,K(s,n),i)})}isCartCreating(r,i){return Jr(i)&&(r.loading||r.success||r.error)}isLoggedInWithCodeFlow(){return!!this.winRef?.localStorage?.getItem(ve)}requireLoadedCart(r=!1){this.checkInitLoad=this.checkInitLoad===void 0;let i=(r?this.cartEntity$.pipe(l(()=>!Ie(this.isGuestCart()))):this.cartEntity$).pipe(l(s=>!s.loading||!!this.checkInitLoad));return this.activeCartId$.pipe(I(i),l(([s,n])=>!this.isCartCreating(n,s)),c(([,s])=>s),A(1)).pipe(I(this.userIdService.getUserId()),G(([s,n])=>{pt(s.value)&&n!==_&&!s.loading&&this.load($,n),this.checkInitLoad=!1}),E(()=>i),I(this.userIdService.getUserId()),l(([s,n])=>!!(n===_||s.success||s.error)),A(1)).pipe(G(([s,n])=>{pt(s.value)&&this.multiCartFacade.createCart({userId:n,extraData:{active:!0}})}),E(()=>i),l(s=>!!(s.success||s.error)),I(this.activeCartId$),l(([s,n])=>!this.isCartCreating(s,n)),c(([s])=>s.value),l(s=>!pt(s)),A(1))}addEntry(r,i,s){this.requireLoadedCart().pipe(I(this.userIdService.getUserId())).subscribe(([n,a])=>{this.multiCartFacade.addEntry(a,K(n,a),r,i,s)})}removeEntry(r){this.activeCartId$.pipe(I(this.userIdService.getUserId()),A(1)).subscribe(([i,s])=>{this.multiCartFacade.removeEntry(s,i,r.entryNumber)})}updateEntry(r,i,s,n=!1){this.activeCartId$.pipe(I(this.userIdService.getUserId()),A(1)).subscribe(([a,C])=>{this.multiCartFacade.updateEntry(C,a,r,i,s,n)})}getEntry(r){return this.activeCartId$.pipe(E(i=>this.multiCartFacade.getEntry(i,r)),T())}addEmail(r){this.activeCartId$.pipe(I(this.userIdService.getUserId()),A(1)).subscribe(([i,s])=>{this.multiCartFacade.assignEmail(i,s,r)})}getAssignedUser(){return this.activeCart$.pipe(c(r=>r.user))}isGuestCart(r){return r?x(this.isCartUserGuest(r)):this.activeCart$.pipe(c(i=>this.isCartUserGuest(i)),T())}isCartUserGuest(r){let i=r.user;return!!(i&&(i.name===Cr||Vi(i.uid?.split("|").slice(1).join("|"))))}addEntries(r){let i=r.map(s=>({productCode:s.product?.code??"",quantity:s.quantity??0}));this.requireLoadedCart().pipe(I(this.userIdService.getUserId())).subscribe(([s,n])=>{s&&this.multiCartFacade.addEntries(n,K(s,n),i)})}reloadActiveCart(){et([this.getActiveCartId(),this.userIdService.takeUserId()]).pipe(A(1),c(([r,i])=>{this.multiCartFacade.loadCart({cartId:r,userId:i,extraData:{active:!0}})})).subscribe()}hasPickupItems(){return this.getActive().pipe(c(r=>r.pickupItemsQuantity?r.pickupItemsQuantity>0:!1))}hasDeliveryItems(){return this.getActive().pipe(c(r=>r.deliveryItemsQuantity?r.deliveryItemsQuantity>0:!1))}getPickupEntries(){return this.getEntries().pipe(c(r=>r.filter(i=>i.deliveryPointOfService!==void 0)))}getDeliveryEntries(){return this.getEntries().pipe(c(r=>r.filter(i=>i.deliveryPointOfService===void 0)))}ngOnDestroy(){this.subscription.unsubscribe()}};t.\u0275fac=function(i){return new(i||t)(o(Ct),o(Q),o(lr))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),us=(()=>{let t=class t{constructor(r){this.routingService=r,this.NAVIGATION_SKIPS=2,this.navigationIdCount=0,this.subscription=new Tt,this.cartValidationResult$=new Ze(1),this.checkForValidationResultClear$=this.routingService.getRouterState().pipe(I(this.cartValidationResult$),G(([i,s])=>{this.navigationIdCount+this.NAVIGATION_SKIPS<=i.navigationId&&s.length&&(this.cartValidationResult$.next([]),this.navigationIdCount=i.navigationId)})),this.setInitialState()}ngOnDestroy(){this.subscription.unsubscribe()}setInitialState(){this.setNavigationIdStep(),this.subscription.add(this.checkForValidationResultClear$.subscribe())}updateValidationResultAndRoutingId(r){this.cartValidationResult$.next(r),this.setNavigationIdStep()}setNavigationIdStep(){this.routingService.getRouterState().pipe(A(1)).subscribe(r=>this.navigationIdCount=r.navigationId)}};t.\u0275fac=function(i){return new(i||t)(o(Er))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),ri=(()=>{let t=class t{constructor(r,i,s,n,a){this.cartValidationConnector=r,this.command=i,this.userIdService=s,this.activeCartFacade=n,this.cartValidationStateService=a,this.validateCartCommand=this.command.create(()=>et([this.activeCartFacade.getActiveCartId(),this.userIdService.takeUserId(),this.activeCartFacade.isStable()]).pipe(l(([C,N,Ri])=>Ri),A(1),E(([C,N])=>this.cartValidationConnector.validate(C,N))),{strategy:Dr.CancelPrevious})}validateCart(){return this.validateCartCommand.execute()}getValidationResults(){return this.cartValidationStateService.cartValidationResult$}};t.\u0275fac=function(i){return new(i||t)(o(Si),o(Mr),o(Q),o(X),o(us))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),ii=(()=>{let t=class t{constructor(r,i,s){this.store=r,this.activeCartFacade=i,this.userIdService=s}addVoucher(r,i){this.combineUserAndCartId(i).subscribe(([s,n])=>this.store.dispatch(new Lt({userId:s,cartId:n,voucherId:r})))}removeVoucher(r,i){this.combineUserAndCartId(i).subscribe(([s,n])=>this.store.dispatch(new $t({userId:s,cartId:n,voucherId:r})))}getAddVoucherResultError(){return this.store.pipe(m(Dt.getProcessErrorFactory(q)))}getAddVoucherResultSuccess(){return this.store.pipe(m(Dt.getProcessSuccessFactory(q)))}getAddVoucherResultLoading(){return this.store.pipe(m(Dt.getProcessLoadingFactory(q)))}resetAddVoucherProcessingState(){this.store.dispatch(new jt)}combineUserAndCartId(r){return r?this.userIdService.getUserId().pipe(A(1),c(i=>[i,r])):et([this.userIdService.getUserId(),this.activeCartFacade.getActiveCartId()]).pipe(A(1))}};t.\u0275fac=function(i){return new(i||t)(o(st),o(X),o(Q))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),si=(()=>{let t=class t{constructor(r,i){this.store=r,this.userIdService=i}getCart(r){return this.store.pipe(m(fi(r)))}getCarts(){return this.store.pipe(m(Hi))}getCartEntity(r){return this.store.pipe(m($i(r)))}isStable(r){return this.store.pipe(m(Pi(r)),er(i=>i?Je(0):x(void 0)),T())}generateTempCartId(){return`temp-${Math.random().toString(36).substring(2,11)}`}createCart({userId:r,oldCartId:i,toMergeCartGuid:s,extraData:n}){let a=this.generateTempCartId();return this.store.dispatch(new ft({extraData:n,userId:r,oldCartId:i,toMergeCartGuid:s,tempCartId:a})),this.getCartIdByType(n?.active?y.ACTIVE:y.NEW_CREATED).pipe(E(C=>this.getCart(C)),l(ct))}mergeToCurrentCart({userId:r,cartId:i,extraData:s}){let n=this.generateTempCartId();this.store.dispatch(new qt({userId:r,cartId:i,extraData:s,tempCartId:n}))}loadCart({cartId:r,userId:i,extraData:s}){this.store.dispatch(new R({userId:i,cartId:r,extraData:s}))}getEntries(r){return this.store.pipe(m(_e(r)))}getLastEntry(r,i){return this.store.pipe(m(_e(r)),c(s=>{let n=s.filter(a=>a.product?.code===i);return n?n[n.length-1]:void 0}))}addEntry(r,i,s,n,a){this.store.dispatch(new lt({userId:r,cartId:i,productCode:s,quantity:n,pickupStore:a}))}addEntries(r,i,s){s.forEach(n=>{this.store.dispatch(new lt({userId:r,cartId:i,productCode:n.productCode,quantity:n.quantity}))})}removeEntry(r,i,s){this.store.dispatch(new bt({userId:r,cartId:i,entryNumber:`${s}`}))}updateEntry(r,i,s,n,a,C=!1){n!==void 0&&n<=0?this.removeEntry(r,i,s):this.store.dispatch(new wt({userId:r,cartId:i,pickupStore:a,pickupToDelivery:C,entryNumber:`${s}`,quantity:n}))}getEntry(r,i){return this.store.pipe(m(Gi(r,i)))}assignEmail(r,i,s){this.store.dispatch(new Yt({userId:i,cartId:r,email:s}))}removeCart(r){this.store.dispatch(new z({cartId:r}))}deleteCart(r,i){this.store.dispatch(new Zt({userId:i,cartId:r}))}reloadCart(r,i){this.userIdService.takeUserId().subscribe(s=>this.store.dispatch(new R({userId:s,cartId:r,extraData:i})))}getCartIdByType(r){return this.store.pipe(m(Bi(r)),T())}};t.\u0275fac=function(i){return new(i||t)(o(st),o(Q))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),ni=(()=>{let t=class t{constructor(r,i,s,n){this.userProfileFacade=r,this.multiCartFacade=i,this.baseSiteService=s,this.userIdService=n}getCart(){return this.selectiveCart$||(this.selectiveCart$=et([this.getSelectiveCartId(),this.userProfileFacade.get(),this.userIdService.getUserId(),this.baseSiteService.getActive()]).pipe(T(),G(([r,i,s,n])=>{!r&&s!==_&&i?.customerId&&this.multiCartFacade.loadCart({userId:s,cartId:`selectivecart${n}${i.customerId}`})}),l(([r])=>!!r),E(([r])=>this.multiCartFacade.getCart(r)),Ce({bufferSize:1,refCount:!0}))),this.selectiveCart$}getEntries(){return this.getSelectiveCartId().pipe(E(r=>this.multiCartFacade.getEntries(r)))}isStable(){return this.getSelectiveCartId().pipe(E(r=>this.multiCartFacade.isStable(r)))}addEntry(r,i){this.getSelectiveIdWithUserId().subscribe(([s,n])=>{this.multiCartFacade.addEntry(n,s,r,i)})}removeEntry(r){this.getSelectiveIdWithUserId().subscribe(([i,s])=>{this.multiCartFacade.removeEntry(s,i,r.entryNumber)})}updateEntry(r,i){this.getSelectiveIdWithUserId().subscribe(([s,n])=>{this.multiCartFacade.updateEntry(n,s,r,i)})}getEntry(r){return this.getSelectiveCartId().pipe(E(i=>this.multiCartFacade.getEntry(i,r)))}getSelectiveCartId(){return this.multiCartFacade.getCartIdByType(y.SELECTIVE)}getSelectiveIdWithUserId(){return this.getSelectiveCartId().pipe(T(),I(this.userIdService.getUserId()),A(1))}};t.\u0275fac=function(i){return new(i||t)(o(Ae),o(Ct),o(gr),o(Q))},t.\u0275prov=u({token:t,factory:t.\u0275fac});let e=t;return e})(),hs=[ei,{provide:X,useExisting:ei},ii,{provide:Qr,useExisting:ii},si,{provide:Ct,useExisting:si},ni,{provide:Zr,useExisting:ni},ri,{provide:De,useExisting:ri}],Cs=(()=>{let t=class t extends dt{constructor(){super(...arguments),this.responseStatus=ye.BAD_REQUEST}getPriority(){return 0}hasMatch(r){return super.hasMatch(r)&&this.getErrors(r).some(xi)}handleError(r,i){this.handleCartNotFoundError(r,i),this.handleOtherCartErrors(r,i)}handleCartNotFoundError(r,i){this.getErrors(i).filter(s=>gi(s)).forEach(()=>{this.globalMessageService.add({key:"httpHandlers.cartNotFound"},Y.MSG_TYPE_ERROR)})}handleOtherCartErrors(r,i){this.getErrors(i).filter(s=>s.reason!=="notFound"||s.subjectType!=="cart").forEach(s=>{this.globalMessageService.add(s.message?s.message:{key:"httpHandlers.otherCartErrors"},Y.MSG_TYPE_ERROR)})}getErrors(r){return(r.error?.errors||[]).filter(i=>i.type!=="JaloObjectNoLongerValidError")}};t.\u0275fac=(()=>{let r;return function(s){return(r||(r=pe(t)))(s||t)}})(),t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),ps=(()=>{let t=class t extends dt{constructor(){super(...arguments),this.responseStatus=ye.BAD_REQUEST}getPriority(){return 0}hasMatch(r){return super.hasMatch(r)&&this.getErrors(r).some(Li)}handleError(r,i){this.handleVoucherExceededError(r,i),this.handleVoucherInvalidError(r,i)}handleVoucherExceededError(r,i){this.getErrors(i).filter(s=>Ui(s)).forEach(()=>{this.globalMessageService.add({key:"httpHandlers.voucherExceeded"},Y.MSG_TYPE_ERROR)})}handleVoucherInvalidError(r,i){this.getErrors(i).filter(s=>Ni(s)).forEach(()=>{this.globalMessageService.add({key:"httpHandlers.invalidCodeProvided"},Y.MSG_TYPE_ERROR)})}getErrors(r){return(r.error?.errors||[]).filter(i=>i.type!=="JaloObjectNoLongerValidError")}};t.\u0275fac=(()=>{let r;return function(s){return(r||(r=pe(t)))(s||t)}})(),t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),ls=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=j({type:t}),t.\u0275inj=V({providers:[es,yi],imports:[ar,yr,dr.forFeature(ai,Ai,{metaReducers:Ji}),ur.forFeature(qi)]});let e=t;return e})(),rn=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=j({type:t}),t.\u0275inj=V({providers:[Ii,li,Ei,Si,...hs,{provide:dt,useExisting:Cs,multi:!0},{provide:dt,useExisting:ps,multi:!0}],imports:[cs,ls,ns,ds]});let e=t;return e})(),sn=new O("CartValidationNormalizer"),nn=(()=>{let t=class t{constructor(r){this.config=r}isSelectiveCartEnabled(){return!!this.config?.cart?.selectiveCart?.enabled}isCartValidationEnabled(){return!!this.config?.cart?.validation?.enabled}};t.\u0275fac=function(i){return new(i||t)(o(zr))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();var an=(()=>{let t=class t{constructor(r){this.actionsSubject=r,this.logger=it(at)}getResults(r){return this.actionsSubject.pipe(v(St,se),l(i=>i.payload.cartId===r),c(i=>this.mapMessages(i)))}mapMessages(r){let{productCode:i}=r.payload;if(r instanceof Et){let{quantity:s,quantityAdded:n,entry:a,statusCode:C}=r.payload;if(C===B.LOW_STOCK)return{productCode:i,statusCode:C,productName:a?.product?.name,quantity:s,quantityAdded:n};if(C===B.SUCCESS||C===B.NO_STOCK)return{productCode:i,statusCode:C,productName:a?.product?.name}}else if(r instanceof vt){let{error:s}=r.payload;if(s?.details[0]?.type==="UnknownIdentifierError")return{productCode:i,statusCode:B.UNKNOWN_IDENTIFIER}}return nr()&&this.logger.warn("Unrecognized cart add entry action type while mapping messages",r),{productCode:i,statusCode:B.UNKNOWN_ERROR}}};t.\u0275fac=function(i){return new(i||t)(o(le))},t.\u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();export{Fs as a,g as b,Nr as c,jr as d,$r as e,bs as f,Yr as g,Os as h,_s as i,Se as j,Re as k,me as l,ws as m,Ct as n,Us as o,X as p,De as q,Qr as r,Zr as s,Ns as t,Di as u,Mi as v,Fi as w,Xr as x,bi as y,Ls as z,xs as A,Vs as B,$s as C,wr as D,Ae as E,vs as F,gs as G,fs as H,Is as I,ai as J,h as K,en as L,be as M,Oe as N,xi as O,pt as P,we as Q,Ue as R,ds as S,ei as T,ii as U,si as V,ni as W,rn as X,sn as Y,nn as Z,an as _};
