import{_ as V}from"./EmptyStateBlock-BaR9js3E.js";import{_ as b}from"./ButtonDefault-BIBStZbJ.js";import{_ as E}from"./TotalAmount.vue_vue_type_script_setup_true_lang-CXrtmBc-.js";import{_ as R}from"./BlockOrderPayBalance-3MeD3TJ2.js";import{_ as U}from"./ClausesKeeper-CTja-fCz.js";import{_ as F}from"./BlockBalanceAgreement-qtspRQ_B.js";import{r as k,f,g as L,H as M,D as S,c as B,b as _,a as c,C as D,F as I,h as w,t as T,d as j,o as i}from"./index-CmCGXBst.js";import{u as q}from"./contracts-P7YPBhEI.js";import{u as H}from"./services-C54cnl9l.js";import{_ as z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./bootstrap-vue-next-DwS3lKQb.js";import"./component-0WedTVCo.js";import"./global-5eUCDNCu.js";import"./IconCross-BH1MaI1J.js";import"./IconClose-B_k4TzXM.js";const G={class:"tw-px-4 md:tw-px-8 tw-mb-6"},J={class:"section-header"},K={class:"section-header__wrapper"},Q={class:"section-label"},W={__name:"DNSmanagerOrderPayId",async setup(X){let s,n;const y=q(),o=H(),C=L(),g=j(),a=k(null),u=k(!1),r=f(()=>Object.values(o.DNSmanagerOrdersList).find(t=>t.OrderID==C.params.id)),l=f(()=>y.contractsList[r.value.ContractID]),m=f(()=>o?.additionalServicesScheme?.DNSmanager?Object.keys(o.additionalServicesScheme.DNSmanager).map(t=>{const e=o.additionalServicesScheme.DNSmanager[t];return{...e,value:e?.ID,name:e?.Name,cost:e?.CostDay,month:e?.CostMonth}}).filter(t=>t?.ID==r.value?.SchemeID):[]);function N(){u.value=!0;const t=l.value.Balance>=a.value?.price-h()||m.value[0]?.cost==="0.00"&&m.value[0]?.month==="0.00",e=!t,p={DNSmanagerOrderID:r.value.ID,DaysPay:a.value?.actualDays,IsNoBasket:t,IsUseBasket:e,PayMessage:""};o.DNSOrderPay(p).then(d=>{d==="UseBasket"?g.push("/Basket"):d==="NoBasket"?g.push("/AdditionalServices?ServiceID=52000"):console.error("Ошибка оплаты заказа"),u.value=!0})}function h(){let t=0;return a.value?.discounts?.Bonuses.map(e=>{t+=Number(e.Economy)}),t}return M(()=>{o.fetchAdditionalServiceScheme("DNSmanager")}),[s,n]=S(()=>o.fetchDNSmanagerOrders()),await s,n(),[s,n]=S(()=>o.fetchAdditionalServiceScheme("DNSmanager")),await s,n(),[s,n]=S(()=>y.fetchContracts()),await s,n(),(t,e)=>{const p=F,d=b,O=U,P=R,$=E,x=b,A=V;return i(),B(I,null,[_(p),c("div",G,[r.value?(i(),B(I,{key:0},[c("div",J,[c("div",K,[e[3]||(e[3]=c("h1",{class:"section-title"},"Оплата заказа вторичного DNS",-1)),_(d,{class:"btn--wide",label:Number(l.value.Balance)>=a.value?.price?"Оплатить c баланса договора":"Добавить в корзину",disabled:a.value===null||a.value?.price===null,"is-loading":u.value,onClick:e[0]||(e[0]=v=>N())},null,8,["label","disabled","is-loading"])]),c("div",Q,T(m.value[0]?.Name),1)]),_(O),l.value?(i(),D(P,{key:0,modelValue:a.value,"onUpdate:modelValue":e[1]||(e[1]=v=>a.value=v),contract:l.value,daysRemainded:r.value?.DaysRemainded,serviceID:52e3,scheme:m.value[0],order:r.value},null,8,["modelValue","contract","daysRemainded","scheme","order"])):w("",!0),a.value?(i(),D($,{key:1,tariff:a.value},null,8,["tariff"])):w("",!0),_(x,{class:"btn--wide",label:Number(l.value.Balance)>=a.value?.price-h()?"Оплатить c баланса договора":"Добавить в корзину",disabled:a.value===null||a.value?.price===null,"is-loading":u.value,onClick:e[2]||(e[2]=v=>N())},null,8,["label","disabled","is-loading"])],64)):(i(),D(A,{key:1,label:"Заказ нельзя продлить"}))])],64)}}},_e=z(W,[["__scopeId","data-v-0efb88ea"]]);export{_e as default};
