import{d as K}from"./datatables-I6jthWPb.js";import{T as P}from"./bootstrap.esm-Bb7dPm-H.js";import{$ as c}from"./datatables-Bo82YvhT.js";/* empty css                                  */document.addEventListener("DOMContentLoaded",function(){var u,m,w,f,p,g,b,h,y,x,R,A,_,T,C,E,S,j,v,$,D,L,k,U;const M=document.getElementById("escalationRules").dataset.recordsUrl,F=c("#escalationRules").DataTable({...K.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:M,type:"GET",headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}},columns:[{data:"name",name:"name",title:((w=(m=(u=window.translations)==null?void 0:u.escalationRules)==null?void 0:m.fields)==null?void 0:w.name)||"Rule Name"},{data:"description",name:"description",title:((g=(p=(f=window.translations)==null?void 0:f.escalationRules)==null?void 0:p.fields)==null?void 0:g.description)||"Description",orderable:!1},{data:"condition_summary",name:"condition_summary",title:((y=(h=(b=window.translations)==null?void 0:b.escalationRules)==null?void 0:h.fields)==null?void 0:y.condition_summary)||"Condition Summary",orderable:!1,render:function(e,l,d){return e||'<span class="text-muted">-</span>'}},{data:"action_summary",name:"action_summary",title:((A=(R=(x=window.translations)==null?void 0:x.escalationRules)==null?void 0:R.fields)==null?void 0:A.action_summary)||"Action Summary",orderable:!1,render:function(e,l,d){return e||'<span class="text-muted">-</span>'}},{data:"status",name:"status",title:((C=(T=(_=window.translations)==null?void 0:_.escalationRules)==null?void 0:T.fields)==null?void 0:C.status)||"Status",render:function(e,l,d){var n,a,s,i,o,r;return e===!0||e===1?`<span class="badge bg-success">${((s=(a=(n=window.translations)==null?void 0:n.escalationRules)==null?void 0:a.status)==null?void 0:s.active)||"Active"}</span>`:`<span class="badge bg-danger">${((r=(o=(i=window.translations)==null?void 0:i.escalationRules)==null?void 0:o.status)==null?void 0:r.inactive)||"Inactive"}</span>`}},{data:"sort_order",name:"sort_order",title:((j=(S=(E=window.translations)==null?void 0:E.escalationRules)==null?void 0:S.fields)==null?void 0:j.sort_order)||"Sort Order",className:"text-center",width:"100px"},{data:"created_at",name:"created_at",title:((D=($=(v=window.translations)==null?void 0:v.escalationRules)==null?void 0:$.fields)==null?void 0:D.created_at)||"Created At",width:"150px"},{data:"id",name:"actions",title:((U=(k=(L=window.translations)==null?void 0:L.escalationRules)==null?void 0:k.fields)==null?void 0:U.actions)||"Actions",orderable:!1,searchable:!1,className:"text-center",width:"100px",render:function(e,l,d){var a,s,i,o,r,t,q,z,B,I,N,O,G;const n=[];if((s=(a=window.permissions)==null?void 0:a.escalationRules)!=null&&s.update){const J=(r=(o=(i=window.routes)==null?void 0:i.escalationRules)==null?void 0:o.edit)==null?void 0:r.replace(":id",e);n.push(`
                            <a href="${J}"
                               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="${((z=(q=(t=window.translations)==null?void 0:t.escalationRules)==null?void 0:q.buttons)==null?void 0:z.edit)||"Edit"}">
                                <i class="fas fa-edit"></i>
                            </a>`)}return(I=(B=window.permissions)==null?void 0:B.escalationRules)!=null&&I.delete&&n.push(`
                            <button type="button"
                                    class="btn btn-sm btn-outline-danger d-inline-flex align-items-center justify-content-center ms-1 delete-escalation-rule"
                                    style="width: 32px; height: 32px;"
                                    data-id="${e}"
                                    data-bs-toggle="tooltip"
                                    title="${((G=(O=(N=window.translations)==null?void 0:N.escalationRules)==null?void 0:O.buttons)==null?void 0:G.delete)||"Delete"}">
                                <i class="fas fa-trash"></i>
                            </button>`),n.length===0?'<span class="text-muted">-</span>':`<div class="d-inline-flex">${n.join("")}</div>`}}],drawCallback:function(){H()}});c(document).on("click",".delete-escalation-rule",async function(){var n,a,s,i,o,r;const e=c(this).data("id"),l=(s=(a=(n=window.routes)==null?void 0:n.escalationRules)==null?void 0:a.delete)==null?void 0:s.replace(":id",e);await window.showConfirm(((r=(o=(i=window.translations)==null?void 0:i.escalationRules)==null?void 0:o.messages)==null?void 0:r.deleteConfirm)||"Are you sure you want to delete this escalation rule?",{confirmClass:"btn-danger",icon:"warning"})&&fetch(l,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}}).then(t=>t.json()).then(t=>{t.success?(window.toastr?window.toastr.success(t.message):window.showSuccess(t.message),F.ajax.reload()):window.toastr?window.toastr.error(t.message||"An error occurred."):window.showError(t.message||"An error occurred.")}).catch(t=>{window.toastr?window.toastr.error("An error occurred."):window.showError("An error occurred.")})});function H(){[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(l=>new P(l,{boundary:document.body}))}});
