"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[4011],{17666:(e,t,r)=>{r.d(t,{Z:()=>C});var o=r(69307),a=r(65736),s=r(94333),n=r(69771),i=r(9818),c=r(92819),l=r(7862),u=r.n(l),m=r(86020),d=r(67221),p=r(81921),y=r(17844),g=r(65994),h=r(10431);function _(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||0===e.length)return null;const o=e.slice(0),a=o.pop();if(a.showFilters(t,r)){const e=(0,h.flattenFilters)(a.filters),r=t[a.param]||a.defaultValue||"all";return(0,c.find)(e,{value:r})}return _(o,t,r)}function f(e){return t=>(0,n.format)(e,t)}class b extends o.Component{shouldComponentUpdate(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!(0,c.isEqual)(e.query,this.props.query)}getItemChartData(){const{primaryData:e,selectedChart:t}=this.props;return e.data.intervals.map((function(e){const r={};return e.subtotals.segments.forEach((function(e){if(e.segment_label){const o=r[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;r[e.segment_id]={label:o,value:e.subtotals[t.key]||0}}})),{date:(0,n.format)("Y-m-d\\TH:i:s",e.date_start),...r}}))}getTimeChartData(){const{query:e,primaryData:t,secondaryData:r,selectedChart:o,defaultDateRange:a}=this.props,s=(0,p.getIntervalForQuery)(e,a),{primary:i,secondary:c}=(0,p.getCurrentDates)(e,a);return t.data.intervals.map((function(t,a){const l=(0,p.getPreviousDate)(t.date_start,i.after,c.after,e.compare,s),u=r.data.intervals[a];return{date:(0,n.format)("Y-m-d\\TH:i:s",t.date_start),primary:{label:`${i.label} (${i.range})`,labelDate:t.date_start,value:t.subtotals[o.key]||0},secondary:{label:`${c.label} (${c.range})`,labelDate:l.format("YYYY-MM-DD HH:mm:ss"),value:u&&u.subtotals[o.key]||0}}}))}getTimeChartTotals(){const{primaryData:e,secondaryData:t,selectedChart:r}=this.props;return{primary:(0,c.get)(e,["data","totals",r.key],null),secondary:(0,c.get)(t,["data","totals",r.key],null)}}renderChart(e,t,r,s){const{emptySearchResults:n,filterParam:i,interactiveLegend:c,itemsLabel:l,legendPosition:u,path:y,query:g,selectedChart:h,showHeaderControls:_,primaryData:b,defaultDateRange:C}=this.props,v=(0,p.getIntervalForQuery)(g,C),w=(0,p.getAllowedIntervalsForQuery)(g,C),R=(0,p.getDateFormatsForInterval)(v,b.data.intervals.length,{type:"php"}),q=n?(0,a.__)("No data for the current search","woocommerce"):(0,a.__)("No data for the selected date range","woocommerce"),{formatAmount:E,getCurrencyConfig:D}=this.context;return(0,o.createElement)(m.Chart,{allowedIntervals:w,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:q,filterParam:i,interactiveLegend:c,interval:v,isRequesting:t,itemsLabel:l,legendPosition:u,legendTotals:s,mode:e,path:y,query:g,screenReaderFormat:f(R.screenReaderFormat),showHeaderControls:_,title:h.label,tooltipLabelFormat:f(R.tooltipLabelFormat),tooltipTitle:"time-comparison"===e&&h.label||null,tooltipValueFormat:(0,d.getTooltipValueFormat)(h.type,E),chartType:(0,p.getChartTypeForQuery)(g),valueType:h.type,xFormat:f(R.xFormat),x2Format:f(R.x2Format),currency:D()})}renderItemComparison(){const{isRequesting:e,primaryData:t}=this.props;if(t.isError)return(0,o.createElement)(g.Z,null);const r=e||t.isRequesting,a=this.getItemChartData();return this.renderChart("item-comparison",r,a)}renderTimeComparison(){const{isRequesting:e,primaryData:t,secondaryData:r}=this.props;if(!t||t.isError||r.isError)return(0,o.createElement)(g.Z,null);const a=e||t.isRequesting||r.isRequesting,s=this.getTimeChartData(),n=this.getTimeChartTotals();return this.renderChart("time-comparison",a,s,n)}render(){const{mode:e}=this.props;return"item-comparison"===e?this.renderItemComparison():this.renderTimeComparison()}}b.contextType=y.CurrencyContext,b.propTypes={filters:u().array,isRequesting:u().bool,itemsLabel:u().string,limitProperties:u().array,mode:u().string,path:u().string.isRequired,primaryData:u().object,query:u().object.isRequired,secondaryData:u().object,selectedChart:u().shape({key:u().string.isRequired,label:u().string.isRequired,order:u().oneOf(["asc","desc"]),orderby:u().string,type:u().oneOf(["average","number","currency"]).isRequired}).isRequired},b.defaultProps={isRequesting:!1,primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};const C=(0,s.compose)((0,i.withSelect)(((e,t)=>{const{charts:r,endpoint:o,filters:a,isRequesting:s,limitProperties:n,query:i,advancedFilters:l}=t,u=n||[o],m=_(a,i),p=(0,c.get)(m,["settings","param"]),y=t.mode||function(e,t){if(e&&t){const r=(0,c.get)(e,["settings","param"]);if(!r||Object.keys(t).includes(r))return(0,c.get)(e,["chartMode"])}return null}(m,i)||"time-comparison",{woocommerce_default_date_range:g}=e(d.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings"),h=e(d.REPORTS_STORE_NAME),f={mode:y,filterParam:p,defaultDateRange:g};if(s)return f;const b=u.some((e=>i[e]&&i[e].length));if(i.search&&!b)return{...f,emptySearchResults:!0};const C=r&&r.map((e=>e.key)),v=(0,d.getReportChartData)({endpoint:o,dataType:"primary",query:i,selector:h,limitBy:u,filters:a,advancedFilters:l,defaultDateRange:g,fields:C});if("item-comparison"===y)return{...f,primaryData:v};const w=(0,d.getReportChartData)({endpoint:o,dataType:"secondary",query:i,selector:h,limitBy:u,filters:a,advancedFilters:l,defaultDateRange:g,fields:C});return{...f,primaryData:v,secondaryData:w}})))(b)},59205:(e,t,r)=>{r.d(t,{Z:()=>f});var o=r(69307),a=r(65736),s=r(94333),n=r(9818),i=r(7862),c=r.n(i),l=r(10431),u=r(86020),m=r(81595),d=r(67221),p=r(81921),y=r(14599),g=r(17844),h=r(65994);class _ extends o.Component{formatVal(e,t){const{formatAmount:r,getCurrencyConfig:o}=this.context;return"currency"===t?r(e):(0,m.formatValue)(o(),t,e)}getValues(e,t){const{emptySearchResults:r,summaryData:o}=this.props,{totals:a}=o,s=a.primary?a.primary[e]:0,n=a.secondary?a.secondary[e]:0,i=r?0:s,c=r?0:n;return{delta:(0,m.calculateDelta)(i,c),prevValue:this.formatVal(c,t),value:this.formatVal(i,t)}}render(){const{charts:e,query:t,selectedChart:r,summaryData:s,endpoint:n,report:i,defaultDateRange:c}=this.props,{isError:m,isRequesting:d}=s;if(m)return(0,o.createElement)(h.Z,null);if(d)return(0,o.createElement)(u.SummaryListPlaceholder,{numberOfItems:e.length});const{compare:g}=(0,p.getDateParamsFromQuery)(t,c);return(0,o.createElement)(u.SummaryList,null,(t=>{let{onToggle:s}=t;return e.map((e=>{const{key:t,order:c,orderby:m,label:d,type:p,isReverseTrend:h,labelTooltipText:_}=e,f={chart:t};m&&(f.orderby=m),c&&(f.order=c);const b=(0,l.getNewPath)(f),C=r.key===t,{delta:v,prevValue:w,value:R}=this.getValues(t,p);return(0,o.createElement)(u.SummaryNumber,{key:t,delta:v,href:b,label:d,reverseTrend:h,prevLabel:"previous_period"===g?(0,a.__)("Previous period:","woocommerce"):(0,a.__)("Previous year:","woocommerce"),prevValue:w,selected:C,value:R,labelTooltipText:_,onLinkClickCallback:()=>{s&&s(),(0,y.recordEvent)("analytics_chart_tab_click",{report:i||n,key:t})}})}))}))}}_.propTypes={charts:c().array.isRequired,endpoint:c().string.isRequired,limitProperties:c().array,query:c().object.isRequired,selectedChart:c().shape({key:c().string.isRequired,label:c().string.isRequired,order:c().oneOf(["asc","desc"]),orderby:c().string,type:c().oneOf(["average","number","currency"]).isRequired}).isRequired,summaryData:c().object,report:c().string},_.defaultProps={summaryData:{totals:{primary:{},secondary:{}},isError:!1}},_.contextType=g.CurrencyContext;const f=(0,s.compose)((0,n.withSelect)(((e,t)=>{const{charts:r,endpoint:o,limitProperties:a,query:s,filters:n,advancedFilters:i}=t,c=a||[o],l=c.some((e=>s[e]&&s[e].length));if(s.search&&!l)return{emptySearchResults:!0};const u=r&&r.map((e=>e.key)),{woocommerce_default_date_range:m}=e(d.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings");return{summaryData:(0,d.getSummaryNumbers)({endpoint:o,query:s,select:e,limitBy:c,filters:n,advancedFilters:i,defaultDateRange:m,fields:u}),defaultDateRange:m}})))(_)},48248:(e,t,r)=>{r.d(t,{O3:()=>l,be:()=>u,u8:()=>d});var o=r(65736),a=r(92694),s=r(9818),n=r(75606),i=r(36309);const{addCesSurveyForAnalytics:c}=(0,s.dispatch)(n.STORE_KEY),l=(0,a.applyFilters)("woocommerce_admin_coupons_report_charts",[{key:"orders_count",label:(0,o.__)("Discounted orders","woocommerce"),order:"desc",orderby:"orders_count",type:"number"},{key:"amount",label:(0,o.__)("Amount","woocommerce"),order:"desc",orderby:"amount",type:"currency"}]),u=(0,a.applyFilters)("woocommerce_admin_coupon_report_advanced_filters",{filters:{},title:(0,o._x)("Coupons match