import"./bootstrap.esm-Bb7dPm-H.js";import{d as f}from"./datatables-I6jthWPb.js";import{i as p}from"./tooltip-manager-D9RaGGY4.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){const o=document.getElementById("emailMarketingLists");if(!o)return;const b=o.getAttribute("data-records-url"),{permissions:d,routes:c}=window;$("#emailMarketingLists").DataTable({...f.getDefaultConfig(),serverSide:!0,searching:!1,dom:'<"d-flex align-items-center mb-3"<"d-flex align-items-center"l>>t<"d-flex justify-content-between align-items-center mt-3"<"d-flex align-items-center"i><"d-flex align-items-center"p>>',ajax:{url:b,type:"GET",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}},columns:[{data:"name",name:"name"},{data:"description",name:"description"},{data:"provider",name:"provider"},{data:"subscribers_count",name:"subscribers_count"},{data:"status",name:"status",render:function(e){var a,n,t,i,s,r;return e===!0||e===1?`<span class="badge bg-success">${((t=(n=(a=window.translations)==null?void 0:a.languages)==null?void 0:n.status)==null?void 0:t.active)||"Active"}</span>`:`<span class="badge bg-danger">${((r=(s=(i=window.translations)==null?void 0:i.languages)==null?void 0:s.status)==null?void 0:r.inactive)||"Inactive"}</span>`}},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e,a,n){var i,s,r,u,m,g;const t=[];if((i=d.emailMarketing)!=null&&i.update){const l=c.emailMarketing.edit.replace(":id",e);t.push(`
                            <a href="${l}"
                               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="${((r=(s=window.translations)==null?void 0:s.buttons)==null?void 0:r.edit)||"Edit"}">
                                <i class="fas fa-edit"></i>
                            </a>`)}if((u=d.emailMarketing)!=null&&u.delete){const l=c.emailMarketing.delete.replace(":id",e);t.push(`
                            <button type="button"
                                    class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-email-list"
                                    style="width: 32px; height: 32px;"
                                    data-id="${e}"
                                    data-url="${l}"
                                    data-bs-toggle="tooltip"
                                    title="${((g=(m=window.translations)==null?void 0:m.buttons)==null?void 0:g.delete)||"Delete"}">
                                <i class="fas fa-trash"></i>
                            </button>`)}return t.length?`<div class="d-inline-flex">${t.join("")}</div>`:'<span class="text-muted">-</span>'}}],drawCallback:function(){p()}}),document.body.addEventListener("click",async function(e){const a=e.target.closest(".delete-email-list");if(!a)return;const n=a.getAttribute("data-url");(await fetch(n,{method:"DELETE",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}})).ok&&$("#emailMarketingLists").DataTable().ajax.reload(null,!1)})});
