import{ao as b,x as M,r as w,d as N,f as B,c as l,o as d,a as m,h as _,F as S,i as j,n as A,t as C}from"./index-CmCGXBst.js";import{u as $}from"./invoices-DSyOyjgA.js";import{u as F}from"./postings-CAwWnBGE.js";import{_ as O}from"./_plugin-vue_export-helper-DlAUqK2U.js";const V={key:0,class:"tw-grid tw-grid-cols-2 md:tw-grid-cols-3 tw-gap-4 tw-mt-4"},W=["onClick"],z={class:"tw-flex tw-justify-center"},E=["src"],J={class:"tw-text-xs tw-text-center tw-mt-2 tw-text-gray-500"},L={class:"modal__error"},R={__name:"ModalWindowInvoiceMakeBasket",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(g,{emit:k}){const a=g,i=k,u=b(),I=$(),v=F(),p=M("emitter"),h=w(null),P=N(),o=w(null),y=B(()=>{const n=a.data.ContractPaymentSystems;if(u.data.PaymentSystems&&n){const t=new Set(n);return Object.keys(u.data.PaymentSystems).filter(s=>t.has(s)).map(s=>{const r=u.data.PaymentSystems[s];return r.IsActive==="1"&&Number(r.MaximumPayment)>=a.data.sum&&Number(r.MinimumPayment)<=a.data.sum?r.Collations:null}).filter(s=>s!==null).flat().slice().sort((s,r)=>{const f=parseInt(s.SortID,10),D=parseInt(r.SortID,10);return isNaN(f)?1:isNaN(D)?-1:f-D})}else return null});function x(n){o.value={id:n.ID,type:n.Source},a.data.ProfileID===null?o.value?.type==="Natural"||o.value?.type==="Juridical"||o.value?.type==="Individual"?(P.push(`/ProfileMake?ContractNew=${a.data.ItemID}&TemplateID=${o.value.type}`),i("modalClose")):I.InvoiceMake({ContractID:a.data.ItemID,PaymentSystemID:o.value.type}).then(t=>{if(t.status==="success"&&t.data&&t.data.InvoiceID){i("modalClose");const e=t.data.InvoiceID;v.InvoiceDocument({InvoiceID:e}).then(c=>{p.emit("open-modal",{component:"InvoiceDocumentBasket",data:{html:c,ID:e}})})}else i("modalClose")}):I.InvoiceMake({ContractID:a.data.ItemID,PaymentSystemID:o.value?.type}).then(t=>{if(t.status==="success"&&t.data&&t.data.InvoiceID){i("modalClose");const e=t.data.InvoiceID;v.InvoiceDocument({InvoiceID:e}).then(c=>{p.emit("open-modal",{component:"InvoiceDocumentBasket",data:{html:c,ID:e}})})}else i("modalClose")})}return(n,t)=>(d(),l("div",null,[t[0]||(t[0]=m("div",{class:"tw-text-2xl"},"Выбрать платёжную систему",-1)),y.value?(d(),l("div",V,[(d(!0),l(S,null,j(y.value,e=>(d(),l(S,{key:e.ID},[e.IsActive?(d(),l("div",{key:0,class:A(["tw-cursor-pointer tw-p-4 tw-border tw-border-gray-200 hover:tw-border-orange-500 tw-rounded",o.value?.id===e.ID?"tw-border-orange-500":"tw-border-gray-200"]),onClick:c=>x(e)},[m("div",z,[m("img",{class:"tw-w-32 tw-h-20 tw-object-contain",src:e.Image},null,8,E)]),m("div",J,C(e.Description),1)],10,W)):_("",!0)],64))),128))])):_("",!0),m("div",L,C(h.value),1)]))}},K=O(R,[["__scopeId","data-v-d33df1af"]]);export{K as default};
