import{_ as A}from"./EmptyStateBlock-D6U_EDq6.js";import{_ as E}from"./ButtonDefault-CghIUDY0.js";import{_ as L}from"./ClausesKeeper-DVJgfLR3.js";import{_ as j}from"./BlockBalanceAgreement-2iQbaweR.js";import{ao as M,r as v,f,g as F,H as K,s as R,D as U,c as i,b as d,a as e,C as z,t as w,h as H,F as h,i as O,v as T,x as q,d as G,o as r,n as J}from"./index-CipWZKo_.js";import{c as Q}from"./component-DWBAga-C.js";import{u as W}from"./postings-dJpYnOCG.js";import{u as X}from"./contracts-CILh9uSu.js";import{u as Y}from"./invoices-BQ0DRF22.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./IconClose-ChC2G6HM.js";const tt={class:"tw-px-4 md:tw-px-8"},et={class:"tw-text-sm tw-text-gray-500 tw-mt-2"},st={key:0},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 I=X(),b=M(),B=Y(),N=W(),P=q("emitter"),k=F(),$=G(),c=v(null),m=v(null),p=v(!1),l=f(()=>I.contractsList?.[k.params.id]),V=f(()=>b.data),g=f(()=>{const s=V.value;if(s?.PaymentSystems&&l.value.PaymentSystems){const t=new Set(l.value.PaymentSystems);return Object.keys(s.PaymentSystems).filter(n=>t.has(n)).map(n=>{const a=s.PaymentSystems[n];return a?.IsActive==1?a.Collations:null}).filter(n=>n!==null).flat().slice().sort((n,a)=>{const o=parseInt(n.SortID,10),_=parseInt(a.SortID,10);return isNaN(o)?1:isNaN(_)?-1:o-_})}else return null}),S=s=>{s.key==="Enter"&&s.ctrlKey&&D()};K(()=>{document.addEventListener("keyup",S)}),R(()=>{document.removeEventListener("keyup",S)});async function D(){if(m.value>0){p.value=!0;const s=await B.InvoiceMake({ContractID:l.value?.ID,PaymentSystemID:c.value?.type,Summ:m.value});if(p.value=!1,s.status==="success"&&s.data&&s.data.InvoiceID){const t=s.data.InvoiceID;N.InvoiceDocument({InvoiceID:t}).then(u=>{P.emit("open-modal",{component:"InvoiceDocument",data:{html:u,ID:t}})})}else $.push(`/ProfileMake?Contract=${k.params.id}&TemplateID=${c.value?.type}`)}}return[y,x]=U(()=>I.fetchContracts()),await y,x(),(s,t)=>{const u=j,C=L,n=E,a=A;return r(),i(h,null,[d(u),e("div",tt,[e("div",null,[t[2]||(t[2]=e("h1",{class:"section-title"},"Пополнить баланс",-1)),e("div",et,"Договор # "+w(s.$route.params.id)+" / "+w(l.value.Customer),1)]),d(C),l.value?(r(),i("div",st,[e("div",ot,[t[3]||(t[3]=e("div",{class:"tw-text-xl sm:tw-text-2xl"},"Платежные системы",-1)),g.value?(r(),i("div",nt,[(r(!0),i(h,null,O(g.value,o=>(r(),i("div",{key:o?.ID,class:J(["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}},[e("div",rt,[e("img",{src:o.Image},null,8,lt)]),e("div",it,w(o.Description),1)],10,at))),128))])):H("",!0)]),e("div",ct,[t[5]||(t[5]=e("div",{class:"tw-text-xl sm:tw-text-2xl"},"Сумма пополнения",-1)),e("div",mt,[t[4]||(t[4]=e("div",{class:"tw-text-sm"},"Пополнить на сумму",-1)),e("div",ut,[e("div",dt,[d(T(Q),{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"])])])):(r(),z(a,{key:1,label:"Договор не найден"}))])],64)}}},ht=Z(pt,[["__scopeId","data-v-d9786944"]]);export{ht as default};
