import{d as r}from"./datatables-CdFC5o1t.js";import{r as d,g as l}from"./api-DZ3cXm1m.js";import"./bootstrap.esm-Bb7dPm-H.js";import"jquery";import"./datatables-bbQliV7G.js";/* empty css                                  */function f(c){const s={payment:{class:"bg-success",icon:"fa-arrow-down",text:"Payment"},credit:{class:"bg-success",icon:"fa-arrow-down",text:"Credit"},refund:{class:"bg-warning",icon:"fa-undo",text:"Refund"},withdrawal:{class:"bg-danger",icon:"fa-arrow-up",text:"Withdrawal"},debit:{class:"bg-danger",icon:"fa-arrow-up",text:"Debit"},deposit:{class:"bg-info",icon:"fa-arrow-down",text:"Deposit"}}[c]||{class:"bg-secondary",icon:"fa-question",text:c};return`<span class="badge ${s.class}"><i class="fas ${s.icon} me-1"></i>${s.text}</span>`}function g(c){const s={completed:{class:"bg-success",icon:"fa-check",text:"Completed"},pending:{class:"bg-warning",icon:"fa-clock",text:"Pending"},failed:{class:"bg-danger",icon:"fa-times",text:"Failed"},cancelled:{class:"bg-secondary",icon:"fa-ban",text:"Cancelled"}}[c]||{class:"bg-secondary",icon:"fa-question",text:c};return`<span class="badge ${s.class}"><i class="fas ${s.icon} me-1"></i>${s.text}</span>`}$(document).ready(function(){const c=window.transactionsConfig,o=$("#transactions").data("records-url"),s=$("#transactions").DataTable({...r.getDefaultConfig(),ajax:{url:o,type:"POST",beforeSend:function(e){e.setRequestHeader("Authorization",`Bearer ${l()}`)},error:async function(e){e.status===401&&await d()&&s.ajax.reload()}},columns:[{data:"id",width:"50px",className:"text-center"},{data:"created_at",render:function(e,i,a){return e}},{data:"type",render:function(e,i,a){const n={payment:{class:"bg-success",icon:"fa-arrow-down",text:"Payment"},refund:{class:"bg-warning",icon:"fa-undo",text:"Refund"},withdrawal:{class:"bg-danger",icon:"fa-arrow-up",text:"Withdrawal"},deposit:{class:"bg-info",icon:"fa-arrow-down",text:"Deposit"}}[e]||{class:"bg-secondary",icon:"fa-question",text:e};return`<span class="badge ${n.class}"><i class="fas ${n.icon} me-1"></i>${n.text}</span>`}},{data:"status",render:function(e,i,a){const n={completed:{class:"bg-success",icon:"fa-check",text:"Completed"},pending:{class:"bg-warning",icon:"fa-clock",text:"Pending"},failed:{class:"bg-danger",icon:"fa-times",text:"Failed"},cancelled:{class:"bg-secondary",icon:"fa-ban",text:"Cancelled"}}[e]||{class:"bg-secondary",icon:"fa-question",text:e};return`<span class="badge ${n.class}"><i class="fas ${n.icon} me-1"></i>${n.text}</span>`}},{data:"amount",className:"text-end",render:function(e,i,a){const t=a.type==="payment"||a.type==="deposit";return`<strong class="${t?"text-success":"text-danger"}">${t?"+":"-"}${a.currency_symbol}${parseFloat(e).toFixed(2)}</strong>`}},{data:"payment_method",render:function(e,i,a){return!e||e==="-"?'<span class="text-muted">-</span>':`<span class="badge bg-primary"><i class="fas fa-credit-card me-1"></i>${e}</span>`}},{data:"description",render:function(e,i,a){return e||'<span class="text-muted">-</span>'}},{data:"reference",render:function(e,i,a){let t="";return a.invoice_id&&(t+=`<a href="/admin/billing/invoices/${a.invoice_id}" class="badge bg-primary me-1">
                            <i class="fas fa-file-invoice me-1"></i>Invoice #${a.invoice_id}
                        </a>`),a.order_id&&(t+=`<a href="/admin/orders/${a.order_id}" class="badge bg-info me-1">
                            <i class="fas fa-shopping-cart me-1"></i>Order #${a.order_id}
                        </a>`),a.payment_gateway&&a.payment_gateway!=="-"&&(t+=`<span class="badge bg-secondary me-1">
                            <i class="fas fa-credit-card me-1"></i>${a.payment_gateway}
                        </span>`),a.payment_transaction_id&&a.payment_transaction_id!=="-"&&(t+=`<span class="badge bg-dark me-1" title="Transaction ID">
                            <i class="fas fa-hashtag me-1"></i>${a.payment_transaction_id}
                        </span>`),a.admin_name&&a.admin_name!=="System"&&(t+=`<span class="badge bg-dark me-1">
                            <i class="fas fa-user-shield me-1"></i>${a.admin_name}
                        </span>`),t||'<span class="text-muted">-</span>'}},{data:null,orderable:!1,searchable:!1,width:"100px",className:"text-center",render:function(e,i,a){var t;return`
                        <button class="btn btn-sm btn-info view-transaction" data-id="${a.id}" title="${((t=c.translations.common)==null?void 0:t.buttons_view)||"View"}">
                            <i class="fas fa-eye"></i>
                        </button>
                    `}}],order:[[0,"desc"]]});$("#searchInput").on("keyup",function(){s.search(this.value).draw()}),$("#transactions").on("click",".view-transaction",function(){const e=s.row($(this).closest("tr")).data();if(!e)return;$("#txn-id").text("#"+e.id),$("#txn-date").text(e.created_at),$("#txn-type").html(f(e.type)),$("#txn-status").html(g(e.status));const i=e.type==="payment"||e.type==="deposit"||e.type==="credit",a=i?"+":"-",t=i?"text-success":"text-danger";$("#txn-amount").html(`<strong class="${t}">${a}${e.currency_symbol}${parseFloat(e.amount).toFixed(2)}</strong> <small class="text-muted">${e.currency_code||""}</small>`),$("#txn-payment-method").text(e.payment_method||"-"),$("#txn-description").text(e.description||"-"),$("#txn-gateway").text(e.payment_gateway||"-"),$("#txn-payment-txn-id").text(e.payment_transaction_id||"-"),$("#txn-admin").text(e.admin_name||"-");let n="";e.invoice_id&&(n+=`<a href="/admin/billing/invoices/${e.invoice_id}" class="badge bg-primary me-1"><i class="fas fa-file-invoice me-1"></i>Invoice #${e.invoice_id}</a>`),e.order_id&&(n+=`<a href="/admin/orders/${e.order_id}" class="badge bg-info me-1"><i class="fas fa-shopping-cart me-1"></i>Order #${e.order_id}</a>`),e.reference_type&&(n+=`<span class="badge bg-secondary">${e.reference_type}</span>`),$("#txn-reference").html(n||"-"),new bootstrap.Modal(document.getElementById("viewTransactionModal")).show()}),$(".add-transaction-btn").on("click",function(){window.location.href=c.routes.addBalance+"?client_id="+c.clientId})});
