"use strict";(self.webpackChunkautonami=self.webpackChunkautonami||[]).push([[5199],{97374(t,e,a){a.r(e),a.d(e,{default:()=>w});var r=a(86087),n=a(27723),o=a(16432),s=a(97482),c=a(43690),i=a(10163),l=a(66087),m=a(14014),u=a(87361),f=a(83583),d=a(39078),p=(a(13032),a(36766)),y=a(88766),_=a(26387);function b(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?v(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,r=Array(e);a<e;a++)r[a]=t[a];return r}const w=function(){var t=(0,d.Zr)(),e=t.isFeaturesLocked,a=t.isLite,v=(0,s.A)(),w=v.fetchContactAnalytics,Y=v.setContactAnalyticsData,h=(0,p.A.getContactAnalytics)();(0,m.A)("contacts",!1,"");var g=(0,c.$Z)(),M=function(t){return t.compare="previous_year",(0,i.lI)(t).primary};g.hasOwnProperty("period")||(g.period="month");var A=g.period,k=g.compare,E=g.interval,C=g.after,D=g.before;(0,r.useEffect)(function(){if((0,f.Ls)("Contact Analytics"),e){for(var t=M(g),a=0,r=0,n=0,o=0,s=[],c=t.after;c.isBefore(t.before);c.add(1,"days")){var i=Math.floor(10*Math.random()),m=Math.floor(Math.random()*parseInt(i)),u=Math.floor(Math.random()*parseInt(i));a+=i,r+=m,n+=i,o+=u,s.push({date_end_gmt:c.format("YYYY-MM-DD")+" 23:59:59",date_start_gmt:c.format("YYYY-MM-DD")+" 00:00:00",end_date:c.format("YYYY-MM-DD")+" 23:59:59",interval:c.format("YYYY-MM-DD"),start_date:c.format("YYYY-MM-DD")+" 00:00:00",subtotals:{total_contacts:a,total_customers:r,new_contacts:i,unsubscribers:u}})}Y("data",{totals:{total_contacts:a,total_customers:r,new_contacts:n,unsubscribers:o},intervals:s}),Y("isLoading",!1)}else{var d=g.hasOwnProperty("interval")?g.interval:"day";!function(t,e){var a=M(t),r="",n="";a&&((0,l.isEmpty)(a.after)||(r=a.after.format("YYYY-MM-DD HH:mm:ss")),(0,l.isEmpty)(a.before)||(n=a.before.format("YYYY-MM-DD 23:59:59")),(0,l.isEmpty)(r)||(0,l.isEmpty)(n)||w(r,n,e))}(g,d)}},[A,k,E,C,D]);var L=function(t){if(!h||!h.hasOwnProperty("totals"))return 0;var e=h.totals;return e.hasOwnProperty(t)?e[t]:void 0},N=function(t){return[{key:"new_contacts",title:(0,n.__)("New Contacts","wp-marketing-automations"),icon:"add-user",value:L("new_contacts")},{key:"total_contacts",title:(0,n.__)("Total Contacts","wp-marketing-automations"),icon:"contact-new",value:L("total_contacts")}].concat(b((0,f.Nj)()?[{key:"total_customers",title:(0,n.__)("Total Customers","wp-marketing-automations"),icon:"visitors",value:L("total_customers")}]:[]),[{key:"unsubscribers",title:(0,n.__)("Unsubscribers","wp-marketing-automations"),icon:"unsubscribes",value:L("unsubscribers")}])};return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"bwf-content-header-new"},(0,r.createElement)("div",{className:"bwf-content-header-left"},(0,r.createElement)("div",{className:"bwf-content-header-title"},(0,n.__)("Contacts","wp-marketing-automations")))),(0,r.createElement)(u.A,null),(0,r.createElement)("div",{className:"bwf-crm-analytics-wrap bwf-crm-contacts-report-wrap"},!a&&e&&(0,r.createElement)(_.A,{onPage:!0,modalContent:{proLink:(0,f.L4)("upgrade",{utm_medium:"Contact+Analytics+Upgrade+Modal"})}}),(0,r.createElement)(o.uR,{query:g},a&&(0,r.createElement)(y.A,{title:(0,n.__)("Contact Analytics","wp-marketing-analytics"),message:(0,n.__)("Use our sample data to explore Contact Analytics. See how contact and customer growth and review impact of your campaigns.","wp-marketing-automations"),proLink:(0,f.L4)("upgrade",{utm_medium:"Contact+Analytics+Sample+Data+Notice"})})),(0,r.createElement)("div",{className:"bwf_clear_2"}),(0,r.createElement)(o.C,{query:g,metrics:N()}),(0,r.createElement)(o.Zc,{query:g,metrics:N()})))}}}]);