import{u as I}from"./widget-qjKd4HCd.js";import{B as C,Y as D,Z as B,a0 as h,n as L}from"./app-JmgyQoR0.js";import{n as c}from"./number-rE36t967.js";import{b as V,r as f,o as A,h as p,t as b,u as i,K as w,H as y,x as a,E as d,z as s,I as N,J as Q}from"./vue-y3KLWBaS.js";const l=r=>(N("data-v-077f1618"),r=r(),Q(),r),W={class:"inbox"},z={class:"label"},E={key:0,class:"ph-warning ph-bold ph-lg icon"},M={class:"values"},H=l(()=>i("div",null,"Process",-1)),J=l(()=>i("div",null,"Active",-1)),K=l(()=>i("div",null,"Delayed",-1)),U=l(()=>i("div",null,"Waiting",-1)),Y={class:"deliver"},Z={class:"label"},F={key:0,class:"ph-warning ph-bold ph-lg icon"},G={class:"values"},O=l(()=>i("div",null,"Process",-1)),R=l(()=>i("div",null,"Active",-1)),X=l(()=>i("div",null,"Delayed",-1)),$=l(()=>i("div",null,"Waiting",-1)),S="jobQueue",ee=V({__name:"job-queue",props:{widget:{}},emits:["updateProps"],setup(r,{expose:P,emit:k}){const T={transparent:{type:"boolean",default:!1},sound:{type:"boolean",default:!1}},u=r,j=k,{widgetProps:g,configure:q}=I(S,T,u,j),v=C.useChannel("queueStats"),e=f({inbox:{activeSincePrevTick:0,active:0,waiting:0,delayed:0},deliver:{activeSincePrevTick:0,active:0,waiting:0,delayed:0}}),n=f({}),m=D(B("syuilo/queue-jammed"),1);for(const o of["inbox","deliver"])n[o]=h(e[o]);const _=o=>{for(const t of["inbox","deliver"])n[t]=h(e[t]),e[t].activeSincePrevTick=o[t].activeSincePrevTick,e[t].active=o[t].active,e[t].waiting=o[t].waiting,e[t].delayed=o[t].delayed,e[t].waiting>0&&g.sound&&m.paused&&m.play()},x=o=>{for(const t of[...o].reverse())_(t)};return v.on("stats",_),v.on("statsLog",x),v.send("requestLog",{id:Math.random().toString().substr(2,8),length:1}),A(()=>{v.off("stats",_),v.off("statsLog",x),v.dispose()}),P({name:S,configure:q,id:u.widget?u.widget.id:null}),(o,t)=>(p(),b("div",{class:a(["mkw-jobQueue _monospace",{_panel:!s(g).transparent}])},[i("div",W,[i("div",z,[w(" Inbox queue"),e.inbox.waiting>0?(p(),b("i",E)):y("",!0)]),i("div",M,[i("div",null,[H,i("div",{class:a({inc:e.inbox.activeSincePrevTick>n.inbox.activeSincePrevTick,dec:e.inbox.activeSincePrevTick<n.inbox.activeSincePrevTick})},d(s(c)(e.inbox.activeSincePrevTick)),3)]),i("div",null,[J,i("div",{class:a({inc:e.inbox.active>n.inbox.active,dec:e.inbox.active<n.inbox.active})},d(s(c)(e.inbox.active)),3)]),i("div",null,[K,i("div",{class:a({inc:e.inbox.delayed>n.inbox.delayed,dec:e.inbox.delayed<n.inbox.delayed})},d(s(c)(e.inbox.delayed)),3)]),i("div",null,[U,i("div",{class:a({inc:e.inbox.waiting>n.inbox.waiting,dec:e.inbox.waiting<n.inbox.waiting})},d(s(c)(e.inbox.waiting)),3)])])]),i("div",Y,[i("div",Z,[w(" Deliver queue"),e.deliver.waiting>0?(p(),b("i",F)):y("",!0)]),i("div",G,[i("div",null,[O,i("div",{class:a({inc:e.deliver.activeSincePrevTick>n.deliver.activeSincePrevTick,dec:e.deliver.activeSincePrevTick<n.deliver.activeSincePrevTick})},d(s(c)(e.deliver.activeSincePrevTick)),3)]),i("div",null,[R,i("div",{class:a({inc:e.deliver.active>n.deliver.active,dec:e.deliver.active<n.deliver.active})},d(s(c)(e.deliver.active)),3)]),i("div",null,[X,i("div",{class:a({inc:e.deliver.delayed>n.deliver.delayed,dec:e.deliver.delayed<n.deliver.delayed})},d(s(c)(e.deliver.delayed)),3)]),i("div",null,[$,i("div",{class:a({inc:e.deliver.waiting>n.deliver.waiting,dec:e.deliver.waiting<n.deliver.waiting})},d(s(c)(e.deliver.waiting)),3)])])])],2))}}),ae=L(ee,[["__scopeId","data-v-077f1618"]]);export{ae as default};
