import{a as g}from"./chunk-GTY62QVP.js";import{a as Ce}from"./chunk-23THS323.js";import{A as Se,B as Le,C as ge,R as De,a as N,b as V,c as W,d as X,e as Y,f as z,g as J,h as Q,ha as Ee,i as Z,ia as Ue,j as _,ja as Te,k as ee,l as te,m as ie,n as re,o as oe,p as se,q as ae,r as ne,s as ce,t as le,u as pe,v as de,w as ue,x as me,y as fe,z as he}from"./chunk-ZL5YJ4TG.js";import{m as x,n as ve,o as ye,q as A,r as Fe,s as I,t as xe,u as D,v as C,w as Ae}from"./chunk-EEUSJGKN.js";import{a as Oe}from"./chunk-4SEMTXPG.js";import{b as Ie}from"./chunk-YS6HBWHP.js";import{Cb as w,Ub as G,ac as H,ib as j,jb as q,ka as p,n as L,rb as k,sb as M}from"./chunk-OD6CMNJH.js";import{b as d,c as K,d as u}from"./chunk-O7JFACMN.js";import{n as P}from"./chunk-O2KDIBGD.js";import{A as o,B as b,D as s,E as l,s as R}from"./chunk-QUA65JBC.js";import{Ca as S,Fa as F,Ha as $,J as T,Ma as B,O as f,Ra as c,a as i,b as r,ba as h}from"./chunk-NRAZ4AKM.js";var ke={searchedFixedLocations:l(),fixedLocation:l(),counties:l(),localities:l(),favoriteOrLastUsedLocation:l(),filterInput:"",countyInput:null,localityInput:null,locationMarker:null,selectedLocation:null,showSkeletons:!1},Ve=b(ke,o(N,(e,{fixedLocationSearchRequestInput:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.loading,request:t})})),o(V,(e,{searchedFixedLocations:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.success,data:t}),filterInput:""})),o(W,(e,{error:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.error,error:t})})),o(X,(e,{id:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.loading,request:t})})),o(Y,(e,{fixedLocation:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.success,data:t})})),o(z,(e,{error:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.error,error:t})})),o(J,e=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.initial,request:void 0,data:void 0})})),o(Q,(e,{filter:t})=>r(i({},e),{filterInput:t})),o(Z,e=>r(i({},e),{filterInput:""})),o(_,(e,{countryCode:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.loading,request:t})})),o(ee,(e,{counties:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.success,data:t})})),o(te,(e,{error:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.error,error:t})})),o(ie,(e,{countyId:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.loading,request:t})})),o(re,(e,{localities:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.success,data:t})})),o(oe,(e,{error:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.error,error:t})})),o(se,e=>r(i({},e),{localities:r(i({},e.localities),{status:s.initial,data:void 0,request:void 0})})),o(ae,(e,{locationMarker:t})=>r(i({},e),{locationMarker:t})),o(ne,ce,(e,{location:t})=>r(i({},e),{selectedLocation:t})),o(le,(e,{showSkeletons:t})=>r(i({},e),{showSkeletons:t})),o(pe,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:t})})),o(fe,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.success,data:t})})),o(de,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.success,data:r(i(i({},e.favoriteOrLastUsedLocation.data),t),{isFavorite:!0})})})),o(ue,he,(e,{error:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.error,error:t})})),o(me,e=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:null})})),o(Se,(e,{countyInput:t})=>r(i({},e),{countyInput:t})),o(Le,(e,{localityInput:t})=>r(i({},e),{localityInput:t})),o(ge,e=>r(i({},e),{countyInput:null,localityInput:null})),o(G,e=>i({},e)));var Me=e=>e.data&&!e.errors?ye():e.errors?ve({errors:e.errors}):L({failedAction:x.type}),we=e=>e.data&&!e.errors?I():e.errors?Fe({errors:e.errors}):L({failedAction:A.type}),Pe=e=>e.data&&!e.errors?C():e.errors?Ae({errors:e.errors}):L({failedAction:D.type}),yt=(()=>{let t=class t{constructor(O,v,$e,Be,Re,be){this.actions$=O,this.cartApolloClient=v,this.store=$e,this.storeSelector=Be,this.cartDeliveryAddressService=Re,this.portInDeliveryAddressService=be,this.setBilling$=d(()=>this.actions$.pipe(u(x),S(a=>this.cartApolloClient.mutate({mutation:a.billing!==null?q:j,variables:{billing:a.billing}}).pipe(f(Me)).pipe(h(g(a)))))),this.setShipping$=d(()=>this.actions$.pipe(u(A),$(this.store.select(De),this.storeSelector.getWithSelector(H(w.DELIVERY)),this.cartDeliveryAddressService.fixedLocationContactPerson$,this.store.select(Ee)),S(([a,E,n,U,je])=>{let y=null,m=null;if(n&&(n.address&&(y=Oe.toAddressResource(n)),n.party&&(m={name:n.party?.name,phone:n.party?.phone,email:n.party?.email})),y===null&&a.shippingTypeSelection===p.Customer||E===null&&a.shippingTypeSelection===p.FixedLocation)return T(xe());a.shippingTypeSelection===p.FixedLocation&&(m=Object.keys(U).length?U:null);let qe={address:y,contactPerson:m,shippingType:{fixedLocation:E,selection:a.shippingTypeSelection},isKeepBillingDataToggled:je===Te.BILLING};return a.shippingTypeSelection===p.FixedLocation&&!m&&this.cartDeliveryAddressService.setEditMode(!1),a.shippingTypeSelection===p.Customer&&this.cartDeliveryAddressService.setEditMode(!1),this.cartApolloClient.mutate({mutation:M,variables:{shipping:qe}}).pipe(f(we),h(g(a)))}))),this.deleteShipping$=d(()=>this.actions$.pipe(u(D),S(a=>this.cartApolloClient.mutate({mutation:k}).pipe(f(Pe),h(g(a)))))),this.setBillingOnSetShippingSuccess$=d(()=>this.actions$.pipe(u(I),F(()=>{this.cartDeliveryAddressService.setDeliveryAddressSuccess$.next("emit")})),{dispatch:!1}),this.deleteShippingSuccess$=d(()=>this.actions$.pipe(u(C),F(()=>{this.portInDeliveryAddressService.setShowAddressToggle(!0)})),{dispatch:!1})}};t.\u0275fac=function(v){return new(v||t)(c(K),c(Ie),c(R),c(P),c(Ue),c(Ce))},t.\u0275prov=B({token:t,factory:t.\u0275fac});let e=t;return e})();export{Ve as a,we as b,yt as c};