import{t as e}from"./axios-m7YkukvY.js";import{et as t}from"./runtime-core.esm-bundler-Babufkcf.js";var n=t(`AFN`),r=t({}),i=t(0),a=!1;function o(){async function t(){if(!a){a=!0;try{let{data:t}=await e.get(`/exchange-rates/current`);n.value=t?.base||`AFN`,r.value=t?.rates||{}}catch{a=!1}}}async function o(){a=!1,await t()}function s(){i.value++}async function c(t,a){let o=Number(a||0);if(!t||t===n.value||o<=0)return!1;try{return await e.post(`/exchange-rates`,{currency_code:t,rate_to_base:o}),r.value={...r.value,[t]:o},i.value++,!0}catch{return!1}}function l(e,t){if(!e||e===n.value)return 1;let r=Number(t||0);return r>0&&r!==1?r:u(e)}function u(e){return!e||e===n.value?1:Number(r.value[e]||0)||1}function d(e,t,n=null){return Number(e||0)*(n??u(t))}function f(e,t=``){return Number(e||0).toLocaleString(`en-US`)+(t?` `+t:``)}function p(e){return Object.entries(e||{}).filter(([,e])=>Math.abs(Number(e))>.009).map(([e,t])=>f(t,e)).join(` · `)}function m(e,t,r=``){let i=Object.entries(t||{}).filter(([,e])=>Math.abs(Number(e))>.009);return i.length===1?{value:Number(i[0][1]).toLocaleString(`en-US`),suffix:i[0][0],sub:r}:{value:Number(e||0).toLocaleString(`en-US`),suffix:n.value,sub:i.length>1?p(t):r}}function h(e){let t=(e||[]).filter(e=>e.status===`confirmed`),n={in:{},out:{},net:{}},r=0,i=0;return t.forEach(e=>{let t=e.direction===`in`?`in`:`out`,a=Number(e.amount||0);n[t][e.currency]=(n[t][e.currency]||0)+a,n.net[e.currency]=(n.net[e.currency]||0)+(t===`in`?a:-a),t===`in`?r+=Number(e.amount_base||0):i+=Number(e.amount_base||0)}),{inBase:r,outBase:i,netBase:r-i,maps:n}}function g(e,t,r=``,i=``){let a=Object.entries(t||{}).filter(([,e])=>Math.abs(Number(e))>.009),o=e>.009?r:e<-.009?i:``;return a.length===1?{value:Math.abs(a[0][1]).toLocaleString(`en-US`),suffix:(o+` `+a[0][0]).trim(),sub:``}:{value:Math.abs(e||0).toLocaleString(`en-US`),suffix:(o+` `+n.value).trim(),sub:a.map(([e,t])=>(t>0?`+`:`−`)+Math.abs(t).toLocaleString(`en-US`)+` `+e).join(` · `)}}return{base:n,rates:r,version:i,loadRates:t,refreshRates:o,bumpVersion:s,setDailyRate:c,rateFor:u,rateOf:l,toBase:d,fmtAmount:f,breakdown:p,smartMoney:m,ledgerTotals:h,netMoney:g}}export{o as t};