text: (window.webpackJsonp=window.webpackJsonp||[]).push([[11],{741:function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return A}));var n=r(17),a=r.n(n),o=r(38),c=r.n(o),i=r(37),s=r.n(i),u=r(39),l=r.n(u),m=r(42),d=r.n(m),p=r(26),f=r.n(p),y=r(0),b=r(1),g=r.n(b),h=r(3),v=r(781),O=r(62),j=r.n(O),_=r(2),R=r(53),w=r(108),q=r(22),C=r(201),D=r(23),k=r(759),P=r(200);function E(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=f()(e);if(t){var a=f()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return d()(this,r)}}var S=function(e){l()(r,e);var t=E(r);function r(){var e;return c()(this,r),(e=t.call(this)).getHeadersContent=e.getHeadersContent.bind(j()(e)),e.getRowsContent=e.getRowsContent.bind(j()(e)),e.getSummary=e.getSummary.bind(j()(e)),e}return s()(r,[{key:"getHeadersContent",value:function(){return[{label:Object(h.__)("Coupon Code","woocommerce-admin"),key:"code",required:!0,isLeftAligned:!0,isSortable:!0},{label:Object(h.__)("Orders","woocommerce-admin"),key:"orders_count",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0},{label:Object(h.__)("Amount Discounted","woocommerce-admin"),key:"amount",isSortable:!0,isNumeric:!0},{label:Object(h.__)("Created","woocommerce-admin"),key:"created"},{label:Object(h.__)("Expires","woocommerce-admin"),key:"expires"},{label:Object(h.__)("Type","woocommerce-admin"),key:"type"}]}},{key:"getRowsContent",value:function(e){var t=this,r=this.props.query,n=Object(q.getPersistedQuery)(r),a=Object(D.g)("dateFormat",w.c),o=this.context,c=o.formatCurrency,i=o.formatDecimal,s=o.getCurrency;return Object(_.map)(e,(function(e){var r=e.amount,o=e.coupon_id,u=e.orders_count,l=e.extended_info||{},m=l.code,d=l.date_created,p=l.date_expires,f=l.discount_type,b=Object(q.getNewPath)(n,"/analytics/coupons",{filter:"single_coupon",coupons:o}),g=Object(y.createElement)(R.Link,{href:b,type:"wc-admin"},m),v=Object(q.getNewPath)(n,"/analytics/orders",{filter:"advanced",coupon_includes:o});return[{display:g,value:m},{display:Object(y.createElement)(R.Link,{href:v,type:"wc-admin"},Object(C.formatValue)(s(),"number",u)),value:u},{display:c(r),value:i(r)},{display:Object(y.createElement)(R.Date,{date:d,visibleFormat:a}),value:d},{display:p?Object(y.createElement)(R.Date,{date:p,visibleFormat:a}):Object(h.__)("N/A","woocommerce-admin"),value:p},{display:t.getCouponType(f),value:f}]}))}},{key:"getSummary",value:function(e){var t=e.coupons_count,r=void 0===t?0:t,n=e.orders_count,a=void 0===n?0:n,o=e.amount,c=void 0===o?0:o,i=this.context,s=i.formatCurrency,u=(0,i.getCurrency)();return[{label:Object(h._n)("coupon","coupons",r,"woocommerce-admin"),value:Object(C.formatValue)(u,"number",r)},{label:Object(h._n)("order","orders",a,"woocommerce-admin"),value:Object(C.formatValue)(u,"number",a)},{label:Object(h.__)("amount discounted","woocommerce-admin"),value:s(c)}]}},{key:"getCouponType",value:function(e){return{percent:Object(h.__)("Percentage","woocommerce-admin"),fixed_cart:Object(h.__)("Fixed cart","woocommerce-admin"),fixed_product:Object(h.__)("Fixed product","woocommerce-admin")}[e]}},{key:"render",value:function(){var e=this.props,t=e.advancedFilters,r=e.filters,n=e.isRequesting,a=e.query;return Object(y.createElement)(k.a,{compareBy:"coupons",endpoint:"coupons",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["coupons_count","orders_count","amount"],isRequesting:n,itemIdField:"coupon_id",query:a,searchBy:"coupons",tableQuery:{orderby:a.orderby||"orders_count",order:a.order||"desc",extended_info:!0},title:Object(h.__)("Coupons","woocommerce-admin"),columnPrefsKey:"coupons_report_columns",filters:r,advancedFilters:t})}}]),r}(y.Component);S.contextType=P.a;var T=S,F=r(755),x=r(754),L=r(756),V=r(757);function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=f()(e);if(t){var a=f()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return d()(this,r)}}var A=function(e){l()(r,e);var t=H(r);function r(){return c()(this,r),t.apply(this,arguments)}return s()(r,[{key:"getChartMeta",value:function(){var e=this.props.query,t="compare-coupons"===e.filter&&e.coupons&&e.coupons.split(",").length>1?"item-comparison":"time-comparison";return{itemsLabel:Object(h.__)("%d coupons","woocommerce-admin"),mode:t}}},{key:"render",value:function(){var e=this.props,t=e.isRequesting,r=e.query,n=e.path,o=this.getChartMeta(),c=o.mode,i=o.itemsLabel,s=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},r);return"item-comparison"===c&&(s.segmentby="coupon"),Object(y.createElement)(y.Fragment,null,Object(y.createElement)(V.a,{query:r,path:n,filters:v.c,advancedFilters:v.a,report:"coupons"}),Object(y.createElement)(L.a,{charts:v.b,endpoint:"coupons",isRequesting:t,query:s,selectedChart:Object(F.a)(r.chart,v.b),filters:v.c,advancedFilters:v.a}),Object(y.createElement)(x.a,{charts:v.b,filters:v.c,advancedFilters:v.a,mode:c,endpoint:"coupons",path:n,query:s,isRequesting:t,itemsLabel:i,selectedChart:Object(F.a)(r.chart,v.b)}),Object(y.createElement)(T,{isRequesting:t,query:r,filters:v.c,advancedFilters:v.a}))}}]),r}(y.Component);A.propTypes={query:g.a.object.isRequired}},751:function(e,t,r){"use strict";r.d(t,"e",(function(){return l})),r.d(t,"a",(function(){return m})),r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return p})),r.d(t,"d",(function(){return f})),r.d(t,"f",(function(){return y})),r.d(t,"g",(function(){return b}));var n=r(27),a=r(21),o=r.n(a),c=r(2),i=r(22),s=r(752),u=r(33);function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.identity;return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1?arguments[1]:void 0,c="function"==typeof e?e(a):e,s=Object(i.getIdsFromQuery)(r);if(s.length<1)return Promise.resolve([]);var u={include:s.join(","),per_page:s.length};return o()({path:Object(n.addQueryArgs)(c,u)}).then((function(e){return e.map(t)}))}}var m=l(u.c+"/products/categories",(function(e){return{key:e.id,label:e.name}})),d=l(u.c+"/coupons",(function(e){return{key:e.id,label:e.code}})),p=l(u.c+"/customers",(function(e){return{key:e.id,label:e.name}})),f=l(u.c+"/products",(function(e){return{key:e.id,label:e.name}})),y=l(u.c+"/taxes",(function(e){return{key:e.id,label:Object(s.a)(e)}})),b=l((function(e){return u.c+"/products/".concat(e.products,"/variations")}),(function(e){return{key:e.id,label:e.attributes.reduce((function(e,t,r,n){return e+"".concat(t.option).concat(n.length===r+1?"":", ")}),"")}}))},752:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(3);function a(e){return[e.country,e.state,e.name||Object(n.__)("TAX","woocommerce-admin"),e.priority].map((function(e){return e.toString().toUpperCase().trim()})).filter(Boolean).join("-")}},754:function(e,t,r){"use strict";var n=r(17),a=r.n(n),o=r(38),c=r.n(o),i=r(37),s=r.n(i),u=r(39),l=r.n(u),m=r(42),d=r.n(m),p=r(26),f=r.n(p),y=r(0),b=r(3),g=r(169),h=r(173),v=r(2),O=r(1),j=r.n(O),_=r(108),R=r(53),w=r(43),q=r(200),C=r(750),D=r(261),k=r(101),P=r(22);function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=f()(e);if(t){var a=f()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return d()(this,r)}}var F=function(e){l()(r,e);var t=T(r);function r(){return c()(this,r),t.apply(this,arguments)}return s()(r,[{key:"shouldComponentUpdate",value:function(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!Object(v.isEqual)(e.query,this.props.query)}},{key:"getItemChartData",value:function(){var e=this.props,t=e.primaryData,r=e.selectedChart;return t.data.intervals.map((function(e){var t={};return e.subtotals.segments.forEach((function(e){if(e.segment_label){var n=t[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;t[e.segment_id]={label:n,value:e.subtotals[r.key]||0}}})),S({date:Object(h.a)("Y-m-d\\TH:i:s",e.date_start)},t)}))}},{key:"getTimeChartData",value:function(){var e=this.props,t=e.query,r=e.primaryData,n=e.secondaryData,a=e.selectedChart,o=e.defaultDateRange,c=Object(_.i)(t),i=Object(_.f)(t,o),s=i.primary,u=i.secondary;return r.data.intervals.map((function(e,r){var o=Object(_.j)(e.date_start,s.after,u.after,t.compare,c),i=n.data.intervals[r];return{date:Object(h.a)("Y-m-d\\TH:i:s",e.date_start),primary:{label:"".concat(s.label," (").concat(s.range,")"),labelDate:e.date_start,value:e.subtotals[a.key]||0},secondary:{label:"".concat(u.label," (").concat(u.range,")"),labelDate:o.format("YYYY-MM-DD HH:mm:ss"),value:i&&i.subtotals[a.key]||0}}}))}},{key:"getTimeChartTotals",value:function(){var e=this.props,t=e.primaryData,r=e.secondaryData,n=e.selectedChart;return{primary:Object(v.get)(t,["data","totals",n.key],null),secondary:Object(v.get)(r,["data","totals",n.key],null)}}},{key:"renderChart",value:function(e,t,r,n){var a=this.props,o=a.emptySearchResults,c=a.filterParam,i=a.interactiveLegend,s=a.itemsLabel,u=a.legendPosition,l=a.path,m=a.query,d=a.selectedChart,p=a.showHeaderControls,f=a.primaryData,g=Object(_.i)(m),h=Object(_.d)(m),v=Object(_.g)(g,f.data.intervals.length),O=o?Object(b.__)("No data for the current search","woocommerce-admin"):Object(b.__)("No data for the selected date range","woocommerce-admin"),j=this.context,w=j.formatCurrency,q=j.getCurrency;return Object(y.createElement)(R.Chart,{allowedIntervals:h,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:O,filterParam:c,interactiveLegend:i,interval:g,isRequesting:t,itemsLabel:s,legendPosition:u,legendTotals:n,mode:e,path:l,query:m,screenReaderFormat:v.screenReaderFormat,showHeaderControls:p,title:d.label,tooltipLabelFormat:v.tooltipLabelFormat,tooltipTitle:"time-comparison"===e&&d.label||null,tooltipValueFormat:Object(C.e)(d.type,w),chartType:Object(_.e)(m),valueType:d.type,xFormat:v.xFormat,x2Format:v.x2Format,currency:q()})}},{key:"renderItemComparison",value:function(){var e=this.props,t=e.isRequesting,r=e.primaryData;if(r.isError)return Object(y.createElement)(D.a,{isError:!0});var n=t||r.isRequesting,a=this.getItemChartData();return this.renderChart("item-comparison",n,a)}},{key:"renderTimeComparison",value:function(){var e=this.props,t=e.isRequesting,r=e.primaryData,n=e.secondaryData;if(!r||r.isError||n.isError)return Object(y.createElement)(D.a,{isError:!0});var a=t||r.isRequesting||n.isRequesting,o=this.getTimeChartData(),c=this.getTimeChartTotals();return this.renderChart("time-comparison",a,o,c)}},{key:"render",value:function(){return"item-comparison"===this.props.mode?this.renderItemComparison():this.renderTimeComparison()}}]),r}(y.Component);F.contextType=q.a,F.propTypes={filters:j.a.array,isRequesting:j.a.bool,itemsLabel:j.a.string,limitProperties:j.a.array,mode:j.a.string,path:j.a.string.isRequired,primaryData:j.a.object,query:j.a.object.isRequired,secondaryData:j.a.object,selectedChart:j.a.shape({key:j.a.string.isRequired,label:j.a.string.isRequired,order:j.a.oneOf(["asc","desc"]),orderby:j.a.string,type:j.a.oneOf(["average","number","currency"]).isRequired}).isRequired},F.defaultProps={isRequesting:!1,primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};t.a=Object(g.a)(Object(k.a)((function(e,t){var r=t.charts,n=t.endpoint,a=t.filters,o=t.isRequesting,c=t.limitProperties,i=t.query,s=t.advancedFilters,u=c||[n],l=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t||0===t.length)return null;var a=t.slice(0),o=a.pop();if(o.showFilters(r,n)){var c=Object(P.flattenFilters)(o.filters),i=r[o.param]||o.defaultValue||"all";return Object(v.find)(c,{value:i})}return e(a,r,n)}(a,i),m=Object(v.get)(l,["settings","param"]),d=t.mode||function(e,t){if(e&&t){var r=Object(v.get)(e,["settings","param"]);if(!r||Object.keys(t).includes(r))return Object(v.get)(e,["chartMode"])}return null}(l,i)||"time-comparison",p=e(w.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings").woocommerce_default_date_range,f={mode:d,filterParam:m,defaultDateRange:p};if(o)return f;var y=u.some((function(e){return i[e]&&i[e].length}));if(i.search&&!y)return S(S({},f),{},{emptySearchResults:!0});var b=r&&r.map((function(e){return e.key})),g=Object(C.a)({endpoint:n,dataType:"primary",query:i,select:e,limitBy:u,filters:a,advancedFilters:s,defaultDateRange:p,fields:b});if("item-comparison"===d)return S(S({},f),{},{primaryData:g});var h=Object(C.a)({endpoint:n,dataType:"secondary",query:i,select:e,limitBy:u,filters:a,advancedFilters:s,defaultDateRange:p,fields:b});return S(S({},f),{},{primaryData:g,secondaryData:h})})))(F)},755:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(2);function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=Object(n.find)(t,{key:e});return r||t[0]}},756:function(e,t,r){"use strict";var n=r(38),a=r.n(n),o=r(37),c=r.n(o),i=r(39),s=r.n(i),u=r(42),l=r.n(u),m=r(26),d=r.n(m),p=r(0),f=r(3),y=r(169),b=r(1),g=r.n(b),h=r(108),v=r(22),O=r(53),j=r(201),_=r(43),R=r(750),w=r(261),q=r(101),C=r(63),D=r(200);function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d()(e);if(t){var a=d()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return l()(this,r)}}var P=function(e){s()(r,e);var t=k(r);function r(){return a()(this,r),t.apply(this,arguments)}return c()(r,[{key:"formatVal",value:function(e,t){var r=this.context,n=r.formatCurrency,a=r.getCurrency;return"currency"===t?n(e):Object(j.formatValue)(a(),t,e)}},{key:"getValues",value:function(e,t){var r=this.props,n=r.emptySearchResults,a=r.summaryData.totals,o=n?0:a.primary[e],c=n?0:a.secondary[e];return{delta:Object(j.calculateDelta)(o,c),prevValue:this.formatVal(c,t),value:this.formatVal(o,t)}}},{key:"render",value:function(){var e=this,t=this.props,r=t.charts,n=t.isRequesting,a=t.query,o=t.selectedChart,c=t.summaryData,i=t.endpoint,s=t.report,u=t.defaultDateRange,l=c.isError,m=c.isRequesting;if(l)return Object(p.createElement)(w.a,{isError:!0});if(n||m)return Object(p.createElement)(O.SummaryListPlaceholder,{numberOfItems:r.length});var d=Object(h.h)(a,u).compare;return Object(p.createElement)(O.SummaryList,null,(function(t){var n=t.onToggle;return r.map((function(t){var r=t.key,a=t.order,c=t.orderby,u=t.label,l=t.type,m={chart:r};c&&(m.orderby=c),a&&(m.order=a);var y=Object(v.getNewPath)(m),b=o.key===r,g=e.getValues(r,l),h=g.delta,j=g.prevValue,_=g.value;return Object(p.createElement)(O.SummaryNumber,{key:r,delta:h,href:y,label:u,prevLabel:"previous_period"===d?Object(f.__)("Previous Period:","woocommerce-admin"):Object(f.__)("Previous Year:","woocommerce-admin"),prevValue:j,selected:b,value:_,onLinkClickCallback:function(){n&&n(),Object(C.b)("analytics_chart_tab_click",{report:s||i,key:r})}})}))}))}}]),r}(p.Component);P.propTypes={charts:g.a.array.isRequired,endpoint:g.a.string.isRequired,limitProperties:g.a.array,query:g.a.object.isRequired,isRequesting:g.a.bool,selectedChart:g.a.shape({key:g.a.string.isRequired,label:g.a.string.isRequired,order:g.a.oneOf(["asc","desc"]),orderby:g.a.string,type:g.a.oneOf(["average","number","currency"]).isRequired}).isRequired,summaryData:g.a.object,report:g.a.string},P.defaultProps={summaryData:{totals:{primary:{},secondary:{}},isError:!1,isRequesting:!1}},P.contextType=D.a,t.a=Object(y.a)(Object(q.a)((function(e,t){var r=t.charts,n=t.endpoint,a=t.isRequesting,o=t.limitProperties,c=t.query,i=t.filters,s=t.advancedFilters,u=o||[n];if(a)return{};var l=u.some((function(e){return c[e]&&c[e].length}));if(c.search&&!l)return{emptySearchResults:!0};var m=r&&r.map((function(e){return e.key})),d=e(_.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings").woocommerce_default_date_range;return{summaryData:Object(R.d)({endpoint:n,query:c,select:e,limitBy:u,filters:i,advancedFilters:s,defaultDateRange:d,fields:m}),defaultDateRange:d}})))(P)},781:function(e,t,r){"use strict";r.d(t,"b",(function(){return c})),r.d(t,"c",(function(){return i})),r.d(t,"a",(function(){return s}));var n=r(3),a=r(48),o=r(751),c=Object(a.applyFilters)("woocommerce_admin_coupons_report_charts",[{key:"orders_count",label:Object(n.__)("Discounted Orders","woocommerce-admin"),order:"desc",orderby:"orders_count",type:"number"},{key:"amount",label:Object(n.__)("Amount","woocommerce-admin"),order:"desc",orderby:"amount",type:"currency"}]),i=Object(a.applyFilters)("woocommerce_admin_coupons_report_filters",[{label:Object(n.__)("Show","woocommerce-admin"),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:function(){return!0},filters:[{label:Object(n.__)("All Coupons","woocommerce-admin"),value:"all"},{label:Object(n.__)("Single Coupon","woocommerce-admin"),value:"select_coupon",chartMode:"item-comparison",subFilters:[{component:"Search",value:"single_coupon",chartMode:"item-comparison",path:["select_coupon"],settings:{type:"coupons",param:"coupons",getLabels:o.b,labels:{placeholder:Object(n.__)("Type to search for a coupon","woocommerce-admin"),button:Object(n.__)("Single Coupon","woocommerce-admin")}}}]},{label:Object(n.__)("Comparison","woocommerce-admin"),value:"compare-coupons",settings:{type:"coupons",param:"coupons",getLabels:o.b,labels:{title:Object(n.__)("Compare Coupon Codes","woocommerce-admin"),update:Object(n.__)("Compare","woocommerce-admin"),helpText:Object(n.__)("Check at least two coupon codes below to compare","woocommerce-admin")}}}]}]),s=Object(a.applyFilters)("woocommerce_admin_coupon_report_advanced_filters",{})}}]);