import{d as b}from"./datatables-I6jthWPb.js";import{r as f,g as w}from"./api-DZ3cXm1m.js";import{i as y}from"./tooltip-manager-D9RaGGY4.js";import{c as g,g as h}from"./datatable-filters-CecjJm_7.js";import"./bootstrap.esm-Bb7dPm-H.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */import"./vendor-zLyX4B24.js";import"./tr-CHCA6xOE.js";const u=window.translations||{},_=[{value:"",label:u.filters_all_types||"All Types"},{value:"payment",label:"Payment"},{value:"refund",label:"Refund"},{value:"credit",label:"Credit"},{value:"debit",label:"Debit"}],v=[{value:"",label:u.filters_all_statuses||"All Statuses"},{value:"pending",label:"Pending"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],p=g(null,{filters:[{type:"select",id:"typeFilter",width:"130px",options:_},{type:"select",id:"statusFilter",width:"140px",options:v}],search:!0,searchPlaceholder:u.search_placeholder||"Search..."}),m=$("#transactions").DataTable({...b.getDefaultConfig(),serverSide:!0,dom:h(),ajax:{url:$("#transactions").data("records-url"),type:"GET",headers:{Authorization:"Bearer "+w()},data:function(t){const e=p.getValues();t.type=e.typeFilter,t.status=e.statusFilter,t.search={value:e.search||""}},error:function(t){t.status===401&&f().then(e=>{e&&m.ajax.reload()})}},columns:[{data:"id",name:"id",render:function(t){return`<span class="fw-bold">#${t}</span>`}},{data:"client_name",name:"client_name",render:function(t,e,a){return t==="-"?"-":`${t}<br><small class="text-muted">${a.client_email}</small>`}},{data:"invoice_number",name:"invoice_number"},{data:"type",name:"type",render:function(t){var n,s,i,l,r,o,d,c;const a={payment:{class:"bg-primary",label:((s=(n=window.translations)==null?void 0:n.transactions)==null?void 0:s.types_payment)||"Payment"},refund:{class:"bg-warning",label:((l=(i=window.translations)==null?void 0:i.transactions)==null?void 0:l.types_refund)||"Refund"},credit:{class:"bg-success",label:((o=(r=window.translations)==null?void 0:r.transactions)==null?void 0:o.types_credit)||"Credit"},debit:{class:"bg-info",label:((c=(d=window.translations)==null?void 0:d.transactions)==null?void 0:c.types_debit)||"Debit"}}[t]||{class:"bg-secondary",label:t};return`<span class="badge ${a.class}">${a.label}</span>`}},{data:"amount",name:"amount",render:function(t,e,a){return`${parseFloat(t).toFixed(2)} ${a.currency_code}`}},{data:"payment_method",name:"payment_method"},{data:"status",name:"status",render:function(t){var n,s,i,l,r,o;const a={completed:{class:"bg-success",label:((s=(n=window.translations)==null?void 0:n.transactions)==null?void 0:s.statuses_completed)||"Completed"},pending:{class:"bg-warning",label:((l=(i=window.translations)==null?void 0:i.transactions)==null?void 0:l.statuses_pending)||"Pending"},failed:{class:"bg-danger",label:((o=(r=window.translations)==null?void 0:r.transactions)==null?void 0:o.statuses_failed)||"Failed"}}[t]||{class:"bg-secondary",label:t};return`<span class="badge ${a.class}">${a.label}</span>`}},{data:"payment_gateway",name:"payment_gateway"},{data:"created_at",name:"created_at"},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(t){var a,n,s,i,l,r,o,d;const e=[];if((n=(a=window.permissions)==null?void 0:a.transactions)!=null&&n.view){const c=window.routes.transactions.show.replace(":id",t);e.push(`
                        <a href="${c}"
                           class="btn btn-sm btn-outline-info d-inline-flex align-items-center justify-content-center"
                           style="width: 32px; height: 32px;"
                           data-bs-toggle="tooltip"
                           title="${((i=(s=window.translations)==null?void 0:s.common)==null?void 0:i.buttons_view)||"View"}">
                            <i class="fas fa-eye"></i>
                        </a>`)}if((r=(l=window.permissions)==null?void 0:l.transactions)!=null&&r.update){const c=window.routes.transactions.edit.replace(":id",t);e.push(`
                        <a href="${c}"
                           class="btn btn-sm btn-outline-primary d-inline-flex align-items-center justify-content-center"
                           style="width: 32px; height: 32px;"
                           data-bs-toggle="tooltip"
                           title="${((d=(o=window.translations)==null?void 0:o.common)==null?void 0:d.buttons_edit)||"Edit"}">
                            <i class="fas fa-edit"></i>
                        </a>`)}return e.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex gap-1">${e.join("")}</div>`}}],initComplete:function(){p.init()},drawCallback:function(){y()}});p.setDataTable(m);
