import{_ as y}from"./BlueButton.vue_vue_type_script_setup_true_lang-CY8chwQm.js";import{_ as k}from"./InputSelect.vue_vue_type_script_setup_true_lang-DDGr1dhD.js";import{_ as x}from"./MessageInfo.vue_vue_type_script_setup_true_lang-C44lULuw.js";import{C as N,r as f,A as B,g as S,l as E,D as M,o as w,c as b,a as s,m as O,i as j,t as c,b as h,w as P,f as U}from"./index-Bb2UEb_P.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./IconChevronDown-NfcUpI8U.js";import"./index-Dax_IkAt.js";import"./HtmlContent-DrkJBX3e.js";const $={class:"md:tw-w-[600px]"},L={class:"tw-grid tw-grid-cols-3 tw-items-center tw-gap-4 tw-mt-4"},G={class:"tw-col-span-2 tw-font-bold"},H={class:"tw-grid tw-grid-cols-3 tw-items-center tw-gap-4 tw-mt-4"},A={class:"tw-col-span-2"},K={class:"tw-flex tw-justify-end tw-mt-4"},X={__name:"ModalWindowVPSOrderSchemeChange",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(n,{emit:g}){const a=n,_=g,r=N(),l=f(!1),o=f(null),D=B("emitter"),I=S(()=>Object.values(r.vpsSchemes).filter(e=>e.ID!==a.data.vpsScheme.ID&&e.IsSchemeChangeable&&e.ServersGroupID==a.data.serverGroupId).sort((e,t)=>e.SortID-t.SortID).map(e=>({name:e.Name+i(e.SchemeParams)+" / "+e.CostMonth+" ₽ в месяц",value:e.ID}))),d=S(()=>{if(!o.value)return"";const e=r.vpsSchemes[o.value];return e?e.SortID<a.data.vpsScheme.SortID?e.MessageDown:e.MessageUp:null});function i(e){const t=Object.values(e).find(m=>m.InternalName==="HDD");return t?" / "+t.Value+" "+t.Unit:""}async function u(){l.value=!0;const{result:e}=await r.VPSOrderSchemeChange({NewSchemeID:o.value,VPSOrderID:a.data.vpsId});e==="SUCCESS"&&(a.data?.emitEvent&&D.emit(a.data?.emitEvent),_("modalClose")),l.value=!1}const p=e=>{e.key==="Enter"&&u()};return E(()=>{document.addEventListener("keyup",p)}),M(()=>{document.removeEventListener("keyup",p)}),(e,t)=>{const m=x,C=k,V=y;return w(),b("div",$,[t[5]||(t[5]=s("div",{class:"tw-text-2xl"},"Смена тарифного плана",-1)),d.value?(w(),O(m,{key:0,class:"tw-mt-4 tw-space-y-4",content:d.value},null,8,["content"])):j("",!0),s("div",L,[t[2]||(t[2]=s("div",null,"Текущий тарифный план",-1)),s("div",G,c(n.data.vpsScheme.Name)+c(i(n.data.vpsScheme.SchemeParams))+" / "+c(n.data.vpsScheme.CostMonth+" ₽ в месяц"),1)]),s("div",H,[t[3]||(t[3]=s("div",null,"Новый тарифный план",-1)),s("div",A,[h(C,{modelValue:o.value,"onUpdate:modelValue":t[0]||(t[0]=v=>o.value=v),options:I.value,"param-to-match":"value",placeholder:"Выберите тарифный план"},null,8,["modelValue","options"])])]),s("div",K,[h(V,{loading:l.value,onClick:t[1]||(t[1]=v=>u())},{default:P(()=>t[4]||(t[4]=[U(" Сменить ",-1)])),_:1,__:[4]},8,["loading"])])])}}};export{X as default};
