import{_ as S}from"./Paginate-D_g9VFI3.js";import{_ as B}from"./NoDataFound-Xi4CpDbx.js";import{s as D}from"./assetStore-BSVLrDIW.js";import{m as N}from"./vue3-apexcharts-DT7e7b_A.js";import{_ as O}from"./UserLayout-D_lxcpvH.js";import{p as k,c as l,o as a,d as e,k as F,t as r,F as $,h as C,g as P,b as z,u as L,n as d,y as R}from"./app-fEKA3BkQ.js";import"./PageHeader-DmRLoM5E.js";import"./ValidationErrors-B24rcOPH.js";const V={class:"grid grid-cols-1 gap-y-4 md:gap-4 lg:grid-cols-3"},j={class:"table-responsive col-span-2 w-full rounded-2xl"},A={class:"table"},E={class:"!text-right"},M={key:0,class:"tbody"},T=["href"],W=["title"],q=["title"],G=["title"],H={class:"text-end"},I=["title"],J={class:"w-full"},K={class:"col-span-full space-y-4 lg:col-span-1"},Q={class:"card card-body flex h-56 flex-col items-center justify-center rounded-2xl"},U={class:"card card-body rounded-2xl"},X={class:"mt-4 space-y-3"},Y={class:"mb-1 text-sm"},Z={class:"h-1.5 w-full rounded-lg bg-gray-200"},oe=Object.assign({layout:O},{__name:"Logs",props:["logs","campaign"],setup(i){const t=i;D();const{failed_messages:m,delivered_messages:_,sent_messages:u,read_messages:h}=t.campaign,g=["#F44336","#4CAF50","#2196F3","#FF9800"],p=k(()=>({series:[m,_,u,h],chartOptions:{plotOptions:{pie:{donut:{size:"75%"}}},chart:{type:"donut"},colors:g,height:160,labels:[`Failed ${m}`,`Delivered ${_}`,`Sent ${u}`,`Read ${h}`],responsive:[{breakpoint:480,options:{chart:{width:150},legend:{position:"bottom"}}}]}})),w=k(()=>{const n=t.campaign.total_messages,o=s=>s?s/n*100:0;return[{name:"Failed",value:t.campaign.failed_messages,percentage:o(t.campaign.failed_messages)},{name:"Delivered",value:t.campaign.delivered_messages,percentage:o(t.campaign.delivered_messages)},{name:"Sent",value:t.campaign.sent_messages,percentage:o(t.campaign.sent_messages)},{name:"Read",value:t.campaign.read_messages,percentage:o(t.campaign.read_messages)}]});return(n,o)=>(a(),l("div",V,[e("div",j,[e("table",A,[e("thead",null,[e("tr",null,[e("th",null,r(n.trans("Phone Number")),1),e("th",null,r(n.trans("Sent")),1),e("th",null,r(n.trans("Delivered")),1),e("th",E,r(n.trans("Read")),1)])]),i.logs.data.length?(a(),l("tbody",M,[(a(!0),l($,null,C(i.logs.data,(s,c)=>{var f,b,v,y,x;return a(),l("tr",{key:c},[e("td",null,[e("a",{href:`https://wa.me/${(f=s.meta)==null?void 0:f.phone}`,target:"_blank",rel:"noopener noreferrer",class:"hover:underline"},r((b=s.meta)==null?void 0:b.phone),9,T)]),e("td",null,[s.failed_at?(a(),l("i",{key:0,class:d(["bx",s.failed_at?"bxs-info-circle text-red-500":"bx-info-circle"]),title:((x=(y=(v=s.meta.errors)==null?void 0:v[0])==null?void 0:y.error_data)==null?void 0:x.details)??s.failed_at},null,10,W)):(a(),l("i",{key:1,class:d(["bx",s.send_at?"bxs-check-circle text-green-500":"bx-circle"]),title:s.send_at},null,10,q))]),e("td",null,[e("i",{class:d(["bx",s.delivered_at?"bxs-check-circle text-green-500":"bx-circle"]),title:s.delivered_at},null,10,G)]),e("td",null,[e("div",H,[e("i",{class:d(["bx",s.read_at?"bxs-check-circle text-green-500":"bx-circle"]),title:s.read_at},null,10,I)])])])}),128))])):(a(),F(B,{key:1,forTable:!0}))]),e("div",J,[i.logs.data.length?(a(),F(S,{key:0,links:i.logs.links},null,8,["links"])):P("",!0)])]),e("div",K,[e("div",Q,[z(L(N),{height:"200",options:p.value.chartOptions,series:p.value.series},null,8,["options","series"])]),e("div",U,[e("h6",null,r(n.trans("Logs")),1),e("div",X,[(a(!0),l($,null,C(w.value,(s,c)=>(a(),l("div",{key:c},[e("p",Y,r(s.name),1),e("div",Z,[e("div",{class:"h-full rounded-lg transition-all",style:R({width:s.percentage+"%",backgroundColor:g[c]})},null,4)])]))),128))])])])]))}});export{oe as default};
