FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
mailpoet
/
assets
/
dist
/
js
Edit File: admin.js
/*! 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}},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},42509(e,t,a){"use strict";var i={};a.r(i),a.d(i,{hideProductDiscovery:()=>k,hideTaskList:()=>C,hideUpsell:()=>I});var s={};a.r(s),a.d(s,{getCanDisplayUpsell:()=>z,getCanImportWooCommerceSubscribers:()=>T,getCurrentTask:()=>H,getGlobalSubscriberStatsChange:()=>M,getHasForms:()=>P,getHasImportedSubscribers:()=>R,getIsFreeMailUser:()=>F,getIsNewUserForSenderDomainAuth:()=>D,getIsProductDiscoveryDone:()=>B,getIsProductDiscoveryHidden:()=>L,getIsTaskListHidden:()=>U,getIsUpsellHidden:()=>W,getIsWooCommerceActive:()=>q,getListsSubscriberStatsChange:()=>$,getMssActive:()=>O,getProductDiscoveryTasksStatus:()=>E,getTasksStatus:()=>A});var n=a(79124),r=a(7378),o=a(65490),l=a(73216),d=a(57370),c=a(35803),m=a(15198),p=a(59018),u=a(67268),h=a(99626),g=a(86106);function _({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,g.jsxs)(h.$,{type:"success",timeout:!1,onClose:l,children:[(0,g.jsx)("h3",{children:(0,u.__)("Good news! MailPoet can now send your website’s emails too","mailpoet")}),(0,g.jsxs)("p",{children:[(0,u.__)("All of your WordPress and WooCommerce emails are sent with your hosting company, unless you have an SMTP plugin. Would you like such emails to be delivered with MailPoet’s active sending method for better deliverability?","mailpoet")," ",(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/292-choose-how-to-send-your-wordpress-websites-emails",target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Read more.","mailpoet")})]}),(0,g.jsx)("p",{children:(0,g.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:(0,u._x)("Enable","verb","mailpoet")})})]})}_.displayName="TransactionalEmailsProposeOptInNotice";var f=a(29491),b=a(95603);function x(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(p.q,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(_,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed}),(0,g.jsx)(f.R,{mtaLog:m.U.mtaLog,mtaMethod:m.U.mtaMethod,isInline:!0})]})}var v=a(57257),j=a(79855),y=a(52710),w=a(54132),S=a(31528),N=a(55044);function*C(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*k(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*I(){return yield(0,N.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function U(e){return e.taskList.isTaskListHidden}function A(e){return e.taskList.tasksStatus}function E(e){return e.productDiscovery.tasksStatus}function T(e){return e.taskList.canImportWooCommerceSubscribers}function R(e){return e.taskList.hasImportedSubscribers}function D(e){return e.taskList.isNewUserForSenderDomainAuth}function F(e){return e.taskList.isFreeMailUser}function O(e){return e.taskList.mssActive}function P(e){return e.formsCount>0}function L(e){return e.productDiscovery.isHidden}function M(e){return e.subscribersStats.global}function $(e){return e.subscribersStats.lists}function B(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function q(e){return e.isWooCommerceActive}function H(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 W(e){return e.upsell.isHidden}function z(e){return e.upsell.upsellStatus?.canDisplay}function V(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 G="mailpoet/homepage",Y={};var K=a(56973),J=a(39528),Q=a(3698),Z=a.n(Q);function X(e,t,a){m.U.trackEvent(e,{ctaLabel:t},{send_immediately:!0},()=>{window.location.href=a})}function ee({title:e,titleCompleted:t="",slug:a,link:i,order:s,isCompleted:n,isActive:r,children:o=null}){const l=Z()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":n,"mailpoet-task-list__task--active":r}),d=()=>{X("Home Page Task",a,i)};return(0,g.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,g.jsx)("div",{className:"mailpoet-task-list__task-before",children:(0,g.jsx)("div",{className:"mailpoet-task-list__task-icon",children:n?(0,g.jsx)(K.A,{icon:J.A}):s})}),(0,g.jsxs)("div",{className:"mailpoet-task-list__task-content",children:[(0,g.jsx)("div",{className:"mailpoet-task-list__task-title",children:n&&t?t:e}),o]})]})}function te({onHide:e}){const{tasksStatus:t,currentTask:a,hasImportedSubscribers:i,canImportWooCommerceSubscribers:s,isNewUserForSenderDomainAuth:n,isFreeMailUser:r,mssActive:l}=(0,v.A)(e=>({tasksStatus:e(G).getTasksStatus(),currentTask:e(G).getCurrentTask(),hasImportedSubscribers:e(G).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(G).getCanImportWooCommerceSubscribers(),isNewUserForSenderDomainAuth:e(G).getIsNewUserForSenderDomainAuth(),isFreeMailUser:e(G).getIsFreeMailUser(),mssActive:e(G).getMssActive()}),[]),d=[];if(d.push((0,g.jsx)(ee,{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,g.jsx)(ee,{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,g.jsx)(ee,{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,g.jsxs)(ee,{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,g.jsxs)("p",{children:[m.U.I18n.t("noSubscribersQuestion")," ",(0,g.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:o.stopLinkPropagation,children:m.U.I18n.t("setUpForm")})]}),t.subscribersAdded&&!i&&(0,g.jsxs)("p",{children:[m.U.I18n.t("haveSubscribersQuestion")," ",(0,g.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,g.jsx)(ee,{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,g.jsx)("p",{children:m.U.I18n.t("improveDeliveryRates")})},"senderDomainAuthenticated"))}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-task-list__heading",children:[(0,g.jsx)("h1",{children:m.U.I18n.t("welcomeToMailPoet")}),(0,g.jsx)("p",{children:m.U.I18n.t("beginByCompletingSetup")}),(0,g.jsx)(j.A,{label:m.U.I18n.t("hideList"),icon:y.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]})]}),(0,g.jsx)("ul",{children:d.map(e=>e)}),!a&&(0,g.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("youAreSet")," ",(0,g.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissList")})]})]})}function ae({title:e,slug:t,link:a,description:i,doneMessage:s,imgSrc:n,isDone:r}){const o=()=>{X("Home Page Task",t,a)};return(0,g.jsxs)("li",{className:Z()("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,g.jsx)("img",{src:n,alt:e,width:124,height:72}),(0,g.jsx)("div",{className:"mailpoet-product-discovery__task-content",children:r?(0,g.jsx)("h3",{children:s}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h3",{children:`${e} →`}),i&&(0,g.jsx)("p",{children:i})]})}),(0,g.jsx)("div",{className:"mailpoet-product-discovery__task-after",children:r&&(0,g.jsx)("div",{className:"mailpoet-task-list__task-icon",children:(0,g.jsx)(K.A,{icon:J.A})})})]})}function ie({heading:e,description:t,children:a,headingAfter:i,className:s=""}){return(0,g.jsxs)("section",{className:Z()("mailpoet-homepage-section__container",s),children:[(0,g.jsxs)("header",{className:"mailpoet-homepage-section__heading",children:[(0,g.jsxs)("h2",{children:[e,t&&(0,g.jsx)("span",{children:t})]}),(0,g.jsx)("div",{className:"mailpoet-homepage-section__heading-after",children:i})]}),a]})}function se({onHide:e}){const{tasksStatus:t,isWooCommerceActive:a,isDiscoveryDone:i}=(0,v.A)(e=>({tasksStatus:e(G).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(G).getIsWooCommerceActive(),isDiscoveryDone:e(G).getIsProductDiscoveryDone()}),[]),s=[];return s.push((0,g.jsx)(ae,{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,g.jsx)(ae,{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,g.jsx)(ae,{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,g.jsx)(ae,{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.20241219.png`,isDone:t.brandWooEmails,doneMessage:m.U.I18n.t("brandWooEmailsDone")},"brandWooEmails")):s.push((0,g.jsx)(ae,{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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ie,{className:"mailpoet-homepage-product-discovery",heading:m.U.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,g.jsx)(j.A,{label:m.U.I18n.t("hideList"),icon:y.A,controls:[{title:m.U.I18n.t("hideList"),onClick:e,icon:null}]}),children:(0,g.jsx)("ul",{children:s.map(e=>e)})}),i&&(0,g.jsxs)("p",{className:"mailpoet-task-list__all-set",children:[m.U.I18n.t("allDone")," ",(0,g.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),e()},children:m.U.I18n.t("dismissTasks")})]})]})}var ne=a(63254),re=a(29441),oe=a(16109),le=a(38238),de=a(1595),ce=a(66248);function me({closable:e,onHide:t}){return(0,g.jsx)(ie,{className:"mailpoet-homepage-upsell",heading:m.U.I18n.t("accelerateYourGrowth"),headingAfter:e&&t?(0,g.jsx)(ce.Ay,{icon:ne.A,onClick:t,label:m.U.I18n.t("close")}):null,children:(0,g.jsxs)("div",{className:"mailpoet-homepage-upsell__content",children:[(0,g.jsxs)("ul",{children:[(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:re.A}),(0,g.jsx)("span",{children:m.U.I18n.t("detailedAnalytics")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:oe.A}),(0,g.jsx)("span",{children:m.U.I18n.t("advancedSubscriberSegmentation")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:le.A}),(0,g.jsx)("span",{children:m.U.I18n.t("emailMarketingAutomations")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(K.A,{icon:de.A}),(0,g.jsx)("span",{children:m.U.I18n.t("prioritySupport")})]})]}),(0,g.jsx)(ce.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 pe=a(14687),ue=a(53187);function he({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,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:s.tooltipTitle.toUpperCase()}),(0,g.jsx)("div",{className:"mailpoet-listing-stats-tooltip-description",children:m.U.I18n.t("engagementScoreDescription")}),(0,g.jsxs)("div",{className:"mailpoet-listing-stats-tooltip-content",children:[(0,g.jsx)(ue.E,{type:"unknown",name:m.U.I18n.t("unknownBadgeName")})," : ",a.unknown.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(ue.E,{type:"excellent",name:m.U.I18n.t("excellentBadgeName")})," : ",a.excellent.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(ue.E,{type:"good",name:m.U.I18n.t("goodBadgeName")})," : ",a.good.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(ue.E,{type:"average",name:m.U.I18n.t("averageBadgeName")})," : ",a.average.tooltipText]})]},`tooltip-${i}`);return(0,g.jsxs)("div",{className:"mailpoet-listing-stats-opened-clicked",children:[null!=t&&(0,g.jsxs)("div",{className:"mailpoet-listing-stats-percentages",children:[t.toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}),"%"]}),(0,g.jsx)("div",{children:(0,g.jsx)(ue.E,{isInverted:!0,type:s.type,name:s.name,tooltip:n,tooltipId:i,tooltipPlace:"top"})})]})}const ge=(e,t,a)=>{e.preventDefault(),X("Home Page Statistics Click",t,a)};function _e(){const{globalChange:e,listsChange:t,hasForms:a}=(0,v.A)(e=>({globalChange:e(G).getGlobalSubscriberStatsChange(),listsChange:e(G).getListsSubscriberStatsChange(),hasForms:e(G).getHasForms()}),[]),i=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,g.jsx)(ie,{className:"mailpoet-subscribers-stats",heading:m.U.I18n.t("subscribersHeading"),description:m.U.I18n.t("subscribersSectionDescription"),headingAfter:!i&&(0,g.jsxs)("span",{className:Z()({"mailpoet-decrease":e.changePercent<0}),children:[(0,g.jsx)(K.A,{icon:re.A}),e.changePercent<0&&"-",Math.abs(e.changePercent)>1e3?"∞%":`${Math.abs(e.changePercent)}%`]}),children:i?(0,g.jsxs)("div",{className:"mailpoet-subscribers-stats-empty",children:[(0,g.jsx)(K.A,{icon:re.A,viewBox:"-4 -4 32 32"}),a?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("subscriberCountHasNotChangeLongTime")}),(0,g.jsx)("a",{href:"admin.php?page=mailpoet-newsletters#/new",onClick:e=>ge(e,"campaigns","admin.php?page=mailpoet-newsletters#/new"),children:m.U.I18n.t("exploreCampaigns")})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("p",{children:[m.U.I18n.t("changesWillAppear"),(0,g.jsx)("br",{}),m.U.I18n.t("starBySettingUpForm")]}),(0,g.jsx)("a",{href:"admin.php?page=mailpoet-form-editor-template-selection",onClick:e=>ge(e,"new form","admin.php?page=mailpoet-form-editor-template-selection"),children:m.U.I18n.t("createForm")})]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-subscribers-stats-global-change",children:[(0,g.jsxs)("div",{children:[m.U.I18n.t("newSubscribers"),(0,g.jsx)("br",{}),(0,g.jsx)("span",{children:e.subscribed})]}),(0,g.jsxs)("div",{children:[m.U.I18n.t("unsubscribedSubscribers"),(0,g.jsx)("br",{}),(0,g.jsx)("span",{children:e.unsubscribed})]})]}),!!t.length&&(0,g.jsxs)("table",{className:"mailpoet-subscribers-stats-list-change-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:m.U.I18n.t("listName")}),(0,g.jsx)("th",{children:m.U.I18n.t("listScore")}),(0,g.jsx)("th",{children:m.U.I18n.t("subscribedSubscribers")}),(0,g.jsx)("th",{children:m.U.I18n.t("unsubscribedSubscribers")})]})}),(0,g.jsx)("tbody",{children:t.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:(0,g.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,g.jsx)("td",{children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)(he,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,g.jsx)("td",{children:e.subscribed}),(0,g.jsx)("td",{children:e.unsubscribed})]},e.id))})]})]})})}var fe=a(30221),be=a(59820);function xe({link:e,abstract:t,title:a,imgSrc:i}){return(0,g.jsxs)("a",{className:"mailpoet-resource-post",href:e,target:"_blank",rel:"noreferrer",children:[(0,g.jsx)("img",{src:i,alt:a,width:"292",height:"166"}),(0,g.jsx)("h3",{children:a}),(0,g.jsx)("p",{children:t})]})}function ve(){const[e,t]=(0,r.useState)(1),a=[(0,g.jsx)(xe,{link:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns",abstract:m.U.I18n.t("createAnEmailAbstract"),title:m.U.I18n.t("createAnEmailTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_email.20241219.png`},"createAnEmail"),(0,g.jsx)(xe,{link:"https://kb.mailpoet.com/article/297-create-a-subscription-form-with-our-editor",abstract:m.U.I18n.t("createAFormAbstract"),title:m.U.I18n.t("createAFormTitle"),imgSrc:`${m.U.cdnUrl}homepage/resources/add_form.png`},"createAForm"),(0,g.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,g.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,g.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,g.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,g.jsxs)(ie,{className:"mailpoet-homepage-resources",heading:m.U.I18n.t("learnMoreAboutEmailMarketing"),children:[(0,g.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,g.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,g.jsx)("a",{href:"#",onClick:s,title:m.U.I18n.t("previousPostsPage"),children:(0,g.jsx)(K.A,{icon:fe.A})}):(0,g.jsx)(K.A,{icon:fe.A}),e<Math.ceil(a.length/2)?(0,g.jsx)("a",{href:"#",onClick:i,title:m.U.I18n.t("nextPostsPage"),children:(0,g.jsx)(K.A,{icon:be.A})}):(0,g.jsx)(K.A,{icon:be.A})]})]})}function je(){const{isTaskListHidden:e,isProductDiscoveryHidden:t,isUpsellHidden:a,canDisplayUpsell:i}=(0,v.A)(e=>({isTaskListHidden:e(G).getIsTaskListHidden(),isProductDiscoveryHidden:e(G).getIsProductDiscoveryHidden(),isUpsellHidden:e(G).getIsUpsellHidden(),canDisplayUpsell:e(G).getCanDisplayUpsell()}),[]),{hideTaskList:s}=(0,pe.A)(G),{hideProductDiscovery:n}=(0,pe.A)(G),{hideUpsell:r}=(0,pe.A)(G);return(0,g.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(te,{onHide:s})}),!t&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(se,{onHide:n})}),e&&t&&i&&!a&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(me,{closable:!0,onHide:r})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(_e,{})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ve,{})})]})}function ye(){const[e,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{(()=>{const e=(0,w.A)(G,{actions:i,controls:Y,selectors:s,reducer:V,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,S.register)(e)})(),t(!0)},[]),(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(d.x,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(x,{}),e?(0,g.jsx)(je,{}):null]})}const we=document.getElementById("mailpoet_homepage_container");we&&((0,o.registerTranslations)(),(0,n.createRoot)(we).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ye,{})})));var Se=a(54593),Ne=a(99091),Ce=a(41669),ke=a.n(Ce),Ie=a(36692),Ue=a(15878),Ae=a(86853),Ee=a(41201),Te=a(97421);function Re({subscribersInPlan:e,subscribersInPlanLimit:t}){return!1===e?null:(0,g.jsxs)("span",{className:"mailpoet-segment-subscriber-count-message",children:[(0,g.jsx)("b",{children:t?(0,u.sprintf)((0,u._n)("%1$s / %2$s subscriber","%1$s / %2$s subscribers",e,"mailpoet"),e.toLocaleString(),t.toLocaleString()):(0,u.sprintf)((0,u._n)("%s subscriber","%s subscribers",e,"mailpoet"),e.toLocaleString())}),(0,g.jsx)(Te.Tooltip,{tooltip:(0,u.__)("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"})]})}var De=a(56017);function Fe({cacheCalculation:e}){const[t,a]=(0,r.useState)(!1),[i,s]=(0,r.useState)([]),n=(new Date).getTime()-new Date(e).getTime(),o=Math.floor(n/1e3/60);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"mailpoet-segment-subscriber-cache",children:(0,u.sprintf)((0,u._n)("Calculated %s min ago","Calculated %s mins ago",o,"mailpoet"),o.toLocaleString())}),(0,g.jsx)(De.$,{variant:"tertiary",onClick:()=>{a(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"settings",action:"recalculateSubscribersCountsCache"}).done(()=>{window.location.reload()}).fail(e=>{a(!1),e&&e.errors&&e.errors.length&&(JSON.stringify(e.errors).includes("reinstall_plugin")?m.U.Notice.showApiErrorNotice(e,{static:!0,scroll:!0}):s(e.errors.map(e=>e.message)))})},withSpinner:t,children:(0,u.__)("Recalculate","mailpoet")}),i.length>0&&(0,g.jsx)(h.$,{type:"error",children:i.map(e=>(0,g.jsx)("p",{children:e},e))})]})}function Oe(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:"\n #screen-meta-links { margin-bottom: -22px; }\n "}})}function Pe(){const e=(0,Ne.zy)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Oe,{}),(0,g.jsx)(d.x,{}),(0,g.jsxs)(Ee.z,{heading:(0,u.__)("Subscribers","mailpoet"),children:[(0,g.jsx)(Se.Link,{className:"page-title-action",to:{pathname:"/new",state:{backUrl:e?.pathname}},children:(0,g.jsx)("span",{"data-automation-id":"add-new-subscribers-button",children:(0,u.__)("Add new subscriber","mailpoet")})}),(0,g.jsx)("a",{className:"page-title-action not-small-screen",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:(0,u.__)("Import","mailpoet")}),(0,g.jsx)("a",{id:"mailpoet_export_button",className:"page-title-action not-small-screen",href:"?page=mailpoet-export",children:(0,u.__)("Export","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Re,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Fe,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]})]})}const Le=m.U.trackingConfig.emailTrackingEnabled,Me=()=>({onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,u.__)("1 subscriber was moved to the trash.","mailpoet"):(0,u.__)("%1$d subscribers 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,u.__)("1 subscriber was permanently deleted.","mailpoet"):(0,u.__)("%1$d subscribers 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,u.__)("1 subscriber has been restored from the trash.","mailpoet"):(0,u.__)("%1$d subscribers have been restored from the trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)},onNoItemsFound:e=>"bounced"===e&&!window.mailpoet_premium_active&&!window.mailpoet_mss_active&&(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,u.__)("Email addresses that are invalid or don't exist anymore are called \"bounced addresses\". It's a good practice not to send emails to bounced addresses to keep a good reputation with spam filters. Send your emails with MailPoet and we'll automatically ensure to keep a list of bounced addresses without any setup.","mailpoet")}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",className:"button-primary",children:(0,u.__)("Get premium version!","mailpoet")})})]})}),$e=(e,t,a,i)=>(0,g.jsxs)(Ue.a,{title:i,onRequestClose:t,isDismissible:!0,children:[(0,g.jsx)(Ae.L,{field:a}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",children:(0,u.__)("Apply","mailpoet")})]}),Be=()=>{const e=[{name:"moveToList",label:(0,u.__)("Move to list...","mailpoet"),onSelect:function(e,t){return $e(e,t,{id:"move_to_segment",name:"move_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},(0,u.__)("Move to list...","mailpoet"))},getData:function(){return{segment_id:Number(ke()("#move_to_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,u.__)("%1$d subscribers were moved to list <strong>%2$s</strong>.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"addToList",label:(0,u.__)("Add to list...","mailpoet"),onSelect:function(e,t){return $e(e,t,{id:"add_to_segment",name:"add_to_segment",endpoint:"segments",filter:function(e){return!(e.deleted_at||"default"!==e.type)}},(0,u.__)("Add to list...","mailpoet"))},getData:function(){return{segment_id:Number(ke()("#add_to_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,u.__)("%1$d subscribers were added to list <strong>%2$s</strong>.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromList",label:(0,u.__)("Remove from list...","mailpoet"),onSelect:function(e,t){return $e(e,t,{id:"remove_from_segment",name:"remove_from_segment",endpoint:"segments",filter:function(e){return"default"===e.type}},(0,u.__)("Remove from list...","mailpoet"))},getData:function(){return{segment_id:Number(ke()("#remove_from_segment").val())}},onSuccess:function(e){m.U.Notice.success((0,u.__)("%1$d subscribers were removed from list <strong>%2$s</strong>.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()).replace("%2$s",e.meta.segment))}},{name:"removeFromAllLists",label:(0,u.__)("Remove from all lists","mailpoet"),onSuccess:function(e){m.U.Notice.success((0,u.__)("%1$d subscribers were removed from all lists.","mailpoet").replace("%1$d",Number(e.meta.count).toLocaleString()))}},{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:Me().onTrash},{name:"unsubscribe",label:(0,u.__)("Unsubscribe","mailpoet"),onSelect:(e,t,a)=>{const i="all"!==a.selection?a.selected_ids.length:a.count;return(0,g.jsxs)(Ue.a,{title:(0,u.__)("Unsubscribe","mailpoet"),onRequestClose:t,isDismissible:!0,children:[(0,g.jsx)("p",{children:(0,u.__)("This action will unsubscribe %s subscribers from all lists. This action cannot be undone. Are you sure, you want to continue?","mailpoet").replace("%s",Number(i).toLocaleString())}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:e,dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:(0,u.__)("Apply","mailpoet")})]})}},{name:"addTag",label:(0,u.__)("Add tag...","mailpoet"),onSelect:function(e,t){return $e(e,t,{id:"add_tag",name:"add_tag",endpoint:"tags"},(0,u.__)("Add tag...","mailpoet"))},getData:function(){return{tag_id:Number(ke()("#add_tag").val())}},onSuccess:function(e){m.U.Notice.success((0,u.__)("Tag <strong>%1$s</strong> was added to %2$d subscribers.","mailpoet").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}},{name:"removeTag",label:(0,u.__)("Remove tag...","mailpoet"),onSelect:function(e,t){return $e(e,t,{id:"remove_tag",name:"remove_tag",endpoint:"tags"},(0,u.__)("Remove tag...","mailpoet"))},getData:function(){return{tag_id:Number(ke()("#remove_tag").val())}},onSuccess:function(e){m.U.Notice.success((0,u.__)("Tag <strong>%1$s</strong> was removed from %2$d subscribers.","mailpoet").replace("%1$s",e.meta.tag).replace("%2$d",Number(e.meta.count).toLocaleString()))}}],t=window.location.href.match(/group\[(.*?)\]/);return"unsubscribed"===(t?t[1]:null)?e.filter(e=>"unsubscribe"!==e.name):e},qe=e=>0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user);function He(){const e=(0,Ne.zy)(),t=(0,Ne.g)();return(0,g.jsxs)("div",{children:[(0,g.jsx)(Pe,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(Ie.l,{limit:window.mailpoet_listing_per_page,location:e,params:t,endpoint:"subscribers",onRenderItem:(t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions","column-username");let s="";switch(t.status){case"subscribed":s=(0,u.__)("Subscribed","mailpoet");break;case"unconfirmed":s=(0,u.__)("Unconfirmed","mailpoet");break;case"unsubscribed":s=(0,u.__)("Unsubscribed","mailpoet");break;case"inactive":s=(0,u.__)("Inactive","mailpoet");break;case"bounced":s=(0,u.__)("Bounced","mailpoet");break;default:s="Invalid"}const n=[];return t.subscriptions.length>0&&t.subscriptions.forEach(e=>{const t=(e=>{let t=null;return window.mailpoet_segments.forEach(a=>{a.id===e&&(t=a)}),t})(e.segment_id);null!==t&&"subscribed"===e.status&&n.push(t)}),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)(Se.Link,{className:"mailpoet-listing-title",to:`/edit/${t.id}`,state:{backUrl:e?.pathname},children:t.email}),(0,g.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[t.first_name," ",t.last_name]}),a]}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Status","mailpoet"),children:s}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Lists","mailpoet"),children:(0,g.jsx)(o.SegmentTags,{segments:n,dimension:"large"})}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Tags","mailpoet"),children:(0,g.jsx)(o.SubscriberTags,{subscribers:t.tags,variant:"wordpress",isInverted:!0})}),!0===Le?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,u.__)("Score","mailpoet"),children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)("a",{href:`#/stats/${t.id}`,children:(0,g.jsx)(he,{id:t.id,engagementScore:t.engagement_score})},`stats-link-${t.id}`)})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Confirmed on","mailpoet"),children:t.last_subscribed_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(t.last_subscribed_at),(0,g.jsx)("br",{}),m.U.Date.time(t.last_subscribed_at)]}):null}),(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Subscribed on","mailpoet"),children:t.created_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(t.created_at),(0,g.jsx)("br",{}),m.U.Date.time(t.created_at)]}):null})]})},columns:[{name:"email",label:(0,u.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,u.__)("Status","mailpoet"),sortable:!0},{name:"segments",label:(0,u.__)("Lists","mailpoet")},{name:"tags",label:(0,u.__)("Tags","mailpoet")},{name:"statistics",label:(0,u.__)("Score","mailpoet"),display:Le},{name:"last_subscribed_at",label:(0,u.__)("Subscribed on","mailpoet"),sortable:!0},{name:"created_at",label:(0,u.__)("Created on","mailpoet"),sortable:!0}],bulk_actions:Be(),item_actions:[{name:"statistics",label:(0,u.__)("Statistics","mailpoet"),link:function(e,t){return(0,g.jsx)(Se.Link,{to:`/stats/${e.id}`,state:{backUrl:t?.pathname},children:(0,u.__)("Statistics","mailpoet")})}},{name:"edit",label:(0,u.__)("Edit","mailpoet"),link:function(e,t){return(0,g.jsx)(Se.Link,{to:`/edit/${e.id}`,state:{backUrl:t?.pathname},children:(0,u.__)("Edit","mailpoet")})}},{name:"sendConfirmationEmail",className:"mailpoet-hide-on-mobile",label:(0,u.__)("Resend confirmation email","mailpoet"),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((0,u.__)("1 confirmation email has been sent.","mailpoet"))).fail(e=>m.U.Notice.showApiErrorNotice(e))}},{name:"trash",className:"mailpoet-hide-on-mobile"}],messages:Me(),sort_by:"created_at",sort_order:"desc",isItemDeletable:qe})]})}He.displayName="SubscriberList";var We=a(36637),ze=a.n(We),Ve=a(2726),Ge=a.n(Ve),Ye=a(70390),Ke=a.n(Ye),Je=a(23108),Qe=a.n(Je),Ze=a(58434);class Xe 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,g.jsx)(Ze.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})}}Xe.propTypes={onValueChange:Qe().func,onBlurEvent:Qe().func,field:Qe().shape({name:Qe().string.isRequired,defaultValue:Qe().string,id:Qe().string,className:Qe().string,size:Qe().oneOfType([Qe().string,Qe().number]),disabled:Qe().oneOfType([Qe().bool,Qe().func]),placeholder:Qe().string,validation:Qe().shape({"data-parsley-required":Qe().bool,"data-parsley-required-message":Qe().string,"data-parsley-type":Qe().string,"data-parsley-errors-container":Qe().string,maxLength:Qe().number}),customLabel:Qe().string,tooltip:Qe().string}).isRequired,item:Qe().object.isRequired};var et=a(4224);function tt(e){return(0,g.jsx)(et.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})}tt.propTypes={item:Qe().object.isRequired,field:Qe().shape({name:Qe().string,placeholder:Qe().string,defaultValue:Qe().string,validation:Qe().shape({"data-parsley-required":Qe().bool,"data-parsley-required-message":Qe().string,"data-parsley-type":Qe().string,"data-parsley-errors-container":Qe().string,maxLength:Qe().number}),className:Qe().string,customLabel:Qe().string,tooltip:Qe().string}).isRequired,onValueChange:Qe().func.isRequired};var at=a(95338),it=a(64996);class st 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,g.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(i=this.props.field.filter),at.default.isFunction(this.props.field.sortBy)&&(n=this.props.field.sortBy),a=n?at.default.map(at.default.sortBy(at.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,g.jsx)("option",{value:e,children:this.props.field.values[e]},`option-${e}`));return(0,g.jsxs)(it.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]})}}st.propTypes={onValueChange:Qe().func,field:Qe().shape({name:Qe().string.isRequired,values:Qe().objectOf(Qe().string),placeholder:Qe().string,filter:Qe().func,sortBy:Qe().func,validation:Qe().shape({"data-parsley-required":Qe().bool,"data-parsley-required-message":Qe().string,"data-parsley-type":Qe().string,"data-parsley-errors-container":Qe().string,maxLength:Qe().number})}).isRequired,item:Qe().object.isRequired,automationId:Qe().string};var nt=a(83658);class rt 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,g.jsx)("p",{children:(0,g.jsx)(nt.s,{checked:e===t,value:t,onCheck:this.onValueChange,name:this.props.field.name,children:this.props.field.values[t]})},`radio-${t}`));return(0,g.jsx)("div",{children:t})}}rt.propTypes={onValueChange:Qe().func,field:Qe().shape({name:Qe().string.isRequired,values:Qe().objectOf(Qe().string)}).isRequired,item:Qe().object.isRequired};var ot=a(34226);class lt 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,g.jsx)("p",{children:(0,g.jsx)(ot.S,{value:"1",checked:e,name:this.props.field.name,onCheck:this.onValueChange,children:this.props.field.values[t]})},`checkbox-${t}`));return(0,g.jsx)("div",{children:t})}}function dt(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));const a=ze()().year();for(let e=a;e>=a-100;e-=1)t.push((0,g.jsx)("option",{value:e,children:e},e));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[year]`,value:e.year,onChange:e.onValueChange,children:t})}function ct(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));for(let a=1;a<=12;a+=1)t.push((0,g.jsx)("option",{value:a,children:e.monthNames[a-1]},a));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[month]`,value:e.month,onChange:e.onValueChange,children:t})}function mt(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));for(let e=1;e<=31;e+=1)t.push((0,g.jsx)("option",{value:e,children:e},e));return(0,g.jsx)(o.Select,{isMinWidth:!0,name:`${e.name}[day]`,value:e.day,onChange:e.onValueChange,children:t})}lt.propTypes={onValueChange:Qe().func.isRequired,field:Qe().shape({name:Qe().string.isRequired,values:Qe().objectOf(Qe().string)}).isRequired,item:Qe().object.isRequired},dt.propTypes={name:Qe().string.isRequired,placeholder:Qe().string.isRequired,onValueChange:Qe().func.isRequired,year:Qe().oneOfType([Qe().string,Qe().number]).isRequired},ct.propTypes={name:Qe().string.isRequired,placeholder:Qe().string.isRequired,onValueChange:Qe().func.isRequired,month:Qe().oneOfType([Qe().string,Qe().number]).isRequired,monthNames:Qe().arrayOf(Qe().string).isRequired},mt.propTypes={name:Qe().string.isRequired,placeholder:Qe().string.isRequired,onValueChange:Qe().func.isRequired,day:Qe().oneOfType([Qe().string,Qe().number]).isRequired};class pt 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=ze()(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,g.jsx)(dt,{onValueChange:this.onValueChange,name:this.props.field.name,year:this.state.year,placeholder:this.props.field.year_placeholder},"year");case"MM":return(0,g.jsx)(ct,{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,g.jsx)(mt,{onValueChange:this.onValueChange,name:this.props.field.name,day:this.state.day,placeholder:this.props.field.day_placeholder},"day");default:return(0,g.jsx)("div",{children:"Invalid date type"})}});return(0,g.jsx)("div",{children:a})}}pt.propTypes={item:Qe().object.isRequired,field:Qe().shape({name:Qe().string,day_placeholder:Qe().string,month_placeholder:Qe().string,year_placeholder:Qe().string,params:Qe().object}).isRequired,onValueChange:Qe().func.isRequired};var ut=a(53919),ht=a(76718);function gt(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,g.jsx)(ht.g,{label:e.field.label,name:e.field.name,placeholder:e.field.placeholder,selectedValues:t,suggestedValues:a,onChange:e.onValueChange})}class _t extends r.Component{renderField=e=>{let t,a=!1;e.field.description&&(a=(0,g.jsx)("p",{className:"description",children:e.field.description}));let i=e.field;switch(void 0!==e.field.field&&(i=ke().merge(i,e.field.field)),i.type){case"text":t=(0,g.jsx)(Xe,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"textarea":t=(0,g.jsx)(tt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"select":t=(0,g.jsx)(st,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"radio":t=(0,g.jsx)(rt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"checkbox":t=(0,g.jsx)(lt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"selection":t=(0,g.jsx)(Ae.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,g.jsx)(pt,{onValueChange:e.onValueChange,field:e.field,item:e.item,automationId:e.automationId,inline:e.inline,description:e.description});break;case"reactComponent":t=(0,g.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,g.jsx)(gt,{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,g.jsxs)("div",{className:Z()("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,g.jsx)(ut.D,{level:4,children:(0,g.jsx)("label",{htmlFor:`field_${this.props.field.name}`,children:this.props.field.label})}));let i=!1;return this.props.field.tip&&(i=(0,g.jsx)("p",{className:"mailpoet-form-description",children:this.props.field.tip})),(0,g.jsxs)("div",{className:`mailpoet-form-field-${this.props.field.name} form-field-row-${this.props.field.name}`,children:[a,i,e]})}}_t.propTypes={onValueChange:Qe().func,field:Qe().shape({name:Qe().string.isRequired,values:Qe().objectOf(Qe().string),tip:Qe().oneOfType([Qe().array,Qe().string]),label:Qe().string,fields:Qe().arrayOf(Qe().object),description:Qe().string,onWrapperClick:Qe().func,disabled:Qe().oneOfType([Qe().func,Qe().bool])}).isRequired,item:Qe().object.isRequired},(0,o.registerTranslations)();class ft 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):Ke()(()=>{const t=ke()(".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&&(Ke()(()=>{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,g.jsx)("div",{className:"mailpoet_notice notice inline error is-dismissible",children:(0,g.jsx)("p",{children:e.message})},`error-${e.message}`)));const l=Z()("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,g.jsx)(_t,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)});let p=!1;return p=e||(0,g.jsx)(o.Button,{type:"submit",isDisabled:this.state.loading,children:(0,u.__)("Save","mailpoet")}),(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-form-content-around",children:d}),(0,g.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,g.jsxs)("div",{className:"mailpoet-form-grid",children:[m,(0,g.jsx)("div",{className:"mailpoet-form-actions",children:p})]})]}),(0,g.jsx)("div",{className:"mailpoet-form-content-around",children:c})]})}}function bt(e){const t=(0,Ne.Zp)();return(0,g.jsx)(ft,{...e,navigate:t})}ft.propTypes={params:Qe().shape({id:Qe().string}),location:Qe().shape({pathname:Qe().string}),item:Qe().object,errors:Qe().arrayOf(Qe().object),endpoint:Qe().string,fields:Qe().arrayOf(Qe().object),messages:Qe().shape({onUpdate:Qe().func,onCreate:Qe().func}),loading:Qe().bool,children:Qe().array,id:Qe().string,automationId:Qe().string,beforeFormContent:Qe().func,afterFormContent:Qe().func,onItemLoad:Qe().func,isValid:Qe().func,onChange:Qe().func,onSubmit:Qe().func,onSuccess:Qe().func,navigate:Qe().func.isRequired};var xt=a(51066);const vt=[{name:"email",label:m.U.I18n.t("email"),type:"text",disabled:function(e){return Boolean(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 Boolean(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 Boolean(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||0},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:String(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=""}vt.push(t)});const jt={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 yt(e){if(Number(e.wp_user_id)>0)return(0,g.jsx)("p",{className:"description",children:Ge()(m.U.I18n.t("WPUserEditNotice"),/\[link\](.*?)\[\/link\]/g,(t,a)=>(0,g.jsx)("a",{href:`user-edit.php?user_id=${e.wp_user_id}`,children:t},a))})}function wt(e){return(0,g.jsxs)(g.Fragment,{children:[e?.unsubscribes?.map(e=>{const t=ze()(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?Ge()(m.U.I18n.t("unsubscribedNewsletter").replace("%1$d",t),/\[link\]/g,(t,a)=>(0,g.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,g.jsx)("p",{className:"description",children:a},a)}),(0,g.jsxs)("p",{className:"description",children:[(0,g.jsx)("strong",{children:m.U.I18n.t("tip")})," ",m.U.I18n.t("customFieldsTip")]})]})}function St(){const e=(0,Ne.zy)(),t=(0,Ne.g)(),a=(0,Ne.Zp)(),i=e.state?.backUrl||"/";return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Ee.z,{heading:t.id?(0,u.__)("Edit subscriber","mailpoet"):(0,u.__)("Add new subscriber","mailpoet"),headingPrefix:(0,g.jsx)(Ee.o,{onClick:()=>a(i),label:m.U.I18n.t("backToList")})}),(0,g.jsx)(xt.X,{}),(0,g.jsx)(bt,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:vt,params:t,messages:jt,beforeFormContent:yt,afterFormContent:wt,onSuccess:()=>a(i)})]})}St.displayName="SubscriberForm";var Nt=a(47632);function Ct({email:e}){const t=(0,Ne.zy)(),a=t.state?.backUrl||"/";return(0,g.jsxs)(ut.D,{level:1,className:"mailpoet-title",children:[(0,g.jsx)("span",{children:m.U.I18n.t("statsHeading").replace("%s",e)}),(0,g.jsx)(Se.Link,{className:"mailpoet-button button button-secondary button-small",to:a,children:m.U.I18n.t("backToList")})]})}var kt=a(8055);function It({stats:e,subscriber:t}){return(0,g.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,g.jsx)("div",{className:"mailpoet-listing",children:(0,g.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.timeframe},e.timeframe))]})}),(0,g.jsxs)("tbody",{children:[(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:m.U.I18n.t("statsSentEmail")}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.total_sent},e.timeframe))]}),(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:(0,g.jsx)(kt.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,g.jsx)("td",{children:a},e.timeframe)})]}),m.U.trackingConfig.opensSeparated&&(0,g.jsxs)("tr",{children:[(0,g.jsxs)("td",{children:[(0,g.jsx)(kt.v,{children:m.U.I18n.t("statsMachineOpened")}),(0,g.jsx)(Te.Tooltip,{tooltip:Ge()(m.U.I18n.t("statsMachineOpenedTooltip"),/\[link](.*?)\[\/link]/,e=>(0,g.jsx)("span",{style:{pointerEvents:"all"},children:(0,g.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,g.jsx)("td",{children:a},e.timeframe)})]}),(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:(0,g.jsx)(kt.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,g.jsx)("td",{children:a},e.timeframe)})]}),(0,g.jsxs)("tr",{children:[(0,g.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,g.jsx)("td",{children:s},e.timeframe)})]}),(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:m.U.I18n.t("statisticsColumn")}),(0,g.jsx)("td",{colSpan:e.periodic_stats.length,children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)(he,{id:t.id,engagementScore:t.engagement_score})})})]})]})]})})})}function Ut({stats:e}){return(0,g.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,g.jsx)("div",{className:"mailpoet-listing",children:(0,g.jsxs)("table",{className:"mailpoet-listing-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.timeframe},e.timeframe))]})}),(0,g.jsxs)("tbody",{children:[(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:"Orders created"}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.woocommerce.count.toLocaleString()},e.timeframe))]}),(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:"Total revenue"}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.woocommerce.formatted},e.timeframe))]}),(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:"Average revenue"}),e.periodic_stats.map(e=>(0,g.jsx)("td",{children:e.woocommerce.formatted_average},e.timeframe))]})]})]})})})}var At=a(37024),Et=a(13624),Tt=a(95176);const{subscribersLimitReached:Rt,subscribersLimit:Dt,subscribersCount:Ft,premiumActive:Ot,hasValidApiKey:Pt,hasValidPremiumKey:Lt,isPremiumPluginInstalled:Mt,pluginPartialKey:$t}=m.U,Bt=Pt||Lt,qt=e=>(0,g.jsx)("p",{children:Ge()(e,/(\[subscribersCount]|\[subscribersLimit])/g,e=>"[subscribersCount]"===e?Ft:Dt)}),Ht=(e,t,a="_blank")=>(0,g.jsx)(De.$,{href:t,target:a,rel:"noopener noreferrer",children:e});function Wt({message:e,actionButton:t,capabilities:a={}}){let i,s,n=(0,u.__)("This is a Premium feature","mailpoet");if(!Lt||Mt&&Ot)if(Rt){i=qt((0,u.__)("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=Bt?m.U.MailPoetComUrlFactory.getUpgradeUrl($t):m.U.MailPoetComUrlFactory.getPurchasePlanUrl(+Ft+1,null,null,null);s=Ht((0,u.__)("Upgrade your plan","mailpoet"),e)}else if(Pt&&!Lt||Lt&&Object.keys(a).some(e=>m.U.capabilities[e].isRestricted)){n=(0,u.__)("Upgrade your plan","mailpoet"),i=e;const t=m.U.MailPoetComUrlFactory.getUpgradeUrl($t,{s:Ft,capabilities:a});s=Ht((0,u.__)("Upgrade","mailpoet"),t)}else i=e,s=t;else i=qt((0,u.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),r=Mt?(0,u.__)("Activate MailPoet Premium plugin","mailpoet"):(0,u.__)("Download MailPoet Premium plugin","mailpoet"),s=(0,g.jsx)(Tt.Wr,{buttonText:r});var r;return(0,g.jsx)(Et.P,{title:n,message:i,actionButton:s})}function zt(){return(0,g.jsx)("div",{className:"mailpoet-listing",children:(0,g.jsxs)("table",{className:"mailpoet-listing-table","data-automation-id":"subscriber-stats-no-access",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,u.__)("E-mail","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Action","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Count","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Action on","mailpoet")})]})}),(0,g.jsx)("tbody",{children:(0,g.jsx)("tr",{children:(0,g.jsx)("td",{colSpan:4,children:(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,g.jsx)(Wt,{message:(()=>{const e=(0,u.__)("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,g.jsx)("p",{children:Ge()(e,/\[link](.*?)\[\/link]/g,e=>(0,g.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e))})})(),actionButton:(0,g.jsx)(De.$,{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,u.__)("Upgrade","mailpoet")}),capabilities:{detailedAnalytics:!0}})})})})})]})})}function Vt({params:e,location:t}){const a=(0,r.useMemo)(()=>At.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",()=>(0,g.jsx)(zt,{}),e,t),[t,e]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:4,children:(0,u.__)("Opened emails","mailpoet")}),(0,g.jsx)(a,{})]})}function Gt(e){return"string"==typeof e?m.U.Date.format(e):(0,u.__)("never","mailpoet")}function Yt({stats:e}){const t=[{label:(0,u.__)("Last click","mailpoet"),date:e.last_click||null},{label:(0,u.__)("Last engagement","mailpoet"),date:e.last_engagement||null},{label:(0,u.__)("Last open","mailpoet"),date:e.last_open||null},{label:(0,u.__)("Last page view","mailpoet"),date:e.last_page_view||null},{label:(0,u.__)("Last sending","mailpoet"),date:e.last_sending||null}];return e.is_woo_active&&t.push({label:(0,u.__)("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,g.jsx)("div",{className:"mailpoet-tab-content mailpoet-subscriber-stats-summary",children:(0,g.jsx)("div",{className:"mailpoet-listing",children:(0,g.jsx)("table",{className:"mailpoet-listing-table",children:(0,g.jsx)("tbody",{children:t.map(({label:e,date:t})=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:e}),(0,g.jsx)("td",{children:(0,g.jsx)("b",{children:Gt(t)})})]},e))})})})})}function Kt(){const e=(0,Ne.g)(),t=(0,Ne.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,g.jsx)(Nt.R,{}):a?(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,g.jsx)(Ct,{email:a.email}),(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-summary-grid",children:[(0,g.jsx)(It,{stats:a,subscriber:{id:Number(e.id),engagement_score:a.engagement_score}}),(0,g.jsx)(Yt,{stats:a}),a.is_woo_active&&(0,g.jsx)(Ut,{stats:a})]}),(0,g.jsx)(Vt,{params:e,location:t})]}):null}function Jt(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"/new",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(St,{})})}),(0,g.jsx)(Ne.qh,{path:"/edit/:id",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(St,{})})}),(0,g.jsx)(Ne.qh,{path:"/stats/:id/*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Kt,{})})}),(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(He,{})})})]})]})})}Kt.displayName="SubscriberStats";const Qt=document.getElementById("subscribers_container");Qt&&((0,o.registerTranslations)(),(0,n.createRoot)(Qt).render((0,g.jsx)(Jt,{})));var Zt=a(32785),Xt=a(48194),ea=a(92449),ta=a(77780),aa=a(74476),ia=a(98968);function sa({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,u.__)("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?(m.U.trackEvent("New Email Editor > try new email editor modal opened",{},{send_immediately:!0}),(0,g.jsxs)(ia.A,{title:(0,u.__)("Try the new email editor","mailpoet"),onRequestClose:()=>{m.U.trackEvent("New Email Editor > try new email editor modal closed"),t()},className:"mailpoet-new-editor-modal",children:[(0,g.jsxs)("div",{className:"mailpoet-new-editor-modal-image",children:[(0,g.jsx)("span",{className:"mailpoet-new-editor-modal-image__beta_label",children:(0,u.__)("Alpha version","mailpoet")}),(0,g.jsx)("img",{src:`${m.U.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,u.__)("Try the new email editor","mailpoet"),width:"324",height:"130"})]}),(0,g.jsx)("p",{children:(0,u.__)("Take a first look at our new email editor. It introduces a more flexible, modern way to design your emails. This version is still evolving, and your feedback will help guide what comes next.","mailpoet")}),(0,g.jsx)("p",{className:"mailpoet-new-editor-modal-note",children:(0,u.__)("Note: Emails created here can't be opened in the legacy editor.","mailpoet")}),(0,g.jsxs)("div",{className:"mailpoet-new-editor-modal-footer",children:[(0,g.jsx)(ce.Ay,{type:"button",variant:"tertiary",onClick:()=>{m.U.trackEvent("New Email Editor > try new email editor modal cancel button clicked",{},{send_immediately:!0},t)},children:(0,u.__)("Cancel","mailpoet")}),(0,g.jsx)(ce.Ay,{type:"button",variant:"primary",isBusy:a,onClick:()=>{m.U.trackEvent("New Email Editor > try new email editor modal create with new editor button clicked",{},{send_immediately:!0},n)},children:(0,u.__)("Try it now","mailpoet")})]})]})):null}var na=a(7655);function ra({errors:e}){return e.length<1?null:(0,g.jsx)(h.$,{type:"error",closable:!1,children:e.map(e=>(0,g.jsx)("p",{children:e.message},e.message))})}var oa=a(95486),la=a(74314);const da=oa.Ay;function ca({children:e}){return(0,g.jsx)(da,{delay:0,text:(0,g.jsx)("div",{className:"mailpoet-newsletter-type-info-tooltip",children:e}),children:(0,g.jsx)("div",{className:"mailpoet-newsletter-type-info",children:(0,g.jsx)(ta.A,{icon:la.A,size:20})})})}const ma=Zt.A;function pa({filter:e=null,hideScreenOptions:t=!0}){const a=(0,Ne.Zp)(),[i,s]=(0,r.useState)(null),[n,o]=(0,r.useState)(!1),l=window.mailpoet_block_email_editor_enabled,d=e=>{void 0!==e&&(a(`/new/${e}`),m.U.trackEvent("Emails > Type selected",{"Email type":e}))},c=at.default.partial(e=>{s(e),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,u.__)("Subject","mailpoet")}}).done(e=>{a(`/template/${e.data.id}`)}).fail(e=>(s(null),e.errors.length>0?(0,g.jsx)(ra,{errors:e.errors}):null))},"standard"),p=at.default.partial(d,"notification"),h=at.default.partial(d,"re-engagement"),_=l?(0,g.jsxs)(Xt.A,{className:"mailpoet-dropdown-button-group",children:[(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:c,isBusy:"standard"===i,disabled:null!==i,"aria-label":(0,u.__)("Create Newsletter","mailpoet"),"data-automation-id":"create_standard",children:(0,u.__)("Create","mailpoet")}),(0,g.jsx)(ea.A,{className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,g.jsx)(ce.Ay,{variant:"secondary",className:"mailpoet-button-with-wordpress-icon",onClick:t,isBusy:"standard"===i,disabled:null!==i,"aria-expanded":e,"aria-label":(0,u.__)("Choose editor version","mailpoet"),"data-automation-id":"create_standard_email_dropdown",children:(0,g.jsx)(ta.A,{icon:aa.A,size:24})}),onToggle:e=>e&&m.U.trackEvent("New Email Editor > create email icon clicked"),renderContent:()=>(0,g.jsx)(ma,{variant:"tertiary",onClick:()=>{o(!0),m.U.trackEvent("New Email Editor > creating using new email editor button clicked")},children:(0,u.__)("Create using the new email editor (Alpha)","mailpoet")})})]}):(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:c,isBusy:i,"data-automation-id":"create_standard",children:(0,u.__)("Create","mailpoet")}),f=[{slug:"standard",title:(0,u.__)("Newsletter","mailpoet"),description:(0,u.__)("Send a newsletter with images, buttons, dividers, and social bookmarks. Or, just send a basic text email.","mailpoet"),action:_},{slug:"automations",title:(0,g.jsxs)(g.Fragment,{children:[(0,u.__)("Automations","mailpoet")," ",(0,g.jsx)(ca,{children:(0,u.__)("Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.","mailpoet")})]}),description:(0,u.__)("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,g.jsx)(ce.Ay,{variant:"secondary",onClick:()=>{s("automation"),window.location.href="admin.php?page=mailpoet-automation-templates"},isBusy:"automation"===i,disabled:null!==i,"aria-label":(0,u.__)("Create Automation","mailpoet"),"data-automation-id":"create_automation",children:(0,u.__)("Create","mailpoet")})},{slug:"notification",title:(0,u.__)("Latest Post Notifications","mailpoet"),description:(0,u.__)("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,g.jsx)(ce.Ay,{variant:"secondary",onClick:p,isBusy:"notification"===i,disabled:null!==i,"aria-label":(0,u.__)("Create Latest Post Notification","mailpoet"),"data-automation-id":"create_notification",children:(0,u.__)("Create","mailpoet")})},{slug:"re_engagement",title:(0,u.__)("Re-engagement Emails","mailpoet"),description:(0,u.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,g.jsx)(ce.Ay,{variant:"secondary",onClick:h,isBusy:"re_engagement"===i,disabled:null!==i,"aria-label":(0,u.__)("Create Re-engagement Email","mailpoet"),"data-automation-id":"create_re_engagement",children:(0,u.__)("Create","mailpoet")})}];let b=At.Hooks.applyFilters("mailpoet_newsletters_types",[...f],this);e&&(b=b.filter(e));const x=m.U.Ajax.constructGetUrl({api_version:m.U.apiVersion,endpoint:"newsletterTemplates",action:"getAll"});return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(na.x,{}),(0,g.jsx)("link",{rel:"prefetch",href:window.mailpoet_editor_javascript_url,as:"script"}),(0,g.jsx)("div",{className:"mailpoet-newsletter-types",children:b.map(e=>(e=>(0,g.jsxs)("div",{"data-type":e.slug,className:"mailpoet-newsletter-type",children:[(0,g.jsx)("div",{className:"mailpoet-newsletter-type-image"}),(0,g.jsxs)("div",{className:"mailpoet-newsletter-type-content",children:[(0,g.jsxs)(ut.D,{level:4,children:[e.title," ",e.beta?`(${(0,u.__)("Beta","mailpoet")})`:""]}),(0,g.jsx)("p",{children:e.description}),(0,g.jsx)("div",{className:"mailpoet-flex-grow"}),(0,g.jsx)("div",{className:"mailpoet-newsletter-type-action",children:e.action})]})]},e.slug))(e),this)}),(0,g.jsx)("link",{rel:"prefetch",href:x,as:"fetch"}),(0,g.jsx)(sa,{onClose:()=>o(!1),isModalOpen:n})]})}var ua=a(4932),ha=a(74445);function ga(e){const t=(0,Ne.zy)();return(0,g.jsx)(ha.Y,{...e,location:t})}var _a=a(57345),fa=a(44037);class ba 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,fa.Z)({message:(0,u.__)('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,g.jsxs)("a",{className:"mailpoet-template-preview",href:"#",onClick:e=>{e.preventDefault(),this.onPreview(e)},children:[(0,g.jsx)("div",{className:"mailpoet-template-thumbnail",children:i?(0,g.jsx)("img",{src:i,alt:(0,u.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,g.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,g.jsx)(De.$,{children:(0,u.__)("Preview","mailpoet")})})]})),(0,g.jsx)(_a.c,{label:t,onSelect:this.onSelect,onDelete:!1===a?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}ba.contextType=l.F,ba.propTypes={index:Qe().number.isRequired,id:Qe().number.isRequired,newsletterId:Qe().string.isRequired,name:Qe().string.isRequired,thumbnail:Qe().string,readonly:Qe().bool.isRequired,beforeDelete:Qe().func.isRequired,afterDelete:Qe().func.isRequired,beforeSelect:Qe().func.isRequired,afterSelect:Qe().func.isRequired},ba.displayName="TemplateBox";class xa extends r.Component{constructor(e){super(e),this.fileRef=(0,r.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),at.default.size(this.fileRef.current.files)<=0)return!1;const t=at.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,g.jsx)("p",{children:(0,u.__)("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;at.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,g.jsxs)("div",{className:"mailpoet-template-import",children:[(0,g.jsxs)("h4",{children:[(0,u.__)("Import a template","mailpoet"),(0,g.jsx)(Te.Tooltip,{tooltip:(0,u.__)("You can only upload .json templates that were originally created with MailPoet.","mailpoet"),place:"right",className:"tooltip-help-import-template"})]}),(0,g.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,g.jsx)("input",{type:"file",placeholder:(0,u.__)("Select a .json file to upload","mailpoet"),ref:this.fileRef}),(0,g.jsx)("p",{className:"submit",children:(0,g.jsx)("input",{className:"button button-primary",type:"submit",value:(0,u.__)("Upload","mailpoet")})})]})]})}}xa.contextType=l.F,xa.propTypes={beforeImport:Qe().func.isRequired,afterImport:Qe().func.isRequired};var va=a(89896);const ja=[];window.mailpoet_newsletters_templates_recently_sent_count&&ja.push({name:"recent",label:(0,u.__)("Recently sent","mailpoet")}),ja.push({name:"standard",label:(0,u.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,u.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,u.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,u.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,u.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&ja.push({name:"woocommerce",label:(0,u.__)("WooCommerce Emails","mailpoet")}),ja.push({name:"saved",label:(0,u.__)("Your saved templates","mailpoet")});class ya 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,u.__)("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=ja.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":at.default.findWhere(ja,{name:i.data.type})?a=i.data.type:"automatic"===i.data.type&&at.default.findWhere(ja,{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,g.jsx)(Nt.R,{});const e=ja.concat({name:"import",label:(0,u._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,g.jsx)(xa,{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,g.jsx)("p",{children:(0,u.__)("This category does not contain any template yet!","mailpoet")}):e.map((e,t)=>(0,g.jsx)(ba,{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(va.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,g.jsx)("input",{type:"button",className:"button link-button",onClick:a,value:"Cancel"})}return(0,g.jsxs)("div",{children:[(0,g.jsx)(ga,{emailType:this.state.emailType,automationId:"email_template_selection_heading",buttons:i,onLogoClick:a}),(0,g.jsxs)("div",{className:"mailpoet-templates",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ua.L,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,g.jsx)(o.ErrorBoundary,{children:t})]})]})}}ya.contextType=l.F,ya.propTypes={params:Qe().shape({id:Qe().string}).isRequired};var wa=a(96749),Sa=a.n(wa),Na=a(29065),Ca=a.n(Na),ka=a(93676),Ia=a(58559),Ua=a(19232),Aa=a(27609);function Ea(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 Ta={abbreviated:[(0,u.__)("Jan","mailpoet"),(0,u.__)("Feb","mailpoet"),(0,u.__)("Mar","mailpoet"),(0,u.__)("Apr","mailpoet"),(0,u.__)("May","mailpoet"),(0,u.__)("Jun","mailpoet"),(0,u.__)("Jul","mailpoet"),(0,u.__)("Aug","mailpoet"),(0,u.__)("Sep","mailpoet"),(0,u.__)("Oct","mailpoet"),(0,u.__)("Nov","mailpoet"),(0,u.__)("Dec","mailpoet")],wide:[(0,u.__)("January","mailpoet"),(0,u.__)("February","mailpoet"),(0,u.__)("March","mailpoet"),(0,u.__)("April","mailpoet"),(0,u.__)("May","mailpoet"),(0,u.__)("June","mailpoet"),(0,u.__)("July","mailpoet"),(0,u.__)("August","mailpoet"),(0,u.__)("September","mailpoet"),(0,u.__)("October","mailpoet"),(0,u.__)("November","mailpoet"),(0,u.__)("December","mailpoet")]},Ra={narrow:[(0,u._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,u._x)("M","Monday - one letter abbreviation","mailpoet"),(0,u._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,u._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,u._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,u._x)("F","Friday - one letter abbreviation","mailpoet"),(0,u._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,u.__)("Sun","mailpoet"),(0,u.__)("Mon","mailpoet"),(0,u.__)("Tue","mailpoet"),(0,u.__)("Wed","mailpoet"),(0,u.__)("Thu","mailpoet"),(0,u.__)("Fri","mailpoet"),(0,u.__)("Sat","mailpoet")],wide:[(0,u.__)("Sunday","mailpoet"),(0,u.__)("Monday","mailpoet"),(0,u.__)("Tuesday","mailpoet"),(0,u.__)("Wednesday","mailpoet"),(0,u.__)("Thursday","mailpoet"),(0,u.__)("Friday","mailpoet"),(0,u.__)("Saturday","mailpoet")]};Ua.A.localize.month=Ea({values:Ta,defaultWidth:"wide"}),Ua.A.localize.day=Ea({values:Ra,defaultWidth:"wide"}),Ua.A.options.weekStartsOn=void 0!==m.U.wpWeekStartsOn?m.U.wpWeekStartsOn:1,(0,Ia.registerLocale)("mailpoet",Ua.A);class Da 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=>ze()(e).toDate();getAsStringInFormat=e=>ze()(e).format(m.U.Date.convertFormat(this.props.storageFormat));render(){return(0,g.jsx)(Aa.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 Fa 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,g.jsx)("option",{value:e,children:t[e]},`option-${t[e]}`)),o=Object.keys(t),l=a&&!o.includes(a),d=a.lastIndexOf(":"),c=d>0?a.slice(0,d):a,m=l?(0,g.jsx)("option",{value:a,children:c}):null;return(0,g.jsxs)(it.Select,{name:s||"time",value:a,disabled:i,onChange:e,isMinWidth:!0,...n,children:[m,r]})}}Fa.propTypes={timeOfDayItems:Qe().objectOf(Qe().string).isRequired,name:Qe().string,value:Qe().string.isRequired,disabled:Qe().bool,onChange:Qe().func.isRequired,validation:Qe().object},Fa.displayName="TimeSelect";class Oa 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||Ke()(()=>{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,g.jsx)(ka.Grid.Column,{className:"mailpoet-datetime-container",children:(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(Da,{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,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Fa,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var Pa=a(23460),La=a(84135),Ma=a(61345);class $a extends r.Component{constructor(e){super(e);const t=(0,Ma.Y8)(e.item.sender_address);this.state={emailAddress:e.item.sender_address,showSenderDomainWarning:!window.mailpoet_sender_restrictions?.skipAuthorization&&!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,La.SB)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,La.oI)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,La.SB)(this.domElementSelector,this.parsleyFieldName),(0,La.vg)(this.domElementSelector)?e?this.showSenderDomainError(!0):this.showInvalidFromAddressError(t):(0,La.jr)(this.domElementSelector))};showSenderDomainError=e=>{e&&this.setState({showSenderDomainWarning:!0})};validateEmailAddress(){if(!window.mailpoet_mss_active)return;if(window.mailpoet_sender_restrictions?.skipAuthorization)return;const e=this.state.emailAddress,t=(0,Ma.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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Xe,{item:{...this.props.item,sender_address:this.state.emailAddress},field:this.props.field,onValueChange:this.onChange,onBlurEvent:this.onBlur}),(0,g.jsx)("div",{className:"regular-text regular-text-full-width",children:(0,g.jsx)(Pa.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,La.SB)(this.domElementSelector,this.parsleyFieldName)}})})]})}}$a.propTypes={field:Qe().object.isRequired,item:Qe().shape({sender_address:Qe().string.isRequired}).isRequired,onValueChange:Qe().func},$a.displayName="SenderField";const Ba=at.default.once(()=>m.U.trackEvent("User has typed a GA campaign name")),qa=Ge()((0,u.__)("For example, “Spring email”. [link]Read the guide.[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsxs)("span",{children:[(0,g.jsx)("br",{}),(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/187-track-newsletters-subscribers-in-google-analytics",target:"_blank",rel:"noopener noreferrer",className:"mailpoet-link",children:e})]},t)),Ha={name:"ga_campaign",label:(0,u.__)("Google Analytics Campaign","mailpoet"),tip:qa,type:"text",onBeforeChange:Ba};var Wa=a(13704),za=a(11947),Va=a(30676),Ga=a(93963),Ya=a(46545);const Ka={saveDraftNewsletter:()=>Promise.resolve()},Ja=r.createContext(Ka);var Qa=a(83471);function Za(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const Xa=[{name:"segments",label:(0,u.__)("Send to","mailpoet"),type:"selection",placeholder:(0,u.__)("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,u.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,u.__)("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)(Va.d&&!!i),l=(0,r.useCallback)(a=>{t({target:{name:"options",value:{...e?.options??{},filterSegmentId:a}}})},[e,t]),d=(0,r.useContext)(Ja);(0,r.useEffect)(()=>{Va.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 p;if(s){const t={name:"filter-segment",type:"selection",placeholder:(0,u.__)("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,u.__)("Please select a filter segment","mailpoet")}};p=(0,g.jsx)(Ae.L,{item:e,field:t,onValueChange:t=>{l(t.target.value),m.U.trackEvent("Emails > Filter by segment selected",{"Email type":e.type})}})}const h=`admin.php?page=mailpoet-segments#/new-segment?newsletterId=${e.id}`;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Toggle,{checked:s,disabled:a.disabled,name:"isFilterSegmentEnabled",onCheck:c,automationId:"filter-segment-toggle"}),(0,g.jsxs)("span",{className:"mailpoet-form-toggle-text",children:[(0,u.__)("Filter by segment","mailpoet"),(0,g.jsx)(ta.A,{"data-tip":!0,"data-tooltip-id":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:Ya.A})]}),(0,g.jsx)(Ga.m,{place:"right",id:"filter-segment-tooltip",children:(0,g.jsx)("div",{children:(0,u.__)("Subscribers selected in 'Send to' will only receive an email if they also belong to this segment.","mailpoet")})}),(0,g.jsx)("div",{className:"mailpoet-gap"}),p,s&&(0,g.jsx)("p",{children:Ge()((0,u.__)("Can't find the segment you're looking for? [link]Create new[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/g,(t,a)=>(0,g.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=h},href:h,children:t},a))})]})})}],ei={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=Za(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=Za(n,o);l.current===i&&s(a)}).always(()=>a(!1)))},[n,o]),(0,g.jsxs)("div",{children:[(0,u.__)("Estimated recipients","mailpoet"),":",t&&(0,g.jsx)(Qa.Ay,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ga.m,{place:"right",id:"estimated-count-tooltip",children:(0,u.__)("This count may change at the time of sending.","mailpoet")}),(0,g.jsx)("span",{"data-tip":!0,"data-tooltip-id":"estimated-count-tooltip",className:"estimated-recipient-count",children:i.toLocaleString()})]})]})})},ti={name:"send-to",label:(0,u.__)("Send to","mailpoet"),tip:(0,u.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:Xa},ai={name:"send-to",label:(0,u.__)("Send to","mailpoet"),tip:(0,u.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...Xa,ei]},ii=`${window.mailpoet_tomorrow_date} 08:00:00`,si=window.mailpoet_schedule_time_of_day,ni=window.mailpoet_date_format,ri=window.mailpoet_date_storage_format;class oi extends r.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:ii,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,u.__)("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,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("span",{className:"mailpoet-form-schedule-time",children:[(0,u.__)("Your website’s time is","mailpoet")," ",m.U.Date.time(new Date)]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{id:"mailpoet_scheduling",children:(0,g.jsx)(Oa,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:ii,timeOfDayItems:si,dateDisplayFormat:ni,dateStorageFormat:ri,maxDate:t})})]})),(0,g.jsxs)("div",{children:[(0,g.jsx)(Wa.l,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}let li=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,u.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,u.__)("Type newsletter subject","mailpoet"),tooltip:(0,u.__)("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,u.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,u.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,u.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,u.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,u.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},ai,{name:"options",label:(0,u.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(oi)},{name:"sender",label:(0,u.__)("Sender","mailpoet"),tip:(0,u.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,u.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)($a),placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ha,{name:"reply-to",label:(0,u.__)("Reply-to","mailpoet"),tip:(0,u.__)("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,u.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];li=At.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",li);const di={getFields:()=>li,getSendButtonOptions:(e={})=>{const t={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&m.U.Date.isInFuture(e.options?.scheduledAt,new Date)?(0,u.__)("Schedule","mailpoet"):(0,u.__)("Send","mailpoet")};return e.status!==za.um.Sent&&e.status!==za.um.Sending||(t.disabled="disabled"),t}},ci=window.mailpoet_time_format||"H:i",mi={immediate:(0,u.__)("immediately","mailpoet"),minutes:(0,u.__)("minute(s) later","mailpoet"),hours:(0,u.__)("hour(s) later","mailpoet"),days:(0,u.__)("day(s) later","mailpoet"),weeks:(0,u.__)("week(s) later","mailpoet")},pi={daily:(0,u.__)("Once a day at...","mailpoet"),weekly:(0,u.__)("Weekly on...","mailpoet"),monthly:(0,u.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,u.__)("Monthly every...","mailpoet"),immediately:(0,u.__)("Immediately","mailpoet")},ui=at.default.object(at.default.map(at.default.times(96,e=>900*e),e=>{const t=new Date(null);return t.setSeconds(e),[e,m.U.Date.format(t,{format:ci,offset:0})]})),hi={0:(0,u.__)("Sunday","mailpoet"),1:(0,u.__)("Monday","mailpoet"),2:(0,u.__)("Tuesday","mailpoet"),3:(0,u.__)("Wednesday","mailpoet"),4:(0,u.__)("Thursday","mailpoet"),5:(0,u.__)("Friday","mailpoet"),6:(0,u.__)("Saturday","mailpoet")},gi=at.default.object(at.default.map(at.default.times(28,e=>e),e=>{const t={0:(0,u.__)("1st","mailpoet"),1:(0,u.__)("2nd","mailpoet"),2:(0,u.__)("3rd","mailpoet")};let a;return a=void 0!==t[e]?t[e]:(0,u.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,a]})),_i={1:(0,u.__)("1st","mailpoet"),2:(0,u.__)("2nd","mailpoet"),3:(0,u.__)("3rd","mailpoet"),4:(0,u.__)("4th","mailpoet"),L:(0,u._x)("last","e.g. monthly every last Monday","mailpoet")},fi={name:"intervalType",values:pi},bi={name:"timeOfDay",values:ui},xi={name:"weekDay",values:hi},vi={name:"monthDay",values:gi},ji={name:"nthWeekDay",values:_i};class yi 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:at.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,g.jsx)(st,{field:bi,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"!==e.intervalType&&"nthWeekDay"!==e.intervalType||(a=(0,g.jsx)(st,{field:xi,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(i=(0,g.jsx)(st,{field:vi,item:this.getCurrentValue(),onValueChange:this.handleMonthDayChange})),"nthWeekDay"===e.intervalType&&(s=(0,g.jsx)(st,{field:ji,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,g.jsxs)("div",{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsx)(st,{field:fi,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,g.jsx)("div",{children:(0,g.jsx)("p",{children:(0,u.__)("after publishing a post","mailpoet")})})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[s,i,a,t]}),"immediately"!==e.intervalType&&(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}yi.propTypes={item:Qe().object.isRequired,field:Qe().shape({name:Qe().string}).isRequired,onValueChange:Qe().func.isRequired};let wi=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,u.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,u.__)("Type newsletter subject","mailpoet"),tooltip:(0,u.__)("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,u.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,u.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,u.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,u.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,u.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,u.__)("Select a frequency","mailpoet"),type:"reactComponent",component:yi},ai,{name:"sender",label:(0,u.__)("Sender","mailpoet"),tip:(0,u.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,u.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)($a),placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Ha,{name:"reply-to",label:(0,u.__)("Reply-to","mailpoet"),tip:(0,u.__)("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,u.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];wi=At.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",wi);const Si={getFields:function(){return wi},getSendButtonOptions:function(){return{value:(0,u.__)("Activate","mailpoet")}}},Ni=window.mailpoet_roles||{},Ci=at.default.filter(window.mailpoet_segments||[],e=>"default"===e.type),ki={name:"event",values:{segment:(0,u.__)("When someone subscribes to the list...","mailpoet"),user:(0,u.__)("When a new WordPress user is added to your site...","mailpoet")}},Ii={name:"segment",placeholder:(0,u.__)("Select a list","mailpoet"),forceSelect2:!0,values:Ci,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},Ui={name:"role",values:Ni},Ai={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,u.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},Ei={name:"afterTimeType",values:mi};class Ti 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:at.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,g.jsx)(st,{field:Ui,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,g.jsx)(Ae.L,{field:Ii,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(a=(0,g.jsx)(Xe,{field:Ai,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,g.jsxs)("div",{children:[(0,g.jsx)(st,{field:ki,item:this.getCurrentValue(),onValueChange:this.handleEventChange}),(0,g.jsx)("div",{className:"mailpoet-gap"}),t,(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[a,(0,g.jsx)(st,{field:Ei,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,g.jsx)("div",{className:"mailpoet-form-errors"}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}Ti.propTypes={item:Qe().object.isRequired,field:Qe().shape({name:Qe().string}).isRequired,onValueChange:Qe().func.isRequired},Ti.displayName="WelcomeScheduling";let Ri=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,u.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,u.__)("Type newsletter subject","mailpoet"),tooltip:(0,u.__)("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,u.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,u.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,u.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,u.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,u.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,u.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(Ti)},Ha,{name:"sender",label:(0,u.__)("Sender","mailpoet"),tip:(0,u.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,u.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)($a),placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,u.__)("Reply-to","mailpoet"),tip:(0,u.__)("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,u.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];Ri=At.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",Ri);const Di={getFields:function(){return Ri},getSendButtonOptions:function(){return{value:(0,u.__)("Activate","mailpoet")}}},Fi=3;class Oi 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=mi;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:at.default.map(t,(e,t)=>({name:e,id:t})),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>a},onValueChange:at.default.partial(this.handleChange,at.default,"afterTimeType")};return(0,g.jsx)(Ae.L,{field:i.field,onValueChange:i.onValueChange})}displayAfterTimeNumberField(){const{event:e,afterTimeNumberSize:t=Fi}=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,u.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:at.default.partial(this.handleChange,at.default,"afterTimeNumber")};return(0,g.jsx)(Xe,{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,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("h4",{children:[" ",(0,u.__)("When to send this email?","mailpoet")," "]}),(0,g.jsxs)(ka.Grid.CenteredRow,{className:"mailpoet-re-engagement-scheduling",children:[this.displayAfterTimeNumberField(),this.displayAfterTimeTypeOptions(),e.afterDelayText&&(0,g.jsx)("p",{children:e.afterDelayText})]}),(0,g.jsx)("div",{className:"mailpoet-form-errors"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),e.schedulingReadMoreLink&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("a",{href:e.schedulingReadMoreLink.link,target:"_blank",rel:"noopener noreferrer",className:"event-scheduling-read-more-link",children:e.schedulingReadMoreLink.text}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})]})}}function Pi(e){const t=e&&e.values?e.values:[];return t?t.map(e=>({id:e.id,name:e.name})):t}function Li({eventOptions:e,eventSlug:t,selected:a,onValueChange:i}){function s(e){i&&i({eventOptionValue:e.target.value})}return(0,g.jsx)("div",{children:(0,g.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:Pi(e),multiple:e.multiple||!1,placeholder:e.placeholder||!1,transformChangedValue:(e,t)=>at.default.map(t,e=>({id:e.id,name:e.text})),selected:()=>a,getLabel:at.default.property("name"),getValue:at.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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ae.L,{field:i.field,onValueChange:i.onValueChange,item:i.item}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}()})})}Oi.propTypes={item:Qe().shape({afterTimeType:Qe().string.isRequired,afterTimeNumber:Qe().number}).isRequired,afterTimeNumberSize:Qe().number,onValueChange:Qe().func,event:Qe().shape({defaultAfterTimeType:Qe().string,afterDelayText:Qe().string,timeDelayValues:Qe().objectOf(Qe().shape({text:Qe().string,displayAfterTimeNumberField:Qe().bool})),schedulingReadMoreLink:Qe().shape({link:Qe().string.isRequired,text:Qe().string.isRequired})}).isRequired},Oi.displayName="EventScheduling",Li.displayName="EventOptions";const Mi=(0,o.withBoundary)(Li);class $i 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=at.default.indexBy(this.email.events,"slug"),this.segments=at.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,g.jsx)(Oi,{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,g.jsx)("div",{className:"event-segment-selection",children:(0,g.jsx)(Ae.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=at.default.map(a.option,e=>e.id)),(0,g.jsx)(Mi,{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,g.jsxs)("div",{children:[(0,g.jsx)(ut.D,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}$i.propTypes={field:Qe().shape({email:Qe().shape({events:Qe().object.isRequired}).isRequired,emailOptions:Qe().object.isRequired}).isRequired,onValueChange:Qe().func},$i.displayName="SendEventConditions";const Bi=window.mailpoet_woocommerce_automatic_emails||[],qi={getFields:function(e){return(e=>{const t=Bi[e.options.group];if(!t)return!1;const a=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,u.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,u.__)("Type newsletter subject","mailpoet"),tooltip:(0,u.__)("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,u.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,u.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,u.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,u.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,u.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,u.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,o.withBoundary)($i),email:t,emailOptions:a},Ha,{name:"sender",label:(0,u.__)("Sender","mailpoet"),tip:(0,u.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,u.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,u.__)("Reply-to","mailpoet"),tip:(0,u.__)("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,u.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,u.__)("Activate","mailpoet")}}};var Hi=a(95106);function Wi({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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:4,children:(0,u.__)("When to send this re-engagement email?","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("After no activity for","mailpoet")}),(0,g.jsxs)(ka.Grid.TwoColumns,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(Ze.p,{type:"number",placeholder:(0,u.__)("count","mailpoet"),value:e,min:1,onChange:(0,Ma.k9)(a),required:!0})}),(0,g.jsx)("div",{children:(0,g.jsxs)(it.Select,{value:t,onChange:(0,Ma.k9)(i),children:[(0,g.jsx)("option",{value:"weeks",children:(0,u.__)("weeks","mailpoet")}),(0,g.jsx)("option",{value:"months",children:(0,u.__)("months","mailpoet")})]})})]}),(!s||o>r)&&(0,g.jsx)("div",{className:"mailpoet-gap"}),!!s&&o<=r&&(0,g.jsx)("p",{className:"mailpoet-re-engagement-scheduling-note",children:Ge()((0,u.__)("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,g.jsx)("a",{href:"https://kb.mailpoet.com/article/264-inactive-subscribers",target:"_blank",rel:"noopener noreferrer",children:e},"link"))})]})}const zi=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,u.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,u.__)("Type newsletter subject","mailpoet"),tooltip:(0,u.__)("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,u.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,u.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,u.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,u.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,u.__)("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,g.jsx)(Wi,{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,Hi.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,Hi.assoc)("afterTimeType",t,e.item.options)}})}})}},ti,{name:"sender",label:(0,u.__)("Sender","mailpoet"),tip:(0,u.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,u.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:$a,placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,u.__)("Reply-to","mailpoet"),tip:(0,u.__)("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,u.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,u.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},Ha],Vi={getFields:()=>zi,getSendButtonOptions:()=>({value:(0,u.__)("Activate","mailpoet")})};var Gi=a(70742);let Yi=null;var Ki=a(36730);function Ji({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,g.jsxs)("div",{className:"mailpoet_error",children:[(0,g.jsx)(Ki.wk,{}),i&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(Ki.Tr,{onRefreshClick:async t=>{t.preventDefault(),e(!0),await a(),s(!1),e(!1)}})]})]})}Ji.displayName="PendingNewsletterMessage";const Qi=(0,o.withBoundary)(Ji),Zi=window.mailpoet_woocommerce_automatic_emails||{},Xi=(e,t)=>`${Ca()(t,{strict:!0,lower:!0})||"email"}-${e}`,es=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function ts(e){let t,a;if(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,u.__)("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,u.__)('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,u.__)("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,u._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,u.__)("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,g.jsx)("span",{style:{pointerEvents:"all"},children:Ge()((0,u.__)("Re-engagement emails are disabled because [link]open and click tracking[/link] is disabled.","mailpoet"),/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{href:"?page=mailpoet-settings#/advanced",rel:"noopener noreferrer",children:e},"advancedSettingsTabLink"))})}class as 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})}),ke()("#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===za.Gn.Automatic&&Zi[e.options.group])return qi;switch(e.type){case"notification":return Si;case"welcome":return Di;case"re_engagement":return Vi;default:return di}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,Gi.uz)(e);isValid=()=>ke()("#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;if(window.mailpoet_sender_restrictions?.skipAuthorization)return!0;const e=await this.loadVerifiedSenderDomains(),t=(0,Ma.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===za.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&&Va.d&&(a.ga_campaign=Xi(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:ts(e.data)}),e.data?.wp_post_id&&m.U.trackEvent("New Email Editor > Send page opened-Newsletter created by BlockEmailEditor"),!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))})):ke()("#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=Sa().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,editor:this.state.item.wp_post_id?"BlockEmailEditor":"legacyEditor"}),s?this.context.notices.success((0,g.jsx)("p",{children:(0,u.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,g.jsx)("p",{children:(0,u.__)("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&&Zi[e.group]?m.U.trackEvent("Emails > Automatic email activated",{Type:Ca()(`${e.group}-${e.event}`),Delay:es(e)}):"welcome"===t.data.type?m.U.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:es(e)}):"re_engagement"===t.data.type?(this.context.notices.success((0,g.jsx)("p",{children:(0,u.__)("Your Re-engagement Email is now activated!","mailpoet")})),m.U.trackEvent("Emails > Re-engagement email activated",{Inactivity:es(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,g.jsx)("p",{children:(0,u.__)("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,g.jsx)("p",{children:(0,u.__)("The newsletter sending has been resumed.","mailpoet")}))}).fail(e=>{this.showError(e)})}).fail(e=>{this.showError(e)}).always(()=>{this.setState({loading:!1})}):ke()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done(()=>{this.context.notices.success((0,g.jsx)("p",{children:(0,u.__)("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,g.jsx)("p",{children:(0,u.__)("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=Sa().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===Xi(i.id,s)&&(i.ga_campaign=Xi(i.id,a)),"reply_to_address"===t&&(i[t]=a.toLowerCase()),{item:i}}),!0};handleSaveDraft=()=>{ke()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>Va.d||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,u.__)("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||Va.d?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,u.__)("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),p=!(!window.mailpoet_subscribers_limit_reached&&!r&&void 0===this.state.validationError);let h=i;return h===za.Gn.Automatic&&(h=s.group||h),(0,g.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,g.jsx)(ga,{emailType:h,automationId:"newsletter_send_heading"}),(0,g.jsxs)(o.ErrorBoundary,{children:[this.state.item.campaign_name?(0,g.jsx)("div",{className:"mailpoet-form-grid mailpoet-send-campaign-name",children:(0,g.jsx)("h1",{children:this.state.item.campaign_name})}):null,(0,g.jsx)(Ja.Provider,{value:this.state.sendContextValue,children:(0,g.jsxs)(bt,{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,g.jsxs)(ka.Grid.CenteredRow,{className:"send-newsletter-buttons",children:[(0,g.jsx)(o.Button,{variant:"secondary",type:"submit",automationId:"email-save-draft",onClick:this.handleSaveDraft,isDisabled:this.state.loading,children:(0,u.__)("Save as draft and close","mailpoet")}),l?(0,g.jsx)(o.Button,{type:"button",onClick:this.handleResume,isDisabled:p||this.state.loading,automationId:"email-resume",children:(0,u.__)("Resume","mailpoet")}):(0,g.jsx)(o.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:p||this.state.loading,automationId:"email-submit",children:d.value||(0,u.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,g.jsx)(Te.Tooltip,{tooltip:(0,g.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,g.jsxs)("p",{children:[(0,u.__)("or simply","mailpoet")," ",(0,g.jsx)("a",{className:"mailpoet-link",href:n?m.U.getBlockEmailEditorUrl(Number(n)):`?page=mailpoet-newsletter-editor&id=${Number(this.props.params.id)}`,onClick:this.handleRedirectToDesign,children:(0,u.__)("go back to the Design page","mailpoet")}),"."]}),r&&(0,g.jsx)(Qi,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,g.jsx)(Va.D,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})]})]})}}function is(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:0,children:(0,u.__)("Congratulations!","mailpoet")}),(0,g.jsx)(ut.D,{level:3,children:(i=e.newsletter,"welcome"===i.type?(0,u.__)("Your Welcome Email is now active.","mailpoet"):"notification"===i.type?(0,u.__)("Your Post Notification is now active.","mailpoet"):"automatic"===i.type?(0,u.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===i.status?(0,u.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,u.__)("Your newsletter is being sent!","mailpoet"))}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("img",{src:e.illustrationImageUrl,alt:"",width:"500"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(o.Button,{type:"button",dimension:"small",onClick:()=>{e.successClicked(),a(!0)},withSpinner:t,children:(0,u.__)("Close","mailpoet")})]});var i}function ss(e){return(0,g.jsxs)("div",{className:"mailpoet-wizard-step",children:[(0,g.jsx)("div",{className:"mailpoet-wizard-step-illustration",children:(0,g.jsx)("img",{src:e.illustrationUrl,alt:""})}),(0,g.jsx)("div",{className:"mailpoet-wizard-step-content",children:e.children})]})}function ns(){return(0,g.jsxs)(o.List,{children:[(0,g.jsx)("li",{children:(0,u.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,g.jsx)("li",{children:(0,u.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,g.jsx)("li",{children:(0,u.__)("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,g.jsx)("li",{children:(0,u.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function rs(e){const[t,a]=(0,r.useState)(!1),i=()=>{e.onFinish(),a(!0)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Heading,{level:1,children:(s=e.newsletter.type,{standard:(0,u.__)("Your email has been sent!","mailpoet"),welcome:(0,u.__)("You are all set up and ready to go!","mailpoet"),notification:(0,u.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,u.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,u.__)("You are all set up and ready to go!","mailpoet"))}),(0,g.jsx)(ss,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,g.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,g.jsx)(o.Heading,{level:4,children:(0,u.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,g.jsx)("p",{children:e.subscribersCount<1e3?(0,u._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,u._x)("Starting at only $10 per month, MailPoet Business offers the following features","Promotion for our email sending service: Paragraph","mailpoet")}),(0,g.jsxs)(o.Heading,{level:5,children:[(0,u._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,g.jsx)(ns,{}),(0,g.jsx)("p",{children:Ge()((0,u.__)("Please enter your key in [link]the Settings[/link] if you have already purchased it.","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{href:"admin.php?page=mailpoet-settings#/premium",children:e},t))}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{isFullWidth:!0,href:e.purchaseUrl,target:"_blank",rel:"noopener noreferrer",onClick:t=>{t.preventDefault(),window.open(e.purchaseUrl),i()},children:(0,u._x)("Sign up for free","Promotion for our email sending service: Button","mailpoet")}),(0,g.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,u._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function os(e){return window.has_mss_key_specified?(0,g.jsx)(is,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,g.jsx)(rs,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function ls(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)("div",{children:[(0,g.jsx)(ut.D,{level:1,children:(0,u.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,g.jsx)(ut.D,{level:3,children:Ge()((0,u.__)("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,g.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kb.mailpoet.com/article/231-sending-does-not-work",children:e},t))}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("img",{src:window.mailpoet_congratulations_error_image,alt:"",width:"500"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(o.Button,{dimension:"small",type:"button",onClick:()=>{e.failClicked(),a(!0)},withSpinner:t,children:(0,u.__)("Close","mailpoet")})]})}as.contextType=l.F,is.propTypes={successClicked:Qe().func.isRequired,illustrationImageUrl:Qe().string.isRequired,newsletter:Qe().shape({status:Qe().string.isRequired,type:Qe().string.isRequired}).isRequired},ss.propTypes={illustrationUrl:Qe().string.isRequired,children:Qe().oneOfType([Qe().arrayOf(Qe().node),Qe().node]).isRequired},os.propTypes={successClicked:Qe().func.isRequired,illustrationImageUrl:Qe().string.isRequired,MSSPitchIllustrationUrl:Qe().string.isRequired,newsletter:Qe().shape({status:Qe().string.isRequired,type:Qe().string.isRequired}).isRequired,subscribersCount:Qe().number.isRequired,purchaseUrl:Qe().string.isRequired},ls.propTypes={failClicked:Qe().func.isRequired};var ds=a(94991);function cs(e){return(0,g.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,g.jsxs)("div",{children:[(0,g.jsx)(ut.D,{level:0,children:(0,u.__)("Verification","mailpoet")}),(0,g.jsx)(ut.D,{level:3,children:(0,u.__)("Congrats, you’re sending your first newsletter! We’re doing a quick verification to make sure everything works fine.","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)("div",{className:"mailpoet-gap-large"}),(0,g.jsx)(ds.a,{size:64})]})})}cs.propTypes={showRichLoadingScreen:Qe().bool.isRequired};const ms=Math.floor(4*Math.random());function ps(){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 us extends r.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:ze()(),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(){ze()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.params.id),ze()().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,g.jsx)(cs,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:ps,showRichLoadingScreen:e})):this.state.error?(m.U.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,g.jsx)(ls,{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,g.jsx)(os,{illustrationImageUrl:window.mailpoet_congratulations_success_images[ms],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[ms],successClicked:ps,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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:"body { background: #fff; overflow-x: hidden; }"}}),(0,g.jsxs)("div",{className:"mailpoet-congratulate",children:[(0,g.jsx)("div",{className:"mailpoet-gap-large"}),this.renderContent()]})]})}}us.propTypes={params:Qe().shape({id:Qe().string}).isRequired},us.displayName="Congratulate";class hs extends r.Component{componentDidMount(){m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,u.__)("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,g.jsx)("div",{children:(0,g.jsx)(ga,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}hs.contextType=l.F,hs.propTypes={navigate:Qe().func.isRequired},hs.displayName="NewsletterStandard";const gs={name:"options",type:"reactComponent",component:yi};class _s 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:at.default.extend({},this.state,{type:"notification",subject:(0,u.__)("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,g.jsxs)("div",{children:[(0,g.jsx)(ga,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,g.jsxs)(ka.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(ut.D,{level:4,children:(0,u.__)("When to send this post notification email?","mailpoet")}),(0,g.jsx)(yi,{item:this.state,field:gs,onValueChange:this.handleValueChange}),(0,g.jsx)(De.$,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,u.__)("Next","mailpoet")})]})]})}}function fs(){let e="11";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,Ne.Zp)();return(0,g.jsxs)("div",{children:[i&&(0,g.jsx)(ra,{errors:i}),(0,g.jsx)(ga,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,g.jsxs)(ka.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(Wi,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,Hi.compose)([a,(0,Hi.assoc)("afterTimeNumber",Hi.__,t)]),updateAfterTimeType:(0,Hi.compose)([a,(0,Hi.assoc)("afterTimeType",Hi.__,t)])}),(0,g.jsx)(De.$,{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,u.__)("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,u.__)("Next","mailpoet")})]})]})}_s.contextType=l.F,fs.displayName="NewsletterTypeReEngagement";var bs=a(10697),xs=a(80540),vs=a(11702);function js({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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ra,{errors:i}),t&&(0,g.jsx)(De.$,{dimension:"small",onClick:e.status===za.um.Corrupt?async()=>{(0,o.confirmAlert)({message:(0,u.__)("There was an issue sending this email before. Please confirm the problems are fixed to proceed.","mailpoet"),onConfirm:n})}:n,children:(0,u.__)("Resume","mailpoet")}),!t&&(0,g.jsx)(De.$,{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,u.__)("Pause","mailpoet")})]})}function ys(){return(0,g.jsx)("div",{className:"mailpoet-listing-stats-too-early",children:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-help#/systemStatus",className:"mailpoet-tag mailpoet-tag-inverted mailpoet-tag-unknown",children:(0,u.__)("Cancelled","mailpoet")})})}function ws({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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Se.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:(0,g.jsx)(vs.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,g.jsx)(ys,{}),"completed"!==e.queue.status&&!i&&!n&&(0,g.jsx)(js,{newsletter:e})]}),o=(0,g.jsx)(vs.um,{scheduledFor:a,isPaused:"scheduled"===e.queue.status&&n,status:e.status,logs:e.logs});return(0,g.jsxs)(g.Fragment,{children:[s&&r,!s&&o]})}ws.displayName="QueueStatus";const Ss=(0,o.withBoundary)(ws);var Ns=a(5107);function Cs({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:At.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",va.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,p,h=0,_=0,f=null;n>0&&(h=100*e.statistics.clicked/n,_=100*e.statistics.opened/n,f=e.statistics.revenue),r||void 0===a?(m=!1,p=!1):(l=6,d=e.queue.scheduled_at||e.queue.created_at,c=ze()(a).diff(ze()(d),"hours"),m=c<l,p=!0);const b=n>=20&&e.statistics.opened>=5&&!m,x=(t,a)=>((e,t,a,i)=>i<=0||!t.link?e:t.externalLink?(0,g.jsx)("a",{href:t.link,onClick:t.onClick||null,children:e},`stats-${a}`):(0,g.jsx)(Se.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${a}`))(t,s,`${a}-${e.id}`,n),v=(0,g.jsx)(Ns.j,{opened:_,clicked:h,revenues:f&&f.value>0?f.formatted:null,hideBadges:!b,newsletterId:e.id,wrapContentInLink:x}),j=(0,g.jsxs)(g.Fragment,{children:[v,m&&x((0,g.jsx)(o.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,u.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",l-c)}),"check-back")]});let y;return p&&_<5&&c>=24&&n>=10&&(y=(0,g.jsx)("div",{children:(0,g.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,u.__)("What can I do to improve this?","mailpoet")})})),(0,g.jsxs)(g.Fragment,{children:[j,y]})}const ks=Qe().shape({clicked:Qe().number,opened:Qe().number,unsubscribed:Qe().number,revenue:Qe().shape({count:Qe().number,currency:Qe().string,formatted:Qe().string,value:Qe().number})}),Is=Qe().shape({status:Qe().string,count_processed:Qe().string.isRequired,count_total:Qe().string.isRequired,created_at:Qe().string,scheduled_at:Qe().string});Cs.propTypes={newsletter:Qe().shape({id:Qe().number.isRequired,queue:Qe().oneOfType([Is,Qe().bool]),total_sent:Qe().number,statistics:Qe().oneOfType([ks,Qe().bool])}).isRequired,isSent:Qe().bool,currentTime:Qe().string},Cs.displayName="NewsletterStatistics";const Us=(0,o.withBoundary)(Cs),As=m.U.trackingConfig.emailTrackingEnabled,Es={onNoItemsFound:(e,t)=>t?(0,u.__)("No emails found.","mailpoet"):(0,u.__)("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,u.__)("1 email was moved to the trash.","mailpoet"):(0,u.__)("%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,u.__)("1 email was permanently deleted.","mailpoet"):(0,u.__)("%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,u.__)("1 email has been restored from the Trash.","mailpoet"):(0,u.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Ts=[{name:"name",label:(0,u.__)("Name","mailpoet"),sortable:!0},{name:"status",label:(0,u.__)("Status","mailpoet")},{name:"segments",label:(0,u.__)("Lists","mailpoet")},{name:"statistics",label:(0,u.__)("Clicked, Opened","mailpoet"),display:As},{name:"sent_at",label:(0,u.__)("Sent on","mailpoet"),sortable:!0}],Rs=[{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:Es.onTrash}],Ds=e=>{const t=m.U.getActiveEmailEditorUrl(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,fa.Z)({message:(0,u.__)("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 Fs=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,u.__)("Edit","mailpoet"),onClick:Ds},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,u.__)("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,u.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,bs.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"}];Fs=(0,va.pE)(Fs);class Os extends r.Component{constructor(e){super(e),this.state={newslettersCount:void 0}}renderItem=(e,t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions"),s=e.queue.newsletter_rendered_subject||e.subject;return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:"#",onClick:t=>{t.preventDefault(),Ds(e)},children:e.campaign_name?(0,g.jsxs)(g.Fragment,{children:[e.campaign_name," ",(0,g.jsx)("br",{}),(0,g.jsx)("span",{className:"mailpoet-listing-subtitle",children:s})]}):s}),t]}),(0,g.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,u.__)("Status","mailpoet"),children:(0,g.jsx)(Ss,{newsletter:e,mailerLog:a.mta_log})}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,u.__)("Lists","mailpoet"),children:(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(xs.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(xs.y,{newsletter:e,dimension:"large"})]})}),!0===As?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,u.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Us,{newsletter:e,currentTime:a.current_time})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Sent on","mailpoet"),children:e.sent_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(e.sent_at),(0,g.jsx)("br",{}),m.U.Date.time(e.sent_at)]}):null})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(pa,{filter:e=>"standard"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Ie.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:Ts,bulk_actions:Rs,item_actions:Fs,messages:Es,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,va.DP)(e),(0,va.tQ)(e)}})]})}}Os.contextType=l.F,Os.propTypes={location:Qe().object.isRequired,params:Qe().object.isRequired},Os.displayName="NewsletterListStandard";const Ps=(0,o.withBoundary)(Os);function Ls(e){const t=(0,Ne.zy)(),a=(0,Ne.g)();return(0,g.jsx)(Ps,{...e,location:t,params:a})}var Ms=a(27014);const $s={onNoItemsFound:(e,t)=>t?(0,u.__)("No emails found.","mailpoet"):(0,u.__)("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,u.__)("1 email was moved to the trash.","mailpoet"):(0,u.__)("%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,u.__)("1 email was permanently deleted.","mailpoet"):(0,u.__)("%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,u.__)("1 email has been restored from the Trash.","mailpoet"):(0,u.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Bs=[{name:"subject",label:(0,u.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,u.__)("Settings","mailpoet")},{name:"history",label:(0,u.__)("History","mailpoet"),width:100},{name:"status",label:(0,u.__)("Status","mailpoet"),width:100},{name:"updated_at",label:(0,u.__)("Last modified on","mailpoet"),sortable:!0}],qs=[{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:$s.onTrash}],Hs=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Preview","mailpoet")})}},{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,u.__)("Edit","mailpoet"),onClick:va.$U},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,u.__)("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,u.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,bs.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 Ws 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,u.__)("Your post notification is now active!","mailpoet")),this.forceUpdate()}).fail(a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e})};renderStatus=e=>(0,g.jsx)(Wa.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,g.jsx)(Se.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,u.__)("You need to select a list to send to.","mailpoet")});const a=Ge()((0,u.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(xs.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(xs.y,{newsletter:e},`filter-segment-${a}`)]},a));switch(e.options.intervalType){case"daily":t=(0,u.__)("Daily at %1$s","mailpoet").replace("%1$s",ui[e.options.timeOfDay]);break;case"weekly":t=(0,u.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",hi[e.options.weekDay]).replace("%2$s",ui[e.options.timeOfDay]);break;case"monthly":t=(0,u.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",gi[e.options.monthDay]).replace("%2$s",ui[e.options.timeOfDay]);break;case"nthWeekDay":t=(0,u.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",_i[e.options.nthWeekDay]).replace("%2$s",hi[e.options.weekDay]).replace("%3$s",ui[e.options.timeOfDay]);break;case"immediately":t=(0,u.__)("Immediately","mailpoet");break;default:t="Invalid sending frequency"}return(0,g.jsxs)("span",{children:[a,(0,g.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,g.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,g.jsx)(Ms.x,{})}),t]})]})};renderHistoryLink=e=>0===Number(e.children_count)?(0,g.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,u.__)("Not sent yet","mailpoet")}):(0,g.jsxs)(Se.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:[(0,g.jsx)(De.$,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,u.__)("View history","mailpoet")}),(0,g.jsx)(De.$,{className:"mailpoet-show-on-mobile mailpoet-listing-notification-status",dimension:"small",variant:"secondary",children:(0,u.__)("View history","mailpoet")})]});renderItem=(e,t)=>{const a=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:a,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),onClick:t=>{t.preventDefault(),(0,va.$U)(e)},children:e.subject}),t]}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,u.__)("Settings","mailpoet"),children:this.renderSettings(e)}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("History","mailpoet"),children:this.renderHistoryLink(e)}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,g.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Last modified on","mailpoet"),children:[m.U.Date.short(e.updated_at),(0,g.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(pa,{filter:e=>"notification"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Ie.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:Bs,bulk_actions:qs,item_actions:Hs,messages:$s,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,va.DP)(e),(0,va.tQ)(e)}})]})}}Ws.propTypes={location:Qe().object.isRequired,params:Qe().object.isRequired},Ws.displayName="NewsletterListNotification";const zs=(0,o.withBoundary)(Ws);function Vs(e){const t=(0,Ne.zy)(),a=(0,Ne.g)();return(0,g.jsx)(zs,{...e,location:t,params:a})}const Gs=m.U.trackingConfig.emailTrackingEnabled,Ys={onNoItemsFound:(e,t)=>t?(0,u.__)("No emails found.","mailpoet"):(0,u.__)("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,u.__)("1 email was moved to the trash.","mailpoet"):(0,u.__)("%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,u.__)("1 email was permanently deleted.","mailpoet"):(0,u.__)("%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,u.__)("1 email has been restored from the Trash.","mailpoet"):(0,u.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},Ks=[{name:"subject",label:(0,u.__)("Subject","mailpoet"),sortable:!0},{name:"settings",label:(0,u.__)("Settings","mailpoet")},{name:"statistics",label:(0,u.__)("Clicked, Opened","mailpoet"),display:Gs},{name:"status",label:(0,u.__)("Status","mailpoet"),width:145},{name:"updated_at",label:(0,u.__)("Last modified on","mailpoet"),sortable:!0}],Js=[{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:Ys.onTrash}];let Qs=[{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Preview","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,u.__)("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,u.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,bs.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,u.__)("Edit","mailpoet"),onClick:va.$U},{name:"trash",className:"mailpoet-hide-on-mobile"}];Qs=(0,va.pE)(Qs);class Zs 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,u.__)("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,u._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",e.total_sent.toLocaleString());return(0,g.jsxs)("div",{children:[(0,g.jsx)(Wa.l,{className:"mailpoet-listing-status-toggle",onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"active"===e.status}),(0,g.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,g.jsx)(Se.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:t})})]})};renderSettings=e=>{if(0===e.segments.length)return(0,g.jsx)(Se.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,u.__)("You need to select a list to send to.","mailpoet")});const t=Ge()((0,u.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(xs.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(xs.y,{newsletter:e},`filter-segment-${a}`)]},a));let a=(0,u._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet");e.options.afterTimeNumber>1&&"months"===e.options.afterTimeType?a=(0,u._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):e.options.afterTimeNumber>1&&"weeks"===e.options.afterTimeType?a=(0,u._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"):1===e.options.afterTimeNumber&&"weeks"===e.options.afterTimeType&&(a=(0,u._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet"));const i=(0,u._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",e.options.afterTimeNumber).replace("{$frequency}",a);return(0,g.jsxs)("span",{children:[t,(0,g.jsxs)("div",{className:"mailpoet-listing-schedule",children:[(0,g.jsx)("div",{className:"mailpoet-listing-schedule-icon",children:(0,g.jsx)(Ms.x,{})}),i]})]})};renderItem=(e,t)=>{const a=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:a,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),onClick:t=>{t.preventDefault(),(0,va.$U)(e)},children:e.subject}),t]}),(0,g.jsx)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,u.__)("Settings","mailpoet"),children:this.renderSettings(e)}),!0===Gs?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,u.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Us,{newsletter:e,isSent:e.total_sent>0&&!!e.statistics})}):null,(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,g.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Last modified on","mailpoet"),children:[m.U.Date.short(e.updated_at),(0,g.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};isItemInactive=e=>"draft"===e.status;render(){return(0,g.jsxs)(g.Fragment,{children:[0===this.state.newslettersCount&&(0,g.jsx)(pa,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1}),0!==this.state.newslettersCount&&(0,g.jsx)(Ie.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:Ks,bulk_actions:Js,item_actions:Qs,messages:Ys,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,va.DP)(e),(0,va.tQ)(e)}})]})}}Zs.propTypes={location:Qe().object.isRequired,params:Qe().object.isRequired},Zs.displayName="NewsletterListReEngagement";const Xs=(0,o.withBoundary)(Zs);function en(e){const t=(0,Ne.zy)(),a=(0,Ne.g)();return(0,g.jsx)(Xs,{...e,location:t,params:a})}const tn=m.U.trackingConfig.emailTrackingEnabled,an=[{name:"subject",label:(0,u.__)("Subject","mailpoet")},{name:"status",label:(0,u.__)("Status","mailpoet")},{name:"segments",label:(0,u.__)("Lists","mailpoet")},{name:"statistics",label:(0,u.__)("Clicked, Opened","mailpoet"),display:tn},{name:"sent_at",label:(0,u.__)("Sent on","mailpoet"),sortable:!0}],sn={onNoItemsFound:(e,t)=>t?(0,u.__)("No emails found.","mailpoet"):(0,u.__)("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,u.__)("1 email was moved to the trash.","mailpoet"):(0,u.__)("%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,u.__)("1 email was permanently deleted.","mailpoet"):(0,u.__)("%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,u.__)("1 email has been restored from the Trash.","mailpoet"):(0,u.__)("%1$d emails have been restored from the Trash.","mailpoet").replace("%1$d",t.toLocaleString()),m.U.Notice.success(a)}},nn=[{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:sn.onTrash}],rn=(0,va.pE)([{name:"view",link:function(e){return(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Preview","mailpoet")})}},{name:"trash",className:"mailpoet-hide-on-mobile"}]),on=(e,t,a)=>{const i=Z()("manage-column","column-primary","has-row-actions");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{className:i,children:[(0,g.jsx)("strong",{children:(0,g.jsx)("a",{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",children:e.queue.newsletter_rendered_subject||e.subject})}),t]}),(0,g.jsx)("td",{className:"column mailpoet-listing-status-column","data-colname":(0,u.__)("Status","mailpoet"),children:(0,g.jsx)(Ss,{newsletter:e,mailerLog:a.mta_log})}),(0,g.jsxs)("td",{className:"column mailpoet-hide-on-mobile","data-colname":(0,u.__)("Lists","mailpoet"),children:[(0,g.jsx)(xs.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(xs.y,{newsletter:e,dimension:"large"})]}),!0===tn?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":(0,u.__)("Clicked, Opened","mailpoet"),children:(0,g.jsx)(Us,{newsletter:e,currentTime:a.current_time})}):null,(0,g.jsx)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Sent on","mailpoet"),children:e.sent_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(e.sent_at),(0,g.jsx)("br",{}),m.U.Date.time(e.sent_at)]}):null})]})};function ln(e){const t=(0,Ne.g)(),a=(0,Ne.zy)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,g.jsx)(Se.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,u.__)("Back to Post notifications","mailpoet")})}),(0,g.jsx)(Ie.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:on,columns:an,messages:sn,item_actions:rn,bulk_actions:nn,auto_refresh:!0,sort_by:"sent_at",sort_order:"desc",afterGetItems:e=>{(0,va.DP)(e),(0,va.tQ)(e)}})]})}ln.propTypes={parentId:Qe().string.isRequired},ln.displayName="NewsletterListNotificationHistory";const dn=(0,o.withBoundary)(ln),cn=[{name:"subscriber_id",label:(0,u.__)("Subscriber","mailpoet"),sortable:!0},{name:"status",label:(0,u._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet")},{name:"failureReason",label:(0,u.__)("Failure reason (if applicable)","mailpoet")}],mn={onNoItemsFound:()=>(0,u.__)("No sending task found.","mailpoet")};function pn(){const e=(0,Ne.g)(),t=(0,Ne.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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h1",{children:(0,u._x)("Sending status","Page title. This page displays a list of emails along with their sending status: unprocessed, sent or failed.","mailpoet")}),(0,g.jsx)(gn,{newsletter:a}),(0,g.jsx)(hn,{location:t,params:e,refreshRef:s})]})}pn.displayName="SendingStatus";const un=(e,t)=>e.location.pathname===t.location.pathname&&e.params.id===t.params.id,hn=(0,r.memo)(({location:e,params:t,refreshRef:a})=>(0,g.jsx)(Ie.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,g.jsx)("div",{children:(0,g.jsx)(_n,{...e,refreshRef:t})}))(e,a),getListingItemKey:e=>`${e.taskId}-${e.subscriberId}`,columns:cn,messages:mn,auto_refresh:!0,sort_by:"failed",sort_order:"desc",refreshRef:a,afterGetItems:e=>{(0,va.DP)(e),(0,va.tQ)(e)}}),un);function gn({newsletter:e={id:null,subject:null,sent:!1}}){return e.id&&e.subject&&e.sent?(0,g.jsx)("p",{children:(0,g.jsx)(Se.Link,{to:`/stats/${e.id}`,children:e.subject})}):null}function _n({failed:e,taskId:t,processed:a,email:i,subscriberId:s,lastName:n,firstName:r,refreshRef:o=null,error:l=""}){const d=Z()("manage-column","column-primary","has-row-actions");let c=(0,u._x)("Unprocessed","status when the sending of a newsletter has not been processed","mailpoet");return a&&(c=e?(0,g.jsxs)("span",{children:[(0,u._x)("Failed","status when the sending of a newsletter has failed","mailpoet"),(0,g.jsx)("br",{}),(0,g.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,u.__)("Resend","mailpoet")})]}):(0,u._x)("Sent","status when a newsletter has been sent","mailpoet")),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{"data-automation-id":`name_${t}_${s}`,className:d,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${s}`,children:i}),(0,g.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${r} ${n}`})]}),(0,g.jsx)("td",{className:"column","data-automation-id":`status_${t}_${s}`,"data-colname":(0,u._x)("Sending status","an email sending status: unprocessed, sent or failed.","mailpoet"),children:c}),(0,g.jsx)("td",{className:"column","data-automation-id":`error_${t}_${s}`,"data-colname":(0,u.__)("Failure reason (if applicable)","mailpoet"),children:l})]})}hn.propTypes={location:Qe().shape({pathname:Qe().string}).isRequired,params:Qe().shape({id:Qe().string.isRequired}).isRequired,refreshRef:Qe().shape({current:Qe().func})},gn.propTypes={newsletter:Qe().shape({id:Qe().string,subject:Qe().string,sent:Qe().bool})},_n.propTypes={error:Qe().string,email:Qe().string.isRequired,failed:Qe().number.isRequired,taskId:Qe().number.isRequired,lastName:Qe().string.isRequired,firstName:Qe().string.isRequired,processed:Qe().number.isRequired,subscriberId:Qe().number.isRequired,refreshRef:Qe().shape({current:Qe().func})},_n.displayName="ListingItem",pn.displayName="SendingStatus";var fn=a(59331),bn=a(65270),xn=a(38255),vn=a.n(xn);function jn({installedDaysAgo:e,reviewRequestIllustrationUrl:t,username:a}){const i=Math.round(e/30),s=e>30?(0,u.sprintf)((0,u._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,u.sprintf)((0,u._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,g.jsxs)("div",{className:"mailpoet_review_request",children:[(0,g.jsx)("img",{src:t,height:"280",width:"280",alt:""}),(0,g.jsx)("h2",{children:(0,u.__)("Thank you! Time to tell the world?","mailpoet")}),(0,g.jsx)("p",{children:(0,u.sprintf)((0,u.__)("%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,bs.escapeHTML)(a))}),(0,g.jsx)("p",{children:s}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"http://bit.ly/2Bi124o",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:(0,u.__)("Rate us now","mailpoet")})}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{id:"mailpoet_review_request_not_now",children:(0,u.__)("Not now")})})]})}const yn=(e=null)=>new Promise((t,a)=>{window.mailpoet_display_nps_poll&&window.mailpoet_3rd_party_libs_enabled?(Yi||(Yi=m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),Yi).then(({data:a})=>{((e,t)=>{let a;a=t||(window.mailpoet_display_nps_form?"EqOgKsgZd832Sz9w":window.mailpoet_is_new_user?"6L479eVPXk7pBn6S":"k0aJAsQAWI2ERyGv");const i={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,woocommerceVersion:e.woocommerceVersion,WordPressVersion:e.WordPressVersion,blockTheme:e.blockTheme,themeVersion:e.themeVersion,theme:e.theme};e.gutenbergVersion&&(i.gutenbergVersion=e.gutenbergVersion),e.wooCommerceVersion&&(i.wooCommerceVersion=e.wooCommerceVersion),vn()({writeKey:a,userId:window.mailpoet_current_wp_user.ID+window.mailpoet_site_url,traits:i,events:{submit:e=>{e.rating>=9&&e.completed&&m.U.Modal.popup({width:800,template:bn.renderToString(jn({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())}})}}})})(a,e),t()}):a()}),wn=e=>function(t){return(0,r.useLayoutEffect)(()=>{yn().catch(()=>{})},[]),(0,g.jsx)(e,{...t})};function Sn(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Oe,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(Ee.z,{heading:(0,u.__)("Emails","mailpoet"),children:(0,g.jsx)(Se.Link,{id:"mailpoet-new-email",className:"page-title-action",to:"/new",onClick:()=>{m.U.trackEvent("Emails > Add New")},"data-automation-id":"new_email",children:(0,u.__)("Add new email","mailpoet")})})]})}function Nn({children:e}){const t=(0,Ne.zy)();return null!==(0,ha.S)(t)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(t)?null:e}function Cn(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}Nn.propTypes={children:Qe().node.isRequired};var kn=a(14753),In=a(51556),Un=a(53007);const An=e=>{const t=e<.1?2:1;return m.U.Num.toLocaleFixed(e,t)},En=e=>+(+e).toFixed(1);function Tn({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=An(i),d=An(s),c=An(n),p=An(r),h=An(o),_=a>=20&&e.statistics.opened>=5,f=e.statistics.unsubscribed>=5&&a>=100,b=e.statistics.bounced>=5&&a>=100,x=(0,Un.u)("opened",s)||"",v=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${x}`,children:[d,"% "]}),(0,u._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),_&&(0,g.jsx)(Un.f,{isInverted:!1,stat:"opened",rate:s,tooltipId:`opened-${e.id||"0"}`,tooltipPlace:"right"})]}),j=(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[c,"% "]}),(0,u._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,g.jsx)(Te.Tooltip,{tooltip:Ge()((0,u.__)("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,g.jsx)("span",{style:{pointerEvents:"all"},children:(0,g.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"))})]}),y=En(r),w=f?(0,Un.u)("unsubscribed",y):"",S=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${w}`,children:[p,"% "]}),(0,u._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),f&&(0,g.jsx)(Un.f,{isInverted:!1,stat:"unsubscribed",rate:y,tooltipId:`unsubscribed-${e.id||"0"}`,tooltipPlace:"right"})]}),N=En(o),C=b?(0,Un.u)("bounced",N):"",k=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${C}`,children:[h,"% "]}),(0,u._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),b&&(0,g.jsx)(Un.f,{isInverted:!1,stat:"bounced",rate:N,tooltipId:`bounced-${e.id||"0"}`,tooltipPlace:"right"})]}),I=(0,Un.u)("clicked",i),U=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-statistics-value",children:[(0,g.jsxs)("span",{className:`mailpoet-statistics-value-number mailpoet-statistics-value-number-${I}`,children:[l,"% "]}),(0,u._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),_&&(0,g.jsx)(Un.f,{isInverted:!1,stat:"clicked",rate:i,tooltipId:`clicked-${e.id||"0"}`,tooltipPlace:"right"})]});return(0,g.jsxs)("div",{className:"mailpoet-stats-general",children:[(0,g.jsxs)(ka.Grid.ThreeColumns,{className:"mailpoet-stats-general-top-row",children:[(0,g.jsx)("div",{children:(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,u.__)("Sent to","mailpoet"),": ",(0,g.jsx)("span",{className:"mailpoet-statistics-value-number",children:a.toLocaleString()})]})}),(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:S}),(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:k})]}),(0,g.jsxs)(ka.Grid.ThreeColumns,{children:[(0,g.jsx)("div",{children:U}),(0,g.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[v,m.U.trackingConfig.opensSeparated&&j]}),t&&(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:At.Hooks.applyFilters("mailpoet_newsletters_revenues_stats",null,e.statistics.revenue)}),!t&&(0,g.jsx)("div",{})]}),(0,g.jsxs)("div",{className:"mailpoet-stats-general-read-more",children:[(0,g.jsx)("p",{className:"mailpoet-stats-has-margin-left",children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/190-whats-a-good-email-open-rate",target:"_blank",rel:"noopener noreferrer",children:(0,u.__)("Read more on stats.","mailpoet")})}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:`admin.php?page=mailpoet-newsletters#/sending-status/${e.id}`,children:(0,u.__)("Sending status","mailpoet")})})]})]})}Tn.displayName="NewsletterGeneralStats";var Rn=a(17741);const Dn=Zt.A,Fn=e=>m.U.getActiveEmailEditorUrl(e);function On({newsletter:e}){const[t,a]=(0,r.useState)(!1),i=e?.queue?.scheduled_at||e?.queue?.created_at||e?.created_at;return(0,g.jsxs)(ka.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,g.jsxs)("div",{children:[(0,g.jsxs)(ut.D,{level:1,children:[e.campaign_name?e.campaign_name:e.subject,e.campaign_name&&(0,g.jsx)("span",{children:` (${e.subject})`})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)(o.Tag,{isInverted:!1,children:(0,o.getNewsletterStatusString)(e.status)})," ",(0,g.jsxs)("b",{children:[m.U.Date.short(i)," • ",m.U.Date.time(i)]})]}),Array.isArray(e.segments)&&e.segments.length&&(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,u.__)("To","mailpoet")}),": ",(0,g.jsx)(o.SegmentTags,{dimension:"large",segments:e.segments}),(0,g.jsx)(o.FilterSegmentTag,{newsletter:e,dimension:"large"})]})]}),(0,g.jsx)("div",{className:"mailpoet-stats-info-sender-preview",children:(0,g.jsxs)("div",{children:[(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,u.__)("From","mailpoet"),": "]}),e.sender_address?e.sender_address:"-"]}),(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,u.__)("Reply-to","mailpoet"),": "]}),e.reply_to_address?e.reply_to_address:"-"]}),(0,g.jsxs)("div",{className:"mailpoet-stats-info-key-value",children:[(0,g.jsxs)("span",{className:"mailpoet-stats-info-key",children:[(0,u.__)("GA campaign","mailpoet"),": "]}),e.ga_campaign?e.ga_campaign:"-"]})]})}),(0,g.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,g.jsxs)(Xt.A,{children:[(0,g.jsx)(ce.Ay,{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,u.__)("Preview","mailpoet")}),(0,g.jsx)(ea.A,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:a})=>(0,g.jsxs)(Xt.A,{children:[(0,g.jsx)(ce.Ay,{disabled:"standard"!==e.type,onClick:()=>{(e=>{const t=Fn(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,o.confirmAlert)({message:(0,u.__)("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})(e)},variant:"primary",children:(0,u.__)("Edit","mailpoet")}),(0,g.jsxs)(ce.Ay,{onClick:a,"aria-expanded":t,variant:"primary",children:[" ",(0,g.jsx)(ta.A,{icon:aa.A,size:18})]})]}),renderContent:()=>(0,g.jsxs)(Rn.A,{children:[(0,g.jsx)(Dn,{isBusy:t,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==e.type,onClick:()=>{a(!0),((e,t=()=>{})=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"duplicate",data:{id:e.id}}).done(t=>{const a=Fn(t.data);m.U.Notice.success((0,u.sprintf)((0,u.__)('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()})})(e,()=>{a(!1)})},children:(0,u.__)("Duplicate","mailpoet")}),(0,g.jsx)(Dn,{isBusy:t,isDestructive:!0,onClick:()=>{a(!0),((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,u.__)("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()})})(e,()=>{a(!1)})},children:(0,u.__)("Move to Trash","mailpoet")})]})})]})})]})}function Pn(){const e=(0,g.jsx)(De.$,{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,u.__)("Upgrade","mailpoet")}),t=(0,g.jsxs)("p",{children:[(0,u.__)("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,g.jsx)("a",{href:"admin.php?page=mailpoet-upgrade",children:(0,u.__)("Learn more","mailpoet")}),"."]});return(0,g.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,g.jsx)(Wt,{message:t,actionButton:e,capabilities:{detailedAnalytics:!0}})})}function Ln(){return window.mailpoet_display_detailed_stats?null:(0,g.jsx)(Pn,{})}On.displayName="NewsletterStatsInfo",Ln.displayName="PremiumBanner";const Mn=(0,o.withBoundary)(Ln);function $n(){const[e,t]=(0,r.useState)({item:void 0,loading:!0}),a=(0,Ne.zy)(),i=(0,Ne.Zp)(),s=(0,Ne.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,p=l;return c?null:p?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Cn,{}),(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)("div",{className:"mailpoet-stats-page",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(On,{newsletter:p})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Tn,{newsletter:p,isWoocommerceActive:m.U.isWoocommerceActive})}),(0,g.jsxs)(kn.t,{activeKey:"clicked",children:[(0,g.jsx)(In.o,{title:(0,u.__)("Clicked Links","mailpoet"),children:At.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,g.jsx)(Mn,{}),p.clicked_links)},"clicked"),m.U.isWoocommerceActive&&(0,g.jsx)(In.o,{title:(0,u.__)("Products Sold","mailpoet"),automationId:"products-sold-tab",children:At.Hooks.applyFilters("mailpoet_newsletters_purchased_products",(0,g.jsx)(Mn,{}),p)},"products"),(0,g.jsx)(In.o,{title:(0,u.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:At.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,g.jsx)(Mn,{}),a,s,p)},"engagement"),(0,g.jsx)(In.o,{title:(0,u._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:At.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,g.jsx)(Mn,{}),a,s)},"bounces")]})]})]}):(0,g.jsxs)("h3",{children:[" ",(0,u.__)("This email does not exist.","mailpoet")," "]})}function Bn({newsletters:e}){return(0,g.jsxs)(h.$,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,g.jsx)("h3",{children:(0,u.__)("Paused emails","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("There was problem sending the following email(s), please fix the issues described for each email and resume.","mailpoet")}),(0,g.jsx)("ul",{children:e.map(({id:e,subject:t})=>(0,g.jsx)("li",{children:t},e))})]})}$n.displayName="CampaignStatsPage",Bn.displayName="CorruptEmailNotice";var qn=a(87948),Hn=a(56201);function Wn(){const e=(0,r.useCallback)(()=>{(0,Hn.k)({endpoint:"UserFlags",method:"set","data[legacy_automatic_emails_notice_dismissed]":"1"})},[]);return(0,g.jsx)(h.$,{type:"info",timeout:!1,closable:!0,renderInPlace:!0,onClose:e,children:(0,g.jsx)("p",{children:(0,qn.A)((0,u.__)("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,g.jsx)("a",{href:"admin.php?page=mailpoet-automation"})})})})}const zn=wn(()=>{const{parentId:e}=(0,Ne.g)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Nn,{children:(0,g.jsx)(Sn,{})}),window.mailpoet_legacy_automatic_emails_count>0&&!window.mailpoet_legacy_automatic_emails_notice_dismissed&&(0,g.jsx)(Wn,{}),m.U.corrupt_newsletters.length>0&&(0,g.jsx)(Bn,{newsletters:m.U.corrupt_newsletters}),(0,g.jsxs)(fn.k,{activeKey:"standard",routerType:"switch-only",onSwitch:e=>(e=>{m.U.trackEvent(`Tab Emails > ${e} clicked`)})(e),automationId:"newsletters_listing_tabs",children:[(0,g.jsx)(o.Tab,{route:"standard/*",title:(0,u.__)("Newsletters","mailpoet"),automationId:`tab-${(0,u.__)("Newsletters","mailpoet")}`,children:(0,g.jsx)(Ls,{})},"standard"),(0,g.jsx)(o.Tab,{route:"notification/*",title:(0,u.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,u.__)("Post Notifications","mailpoet")}`,children:e?(0,g.jsx)(dn,{parentId:e}):(0,g.jsx)(Vs,{})},"notification"),(0,g.jsx)(o.Tab,{route:"re_engagement/*",title:(0,u.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,u.__)("Re-engagement Emails","mailpoet")}`,children:(0,g.jsx)(en,{})},"re_engagement")]})]})}),Vn=[{path:"/notification/history/:parentId/*",children:(0,o.withBoundary)(zn)},{path:"/standard/*",children:(0,o.withBoundary)(zn)},{path:"/notification/*",children:(0,o.withBoundary)(zn)},{path:"/re_engagement/*",children:(0,o.withBoundary)(zn)},{path:"/new/standard",children:(0,o.withBoundary)(function(e){const t=(0,Ne.Zp)();return(0,g.jsx)(hs,{...e,navigate:t})})},{path:"/new/notification",children:(0,o.withBoundary)(function(){const e=(0,Ne.Zp)();return(0,g.jsx)(_s,{navigate:e})})},{path:"/new/re-engagement",children:(0,o.withBoundary)(fs)},{path:"/new",children:(0,o.withBoundary)(function(){return(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(d.x,{}),(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(Ee.z,{heading:(0,u.__)("What would you like to create?","mailpoet"),headingPrefix:(0,g.jsx)(Ee.o,{href:"#/",label:(0,u.__)("Listing","mailpoet"),"aria-label":(0,u.__)("Go back to email listing page","mailpoet")})}),(0,g.jsx)(pa,{})]})]})})},{name:"template",path:"/template/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ne.g)();return(0,g.jsx)(ya,{...e,params:t})})},{path:"/send/congratulate/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ne.g)();return(0,g.jsx)(us,{...e,params:t})})},{path:"/send/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ne.zy)(),a=(0,Ne.Zp)(),i=(0,Ne.g)();return(0,g.jsx)(as,{...e,location:t,navigate:a,params:i})})},{path:"/sending-status/:id/*",children:(0,o.withBoundary)(pn)},{path:"/stats/:id/*",children:(0,o.withBoundary)($n)}];function Gn(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(_,{mailpoetInstalledDaysAgo:m.U.installedDaysAgo,sendTransactionalEmails:m.U.transactionalEmailsEnabled,mtaMethod:m.U.mtaMethod,apiVersion:m.U.apiVersion,noticeDismissed:m.U.transactionalEmailsOptInNoticeDismissed})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(b.D,{})}),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"/",element:(0,g.jsx)(Ne.C5,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),Vn.map(e=>(0,g.jsx)(Ne.qh,{path:e.path,element:(0,g.jsx)(e.children,{})},e.path))]})]})})}const Yn=document.getElementById("newsletters_container");function Kn(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{}),(0,g.jsx)(Ee.z,{heading:(0,u.__)("Lists","mailpoet"),children:(0,g.jsx)(Se.Link,{className:"page-title-action",to:"/new","data-automation-id":"new-list",children:(0,u.__)("Add new list","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Re,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Fe,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(b.D,{})]})}Yn&&((0,o.registerTranslations)(),(0,n.createRoot)(Yn).render((0,g.jsx)(Gn,{})));const Jn=e=>"wp_users"===e.type,Qn=e=>"woocommerce_users"===e.type,Zn=e=>Jn(e)||Qn(e),Xn=m.U.trackingConfig.emailTrackingEnabled,er=[{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:Xn},{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}],tr={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)}},ar=[{name:"trash",label:m.U.I18n.t("moveToTrash"),onSuccess:tr.onTrash}],ir=e=>!Zn(e),sr=[{name:"edit",className:"mailpoet-hide-on-mobile",link:function(e){return(0,g.jsx)(Se.Link,{to:`/edit/${e.id}`,children:m.U.I18n.t("edit")})},display:function(e){return!Zn(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,bs.escapeHTML)(e.data.name))),t()}).fail(e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0})}),display:function(e){return!Zn(e)}},{name:"read_more",className:"mailpoet-hide-on-mobile",link:function(){return(0,g.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 Jn(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 Jn(e)||Qn(e)}},{name:"view_subscribers",link:function(e){return(0,g.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!Qn(e)}}];class nr extends r.Component{renderItem=(e,t)=>{const a=Z()("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=Zn(e)?(0,g.jsx)("span",{className:"mailpoet-listing-title",children:e.name}):(0,g.jsx)(Se.Link,{className:"mailpoet-listing-title",to:`/edit/${e.id}`,children:e.name}),(0,g.jsxs)("div",{children:[(0,g.jsxs)("td",{className:a,"data-automation-id":`segment_name_${(0,bs.escapeAttribute)(e.name)}`,children:[l,t]}),(0,g.jsx)("td",{"data-colname":m.U.I18n.t("description"),children:(0,g.jsx)("abbr",{children:e.description})}),Xn?(0,g.jsx)("td",{className:"column mailpoet-listing-stats-column","data-colname":m.U.I18n.t("averageScore"),children:(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)(he,{id:e.id,engagementScore:e.average_engagement_score})})}):null,(0,g.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("subscribed"),children:(0,g.jsx)("abbr",{children:i.toLocaleString()})}),(0,g.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("unconfirmed"),children:(0,g.jsx)("abbr",{children:s.toLocaleString()})}),(0,g.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("unsubscribed"),children:(0,g.jsx)("abbr",{children:n.toLocaleString()})}),(0,g.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("inactive"),children:(0,g.jsx)("abbr",{children:r.toLocaleString()})}),(0,g.jsx)("td",{className:"mailpoet-hide-on-mobile","data-colname":m.U.I18n.t("bounced"),children:(0,g.jsx)("abbr",{children:o.toLocaleString()})}),(0,g.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,g.jsx)("br",{}),m.U.Date.time(e.created_at)]})]})};render(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(na.x,{}),(0,g.jsx)(Kn,{}),(0,g.jsx)("div",{className:"mailpoet-segments-listing",children:(0,g.jsx)(Ie.l,{limit:window.mailpoet_listing_per_page,location:this.props.location,params:this.props.params,messages:tr,search:!1,endpoint:"segments",base_url:"lists",onRenderItem:this.renderItem,columns:er,bulk_actions:ar,item_actions:sr,sort_by:"name",sort_order:"asc",isItemDeletable:ir,isItemToggleable:Jn})})]})}}const rr=[{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}],or={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 lr(){const e=(0,Ne.g)();return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Ee.z,{heading:e.id?(0,u.__)("Edit list","mailpoet"):(0,u.__)("Add new list","mailpoet"),headingPrefix:(0,g.jsx)(Ee.o,{href:"#/",label:(0,u.__)("Lists","mailpoet"),"aria-label":(0,u.__)("Navigate to the lists page","mailpoet")})}),(0,g.jsx)(xt.X,{}),(0,g.jsx)(bt,{endpoint:"segments",fields:rr,params:e,messages:or})]})}lr.displayName="SegmentForm";const dr=document.getElementById("static_segments_container"),cr=(0,o.withBoundary)(lr),mr=(0,o.withBoundary)(function(e){const t=(0,Ne.g)(),a=(0,Ne.zy)();return(0,g.jsx)(nr,{...e,params:t,location:a})});function pr(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"/new",element:(0,g.jsx)(cr,{})}),(0,g.jsx)(Ne.qh,{path:"/edit/:id",element:(0,g.jsx)(cr,{})}),(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(mr,{})})]})]})})}dr&&((0,o.registerTranslations)(),(0,n.createRoot)(dr).render((0,g.jsx)(pr,{})));var ur=a(88032),hr=a(25281),gr=a(49188),_r=a(42732);function fr({children:e,title:t,description:a}){return(0,g.jsxs)("div",{className:"mailpoet-admin-fields",children:[(0,g.jsxs)("div",{className:"mailpoet-admin-fields-title",children:[(0,g.jsx)(_r.D,{level:4,children:t}),(0,g.jsx)("p",{children:a})]}),(0,g.jsx)(hr.A,{children:(0,g.jsx)(gr.A,{children:e})})]})}function br({children:e,slug:t,title:a,description:i}){return(0,g.jsxs)("div",{className:"mailpoet-admin-field",children:[a&&(0,g.jsx)("p",{children:(0,g.jsx)("label",{htmlFor:`field_${t}`,children:a})}),(0,g.jsx)("div",{children:e}),i&&(0,g.jsx)("p",{className:"mailpoet-admin-field-description",children:i})]})}var xr=a(85210),vr=a(74782),jr=a(36795),yr=a(65070);function wr({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(jr.Hz).getAutomations(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,pe.A)(jr.Hz);(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&i({operator:vr.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>{s("operator",e,t)},isMinWidth:!0,children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.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 Sr={[yr.g.ENTERED_AUTOMATION]:wr,[yr.g.EXITED_AUTOMATION]:wr};function Nr({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.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!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e),t.action===vr._R.MACHINE_OPENED&&t.operator===vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[t.action,t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),t.action!==vr._R.MACHINE_OPENED?(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")}):null]},"select"),(0,g.jsx)(ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:n,automationId:"segment-email",value:(0,Hi.filter)(e=>{if(!t.newsletters)return;const a=e.value;return-1!==t.newsletters.indexOf(a)},n),onChange:t=>{a({newsletters:(0,Hi.map)((0,Hi.parseInt)(10),(0,Hi.map)("value",t))},e)}})]})}const Cr=e=>!!e;var kr=a(96985);function Ir({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,pe.A)(jr.Hz);(0,r.useEffect)(()=>{(0,kr.J)(t.timeframe,vr.VE)||i({timeframe:vr.VE.IN_THE_LAST},e)},[t,i,e]);const s=t.timeframe===vr.VE.IN_THE_LAST;return(0,g.jsx)(g.Fragment,{children:(n=i=>s&&"{days}"===i?(0,g.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,g.jsxs)(it.Select,{value:t.timeframe,onChange:t=>{a("timeframe",e,t)},children:[(0,g.jsx)("option",{value:"inTheLast",children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:"allTime",children:m.U.I18n.t("overAllTime")})]},"timeframe-select"):s&&"string"==typeof i&&i.trim().length>1?(0,g.jsx)("div",{children:i},i):null,m.U.I18n.t("emailActionOpensDaysSentence").split(/({days})|({timeframe})/gim).map(n))});var n}function Ur(e){return e.timeframe===vr.VE.ALL_TIME||parseInt(e.days,10)>=1}function Ar({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{void 0===t.operator&&a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{opens}"===a?(0,g.jsx)(Ze.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,g.jsx)("div",{children:a},"opens"):null,m.U.I18n.t("emailActionOpensSentence").split(/({condition})|({opens})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]});var s}const Er={[vr._R.OPENS_ABSOLUTE_COUNT]:Ar,[vr._R.MACHINE_OPENS_ABSOLUTE_COUNT]:Ar,[vr._R.CLICKED]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getNewslettersList(),[]),[n,o]=(0,r.useState)([]),[l,d]=(0,r.useState)([]),[c,p]=(0,r.useState)(!1),h=s?.map(e=>{const t=e.sent_at?m.U.Date.format(e.sent_at):(0,u.__)("Not sent yet","mailpoet");return{label:e.name,tag:t,value:Number(e.id)}}),_=(0,r.useCallback)(()=>{var e;Cr(t.newsletter_id)&&(d([]),e=t.newsletter_id,o([]),p(!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}));p(!1),d(a)}).fail(e=>{o(e.errors)}))},[t.newsletter_id]);return(0,r.useEffect)(()=>{_()},[_,t.newsletter_id]),(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[n.length>0&&(0,g.jsx)(ra,{errors:n}),(0,g.jsx)(ur.ReactSelect,{placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:h,value:(0,Hi.find)(["value",t.newsletter_id],h),onChange:t=>{a({newsletter_id:t.value,link_ids:[]},e)},automationId:"segment-email"}),(0,g.jsxs)(it.Select,{isMinWidth:!0,value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),c&&(0,g.jsx)("span",{children:m.U.I18n.t("loadingDynamicSegmentItems")}),!c&&Cr(t.newsletter_id)&&(0,g.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,Hi.filter)(e=>!!t.link_ids&&-1!==t.link_ids.indexOf(e.value),l),onChange:t=>{a({link_ids:(t||[]).map(e=>e.value)},e)}})]})},[vr._R.OPENED]:Nr,[vr._R.WAS_SENT]:Nr,[vr._R.MACHINE_OPENED]:Nr,[vr._R.CLICKED_ANY]:null,[vr._R.NUMBER_RECEIVED]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{emails}"===a?(0,g.jsx)(Ze.p,{type:"number",value:t.emails||"","data-automation-id":"segment-number-emails-received",onChange:t=>{i("emails",e,t)},min:"0",placeholder:(0,u.__)("emails","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"emails"):null,(0,u.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]});var s},[vr._R.NUMBER_OF_CLICKS]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{["more","less","equals","not_equals"].includes(t.operator)||a({operator:"more"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"more",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("notEquals")})]},"select"):"{clicks}"===a?(0,g.jsx)(Ze.p,{type:"number",value:t.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:t=>{i("clicks",e,t)},min:"0",placeholder:(0,u.__)("clicks","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"clicks"):null,(0,u.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]});var s}};var Tr=a(89011);function Rr(e,t){const a=t?.additionalDigits??2,i=function(e){const t={},a=e.split(Dr.dateTimeDelimiter);let i;if(a.length>2)return t;if(/:/.test(a[0])?i=a[0]:(t.date=a[0],i=a[1],Dr.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Dr.timeZoneDelimiter)[0],i=e.substr(t.date.length,e.length))),i){const e=Dr.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(Fr);if(!a)return new Date(NaN);const i=!!a[4],s=Lr(a[1]),n=Lr(a[2])-1,r=Lr(a[3]),o=Lr(a[4]),l=Lr(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<=($r[t]||(Br(e)?29:28))}(t,n,r)&&function(e,t){return t>=1&&t<=(Br(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(Or);if(!t)return NaN;const a=Mr(t[1]),i=Mr(t[2]),s=Mr(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*Tr.s0+i*Tr.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(Pr);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*Tr.s0+s*Tr.Cg):NaN}(i.timezone),isNaN(r)?new Date(NaN):new Date(n+o+r)}const Dr={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Fr=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Or=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Pr=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Lr(e){return e?parseInt(e):1}function Mr(e){return e&&parseFloat(e.replace(",","."))||0}const $r=[31,null,31,30,31,30,31,31,30,31,30,31];function Br(e){return e%400==0||e%4==0&&e%100!=0}var qr=a(47195);let Hr=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 Wr=[Hr.BEFORE,Hr.AFTER,Hr.ON,Hr.ON_OR_AFTER,Hr.ON_OR_BEFORE,Hr.NOT_ON,Hr.IN_THE_LAST,Hr.NOT_IN_THE_LAST],zr=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"})}},Vr=e=>{if(!e)return;const t=Rr(e);return(0,qr.f)(t)?t:void 0};function Gr({filterIndex:e,defaultOperator:t}){const a=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{Wr.includes(a.operator)||i({operator:t},e),a.operator!==Hr.BEFORE&&a.operator!==Hr.AFTER&&a.operator!==Hr.ON&&a.operator!==Hr.ON_OR_AFTER&&a.operator!==Hr.ON_OR_BEFORE&&a.operator!==Hr.NOT_ON||void 0!==Vr(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||i({value:zr(new Date)},e),a.operator!==Hr.IN_THE_LAST&&a.operator!==Hr.NOT_IN_THE_LAST||"string"!=typeof a.value||/^\d*$/.exec(a.value)||i({value:""},e)},[i,a,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:a.operator,isMinWidth:!0,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:Hr.BEFORE,children:m.U.I18n.t("before")}),(0,g.jsx)("option",{value:Hr.ON_OR_BEFORE,children:m.U.I18n.t("onOrBefore")}),(0,g.jsx)("option",{value:Hr.ON,children:m.U.I18n.t("on")}),(0,g.jsx)("option",{value:Hr.NOT_ON,children:m.U.I18n.t("notOn")}),(0,g.jsx)("option",{value:Hr.ON_OR_AFTER,children:m.U.I18n.t("onOrAfter")}),(0,g.jsx)("option",{value:Hr.AFTER,children:m.U.I18n.t("after")}),(0,g.jsx)("option",{value:Hr.IN_THE_LAST,children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:Hr.NOT_IN_THE_LAST,children:m.U.I18n.t("notInTheLast")})]},"select"),(a.operator===Hr.BEFORE||a.operator===Hr.AFTER||a.operator===Hr.ON||a.operator===Hr.ON_OR_AFTER||a.operator===Hr.ON_OR_BEFORE||a.operator===Hr.NOT_ON)&&(0,g.jsx)(Aa.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value:zr(t)},e)},selected:a.value?Vr(a.value):void 0}),(a.operator===Hr.IN_THE_LAST||a.operator===Hr.NOT_IN_THE_LAST)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ze.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,g.jsx)("span",{children:m.U.I18n.t("daysPlaceholder")})]})]})}function Yr(e){return!(!e.operator||!e.value)&&([Hr.BEFORE,Hr.AFTER,Hr.ON,Hr.NOT_ON,Hr.ON_OR_BEFORE,Hr.ON_OR_AFTER].includes(e.operator)?/^\d+-\d+-\d+$/.test(e.value):!![Hr.IN_THE_LAST,Hr.NOT_IN_THE_LAST].includes(e.operator)&&(/^\d+$/.test(e.value)&&Number(e.value)>0))}function Kr(e){return function(t){return(0,g.jsx)(Gr,{...t,defaultOperator:e})}}const Jr=Kr(Hr.BEFORE),Qr=Kr(Hr.IN_THE_LAST);var Zr=a(42375);function Xr({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{void 0===t.number_of_orders_type&&a({number_of_orders_type:"="},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.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,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.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,g.jsx)("div",{children:m.U.I18n.t("wooNumberOfOrdersOrders")})]}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})}const eo=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function to(e){return!!eo.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function ao({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{eo.includes(t.operator)||i({operator:"is",value:""},e)},[i,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{automationId:"subscriber-text-field-select",value:t.operator,isMinWidth:!0,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"is",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:"isNot",children:m.U.I18n.t("isNot")}),(0,g.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,g.jsx)("option",{value:"notContains",children:m.U.I18n.t("notContains")}),(0,g.jsx)("option",{value:"startsWith",children:m.U.I18n.t("startsWith")}),(0,g.jsx)("option",{value:"notStartsWith",children:m.U.I18n.t("notStartsWith")}),(0,g.jsx)("option",{value:"endsWith",children:m.U.I18n.t("endsWith")}),(0,g.jsx)("option",{value:"notEndsWith",children:m.U.I18n.t("notEndsWith")})]},"select"),(0,g.jsx)(Ze.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 io={[Zr.Ag.CUSTOMER_IN_COUNTRY]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getWooCommerceCountries(),[]).map(e=>({value:e.code,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-country",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-country"),(0,g.jsx)(ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectWooCountry"),options:i,value:(0,Hi.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")]})},[Zr.Ag.CUSTOMER_IN_CITY]:ao,[Zr.Ag.CUSTOMER_IN_POSTAL_CODE]:ao,[Zr.Ag.NUMBER_OF_ORDERS]:Xr,[Zr.Ag.NUMBER_OF_ORDERS_WITH_COUPON]:Xr,[Zr.Ag.NUMBER_OF_REVIEWS]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{(0,kr.J)(t.count_type,vr.YR)||a({count_type:vr.YR.EQUALS},e),(0,kr.J)(t.rating,vr.Un)||a({rating:vr.Un.ANY},e),(0,kr.J)(t.timeframe,vr.VE)||a({timeframe:vr.VE.IN_THE_LAST},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(o.Select,{value:t.rating,isMinWidth:!0,onChange:t=>{i("rating",e,t)},children:[(0,g.jsx)("option",{value:vr.Un.ANY,children:m.U.I18n.t("wooAnyStarRating")}),(0,g.jsx)("option",{value:vr.Un.ONE,children:m.U.I18n.t("wooOneStarRating")}),(0,g.jsx)("option",{value:vr.Un.TWO,children:m.U.I18n.t("wooTwoStarRating")}),(0,g.jsx)("option",{value:vr.Un.THREE,children:m.U.I18n.t("wooThreeStarRating")}),(0,g.jsx)("option",{value:vr.Un.FOUR,children:m.U.I18n.t("wooFourStarRating")}),(0,g.jsx)("option",{value:vr.Un.FIVE,children:m.U.I18n.t("wooFiveStarRating")})]},"rating-select"),(0,g.jsxs)(o.Select,{value:t.count_type,isMinWidth:!0,onChange:t=>{i("count_type",e,t)},automationId:"select-number-of-reviews-type",children:[(0,g.jsx)("option",{value:vr.YR.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:vr.YR.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:vr.YR.MORE_THAN,children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:vr.YR.LESS_THAN,children:m.U.I18n.t("lessThan")})]},"select"),(0,g.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,g.jsx)("div",{children:m.U.I18n.t("wooNumberOfReviewsReviews")}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.PURCHASE_DATE]:Jr,[Zr.Ag.PURCHASED_PRODUCT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ALL&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedProduct"),options:i,value:(0,Hi.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")]})},[Zr.Ag.PURCHASED_CATEGORY]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getProductCategories(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ALL&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedCategory"),options:i,value:(0,Hi.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")]})},[Zr.Ag.PURCHASED_WITH_ATTRIBUTE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.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,v.A)(e=>e(jr.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!==vr.dP.ALL&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&a({operator:vr.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]),p=(0,r.useMemo)(()=>"local"===t.attribute_type?(0,Hi.filter)(e=>{if(t.attribute_local_name)return`${t.attribute_local_name}@local`===e.value},o):(0,Hi.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]),h=(0,r.useMemo)(()=>(0,Hi.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]),_=(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,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:(0,u.__)("any of","mailpoet")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:(0,u.__)("all of","mailpoet")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:(0,u.__)("none of","mailpoet")})]},"select-operator"),(0,g.jsx)(ur.ReactSelect,{dimension:"small",placeholder:(0,u.__)("Search attributes","mailpoet"),options:d,value:p,onChange:m},"select-segment-product-attribute"),c.length>0&&(0,g.jsx)(ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:(0,u.__)("Search attributes terms","mailpoet"),options:c,value:h,onChange:_},"select-segment-product-attribute-terms")]})},[Zr.Ag.PURCHASED_TAG]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getProductTags(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ALL&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(ur.ReactSelect,{isMulti:!0,dimension:"small",placeholder:(0,u.__)("Search tags","mailpoet"),options:i,value:(0,Hi.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")]})},[Zr.Ag.SINGLE_ORDER_VALUE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{void 0===t.single_order_value_type&&a({single_order_value_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.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,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.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,g.jsx)("div",{children:s})]}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.TOTAL_SPENT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{void 0===t.total_spent_type&&a({total_spent_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{value:t.total_spent_type,onChange:t=>{i("total_spent_type",e,t)},automationId:"select-total-spent-type",children:[(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.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,g.jsx)("div",{children:s})]}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.AVERAGE_SPENT]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getWooCommerceCurrencySymbol(),[]);return(0,r.useEffect)(()=>{[">",">=","=","!=","<=","<"].includes(t.average_spent_type)||a({average_spent_type:">"},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.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,g.jsx)("option",{value:">",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:">=",children:m.U.I18n.t("moreThanOrEqual")}),(0,g.jsx)("option",{value:"=",children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:"!=",children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:"<=",children:m.U.I18n.t("lessThanOrEqual")}),(0,g.jsx)("option",{value:"<",children:m.U.I18n.t("lessThan")})]},"select"),(0,g.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,g.jsx)("div",{children:s}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.USED_COUPON_CODE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),[i,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[p,h]=(0,r.useState)(1),[_,f]=(0,r.useState)(!0),[b,x]=(0,r.useState)(""),[j,y]=(0,r.useState)([]),w=(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?f(!1):(l(e=>(0,Hi.uniqBy)(e=>e.value,[...e,...s])),h(n)),e||c(!1)}).fail(e=>{y(e.errors)}))},[t.coupon_code_ids]),S=(0,Hi.debounce)(300,e=>{const t=b;x(e),!d&&(_&&e||t&&!e)&&(h(1),w(!1,1,e,_))});return(0,r.useEffect)(()=>{i||(w(!0,p,b,_),s(!0))},[i,p,b,w,_]),(0,r.useEffect)(()=>{Array.isArray(t.coupon_code_ids)||a({coupon_code_ids:[]},e),(0,kr.J)(t.operator,vr.dP)||a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[j.length>0&&(0,g.jsx)(ra,{errors:j}),i?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-coupon-code",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,g.jsx)(ur.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:d,placeholder:m.U.I18n.t("selectWooCouponCodes"),options:n,value:(0,Hi.filter)(e=>{if(t.coupon_code_ids)return-1!==t.coupon_code_ids.indexOf(e.value)},n),onInputChange:e=>{S(e)},onChange:t=>{a({coupon_code_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!d&&_&&w(!1,p,b,_)}},"select-coupon-codes")]}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]}):(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,u.__)("Loading coupon codes...","mailpoet")})]})},[Zr.Ag.USED_PAYMENT_METHOD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getPaymentMethods(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-payment-methods",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,g.jsx)(ur.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooPaymentMethods"),options:i,value:(0,Hi.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,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.USED_SHIPPING_METHOD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getShippingMethods(),[]).map(e=>({value:e.instanceId,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(o.Select,{isMaxContentWidth:!0,value:t.operator,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-used-shipping-methods",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,g.jsx)(ur.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooShippingMethods"),options:i,value:(0,Hi.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,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(Ir,{filterIndex:e})})]})},[Zr.Ag.FIRST_ORDER]:Jr};function so({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);(0,r.useEffect)(()=>{t.action===vr.gw.WORDPRESS_ROLE&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]);const s=(0,v.A)(e=>e(jr.Hz).getWordpressRoles(),[]).map(e=>({value:e.role_id,label:e.role_name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsxs)(it.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select")}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(ur.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:m.U.I18n.t("selectUserRolePlaceholder"),options:s,value:(0,Hi.filter)(e=>{if(t.wordpressRole)return-1!==t.wordpressRole.indexOf(e.value)},s),onChange:t=>{a({wordpressRole:(0,Hi.map)("value",t)},e)}})})]})}let no=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 ro=[no.HIGHER_THAN,no.LOWER_THAN,no.EQUALS,no.NOT_EQUALS,no.UNKNOWN,no.NOT_UNKNOWN];function oo(e){return!!(0,vr.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 lo({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{void 0===t.operator&&i({operator:"equals",value:""},e)},[i,t,e]),(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:"not_equals",children:m.U.I18n.t("isNot")}),(0,g.jsx)("option",{value:"contains",children:m.U.I18n.t("contains")}),(0,g.jsx)("option",{value:"not_contains",children:m.U.I18n.t("notContains")}),(0,g.jsx)("option",{value:"more_than",children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:"less_than",children:m.U.I18n.t("lessThan")}),(0,g.jsx)("option",{value:"is_blank",children:m.U.I18n.t("isBlank")}),(0,g.jsx)("option",{value:"is_not_blank",children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,vr.uA)(t.operator)&&(0,g.jsx)(Ze.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 co(e){return!!(0,vr.uA)(e.operator)||"string"==typeof e.value&&e.value.length>0}function mo({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getCustomFieldsList(),[]),n=(0,Hi.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,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{automationId:"text-custom-field-operator",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:m.U.I18n.t("is")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:m.U.I18n.t("isBlank")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,vr.uA)(t.operator)&&(0,g.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 po=a(85963);var uo=a(76592);function ho(e){return!!(0,vr.uA)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const go=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")}},_o=e=>{const t=Rr(e);if((0,qr.f)(t))return t},fo={month:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{ho(t)||e((0,Hi.assign)(t,{value:"2017-01-01 00:00:00"}),a),void 0===t.operator&&e((0,Hi.assign)(t,{operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:i=>{e((0,Hi.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,u.__)("is","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:(0,u.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:(0,u.__)("is not blank","mailpoet")})]},"select-operator"),!(0,vr.uA)(t.operator)&&(0,g.jsxs)(it.Select,{value:t.value,onChange:i=>{e((0,Hi.assign)(t,{value:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,u.__)("january","mailpoet")}),(0,g.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,u.__)("february","mailpoet")}),(0,g.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,u.__)("march","mailpoet")}),(0,g.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,u.__)("april","mailpoet")}),(0,g.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,u.__)("may","mailpoet")}),(0,g.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,u.__)("june","mailpoet")}),(0,g.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,u.__)("july","mailpoet")}),(0,g.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,u.__)("august","mailpoet")}),(0,g.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,u.__)("september","mailpoet")}),(0,g.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,u.__)("october","mailpoet")}),(0,g.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,u.__)("november","mailpoet")}),(0,g.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,u.__)("december","mailpoet")})]},"select")]})},year:function({onChange:e,item:t,filterIndex:a}){const i=(s=new Date,(0,po.a)(s).getFullYear());var s;return(0,r.useEffect)(()=>{ho(t)||e((0,Hi.assign)(t,{value:`${i}-01-01 00:00:00`,operator:"equals"}),a)},[i,e,t,a]),(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:i=>{e((0,Hi.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,u.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,u._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,u._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:(0,u.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:(0,u.__)("is not blank","mailpoet")})]},"select-operator"),(0,g.jsx)(it.Select,{value:t.value,onChange:i=>{e((0,Hi.assign)(t,{value:i.target.value}),a)},children:(0,Hi.range)(0,100).map(e=>(0,g.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,Hi.assign)(t,{value:`${(0,uo.GP)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:i=>{e((0,Hi.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,u.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,u._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,u._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:(0,u.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:(0,u.__)("is not blank","mailpoet")})]},"select-operator"),!(0,vr.uA)(t.operator)&&(0,g.jsx)(Aa.t,{onChange:i=>e((0,Hi.assign)(t,{value:go(i)}),a),selected:t.value?_o(t.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{ho(t)||e((0,Hi.assign)(t,{value:`${(0,uo.GP)(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:i=>{e((0,Hi.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,u.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,u._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,u._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:(0,u.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:(0,u.__)("is not blank","mailpoet")})]},"select-operator"),!(0,vr.uA)(t.operator)&&(0,g.jsx)(Aa.t,{dateFormat:"MMM d, yyyy",onChange:i=>e((0,Hi.assign)(t,{value:go(i)}),a),selected:t.value?_o(t.value):void 0})]})}};var bo=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(bo||{});const xo={[bo.TEXT]:oo,[bo.TEXTAREA]:oo,[bo.RADIO]:co,[bo.SELECT]:co,[bo.CHECKBOX]:function(e){return!!(0,vr.uA)(e.operator)||["1","0"].includes(e.value)},[bo.DATE]:ho},vo={[bo.TEXT]:lo,[bo.TEXTAREA]:lo,[bo.RADIO]:mo,[bo.SELECT]:mo,[bo.CHECKBOX]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,pe.A)(jr.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,g.jsxs)(ka.Grid.CenteredRow,{children:[(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:(0,u.__)("is","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.BLANK,children:(0,u.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:vr.FI.NOT_BLANK,children:(0,u.__)("is not blank","mailpoet")})]},"select-operator"),!(0,vr.uA)(t.operator)&&(0,g.jsxs)(it.Select,{value:t.value,onChange:t=>a("value",e,t),children:[(0,g.jsx)("option",{value:"1",children:(0,u.__)("checked","mailpoet")}),(0,g.jsx)("option",{value:"0",children:(0,u.__)("unchecked","mailpoet")})]},"select")]})},[bo.DATE]:function({customField:e,filterIndex:t}){const a=(0,v.A)(e=>e(jr.Hz).getSegmentFilter(t),[t]),{updateSegmentFilter:i}=(0,pe.A)(jr.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=fo[e.params.date_type];return s?(0,g.jsx)(s,{item:a,onChange:i,filterIndex:t}):null}};function jo(){return(0,g.jsx)(Wt,{message:(()=>{const e=m.U.I18n.t("premiumFeatureMultipleConditions");return(0,g.jsx)("p",{children:Ge()(e,/\[link](.*?)\[\/link]/g,e=>(0,g.jsx)("a",{href:m.U.premiumLink,target:"_blank",rel:"noopener noreferrer",children:e},e))})})(),actionButton:(0,g.jsx)(De.$,{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 yo={[vr.gw.WORDPRESS_ROLE]:so,[vr.gw.SUBSCRIBER_SCORE]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz);return(0,r.useEffect)(()=>{ro.includes(t.operator)||a({operator:no.HIGHER_THAN},e),t.operator!==no.HIGHER_THAN&&t.operator!==no.LOWER_THAN&&t.operator!==no.EQUALS&&t.operator!==no.NOT_EQUALS||void 0!==t.value||a({value:""},e),t.operator!==no.UNKNOWN&&t.operator!==no.NOT_UNKNOWN||a({value:null},e)},[a,t,e]),(0,g.jsx)(ka.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(it.Select,{value:t.operator,automationId:"segment-subscriber-score-operator",onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:no.HIGHER_THAN,children:m.U.I18n.t("higherThan")}),(0,g.jsx)("option",{value:no.LOWER_THAN,children:m.U.I18n.t("lowerThan")}),(0,g.jsx)("option",{value:no.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:no.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:no.UNKNOWN,children:m.U.I18n.t("unknown")}),(0,g.jsx)("option",{value:no.NOT_UNKNOWN,children:m.U.I18n.t("notUnknown")})]},"select"):"{score}"===a?(t.operator===no.HIGHER_THAN||t.operator===no.LOWER_THAN||t.operator===no.EQUALS||t.operator===no.NOT_EQUALS)&&(0,g.jsx)(Ze.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!==no.UNKNOWN&&t.operator!==no.NOT_UNKNOWN&&(0,g.jsx)("div",{children:a},"score"):null,m.U.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(s))});var s},[vr.gw.SUBSCRIBED_DATE]:Jr,[vr.gw.MAILPOET_CUSTOM_FIELD]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getCustomFieldsList(),[]),s=(0,Hi.find)({id:Number(t.custom_field_id)},i),n=i.map(e=>({value:e.id.toString(),label:e.name})),r=vo[t.custom_field_type];return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(ur.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectCustomFieldPlaceholder"),options:n,automationId:"select-custom-field",value:(0,Hi.find)(e=>{if(t.custom_field_id)return t.custom_field_id===e.value},n),onChange:t=>{const s=(0,Hi.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,g.jsx)("div",{children:r&&(0,g.jsx)(r,{customField:s,filterIndex:e})})]})},[vr.gw.SUBSCRIBED_TO_LIST]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(jr.Hz).getStaticSegmentsList(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,pe.A)(jr.Hz);(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&i({operator:vr.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(ur.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchLists"),options:n,value:(0,Hi.filter)(e=>{if(!t.segments)return;const a=e.value;return-1!==t.segments.indexOf(a)},n),onChange:t=>{i({segments:(0,Hi.map)((0,Hi.parseInt)(10),(0,Hi.map)("value",t))},e)}})]})},[vr.gw.SUBSCRIBER_TAG]:function({filterIndex:e}){return At.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,g.jsx)(jo,{}),e)},[vr.gw.SUBSCRIBER_FIRST_NAME]:ao,[vr.gw.SUBSCRIBER_LAST_NAME]:ao,[vr.gw.SUBSCRIBER_EMAIL]:ao,[vr.gw.SUBSCRIBED_VIA_FORM]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=(0,v.A)(e=>e(jr.Hz).getSignupForms(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,pe.A)(jr.Hz);(0,r.useEffect)(()=>{t.operator!==vr.dP.ANY&&t.operator!==vr.dP.NONE&&i({operator:vr.dP.ANY},e)},[i,t,e]);const n=a.map(e=>({value:e.id,label:e.name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(it.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.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)}})]})},[vr.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:Qr,[vr.gw.SUBSCRIBER_LAST_PURCHASE_DATE]:Qr,[vr.gw.SUBSCRIBER_LAST_OPEN_DATE]:Qr,[vr.gw.SUBSCRIBER_LAST_CLICK_DATE]:Qr,[vr.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:Qr,[vr.gw.SUBSCRIBER_LAST_SENDING_DATE]:Qr},wo={[vr.dx.Automations]:function(e){return!!Object.values(yr.g).some(t=>t===e.action)&&(e.action!==yr.g.ENTERED_AUTOMATION||function(e){return(e.operator===vr.dP.ANY||e.operator===vr.dP.NONE||e.operator===vr.dP.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[vr.dx.Email]:function(e){return!!Object.values(vr._R).some(t=>t===e.action)&&(e.action===vr._R.CLICKED_ANY||(e.action===vr._R.CLICKED?!!e.newsletter_id:[vr._R.OPENED,vr._R.MACHINE_OPENED,vr._R.WAS_SENT].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[vr._R.OPENS_ABSOLUTE_COUNT,vr._R.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?Ur(e)&&!!e.opens&&!!e.operator:vr._R.NUMBER_RECEIVED===e.action?Ur(e)&&!!e.emails&&!!e.operator:e.action===vr._R.NUMBER_OF_CLICKS&&Ur(e)&&!!e.clicks&&!!e.operator))},[vr.dx.WooCommerce]:function(e){return!!Object.values(Zr.Ag).some(t=>t===e.action)&&(e.action===Zr.Ag.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator)}(e):e.action===Zr.Ag.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator)}(e):e.action===Zr.Ag.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):[Zr.Ag.NUMBER_OF_ORDERS,Zr.Ag.NUMBER_OF_ORDERS_WITH_COUPON].includes(e.action)?function(e){return!(!e.number_of_orders_count||!Ur(e)||!e.number_of_orders_type)}(e):e.action===Zr.Ag.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!Ur(e)||!e.total_spent_type)}(e):e.action===Zr.Ag.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!Ur(e)||!e.single_order_value_type)}(e):e.action===Zr.Ag.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!Ur(e))}(e):e.action===Zr.Ag.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!Ur(e))}(e):e.action===Zr.Ag.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!Ur(e))}(e):e.action===Zr.Ag.PURCHASE_DATE?Yr(e):e.action===Zr.Ag.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&Ur(e))}(e):e.action===Zr.Ag.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,kr.J)(e.operator,vr.dP)||!Ur(e))}(e):e.action===Zr.Ag.FIRST_ORDER?Yr(e):e.action===Zr.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):[Zr.Ag.CUSTOMER_IN_POSTAL_CODE,Zr.Ag.CUSTOMER_IN_CITY].includes(e.action)?to(e):e.action!==Zr.Ag.PURCHASED_TAG||function(e){return!(void 0===e.tag_ids||0===e.tag_ids.length||!e.operator)}(e))},[vr.dx.WordPressRole]:function(e){return e.action&&e.action!==vr.gw.WORDPRESS_ROLE?e.action===vr.gw.MAILPOET_CUSTOM_FIELD?function(e){const t=xo[e.custom_field_type];return!!t&&t(e)}(e):e.action===vr.gw.SUBSCRIBER_SCORE?function(e){if(e.operator===no.HIGHER_THAN||e.operator===no.LOWER_THAN||e.operator===no.EQUALS||e.operator===no.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===no.UNKNOWN||e.operator===no.NOT_UNKNOWN}(e):e.action===vr.gw.SUBSCRIBED_TO_LIST?function(e){return(e.operator===vr.dP.ANY||e.operator===vr.dP.ALL||e.operator===vr.dP.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===vr.gw.SUBSCRIBER_TAG?function(e){return At.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[vr.gw.SUBSCRIBER_FIRST_NAME,vr.gw.SUBSCRIBER_LAST_NAME,vr.gw.SUBSCRIBER_EMAIL].includes(e.action)?to(e):[vr.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE,vr.gw.SUBSCRIBER_LAST_PURCHASE_DATE,vr.gw.SUBSCRIBER_LAST_OPEN_DATE,vr.gw.SUBSCRIBER_LAST_CLICK_DATE,vr.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE,vr.gw.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?Yr(e):e.action===vr.gw.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===vr.dP.ANY||e.operator===vr.dP.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(Hr).includes(e.operator)&&Yr(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[vr.dx.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==Zr.HM.MEMBER_OF||!t},[vr.dx.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==Zr.IC.ACTIVE_SUBSCRIPTIONS||!t}};function So(e){return!(e.length<1)&&0===e.map(e=>void 0!==wo[e.segmentType]&&wo[e.segmentType](e)).filter(e=>!1===e).length}let No,Co;function ko(){const e=(0,v.A)(e=>e(jr.Hz).getSegment(),[]),t=(0,v.A)(e=>e(jr.Hz).getSubscriberCount(),[]),{updateSubscriberCount:a}=(0,pe.A)(jr.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,wa.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 Sa().isEqual(t,No)?Promise.resolve(Co):(No={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 Co={count:t.count,errors:void 0},Co}))}(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)(()=>{So(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,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsxs)("span",{className:"mailpoet-form-error-message",children:[m.U.I18n.t("dynamicSegmentSizeCalculatingTimeout")," ",(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/237-guide-to-subscriber-segmentation",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,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSizeIsCalculated")})}):(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("dynamicSegmentSize").replace("%1$d",t.count.toLocaleString())})}):(0,g.jsx)("span",{})}const Io={[vr.dx.Automations]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=Sr[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[vr.dx.Email]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=Er[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[vr.dx.WooCommerce]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),a=io[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[vr.dx.WordPressRole]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]);let a;return a=t.action?yo[t.action]:so,a?(0,g.jsx)(a,{filterIndex:e}):null},[vr.dx.WooCommerceMembership]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getMembershipPlans(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===Zr.HM.MEMBER_OF&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(ur.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooMembership"),options:s,value:(0,Hi.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")})]})},[vr.dx.WooCommerceSubscription]:function({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,pe.A)(jr.Hz),s=(0,v.A)(e=>e(jr.Hz).getSubscriptionProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===Zr.IC.ACTIVE_SUBSCRIPTIONS&&t.operator!==vr.dP.ANY&&t.operator!==vr.dP.ALL&&t.operator!==vr.dP.NONE&&a({operator:vr.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsxs)(it.Select,{value:t.operator,onChange:t=>i("operator",e,t),automationId:"select-operator",children:[(0,g.jsx)("option",{value:vr.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:vr.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:vr.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(ka.Grid.CenteredRow,{children:(0,g.jsx)(ur.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooSubscription"),options:s,value:(0,Hi.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 Uo({filterIndex:e}){const t=(0,v.A)(t=>t(jr.Hz).getSegmentFilter(e),[e]);if(void 0===t||void 0===Io[t.segmentType])return null;const a=Io[t.segmentType];return(0,g.jsx)(a,{filterIndex:e})}function Ao(){const e=(0,v.A)(e=>e(jr.Hz).getSegment(),[]),t=[vr._R.OPENED,vr._R.OPENS_ABSOLUTE_COUNT,vr._R.MACHINE_OPENED,vr._R.MACHINE_OPENS_ABSOLUTE_COUNT];let a=!1;return e.filters.forEach(e=>{t.includes(e.action)&&(a=!0)}),a?(0,g.jsx)("div",{className:"mailpoet-form-field",children:(0,g.jsx)("span",{className:"mailpoet-form-notice-message",children:m.U.I18n.t("privacyProtectionNotice")})}):(0,g.jsx)("span",{})}const Eo=At.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",()=>null),To=At.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",()=>null),Ro=At.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",()=>(0,g.jsx)("div",{className:"mailpoet-gap"}));function Do({isNewSegment:e,newsletterId:t}){const{segment:a,segmentFilters:i,subscriberCount:s,filterRows:n,errors:o}=(0,v.A)(e=>{const t=e(jr.Hz).getSegment();return{segment:t,segmentFilters:e(jr.Hz).getAvailableFilters(),subscriberCount:e(jr.Hz).getSubscriberCount(),filterRows:e(jr.Hz).findFiltersValueForSegment(t),errors:e(jr.Hz).getErrors()}},[]),l=a.filters.length,d=m.U.capabilities.segmentFilters.value>0&&l>=m.U.capabilities.segmentFilters.value,{updateSegment:c,updateSegmentFilter:p,handleSave:h}=(0,pe.A)(jr.Hz),[_,f]=(0,r.useState)(!1),b=At.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",()=>{f(!0)});return(0,g.jsx)("div",{className:"mailpoet-form-container",children:(0,g.jsxs)("form",{children:[o.length>0&&(0,g.jsx)(ra,{errors:o.map(e=>({message:e}))}),(0,g.jsxs)(fr,{title:(0,u.__)("Details","mailpoet"),description:(0,u.__)("What do you want to call this segment?","mailpoet"),children:[(0,g.jsx)(br,{slug:"name",title:(0,u.__)("Name","mailpoet"),children:(0,g.jsx)(Ze.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,u.__)("Enter name","mailpoet")})}),(0,g.jsx)(br,{slug:"description",title:(0,u.__)("Description","mailpoet"),description:(0,u.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,g.jsx)(Ze.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,u.__)("Enter description","mailpoet")})})]}),(0,g.jsx)(fr,{title:(0,u.__)("Conditions","mailpoet"),description:(0,u.__)("Set your segment constraints","mailpoet"),children:(0,g.jsx)(br,{children:(0,g.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,g.jsx)(Eo,{}),Array.isArray(n)&&n.map((e,t)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t}`,children:[(0,g.jsx)(To,{filterRows:n,index:t}),(0,g.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,g.jsx)(ur.ReactSelect,{dimension:"small",placeholder:(0,u.__)("Select action","mailpoet"),options:i,value:e.filterValue,onChange:e=>{p({segmentType:e.group,action:e.value},t)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==e.index&&(0,g.jsx)(Uo,{filterIndex:e.index})]}),(0,g.jsx)(Ro,{index:t})]},e.index)),(0,g.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,g.jsx)(ce.Ay,{type:"button",variant:"secondary",onClick:e=>{e.preventDefault(),b(a,c)},children:(0,u.__)("Add a condition","mailpoet")}),(!m.U.premiumActive||!m.U.hasValidPremiumKey||m.U.subscribersLimitReached||d)&&(0,g.jsx)(xr.S,{text:(0,u.__)("UPGRADE","mailpoet")}),_&&(0,g.jsx)(Va.D,{onRequestClose:()=>{f(!1)},data:{capabilities:{segmentFilters:0}},children:(0,u.__)("Multiple conditions per segment are not available in the free version of the MailPoet plugin.","mailpoet")})]})]})})}),(0,g.jsxs)("div",{className:"mailpoet-admin-fields-footer",children:[(0,g.jsxs)("div",{className:"mailpoet-segments-counter-section",children:[(0,g.jsx)(ko,{}),(0,g.jsx)(Ao,{})]}),(0,g.jsx)("div",{className:"mailpoet-form-actions",children:(0,g.jsx)(ce.Ay,{variant:"primary",type:"submit",onClick:a=>{a.preventDefault(),h(e,t)},disabled:!So(a.filters)||void 0===s.count,children:t?(0,u.__)("Save and return","mailpoet"):(0,u.__)("Save","mailpoet")})})]})]})})}function Fo(){const e=(0,Ne.g)(),{pageLoaded:t,pageUnloaded:a}=(0,pe.A)(jr.Hz),i=(0,v.A)(e=>e(jr.Hz).getPreviousPage())||"/",s=(0,Ne.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,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Ee.z,{heading:e.id?(0,u.__)("Edit segment","mailpoet"):(0,u.__)("Add new segment","mailpoet"),headingPrefix:(0,g.jsx)(Ee.o,{id:"mailpoet-segments-back-button",href:`#${i}`,label:(0,u.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,g.jsx)(Do,{isNewSegment:o,newsletterId:n})]})}Fo.displayName="SegmentEditor";var Oo=a(13432),Po=a(36194),Lo=a(57699),Mo=a(75379),$o=a(49543),Bo=a(74679),qo=a(63342);var Ho=a(71612),Wo=a(8301);function zo({tab:e,onClick:t}){const a=(0,Wo.L)(jr.Hz).getDynamicSegments(),i=a?a.filter(e=>e.selected):[],s="trash"!==e.name?[{value:"0",label:(0,u.__)("Bulk actions","mailpoet")},{label:(0,u.__)("Trash","mailpoet"),value:"trash"}]:[{value:"0",label:(0,u.__)("Bulk actions","mailpoet")},{label:(0,u.__)("Restore","mailpoet"),value:"restore"},{label:(0,u.__)("Delete permanently","mailpoet"),value:"delete"}];return(0,g.jsx)(Ho.A,{multiple:!1,hideLabelFromVision:!0,className:"mailpoet-segments-listing-bulk-actions",label:(0,u.__)("Bulk actions","mailpoet"),options:s,value:"0",onChange:e=>{0!==i.length&&"0"!==e&&t(i,e)}})}var Vo=a(70143);function Go({action:e,selected:t,onClose:a}){if(null===e)return null;let i="",s="",n="";const r=new Intl.ListFormat(jr.Hg.toString(),{style:"long",type:"conjunction"}).format(t.map(({name:e})=>`"${e}"`));switch(e){case"trash":i=(0,u._n)("Trash selected segment","Trash selected segments",t.length,"mailpoet"),s=(0,u.sprintf)((0,u._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,u.__)("Trash","mailpoet");break;case"restore":i=(0,u._n)("Restore selected segment","Restore selected segments",t.length,"mailpoet"),s=(0,u.sprintf)((0,u._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,u.__)("Restore","mailpoet");break;case"delete":i=(0,u._n)("Delete selected segment permanently","Delete selected segments permanently",t.length,"mailpoet"),s=(0,g.jsxs)(g.Fragment,{children:[(0,u.sprintf)((0,u._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,g.jsx)("strong",{children:(0,u.__)("This action can not be reversed.","mailpoet")})]}),n=(0,u.__)("Delete permanently","mailpoet")}return(0,g.jsx)(Vo.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,Mo.J)(Bo.store).createErrorNotice(e)});const i=a.meta.count;if(i>0){let t="";switch(e){case"trash":t=(0,u.sprintf)((0,u._n)("Segment moved to trash.","%d segments moved to trash.",i,"mailpoet"),i);break;case"delete":t=(0,u.sprintf)((0,u._n)("Segment permanently deleted.","%d segments permanently deleted.",i,"mailpoet"),i);break;case"restore":t=(0,u.sprintf)((0,u._n)("Segment restored.","%d segments restored.",i,"mailpoet"),i)}(0,Mo.J)(Bo.store).createSuccessNotice(t),(0,Mo.J)(jr.Hz).loadDynamicSegments()}}catch(t){if((0,qo.C)(t)){let a="";if(t.errors)m.U.Notice.showApiErrorNotice(t);else{switch(e){case"trash":a=(0,u.__)("Error moving segment to trash.","mailpoet");break;case"delete":a=(0,u.__)("Error deleting segment.","mailpoet");break;case"restore":a=(0,u.__)("Error restoring segment.","mailpoet")}(0,Mo.J)(Bo.store).createErrorNotice(a,{explicitDismiss:!0})}}}}(e,t),a()},onCancel:a,children:(0,g.jsx)("p",{children:s})})}var Yo=a(67340),Ko=a(19206);const Jo=window.mailpoet_dynamic_segment_count;function Qo(){const{dynamicSegments:e}=(0,v.A)(e=>({dynamicSegments:e(jr.Hz).getDynamicSegments()})),t=null!==e&&e.filter(e=>e.selected).length===e.length&&e.length>0;return(0,g.jsx)("input",{checked:t,type:"checkbox","data-automation-id":"select_all",onChange:()=>{t?(0,Mo.J)(jr.Hz).unselectAllDynamicSections():(0,Mo.J)(jr.Hz).selectAllDynamicSections()}})}const Zo=[{key:"checkbox",label:(0,g.jsx)(Qo,{}),cellClassName:"mailpoet-listing-checkbox"},{key:"name",label:(0,u.__)("Segment","mailpoet"),cellClassName:"mailpoet-listing-name",isSortable:!0},{key:"subscribers",label:(0,u.__)("Number of subscribers","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"subscribed",label:(0,u.__)("Subscribed","mailpoet"),isLeftAligned:!1,isNumeric:!0,isSortable:!1},{key:"updated_at",label:(0,u.__)("Modified","mailpoet"),cellClassName:"mailpoet-listing-modified-date",isLeftAligned:!1,isSortable:!0},{key:"actions",isLeftAligned:!1}];function Xo({tab:e}){const[t,a]=(0,r.useState)(null),[i,s]=(0,r.useState)([]),{dynamicSegments:n,dynamicSegmentsLoading:o,dynamicSegmentsCount:l}=(0,v.A)(e=>({dynamicSegments:e(jr.Hz).getDynamicSegments(),dynamicSegmentsLoading:e(jr.Hz).getDynamicSegmentsLoading(),dynamicSegmentsCount:e(jr.Hz).getDynamicSegmentsCount()})),d=(0,Yo.aJ)(),[c,p,h]=function(e=""){const[t,a]=(0,r.useState)(e),[i,s]=(0,r.useState)(e),n=(0,Ko.A)(s,250);return(0,r.useEffect)(()=>{n(t)},[t,n]),[t,a,i]}(d.search??"");(0,r.useEffect)(()=>{(0,Yo.ql)({search:h,offset:0})},[h]),(0,r.useEffect)(()=>{(0,Mo.J)(jr.Hz).loadDynamicSegments(d)},[d]);const _=((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,u.__)("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,u.sprintf)((0,u.__)('Segment "%s" has been duplicated.',"mailpoet"),t.name);(0,Mo.J)(Bo.store).createSuccessNotice(a),(0,Mo.J)(jr.Hz).loadDynamicSegments()}catch(e){(0,qo.C)(e)&&m.U.Notice.showApiErrorNotice(e)}}(e)}}},{key:"trash",control:{title:(0,u.__)("Move to trash","mailpoet"),icon:null,onClick:()=>a("trash",e)}}]:[{key:"restore",control:{title:(0,u.__)("Restore","mailpoet"),icon:null,onClick:()=>a("restore",e)}},{key:"delete",control:{title:(0,u.__)("Delete permanently","mailpoet"),icon:null,onClick:()=>a("delete",e)}}];return[{value:null,display:(0,g.jsx)("input",{type:"checkbox",checked:e?.selected??!1,onChange:()=>{e?.selected?(0,Mo.J)(jr.Hz).unselectDynamicSection(e):(0,Mo.J)(jr.Hz).selectDynamicSection(e)}})},{value:e.name,display:(0,g.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_name_${e.id}`,children:[(0,g.jsx)(Se.Link,{to:`${$o.r$}/${e.id}`,children:e.name}),e.description&&(0,g.jsx)("div",{children:e.description})]})},e.is_plugin_missing?{value:e.missing_plugin_message,display:(0,g.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,g.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,g.jsx)(ce.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,g.jsxs)("div",{"data-automation-id":`mailpoet_dynamic_segment_created_at_${e.id}`,children:[m.U.Date.short(e.created_at),(0,g.jsx)("br",{}),m.U.Date.time(e.created_at)]})},{value:null,display:(0,g.jsxs)("div",{className:"mailpoet-listing-actions-cell","data-automation-id":`mailpoet_dynamic_segment_actions_${e.id}`,children:[(0,g.jsx)(ce.Ay,{variant:"tertiary",href:e.subscribers_url,children:(0,u.__)("View subscribers","mailpoet")}),e.is_plugin_missing?(0,g.jsx)(ce.Ay,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",disabled:!0,children:(0,u.__)("Edit","mailpoet")}):(0,g.jsx)(ce.Ay,{"data-automation-id":`mailpoet_dynamic_segment_edit_button_${e.id}`,variant:"tertiary",href:`#${$o.r$}/${e.id}`,children:(0,u.__)("Edit","mailpoet")}),(0,g.jsx)(j.A,{className:"mailpoet-listing-more-button",label:(0,u.__)("More","mailpoet"),icon:y.A,controls:i.map(({control:e})=>e),popoverProps:{position:"bottom left"}})]})}]}(t,e.name,(e,t)=>{s([t]),a(e)})),f={orderby:d.sort_by,order:d.sort_order,page:String(d.offset/d.limit+1),per_page:d.limit,paged:d.offset/d.limit+1};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-segments-listing-header",children:[(0,g.jsx)(zo,{tab:e,onClick:(e,t)=>{s(e),a(t)}}),(0,g.jsx)(Lo.A,{className:"mailpoet-segments-listing-search",placeholder:(0,u.__)("Search","mailpoet"),onChange:p,value:c})]}),(0,g.jsx)(Po.A,{className:"mailpoet-listing-card mailpoet-segments-listing",title:"",isLoading:o.value,headers:Zo,rows:_,onQueryChange:e=>t=>{"paged"===e&&(0,Yo.ql)({offset:d.limit*(t-1)}),"per_page"===e&&(0,Yo.ql)({limit:parseInt(t,10),offset:0}),"sort"===e&&(0,Yo.ql)({offset:0,sort_by:t,sort_order:d.sort_by===t&&"desc"===d.sort_order?"asc":"desc"})},query:f,rowKey:(e,t)=>n[t].id,rowsPerPage:d.limit,totalRows:l??Jo,showMenu:!1}),(0,g.jsx)(Go,{action:t,selected:i,onClose:()=>a(null)})]})}const el=[{name:"all",title:(0,u.__)("All","mailpoet"),className:"mailpoet-tab-all"},{name:"trash",title:(0,u._x)("Trash","noun","mailpoet"),className:"mailpoet-tab-trash"}];function tl(){const e=(0,Yo.aJ)(),{dynamicSegmentsGroups:t}=(0,v.A)(e=>({dynamicSegments:e(jr.Hz).getDynamicSegments(),dynamicSegmentsGroups:e(jr.Hz).getDynamicSegmentsGroups()})),a=(0,r.useMemo)(()=>el.map(e=>{const a=t?.find(t=>e.name===t.name),i=a?.count??0;return{name:e.name,title:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{children:e.title}),i>0&&(0,g.jsx)("span",{className:"count",children:i})]}),className:e.className}}),[t]),i=(0,r.useCallback)(e=>(0,g.jsx)(Xo,{tab:e}),[]);return(0,g.jsx)(Oo.A,{className:"mailpoet-filter-tab-panel",tabs:a,initialTabName:e.group,onSelect:e=>{(0,Yo.ql)({group:e,offset:0})},children:i},e.group)}function al(){const{notices:e}=(0,v.A)(e=>({notices:e(Bo.store).getNotices()}),[]),{removeNotice:t}=(0,pe.A)(Bo.store),a=e.filter(({isDismissible:e,type:t})=>e&&"default"===t),i=e.filter(({isDismissible:e,type:t})=>!e&&"default"===t);return(0,g.jsxs)(g.Fragment,{children:[i.reverse().map(({id:e,status:t,content:a,__unstableHTML:i})=>(0,g.jsx)(h.$,{renderInPlace:!0,type:t,timeout:!1,children:i??(0,g.jsx)("p",{children:a})},e)),a.reverse().map(({id:e,status:a,content:i,__unstableHTML:s})=>(0,g.jsx)(h.$,{type:a,renderInPlace:!0,timeout:!1,closable:!0,onClose:()=>t(e),children:s??(0,g.jsx)("p",{children:i})},e))]})}var il=a(39116);const sl=[{name:(0,u.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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,u.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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,u.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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,u.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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:vr.Z2.OR},{name:(0,u.__)("Unengaged Subscribers","mailpoet"),slug:"unengaged-subscribers",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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:vr.VE.ALL_TIME}],isEssential:!0},{name:(0,u.__)("First-Time Buyers","mailpoet"),slug:"first-time-buyers",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("Customers who have made their first purchase in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:"firstOrder",operator:Hr.IN_THE_LAST,value:"30"}],isEssential:!0},{name:(0,u.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:vr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,u.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:vr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,u.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:vr.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,u.__)("Win-Back","mailpoet"),slug:"win-back",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("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,u.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:vr.eu.PURCHASE_HISTORY,description:(0,u.__)("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,u.__)("Clickers","mailpoet"),slug:"clickers",category:vr.eu.ENGAGEMENT,description:(0,u.__)("Contacts who regularly click on your emails in the last 90 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:vr.VE.IN_THE_LAST,clicks:"2",days:"90"}],isEssential:!1},{name:(0,u.__)("Non-Openers","mailpoet"),slug:"non-openers",category:vr.eu.ENGAGEMENT,description:(0,u.__)("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:vr.VE.IN_THE_LAST,emails:"0",days:"90"},{segmentType:"email",action:"opensAbsoluteCount",operator:"equals",timeframe:vr.VE.IN_THE_LAST,opens:"0",days:"90"}]},{name:(0,u.__)("Recent Clickers","mailpoet"),slug:"recent-clickers",category:vr.eu.ENGAGEMENT,description:(0,u.__)("Contacts who have clicked on an email in the last 7 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:vr.VE.IN_THE_LAST,clicks:"0",days:"7"}],isEssential:!1},{name:(0,u.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:vr.eu.ENGAGEMENT,description:(0,u.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:vr.VE.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,u.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:vr.eu.SHOPPING_BEHAVIOR,description:(0,u.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:vr.VE.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]},{name:(0,u.__)("Used a discount code","mailpoet"),slug:"used-a-discount-code",category:vr.eu.SHOPPING_BEHAVIOR,description:(0,u.__)("Customers who made a purchase with a coupon code in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:Zr.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:0,timeframe:vr.VE.IN_THE_LAST,days:"30"}],isEssential:!1},{name:(0,u.__)("Frequently uses discounts","mailpoet"),slug:"frequently-uses-discounts",category:vr.eu.SHOPPING_BEHAVIOR,description:(0,u.__)("Customers who have regularly used coupons in the last 90 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:Zr.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:2,timeframe:vr.VE.IN_THE_LAST,days:"90"}],isEssential:!1}],nl=[{slug:vr.eu.ENGAGEMENT,name:(0,u.__)("Engagement","mailpoet")},{slug:vr.eu.PURCHASE_HISTORY,name:(0,u.__)("Purchase History","mailpoet")},{slug:vr.eu.SHOPPING_BEHAVIOR,name:(0,u.__)("Shopping Behavior","mailpoet")}];function rl(e){const t=nl.find(t=>t.slug===e);return t?t.name:null}var ol=a(96170);const ll=[{name:"all",title:(0,g.jsx)(ol.Ic,{title:(0,u.__)("All","mailpoet"),count:sl.length})}];nl.forEach(e=>{const t=sl.filter(t=>t.category===e.slug).length;ll.push({name:e.slug,title:(0,g.jsx)(ol.Ic,{title:e.name,count:t})})});const dl=document.getElementById("dynamic_segments_container");function cl(){const{setPreviousPage:e}=(0,pe.A)(jr.Hz),t=(0,Ne.zy)(),a=(0,r.useRef)(t.pathname);return(0,r.useEffect)(()=>{e(a.current),a.current=t.pathname},[t,e]),null}const ml=(0,o.withBoundary)(Fo),pl=(0,o.withBoundary)(function(){const e=(0,v.A)(e=>e(jr.Hz).getErrors(),[]),{createFromTemplate:t}=(0,pe.A)(jr.Hz),a=()=>{m.U.trackEvent("Segments > New empty segment")};return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)(Ee.z,{className:"mailpoet-templates-header",heading:(0,u.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,g.jsx)(Ee.o,{href:"#/",label:(0,u.__)("Segments list","mailpoet"),"aria-label":(0,u.__)("Navigate to the segments list page","mailpoet")}),children:[(0,g.jsx)(il.A,{label:(0,u.__)("Search segment templates","mailpoet"),onChange:()=>null}),(0,g.jsx)("a",{href:`#${$o.LX}`,"data-automation-id":"new-custom-segment",onClick:()=>{a()},className:"page-title-action",children:(0,u.__)("Or, create custom segment","mailpoet")})]}),e.length>0&&(0,g.jsx)(ra,{errors:e.map(e=>({message:e}))}),(0,g.jsx)(ol.Kp,{tabs:ll,children:e=>(0,g.jsx)(ol.xA,{children:sl.filter(t=>"all"===e.name||t.category===e.name).map(e=>(0,g.jsx)(ol.q7,{name:e.name,description:e.description,category:rl(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug))})}),(0,g.jsxs)(ol.wi,{children:[(0,g.jsx)("p",{children:(0,u.__)("Want to set your own conditions?","mailpoet")}),(0,g.jsx)(ce.Ay,{variant:"link",href:`#${$o.LX}`,onClick:()=>{a()},children:(0,u.__)("Create custom segment","mailpoet")})]})]})}),ul=(0,o.withBoundary)(function(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(al,{}),(0,g.jsx)(Ee.z,{heading:(0,u.__)("Segments","mailpoet"),children:(0,g.jsx)("a",{href:`#${$o.WA}`,"data-automation-id":"new-segment",className:"page-title-action",children:(0,u.__)("Add new segment","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(Re,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Fe,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(b.D,{}),(0,g.jsx)(tl,{})]})});function hl(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(cl,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:$o.LX,element:(0,g.jsx)(ml,{})}),(0,g.jsx)(Ne.qh,{path:`${$o.r$}/:id`,element:(0,g.jsx)(ml,{})}),(0,g.jsx)(Ne.qh,{path:$o.WA,element:(0,g.jsx)(pl,{})}),(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(ul,{})})]})]})})}dl&&((0,o.registerTranslations)(),(0,jr.y$)(),(0,n.createRoot)(dl).render((0,g.jsx)(hl,{})));const gl=()=>{m.U.trackEvent("Forms > Add New"),setTimeout(()=>{window.location.href=window.mailpoet_form_template_selection_url},200)};function _l(){const[e,t]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Oe,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(Ee.z,{heading:(0,u.__)("Forms","mailpoet"),children:(0,g.jsx)("button",{onClick:()=>{t(!0),gl()},"data-automation-id":"create_new_form",className:"page-title-action "+(e?"mailpoet-button-with-spinner":""),type:"button",children:(0,u.__)("Add new form","mailpoet")})})]})}_l.displayName="FormsHeading";const fl=[{name:"name",label:(0,u.__)("Name","mailpoet"),sortable:!0},{name:"segments",label:(0,u.__)("Lists","mailpoet")},{name:"type",label:(0,u.__)("Type","mailpoet")},{name:"status",label:(0,u.__)("Status","mailpoet")},{name:"updated_at",label:(0,u.__)("Modified date","mailpoet"),sortable:!0}],bl={onTrash:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,u.__)("1 form was moved to the trash.","mailpoet"):(0,u.__)("%1$d forms were moved to the trash.","mailpoet").replace("%1$d",t),m.U.Notice.success(a)},onDelete:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,u.__)("1 form was permanently deleted.","mailpoet"):(0,u.__)("%1$d forms were permanently deleted.","mailpoet").replace("%1$d",t),m.U.Notice.success(a)},onRestore:e=>{const t=Number(e.meta.count);let a=null;a=1===t?(0,u.__)("1 form has been restored from the trash.","mailpoet"):(0,u.__)("%1$d forms have been restored from the trash.","mailpoet").replace("%1$d",t),m.U.Notice.success(a)},onNoItemsFound:()=>(0,g.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,g.jsx)("p",{children:(0,u.__)("No forms were found. Why not create a new one?","mailpoet")}),(0,g.jsx)(o.Button,{onClick:gl,automationId:"add_new_form",children:(0,u.__)("Add new form","mailpoet")})]})},xl=[{name:"trash",label:(0,u.__)("Move to trash","mailpoet"),onSuccess:bl.onTrash}],vl=[{name:"edit",className:"mailpoet-hide-on-mobile",label:(0,u.__)("Edit","mailpoet"),link:function(e){return(0,g.jsx)("a",{href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:(0,u.__)("Edit","mailpoet")})}},{name:"duplicate",className:"mailpoet-hide-on-mobile",label:(0,u.__)("Duplicate","mailpoet"),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:(0,u.__)("no name","mailpoet");m.U.Notice.success((0,u.__)('Form "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,bs.escapeHTML)(a))),t()}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}},{name:"trash",className:"mailpoet-hide-on-mobile"}];class jl 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((0,u.__)("Your Form is now activated!","mailpoet"))}).fail(a=>{m.U.Notice.showApiErrorNotice(a),t.target.checked=!e})};isItemInactive=e=>"disabled"===e.status;renderStatus(e){return(0,g.jsxs)("div",{children:[(0,g.jsx)(Wa.l,{onCheck:this.updateStatus,"data-id":e.id,dimension:"small",defaultChecked:"enabled"===e.status}),(0,g.jsxs)("p",{children:[(0,u.__)("Sign-ups","mailpoet"),": ",e.signups.toLocaleString()]})]})}renderItem=(e,t)=>{null===e.settings&&m.U.Notice.error((0,u.__)('Form settings of "%1$s" form are corrupted. Please [link]reconfigure the form in the editor[/link].',"mailpoet").replace("%1$s",(0,bs.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=Z()("manage-column","column-primary","has-row-actions"),i=window.mailpoet_segments.filter(t=>-1!==ke().inArray(t.id,e.segments)),s=function(e){const t=[];return"1"===e?.form_placement?.fixed_bar?.enabled&&t.push((0,u.__)("Fixed bar","mailpoet")),"1"===e?.form_placement?.below_posts?.enabled&&t.push((0,u.__)("Below pages","mailpoet")),"1"===e?.form_placement?.popup?.enabled&&t.push((0,u.__)("Pop-up","mailpoet")),"1"===e?.form_placement?.slide_in?.enabled&&t.push((0,u.__)("Slide–in","mailpoet")),t.length>0?t.join(", "):(0,u.__)("Others (widget)","mailpoet")}(e.settings);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("td",{className:a,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`,children:e.name?e.name:`(${(0,u.__)("no name","mailpoet")})`}),t]}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Lists","mailpoet"),children:(0,g.jsx)(xs.vC,{segments:i,dimension:"large",children:"user"===e.settings?.segments_selected_by&&(0,g.jsx)("span",{className:"mailpoet-tags-prefix",children:(0,u.__)("User choice:","mailpoet")})})}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Type","mailpoet"),children:s}),(0,g.jsx)("td",{className:"column","data-colname":(0,u.__)("Status","mailpoet"),children:this.renderStatus(e)}),(0,g.jsxs)("td",{className:"column-date mailpoet-hide-on-mobile","data-colname":(0,u.__)("Modified date","mailpoet"),children:[m.U.Date.short(e.updated_at),(0,g.jsx)("br",{}),m.U.Date.time(e.updated_at)]})]})};render(){return(0,g.jsxs)("div",{className:"mailpoet-listing-no-actions-on-mobile",children:[(0,g.jsx)(_l,{}),(0,g.jsx)(Ie.l,{limit:window.mailpoet_listing_per_page,className:"mailpoet-forms-listing",location:this.props.location,params:this.props.params,messages:bl,search:!1,endpoint:"forms",onRenderItem:this.renderItem,isItemInactive:this.isItemInactive,columns:fl,bulk_actions:xl,item_actions:vl})]})}}jl.propTypes={location:Qe().object.isRequired,params:Qe().object.isRequired},jl.displayName="FormList";const yl=wn(jl);function wl(e){const t=(0,Ne.zy)(),a=(0,Ne.g)();return(0,g.jsx)(yl,{...e,location:t,params:a})}function Sl(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsx)(b.D,{}),(0,g.jsx)(Ne.BV,{children:(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(wl,{})})})})]})})}const Nl=document.getElementById("forms_container");function Cl(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("knowledgeBaseIntro")}),(0,g.jsxs)("ul",{className:"mailpoet-text-links",children:[(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/116-common-problems",children:"Common Problems"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/165-guides-tips",children:"Newsletters"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/156-migration-questions",children:"Migration Questions"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/149-other-sending-methods",children:"Sending Methods"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/139-subscription-forms",children:"Subscription Forms"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/114-getting-started",children:"Getting Started"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/123-newsletter-editor-designer",children:"Newsletter Designer"})}),(0,g.jsx)("li",{children:(0,g.jsx)("a",{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/category/121-subscribers-and-lists",children:"Subscribers and Lists"})})]}),(0,g.jsx)(De.$,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:m.U.I18n.t("knowledgeBaseButton")})]})}Nl&&((0,o.registerTranslations)(),(0,n.createRoot)(Nl).render((0,g.jsx)(Sl,{})));var kl=a(87902);function Il(e){e.target.select()}function Ul(e,t){if(at.default.isObject(e)){const a=Object.keys(e).map(t=>`${t}: ${e[t]}`);return(0,g.jsx)("textarea",{readOnly:!0,id:t,onFocus:Il,value:a.join("\n"),style:{width:"100%",height:"400px"}})}return(0,g.jsx)("p",{children:m.U.I18n.t("systemInfoDataError")})}function Al(){const e="mailpoet-system-info",t=window.systemInfoData;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,g.jsx)("p",{children:m.U.I18n.t("systemInfoIntro")})}),Ul(t,e),(0,g.jsx)(kl.T,{variant:"secondary",targetId:e})]})}function El({rows:e,max_width:t="auto",is_fixed:a=!0}){return(0,g.jsx)("table",{className:Z()("widefat",{fixed:a}),style:{maxWidth:t},children:(0,g.jsx)("tbody",{children:e.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{className:"row-title",children:e.key}),(0,g.jsx)("td",{children:e.value}),e.action?(0,g.jsx)("td",{children:e.action}):null]},`row_${e.key}`))})})}function Tl({truthy:e=(0,u.__)("Yes","mailpoet"),falsy:t=(0,u.__)("No","mailpoet"),unknown:a=(0,u.__)("Unknown","mailpoet"),children:i=null}){return(0,g.jsx)("span",{children:!0===i&&e||!1===i&&t||a})}function Rl(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,g.jsx)(g.Fragment,{children:t.last_error.map(e=>(0,g.jsxs)("div",{children:[e.worker,": ",(0,g.jsx)("i",{children:e.message})]},e.worker))}):t.last_error;return(0,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusCronStatusTitle")}),(0,g.jsx)(El,{max_width:"400px",rows:[{key:m.U.I18n.t("accessible"),value:(0,g.jsx)(Tl,{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")}]})]})}Tl.propTypes={truthy:Qe().string,falsy:Qe().string,unknown:Qe().string,children:Qe().bool},Rl.propTypes={status_data:Qe().shape({accessible:Qe().bool,last_error_date:Qe().string,status:Qe().string,updated_at:Qe().number,run_accessed_at:Qe().number,run_completed_at:Qe().number,run_started_at:Qe().number,last_error:Qe().oneOfType([Qe().string,Qe().array])}).isRequired};var Dl=a(78048);function Fl({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,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Vo.A,{className:"mailpoet-help-modal",isOpen:a,title:o?(0,u.__)("Cancel task","mailpoet"):(0,u.__)("Reschedule task","mailpoet"),cancelButtonText:(0,u.__)("Not now","mailpoet"),confirmButtonText:o?(0,u.__)("Yes, cancel task","mailpoet"):(0,u.__)("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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Dl.A,{status:"error",isDismissible:!1,children:s}),(0,g.jsx)("br",{})]}),o&&(0,u.sprintf)((0,u.__)('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,u.__)("(no subject)","mailpoet")),l&&(0,u.sprintf)((0,u.__)('Are you sure you want to reschedule the task with ID %s for the email "%2$s"?',"mailpoet"),e.id,e.newsletter.subject||(0,u.__)("(no subject)","mailpoet"))," ",l&&c&&(0,u.__)("The email will be sent immediately.","mailpoet"),l&&!c&&(0,u.sprintf)((0,u.__)("The task will be scheduled for sending on %s.","mailpoet"),`${m.U.Date.short(d)} ${m.U.Date.time(d)}`)]}),(0,g.jsx)(ce.Ay,{variant:"secondary",size:"small",isDestructive:o,onClick:()=>i(!0),children:o?(0,u.__)("Cancel task","mailpoet"):(0,u.__)("Reschedule task","mailpoet")})]})}function Ol({task:e}){return(0,g.jsx)(Fl,{task:e,type:"cancel"})}function Pl({task:e}){return(0,g.jsx)(Fl,{task:e,type:"reschedule"})}function Ll({type:e,task:t}){const a="scheduled"===e,i="cancelled"===e,s="scheduled"===e||"running"===e,n="cancelled"===e;return(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{className:"column column-primary",children:t.id}),(0,g.jsx)("td",{className:"column",children:t.newsletter?(0,g.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,g.jsx)("td",{className:"column",children:t.subscriberEmail?(0,g.jsx)("a",{href:`admin.php?page=mailpoet-subscribers#/search[${t.subscriberEmail}]`,children:t.subscriberEmail}):(0,g.jsx)("i",{children:m.U.I18n.t("multipleSubscribers")})}),(0,g.jsx)("td",{className:"column",children:t.priority}),a?(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:`${m.U.Date.short(t.scheduledAt)} ${m.U.Date.time(t.scheduledAt)}`})}):null,i?(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:`${m.U.Date.short(t.cancelledAt)} ${m.U.Date.time(t.cancelledAt)}`})}):null,(0,g.jsx)("td",{className:"column-date",children:(0,g.jsx)("abbr",{children:`${m.U.Date.short(t.updatedAt)} ${m.U.Date.time(t.updatedAt)}`})}),s?(0,g.jsx)("td",{children:(0,g.jsx)(Ol,{task:t})}):null,n?(0,g.jsx)("td",{children:(0,g.jsx)(Pl,{task:t})}):null]})}function Ml({type:e}){const t=["scheduled","running","cancelled"].includes(e);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{className:"row-title",children:"Id"}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("email")}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("subscriber")}),(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("priority")}),"scheduled"===e?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("scheduledAt")}):null,"cancelled"===e?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("cancelledAt")}):null,(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("updatedAt")}),t?(0,g.jsx)("th",{className:"row-title",children:m.U.I18n.t("action")}):null]})}function $l({tasks:e,type:t}){let a=5;return"running"===t&&(a+=1),"scheduled"!==t&&"cancelled"!==t||(a+=2),(0,g.jsxs)("table",{className:"widefat fixed striped",children:[(0,g.jsx)("thead",{children:(0,g.jsx)(Ml,{type:t})}),(0,g.jsx)("tbody",{children:e.length?e.map(e=>(0,g.jsx)(Ll,{task:e,type:t},e.id)):(0,g.jsx)("tr",{className:"mailpoet-listing-no-items",children:(0,g.jsx)("td",{colSpan:a,children:m.U.I18n.t("nothingToShow")})})}),(0,g.jsx)("tfoot",{children:(0,g.jsx)(Ml,{type:t})})]})}function Bl({statusData:e}){const t=e;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusQueueTitle")}),(0,g.jsx)(El,{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,g.jsx)("h5",{children:m.U.I18n.t("scheduledTasks")}),(0,g.jsx)($l,{type:"scheduled",tasks:t.latestTasks.filter(e=>"scheduled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("cancelledTasks")}),(0,g.jsx)($l,{type:"cancelled",tasks:t.latestTasks.filter(e=>"cancelled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("runningTasks")}),(0,g.jsx)($l,{type:"running",tasks:t.latestTasks.filter(e=>null===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("pausedTasks")}),(0,g.jsx)($l,{type:"paused",tasks:t.latestTasks.filter(e=>"paused"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("completedTasks")}),(0,g.jsx)($l,{type:"completed",tasks:t.latestTasks.filter(e=>"completed"===e.status)})]})}function ql({version:e,storage:t,latestTrigger:a,latestCompletedTrigger:i,latestCompletedRun:s}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("actionSchedulerStatus")}),(0,g.jsx)(El,{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 Hl(){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,u.__)("Orphaned Sending Tasks","mailpoet"),orphaned_sending_task_subscribers:(0,u.__)("Orphaned Sending Task Subscribers","mailpoet"),sending_queue_without_newsletter:(0,u.__)("Sending Queues without Newsletter","mailpoet"),orphaned_subscriptions:(0,u.__)("Orphaned Subscriptions","mailpoet"),orphaned_links:(0,u.__)("Orphaned Links","mailpoet"),orphaned_newsletter_posts:(0,u.__)("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,u.__)("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,g.jsx)(ce.Ay,{variant:"primary",size:"small",label:(0,u.__)("Clean","mailpoet"),onClick:()=>n(e),isBusy:a===e,disabled:!!a,children:(0,u.__)("Fix","mailpoet")})}));return(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{children:(0,u.__)("Data Inconsistencies","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)('We found the following data inconsistencies in your DB. Click the "Fix" button to clean them.',"mailpoet")}),(0,g.jsx)(El,{rows:o,max_width:"400px",is_fixed:!1})]})}function Wl(e,t,a,i,s){const n=e?"success":"error";let r=e?t:a;return i&&(r=Ge()(r,/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{className:"mailpoet-text-link",href:i,children:e},"kb-link"))),(0,g.jsxs)("div",{className:`mailpoet_notice notice inline notice-${n}`,children:[(0,g.jsx)("p",{children:r}),s?(0,g.jsx)("p",{children:(0,g.jsx)("i",{children:s})}):null]})}function zl(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,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusCronTitle")}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{className:"mailpoet-text-link",href:a,target:"_blank",rel:"noopener noreferrer",children:a})}),Wl(t,s,i,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function Vl(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,g.jsxs)("div",{children:[(0,g.jsx)("h4",{children:m.U.I18n.t("systemStatusMSSTitle")}),Wl(e.mss.isReachable,a,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function Gl(){const e=window.systemStatusData,t=window.actionSchedulerData;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,g.jsx)("p",{children:e.mss.enabled?m.U.I18n.t("systemStatusIntroCronMSS"):m.U.I18n.t("systemStatusIntroCron")})}),zl(e),Vl(e),(0,g.jsx)(Rl,{status_data:e.cronStatus}),(0,g.jsx)(ql,{...t}),t?(0,g.jsx)(Bl,{statusData:e.queueStatus}):null,(0,g.jsx)(Hl,{})]})}function Yl(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent1")}),(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent2")}),(0,g.jsx)("p",{children:m.U.I18n.t("yourPrivacyContent3")}),(0,g.jsx)(De.$,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:m.U.I18n.t("yourPrivacyButton")})]})}var Kl=a(18363);function Jl(){return(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(d.V,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(p.q,{}),(0,g.jsx)(Kl.z,{heading:(0,u.__)("Help","mailpoet")}),(0,g.jsx)(b.D,{}),(0,g.jsxs)(fn.k,{activeKey:"knowledgeBase",children:[(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabKnowledgeBaseTitle"),children:(0,g.jsx)(Cl,{})},"knowledgeBase"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemStatusTitle"),children:(0,g.jsx)(Gl,{})},"systemStatus"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemInfoTitle"),children:(0,g.jsx)(Al,{})},"systemInfo"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabYourPrivacyTitle"),children:(0,g.jsx)(Yl,{})},"yourPrivacy")]})]})}const Ql=document.getElementById("help_container");Ql&&((0,o.registerTranslations)(),(0,n.createRoot)(Ql).render((0,g.jsx)(Jl,{})));var Zl=a(52969);function Xl({children:e}){const t=(0,Ne.zy)();return(0,r.useEffect)(()=>{window.scrollTo(0,0)},[t.pathname]),e||null}Xl.propTypes={children:Qe().node.isRequired},Xl.displayName="ScrollToTopComponent";const ed=(0,Zl.fk)(Xl);function td({onMethodChange:e,activeMethod:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodSelectionHead")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs-row",children:(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file",target:"_blank",rel:"noopener noreferrer",children:(0,g.jsx)(kt.v,{dimension:"large",variant:"excellent",isInverted:!0,children:m.U.I18n.t("seeVideo")})})})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(nt.s,{name:"select_method",automationId:"import-paste-method",id:"import-paste-method",checked:"paste-method"===t,value:"paste-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-paste-method",children:m.U.I18n.t("methodPaste")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(nt.s,{name:"select_method",automationId:"import-csv-method",id:"import-csv-method",checked:"file-method"===t,value:"file-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-csv-method",children:m.U.I18n.t("methodUpload")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(nt.s,{name:"select_method",automationId:"import-mailchimp-method",id:"import-mailchimp-method",checked:"mailchimp-method"===t,value:"mailchimp-method",onCheck:e}),(0,g.jsx)("label",{htmlFor:"import-mailchimp-method",children:m.U.I18n.t("methodMailChimp")})]})]})]})}function ad({hidePrevious:e=!1,isLastStep:t=!1,canGoNext:a=!0,onPreviousAction:i=()=>{},onNextAction:s=()=>{}}){return(0,g.jsxs)("div",{className:"mailpoet-settings-save",children:[!e&&(0,g.jsx)(De.$,{type:"button",variant:"secondary",onClick:i,children:m.U.I18n.t("previousStep")}),(0,g.jsx)(De.$,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&s()},children:m.U.I18n.t(t?"import":"nextStep")})]})}function id({canFinish:e,onValueChange:t,data:a="",onFinish:i=()=>{},onPrevious:s=()=>{}}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"paste_input",children:m.U.I18n.t("pasteLabel")}),(0,g.jsx)("p",{className:"description",children:Ge()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(et.T,{id:"paste_input",rows:"15",placeholder:"Email, First Name, Last Name\njohn@doe.com, John, Doe\nmary@smith.com, Mary, Smith\njohnny@walker.com, Johnny, Walker",isCode:!0,onChange:e=>{t(e.target.value)},defaultValue:a})}),(0,g.jsx)(ad,{canGoNext:e,onPreviousAction:s,onNextAction:i})]})}function sd({onValueChange:e,canFinish:t,onFinish:a=()=>{},onPrevious:i=()=>{}}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"file_local",children:m.U.I18n.t("methodUpload")}),(0,g.jsx)("p",{className:"description",children:Ge()(m.U.I18n.t("pasteDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{className:"mailpoet-link",href:"https://kb.mailpoet.com/article/126-importing-subscribers-with-csv-files",target:"_blank",rel:"noopener noreferrer",children:e},"kb-link"))})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(Ze.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,g.jsx)(ad,{canGoNext:t,onPreviousAction:i,onNextAction:a})]})}function nd({onFinish:e=()=>{},onPrevious:t=()=>{}}){const[a,i]=(0,r.useState)(""),[s,n]=(0,r.useState)(void 0),[o,l]=(0,r.useState)([]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:(0,g.jsxs)("label",{htmlFor:"mailpoet_mailchimp_key_input",children:[(0,g.jsx)("span",{className:"mailpoet_import_heading",children:m.U.I18n.t("methodMailChimpLabel")}),(0,g.jsx)("p",{className:"description",children:Ge()(m.U.I18n.t("methodMailChimpDescription"),/\[link\](.*?)\[\/link\]/,e=>(0,g.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,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,g.jsx)(Ze.p,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{i(e.target.value),""===e.target.value.trim()&&n(void 0)}}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)(De.$,{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,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)("span",{children:Array.isArray(s)&&0===s.length?m.U.I18n.t("noMailChimpLists"):null})]})}),s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("methodMailChimpSelectList")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsx)(Ae.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,g.jsx)(ad,{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})})}})]})}td.propTypes={activeMethod:Qe().string,onMethodChange:Qe().func.isRequired},td.displayName="SelectImportMethod",ad.propTypes={canGoNext:Qe().bool,hidePrevious:Qe().bool,isLastStep:Qe().bool,onPreviousAction:Qe().func,onNextAction:Qe().func},ad.displayName="PreviousNextStepButtons",id.propTypes={onFinish:Qe().func,onPrevious:Qe().func,canFinish:Qe().bool.isRequired,onValueChange:Qe().func.isRequired,data:Qe().string},id.displayName="MethodPaste",sd.propTypes={canFinish:Qe().bool.isRequired,onFinish:Qe().func,onPrevious:Qe().func,onValueChange:Qe().func.isRequired},sd.displayName="MethodUpload",nd.propTypes={onFinish:Qe().func,onPrevious:Qe().func},nd.displayName="MethodMailChimp";var rd=a(87714),od=a.n(rd);const ld=e=>window.roleBasedEmails.findIndex(t=>e.startsWith(`${t}@`))>=0,dd=e=>{let t,a=at.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)&&!ld(a)&&a};function cd({setStepMethodSelectionData:e,subscribersLimitForValidation:t}){const a=(0,Ne.Zp)(),[i,s]=(0,r.useState)(void 0),[n,l]=(0,r.useState)(""),[d,c]=(0,r.useState)(void 0),p=s=>{e(s),a(((e,t,a)=>void 0===e||void 0===e.subscribersCount||e.subscribersCount<t||"mailchimp-method"===a?"/step_data_manipulation":"/step_input_validation")(s,t,i))},u=()=>{a("/step_clean_list")},h=()=>{(e=>{const t=encodeURI(e).split(/%..|./).length-1;m.U.Notice.hide(),t>window.maxPostSizeBytes?m.U.Notice.error(m.U.I18n.t("maxPostSizeNotice")):(m.U.Modal.loading(!0),od().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,p=!1;return Object.keys(e).forEach(u=>{l=e[u].map(e=>e.trim()),d=l.length,null===m&&(m=d),d===m&&(null===c?(Object.keys(l).forEach(e=>{o=dd(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(u,10)&&(p=!0,t[0]=l)):""!==l[c]&&(r=dd(l[c]),at.default.has(a,r)?i.push(r):ld(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=at.default.values(t),t&&(p&&t.length>=2||!p&&t.length>=1)?{header:window.mailpoet_email_regex.test(t[0][c])?null:t.shift(),subscribers:t,subscribersCount:t.length,duplicate:at.default.uniq(i),invalid:at.default.uniq(s),role:at.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)}}}(e=>{m.U.trackEvent("Subscribers import started",{source:"file-method"===i?"file upload":"pasted data"}),p(e)})))})("paste-method"===i?n:d)};return(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(td,{activeMethod:i,onMethodChange:s})}),"paste-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(id,{onPrevious:u,onValueChange:l,onFinish:h,canFinish:!!n.trim(),data:n})}),"file-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(sd,{onPrevious:u,onValueChange:c,onFinish:h,canFinish:!!d,data:d})}),"mailchimp-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(nd,{onPrevious:u,onFinish:e=>{m.U.trackEvent("Subscribers import started",{source:"MailChimp"}),p(e)}})}),void 0===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ad,{canGoNext:!1,onPreviousAction:u})})]})}function md({onProceed:e,iHaveCleanedList:t}){return(0,g.jsxs)("div",{className:"mailpoet-clean-list-step-container",children:[(0,g.jsx)("p",{children:m.U.I18n.t("cleanListText1")}),(0,g.jsx)("p",{children:m.U.I18n.t("cleanListText2")}),(0,g.jsxs)("p",{children:[e&&(0,g.jsx)(De.$,{onClick:e,variant:"tertiary",children:m.U.I18n.t("listCleaningGotIt")}),(0,g.jsx)(De.$,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:m.U.I18n.t("tryListCleaning")}),t&&(0,g.jsx)(De.$,{onClick:t,variant:"secondary",children:m.U.I18n.t("cleanedList")})]})]})}function pd({onSubmit:e}){const t=(0,Ne.Zp)(),[a,i]=(0,r.useState)(void 0);return(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepHeading")}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(nt.s,{automationId:"mailpoet_import_validation_step_option1",id:"existing-list",checked:"existing-list"===a,value:"existing-list",onCheck:i}),(0,g.jsx)("label",{htmlFor:"existing-list",children:m.U.I18n.t("validationStepRadio1")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(nt.s,{automationId:"mailpoet_import_validation_step_option2",id:"address-book",checked:"address-book"===a,value:"address-book",onCheck:i}),(0,g.jsx)("label",{htmlFor:"address-book",children:m.U.I18n.t("validationStepRadio2")})]})]}),(0,g.jsx)(ad,{canGoNext:void 0!==a,onPreviousAction:()=>t("/step_method_selection"),onNextAction:()=>e(a)})]})}function ud(){return(0,g.jsxs)("div",{className:"mailpoet-clean-list-step-container","data-automation-id":"import_wrong_source_block",children:[(0,g.jsx)("p",{children:m.U.I18n.t("validationStepBlock1")}),(0,g.jsx)("p",{children:m.U.I18n.t("validationStepBlock2")}),(0,g.jsx)("p",{children:(0,g.jsx)(De.$,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("validationStepBlockButton")})})]})}function hd({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,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("validationStepLastSentHeading")}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(it.Select,{defaultValue:t,onChange:i,automationId:"last_sent_to_list",children:[(0,g.jsx)("option",{value:"over2years",children:m.U.I18n.t("validationStepLastSentOption1")}),(0,g.jsx)("option",{value:"1to2years",children:m.U.I18n.t("validationStepLastSentOption2")}),(0,g.jsx)("option",{value:"less1year",children:m.U.I18n.t("validationStepLastSentOption3")}),(0,g.jsx)("option",{value:"less3months",children:m.U.I18n.t("validationStepLastSentOption4")})]})}),(0,g.jsx)("div",{className:"mailpoet-settings-save",children:(0,g.jsx)(De.$,{type:"button",automationId:"last_sent_to_list_next",onClick:s,children:m.U.I18n.t("validationStepLastSentNext")})})]})}function gd({stepMethodSelectionData:e}){const t=(0,Ne.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,g.jsxs)(g.Fragment,{children:[void 0===a&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(pd,{onSubmit:i})}),"address-book"===a&&(0,g.jsx)(ud,{}),"existing-list"===a&&void 0===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(hd,{onSubmit:l})}),"existing-list"===a&&"notRecently"===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(md,{iHaveCleanedList:()=>l("recently")})})]})}function _d({translation:e,subscribers:t}){let a="";return t.length&&(a=Ge()(e.replace("%2$s",t.join(", ")),"%1$s",()=>(0,g.jsx)("strong",{children:t.length.toLocaleString()},e)),a=(0,g.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=Z()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!s}),l=(0,g.jsx)(_d,{translation:m.U.I18n.t("importNoticeInvalid"),subscribers:t}),d=(0,g.jsx)(_d,{translation:m.U.I18n.t("importNoticeDuplicate"),subscribers:a});let c="";if(i.length&&(c=Ge()(m.U.I18n.t("importNoticeRoleBased"),/(%1\$s|\[link\].*\[\/link\]|%2\$s)/,e=>"%1$s"===e?(0,g.jsx)("strong",{children:i.length.toLocaleString()},"role-length"):"%2$s"===e?i.join(", "):(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/270-sending-to-role-based-email-addresses-is-not-allowed",target:"_blank",rel:"noopener noreferrer",children:e.replace("[link]","").replace("[/link]","")},e)),c=(0,g.jsx)("p",{children:c})),t.length||a.length||i.length){const e=t.length+a.length+i.length;return(0,g.jsxs)("div",{className:"error",children:[(0,g.jsxs)("p",{children:[Ge()(m.U.I18n.t("importNoticeSkipped"),"%1$s",()=>(0,g.jsx)("strong",{children:e.toLocaleString()},"lengths"))," ",(0,g.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,g.jsxs)("div",{className:o,children:[(0,g.jsx)("hr",{}),l,d,c]})]})}return null}function bd({header:e=[],subscribers:t}){const a=((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})(t,e);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:m.U.I18n.t("matchData")}),a.map((e,t)=>(0,g.jsx)("th",{children:(0,g.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 xd({header:e}){return(0,g.jsxs)("tr",{className:"mailpoet_header",children:[(0,g.jsx)("td",{}),e.map(e=>(0,g.jsx)("td",{children:e},e))]})}function vd({subscriber:e,index:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("td",{children:t}),e.map((e,a)=>(0,g.jsx)("td",{children:e},`${e}-${t}-${a}`))]})}function jd({subscribers:e,subscribersCount:t}){const a=". . .",i=Array(e[0].length).fill(a);return(0,g.jsxs)(g.Fragment,{children:[e.slice(0,10).map((e,t)=>(0,g.jsx)("tr",{children:(0,g.jsx)(vd,{subscriber:e,index:t+1})},`${e[0]}-${t}`)),t>11?(0,g.jsx)("tr",{children:(0,g.jsx)(vd,{subscriber:i,index:a})},"filler"):null,t>10?(0,g.jsx)("tr",{children:(0,g.jsx)(vd,{subscriber:e[t-1],index:t})},e[t-1][0]):null]})}function yd({subscribersCount:e=0,subscribers:t=[],header:a=[]}){return(0,r.useLayoutEffect)(()=>{(()=>{const e={data:window.mailpoetColumnsSelect2,width:"15em"};ke()("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(),ke()(a).select2("close"),m.U.Modal.popup({title:m.U.I18n.t("addNewField"),template:ke()("#form_template_field_form").html()}),ke()("#form_field_new").parsley().on("form:submit",()=>{const t=ke()("#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),ke()("select.mailpoet_subscribers_column_data_match").each(()=>{ke()(a).html("").select2("destroy").select2(e)}),ke()(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})):ke()("select.mailpoet_subscribers_column_data_match").each(()=>{const e=a,s=ke()(e).val();s===i&&"ignore"!==s&&(confirm(`${m.U.I18n.t("selectedValueAlreadyMatched")} ${m.U.I18n.t("confirmCorrespondingColumn")}`)?ke()(e).data("column-id","ignore"):(t.preventDefault(),ke()(a).select2("close")))})}).on("select2:select",e=>{const t=e.currentTarget,a=e.params.data.id;ke()(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()}),ke().map(ke()(".mailpoet_subscribers_column_data_match"),e=>{const t=ke()(e).data("column-id");ke()(e).val(t).trigger("change")})})()}),(0,g.jsx)("div",{className:"subscribers_data",children:(0,g.jsxs)("table",{className:"mailpoet_subscribers widefat fixed",children:[(0,g.jsx)("thead",{children:(0,g.jsx)(bd,{header:a,subscribers:t})}),(0,g.jsxs)("tbody",{children:[a?(0,g.jsx)(xd,{header:a}):null,(0,g.jsx)(jd,{subscribers:t,subscribersCount:e})]})]})})}function wd({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){const a=ke()("select#mailpoet_segments_select");if(a.data("select2"))return;const i=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};a.html(""),a.select2({data:t.map(e=>({...e,text:e.name})),dropdownCssClass:"mailpoet-form-select2-dropdown",escapeMarkup:e=>e,templateResult:i,templateSelection:i}).on("change",t=>{const i=ke()('[data-id="notice_segmentSelection"]');t.currentTarget.value?ke()('[data-id="notice_segmentSelection"]').remove():i.length||m.U.Notice.error(m.U.I18n.t("segmentSelectionRequired"),{static:!0,scroll:!0,id:"notice_segmentSelection",hideClose:!0});(t=>{e(t)})(at.default.pluck(a.select2("data"),"id"))})}(s)},[s,e]);const o=t=>{!function(){const e=ke()("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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:(0,g.jsxs)("label",{htmlFor:"mailpoet_segments_select",children:[m.U.I18n.t("pickLists"),(0,g.jsx)("p",{className:"description",children:m.U.I18n.t("pickListsDescription")})]})}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row mailpoet-settings-inputs-row-centered",children:[(0,g.jsx)("div",{className:"mailpoet-form-select mailpoet-form-input",children:(0,g.jsx)("select",{id:"mailpoet_segments_select","data-placeholder":m.U.I18n.t("select"),multiple:"multiple",children:(0,g.jsx)("option",{})})}),(0,g.jsx)(De.$,{variant:"tertiary",onClick:()=>{return e=o,m.U.Modal.popup({title:m.U.I18n.t("addNewList"),template:ke()("#new_segment_template").html()}),ke()("#new_segment_name").on("keypress",e=>{13===e.which&&ke()("#new_segment_process").trigger("click")}),ke()("#new_segment_process").on("click",()=>{const t=ke()("#new_segment_name").val()?.toString().trim()||"",a=ke()("#new_segment_description").val()?.toString().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_error_message"}))}).catch(()=>{})}),void ke()("#new_segment_cancel").on("click",()=>{m.U.Modal.close()});var e},children:m.U.I18n.t("createANewList")})]})})]})}function Sd(){return(0,g.jsx)("p",{className:"description",children:Ge()(m.U.I18n.t("consentSubscribed"),/\[link](.*?)\[\/link]/,e=>(0,g.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 Nd({newSubscribersStatus:e,setNewSubscribersStatus:t}){const a=(0,r.useCallback)(e=>{t(e.target.value)},[t]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"new_subscribers_status",children:m.U.I18n.t("newSubscribersStatus")}),(0,g.jsx)(Sd,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(it.Select,{id:"new_subscribers_status",placeholder:m.U.I18n.t("select"),name:"new_subscribers_status",onChange:a,defaultValue:e,children:[(0,g.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,g.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,g.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function Cd({existingSubscribersStatus:e,setExistingSubscribersStatus:t}){const a=(0,r.useCallback)(e=>{t(e.target.value)},[t]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[(0,g.jsx)("label",{htmlFor:"existing_subscribers_status",children:m.U.I18n.t("existingSubscribersStatus")}),(0,g.jsx)(Sd,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(it.Select,{id:"existing_subscribers_status",placeholder:m.U.I18n.t("select"),name:"existing_subscribers_status",onChange:a,defaultValue:e,children:[(0,g.jsx)("option",{value:"dont_update",children:m.U.I18n.t("dontUpdate")}),(0,g.jsx)("option",{value:"subscribed",children:m.U.I18n.t("subscribed")}),(0,g.jsx)("option",{value:"inactive",children:m.U.I18n.t("inactive")}),(0,g.jsx)("option",{value:"unsubscribed",children:m.U.I18n.t("unsubscribed")})]})})]})}function kd({updateExistingSubscribers:e,setUpdateExistingSubscribers:t}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-settings-label",children:m.U.I18n.t("updateExistingSubscribers")}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs",children:[(0,g.jsx)(nt.s,{id:"update_existing_subscribers",name:"update_existing_subscribers",value:"1",checked:e,onCheck:()=>t(!0)}),(0,g.jsx)("label",{htmlFor:"update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersYes")}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)(nt.s,{id:"dont_update_existing_subscribers",name:"update_existing_subscribers",value:"",checked:!e,onCheck:()=>t(!1)}),(0,g.jsx)("label",{htmlFor:"dont_update_existing_subscribers",children:m.U.I18n.t("updateExistingSubscribersNo")})]})]})}cd.propTypes={setStepMethodSelectionData:Qe().func.isRequired,subscribersLimitForValidation:Qe().number.isRequired},cd.diplayName="StepMethodSelection",md.displayName="CleanList",pd.propTypes={onSubmit:Qe().func.isRequired},pd.displayName="InitialQuestion",hd.propTypes={onSubmit:Qe().func.isRequired},hd.displayName="LastSentQuestion",gd.displayName="StepInputValidation",_d.propTypes={translation:Qe().string.isRequired,subscribers:Qe().arrayOf(Qe().string).isRequired},fd.propTypes={stepMethodSelectionData:Qe().shape({duplicate:Qe().arrayOf(Qe().string),invalid:Qe().arrayOf(Qe().string),role:Qe().arrayOf(Qe().string)})},bd.propTypes={subscribers:Qe().arrayOf(Qe().arrayOf(Qe().oneOfType([Qe().string,Qe().number]))).isRequired,header:Qe().arrayOf(Qe().string)},xd.propTypes={header:Qe().arrayOf(Qe().string).isRequired},vd.propTypes={subscriber:Qe().arrayOf(Qe().oneOfType([Qe().string,Qe().number])).isRequired,index:Qe().node.isRequired},jd.propTypes={subscribersCount:Qe().number.isRequired,subscribers:Qe().arrayOf(Qe().arrayOf(Qe().oneOfType([Qe().string,Qe().number]))).isRequired},yd.propTypes={subscribersCount:Qe().number,subscribers:Qe().arrayOf(Qe().arrayOf(Qe().oneOfType([Qe().string,Qe().number]))),header:Qe().arrayOf(Qe().string)},wd.propTypes={setSelectedSegments:Qe().func.isRequired},kd.propTypes={setUpdateExistingSubscribers:Qe().func.isRequired,updateExistingSubscribers:Qe().bool.isRequired},a(36202);function Id({selectedTags:e,setSelectedTags:t}){const a=(0,r.useCallback)(({value:e})=>{t(e)},[t]),i=m.U.tags.map(e=>e.name);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-settings-label",children:[m.U.I18n.t("assignTagsLabel"),(0,g.jsx)("p",{className:"description",children:m.U.I18n.t("assignTagsDescription")})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs mailpoet-import-tags",children:(0,g.jsx)(ht.g,{name:"tags",onChange:a,suggestedValues:i,selectedValues:e,placeholder:m.U.I18n.t("addNewTag")})})]})}function Ud({subscribersLimitForValidation:e,setStepDataManipulationData:t,stepMethodSelectionData:a}){const i=(0,Ne.Zp)(),[s,n]=(0,r.useState)([]),[o,l]=(0,r.useState)(!0),[d,c]=(0,r.useState)("subscribed"),[p,u]=(0,r.useState)("dontUpdate"),[h,_]=(0,r.useState)([]);return(0,r.useEffect)(()=>{void 0===a&&i("/step_method_selection",{replace:!0})},[a,i]),void 0===a?null:(0,g.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,g.jsx)(fd,{stepMethodSelectionData:a}),(0,g.jsx)(yd,{subscribersCount:a.subscribersCount,subscribers:a.subscribers,header:a.header}),(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)(wd,{setSelectedSegments:n}),(0,g.jsx)(Nd,{newSubscribersStatus:d,setNewSubscribersStatus:c}),(0,g.jsx)(Cd,{existingSubscribersStatus:p,setExistingSubscribersStatus:u}),(0,g.jsx)(kd,{setUpdateExistingSubscribers:l,updateExistingSubscribers:o}),(0,g.jsx)(Id,{selectedTags:h,setSelectedTags:_}),(0,g.jsx)(ad,{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:()=>{((e,t,a,i,s,n,r)=>{const o={},l=new(ke().AsyncQueue);let d=0;const c=Date.now()/1e3,p={created:0,updated:0,errors:[],segments:[],tags:[]};m.U.Modal.progress(!0);const u=e.reduce((e,t,a)=>(a%2e3==0&&e.push([]),e[e.length-1].push(t),e),[]);at.default.each(ke()("select.mailpoet_subscribers_column_data_match"),(e,t)=>{const a=ke()(e).data("column-id");"ignore"!==a&&(o[a]={index:t})}),at.default.each(u,()=>{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:u[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;p.created+=t.data.created,p.updated+=t.data.updated,p.segments=t.data.segments,p.added_to_segment_with_welcome_notification=a,m.U.Modal.setProgress((i=p,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),p.errors.length>0&&!p.updated&&!p.created?m.U.Notice.error(at.default.flatten(p.errors)):(p.segments=at.default.map(at.default.filter(p.segments,e=>t.includes(e.id)),e=>e.name),r(p))})})(a.subscribers,s,d,p,o,h,e=>{t(e),i("/step_results")})},isLastStep:!0})]})]})}function Ad({subscribersCount:e=0,segments:t=[],initialMessage:a=""}){if(e){let i=Ge()(a,"%1$s",()=>(0,g.jsx)("strong",{children:e.toLocaleString()},"%1$s"));return i=Ge()(i,"%2$s",()=>`"${t.join('", "')}"`),(0,g.jsx)("p",{children:i})}return null}function Ed({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?null:(0,g.jsx)("p",{children:m.U.I18n.t("importNoAction")})}function Td({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,g.jsx)("b",{children:m.U.I18n.t("congratulationResult")})}),(0,g.jsx)("p",{children:Ge()(m.U.I18n.t("suppressionListReminder"),/\[link](.*?)\[\/link]/,e=>(0,g.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 Rd({addedToSegmentWithWelcomeNotification:e=!1}){return e?(0,g.jsx)("p",{children:m.U.I18n.t("importNoWelcomeEmail")}):null}function Dd({errors:e=[],createdSubscribers:t,updatedSubscribers:a,segments:i,addedToSegmentWithWelcomeNotification:s}){const n=(0,Ne.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(at.default.flatten(e)),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsxs)("div",{className:"updated",children:[(0,g.jsx)(Ad,{subscribersCount:t,segments:i,initialMessage:m.U.I18n.t("subscribersCreated")}),(0,g.jsx)(Ad,{subscribersCount:a,segments:i,initialMessage:m.U.I18n.t("subscribersUpdated")}),(0,g.jsx)(Ed,{createdSubscribers:t,updatedSubscribers:a}),(0,g.jsx)(Rd,{addedToSegmentWithWelcomeNotification:s})]})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Td,{createdSubscribers:t,updatedSubscribers:a})}),(0,g.jsx)("div",{className:"mailpoet-settings-grid",children:(0,g.jsxs)("div",{className:"mailpoet-settings-save",children:[(0,g.jsx)(De.$,{variant:"secondary",type:"button",onClick:()=>n("/step_method_selection"),children:m.U.I18n.t("importAgain")}),(0,g.jsx)(De.$,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:m.U.I18n.t("viewSubscribers")})]})})]})}function Fd(){const e=(0,Ne.Zp)();return(0,g.jsx)(md,{onProceed:()=>e("/step_method_selection")})}Ud.propTypes={stepMethodSelectionData:Qe().shape({duplicate:Qe().arrayOf(Qe().string),header:Qe().arrayOf(Qe().string),invalid:Qe().arrayOf(Qe().string),role:Qe().arrayOf(Qe().string),subscribersCount:Qe().number,subscribers:Qe().arrayOf(Qe().arrayOf(Qe().oneOfType([Qe().string,Qe().number])))}),subscribersLimitForValidation:Qe().number.isRequired,setStepDataManipulationData:Qe().func.isRequired},Ad.propTypes={segments:Qe().arrayOf(Qe().string.isRequired),subscribersCount:Qe().number,initialMessage:Qe().string},Ad.displayName="ResultMessage",Ed.propTypes={createdSubscribers:Qe().number,updatedSubscribers:Qe().number},Ed.displayName="NoAction",Td.propTypes={createdSubscribers:Qe().number,updatedSubscribers:Qe().number},Td.displayName="SuppressionListReminder",Rd.propTypes={addedToSegmentWithWelcomeNotification:Qe().bool},Rd.diplayName="NoWelcomeEmail",Dd.propTypes={errors:Qe().arrayOf(Qe().string.isRequired),segments:Qe().arrayOf(Qe().string.isRequired),createdSubscribers:Qe().number,updatedSubscribers:Qe().number,addedToSegmentWithWelcomeNotification:Qe().bool},Dd.displayName="StepResults",Fd.displayName="StepCleanList";const Od=document.getElementById("import_container");function Pd(){const[e,t]=(0,r.useState)(void 0),[a,i]=(0,r.useState)({}),s=(0,l.f)(window);return(0,g.jsx)(l.F.Provider,{value:s,children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(p.q,{}),(0,g.jsx)(ed,{children:(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"/step_clean_list",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Fd,{})})}),(0,g.jsx)(Ne.qh,{path:"/step_method_selection",element:(0,g.jsx)(cd,{setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,g.jsx)(Ne.qh,{path:"/step_input_validation",element:(0,g.jsx)(gd,{stepMethodSelectionData:e})}),(0,g.jsx)(Ne.qh,{path:"/step_data_manipulation",element:(0,g.jsx)(Ud,{stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:i})}),(0,g.jsx)(Ne.qh,{path:"/step_results",element:(0,g.jsx)(Dd,{errors:a.errors,createdSubscribers:a.created,updatedSubscribers:a.updated,segments:a.segments,addedToSegmentWithWelcomeNotification:a.added_to_segment_with_welcome_notification})}),(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(Ne.C5,{to:"/step_clean_list"})})]})})]})})}Od&&((0,o.registerTranslations)(),(0,n.createRoot)(Od).render((0,g.jsx)(Pd,{})));var Ld=a(75370),Md=a.n(Ld);ke()(document).ready(()=>{let e;if(!ke()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=Md().compile(ke()("#mailpoet_subscribers_export_template").html());function a(t){const a="mailpoet-disabled";"on"===t?e.removeClass(a):e.addClass(a)}ke()("#mailpoet-export").html(t(window.exportData));const i=ke()("#export_lists"),s=ke()("#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;at.default.contains(i,a)&&(t.preventDefault(),"deselect"===a?ke()(t.target).val("").trigger("change"):(s=[],at.default.each(e.find("option"),e=>{const t=e.value;at.default.contains(i,t)||s.push(t)}),ke()(t.target).val(s).trigger("change")),ke()(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=ke()("#mailpoet-export-button"),window.segments.forEach(e=>{i.append(ke()("<option></option>").attr("value",e.id).text(e.name))}),window.subscriberFieldsSelect2.forEach(e=>{e.text=e.name,e.children.forEach(e=>{e.name=(0,bs.escapeHTML)(e.name),e.text=(0,bs.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(ke()(e.target).hasClass("mailpoet-disabled"))return;m.U.Modal.loading(!0);const t=ke()(':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>");ke()("#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 $d=a(6738),Bd=a(28651);function qd({children:e}){return(0,g.jsx)("div",{className:"mailpoet-steps-content",children:e})}const Hd=(0,g.jsx)("svg",{width:"13",height:"11",viewBox:"0 0 13 11",children:(0,g.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"})}),Wd=(0,g.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",children:(0,g.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 zd({onCheck:e,showError:t,checked:a,automationId:i,...s}){return(0,g.jsxs)("div",{className:Z()({"mailpoet-form-yesno":!0,"mailpoet-form-yesno-error":t,"mailpoet-disabled":s.disabled}),"data-automation-id":i,children:[(0,g.jsxs)("label",{children:[(0,g.jsx)("input",{"aria-label":(0,u.__)("Yes","mailpoet"),type:"radio",checked:!0===a,onChange:()=>e(!0),...s}),(0,g.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-yes",children:Hd})]}),(0,g.jsxs)("label",{children:[(0,g.jsx)("input",{"aria-label":(0,u.__)("No","mailpoet"),type:"radio",checked:!1===a,onChange:()=>e(!1),...s}),(0,g.jsx)("span",{className:"mailpoet-form-yesno-control mailpoet-form-yesno-no",children:Wd})]})]})}function Vd({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),p=i?(0,u._x)("Continue","A label on a button","mailpoet"):(0,u._x)("Start using WooCommerce features","Submit button caption on the standalone WooCommerce setup page","mailpoet");let h;return"subscribed"===l&&(h=!0),"unsubscribed"===l&&(h=!1),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.TypographyHeading,{level:1,children:(0,u._x)("Power up your WooCommerce store","Title on the WooCommerce setup page","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:(0,u.__)("MailPoet comes with powerful features for WooCommerce. Select features that you would like to use with your store.","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{onSubmit:t=>(t.preventDefault(),m(!0),null===l||null===s||e(l,s),!1),children:[(0,g.jsxs)("div",{children:[a?(0,g.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:Ge()((0,u.__)("Do you want to import your WooCommerce customers as subscribed? [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.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,g.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,g.jsx)("span",{children:"GDPR"}),(0,u._x)("To be compliant with privacy regulations, your customers must have explicitly accepted to receive your marketing emails.","GDPR compliance information","mailpoet")]})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(zd,{showError:c&&null===l,checked:h,onCheck:e=>d(e?"subscribed":"unsubscribed"),name:"mailpoet_woocommerce_import_type",automationId:"woocommerce_import_type"})})]}):null,(0,g.jsxs)("div",{className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:Ge()((0,u.__)("Collect more precise email and site engagement, and e-commerce metrics by enabling cookie tracking. [link]Learn more[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/280-woocommerce-cookie-tracking",rel:"noopener noreferrer",target:"_blank",children:e},e))}),(0,g.jsxs)("div",{className:"mailpoet-wizard-note",children:[(0,g.jsx)("span",{children:"GDPR"}),(0,u._x)("To be compliant, you should display a cookie tracking banner on your website.","GDPR compliance information","mailpoet")]})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(zd,{showError:c&&null===s,checked:s,onCheck:e=>n(e),name:"mailpoet_woocommerce_tracking",automationId:"woocommerce_tracking"})})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,disabled:t,automationId:"submit_woocommerce_setup",children:p})]})]})}function Gd(e){return(0,g.jsx)(ss,{illustrationUrl:e.illustrationUrl,children:e.children})}function Yd({isWizardStep:e=!1,redirectToNextStep:t=null}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,Bd.iK)("woocommerce"),l=(0,Bd.iK)("tracking")[1],d=(0,Bd.iK)("woocommerce_import_screen_displayed")[1],c=(0,Bd.iK)("mailpoet_subscribe_old_woocommerce_customers")[1],p=e=>{i(!1),m.U.Notice.showApiErrorNotice(e,{scroll:!0})},u=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(p),h=(0,g.jsx)(Gd,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Vd,{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 u(_),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(p),e?t():await(async()=>{e?await u({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?h:(0,g.jsx)(qd,{children:h})}function Kd({skipStep:e,loading:t,update_sender:a,submit_sender:i,sender:s=null}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:1,children:(0,u.__)("Start by configuring your sender information","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("p",{children:[(0,g.jsx)("b",{children:(0,u.__)("Default sender","mailpoet")}),(0,g.jsx)("br",{}),(0,u.__)("Enter details of the person or brand your subscribers expect to receive emails from","mailpoet")]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{id:"mailpoet_sender_form",onSubmit:e=>{e.preventDefault(),ke()("#mailpoet_sender_form").parsley().validate()&&i()},children:[(0,g.jsxs)(ka.Grid.TwoColumns,{children:[(0,g.jsxs)("label",{htmlFor:"senderName",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:(0,u._x)("From Name","A form field label","mailpoet")}),(0,g.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,g.jsxs)("label",{htmlFor:"senderAddress",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:(0,u._x)("From Address","A form field label","mailpoet")}),(0,g.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,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:t,children:(0,u._x)("Continue","A label on a button","mailpoet")}),(0,g.jsx)(o.Button,{href:"#skipStep",isDisabled:t,isFullWidth:!0,onClick:e,variant:"tertiary",children:(0,u._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}Gd.propTypes={illustrationUrl:Qe().string.isRequired,children:Qe().oneOfType([Qe().arrayOf(Qe().node),Qe().node]).isRequired},Yd.displayName="WooCommerceController",Kd.displayName="WelcomeWizardSenderStep";const Jd=e=>null==e;function Qd({loading:e,submitForm:t}){const[a,i]=(0,r.useState)({tracking:void 0,libs3rdParty:void 0}),[s,n]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:1,children:(0,u.__)("Confirm privacy and data settings","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("form",{onSubmit:function(e){return e.preventDefault(),n(!0),Jd(a.libs3rdParty)||Jd(a.tracking)||t(a.tracking,a.libs3rdParty),!1},children:[(0,g.jsxs)("div",{children:[(0,g.jsxs)("div",{id:"mailpoet-wizard-3rd-party-libs",className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,u.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:Ge()((0,u.__)("MailPoet may load Google Fonts, WordPress.com and other [link]3rd party libraries[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,(e,t)=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/article/338-enabledisable-3rd-party-libraries",target:"_blank",rel:"noopener noreferrer",children:e},t))})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(zd,{showError:s&&Jd(a.libs3rdParty),onCheck:e=>{const t={libs3rdParty:e};i(e=>({...e,...t}))},checked:a.libs3rdParty,name:"mailpoet_libs_3rdParty"})})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{id:"mailpoet-wizard-tracking",className:"mailpoet-wizard-woocommerce-option",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,u.__)("Help improve MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:Ge()((0,u.__)("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,g.jsx)("a",{href:"https://kb.mailpoet.com/article/130-sharing-your-data-with-us",target:"_blank",rel:"noopener noreferrer",children:e},t))})]}),(0,g.jsx)("div",{className:"mailpoet-wizard-woocommerce-toggle",children:(0,g.jsx)(zd,{showError:s&&Jd(a.tracking),onCheck:e=>{const t={tracking:e};i(e=>({...e,...t}))},checked:a.tracking,name:"mailpoet_tracking"})})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(De.$,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:e,disabled:e,children:(0,u._x)("Continue","A label on a button","mailpoet")})]})]})}Qd.propTypes={loading:Qe().bool.isRequired,submitForm:Qe().func.isRequired},Qd.displayName="WelcomeWizardUsageTrackingStep";var Zd=a(32881);async function Xd(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 ec(e=null){await Xd({version:window.mailpoet_version,installed_after_new_domain_restrictions:1,welcome_wizard_current_step:""}),window.location.href=e||window.finish_wizard_url}function tc(){const[e,t]=(0,r.useState)(!1),a=e=>{e.preventDefault(),t(!0)},i=()=>t(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:Ge()(m.U.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,(e,t)=>(0,g.jsx)("a",{onClick:a,href:"#",children:e},t))}),e&&(0,g.jsxs)(ia.A,{className:"mailpoet-welcome-wizard-confirmation-modal",title:m.U.I18n.t("welcomeWizardMSSConfirmationModalTitle"),onRequestClose:i,children:[(0,g.jsx)("p",{children:m.U.mailFunctionEnabled?m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraph"):m.U.I18n.t("welcomeWizardMSSConfirmationModalFirstParagraphWithoutMailFunction")}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSConfirmationModalSecondParagraph")}),(0,g.jsxs)("div",{className:"mailpoet-welcome-wizard-confirmation-modal-buttons",children:[(0,g.jsx)(o.Button,{variant:"secondary",onClick:i,children:m.U.I18n.t("welcomeWizardMSSConfirmationModalGoBackButton")}),(0,g.jsx)(o.Button,{onClick:async e=>{e.preventDefault(),await ec("admin.php?page=mailpoet-settings#/mta/other")},children:m.U.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const ac=(e,t,a=!1)=>{Xd({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 sc(){const e=(0,Ne.Zp)(),{step:t}=(0,Ne.g)(),a=(0,Bd.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&ac(e,`/steps/${t}/part/3`,!0)},[a.isKeyValid,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSFirstPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSFirstPartSubtitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-welcome-wizard-mss-list",children:(0,g.jsxs)(o.List,{children:[(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList1")}),(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList2")}),m.U.subscribersCount<1e3?(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Free")}):(0,g.jsx)("li",{children:m.U.I18n.t("welcomeWizardMSSList3Paid")})]})}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.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),ac(t,`/steps/${a}/part/2`)}(a,e,t),iconEnd:(0,g.jsx)(ta.A,{icon:Zd.A}),children:m.U.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(tc,{})]})}var nc=a(89949),rc=a(98304);function oc(){const e=(0,Ne.Zp)(),{step:t}=(0,Ne.g)(),a=(0,Bd.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&ac(e,`/steps/${t}/part/3`,!0)},[a.isKeyValid,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.Heading,{level:1,children:m.U.I18n.t("welcomeWizardMSSSecondPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSSecondPartEnterKey")}),(0,g.jsx)("p",{children:Ge()(m.U.I18n.t("welcomeWizardMSSSecondPartNoAccount"),/\[link](.*?)\[\/link]/g,(e,t)=>(0,g.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,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("label",{htmlFor:"mailpoet_premium_key",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:m.U.I18n.t("welcomeWizardMSSSecondPartInputLabel")}),(0,g.jsx)(rc.M,{placeholder:m.U.I18n.t("welcomeWizardMSSSecondPartInputPlaceholder"),isFullWidth:!0,forceRevealed:!0})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(nc.y,{label:m.U.I18n.t("welcomeWizardMSSSecondPartButton"),isFullWidth:!0}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(tc,{})]})}function lc(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ut.D,{level:1,children:m.U.I18n.t("welcomeWizardMSSThirdPartTitle")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartFirstParagraph")}),(0,g.jsx)("p",{children:m.U.I18n.t("welcomeWizardMSSThirdPartSecondParagraph")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(o.Button,{className:"mailpoet-wizard-continue-button",type:"button",onClick:()=>ec(),isFullWidth:!0,children:m.U.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function dc(){const{pathname:e}=(0,Ne.zy)(),{step:t}=(0,Ne.g)(),a=(0,Ne.Zp)(),i=(0,Ne.zy)();return(0,r.useEffect)(()=>{i.pathname.includes("part")||ac(a,`/steps/${t}/part/1`,!0)},[t,e,a,i]),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"part/1",element:(0,g.jsx)(sc,{})}),(0,g.jsx)(Ne.qh,{path:"part/2",element:(0,g.jsx)(oc,{})}),(0,g.jsx)(Ne.qh,{path:"part/3",element:(0,g.jsx)(lc,{})})]})}const cc=({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})},mc=()=>{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},pc=()=>mc().length,uc=async(e,t,a)=>{a<pc()?ac(e,`/steps/${a+1}`):t()};var hc=a(22270);function gc(){const e=(0,Ne.g)(),t=(0,Ne.Zp)(),a=pc(),i=parseInt(e.step,10),[s,n]=(0,r.useState)(!1),[l,c]=(0,Bd.iK)("sender"),m=(0,Bd.iK)("analytics")[1],p=(0,Bd.iK)("3rd_party_libs")[1];(0,r.useEffect)(()=>{(i>a||i<1)&&ac(t,"/steps/1")},[i,a,t]);const u=(0,at.partial)(uc,t,ec),h=(0,r.useCallback)(async(e,t)=>{const a={enabled:e?"1":""},i={enabled:t?"1":""},s={analytics:a,"3rd_party_libs":i};await Xd(s),m(a),p(i)},[m,p]),_=(0,r.useCallback)(async(e,t)=>{n(!0),await h(e,t),u(i),n(!1)},[u,i,h]),f=(0,r.useCallback)(e=>{c({...l,...e})},[l,c]),b=(0,r.useCallback)(async()=>{n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await h(!0,!0),await Xd(cc(l)).then(()=>u(i)),n(!1)},[u,l,i,h]),x=(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 h(!0,!0),await Xd(cc(t)).then(()=>{c(t),u(i)}),n(!1)},[u,i,c,h]),v=(j=i,mc()[j-1]||null);var j;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.V,{hideScreenOptions:!0,logoWithLink:!1,children:(0,g.jsx)(hc.g,{count:a,current:i,doneCallback:e=>{ac(t,`/steps/${e}`)}})}),(0,g.jsxs)(qd,{children:["WelcomeWizardSenderStep"===v?(0,g.jsx)(Gd,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Kd,{update_sender:f,submit_sender:b,skipStep:x,loading:s,sender:l})})}):null,"WelcomeWizardUsageTrackingStep"===v?(0,g.jsx)(Gd,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Qd,{loading:s,submitForm:_})})}):null,"WelcomeWizardPitchMSSStep"===v?(0,g.jsx)(Gd,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(dc,{})})}):null,"WizardWooCommerceStep"===v?(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Yd,{isWizardStep:!0,redirectToNextStep:()=>u(i)})}):null]})]})}gc.displayName="WelcomeWizardStepsController";const _c=(0,o.withBoundary)(gc),fc=(0,o.withBoundary)(Yd);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,g.jsx)(l.F.Provider,{value:a,children:(0,g.jsxs)(Se.HashRouter,{children:[(0,g.jsx)(p.q,{}),(0,g.jsxs)(Ne.BV,{children:[(0,g.jsx)(Ne.qh,{path:"/steps/:step/*",element:(0,g.jsx)(_c,{})}),(0,g.jsx)(Ne.qh,{path:"/woocommerce",element:(0,g.jsx)(fc,{})}),(0,g.jsx)(Ne.qh,{path:"*",element:(0,g.jsx)(Ne.C5,{to:e})})]})]})})}const xc=document.getElementById("mailpoet-wizard-container");function vc(){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,g.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,g.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,g.jsx)(g.Fragment,{children:e.errors.map(e=>(0,g.jsx)("p",{children:e.message}))}),{scroll:!0}))})},[i]),null===e?(0,g.jsx)("p",{children:"Loading experimental features..."}):0===Object.values(e).length?(0,g.jsx)("p",{children:"There are no experimental features at the moment."}):(0,g.jsx)(l.F.Provider,{value:a,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(p.q,{}),Object.values(e).map(e=>{const t=`experimental-feature-${e.name}`;return(0,g.jsx)("div",{children:(0,g.jsxs)("label",{htmlFor:t,children:[(0,g.jsx)("input",{id:t,type:"checkbox",name:e.name,defaultChecked:e.value,onChange:s})," ",e.name]})},e.name)})]})})}xc&&((0,o.registerTranslations)(),(0,$d.k)(),(0,n.createRoot)(xc).render((0,g.jsx)(bc,{})));const jc=document.getElementById("experimental_features_container");vc.displayName="ExperimentalFeatures",jc&&((0,o.registerTranslations)(),(0,n.createRoot)(jc).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(vc,{})})));var yc=a(98359);function wc({log:e}){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:e.name}),(0,g.jsx)("td",{role:"gridcell",children:(0,g.jsx)("div",{className:"mailpoet-logs-message "+(t?"mailpoet-logs-message-full":""),children:e.message})}),(0,g.jsx)("td",{role:"gridcell",className:"mailpoet-logs-min-width",children:(0,g.jsx)(o.Button,{dimension:"small",variant:"secondary",onClick:()=>{a(!t)},children:t?(0,u.__)("Show less","mailpoet"):(0,u.__)("Show more","mailpoet")})}),(0,g.jsx)("td",{className:"mailpoet-logs-min-width",role:"gridcell",children:m.U.Date.full(e.created_at)})]},`log-row-${e.id}`)}function Sc({logs:e,onFilter:t,originalFrom:a,originalTo:i,originalSearch:s,originalOffset:n,originalLimit:l}){const[d,c]=(0,r.useState)(a??void 0),[p,h]=(0,r.useState)(i??void 0),[_,f]=(0,r.useState)(n??""),[b,x]=(0,r.useState)(l??""),[v,j]=(0,r.useState)(s||""),y=(0,wa.curry)((e,t)=>{e(null!==t?m.U.Date.format(t,{format:"Y-m-d"}):void 0)}),w=(0,r.useCallback)(()=>{const e={};d&&(e.from=d),p&&(e.to=p),_&&""!==_.trim()&&(e.offset=_),b&&""!==b.trim()&&(e.limit=b),v&&""!==v.trim()&&(e.search=v.trim()),t(e)},[d,b,_,v,p,t]);return(0,g.jsxs)("div",{className:"mailpoet-listing mailpoet-logs",children:[(0,g.jsxs)("div",{className:"mailpoet-listing-header",children:[(0,g.jsxs)("div",{className:"mailpoet-listing-search",children:[(0,g.jsx)("label",{htmlFor:"search_input",className:"screen-reader-text",children:(0,u.__)("Search","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",iconStart:yc.I,type:"search",id:"search_input",name:"s",onChange:e=>j(e.target.value),value:v,placeholder:(0,u.__)("Search","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-listing-filters",children:[`${(0,u.__)("From","mailpoet")}:`,(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(Aa.t,{dateFormat:"MMMM d, yyyy",onChange:y(c),maxDate:new Date,selected:d?Rr(d):void 0,dimension:"small"}),`${(0,u.__)("To","mailpoet")}:`,(0,g.jsx)(Aa.t,{dateFormat:"MMMM d, yyyy",onChange:y(h),maxDate:new Date,selected:p?Rr(p):void 0,dimension:"small"})]})]}),(0,g.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,g.jsx)("label",{htmlFor:"offset_input",className:"screen-reader-text",children:(0,u.__)("Offset","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",id:"offset_input",name:"o",type:"number",onChange:e=>f(e.target.value),value:_,placeholder:(0,u.__)("Offset","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-logs-limit",children:[(0,g.jsx)("label",{htmlFor:"limit_input",className:"screen-reader-text",children:(0,u.__)("Limit","mailpoet")}),(0,g.jsx)(o.Input,{dimension:"small",id:"limit_input",name:"l",type:"number",onChange:e=>x(e.target.value),value:b,placeholder:(0,u.__)("Limit","mailpoet")})]}),(0,g.jsx)(o.Button,{dimension:"small",onClick:w,children:(0,u._x)("Filter","verb","mailpoet")})]}),(0,g.jsxs)("table",{className:"mailpoet-listing-table widefat striped",role:"grid",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,u.__)("Name","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Message","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Action","mailpoet")}),(0,g.jsx)("th",{children:(0,u.__)("Created On","mailpoet")})]})}),(0,g.jsx)("tbody",{children:(0,g.jsx)(o.ErrorBoundary,{children:e.map(e=>(0,g.jsx)(wc,{log:e},`log-${e.id}`))})})]})]})}wc.displayName="Log",Sc.displayName="LogsList";const Nc=document.getElementById("mailpoet_logs_container");if(Nc){const e=new URL(window.location.href);(0,n.createRoot)(Nc).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Sc,{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 Cc=a(55570);function kc({onRequestClose:e=wa.noop}){const[t,a]=(0,r.useState)(!1);return ke()(e=>{e(document).on("click",".notice .mailpoet-js-button-fix-this",()=>{a(!0)})}),(0,g.jsxs)(l.F.Provider,{value:(0,l.f)(window),children:[(0,g.jsx)(p.q,{}),t&&(0,g.jsx)(Cc.U,{onRequestClose:()=>{a(!1),e()}})]})}const Ic=document.getElementById("mailpoet_set_from_address_modal");Ic&&(0,n.createRoot)(Ic).render((0,g.jsx)(kc,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const Uc=e=>(async e=>{if("MailPoet"!==m.U.mtaMethod)return!0;if(window.mailpoet_sender_restrictions?.skipAuthorization)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,Ma.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((0,u.__)("Failed to resume sending because the email address is unauthorized. Please authorize it and try again.","mailpoet"),{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((0,u.__)("Sending has been resumed.","mailpoet"))}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})});ke()(e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",e=>{Uc(e.target.value)})});var Ac=a(83260);const Ec=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),a=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,Ma.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 Tc(){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)};ke()(t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)})},[]),(0,g.jsx)(g.Fragment,{children:e&&(0,g.jsx)(Ac.J,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:Ec,showSenderEmailTab:"email"===a,showSenderDomainTab:"domain"===a,initialTab:"domain"===a?"sender_domain":"sender_email"})})}const Rc=document.getElementById("mailpoet_authorize_sender_email_modal");function Dc({color:e}){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:`body { background: ${e}; }`}})}Rc&&(0,n.createRoot)(Rc).render((0,g.jsx)(Tc,{}));const Fc=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function Oc(){const e=window.mailpoet_welcome_wizard_current_step,t="string"==typeof e&&e.startsWith("/steps");return(0,g.jsx)(o.Button,{onClick:Fc,dimension:"hero",children:t?(0,u.__)("Continue setup","mailpoet"):(0,u.__)("Begin setup","mailpoet")})}function Pc(){return(0,g.jsx)("section",{className:"landing-header",children:(0,g.jsxs)("div",{className:"mailpoet-content-center",children:[(0,g.jsx)(ut.D,{level:0,children:(0,u.__)("Better email — without leaving WordPress","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("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,g.jsx)(Oc,{})]})})}function Lc(){return(0,g.jsx)("section",{className:"landing-footer",children:(0,g.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,g.jsxs)(ut.D,{level:4,children:[" ",(0,u.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,g.jsx)(Oc,{})]})})}function Mc(){const e=[{slug:"item-1",title:(0,u.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,u.__)("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,u.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,u.__)("How do I send a newsletter?","mailpoet"),text:(0,u.__)("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,u.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,u.__)("Do I need a paid plan?","mailpoet"),text:(0,u.__)("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,u.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-mailpoet-plans-and-limits-explained"},{slug:"item-4",title:(0,u.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,u.__)('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,u.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,u.__)("How do I customize emails for my store?","mailpoet"),text:(0,u.__)("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,u.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/277-woocommerce-automatic-emails"}];return(0,g.jsxs)("section",{className:"landing-faq",children:[(0,g.jsxs)("div",{className:"mailpoet-content-center landing-faq-header",children:[(0,g.jsxs)(ut.D,{level:2,children:[" ",(0,u.__)("Frequently asked questions","mailpoet")," "]}),(0,g.jsx)("p",{children:Ge()((0,u.__)("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,g.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e))})]}),(0,g.jsx)("div",{className:"mailpoet-content-center landing-faq-mobile",children:(0,g.jsx)(ut.D,{level:2,children:(0,u.__)("FAQ","mailpoet")})}),(0,g.jsx)("div",{className:"mailpoet-faq-accordion",children:e.map(e=>(0,g.jsxs)("details",{children:[(0,g.jsxs)("summary",{children:[" ",(0,g.jsxs)("strong",{children:[" ",e.title," "]})," "]}),(0,g.jsxs)("div",{className:"content",children:[(0,g.jsx)("p",{children:e.text}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:e.readMoreLink,rel:"noopener noreferrer",target:"_blank",children:e.readMoreText})})]})]},e.slug))}),(0,g.jsxs)("div",{className:"mailpoet-content-center landing-faq-mobile",children:[(0,g.jsx)("p",{children:(0,u.__)("Can’t find what you’re looking for?","mailpoet")}),(0,g.jsx)("p",{children:Ge()((0,u.__)("[link]View all resources[/link]","mailpoet"),/\[link\](.*?)\[\/link\]/,e=>(0,g.jsx)("a",{href:"https://kb.mailpoet.com/",rel:"noopener noreferrer",target:"_blank",children:e},e))})]})]})}Pc.displayName="Landingpage Header",Lc.displayName="Landingpage Footer",Mc.displayName="Landingpage FAQ";const $c={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.20241219.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 Bc(){return(0,g.jsxs)("section",{className:"landing-content",children:[(0,g.jsxs)("div",{className:"hero-section mailpoet-content-center",children:[(0,g.jsx)("img",{src:$c.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(ut.D,{level:4,children:(0,u.sprintf)((0,u.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"600,000+")}),(0,g.jsx)("br",{}),(0,g.jsxs)(ka.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:$c.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,u.__)("Deliver beautiful emails","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Choose from our pre-built templates or create your own with our drag-and-drop email builder.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:$c.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,u.__)("Grow your mailing list","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Use our custom sign-up forms to reach more subscribers while you deliver engaging content.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:$c.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,u.__)("Reach the right people","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("From the first hello to repeated purchases, send emails to the right people at the right time.","mailpoet")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:$c.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,u.__)("Save time with automations","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Set up smart triggers based on user behavior to automate list management, email sending, and more.","mailpoet")})]})]})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsxs)("div",{className:"landingpage-wooCommerce-features",children:[(0,g.jsxs)("div",{className:"mailpoet-content-center",children:[(0,g.jsx)(ut.D,{level:2,children:(0,u.__)("MailPoet + WooCommerce","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,g.jsx)("br",{}),(0,g.jsxs)(ka.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:$c.wooCommerceFeatureImages.feature_1,alt:(0,u.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,u.__)("Automate customer communication","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,g.jsxs)(ka.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:$c.wooCommerceFeatureImages.feature_2,alt:(0,u.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,u.__)("Measure revenue per email","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,g.jsxs)(ka.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:$c.wooCommerceFeatureImages.feature_3,alt:(0,u.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,u.__)("Let your brand shine","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,g.jsxs)(ka.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:$c.wooCommerceFeatureImages.feature_4,alt:(0,u.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,u.__)("Rescue abandoned carts","mailpoet")}),(0,g.jsx)("p",{children:(0,u.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function qc(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)("main",{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(Dc,{color:"#fff"}),(0,g.jsx)(Pc,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Bc,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Mc,{}),(0,g.jsx)(Lc,{})]})})}Bc.displayName="Landingpage Content",qc.displayName="Landingpage";const Hc=document.getElementById("mailpoet_landingpage_container");Hc&&((0,o.registerTranslations)(),(0,n.createRoot)(Hc).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(qc,{})}))),a(45371)},45371(){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(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 u=null;return r.NODE_STREAM_INPUT,"string"==typeof a?(a=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(a),u=i.download?new d(i):new m(i)):!0===a.readable&&j(a.read)&&j(a.on)?u=new p(i):(t.File&&a instanceof File||a instanceof Object)&&(u=new c(i)),u.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 p=new RegExp(h(o),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return u(null,e,d);if("object"==typeof e[0])return u(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])),u(e.fields||[],e.data||[],d);throw new Error("Unable to serialize unrecognized input");function u(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,p=!1,u=o?0===Object.keys(t[c]).length:0===t[c].length;if(a&&!o&&(p="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])}p=""===h.join("").trim()}if(!p){for(var b=0;b<m;b++){0<b&&!u&&(r+=s);var x=o&&l?e[b]:b;r+=g(t[c][x],b)}c<t.length-1&&(!a||0<m&&!u)&&(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(p,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=u,r.NetworkStreamer=d,r.FileStreamer=c,r.StringStreamer=m,r.ReadableStreamStreamer=p,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=x(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new u(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 p(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 u(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,p=!1,u=!1,_=[],f={data:[],errors:[],meta:{}};if(j(e.step)){var b=e.step;e.step=function(t){if(f=t,w())y();else{if(y(),0===f.data.length)return;c+=t.data.length,e.preview&&c>e.preview?a.abort():(f.data=f.data[0],b(f,d))}}}function v(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function y(){return f&&i&&(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 p=n[m],u=0,h=0,_=0;d=void 0;for(var f=new g({comments:s,delimiter:p,newline:a,preview:10}).parse(t),b=0;b<f.data.length;b++)if(i&&v(f.data[b]))_++;else{var x=f.data[b].length;h+=x,void 0!==d?0<x&&(u+=Math.abs(x-d),d=x):d=x}0<f.data.length&&(h/=f.data.length-_),(void 0===l||u<=l)&&(void 0===c||c<h)&&1.99<h&&(l=u,o=p,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=x(e);return e.preview&&e.header&&c.preview++,t=s,a=new g(c),f=a.parse(t,n,o),y(),p?{meta:{paused:!0}}:f||{meta:{paused:!1}}},this.paused=function(){return p},this.pause=function(){p=!0,a.abort(),t=j(e.chunk)?"":t.substring(a.getCharIndex())},this.resume=function(){d.streamer._halted?(p=!1,d.streamer.parseChunk(t,!0)):setTimeout(d.resume,3)},this.aborted=function(){return u},this.abort=function(){u=!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,p,u){if("string"!=typeof r)throw new Error("Input must be a string");var g=r.length,_=a.length,f=i.length,b=s.length,x=j(n),v=[],y=[],w=[],S=c=0;if(!r)return V();if(e.header&&!p){var N=r.split(i)[0].split(a),C=[],k={},I=!1;for(var U in N){var A=N[U];j(e.transformHeader)&&(A=e.transformHeader(A,U));var E=A,T=k[A]||0;for(0<T&&(I=!0,E=A+"_"+T),k[A]=T+1;C.includes(E);)E=E+"_"+T;C.push(E)}if(I){var R=r.split(i);R[0]=C.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(u)return V();if(!s||w.substring(0,b)!==s){if(x){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+b)===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),x&&(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 u||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),x&&(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 u||(void 0===e&&(e=r.substring(c)),w.push(e),c=g,q(w),x&&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+(p||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:b,resume:b};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 b(){throw new Error("Not implemented.")}function x(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var a in e)t[a]=x(e[a]);return t}function v(e,t){return function(){e.apply(t,arguments)}}function j(e){return"function"==typeof e}return i&&(t.onmessage=function(e){var a=e.data;if(void 0===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,(p.prototype=Object.create(l.prototype)).constructor=p,r},void 0===(i=a.apply(t,[]))||(e.exports=i)}},e=>{e.O(0,[223],()=>e(e.s=42509)),e.O()}]);
Save
Back