dinero.js
Version:
An immutable library to create, calculate and format monetary values.
2 lines (1 loc) • 34.7 kB
JavaScript
define(function(){'use strict';var I=Math.min,_=Math.ceil,x=Math.sign,L=Math.floor,j=Math.max,C=Math.pow,N=Math.abs,k=Number.isInteger;function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e){"@babel/helpers - typeof";return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e){return n(e)||o(e)||a(e)||s()}function n(e){if(Array.isArray(e))return e}function o(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function a(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e){return!isNaN(parseInt(e))&&isFinite(e)}function c(e){return l(e)&&100>=e&&0<=e}function u(e){return 0<e.length&&e.every(function(e){return 0<=e})&&e.some(function(e){return 0<e})}function d(e){return 0==e%2}function g(e){return l(e)&&!k(e)}function p(){var e=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0,t=e.toString();if(0<t.indexOf("e-"))return parseInt(t.split("e-")[1]);var r=t.split(".")[1];return r?r.length:0}function m(e){return .5==N(e)%1}function y(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(r,n){var o=Object.assign(new XMLHttpRequest,{onreadystatechange:function(){4===o.readyState&&(200<=o.status&&400>o.status?r(JSON.parse(o.responseText)):n(new Error(o.statusText)))},onerror:function(){n(new Error("Network error"))}});o.open("GET",e,!0),h(o,t.headers),o.send()})}function h(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};for(var r in t)e.setRequestHeader(r,t[r]);return e}function A(e){return"undefined"==typeof e}function E(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:".",n={};return Object.entries(e).forEach(function(e){if("object"===t(e[1])){var o=E(e[1]);Object.entries(o).forEach(function(t){n[e[0]+r+t[0]]=t[1]})}else n[e[0]]=e[1]}),n}function v(e){return!!e&&("object"===t(e)||"function"==typeof e)&&"function"==typeof e.then}function T(){var e=Math.round,t=function(t,r){var n=function(e){return C(10,p(e))},o=j(n(t),n(r));return e(t*o)*e(r*o)/(o*o)},r={HALF_ODD:function(t){var r=e(t);return m(t)?d(r)?r-1:r:r},HALF_EVEN:function(t){var r=e(t);return m(t)?d(r)?r:r-1:r},HALF_UP:function(t){return e(t)},HALF_DOWN:function(t){return m(t)?L(t):e(t)},HALF_TOWARDS_ZERO:function(t){return m(t)?x(t)*L(N(t)):e(t)},HALF_AWAY_FROM_ZERO:function(t){return m(t)?x(t)*_(N(t)):e(t)},DOWN:function(e){return L(e)}};return{add:function(e,t){return e+t},subtract:function(e,t){return e-t},multiply:function(e,r){return g(e)||g(r)?t(e,r):e*r},divide:function(e,t){return e/t},modulo:function(e,t){return e%t},round:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"HALF_EVEN";return r[t](e)}}}function S(e){var t=/^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(e);return{getMatches:function(){return null===t?[]:t.slice(1).filter(function(e){return!A(e)})},getMinimumFractionDigits:function(){var e=function(e){return"."===e};return A(this.getMatches().find(e))?0:this.getMatches()[Ma.add(this.getMatches().findIndex(e),1)].split("").length},getCurrencyDisplay:function(){return{USD:"code",dollar:"name",$:"symbol"}[this.getMatches().find(function(e){return"USD"===e||"dollar"===e||"$"===e})]},getStyle:function(){return A(this.getCurrencyDisplay(this.getMatches()))?"decimal":"currency"},getUseGrouping:function(){return!A(this.getMatches().find(function(e){return","===e}))}}}function O(e){var t=function(){var e=0<arguments.length&&arguments[0]!==void 0?arguments[0]:"",t=1<arguments.length?arguments[1]:void 0;for(var r in t)e=e.replace("{{".concat(r,"}}"),t[r]);return e},r=function(r,n){return y(t(e.endpoint,{from:r,to:n}),{headers:e.headers})};return{getExchangeRate:function(n,o){return(v(e.endpoint)?e.endpoint:r(n,o)).then(function(r){return E(r)[t(e.propertyPath,{from:n,to:o})]})}}}function b(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:Error;if(!e)throw new r(t)}function P(e){b(c(e),"You must provide a numeric value between 0 and 100.",RangeError)}function R(e){b(u(e),"You must provide a non-empty array of numeric values greater than 0.",TypeError)}function M(e){b(k(e),"You must provide an integer.",TypeError)}var D="undefined"==typeof globalThis?"undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?{}:self:global:window:globalThis,F=function(e){return e&&e.Math==Math&&e},H=F("object"==typeof globalThis&&globalThis)||F("object"==typeof window&&window)||F("object"==typeof self&&self)||F("object"==typeof D&&D)||Function("return this")(),w=function(e){try{return!!e()}catch(e){return!0}},G=!w(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),U={}.propertyIsEnumerable,$=Object.getOwnPropertyDescriptor,Y=$&&!U.call({1:2},1),z=Y?function(e){var t=$(this,e);return!!t&&t.enumerable}:U,f={f:z},V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},W={}.toString,q=function(e){return W.call(e).slice(8,-1)},B="".split,K=w(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==q(e)?B.call(e,""):Object(e)}:Object,Z=function(e){if(e==null)throw TypeError("Can't call method on "+e);return e},J=function(e){return K(Z(e))},X=function(e){return"object"==typeof e?null!==e:"function"==typeof e},Q=function(e,t){if(!X(e))return e;var r,n;if(t&&"function"==typeof(r=e.toString)&&!X(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!X(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!X(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},ee={}.hasOwnProperty,te=function(e,t){return ee.call(e,t)},re=H.document,ne=X(re)&&X(re.createElement),oe=function(e){return ne?re.createElement(e):{}},ae=!G&&!w(function(){return 7!=Object.defineProperty(oe("div"),"a",{get:function(){return 7}}).a}),ie=Object.getOwnPropertyDescriptor,se=G?ie:function(e,t){if(e=J(e),t=Q(t,!0),ae)try{return ie(e,t)}catch(e){}return te(e,t)?V(!f.f.call(e,t),e[t]):void 0},le={f:se},ce=function(e){if(!X(e))throw TypeError(e+" is not an object");return e},ue=Object.defineProperty,de=G?ue:function(e,t,r){if(ce(e),t=Q(t,!0),ce(r),ae)try{return ue(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(e[t]=r.value),e},ge={f:de},pe=G?function(e,t,r){return ge.f(e,t,V(1,r))}:function(e,t,r){return e[t]=r,e},me=function(e,t){try{pe(H,e,t)}catch(r){H[e]=t}return t},ye="__core-js_shared__",fe=H[ye]||me(ye,{}),he=fe,Ae=Function.toString;"function"!=typeof he.inspectSource&&(he.inspectSource=function(e){return Ae.call(e)});var Ee,ve,Te,Se=he.inspectSource,Oe=H.WeakMap,be="function"==typeof Oe&&/native code/.test(Se(Oe)),Pe=e(function(e){(e.exports=function(e,t){return he[e]||(he[e]=t===void 0?{}:t)})("versions",[]).push({version:"3.6.4",mode:"global",copyright:"\xA9 2020 Denis Pushkarev (zloirock.ru)"})}),Re=0,Me=Math.random(),Ie=function(e){return"Symbol("+((e===void 0?"":e)+"")+")_"+(++Re+Me).toString(36)},_e=Pe("keys"),xe=function(e){return _e[e]||(_e[e]=Ie(e))},Le={},je=H.WeakMap,Ce=function(e){return Te(e)?ve(e):Ee(e,{})};if(be){var Ne=new je,ke=Ne.get,De=Ne.has,Fe=Ne.set;Ee=function(e,t){return Fe.call(Ne,e,t),t},ve=function(e){return ke.call(Ne,e)||{}},Te=function(e){return De.call(Ne,e)}}else{var He=xe("state");Le[He]=!0,Ee=function(e,t){return pe(e,He,t),t},ve=function(e){return te(e,He)?e[He]:{}},Te=function(e){return te(e,He)}}var we={set:Ee,get:ve,has:Te,enforce:Ce,getterFor:function(e){return function(t){var r;if(!X(t)||(r=ve(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}},Ge=e(function(e){var t=we.get,r=we.enforce,n=(String+"").split("String");(e.exports=function(e,t,o,a){var i=!!a&&!!a.unsafe,s=!!a&&!!a.enumerable,l=!!a&&!!a.noTargetGet;return("function"==typeof o&&("string"==typeof t&&!te(o,"name")&&pe(o,"name",t),r(o).source=n.join("string"==typeof t?t:"")),e===H)?void(s?e[t]=o:me(t,o)):void(i?!l&&e[t]&&(s=!0):delete e[t],s?e[t]=o:pe(e,t,o))})(Function.prototype,"toString",function(){return"function"==typeof this&&t(this).source||Se(this)})}),Ue=H,$e=function(e){return"function"==typeof e?e:void 0},Ye=function(e,t){return 2>arguments.length?$e(Ue[e])||$e(H[e]):Ue[e]&&Ue[e][t]||H[e]&&H[e][t]},ze=function(e){return isNaN(e=+e)?0:(0<e?L:_)(e)},Ve=function(e){return 0<e?I(ze(e),9007199254740991):0},We=function(e,t){var r=ze(e);return 0>r?j(r+t,0):I(r,t)},qe=function(e){return function(t,r,n){var o,a=J(t),i=Ve(a.length),s=We(n,i);if(e&&r!=r){for(;i>s;)if(o=a[s++],o!=o)return!0;}else for(;i>s;s++)if((e||s in a)&&a[s]===r)return e||s||0;return!e&&-1}},Be={includes:qe(!0),indexOf:qe(!1)},Ke=Be.indexOf,Ze=function(e,t){var r,n=J(e),o=0,a=[];for(r in n)!te(Le,r)&&te(n,r)&&a.push(r);for(;t.length>o;)te(n,r=t[o++])&&(~Ke(a,r)||a.push(r));return a},Je=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Xe=Je.concat("length","prototype"),Qe=Object.getOwnPropertyNames||function(e){return Ze(e,Xe)},et={f:Qe},tt=Object.getOwnPropertySymbols,rt={f:tt},nt=Ye("Reflect","ownKeys")||function(e){var t=et.f(ce(e)),r=rt.f;return r?t.concat(r(e)):t},ot=function(e,t){for(var r,n=nt(t),o=ge.f,a=le.f,s=0;s<n.length;s++)r=n[s],te(e,r)||o(e,r,a(t,r))},at=/#|\.prototype\./,it=function(e,t){var r=lt[st(e)];return!(r!=ut)||r!=ct&&("function"==typeof t?w(t):!!t)},st=it.normalize=function(e){return(e+"").replace(at,".").toLowerCase()},lt=it.data={},ct=it.NATIVE="N",ut=it.POLYFILL="P",dt=it,gt=le.f,pt=function(e,t){var r,n,o,a,i,s,l=e.target,c=e.global,u=e.stat;if(n=c?H:u?H[l]||me(l,{}):(H[l]||{}).prototype,n)for(o in t){if(i=t[o],e.noTargetGet?(s=gt(n,o),a=s&&s.value):a=n[o],r=dt(c?o:l+(u?".":"#")+o,e.forced),!r&&void 0!==a){if(typeof i==typeof a)continue;ot(i,a)}(e.sham||a&&a.sham)&&pe(i,"sham",!0),Ge(n,o,i,e)}},mt=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function");return e},yt=function(e,t,r){return(mt(e),void 0===t)?e:0===r?function(){return e.call(t)}:1===r?function(r){return e.call(t,r)}:2===r?function(r,n){return e.call(t,r,n)}:3===r?function(r,n,o){return e.call(t,r,n,o)}:function(){return e.apply(t,arguments)}},ft=function(e){return Object(Z(e))},ht=Array.isArray||function(e){return"Array"==q(e)},At=!!Object.getOwnPropertySymbols&&!w(function(){return!(Symbol()+"")}),Et=At&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,vt=Pe("wks"),Tt=H.Symbol,St=Et?Tt:Tt&&Tt.withoutSetter||Ie,Ot=function(e){return te(vt,e)||(At&&te(Tt,e)?vt[e]=Tt[e]:vt[e]=St("Symbol."+e)),vt[e]},bt=Ot("species"),Pt=function(e,t){var r;return ht(e)&&(r=e.constructor,"function"==typeof r&&(r===Array||ht(r.prototype))?r=void 0:X(r)&&(r=r[bt],null===r&&(r=void 0))),new(void 0===r?Array:r)(0===t?0:t)},Rt=[].push,Mt=function(e){var t=1==e,r=4==e,n=6==e;return function(o,a,i,s){for(var l,c,u=ft(o),d=K(u),g=yt(a,i,3),p=Ve(d.length),m=0,y=s||Pt,f=t?y(o,p):2==e?y(o,0):void 0;p>m;m++)if((5==e||n||m in d)&&(l=d[m],c=g(l,m,u),e))if(t)f[m]=c;else if(c)switch(e){case 3:return!0;case 5:return l;case 6:return m;case 2:Rt.call(f,l);}else if(r)return!1;return n?-1:3==e||r?r:f}},It={forEach:Mt(0),map:Mt(1),filter:Mt(2),some:Mt(3),every:Mt(4),find:Mt(5),findIndex:Mt(6)},_t=function(e,t){var r=[][e];return!!r&&w(function(){r.call(null,t||function(){throw 1},1)})},xt=Object.defineProperty,Lt={},jt=function(e){throw e},Ct=function(e,t){if(te(Lt,e))return Lt[e];t||(t={});var r=[][e],n=!!te(t,"ACCESSORS")&&t.ACCESSORS,o=te(t,0)?t[0]:jt,a=te(t,1)?t[1]:void 0;return Lt[e]=!!r&&!w(function(){if(n&&!G)return!0;var e={length:-1};n?xt(e,1,{enumerable:!0,get:jt}):e[1]=1,r.call(e,o,a)})},Nt=It.every,kt=_t("every"),Dt=Ct("every");pt({target:"Array",proto:!0,forced:!kt||!Dt},{every:function(e){return Nt(this,e,1<arguments.length?arguments[1]:void 0)}});var Ft,Ht=Function.call,wt=function(e,t,r){return yt(Ht,H[e].prototype[t],r)},Gt=wt("Array","every"),Ut=Object.keys||function(e){return Ze(e,Je)},$t=G?Object.defineProperties:function(e,t){ce(e);for(var r,n=Ut(t),o=n.length,a=0;o>a;)ge.f(e,r=n[a++],t[r]);return e},Yt=Ye("document","documentElement"),zt=">",Vt="<",Wt="prototype",qt="script",Bt=xe("IE_PROTO"),Kt=function(){},Zt=function(e){return Vt+qt+zt+e+Vt+"/"+qt+zt},Jt=function(e){e.write(Zt("")),e.close();var t=e.parentWindow.Object;return e=null,t},Xt=function(){var e,t=oe("iframe");return t.style.display="none",Yt.appendChild(t),t.src="java"+qt+":"+"",e=t.contentWindow.document,e.open(),e.write(Zt("document.F=Object")),e.close(),e.F},Qt=function(){try{Ft=document.domain&&new ActiveXObject("htmlfile")}catch(e){}Qt=Ft?Jt(Ft):Xt();for(var e=Je.length;e--;)delete Qt[Wt][Je[e]];return Qt()};Le[Bt]=!0;var er=Object.create||function(e,t){var r;return null===e?r=Qt():(Kt[Wt]=ce(e),r=new Kt,Kt[Wt]=null,r[Bt]=e),void 0===t?r:$t(r,t)},tr=Ot("unscopables"),rr=Array.prototype;rr[tr]==null&&ge.f(rr,tr,{configurable:!0,value:er(null)});var nr=function(e){rr[tr][e]=!0},or=It.findIndex,ar="findIndex",ir=!0,sr=Ct(ar);ar in[]&&[,][ar](function(){ir=!1}),pt({target:"Array",proto:!0,forced:ir||!sr},{findIndex:function(e){return or(this,e,1<arguments.length?arguments[1]:void 0)}}),nr(ar);var lr=wt("Array","findIndex"),cr=It.find,ur="find",dr=!0,gr=Ct(ur);ur in[]&&[,][ur](function(){dr=!1}),pt({target:"Array",proto:!0,forced:dr||!gr},{find:function(e){return cr(this,e,1<arguments.length?arguments[1]:void 0)}}),nr(ur);var pr,mr,yr,fr=wt("Array","find"),hr={},Ar=!w(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Er=xe("IE_PROTO"),vr=Object.prototype,Tr=Ar?Object.getPrototypeOf:function(e){return e=ft(e),te(e,Er)?e[Er]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?vr:null},Sr=Ot("iterator"),Or=!1;[].keys&&(yr=[].keys(),"next"in yr?(mr=Tr(Tr(yr)),mr!==Object.prototype&&(pr=mr)):Or=!0),pr==null&&(pr={}),te(pr,Sr)||pe(pr,Sr,function(){return this});var br={IteratorPrototype:pr,BUGGY_SAFARI_ITERATORS:Or},Pr=ge.f,Rr=Ot("toStringTag"),Mr=function(e,t,r){e&&!te(e=r?e:e.prototype,Rr)&&Pr(e,Rr,{configurable:!0,value:t})},Ir=br.IteratorPrototype,_r=function(){return this},xr=function(e,t,r){var n=t+" Iterator";return e.prototype=er(Ir,{next:V(1,r)}),Mr(e,n,!1),hr[n]=_r,e},Lr=function(e){if(!X(e)&&null!==e)throw TypeError("Can't set "+(e+" as a prototype"));return e},jr=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set,e.call(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return ce(r),Lr(n),t?e.call(r,n):r.__proto__=n,r}}():void 0),Cr=br.IteratorPrototype,Nr=br.BUGGY_SAFARI_ITERATORS,kr=Ot("iterator"),Dr="keys",Fr="values",Hr="entries",wr=function(){return this},Gr=function(e,t,r,n,o,a,i){xr(r,t,n);var s,l,c,u=function(e){return e===o&&m?m:!Nr&&e in g?g[e]:e===Dr?function(){return new r(this,e)}:e===Fr?function(){return new r(this,e)}:e===Hr?function(){return new r(this,e)}:function(){return new r(this)}},d=!1,g=e.prototype,p=g[kr]||g["@@iterator"]||o&&g[o],m=!Nr&&p||u(o),y="Array"==t?g.entries||p:p;if(y&&(s=Tr(y.call(new e)),Cr!==Object.prototype&&s.next&&(Tr(s)!==Cr&&(jr?jr(s,Cr):"function"!=typeof s[kr]&&pe(s,kr,wr)),Mr(s,t+" Iterator",!0))),o==Fr&&p&&p.name!==Fr&&(d=!0,m=function(){return p.call(this)}),g[kr]!==m&&pe(g,kr,m),hr[t]=m,o)if(l={values:u(Fr),keys:a?m:u(Dr),entries:u(Hr)},i)for(c in l)(Nr||d||!(c in g))&&Ge(g,c,l[c]);else pt({target:t,proto:!0,forced:Nr||d},l);return l},Ur="Array Iterator",$r=we.set,Yr=we.getterFor(Ur),zr=Gr(Array,"Array",function(e,t){$r(this,{type:Ur,target:J(e),index:0,kind:t})},function(){var e=Yr(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==r?{value:n,done:!1}:"values"==r?{value:t[n],done:!1}:{value:[n,t[n]],done:!1}},"values");hr.Arguments=hr.Array,nr("keys"),nr("values"),nr("entries");var Vr=wt("Array","keys"),Wr=It.some,qr=_t("some"),Br=Ct("some");pt({target:"Array",proto:!0,forced:!qr||!Br},{some:function(e){return Wr(this,e,1<arguments.length?arguments[1]:void 0)}});var Kr=wt("Array","some"),Zr=Object.assign,Jr=Object.defineProperty,Xr=!Zr||w(function(){if(G&&1!==Zr({b:1},Zr(Jr({},"a",{enumerable:!0,get:function(){Jr(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach(function(e){t[e]=e}),7!=Zr({},e)[r]||Ut(Zr({},t)).join("")!=n})?function(e){for(var t=ft(e),r=arguments.length,n=1,o=rt.f,a=f.f;r>n;)for(var i,s=K(arguments[n++]),l=o?Ut(s).concat(o(s)):Ut(s),c=l.length,u=0;c>u;)i=l[u++],(!G||a.call(s,i))&&(t[i]=s[i]);return t}:Zr;pt({target:"Object",stat:!0,forced:Object.assign!==Xr},{assign:Xr});var Qr=Ue.Object.assign,en=f.f,tn=function(e){return function(t){for(var r,n=J(t),o=Ut(n),a=o.length,s=0,l=[];a>s;)r=o[s++],(!G||en.call(n,r))&&l.push(e?[r,n[r]]:n[r]);return l}},rn={entries:tn(!0),values:tn(!1)},nn=rn.entries;pt({target:"Object",stat:!0},{entries:function(e){return nn(e)}});var on=Ue.Object.entries;pt({target:"Number",stat:!0},{isInteger:function(e){return!X(e)&&isFinite(e)&&L(e)===e}});var an=Ue.Number.isInteger;pt({target:"Math",stat:!0},{sign:x||function(e){return 0==(e=+e)||e!=e?e:0>e?-1:1}});var sn=Ue.Math.sign,ln=Ot("toStringTag"),cn={};cn[ln]="z";var un="[object z]"===cn+"",dn=Ot("toStringTag"),gn="Arguments"==q(function(){return arguments}()),pn=function(e,t){try{return e[t]}catch(e){}},mn=function(e){var t,r,n;return e===void 0?"Undefined":null===e?"Null":"string"==typeof(r=pn(t=Object(e),dn))?r:gn?q(t):"Object"==(n=q(t))&&"function"==typeof t.callee?"Arguments":n},yn=function(){return"[object "+mn(this)+"]"};un||Ge(Object.prototype,"toString",yn,{unsafe:!0});var fn=function(e){return function(t,r){var n,o,a=Z(t)+"",i=ze(r),s=a.length;return 0>i||i>=s?e?"":void 0:(n=a.charCodeAt(i),55296>n||56319<n||i+1===s||56320>(o=a.charCodeAt(i+1))||57343<o?e?a.charAt(i):n:e?a.slice(i,i+2):(n-55296<<10)+(o-56320)+65536)}},hn={codeAt:fn(!1),charAt:fn(!0)},An=hn.charAt,En="String Iterator",vn=we.set,Tn=we.getterFor(En);Gr(String,"String",function(e){vn(this,{type:En,string:e+"",index:0})},function(){var e,t=Tn(this),r=t.string,n=t.index;return n>=r.length?{value:void 0,done:!0}:(e=An(r,n),t.index+=e.length,{value:e,done:!1})});var Sn={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},On=Ot("iterator"),bn=Ot("toStringTag"),Pn=zr.values;for(var Rn in Sn){var Mn=H[Rn],In=Mn&&Mn.prototype;if(In){if(In[On]!==Pn)try{pe(In,On,Pn)}catch(e){In[On]=Pn}if(In[bn]||pe(In,bn,Rn),Sn[Rn])for(var _n in zr)if(In[_n]!==zr[_n])try{pe(In,_n,zr[_n])}catch(e){In[_n]=zr[_n]}}}var xn=H.Promise,Ln=Ot("species"),jn=function(e,t,r){if(!(e instanceof t))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation");return e},Cn=Ot("iterator"),Nn=Array.prototype,kn=function(e){return e!==void 0&&(hr.Array===e||Nn[Cn]===e)},Dn=Ot("iterator"),Fn=function(e){if(e!=null)return e[Dn]||e["@@iterator"]||hr[mn(e)]},Hn=function(e,t,r,n){try{return n?t(ce(r)[0],r[1]):t(r)}catch(t){var o=e["return"];throw void 0!==o&&ce(o.call(e)),t}},wn=e(function(e){var t=function(e,t){this.stopped=e,this.result=t},r=e.exports=function(e,r,n,o,a){var i,s,l,c,u,d,g,p=yt(r,n,o?2:1);if(a)i=e;else{if(s=Fn(e),"function"!=typeof s)throw TypeError("Target is not iterable");if(kn(s)){for(l=0,c=Ve(e.length);c>l;l++)if(u=o?p(ce(g=e[l])[0],g[1]):p(e[l]),u&&u instanceof t)return u;return new t(!1)}i=s.call(e)}for(d=i.next;!(g=d.call(i)).done;)if(u=Hn(i,p,g.value,o),"object"==typeof u&&u&&u instanceof t)return u;return new t(!1)};r.stop=function(e){return new t(!0,e)}}),Gn=Ot("iterator"),Un=!1;try{var $n=0,Yn={next:function(){return{done:!!$n++}},return:function(){Un=!0}};Yn[Gn]=function(){return this},Array.from(Yn,function(){throw 2})}catch(e){}var zn,Vn,Wn,qn=function(e,t){if(!t&&!Un)return!1;var r=!1;try{var n={};n[Gn]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},Bn=Ot("species"),Kn=function(e,t){var r,n=ce(e).constructor;return n===void 0||(r=ce(n)[Bn])==null?t:mt(r)},Zn=Ye("navigator","userAgent")||"",Jn=/(iphone|ipod|ipad).*applewebkit/i.test(Zn),Xn=H.location,Qn=H.setImmediate,eo=H.clearImmediate,to=H.process,ro=H.MessageChannel,no=H.Dispatch,oo=0,ao={},io="onreadystatechange",so=function(e){if(ao.hasOwnProperty(e)){var t=ao[e];delete ao[e],t()}},lo=function(e){return function(){so(e)}},co=function(e){so(e.data)},uo=function(e){H.postMessage(e+"",Xn.protocol+"//"+Xn.host)};Qn&&eo||(Qn=function(e){for(var t=[],r=1;arguments.length>r;)t.push(arguments[r++]);return ao[++oo]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},zn(oo),oo},eo=function(e){delete ao[e]},"process"==q(to)?zn=function(e){to.nextTick(lo(e))}:no&&no.now?zn=function(e){no.now(lo(e))}:ro&&!Jn?(Vn=new ro,Wn=Vn.port2,Vn.port1.onmessage=co,zn=yt(Wn.postMessage,Wn,1)):!H.addEventListener||"function"!=typeof postMessage||H.importScripts||w(uo)?io in oe("script")?zn=function(e){Yt.appendChild(oe("script"))[io]=function(){Yt.removeChild(this),so(e)}}:zn=function(e){setTimeout(lo(e),0)}:(zn=uo,H.addEventListener("message",co,!1)));var go,po,mo,yo,fo,ho,Ao,Eo,vo={set:Qn,clear:eo},To=le.f,So=vo.set,Oo=H.MutationObserver||H.WebKitMutationObserver,bo=H.process,Po=H.Promise,Ro="process"==q(bo),Mo=To(H,"queueMicrotask"),Io=Mo&&Mo.value;Io||(go=function(){var e,t;for(Ro&&(e=bo.domain)&&e.exit();po;){t=po.fn,po=po.next;try{t()}catch(e){throw po?yo():mo=void 0,e}}mo=void 0,e&&e.enter()},Ro?yo=function(){bo.nextTick(go)}:Oo&&!Jn?(fo=!0,ho=document.createTextNode(""),new Oo(go).observe(ho,{characterData:!0}),yo=function(){ho.data=fo=!fo}):Po&&Po.resolve?(Ao=Po.resolve(void 0),Eo=Ao.then,yo=function(){Eo.call(Ao,go)}):yo=function(){So.call(H,go)});var _o,xo,Lo=Io||function(e){var t={fn:e,next:void 0};mo&&(mo.next=t),po||(po=t,yo()),mo=t},jo=function(e){var t,r;this.promise=new e(function(e,n){if(t!==void 0||r!==void 0)throw TypeError("Bad Promise constructor");t=e,r=n}),this.resolve=mt(t),this.reject=mt(r)},Co={f:function(e){return new jo(e)}},No=function(e,t){if(ce(e),X(t)&&t.constructor===e)return t;var r=Co.f(e),n=r.resolve;return n(t),r.promise},ko=function(e,t){var r=H.console;r&&r.error&&(1===arguments.length?r.error(e):r.error(e,t))},Do=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Fo=H.process,Ho=Fo&&Fo.versions,wo=Ho&&Ho.v8;wo?(_o=wo.split("."),xo=_o[0]+_o[1]):Zn&&(_o=Zn.match(/Edge\/(\d+)/),(!_o||74<=_o[1])&&(_o=Zn.match(/Chrome\/(\d+)/),_o&&(xo=_o[1])));var Go,Uo,$o,Yo,zo=xo&&+xo,Vo=vo.set,Wo=Ot("species"),qo="Promise",Bo=we.get,Ko=we.set,Zo=we.getterFor(qo),Jo=xn,Xo=H.TypeError,Qo=H.document,ea=H.process,ta=Ye("fetch"),ra=Co.f,na=ra,oa="process"==q(ea),aa=!!(Qo&&Qo.createEvent&&H.dispatchEvent),ia="unhandledrejection",sa=0,la=1,ca=1,ua=2,da=dt(qo,function(){var e=Se(Jo)!==Jo+"";if(!e){if(66===zo)return!0;if(!oa&&"function"!=typeof PromiseRejectionEvent)return!0}if(51<=zo&&/native code/.test(Jo))return!1;var t=Jo.resolve(1),r=function(e){e(function(){},function(){})},n=t.constructor={};return n[Wo]=r,!(t.then(function(){})instanceof r)}),ga=da||!qn(function(e){Jo.all(e)["catch"](function(){})}),pa=function(e){var t;return!!(X(e)&&"function"==typeof(t=e.then))&&t},ma=function(e,t,r){if(!t.notified){t.notified=!0;var n=t.reactions;Lo(function(){for(var o=t.value,a=t.state==la,i=0;n.length>i;){var s,l,c,u=n[i++],d=a?u.ok:u.fail,g=u.resolve,p=u.reject,m=u.domain;try{d?(!a&&(t.rejection===ua&&Aa(e,t),t.rejection=ca),!0===d?s=o:(m&&m.enter(),s=d(o),m&&(m.exit(),c=!0)),s===u.promise?p(Xo("Promise-chain cycle")):(l=pa(s))?l.call(s,g,p):g(s)):p(o)}catch(e){m&&!c&&m.exit(),p(e)}}t.reactions=[],t.notified=!1,r&&!t.rejection&&fa(e,t)})}},ya=function(e,t,r){var n,o;aa?(n=Qo.createEvent("Event"),n.promise=t,n.reason=r,n.initEvent(e,!1,!0),H.dispatchEvent(n)):n={promise:t,reason:r},(o=H["on"+e])?o(n):e===ia&&ko("Unhandled promise rejection",r)},fa=function(e,t){Vo.call(H,function(){var r,n=t.value,o=ha(t);if(o&&(r=Do(function(){oa?ea.emit("unhandledRejection",n,e):ya(ia,e,n)}),t.rejection=oa||ha(t)?ua:ca,r.error))throw r.value})},ha=function(e){return e.rejection!==ca&&!e.parent},Aa=function(e,t){Vo.call(H,function(){oa?ea.emit("rejectionHandled",e):ya("rejectionhandled",e,t.value)})},Ea=function(e,t,r,n){return function(o){e(t,r,o,n)}},va=function(e,t,r,n){t.done||(t.done=!0,n&&(t=n),t.value=r,t.state=2,ma(e,t,!0))},Ta=function(e,t,r,n){if(!t.done){t.done=!0,n&&(t=n);try{if(e===r)throw Xo("Promise can't be resolved itself");var o=pa(r);o?Lo(function(){var n={done:!1};try{o.call(r,Ea(Ta,e,n,t),Ea(va,e,n,t))}catch(r){va(e,n,r,t)}}):(t.value=r,t.state=la,ma(e,t,!1))}catch(r){va(e,{done:!1},r,t)}}};da&&(Jo=function(e){jn(this,Jo,qo),mt(e),Go.call(this);var t=Bo(this);try{e(Ea(Ta,this,t),Ea(va,this,t))}catch(e){va(this,t,e)}},Go=function(){Ko(this,{type:qo,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:sa,value:void 0})},Go.prototype=function(e,t,r){for(var n in t)Ge(e,n,t[n],r);return e}(Jo.prototype,{then:function(e,t){var r=Zo(this),n=ra(Kn(this,Jo));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=oa?ea.domain:void 0,r.parent=!0,r.reactions.push(n),r.state!=sa&&ma(this,r,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),Uo=function(){var e=new Go,t=Bo(e);this.promise=e,this.resolve=Ea(Ta,e,t),this.reject=Ea(va,e,t)},Co.f=ra=function(e){return e===Jo||e===$o?new Uo(e):na(e)},"function"==typeof xn&&(Yo=xn.prototype.then,Ge(xn.prototype,"then",function(e,t){var r=this;return new Jo(function(e,t){Yo.call(r,e,t)}).then(e,t)},{unsafe:!0}),"function"==typeof ta&&pt({global:!0,enumerable:!0,forced:!0},{fetch:function(){return No(Jo,ta.apply(H,arguments))}}))),pt({global:!0,wrap:!0,forced:da},{Promise:Jo}),Mr(Jo,qo,!1),function(e){var t=Ye(e),r=ge.f;G&&t&&!t[Ln]&&r(t,Ln,{configurable:!0,get:function(){return this}})}(qo),$o=Ye(qo),pt({target:qo,stat:!0,forced:da},{reject:function(e){var t=ra(this);return t.reject.call(void 0,e),t.promise}}),pt({target:qo,stat:!0,forced:da},{resolve:function(e){return No(this,e)}}),pt({target:qo,stat:!0,forced:ga},{all:function(e){var t=this,r=ra(t),n=r.resolve,o=r.reject,a=Do(function(){var r=mt(t.resolve),a=[],i=0,s=1;wn(e,function(e){var l=i++,c=!1;a.push(void 0),s++,r.call(t,e).then(function(e){c||(c=!0,a[l]=e,--s||n(a))},o)}),--s||n(a)});return a.error&&o(a.value),r.promise},race:function(e){var t=this,r=ra(t),n=r.reject,o=Do(function(){var o=mt(t.resolve);wn(e,function(e){o.call(t,e).then(r.resolve,n)})});return o.error&&n(o.value),r.promise}}),pt({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=Co.f(t),n=r.resolve,o=r.reject,a=Do(function(){var r=mt(t.resolve),o=[],a=0,i=1;wn(e,function(e){var s=a++,l=!1;o.push(void 0),i++,r.call(t,e).then(function(e){l||(l=!0,o[s]={status:"fulfilled",value:e},--i||n(o))},function(t){l||(l=!0,o[s]={status:"rejected",reason:t},--i||n(o))})}),--i||n(o)});return a.error&&o(a.value),r.promise}});var Sa=!!xn&&w(function(){xn.prototype["finally"].call({then:function(){}},function(){})});pt({target:"Promise",proto:!0,real:!0,forced:Sa},{finally:function(t){var r=Kn(this,Ye("Promise")),e="function"==typeof t;return this.then(e?function(e){return No(r,t()).then(function(){return e})}:t,e?function(n){return No(r,t()).then(function(){throw n})}:t)}}),"function"!=typeof xn||xn.prototype["finally"]||Ge(xn.prototype,"finally",Ye("Promise").prototype["finally"]);var Oa=Ue.Promise,ba=we.set,Pa=we.getterFor("AggregateError"),Ra=function(e,t){var r=this;if(!(r instanceof Ra))return new Ra(e,t);jr&&(r=jr(new Error(t),Tr(r)));var n=[];return wn(e,n.push,n),G?ba(r,{errors:n,type:"AggregateError"}):r.errors=n,void 0!==t&&pe(r,"message",t+""),r};Ra.prototype=er(Error.prototype,{constructor:V(5,Ra),message:V(5,""),name:V(5,"AggregateError")}),G&&ge.f(Ra.prototype,"errors",{get:function(){return Pa(this).errors},configurable:!0}),pt({global:!0},{AggregateError:Ra}),pt({target:"Promise",stat:!0},{try:function(e){var t=Co.f(this),r=Do(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});pt({target:"Promise",stat:!0},{any:function(e){var t=this,r=Co.f(t),n=r.resolve,o=r.reject,a=Do(function(){var r=mt(t.resolve),a=[],i=0,s=1,l=!1;wn(e,function(e){var c=i++,u=!1;a.push(void 0),s++,r.call(t,e).then(function(e){u||l||(l=!0,n(e))},function(t){u||l||(u=!0,a[c]=t,--s||o(new(Ye("AggregateError"))(a,"No one promise resolved")))})}),--s||o(new(Ye("AggregateError"))(a,"No one promise resolved"))});return a.error&&o(a.value),r.promise}});var Ma=T(),Ia=T(),_a=Object.assign(function e(t){var r=Object.assign({},{amount:e.defaultAmount,currency:e.defaultCurrency,precision:e.defaultPrecision},t),n=r.amount,o=r.currency,a=r.precision;M(n),M(a);var i=e.globalLocale,s=e.globalFormat,l=e.globalRoundingMode,c=e.globalFormatRoundingMode,u=Object.assign({},e.globalExchangeRatesApi),d=function(t){var r=Object.assign({},Object.assign({},{amount:n,currency:o,precision:a},t),Object.assign({},{locale:this.locale},t));return Object.assign(e({amount:r.amount,currency:r.currency,precision:r.precision}),{locale:r.locale})},g=function(e){b(this.hasSameCurrency(e),"You must provide a Dinero instance with the same currency.",TypeError)};return{getAmount:function(){return n},getCurrency:function(){return o},getLocale:function(){return this.locale||i},setLocale:function(e){return d.call(this,{locale:e})},getPrecision:function(){return a},convertPrecision:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:c;return M(e),d.call(this,{amount:Ia.round(Ia.multiply(this.getAmount(),C(10,Ia.subtract(e,this.getPrecision()))),t),precision:e})},add:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return d.call(this,{amount:Ia.add(r[0].getAmount(),r[1].getAmount()),precision:r[0].getPrecision()})},subtract:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return d.call(this,{amount:Ia.subtract(r[0].getAmount(),r[1].getAmount()),precision:r[0].getPrecision()})},multiply:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:l;return d.call(this,{amount:Ia.round(Ia.multiply(this.getAmount(),e),t)})},divide:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:l;return d.call(this,{amount:Ia.round(Ia.divide(this.getAmount(),e),t)})},percentage:function(e){return P(e),this.multiply(Ia.divide(e,100))},allocate:function(e){var t=this;R(e);for(var r=e.reduce(function(e,t){return Ia.add(e,t)}),n=this.getAmount(),o=e.map(function(e){var o=L(Ia.divide(Ia.multiply(t.getAmount(),e),r));return n=Ia.subtract(n,o),d.call(t,{amount:o})}),a=0;0<n;)0<e[a]&&(o[a]=o[a].add(d.call(this,{amount:1})),n=Ia.subtract(n,1)),a+=1;return o},convert:function(e){var t=this,r=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},n=r.endpoint,o=void 0===n?u.endpoint:n,a=r.propertyPath,i=void 0===a?u.propertyPath||"rates.{{to}}":a,s=r.headers,c=void 0===s?u.headers:s,g=r.roundingMode,p=void 0===g?l:g,m=Object.assign({},{endpoint:o,propertyPath:i,headers:c,roundingMode:p});return O(m).getExchangeRate(this.getCurrency(),e).then(function(r){return b(!A(r),"No rate was found for the destination currency \"".concat(e,"\"."),TypeError),d.call(t,{amount:Ia.round(Ia.multiply(t.getAmount(),parseFloat(r)),m.roundingMode),currency:e})})},equalsTo:function(e){return this.hasSameAmount(e)&&this.hasSameCurrency(e)},lessThan:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return r[0].getAmount()<r[1].getAmount()},lessThanOrEqual:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return r[0].getAmount()<=r[1].getAmount()},greaterThan:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return r[0].getAmount()>r[1].getAmount()},greaterThanOrEqual:function(t){g.call(this,t);var r=e.normalizePrecision([this,t]);return r[0].getAmount()>=r[1].getAmount()},isZero:function(){return 0===this.getAmount()},isPositive:function(){return 0<=this.getAmount()},isNegative:function(){return 0>this.getAmount()},hasSubUnits:function(){return 0!==Ia.modulo(this.getAmount(),C(10,a))},hasCents:function(){return 0!==Ia.modulo(this.getAmount(),C(10,a))},hasSameCurrency:function(e){return this.getCurrency()===e.getCurrency()},hasSameAmount:function(t){var r=e.normalizePrecision([this,t]);return r[0].getAmount()===r[1].getAmount()},toFormat:function(){var e=0<arguments.length&&arguments[0]!==void 0?arguments[0]:s,t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:c,r=S(e);return this.toRoundedUnit(r.getMinimumFractionDigits(),t).toLocaleString(this.getLocale(),{currencyDisplay:r.getCurrencyDisplay(),useGrouping:r.getUseGrouping(),minimumFractionDigits:r.getMinimumFractionDigits(),style:r.getStyle(),currency:this.getCurrency()})},toUnit:function(){return Ia.divide(this.getAmount(),C(10,a))},toRoundedUnit:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:c,r=C(10,e);return Ia.divide(Ia.round(Ia.multiply(this.toUnit(),r),t),r)},toObject:function(){return{amount:n,currency:o,precision:a}},toJSON:function(){return this.toObject()}}},{defaultAmount:0,defaultCurrency:"USD",defaultPrecision:2},{globalLocale:"en-US",globalFormat:"$0,0.00",globalRoundingMode:"HALF_EVEN",globalFormatRoundingMode:"HALF_AWAY_FROM_ZERO",globalExchangeRatesApi:{endpoint:void 0,headers:void 0,propertyPath:void 0}},{normalizePrecision:function(e){var t=e.reduce(function(e,t){return j(e.getPrecision(),t.getPrecision())});return e.map(function(e){return e.getPrecision()===t?e:e.convertPrecision(t)})},minimum:function(e){var t=r(e),n=t[0],o=t.slice(1),a=n;return o.forEach(function(e){a=a.lessThan(e)?a:e}),a},maximum:function(e){var t=r(e),n=t[0],o=t.slice(1),a=n;return o.forEach(function(e){a=a.greaterThan(e)?a:e}),a}});return _a});