import{_ as N}from"./EmptyStateBlock-Dt7jmbAi.js";import{_ as $}from"./TotalAmount.vue_vue_type_script_setup_true_lang-BCu2SNOJ.js";import{_ as V}from"./BlockOrderPay-BP1936HA.js";import{_ as A}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as L}from"./ButtonDefault-CzWpVlv6.js";import{_ as U}from"./BlockBalanceAgreement-396E9Da8.js";import{r as C,g as v,x as h,o as i,c as D,b as f,a as c,F as g,t as j,m as k,i as E,B as R,j as T,e as F}from"./index-Bb2UEb_P.js";import{u as M}from"./index-Dax_IkAt.js";import{u as z}from"./services-DEZoSah0.js";import{_ as K}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./common-U_VzDrmL.js";import"./bootstrap-vue-next-C0pyDr3k.js";import"./component-C-Q4t0gB.js";import"./global-BK91p1BE.js";import"./IconHelp-wlsb2dRe.js";import"./IconCross-Cfk4fnHT.js";import"./HtmlContent-DrkJBX3e.js";import"./IconCloseCircle-ctElXVvc.js";import"./clauses-Bhz_DuFa.js";const q={class:"tw-px-4 md:tw-px-8"},G={class:"section-header"},H={class:"section-header__wrapper"},J={class:"section-label"},Q={class:"tw-my-6"},W={__name:"ExtraIPOrderPayId",async setup(X){let r,n;const P=M(),s=z(),b=T(),B=F(),t=C(null),u=C(!1),o=v(()=>Object.values(s.ExtraIPOrdersList).find(a=>a.OrderID==b.params.id)),d=v(()=>P.contractsList[o.value.ContractID]),S=v(()=>d.value?.Balance>=t.value?.CostPay?"Оплатить с баланса договора":"Добавить в корзину"),m=v(()=>s?.additionalServicesScheme?.ExtraIP?Object.keys(s.additionalServicesScheme.ExtraIP).map(a=>{const e=s.additionalServicesScheme.ExtraIP[a];return{...e,value:e?.ID,name:e?.Name,cost:e?.CostDay,month:e?.CostMonth}}).filter(a=>a?.ID==o.value?.SchemeID):[]);async function x(){u.value=!0;const a=d.value?.Balance>=t.value?.CostPay,e=m.value[0]?.cost==="0.00"&&m.value[0]?.month==="0.00",_=a||e,p=!_,y={ExtraIPOrderID:o.value.ID,DaysPay:t.value?.actualDays,IsNoBasket:_,IsUseBasket:p,PayMessage:""};try{const l=await s.ExtraIPOrderPay(y);l==="UseBasket"?B.push("/Basket"):l==="NoBasket"?B.push("/AdditionalServices"):console.error("Ошибка оплаты заказа")}catch(l){console.error("ExtraIPOrderPay error:",l)}u.value=!1}return[r,n]=h(()=>s.fetchExtraIPOrders()),await r,n(),[r,n]=h(()=>s.fetchAdditionalServiceScheme("ExtraIP")),await r,n(),[r,n]=h(()=>P.fetchContracts()),await r,n(),(a,e)=>{const _=U,p=L,y=A,l=V,w=$,O=N;return i(),D(g,null,[f(_,{"contract-id":o.value?.ContractID},null,8,["contract-id"]),c("div",q,[o.value?(i(),D(g,{key:0},[c("div",G,[c("div",H,[e[3]||(e[3]=c("h1",{class:"section-title"},"Оплата заказа IP адреса",-1)),f(p,{class:"btn--wide",label:S.value,disabled:t.value===null||t.value?.price===null,"is-loading":u.value,onClick:e[0]||(e[0]=I=>x())},null,8,["label","disabled","is-loading"])]),c("div",J,j(m.value[0]?.Name),1)]),f(y),d.value?(i(),k(l,{key:0,modelValue:t.value,"onUpdate:modelValue":e[1]||(e[1]=I=>t.value=I),contract:d.value,"days-remainded":o.value?.DaysRemainded,"service-id":5e4,scheme:m.value[0],order:o.value},null,8,["modelValue","contract","days-remainded","scheme","order"])):E("",!0),c("div",Q,[t.value?(i(),k(w,{key:0,tariff:t.value},null,8,["tariff"])):E("",!0),f(p,{class:"btn--wide",label:S.value,disabled:t.value===null||t.value?.price===null,"is-loading":u.value,onClick:e[2]||(e[2]=I=>x())},null,8,["label","disabled","is-loading"])])],64)):(i(),k(O,{key:1,label:`Заказ #${R(b).params.id} не найден`},null,8,["label"]))])],64)}}},ye=K(W,[["__scopeId","data-v-c9b74041"]]);export{ye as default};
