/*! For license information please see admin.js.LICENSE.txt */
(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[884],{36202:()=>{jQuery.AsyncQueue=function(){var e,t,a,s,n=this,r=[],o=!1;return s=function(){var e=r.shift();e?(e.apply(n,[n]),!1===o&&s()):t&&t.apply(n)},this.onFailure=function(t){e=t},this.onComplete=function(e){t=e},this.add=function(e){return r.push(e),this},this.storeData=function(e){return a=e,this},this.lastCallbackData=function(){return a},this.run=function(){o=!1,s()},this.pause=function(){return o=!0,this},this.failure=function(){if(o=!0,e){var t=[n];for(i=0;i<arguments.length;i++)t.push(arguments[i]);e.apply(n,t)}},this}},22624:(e,t,a)=>{"use strict";var i={};a.r(i),a.d(i,{hideProductDiscovery:()=>I,hideTaskList:()=>N,hideUpsell:()=>U});var s={};a.r(s),a.d(s,{getCanDisplayUpsell:()=>W,getCanImportWooCommerceSubscribers:()=>T,getCurrentTask:()=>q,getGlobalSubscriberStatsChange:()=>L,getHasForms:()=>O,getHasImportedSubscribers:()=>E,getIsFreeMailUser:()=>D,getIsNewUserForSenderDomainAuth:()=>R,getIsProductDiscoveryDone:()=>$,getIsProductDiscoveryHidden:()=>P,getIsTaskListHidden:()=>C,getIsUpsellHidden:()=>H,getIsWooCommerceActive:()=>B,getListsSubscriberStatsChange:()=>M,getMssActive:()=>F,getProductDiscoveryTasksStatus:()=>A,getTasksStatus:()=>k});var n=a(79124),r=a(7378),o=a(78631),l=a(50661),d=a(29975),c=a(89470),m=a(43318),u=a(71328),p=a(19669),h=a(86106);function g({mailpoetInstalledDaysAgo:e,sendTransactionalEmails:t,mtaMethod:a,noticeDismissed:i,apiVersion:s}){const[n,o]=(0,r.useState)(!1),l=()=>{m.U.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,h.jsxs)(p.$,{type:"success",timeout:!1,onClose:l,children:[(0,h.jsx)("h3",{children:m.U.I18n.t("transactionalEmailNoticeTitle")}),(0,h.jsxs)("p",{children:[m.U.I18n.t("transactionalEmailNoticeBody")," ",(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/292-choose-how-to-send-your-wordpress-websites-emails",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("transactionalEmailNoticeBodyReadMore")})]}),(0,h.jsx)("p",{children:(0,h.jsx)("button",{type:"button",className:"button",onClick:()=>{o(!0),m.U.Ajax.post({api_version:s,endpoint:"settings",action:"set",data:{send_transactional_emails:"1"}}),l()},children:m.U.I18n.t("transactionalEmailNoticeCTA")})})]})}g.displayName="TransactionalEmailsProposeOptInNotice";var _=a(57116),f=a(82808);function x(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.q,{}),(0,h.jsx)(f.D,{}),(0,h.jsx)(g,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed}),(0,h.jsx)(_.R,{mtaLog:m.U.mtaLog,mtaMethod:m.U.mtaMethod,isInline:!0})]})}var b=a(77906),v=a(79855),j=a(52710),y=a(58013),w=a(31528),S=a(96721);function*N(){return yield(0,S.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*I(){return yield(0,S.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*U(){return yield(0,S.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function C(e){return e.taskList.isTaskListHidden}function k(e){return e.taskList.tasksStatus}function A(e){return e.productDiscovery.tasksStatus}function T(e){return e.taskList.canImportWooCommerceSubscribers}function E(e){return e.taskList.hasImportedSubscribers}function R(e){return e.taskList.isNewUserForSenderDomainAuth}function D(e){return e.taskList.isFreeMailUser}function F(e){return e.taskList.mssActive}function O(e){return e.formsCount>0}function P(e){return e.productDiscovery.isHidden}function L(e){return e.subscribersStats.global}function M(e){return e.subscribersStats.lists}function $(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function B(e){return e.isWooCommerceActive}function q(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 H(e){return e.upsell.isHidden}function W(e){return e.upsell.upsellStatus?.canDisplay}function z(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 V="mailpoet/homepage",G={};var Y=a(56973),K=a(39528),J=a(3698),Q=a.n(J);function Z(e,t,a){m.U.trackEvent(e,{ctaLabel:t},{send_immediately:!0},(()=>{window.location.href=a}))}function X({title:e,titleCompleted:t="",slug:a,link:i,order:s,isCompleted:n,isActive:r,children:o=null}){const l=Q()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":n,"mailpoet-task-list__task--active":r}),d=()=>{Z("Home Page Task",a,i)};return(0,h.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,h.jsx)("div",{className:"mailpoet-task-list__task-before",children:(0,h.jsx)("div",{className:"mailpoet-task-list__task-icon",children:n?(0,h.jsx)(Y.A,{icon:K.A}):s})}),(0,h.jsxs)("div",{className:"mailpoet-task-list__task-content",children:[(0,h.jsx)("div",{className:"mailpoet-task-list__task-title",children:n&&t?t:e}),o]})]})}function ee({onHide:e}){const{tasksStatus:t,currentTask:a,hasImportedSubscribers:i,canImportWooCommerceSubscribers:s,isNewUserForSenderDomainAuth:n,isFreeMailUser:r,mssActive:l}=(0,b.A)((e=>({tasksStatus:e(V).getTasksStatus(),currentTask:e(V).getCurrentTask(),hasImportedSubscribers:e(V).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(V).getCanImportWooCommerceSubscribers(),isNewUserForSenderDomainAuth:e(V).getIsNewUserForSenderDomainAuth(),isFreeMailUser:e(V).getIsFreeMailUser(),mssActive:e(V).getMssActive()})),[]),d=[];if(d.push((0,h.jsx)(X,{slug:"set sender",title:m.U.I18n.t("senderSetTask"),titleCompleted:m.U.I18n.t("senderSetTaskDone"),link:"admin.php?page=mailpoet-settings#/basics",order:1,isCompleted:t.senderSet,isActive:"senderSet"===a},"senderSet")),d.push((0,h.jsx)(X,{slug:"connect mss",title:m.U.I18n.t("mssConnectedTask"),titleCompleted:m.U.I18n.t("mssConnectedTaskDone"),link:"admin.php?page=mailpoet-settings#/premium",order:2,isCompleted:t.mssConnected,isActive:"mssConnected"===a},"mssConnected")),s&&d.push((0,h.jsx)(X,{slug:"import woocommerce subscribers",title:m.U.I18n.t("wooSubscribersImportedTask"),titleCompleted:m.U.I18n.t("wooSubscribersImportedTaskDone"),link:"admin.php?page=mailpoet-woocommerce-setup",order:3,isCompleted:t.wooSubscribersImported,isActive:"wooSubscribersImported"===a},"wooSubscribersImported")),d.push((0,h.jsxs)(X,{slug:"add subscribers",title:m.U.I18n.t("subscribersAddedTask"),titleCompleted:i?m.U.I18n.t("subscribersAddedTaskDoneByImport"):m.U.I18n.t("subscribersAddedTaskDoneByForm"),link:"admin.php?page=mailpoet-import",order:s?4:3,isCompleted:t.subscribersAdded,isActive:"subscribersAdded"===a,children:[!t.subscribersAdded&&(0,h.jsxs)("p",{children:[m.U.I18n.t("noSubscribersQuestion")," ",(0,h.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:o.stopLinkPropagation,children:m.U.I18n.t("setUpForm")})]}),t.subscribersAdded&&!i&&(0,h.jsxs)("p",{children:[m.U.I18n.t("haveSubscribersQuestion")," ",(0,h.jsx)("a",{href:"admin.php?page=mailpoet-import",children:m.U.I18n.t("import")})]})]},"subscribersAdded")),n&&l){let e="admin.php?page=mailpoet-settings#/basics";r||(e="admin.php?page=mailpoet-settings#/basics/authorizedEmailModal"),d.push((0,h.jsx)(X,{slug:"authenticate sender domain",title:m.U.I18n.t("senderDomainAuthenticatedTask"),titleCompleted:m.U.I18n.t("senderDomainAuthenticatedTaskDone"),link:e,order:s?5:4,isCompleted:t.senderDomainAuthenticated,isActive:"senderDomainAuthenticated"===a,children:!t.senderDomainAuthenticated&&(0,h.jsx)("p",{children:m.U.I18n.t("improveDeliveryRates")})},"senderDomainAuthenticated"))}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-task-list__heading",children:[(0,h.jsx)("h1",{children:m.U.I18n.t("welcomeToMailPoet")}),(0,h.jsx)("p",{children:m.U.I18n.t("beginByCompletingSetup")}),(0,h.jsx)(v.A,{label:m.U.I18n.t("hideList"),icon:j.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]})]}),(0,h.jsx)("ul",{children:d.map((e=>e))}),!a&&(0,h.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("youAreSet")," ",(0,h.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissList")})]})]})}function te({title:e,slug:t,link:a,description:i,doneMessage:s,imgSrc:n,isDone:r}){const o=()=>{Z("Home Page Task",t,a)};return(0,h.jsxs)("li",{className:Q()("mailpoet-product-discovery__task",{"mailpoet-product-discovery__task--completed":r}),role:"row",onClick:r?void 0:o,tabIndex:r?void 0:0,onKeyDown:r?void 0:e=>"Enter"===e.key&&o(),children:[(0,h.jsx)("img",{src:n,alt:e,width:124,height:72}),(0,h.jsx)("div",{className:"mailpoet-product-discovery__task-content",children:r?(0,h.jsx)("h3",{children:s}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h3",{children:`${e} →`}),i&&(0,h.jsx)("p",{children:i})]})}),(0,h.jsx)("div",{className:"mailpoet-product-discovery__task-after",children:r&&(0,h.jsx)("div",{className:"mailpoet-task-list__task-icon",children:(0,h.jsx)(Y.A,{icon:K.A})})})]})}function ae({heading:e,description:t,children:a,headingAfter:i,className:s=""}){return(0,h.jsxs)("section",{className:Q()("mailpoet-homepage-section__container",s),children:[(0,h.jsxs)("header",{className:"mailpoet-homepage-section__heading",children:[(0,h.jsxs)("h2",{children:[e,t&&(0,h.jsx)("span",{children:t})]}),(0,h.jsx)("div",{className:"mailpoet-homepage-section__heading-after",children:i})]}),a]})}function ie({onHide:e}){const{tasksStatus:t,isWooCommerceActive:a,isDiscoveryDone:i}=(0,b.A)((e=>({tasksStatus:e(V).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(V).getIsWooCommerceActive(),isDiscoveryDone:e(V).getIsProductDiscoveryDone()})),[]),s=[];return s.push((0,h.jsx)(te,{slug:"set up welcome campaign",title:m.U.I18n.t("setUpWelcomeCampaign"),description:m.U.I18n.t("setUpWelcomeCampaignDesc"),link:"admin.php?page=mailpoet-automation-templates&initialTab=welcome",imgSrc:`${m.U.cdnUrl}homepage/welcome-email-illustration.png`,isDone:t.setUpWelcomeCampaign,doneMessage:m.U.I18n.t("setUpWelcomeCampaignDone")},"setUpWelcomeCampaign"),(0,h.jsx)(te,{slug:"add subscription form",title:m.U.I18n.t("addSubscriptionForm"),description:m.U.I18n.t("addSubscriptionFormDesc"),link:"admin.php?page=mailpoet-form-editor-template-selection",imgSrc:`${m.U.cdnUrl}homepage/subscription-form-illustration.png`,isDone:t.addSubscriptionForm,doneMessage:m.U.I18n.t("addSubscriptionFormDone")},"addSubscriptionForm")),a?s.push((0,h.jsx)(te,{slug:"set up abandoned cart email",title:m.U.I18n.t("setUpAbandonedCartEmail"),description:m.U.I18n.t("setUpAbandonedCartEmailDesc"),link:"admin.php?page=mailpoet-automation-templates&initialTab=abandoned-cart",imgSrc:`${m.U.cdnUrl}homepage/woo-cart-email-illustration.png`,isDone:t.setUpAbandonedCartEmail,doneMessage:m.U.I18n.t("setUpAbandonedCartEmailDone")},"setUpAbandonedCartEmail"),(0,h.jsx)(te,{slug:"brand woocommerce emails",title:m.U.I18n.t("brandWooEmails"),description:m.U.I18n.t("brandWooEmailsDesc"),link:"admin.php?page=mailpoet-settings#/woocommerce",imgSrc:`${m.U.cdnUrl}homepage/woo-transactional-email-illustration.png`,isDone:t.brandWooEmails,doneMessage:m.U.I18n.t("brandWooEmailsDone")},"brandWooEmails")):s.push((0,h.jsx)(te,{slug:"send first newsletter",title:m.U.I18n.t("sendFirstNewsletter"),description:m.U.I18n.t("sendFirstNewsletterDesc"),link:"admin.php?page=mailpoet-newsletters#/new",imgSrc:`${m.U.cdnUrl}homepage/newsletter-illustration.png`,isDone:t.sendFirstNewsletter,doneMessage:m.U.I18n.t("sendFirstNewsletterDone")},"sendFirstNewsletter")),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ae,{className:"mailpoet-homepage-product-discovery",heading:m.U.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,h.jsx)(v.A,{label:m.U.I18n.t("hideList"),icon:j.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]}),children:(0,h.jsx)("ul",{children:s.map((e=>e))})}),i&&(0,h.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("allDone")," ",(0,h.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissTasks")})]})]})}var se=a(63254),ne=a(29441),re=a(16109),oe=a(38238),le=a(1595),de=a(66248);function ce({closable:e,onHide:t}){return(0,h.jsx)(ae,{className:"mailpoet-homepage-upsell",heading:m.U.I18n.t("accelerateYourGrowth"),headingAfter:e&&t?(0,h.jsx)(de.Ay,{icon:se.A,onClick:t,label:m.U.I18n.t("close")}):null,children:(0,h.jsxs)("div",{className:"mailpoet-homepage-upsell__content",children:[(0,h.jsxs)("ul",{children:[(0,h.jsxs)("li",{children:[(0,h.jsx)(Y.A,{icon:ne.A}),(0,h.jsx)("span",{children:m.U.I18n.t("detailedAnalytics")})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)(Y.A,{icon:re.A}),(0,h.jsx)("span",{children:m.U.I18n.t("advancedSubscriberSegmentation")})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)(Y.A,{icon:oe.A}),(0,h.jsx)("span",{children:m.U.I18n.t("emailMarketingAutomations")})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)(Y.A,{icon:le.A}),(0,h.jsx)("span",{children:m.U.I18n.t("prioritySupport")})]})]}),(0,h.jsx)(de.Ay,{variant:"primary",href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"business",{utm_source:"plugin",utm_medium:"homepage",utm_campaign:"upsell"}),children:m.U.I18n.t("upgradePlan")})]})})}var me=a(14687),ue=a(96188);function pe({id:e,engagementScore:t}){const a={unknown:{name:m.U.I18n.t("unknownBadgeName"),type:"unknown",tooltipTitle:m.U.I18n.t("unknownBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipUnknown")},excellent:{name:m.U.I18n.t("excellentBadgeName"),type:"excellent",tooltipTitle:m.U.I18n.t("excellentBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipExcellent")},good:{name:m.U.I18n.t("goodBadgeName"),type:"good",tooltipTitle:m.U.I18n.t("goodBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipGood")},average:{name:m.U.I18n.t("averageBadgeName"),type:"average",tooltipTitle:m.U.I18n.t("averageBadgeTooltip"),tooltipText:m.U.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,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:s.tooltipTitle.toUpperCase()}),(0,h.jsx)("div",{className:"mailpoet-listing-stats-tooltip-description",children:m.U.I18n.t("engagementScoreDescription")}),(0,h.jsxs)("div",{className:"mailpoet-listing-stats-tooltip-content",children:[(0,h.jsx)(ue.E,{type:"unknown",name:m.U.I18n.t("unknownBadgeName")})," : ",a.unknown.tooltipText,(0,h.jsx)("br",{}),(0,h.jsx)(ue.E,{type:"excellent",name:m.U.I18n.t("excellentBadgeName")})," : ",a.excellent.tooltipText,(0,h.jsx)("br",{}),(0,h.jsx)(ue.E,{type:"good",name:m.U.I18n.t("goodBadgeName")})," : ",a.good.tooltipText,(0,h.jsx)("br",{}),(0,h.jsx)(ue.E,{type:"average",name:m.U.I18n.t("averageBadgeName")})," : ",a.average.tooltipText]})]},`tooltip-${i}`);return(0,h.jsxs)("div",{className:"mailpoet-listing-stats-opened-clicked",children:[null!=t&&(0,h.jsxs)("div",{className:"mailpoet-listing-stats-percentages",children:[t.toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),"%"]}),(0,h.jsx)("div",{children:(0,h.jsx)(ue.E,{isInverted:!0,type:s.type,name:s.name,tooltip:n,tooltipId:i,tooltipPlace:"top"})})]})}const he=(e,t,a)=>{e.preventDefault(),Z("Home Page Statistics Click",t,a)};function ge(){const{globalChange:e,listsChange:t,hasForms:a}=(0,b.A)((e=>({globalChange:e(V).getGlobalSubscriberStatsChange(),listsChange:e(V).getListsSubscriberStatsChange(),hasForms:e(V).getHasForms()})),[]),i=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,h.jsx)(ae,{className:"mailpoet-subscribers-stats",heading:m.U.I18n.t("subscribersHeading"),description:m.U.I18n.t("subscribersSectionDescription"),headingAfter:!i&&(0,h.jsxs)("span",{className:Q()({"mailpoet-decrease":e.changePercent<0}),children:[(0,h.jsx)(Y.A,{icon:ne.A}),e.changePercent<0&&"-",Math.abs(e.changePercent)>1e3?"∞%":`${Math.abs(e.changePercent)}%`]}),children:i?(0,h.jsxs)("div",{className:"mailpoet-subscribers-stats-empty",children:[(0,h.jsx)(Y.A,{icon:ne.A,viewBox:"-4 -4 32 32"}),a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:m.U.I18n.t("subscriberCountHasNotChangeLongTime")}),(0,h.jsx)("a",{href:"admin.php?page=mailpoet-newsletters#/new",onClick:e=>he(e,"campaigns","admin.php?page=mailpoet-newsletters#/new"),children:m.U.I18n.t("exploreCampaigns")})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("p",{children:[m.U.I18n.t("changesWillAppear"),(0,h.jsx)("br",{}),m.U.I18n.t("starBySettingUpForm")]}),(0,h.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:e=>he(e,"new form","admin.php?page=mailpoet-form-editor-template-selection"),children:m.U.I18n.t("createForm")})]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-subscribers-stats-global-change",children:[(0,h.jsxs)("div",{children:[m.U.I18n.t("newSubscribers"),(0,h.jsx)("br",{}),(0,h.jsx)("span",{children:e.subscribed})]}),(0,h.jsxs)("div",{children:[m.U.I18n.t("unsubscribedSubscribers"),(0,h.jsx)("br",{}),(0,h.jsx)("span",{children:e.unsubscribed})]})]}),!!t.length&&(0,h.jsxs)("table",{className:"mailpoet-subscribers-stats-list-change-table",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:m.U.I18n.t("listName")}),(0,h.jsx)("th",{children:m.U.I18n.t("listScore")}),(0,h.jsx)("th",{children:m.U.I18n.t("subscribedSubscribers")}),(0,h.jsx)("th",{children:m.U.I18n.t("unsubscribedSubscribers")})]})}),(0,h.jsx)("tbody",{children:t.map((e=>(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:(0,h.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,h.jsx)("td",{children:(0,h.jsx)("div",{className:"mailpoet-listing-stats",children:(0,h.jsx)(pe,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,h.jsx)("td",{children:e.subscribed}),(0,h.jsx)("td",{children:e.unsubscribed})]},e.id)))})]})]})})}var _e=a(30221),fe=a(59820);function xe({link:e,abstract:t,title:a,imgSrc:i}){return(0,h.jsxs)("a",{className:"mailpoet-resource-post",href:e,target:"_blank",rel:"noreferrer",children:[(0,h.jsx)("img",{src:i,alt:a,width:"292",height:"166"}),(0,h.jsx)("h3",{children:a}),(0,h.jsx)("p",{children:t})]})}function be(){const[e,t]=(0,r.useState)(1),a=[(0,h.jsx)(xe,{link:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("createAnEmailAbstract"),title:m.U.I18n.t("createAnEmailTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_email.png`},"createAnEmail"),(0,h.jsx)(xe,{link:"https://kb.mailpoet.com/article/297-create-a-form-with-our-new-editor?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("createAFormAbstract"),title:m.U.I18n.t("createAFormTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_form.png`},"createAForm"),(0,h.jsx)(xe,{link:"https://www.mailpoet.com/blog/email-segmentation/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("segmentationGuideAbstract"),title:m.U.I18n.t("segmentationGuideTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/segmentation.png`},"segmentationGuide"),(0,h.jsx)(xe,{link:"https://www.mailpoet.com/blog/re-engagement-emails/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("reEngagementAbstract"),title:m.U.I18n.t("reEngagementTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/reengagement.png`},"reEngagement"),(0,h.jsx)(xe,{link:"https://www.mailpoet.com/blog/newsletter-marketing-strategy/?utm_source=plugin&utm_medium=homepage&utm_campaign=resources",abstract:m.U.I18n.t("marketingStrategyAbstract"),title:m.U.I18n.t("marketingStrategyTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/marketing.png`},"marketingStrategy"),(0,h.jsx)(xe,{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:m.U.I18n.t("promotingSalesAbstract"),title:m.U.I18n.t("promotingSalesTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/sales.png`},"promotingSales")],i=(0,r.useCallback)((a=>{a.preventDefault(),t(e+1)}),[e]),s=(0,r.useCallback)((a=>{a.preventDefault(),t(e-1)}),[e]);return(0,h.jsxs)(ae,{className:"mailpoet-homepage-resources",heading:m.U.I18n.t("learnMoreAboutEmailMarketing"),children:[(0,h.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,h.jsxs)("div",{className:"mailpoet-homepage-resources__pagination",children:[m.U.I18n.t("pageOf").replace("%1$d",e.toString()).replace("%2$d",Math.ceil(a.length/2).toString()),e>1?(0,h.jsx)("a",{href:"#",onClick:s,title:m.U.I18n.t("previousPostsPage"),children:(0,h.jsx)(Y.A,{icon:_e.A})}):(0,h.jsx)(Y.A,{icon:_e.A}),e<Math.ceil(a.length/2)?(0,h.jsx)("a",{href:"#",onClick:i,title:m.U.I18n.t("nextPostsPage"),children:(0,h.jsx)(Y.A,{icon:fe.A})}):(0,h.jsx)(Y.A,{icon:fe.A})]})]})}function ve(){const{isTaskListHidden:e,isProductDiscoveryHidden:t,isUpsellHidden:a,canDisplayUpsell:i}=(0,b.A)((e=>({isTaskListHidden:e(V).getIsTaskListHidden(),isProductDiscoveryHidden:e(V).getIsProductDiscoveryHidden(),isUpsellHidden:e(V).getIsUpsellHidden(),canDisplayUpsell:e(V).getCanDisplayUpsell()})),[]),{hideTaskList:s}=(0,me.A)(V),{hideProductDiscovery:n}=(0,me.A)(V),{hideUpsell:r}=(0,me.A)(V);return(0,h.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ee,{onHide:s})}),!t&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ie,{onHide:n})}),e&&t&&i&&!a&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ce,{closable:!0,onHide:r})}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ge,{})}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(be,{})})]})}function je(){const[e,t]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{(()=>{const e=(0,y.A)(V,{actions:i,controls:G,selectors:s,reducer:z,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:m.U.isWoocommerceActive,subscribersStats:window.mailpoet_homepage_data.subscribersStats,formsCount:window.mailpoet_homepage_data.formsCount}});(0,w.register)(e)})(),t(!0)}),[]),(0,h.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,h.jsx)(d.x,{}),(0,h.jsx)(c.D,{}),(0,h.jsx)(x,{}),e?(0,h.jsx)(ve,{}):null]})}const ye=document.getElementById("mailpoet_homepage_container");ye&&((0,o.registerTranslations)(),(0,n.H)(ye).render((0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(je,{})})));var we=a(65069),Se=a(73867),Ne=a(41669),Ie=a.n(Ne),Ue=a(59436),Ce=a(11021),ke=a(24356),Ae=a(67268),Te=a(85386),Ee=a(2726),Re=a.n(Ee);function De({cacheCalculation:e,design:t="old"}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,r.useState)([]),o=(new Date).getTime()-new Date(e).getTime(),l=Math.floor(o/1e3/60),d=()=>{i(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"settings",action:"recalculateSubscribersCountsCache"}).done((()=>{window.location.reload()})).fail((e=>{i(!1),e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e,{static:!0,scroll:!0}):n(e.errors.map((e=>e.message))))}))};return"old"===t?(0,h.jsxs)("div",{className:"mailpoet-subscribers-cache-notice",children:[Re()((0,Ae.__)("Lists and Segments subscribers counts were calculated <abbr>{$mins} minutes ago</abbr>","mailpoet"),/<abbr>(.*?)<\/abbr>/,((t,a)=>(0,h.jsx)("abbr",{title:e,children:t.replace(/(\{\$mins\}|\$mins)/i,String(l))},a))),(0,h.jsx)(Te.$,{className:"mailpoet-subscribers-cache-notice-button",type:"button",variant:"secondary",dimension:"small",onClick:d,withSpinner:a,children:(0,Ae.__)("Recalculate now","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),s.length>0&&(0,h.jsx)(p.$,{type:"error",children:s.map((e=>(0,h.jsx)("p",{children:e},e)))})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:"mailpoet-segment-subscriber-cache",children:(0,Ae.sprintf)((0,Ae._n)("Calculated %s min ago","Calculated %s mins ago",l,"mailpoet"),l.toLocaleString())}),(0,h.jsx)(de.Ay,{variant:"link",onClick:d,children:(0,Ae.__)("Recalculate","mailpoet")}),s.length>0&&(0,h.jsx)(p.$,{type:"error",children:s.map((e=>(0,h.jsx)("p",{children:e},e)))})]})}var Fe=a(62138),Oe=a(95486),Pe=a(46545);function Le({subscribersInPlan:e,subscribersInPlanLimit:t,design:a="old"}){if(!1===e)return null;const i=t?(0,h.jsx)("b",{children:(0,Ae._x)("%1$d / %2$d","count / total subscribers","mailpoet").replace("%1$d",e.toLocaleString()).replace("%2$d",t.toLocaleString())},"subscribers_count"):(0,h.jsx)("b",{children:e},"subscribers_count");return"old"===a?(0,h.jsxs)("div",{className:"mailpoet-subscribers-in-plan",children:[Re()((0,Ae._x)("%s subscribers in your plan","number of subscribers in a sending plan","mailpoet"),"%s",(()=>i))," ",(0,h.jsx)(Fe.Tooltip,{tooltip:(0,Ae.__)("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,h.jsx)("span",{className:"mailpoet-subscribers-in-plan-spacer",children:" "})]}):(0,h.jsxs)("span",{className:"mailpoet-segment-subscriber-count-message",children:[(0,h.jsx)("b",{children:t?(0,Ae.sprintf)((0,Ae._n)("%1$s / %2$s subscriber","%1$s / %2$s subscribers",e,"mailpoet"),e.toLocaleString(),t.toLocaleString()):(0,Ae.sprintf)((0,Ae._n)("%s subscriber","%s subscribers",e,"mailpoet"),e.toLocaleString())}),(0,h.jsx)(Oe.Ay,{text:(0,Ae.__)("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,h.jsx)("div",{className:"mailpoet-segment-help-icon",children:(0,h.jsx)(Y.A,{icon:Pe.A})})})]})}var Me=a(91378);function $e(){const e=(0,Se.zy)();return(0,h.jsxs)(d.x,{children:[(0,h.jsxs)(we.Link,{className:"mailpoet-button button-secondary",to:{pathname:"/new",state:{backUrl:e?.pathname}},children:[Me.W,(0,h.jsx)("span",{"data-automation-id":"add-new-subscribers-button",children:m.U.I18n.t("new")})]}),(0,h.jsx)("a",{className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:m.U.I18n.t("import")}),(0,h.jsx)("a",{id:"mailpoet_export_button",className:"mailpoet-button not-small-screen button-secondary",href:"?page=mailpoet-export",children:m.U.I18n.t("export")})]})}const Be=m.U.trackingConfig.emailTrackingEnabled,qe=[{name:"email",label:m.U.I18n.t("subscriber"),sortable:!0},{name:"status",label:m.U.I18n.t("status"),sortable:!0},{name:"segments",label:m.U.I18n.t("lists")},{name:"tags",label:m.U.I18n.t("tags")},{name:"statistics",label:m.U.I18n.t("statisticsColumn"),display:Be},{name:"last_subscribed_at",label:m.U.I18n.t("subscribedOn"),sortable:!0},{name:"created_at",label:m.U.I18n.t("createdOn"),sortable:!0}],He={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSubscriberTrashed"):m.U.I18n.t("multipleSubscribersTrashed").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSubscriberDeleted"):m.U.I18n.t("multipleSubscribersDeleted").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSubscriberRestored"):m.U.I18n.t("multipleSubscribersRestored").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onNoItemsFound:e=>"bounced"===e&&!window.mailpoet_premium_active&&!window.mailpoet_mss_active&&(0,h.jsxs)("div",{children:[(0,h.jsx)("p",{children:m.U.I18n.t("bouncedSubscribersHelp")}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",className:"button-primary",children:m.U.I18n.t("bouncedSubscribersPremiumButtonText")})})]})},We=(e,t,a,i)=>(0,h.jsxs)(Ce.a,{title:i,onRequestClose:t,isDismissible:!0,children:[(0,h.jsx)(ke.L,{field:a}),(0,h.jsx)("span",{className:"mailpoet-gap-half"}),(0,h.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",children:m.U.I18n.t("apply")})]}),ze=[{name:"moveToList",label:m.U.I18n.t("moveToList"),onSelect:function(e,t){return We(e,t,{id:"move_to_segment",name:"move_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},m.U.I18n.t("moveToList"))},getData:function(){return{segment_id:Number(Ie()("#move_to_segment").val())}},onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("multipleSubscribersMovedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"addToList",label:m.U.I18n.t("addToList"),onSelect:function(e,t){return We(e,t,{id:"add_to_segment",name:"add_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},m.U.I18n.t("addToList"))},getData:function(){return{segment_id:Number(Ie()("#add_to_segment").val())}},onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("multipleSubscribersAddedToList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromList",label:m.U.I18n.t("removeFromList"),onSelect:function(e,t){return We(e,t,{id:"remove_from_segment",name:"remove_from_segment",endpoint:"segments",filter:function(e){return"default"===e.type}},m.U.I18n.t("removeFromList"))},getData:function(){return{segment_id:Number(Ie()("#remove_from_segment").val())}},onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("multipleSubscribersRemovedFromList").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromAllLists",label:m.U.I18n.t("removeFromAllLists"),onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("multipleSubscribersRemovedFromAllLists").replace("%1$d",Number(e.meta.count).toLocaleString()))}},{name:"trash",label:m.U.I18n.t("moveToTrash"),onSuccess:He.onTrash},{name:"unsubscribe",label:m.U.I18n.t("unsubscribe"),onSelect:(e,t,a)=>{const i="all"!==a.selection?a.selected_ids.length:a.count;return(0,h.jsxs)(Ce.a,{title:m.U.I18n.t("unsubscribe"),onRequestClose:t,isDismissible:!0,children:[(0,h.jsx)("p",{children:m.U.I18n.t("unsubscribeConfirm").replace("%s",Number(i).toLocaleString())}),(0,h.jsx)("span",{className:"mailpoet-gap-half"}),(0,h.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:m.U.I18n.t("apply")})]})}},{name:"addTag",label:m.U.I18n.t("addTag"),onSelect:function(e,t){return We(e,t,{id:"add_tag",name:"add_tag",endpoint:"tags"},m.U.I18n.t("addTag"))},getData:function(){return{tag_id:Number(Ie()("#add_tag").val())}},onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("tagAddedToMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}},{name:"removeTag",label:m.U.I18n.t("removeTag"),onSelect:function(e,t){return We(e,t,{id:"remove_tag",name:"remove_tag",endpoint:"tags"},m.U.I18n.t("removeTag"))},getData:function(){return{tag_id:Number(Ie()("#remove_tag").val())}},onSuccess:function(e){m.U.Notice.success(m.U.I18n.t("tagRemovedFromMultipleSubscribers").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}}],Ve=[{name:"statistics",label:m.U.I18n.t("statsListingActionTitle"),link:function(e,t){return(0,h.jsx)(we.Link,{to:`/stats/${e.id}`,state:{backUrl:t?.pathname},children:m.U.I18n.t("statsListingActionTitle")})}},{name:"edit",label:m.U.I18n.t("edit"),link:function(e,t){return(0,h.jsx)(we.Link,{to:`/edit/${e.id}`,state:{backUrl:t?.pathname},children:m.U.I18n.t("edit")})}},{name:"sendConfirmationEmail",className:"mailpoet-hide-on-mobile",label:m.U.I18n.t("resendConfirmationEmail"),display:function(e){return"unconfirmed"===e.status},onClick:function(e){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"subscribers",action:"sendConfirmationEmail",data:{id:e.id}}).done((()=>m.U.Notice.success(m.U.I18n.t("oneConfirmationEmailSent")))).fail((e=>m.U.Notice.showApiErrorNotice(e)))}},{name:"trash",className:"mailpoet-hide-on-mobile"}],Ge=e=>0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user),Ye=e=>{let t=null;return window.mailpoet_segments.forEach((a=>{a.id===e&&(t=a)})),t};function Ke(){const e=(0,Se.zy)(),t=(0,Se.g)();return(0,h.jsxs)("div",{children:[(0,h.jsx)($e,{}),(0,h.jsx)(Le,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,h.jsx)(f.D,{}),(0,h.jsx)(De,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"subscribers",onRenderItem:(t,a)=>{const i=Q()("manage-column","column-primary","has-row-actions","column-username");let s="";switch(t.status){case"subscribed":s=m.U.I18n.t("subscribed");break;case"unconfirmed":s=m.U.I18n.t("unconfirmed");break;case"unsubscribed":s=m.U.I18n.t("unsubscribed");break;case"inactive":s=m.U.I18n.t("inactive");break;case"bounced":s=m.U.I18n.t("bounced");break;default:s="Invalid"}const n=[];return t.subscriptions.length>0&&t.subscriptions.forEach((e=>{const t=Ye(e.segment_id);null!==t&&"subscribed"===e.status&&n.push(t)})),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("td",{className:i,children:[(0,h.jsx)(we.Link,{className:"mailpoet-listing-title",to:`/edit/${t.id}`,state:{backUrl:e?.pathname},children:t.email}),(0,h.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[t.first_name," ",t.last_name]}),a]}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("status"),children:s}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("lists"),children:(0,h.jsx)(o.SegmentTags,{segments:n,dimension:"large"})}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("tags"),children:(0,h.jsx)(o.SubscriberTags,{subscribers:t.tags,variant:"wordpress",isInverted:!0})}),!0===Be?(0,h.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":m.U.I18n.t("statisticsColumn"),children:(0,h.jsx)("div",{className:"mailpoet-listing-stats",children:(0,h.jsx)("a",{href:`#/stats/${t.id}`,children:(0,h.jsx)(pe,{id:t.id,engagementScore:t.engagement_score})},`stats-link-${t.id}`)})}):null,(0,h.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("confirmedOn"),children:t.last_subscribed_at?(0,h.jsxs)(h.Fragment,{children:[m.U.Date.short(t.last_subscribed_at),(0,h.jsx)("br",{}),m.U.Date.time(t.last_subscribed_at)]}):null}),(0,h.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("subscribedOn"),children:t.created_at?(0,h.jsxs)(h.Fragment,{children:[m.U.Date.short(t.created_at),(0,h.jsx)("br",{}),m.U.Date.time(t.created_at)]}):null})]})},columns:qe,bulk_actions:ze,item_actions:Ve,messages:He,sort_by:"created_at",sort_order:"desc",isItemDeletable:Ge})]})}Ke.displayName="SubscriberList";var Je=a(36637),Qe=a.n(Je),Ze=a(97550),Xe=a(54176),et=a.n(Xe),tt=a(23108),at=a.n(tt),it=a(63599);class st extends r.Component{render(){const{onValueChange:e=(()=>{}),onBlurEvent:t=(()=>{})}=this.props,a=this.props.field.name||null,i=this.props.item||{};let s,n;e instanceof Function&&(s=i[this.props.field.name],s=void 0===s?this.props.field.defaultValue||"":s),!s&&this.props.field.defaultValue&&(n=this.props.field.defaultValue);let r=this.props.field.id||null;!r&&this.props.field.name&&(r=`field_${this.props.field.name}`);let o,l=this.props.field.className||null;return l||this.props.field.size||(l="regular-text"),o="function"==typeof this.props.field.disabled?this.props.field.disabled(this.props.item):"boolean"==typeof this.props.field.disabled&&this.props.field.disabled,(0,h.jsx)(it.p,{type:"text",disabled:o,className:l,size:"auto"!==this.props.field.size&&this.props.field.size>0?this.props.field.size:null,name:a,id:r,value:s,defaultValue:n,placeholder:this.props.field.placeholder,onChange:e,onBlur:t,customLabel:this.props.field.customLabel,tooltip:this.props.field.tooltip,...this.props.field.validation})}}st.propTypes={onValueChange:at().func,onBlurEvent:at().func,field:at().shape({name:at().string.isRequired,defaultValue:at().string,id:at().string,className:at().string,size:at().oneOfType([at().string,at().number]),disabled:at().oneOfType([at().bool,at().func]),placeholder:at().string,validation:at().shape({"data-parsley-required":at().bool,"data-parsley-required-message":at().string,"data-parsley-type":at().string,"data-parsley-errors-container":at().string,maxLength:at().number}),customLabel:at().string,tooltip:at().string}).isRequired,item:at().object.isRequired};var nt=a(33609);function rt(e){return(0,h.jsx)(nt.T,{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})}rt.propTypes={item:at().object.isRequired,field:at().shape({name:at().string,placeholder:at().string,defaultValue:at().string,validation:at().shape({"data-parsley-required":at().bool,"data-parsley-required-message":at().string,"data-parsley-type":at().string,"data-parsley-errors-container":at().string,maxLength:at().number}),className:at().string,customLabel:at().string,tooltip:at().string}).isRequired,onValueChange:at().func.isRequired};var ot=a(5668),lt=a(36113);class dt extends r.Component{render(){if(void 0===this.props.field.values)return!1;const{automationId:e="",onValueChange:t=(()=>{})}=this.props;let a,i=!1,s=!1,n=!1;void 0!==this.props.field.placeholder&&(s=(0,h.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(i=this.props.field.filter),ot.default.isFunction(this.props.field.sortBy)&&(n=this.props.field.sortBy),a=n?ot.default.map(ot.default.sortBy(ot.default.pairs(this.props.field.values),(e=>n(e[0],e[1]))),(e=>e[0])):Object.keys(this.props.field.values);const r=a.filter((e=>!1===i||i(this.props.item,e))).map((e=>(0,h.jsx)("option",{value:e,children:this.props.field.values[e]},`option-${e}`)));return(0,h.jsxs)(lt.Select,{name:this.props.field.name,id:`field_${this.props.field.name}`,value:this.props.item[this.props.field.name]||"",onChange:t,automationId:e,...this.props.field.validation,children:[s,r]})}}dt.propTypes={onValueChange:at().func,field:at().shape({name:at().string.isRequired,values:at().objectOf(at().string),placeholder:at().string,filter:at().func,sortBy:at().func,validation:at().shape({"data-parsley-required":at().bool,"data-parsley-required-message":at().string,"data-parsley-type":at().string,"data-parsley-errors-container":at().string,maxLength:at().number})}).isRequired,item:at().object.isRequired,automationId:at().string};var ct=a(51015);class mt extends r.Component{constructor(e){super(e),this.onValueChange=this.onValueChange.bind(this)}onValueChange=(e,t)=>{const{onValueChange:a=(()=>{})}=this.props;a(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,h.jsx)("p",{children:(0,h.jsx)(ct.s,{checked:e===t,value:t,onCheck:this.onValueChange,name:this.props.field.name,children:this.props.field.values[t]})},`radio-${t}`)));return(0,h.jsx)("div",{children:t})}}mt.propTypes={onValueChange:at().func,field:at().shape({name:at().string.isRequired,values:at().objectOf(at().string)}).isRequired,item:at().object.isRequired};var ut=a(6519);class pt extends r.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,h.jsx)("p",{children:(0,h.jsx)(ut.S,{value:"1",checked:e,name:this.props.field.name,onCheck:this.onValueChange,children:this.props.field.values[t]})},`checkbox-${t}`)));return(0,h.jsx)("div",{children:t})}}function ht(e){const t=[];void 0!==e.placeholder&&t.push((0,h.jsx)("option",{value:"",children:e.placeholder},0));const a=Qe()().year();for(let e=a;e>=a-100;e-=1)t.push((0,h.jsx)("option",{value:e,children:e},e));return(0,h.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[year]`,value:e.year,onChange:e.onValueChange,children:t})}function gt(e){const t=[];void 0!==e.placeholder&&t.push((0,h.jsx)("option",{value:"",children:e.placeholder},0));for(let a=1;a<=12;a+=1)t.push((0,h.jsx)("option",{value:a,children:e.monthNames[a-1]},a));return(0,h.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[month]`,value:e.month,onChange:e.onValueChange,children:t})}function _t(e){const t=[];void 0!==e.placeholder&&t.push((0,h.jsx)("option",{value:"",children:e.placeholder},0));for(let e=1;e<=31;e+=1)t.push((0,h.jsx)("option",{value:e,children:e},e));return(0,h.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[day]`,value:e.day,onChange:e.onValueChange,children:t})}pt.propTypes={onValueChange:at().func.isRequired,field:at().shape({name:at().string.isRequired,values:at().objectOf(at().string)}).isRequired,item:at().object.isRequired},ht.propTypes={name:at().string.isRequired,placeholder:at().string.isRequired,onValueChange:at().func.isRequired,year:at().oneOfType([at().string,at().number]).isRequired},gt.propTypes={name:at().string.isRequired,placeholder:at().string.isRequired,onValueChange:at().func.isRequired,month:at().oneOfType([at().string,at().number]).isRequired,monthNames:at().arrayOf(at().string).isRequired},_t.propTypes={name:at().string.isRequired,placeholder:at().string.isRequired,onValueChange:at().func.isRequired,day:at().oneOfType([at().string,at().number]).isRequired};class ft extends r.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=Qe()(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,h.jsx)(ht,{onValueChange:this.onValueChange,name:this.props.field.name,year:this.state.year,placeholder:this.props.field.year_placeholder},"year");case"MM":return(0,h.jsx)(gt,{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,h.jsx)(_t,{onValueChange:this.onValueChange,name:this.props.field.name,day:this.state.day,placeholder:this.props.field.day_placeholder},"day");default:return(0,h.jsx)("div",{children:"Invalid date type"})}}));return(0,h.jsx)("div",{children:a})}}ft.propTypes={item:at().object.isRequired,field:at().shape({name:at().string,day_placeholder:at().string,month_placeholder:at().string,year_placeholder:at().string,params:at().object}).isRequired,onValueChange:at().func.isRequired};var xt=a(49790),bt=a(50459);function vt(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,h.jsx)(bt.g,{label:e.field.label,name:e.field.name,placeholder:e.field.placeholder,selectedValues:t,suggestedValues:a,onChange:e.onValueChange})}class jt extends r.Component{renderField=e=>{let t,a=!1;e.field.description&&(a=(0,h.jsx)("p",{className:"description",children:e.field.description}));let i=e.field;switch(void 0!==e.field.field&&(i=Ie().merge(i,e.field.field)),i.type){case"text":t=(0,h.jsx)(st,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"textarea":t=(0,h.jsx)(rt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"select":t=(0,h.jsx)(dt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"radio":t=(0,h.jsx)(mt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"checkbox":t=(0,h.jsx)(pt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"selection":t=(0,h.jsx)(ke.L,{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,h.jsx)(ft,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"reactComponent":t=(0,h.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,h.jsx)(vt,{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,h.jsxs)("div",{className:Q()("mailpoet-form-field",{"mailpoet-form-field-disabled":s}),...n,children:[t,a]},`field-${e.index||0}`)};render(){let e=!1;const{onValueChange:t=(()=>{})}=this.props;e=void 0!==this.props.field.fields?this.props.field.fields.map(((e,a)=>this.renderField({index:a,field:e,item:this.props.item,onValueChange:t||!1}))):this.renderField(this.props);let a=!1;this.props.field.label&&(a=(0,h.jsx)(xt.D,{level:4,children:(0,h.jsx)("label",{htmlFor:`field_${this.props.field.name}`,children:this.props.field.label})}));let i=!1;return this.props.field.tip&&(i=(0,h.jsx)("p",{className:"mailpoet-form-description",children:this.props.field.tip})),(0,h.jsxs)("div",{className:`mailpoet-form-field-${this.props.field.name} form-field-row-${this.props.field.name}`,children:[a,i,e]})}}jt.propTypes={onValueChange:at().func,field:at().shape({name:at().string.isRequired,values:at().objectOf(at().string),tip:at().oneOfType([at().array,at().string]),label:at().string,fields:at().arrayOf(at().object),description:at().string,onWrapperClick:at().func,disabled:at().oneOfType([at().func,at().bool])}).isRequired,item:at().object.isRequired},(0,o.registerTranslations)();class yt extends r.Component{constructor(e){super(e),this.formRef=(0,r.createRef)(),this.state={loading:!1,errors:[],item:{}}}componentDidMount(){const{fields:e,params:t={}}=this.props;void 0!==t.id?this.loadItem(t.id):et()((()=>{const t=Ie()(".mailpoet_form").mailpoetSerializeObject(),a=Array.isArray(e)&&e.length>0&&e.find((e=>"checkbox"===e?.type&&e?.isChecked));a&&a.name&&(t[a.name]="1"),this.setState({item:t})}))}componentDidUpdate(e){const{item:t,location:a={},params:i={}}=this.props;void 0===i.id&&e.location?.pathname!==a.pathname&&(et()((()=>{this.setState({loading:!1,item:{}})})),void 0===t&&this.formRef.current.reset())}getValues=()=>this.props.item||this.state.item;getErrors=()=>this.props.errors||this.state.errors;loadItem=e=>{const{navigate:t,endpoint:a,onItemLoad:i}=this.props;this.setState({loading:!0}),a&&m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:a,action:"get",data:{id:e}}).done((e=>{this.setState({loading:!1,item:e.data}),"function"==typeof i&&i(e.data)})).fail((()=>{this.setState({loading:!1,item:{}},(()=>{t("/lists")}))}))};handleSubmit=e=>{e.preventDefault();const{navigate:t,endpoint:a,fields:i=[],isValid:s,messages:n={onUpdate:()=>{},onCreate:()=>{}},onSuccess:r,params:o={}}=this.props;if("function"==typeof s&&!1===s())return;this.setState({loading:!0});const l={};i.forEach((e=>{void 0!==e.fields?e.fields.forEach((e=>{l[e.name]=this.state.item[e.name]})):l[e.name]=this.state.item[e.name]})),void 0!==o.id&&(l.id=o.id),a&&m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:a,action:"save",data:l}).always((()=>{this.setState({loading:!1})})).done((()=>{"function"==typeof r?r():t("/"),void 0!==o.id?n.onUpdate():n.onCreate()})).fail((e=>{e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):this.setState({errors:e.errors}))}))};handleValueChange=e=>{const{onChange:t}=this.props,{name:a,value:i}=Object.prototype.hasOwnProperty.call(e,"target")?e.target:e;return"function"==typeof t?t(e):(this.setState((e=>{const t=e.item;return t[a]=i,{item:t}})),!0)};render(){const{children:e,afterFormContent:t,beforeFormContent:a,onSubmit:i,fields:s=[],id:n=""}=this.props;let r;void 0!==this.getErrors()&&(r=this.getErrors().map((e=>(0,h.jsx)("div",{className:"mailpoet_notice notice inline error is-dismissible",children:(0,h.jsx)("p",{children:e.message})},`error-${e.message}`))));const l=Q()("mailpoet_form",{mailpoet_form_loading:this.state.loading||this.props.loading});let d=!1,c=!1;"function"==typeof a&&(d=a(this.getValues())),"function"==typeof t&&(c=t(this.getValues()));const m=s.map((e=>{let t=this.handleValueChange;return e.onBeforeChange&&(t=t=>(e.onBeforeChange(t),this.handleValueChange(t))),(0,h.jsx)(jt,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)}));let u=!1;return u=e||(0,h.jsx)(o.Button,{type:"submit",isDisabled:this.state.loading,children:(0,Ae.__)("Save","mailpoet")}),(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:"mailpoet-form-content-around",children:d}),(0,h.jsxs)("form",{id:n,ref:this.formRef,className:l,onSubmit:"function"==typeof i?i:this.handleSubmit,"data-automation-id":this.props.automationId,children:[r,(0,h.jsxs)("div",{className:"mailpoet-form-grid",children:[m,(0,h.jsx)("div",{className:"mailpoet-form-actions",children:u})]})]}),(0,h.jsx)("div",{className:"mailpoet-form-content-around",children:c})]})}}function wt(e){const t=(0,Se.Zp)();return(0,h.jsx)(yt,{...e,navigate:t})}yt.propTypes={params:at().shape({id:at().string}),location:at().shape({pathname:at().string}),item:at().object,errors:at().arrayOf(at().object),endpoint:at().string,fields:at().arrayOf(at().object),messages:at().shape({onUpdate:at().func,onCreate:at().func}),loading:at().bool,children:at().array,id:at().string,automationId:at().string,beforeFormContent:at().func,afterFormContent:at().func,onItemLoad:at().func,isValid:at().func,onChange:at().func,onSubmit:at().func,onSuccess:at().func,navigate:at().func.isRequired};var St=a(45172),Nt=a(4077),It=a(83586);const Ut=[{name:"email",label:m.U.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:m.U.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:m.U.I18n.t("lastname"),type:"text",disabled:function(e){return Number(e.wp_user_id>0)||1===Number(e.is_woocommerce_user)}},{name:"status",label:m.U.I18n.t("status"),type:"select",automationId:"subscriber-status",values:{subscribed:m.U.I18n.t("subscribed"),unconfirmed:m.U.I18n.t("unconfirmed"),unsubscribed:m.U.I18n.t("unsubscribed"),inactive:m.U.I18n.t("inactive"),bounced:m.U.I18n.t("bounced")}},{name:"segments",label:m.U.I18n.t("lists"),type:"selection",placeholder:m.U.I18n.t("selectList"),tip:m.U.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=m.U.Date.format(t.updated_at);a+=" (%1$s)".replace("%1$s",m.U.I18n.t("unsubscribedOn").replace("%1$s",e))}})),a}},{name:"tags",label:m.U.I18n.t("tags"),type:"tokenField",placeholder:m.U.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=m.U.I18n.t("year"),t.month_placeholder=m.U.I18n.t("month"),t.day_placeholder=m.U.I18n.t("day");break;case"select":t.placeholder="-";break;default:t.placeholder=""}Ut.push(t)}));const Ct={onUpdate:function(){m.U.Notice.success(m.U.I18n.t("subscriberUpdated"))},onCreate:function(){m.U.Notice.success(m.U.I18n.t("subscriberAdded")),m.U.trackEvent("Subscribers > Add new")}};function kt(e){if(Number(e.wp_user_id)>0)return(0,h.jsx)("p",{className:"description",children:Re()(m.U.I18n.t("WPUserEditNotice"),/\[link\](.*?)\[\/link\]/g,((t,a)=>(0,h.jsx)("a",{href:`user-edit.php?user_id=${e.wp_user_id}`,children:t},a)))})}function At(e){return(0,h.jsxs)(h.Fragment,{children:[e?.unsubscribes?.map((e=>{const t=Qe()(e.createdAt.date).format("dddd MMMM Do YYYY [at] h:mm:ss a");let a;return a="admin"===e.source?m.U.I18n.t("unsubscribedAdmin").replace("%1$d",t).replace("%2$d",e.meta):"manage"===e.source?m.U.I18n.t("unsubscribedManage").replace("%1$d",t):"newsletter"===e.source?Re()(m.U.I18n.t("unsubscribedNewsletter").replace("%1$d",t),/\[link\]/g,((t,a)=>(0,h.jsx)("a",{href:`admin.php?page=mailpoet-newsletter-editor&id=${e.newsletterId}`,children:e.newsletterSubject},a))):"mp_api"===e.source?m.U.I18n.t("unsubscribedMpApi").replace("%1$d",t):m.U.I18n.t("unsubscribedUnknown").replace("%1$d",t),(0,h.jsx)("p",{className:"description",children:a},a)})),(0,h.jsxs)("p",{className:"description",children:[(0,h.jsx)("strong",{children:m.U.I18n.t("tip")})," ",m.U.I18n.t("customFieldsTip")]})]})}function Tt(){const e=(0,Se.zy)(),t=(0,Se.g)(),a=(0,Se.Zp)(),i=e.state?.backUrl||"/";return(0,h.jsxs)("div",{className:"mailpoet-main-container",children:[(0,h.jsx)(d.x,{}),(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(St.x,{}),(0,h.jsx)(It.z,{heading:m.U.I18n.t("subscriber"),headingPrefix:(0,h.jsx)(It.o,{onClick:()=>a(i),label:m.U.I18n.t("backToList")})}),(0,h.jsx)(Nt.X,{}),(0,h.jsx)(wt,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:Ut,params:t,messages:Ct,beforeFormContent:kt,afterFormContent:At,onSuccess:()=>a(i)})]})}Tt.displayName="SubscriberForm";var Et=a(79711);function Rt({email:e}){const t=(0,Se.zy)(),a=t.state?.backUrl||"/";return(0,h.jsxs)(xt.D,{level:1,className:"mailpoet-title",children:[(0,h.jsx)("span",{children:m.U.I18n.t("statsHeading").replace("%s",e)}),(0,h.jsx)(we.Link,{className:"mailpoet-button button button-secondary button-small",to:a,children:m.U.I18n.t("backToList")})]})}var Dt=a(89788);function Ft({stats:e,subscriber:t}){return(0,h.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,h.jsx)("div",{className:"mailpoet-listing",children:(0,h.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,h.jsxs)("tbody",{children:[(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:m.U.I18n.t("statsSentEmail")}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.total_sent},e.timeframe)))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:(0,h.jsx)(Dt.v,{children:m.U.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,h.jsx)("td",{children:a},e.timeframe)}))]}),m.U.trackingConfig.opensSeparated&&(0,h.jsxs)("tr",{children:[(0,h.jsxs)("td",{children:[(0,h.jsx)(Dt.v,{children:m.U.I18n.t("statsMachineOpened")}),(0,h.jsx)(Fe.Tooltip,{tooltip:Re()(m.U.I18n.t("statsMachineOpenedTooltip"),/\[link](.*?)\[\/link]/,(e=>(0,h.jsx)("span",{style:{pointerEvents:"all"},children:(0,h.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,h.jsx)("td",{children:a},e.timeframe)}))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:(0,h.jsx)(Dt.v,{isInverted:!0,children:m.U.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,h.jsx)("td",{children:a},e.timeframe)}))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:m.U.I18n.t("statsNotClicked")}),e.periodic_stats.map((e=>{const t=m.U.trackingConfig.opensSeparated?e.open+e.machine_open:e.open,a=e.total_sent-t,i=e.total_sent>0;let s=a.toLocaleString();return i&&(s+=` (${Math.round(a/e.total_sent*100)}%)`),(0,h.jsx)("td",{children:s},e.timeframe)}))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:m.U.I18n.t("statisticsColumn")}),(0,h.jsx)("td",{colSpan:e.periodic_stats.length,children:(0,h.jsx)("div",{className:"mailpoet-listing-stats",children:(0,h.jsx)(pe,{id:t.id,engagementScore:t.engagement_score})})})]})]})]})})})}function Ot({stats:e}){return(0,h.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,h.jsx)("div",{className:"mailpoet-listing",children:(0,h.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.timeframe},e.timeframe)))]})}),(0,h.jsxs)("tbody",{children:[(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:"Orders created"}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.woocommerce.count.toLocaleString()},e.timeframe)))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:"Total revenue"}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.woocommerce.formatted},e.timeframe)))]}),(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:"Average revenue"}),e.periodic_stats.map((e=>(0,h.jsx)("td",{children:e.woocommerce.formatted_average},e.timeframe)))]})]})]})})})}var Pt=a(51047),Lt=a(43405),Mt=a(17867);const{subscribersLimitReached:$t,subscribersLimit:Bt,subscribersCount:qt,premiumActive:Ht,hasValidApiKey:Wt,hasValidPremiumKey:zt,isPremiumPluginInstalled:Vt,pluginPartialKey:Gt}=m.U,Yt=Wt||zt,Kt=e=>(0,h.jsx)("p",{children:Re()(e,/(\[subscribersCount]|\[subscribersLimit])/g,(e=>"[subscribersCount]"===e?qt:Bt))}),Jt=(e,t,a="_blank")=>(0,h.jsx)(Te.$,{href:t,target:a,rel:"noopener noreferrer",children:e}),Qt=e=>(0,h.jsx)(Mt.Wr,{buttonText:e});function Zt({message:e,actionButton:t,capabilities:a={}}){let i,s,n=(0,Ae.__)("This is a Premium feature","mailpoet");if(!zt||Vt&&Ht)if($t){i=Kt((0,Ae.__)("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=Yt?m.U.MailPoetComUrlFactory.getUpgradeUrl(Gt):m.U.MailPoetComUrlFactory.getPurchasePlanUrl(+qt+1,null,null,null);s=Jt((0,Ae.__)("Upgrade your plan","mailpoet"),e)}else if(Wt&&!zt||zt&&Object.keys(a).some((e=>m.U.capabilities[e].isRestricted))){n=(0,Ae.__)("Upgrade your plan","mailpoet"),i=e;const t=m.U.MailPoetComUrlFactory.getUpgradeUrl(Gt,{s:qt,capabilities:a});s=Jt((0,Ae.__)("Upgrade","mailpoet"),t)}else i=e,s=t;else i=Kt((0,Ae.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),s=Qt(Vt?(0,Ae.__)("Activate MailPoet Premium plugin","mailpoet"):(0,Ae.__)("Download MailPoet Premium plugin","mailpoet"));return(0,h.jsx)(Lt.P,{title:n,message:i,actionButton:s})}function Xt(){return(0,h.jsx)("div",{className:"mailpoet-listing",children:(0,h.jsxs)("table",{className:"mailpoet-listing-table","data-automation-id":"subscriber-stats-no-access",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:(0,Ae.__)("E-mail","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Action","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Count","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Action on","mailpoet")})]})}),(0,h.jsx)("tbody",{children:(0,h.jsx)("tr",{children:(0,h.jsx)("td",{colSpan:4,children:(0,h.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,h.jsx)(Zt,{message:(()=>{const e=(0,Ae.__)("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,h.jsx)("p",{children:Re()(e,/\[link](.*?)\[\/link]/g,(e=>(0,h.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e)))})})(),actionButton:(0,h.jsx)(Te.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,null,{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Upgrade","mailpoet")}),capabilities:{detailedAnalytics:!0}})})})})})]})})}function ea({params:e,location:t}){const a=(0,r.useMemo)((()=>Pt.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",(()=>(0,h.jsx)(Xt,{})),e,t)),[t,e]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:4,children:(0,Ae.__)("Opened emails","mailpoet")}),(0,h.jsx)(a,{})]})}function ta(e){return"string"==typeof e?m.U.Date.format(e):(0,Ae.__)("never","mailpoet")}function aa({stats:e}){const t=[{label:(0,Ae.__)("Last click","mailpoet"),date:e.last_click||null},{label:(0,Ae.__)("Last engagement","mailpoet"),date:e.last_engagement||null},{label:(0,Ae.__)("Last open","mailpoet"),date:e.last_open||null},{label:(0,Ae.__)("Last page view","mailpoet"),date:e.last_page_view||null},{label:(0,Ae.__)("Last sending","mailpoet"),date:e.last_sending||null}];return e.is_woo_active&&t.push({label:(0,Ae.__)("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,h.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,h.jsx)("div",{className:"mailpoet-listing",children:(0,h.jsx)("table",{className:"mailpoet-listing-table",children:(0,h.jsx)("tbody",{children:t.map((({label:e,date:t})=>(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{children:e}),(0,h.jsx)("td",{children:(0,h.jsx)("b",{children:ta(t)})})]},e)))})})})})}function ia(){const e=(0,Se.g)(),t=(0,Se.zy)(),[a,i]=(0,r.useState)(null),[s,n]=(0,r.useState)(!0);return(0,r.useEffect)((()=>{m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"subscriberStats",action:"get",data:{subscriber_id:e.id}}).done((e=>{i(e.data),n(!1)})).fail((e=>{n(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}),[e.id]),s?(0,h.jsx)(Et.R,{}):a?(0,h.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,h.jsx)(Rt,{email:a.email}),(0,h.jsxs)("div",{className:"mailpoet-subscriber-stats-summary-grid",children:[(0,h.jsx)(Ft,{stats:a,subscriber:{id:Number(e.id),engagement_score:a.engagement_score}}),(0,h.jsx)(aa,{stats:a}),a.is_woo_active&&(0,h.jsx)(Ot,{stats:a})]}),(0,h.jsx)(ea,{params:e,location:t})]}):null}function sa(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:"/new",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Tt,{})})}),(0,h.jsx)(Se.qh,{path:"/edit/:id",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Tt,{})})}),(0,h.jsx)(Se.qh,{path:"/stats/:id/*",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ia,{})})}),(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Ke,{})})})]})]})})}ia.displayName="SubscriberStats";const na=document.getElementById("subscribers_container");na&&((0,o.registerTranslations)(),(0,n.H)(na).render((0,h.jsx)(sa,{})));var ra=a(32785),oa=a(48194),la=a(92449),da=a(77780),ca=a(74476),ma=a(98968);function ua({isModalOpen:e,onClose:t}){const[a,i]=(0,r.useState)(!1),{notices:s}=(0,r.useContext)(l.F),n=(0,r.useCallback)((()=>{i(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,Ae.__)("Subject","mailpoet"),new_editor:!0}}).done((e=>{window.location.href=m.U.getBlockEmailEditorUrl(e.data.wp_post_id)})).fail((e=>{i(!1),t(),e.errors.length>0&&s.apiError(e,{scroll:!0})}))}),[s,t]);return e?(0,h.jsxs)(ma.A,{title:(0,Ae.__)("Try the new email editor","mailpoet"),onRequestClose:t,className:"mailpoet-new-editor-modal",children:[(0,h.jsxs)("div",{className:"mailpoet-new-editor-modal-image",children:[(0,h.jsx)("span",{className:"mailpoet-new-editor-modal-image__beta_label",children:(0,Ae.__)("Alpha version","mailpoet")}),(0,h.jsx)("img",{src:`${m.U.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,Ae.__)("Try the new email editor","mailpoet"),width:"324",height:"130"})]}),(0,h.jsx)("p",{children:(0,Ae.__)("Get a sneak peek of an early version of the upcoming email design experience and help shape its development.","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Create modern, beautiful emails that embody your brand with advanced customization and editing capabilities.","mailpoet")}),(0,h.jsx)("p",{className:"mailpoet-new-editor-modal-note",children:(0,Ae.__)("Emails created in the new editor cannot be reverted to the legacy version.","mailpoet")}),(0,h.jsxs)("div",{className:"mailpoet-new-editor-modal-footer",children:[(0,h.jsx)(de.Ay,{type:"button",variant:"tertiary",onClick:()=>{t()},children:(0,Ae.__)("Cancel","mailpoet")}),(0,h.jsx)(de.Ay,{type:"button",variant:"primary",isBusy:a,onClick:n,children:(0,Ae.__)("Continue","mailpoet")})]})]}):null}function pa({errors:e}){return e.length<1?null:(0,h.jsx)(p.$,{type:"error",closable:!1,children:e.map((e=>(0,h.jsx)("p",{children:e.message},e.message)))})}var ha=a(74314);const ga=Oe.Ay;function _a({children:e}){return(0,h.jsx)(ga,{delay:0,text:(0,h.jsx)("div",{className:"mailpoet-newsletter-type-info-tooltip",children:e}),children:(0,h.jsx)("div",{className:"mailpoet-newsletter-type-info",children:(0,h.jsx)(da.A,{icon:ha.A,size:20})})})}const fa=ra.A;function xa({filter:e=null,hideScreenOptions:t=!0}){const a=(0,Se.Zp)(),[i,s]=(0,r.useState)(!1),[n,o]=(0,r.useState)(!1),l=m.U.FeaturesController.isSupported("gutenberg_email_editor"),d=e=>{void 0!==e&&(a(`/new/${e}`),m.U.trackEvent("Emails > Type selected",{"Email type":e}))},c=ot.default.partial((e=>{s(!0),m.U.trackEvent("Emails > Type selected",{"Email type":e}),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"create",data:{type:e,subject:(0,Ae.__)("Subject","mailpoet")}}).done((e=>{a(`/template/${e.data.id}`)})).fail((e=>(s(!1),e.errors.length>0?(0,h.jsx)(pa,{errors:e.errors}):null)))}),"standard"),u=ot.default.partial(d,"notification"),p=ot.default.partial(d,"re-engagement"),g=l?(0,h.jsxs)(oa.A,{className:"mailpoet-dropdown-button-group",children:[(0,h.jsx)(de.Ay,{variant:"secondary",onClick:c,isBusy:i,"data-automation-id":"create_standard",children:(0,Ae.__)("Create","mailpoet")}),(0,h.jsx)(la.A,{focusOnMount:!1,className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,h.jsx)(de.Ay,{variant:"secondary",className:"mailpoet-button-with-wordpress-icon",onClick:t,"aria-expanded":e,"data-automation-id":"create_standard_email_dropdown",children:(0,h.jsx)(da.A,{icon:ca.A,size:24})}),renderContent:()=>(0,h.jsx)(fa,{variant:"tertiary",onClick:()=>o(!0),children:(0,Ae.__)("Create using the new email editor (Alpha)","mailpoet")})})]}):(0,h.jsx)(de.Ay,{variant:"secondary",onClick:c,isBusy:i,"data-automation-id":"create_standard",children:(0,Ae.__)("Create","mailpoet")}),_=[{slug:"standard",title:(0,Ae.__)("Newsletter","mailpoet"),description:(0,Ae.__)("Send a newsletter with images, buttons, dividers, and social bookmarks. Or, just send a basic text email.","mailpoet"),action:g},{slug:"automations",title:(0,h.jsxs)(h.Fragment,{children:[(0,Ae.__)("Automations","mailpoet")," ",(0,h.jsx)(_a,{children:(0,Ae.__)("Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.","mailpoet")})]}),description:(0,Ae.__)("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,h.jsx)(de.Ay,{variant:"secondary",onClick:()=>{s(!0),window.location.href="admin.php?page=mailpoet-automation-templates"},isBusy:i,"data-automation-id":"create_automation",children:(0,Ae.__)("Create","mailpoet")})},{slug:"notification",title:(0,Ae.__)("Latest Post Notifications","mailpoet"),description:(0,Ae.__)("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,h.jsx)(de.Ay,{variant:"secondary",onClick:u,isBusy:i,"data-automation-id":"create_notification",children:(0,Ae.__)("Create","mailpoet")})},{slug:"re_engagement",title:(0,Ae.__)("Re-engagement Emails","mailpoet"),description:(0,Ae.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,h.jsx)(de.Ay,{variant:"secondary",onClick:p,isBusy:i,"data-automation-id":"create_notification",children:(0,Ae.__)("Create","mailpoet")})}];let f=Pt.Hooks.applyFilters("mailpoet_newsletters_types",[..._],this);e&&(f=f.filter(e));const x=m.U.Ajax.constructGetUrl({api_version:m.U.apiVersion,endpoint:"newsletterTemplates",action:"getAll"});return(0,h.jsxs)(h.Fragment,{children:[t&&(0,h.jsx)(St.x,{}),(0,h.jsx)("link",{rel:"prefetch",href:window.mailpoet_editor_javascript_url,as:"script"}),(0,h.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,h.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,h.jsx)("div",{className:"mailpoet-newsletter-type-image"}),(0,h.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,h.jsxs)(xt.D,{level:4,children:[e.title," ",e.beta?`(${(0,Ae.__)("Beta","mailpoet")})`:""]}),(0,h.jsx)("p",{children:e.description}),e.videoGuide&&(0,h.jsxs)("a",{className:t,href:e.videoGuide,target:"_blank",rel:"noopener noreferrer",children:[(0,h.jsx)("span",{className:"dashicons dashicons-format-video"}),(0,Ae.__)("See video guide","mailpoet")]}),e.kbLink&&(0,h.jsx)("a",{href:e.kbLink,target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Read more.","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-flex-grow"}),(0,h.jsx)("div",{className:"mailpoet-newsletter-type-action",children:e.action})]})]},e.slug)})(e)),this)}),(0,h.jsx)("link",{rel:"prefetch",href:x,as:"fetch"}),(0,h.jsx)(ua,{onClose:()=>o(!1),isModalOpen:n})]})}var ba=a(48661),va=a(63725);function ja(e){const t=(0,Se.zy)();return(0,h.jsx)(va.Y,{...e,location:t})}var ya=a(87526),wa=a(40914);class Sa extends r.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,wa.Z)({message:(0,Ae.__)('You are about to delete the template named "%1$s".',"mailpoet").replace("%1$s",t),onConfirm:()=>{a(),m.U.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.apiError(e,{scroll:!0}),i(!1)}))}})}onPreview(){m.U.Modal.popup({title:this.props.name,template:'<img class="mailpoet-template-preview-image" src="{{ thumbnail }}" />',data:this.props})}onSelect(){const{newsletterId:e,name:t,beforeSelect:a,afterSelect:i}=this.props;a(),m.U.trackEvent("Emails > Template selected",{"Email name":t}),m.U.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.apiError(e,{scroll:!0}),i(!1)}))}render(){const{index:e,name:t,readonly:a,thumbnail:i=null}=this.props;let s="";return"string"==typeof i&&i.length>0&&(s=(0,h.jsxs)("a",{className:"mailpoet-template-preview",href:"#",onClick:e=>{e.preventDefault(),this.onPreview(e)},children:[(0,h.jsx)("div",{className:"mailpoet-template-thumbnail",children:i?(0,h.jsx)("img",{src:i,alt:(0,Ae.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,h.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,h.jsx)(Te.$,{children:(0,Ae.__)("Preview","mailpoet")})})]})),(0,h.jsx)(ya.c,{label:t,onSelect:this.onSelect,onDelete:!1===a?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}Sa.contextType=l.F,Sa.propTypes={index:at().number.isRequired,id:at().number.isRequired,newsletterId:at().string.isRequired,name:at().string.isRequired,thumbnail:at().string,readonly:at().bool.isRequired,beforeDelete:at().func.isRequired,afterDelete:at().func.isRequired,beforeSelect:at().func.isRequired,afterSelect:at().func.isRequired},Sa.displayName="TemplateBox";class Na extends r.Component{constructor(e){super(e),this.fileRef=(0,r.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),ot.default.size(this.fileRef.current.files)<=0)return!1;const t=ot.default.first(this.fileRef.current.files),a=new FileReader;return a.onload=e=>{try{this.saveTemplate(JSON.parse(e.target.result)),m.U.trackEvent("Emails > Template imported")}catch(e){this.context.notices.error((0,h.jsx)("p",{children:(0,Ae.__)("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;ot.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(),m.U.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.apiError(e,{scroll:!0}),i(!1)}))}render(){return(0,h.jsxs)("div",{className:"mailpoet-template-import",children:[(0,h.jsxs)("h4",{children:[(0,Ae.__)("Import a template","mailpoet"),(0,h.jsx)(Fe.Tooltip,{tooltip:(0,Ae.__)("You can only upload .json templates that were originally created with MailPoet.","mailpoet"),place:"right",className:"tooltip-help-import-template"})]}),(0,h.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,h.jsx)("input",{type:"file",placeholder:(0,Ae.__)("Select a .json file to upload","mailpoet"),ref:this.fileRef}),(0,h.jsx)("p",{className:"submit",children:(0,h.jsx)("input",{className:"button button-primary",type:"submit",value:(0,Ae.__)("Upload","mailpoet")})})]})]})}}Na.contextType=l.F,Na.propTypes={beforeImport:at().func.isRequired,afterImport:at().func.isRequired};var Ia=a(67787);const Ua=[];window.mailpoet_newsletters_templates_recently_sent_count&&Ua.push({name:"recent",label:(0,Ae.__)("Recently sent","mailpoet")}),Ua.push({name:"standard",label:(0,Ae.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,Ae.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,Ae.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,Ae.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,Ae.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&Ua.push({name:"woocommerce",label:(0,Ae.__)("WooCommerce Emails","mailpoet")}),Ua.push({name:"saved",label:(0,Ae.__)("Your saved templates","mailpoet")});class Ca extends r.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(){m.U.Ajax.get({api_version:window.mailpoet_api_version,endpoint:"newsletterTemplates",action:"getAll"}).done((e=>{0===e.data.length&&(e.data=[{name:(0,Ae.__)("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.apiError(e,{scroll:!0})})).always((()=>{this.selectInitialTab()}))}addTemplate(e){const t=Ua.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";m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:this.props.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":ot.default.findWhere(Ua,{name:i.data.type})?a=i.data.type:"automatic"===i.data.type&&ot.default.findWhere(Ua,{name:i.data.options.group})&&(a=i.data.options.group)})).fail((e=>{e.errors.length>0&&this.context.notices.apiError(e,{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,h.jsx)(Et.R,{});const e=Ua.concat({name:"import",label:(0,Ae._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,h.jsx)(Na,{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,h.jsx)("p",{children:(0,Ae.__)("This category does not contain any template yet!","mailpoet")}):e.map(((e,t)=>(0,h.jsx)(Sa,{index:t,newsletterId:this.props.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(Ia.Ls.includes(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,h.jsx)("input",{type:"button",className:"button link-button",onClick:a,value:"Cancel"})}return(0,h.jsxs)("div",{children:[(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(ja,{emailType:this.state.emailType,automationId:"email_template_selection_heading",buttons:i,onLogoClick:a}),(0,h.jsxs)("div",{className:"mailpoet-templates",children:[(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(ba.L,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,h.jsx)(o.ErrorBoundary,{children:t})]})]})}}Ca.contextType=l.F,Ca.propTypes={params:at().shape({id:at().string}).isRequired};var ka=a(25043),Aa=a.n(ka),Ta=a(29065),Ea=a.n(Ta),Ra=a(42581),Da=a(80940),Fa=a(19232),Oa=a(68490);function Pa(e){return(t,a)=>{let i;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;i=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;i=e.values[s]||e.values[t]}return i[e.argumentCallback?e.argumentCallback(t):t]}}const La={abbreviated:[(0,Ae.__)("Jan","mailpoet"),(0,Ae.__)("Feb","mailpoet"),(0,Ae.__)("Mar","mailpoet"),(0,Ae.__)("Apr","mailpoet"),(0,Ae.__)("May","mailpoet"),(0,Ae.__)("Jun","mailpoet"),(0,Ae.__)("Jul","mailpoet"),(0,Ae.__)("Aug","mailpoet"),(0,Ae.__)("Sep","mailpoet"),(0,Ae.__)("Oct","mailpoet"),(0,Ae.__)("Nov","mailpoet"),(0,Ae.__)("Dec","mailpoet")],wide:[(0,Ae.__)("January","mailpoet"),(0,Ae.__)("February","mailpoet"),(0,Ae.__)("March","mailpoet"),(0,Ae.__)("April","mailpoet"),(0,Ae.__)("May","mailpoet"),(0,Ae.__)("June","mailpoet"),(0,Ae.__)("July","mailpoet"),(0,Ae.__)("August","mailpoet"),(0,Ae.__)("September","mailpoet"),(0,Ae.__)("October","mailpoet"),(0,Ae.__)("November","mailpoet"),(0,Ae.__)("December","mailpoet")]},Ma={narrow:[(0,Ae._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,Ae._x)("M","Monday - one letter abbreviation","mailpoet"),(0,Ae._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,Ae._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,Ae._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,Ae._x)("F","Friday - one letter abbreviation","mailpoet"),(0,Ae._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,Ae.__)("Sun","mailpoet"),(0,Ae.__)("Mon","mailpoet"),(0,Ae.__)("Tue","mailpoet"),(0,Ae.__)("Wed","mailpoet"),(0,Ae.__)("Thu","mailpoet"),(0,Ae.__)("Fri","mailpoet"),(0,Ae.__)("Sat","mailpoet")],wide:[(0,Ae.__)("Sunday","mailpoet"),(0,Ae.__)("Monday","mailpoet"),(0,Ae.__)("Tuesday","mailpoet"),(0,Ae.__)("Wednesday","mailpoet"),(0,Ae.__)("Thursday","mailpoet"),(0,Ae.__)("Friday","mailpoet"),(0,Ae.__)("Saturday","mailpoet")]};Fa.A.localize.month=Pa({values:La,defaultWidth:"wide"}),Fa.A.localize.day=Pa({values:Ma,defaultWidth:"wide"}),Fa.A.options.weekStartsOn=void 0!==m.U.wpWeekStartsOn?m.U.wpWeekStartsOn:1,(0,Da.registerLocale)("mailpoet",Fa.A);class $a extends r.Component{onChange=(e,t)=>{const a=t,i=this.getAsStringInFormat(e);a.target.name=this.getFieldName(),a.target.value=i,this.props.onChange(a)};getFieldName=()=>this.props.name||"date";getDisplayDateFormat=e=>m.U.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=>Qe()(e).toDate();getAsStringInFormat=e=>Qe()(e).format(m.U.Date.convertFormat(this.props.storageFormat));render(){return(0,h.jsx)(Oa.t,{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 Ba extends r.Component{render(){const{onChange:e,timeOfDayItems:t,value:a,disabled:i=!1,name:s="time",validation:n={}}=this.props,r=Object.keys(t).map((e=>(0,h.jsx)("option",{value:e,children:t[e]},`option-${t[e]}`)));return(0,h.jsx)(lt.Select,{name:s||"time",value:a,disabled:i,onChange:e,isMinWidth:!0,...n,children:r})}}Ba.propTypes={timeOfDayItems:at().objectOf(at().string).isRequired,name:at().string,value:at().string.isRequired,disabled:at().bool,onChange:at().func.isRequired,validation:at().object},Ba.displayName="TimeSelect";class qa extends r.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||et()((()=>{this.setState(this.buildStateFromProps(this.props))}))}getDateTime=()=>{const e=[this.state.date,this.state.time].join(this.DATE_TIME_SEPARATOR);return m.U.Date.toGmtDatetimeString(e)};buildStateFromProps=e=>{const t=e.value||this.props.defaultDateTime,a=m.U.Date.datetimeString(t),[i,s]=a.split(this.DATE_TIME_SEPARATOR);return{date:i,time:s}};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,h.jsx)(Ra.Grid.Column,{className:"mailpoet-datetime-container",children:(0,h.jsxs)(o.ErrorBoundary,{children:[(0,h.jsx)($a,{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,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(Ba,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var Ha=a(49429),Wa=a(85980),za=a(30253);class Va extends r.Component{constructor(e){super(e);const t=(0,za.Y8)(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{onValueChange:t=(()=>{})}=this.props,a=e.target.value.toLowerCase();this.setState({emailAddress:a}),t({...e,target:{...e.target,name:e.target.name,value:a}}),this.setState({showAuthEmailsError:!1,showSenderDomainWarning:!1}),(0,Wa.SB)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,Wa.oI)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,Wa.SB)(this.domElementSelector,this.parsleyFieldName),(0,Wa.vg)(this.domElementSelector)?e?this.showSenderDomainError(!0):this.showInvalidFromAddressError(t):(0,Wa.jr)(this.domElementSelector))};showSenderDomainError=e=>{e&&this.setState({showSenderDomainWarning:!0})};validateEmailAddress(){if(!window.mailpoet_mss_active)return;const e=this.state.emailAddress,t=(0,za.Y8)(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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(st,{item:{...this.props.item,sender_address:this.state.emailAddress},field:this.props.field,onValueChange:this.onChange,onBlurEvent:this.onBlur}),(0,h.jsx)("div",{className:"regular-text regular-text-full-width",children:(0,h.jsx)(Ha.Y,{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}),m.U.trackEvent("MSS in plugin authorize email",{"authorized email source":"newsletter",wasSuccessful:"yes"})),"domain"===e.type&&(this.setState({showSenderDomainWarning:!1}),this.setState({isPartiallyVerifiedDomain:!1}),m.U.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"newsletter",wasSuccessful:"yes"})),(0,Wa.SB)(this.domElementSelector,this.parsleyFieldName)}})})]})}}Va.propTypes={field:at().object.isRequired,item:at().shape({sender_address:at().string.isRequired}).isRequired,onValueChange:at().func},Va.displayName="SenderField";const Ga=ot.default.once((()=>m.U.trackEvent("User has typed a GA campaign name"))),Ya=Re()((0,Ae.__)("For example, “Spring email”. [link]Read the guide.[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,h.jsxs)("span",{children:[(0,h.jsx)("br",{}),(0,h.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))),Ka={name:"ga_campaign",label:(0,Ae.__)("Google Analytics Campaign","mailpoet"),tip:Ya,type:"text",onBeforeChange:Ga};var Ja=a(4137),Qa=a(17052),Za=a(20363),Xa=a(4152);const ei={saveDraftNewsletter:()=>Promise.resolve()},ti=r.createContext(ei);var ai=a(83471);function ii(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const si=[{name:"segments",label:(0,Ae.__)("Send to","mailpoet"),type:"selection",placeholder:(0,Ae.__)("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,Ae.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,Ae.__)("Please select a list with subscribers.","mailpoet")}},{name:"filter-segment-toggle",type:"reactComponent",component:(0,o.withBoundary)((function({item:e,onValueChange:t,field:a}){const i=e?.options.filterSegmentId,[s,n]=(0,r.useState)(Za.d&&!!i),l=(0,r.useCallback)((a=>{t({target:{name:"options",value:{...e?.options??{},filterSegmentId:a}}})}),[e,t]),d=(0,r.useContext)(ti);(0,r.useEffect)((()=>{Za.d||""===i||l("")}),[l,i]);const c=(0,r.useCallback)((i=>{t({target:{name:a.name,value:i}}),i||l(""),n(i),m.U.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,Ae.__)("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,Ae.__)("Please select a filter segment","mailpoet")}};u=(0,h.jsx)(ke.L,{item:e,field:t,onValueChange:t=>{l(t.target.value),m.U.trackEvent("Emails > Filter by segment selected",{"Email type":e.type})}})}const p=`admin.php?page=mailpoet-segments#/new-segment?newsletterId=${e.id}`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Toggle,{checked:s,disabled:a.disabled,name:"isFilterSegmentEnabled",onCheck:c,automationId:"filter-segment-toggle"}),(0,h.jsxs)("span",{className:"mailpoet-form-toggle-text",children:[(0,Ae.__)("Filter by segment","mailpoet"),(0,h.jsx)(da.A,{"data-tip":!0,"data-tooltip-id":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:Pe.A})]}),(0,h.jsx)(Xa.m,{place:"right",id:"filter-segment-tooltip",children:(0,h.jsx)("div",{children:(0,Ae.__)("Subscribers selected in 'Send to' will only receive an email if they also belong to this segment.","mailpoet")})}),(0,h.jsx)("div",{className:"mailpoet-gap"}),u,s&&(0,h.jsx)("p",{children:Re()((0,Ae.__)("Can't find the segment you're looking for? [link]Create new[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,((t,a)=>(0,h.jsx)("a",{className:"mailpoet-link",rel:"noopener noreferrer",onClick:async t=>{t.preventDefault(),m.U.trackEvent("Emails > Create new segment clicked",{"Email type":e.type}),await d.saveDraftNewsletter(),window.location.href=p},href:p,children:t},a)))})]})}))}],ni={name:"recipient-count",type:"reactComponent",component:(0,o.withBoundary)((function(e){const[t,a]=(0,r.useState)(!0),[i,s]=(0,r.useState)(0),n=(0,r.useMemo)((()=>(e.item.segments||[]).map((e=>e.id))),[e.item.segments]),o=(0,r.useMemo)((()=>e.item.options?.filterSegmentId||null),[e.item.options?.filterSegmentId]),l=(0,r.useRef)(""),d=(0,r.useRef)({});return(0,r.useEffect)((()=>{const e=ii(n,o);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 m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"subscriberCount",data:{segmentIds:n,filterSegmentId:o}}).done((t=>{const a=t.data.count;d.current[e]=a;const i=ii(n,o);l.current===i&&s(a)})).always((()=>a(!1))))}),[n,o]),(0,h.jsxs)("div",{children:[(0,Ae.__)("Estimated recipients","mailpoet"),":",t&&(0,h.jsx)(ai.Ay,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Xa.m,{place:"right",id:"estimated-count-tooltip",children:(0,Ae.__)("This count may change at the time of sending.","mailpoet")}),(0,h.jsx)("span",{"data-tip":!0,"data-tooltip-id":"estimated-count-tooltip",className:"estimated-recipient-count",children:i.toLocaleString()})]})]})}))},ri={name:"send-to",label:(0,Ae.__)("Send to","mailpoet"),tip:(0,Ae.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:si},oi={name:"send-to",label:(0,Ae.__)("Send to","mailpoet"),tip:(0,Ae.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...si,ni]},li=`${window.mailpoet_tomorrow_date} 08:00:00`,di=window.mailpoet_schedule_time_of_day,ci=window.mailpoet_date_format,mi=window.mailpoet_date_storage_format;class ui extends r.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:li,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,Ae.__)("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,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("span",{className:"mailpoet-form-schedule-time",children:[(0,Ae.__)("Your website’s time is","mailpoet")," ",m.U.Date.time(new Date)]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{id:"mailpoet_scheduling",children:(0,h.jsx)(qa,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:li,timeOfDayItems:di,dateDisplayFormat:ci,dateStorageFormat:mi,maxDate:t})})]})),(0,h.jsxs)("div",{children:[(0,h.jsx)(Ja.l,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}let pi=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Ae.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Ae.__)("Type newsletter subject","mailpoet"),tooltip:(0,Ae.__)("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,Ae.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Ae.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Ae.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Ae.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Ae.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},oi,{name:"options",label:(0,Ae.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(ui)},{name:"sender",label:(0,Ae.__)("Sender","mailpoet"),tip:(0,Ae.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Ae.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Va),placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ka,{name:"reply-to",label:(0,Ae.__)("Reply-to","mailpoet"),tip:(0,Ae.__)("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,Ae.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];pi=Pt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",pi);const hi={getFields:()=>pi,getSendButtonOptions:(e={})=>{const t={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&m.U.Date.isInFuture(e.options?.scheduledAt,new Date)?(0,Ae.__)("Schedule","mailpoet"):(0,Ae.__)("Send","mailpoet")};return e.status!==Qa.um.Sent&&e.status!==Qa.um.Sending||(t.disabled="disabled"),t}},gi=window.mailpoet_time_format||"H:i",_i={immediate:(0,Ae.__)("immediately","mailpoet"),minutes:(0,Ae.__)("minute(s) later","mailpoet"),hours:(0,Ae.__)("hour(s) later","mailpoet"),days:(0,Ae.__)("day(s) later","mailpoet"),weeks:(0,Ae.__)("week(s) later","mailpoet")},fi={daily:(0,Ae.__)("Once a day at...","mailpoet"),weekly:(0,Ae.__)("Weekly on...","mailpoet"),monthly:(0,Ae.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,Ae.__)("Monthly every...","mailpoet"),immediately:(0,Ae.__)("Immediately","mailpoet")},xi=ot.default.object(ot.default.map(ot.default.times(96,(e=>900*e)),(e=>{const t=new Date(null);return t.setSeconds(e),[e,m.U.Date.format(t,{format:gi,offset:0})]}))),bi={0:(0,Ae.__)("Sunday","mailpoet"),1:(0,Ae.__)("Monday","mailpoet"),2:(0,Ae.__)("Tuesday","mailpoet"),3:(0,Ae.__)("Wednesday","mailpoet"),4:(0,Ae.__)("Thursday","mailpoet"),5:(0,Ae.__)("Friday","mailpoet"),6:(0,Ae.__)("Saturday","mailpoet")},vi=ot.default.object(ot.default.map(ot.default.times(28,(e=>e)),(e=>{const t={0:(0,Ae.__)("1st","mailpoet"),1:(0,Ae.__)("2nd","mailpoet"),2:(0,Ae.__)("3rd","mailpoet")};let a;return a=void 0!==t[e]?t[e]:(0,Ae.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,a]}))),ji={1:(0,Ae.__)("1st","mailpoet"),2:(0,Ae.__)("2nd","mailpoet"),3:(0,Ae.__)("3rd","mailpoet"),L:(0,Ae._x)("last","e.g. monthly every last Monday","mailpoet")},yi={name:"intervalType",values:fi},wi={name:"timeOfDay",values:xi},Si={name:"weekDay",values:bi},Ni={name:"monthDay",values:vi},Ii={name:"nthWeekDay",values:ji};class Ui extends r.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:ot.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,h.jsx)(dt,{field:wi,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"!==e.intervalType&&"nthWeekDay"!==e.intervalType||(a=(0,h.jsx)(dt,{field:Si,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(i=(0,h.jsx)(dt,{field:Ni,item:this.getCurrentValue(),onValueChange:this.handleMonthDayChange})),"nthWeekDay"===e.intervalType&&(s=(0,h.jsx)(dt,{field:Ii,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,h.jsxs)("div",{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsx)(dt,{field:yi,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,h.jsx)("div",{children:(0,h.jsx)("p",{children:(0,Ae.__)("after publishing a post","mailpoet")})})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[s,i,a,t]}),"immediately"!==e.intervalType&&(0,h.jsx)("div",{className:"mailpoet-gap"})]})}}Ui.propTypes={item:at().object.isRequired,field:at().shape({name:at().string}).isRequired,onValueChange:at().func.isRequired};let Ci=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Ae.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Ae.__)("Type newsletter subject","mailpoet"),tooltip:(0,Ae.__)("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,Ae.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Ae.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Ae.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Ae.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Ae.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Ae.__)("Select a frequency","mailpoet"),type:"reactComponent",component:Ui},oi,{name:"sender",label:(0,Ae.__)("Sender","mailpoet"),tip:(0,Ae.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Ae.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Va),placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ka,{name:"reply-to",label:(0,Ae.__)("Reply-to","mailpoet"),tip:(0,Ae.__)("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,Ae.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Ci=Pt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Ci);const ki={getFields:function(){return Ci},getSendButtonOptions:function(){return{value:(0,Ae.__)("Activate","mailpoet")}}},Ai=window.mailpoet_roles||{},Ti=ot.default.filter(window.mailpoet_segments||[],(e=>"default"===e.type)),Ei={name:"event",values:{segment:(0,Ae.__)("When someone subscribes to the list...","mailpoet"),user:(0,Ae.__)("When a new WordPress user is added to your site...","mailpoet")}},Ri={name:"segment",placeholder:(0,Ae.__)("Select a list","mailpoet"),forceSelect2:!0,values:Ti,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},Di={name:"role",values:Ai},Fi={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Ae.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},Oi={name:"afterTimeType",values:_i};class Pi extends r.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:ot.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,h.jsx)(dt,{field:Di,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,h.jsx)(ke.L,{field:Ri,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(a=(0,h.jsx)(st,{field:Fi,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,h.jsxs)("div",{children:[(0,h.jsx)(dt,{field:Ei,item:this.getCurrentValue(),onValueChange:this.handleEventChange}),(0,h.jsx)("div",{className:"mailpoet-gap"}),t,(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[a,(0,h.jsx)(dt,{field:Oi,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,h.jsx)("div",{className:"mailpoet-form-errors"}),(0,h.jsx)("div",{className:"mailpoet-gap"})]})}}Pi.propTypes={item:at().object.isRequired,field:at().shape({name:at().string}).isRequired,onValueChange:at().func.isRequired},Pi.displayName="WelcomeScheduling";let Li=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Ae.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Ae.__)("Type newsletter subject","mailpoet"),tooltip:(0,Ae.__)("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,Ae.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Ae.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Ae.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Ae.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Ae.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Ae.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(Pi)},Ka,{name:"sender",label:(0,Ae.__)("Sender","mailpoet"),tip:(0,Ae.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Ae.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Va),placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Ae.__)("Reply-to","mailpoet"),tip:(0,Ae.__)("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,Ae.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Li=Pt.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Li);const Mi={getFields:function(){return Li},getSendButtonOptions:function(){return{value:(0,Ae.__)("Activate","mailpoet")}}},$i=3;class Bi extends r.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=_i;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:ot.default.map(t,((e,t)=>({name:e,id:t}))),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>a},onValueChange:ot.default.partial(this.handleChange,ot.default,"afterTimeType")};return(0,h.jsx)(ke.L,{field:i.field,onValueChange:i.onValueChange})}displayAfterTimeNumberField(){const{event:e,afterTimeNumberSize:t=$i}=this.props,{afterTimeType:a,afterTimeNumber:i}=this.state;if("immediate"===a)return null;if(e.timeDelayValues&&e.timeDelayValues[a]&&!e.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:t,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,Ae.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:ot.default.partial(this.handleChange,ot.default,"afterTimeNumber")};return(0,h.jsx)(st,{field:s.field,item:s.item,onValueChange:s.onValueChange})}propagateChange(e){const{onValueChange:t=null}=this.props;t&&t(e)}render(){const{event:e}=this.props;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("h4",{children:[" ",(0,Ae.__)("When to send this email?","mailpoet")," "]}),(0,h.jsxs)(Ra.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[this.displayAfterTimeNumberField(),this.displayAfterTimeTypeOptions(),e.afterDelayText&&(0,h.jsx)("p",{children:e.afterDelayText})]}),(0,h.jsx)("div",{className:"mailpoet-form-errors"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),e.schedulingReadMoreLink&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("a",{href:e.schedulingReadMoreLink.link,target:"_blank",rel:"noopener noreferrer",className:"event-scheduling-read-more-link",children:e.schedulingReadMoreLink.text}),(0,h.jsx)("div",{className:"mailpoet-gap"})]})]})}}function qi(e){const t=e&&e.values?e.values:[];return t?t.map((e=>({id:e.id,name:e.name}))):t}function Hi({eventOptions:e,eventSlug:t,selected:a,onValueChange:i}){function s(e){i&&i({eventOptionValue:e.target.value})}return(0,h.jsx)("div",{children:(0,h.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:qi(e),multiple:e.multiple||!1,placeholder:e.placeholder||!1,transformChangedValue:(e,t)=>ot.default.map(t,(e=>({id:e.id,name:e.text}))),selected:()=>a,getLabel:ot.default.property("name"),getValue:ot.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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ke.L,{field:i.field,onValueChange:i.onValueChange,item:i.item}),(0,h.jsx)("div",{className:"mailpoet-gap"})]})}()})})}Bi.propTypes={item:at().shape({afterTimeType:at().string.isRequired,afterTimeNumber:at().number}).isRequired,afterTimeNumberSize:at().number,onValueChange:at().func,event:at().shape({defaultAfterTimeType:at().string,afterDelayText:at().string,timeDelayValues:at().objectOf(at().shape({text:at().string,displayAfterTimeNumberField:at().bool})),schedulingReadMoreLink:at().shape({link:at().string.isRequired,text:at().string.isRequired})}).isRequired},Bi.displayName="EventScheduling",Hi.displayName="EventOptions";const Wi=(0,o.withBoundary)(Hi);class zi extends r.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=ot.default.indexBy(this.email.events,"slug"),this.segments=ot.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,h.jsx)(Bi,{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,h.jsx)("div",{className:"event-segment-selection",children:(0,h.jsx)(ke.L,{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=ot.default.map(a.option,(e=>e.id))),(0,h.jsx)(Wi,{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=null}=this.props;if(!n)return;const r={group:this.email.slug,event:e,afterTimeType:t};a&&(r.afterTimeNumber=a),i&&(r.segment=i),s&&(r.meta=JSON.stringify({option:this.state.eventOptionValue})),n({target:{name:"options",value:r}})}render(){return(0,h.jsxs)("div",{children:[(0,h.jsx)(xt.D,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}zi.propTypes={field:at().shape({email:at().shape({events:at().object.isRequired}).isRequired,emailOptions:at().object.isRequired}).isRequired,onValueChange:at().func},zi.displayName="SendEventConditions";const Vi=window.mailpoet_woocommerce_automatic_emails||[],Gi={getFields:function(e){return(e=>{const t=Vi[e.options.group];if(!t)return!1;const a=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Ae.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Ae.__)("Type newsletter subject","mailpoet"),tooltip:(0,Ae.__)("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,Ae.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Ae.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Ae.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Ae.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Ae.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,Ae.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,o.withBoundary)(zi),email:t,emailOptions:a},Ka,{name:"sender",label:(0,Ae.__)("Sender","mailpoet"),tip:(0,Ae.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Ae.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,Ae.__)("Reply-to","mailpoet"),tip:(0,Ae.__)("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,Ae.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,Ae.__)("Activate","mailpoet")}}};var Yi=a(32228);function Ki({afterTimeNumber:e,afterTimeType:t,updateAfterTimeNumber:a,updateAfterTimeType:i,inactiveSubscribersPeriod:s}){const n="weeks"===t?7:30,r=Number(e)*n;let o=s;return 365===s&&(o=360),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:4,children:(0,Ae.__)("When to send this re-engagement email?","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("After no activity for","mailpoet")}),(0,h.jsxs)(Ra.Grid.TwoColumns,{children:[(0,h.jsx)("div",{children:(0,h.jsx)(it.p,{type:"number",placeholder:(0,Ae.__)("count","mailpoet"),value:e,min:1,onChange:(0,za.k9)(a),required:!0})}),(0,h.jsx)("div",{children:(0,h.jsxs)(lt.Select,{value:t,onChange:(0,za.k9)(i),children:[(0,h.jsx)("option",{value:"weeks",children:(0,Ae.__)("weeks","mailpoet")}),(0,h.jsx)("option",{value:"months",children:(0,Ae.__)("months","mailpoet")})]})})]}),(!s||o>r)&&(0,h.jsx)("div",{className:"mailpoet-gap"}),!!s&&o<=r&&(0,h.jsx)("p",{className:"mailpoet-re-engagement-scheduling-note",children:Re()((0,Ae.__)("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,h.jsx)("a",{href:"https://kb.mailpoet.com/article/264-inactive-subscribers",target:"_blank",rel:"noopener noreferrer",children:e},"link")))})]})}const Ji=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,Ae.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,Ae.__)("Type newsletter subject","mailpoet"),tooltip:(0,Ae.__)("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,Ae.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,Ae.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,Ae.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,Ae.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,Ae.__)("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,h.jsx)(Ki,{afterTimeNumber:e.item.options.afterTimeNumber.toString(),afterTimeType:e.item.options.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:t=>{e.onValueChange({target:{name:"options",value:(0,Yi.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,Yi.assoc)("afterTimeType",t,e.item.options)}})}})}},ri,{name:"sender",label:(0,Ae.__)("Sender","mailpoet"),tip:(0,Ae.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,Ae.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:Va,placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,Ae.__)("Reply-to","mailpoet"),tip:(0,Ae.__)("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,Ae.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,Ae.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},Ka],Qi={getFields:()=>Ji,getSendButtonOptions:()=>({value:(0,Ae.__)("Activate","mailpoet")})};var Zi=a(74099);let Xi=null;var es=a(68345);function ts({toggleLoadingState:e,updatePendingState:t}){const a=(0,r.useCallback)((async()=>{try{const{success:e,res:a}=await(0,o.callApi)({endpoint:"services",action:"refreshMSSKeyStatus"});!0===e?t(!(0,o.isTruthy)(a.data.result.data.is_approved)):m.U.Notice.showApiErrorNotice(a)}catch(e){m.U.Notice.showApiErrorNotice(e)}}),[t]),[i,s]=(0,r.useState)(!0);return(0,h.jsxs)("div",{className:"mailpoet_error",children:[(0,h.jsx)(es.wk,{}),i&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("br",{}),(0,h.jsx)("br",{}),(0,h.jsx)(es.Tr,{onRefreshClick:async t=>{t.preventDefault(),e(!0),await a(),s(!1),e(!1)}})]})]})}ts.displayName="PendingNewsletterMessage";const as=(0,o.withBoundary)(ts),is=window.mailpoet_woocommerce_automatic_emails||{},ss=(e,t)=>`${Ea()(t,{strict:!0,lower:!0})||"email"}-${e}`,ns=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function rs(e){let t,a;if(!m.U.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,Ae.__)("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,Ae.__)('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,Ae.__)("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,Ae._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,Ae.__)("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||m.U.trackingConfig.emailTrackingEnabled?void 0:(0,h.jsx)("span",{style:{pointerEvents:"all"},children:Re()((0,Ae.__)("Re-engagement emails are disabled because [link]open and click tracking[/link] is disabled.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e=>(0,h.jsx)("a",{href:"?page=mailpoet-settings#/advanced",rel:"noopener noreferrer",children:e},"advancedSettingsTabLink")))})}class os extends r.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.params.id).always((()=>{this.setState({loading:!1})})),Ie()("#mailpoet_newsletter").parsley({successClass:""})}componentDidUpdate(e){this.props.params.id!==e.params.id&&this.loadItem(this.props.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===Qa.Gn.Automatic&&is[e.options.group])return Gi;switch(e.type){case"notification":return ki;case"welcome":return Mi;case"re_engagement":return Qi;default:return hi}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,Zi.uz)(e);isValid=()=>Ie()("#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,za.Y8)(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}),m.U.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===Qa.Gn.Automation){const e=a.options?.automationId,t=e?`admin.php?page=mailpoet-automation-editor&id=${e}`:"/new";return this.setState({item:{}},(()=>{this.props.navigate(t)}))}!a.ga_campaign&&Za.d&&(a.ga_campaign=ss(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:rs(e.data)}),!0})).fail((()=>{this.setState({item:{}},(()=>{this.props.navigate("/new")}))})));saveTemplate=(e,t)=>{this.getThumbnailPromise(e.meta.preview_url).then((a=>{m.U.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}),m.U.Modal.loading(!1)}))})).catch((e=>{this.showError({errors:[e]})}))};loadAuthorizedEmailAddresses=async()=>{if("MailPoet"!==window.mailpoet_mta_method)return[];const e=(await m.U.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 m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[];handleSend=e=>(e.preventDefault(),this.isValid()?(m.U.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}),m.U.Modal.loading(!1)})):(window.mailpoet_sender_address_field_blur(),m.U.Modal.loading(!1))}))):Ie()("#mailpoet_newsletter").parsley().validate());sendNewsletter=e=>m.U.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 m.U.Modal.loading(!1),void this.props.navigate(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");let a=[];e.data.segments.map((e=>a.push(...e.filters))),a=Aa().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;m.U.trackEvent("Emails > Newsletter sent",{scheduled:s,"Segment Applied":!!this.state.item.options.filterSegmentId,segments:i}),s?this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("The newsletter is being sent...","mailpoet")}),{id:"mailpoet_notice_being_sent"}),m.U.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)}));activateNewsletter=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:this.props.params.id,status:"active"}}).done((t=>{this.saveTemplate(e,(()=>{if(window.mailpoet_show_congratulate_after_first_newsletter)return m.U.Modal.loading(!1),void this.props.navigate(`/send/congratulate/${this.state.item.id}`);this.redirectToListing("activated");const e=this.state.item.options;"automatic"===this.state.item.type&&is[e.group]?m.U.trackEvent("Emails > Automatic email activated",{Type:Ea()(`${e.group}-${e.event}`),Delay:ns(e)}):"welcome"===t.data.type?m.U.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:ns(e)}):"re_engagement"===t.data.type?(this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("Your Re-engagement Email is now activated!","mailpoet")})),m.U.trackEvent("Emails > Re-engagement email activated",{Inactivity:ns(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("Your post notification is now active!","mailpoet")})),m.U.trackEvent("Emails > Post notifications activated",{Frequency:e.intervalType,"Segment Applied":!!this.state.item.options.filterSegmentId})),m.U.Modal.loading(!1)}))})).fail((e=>{this.showError(e),this.setState({loading:!1}),m.U.Modal.loading(!1)}));handleResume=e=>(e.preventDefault(),this.isValid()?this.saveNewsletter().done((()=>{this.setState({loading:!0})})).done((()=>{m.U.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,h.jsx)("p",{children:(0,Ae.__)("The newsletter sending has been resumed.","mailpoet")}))})).fail((e=>{this.showError(e)}))})).fail((e=>{this.showError(e)})).always((()=>{this.setState({loading:!1})})):Ie()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done((()=>{this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("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.navigate(`/${this.state.item.type}`)};handleRedirectToDesign=e=>{e.preventDefault();const t=e.target.href;this.saveNewsletter().done((()=>{this.context.notices.success((0,h.jsx)("p",{children:(0,Ae.__)("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=Aa().omit(e,["body","created_at","deleted_at","hash","status","updated_at","type"]);return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:t})};showError=e=>{e.errors.length>0&&this.context.notices.apiError(e,{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===ss(i.id,s)&&(i.ga_campaign=ss(i.id,a)),"reply_to_address"===t&&(i[t]=a.toLowerCase()),{item:i}})),!0};handleSaveDraft=()=>{Ie()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>Za.d||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,Ae.__)("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||Za.d?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,Ae.__)("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:r}=this.state,l="sending"===t&&a&&"paused"===a.status,d=this.getSendButtonOptions(),c=this.getPreparedFields(l),u=!(!window.mailpoet_subscribers_limit_reached&&!r&&void 0===this.state.validationError);let p=i;return p===Qa.Gn.Automatic&&(p=s.group||p),(0,h.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(ja,{emailType:p,automationId:"newsletter_send_heading"}),(0,h.jsxs)(o.ErrorBoundary,{children:[this.state.item.campaign_name?(0,h.jsx)("div",{className:"mailpoet-form-grid mailpoet-send-campaign-name",children:(0,h.jsx)("h1",{children:this.state.item.campaign_name})}):null,(0,h.jsx)(ti.Provider,{value:this.state.sendContextValue,children:(0,h.jsxs)(wt,{id:"mailpoet_newsletter",fields:c,automationId:"newsletter_send_form",item:this.state.item,loading:this.state.loading,onChange:this.handleFormChange,onSubmit:this.handleSave,children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{className:"send-newsletter-buttons",children:[(0,h.jsx)(o.Button,{variant:"secondary",type:"submit",automationId:"email-save-draft",onClick:this.handleSaveDraft,isDisabled:this.state.loading,children:(0,Ae.__)("Save as draft and close","mailpoet")}),l?(0,h.jsx)(o.Button,{type:"button",onClick:this.handleResume,isDisabled:u||this.state.loading,automationId:"email-resume",children:(0,Ae.__)("Resume","mailpoet")}):(0,h.jsx)(o.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:u||this.state.loading,automationId:"email-submit",children:d.value||(0,Ae.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,h.jsx)(Fe.Tooltip,{tooltip:(0,h.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,h.jsxs)("p",{children:[(0,Ae.__)("or simply","mailpoet")," ",(0,h.jsx)("a",{className:"mailpoet-link",href:m.U.FeaturesController.isSupported("gutenberg_email_editor")&&n?m.U.getBlockEmailEditorUrl(Number(n)):`?page=mailpoet-newsletter-editor&id=${Number(this.props.params.id)}`,onClick:this.handleRedirectToDesign,children:(0,Ae.__)("go back to the Design page","mailpoet")}),"."]}),r&&(0,h.jsx)(as,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,h.jsx)(Za.D,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})]})]})}}function ls(e){const[t,a]=(0,r.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:0,children:(0,Ae.__)("Congratulations!","mailpoet")}),(0,h.jsx)(xt.D,{level:3,children:(i=e.newsletter,"welcome"===i.type?(0,Ae.__)("Your Welcome Email is now active.","mailpoet"):"notification"===i.type?(0,Ae.__)("Your Post Notification is now active.","mailpoet"):"automatic"===i.type?(0,Ae.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===i.status?(0,Ae.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,Ae.__)("Your newsletter is being sent!","mailpoet"))}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)("img",{src:e.illustrationImageUrl,alt:"",width:"500"}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)(o.Button,{type:"button",dimension:"small",onClick:()=>{e.successClicked(),a(!0)},withSpinner:t,children:(0,Ae.__)("Close","mailpoet")})]});var i}function ds(e){return(0,h.jsxs)("div",{className:"mailpoet-wizard-step",children:[(0,h.jsx)("div",{className:"mailpoet-wizard-step-illustration",children:(0,h.jsx)("img",{src:e.illustrationUrl,width:"500",alt:""})}),(0,h.jsx)("div",{className:"mailpoet-wizard-step-content",children:e.children})]})}function cs(){return(0,h.jsxs)(o.List,{children:[(0,h.jsx)("li",{children:(0,Ae.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,h.jsx)("li",{children:(0,Ae.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,h.jsx)("li",{children:(0,Ae.__)("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,h.jsx)("li",{children:(0,Ae.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function ms(e){const[t,a]=(0,r.useState)(!1),i=()=>{e.onFinish(),a(!0)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Heading,{level:1,children:(s=e.newsletter.type,{standard:(0,Ae.__)("Your email has been sent!","mailpoet"),welcome:(0,Ae.__)("You are all set up and ready to go!","mailpoet"),notification:(0,Ae.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,Ae.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,Ae.__)("You are all set up and ready to go!","mailpoet"))}),(0,h.jsx)(ds,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,h.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,h.jsx)(o.Heading,{level:4,children:(0,Ae.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,h.jsx)("p",{children:e.subscribersCount<1e3?(0,Ae._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,Ae._x)("Starting at only $10 per month, MailPoet Business offers the following features","Promotion for our email sending service: Paragraph","mailpoet")}),(0,h.jsxs)(o.Heading,{level:5,children:[(0,Ae._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,h.jsx)(cs,{}),(0,h.jsx)("p",{children:Re()((0,Ae.__)("Please enter your key in [link]the Settings[/link] if you have already purchased it.","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,h.jsx)("a",{href:"admin.php?page=mailpoet-settings#/premium",children:e},t)))}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(o.Button,{isFullWidth:!0,href:e.purchaseUrl,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),window.open(e.purchaseUrl),i()},children:(0,Ae._x)("Sign up for free","Promotion for our email sending service: Button","mailpoet")}),(0,h.jsx)(o.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,Ae._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function us(e){return window.has_mss_key_specified?(0,h.jsx)(ls,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,h.jsx)(ms,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function ps(e){const[t,a]=(0,r.useState)(!1);return(0,h.jsxs)("div",{children:[(0,h.jsx)(xt.D,{level:1,children:(0,Ae.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,h.jsx)(xt.D,{level:3,children:Re()((0,Ae.__)("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,h.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kb.mailpoet.com/article/231-sending-does-not-work",children:e},t)))}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)("img",{src:window.mailpoet_congratulations_error_image,alt:"",width:"500"}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)(o.Button,{dimension:"small",type:"button",onClick:()=>{e.failClicked(),a(!0)},withSpinner:t,children:(0,Ae.__)("Close","mailpoet")})]})}os.contextType=l.F,ls.propTypes={successClicked:at().func.isRequired,illustrationImageUrl:at().string.isRequired,newsletter:at().shape({status:at().string.isRequired,type:at().string.isRequired}).isRequired},ds.propTypes={illustrationUrl:at().string.isRequired,children:at().oneOfType([at().arrayOf(at().node),at().node]).isRequired},us.propTypes={successClicked:at().func.isRequired,illustrationImageUrl:at().string.isRequired,MSSPitchIllustrationUrl:at().string.isRequired,newsletter:at().shape({status:at().string.isRequired,type:at().string.isRequired}).isRequired,subscribersCount:at().number.isRequired,purchaseUrl:at().string.isRequired},ps.propTypes={failClicked:at().func.isRequired};var hs=a(41024);function gs(e){return(0,h.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,h.jsxs)("div",{children:[(0,h.jsx)(xt.D,{level:0,children:(0,Ae.__)("Verification","mailpoet")}),(0,h.jsx)(xt.D,{level:3,children:(0,Ae.__)("Congrats, you’re sending your first newsletter! We’re doing a quick verification to make sure everything works fine.","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)("div",{className:"mailpoet-gap-large"}),(0,h.jsx)(hs.a,{size:64})]})})}gs.propTypes={showRichLoadingScreen:at().bool.isRequired};const _s=Math.floor(4*Math.random());function fs(){return m.U.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 xs extends r.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:Qe()(),minimumLoadingTimePassed:!1},this.tick=this.tick.bind(this)}componentDidMount(){this.loadNewsletter(this.props.params.id),this.tick()}componentDidUpdate(e){e.params.id!==this.props.params.id&&this.loadNewsletter(this.props.params.id)}tick(){Qe()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.params.id),Qe()().subtract(6,"seconds").isAfter(this.state.timeStart)&&this.setState({minimumLoadingTimePassed:!0}),!this.state.loading&&this.state.minimumLoadingTimePassed||setTimeout(this.tick,2e3)}loadNewsletter(e){m.U.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,h.jsx)(gs,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:fs,showRichLoadingScreen:e})):this.state.error?(m.U.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,h.jsx)(ps,{failClicked:()=>{window.location=window.mailpoet_emails_page}})):(t=this.state.newsletter,this.state.testingPassed&&m.U.trackEvent("Cron testing done",{"Cron is working":"true"}),(0,h.jsx)(us,{illustrationImageUrl:window.mailpoet_congratulations_success_images[_s],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[_s],successClicked:fs,newsletter:t,isWoocommerceActive:window.mailpoet_woocommerce_active,subscribersCount:window.mailpoet_subscribers_count,purchaseUrl:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"starter",{utm_medium:"first-newsletter-congratulations",utm_campaign:"purchase"})}));var e,t}render(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("style",{dangerouslySetInnerHTML:{__html:"body { background: #fff; overflow-x: hidden; }"}}),(0,h.jsxs)("div",{className:"mailpoet-congratulate",children:[(0,h.jsx)("div",{className:"mailpoet-gap-large"}),this.renderContent()]})]})}}xs.propTypes={params:at().shape({id:at().string}).isRequired},xs.displayName="Congratulate";class bs extends r.Component{componentDidMount(){m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,Ae.__)("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.apiError(e,{scroll:!0})}))}showTemplateSelection=e=>{this.props.navigate(`/template/${e}`)};render(){return(0,h.jsx)("div",{children:(0,h.jsx)(ja,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}bs.contextType=l.F,bs.propTypes={navigate:at().func.isRequired},bs.displayName="NewsletterStandard";const vs={name:"options",type:"reactComponent",component:Ui};class js extends r.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=()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:ot.default.extend({},this.state,{type:"notification",subject:(0,Ae.__)("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.apiError(e,{scroll:!0})}))};showTemplateSelection=e=>{this.props.navigate(`/template/${e}`)};render(){return(0,h.jsxs)("div",{children:[(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(ja,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,h.jsxs)(Ra.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,h.jsx)(xt.D,{level:4,children:(0,Ae.__)("When to send this post notification email?","mailpoet")}),(0,h.jsx)(Ui,{item:this.state,field:vs,onValueChange:this.handleValueChange}),(0,h.jsx)(Te.$,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,Ae.__)("Next","mailpoet")})]})]})}}function ys(){let e="";m.U.deactivateSubscriberAfterInactiveDays&&(e=(Math.floor(Number(m.U.deactivateSubscriberAfterInactiveDays)/30)-1).toString());const[t,a]=(0,r.useState)({afterTimeNumber:e,afterTimeType:"months"}),[i,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(!1),l=(0,Se.Zp)();return(0,h.jsxs)("div",{children:[(0,h.jsx)(Ze.V,{color:"#fff"}),i&&(0,h.jsx)(pa,{errors:i}),(0,h.jsx)(ja,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,h.jsxs)(Ra.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,h.jsx)(Ki,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,Yi.compose)([a,(0,Yi.assoc)("afterTimeNumber",Yi.__,t)]),updateAfterTimeType:(0,Yi.compose)([a,(0,Yi.assoc)("afterTimeType",Yi.__,t)])}),(0,h.jsx)(Te.$,{isFullWidth:!0,onClick:()=>(s([]),o(!0),void m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"create",data:{type:"re_engagement",subject:(0,Ae.__)("Subject","mailpoet"),options:t}}).done((e=>{var t;t=e.data.id,l(`/template/${t}`)})).fail((e=>{o(!1),e.errors&&s(e.errors)}))),type:"button",isDisabled:!t.afterTimeNumber||n,withSpinner:n,children:(0,Ae.__)("Next","mailpoet")})]})]})}js.contextType=l.F,js.propTypes={navigate:at().func.isRequired},js.displayName="NewsletterNotification",ys.displayName="NewsletterTypeReEngagement";var ws=a(10697),Ss=a(92489),Ns=a(29921);function Is({newsletter:e}){const[t,a]=(0,r.useState)("paused"===e.queue.status),[i,s]=(0,r.useState)([]),n=async()=>{s([]),await(async()=>{await m.U.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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(pa,{errors:i}),t&&(0,h.jsx)(Te.$,{dimension:"small",onClick:e.status===Qa.um.Corrupt?async()=>{(0,o.confirmAlert)({message:(0,Ae.__)("There was an issue sending this email before. Please confirm the problems are fixed to proceed.","mailpoet"),onConfirm:n})}:n,children:(0,Ae.__)("Resume","mailpoet")}),!t&&(0,h.jsx)(Te.$,{dimension:"small",onClick:async()=>{s([]),await m.U.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,Ae.__)("Pause","mailpoet")})]})}function Us(){return(0,h.jsx)("div",{className:"mailpoet-listing-stats-too-early",children:(0,h.jsx)("a",{href:"admin.php?page=mailpoet-help#/systemStatus",className:"mailpoet-tag mailpoet-tag-inverted mailpoet-tag-unknown",children:(0,Ae.__)("Cancelled","mailpoet")})})}function Cs({newsletter:e,mailerLog:t}){const a=e.sent_at||e.queue.scheduled_at,i=e.queue&&"cancelled"===e.queue.status,s=e.queue&&"scheduled"!==e.queue.status,n="paused"===t.status,r=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(we.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:(0,h.jsx)(Ns.um,{processed:parseInt(e.queue.count_processed,10),scheduledFor:a,total:parseInt(e.queue.count_total,10),isPaused:n,status:e.status,logs:e.logs})}),i&&(0,h.jsx)(Us,{}),"completed"!==e.queue.status&&!i&&!n&&(0,h.jsx)(Is,{newsletter:e})]}),o=(0,h.jsx)(Ns.um,{scheduledFor:a,isPaused:"scheduled"===e.queue.status&&n,status:e.status,logs:e.logs});return(0,h.jsxs)(h.Fragment,{children:[s&&r,!s&&o]})}Cs.displayName="QueueStatus";const ks=(0,o.withBoundary)(Cs);var As=a(41628);function Ts({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:Pt.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",Ia.cp)},n=Number(e.total_sent||e.queue.count_processed),r=e.queue&&"cancelled"===e.queue.status;if(r&&0===n)return null;let l,d,c,m,u,p=0,g=0,_=null;n>0&&(p=100*e.statistics.clicked/n,g=100*e.statistics.opened/n,_=e.statistics.revenue),r||void 0===a?(m=!1,u=!1):(l=6,d=e.queue.scheduled_at||e.queue.created_at,c=Qe()(a).diff(Qe()(d),"hours"),m=c<l,u=!0);const f=n>=20&&e.statistics.opened>=5&&!m,x=(t,a)=>((e,t,a,i)=>i<=0||!t.link?e:t.externalLink?(0,h.jsx)("a",{href:t.link,onClick:t.onClick||null,children:e},`stats-${a}`):(0,h.jsx)(we.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${a}`))(t,s,`${a}-${e.id}`,n),b=(0,h.jsx)(As.j,{opened:g,clicked:p,revenues:_&&_.value>0?_.formatted:null,hideBadges:!f,newsletterId:e.id,wrapContentInLink:x}),v=(0,h.jsxs)(h.Fragment,{children:[b,m&&x((0,h.jsx)(o.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,Ae.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",l-c)}),"check-back")]});let j;return u&&g<5&&c>=24&&n>=10&&(j=(0,h.jsx)("div",{children:(0,h.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,Ae.__)("What can I do to improve this?","mailpoet")})})),(0,h.jsxs)(h.Fragment,{children:[v,j]})}const Es=at().shape({clicked:at().number,opened:at().number,unsubscribed:at().number,revenue:at().shape({count:at().number,currency:at().string,formatted:at().string,value:at().number})}),Rs=at().shape({status:at().string,count_processed:at().string.isRequired,count_total:at().string.isRequired,created_at:at().string,scheduled_at:at().string});Ts.propTypes={newsletter:at().shape({id:at().number.isRequired,queue:at().oneOfType([Rs,at().bool]),total_sent:at().number,statistics:at().oneOfType([Es,at().bool])}).isRequired,isSent:at().bool,currentTime:at().string},Ts.displayName="NewsletterStatistics";const Ds=(0,o.withBoundary)(Ts),Fs=m.U.trackingConfig.emailTrackingEnabled,Os={onNoItemsFound:(e,t)=>t?(0,Ae.__)("No emails found.","mailpoet"):(0,Ae.__)("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,Ae.__)("1 email was moved to the trash.","mailpoet"):(0,Ae.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email was permanently deleted.","mailpoet"):(0,Ae.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email has been restored from the Trash.","mailpoet"):(0,Ae.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Ps=[{name:m.U.FeaturesController.isSupported("gutenberg_email_editor")?"name":"subject",label:m.U.FeaturesController.isSupported("gutenberg_email_editor")?(0,Ae.__)("Name","mailpoet"):(0,Ae.__)("Subject","mailpoet"),sortable:!0},{name:"status",label:(0,Ae.__)("Status","mailpoet")},{name:"segments",label:(0,Ae.__)("Lists","mailpoet")},{name:"statistics",label:(0,Ae.__)("Clicked, Opened","mailpoet"),display:Fs},{name:"sent_at",label:(0,Ae.__)("Sent on","mailpoet"),sortable:!0}],Ls=[{name:"trash",label:(0,Ae.__)("Move to trash","mailpoet"),onSuccess:Os.onTrash}],Ms=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;m.U.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=m.U.getBlockEmailEditorUrl(e.wp_post_id)),e.queue&&"sending"===e.status&&null===e.queue.status?(0,wa.Z)({message:(0,Ae.__)("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 $s=[{name:"view",link:function(e){return(0,h.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Edit","mailpoet"),onClick:Ms},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Duplicate","mailpoet"),onClick:function(e,t){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{m.U.Notice.success((0,Ae.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,ws.escapeHTML)(e.data.subject))),t()})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];$s=(0,Ia.pE)($s);class Bs extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}renderItem=(e,t,a)=>{const i=Q()("manage-column","column-primary","has-row-actions"),s=e.queue.newsletter_rendered_subject||e.subject;return(0,h.jsxs)("div",{children:[(0,h.jsxs)("td",{className:i,children:[(0,h.jsx)("a",{className:"mailpoet-listing-title",href:"#",onClick:t=>{t.preventDefault(),Ms(e)},children:e.campaign_name?(0,h.jsxs)(h.Fragment,{children:[e.campaign_name," ",(0,h.jsx)("br",{}),(0,h.jsx)("span",{className:"mailpoet-listing-subtitle",children:s})]}):s}),t]}),(0,h.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Ae.__)("Status","mailpoet"),children:(0,h.jsx)(ks,{newsletter:e,mailerLog:a.mta_log})}),(0,h.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Lists","mailpoet"),children:(0,h.jsxs)(o.ErrorBoundary,{children:[(0,h.jsx)(Ss.vC,{segments:e.segments,dimension:"large"}),(0,h.jsx)(Ss.y,{newsletter:e,dimension:"large"})]})}),!0===Fs?(0,h.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Ae.__)("Clicked, Opened","mailpoet"),children:(0,h.jsx)(Ds,{newsletter:e,currentTime:a.current_time})}):null,(0,h.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Sent on","mailpoet"),children:e.sent_at?(0,h.jsxs)(h.Fragment,{children:[m.U.Date.short(e.sent_at),(0,h.jsx)("br",{}),m.U.Date.time(e.sent_at)]}):null})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,h.jsxs)(h.Fragment,{children:[0===this.state.newslettersCount&&(0,h.jsx)(xa,{filter:e=>"standard"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"standard",base_url:"standard",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Ps,bulk_actions:Ls,item_actions:$s,messages:Os,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,Ia.DP)(e),(0,Ia.tQ)(e)}})]})}}Bs.contextType=l.F,Bs.propTypes={location:at().object.isRequired,params:at().object.isRequired},Bs.displayName="NewsletterListStandard";const qs=(0,o.withBoundary)(Bs);function Hs(e){const t=(0,Se.zy)(),a=(0,Se.g)();return(0,h.jsx)(qs,{...e,location:t,params:a})}var Ws=a(37737);const zs={onNoItemsFound:(e,t)=>t?(0,Ae.__)("No emails found.","mailpoet"):(0,Ae.__)("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,Ae.__)("1 email was moved to the trash.","mailpoet"):(0,Ae.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email was permanently deleted.","mailpoet"):(0,Ae.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email has been restored from the Trash.","mailpoet"):(0,Ae.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Vs=[{name:"subject",label:(0,Ae.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Ae.__)("Settings","mailpoet")},{name:"history",label:(0,Ae.__)("History","mailpoet"),width:100},{name:"status",label:(0,Ae.__)("Status","mailpoet"),width:100},{name:"updated_at",label:(0,Ae.__)("Last modified on","mailpoet"),sortable:!0}],Gs=[{name:"trash",label:(0,Ae.__)("Move to trash","mailpoet"),onSuccess:zs.onTrash}],Ys=[{name:"view",link:function(e){return(0,h.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Edit","mailpoet"),onClick:Ia.$U},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Duplicate","mailpoet"),onClick:function(e,t){return m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{m.U.Notice.success((0,Ae.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,ws.escapeHTML)(e.data.subject))),t()})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class Ks extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),m.U.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&&m.U.Notice.success((0,Ae.__)("Your post notification is now active!","mailpoet")),this.forceUpdate()})).fail((a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e}))};renderStatus=e=>(0,h.jsx)(Ja.l,{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,h.jsx)(we.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Ae.__)("You need to select a list to send to.","mailpoet")});const a=Re()((0,Ae.__)("Send to %1$s","mailpoet"),"%1$s",((t,a)=>(0,h.jsxs)(r.Fragment,{children:[(0,h.jsx)(Ss.vC,{segments:e.segments},`segment-${a}`),(0,h.jsx)(Ss.y,{newsletter:e},`filter-segment-${a}`)]},a)));switch(e.options.intervalType){case"daily":t=(0,Ae.__)("Daily at %1$s","mailpoet").replace("%1$s",xi[e.options.timeOfDay]);break;case"weekly":t=(0,Ae.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",bi[e.options.weekDay]).replace("%2$s",xi[e.options.timeOfDay]);break;case"monthly":t=(0,Ae.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",vi[e.options.monthDay]).replace("%2$s",xi[e.options.timeOfDay]);break;case"nthWeekDay":t=(0,Ae.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",ji[e.options.nthWeekDay]).replace("%2$s",bi[e.options.weekDay]).replace("%3$s",xi[e.options.timeOfDay]);break;case"immediately":t=(0,Ae.__)("Immediately","mailpoet");break;default:t="Invalid sending frequency"}return(0,h.jsxs)("span",{children:[a,(0,h.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,h.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,h.jsx)(Ws.x,{})}),t]})]})};renderHistoryLink=e=>0===Number(e.children_count)?(0,h.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,Ae.__)("Not sent yet","mailpoet")}):(0,h.jsxs)(we.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:[(0,h.jsx)(Te.$,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,Ae.__)("View history","mailpoet")}),(0,h.jsx)(Te.$,{className:"mailpoet-show-on-mobile mailpoet-listing-notification-status",dimension:"small",variant:"secondary",children:(0,Ae.__)("View history","mailpoet")})]});renderItem=(e,t)=>{const a=Q()("manage-column","column-primary","has-row-actions");return(0,h.jsxs)("div",{children:[(0,h.jsxs)("td",{className:a,children:[(0,h.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,Ia.$U)(e)},children:e.subject}),t]}),(0,h.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Settings","mailpoet"),children:this.renderSettings(e)}),(0,h.jsx)("td",{className:"column","data-colname":(0,Ae.__)("History","mailpoet"),children:this.renderHistoryLink(e)}),(0,h.jsx)("td",{className:"column","data-colname":(0,Ae.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,h.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Last modified on","mailpoet"),children:[m.U.Date.short(e.updated_at),(0,h.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,h.jsxs)(h.Fragment,{children:[0===this.state.newslettersCount&&(0,h.jsx)(xa,{filter:e=>"notification"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"notification",base_url:"notification",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Vs,bulk_actions:Gs,item_actions:Ys,messages:zs,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,Ia.DP)(e),(0,Ia.tQ)(e)}})]})}}Ks.propTypes={location:at().object.isRequired,params:at().object.isRequired},Ks.displayName="NewsletterListNotification";const Js=(0,o.withBoundary)(Ks);function Qs(e){const t=(0,Se.zy)(),a=(0,Se.g)();return(0,h.jsx)(Js,{...e,location:t,params:a})}const Zs=m.U.trackingConfig.emailTrackingEnabled,Xs={onNoItemsFound:(e,t)=>t?(0,Ae.__)("No emails found.","mailpoet"):(0,Ae.__)("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,Ae.__)("1 email was moved to the trash.","mailpoet"):(0,Ae.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email was permanently deleted.","mailpoet"):(0,Ae.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email has been restored from the Trash.","mailpoet"):(0,Ae.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},en=[{name:"subject",label:(0,Ae.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,Ae.__)("Settings","mailpoet")},{name:"statistics",label:(0,Ae.__)("Clicked, Opened","mailpoet"),display:Zs},{name:"status",label:(0,Ae.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,Ae.__)("Last modified on","mailpoet"),sortable:!0}],tn=[{name:"trash",label:(0,Ae.__)("Move to trash","mailpoet"),onSuccess:Xs.onTrash}];let an=[{name:"view",link:function(e){return(0,h.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Duplicate","mailpoet"),onClick:(e,t)=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((e=>{m.U.Notice.success((0,Ae.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,ws.escapeHTML)(e.data.subject))),t()})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,Ae.__)("Edit","mailpoet"),onClick:Ia.$U},{name:"trash",className:"mailpoet-hide-on-mobile"}];an=(0,Ia.pE)(an);class sn extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}updateStatus=(e,t)=>{t.persist(),m.U.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&&m.U.Notice.success((0,Ae.__)("Your Re-engagement Email is now activated!","mailpoet")),this.forceUpdate()})).fail((a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e}))};renderStatus=e=>{const t=(0,Ae._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString());return(0,h.jsxs)("div",{children:[(0,h.jsx)(Ja.l,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,h.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,h.jsx)(we.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})})]})};renderSettings=e=>{if(0===e.segments.length)return(0,h.jsx)(we.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,Ae.__)("You need to select a list to send to.","mailpoet")});const t=Re()((0,Ae.__)("Send to %1$s","mailpoet"),"%1$s",((t,a)=>(0,h.jsxs)(r.Fragment,{children:[(0,h.jsx)(Ss.vC,{segments:e.segments},`segment-${a}`),(0,h.jsx)(Ss.y,{newsletter:e},`filter-segment-${a}`)]},a)));let a=(0,Ae._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet");e.options.afterTimeNumber>1&&"months"===e.options.afterTimeType?a=(0,Ae._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):e.options.afterTimeNumber>1&&"weeks"===e.options.afterTimeType?a=(0,Ae._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"):1===e.options.afterTimeNumber&&"weeks"===e.options.afterTimeType&&(a=(0,Ae._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet"));const i=(0,Ae._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",e.options.afterTimeNumber).replace("{$frequency}",a);return(0,h.jsxs)("span",{children:[t,(0,h.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,h.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,h.jsx)(Ws.x,{})}),i]})]})};renderItem=(e,t)=>{const a=Q()("manage-column","column-primary","has-row-actions");return(0,h.jsxs)("div",{children:[(0,h.jsxs)("td",{className:a,children:[(0,h.jsx)("a",{className:"mailpoet-listing-title",href:`?page=mailpoet-newsletter-editor&id=${e.id}`,onClick:t=>{t.preventDefault(),(0,Ia.$U)(e)},children:e.subject}),t]}),(0,h.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===Zs?(0,h.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Ae.__)("Clicked, Opened","mailpoet"),children:(0,h.jsx)(Ds,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,h.jsx)("td",{className:"column","data-colname":(0,Ae.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,h.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Last modified on","mailpoet"),children:[m.U.Date.short(e.updated_at),(0,h.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,h.jsxs)(h.Fragment,{children:[0===this.state.newslettersCount&&(0,h.jsx)(xa,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,endpoint:"newsletters",type:"re_engagement",base_url:"re_engagement",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,Ia.DP)(e),(0,Ia.tQ)(e)}})]})}}sn.propTypes={location:at().object.isRequired,params:at().object.isRequired},sn.displayName="NewsletterListReEngagement";const nn=(0,o.withBoundary)(sn);function rn(e){const t=(0,Se.zy)(),a=(0,Se.g)();return(0,h.jsx)(nn,{...e,location:t,params:a})}const on=m.U.trackingConfig.emailTrackingEnabled,ln=[{name:"subject",label:(0,Ae.__)("Subject","mailpoet")},{name:"status",label:(0,Ae.__)("Status","mailpoet")},{name:"segments",label:(0,Ae.__)("Lists","mailpoet")},{name:"statistics",label:(0,Ae.__)("Clicked, Opened","mailpoet"),display:on},{name:"sent_at",label:(0,Ae.__)("Sent on","mailpoet"),sortable:!0}],dn={onNoItemsFound:(e,t)=>t?(0,Ae.__)("No emails found.","mailpoet"):(0,Ae.__)("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,Ae.__)("1 email was moved to the trash.","mailpoet"):(0,Ae.__)("%1$d emails were moved to the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email was permanently deleted.","mailpoet"):(0,Ae.__)("%1$d emails were permanently deleted.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,Ae.__)("1 email has been restored from the Trash.","mailpoet"):(0,Ae.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},cn=[{name:"trash",label:(0,Ae.__)("Move to trash","mailpoet"),onSuccess:dn.onTrash}],mn=(0,Ia.pE)([{name:"view",link:function(e){return(0,h.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Preview","mailpoet")})}},{name:"trash",className:"mailpoet-hide-on-mobile"}]),un=(e,t,a)=>{const i=Q()("manage-column","column-primary","has-row-actions");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("td",{className:i,children:[(0,h.jsx)("strong",{children:(0,h.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:e.queue.newsletter_rendered_subject||e.subject})}),t]}),(0,h.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,Ae.__)("Status","mailpoet"),children:(0,h.jsx)(ks,{newsletter:e,mailerLog:a.mta_log})}),(0,h.jsxs)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Lists","mailpoet"),children:[(0,h.jsx)(Ss.vC,{segments:e.segments,dimension:"large"}),(0,h.jsx)(Ss.y,{newsletter:e,dimension:"large"})]}),!0===on?(0,h.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,Ae.__)("Clicked, Opened","mailpoet"),children:(0,h.jsx)(Ds,{newsletter:e,currentTime:a.current_time})}):null,(0,h.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,Ae.__)("Sent on","mailpoet"),children:e.sent_at?(0,h.jsxs)(h.Fragment,{children:[m.U.Date.short(e.sent_at),(0,h.jsx)("br",{}),m.U.Date.time(e.sent_at)]}):null})]})};function pn(e){const t=(0,Se.g)(),a=(0,Se.zy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(we.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,Ae.__)("Back to Post notifications","mailpoet")}),(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:a,params:{...t,parentId:e.parentId},endpoint:"newsletters",type:"notification_history",base_url:"notification/history/:parentId",onRenderItem:un,columns:ln,messages:dn,item_actions:mn,bulk_actions:cn,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{(0,Ia.DP)(e),(0,Ia.tQ)(e)}})]})}pn.propTypes={parentId:at().string.isRequired},pn.displayName="NewsletterListNotificationHistory";const hn=(0,o.withBoundary)(pn),gn=[{name:"subscriber_id",label:(0,Ae.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,Ae._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet")},{name:"failureReason",label:(0,Ae.__)("Failure reason (if applicable)","mailpoet")}],_n={onNoItemsFound:()=>(0,Ae.__)("No sending task found.","mailpoet")};function fn(){const e=(0,Se.g)(),t=(0,Se.zy)(),[a,i]=(0,r.useState)({id:e.id,subject:"",sent:!1}),s=(0,r.useRef)(null);return(0,r.useEffect)((()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:a.id}}).done((e=>i({id:a.id,subject:e.data.subject,sent:null!==e.data.sent_at}))).fail((e=>m.U.Notice.showApiErrorNotice(e)))}),[a.id]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h1",{children:(0,Ae._x)("Sending status","Page title. This page displays a list of emails along with their sending status: unprocessed, sent or failed.","mailpoet")}),(0,h.jsx)(vn,{newsletter:a}),(0,h.jsx)(bn,{location:t,params:e,refreshRef:s})]})}fn.displayName="SendingStatus";const xn=(e,t)=>e.location.pathname===t.location.pathname&&e.params.id===t.params.id,bn=(0,r.memo)((({location:e,params:t,refreshRef:a})=>(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"sending_task_subscribers",base_url:"sending-status/:id",onRenderItem:e=>((e,t)=>(0,h.jsx)("div",{children:(0,h.jsx)(jn,{...e,refreshRef:t})}))(e,a),getListingItemKey:e=>`${e.taskId}-${e.subscriberId}`,columns:gn,messages:_n,auto_refresh:!0,sort_by:"failed",sort_order:"desc",refreshRef:a,afterGetItems:e=>{(0,Ia.DP)(e),(0,Ia.tQ)(e)}})),xn);function vn({newsletter:e={id:null,subject:null,sent:!1}}){return e.id&&e.subject&&e.sent?(0,h.jsx)("p",{children:(0,h.jsx)(we.Link,{to:`/stats/${e.id}`,children:e.subject})}):null}function jn({failed:e,taskId:t,processed:a,email:i,subscriberId:s,lastName:n,firstName:r,refreshRef:o=null,error:l=""}){const d=Q()("manage-column","column-primary","has-row-actions");let c=(0,Ae._x)("Unprocessed","status when the sending of a newsletter has not been processed","mailpoet");return a&&(c=e?(0,h.jsxs)("span",{children:[(0,Ae._x)("Failed","status when the sending of a newsletter has failed","mailpoet"),(0,h.jsx)("br",{}),(0,h.jsx)("a",{className:"button",href:"#",onClick:e=>{e.preventDefault(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sending_task_subscribers",action:"resend",data:{taskId:t,subscriberId:s}}).done((()=>o?.current&&o.current())).fail((e=>m.U.Notice.showApiErrorNotice(e)))},children:(0,Ae.__)("Resend","mailpoet")})]}):(0,Ae._x)("Sent","status when a newsletter has been sent","mailpoet")),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("td",{"data-automation-id":`name_${t}_${s}`,className:d,children:[(0,h.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${s}`,children:i}),(0,h.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${r} ${n}`})]}),(0,h.jsx)("td",{className:"column","data-automation-id":`status_${t}_${s}`,"data-colname":(0,Ae._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet"),children:c}),(0,h.jsx)("td",{className:"column","data-automation-id":`error_${t}_${s}`,"data-colname":(0,Ae.__)("Failure reason (if applicable)","mailpoet"),children:l})]})}bn.propTypes={location:at().shape({pathname:at().string}).isRequired,params:at().shape({id:at().string.isRequired}).isRequired,refreshRef:at().shape({current:at().func})},vn.propTypes={newsletter:at().shape({id:at().string,subject:at().string,sent:at().bool})},jn.propTypes={error:at().string,email:at().string.isRequired,failed:at().number.isRequired,taskId:at().number.isRequired,lastName:at().string.isRequired,firstName:at().string.isRequired,processed:at().number.isRequired,subscriberId:at().number.isRequired,refreshRef:at().shape({current:at().func})},jn.displayName="ListingItem",fn.displayName="SendingStatus";var yn=a(77542),wn=a(65270),Sn=a(38255),Nn=a.n(Sn);function In({installedDaysAgo:e,reviewRequestIllustrationUrl:t,username:a}){const i=Math.round(e/30),s=e>30?(0,Ae.sprintf)((0,Ae._n)("You’ve been using MailPoet for %d month now, and we would love to read your own review.","You’ve been using MailPoet for %d months now, and we would love to read your own review.",i,"mailpoet"),i):(0,Ae.sprintf)((0,Ae._n)("You’ve been using MailPoet for %d day now, and we would love to read your own review.","You’ve been using MailPoet for %d days now, and we would love to read your own review.",e,"mailpoet"),e);return(0,h.jsxs)("div",{className:"mailpoet_review_request",children:[(0,h.jsx)("img",{src:t,height:"280",width:"280",alt:""}),(0,h.jsx)("h2",{children:(0,Ae.__)("Thank you! Time to tell the world?","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.sprintf)((0,Ae.__)("%s, did you know that hundreds of WordPress users read the reviews on the plugin repository? They’re also a source of inspiration for our team.","mailpoet"),(0,ws.escapeHTML)(a))}),(0,h.jsx)("p",{children:s}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{href:"http://bit.ly/2Bi124o",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:(0,Ae.__)("Rate us now","mailpoet")})}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{id:"mailpoet_review_request_not_now",children:(0,Ae.__)("Not now")})})]})}const Un=()=>((0,r.useLayoutEffect)((()=>{window.mailpoet_display_nps_poll&&window.mailpoet_3rd_party_libs_enabled&&(Xi||(Xi=m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),Xi).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",Nn()({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&&m.U.Modal.popup({width:800,template:wn.renderToString(In({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",(()=>m.U.Modal.close()))}})}}})})(e)))}),[]),null),Cn=e=>function(t){return Un(),(0,h.jsx)(e,{...t})};function kn(){return(0,h.jsx)(d.x,{children:(0,h.jsxs)(we.Link,{id:"mailpoet-new-email",className:"mailpoet-button button-secondary",to:"/new",onClick:()=>m.U.trackEvent("Emails > Add New"),"data-automation-id":"new_email",children:[Me.W,(0,h.jsx)("span",{children:(0,Ae.__)("New email","mailpoet")})]})})}function An({children:e}){const t=(0,Se.zy)();return null!==(0,va.S)(t)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(t)?null:e}function Tn(){return(0,h.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}An.propTypes={children:at().node.isRequired};var En=a(30486),Rn=a(28425),Dn=a(68764);const Fn=20,On=5,Pn=5,Ln=5,Mn=100,$n=e=>{const t=e<.1?2:1;return m.U.Num.toLocaleFixed(e,t)},Bn=e=>+(+e).toFixed(1);function qn({newsletter:e,isWoocommerceActive:t}){const a=e.total_sent||0;let i=0,s=0,n=0,r=0,o=0;a>0&&(i=100*e.statistics.clicked/a,s=100*e.statistics.opened/a,n=100*e.statistics.machineOpened/a,r=100*e.statistics.unsubscribed/a,o=100*e.statistics.bounced/a);const l=$n(i),d=$n(s),c=$n(n),u=$n(r),p=$n(o),g=a>=Fn&&e.statistics.opened>=On,_=e.statistics.unsubscribed>=Pn&&a>=Mn,f=e.statistics.bounced>=Ln&&a>=Mn,x=(0,Dn.u)("opened",s)||"",b=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,h.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${x}`,children:[d,"% "]}),(0,Ae._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),g&&(0,h.jsx)(Dn.f,{isInverted:!1,stat:"opened",rate:s,tooltipId:`opened-${e.id||"0"}`,tooltipPlace:"right"})]}),v=(0,h.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,h.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[c,"% "]}),(0,Ae._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,h.jsx)(Fe.Tooltip,{tooltip:Re()((0,Ae.__)("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,h.jsx)("span",{style:{pointerEvents:"all"},children:(0,h.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=Bn(r),y=_?(0,Dn.u)("unsubscribed",j):"",w=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,h.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${y}`,children:[u,"% "]}),(0,Ae._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),_&&(0,h.jsx)(Dn.f,{isInverted:!1,stat:"unsubscribed",rate:j,tooltipId:`unsubscribed-${e.id||"0"}`,tooltipPlace:"right"})]}),S=Bn(o),N=f?(0,Dn.u)("bounced",S):"",I=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,h.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${N}`,children:[p,"% "]}),(0,Ae._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),f&&(0,h.jsx)(Dn.f,{isInverted:!1,stat:"bounced",rate:S,tooltipId:`bounced-${e.id||"0"}`,tooltipPlace:"right"})]}),U=(0,Dn.u)("clicked",i),C=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-statistics-value",children:[(0,h.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${U}`,children:[l,"% "]}),(0,Ae._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),g&&(0,h.jsx)(Dn.f,{isInverted:!1,stat:"clicked",rate:i,tooltipId:`clicked-${e.id||"0"}`,tooltipPlace:"right"})]});return(0,h.jsxs)("div",{className:"mailpoet-stats-general",children:[(0,h.jsxs)(Ra.Grid.ThreeColumns,{className:"mailpoet-stats-general-top-row",children:[(0,h.jsx)("div",{children:(0,h.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,Ae.__)("Sent to","mailpoet"),": ",(0,h.jsx)("span",{className:"mailpoet-statistics-value-number",children:a.toLocaleString()})]})}),(0,h.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:w}),(0,h.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:I})]}),(0,h.jsxs)(Ra.Grid.ThreeColumns,{children:[(0,h.jsx)("div",{children:C}),(0,h.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[b,m.U.trackingConfig.opensSeparated&&v]}),t&&(0,h.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:Pt.Hooks.applyFilters("mailpoet_newsletters_revenues_stats",null,e.statistics.revenue)}),!t&&(0,h.jsx)("div",{})]}),(0,h.jsxs)("div",{className:"mailpoet-stats-general-read-more",children:[(0,h.jsx)("p",{className:"mailpoet-stats-has-margin-left",children:(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/190-whats-a-good-email-open-rate",target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Read more on stats.","mailpoet")})}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{href:`admin.php?page=mailpoet-newsletters#/sending-status/${e.id}`,children:(0,Ae.__)("Sending status","mailpoet")})})]})]})}qn.displayName="NewsletterGeneralStats";var Hn=a(17741);const Wn=ra.A,zn=e=>{let t=`?page=mailpoet-newsletter-editor&id=${e.id}`;return m.U.FeaturesController.isSupported("gutenberg_email_editor")&&e.wp_post_id&&(t=m.U.getBlockEmailEditorUrl(e.wp_post_id)),t},Vn=e=>{const t=zn(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,o.confirmAlert)({message:(0,Ae.__)("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},Gn=(e,t=(()=>{}))=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done((t=>{const a=zn(t.data);m.U.Notice.success((0,Ae.sprintf)((0,Ae.__)('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&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})).always((()=>{t()}))},Yn=(e,t=(()=>{}))=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"trash",data:{id:e.id}}).done((()=>{m.U.Notice.success((0,Ae.__)("1 email was moved to the trash.","mailpoet")),window.location.href="?page=mailpoet-newsletters"})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})).always((()=>{t()}))};function Kn({newsletter:e}){const[t,a]=(0,r.useState)(!1),i=e?.queue?.scheduled_at||e?.queue?.created_at||e?.created_at;return(0,h.jsxs)(Ra.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,h.jsxs)("div",{children:[(0,h.jsxs)(xt.D,{level:1,children:[e.campaign_name?e.campaign_name:e.subject,e.campaign_name&&(0,h.jsx)("span",{children:` (${e.subject})`})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)(o.Tag,{isInverted:!1,children:(0,o.getNewsletterStatusString)(e.status)})," ",(0,h.jsxs)("b",{children:[m.U.Date.short(i)," • ",m.U.Date.time(i)]})]}),Array.isArray(e.segments)&&e.segments.length&&(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,Ae.__)("To","mailpoet")}),": ",(0,h.jsx)(o.SegmentTags,{dimension:"large",segments:e.segments}),(0,h.jsx)(o.FilterSegmentTag,{newsletter:e,dimension:"large"})]})]}),(0,h.jsx)("div",{className:"mailpoet-stats-info-sender-preview",children:(0,h.jsxs)("div",{children:[(0,h.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,h.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Ae.__)("From","mailpoet"),": "]}),e.sender_address?e.sender_address:"-"]}),(0,h.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,h.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Ae.__)("Reply-to","mailpoet"),": "]}),e.reply_to_address?e.reply_to_address:"-"]}),(0,h.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,h.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,Ae.__)("GA campaign","mailpoet"),": "]}),e.ga_campaign?e.ga_campaign:"-"]})]})}),(0,h.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,h.jsxs)(oa.A,{children:[(0,h.jsx)(de.Ay,{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,Ae.__)("Preview","mailpoet")}),(0,h.jsx)(la.A,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:a})=>(0,h.jsxs)(oa.A,{children:[(0,h.jsx)(de.Ay,{disabled:"standard"!==e.type,onClick:()=>{Vn(e)},variant:"primary",children:(0,Ae.__)("Edit","mailpoet")}),(0,h.jsxs)(de.Ay,{onClick:a,"aria-expanded":t,variant:"primary",children:[" ",(0,h.jsx)(da.A,{icon:ca.A,size:18})]})]}),renderContent:()=>(0,h.jsxs)(Hn.A,{children:[(0,h.jsx)(Wn,{isBusy:t,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==e.type,onClick:()=>{a(!0),Gn(e,(()=>{a(!1)}))},children:(0,Ae.__)("Duplicate","mailpoet")}),(0,h.jsx)(Wn,{isBusy:t,isDestructive:!0,onClick:()=>{a(!0),Yn(e,(()=>{a(!1)}))},children:(0,Ae.__)("Move to Trash","mailpoet")})]})})]})})]})}function Jn(){const e=(0,h.jsx)(Te.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,"starter",{utm_medium:"stats",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:(0,Ae.__)("Upgrade","mailpoet")}),t=(0,h.jsxs)("p",{children:[(0,Ae.__)("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,h.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",children:(0,Ae.__)("Learn more","mailpoet")}),"."]});return(0,h.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,h.jsx)(Zt,{message:t,actionButton:e,capabilities:{detailedAnalytics:!0}})})}function Qn(){return window.mailpoet_display_detailed_stats?null:(0,h.jsx)(Jn,{})}Kn.displayName="NewsletterStatsInfo",Qn.displayName="PremiumBanner";const Zn=(0,o.withBoundary)(Qn);function Xn(){const[e,t]=(0,r.useState)({item:void 0,loading:!0}),a=(0,Se.zy)(),i=(0,Se.Zp)(),s=(0,Se.g)(),n=(0,r.useCallback)((a=>{t({loading:!0,item:e.item}),m.U.Modal.loading(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:window.mailpoet_display_detailed_stats?"stats":"newsletters",action:window.mailpoet_display_detailed_stats?"get":"getWithStats",data:{id:a,accept:"all"}}).always((()=>{m.U.Modal.loading(!1)})).done((e=>{t({loading:!1,item:e.data})})).fail((e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0}),t({loading:!1}),i("/")}))}),[i,e.item]);(0,r.useEffect)((()=>{window.scrollTo(0,0),e.item?.id!==s.id&&n(s.id)}),[s.id,n,e.item]);const{item:l,loading:c}=e,u=l;return c?null:u?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(St.x,{}),(0,h.jsx)(Tn,{}),(0,h.jsx)(d.x,{}),(0,h.jsxs)("div",{className:"mailpoet-stats-page",children:[(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Kn,{newsletter:u})}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(qn,{newsletter:u,isWoocommerceActive:m.U.isWoocommerceActive})}),(0,h.jsxs)(En.t,{activeKey:"clicked",children:[(0,h.jsx)(Rn.o,{title:(0,Ae.__)("Clicked Links","mailpoet"),children:Pt.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,h.jsx)(Zn,{}),u.clicked_links)},"clicked"),m.U.isWoocommerceActive&&(0,h.jsx)(Rn.o,{title:(0,Ae.__)("Products Sold","mailpoet"),automationId:"products-sold-tab",children:Pt.Hooks.applyFilters("mailpoet_newsletters_purchased_products",(0,h.jsx)(Zn,{}),u)},"products"),(0,h.jsx)(Rn.o,{title:(0,Ae.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:Pt.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,h.jsx)(Zn,{}),a,s,u)},"engagement"),(0,h.jsx)(Rn.o,{title:(0,Ae._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:Pt.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,h.jsx)(Zn,{}),a,s)},"bounces")]})]})]}):(0,h.jsxs)("h3",{children:[" ",(0,Ae.__)("This email does not exist.","mailpoet")," "]})}function er({newsletters:e}){return(0,h.jsxs)(p.$,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,h.jsx)("h3",{children:(0,Ae.__)("Paused emails","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("There was problem sending the following email(s), please fix the issues described for each email and resume.","mailpoet")}),(0,h.jsx)("ul",{children:e.map((({id:e,subject:t})=>(0,h.jsx)("li",{children:t},e)))})]})}Xn.displayName="CampaignStatsPage",er.displayName="CorruptEmailNotice";var tr=a(87948),ar=a(46928);function ir(){const e=(0,r.useCallback)((()=>{(0,ar.k)({endpoint:"UserFlags",method:"set","data[legacy_automatic_emails_notice_dismissed]":"1"})}),[]);return(0,h.jsx)(p.$,{type:"info",timeout:!1,closable:!0,renderInPlace:!0,onClose:e,children:(0,h.jsx)("p",{children:(0,tr.A)((0,Ae.__)("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,h.jsx)("a",{href:"admin.php?page=mailpoet-automation"})})})})}const sr=Cn((()=>{const{parentId:e}=(0,Se.g)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(An,{children:(0,h.jsx)(kn,{})}),window.mailpoet_legacy_automatic_emails_count>0&&!window.mailpoet_legacy_automatic_emails_notice_dismissed&&(0,h.jsx)(ir,{}),m.U.corrupt_newsletters.length>0&&(0,h.jsx)(er,{newsletters:m.U.corrupt_newsletters}),(0,h.jsxs)(yn.k,{activeKey:"standard",routerType:"switch-only",onSwitch:e=>(e=>m.U.trackEvent(`Tab Emails > ${e} clicked`))(e),automationId:"newsletters_listing_tabs",children:[(0,h.jsx)(o.Tab,{route:"standard/*",title:(0,Ae.__)("Newsletters","mailpoet"),automationId:`tab-${(0,Ae.__)("Newsletters","mailpoet")}`,children:(0,h.jsx)(Hs,{})},"standard"),(0,h.jsx)(o.Tab,{route:"notification/*",title:(0,Ae.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,Ae.__)("Post Notifications","mailpoet")}`,children:e?(0,h.jsx)(hn,{parentId:e}):(0,h.jsx)(Qs,{})},"notification"),(0,h.jsx)(o.Tab,{route:"re_engagement/*",title:(0,Ae.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,Ae.__)("Re-engagement Emails","mailpoet")}`,children:(0,h.jsx)(rn,{})},"re_engagement")]})]})}));function nr({history:e}){return(0,h.jsxs)(o.ErrorBoundary,{children:[(0,h.jsx)(d.x,{}),(0,h.jsxs)("div",{className:"mailpoet-main-container",children:[(0,h.jsx)(It.z,{heading:(0,Ae.__)("What would you like to create?","mailpoet"),headingPrefix:(0,h.jsx)(It.o,{href:"#/",label:(0,Ae.__)("Listing","mailpoet"),"aria-label":(0,Ae.__)("Go back to email listing page","mailpoet")})}),(0,h.jsx)(xa,{history:e})]})]})}sr.displayName="NewsletterTabs",nr.propTypes={history:at().shape({push:at().func.isRequired}).isRequired},nr.displayName="NewNewsletter";const rr=[{path:"/notification/history/:parentId/*",children:(0,o.withBoundary)(sr)},{path:"/standard/*",children:(0,o.withBoundary)(sr)},{path:"/notification/*",children:(0,o.withBoundary)(sr)},{path:"/re_engagement/*",children:(0,o.withBoundary)(sr)},{path:"/new/standard",children:(0,o.withBoundary)((function(e){const t=(0,Se.Zp)();return(0,h.jsx)(bs,{...e,navigate:t})}))},{path:"/new/notification",children:(0,o.withBoundary)((function(e){const t=(0,Se.Zp)();return(0,h.jsx)(js,{...e,navigate:t})}))},{path:"/new/re-engagement",children:(0,o.withBoundary)(ys)},{path:"/new",children:(0,o.withBoundary)(nr)},{name:"template",path:"/template/:id",children:(0,o.withBoundary)((function(e){const t=(0,Se.g)();return(0,h.jsx)(Ca,{...e,params:t})}))},{path:"/send/congratulate/:id",children:(0,o.withBoundary)((function(e){const t=(0,Se.g)();return(0,h.jsx)(xs,{...e,params:t})}))},{path:"/send/:id",children:(0,o.withBoundary)((function(e){const t=(0,Se.zy)(),a=(0,Se.Zp)(),i=(0,Se.g)();return(0,h.jsx)(os,{...e,location:t,navigate:a,params:i})}))},{path:"/sending-status/:id/*",children:(0,o.withBoundary)(fn)},{path:"/stats/:id/*",children:(0,o.withBoundary)(Xn)}];function or(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(g,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed})}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(f.D,{})}),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{exact:!0,path:"/",element:(0,h.jsx)(Se.C5,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),rr.map((e=>(0,h.jsx)(Se.qh,{path:e.path,name:e.name||null,data:e.data||null,element:(0,h.jsx)(e.children,{})},e.path)))]})]})})}const lr=document.getElementById("newsletters_container");function dr(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.x,{children:(0,h.jsxs)(we.Link,{className:"mailpoet-button button-secondary",to:"/new","data-automation-id":"new-list",children:[Me.W,(0,h.jsx)("span",{children:m.U.I18n.t("new")})]})}),(0,h.jsx)(Le,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,h.jsx)(De,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at}),(0,h.jsx)(f.D,{})]})}lr&&((0,o.registerTranslations)(),(0,n.H)(lr).render((0,h.jsx)(or,{})));const cr=e=>"wp_users"===e.type,mr=e=>"woocommerce_users"===e.type,ur=e=>cr(e)||mr(e),pr=m.U.trackingConfig.emailTrackingEnabled,hr=[{name:"name",label:m.U.I18n.t("name"),sortable:!0},{name:"description",label:m.U.I18n.t("description")},{name:"average_subscriber_score",label:m.U.I18n.t("listScore"),display:pr},{name:"subscribed",label:m.U.I18n.t("subscribed"),className:"mailpoet-listing-column-narrow"},{name:"unconfirmed",label:m.U.I18n.t("unconfirmed"),className:"mailpoet-listing-column-narrow"},{name:"unsubscribed",label:m.U.I18n.t("unsubscribed"),className:"mailpoet-listing-column-narrow"},{name:"inactive",label:m.U.I18n.t("inactive"),className:"mailpoet-listing-column-narrow"},{name:"bounced",label:m.U.I18n.t("bounced"),className:"mailpoet-listing-column-narrow"},{name:"created_at",label:m.U.I18n.t("createdOn"),sortable:!0}],gr={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSegmentTrashed"):m.U.I18n.t("multipleSegmentsTrashed").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSegmentDeleted"):m.U.I18n.t("multipleSegmentsDeleted").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneSegmentRestored"):m.U.I18n.t("multipleSegmentsRestored").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},_r=[{name:"trash",label:m.U.I18n.t("moveToTrash"),onSuccess:gr.onTrash}],fr=e=>!ur(e),xr=[{name:"edit",className:"mailpoet-hide-on-mobile",link:function(e){return(0,h.jsx)(we.Link,{to:`/edit/${e.id}`,children:m.U.I18n.t("edit")})},display:function(e){return!ur(e)}},{name:"duplicate_segment",className:"mailpoet-hide-on-mobile",label:m.U.I18n.t("duplicate"),onClick:(e,t)=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"duplicate",data:{id:e.id}}).done((e=>{m.U.Notice.success(m.U.I18n.t("listDuplicated").replace("%1$s",(0,ws.escapeHTML)(e.data.name))),t()})).fail((e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0})})),display:function(e){return!ur(e)}},{name:"read_more",className:"mailpoet-hide-on-mobile",link:function(){return(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/133-the-wordpress-users-list",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("readMore")})},display:function(e){return cr(e)}},{name:"synchronize_segment",label:m.U.I18n.t("forceSync"),onClick:async function(e,t){m.U.Modal.loading(!0),await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"synchronize",data:{type:e.type}}).done((()=>{let a=m.U.I18n.t("listSynchronized").replace("%1$s",e.name);"woocommerce_users"===e.type&&(a=m.U.I18n.t("listSynchronizationWasScheduled").replace("%1$s",e.name)),m.U.Modal.loading(!1),m.U.Notice.success(a),t()})).fail((e=>{m.U.Modal.loading(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))},display:function(e){return cr(e)||mr(e)}},{name:"view_subscribers",link:function(e){return(0,h.jsx)("a",{href:e.subscribers_url,"data-automation-id":`view_subscribers_${e.name}`,children:m.U.I18n.t("viewSubscribers")})}},{name:"trash",className:"mailpoet-hide-on-mobile",display:function(e){return!mr(e)}}];class br extends r.Component{renderItem=(e,t)=>{const a=Q()("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),r=Number(e.subscribers_count.inactive||0),o=Number(e.subscribers_count.bounced||0);let l;return l=ur(e)?(0,h.jsx)("span",{className:"mailpoet-listing-title",children:e.name}):(0,h.jsx)(we.Link,{className:"mailpoet-listing-title",to:`/edit/${e.id}`,children:e.name}),(0,h.jsxs)("div",{children:[(0,h.jsxs)("td",{className:a,"data-automation-id":`segment_name_${(0,ws.escapeAttribute)(e.name)}`,children:[l,t]}),(0,h.jsx)("td",{"data-colname":m.U.I18n.t("description"),children:(0,h.jsx)("abbr",{children:e.description})}),pr?(0,h.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":m.U.I18n.t("averageScore"),children:(0,h.jsx)("div",{className:"mailpoet-listing-stats",children:(0,h.jsx)(pe,{id:e.id,engagementScore:e.average_engagement_score})})}):null,(0,h.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("subscribed"),children:(0,h.jsx)("abbr",{children:i.toLocaleString()})}),(0,h.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("unconfirmed"),children:(0,h.jsx)("abbr",{children:s.toLocaleString()})}),(0,h.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("unsubscribed"),children:(0,h.jsx)("abbr",{children:n.toLocaleString()})}),(0,h.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("inactive"),children:(0,h.jsx)("abbr",{children:r.toLocaleString()})}),(0,h.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("bounced"),children:(0,h.jsx)("abbr",{children:o.toLocaleString()})}),(0,h.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("createdOn"),children:[m.U.Date.short(e.created_at),(0,h.jsx)("br",{}),m.U.Date.time(e.created_at)]})]})};render(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dr,{}),(0,h.jsx)("div",{className:"mailpoet-segments-listing",children:(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,messages:gr,search:!1,endpoint:"segments",base_url:"lists",onRenderItem:this.renderItem,columns:hr,bulk_actions:_r,item_actions:xr,sort_by:"name",sort_order:"asc",isItemDeletable:fr,isItemToggleable:cr})})]})}}const vr=[{name:"name",label:m.U.I18n.t("segmentFormName"),type:"text",tip:m.U.I18n.t("segmentFormNameTip")},{name:"description",label:m.U.I18n.t("description"),type:"textarea",tip:m.U.I18n.t("segmentDescriptionTip")},{name:"showInManageSubscriptionPage",label:m.U.I18n.t("showInManageSubscriptionPage"),type:"checkbox",values:{showInManageSubscriptionPage:m.U.I18n.t("showInManageSubscriptionPageTip")},isChecked:!0}],jr={onUpdate:function(){m.U.Notice.success(m.U.I18n.t("segmentUpdated"))},onCreate:function(){m.U.Notice.success(m.U.I18n.t("segmentAdded")),m.U.trackEvent("Lists > Add new")}};function yr(){const e=(0,Se.g)();return(0,h.jsxs)("div",{className:"mailpoet-main-container",children:[(0,h.jsx)(d.x,{}),(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(St.x,{}),(0,h.jsx)(It.z,{heading:m.U.I18n.t("segment"),headingPrefix:(0,h.jsx)(It.o,{href:"#/",label:(0,Ae.__)("Lists","mailpoet"),"aria-label":(0,Ae.__)("Navigate to the lists page","mailpoet")})}),(0,h.jsx)(Nt.X,{}),(0,h.jsx)(wt,{endpoint:"segments",fields:vr,params:e,messages:jr})]})}yr.displayName="SegmentForm";const wr=document.getElementById("static_segments_container"),Sr=(0,o.withBoundary)(yr),Nr=(0,o.withBoundary)((function(e){const t=(0,Se.g)(),a=(0,Se.zy)();return(0,h.jsx)(br,{...e,params:t,location:a})}));function Ir(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:"/new",element:(0,h.jsx)(Sr,{})}),(0,h.jsx)(Se.qh,{path:"/edit/:id",element:(0,h.jsx)(Sr,{})}),(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(Nr,{})})]})]})})}wr&&((0,o.registerTranslations)(),(0,n.H)(wr).render((0,h.jsx)(Ir,{})));var Ur=a(30676),Cr=a(25281),kr=a(49188),Ar=a(91834);function Tr({children:e,title:t,description:a}){return(0,h.jsxs)("div",{className:"mailpoet-admin-fields",children:[(0,h.jsxs)("div",{className:"mailpoet-admin-fields-title",children:[(0,h.jsx)(Ar.D,{level:4,children:t}),(0,h.jsx)("p",{children:a})]}),(0,h.jsx)(Cr.A,{children:(0,h.jsx)(kr.A,{children:e})})]})}function Er({children:e,slug:t,title:a,description:i}){return(0,h.jsxs)("div",{className:"mailpoet-admin-field",children:[a&&(0,h.jsx)("p",{children:(0,h.jsx)("label",{htmlFor:`field_${t}`,children:a})}),(0,h.jsx)("div",{children:e}),i&&(0,h.jsx)("p",{className:"mailpoet-admin-field-description",children:i})]})}var Rr=a(95859),Dr=a(79579),Fr=a(96877),Or=a(96731);function Pr({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=(0,b.A)((e=>e(Fr.Hz).getAutomations()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,me.A)(Fr.Hz);(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&i({operator:Dr.dP.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>{s("operator",e,t)},isMinWidth:!0,children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.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 Lr={[Or.g.ENTERED_AUTOMATION]:Pr,[Or.g.EXITED_AUTOMATION]:Pr};function Mr({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getNewslettersList()),[]),n=s?.map((e=>{const t=e.sent_at?m.U.Date.format(e.sent_at):m.U.I18n.t("notSentYet");return{label:e.name,tag:t,value:Number(e.id)}}));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e),t.action===Dr._R.MACHINE_OPENED&&t.operator===Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[t.action,t.operator,e,a]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),t.action!==Dr._R.MACHINE_OPENED?(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")}):null]},"select"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:n,automationId:"segment-email",value:(0,Yi.filter)((e=>{if(!t.newsletters)return;const a=e.value;return-1!==t.newsletters.indexOf(a)}),n),onChange:t=>{a({newsletters:(0,Yi.map)((0,Yi.parseInt)(10),(0,Yi.map)("value",t))},e)}})]})}const $r=e=>!!e;var Br=a(7460);function qr({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,me.A)(Fr.Hz);(0,r.useEffect)((()=>{(0,Br.J)(t.timeframe,Dr.VE)||i({timeframe:Dr.VE.IN_THE_LAST},e)}),[t,i,e]);const s=t.timeframe===Dr.VE.IN_THE_LAST;return(0,h.jsx)(h.Fragment,{children:(n=i=>s&&"{days}"===i?(0,h.jsx)(o.Input,{type:"number",value:t.days||"","data-automation-id":"segment-number-of-days",onChange:t=>{a("days",e,t)},min:1,step:1,placeholder:m.U.I18n.t("daysPlaceholder")},"input"):"{timeframe}"===i?(0,h.jsxs)(lt.Select,{value:t.timeframe,onChange:t=>{a("timeframe",e,t)},children:[(0,h.jsx)("option",{value:"inTheLast",children:m.U.I18n.t("inTheLast")}),(0,h.jsx)("option",{value:"allTime",children:m.U.I18n.t("overAllTime")})]},"timeframe-select"):s&&"string"==typeof i&&i.trim().length>1?(0,h.jsx)("div",{children:i},i):null,m.U.I18n.t("emailActionOpensDaysSentence").split(/({days})|({timeframe})/gim).map(n))});var n}function Hr(e){return e.timeframe===Dr.VE.ALL_TIME||parseInt(e.days,10)>=1}function Wr({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{void 0===t.operator&&a({operator:"more"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,h.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{opens}"===a?(0,h.jsx)(it.p,{type:"number",value:t.opens||"","data-automation-id":"segment-number-of-opens",onChange:t=>{i("opens",e,t)},min:"0",placeholder:m.U.I18n.t("emailActionOpens")},"input"):"string"==typeof a&&a.trim().length>1?(0,h.jsx)("div",{children:a},"opens"):null,m.U.I18n.t("emailActionOpensSentence").split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]});var s}const zr={[Dr._R.OPENS_ABSOLUTE_COUNT]:Wr,[Dr._R.MACHINE_OPENS_ABSOLUTE_COUNT]:Wr,[Dr._R.CLICKED]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getNewslettersList()),[]),[n,o]=(0,r.useState)([]),[l,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),p=s?.map((e=>{const t=e.sent_at?m.U.Date.format(e.sent_at):(0,Ae.__)("Not sent yet","mailpoet");return{label:e.name,tag:t,value:Number(e.id)}})),g=(0,r.useCallback)((()=>{var e;$r(t.newsletter_id)&&(d([]),e=t.newsletter_id,o([]),u(!0),m.U.Ajax.post({api_version:m.U.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=>{o(e.errors)})))}),[t.newsletter_id]);return(0,r.useEffect)((()=>{g()}),[g,t.newsletter_id]),(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[t.operator,e,a]),(0,h.jsxs)(h.Fragment,{children:[n.length>0&&(0,h.jsx)(pa,{errors:n}),(0,h.jsx)(Ur.ReactSelect,{placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:p,value:(0,Yi.find)(["value",t.newsletter_id],p),onChange:t=>{a({newsletter_id:t.value,link_ids:[]},e)},automationId:"segment-email"}),(0,h.jsxs)(lt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),c&&(0,h.jsx)("span",{children:m.U.I18n.t("loadingDynamicSegmentItems")}),!c&&$r(t.newsletter_id)&&(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,automationId:"segment-link-select",placeholder:m.U.I18n.t("allLinksPlaceholder"),options:l.length?l:[{value:0,label:m.U.I18n.t("noLinksHint"),isDisabled:!0}],value:(0,Yi.filter)((e=>!!t.link_ids&&-1!==t.link_ids.indexOf(e.value)),l),onChange:t=>{a({link_ids:(t||[]).map((e=>e.value))},e)}})]})},[Dr._R.OPENED]:Mr,[Dr._R.WAS_SENT]:Mr,[Dr._R.MACHINE_OPENED]:Mr,[Dr._R.CLICKED_ANY]:null,[Dr._R.NUMBER_RECEIVED]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,h.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{emails}"===a?(0,h.jsx)(it.p,{type:"number",value:t.emails||"","data-automation-id":"segment-number-emails-received",onChange:t=>{i("emails",e,t)},min:"0",placeholder:(0,Ae.__)("emails","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,h.jsx)("div",{children:a},"emails"):null,(0,Ae.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]});var s},[Dr._R.NUMBER_OF_CLICKS]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,h.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{clicks}"===a?(0,h.jsx)(it.p,{type:"number",value:t.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:t=>{i("clicks",e,t)},min:"0",placeholder:(0,Ae.__)("clicks","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,h.jsx)("div",{children:a},"clicks"):null,(0,Ae.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]});var s}};var Vr=a(89011);function Gr(e,t){const a=t?.additionalDigits??2,i=function(e){const t={},a=e.split(Yr.dateTimeDelimiter);let i;if(a.length>2)return t;if(/:/.test(a[0])?i=a[0]:(t.date=a[0],i=a[1],Yr.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Yr.timeZoneDelimiter)[0],i=e.substr(t.date.length,e.length))),i){const e=Yr.timezone.exec(i);e?(t.time=i.replace(e[1],""),t.timezone=e[1]):t.time=i}return t}(e);let s;if(i.date){const e=function(e,t){const a=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(a);if(!i)return{year:NaN,restDateString:""};const s=i[1]?parseInt(i[1]):null,n=i[2]?parseInt(i[2]):null;return{year:null===n?s:100*n,restDateString:e.slice((i[1]||i[2]).length)}}(i.date,a);s=function(e,t){if(null===t)return new Date(NaN);const a=e.match(Kr);if(!a)return new Date(NaN);const i=!!a[4],s=Zr(a[1]),n=Zr(a[2])-1,r=Zr(a[3]),o=Zr(a[4]),l=Zr(a[5])-1;if(i)return function(e,t,a){return t>=1&&t<=53&&a>=0&&a<=6}(0,o,l)?function(e,t,a){const i=new Date(0);i.setUTCFullYear(e,0,4);const s=7*(t-1)+a+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+s),i}(t,o,l):new Date(NaN);{const e=new Date(0);return function(e,t,a){return t>=0&&t<=11&&a>=1&&a<=(eo[t]||(to(e)?29:28))}(t,n,r)&&function(e,t){return t>=1&&t<=(to(e)?366:365)}(t,s)?(e.setUTCFullYear(t,n,Math.max(s,r)),e):new Date(NaN)}}(e.restDateString,e.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const n=s.getTime();let r,o=0;if(i.time&&(o=function(e){const t=e.match(Jr);if(!t)return NaN;const a=Xr(t[1]),i=Xr(t[2]),s=Xr(t[3]);return function(e,t,a){return 24===e?0===t&&0===a:a>=0&&a<60&&t>=0&&t<60&&e>=0&&e<25}(a,i,s)?a*Vr.s0+i*Vr.Cg+1e3*s:NaN}(i.time),isNaN(o)))return new Date(NaN);if(!i.timezone){const e=new Date(n+o),t=new Date(0);return t.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),t.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),t}return r=function(e){if("Z"===e)return 0;const t=e.match(Qr);if(!t)return 0;const a="+"===t[1]?-1:1,i=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,s)?a*(i*Vr.s0+s*Vr.Cg):NaN}(i.timezone),isNaN(r)?new Date(NaN):new Date(n+o+r)}const Yr={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Kr=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Jr=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Qr=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Zr(e){return e?parseInt(e):1}function Xr(e){return e&&parseFloat(e.replace(",","."))||0}const eo=[31,null,31,30,31,30,31,31,30,31,30,31];function to(e){return e%400==0||e%4==0&&e%100!=0}var ao=a(47195);let io=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 so=[io.BEFORE,io.AFTER,io.ON,io.ON_OR_AFTER,io.ON_OR_BEFORE,io.NOT_ON,io.IN_THE_LAST,io.NOT_IN_THE_LAST],no=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return m.U.Date.format(e,{format:"Y-m-d"})}},ro=e=>{if(!e)return;const t=Gr(e);return(0,ao.f)(t)?t:void 0};function oo({filterIndex:e,defaultOperator:t}){const a=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{so.includes(a.operator)||i({operator:t},e),a.operator!==io.BEFORE&&a.operator!==io.AFTER&&a.operator!==io.ON&&a.operator!==io.ON_OR_AFTER&&a.operator!==io.ON_OR_BEFORE&&a.operator!==io.NOT_ON||void 0!==ro(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||i({value:no(new Date)},e),a.operator!==io.IN_THE_LAST&&a.operator!==io.NOT_IN_THE_LAST||"string"!=typeof a.value||/^\d*$/.exec(a.value)||i({value:""},e)}),[i,a,e,t]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:a.operator,isMinWidth:!0,onChange:t=>{s("operator",e,t)},children:[(0,h.jsx)("option",{value:io.BEFORE,children:m.U.I18n.t("before")}),(0,h.jsx)("option",{value:io.ON_OR_BEFORE,children:m.U.I18n.t("onOrBefore")}),(0,h.jsx)("option",{value:io.ON,children:m.U.I18n.t("on")}),(0,h.jsx)("option",{value:io.NOT_ON,children:m.U.I18n.t("notOn")}),(0,h.jsx)("option",{value:io.ON_OR_AFTER,children:m.U.I18n.t("onOrAfter")}),(0,h.jsx)("option",{value:io.AFTER,children:m.U.I18n.t("after")}),(0,h.jsx)("option",{value:io.IN_THE_LAST,children:m.U.I18n.t("inTheLast")}),(0,h.jsx)("option",{value:io.NOT_IN_THE_LAST,children:m.U.I18n.t("notInTheLast")})]},"select"),(a.operator===io.BEFORE||a.operator===io.AFTER||a.operator===io.ON||a.operator===io.ON_OR_AFTER||a.operator===io.ON_OR_BEFORE||a.operator===io.NOT_ON)&&(0,h.jsx)(Oa.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value:no(t)},e)},selected:a.value?ro(a.value):void 0}),(a.operator===io.IN_THE_LAST||a.operator===io.NOT_IN_THE_LAST)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(it.p,{className:"mailpoet-segments-input-small",type:"number",value:a.value||"",onChange:t=>{s("value",e,t)},min:"1",placeholder:m.U.I18n.t("daysPlaceholder")},"input"),(0,h.jsx)("span",{children:m.U.I18n.t("daysPlaceholder")})]})]})}function lo(e){return!(!e.operator||!e.value)&&([io.BEFORE,io.AFTER,io.ON,io.NOT_ON,io.ON_OR_BEFORE,io.ON_OR_AFTER].includes(e.operator)?/^\d+-\d+-\d+$/.test(e.value):!![io.IN_THE_LAST,io.NOT_IN_THE_LAST].includes(e.operator)&&(/^\d+$/.test(e.value)&&Number(e.value)>0))}function co(e){return function(t){return(0,h.jsx)(oo,{...t,defaultOperator:e})}}const mo=co(io.BEFORE),uo=co(io.IN_THE_LAST);var po=a(22832);function ho({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{void 0===t.number_of_orders_type&&a({number_of_orders_type:"="},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{value:t.number_of_orders_type,onChange:t=>{i("number_of_orders_type",e,t)},automationId:"select-number-of-orders-type",children:[(0,h.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,h.jsx)(o.Input,{"data-automation-id":"input-number-of-orders-count",type:"number",min:0,value:t.number_of_orders_count||"",placeholder:m.U.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("number_of_orders_count",e,t)}}),(0,h.jsx)("div",{children:m.U.I18n.t("wooNumberOfOrdersOrders")})]}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})}const go=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function _o(e){return!!go.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function fo({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{go.includes(t.operator)||i({operator:"is",value:""},e)}),[i,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{automationId:"subscriber-text-field-select",value:t.operator,isMinWidth:!0,onChange:t=>{a("operator",e,t)},children:[(0,h.jsx)("option",{value:"is",children:m.U.I18n.t("is")}),(0,h.jsx)("option",{value:"isNot",children:m.U.I18n.t("isNot")}),(0,h.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,h.jsx)("option",{value:"notContains",children:m.U.I18n.t("notContains")}),(0,h.jsx)("option",{value:"startsWith",children:m.U.I18n.t("startsWith")}),(0,h.jsx)("option",{value:"notStartsWith",children:m.U.I18n.t("notStartsWith")}),(0,h.jsx)("option",{value:"endsWith",children:m.U.I18n.t("endsWith")}),(0,h.jsx)("option",{value:"notEndsWith",children:m.U.I18n.t("notEndsWith")})]},"select"),(0,h.jsx)(it.p,{className:"mailpoet-segments-input-medium","data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}const xo={[po.Ag.CUSTOMER_IN_COUNTRY]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getWooCommerceCountries()),[]).map((e=>({value:e.code,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-country",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-country"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectWooCountry"),options:i,value:(0,Yi.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")]})},[po.Ag.CUSTOMER_IN_CITY]:fo,[po.Ag.CUSTOMER_IN_POSTAL_CODE]:fo,[po.Ag.NUMBER_OF_ORDERS]:ho,[po.Ag.NUMBER_OF_ORDERS_WITH_COUPON]:ho,[po.Ag.NUMBER_OF_REVIEWS]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{(0,Br.J)(t.count_type,Dr.YR)||a({count_type:Dr.YR.EQUALS},e),(0,Br.J)(t.rating,Dr.Un)||a({rating:Dr.Un.ANY},e),(0,Br.J)(t.timeframe,Dr.VE)||a({timeframe:Dr.VE.IN_THE_LAST},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Select,{value:t.rating,isMinWidth:!0,onChange:t=>{i("rating",e,t)},children:[(0,h.jsx)("option",{value:Dr.Un.ANY,children:m.U.I18n.t("wooAnyStarRating")}),(0,h.jsx)("option",{value:Dr.Un.ONE,children:m.U.I18n.t("wooOneStarRating")}),(0,h.jsx)("option",{value:Dr.Un.TWO,children:m.U.I18n.t("wooTwoStarRating")}),(0,h.jsx)("option",{value:Dr.Un.THREE,children:m.U.I18n.t("wooThreeStarRating")}),(0,h.jsx)("option",{value:Dr.Un.FOUR,children:m.U.I18n.t("wooFourStarRating")}),(0,h.jsx)("option",{value:Dr.Un.FIVE,children:m.U.I18n.t("wooFiveStarRating")})]},"rating-select"),(0,h.jsxs)(o.Select,{value:t.count_type,isMinWidth:!0,onChange:t=>{i("count_type",e,t)},automationId:"select-number-of-reviews-type",children:[(0,h.jsx)("option",{value:Dr.YR.EQUALS,children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:Dr.YR.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:Dr.YR.MORE_THAN,children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:Dr.YR.LESS_THAN,children:m.U.I18n.t("lessThan")})]},"select"),(0,h.jsx)(o.Input,{className:"mailpoet-segments-input-small","data-automation-id":"input-number-of-reviews-count",type:"number",min:0,value:t.count||"",placeholder:m.U.I18n.t("wooNumberOfOrdersCount"),onChange:t=>{i("count",e,t)}}),(0,h.jsx)("div",{children:m.U.I18n.t("wooNumberOfReviewsReviews")}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.PURCHASE_DATE]:mo,[po.Ag.PURCHASED_PRODUCT]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedProduct"),options:i,value:(0,Yi.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")]})},[po.Ag.PURCHASED_CATEGORY]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getProductCategories()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedCategory"),options:i,value:(0,Yi.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")]})},[po.Ag.PURCHASED_WITH_ATTRIBUTE]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getProductAttributes()),[]),s=(0,r.useMemo)((()=>Object.values(i).filter((e=>e.terms.length>0)).map((e=>({value:e.taxonomy,label:e.label})))),[i]),n=(0,b.A)((e=>e(Fr.Hz).getLocalProductAttributes()),[]),o=(0,r.useMemo)((()=>Object.values(n).filter((e=>e.values.length>0)).map((e=>({value:`${e.name}@local`,label:e.name})))),[n]),l=(0,r.useMemo)((()=>Object.values(o).map((e=>e.value))),[o]),d=(0,r.useMemo)((()=>[...s,...o]),[s,o]),c=(0,r.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,r.useEffect)((()=>{t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]);const m=(0,r.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,r.useMemo)((()=>"local"===t.attribute_type?(0,Yi.filter)((e=>{if(t.attribute_local_name)return`${t.attribute_local_name}@local`===e.value}),o):(0,Yi.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,o,s]),p=(0,r.useMemo)((()=>(0,Yi.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,r.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,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:(0,Ae.__)("any of","mailpoet")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:(0,Ae.__)("all of","mailpoet")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:(0,Ae.__)("none of","mailpoet")})]},"select-operator"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",placeholder:(0,Ae.__)("Search attributes","mailpoet"),options:d,value:u,onChange:m},"select-segment-product-attribute"),c.length>0&&(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:(0,Ae.__)("Search attributes terms","mailpoet"),options:c,value:p,onChange:g},"select-segment-product-attribute-terms")]})},[po.Ag.PURCHASED_TAG]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getProductTags()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:(0,Ae.__)("Search tags","mailpoet"),options:i,value:(0,Yi.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")]})},[po.Ag.SINGLE_ORDER_VALUE]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getWooCommerceCurrencySymbol()),[]);return(0,r.useEffect)((()=>{void 0===t.single_order_value_type&&a({single_order_value_type:">"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{value:t.single_order_value_type,onChange:t=>{i("single_order_value_type",e,t)},automationId:"select-single-order-value-type",children:[(0,h.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,h.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,h.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,h.jsx)(o.Input,{"data-automation-id":"input-single-order-value-amount",type:"number",min:0,step:.01,value:t.single_order_value_amount||"",placeholder:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("single_order_value_amount",e,t)}}),(0,h.jsx)("div",{children:s})]}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.TOTAL_SPENT]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getWooCommerceCurrencySymbol()),[]);return(0,r.useEffect)((()=>{void 0===t.total_spent_type&&a({total_spent_type:">"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{value:t.total_spent_type,onChange:t=>{i("total_spent_type",e,t)},automationId:"select-total-spent-type",children:[(0,h.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,h.jsx)(o.Input,{"data-automation-id":"input-total-spent-amount",type:"number",min:0,step:.01,value:t.total_spent_amount||"",placeholder:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("total_spent_amount",e,t)}}),(0,h.jsx)("div",{children:s})]}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.AVERAGE_SPENT]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getWooCommerceCurrencySymbol()),[]);return(0,r.useEffect)((()=>{[">",">=","=","!=","<=","<"].includes(t.average_spent_type)||a({average_spent_type:">"},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Select,{value:t.average_spent_type,isMinWidth:!0,onChange:t=>{i("average_spent_type",e,t)},automationId:"select-average-spent-type",children:[(0,h.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,h.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,h.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,h.jsx)(o.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:m.U.I18n.t("wooSpentAmount"),onChange:t=>{i("average_spent_amount",e,t)}}),(0,h.jsx)("div",{children:s}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.USED_COUPON_CODE]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),[i,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,p]=(0,r.useState)(1),[g,_]=(0,r.useState)(!0),[f,x]=(0,r.useState)(""),[v,j]=(0,r.useState)([]),y=(0,r.useCallback)(((e,a,i,s)=>{s&&(e||c(!0),m.U.Ajax.post({api_version:m.U.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,Yi.uniqBy)((e=>e.value),[...e,...s]))),p(n)),e||c(!1)})).fail((e=>{j(e.errors)})))}),[t.coupon_code_ids]),w=(0,Yi.debounce)(300,(e=>{const t=f;x(e),!d&&(g&&e||t&&!e)&&(p(1),y(!1,1,e,g))}));return(0,r.useEffect)((()=>{i||(y(!0,u,f,g),s(!0))}),[i,u,f,y,g]),(0,r.useEffect)((()=>{Array.isArray(t.coupon_code_ids)||a({coupon_code_ids:[]},e),(0,Br.J)(t.operator,Dr.dP)||a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[v.length>0&&(0,h.jsx)(pa,{errors:v}),i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-coupon-code",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,h.jsx)(Ur.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:d,placeholder:m.U.I18n.t("selectWooCouponCodes"),options:n,value:(0,Yi.filter)((e=>{if(t.coupon_code_ids)return-1!==t.coupon_code_ids.indexOf(e.value)}),n),onInputChange:e=>{w(e)},onChange:t=>{a({coupon_code_ids:(t||[]).map((e=>e.value))},e)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!d&&g&&y(!1,u,f,g)}},"select-coupon-codes")]}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]}):(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,Ae.__)("Loading coupon codes...","mailpoet")})]})},[po.Ag.USED_PAYMENT_METHOD]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getPaymentMethods()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-payment-methods",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,h.jsx)(Ur.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooPaymentMethods"),options:i,value:(0,Yi.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,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.USED_SHIPPING_METHOD]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getShippingMethods()),[]).map((e=>({value:e.instanceId,label:e.name})));return(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-shipping-methods",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,h.jsx)(Ur.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooShippingMethods"),options:i,value:(0,Yi.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,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(qr,{filterIndex:e})})]})},[po.Ag.FIRST_ORDER]:mo};function bo({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);(0,r.useEffect)((()=>{t.action===Dr.gw.WORDPRESS_ROLE&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]);const s=(0,b.A)((e=>e(Fr.Hz).getWordpressRoles()),[]).map((e=>({value:e.role_id,label:e.role_name})));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsxs)(lt.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select")}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:m.U.I18n.t("selectUserRolePlaceholder"),options:s,value:(0,Yi.filter)((e=>{if(t.wordpressRole)return-1!==t.wordpressRole.indexOf(e.value)}),s),onChange:t=>{a({wordpressRole:(0,Yi.map)("value",t)},e)}})})]})}let vo=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 jo=[vo.HIGHER_THAN,vo.LOWER_THAN,vo.EQUALS,vo.NOT_EQUALS,vo.UNKNOWN,vo.NOT_UNKNOWN];function yo(e){return!!(0,Dr.uA)(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 wo({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{void 0===t.operator&&i({operator:"equals",value:""},e)}),[i,t,e]),(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,h.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,h.jsx)("option",{value:"not_equals",children:m.U.I18n.t("isNot")}),(0,h.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,h.jsx)("option",{value:"not_contains",children:m.U.I18n.t("notContains")}),(0,h.jsx)("option",{value:"more_than",children:m.U.I18n.t("moreThan")}),(0,h.jsx)("option",{value:"less_than",children:m.U.I18n.t("lessThan")}),(0,h.jsx)("option",{value:"is_blank",children:m.U.I18n.t("isBlank")}),(0,h.jsx)("option",{value:"is_not_blank",children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,Dr.uA)(t.operator)&&(0,h.jsx)(it.p,{"data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}function So(e){return!!(0,Dr.uA)(e.operator)||"string"==typeof e.value&&e.value.length>0}function No({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getCustomFieldsList()),[]),n=(0,Yi.find)({id:Number(t.custom_field_id)},s);if(!n)return null;const r=n.params;if(!r||!Array.isArray(r.values))return null;const o=r.values.map((e=>({value:e.value,label:e.value}))),l=o.find((e=>e.value===t.value))?.label;return(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:m.U.I18n.t("isBlank")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,Dr.uA)(t.operator)&&(0,h.jsx)(Ur.ReactSelect,{dimension:"small",placeholder:m.U.I18n.t("selectValue"),options:o,value:t.value&&l?{value:t.value,label:l}:null,onChange:t=>{a({value:t.value},e)},automationId:"segment-wordpress-role"})]})}var Io=a(85963);var Uo=a(76592);function Co(e){return!!(0,Dr.uA)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const ko=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return(0,Uo.GP)(e,"yyyy-MM-dd 00:00:00")}},Ao=e=>{const t=Gr(e);if((0,ao.f)(t))return t},To={month:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)((()=>{Co(t)||e((0,Yi.assign)(t,{value:"2017-01-01 00:00:00"}),a),void 0===t.operator&&e((0,Yi.assign)(t,{operator:"equals"}),a)}),[e,t,a]),(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:i=>{e((0,Yi.assign)(t,{operator:i.target.value}),a)},children:[(0,h.jsx)("option",{value:"equals",children:(0,Ae.__)("is","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:(0,Ae.__)("is blank","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:(0,Ae.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Dr.uA)(t.operator)&&(0,h.jsxs)(lt.Select,{value:t.value,onChange:i=>{e((0,Yi.assign)(t,{value:i.target.value}),a)},children:[(0,h.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,Ae.__)("january","mailpoet")}),(0,h.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,Ae.__)("february","mailpoet")}),(0,h.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,Ae.__)("march","mailpoet")}),(0,h.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,Ae.__)("april","mailpoet")}),(0,h.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,Ae.__)("may","mailpoet")}),(0,h.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,Ae.__)("june","mailpoet")}),(0,h.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,Ae.__)("july","mailpoet")}),(0,h.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,Ae.__)("august","mailpoet")}),(0,h.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,Ae.__)("september","mailpoet")}),(0,h.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,Ae.__)("october","mailpoet")}),(0,h.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,Ae.__)("november","mailpoet")}),(0,h.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,Ae.__)("december","mailpoet")})]},"select")]})},year:function({onChange:e,item:t,filterIndex:a}){const i=(s=new Date,(0,Io.a)(s).getFullYear());var s;return(0,r.useEffect)((()=>{Co(t)||e((0,Yi.assign)(t,{value:`${i}-01-01 00:00:00`,operator:"equals"}),a)}),[i,e,t,a]),(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:i=>{e((0,Yi.assign)(t,{operator:i.target.value}),a)},children:[(0,h.jsx)("option",{value:"equals",children:(0,Ae.__)("is","mailpoet")}),(0,h.jsx)("option",{value:"before",children:(0,Ae._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,h.jsx)("option",{value:"after",children:(0,Ae._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:(0,Ae.__)("is blank","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:(0,Ae.__)("is not blank","mailpoet")})]},"select-operator"),(0,h.jsx)(lt.Select,{value:t.value,onChange:i=>{e((0,Yi.assign)(t,{value:i.target.value}),a)},children:(0,Yi.range)(0,100).map((e=>(0,h.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,r.useEffect)((()=>{void 0!==t.value&&""!==t.value||e((0,Yi.assign)(t,{value:`${(0,Uo.GP)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[e,t,a]),(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:i=>{e((0,Yi.assign)(t,{operator:i.target.value}),a)},children:[(0,h.jsx)("option",{value:"equals",children:(0,Ae.__)("is","mailpoet")}),(0,h.jsx)("option",{value:"before",children:(0,Ae._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,h.jsx)("option",{value:"after",children:(0,Ae._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:(0,Ae.__)("is blank","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:(0,Ae.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Dr.uA)(t.operator)&&(0,h.jsx)(Oa.t,{onChange:i=>e((0,Yi.assign)(t,{value:ko(i)}),a),selected:t.value?Ao(t.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)((()=>{Co(t)||e((0,Yi.assign)(t,{value:`${(0,Uo.GP)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)}),[e,t,a]),(0,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:i=>{e((0,Yi.assign)(t,{operator:i.target.value}),a)},children:[(0,h.jsx)("option",{value:"equals",children:(0,Ae.__)("is","mailpoet")}),(0,h.jsx)("option",{value:"before",children:(0,Ae._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,h.jsx)("option",{value:"after",children:(0,Ae._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:(0,Ae.__)("is blank","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:(0,Ae.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Dr.uA)(t.operator)&&(0,h.jsx)(Oa.t,{dateFormat:"MMM d, yyyy",onChange:i=>e((0,Yi.assign)(t,{value:ko(i)}),a),selected:t.value?Ao(t.value):void 0})]})}};var Eo=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(Eo||{});const Ro={[Eo.TEXT]:yo,[Eo.TEXTAREA]:yo,[Eo.RADIO]:So,[Eo.SELECT]:So,[Eo.CHECKBOX]:function(e){return!!(0,Dr.uA)(e.operator)||["1","0"].includes(e.value)},[Eo.DATE]:Co},Do={[Eo.TEXT]:wo,[Eo.TEXTAREA]:wo,[Eo.RADIO]:No,[Eo.SELECT]:No,[Eo.CHECKBOX]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,me.A)(Fr.Hz);return(0,r.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,h.jsxs)(Ra.Grid.CenteredRow,{children:[(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,h.jsx)("option",{value:"equals",children:(0,Ae.__)("is","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.BLANK,children:(0,Ae.__)("is blank","mailpoet")}),(0,h.jsx)("option",{value:Dr.FI.NOT_BLANK,children:(0,Ae.__)("is not blank","mailpoet")})]},"select-operator"),!(0,Dr.uA)(t.operator)&&(0,h.jsxs)(lt.Select,{value:t.value,onChange:t=>a("value",e,t),children:[(0,h.jsx)("option",{value:"1",children:(0,Ae.__)("checked","mailpoet")}),(0,h.jsx)("option",{value:"0",children:(0,Ae.__)("unchecked","mailpoet")})]},"select")]})},[Eo.DATE]:function({customField:e,filterIndex:t}){const a=(0,b.A)((e=>e(Fr.Hz).getSegmentFilter(t)),[t]),{updateSegmentFilter:i}=(0,me.A)(Fr.Hz);(0,r.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=To[e.params.date_type];return s?(0,h.jsx)(s,{item:a,onChange:i,filterIndex:t}):null}};function Fo(){return(0,h.jsx)(Zt,{message:(()=>{const e=m.U.I18n.t("premiumFeatureMultipleConditions");return(0,h.jsx)("p",{children:Re()(e,/\[link](.*?)\[\/link]/g,(e=>(0,h.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e)))})})(),actionButton:(0,h.jsx)(Te.$,{href:m.U.MailPoetComUrlFactory.getPurchasePlanUrl(m.U.subscribersCount,m.U.currentWpUserEmail,null,{utm_medium:"segments",utm_campaign:"signup"}),target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("premiumBannerCtaFree")})})}const Oo={[Dr.gw.WORDPRESS_ROLE]:bo,[Dr.gw.SUBSCRIBER_SCORE]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz);return(0,r.useEffect)((()=>{jo.includes(t.operator)||a({operator:vo.HIGHER_THAN},e),t.operator!==vo.HIGHER_THAN&&t.operator!==vo.LOWER_THAN&&t.operator!==vo.EQUALS&&t.operator!==vo.NOT_EQUALS||void 0!==t.value||a({value:""},e),t.operator!==vo.UNKNOWN&&t.operator!==vo.NOT_UNKNOWN||a({value:null},e)}),[a,t,e]),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,h.jsxs)(lt.Select,{value:t.operator,automationId:"segment-subscriber-score-operator",onChange:t=>{i("operator",e,t)},children:[(0,h.jsx)("option",{value:vo.HIGHER_THAN,children:m.U.I18n.t("higherThan")}),(0,h.jsx)("option",{value:vo.LOWER_THAN,children:m.U.I18n.t("lowerThan")}),(0,h.jsx)("option",{value:vo.EQUALS,children:m.U.I18n.t("equals")}),(0,h.jsx)("option",{value:vo.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,h.jsx)("option",{value:vo.UNKNOWN,children:m.U.I18n.t("unknown")}),(0,h.jsx)("option",{value:vo.NOT_UNKNOWN,children:m.U.I18n.t("notUnknown")})]},"select"):"{score}"===a?(t.operator===vo.HIGHER_THAN||t.operator===vo.LOWER_THAN||t.operator===vo.EQUALS||t.operator===vo.NOT_EQUALS)&&(0,h.jsx)(it.p,{type:"number",value:t.value||"","data-automation-id":"segment-subscriber-score-value",onChange:t=>{i("value",e,t)},min:"0",placeholder:m.U.I18n.t("subscriberScorePlaceholder")},"input"):"string"==typeof a&&a.trim().length>0?t.operator!==vo.UNKNOWN&&t.operator!==vo.NOT_UNKNOWN&&(0,h.jsx)("div",{children:a},"score"):null,m.U.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(s))});var s},[Dr.gw.SUBSCRIBED_DATE]:mo,[Dr.gw.MAILPOET_CUSTOM_FIELD]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getCustomFieldsList()),[]),s=(0,Yi.find)({id:Number(t.custom_field_id)},i),n=i.map((e=>({value:e.id.toString(),label:e.name}))),r=Do[t.custom_field_type];return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{children:(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectCustomFieldPlaceholder"),options:n,automationId:"select-custom-field",value:(0,Yi.find)((e=>{if(t.custom_field_id)return t.custom_field_id===e.value}),n),onChange:t=>{const s=(0,Yi.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,h.jsx)("div",{children:r&&(0,h.jsx)(r,{customField:s,filterIndex:e})})]})},[Dr.gw.SUBSCRIBED_TO_LIST]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=(0,b.A)((e=>e(Fr.Hz).getStaticSegmentsList()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,me.A)(Fr.Hz);(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&i({operator:Dr.dP.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchLists"),options:n,value:(0,Yi.filter)((e=>{if(!t.segments)return;const a=e.value;return-1!==t.segments.indexOf(a)}),n),onChange:t=>{i({segments:(0,Yi.map)((0,Yi.parseInt)(10),(0,Yi.map)("value",t))},e)}})]})},[Dr.gw.SUBSCRIBER_TAG]:function({filterIndex:e}){return Pt.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,h.jsx)(Fo,{}),e)},[Dr.gw.SUBSCRIBER_FIRST_NAME]:fo,[Dr.gw.SUBSCRIBER_LAST_NAME]:fo,[Dr.gw.SUBSCRIBER_EMAIL]:fo,[Dr.gw.SUBSCRIBED_VIA_FORM]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=(0,b.A)((e=>e(Fr.Hz).getSignupForms()),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,me.A)(Fr.Hz);(0,r.useEffect)((()=>{t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.NONE&&i({operator:Dr.dP.ANY},e)}),[i,t,e]);const n=a.map((e=>({value:e.id,label:e.name})));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(lt.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,h.jsx)(Ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.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)}})]})},[Dr.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:uo,[Dr.gw.SUBSCRIBER_LAST_PURCHASE_DATE]:uo,[Dr.gw.SUBSCRIBER_LAST_OPEN_DATE]:uo,[Dr.gw.SUBSCRIBER_LAST_CLICK_DATE]:uo,[Dr.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:uo,[Dr.gw.SUBSCRIBER_LAST_SENDING_DATE]:uo},Po={[Dr.dx.Automations]:function(e){return!!Object.values(Or.g).some((t=>t===e.action))&&(e.action!==Or.g.ENTERED_AUTOMATION||function(e){return(e.operator===Dr.dP.ANY||e.operator===Dr.dP.NONE||e.operator===Dr.dP.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[Dr.dx.Email]:function(e){return!!Object.values(Dr._R).some((t=>t===e.action))&&(e.action===Dr._R.CLICKED_ANY||(e.action===Dr._R.CLICKED?!!e.newsletter_id:[Dr._R.OPENED,Dr._R.MACHINE_OPENED,Dr._R.WAS_SENT].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[Dr._R.OPENS_ABSOLUTE_COUNT,Dr._R.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?Hr(e)&&!!e.opens&&!!e.operator:Dr._R.NUMBER_RECEIVED===e.action?Hr(e)&&!!e.emails&&!!e.operator:e.action===Dr._R.NUMBER_OF_CLICKS&&Hr(e)&&!!e.clicks&&!!e.operator))},[Dr.dx.WooCommerce]:function(e){return!!Object.values(po.Ag).some((t=>t===e.action))&&(e.action===po.Ag.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator)}(e):e.action===po.Ag.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator)}(e):e.action===po.Ag.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):[po.Ag.NUMBER_OF_ORDERS,po.Ag.NUMBER_OF_ORDERS_WITH_COUPON].includes(e.action)?function(e){return!(!e.number_of_orders_count||!Hr(e)||!e.number_of_orders_type)}(e):e.action===po.Ag.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!Hr(e)||!e.total_spent_type)}(e):e.action===po.Ag.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!Hr(e)||!e.single_order_value_type)}(e):e.action===po.Ag.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!Hr(e))}(e):e.action===po.Ag.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!Hr(e))}(e):e.action===po.Ag.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!Hr(e))}(e):e.action===po.Ag.PURCHASE_DATE?lo(e):e.action===po.Ag.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&Hr(e))}(e):e.action===po.Ag.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,Br.J)(e.operator,Dr.dP)||!Hr(e))}(e):e.action===po.Ag.FIRST_ORDER?lo(e):e.action===po.Ag.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):[po.Ag.CUSTOMER_IN_POSTAL_CODE,po.Ag.CUSTOMER_IN_CITY].includes(e.action)?_o(e):e.action!==po.Ag.PURCHASED_TAG||function(e){return!(void 0===e.tag_ids||0===e.tag_ids.length||!e.operator)}(e))},[Dr.dx.WordPressRole]:function(e){return e.action&&e.action!==Dr.gw.WORDPRESS_ROLE?e.action===Dr.gw.MAILPOET_CUSTOM_FIELD?function(e){const t=Ro[e.custom_field_type];return!!t&&t(e)}(e):e.action===Dr.gw.SUBSCRIBER_SCORE?function(e){if(e.operator===vo.HIGHER_THAN||e.operator===vo.LOWER_THAN||e.operator===vo.EQUALS||e.operator===vo.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===vo.UNKNOWN||e.operator===vo.NOT_UNKNOWN}(e):e.action===Dr.gw.SUBSCRIBED_TO_LIST?function(e){return(e.operator===Dr.dP.ANY||e.operator===Dr.dP.ALL||e.operator===Dr.dP.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===Dr.gw.SUBSCRIBER_TAG?function(e){return Pt.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[Dr.gw.SUBSCRIBER_FIRST_NAME,Dr.gw.SUBSCRIBER_LAST_NAME,Dr.gw.SUBSCRIBER_EMAIL].includes(e.action)?_o(e):[Dr.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE,Dr.gw.SUBSCRIBER_LAST_PURCHASE_DATE,Dr.gw.SUBSCRIBER_LAST_OPEN_DATE,Dr.gw.SUBSCRIBER_LAST_CLICK_DATE,Dr.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE,Dr.gw.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?lo(e):e.action===Dr.gw.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===Dr.dP.ANY||e.operator===Dr.dP.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(io).includes(e.operator)&&lo(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[Dr.dx.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==po.HM.MEMBER_OF||!t},[Dr.dx.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==po.IC.ACTIVE_SUBSCRIPTIONS||!t}};function Lo(e){return!(e.length<1)&&0===e.map((e=>void 0!==Po[e.segmentType]&&Po[e.segmentType](e))).filter((e=>!1===e)).length}let Mo,$o;function Bo(){const e=(0,b.A)((e=>e(Fr.Hz).getSegment()),[]),t=(0,b.A)((e=>e(Fr.Hz).getSubscriberCount()),[]),{updateSubscriberCount:a}=(0,me.A)(Fr.Hz),i=JSON.stringify(e),s=(0,r.useRef)(1),n=(0,r.useRef)(null),o=(0,r.useRef)(!1),l=(0,r.useRef)((0,ka.debounce)((function e(t){if(o.current)return void(n.current=t);n.current=null,s.current+=1;const i=s.current;o.current=!0,function(e){const t={filters:e.filters,filters_connect:e.filters_connect};return Aa().isEqual(t,Mo)?Promise.resolve($o):(Mo={filters:[...e.filters],filters_connect:e.filters_connect},m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"dynamic_segments",action:"getCount",data:e,timeout:2e4}).then((e=>{const{data:t}=e;return $o={count:t.count,errors:void 0},$o})))}(t).then((t=>{if(o.current=!1,n.current)return void e(n.current);if(i!==s.current)return;const r={loading:!1};t&&(r.count=t.count,r.errors=t.errors),a(r)}),(e=>{o.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,r.useEffect)((()=>{Lo(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,h.jsx)("div",{className:"mailpoet-form-field",children:(0,h.jsxs)("span",{className:"mailpoet-form-error-message",children:[m.U.I18n.t("dynamicSegmentSizeCalculatingTimeout")," ",(0,h.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:m.U.I18n.t("learnMore")})]})}):t.loading||void 0!==t.count?t.loading?(0,h.jsx)("div",{className:"mailpoet-form-field",children:(0,h.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSizeIsCalculated")})}):(0,h.jsx)("div",{className:"mailpoet-form-field",children:(0,h.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSize").replace("%1$d",t.count.toLocaleString())})}):(0,h.jsx)("span",{})}const qo={[Dr.dx.Automations]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=Lr[t.action];return a?(0,h.jsx)(a,{filterIndex:e}):null},[Dr.dx.Email]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=zr[t.action];return a?(0,h.jsx)(a,{filterIndex:e}):null},[Dr.dx.WooCommerce]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),a=xo[t.action];return a?(0,h.jsx)(a,{filterIndex:e}):null},[Dr.dx.WordPressRole]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]);let a;return a=t.action?Oo[t.action]:bo,a?(0,h.jsx)(a,{filterIndex:e}):null},[Dr.dx.WooCommerceMembership]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getMembershipPlans()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.action===po.HM.MEMBER_OF&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooMembership"),options:s,value:(0,Yi.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")})]})},[Dr.dx.WooCommerceSubscription]:function({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,me.A)(Fr.Hz),s=(0,b.A)((e=>e(Fr.Hz).getSubscriptionProducts()),[]).map((e=>({value:e.id,label:e.name})));return(0,r.useEffect)((()=>{t.action===po.IC.ACTIVE_SUBSCRIPTIONS&&t.operator!==Dr.dP.ANY&&t.operator!==Dr.dP.ALL&&t.operator!==Dr.dP.NONE&&a({operator:Dr.dP.ANY},e)}),[a,t,e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsxs)(lt.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,h.jsx)("option",{value:Dr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,h.jsx)("option",{value:Dr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,h.jsx)("option",{value:Dr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,h.jsx)(Ra.Grid.CenteredRow,{children:(0,h.jsx)(Ur.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooSubscription"),options:s,value:(0,Yi.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 Ho({filterIndex:e}){const t=(0,b.A)((t=>t(Fr.Hz).getSegmentFilter(e)),[e]);if(void 0===t||void 0===qo[t.segmentType])return null;const a=qo[t.segmentType];return(0,h.jsx)(a,{filterIndex:e})}function Wo(){const e=(0,b.A)((e=>e(Fr.Hz).getSegment()),[]),t=[Dr._R.OPENED,Dr._R.OPENS_ABSOLUTE_COUNT,Dr._R.MACHINE_OPENED,Dr._R.MACHINE_OPENS_ABSOLUTE_COUNT];let a=!1;return e.filters.forEach((e=>{t.includes(e.action)&&(a=!0)})),a?(0,h.jsx)("div",{className:"mailpoet-form-field",children:(0,h.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("privacyProtectionNotice")})}):(0,h.jsx)("span",{})}const zo=Pt.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",(()=>null)),Vo=Pt.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",(()=>null)),Go=Pt.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",(()=>(0,h.jsx)("div",{className:"mailpoet-gap"})));function Yo({isNewSegment:e,newsletterId:t}){const{segment:a,segmentFilters:i,subscriberCount:s,filterRows:n,errors:o}=(0,b.A)((e=>{const t=e(Fr.Hz).getSegment();return{segment:t,segmentFilters:e(Fr.Hz).getAvailableFilters(),subscriberCount:e(Fr.Hz).getSubscriberCount(),filterRows:e(Fr.Hz).findFiltersValueForSegment(t),errors:e(Fr.Hz).getErrors()}}),[]),l=a.filters.length,d=m.U.capabilities.segmentFilters.value>0&&l>=m.U.capabilities.segmentFilters.value,{updateSegment:c,updateSegmentFilter:u,handleSave:p}=(0,me.A)(Fr.Hz),[g,_]=(0,r.useState)(!1),f=Pt.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",(()=>{_(!0)}));return(0,h.jsx)("div",{className:"mailpoet-form-container",children:(0,h.jsxs)("form",{children:[o.length>0&&(0,h.jsx)(pa,{errors:o.map((e=>({message:e})))}),(0,h.jsxs)(Tr,{title:(0,Ae.__)("Details","mailpoet"),description:(0,Ae.__)("What do you want to call this segment?","mailpoet"),children:[(0,h.jsx)(Er,{slug:"name",title:(0,Ae.__)("Name","mailpoet"),children:(0,h.jsx)(it.p,{isFullWidth:!0,type:"text",name:"name",id:"field_name",value:a.name||"","data-automation-id":"input-name",onChange:e=>{c({name:e.target.value})},placeholder:(0,Ae.__)("Enter name","mailpoet")})}),(0,h.jsx)(Er,{slug:"description",title:(0,Ae.__)("Description","mailpoet"),description:(0,Ae.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,h.jsx)(it.p,{isFullWidth:!0,name:"description",id:"field_description",value:a.description||"","data-automation-id":"input-description",onChange:e=>{c({description:e.target.value})},placeholder:(0,Ae.__)("Enter description","mailpoet")})})]}),(0,h.jsx)(Tr,{title:(0,Ae.__)("Conditions","mailpoet"),description:(0,Ae.__)("Set your segment constraints","mailpoet"),children:(0,h.jsx)(Er,{children:(0,h.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,h.jsx)(zo,{}),Array.isArray(n)&&n.map(((e,t)=>(0,h.jsxs)(r.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t}`,children:[(0,h.jsx)(Vo,{filterRows:n,index:t}),(0,h.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,h.jsx)(Ur.ReactSelect,{dimension:"small",placeholder:(0,Ae.__)("Select action","mailpoet"),options:i,value:e.filterValue,onChange:e=>{u({segmentType:e.group,action:e.value},t)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==e.index&&(0,h.jsx)(Ho,{filterIndex:e.index})]}),(0,h.jsx)(Go,{index:t})]},e.index))),(0,h.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,h.jsx)(de.Ay,{type:"button",variant:"secondary",onClick:e=>{e.preventDefault(),f(a,c)},children:(0,Ae.__)("Add a condition","mailpoet")}),(!m.U.premiumActive||!m.U.hasValidPremiumKey||m.U.subscribersLimitReached||d)&&(0,h.jsx)(Rr.S,{text:(0,Ae.__)("UPGRADE","mailpoet")}),g&&(0,h.jsx)(Za.D,{onRequestClose:()=>{_(!1)},data:{capabilities:{segmentFilters:0}},children:(0,Ae.__)("Multiple conditions per segment are not available in the free version of the MailPoet plugin.","mailpoet")})]})]})})}),(0,h.jsxs)("div",{className:"mailpoet-admin-fields-footer",children:[(0,h.jsxs)("div",{className:"mailpoet-segments-counter-section",children:[(0,h.jsx)(Bo,{}),(0,h.jsx)(Wo,{})]}),(0,h.jsx)("div",{className:"mailpoet-form-actions",children:(0,h.jsx)(de.Ay,{variant:"primary",type:"submit",onClick:a=>{a.preventDefault(),p(e,t)},disabled:!Lo(a.filters)||void 0===s.count,children:t?(0,Ae.__)("Save and return","mailpoet"):(0,Ae.__)("Save","mailpoet")})})]})]})})}function Ko(){const e=(0,Se.g)(),{pageLoaded:t,pageUnloaded:a}=(0,me.A)(Fr.Hz),i=(0,b.A)((e=>e(Fr.Hz).getPreviousPage()))||"/",s=(0,Se.zy)(),n=new URLSearchParams(s.search).get("newsletterId")||null;(0,r.useEffect)((()=>(t(e.id),()=>{a()})),[e.id,t,a]);const o=void 0===e.id||Number.isNaN(Number(e.id));return(0,h.jsxs)("div",{className:"mailpoet-main-container",children:[(0,h.jsx)(d.x,{}),(0,h.jsx)(St.x,{}),(0,h.jsx)(It.z,{heading:e.id?(0,Ae.__)("Edit segment","mailpoet"):(0,Ae.__)("New segment","mailpoet"),headingPrefix:(0,h.jsx)(It.o,{id:"mailpoet-segments-back-button",href:`#${i}`,label:(0,Ae.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,h.jsx)(Yo,{isNewSegment:o,newsletterId:n})]})}Ko.displayName="SegmentEditor";var Jo=a(13432),Qo=a(38793),Zo=a(57699),Xo=a(75379),el=a(1624),tl=a(74679),al=a(31771);var il=a(71612),sl=a(8301);function nl({tab:e,onClick:t}){const a=(0,sl.L)(Fr.Hz).getDynamicSegments(),i=a?a.filter((e=>e.selected)):[],s="trash"!==e.name?[{value:"0",label:(0,Ae.__)("Bulk actions","mailpoet")},{label:(0,Ae.__)("Trash","mailpoet"),value:"trash"}]:[{value:"0",label:(0,Ae.__)("Bulk actions","mailpoet")},{label:(0,Ae.__)("Restore","mailpoet"),value:"restore"},{label:(0,Ae.__)("Delete permanently","mailpoet"),value:"delete"}];return(0,h.jsx)(il.A,{multiple:!1,hideLabelFromVision:!0,className:"mailpoet-segments-listing-bulk-actions",label:(0,Ae.__)("Bulk actions","mailpoet"),options:s,value:"0",onChange:e=>{0!==i.length&&"0"!==e&&t(i,e)}})}var rl=a(70143);function ol({action:e,selected:t,onClose:a}){if(null===e)return null;let i="",s="",n="";const r=new Intl.ListFormat(Fr.Hg.toString(),{style:"long",type:"conjunction"}).format(t.map((({name:e})=>`"${e}"`)));switch(e){case"trash":i=(0,Ae._n)("Trash selected segment","Trash selected segments",t.length,"mailpoet"),s=(0,Ae.sprintf)((0,Ae._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"),r),n=(0,Ae.__)("Trash","mailpoet");break;case"restore":i=(0,Ae._n)("Restore selected segment","Restore selected segments",t.length,"mailpoet"),s=(0,Ae.sprintf)((0,Ae._n)("Are you sure you want to restore the selected segment %s?","Are you sure you want to restore segments %s?",t.length,"mailpoet"),r),n=(0,Ae.__)("Restore","mailpoet");break;case"delete":i=(0,Ae._n)("Delete selected segment permanently","Delete selected segments permanently",t.length,"mailpoet"),s=(0,h.jsxs)(h.Fragment,{children:[(0,Ae.sprintf)((0,Ae._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"),r)," ",(0,h.jsx)("strong",{children:(0,Ae.__)("This action can not be reversed.","mailpoet")})]}),n=(0,Ae.__)("Delete permanently","mailpoet")}return(0,h.jsx)(rl.A,{className:"mailpoet-confirm-dialog",isOpen:!0,title:i,confirmButtonText:n,__experimentalHideHeader:!1,onConfirm:()=>{!async function(e,t){if(e)try{const a=await m.U.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,Xo.J)(tl.store).createErrorNotice(e)}));const i=a.meta.count;if(i>0){let t="";switch(e){case"trash":t=(0,Ae.sprintf)((0,Ae._n)("Segment moved to trash.","%d segments moved to trash.",i,"mailpoet"),i);break;case"delete":t=(0,Ae.sprintf)((0,Ae._n)("Segment permanently deleted.","%d segments permanently deleted.",i,"mailpoet"),i);break;case"restore":t=(0,Ae.sprintf)((0,Ae._n)("Segment restored.","%d segments restored.",i,"mailpoet"),i)}(0,Xo.J)(tl.store).createSuccessNotice(t),(0,Xo.J)(Fr.Hz).loadDynamicSegments()}}catch(t){if((0,al.C)(t)){let a="";if(t.errors)m.U.Notice.showApiErrorNotice(t);else{switch(e){case"trash":a=(0,Ae.__)("Error moving segment to trash.","mailpoet");break;case"delete":a=(0,Ae.__)("Error deleting segment.","mailpoet");break;case"restore":a=(0,Ae.__)("Error restoring segment.","mailpoet")}(0,Xo.J)(tl.store).createErrorNotice(a,{explicitDismiss:!0})}}}}(e,t),a()},onCancel:a,children:(0,h.jsx)("p",{children:s})})}var ll=a(43991),dl=a(16228);const cl=window.mailpoet_dynamic_segment_count;function ml(){const{dynamicSegments:e}=(0,b.A)((e=>({dynamicSegments:e(Fr.Hz).getDynamicSegments()}))),t=null!==e&&e.filter((e=>e.selected)).length===e.length&&e.length>0;return(0,h.jsx)("input",{checked:t,type:"checkbox","data-automation-id":"select_all",onChange:()=>{t?(0,Xo.J)(Fr.Hz).unselectAllDynamicSections():(0,Xo.J)(Fr.Hz).selectAllDynamicSections()}})}const ul=[{key:"checkbox",label:(0,h.jsx)(ml,{}),cellClassName:"mailpoet-listing-checkbox"},{key:"name",label:(0,Ae.__)("Segment","mailpoet"),cellClassName:"mailpoet-listing-name",isSortable:!0},{key:"subscribers",label:(0,Ae.__)("Number of subscribers","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"subscribed",label:(0,Ae.__)("Subscribed","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"updated_at",label:(0,Ae.__)("Modified","mailpoet"),cellClassName:"mailpoet-listing-modified-date",isLeftAligned:!1,isSortable:!0},{key:"actions",isLeftAligned:!1}];function pl({tab:e}){const[t,a]=(0,r.useState)(null),[i,s]=(0,r.useState)([]),{dynamicSegments:n,dynamicSegmentsLoading:o,dynamicSegmentsCount:l}=(0,b.A)((e=>({dynamicSegments:e(Fr.Hz).getDynamicSegments(),dynamicSegmentsLoading:e(Fr.Hz).getDynamicSegmentsLoading(),dynamicSegmentsCount:e(Fr.Hz).getDynamicSegmentsCount()}))),d=(0,ll.aJ)(),[c,u,p]=function(e=""){const[t,a]=(0,r.useState)(e),[i,s]=(0,r.useState)(e),n=(0,dl.A)(s,250);return(0,r.useEffect)((()=>{n(t)}),[t,n]),[t,a,i]}(d.search??"");(0,r.useEffect)((()=>{(0,ll.ql)({search:p,offset:0})}),[p]),(0,r.useEffect)((()=>{(0,Xo.J)(Fr.Hz).loadDynamicSegments(d)}),[d]);const g=((0,r.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,Ae.__)("Duplicate","mailpoet"),icon:null,onClick:()=>{!async function(e){try{const t=(await m.U.Ajax.post({api_version:"v1",endpoint:"dynamic_segments",action:"duplicate",data:{id:e.id}})).data,a=(0,Ae.sprintf)((0,Ae.__)('Segment "%s" has been duplicated.',"mailpoet"),t.name);(0,Xo.J)(tl.store).createSuccessNotice(a),(0,Xo.J)(Fr.Hz).loadDynamicSegments()}catch(e){(0,al.C)(e)&&m.U.Notice.showApiErrorNotice(e)}}(e)}}},{key:"trash",control:{title:(0,Ae.__)("Move to trash","mailpoet"),icon:null,onClick:()=>a("trash",e)}}]:[{key:"restore",control:{title:(0,Ae.__)("Restore","mailpoet"),icon:null,onClick:()=>a("restore",e)}},{key:"delete",control:{title:(0,Ae.__)("Delete permanently","mailpoet"),icon:null,onClick:()=>a("delete",e)}}];return[{value:null,display:(0,h.jsx)("input",{type:"checkbox",checked:e?.selected??!1,onChange:()=>{e?.selected?(0,Xo.J)(Fr.Hz).unselectDynamicSection(e):(0,Xo.J)(Fr.Hz).selectDynamicSection(e)}})},{value:e.name,display:(0,h.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_name_${e.id}`,children:[(0,h.jsx)(we.Link,{to:`${el.r$}/${e.id}`,children:e.name}),e.description&&(0,h.jsx)("div",{children:e.description})]})},e.is_plugin_missing?{value:e.missing_plugin_message,display:(0,h.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,h.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,h.jsx)(de.Ay,{"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,h.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_created_at_${e.id}`,children:[m.U.Date.short(e.created_at),(0,h.jsx)("br",{}),m.U.Date.time(e.created_at)]})},{value:null,display:(0,h.jsxs)("div",{className:"mailpoet-listing-actions-cell","data-automation-id":`mailpoet_dynamic_segment_actions_${e.id}`,children:[(0,h.jsx)(de.Ay,{variant:"tertiary",href:e.subscribers_url,children:(0,Ae.__)("View subscribers","mailpoet")}),e.is_plugin_missing?(0,h.jsx)(de.Ay,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",disabled:!0,children:(0,Ae.__)("Edit","mailpoet")}):(0,h.jsx)(de.Ay,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",href:`#${el.r$}/${e.id}`,children:(0,Ae.__)("Edit","mailpoet")}),(0,h.jsx)(v.A,{className:"mailpoet-listing-more-button",label:(0,Ae.__)("More","mailpoet"),icon:j.A,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,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-segments-listing-header",children:[(0,h.jsx)(nl,{tab:e,onClick:(e,t)=>{s(e),a(t)}}),(0,h.jsx)(Zo.A,{className:"mailpoet-segments-listing-search",placeholder:(0,Ae.__)("Search","mailpoet"),onChange:u,value:c})]}),(0,h.jsx)(Qo.A,{className:"mailpoet-listing-card mailpoet-segments-listing",title:"",isLoading:o.value,headers:ul,rows:g,onQueryChange:e=>t=>{"paged"===e&&(0,ll.ql)({offset:d.limit*(t-1)}),"per_page"===e&&(0,ll.ql)({limit:parseInt(t,10),offset:0}),"sort"===e&&(0,ll.ql)({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,h.jsx)(ol,{action:t,selected:i,onClose:()=>a(null)})]})}const hl=[{name:"all",title:(0,Ae.__)("All","mailpoet"),className:"mailpoet-tab-all"},{name:"trash",title:(0,Ae._x)("Trash","noun","mailpoet"),className:"mailpoet-tab-trash"}];function gl(){const e=(0,ll.aJ)(),{dynamicSegmentsGroups:t}=(0,b.A)((e=>({dynamicSegments:e(Fr.Hz).getDynamicSegments(),dynamicSegmentsGroups:e(Fr.Hz).getDynamicSegmentsGroups()}))),a=(0,r.useMemo)((()=>hl.map((e=>{const a=t?.find((t=>e.name===t.name)),i=a?.count??0;return{name:e.name,title:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{children:e.title}),i>0&&(0,h.jsx)("span",{className:"count",children:i})]}),className:e.className}}))),[t]),i=(0,r.useCallback)((e=>(0,h.jsx)(pl,{tab:e})),[]);return(0,h.jsx)(Jo.A,{className:"mailpoet-filter-tab-panel",tabs:a,initialTabName:e.group,onSelect:e=>{(0,ll.ql)({group:e,offset:0})},children:i},e.group)}function _l(){const{notices:e}=(0,b.A)((e=>({notices:e(tl.store).getNotices()})),[]),{removeNotice:t}=(0,me.A)(tl.store),a=e.filter((({isDismissible:e,type:t})=>e&&"default"===t)),i=e.filter((({isDismissible:e,type:t})=>!e&&"default"===t));return(0,h.jsxs)(h.Fragment,{children:[i.reverse().map((({id:e,status:t,content:a,__unstableHTML:i})=>(0,h.jsx)(p.$,{renderInPlace:!0,type:t,timeout:!1,children:i??(0,h.jsx)("p",{children:a})},e))),a.reverse().map((({id:e,status:a,content:i,__unstableHTML:s})=>(0,h.jsx)(p.$,{type:a,renderInPlace:!0,timeout:!1,closable:!0,onClose:()=>t(e),children:s??(0,h.jsx)("p",{children:i})},e)))]})}var fl=a(39116);const xl=[{name:(0,Ae.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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,Ae.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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,Ae.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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,Ae.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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:Dr.Z2.OR},{name:(0,Ae.__)("Unengaged Subscribers","mailpoet"),slug:"unengaged-subscribers",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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:Dr.VE.ALL_TIME}],isEssential:!0},{name:(0,Ae.__)("First-Time Buyers","mailpoet"),slug:"first-time-buyers",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("Customers who have made their first purchase in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:"firstOrder",operator:io.IN_THE_LAST,value:"30"}],isEssential:!0},{name:(0,Ae.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Dr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,Ae.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Dr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,Ae.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:Dr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,Ae.__)("Win-Back","mailpoet"),slug:"win-back",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("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,Ae.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:Dr.eu.PURCHASE_HISTORY,description:(0,Ae.__)("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,Ae.__)("Clickers","mailpoet"),slug:"clickers",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("Contacts who regularly click on your emails in the last 90 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Dr.VE.IN_THE_LAST,clicks:"2",days:"90"}],isEssential:!1},{name:(0,Ae.__)("Non-Openers","mailpoet"),slug:"non-openers",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("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:Dr.VE.IN_THE_LAST,emails:"0",days:"90"},{segmentType:"email",action:"opensAbsoluteCount",operator:"equals",timeframe:Dr.VE.IN_THE_LAST,opens:"0",days:"90"}]},{name:(0,Ae.__)("Recent Clickers","mailpoet"),slug:"recent-clickers",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("Contacts who have clicked on an email in the last 7 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:Dr.VE.IN_THE_LAST,clicks:"0",days:"7"}],isEssential:!1},{name:(0,Ae.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:Dr.eu.ENGAGEMENT,description:(0,Ae.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:Dr.VE.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,Ae.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:Dr.eu.SHOPPING_BEHAVIOR,description:(0,Ae.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:Dr.VE.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]},{name:(0,Ae.__)("Used a discount code","mailpoet"),slug:"used-a-discount-code",category:Dr.eu.SHOPPING_BEHAVIOR,description:(0,Ae.__)("Customers who made a purchase with a coupon code in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:po.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:0,timeframe:Dr.VE.IN_THE_LAST,days:"30"}],isEssential:!1},{name:(0,Ae.__)("Frequently uses discounts","mailpoet"),slug:"frequently-uses-discounts",category:Dr.eu.SHOPPING_BEHAVIOR,description:(0,Ae.__)("Customers who have regularly used coupons in the last 90 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:po.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:2,timeframe:Dr.VE.IN_THE_LAST,days:"90"}],isEssential:!1}],bl=[{slug:Dr.eu.ENGAGEMENT,name:(0,Ae.__)("Engagement","mailpoet")},{slug:Dr.eu.PURCHASE_HISTORY,name:(0,Ae.__)("Purchase History","mailpoet")},{slug:Dr.eu.SHOPPING_BEHAVIOR,name:(0,Ae.__)("Shopping Behavior","mailpoet")}];function vl(e){const t=bl.find((t=>t.slug===e));return t?t.name:null}var jl=a(55494);const yl=[{name:"all",title:(0,h.jsx)(jl.Ic,{title:(0,Ae.__)("All","mailpoet"),count:xl.length})}];bl.forEach((e=>{const t=xl.filter((t=>t.category===e.slug)).length;yl.push({name:e.slug,title:(0,h.jsx)(jl.Ic,{title:e.name,count:t})})}));const wl=document.getElementById("dynamic_segments_container");function Sl(){const{setPreviousPage:e}=(0,me.A)(Fr.Hz),t=(0,Se.zy)(),a=(0,r.useRef)(t.pathname);return(0,r.useEffect)((()=>{e(a.current),a.current=t.pathname}),[t,e]),null}const Nl=(0,o.withBoundary)(Ko),Il=(0,o.withBoundary)((function(){const e=(0,b.A)((e=>e(Fr.Hz).getErrors()),[]),{createFromTemplate:t}=(0,me.A)(Fr.Hz),a=()=>{m.U.trackEvent("Segments > New empty segment")};return(0,h.jsxs)("div",{className:"mailpoet-main-container",children:[(0,h.jsx)(St.x,{}),(0,h.jsx)(d.x,{}),(0,h.jsxs)(It.z,{className:"mailpoet-templates-header",heading:(0,Ae.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,h.jsx)(It.o,{href:"#/",label:(0,Ae.__)("Segments list","mailpoet"),"aria-label":(0,Ae.__)("Navigate to the segments list page","mailpoet")}),children:[(0,h.jsx)(fl.A,{label:(0,Ae.__)("Search segment templates","mailpoet"),onChange:()=>null}),(0,h.jsx)(de.Ay,{variant:"secondary",href:`#${el.LX}`,"data-automation-id":"new-custom-segment",onClick:()=>{a()},children:(0,Ae.__)("Create custom segment","mailpoet")})]}),e.length>0&&(0,h.jsx)(pa,{errors:e.map((e=>({message:e})))}),(0,h.jsx)(jl.Kp,{tabs:yl,children:e=>(0,h.jsx)(jl.xA,{children:xl.filter((t=>"all"===e.name||t.category===e.name)).map((e=>(0,h.jsx)(jl.q7,{name:e.name,description:e.description,category:vl(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug)))})}),(0,h.jsxs)(jl.wi,{children:[(0,h.jsx)("p",{children:(0,Ae.__)("Want to set your own conditions?","mailpoet")}),(0,h.jsx)(de.Ay,{variant:"link",href:`#${el.LX}`,onClick:()=>{a()},children:(0,Ae.__)("Create custom segment","mailpoet")})]})]})})),Ul=(0,o.withBoundary)((function(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.x,{hideScreenOptions:!0}),(0,h.jsx)(_l,{}),(0,h.jsx)(It.z,{heading:(0,Ae.__)("Segments","mailpoet"),children:(0,h.jsx)(de.Ay,{href:`#${el.WA}`,icon:Me.W,variant:"primary","data-automation-id":"new-segment",className:"mailpoet-add-new-button",children:(0,Ae.__)("New segment","mailpoet")})}),(0,h.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,h.jsx)(Le,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit,design:"new"}),(0,h.jsx)(De,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at,design:"new"})]}),(0,h.jsx)(f.D,{}),(0,h.jsx)(gl,{})]})}));function Cl(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(Sl,{}),(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:el.LX,element:(0,h.jsx)(Nl,{})}),(0,h.jsx)(Se.qh,{path:`${el.r$}/:id`,element:(0,h.jsx)(Nl,{})}),(0,h.jsx)(Se.qh,{path:el.WA,element:(0,h.jsx)(Il,{})}),(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(Ul,{})})]})]})})}wl&&((0,o.registerTranslations)(),(0,Fr.y$)(),(0,n.H)(wl).render((0,h.jsx)(Cl,{})));const kl=()=>{m.U.trackEvent("Forms > Add New"),setTimeout((()=>{window.location=window.mailpoet_form_template_selection_url}),200)};function Al(){const[e,t]=(0,r.useState)(!1);return(0,h.jsx)(d.x,{children:(0,h.jsx)(Te.$,{onClick:()=>{t(!0),kl()},withSpinner:e,automationId:"create_new_form",variant:"secondary",iconStart:Me.W,children:m.U.I18n.t("new")})})}Al.displayName="FormsHeading";const Tl=[{name:"name",label:m.U.I18n.t("formName"),sortable:!0},{name:"segments",label:m.U.I18n.t("segments")},{name:"type",label:m.U.I18n.t("type")},{name:"status",label:m.U.I18n.t("status")},{name:"updated_at",label:m.U.I18n.t("updatedAt"),sortable:!0}],El={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneFormTrashed"):m.U.I18n.t("multipleFormsTrashed").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneFormDeleted"):m.U.I18n.t("multipleFormsDeleted").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?m.U.I18n.t("oneFormRestored"):m.U.I18n.t("multipleFormsRestored").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onNoItemsFound:()=>(0,h.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,h.jsx)("p",{children:m.U.I18n.t("noItemsFound")}),(0,h.jsx)(o.Button,{onClick:kl,automationId:"add_new_form",iconStart:Me.W,children:m.U.I18n.t("new")})]})},Rl=[{name:"trash",label:m.U.I18n.t("moveToTrash"),onSuccess:El.onTrash}],Dl=[{name:"edit",className:"mailpoet-hide-on-mobile",label:m.U.I18n.t("edit"),link:function(e){return(0,h.jsx)("a",{href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:m.U.I18n.t("edit")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:m.U.I18n.t("duplicate"),onClick:function(e,t){return m.U.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:m.U.I18n.t("noName");m.U.Notice.success(m.U.I18n.t("formDuplicated").replace("%1$s",(0,ws.escapeHTML)(a))),t()})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class Fl extends r.Component{updateStatus=(e,t)=>{t.persist(),m.U.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&&m.U.Notice.success(m.U.I18n.t("formActivated"))})).fail((a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e}))};isItemInactive=e=>"disabled"===e.status;renderStatus(e){return(0,h.jsxs)("div",{children:[(0,h.jsx)(Ja.l,{onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"enabled"===e.status}),(0,h.jsxs)("p",{children:[m.U.I18n.t("signups"),": ",e.signups.toLocaleString()]})]})}renderItem=(e,t)=>{null===e.settings&&m.U.Notice.error(m.U.I18n.t("formSettingsCorrupted").replace("%1$s",(0,ws.escapeHTML)(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=Q()("manage-column","column-primary","has-row-actions"),i=window.mailpoet_segments.filter((t=>-1!==Ie().inArray(t.id,e.segments))),s=function(e){const t=[];return"1"===e?.form_placement?.fixed_bar?.enabled&&t.push(m.U.I18n.t("placeFixedBarFormOnPages")),"1"===e?.form_placement?.below_posts?.enabled&&t.push(m.U.I18n.t("placeFormBellowPages")),"1"===e?.form_placement?.popup?.enabled&&t.push(m.U.I18n.t("placePopupFormOnPages")),"1"===e?.form_placement?.slide_in?.enabled&&t.push(m.U.I18n.t("placeSlideInFormOnPages")),t.length>0?t.join(", "):m.U.I18n.t("placeFormOthers")}(e.settings);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("td",{className:a,children:[(0,h.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:e.name?e.name:`(${m.U.I18n.t("noName")})`}),t]}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("segments"),children:(0,h.jsx)(Ss.vC,{segments:i,dimension:"large",children:"user"===e.settings?.segments_selected_by&&(0,h.jsx)("span",{className:"mailpoet-tags-prefix",children:m.U.I18n.t("userChoice")})})}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("type"),children:s}),(0,h.jsx)("td",{className:"column","data-colname":m.U.I18n.t("status"),children:this.renderStatus(e)}),(0,h.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("updatedAt"),children:[m.U.Date.short(e.updated_at),(0,h.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};render(){return(0,h.jsxs)("div",{className:"mailpoet-listing-no-actions-on-mobile",children:[(0,h.jsx)(Al,{}),(0,h.jsx)(Ue.l,{limit:window.mailpoet_listing_per_page,className:"mailpoet-forms-listing",location:this.props.location,params:this.props.params,messages:El,search:!1,endpoint:"forms",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:Tl,bulk_actions:Rl,item_actions:Dl})]})}}Fl.propTypes={location:at().object.isRequired,params:at().object.isRequired},Fl.displayName="FormList";const Ol=Cn(Fl);function Pl(e){const t=(0,Se.zy)(),a=(0,Se.g)();return(0,h.jsx)(Ol,{...e,location:t,params:a})}function Ll(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsx)(f.D,{}),(0,h.jsx)(Se.BV,{children:(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Pl,{})})})})]})})}const Ml=document.getElementById("forms_container");function $l(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:m.U.I18n.t("knowledgeBaseIntro")}),(0,h.jsxs)("ul",{className:"mailpoet-text-links",children:[(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/116-common-problems",children:"Common Problems"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/165-newsletters",children:"Newsletters"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/156-migration-questions",children:"Migration Questions"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/149-sending-methods",children:"Sending Methods"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/139-subscription-forms",children:"Subscription Forms"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/114-getting-started",children:"Getting Started"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/123-newsletter-designer",children:"Newsletter Designer"})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/121-subscribers-and-lists",children:"Subscribers and Lists"})})]}),(0,h.jsx)(Te.$,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:m.U.I18n.t("knowledgeBaseButton")})]})}Ml&&((0,o.registerTranslations)(),(0,n.H)(Ml).render((0,h.jsx)(Ll,{})));var Bl=a(85501);function ql(e){e.target.select()}function Hl(e,t){if(ot.default.isObject(e)){const a=Object.keys(e).map((t=>`${t}: ${e[t]}`));return(0,h.jsx)("textarea",{readOnly:!0,id:t,onFocus:ql,value:a.join("\n"),style:{width:"100%",height:"400px"}})}return(0,h.jsx)("p",{children:m.U.I18n.t("systemInfoDataError")})}function Wl(){const e="mailpoet-system-info",t=window.systemInfoData;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,h.jsx)("p",{children:m.U.I18n.t("systemInfoIntro")})}),Hl(t,e),(0,h.jsx)(Bl.T,{variant:"secondary",targetId:e})]})}function zl({rows:e,max_width:t="auto",is_fixed:a=!0}){return(0,h.jsx)("table",{className:Q()("widefat",{fixed:a}),style:{maxWidth:t},children:(0,h.jsx)("tbody",{children:e.map((e=>(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{className:"row-title",children:e.key}),(0,h.jsx)("td",{children:e.value}),e.action?(0,h.jsx)("td",{children:e.action}):null]},`row_${e.key}`)))})})}function Vl({truthy:e=(0,Ae.__)("Yes","mailpoet"),falsy:t=(0,Ae.__)("No","mailpoet"),unknown:a=(0,Ae.__)("Unknown","mailpoet"),children:i=null}){return(0,h.jsx)("span",{children:!0===i&&e||!1===i&&t||a})}function Gl(e){const t=e.status_data,a={active:m.U.I18n.t("running"),inactive:m.U.I18n.t("cronWaiting")},i=Array.isArray(t.last_error)?(0,h.jsx)(h.Fragment,{children:t.last_error.map((e=>(0,h.jsxs)("div",{children:[e.worker,": ",(0,h.jsx)("i",{children:e.message})]},e.worker)))}):t.last_error;return(0,h.jsxs)("div",{children:[(0,h.jsx)("h4",{children:m.U.I18n.t("systemStatusCronStatusTitle")}),(0,h.jsx)(zl,{max_width:"400px",rows:[{key:m.U.I18n.t("accessible"),value:(0,h.jsx)(Vl,{children:t.accessible})},{key:m.U.I18n.t("status"),value:a[t.status]?a[t.status]:m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastUpdated"),value:t.updated_at?m.U.Date.full(1e3*t.updated_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastRunStarted"),value:t.run_started_at?m.U.Date.full(1e3*t.run_started_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastRunCompleted"),value:t.run_completed_at?m.U.Date.full(1e3*t.run_completed_at):m.U.I18n.t("unknown")},{key:m.U.I18n.t("lastSeenError"),value:i||m.U.I18n.t("none")},{key:m.U.I18n.t("lastSeenErrorDate"),value:t.last_error_date?m.U.Date.full(1e3*t.last_error_date):m.U.I18n.t("unknown")}]})]})}Vl.propTypes={truthy:at().string,falsy:at().string,unknown:at().string,children:at().bool},Gl.propTypes={status_data:at().shape({accessible:at().bool,last_error_date:at().string,status:at().string,updated_at:at().number,run_accessed_at:at().number,run_completed_at:at().number,run_started_at:at().number,last_error:at().oneOfType([at().string,at().array])}).isRequired};var Yl=a(78048);function Kl({task:e,type:t}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,r.useState)(null),o="cancel"===t,l="reschedule"===t,d=e.scheduledAt,c=m.U.Date.isInPast(d,new Date);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(rl.A,{className:"mailpoet-help-modal",isOpen:a,title:o?(0,Ae.__)("Cancel task","mailpoet"):(0,Ae.__)("Reschedule task","mailpoet"),cancelButtonText:(0,Ae.__)("Not now","mailpoet"),confirmButtonText:o?(0,Ae.__)("Yes, cancel task","mailpoet"):(0,Ae.__)("Yes, reschedule task","mailpoet"),onConfirm:async()=>{await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:o?"cancelTask":"rescheduleTask",data:{id:e.id}}).done((()=>{n(null),i(!1),window.location.reload()})).catch((e=>{n(e.errors.map((e=>e.message)).join(" "))}))},onCancel:()=>i(!1),__experimentalHideHeader:!1,children:[s&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Yl.A,{status:"error",isDismissible:!1,children:s}),(0,h.jsx)("br",{})]}),o&&(0,Ae.sprintf)((0,Ae.__)('Are you sure you want to cancel the task with ID %1$s for the email "%2$s"? Once cancelled, the email will not be sent.',"mailpoet"),e.id,e.newsletter.subject||(0,Ae.__)("(no subject)","mailpoet")),l&&(0,Ae.sprintf)((0,Ae.__)('Are you sure you want to reschedule the task with ID %s for the email "%2$s"?',"mailpoet"),e.id,e.newsletter.subject||(0,Ae.__)("(no subject)","mailpoet"))," ",l&&c&&(0,Ae.__)("The email will be sent immediately.","mailpoet"),l&&!c&&(0,Ae.sprintf)((0,Ae.__)("The task will be scheduled for sending on %s.","mailpoet"),`${m.U.Date.short(d)} ${m.U.Date.time(d)}`)]}),(0,h.jsx)(de.Ay,{variant:"secondary",size:"small",isDestructive:o,onClick:()=>i(!0),children:o?(0,Ae.__)("Cancel task","mailpoet"):(0,Ae.__)("Reschedule task","mailpoet")})]})}function Jl({task:e}){return(0,h.jsx)(Kl,{task:e,type:"cancel"})}function Ql({task:e}){return(0,h.jsx)(Kl,{task:e,type:"reschedule"})}function Zl({type:e,task:t}){const a="scheduled"===e,i="cancelled"===e,s="scheduled"===e||"running"===e,n="cancelled"===e;return(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{className:"column column-primary",children:t.id}),(0,h.jsx)("td",{className:"column",children:t.newsletter?(0,h.jsx)("a",{href:t.newsletter.previewUrl,"data-newsletter-id":t.newsletter.newsletterId,"data-queue-id":t.newsletter.queueId,target:"_blank",rel:"noopener noreferrer",children:t.newsletter.subject||m.U.I18n.t("preview")}):m.U.I18n.t("none")}),(0,h.jsx)("td",{className:"column",children:t.subscriberEmail?(0,h.jsx)("a",{href:`admin.php?page=mailpoet-subscribers#/search[${t.subscriberEmail}]`,children:t.subscriberEmail}):(0,h.jsx)("i",{children:m.U.I18n.t("multipleSubscribers")})}),(0,h.jsx)("td",{className:"column",children:t.priority}),a?(0,h.jsx)("td",{className:"column-date",children:(0,h.jsx)("abbr",{children:`${m.U.Date.short(t.scheduledAt)} ${m.U.Date.time(t.scheduledAt)}`})}):null,i?(0,h.jsx)("td",{className:"column-date",children:(0,h.jsx)("abbr",{children:`${m.U.Date.short(t.cancelledAt)} ${m.U.Date.time(t.cancelledAt)}`})}):null,(0,h.jsx)("td",{className:"column-date",children:(0,h.jsx)("abbr",{children:`${m.U.Date.short(t.updatedAt)} ${m.U.Date.time(t.updatedAt)}`})}),s?(0,h.jsx)("td",{children:(0,h.jsx)(Jl,{task:t})}):null,n?(0,h.jsx)("td",{children:(0,h.jsx)(Ql,{task:t})}):null]})}function Xl({type:e}){const t=["scheduled","running","cancelled"].includes(e);return(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{className:"row-title",children:"Id"}),(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("email")}),(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("subscriber")}),(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("priority")}),"scheduled"===e?(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("scheduledAt")}):null,"cancelled"===e?(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("cancelledAt")}):null,(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("updatedAt")}),t?(0,h.jsx)("th",{className:"row-title",children:m.U.I18n.t("action")}):null]})}function ed({tasks:e,type:t}){let a=5;return"running"===t&&(a+=1),"scheduled"!==t&&"cancelled"!==t||(a+=2),(0,h.jsxs)("table",{className:"widefat fixed striped",children:[(0,h.jsx)("thead",{children:(0,h.jsx)(Xl,{type:t})}),(0,h.jsx)("tbody",{children:e.length?e.map((e=>(0,h.jsx)(Zl,{task:e,type:t},e.id))):(0,h.jsx)("tr",{className:"mailpoet-listing-no-items",children:(0,h.jsx)("td",{colSpan:a,children:m.U.I18n.t("nothingToShow")})})}),(0,h.jsx)("tfoot",{children:(0,h.jsx)(Xl,{type:t})})]})}function td({statusData:e}){const t=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h4",{children:m.U.I18n.t("systemStatusQueueTitle")}),(0,h.jsx)(zl,{max_width:"400px",rows:[{key:m.U.I18n.t("status"),value:"paused"===t.status?m.U.I18n.t("paused"):m.U.I18n.t("running")},{key:m.U.I18n.t("startedAt"),value:t.started?m.U.Date.full(1e3*t.started):m.U.I18n.t("unknown")},{key:m.U.I18n.t("sentEmails"),value:t.sent||0},{key:m.U.I18n.t("retryAttempt"),value:t.retryAttempt||m.U.I18n.t("none")},{key:m.U.I18n.t("retryAt"),value:t.retryAt?m.U.Date.full(1e3*t.retryAt):m.U.I18n.t("none")},{key:m.U.I18n.t("error"),value:t.error?t.error.errorMessage:m.U.I18n.t("none")},{key:m.U.I18n.t("totalCompletedTasks"),value:t.tasksStatusCounts.completed},{key:m.U.I18n.t("totalRunningTasks"),value:t.tasksStatusCounts.running},{key:m.U.I18n.t("totalPausedTasks"),value:t.tasksStatusCounts.paused},{key:m.U.I18n.t("totalCancelledTasks"),value:t.tasksStatusCounts.cancelled},{key:m.U.I18n.t("totalScheduledTasks"),value:t.tasksStatusCounts.scheduled}]}),(0,h.jsx)("h5",{children:m.U.I18n.t("scheduledTasks")}),(0,h.jsx)(ed,{type:"scheduled",tasks:t.latestTasks.filter((e=>"scheduled"===e.status))}),(0,h.jsx)("h5",{children:m.U.I18n.t("cancelledTasks")}),(0,h.jsx)(ed,{type:"cancelled",tasks:t.latestTasks.filter((e=>"cancelled"===e.status))}),(0,h.jsx)("h5",{children:m.U.I18n.t("runningTasks")}),(0,h.jsx)(ed,{type:"running",tasks:t.latestTasks.filter((e=>null===e.status))}),(0,h.jsx)("h5",{children:m.U.I18n.t("pausedTasks")}),(0,h.jsx)(ed,{type:"paused",tasks:t.latestTasks.filter((e=>"paused"===e.status))}),(0,h.jsx)("h5",{children:m.U.I18n.t("completedTasks")}),(0,h.jsx)(ed,{type:"completed",tasks:t.latestTasks.filter((e=>"completed"===e.status))})]})}function ad({version:e,storage:t,latestTrigger:a,latestCompletedTrigger:i,latestCompletedRun:s}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("h4",{children:m.U.I18n.t("actionSchedulerStatus")}),(0,h.jsx)(zl,{max_width:"400px",rows:[{key:m.U.I18n.t("version"),value:e},{key:m.U.I18n.t("storage"),value:t},{key:m.U.I18n.t("latestActionSchedulerTrigger"),value:m.U.Date.full(a)},{key:m.U.I18n.t("latestActionSchedulerCompletedTrigger"),value:m.U.Date.full(i)},{key:m.U.I18n.t("latestActionSchedulerCompletedRun"),value:m.U.Date.full(s)}]})]})}function id(){const[e,t]=(0,r.useState)({total:0}),[a,i]=(0,r.useState)("");(0,r.useEffect)((()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:"getInconsistentDataStatus"}).done((e=>{t(e.data||null)})).catch((e=>{m.U.Notice.show({type:"error",message:e.errors.map((e=>e.message)).join(" "),scroll:!0})}))}),[]);const s=(0,r.useMemo)((()=>({orphaned_sending_tasks:(0,Ae.__)("Orphaned Sending Tasks","mailpoet"),orphaned_sending_task_subscribers:(0,Ae.__)("Orphaned Sending Task Subscribers","mailpoet"),sending_queue_without_newsletter:(0,Ae.__)("Sending Queues without Newsletter","mailpoet"),orphaned_subscriptions:(0,Ae.__)("Orphaned Subscriptions","mailpoet"),orphaned_links:(0,Ae.__)("Orphaned Links","mailpoet"),orphaned_newsletter_posts:(0,Ae.__)("Orphaned Newsletter Posts","mailpoet")})),[]),n=(0,r.useCallback)((e=>{i(e),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"help",action:"fixInconsistentData",data:{inconsistency:e}}).done((e=>{i(""),t(e.data||null),m.U.Notice.show({message:(0,Ae.__)("Inconsistency fixed!","mailpoet"),scroll:!0})})).catch((e=>{i(""),m.U.Notice.show({type:"error",message:e.errors.map((e=>e.message)).join(" "),scroll:!0})}))}),[]);if(!e||0===e.total)return null;const o=Object.entries(e).filter((([e,t])=>"total"!==e&&t>0)).map((([e,t])=>({key:s[e],value:t,action:(0,h.jsx)(de.Ay,{variant:"primary",size:"small",label:(0,Ae.__)("Clean","mailpoet"),onClick:()=>n(e),isBusy:a===e,disabled:!!a,children:(0,Ae.__)("Fix","mailpoet")})})));return(0,h.jsxs)("div",{children:[(0,h.jsx)("h2",{children:(0,Ae.__)("Data Inconsistencies","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)('We found the following data inconsistencies in your DB. Click the "Fix" button to clean them.',"mailpoet")}),(0,h.jsx)(zl,{rows:o,max_width:"400px",is_fixed:!1})]})}function sd(e,t,a,i,s){const n=e?"success":"error";let r=e?t:a;return i&&(r=Re()(r,/\[link\](.*?)\[\/link\]/g,(e=>(0,h.jsx)("a",{className:"mailpoet-text-link",href:i,children:e},"kb-link")))),(0,h.jsxs)("div",{className:`mailpoet_notice notice inline notice-${n}`,children:[(0,h.jsx)("p",{children:r}),s?(0,h.jsx)("p",{children:(0,h.jsx)("i",{children:s})}):null]})}function nd(e){const t=e.cron.isReachable,a=e.cron.url,i=`${m.U.I18n.t("systemStatusConnectionUnsuccessful")} ${m.U.I18n.t("systemStatusCronConnectionUnsuccessfulInfo")}`,s=m.U.I18n.t("systemStatusConnectionSuccessful"),n=t?null:e.cron.pingResponse;return(0,h.jsxs)("div",{children:[(0,h.jsx)("h4",{children:m.U.I18n.t("systemStatusCronTitle")}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{className:"mailpoet-text-link",href:a,target:"_blank",rel:"noopener noreferrer",children:a})}),sd(t,s,i,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function rd(e){const t=e.mss.enabled?`${m.U.I18n.t("systemStatusConnectionUnsuccessful")} ${m.U.I18n.t("systemStatusMSSConnectionUnsuccessfulInfo")}`:m.U.I18n.t("systemStatusMSSConnectionCanNotConnect"),a=e.mss.enabled?m.U.I18n.t("systemStatusConnectionSuccessful"):m.U.I18n.t("systemStatusMSSConnectionCanConnect");return(0,h.jsxs)("div",{children:[(0,h.jsx)("h4",{children:m.U.I18n.t("systemStatusMSSTitle")}),sd(e.mss.isReachable,a,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function od(){const e=window.systemStatusData,t=window.actionSchedulerData;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,h.jsx)("p",{children:e.mss.enabled?m.U.I18n.t("systemStatusIntroCronMSS"):m.U.I18n.t("systemStatusIntroCron")})}),nd(e),rd(e),(0,h.jsx)(Gl,{status_data:e.cronStatus}),(0,h.jsx)(ad,{...t}),t?(0,h.jsx)(td,{statusData:e.queueStatus}):null,(0,h.jsx)(id,{})]})}function ld(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent1")}),(0,h.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent2")}),(0,h.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent3")}),(0,h.jsx)(Te.$,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:m.U.I18n.t("yourPrivacyButton")})]})}function dd(){return(0,h.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,h.jsx)(d.V,{}),(0,h.jsx)(c.D,{}),(0,h.jsx)(u.q,{}),(0,h.jsx)(f.D,{}),(0,h.jsxs)(yn.k,{activeKey:"knowledgeBase",children:[(0,h.jsx)(o.Tab,{title:m.U.I18n.t("tabKnowledgeBaseTitle"),children:(0,h.jsx)($l,{})},"knowledgeBase"),(0,h.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemStatusTitle"),children:(0,h.jsx)(od,{})},"systemStatus"),(0,h.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemInfoTitle"),children:(0,h.jsx)(Wl,{})},"systemInfo"),(0,h.jsx)(o.Tab,{title:m.U.I18n.t("tabYourPrivacyTitle"),children:(0,h.jsx)(ld,{})},"yourPrivacy")]})]})}const cd=document.getElementById("help_container");cd&&((0,o.registerTranslations)(),(0,n.H)(cd).render((0,h.jsx)(dd,{})));var md=a(85145);function ud({children:e}){const t=(0,Se.zy)();return(0,r.useEffect)((()=>{window.scrollTo(0,0)}),[t.pathname]),e||null}ud.propTypes={children:at().node.isRequired},ud.displayName="ScrollToTopComponent";const pd=(0,md.fk)(ud);function hd({onMethodChange:e,activeMethod:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,h.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodSelectionHead")}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs-row",children:(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file",target:"_blank",rel:"noopener noreferrer",children:(0,h.jsx)(Dt.v,{dimension:"large",variant:"excellent",isInverted:!0,children:m.U.I18n.t("seeVideo")})})})]}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,h.jsx)(ct.s,{name:"select_method",automationId:"import-paste-method",id:"import-paste-method",checked:"paste-method"===t,value:"paste-method",onCheck:e}),(0,h.jsx)("label",{htmlFor:"import-paste-method",children:m.U.I18n.t("methodPaste")})]}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,h.jsx)(ct.s,{name:"select_method",automationId:"import-csv-method",id:"import-csv-method",checked:"file-method"===t,value:"file-method",onCheck:e}),(0,h.jsx)("label",{htmlFor:"import-csv-method",children:m.U.I18n.t("methodUpload")})]}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,h.jsx)(ct.s,{name:"select_method",automationId:"import-mailchimp-method",id:"import-mailchimp-method",checked:"mailchimp-method"===t,value:"mailchimp-method",onCheck:e}),(0,h.jsx)("label",{htmlFor:"import-mailchimp-method",children:m.U.I18n.t("methodMailChimp")})]})]})]})}function gd({hidePrevious:e=!1,isLastStep:t=!1,canGoNext:a=!0,onPreviousAction:i=(()=>{}),onNextAction:s=(()=>{})}){return(0,h.jsxs)("div",{className:"mailpoet-settings-save",children:[!e&&(0,h.jsx)(Te.$,{type:"button",variant:"secondary",onClick:i,children:m.U.I18n.t("previousStep")}),(0,h.jsx)(Te.$,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&s()},children:m.U.I18n.t(t?"import":"nextStep")})]})}hd.propTypes={activeMethod:at().string,onMethodChange:at().func.isRequired},hd.displayName="SelectImportMethod",gd.propTypes={canGoNext:at().bool,hidePrevious:at().bool,isLastStep:at().bool,onPreviousAction:at().func,onNextAction:at().func},gd.displayName="PreviousNextStepButtons";const _d="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",fd="Email, First Name, Last Name\njohn@doe.com, John, Doe\nmary@smith.com, Mary, Smith\njohnny@walker.com, Johnny, Walker";function xd({canFinish:e,onValueChange:t,data:a="",onFinish:i=(()=>{}),onPrevious:s=(()=>{})}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,h.jsx)("label",{htmlFor:"paste_input",children:m.U.I18n.t("pasteLabel")}),(0,h.jsx)("p",{className:"description",children:Re()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.jsx)("a",{className:"mailpoet-link",href:`${_d}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsx)(nt.T,{id:"paste_input",rows:"15",placeholder:fd,isCode:!0,onChange:e=>{t(e.target.value)},defaultValue:a})}),(0,h.jsx)(gd,{canGoNext:e,onPreviousAction:s,onNextAction:i})]})}xd.propTypes={onFinish:at().func,onPrevious:at().func,canFinish:at().bool.isRequired,onValueChange:at().func.isRequired,data:at().string},xd.displayName="MethodPaste";const bd="https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files";function vd({onValueChange:e,canFinish:t,onFinish:a=(()=>{}),onPrevious:i=(()=>{})}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,h.jsx)("label",{htmlFor:"file_local",children:m.U.I18n.t("methodUpload")}),(0,h.jsx)("p",{className:"description",children:Re()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.jsx)("a",{className:"mailpoet-link",href:`${bd}`,target:"_blank",rel:"noopener noreferrer",children:e},"kb-link")))})]}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsx)(it.p,{type:"file",id:"file_local",accept:".csv","data-automation-id":"import-file-upload-input",onChange:t=>{const a=t.target.value.match(/[^.]+$/);m.U.Notice.hide(),null===a||"csv"!==a[0].toLowerCase()?(m.U.Notice.error(m.U.I18n.t("wrongFileFormat")),e("")):e(t.target.files[0])}})}),(0,h.jsx)(gd,{canGoNext:t,onPreviousAction:i,onNextAction:a})]})}function jd({onFinish:e=(()=>{}),onPrevious:t=(()=>{})}){const[a,i]=(0,r.useState)(""),[s,n]=(0,r.useState)(void 0),[o,l]=(0,r.useState)([]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:(0,h.jsxs)("label",{htmlFor:"mailpoet_mailchimp_key_input",children:[(0,h.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodMailChimpLabel")}),(0,h.jsx)("p",{className:"description",children:Re()(m.U.I18n.t("methodMailChimpDescription"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.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,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,h.jsx)(it.p,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{i(e.target.value),""===e.target.value.trim()&&n(void 0)}}),(0,h.jsx)("span",{className:"mailpoet-gap"}),(0,h.jsx)(Te.$,{type:"button",dimension:"small",onClick:()=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpLists",data:{api_key:a}}).always((()=>{m.U.Modal.loading(!1)})).done((e=>n(e.data))).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))},children:m.U.I18n.t("methodMailChimpVerify")}),(0,h.jsx)("span",{className:"mailpoet-gap"}),(0,h.jsx)("span",{children:Array.isArray(s)&&0===s.length?m.U.I18n.t("noMailChimpLists"):null})]})}),s?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("methodMailChimpSelectList")}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsx)(ke.L,{field:{id:"segments",name:"list-selection",multiple:!0,placeholder:m.U.I18n.t("methodMailChimpSelectPlaceholder"),forceSelect2:!0,values:s},onValueChange:e=>l(e.target.value)})})]}):null,(0,h.jsx)(gd,{canGoNext:Array.isArray(o)&&o.length>0,onPreviousAction:t,onNextAction:()=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"getMailChimpSubscribers",data:{api_key:a,lists:o}}).always((()=>{m.U.Modal.loading(!1)})).done((t=>e(t.data))).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}})]})}vd.propTypes={canFinish:at().bool.isRequired,onFinish:at().func,onPrevious:at().func,onValueChange:at().func.isRequired},vd.displayName="MethodUpload",jd.propTypes={onFinish:at().func,onPrevious:at().func},jd.displayName="MethodMailChimp";var yd=a(87714),wd=a.n(yd);const Sd=e=>window.roleBasedEmails.findIndex((t=>e.startsWith(`${t}@`)))>=0,Nd=e=>{let t,a=ot.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)&&!Sd(a)&&a};const Id=(e,t)=>{const a=encodeURI(e).split(/%..|./).length-1;m.U.Notice.hide(),a>window.maxPostSizeBytes?m.U.Notice.error(m.U.I18n.t("maxPostSizeNotice")):(m.U.Modal.loading(!0),wd().parse(e,function(e){return{skipEmptyLines:!0,error(){m.U.Notice.hide(),m.U.Notice.error(m.U.I18n.t("dataProcessingError"))},complete(t){const a=function(e){let t=[];const a=[],i=[],s=[],n=[];let r,o,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=>{o=Nd(l[e]),null===c&&window.mailpoet_email_regex.test(o)&&(c=e,a[o]=!0,l[e]=o,t[o]=l)})),null===c&&0===parseInt(p,10)&&(u=!0,t[0]=l)):""!==l[c]&&(r=Nd(l[c]),ot.default.has(a,r)?i.push(r):Sd(l[c])?n.push(l[c]):window.mailpoet_email_regex.test(r)?(a[r]=!0,l[c]=r,t[r]=l):s.push(l[c])))})),t=ot.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:ot.default.uniq(i),invalid:ot.default.uniq(s),role:ot.default.uniq(n)}:null}(t.data);if(a)e(a);else{let e=m.U.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>"),m.U.Notice.error(e)}m.U.Modal.loading(!1)}}}(t)))},Ud=(e,t,a)=>void 0===e||void 0===e.subscribersCount||e.subscribersCount<t||"mailchimp-method"===a?"/step_data_manipulation":"/step_input_validation";function Cd({setStepMethodSelectionData:e,subscribersLimitForValidation:t}){const a=(0,Se.Zp)(),[i,s]=(0,r.useState)(void 0),[n,l]=(0,r.useState)(""),[d,c]=(0,r.useState)(void 0),u=s=>{e(s),a(Ud(s,t,i))},p=()=>{a("/step_clean_list")},g=()=>{Id("paste-method"===i?n:d,(e=>{m.U.trackEvent("Subscribers import started",{source:"file-method"===i?"file upload":"pasted data"}),u(e)}))};return(0,h.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(hd,{activeMethod:i,onMethodChange:s})}),"paste-method"===i&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(xd,{onPrevious:p,onValueChange:l,onFinish:g,canFinish:!!n.trim(),data:n})}),"file-method"===i&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(vd,{onPrevious:p,onValueChange:c,onFinish:g,canFinish:!!d,data:d})}),"mailchimp-method"===i&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(jd,{onPrevious:p,onFinish:e=>{m.U.trackEvent("Subscribers import started",{source:"MailChimp"}),u(e)}})}),void 0===i&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(gd,{canGoNext:!1,onPreviousAction:p})})]})}function kd({onProceed:e,iHaveCleanedList:t}){return(0,h.jsxs)("div",{className:"mailpoet-clean-list-step-container",children:[(0,h.jsx)("p",{children:m.U.I18n.t("cleanListText1")}),(0,h.jsx)("p",{children:m.U.I18n.t("cleanListText2")}),(0,h.jsxs)("p",{children:[e&&(0,h.jsx)(Te.$,{onClick:e,variant:"tertiary",children:m.U.I18n.t("listCleaningGotIt")}),(0,h.jsx)(Te.$,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:m.U.I18n.t("tryListCleaning")}),t&&(0,h.jsx)(Te.$,{onClick:t,variant:"secondary",children:m.U.I18n.t("cleanedList")})]})]})}function Ad({onSubmit:e}){const t=(0,Se.Zp)(),[a,i]=(0,r.useState)(void 0);return(0,h.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepHeading")}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,h.jsx)(ct.s,{automationId:"mailpoet_import_validation_step_option1",id:"existing-list",checked:"existing-list"===a,value:"existing-list",onCheck:i}),(0,h.jsx)("label",{htmlFor:"existing-list",children:m.U.I18n.t("validationStepRadio1")})]}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,h.jsx)(ct.s,{automationId:"mailpoet_import_validation_step_option2",id:"address-book",checked:"address-book"===a,value:"address-book",onCheck:i}),(0,h.jsx)("label",{htmlFor:"address-book",children:m.U.I18n.t("validationStepRadio2")})]})]}),(0,h.jsx)(gd,{canGoNext:void 0!==a,onPreviousAction:()=>t("/step_method_selection"),onNextAction:()=>e(a)})]})}function Td(){return(0,h.jsxs)("div",{className:"mailpoet-clean-list-step-container","data-automation-id":"import_wrong_source_block",children:[(0,h.jsx)("p",{children:m.U.I18n.t("validationStepBlock1")}),(0,h.jsx)("p",{children:m.U.I18n.t("validationStepBlock2")}),(0,h.jsx)("p",{children:(0,h.jsx)(Te.$,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("validationStepBlockButton")})})]})}function Ed({onSubmit:e}){const[t,a]=(0,r.useState)("over2years"),i=(0,r.useCallback)((e=>{a(e.target.value)}),[a]),s=(0,r.useCallback)((()=>{e("over2years"===t||"1to2years"===t?"notRecently":"recently")}),[e,t]);return(0,h.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepLastSentHeading")}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsxs)(lt.Select,{defaultValue:t,onChange:i,automationId:"last_sent_to_list",children:[(0,h.jsx)("option",{value:"over2years",children:m.U.I18n.t("validationStepLastSentOption1")}),(0,h.jsx)("option",{value:"1to2years",children:m.U.I18n.t("validationStepLastSentOption2")}),(0,h.jsx)("option",{value:"less1year",children:m.U.I18n.t("validationStepLastSentOption3")}),(0,h.jsx)("option",{value:"less3months",children:m.U.I18n.t("validationStepLastSentOption4")})]})}),(0,h.jsx)("div",{className:"mailpoet-settings-save",children:(0,h.jsx)(Te.$,{type:"button",automationId:"last_sent_to_list_next",onClick:s,children:m.U.I18n.t("validationStepLastSentNext")})})]})}function Rd({stepMethodSelectionData:e}){const t=(0,Se.Zp)(),[a,i]=(0,r.useState)(void 0),[s,n]=(0,r.useState)(void 0);(0,r.useEffect)((()=>{void 0===e&&t("/step_method_selection",{replace:!0})}),[e,t]);const l=(0,r.useCallback)((e=>{n(e),"recently"===e&&t("/step_data_manipulation")}),[t,n]);return(0,h.jsxs)(h.Fragment,{children:[void 0===a&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Ad,{onSubmit:i})}),"address-book"===a&&(0,h.jsx)(Td,{}),"existing-list"===a&&void 0===s&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Ed,{onSubmit:l})}),"existing-list"===a&&"notRecently"===s&&(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(kd,{iHaveCleanedList:()=>l("recently")})})]})}function Dd({translation:e,subscribers:t}){let a="";return t.length&&(a=Re()(e.replace("%2$s",t.join(", ")),"%1$s",(()=>(0,h.jsx)("strong",{children:t.length.toLocaleString()},e))),a=(0,h.jsx)("p",{children:a})),a}function Fd({stepMethodSelectionData:e={invalid:[],duplicate:[],role:[]}}){const{invalid:t,duplicate:a,role:i}=e,[s,n]=(0,r.useState)(!1),o=Q()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!s}),l=(0,h.jsx)(Dd,{translation:m.U.I18n.t("importNoticeInvalid"),subscribers:t}),d=(0,h.jsx)(Dd,{translation:m.U.I18n.t("importNoticeDuplicate"),subscribers:a});let c="";if(i.length&&(c=Re()(m.U.I18n.t("importNoticeRoleBased"),/(%1\$s|\[link\].*\[\/link\]|%2\$s)/,(e=>"%1$s"===e?(0,h.jsx)("strong",{children:i.length.toLocaleString()},"role-length"):"%2$s"===e?i.join(", "):(0,h.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))),c=(0,h.jsx)("p",{children:c})),t.length||a.length||i.length){const e=t.length+a.length+i.length;return(0,h.jsxs)("div",{className:"error",children:[(0,h.jsxs)("p",{children:[Re()(m.U.I18n.t("importNoticeSkipped"),"%1$s",(()=>(0,h.jsx)("strong",{children:e.toLocaleString()},"lengths")))," ",(0,h.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:m.U.I18n.t("showMoreDetails")})]}),(0,h.jsxs)("div",{className:o,children:[(0,h.jsx)("hr",{}),l,d,c]})]})}return null}Cd.propTypes={setStepMethodSelectionData:at().func.isRequired,subscribersLimitForValidation:at().number.isRequired},Cd.diplayName="StepMethodSelection",kd.displayName="CleanList",Ad.propTypes={onSubmit:at().func.isRequired},Ad.displayName="InitialQuestion",Ed.propTypes={onSubmit:at().func.isRequired},Ed.displayName="LastSentQuestion",Rd.displayName="StepInputValidation",Dd.propTypes={translation:at().string.isRequired,subscribers:at().arrayOf(at().string).isRequired},Fd.propTypes={stepMethodSelectionData:at().shape({duplicate:at().arrayOf(at().string),invalid:at().arrayOf(at().string),role:at().arrayOf(at().string)})};const Od=()=>{const e={data:window.mailpoetColumnsSelect2,width:"15em"};Ie()("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(),Ie()(a).select2("close"),m.U.Modal.popup({title:m.U.I18n.t("addNewField"),template:Ie()("#form_template_field_form").html()}),Ie()("#form_field_new").parsley().on("form:submit",(()=>{const t=Ie()("#form_field_new").mailpoetSerializeObject();return m.U.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:m.U.I18n.t("userColumns"),children:[]}),window.mailpoetColumnsSelect2[2].children.push(i),window.mailpoetColumns.push(i),Ie()("select.mailpoet_subscribers_column_data_match").each((()=>{Ie()(a).html("").select2("destroy").select2(e)})),Ie()(a).data("column-id",i.id),m.U.Modal.close()})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{positionAfter:"#field_name"})})),!1}))):Ie()("select.mailpoet_subscribers_column_data_match").each((()=>{const e=a,s=Ie()(e).val();s===i&&"ignore"!==s&&(confirm(`${m.U.I18n.t("selectedValueAlreadyMatched")} ${m.U.I18n.t("confirmCorrespondingColumn")}`)?Ie()(e).data("column-id","ignore"):(t.preventDefault(),Ie()(a).select2("close")))}))})).on("select2:select",(e=>{const t=e.currentTarget,a=e.params.data.id;Ie()(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()})),Ie().map(Ie()(".mailpoet_subscribers_column_data_match"),(e=>{const t=Ie()(e).data("column-id");Ie()(e).val(t).trigger("change")}))},Pd=(e,t)=>{const a=[],i=[];let s,n,r,o;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&&(r=t[l],o=window.mailpoetColumns.map((e=>e.name)).indexOf(r),-1!==o?n=window.mailpoetColumns[o].id:r&&(/first|first name|given name/i.test(r)?n="first_name":/last|last name/i.test(r)&&(n="last_name"))),n="ignore"!==n&&-1===i.indexOf(n)?n:"ignore",a[l]={column_id:n},i.push(n)})),a},Ld=10;function Md({header:e=[],subscribers:t}){const a=Pd(t,e);return(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:m.U.I18n.t("matchData")}),a.map(((e,t)=>(0,h.jsx)("th",{children:(0,h.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 $d({header:e}){return(0,h.jsxs)("tr",{className:"mailpoet_header",children:[(0,h.jsx)("td",{}),e.map((e=>(0,h.jsx)("td",{children:e},e)))]})}function Bd({subscriber:e,index:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("td",{children:t}),e.map(((e,a)=>(0,h.jsx)("td",{children:e},`${e}-${t}-${a}`)))]})}function qd({subscribers:e,subscribersCount:t}){const a=". . .",i=Array(e[0].length).fill(a);return(0,h.jsxs)(h.Fragment,{children:[e.slice(0,Ld).map(((e,t)=>(0,h.jsx)("tr",{children:(0,h.jsx)(Bd,{subscriber:e,index:t+1})},`${e[0]}-${t}`))),t>Ld+1?(0,h.jsx)("tr",{children:(0,h.jsx)(Bd,{subscriber:i,index:a})},"filler"):null,t>Ld?(0,h.jsx)("tr",{children:(0,h.jsx)(Bd,{subscriber:e[t-1],index:t})},e[t-1][0]):null]})}function Hd({subscribersCount:e=0,subscribers:t=[],header:a=[]}){return(0,r.useLayoutEffect)((()=>{Od()})),(0,h.jsx)("div",{className:"subscribers_data",children:(0,h.jsxs)("table",{className:"mailpoet_subscribers widefat fixed",children:[(0,h.jsx)("thead",{children:(0,h.jsx)(Md,{header:a,subscribers:t})}),(0,h.jsxs)("tbody",{children:[a?(0,h.jsx)($d,{header:a}):null,(0,h.jsx)(qd,{subscribers:t,subscribersCount:e})]})]})})}Md.propTypes={subscribers:at().arrayOf(at().arrayOf(at().oneOfType([at().string,at().number]))).isRequired,header:at().arrayOf(at().string)},$d.propTypes={header:at().arrayOf(at().string).isRequired},Bd.propTypes={subscriber:at().arrayOf(at().oneOfType([at().string,at().number])).isRequired,index:at().node.isRequired},qd.propTypes={subscribersCount:at().number.isRequired,subscribers:at().arrayOf(at().arrayOf(at().oneOfType([at().string,at().number]))).isRequired},Hd.propTypes={subscribersCount:at().number,subscribers:at().arrayOf(at().arrayOf(at().oneOfType([at().string,at().number]))),header:at().arrayOf(at().string)};const Wd=e=>{m.U.Modal.popup({title:m.U.I18n.t("addNewList"),template:Ie()("#new_segment_template").html()}),Ie()("#new_segment_name").on("keypress",(e=>{13===e.which&&Ie()("#new_segment_process").trigger("click")})),Ie()("#new_segment_process").on("click",(()=>{const t=Ie()("#new_segment_name").val().trim(),a=Ie()("#new_segment_description").val().trim();m.U.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}),m.U.Modal.close()})).fail((e=>{e.errors.length>0&&(m.U.Notice.hide(),m.U.Notice.showApiErrorNotice(e,{positionAfter:"#new_segment_name"}))}))})),Ie()("#new_segment_cancel").on("click",(()=>{m.U.Modal.close()}))};function zd({setSelectedSegments:e}){const{segments:t}=(0,r.useContext)(l.F),{all:a,updateAll:i}=t,[s,n]=(0,r.useState)(a);(0,r.useLayoutEffect)((()=>{!function(t,a){const i=Ie()("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=Ie()('[data-id="notice_segmentSelection"]');t.currentTarget.value?Ie()('[data-id="notice_segmentSelection"]').remove():a.length||m.U.Notice.error(m.U.I18n.t("segmentSelectionRequired"),{static:!0,scroll:!0,id:"notice_segmentSelection",hideClose:!0});(t=>{e(t)})(ot.default.pluck(i.select2("data"),"id"))}))}(s)}),[s,e]);const o=t=>{!function(){const e=Ie()("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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:(0,h.jsxs)("label",{htmlFor:"mailpoet_segments_select",children:[m.U.I18n.t("pickLists"),(0,h.jsx)("p",{className:"description",children:m.U.I18n.t("pickListsDescription")})]})}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,h.jsx)("div",{className:"mailpoet-form-select mailpoet-form-input",children:(0,h.jsx)("select",{id:"mailpoet_segments_select","data-placeholder":m.U.I18n.t("select"),multiple:"multiple",children:(0,h.jsx)("option",{})})}),(0,h.jsx)(Te.$,{variant:"tertiary",onClick:()=>Wd(o),children:m.U.I18n.t("createANewList")})]})})]})}function Vd(){return(0,h.jsx)("p",{className:"description",children:Re()(m.U.I18n.t("consentSubscribed"),/\[link](.*?)\[\/link]/,(e=>(0,h.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 Gd({newSubscribersStatus:e,setNewSubscribersStatus:t}){const a=(0,r.useCallback)((e=>{t(e.target.value)}),[t]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,h.jsx)("label",{htmlFor:"new_subscribers_status",children:m.U.I18n.t("newSubscribersStatus")}),(0,h.jsx)(Vd,{})]}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsxs)(lt.Select,{id:"new_subscribers_status",placeholder:m.U.I18n.t("select"),name:"new_subscribers_status",onChange:a,defaultValue:e,children:[(0,h.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,h.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,h.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function Yd({existingSubscribersStatus:e,setExistingSubscribersStatus:t}){const a=(0,r.useCallback)((e=>{t(e.target.value)}),[t]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,h.jsx)("label",{htmlFor:"existing_subscribers_status",children:m.U.I18n.t("existingSubscribersStatus")}),(0,h.jsx)(Vd,{})]}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,h.jsxs)(lt.Select,{id:"existing_subscribers_status",placeholder:m.U.I18n.t("select"),name:"existing_subscribers_status",onChange:a,defaultValue:e,children:[(0,h.jsx)("option",{value:"dont_update",children:m.U.I18n.t("dontUpdate")}),(0,h.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,h.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,h.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function Kd({updateExistingSubscribers:e,setUpdateExistingSubscribers:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("updateExistingSubscribers")}),(0,h.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,h.jsx)(ct.s,{id:"update_existing_subscribers",name:"update_existing_subscribers",value:"1",checked:e,onCheck:()=>t(!0)}),(0,h.jsx)("label",{htmlFor:"update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersYes")}),(0,h.jsx)("span",{className:"mailpoet-gap"}),(0,h.jsx)(ct.s,{id:"dont_update_existing_subscribers",name:"update_existing_subscribers",value:"",checked:!e,onCheck:()=>t(!1)}),(0,h.jsx)("label",{htmlFor:"dont_update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersNo")})]})]})}zd.propTypes={setSelectedSegments:at().func.isRequired},Kd.propTypes={setUpdateExistingSubscribers:at().func.isRequired,updateExistingSubscribers:at().bool.isRequired},a(36202);const Jd=(e,t,a,i,s,n,r)=>{const o={},l=new(Ie().AsyncQueue);let d=0;const c=Date.now()/1e3,u={created:0,updated:0,errors:[],segments:[],tags:[]};m.U.Modal.progress(!0);const p=e.reduce(((e,t,a)=>(a%2e3==0&&e.push([]),e[e.length-1].push(t),e)),[]);ot.default.each(Ie()("select.mailpoet_subscribers_column_data_match"),((e,t)=>{const a=Ie()(e).data("column-id");"ignore"!==a&&(o[a]={index:t})})),ot.default.each(p,(()=>{l.add((r=>{r.pause(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"processImport",data:JSON.stringify({columns:o,subscribers:p[d],timestamp:c,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,m.U.Modal.setProgress((i=u,s=e,Math.floor((i.created+i.updated)/s.length*100))),r.run()})).fail((e=>{m.U.Modal.progress(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})),d+=1}))})),l.run(),l.onComplete((()=>{m.U.Modal.progress(!1),u.errors.length>0&&!u.updated&&!u.created?m.U.Notice.error(ot.default.flatten(u.errors)):(u.segments=ot.default.map(ot.default.filter(u.segments,(e=>t.includes(e.id))),(e=>e.name)),r(u))}))};function Qd({selectedTags:e,setSelectedTags:t}){const a=(0,r.useCallback)((({value:e})=>{t(e)}),[t]),i=m.U.tags.map((e=>e.name));return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"mailpoet-settings-label",children:[m.U.I18n.t("assignTagsLabel"),(0,h.jsx)("p",{className:"description",children:m.U.I18n.t("assignTagsDescription")})]}),(0,h.jsx)("div",{className:"mailpoet-settings-inputs mailpoet-import-tags",children:(0,h.jsx)(bt.g,{name:"tags",onChange:a,suggestedValues:i,selectedValues:e,placeholder:m.U.I18n.t("addNewTag")})})]})}function Zd({subscribersLimitForValidation:e,setStepDataManipulationData:t,stepMethodSelectionData:a}){const i=(0,Se.Zp)(),[s,n]=(0,r.useState)([]),[o,l]=(0,r.useState)(!0),[d,c]=(0,r.useState)("subscribed"),[m,u]=(0,r.useState)("dontUpdate"),[p,g]=(0,r.useState)([]);return(0,r.useEffect)((()=>{void 0===a&&i("/step_method_selection",{replace:!0})}),[a,i]),void 0===a?null:(0,h.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,h.jsx)(Fd,{stepMethodSelectionData:a}),(0,h.jsx)(Hd,{subscribersCount:a.subscribersCount,subscribers:a.subscribers,header:a.header}),(0,h.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,h.jsx)(zd,{setSelectedSegments:n}),(0,h.jsx)(Gd,{newSubscribersStatus:d,setNewSubscribersStatus:c}),(0,h.jsx)(Yd,{existingSubscribersStatus:m,setExistingSubscribersStatus:u}),(0,h.jsx)(Kd,{setUpdateExistingSubscribers:l,updateExistingSubscribers:o}),(0,h.jsx)(Qd,{selectedTags:p,setSelectedTags:g}),(0,h.jsx)(gd,{canGoNext:s.length>0,onPreviousAction:()=>i(function(e,t){return void 0===e||void 0===e.subscribersCount||e.subscribersCount<t?"/step_method_selection":"/step_input_validation"}(a,e)),onNextAction:()=>{Jd(a.subscribers,s,d,m,o,p,(e=>{t(e),i("/step_results")}))},isLastStep:!0})]})]})}function Xd({subscribersCount:e=0,segments:t=[],initialMessage:a=""}){if(e){let i=Re()(a,"%1$s",(()=>(0,h.jsx)("strong",{children:e.toLocaleString()},"%1$s")));return i=Re()(i,"%2$s",(()=>`"${t.join('", "')}"`)),(0,h.jsx)("p",{children:i})}return null}function ec({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?null:(0,h.jsx)("p",{children:m.U.I18n.t("importNoAction")})}function tc({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:(0,h.jsx)("b",{children:m.U.I18n.t("congratulationResult")})}),(0,h.jsx)("p",{children:Re()(m.U.I18n.t("suppressionListReminder"),/\[link](.*?)\[\/link]/,(e=>(0,h.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 ac({addedToSegmentWithWelcomeNotification:e=!1}){return e?(0,h.jsx)("p",{children:m.U.I18n.t("importNoWelcomeEmail")}):null}function ic({errors:e=[],createdSubscribers:t,updatedSubscribers:a,segments:i,addedToSegmentWithWelcomeNotification:s}){const n=(0,Se.Zp)();return(0,r.useEffect)((()=>{void 0===i&&0===e.length&&void 0===t&&void 0===a&&n("/step_method_selection",{replace:!0})}),[i,t,e.length,n,a]),e.length&&m.U.Notice.error(ot.default.flatten(e)),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsxs)("div",{className:"updated",children:[(0,h.jsx)(Xd,{subscribersCount:t,segments:i,initialMessage:m.U.I18n.t("subscribersCreated")}),(0,h.jsx)(Xd,{subscribersCount:a,segments:i,initialMessage:m.U.I18n.t("subscribersUpdated")}),(0,h.jsx)(ec,{createdSubscribers:t,updatedSubscribers:a}),(0,h.jsx)(ac,{addedToSegmentWithWelcomeNotification:s})]})}),(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(tc,{createdSubscribers:t,updatedSubscribers:a})}),(0,h.jsx)("div",{className:"mailpoet-settings-grid",children:(0,h.jsxs)("div",{className:"mailpoet-settings-save",children:[(0,h.jsx)(Te.$,{variant:"secondary",type:"button",onClick:()=>n("/step_method_selection"),children:m.U.I18n.t("importAgain")}),(0,h.jsx)(Te.$,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:m.U.I18n.t("viewSubscribers")})]})})]})}function sc(){const e=(0,Se.Zp)();return(0,h.jsx)(kd,{onProceed:()=>e("/step_method_selection")})}Zd.propTypes={stepMethodSelectionData:at().shape({duplicate:at().arrayOf(at().string),header:at().arrayOf(at().string),invalid:at().arrayOf(at().string),role:at().arrayOf(at().string),subscribersCount:at().number,subscribers:at().arrayOf(at().arrayOf(at().oneOfType([at().string,at().number])))}),subscribersLimitForValidation:at().number.isRequired,setStepDataManipulationData:at().func.isRequired},Xd.propTypes={segments:at().arrayOf(at().string.isRequired),subscribersCount:at().number,initialMessage:at().string},Xd.displayName="ResultMessage",ec.propTypes={createdSubscribers:at().number,updatedSubscribers:at().number},ec.displayName="NoAction",tc.propTypes={createdSubscribers:at().number,updatedSubscribers:at().number},tc.displayName="SuppressionListReminder",ac.propTypes={addedToSegmentWithWelcomeNotification:at().bool},ac.diplayName="NoWelcomeEmail",ic.propTypes={errors:at().arrayOf(at().string.isRequired),segments:at().arrayOf(at().string.isRequired),createdSubscribers:at().number,updatedSubscribers:at().number,addedToSegmentWithWelcomeNotification:at().bool},ic.displayName="StepResults",sc.displayName="StepCleanList";const nc=document.getElementById("import_container");function rc(){const[e,t]=(0,r.useState)(void 0),[a,i]=(0,r.useState)({}),s=(0,l.f)(window);return(0,h.jsx)(l.F.Provider,{value:s,children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(u.q,{}),(0,h.jsx)(pd,{children:(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:"/step_clean_list",element:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(sc,{})})}),(0,h.jsx)(Se.qh,{path:"/step_method_selection",element:(0,h.jsx)(Cd,{setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,h.jsx)(Se.qh,{path:"/step_input_validation",element:(0,h.jsx)(Rd,{stepMethodSelectionData:e})}),(0,h.jsx)(Se.qh,{path:"/step_data_manipulation",element:(0,h.jsx)(Zd,{stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:i})}),(0,h.jsx)(Se.qh,{path:"/step_results",element:(0,h.jsx)(ic,{errors:a.errors,createdSubscribers:a.created,updatedSubscribers:a.updated,segments:a.segments,addedToSegmentWithWelcomeNotification:a.added_to_segment_with_welcome_notification})}),(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(Se.C5,{to:"/step_clean_list"})})]})})]})})}nc&&((0,o.registerTranslations)(),(0,n.H)(nc).render((0,h.jsx)(rc,{})));var oc=a(38229),lc=a.n(oc);Ie()(document).ready((()=>{let e;if(!Ie()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=lc().compile(Ie()("#mailpoet_subscribers_export_template").html());function a(t){const a="mailpoet-disabled";"on"===t?e.removeClass(a):e.addClass(a)}Ie()("#mailpoet-export").html(t(window.exportData));const i=Ie()("#export_lists"),s=Ie()("#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 r(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;ot.default.contains(i,a)&&(t.preventDefault(),"deselect"===a?Ie()(t.target).val("").trigger("change"):(s=[],ot.default.each(e.find("option"),(e=>{const t=e.value;ot.default.contains(i,t)||s.push(t)})),Ie()(t.target).val(s).trigger("change")),Ie()(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=Ie()("#mailpoet-export-button"),window.segments.forEach((e=>{i.append(Ie()("<option></option>").attr("value",e.id).text(e.name))})),window.subscriberFieldsSelect2.forEach((e=>{e.text=e.name,e.children.forEach((e=>{e.name=(0,ws.escapeHTML)(e.name),e.text=(0,ws.escapeHTML)(e.name)}))})),r(i,window.segments),r(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(Ie()(e.target).hasClass("mailpoet-disabled"))return;m.U.Modal.loading(!0);const t=Ie()(':radio[name="option_format"]:checked').val();m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"ImportExport",action:"processExport",data:JSON.stringify({export_format_option:t,segments:!!window.exportData.segments&&i.val(),subscriber_fields:s.val()})}).always((()=>{m.U.Modal.loading(!1)})).done((e=>{const a=m.U.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>");Ie()("#export_result_notice").html(`<p>${a}</p>`).show(),window.location.href=e.data.exportFileURL,m.U.trackEvent("Subscribers export completed",{"Total exported":e.data.totalExported,"File Format":t})})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}))}));var dc=a(42109),cc=a(16609);function mc({children:e}){return(0,h.jsx)("div",{className:"mailpoet-steps-content",children:e})}const uc=(0,h.jsx)("svg",{width:"13",height:"11",viewBox:"0 0 13 11",children:(0,h.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"})}),pc=(0,h.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",children:(0,h.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 hc({onCheck:e,showError:t,checked:a,automationId:i,...s}){return(0,h.jsxs)("div",{className:Q()({"mailpoet-form-yesno":!0,"mailpoet-form-yesno-error":t,"mailpoet-disabled":s.disabled}),"data-automation-id":i,children:[(0,h.jsxs)("label",{children:[(0,h.jsx)("input",{type:"radio",checked:!0===a,onChange:()=>e(!0),...s}),(0,h.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-yes",children:uc})]}),(0,h.jsxs)("label",{children:[(0,h.jsx)("input",{type:"radio",checked:!1===a,onChange:()=>e(!1),...s}),(0,h.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-no",children:pc})]})]})}function gc({submitForm:e,loading:t,showCustomersImportSetting:a,isWizardStep:i=!1}){const[s,n]=(0,r.useState)(null),[l,d]=(0,r.useState)(!1===a?"unsubscribed":null),[c,m]=(0,r.useState)(!1),u=i?(0,Ae._x)("Continue","A label on a button","mailpoet"):(0,Ae._x)("Start using WooCommerce features","Submit button caption on the standalone WooCommerce setup page","mailpoet");let p;return"subscribed"===l&&(p=!0),"unsubscribed"===l&&(p=!1),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.TypographyHeading,{level:1,children:(0,Ae._x)("Power up your WooCommerce store","Title on the WooCommerce setup page","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("p",{children:(0,Ae.__)("MailPoet comes with powerful features for WooCommerce. Select features that you would like to use with your store.","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("form",{onSubmit:t=>(t.preventDefault(),m(!0),null===l||null===s||e(l,s),!1),children:[(0,h.jsxs)("div",{children:[a?(0,h.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,h.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,h.jsx)(hc,{showError:c&&null===l,checked:p,onCheck:e=>d(e?"subscribed":"unsubscribed"),name:"mailpoet_woocommerce_import_type",automationId:"woocommerce_import_type"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("p",{children:Re()((0,Ae.__)("Do you want to import your WooCommerce customers as subscribed? [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.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,h.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,h.jsx)("span",{children:"GDPR"}),(0,Ae._x)("To be compliant with privacy regulations, your customers must have explicitly accepted to receive your marketing emails.","GDPR compliance information","mailpoet")]})]})]}):null,(0,h.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,h.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,h.jsx)(hc,{showError:c&&null===s,checked:s,onCheck:e=>n(e),name:"mailpoet_woocommerce_tracking",automationId:"woocommerce_tracking"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("p",{children:Re()((0,Ae.__)("Collect more precise email and site engagement, and e-commerce metrics by enabling cookie tracking. [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/280-woocommerce-cookie-tracking",rel:"noopener noreferrer",target:"_blank",children:e},e)))}),(0,h.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,h.jsx)("span",{children:"GDPR"}),(0,Ae._x)("To be compliant, you should display a cookie tracking banner on your website.","GDPR compliance information","mailpoet")]})]})]})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,disabled:t,automationId:"submit_woocommerce_setup",children:u})]})]})}function _c(e){return(0,h.jsx)(ds,{illustrationUrl:e.illustrationUrl,children:e.children})}function fc({isWizardStep:e=!1,redirectToNextStep:t=null}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,cc.iK)("woocommerce"),l=(0,cc.iK)("tracking")[1],d=(0,cc.iK)("woocommerce_import_screen_displayed")[1],c=(0,cc.iK)("mailpoet_subscribe_old_woocommerce_customers")[1],u=e=>{i(!1),m.U.Notice.showApiErrorNotice(e,{scroll:!0})},p=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(u),g=(0,h.jsx)(_c,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(gc,{loading:a,submitForm:async(a,r)=>{i(!0);const o="basic"===m.U.trackingConfig.level?"basic":"partial",h={level:r?"full":o,opens:"merged"},g={enabled:"subscribed"===a?"1":""},_={woocommerce_import_screen_displayed:1,"mailpoet_subscribe_old_woocommerce_customers.enabled":g.enabled,"tracking.level":h.level,"woocommerce.accept_cookie_revenue_tracking.set":"1","tracking.opens":h.opens};await p(_),l(h),c(g),n({...s,accept_cookie_revenue_tracking:{...s.accept_cookie_revenue_tracking||{},set:"1"}}),d("1"),await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"setupWooCommerceInitialImport"}).fail(u),e?t():await(async()=>{e?await p({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,h.jsx)(mc,{children:g})}function xc({skipStep:e,loading:t,update_sender:a,submit_sender:i,sender:s=null}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:1,children:(0,Ae.__)("Start by configuring your sender information","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("p",{children:[(0,h.jsx)("b",{children:(0,Ae.__)("Default sender","mailpoet")}),(0,h.jsx)("br",{}),(0,Ae.__)("Enter details of the person or brand your subscribers expect to receive emails from","mailpoet")]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("form",{id:"mailpoet_sender_form",onSubmit:e=>{e.preventDefault(),Ie()("#mailpoet_sender_form").parsley().validate()&&i()},children:[(0,h.jsxs)(Ra.Grid.TwoColumns,{children:[(0,h.jsxs)("label",{htmlFor:"senderName",children:[(0,h.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Ae._x)("From Name","A form field label","mailpoet")}),(0,h.jsx)(o.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,h.jsxs)("label",{htmlFor:"senderAddress",children:[(0,h.jsx)("span",{className:"mailpoet-wizard-label",children:(0,Ae._x)("From Address","A form field label","mailpoet")}),(0,h.jsx)(o.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,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,children:(0,Ae._x)("Continue","A label on a button","mailpoet")}),(0,h.jsx)(o.Button,{href:"#skipStep",isDisabled:t,isFullWidth:!0,onClick:e,variant:"tertiary",children:(0,Ae._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}_c.propTypes={illustrationUrl:at().string.isRequired,children:at().oneOfType([at().arrayOf(at().node),at().node]).isRequired},fc.displayName="WooCommerceController",xc.displayName="WelcomeWizardSenderStep";const bc=e=>null==e;function vc({loading:e,submitForm:t}){const[a,i]=(0,r.useState)({tracking:void 0,libs3rdParty:void 0}),[s,n]=(0,r.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:1,children:(0,Ae.__)("Confirm privacy and data settings","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("form",{onSubmit:function(e){return e.preventDefault(),n(!0),bc(a.libs3rdParty)||bc(a.tracking)||t(a.tracking,a.libs3rdParty),!1},children:[(0,h.jsxs)("div",{children:[(0,h.jsxs)("div",{id:"mailpoet-wizard-3rd-party-libs",className:"mailpoet-wizard-woocommerce-option",children:[(0,h.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,h.jsx)(hc,{showError:s&&bc(a.libs3rdParty),onCheck:e=>{const t={libs3rdParty:e};i((e=>({...e,...t})))},checked:a.libs3rdParty,name:"mailpoet_libs_3rdParty"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("p",{children:(0,Ae.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-wizard-note",children:Re()((0,Ae.__)("MailPoet may load Google Fonts, DocsBot and other [link]3rd party libraries[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,((e,t)=>(0,h.jsx)("a",{href:"https://kb.mailpoet.com/article/338-what-3rd-party-libraries-we-use",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("div",{id:"mailpoet-wizard-tracking",className:"mailpoet-wizard-woocommerce-option",children:[(0,h.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,h.jsx)(hc,{showError:s&&bc(a.tracking),onCheck:e=>{const t={tracking:e};i((e=>({...e,...t})))},checked:a.tracking,name:"mailpoet_tracking"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("p",{children:(0,Ae.__)("Help improve MailPoet","mailpoet")}),(0,h.jsx)("div",{className:"mailpoet-wizard-note",children:Re()((0,Ae.__)("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,h.jsx)("a",{href:"https://kb.mailpoet.com/article/130-sharing-your-data-with-us",target:"_blank",rel:"noopener noreferrer",children:e},t)))})]})]})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(Te.$,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:e,disabled:e,children:(0,Ae._x)("Continue","A label on a button","mailpoet")})]})]})}vc.propTypes={loading:at().bool.isRequired,submitForm:at().func.isRequired},vc.displayName="WelcomeWizardUsageTrackingStep";var jc=a(32881);async function yc(e){await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}async function wc(e=null){await yc({version:window.mailpoet_version,installed_after_new_domain_restrictions:1,welcome_wizard_current_step:""}),window.location.href=e||window.finish_wizard_url}function Sc(){const[e,t]=(0,r.useState)(!1),a=e=>{e.preventDefault(),t(!0)},i=()=>t(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{children:Re()(m.U.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,h.jsx)("a",{onClick:a,href:"#",children:e},t)))}),e&&(0,h.jsxs)(ma.A,{className:"mailpoet-welcome-wizard-confirmation-modal",title:m.U.I18n.t("welcomeWizardMSSConfirmationModalTitle"),onRequestClose:i,children:[(0,h.jsx)("p",{children:m.U.mailFunctionEnabled?m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraph"):m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraphWithoutMailFunction")}),(0,h.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSConfirmationModalSecondParagraph")}),(0,h.jsxs)("div",{className:"mailpoet-welcome-wizard-confirmation-modal-buttons",children:[(0,h.jsx)(o.Button,{variant:"secondary",onClick:i,children:m.U.I18n.t("welcomeWizardMSSConfirmationModalGoBackButton")}),(0,h.jsx)(o.Button,{onClick:async e=>{e.preventDefault(),await wc("admin.php?page=mailpoet-settings#/mta/other")},children:m.U.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const Nc=(e,t,a=!1)=>{yc({welcome_wizard_current_step:t}),a?e(t,{replace:!0}):e(t)},Ic="https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase";function Uc(){const e=(0,Se.Zp)(),{step:t}=(0,Se.g)(),a=(0,cc.d4)("getKeyActivationState")();return(0,r.useEffect)((()=>{!0===a.isKeyValid&&Nc(e,`/steps/${t}/part/3`,!0)}),[a.isKeyValid,e,t]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSFirstPartTitle")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSFirstPartSubtitle")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-welcome-wizard-mss-list",children:(0,h.jsxs)(o.List,{children:[(0,h.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList1")}),(0,h.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList2")}),m.U.subscribersCount<1e3?(0,h.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Free")}):(0,h.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Paid")})]})}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,href:Ic,target:"_blank",rel:"noopener noreferrer",onClick:a=>function(e,t,a){e.preventDefault(),window.open(Ic),Nc(t,`/steps/${a}/part/2`)}(a,e,t),iconEnd:(0,h.jsx)(da.A,{icon:jc.A}),children:m.U.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(Sc,{})]})}var Cc=a(59866),kc=a(54787);function Ac(){const e=(0,Se.Zp)(),{step:t}=(0,Se.g)(),a=(0,cc.d4)("getKeyActivationState")();return(0,r.useEffect)((()=>{!0===a.isKeyValid&&Nc(e,`/steps/${t}/part/3`,!0)}),[a.isKeyValid,e,t]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Heading,{level:1,children:m.U.I18n.t("welcomeWizardMSSSecondPartTitle")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSSecondPartEnterKey")}),(0,h.jsx)("p",{children:Re()(m.U.I18n.t("welcomeWizardMSSSecondPartNoAccount"),/\[link](.*?)\[\/link]/g,((e,t)=>(0,h.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,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("label",{htmlFor:"mailpoet_premium_key",children:[(0,h.jsx)("span",{className:"mailpoet-wizard-label",children:m.U.I18n.t("welcomeWizardMSSSecondPartInputLabel")}),(0,h.jsx)(kc.M,{placeholder:m.U.I18n.t("welcomeWizardMSSSecondPartInputPlaceholder"),isFullWidth:!0})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(Cc.y,{label:m.U.I18n.t("welcomeWizardMSSSecondPartButton"),isFullWidth:!0}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(Sc,{})]})}function Tc(){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xt.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSThirdPartTitle")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartFirstParagraph")}),(0,h.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartSecondParagraph")}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",type:"button",onClick:()=>wc(),isFullWidth:!0,children:m.U.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function Ec(){const{pathname:e}=(0,Se.zy)(),{step:t}=(0,Se.g)(),a=(0,Se.Zp)(),i=(0,Se.zy)();return(0,r.useEffect)((()=>{i.pathname.includes("part")||Nc(a,`/steps/${t}/part/1`,!0)}),[t,e,a,i]),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:"part/1",element:(0,h.jsx)(Uc,{})}),(0,h.jsx)(Se.qh,{path:"part/2",element:(0,h.jsx)(Ac,{})}),(0,h.jsx)(Se.qh,{path:"part/3",element:(0,h.jsx)(Tc,{})})]})}const Rc=({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})},Dc=()=>{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},Fc=()=>Dc().length,Oc=async(e,t,a)=>{a<Fc()?Nc(e,`/steps/${a+1}`):t()};var Pc=a(57692);function Lc(){const e=(0,Se.g)(),t=(0,Se.Zp)(),a=Fc(),i=parseInt(e.step,10),[s,n]=(0,r.useState)(!1),[l,c]=(0,cc.iK)("sender"),m=(0,cc.iK)("analytics")[1],u=(0,cc.iK)("3rd_party_libs")[1];(0,r.useEffect)((()=>{(i>a||i<1)&&Nc(t,"/steps/1")}),[i,a,t]);const p=(0,ot.partial)(Oc,t,wc),g=(0,r.useCallback)((async(e,t)=>{const a={enabled:e?"1":""},i={enabled:t?"1":""},s={analytics:a,"3rd_party_libs":i};await yc(s),m(a),u(i)}),[m,u]),_=(0,r.useCallback)((async(e,t)=>{n(!0),await g(e,t),p(i),n(!1)}),[p,i,g]),f=(0,r.useCallback)((e=>{c({...l,...e})}),[l,c]),x=(0,r.useCallback)((async()=>{n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await g(!0,!0),await yc(Rc(l)).then((()=>p(i))),n(!1)}),[p,l,i,g]),b=(0,r.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 yc(Rc(t)).then((()=>{c(t),p(i)})),n(!1)}),[p,i,c,g]),v=(j=i,Dc()[j-1]||null);var j;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(St.x,{}),(0,h.jsx)(d.V,{logoWithLink:!1,children:(0,h.jsx)(Pc.g,{count:a,current:i,doneCallback:e=>{Nc(t,`/steps/${e}`)}})}),(0,h.jsxs)(mc,{children:["WelcomeWizardSenderStep"===v?(0,h.jsx)(_c,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(xc,{update_sender:f,submit_sender:x,skipStep:b,loading:s,sender:l})})}):null,"WelcomeWizardUsageTrackingStep"===v?(0,h.jsx)(_c,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(vc,{loading:s,submitForm:_})})}):null,"WelcomeWizardPitchMSSStep"===v?(0,h.jsx)(_c,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Ec,{})})}):null,"WizardWooCommerceStep"===v?(0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(fc,{isWizardStep:!0,redirectToNextStep:()=>p(i)})}):null]})]})}Lc.displayName="WelcomeWizardStepsController";const Mc=(0,o.withBoundary)(Lc),$c=(0,o.withBoundary)(fc);function Bc(){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.f)(window);return(0,h.jsx)(l.F.Provider,{value:a,children:(0,h.jsxs)(we.HashRouter,{children:[(0,h.jsx)(u.q,{}),(0,h.jsxs)(Se.BV,{children:[(0,h.jsx)(Se.qh,{path:"/steps/:step/*",element:(0,h.jsx)(Mc,{})}),(0,h.jsx)(Se.qh,{path:"/woocommerce",element:(0,h.jsx)($c,{})}),(0,h.jsx)(Se.qh,{path:"*",element:(0,h.jsx)(Se.C5,{to:e})})]})]})})}const qc=document.getElementById("mailpoet-wizard-container");function Hc(){const[e,t]=(0,r.useState)(null),a=(0,l.f)(window),i=a.notices.error;function s(s){const n=s.target.name,r=s.target.checked;m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"featureFlags",action:"set",data:{[n]:r?1:0}}).done((()=>{const i=e[n];i.value=r,t({...e,[n]:i});const s=`Feature '${n}' was ${r?"enabled":"disabled"}.`;a.notices.success((0,h.jsx)("p",{children:s}))})).fail((e=>{e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):i(e.errors.map((e=>(0,h.jsx)("p",{children:e.message},e.message))),{scroll:!0}))}))}return(0,r.useEffect)((()=>{m.U.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&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e):i((0,h.jsx)(h.Fragment,{children:e.errors.map((e=>(0,h.jsx)("p",{children:e.message})))}),{scroll:!0}))}))}),[i]),null===e?(0,h.jsx)("p",{children:"Loading experimental features..."}):0===Object.values(e).length?(0,h.jsx)("p",{children:"There are no experimental features at the moment."}):(0,h.jsx)(l.F.Provider,{value:a,children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.q,{}),Object.values(e).map((e=>{const t=`experimental-feature-${e.name}`;return(0,h.jsx)("div",{children:(0,h.jsxs)("label",{htmlFor:t,children:[(0,h.jsx)("input",{id:t,type:"checkbox",name:e.name,defaultChecked:e.value,onChange:s})," ",e.name]})},e.name)}))]})})}qc&&((0,o.registerTranslations)(),(0,dc.k)(),(0,n.H)(qc).render((0,h.jsx)(Bc,{})));const Wc=document.getElementById("experimental_features_container");Hc.displayName="ExperimentalFeatures",Wc&&((0,o.registerTranslations)(),(0,n.H)(Wc).render((0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Hc,{})})));var zc=a(28860);function Vc({log:e}){const[t,a]=(0,r.useState)(!1);return(0,h.jsxs)("tr",{children:[(0,h.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:e.name}),(0,h.jsx)("td",{role:"gridcell",children:(0,h.jsx)("div",{className:"mailpoet-logs-message "+(t?"mailpoet-logs-message-full":""),children:e.message})}),(0,h.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:(0,h.jsx)(o.Button,{dimension:"small",variant:"secondary",onClick:()=>{a(!t)},children:t?(0,Ae.__)("Show less","mailpoet"):(0,Ae.__)("Show more","mailpoet")})}),(0,h.jsx)("td",{className:"mailpoet-logs-min-width",role:"gridcell",children:m.U.Date.full(e.created_at)})]},`log-row-${e.id}`)}function Gc({logs:e,onFilter:t,originalFrom:a,originalTo:i,originalSearch:s,originalOffset:n,originalLimit:l}){const[d,c]=(0,r.useState)(a??void 0),[u,p]=(0,r.useState)(i??void 0),[g,_]=(0,r.useState)(n??""),[f,x]=(0,r.useState)(l??""),[b,v]=(0,r.useState)(s||""),j=(0,ka.curry)(((e,t)=>{e(null!==t?m.U.Date.format(t,{format:"Y-m-d"}):void 0)})),y=(0,r.useCallback)((()=>{const e={};d&&(e.from=d),u&&(e.to=u),g&&""!==g.trim()&&(e.offset=g),f&&""!==f.trim()&&(e.limit=f),b&&""!==b.trim()&&(e.search=b.trim()),t(e)}),[d,f,g,b,u,t]);return(0,h.jsxs)("div",{className:"mailpoet-listing mailpoet-logs",children:[(0,h.jsxs)("div",{className:"mailpoet-listing-header",children:[(0,h.jsxs)("div",{className:"mailpoet-listing-search",children:[(0,h.jsx)("label",{htmlFor:"search_input",className:"screen-reader-text",children:(0,Ae.__)("Search","mailpoet")}),(0,h.jsx)(o.Input,{dimension:"small",iconStart:zc.I,type:"search",id:"search_input",name:"s",onChange:e=>v(e.target.value),value:b,placeholder:(0,Ae.__)("Search","mailpoet")})]}),(0,h.jsxs)("div",{className:"mailpoet-listing-filters",children:[`${(0,Ae.__)("From","mailpoet")}:`,(0,h.jsxs)(o.ErrorBoundary,{children:[(0,h.jsx)(Oa.t,{dateFormat:"MMMM d, yyyy",onChange:j(c),maxDate:new Date,selected:d?Gr(d):void 0,dimension:"small"}),`${(0,Ae.__)("To","mailpoet")}:`,(0,h.jsx)(Oa.t,{dateFormat:"MMMM d, yyyy",onChange:j(p),maxDate:new Date,selected:u?Gr(u):void 0,dimension:"small"})]})]}),(0,h.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,h.jsx)("label",{htmlFor:"offset_input",className:"screen-reader-text",children:(0,Ae.__)("Offset","mailpoet")}),(0,h.jsx)(o.Input,{dimension:"small",id:"offset_input",name:"o",type:"number",onChange:e=>_(e.target.value),value:g,placeholder:(0,Ae.__)("Offset","mailpoet")})]}),(0,h.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,h.jsx)("label",{htmlFor:"limit_input",className:"screen-reader-text",children:(0,Ae.__)("Limit","mailpoet")}),(0,h.jsx)(o.Input,{dimension:"small",id:"limit_input",name:"l",type:"number",onChange:e=>x(e.target.value),value:f,placeholder:(0,Ae.__)("Limit","mailpoet")})]}),(0,h.jsx)(o.Button,{dimension:"small",onClick:y,children:(0,Ae._x)("Filter","verb","mailpoet")})]}),(0,h.jsxs)("table",{className:"mailpoet-listing-table widefat striped",role:"grid",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:(0,Ae.__)("Name","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Message","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Action","mailpoet")}),(0,h.jsx)("th",{children:(0,Ae.__)("Created On","mailpoet")})]})}),(0,h.jsx)("tbody",{children:(0,h.jsx)(o.ErrorBoundary,{children:e.map((e=>(0,h.jsx)(Vc,{log:e},`log-${e.id}`)))})})]})]})}Vc.displayName="Log",Gc.displayName="LogsList";const Yc=document.getElementById("mailpoet_logs_container");if(Yc){const e=new URL(window.location.href);(0,n.H)(Yc).render((0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(Gc,{logs:window.mailpoet_logs,originalFrom:e.searchParams.get("from")||window.mailpoet_logs_default_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 Kc=a(37035);function Jc({onRequestClose:e=ka.noop}){const[t,a]=(0,r.useState)(!1);return Ie()((e=>{e(document).on("click",".notice .mailpoet-js-button-fix-this",(()=>{a(!0)}))})),(0,h.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,h.jsx)(u.q,{}),t&&(0,h.jsx)(Kc.U,{onRequestClose:()=>{a(!1),e()}})]})}const Qc=document.getElementById("mailpoet_set_from_address_modal");Qc&&(0,n.H)(Qc).render((0,h.jsx)(Jc,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const Zc=e=>(async e=>{if("MailPoet"!==m.U.mtaMethod)return!0;const t=await(async()=>"MailPoet"!==m.U.mtaMethod?[]:(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"getVerifiedSenderDomains"})).data||[])(),a=(0,za.Y8)(e);return-1!==t.indexOf(a)||-1!==(await(async()=>"MailPoet"!==m.U.mtaMethod?[]:(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"getAuthorizedEmailAddresses"})).data||[])()).indexOf(e)})(e).then((e=>{if(!e)return m.U.Notice.error(m.U.I18n.t("mailerSendingNotResumedUnauthorized"),{scroll:!0}),m.U.trackEvent("Unauthorized email used",{"Unauthorized email source":"send"}),!1;m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"mailer",action:"resumeSending"}).done((()=>{m.U.Notice.success(m.U.I18n.t("mailerSendingResumedNotice"))})).fail((e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}))}));Ie()((e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",(e=>{Zc(e.target.value)}))}));var Xc=a(1123);const em=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),a=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,za.no)()||"some other"} page`;e&&e.type&&"email"===e.type?m.U.trackEvent("MSS in plugin authorize email",{"authorized email source":"modal","original page":t,wasSuccessful:"yes"}):e&&e.type&&"domain"===e.type&&m.U.trackEvent("MSS in plugin verify sender domain",{"verify sender domain source":"modal","original page":t,wasSuccessful:"yes"})})(e),(t||a)&&window.location.reload()};function tm(){const[e,t]=(0,r.useState)(""),[a,i]=(0,r.useState)("email");return(0,r.useEffect)((()=>{const e=e=>{e.preventDefault();const a=String(e?.target?.dataset?.email||""),s=String(e?.target?.dataset?.type||"");i(s||"email"),t(a)};Ie()((t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)}))}),[]),(0,h.jsx)(h.Fragment,{children:e&&(0,h.jsx)(Xc.J,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:em,showSenderEmailTab:"email"===a,showSenderDomainTab:"domain"===a,initialTab:"domain"===a?"sender_domain":"sender_email"})})}const am=document.getElementById("mailpoet_authorize_sender_email_modal");am&&(0,n.H)(am).render((0,h.jsx)(tm,{}));const im=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function sm(){const e=window.mailpoet_welcome_wizard_current_step,t="string"==typeof e&&e.startsWith("/steps");return(0,h.jsx)(o.Button,{onClick:im,dimension:"hero",children:t?(0,Ae.__)("Continue setup","mailpoet"):(0,Ae.__)("Begin setup","mailpoet")})}function nm(){return(0,h.jsx)("section",{className:"landing-header",children:(0,h.jsxs)("div",{className:"mailpoet-content-center",children:[(0,h.jsx)(xt.D,{level:0,children:(0,Ae.__)("Better email — without leaving WordPress","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("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,h.jsx)(sm,{})]})})}function rm(){return(0,h.jsx)("section",{className:"landing-footer",children:(0,h.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,h.jsxs)(xt.D,{level:4,children:[" ",(0,Ae.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,h.jsx)(sm,{})]})})}function om(){const e=[{slug:"item-1",title:(0,Ae.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,Ae.__)("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,Ae.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,Ae.__)("How do I send a newsletter?","mailpoet"),text:(0,Ae.__)("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,Ae.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,Ae.__)("Do I need a paid plan?","mailpoet"),text:(0,Ae.__)("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,Ae.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-choosing-your-mailpoet-plan"},{slug:"item-4",title:(0,Ae.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,Ae.__)('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,Ae.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,Ae.__)("How do I customize emails for my store?","mailpoet"),text:(0,Ae.__)("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,Ae.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/277-woocommerce-automatic-emails"}];return(0,h.jsxs)("section",{className:"landing-faq",children:[(0,h.jsxs)("div",{className:"mailpoet-content-center landing-faq-header",children:[(0,h.jsxs)(xt.D,{level:2,children:[" ",(0,Ae.__)("Frequently asked questions","mailpoet")," "]}),(0,h.jsx)("p",{children:Re()((0,Ae.__)("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,h.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]}),(0,h.jsx)("div",{className:"mailpoet-content-center landing-faq-mobile",children:(0,h.jsx)(xt.D,{level:2,children:(0,Ae.__)("FAQ","mailpoet")})}),(0,h.jsx)("div",{className:"mailpoet-faq-accordion",children:e.map((e=>(0,h.jsxs)("details",{children:[(0,h.jsxs)("summary",{children:[" ",(0,h.jsxs)("strong",{children:[" ",e.title," "]})," "]}),(0,h.jsxs)("div",{className:"content",children:[(0,h.jsx)("p",{children:e.text}),(0,h.jsx)("p",{children:(0,h.jsx)("a",{href:e.readMoreLink,rel:"noopener noreferrer",target:"_blank",children:e.readMoreText})})]})]},e.slug)))}),(0,h.jsxs)("div",{className:"mailpoet-content-center landing-faq-mobile",children:[(0,h.jsx)("p",{children:(0,Ae.__)("Can’t find what you’re looking for?","mailpoet")}),(0,h.jsx)("p",{children:Re()((0,Ae.__)("[link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,(e=>(0,h.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e)))})]})]})}nm.displayName="Landingpage Header",rm.displayName="Landingpage Footer",om.displayName="Landingpage FAQ";const lm={heroImage:`${m.U.cdnUrl}landingpage/landingpage-hero-image.png`,featureImages:{icon_1:`${m.U.cdnUrl}landingpage/feature_icon_1.png`,icon_2:`${m.U.cdnUrl}landingpage/feature_icon_2.png`,icon_3:`${m.U.cdnUrl}landingpage/feature_icon_3.png`,icon_4:`${m.U.cdnUrl}landingpage/feature_icon_4.png`},wooCommerceFeatureImages:{feature_1:`${m.U.cdnUrl}landingpage/woo_feature_automate_your_marketing.png`,feature_2:`${m.U.cdnUrl}landingpage/woo_feature_measure_revenue_per_email.png`,feature_3:`${m.U.cdnUrl}landingpage/woo_feature_let_your_brand_shine.png`,feature_4:`${m.U.cdnUrl}landingpage/woo_feature_rescue_abandoned_carts.png`}};function dm(){return(0,h.jsxs)("section",{className:"landing-content",children:[(0,h.jsxs)("div",{className:"hero-section mailpoet-content-center",children:[(0,h.jsx)("img",{src:lm.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,h.jsx)("br",{}),(0,h.jsx)("br",{}),(0,h.jsx)(xt.D,{level:4,children:(0,Ae.sprintf)((0,Ae.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"600,000+")}),(0,h.jsx)("br",{}),(0,h.jsxs)(Ra.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("img",{src:lm.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,h.jsx)("strong",{children:(0,Ae.__)("Deliver beautiful emails","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Choose from our pre-built templates or create your own with our drag-and-drop email builder.","mailpoet")})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)("img",{src:lm.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,h.jsx)("strong",{children:(0,Ae.__)("Grow your mailing list","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Use our custom sign-up forms to reach more subscribers while you deliver engaging content.","mailpoet")})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)("img",{src:lm.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,h.jsx)("strong",{children:(0,Ae.__)("Reach the right people","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("From the first hello to repeated purchases, send emails to the right people at the right time.","mailpoet")})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)("img",{src:lm.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,h.jsx)("strong",{children:(0,Ae.__)("Save time with automations","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Set up smart triggers based on user behavior to automate list management, email sending, and more.","mailpoet")})]})]})]}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsxs)("div",{className:"landingpage-wooCommerce-features",children:[(0,h.jsxs)("div",{className:"mailpoet-content-center",children:[(0,h.jsx)(xt.D,{level:2,children:(0,Ae.__)("MailPoet + WooCommerce","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,h.jsx)("br",{}),(0,h.jsxs)(Ra.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,h.jsx)("div",{children:(0,h.jsx)("img",{src:lm.wooCommerceFeatureImages.feature_1,alt:(0,Ae.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:(0,Ae.__)("Automate customer communication","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,h.jsxs)(Ra.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,h.jsx)("div",{children:(0,h.jsx)("img",{src:lm.wooCommerceFeatureImages.feature_2,alt:(0,Ae.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:(0,Ae.__)("Measure revenue per email","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,h.jsxs)(Ra.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,h.jsx)("div",{children:(0,h.jsx)("img",{src:lm.wooCommerceFeatureImages.feature_3,alt:(0,Ae.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:(0,Ae.__)("Let your brand shine","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,h.jsxs)(Ra.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,h.jsx)("div",{children:(0,h.jsx)("img",{src:lm.wooCommerceFeatureImages.feature_4,alt:(0,Ae.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:(0,Ae.__)("Rescue abandoned carts","mailpoet")}),(0,h.jsx)("p",{children:(0,Ae.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function cm(){return(0,h.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,h.jsxs)("main",{children:[(0,h.jsx)(St.x,{}),(0,h.jsx)(d.x,{}),(0,h.jsx)(Ze.V,{color:"#fff"}),(0,h.jsx)(nm,{}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(dm,{}),(0,h.jsx)("div",{className:"mailpoet-gap"}),(0,h.jsx)(om,{}),(0,h.jsx)(rm,{})]})})}dm.displayName="Landingpage Content",cm.displayName="Landingpage";const mm=document.getElementById("mailpoet_landingpage_container");mm&&((0,o.registerTranslations)(),(0,n.H)(mm).render((0,h.jsx)(o.ErrorBoundary,{children:(0,h.jsx)(cm,{})}))),a(21932)},21932:()=>{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"}))}))},87714: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,r={parse:function(a,i){var o=(i=i||{}).dynamicTyping||!1;if(j(o)&&(i.dynamicTypingFunction=o,o={}),i.dynamicTyping=o,i.transform=!!j(i.transform)&&i.transform,i.worker&&r.WORKERS_SUPPORTED){var l=function(){if(!r.WORKERS_SUPPORTED)return!1;var a,i,o=(a=t.URL||t.webkitURL||null,i=e.toString(),r.BLOB_URL||(r.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(o);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 r.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",o='"',l=o+o,d=!1,c=null,m=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||r.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&&(o=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+o),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(m=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var u=new RegExp(h(o),"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 r="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var o=Array.isArray(e)&&0<e.length,l=!Array.isArray(t[0]);if(o&&i){for(var d=0;d<e.length;d++)0<d&&(r+=s),r+=g(e[d],d);0<t.length&&(r+=n)}for(var c=0;c<t.length;c++){var m=o?e.length:t[c].length,u=!1,p=o?0===Object.keys(t[c]).length:0===t[c].length;if(a&&!o&&(u="greedy"===a?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===a&&o){for(var h=[],_=0;_<m;_++){var f=l?e[_]:_;h.push(t[c][f])}u=""===h.join("").trim()}if(!u){for(var x=0;x<m;x++){0<x&&!p&&(r+=s);var b=o&&l?e[x]:x;r+=g(t[c][b],x)}c<t.length-1&&(!a||0<m&&!p)&&(r+=n)}}return r}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,r.BAD_DELIMITERS)||-1<n.indexOf(s)||" "===n.charAt(0)||" "===n.charAt(n.length-1))?o+n+o:n}}};if(r.RECORD_SEP=String.fromCharCode(30),r.UNIT_SEP=String.fromCharCode(31),r.BYTE_ORDER_MARK="\ufeff",r.BAD_DELIMITERS=["\r","\n",'"',r.BYTE_ORDER_MARK],r.WORKERS_SUPPORTED=!a&&!!t.Worker,r.NODE_STREAM_INPUT=1,r.LocalChunkSize=10485760,r.RemoteChunkSize=5242880,r.DefaultDelimiter=",",r.Parser=g,r.ParserHandle=p,r.NetworkStreamer=d,r.FileStreamer=c,r.StringStreamer=m,r.ReadableStreamStreamer=u,t.jQuery){var o=t.jQuery;o.fn.parse=function(e){var a=e.config||{},i=[];return this.each((function(e){if("INPUT"!==o(this).prop("tagName").toUpperCase()||"file"!==o(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:o.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 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=o.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()},r.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=b(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 o=this._handle.parse(n,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var l=o.meta.cursor;this._finished||(this._partialLine=n.substring(l-this._baseIndex),this._baseIndex=l),o&&o.data&&(this._rowCount+=o.data.length);var d=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(i)t.postMessage({results:o,workerId:r.WORKER_ID,finished:d});else if(j(this._config.chunk)&&!a){if(this._config.chunk(o,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);o=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(o.data),this._completeResults.errors=this._completeResults.errors.concat(o.errors),this._completeResults.meta=o.meta),this._completed||!d||!j(this._config.complete)||o&&o.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),d||o&&o.meta.paused||this._nextChunk(),o}this._halted=!0},this._sendError=function(e){j(this._config.error)?this._config.error(e):i&&this._config.error&&t.postMessage({workerId:r.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=r.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=r.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,o=/^\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 x=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],x(f,d))}}}function v(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function y(){return f&&i&&(N("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+r.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,r=t[i];e.header&&(n=i>=_.length?"__parsed_extra":_[i]),e.transform&&(r=e.transform(r,n)),r=S(n,r),"__parsed_extra"===n?(s[n]=s[n]||[],s[n].push(r)):s[n]=r}return e.header&&(i>_.length?N("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,m+a):i<_.length&&N("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(o.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 N(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,o){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 r=0,o=0;o<i.length;o++)"\n"===i[o][0]&&r++;return r>=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 o,l,d,c;n=n||[",","\t","|",";",r.RECORD_SEP,r.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),x=0;x<f.data.length;x++)if(i&&v(f.data[x]))_++;else{var b=f.data[x].length;h+=b,void 0!==d?0<b&&(p+=Math.abs(b-d),d=b):d=b}0<f.data.length&&(h/=f.data.length-_),(void 0===l||p<=l)&&(void 0===c||c<h)&&1.99<h&&(l=p,o=u,c=h)}return{successful:!!(e.delimiter=o),bestDelimiter:o}}(s,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess);d.successful?e.delimiter=d.bestDelimiter:(i=!0,e.delimiter=r.DefaultDelimiter),f.meta.delimiter=e.delimiter}var c=b(e);return e.preview&&e.header&&c.preview++,t=s,a=new g(c),f=a.parse(t,n,o),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,o=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<r.BAD_DELIMITERS.indexOf(a))&&(a=","),s===a)throw new Error("Comment character same as delimiter");!0===s?s="#":("string"!=typeof s||-1<r.BAD_DELIMITERS.indexOf(s))&&(s=!1),"\n"!==i&&"\r"!==i&&"\r\n"!==i&&(i="\n");var c=0,m=!1;this.parse=function(r,u,p){if("string"!=typeof r)throw new Error("Input must be a string");var g=r.length,_=a.length,f=i.length,x=s.length,b=j(n),v=[],y=[],w=[],S=c=0;if(!r)return V();if(e.header&&!u){var N=r.split(i)[0].split(a),I=[],U={},C=!1;for(var k in N){var A=N[k];j(e.transformHeader)&&(A=e.transformHeader(A,k));var T=A,E=U[A]||0;for(0<E&&(C=!0,T=A+"_"+E),U[A]=E+1;I.includes(T);)T=T+"_"+E;I.push(T)}if(C){var R=r.split(i);R[0]=I.join(a),r=R.join(i)}}if(l||!1!==l&&-1===r.indexOf(t)){for(var D=r.split(i),F=0;F<D.length;F++){if(w=D[F],c+=w.length,F!==D.length-1)c+=i.length;else if(p)return V();if(!s||w.substring(0,x)!==s){if(b){if(v=[],q(w.split(a)),G(),m)return V()}else q(w.split(a));if(o&&o<=F)return v=v.slice(0,o),V(!0)}}return V()}for(var O=r.indexOf(a,c),P=r.indexOf(i,c),L=new RegExp(h(d)+h(t),"g"),M=r.indexOf(t,c);;)if(r[c]!==t)if(s&&0===w.length&&r.substring(c,c+x)===s){if(-1===P)return V();c=P+f,P=r.indexOf(i,c),O=r.indexOf(a,c)}else if(-1!==O&&(O<P||-1===P))w.push(r.substring(c,O)),c=O+_,O=r.indexOf(a,c);else{if(-1===P)break;if(w.push(r.substring(c,P)),z(P+f),b&&(G(),m))return V();if(o&&v.length>=o)return V(!0)}else for(M=c,c++;;){if(-1===(M=r.indexOf(t,M+1)))return p||y.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),W();if(M===g-1)return W(r.substring(c,M).replace(L,t));if(t!==d||r[M+1]!==d){if(t===d||0===M||r[M-1]!==d){-1!==O&&O<M+1&&(O=r.indexOf(a,M+1)),-1!==P&&P<M+1&&(P=r.indexOf(i,M+1));var $=H(-1===P?O:Math.min(O,P));if(r.substr(M+1+$,_)===a){w.push(r.substring(c,M).replace(L,t)),r[c=M+1+$+_]!==t&&(M=r.indexOf(t,c)),O=r.indexOf(a,c),P=r.indexOf(i,c);break}var B=H(P);if(r.substring(M+1+B,M+1+B+f)===i){if(w.push(r.substring(c,M).replace(L,t)),z(M+1+B+f),O=r.indexOf(a,c),M=r.indexOf(t,c),b&&(G(),m))return V();if(o&&v.length>=o)return V(!0);break}y.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),M++}}else M++}return W();function q(e){v.push(e),S=c}function H(e){var t=0;if(-1!==e){var a=r.substring(M+1,e);a&&""===a.trim()&&(t=a.length)}return t}function W(e){return p||(void 0===e&&(e=r.substring(c)),w.push(e),c=g,q(w),b&&G()),V()}function z(e){c=e,q(w),w=[],P=r.indexOf(i,c)}function V(e){return{data:v,errors:y,meta:{delimiter:a,linebreak:i,aborted:m,truncated:!!e,cursor:S+(u||0)}}}function G(){n(V()),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:x,resume:x};if(j(a.userStep)){for(var r=0;r<t.results.data.length&&(a.userStep({data:t.results.data[r],errors:t.results.errors,meta:t.results.meta},n),!i);r++);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 x(){throw new Error("Not implemented.")}function b(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var a in e)t[a]=b(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===r.WORKER_ID&&a&&(r.WORKER_ID=a.workerId),"string"==typeof a.input)t.postMessage({workerId:r.WORKER_ID,results:r.parse(a.input,a.config),finished:!0});else if(t.File&&a.input instanceof File||a.input instanceof Object){var i=r.parse(a.input,a.config);i&&t.postMessage({workerId:r.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,r},void 0===(i=a.apply(t,[]))||(e.exports=i)},38255: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)}},41669:e=>{"use strict";e.exports=jQuery}},e=>{e.O(0,[223],(()=>e(e.s=22624))),e.O()}]);