import{F as C,ag as x,r as L,aR as P,P as d,Q as T,_ as c,e,R as o,T as b,W as I,a0 as r,a1 as m,a2 as p}from"./vendor-DpspMRYS.js";import"./index-BN2vBFYR.js";import{a as N}from"./index-CUGelin5.js";import{u as W}from"./useLoyaltyBalance-i3XxeJNi.js";const $={key:0},M={class:"md:py-3 md:text-left"},E=C({__name:"payment-processing-loyalty",props:{order:{}},emits:["success","fail"],setup(f,{emit:_}){const n=_,s=f,{t:B}=x(),l=L(!1),{fetchLoyaltyBalance:k,loading:g,currentBalance:i,resultBalance:a}=W();async function h(){l.value=!0;const{isSuccess:t,errorMessage:y=""}=await N({orderId:s.order.id,paymentId:s.order.inPayments[0].id});l.value=!1,t?n("success"):n("fail",y)}P(async()=>{await k(s.order.id)});async function v(){await h()}function V(){n("fail",B("loyalty.payment.loyalty.errors.insufficient_points",{currentBalance:i.value}))}return(t,y)=>{const u=d("VcButton"),w=d("VcLoaderWithText");return e(g)?(o(),c(w,{key:1})):(o(),T("div",$,[b("p",M,r(t.$t("loyalty.payment.loyalty.text",{currentBalance:e(i)})),1),e(a)!==null&&e(a)!==void 0&&e(a)>=0?(o(),c(u,{key:0,loading:l.value,onClick:v},{default:m(()=>[p(r(t.$t("loyalty.payment.loyalty.pay_now_button")),1)]),_:1},8,["loading"])):e(a)!==null&&e(a)!==void 0&&e(a)<0?(o(),c(u,{key:1,onClick:V},{default:m(()=>[p(r(t.$t("loyalty.payment.loyalty.pay_now_button")),1)]),_:1})):I("",!0)]))}}});export{E as default};
//# sourceMappingURL=payment-processing-loyalty-Xf4EC8WS.js.map
