import{a as g}from"./chunk-V5GZJE5U.js";import{a as Re}from"./chunk-F2RPD3JX.js";import{A as ve,B as ye,C as xe,R as Ee,a as G,b as J,c as K,d as N,da as $e,e as Q,f as Z,g as _,h as ee,i as te,ia as Te,j as ie,k as re,l as oe,m as se,n as ae,o as ne,p as ce,q as le,r as pe,s as de,t as ue,u as me,v as fe,w as he,x as Se,y as Le,z as ge}from"./chunk-C3Y7HGKV.js";import{a as F,b as Fe,c as Ae,g as A,h as Ie,i as I,j as De,k as D,l as C,m as Ce}from"./chunk-HNDR6KRA.js";import{a as Ue}from"./chunk-ZAGW7ZY2.js";import{b as Oe}from"./chunk-YICBAQ54.js";import{Da as M,E as p,Ea as w,Ma as P,Na as H,Xa as V,nb as X,vb as Y}from"./chunk-GYYYM227.js";import{n as L}from"./chunk-PWAOFJLF.js";import{b as d,c as z,d as u}from"./chunk-XA6AU52H.js";import{o as W}from"./chunk-DAYGRJHR.js";import{A as o,B as k,D as s,E as l,s as B}from"./chunk-VYUKN3XQ.js";import{Da as S,Ga as x,Ia as j,K as b,Na as q,P as f,Sa as c,a as i,b as r,ca as h}from"./chunk-XNQ3RS5P.js";var we={searchedFixedLocations:l(),fixedLocation:l(),counties:l(),localities:l(),favoriteOrLastUsedLocation:l(),filterInput:"",countyInput:null,localityInput:null,locationMarker:null,selectedLocation:null,showSkeletons:!1},Ge=k(we,o(G,(e,{fixedLocationSearchRequestInput:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.loading,request:t})})),o(J,(e,{searchedFixedLocations:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.success,data:t}),filterInput:""})),o(K,(e,{error:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.error,error:t})})),o(N,(e,{id:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.loading,request:t})})),o(Q,(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(_,e=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.initial,request:void 0,data:void 0})})),o(ee,(e,{filter:t})=>r(i({},e),{filterInput:t})),o(te,e=>r(i({},e),{filterInput:""})),o(ie,(e,{countryCode:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.loading,request:t})})),o(re,(e,{counties:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.success,data:t})})),o(oe,(e,{error:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.error,error:t})})),o(se,(e,{countyId:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.loading,request:t})})),o(ae,(e,{localities:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.success,data:t})})),o(ne,(e,{error:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.error,error:t})})),o(ce,e=>r(i({},e),{localities:r(i({},e.localities),{status:s.initial,data:void 0,request:void 0})})),o(le,(e,{locationMarker:t})=>r(i({},e),{locationMarker:t})),o(pe,de,(e,{location:t})=>r(i({},e),{selectedLocation:t})),o(ue,(e,{showSkeletons:t})=>r(i({},e),{showSkeletons:t})),o(me,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:t})})),o(Le,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.success,data:t})})),o(fe,(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(he,ge,(e,{error:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.error,error:t})})),o(Se,e=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:null})})),o(ve,(e,{countyInput:t})=>r(i({},e),{countyInput:t})),o(ye,(e,{localityInput:t})=>r(i({},e),{localityInput:t})),o(xe,e=>r(i({},e),{countyInput:null,localityInput:null})),o(X,e=>i({},e)));var Pe=e=>e.data&&!e.errors?Ae():e.errors?Fe({errors:e.errors}):L({failedAction:F.type}),He=e=>e.data&&!e.errors?I():e.errors?Ie({errors:e.errors}):L({failedAction:A.type}),Ve=e=>e.data&&!e.errors?C():e.errors?Ce({errors:e.errors}):L({failedAction:D.type}),At=(()=>{let t=class t{constructor(O,v,be,je,qe,Be){this.actions$=O,this.cartApolloClient=v,this.store=be,this.storeSelector=je,this.cartDeliveryAddressService=qe,this.portInDeliveryAddressService=Be,this.setBilling$=d(()=>this.actions$.pipe(u(F),S(a=>this.cartApolloClient.mutate({mutation:a.billing!==null?w:M,variables:{billing:a.billing}}).pipe(f(Pe)).pipe(h(g(a)))))),this.setShipping$=d(()=>this.actions$.pipe(u(A),j(this.store.select(Ee),this.storeSelector.getWithSelector(Y(V.DELIVERY)),this.cartDeliveryAddressService.fixedLocationContactPerson$,this.store.select($e)),S(([a,E,n,U,ke])=>{var $,T,R;let y=null,m=null;if(n&&(n.address&&(y=Ue.toAddressResource(n)),n.party&&(m={name:($=n.party)==null?void 0:$.name,phone:(T=n.party)==null?void 0:T.phone,email:(R=n.party)==null?void 0:R.email})),y===null&&a.shippingTypeSelection===p.Customer||E===null&&a.shippingTypeSelection===p.FixedLocation)return b(De());a.shippingTypeSelection===p.FixedLocation&&(m=Object.keys(U).length?U:null);let Me={address:y,contactPerson:m,shippingType:{fixedLocation:E,selection:a.shippingTypeSelection},shippingAddressSourceSubResource:ke};return a.shippingTypeSelection===p.FixedLocation&&!m&&this.cartDeliveryAddressService.setEditMode(!1),a.shippingTypeSelection===p.Customer&&this.cartDeliveryAddressService.setEditMode(!1),this.cartApolloClient.mutate({mutation:H,variables:{shipping:Me}}).pipe(f(He),h(g(a)))}))),this.deleteShipping$=d(()=>this.actions$.pipe(u(D),S(a=>this.cartApolloClient.mutate({mutation:P}).pipe(f(Ve),h(g(a)))))),this.setBillingOnSetShippingSuccess$=d(()=>this.actions$.pipe(u(I),x(()=>{this.cartDeliveryAddressService.setDeliveryAddressSuccess$.next("emit")})),{dispatch:!1}),this.deleteShippingSuccess$=d(()=>this.actions$.pipe(u(C),x(()=>{this.portInDeliveryAddressService.setShowAddressToggle(!0)})),{dispatch:!1})}};t.\u0275fac=function(v){return new(v||t)(c(z),c(Oe),c(B),c(W),c(Te),c(Re))},t.\u0275prov=q({token:t,factory:t.\u0275fac});let e=t;return e})();export{Ge as a,He as b,At as c};