const e={openrouter:t=>{const o=t?.openrouter;return typeof o=="object"&&o!==null&&"usage"in o&&typeof o.usage=="object"&&o.usage!==null&&"cost"in o.usage&&typeof o.usage.cost=="number"?o.usage.cost:null}};function r(t){if(!t?.providerMetadata)return 0;for(const o of Object.values(e)){const n=o(t.providerMetadata);if(n!==null)return n}return 0}function s(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0}}function u(t,o){return o?{inputTokens:t.inputTokens+(o.inputTokens??0),outputTokens:t.outputTokens+(o.outputTokens??0),reasoningTokens:t.reasoningTokens+(o.reasoningTokens??0),totalTokens:t.totalTokens+(o.totalTokens??0),cost:t.cost+r(o)}:t}function a(t){return t.reduce((o,n)=>u(o,n.metadata?.usage),s())}export{u as a,a as c,s as e,r as g};
