import{d as f}from"./datatables-I6jthWPb.js";import{r as l,g as c}from"./api-DZ3cXm1m.js";import{i as u}from"./tooltip-manager-D9RaGGY4.js";import"./bootstrap.esm-Bb7dPm-H.js";import"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){const r=document.getElementById("slaPlansTable");if(!r)return;const d=r.getAttribute("data-records-url"),s=window.slaPlansConfig,o=$("#slaPlansTable").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:d,type:"GET",beforeSend:function(e){e.setRequestHeader("Authorization",`Bearer ${c()}`)},error:async function(e){e.status===401&&await l()&&o.ajax.reload()}},columns:[{data:"id",name:"id"},{data:"name",name:"name"},{data:"first_response_time",name:"first_response_time"},{data:"resolution_time",name:"resolution_time"},{data:"business_hours_only",render:function(e){return e?'<i class="fas fa-check text-success"></i>':'<i class="fas fa-times text-muted"></i>'}},{data:"is_active",render:function(e){return e?`<span class="badge bg-success">${s.translations.status_active}</span>`:`<span class="badge bg-secondary">${s.translations.status_inactive}</span>`}},{data:"id",name:"actions",orderable:!1,searchable:!1,render:function(e){var n;const t=((n=window.pageConfig)==null?void 0:n.permissions)||{},a=[];if(t.update){const i=s.routes.edit.replace(":id",e);a.push(`<a href="${i}" 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="Edit"><i class="fas fa-edit"></i></a>`)}if(t.delete){const i=s.routes.destroy.replace(":id",e);a.push(`<button type="button" class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-sla-plan" style="width: 32px; height: 32px;" data-id="${e}" data-url="${i}" data-bs-toggle="tooltip" title="Delete"><i class="fas fa-trash"></i></button>`)}return a.length?`<div class="d-inline-flex">${a.join("")}</div>`:"-"}}],drawCallback:function(){u()}});document.body.addEventListener("click",async function(e){const t=e.target.closest(".delete-sla-plan");if(!t||!confirm(s.translations.confirm_delete))return;const a=t.getAttribute("data-url");try{const n=await fetch(a,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c()}`}});if(n.status===401){await l()&&t.click();return}n.ok&&o.ajax.reload(null,!1)}catch(n){console.error("Delete error:",n)}})});
