import{Si as e}from"./forms-CL2ODv4X.js";import{t}from"./useCurrencies-C8PCttqW.js";import{t as n}from"./useResolveCountry-C2h8eMhm.js";function r(e,t=2){if(Math.abs(e)<1e-10)return 0;let n=e<0;n&&(e=-e);let r=Number(e+`e+${t}`);return e=r>2**53-1?parseFloat(e.toFixed(t)):Number(Math.round(r)+`e-${t}`),n&&(e=-e),e}function i(e){return e??2}function a(e,t,n=2){return r(o(e,t),n)}function o(e,t){return Number(((t??0)/100*e).toPrecision(15))}function s(e,t){return`${e}${t}`.replace(/\s/g,``)}function c(e,t){return`${e} ${parseFloat(t.toString())} %`}function l(e,t=0,n=`.`,i=`,`){let a=typeof e==`string`?parseFloat(e):e,o=a<0?`-`:``,s=r(Math.abs(a),t).toFixed(t).toString().split(`.`),c=s[0],l=s[1]||``,u=[];for(let e=c.length;e>0;e-=3)u.unshift(c.substring(Math.max(0,e-3),e));return o+u.join(i)+(l?n+l:``)}var u=class{static formatValue(e,t){let n=t.thousand_separator,r=t.decimal_separator,i=t.precision;return l(e,i,r,n)}static formatMoney(e,t,n,r){let i=t.thousand_separator,a=t.decimal_separator,o=t.swap_currency_symbol,s=t.precision,c=t.code;n.thousand_separator?.length>=1&&(i=n.thousand_separator),n.decimal_separator?.length>=1&&(a=n.decimal_separator),n.swap_currency_symbol&&(o=n.swap_currency_symbol);let u=l(e,s,a,i),d=t.symbol;return r?.showCurrencyCode&&t.code===`CHF`?`${c} ${u}`:r?.showCurrencyCode?`${u} ${c}`:o?`${u} ${d.trim()}`:r?.showCurrencyCode?this.formatValue(u,t):`${d} ${u}`}};function d(e){let n=t(),{resolveBy:r}=e||{};return r===`code`?e=>n.find(t=>t.code===e):e=>n.find(t=>t.id==e)}function f(){let t=n(),r=d(),i=e();return(e,n,a,o,s)=>{let c=n||i?.settings.country_id,l=a&&a!==`999`?a:i?.settings.currency_id,d=t(c),f=r(l);return d&&f?u.formatMoney(isNaN(Number(e))?0:e,f,d,{showCurrencyCode:s??i.settings.show_currency_code}):o?Number(e).toFixed(o):e}}export{c as a,r as c,l as i,s as l,d as n,a as o,u as r,i as s,f as t,o as u};