import{am as x,au as N,A as M,r as f,e as B,g as j,o as l,c as m,a as d,F as _,h as A,n as F,t as S,i as C}from"./index-Bb2UEb_P.js";import{u as O}from"./invoices-F361lW0u.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";const W={key:0,class:"tw-grid tw-grid-cols-2 md:tw-grid-cols-3 tw-gap-4 tw-mt-4"},$=["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 s=g,i=k,u=x(),I=O(),v=N(),p=M("emitter"),h=f(null),b=B(),o=f(null),y=j(()=>{const n=s.data.ContractPaymentSystems;if(u.data.PaymentSystems&&n){const t=new Set(n);return Object.keys(u.data.PaymentSystems).filter(a=>t.has(a)).map(a=>{const r=u.data.PaymentSystems[a];return r.IsActive==="1"&&Number(r.MaximumPayment)>=s.data.sum&&Number(r.MinimumPayment)<=s.data.sum?r.Collations:null}).filter(a=>a!==null).flat().slice().sort((a,r)=>{const D=Number.parseInt(a.SortID,10),w=Number.parseInt(r.SortID,10);return isNaN(D)?1:isNaN(w)?-1:D-w})}else return null});function P(n){o.value={id:n.ID,type:n.Source},s.data.ProfileID===null?o.value?.type==="Natural"||o.value?.type==="Juridical"||o.value?.type==="Individual"?(b.push(`/ProfileMake?CreateContract=true&TemplateID=${o.value.type}`),i("modalClose")):I.InvoiceMake({ContractID:s.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:s.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)=>(l(),m("div",null,[t[0]||(t[0]=d("div",{class:"tw-text-2xl"},"Выбрать платёжную систему",-1)),y.value?(l(),m("div",W,[(l(!0),m(_,null,A(y.value,e=>(l(),m(_,{key:e.ID},[e.IsActive?(l(),m("div",{key:0,class:F(["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=>P(e)},[d("div",z,[d("img",{class:"tw-w-32 tw-h-20 tw-object-contain",src:e.Image},null,8,E)]),d("div",J,S(e.Description),1)],10,$)):C("",!0)],64))),128))])):C("",!0),d("div",L,S(h.value),1)]))}},H=V(R,[["__scopeId","data-v-551022eb"]]);export{H as default};
