| 1 |
var V=f=>{throw TypeError(f)};var D=(f,t,e)=>t.has(f)||V("Cannot "+e);var F=(f,t,e)=>(D(f,t,"read from private field"),e?e.call(f):t.get(f)),x=(f,t,e)=>t.has(f)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,e),S=(f,t,e,s)=>(D(f,t,"write to private field"),s?s.call(f,e):t.set(f,e),e),d=(f,t,e)=>(D(f,t,"access private method"),e);import{A as v}from"./Arr.js?ver=1.5.4";import{d as Y}from"./dayjs.min.js?ver=1.5.4";import{A as w,a as L,t as p}from"./Translator.js?ver=1.5.4";var h,N,g,$,O;const r=class r{static setLocale(){var s;const t=w.get("wp_locale","en-US").replace("_","-"),e=w.get("shop",{});S(r,N,e.decimal_separator||null),S(r,h,t),e.decimal_separator?S(r,h,e.decimal_separator==="comma"?"de-DE":"en-US"):S(r,h,navigator.language||((s=navigator.languages)==null?void 0:s[0])||"en-US")}static formatForOrder(t,e,s=!0,i=!1){let a=null;return typeof e=="string"?a=e||null:e&&e.currency&&(a=e.currency),r.formatNumber(t,s,i,a)}static formatNumber(t,e=!0,s=!1,i=null){var n;if(!t&&s)return"";const{signs:a,sign:u,position:c}=d(n=r,g,$).call(n),l=v.get(a,i||"",u);let o=new Intl.NumberFormat(F(r,h),{minimumFractionDigits:0,maximumFractionDigits:2}).format(t?t/100:0);return o=L(o),e?c==="before"?`${l}${o}`:`${o}${l}`:o}static formatScaled(t,e=!0,s=!1,i=""){var M;if(!t&&s)return"";const{signs:a,sign:u,position:c}=d(M=r,g,$).call(M),l=v.get(a,i||"",u);let o,n="";if(Math.abs(t)>=1e11)t=t/1e9,n="B";else if(Math.abs(t)>=1e8)t=t/1e6,n="M";else if(Math.abs(t)>=1e5)t=t/1e3,n="K";else return r.formatNumber(t,e,s,l);if(o=r.formatNumber(t,!1,s,l),!e)return o;const b=`${o}${n}`;return c==="before"?`${l}${b}`:`${b}${l}`}static formatScaledChart(t,e=""){var n;if(!t)return"0";const{signs:s,sign:i,position:a}=d(n=r,g,$).call(n),u=v.get(s,e||"",i);let c="";Math.abs(t)>=1e11?(t=t/1e9,c="B"):Math.abs(t)>=1e8?(t=t/1e6,c="M"):Math.abs(t)>=1e5&&(t=t/1e3,c="K");const o=`${new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t/100)}${c}`;return a==="before"?`${u}${o}`:`${o}${u}`}static scaled(t,e=!0,s=!1,i=""){return r.formatScaled(t*100,e,s,i)}static scaledChart(t,e=!0,s=!1,i=""){return r.formatScaledChart(t*100,i)}static formatBulk(t,e=!1,s=(a=>d(a=r,g,$).call(a))().sign,i=!1){return t.map(u=>e?r.formatScaled(u,!0,i,s):r.formatNumber(u,!0,i,s))}static get currencySign(){var t;return d(t=r,g,$).call(t).sign}static get currencyPosition(){var t;return d(t=r,g,$).call(t).position}static get locale(){return F(r,h)}static generateVolumeSummary(t,e=!1){if(e){const s=Y(),i=s.format("YYYY-MM"),a=s.subtract(1,"month").format("YYYY-MM"),u=s.format("MMMM"),c=s.subtract(1,"month").format("MMMM"),l=t[i]||{current:0,yoy_growth:0},o=t[a]||{current:0,yoy_growth:0};o.yoy_growth=Number(o.yoy_growth||0),l.yoy_growth=Number(l.yoy_growth||0);const n=r.formatScaled(o.current),b=r.formatScaled(l.current),M=o.yoy_growth>=0?p("Increase of %s year-over-year",o.yoy_growth.toFixed(1)+"%"):p("Decrease of %s year-over-year",Math.abs(o.yoy_growth).toFixed(1)+"%");return p("%1$s gross volume was %2$s, a %3$s. Gross volume for the month of %4$s so far is %5$s. Here's the trend over the previous 12 months.",`<span class="font-bold">${c}</span>`,`<span class="font-bold fct-custom-tooltip">${n}<span class="fct-custom-tooltip-content">${r.formatNumber(o.current)}</span></span>`,`<span class="font-bold ${o.yoy_growth>=0?"text-green-500":"text-red-500"}">${M} </span>`,u,`<span class="font-bold fct-custom-tooltip">${b}<span class="fct-custom-tooltip-content">${r.formatNumber(l.current)}</span></span>`)}else{const s=Y(),i=s.year(),a=Math.floor((s.month()+3)/3);s.format("MMMM");const u=a*3-1;let c=Y().year(i).month(u).endOf("month");a===1&&(c=c.month(2).endOf("month")),a===2&&(c=c.month(5).endOf("month")),a===3&&(c=c.month(8).endOf("month")),a===4&&(c=c.month(11).endOf("month"));const l=c.diff(s,"day"),o=Object.keys(t)[0],n=Object.values(t)[0],b=r.formatScaled(n.current);n.yy_growth=Number(n.yy_growth||0);const M=n.yy_growth>=0?p("Increase of %s year-over-year",n.yy_growth.toFixed(1)+"%"):p("Decrease of %s year-over-year",Math.abs(n.yy_growth).toFixed(1)+"%");let A=`Q${a}-${i}`;const m=v.get(t,A,{current:0,prev_year:0,yy_growth:0});m.yy_growth=Number(m.yy_growth||0);const q=r.formatScaled(m.current);let y=0;m.current===0&&n.current===0?y=0:m.current===0?y=-100:(y=(m.current-n.current)/m.current*100,isNaN(y)&&(y=0));const C=y>=0?p("a increase of %1$s compared to %2$s",y.toFixed(1)+"%",o):p("a decrease of %1$s compared to %2$s",Math.abs(y).toFixed(1)+"%",o);return p("%1$s gross volume was %2$s, a %3$s. With %4$s days left in %5$s, Gross volume is %6$s for the quarter, %7$s and %8$s year-over-year",`<span class="font-bold">${o}</span>`,`<span class="font-bold fct-custom-tooltip">${b}<span class="fct-custom-tooltip-content">${r.formatNumber(n.current)}</span></span>`,`<span class="font-bold ${n.yy_growth>=0?"text-green-500":"text-red-500"}">${M} </span>`,l,`Q${a}`,`<span class="font-bold fct-custom-tooltip">${q}<span class="fct-custom-tooltip-content">${r.formatNumber(m.current)}</span></span>`,`<span class="font-bold ${y>=0?"text-green-500":"text-red-500"}">${C} </span>`,`<span class="font-bold ${m.yy_growth>=0?"text-green-500":"text-red-500"}">${m.yy_growth}% </span>`)}}};h=new WeakMap,N=new WeakMap,g=new WeakSet,$=function(){return{signs:w.get("currency_signs",{}),sign:w.get("shop.currency_sign","$"),position:w.get("shop.currency_position","before")}},O=function(t){return t},x(r,g),x(r,h,null),x(r,N),w.onShopUpdate(()=>r.setLocale());let I=r;I.setLocale();export{I as C}; |