(globalThis.webpackChunkdokan_pro=globalThis.webpackChunkdokan_pro||[]).push([[6424],{331(e,t,r){"use strict";r.d(t,{A:()=>s});var a=r(8468);function s(e,t=[]){return(0,a.find)(t,{key:e})||t[0]}},1569(e,t,r){"use strict";r.r(t),r.d(t,{default:()=>A});var a=r(6087),s=r(5556),n=r.n(s),o=r(7723),i=r(2619),l=r(7057);const d=(0,i.applyFilters)("dokan_analytics_downloads_report_charts",[{key:"download_count",label:(0,o.__)("Downloads","dokan"),type:"number"}]),c=(0,i.applyFilters)("dokan_analytics_downloads_report_filters",[{label:(0,o.__)("Show","dokan"),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:()=>!0,filters:[{label:(0,o.__)("All downloads","dokan"),value:"all"},{label:(0,o.__)("Advanced filters","dokan"),value:"advanced"}]}]),u=(0,i.applyFilters)("dokan_analytics_downloads_report_advanced_filters",{title:(0,o._x)("Downloads match <select/> filters","A sentence describing filters for Downloads. See screen shot for context: https://cloudup.com/ccxhyH2mEDg","dokan"),filters:{product:{labels:{add:(0,o.__)("Product","dokan"),placeholder:(0,o.__)("Search","dokan"),remove:(0,o.__)("Remove product filter","dokan"),rule:(0,o.__)("Select a product filter match","dokan"),
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title:(0,o.__)("<title>Product</title> <rule/> <filter/>","dokan"),filter:(0,o.__)("Select product","dokan")},rules:[{value:"includes",
/* translators: Sentence fragment, logical, "Includes" refers to products including a given product(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Includes","products","dokan")},{value:"excludes",
/* translators: Sentence fragment, logical, "Excludes" refers to products excluding a products(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Excludes","products","dokan")}],input:{component:"Search",type:"products",getLabels:l.p0}},customer:{labels:{add:(0,o.__)("Username","dokan"),placeholder:(0,o.__)("Search customer username","dokan"),remove:(0,o.__)("Remove customer username filter","dokan"),rule:(0,o.__)("Select a customer username filter match","dokan"),
/* translators: A sentence describing a customer username filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title:(0,o.__)("<title>Username</title> <rule/> <filter />","dokan"),filter:(0,o.__)("Select customer username","dokan")},rules:[{value:"includes",
/* translators: Sentence fragment, logical, "Includes" refers to customer usernames including a given username(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Includes","customer usernames","dokan")},{value:"excludes",
/* translators: Sentence fragment, logical, "Excludes" refers to customer usernames excluding a given username(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Excludes","customer usernames","dokan")}],input:{component:"Search",type:"usernames",getLabels:l.wd}},order:{labels:{add:(0,o.__)("Order #","dokan"),placeholder:(0,o.__)("Search order number","dokan"),remove:(0,o.__)("Remove order number filter","dokan"),rule:(0,o.__)("Select a order number filter match","dokan"),
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title:(0,o.__)("<title>Order #</title> <rule/> <filter/>","dokan"),filter:(0,o.__)("Select order number","dokan")},rules:[{value:"includes",
/* translators: Sentence fragment, logical, "Includes" refers to order numbers including a given order(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Includes","order numbers","dokan")},{value:"excludes",
/* translators: Sentence fragment, logical, "Excludes" refers to order numbers excluding a given order(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Excludes","order numbers","dokan")}],input:{component:"Search",type:"orders",getLabels:async e=>{const t=e.split(",");return await t.map(e=>({id:e,label:"#"+e}))}}},ip_address:{labels:{add:(0,o.__)("IP Address","dokan"),placeholder:(0,o.__)("Search IP address","dokan"),remove:(0,o.__)("Remove IP address filter","dokan"),rule:(0,o.__)("Select an IP address filter match","dokan"),
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title:(0,o.__)("<title>IP Address</title> <rule/> <filter/>","dokan"),filter:(0,o.__)("Select IP address","dokan")},rules:[{value:"includes",
/* translators: Sentence fragment, logical, "Includes" refers to IP addresses including a given address(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Includes","IP addresses","dokan")},{value:"excludes",
/* translators: Sentence fragment, logical, "Excludes" refers to IP addresses excluding a given address(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label:(0,o._x)("Excludes","IP addresses","dokan")}],input:{component:"Search",type:"downloadIps",getLabels:async e=>{const t=e.split(",");return await t.map(e=>({id:e,label:e}))}}}}});var p=r(7143),m=r(8468),y=r(6154),h=r.n(y),g=r(8846),_=r(6476),f=r(3577),b=r(5703),v=r(314),k=r(7374),S=r(4111),C=r(8660),w=r(274),R=r(790);class x extends a.Component{constructor(){super(),this.getHeadersContent=this.getHeadersContent.bind(this),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:(0,o.__)("Date","dokan"),key:"date",defaultSort:!0,required:!0,isLeftAligned:!0,isSortable:!0},{label:(0,o.__)("Product title","dokan"),key:"product",isSortable:!0,required:!0},{label:(0,o.__)("File name","dokan"),key:"file_name"},{label:(0,o.__)("Order #","dokan"),screenReaderLabel:(0,o.__)("Order Number","dokan"),key:"order_number"},{label:(0,o.__)("Username","dokan"),key:"user_id"},{label:(0,o.__)("IP","dokan"),key:"ip_address"}]}getRowsContent(e){const{query:t}=this.props,r=(0,_.getPersistedQuery)(t),a=(0,w.Qk)("dateFormat",k.defaultTableDateFormat);return(0,m.map)(e,e=>{const{_embedded:t,date:s,file_name:n,file_path:i,ip_address:l,order_id:d,order_number:c,product_id:u,username:p}=e,{code:m,name:y}=t.product[0];let h,f;if("woocommerce_rest_product_invalid_id"===m)h=(0,o.__)("(Deleted)","dokan"),f=(0,o.__)("(Deleted)","dokan");else{const e=(0,_.getNewPath)(r,"/analytics/products",{filter:"single_product",products:u});h=(0,R.jsx)(g.Link,{href:e,type:"wc-admin",children:y}),f=y}return[{display:(0,R.jsx)(g.Date,{date:s,visibleFormat:a}),value:s},{display:h,value:f},{display:(0,R.jsx)(g.Link,{href:i,type:"external",children:n}),value:n},{display:(0,R.jsx)(g.Link,{href:(0,b.getAdminLink)(`post.php?post=${d}&action=edit`),type:"wp-admin",children:c}),value:c},{display:p,value:p},{display:l,value:l}]})}getSummary(e){const{download_count:t=0}=e,{query:r,defaultDateRange:a}=this.props,s=(0,k.getCurrentDates)(r,a),n=h()(s.primary.after),i=h()(s.primary.before).diff(n,"days")+1,l=this.context.getCurrencyConfig();return[{label:(0,o._n)("day","days",i,"dokan"),value:(0,f.formatValue)(l,"number",i)},{label:(0,o._n)("Download","Downloads",t,"dokan"),value:(0,f.formatValue)(l,"number",t)}]}render(){const{query:e,filters:t,advancedFilters:r}=this.props;return(0,R.jsx)(C.A,{endpoint:"downloads",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["download_count"],query:e,tableQuery:{_embed:!0},title:(0,o.__)("Downloads","dokan"),columnPrefsKey:"downloads_report_columns",filters:t,advancedFilters:r})}}x.contextType=S.CurrencyContext;const D=(0,p.withSelect)(e=>{const{woocommerce_default_date_range:t}=e(v.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings");return{defaultDateRange:t}})(x);var q=r(331),T=r(2703),F=r(9581),E=r(8222);class A extends a.Component{render(){const{query:e,path:t}=this.props;return(0,R.jsxs)(a.Fragment,{children:[(0,R.jsx)(E.A,{query:e,path:t,filters:c,advancedFilters:u,report:"downloads"}),(0,R.jsx)(F.A,{charts:d,endpoint:"downloads",query:e,selectedChart:(0,q.A)(e.chart,d),filters:c,advancedFilters:u}),(0,R.jsx)(T.A,{charts:d,endpoint:"downloads",path:t,query:e,selectedChart:(0,q.A)(e.chart,d),filters:c,advancedFilters:u}),(0,R.jsx)(D,{query:e,filters:c,advancedFilters:u})]})}}A.propTypes={query:n().object.isRequired}},2694(e,t,r){"use strict";var a=r(6925);function s(){}function n(){}n.resetWarningCache=s,e.exports=function(){function e(e,t,r,s,n,o){if(o!==a){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:n,resetWarningCache:s};return r.PropTypes=r,r}},2703(e,t,r){"use strict";r.d(t,{A:()=>S});var a=r(7723),s=r(6087),n=r(9491),o=r(8443),i=r(7143),l=r(8468),d=r(5556),c=r.n(d),u=r(8846),p=r(314),m=r(7374),y=r(4111),h=r(4351),g=r(6476);function _(e,t,r={}){if(!e||0===e.length)return null;const a=e.slice(0),s=a.pop();if(s.showFilters(t,r)){const e=(0,g.flattenFilters)(s.filters),r=t[s.param]||s.defaultValue||"all";return(0,l.find)(e,{value:r})}return _(a,t,r)}function f(e){return t=>(0,o.format)(e,t)}function b(e){if(e?.data?.intervals?.length>1){const t=e.data.intervals[0].date_start,r=e.data.intervals[e.data.intervals.length-1].date_end;if(m.containsLeapYear&&(0,m.containsLeapYear)(t,r))return!0}return!1}var v=r(790);class k extends s.Component{shouldComponentUpdate(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!(0,l.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 a=r[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;r[e.segment_id]={label:a,value:e.subtotals[t.key]||0}}}),{date:(0,o.format)("Y-m-d\\TH:i:s",e.date_start),...r}})}getTimeChartData(){const{query:e,primaryData:t,secondaryData:r,selectedChart:a,defaultDateRange:s}=this.props,n=(0,m.getIntervalForQuery)(e,s),{primary:i,secondary:l}=(0,m.getCurrentDates)(e,s);return function(e,t,r,a,s,n,i){const l=b(e),d=b(t),c=[...e.data.intervals],u=[...t.data.intervals],p=[];for(let e=0;e<c.length;e++){const t=c[e],y=(0,o.format)("Y-m-d\\TH:i:s",t.date_start),h=`${r.label} (${r.range})`,g=t.date_start,_=t.subtotals[n]||0,f=u[e],b=`${a.label} (${a.range})`;let v=(0,m.getPreviousDate)(t.date_start,r.after,a.after,s,i).format("YYYY-MM-DD HH:mm:ss"),k=f&&f.subtotals[n]||0;if("day"===i&&l&&!d&&u?.[e]){const r=new Date(t.date_start),a=new Date(u[e].date_start);(0,m.isLeapYear)(r.getFullYear())&&1===r.getMonth()&&29===r.getDate()&&2===a.getMonth()&&1===a.getDate()&&(v="-",k=0,u.splice(e,0,u[e]))}p.push({date:y,primary:{label:h,labelDate:g,value:_},secondary:{label:b,labelDate:v,value:k}})}return p}(t,r,i,l,e.compare,a.key,n)}getTimeChartTotals(){const{primaryData:e,secondaryData:t,selectedChart:r}=this.props;return{primary:(0,l.get)(e,["data","totals",r.key],null),secondary:(0,l.get)(t,["data","totals",r.key],null)}}renderChart(e,t,r,s){const{emptySearchResults:n,filterParam:o,interactiveLegend:i,itemsLabel:l,legendPosition:d,path:c,query:y,selectedChart:h,showHeaderControls:g,primaryData:_,defaultDateRange:b}=this.props,k=(0,m.getIntervalForQuery)(y,b),S=(0,m.getAllowedIntervalsForQuery)(y,b),C=(0,m.getDateFormatsForInterval)(k,_.data.intervals.length,{type:"php"}),w=n?(0,a.__)("No data for the current search","dokan"):(0,a.__)("No data for the selected date range","dokan"),{formatAmount:R,getCurrencyConfig:x}=this.context;return(0,v.jsx)(u.Chart,{allowedIntervals:S,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:w,filterParam:o,interactiveLegend:i,interval:k,isRequesting:t,itemsLabel:l,legendPosition:d,legendTotals:s,mode:e,path:c,query:y,screenReaderFormat:f(C.screenReaderFormat),showHeaderControls:g,title:h.label,tooltipLabelFormat:f(C.tooltipLabelFormat),tooltipTitle:"time-comparison"===e&&h.label||null,tooltipValueFormat:(0,p.getTooltipValueFormat)(h.type,R),chartType:(0,m.getChartTypeForQuery)(y),valueType:h.type,xFormat:f(C.xFormat),x2Format:f(C.x2Format),currency:x()})}renderItemComparison(){const{isRequesting:e,primaryData:t}=this.props;if(t.isError)return(0,v.jsx)(h.A,{});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,v.jsx)(h.A,{});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()}}k.contextType=y.CurrencyContext,k.propTypes={filters:c().array,isRequesting:c().bool,itemsLabel:c().string,limitProperties:c().array,mode:c().string,path:c().string.isRequired,primaryData:c().object,query:c().object.isRequired,secondaryData:c().object,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},k.defaultProps={isRequesting:!1,primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};const S=(0,n.compose)((0,i.withSelect)((e,t)=>{const{charts:r,endpoint:a,filters:s,isRequesting:n,limitProperties:o,query:i,advancedFilters:d}=t,c=o||[a],u=_(s,i),m=(0,l.get)(u,["settings","param"]),y=t.mode||function(e,t){if(e&&t){const r=(0,l.get)(e,["settings","param"]);if(!r||Object.keys(t).includes(r))return(0,l.get)(e,["chartMode"])}return null}(u,i)||"time-comparison",{woocommerce_default_date_range:h}=e(p.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings"),g=e(p.REPORTS_STORE_NAME),f={mode:y,filterParam:m,defaultDateRange:h};if(n)return f;const b=c.some(e=>i[e]&&i[e].length);if(i.search&&!b)return{...f,emptySearchResults:!0};const v=r&&r.map(e=>e.key),k=(0,p.getReportChartData)({endpoint:a,dataType:"primary",query:i,selector:g,limitBy:c,filters:s,advancedFilters:d,defaultDateRange:h,fields:v});if("item-comparison"===y)return{...f,primaryData:k};const S=(0,p.getReportChartData)({endpoint:a,dataType:"secondary",query:i,selector:g,limitBy:c,filters:s,advancedFilters:d,defaultDateRange:h,fields:v});return{...f,primaryData:k,secondaryData:S}}))(k)},4351(e,t,r){"use strict";r.d(t,{A:()=>d});var a=r(7723),s=r(5556),n=r.n(s),o=r(8846),i=r(790);function l({className:e}){const t=(0,a.__)("There was an error getting your stats. Please try again.","dokan"),r=(0,a.__)("Reload","dokan");return(0,i.jsx)(o.EmptyContent,{className:e,title:t,actionLabel:r,actionCallback:()=>{window.location.reload()}})}l.propTypes={className:n().string};const d=l},4924(e,t,r){"use strict";r.d(t,{H:()=>s});var a=r(7723);function s(e){return[e.country,e.state,e.name||(0,a.__)("TAX","dokan"),e.priority].map(e=>e.toString().toUpperCase().trim()).filter(Boolean).join("-")}},5556(e,t,r){e.exports=r(2694)()},6925(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},7057(e,t,r){"use strict";r.d(t,{Dn:()=>u,U4:()=>m,aG:()=>p,b8:()=>f,jx:()=>g,p0:()=>h,wd:()=>y,xP:()=>_});var a=r(3832),s=r(1455),n=r.n(s),o=r(8468),i=r(6476),l=r(4924),d=r(274);const c="/wc-analytics";function u(e,t=o.identity){return function(r="",s){const o="function"==typeof e?e(s):e,l=(0,i.getIdsFromQuery)(r);if(l.length<1)return Promise.resolve([]);const d={include:l.join(","),per_page:l.length};return n()({path:(0,a.addQueryArgs)(o,d)}).then(e=>e.map(t))}}u(c+"/products/attributes",e=>({key:e.id,label:e.name}));const p=u(c+"/products/categories",e=>({key:e.id,label:e.name})),m=u(c+"/coupons",e=>({key:e.id,label:e.code})),y=u(c+"/customers",e=>({key:e.id,label:e.name})),h=u(c+"/products",e=>({key:e.id,label:e.name})),g=u(c+"/taxes",e=>({key:e.id,label:(0,l.H)(e)}));function _({attributes:e,name:t}){const r=(0,d.Qk)("variationTitleAttributesSeparator"," - ");if(t&&t.indexOf(r)>-1)return t;const a=(e||[]).map(({option:e})=>e).join(", ");return a?t+r+a:t}const f=u(({products:e})=>e?c+`/products/${e}/variations`:c+"/variations",e=>({key:e.id,label:_(e)}))},8222(e,t,r){"use strict";r.d(t,{A:()=>f});var a=r(6087),s=r(9491),n=r(5556),o=r.n(n),i=r(8468),l=r(7143),d=r(7752),c=r(8846),u=r(314),p=r(7374),m=r(3306),y=r(4111),h=r(274),g=r(790);class _ extends a.Component{constructor(){super(),this.onDateSelect=this.onDateSelect.bind(this),this.onFilterSelect=this.onFilterSelect.bind(this),this.onAdvancedFilterAction=this.onAdvancedFilterAction.bind(this)}onDateSelect(e){const{report:t,addCesSurveyForAnalytics:r}=this.props;r(),(0,m.recordEvent)("datepicker_update",{report:t,...(0,i.omitBy)(e,i.isUndefined)})}onFilterSelect(e){const{report:t,addCesSurveyForAnalytics:r}=this.props,a=e.filter||e["filter-variations"];["single_product","single_category","single_coupon","single_variation"].includes(a)&&r();const s={report:t,filter:e.filter||"all"};"single_product"===e.filter&&(s.filter_variation=e["filter-variations"]||"all"),(0,m.recordEvent)("analytics_filter",s)}onAdvancedFilterAction(e,t){const{report:r,addCesSurveyForAnalytics:a}=this.props;switch(e){case"add":(0,m.recordEvent)("analytics_filters_add",{report:r,filter:t.key});break;case"remove":(0,m.recordEvent)("analytics_filters_remove",{report:r,filter:t.key});break;case"filter":const e=Object.keys(t).reduce((e,r)=>(e[(0,i.snakeCase)(r)]=t[r],e),{});a(),(0,m.recordEvent)("analytics_filters_filter",{report:r,...e});break;case"clear_all":(0,m.recordEvent)("analytics_filters_clear_all",{report:r});break;case"match":(0,m.recordEvent)("analytics_filters_all_any",{report:r,value:t.match})}}render(){const{advancedFilters:e,filters:t,path:r,query:a,showDatePicker:s,defaultDateRange:n}=this.props,{period:o,compare:i,before:l,after:d}=(0,p.getDateParamsFromQuery)(a,n),{primary:u,secondary:m}=(0,p.getCurrentDates)(a,n),y={period:o,compare:i,before:l,after:d,primaryDate:u,secondaryDate:m},_=this.context;return(0,g.jsx)(c.ReportFilters,{query:a,siteLocale:h.ne.siteLocale,currency:_.getCurrencyConfig(),path:r,filters:t,advancedFilters:e,showDatePicker:s,onDateSelect:this.onDateSelect,onFilterSelect:this.onFilterSelect,onAdvancedFilterAction:this.onAdvancedFilterAction,dateQuery:y,isoDateFormat:p.isoDateFormat})}}_.contextType=y.CurrencyContext;const f=(0,s.compose)((0,l.withSelect)(e=>{const{woocommerce_default_date_range:t}=e(u.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings");return{defaultDateRange:t}}),(0,l.withDispatch)(e=>{const{addCesSurveyForAnalytics:t}=e(d.STORE_KEY);return{addCesSurveyForAnalytics:t}}))(_);_.propTypes={advancedFilters:o().object,filters:o().array,path:o().string.isRequired,query:o().object,showDatePicker:o().bool,report:o().string.isRequired}},8660(e,t,r){"use strict";r.d(t,{A:()=>R});var a=r(6427),s=r(2619),n=r(6087),o=r(9491),i=r(8107),l=r(7143),d=r(8468),c=r(7723),u=r(5556),p=r.n(u),m=r(7752),y=r(8846),h=r(6476),g=r(1554),_=r(314),f=r(3306),b=r(790);const v=()=>(0,b.jsx)("svg",{role:"img","aria-hidden":"true",focusable:"false",version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",children:(0,b.jsx)("path",{d:"M18,9c-0.009,0-0.017,0.002-0.025,0.003C17.72,5.646,14.922,3,11.5,3C7.91,3,5,5.91,5,9.5c0,0.524,0.069,1.031,0.186,1.519 C5.123,11.016,5.064,11,5,11c-2.209,0-4,1.791-4,4c0,1.202,0.541,2.267,1.38,3h18.593C22.196,17.089,23,15.643,23,14 C23,11.239,20.761,9,18,9z M12,16l-4-5h3V8h2v3h3L12,16z"})});var k=r(4351);const S=e=>{const{getHeadersContent:t,getRowsContent:r,getSummary:o,isRequesting:l,primaryData:u,tableData:p,endpoint:m,itemIdField:S,tableQuery:C,compareBy:w,compareParam:R,searchBy:x,labels:D={},...q}=e,{query:T,columnPrefsKey:F}=e,{items:E,query:A}=p,P=T[R]?(0,h.getIdsFromQuery)(T[w]):[],[j,I]=(0,n.useState)(P),N=(0,n.useRef)(null),{updateUserPreferences:O,...L}=(0,_.useUserPreferences)();if(p.isError||u.isError)return(0,b.jsx)(k.A,{});let Q=[];F&&(Q=L&&L[F]?L[F]:Q);const V=(e,a,n)=>{const i=o?o(a,n):null;return(0,s.applyFilters)("dokan_analytics_report_table",{endpoint:m,headers:t(),rows:r(e),totals:a,summary:i,items:E})},B=t=>{const{ids:r}=e;I(t?r:[])},M=(t,r)=>{const{ids:a}=e;if(r)I((0,d.uniq)([a[t],...j]));else{const e=j.indexOf(a[t]);I([...j.slice(0,e),...j.slice(e+1)])}},H=t=>{const{ids:r=[]}=e,s=-1!==j.indexOf(r[t]);return{display:(0,b.jsx)(a.CheckboxControl,{onChange:(0,d.partial)(M,t),checked:s}),value:!1}},Y=l||p.isRequesting||u.isRequesting,U=(0,d.get)(u,["data","totals"],{}),G=E.totalResults||0,$=G>0,K=(0,h.getSearchWords)(T).map(e=>({key:e,label:e})),{data:W}=E,z=V(W,U,G);let{headers:X,rows:J}=z;const{summary:Z}=z;w&&(J=J.map((e,t)=>[H(t),...e]),X=[(()=>{const{ids:t=[]}=e,r=t.length>0,s=r&&t.length===j.length;return{cellClassName:"is-checkbox-column",key:"compare",label:(0,b.jsx)(a.CheckboxControl,{onChange:B,"aria-label":(0,c.__)("Select All","dokan"),checked:s,disabled:!r}),required:!0}})(),...X]);const ee=((e,t)=>t?e.map(e=>({...e,visible:e.required||!t.includes(e.key)})):e.map(e=>({...e,visible:e.required||!e.hiddenByDefault})))(X,Q);return(0,b.jsxs)(n.Fragment,{children:[(0,b.jsx)("div",{className:"woocommerce-report-table__scroll-point",ref:N,"aria-hidden":!0}),(0,b.jsx)(y.TableCard,{className:"woocommerce-report-table",hasSearch:!!x,actions:[w&&(0,b.jsx)(y.CompareButton,{className:"woocommerce-table__compare",count:j.length,helpText:D.helpText||(0,c.__)("Check at least two items below to compare","dokan"),onClick:()=>{w&&(0,h.onQueryChange)("compare")(w,R,j.join(","))},disabled:!$,children:D.compareButton||(0,c.__)("Compare","dokan")},"compare"),x&&(0,b.jsx)(y.Search,{allowFreeTextSearch:!0,inlineTags:!0,onChange:t=>{const{baseSearchQuery:r,addCesSurveyForCustomerSearch:a}=e,s=t.map(e=>e.label.replace(",","%2C"));s.length?((0,h.updateQueryString)({filter:void 0,[R]:void 0,[x]:void 0,...r,search:(0,d.uniq)(s).join(",")}),a()):(0,h.updateQueryString)({search:void 0}),(0,f.recordEvent)("analytics_table_filter",{report:m})},placeholder:D.placeholder||(0,c.__)("Search by item name","dokan"),selected:K,showClearButton:!0,type:x,disabled:!$},"search"),$&&(0,b.jsxs)(a.Button,{className:"woocommerce-table__download-button",disabled:Y,onClick:()=>{const{createNotice:t,startExport:r,title:a}=e,s=Object.assign({},T),{data:n,totalResults:o}=E;let i="browser";if(delete s.extended_info,s.search&&delete s[x],n&&n.length===o){const{headers:e,rows:t}=V(n,o);(0,g.downloadCSVFile)((0,g.generateCSVFileName)(a,s),(0,g.generateCSVDataFromTable)(e,t))}else i="email",r(m,A).then(()=>t("success",(0,c.sprintf)(/* translators: %s = type of report */ /* translators: %s = type of report */
(0,c.__)("Your %s Report will be emailed to you.","dokan"),a))).catch(e=>t("error",e.message||(0,c.sprintf)(/* translators: %s = type of report */ /* translators: %s = type of report */
(0,c.__)("There was a problem exporting your %s Report. Please try again.","dokan"),a)));(0,f.recordEvent)("analytics_table_download",{report:m,rows:o,download_type:i})},children:[(0,b.jsx)(v,{}),(0,b.jsx)("span",{className:"woocommerce-table__download-button__label",children:D.downloadButton||(0,c.__)("Download","dokan")})]},"download")],headers:ee,isLoading:Y,onQueryChange:h.onQueryChange,onColumnsChange:(e,t)=>{const r=X.map(e=>e.key).filter(t=>!e.includes(t));if(F&&O({[F]:r}),t){const r={report:m,column:t,status:e.includes(t)?"on":"off"};(0,f.recordEvent)("analytics_table_header_toggle",r)}},onSort:(e,t)=>{(0,h.onQueryChange)("sort")(e,t);const r={report:m,column:e,direction:t};(0,f.recordEvent)("analytics_table_sort",r)},onPageChange:(e,t)=>{N.current.scrollIntoView();const r=N.current.nextSibling.querySelector(".woocommerce-table__table"),a=i.focus.focusable.find(r);a.length&&a[0].focus(),t&&("goto"===t?(0,f.recordEvent)("analytics_table_go_to_page",{report:m,page:e}):(0,f.recordEvent)("analytics_table_page_click",{report:m,direction:t}))},rows:J,rowsPerPage:parseInt(A.per_page,10)||_.QUERY_DEFAULTS.pageSize,summary:Z,totalRows:G,...q})]})};S.propTypes={baseSearchQuery:p().object,compareBy:p().string,compareParam:p().string,columnPrefsKey:p().string,endpoint:p().string,extendItemsMethodNames:p().shape({getError:p().string,isRequesting:p().string,load:p().string}),extendedItemsStoreName:p().string,getHeadersContent:p().func.isRequired,getRowsContent:p().func.isRequired,getSummary:p().func,itemIdField:p().string,labels:p().shape({compareButton:p().string,downloadButton:p().string,helpText:p().string,placeholder:p().string}),primaryData:p().object,searchBy:p().string,summaryFields:p().arrayOf(p().string),tableData:p().object.isRequired,tableQuery:p().object,title:p().string.isRequired},S.defaultProps={primaryData:{},tableData:{items:{data:[],totalResults:0},query:{}},tableQuery:{},compareParam:"filter",downloadable:!1,onSearch:d.noop,baseSearchQuery:{}};const C=[],w={},R=(0,o.compose)((0,l.withSelect)((e,t)=>{const{endpoint:r,getSummary:a,isRequesting:s,itemIdField:n,query:o,tableData:i,tableQuery:l,filters:c,advancedFilters:u,summaryFields:p,extendedItemsStoreName:m}=t,y=e(_.REPORTS_STORE_NAME),h=m?e(m):null,{woocommerce_default_date_range:g}=e(_.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings"),f=o.search&&!(o[r]&&o[r].length);if(s||f)return w;const b="categories"===r?"products":r,v=a?(0,_.getReportChartData)({endpoint:b,selector:y,dataType:"primary",query:o,filters:c,advancedFilters:u,defaultDateRange:g,fields:p}):w,k=i||(0,_.getReportTableData)({endpoint:r,query:o,selector:y,tableQuery:l,filters:c,advancedFilters:u,defaultDateRange:g}),S=h?function(e,t,r){const{extendItemsMethodNames:a,itemIdField:s}=t,n=r.items.data;if(!(Array.isArray(n)&&n.length&&a&&s))return r;const{[a.getError]:o,[a.isRequesting]:i,[a.load]:l}=e,c={include:n.map(e=>e[s]).join(","),per_page:n.length},u=l(c),p=!!i&&i(c),m=!!o&&o(c),y=n.map(e=>{const t=(0,d.first)(u.filter(t=>e.id===t.id));return{...e,...t}}),h=r.isRequesting||p,g=r.isError||m;return{...r,isRequesting:h,isError:g,items:{...r.items,data:y}}}(h,t,k):k;return{primaryData:v,ids:n&&S.items.data?S.items.data.map(e=>e[n]):C,tableData:S,query:o}}),(0,l.withDispatch)(e=>{const{startExport:t}=e(_.EXPORT_STORE_NAME),{createNotice:r}=e("core/notices"),{addCesSurveyForCustomerSearch:a}=e(m.STORE_KEY);return{createNotice:r,startExport:t,addCesSurveyForCustomerSearch:a}}))(S)},9581(e,t,r){"use strict";r.d(t,{A:()=>b});var a=r(7723),s=r(6087),n=r(9491),o=r(7143),i=r(5556),l=r.n(i),d=r(6476),c=r(8846),u=r(3577),p=r(314),m=r(7374),y=r(3306),h=r(4111),g=r(4351),_=r(790);class f extends s.Component{formatVal(e,t){const{formatAmount:r,getCurrencyConfig:a}=this.context;return"currency"===t?r(e):(0,u.formatValue)(a(),t,e)}getValues(e,t){const{emptySearchResults:r,summaryData:a}=this.props,{totals:s}=a,n=s.primary?s.primary[e]:0,o=s.secondary?s.secondary[e]:0,i=r?0:n,l=r?0:o;return{delta:(0,u.calculateDelta)(i,l),prevValue:this.formatVal(l,t),value:this.formatVal(i,t)}}render(){const{charts:e,query:t,selectedChart:r,summaryData:s,endpoint:n,report:o,defaultDateRange:i}=this.props,{isError:l,isRequesting:u}=s;if(l)return(0,_.jsx)(g.A,{});if(u)return(0,_.jsx)(c.SummaryListPlaceholder,{numberOfItems:e.length});const{compare:p}=(0,m.getDateParamsFromQuery)(t,i);return(0,_.jsx)(c.SummaryList,{children:({onToggle:t})=>e.map(e=>{const{key:s,order:i,orderby:l,label:u,type:m,isReverseTrend:h,labelTooltipText:g}=e,f={chart:s};l&&(f.orderby=l),i&&(f.order=i);const b=(0,d.getNewPath)(f),v=r.key===s,{delta:k,prevValue:S,value:C}=this.getValues(s,m);return(0,_.jsx)(c.SummaryNumber,{delta:k,href:b,label:u,reverseTrend:h,prevLabel:"previous_period"===p?(0,a.__)("Previous period:","dokan"):(0,a.__)("Previous year:","dokan"),prevValue:S,selected:v,value:C,labelTooltipText:g,onLinkClickCallback:()=>{t&&t(),(0,y.recordEvent)("analytics_chart_tab_click",{report:o||n,key:s})}},s)})})}}f.propTypes={charts:l().array.isRequired,endpoint:l().string.isRequired,limitProperties:l().array,query:l().object.isRequired,selectedChart:l().shape({key:l().string.isRequired,label:l().string.isRequired,order:l().oneOf(["asc","desc"]),orderby:l().string,type:l().oneOf(["average","number","currency"]).isRequired}).isRequired,summaryData:l().object,report:l().string},f.defaultProps={summaryData:{totals:{primary:{},secondary:{}},isError:!1}},f.contextType=h.CurrencyContext;const b=(0,n.compose)((0,o.withSelect)((e,t)=>{const{charts:r,endpoint:a,limitProperties:s,query:n,filters:o,advancedFilters:i}=t,l=s||[a],d=l.some(e=>n[e]&&n[e].length);if(n.search&&!d)return{emptySearchResults:!0};const c=r&&r.map(e=>e.key),{woocommerce_default_date_range:u}=e(p.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings");return{summaryData:(0,p.getSummaryNumbers)({endpoint:a,query:n,select:e,limitBy:l,filters:o,advancedFilters:i,defaultDateRange:u,fields:c}),defaultDateRange:u}}))(f)}}]);