(window.webpackJsonp=window.webpackJsonp||[]).push([[84],{1483:function(t,e,r){"use strict";r.r(e);var n=r(0),o=r(1),a=r(1065),i=r(344),c=function(t){var e=t.metrics,r=(0,a.a.getEmailAnalyticsLoading)();return Object(n.createElement)("div",{className:"bwf-crm-emails-report-tiles"},Object(n.createElement)(i.a,{items:e,title:Object(o.__)("Overview","wp-marketing-automations"),isLoading:r}))},u=r(340),l=r(24),s=r(2),f=r(5),p=r(6),m=r.n(p),y=r(12);function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),h}},e}function A(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function T(t){for(var e=1;e=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),h}},e}function F(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function G(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function C(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1?arguments[1]:void 0;if(e.hasOwnProperty("filter")){var r=0;return"broadcast"==e.filter?r=2:"automation"==e.filter&&(r=1),E()({path:Object(d.A)("/analytics/entity/data/?type=".concat(r,"&oid=").concat(t)),method:"GET"}).then((function(t){return 200==t.code&&t.hasOwnProperty("result")?[{key:t.result.id,label:t.result.title}]:[]}))}},i=[{staticParams:["page","path","period","chart","chartType"],param:"filter",showFilters:function(){return!0},filters:[{label:Object(o.__)("All SMS","wp-marketing-automations"),value:"all"}]}];if(Object(d.ac)()){var c=[{label:Object(o.__)("Single Automation","wp-marketing-automations"),value:"select_automation",subFilters:[{component:"Search",value:"automation",path:["select_automation"],autocompleter:N,settings:{type:"custom",param:"id",selected:!0,getLabels:a,labels:{placeholder:Object(o.__)("Type to search for a automation","wp-marketing-automations"),button:Object(o.__)("Automation","wp-marketing-automations")}}}]},{label:Object(o.__)("Single Broadcast","wp-marketing-automations"),value:"select_broadcast",subFilters:[{component:"Search",value:"broadcast",path:["select_broadcast"],autocompleter:U,settings:{type:"custom",param:"id",getLabels:a,labels:{placeholder:Object(o.__)("Type to search for a broadcast","wp-marketing-automations"),button:Object(o.__)("Broadcast","wp-marketing-automations")}}}]}];i[0].filters=[].concat(z(i[0].filters),c)}return Object(n.createElement)("div",{className:"bwf-crm-emails-report-filter"},r,Object(n.createElement)(g.a,{siteLocale:"en-US",path:"/",query:e,filterTitle:Object(o.__)("Email","wp-marketing-automations"),filters:i,onDateSelect:function(t){var r=B(B({},e),t);delete r.compare,Object(y.l)(r,"/",{})},showDatePicker:!0,isoDateFormat:l.j,hideCompare:!0,dateQuery:function(t){t.compare="previous_year";var e=Object(l.g)(t),r=e.period,n=e.compare,o=e.before,a=e.after,i=Object(l.e)(t);return{period:r,compare:n,before:o,after:a,primaryDate:i.primary,secondaryDate:i.secondary}}(e),currency:Object(d.zb)()}))},K=r(1092),V=r(1093),W=r(47),X=r(70),Z=r(146),tt=r(1067),et=r(1094);function rt(t){return function(t){if(Array.isArray(t))return nt(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 nt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nt(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 nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0,c=m(t),u="",l="";c&&(Object(s.isEmpty)(c.after)||(u=c.after.format("YYYY-MM-DD HH:mm:ss")),Object(s.isEmpty)(c.before)||(l=c.before.format("YYYY-MM-DD 23:59:59")),Object(s.isEmpty)(u)||Object(s.isEmpty)(l)||(n&&r(u,l,e,Y,I,2),i(o,a,u,l,e,Y,I,2)))};Object(n.useEffect)((function(){if(Object(d.m)(Object(o.__)("SMS Analytics","wp-marketing-automations")),Object(d.ac)()){var t=p.hasOwnProperty("interval")?p.interval:"day";G(p,t,!0,S,k)}else{for(var e=m(p),r=0,n=0,a=0,i=0,c=[],l=e.after;l.isBefore(e.before);l.add(1,"days")){var s=Math.floor(11*Math.random()),y=Math.floor(Math.random()*parseInt(s)),h=Math.floor(Math.random()*parseInt(y)),b=Math.floor(100*Math.random());c.push({date_end_gmt:l.format("YYYY-MM-DD")+" 23:59:59",date_start_gmt:l.format("YYYY-MM-DD")+" 00:00:00",end_date:l.format("YYYY-MM-DD")+" 23:59:59",interval:l.format("YYYY-MM-DD"),start_date:l.format("YYYY-MM-DD")+" 00:00:00",subtotals:{click_rate:(y/s*100).toFixed(2),email_click:y,email_sents:s,total_orders:h,total_revenue:b}}),r+=s,n+=y,a+=h,i+=b}f("data",{totals:{click_rate:(n/r*100).toFixed(2),email_click:n,email_sents:r,total_orders:a,total_revenue:i},intervals:c}),f("isLoading",!1),u("data",[{click_count:n,click_rate:(n/r*100).toFixed(2),conversions:a,oid:"5",revenue:i,sent:r,subject:Object(o.__)("Dummy Message","wp-marketing-automations"),template:"",tid:"52",title:Object(o.__)("Dummy SMS","wp-marketing-automations"),type:"1"}]),u("isLoading",!1)}}),[A,M,T,D,N,Y,I]);var C,q=[{key:"message",label:Object(o.__)("Message","wp-marketing-automations"),isLeftAligned:!0,cellClassName:"bwf-w-360 bwf-max-w-400"},{key:"source",label:Object(o.__)("Source","wp-marketing-automations"),isLeftAligned:!1},{key:"sent",label:Object(o.__)("Sent","wp-marketing-automations"),isLeftAligned:!0,isNumeric:!0},{key:"click",label:Object(o.__)("Click","wp-marketing-automations"),isLeftAligned:!1,isNumeric:!0},Object(d.qc)()?{key:"orders",label:Object(o.__)("Orders","wp-marketing-automations"),isLeftAligned:!0}:{},Object(d.qc)()?{key:"revenue",label:Object(o.__)("Revenue","wp-marketing-automations"),isLeftAligned:!1,isNumeric:!0}:{}],U=function(t){if(t!==S){u("limit",t);var e=p.hasOwnProperty("interval")?p.interval:"day";G(p,e,!1,t,k)}},H=function(t){if(!F||!F.hasOwnProperty("totals"))return 0;var e=F.totals;return e.hasOwnProperty(t)?e[t]:void 0},R=function(e){return[{key:"email_sents",title:Object(o.__)("Sent","wp-marketing-automations"),icon:"sent",value:parseInt(H("email_sents"))},{key:"email_click",title:Object(o.__)("Clicks","wp-marketing-automations"),icon:"open-rate",value:parseInt(H("email_click"))}].concat(rt(Object(d.qc)()?[{key:"total_orders",title:Object(o.__)("Orders","wp-marketing-automations"),icon:"open-rate",value:parseInt(H("total_orders"))},{key:"total_revenue",title:Object(o.__)("Revenue","wp-marketing-automations"),icon:"open-rate",value:t(H("total_revenue")),isCurrency:!0}]:[]))};return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("div",{className:"bwf-content-header-new"},Object(n.createElement)("div",{className:"bwf-content-header-left"},Object(n.createElement)("div",{className:"bwf-content-header-title"},Object(o.__)("SMS","wp-marketing-automations")))),Object(n.createElement)(X.a,null),Object(n.createElement)("div",{className:"bwf-crm-analytics-wrap bwf-crm-emails-report-wrap bwf-table-with-border"},!d.Yb&&!Object(d.ac)()&&Object(n.createElement)(tt.a,{onPage:!0,modalContent:{proLink:Object(d.fb)("upgrade",{utm_medium:"SMS+Analytics+Upgrade+Modal"})}}),Object(n.createElement)(Q,{query:p},d.Yb&&Object(n.createElement)(et.a,{title:Object(o.__)("SMS Analytics","wp-marketing-automations"),message:Object(o.__)("Use our sample data to explore SMS Analytics. Use these trends to find out best time to send campaigns.","wp-marketing-automations"),proLink:Object(d.fb)("upgrade",{utm_medium:"SMS+Analytics+Sample+Data+Notice"})})),Object(n.createElement)("div",{className:"bwf_clear_2"}),Object(n.createElement)(c,{query:p,metrics:R()}),Object(n.createElement)(v,{query:p,metrics:R()}),Object(n.createElement)(Z.a,{title:Object(o.__)("SMS","wp-marketing-automations"),rows:(C=[],Object(s.isEmpty)(P)||P.map((function(e){var r=parseFloat(e.click_rate)?" ( "+parseFloat(e.click_rate).toFixed(2)+"% ) ":"";C.push([{display:e.template?Object(n.createElement)("div",{className:"bwf-pre-line"},e.template):"-",value:e.subject},{display:e.title?e.title:"-",value:e.title},{display:parseInt(e.sent)?parseInt(e.sent):"-",value:e.sent},{display:parseInt(e.click_count)?e.click_count+r:"-",value:e.click_count},Object(d.qc)()?{display:parseInt(e.conversions)?parseInt(e.conversions):"-",value:e.conversions}:{},Object(d.qc)()?{display:e&&e.hasOwnProperty("revenue")&&e.revenue?t(e.revenue):"-",value:e.revenue,isCurrency:!0}:{}])})),C),headers:q,query:{paged:L},rowsPerPage:S?parseInt(S):25,totalRows:x,isLoading:E,onPageChange:function(t,e){var r=(t-1)*S;u("offset",r);var n=p.hasOwnProperty("interval")?p.interval:"day";G(p,n,!1,S,r)},onQueryChange:function(t){return"per_page"!==t?function(){}:U},showMenu:!1,rowHeader:!0,hideHeader:"yes",emptyMessage:Object(o.__)("No SMS found","wp-marketing-automations")})))}}}]);