PATH:
home
/
lab2454c
/
caimegroup.com
/
wp-content
/
plugins
/
mailpoet
/
assets
/
dist
/
js
/*! For license information please see admin.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([[328],{49868:function(){jQuery.AsyncQueue=function(){var e,t,a,s,n=this,o=[],r=!1;return s=function(){var e=o.shift();e?(e.apply(n,[n]),!1===r&&s()):t&&t.apply(n)},this.onFailure=function(t){e=t},this.onComplete=function(e){t=e},this.add=function(e){return o.push(e),this},this.storeData=function(e){return a=e,this},this.lastCallbackData=function(){return a},this.run=function(){r=!1,s()},this.pause=function(){return r=!0,this},this.failure=function(){if(r=!0,e){var t=[n];for(i=0;i<arguments.length;i++)t.push(arguments[i]);e.apply(n,t)}},this}},67163:function(e,t,a){"use strict";var i={};a.r(i),a.d(i,{hideProductDiscovery:function(){return E},hideTaskList:function(){return T},hideUpsell:function(){return A}});var s={};a.r(s),a.d(s,{getCanDisplayUpsell:function(){return K},getCanImportWooCommerceSubscribers:function(){return D},getCurrentTask:function(){return Y},getGlobalSubscriberStatsChange:function(){return V},getHasForms:function(){return $},getHasImportedSubscribers:function(){return L},getIsFreeMailUser:function(){return B},getIsNewUserForSenderDomainAuth:function(){return q},getIsProductDiscoveryDone:function(){return z},getIsProductDiscoveryHidden:function(){return U},getIsTaskListHidden:function(){return R},getIsUpsellHidden:function(){return G},getIsWooCommerceActive:function(){return Z},getListsSubscriberStatsChange:function(){return H},getMssActive:function(){return W},getProductDiscoveryTasksStatus:function(){return O},getTasksStatus:function(){return F}});var n=a(2226),o=a(70079),r=a(89912),l=a(14526),d=a(44259),c=a(69177),m=a(92883),u=a(82299),p=a(35250);function h({mailpoetInstalledDaysAgo:e,sendTransactionalEmails:t,mtaMethod:a,noticeDismissed:i,apiVersion:s}){const[n,r]=(0,o.useState)(!1),l=()=>{c.MailPoet.Ajax.post({api_version:s,endpoint:"UserFlags",action:"set",data:{transactional_emails_opt_in_notice_dismissed:"1"}})};return e<30||t||"PHPMail"===a||i||n?null:(0,p.jsxs)(u.q,{type:"success",timeout:!1,onClose:l,children:[(0,p.jsx)("h3",{children:c.MailPoet.I18n.t("transactionalEmailNoticeTitle")}),(0,p.jsxs)("p",{children:[c.MailPoet.I18n.t("transactionalEmailNoticeBody")," ",(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/292-choose-how-to-send-your-wordpress-websites-emails",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("transactionalEmailNoticeBodyReadMore")})]}),(0,p.jsx)("p",{children:(0,p.jsx)("button",{type:"button",className:"button",onClick:()=>{r(!0),c.MailPoet.Ajax.post({api_version:s,endpoint:"settings",action:"set",data:{send_transactional_emails:"1"}}),l()},children:c.MailPoet.I18n.t("transactionalEmailNoticeCTA")})})]})}h.displayName="TransactionalEmailsProposeOptInNotice";var g=a(87658),_=a(34352),f=a.n(_);function b(){if(!c.MailPoet.subscribersLimitReached)return null;const e=c.MailPoet.hasValidApiKey,t=c.MailPoet.subscribersLimit.toLocaleString();let a=c.MailPoet.I18n.t("subscribersLimitNoticeTitleUnknownLimit"),i=c.MailPoet.I18n.t("subscribersLimitReachedUnknownLimit"),s="";c.MailPoet.subscribersLimit&&(a=c.MailPoet.I18n.t("subscribersLimitNoticeTitle").replace("[subscribersLimit]",t),s=c.MailPoet.I18n.t(e?"yourPlanLimit":"freeVersionLimit").replace("[subscribersLimit]",t),i=c.MailPoet.I18n.t("subscribersLimitReached").replace("[subscribersLimit]",t));const n=e?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(c.MailPoet.pluginPartialKey):c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount+1),o=f()(c.MailPoet.I18n.t("checkHowToManageSubscribers"),/\[link](.*?)\[\/link]/g,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/348-subscribers-limit-for-sending-plans",children:e},"checkManageSubscribers")));return(0,p.jsxs)(u.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,p.jsx)("h3",{children:a}),(0,p.jsxs)("p",{children:[i," ",s," ",c.MailPoet.I18n.t("youNeedToUpgrade"),(0,p.jsx)("br",{}),"active"===c.MailPoet.wpSegmentState?o:null," ",c.MailPoet.I18n.t("actToSeamlessService")]}),(0,p.jsxs)("p",{children:[(0,p.jsx)("a",{target:"_blank",rel:"noopener noreferrer",className:"button button-primary",href:n,children:c.MailPoet.I18n.t("upgradeNow")}),e&&(0,p.jsxs)(p.Fragment,{children:[" ",(0,p.jsx)("button",{type:"button",className:"button",onClick:async()=>{await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"services",action:"recheckKeys"}),window.location.reload()},children:c.MailPoet.I18n.t("refreshMySubscribers")})]})]})]})}b.displayName="SubscribersLimitNotice";var x=a(26973);function v(){if(!c.MailPoet.emailVolumeLimitReached)return null;let e=c.MailPoet.I18n.t("emailVolumeLimitNoticeTitleUnknownLimit"),t=c.MailPoet.I18n.t("youReachedEmailVolumeLimitUnknownLimit");c.MailPoet.emailVolumeLimit&&(e=c.MailPoet.I18n.t("emailVolumeLimitNoticeTitle").replace("[emailVolumeLimit]",c.MailPoet.emailVolumeLimit.toLocaleString()),t=c.MailPoet.I18n.t("youReachedEmailVolumeLimit").replace("[emailVolumeLimit]",c.MailPoet.emailVolumeLimit.toLocaleString()));const a=c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(c.MailPoet.pluginPartialKey),i=new Date,s=new Date(i.getFullYear(),i.getMonth()+1,1);let n=f()(c.MailPoet.I18n.t("toContinueUpgradeYourPlanOrWaitUntil"),/\[link](.*?)\[\/link]/g,(e=>(0,p.jsx)("a",{target:"_blank",rel:"noreferrer",href:a,children:e},e)));return n=f()(n,/<b>\[date]<\/b>\./g,(()=>(0,x.ZP)(`<b>${c.MailPoet.Date.short(s)}</b>.`))),(0,p.jsxs)(u.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,p.jsx)("h3",{children:e}),(0,p.jsxs)("p",{children:[t,(0,p.jsx)("br",{}),n]}),(0,p.jsxs)("p",{children:[(0,p.jsx)("a",{target:"_blank",rel:"noopener noreferrer",className:"button button-primary",href:a,children:c.MailPoet.I18n.t("upgradeNow")})," ",(0,p.jsx)("button",{type:"button",className:"button",onClick:async()=>{await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"services",action:"recheckKeys"}),window.location.reload()},children:c.MailPoet.I18n.t("refreshMyEmailVolumeLimit")})]})]})}v.displayName="EmailVolumeLimitNotice";const j=(0,r.withBoundary)(v);function y({mssKeyInvalid:e,subscribersCount:t}){return e?(0,p.jsxs)(u.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,p.jsx)("h3",{children:c.MailPoet.I18n.t("allSendingPausedHeader")}),(0,p.jsx)("p",{children:f()(c.MailPoet.I18n.t("allSendingPausedBody"),/\[link\](.*?)\[\/link\]/g,(e=>(0,p.jsx)("a",{href:"?page=mailpoet-settings#premium",children:e},"check-sending")))}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{href:`https://account.mailpoet.com?s=${t}`,className:"button button-primary",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("allSendingPausedLink")})})]}):null}function w(){return(0,p.jsxs)(r.ErrorBoundary,{children:[c.MailPoet.subscribersLimitReached&&(0,p.jsx)(b,{}),c.MailPoet.emailVolumeLimitReached&&(0,p.jsx)(j,{}),!c.MailPoet.subscribersLimitReached&&!c.MailPoet.emailVolumeLimitReached&&(0,p.jsx)(y,{mssKeyInvalid:c.MailPoet.hasInvalidMssApiKey,subscribersCount:c.MailPoet.subscribersCount})]})}function S(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(m.w,{}),(0,p.jsx)(w,{}),(0,p.jsx)(h,{mailpoetInstalledDaysAgo:c.MailPoet.installedDaysAgo,sendTransactionalEmails:c.MailPoet.transactionalEmailsEnabled,mtaMethod:c.MailPoet.mtaMethod,apiVersion:c.MailPoet.apiVersion,noticeDismissed:c.MailPoet.transactionalEmailsOptInNoticeDismissed}),(0,p.jsx)(g._,{mtaLog:c.MailPoet.mtaLog,mtaMethod:c.MailPoet.mtaMethod,isInline:!0})]})}y.displayName="InvalidMssKeyNotice";var P=a(21229),M=a(33584),N=a(14275),C=a(96082),I=a(43160),k=a(76944);function*T(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*E(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*A(){return yield(0,k.t)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function R(e){return e.taskList.isTaskListHidden}function F(e){return e.taskList.tasksStatus}function O(e){return e.productDiscovery.tasksStatus}function D(e){return e.taskList.canImportWooCommerceSubscribers}function L(e){return e.taskList.hasImportedSubscribers}function q(e){return e.taskList.isNewUserForSenderDomainAuth}function B(e){return e.taskList.isFreeMailUser}function W(e){return e.taskList.mssActive}function $(e){return e.formsCount>0}function U(e){return e.productDiscovery.isHidden}function V(e){return e.subscribersStats.global}function H(e){return e.subscribersStats.lists}function z(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function Z(e){return e.isWooCommerceActive}function Y(e){return e.taskList.tasksStatus.senderSet?e.taskList.tasksStatus.mssConnected?!e.taskList.tasksStatus.wooSubscribersImported&&e.taskList.canImportWooCommerceSubscribers?"wooSubscribersImported":e.taskList.tasksStatus.subscribersAdded?null:"subscribersAdded":"mssConnected":"senderSet"}function G(e){return e.upsell.isHidden}function K(e){return e.upsell.upsellStatus?.canDisplay}function Q(e,t){switch(t.type){case"SET_TASK_LIST_HIDDEN":return{...e,taskList:{...e.taskList,isTaskListHidden:!0}};case"SET_PRODUCT_DISCOVERY_HIDDEN":return{...e,productDiscovery:{...e.productDiscovery,isHidden:!0}};case"SET_UPSELL_HIDDEN":return{...e,upsell:{...e.upsell,isHidden:!0}};default:return e}}const J="mailpoet/homepage",X={};var ee=a(91908),te=a(64052),ae=a(26372),ie=a.n(ae);function se(e,t,a){c.MailPoet.trackEvent(e,{ctaLabel:t},{send_immediately:!0},(()=>{window.location.href=a}))}function ne({title:e,titleCompleted:t="",slug:a,link:i,order:s,isCompleted:n,isActive:o,children:r=null}){const l=ie()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":n,"mailpoet-task-list__task--active":o}),d=()=>{se("Home Page Task",a,i)};return(0,p.jsxs)("li",{className:l,role:"row",onClick:n?void 0:d,tabIndex:n?void 0:0,onKeyDown:n?void 0:e=>"Enter"===e.key&&d(),children:[(0,p.jsx)("div",{className:"mailpoet-task-list__task-before",children:(0,p.jsx)("div",{className:"mailpoet-task-list__task-icon",children:n?(0,p.jsx)(ee.Z,{icon:te.Z}):s})}),(0,p.jsxs)("div",{className:"mailpoet-task-list__task-content",children:[(0,p.jsx)("div",{className:"mailpoet-task-list__task-title",children:n&&t?t:e}),r]})]})}function oe({onHide:e}){const{tasksStatus:t,currentTask:a,hasImportedSubscribers:i,canImportWooCommerceSubscribers:s,isNewUserForSenderDomainAuth:n,isFreeMailUser:o,mssActive:l}=(0,P.Z)((e=>({tasksStatus:e(J).getTasksStatus(),currentTask:e(J).getCurrentTask(),hasImportedSubscribers:e(J).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(J).getCanImportWooCommerceSubscribers(),isNewUserForSenderDomainAuth:e(J).getIsNewUserForSenderDomainAuth(),isFreeMailUser:e(J).getIsFreeMailUser(),mssActive:e(J).getMssActive()})),[]),d=[];if(d.push((0,p.jsx)(ne,{slug:"set sender",title:c.MailPoet.I18n.t("senderSetTask"),titleCompleted:c.MailPoet.I18n.t("senderSetTaskDone"),link:"admin.php?page=mailpoet-settings#/basics",order:1,isCompleted:t.senderSet,isActive:"senderSet"===a},"senderSet")),d.push((0,p.jsx)(ne,{slug:"connect mss",title:c.MailPoet.I18n.t("mssConnectedTask"),titleCompleted:c.MailPoet.I18n.t("mssConnectedTaskDone"),link:"admin.php?page=mailpoet-settings#/premium",order:2,isCompleted:t.mssConnected,isActive:"mssConnected"===a},"mssConnected")),s&&d.push((0,p.jsx)(ne,{slug:"import woocommerce subscribers",title:c.MailPoet.I18n.t("wooSubscribersImportedTask"),titleCompleted:c.MailPoet.I18n.t("wooSubscribersImportedTaskDone"),link:"admin.php?page=mailpoet-woocommerce-setup",order:3,isCompleted:t.wooSubscribersImported,isActive:"wooSubscribersImported"===a},"wooSubscribersImported")),d.push((0,p.jsxs)(ne,{slug:"add subscribers",title:c.MailPoet.I18n.t("subscribersAddedTask"),titleCompleted:i?c.MailPoet.I18n.t("subscribersAddedTaskDoneByImport"):c.MailPoet.I18n.t("subscribersAddedTaskDoneByForm"),link:"admin.php?page=mailpoet-import",order:s?4:3,isCompleted:t.subscribersAdded,isActive:"subscribersAdded"===a,children:[!t.subscribersAdded&&(0,p.jsxs)("p",{children:[c.MailPoet.I18n.t("noSubscribersQuestion")," ",(0,p.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:r.stopLinkPropagation,children:c.MailPoet.I18n.t("setUpForm")})]}),t.subscribersAdded&&!i&&(0,p.jsxs)("p",{children:[c.MailPoet.I18n.t("haveSubscribersQuestion")," ",(0,p.jsx)("a",{href:"admin.php?page=mailpoet-import",children:c.MailPoet.I18n.t("import")})]})]},"subscribersAdded")),n&&l){let e="admin.php?page=mailpoet-settings#/basics";o||(e="admin.php?page=mailpoet-settings#/basics/authorizedEmailModal"),d.push((0,p.jsx)(ne,{slug:"authenticate sender domain",title:c.MailPoet.I18n.t("senderDomainAuthenticatedTask"),titleCompleted:c.MailPoet.I18n.t("senderDomainAuthenticatedTaskDone"),link:e,order:s?5:4,isCompleted:t.senderDomainAuthenticated,isActive:"senderDomainAuthenticated"===a,children:!t.senderDomainAuthenticated&&(0,p.jsx)("p",{children:c.MailPoet.I18n.t("improveDeliveryRates")})},"senderDomainAuthenticated"))}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-task-list__heading",children:[(0,p.jsx)("h1",{children:c.MailPoet.I18n.t("welcomeToMailPoet")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("beginByCompletingSetup")}),(0,p.jsx)(M.Z,{label:c.MailPoet.I18n.t("hideList"),icon:N.Z,controls:[{title:c.MailPoet.I18n.t("hideList"),onClick:e,icon:null}]})]}),(0,p.jsx)("ul",{children:d.map((e=>e))}),!a&&(0,p.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[c.MailPoet.I18n.t("youAreSet")," ",(0,p.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:c.MailPoet.I18n.t("dismissList")})]})]})}function re({title:e,slug:t,link:a,description:i,doneMessage:s,imgSrc:n,isDone:o}){const r=()=>{se("Home Page Task",t,a)};return(0,p.jsxs)("li",{className:ie()("mailpoet-product-discovery__task",{"mailpoet-product-discovery__task--completed":o}),role:"row",onClick:o?void 0:r,tabIndex:o?void 0:0,onKeyDown:o?void 0:e=>"Enter"===e.key&&r(),children:[(0,p.jsx)("img",{src:n,alt:e,width:124,height:72}),(0,p.jsx)("div",{className:"mailpoet-product-discovery__task-content",children:o?(0,p.jsx)("h3",{children:s}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h3",{children:`${e} →`}),i&&(0,p.jsx)("p",{children:i})]})}),(0,p.jsx)("div",{className:"mailpoet-product-discovery__task-after",children:o&&(0,p.jsx)("div",{className:"mailpoet-task-list__task-icon",children:(0,p.jsx)(ee.Z,{icon:te.Z})})})]})}function le({heading:e,description:t,children:a,headingAfter:i,className:s=""}){return(0,p.jsxs)("section",{className:ie()("mailpoet-homepage-section__container",s),children:[(0,p.jsxs)("header",{className:"mailpoet-homepage-section__heading",children:[(0,p.jsxs)("h2",{children:[e,t&&(0,p.jsx)("span",{children:t})]}),(0,p.jsx)("div",{className:"mailpoet-homepage-section__heading-after",children:i})]}),a]})}function de({onHide:e}){const{tasksStatus:t,isWooCommerceActive:a,isDiscoveryDone:i}=(0,P.Z)((e=>({tasksStatus:e(J).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(J).getIsWooCommerceActive(),isDiscoveryDone:e(J).getIsProductDiscoveryDone()})),[]),s=[];return s.push((0,p.jsx)(re,{slug:"set up welcome campaign",title:c.MailPoet.I18n.t("setUpWelcomeCampaign"),description:c.MailPoet.I18n.t("setUpWelcomeCampaignDesc"),link:"admin.php?page=mailpoet-automation-templates",imgSrc:`${c.MailPoet.cdnUrl}homepage/welcome-email-illustration.png`,isDone:t.setUpWelcomeCampaign,doneMessage:c.MailPoet.I18n.t("setUpWelcomeCampaignDone")},"setUpWelcomeCampaign"),(0,p.jsx)(re,{slug:"add subscription form",title:c.MailPoet.I18n.t("addSubscriptionForm"),description:c.MailPoet.I18n.t("addSubscriptionFormDesc"),link:"admin.php?page=mailpoet-form-editor-template-selection",imgSrc:`${c.MailPoet.cdnUrl}homepage/subscription-form-illustration.png`,isDone:t.addSubscriptionForm,doneMessage:c.MailPoet.I18n.t("addSubscriptionFormDone")},"addSubscriptionForm")),a?s.push((0,p.jsx)(re,{slug:"set up abandoned cart email",title:c.MailPoet.I18n.t("setUpAbandonedCartEmail"),description:c.MailPoet.I18n.t("setUpAbandonedCartEmailDesc"),link:"admin.php?page=mailpoet-newsletters#/new/woocommerce/woocommerce_abandoned_shopping_cart/conditions",imgSrc:`${c.MailPoet.cdnUrl}homepage/woo-cart-email-illustration.png`,isDone:t.setUpAbandonedCartEmail,doneMessage:c.MailPoet.I18n.t("setUpAbandonedCartEmailDone")},"setUpAbandonedCartEmail"),(0,p.jsx)(re,{slug:"brand woocommerce emails",title:c.MailPoet.I18n.t("brandWooEmails"),description:c.MailPoet.I18n.t("brandWooEmailsDesc"),link:"admin.php?page=mailpoet-settings#/woocommerce",imgSrc:`${c.MailPoet.cdnUrl}homepage/woo-transactional-email-illustration.png`,isDone:t.brandWooEmails,doneMessage:c.MailPoet.I18n.t("brandWooEmailsDone")},"brandWooEmails")):s.push((0,p.jsx)(re,{slug:"send first newsletter",title:c.MailPoet.I18n.t("sendFirstNewsletter"),description:c.MailPoet.I18n.t("sendFirstNewsletterDesc"),link:"admin.php?page=mailpoet-newsletters#/new",imgSrc:`${c.MailPoet.cdnUrl}homepage/newsletter-illustration.png`,isDone:t.sendFirstNewsletter,doneMessage:c.MailPoet.I18n.t("sendFirstNewsletterDone")},"sendFirstNewsletter")),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(le,{className:"mailpoet-homepage-product-discovery",heading:c.MailPoet.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,p.jsx)(M.Z,{label:c.MailPoet.I18n.t("hideList"),icon:N.Z,controls:[{title:c.MailPoet.I18n.t("hideList"),onClick:e,icon:null}]}),children:(0,p.jsx)("ul",{children:s.map((e=>e))})}),i&&(0,p.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[c.MailPoet.I18n.t("allDone")," ",(0,p.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:c.MailPoet.I18n.t("dismissTasks")})]})]})}var ce=a(59098),me=a(16519),ue=a(40311),pe=a(18258),he=a(65752),ge=a(21263);function _e({closable:e,onHide:t}){return(0,p.jsx)(le,{className:"mailpoet-homepage-upsell",heading:c.MailPoet.I18n.t("accelerateYourGrowth"),headingAfter:e&&t?(0,p.jsx)(ge.ZP,{icon:ce.Z,onClick:t,label:c.MailPoet.I18n.t("close")}):null,children:(0,p.jsxs)("div",{className:"mailpoet-homepage-upsell__content",children:[(0,p.jsxs)("ul",{children:[(0,p.jsxs)("li",{children:[(0,p.jsx)(ee.Z,{icon:me.Z}),(0,p.jsx)("span",{children:c.MailPoet.I18n.t("detailedAnalytics")})]}),(0,p.jsxs)("li",{children:[(0,p.jsx)(ee.Z,{icon:ue.Z}),(0,p.jsx)("span",{children:c.MailPoet.I18n.t("advancedSubscriberSegmentation")})]}),(0,p.jsxs)("li",{children:[(0,p.jsx)(ee.Z,{icon:pe.Z}),(0,p.jsx)("span",{children:c.MailPoet.I18n.t("emailMarketingAutomations")})]}),(0,p.jsxs)("li",{children:[(0,p.jsx)(ee.Z,{icon:he.Z}),(0,p.jsx)("span",{children:c.MailPoet.I18n.t("prioritySupport")})]})]}),(0,p.jsx)(ge.ZP,{variant:"primary",href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"business",{utm_source:"plugin",utm_medium:"homepage",utm_campaign:"upsell"}),children:c.MailPoet.I18n.t("upgradePlan")})]})})}var fe=a(14029),be=a(47384);function xe({id:e,engagementScore:t}){const a={unknown:{name:c.MailPoet.I18n.t("unknownBadgeName"),type:"unknown",tooltipTitle:c.MailPoet.I18n.t("unknownBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipUnknown")},excellent:{name:c.MailPoet.I18n.t("excellentBadgeName"),type:"excellent",tooltipTitle:c.MailPoet.I18n.t("excellentBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipExcellent")},good:{name:c.MailPoet.I18n.t("goodBadgeName"),type:"good",tooltipTitle:c.MailPoet.I18n.t("goodBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipGood")},average:{name:c.MailPoet.I18n.t("averageBadgeName"),type:"average",tooltipTitle:c.MailPoet.I18n.t("averageBadgeTooltip"),tooltipText:c.MailPoet.I18n.t("tooltipAverage")}},i=`badge-${e}`;let s;s=null==t?a.unknown:t<20?a.average:t<50?a.good:a.excellent;const n=(0,p.jsxs)("div",{children:[(0,p.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:s.tooltipTitle.toUpperCase()}),(0,p.jsx)("div",{className:"mailpoet-listing-stats-tooltip-description",children:c.MailPoet.I18n.t("engagementScoreDescription")}),(0,p.jsxs)("div",{className:"mailpoet-listing-stats-tooltip-content",children:[(0,p.jsx)(be.C,{type:"unknown",name:c.MailPoet.I18n.t("unknownBadgeName")})," : ",a.unknown.tooltipText,(0,p.jsx)("br",{}),(0,p.jsx)(be.C,{type:"excellent",name:c.MailPoet.I18n.t("excellentBadgeName")})," : ",a.excellent.tooltipText,(0,p.jsx)("br",{}),(0,p.jsx)(be.C,{type:"good",name:c.MailPoet.I18n.t("goodBadgeName")})," : ",a.good.tooltipText,(0,p.jsx)("br",{}),(0,p.jsx)(be.C,{type:"average",name:c.MailPoet.I18n.t("averageBadgeName")})," : ",a.average.tooltipText]})]},`tooltip-${i}`);return(0,p.jsxs)("div",{className:"mailpoet-listing-stats-opened-clicked",children:[null!=t&&(0,p.jsxs)("div",{className:"mailpoet-listing-stats-percentages",children:[t.toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),"%"]}),(0,p.jsx)("div",{children:(0,p.jsx)(be.C,{isInverted:!0,type:s.type,name:s.name,tooltip:n,tooltipId:i,tooltipPlace:"top"})})]})}const ve=(e,t,a)=>{e.preventDefault(),se("Home Page Statistics Click",t,a)};function je(){const{globalChange:e,listsChange:t,hasForms:a}=(0,P.Z)((e=>({globalChange:e(J).getGlobalSubscriberStatsChange(),listsChange:e(J).getListsSubscriberStatsChange(),hasForms:e(J).getHasForms()})),[]),i=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,p.jsx)(le,{className:"mailpoet-subscribers-stats",heading:c.MailPoet.I18n.t("subscribersHeading"),description:c.MailPoet.I18n.t("subscribersSectionDescription"),headingAfter:!i&&(0,p.jsxs)("span",{className:ie()({"mailpoet-decrease":e.changePercent<0}),children:[(0,p.jsx)(ee.Z,{icon:me.Z}),e.changePercent<0&&"-",Math.abs(e.changePercent)>1e3?"∞%":`${Math.abs(e.changePercent)}%`]}),children:i?(0,p.jsxs)("div",{className:"mailpoet-subscribers-stats-empty",children:[(0,p.jsx)(ee.Z,{icon:me.Z,viewBox:"-4 -4 32 32"}),a?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("subscriberCountHasNotChangeLongTime")}),(0,p.jsx)("a",{href:"admin.php?page=mailpoet-newsletters#/new",onClick:e=>ve(e,"campaigns","admin.php?page=mailpoet-newsletters#/new"),children:c.MailPoet.I18n.t("exploreCampaigns")})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("p",{children:[c.MailPoet.I18n.t("changesWillAppear"),(0,p.jsx)("br",{}),c.MailPoet.I18n.t("starBySettingUpForm")]}),(0,p.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:e=>ve(e,"new form","admin.php?page=mailpoet-form-editor-template-selection"),children:c.MailPoet.I18n.t("createForm")})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-subscribers-stats-global-change",children:[(0,p.jsxs)("div",{children:[c.MailPoet.I18n.t("newSubscribers"),(0,p.jsx)("br",{}),(0,p.jsx)("span",{children:e.subscribed})]}),(0,p.jsxs)("div",{children:[c.MailPoet.I18n.t("unsubscribedSubscribers"),(0,p.jsx)("br",{}),(0,p.jsx)("span",{children:e.unsubscribed})]})]}),!!t.length&&(0,p.jsxs)("table",{className:"mailpoet-subscribers-stats-list-change-table",children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{children:c.MailPoet.I18n.t("listName")}),(0,p.jsx)("th",{children:c.MailPoet.I18n.t("listScore")}),(0,p.jsx)("th",{children:c.MailPoet.I18n.t("subscribedSubscribers")}),(0,p.jsx)("th",{children:c.MailPoet.I18n.t("unsubscribedSubscribers")})]})}),(0,p.jsx)("tbody",{children:t.map((e=>(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:(0,p.jsx)("a",{href:`admin.php?page=mailpoet-subscribers#/page[1]/sort_by[created_at]/sort_order[desc]/group[all]/filter[segment=${e.id}]`,children:e.name})}),(0,p.jsx)("td",{children:(0,p.jsx)("div",{className:"mailpoet-listing-stats",children:(0,p.jsx)(xe,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,p.jsx)("td",{children:e.subscribed}),(0,p.jsx)("td",{children:e.unsubscribed})]},e.id)))})]})]})})}var ye=a(91023),we=a(27773);function Se({link:e,abstract:t,title:a,imgSrc:i}){return(0,p.jsxs)("a",{className:"mailpoet-resource-post",href:e,target:"_blank",rel:"noreferrer",children:[(0,p.jsx)("img",{src:i,alt:a,width:"292",height:"166"}),(0,p.jsx)("h3",{children:a}),(0,p.jsx)("p",{children:t})]})}function Pe(){const[e,t]=(0,o.useState)(1),a=[(0,p.jsx)(Se,{link:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("createAnEmailAbstract"),title:c.MailPoet.I18n.t("createAnEmailTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/add_email.png`},"createAnEmail"),(0,p.jsx)(Se,{link:"https://kb.mailpoet.com/article/297-create-a-form-with-our-new-editor?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("createAFormAbstract"),title:c.MailPoet.I18n.t("createAFormTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/add_form.png`},"createAForm"),(0,p.jsx)(Se,{link:"https://www.mailpoet.com/blog/email-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("segmentationGuideAbstract"),title:c.MailPoet.I18n.t("segmentationGuideTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/segmentation.png`},"segmentationGuide"),(0,p.jsx)(Se,{link:"https://www.mailpoet.com/blog/re-engagement-emails/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("reEngagementAbstract"),title:c.MailPoet.I18n.t("reEngagementTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/reengagement.png`},"reEngagement"),(0,p.jsx)(Se,{link:"https://www.mailpoet.com/blog/newsletter-marketing-strategy/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("marketingStrategyAbstract"),title:c.MailPoet.I18n.t("marketingStrategyTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/marketing.png`},"marketingStrategy"),(0,p.jsx)(Se,{link:"https://www.mailpoet.com/blog/how-to-promote-your-sales-with-email-marketing-mailpoet-woocommerce-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:c.MailPoet.I18n.t("promotingSalesAbstract"),title:c.MailPoet.I18n.t("promotingSalesTitle"),imgSrc:`${c.MailPoet.cdnUrl}homepage/resources/sales.png`},"promotingSales")],i=(0,o.useCallback)((a=>{a.preventDefault(),t(e+1)}),[e]),s=(0,o.useCallback)((a=>{a.preventDefault(),t(e-1)}),[e]);return(0,p.jsxs)(le,{className:"mailpoet-homepage-resources",heading:c.MailPoet.I18n.t("learnMoreAboutEmailMarketing"),children:[(0,p.jsx)("div",{className:"mailpoet-homepage-resources__posts",children:a.filter(((t,a)=>a+1===2*e||a+1===2*e-1)).map((e=>e))}),(0,p.jsxs)("div",{className:"mailpoet-homepage-resources__pagination",children:[c.MailPoet.I18n.t("pageOf").replace("%1$d",e.toString()).replace("%2$d",Math.ceil(a.length/2).toString()),e>1?(0,p.jsx)("a",{href:"#",onClick:s,title:c.MailPoet.I18n.t("previousPostsPage"),children:(0,p.jsx)(ee.Z,{icon:ye.Z})}):(0,p.jsx)(ee.Z,{icon:ye.Z}),e<Math.ceil(a.length/2)?(0,p.jsx)("a",{href:"#",onClick:i,title:c.MailPoet.I18n.t("nextPostsPage"),children:(0,p.jsx)(ee.Z,{icon:we.Z})}):(0,p.jsx)(ee.Z,{icon:we.Z})]})]})}function Me(){const{isTaskListHidden:e,isProductDiscoveryHidden:t,isUpsellHidden:a,canDisplayUpsell:i}=(0,P.Z)((e=>({isTaskListHidden:e(J).getIsTaskListHidden(),isProductDiscoveryHidden:e(J).getIsProductDiscoveryHidden(),isUpsellHidden:e(J).getIsUpsellHidden(),canDisplayUpsell:e(J).getCanDisplayUpsell()})),[]),{hideTaskList:s}=(0,fe.Z)(J),{hideProductDiscovery:n}=(0,fe.Z)(J),{hideUpsell:o}=(0,fe.Z)(J);return(0,p.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(oe,{onHide:s})}),!t&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(de,{onHide:n})}),e&&t&&i&&!a&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(_e,{closable:!0,onHide:o})}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(je,{})}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Pe,{})})]})}function Ne(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{(()=>{const e=(0,C.Z)(J,{actions:i,controls:X,selectors:s,reducer:Q,initialState:{taskList:{isTaskListHidden:window.mailpoet_homepage_data.taskListDismissed,tasksStatus:window.mailpoet_homepage_data.taskListStatus,canImportWooCommerceSubscribers:window.mailpoet_homepage_data.wooCustomersCount>0,hasImportedSubscribers:window.mailpoet_homepage_data.subscribersCount>10,isNewUserForSenderDomainAuth:window.mailpoet_homepage_data.isNewUserForSenderDomainAuth,mssActive:window.mailpoet_mss_active,isFreeMailUser:window.mailpoet_homepage_data.isFreeMailUser},productDiscovery:{isHidden:window.mailpoet_homepage_data.productDiscoveryDismissed,tasksStatus:window.mailpoet_homepage_data.productDiscoveryStatus},upsell:{isHidden:window.mailpoet_homepage_data.upsellDismissed,upsellStatus:window.mailpoet_homepage_data.upsellStatus},isWooCommerceActive:c.MailPoet.isWoocommerceActive,subscribersStats:window.mailpoet_homepage_data.subscribersStats,formsCount:window.mailpoet_homepage_data.formsCount}});(0,I.register)(e)})(),t(!0)}),[]),(0,p.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,p.jsx)(d.Q,{}),(0,p.jsx)(S,{}),e?(0,p.jsx)(Me,{}):null]})}const Ce=document.getElementById("mailpoet_homepage_container");Ce&&((0,r.registerTranslations)(),(0,n.s)(Ce).render((0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Ne,{})})));var Ie=a(26952),ke=a(91285),Te=a(65311),Ee=a.n(Te),Ae=a(39519),Re=a.n(Ae),Fe=a(26694),Oe=a(30425),De=a(79830),Le=a(51867),qe=a(49773);function Be({cacheCalculation:e,design:t="old"}){const[a,i]=(0,o.useState)(!1),[s,n]=(0,o.useState)([]),r=(new Date).getTime()-new Date(e).getTime(),l=Math.floor(r/1e3/60),d=()=>{i(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"settings",action:"recalculateSubscribersCountsCache"}).done((()=>{window.location.reload()})).fail((e=>{n(e.errors.map((e=>e.message))),i(!1)}))};return"old"===t?(0,p.jsxs)("div",{className:"mailpoet-subscribers-cache-notice",children:[f()((0,Le.__)("Lists and Segments subscribers counts were calculated <abbr>{$mins} minutes ago</abbr>","mailpoet"),/<abbr>(.*?)<\/abbr>/,((t,a)=>(0,p.jsx)("abbr",{title:e,children:t.replace(/(\{\$mins\}|\$mins)/i,String(l))},a))),(0,p.jsx)(qe.z,{className:"mailpoet-subscribers-cache-notice-button",type:"button",variant:"secondary",dimension:"small",onClick:d,withSpinner:a,children:(0,Le.__)("Recalculate now","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),s.length>0&&(0,p.jsx)(u.q,{type:"error",children:s.map((e=>(0,p.jsx)("p",{children:e},e)))})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:"mailpoet-segment-subscriber-cache",children:(0,Le.sprintf)((0,Le._n)("Calculated %s min ago","Calculated %s mins ago",l,"mailpoet"),l.toLocaleString())}),(0,p.jsx)(ge.ZP,{variant:"link",onClick:d,children:(0,Le.__)("Recalculate","mailpoet")}),s.length>0&&(0,p.jsx)(u.q,{type:"error",children:s.map((e=>(0,p.jsx)("p",{children:e},e)))})]})}var We=a(37248),$e=a(37266),Ue=a(52485);function Ve({subscribersInPlan:e,subscribersInPlanLimit:t,design:a="old"}){if(!1===e)return null;const i=t?(0,p.jsx)("b",{children:(0,Le._x)("%1$d / %2$d","count / total subscribers","mailpoet").replace("%1$d",e.toLocaleString()).replace("%2$d",t.toLocaleString())},"subscribers_count"):(0,p.jsx)("b",{children:e},"subscribers_count");return"old"===a?(0,p.jsxs)("div",{className:"mailpoet-subscribers-in-plan",children:[f()((0,Le._x)("%s subscribers in your plan","number of subscribers in a sending plan","mailpoet"),"%s",(()=>i))," ",(0,p.jsx)(We.Tooltip,{tooltip:(0,Le.__)("This is the total of subscribed, unconfirmed and inactive subscribers we count when you are sending with MailPoet Sending Service. The count excludes unsubscribed and bounced (invalid) email addresses.","mailpoet"),place:"right"}),(0,p.jsx)("span",{className:"mailpoet-subscribers-in-plan-spacer",children:" "})]}):(0,p.jsxs)("span",{className:"mailpoet-segment-subscriber-count-message",children:[(0,p.jsx)("b",{children:t?(0,Le.sprintf)((0,Le._n)("%1$s / %2$s subscriber","%1$s / %2$s subscribers",e,"mailpoet"),e.toLocaleString(),t.toLocaleString()):(0,Le.sprintf)((0,Le._n)("%s subscriber","%s subscribers",e,"mailpoet"),e.toLocaleString())}),(0,p.jsx)($e.Z,{text:(0,Le.__)("This is the total of subscribed, unconfirmed and inactive subscribers we count when you are sending with MailPoet Sending Service. The count excludes unsubscribed and bounced (invalid) email addresses.","mailpoet"),children:(0,p.jsx)("div",{className:"mailpoet-segment-help-icon",children:(0,p.jsx)(ee.Z,{icon:Ue.Z})})})]})}var He=a(33493);function ze({location:e}){return(0,p.jsxs)(d.Q,{children:[(0,p.jsxs)(Ie.Link,{className:"mailpoet-button button-secondary",to:{pathname:"/new",state:{backUrl:e?.pathname}},children:[He.R,(0,p.jsx)("span",{"data-automation-id":"add-new-subscribers-button",children:c.MailPoet.I18n.t("new")})]}),(0,p.jsx)("a",{className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:c.MailPoet.I18n.t("import")}),(0,p.jsx)("a",{id:"mailpoet_export_button",className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-export",children:c.MailPoet.I18n.t("export")})]})}ze.propTypes={location:Re().object.isRequired};const Ze=(0,ke.EN)(ze),Ye=c.MailPoet.trackingConfig.emailTrackingEnabled,Ge=[{name:"email",label:c.MailPoet.I18n.t("subscriber"),sortable:!0},{name:"status",label:c.MailPoet.I18n.t("status"),sortable:!0},{name:"segments",label:c.MailPoet.I18n.t("lists")},{name:"tags",label:c.MailPoet.I18n.t("tags")},{name:"statistics",label:c.MailPoet.I18n.t("statisticsColumn"),display:Ye},{name:"last_subscribed_at",label:c.MailPoet.I18n.t("subscribedOn"),sortable:!0}],Ke={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSubscriberTrashed"):c.MailPoet.I18n.t("multipleSubscribersTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSubscriberDeleted"):c.MailPoet.I18n.t("multipleSubscribersDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSubscriberRestored"):c.MailPoet.I18n.t("multipleSubscribersRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onNoItemsFound:e=>"bounced"===e&&!window.mailpoet_premium_active&&!window.mailpoet_mss_active&&(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("bouncedSubscribersHelp")}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",className:"button-primary",children:c.MailPoet.I18n.t("bouncedSubscribersPremiumButtonText")})})]})},Qe=(e,t,a,i)=>(0,p.jsxs)(Oe.u,{title:i,onRequestClose:t,isDismissible:!0,children:[(0,p.jsx)(De.Y,{field:a}),(0,p.jsx)("span",{className:"mailpoet-gap-half"}),(0,p.jsx)(r.Button,{onClick:e,dimension:"small",variant:"secondary",children:c.MailPoet.I18n.t("apply")})]}),Je=[{name:"moveToList",label:c.MailPoet.I18n.t("moveToList"),onSelect:function(e,t){return Qe(e,t,{id:"move_to_segment",name:"move_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},c.MailPoet.I18n.t("moveToList"))},getData:function(){return{segment_id:Number(Ee()("#move_to_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersMovedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"addToList",label:c.MailPoet.I18n.t("addToList"),onSelect:function(e,t){return Qe(e,t,{id:"add_to_segment",name:"add_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},c.MailPoet.I18n.t("addToList"))},getData:function(){return{segment_id:Number(Ee()("#add_to_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersAddedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromList",label:c.MailPoet.I18n.t("removeFromList"),onSelect:function(e,t){return Qe(e,t,{id:"remove_from_segment",name:"remove_from_segment",endpoint:"segments",filter:function(e){return!("default"!==e.type)}},c.MailPoet.I18n.t("removeFromList"))},getData:function(){return{segment_id:Number(Ee()("#remove_from_segment").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersRemovedFromList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromAllLists",label:c.MailPoet.I18n.t("removeFromAllLists"),onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("multipleSubscribersRemovedFromAllLists").replace("%1$d",Number(e.meta.count).toLocaleString()))}},{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:Ke.onTrash},{name:"unsubscribe",label:c.MailPoet.I18n.t("unsubscribe"),onSelect:(e,t,a)=>{const i="all"!==a.selection?a.selected_ids.length:a.count;return(0,p.jsxs)(Oe.u,{title:c.MailPoet.I18n.t("unsubscribe"),onRequestClose:t,isDismissible:!0,children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("unsubscribeConfirm").replace("%s",Number(i).toLocaleString())}),(0,p.jsx)("span",{className:"mailpoet-gap-half"}),(0,p.jsx)(r.Button,{onClick:e,dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:c.MailPoet.I18n.t("apply")})]})}},{name:"addTag",label:c.MailPoet.I18n.t("addTag"),onSelect:function(e,t){return Qe(e,t,{id:"add_tag",name:"add_tag",endpoint:"tags"},c.MailPoet.I18n.t("addTag"))},getData:function(){return{tag_id:Number(Ee()("#add_tag").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("tagAddedToMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}},{name:"removeTag",label:c.MailPoet.I18n.t("removeTag"),onSelect:function(e,t){return Qe(e,t,{id:"remove_tag",name:"remove_tag",endpoint:"tags"},c.MailPoet.I18n.t("removeTag"))},getData:function(){return{tag_id:Number(Ee()("#remove_tag").val())}},onSuccess:function(e){c.MailPoet.Notice.success(c.MailPoet.I18n.t("tagRemovedFromMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}}],Xe=[{name:"statistics",label:c.MailPoet.I18n.t("statsListingActionTitle"),link:function(e,t){return(0,p.jsx)(Ie.Link,{to:{pathname:`/stats/${e.id}`,state:{backUrl:t?.pathname}},children:c.MailPoet.I18n.t("statsListingActionTitle")})}},{name:"edit",label:c.MailPoet.I18n.t("edit"),link:function(e,t){return(0,p.jsx)(Ie.Link,{to:{pathname:`/edit/${e.id}`,state:{backUrl:t?.pathname}},children:c.MailPoet.I18n.t("edit")})}},{name:"sendConfirmationEmail",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("resendConfirmationEmail"),display:function(e){return"unconfirmed"===e.status&&e.count_confirmations<window.mailpoet_max_confirmation_emails},onClick:function(e){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"subscribers",action:"sendConfirmationEmail",data:{id:e.id}}).done((()=>c.MailPoet.Notice.success(c.MailPoet.I18n.t("oneConfirmationEmailSent")))).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))}},{name:"trash",className:"mailpoet-hide-on-mobile"}],et=e=>0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user),tt=e=>{let t=null;return window.mailpoet_segments.forEach((a=>{a.id===e&&(t=a)})),t};function at({match:e}){const t=(0,ke.TH)();return(0,p.jsxs)("div",{children:[(0,p.jsx)(Ze,{}),(0,p.jsx)(Ve,{subscribersInPlan:c.MailPoet.subscribersCount,subscribersInPlanLimit:c.MailPoet.subscribersLimit}),(0,p.jsx)(w,{}),(0,p.jsx)(Be,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:t,params:e.params,endpoint:"subscribers",onRenderItem:(e,a)=>{const i=ie()("manage-column","column-primary","has-row-actions","column-username");let s="";switch(e.status){case"subscribed":s=c.MailPoet.I18n.t("subscribed");break;case"unconfirmed":s=c.MailPoet.I18n.t("unconfirmed");break;case"unsubscribed":s=c.MailPoet.I18n.t("unsubscribed");break;case"inactive":s=c.MailPoet.I18n.t("inactive");break;case"bounced":s=c.MailPoet.I18n.t("bounced");break;default:s="Invalid"}const n=[];return e.subscriptions.length>0&&e.subscriptions.forEach((e=>{const t=tt(e.segment_id);null!==t&&"subscribed"===e.status&&n.push(t)})),(0,p.jsxs)("div",{children:[(0,p.jsxs)("td",{className:i,children:[(0,p.jsx)(Ie.Link,{className:"mailpoet-listing-title",to:{pathname:`/edit/${e.id}`,state:{backUrl:t?.pathname}},children:e.email}),(0,p.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[e.first_name," ",e.last_name]}),a]}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("status"),children:s}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("lists"),children:(0,p.jsx)(r.SegmentTags,{segments:n,dimension:"large"})}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("tags"),children:(0,p.jsx)(r.SubscriberTags,{subscribers:e.tags,variant:"wordpress",isInverted:!0})}),!0===Ye?(0,p.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":c.MailPoet.I18n.t("statisticsColumn"),children:(0,p.jsx)("div",{className:"mailpoet-listing-stats",children:(0,p.jsx)("a",{href:`#/stats/${e.id}`,children:(0,p.jsx)(xe,{id:e.id,engagementScore:e.engagement_score})},`stats-link-${e.id}`)})}):null,(0,p.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribedOn"),children:e.last_subscribed_at?(0,p.jsxs)(p.Fragment,{children:[c.MailPoet.Date.short(e.last_subscribed_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.last_subscribed_at)]}):null})]})},columns:Ge,bulk_actions:Je,item_actions:Xe,messages:Ke,sort_by:"created_at",sort_order:"desc",isItemDeletable:et})]})}at.propTypes={match:Re().shape({params:Re().object}).isRequired},at.displayName="SubscriberList";var it=a(73136),st=a.n(it),nt=a(93625),ot=a(26869),rt=a.n(ot),lt=a(3537);class dt extends o.Component{render(){const e=this.props.field.name||null,t=this.props.item||{};let a,i;this.props.onValueChange instanceof Function&&(a=t[this.props.field.name],a=void 0===a?this.props.field.defaultValue||"":a),!a&&this.props.field.defaultValue&&(i=this.props.field.defaultValue);let s=this.props.field.id||null;!s&&this.props.field.name&&(s=`field_${this.props.field.name}`);let n,o=this.props.field.className||null;return o||this.props.field.size||(o="regular-text"),n="function"==typeof this.props.field.disabled?this.props.field.disabled(this.props.item):"boolean"==typeof this.props.field.disabled&&this.props.field.disabled,(0,p.jsx)(lt.I,{type:"text",disabled:n,className:o,size:"auto"!==this.props.field.size&&this.props.field.size>0?this.props.field.size:null,name:e,id:s,value:a,defaultValue:i,placeholder:this.props.field.placeholder,onChange:this.props.onValueChange,onBlur:this.props.onBlurEvent,customLabel:this.props.field.customLabel,tooltip:this.props.field.tooltip,...this.props.field.validation})}}dt.propTypes={onValueChange:Re().func,onBlurEvent:Re().func,field:Re().shape({name:Re().string.isRequired,defaultValue:Re().string,id:Re().string,className:Re().string,size:Re().oneOfType([Re().string,Re().number]),disabled:Re().oneOfType([Re().bool,Re().func]),placeholder:Re().string,validation:Re().shape({"data-parsley-required":Re().bool,"data-parsley-required-message":Re().string,"data-parsley-type":Re().string,"data-parsley-errors-container":Re().string,maxLength:Re().number}),customLabel:Re().string,tooltip:Re().string}).isRequired,item:Re().object.isRequired},dt.defaultProps={onValueChange:function(){},onBlurEvent:function(){}};var ct=a(62865);function mt(e){return(0,p.jsx)(ct.g,{type:"text",name:e.field.name,id:`field_${e.field.name}`,value:e.item[e.field.name],placeholder:e.field.placeholder,defaultValue:e.field.defaultValue,onChange:e.onValueChange,className:e.field.className,customLabel:e.field.customLabel,tooltip:e.field.tooltip,...e.field.validation})}mt.propTypes={item:Re().object.isRequired,field:Re().shape({name:Re().string,placeholder:Re().string,defaultValue:Re().string,validation:Re().shape({"data-parsley-required":Re().bool,"data-parsley-required-message":Re().string,"data-parsley-type":Re().string,"data-parsley-errors-container":Re().string,maxLength:Re().number}),className:Re().string,customLabel:Re().string,tooltip:Re().string}).isRequired,onValueChange:Re().func.isRequired};var ut=a(43869),pt=a(67902);class ht extends o.Component{render(){if(void 0===this.props.field.values)return!1;let e,t=!1,a=!1,i=!1;void 0!==this.props.field.placeholder&&(a=(0,p.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(t=this.props.field.filter),ut.default.isFunction(this.props.field.sortBy)&&(i=this.props.field.sortBy),e=i?ut.default.map(ut.default.sortBy(ut.default.pairs(this.props.field.values),(e=>i(e[0],e[1]))),(e=>e[0])):Object.keys(this.props.field.values);const s=e.filter((e=>!1===t||t(this.props.item,e))).map((e=>(0,p.jsx)("option",{value:e,children:this.props.field.values[e]},`option-${e}`)));return(0,p.jsxs)(pt.Select,{name:this.props.field.name,id:`field_${this.props.field.name}`,value:this.props.item[this.props.field.name]||"",onChange:this.props.onValueChange,automationId:this.props.automationId,...this.props.field.validation,children:[a,s]})}}ht.propTypes={onValueChange:Re().func,field:Re().shape({name:Re().string.isRequired,values:Re().objectOf(Re().string),placeholder:Re().string,filter:Re().func,sortBy:Re().func,validation:Re().shape({"data-parsley-required":Re().bool,"data-parsley-required-message":Re().string,"data-parsley-type":Re().string,"data-parsley-errors-container":Re().string,maxLength:Re().number})}).isRequired,item:Re().object.isRequired,automationId:Re().string},ht.defaultProps={automationId:"",onValueChange:function(){}};var gt=a(60216);class _t extends o.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>this.props.onValueChange(t);render(){if(void 0===this.props.field.values)return!1;const e=this.props.item[this.props.field.name],t=Object.keys(this.props.field.values).map((t=>(0,p.jsx)("p",{children:(0,p.jsx)(gt.Y,{checked:e===t,value:t,onCheck:this.onValueChange,name:this.props.field.name,children:this.props.field.values[t]})},`radio-${t}`)));return(0,p.jsx)("div",{children:t})}}_t.propTypes={onValueChange:Re().func,field:Re().shape({name:Re().string.isRequired,values:Re().objectOf(Re().string)}).isRequired,item:Re().object.isRequired},_t.defaultProps={onValueChange:function(){}};var ft=a(49321);class bt extends o.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>(t.target.value=e?"1":"0",this.props.onValueChange(t));render(){if(void 0===this.props.field.values)return!1;const e=!!Number(this.props.item[this.props.field.name]),t=Object.keys(this.props.field.values).map((t=>(0,p.jsx)("p",{children:(0,p.jsx)(ft.X,{value:"1",checked:e,name:this.props.field.name,onCheck:this.onValueChange,children:this.props.field.values[t]})},`checkbox-${t}`)));return(0,p.jsx)("div",{children:t})}}function xt(e){const t=[];void 0!==e.placeholder&&t.push((0,p.jsx)("option",{value:"",children:e.placeholder},0));const a=st()().year();for(let e=a;e>=a-100;e-=1)t.push((0,p.jsx)("option",{value:e,children:e},e));return(0,p.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[year]`,value:e.year,onChange:e.onValueChange,children:t})}function vt(e){const t=[];void 0!==e.placeholder&&t.push((0,p.jsx)("option",{value:"",children:e.placeholder},0));for(let a=1;a<=12;a+=1)t.push((0,p.jsx)("option",{value:a,children:e.monthNames[a-1]},a));return(0,p.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[month]`,value:e.month,onChange:e.onValueChange,children:t})}function jt(e){const t=[];void 0!==e.placeholder&&t.push((0,p.jsx)("option",{value:"",children:e.placeholder},0));for(let e=1;e<=31;e+=1)t.push((0,p.jsx)("option",{value:e,children:e},e));return(0,p.jsx)(r.Select,{isMinWidth:!0,name:`${e.name}[day]`,value:e.day,onChange:e.onValueChange,children:t})}bt.propTypes={onValueChange:Re().func.isRequired,field:Re().shape({name:Re().string.isRequired,values:Re().objectOf(Re().string)}).isRequired,item:Re().object.isRequired},xt.propTypes={name:Re().string.isRequired,placeholder:Re().string.isRequired,onValueChange:Re().func.isRequired,year:Re().oneOfType([Re().string,Re().number]).isRequired},vt.propTypes={name:Re().string.isRequired,placeholder:Re().string.isRequired,onValueChange:Re().func.isRequired,month:Re().oneOfType([Re().string,Re().number]).isRequired,monthNames:Re().arrayOf(Re().string).isRequired},jt.propTypes={name:Re().string.isRequired,placeholder:Re().string.isRequired,onValueChange:Re().func.isRequired,day:Re().oneOfType([Re().string,Re().number]).isRequired};class yt extends o.Component{constructor(e){super(e),this.state={year:"",month:"",day:""},this.onValueChange=this.onValueChange.bind(this)}componentDidMount(){this.extractDateParts()}componentDidUpdate(e){void 0!==this.props.item&&void 0!==e.item&&this.props.item.id!==e.item.id&&this.extractDateParts()}onValueChange(e){const t=e.target.name.match(/(.*?)\[(.*?)\]/);let a=null,i=null;if(null!==t&&3===t.length){[,a,i]=t;const s=Number(e.target.value);this.setState({[`${i}`]:s},(()=>{this.props.onValueChange({target:{name:a,value:this.formatValue()}})}))}}formatValue(){let e;switch(this.props.field.params.date_type){case"year_month_day":e={year:this.state.year,month:this.state.month,day:this.state.day};break;case"year_month":e={year:this.state.year,month:this.state.month};break;case"month":e={month:this.state.month};break;case"year":e={year:this.state.year};break;default:e={value:"invalid type"}}return e}extractDateParts(){const e=void 0!==this.props.item[this.props.field.name]?this.props.item[this.props.field.name].trim():"";if(""===e)return;const t=st()(e);this.setState({year:t.format("YYYY"),month:t.format("M"),day:t.format("D")})}render(){const e=window.mailpoet_month_names||[];let t=(window.mailpoet_date_formats||{})[this.props.field.params.date_type][0];this.props.field.params.date_format&&(t=this.props.field.params.date_format);const a=t.split("/").map((t=>{switch(t){case"YYYY":return(0,p.jsx)(xt,{onValueChange:this.onValueChange,name:this.props.field.name,year:this.state.year,placeholder:this.props.field.year_placeholder},"year");case"MM":return(0,p.jsx)(vt,{onValueChange:this.onValueChange,name:this.props.field.name,month:this.state.month,monthNames:e,placeholder:this.props.field.month_placeholder},"month");case"DD":return(0,p.jsx)(jt,{onValueChange:this.onValueChange,name:this.props.field.name,day:this.state.day,placeholder:this.props.field.day_placeholder},"day");default:return(0,p.jsx)("div",{children:"Invalid date type"})}}));return(0,p.jsx)("div",{children:a})}}yt.propTypes={item:Re().object.isRequired,field:Re().shape({name:Re().string,day_placeholder:Re().string,month_placeholder:Re().string,year_placeholder:Re().string,params:Re().object}).isRequired,onValueChange:Re().func.isRequired};var wt=a(86104),St=a(41745);function Pt(e){const t=Array.isArray(e.item[e.field.name])?e.field.name&&e.item[e.field.name].map((t=>e.field.getName(t))):[];let a=[];return e.field.endpoint?a=function(e){let t=[];return void 0!==window[`mailpoet_${e}`]&&(t=window[`mailpoet_${e}`]),t}(String(e.field.endpoint)).map((t=>e.field.getName(t))):e.field.suggestedValues&&(a=e.field.suggestedValues),(0,p.jsx)(St.T,{label:e.field.label,name:e.field.name,placeholder:e.field.placeholder,selectedValues:t,suggestedValues:a,onChange:e.onValueChange})}class Mt extends o.Component{renderField=e=>{let t,a=!1;e.field.description&&(a=(0,p.jsx)("p",{className:"description",children:e.field.description}));let i=e.field;switch(void 0!==e.field.field&&(i=Ee().merge(i,e.field.field)),i.type){case"text":t=(0,p.jsx)(dt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"textarea":t=(0,p.jsx)(mt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"select":t=(0,p.jsx)(ht,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"radio":t=(0,p.jsx)(_t,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"checkbox":t=(0,p.jsx)(bt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"selection":t=(0,p.jsx)(De.Y,{onValueChange:e.onValueChange,field:e.field,automationId:e.automationId,inline:e.inline,description:e.description,item:e.item},`selection-field-${i.name}`);break;case"date":t=(0,p.jsx)(yt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"reactComponent":t=(0,p.jsx)(e.field.component,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"tokenField":t=(0,p.jsx)(Pt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,description:e.description});break;case"empty":break;default:t="invalid"}const s="function"==typeof i.disabled?i.disabled(e.field):i.disabled,n={...i.onWrapperClick?{onClick:i.onWrapperClick}:{}};return(0,p.jsxs)("div",{className:ie()("mailpoet-form-field",{"mailpoet-form-field-disabled":s}),...n,children:[t,a]},`field-${e.index||0}`)};render(){let e=!1;e=void 0!==this.props.field.fields?this.props.field.fields.map(((e,t)=>this.renderField({index:t,field:e,item:this.props.item,onValueChange:this.props.onValueChange||!1}))):this.renderField(this.props);let t=!1;this.props.field.label&&(t=(0,p.jsx)(wt.X,{level:4,children:(0,p.jsx)("label",{htmlFor:`field_${this.props.field.name}`,children:this.props.field.label})}));let a=!1;return this.props.field.tip&&(a=(0,p.jsx)("p",{className:"mailpoet-form-description",children:this.props.field.tip})),(0,p.jsxs)("div",{className:`mailpoet-form-field-${this.props.field.name} form-field-row-${this.props.field.name}`,children:[t,a,e]})}}Mt.propTypes={onValueChange:Re().func,field:Re().shape({name:Re().string.isRequired,values:Re().objectOf(Re().string),tip:Re().oneOfType([Re().array,Re().string]),label:Re().string,fields:Re().arrayOf(Re().object),description:Re().string,onWrapperClick:Re().func,disabled:Re().oneOfType([Re().func,Re().bool])}).isRequired,item:Re().object.isRequired},Mt.defaultProps={onValueChange:function(){}},(0,r.registerTranslations)();class Nt extends o.Component{constructor(e){super(e),this.formRef=(0,o.createRef)(),this.state={loading:!1,errors:[],item:{}}}componentDidMount(){void 0!==this.props.params.id?this.loadItem(this.props.params.id):rt()((()=>{const e=Ee()(".mailpoet_form").mailpoetSerializeObject(),t=Array.isArray(this.props.fields)&&this.props.fields.length>0&&this.props.fields.find((e=>"checkbox"===e?.type&&e?.isChecked));t&&t.name&&(e[t.name]="1"),this.setState({item:e})}))}componentDidUpdate(e){void 0===this.props.params.id&&e.location.pathname!==this.props.location.pathname&&(rt()((()=>{this.setState({loading:!1,item:{}})})),void 0===this.props.item&&this.formRef.current.reset())}getValues=()=>this.props.item||this.state.item;getErrors=()=>this.props.errors||this.state.errors;loadItem=e=>{this.setState({loading:!0}),this.props.endpoint&&c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:this.props.endpoint,action:"get",data:{id:e}}).done((e=>{this.setState({loading:!1,item:e.data}),"function"==typeof this.props.onItemLoad&&this.props.onItemLoad(e.data)})).fail((()=>{this.setState({loading:!1,item:{}},(function(){this.props.history.push("/lists")}))}))};handleSubmit=e=>{if(e.preventDefault(),void 0!==this.props.isValid&&!1===this.props.isValid())return;this.setState({loading:!0});const t={};this.props.fields.forEach((e=>{void 0!==e.fields?e.fields.forEach((e=>{t[e.name]=this.state.item[e.name]})):t[e.name]=this.state.item[e.name]})),void 0!==this.props.params.id&&(t.id=this.props.params.id),this.props.endpoint&&c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:this.props.endpoint,action:"save",data:t}).always((()=>{this.setState({loading:!1})})).done((()=>{void 0!==this.props.onSuccess?this.props.onSuccess():this.props.history.push("/"),void 0!==this.props.params.id?this.props.messages.onUpdate():this.props.messages.onCreate()})).fail((e=>{e.errors.length>0&&this.setState({errors:e.errors})}))};handleValueChange=e=>{const{name:t,value:a}=Object.prototype.hasOwnProperty.call(e,"target")?e.target:e;return this.props.onChange?this.props.onChange(e):(this.setState((e=>{const i=e.item;return i[t]=a,{item:i}})),!0)};render(){let e;void 0!==this.getErrors()&&(e=this.getErrors().map((e=>(0,p.jsx)("div",{className:"mailpoet_notice notice inline error is-dismissible",children:(0,p.jsx)("p",{children:e.message})},`error-${e.message}`))));const t=ie()("mailpoet_form",{mailpoet_form_loading:this.state.loading||this.props.loading});let a=!1,i=!1;void 0!==this.props.beforeFormContent&&(a=this.props.beforeFormContent(this.getValues())),void 0!==this.props.afterFormContent&&(i=this.props.afterFormContent(this.getValues()));const s=this.props.fields.map((e=>{let t=this.handleValueChange;return e.onBeforeChange&&(t=t=>(e.onBeforeChange(t),this.handleValueChange(t))),(0,p.jsx)(Mt,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)}));let n=!1;return n=this.props.children?this.props.children:(0,p.jsx)(r.Button,{type:"submit",isDisabled:this.state.loading,children:(0,Le.__)("Save","mailpoet")}),(0,p.jsxs)("div",{children:[(0,p.jsx)("div",{className:"mailpoet-form-content-around",children:a}),(0,p.jsxs)("form",{id:this.props.id,ref:this.formRef,className:t,onSubmit:void 0!==this.props.onSubmit?this.props.onSubmit:this.handleSubmit,"data-automation-id":this.props.automationId,children:[e,(0,p.jsxs)("div",{className:"mailpoet-form-grid",children:[s,(0,p.jsx)("div",{className:"mailpoet-form-actions",children:n})]})]}),(0,p.jsx)("div",{className:"mailpoet-form-content-around",children:i})]})}}Nt.propTypes={params:Re().shape({id:Re().string}),location:Re().shape({pathname:Re().string}),item:Re().object,errors:Re().arrayOf(Re().object),endpoint:Re().string,fields:Re().arrayOf(Re().object),messages:Re().shape({onUpdate:Re().func,onCreate:Re().func}),loading:Re().bool,children:Re().array,id:Re().string,automationId:Re().string,beforeFormContent:Re().func,afterFormContent:Re().func,onItemLoad:Re().func,isValid:Re().func,onChange:Re().func,onSubmit:Re().func,onSuccess:Re().func,history:Re().shape({push:Re().func.isRequired}).isRequired},Nt.defaultProps={params:{},location:{},errors:void 0,fields:void 0,item:void 0,onItemLoad:void 0,isValid:void 0,onSuccess:void 0,onChange:void 0,loading:!1,beforeFormContent:void 0,afterFormContent:void 0,children:void 0,id:"",onSubmit:void 0,automationId:"",messages:{onUpdate:()=>{},onCreate:()=>{}},endpoint:void 0};const Ct=(0,ke.EN)(Nt);var It=a(92348),kt=a(2632);const Tt=[{name:"email",label:c.MailPoet.I18n.t("email"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"first_name",label:c.MailPoet.I18n.t("firstname"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"last_name",label:c.MailPoet.I18n.t("lastname"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"status",label:c.MailPoet.I18n.t("status"),type:"select",automationId:"subscriber-status",values:{subscribed:c.MailPoet.I18n.t("subscribed"),unconfirmed:c.MailPoet.I18n.t("unconfirmed"),unsubscribed:c.MailPoet.I18n.t("unsubscribed"),inactive:c.MailPoet.I18n.t("inactive"),bounced:c.MailPoet.I18n.t("bounced")}},{name:"segments",label:c.MailPoet.I18n.t("lists"),type:"selection",placeholder:c.MailPoet.I18n.t("selectList"),tip:c.MailPoet.I18n.t("welcomeEmailTip"),api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!0,selected:function(e){return!1===Array.isArray(e.subscriptions)?null:e.subscriptions.filter((e=>"subscribed"===e.status)).map((e=>e.segment_id))},filter:function(e){return!e.deleted_at&&"default"===e.type},getLabel:function(e){return e.name},getCount:function(e){return e.subscribers},getSearchLabel:function(e,t){let a="";return void 0!==t.subscriptions&&t.subscriptions.forEach((t=>{if(e.id===t.segment_id&&(a=e.name,"unsubscribed"===t.status)){const e=c.MailPoet.Date.format(t.updated_at);a+=" (%1$s)".replace("%1$s",c.MailPoet.I18n.t("unsubscribedOn").replace("%1$s",e))}})),a}},{name:"tags",label:c.MailPoet.I18n.t("tags"),type:"tokenField",placeholder:c.MailPoet.I18n.t("addNewTag"),suggestedValues:[],endpoint:"tags",getName:function(e){return Object.prototype.hasOwnProperty.call(e,"name")?e.name:e}}];(window.mailpoet_custom_fields||[]).forEach((e=>{const t={name:`cf_${e.id}`,label:e.name,type:e.type};switch(e.params&&(t.params=e.params,e.params.values&&(t.values=e.params.values)),e.type){case"date":t.year_placeholder=c.MailPoet.I18n.t("year"),t.month_placeholder=c.MailPoet.I18n.t("month"),t.day_placeholder=c.MailPoet.I18n.t("day");break;case"select":t.placeholder="-";break;default:t.placeholder=""}Tt.push(t)}));const Et={onUpdate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("subscriberUpdated"))},onCreate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("subscriberAdded")),c.MailPoet.trackEvent("Subscribers > Add new")}};function At(e){if(Number(e.wp_user_id)>0)return(0,p.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("WPUserEditNotice"),/\[link\](.*?)\[\/link\]/g,((t,a)=>(0,p.jsx)("a",{href:`user-edit.php?user_id=${e.wp_user_id}`,children:t},a)))})}function Rt(e){return(0,p.jsxs)(p.Fragment,{children:[e?.unsubscribes?.map((e=>{const t=st()(e.createdAt.date).format("dddd MMMM Do YYYY [at] h:mm:ss a");let a;return a="admin"===e.source?c.MailPoet.I18n.t("unsubscribedAdmin").replace("%1$d",t).replace("%2$d",e.meta):"manage"===e.source?c.MailPoet.I18n.t("unsubscribedManage").replace("%1$d",t):"newsletter"===e.source?f()(c.MailPoet.I18n.t("unsubscribedNewsletter").replace("%1$d",t),/\[link\]/g,((t,a)=>(0,p.jsx)("a",{href:`admin.php?page=mailpoet-newsletter-editor&id=${e.newsletterId}`,children:e.newsletterSubject},a))):"mp_api"===e.source?c.MailPoet.I18n.t("unsubscribedMpApi").replace("%1$d",t):c.MailPoet.I18n.t("unsubscribedUnknown").replace("%1$d",t),(0,p.jsx)("p",{className:"description",children:a},a)})),(0,p.jsxs)("p",{className:"description",children:[(0,p.jsx)("strong",{children:c.MailPoet.I18n.t("tip")})," ",c.MailPoet.I18n.t("customFieldsTip")]})]})}function Ft({match:e}){const t=(0,ke.TH)(),a=(0,ke.k6)(),i=t.state?.backUrl||"/";return(0,p.jsxs)("div",{className:"mailpoet-main-container",children:[(0,p.jsx)(d.Q,{}),(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(It.B,{}),(0,p.jsx)(kt.m,{heading:c.MailPoet.I18n.t("subscriber"),headingPrefix:(0,p.jsx)(kt.x,{onClick:()=>a.push(i),label:c.MailPoet.I18n.t("backToList")})}),(0,p.jsx)(b,{}),(0,p.jsx)(Ct,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:Tt,params:e.params,messages:Et,beforeFormContent:At,afterFormContent:Rt,onSuccess:()=>a.push(i)})]})}Ft.propTypes={match:Re().shape({params:Re().shape({id:Re().string}).isRequired}).isRequired},Ft.displayName="SubscriberForm";var Ot=a(9515);function Dt({email:e}){const t=(0,ke.TH)(),a=t.state?.backUrl||"/";return(0,p.jsxs)(wt.X,{level:1,className:"mailpoet-title",children:[(0,p.jsx)("span",{children:c.MailPoet.I18n.t("statsHeading").replace("%s",e)}),(0,p.jsx)(Ie.Link,{className:"mailpoet-button button button-secondary button-small",to:a,children:c.MailPoet.I18n.t("backToList")})]})}var Lt=a(74702);function qt({stats:e,subscriber:t}){return(0,p.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,p.jsx)("div",{className:"mailpoet-listing",children:(0,p.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,p.jsxs)("tbody",{children:[(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:c.MailPoet.I18n.t("statsSentEmail")}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.total_sent},e.timeframe)))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:(0,p.jsx)(Lt.V,{children:c.MailPoet.I18n.t("statsOpened")})}),e.periodic_stats.map((e=>{const t=e.total_sent>0;let a=e.open.toLocaleString();return t&&(a+=` (${Math.round(e.open/e.total_sent*100)}%)`),(0,p.jsx)("td",{children:a},e.timeframe)}))]}),(0,p.jsxs)("tr",{children:[(0,p.jsxs)("td",{children:[(0,p.jsx)(Lt.V,{children:c.MailPoet.I18n.t("statsMachineOpened")}),(0,p.jsx)(We.Tooltip,{tooltip:f()(c.MailPoet.I18n.t("statsMachineOpenedTooltip"),/\[link](.*?)\[\/link]/,(e=>(0,p.jsx)("span",{style:{pointerEvents:"all"},children:(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/368-what-are-machine-opens",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")},"machine-opened-info")))})]}),e.periodic_stats.map((e=>{const t=e.total_sent>0;let a=e.machine_open.toLocaleString();return t&&(a+=` (${Math.round(e.machine_open/e.total_sent*100)}%)`),(0,p.jsx)("td",{children:a},e.timeframe)}))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:(0,p.jsx)(Lt.V,{isInverted:!0,children:c.MailPoet.I18n.t("statsClicked")})}),e.periodic_stats.map((e=>{const t=e.total_sent>0;let a=e.click.toLocaleString();return t&&(a+=` (${Math.round(e.click/e.total_sent*100)}%)`),(0,p.jsx)("td",{children:a},e.timeframe)}))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:c.MailPoet.I18n.t("statsNotClicked")}),e.periodic_stats.map((e=>{const t=e.total_sent-(e.open+e.machine_open),a=e.total_sent>0;let i=t.toLocaleString();return a&&(i+=` (${Math.round(t/e.total_sent*100)}%)`),(0,p.jsx)("td",{children:i},e.timeframe)}))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:c.MailPoet.I18n.t("statisticsColumn")}),(0,p.jsx)("td",{colSpan:e.periodic_stats.length,children:(0,p.jsx)("div",{className:"mailpoet-listing-stats",children:(0,p.jsx)(xe,{id:t.id,engagementScore:t.engagement_score})})})]})]})]})})})}function Bt({stats:e}){return(0,p.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,p.jsx)("div",{className:"mailpoet-listing",children:(0,p.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,p.jsxs)("tbody",{children:[(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:"Orders created"}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.woocommerce.count.toLocaleString()},e.timeframe)))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:"Total revenue"}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.woocommerce.formatted},e.timeframe)))]}),(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:"Average revenue"}),e.periodic_stats.map((e=>(0,p.jsx)("td",{children:e.woocommerce.formatted_average},e.timeframe)))]})]})]})})})}var Wt=a(84209),$t=a(51409),Ut=a(83393);const{subscribersLimitReached:Vt,subscribersLimit:Ht,subscribersCount:zt,premiumActive:Zt,hasValidApiKey:Yt,hasValidPremiumKey:Gt,isPremiumPluginInstalled:Kt,pluginPartialKey:Qt}=c.MailPoet,Jt=Yt||Gt,Xt=e=>(0,p.jsx)("p",{children:f()(e,/(\[subscribersCount]|\[subscribersLimit])/g,(e=>"[subscribersCount]"===e?zt:Ht))}),ea=(e,t,a="_blank")=>(0,p.jsx)(qe.z,{href:t,target:a,rel:"noopener noreferrer",children:e}),ta=e=>(0,p.jsx)(Ut.yM,{buttonText:e});function aa({message:e,actionButton:t,capabilities:a={}}){let i,s,n=(0,Le.__)("This is a Premium feature","mailpoet");if(!Gt||Kt&&Zt)if(Vt){i=Xt((0,Le.__)("Congratulations, you now have [subscribersCount] subscribers! Your plan is limited to [subscribersLimit] subscribers. You need to upgrade now to be able to continue using MailPoet.","mailpoet"));const e=Jt?c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(Qt):c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(+zt+1,null,null,null);s=ea((0,Le.__)("Upgrade your plan","mailpoet"),e)}else if(Yt&&!Gt||Gt&&Object.keys(a).some((e=>c.MailPoet.capabilities[e].isRestricted))){n=(0,Le.__)("Upgrade your plan","mailpoet"),i=e;const t=c.MailPoet.MailPoetComUrlFactory.getUpgradeUrl(Qt,{s:zt,capabilities:a});s=ea((0,Le.__)("Upgrade","mailpoet"),t)}else i=e,s=t;else i=Xt((0,Le.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),s=ta(Kt?(0,Le.__)("Activate MailPoet Premium plugin","mailpoet"):(0,Le.__)("Download MailPoet Premium plugin","mailpoet"));return(0,p.jsx)($t.K,{title:n,message:i,actionButton:s})}function ia(){return(0,p.jsxs)("table",{className:"mailpoet-listing-table","data-automation-id":"subscriber-stats-no-access",children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{children:(0,Le.__)("E-mail","mailpoet")}),(0,p.jsx)("th",{children:(0,Le.__)("Action","mailpoet")}),(0,p.jsx)("th",{children:(0,Le.__)("Count","mailpoet")}),(0,p.jsx)("th",{children:(0,Le.__)("Action on","mailpoet")})]})}),(0,p.jsx)("tbody",{children:(0,p.jsx)("tr",{children:(0,p.jsx)("td",{colSpan:4,children:(0,p.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,p.jsx)(aa,{message:(()=>{const e=(0,Le.__)("Learn more about how each of your subscribers is engaging with your emails. See which emails they’ve opened, the links they clicked. If you’re a WooCommerce store owner, you’ll also see any purchases made as a result of your emails. [link]Learn more[/link].","mailpoet");return(0,p.jsx)("p",{children:f()(e,/\[link](.*?)\[\/link]/g,(e=>(0,p.jsx)("a",{href:c.MailPoet.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e)))})})(),actionButton:(0,p.jsx)(qe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,null,{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Upgrade","mailpoet")}),capabilities:{detailedAnalytics:!0}})})})})})]})}function sa({params:e,location:t}){const a=(0,o.useMemo)((()=>Wt.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",(()=>(0,p.jsx)(ia,{})),e,t)),[t,e]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:4,children:(0,Le.__)("Opened emails","mailpoet")}),(0,p.jsx)(a,{})]})}function na(e){return"string"==typeof e?c.MailPoet.Date.format(e):(0,Le.__)("never","mailpoet")}function oa({stats:e}){const t=[{label:(0,Le.__)("Last click","mailpoet"),date:e.last_click||null},{label:(0,Le.__)("Last engagement","mailpoet"),date:e.last_engagement||null},{label:(0,Le.__)("Last open","mailpoet"),date:e.last_open||null},{label:(0,Le.__)("Last page view","mailpoet"),date:e.last_page_view||null},{label:(0,Le.__)("Last sending","mailpoet"),date:e.last_sending||null}];return e.is_woo_active&&t.push({label:(0,Le.__)("Last purchase","mailpoet"),date:e.last_purchase||null}),t.sort(((e,t)=>e.date===t.date?0:e.date?t.date?t.date.localeCompare(e.date):-1:1)),(0,p.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,p.jsx)("div",{className:"mailpoet-listing",children:(0,p.jsx)("table",{className:"mailpoet-listing-table",children:(0,p.jsx)("tbody",{children:t.map((({label:e,date:t})=>(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:e}),(0,p.jsx)("td",{children:(0,p.jsx)("b",{children:na(t)})})]},e)))})})})})}function ra(){const e=(0,ke.$B)(),t=(0,ke.TH)(),[a,i]=(0,o.useState)(null),[s,n]=(0,o.useState)(!0),r=(0,l.S)(window).notices.error;return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"subscriberStats",action:"get",data:{subscriber_id:e.params.id}}).done((e=>{i(e.data),n(!1)})).fail((e=>{n(!1),e.errors.length>0&&r((0,p.jsx)(p.Fragment,{children:e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message)))}),{scroll:!0})}))}),[e.params.id,r]),s?(0,p.jsx)(Ot.g,{}):(0,p.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,p.jsx)(Dt,{email:a.email}),(0,p.jsxs)("div",{className:"mailpoet-subscriber-stats-summary-grid",children:[(0,p.jsx)(qt,{stats:a,subscriber:{id:Number(e.params.id),engagement_score:a.engagement_score}}),(0,p.jsx)(oa,{stats:a}),a.is_woo_active&&(0,p.jsx)(Bt,{stats:a})]}),(0,p.jsx)(sa,{params:e.params,location:t})]})}function la(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:"/new",render:(0,r.withBoundary)(Ft)}),(0,p.jsx)(ke.AW,{path:"/edit/:id",render:(0,r.withBoundary)(Ft)}),(0,p.jsx)(ke.AW,{path:"/stats/:id/(.*)?",component:(0,r.withBoundary)(ra)}),(0,p.jsx)(ke.AW,{path:"*",component:(0,r.withBoundary)(at)})]})]})})}ra.displayName="SubscriberStats";const da=document.getElementById("subscribers_container");da&&((0,r.registerTranslations)(),(0,n.s)(da).render((0,p.jsx)(la,{})));var ca=a(46696),ma=a(41932),ua=a(96599),pa=a(26111),ha=a(77701),ga=a(18175);function _a({isModalOpen:e,onClose:t}){const[a,i]=(0,o.useState)(!1),{notices:s}=(0,o.useContext)(l.k),n=(0,o.useCallback)((()=>{i(!0),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,Le.__)("Subject","mailpoet"),new_editor:!0}}).done((e=>{window.location.href=`admin.php?page=mailpoet-email-editor&postId=${e.data.wp_post_id}`})).fail((e=>{i(!1),t(),e.errors.length>0&&s.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}),[s,t]);return e?(0,p.jsxs)(ga.Z,{title:(0,Le.__)("New editor","mailpoet"),onRequestClose:t,className:"mailpoet-new-editor-modal",children:[(0,p.jsxs)("div",{className:"mailpoet-new-editor-modal-image",children:[(0,p.jsx)("span",{className:"mailpoet-new-editor-modal-image__beta_label",children:(0,Le.__)("Beta version","mailpoet")}),(0,p.jsx)("img",{src:`${c.MailPoet.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,Le.__)("New editor","mailpoet"),width:"324",height:"130"})]}),(0,p.jsx)("p",{children:(0,Le.__)("Create modern, beautiful emails that embody your brand with advanced customization and editing capabilities.","mailpoet")}),(0,p.jsx)("p",{className:"mailpoet-new-editor-modal-note",children:(0,Le.__)("Emails created in the new editor cannot be reverted to the legacy version.","mailpoet")}),(0,p.jsxs)("div",{className:"mailpoet-new-editor-modal-footer",children:[(0,p.jsx)(ge.ZP,{type:"button",variant:"tertiary",onClick:()=>{t()},children:(0,Le.__)("Cancel","mailpoet")}),(0,p.jsx)(ge.ZP,{type:"button",variant:"primary",isBusy:a,onClick:n,children:(0,Le.__)("Continue","mailpoet")})]})]}):null}function fa({errors:e}){return e.length<1?null:(0,p.jsx)(u.q,{type:"error",closable:!1,children:e.map((e=>(0,p.jsx)("p",{children:e.message},e.message)))})}var ba=a(87118);const xa=$e.Z;function va({children:e}){return(0,p.jsx)(xa,{delay:0,text:(0,p.jsx)("div",{className:"mailpoet-newsletter-type-info-tooltip",children:e}),children:(0,p.jsx)("div",{className:"mailpoet-newsletter-type-info",children:(0,p.jsx)(pa.Z,{icon:ba.Z,size:20})})})}const ja=ca.Z;function ya({filter:e,history:t,hideScreenOptions:a=!0}){const[i,s]=(0,o.useState)(!1),[n,r]=(0,o.useState)(!1),l=c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor"),d=e=>{void 0!==e&&(t.push(`/new/${e}`),c.MailPoet.trackEvent("Emails > Type selected",{"Email type":e}))},m=ut.default.partial((e=>{s(!0),c.MailPoet.trackEvent("Emails > Type selected",{"Email type":e}),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletters",action:"create",data:{type:e,subject:(0,Le.__)("Subject","mailpoet")}}).done((e=>{t.push(`/template/${e.data.id}`)})).fail((e=>(s(!1),e.errors.length>0?(0,p.jsx)(fa,{errors:e.errors}):null)))}),"standard"),u=ut.default.partial(d,"notification"),h=ut.default.partial(d,"re-engagement"),g=l?(0,p.jsxs)(ma.Z,{className:"mailpoet-dropdown-button-group",children:[(0,p.jsx)(ge.ZP,{variant:"secondary",onClick:m,isBusy:i,"data-automation-id":"create_standard",children:(0,Le.__)("Create","mailpoet")}),(0,p.jsx)(ua.Z,{focusOnMount:!1,className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,p.jsx)(ge.ZP,{variant:"secondary",className:"mailpoet-button-with-wordpress-icon",onClick:t,"aria-expanded":e,"data-automation-id":"create_standard_email_dropdown",children:(0,p.jsx)(pa.Z,{icon:ha.Z,size:24})}),renderContent:()=>(0,p.jsx)(ja,{variant:"tertiary",onClick:()=>r(!0),children:(0,Le.__)("Create using new editor (Beta)","mailpoet")})})]}):(0,p.jsx)(ge.ZP,{variant:"secondary",onClick:m,isBusy:i,"data-automation-id":"create_standard",children:(0,Le.__)("Create","mailpoet")}),_=[{slug:"standard",title:(0,Le.__)("Newsletter","mailpoet"),description:(0,Le.__)("Send a newsletter with images, buttons, dividers, and social bookmarks. Or, just send a basic text email.","mailpoet"),action:g},{slug:"automations",title:(0,p.jsxs)(p.Fragment,{children:[(0,Le.__)("Automations","mailpoet")," ",(0,p.jsx)(va,{children:(0,Le.__)("Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.","mailpoet")})]}),description:(0,Le.__)("Set up automated emails like welcome emails, abandoned cart reminders or one of our many automation templates to inform, engage and reward your audience.","mailpoet"),action:(0,p.jsx)(ge.ZP,{variant:"secondary",onClick:()=>{s(!0),window.location.href="admin.php?page=mailpoet-automation-templates"},isBusy:i,"data-automation-id":"create_automation",children:(0,Le.__)("Create","mailpoet")})},{slug:"notification",title:(0,Le.__)("Latest Post Notifications","mailpoet"),description:(0,Le.__)("Let MailPoet email your subscribers with your latest content. You can send daily, weekly, monthly, or even immediately after publication.","mailpoet"),videoGuide:"https://kb.mailpoet.com/article/210-video-guide-to-post-notifications",action:(0,p.jsx)(ge.ZP,{variant:"secondary",onClick:u,isBusy:i,"data-automation-id":"create_notification",children:(0,Le.__)("Create","mailpoet")})},{slug:"re_engagement",title:(0,Le.__)("Re-engagement Emails","mailpoet"),description:(0,Le.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,p.jsx)(ge.ZP,{variant:"secondary",onClick:h,isBusy:i,"data-automation-id":"create_notification",children:(0,Le.__)("Create","mailpoet")})}];let f=Wt.Hooks.applyFilters("mailpoet_newsletters_types",[..._],this);e&&(f=f.filter(e));const b=c.MailPoet.Ajax.constructGetUrl({api_version:c.MailPoet.apiVersion,endpoint:"newsletterTemplates",action:"getAll"});return(0,p.jsxs)(p.Fragment,{children:[a&&(0,p.jsx)(It.B,{}),(0,p.jsx)("link",{rel:"prefetch",href:window.mailpoet_editor_javascript_url,as:"script"}),(0,p.jsx)("div",{className:"mailpoet-newsletter-types",children:f.map((e=>(e=>{const t=!0===window.mailpoet_is_new_user?"mailpoet_badge mailpoet_badge_video":"mailpoet_badge mailpoet_badge_video mailpoet_badge_video_grey";return(0,p.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,p.jsx)("div",{className:"mailpoet-newsletter-type-image"}),(0,p.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,p.jsxs)(wt.X,{level:4,children:[e.title," ",e.beta?`(${(0,Le.__)("Beta","mailpoet")})`:""]}),(0,p.jsx)("p",{children:e.description}),e.videoGuide&&(0,p.jsxs)("a",{className:t,href:e.videoGuide,target:"_blank",rel:"noopener noreferrer",children:[(0,p.jsx)("span",{className:"dashicons dashicons-format-video"}),(0,Le.__)("See video guide","mailpoet")]}),e.kbLink&&(0,p.jsx)("a",{href:e.kbLink,target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Read more.","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-flex-grow"}),(0,p.jsx)("div",{className:"mailpoet-newsletter-type-action",children:e.action})]})]},e.slug)})(e)),this)}),(0,p.jsx)("link",{rel:"prefetch",href:b,as:"fetch"}),(0,p.jsx)(_a,{onClose:()=>r(!1),isModalOpen:n})]})}ya.defaultProps={filter:null,hideScreenOptions:!0};const wa=(0,ke.EN)(ya);var Sa=a(23525),Pa=a(11103);const Ma=(0,ke.EN)((e=>(0,p.jsx)(Pa.b,{...e})));var Na=a(26050),Ca=a(16424);class Ia extends o.Component{constructor(e){super(e),this.onPreview=this.onPreview.bind(this),this.onDelete=this.onDelete.bind(this),this.onSelect=this.onSelect.bind(this)}onDelete(){const{id:e,name:t,beforeDelete:a,afterDelete:i}=this.props;(0,Ca._)({message:(0,Le.__)('You are about to delete the template named "%1$s".',"mailpoet").replace("%1$s",t),onConfirm:()=>{a(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"delete",data:{id:e}}).done((()=>{i(!0,e)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0}),i(!1)}))}})}onPreview(){c.MailPoet.Modal.popup({title:this.props.name,template:'<img src="{{ thumbnail }}" />',data:this.props})}onSelect(){const{newsletterId:e,name:t,beforeSelect:a,afterSelect:i}=this.props;a(),c.MailPoet.trackEvent("Emails > Template selected",{"Email name":t}),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:{id:e,template_id:this.props.id}}).done((e=>{i(!0,e.data.id)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0}),i(!1)}))}render(){const{index:e,name:t,thumbnail:a,readonly:i}=this.props;let s="";return"string"==typeof a&&a.length>0&&(s=(0,p.jsxs)("a",{className:"mailpoet-template-preview",href:"#",onClick:e=>{e.preventDefault(),this.onPreview(e)},children:[(0,p.jsx)("div",{className:"mailpoet-template-thumbnail",children:a?(0,p.jsx)("img",{src:a,alt:(0,Le.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,p.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,p.jsx)(qe.z,{children:(0,Le.__)("Preview","mailpoet")})})]})),(0,p.jsx)(Na.G,{label:t,onSelect:this.onSelect,onDelete:!1===i?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}Ia.contextType=l.k,Ia.propTypes={index:Re().number.isRequired,id:Re().number.isRequired,newsletterId:Re().string.isRequired,name:Re().string.isRequired,thumbnail:Re().string,readonly:Re().bool.isRequired,beforeDelete:Re().func.isRequired,afterDelete:Re().func.isRequired,beforeSelect:Re().func.isRequired,afterSelect:Re().func.isRequired},Ia.defaultProps={thumbnail:null},Ia.displayName="TemplateBox";class ka extends o.Component{constructor(e){super(e),this.fileRef=(0,o.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),ut.default.size(this.fileRef.current.files)<=0)return!1;const t=ut.default.first(this.fileRef.current.files),a=new FileReader;return a.onload=e=>{try{this.saveTemplate(JSON.parse(e.target.result)),c.MailPoet.trackEvent("Emails > Template imported")}catch(e){this.context.notices.error((0,p.jsx)("p",{children:(0,Le.__)("This template file appears to be damaged. Please try another one.","mailpoet")}))}},a.readAsText(t),!0}saveTemplate(e){const t=e,{beforeImport:a,afterImport:i}=this.props;ut.default.isUndefined(t.body)||(t.body=JSON.stringify(t.body));try{t.categories=JSON.parse(t.categories)}catch(e){t.categories=[]}-1===t.categories.indexOf("saved")&&t.categories.push("saved"),-1===t.categories.indexOf("standard")&&-1===t.categories.indexOf("welcome")&&-1===t.categories.indexOf("notification")&&t.categories.push("standard"),t.categories=JSON.stringify(t.categories),a(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:t}).done((e=>{i(!0,e.data)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0}),i(!1)}))}render(){return(0,p.jsxs)("div",{className:"mailpoet-template-import",children:[(0,p.jsxs)("h4",{children:[(0,Le.__)("Import a template","mailpoet"),(0,p.jsx)(We.Tooltip,{tooltip:(0,Le.__)("You can only upload .json templates that were originally created with MailPoet.","mailpoet"),place:"right",className:"tooltip-help-import-template"})]}),(0,p.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,p.jsx)("input",{type:"file",placeholder:(0,Le.__)("Select a .json file to upload","mailpoet"),ref:this.fileRef}),(0,p.jsx)("p",{className:"submit",children:(0,p.jsx)("input",{className:"button button-primary",type:"submit",value:(0,Le.__)("Upload","mailpoet")})})]})]})}}ka.contextType=l.k,ka.propTypes={beforeImport:Re().func.isRequired,afterImport:Re().func.isRequired};const Ta=[];window.mailpoet_newsletters_templates_recently_sent_count&&Ta.push({name:"recent",label:(0,Le.__)("Recently sent","mailpoet")}),Ta.push({name:"standard",label:(0,Le.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,Le.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,Le.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,Le.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,Le.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&Ta.push({name:"woocommerce",label:(0,Le.__)("WooCommerce Emails","mailpoet")}),Ta.push({name:"saved",label:(0,Le.__)("Your saved templates","mailpoet")});class Ea extends o.Component{constructor(e){super(e),this.state={loading:!0,templates:{},emailType:null,emailOptions:{},selectedTab:""},this.templates={},this.addTemplate=this.addTemplate.bind(this),this.afterTemplateDelete=this.afterTemplateDelete.bind(this),this.afterTemplateSelect=this.afterTemplateSelect.bind(this),this.afterTemplateImport=this.afterTemplateImport.bind(this)}componentDidMount(){c.MailPoet.Ajax.get({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"getAll"}).done((e=>{0===e.data.length&&(e.data=[{name:(0,Le.__)("MailPoet's Guide","mailpoet"),categories:'["welcome", "notification", "standard", "woocommerce"]',readonly:!0}]),e.data.forEach(this.addTemplate),this.sortTemplates()})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})})).always((()=>{this.selectInitialTab()}))}addTemplate(e){const t=Ta.map((e=>e.name));let a;-1===t.indexOf("woocommerce")&&t.push("woocommerce");try{a=JSON.parse(e.categories).filter((e=>-1!==t.indexOf(e)))}catch(e){a=[]}0===a.length&&a.push("saved"),a.forEach((t=>{void 0===this.templates[t]&&(this.templates[t]=[]),this.templates[t].unshift(e)}))}sortTemplates(){const e=["welcome","notification","standard"];Object.keys(this.templates).forEach((t=>{this.templates[t].sort(((a,i)=>{if(e.includes(t)){if(a.categories.includes('"blank"')&&!i.categories.includes('"blank"'))return-1;if(!a.categories.includes('"blank"')&&i.categories.includes('"blank"'))return 1}return a.id<i.id?1:-1}))}))}selectInitialTab(){let e,t,a="standard";c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:this.props.match.params.id}}).done((i=>{e=i.data.type,t=i.data.options,"automatic"===e&&(e=i.data.options.group||e),window.mailpoet_newsletters_templates_recently_sent_count?a="recent":ut.default.findWhere(Ta,{name:i.data.type})?a=i.data.type:"automatic"===i.data.type&&ut.default.findWhere(Ta,{name:i.data.options.group})&&(a=i.data.options.group)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})})).always((()=>{this.setState({templates:this.templates,emailType:e,emailOptions:t,selectedTab:a,loading:!1})}))}afterTemplateDelete(e,t){e&&Object.keys(this.templates).forEach((e=>{this.templates[e]=this.templates[e].filter((e=>e.id!==t))})),this.setState({templates:this.templates,loading:!1})}afterTemplateSelect(e,t){e?window.location=(e=>{const t=new URLSearchParams(window.location.search).get("context"),a=`admin.php?page=mailpoet-newsletter-editor&id=${e}`;return t?`${a}&context=${t}`:a})(t):this.setState({loading:!1})}afterTemplateImport(e,t){e&&this.addTemplate(t),this.setState({templates:this.templates,selectedTab:e?"saved":"import",loading:!1})}render(){if(this.state.loading)return(0,p.jsx)(Ot.g,{});const e=Ta.concat({name:"import",label:(0,Le._x)("Import","Importing template tab title","mailpoet")}).map((e=>Object.assign(e,{automationId:`templates-${e.name.replace(/\s+/g,"-").toLowerCase()}`})));let t=null;if("import"===this.state.selectedTab)t=(0,p.jsx)(ka,{beforeImport:()=>this.setState({loading:!0}),afterImport:this.afterTemplateImport});else{let e=this.state.templates[this.state.selectedTab]||[];e=0===e.length?this.state.loading?null:(0,p.jsx)("p",{children:(0,Le.__)("This category does not contain any template yet!","mailpoet")}):e.map(((e,t)=>(0,p.jsx)(Ia,{index:t,newsletterId:this.props.match.params.id,beforeDelete:()=>this.setState({loading:!0}),afterDelete:this.afterTemplateDelete,beforeSelect:()=>this.setState({loading:!0}),afterSelect:this.afterTemplateSelect,id:e.id,name:e.name,thumbnail:e.thumbnail,readonly:e.readonly},e.id))),t=e}let a,i=null;if("automation"===this.state.emailType){const e=this.state.emailOptions?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"admin.php?page=mailpoet-automation";a=()=>{window.location=t},i=(0,p.jsx)("input",{type:"button",className:"button link-button",onClick:a,value:"Cancel"})}return(0,p.jsxs)("div",{children:[(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(Ma,{emailType:this.state.emailType,automationId:"email_template_selection_heading",buttons:i,onLogoClick:a}),(0,p.jsxs)("div",{className:"mailpoet-templates",children:[(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Sa.R,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,p.jsx)(r.ErrorBoundary,{children:t})]})]})}}Ea.contextType=l.k,Ea.propTypes={match:Re().shape({params:Re().shape({id:Re().string}).isRequired}).isRequired},Ea.display="NewsletterTemplates";var Aa=a(61888),Ra=a.n(Aa),Fa=a(5837),Oa=a.n(Fa),Da=a(15133),La=a(61515),qa=a(93676),Ba=a(28270),Wa=a.n(Ba),$a=a(40612);const Ua={abbreviated:[(0,Le.__)("Jan","mailpoet"),(0,Le.__)("Feb","mailpoet"),(0,Le.__)("Mar","mailpoet"),(0,Le.__)("Apr","mailpoet"),(0,Le.__)("May","mailpoet"),(0,Le.__)("Jun","mailpoet"),(0,Le.__)("Jul","mailpoet"),(0,Le.__)("Aug","mailpoet"),(0,Le.__)("Sep","mailpoet"),(0,Le.__)("Oct","mailpoet"),(0,Le.__)("Nov","mailpoet"),(0,Le.__)("Dec","mailpoet")],wide:[(0,Le.__)("January","mailpoet"),(0,Le.__)("February","mailpoet"),(0,Le.__)("March","mailpoet"),(0,Le.__)("April","mailpoet"),(0,Le.__)("May","mailpoet"),(0,Le.__)("June","mailpoet"),(0,Le.__)("July","mailpoet"),(0,Le.__)("August","mailpoet"),(0,Le.__)("September","mailpoet"),(0,Le.__)("October","mailpoet"),(0,Le.__)("November","mailpoet"),(0,Le.__)("December","mailpoet")]},Va={narrow:[(0,Le._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,Le._x)("M","Monday - one letter abbreviation","mailpoet"),(0,Le._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,Le._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,Le._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,Le._x)("F","Friday - one letter abbreviation","mailpoet"),(0,Le._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,Le.__)("Sun","mailpoet"),(0,Le.__)("Mon","mailpoet"),(0,Le.__)("Tue","mailpoet"),(0,Le.__)("Wed","mailpoet"),(0,Le.__)("Thu","mailpoet"),(0,Le.__)("Fri","mailpoet"),(0,Le.__)("Sat","mailpoet")],wide:[(0,Le.__)("Sunday","mailpoet"),(0,Le.__)("Monday","mailpoet"),(0,Le.__)("Tuesday","mailpoet"),(0,Le.__)("Wednesday","mailpoet"),(0,Le.__)("Thursday","mailpoet"),(0,Le.__)("Friday","mailpoet"),(0,Le.__)("Saturday","mailpoet")]};qa.Z.localize.month=Wa()({values:Ua,defaultWidth:"wide"}),qa.Z.localize.day=Wa()({values:Va,defaultWidth:"wide"}),qa.Z.options.weekStartsOn=void 0!==c.MailPoet.wpWeekStartsOn?c.MailPoet.wpWeekStartsOn:1,(0,La.registerLocale)("mailpoet",qa.Z);class Ha extends o.Component{onChange=(e,t)=>{const a=t,i=this.getStorageDate(e);a.target.name=this.getFieldName(),a.target.value=i,this.props.onChange(a)};getFieldName=()=>this.props.name||"date";getDisplayDateFormat=e=>c.MailPoet.Date.convertFormat(e).replace(/D/g,"d").replace(/Y/g,"y").replace(/A/g,"a").replace(/o/g,"Y").replace(/\[/g,"").replace(/\]/g,"");getDate=e=>{const t={parseFormat:this.props.storageFormat};return c.MailPoet.Date.toDate(e,t)};getStorageDate=e=>{const t={format:this.props.storageFormat};return c.MailPoet.Date.format(e,t)};render(){return(0,p.jsx)($a.a,{name:this.getFieldName(),selected:this.getDate(this.props.value),dateFormat:this.getDisplayDateFormat(this.props.displayFormat),disabled:this.props.disabled,onChange:this.onChange,minDate:this.getDate(window.mailpoet_current_date),maxDate:this.props.maxDate,locale:"mailpoet",...this.props.validation})}}class za extends o.Component{render(){const e=Object.keys(this.props.timeOfDayItems).map((e=>(0,p.jsx)("option",{value:e,children:this.props.timeOfDayItems[e]},`option-${this.props.timeOfDayItems[e]}`)));return(0,p.jsx)(pt.Select,{name:this.props.name||"time",value:this.props.value,disabled:this.props.disabled,onChange:this.props.onChange,isMinWidth:!0,...this.props.validation,children:e})}}za.propTypes={timeOfDayItems:Re().objectOf(Re().string).isRequired,name:Re().string,value:Re().string.isRequired,disabled:Re().bool,onChange:Re().func.isRequired,validation:Re().object},za.defaultProps={name:"time",disabled:!1,validation:{}},za.displayName="TimeSelect";class Za extends o.Component{DATE_TIME_SEPARATOR=" ";constructor(e){super(e),this.state=this.buildStateFromProps(e)}componentDidUpdate(e){this.props.value===e.value&&this.props.defaultDateTime===e.defaultDateTime||rt()((()=>{this.setState(this.buildStateFromProps(this.props))}))}getDateTime=()=>[this.state.date,this.state.time].join(this.DATE_TIME_SEPARATOR);buildStateFromProps=e=>{const t=e.value||this.props.defaultDateTime,[a,i]=t.split(this.DATE_TIME_SEPARATOR);return{date:a,time:i}};handleChange=e=>{const t={};t[e.target.name]=e.target.value,this.setState(t,this.propagateChange)};propagateChange=()=>{this.props.onChange&&this.props.onChange({target:{name:this.props.name||"",value:this.getDateTime()}})};render(){return(0,p.jsx)(Da.Grid.Column,{className:"mailpoet-datetime-container",children:(0,p.jsxs)(r.ErrorBoundary,{children:[(0,p.jsx)(Ha,{name:"date",value:this.state.date,onChange:this.handleChange,displayFormat:this.props.dateDisplayFormat,storageFormat:this.props.dateStorageFormat,disabled:this.props.disabled,validation:this.props.dateValidation,maxDate:this.props.maxDate}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(za,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var Ya=a(13779),Ga=a(57036),Ka=a(44584);class Qa extends o.Component{constructor(e){super(e);const t=(0,Ka.DA)(e.item.sender_address);this.state={emailAddress:e.item.sender_address,showSenderDomainWarning:!window.mailpoet_verified_sender_domains.includes(t),isPartiallyVerifiedDomain:window.mailpoet_partially_verified_sender_domains.includes(t),showAuthEmailsError:!1},this.onChange=this.onChange.bind(this),this.onBlur=this.onBlur.bind(this),window.mailpoet_sender_address_field_blur=this.onBlur;const a=e.field.id||`field_${e.field.name}`;this.domElementSelector=`#${a}`,this.parsleyFieldName="invalidFromAddress"}componentDidMount(){this.validateEmailAddress()}onChange(e){const t=e.target.value.toLowerCase();this.setState({emailAddress:t}),this.props.onValueChange({...e,target:{...e.target,name:e.target.name,value:t}}),this.setState({showAuthEmailsError:!1,showSenderDomainWarning:!1}),(0,Ga.dy)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,Ga.Ib)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,Ga.dy)(this.domElementSelector,this.parsleyFieldName),(0,Ga.K0)(this.domElementSelector)?e?this.showSenderDomainError(!0):this.showInvalidFromAddressError(t):(0,Ga.OP)(this.domElementSelector))};showSenderDomainError=e=>{e&&this.setState({showSenderDomainWarning:!0})};validateEmailAddress(){if(!window.mailpoet_mss_active)return;const e=this.state.emailAddress,t=(0,Ka.DA)(e);if(window.mailpoet_verified_sender_domains.includes(t))return;const a=this.isEmailAddressAuthorized(e);this.showSenderFieldError(a,e),this.setState({isPartiallyVerifiedDomain:window.mailpoet_partially_verified_sender_domains.includes(t)})}render(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(dt,{item:{...this.props.item,sender_address:this.state.emailAddress},field:this.props.field,onValueChange:this.onChange,onBlurEvent:this.onBlur}),(0,p.jsx)("div",{className:"regular-text regular-text-full-width",children:(0,p.jsx)(Ya.L,{emailAddress:this.state.emailAddress,mssActive:window.mailpoet_mss_active,isEmailAuthorized:!this.state.showAuthEmailsError,showSenderDomainWarning:this.state.showSenderDomainWarning&&!this.state.showAuthEmailsError,isPartiallyVerifiedDomain:this.state.isPartiallyVerifiedDomain,senderRestrictions:window.mailpoet_sender_restrictions,onSuccessfulEmailOrDomainAuthorization:e=>{"email"===e.type&&(this.setState({showAuthEmailsError:!1}),c.MailPoet.trackEvent("MSS in plugin authorize email",{"authorized email source":"newsletter",wasSuccessful:"yes"})),"domain"===e.type&&(this.setState({showSenderDomainWarning:!1}),this.setState({isPartiallyVerifiedDomain:!1}),c.MailPoet.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"newsletter",wasSuccessful:"yes"})),(0,Ga.dy)(this.domElementSelector,this.parsleyFieldName)}})})]})}}Qa.propTypes={field:Re().object.isRequired,item:Re().shape({sender_address:Re().string.isRequired}).isRequired,onValueChange:Re().func},Qa.defaultProps={onValueChange:function(){}},Qa.displayName="SenderField";const Ja=ut.default.once((()=>c.MailPoet.trackEvent("User has typed a GA campaign name"))),Xa=f()((0,Le.__)("For example, “Spring email”. [link]Read the guide.[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,p.jsxs)("span",{children:[(0,p.jsx)("br",{}),(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/187-track-your-newsletters-subscribers-in-google-analytics",target:"_blank",rel:"noopener noreferrer",className:"mailpoet-link",children:e})]},t))),ei={name:"ga_campaign",label:(0,Le.__)("Google Analytics Campaign","mailpoet"),tip:Xa,type:"text",onBeforeChange:Ja};var ti=a(76545),ai=a(42305),ii=a(20174),si=a(81207);const ni={saveDraftNewsletter:()=>Promise.resolve()},oi=o.createContext(ni);var ri=a(6958);function li(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const di=[{name:"segments",label:(0,Le.__)("Send to","mailpoet"),type:"selection",placeholder:(0,Le.__)("Choose","mailpoet"),id:"mailpoet_segments",api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!0,filter:function(e){return!e?.deleted_at},getLabel:function(e){return e.name},getCount:function(e){return parseInt(e.subscribers,10).toLocaleString()},transformChangedValue:function(e){const t=this.getItems()||[];return e.map((e=>t.find((t=>t.id===e))))},validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,Le.__)("Please select a list with subscribers.","mailpoet")}},{name:"filter-segment-toggle",type:"reactComponent",component:(0,r.withBoundary)((function({item:e,onValueChange:t,field:a}){const i=e?.options.filterSegmentId,[s,n]=(0,o.useState)(ii.P&&!!i),l=(0,o.useCallback)((a=>{t({target:{name:"options",value:{...e?.options??{},filterSegmentId:a}}})}),[e,t]),d=(0,o.useContext)(oi);(0,o.useEffect)((()=>{ii.P||""===i||l("")}),[l,i]);const m=(0,o.useCallback)((i=>{t({target:{name:a.name,value:i}}),i||l(""),n(i),c.MailPoet.trackEvent("Emails > Filter by segment toggled",{"Email type":e.type})}),[a,t,l,e]);let u;if(s){const t={name:"filter-segment",type:"selection",placeholder:(0,Le.__)("Choose","mailpoet"),id:"mailpoetFilterSegment",api_version:window.mailpoet_api_version,endpoint:"segments",multiple:!1,forceSelect2:!0,selected:e=>e.options.filterSegmentId,filter:function(e){return!e.deleted_at&&"dynamic"===e.type},getLabel:function(e){return e.name},getCount:function(e){return parseInt(e.subscribers,10).toLocaleString()},validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please select a filter segment","mailpoet")}};u=(0,p.jsx)(De.Y,{item:e,field:t,onValueChange:t=>{l(t.target.value),c.MailPoet.trackEvent("Emails > Filter by segment selected",{"Email type":e.type})}})}const h=`admin.php?page=mailpoet-segments#/new-segment?newsletterId=${e.id}`;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.Toggle,{checked:s,disabled:a.disabled,name:"isFilterSegmentEnabled",onCheck:m,automationId:"filter-segment-toggle"}),(0,p.jsxs)("span",{className:"mailpoet-form-toggle-text",children:[(0,Le.__)("Filter by segment","mailpoet"),(0,p.jsx)(pa.Z,{"data-tip":!0,"data-for":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:Ue.Z})]}),(0,p.jsx)(si.u,{place:"right",multiline:!0,id:"filter-segment-tooltip",children:(0,p.jsx)("div",{children:(0,Le.__)("Subscribers selected in 'Send to' will only receive an email if they also belong to this segment.","mailpoet")})}),(0,p.jsx)("div",{className:"mailpoet-gap"}),u,s&&(0,p.jsx)("p",{children:f()((0,Le.__)("Can't find the segment you're looking for? [link]Create new[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((t,a)=>(0,p.jsx)("a",{className:"mailpoet-link",rel:"noopener noreferrer",onClick:async t=>{t.preventDefault(),c.MailPoet.trackEvent("Emails > Create new segment clicked",{"Email type":e.type}),await d.saveDraftNewsletter(),window.location.href=h},href:h,children:t},a)))})]})}))}],ci={name:"recipient-count",type:"reactComponent",component:(0,r.withBoundary)((function(e){const[t,a]=(0,o.useState)(!0),[i,s]=(0,o.useState)(0),n=(0,o.useMemo)((()=>(e.item.segments||[]).map((e=>e.id))),[e.item.segments]),r=(0,o.useMemo)((()=>e.item.options?.filterSegmentId||null),[e.item.options?.filterSegmentId]),l=(0,o.useRef)(""),d=(0,o.useRef)({});return(0,o.useEffect)((()=>{const e=li(n,r);return l.current=e,n.length<1?(s(0),void a(!1)):e in d.current?(s(d.current[e]),void a(!1)):(a(!0),void c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"subscriberCount",data:{segmentIds:n,filterSegmentId:r}}).done((t=>{const a=t.data.count;d.current[e]=a;const i=li(n,r);l.current===i&&s(a)})).always((()=>a(!1))))}),[n,r]),(0,p.jsxs)("div",{children:[(0,Le.__)("Estimated recipients","mailpoet"),":",t&&(0,p.jsx)(ri.ZP,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(si.u,{place:"right",multiline:!0,id:"estimated-count-tooltip",children:(0,Le.__)("This count may change at the time of sending.","mailpoet")}),(0,p.jsx)("span",{"data-tip":!0,"data-for":"estimated-count-tooltip",className:"estimated-recipient-count",children:i.toLocaleString()})]})]})}))},mi={name:"send-to",label:(0,Le.__)("Send to","mailpoet"),tip:(0,Le.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:di},ui={name:"send-to",label:(0,Le.__)("Send to","mailpoet"),tip:(0,Le.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...di,ci]},pi=window.mailpoet_current_time||"00:00",hi=`${window.mailpoet_tomorrow_date} 08:00:00`,gi=window.mailpoet_schedule_time_of_day,_i=window.mailpoet_date_format,fi=window.mailpoet_date_storage_format;class bi extends o.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:hi,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please enter the scheduled date.","mailpoet"),"data-parsley-errors-container":"#mailpoet_scheduling"});isScheduled=()=>"1"===this.getCurrentValue().isScheduled;handleCheckboxChange=(e,t)=>{const a={...t};a.target.value=t.target.checked?"1":"0",this.handleValueChange(a)};handleValueChange=e=>{const t=this.getCurrentValue(),a={};a[e.target.name]=e.target.value,this.props.onValueChange({target:{name:this.props.field.name,value:{...t,...a}}})};render(){let e;const t=new Date;return t.setFullYear(t.getFullYear()+5),this.isScheduled()&&(e=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"mailpoet-form-schedule-time",children:[(0,Le.__)("Your website’s time is","mailpoet")," ",pi]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{id:"mailpoet_scheduling",children:(0,p.jsx)(Za,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:hi,timeOfDayItems:gi,dateDisplayFormat:_i,dateStorageFormat:fi,maxDate:t})})]})),(0,p.jsxs)("div",{children:[(0,p.jsx)(ti.Z,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}let xi=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Le.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Le.__)("Type newsletter subject","mailpoet"),tooltip:(0,Le.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Le.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Le.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Le.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Le.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},ui,{name:"options",label:(0,Le.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,r.withBoundary)(bi)},{name:"sender",label:(0,Le.__)("Sender","mailpoet"),tip:(0,Le.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Qa),placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},ei,{name:"reply-to",label:(0,Le.__)("Reply-to","mailpoet"),tip:(0,Le.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];xi=Wt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",xi);const vi={getFields:()=>xi,getSendButtonOptions:(e={})=>{const t=st()(window.mailpoet_current_date_time),a={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&c.MailPoet.Date.isInFuture(e.options?.scheduledAt,t)?(0,Le.__)("Schedule","mailpoet"):(0,Le.__)("Send","mailpoet")};return e.status!==ai.sj.Sent&&e.status!==ai.sj.Sending||(a.disabled="disabled"),a}},ji=window.mailpoet_time_format||"H:i",yi={immediate:(0,Le.__)("immediately","mailpoet"),minutes:(0,Le.__)("minute(s) later","mailpoet"),hours:(0,Le.__)("hour(s) later","mailpoet"),days:(0,Le.__)("day(s) later","mailpoet"),weeks:(0,Le.__)("week(s) later","mailpoet")},wi={daily:(0,Le.__)("Once a day at...","mailpoet"),weekly:(0,Le.__)("Weekly on...","mailpoet"),monthly:(0,Le.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,Le.__)("Monthly every...","mailpoet"),immediately:(0,Le.__)("Immediately","mailpoet")},Si=ut.default.object(ut.default.map(ut.default.times(96,(e=>900*e)),(e=>{const t=new Date(null);return t.setSeconds(e),[e,c.MailPoet.Date.format(t,{format:ji,offset:0})]}))),Pi={0:(0,Le.__)("Sunday","mailpoet"),1:(0,Le.__)("Monday","mailpoet"),2:(0,Le.__)("Tuesday","mailpoet"),3:(0,Le.__)("Wednesday","mailpoet"),4:(0,Le.__)("Thursday","mailpoet"),5:(0,Le.__)("Friday","mailpoet"),6:(0,Le.__)("Saturday","mailpoet")},Mi=ut.default.object(ut.default.map(ut.default.times(28,(e=>e)),(e=>{const t={0:(0,Le.__)("1st","mailpoet"),1:(0,Le.__)("2nd","mailpoet"),2:(0,Le.__)("3rd","mailpoet")};let a;return a=void 0!==t[e]?t[e]:(0,Le.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,a]}))),Ni={1:(0,Le.__)("1st","mailpoet"),2:(0,Le.__)("2nd","mailpoet"),3:(0,Le.__)("3rd","mailpoet"),L:(0,Le._x)("last","e.g. monthly every last Monday","mailpoet")},Ci={name:"intervalType",values:wi},Ii={name:"timeOfDay",values:Si},ki={name:"weekDay",values:Pi},Ti={name:"monthDay",values:Mi},Ei={name:"nthWeekDay",values:Ni};class Ai extends o.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};handleValueChanges=e=>{const t=this.getCurrentValue();return this.props.onValueChange({target:{name:this.props.field.name,value:ut.default.extend({},t,e)}})};handleIntervalChange=e=>{const t=e.target.value,a={};a.intervalType=t,"monthly"===t&&(a.monthDay="1"),this.handleValueChanges(a)};handleTimeOfDayChange=e=>this.handleValueChanges({timeOfDay:e.target.value});handleWeekDayChange=e=>this.handleValueChanges({weekDay:e.target.value});handleMonthDayChange=e=>this.handleValueChanges({monthDay:e.target.value});handleNthWeekDayChange=e=>this.handleValueChanges({nthWeekDay:e.target.value});render(){const e=this.getCurrentValue();let t,a,i,s;return"immediately"!==e.intervalType&&(t=(0,p.jsx)(ht,{field:Ii,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"!==e.intervalType&&"nthWeekDay"!==e.intervalType||(a=(0,p.jsx)(ht,{field:ki,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(i=(0,p.jsx)(ht,{field:Ti,item:this.getCurrentValue(),onValueChange:this.handleMonthDayChange})),"nthWeekDay"===e.intervalType&&(s=(0,p.jsx)(ht,{field:Ei,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,p.jsxs)("div",{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsx)(ht,{field:Ci,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,p.jsx)("div",{children:(0,p.jsx)("p",{children:(0,Le.__)("after publishing a post","mailpoet")})})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[s,i,a,t]}),"immediately"!==e.intervalType&&(0,p.jsx)("div",{className:"mailpoet-gap"})]})}}Ai.propTypes={item:Re().object.isRequired,field:Re().shape({name:Re().string}).isRequired,onValueChange:Re().func.isRequired};let Ri=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Le.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Le.__)("Type newsletter subject","mailpoet"),tooltip:(0,Le.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Le.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Le.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Le.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Le.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Le.__)("Select a frequency","mailpoet"),type:"reactComponent",component:Ai},ui,{name:"sender",label:(0,Le.__)("Sender","mailpoet"),tip:(0,Le.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Qa),placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},ei,{name:"reply-to",label:(0,Le.__)("Reply-to","mailpoet"),tip:(0,Le.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Ri=Wt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Ri);const Fi={getFields:function(){return Ri},getSendButtonOptions:function(){return{value:(0,Le.__)("Activate","mailpoet")}}},Oi=window.mailpoet_roles||{},Di=ut.default.filter(window.mailpoet_segments||[],(e=>"default"===e.type)),Li={name:"event",values:{segment:(0,Le.__)("When someone subscribes to the list...","mailpoet"),user:(0,Le.__)("When a new WordPress user is added to your site...","mailpoet")}},qi={name:"segment",placeholder:(0,Le.__)("Select a list","mailpoet"),forceSelect2:!0,values:Di,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},Bi={name:"role",values:Oi},Wi={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Le.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},$i={name:"afterTimeType",values:yi};class Ui extends o.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};handleValueChange=(e,t)=>{const a=this.getCurrentValue(),i={};let s=t;return"afterTimeNumber"===e&&(s=parseInt(t,10),s=Number.isNaN(s)?"":s),i[e]=s,this.props.onValueChange({target:{name:this.props.field.name,value:ut.default.extend({},a,i)}})};handleEventChange=e=>this.handleValueChange("event",e.target.value);handleSegmentChange=e=>this.handleValueChange("segment",e.target.value);handleRoleChange=e=>this.handleValueChange("role",e.target.value);handleAfterTimeNumberChange=e=>this.handleValueChange("afterTimeNumber",e.target.value);handleAfterTimeTypeChange=e=>this.handleValueChange("afterTimeType",e.target.value);render(){const e=this.getCurrentValue();let t,a;return t="user"===e.event?(0,p.jsx)(ht,{field:Bi,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,p.jsx)(De.Y,{field:qi,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(a=(0,p.jsx)(dt,{field:Wi,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,p.jsxs)("div",{children:[(0,p.jsx)(ht,{field:Li,item:this.getCurrentValue(),onValueChange:this.handleEventChange}),(0,p.jsx)("div",{className:"mailpoet-gap"}),t,(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[a,(0,p.jsx)(ht,{field:$i,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,p.jsx)("div",{className:"mailpoet-form-errors"}),(0,p.jsx)("div",{className:"mailpoet-gap"})]})}}Ui.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired,item:Re().object.isRequired,field:Re().shape({name:Re().string}).isRequired,onValueChange:Re().func.isRequired},Ui.displayName="WelcomeScheduling";const Vi=(0,ke.EN)(Ui);let Hi=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Le.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Le.__)("Type newsletter subject","mailpoet"),tooltip:(0,Le.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Le.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Le.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Le.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Le.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Le.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,r.withBoundary)(Vi)},ei,{name:"sender",label:(0,Le.__)("Sender","mailpoet"),tip:(0,Le.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,r.withBoundary)(Qa),placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Le.__)("Reply-to","mailpoet"),tip:(0,Le.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Hi=Wt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Hi);const zi={getFields:function(){return Hi},getSendButtonOptions:function(){return{value:(0,Le.__)("Activate","mailpoet")}}};class Zi extends o.Component{constructor(e){super(e);const{item:t,event:a}=this.props;this.handleChange=this.handleChange.bind(this);const i=t.afterTimeType||a.defaultAfterTimeType||"immediate",s="minutes"===i?30:1,n=t.afterTimeNumber||s;this.state={afterTimeType:i,afterTimeNumber:n},t.afterTimeNumber===n&&t.afterTimeType===i||this.propagateChange(this.state)}handleChange(e,t){let{value:a}=e.target;"afterTimeNumber"===t&&(a=parseInt(e.target.value,10),a=Number.isNaN(a)?null:a);const i={[t]:a},{afterTimeType:s}=this.state;"afterTimeType"===t&&s!==a&&("minutes"===s&&(i.afterTimeNumber=1),"minutes"===a&&(i.afterTimeNumber=30)),this.setState(i,this.propagateChange(i))}displayAfterTimeTypeOptions(){const{event:e}=this.props;let t=yi;e.timeDelayValues&&(t=Object.entries(e.timeDelayValues).reduce(((e,[t,a])=>(e[t]=a.text,e)),{}));const{afterTimeType:a}=this.state,i={field:{id:"scheduling_time_interval",name:"scheduling_time_interval",forceSelect2:!0,values:ut.default.map(t,((e,t)=>({name:e,id:t}))),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>a},onValueChange:ut.default.partial(this.handleChange,ut.default,"afterTimeType")};return(0,p.jsx)(De.Y,{field:i.field,onValueChange:i.onValueChange})}displayAfterTimeNumberField(){const{afterTimeNumberSize:e,event:t}=this.props,{afterTimeType:a,afterTimeNumber:i}=this.state;if("immediate"===a)return null;if(t.timeDelayValues&&t.timeDelayValues[a]&&!t.timeDelayValues[a].displayAfterTimeNumberField)return null;const s={field:{id:"scheduling_time_duration",name:"scheduling_time_duration",className:"mailpoet-form-input-small",defaultValue:i?i.toString():"",size:e,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Le.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:ut.default.partial(this.handleChange,ut.default,"afterTimeNumber")};return(0,p.jsx)(dt,{field:s.field,item:s.item,onValueChange:s.onValueChange})}propagateChange(e){const{onValueChange:t}=this.props;t&&t(e)}render(){const{event:e}=this.props;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("h4",{children:[" ",(0,Le.__)("When to send this email?","mailpoet")," "]}),(0,p.jsxs)(Da.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[this.displayAfterTimeNumberField(),this.displayAfterTimeTypeOptions(),e.afterDelayText&&(0,p.jsx)("p",{children:e.afterDelayText})]}),(0,p.jsx)("div",{className:"mailpoet-form-errors"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),e.schedulingReadMoreLink&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("a",{href:e.schedulingReadMoreLink.link,target:"_blank",rel:"noopener noreferrer",className:"event-scheduling-read-more-link",children:e.schedulingReadMoreLink.text}),(0,p.jsx)("div",{className:"mailpoet-gap"})]})]})}}function Yi(e){const t=e&&e.values?e.values:[];return t?t.map((e=>({id:e.id,name:e.name}))):t}function Gi({eventOptions:e,eventSlug:t,selected:a,onValueChange:i}){function s(e){i&&i({eventOptionValue:e.target.value})}return(0,p.jsx)("div",{children:(0,p.jsx)("div",{className:"event-option-selection",children:function(){if(!e)return null;const i={field:{name:`event_options_${t}`,forceSelect2:!0,endpoint:e.endpoint,resetSelect2OnUpdate:!0,values:Yi(e),multiple:e.multiple||!1,placeholder:e.placeholder||!1,transformChangedValue:(e,t)=>ut.default.map(t,(e=>({id:e.id,name:e.text}))),selected:()=>a,getLabel:ut.default.property("name"),getValue:ut.default.property("id"),validation:{"data-parsley-required":!0}},onValueChange:s,item:{action:""}};return"product_categories"===e.endpoint&&(i.field.name="category_ids",i.item={action:"purchasedCategory"}),"products"===e.endpoint&&(i.field.name="product_ids",i.item={action:"purchasedProduct"}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(De.Y,{field:i.field,onValueChange:i.onValueChange,item:i.item}),(0,p.jsx)("div",{className:"mailpoet-gap"})]})}()})})}Zi.propTypes={item:Re().shape({afterTimeType:Re().string.isRequired,afterTimeNumber:Re().number}).isRequired,afterTimeNumberSize:Re().number,onValueChange:Re().func,event:Re().shape({defaultAfterTimeType:Re().string,afterDelayText:Re().string,timeDelayValues:Re().objectOf(Re().shape({text:Re().string,displayAfterTimeNumberField:Re().bool})),schedulingReadMoreLink:Re().shape({link:Re().string.isRequired,text:Re().string.isRequired})}).isRequired},Zi.defaultProps={afterTimeNumberSize:3,onValueChange:null},Zi.displayName="EventScheduling",Gi.displayName="EventOptions";const Ki=(0,r.withBoundary)(Gi);class Qi extends o.Component{constructor(e){super(e);const{field:t}=e;this.handleChange=this.handleChange.bind(this),this.email=t.email,this.emailOptions=t.emailOptions,this.events=ut.default.indexBy(this.email.events,"slug"),this.segments=ut.default.filter(window.mailpoet_segments,(e=>null===e.deleted_at));const a=this.events[this.emailOptions.event],i=this.emailOptions.afterTimeType||a.defaultAfterTimeType||"immediate";this.state={event:a,afterTimeType:i,eventSlug:this.emailOptions.event,eventOptionValue:null,afterTimeNumber:this.emailOptions.afterTimeNumber||1,segment:this.emailOptions.segment?this.emailOptions.segment:null}}handleChange(e){const{afterTimeNumber:t}=this.state,a=e;a.afterTimeType&&"immediate"===a.afterTimeType?a.afterTimeNumber=null:!a.afterTimeType||a.afterTimeNumber||t||(a.afterTimeNumber=1),this.setState(e,this.propagateChange)}displayScheduling(){const{afterTimeNumber:e,afterTimeType:t,event:a}=this.state,i={item:{afterTimeNumber:e,afterTimeType:t},event:a,onValueChange:this.handleChange};return(0,p.jsx)(Zi,{item:i.item,event:i.event,onValueChange:i.onValueChange})}displaySegments(){const{segment:e}=this.state;if("user"===this.emailOptions.sendTo)return null;const t={field:{id:"segments",forceSelect2:!0,values:this.segments,extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>e},onValueChange:e=>this.handleChange({segment:e.target.value})};return(0,p.jsx)("div",{className:"event-segment-selection",children:(0,p.jsx)(De.Y,{field:t.field,onValueChange:t.onValueChange})})}displayEventOptions(){const{event:e,eventSlug:t}=this.state;let a;try{a=JSON.parse(this.emailOptions.meta||null)}catch(e){a=this.emailOptions.meta||null}const i={emailSlug:this.email.slug,eventSlug:t,onValueChange:this.handleChange,eventOptions:e.options||null};return a&&a.option&&("remote"===i.eventOptions.type&&(i.eventOptions.values=a.option),i.selected=ut.default.map(a.option,(e=>e.id))),(0,p.jsx)(Ki,{emailSlug:i.emailSlug,eventSlug:i.eventSlug,eventOptions:i.eventOptions,onValueChange:i.onValueChange,selected:i.selected})}displayHeader(){const{event:e}=this.state;return e.title}propagateChange(){const{eventSlug:e,afterTimeType:t,afterTimeNumber:a,segment:i,eventOptionValue:s}=this.state,{onValueChange:n}=this.props;if(!n)return;const o={group:this.email.slug,event:e,afterTimeType:t};a&&(o.afterTimeNumber=a),i&&(o.segment=i),s&&(o.meta=JSON.stringify({option:this.state.eventOptionValue})),n({target:{name:"options",value:o}})}render(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(wt.X,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}Qi.propTypes={field:Re().shape({email:Re().shape({events:Re().object.isRequired}).isRequired,emailOptions:Re().object.isRequired}).isRequired,onValueChange:Re().func},Qi.defaultProps={onValueChange:null},Qi.displayName="SendEventConditions";const Ji=window.mailpoet_woocommerce_automatic_emails||[],Xi={getFields:function(e){return(e=>{const t=Ji[e.options.group];if(!t)return!1;const a=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Le.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Le.__)("Type newsletter subject","mailpoet"),tooltip:(0,Le.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Le.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Le.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Le.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Le.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Le.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,r.withBoundary)(Qi),email:t,emailOptions:a},ei,{name:"sender",label:(0,Le.__)("Sender","mailpoet"),tip:(0,Le.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Le.__)("Reply-to","mailpoet"),tip:(0,Le.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,Le.__)("Activate","mailpoet")}}};var es=a(30211);function ts({afterTimeNumber:e,afterTimeType:t,updateAfterTimeNumber:a,updateAfterTimeType:i,inactiveSubscribersPeriod:s}){const n="weeks"===t?7:30,o=Number(e)*n;let r=s;return 365===s&&(r=360),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:4,children:(0,Le.__)("When to send this re-engagement email?","mailpoet")}),(0,p.jsxs)(Da.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[(0,p.jsx)("p",{children:(0,Le.__)("After no activity for","mailpoet")}),(0,p.jsx)(lt.I,{type:"text",placeholder:(0,Le.__)("count","mailpoet"),value:e,onChange:(0,Ka.z2)(a)}),(0,p.jsxs)(pt.Select,{value:t,onChange:(0,Ka.z2)(i),children:[(0,p.jsx)("option",{value:"weeks",children:"weeks"}),(0,p.jsx)("option",{value:"months",children:"months"})]})]}),!!s&&r<=o&&(0,p.jsx)("p",{className:"mailpoet-re-engagement-scheduling-note",children:f()((0,Le.__)("Disengaged subscribers will [link]become inactive[/link] after {$months} months and won’t receive this email. Please select a shorter period.","mailpoet").replace("{$months}",`${Math.floor(s/30)}`),/\[link\](.*?)\[\/link\]/g,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/264-inactive-subscribers",target:"_blank",rel:"noopener noreferrer",children:e},"link")))})]})}const as=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Le.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Le.__)("Type newsletter subject","mailpoet"),tooltip:(0,Le.__)("Be creative! It's the first thing that your subscribers see. Tempt them to open your email.","mailpoet"),type:"text",validation:{"data-parsley-required":!0,"data-parsley-required-message":(0,Le.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Le.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Le.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Le.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Le.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",type:"reactComponent",component:function(e){return(0,p.jsx)(ts,{afterTimeNumber:e.item.options.afterTimeNumber.toString(),afterTimeType:e.item.options.afterTimeType,inactiveSubscribersPeriod:Number(c.MailPoet.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:t=>{e.onValueChange({target:{name:"options",value:(0,es.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,es.assoc)("afterTimeType",t,e.item.options)}})}})}},mi,{name:"sender",label:(0,Le.__)("Sender","mailpoet"),tip:(0,Le.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:Qa,placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,Le.__)("Reply-to","mailpoet"),tip:(0,Le.__)("When your subscribers reply to your emails, their emails will go to this address.","mailpoet"),inline:!0,fields:[{name:"reply_to_name",type:"text",placeholder:(0,Le.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Le.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},ei],is={getFields(){return as},getSendButtonOptions(){return{value:(0,Le.__)("Activate","mailpoet")}}};var ss=a(86194);let ns=null;var os=a(82380);function rs({toggleLoadingState:e,updatePendingState:t}){const a=(0,o.useCallback)((async()=>{try{const{success:e,res:a}=await(0,r.callApi)({endpoint:"services",action:"refreshMSSKeyStatus"});!0===e?t(!(0,r.isTruthy)(a.data.result.data.is_approved)):c.MailPoet.Notice.showApiErrorNotice(a)}catch(e){c.MailPoet.Notice.showApiErrorNotice(e)}}),[t]),[i,s]=(0,o.useState)(!0);return(0,p.jsxs)("div",{className:"mailpoet_error",children:[(0,p.jsx)(os.aK,{}),i&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),(0,p.jsx)(os.qy,{onRefreshClick:async t=>{t.preventDefault(),e(!0),await a(),s(!1),e(!1)}})]})]})}rs.displayName="PendingNewsletterMessage";const ls=(0,r.withBoundary)(rs),ds=window.mailpoet_woocommerce_automatic_emails||{},cs=(e,t)=>`${Oa()(t,{strict:!0,lower:!0})||"email"}-${e}`,ms=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function us(e){let t,a;if(!c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")||null===e.wp_post_id)return e&&e.body&&e.body.content&&(a=e.body.content,t=JSON.stringify(e.body.content),!a.blocks||!Array.isArray(a.blocks)||0===a.blocks.length)?(0,Le.__)("Poet, please add prose to your masterpiece before you send it to your followers.","mailpoet"):window.mailpoet_mss_active&&t.indexOf("[link:subscription_unsubscribe_url]")<0&&t.indexOf("[link:subscription_unsubscribe]")<0?(0,Le.__)('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.',"mailpoet"):"re_engagement"===e.type&&t.indexOf("[link:subscription_re_engage_url]")<0?(0,Le.__)("A re-engagement email must include a link with [link:subscription_re_engage_url] shortcode.","mailpoet"):"notification"===e.type&&t.indexOf('"type":"automatedLatestContent"')<0&&t.indexOf('"type":"automatedLatestContentLayout"')<0?(0,Le._x)("Please add an “Automatic Latest Content” widget to the email from the right sidebar.","(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside","mailpoet"):"standard"===e.type&&"sent"===e.status?(0,Le.__)("This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.","mailpoet"):"re_engagement"!==e.type||c.MailPoet.trackingConfig.emailTrackingEnabled?void 0:(0,p.jsx)("span",{style:{pointerEvents:"all"},children:f()((0,Le.__)("Re-engagement emails are disabled because [link]open and click tracking[/link] is disabled.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e=>(0,p.jsx)("a",{href:"?page=mailpoet-settings#/advanced",rel:"noopener noreferrer",children:e},"advancedSettingsTabLink")))})}class ps extends o.Component{constructor(e){super(e),this.saveDraftNewsletter=this.saveDraftNewsletter.bind(this),this.state={fields:[],item:{},loading:!0,thumbnailPromise:null,showPremiumModal:!1,mssKeyPendingApproval:window.mailpoet_mss_key_pending_approval,sendContextValue:{saveDraftNewsletter:this.saveDraftNewsletter}}}componentDidMount(){this.loadItem(this.props.match.params.id).always((()=>{this.setState({loading:!1})})),Ee()("#mailpoet_newsletter").parsley({successClass:""})}componentDidUpdate(e){this.props.match.params.id!==e.match.params.id&&this.loadItem(this.props.match.params.id).always((()=>{this.setState({loading:!1})}))}getFieldsByNewsletter=e=>this.getSubtype(e).getFields(e);getSendButtonOptions=()=>this.getSubtype(this.state.item).getSendButtonOptions(this.state.item);getSubtype=e=>{if(e.type===ai.j9.Automatic&&ds[e.options.group])return Xi;switch(e.type){case"notification":return Fi;case"welcome":return zi;case"re_engagement":return is;default:return vi}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,ss.W0)(e);isValid=()=>Ee()("#mailpoet_newsletter").parsley().isValid();isCampaign=()=>(window.mailpoet_sender_restrictions?.campaignTypes??[]).includes(this.state?.item?.type);isAuthorizedDomainRequired=()=>{const e=window.mailpoet_sender_restrictions?.isAuthorizedDomainRequiredForNewCampaigns||!1;return this.isCampaign()&&e};isValidFromAddress=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return!0;const e=await this.loadVerifiedSenderDomains(),t=(0,Ka.DA)(this.state.item.sender_address);if(-1!==e.indexOf(t))return!0;const a=await this.loadAuthorizedEmailAddresses(),i=this.state.item.sender_address;return-1!==a.indexOf(i)&&!this.isAuthorizedDomainRequired()};loadItem=e=>(this.setState({loading:!0}),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:e}}).done((e=>{const t="draft"===e.data.status?this.getThumbnailPromise(e.meta.preview_url):null,a=e.data;if(a.type===ai.j9.Automation){const e=a.options?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"/new";return this.setState({item:{}},(()=>{this.props.history.push(t)}))}!a.ga_campaign&&ii.P&&(a.ga_campaign=cs(a.id,a.subject));const i=new URLSearchParams(this.props.location.search).get("filterSegmentId");return i&&(e.data.options.filterSegmentId=i),this.setState({item:e.data,fields:this.getFieldsByNewsletter(e.data),thumbnailPromise:t,validationError:us(e.data)}),!0})).fail((()=>{this.setState({item:{}},(()=>{this.props.history.push("/new")}))})));saveTemplate=(e,t)=>{this.getThumbnailPromise(e.meta.preview_url).then((a=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"save",data:{newsletter_id:e.data.id,name:e.data.subject,thumbnail_data:a,body:JSON.stringify(e.data.body),categories:'["recent"]'}}).then((()=>t())).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)}))})).catch((e=>{this.showError({errors:[e]})}))};loadAuthorizedEmailAddresses=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return[];const e=(await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[];return window.mailpoet_authorized_emails=e,e};loadVerifiedSenderDomains=async()=>"MailPoet"!==window.mailpoet_mta_method?[]:(await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[];handleSend=e=>(e.preventDefault(),this.isValid()?(c.MailPoet.Modal.loading(!0),this.isValidFromAddress().then((e=>{e?this.saveNewsletter().done((()=>{this.setState({loading:!0})})).done((e=>{switch(e.data.type){case"notification":case"welcome":case"automatic":case"re_engagement":this.activateNewsletter(e);break;default:this.sendNewsletter(e)}})).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)})):(window.mailpoet_sender_address_field_blur(),c.MailPoet.Modal.loading(!1))}))):Ee()("#mailpoet_newsletter").parsley().validate());sendNewsletter=e=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"add",data:{newsletter_id:this.state.item.id}}).done((t=>{this.saveTemplate(e,(()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return c.MailPoet.Modal.loading(!1),void this.props.history.push(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");let a=[];e.data.segments.map((e=>a.push(...e.filters))),a=Ra().uniqWith(a,((e,t)=>e.action===t.action&&e.type===t.type));const i=a.map((e=>function(e){const t=e.action,a=e.type;if("automations"===a)switch(t){case"enteredAutomation":return"entered automation";case"exitedAutomation":return"exited automation";default:return""}if("email"===a)switch(t){case"machineOpensAbsoluteCount":return"number of machine-opens";case"opensAbsoluteCount":return"number of opens";case"clicked":return"clicked";case"clickedAny":return"clicked any email";case"opened":return"opened";case"machineOpened":return"machine-opened";case"wasSent":return"was sent";case"numberReceived":return"number of emails received";case"numberOfClicks":return"number of clicks";default:return""}if("userRole"===a)switch(t){case"subscriberTag":return"subscriber tags";case"subscribedToList":return"subscribed to list";case"subscriberScore":return"score";case"wordpressRole":return"WordPress user role";case"lastEngagementDate":return"last engagement date";case"lastClickDate":return"last click date";case"lastPurchaseDate":return"last purchase date";case"lastOpenDate":return"last open date";case"lastPageViewDate":return"last page view date";case"lastSendingDate":return"last sending date";case"subscriberFirstName":return"first name";case"subscriberLastName":return"last name";case"subscriberEmail":return"email";case"subscribedViaForm":return"subscribed via form";default:return""}if("woocommerce"===a)switch(t){case"customerInCountry":return"is in country";case"customerInPostalCode":return"postal code";case"customerInCity":return"city";case"purchasedCategory":return"purchased in category";case"purchasedTag":return"purchased with tag";case"purchasedProduct":return"purchased product";case"subscribedDate":return"subscribed date";case"totalSpent":return"total spent";case"firstOrder":return"first order";case"purchaseDate":return"purchase date";case"averageSpent":return"average order value";case"singleOrderValue":return"single order value";case"usedPaymentMethod":return"used payment method";case"usedShippingMethod":return"used shipping method";case"numberOfReviews":return"number of reviews";case"usedCouponCode":return"used coupon code";case"numberOfOrders":return"number of orders";case"purchasedWithAttribute":return"purchased with attribute";default:return""}return"woocommerceSubscription"===a&&"hasActiveSubscription"===t?"has an active subscription":"woocommerceMembership"===a&&"isMemberOf"===t?"is active member of":""}(e))).join(", "),s="scheduled"===t.data.status;c.MailPoet.trackEvent("Emails > Newsletter sent",{scheduled:s,"Segment Applied":!!this.state.item.options.filterSegmentId,segments:i}),s?this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("The newsletter is being sent...","mailpoet")}),{id:"mailpoet_notice_being_sent"}),c.MailPoet.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)}));activateNewsletter=e=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:this.props.match.params.id,status:"active"}}).done((t=>{this.saveTemplate(e,(()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return c.MailPoet.Modal.loading(!1),void this.props.history.push(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");const e=this.state.item.options;"automatic"===this.state.item.type&&ds[e.group]?c.MailPoet.trackEvent("Emails > Automatic email activated",{Type:Oa()(`${e.group}-${e.event}`),Delay:ms(e)}):"welcome"===t.data.type?c.MailPoet.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:ms(e)}):"re_engagement"===t.data.type?(this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("Your Re-engagement Email is now activated!","mailpoet")})),c.MailPoet.trackEvent("Emails > Re-engagement email activated",{Inactivity:ms(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("Your post notification is now active!","mailpoet")})),c.MailPoet.trackEvent("Emails > Post notifications activated",{Frequency:e.intervalType,"Segment Applied":!!this.state.item.options.filterSegmentId})),c.MailPoet.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),c.MailPoet.Modal.loading(!1)}));handleResume=e=>(e.preventDefault(),this.isValid()?this.saveNewsletter().done((()=>{this.setState({loading:!0})})).done((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:this.state.item.id}}).done((()=>{this.redirectToListing("activated"),this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("The newsletter sending has been resumed.","mailpoet")}))})).fail((e=>{this.showError(e)}))})).fail((e=>{this.showError(e)})).always((()=>{this.setState({loading:!1})})):Ee()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done((()=>{this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("Email was updated successfully!","mailpoet")}))})).done((()=>{this.redirectToListing("saved")})).fail((e=>{this.showError(e)}))};redirectToListing=e=>{["automatic","welcome"].includes(this.state.item.type)?window.location.href=`admin.php?page=mailpoet-automation¬ice=${e}`:this.props.history.push(`/${this.state.item.type}`)};handleRedirectToDesign=e=>{e.preventDefault();const t=e.target.href;this.saveNewsletter().done((()=>{this.context.notices.success((0,p.jsx)("p",{children:(0,Le.__)("Email was updated successfully!","mailpoet")}))})).done((()=>{window.location=t})).fail((e=>{this.showError(e)}))};saveNewsletter=()=>{const e=this.state.item;e.queue=void 0,this.setState({loading:!0});const t=Ra().omit(e,["body","created_at","deleted_at","hash","status","updated_at","type"]);return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:t})};showError=e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0,timeout:!1})};handleFormChange=e=>{const t=e.target.name,a=e.target.value;return this.setState((e=>{const i={...e.item},s=i.subject,n=i.ga_campaign;return i[t]=a,"subject"===t&&n===cs(i.id,s)&&(i.ga_campaign=cs(i.id,a)),"reply_to_address"===t&&(i[t]=a.toLowerCase()),{item:i}})),!0};handleSaveDraft=()=>{Ee()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>ii.P||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,Le.__)("Google Analytics tracking is not available in the free version of the MailPoet plugin.","mailpoet")})};disableFilterSegmentToggleIfPremiumInactive=()=>e=>{if(!Array.isArray(e.fields))return e;const t={...e};return t.fields=t.fields.map((e=>"filter-segment-toggle"!==e.name||ii.P?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,Le.__)("Filtering by segment is not available in the free version of the MailPoet plugin.","mailpoet")})}})),t};getPreparedFields=e=>Array.isArray(this.state.fields)?this.state.fields.map(this.disableSegmentsSelectorWhenPaused(e)).map(this.disableGAIfPremiumInactive()).map(this.disableFilterSegmentToggleIfPremiumInactive()):[];closePremiumModal=()=>this.setState({showPremiumModal:!1});toggleLoadingState=e=>this.setState({loading:e});updatePendingApprovalState=e=>this.setState({mssKeyPendingApproval:e});saveDraftNewsletter=async()=>{this.handleSaveDraft(),await this.saveNewsletter()};render(){const{showPremiumModal:e,item:{status:t,queue:a,type:i,options:s,wp_post_id:n},mssKeyPendingApproval:o}=this.state,l="sending"===t&&a&&"paused"===a.status,d=this.getSendButtonOptions(),m=this.getPreparedFields(l),u=!(!window.mailpoet_subscribers_limit_reached&&!o&&void 0===this.state.validationError);let h=i;return h===ai.j9.Automatic&&(h=s.group||h),(0,p.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(Ma,{emailType:h,automationId:"newsletter_send_heading"}),(0,p.jsxs)(r.ErrorBoundary,{children:[this.state.item.campaign_name?(0,p.jsx)("div",{className:"mailpoet-form-grid mailpoet-send-campaign-name",children:(0,p.jsx)("h1",{children:this.state.item.campaign_name})}):null,(0,p.jsx)(oi.Provider,{value:this.state.sendContextValue,children:(0,p.jsxs)(Ct,{id:"mailpoet_newsletter",fields:m,automationId:"newsletter_send_form",item:this.state.item,loading:this.state.loading,onChange:this.handleFormChange,onSubmit:this.handleSave,children:[(0,p.jsxs)(Da.Grid.CenteredRow,{className:"send-newsletter-buttons",children:[(0,p.jsx)(r.Button,{variant:"secondary",type:"submit",automationId:"email-save-draft",onClick:this.handleSaveDraft,isDisabled:this.state.loading,children:(0,Le.__)("Save as draft and close","mailpoet")}),l?(0,p.jsx)(r.Button,{type:"button",onClick:this.handleResume,isDisabled:u||this.state.loading,automationId:"email-resume",children:(0,Le.__)("Resume","mailpoet")}):(0,p.jsx)(r.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:u||this.state.loading,automationId:"email-submit",children:d.value||(0,Le.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,p.jsx)(We.Tooltip,{tooltip:(0,p.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,p.jsxs)("p",{children:[(0,Le.__)("or simply","mailpoet")," ",(0,p.jsx)("a",{className:"mailpoet-link",href:c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&n?`admin.php?page=mailpoet-email-editor&postId=${n}`:`?page=mailpoet-newsletter-editor&id=${this.props.match.params.id}`,onClick:this.handleRedirectToDesign,children:(0,Le.__)("go back to the Design page","mailpoet")}),"."]}),o&&(0,p.jsx)(ls,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,p.jsx)(ii.Z,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})]})]})}}ps.contextType=l.k;const hs=(0,ke.EN)(ps);function gs(e){const[t,a]=(0,o.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:0,children:(0,Le.__)("Congratulations!","mailpoet")}),(0,p.jsx)(wt.X,{level:3,children:(i=e.newsletter,"welcome"===i.type?(0,Le.__)("Your Welcome Email is now active.","mailpoet"):"notification"===i.type?(0,Le.__)("Your Post Notification is now active.","mailpoet"):"automatic"===i.type?(0,Le.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===i.status?(0,Le.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,Le.__)("Your newsletter is being sent!","mailpoet"))}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)("img",{src:e.illustrationImageUrl,alt:"",width:"500"}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)(r.Button,{type:"button",dimension:"small",onClick:()=>{e.successClicked(),a(!0)},withSpinner:t,children:(0,Le.__)("Close","mailpoet")})]});var i}function _s(e){return(0,p.jsxs)("div",{className:"mailpoet-wizard-step",children:[(0,p.jsx)("div",{className:"mailpoet-wizard-step-illustration",children:(0,p.jsx)("img",{src:e.illustrationUrl,width:"500",alt:""})}),(0,p.jsx)("div",{className:"mailpoet-wizard-step-content",children:e.children})]})}function fs(){return(0,p.jsxs)(r.List,{children:[(0,p.jsx)("li",{children:(0,Le.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,p.jsx)("li",{children:(0,Le.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,p.jsx)("li",{children:(0,Le.__)("Maintain your sender reputation and improve engagement levels with automated bounce and complaint handling. Stop sending to non-deliverable and complaining addresses, automatically","mailpoet")}),(0,p.jsx)("li",{children:(0,Le.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function bs(e){const[t,a]=(0,o.useState)(!1),i=()=>{e.onFinish(),a(!0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.Heading,{level:1,children:(s=e.newsletter.type,{standard:(0,Le.__)("Your email has been sent!","mailpoet"),welcome:(0,Le.__)("You are all set up and ready to go!","mailpoet"),notification:(0,Le.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,Le.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,Le.__)("You are all set up and ready to go!","mailpoet"))}),(0,p.jsx)(_s,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,p.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,p.jsx)(r.Heading,{level:4,children:(0,Le.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,p.jsx)("p",{children:e.subscribersCount<1e3?(0,Le._x)("Did you know? Users with 1,000 subscribers or less get the Starter plan for free.","Promotion for our email sending service: Paragraph","mailpoet"):(0,Le._x)("Starting at only $10 per month, MailPoet Business offers the following features","Promotion for our email sending service: Paragraph","mailpoet")}),(0,p.jsxs)(r.Heading,{level:5,children:[(0,Le._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,p.jsx)(fs,{}),(0,p.jsx)("p",{children:f()((0,Le.__)("Please enter your key in [link]the Settings[/link] if you have already purchased it.","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,p.jsx)("a",{href:"admin.php?page=mailpoet-settings#/premium",children:e},t)))}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(r.Button,{isFullWidth:!0,href:e.purchaseUrl,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),window.open(e.purchaseUrl),i()},children:(0,Le._x)("Sign up for free","Promotion for our email sending service: Button","mailpoet")}),(0,p.jsx)(r.Button,{isFullWidth:!0,variant:"tertiary",onClick:i,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),i())},withSpinner:t,children:(0,Le._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function xs(e){return window.has_mss_key_specified?(0,p.jsx)(gs,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,p.jsx)(bs,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function vs(e){const[t,a]=(0,o.useState)(!1);return(0,p.jsxs)("div",{children:[(0,p.jsx)(wt.X,{level:1,children:(0,Le.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,p.jsx)(wt.X,{level:3,children:f()((0,Le.__)("Rest assured, this is fairly common and is usually fixed quickly. [link]See our quick guide[/link] to help you solve this and get your website sending.","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,p.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kb.mailpoet.com/article/231-sending-does-not-work",children:e},t)))}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)("img",{src:window.mailpoet_congratulations_error_image,alt:"",width:"500"}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)(r.Button,{dimension:"small",type:"button",onClick:()=>{e.failClicked(),a(!0)},withSpinner:t,children:(0,Le.__)("Close","mailpoet")})]})}gs.propTypes={successClicked:Re().func.isRequired,illustrationImageUrl:Re().string.isRequired,newsletter:Re().shape({status:Re().string.isRequired,type:Re().string.isRequired}).isRequired},_s.propTypes={illustrationUrl:Re().string.isRequired,children:Re().oneOfType([Re().arrayOf(Re().node),Re().node]).isRequired},xs.propTypes={successClicked:Re().func.isRequired,illustrationImageUrl:Re().string.isRequired,MSSPitchIllustrationUrl:Re().string.isRequired,newsletter:Re().shape({status:Re().string.isRequired,type:Re().string.isRequired}).isRequired,subscribersCount:Re().number.isRequired,purchaseUrl:Re().string.isRequired},vs.propTypes={failClicked:Re().func.isRequired};var js=a(16065);function ys(e){return(0,p.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,p.jsxs)("div",{children:[(0,p.jsx)(wt.X,{level:0,children:(0,Le.__)("Verification","mailpoet")}),(0,p.jsx)(wt.X,{level:3,children:(0,Le.__)("Congrats, you’re sending your first newsletter! We’re doing a quick verification to make sure everything works fine.","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)("div",{className:"mailpoet-gap-large"}),(0,p.jsx)(js.a,{size:64})]})})}ys.propTypes={showRichLoadingScreen:Re().bool.isRequired};const ws=Math.floor(4*Math.random());function Ss(){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:{show_congratulate_after_first_newsletter:!1}}).always((()=>{window.location=window.mailpoet_emails_page}))}class Ps extends o.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:st()(),minimumLoadingTimePassed:!1},this.tick=this.tick.bind(this)}componentDidMount(){this.loadNewsletter(this.props.match.params.id),this.tick()}componentDidUpdate(e){e.match.params.id!==this.props.match.params.id&&this.loadNewsletter(this.props.match.params.id)}tick(){st()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.match.params.id),st()().subtract(6,"seconds").isAfter(this.state.timeStart)&&this.setState({minimumLoadingTimePassed:!0}),!this.state.loading&&this.state.minimumLoadingTimePassed||setTimeout(this.tick,2e3)}loadNewsletter(e){c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:e}}).done((e=>this.newsletterLoaded(e.data)))}newsletterLoaded(e){"standard"!==e.type||"scheduled"===e.status?this.setState({newsletter:e,loading:!1,minimumLoadingTimePassed:!0}):"sent"===e.status||"sending"===e.status?this.setState({newsletter:e,loading:!1,testingPassed:!0}):this.setState({newsletter:e})}renderContent(){return this.state.loading||!this.state.minimumLoadingTimePassed?(e=!this.state.newsletter,(0,p.jsx)(ys,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:Ss,showRichLoadingScreen:e})):this.state.error?(c.MailPoet.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,p.jsx)(vs,{failClicked:()=>{window.location=window.mailpoet_emails_page}})):(t=this.state.newsletter,this.state.testingPassed&&c.MailPoet.trackEvent("Cron testing done",{"Cron is working":"true"}),(0,p.jsx)(xs,{illustrationImageUrl:window.mailpoet_congratulations_success_images[ws],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[ws],successClicked:Ss,newsletter:t,isWoocommerceActive:window.mailpoet_woocommerce_active,subscribersCount:window.mailpoet_subscribers_count,purchaseUrl:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"starter",{utm_medium:"first-newsletter-congratulations",utm_campaign:"purchase"})}));var e,t}render(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("style",{dangerouslySetInnerHTML:{__html:"body { background: #fff; overflow-x: hidden; }"}}),(0,p.jsxs)("div",{className:"mailpoet-congratulate",children:[(0,p.jsx)("div",{className:"mailpoet-gap-large"}),this.renderContent()]})]})}}Ps.propTypes={match:Re().shape({params:Re().shape({id:Re().string}).isRequired}).isRequired},Ps.displayName="Congratulate";class Ms extends o.Component{componentDidMount(){c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,Le.__)("Subject","mailpoet")}}).done((e=>{window.location.search.includes("loadedvia=woo_multichannel_dashboard")&&window.MailPoet.trackEvent("MailPoet - WooCommerce Multichannel Marketing dashboard > Newsletter template selection page",{"WooCommerce version":window.mailpoet_woocommerce_version}),this.showTemplateSelection(e.data.id)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}showTemplateSelection=e=>{this.props.history.push(`/template/${e}`)};render(){return(0,p.jsx)("div",{children:(0,p.jsx)(Ma,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}Ms.contextType=l.k,Ms.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired},Ms.displayName="NewsletterStandard";const Ns=(0,ke.EN)(Ms),Cs={name:"options",type:"reactComponent",component:Ai};class Is extends o.Component{constructor(e){super(e),this.state={options:{intervalType:"daily",timeOfDay:0,weekDay:1,monthDay:0,nthWeekDay:1}}}componentDidMount(){window.location.search.includes("loadedvia=woo_multichannel_dashboard")&&window.MailPoet.trackEvent("MailPoet - WooCommerce Multichannel Marketing dashboard > Create post notification page",{"WooCommerce version":window.mailpoet_woocommerce_version})}handleValueChange=e=>{const t=this.state;t[e.target.name]=e.target.value,this.setState(t)};handleNext=()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:ut.default.extend({},this.state,{type:"notification",subject:(0,Le.__)("The last [newsletter:total] posts from our blog","mailpoet")})}).done((e=>{this.showTemplateSelection(e.data.id)})).fail((e=>{e.errors.length>0&&this.context.notices.error(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))};showTemplateSelection=e=>{this.props.history.push(`/template/${e}`)};render(){return(0,p.jsxs)("div",{children:[(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(Ma,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,p.jsxs)(Da.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,p.jsx)(wt.X,{level:4,children:(0,Le.__)("When to send this post notification email?","mailpoet")}),(0,p.jsx)(Ai,{item:this.state,field:Cs,onValueChange:this.handleValueChange}),(0,p.jsx)(qe.z,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,Le.__)("Next","mailpoet")})]})]})}}Is.contextType=l.k,Is.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired},Is.displayName="NewsletterNotification";const ks=(0,ke.EN)(Is);function Ts(){let e="";c.MailPoet.deactivateSubscriberAfterInactiveDays&&(e=(Math.floor(Number(c.MailPoet.deactivateSubscriberAfterInactiveDays)/30)-1).toString());const[t,a]=(0,o.useState)({afterTimeNumber:e,afterTimeType:"months"}),[i,s]=(0,o.useState)([]),[n,r]=(0,o.useState)(!1),l=(0,ke.k6)();return(0,p.jsxs)("div",{children:[(0,p.jsx)(nt.A,{color:"#fff"}),i&&(0,p.jsx)(fa,{errors:i}),(0,p.jsx)(Ma,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,p.jsxs)(Da.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,p.jsx)(ts,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(c.MailPoet.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,es.compose)([a,(0,es.assoc)("afterTimeNumber",es.__,t)]),updateAfterTimeType:(0,es.compose)([a,(0,es.assoc)("afterTimeType",es.__,t)])}),(0,p.jsx)(qe.z,{isFullWidth:!0,onClick:()=>(s([]),r(!0),void c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletters",action:"create",data:{type:"re_engagement",subject:(0,Le.__)("Subject","mailpoet"),options:t}}).done((e=>{var t;t=e.data.id,l.push(`/template/${t}`)})).fail((e=>{r(!1),e.errors&&s(e.errors)}))),type:"button",isDisabled:!t.afterTimeNumber||n,withSpinner:n,children:(0,Le.__)("Next","mailpoet")})]})]})}Ts.displayName="NewsletterTypeReEngagement";var Es=a(5934),As=a(41991),Rs=a(10235);function Fs({newsletter:e}){const[t,a]=(0,o.useState)("paused"===e.queue.status),[i,s]=(0,o.useState)([]),n=async()=>{s([]),await(async()=>{await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"resume",data:{newsletter_id:e.id}}).done((()=>a(!1))).fail((e=>s(e.errors)))})()};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(fa,{errors:i}),t&&(0,p.jsx)(qe.z,{dimension:"small",onClick:e.status===ai.sj.Corrupt?async()=>{(0,r.confirmAlert)({message:(0,Le.__)("There was an issue sending this email before. Please confirm the problems are fixed to proceed.","mailpoet"),onConfirm:n})}:n,children:(0,Le.__)("Resume","mailpoet")}),!t&&(0,p.jsx)(qe.z,{dimension:"small",onClick:async()=>{s([]),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sendingQueue",action:"pause",data:{newsletter_id:e.id}}).done((()=>a(!0))).fail((e=>s(e.errors)))},children:(0,Le.__)("Pause","mailpoet")})]})}function Os({newsletter:e,mailerLog:t}){const a=e.sent_at||e.queue.scheduled_at,i=a?(0,As.default)(a,"yyyy-MM-dd HH:mm:ss",new Date):void 0,s=e.queue&&"scheduled"!==e.queue.status,n="paused"===t.status,o=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ie.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:(0,p.jsx)(Rs.sj,{processed:parseInt(e.queue.count_processed,10),scheduledFor:i,total:parseInt(e.queue.count_total,10),isPaused:n,status:e.status,logs:e.logs})}),"completed"!==e.queue.status&&!n&&(0,p.jsx)(Fs,{newsletter:e})]}),r=(0,p.jsx)(Rs.sj,{scheduledFor:i,isPaused:"scheduled"===e.queue.status&&n,status:e.status,logs:e.logs});return(0,p.jsxs)(p.Fragment,{children:[s&&o,!s&&r]})}Os.displayName="QueueStatus";const Ds=(0,r.withBoundary)(Os);var Ls=a(83665),qs=a(40292);function Bs({newsletter:e,isSent:t,currentTime:a}){let i=t;if(void 0===i&&(i=e.statistics&&e.queue&&"scheduled"!==e.queue.status),!i)return null;const s={link:`/stats/${e.id}`,onClick:Wt.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",Ls.gP)},n=Number(e.total_sent||e.queue.count_processed);let o,l,d,c,m,u=0,h=0,g=null;n>0&&(u=100*e.statistics.clicked/n,h=100*e.statistics.opened/n,g=e.statistics.revenue),void 0!==a?(o=6,l=e.queue.scheduled_at||e.queue.created_at,d=st()(a).diff(st()(l),"hours"),c=d<o,m=!0):(c=!1,m=!1);const _=n>=20&&e.statistics.opened>=5&&!c,f=(t,a)=>((e,t,a,i)=>i<=0||!t.link?e:t.externalLink?(0,p.jsx)("a",{href:t.link,onClick:t.onClick||null,children:e},`stats-${a}`):(0,p.jsx)(Ie.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${a}`))(t,s,`${a}-${e.id}`,n),b=(0,p.jsx)(qs.M,{opened:h,clicked:u,revenues:g&&g.value>0?g.formatted:null,hideBadges:!_,newsletterId:e.id,wrapContentInLink:f}),x=(0,p.jsxs)(p.Fragment,{children:[b,c&&f((0,p.jsx)(r.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,Le.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",o-d)}),"check-back")]});let v;return m&&h<5&&d>=24&&n>=10&&(v=(0,p.jsx)("div",{children:(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/191-how-to-improve-my-open-and-click-rates",target:"_blank",rel:"noopener noreferrer",className:"mailpoet_stat_link_small",children:(0,Le.__)("What can I do to improve this?","mailpoet")})})),(0,p.jsxs)(p.Fragment,{children:[x,v]})}const Ws=Re().shape({clicked:Re().number,opened:Re().number,unsubscribed:Re().number,revenue:Re().shape({count:Re().number,currency:Re().string,formatted:Re().string,value:Re().number})}),$s=Re().shape({status:Re().string,count_processed:Re().string.isRequired,count_total:Re().string.isRequired,created_at:Re().string,scheduled_at:Re().string});Bs.propTypes={newsletter:Re().shape({id:Re().number.isRequired,queue:Re().oneOfType([$s,Re().bool]),total_sent:Re().number,statistics:Re().oneOfType([Ws,Re().bool])}).isRequired,isSent:Re().bool,currentTime:Re().string},Bs.defaultProps={isSent:void 0,currentTime:void 0},Bs.displayName="NewsletterStatistics";const Us=(0,r.withBoundary)(Bs),Vs=c.MailPoet.trackingConfig.emailTrackingEnabled,Hs={onNoItemsFound:(e,t)=>t?(0,Le.__)("No emails found.","mailpoet"):(0,Le.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was moved to the trash.","mailpoet"):(0,Le.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was permanently deleted.","mailpoet"):(0,Le.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email has been restored from the Trash.","mailpoet"):(0,Le.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)}},zs=[{name:c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")?"name":"subject",label:c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")?(0,Le.__)("Name","mailpoet"):(0,Le.__)("Subject","mailpoet"),sortable:!0},{name:"status",label:(0,Le.__)("Status","mailpoet")},{name:"segments",label:(0,Le.__)("Lists","mailpoet")},{name:"statistics",label:(0,Le.__)("Clicked, Opened","mailpoet"),display:Vs},{name:"sent_at",label:(0,Le.__)("Sent on","mailpoet"),sortable:!0}],Zs=[{name:"trash",label:(0,Le.__)("Move to trash","mailpoet"),onSuccess:Hs.onTrash}],Ys=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=`admin.php?page=mailpoet-email-editor&postId=${e.wp_post_id}`),e.queue&&"sending"===e.status&&null===e.queue.status?(0,Ca._)({message:(0,Le.__)("Sending is in progress. Do you want to pause sending and edit the newsletter?","mailpoet"),onConfirm:()=>{window.location.href=`${t}&pauseConfirmed=yes`}}):window.location.href=t};let Gs=[{name:"view",link:function(e){return(0,p.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Edit","mailpoet"),onClick:Ys},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Duplicate","mailpoet"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Le.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];Gs=(0,Ls.y8)(Gs);class Ks extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}renderItem=(e,t,a)=>{const i=ie()("manage-column","column-primary","has-row-actions"),s=e.queue.newsletter_rendered_subject||e.subject;return(0,p.jsxs)("div",{children:[(0,p.jsxs)("td",{className:i,children:[(0,p.jsx)("a",{className:"mailpoet-listing-title",href:"#",onClick:t=>{t.preventDefault(),Ys(e)},children:e.campaign_name?(0,p.jsxs)(p.Fragment,{children:[e.campaign_name," ",(0,p.jsx)("br",{}),(0,p.jsx)("span",{className:"mailpoet-listing-subtitle",children:s})]}):s}),t]}),(0,p.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Le.__)("Status","mailpoet"),children:(0,p.jsx)(Ds,{newsletter:e,mailerLog:a.mta_log})}),(0,p.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Lists","mailpoet"),children:(0,p.jsxs)(r.ErrorBoundary,{children:[(0,p.jsx)(Es.Eg,{segments:e.segments,dimension:"large"}),(0,p.jsx)(Es.$6,{newsletter:e,dimension:"large"})]})}),!0===Vs?(0,p.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Le.__)("Clicked, Opened","mailpoet"),children:(0,p.jsx)(Us,{newsletter:e,currentTime:a.current_time})}):null,(0,p.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Sent on","mailpoet"),children:e.sent_at?(0,p.jsxs)(p.Fragment,{children:[c.MailPoet.Date.short(e.sent_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.sent_at)]}):null})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,p.jsxs)(p.Fragment,{children:[0===this.state.newslettersCount&&(0,p.jsx)(wa,{filter:e=>"standard"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"standard",base_url:"standard",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:zs,bulk_actions:Zs,item_actions:Gs,messages:Hs,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce(((e,t)=>e+t.count),0);this.setState({newslettersCount:t})}(0,Ls._X)(e),(0,Ls.bF)(e)}})]})}}Ks.contextType=l.k,Ks.propTypes={location:Re().object.isRequired,match:Re().shape({params:Re().object}).isRequired},Ks.displayName="NewsletterListStandard";const Qs=(0,ke.EN)((0,r.withBoundary)(Ks));var Js=a(45959);const Xs={onNoItemsFound:(e,t)=>t?(0,Le.__)("No emails found.","mailpoet"):(0,Le.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was moved to the trash.","mailpoet"):(0,Le.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was permanently deleted.","mailpoet"):(0,Le.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email has been restored from the Trash.","mailpoet"):(0,Le.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)}},en=[{name:"subject",label:(0,Le.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Le.__)("Settings","mailpoet")},{name:"history",label:(0,Le.__)("History","mailpoet"),width:100},{name:"status",label:(0,Le.__)("Status","mailpoet"),width:100},{name:"updated_at",label:(0,Le.__)("Last modified on","mailpoet"),sortable:!0}],tn=[{name:"trash",label:(0,Le.__)("Move to trash","mailpoet"),onSuccess:Xs.onTrash}],an=[{name:"view",link:function(e){return(0,p.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Edit","mailpoet"),onClick:Ls.Q2},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Duplicate","mailpoet"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Le.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class sn extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"active":"draft"}}).done((e=>{"active"===e.data.status&&c.MailPoet.Notice.success((0,Le.__)("Your post notification is now active!","mailpoet")),this.forceUpdate()})).fail((a=>{c.MailPoet.Notice.showApiErrorNotice(a),t.target.checked=!e}))};renderStatus=e=>(0,p.jsx)(ti.Z,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status});renderSettings=e=>{let t;if(0===e.segments.length)return(0,p.jsx)(Ie.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Le.__)("You need to select a list to send to.","mailpoet")});const a=f()((0,Le.__)("Send to %1$s","mailpoet"),"%1$s",((t,a)=>(0,p.jsxs)(o.Fragment,{children:[(0,p.jsx)(Es.Eg,{segments:e.segments},`segment-${a}`),(0,p.jsx)(Es.$6,{newsletter:e},`filter-segment-${a}`)]},a)));switch(e.options.intervalType){case"daily":t=(0,Le.__)("Daily at %1$s","mailpoet").replace("%1$s",Si[e.options.timeOfDay]);break;case"weekly":t=(0,Le.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",Pi[e.options.weekDay]).replace("%2$s",Si[e.options.timeOfDay]);break;case"monthly":t=(0,Le.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",Mi[e.options.monthDay]).replace("%2$s",Si[e.options.timeOfDay]);break;case"nthWeekDay":t=(0,Le.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",Ni[e.options.nthWeekDay]).replace("%2$s",Pi[e.options.weekDay]).replace("%3$s",Si[e.options.timeOfDay]);break;case"immediately":t=(0,Le.__)("Immediately","mailpoet");break;default:t="Invalid sending frequency"}return(0,p.jsxs)("span",{children:[a,(0,p.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,p.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,p.jsx)(Js.P,{})}),t]})]})};renderHistoryLink=e=>0===Number(e.children_count)?(0,p.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,Le.__)("Not sent yet","mailpoet")}):(0,p.jsxs)(Ie.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:[(0,p.jsx)(qe.z,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,Le.__)("View history","mailpoet")}),(0,p.jsx)(qe.z,{className:"mailpoet-show-on-mobile mailpoet-listing-notification-status",dimension:"small",variant:"secondary",children:(0,Le.__)("View history","mailpoet")})]});renderItem=(e,t)=>{const a=ie()("manage-column","column-primary","has-row-actions");return(0,p.jsxs)("div",{children:[(0,p.jsxs)("td",{className:a,children:[(0,p.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,Ls.Q2)(e)},children:e.subject}),t]}),(0,p.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Settings","mailpoet"),children:this.renderSettings(e)}),(0,p.jsx)("td",{className:"column","data-colname":(0,Le.__)("History","mailpoet"),children:this.renderHistoryLink(e)}),(0,p.jsx)("td",{className:"column","data-colname":(0,Le.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,p.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,p.jsxs)(p.Fragment,{children:[0===this.state.newslettersCount&&(0,p.jsx)(wa,{filter:e=>"notification"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"notification",base_url:"notification",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:en,bulk_actions:tn,item_actions:an,messages:Xs,auto_refresh:!0,sort_by:"updated_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce(((e,t)=>e+t.count),0);this.setState({newslettersCount:t})}(0,Ls._X)(e),(0,Ls.bF)(e)}})]})}}sn.propTypes={location:Re().object.isRequired,match:Re().shape({params:Re().object}).isRequired},sn.displayName="NewsletterListNotification";const nn=(0,ke.EN)((0,r.withBoundary)(sn)),on=c.MailPoet.trackingConfig.emailTrackingEnabled,rn={onNoItemsFound:(e,t)=>t?(0,Le.__)("No emails found.","mailpoet"):(0,Le.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was moved to the trash.","mailpoet"):(0,Le.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was permanently deleted.","mailpoet"):(0,Le.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email has been restored from the Trash.","mailpoet"):(0,Le.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)}},ln=[{name:"subject",label:(0,Le.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Le.__)("Settings","mailpoet")},{name:"statistics",label:(0,Le.__)("Clicked, Opened","mailpoet"),display:on},{name:"status",label:(0,Le.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,Le.__)("Last modified on","mailpoet"),sortable:!0}],dn=[{name:"trash",label:(0,Le.__)("Move to trash","mailpoet"),onSuccess:rn.onTrash}];let cn=[{name:"view",link:function(e){return(0,p.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Duplicate","mailpoet"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success((0,Le.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",e.data.subject)),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Le.__)("Edit","mailpoet"),onClick:Ls.Q2},{name:"trash",className:"mailpoet-hide-on-mobile"}];cn=(0,Ls.y8)(cn);class mn extends o.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"active":"draft"}}).done((e=>{"active"===e.data.status&&c.MailPoet.Notice.success((0,Le.__)("Your Re-engagement Email is now activated!","mailpoet")),this.forceUpdate()})).fail((a=>{c.MailPoet.Notice.showApiErrorNotice(a),t.target.checked=!e}))};renderStatus=e=>{const t=(0,Le._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString());return(0,p.jsxs)("div",{children:[(0,p.jsx)(ti.Z,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,p.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,p.jsx)(Ie.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})})]})};renderSettings=e=>{if(0===e.segments.length)return(0,p.jsx)(Ie.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Le.__)("You need to select a list to send to.","mailpoet")});const t=f()((0,Le.__)("Send to %1$s","mailpoet"),"%1$s",((t,a)=>(0,p.jsxs)(o.Fragment,{children:[(0,p.jsx)(Es.Eg,{segments:e.segments},`segment-${a}`),(0,p.jsx)(Es.$6,{newsletter:e},`filter-segment-${a}`)]},a)));let a=(0,Le._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet");e.options.afterTimeNumber>1&&"months"===e.options.afterTimeType?a=(0,Le._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):e.options.afterTimeNumber>1&&"weeks"===e.options.afterTimeType?a=(0,Le._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"):1===e.options.afterTimeNumber&&"weeks"===e.options.afterTimeType&&(a=(0,Le._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet"));const i=(0,Le._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",e.options.afterTimeNumber).replace("{$frequency}",a);return(0,p.jsxs)("span",{children:[t,(0,p.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,p.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,p.jsx)(Js.P,{})}),i]})]})};renderItem=(e,t)=>{const a=ie()("manage-column","column-primary","has-row-actions");return(0,p.jsxs)("div",{children:[(0,p.jsxs)("td",{className:a,children:[(0,p.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,Ls.Q2)(e)},children:e.subject}),t]}),(0,p.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===on?(0,p.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Le.__)("Clicked, Opened","mailpoet"),children:(0,p.jsx)(Us,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,p.jsx)("td",{className:"column","data-colname":(0,Le.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,p.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Last modified on","mailpoet"),children:[c.MailPoet.Date.short(e.updated_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,p.jsxs)(p.Fragment,{children:[0===this.state.newslettersCount&&(0,p.jsx)(wa,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,endpoint:"newsletters",type:"re_engagement",base_url:"re_engagement",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:ln,bulk_actions:dn,item_actions:cn,messages:rn,auto_refresh:!0,sort_by:"updated_at",sort_order:"desc",afterGetItems:e=>{if(!e.loading){const t=e.groups.reduce(((e,t)=>e+t.count),0);this.setState({newslettersCount:t})}(0,Ls._X)(e),(0,Ls.bF)(e)}})]})}}mn.propTypes={location:Re().object.isRequired,match:Re().shape({params:Re().object}).isRequired},mn.displayName="NewsletterListReEngagement";const un=(0,ke.EN)((0,r.withBoundary)(mn)),pn=c.MailPoet.trackingConfig.emailTrackingEnabled,hn=[{name:"subject",label:(0,Le.__)("Subject","mailpoet")},{name:"status",label:(0,Le.__)("Status","mailpoet")},{name:"segments",label:(0,Le.__)("Lists","mailpoet")},{name:"statistics",label:(0,Le.__)("Clicked, Opened","mailpoet"),display:pn},{name:"sent_at",label:(0,Le.__)("Sent on","mailpoet"),sortable:!0}],gn={onNoItemsFound:(e,t)=>t?(0,Le.__)("No emails found.","mailpoet"):(0,Le.__)("Nothing here yet! But, don't fret - there's no reason to get upset. Pretty soon, you’ll be sending emails faster than a turbo-jet.","mailpoet"),onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was moved to the trash.","mailpoet"):(0,Le.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email was permanently deleted.","mailpoet"):(0,Le.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Le.__)("1 email has been restored from the Trash.","mailpoet"):(0,Le.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)}},_n=[{name:"trash",label:(0,Le.__)("Move to trash","mailpoet"),onSuccess:gn.onTrash}],fn=(0,Ls.y8)([{name:"view",link:function(e){return(0,p.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Preview","mailpoet")})}},{name:"trash",className:"mailpoet-hide-on-mobile"}]),bn=(e,t,a)=>{const i=ie()("manage-column","column-primary","has-row-actions");return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("td",{className:i,children:[(0,p.jsx)("strong",{children:(0,p.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:e.queue.newsletter_rendered_subject||e.subject})}),t]}),(0,p.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Le.__)("Status","mailpoet"),children:(0,p.jsx)(Ds,{newsletter:e,mailerLog:a.mta_log})}),(0,p.jsxs)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Lists","mailpoet"),children:[(0,p.jsx)(Es.Eg,{segments:e.segments,dimension:"large"}),(0,p.jsx)(Es.$6,{newsletter:e,dimension:"large"})]}),!0===pn?(0,p.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Le.__)("Clicked, Opened","mailpoet"),children:(0,p.jsx)(Us,{newsletter:e,currentTime:a.current_time})}):null,(0,p.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Le.__)("Sent on","mailpoet"),children:e.sent_at?(0,p.jsxs)(p.Fragment,{children:[c.MailPoet.Date.short(e.sent_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.sent_at)]}):null})]})};function xn(e){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ie.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,Le.__)("Back to Post notifications","mailpoet")}),(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:e.location,params:{...e.match.params,parentId:e.parentId},endpoint:"newsletters",type:"notification_history",base_url:"notification/history/:parentId",onRenderItem:bn,columns:hn,messages:gn,item_actions:fn,bulk_actions:_n,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{(0,Ls._X)(e),(0,Ls.bF)(e)}})]})}xn.propTypes={parentId:Re().string.isRequired,location:Re().shape({pathname:Re().string}).isRequired,match:Re().shape({params:Re().shape({id:Re().node}).isRequired}).isRequired},xn.displayName="NewsletterListNotificationHistory";const vn=(0,ke.EN)((0,r.withBoundary)(xn)),jn=[{name:"subscriber_id",label:(0,Le.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,Le._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet")},{name:"failureReason",label:(0,Le.__)("Failure reason (if applicable)","mailpoet")}],yn={onNoItemsFound:()=>(0,Le.__)("No sending task found.","mailpoet")};function wn(e){const[t,a]=(0,o.useState)({id:e.match.params.id,subject:"",sent:!1});return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:t.id}}).done((e=>a({id:t.id,subject:e.data.subject,sent:null!==e.data.sent_at}))).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))}),[t.id]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h1",{children:(0,Le._x)("Sending status","Page title. This page displays a list of emails along with their sending status: unprocessed, sent or failed.","mailpoet")}),(0,p.jsx)(Nn,{newsletter:t}),(0,p.jsx)(Mn,{location:e.location,params:e.match.params})]})}wn.propTypes={location:Re().shape({pathname:Re().string}).isRequired,match:Re().shape({params:Re().shape({id:Re().string.isRequired}).isRequired}).isRequired},wn.displayName="SendingStatus";const Sn=(e,t)=>e.location.pathname===t.location.pathname&&e.params.id===t.params.id,Pn=e=>(0,p.jsx)("div",{children:(0,p.jsx)(Cn,{...e})}),Mn=(0,o.memo)((({location:e,params:t})=>(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"sending_task_subscribers",base_url:"sending-status/:id",onRenderItem:Pn,getListingItemKey:e=>`${e.taskId}-${e.subscriberId}`,columns:jn,messages:yn,auto_refresh:!0,sort_by:"failed",sort_order:"desc",afterGetItems:e=>{(0,Ls._X)(e),(0,Ls.bF)(e)}})),Sn);function Nn({newsletter:e}){return e.id&&e.subject&&e.sent?(0,p.jsx)("p",{children:(0,p.jsx)(Ie.Link,{to:`/stats/${e.id}`,children:e.subject})}):null}function Cn({error:e,failed:t,taskId:a,processed:i,email:s,subscriberId:n,lastName:o,firstName:r}){const l=ie()("manage-column","column-primary","has-row-actions");let d=(0,Le._x)("Unprocessed","status when the sending of a newsletter has not been processed","mailpoet");return i&&(d=t?(0,p.jsxs)("span",{children:[(0,Le._x)("Failed","status when the sending of a newsletter has failed","mailpoet"),(0,p.jsx)("br",{}),(0,p.jsx)("a",{className:"button",href:"#",onClick:e=>{e.preventDefault(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sending_task_subscribers",action:"resend",data:{taskId:a,subscriberId:n}}).done((()=>window.mailpoet_listing.forceUpdate())).fail((e=>c.MailPoet.Notice.showApiErrorNotice(e)))},children:(0,Le.__)("Resend","mailpoet")})]}):(0,Le._x)("Sent","status when a newsletter has been sent","mailpoet")),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("td",{"data-automation-id":`name_${a}_${n}`,className:l,children:[(0,p.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${n}`,children:s}),(0,p.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${r} ${o}`})]}),(0,p.jsx)("td",{className:"column","data-automation-id":`status_${a}_${n}`,"data-colname":(0,Le._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet"),children:d}),(0,p.jsx)("td",{className:"column","data-automation-id":`error_${a}_${n}`,"data-colname":(0,Le.__)("Failure reason (if applicable)","mailpoet"),children:e})]})}Mn.propTypes={location:Re().shape({pathname:Re().string}).isRequired,params:Re().shape({id:Re().string.isRequired}).isRequired},Nn.propTypes={newsletter:Re().shape({id:Re().string,subject:Re().string,sent:Re().bool})},Nn.defaultProps={newsletter:{id:null,subject:null,sent:!1}},Cn.propTypes={error:Re().string,email:Re().string.isRequired,failed:Re().number.isRequired,taskId:Re().number.isRequired,lastName:Re().string.isRequired,firstName:Re().string.isRequired,processed:Re().number.isRequired,subscriberId:Re().number.isRequired},Cn.defaultProps={error:""},Cn.displayName="ListingItem",wn.displayName="SendingStatus";var In=a(23584),kn=a(52249),Tn=a(23064),En=a.n(Tn);function An(e){const t=e.installedDaysAgo,a=t>30?c.MailPoet.I18n.t("reviewRequestUsingForMonths").replace("[months]",Math.round(t/30)):c.MailPoet.I18n.t("reviewRequestUsingForDays").replace("[days]",t);return(0,p.jsxs)("div",{className:"mailpoet_review_request",children:[(0,p.jsx)("img",{src:e.reviewRequestIllustrationUrl,height:"280",width:"280",alt:""}),(0,p.jsx)("h2",{children:c.MailPoet.I18n.t("reviewRequestHeading")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("reviewRequestDidYouKnow").replace("[username]",e.username)}),(0,p.jsx)("p",{children:a}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{href:"http://bit.ly/2Bi124o",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:c.MailPoet.I18n.t("reviewRequestRateUsNow")})}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{id:"mailpoet_review_request_not_now",children:c.MailPoet.I18n.t("reviewRequestNotNow")})})]})}An.propTypes={installedDaysAgo:Re().number.isRequired,reviewRequestIllustrationUrl:Re().string.isRequired,username:Re().string.isRequired};const Rn=()=>((0,o.useLayoutEffect)((()=>{window.mailpoet_display_nps_poll&&c.MailPoet.libs3rdPartyEnabled&&(ns||(ns=c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),ns).then((({data:e})=>(e=>{let t;t=window.mailpoet_display_nps_email_editor?"9qCj2SJBE1s5OhnX5NYfRXu82pEDUB9x":window.mailpoet_display_nps_form?"EqOgKsgZd832Sz9w":window.mailpoet_is_new_user?"6L479eVPXk7pBn6S":"k0aJAsQAWI2ERyGv",En()({writeKey:t,userId:window.mailpoet_current_wp_user.ID+window.mailpoet_site_url,traits:{name:window.mailpoet_current_wp_user.user_nicename,email:window.mailpoet_current_wp_user.user_email,mailpoetVersion:window.mailpoet_version,mailpoetPremiumIsActive:window.mailpoet_premium_active,createdAt:e.installedAtIso,newslettersSent:e.newslettersSent,welcomeEmails:e.welcomeEmails,postnotificationEmails:e.postnotificationEmails,woocommerceEmails:e.woocommerceEmails,subscribers:e.subscribers,lists:e.lists,sendingMethod:e.sendingMethod,woocommerceIsInstalled:e.woocommerceIsInstalled},events:{submit:e=>{e.rating>=9&&e.completed&&c.MailPoet.Modal.popup({width:800,template:kn.renderToString(An({username:window.mailpoet_current_wp_user_firstname||window.mailpoet_current_wp_user.user_login,reviewRequestIllustrationUrl:window.mailpoet_review_request_illustration_url,installedDaysAgo:window.mailpoet_installed_days_ago})),onInit:()=>{document.getElementById("mailpoet_review_request_not_now").addEventListener("click",(()=>c.MailPoet.Modal.close()))}})}}})})(e)))}),[]),null),Fn=e=>function(t){return Rn(),(0,p.jsx)(e,{...t})};function On(){return(0,p.jsx)(d.Q,{children:(0,p.jsxs)(Ie.Link,{id:"mailpoet-new-email",className:"mailpoet-button button-secondary",to:"/new",onClick:()=>c.MailPoet.trackEvent("Emails > Add New"),"data-automation-id":"new_email",children:[He.R,(0,p.jsx)("span",{children:(0,Le.__)("New email","mailpoet")})]})})}function Dn({children:e,location:t}){return null!==(0,Pa.X)(t)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(t)?null:e}Dn.propTypes={location:Re().string.isRequired,children:Re().node.isRequired};const Ln=(0,ke.EN)(Dn);function qn(){return(0,p.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}var Bn=a(23535),Wn=a(59355),$n=a(99983);const Un=20,Vn=5,Hn=5,zn=5,Zn=100,Yn=e=>{const t=e<.1?2:1;return c.MailPoet.Num.toLocaleFixed(e,t)},Gn=e=>+(+e).toFixed(1);function Kn({newsletter:e,isWoocommerceActive:t}){const a=e.total_sent||0;let i=0,s=0,n=0,o=0,r=0;a>0&&(i=100*e.statistics.clicked/a,s=100*e.statistics.opened/a,n=100*e.statistics.machineOpened/a,o=100*e.statistics.unsubscribed/a,r=100*e.statistics.bounced/a);const l=Yn(i),d=Yn(s),c=Yn(n),m=Yn(o),u=Yn(r),h=a>=Un&&e.statistics.opened>=Vn,g=e.statistics.unsubscribed>=Hn&&a>=Zn,_=e.statistics.bounced>=zn&&a>=Zn,b=(0,$n.y)("opened",s)||"",x=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,p.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${b}`,children:[d,"% "]}),(0,Le._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),h&&(0,p.jsx)($n.$,{isInverted:!1,stat:"opened",rate:s,tooltipId:`opened-${e.id||"0"}`,tooltipPlace:"right"})]}),v=(0,p.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,p.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[c,"% "]}),(0,Le._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,p.jsx)(We.Tooltip,{tooltip:f()((0,Le.__)("A machine-opened email is an email opened by a computer in the background without the user’s explicit request or knowledge. [link]Read more[/link]","mailpoet"),/\[link](.*?)\[\/link]/,(e=>(0,p.jsx)("span",{style:{pointerEvents:"all"},children:(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/368-what-are-machine-opens",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")},"machine-opened-tooltip")))})]}),j=Gn(o),y=g?(0,$n.y)("unsubscribed",j):"",w=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,p.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${y}`,children:[m,"% "]}),(0,Le._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),g&&(0,p.jsx)($n.$,{isInverted:!1,stat:"unsubscribed",rate:j,tooltipId:`unsubscribed-${e.id||"0"}`,tooltipPlace:"right"})]}),S=Gn(r),P=_?(0,$n.y)("bounced",S):"",M=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,p.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${P}`,children:[u,"% "]}),(0,Le._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),_&&(0,p.jsx)($n.$,{isInverted:!1,stat:"bounced",rate:S,tooltipId:`bounced-${e.id||"0"}`,tooltipPlace:"right"})]}),N=(0,$n.y)("clicked",i),C=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-statistics-value",children:[(0,p.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${N}`,children:[l,"% "]}),(0,Le._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),h&&(0,p.jsx)($n.$,{isInverted:!1,stat:"clicked",rate:i,tooltipId:`clicked-${e.id||"0"}`,tooltipPlace:"right"})]});return(0,p.jsxs)("div",{className:"mailpoet-stats-general",children:[(0,p.jsxs)(Da.Grid.ThreeColumns,{className:"mailpoet-stats-general-top-row",children:[(0,p.jsx)("div",{children:(0,p.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,Le.__)("Sent to","mailpoet"),": ",(0,p.jsx)("span",{className:"mailpoet-statistics-value-number",children:a.toLocaleString()})]})}),(0,p.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:w}),(0,p.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:M})]}),(0,p.jsxs)(Da.Grid.ThreeColumns,{children:[(0,p.jsx)("div",{children:C}),(0,p.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[x,v]}),t&&(0,p.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:Wt.Hooks.applyFilters("mailpoet_newsletters_revenues_stats",null,e.statistics.revenue)}),!t&&(0,p.jsx)("div",{})]}),(0,p.jsxs)("div",{className:"mailpoet-stats-general-read-more",children:[(0,p.jsx)("p",{className:"mailpoet-stats-has-margin-left",children:(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/190-whats-a-good-email-open-rate",target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Read more on stats.","mailpoet")})}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{href:`admin.php?page=mailpoet-newsletters#/sending-status/${e.id}`,children:(0,Le.__)("Sending status","mailpoet")})})]})]})}Kn.displayName="NewsletterGeneralStats";var Qn=a(71608);const Jn=ca.Z,Xn=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;return c.MailPoet.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=`admin.php?page=mailpoet-email-editor&postId=${e.wp_post_id}`),t},eo=e=>{const t=Xn(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,r.confirmAlert)({message:(0,Le.__)("Sending is in progress. Do you want to pause sending and edit the newsletter?","mailpoet"),onConfirm:()=>{window.location.href=`${t}&pauseConfirmed=yes`}}):window.location.href=t},to=(e,t=(()=>{}))=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((t=>{const a=Xn(t.data);c.MailPoet.Notice.success((0,Le.sprintf)((0,Le.__)('Email "%s" has been duplicated. New email: <a href="%s"> %s </a>',"mailpoet"),e.subject,a,t.data.subject),{static:!0})})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})).always((()=>{t()}))},ao=(e,t=(()=>{}))=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"trash",data:{id:e.id}}).done((()=>{c.MailPoet.Notice.success((0,Le.__)("1 email was moved to the trash.","mailpoet")),window.location.href="?page=mailpoet-newsletters"})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})).always((()=>{t()}))};function io({newsletter:e}){const[t,a]=(0,o.useState)(!1),i=e?.queue?.scheduled_at||e?.queue?.created_at||e?.created_at;return(0,p.jsxs)(Da.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,p.jsxs)("div",{children:[(0,p.jsxs)(wt.X,{level:1,children:[e.campaign_name?e.campaign_name:e.subject,e.campaign_name&&(0,p.jsx)("span",{children:` (${e.subject})`})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)(r.Tag,{isInverted:!1,children:(0,r.getNewsletterStatusString)(e.status)})," ",(0,p.jsxs)("b",{children:[c.MailPoet.Date.short(i)," • ",c.MailPoet.Date.time(i)]})]}),Array.isArray(e.segments)&&e.segments.length&&(0,p.jsxs)("div",{children:[(0,p.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,Le.__)("To","mailpoet")}),": ",(0,p.jsx)(r.SegmentTags,{dimension:"large",segments:e.segments}),(0,p.jsx)(r.FilterSegmentTag,{newsletter:e,dimension:"large"})]})]}),(0,p.jsx)("div",{className:"mailpoet-stats-info-sender-preview",children:(0,p.jsxs)("div",{children:[(0,p.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,p.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Le.__)("From","mailpoet"),": "]}),e.sender_address?e.sender_address:"-"]}),(0,p.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,p.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Le.__)("Reply-to","mailpoet"),": "]}),e.reply_to_address?e.reply_to_address:"-"]}),(0,p.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,p.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Le.__)("GA campaign","mailpoet"),": "]}),e.ga_campaign?e.ga_campaign:"-"]})]})}),(0,p.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,p.jsxs)(ma.Z,{children:[(0,p.jsx)(ge.ZP,{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,Le.__)("Preview","mailpoet")}),(0,p.jsx)(ua.Z,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:a})=>(0,p.jsxs)(ma.Z,{children:[(0,p.jsx)(ge.ZP,{disabled:"standard"!==e.type,onClick:()=>{eo(e)},variant:"primary",children:(0,Le.__)("Edit","mailpoet")}),(0,p.jsxs)(ge.ZP,{onClick:a,"aria-expanded":t,variant:"primary",children:[" ",(0,p.jsx)(pa.Z,{icon:ha.Z,size:18})]})]}),renderContent:()=>(0,p.jsxs)(Qn.Z,{children:[(0,p.jsx)(Jn,{isBusy:t,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==e.type,onClick:()=>{a(!0),to(e,(()=>{a(!1)}))},children:(0,Le.__)("Duplicate","mailpoet")}),(0,p.jsx)(Jn,{isBusy:t,isDestructive:!0,onClick:()=>{a(!0),ao(e,(()=>{a(!1)}))},children:(0,Le.__)("Move to Trash","mailpoet")})]})})]})})]})}function so(){const e=(0,p.jsx)(qe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,"starter",{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,Le.__)("Upgrade","mailpoet")}),t=(0,p.jsxs)("p",{children:[(0,Le.__)("Learn more about your subscribers and optimize your campaigns. See who opened your emails, which links they clicked, and then use the data to make your emails even better. And if you run a WooCommerce store, you’ll also see the revenue earned per email.","mailpoet")," ",(0,p.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",children:(0,Le.__)("Learn more","mailpoet")}),"."]});return(0,p.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,p.jsx)(aa,{message:t,actionButton:e,capabilities:{detailedAnalytics:!0}})})}function no(){return window.mailpoet_display_detailed_stats?null:(0,p.jsx)(so,{})}io.displayName="NewsletterStatsInfo",no.displayName="PremiumBanner";const oo=(0,r.withBoundary)(no);function ro({match:e,history:t,location:a}){const[i,s]=(0,o.useState)({item:void 0,loading:!0}),n=(0,o.useCallback)((e=>{s({loading:!0,item:i.item}),c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:window.mailpoet_display_detailed_stats?"stats":"newsletters",action:window.mailpoet_display_detailed_stats?"get":"getWithStats",data:{id:e,accept:"all"}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>{s({loading:!1,item:e.data})})).fail((e=>{c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0}),s({loading:!1}),t.push("/")}))}),[t,i.item]);(0,o.useEffect)((()=>{window.scrollTo(0,0),i.item?.id!==e.params.id&&n(e.params.id)}),[e.params.id,n,i.item]);const{item:l,loading:m}=i,u=l;return m?null:u?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(It.B,{}),(0,p.jsx)(qn,{}),(0,p.jsx)(d.Q,{}),(0,p.jsxs)("div",{className:"mailpoet-stats-page",children:[(0,p.jsx)(w,{}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(io,{newsletter:u})}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Kn,{newsletter:u,isWoocommerceActive:c.MailPoet.isWoocommerceActive})}),(0,p.jsxs)(Bn.m,{activeKey:"clicked",children:[(0,p.jsx)(Wn.O,{title:(0,Le.__)("Clicked Links","mailpoet"),children:Wt.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,p.jsx)(oo,{}),u.clicked_links)},"clicked"),c.MailPoet.isWoocommerceActive&&(0,p.jsx)(Wn.O,{title:(0,Le.__)("Products Sold","mailpoet"),automationId:"products-sold-tab",children:Wt.Hooks.applyFilters("mailpoet_newsletters_purchased_products",(0,p.jsx)(oo,{}),u)},"products"),(0,p.jsx)(Wn.O,{title:(0,Le.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:Wt.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,p.jsx)(oo,{}),a,e.params,u)},"engagement"),(0,p.jsx)(Wn.O,{title:(0,Le._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:Wt.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,p.jsx)(oo,{}),a,e.params)},"bounces")]})]})]}):(0,p.jsxs)("h3",{children:[" ",(0,Le.__)("This email does not exist.","mailpoet")," "]})}ro.displayName="CampaignStatsPage";const lo=(0,ke.EN)(ro);function co({newsletters:e}){return(0,p.jsxs)(u.q,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,p.jsx)("h3",{children:(0,Le.__)("Paused emails","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("There was problem sending the following email(s), please fix the issues described for each email and resume.","mailpoet")}),(0,p.jsx)("ul",{children:e.map((({id:e,subject:t})=>(0,p.jsx)("li",{children:t},e)))})]})}co.displayName="CorruptEmailNotice";var mo=a(98097),uo=a(689);function po(){const e=(0,o.useCallback)((()=>{(0,uo.E)({endpoint:"UserFlags",method:"set","data[legacy_automatic_emails_notice_dismissed]":"1"})}),[]);return(0,p.jsx)(u.q,{type:"info",timeout:!1,closable:!0,renderInPlace:!0,onClose:e,children:(0,p.jsx)("p",{children:(0,mo.Z)((0,Le.__)("We moved your existing Welcome and WooCommerce emails to Automations. Rest assured, all your automations are still actively running. <link>View automations</link>","mailpoet"),{link:(0,p.jsx)("a",{href:"admin.php?page=mailpoet-automation"})})})})}const ho=Fn((()=>{const{parentId:e}=(0,ke.UO)();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ln,{children:(0,p.jsx)(On,{})}),window.mailpoet_legacy_automatic_emails_count>0&&!window.mailpoet_legacy_automatic_emails_notice_dismissed&&(0,p.jsx)(po,{}),c.MailPoet.corrupt_newsletters.length>0&&(0,p.jsx)(co,{newsletters:c.MailPoet.corrupt_newsletters}),(0,p.jsxs)(In.t,{activeKey:"standard",routerType:"switch-only",onSwitch:e=>(e=>c.MailPoet.trackEvent(`Tab Emails > ${e} clicked`))(e),automationId:"newsletters_listing_tabs",children:[(0,p.jsx)(r.Tab,{route:"standard/(.*)?",title:(0,Le.__)("Newsletters","mailpoet"),automationId:`tab-${(0,Le.__)("Newsletters","mailpoet")}`,children:(0,p.jsx)(Qs,{})},"standard"),(0,p.jsx)(r.Tab,{route:"notification/(.*)?",title:(0,Le.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,Le.__)("Post Notifications","mailpoet")}`,children:e?(0,p.jsx)(vn,{parentId:e}):(0,p.jsx)(nn,{})},"notification"),(0,p.jsx)(r.Tab,{route:"re_engagement/(.*)?",title:(0,Le.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,Le.__)("Re-engagement Emails","mailpoet")}`,children:(0,p.jsx)(un,{})},"re_engagement")]})]})}));function go({history:e}){return(0,p.jsxs)(r.ErrorBoundary,{children:[(0,p.jsx)(d.Q,{}),(0,p.jsxs)("div",{className:"mailpoet-main-container",children:[(0,p.jsx)(kt.m,{heading:(0,Le.__)("What would you like to create?","mailpoet"),headingPrefix:(0,p.jsx)(kt.x,{href:"#/",label:(0,Le.__)("Listing","mailpoet"),"aria-label":(0,Le.__)("Go back to email listing page","mailpoet")})}),(0,p.jsx)(wa,{history:e})]})]})}ho.displayName="NewsletterTabs",go.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired},go.displayName="NewNewsletter";const _o=[{path:"/notification/history/:parentId/(.*)?",render:(0,r.withBoundary)(ho)},{path:"/(standard|notification|re_engagement)/(.*)?",render:(0,r.withBoundary)(ho)},{path:"/new/standard",render:(0,r.withBoundary)(Ns)},{path:"/new/notification",render:(0,r.withBoundary)(ks)},{path:"/new/re-engagement",render:(0,r.withBoundary)(Ts)},{path:"/new",render:(0,r.withBoundary)(go)},{name:"template",path:"/template/:id",render:(0,r.withBoundary)(Ea)},{path:"/send/congratulate/:id",render:(0,r.withBoundary)(Ps)},{path:"/send/:id",render:(0,r.withBoundary)(hs)},{path:"/sending-status/:id/(.*)?",render:(0,r.withBoundary)(wn)},{path:"/stats/:id/(.*)?",render:(0,r.withBoundary)(lo)}];function fo(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(h,{mailpoetInstalledDaysAgo:c.MailPoet.installedDaysAgo,sendTransactionalEmails:c.MailPoet.transactionalEmailsEnabled,mtaMethod:c.MailPoet.mtaMethod,apiVersion:c.MailPoet.apiVersion,noticeDismissed:c.MailPoet.transactionalEmailsOptInNoticeDismissed})}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(w,{})}),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{exact:!0,path:"/",render:()=>(0,p.jsx)(ke.l_,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),_o.map((e=>(0,p.jsx)(ke.AW,{path:e.path,component:e.component,name:e.name||null,data:e.data||null,render:e.render},e.path)))]})]})})}const bo=document.getElementById("newsletters_container");bo&&((0,r.registerTranslations)(),(0,n.s)(bo).render((0,p.jsx)(fo,{})));var xo=a(83488);function vo(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.Q,{children:(0,p.jsxs)(Ie.Link,{className:"mailpoet-button button-secondary",to:"/new","data-automation-id":"new-list",children:[He.R,(0,p.jsx)("span",{children:c.MailPoet.I18n.t("new")})]})}),(0,p.jsx)(Ve,{subscribersInPlan:c.MailPoet.subscribersCount,subscribersInPlanLimit:c.MailPoet.subscribersLimit}),(0,p.jsx)(Be,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,p.jsx)(w,{})]})}const jo=e=>"wp_users"===e.type,yo=e=>"woocommerce_users"===e.type,wo=e=>jo(e)||yo(e),So=c.MailPoet.trackingConfig.emailTrackingEnabled,Po=[{name:"name",label:c.MailPoet.I18n.t("name"),sortable:!0},{name:"description",label:c.MailPoet.I18n.t("description")},{name:"average_subscriber_score",label:c.MailPoet.I18n.t("listScore"),display:So},{name:"subscribed",label:c.MailPoet.I18n.t("subscribed"),className:"mailpoet-listing-column-narrow"},{name:"unconfirmed",label:c.MailPoet.I18n.t("unconfirmed"),className:"mailpoet-listing-column-narrow"},{name:"unsubscribed",label:c.MailPoet.I18n.t("unsubscribed"),className:"mailpoet-listing-column-narrow"},{name:"inactive",label:c.MailPoet.I18n.t("inactive"),className:"mailpoet-listing-column-narrow"},{name:"bounced",label:c.MailPoet.I18n.t("bounced"),className:"mailpoet-listing-column-narrow"},{name:"created_at",label:c.MailPoet.I18n.t("createdOn"),sortable:!0}],Mo={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSegmentTrashed"):c.MailPoet.I18n.t("multipleSegmentsTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSegmentDeleted"):c.MailPoet.I18n.t("multipleSegmentsDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneSegmentRestored"):c.MailPoet.I18n.t("multipleSegmentsRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)}},No=[{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:Mo.onTrash}],Co=e=>!wo(e),Io=[{name:"edit",className:"mailpoet-hide-on-mobile",link:function(e){return(0,p.jsx)(Ie.Link,{to:`/edit/${e.id}`,children:c.MailPoet.I18n.t("edit")})},display:function(e){return!wo(e)}},{name:"duplicate_segment",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("duplicate"),onClick:(e,t)=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"duplicate",data:{id:e.id}}).done((e=>{c.MailPoet.Notice.success(c.MailPoet.I18n.t("listDuplicated").replace("%1$s",(0,xo.r)(e.data.name))),t()})).fail((e=>{c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})),display:function(e){return!wo(e)}},{name:"read_more",className:"mailpoet-hide-on-mobile",link:function(){return(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/133-the-wordpress-users-list",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("readMore")})},display:function(e){return jo(e)}},{name:"synchronize_segment",label:c.MailPoet.I18n.t("forceSync"),onClick:async function(e,t){c.MailPoet.Modal.loading(!0),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"synchronize",data:{type:e.type}}).done((()=>{let a=c.MailPoet.I18n.t("listSynchronized").replace("%1$s",e.name);"woocommerce_users"===e.type&&(a=c.MailPoet.I18n.t("listSynchronizationWasScheduled").replace("%1$s",e.name)),c.MailPoet.Modal.loading(!1),c.MailPoet.Notice.success(a),t()})).fail((e=>{c.MailPoet.Modal.loading(!1),e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},display:function(e){return jo(e)||yo(e)}},{name:"view_subscribers",link:function(e){return(0,p.jsx)("a",{href:e.subscribers_url,"data-automation-id":`view_subscribers_${e.name}`,children:c.MailPoet.I18n.t("viewSubscribers")})}},{name:"trash",className:"mailpoet-hide-on-mobile",display:function(e){return!yo(e)}}];class ko extends o.Component{renderItem=(e,t)=>{const a=ie()("manage-column","column-primary","has-row-actions"),i=Number(e.subscribers_count.subscribed||0),s=Number(e.subscribers_count.unconfirmed||0),n=Number(e.subscribers_count.unsubscribed||0),o=Number(e.subscribers_count.inactive||0),r=Number(e.subscribers_count.bounced||0);let l;return l=wo(e)?(0,p.jsx)("span",{className:"mailpoet-listing-title",children:e.name}):(0,p.jsx)(Ie.Link,{className:"mailpoet-listing-title",to:`/edit/${e.id}`,children:e.name}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("td",{className:a,"data-automation-id":`segment_name_${(0,xo.kb)(e.name)}`,children:[l,t]}),(0,p.jsx)("td",{"data-colname":c.MailPoet.I18n.t("description"),children:(0,p.jsx)("abbr",{children:e.description})}),So?(0,p.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":c.MailPoet.I18n.t("averageScore"),children:(0,p.jsx)("div",{className:"mailpoet-listing-stats",children:(0,p.jsx)(xe,{id:e.id,engagementScore:e.average_engagement_score})})}):null,(0,p.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("subscribed"),children:(0,p.jsx)("abbr",{children:i.toLocaleString()})}),(0,p.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("unconfirmed"),children:(0,p.jsx)("abbr",{children:s.toLocaleString()})}),(0,p.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("unsubscribed"),children:(0,p.jsx)("abbr",{children:n.toLocaleString()})}),(0,p.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("inactive"),children:(0,p.jsx)("abbr",{children:o.toLocaleString()})}),(0,p.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("bounced"),children:(0,p.jsx)("abbr",{children:r.toLocaleString()})}),(0,p.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("createdOn"),children:[c.MailPoet.Date.short(e.created_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.created_at)]})]})};render(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(vo,{}),(0,p.jsx)("div",{className:"mailpoet-segments-listing",children:(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.match.params,messages:Mo,search:!1,endpoint:"segments",base_url:"lists",onRenderItem:this.renderItem,columns:Po,bulk_actions:No,item_actions:Io,sort_by:"name",sort_order:"asc",isItemDeletable:Co,isItemToggleable:jo})})]})}}const To=(0,ke.EN)(ko),Eo=[{name:"name",label:c.MailPoet.I18n.t("segmentFormName"),type:"text",tip:c.MailPoet.I18n.t("segmentFormNameTip")},{name:"description",label:c.MailPoet.I18n.t("description"),type:"textarea",tip:c.MailPoet.I18n.t("segmentDescriptionTip")},{name:"showInManageSubscriptionPage",label:c.MailPoet.I18n.t("showInManageSubscriptionPage"),type:"checkbox",values:{showInManageSubscriptionPage:c.MailPoet.I18n.t("showInManageSubscriptionPageTip")},isChecked:!0}],Ao={onUpdate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("segmentUpdated"))},onCreate:function(){c.MailPoet.Notice.success(c.MailPoet.I18n.t("segmentAdded")),c.MailPoet.trackEvent("Lists > Add new")}};function Ro({match:e}){return(0,p.jsxs)("div",{className:"mailpoet-main-container",children:[(0,p.jsx)(d.Q,{}),(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(It.B,{}),(0,p.jsx)(kt.m,{heading:c.MailPoet.I18n.t("segment"),headingPrefix:(0,p.jsx)(kt.x,{href:"#/",label:(0,Le.__)("Lists","mailpoet"),"aria-label":(0,Le.__)("Navigate to the lists page","mailpoet")})}),(0,p.jsx)(b,{}),(0,p.jsx)(Ct,{endpoint:"segments",fields:Eo,params:e.params,messages:Ao})]})}Ro.displayName="SegmentForm";const Fo=document.getElementById("static_segments_container");function Oo(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:"/new",component:(0,r.withBoundary)(Ro)}),(0,p.jsx)(ke.AW,{path:"/edit/:id",component:(0,r.withBoundary)(Ro)}),(0,p.jsx)(ke.AW,{path:"*",component:(0,r.withBoundary)(To)})]})]})})}Fo&&((0,r.registerTranslations)(),(0,n.s)(Fo).render((0,p.jsx)(Oo,{})));var Do=a(32128),Lo=a(93331),qo=a(1964),Bo=a(5019);function Wo({children:e,title:t,description:a}){return(0,p.jsxs)("div",{className:"mailpoet-admin-fields",children:[(0,p.jsxs)("div",{className:"mailpoet-admin-fields-title",children:[(0,p.jsx)(Bo.X,{level:4,children:t}),(0,p.jsx)("p",{children:a})]}),(0,p.jsx)(Lo.C,{children:(0,p.jsx)(qo.Z,{children:e})})]})}function $o({children:e,slug:t,title:a,description:i}){return(0,p.jsxs)("div",{className:"mailpoet-admin-field",children:[a&&(0,p.jsx)("p",{children:(0,p.jsx)("label",{htmlFor:`field_${t}`,children:a})}),(0,p.jsx)("div",{children:e}),i&&(0,p.jsx)("p",{className:"mailpoet-admin-field-description",children:i})]})}var Uo=a(33334),Vo=a(58678),Ho=a(92180),zo=a(93725);function Zo({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=(0,P.Z)((e=>e(Ho.tC).getAutomations()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&i({operator:Vo.f5.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>{s("operator",e,t)},isMinWidth:!0,children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchAutomations"),options:n,value:n.filter((e=>{if(!t.automation_ids)return;const a=e.value;return-1!==t.automation_ids.indexOf(a)})),onChange:t=>{i({automation_ids:t.map((e=>e.value))},e)}})]})}const Yo={[zo.Z.ENTERED_AUTOMATION]:Zo,[zo.Z.EXITED_AUTOMATION]:Zo};function Go({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getNewslettersList()),[]),n=s?.map((e=>{const t=e.sent_at?c.MailPoet.Date.format(e.sent_at):c.MailPoet.I18n.t("notSentYet");return{label:e.name,tag:t,value:Number(e.id)}}));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e),t.action===Vo.zd.MACHINE_OPENED&&t.operator===Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[t.action,t.operator,e,a]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),t.action!==Vo.zd.MACHINE_OPENED?(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")}):null]},"select"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("selectNewsletterPlaceholder"),options:n,automationId:"segment-email",value:(0,es.filter)((e=>{if(!t.newsletters)return;const a=e.value;return-1!==t.newsletters.indexOf(a)}),n),onChange:t=>{a({newsletters:(0,es.map)((0,es.parseInt)(10),(0,es.map)("value",t))},e)}})]})}const Ko=e=>!!e;var Qo=a(66265);function Jo({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{(0,Qo.J)(t.timeframe,Vo.u4)||i({timeframe:Vo.u4.IN_THE_LAST},e)}),[t,i,e]);const s=t.timeframe===Vo.u4.IN_THE_LAST;return(0,p.jsx)(p.Fragment,{children:(n=i=>s&&"{days}"===i?(0,p.jsx)(r.Input,{type:"number",value:t.days||"","data-automation-id":"segment-number-of-days",onChange:t=>{a("days",e,t)},min:1,step:1,placeholder:c.MailPoet.I18n.t("daysPlaceholder")},"input"):"{timeframe}"===i?(0,p.jsxs)(pt.Select,{value:t.timeframe,onChange:t=>{a("timeframe",e,t)},children:[(0,p.jsx)("option",{value:"inTheLast",children:c.MailPoet.I18n.t("inTheLast")}),(0,p.jsx)("option",{value:"allTime",children:c.MailPoet.I18n.t("overAllTime")})]},"timeframe-select"):s&&"string"==typeof i&&i.trim().length>1?(0,p.jsx)("div",{children:i},i):null,c.MailPoet.I18n.t("emailActionOpensDaysSentence").split(/({days})|({timeframe})/gim).map(n))});var n}function Xo(e){return e.timeframe===Vo.u4.ALL_TIME||parseInt(e.days,10)>=1}function er({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{void 0===t.operator&&a({operator:"more"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,p.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{opens}"===a?(0,p.jsx)(lt.I,{type:"number",value:t.opens||"","data-automation-id":"segment-number-of-opens",onChange:t=>{i("opens",e,t)},min:"0",placeholder:c.MailPoet.I18n.t("emailActionOpens")},"input"):"string"==typeof a&&a.trim().length>1?(0,p.jsx)("div",{children:a},"opens"):null,c.MailPoet.I18n.t("emailActionOpensSentence").split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]});var s}const tr={[Vo.zd.OPENS_ABSOLUTE_COUNT]:er,[Vo.zd.MACHINE_OPENS_ABSOLUTE_COUNT]:er,[Vo.zd.CLICKED]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getNewslettersList()),[]),[n,r]=(0,o.useState)([]),[l,d]=(0,o.useState)([]),[m,u]=(0,o.useState)(!1),h=s?.map((e=>{const t=e.sent_at?c.MailPoet.Date.format(e.sent_at):(0,Le.__)("Not sent yet","mailpoet");return{label:e.name,tag:t,value:Number(e.id)}})),g=(0,o.useCallback)((()=>{var e;Ko(t.newsletter_id)&&(d([]),e=t.newsletter_id,r([]),u(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"newsletter_links",action:"get",data:{newsletterId:e}}).then((e=>{const{data:t}=e,a=t.map((e=>({value:e.id,label:e.url})));u(!1),d(a)})).fail((e=>{r(e.errors)})))}),[t.newsletter_id]);return(0,o.useEffect)((()=>{g()}),[g,t.newsletter_id]),(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[t.operator,e,a]),(0,p.jsxs)(p.Fragment,{children:[n.length>0&&(0,p.jsx)(fa,{errors:n}),(0,p.jsx)(Do.ReactSelect,{placeholder:c.MailPoet.I18n.t("selectNewsletterPlaceholder"),options:h,value:(0,es.find)(["value",t.newsletter_id],h),onChange:t=>{a({newsletter_id:t.value,link_ids:[]},e)},automationId:"segment-email"}),(0,p.jsxs)(pt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),m&&(0,p.jsx)("span",{children:c.MailPoet.I18n.t("loadingDynamicSegmentItems")}),!m&&Ko(t.newsletter_id)&&(0,p.jsx)(Do.ReactSelect,{isMulti:!0,automationId:"segment-link-select",placeholder:c.MailPoet.I18n.t("allLinksPlaceholder"),options:l.length?l:[{value:0,label:c.MailPoet.I18n.t("noLinksHint"),isDisabled:!0}],value:(0,es.filter)((e=>!!t.link_ids&&-1!==t.link_ids.indexOf(e.value)),l),onChange:t=>{a({link_ids:(t||[]).map((e=>e.value))},e)}})]})},[Vo.zd.OPENED]:Go,[Vo.zd.WAS_SENT]:Go,[Vo.zd.MACHINE_OPENED]:Go,[Vo.zd.CLICKED_ANY]:null,[Vo.zd.NUMBER_RECEIVED]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,p.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{emails}"===a?(0,p.jsx)(lt.I,{type:"number",value:t.emails||"","data-automation-id":"segment-number-emails-received",onChange:t=>{i("emails",e,t)},min:"0",placeholder:(0,Le.__)("emails","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,p.jsx)("div",{children:a},"emails"):null,(0,Le.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]});var s},[Vo.zd.NUMBER_OF_CLICKS]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:"more",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"less",children:c.MailPoet.I18n.t("lessThan")}),(0,p.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("notEquals")})]},"select"):"{clicks}"===a?(0,p.jsx)(lt.I,{type:"number",value:t.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:t=>{i("clicks",e,t)},min:"0",placeholder:(0,Le.__)("clicks","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,p.jsx)("div",{children:a},"clicks"):null,(0,Le.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]});var s}};var ar=a(71622),ir=a(30673);let sr=function(e){return e.BEFORE="before",e.AFTER="after",e.ON="on",e.ON_OR_BEFORE="onOrBefore",e.ON_OR_AFTER="onOrAfter",e.NOT_ON="notOn",e.IN_THE_LAST="inTheLast",e.NOT_IN_THE_LAST="notInTheLast",e}({});const nr=[sr.BEFORE,sr.AFTER,sr.ON,sr.ON_OR_AFTER,sr.ON_OR_BEFORE,sr.NOT_ON,sr.IN_THE_LAST,sr.NOT_IN_THE_LAST],or=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return c.MailPoet.Date.format(e,{format:"Y-m-d"})}},rr=e=>{const t=(0,ar.default)(e);if((0,ir.default)(t))return t};function lr({filterIndex:e,defaultOperator:t}){const a=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{nr.includes(a.operator)||i({operator:t},e),a.operator!==sr.BEFORE&&a.operator!==sr.AFTER&&a.operator!==sr.ON&&a.operator!==sr.ON_OR_AFTER&&a.operator!==sr.ON_OR_BEFORE&&a.operator!==sr.NOT_ON||void 0!==rr(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||i({value:or(new Date)},e),a.operator!==sr.IN_THE_LAST&&a.operator!==sr.NOT_IN_THE_LAST||"string"!=typeof a.value||/^\d*$/.exec(a.value)||i({value:""},e)}),[i,a,e,t]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:a.operator,isMinWidth:!0,onChange:t=>{s("operator",e,t)},children:[(0,p.jsx)("option",{value:sr.BEFORE,children:c.MailPoet.I18n.t("before")}),(0,p.jsx)("option",{value:sr.ON_OR_BEFORE,children:c.MailPoet.I18n.t("onOrBefore")}),(0,p.jsx)("option",{value:sr.ON,children:c.MailPoet.I18n.t("on")}),(0,p.jsx)("option",{value:sr.NOT_ON,children:c.MailPoet.I18n.t("notOn")}),(0,p.jsx)("option",{value:sr.ON_OR_AFTER,children:c.MailPoet.I18n.t("onOrAfter")}),(0,p.jsx)("option",{value:sr.AFTER,children:c.MailPoet.I18n.t("after")}),(0,p.jsx)("option",{value:sr.IN_THE_LAST,children:c.MailPoet.I18n.t("inTheLast")}),(0,p.jsx)("option",{value:sr.NOT_IN_THE_LAST,children:c.MailPoet.I18n.t("notInTheLast")})]},"select"),(a.operator===sr.BEFORE||a.operator===sr.AFTER||a.operator===sr.ON||a.operator===sr.ON_OR_AFTER||a.operator===sr.ON_OR_BEFORE||a.operator===sr.NOT_ON)&&(0,p.jsx)($a.a,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value:or(t)},e)},selected:a.value?rr(a.value):void 0}),(a.operator===sr.IN_THE_LAST||a.operator===sr.NOT_IN_THE_LAST)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(lt.I,{className:"mailpoet-segments-input-small",type:"number",value:a.value||"",onChange:t=>{s("value",e,t)},min:"1",placeholder:c.MailPoet.I18n.t("daysPlaceholder")},"input"),(0,p.jsx)("span",{children:c.MailPoet.I18n.t("daysPlaceholder")})]})]})}function dr(e){return!(!e.operator||!e.value)&&([sr.BEFORE,sr.AFTER,sr.ON,sr.NOT_ON,sr.ON_OR_BEFORE,sr.ON_OR_AFTER].includes(e.operator)?/^\d+-\d+-\d+$/.test(e.value):!![sr.IN_THE_LAST,sr.NOT_IN_THE_LAST].includes(e.operator)&&(/^\d+$/.test(e.value)&&Number(e.value)>0))}function cr(e){return function(t){return(0,p.jsx)(lr,{...t,defaultOperator:e})}}const mr=cr(sr.BEFORE),ur=cr(sr.IN_THE_LAST);var pr=a(70468);function hr({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{void 0===t.number_of_orders_type&&a({number_of_orders_type:"="},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{value:t.number_of_orders_type,onChange:t=>{i("number_of_orders_type",e,t)},automationId:"select-number-of-orders-type",children:[(0,p.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,p.jsx)(r.Input,{"data-automation-id":"input-number-of-orders-count",type:"number",min:0,value:t.number_of_orders_count||"",placeholder:c.MailPoet.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("number_of_orders_count",e,t)}}),(0,p.jsx)("div",{children:c.MailPoet.I18n.t("wooNumberOfOrdersOrders")})]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})}const gr=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function _r(e){return!!gr.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function fr({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{gr.includes(t.operator)||i({operator:"is",value:""},e)}),[i,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{automationId:"subscriber-text-field-select",value:t.operator,isMinWidth:!0,onChange:t=>{a("operator",e,t)},children:[(0,p.jsx)("option",{value:"is",children:c.MailPoet.I18n.t("is")}),(0,p.jsx)("option",{value:"isNot",children:c.MailPoet.I18n.t("isNot")}),(0,p.jsx)("option",{value:"contains",children:c.MailPoet.I18n.t("contains")}),(0,p.jsx)("option",{value:"notContains",children:c.MailPoet.I18n.t("notContains")}),(0,p.jsx)("option",{value:"startsWith",children:c.MailPoet.I18n.t("startsWith")}),(0,p.jsx)("option",{value:"notStartsWith",children:c.MailPoet.I18n.t("notStartsWith")}),(0,p.jsx)("option",{value:"endsWith",children:c.MailPoet.I18n.t("endsWith")}),(0,p.jsx)("option",{value:"notEndsWith",children:c.MailPoet.I18n.t("notEndsWith")})]},"select"),(0,p.jsx)(lt.I,{className:"mailpoet-segments-input-medium","data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:c.MailPoet.I18n.t("value")},"input")]})}const br={[pr.wq.CUSTOMER_IN_COUNTRY]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getWooCommerceCountries()),[]).map((e=>({value:e.code,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-country",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-country"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooCountry"),options:i,value:(0,es.filter)((e=>{if(t.country_code)return-1!==t.country_code.indexOf(e.value)}),i),onChange:t=>{a({country_code:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-country"},"select-segment-country")]})},[pr.wq.CUSTOMER_IN_CITY]:fr,[pr.wq.CUSTOMER_IN_POSTAL_CODE]:fr,[pr.wq.NUMBER_OF_ORDERS]:hr,[pr.wq.NUMBER_OF_ORDERS_WITH_COUPON]:hr,[pr.wq.NUMBER_OF_REVIEWS]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{(0,Qo.J)(t.count_type,Vo.Si)||a({count_type:Vo.Si.EQUALS},e),(0,Qo.J)(t.rating,Vo.Nj)||a({rating:Vo.Nj.ANY},e),(0,Qo.J)(t.timeframe,Vo.u4)||a({timeframe:Vo.u4.IN_THE_LAST},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(r.Select,{value:t.rating,isMinWidth:!0,onChange:t=>{i("rating",e,t)},children:[(0,p.jsx)("option",{value:Vo.Nj.ANY,children:c.MailPoet.I18n.t("wooAnyStarRating")}),(0,p.jsx)("option",{value:Vo.Nj.ONE,children:c.MailPoet.I18n.t("wooOneStarRating")}),(0,p.jsx)("option",{value:Vo.Nj.TWO,children:c.MailPoet.I18n.t("wooTwoStarRating")}),(0,p.jsx)("option",{value:Vo.Nj.THREE,children:c.MailPoet.I18n.t("wooThreeStarRating")}),(0,p.jsx)("option",{value:Vo.Nj.FOUR,children:c.MailPoet.I18n.t("wooFourStarRating")}),(0,p.jsx)("option",{value:Vo.Nj.FIVE,children:c.MailPoet.I18n.t("wooFiveStarRating")})]},"rating-select"),(0,p.jsxs)(r.Select,{value:t.count_type,isMinWidth:!0,onChange:t=>{i("count_type",e,t)},automationId:"select-number-of-reviews-type",children:[(0,p.jsx)("option",{value:Vo.Si.EQUALS,children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:Vo.Si.NOT_EQUALS,children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:Vo.Si.MORE_THAN,children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:Vo.Si.LESS_THAN,children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,p.jsx)(r.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-number-of-reviews-count",type:"number",min:0,value:t.count||"",placeholder:c.MailPoet.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("count",e,t)}}),(0,p.jsx)("div",{children:c.MailPoet.I18n.t("wooNumberOfReviewsReviews")}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.PURCHASE_DATE]:mr,[pr.wq.PURCHASED_PRODUCT]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),(0,p.jsx)(Do.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c.MailPoet.I18n.t("selectWooPurchasedProduct"),options:i,value:(0,es.filter)((e=>{if(void 0!==t.product_ids&&0!==t.product_ids.length)return-1!==t.product_ids.indexOf(e.value)}),i),onChange:t=>{a({product_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-products"},"select-segment-products")]})},[pr.wq.PURCHASED_CATEGORY]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getProductCategories()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),(0,p.jsx)(Do.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c.MailPoet.I18n.t("selectWooPurchasedCategory"),options:i,value:(0,es.filter)((e=>{if(void 0!==t.category_ids&&0!==t.category_ids.length)return-1!==t.category_ids.indexOf(e.value)}),i),onChange:t=>{a({category_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-category"},"select-segment-category")]})},[pr.wq.PURCHASED_WITH_ATTRIBUTE]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getProductAttributes()),[]),s=(0,o.useMemo)((()=>Object.values(i).filter((e=>e.terms.length>0)).map((e=>({value:e.taxonomy,label:e.label})))),[i]),n=(0,P.Z)((e=>e(Ho.tC).getLocalProductAttributes()),[]),r=(0,o.useMemo)((()=>Object.values(n).filter((e=>e.values.length>0)).map((e=>({value:`${e.name}@local`,label:e.name})))),[n]),l=(0,o.useMemo)((()=>Object.values(r).map((e=>e.value))),[r]),d=(0,o.useMemo)((()=>[...s,...r]),[s,r]),c=(0,o.useMemo)((()=>"taxonomy"===t.attribute_type?i[t.attribute_taxonomy_slug].terms.map((e=>({value:e.term_id.toString(),label:e.name}))):"local"===t.attribute_type?n[t.attribute_local_name].values.map((e=>({value:e,label:e}))):[]),[t.attribute_type,t.attribute_taxonomy_slug,t.attribute_local_name,i,n]);(0,o.useEffect)((()=>{t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]);const m=(0,o.useCallback)((t=>{l.includes(t.value)?a({attribute_type:"local",attribute_local_name:t.value.replace(/@local$/,""),attribute_local_values:[],attribute_taxonomy_slug:null,attribute_term_ids:null},e):a({attribute_type:"taxonomy",attribute_local_name:null,attribute_local_values:null,attribute_taxonomy_slug:t.value,attribute_term_ids:[]},e)}),[e,l,a]),u=(0,o.useMemo)((()=>"local"===t.attribute_type?(0,es.filter)((e=>{if(t.attribute_local_name)return`${t.attribute_local_name}@local`===e.value}),r):(0,es.filter)((e=>{if(void 0!==t.attribute_taxonomy_slug)return t.attribute_taxonomy_slug===e.value}),s)),[t.attribute_type,t.attribute_local_name,t.attribute_taxonomy_slug,r,s]),h=(0,o.useMemo)((()=>(0,es.filter)((e=>t.attribute_local_values?-1!==t.attribute_local_values.indexOf(e.value):t.attribute_term_ids?-1!==t.attribute_term_ids.indexOf(e.value):void 0),c)),[t.attribute_local_values,t.attribute_term_ids,c]),g=(0,o.useCallback)((i=>{"local"===t.attribute_type?a({attribute_term_ids:null,attribute_local_values:(i||[]).map((e=>e.value))},e):a({attribute_term_ids:(i||[]).map((e=>e.value)),attribute_local_values:null},e)}),[t.attribute_type,a,e]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:(0,Le.__)("any of","mailpoet")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:(0,Le.__)("all of","mailpoet")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:(0,Le.__)("none of","mailpoet")})]},"select-operator"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",placeholder:(0,Le.__)("Search attributes","mailpoet"),options:d,value:u,onChange:m},"select-segment-product-attribute"),c.length>0&&(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:(0,Le.__)("Search attributes terms","mailpoet"),options:c,value:h,onChange:g},"select-segment-product-attribute-terms")]})},[pr.wq.PURCHASED_TAG]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getProductTags()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator"),(0,p.jsx)(Do.ReactSelect,{isMulti:!0,dimension:"small",placeholder:(0,Le.__)("Search tags","mailpoet"),options:i,value:(0,es.filter)((e=>{if(void 0!==t.tag_ids&&0!==t.tag_ids.length)return-1!==t.tag_ids.indexOf(e.value)}),i),onChange:t=>{a({tag_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-tags"},"select-segment-tag")]})},[pr.wq.SINGLE_ORDER_VALUE]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{void 0===t.single_order_value_type&&a({single_order_value_type:">"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{value:t.single_order_value_type,onChange:t=>{i("single_order_value_type",e,t)},automationId:"select-single-order-value-type",children:[(0,p.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:">=",children:c.MailPoet.I18n.t("moreThanOrEqual")}),(0,p.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:"<=",children:c.MailPoet.I18n.t("lessThanOrEqual")}),(0,p.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,p.jsx)(r.Input,{"data-automation-id":"input-single-order-value-amount",type:"number",min:0,step:.01,value:t.single_order_value_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:t=>{i("single_order_value_amount",e,t)}}),(0,p.jsx)("div",{children:s})]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.TOTAL_SPENT]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{void 0===t.total_spent_type&&a({total_spent_type:">"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{value:t.total_spent_type,onChange:t=>{i("total_spent_type",e,t)},automationId:"select-total-spent-type",children:[(0,p.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,p.jsx)(r.Input,{"data-automation-id":"input-total-spent-amount",type:"number",min:0,step:.01,value:t.total_spent_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:t=>{i("total_spent_amount",e,t)}}),(0,p.jsx)("div",{children:s})]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.AVERAGE_SPENT]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getWooCommerceCurrencySymbol()),[]);return(0,o.useEffect)((()=>{[">",">=","=","!=","<=","<"].includes(t.average_spent_type)||a({average_spent_type:">"},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(r.Select,{value:t.average_spent_type,isMinWidth:!0,onChange:t=>{i("average_spent_type",e,t)},automationId:"select-average-spent-type",children:[(0,p.jsx)("option",{value:">",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:">=",children:c.MailPoet.I18n.t("moreThanOrEqual")}),(0,p.jsx)("option",{value:"=",children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:"!=",children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:"<=",children:c.MailPoet.I18n.t("lessThanOrEqual")}),(0,p.jsx)("option",{value:"<",children:c.MailPoet.I18n.t("lessThan")})]},"select"),(0,p.jsx)(r.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-average-spent-amount",type:"number",min:0,step:.01,value:t.average_spent_amount||"",placeholder:c.MailPoet.I18n.t("wooSpentAmount"),onChange:t=>{i("average_spent_amount",e,t)}}),(0,p.jsx)("div",{children:s}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.USED_COUPON_CODE]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),[i,s]=(0,o.useState)(!1),[n,l]=(0,o.useState)([]),[d,m]=(0,o.useState)(!1),[u,h]=(0,o.useState)(1),[g,_]=(0,o.useState)(!0),[f,b]=(0,o.useState)(""),[x,v]=(0,o.useState)([]),j=(0,o.useCallback)(((e,a,i,s)=>{s&&(e||m(!0),c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"coupons",action:"getCoupons",data:{page_number:a,page_size:1e3,include_coupon_ids:t.coupon_code_ids,search:i}}).then((t=>{const{data:i}=t,s=i.map((e=>({value:e.id.toString(),label:e.text}))),n=a+1;0===s.length?_(!1):(l((e=>(0,es.uniqBy)((e=>e.value),[...e,...s]))),h(n)),e||m(!1)})).fail((e=>{v(e.errors)})))}),[t.coupon_code_ids]),y=(0,es.debounce)(300,(e=>{const t=f;b(e),!d&&(g&&e||t&&!e)&&(h(1),j(!1,1,e,g))}));return(0,o.useEffect)((()=>{i||(j(!0,u,f,g),s(!0))}),[i,u,f,j,g]),(0,o.useEffect)((()=>{Array.isArray(t.coupon_code_ids)||a({coupon_code_ids:[]},e),(0,Qo.J)(t.operator,Vo.f5)||a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[x.length>0&&(0,p.jsx)(fa,{errors:x}),i?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-coupon-code",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,p.jsx)(Do.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:d,placeholder:c.MailPoet.I18n.t("selectWooCouponCodes"),options:n,value:(0,es.filter)((e=>{if(t.coupon_code_ids)return-1!==t.coupon_code_ids.indexOf(e.value)}),n),onInputChange:e=>{y(e)},onChange:t=>{a({coupon_code_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!d&&g&&j(!1,u,f,g)}},"select-coupon-codes")]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]}):(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,Le.__)("Loading coupon codes...","mailpoet")})]})},[pr.wq.USED_PAYMENT_METHOD]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getPaymentMethods()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-payment-methods",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,p.jsx)(Do.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooPaymentMethods"),options:i,value:(0,es.filter)((e=>{if(t.payment_methods)return-1!==t.payment_methods.indexOf(e.value)}),i),onChange:t=>{a({payment_methods:(t||[]).map((e=>e.value))},e)},automationId:"select-payment-methods"},"select-payment-methods")]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.USED_SHIPPING_METHOD]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getShippingMethods()),[]).map((e=>({value:e.instanceId,label:e.name})));return(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(r.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-shipping-methods",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,p.jsx)(Do.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:c.MailPoet.I18n.t("selectWooShippingMethods"),options:i,value:(0,es.filter)((e=>{if(t.shipping_methods)return-1!==t.shipping_methods.indexOf(e.value)}),i),onChange:t=>{a({shipping_methods:(t||[]).map((e=>e.value))},e)},automationId:"select-shipping-methods"},"select-shipping-methods")]}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Jo,{filterIndex:e})})]})},[pr.wq.FIRST_ORDER]:mr};function xr({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{t.action===Vo.jx.WORDPRESS_ROLE&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]);const s=(0,P.Z)((e=>e(Ho.tC).getWordpressRoles()),[]).map((e=>({value:e.role_id,label:e.role_name})));return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsxs)(pt.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select")}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:c.MailPoet.I18n.t("selectUserRolePlaceholder"),options:s,value:(0,es.filter)((e=>{if(t.wordpressRole)return-1!==t.wordpressRole.indexOf(e.value)}),s),onChange:t=>{a({wordpressRole:(0,es.map)("value",t)},e)}})})]})}let vr=function(e){return e.HIGHER_THAN="higherThan",e.LOWER_THAN="lowerThan",e.EQUALS="equals",e.NOT_EQUALS="not_equals",e.UNKNOWN="unknown",e.NOT_UNKNOWN="not_unknown",e}({});const jr=[vr.HIGHER_THAN,vr.LOWER_THAN,vr.EQUALS,vr.NOT_EQUALS,vr.UNKNOWN,vr.NOT_UNKNOWN];function yr(e){return!!(0,Vo.F3)(e.operator)||"string"==typeof e.value&&e.value.length>0&&("equals"===e.operator||"contains"===e.operator||"not_contains"===e.operator||"not_equals"===e.operator||"more_than"===e.operator||"less_than"===e.operator)}function wr({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{void 0===t.operator&&i({operator:"equals",value:""},e)}),[i,t,e]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,p.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("is")}),(0,p.jsx)("option",{value:"not_equals",children:c.MailPoet.I18n.t("isNot")}),(0,p.jsx)("option",{value:"contains",children:c.MailPoet.I18n.t("contains")}),(0,p.jsx)("option",{value:"not_contains",children:c.MailPoet.I18n.t("notContains")}),(0,p.jsx)("option",{value:"more_than",children:c.MailPoet.I18n.t("moreThan")}),(0,p.jsx)("option",{value:"less_than",children:c.MailPoet.I18n.t("lessThan")}),(0,p.jsx)("option",{value:"is_blank",children:c.MailPoet.I18n.t("isBlank")}),(0,p.jsx)("option",{value:"is_not_blank",children:c.MailPoet.I18n.t("isNotBlank")})]},"select"),!(0,Vo.F3)(t.operator)&&(0,p.jsx)(lt.I,{"data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:c.MailPoet.I18n.t("value")},"input")]})}function Sr(e){return!!(0,Vo.F3)(e.operator)||"string"==typeof e.value&&e.value.length>0}function Pr({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getCustomFieldsList()),[]),n=(0,es.find)({id:Number(t.custom_field_id)},s);if(!n)return null;const o=n.params;if(!o||!Array.isArray(o.values))return null;const r=o.values.map((e=>({value:e.value,label:e.value}))),l=r.find((e=>e.value===t.value))?.label;return(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:"equals",children:c.MailPoet.I18n.t("is")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:c.MailPoet.I18n.t("isBlank")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:c.MailPoet.I18n.t("isNotBlank")})]},"select"),!(0,Vo.F3)(t.operator)&&(0,p.jsx)(Do.ReactSelect,{dimension:"small",placeholder:c.MailPoet.I18n.t("selectValue"),options:r,value:t.value&&l?{value:t.value,label:l}:null,onChange:t=>{a({value:t.value},e)},automationId:"segment-wordpress-role"})]})}var Mr=a(12892),Nr=a(15826);function Cr(e){return!!(0,Vo.F3)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const Ir=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return(0,Nr.default)(e,"yyyy-MM-dd 00:00:00")}},kr=e=>{const t=(0,ar.default)(e);if((0,ir.default)(t))return t},Tr={month:function({onChange:e,item:t,filterIndex:a}){return(0,o.useEffect)((()=>{Cr(t)||e((0,es.assign)(t,{value:"2017-01-01 00:00:00"}),a),void 0===t.operator&&e((0,es.assign)(t,{operator:"equals"}),a)}),[e,t,a]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:i=>{e((0,es.assign)(t,{operator:i.target.value}),a)},children:[(0,p.jsx)("option",{value:"equals",children:(0,Le.__)("is","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:(0,Le.__)("is blank","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:(0,Le.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Vo.F3)(t.operator)&&(0,p.jsxs)(pt.Select,{value:t.value,onChange:i=>{e((0,es.assign)(t,{value:i.target.value}),a)},children:[(0,p.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,Le.__)("january","mailpoet")}),(0,p.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,Le.__)("february","mailpoet")}),(0,p.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,Le.__)("march","mailpoet")}),(0,p.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,Le.__)("april","mailpoet")}),(0,p.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,Le.__)("may","mailpoet")}),(0,p.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,Le.__)("june","mailpoet")}),(0,p.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,Le.__)("july","mailpoet")}),(0,p.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,Le.__)("august","mailpoet")}),(0,p.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,Le.__)("september","mailpoet")}),(0,p.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,Le.__)("october","mailpoet")}),(0,p.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,Le.__)("november","mailpoet")}),(0,p.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,Le.__)("december","mailpoet")})]},"select")]})},year:function({onChange:e,item:t,filterIndex:a}){const i=(0,Mr.default)(new Date);return(0,o.useEffect)((()=>{Cr(t)||e((0,es.assign)(t,{value:`${i}-01-01 00:00:00`,operator:"equals"}),a)}),[i,e,t,a]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:i=>{e((0,es.assign)(t,{operator:i.target.value}),a)},children:[(0,p.jsx)("option",{value:"equals",children:(0,Le.__)("is","mailpoet")}),(0,p.jsx)("option",{value:"before",children:(0,Le._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,p.jsx)("option",{value:"after",children:(0,Le._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:(0,Le.__)("is blank","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:(0,Le.__)("is not blank","mailpoet")})]},"select-operator"),(0,p.jsx)(pt.Select,{value:t.value,onChange:i=>{e((0,es.assign)(t,{value:i.target.value}),a)},children:(0,es.range)(0,100).map((e=>(0,p.jsx)("option",{value:i-e+"-01-01 00:00:00",children:i-e},i-e)))},"select-year")]})},year_month:function({onChange:e,item:t,filterIndex:a}){return(0,o.useEffect)((()=>{void 0!==t.value&&""!==t.value||e((0,es.assign)(t,{value:`${(0,Nr.default)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[e,t,a]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:i=>{e((0,es.assign)(t,{operator:i.target.value}),a)},children:[(0,p.jsx)("option",{value:"equals",children:(0,Le.__)("is","mailpoet")}),(0,p.jsx)("option",{value:"before",children:(0,Le._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,p.jsx)("option",{value:"after",children:(0,Le._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:(0,Le.__)("is blank","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:(0,Le.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Vo.F3)(t.operator)&&(0,p.jsx)($a.a,{onChange:i=>e((0,es.assign)(t,{value:Ir(i)}),a),selected:t.value?kr(t.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function({onChange:e,item:t,filterIndex:a}){return(0,o.useEffect)((()=>{Cr(t)||e((0,es.assign)(t,{value:`${(0,Nr.default)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[e,t,a]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:i=>{e((0,es.assign)(t,{operator:i.target.value}),a)},children:[(0,p.jsx)("option",{value:"equals",children:(0,Le.__)("is","mailpoet")}),(0,p.jsx)("option",{value:"before",children:(0,Le._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,p.jsx)("option",{value:"after",children:(0,Le._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:(0,Le.__)("is blank","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:(0,Le.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Vo.F3)(t.operator)&&(0,p.jsx)($a.a,{dateFormat:"MMM d, yyyy",onChange:i=>e((0,es.assign)(t,{value:Ir(i)}),a),selected:t.value?kr(t.value):void 0})]})}};var Er=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(Er||{});const Ar={[Er.TEXT]:yr,[Er.TEXTAREA]:yr,[Er.RADIO]:Sr,[Er.SELECT]:Sr,[Er.CHECKBOX]:function(e){return!!(0,Vo.F3)(e.operator)||["1","0"].includes(e.value)},[Er.DATE]:Cr},Rr={[Er.TEXT]:wr,[Er.TEXTAREA]:wr,[Er.RADIO]:Pr,[Er.SELECT]:Pr,[Er.CHECKBOX]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{void 0===t.operator?i({operator:"equals",value:"1"},e):"equals"!==t.operator||["1","0"].includes(t.value)||i({value:"1"},e)}),[i,t,e]),(0,p.jsxs)(Da.Grid.CenteredRow,{children:[(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,p.jsx)("option",{value:"equals",children:(0,Le.__)("is","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.BLANK,children:(0,Le.__)("is blank","mailpoet")}),(0,p.jsx)("option",{value:Vo.DB.NOT_BLANK,children:(0,Le.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Vo.F3)(t.operator)&&(0,p.jsxs)(pt.Select,{value:t.value,onChange:t=>a("value",e,t),children:[(0,p.jsx)("option",{value:"1",children:(0,Le.__)("checked","mailpoet")}),(0,p.jsx)("option",{value:"0",children:(0,Le.__)("unchecked","mailpoet")})]},"select")]})},[Er.DATE]:function({customField:e,filterIndex:t}){const a=(0,P.Z)((e=>e(Ho.tC).getSegmentFilter(t)),[t]),{updateSegmentFilter:i}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{a.date_type!==e.params.date_type&&i({date_type:e.params.date_type,value:""},t)}),[a.date_type,i,e.params.date_type,t]);const s=Tr[e.params.date_type];return s?(0,p.jsx)(s,{item:a,onChange:i,filterIndex:t}):null}};function Fr(){return(0,p.jsx)(aa,{message:(()=>{const e=c.MailPoet.I18n.t("premiumFeatureMultipleConditions");return(0,p.jsx)("p",{children:f()(e,/\[link](.*?)\[\/link]/g,(e=>(0,p.jsx)("a",{href:c.MailPoet.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e)))})})(),actionButton:(0,p.jsx)(qe.z,{href:c.MailPoet.MailPoetComUrlFactory.getPurchasePlanUrl(c.MailPoet.subscribersCount,c.MailPoet.currentWpUserEmail,null,{utm_medium:"segments",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("premiumBannerCtaFree")})})}const Or={[Vo.jx.WORDPRESS_ROLE]:xr,[Vo.jx.SUBSCRIBER_SCORE]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC);return(0,o.useEffect)((()=>{jr.includes(t.operator)||a({operator:vr.HIGHER_THAN},e),t.operator!==vr.HIGHER_THAN&&t.operator!==vr.LOWER_THAN&&t.operator!==vr.EQUALS&&t.operator!==vr.NOT_EQUALS||void 0!==t.value||a({value:""},e),t.operator!==vr.UNKNOWN&&t.operator!==vr.NOT_UNKNOWN||a({value:null},e)}),[a,t,e]),(0,p.jsx)(Da.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,p.jsxs)(pt.Select,{value:t.operator,automationId:"segment-subscriber-score-operator",onChange:t=>{i("operator",e,t)},children:[(0,p.jsx)("option",{value:vr.HIGHER_THAN,children:c.MailPoet.I18n.t("higherThan")}),(0,p.jsx)("option",{value:vr.LOWER_THAN,children:c.MailPoet.I18n.t("lowerThan")}),(0,p.jsx)("option",{value:vr.EQUALS,children:c.MailPoet.I18n.t("equals")}),(0,p.jsx)("option",{value:vr.NOT_EQUALS,children:c.MailPoet.I18n.t("notEquals")}),(0,p.jsx)("option",{value:vr.UNKNOWN,children:c.MailPoet.I18n.t("unknown")}),(0,p.jsx)("option",{value:vr.NOT_UNKNOWN,children:c.MailPoet.I18n.t("notUnknown")})]},"select"):"{score}"===a?(t.operator===vr.HIGHER_THAN||t.operator===vr.LOWER_THAN||t.operator===vr.EQUALS||t.operator===vr.NOT_EQUALS)&&(0,p.jsx)(lt.I,{type:"number",value:t.value||"","data-automation-id":"segment-subscriber-score-value",onChange:t=>{i("value",e,t)},min:"0",placeholder:c.MailPoet.I18n.t("subscriberScorePlaceholder")},"input"):"string"==typeof a&&a.trim().length>0?t.operator!==vr.UNKNOWN&&t.operator!==vr.NOT_UNKNOWN&&(0,p.jsx)("div",{children:a},"score"):null,c.MailPoet.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(s))});var s},[Vo.jx.SUBSCRIBED_DATE]:mr,[Vo.jx.MAILPOET_CUSTOM_FIELD]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getCustomFieldsList()),[]),s=(0,es.find)({id:Number(t.custom_field_id)},i),n=i.map((e=>({value:e.id.toString(),label:e.name}))),o=Rr[t.custom_field_type];return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{children:(0,p.jsx)(Do.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectCustomFieldPlaceholder"),options:n,automationId:"select-custom-field",value:(0,es.find)((e=>{if(t.custom_field_id)return t.custom_field_id===e.value}),n),onChange:t=>{const s=(0,es.find)({id:Number(t.value)},i);s&&a({custom_field_id:t.value,custom_field_type:s.type,operator:void 0,value:void 0},e)}})}),(0,p.jsx)("div",{children:o&&(0,p.jsx)(o,{customField:s,filterIndex:e})})]})},[Vo.jx.SUBSCRIBED_TO_LIST]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=(0,P.Z)((e=>e(Ho.tC).getStaticSegmentsList()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&i({operator:Vo.f5.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchLists"),options:n,value:(0,es.filter)((e=>{if(!t.segments)return;const a=e.value;return-1!==t.segments.indexOf(a)}),n),onChange:t=>{i({segments:(0,es.map)((0,es.parseInt)(10),(0,es.map)("value",t))},e)}})]})},[Vo.jx.SUBSCRIBER_TAG]:function({filterIndex:e}){return Wt.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,p.jsx)(Fr,{}),e)},[Vo.jx.SUBSCRIBER_FIRST_NAME]:fr,[Vo.jx.SUBSCRIBER_LAST_NAME]:fr,[Vo.jx.SUBSCRIBER_EMAIL]:fr,[Vo.jx.SUBSCRIBED_VIA_FORM]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=(0,P.Z)((e=>e(Ho.tC).getSignupForms()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.Z)(Ho.tC);(0,o.useEffect)((()=>{t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.NONE&&i({operator:Vo.f5.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(pt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select"),(0,p.jsx)(Do.ReactSelect,{dimension:"small",isMulti:!0,placeholder:c.MailPoet.I18n.t("searchForms"),options:n,value:n.filter((e=>{if(!t.form_ids)return;const a=e.value;return-1!==t.form_ids.indexOf(a)})),onChange:t=>{i({form_ids:t.map((e=>e.value))},e)}})]})},[Vo.jx.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:ur,[Vo.jx.SUBSCRIBER_LAST_PURCHASE_DATE]:ur,[Vo.jx.SUBSCRIBER_LAST_OPEN_DATE]:ur,[Vo.jx.SUBSCRIBER_LAST_CLICK_DATE]:ur,[Vo.jx.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:ur,[Vo.jx.SUBSCRIBER_LAST_SENDING_DATE]:ur},Dr={[Vo.Bt.Automations]:function(e){return!!Object.values(zo.Z).some((t=>t===e.action))&&(e.action!==zo.Z.ENTERED_AUTOMATION||function(e){return(e.operator===Vo.f5.ANY||e.operator===Vo.f5.NONE||e.operator===Vo.f5.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[Vo.Bt.Email]:function(e){return!!Object.values(Vo.zd).some((t=>t===e.action))&&(e.action===Vo.zd.CLICKED_ANY||(e.action===Vo.zd.CLICKED?!!e.newsletter_id:[Vo.zd.OPENED,Vo.zd.MACHINE_OPENED,Vo.zd.WAS_SENT].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[Vo.zd.OPENS_ABSOLUTE_COUNT,Vo.zd.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?Xo(e)&&!!e.opens&&!!e.operator:Vo.zd.NUMBER_RECEIVED===e.action?Xo(e)&&!!e.emails&&!!e.operator:e.action===Vo.zd.NUMBER_OF_CLICKS&&Xo(e)&&!!e.clicks&&!!e.operator))},[Vo.Bt.WooCommerce]:function(e){return!!Object.values(pr.wq).some((t=>t===e.action))&&(e.action===pr.wq.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator)}(e):e.action===pr.wq.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator)}(e):e.action===pr.wq.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):[pr.wq.NUMBER_OF_ORDERS,pr.wq.NUMBER_OF_ORDERS_WITH_COUPON].includes(e.action)?function(e){return!(!e.number_of_orders_count||!Xo(e)||!e.number_of_orders_type)}(e):e.action===pr.wq.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!Xo(e)||!e.total_spent_type)}(e):e.action===pr.wq.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!Xo(e)||!e.single_order_value_type)}(e):e.action===pr.wq.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!Xo(e))}(e):e.action===pr.wq.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!Xo(e))}(e):e.action===pr.wq.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!Xo(e))}(e):e.action===pr.wq.PURCHASE_DATE?dr(e):e.action===pr.wq.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&Xo(e))}(e):e.action===pr.wq.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,Qo.J)(e.operator,Vo.f5)||!Xo(e))}(e):e.action===pr.wq.FIRST_ORDER?dr(e):e.action===pr.wq.PURCHASED_WITH_ATTRIBUTE?function(e){return!!(e.operator&&e.attribute_type&&("taxonomy"!==e.attribute_type||void 0!==e.attribute_taxonomy_slug&&Array.isArray(e.attribute_term_ids)&&0!==e.attribute_term_ids.length)&&("local"!==e.attribute_type||e.attribute_local_name&&0!==e.attribute_local_name.length&&Array.isArray(e.attribute_local_values)&&0!==e.attribute_local_values.length))}(e):[pr.wq.CUSTOMER_IN_POSTAL_CODE,pr.wq.CUSTOMER_IN_CITY].includes(e.action)?_r(e):e.action!==pr.wq.PURCHASED_TAG||function(e){return!(void 0===e.tag_ids||0===e.tag_ids.length||!e.operator)}(e))},[Vo.Bt.WordPressRole]:function(e){return e.action&&e.action!==Vo.jx.WORDPRESS_ROLE?e.action===Vo.jx.MAILPOET_CUSTOM_FIELD?function(e){const t=Ar[e.custom_field_type];return!!t&&t(e)}(e):e.action===Vo.jx.SUBSCRIBER_SCORE?function(e){if(e.operator===vr.HIGHER_THAN||e.operator===vr.LOWER_THAN||e.operator===vr.EQUALS||e.operator===vr.NOT_EQUALS){const t=Number(e.value),a=Number(parseFloat(e.value));return!Number.isNaN(t)&&!Number.isNaN(a)&&t>=0&&t<=100}return e.operator===vr.UNKNOWN||e.operator===vr.NOT_UNKNOWN}(e):e.action===Vo.jx.SUBSCRIBED_TO_LIST?function(e){return(e.operator===Vo.f5.ANY||e.operator===Vo.f5.ALL||e.operator===Vo.f5.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===Vo.jx.SUBSCRIBER_TAG?function(e){return Wt.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[Vo.jx.SUBSCRIBER_FIRST_NAME,Vo.jx.SUBSCRIBER_LAST_NAME,Vo.jx.SUBSCRIBER_EMAIL].includes(e.action)?_r(e):[Vo.jx.SUBSCRIBER_LAST_ENGAGEMENT_DATE,Vo.jx.SUBSCRIBER_LAST_PURCHASE_DATE,Vo.jx.SUBSCRIBER_LAST_OPEN_DATE,Vo.jx.SUBSCRIBER_LAST_CLICK_DATE,Vo.jx.SUBSCRIBER_LAST_PAGE_VIEW_DATE,Vo.jx.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?dr(e):e.action===Vo.jx.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===Vo.f5.ANY||e.operator===Vo.f5.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(sr).includes(e.operator)&&dr(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[Vo.Bt.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==pr.hs.MEMBER_OF||!t},[Vo.Bt.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==pr.ht.ACTIVE_SUBSCRIPTIONS||!t}};function Lr(e){return!(e.length<1)&&0===e.map((e=>void 0!==Dr[e.segmentType]&&Dr[e.segmentType](e))).filter((e=>!1===e)).length}let qr,Br;function Wr(){const e=(0,P.Z)((e=>e(Ho.tC).getSegment()),[]),t=(0,P.Z)((e=>e(Ho.tC).getSubscriberCount()),[]),{updateSubscriberCount:a}=(0,fe.Z)(Ho.tC),i=JSON.stringify(e),s=(0,o.useRef)(1),n=(0,o.useRef)(null),r=(0,o.useRef)(!1),l=(0,o.useRef)((0,Aa.debounce)((function e(t){if(r.current)return void(n.current=t);n.current=null,s.current+=1;const i=s.current;r.current=!0,function(e){const t={filters:e.filters,filters_connect:e.filters_connect};return Ra().isEqual(t,qr)?Promise.resolve(Br):(qr={filters:[...e.filters],filters_connect:e.filters_connect},c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"dynamic_segments",action:"getCount",data:e,timeout:2e4}).then((e=>{const{data:t}=e;return Br={count:t.count,errors:void 0},Br})))}(t).then((t=>{if(r.current=!1,n.current)return void e(n.current);if(i!==s.current)return;const o={loading:!1};t&&(o.count=t.count,o.errors=t.errors),a(o)}),(e=>{r.current=!1;const t={},i=e.errors.map((e=>e.message));t.loading=!1,t.count=void 0,t.errors=i,a(t)}))}),2e3,{trailing:!0}));return(0,o.useEffect)((()=>{Lr(e.filters)?(a({loading:!0,count:void 0,errors:void 0}),(0,l.current)(e)):a({count:void 0,loading:!1})}),[e,i,a]),t.errors?(0,p.jsx)("div",{className:"mailpoet-form-field",children:(0,p.jsxs)("span",{className:"mailpoet-form-error-message",children:[c.MailPoet.I18n.t("dynamicSegmentSizeCalculatingTimeout")," ",(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/237-guide-to-subscriber-segmentation?utm_source=plugin&utm_medium=segments",target:"_blank",className:"mailpoet-form-error-message",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("learnMore")})]})}):t.loading||void 0!==t.count?t.loading?(0,p.jsx)("div",{className:"mailpoet-form-field",children:(0,p.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("dynamicSegmentSizeIsCalculated")})}):(0,p.jsx)("div",{className:"mailpoet-form-field",children:(0,p.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("dynamicSegmentSize").replace("%1$d",t.count.toLocaleString())})}):(0,p.jsx)("span",{})}const $r={[Vo.Bt.Automations]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=Yo[t.action];return a?(0,p.jsx)(a,{filterIndex:e}):null},[Vo.Bt.Email]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=tr[t.action];return a?(0,p.jsx)(a,{filterIndex:e}):null},[Vo.Bt.WooCommerce]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),a=br[t.action];return a?(0,p.jsx)(a,{filterIndex:e}):null},[Vo.Bt.WordPressRole]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]);let a;return a=t.action?Or[t.action]:xr,a?(0,p.jsx)(a,{filterIndex:e}):null},[Vo.Bt.WooCommerceMembership]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getMembershipPlans()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.action===pr.hs.MEMBER_OF&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator")}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Do.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectWooMembership"),options:s,value:(0,es.filter)((e=>!!t.plan_ids&&-1!==t.plan_ids.indexOf(e.value)),s),onChange:t=>{a({plan_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-plans"},"select-segment-membership-plan")})]})},[Vo.Bt.WooCommerceSubscription]:function({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.Z)(Ho.tC),s=(0,P.Z)((e=>e(Ho.tC).getSubscriptionProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,o.useEffect)((()=>{t.action===pr.ht.ACTIVE_SUBSCRIPTIONS&&t.operator!==Vo.f5.ANY&&t.operator!==Vo.f5.ALL&&t.operator!==Vo.f5.NONE&&a({operator:Vo.f5.ANY},e)}),[a,t,e]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsxs)(pt.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,p.jsx)("option",{value:Vo.f5.ANY,children:c.MailPoet.I18n.t("anyOf")}),(0,p.jsx)("option",{value:Vo.f5.ALL,children:c.MailPoet.I18n.t("allOf")}),(0,p.jsx)("option",{value:Vo.f5.NONE,children:c.MailPoet.I18n.t("noneOf")})]},"select-operator")}),(0,p.jsx)(Da.Grid.CenteredRow,{children:(0,p.jsx)(Do.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:c.MailPoet.I18n.t("selectWooSubscription"),options:s,value:(0,es.filter)((e=>!!t.product_ids&&-1!==t.product_ids.indexOf(e.value)),s),onChange:t=>{a({product_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-segment-products"},"select-segment-category")})]})}};function Ur({filterIndex:e}){const t=(0,P.Z)((t=>t(Ho.tC).getSegmentFilter(e)),[e]);if(void 0===t||void 0===$r[t.segmentType])return null;const a=$r[t.segmentType];return(0,p.jsx)(a,{filterIndex:e})}function Vr(){const e=(0,P.Z)((e=>e(Ho.tC).getSegment()),[]),t=[Vo.zd.OPENED,Vo.zd.OPENS_ABSOLUTE_COUNT,Vo.zd.MACHINE_OPENED,Vo.zd.MACHINE_OPENS_ABSOLUTE_COUNT];let a=!1;return e.filters.forEach((e=>{t.includes(e.action)&&(a=!0)})),a?(0,p.jsx)("div",{className:"mailpoet-form-field",children:(0,p.jsx)("span",{className:"mailpoet-form-notice-message",children:c.MailPoet.I18n.t("privacyProtectionNotice")})}):(0,p.jsx)("span",{})}const Hr=Wt.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",(()=>null)),zr=Wt.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",(()=>null)),Zr=Wt.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",(()=>(0,p.jsx)("div",{className:"mailpoet-gap"})));function Yr({isNewSegment:e,newsletterId:t}){const a=(0,P.Z)((e=>e(Ho.tC).getSegment()),[]),i=a.filters.length,s=c.MailPoet.capabilities.segmentFilters.value>0&&i>=c.MailPoet.capabilities.segmentFilters.value,n=(0,P.Z)((e=>e(Ho.tC).getAvailableFilters()),[]),r=(0,P.Z)((e=>e(Ho.tC).findFiltersValueForSegment(a)),[a]),l=(0,P.Z)((e=>e(Ho.tC).getSubscriberCount()),[]),d=(0,P.Z)((e=>e(Ho.tC).getErrors()),[]),{updateSegment:m,updateSegmentFilter:u,handleSave:h}=(0,fe.Z)(Ho.tC),[g,_]=(0,o.useState)(!1),f=Wt.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",(()=>{_(!0)}));return(0,p.jsx)("div",{className:"mailpoet-form-container",children:(0,p.jsxs)("form",{children:[d.length>0&&(0,p.jsx)(fa,{errors:d.map((e=>({message:e})))}),(0,p.jsxs)(Wo,{title:(0,Le.__)("Details","mailpoet"),description:(0,Le.__)("What do you want to call this segment?","mailpoet"),children:[(0,p.jsx)($o,{slug:"name",title:(0,Le.__)("Name","mailpoet"),children:(0,p.jsx)(lt.I,{isFullWidth:!0,type:"text",name:"name",id:"field_name",value:a.name||"","data-automation-id":"input-name",onChange:e=>{m({name:e.target.value})},placeholder:(0,Le.__)("Enter name","mailpoet")})}),(0,p.jsx)($o,{slug:"description",title:(0,Le.__)("Description","mailpoet"),description:(0,Le.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,p.jsx)(lt.I,{isFullWidth:!0,name:"description",id:"field_description",value:a.description||"","data-automation-id":"input-description",onChange:e=>{m({description:e.target.value})},placeholder:(0,Le.__)("Enter description","mailpoet")})})]}),(0,p.jsx)(Wo,{title:(0,Le.__)("Conditions","mailpoet"),description:(0,Le.__)("Set your segment constraints","mailpoet"),children:(0,p.jsx)($o,{children:(0,p.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,p.jsx)(Hr,{}),Array.isArray(r)&&r.map(((e,t)=>(0,p.jsxs)(o.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t}`,children:[(0,p.jsx)(zr,{filterRows:r,index:t}),(0,p.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,p.jsx)(Do.ReactSelect,{dimension:"small",placeholder:(0,Le.__)("Select action","mailpoet"),options:n,value:e.filterValue,onChange:e=>{u({segmentType:e.group,action:e.value},t)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==e.index&&(0,p.jsx)(Ur,{filterIndex:e.index})]}),(0,p.jsx)(Zr,{index:t})]},e.index))),(0,p.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,p.jsx)(ge.ZP,{type:"button",variant:"secondary",onClick:e=>{e.preventDefault(),f(a,m)},children:(0,Le.__)("Add a condition","mailpoet")}),(!c.MailPoet.premiumActive||!c.MailPoet.hasValidPremiumKey||c.MailPoet.subscribersLimitReached||s)&&(0,p.jsx)(Uo.x,{text:(0,Le.__)("UPGRADE","mailpoet")}),g&&(0,p.jsx)(ii.Z,{onRequestClose:()=>{_(!1)},data:{capabilities:{segmentFilters:0}},children:(0,Le.__)("Multiple conditions per segment are not available in the free version of the MailPoet plugin.","mailpoet")})]})]})})}),(0,p.jsxs)("div",{className:"mailpoet-admin-fields-footer",children:[(0,p.jsxs)("div",{className:"mailpoet-segments-counter-section",children:[(0,p.jsx)(Wr,{}),(0,p.jsx)(Vr,{})]}),(0,p.jsx)("div",{className:"mailpoet-form-actions",children:(0,p.jsx)(ge.ZP,{variant:"primary",type:"submit",onClick:a=>{a.preventDefault(),h(e,t)},disabled:!Lr(a.filters)||void 0===l.count,children:t?(0,Le.__)("Save and return","mailpoet"):(0,Le.__)("Save","mailpoet")})})]})]})})}function Gr(){const e=(0,ke.$B)(),{pageLoaded:t,pageUnloaded:a}=(0,fe.Z)(Ho.tC),i=(0,P.Z)((e=>e(Ho.tC).getPreviousPage()))||"/",s=(0,ke.TH)(),n=new URLSearchParams(s.search).get("newsletterId")||null;(0,o.useEffect)((()=>(t(e.params.id),()=>{a()})),[e.params.id,t,a]);const r=void 0===e.params.id||Number.isNaN(Number(e.params.id));return(0,p.jsxs)("div",{className:"mailpoet-main-container",children:[(0,p.jsx)(d.Q,{}),(0,p.jsx)(It.B,{}),(0,p.jsx)(kt.m,{heading:e.params.id?(0,Le.__)("Edit segment","mailpoet"):(0,Le.__)("New segment","mailpoet"),headingPrefix:(0,p.jsx)(kt.x,{id:"mailpoet-segments-back-button",href:`#${i}`,label:(0,Le.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,p.jsx)(Yr,{isNewSegment:r,newsletterId:n})]})}Gr.displayName="SegmentEditor";var Kr=a(83200),Qr=a(81922),Jr=a(86339),Xr=a(69138),el=a(36657),tl=a(30550),al=a(96300);var il=a(44603),sl=a(41474);function nl({tab:e,onClick:t}){const a=(0,sl.Y)(Ho.tC).getDynamicSegments(),i=a?a.filter((e=>e.selected)):[],s="trash"!==e.name?[{value:"0",label:(0,Le.__)("Bulk actions","mailpoet")},{label:(0,Le.__)("Trash","mailpoet"),value:"trash"}]:[{value:"0",label:(0,Le.__)("Bulk actions","mailpoet")},{label:(0,Le.__)("Restore","mailpoet"),value:"restore"},{label:(0,Le.__)("Delete permanently","mailpoet"),value:"delete"}];return(0,p.jsx)(il.Z,{multiple:!1,hideLabelFromVision:!0,className:"mailpoet-segments-listing-bulk-actions",label:(0,Le.__)("Bulk actions","mailpoet"),options:s,value:"0",onChange:e=>{0!==i.length&&"0"!==e&&t(i,e)}})}const ol=a(33791).Z;function rl({action:e,selected:t,onClose:a}){if(null===e)return null;let i="",s="",n="";const o=new Intl.ListFormat(Ho.SP.toString(),{style:"long",type:"conjunction"}).format(t.map((({name:e})=>`"${e}"`)));switch(e){case"trash":i=(0,Le._n)("Trash selected segment","Trash selected segments",t.length,"mailpoet"),s=(0,Le.sprintf)((0,Le._n)("Are you sure you want to trash the selected segment %s?","Are you sure you want to trash the selected segments %s?",t.length,"mailpoet"),o),n=(0,Le.__)("Trash","mailpoet");break;case"restore":i=(0,Le._n)("Restore selected segment","Restore selected segments",t.length,"mailpoet"),s=(0,Le.sprintf)((0,Le._n)("Are you sure you want to restore the selected segment %s?","Are you sure you want to restore segments %s?",t.length,"mailpoet"),o),n=(0,Le.__)("Restore","mailpoet");break;case"delete":i=(0,Le._n)("Delete selected segment permanently","Delete selected segments permanently",t.length,"mailpoet"),s=(0,p.jsxs)(p.Fragment,{children:[(0,Le.sprintf)((0,Le._n)("Are you sure you want to delete the selected segment %s permanently?","Are you sure you want to delete the selected segments %s permanently?",t.length,"mailpoet"),o)," ",(0,p.jsx)("strong",{children:(0,Le.__)("This action can not be reversed.","mailpoet")})]}),n=(0,Le.__)("Delete permanently","mailpoet")}return(0,p.jsx)(ol,{className:"mailpoet-confirm-dialog",isOpen:!0,title:i,confirmButtonText:n,__experimentalHideHeader:!1,onConfirm:()=>{!async function(e,t){if(e)try{const a=await c.MailPoet.Ajax.post({api_version:"v1",endpoint:"dynamic_segments",action:"bulk_action",data:{action:e,listing:{selection:t.map((e=>e.id))}}});a.meta.errors&&a.meta.errors.length>0&&a.meta.errors.forEach((e=>{(0,Xr.W)(tl.store).createErrorNotice(e)}));const i=a.meta.count;if(i>0){let t="";switch(e){case"trash":t=(0,Le.sprintf)((0,Le._n)("Segment moved to trash.","%d segments moved to trash.",i,"mailpoet"),i);break;case"delete":t=(0,Le.sprintf)((0,Le._n)("Segment permanently deleted.","%d segments permanently deleted.",i,"mailpoet"),i);break;case"restore":t=(0,Le.sprintf)((0,Le._n)("Segment restored.","%d segments restored.",i,"mailpoet"),i)}(0,Xr.W)(tl.store).createSuccessNotice(t),(0,Xr.W)(Ho.tC).loadDynamicSegments()}}catch(t){if((0,al.q)(t)){let a="";if(t.errors)t.errors.forEach((e=>{(0,Xr.W)(tl.store).createErrorNotice(e.message)}),{explicitDismiss:!0});else{switch(e){case"trash":a=(0,Le.__)("Error moving segment to trash.","mailpoet");break;case"delete":a=(0,Le.__)("Error deleting segment.","mailpoet");break;case"restore":a=(0,Le.__)("Error restoring segment.","mailpoet")}(0,Xr.W)(tl.store).createErrorNotice(a,{explicitDismiss:!0})}}}}(e,t),a()},onCancel:a,children:(0,p.jsx)("p",{children:s})})}var ll=a(14201),dl=a(32770);const cl=window.mailpoet_dynamic_segment_count;function ml(){const{dynamicSegments:e}=(0,P.Z)((e=>({dynamicSegments:e(Ho.tC).getDynamicSegments()}))),t=null!==e&&e.filter((e=>e.selected)).length===e.length&&e.length>0;return(0,p.jsx)("input",{checked:t,type:"checkbox","data-automation-id":"select_all",onChange:()=>{t?(0,Xr.W)(Ho.tC).unselectAllDynamicSections():(0,Xr.W)(Ho.tC).selectAllDynamicSections()}})}const ul=[{key:"checkbox",label:(0,p.jsx)(ml,{}),cellClassName:"mailpoet-listing-checkbox"},{key:"name",label:(0,Le.__)("Segment","mailpoet"),cellClassName:"mailpoet-listing-name",isSortable:!0},{key:"subscribers",label:(0,Le.__)("Number of subscribers","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"subscribed",label:(0,Le.__)("Subscribed","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"updated_at",label:(0,Le.__)("Modified","mailpoet"),cellClassName:"mailpoet-listing-modified-date",isLeftAligned:!1,isSortable:!0},{key:"actions",isLeftAligned:!1}];function pl({tab:e}){const[t,a]=(0,o.useState)(null),[i,s]=(0,o.useState)([]),{dynamicSegments:n,dynamicSegmentsLoading:r,dynamicSegmentsCount:l}=(0,P.Z)((e=>({dynamicSegments:e(Ho.tC).getDynamicSegments(),dynamicSegmentsLoading:e(Ho.tC).getDynamicSegmentsLoading(),dynamicSegmentsCount:e(Ho.tC).getDynamicSegmentsCount()}))),d=(0,ll.FJ)(),[m,u,h]=function(e=""){const[t,a]=(0,o.useState)(e),[i,s]=(0,o.useState)(e),n=(0,dl.Z)(s,250);return(0,o.useEffect)((()=>{n(t)}),[t,n]),[t,a,i]}(d.search??"");(0,o.useEffect)((()=>{(0,ll.kh)({search:h,offset:0})}),[h]),(0,o.useEffect)((()=>{(0,Xr.W)(Ho.tC).loadDynamicSegments(d)}),[d]);const g=((0,o.useMemo)((()=>{const e={all:[],trash:[]};return(n??[]).forEach((t=>{null===t.deleted_at?e.all.push(t):e.trash.push(t)})),e}),[n])[e.name]??[]).map((t=>function(e,t,a){const i="trash"!==t?[{key:"duplicate",control:{title:(0,Le.__)("Duplicate","mailpoet"),icon:null,onClick:()=>{!async function(e){try{const t=(await c.MailPoet.Ajax.post({api_version:"v1",endpoint:"dynamic_segments",action:"duplicate",data:{id:e.id}})).data,a=(0,Le.sprintf)((0,Le.__)('Segment "%s" has been duplicated.',"mailpoet"),t.name);(0,Xr.W)(tl.store).createSuccessNotice(a),(0,Xr.W)(Ho.tC).loadDynamicSegments()}catch(e){(0,al.q)(e)&&e.errors.forEach((e=>{(0,Xr.W)(tl.store).createErrorNotice(e.message)}))}}(e)}}},{key:"trash",control:{title:(0,Le.__)("Move to trash","mailpoet"),icon:null,onClick:()=>a("trash",e)}}]:[{key:"restore",control:{title:(0,Le.__)("Restore","mailpoet"),icon:null,onClick:()=>a("restore",e)}},{key:"delete",control:{title:(0,Le.__)("Delete permanently","mailpoet"),icon:null,onClick:()=>a("delete",e)}}];return[{value:null,display:(0,p.jsx)("input",{type:"checkbox",checked:e?.selected??!1,onChange:()=>{e?.selected?(0,Xr.W)(Ho.tC).unselectDynamicSection(e):(0,Xr.W)(Ho.tC).selectDynamicSection(e)}})},{value:e.name,display:(0,p.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_name_${e.id}`,children:[(0,p.jsx)(Ie.Link,{to:`${el.jY}/${e.id}`,children:e.name}),e.description&&(0,p.jsx)("div",{children:e.description})]})},e.is_plugin_missing?{value:e.missing_plugin_message,display:(0,p.jsx)("div",{"data-automation-id":`mailpoet_dynamic_segment_plugin_missing_message_${e.id}`,children:e.missing_plugin_message.message})}:{value:e.count_all,display:(0,p.jsx)("div",{"data-automation-id":`mailpoet_dynamic_segment_count_all_${e.id}`,children:e.count_all})},e.is_plugin_missing?{value:null,display:null}:{value:e.count_subscribed,display:"0"===e.count_subscribed?e.count_subscribed:(0,p.jsx)(ge.ZP,{"data-automation-id":`mailpoet_dynamic_segment_count_subscribed_${e.id}`,className:"mailpoet-listing-text-right-align",variant:"link",href:e.subscribers_url,children:e.count_subscribed})},{value:e.created_at,display:(0,p.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_created_at_${e.id}`,children:[c.MailPoet.Date.short(e.created_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.created_at)]})},{value:null,display:(0,p.jsxs)("div",{className:"mailpoet-listing-actions-cell","data-automation-id":`mailpoet_dynamic_segment_actions_${e.id}`,children:[(0,p.jsx)(ge.ZP,{variant:"tertiary",href:e.subscribers_url,children:(0,Le.__)("View subscribers","mailpoet")}),e.is_plugin_missing?(0,p.jsx)(ge.ZP,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",disabled:!0,children:(0,Le.__)("Edit","mailpoet")}):(0,p.jsx)(ge.ZP,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",href:`#${el.jY}/${e.id}`,children:(0,Le.__)("Edit","mailpoet")}),(0,p.jsx)(M.Z,{className:"mailpoet-listing-more-button",label:(0,Le.__)("More","mailpoet"),icon:N.Z,controls:i.map((({control:e})=>e)),popoverProps:{position:"bottom left"}})]})}]}(t,e.name,((e,t)=>{s([t]),a(e)})))),_={orderby:d.sort_by,order:d.sort_order,page:d.offset/d.limit+1,per_page:d.limit,paged:d.offset/d.limit+1};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-segments-listing-header",children:[(0,p.jsx)(nl,{tab:e,onClick:(e,t)=>{s(e),a(t)}}),(0,p.jsx)(Jr.Z,{className:"mailpoet-segments-listing-search",placeholder:(0,Le.__)("Search","mailpoet"),onChange:u,value:m})]}),(0,p.jsx)(Qr.Z,{className:"mailpoet-listing-card mailpoet-segments-listing",title:"",isLoading:r.value,headers:ul,rows:g,onQueryChange:e=>t=>{"paged"===e&&(0,ll.kh)({offset:d.limit*(t-1)}),"per_page"===e&&(0,ll.kh)({limit:parseInt(t,10),offset:0}),"sort"===e&&(0,ll.kh)({offset:0,sort_by:t,sort_order:d.sort_by===t&&"desc"===d.sort_order?"asc":"desc"})},query:_,rowKey:(e,t)=>n[t].id,rowsPerPage:d.limit,totalRows:l??cl,showMenu:!1}),(0,p.jsx)(rl,{action:t,selected:i,onClose:()=>a(null)})]})}const hl=[{name:"all",title:(0,Le.__)("All","mailpoet"),className:"mailpoet-tab-all"},{name:"trash",title:(0,Le._x)("Trash","noun","mailpoet"),className:"mailpoet-tab-trash"}];function gl(){const e=(0,ll.FJ)(),{dynamicSegmentsGroups:t}=(0,P.Z)((e=>({dynamicSegments:e(Ho.tC).getDynamicSegments(),dynamicSegmentsGroups:e(Ho.tC).getDynamicSegmentsGroups()}))),a=(0,o.useMemo)((()=>hl.map((e=>{const a=t?.find((t=>e.name===t.name)),i=a?.count??0;return{name:e.name,title:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{children:e.title}),i>0&&(0,p.jsx)("span",{className:"count",children:i})]}),className:e.className}}))),[t]),i=(0,o.useCallback)((e=>(0,p.jsx)(pl,{tab:e})),[]);return(0,p.jsx)(Kr.Z,{className:"mailpoet-filter-tab-panel",tabs:a,initialTabName:e.group,onSelect:e=>{(0,ll.kh)({group:e,offset:0})},children:i},e.group)}function _l(){const{notices:e}=(0,P.Z)((e=>({notices:e(tl.store).getNotices()})),[]),{removeNotice:t}=(0,fe.Z)(tl.store),a=e.filter((({isDismissible:e,type:t})=>e&&"default"===t)),i=e.filter((({isDismissible:e,type:t})=>!e&&"default"===t));return(0,p.jsxs)(p.Fragment,{children:[i.reverse().map((({id:e,status:t,content:a,__unstableHTML:i})=>(0,p.jsx)(u.q,{renderInPlace:!0,type:t,timeout:!1,children:i??(0,p.jsx)("p",{children:a})},e))),a.reverse().map((({id:e,status:a,content:i,__unstableHTML:s})=>(0,p.jsx)(u.q,{type:a,renderInPlace:!0,timeout:!1,closable:!0,onClose:()=>t(e),children:s??(0,p.jsx)("p",{children:i})},e)))]})}function fl(){return(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(d.Q,{hideScreenOptions:!0}),(0,p.jsx)(_l,{}),(0,p.jsx)(kt.m,{heading:(0,Le.__)("Segments","mailpoet"),children:(0,p.jsx)(ge.ZP,{href:`#${el.$W}`,icon:He.R,variant:"primary","data-automation-id":"new-segment",className:"mailpoet-add-new-button",children:(0,Le.__)("New segment","mailpoet")})}),(0,p.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,p.jsx)(Ve,{subscribersInPlan:c.MailPoet.subscribersCount,subscribersInPlanLimit:c.MailPoet.subscribersLimit,design:"new"}),(0,p.jsx)(Be,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at,design:"new"})]}),(0,p.jsx)(w,{}),(0,p.jsx)(gl,{})]})}var bl=a(5600);const xl=[{name:(0,Le.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have subscribed to your emails within the last 30 days.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"subscribedDate",operator:"inTheLast",value:"30"}]},{name:(0,Le.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 30 days.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"30"}]},{name:(0,Le.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 3 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"90"}]},{name:(0,Le.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have interacted with your emails or made at least one purchase, and received emails from you in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"inTheLast",value:"180"}],filtersConnect:Vo.cK.OR},{name:(0,Le.__)("Unengaged Subscribers","mailpoet"),slug:"unengaged-subscribers",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who haven’t interacted with your emails, haven’t made a purchase, or haven’t visited your page in the last 6 months.","mailpoet"),filters:[{segmentType:"userRole",action:"lastEngagementDate",operator:"notInTheLast",value:"180"},{segmentType:"userRole",action:"subscribedDate",operator:"notInTheLast",value:"210"},{segmentType:"email",action:"numberReceived",operator:"more",emails:"9",timeframe:Vo.u4.ALL_TIME}],isEssential:!0},{name:(0,Le.__)("First-Time Buyers","mailpoet"),slug:"first-time-buyers",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who have made their first purchase in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:"firstOrder",operator:sr.IN_THE_LAST,value:"30"}],isEssential:!0},{name:(0,Le.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Vo.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,Le.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Vo.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,Le.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Vo.u4.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,Le.__)("Win-Back","mailpoet"),slug:"win-back",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who have previously purchased, but haven’t made a purchase in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"userRole",action:"lastPurchaseDate",operator:"notInTheLast",value:"180"}]},{name:(0,Le.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:Vo.r9.PURCHASE_HISTORY,description:(0,Le.__)("Customers who haven’t made a purchase in the last 9 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"userRole",action:"lastPurchaseDate",operator:"notInTheLast",value:"270"}]},{name:(0,Le.__)("Clickers","mailpoet"),slug:"clickers",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who regularly click on your emails in the last 90 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Vo.u4.IN_THE_LAST,clicks:"2",days:"90"}],isEssential:!1},{name:(0,Le.__)("Non-Openers","mailpoet"),slug:"non-openers",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have received but haven’t opened an email in the last 90 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"numberReceived",operator:"more",timeframe:Vo.u4.IN_THE_LAST,emails:"0",days:"90"},{segmentType:"email",action:"opensAbsoluteCount",operator:"equals",timeframe:Vo.u4.IN_THE_LAST,opens:"0",days:"90"}]},{name:(0,Le.__)("Recent Clickers","mailpoet"),slug:"recent-clickers",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have clicked on an email in the last 7 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Vo.u4.IN_THE_LAST,clicks:"0",days:"7"}],isEssential:!1},{name:(0,Le.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:Vo.r9.ENGAGEMENT,description:(0,Le.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:Vo.u4.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,Le.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:Vo.r9.SHOPPING_BEHAVIOR,description:(0,Le.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:Vo.u4.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]},{name:(0,Le.__)("Used a discount code","mailpoet"),slug:"used-a-discount-code",category:Vo.r9.SHOPPING_BEHAVIOR,description:(0,Le.__)("Customers who made a purchase with a coupon code in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:pr.wq.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:0,timeframe:Vo.u4.IN_THE_LAST,days:"30"}],isEssential:!1},{name:(0,Le.__)("Frequently uses discounts","mailpoet"),slug:"frequently-uses-discounts",category:Vo.r9.SHOPPING_BEHAVIOR,description:(0,Le.__)("Customers who have regularly used coupons in the last 90 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:pr.wq.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:2,timeframe:Vo.u4.IN_THE_LAST,days:"90"}],isEssential:!1}],vl=[{slug:Vo.r9.ENGAGEMENT,name:(0,Le.__)("Engagement","mailpoet")},{slug:Vo.r9.PURCHASE_HISTORY,name:(0,Le.__)("Purchase History","mailpoet")},{slug:Vo.r9.SHOPPING_BEHAVIOR,name:(0,Le.__)("Shopping Behavior","mailpoet")}];function jl(e){const t=vl.find((t=>t.slug===e));return t?t.name:null}var yl=a(13572);const wl=[{name:"all",title:(0,p.jsx)(yl.J$,{title:(0,Le.__)("All","mailpoet"),count:xl.length})}];function Sl(){const e=(0,P.Z)((e=>e(Ho.tC).getErrors()),[]),{createFromTemplate:t}=(0,fe.Z)(Ho.tC),a=()=>{c.MailPoet.trackEvent("Segments > New empty segment")};return(0,p.jsxs)("div",{className:"mailpoet-main-container",children:[(0,p.jsx)(It.B,{}),(0,p.jsx)(d.Q,{}),(0,p.jsxs)(kt.m,{className:"mailpoet-templates-header",heading:(0,Le.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,p.jsx)(kt.x,{href:"#/",label:(0,Le.__)("Segments list","mailpoet"),"aria-label":(0,Le.__)("Navigate to the segments list page","mailpoet")}),children:[(0,p.jsx)(bl.Z,{label:(0,Le.__)("Search segment templates","mailpoet"),onChange:()=>null}),(0,p.jsx)(ge.ZP,{variant:"secondary",href:`#${el.yK}`,"data-automation-id":"new-custom-segment",onClick:()=>{a()},children:(0,Le.__)("Create custom segment","mailpoet")})]}),e.length>0&&(0,p.jsx)(fa,{errors:e.map((e=>({message:e})))}),(0,p.jsx)(yl.x4,{tabs:wl,children:e=>(0,p.jsx)(yl.rj,{children:xl.filter((t=>"all"===e.name||t.category===e.name)).map((e=>(0,p.jsx)(yl.ck,{name:e.name,description:e.description,category:jl(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug)))})}),(0,p.jsxs)(yl.$_,{children:[(0,p.jsx)("p",{children:(0,Le.__)("Want to set your own conditions?","mailpoet")}),(0,p.jsx)(ge.ZP,{variant:"link",href:`#${el.yK}`,onClick:()=>{a()},children:(0,Le.__)("Create custom segment","mailpoet")})]})]})}vl.forEach((e=>{const t=xl.filter((t=>t.category===e.slug)).length;wl.push({name:e.slug,title:(0,p.jsx)(yl.J$,{title:e.name,count:t})})}));const Pl=document.getElementById("dynamic_segments_container");function Ml(){const{setPreviousPage:e}=(0,fe.Z)(Ho.tC),t=(0,ke.k6)(),a=(0,o.useRef)(t.location.pathname);return(0,o.useEffect)((()=>t.listen((t=>{e(a.current),a.current=t.pathname}))),[t,e]),null}function Nl(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(Ml,{}),(0,p.jsx)(m.w,{}),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:el.yK,component:(0,r.withBoundary)(Gr)}),(0,p.jsx)(ke.AW,{path:`${el.jY}/:id`,component:(0,r.withBoundary)(Gr)}),(0,p.jsx)(ke.AW,{path:el.$W,component:(0,r.withBoundary)(Sl)}),(0,p.jsx)(ke.AW,{path:"*",component:(0,r.withBoundary)(fl)})]})]})})}Pl&&((0,r.registerTranslations)(),(0,Ho.MT)(),(0,n.s)(Pl).render((0,p.jsx)(Nl,{})));const Cl=()=>{c.MailPoet.trackEvent("Forms > Add New"),setTimeout((()=>{window.location=window.mailpoet_form_template_selection_url}),200)};function Il(){const[e,t]=(0,o.useState)(!1);return(0,p.jsx)(d.Q,{children:(0,p.jsx)(qe.z,{onClick:()=>{t(!0),Cl()},withSpinner:e,automationId:"create_new_form",variant:"secondary",iconStart:He.R,children:c.MailPoet.I18n.t("new")})})}Il.displayName="FormsHeading";const kl=[{name:"name",label:c.MailPoet.I18n.t("formName"),sortable:!0},{name:"segments",label:c.MailPoet.I18n.t("segments")},{name:"type",label:c.MailPoet.I18n.t("type")},{name:"status",label:c.MailPoet.I18n.t("status")},{name:"updated_at",label:c.MailPoet.I18n.t("updatedAt"),sortable:!0}],Tl={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneFormTrashed"):c.MailPoet.I18n.t("multipleFormsTrashed").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneFormDeleted"):c.MailPoet.I18n.t("multipleFormsDeleted").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?c.MailPoet.I18n.t("oneFormRestored"):c.MailPoet.I18n.t("multipleFormsRestored").replace("%1$d",t.toLocaleString()),c.MailPoet.Notice.success(a)},onNoItemsFound:()=>(0,p.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("noItemsFound")}),(0,p.jsx)(r.Button,{onClick:Cl,automationId:"add_new_form",iconStart:He.R,children:c.MailPoet.I18n.t("new")})]})},El=[{name:"trash",label:c.MailPoet.I18n.t("moveToTrash"),onSuccess:Tl.onTrash}],Al=[{name:"edit",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("edit"),link:function(e){return(0,p.jsx)("a",{href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:c.MailPoet.I18n.t("edit")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:c.MailPoet.I18n.t("duplicate"),onClick:function(e,t){return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"duplicate",data:{id:e.id}}).done((e=>{const a=e.data.name?e.data.name:c.MailPoet.I18n.t("noName");c.MailPoet.Notice.success(c.MailPoet.I18n.t("formDuplicated").replace("%1$s",(0,xo.r)(a))),t()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class Rl extends o.Component{updateStatus=(e,t)=>{t.persist(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"setStatus",data:{id:Number(t.target.getAttribute("data-id")),status:e?"enabled":"disabled"}}).done((e=>{"enabled"===e.data.status&&c.MailPoet.Notice.success(c.MailPoet.I18n.t("formActivated"))})).fail((a=>{c.MailPoet.Notice.showApiErrorNotice(a),t.target.checked=!e}))};isItemInactive=e=>"disabled"===e.status;renderStatus(e){return(0,p.jsxs)("div",{children:[(0,p.jsx)(ti.Z,{onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"enabled"===e.status}),(0,p.jsxs)("p",{children:[c.MailPoet.I18n.t("signups"),": ",e.signups.toLocaleString()]})]})}renderItem=(e,t)=>{null===e.settings&&c.MailPoet.Notice.error(c.MailPoet.I18n.t("formSettingsCorrupted").replace("%1$s",(0,xo.r)(e.name)).replace("[link]",`<a class="mailpoet-link" href="admin.php?page=mailpoet-form-editor&id=${parseInt(e.id,10)}">`).replace("[/link]","</a>"));const a=ie()("manage-column","column-primary","has-row-actions"),i=window.mailpoet_segments.filter((t=>-1!==Ee().inArray(t.id,e.segments))),s=function(e){const t=[];return"1"===e?.form_placement?.fixed_bar?.enabled&&t.push(c.MailPoet.I18n.t("placeFixedBarFormOnPages")),"1"===e?.form_placement?.below_posts?.enabled&&t.push(c.MailPoet.I18n.t("placeFormBellowPages")),"1"===e?.form_placement?.popup?.enabled&&t.push(c.MailPoet.I18n.t("placePopupFormOnPages")),"1"===e?.form_placement?.slide_in?.enabled&&t.push(c.MailPoet.I18n.t("placeSlideInFormOnPages")),t.length>0?t.join(", "):c.MailPoet.I18n.t("placeFormOthers")}(e.settings);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("td",{className:a,children:[(0,p.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:e.name?e.name:`(${c.MailPoet.I18n.t("noName")})`}),t]}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("segments"),children:(0,p.jsx)(Es.Eg,{segments:i,dimension:"large",children:"user"===e.settings?.segments_selected_by&&(0,p.jsx)("span",{className:"mailpoet-tags-prefix",children:c.MailPoet.I18n.t("userChoice")})})}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("type"),children:s}),(0,p.jsx)("td",{className:"column","data-colname":c.MailPoet.I18n.t("status"),children:this.renderStatus(e)}),(0,p.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":c.MailPoet.I18n.t("updatedAt"),children:[c.MailPoet.Date.short(e.updated_at),(0,p.jsx)("br",{}),c.MailPoet.Date.time(e.updated_at)]})]})};render(){return(0,p.jsxs)("div",{className:"mailpoet-listing-no-actions-on-mobile",children:[(0,p.jsx)(Il,{}),(0,p.jsx)(Fe.N,{limit:window.mailpoet_listing_per_page,className:"mailpoet-forms-listing",location:this.props.location,params:this.props.match.params,messages:Tl,search:!1,endpoint:"forms",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:kl,bulk_actions:El,item_actions:Al})]})}}Rl.propTypes={location:Re().object.isRequired,match:Re().shape({params:Re().object}).isRequired},Rl.displayName="FormList";const Fl=Fn(Rl);function Ol(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsx)(ke.AW,{path:"*",render:(0,r.withBoundary)(Fl)})]})})}const Dl=document.getElementById("forms_container");function Ll(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("knowledgeBaseIntro")}),(0,p.jsxs)("ul",{className:"mailpoet-text-links",children:[(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/116-common-problems",children:"Common Problems"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/165-newsletters",children:"Newsletters"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/156-migration-questions",children:"Migration Questions"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/149-sending-methods",children:"Sending Methods"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/139-subscription-forms",children:"Subscription Forms"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/114-getting-started",children:"Getting Started"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/123-newsletter-designer",children:"Newsletter Designer"})}),(0,p.jsx)("li",{children:(0,p.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/121-subscribers-and-lists",children:"Subscribers and Lists"})})]}),(0,p.jsx)(qe.z,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:c.MailPoet.I18n.t("knowledgeBaseButton")})]})}Dl&&((0,r.registerTranslations)(),(0,n.s)(Dl).render((0,p.jsx)(Ol,{})));var ql=a(39425);function Bl(e){e.target.select()}function Wl(e,t){if(ut.default.isObject(e)){const a=Object.keys(e).map((t=>`${t}: ${e[t]}`));return(0,p.jsx)("textarea",{readOnly:!0,id:t,onFocus:Bl,value:a.join("\n"),style:{width:"100%",height:"400px"}})}return(0,p.jsx)("p",{children:c.MailPoet.I18n.t("systemInfoDataError")})}function $l(){const e="mailpoet-system-info",t=window.systemInfoData;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,p.jsx)("p",{children:c.MailPoet.I18n.t("systemInfoIntro")})}),Wl(t,e),(0,p.jsx)(ql.m,{variant:"secondary",targetId:e})]})}function Ul(e){return(0,p.jsx)("table",{className:"widefat fixed",style:{maxWidth:e.max_width},children:(0,p.jsx)("tbody",{children:e.rows.map((e=>(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{className:"row-title",children:e.key}),(0,p.jsx)("td",{children:e.value})]},`row_${e.key}`)))})})}function Vl(e){return(0,p.jsx)("span",{children:!0===e.children&&e.truthy||!1===e.children&&e.falsy||e.unknown})}function Hl(e){const t=e.status_data,a={active:c.MailPoet.I18n.t("running"),inactive:c.MailPoet.I18n.t("cronWaiting")},i=Array.isArray(t.last_error)?(0,p.jsx)(p.Fragment,{children:t.last_error.map((e=>(0,p.jsxs)("div",{children:[e.worker,": ",(0,p.jsx)("i",{children:e.message})]},e.worker)))}):t.last_error;return(0,p.jsxs)("div",{children:[(0,p.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusCronStatusTitle")}),(0,p.jsx)(Ul,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("accessible"),value:(0,p.jsx)(Vl,{children:t.accessible})},{key:c.MailPoet.I18n.t("status"),value:a[t.status]?a[t.status]:c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastUpdated"),value:t.updated_at?c.MailPoet.Date.full(1e3*t.updated_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastRunStarted"),value:t.run_accessed_at?c.MailPoet.Date.full(1e3*t.run_started_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastRunCompleted"),value:t.run_completed_at?c.MailPoet.Date.full(1e3*t.run_completed_at):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("lastSeenError"),value:i||c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("lastSeenErrorDate"),value:t.last_error_date?c.MailPoet.Date.full(1e3*t.last_error_date):c.MailPoet.I18n.t("unknown")}]})]})}function zl(e){let t=e.task.scheduled_at;t&&(t=(0,As.default)(t,"yyyy-MM-dd HH:mm:ss",new Date));const a=(0,As.default)(e.task.updated_at,"yyyy-MM-dd HH:mm:ss",new Date);return(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{className:"column column-primary",children:e.task.id}),(0,p.jsx)("td",{className:"column",children:e.task.type}),(0,p.jsx)("td",{className:"column",children:e.task.newsletter?(0,p.jsx)("a",{href:e.task.newsletter.preview_url,"data-newsletter-id":e.task.newsletter.newsletter_id,"data-queue-id":e.task.newsletter.queue_id,target:"_blank",rel:"noopener noreferrer",children:e.task.newsletter.subject||c.MailPoet.I18n.t("preview")}):c.MailPoet.I18n.t("none")}),(0,p.jsx)("td",{className:"column",children:e.task.priority}),e.show_scheduled_at?(0,p.jsx)("td",{className:"column-date",children:(0,p.jsx)("abbr",{children:`${c.MailPoet.Date.short(t)} ${c.MailPoet.Date.time(t)}`})}):null,(0,p.jsx)("td",{className:"column-date",children:(0,p.jsx)("abbr",{children:`${c.MailPoet.Date.short(a)} ${c.MailPoet.Date.time(a)}`})})]})}function Zl(e){return(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{className:"row-title",children:"Id"}),(0,p.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("type")}),(0,p.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("email")}),(0,p.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("priority")}),e.show_scheduled_at?(0,p.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("scheduledAt")}):null,(0,p.jsx)("th",{className:"row-title",children:c.MailPoet.I18n.t("updatedAt")})]})}function Yl(e){const t=e.show_scheduled_at?6:5;return(0,p.jsxs)("table",{className:"widefat fixed striped",children:[(0,p.jsx)("thead",{children:(0,p.jsx)(Zl,{show_scheduled_at:e.show_scheduled_at})}),(0,p.jsx)("tbody",{children:e.tasks.length?e.tasks.map((t=>(0,p.jsx)(zl,{task:t,show_scheduled_at:e.show_scheduled_at},t.id))):(0,p.jsx)("tr",{className:"mailpoet-listing-no-items",children:(0,p.jsx)("td",{colSpan:t,children:c.MailPoet.I18n.t("nothingToShow")})})}),(0,p.jsx)("tfoot",{children:(0,p.jsx)(Zl,{show_scheduled_at:e.show_scheduled_at})})]})}function Gl(e){const t=e.status_data;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusQueueTitle")}),(0,p.jsx)(Ul,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("status"),value:"paused"===t.status?c.MailPoet.I18n.t("paused"):c.MailPoet.I18n.t("running")},{key:c.MailPoet.I18n.t("startedAt"),value:t.started?c.MailPoet.Date.full(1e3*t.started):c.MailPoet.I18n.t("unknown")},{key:c.MailPoet.I18n.t("sentEmails"),value:t.sent||0},{key:c.MailPoet.I18n.t("retryAttempt"),value:t.retry_attempt||c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("retryAt"),value:t.retry_at?c.MailPoet.Date.full(1e3*t.retry_at):c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("error"),value:t.error?t.error.error_message:c.MailPoet.I18n.t("none")},{key:c.MailPoet.I18n.t("totalCompletedTasks"),value:t.tasksStatusCounts.completed},{key:c.MailPoet.I18n.t("totalRunningTasks"),value:t.tasksStatusCounts.running},{key:c.MailPoet.I18n.t("totalPausedTasks"),value:t.tasksStatusCounts.paused},{key:c.MailPoet.I18n.t("totalScheduledTasks"),value:t.tasksStatusCounts.scheduled}]}),(0,p.jsx)("h5",{children:c.MailPoet.I18n.t("scheduledTasks")}),(0,p.jsx)(Yl,{show_scheduled_at:!0,tasks:t.latestTasks.filter((e=>"scheduled"===e.status))}),(0,p.jsx)("h5",{children:c.MailPoet.I18n.t("runningTasks")}),(0,p.jsx)(Yl,{tasks:t.latestTasks.filter((e=>null===e.status))}),(0,p.jsx)("h5",{children:c.MailPoet.I18n.t("completedTasks")}),(0,p.jsx)(Yl,{tasks:t.latestTasks.filter((e=>"completed"===e.status))})]})}function Kl({version:e,storage:t,latestTrigger:a,latestCompletedTrigger:i,latestCompletedRun:s}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h4",{children:c.MailPoet.I18n.t("actionSchedulerStatus")}),(0,p.jsx)(Ul,{max_width:"400px",rows:[{key:c.MailPoet.I18n.t("version"),value:e},{key:c.MailPoet.I18n.t("storage"),value:t},{key:c.MailPoet.I18n.t("latestActionSchedulerTrigger"),value:c.MailPoet.Date.full(st().utc(a).local())},{key:c.MailPoet.I18n.t("latestActionSchedulerCompletedTrigger"),value:c.MailPoet.Date.full(st().utc(i).local())},{key:c.MailPoet.I18n.t("latestActionSchedulerCompletedRun"),value:c.MailPoet.Date.full(st().utc(s).local())}]})]})}function Ql(e,t,a,i,s){const n=e?"success":"error";let o=e?t:a;return i&&(o=f()(o,/\[link\](.*?)\[\/link\]/g,(e=>(0,p.jsx)("a",{className:"mailpoet-text-link",href:i,children:e},"kb-link")))),(0,p.jsxs)("div",{className:`mailpoet_notice notice inline notice-${n}`,children:[(0,p.jsx)("p",{children:o}),s?(0,p.jsx)("p",{children:(0,p.jsx)("i",{children:s})}):null]})}function Jl(e){const t=e.cron.isReachable,a=e.cron.url,i=`${c.MailPoet.I18n.t("systemStatusConnectionUnsuccessful")} ${c.MailPoet.I18n.t("systemStatusCronConnectionUnsuccessfulInfo")}`,s=c.MailPoet.I18n.t("systemStatusConnectionSuccessful"),n=t?null:e.cron.pingResponse;return(0,p.jsxs)("div",{children:[(0,p.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusCronTitle")}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{className:"mailpoet-text-link",href:a,target:"_blank",rel:"noopener noreferrer",children:a})}),Ql(t,s,i,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function Xl(e){const t=e.mss.enabled?`${c.MailPoet.I18n.t("systemStatusConnectionUnsuccessful")} ${c.MailPoet.I18n.t("systemStatusMSSConnectionUnsuccessfulInfo")}`:c.MailPoet.I18n.t("systemStatusMSSConnectionCanNotConnect"),a=e.mss.enabled?c.MailPoet.I18n.t("systemStatusConnectionSuccessful"):c.MailPoet.I18n.t("systemStatusMSSConnectionCanConnect");return(0,p.jsxs)("div",{children:[(0,p.jsx)("h4",{children:c.MailPoet.I18n.t("systemStatusMSSTitle")}),Ql(e.mss.isReachable,a,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function ed(){const e=window.systemStatusData,t=window.actionSchedulerData;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,p.jsx)("p",{children:e.mss.enabled?c.MailPoet.I18n.t("systemStatusIntroCronMSS"):c.MailPoet.I18n.t("systemStatusIntroCron")})}),Jl(e),Xl(e),(0,p.jsx)(Hl,{status_data:e.cronStatus}),(0,p.jsx)(Kl,{...t}),t?(0,p.jsx)(Gl,{status_data:e.queueStatus}):null]})}function td(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent1")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent2")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("yourPrivacyContent3")}),(0,p.jsx)(qe.z,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:c.MailPoet.I18n.t("yourPrivacyButton")})]})}function ad(){return(0,p.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,p.jsx)(d.D,{}),(0,p.jsx)(m.w,{}),(0,p.jsxs)(In.t,{activeKey:"knowledgeBase",children:[(0,p.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabKnowledgeBaseTitle"),children:(0,p.jsx)(Ll,{})},"knowledgeBase"),(0,p.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabSystemStatusTitle"),children:(0,p.jsx)(ed,{})},"systemStatus"),(0,p.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabSystemInfoTitle"),children:(0,p.jsx)($l,{})},"systemInfo"),(0,p.jsx)(r.Tab,{title:c.MailPoet.I18n.t("tabYourPrivacyTitle"),children:(0,p.jsx)(td,{})},"yourPrivacy")]})]})}Ul.propTypes={max_width:Re().string,rows:Re().arrayOf(Re().shape({key:Re().string.isRequired,value:Re().oneOfType([Re().string,Re().number,Re().element]).isRequired})).isRequired},Ul.defaultProps={max_width:"auto"},Vl.propTypes={truthy:Re().string,falsy:Re().string,unknown:Re().string,children:Re().bool},Vl.defaultProps={truthy:(0,Le.__)("Yes","mailpoet"),falsy:(0,Le.__)("No","mailpoet"),unknown:(0,Le.__)("Unknown","mailpoet"),children:null},Hl.propTypes={status_data:Re().shape({accessible:Re().bool,last_error_date:Re().string,status:Re().string,updated_at:Re().number,run_accessed_at:Re().number,run_completed_at:Re().number,run_started_at:Re().number,last_error:Re().oneOfType([Re().string,Re().array])}).isRequired},zl.propTypes={show_scheduled_at:Re().bool,task:Re().shape({id:Re().number.isRequired,type:Re().string.isRequired,priority:Re().number.isRequired,updated_at:Re().string.isRequired,scheduled_at:Re().string,status:Re().string,newsletter:Re().shape({newsletter_id:Re().number.isRequired,queue_id:Re().number.isRequired,preview_url:Re().string.isRequired,subject:Re().string})}).isRequired},zl.defaultProps={show_scheduled_at:!1},Zl.propTypes={show_scheduled_at:Re().bool},Zl.defaultProps={show_scheduled_at:!1},Yl.propTypes={show_scheduled_at:Re().bool,tasks:Re().arrayOf(zl.propTypes.task).isRequired},Yl.defaultProps={show_scheduled_at:!1},Gl.propTypes={status_data:Re().shape({status:Re().string,started:Re().number,sent:Re().number,retry_attempt:Re().number,retry_at:Re().number,error:Re().shape({operation:Re().string,error_message:Re().string}),tasksStatusCounts:Re().shape({completed:Re().number.isRequired,running:Re().number.isRequired,paused:Re().number.isRequired,scheduled:Re().number.isRequired}).isRequired,latestTasks:Re().arrayOf(zl.propTypes.task).isRequired}).isRequired};const id=document.getElementById("help_container");id&&((0,r.registerTranslations)(),(0,n.s)(id).render((0,p.jsx)(ad,{})));var sd=a(13269);function nd({children:e,location:{pathname:t}}){return(0,o.useEffect)((()=>{window.scrollTo(0,0)}),[t]),e||null}nd.propTypes={location:Re().shape({pathname:Re().string.isRequired}).isRequired,children:Re().node.isRequired},nd.displayName="ScrollToTopComponent";const od=(0,ke.EN)((0,sd.lV)(nd));function rd({activeMethod:e,onMethodChange:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,p.jsx)("span",{className:"mailpoet_import_heading",children:c.MailPoet.I18n.t("methodSelectionHead")}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs-row",children:(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file",target:"_blank",rel:"noopener noreferrer",children:(0,p.jsx)(Lt.V,{dimension:"large",variant:"excellent",isInverted:!0,children:c.MailPoet.I18n.t("seeVideo")})})})]}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,p.jsx)(gt.Y,{name:"select_method",automationId:"import-paste-method",id:"import-paste-method",checked:"paste-method"===e,value:"paste-method",onCheck:t}),(0,p.jsx)("label",{htmlFor:"import-paste-method",children:c.MailPoet.I18n.t("methodPaste")})]}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,p.jsx)(gt.Y,{name:"select_method",automationId:"import-csv-method",id:"import-csv-method",checked:"file-method"===e,value:"file-method",onCheck:t}),(0,p.jsx)("label",{htmlFor:"import-csv-method",children:c.MailPoet.I18n.t("methodUpload")})]}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,p.jsx)(gt.Y,{name:"select_method",automationId:"import-mailchimp-method",id:"import-mailchimp-method",checked:"mailchimp-method"===e,value:"mailchimp-method",onCheck:t}),(0,p.jsx)("label",{htmlFor:"import-mailchimp-method",children:c.MailPoet.I18n.t("methodMailChimp")})]})]})]})}function ld({hidePrevious:e,isLastStep:t,canGoNext:a,onPreviousAction:i,onNextAction:s}){return(0,p.jsxs)("div",{className:"mailpoet-settings-save",children:[!e&&(0,p.jsx)(qe.z,{type:"button",variant:"secondary",onClick:i,children:c.MailPoet.I18n.t("previousStep")}),(0,p.jsx)(qe.z,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&s()},children:c.MailPoet.I18n.t(t?"import":"nextStep")})]})}rd.propTypes={activeMethod:Re().string,onMethodChange:Re().func.isRequired},rd.defaultProps={activeMethod:void 0},rd.displayName="SelectImportMethod",ld.propTypes={canGoNext:Re().bool,hidePrevious:Re().bool,isLastStep:Re().bool,onPreviousAction:Re().func,onNextAction:Re().func},ld.defaultProps={hidePrevious:!1,isLastStep:!1,canGoNext:!0,onPreviousAction:()=>{},onNextAction:()=>{}},ld.displayName="PreviousNextStepButtons";const dd="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",cd="Email, First Name, Last Name\njohn@doe.com, John, Doe\nmary@smith.com, Mary, Smith\njohnny@walker.com, Johnny, Walker";function md({onValueChange:e,canFinish:t,onFinish:a,data:i,onPrevious:s}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,p.jsx)("label",{htmlFor:"paste_input",children:c.MailPoet.I18n.t("pasteLabel")}),(0,p.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{className:"mailpoet-link",href:`${dd}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsx)(ct.g,{id:"paste_input",rows:"15",placeholder:cd,isCode:!0,onChange:t=>{e(t.target.value)},defaultValue:i})}),(0,p.jsx)(ld,{canGoNext:t,onPreviousAction:s,onNextAction:a})]})}md.propTypes={onFinish:Re().func,onPrevious:Re().func,canFinish:Re().bool.isRequired,onValueChange:Re().func.isRequired,data:Re().string},md.defaultProps={onFinish:()=>{},onPrevious:()=>{},data:""},md.displayName="MethodPaste";const ud="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files";function pd({onValueChange:e,canFinish:t,onFinish:a,onPrevious:i}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,p.jsx)("label",{htmlFor:"file_local",children:c.MailPoet.I18n.t("methodUpload")}),(0,p.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{className:"mailpoet-link",href:`${ud}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsx)(lt.I,{type:"file",id:"file_local",accept:".csv","data-automation-id":"import-file-upload-input",onChange:t=>{const a=t.target.value.match(/[^.]+$/);c.MailPoet.Notice.hide(),null===a||"csv"!==a[0].toLowerCase()?(c.MailPoet.Notice.error(c.MailPoet.I18n.t("wrongFileFormat")),e("")):e(t.target.files[0])}})}),(0,p.jsx)(ld,{canGoNext:t,onPreviousAction:i,onNextAction:a})]})}function hd({onFinish:e,onPrevious:t}){const[a,i]=(0,o.useState)(""),[s,n]=(0,o.useState)(void 0),[r,l]=(0,o.useState)([]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:(0,p.jsxs)("label",{htmlFor:"mailpoet_mailchimp_key_input",children:[(0,p.jsx)("span",{className:"mailpoet_import_heading",children:c.MailPoet.I18n.t("methodMailChimpLabel")}),(0,p.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("methodMailChimpDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/255-migrating-from-mailchimp-to-mailpoet#api",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]})}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,p.jsx)(lt.I,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{i(e.target.value),""===e.target.value.trim()&&n(void 0)}}),(0,p.jsx)("span",{className:"mailpoet-gap"}),(0,p.jsx)(qe.z,{type:"button",dimension:"small",onClick:()=>{c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpLists",data:{api_key:a}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>n(e.data))).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))},children:c.MailPoet.I18n.t("methodMailChimpVerify")}),(0,p.jsx)("span",{className:"mailpoet-gap"}),(0,p.jsx)("span",{children:Array.isArray(s)&&0===s.length?c.MailPoet.I18n.t("noMailChimpLists"):null})]})}),s?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("methodMailChimpSelectList")}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsx)(De.Y,{field:{id:"segments",name:"list-selection",multiple:!0,placeholder:c.MailPoet.I18n.t("methodMailChimpSelectPlaceholder"),forceSelect2:!0,values:s},onValueChange:e=>l(e.target.value)})})]}):null,(0,p.jsx)(ld,{canGoNext:Array.isArray(r)&&r.length>0,onPreviousAction:t,onNextAction:()=>{c.MailPoet.Modal.loading(!0),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpSubscribers",data:{api_key:a,lists:r}}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((t=>e(t.data))).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}})]})}pd.propTypes={canFinish:Re().bool.isRequired,onFinish:Re().func,onPrevious:Re().func,onValueChange:Re().func.isRequired},pd.defaultProps={onFinish:()=>{},onPrevious:()=>{}},pd.displayName="MethodUpload",hd.propTypes={onFinish:Re().func,onPrevious:Re().func},hd.defaultProps={onFinish:()=>{},onPrevious:()=>{}},hd.displayName="MethodMailChimp";var gd=a(80824),_d=a.n(gd);const fd=e=>window.roleBasedEmails.findIndex((t=>e.startsWith(`${t}@`)))>=0,bd=e=>{let t,a=ut.default.unescape(e);return a=a.toLowerCase().replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g,"").replace(/\s+|%\d+|,+/g,""),t=/<(.*?)>/.exec(a),t&&(a=t[1].trim()),t=/mailto:(?:\s+)?(.*)/.exec(a),t&&(a=t[1].trim()),!!window.mailpoet_email_regex.test(a)&&!fd(a)&&a};function xd({history:e,setStepMethodSelectionData:t,subscribersLimitForValidation:a}){const[i,s]=(0,o.useState)(void 0),[n,l]=(0,o.useState)(""),[d,m]=(0,o.useState)(void 0),u=s=>{t(s),e.push(((e,t,a)=>void 0===e||void 0===e.subscribersCount||e.subscribersCount<t||"mailchimp-method"===a?"step_data_manipulation":"step_input_validation")(s,a,i))},h=()=>{e.push("/step_clean_list")},g=()=>{((e,t)=>{const a=encodeURI(e).split(/%..|./).length-1;c.MailPoet.Notice.hide(),a>window.maxPostSizeBytes?c.MailPoet.Notice.error(c.MailPoet.I18n.t("maxPostSizeNotice")):(c.MailPoet.Modal.loading(!0),_d().parse(e,function(e){return{skipEmptyLines:!0,error(){c.MailPoet.Notice.hide(),c.MailPoet.Notice.error(c.MailPoet.I18n.t("dataProcessingError"))},complete(t){const a=function(e){let t=[];const a=[],i=[],s=[],n=[];let o,r,l,d,c=null,m=null,u=!1;return Object.keys(e).forEach((p=>{l=e[p].map((e=>e.trim())),d=l.length,null===m&&(m=d),d===m&&(null===c?(Object.keys(l).forEach((e=>{r=bd(l[e]),null===c&&window.mailpoet_email_regex.test(r)&&(c=e,a[r]=!0,l[e]=r,t[r]=l)})),null===c&&0===parseInt(p,10)&&(u=!0,t[0]=l)):""!==l[c]&&(o=bd(l[c]),ut.default.has(a,o)?i.push(o):fd(l[c])?n.push(l[c]):window.mailpoet_email_regex.test(o)?(a[o]=!0,l[c]=o,t[o]=l):s.push(l[c])))})),t=ut.default.values(t),t&&(u&&t.length>=2||!u&&t.length>=1)?{header:window.mailpoet_email_regex.test(t[0][c])?null:t.shift(),subscribers:t,subscribersCount:t.length,duplicate:ut.default.uniq(i),invalid:ut.default.uniq(s),role:ut.default.uniq(n)}:null}(t.data);if(a)e(a);else{let e=c.MailPoet.I18n.t("noValidRecords");e=e.replace("[link]",'<a href="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files">'),e=e.replace("[/link]","</a>"),c.MailPoet.Notice.error(e)}c.MailPoet.Modal.loading(!1)}}}((e=>{c.MailPoet.trackEvent("Subscribers import started",{source:"file-method"===i?"file upload":"pasted data"}),u(e)}))))})("paste-method"===i?n:d)};return(0,p.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(rd,{activeMethod:i,onMethodChange:s})}),"paste-method"===i&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(md,{onPrevious:h,onValueChange:l,onFinish:g,canFinish:!!n.trim(),data:n})}),"file-method"===i&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(pd,{onPrevious:h,onValueChange:m,onFinish:g,canFinish:!!d,data:d})}),"mailchimp-method"===i&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(hd,{onPrevious:h,onFinish:e=>{c.MailPoet.trackEvent("Subscribers import started",{source:"MailChimp"}),u(e)}})}),void 0===i&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(ld,{canGoNext:!1,onPreviousAction:h})})]})}xd.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired,setStepMethodSelectionData:Re().func.isRequired,subscribersLimitForValidation:Re().number.isRequired},xd.diplayName="StepMethodSelection";const vd=(0,ke.EN)(xd);function jd({onProceed:e,iHaveCleanedList:t}){return(0,p.jsxs)("div",{className:"mailpoet-clean-list-step-container",children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("cleanListText1")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("cleanListText2")}),(0,p.jsxs)("p",{children:[e&&(0,p.jsx)(qe.z,{onClick:e,variant:"tertiary",children:c.MailPoet.I18n.t("listCleaningGotIt")}),(0,p.jsx)(qe.z,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:c.MailPoet.I18n.t("tryListCleaning")}),t&&(0,p.jsx)(qe.z,{onClick:t,variant:"secondary",children:c.MailPoet.I18n.t("cleanedList")})]})]})}function yd({onSubmit:e,history:t}){const[a,i]=(0,o.useState)(void 0);return(0,p.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("validationStepHeading")}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,p.jsx)(gt.Y,{automationId:"mailpoet_import_validation_step_option1",id:"existing-list",checked:"existing-list"===a,value:"existing-list",onCheck:i}),(0,p.jsx)("label",{htmlFor:"existing-list",children:c.MailPoet.I18n.t("validationStepRadio1")})]}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,p.jsx)(gt.Y,{automationId:"mailpoet_import_validation_step_option2",id:"address-book",checked:"address-book"===a,value:"address-book",onCheck:i}),(0,p.jsx)("label",{htmlFor:"address-book",children:c.MailPoet.I18n.t("validationStepRadio2")})]})]}),(0,p.jsx)(ld,{canGoNext:void 0!==a,onPreviousAction:()=>t.push("step_method_selection"),onNextAction:()=>e(a)})]})}function wd(){return(0,p.jsxs)("div",{className:"mailpoet-clean-list-step-container","data-automation-id":"import_wrong_source_block",children:[(0,p.jsx)("p",{children:c.MailPoet.I18n.t("validationStepBlock1")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("validationStepBlock2")}),(0,p.jsx)("p",{children:(0,p.jsx)(qe.z,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:c.MailPoet.I18n.t("validationStepBlockButton")})})]})}function Sd({onSubmit:e}){const[t,a]=(0,o.useState)("over2years"),i=(0,o.useCallback)((e=>{a(e.target.value)}),[a]),s=(0,o.useCallback)((()=>{e("over2years"===t||"1to2years"===t?"notRecently":"recently")}),[e,t]);return(0,p.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("validationStepLastSentHeading")}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsxs)(pt.Select,{defaultValue:t,onChange:i,automationId:"last_sent_to_list",children:[(0,p.jsx)("option",{value:"over2years",children:c.MailPoet.I18n.t("validationStepLastSentOption1")}),(0,p.jsx)("option",{value:"1to2years",children:c.MailPoet.I18n.t("validationStepLastSentOption2")}),(0,p.jsx)("option",{value:"less1year",children:c.MailPoet.I18n.t("validationStepLastSentOption3")}),(0,p.jsx)("option",{value:"less3months",children:c.MailPoet.I18n.t("validationStepLastSentOption4")})]})}),(0,p.jsx)("div",{className:"mailpoet-settings-save",children:(0,p.jsx)(qe.z,{type:"button",automationId:"last_sent_to_list_next",onClick:s,children:c.MailPoet.I18n.t("validationStepLastSentNext")})})]})}function Pd({stepMethodSelectionData:e,history:t}){const[a,i]=(0,o.useState)(void 0),[s,n]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{void 0===e&&t.replace("step_method_selection")}),[e,t]);const l=(0,o.useCallback)((e=>{n(e),"recently"===e&&t.push("step_data_manipulation")}),[t,n]);return(0,p.jsxs)(p.Fragment,{children:[void 0===a&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(yd,{onSubmit:i,history:t})}),"address-book"===a&&(0,p.jsx)(wd,{}),"existing-list"===a&&void 0===s&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Sd,{onSubmit:l})}),"existing-list"===a&&"notRecently"===s&&(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(jd,{iHaveCleanedList:()=>l("recently")})})]})}jd.displayName="CleanList",yd.propTypes={history:Re().shape({push:Re().func.isRequired}).isRequired,onSubmit:Re().func.isRequired},yd.displayName="InitialQuestion",Sd.propTypes={onSubmit:Re().func.isRequired},Sd.displayName="LastSentQuestion",Pd.defaultProps={stepMethodSelectionData:void 0},Pd.displayName="StepInputValidationComponent";const Md=(0,ke.EN)(Pd);function Nd({translation:e,subscribers:t}){let a="";return t.length&&(a=f()(e.replace("%2$s",t.join(", ")),"%1$s",(()=>(0,p.jsx)("strong",{children:t.length.toLocaleString()},e))),a=(0,p.jsx)("p",{children:a})),a}function Cd({stepMethodSelectionData:e}){const{invalid:t,duplicate:a,role:i}=e,[s,n]=(0,o.useState)(!1),r=ie()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!s}),l=(0,p.jsx)(Nd,{translation:c.MailPoet.I18n.t("importNoticeInvalid"),subscribers:t}),d=(0,p.jsx)(Nd,{translation:c.MailPoet.I18n.t("importNoticeDuplicate"),subscribers:a});let m="";if(i.length&&(m=f()(c.MailPoet.I18n.t("importNoticeRoleBased"),/(%1\$s|\[link\].*\[\/link\]|%2\$s)/,(e=>"%1$s"===e?(0,p.jsx)("strong",{children:i.length.toLocaleString()},"role-length"):"%2$s"===e?i.join(", "):(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/270-role-based-email-addresses-are-not-allowed",target:"_blank",rel:"noopener noreferrer",children:e.replace("[link]","").replace("[/link]","")},e))),m=(0,p.jsx)("p",{children:m})),t.length||a.length||i.length){const e=t.length+a.length+i.length;return(0,p.jsxs)("div",{className:"error",children:[(0,p.jsxs)("p",{children:[f()(c.MailPoet.I18n.t("importNoticeSkipped"),"%1$s",(()=>(0,p.jsx)("strong",{children:e.toLocaleString()},"lengths")))," ",(0,p.jsx)("a",{className:"mailpoet_subscribers_data_parse_results_details_show","data-automation-id":"show-more-details",onClick:()=>n(!s),role:"button",tabIndex:0,onKeyDown:e=>{["keydown","keypress"].includes(e.type)&&["Enter"," "].includes(e.key)&&(e.preventDefault(),n(!s))},children:c.MailPoet.I18n.t("showMoreDetails")})]}),(0,p.jsxs)("div",{className:r,children:[(0,p.jsx)("hr",{}),l,d,m]})]})}return null}Nd.propTypes={translation:Re().string.isRequired,subscribers:Re().arrayOf(Re().string).isRequired},Cd.propTypes={stepMethodSelectionData:Re().shape({duplicate:Re().arrayOf(Re().string),invalid:Re().arrayOf(Re().string),role:Re().arrayOf(Re().string)})},Cd.defaultProps={stepMethodSelectionData:{invalid:[],duplicate:[],role:[]}};const Id=()=>{const e={data:window.mailpoetColumnsSelect2,width:"15em"};Ee()("select.mailpoet_subscribers_column_data_match").select2(e).on("select2:selecting",(t=>{const a=t.currentTarget,i=t.params.args.data.id;"create"===i?(t.preventDefault(),Ee()(a).select2("close"),c.MailPoet.Modal.popup({title:c.MailPoet.I18n.t("addNewField"),template:Ee()("#form_template_field_form").html()}),Ee()("#form_field_new").parsley().on("form:submit",(()=>{const t=Ee()("#form_field_new").mailpoetSerializeObject();return c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"customFields",action:"save",data:t}).done((t=>{const i={id:t.data.id,name:t.data.name,text:t.data.name,type:t.data.type,params:t.data.params,custom:!0};2===window.mailpoetColumnsSelect2.length&&window.mailpoetColumnsSelect2.push({name:c.MailPoet.I18n.t("userColumns"),children:[]}),window.mailpoetColumnsSelect2[2].children.push(i),window.mailpoetColumns.push(i),Ee()("select.mailpoet_subscribers_column_data_match").each((()=>{Ee()(a).html("").select2("destroy").select2(e)})),Ee()(a).data("column-id",i.id),c.MailPoet.Modal.close()})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{positionAfter:"#field_name"})})),!1}))):Ee()("select.mailpoet_subscribers_column_data_match").each((()=>{const e=a,s=Ee()(e).val();s===i&&"ignore"!==s&&(confirm(`${c.MailPoet.I18n.t("selectedValueAlreadyMatched")} ${c.MailPoet.I18n.t("confirmCorrespondingColumn")}`)?Ee()(e).data("column-id","ignore"):(t.preventDefault(),Ee()(a).select2("close")))}))})).on("select2:select",(e=>{const t=e.currentTarget,a=e.params.data.id;Ee()(t).data("column-id",a)})).on("select2:open",(()=>{const e=document.querySelectorAll(".select2-search__field[aria-controls]");0!==e.length&&e[e.length-1].focus()})),Ee().map(Ee()(".mailpoet_subscribers_column_data_match"),(e=>{const t=Ee()(e).data("column-id");Ee()(e).val(t).trigger("change")}))},kd=(e,t)=>{const a=[],i=[];let s,n,o,r;return Object.keys(e[0]).forEach((l=>{s=e[0][l],n="ignore",s%1!=0&&window.mailpoet_email_regex.test(s)?n="email":t&&(o=t[l],r=window.mailpoetColumns.map((e=>e.name)).indexOf(o),-1!==r?n=window.mailpoetColumns[r].id:o&&(/first|first name|given name/i.test(o)?n="first_name":/last|last name/i.test(o)&&(n="last_name"))),n="ignore"!==n&&-1===i.indexOf(n)?n:"ignore",a[l]={column_id:n},i.push(n)})),a},Td=10;function Ed({header:e,subscribers:t}){const a=kd(t,e);return(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{children:c.MailPoet.I18n.t("matchData")}),a.map(((e,t)=>(0,p.jsx)("th",{children:(0,p.jsx)("select",{className:"mailpoet_subscribers_column_data_match","data-column-id":e.column_id,"data-column-index":t,id:`column_${t}`})},e.column_id+t)))]})}function Ad({header:e}){return(0,p.jsxs)("tr",{className:"mailpoet_header",children:[(0,p.jsx)("td",{}),e.map((e=>(0,p.jsx)("td",{children:e},e)))]})}function Rd({subscriber:e,index:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("td",{children:t}),e.map(((e,a)=>(0,p.jsx)("td",{children:e},`${e}-${t}-${a}`)))]})}function Fd({subscribers:e,subscribersCount:t}){const a=". . .",i=Array(e[0].length).fill(a);return(0,p.jsxs)(p.Fragment,{children:[e.slice(0,Td).map(((e,t)=>(0,p.jsx)("tr",{children:(0,p.jsx)(Rd,{subscriber:e,index:t+1})},`${e[0]}-${t}`))),t>Td+1?(0,p.jsx)("tr",{children:(0,p.jsx)(Rd,{subscriber:i,index:a})},"filler"):null,t>Td?(0,p.jsx)("tr",{children:(0,p.jsx)(Rd,{subscriber:e[t-1],index:t})},e[t-1][0]):null]})}function Od({subscribersCount:e,subscribers:t,header:a}){return(0,o.useLayoutEffect)((()=>{Id()})),(0,p.jsx)("div",{className:"subscribers_data",children:(0,p.jsxs)("table",{className:"mailpoet_subscribers widefat fixed",children:[(0,p.jsx)("thead",{children:(0,p.jsx)(Ed,{header:a,subscribers:t})}),(0,p.jsxs)("tbody",{children:[a?(0,p.jsx)(Ad,{header:a}):null,(0,p.jsx)(Fd,{subscribers:t,subscribersCount:e})]})]})})}Ed.propTypes={subscribers:Re().arrayOf(Re().arrayOf(Re().oneOfType([Re().string,Re().number]))).isRequired,header:Re().arrayOf(Re().string)},Ed.defaultProps={header:[]},Ad.propTypes={header:Re().arrayOf(Re().string).isRequired},Rd.propTypes={subscriber:Re().arrayOf(Re().oneOfType([Re().string,Re().number])).isRequired,index:Re().node.isRequired},Fd.propTypes={subscribersCount:Re().number.isRequired,subscribers:Re().arrayOf(Re().arrayOf(Re().oneOfType([Re().string,Re().number]))).isRequired},Od.propTypes={subscribersCount:Re().number,subscribers:Re().arrayOf(Re().arrayOf(Re().oneOfType([Re().string,Re().number]))),header:Re().arrayOf(Re().string)},Od.defaultProps={subscribersCount:0,subscribers:[],header:[]};const Dd=e=>{c.MailPoet.Modal.popup({title:c.MailPoet.I18n.t("addNewList"),template:Ee()("#new_segment_template").html()}),Ee()("#new_segment_name").on("keypress",(e=>{13===e.which&&Ee()("#new_segment_process").trigger("click")})),Ee()("#new_segment_process").on("click",(()=>{const t=Ee()("#new_segment_name").val().trim(),a=Ee()("#new_segment_description").val().trim();c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"addSegment",data:{name:t,description:a}}).done((t=>{e({id:t.data.id,name:t.data.name,text:t.data.name,subscriberCount:0}),c.MailPoet.Modal.close()})).fail((e=>{e.errors.length>0&&(c.MailPoet.Notice.hide(),c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{positionAfter:"#new_segment_name"}))}))})),Ee()("#new_segment_cancel").on("click",(()=>{c.MailPoet.Modal.close()}))};function Ld({setSelectedSegments:e}){const{segments:t}=(0,o.useContext)(l.k),{all:a,updateAll:i}=t,[s,n]=(0,o.useState)(a);(0,o.useLayoutEffect)((()=>{!function(t,a){const i=Ee()("select#mailpoet_segments_select");if(i.data("select2"))return;const s=e=>{let t=`<span class="mailpoet-form-select2-text"><span>${e.name}</span></span>`;return e.count&&(t+=`<span class="mailpoet-form-select2-count">${e.count}</span>`),t};i.html(""),i.select2({data:t.map((e=>({...e,text:e.name}))),dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:s,templateSelection:s}).on("change",(t=>{const a=Ee()('[data-id="notice_segmentSelection"]');t.currentTarget.value?Ee()('[data-id="notice_segmentSelection"]').remove():a.length||c.MailPoet.Notice.error(c.MailPoet.I18n.t("segmentSelectionRequired"),{static:!0,scroll:!0,id:"notice_segmentSelection",hideClose:!0});(t=>{e(t)})(ut.default.pluck(i.select2("data"),"id"))}))}(s)}),[s,e]);const r=t=>{!function(){const e=Ee()("select#mailpoet_segments_select");e.data("select2")&&(e.select2("destroy"),e.find("option").remove(),e.off("select2:unselecting").off("change").off("select2:opening"))}(),e([]),n([...s,t]),i([...s,t])};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:(0,p.jsxs)("label",{htmlFor:"mailpoet_segments_select",children:[c.MailPoet.I18n.t("pickLists"),(0,p.jsx)("p",{className:"description",children:c.MailPoet.I18n.t("pickListsDescription")})]})}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,p.jsx)("div",{className:"mailpoet-form-select mailpoet-form-input",children:(0,p.jsx)("select",{id:"mailpoet_segments_select","data-placeholder":c.MailPoet.I18n.t("select"),multiple:"multiple",children:(0,p.jsx)("option",{})})}),(0,p.jsx)(qe.z,{variant:"tertiary",onClick:()=>Dd(r),children:c.MailPoet.I18n.t("createANewList")})]})})]})}function qd(){return(0,p.jsx)("p",{className:"description",children:f()(c.MailPoet.I18n.t("consentSubscribed"),/\[link](.*?)\[\/link]/,(e=>(0,p.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/357-why-express-consent-is-important",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})}function Bd({newSubscribersStatus:e,setNewSubscribersStatus:t}){const a=(0,o.useCallback)((e=>{t(e.target.value)}),[t]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,p.jsx)("label",{htmlFor:"new_subscribers_status",children:c.MailPoet.I18n.t("newSubscribersStatus")}),(0,p.jsx)(qd,{})]}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsxs)(pt.Select,{id:"new_subscribers_status",placeholder:c.MailPoet.I18n.t("select"),name:"new_subscribers_status",onChange:a,defaultValue:e,children:[(0,p.jsx)("option",{value:"subscribed",children:c.MailPoet.I18n.t("subscribed")}),(0,p.jsx)("option",{value:"inactive",children:c.MailPoet.I18n.t("inactive")}),(0,p.jsx)("option",{value:"unsubscribed",children:c.MailPoet.I18n.t("unsubscribed")})]})})]})}function Wd({existingSubscribersStatus:e,setExistingSubscribersStatus:t}){const a=(0,o.useCallback)((e=>{t(e.target.value)}),[t]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,p.jsx)("label",{htmlFor:"existing_subscribers_status",children:c.MailPoet.I18n.t("existingSubscribersStatus")}),(0,p.jsx)(qd,{})]}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,p.jsxs)(pt.Select,{id:"existing_subscribers_status",placeholder:c.MailPoet.I18n.t("select"),name:"existing_subscribers_status",onChange:a,defaultValue:e,children:[(0,p.jsx)("option",{value:"dont_update",children:c.MailPoet.I18n.t("dontUpdate")}),(0,p.jsx)("option",{value:"subscribed",children:c.MailPoet.I18n.t("subscribed")}),(0,p.jsx)("option",{value:"inactive",children:c.MailPoet.I18n.t("inactive")}),(0,p.jsx)("option",{value:"unsubscribed",children:c.MailPoet.I18n.t("unsubscribed")})]})})]})}function $d({updateExistingSubscribers:e,setUpdateExistingSubscribers:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"mailpoet-settings-label",children:c.MailPoet.I18n.t("updateExistingSubscribers")}),(0,p.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,p.jsx)(gt.Y,{id:"update_existing_subscribers",name:"update_existing_subscribers",value:"1",checked:e,onCheck:()=>t(!0)}),(0,p.jsx)("label",{htmlFor:"update_existing_subscribers",children:c.MailPoet.I18n.t("updateExistingSubscribersYes")}),(0,p.jsx)("span",{className:"mailpoet-gap"}),(0,p.jsx)(gt.Y,{id:"dont_update_existing_subscribers",name:"update_existing_subscribers",value:"",checked:!e,onCheck:()=>t(!1)}),(0,p.jsx)("label",{htmlFor:"dont_update_existing_subscribers",children:c.MailPoet.I18n.t("updateExistingSubscribersNo")})]})]})}Ld.propTypes={setSelectedSegments:Re().func.isRequired},$d.propTypes={setUpdateExistingSubscribers:Re().func.isRequired,updateExistingSubscribers:Re().bool.isRequired},a(49868);function Ud({selectedTags:e,setSelectedTags:t}){const a=(0,o.useCallback)((({value:e})=>{t(e)}),[t]),i=c.MailPoet.tags.map((e=>e.name));return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:"mailpoet-settings-label",children:[c.MailPoet.I18n.t("assignTagsLabel"),(0,p.jsx)("p",{className:"description",children:c.MailPoet.I18n.t("assignTagsDescription")})]}),(0,p.jsx)("div",{className:"mailpoet-settings-inputs mailpoet-import-tags",children:(0,p.jsx)(St.T,{name:"tags",onChange:a,suggestedValues:i,selectedValues:e,placeholder:c.MailPoet.I18n.t("addNewTag")})})]})}function Vd({history:e,stepMethodSelectionData:t,subscribersLimitForValidation:a,setStepDataManipulationData:i}){const[s,n]=(0,o.useState)([]),[r,l]=(0,o.useState)(!0),[d,m]=(0,o.useState)("subscribed"),[u,h]=(0,o.useState)("dontUpdate"),[g,_]=(0,o.useState)([]);return(0,o.useEffect)((()=>{void 0===t&&e.replace("step_method_selection")}),[t,e]),void 0===t?null:(0,p.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,p.jsx)(Cd,{stepMethodSelectionData:t}),(0,p.jsx)(Od,{subscribersCount:t.subscribersCount,subscribers:t.subscribers,header:t.header}),(0,p.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,p.jsx)(Ld,{setSelectedSegments:n}),(0,p.jsx)(Bd,{newSubscribersStatus:d,setNewSubscribersStatus:m}),(0,p.jsx)(Wd,{existingSubscribersStatus:u,setExistingSubscribersStatus:h}),(0,p.jsx)($d,{setUpdateExistingSubscribers:l,updateExistingSubscribers:r}),(0,p.jsx)(Ud,{selectedTags:g,setSelectedTags:_}),(0,p.jsx)(ld,{canGoNext:s.length>0,onPreviousAction:()=>e.push(function(e,t){return void 0===e||void 0===e.subscribersCount||e.subscribersCount<t?"step_method_selection":"step_input_validation"}(t,a)),onNextAction:()=>{((e,t,a,i,s,n,o)=>{const r={},l=new(Ee().AsyncQueue);let d=0;const m=Date.now()/1e3,u={created:0,updated:0,errors:[],segments:[],tags:[]};c.MailPoet.Modal.progress(!0);const p=e.reduce(((e,t,a)=>(a%2e3==0&&e.push([]),e[e.length-1].push(t),e)),[]);ut.default.each(Ee()("select.mailpoet_subscribers_column_data_match"),((e,t)=>{const a=Ee()(e).data("column-id");"ignore"!==a&&(r[a]={index:t})})),ut.default.each(p,(()=>{l.add((o=>{o.pause(),c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"processImport",data:JSON.stringify({columns:r,subscribers:p[d],timestamp:m,segments:t,newSubscribersStatus:a,existingSubscribersStatus:i,updateSubscribers:s,tags:n})}).done((t=>{const a=t.data.added_to_segment_with_welcome_notification;var i,s;u.created+=t.data.created,u.updated+=t.data.updated,u.segments=t.data.segments,u.added_to_segment_with_welcome_notification=a,c.MailPoet.Modal.setProgress((i=u,s=e,Math.floor((i.created+i.updated)/s.length*100))),o.run()})).fail((e=>{c.MailPoet.Modal.progress(!1),e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})})),d+=1}))})),l.run(),l.onComplete((()=>{c.MailPoet.Modal.progress(!1),u.errors.length>0&&!u.updated&&!u.created?c.MailPoet.Notice.error(ut.default.flatten(u.errors)):(u.segments=ut.default.map(ut.default.filter(u.segments,(e=>t.includes(e.id))),(e=>e.name)),o(u))}))})(t.subscribers,s,d,u,r,g,(t=>{i(t),e.push("step_results")}))},isLastStep:!0})]})]})}Vd.propTypes={history:Re().shape({push:Re().func.isRequired,replace:Re().func.isRequired}).isRequired,stepMethodSelectionData:Re().shape({duplicate:Re().arrayOf(Re().string),header:Re().arrayOf(Re().string),invalid:Re().arrayOf(Re().string),role:Re().arrayOf(Re().string),subscribersCount:Re().number,subscribers:Re().arrayOf(Re().arrayOf(Re().oneOfType([Re().string,Re().number])))}),subscribersLimitForValidation:Re().number.isRequired,setStepDataManipulationData:Re().func.isRequired},Vd.defaultProps={stepMethodSelectionData:void 0};const Hd=(0,ke.EN)(Vd);function zd({subscribersCount:e,segments:t,initialMessage:a}){if(e){let i=f()(a,"%1$s",(()=>(0,p.jsx)("strong",{children:e.toLocaleString()},"%1$s")));return i=f()(i,"%2$s",(()=>`"${t.join('", "')}"`)),(0,p.jsx)("p",{children:i})}return null}function Zd({createdSubscribers:e,updatedSubscribers:t}){return e||t?null:(0,p.jsx)("p",{children:c.MailPoet.I18n.t("importNoAction")})}function Yd({createdSubscribers:e,updatedSubscribers:t}){return e||t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("p",{children:(0,p.jsx)("b",{children:c.MailPoet.I18n.t("congratulationResult")})}),(0,p.jsx)("p",{children:f()(c.MailPoet.I18n.t("suppressionListReminder"),/\[link](.*?)\[\/link]/,(e=>(0,p.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/359-how-to-import-a-suppression-list",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}):null}function Gd({addedToSegmentWithWelcomeNotification:e}){return e?(0,p.jsx)("p",{children:c.MailPoet.I18n.t("importNoWelcomeEmail")}):null}function Kd({errors:e,createdSubscribers:t,updatedSubscribers:a,segments:i,addedToSegmentWithWelcomeNotification:s,history:n}){return(0,o.useEffect)((()=>{void 0===i&&0===e.length&&void 0===t&&void 0===a&&n.replace("step_method_selection")}),[i,t,e.length,n,a]),e.length&&c.MailPoet.Notice.error(ut.default.flatten(e)),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsxs)("div",{className:"updated",children:[(0,p.jsx)(zd,{subscribersCount:t,segments:i,initialMessage:c.MailPoet.I18n.t("subscribersCreated")}),(0,p.jsx)(zd,{subscribersCount:a,segments:i,initialMessage:c.MailPoet.I18n.t("subscribersUpdated")}),(0,p.jsx)(Zd,{createdSubscribers:t,updatedSubscribers:a}),(0,p.jsx)(Gd,{addedToSegmentWithWelcomeNotification:s})]})}),(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Yd,{createdSubscribers:t,updatedSubscribers:a})}),(0,p.jsx)("div",{className:"mailpoet-settings-grid",children:(0,p.jsxs)("div",{className:"mailpoet-settings-save",children:[(0,p.jsx)(qe.z,{variant:"secondary",type:"button",onClick:()=>n.push("step_method_selection"),children:c.MailPoet.I18n.t("importAgain")}),(0,p.jsx)(qe.z,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:c.MailPoet.I18n.t("viewSubscribers")})]})})]})}zd.propTypes={segments:Re().arrayOf(Re().string.isRequired),subscribersCount:Re().number,initialMessage:Re().string},zd.defaultProps={segments:[],subscribersCount:0,initialMessage:""},zd.displayName="ResultMessage",Zd.propTypes={createdSubscribers:Re().number,updatedSubscribers:Re().number},Zd.defaultProps={createdSubscribers:0,updatedSubscribers:0},Zd.displayName="NoAction",Yd.propTypes={createdSubscribers:Re().number,updatedSubscribers:Re().number},Yd.defaultProps={createdSubscribers:0,updatedSubscribers:0},Yd.displayName="SuppressionListReminder",Gd.propTypes={addedToSegmentWithWelcomeNotification:Re().bool},Gd.defaultProps={addedToSegmentWithWelcomeNotification:!1},Gd.diplayName="NoWelcomeEmail",Kd.propTypes={history:Re().shape({push:Re().func.isRequired,replace:Re().func.isRequired}).isRequired,errors:Re().arrayOf(Re().string.isRequired),segments:Re().arrayOf(Re().string.isRequired),createdSubscribers:Re().number,updatedSubscribers:Re().number,addedToSegmentWithWelcomeNotification:Re().bool},Kd.defaultProps={errors:[],segments:void 0,createdSubscribers:void 0,updatedSubscribers:void 0,addedToSegmentWithWelcomeNotification:void 0},Kd.displayName="StepResultsComponent";const Qd=(0,ke.EN)(Kd);function Jd({history:e}){return(0,p.jsx)(jd,{onProceed:()=>e.push("step_method_selection")})}Jd.displayName="StepCleanList";const Xd=document.getElementById("import_container");function ec(){const[e,t]=(0,o.useState)(void 0),[a,i]=(0,o.useState)({}),s=(0,l.S)(window);return(0,p.jsx)(l.k.Provider,{value:s,children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsx)(od,{children:(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:"/step_clean_list",render:(0,r.withBoundary)(Jd)}),(0,p.jsx)(ke.AW,{path:"/step_method_selection",render:e=>(0,p.jsx)(vd,{...e,setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,p.jsx)(ke.AW,{path:"/step_input_validation",render:t=>(0,p.jsx)(Md,{...t,stepMethodSelectionData:e})}),(0,p.jsx)(ke.AW,{path:"/step_data_manipulation",render:t=>(0,p.jsx)(Hd,{...t,stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:i})}),(0,p.jsx)(ke.AW,{path:"/step_results",render:e=>(0,p.jsx)(Qd,{...e,errors:a.errors,createdSubscribers:a.created,updatedSubscribers:a.updated,segments:a.segments,addedToSegmentWithWelcomeNotification:a.added_to_segment_with_welcome_notification})}),(0,p.jsx)(ke.AW,{path:"*",render:()=>(0,p.jsx)(ke.l_,{to:"/step_clean_list"})})]})})]})})}Xd&&((0,r.registerTranslations)(),(0,n.s)(Xd).render((0,p.jsx)(ec,{})));var tc=a(76721),ac=a.n(tc);Ee()(document).ready((()=>{let e;if(!Ee()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=ac().compile(Ee()("#mailpoet_subscribers_export_template").html());function a(t){const a="mailpoet-disabled";"on"===t?e.removeClass(a):e.addClass(a)}Ee()("#mailpoet-export").html(t(window.exportData));const i=Ee()("#export_lists"),s=Ee()("#export_columns");function n(e){let t=`<span class="mailpoet-form-select2-text"><span>${e.name}</span></span>`;return void 0!==e.count&&(t+=`<span class="mailpoet-form-select2-count">${e.count}</span>`),t}function o(e,t){e.data("select2")&&e.html("").select2("destroy"),e.select2({data:t,width:"20em",dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:n,templateSelection:n}).on("select2:selecting",(t=>{const a=t.params.args.data.id,i=["select","deselect"];let s;ut.default.contains(i,a)&&(t.preventDefault(),"deselect"===a?Ee()(t.target).val("").trigger("change"):(s=[],ut.default.each(e.find("option"),(e=>{const t=e.value;ut.default.contains(i,t)||s.push(t)})),Ee()(t.target).val(s).trigger("change")),Ee()(t.target).select2("close"))})).on("change",(()=>{window.exportData.segments&&i.select2("data").length&&s.select2("data").length||!window.exportData.segments&&s.select2("data").length?a("on"):a("off")}))}e=Ee()("#mailpoet-export-button"),window.segments.forEach((e=>{i.append(Ee()("<option></option>").attr("value",e.id).text(e.name))})),window.subscriberFieldsSelect2.forEach((e=>{e.text=e.name,e.children.forEach((e=>{e.name=(0,xo.r)(e.name),e.text=(0,xo.r)(e.name)}))})),o(i,window.segments),o(s,window.subscriberFieldsSelect2),s.val(["email","first_name","last_name","list_status","global_status","subscribed_ip","created_at","confirmed_at","confirmed_ip"]).trigger("change"),e.on("click",(e=>{if(Ee()(e.target).hasClass("mailpoet-disabled"))return;c.MailPoet.Modal.loading(!0);const t=Ee()(':radio[name="option_format"]:checked').val();c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"ImportExport",action:"processExport",data:JSON.stringify({export_format_option:t,segments:!!window.exportData.segments&&i.val(),subscriber_fields:s.val()})}).always((()=>{c.MailPoet.Modal.loading(!1)})).done((e=>{const a=c.MailPoet.I18n.t("exportMessage").replace("%1$s",`<strong>${parseInt(e.data.totalExported,10).toLocaleString()}</strong>`).replace("[link]",`<a href="${e.data.exportFileURL}" target="_blank" >`).replace("[/link]","</a>");Ee()("#export_result_notice").html(`<p>${a}</p>`).show(),window.location.href=e.data.exportFileURL,c.MailPoet.trackEvent("Subscribers export completed",{"Total exported":e.data.totalExported,"File Format":t})})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}))}));var ic=a(37441),sc=a(19613);function nc({children:e}){return(0,p.jsx)("div",{className:"mailpoet-steps-content",children:e})}const oc=(0,p.jsx)("svg",{width:"13",height:"11",viewBox:"0 0 13 11",children:(0,p.jsx)("path",{fill:"currentColor",d:"M9.967.638c.483-.698 1.405-.846 2.06-.33.654.515.793 1.499.31 2.197l-5.44 7.857c-.55.794-1.64.857-2.267.132l-3.4-3.928c-.552-.638-.515-1.632.083-2.22.598-.59 1.53-.55 2.082.088l2.19 2.532L9.968.638z"})}),rc=(0,p.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",children:(0,p.jsx)("path",{fill:"currentColor",d:"M12.407 3.31c.576.576.576 1.509 0 2.084L9.914 7.888l2.411 2.412c.586.585.586 1.535 0 2.121-.585.586-1.535.586-2.12 0l-2.413-2.412L5.3 12.503c-.576.575-1.509.575-2.084 0-.575-.575-.575-1.508 0-2.083l2.493-2.495-2.41-2.41c-.587-.587-.587-1.536 0-2.122.585-.586 1.535-.586 2.12 0L7.83 5.804l2.494-2.493c.575-.576 1.508-.576 2.083 0z"})});function lc({onCheck:e,showError:t,checked:a,automationId:i,...s}){return(0,p.jsxs)("div",{className:ie()({"mailpoet-form-yesno":!0,"mailpoet-form-yesno-error":t,"mailpoet-disabled":s.disabled}),"data-automation-id":i,children:[(0,p.jsxs)("label",{children:[(0,p.jsx)("input",{type:"radio",checked:!0===a,onChange:()=>e(!0),...s}),(0,p.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-yes",children:oc})]}),(0,p.jsxs)("label",{children:[(0,p.jsx)("input",{type:"radio",checked:!1===a,onChange:()=>e(!1),...s}),(0,p.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-no",children:rc})]})]})}function dc({submitForm:e,loading:t,showCustomersImportSetting:a,isWizardStep:i=!1}){const[s,n]=(0,o.useState)(null),[l,d]=(0,o.useState)(!1===a?"unsubscribed":null),[c,m]=(0,o.useState)(!1),u=i?(0,Le._x)("Continue","A label on a button","mailpoet"):(0,Le._x)("Start using WooCommerce features","Submit button caption on the standalone WooCommerce setup page","mailpoet");let h;return"subscribed"===l&&(h=!0),"unsubscribed"===l&&(h=!1),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.TypographyHeading,{level:1,children:(0,Le._x)("Power up your WooCommerce store","Title on the WooCommerce setup page","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("p",{children:(0,Le.__)("MailPoet comes with powerful features for WooCommerce. Select features that you would like to use with your store.","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("form",{onSubmit:t=>(t.preventDefault(),m(!0),null===l||null===s||e(l,s),!1),children:[(0,p.jsxs)("div",{children:[a?(0,p.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,p.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,p.jsx)(lc,{showError:c&&null===l,checked:h,onCheck:e=>d(e?"subscribed":"unsubscribed"),name:"mailpoet_woocommerce_import_type",automationId:"woocommerce_import_type"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:f()((0,Le.__)("Do you want to import your WooCommerce customers as subscribed? [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list",rel:"noopener noreferrer",target:"_blank",children:e},e)))}),(0,p.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,p.jsx)("span",{children:"GDPR"}),(0,Le._x)("To be compliant with privacy regulations, your customers must have explicitly accepted to receive your marketing emails.","GDPR compliance information","mailpoet")]})]})]}):null,(0,p.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,p.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,p.jsx)(lc,{showError:c&&null===s,checked:s,onCheck:e=>n(e),name:"mailpoet_woocommerce_tracking",automationId:"woocommerce_tracking"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:f()((0,Le.__)("Collect more precise email and site engagement, and e-commerce metrics by enabling cookie tracking. [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/280-woocommerce-cookie-tracking",rel:"noopener noreferrer",target:"_blank",children:e},e)))}),(0,p.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,p.jsx)("span",{children:"GDPR"}),(0,Le._x)("To be compliant, you should display a cookie tracking banner on your website.","GDPR compliance information","mailpoet")]})]})]})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,disabled:t,automationId:"submit_woocommerce_setup",children:u})]})]})}function cc(e){return(0,p.jsx)(_s,{illustrationUrl:e.illustrationUrl,children:e.children})}function mc({isWizardStep:e=!1,redirectToNextStep:t=null}){const[a,i]=(0,o.useState)(!1),[s,n]=(0,sc.yu)("woocommerce"),l=(0,sc.yu)("tracking")[1],d=(0,sc.yu)("woocommerce_import_screen_displayed")[1],m=(0,sc.yu)("mailpoet_subscribe_old_woocommerce_customers")[1],u=e=>{i(!1),c.MailPoet.Notice.showApiErrorNotice(e,{scroll:!0})},h=e=>c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(u),g=(0,p.jsx)(cc,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(dc,{loading:a,submitForm:async(a,o)=>{i(!0);const r="basic"===c.MailPoet.trackingConfig.level?"basic":"partial",p={level:o?"full":r},g={enabled:"subscribed"===a?"1":""},_={woocommerce_import_screen_displayed:1,"mailpoet_subscribe_old_woocommerce_customers.enabled":g.enabled,"tracking.level":p.level,"woocommerce.accept_cookie_revenue_tracking.set":"1"};await h(_),l(p),m(g),n({...s,accept_cookie_revenue_tracking:{...s.accept_cookie_revenue_tracking||{},set:"1"}}),d("1"),await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"setupWooCommerceInitialImport"}).fail(u),e?t():await(async()=>{e?await h({version:window.mailpoet_version}).then((()=>{window.location.href=window.finish_wizard_url})):window.location.href=window.finish_wizard_url})()},isWizardStep:e,showCustomersImportSetting:window.mailpoet_show_customers_import})})});return e?g:(0,p.jsx)(nc,{children:g})}function uc({skipStep:e,loading:t,update_sender:a,submit_sender:i,sender:s=null}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:1,children:(0,Le.__)("Start by configuring your sender information","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("p",{children:[(0,p.jsx)("b",{children:(0,Le.__)("Default sender","mailpoet")}),(0,p.jsx)("br",{}),(0,Le.__)("Enter details of the person or brand your subscribers expect to receive emails from","mailpoet")]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("form",{id:"mailpoet_sender_form",onSubmit:e=>{e.preventDefault(),Ee()("#mailpoet_sender_form").parsley().validate()&&i()},children:[(0,p.jsxs)(Da.Grid.TwoColumns,{children:[(0,p.jsxs)("label",{htmlFor:"senderName",children:[(0,p.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Le._x)("From Name","A form field label","mailpoet")}),(0,p.jsx)(r.Input,{isFullWidth:!0,name:"senderName",type:"text",placeholder:"John Doe",value:s?s.name:"","data-parsley-required":!0,onChange:e=>a({name:e.target.value})})]}),(0,p.jsxs)("label",{htmlFor:"senderAddress",children:[(0,p.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Le._x)("From Address","A form field label","mailpoet")}),(0,p.jsx)(r.Input,{isFullWidth:!0,name:"senderAddress",type:"text",placeholder:"john@doe.com",value:s?s.address:"","data-parsley-required":!0,"data-parsley-type":"email",onChange:e=>a({address:e.target.value})})]})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,children:(0,Le._x)("Continue","A label on a button","mailpoet")}),(0,p.jsx)(r.Button,{href:"#skipStep",isDisabled:t,isFullWidth:!0,onClick:e,variant:"tertiary",children:(0,Le._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}cc.propTypes={illustrationUrl:Re().string.isRequired,children:Re().oneOfType([Re().arrayOf(Re().node),Re().node]).isRequired},mc.displayName="WooCommerceController",uc.displayName="WelcomeWizardSenderStep";const pc=e=>null==e;function hc({loading:e,submitForm:t}){const[a,i]=(0,o.useState)({tracking:void 0,libs3rdParty:void 0}),[s,n]=(0,o.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:1,children:(0,Le.__)("Confirm privacy and data settings","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("form",{onSubmit:function(e){return e.preventDefault(),n(!0),pc(a.libs3rdParty)||pc(a.tracking)||t(a.tracking,a.libs3rdParty),!1},children:[(0,p.jsxs)("div",{children:[(0,p.jsxs)("div",{id:"mailpoet-wizard-3rd-party-libs",className:"mailpoet-wizard-woocommerce-option",children:[(0,p.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,p.jsx)(lc,{showError:s&&pc(a.libs3rdParty),onCheck:e=>{const t={libs3rdParty:e};i((e=>({...e,...t})))},checked:a.libs3rdParty,name:"mailpoet_libs_3rdParty"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:(0,Le.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-wizard-note",children:f()((0,Le.__)("MailPoet may load Google Fonts, DocsBot and other [link]3rd party libraries[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/338-what-3rd-party-libraries-we-use",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("div",{id:"mailpoet-wizard-tracking",className:"mailpoet-wizard-woocommerce-option",children:[(0,p.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,p.jsx)(lc,{showError:s&&pc(a.tracking),onCheck:e=>{const t={tracking:e};i((e=>({...e,...t})))},checked:a.tracking,name:"mailpoet_tracking"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{children:(0,Le.__)("Help improve MailPoet","mailpoet")}),(0,p.jsx)("div",{className:"mailpoet-wizard-note",children:f()((0,Le.__)("Get improved features and fixes faster by sharing with us [link]non-sensitive data about how you use MailPoet[/link]. No personal data is tracked or stored.","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/article/130-sharing-your-data-with-us",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(qe.z,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:e,disabled:e,children:(0,Le._x)("Continue","A label on a button","mailpoet")})]})]})}hc.propTypes={loading:Re().bool.isRequired,submitForm:Re().func.isRequired},hc.displayName="WelcomeWizardUsageTrackingStep";var gc=a(36503);async function _c(e){await c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}async function fc(e=null){await _c({version:window.mailpoet_version,installed_after_new_domain_restrictions:1,welcome_wizard_current_step:""}),window.location.href=e||window.finish_wizard_url}function bc(){const[e,t]=(0,o.useState)(!1),a=e=>{e.preventDefault(),t(!0)},i=()=>t(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("p",{children:f()(c.MailPoet.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,p.jsx)("a",{onClick:a,href:"#",children:e},t)))}),e&&(0,p.jsxs)(ga.Z,{className:"mailpoet-welcome-wizard-confirmation-modal",title:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalTitle"),onRequestClose:i,children:[(0,p.jsx)("p",{children:c.MailPoet.mailFunctionEnabled?c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraph"):c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraphWithoutMailFunction")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalSecondParagraph")}),(0,p.jsxs)("div",{className:"mailpoet-welcome-wizard-confirmation-modal-buttons",children:[(0,p.jsx)(r.Button,{variant:"secondary",onClick:i,children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalGoBackButton")}),(0,p.jsx)(r.Button,{onClick:async e=>{e.preventDefault(),await fc("admin.php?page=mailpoet-settings#/mta/other")},children:c.MailPoet.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const xc=(e,t,a=!1)=>{_c({welcome_wizard_current_step:t}),a?e.replace(t):e.push(t)},vc="https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase";function jc(){const e=(0,ke.k6)(),{step:t}=(0,ke.UO)(),a=(0,sc.v9)("getKeyActivationState")();return(0,o.useEffect)((()=>{!0===a.isKeyValid&&xc(e,`/steps/${t}/part/3`,!0)}),[a.isKeyValid,e,t]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartTitle")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartSubtitle")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-welcome-wizard-mss-list",children:(0,p.jsxs)(r.List,{children:[(0,p.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList1")}),(0,p.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList2")}),c.MailPoet.subscribersCount<1e3?(0,p.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList3Free")}):(0,p.jsx)("li",{children:c.MailPoet.I18n.t("welcomeWizardMSSList3Paid")})]})}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,href:vc,target:"_blank",rel:"noopener noreferrer",onClick:a=>function(e,t,a){e.preventDefault(),window.open(vc),xc(t,`/steps/${a}/part/2`)}(a,e,t),iconEnd:(0,p.jsx)(pa.Z,{icon:gc.Z}),children:c.MailPoet.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(bc,{})]})}var yc=a(86873),wc=a(77135);function Sc(){const e=(0,ke.k6)(),{step:t}=(0,ke.UO)(),a=(0,sc.v9)("getKeyActivationState")();return(0,o.useEffect)((()=>{!0===a.isKeyValid&&xc(e,`/steps/${t}/part/3`,!0)}),[a.isKeyValid,e,t]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.Heading,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartTitle")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartEnterKey")}),(0,p.jsx)("p",{children:f()(c.MailPoet.I18n.t("welcomeWizardMSSSecondPartNoAccount"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,p.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase",children:e},t)))}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("label",{htmlFor:"mailpoet_premium_key",children:[(0,p.jsx)("span",{className:"mailpoet-wizard-label",children:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartInputLabel")}),(0,p.jsx)(wc.c,{placeholder:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartInputPlaceholder"),isFullWidth:!0})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(yc.X,{label:c.MailPoet.I18n.t("welcomeWizardMSSSecondPartButton"),isFullWidth:!0}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(bc,{})]})}function Pc(){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(wt.X,{level:1,children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartTitle")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartFirstParagraph")}),(0,p.jsx)("p",{children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartSecondParagraph")}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(r.Button,{className:"mailpoet-wizard-continue-button",type:"button",onClick:()=>fc(),isFullWidth:!0,children:c.MailPoet.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function Mc(){const{path:e}=(0,ke.$B)(),{step:t}=(0,ke.UO)(),a=(0,ke.k6)(),i=(0,ke.TH)();return(0,o.useEffect)((()=>{i.pathname.includes("part")||xc(a,`/steps/${t}/part/1`,!0)}),[t,e,a,i]),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:`${e}/part/1`,children:(0,p.jsx)(jc,{})}),(0,p.jsx)(ke.AW,{path:`${e}/part/2`,children:(0,p.jsx)(Sc,{})}),(0,p.jsx)(ke.AW,{path:`${e}/part/3`,children:(0,p.jsx)(Pc,{})})]})}const Nc=({name:e,address:t})=>{const a=t.split("@").pop().toLowerCase();return window.mailpoet_free_domains.indexOf(a)>-1?(({name:e,address:t})=>{const a=`wordpress@${window.location.hostname.replace("www.","")}`;return{sender:{name:e,address:a},reply_to:{name:e,address:t},"signup_confirmation.from.address":a,"signup_confirmation.from.name":e,"signup_confirmation.reply_to.address":t,"signup_confirmation.reply_to.name":e}})({name:e,address:t}):(({name:e,address:t})=>({sender:{name:e,address:t},reply_to:{name:e,address:t},"signup_confirmation.from.address":t,"signup_confirmation.from.name":e,"signup_confirmation.reply_to.address":t,"signup_confirmation.reply_to.name":e}))({name:e,address:t})},Cc=()=>{const e=["WelcomeWizardSenderStep"];return window.mailpoet_is_dotcom||e.push("WelcomeWizardUsageTrackingStep"),window.mailpoet_woocommerce_active&&e.push("WizardWooCommerceStep"),window.mailpoet_has_valid_api_key||e.push("WelcomeWizardPitchMSSStep"),e},Ic=()=>Cc().length,kc=e=>Cc()[e-1]||null,Tc=async(e,t,a)=>{a<Ic()?xc(e,`/steps/${a+1}`):t()};var Ec=a(93006);function Ac({match:e,history:t}){const a=Ic(),i=parseInt(e.params.step,10),[s,n]=(0,o.useState)(!1),[l,c]=(0,sc.yu)("sender"),m=(0,sc.yu)("analytics")[1],u=(0,sc.yu)("3rd_party_libs")[1];(0,o.useEffect)((()=>{(i>a||i<1)&&xc(t,"/steps/1")}),[i,a,t]);const h=(0,ut.partial)(Tc,t,fc),g=(0,o.useCallback)((async(e,t)=>{const a={enabled:e?"1":""},i={enabled:t?"1":""},s={analytics:a,"3rd_party_libs":i};await _c(s),m(a),u(i)}),[m,u]),_=(0,o.useCallback)((async(e,t)=>{n(!0),await g(e,t),h(i),n(!1)}),[h,i,g]),f=(0,o.useCallback)((e=>{c({...l,...e})}),[l,c]),b=(0,o.useCallback)((async()=>{n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await g(!0,!0),await _c(Nc(l)).then((()=>h(i))),n(!1)}),[h,l,i,g]),x=(0,o.useCallback)((async e=>{e.preventDefault(),n(!0);const t={address:window.admin_email,name:""};window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await g(!0,!0),await _c(Nc(t)).then((()=>{c(t),h(i)})),n(!1)}),[h,i,c,g]),v=kc(i);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(It.B,{}),(0,p.jsx)(d.D,{logoWithLink:!1,children:(0,p.jsx)(Ec.R,{count:a,current:i,doneCallback:e=>{xc(t,`/steps/${e}`)}})}),(0,p.jsxs)(nc,{children:["WelcomeWizardSenderStep"===v?(0,p.jsx)(cc,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(uc,{update_sender:f,submit_sender:b,skipStep:x,loading:s,sender:l})})}):null,"WelcomeWizardUsageTrackingStep"===v?(0,p.jsx)(cc,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(hc,{loading:s,submitForm:_})})}):null,"WelcomeWizardPitchMSSStep"===v?(0,p.jsx)(cc,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Mc,{})})}):null,"WizardWooCommerceStep"===v?(0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(mc,{isWizardStep:!0,redirectToNextStep:()=>h(i)})}):null]})]})}function Rc(){let e="/steps/1";const t=window.mailpoet_welcome_wizard_current_step;"string"==typeof t&&t.startsWith("/steps")&&(e=t),window.location.search.includes("woocommerce-setup")&&(e="/woocommerce");const a=(0,l.S)(window);return(0,p.jsx)(l.k.Provider,{value:a,children:(0,p.jsxs)(Ie.HashRouter,{children:[(0,p.jsx)(m.w,{}),(0,p.jsxs)(ke.rs,{children:[(0,p.jsx)(ke.AW,{path:"/steps/:step",component:(0,r.withBoundary)(Ac)}),(0,p.jsx)(ke.AW,{path:"/woocommerce",component:(0,r.withBoundary)(mc)}),(0,p.jsx)(ke.AW,{render:()=>(0,p.jsx)(ke.l_,{to:e})})]})]})})}Ac.displayName="WelcomeWizardStepsController";const Fc=document.getElementById("mailpoet-wizard-container");function Oc(){const[e,t]=(0,o.useState)(null),a=(0,l.S)(window),i=a.notices.error;function s(s){const n=s.target.name,o=s.target.checked;c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"set",data:{[n]:o?1:0}}).done((()=>{const i=e[n];i.value=o,t({...e,[n]:i});const s=`Feature '${n}' was ${o?"enabled":"disabled"}.`;a.notices.success((0,p.jsx)("p",{children:s}))})).fail((e=>{e.errors.length>0&&i(e.errors.map((e=>(0,p.jsx)("p",{children:e.message},e.message))),{scroll:!0})}))}return(0,o.useEffect)((()=>{c.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"getAll"}).done((e=>{const a=e.data.reduce(((e,t)=>({...e,[t.name]:t})),{});t(a)})).fail((e=>{e.errors.length>0&&i((0,p.jsx)(p.Fragment,{children:e.errors.map((e=>(0,p.jsx)("p",{children:e.message})))}),{scroll:!0})}))}),[i]),null===e?(0,p.jsx)("p",{children:"Loading experimental features..."}):0===Object.values(e).length?(0,p.jsx)("p",{children:"There are no experimental features at the moment."}):(0,p.jsx)(l.k.Provider,{value:a,children:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(m.w,{}),Object.values(e).map((e=>{const t=`experimental-feature-${e.name}`;return(0,p.jsx)("div",{children:(0,p.jsxs)("label",{htmlFor:t,children:[(0,p.jsx)("input",{id:t,type:"checkbox",name:e.name,defaultChecked:e.value,onChange:s})," ",e.name]})},e.name)}))]})})}Fc&&((0,r.registerTranslations)(),(0,ic.N)(),(0,n.s)(Fc).render((0,p.jsx)(Rc,{})));const Dc=document.getElementById("experimental_features_container");Oc.displayName="ExperimentalFeatures",Dc&&((0,r.registerTranslations)(),(0,n.s)(Dc).render((0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Oc,{})})));var Lc=a(26227);function qc({message:e,editing:t}){return t?(0,p.jsx)("textarea",{value:e,className:"mailpoet-logs-full-message",readOnly:!0}):(0,p.jsx)(p.Fragment,{children:`${e.substr(0,150)}…`})}function Bc({log:e}){const[t,a]=(0,o.useState)(!1);return(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{role:"gridcell",children:e.name}),(0,p.jsx)("td",{onClick:function(e){(function(e){return(e.ctrlKey||e.metaKey)&&!e.altKey})(e)&&(t||a(!0))},role:"gridcell",children:(0,p.jsx)(qc,{message:e.message,editing:t})}),(0,p.jsx)("td",{role:"gridcell",children:c.MailPoet.Date.full(e.created_at)})]},`log-row-${e.id}`)}function Wc({logs:e,onFilter:t,originalFrom:a,originalTo:i,originalSearch:s,originalOffset:n,originalLimit:l}){const[d,m]=(0,o.useState)(a??void 0),[u,h]=(0,o.useState)(i??void 0),[g,_]=(0,o.useState)(n??""),[f,b]=(0,o.useState)(l??""),[x,v]=(0,o.useState)(s||""),j=(0,Aa.curry)(((e,t)=>{e(null!==t?c.MailPoet.Date.format(t,{format:"Y-m-d"}):void 0)})),y=(0,o.useCallback)((()=>{const e={};d&&(e.from=d),u&&(e.to=u),g&&""!==g.trim()&&(e.offset=g),f&&""!==f.trim()&&(e.limit=f),x&&""!==x.trim()&&(e.search=x.trim()),t(e)}),[d,f,g,x,u,t]);return(0,p.jsxs)("div",{className:"mailpoet-listing mailpoet-logs",children:[(0,p.jsxs)("div",{className:"mailpoet-listing-header",children:[(0,p.jsxs)("div",{className:"mailpoet-listing-search",children:[(0,p.jsx)("label",{htmlFor:"search_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("searchLabel")}),(0,p.jsx)(r.Input,{dimension:"small",iconStart:Lc.J,type:"search",id:"search_input",name:"s",onChange:e=>v(e.target.value),value:x,placeholder:c.MailPoet.I18n.t("searchLabel")})]}),(0,p.jsxs)("div",{className:"mailpoet-listing-filters",children:[`${c.MailPoet.I18n.t("from")}:`,(0,p.jsxs)(r.ErrorBoundary,{children:[(0,p.jsx)($a.a,{dateFormat:"MMMM d, yyyy",onChange:j(m),maxDate:new Date,selected:d?(0,ar.default)(d):void 0,dimension:"small"}),`${c.MailPoet.I18n.t("to")}:`,(0,p.jsx)($a.a,{dateFormat:"MMMM d, yyyy",onChange:j(h),maxDate:new Date,selected:u?(0,ar.default)(u):void 0,dimension:"small"})]})]}),(0,p.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,p.jsx)("label",{htmlFor:"offset_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("offsetLabel")}),(0,p.jsx)(r.Input,{dimension:"small",id:"offset_input",name:"o",type:"number",onChange:e=>_(e.target.value),value:g,placeholder:c.MailPoet.I18n.t("offsetLabel")})]}),(0,p.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,p.jsx)("label",{htmlFor:"limit_input",className:"screen-reader-text",children:c.MailPoet.I18n.t("limitLabel")}),(0,p.jsx)(r.Input,{dimension:"small",id:"limit_input",name:"l",type:"number",onChange:e=>b(e.target.value),value:f,placeholder:c.MailPoet.I18n.t("limitLabel")})]}),(0,p.jsx)(r.Button,{dimension:"small",onClick:y,children:c.MailPoet.I18n.t("filter")})]}),(0,p.jsxs)("table",{className:"mailpoet-listing-table widefat striped",role:"grid",children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderName")}),(0,p.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderMessage")}),(0,p.jsx)("th",{children:c.MailPoet.I18n.t("tableHeaderCreatedOn")})]})}),(0,p.jsx)("tbody",{children:(0,p.jsx)(r.ErrorBoundary,{children:e.map((e=>(0,p.jsx)(Bc,{log:e},`log-${e.id}`)))})})]})]})}Bc.displayName="Log",Wc.displayName="LogsList";const $c=document.getElementById("mailpoet_logs_container");if($c){const e=new URL(window.location.href);(0,n.s)($c).render((0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(Wc,{logs:window.mailpoet_logs,originalFrom:e.searchParams.get("from"),originalTo:e.searchParams.get("to"),originalSearch:e.searchParams.get("search"),originalOffset:e.searchParams.get("offset"),originalLimit:e.searchParams.get("limit"),onFilter:t=>{e.searchParams.delete("from"),e.searchParams.delete("to"),e.searchParams.delete("search"),e.searchParams.delete("offset"),e.searchParams.delete("limit"),Object.entries(t).forEach((([t,a])=>{e.searchParams.append(t,a)})),window.location.href=e.href}})}))}var Uc=a(634);function Vc({onRequestClose:e}){const[t,a]=(0,o.useState)(!1);return Ee()((e=>{e(document).on("click",".notice .mailpoet-js-button-fix-this",(()=>{a(!0)}))})),(0,p.jsxs)(l.k.Provider,{value:(0,l.S)(window),children:[(0,p.jsx)(m.w,{}),t&&(0,p.jsx)(Uc.d,{onRequestClose:()=>{a(!1),e()}})]})}Vc.defaultProps={onRequestClose:Aa.noop};const Hc=document.getElementById("mailpoet_set_from_address_modal");Hc&&(0,n.s)(Hc).render((0,p.jsx)(Vc,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const zc=e=>(async e=>{if("MailPoet"!==c.MailPoet.mtaMethod)return!0;const t=await(async()=>"MailPoet"!==c.MailPoet.mtaMethod?[]:(await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[])(),a=(0,Ka.DA)(e);return-1!==t.indexOf(a)||-1!==(await(async()=>"MailPoet"!==c.MailPoet.mtaMethod?[]:(await c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[])()).indexOf(e)})(e).then((e=>{if(!e)return c.MailPoet.Notice.error(c.MailPoet.I18n.t("mailerSendingNotResumedUnauthorized"),{scroll:!0}),c.MailPoet.trackEvent("Unauthorized email used",{"Unauthorized email source":"send"}),!1;c.MailPoet.Ajax.post({api_version:c.MailPoet.apiVersion,endpoint:"mailer",action:"resumeSending"}).done((()=>{c.MailPoet.Notice.success(c.MailPoet.I18n.t("mailerSendingResumedNotice"))})).fail((e=>{e.errors.length>0&&c.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0})}))}));Ee()((e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",(e=>{zc(e.target.value)}))}));var Zc=a(79142);const Yc=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),a=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,Ka.HD)()||"some other"} page`;e&&e.type&&"email"===e.type?c.MailPoet.trackEvent("MSS in plugin authorize email",{"authorized email source":"modal","original page":t,wasSuccessful:"yes"}):e&&e.type&&"domain"===e.type&&c.MailPoet.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"modal","original page":t,wasSuccessful:"yes"})})(e),(t||a)&&window.location.reload()};function Gc(){const[e,t]=(0,o.useState)(""),[a,i]=(0,o.useState)("email");return(0,o.useEffect)((()=>{const e=e=>{e.preventDefault();const a=String(e?.target?.dataset?.email||""),s=String(e?.target?.dataset?.type||"");i(s||"email"),t(a)};Ee()((t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)}))}),[]),(0,p.jsx)(p.Fragment,{children:e&&(0,p.jsx)(Zc.h,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:Yc,showSenderEmailTab:"email"===a,showSenderDomainTab:"domain"===a,initialTab:"domain"===a?"sender_domain":"sender_email"})})}const Kc=document.getElementById("mailpoet_authorize_sender_email_modal");Kc&&(0,n.s)(Kc).render((0,p.jsx)(Gc,{}));const Qc=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function Jc(){const e=window.mailpoet_welcome_wizard_current_step,t="string"==typeof e&&e.startsWith("/steps");return(0,p.jsx)(r.Button,{onClick:Qc,dimension:"hero",children:t?(0,Le.__)("Continue setup","mailpoet"):(0,Le.__)("Begin setup","mailpoet")})}function Xc(){return(0,p.jsx)("section",{className:"landing-header",children:(0,p.jsxs)("div",{className:"mailpoet-content-center",children:[(0,p.jsx)(wt.X,{level:0,children:(0,Le.__)("Better email — without leaving WordPress","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Whether you’re just starting out or have already established your business, we’ve got the tools you need to reach customers where they are.","mailpoet")}),(0,p.jsx)(Jc,{})]})})}function em(){return(0,p.jsx)("section",{className:"landing-footer",children:(0,p.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,p.jsxs)(wt.X,{level:4,children:[" ",(0,Le.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,p.jsx)(Jc,{})]})})}function tm(){const e=[{slug:"item-1",title:(0,Le.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,Le.__)("MailPoet allows you to create five different types of campaigns: Newsletter, Welcome Email, Latest Post Notifications, Re-engagement Emails, and WooCommerce behavior-based emails.","mailpoet"),readMoreText:(0,Le.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,Le.__)("How do I send a newsletter?","mailpoet"),text:(0,Le.__)("You can manually create a standard newsletter to be sent immediately or scheduled to be sent at a later time. Simply go to MailPoet > Emails and click on the “+ New Email” button to select “Newsletter”.","mailpoet"),readMoreText:(0,Le.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,Le.__)("Do I need a paid plan?","mailpoet"),text:(0,Le.__)("When you install the MailPoet plugin, you can use it for free up to 1,000 subscribers. If you have more than 1,000 subscribers, or want access to MailPoet’s advanced features, you'll need one of our paid plans: Creator, Business, or Agency. The best choice of plan type will depend on whether you want to send with our MailPoet Sending Service or your own sending method, as well as the number of sites you will be using MailPoet on.","mailpoet"),readMoreText:(0,Le.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-choosing-your-mailpoet-plan"},{slug:"item-4",title:(0,Le.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,Le.__)('The WooCommerce Customers list is a list automatically created by MailPoet with all of your WooCommerce customers. It also includes “Guest" customers. If WooCommerce is active, users that installed or updated the plugin should have chosen if they wanted to add the customers as “Subscribed” or “Unsubscribed” to the WooCommerce Customers list.',"mailpoet"),readMoreText:(0,Le.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,Le.__)("How do I customize emails for my store?","mailpoet"),text:(0,Le.__)("You can create and send the following four WooCommerce Automatic emails with MailPoet: Abandoned Shopping Cart, First Purchase, Purchased In This Category, Purchased This Product. You can read more about each in our article.","mailpoet"),readMoreText:(0,Le.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/277-woocommerce-automatic-emails"}];return(0,p.jsxs)("section",{className:"landing-faq",children:[(0,p.jsxs)("div",{className:"mailpoet-content-center landing-faq-header",children:[(0,p.jsxs)(wt.X,{level:2,children:[" ",(0,Le.__)("Frequently asked questions","mailpoet")," "]}),(0,p.jsx)("p",{children:f()((0,Le.__)("Here are some common questions on getting started. Can't find what you're looking for? [link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]}),(0,p.jsx)("div",{className:"mailpoet-content-center landing-faq-mobile",children:(0,p.jsx)(wt.X,{level:2,children:(0,Le.__)("FAQ","mailpoet")})}),(0,p.jsx)("div",{className:"mailpoet-faq-accordion",children:e.map((e=>(0,p.jsxs)("details",{children:[(0,p.jsxs)("summary",{children:[" ",(0,p.jsxs)("strong",{children:[" ",e.title," "]})," "]}),(0,p.jsxs)("div",{className:"content",children:[(0,p.jsx)("p",{children:e.text}),(0,p.jsx)("p",{children:(0,p.jsx)("a",{href:e.readMoreLink,rel:"noopener noreferrer",target:"_blank",children:e.readMoreText})})]})]},e.slug)))}),(0,p.jsxs)("div",{className:"mailpoet-content-center landing-faq-mobile",children:[(0,p.jsx)("p",{children:(0,Le.__)("Can’t find what you’re looking for?","mailpoet")}),(0,p.jsx)("p",{children:f()((0,Le.__)("[link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,p.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]})]})}Xc.displayName="Landingpage Header",em.displayName="Landingpage Footer",tm.displayName="Landingpage FAQ";const am={heroImage:`${c.MailPoet.cdnUrl}landingpage/landingpage-hero-image.png`,featureImages:{icon_1:`${c.MailPoet.cdnUrl}landingpage/feature_icon_1.png`,icon_2:`${c.MailPoet.cdnUrl}landingpage/feature_icon_2.png`,icon_3:`${c.MailPoet.cdnUrl}landingpage/feature_icon_3.png`,icon_4:`${c.MailPoet.cdnUrl}landingpage/feature_icon_4.png`},wooCommerceFeatureImages:{feature_1:`${c.MailPoet.cdnUrl}landingpage/woo_feature_automate_your_marketing.png`,feature_2:`${c.MailPoet.cdnUrl}landingpage/woo_feature_measure_revenue_per_email.png`,feature_3:`${c.MailPoet.cdnUrl}landingpage/woo_feature_let_your_brand_shine.png`,feature_4:`${c.MailPoet.cdnUrl}landingpage/woo_feature_rescue_abandoned_carts.png`}};function im(){return(0,p.jsxs)("section",{className:"landing-content",children:[(0,p.jsxs)("div",{className:"hero-section mailpoet-content-center",children:[(0,p.jsx)("img",{src:am.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,p.jsx)("br",{}),(0,p.jsx)("br",{}),(0,p.jsx)(wt.X,{level:4,children:(0,Le.sprintf)((0,Le.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"700,000+")}),(0,p.jsx)("br",{}),(0,p.jsxs)(Da.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("img",{src:am.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,p.jsx)("strong",{children:(0,Le.__)("Deliver beautiful emails","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Choose from our pre-built templates or create your own with our drag-and-drop email builder.","mailpoet")})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("img",{src:am.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,p.jsx)("strong",{children:(0,Le.__)("Grow your mailing list","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Use our custom sign-up forms to reach more subscribers while you deliver engaging content.","mailpoet")})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("img",{src:am.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,p.jsx)("strong",{children:(0,Le.__)("Reach the right people","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("From the first hello to repeated purchases, send emails to the right people at the right time.","mailpoet")})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("img",{src:am.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,p.jsx)("strong",{children:(0,Le.__)("Save time with automations","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Set up smart triggers based on user behavior to automate list management, email sending, and more.","mailpoet")})]})]})]}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsxs)("div",{className:"landingpage-wooCommerce-features",children:[(0,p.jsxs)("div",{className:"mailpoet-content-center",children:[(0,p.jsx)(wt.X,{level:2,children:(0,Le.__)("MailPoet + WooCommerce","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,p.jsx)("br",{}),(0,p.jsxs)(Da.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,p.jsx)("div",{children:(0,p.jsx)("img",{src:am.wooCommerceFeatureImages.feature_1,alt:(0,Le.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("strong",{children:(0,Le.__)("Automate customer communication","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,p.jsxs)(Da.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,p.jsx)("div",{children:(0,p.jsx)("img",{src:am.wooCommerceFeatureImages.feature_2,alt:(0,Le.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("strong",{children:(0,Le.__)("Measure revenue per email","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,p.jsxs)(Da.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,p.jsx)("div",{children:(0,p.jsx)("img",{src:am.wooCommerceFeatureImages.feature_3,alt:(0,Le.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("strong",{children:(0,Le.__)("Let your brand shine","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,p.jsxs)(Da.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,p.jsx)("div",{children:(0,p.jsx)("img",{src:am.wooCommerceFeatureImages.feature_4,alt:(0,Le.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("strong",{children:(0,Le.__)("Rescue abandoned carts","mailpoet")}),(0,p.jsx)("p",{children:(0,Le.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function sm(){return(0,p.jsx)(l.k.Provider,{value:(0,l.S)(window),children:(0,p.jsxs)("main",{children:[(0,p.jsx)(It.B,{}),(0,p.jsx)(d.Q,{}),(0,p.jsx)(nt.A,{color:"#fff"}),(0,p.jsx)(Xc,{}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(im,{}),(0,p.jsx)("div",{className:"mailpoet-gap"}),(0,p.jsx)(tm,{}),(0,p.jsx)(em,{})]})})}im.displayName="Landingpage Content",sm.displayName="Landingpage";const nm=document.getElementById("mailpoet_landingpage_container");nm&&((0,r.registerTranslations)(),(0,n.s)(nm).render((0,p.jsx)(r.ErrorBoundary,{children:(0,p.jsx)(sm,{})}))),a(86555)},86555:function(){document.addEventListener("DOMContentLoaded",(function(){window.mailpoet_track_wizard_loaded_via_woocommerce&&(window.MailPoet.trackEvent("User opened the MailPoet setup task in WooCommerce > Home",{"WooCommerce version":window.mailpoet_woocommerce_version}),window.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"delete",data:"send_event_that_wizard_was_loaded_via_woocommerce"})),window.mailpoet_track_wizard_loaded_via_woocommerce_marketing_dashboard&&(window.MailPoet.trackEvent("User clicked on complete MailPoet setup in WooCommerce > Multichannel Marketing dashboard",{"WooCommerce version":window.mailpoet_woocommerce_version}),window.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"delete",data:"wizard_loaded_via_woocommerce_marketing_dashboard"}))}))},28270:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,a){var i;if("formatting"===(null!=a&&a.context?String(a.context):"standalone")&&e.formattingValues){var s=e.defaultFormattingWidth||e.defaultWidth,n=null!=a&&a.width?String(a.width):s;i=e.formattingValues[n]||e.formattingValues[s]}else{var o=e.defaultWidth,r=null!=a&&a.width?String(a.width):e.defaultWidth;i=e.values[r]||e.values[o]}return i[e.argumentCallback?e.argumentCallback(t):t]}},e.exports=t.default},80824:function(e,t){var a,i;a=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},a=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,s={},n=0,o={parse:function(a,i){var r=(i=i||{}).dynamicTyping||!1;if(j(r)&&(i.dynamicTypingFunction=r,r={}),i.dynamicTyping=r,i.transform=!!j(i.transform)&&i.transform,i.worker&&o.WORKERS_SUPPORTED){var l=function(){if(!o.WORKERS_SUPPORTED)return!1;var a,i,r=(a=t.URL||t.webkitURL||null,i=e.toString(),o.BLOB_URL||(o.BLOB_URL=a.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",i,")();"],{type:"text/javascript"})))),l=new t.Worker(r);return l.onmessage=_,l.id=n++,s[l.id]=l}();return l.userStep=i.step,l.userChunk=i.chunk,l.userComplete=i.complete,l.userError=i.error,i.step=j(i.step),i.chunk=j(i.chunk),i.complete=j(i.complete),i.error=j(i.error),delete i.worker,void l.postMessage({input:a,config:i,workerId:l.id})}var p=null;return o.NODE_STREAM_INPUT,"string"==typeof a?(a=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(a),p=i.download?new d(i):new m(i)):!0===a.readable&&j(a.read)&&j(a.on)?p=new u(i):(t.File&&a instanceof File||a instanceof Object)&&(p=new c(i)),p.stream(a)},unparse:function(e,t){var a=!1,i=!0,s=",",n="\r\n",r='"',l=r+r,d=!1,c=null,m=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||o.BAD_DELIMITERS.filter((function(e){return-1!==t.delimiter.indexOf(e)})).length||(s=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(a=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(d=t.skipEmptyLines),"string"==typeof t.newline&&(n=t.newline),"string"==typeof t.quoteChar&&(r=t.quoteChar),"boolean"==typeof t.header&&(i=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+r),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(m=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var u=new RegExp(h(r),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return p(null,e,d);if("object"==typeof e[0])return p(c||Object.keys(e[0]),e,d)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),p(e.fields||[],e.data||[],d);throw new Error("Unable to serialize unrecognized input");function p(e,t,a){var o="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var r=Array.isArray(e)&&0<e.length,l=!Array.isArray(t[0]);if(r&&i){for(var d=0;d<e.length;d++)0<d&&(o+=s),o+=g(e[d],d);0<t.length&&(o+=n)}for(var c=0;c<t.length;c++){var m=r?e.length:t[c].length,u=!1,p=r?0===Object.keys(t[c]).length:0===t[c].length;if(a&&!r&&(u="greedy"===a?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===a&&r){for(var h=[],_=0;_<m;_++){var f=l?e[_]:_;h.push(t[c][f])}u=""===h.join("").trim()}if(!u){for(var b=0;b<m;b++){0<b&&!p&&(o+=s);var x=r&&l?e[b]:b;o+=g(t[c][x],b)}c<t.length-1&&(!a||0<m&&!p)&&(o+=n)}}return o}function g(e,t){if(null==e)return"";if(e.constructor===Date)return JSON.stringify(e).slice(1,25);var i=!1;m&&"string"==typeof e&&m.test(e)&&(e="'"+e,i=!0);var n=e.toString().replace(u,l);return(i=i||!0===a||"function"==typeof a&&a(e,t)||Array.isArray(a)&&a[t]||function(e,t){for(var a=0;a<t.length;a++)if(-1<e.indexOf(t[a]))return!0;return!1}(n,o.BAD_DELIMITERS)||-1<n.indexOf(s)||" "===n.charAt(0)||" "===n.charAt(n.length-1))?r+n+r:n}}};if(o.RECORD_SEP=String.fromCharCode(30),o.UNIT_SEP=String.fromCharCode(31),o.BYTE_ORDER_MARK="\ufeff",o.BAD_DELIMITERS=["\r","\n",'"',o.BYTE_ORDER_MARK],o.WORKERS_SUPPORTED=!a&&!!t.Worker,o.NODE_STREAM_INPUT=1,o.LocalChunkSize=10485760,o.RemoteChunkSize=5242880,o.DefaultDelimiter=",",o.Parser=g,o.ParserHandle=p,o.NetworkStreamer=d,o.FileStreamer=c,o.StringStreamer=m,o.ReadableStreamStreamer=u,t.jQuery){var r=t.jQuery;r.fn.parse=function(e){var a=e.config||{},i=[];return this.each((function(e){if("INPUT"!==r(this).prop("tagName").toUpperCase()||"file"!==r(this).attr("type").toLowerCase()||!t.FileReader||!this.files||0===this.files.length)return!0;for(var s=0;s<this.files.length;s++)i.push({file:this.files[s],inputElem:this,instanceConfig:r.extend({},a)})})),s(),this;function s(){if(0!==i.length){var t,a,s,l=i[0];if(j(e.before)){var d=e.before(l.file,l.inputElem);if("object"==typeof d){if("abort"===d.action)return"AbortError",t=l.file,a=l.inputElem,s=d.reason,void(j(e.error)&&e.error({name:"AbortError"},t,a,s));if("skip"===d.action)return void n();"object"==typeof d.config&&(l.instanceConfig=r.extend(l.instanceConfig,d.config))}else if("skip"===d)return void n()}var c=l.instanceConfig.complete;l.instanceConfig.complete=function(e){j(c)&&c(e,l.file,l.inputElem),n()},o.parse(l.file,l.instanceConfig)}else j(e.complete)&&e.complete()}function n(){i.splice(0,1),s()}}}function l(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=x(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new p(t),(this._handle.streamer=this)._config=t}.call(this,e),this.parseChunk=function(e,a){if(this.isFirstChunk&&j(this._config.beforeFirstChunk)){var s=this._config.beforeFirstChunk(e);void 0!==s&&(e=s)}this.isFirstChunk=!1,this._halted=!1;var n=this._partialLine+e;this._partialLine="";var r=this._handle.parse(n,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var l=r.meta.cursor;this._finished||(this._partialLine=n.substring(l-this._baseIndex),this._baseIndex=l),r&&r.data&&(this._rowCount+=r.data.length);var d=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(i)t.postMessage({results:r,workerId:o.WORKER_ID,finished:d});else if(j(this._config.chunk)&&!a){if(this._config.chunk(r,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);r=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(r.data),this._completeResults.errors=this._completeResults.errors.concat(r.errors),this._completeResults.meta=r.meta),this._completed||!d||!j(this._config.complete)||r&&r.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),d||r&&r.meta.paused||this._nextChunk(),r}this._halted=!0},this._sendError=function(e){j(this._config.error)?this._config.error(e):i&&this._config.error&&t.postMessage({workerId:o.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=o.RemoteChunkSize),l.call(this,e),this._nextChunk=a?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),a||(t.onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!a),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var i in e)t.setRequestHeader(i,e[i])}if(this._config.chunkSize){var s=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+s)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}a&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var a=t.statusText||e;this._sendError(new Error(a))}}function c(e){var t,a;(e=e||{}).chunkSize||(e.chunkSize=o.LocalChunkSize),l.call(this,e);var i="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,a=e.slice||e.webkitSlice||e.mozSlice,i?((t=new FileReader).onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input;if(this._config.chunkSize){var s=Math.min(this._start+this._config.chunkSize,this._input.size);e=a.call(e,this._start,s)}var n=t.readAsText(e,this._config.encoding);i||this._chunkLoaded({target:{result:n}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function m(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,a=this._config.chunkSize;return a?(e=t.substring(0,a),t=t.substring(a)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function u(e){l.call(this,e=e||{});var t=[],a=!0,i=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){i&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):a=!0},this._streamData=v((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),a&&(a=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=v((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=v((function(){this._streamCleanUp(),i=!0,this._streamData("")}),this),this._streamCleanUp=v((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function p(e){var t,a,i,s=Math.pow(2,53),n=-s,r=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,d=this,c=0,m=0,u=!1,p=!1,_=[],f={data:[],errors:[],meta:{}};if(j(e.step)){var b=e.step;e.step=function(t){if(f=t,w())y();else{if(y(),0===f.data.length)return;c+=t.data.length,e.preview&&c>e.preview?a.abort():(f.data=f.data[0],b(f,d))}}}function v(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function y(){return f&&i&&(P("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),i=!1),e.skipEmptyLines&&(f.data=f.data.filter((function(e){return!v(e)}))),w()&&function(){if(f)if(Array.isArray(f.data[0])){for(var t=0;w()&&t<f.data.length;t++)f.data[t].forEach(a);f.data.splice(0,1)}else f.data.forEach(a);function a(t,a){j(e.transformHeader)&&(t=e.transformHeader(t,a)),_.push(t)}}(),function(){if(!f||!e.header&&!e.dynamicTyping&&!e.transform)return f;function t(t,a){var i,s=e.header?{}:[];for(i=0;i<t.length;i++){var n=i,o=t[i];e.header&&(n=i>=_.length?"__parsed_extra":_[i]),e.transform&&(o=e.transform(o,n)),o=S(n,o),"__parsed_extra"===n?(s[n]=s[n]||[],s[n].push(o)):s[n]=o}return e.header&&(i>_.length?P("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,m+a):i<_.length&&P("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+i,m+a)),s}var a=1;return!f.data.length||Array.isArray(f.data[0])?(f.data=f.data.map(t),a=f.data.length):f.data=t(f.data,0),e.header&&f.meta&&(f.meta.fields=_),m+=a,f}()}function w(){return e.header&&0===_.length}function S(t,a){return i=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[i]&&(e.dynamicTyping[i]=e.dynamicTypingFunction(i)),!0===(e.dynamicTyping[i]||e.dynamicTyping)?"true"===a||"TRUE"===a||"false"!==a&&"FALSE"!==a&&(function(e){if(r.test(e)){var t=parseFloat(e);if(n<t&&t<s)return!0}return!1}(a)?parseFloat(a):l.test(a)?new Date(a):""===a?null:a):a;var i}function P(e,t,a,i){var s={type:e,code:t,message:a};void 0!==i&&(s.row=i),f.errors.push(s)}this.parse=function(s,n,r){var l=e.quoteChar||'"';if(e.newline||(e.newline=function(e,t){e=e.substring(0,1048576);var a=new RegExp(h(t)+"([^]*?)"+h(t),"gm"),i=(e=e.replace(a,"")).split("\r"),s=e.split("\n"),n=1<s.length&&s[0].length<i[0].length;if(1===i.length||n)return"\n";for(var o=0,r=0;r<i.length;r++)"\n"===i[r][0]&&o++;return o>=i.length/2?"\r\n":"\r"}(s,l)),i=!1,e.delimiter)j(e.delimiter)&&(e.delimiter=e.delimiter(s),f.meta.delimiter=e.delimiter);else{var d=function(t,a,i,s,n){var r,l,d,c;n=n||[",","\t","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var m=0;m<n.length;m++){var u=n[m],p=0,h=0,_=0;d=void 0;for(var f=new g({comments:s,delimiter:u,newline:a,preview:10}).parse(t),b=0;b<f.data.length;b++)if(i&&v(f.data[b]))_++;else{var x=f.data[b].length;h+=x,void 0!==d?0<x&&(p+=Math.abs(x-d),d=x):d=x}0<f.data.length&&(h/=f.data.length-_),(void 0===l||p<=l)&&(void 0===c||c<h)&&1.99<h&&(l=p,r=u,c=h)}return{successful:!!(e.delimiter=r),bestDelimiter:r}}(s,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess);d.successful?e.delimiter=d.bestDelimiter:(i=!0,e.delimiter=o.DefaultDelimiter),f.meta.delimiter=e.delimiter}var c=x(e);return e.preview&&e.header&&c.preview++,t=s,a=new g(c),f=a.parse(t,n,r),y(),u?{meta:{paused:!0}}:f||{meta:{paused:!1}}},this.paused=function(){return u},this.pause=function(){u=!0,a.abort(),t=j(e.chunk)?"":t.substring(a.getCharIndex())},this.resume=function(){d.streamer._halted?(u=!1,d.streamer.parseChunk(t,!0)):setTimeout(d.resume,3)},this.aborted=function(){return p},this.abort=function(){p=!0,a.abort(),f.meta.aborted=!0,j(e.complete)&&e.complete(f),t=""}}function h(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(e){var t,a=(e=e||{}).delimiter,i=e.newline,s=e.comments,n=e.step,r=e.preview,l=e.fastMode,d=t=void 0===e.quoteChar||null===e.quoteChar?'"':e.quoteChar;if(void 0!==e.escapeChar&&(d=e.escapeChar),("string"!=typeof a||-1<o.BAD_DELIMITERS.indexOf(a))&&(a=","),s===a)throw new Error("Comment character same as delimiter");!0===s?s="#":("string"!=typeof s||-1<o.BAD_DELIMITERS.indexOf(s))&&(s=!1),"\n"!==i&&"\r"!==i&&"\r\n"!==i&&(i="\n");var c=0,m=!1;this.parse=function(o,u,p){if("string"!=typeof o)throw new Error("Input must be a string");var g=o.length,_=a.length,f=i.length,b=s.length,x=j(n),v=[],y=[],w=[],S=c=0;if(!o)return z();if(e.header&&!u){var P=o.split(i)[0].split(a),M=[],N={},C=!1;for(var I in P){var k=P[I];j(e.transformHeader)&&(k=e.transformHeader(k,I));var T=k,E=N[k]||0;for(0<E&&(C=!0,T=k+"_"+E),N[k]=E+1;M.includes(T);)T=T+"_"+E;M.push(T)}if(C){var A=o.split(i);A[0]=M.join(a),o=A.join(i)}}if(l||!1!==l&&-1===o.indexOf(t)){for(var R=o.split(i),F=0;F<R.length;F++){if(w=R[F],c+=w.length,F!==R.length-1)c+=i.length;else if(p)return z();if(!s||w.substring(0,b)!==s){if(x){if(v=[],$(w.split(a)),Z(),m)return z()}else $(w.split(a));if(r&&r<=F)return v=v.slice(0,r),z(!0)}}return z()}for(var O=o.indexOf(a,c),D=o.indexOf(i,c),L=new RegExp(h(d)+h(t),"g"),q=o.indexOf(t,c);;)if(o[c]!==t)if(s&&0===w.length&&o.substring(c,c+b)===s){if(-1===D)return z();c=D+f,D=o.indexOf(i,c),O=o.indexOf(a,c)}else if(-1!==O&&(O<D||-1===D))w.push(o.substring(c,O)),c=O+_,O=o.indexOf(a,c);else{if(-1===D)break;if(w.push(o.substring(c,D)),H(D+f),x&&(Z(),m))return z();if(r&&v.length>=r)return z(!0)}else for(q=c,c++;;){if(-1===(q=o.indexOf(t,q+1)))return p||y.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),V();if(q===g-1)return V(o.substring(c,q).replace(L,t));if(t!==d||o[q+1]!==d){if(t===d||0===q||o[q-1]!==d){-1!==O&&O<q+1&&(O=o.indexOf(a,q+1)),-1!==D&&D<q+1&&(D=o.indexOf(i,q+1));var B=U(-1===D?O:Math.min(O,D));if(o.substr(q+1+B,_)===a){w.push(o.substring(c,q).replace(L,t)),o[c=q+1+B+_]!==t&&(q=o.indexOf(t,c)),O=o.indexOf(a,c),D=o.indexOf(i,c);break}var W=U(D);if(o.substring(q+1+W,q+1+W+f)===i){if(w.push(o.substring(c,q).replace(L,t)),H(q+1+W+f),O=o.indexOf(a,c),q=o.indexOf(t,c),x&&(Z(),m))return z();if(r&&v.length>=r)return z(!0);break}y.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),q++}}else q++}return V();function $(e){v.push(e),S=c}function U(e){var t=0;if(-1!==e){var a=o.substring(q+1,e);a&&""===a.trim()&&(t=a.length)}return t}function V(e){return p||(void 0===e&&(e=o.substring(c)),w.push(e),c=g,$(w),x&&Z()),z()}function H(e){c=e,$(w),w=[],D=o.indexOf(i,c)}function z(e){return{data:v,errors:y,meta:{delimiter:a,linebreak:i,aborted:m,truncated:!!e,cursor:S+(u||0)}}}function Z(){n(z()),v=[],y=[]}},this.abort=function(){m=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,a=s[t.workerId],i=!1;if(t.error)a.userError(t.error,t.file);else if(t.results&&t.results.data){var n={abort:function(){i=!0,f(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:b,resume:b};if(j(a.userStep)){for(var o=0;o<t.results.data.length&&(a.userStep({data:t.results.data[o],errors:t.results.errors,meta:t.results.meta},n),!i);o++);delete t.results}else j(a.userChunk)&&(a.userChunk(t.results,n,t.file),delete t.results)}t.finished&&!i&&f(t.workerId,t.results)}function f(e,t){var a=s[e];j(a.userComplete)&&a.userComplete(t),a.terminate(),delete s[e]}function b(){throw new Error("Not implemented.")}function x(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var a in e)t[a]=x(e[a]);return t}function v(e,t){return function(){e.apply(t,arguments)}}function j(e){return"function"==typeof e}return i&&(t.onmessage=function(e){var a=e.data;if(void 0===o.WORKER_ID&&a&&(o.WORKER_ID=a.workerId),"string"==typeof a.input)t.postMessage({workerId:o.WORKER_ID,results:o.parse(a.input,a.config),finished:!0});else if(t.File&&a.input instanceof File||a.input instanceof Object){var i=o.parse(a.input,a.config);i&&t.postMessage({workerId:o.WORKER_ID,results:i,finished:!0})}}),(d.prototype=Object.create(l.prototype)).constructor=d,(c.prototype=Object.create(l.prototype)).constructor=c,(m.prototype=Object.create(m.prototype)).constructor=m,(u.prototype=Object.create(l.prototype)).constructor=u,o},void 0===(i=a.apply(t,[]))||(e.exports=i)},23064:function(e){e.exports=function(e){if(!window.satismeter){window.satismeter=function(){var e=[];function t(){e.push(arguments)}return t.q=e,t}();var t=document.createElement("script"),a=document.getElementsByTagName("script")[0].parentNode;t.async=1,t.src="https://app.satismeter.com/satismeter.js",a.appendChild(t)}return window.satismeter(e)}},65311:function(e){"use strict";e.exports=jQuery}},function(e){e.O(0,[351],(function(){return 67163,e(e.s=67163)})),e.O()}]);
[-] form_editor.js
[edit]
[-] automation_editor.js
[edit]
[-] automation.js
[edit]
[-] index.php
[edit]
[-] form_preview.js
[edit]
[+]
..
[-] admin.js
[edit]
[-] post_editor_block.js
[edit]
[-] vendor.js
[edit]
[-] mailpoet.js
[edit]
[-] commons.js
[edit]
[+]
marketing-optin-block
[-] newsletter_editor.js
[edit]
[-] mailpoet.js.LICENSE.txt
[edit]
[-] automation_analytics.js.LICENSE.txt
[edit]
[-] settings.js
[edit]
[-] commons.js.LICENSE.txt
[edit]
[-] manifest.json
[edit]
[-] admin_vendor.js
[edit]
[-] public.js.LICENSE.txt
[edit]
[+]
skins
[+]
email-editor
[-] public.js
[edit]
[-] newsletter_editor.js.LICENSE.txt
[edit]
[-] automation_analytics.js
[edit]
[-] automation_templates.js
[edit]
[-] runtime.js
[edit]
[-] form_editor.js.LICENSE.txt
[edit]
[-] admin.js.LICENSE.txt
[edit]
[-] post_editor_block.js.LICENSE.txt
[edit]