text: (window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[46],{739:function(e,t,r){"use strict";r.d(t,"a",(function(){return y})),r.d(t,"e",(function(){return j})),r.d(t,"b",(function(){return v})),r.d(t,"f",(function(){return h})),r.d(t,"d",(function(){return w})),r.d(t,"c",(function(){return R}));var n=r(5),a=r.n(n),i=r(53),c=r.n(i),o=r(2),s=r(17),u=r.n(s),l=r(115),f=r(29),d=r(36),p=r(739);function m(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 b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e){var t=e.endpoint,r=e.query,n=e.limitBy,i=e.filters,s=void 0===i?[]:i,d=e.advancedFilters,p=void 0===d?{}:d;return r.search?(n||[t]).reduce((function(e,t){return e[t]=r[t],e}),{}):s.map((function(e){return function(e,t,r){var n=r[e.param];if(!n)return{};if("advanced"===n){var i=Object(f.getActiveFiltersFromQuery)(r,t.filters);return 0===i.length?{}:i.map((function(e){return function(e,t){var r=e.filters[t.key];if("Date"!==Object(o.get)(r,["input","component"]))return t;var n=t.rule,a=t.value,i={after:"start",before:"end"};if(Array.isArray(a)){var s=c()(a,2),f=s[0],d=s[1];return Object.assign({},t,{value:[Object(l.a)(u()(f),i.after),Object(l.a)(u()(d),i.before)]})}return Object.assign({},t,{value:Object(l.a)(u()(a),i[n])})}(t,e)})).reduce((function(e,t){var r=t.key,n=t.rule,a=t.value;return e[Object(f.getUrlKey)(r,n)]=a,e}),{match:r.match||"all"})}var s=Object(o.find)(Object(f.flattenFilters)(e.filters),{value:n});if(!s)return{};if(s.settings&&s.settings.param){var d=s.settings.param;return r[d]?a()({},d,r[d]):{}}return a()({},e.param,n)}(e,p,r)})).reduce((function(e,t){return Object.assign(e,t)}),{})}var O=["stock","customers"];function g(e){var t=e.endpoint,r=e.dataType,n=e.query,a=e.fields,i=Object(l.f)(n,e.defaultDateRange),c=Object(l.i)(n),s=y(e),u=i[r].before;return Object(o.includes)(O,t)?b(b({},s),{},{fields:a}):b({order:"asc",interval:c,per_page:d.b,after:Object(l.a)(i[r].after,"start"),before:Object(l.a)(u,"end"),segmentby:n.segmentby,fields:a},s)}function j(e){var t=e.endpoint,r=(0,e.select)("wc-api"),n=r.getReportStats,a=r.getReportStatsError,i=r.isReportStatsRequesting,c={isRequesting:!1,isError:!1,totals:{primary:null,secondary:null}},o=g(b(b({},e),{},{dataType:"primary"})),s=n(t,o);if(i(t,o))return b(b({},c),{},{isRequesting:!0});if(a(t,o))return b(b({},c),{},{isError:!0});var u=s&&s.data&&s.data.totals||null,l=g(b(b({},e),{},{dataType:"secondary"})),f=n(t,l);if(i(t,l))return b(b({},c),{},{isRequesting:!0});if(a(t,l))return b(b({},c),{},{isError:!0});var d=f&&f.data&&f.data.totals||null;return b(b({},c),{},{totals:{primary:u,secondary:d}})}function v(e){var t=e.endpoint,r=(0,e.select)("wc-api"),n=r.getReportStats,a=r.getReportStatsError,i=r.isReportStatsRequesting,c={isEmpty:!1,isError:!1,isRequesting:!1,data:{totals:{},intervals:[]}},s=g(e),u=n(t,s);if(i(t,s))return b(b({},c),{},{isRequesting:!0});if(a(t,s))return b(b({},c),{},{isError:!0});if(function(e,t){return!e||(!e.data||(!(e.data.totals&&!Object(o.isNull)(e.data.totals))||!(Object(o.includes)(O,t)||e.data.intervals&&0!==e.data.intervals.length)))}(u,t))return b(b({},c),{},{isEmpty:!0});var l=u&&u.data&&u.data.totals||null,f=u&&u.data&&u.data.intervals||[];if(u.totalResults>d.b){for(var p=!0,m=!1,y=[],j=Math.ceil(u.totalResults/d.b),v=1,h=2;h<=j;h++){var w=b(b({},s),{},{page:h}),R=n(t,w);if(!i(t,w)){if(a(t,w)){m=!0,p=!1;break}if(y.push(R),++v===j){p=!1;break}}}if(p)return b(b({},c),{},{isRequesting:!0});if(m)return b(b({},c),{},{isError:!0});Object(o.forEach)(y,(function(e){f=f.concat(e.data.intervals)}))}return b(b({},c),{},{data:{totals:l,intervals:f}})}function h(e,t){switch(e){case"currency":return t;case"percent":return".0%";case"number":return",";case"average":return",.2r";default:return","}}function w(e){var t=e.query,r=e.tableQuery,n=void 0===r?{}:r,a=y(e),i=Object(l.f)(t,e.defaultDateRange),c=Object(o.includes)(O,e.endpoint);return b(b({orderby:t.orderby||"date",order:t.order||"desc",after:c?void 0:Object(l.a)(i.primary.after,"start"),before:c?void 0:Object(l.a)(i.primary.before,"end"),page:t.paged||1,per_page:t.per_page||d.d.pageSize},a),n)}function R(e){var t=e.endpoint,r=(0,e.select)("wc-api"),n=r.getReportItems,a=r.getReportItemsError,i=r.isReportItemsRequesting,c=p.d(e),o={query:c,isRequesting:!1,isError:!1,items:{data:[],totalResults:0}},s=n(t,c);return i(t,c)?b(b({},o),{},{isRequesting:!0}):a(t,c)?b(b({},o),{},{isError:!0}):b(b({},o),{},{items:s})}},762:function(e,t,r){"use strict";r.d(t,"b",(function(){return y})),r.d(t,"a",(function(){return O}));var n=r(5),a=r.n(n),i=r(17),c=r.n(i),o=r(2),s=r(32),u=r(46),l=r(29),f=r(219),d=r(28),p=r(739);function m(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 b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var y=function(e){var t=e.indicator,r=e.primaryData,n=e.secondaryData,a=e.currency,i=e.formatAmount,c=e.persistedQuery,s=Object(o.find)(r.data,(function(e){return e.stat===t.stat})),u=Object(o.find)(n.data,(function(e){return e.stat===t.stat}));if(!s||!u)return{};var p=s._links&&s._links.report[0]&&s._links.report[0].href||"",m=function(e,t,r){return e?"/jetpack"===e?Object(d.f)("admin.php?page=jetpack#/dashboard"):Object(l.getNewPath)(t,e,{chart:r.chart}):""}(p,c,s),b="/jetpack"===p?"wp-admin":"wc-admin",y="currency"===s.format,O=Object(f.calculateDelta)(s.value,u.value);return{primaryValue:y?i(s.value):Object(f.formatValue)(a,s.format,s.value),secondaryValue:y?i(u.value):Object(f.formatValue)(a,u.format,u.value),delta:O,reportUrl:m,reportUrlType:b}},O=function(e,t,r,n){var a=e("wc-api"),i=a.getReportItems,o=a.getReportItemsError,l=a.isReportItemsRequesting,f=e(u.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings").woocommerce_default_date_range,d=Object(s.getCurrentDates)(r,f),m=d.primary.before,y=d.secondary.before,O=t.map((function(e){return e.stat})).join(","),g=Object(p.a)({filters:n,query:r}),j=b(b({},g),{},{after:Object(s.appendTimestamp)(d.primary.after,"start"),before:Object(s.appendTimestamp)(m,m.isSame(c()(),"day")?"now":"end"),stats:O}),v=b(b({},g),{},{after:Object(s.appendTimestamp)(d.secondary.after,"start"),before:Object(s.appendTimestamp)(y,y.isSame(c()(),"day")?"now":"end"),stats:O});return{primaryData:i("performance-indicators",j),primaryError:o("performance-indicators",j)||null,primaryRequesting:l("performance-indicators",j),secondaryData:i("performance-indicators",v),secondaryError:o("performance-indicators",v)||null,secondaryRequesting:l("performance-indicators",v),defaultDateRange:f}}},915:function(e,t,r){},924:function(e,t,r){"use strict";r.r(t);var n=r(5),a=r.n(n),i=r(13),c=r.n(i),o=r(12),s=r.n(o),u=r(14),l=r.n(u),f=r(15),d=r.n(f),p=r(6),m=r.n(p),b=r(0),y=r(3),O=r(185),g=r(115),j=r(29),v=r(28),h=r(46),w=r(55),R=r(104),E=(r(915),r(63)),_=r(218),k=r(762);function P(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?P(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(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=m()(e);if(t){var a=m()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return d()(this,r)}}var T=Object(v.g)("dataEndpoints",{performanceIndicators:[]}).performanceIndicators,q=function(e){l()(r,e);var t=D(r);function r(){return c()(this,r),t.apply(this,arguments)}return s()(r,[{key:"renderMenu",value:function(){var e=this.props,t=e.hiddenBlocks,r=e.isFirst,n=e.isLast,a=e.onMove,i=e.onRemove,c=e.onTitleBlur,o=e.onTitleChange,s=e.onToggleHiddenBlock,u=e.titleInput,l=e.controls;return Object(b.createElement)(w.EllipsisMenu,{label:Object(y.__)("Choose which analytics to display and the section name","woocommerce-admin"),renderContent:function(e){var f=e.onToggle;return Object(b.createElement)(b.Fragment,null,Object(b.createElement)(w.MenuTitle,null,Object(y.__)("Display Stats:","woocommerce-admin")),T.map((function(e,r){var n=!t.includes(e.stat);return Object(b.createElement)(w.MenuItem,{checked:n,isCheckbox:!0,isClickable:!0,key:r,onInvoke:function(){s(e.stat)(),Object(E.b)("dash_indicators_toggle",{status:n?"off":"on",key:e.stat})}},e.label)})),window.wcAdminFeatures["analytics-dashboard/customizable"]&&Object(b.createElement)(l,{onToggle:f,onMove:a,onRemove:i,isFirst:r,isLast:n,onTitleBlur:c,onTitleChange:o,titleInput:u}))}})}},{key:"renderList",value:function(){var e=this.props,t=e.query,r=e.primaryRequesting,n=e.secondaryRequesting,a=e.primaryError,i=e.secondaryError,c=e.primaryData,o=e.secondaryData,s=e.userIndicators,u=e.defaultDateRange;if(r||n)return Object(b.createElement)(w.SummaryListPlaceholder,{numberOfItems:s.length});if(a||i)return null;var l=Object(j.getPersistedQuery)(t),f="previous_period"===Object(g.h)(t,u).compare?Object(y.__)("Previous Period:","woocommerce-admin"):Object(y.__)("Previous Year:","woocommerce-admin"),d=this.context,p=d.formatAmount,m=(0,d.getCurrencyConfig)();return Object(b.createElement)(w.SummaryList,null,(function(){return s.map((function(e,t){var r=Object(k.b)({indicator:e,primaryData:c,secondaryData:o,currency:m,formatAmount:p,persistedQuery:l}),n=r.primaryValue,a=r.secondaryValue,i=r.delta,s=r.reportUrl,u=r.reportUrlType;return Object(b.createElement)(w.SummaryNumber,{key:t,href:s,hrefType:u,label:e.label,value:n,prevLabel:f,prevValue:a,delta:i,onLinkClickCallback:function(){Object(E.b)("dash_indicators_click",{key:e.stat})}})}))}))}},{key:"render",value:function(){var e=this.props,t=e.userIndicators,r=e.title;return Object(b.createElement)(b.Fragment,null,Object(b.createElement)(w.SectionHeader,{title:r||Object(y.__)("Store Performance","woocommerce-admin"),menu:this.renderMenu()}),t.length>0&&Object(b.createElement)("div",{className:"woocommerce-dashboard__store-performance"},this.renderList()))}}]),r}(b.Component);q.contextType=_.a,t.default=Object(O.a)(Object(R.a)((function(e,t){var r=t.hiddenBlocks,n=t.query,a=t.filters,i=T.filter((function(e){return!r.includes(e.stat)})),c=e(h.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings").woocommerce_default_date_range,o={hiddenBlocks:r,userIndicators:i,indicators:T,defaultDateRange:c};if(0===i.length)return o;var s=Object(k.a)(e,i,n,a);return S(S({},o),s)})))(q)}}]);