import{Af as j,B as m,Bf as x,Cf as I,Df as L,E as s,Ef as $,Fd as w,Pb as n,Qb as O,Sb as h,a as y,ac as k,b as S,bd as p,h as o,pb as g,y as d,yf as b,zf as _}from"./chunk-5ZN6IIP7.js";var P=(()=>{let r=class r{constructor(t){this.http=t,this.skeletonLoader=!1}getOrders(t){return this.http.get(`${p.URL}/order`,{params:t})}viewOrder(t){return this.http.get(`${p.URL}/order/${t}`)}checkout(t){return this.http.post(`${p.URL}/checkout`,t)}placeOrder(t){return this.http.post(`${p.URL}/order`,t)}rePayment(t){return this.http.post(`${p.URL}/rePayment`,t)}orderTracking(t){return this.http.get(`${p.URL}/trackOrder`,{params:t})}};r.\u0275fac=function(c){return new(c||r)(s(g))},r.\u0275prov=m({token:r,factory:r.\u0275fac,providedIn:"root"});let i=r;return i})();var l,a=(l=class{constructor(r,e,t){this.notificationService=r,this.router=e,this.orderService=t}static order(r){return r.order}static selectedOrder(r){return r.selectedOrder}static checkout(r){return r.checkout}getOrders(r,e){return this.orderService.getOrders(e?.payload).pipe(d({next:t=>{r.patchState({order:{data:t.data,total:t?.total?t?.total:t.data?.length}})},error:t=>{throw new Error(t?.error?.message)}}))}viewOrder(r,{id:e}){return this.orderService.skeletonLoader=!0,this.orderService.viewOrder(e).pipe(d({next:t=>{let c=r.getState();r.patchState(S(y({},c),{selectedOrder:t}))},error:t=>{throw new Error(t?.error?.message)},complete:()=>{this.orderService.skeletonLoader=!1}}))}checkout(r,e){return this.orderService.checkout(e?.payload).pipe(d({next:t=>{let c=r.getState();r.patchState(S(y({},c),{checkout:t}))},error:t=>{throw new Error(t?.error?.message)}}))}placeOrder(r,e){return this.orderService.placeOrder(e?.payload).pipe(d({next:t=>{(e.payload.payment_method=="cod"||e.payload.payment_method=="bank_transfer")&&!t.is_guest?this.router.navigateByUrl(`/account/order/details/${t.order_number}`):(e.payload.payment_method=="cod"||e.payload.payment_method=="bank_transfer")&&t.is_guest?this.router.navigate(["order/details"],{queryParams:{order_number:t.order_number,email_or_phone:e?.payload.email}}):window.open(t.url,"_self")},error:t=>{throw new Error(t?.error?.message)}}))}rePayment(r,e){return this.orderService.rePayment(e.payload).pipe(d({next:t=>{(e.payload.payment_method=="cod"||e.payload.payment_method=="bank_transfer")&&!t.is_guest?this.router.navigateByUrl(`/account/order/details/${t.order_number}`):(e.payload.payment_method=="cod"||e.payload.payment_method=="bank_transfer")&&t.is_guest?this.router.navigate(["order/details"],{queryParams:{order_number:t.order_number,email_or_phone:t.email}}):window.open(t.url,"_self")},error:t=>{throw new Error(t?.error?.message)}}))}orderTracking(r,e){return this.notificationService.notification=!1,this.orderService.orderTracking(e.payload).pipe(d({next:t=>{let c=r.getState();r.patchState(S(y({},c),{selectedOrder:t}))},error:t=>{throw new Error(t?.error?.message)}}))}clear(r){let e=r.getState();r.patchState(S(y({},e),{checkout:null}))}},l.\u0275fac=function(e){return new(e||l)(s(w),s(k),s(P))},l.\u0275prov=m({token:l,factory:l.\u0275fac}),l);o([n(b)],a.prototype,"getOrders",null);o([n(_)],a.prototype,"viewOrder",null);o([n(j)],a.prototype,"checkout",null);o([n(x)],a.prototype,"placeOrder",null);o([n(L)],a.prototype,"rePayment",null);o([n($)],a.prototype,"orderTracking",null);o([n(I)],a.prototype,"clear",null);o([h()],a,"order",null);o([h()],a,"selectedOrder",null);o([h()],a,"checkout",null);a=o([O({name:"order",defaults:{order:{data:[],total:0},selectedOrder:null,checkout:null}})],a);var R=(()=>{let r=class r{constructor(t){this.payload=t}};r.type="[Order Status] Get";let i=r;return i})();var U=(()=>{let r=class r{constructor(t){this.http=t}getOrderStatus(t){return this.http.get(`${p.URL}/orderStatus`,{params:t})}};r.\u0275fac=function(c){return new(c||r)(s(g))},r.\u0275prov=m({token:r,factory:r.\u0275fac,providedIn:"root"});let i=r;return i})();var u,f=(u=class{constructor(r){this.orderStatusService=r}static orderStatus(r){return r.orderStatus}static orderStatuses(r){return r.orderStatus.data.map(e=>({label:e?.name,value:e?.id}))}static selectedOrderStatus(r){return r.selectedOrderStatus}getOrderStatus(r,e){return this.orderStatusService.getOrderStatus(e.payload).pipe(d({next:t=>{r.patchState({orderStatus:{data:t.data,total:t?.total?t?.total:t.data?.length}})},error:t=>{throw new Error(t?.error?.message)}}))}},u.\u0275fac=function(e){return new(e||u)(s(U))},u.\u0275prov=m({token:u,factory:u.\u0275fac}),u);o([n(R)],f.prototype,"getOrderStatus",null);o([h()],f,"orderStatus",null);o([h()],f,"orderStatuses",null);o([h()],f,"selectedOrderStatus",null);f=o([O({name:"orderStatus",defaults:{orderStatus:{data:[],total:0},selectedOrderStatus:null}})],f);export{a,R as b,f as c};
