| 1 |
var A=s=>{throw TypeError(s)};var Y=(s,t,o)=>t.has(s)||A("Cannot "+o);var f=(s,t,o)=>(Y(s,t,"read from private field"),o?o.call(s):t.get(s)),y=(s,t,o)=>t.has(s)?A("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,o),$=(s,t,o,e)=>(Y(s,t,"write to private field"),e?e.call(s,o):t.set(s,o),o);import{A as v,a as V,t as h}from"./Translator.js?ver=1.3.19";import{A as S}from"./Arr.js?ver=1.3.19";import{d as I}from"./dayjs.min.js?ver=1.3.19";var g,M,b,w,_,N,j,F;const i=class i{static setLocale(){var o;$(i,w,f(i,w).replace("_","-"));const t=v.get("shop",{});$(i,N,t.decimal_separator||null),$(i,_,f(this,w)),t.decimal_separator?$(i,_,t.decimal_separator==="comma"?"de-DE":"en-US"):$(i,_,navigator.language||((o=navigator.languages)==null?void 0:o[0])||"en-US")}static formatNumber(t,o=!0,e=!1,r=null){if(!t&&e)return"";const c=S.get(f(i,M),r||"",f(i,g));if(t?t=(t/100).toFixed(2):t="0.00",!o)return t;let a=new Intl.NumberFormat(f(i,_),{minimumFractionDigits:2,maximumFractionDigits:2}).format(t);return a=V(a),o?f(i,b)==="before"?`${c}${a}`:`${a}${c}`:a}static formatScaled(t,o=!0,e=!1,r=""){if(!t&&e)return"";const c=S.get(f(i,M),r||"",f(i,g));let a,l="";if(Math.abs(t)>=1e11)t=t/1e9,l="B";else if(Math.abs(t)>=1e8)t=t/1e6,l="M";else if(Math.abs(t)>=1e5)t=t/1e3,l="K";else return i.formatNumber(t,o,e,c);if(a=i.formatNumber(t,!1,e,c),!o)return a;const d=`${a}${l}`;return f(i,b)==="before"?`${c}${d}`:`${d}${c}`}static formatScaledChart(t,o=""){if(!t)return"0";const e=S.get(f(i,M),o||"",f(i,g)).replace(/&#(\d+);/g,(l,d)=>String.fromCharCode(d)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ");let r="";Math.abs(t)>=1e11?(t=t/1e9,r="B"):Math.abs(t)>=1e8?(t=t/1e6,r="M"):Math.abs(t)>=1e5&&(t=t/1e3,r="K");const a=`${new Intl.NumberFormat(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}).format(t/100)}${r}`;return f(i,b)==="before"?`${e}${a}`:`${a}${e}`}static scaled(t,o=!0,e=!1,r=""){return i.formatScaled(t*100,o,e,r)}static scaledChart(t,o=!0,e=!1,r=""){return i.formatScaledChart(t*100,r)}static formatBulk(t,o=!1,e=f(i,g),r=!1){return t.map(c=>o?i.formatScaled(c,e,r):i.formatNumber(c,e,r))}static get currencySign(){return f(i,g)}static get currencyPosition(){return f(i,b)}static get locale(){return f(i,_)}static generateVolumeSummary(t,o=!1){if(o){const e=I(),r=e.format("YYYY-MM"),c=e.subtract(1,"month").format("YYYY-MM"),a=e.format("MMMM"),l=e.subtract(1,"month").format("MMMM"),d=t[r]||{current:0,yoy_growth:0},n=t[c]||{current:0,yoy_growth:0};n.yoy_growth=Number(n.yoy_growth||0),d.yoy_growth=Number(d.yoy_growth||0);const u=i.formatScaled(n.current),k=i.formatScaled(d.current),D=n.yoy_growth>=0?h("Increase of %s year-over-year",n.yoy_growth.toFixed(1)+"%"):h("Decrease of %s year-over-year",Math.abs(n.yoy_growth).toFixed(1)+"%");return h("%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">${l}</span>`,`<span class="font-bold fct-custom-tooltip">${u}<span class="fct-custom-tooltip-content">${i.formatNumber(n.current)}</span></span>`,`<span class="font-bold ${n.yoy_growth>=0?"text-green-500":"text-red-500"}">${D} </span>`,a,`<span class="font-bold fct-custom-tooltip">${k}<span class="fct-custom-tooltip-content">${i.formatNumber(d.current)}</span></span>`)}else{const e=I(),r=e.year(),c=Math.floor((e.month()+3)/3);e.format("MMMM");const a=c*3-1;let l=I().year(r).month(a).endOf("month");c===1&&(l=l.month(2).endOf("month")),c===2&&(l=l.month(5).endOf("month")),c===3&&(l=l.month(8).endOf("month")),c===4&&(l=l.month(11).endOf("month"));const d=l.diff(e,"day"),n=Object.keys(t)[0],u=Object.values(t)[0],k=i.formatScaled(u.current);u.yy_growth=Number(u.yy_growth||0);const D=u.yy_growth>=0?h("Increase of %s year-over-year",u.yy_growth.toFixed(1)+"%"):h("Decrease of %s year-over-year",Math.abs(u.yy_growth).toFixed(1)+"%");let O=`Q${c}-${r}`;const m=S.get(t,O,{current:0,prev_year:0,yy_growth:0});m.yy_growth=Number(m.yy_growth||0);const C=i.formatScaled(m.current);let p=0;m.current===0&&u.current===0?p=0:m.current===0?p=-100:(p=(m.current-u.current)/m.current*100,isNaN(p)&&(p=0));const P=p>=0?h("a increase of %1$s compared to %2$s",p.toFixed(1)+"%",n):h("a decrease of %1$s compared to %2$s",Math.abs(p).toFixed(1)+"%",n);return h("%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">${n}</span>`,`<span class="font-bold fct-custom-tooltip">${k}<span class="fct-custom-tooltip-content">${i.formatNumber(u.current)}</span></span>`,`<span class="font-bold ${u.yy_growth>=0?"text-green-500":"text-red-500"}">${D} </span>`,d,`Q${c}`,`<span class="font-bold fct-custom-tooltip">${C}<span class="fct-custom-tooltip-content">${i.formatNumber(m.current)}</span></span>`,`<span class="font-bold ${p>=0?"text-green-500":"text-red-500"}">${P} </span>`,`<span class="font-bold ${m.yy_growth>=0?"text-green-500":"text-red-500"}">${m.yy_growth}% </span>`)}}};g=new WeakMap,M=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,N=new WeakMap,j=new WeakSet,F=function(t){return t},y(i,j),y(i,g,v.get("shop.currency_sign","$")),y(i,M,v.get("currency_signs",{})),y(i,b,v.get("shop.currency_position","before")),y(i,w,v.get("wp_locale","en-US")),y(i,_,null),y(i,N);let x=i;x.setLocale();function B(s,t){var c;let o=[],e,r;if(s){for(const a of s)if(a!=null&&a.detail){if(e={},e.id=a.detail.id,e.order_id=t,e.post_id=a.ID,e.object_id=a.detail.default_variation_id,e.featured_media=(c=a.detail.featured_media)==null?void 0:c.url,e.price=a.detail.item_price,e.unit_price=a.detail.item_price,e.title=a.post_title,e.post_title=a.post_title,e.quantity=1,e.fulfillment_type=a.detail.fulfillment_type,e.manage_stock=a.detail.manage_stock,e.stockStatus=a.detail.manage_stock==1?a.detail.stock_availability:"in-stock",e.soldIndividually=a.detail.sold_individually,e.settings=a.detail.settings,e.checked=!1,e.min_price=a.detail.min_price,e.max_price=a.detail.max_price,a.detail.variants&&a.detail.variants.length){e.children=[];for(const l in a.detail.variants){r=a.detail.variants[l],e.title=r.variation_title;let d=a.detail.default_variation_id==r.id;if(!d&&a.detail.variation_type==="simple"&&(d=!0),d&&(e.available=r.manage_stock.toString()==="1"?r.available:1/0,e.price=r.item_price,e.unit_price=r.item_price,e.object_id=r.id,e.cost=r.item_cost,e.other_info=r.other_info,e.payment_type=r.other_info.payment_type,e.bundle_items=r.bundle_children),a.detail.variants&&a.detail.variation_type==="simple_variations"){let n={};r=a.detail.variants[l],n.id=r.id,n.order_id=t,n.post_id=r.post_id,n.object_id=r.id,n.price=r.item_price,n.unit_price=r.item_price,n.item_cost=r.item_cost,n.featured_media=r.media&&r.media.meta_value&&r.media.meta_value[0]?r.media.meta_value[0].url:e.featured_media,n.quantity=1,n.post_title=a.post_title,n.title=r.variation_title,n.fulfillment_type=a.detail.fulfillment_type,n.manage_stock=r.manage_stock,n.stockStatus=r.manage_stock==1?r.stock_status:"in-stock",n.available=r.manage_stock==1?r.available:1/0,n.soldIndividually=r.sold_individually,n.settings=r.settings,n.checked=!1,n.disable=q(n),n.other_info=r.other_info,n.payment_type=r.other_info.payment_type,n.bundle_items=r.bundle_children,e.children.push(n)}}}e.disable=q(e),o.push(e)}}return o}const q=s=>!(s.stockStatus==="in-stock"&&(Array.isArray(s.children)&&s.children.length===0||!s.children)),K=(s,t,o=!1)=>!s&&o?"":(s||(s="0.00"),v.get("shop.currency_sign")+" "+s),Q=(s,t,o=!1)=>x.formatNumber(s,t,o),E=s=>!s.item_price||!s.item_cost?"--":((s.item_price-s.item_cost)/s.item_price*100).toFixed(2)+"% ",G=s=>{if(!s.item_price||!s.item_cost)return"--";const t=s.item_price-s.item_cost;return x.formatNumber(t*100,!0)},H=s=>s.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),R=s=>{const t=new Set;return s.order_items.forEach(o=>{(Number(o.object_id)!==0||o.object_id===null)&&t.add(o.object_id)}),t.size};export{x as C,H as a,K as b,G as c,E as d,Q as f,R as g,B as p}; |