(globalThis.webpackChunkstoresuite=globalThis.webpackChunkstoresuite||[]).push([[703],{7617(e,t,r){"use strict";r.r(t),r.d(t,{default:()=>T});var s=r(6087),a=r(7723),o=r(9491),n=r(7143),i=r(6427),l=r(6773),c=r(1993),d=r(3679),u=r(5556),h=r.n(u),p=r(638),b=r(3365),f=r(1086),m=r(4622),y=r(790);function g(e){if(!e||!e.includes("admin.php"))return e;const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("a[href]").forEach(e=>{try{const t=new URL(e.getAttribute("href"),window.location.href).href;e.setAttribute("href",(0,b.Lx)(t))}catch{}}),t.innerHTML}function _(e){const t=e.target.closest("a");t&&(e.preventDefault(),(0,d.getHistory)().push(t.getAttribute("href")))}class w extends s.Component{getFormattedHeaders(){return(this.props.headers||[]).map((e,t)=>({isLeftAligned:0===t,hiddenByDefault:!1,isSortable:!1,key:e.label,label:e.label}))}getFormattedRows(){return(this.props.rows||[]).map(e=>e.map(e=>({display:(0,y.jsx)("span",{dangerouslySetInnerHTML:{__html:g(e.display)},onClick:_}),value:e.value})))}renderContent(){const{isRequesting:e,isError:t,totalRows:r,title:s}=this.props,o="storesuite-leaderboard";if(t)return(0,y.jsxs)(i.Card,{className:o,children:[(0,y.jsx)(i.CardHeader,{children:(0,y.jsx)("h3",{className:"storesuite-leaderboard__title",children:s})}),(0,y.jsx)(i.CardBody,{children:(0,y.jsx)(l.EmptyTable,{children:(0,a.__)("There was an error loading this leaderboard.","storesuite")})})]});const n=this.getFormattedRows();return e||0!==n.length?(0,y.jsx)(l.TableCard,{className:o,headers:this.getFormattedHeaders(),isLoading:e,rows:n,rowsPerPage:r,showMenu:!1,title:s,totalRows:r}):(0,y.jsxs)(i.Card,{className:o,children:[(0,y.jsx)(i.CardHeader,{children:(0,y.jsx)("h3",{className:"storesuite-leaderboard__title",children:s})}),(0,y.jsx)(i.CardBody,{children:(0,y.jsx)(l.EmptyTable,{children:(0,a.__)("No data recorded for the selected time period.","storesuite")})})]})}render(){return(0,y.jsx)(m.A,{children:this.renderContent()})}}w.defaultProps={headers:[],rows:[],isError:!1,isRequesting:!1};const x=(0,o.compose)((0,n.withSelect)((e,t)=>{const{id:r,query:s,totalRows:a}=t,o={id:r,per_page:a,persisted_query:{},query:s,select:e,defaultDateRange:f.I};return(0,c.getLeaderboard)(o)}))(w);function T({query:e}){const t=(0,p.Qk)("dataEndpoints",{leaderboards:[]}).leaderboards||[],[r,a]=(0,s.useState)(()=>parseInt(function(){try{return localStorage.getItem("storesuite_dashboard_leaderboard_rows")||"5"}catch{return"5"}}(),7)),o=t.find(e=>"products"===e.id);return o?(0,y.jsx)(s.Fragment,{children:(0,y.jsx)(x,{id:o.id,title:o.label,headers:o.headers,query:e,totalRows:r})}):null}T.propTypes={query:h().object.isRequired}},4622(e,t,r){"use strict";r.d(t,{A:()=>o});var s=r(6087),a=r(790);function o({children:e,className:t=""}){const r=(0,s.useRef)(null);return(0,s.useEffect)(()=>{const e=r.current;if(!e)return;const t=()=>{e.querySelectorAll(".woocommerce-table__table table").forEach(e=>{const t=Array.from(e.querySelectorAll(".woocommerce-table__header")).map(e=>e.textContent.trim());t.length&&e.querySelectorAll("tbody tr").forEach(e=>{e.querySelectorAll(".woocommerce-table__item").forEach((e,r)=>{t[r]&&e.setAttribute("data-label",t[r])})})})};t();const s=new window.MutationObserver(t);return s.observe(e,{childList:!0,subtree:!0}),()=>s.disconnect()},[]),(0,a.jsx)("div",{className:`storesuite-responsive-table ${t}`.trim(),ref:r,children:e})}},2694(e,t,r){"use strict";var s=r(6925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,r,a,o,n){if(n!==s){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:o,resetWarningCache:a};return r.PropTypes=r,r}},5556(e,t,r){e.exports=r(2694)()},6925(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}}]);