PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / assets / chunks / productService.js

productService.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.27, at assets/chunks/productService.js

2 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var A=i=>{throw TypeError(i)};var Y=(i,t,s)=>t.has(i)||A("Cannot "+s);var f=(i,t,s)=>(Y(i,t,"read from private field"),s?s.call(i):t.get(i)),y=(i,t,s)=>t.has(i)?A("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),$=(i,t,s,e)=>(Y(i,t,"write to private field"),e?e.call(i,s):t.set(i,s),s);import{A as v,a as V,t as h}from"./Translator.js?ver=1.3.27";import{A as w}from"./Arr.js?ver=1.3.27";import{d as I}from"./dayjs.min.js?ver=1.3.27";var g,M,b,N,_,x,j,F;const o=class o{static setLocale(){var s;$(o,N,f(o,N).replace("_","-"));const t=v.get("shop",{});$(o,x,t.decimal_separator||null),$(o,_,f(this,N)),t.decimal_separator?$(o,_,t.decimal_separator==="comma"?"de-DE":"en-US"):$(o,_,navigator.language||((s=navigator.languages)==null?void 0:s[0])||"en-US")}static formatNumber(t,s=!0,e=!1,r=null){if(!t&&e)return"";const c=w.get(f(o,M),r||"",f(o,g));if(t?t=(t/100).toFixed(2):t="0.00",!s)return t;let a=new Intl.NumberFormat(f(o,_),{minimumFractionDigits:2,maximumFractionDigits:2}).format(t);return a=V(a),s?f(o,b)==="before"?`${c}${a}`:`${a}${c}`:a}static formatScaled(t,s=!0,e=!1,r=""){if(!t&&e)return"";const c=w.get(f(o,M),r||"",f(o,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 o.formatNumber(t,s,e,c);if(a=o.formatNumber(t,!1,e,c),!s)return a;const d=`${a}${l}`;return f(o,b)==="before"?`${c}${d}`:`${d}${c}`}static formatScaledChart(t,s=""){if(!t)return"0";const e=w.get(f(o,M),s||"",f(o,g)).replace(/&#(\d+);/g,(l,d)=>String.fromCharCode(d)).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/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(o,b)==="before"?`${e}${a}`:`${a}${e}`}static scaled(t,s=!0,e=!1,r=""){return o.formatScaled(t*100,s,e,r)}static scaledChart(t,s=!0,e=!1,r=""){return o.formatScaledChart(t*100,r)}static formatBulk(t,s=!1,e=f(o,g),r=!1){return t.map(c=>s?o.formatScaled(c,e,r):o.formatNumber(c,e,r))}static get currencySign(){return f(o,g)}static get currencyPosition(){return f(o,b)}static get locale(){return f(o,_)}static generateVolumeSummary(t,s=!1){if(s){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=o.formatScaled(n.current),k=o.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">${o.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">${o.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=o.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=w.get(t,O,{current:0,prev_year:0,yy_growth:0});m.yy_growth=Number(m.yy_growth||0);const C=o.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">${o.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">${o.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,N=new WeakMap,_=new WeakMap,x=new WeakMap,j=new WeakSet,F=function(t){return t},y(o,j),y(o,g,v.get("shop.currency_sign","$")),y(o,M,v.get("currency_signs",{})),y(o,b,v.get("shop.currency_position","before")),y(o,N,v.get("wp_locale","en-US")),y(o,_,null),y(o,x);let S=o;S.setLocale();function B(i,t){var c;let s=[],e,r;if(i){for(const a of i)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),s.push(e)}}return s}const q=i=>!(i.stockStatus==="in-stock"&&(Array.isArray(i.children)&&i.children.length===0||!i.children)),K=(i,t,s=!1)=>!i&&s?"":(i||(i="0.00"),v.get("shop.currency_sign")+" "+i),Q=(i,t,s=!1)=>S.formatNumber(i,t,s),E=i=>{if(!i.item_price||!i.item_cost)return"--";const t=Number(String(i.item_price).replace(",",".")),s=Number(String(i.item_cost).replace(",","."));return isNaN(t)||isNaN(s)||t===0?"--":((t-s)/t*100).toFixed(2)+"% "},G=i=>{if(!i.item_price||!i.item_cost)return"--";const t=Number(String(i.item_price).replace(",",".")),s=Number(String(i.item_cost).replace(",","."));if(isNaN(t)||isNaN(s))return"--";const e=t-s;return S.formatNumber(e*100,!0)},H=i=>i.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),R=i=>{const t=new Set;return i.order_items.forEach(s=>{(Number(s.object_id)!==0||s.object_id===null)&&t.add(s.object_id)}),t.size};export{S as C,H as a,K as b,G as c,E as d,Q as f,R as g,B as p};
2