require(`./paths-BvlJvmRS.cjs`);const e=require(`./logger-BYbgqzvt.cjs`),t=require(`./model-auth-AR9ykNRi.cjs`);let n=require(`@buape/carbon`);const r={attempts:3,minDelayMs:500,maxDelayMs:3e4,jitter:.1},i={attempts:3,minDelayMs:400,maxDelayMs:3e4,jitter:.1},a=/429|timeout|connect|reset|closed|unavailable|temporarily/i,o=e.O(`retry-policy`);function s(e){return e.shouldRetry?e.strictShouldRetry?e.shouldRetry:n=>e.shouldRetry?.(n)||a.test(t.lr(n)):e=>a.test(t.lr(e))}function c(e){if(!e||typeof e!=`object`)return;let t=`parameters`in e&&e.parameters&&typeof e.parameters==`object`?e.parameters.retry_after:`response`in e&&e.response&&typeof e.response==`object`&&`parameters`in e.response?e.response.parameters?.retry_after:`error`in e&&e.error&&typeof e.error==`object`&&`parameters`in e.error?e.error.parameters?.retry_after:void 0;return typeof t==`number`&&Number.isFinite(t)?t*1e3:void 0}function l(e){let i=t.co(r,{...e.configRetry,...e.retry});return(r,a)=>t.lo(r,{...i,label:a,shouldRetry:e=>e instanceof n.RateLimitError,retryAfterMs:e=>e instanceof n.RateLimitError?e.retryAfter*1e3:void 0,onRetry:e.verbose?e=>{let t=e.label??`request`,n=Math.max(1,e.maxAttempts-1);o.warn(`discord ${t} rate limited, retry ${e.attempt}/${n} in ${e.delayMs}ms`)}:void 0})}function u(e){let n=t.co(i,{...e.configRetry,...e.retry}),r=s(e);return(i,a)=>t.lo(i,{...n,label:a,shouldRetry:r,retryAfterMs:c,onRetry:e.verbose?e=>{let n=Math.max(1,e.maxAttempts-1);o.warn(`telegram send retry ${e.attempt}/${n} for ${e.label??a??`request`} in ${e.delayMs}ms: ${t.lr(e.err)}`)}:void 0})}const d=new Map;function f(e,t){return`${e}:${t||`default`}`}function p(e,t){let n=f(e,t),r=d.get(n);if(r)return r;let i={inboundAt:null,outboundAt:null};return d.set(n,i),i}function m(e){let t=typeof e.at==`number`?e.at:Date.now(),n=e.accountId?.trim()||`default`,r=p(e.channel,n);e.direction===`inbound`&&(r.inboundAt=t),e.direction===`outbound`&&(r.outboundAt=t)}function h(e){let t=e.accountId?.trim()||`default`;return d.get(f(e.channel,t))??{inboundAt:null,outboundAt:null}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return h}});
