import{_ as E}from"./EmptyStateBlock-Dt7jmbAi.js";import{_ as L}from"./ButtonDefault-CzWpVlv6.js";import{_ as j}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as M}from"./BlockBalanceAgreement-396E9Da8.js";import{am as F,au as K,r as v,g as w,l as R,D as U,x as z,o as a,c as i,b as d,a as s,t as f,i as b,F as h,h as O,B as T,m as q,A as G,e as H,j as J,n as Q}from"./index-Bb2UEb_P.js";import{c as W}from"./component-C-Q4t0gB.js";import{u as X}from"./index-Dax_IkAt.js";import{u as Y}from"./invoices-F361lW0u.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./HtmlContent-DrkJBX3e.js";import"./IconCloseCircle-ctElXVvc.js";import"./clauses-Bhz_DuFa.js";import"./common-U_VzDrmL.js";const tt={class:"tw-px-4 md:tw-px-8"},et={key:0,class:"tw-text-sm tw-text-gray-500 tw-mt-2"},st={key:1},ot={class:"tw-mt-8"},nt={key:0,class:"tw-flex tw-flex-wrap tw-gap-4 tw-mt-2"},at=["onClick"],rt={class:"tw-flex tw-justify-center"},lt=["src"],it={class:"tw-text-sm tw-text-center tw-mt-4"},ct={class:"tw-mt-8 tw-mb-6"},mt={class:"tw-flex tw-gap-2 tw-items-center tw-mt-2"},ut={class:"list-form_col list-form_col--xl"},dt={class:"search-field form-field"},pt={__name:"Balance",async setup(_t){let y,x;const k=X(),B=F(),N=Y(),P=K(),$=G("emitter"),I=J(),V=H(),c=v(null),m=v(null),p=v(!1),r=w(()=>k.contractsList?.[I.params.id]),A=w(()=>B.data),g=w(()=>{const e=A.value;if(e?.PaymentSystems&&r.value.PaymentSystems){const t=new Set(r.value.PaymentSystems);return Object.keys(e.PaymentSystems).filter(n=>t.has(n)).map(n=>{const l=e.PaymentSystems[n];return l?.IsActive==1?l.Collations:null}).filter(n=>n!==null).flat().slice().sort((n,l)=>{const o=Number.parseInt(n.SortID,10),_=Number.parseInt(l.SortID,10);return isNaN(o)?1:isNaN(_)?-1:o-_})}else return null}),S=e=>{e.key==="Enter"&&e.ctrlKey&&D()};R(()=>{document.addEventListener("keyup",S)}),U(()=>{document.removeEventListener("keyup",S)});async function D(){if(m.value>0){p.value=!0;const e=await N.InvoiceMake({ContractID:r.value?.ID,PaymentSystemID:c.value?.type,Summ:m.value});if(p.value=!1,e.status==="success"&&e.data&&e.data.InvoiceID){const t=e.data.InvoiceID;P.InvoiceDocument({InvoiceID:t}).then(u=>{$.emit("open-modal",{component:"InvoiceDocument",data:{html:u,ID:t}})})}else V.push(`/ProfileMake?Contract=${I.params.id}&TemplateID=${c.value?.type}`)}}return[y,x]=z(()=>k.fetchContracts()),await y,x(),(e,t)=>{const u=M,C=j,n=L,l=E;return a(),i(h,null,[d(u),s("div",tt,[t[5]||(t[5]=s("h1",{class:"tw-text-xl sm:tw-text-4xl"},"Пополнить баланс",-1)),r.value?(a(),i("div",et," Договор # "+f(e.$route.params.id)+" / "+f(r.value.Customer),1)):b("",!0),d(C),r.value?(a(),i("div",st,[s("div",ot,[t[2]||(t[2]=s("div",{class:"tw-text-xl sm:tw-text-2xl"},"Платежные системы",-1)),g.value?(a(),i("div",nt,[(a(!0),i(h,null,O(g.value,o=>(a(),i("div",{key:o?.ID,class:Q(["tw-w-44 tw-cursor-pointer tw-p-2 tw-rounded tw-border tw-border-gray-200 hover:tw-border-sky-400 tw-text-gray-500 hover:tw-text-sky-400 hover:tw-bg-sky-100",{"tw-bg-sky-100 tw-border-sky-400 tw-text-sky-400":c.value?.id===o.ID}]),onClick:_=>c.value={id:o.ID,type:o.Source}},[s("div",rt,[s("img",{src:o.Image},null,8,lt)]),s("div",it,f(o.Description),1)],10,at))),128))])):b("",!0)]),s("div",ct,[t[4]||(t[4]=s("div",{class:"tw-text-xl sm:tw-text-2xl"},"Сумма пополнения",-1)),s("div",mt,[t[3]||(t[3]=s("div",{class:"tw-text-sm"},"Пополнить на сумму",-1)),s("div",ut,[s("div",dt,[d(T(W),{type:"text",mask:Number,placeholder:"100 ₽",modelValue:m.value,"onUpdate:modelValue":t[0]||(t[0]=o=>m.value=o)},null,8,["modelValue"])])])]),d(n,{"is-loading":p.value,label:"Пополнить баланс",onClick:t[1]||(t[1]=o=>D()),class:"tw-mt-8"},null,8,["is-loading"])])])):(a(),q(l,{key:2,label:"Договор не найден"}))])],64)}}},Bt=Z(pt,[["__scopeId","data-v-bcbc07bc"]]);export{Bt as default};
