function e(e){if(e){if(!Array.isArray(e))return e;for(let t=e.length-1;t>=0;--t){let n=e[t];if(n&&(n.text||n.mediaUrl||n.mediaUrls&&n.mediaUrls.length>0))return n}}}function t(e){switch(e){case`ok-empty`:case`ok-token`:return`ok`;case`sent`:return`alert`;case`failed`:return`error`;case`skipped`:return}}let n=null;const r=new Set;function i(e){let t={ts:Date.now(),...e};n=t;for(let e of r)try{e(t)}catch{}}function a(e){return r.add(e),()=>r.delete(e)}function o(){return n}const s={showOk:!1,showAlerts:!0,useIndicator:!0};function c(e){let{cfg:t,channel:n,accountId:r}=e;if(n===`webchat`){let e=t.channels?.defaults?.heartbeat;return{showOk:e?.showOk??s.showOk,showAlerts:e?.showAlerts??s.showAlerts,useIndicator:e?.useIndicator??s.useIndicator}}let i=t.channels?.defaults?.heartbeat,a=t.channels?.[n],o=a?.heartbeat,c=(r?a?.accounts?.[r]:void 0)?.heartbeat;return{showOk:c?.showOk??o?.showOk??i?.showOk??s.showOk,showAlerts:c?.showAlerts??o?.showAlerts??i?.showAlerts??s.showAlerts,useIndicator:c?.useIndicator??o?.useIndicator??i?.useIndicator??s.useIndicator}}export{t as a,a as i,i as n,e as o,o as r,c as t};
