403Webshell
Server IP : 104.26.3.156  /  Your IP : 216.73.216.185
Web Server : nginx/1.27.1
System : Linux us-1 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User : vinodai ( 3134)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /storage/v1396/themastermynd/public_html/wp-content/plugins/mailpoet/assets/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /storage/v1396/themastermynd/public_html/wp-content/plugins/mailpoet/assets/dist/js/admin.js
/*! For license information please see admin.js.LICENSE.txt */
(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[884],{34989(e,t,a){"use strict";var i={};a.r(i),a.d(i,{hideProductDiscovery:()=>R,hideTaskList:()=>P,hideUpsell:()=>D});var s={};a.r(s),a.d(s,{getCanDisplayUpsell:()=>Z,getCanImportWooCommerceSubscribers:()=>L,getCurrentTask:()=>Q,getGlobalSubscriberStatsChange:()=>z,getHasForms:()=>q,getHasImportedSubscribers:()=>$,getIsFreeMailUser:()=>W,getIsNewUserForSenderDomainAuth:()=>B,getIsProductDiscoveryDone:()=>Y,getIsProductDiscoveryHidden:()=>H,getIsTaskListHidden:()=>F,getIsUpsellHidden:()=>J,getIsWooCommerceActive:()=>K,getListsSubscriberStatsChange:()=>G,getMssActive:()=>V,getProductDiscoveryTasksStatus:()=>M,getTasksStatus:()=>O}),(0,a(11787).md)();var n=a(79124),r=a(7378),o=a(14762),l=a(13722),d=a(25354),c=a(65591),m=a(92794),u=a(27901),p=a(69139),h=a(14442),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,p.__)("Good news! MailPoet can now send your website’s emails too","mailpoet")}),(0,g.jsxs)("p",{children:[(0,p.__)("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,p.__)("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,p._x)("Enable","verb","mailpoet")})})]})}_.displayName="TransactionalEmailsProposeOptInNotice";var f=a(2726),b=a.n(f),x=a(3698),v=a.n(x);const y=()=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"mailer",action:"resumeSending"}).done(()=>{m.U.Notice.success((0,p.__)("Sending has been resumed.","mailpoet"))}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})});function w(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,p.__)("Please check your sending method configuration, you may need to consult with your hosting company.","mailpoet")}),(0,g.jsx)("br",{}),(0,g.jsx)("p",{children:b()((0,p.__)("The easy alternative is to <b>send emails with MailPoet Sending Service</b> instead, like thousands of other users do.","mailpoet"),/<b>(.*?)<\/b>/g,(e,t)=>(0,g.jsx)("b",{children:e},t))}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:m.U.MailPoetComUrlFactory.getFreePlanUrl({utm_campaign:"sending-error"}),target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Sign up for free in minutes","mailpoet")})}),(0,g.jsx)("br",{})]})}function j(){return(0,g.jsx)("p",{children:b()((0,p.__)("Check your [link]sending method settings[/link].","mailpoet"),/\[link\](.*?)\[\/link\]/g,e=>(0,g.jsx)("a",{href:"?page=mailpoet-settings#mta",children:e},"check-sending"))})}function S({mtaLog:e,mtaMethod:t,isInline:a=!1}){const[i,s]=(0,r.useState)(!1);if(i||!e?.error||"paused"!==e.status||"authorization"===e.error.operation)return null;if("send"===e.error.operation&&"MailPoet"===t&&m.U.hasInvalidMssApiKey)return null;if("MailPoet"===t&&"email_limit_reached"===e.error.operation&&m.U.emailVolumeLimitReached)return null;if("MailPoet"===t&&"subscriber_limit_reached"===e.error.operation&&m.U.subscribersLimitReached)return null;if("migration"===e.error.operation){const t=v()("mailpoet_notice notice notice-warning",{inline:a});return(0,g.jsx)("div",{className:t,children:(0,g.jsx)("p",{children:e.error.error_message})})}let n=e.error.error_message;const o=e.error.error_code,l=v()("mailpoet_notice notice notice-error",{inline:a});o&&(n+=n?", ":"",n+=(0,p.__)("Error code: %1$s","mailpoet").replace("%1$s",o));const d=[];n=n.replace(/<a.*?>.*?<\/a>/g,e=>(d.push(e),`[link-${d.length-1}]`)),n=b()(n,/\[link-(\d+)\]/g,e=>{const t=d[e],a=(new DOMParser).parseFromString(t,"text/xml").firstChild,i=a.getAttributeNames(),s=["target","rel","class","data-email","data-type"],n=i.reduce((e,t)=>s.includes(t)?{...e,["class"===t?"className":t]:a.getAttribute(t)}:e,{});return(0,g.jsx)("a",{href:a.getAttribute("href"),...n,children:a.textContent},`a-${e}`)});let c=0;if(n=b()(n,/(<br\s*\/?>)/g,()=>(0,g.jsx)("br",{},"br-"+c++)),"pending_approval"===e.error.operation)return(0,g.jsx)("div",{className:l,children:(0,g.jsx)("p",{children:n})});if("insufficient_privileges"===e.error.operation||"subscriber_limit_reached"===e.error.operation||"email_limit_reached"===e.error.operation)return(0,g.jsxs)("div",{className:l,children:[(0,g.jsx)("p",{children:n}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"#",className:"button button-primary",onClick:e=>{e.preventDefault(),y().then(()=>s(!0)).catch(()=>{})},children:(0,p.__)("I have upgraded my subscription, resume sending","mailpoet")})})]});let u=null;return"PHPMail"===t?u=(0,g.jsx)(w,{}):"MailPoet"!==t&&(u=(0,g.jsx)(j,{})),(0,g.jsxs)("div",{className:l,children:[(0,g.jsxs)("p",{children:["send"===e.error.operation?(0,p.__)("Sending has been paused due to a technical issue with %1$s","mailpoet").replace("%1$s",t):(0,p.__)("Sending is paused because the following connection issue prevents MailPoet from delivering emails","mailpoet"),": ",(0,g.jsx)("i",{children:n})]}),u,(0,g.jsx)("p",{children:(0,g.jsx)("a",{href:"#",className:"button button-primary",onClick:e=>{e.preventDefault(),y().then(()=>s(!0)).catch(()=>{})},children:(0,p.__)("Resume sending","mailpoet")})})]})}var k=a(10812);function N(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u.q,{}),(0,g.jsx)(k.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)(S,{mtaLog:m.U.mtaLog,mtaMethod:m.U.mtaMethod,isInline:!0})]})}var C=a(51751),E=a(90194),U=a(39173),I=a(89074),A=a(95924),T=a(84356);function*P(){return yield(0,T.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.task_list_dismissed":!0}}),{type:"SET_TASK_LIST_HIDDEN"}}function*R(){return yield(0,T.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.product_discovery_dismissed":!0}}),{type:"SET_PRODUCT_DISCOVERY_HIDDEN"}}function*D(){return yield(0,T.p)({endpoint:"settings",action:"set",method:"POST",data:{"homepage.upsell_dismissed":!0}}),{type:"SET_UPSELL_HIDDEN"}}function F(e){return e.taskList.isTaskListHidden}function O(e){return e.taskList.tasksStatus}function M(e){return e.productDiscovery.tasksStatus}function L(e){return e.taskList.canImportWooCommerceSubscribers}function $(e){return e.taskList.hasImportedSubscribers}function B(e){return e.taskList.isNewUserForSenderDomainAuth}function W(e){return e.taskList.isFreeMailUser}function V(e){return e.taskList.mssActive}function q(e){return e.formsCount>0}function H(e){return e.productDiscovery.isHidden}function z(e){return e.subscribersStats.global}function G(e){return e.subscribersStats.lists}function Y(e){const t=e.productDiscovery.tasksStatus;return e.isWooCommerceActive?t.addSubscriptionForm&&t.setUpWelcomeCampaign&&t.setUpAbandonedCartEmail&&t.brandWooEmails:t.setUpWelcomeCampaign&&t.addSubscriptionForm&&t.sendFirstNewsletter}function K(e){return e.isWooCommerceActive}function Q(e){return e.taskList.tasksStatus.senderSet?e.taskList.tasksStatus.mssConnected?!e.taskList.tasksStatus.wooSubscribersImported&&e.taskList.canImportWooCommerceSubscribers?"wooSubscribersImported":e.taskList.tasksStatus.subscribersAdded?null:"subscribersAdded":"mssConnected":"senderSet"}function J(e){return e.upsell.isHidden}function Z(e){return e.upsell.upsellStatus?.canDisplay}function X(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 ee="mailpoet/homepage",te={};var ae=a(87452),ie=a(13387);function se(e,t,a){m.U.trackEvent(e,{ctaLabel:t},{send_immediately:!0},()=>{window.location.href=a})}function ne({title:e,titleCompleted:t="",slug:a,link:i,order:s,isCompleted:n,isActive:r,children:o=null}){const l=v()("mailpoet-task-list__task",{"mailpoet-task-list__task--completed":n,"mailpoet-task-list__task--active":r}),d=()=>{se("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)(ae.A,{icon:ie.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 re({onHide:e}){const{tasksStatus:t,currentTask:a,hasImportedSubscribers:i,canImportWooCommerceSubscribers:s,isNewUserForSenderDomainAuth:n,isFreeMailUser:r,mssActive:l}=(0,C.A)(e=>({tasksStatus:e(ee).getTasksStatus(),currentTask:e(ee).getCurrentTask(),hasImportedSubscribers:e(ee).getHasImportedSubscribers(),canImportWooCommerceSubscribers:e(ee).getCanImportWooCommerceSubscribers(),isNewUserForSenderDomainAuth:e(ee).getIsNewUserForSenderDomainAuth(),isFreeMailUser:e(ee).getIsFreeMailUser(),mssActive:e(ee).getMssActive()}),[]),d=[];if(d.push((0,g.jsx)(ne,{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)(ne,{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)(ne,{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)(ne,{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)(ne,{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)(E.A,{label:m.U.I18n.t("hideList"),icon:U.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 oe({title:e,slug:t,link:a,description:i,doneMessage:s,imgSrc:n,isDone:r}){const o=()=>{se("Home Page Task",t,a)};return(0,g.jsxs)("li",{className:v()("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)(ae.A,{icon:ie.A})})})]})}function le({heading:e,description:t,children:a,headingAfter:i,className:s=""}){return(0,g.jsxs)("section",{className:v()("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 de({onHide:e}){const{tasksStatus:t,isWooCommerceActive:a,isDiscoveryDone:i}=(0,C.A)(e=>({tasksStatus:e(ee).getProductDiscoveryTasksStatus(),isWooCommerceActive:e(ee).getIsWooCommerceActive(),isDiscoveryDone:e(ee).getIsProductDiscoveryDone()}),[]),s=[];return s.push((0,g.jsx)(oe,{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)(oe,{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)(oe,{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)(oe,{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)(oe,{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)(le,{className:"mailpoet-homepage-product-discovery",heading:m.U.I18n.t("startEngagingWithYourCustomers"),headingAfter:(0,g.jsx)(E.A,{label:m.U.I18n.t("hideList"),icon:U.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 ce=a(35061),me=a(58768),ue=a(59068),pe=a(19453),he=a(8254),ge=a(69611);function _e({closable:e,onHide:t}){return(0,g.jsx)(le,{className:"mailpoet-homepage-upsell",heading:m.U.I18n.t("accelerateYourGrowth"),headingAfter:e&&t?(0,g.jsx)(ge.Ay,{icon:ce.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)(ae.A,{icon:me.A}),(0,g.jsx)("span",{children:m.U.I18n.t("detailedAnalytics")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(ae.A,{icon:ue.A}),(0,g.jsx)("span",{children:m.U.I18n.t("advancedSubscriberSegmentation")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(ae.A,{icon:pe.A}),(0,g.jsx)("span",{children:m.U.I18n.t("emailMarketingAutomations")})]}),(0,g.jsxs)("li",{children:[(0,g.jsx)(ae.A,{icon:he.A}),(0,g.jsx)("span",{children:m.U.I18n.t("prioritySupport")})]})]}),(0,g.jsx)(ge.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 fe=a(59717),be=a(19299);function xe(e,t){switch(t){case"unknown":case"dormant":case"good":case"excellent":return t;case"low":return"average"}return null==e?"unknown":e<20?"average":e<50?"good":"excellent"}function ve({id:e,engagementScore:t,engagementScoreType:a}){const i={unknown:{name:m.U.I18n.t("unknownBadgeName"),type:"unknown",tooltipTitle:m.U.I18n.t("unknownBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipUnknown")},dormant:{name:m.U.I18n.t("dormantBadgeName"),type:"dormant",tooltipTitle:m.U.I18n.t("dormantBadgeTooltip"),tooltipText:m.U.I18n.t("tooltipDormant")},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")}},s=`badge-${e}`,n=i[xe(t,a)],r=(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-listing-stats-tooltip-title",children:n.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)(be.E,{type:"unknown",name:m.U.I18n.t("unknownBadgeName")})," : ",i.unknown.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(be.E,{type:"dormant",name:m.U.I18n.t("dormantBadgeName")})," : ",i.dormant.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(be.E,{type:"excellent",name:m.U.I18n.t("excellentBadgeName")})," : ",i.excellent.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(be.E,{type:"good",name:m.U.I18n.t("goodBadgeName")})," : ",i.good.tooltipText,(0,g.jsx)("br",{}),(0,g.jsx)(be.E,{type:"average",name:m.U.I18n.t("averageBadgeName")})," : ",i.average.tooltipText]})]},`tooltip-${s}`);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)(be.E,{isInverted:!0,type:n.type,name:n.name,tooltip:r,tooltipId:s,tooltipPlace:"top"})})]})}const ye=(e,t,a)=>{e.preventDefault(),se("Home Page Statistics Click",t,a)};function we(){const{globalChange:e,listsChange:t,hasForms:a}=(0,C.A)(e=>({globalChange:e(ee).getGlobalSubscriberStatsChange(),listsChange:e(ee).getListsSubscriberStatsChange(),hasForms:e(ee).getHasForms()}),[]),i=0===t.length&&0===e.subscribed&&0===e.unsubscribed;return(0,g.jsx)(le,{className:"mailpoet-subscribers-stats",heading:m.U.I18n.t("subscribersHeading"),description:m.U.I18n.t("subscribersSectionDescription"),headingAfter:!i&&(0,g.jsxs)("span",{className:v()({"mailpoet-decrease":e.changePercent<0}),children:[(0,g.jsx)(ae.A,{icon:me.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)(ae.A,{icon:me.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=>ye(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=>ye(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)(ve,{id:e.id,engagementScore:e.averageEngagementScore})})}),(0,g.jsx)("td",{children:e.subscribed}),(0,g.jsx)("td",{children:e.unsubscribed})]},e.id))})]})]})})}var je=a(56828),Se=a(24671);function ke({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 Ne(){const[e,t]=(0,r.useState)(1),a=[(0,g.jsx)(ke,{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)(ke,{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)(ke,{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)(ke,{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)(ke,{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)(ke,{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)(le,{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)(ae.A,{icon:je.A})}):(0,g.jsx)(ae.A,{icon:je.A}),e<Math.ceil(a.length/2)?(0,g.jsx)("a",{href:"#",onClick:i,title:m.U.I18n.t("nextPostsPage"),children:(0,g.jsx)(ae.A,{icon:Se.A})}):(0,g.jsx)(ae.A,{icon:Se.A})]})]})}function Ce(){const{isTaskListHidden:e,isProductDiscoveryHidden:t,isUpsellHidden:a,canDisplayUpsell:i}=(0,C.A)(e=>({isTaskListHidden:e(ee).getIsTaskListHidden(),isProductDiscoveryHidden:e(ee).getIsProductDiscoveryHidden(),isUpsellHidden:e(ee).getIsUpsellHidden(),canDisplayUpsell:e(ee).getCanDisplayUpsell()}),[]),{hideTaskList:s}=(0,fe.A)(ee),{hideProductDiscovery:n}=(0,fe.A)(ee),{hideUpsell:r}=(0,fe.A)(ee);return(0,g.jsxs)("div",{className:"mailpoet-homepage__container",children:[!e&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(re,{onHide:s})}),!t&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(de,{onHide:n})}),e&&t&&i&&!a&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(_e,{closable:!0,onHide:r})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(we,{})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Ne,{})})]})}function Ee(){const[e,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{(()=>{const e=(0,I.A)(ee,{actions:i,controls:te,selectors:s,reducer:X,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,A.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)(N,{}),e?(0,g.jsx)(Ce,{}):null]})}const Ue=document.getElementById("mailpoet_homepage_container");Ue&&((0,o.registerTranslations)(),(0,n.H)(Ue).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Ee,{})})));var Ie=a(34662),Ae=a(93062),Te=a(77779),Pe=a(54312),Re=a(93691),De=a(15172),Fe=a(14755),Oe=a(27314),Me=a(35635),Le=a(90708),$e=a(45372),Be=a(41636),We=a(51359),Ve=a(16037),qe=a(4686),He=a(97997);function ze({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,p.sprintf)((0,p._n)("%1$s / %2$s subscriber","%1$s / %2$s subscribers",e,"mailpoet"),e.toLocaleString(),t.toLocaleString()):(0,p.sprintf)((0,p._n)("%s subscriber","%s subscribers",e,"mailpoet"),e.toLocaleString())}),(0,g.jsx)(He.Tooltip,{tooltip:(0,p.__)("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 Ge=a(97041);function Ye({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,p.sprintf)((0,p._n)("Calculated %s min ago","Calculated %s mins ago",o,"mailpoet"),o.toLocaleString())}),(0,g.jsx)(Ge.$,{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,p.__)("Recalculate","mailpoet")}),i.length>0&&(0,g.jsx)(h.$,{type:"error",children:i.map(e=>(0,g.jsx)("p",{children:e},e))})]})}function Ke(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:"\n        #screen-meta-links { margin-bottom: -22px; }\n      "}})}function Qe(){const e=(0,Ae.zy)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ke,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(qe.z,{className:"mailpoet-subscribers-page-header",heading:(0,p.__)("Subscribers","mailpoet"),children:(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-actions",children:[(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-primary-actions",children:[(0,g.jsx)(Ie.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,p.__)("Add new subscriber","mailpoet")})}),(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-import","data-automation-id":"import-subscribers-button",children:(0,p.__)("Import","mailpoet")}),(0,g.jsx)("a",{id:"mailpoet_export_button",className:"page-title-action",href:"?page=mailpoet-export",children:(0,p.__)("Export","mailpoet")})]}),(0,g.jsxs)("span",{className:"mailpoet-subscribers-heading-management-actions",children:[(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-tags","data-automation-id":"manage-tags-button",children:(0,p.__)("Tags","mailpoet")}),(0,g.jsx)("a",{className:"page-title-action",href:"?page=mailpoet-custom-fields","data-automation-id":"manage-custom-fields-button",children:(0,p.__)("Custom fields","mailpoet")})]})]})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(ze,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Ye,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]})]})}const Je=m.U.trackingConfig.emailTrackingEnabled;function Ze(e){switch(e){case"subscribed":return(0,p.__)("Subscribed","mailpoet");case"unconfirmed":return(0,p.__)("Unconfirmed","mailpoet");case"unsubscribed":return(0,p.__)("Unsubscribed","mailpoet");case"inactive":return(0,p.__)("Inactive","mailpoet");case"bounced":return(0,p.__)("Bounced","mailpoet");default:return"Invalid"}}const Xe=new Map((window.mailpoet_segments??[]).map(e=>[String(e.id),e]));function et(e){return e?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(e),(0,g.jsx)("br",{}),m.U.Date.time(e)]}):null}function tt(e){const t=Je?[{id:"statistics",label:(0,p.__)("Score","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:t})=>(0,g.jsx)("div",{className:"mailpoet-listing-stats",children:(0,g.jsx)(Ie.Link,{to:`/stats/${String(t.id)}`,state:{backUrl:e()},children:(0,g.jsx)(ve,{id:Number(t.id),engagementScore:t.engagement_score,engagementScoreType:t.engagement_score_type})})})}]:[];return[{id:"email",label:(0,p.__)("Subscriber","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,render:({item:t})=>(0,g.jsxs)("div",{children:[(0,g.jsx)(Ie.Link,{className:"mailpoet-listing-title","data-automation-id":`listing_item_${t.id}`,to:`/edit/${t.id}`,state:{backUrl:e()},children:t.email}),(0,g.jsxs)("div",{className:"mailpoet-listing-subtitle",children:[t.first_name," ",t.last_name]})]})},{id:"status",label:(0,p.__)("Status","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)("span",{children:Ze(e.status)})},{id:"segments",label:(0,p.__)("Lists","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>{return(0,g.jsx)(o.SegmentTags,{segments:(t=e,t.subscriptions.reduce((e,t)=>{if("subscribed"!==t.status)return e;const a=Xe.get(String(t.segment_id));return a&&e.push(a),e},[])),dimension:"large"});var t}},{id:"tags",label:(0,p.__)("Tags","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)(o.SubscriberTags,{subscribers:e.tags,variant:"wordpress",isInverted:!0})},...t,{id:"last_subscribed_at",label:(0,p.__)("Subscribed on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)("span",{children:et(e.last_subscribed_at)})},{id:"created_at",label:(0,p.__)("Created on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)("span",{children:et(e.created_at)})}]}(0,$e.tN)(window.mailpoet_subscribers_api);const at=(0,$e.gU)("/mailpoet/v1/subscribers"),it=m.U.trackingConfig.emailTrackingEnabled,st=window.mailpoet_bulk_confirmation_resend_limit,nt="bulk-resend-confirmation-checkbox-input",rt=Number(window.mailpoet_listing_per_page),ot={type:"table",perPage:rt,page:1,sort:{field:"created_at",direction:"desc"},fields:["status","segments","tags",...it?["statistics"]:[],"last_subscribed_at","created_at"],titleField:"email",showTitle:!0};function lt(e){const t=new URLSearchParams(e);return Array.from(t.entries()).reduce((e,[t,a])=>a?{...e,[t]:a}:e,{})}function dt(e){try{return decodeURIComponent(e)}catch{return e}}function ct(){return window.location.hash.split("/").map(e=>(e.endsWith("]")?e.slice(0,-1):e).split("[")).reduce((e,[t,a])=>a?"group"===t&&["all","subscribed","unconfirmed","unsubscribed","inactive","bounced","trash"].includes(a)?{...e,group:a}:("page"===t||"paged"===t)&&Number(a)>0?{...e,page:Number(a)}:("per_page"===t||"limit"===t)&&Number(a)>0?{...e,perPage:Number(a)}:"sort_by"===t||"orderby"===t?{...e,orderby:a}:"sort_order"!==t&&"order"!==t||"asc"!==a&&"desc"!==a?"search"===t?{...e,search:dt(a)}:"filter"===t?{...e,filter:lt(a)}:e:{...e,order:a}:e,{})}function mt(e,t,a,i){return[["group",e],["filter",new URLSearchParams(a).toString()||void 0],["search",t.search?encodeURIComponent(t.search):void 0],["page",t.page&&1!==t.page?t.page:void 0],["limit",t.perPage&&t.perPage!==(i.perPage??rt)?t.perPage:void 0],["sort_by",t.sort?.field&&t.sort.field!==(i.sort?.field??"created_at")?t.sort.field:void 0],["sort_order",t.sort?.direction&&t.sort.direction!==(i.sort?.direction??"desc")?t.sort.direction:void 0]].reduce((e,[t,a])=>a?`${e}/${t}[${a}]`:e,"")||"/"}function ut(e){return 0===Number(e.wp_user_id)&&0===Number(e.is_woocommerce_user)}function pt(e){return e.toLocaleString()}const ht={moveToList:{kind:"segment",fieldId:"move_to_segment",endpoint:"segments",filter:e=>!(e.deleted_at||"default"!==e.type)},addToList:{kind:"segment",fieldId:"add_to_segment",endpoint:"segments",filter:e=>!(e.deleted_at||"default"!==e.type)},removeFromList:{kind:"segment",fieldId:"remove_from_segment",endpoint:"segments",filter:e=>"default"===e.type},addTag:{kind:"tag",fieldId:"add_tag",endpoint:"tags"},removeTag:{kind:"tag",fieldId:"remove_tag",endpoint:"tags"}};function gt(e){return{moveToList:(0,p.__)("Move to list...","mailpoet"),addToList:(0,p.__)("Add to list...","mailpoet"),removeFromList:(0,p.__)("Remove from list...","mailpoet"),addTag:(0,p.__)("Add tag...","mailpoet"),removeTag:(0,p.__)("Remove tag...","mailpoet"),unsubscribe:(0,p.__)("Unsubscribe","mailpoet"),resendConfirmationEmails:(0,p.__)("Resend confirmation emails","mailpoet")}[e]}function _t({submitModal:e,closeModal:t,count:a}){const[i,s]=(0,r.useState)(!1),[n,o]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{document.getElementById(nt)?.focus()},[]),(0,g.jsx)(Te.A,{title:(0,p.__)("Resend confirmation emails","mailpoet"),onRequestClose:t,children:(0,g.jsxs)(Pe.A,{spacing:3,children:[(0,g.jsx)(Re.A,{as:"p",children:(0,p.sprintf)((0,p.__)("You selected %1$s subscribers. MailPoet can resend confirmation emails to up to %2$s of them at a time.","mailpoet"),Number(a).toLocaleString(),st.toLocaleString())}),(0,g.jsx)(Re.A,{as:"p",children:(0,p.__)("Some subscribers may be skipped if they already received too many confirmation emails, got one recently, or were added too long ago.","mailpoet")}),(0,g.jsx)("div",{"data-automation-id":"bulk-resend-confirmation-checkbox",children:(0,g.jsx)(De.A,{id:nt,label:(0,p.__)("I confirm these subscribers asked to join my list.","mailpoet"),checked:i,disabled:n,onChange:e=>s(e)})}),(0,g.jsx)("div",{children:(0,g.jsx)(ge.Ay,{variant:"primary",onClick:()=>{i&&!n&&(o(!0),e())},disabled:!i||n,isBusy:n,"data-automation-id":"bulk-resend-confirmation-confirm",children:(0,p.__)("Resend emails","mailpoet")})})]})})}function ft({title:e,config:t,onApply:a,onClose:i}){const[s,n]=(0,r.useState)(0),l=(0,r.useMemo)(()=>({id:t.fieldId,name:t.fieldId,endpoint:t.endpoint,filter:t.filter,forceSelect2:!0}),[t]);return(0,g.jsxs)(We.a,{title:e,onRequestClose:i,isDismissible:!0,children:[(0,g.jsx)(Ve.L,{field:l,onValueChange:e=>{const t=Number(e.target.value);n(Number.isFinite(t)?t:0)}}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:()=>{s&&a(s)},dimension:"small",variant:"secondary",isDisabled:!s,children:(0,p.__)("Apply","mailpoet")})]})}function bt({filters:e,filter:t,group:a,onSelectFilter:i,onEmptyTrash:s}){const n=Object.keys(e).filter(t=>!(0===e[t].length||1===e[t].length&&!e[t][0].value));return(0,g.jsxs)("div",{className:"mailpoet-listing-filters",children:[n.map(a=>(0,g.jsx)(Be.Select,{isMinWidth:!0,dimension:"small",name:a,value:t[a]??"",automationId:`listing_filter_${a}`,onChange:e=>i(a,e.currentTarget.value),children:e[a].map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},`filter-option-${e.value}`))},`filter-${a}`)),"trash"===a&&(0,g.jsx)("span",{className:"mailpoet-listing-filters-empty-trash",children:(0,g.jsx)(o.Button,{variant:"secondary",onClick:s,automationId:"empty_trash",children:(0,p.__)("Empty Trash","mailpoet")})})]})}function xt({group:e,search:t,onWildcardSearch:a}){const i=t?.trim();if(!i||i.includes("*"))return(0,g.jsx)(g.Fragment,{children:(0,p.__)("No items found.","mailpoet")});const s=`*${i}`;return(0,g.jsx)(g.Fragment,{children:(0,Oe.A)((0,p.sprintf)((0,p.__)("No items found that begin with „%1$s“. Tip: use * to match anywhere, e.g. <link>%2$s</link>.","mailpoet"),i,s),{link:(0,g.jsx)("a",{href:`#/group[${e}]/search[${encodeURIComponent(s)}]`,onClick:e=>{e.preventDefault(),a(s)},children:s})})})}function vt({group:e,search:t,onCheckTrash:a,onWildcardSearch:i}){return"bounced"!==e||window.mailpoet_premium_active||window.mailpoet_mss_active?"trash"!==e&&t?(0,g.jsxs)("p",{children:[(0,g.jsx)(xt,{group:e,search:t,onWildcardSearch:i}),(0,g.jsx)("br",{}),(0,g.jsx)("a",{href:`#/group[trash]/search[${encodeURIComponent(t)}]`,onClick:e=>{e.preventDefault(),a()},children:(0,p.__)("Have you checked the Trash?","mailpoet")})]}):(0,g.jsx)("div",{children:(0,g.jsx)(xt,{group:e,search:t,onWildcardSearch:i})}):(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{children:(0,p.__)("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,p.__)("Get premium version!","mailpoet")})})]})}function yt(){const e=(0,Ae.Zp)(),{notices:t}=(0,r.useContext)(l.F),a=ct(),[i,s]=(0,r.useState)(a.group??"all"),[n,d]=(0,r.useState)(a.filter??{}),[c,u]=(0,r.useState)([]),[h,_]=(0,r.useState)(null),f=(0,r.useRef)(null),b=(0,r.useRef)(!1),[x]=(0,r.useState)(()=>(0,$e.Aq)("subscribers",ot,tt(()=>""))),[y]=(0,r.useState)(()=>({...x,page:a.page??x.page,perPage:a.perPage??x.perPage,search:a.search,sort:{field:a.orderby??x.sort?.field??"created_at",direction:a.order??x.sort?.direction??"desc"}})),w=(0,r.useCallback)((e,t)=>function(e,t){return at(e,t)}({...e,group:i,filter:n},t),[n,i]),{view:j,setView:S,items:N,meta:C,filters:E,groups:U,isLoading:I,error:A,clearError:T,refresh:P}=(0,$e.i7)({initialView:y,load:w}),R=(0,r.useCallback)(()=>(0,$e.Aq)("subscribers",ot,tt(()=>"")),[]);(0,r.useEffect)(()=>{!function(e,t,a,i){const s=`#${mt(e,t,a,i)}`;window.location.hash!==s&&window.history.replaceState(null,"",s)}(i,j,n,R())},[n,i,j,R]),(0,r.useEffect)(()=>{const e=()=>{const e=ct();s(t=>e.group??t),d(e.filter??{}),u([]),T();const t=R();S(a=>({...a,page:e.page??1,perPage:e.perPage??t.perPage,search:e.search??"",sort:{field:e.orderby??t.sort?.field??"created_at",direction:e.order??t.sort?.direction??"desc"}}))};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[T,R,S]);const D=(0,r.useMemo)(()=>mt(i,j,n,R()),[n,i,j,R]),F=(0,r.useRef)(D);F.current=D;const O=(0,r.useCallback)(()=>F.current,[]),M=(0,r.useMemo)(()=>{const e={all:null,subscribed:null,unconfirmed:null,unsubscribed:null,inactive:null,bounced:null,trash:null};return(U??[]).forEach(t=>{t.name in e&&(e[t.name]=t.count)}),e},[U]);(0,r.useEffect)(()=>{"trash"!==i||I||A||0!==M.trash||j.search||0!==Object.keys(n).length||(s("all"),u([]),S(e=>({...e,page:1})))},[n,i,M.trash,I,A,S,j.search]);const L=(0,r.useCallback)(()=>{const e=f.current;f.current=null,e&&document.contains(e)&&e.focus()},[]),$=(0,r.useCallback)(()=>{_(null),window.setTimeout(L)},[L]),B=(0,r.useCallback)((e,t)=>{f.current=document.activeElement,_({action:e,targets:t})},[]),W=(0,r.useCallback)(e=>{u([]),S(e)},[S]),V=(0,$e.wh)("subscribers",j,W),q=(0,r.useCallback)((e,a)=>{if("resendConfirmationEmails"===a&&"mailpoet_subscribers_confirmation_disabled"===e.code)return void t.error((0,g.jsx)("p",{children:(0,Oe.A)((0,p.__)("Sign-up confirmation is disabled in your <link>MailPoet settings</link>. Please enable it to resend confirmation emails or update your subscriber’s status manually.","mailpoet"),{link:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-settings#/signup",children:" "})})}),{scroll:!0});const i=e.message||(0,p.__)("The bulk action could not be completed. Please try again.","mailpoet");t.error((0,g.jsx)("p",{children:i}),{scroll:!0})},[t]),H=(0,r.useCallback)(async(e,t,a)=>{try{const i=await function(e,t,a={}){return(0,$e.J8)("/mailpoet/v1/subscribers/bulk-action",{action:e,selection:t.selection,group:t.group,search:t.search,filter:t.filter,...a})}(e,t,a),s=i.data;u([]),"resendConfirmationEmails"===e?function(e){const t=e.queue;if(!t)return void m.U.Notice.success((0,p.__)("Confirmation emails are being resent.","mailpoet"));const a=Number(t.queued_count),i=Number(t.skipped_count);if(0===a)return void m.U.Notice.success((0,p.__)("No confirmation emails were resent. The selected subscribers could not receive another confirmation email right now.","mailpoet"));const s=[String((0,p.sprintf)((0,p._n)("MailPoet is resending confirmation emails to %d subscriber.","MailPoet is resending confirmation emails to %d subscribers.",a,"mailpoet"),a))];i>0&&s.push(String((0,p.sprintf)((0,p._n)("%d selected subscriber was skipped.","%d selected subscribers were skipped.",i,"mailpoet"),i))),m.U.Notice.success(s.join(" "),{onOpen:e=>{e.attr("role","status"),e.attr("aria-live","polite")}})}(s):function(e,t){const a=Number(t.count??0),i=(0,Me.Zn)(t.segment?.name??""),s=(0,Me.Zn)(t.tag?.name??"");"trash"===e?m.U.Notice.success(1===a?(0,p.__)("1 subscriber was moved to the trash.","mailpoet"):(0,p.__)("%1$d subscribers were moved to the trash.","mailpoet").replace("%1$d",pt(a))):"delete"===e?m.U.Notice.success(1===a?(0,p.__)("1 subscriber was permanently deleted.","mailpoet"):(0,p.__)("%1$d subscribers were permanently deleted.","mailpoet").replace("%1$d",pt(a))):"restore"===e?m.U.Notice.success(1===a?(0,p.__)("1 subscriber has been restored from the trash.","mailpoet"):(0,p.__)("%1$d subscribers have been restored from the trash.","mailpoet").replace("%1$d",pt(a))):"moveToList"===e?m.U.Notice.success((0,p.__)("%1$d subscribers were moved to list <strong>%2$s</strong>.","mailpoet").replace("%1$d",pt(a)).replace("%2$s",i)):"addToList"===e?m.U.Notice.success((0,p.__)("%1$d subscribers were added to list <strong>%2$s</strong>.","mailpoet").replace("%1$d",pt(a)).replace("%2$s",i)):"removeFromList"===e?m.U.Notice.success((0,p.__)("%1$d subscribers were removed from list <strong>%2$s</strong>.","mailpoet").replace("%1$d",pt(a)).replace("%2$s",i)):"removeFromAllLists"===e?m.U.Notice.success((0,p.__)("%1$d subscribers were removed from all lists.","mailpoet").replace("%1$d",pt(a))):"unsubscribe"===e?m.U.Notice.success(1===a?(0,p.__)("1 subscriber was unsubscribed from all lists.","mailpoet"):(0,p.__)("%1$d subscribers were unsubscribed from all lists.","mailpoet").replace("%1$d",pt(a))):"addTag"===e?m.U.Notice.success((0,p.__)("Tag <strong>%1$s</strong> was added to %2$d subscribers.","mailpoet").replace("%1$s",s).replace("%2$d",pt(a))):"removeTag"===e&&m.U.Notice.success((0,p.__)("Tag <strong>%1$s</strong> was removed from %2$d subscribers.","mailpoet").replace("%1$s",s).replace("%2$d",pt(a)))}(e,s),P()}catch(t){q(t,e)}},[q,P]),z=(0,r.useCallback)(async(e,t,a={})=>{if(0===t.length)return;const s=t.map(e=>Number(e.id));await H(e,{group:i,filter:n,search:j.search||"",selection:s},a)},[n,i,H,j.search]),G=(0,r.useCallback)(async()=>{"trash"===i&&await H("delete",{group:"trash",filter:n,search:j.search||"",selection:[]},{})},[n,i,H,j.search]),Y=(0,r.useCallback)(async(e={})=>{if(!h||b.current)return;b.current=!0;const{action:t,targets:a}=h;try{await z(t,a,e)}finally{b.current=!1,_(null),window.setTimeout(L)}},[z,h,L]),K=(0,r.useCallback)(async e=>{try{await async function(e){await(0,$e.J8)((e=>`/mailpoet/v1/subscribers/${e}/resend-confirmation-email`)(e),{})}(Number(e.id)),m.U.Notice.success((0,p.__)("1 confirmation email has been sent.","mailpoet"))}catch(e){q(e,"resendConfirmationEmails")}},[q]),Q=(0,r.useMemo)(()=>[{id:"statistics",label:(0,p.__)("Statistics","mailpoet"),context:"single",supportsBulk:!1,isEligible:()=>"trash"!==i,callback:t=>{const a=t[0];a&&e(`/stats/${a.id}`,{state:{backUrl:O()}})}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,isEligible:()=>"trash"!==i,callback:t=>{const a=t[0];a&&e(`/edit/${a.id}`,{state:{backUrl:O()}})}},{id:"sendConfirmationEmail",label:(0,p.__)("Resend confirmation email","mailpoet"),context:"single",supportsBulk:!1,isEligible:e=>"trash"!==i&&"unconfirmed"===e.status&&window.mailpoet_signup_confirmation_enabled,callback:e=>{e[0]&&K(e[0])}},{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>{z("trash",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:()=>"trash"===i,callback:e=>{z("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>"trash"===i&&ut(e),callback:e=>{z("delete",e.filter(ut))}},{id:"moveToList",label:(0,p.__)("Move to list...","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>B("moveToList",e)},{id:"addToList",label:(0,p.__)("Add to list...","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>B("addToList",e)},{id:"removeFromList",label:(0,p.__)("Remove from list...","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>B("removeFromList",e)},{id:"removeFromAllLists",label:(0,p.__)("Remove from all lists","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>{z("removeFromAllLists",e)}},{id:"unsubscribe",label:(0,p.__)("Unsubscribe","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i&&"unsubscribed"!==i,callback:e=>B("unsubscribe",e)},{id:"resendConfirmationEmails",label:(0,p.__)("Resend confirmation emails","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"unconfirmed"===i&&window.mailpoet_signup_confirmation_enabled,callback:e=>B("resendConfirmationEmails",e)},{id:"addTag",label:(0,p.__)("Add tag...","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>B("addTag",e)},{id:"removeTag",label:(0,p.__)("Remove tag...","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==i,callback:e=>B("removeTag",e)}],[O,i,z,K,e,B]),J=(0,r.useMemo)(()=>(U??[]).filter(e=>!("trash"===e.name&&0===e.count&&"trash"!==i)).filter(e=>e.name in M),[i,M,U]),Z=(0,r.useMemo)(()=>tt(O),[O]),X=(0,r.useMemo)(()=>({totalItems:C.count,totalPages:C.pages}),[C]);return(0,g.jsxs)("div",{children:[(0,g.jsx)(Qe,{}),(0,g.jsx)(k.D,{}),A&&(0,g.jsx)(Fe.A,{status:"error",onRemove:T,children:"Failed to load data."===A?(0,p.__)("Failed to load subscribers.","mailpoet"):A}),(0,g.jsx)("div",{className:"mailpoet-categories mailpoet-dataviews__tabs mailpoet-subscribers-dataviews__tabs",children:(0,g.jsx)("div",{className:"components-tab-panel__tabs",role:"tablist",children:J.map(e=>{const t=v()("components-button","components-tab-panel__tabs-item",`mailpoet-dataviews-group-${e.name}`,{"is-active":e.name===i});return(0,g.jsxs)("a",{href:"#",className:t,"data-automation-id":`filters_${e.name}`,onClick:t=>{var a;t.preventDefault(),(a=e.name)!==i&&(s(a),u([]),T(),S(e=>({...e,page:1})))},children:[(0,g.jsx)("span",{"data-title":e.label,children:e.label}),Number(e.count)>0&&(0,g.jsx)("span",{className:"count",children:Number(e.count).toLocaleString()})]},e.name)})})}),(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-subscribers-dataviews","data-automation-id":"subscribers_listing",children:(0,g.jsxs)(Le.A,{data:N,fields:Z,view:j,onChangeView:V,actions:Q,paginationInfo:X,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:c,onChangeSelection:u,isLoading:I,empty:(0,g.jsx)(vt,{group:i,search:j.search,onCheckTrash:()=>{s("trash"),u([]),T(),S(e=>({...e,page:1}))},onWildcardSearch:e=>{u([]),T(),S(t=>({...t,search:e,page:1}))}}),children:[(0,g.jsxs)("div",{className:"mailpoet-dataviews__toolbar mailpoet-subscribers-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search","mailpoet")}),(0,g.jsx)(bt,{filters:E,filter:n,group:i,onSelectFilter:(e,t)=>{d(a=>{const i={...a};return t?i[e]=t:delete i[e],i}),u([]),S(e=>({...e,page:1}))},onEmptyTrash:()=>{G()}}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})}),(()=>{if(!h)return null;const{action:e,targets:t}=h;if("unsubscribe"===e)return(0,g.jsxs)(We.a,{title:(0,p.__)("Unsubscribe","mailpoet"),onRequestClose:$,isDismissible:!0,children:[(0,g.jsx)("p",{children:(0,p.__)("This action will unsubscribe %s subscribers from all lists. This action cannot be undone. Are you sure, you want to continue?","mailpoet").replace("%s",pt(t.length))}),(0,g.jsx)("span",{className:"mailpoet-gap-half"}),(0,g.jsx)(o.Button,{onClick:()=>Y(),dimension:"small",variant:"secondary",automationId:"bulk-unsubscribe-confirm",children:(0,p.__)("Apply","mailpoet")})]});if("resendConfirmationEmails"===e)return(0,g.jsx)(_t,{submitModal:()=>Y(),closeModal:$,count:t.length});const a=ht[e];return(0,g.jsx)(ft,{title:gt(e),config:a,onApply:e=>Y("segment"===a.kind?{segment_id:e}:{tag_id:e}),onClose:$})})()]})}yt.displayName="SubscriberList";var wt=a(36637),jt=a.n(wt),St=a(70390),kt=a.n(St),Nt=a(41669),Ct=a.n(Nt),Et=a(23108),Ut=a.n(Et),It=a(68354);class At 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)(It.p,{type:"text",disabled:o,className:l,size:"auto"!==this.props.field.size&&this.props.field.size>0?this.props.field.size:null,name:a,id:r,value:s,defaultValue:n,placeholder:this.props.field.placeholder,onChange:e,onBlur:t,customLabel:this.props.field.customLabel,tooltip:this.props.field.tooltip,...this.props.field.validation})}}At.propTypes={onValueChange:Ut().func,onBlurEvent:Ut().func,field:Ut().shape({name:Ut().string.isRequired,defaultValue:Ut().string,id:Ut().string,className:Ut().string,size:Ut().oneOfType([Ut().string,Ut().number]),disabled:Ut().oneOfType([Ut().bool,Ut().func]),placeholder:Ut().string,validation:Ut().shape({"data-parsley-required":Ut().bool,"data-parsley-required-message":Ut().string,"data-parsley-type":Ut().string,"data-parsley-errors-container":Ut().string,maxLength:Ut().number}),customLabel:Ut().string,tooltip:Ut().string}).isRequired,item:Ut().object.isRequired};var Tt=a(99808);function Pt(e){return(0,g.jsx)(Tt.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})}Pt.propTypes={item:Ut().object.isRequired,field:Ut().shape({name:Ut().string,placeholder:Ut().string,defaultValue:Ut().string,validation:Ut().shape({"data-parsley-required":Ut().bool,"data-parsley-required-message":Ut().string,"data-parsley-type":Ut().string,"data-parsley-errors-container":Ut().string,maxLength:Ut().number}),className:Ut().string,customLabel:Ut().string,tooltip:Ut().string}).isRequired,onValueChange:Ut().func.isRequired};var Rt=a(95338);class Dt extends r.Component{render(){if(void 0===this.props.field.values)return!1;const{automationId:e="",onValueChange:t=()=>{}}=this.props;let a,i=!1,s=!1,n=!1;void 0!==this.props.field.placeholder&&(s=(0,g.jsx)("option",{value:"",children:this.props.field.placeholder})),void 0!==this.props.field.filter&&(i=this.props.field.filter),Rt.default.isFunction(this.props.field.sortBy)&&(n=this.props.field.sortBy),a=n?Rt.default.map(Rt.default.sortBy(Rt.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)(Be.Select,{name:this.props.field.name,id:`field_${this.props.field.name}`,value:this.props.item[this.props.field.name]||"",onChange:t,automationId:e,...this.props.field.validation,children:[s,r]})}}Dt.propTypes={onValueChange:Ut().func,field:Ut().shape({name:Ut().string.isRequired,values:Ut().objectOf(Ut().string),placeholder:Ut().string,filter:Ut().func,sortBy:Ut().func,validation:Ut().shape({"data-parsley-required":Ut().bool,"data-parsley-required-message":Ut().string,"data-parsley-type":Ut().string,"data-parsley-errors-container":Ut().string,maxLength:Ut().number})}).isRequired,item:Ut().object.isRequired,automationId:Ut().string};var Ft=a(63146);class Ot 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)(Ft.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})}}Ot.propTypes={onValueChange:Ut().func,field:Ut().shape({name:Ut().string.isRequired,values:Ut().objectOf(Ut().string)}).isRequired,item:Ut().object.isRequired};var Mt=a(32882);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)(Mt.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 $t(e){const t=[];void 0!==e.placeholder&&t.push((0,g.jsx)("option",{value:"",children:e.placeholder},0));const a=jt()().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 Bt(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 Wt(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:Ut().func.isRequired,field:Ut().shape({name:Ut().string.isRequired,values:Ut().objectOf(Ut().string)}).isRequired,item:Ut().object.isRequired},$t.propTypes={name:Ut().string.isRequired,placeholder:Ut().string.isRequired,onValueChange:Ut().func.isRequired,year:Ut().oneOfType([Ut().string,Ut().number]).isRequired},Bt.propTypes={name:Ut().string.isRequired,placeholder:Ut().string.isRequired,onValueChange:Ut().func.isRequired,month:Ut().oneOfType([Ut().string,Ut().number]).isRequired,monthNames:Ut().arrayOf(Ut().string).isRequired},Wt.propTypes={name:Ut().string.isRequired,placeholder:Ut().string.isRequired,onValueChange:Ut().func.isRequired,day:Ut().oneOfType([Ut().string,Ut().number]).isRequired};class Vt 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=jt()(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)($t,{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)(Bt,{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)(Wt,{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})}}Vt.propTypes={item:Ut().object.isRequired,field:Ut().shape({name:Ut().string,day_placeholder:Ut().string,month_placeholder:Ut().string,year_placeholder:Ut().string,params:Ut().object}).isRequired,onValueChange:Ut().func.isRequired};var qt=a(94367),Ht=a(90574);function zt(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 Gt 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=Ct().merge(i,e.field.field)),i.type){case"text":t=(0,g.jsx)(At,{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)(Pt,{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)(Dt,{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)(Ot,{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)(Ve.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)(Vt,{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)(zt,{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:v()("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)(qt.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]})}}Gt.propTypes={onValueChange:Ut().func,field:Ut().shape({name:Ut().string.isRequired,values:Ut().objectOf(Ut().string),tip:Ut().oneOfType([Ut().array,Ut().string]),label:Ut().string,fields:Ut().arrayOf(Ut().object),description:Ut().string,onWrapperClick:Ut().func,disabled:Ut().oneOfType([Ut().func,Ut().bool])}).isRequired,item:Ut().object.isRequired},(0,o.registerTranslations)();class Yt extends r.Component{constructor(e){super(e),this.formRef=(0,r.createRef)(),this.state={loading:!1,errors:[],item:{}}}componentDidMount(){const{fields:e,params:t={}}=this.props;void 0!==t.id?this.loadItem(t.id):kt()(()=>{const t=Ct()(".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&&(kt()(()=>{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=v()("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)(Gt,{field:e,item:this.getValues(),onValueChange:t,automationId:e.automationId},`field-${e.name}`)});let u=!1;return u=e||(0,g.jsx)(o.Button,{type:"submit",isDisabled:this.state.loading,children:(0,p.__)("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:u})]})]}),(0,g.jsx)("div",{className:"mailpoet-form-content-around",children:c})]})}}function Kt(e){const t=(0,Ae.Zp)();return(0,g.jsx)(Yt,{...e,navigate:t})}Yt.propTypes={params:Ut().shape({id:Ut().string}),location:Ut().shape({pathname:Ut().string}),item:Ut().object,errors:Ut().arrayOf(Ut().object),endpoint:Ut().string,fields:Ut().arrayOf(Ut().object),messages:Ut().shape({onUpdate:Ut().func,onCreate:Ut().func}),loading:Ut().bool,children:Ut().array,id:Ut().string,automationId:Ut().string,beforeFormContent:Ut().func,afterFormContent:Ut().func,onItemLoad:Ut().func,isValid:Ut().func,onChange:Ut().func,onSubmit:Ut().func,onSuccess:Ut().func,navigate:Ut().func.isRequired};var Qt=a(12218);const Jt=[{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=""}Jt.push(t)});const Zt={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 Xt(e){if(Number(e.wp_user_id)>0)return(0,g.jsx)("p",{className:"description",children:b()(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 ea(e){return(0,g.jsxs)(g.Fragment,{children:[e?.unsubscribes?.map(e=>{const t=jt()(e.createdAt.date).format("dddd MMMM Do YYYY [at] h:mm:ss a");let a;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?b()(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);const i=e.reasonLabel?m.U.I18n.t(e.reasonText?"unsubscribeReasonWithDetails":"unsubscribeReason").replace("%1$s",e.reasonLabel).replace("%2$s",e.reasonText||""):null;return(0,g.jsxs)("div",{className:"description",children:[(0,g.jsx)("p",{children:a}),i&&(0,g.jsx)("p",{children:i})]},`${e.source}-${t}-${e.newsletterId||""}`)}),(0,g.jsxs)("p",{className:"description",children:[(0,g.jsx)("strong",{children:m.U.I18n.t("tip")})," ",m.U.I18n.t("customFieldsTip")]})]})}function ta(){const e=(0,Ae.zy)(),t=(0,Ae.g)(),a=(0,Ae.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)(qe.z,{heading:t.id?(0,p.__)("Edit subscriber","mailpoet"):(0,p.__)("Add new subscriber","mailpoet"),headingPrefix:(0,g.jsx)(qe.o,{onClick:()=>a(i),label:m.U.I18n.t("backToList")})}),(0,g.jsx)(Qt.X,{}),(0,g.jsx)(Kt,{automationId:"subscriber_edit_form",endpoint:"subscribers",fields:Jt,params:t,messages:Zt,beforeFormContent:Xt,afterFormContent:ea,onSuccess:()=>a(i)})]})}ta.displayName="SubscriberForm";var aa=a(8720),ia=a(37059),sa=a(64929),na=a(1452);function ra({email:e,avatarUrl:t,subscribedAt:a,sourceLabel:i}){const s=(0,Ae.zy)(),n=(0,Ae.Zp)(),r=s.state?.backUrl||"/",o=function(e,t){if(!e)return null;const a=m.U.Date.short(e);return t?(0,p.sprintf)((0,p.__)("Subscribed on %1$s / via %2$s","mailpoet"),a,t):(0,p.sprintf)((0,p.__)("Subscribed on %s","mailpoet"),a)}(a,i);return(0,g.jsxs)(ia.A,{className:"mailpoet-subscriber-stats-heading",align:"center",gap:4,children:[(0,g.jsx)(sa.A,{children:(0,g.jsx)(qe.o,{onClick:()=>n(r),label:m.U.I18n.t("backToList")})}),t?(0,g.jsx)(sa.A,{children:(0,g.jsx)("img",{className:"mailpoet-subscriber-stats-heading-avatar",src:t,alt:"",width:48,height:48})}):null,(0,g.jsxs)(na.A,{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-heading-email",children:e}),o?(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-heading-subtitle",children:o}):null]})]})}ra.displayName="StatsHeading";var oa=a(16325),la=a(36370);function da({stats:e}){const t=e.woocommerce_overview;if(!t)return null;const a=[{label:(0,p.__)("Orders placed","mailpoet"),value:(0,g.jsx)("a",{href:t.orders_url,children:t.orders_count.toLocaleString()})},{label:(0,p.__)("Lifetime value","mailpoet"),value:t.total_revenue_formatted},{label:(0,p.__)("Average order value","mailpoet"),value:t.average_order_value_formatted}];return(0,g.jsx)(ia.A,{className:"mailpoet-subscriber-stats-woocommerce-overview",align:"stretch",gap:4,children:a.map(e=>(0,g.jsx)(na.A,{children:(0,g.jsx)(oa.A,{size:"medium",children:(0,g.jsxs)(la.A,{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-woocommerce-overview-label",children:e.label}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-woocommerce-overview-value",children:e.value})]})})},e.label))})}da.displayName="WoocommerceOverview";var ca=a(58642),ma=a(58319),ua=a(40729),pa=a(55855);const ha=[{label:(0,p.__)("7 days","mailpoet"),value:"7_days"},{label:(0,p.__)("30 days","mailpoet"),value:"30_days"},{label:(0,p.__)("3 months","mailpoet"),value:"3_months"},{label:(0,p.__)("12 months","mailpoet"),value:"12_months"}];function ga(e,t){return e.find(e=>e.key===t)}function _a(e){return Intl.NumberFormat(void 0,{maximumFractionDigits:1,notation:"compact"}).format(e)}function fa({stats:e,type:t}){if("sent"===t)return(0,g.jsx)(g.Fragment,{children:_a(e.total_sent)});const a=function(e,t){return t<=0?0:e/t*100}("opened"===t?e.open:e.click,e.total_sent),i=function(e){const t=Math.round(10*e)/10,a=Number.isInteger(t)?0:1;return`${t.toLocaleString(void 0,{minimumFractionDigits:a,maximumFractionDigits:1})}%`}(a);return"clicked"===t?(0,g.jsxs)("span",{className:"mailpoet-subscriber-stats-engagement-value-with-badge",children:[(0,g.jsx)(pa.f,{stat:"clicked",rate:a,tooltipId:`subscriber-stats-clicked-${e.key}`}),(0,g.jsx)("span",{children:i})]}):(0,g.jsx)(g.Fragment,{children:i})}function ba({stats:e}){const[t,a]=(0,r.useState)("30_days"),i=(0,r.useMemo)(()=>ga(e.periodic_stats,"lifetime"),[e.periodic_stats]),s=(0,r.useMemo)(()=>ga(e.periodic_stats,t)||ga(e.periodic_stats,"30_days")||e.periodic_stats[0],[t,e.periodic_stats]);if(!s||!i)return null;const n=xe(e.engagement_score,e.engagement_score_type),o=[{label:(0,p.__)("Emails sent","mailpoet"),type:"sent"},{label:(0,p.__)("Opened","mailpoet"),type:"opened"},{label:(0,p.__)("Clicked","mailpoet"),type:"clicked"}];return(0,g.jsxs)(oa.A,{className:"mailpoet-subscriber-stats-card",size:"medium",children:[(0,g.jsx)(ca.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(ia.A,{align:"center",gap:3,children:[(0,g.jsx)(na.A,{children:(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-card-title-row",children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Engagement","mailpoet")}),(0,g.jsx)(ua.vw,{className:"mailpoet-subscriber-stats-engagement-badge",variant:n,children:(l=n,{unknown:(0,p.__)("Unknown","mailpoet"),dormant:(0,p.__)("Dormant","mailpoet"),average:(0,p.__)("Average","mailpoet"),good:(0,p.__)("Good","mailpoet"),excellent:(0,p.__)("Excellent","mailpoet")}[l])})]})}),(0,g.jsx)(ma.A,{className:"mailpoet-subscriber-stats-period-control",hideLabelFromVision:!0,label:(0,p.__)("Engagement period","mailpoet"),onChange:e=>a(e),options:ha,value:t})]})}),(0,g.jsx)(la.A,{children:(0,g.jsxs)("table",{className:"mailpoet-subscriber-stats-engagement-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Engagement metric","mailpoet")})}),(0,g.jsx)("th",{children:s.timeframe}),(0,g.jsx)("th",{children:i.timeframe})]})}),(0,g.jsx)("tbody",{children:o.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{scope:"row",children:e.label}),(0,g.jsx)("td",{children:(0,g.jsx)(fa,{stats:s,type:e.type})}),(0,g.jsx)("td",{children:(0,g.jsx)(fa,{stats:i,type:e.type})})]},e.type))})]})})]});var l}function xa(){return(0,g.jsx)("span",{className:"mailpoet-subscriber-stats-empty-value",children:"-"})}function va({value:e}){return e?(0,g.jsx)(g.Fragment,{children:e}):(0,g.jsx)(xa,{})}function ya(e){switch(e){case"subscribed":return(0,p.__)("Subscribed","mailpoet");case"unconfirmed":return(0,p.__)("Unconfirmed","mailpoet");case"unsubscribed":return(0,p.__)("Unsubscribed","mailpoet");case"inactive":return(0,p.__)("Inactive","mailpoet");case"bounced":return(0,p.__)("Bounced","mailpoet");default:return e}}function wa({label:e,children:t}){return(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-profile-row",children:[(0,g.jsx)("dt",{children:e}),(0,g.jsx)("dd",{children:t})]})}function ja({profile:e,subscriberId:t}){const a=(0,Ae.zy)(),i=(0,Ae.Zp)();return(0,g.jsxs)(oa.A,{className:"mailpoet-subscriber-stats-card",size:"medium",children:[(0,g.jsx)(ca.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(ia.A,{align:"center",justify:"space-between",children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Profile information","mailpoet")}),(0,g.jsx)(ge.Ay,{variant:"secondary",onClick:()=>i(`/edit/${t}`,{state:{backUrl:a.pathname}}),children:(0,p.__)("Edit","mailpoet")})]})}),(0,g.jsx)(la.A,{children:(0,g.jsxs)("dl",{className:"mailpoet-subscriber-stats-profile-list",children:[(0,g.jsx)(wa,{label:(0,p.__)("Status","mailpoet"),children:(0,g.jsx)(va,{value:ya(e.status)})}),"unsubscribed"===e.status&&(0,g.jsx)(wa,{label:(0,p.__)("Unsubscribe reason","mailpoet"),children:(0,g.jsx)(va,{value:e.unsubscribe_reason??void 0})}),(0,g.jsx)(wa,{label:(0,p.__)("First name","mailpoet"),children:(0,g.jsx)(va,{value:e.first_name})}),(0,g.jsx)(wa,{label:(0,p.__)("Last name","mailpoet"),children:(0,g.jsx)(va,{value:e.last_name})}),(0,g.jsx)(wa,{label:(0,p.__)("Email address","mailpoet"),children:(0,g.jsx)(va,{value:e.email})}),e.shipping_address.length>0&&(0,g.jsx)(wa,{label:(0,p.__)("Shipping","mailpoet"),children:(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-shipping-address",children:e.shipping_address.join("\n")})}),e.custom_fields.map(e=>(0,g.jsx)(wa,{label:e.name,children:(0,g.jsx)(va,{value:e.value})},e.id)),(0,g.jsx)(wa,{label:(0,p.__)("Tags","mailpoet"),children:e.tags.length>0?(0,g.jsx)(o.SubscriberTags,{subscribers:e.tags,variant:"wordpress",isInverted:!0}):(0,g.jsx)(xa,{})}),(0,g.jsx)(wa,{label:(0,p.__)("Lists","mailpoet"),children:e.segments.length>0?(0,g.jsx)(o.SegmentTags,{segments:e.segments}):(0,g.jsx)(xa,{})})]})})]})}ba.displayName="EngagementCard",ja.displayName="ProfileInformation";var Sa=a(42176),ka=a(79616),Na=a(25557),Ca=a(48547),Ea=a(31e3),Ua=a(14206);const{subscribersLimitReached:Ia,subscribersLimit:Aa,subscribersCount:Ta,premiumActive:Pa,hasValidApiKey:Ra,hasValidPremiumKey:Da,isPremiumPluginInstalled:Fa,pluginPartialKey:Oa}=m.U,Ma=Ra||Da,La=e=>(0,g.jsx)("p",{children:b()(e,/(\[subscribersCount]|\[subscribersLimit])/g,e=>"[subscribersCount]"===e?Ta:Aa)}),$a=(e,t,a="_blank")=>(0,g.jsx)(Ge.$,{href:t,target:a,rel:"noopener noreferrer",children:e});function Ba({message:e,actionButton:t,capabilities:a={}}){let i,s,n=(0,p.__)("This is a Premium feature","mailpoet");if(!Da||Fa&&Pa)if(Ia){i=La((0,p.__)("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=Ma?m.U.MailPoetComUrlFactory.getUpgradeUrl(Oa):m.U.MailPoetComUrlFactory.getPurchasePlanUrl(+Ta+1,null,null,null);s=$a((0,p.__)("Upgrade your plan","mailpoet"),e)}else if(Ra&&!Da||Da&&Object.keys(a).some(e=>m.U.capabilities[e].isRestricted)){n=(0,p.__)("Upgrade your plan","mailpoet"),i=e;const t=m.U.MailPoetComUrlFactory.getUpgradeUrl(Oa,{s:Ta,capabilities:a});s=$a((0,p.__)("Upgrade","mailpoet"),t)}else i=e,s=t;else i=La((0,p.__)("Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.","mailpoet")),r=Fa?(0,p.__)("Activate MailPoet Premium plugin","mailpoet"):(0,p.__)("Download MailPoet Premium plugin","mailpoet"),s=(0,g.jsx)(Ua.Wr,{buttonText:r});var r;return(0,g.jsx)(Ea.P,{title:n,message:i,actionButton:s})}function Wa(e,t=0){const a=new Date;return a.setDate(a.getDate()-e),a.setHours(Math.max(0,a.getHours()-t)),a}function Va(e){return m.U.Date.format(e,{format:"Y-m-d"})}function qa(e){const t=new Date,a=new Date;a.setDate(t.getDate()-1);const i=Va(e);return i===Va(t)?(0,p.__)("Today","mailpoet"):i===Va(a)?(0,p.__)("Yesterday","mailpoet"):m.U.Date.short(e)}function Ha({item:e}){return(0,g.jsxs)("li",{className:"mailpoet-subscriber-stats-activity-item",children:[(0,g.jsx)("span",{className:"mailpoet-subscriber-stats-activity-icon","aria-hidden":"true",children:(0,g.jsx)(ae.A,{icon:e.icon})}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-content",children:(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-activity-item-main",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-title",children:e.title}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-activity-item-description",children:e.description})]}),(0,g.jsx)("time",{className:"mailpoet-subscriber-stats-activity-item-date",dateTime:e.date.toISOString(),children:m.U.Date.full(e.date)})]})})]})}function za({group:e}){return(0,g.jsxs)("li",{className:"mailpoet-subscriber-stats-activity-day",children:[(0,g.jsx)("h3",{className:"mailpoet-subscriber-stats-activity-day-title",children:e.label}),(0,g.jsx)("ul",{className:"mailpoet-subscriber-stats-activity-list",children:e.items.map(e=>(0,g.jsx)(Ha,{item:e},e.key))})]})}function Ga({eventType:e}){const t=[{key:"opened",eventType:"open",icon:ka.A,title:(0,p.__)("Opened email “Spring sale newsletter”","mailpoet"),description:(0,p.__)("Opened the email on desktop.","mailpoet"),date:Wa(0,2)},{key:"clicked",eventType:"click",icon:Na.A,title:(0,p.__)("Clicked a link in email “Spring sale newsletter”","mailpoet"),description:(0,p.__)("https://example.com/spring-collection","mailpoet"),date:Wa(0,3)},{key:"purchased",eventType:"purchase",icon:Ca.A,title:(0,p.__)("Completed purchase","mailpoet"),description:(0,p.__)("Revenue tracked from an email click.","mailpoet"),date:Wa(1)},{key:"unsubscribed",eventType:"unsubscribe",icon:ce.A,title:(0,p.__)("Unsubscribed","mailpoet"),description:(0,p.__)("Reason: No reason provided","mailpoet"),date:Wa(1,2)}].filter(t=>"all"===e||t.eventType===e).sort((e,t)=>t.date.getTime()-e.date.getTime()).reduce((e,t)=>{const a=Va(t.date),i=e.find(e=>e.key===a);return i?(i.items.push(t),e):(e.push({key:a,label:qa(t.date),items:[t]}),e)},[]);return(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-locked-activity","data-automation-id":"subscriber-stats-no-access",children:[(0,g.jsx)("ul",{className:"mailpoet-subscriber-stats-activity-days mailpoet-subscriber-stats-activity-list-sample","aria-label":(0,p.__)("Sample subscriber activity","mailpoet"),children:t.map(e=>(0,g.jsx)(za,{group:e},e.key))}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-no-access-content",children:(0,g.jsx)(Ba,{message:(()=>{const e=(0,p.__)("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:b()(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)(Ge.$,{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,p.__)("Upgrade","mailpoet")}),capabilities:{detailedAnalytics:!0}})})]})}function Ya({eventType:e,params:t,location:a}){const i=(0,r.useMemo)(()=>Sa.Hooks.applyFilters("mailpoet_subscribers_opened_emails_stats",()=>(0,g.jsx)(Ga,{eventType:e}),t,a,e),[e,a,t]);return(0,g.jsx)(i,{})}const Ka=[{label:(0,p.__)("All events","mailpoet"),value:"all"},{label:(0,p.__)("Email opens","mailpoet"),value:"open"},{label:(0,p.__)("Link clicks","mailpoet"),value:"click"},{label:(0,p.__)("Purchases","mailpoet"),value:"purchase"},{label:(0,p.__)("Unsubscribes","mailpoet"),value:"unsubscribe"}];function Qa({lastEngagementAt:e,location:t,params:a}){const[i,s]=(0,r.useState)("all"),n=e?(0,p.sprintf)((0,p.__)("Last seen on %s","mailpoet"),m.U.Date.full(e)):(0,p.__)("Last seen: never","mailpoet");return(0,g.jsxs)(oa.A,{className:"mailpoet-subscriber-stats-card mailpoet-subscriber-stats-activity",size:"medium",children:[(0,g.jsx)(ca.A,{className:"mailpoet-subscriber-stats-card-header",children:(0,g.jsxs)(ia.A,{align:"center",gap:3,children:[(0,g.jsx)(na.A,{children:(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mailpoet-subscriber-stats-card-title",children:(0,p.__)("Activity","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-subscriber-stats-card-subtitle",children:n})]})}),(0,g.jsx)(ma.A,{className:"mailpoet-subscriber-stats-activity-filter",hideLabelFromVision:!0,label:(0,p.__)("Activity event type","mailpoet"),onChange:e=>s(e),options:Ka,value:i})]})}),(0,g.jsx)(la.A,{className:"mailpoet-subscriber-stats-activity-body",children:(0,g.jsx)(Ya,{eventType:i,params:a,location:t})})]})}function Ja(){const e=(0,Ae.g)(),t=(0,Ae.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)(aa.R,{}):a?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats",children:[(0,g.jsx)(ra,{email:a.email,avatarUrl:a.avatar_url,subscribedAt:a.subscribed_at,sourceLabel:a.source_label}),a.is_woo_active&&a.is_woocommerce_user&&(0,g.jsx)(da,{stats:a}),(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-content",children:[(0,g.jsxs)("div",{className:"mailpoet-subscriber-stats-primary-column",children:[(0,g.jsx)(ba,{stats:a}),(0,g.jsx)(ja,{profile:a.profile,subscriberId:Number(e.id)})]}),(0,g.jsx)(Qa,{lastEngagementAt:a.last_engagement,params:e,location:t})]})]})]}):null}function Za(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ie.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"/new",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ta,{})})}),(0,g.jsx)(Ae.qh,{path:"/edit/:id",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ta,{})})}),(0,g.jsx)(Ae.qh,{path:"/stats/:id/*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Ja,{})})}),(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(yt,{})})})]})]})})}Qa.displayName="ActivityShell",Ja.displayName="SubscriberStats";const Xa=document.getElementById("subscribers_container");Xa&&((0,o.registerTranslations)(),(0,n.H)(Xa).render((0,g.jsx)(Za,{})));var ei=a(95776),ti=a(66177),ai=a(5296),ii=a(75847),si=a(45919);function ni({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,p.__)("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)(Te.A,{title:(0,p.__)("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,p.__)("Alpha version","mailpoet")}),(0,g.jsx)("img",{src:`${m.U.cdnUrl}email-editor/new-editor-modal-header.png`,alt:(0,p.__)("Try the new email editor","mailpoet"),width:"324",height:"130"})]}),(0,g.jsx)("p",{children:(0,p.__)("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,p.__)("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)(ge.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,p.__)("Cancel","mailpoet")}),(0,g.jsx)(ge.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,p.__)("Try it now","mailpoet")})]})]})):null}var ri=a(5863);function oi({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 li=a(43987),di=a(60713);const ci=li.Ay;function mi({children:e}){return(0,g.jsx)(ci,{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)(ii.A,{icon:di.A,size:20})})})}const ui=ei.A;function pi({filter:e=null,hideScreenOptions:t=!0}){const a=(0,Ae.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=Rt.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,p.__)("Subject","mailpoet")}}).done(e=>{a(`/template/${e.data.id}`)}).fail(e=>(s(null),e.errors.length>0?(0,g.jsx)(oi,{errors:e.errors}):null))},"standard"),u=Rt.default.partial(d,"notification"),h=Rt.default.partial(d,"re-engagement"),_=l?(0,g.jsxs)(ti.A,{className:"mailpoet-dropdown-button-group",children:[(0,g.jsx)(ge.Ay,{variant:"secondary",onClick:c,isBusy:"standard"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Newsletter","mailpoet"),"data-automation-id":"create_standard",children:(0,p.__)("Create","mailpoet")}),(0,g.jsx)(ai.A,{className:"mailpoet-dropdown-button",contentClassName:"mailpoet-dropdown-button-content",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,g.jsx)(ge.Ay,{variant:"secondary",className:"mailpoet-button-with-wordpress-icon",onClick:t,isBusy:"standard"===i,disabled:null!==i,"aria-expanded":e,"aria-label":(0,p.__)("Choose editor version","mailpoet"),"data-automation-id":"create_standard_email_dropdown",children:(0,g.jsx)(ii.A,{icon:si.A,size:24})}),onToggle:e=>e&&m.U.trackEvent("New Email Editor > create email icon clicked"),renderContent:()=>(0,g.jsx)(ui,{variant:"tertiary",onClick:()=>{o(!0),m.U.trackEvent("New Email Editor > creating using new email editor button clicked")},children:(0,p.__)("Create using the new email editor (Alpha)","mailpoet")})})]}):(0,g.jsx)(ge.Ay,{variant:"secondary",onClick:c,isBusy:i,"data-automation-id":"create_standard",children:(0,p.__)("Create","mailpoet")}),f=[{slug:"standard",title:(0,p.__)("Newsletter","mailpoet"),description:(0,p.__)("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,p.__)("Automations","mailpoet")," ",(0,g.jsx)(mi,{children:(0,p.__)("Automations such as Welcome emails and WooCommerce emails can be found here, alongside more automation templates powered by our new editor.","mailpoet")})]}),description:(0,p.__)("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)(ge.Ay,{variant:"secondary",onClick:()=>{s("automation"),window.location.href="admin.php?page=mailpoet-automation-templates"},isBusy:"automation"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Automation","mailpoet"),"data-automation-id":"create_automation",children:(0,p.__)("Create","mailpoet")})},{slug:"notification",title:(0,p.__)("Latest Post Notifications","mailpoet"),description:(0,p.__)("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)(ge.Ay,{variant:"secondary",onClick:u,isBusy:"notification"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Latest Post Notification","mailpoet"),"data-automation-id":"create_notification",children:(0,p.__)("Create","mailpoet")})},{slug:"re_engagement",title:(0,p.__)("Re-engagement Emails","mailpoet"),description:(0,p.__)("Automatically email and win back subscribers who have recently lost interest and stopped engaging with your emails.","mailpoet"),action:(0,g.jsx)(ge.Ay,{variant:"secondary",onClick:h,isBusy:"re_engagement"===i,disabled:null!==i,"aria-label":(0,p.__)("Create Re-engagement Email","mailpoet"),"data-automation-id":"create_re_engagement",children:(0,p.__)("Create","mailpoet")})}];let b=Sa.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)(ri.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)(qt.D,{level:4,children:[e.title," ",e.beta?`(${(0,p.__)("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)(ni,{onClose:()=>o(!1),isModalOpen:n})]})}var hi=a(7352),gi=a(74733);function _i(e){const t=(0,Ae.zy)();return(0,g.jsx)(gi.Y,{...e,location:t})}var fi=a(25249),bi=a(61349);class xi 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,bi.Z)({message:(0,p.__)('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,p.__)("Template preview","mailpoet"),loading:"lazy"}):""}),(0,g.jsx)("div",{className:"mailpoet-template-preview-overlay",children:(0,g.jsx)(Ge.$,{children:(0,p.__)("Preview","mailpoet")})})]})),(0,g.jsx)(fi.c,{label:t,onSelect:this.onSelect,onDelete:!1===a?this.onDelete:void 0,automationId:`select_template_${e}`,className:"mailpoet-template-two-lines",children:s})}}xi.contextType=l.F,xi.propTypes={index:Ut().number.isRequired,id:Ut().number.isRequired,newsletterId:Ut().string.isRequired,name:Ut().string.isRequired,thumbnail:Ut().string,readonly:Ut().bool.isRequired,beforeDelete:Ut().func.isRequired,afterDelete:Ut().func.isRequired,beforeSelect:Ut().func.isRequired,afterSelect:Ut().func.isRequired},xi.displayName="TemplateBox";class vi extends r.Component{constructor(e){super(e),this.fileRef=(0,r.createRef)(),this.handleSubmit=this.handleSubmit.bind(this)}handleSubmit(e){if(e.preventDefault(),Rt.default.size(this.fileRef.current.files)<=0)return!1;const t=Rt.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,p.__)("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;Rt.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,p.__)("Import a template","mailpoet"),(0,g.jsx)(He.Tooltip,{tooltip:(0,p.__)("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,p.__)("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,p.__)("Upload","mailpoet")})})]})]})}}vi.contextType=l.F,vi.propTypes={beforeImport:Ut().func.isRequired,afterImport:Ut().func.isRequired};var yi=a(1672);const wi=[];window.mailpoet_newsletters_templates_recently_sent_count&&wi.push({name:"recent",label:(0,p.__)("Recently sent","mailpoet")}),wi.push({name:"standard",label:(0,p.__)("Newsletters","mailpoet")},{name:"welcome",label:(0,p.__)("Welcome Emails","mailpoet")},{name:"notification",label:(0,p.__)("Post Notifications","mailpoet")},{name:"re_engagement",label:(0,p.__)("Re-engagement Emails","mailpoet")},{name:"blank",label:(0,p.__)("Simple text","mailpoet")}),window.mailpoet_woocommerce_active&&wi.push({name:"woocommerce",label:(0,p.__)("WooCommerce Emails","mailpoet")}),wi.push({name:"saved",label:(0,p.__)("Your saved templates","mailpoet")});class ji 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,p.__)("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=wi.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":Rt.default.findWhere(wi,{name:i.data.type})?a=i.data.type:"automatic"===i.data.type&&Rt.default.findWhere(wi,{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)(aa.R,{});const e=wi.concat({name:"import",label:(0,p._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)(vi,{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,p.__)("This category does not contain any template yet!","mailpoet")}):e.map((e,t)=>(0,g.jsx)(xi,{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(yi.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)(_i,{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)(hi.L,{categories:e,active:this.state.selectedTab,onSelect:e=>this.setState({selectedTab:e})})}),(0,g.jsx)(o.ErrorBoundary,{children:t})]})]})}}ji.contextType=l.F,ji.propTypes={params:Ut().shape({id:Ut().string}).isRequired};var Si=a(35558),ki=a.n(Si),Ni=a(29065),Ci=a.n(Ni),Ei=a(69308),Ui=a(76056);const Ii={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Ai(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const Ti={date:Ai({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ai({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Ai({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Pi={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Ri(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]}}function Di(e){return(t,a={})=>{const i=a.width,s=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],n=t.match(s);if(!n)return null;const r=n[0],o=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a}(o,e=>e.test(r)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a}(o,e=>e.test(r));let d;return d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d,{value:d,rest:t.slice(r.length)}}}var Fi;const Oi={code:"en-US",formatDistance:(e,t,a)=>{let i;const s=Ii[e];return i="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+i:i+" ago":i},formatLong:Ti,formatRelative:(e,t,a,i)=>Pi[e],localize:{ordinalNumber:(e,t)=>{const a=Number(e),i=a%100;if(i>20||i<10)switch(i%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Ri({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Ri({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ri({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Ri({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Ri({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(Fi={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const a=e.match(Fi.matchPattern);if(!a)return null;const i=a[0],s=e.match(Fi.parsePattern);if(!s)return null;let n=Fi.valueCallback?Fi.valueCallback(s[0]):s[0];return n=t.valueCallback?t.valueCallback(n):n,{value:n,rest:e.slice(i.length)}}),era:Di({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Di({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:Di({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Di({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Di({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Mi=Oi;var Li=a(78169);function $i(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 Bi={abbreviated:[(0,p.__)("Jan","mailpoet"),(0,p.__)("Feb","mailpoet"),(0,p.__)("Mar","mailpoet"),(0,p.__)("Apr","mailpoet"),(0,p.__)("May","mailpoet"),(0,p.__)("Jun","mailpoet"),(0,p.__)("Jul","mailpoet"),(0,p.__)("Aug","mailpoet"),(0,p.__)("Sep","mailpoet"),(0,p.__)("Oct","mailpoet"),(0,p.__)("Nov","mailpoet"),(0,p.__)("Dec","mailpoet")],wide:[(0,p.__)("January","mailpoet"),(0,p.__)("February","mailpoet"),(0,p.__)("March","mailpoet"),(0,p.__)("April","mailpoet"),(0,p.__)("May","mailpoet"),(0,p.__)("June","mailpoet"),(0,p.__)("July","mailpoet"),(0,p.__)("August","mailpoet"),(0,p.__)("September","mailpoet"),(0,p.__)("October","mailpoet"),(0,p.__)("November","mailpoet"),(0,p.__)("December","mailpoet")]},Wi={narrow:[(0,p._x)("S","Sunday - one letter abbreviation","mailpoet"),(0,p._x)("M","Monday - one letter abbreviation","mailpoet"),(0,p._x)("T","Tuesday - one letter abbreviation","mailpoet"),(0,p._x)("W","Wednesday - one letter abbreviation","mailpoet"),(0,p._x)("T","Thursday - one letter abbreviation","mailpoet"),(0,p._x)("F","Friday - one letter abbreviation","mailpoet"),(0,p._x)("S","Saturday - one letter abbreviation","mailpoet")],abbreviated:[(0,p.__)("Sun","mailpoet"),(0,p.__)("Mon","mailpoet"),(0,p.__)("Tue","mailpoet"),(0,p.__)("Wed","mailpoet"),(0,p.__)("Thu","mailpoet"),(0,p.__)("Fri","mailpoet"),(0,p.__)("Sat","mailpoet")],wide:[(0,p.__)("Sunday","mailpoet"),(0,p.__)("Monday","mailpoet"),(0,p.__)("Tuesday","mailpoet"),(0,p.__)("Wednesday","mailpoet"),(0,p.__)("Thursday","mailpoet"),(0,p.__)("Friday","mailpoet"),(0,p.__)("Saturday","mailpoet")]};Mi.localize.month=$i({values:Bi,defaultWidth:"wide"}),Mi.localize.day=$i({values:Wi,defaultWidth:"wide"}),Mi.options.weekStartsOn=void 0!==m.U.wpWeekStartsOn?m.U.wpWeekStartsOn:1,(0,Ui.registerLocale)("mailpoet",Mi);class Vi 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=>jt()(e).toDate();getAsStringInFormat=e=>jt()(e).format(m.U.Date.convertFormat(this.props.storageFormat));render(){return(0,g.jsx)(Li.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 qi 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)(Be.Select,{name:s||"time",value:a,disabled:i,onChange:e,isMinWidth:!0,...n,children:[m,r]})}}qi.propTypes={timeOfDayItems:Ut().objectOf(Ut().string).isRequired,name:Ut().string,value:Ut().string.isRequired,disabled:Ut().bool,onChange:Ut().func.isRequired,validation:Ut().object},qi.displayName="TimeSelect";class Hi 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||kt()(()=>{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)(Ei.Grid.Column,{className:"mailpoet-datetime-container",children:(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(Vi,{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)(qi,{name:"time",value:this.state.time,onChange:this.handleChange,disabled:this.props.disabled,timeOfDayItems:this.props.timeOfDayItems})]})})}}var zi=a(88516),Gi=a(34599),Yi=a(98933);class Ki extends r.Component{constructor(e){super(e);const t=(0,Yi.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,Gi.SB)(this.domElementSelector,this.parsleyFieldName)}onBlur(){this.validateEmailAddress()}isEmailAddressAuthorized=e=>(window.mailpoet_authorized_emails||[]).includes(e);showInvalidFromAddressError=()=>{(0,Gi.oI)(this.domElementSelector,this.parsleyFieldName," "),this.setState({showAuthEmailsError:!0})};showSenderFieldError=(e,t)=>{window.mailpoet_mss_active&&((0,Gi.SB)(this.domElementSelector,this.parsleyFieldName),(0,Gi.vg)(this.domElementSelector)?e?this.showSenderDomainError(!0):this.showInvalidFromAddressError(t):(0,Gi.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,Yi.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)(At,{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)(zi.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,Gi.SB)(this.domElementSelector,this.parsleyFieldName)}})})]})}}Ki.propTypes={field:Ut().object.isRequired,item:Ut().shape({sender_address:Ut().string.isRequired}).isRequired,onValueChange:Ut().func},Ki.displayName="SenderField";const Qi=Rt.default.once(()=>m.U.trackEvent("User has typed a GA campaign name")),Ji=b()((0,p.__)("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)),Zi={name:"ga_campaign",label:(0,p.__)("Google Analytics Campaign","mailpoet"),tip:Ji,type:"text",onBeforeChange:Qi};var Xi=a(8872),es=a(94667),ts=a(6548),as=a(24683),is=a(66880);const ss={saveDraftNewsletter:()=>Promise.resolve()},ns=r.createContext(ss);var rs=a(58270);function os(e,t){return`segments:${e.join(",")}|filterSegmentId:${t}`}const ls=[{name:"segments",label:(0,p.__)("Send to","mailpoet"),type:"selection",placeholder:(0,p.__)("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,p.__)("Please select a list","mailpoet"),"data-parsley-segments-with-subscribers":(0,p.__)("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)(ts.d&&!!i),l=(0,r.useCallback)(a=>{t({target:{name:"options",value:{...e?.options??{},filterSegmentId:a}}})},[e,t]),d=(0,r.useContext)(ns);(0,r.useEffect)(()=>{ts.d||""===i||l("")},[l,i]);const c=(0,r.useCallback)(i=>{t({target:{name:a.name,value:i}}),i||l(""),n(i),m.U.trackEvent("Emails > Filter by segment toggled",{"Email type":e.type})},[a,t,l,e]);let u;if(s){const t={name:"filter-segment",type:"selection",placeholder:(0,p.__)("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,p.__)("Please select a filter segment","mailpoet")}};u=(0,g.jsx)(Ve.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,p.__)("Filter by segment","mailpoet"),(0,g.jsx)(ii.A,{"data-tip":!0,"data-tooltip-id":"filter-segment-tooltip",className:"filter-segment-tooltip",icon:is.A})]}),(0,g.jsx)(as.m,{place:"right",id:"filter-segment-tooltip",children:(0,g.jsx)("div",{children:(0,p.__)("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"}),u,s&&(0,g.jsx)("p",{children:b()((0,p.__)("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))})]})})}],ds={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=os(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=os(n,o);l.current===i&&s(a)}).always(()=>a(!1)))},[n,o]),(0,g.jsxs)("div",{children:[(0,p.__)("Estimated recipients","mailpoet"),":",t&&(0,g.jsx)(rs.Ay,{className:"mailpoet-recipient-count-spinner"}),!t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(as.m,{place:"right",id:"estimated-count-tooltip",children:(0,p.__)("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()})]})]})})},cs={name:"send-to",label:(0,p.__)("Send to","mailpoet"),tip:(0,p.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:ls},ms={name:"send-to",label:(0,p.__)("Send to","mailpoet"),tip:(0,p.__)("Subscribers in multiple lists will only receive one email.","mailpoet"),fields:[...ls,ds]},us=`${window.mailpoet_tomorrow_date} 08:00:00`,ps=m.U.Date.toGmtDatetimeString(us),hs=window.mailpoet_schedule_time_of_day,gs=window.mailpoet_date_format,_s=window.mailpoet_date_storage_format;class fs extends r.Component{getCurrentValue=()=>({isScheduled:"0",scheduledAt:ps,...this.props.item?.[this.props.field.name]??{}});getDateValidation=()=>({"data-parsley-required":!0,"data-parsley-required-message":(0,p.__)("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,p.__)("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)(Hi,{name:"scheduledAt",value:this.getCurrentValue().scheduledAt,onChange:this.handleValueChange,disabled:this.props.field.disabled,dateValidation:this.getDateValidation(),defaultDateTime:ps,timeOfDayItems:hs,dateDisplayFormat:gs,dateStorageFormat:_s,maxDate:t})})]})),(0,g.jsxs)("div",{children:[(0,g.jsx)(Xi.l,{checked:this.isScheduled(),disabled:this.props.field.disabled,name:"isScheduled",onCheck:this.handleCheckboxChange,automationId:"email-schedule-checkbox"}),e]})}}function bs({item:e,field:t,onValueChange:a}){const i=e?.options??{},s=i.shareVisibility,n="public"===s||"private"===s?s:e?.effective_share_visibility||"private",o=e=>{a({target:{name:t.name,value:{...i,shareVisibility:e}}})};return(0,r.useEffect)(()=>{s||a({target:{name:t.name,value:{...i,shareVisibility:n}}})},[]),(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"mailpoet-form-description",children:(0,p.__)("Choose whether this email can be opened from a public share link after it is sent.","mailpoet")}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(Ft.s,{id:"mailpoet-share-visibility-public",value:"public",checked:"public"===n,onCheck:o,name:"shareVisibility"}),(0,g.jsx)("label",{htmlFor:"mailpoet-share-visibility-public",children:(0,p.__)("Public","mailpoet")})]}),(0,g.jsxs)("div",{className:"mailpoet-settings-inputs-row",children:[(0,g.jsx)(Ft.s,{id:"mailpoet-share-visibility-private",value:"private",checked:"private"===n,onCheck:o,name:"shareVisibility"}),(0,g.jsx)("label",{htmlFor:"mailpoet-share-visibility-private",children:(0,p.__)("Private","mailpoet")})]})]})}let xs=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("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,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},ms,{name:"options",label:(0,p.__)("Schedule it","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(function(e){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(fs,{...e}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("h4",{className:"mailpoet-h4",children:(0,p.__)("Sharing visibility","mailpoet")}),(0,g.jsx)(bs,{...e})]})})},{name:"archive-visibility",label:(0,p.__)("Archive","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(function({item:e,onValueChange:t,field:a}){const i=e?.options??{},s="mailpoet-archive-visibility-help",n=(0,p.__)("Show this newsletter in the archive","mailpoet");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Xi.l,{checked:(r=i.excludeFromArchive,"1"!==r&&!0!==r),disabled:a.disabled,name:"excludeFromArchive",onCheck:e=>{var a;t({target:{name:"options",value:{...i,excludeFromArchive:(a=e,a?"0":"1")}}})},automationId:"archive-visibility-toggle","aria-label":n,"aria-describedby":s}),(0,g.jsx)("span",{className:"mailpoet-form-toggle-text",children:n}),(0,g.jsx)("p",{id:s,className:"mailpoet-form-field-description",children:(0,p.__)("Shown on pages using the MailPoet archive shortcode.","mailpoet")})]});var r})},{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ki),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Zi,{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("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,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];xs=Sa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",xs);const vs={getFields:()=>xs,getSendButtonOptions:(e={})=>{const t={value:"object"==typeof e.options&&"1"===e.options?.isScheduled&&m.U.Date.isInFuture(e.options?.scheduledAt,new Date)?(0,p.__)("Schedule","mailpoet"):(0,p.__)("Send","mailpoet")};return e.status!==es.um.Sent&&e.status!==es.um.Sending||(t.disabled="disabled"),t}},ys=window.mailpoet_time_format||"H:i",ws={immediate:(0,p.__)("immediately","mailpoet"),minutes:(0,p.__)("minute(s) later","mailpoet"),hours:(0,p.__)("hour(s) later","mailpoet"),days:(0,p.__)("day(s) later","mailpoet"),weeks:(0,p.__)("week(s) later","mailpoet")},js={daily:(0,p.__)("Once a day at...","mailpoet"),weekly:(0,p.__)("Weekly on...","mailpoet"),monthly:(0,p.__)("Monthly on the...","mailpoet"),nthWeekDay:(0,p.__)("Monthly every...","mailpoet"),immediately:(0,p.__)("Immediately","mailpoet")},Ss=Rt.default.object(Rt.default.map(Rt.default.times(96,e=>900*e),e=>{const t=new Date(null);return t.setSeconds(e),[e,m.U.Date.format(t,{format:ys,offset:0})]})),ks={0:(0,p.__)("Sunday","mailpoet"),1:(0,p.__)("Monday","mailpoet"),2:(0,p.__)("Tuesday","mailpoet"),3:(0,p.__)("Wednesday","mailpoet"),4:(0,p.__)("Thursday","mailpoet"),5:(0,p.__)("Friday","mailpoet"),6:(0,p.__)("Saturday","mailpoet")},Ns=Rt.default.object(Rt.default.map(Rt.default.times(28,e=>e),e=>{const t={0:(0,p.__)("1st","mailpoet"),1:(0,p.__)("2nd","mailpoet"),2:(0,p.__)("3rd","mailpoet")};let a;return a=void 0!==t[e]?t[e]:(0,p.__)("%1$dth","mailpoet").replace("%1$d",e+1),[e+1,a]})),Cs={1:(0,p.__)("1st","mailpoet"),2:(0,p.__)("2nd","mailpoet"),3:(0,p.__)("3rd","mailpoet"),4:(0,p.__)("4th","mailpoet"),L:(0,p._x)("last","e.g. monthly every last Monday","mailpoet")},Es="1",Us=["0","1","2","3","4","5","6"],Is=e=>[...e].sort((e,t)=>Number(e)-Number(t)),As=e=>null==e?"":String(e).trim(),Ts=e=>{const t=As(e);return Us.includes(t)?t:Es},Ps=e=>{const t=Ts(e),a=Us.indexOf(t);return[...Us.slice(a),...Us.slice(0,a)]},Rs=(e,t,a)=>{const i=Object.keys(a),s=As(e).split(",").map(e=>e.trim()).filter(e=>i.includes(e));return 0===s.length?[t]:Is([...new Set(s)])},Ds=e=>Is(e).join(","),Fs=(e,t,a,i=Is(Object.keys(t)))=>((e,t)=>[...e].sort((e,a)=>{const i=t.indexOf(e),s=t.indexOf(a);return-1===i||-1===s?Number(e)-Number(a):i-s}))(Rs(e,a,t),i).map(e=>t[e]).join(", "),Os={name:"intervalType",values:js},Ms={name:"timeOfDay",values:Ss},Ls={name:"weekDay",values:ks},$s={name:"nthWeekDay",values:Cs},Bs=e=>4===e?"mailpoet-grid-four-columns":"mailpoet-grid-three-columns";function Ws({name:e,values:t,selectedValues:a,onValueChange:i,automationId:s,columns:n,valueOrder:r}){const o=a.map(e=>`${e}`),l=r||Object.keys(t);return(0,g.jsx)("div",{className:Bs(n),children:l.map(a=>(0,g.jsx)("span",{children:(0,g.jsx)(Mt.S,{name:e,value:a,checked:o.includes(a),onCheck:e=>{let t=o;e?t=[...o,a]:o.length>1&&(t=o.filter(e=>e!==a)),i(Ds(t))},automationId:`${s}_${a}`,children:t[a]})},`${e}-${a}`))})}Ws.propTypes={name:Ut().string.isRequired,values:Ut().objectOf(Ut().string).isRequired,selectedValues:Ut().arrayOf(Ut().string).isRequired,onValueChange:Ut().func.isRequired,automationId:Ut().string.isRequired,columns:Ut().oneOf([3,4]).isRequired,valueOrder:Ut().arrayOf(Ut().string)};class Vs extends r.Component{getCurrentValue=()=>this.props.item[this.props.field.name]||{};getDefaultWeekDay=()=>Ts(m.U.wpWeekStartsOn);getOrderedWeekDayKeys=()=>Ps(m.U.wpWeekStartsOn);handleValueChanges=e=>{const t=this.getCurrentValue();return this.props.onValueChange({target:{name:this.props.field.name,value:Rt.default.extend({},t,e)}})};handleIntervalChange=e=>{const t=e.target.value,a=this.getCurrentValue(),i={};i.intervalType=t,"monthly"===t&&(i.monthDay=Ds(Rs(a.monthDay,Es,Ns))),"weekly"===t&&(i.weekDay=Ds(Rs(a.weekDay,this.getDefaultWeekDay(),ks))),"nthWeekDay"===t&&(i.weekDay=((e,t)=>Rs(e,t,ks)[0])(a.weekDay,this.getDefaultWeekDay()),i.nthWeekDay=a.nthWeekDay||Es),this.handleValueChanges(i)};handleTimeOfDayChange=e=>this.handleValueChanges({timeOfDay:e.target.value});handleWeekDayChange=e=>this.handleValueChanges({weekDay:e.target.value});handleWeekDaysChange=e=>this.handleValueChanges({weekDay:e});handleMonthDaysChange=e=>this.handleValueChanges({monthDay:e});handleNthWeekDayChange=e=>this.handleValueChanges({nthWeekDay:e.target.value});render(){const e=this.getCurrentValue(),t=this.getDefaultWeekDay(),a=this.getOrderedWeekDayKeys(),i={...Ls,sortBy:e=>a.indexOf(e)};let s,n,r,o;return"immediately"!==e.intervalType&&(n=(0,g.jsx)(Dt,{field:Ms,item:this.getCurrentValue(),onValueChange:this.handleTimeOfDayChange})),"weekly"===e.intervalType&&(s=(0,g.jsx)(Ws,{name:"weekDay",values:ks,selectedValues:Rs(e.weekDay,t,ks),onValueChange:this.handleWeekDaysChange,automationId:"newsletter_week_day",columns:3,valueOrder:a})),"nthWeekDay"===e.intervalType&&(r=(0,g.jsx)(Dt,{field:i,item:this.getCurrentValue(),onValueChange:this.handleWeekDayChange})),"monthly"===e.intervalType&&(s=(0,g.jsx)(Ws,{name:"monthDay",values:Ns,selectedValues:Rs(e.monthDay,Es,Ns),onValueChange:this.handleMonthDaysChange,automationId:"newsletter_month_day",columns:4})),"nthWeekDay"===e.intervalType&&(o=(0,g.jsx)(Dt,{field:$s,item:this.getCurrentValue(),onValueChange:this.handleNthWeekDayChange})),(0,g.jsxs)("div",{children:[(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsx)(Dt,{field:Os,item:this.getCurrentValue(),onValueChange:this.handleIntervalChange,automationId:"newsletter_interval_type"}),"immediately"===e.intervalType&&(0,g.jsx)("div",{children:(0,g.jsx)("p",{children:(0,p.__)("after publishing a post","mailpoet")})})]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),s&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet-grid-column",children:s}),(0,g.jsx)("div",{className:"mailpoet-gap"})]}),(0,g.jsxs)("div",{className:"mailpoet-grid-column mailpoet-flex",children:[o,r,n]}),"immediately"!==e.intervalType&&(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}Vs.propTypes={item:Ut().object.isRequired,field:Ut().shape({name:Ut().string}).isRequired,onValueChange:Ut().func.isRequired};let qs=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("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,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("Select a frequency","mailpoet"),type:"reactComponent",component:Vs},ms,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ki),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},Zi,{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("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,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];qs=Sa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",qs);const Hs={getFields:function(){return qs},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}},zs=window.mailpoet_roles||{},Gs=Rt.default.filter(window.mailpoet_segments||[],e=>"default"===e.type),Ys={name:"event",values:{segment:(0,p.__)("When someone subscribes to the list...","mailpoet"),user:(0,p.__)("When a new WordPress user is added to your site...","mailpoet")}},Ks={name:"segment",placeholder:(0,p.__)("Select a list","mailpoet"),forceSelect2:!0,values:Gs,getCount:e=>parseInt(e.subscribers,10).toLocaleString(),getLabel:e=>e.name,getValue:e=>e.id},Qs={name:"role",values:zs},Js={name:"afterTimeNumber",size:3,validation:{"data-parsley-required":!0,"data-parsley-errors-container":".mailpoet-form-errors","data-parsley-scheduled-at":(0,p.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},Zs={name:"afterTimeType",values:ws};class Xs 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:Rt.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)(Dt,{field:Qs,item:this.getCurrentValue(),onValueChange:this.handleRoleChange}):(0,g.jsx)(Ve.L,{field:Ks,item:this.getCurrentValue(),onValueChange:this.handleSegmentChange}),"immediate"!==e.afterTimeType&&(a=(0,g.jsx)(At,{field:Js,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeNumberChange})),(0,g.jsxs)("div",{children:[(0,g.jsx)(Dt,{field:Ys,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)(Dt,{field:Zs,item:this.getCurrentValue(),onValueChange:this.handleAfterTimeTypeChange})]}),(0,g.jsx)("div",{className:"mailpoet-form-errors"}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}}Xs.propTypes={item:Ut().object.isRequired,field:Ut().shape({name:Ut().string}).isRequired,onValueChange:Ut().func.isRequired},Xs.displayName="WelcomeScheduling";let en=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("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,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("When to send this welcome email?","mailpoet"),type:"reactComponent",component:(0,o.withBoundary)(Xs)},Zi,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:(0,o.withBoundary)(Ki),placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("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,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}];en=Sa.Hooks.applyFilters("mailpoet_newsletters_3rd_step_fields",en);const tn={getFields:function(){return en},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}},an=3;class sn 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=ws;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:Rt.default.map(t,(e,t)=>({name:e,id:t})),extendSelect2Options:{minimumResultsForSearch:1/0},selected:()=>a},onValueChange:Rt.default.partial(this.handleChange,Rt.default,"afterTimeType")};return(0,g.jsx)(Ve.L,{field:i.field,onValueChange:i.onValueChange})}displayAfterTimeNumberField(){const{event:e,afterTimeNumberSize:t=an}=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,p.__)("An email can only be scheduled up to 5 years in the future. Please choose a shorter period.","mailpoet")}},item:{},onValueChange:Rt.default.partial(this.handleChange,Rt.default,"afterTimeNumber")};return(0,g.jsx)(At,{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,p.__)("When to send this email?","mailpoet")," "]}),(0,g.jsxs)(Ei.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 nn(e){const t=e&&e.values?e.values:[];return t?t.map(e=>({id:e.id,name:e.name})):t}function rn({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:nn(e),multiple:e.multiple||!1,placeholder:e.placeholder||!1,transformChangedValue:(e,t)=>Rt.default.map(t,e=>({id:e.id,name:e.text})),selected:()=>a,getLabel:Rt.default.property("name"),getValue:Rt.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)(Ve.L,{field:i.field,onValueChange:i.onValueChange,item:i.item}),(0,g.jsx)("div",{className:"mailpoet-gap"})]})}()})})}sn.propTypes={item:Ut().shape({afterTimeType:Ut().string.isRequired,afterTimeNumber:Ut().number}).isRequired,afterTimeNumberSize:Ut().number,onValueChange:Ut().func,event:Ut().shape({defaultAfterTimeType:Ut().string,afterDelayText:Ut().string,timeDelayValues:Ut().objectOf(Ut().shape({text:Ut().string,displayAfterTimeNumberField:Ut().bool})),schedulingReadMoreLink:Ut().shape({link:Ut().string.isRequired,text:Ut().string.isRequired})}).isRequired},sn.displayName="EventScheduling",rn.displayName="EventOptions";const on=(0,o.withBoundary)(rn);class ln 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=Rt.default.indexBy(this.email.events,"slug"),this.segments=Rt.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)(sn,{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)(Ve.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=Rt.default.map(a.option,e=>e.id)),(0,g.jsx)(on,{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)(qt.D,{level:5,children:this.displayHeader()}),this.displayEventOptions(),this.displaySegments(),this.displayScheduling()]})}}ln.propTypes={field:Ut().shape({email:Ut().shape({events:Ut().object.isRequired}).isRequired,emailOptions:Ut().object.isRequired}).isRequired,onValueChange:Ut().func},ln.displayName="SendEventConditions";const dn=window.mailpoet_woocommerce_automatic_emails||[],cn={getFields:function(e){return(e=>{const t=dn[e.options.group];if(!t)return!1;const a=e.options;return[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("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,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("Max length is 250 characters, however, we recommend 80 characters on a single line.","mailpoet")}`,type:"textarea",validation:{maxLength:250}}]},{name:"options",label:(0,p.__)("Send this %1s Automatic Email when...","mailpoet").replace("%1s",t.title),type:"reactComponent",component:(0,o.withBoundary)(ln),email:t,emailOptions:a},Zi,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"empty",type:"empty"},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("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,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]}]})(e)},getSendButtonOptions:function(){return{value:(0,p.__)("Activate","mailpoet")}}};var mn=a(39429);function un({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)(qt.D,{level:4,children:(0,p.__)("When to send this re-engagement email?","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("After no activity for","mailpoet")}),(0,g.jsxs)(Ei.Grid.TwoColumns,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(It.p,{type:"number",placeholder:(0,p.__)("count","mailpoet"),value:e,min:1,onChange:(0,Yi.k9)(a),required:!0})}),(0,g.jsx)("div",{children:(0,g.jsxs)(Be.Select,{value:t,onChange:(0,Yi.k9)(i),children:[(0,g.jsx)("option",{value:"weeks",children:(0,p.__)("weeks","mailpoet")}),(0,g.jsx)("option",{value:"months",children:(0,p.__)("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:b()((0,p.__)("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 pn=[{name:"email-header",label:null,tip:null,fields:[{name:"subject",customLabel:(0,p.__)("Subject","mailpoet"),className:"mailpoet-form-field-subject",placeholder:(0,p.__)("Type newsletter subject","mailpoet"),tooltip:(0,p.__)("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,p.__)("Please specify a subject","mailpoet"),maxLength:250}},{name:"preheader",customLabel:(0,p.__)("Preview text","mailpoet"),className:"mailpoet-form-field-preheader",placeholder:(0,p.__)("Type preview text (usually displayed underneath the subject line in the inbox)","mailpoet"),tooltip:`${(0,p.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")} ${(0,p.__)("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)(un,{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,mn.assoc)("afterTimeNumber",t,e.item.options)}})},updateAfterTimeType:t=>{e.onValueChange({target:{name:"options",value:(0,mn.assoc)("afterTimeType",t,e.item.options)}})}})}},cs,{name:"sender",label:(0,p.__)("Sender","mailpoet"),tip:(0,p.__)("Your name and email","mailpoet"),fields:[{name:"sender_name",type:"text",placeholder:(0,p.__)("John Doe","mailpoet"),validation:{"data-parsley-required":!0}},{name:"sender_address",type:"reactComponent",component:Ki,placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-required":!0,"data-parsley-type":"email"}}]},{name:"reply-to",label:(0,p.__)("Reply-to","mailpoet"),tip:(0,p.__)("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,p.__)("John Doe","mailpoet")},{name:"reply_to_address",type:"text",placeholder:(0,p.__)("john.doe@email.com","mailpoet"),validation:{"data-parsley-type":"email"}}]},Zi],hn={getFields:()=>pn,getSendButtonOptions:()=>({value:(0,p.__)("Activate","mailpoet")})};var gn=a(82518);let _n=null;var fn=a(84025),bn=a(74298);function xn({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)(bn.wk,{}),i&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(bn.Tr,{onRefreshClick:async t=>{t.preventDefault(),e(!0),await a(),s(!1),e(!1)}})]})]})}xn.displayName="PendingNewsletterMessage";const vn=(0,o.withBoundary)(xn),yn=window.mailpoet_woocommerce_automatic_emails||{},wn=(e,t)=>`${Ci()(t,{strict:!0,lower:!0})||"email"}-${e}`,jn=e=>"immediate"===e.afterTimeType?"immediate":`${e.afterTimeNumber} ${e.afterTimeType}`;function Sn(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,p.__)("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,p.__)('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,p.__)("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,p._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,p.__)("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:b()((0,p.__)("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 kn 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})}),Ct()("#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===es.Gn.Automatic&&yn[e.options.group])return cn;switch(e.type){case"notification":return Hs;case"welcome":return tn;case"re_engagement":return hn;default:return vs}};getThumbnailPromise=e=>this.state?.thumbnailPromise??(0,gn.uz)(e);isValid=()=>Ct()("#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,Yi.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===es.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&&ts.d&&(a.ga_campaign=wn(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:Sn(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))})):Ct()("#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=ki().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,p.__)("The newsletter has been scheduled.","mailpoet")})):this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("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=>(0,fn.M4)(Number(this.props.params.id),"active").then(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&&yn[e.group]?m.U.trackEvent("Emails > Automatic email activated",{Type:Ci()(`${e.group}-${e.event}`),Delay:jn(e)}):"welcome"===t.data.type?m.U.trackEvent("Emails > Welcome email activated",{"List type":e.event,Delay:jn(e)}):"re_engagement"===t.data.type?(this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("Your Re-engagement Email is now activated!","mailpoet")})),m.U.trackEvent("Emails > Re-engagement email activated",{Inactivity:jn(e),"Segment Applied":!!this.state.item.options.filterSegmentId})):"notification"===t.data.type&&(this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("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)})}).catch(e=>{this.showError({errors:[{message:e.message}]}),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,p.__)("The newsletter sending has been resumed.","mailpoet")}))}).fail(e=>{this.showError(e)})}).fail(e=>{this.showError(e)}).always(()=>{this.setState({loading:!1})}):Ct()("#mailpoet_newsletter").parsley().validate(),!1);handleSave=e=>{e.preventDefault(),this.saveNewsletter().done(()=>{this.context.notices.success((0,g.jsx)("p",{children:(0,p.__)("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&notice=${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,p.__)("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=ki().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===wn(i.id,s)&&(i.ga_campaign=wn(i.id,a)),"reply_to_address"===t&&(i[t]=a.toLowerCase()),{item:i}}),!0};handleSaveDraft=()=>{Ct()("#mailpoet_newsletter").parsley().destroy()};disableSegmentsSelectorWhenPaused=e=>t=>"segments"===t.name||"options"===t.name?{...t,disabled:e}:t;disableGAIfPremiumInactive=()=>e=>ts.d||"ga_campaign"!==e.name?e:{...e,disabled:!0,onWrapperClick:()=>this.setState({showPremiumModal:!0,premiumModalMessage:(0,p.__)("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||ts.d?e:{...e,disabled:!0,onWrapperClick:e=>{e.preventDefault(),this.setState({showPremiumModal:!0,premiumModalMessage:(0,p.__)("Filtering by segment is not available in the free version of the MailPoet plugin.","mailpoet")})}}),t};getPreparedFields=e=>Array.isArray(this.state.fields)?this.state.fields.map(this.disableSegmentsSelectorWhenPaused(e)).map(this.disableGAIfPremiumInactive()).map(this.disableFilterSegmentToggleIfPremiumInactive()):[];closePremiumModal=()=>this.setState({showPremiumModal:!1});toggleLoadingState=e=>this.setState({loading:e});updatePendingApprovalState=e=>this.setState({mssKeyPendingApproval:e});saveDraftNewsletter=async()=>{this.handleSaveDraft(),await this.saveNewsletter()};render(){const{showPremiumModal:e,item:{status:t,queue:a,type:i,options:s,wp_post_id:n},mssKeyPendingApproval:r}=this.state,l="sending"===t&&a&&"paused"===a.status,d=this.getSendButtonOptions(),c=this.getPreparedFields(l),u=!(!window.mailpoet_subscribers_limit_reached&&!r&&void 0===this.state.validationError);let h=i;return h===es.Gn.Automatic&&(h=s.group||h),(0,g.jsxs)("div",{className:"mailpoet-form-send-email",children:[(0,g.jsx)(_i,{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)(ns.Provider,{value:this.state.sendContextValue,children:(0,g.jsxs)(Kt,{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)(Ei.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,p.__)("Save as draft and close","mailpoet")}),l?(0,g.jsx)(o.Button,{type:"button",onClick:this.handleResume,isDisabled:u||this.state.loading,automationId:"email-resume",children:(0,p.__)("Resume","mailpoet")}):(0,g.jsx)(o.Button,{type:"button",onClick:this.handleSend,...d,isDisabled:u||this.state.loading,automationId:"email-submit",children:d.value||(0,p.__)("Send","mailpoet")}),void 0!==this.state.validationError&&(0,g.jsx)(He.Tooltip,{tooltip:(0,g.jsx)("div",{children:this.state.validationError}),tooltipId:"helpTooltipSendEmail"})]}),(0,g.jsxs)("p",{children:[(0,p.__)("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,p.__)("go back to the Design page","mailpoet")}),"."]}),r&&(0,g.jsx)(vn,{toggleLoadingState:this.toggleLoadingState,updatePendingState:this.updatePendingApprovalState}),e&&(0,g.jsx)(ts.D,{onRequestClose:this.closePremiumModal,children:this.state.premiumModalMessage})]})})]})]})}}function Nn(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(qt.D,{level:0,children:(0,p.__)("Congratulations!","mailpoet")}),(0,g.jsx)(qt.D,{level:3,children:(i=e.newsletter,"welcome"===i.type?(0,p.__)("Your Welcome Email is now active.","mailpoet"):"notification"===i.type?(0,p.__)("Your Post Notification is now active.","mailpoet"):"automatic"===i.type?(0,p.__)("Your WooCommerce email has been activated.","mailpoet"):"scheduled"===i.status?(0,p.__)("Your newsletter is scheduled to be sent.","mailpoet"):(0,p.__)("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,p.__)("Close","mailpoet")})]});var i}function Cn(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 En(){return(0,g.jsxs)(o.List,{children:[(0,g.jsx)("li",{children:(0,p.__)("Reliable marketing and transactional email delivery. Reach inboxes, not spam boxes","mailpoet")}),(0,g.jsx)("li",{children:(0,p.__)("Send your emails super fast (up to 50,000 emails per hour)","mailpoet")}),(0,g.jsx)("li",{children:(0,p.__)("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,p.__)("Authenticate your emails (with SPF and DKIM) to improve deliverability and avoid spam boxes","mailpoet")})]})}function Un(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,p.__)("Your email has been sent!","mailpoet"),welcome:(0,p.__)("You are all set up and ready to go!","mailpoet"),notification:(0,p.__)("You are all set up and ready to go!","mailpoet"),woocommerce:(0,p.__)("You are all set up and ready to go!","mailpoet")}[s]||(0,p.__)("You are all set up and ready to go!","mailpoet"))}),(0,g.jsx)(Cn,{illustrationUrl:e.MSSPitchIllustrationUrl,children:(0,g.jsxs)("div",{className:"mailpoet-welcome-wizard-step-content",children:[(0,g.jsx)(o.Heading,{level:4,children:(0,p.__)("What’s next? Sign up to the MailPoet Starter plan for fast and reliable email delivery","mailpoet")}),(0,g.jsx)("p",{children:e.subscribersCount<500?(0,p._x)("Did you know? Users with 500 subscribers or less get the Starter plan for free.","Promotion for our email sending service: Paragraph","mailpoet"):(0,p._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,p._x)("You’ll get","Promotion for our email sending service: Paragraph","mailpoet"),":"]}),(0,g.jsx)(En,{}),(0,g.jsx)("p",{children:b()((0,p.__)("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,p._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,p._x)("No thanks!","Promotion for our email sending service: Skip link","mailpoet")})]})})]});var s}function In(e){return window.has_mss_key_specified?(0,g.jsx)(Nn,{successClicked:e.successClicked,illustrationImageUrl:e.illustrationImageUrl,newsletter:e.newsletter}):(0,g.jsx)(Un,{MSSPitchIllustrationUrl:e.MSSPitchIllustrationUrl,onFinish:e.successClicked,subscribersCount:e.subscribersCount,purchaseUrl:e.purchaseUrl,newsletter:e.newsletter})}function An(e){const[t,a]=(0,r.useState)(!1);return(0,g.jsxs)("div",{children:[(0,g.jsx)(qt.D,{level:1,children:(0,p.__)("Oops! We can’t send your newsletter","mailpoet")}),(0,g.jsx)(qt.D,{level:3,children:b()((0,p.__)("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,p.__)("Close","mailpoet")})]})}kn.contextType=l.F,Nn.propTypes={successClicked:Ut().func.isRequired,illustrationImageUrl:Ut().string.isRequired,newsletter:Ut().shape({status:Ut().string.isRequired,type:Ut().string.isRequired}).isRequired},Cn.propTypes={illustrationUrl:Ut().string.isRequired,children:Ut().oneOfType([Ut().arrayOf(Ut().node),Ut().node]).isRequired},In.propTypes={successClicked:Ut().func.isRequired,illustrationImageUrl:Ut().string.isRequired,MSSPitchIllustrationUrl:Ut().string.isRequired,newsletter:Ut().shape({status:Ut().string.isRequired,type:Ut().string.isRequired}).isRequired,subscribersCount:Ut().number.isRequired,purchaseUrl:Ut().string.isRequired},An.propTypes={failClicked:Ut().func.isRequired};var Tn=a(98191);function Pn(e){return(0,g.jsx)("div",{className:"mailpoet-congratulate-loading",children:e.showRichLoadingScreen&&(0,g.jsxs)("div",{children:[(0,g.jsx)(qt.D,{level:0,children:(0,p.__)("Verification","mailpoet")}),(0,g.jsx)(qt.D,{level:3,children:(0,p.__)("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)(Tn.a,{size:64})]})})}Pn.propTypes={showRichLoadingScreen:Ut().bool.isRequired};const Rn=Math.floor(4*Math.random());function Dn(){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 Fn extends r.Component{constructor(e){super(e),this.state={loading:!0,newsletter:null,testingPassed:!1,timeStart:jt()(),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(){jt()().subtract(20,"second").isAfter(this.state.timeStart)&&this.setState({error:!0,loading:!1}),this.state.loading&&this.loadNewsletter(this.props.params.id),jt()().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)(Pn,{illustrationImageUrl:window.mailpoet_congratulations_loading_image,successClicked:Dn,showRichLoadingScreen:e})):this.state.error?(m.U.trackEvent("Cron testing done",{"Cron is working":"false"}),(0,g.jsx)(An,{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)(In,{illustrationImageUrl:window.mailpoet_congratulations_success_images[Rn],MSSPitchIllustrationUrl:window.mailpoet_congratulations_success_images[Rn],successClicked:Dn,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()]})]})}}Fn.propTypes={params:Ut().shape({id:Ut().string}).isRequired},Fn.displayName="Congratulate";class On extends r.Component{componentDidMount(){m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"create",data:{type:"standard",subject:(0,p.__)("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)(_i,{emailType:"standard",automationId:"standard_newsletter_creation_heading"})})}}On.contextType=l.F,On.propTypes={navigate:Ut().func.isRequired},On.displayName="NewsletterStandard";const Mn={name:"options",type:"reactComponent",component:Vs};class Ln extends r.Component{constructor(e){super(e),this.state={options:{intervalType:"daily",timeOfDay:0,weekDay:Ts(m.U.wpWeekStartsOn),monthDay:"1",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:Rt.default.extend({},this.state,{type:"notification",subject:(0,p.__)("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)(_i,{emailType:"notification",automationId:"post_notification_creation_heading"}),(0,g.jsxs)(Ei.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(qt.D,{level:4,children:(0,p.__)("When to send this post notification email?","mailpoet")}),(0,g.jsx)(Vs,{item:this.state,field:Mn,onValueChange:this.handleValueChange}),(0,g.jsx)(Ge.$,{isFullWidth:!0,onClick:this.handleNext,type:"button",children:(0,p.__)("Next","mailpoet")})]})]})}}function $n(){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,Ae.Zp)();return(0,g.jsxs)("div",{children:[i&&(0,g.jsx)(oi,{errors:i}),(0,g.jsx)(_i,{emailType:"re_engagement",automationId:"re_engagement_heading_creation_heading"}),(0,g.jsxs)(Ei.Grid.Column,{align:"center",className:"mailpoet-schedule-email",children:[(0,g.jsx)(un,{afterTimeNumber:t.afterTimeNumber,afterTimeType:t.afterTimeType,inactiveSubscribersPeriod:Number(m.U.deactivateSubscriberAfterInactiveDays),updateAfterTimeNumber:(0,mn.compose)([a,(0,mn.assoc)("afterTimeNumber",mn.__,t)]),updateAfterTimeType:(0,mn.compose)([a,(0,mn.assoc)("afterTimeType",mn.__,t)])}),(0,g.jsx)(Ge.$,{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,p.__)("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,p.__)("Next","mailpoet")})]})]})}Ln.contextType=l.F,$n.displayName="NewsletterTypeReEngagement";var Bn=a(68380),Wn=a(4534);function Vn({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)(oi,{errors:i}),t&&(0,g.jsx)(Ge.$,{dimension:"small",onClick:e.status===es.um.Corrupt?async()=>{(0,o.confirmAlert)({message:(0,p.__)("There was an issue sending this email before. Please confirm the problems are fixed to proceed.","mailpoet"),onConfirm:n})}:n,children:(0,p.__)("Resume","mailpoet")}),!t&&(0,g.jsx)(Ge.$,{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,p.__)("Pause","mailpoet")})]})}function qn(){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,p.__)("Cancelled","mailpoet")})})}function Hn({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)(Ie.Link,{to:`/sending-status/${e.id}`,"data-automation-id":`sending_status_${e.id}`,children:(0,g.jsx)(Wn.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)(qn,{}),"completed"!==e.queue.status&&!i&&!n&&(0,g.jsx)(Vn,{newsletter:e})]}),o=(0,g.jsx)(Wn.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]})}Hn.displayName="QueueStatus";const zn=(0,o.withBoundary)(Hn);var Gn=a(63027);function Yn({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:Sa.Hooks.applyFilters("mailpoet_newsletters_listing_stats_tracking",yi.cp)},n=Number(e.total_sent||e.queue.count_processed),r=e.queue&&"cancelled"===e.queue.status;if(r&&0===n)return null;let l,d,c,m,u,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,u=!1):(l=6,d=e.queue.scheduled_at||e.queue.created_at,c=jt()(a).diff(jt()(d),"hours"),m=c<l,u=!0);const b=n>=20&&e.statistics.opened>=5&&!m,x=m&&"completed"===e.queue.status,v=(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)(Ie.Link,{to:t.link,onClick:t.onClick||null,children:e},`stats-${a}`))(t,s,`${a}-${e.id}`,n),y=(0,g.jsx)(Gn.j,{opened:_,clicked:h,revenues:f&&f.value>0?f.formatted:null,hideBadges:!b,newsletterId:e.id,wrapContentInLink:v}),w=(0,g.jsxs)(g.Fragment,{children:[y,x&&v((0,g.jsx)(o.Tag,{className:"mailpoet-listing-stats-too-early",dimension:"large",variant:"excellent",isInverted:!0,children:(0,p.__)("Nice job! Check back in %1$d hour(s) for more stats.","mailpoet").replace("%1$d",l-c)}),"check-back")]});let j;return u&&_<5&&c>=24&&n>=10&&(j=(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,p.__)("What can I do to improve this?","mailpoet")})})),(0,g.jsxs)(g.Fragment,{children:[w,j]})}const Kn=Ut().shape({clicked:Ut().number,opened:Ut().number,unsubscribed:Ut().number,revenue:Ut().shape({count:Ut().number,currency:Ut().string,formatted:Ut().string,value:Ut().number})}),Qn=Ut().shape({status:Ut().string,count_processed:Ut().string.isRequired,count_total:Ut().string.isRequired,created_at:Ut().string,scheduled_at:Ut().string});Yn.propTypes={newsletter:Ut().shape({id:Ut().oneOfType([Ut().number,Ut().string]).isRequired,queue:Ut().oneOfType([Qn,Ut().bool]),total_sent:Ut().number,statistics:Ut().oneOfType([Kn,Ut().bool])}).isRequired,isSent:Ut().bool,currentTime:Ut().string},Yn.displayName="NewsletterStatistics";const Jn=(0,o.withBoundary)(Yn);var Zn=a(19718),Xn=a(16674),er=a(628),tr=a(79358),ar=a(65177);function ir(e,t=""){const a=encodeURIComponent(e),i=encodeURIComponent(t);return[{name:"facebook",url:`https://www.facebook.com/sharer/sharer.php?u=${a}`},{name:"x",url:`https://twitter.com/intent/tweet?url=${a}&text=${i}`},{name:"whatsapp",url:`https://wa.me/?text=${i}%20${a}`},{name:"email",url:`mailto:?subject=${i}&body=${a}`}]}const sr={facebook:(0,p.__)("Facebook","mailpoet"),x:(0,p.__)("X","mailpoet"),whatsapp:(0,p.__)("WhatsApp","mailpoet"),email:(0,p.__)("Email","mailpoet")},nr={idle:(0,p.__)("Copy to clipboard","mailpoet"),copied:(0,p.__)("Copied to clipboard","mailpoet"),failed:(0,p.__)("Could not copy to clipboard","mailpoet")},rr={idle:Xn.A,copied:ie.A,failed:er.A};function or(){return(0,g.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)("path",{fill:"currentColor",d:"M13.5 21v-7.2h2.4l.5-3h-2.9V8.9c0-.8.4-1.6 1.7-1.6h1.3V4.7c-.2 0-1.2-.2-2.3-.2-2.4 0-4 1.5-4 4.1v2.2H7.5v3h2.7V21h3.3Z"})})}function lr(){return(0,g.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)("path",{fill:"currentColor",d:"M14.2 10.4 21 3h-1.6l-5.9 6.4L8.8 3H3.3l7.1 9.6L3.3 21H5l6.2-7.3 5 7.3h5.5l-7.5-10.6Zm-2.2 2.5-.7-1-5.7-7.6H8l4.6 6.2.7 1 6 8.1h-2.4L12 12.9Z"})})}function dr(){return(0,g.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)("path",{fill:"currentColor",d:"M12 3.5a8.3 8.3 0 0 0-7.2 12.4L4 20.5l4.7-1.2A8.5 8.5 0 1 0 12 3.5Zm0 15.3c-1.1 0-2.2-.3-3.2-.8l-.3-.2-2.7.7.7-2.6-.2-.3A6.8 6.8 0 1 1 12 18.8Zm3.8-5.1c-.2-.1-1.2-.6-1.4-.7-.2 0-.3-.1-.5.1l-.6.8c-.1.2-.3.2-.5.1-.2-.1-1-.4-1.9-1.1-.7-.6-1.1-1.3-1.3-1.5-.1-.2 0-.4.1-.5l.4-.4.2-.4c.1-.1 0-.3 0-.4 0-.1-.5-1.2-.7-1.6-.2-.4-.4-.4-.5-.4h-.5c-.2 0-.4.1-.6.3-.2.2-.8.8-.8 1.9s.8 2.2.9 2.3c.1.2 1.6 2.5 3.9 3.5.5.2 1 .4 1.3.5.5.2 1 .1 1.4.1.4-.1 1.2-.5 1.4-1 .2-.5.2-.9.2-1 0-.1-.2-.2-.4-.3Z"})})}function cr(){return(0,g.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,g.jsx)("path",{fill:"currentColor",d:"M4.8 6h14.4c1 0 1.8.8 1.8 1.8v8.4c0 1-.8 1.8-1.8 1.8H4.8c-1 0-1.8-.8-1.8-1.8V7.8C3 6.8 3.8 6 4.8 6Zm7.2 6.4 7.1-4.9H4.9l7.1 4.9Zm-7.5 3.8c0 .2.1.3.3.3h14.4c.2 0 .3-.1.3-.3V8.9l-7.1 4.9a.8.8 0 0 1-.8 0L4.5 8.9v7.3Z"})})}const mr={facebook:(0,g.jsx)(or,{}),x:(0,g.jsx)(lr,{}),whatsapp:(0,g.jsx)(dr,{}),email:(0,g.jsx)(cr,{})};function ur({newsletter:e,onClose:t,onMakePublic:a}){const[i,s]=(0,r.useState)("idle"),n=`mailpoet-share-url-${e.id}`,o=e.campaign_name||e.subject||"",l=e.can_share&&e.share_url,d=e.is_share_supported,c="undefined"!=typeof navigator&&"function"==typeof navigator.share;return(0,g.jsx)(Te.A,{title:(0,p.__)("Share email","mailpoet"),onRequestClose:t,className:"mailpoet-share-email-modal",size:"medium",children:(0,g.jsxs)("div",{className:"mailpoet-share-email-modal__content","data-automation-id":"newsletter-share-modal",children:[(0,g.jsx)("p",{className:"mailpoet-share-email-modal__intro",children:(0,p.sprintf)((0,p.__)('Share "%s" using its public email page.',"mailpoet"),o)}),l?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-share-email-modal__url-row",children:[(0,g.jsx)(Zn.A,{id:n,className:"mailpoet-share-email-modal__url-control",type:"url",label:(0,p.__)("Public share link","mailpoet"),readOnly:!0,value:e.share_url||"",onChange:()=>{},onFocus:e=>e.target.select(),"data-automation-id":"newsletter-share-url",__next40pxDefaultSize:!0}),(0,g.jsx)(ge.Ay,{type:"button",variant:"secondary",icon:rr[i],disabled:"copied"===i,accessibleWhenDisabled:!0,onClick:()=>{(async()=>{await(0,ar.l)(n,e=>{e?(s("copied"),window.setTimeout(()=>s("idle"),3e3)):s("failed")},!0)})()},"data-automation-id":"newsletter-share-copy",__next40pxDefaultSize:!0,children:nr[i]})]}),(0,g.jsxs)("div",{className:"mailpoet-share-email-modal__actions",children:[c&&(0,g.jsx)(ge.Ay,{type:"button",variant:"secondary",icon:tr.A,onClick:()=>{(async()=>{navigator.share&&e.share_url&&await navigator.share({title:o,url:e.share_url})})()},"data-automation-id":"newsletter-share-native",__next40pxDefaultSize:!0,children:(0,p.__)("Share","mailpoet")}),ir(e.share_url,o).map(e=>(0,g.jsx)(ge.Ay,{href:e.url,target:"_blank",rel:"noopener noreferrer",className:`mailpoet-share-email-modal__social-button mailpoet-share-email-modal__social-button--${e.name}`,icon:mr[e.name],"data-automation-id":`newsletter-share-${e.name}`,__next40pxDefaultSize:!0,children:sr[e.name]},e.name))]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Fe.A,{status:"warning",isDismissible:!1,className:"mailpoet-share-email-modal__notice","data-automation-id":"newsletter-share-unavailable",children:e.share_unavailable_reason||(0,p.__)("This email cannot be shared yet.","mailpoet")}),d&&(0,g.jsx)("div",{className:"mailpoet-share-email-modal__footer",children:(0,g.jsx)(ge.Ay,{type:"button",variant:"primary",onClick:()=>a(e),"data-automation-id":"newsletter-share-make-public",__next40pxDefaultSize:!0,children:(0,p.__)("Make public and share","mailpoet")})})]})]})})}function pr(e,t){let a=null,i=!1,s=0;const n=Date.now(),r=()=>{i||(Date.now()-n>3e5?t.onError((0,p.__)("The export is taking longer than expected. Please try again later.","mailpoet")):(e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"getStatus",data:{task_id:e}}).then(e=>e.data))(e).then(e=>{i||(s=0,e.error?t.onError(e.error):e.exportFileURL?t.onComplete(e):a=window.setTimeout(r,2500))}).catch(e=>{if(!i){if(s+=1,s>=3){const a=e?.errors?.[0]?.message??(0,p.__)("Could not check the export status.","mailpoet");return void t.onError(a)}a=window.setTimeout(r,2500)}}))};return r(),{cancel:()=>{i=!0,null!==a&&(window.clearTimeout(a),a=null)}}}function hr(e){const t=new URLSearchParams(e);return Array.from(t.entries()).reduce((e,[t,a])=>a?{...e,[t]:a}:e,{})}function gr(e){try{return decodeURIComponent(e)}catch{return e}}function _r(e,t,a){const i=`#/${t}`;return e.startsWith(i)?e.slice(i.length).replace(/^\//,"").split("/").map(e=>(e.endsWith("]")?e.slice(0,-1):e).split("[")).reduce((e,[t,i])=>i?"group"===t&&a.includes(i)?{...e,group:i}:("page"===t||"paged"===t)&&Number(i)>0?{...e,page:Number(i)}:("per_page"===t||"limit"===t)&&Number(i)>0?{...e,perPage:Number(i)}:"sort_by"===t||"orderby"===t?{...e,orderby:i}:"sort_order"!==t&&"order"!==t||"asc"!==i&&"desc"!==i?"search"===t?{...e,search:gr(i)}:"filter"===t?{...e,filter:hr(i)}:e:{...e,order:i}:e,{}):{}}function fr(e,t,a,i,s){return`#/${e}${[["group","all"!==t?t:void 0],["filter",new URLSearchParams(i).toString()||void 0],["search",a.search?encodeURIComponent(a.search):void 0],["page",a.page&&1!==a.page?a.page:void 0],["limit",a.perPage&&a.perPage!==s.perPage?a.perPage:void 0],["sort_by",a.sort?.field&&a.sort.field!==s.sort?a.sort.field:void 0],["sort_order",a.sort?.direction&&a.sort.direction!==s.order?a.sort.direction:void 0]].reduce((e,[t,a])=>a?`${e}/${t}[${a}]`:e,"")}`}const br=Number(window.mailpoet_listing_per_page),xr=["all","trash"],vr=["all","draft","scheduled","sending","sent","trash"],yr=["all","active","draft","trash"],wr=["all","sending","sent","trash"];function jr(e){if(e&&"object"==typeof e){const t=e;return{...t,status:"string"==typeof t.status?t.status:""}}return{status:""}}const Sr={one:(0,p.__)("1 email was moved to the trash.","mailpoet"),many:(0,p.__)("%1$d emails were moved to the trash.","mailpoet")},kr={one:(0,p.__)("1 email was permanently deleted.","mailpoet"),many:(0,p.__)("%1$d emails were permanently deleted.","mailpoet")},Nr={one:(0,p.__)("1 email has been restored from the Trash.","mailpoet"),many:(0,p.__)("%1$d emails have been restored from the Trash.","mailpoet")};function Cr({type:e,baseUrl:t,parentId:a,fields:i,defaultFields:s,itemActions:n,defaultSort:o,emptyState:l,supportsExportStats:d=!1,supportedGroups:c=xr,getItemId:u,onItemsLoaded:h}){const _=(0,Ae.zy)(),f=(0,Ae.Zp)(),b=(0,r.useMemo)(()=>_r(window.location.hash,t,[...c]),[t,c]),[x,y]=(0,r.useState)(b.group??"all"),[w,j]=(0,r.useState)(b.filter??{}),[k,N]=(0,r.useState)([]),[C,E]=(0,r.useState)({method:null,log:{status:""}}),[U]=(0,r.useState)(()=>({type:"table",perPage:br,page:1,sort:o,fields:s,titleField:i[0]?.id,showTitle:!0})),I=(0,r.useCallback)(()=>(0,$e.Aq)(`newsletters-${e}`,U,i),[U,i,e]),[A]=(0,r.useState)(()=>{const e=I();return{...e,perPage:b.perPage??e.perPage,page:b.page??1,search:b.search,sort:{field:b.orderby??e.sort?.field??o.field,direction:b.order??e.sort?.direction??o.direction}}}),T=(0,r.useCallback)((t,i)=>{const s={...t,group:x,filter:w,type:e};return void 0!==a&&(s.parent_id=a),(0,fn.bL)(s,i)},[w,x,a,e]),{view:P,setView:R,onChangeView:D,items:F,meta:O,filters:M,groups:L,isLoading:$,error:B,clearError:W,refresh:V}=(0,$e.i7)({initialView:A,load:T});(0,r.useEffect)(()=>(0,fn.$0)(e=>{const t=jr(e.mta_log),a={meta:{...e,mta_log:t}};(0,yi.DP)(a),(0,yi.tQ)(a),E({method:e.mta_method??null,log:t})}),[]),(0,r.useEffect)(()=>{h?.(F)},[F,h]),(0,r.useEffect)(()=>{const e=()=>{0===k.length&&V()};return Ct()(document).on("heartbeat-tick.mailpoet-listing",e),()=>{Ct()(document).off("heartbeat-tick.mailpoet-listing",e)}},[V,k.length]),(0,r.useEffect)(()=>{const e=I(),a=fr(t,x,P,w,{sort:e.sort?.field??o.field,order:e.sort?.direction??o.direction,perPage:e.perPage??br});window.location.hash!==a&&window.history.replaceState(null,"",a)},[t,o.direction,o.field,w,I,x,P]),(0,r.useEffect)(()=>{const e=()=>{const e=_r(window.location.hash,t,[...c]);y(e.group??"all"),j(e.filter??{}),N([]),W();const a=I();R(t=>({...t,page:e.page??1,perPage:e.perPage??a.perPage,search:e.search??"",sort:{field:e.orderby??a.sort?.field??o.field,direction:e.order??a.sort?.direction??o.direction}}))};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[t,W,o.direction,o.field,I,R,c]);const q=(0,r.useMemo)(()=>({type:e,group:x,filter:w,search:P.search??"",parent_id:a}),[w,x,a,e,P.search]),H=(0,r.useCallback)(e=>{m.U.Notice.error(e.message||(0,p.__)("The action could not be completed. Please try again.","mailpoet"),{scroll:!0})},[]),z=(0,r.useCallback)(async(e,t,a=!1,i={},s=q)=>{if(0!==t.length||a)try{const n=await(0,fn.XE)(e,{...s,selection:t,select_all:a},i);if(N([]),"export_stats"===e){const e="string"==typeof i.format?i.format:"csv";return void function(e,t){e.task_id?(m.U.Notice.success((0,p.__)("Export queued. The download will start automatically when it is ready.","mailpoet"),{timeout:6e3}),pr(e.task_id,{onComplete:e=>{e.exportFileURL?(m.U.trackEvent("Email statistics export completed",{"File Format":t,"Export Type":"bulk"}),window.location.href=e.exportFileURL):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})},onError:e=>{m.U.Notice.error(e,{scroll:!0})}})):m.U.Notice.error((0,p.__)("Could not start the export.","mailpoet"),{scroll:!0})}(n.data,e)}!function(e,t){const a=function(e){return e.toLocaleString()}(t);"trash"===e?m.U.Notice.success(1===t?Sr.one:Sr.many.replace("%1$d",a)):"delete"===e?m.U.Notice.success(1===t?kr.one:kr.many.replace("%1$d",a)):"restore"===e&&m.U.Notice.success(1===t?Nr.one:Nr.many.replace("%1$d",a))}(e,n.data.count),V()}catch(e){H(e)}},[H,q,V]),G=(0,r.useCallback)(async(e,t,a={})=>{const i=t.map(e=>Number(e.id)).filter(e=>Number.isFinite(e));await z(e,i,!1,a)},[z]),Y=(0,r.useCallback)(e=>{N([]),D(e)},[D]),K=(0,$e.wh)(`newsletters-${e}`,P,Y),Q=(0,r.useCallback)(e=>{N(e)},[]),J=(0,r.useCallback)(e=>{e!==x&&(y(e),N([]),W(),R(e=>({...e,page:1})))},[W,x,R]),Z=(0,r.useCallback)((e,t)=>{j(a=>{const i={...a};return t?i[e]=t:delete i[e],i}),N([]),R(e=>({...e,page:1}))},[R]),X=(0,r.useMemo)(()=>{const e={all:null,trash:null};return c.forEach(t=>{e[t]=null}),(L??[]).forEach(t=>{t.name in e&&(e[t.name]=t.count)}),e},[L,c]);(0,r.useEffect)(()=>{"trash"!==x||$||B||0!==X.trash||P.search||0!==Object.keys(w).length||(y("all"),N([]),R(e=>({...e,page:1})))},[w,x,X.trash,$,B,R,P.search]);const ee=(0,r.useMemo)(()=>(L??[]).filter(e=>e.name in X&&!("trash"===e.name&&0===e.count&&"trash"!==x)),[x,X,L]),te=(0,r.useMemo)(()=>({refresh:V,navigate:e=>f(e),location:{pathname:_.pathname}}),[_.pathname,f,V]),ae=(0,r.useMemo)(()=>{const e=[{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"!==x,callback:e=>{G("trash",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"===x,callback:e=>{G("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),context:"list",supportsBulk:!0,isEligible:()=>"trash"===x,callback:e=>{G("delete",e)}}];return d&&e.push({id:"export_stats",label:(0,p.__)("Export statistics","mailpoet"),context:"list",supportsBulk:!0,isEligible:e=>"trash"!==x&&"sent"===e.status,callback:e=>{G("export_stats",e,{format:"csv"})}}),e},[x,G,d]),ie=(0,r.useMemo)(()=>[...n?n(te):[],...ae],[te,ae,n]),se=(0,r.useMemo)(()=>({totalItems:O.count,totalPages:O.pages}),[O]),ne=(0,r.useCallback)(()=>{z("delete",[],!0,{},{type:e,group:"trash",parent_id:a})},[z,a,e]),re=(0,r.useMemo)(()=>Object.keys(M).filter(e=>{const t=M[e]??[];return!(0===t.length||1===t.length&&!t[0].value)}),[M]);return(0,r.useMemo)(()=>{const{all:e,trash:t}=X;return null!==e&&null!==t&&0===e&&0===t},[X])&&l?(0,g.jsx)(g.Fragment,{children:l(0)}):(0,g.jsxs)("div",{children:[C.method&&(0,g.jsx)(S,{mtaMethod:C.method,mtaLog:C.log}),B&&(0,g.jsx)(Fe.A,{status:"error",onRemove:W,children:"Failed to load data."===B?(0,p.__)("Failed to load emails.","mailpoet"):B}),(0,g.jsx)("div",{className:"mailpoet-categories mailpoet-dataviews__tabs mailpoet-newsletters-dataviews__tabs",children:(0,g.jsx)("div",{className:"components-tab-panel__tabs",role:"tablist",children:ee.map(e=>{const t=v()("components-button","components-tab-panel__tabs-item",`mailpoet-dataviews-group-${e.name}`,{"is-active":e.name===x});return(0,g.jsxs)("a",{href:"#",role:"tab","aria-selected":e.name===x,className:t,"data-automation-id":`filters_${e.name}`,onClick:t=>{t.preventDefault(),J(e.name)},children:[(0,g.jsx)("span",{"data-title":e.label,children:e.label}),Number(e.count)>0&&(0,g.jsx)("span",{className:"count",children:Number(e.count).toLocaleString()})]},e.name)})})}),(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-newsletters-dataviews mailpoet-listing","data-automation-id":`newsletters_listing_${e}`,children:(0,g.jsxs)(Le.A,{data:F,fields:i,view:P,onChangeView:K,actions:ie,paginationInfo:se,defaultLayouts:{table:{}},getItemId:e=>u?u(e):String(e.id),selection:k,onChangeSelection:Q,isLoading:$,empty:(0,g.jsx)("p",{children:P.search?(0,p.__)("No emails found.","mailpoet"):(0,p.__)("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")}),children:[(0,g.jsxs)("div",{className:"mailpoet-dataviews__toolbar mailpoet-newsletters-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search","mailpoet")}),(re.length>0||"trash"===x)&&(0,g.jsxs)("div",{className:"mailpoet-listing-filters",children:[re.map(e=>(0,g.jsx)(Be.Select,{isMinWidth:!0,dimension:"small",name:e,value:w[e]??"",automationId:`listing_filter_${e}`,onChange:t=>Z(e,t.currentTarget.value),children:M[e].map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},`filter-option-${e.value}`))},`filter-${e}`)),"trash"===x&&(0,g.jsx)(ge.Ay,{variant:"secondary",size:"compact","data-automation-id":"empty_trash",onClick:ne,children:(0,p.__)("Empty Trash","mailpoet")})]}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})})]})}const Er=m.U.trackingConfig.emailTrackingEnabled;function Ur(){const[e,t]=(0,r.useState)(null),a=(0,r.useRef)(null),i=(0,r.useCallback)(e=>{t(e),m.U.trackEvent("Emails > Share modal opened")},[]),s=(0,r.useCallback)(()=>t(null),[]),n=(0,r.useCallback)(async e=>{try{const i=await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"updateShareVisibility",data:{id:e.id,share_visibility:"public"}});t(i.data),a.current?.(),m.U.trackEvent("Emails > Share email made public")}catch(e){const t=e;t.errors&&t.errors.length>0&&m.U.Notice.showApiErrorNotice(t,{scroll:!0})}},[]),[l,d]=(0,r.useState)(void 0),[c,u]=(0,r.useState)({status:""});(0,r.useEffect)(()=>(0,fn.$0)(e=>{d(e.current_time||void 0),u(jr(e.mta_log))}),[]);const h=(0,r.useMemo)(()=>function(e,t={status:""}){return[{id:"name",label:(0,p.__)("Subject","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,getValue:({item:e})=>e.campaign_name||e.subject,render:({item:e})=>{const t=e.queue&&e.queue.newsletter_rendered_subject||e.subject;return(0,g.jsx)("a",{className:"mailpoet-listing-title",href:"#","data-automation-id":`listing_item_${e.id}`,onClick:t=>{t.preventDefault(),(0,yi.$U)(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:t})]}):t})}},{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)(zn,{newsletter:e,mailerLog:t})},{id:"segments",label:(0,p.__)("Lists","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsxs)(o.ErrorBoundary,{children:[(0,g.jsx)(Bn.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(Bn.y,{newsletter:e,dimension:"large"})]})},...Er?[{id:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:t})=>(0,g.jsx)(Jn,{newsletter:t,currentTime:e})}]:[],{id:"sent_at",label:(0,p.__)("Sent on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>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}]}(l,c),[l,c]),_=(0,r.useCallback)(e=>(0,yi.pE)([{id:"preview",label:(0,p.__)("Preview","mailpoet"),context:"single",supportsBulk:!1,callback:e=>{const t=e[0];t?.preview_url&&window.open(String(t.preview_url),"_blank","noopener,noreferrer")}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,callback:e=>{e[0]&&(0,yi.$U)(e[0])}},{id:"share",label:(0,p.__)("Share","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,isEligible:e=>Boolean(e.is_share_supported),callback:t=>{t[0]&&(a.current=e.refresh,i(t[0]))}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),context:"single",supportsBulk:!1,callback:t=>{const a=t[0];a&&(async()=>{try{const t=await(0,fn.r3)(Number(a.id));m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,Me.Zn)(t.data.subject))),e.refresh()}catch(e){const t=e;m.U.Notice.error(t.message||(0,p.__)("The action could not be completed.","mailpoet"),{scroll:!0})}})()}}],e.navigate),[i]),f=Er&&!function(){const e=m.U.capabilities?.detailedAnalytics;return!e||e.isRestricted}();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Cr,{type:"standard",baseUrl:"standard",fields:h,defaultFields:["status","segments",...Er?["statistics"]:[],"sent_at"],defaultSort:{field:"sent_at",direction:"desc"},itemActions:_,supportsExportStats:f,supportedGroups:vr,emptyState:()=>(0,g.jsx)(pi,{filter:e=>"standard"===e.slug,hideScreenOptions:!1})}),e&&(0,g.jsx)(ur,{newsletter:e,onClose:s,onMakePublic:()=>{n(e)}})]})}Ur.displayName="NewsletterListStandard";const Ir=(0,o.withBoundary)(Ur);var Ar=a(95069);function Tr(){const[e,t]=(0,r.useState)({}),a=(0,r.useRef)(null),i=(0,r.useCallback)((e,i)=>{const s=String(e.id),n=i?"active":"draft";t(e=>({...e,[s]:n})),(async()=>{try{"active"===(await(0,fn.M4)(Number(e.id),n)).data.status&&m.U.Notice.success((0,p.__)("Your post notification is now active!","mailpoet")),a.current?.()}catch(a){t(t=>({...t,[s]:"active"===e.status?"active":"draft"})),m.U.Notice.error(a.message||(0,p.__)("Could not update the post notification status.","mailpoet"))}})()},[]),s=(0,r.useCallback)(e=>{t(t=>{const a=Object.keys(t);if(0===a.length)return t;const i={};return a.forEach(a=>{const s=e.find(e=>String(e.id)===a);s&&s.status===t[a]||(i[a]=t[a])}),Object.keys(i).length===a.length?t:i})},[]),n=(0,r.useMemo)(()=>function(e,t){return[{id:"subject",label:(0,p.__)("Subject","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,render:({item:e})=>(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),"data-automation-id":`listing_item_${e.id}`,onClick:t=>{t.preventDefault(),(0,yi.$U)(e)},children:e.subject})},{id:"settings",label:(0,p.__)("Settings","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>function(e){if(!e.segments||0===e.segments.length)return(0,g.jsx)(Ie.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,p.__)("You need to select a list to send to.","mailpoet")});const t=b()((0,p.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(Bn.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(Bn.y,{newsletter:e},`filter-segment-${a}`)]},a)),a=e.options??{},i=(e,t)=>{if(!e||void 0===t)return"";const a=e[t];return null!=a?String(a):""},s=Ts(m.U.wpWeekStartsOn),n=Ps(m.U.wpWeekStartsOn);let o="";switch(a.intervalType){case"daily":o=(0,p.__)("Daily at %1$s","mailpoet").replace("%1$s",i(Ss,a.timeOfDay));break;case"weekly":o=(0,p.__)("Weekly on %1$s at %2$s","mailpoet").replace("%1$s",Fs(a.weekDay??"",ks,s,n)).replace("%2$s",i(Ss,a.timeOfDay));break;case"monthly":o=(0,p.__)("Monthly on the %1$s at %2$s","mailpoet").replace("%1$s",Fs(a.monthDay??"",Ns,Es)).replace("%2$s",i(Ss,a.timeOfDay));break;case"nthWeekDay":o=(0,p.__)("Every %1$s %2$s of the month at %3$s","mailpoet").replace("%1$s",i(Cs,a.nthWeekDay)).replace("%2$s",i(ks,a.weekDay)).replace("%3$s",i(Ss,a.timeOfDay));break;case"immediately":o=(0,p.__)("Immediately","mailpoet");break;default:o="Invalid sending frequency"}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)(Ar.x,{})}),o]})]})}(e)},{id:"history",label:(0,p.__)("History","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>0===Number(e.children_count??0)?(0,g.jsx)("span",{className:"mailpoet-listing-status-unknown mailpoet-font-extra-small mailpoet-listing-notification-status",children:(0,p.__)("Not sent yet","mailpoet")}):(0,g.jsx)(Ie.Link,{className:"mailpoet-nowrap","data-automation-id":`history-${e.id}`,to:`/notification/history/${e.id}`,children:(0,g.jsx)(Ge.$,{className:"mailpoet-hide-on-mobile",dimension:"small",children:(0,p.__)("View history","mailpoet")})})},{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:a})=>{const i=t[String(a.id)]??a.status;return(0,g.jsx)(Xi.l,{className:"mailpoet-listing-status-toggle",onCheck:t=>{e(a,t)},"data-id":a.id,dimension:"small",checked:"active"===i})}},{id:"updated_at",label:(0,p.__)("Last modified on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>e.updated_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(e.updated_at),(0,g.jsx)("br",{}),m.U.Date.time(e.updated_at)]}):null}]}(i,e),[i,e]),o=(0,r.useCallback)(e=>(a.current=e.refresh,[{id:"preview",label:(0,p.__)("Preview","mailpoet"),context:"single",supportsBulk:!1,callback:e=>{const t=e[0];t?.preview_url&&window.open(String(t.preview_url),"_blank","noopener,noreferrer")}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,callback:e=>{e[0]&&(0,yi.$U)(e[0])}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),context:"single",supportsBulk:!1,callback:t=>{const a=t[0];a&&(async()=>{try{const t=await(0,fn.r3)(Number(a.id));m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,Me.Zn)(t.data.subject))),e.refresh()}catch(e){const t=e;m.U.Notice.error(t.message||(0,p.__)("The action could not be completed.","mailpoet"),{scroll:!0})}})()}}]),[]);return(0,g.jsx)(Cr,{type:"notification",baseUrl:"notification",fields:n,defaultFields:["settings","history","status","updated_at"],defaultSort:{field:"updated_at",direction:"desc"},itemActions:o,onItemsLoaded:s,supportedGroups:yr,emptyState:()=>(0,g.jsx)(pi,{filter:e=>"notification"===e.slug,hideScreenOptions:!1})})}Tr.displayName="NewsletterListNotification";const Pr=(0,o.withBoundary)(Tr),Rr=m.U.trackingConfig.emailTrackingEnabled;function Dr(){const[e,t]=(0,r.useState)({}),a=(0,r.useRef)(null),i=(0,r.useCallback)((e,i)=>{const s=String(e.id),n=i?"active":"draft";t(e=>({...e,[s]:n})),(async()=>{try{"active"===(await(0,fn.M4)(Number(e.id),n)).data.status&&m.U.Notice.success((0,p.__)("Your Re-engagement Email is now activated!","mailpoet")),a.current?.()}catch(a){t(t=>({...t,[s]:"active"===e.status?"active":"draft"})),m.U.Notice.error(a.message||(0,p.__)("Could not update the re-engagement email status.","mailpoet"))}})()},[]),s=(0,r.useCallback)(e=>{t(t=>{const a=Object.keys(t);if(0===a.length)return t;const i={};return a.forEach(a=>{const s=e.find(e=>String(e.id)===a);s&&s.status===t[a]||(i[a]=t[a])}),Object.keys(i).length===a.length?t:i})},[]),n=(0,r.useMemo)(()=>function(e,t){return[{id:"subject",label:(0,p.__)("Subject","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,render:({item:e})=>(0,g.jsx)("a",{className:"mailpoet-listing-title",href:m.U.getActiveEmailEditorUrl(e),"data-automation-id":`listing_item_${e.id}`,onClick:t=>{t.preventDefault(),(0,yi.$U)(e)},children:e.subject})},{id:"settings",label:(0,p.__)("Settings","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>function(e){if(!e.segments||0===e.segments.length)return(0,g.jsx)(Ie.Link,{className:"mailpoet-listing-error",to:`/send/${e.id}`,children:(0,p.__)("You need to select a list to send to.","mailpoet")});const t=b()((0,p.__)("Send to %1$s","mailpoet"),"%1$s",(t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsx)(Bn.vC,{segments:e.segments},`segment-${a}`),(0,g.jsx)(Bn.y,{newsletter:e},`filter-segment-${a}`)]},a)),a=e.options??{},i=Number(a.afterTimeNumber??0),s="weeks"!==a.afterTimeType;let n=s?(0,p._x)("month",'month in the sentence "1 month after inactivity"',"mailpoet"):(0,p._x)("week",'week in the sentence "1 week after inactivity"',"mailpoet");i>1&&(n=s?(0,p._x)("months",'months in the sentence "5 months after inactivity"',"mailpoet"):(0,p._x)("weeks",'weeks in the sentence "5 weeks after inactivity"',"mailpoet"));const o=(0,p._x)("{$count} {$frequency} after inactivity",'example: "5 months after inactivity"',"mailpoet").replace("{$count}",String(i)).replace("{$frequency}",n);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)(Ar.x,{})}),o]})]})}(e)},...Rr?[{id:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>{const t=Number(e.total_sent??0);return(0,g.jsx)(Jn,{newsletter:e,isSent:t>0&&!!e.statistics})}}]:[],{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:a})=>{const i=Number(a.total_sent??0),s=(0,p._x)("%1$d sent","number of welcome emails sent","mailpoet").replace("%1$d",i.toLocaleString()),n=t[String(a.id)]??a.status;return(0,g.jsxs)("div",{children:[(0,g.jsx)(Xi.l,{className:"mailpoet-listing-status-toggle",onCheck:t=>{e(a,t)},"data-id":a.id,dimension:"small",checked:"active"===n}),(0,g.jsx)("p",{className:"mailpoet-listing-stats-description",children:(0,g.jsx)(Ie.Link,{to:`/sending-status/${a.id}`,"data-automation-id":`sending_status_${a.id}`,children:s})})]})}},{id:"updated_at",label:(0,p.__)("Last modified on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>e.updated_at?(0,g.jsxs)(g.Fragment,{children:[m.U.Date.short(e.updated_at),(0,g.jsx)("br",{}),m.U.Date.time(e.updated_at)]}):null}]}(i,e),[i,e]),o=(0,r.useCallback)(e=>(a.current=e.refresh,(0,yi.pE)([{id:"preview",label:(0,p.__)("Preview","mailpoet"),context:"single",supportsBulk:!1,callback:e=>{const t=e[0];t?.preview_url&&window.open(String(t.preview_url),"_blank","noopener,noreferrer")}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),context:"single",supportsBulk:!1,callback:t=>{const a=t[0];a&&(async()=>{try{const t=await(0,fn.r3)(Number(a.id));m.U.Notice.success((0,p.__)('Email "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,Me.Zn)(t.data.subject))),e.refresh()}catch(e){m.U.Notice.error(e.message||(0,p.__)("The action could not be completed.","mailpoet"),{scroll:!0})}})()}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,callback:e=>{e[0]&&(0,yi.$U)(e[0])}}],e.navigate)),[]);return(0,g.jsx)(Cr,{type:"re_engagement",baseUrl:"re_engagement",fields:n,defaultFields:["settings",...Rr?["statistics"]:[],"status","updated_at"],defaultSort:{field:"updated_at",direction:"desc"},itemActions:o,onItemsLoaded:s,supportedGroups:yr,emptyState:()=>(0,g.jsx)(pi,{filter:e=>"re_engagement"===e.slug,hideScreenOptions:!1})})}Dr.displayName="NewsletterListReEngagement";const Fr=(0,o.withBoundary)(Dr),Or=m.U.trackingConfig.emailTrackingEnabled;function Mr({parentId:e}){const[t,a]=(0,r.useState)(void 0),[i,s]=(0,r.useState)({status:""});(0,r.useEffect)(()=>(0,fn.$0)(e=>{a(e.current_time||void 0),s(jr(e.mta_log))}),[]);const n=(0,r.useMemo)(()=>function(e,t={status:""}){return[{id:"subject",label:(0,p.__)("Subject","mailpoet"),enableSorting:!1,enableGlobalSearch:!0,render:({item:e})=>{const t=e.queue&&e.queue.newsletter_rendered_subject||e.subject;return(0,g.jsx)("a",{className:"mailpoet-listing-title",href:e.preview_url,target:"_blank",rel:"noopener noreferrer","data-automation-id":`listing_item_${e.id}`,children:t})}},{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)(zn,{newsletter:e,mailerLog:t})},{id:"segments",label:(0,p.__)("Lists","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Bn.vC,{segments:e.segments,dimension:"large"}),(0,g.jsx)(Bn.y,{newsletter:e,dimension:"large"})]})},...Or?[{id:"statistics",label:(0,p.__)("Clicked, Opened","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:t})=>(0,g.jsx)(Jn,{newsletter:t,currentTime:e})}]:[],{id:"sent_at",label:(0,p.__)("Sent on","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>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}]}(t,i),[t,i]),o=(0,r.useMemo)(()=>e=>(0,yi.pE)([{id:"preview",label:(0,p.__)("Preview","mailpoet"),context:"single",supportsBulk:!1,callback:e=>{const t=e[0];t?.preview_url&&window.open(String(t.preview_url),"_blank","noopener,noreferrer")}}],e.navigate),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("p",{children:(0,g.jsx)(Ie.Link,{className:"mailpoet-button button button-secondary button-small",to:"/notification",children:(0,p.__)("Back to Post notifications","mailpoet")})}),(0,g.jsx)(Cr,{type:"notification_history",baseUrl:`notification/history/${e}`,parentId:Number(e),fields:n,defaultFields:["status","segments",...Or?["statistics"]:[],"sent_at"],defaultSort:{field:"sent_at",direction:"desc"},itemActions:o,supportedGroups:wr})]})}Mr.displayName="NewsletterListNotificationHistory";const Lr=(0,o.withBoundary)(Mr);(0,$e.tN)(window.mailpoet_newsletters_api);const $r=new Map;const Br=Number(window.mailpoet_listing_per_page),Wr=["all","sent","failed","unprocessed"],Vr={field:"failed",direction:"desc"},qr={unprocessed:(0,p.__)("Unprocessed","mailpoet"),sent:(0,p.__)("Sent","mailpoet"),failed:(0,p.__)("Failed","mailpoet")},Hr=(0,p.__)("Sending status","mailpoet");function zr({newsletter:e}){return e.id&&e.subject&&e.sent?(0,g.jsx)("p",{children:(0,g.jsx)(Ie.Link,{to:`/stats/${e.id}`,children:e.subject})}):null}function Gr(){const e=(0,Ae.g)(),t=Number(e.id),a=`sending-status/${e.id}`,[i,s]=(0,r.useState)({id:e.id??"",subject:"",sent:!1});(0,r.useEffect)(()=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:t}}).done(t=>s({id:e.id??"",subject:t.data.subject,sent:null!==t.data.sent_at})).fail(e=>m.U.Notice.showApiErrorNotice(e))},[t,e.id]);const n=(0,r.useMemo)(()=>_r(window.location.hash,a,[...Wr]),[a]),[o,l]=(0,r.useState)(n.group??"all"),d=(0,r.useMemo)(()=>[{id:"subscriberId",label:(0,p.__)("Subscriber","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,getValue:({item:e})=>e.email,render:({item:e})=>(0,g.jsxs)("div",{"data-automation-id":`name_${e.taskId}_${e.subscriberId}`,children:[(0,g.jsx)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-subscribers#/edit/${e.subscriberId}`,children:e.email}),(0,g.jsx)("div",{className:"mailpoet-listing-subtitle",children:`${e.firstName} ${e.lastName}`})]})},{id:"failed",label:Hr,enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{let t=qr.unprocessed;return e.processed&&(t=e.failed?qr.failed:qr.sent),(0,g.jsx)("span",{"data-automation-id":`status_${e.taskId}_${e.subscriberId}`,children:t})}},{id:"error",label:(0,p.__)("Failure reason (if applicable)","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,g.jsx)("span",{"data-automation-id":`error_${e.taskId}_${e.subscriberId}`,children:e.error??""})}],[]),c=(0,r.useCallback)(()=>(0,$e.Aq)("sending-status",{type:"table",perPage:Br,page:1,sort:Vr,fields:["failed","error"],titleField:"subscriberId",showTitle:!0},d),[d]),[u]=(0,r.useState)(()=>{const e=c();return{...e,perPage:n.perPage??e.perPage,page:n.page??1,search:n.search,sort:{field:n.orderby??e.sort?.field??Vr.field,direction:n.order??e.sort?.direction??Vr.direction}}}),h=(0,r.useCallback)(async(e,a)=>{const i=await function(e,t,a){return function(e){let t=$r.get(e);return t||(t=(0,$e.gU)((e=>`/mailpoet/v1/newsletters/${e}/sending-status`)(e)),$r.set(e,t)),t}(e)(t,a)}(t,{...e,group:o},a),s={meta:{mta_log:i.mta_log&&"object"==typeof i.mta_log?i.mta_log:{},cron_accessible:i.cron_accessible}};return(0,yi.DP)(s),(0,yi.tQ)(s),i},[o,t]),{view:_,setView:f,onChangeView:b,items:x,meta:y,groups:w,isLoading:j,error:S,clearError:k,refresh:N}=(0,$e.i7)({initialView:u,load:h}),C=(0,$e.wh)("sending-status",_,b);(0,r.useEffect)(()=>{const e=c(),t=fr(a,o,_,{},{sort:e.sort?.field??Vr.field,order:e.sort?.direction??Vr.direction,perPage:e.perPage??Br});window.location.hash!==t&&window.history.replaceState(null,"",t)},[a,c,o,_]),(0,r.useEffect)(()=>{const e=()=>{const e=_r(window.location.hash,a,[...Wr]);l(e.group??"all"),k();const t=c();f(a=>({...a,page:e.page??1,perPage:e.perPage??t.perPage,search:e.search??"",sort:{field:e.orderby??t.sort?.field??Vr.field,direction:e.order??t.sort?.direction??Vr.direction}}))};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[a,k,c,f]),(0,r.useEffect)(()=>{const e=()=>N();return Ct()(document).on("heartbeat-tick.mailpoet-sending-status",e),()=>{Ct()(document).off("heartbeat-tick.mailpoet-sending-status",e)}},[N]);const E=(0,r.useCallback)(e=>{e!==o&&(l(e),k(),f(e=>({...e,page:1})))},[k,o,f]),U=(0,r.useCallback)(e=>{(function(e,t,a){return(0,$e.J8)((e=>`/mailpoet/v1/newsletters/${e}/sending-status/resend`)(e),{task_id:t,subscriber_id:a})})(t,e.taskId,e.subscriberId).then(()=>N()).catch(e=>{m.U.Notice.error(e.message||(0,p.__)("The email could not be resent. Please try again.","mailpoet"),{scroll:!0})})},[t,N]),I=(0,r.useMemo)(()=>[{id:"resend",label:(0,p.__)("Resend","mailpoet"),context:"single",isPrimary:!0,supportsBulk:!1,isEligible:e=>Boolean(e.failed),callback:e=>{e[0]&&U(e[0])}}],[U]),A=(0,r.useMemo)(()=>(w??[]).filter(e=>Wr.includes(e.name)),[w]),T=(0,r.useMemo)(()=>({totalItems:y.count,totalPages:y.pages}),[y]),P=i.sent&&!j&&!S&&"all"===o&&!_.search&&0===y.count;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h1",{children:(0,p.__)("Sending status","mailpoet")}),(0,g.jsx)(zr,{newsletter:i}),P&&(0,g.jsx)("p",{className:"mailpoet-notice mailpoet-notice-info",children:(0,Oe.A)((0,p.__)("Sending status data is no longer available. Per-subscriber records for this newsletter have been cleaned up. You can adjust the retention period in <link>Advanced settings</link>.","mailpoet"),{link:(0,g.jsx)("a",{href:"admin.php?page=mailpoet-settings#/advanced",children:" "})})}),S&&(0,g.jsx)(Fe.A,{status:"error",onRemove:k,children:"Failed to load data."===S?(0,p.__)("Failed to load the sending status.","mailpoet"):S}),(0,g.jsx)("div",{className:"mailpoet-categories mailpoet-dataviews__tabs",children:(0,g.jsx)("div",{className:"components-tab-panel__tabs",role:"tablist",children:A.map(e=>{const t=v()("components-button","components-tab-panel__tabs-item",`mailpoet-dataviews-group-${e.name}`,{"is-active":e.name===o});return(0,g.jsxs)("a",{href:"#",role:"tab","aria-selected":e.name===o,className:t,"data-automation-id":`filters_${e.name}`,onClick:t=>{t.preventDefault(),E(e.name)},children:[(0,g.jsx)("span",{"data-title":e.label,children:e.label}),Number(e.count)>0&&(0,g.jsx)("span",{className:"count",children:Number(e.count).toLocaleString()})]},e.name)})})}),(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-listing","data-automation-id":"sending_status_listing",children:(0,g.jsxs)(Le.A,{data:x,fields:d,view:_,onChangeView:C,actions:I,paginationInfo:T,defaultLayouts:{table:{}},getItemId:e=>`${e.taskId}-${e.subscriberId}`,isLoading:j,empty:(0,g.jsx)("p",{children:(0,p.__)("No sending task found.","mailpoet")}),children:[(0,g.jsxs)("div",{className:"mailpoet-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})})]})}Gr.displayName="SendingStatus";var Yr=a(14051),Kr=a(65270),Qr=a(38255),Jr=a.n(Qr);function Zr({installedDaysAgo:e,reviewRequestIllustrationUrl:t,username:a}){const i=Math.round(e/30),s=e>30?(0,p.sprintf)((0,p._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,p.sprintf)((0,p._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,p.__)("Thank you! Time to tell the world?","mailpoet")}),(0,g.jsx)("p",{children:(0,p.sprintf)((0,p.__)("%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,Me.Zn)(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,p.__)("Rate us now","mailpoet")})}),(0,g.jsx)("p",{children:(0,g.jsx)("a",{id:"mailpoet_review_request_not_now",children:(0,p.__)("Not now")})})]})}const Xr=(e=null)=>new Promise((t,a)=>{window.mailpoet_display_nps_poll&&window.mailpoet_3rd_party_libs_enabled?(_n||(_n=m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"analytics",action:"getTrackingData"})),_n).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),Jr()({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:Kr.renderToString(Zr({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()}),eo=e=>function(t){return(0,r.useLayoutEffect)(()=>{Xr().catch(()=>{})},[]),(0,g.jsx)(e,{...t})};function to(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ke,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(qe.z,{heading:(0,p.__)("Emails","mailpoet"),children:(0,g.jsx)(Ie.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,p.__)("Add new email","mailpoet")})})]})}function ao({children:e}){const t=(0,Ae.zy)();return null!==(0,gi.S)(t)||(e=>e.hash.match(/^#\/new/)||e.pathname.match(/^\/new/))(t)?null:e}function io(){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:".wrap { margin: 0 !important; }"}})}ao.propTypes={children:Ut().node.isRequired};var so=a(59617),no=a(16791);const ro=e=>{const t=e<.1?2:1;return m.U.Num.toLocaleFixed(e,t)},oo=e=>+(+e).toFixed(1);function lo({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=ro(i),d=ro(s),c=ro(n),u=ro(r),h=ro(o),_=a>=20&&e.statistics.opened>=5,f=e.statistics.unsubscribed>=5&&a>=100,x=e.statistics.bounced>=5&&a>=100,v=(0,pa.u)("opened",s)||"",y=(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-${v}`,children:[d,"% "]}),(0,p._x)("opened","Percentage of subscribers that opened a newsletter link","mailpoet")]}),_&&(0,g.jsx)(pa.f,{isInverted:!1,stat:"opened",rate:s,tooltipId:`opened-${e.id||"0"}`,tooltipPlace:"right"})]}),w=(0,g.jsxs)("div",{className:"mailpoet-statistics-value-small",children:[(0,g.jsxs)("span",{className:"mailpoet-statistics-value-number",children:[c,"% "]}),(0,p._x)("machine-opened","Percentage of newsletters that were opened by a machine","mailpoet"),(0,g.jsx)(He.Tooltip,{tooltip:b()((0,p.__)("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"))})]}),j=oo(r),S=f?(0,pa.u)("unsubscribed",j):"",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-${S}`,children:[u,"% "]}),(0,p._x)("unsubscribed","Percentage of subscribers that unsubscribed from a newsletter","mailpoet")]}),f&&(0,g.jsx)(pa.f,{isInverted:!1,stat:"unsubscribed",rate:j,tooltipId:`unsubscribed-${e.id||"0"}`,tooltipPlace:"right"})]}),N=oo(o),C=x?(0,pa.u)("bounced",N):"",E=(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,p._x)("bounced","Percentage of subscribers that bounced from a newsletter","mailpoet")]}),x&&(0,g.jsx)(pa.f,{isInverted:!1,stat:"bounced",rate:N,tooltipId:`bounced-${e.id||"0"}`,tooltipPlace:"right"})]}),U=(0,pa.u)("clicked",i),I=(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-${U}`,children:[l,"% "]}),(0,p._x)("clicked","Percentage of subscribers that clicked a newsletter link","mailpoet")]}),_&&(0,g.jsx)(pa.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)(Ei.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,p.__)("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:k}),(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:E})]}),(0,g.jsxs)(Ei.Grid.ThreeColumns,{children:[(0,g.jsx)("div",{children:I}),(0,g.jsxs)("div",{className:"mailpoet-statistics-with-left-separator",children:[y,m.U.trackingConfig.opensSeparated&&w]}),t&&(0,g.jsx)("div",{className:"mailpoet-statistics-with-left-separator",children:Sa.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,p.__)("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,p.__)("Sending status","mailpoet")})})]})]})}lo.displayName="NewsletterGeneralStats";var co=a(81692);function mo(e,t){m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"exportCampaign",data:{id:e,format:t}}).always(()=>{m.U.Modal.loading(!1)}).done(e=>{const a=e.data?.exportFileURL;a?(m.U.trackEvent("Email statistics export completed",{"File Format":t,"Export Type":"aggregate"}),window.location.href=a):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})}function uo({newsletter:e}){const[t,a]=(0,r.useState)(!1),{start:i,isExporting:s}=(e=>{const[t,a]=(0,r.useState)(!1),i=(0,r.useRef)(null),s=(0,r.useCallback)(()=>{null!==i.current&&(i.current(),i.current=null)},[]);(0,r.useEffect)(()=>s,[s]);const n=(0,r.useCallback)((e,t)=>{a(!1),e.exportFileURL?(m.U.trackEvent("Email statistics export completed",{"File Format":t,"Export Type":"recipients"}),window.location.href=e.exportFileURL):m.U.Notice.error((0,p.__)("The export file could not be generated.","mailpoet"),{scroll:!0})},[]),o=(0,r.useCallback)(e=>{a(!1),m.U.Notice.error(e,{scroll:!0})},[]),l=(0,r.useCallback)(s=>{t||(a(!0),m.U.Notice.success((0,p.__)("Export queued. The download will start automatically when it is ready.","mailpoet"),{timeout:6e3}),((e,t)=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"statisticsExport",action:"exportRecipients",data:{id:e,format:t}}).then(e=>e.data))(e,s).then(e=>{if(e.exportFileURL)return void n(e,s);const t=pr(e.taskId,{onComplete:e=>n(e,s),onError:o});i.current=t.cancel}).catch(e=>{const t=e?.errors?.[0]?.message??(0,p.__)("Could not start the export.","mailpoet");o(t)}))},[o,n,t,e]);return{start:l,isExporting:t}})(e.id);if(!m.U.trackingConfig.emailTrackingEnabled)return null;const n=!m.U.capabilities.detailedAnalytics||m.U.capabilities.detailedAnalytics.isRestricted,o=(e,t)=>{t(),n?a(!0):i(e)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ai.A,{className:"mailpoet-stats-export-dropdown",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,g.jsxs)(ge.Ay,{variant:"secondary",onClick:t,"aria-expanded":e,"aria-label":(0,p.__)("Export","mailpoet"),isBusy:s,disabled:s,children:[(0,p.__)("Export","mailpoet"),(0,g.jsx)(ii.A,{icon:si.A,size:18})]}),renderContent:({onClose:t})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(co.A,{label:(0,p.__)("Campaign summary","mailpoet"),children:[(0,g.jsx)(ei.A,{className:"mailpoet-no-box-shadow",onClick:()=>{mo(e.id,"csv"),t()},children:(0,p.__)("Export as CSV","mailpoet")}),(0,g.jsx)(ei.A,{className:"mailpoet-no-box-shadow",onClick:()=>{mo(e.id,"xlsx"),t()},children:(0,p.__)("Export as Excel (XLSX)","mailpoet")})]}),(0,g.jsxs)(co.A,{label:(0,p.__)("Per recipient","mailpoet"),children:[(0,g.jsx)(ei.A,{className:"mailpoet-no-box-shadow",onClick:()=>o("csv",t),children:(0,p.__)("Recipients as CSV","mailpoet")}),(0,g.jsx)(ei.A,{className:"mailpoet-no-box-shadow",onClick:()=>o("xlsx",t),children:(0,p.__)("Recipients as Excel (XLSX)","mailpoet")})]})]})}),t&&(0,g.jsx)(ts.D,{onRequestClose:()=>a(!1),data:{capabilities:{detailedAnalytics:!0}},tracking:{utm_medium:"upsell_modal",utm_campaign:"stats_recipients_export"},children:(0,p.__)("Per-recipient statistics export is available with detailed analytics.","mailpoet")})]})}uo.displayName="ExportButton";const po=ei.A,ho=e=>m.U.getActiveEmailEditorUrl(e);function go({newsletter:e,onClose:t}){const a=(0,p.sprintf)((0,p.__)("Re: %s","mailpoet"),e.subject),[i,s]=(0,r.useState)(a),[n,o]=(0,r.useState)(!1);return(0,g.jsxs)(Te.A,{title:(0,p.__)("Resend to non-openers","mailpoet"),onRequestClose:t,children:[(0,g.jsx)("p",{children:(0,p.__)("This will send a copy of this email to subscribers who haven’t opened it. A different subject line is required.","mailpoet")}),(0,g.jsx)(Zn.A,{label:(0,p.__)("New subject line","mailpoet"),value:i,onChange:s,help:(0,p.__)("Must be different from the original subject.","mailpoet")}),(0,g.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:[(0,g.jsx)(ge.Ay,{variant:"tertiary",onClick:t,disabled:n,children:(0,p.__)("Cancel","mailpoet")}),(0,g.jsx)(ge.Ay,{variant:"primary",onClick:()=>{i.trim()&&(o(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"resendToNonOpeners",data:{id:e.id,subject:i.trim()}}).done(()=>{m.U.Notice.success((0,p.__)("A copy of this email is being sent to non-openers.","mailpoet"),{static:!0}),t()}).fail(e=>{e?.errors?.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}).always(()=>{o(!1)}))},isBusy:n,disabled:!i.trim()||n,children:(0,p.__)("Resend","mailpoet")})]})]})}function _o({newsletter:e}){const[t,a]=(0,r.useState)(!1),[i,s]=(0,r.useState)(!1),n=function(e){if("standard"!==e.type||"sent"!==e.status)return{eligible:!1};const t=e.sent_at;if(!t)return{eligible:!1,reason:(0,p.__)("No send date available.","mailpoet")};const a=(Date.now()-new Date(t).getTime())/36e5;if(a<24){const e=Math.ceil(24-a);return{eligible:!1,reason:(0,p.sprintf)((0,p._n)("Available in %d hour.","Available in %d hours.",e,"mailpoet"),e)}}return a>72?{eligible:!1,reason:(0,p.__)("Resend window expired (3 days).","mailpoet")}:{eligible:!0}}(e),l=e?.queue?.scheduled_at||e?.queue?.created_at||e?.created_at;return(0,g.jsxs)(Ei.Grid.ThreeColumns,{className:"mailpoet-stats-info",children:[(0,g.jsxs)("div",{children:[(0,g.jsxs)(qt.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(l)," • ",m.U.Date.time(l)]})]}),Array.isArray(e.segments)&&e.segments.length&&(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{className:"mailpoet-stats-info-key",children:(0,p.__)("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,p.__)("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,p.__)("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,p.__)("GA campaign","mailpoet"),": "]}),e.ga_campaign?e.ga_campaign:"-"]})]})}),(0,g.jsx)("div",{className:"mailpoet-stats-button-group",children:(0,g.jsxs)(ti.A,{children:[(0,g.jsx)(uo,{newsletter:e}),(0,g.jsx)(ge.Ay,{href:e.preview_url,target:"_blank",rel:"noopener noreferrer",variant:"secondary",children:(0,p.__)("Preview","mailpoet")}),(0,g.jsx)(ai.A,{className:"mailpoet-stats-has-margin-left",focusOnMount:!1,popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:a})=>(0,g.jsxs)(ti.A,{children:[(0,g.jsx)(ge.Ay,{disabled:"standard"!==e.type,onClick:()=>{(e=>{const t=ho(e);e.queue&&"sending"===e.status&&null===e.queue.status?(0,o.confirmAlert)({message:(0,p.__)("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,p.__)("Edit","mailpoet")}),(0,g.jsxs)(ge.Ay,{onClick:a,"aria-expanded":t,variant:"primary",children:[" ",(0,g.jsx)(ii.A,{icon:si.A,size:18})]})]}),renderContent:()=>(0,g.jsxs)(co.A,{children:[(0,g.jsx)(po,{isBusy:t,className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:"standard"!==e.type,onClick:()=>{a(!0),((e,t=()=>{})=>{(0,fn.r3)(Number(e.id)).then(t=>{const a=t.data,i=ho(a);m.U.Notice.success((0,p.sprintf)((0,p.__)('Email "%s" has been duplicated. New email: <a href="%s"> %s </a>',"mailpoet"),e.subject,i,a.subject),{static:!0})}).catch(e=>{m.U.Notice.error(e.message,{scroll:!0})}).finally(()=>{t()})})(e,()=>{a(!1)})},children:(0,p.__)("Duplicate","mailpoet")}),"standard"===e.type&&"sent"===e.status&&(0,g.jsx)(po,{className:"mailpoet-no-box-shadow",variant:"tertiary",disabled:!n.eligible,onClick:()=>{n.eligible&&s(!0)},info:n.reason,children:(0,p.__)("Resend to non-openers","mailpoet")}),(0,g.jsx)(po,{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,p.__)("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,p.__)("Move to Trash","mailpoet")})]})})]})}),i&&(0,g.jsx)(go,{newsletter:e,onClose:()=>s(!1)})]})}function fo(){const e=(0,g.jsx)(Ge.$,{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,p.__)("Upgrade","mailpoet")}),t=(0,g.jsxs)("p",{children:[(0,p.__)("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,p.__)("Learn more","mailpoet")}),"."]});return(0,g.jsx)("div",{className:"mailpoet-stats-premium-required",children:(0,g.jsx)(Ba,{message:t,actionButton:e,capabilities:{detailedAnalytics:!0}})})}function bo(){return window.mailpoet_display_detailed_stats?null:(0,g.jsx)(fo,{})}_o.displayName="NewsletterStatsInfo",bo.displayName="PremiumBanner";const xo=(0,o.withBoundary)(bo),vo=["clicked","products","engagement","bounces","unsubscribe-reasons"],yo=["group","filter","search","page","sort_by","sort_order"];function wo(e,t){return"clicked"===t?`/stats/${e}`:`/stats/${e}/${t}`}function jo(){const[e,t]=(0,r.useState)({item:void 0,loading:!0}),a=(0,Ae.zy)(),i=(0,Ae.Zp)(),s=(0,Ae.g)(),n=(0,r.useCallback)(a=>{t({loading:!0,item:e.item}),m.U.Modal.loading(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:window.mailpoet_display_detailed_stats?"stats":"newsletters",action:window.mailpoet_display_detailed_stats?"get":"getWithStats",data:{id:a,accept:"all"}}).always(()=>{m.U.Modal.loading(!1)}).done(e=>{t({loading:!1,item:e.data})}).fail(e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0}),t({loading:!1}),i("/")})},[i,e.item]);(0,r.useEffect)(()=>{window.scrollTo(0,0),e.item?.id!==s.id&&n(s.id)},[s.id,n,e.item]);const{item:l,loading:c}=e,u=l,h=function(e){const t=(e||"").split("/").filter(Boolean)[0];return vo.includes(t)?t:yo.some(e=>t?.startsWith(`${e}[`))?"engagement":"clicked"}(s["*"]);let _=h;return(0,r.useEffect)(()=>{!c&&u&&("products"!==h||m.U.isWoocommerceActive||i(wo(u.id,"clicked"),{replace:!0}))},[c,i,u,h]),c?null:u?("products"!==_||m.U.isWoocommerceActive||(_="clicked"),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(io,{}),(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)(_o,{newsletter:u})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(lo,{newsletter:u,isWoocommerceActive:m.U.isWoocommerceActive})}),(0,g.jsxs)(so.t,{activeKey:_,onSwitch:e=>{i(wo(u.id,e))},children:[(0,g.jsx)(no.o,{title:(0,p.__)("Clicked Links","mailpoet"),children:Sa.Hooks.applyFilters("mailpoet_newsletters_clicked_links_table",(0,g.jsx)(xo,{}),u.clicked_links)},"clicked"),m.U.isWoocommerceActive&&(0,g.jsx)(no.o,{title:(0,p.__)("Products Sold","mailpoet"),automationId:"products-sold-tab",children:Sa.Hooks.applyFilters("mailpoet_newsletters_purchased_products",(0,g.jsx)(xo,{}),u)},"products"),(0,g.jsx)(no.o,{title:(0,p.__)("Subscriber Engagement","mailpoet"),automationId:"engagement-tab",children:Sa.Hooks.applyFilters("mailpoet_newsletters_subscriber_engagement",(0,g.jsx)(xo,{}),a,s,u)},"engagement"),(0,g.jsx)(no.o,{title:(0,p._x)("Bounces","A tab title for the list of bounces (w.wiki/45Qc)","mailpoet"),automationId:"bounces-tab",children:Sa.Hooks.applyFilters("mailpoet_newsletters_bounces",(0,g.jsx)(xo,{}),a,s)},"bounces"),(0,g.jsx)(no.o,{title:(0,p.__)("Unsubscribe reasons","mailpoet"),automationId:"unsubscribe-reasons-tab",children:Sa.Hooks.applyFilters("mailpoet_newsletters_unsubscribe_reasons",(0,g.jsx)(xo,{}),u.statistics.unsubscribeReasons)},"unsubscribe-reasons")]})]})]})):(0,g.jsxs)("h3",{children:[" ",(0,p.__)("This email does not exist.","mailpoet")," "]})}function So({newsletters:e}){return(0,g.jsxs)(h.$,{type:"error",timeout:!1,closable:!1,renderInPlace:!0,children:[(0,g.jsx)("h3",{children:(0,p.__)("Paused emails","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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))})]})}jo.displayName="CampaignStatsPage",So.displayName="CorruptEmailNotice";var ko=a(73193);function No(){const e=(0,r.useCallback)(()=>{(0,ko.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,Oe.A)((0,p.__)("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 Co=eo(()=>{const{parentId:e}=(0,Ae.g)();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ao,{children:(0,g.jsx)(to,{})}),window.mailpoet_legacy_automatic_emails_count>0&&!window.mailpoet_legacy_automatic_emails_notice_dismissed&&(0,g.jsx)(No,{}),m.U.corrupt_newsletters.length>0&&(0,g.jsx)(So,{newsletters:m.U.corrupt_newsletters}),(0,g.jsxs)(Yr.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,p.__)("Newsletters","mailpoet"),automationId:`tab-${(0,p.__)("Newsletters","mailpoet")}`,children:(0,g.jsx)(Ir,{})},"standard"),(0,g.jsx)(o.Tab,{route:"notification/*",title:(0,p.__)("Post Notifications","mailpoet"),automationId:`tab-${(0,p.__)("Post Notifications","mailpoet")}`,children:e?(0,g.jsx)(Lr,{parentId:e}):(0,g.jsx)(Pr,{})},"notification"),(0,g.jsx)(o.Tab,{route:"re_engagement/*",title:(0,p.__)("Re-engagement Emails","mailpoet"),automationId:`tab-${(0,p.__)("Re-engagement Emails","mailpoet")}`,children:(0,g.jsx)(Fr,{})},"re_engagement")]})]})}),Eo=[{path:"/notification/history/:parentId/*",children:(0,o.withBoundary)(Co)},{path:"/standard/*",children:(0,o.withBoundary)(Co)},{path:"/notification/*",children:(0,o.withBoundary)(Co)},{path:"/re_engagement/*",children:(0,o.withBoundary)(Co)},{path:"/new/standard",children:(0,o.withBoundary)(function(e){const t=(0,Ae.Zp)();return(0,g.jsx)(On,{...e,navigate:t})})},{path:"/new/notification",children:(0,o.withBoundary)(function(){const e=(0,Ae.Zp)();return(0,g.jsx)(Ln,{navigate:e})})},{path:"/new/re-engagement",children:(0,o.withBoundary)($n)},{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)(qe.z,{heading:(0,p.__)("What would you like to create?","mailpoet"),headingPrefix:(0,g.jsx)(qe.o,{href:"#/",label:(0,p.__)("Listing","mailpoet"),"aria-label":(0,p.__)("Go back to email listing page","mailpoet")})}),(0,g.jsx)(pi,{})]})]})})},{name:"template",path:"/template/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ae.g)();return(0,g.jsx)(ji,{...e,params:t})})},{path:"/send/congratulate/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ae.g)();return(0,g.jsx)(Fn,{...e,params:t})})},{path:"/send/:id",children:(0,o.withBoundary)(function(e){const t=(0,Ae.zy)(),a=(0,Ae.Zp)(),i=(0,Ae.g)();return(0,g.jsx)(kn,{...e,location:t,navigate:a,params:i})})},{path:"/sending-status/:id/*",children:(0,o.withBoundary)(Gr)},{path:"/stats/:id/*",children:(0,o.withBoundary)(jo)}];function Uo(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ie.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.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)(k.D,{})}),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"/",element:(0,g.jsx)(Ae.C5,{to:0===window.mailpoet_newsletters_count?"/new":"/standard"})}),Eo.map(e=>(0,g.jsx)(Ae.qh,{path:e.path,element:(0,g.jsx)(e.children,{})},e.path))]})]})})}const Io=document.getElementById("newsletters_container");Io&&((0,o.registerTranslations)(),(0,n.H)(Io).render((0,g.jsx)(Uo,{})));var Ao=a(94779),To=a(53169);function Po(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{}),(0,g.jsx)(qe.z,{heading:(0,p.__)("Lists","mailpoet"),children:(0,g.jsx)(Ie.Link,{className:"page-title-action",to:"/new","data-automation-id":"new-list",children:(0,p.__)("Add new list","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(ze,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Ye,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(k.D,{})]})}var Ro=a(80502),Do=a(85123);let Fo=!1;function Oo(){if(Fo)return;const e=window.mailpoet_segments_api;Ro.default.use(Ro.default.createRootURLMiddleware(`${e.root}/`)),Ro.default.use(Ro.default.createNonceMiddleware(e.nonce)),Fo=!0}function Mo(e,t){return(0,r.createElement)("span",{"data-automation-id":`listing_item_${e.id}_${t}_count`},Number(e.subscribers_count[t]??0).toLocaleString())}const Lo=m.U.trackingConfig.emailTrackingEnabled?[{id:"average_engagement_score",label:m.U.I18n.t("listScore"),enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)(ve,{id:Number(e.id),engagementScore:e.average_engagement_score})}]:[],$o=[{id:"name",label:(0,p.__)("Name","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{const t=0===Number(e.show_in_manage_subscription_page)?(0,r.createElement)("span",{className:"mailpoet-listing-title-private-label"},` ${m.U.I18n.t("privateListLabel")}`):null,a=[e.name,t].filter(Boolean),i={className:"mailpoet-listing-title","data-automation-id":`listing_item_${e.id}`},s=t=>(0,r.createElement)("span",{"data-automation-id":`segment_name_${e.name}`},t);return"wp_users"===e.type||"woocommerce_users"===e.type?(0,r.createElement)("div",null,s((0,r.createElement)("span",i,...a))):(0,r.createElement)("div",null,s((0,r.createElement)("a",{...i,href:`#/edit/${e.id}`},...a)))}},{id:"description",label:(0,p.__)("Description","mailpoet"),enableSorting:!1,enableGlobalSearch:!1},{id:"type",label:(0,p.__)("Type","mailpoet"),elements:[{value:"default",label:(0,p.__)("List","mailpoet")},{value:"wp_users",label:(0,p.__)("WordPress users","mailpoet")},{value:"woocommerce_users",label:(0,p.__)("WooCommerce customers","mailpoet")}],enableSorting:!1,enableGlobalSearch:!1},...Lo,{id:"subscribed",label:m.U.I18n.t("subscribed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>Mo(e,"subscribed")},{id:"unconfirmed",label:m.U.I18n.t("unconfirmed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>Mo(e,"unconfirmed")},{id:"unsubscribed",label:m.U.I18n.t("unsubscribed"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>Mo(e,"unsubscribed")},{id:"inactive",label:m.U.I18n.t("inactive"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>Mo(e,"inactive")},{id:"bounced",label:m.U.I18n.t("bounced"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>Mo(e,"bounced")},{id:"created_at",label:m.U.I18n.t("createdOn"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{return(t=e.created_at)?(0,r.createElement)("span",null,(0,r.createElement)("span",null,m.U.Date.short(t)),(0,r.createElement)("br",null),(0,r.createElement)("span",null,m.U.Date.time(t))):(0,r.createElement)("span",null,"—");var t}}],Bo=Number(window.mailpoet_listing_per_page),Wo={type:"table",perPage:Bo,page:1,sort:{field:"name",direction:"asc"},fields:["description",...m.U.trackingConfig.emailTrackingEnabled?["average_engagement_score"]:[],"subscribed","unconfirmed","unsubscribed","inactive","bounced","created_at"],titleField:"name",showTitle:!0};function Vo(e){return"wp_users"===e.type}function qo(e){return"woocommerce_users"===e.type}function Ho(e){return Vo(e)||qo(e)}function zo(){const e=window.location.hash.split("/").map(e=>e.replace(/\]$/,"").split("[")).reduce((e,[t,a])=>a?"group"!==t||"all"!==a&&"trash"!==a?("page"===t||"paged"===t)&&Number(a)>0?{...e,page:Number(a)}:("per_page"===t||"limit"===t)&&Number(a)>0?{...e,perPage:Number(a)}:"sort_by"===t||"orderby"===t?{...e,orderby:a}:"sort_order"!==t&&"order"!==t||"asc"!==a&&"desc"!==a?e:{...e,order:a}:{...e,group:a}:e,{}),[t,a]=(0,r.useState)(e.group??"all"),[i,s]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),[c,u]=(0,r.useState)(null),[h]=(0,r.useState)(()=>(0,$e.Aq)("static-segments",Wo,$o)),[_]=(0,r.useState)(()=>({...h,page:e.page??h.page,perPage:e.perPage??h.perPage,sort:{field:e.orderby??h.sort?.field??"name",direction:e.order??h.sort?.direction??"asc"}})),f=(0,r.useCallback)(e=>async function(e){return Oo(),(await(0,Ro.default)({path:(0,Do.F)("/mailpoet/v1/segments",e),method:"GET"})).data}({...e,group:t}),[t]),{view:b,setView:x,items:v,meta:y,groups:w,isLoading:j,error:S,onChangeView:k,clearError:N,refresh:C}=(0,$e.i7)({initialView:_,load:f}),E=(0,$e.wh)("static-segments",b,k);(0,r.useEffect)(()=>{!function(e,t,a){const i=[["group",e],["page",t.page&&1!==t.page?t.page:void 0],["limit",t.perPage&&t.perPage!==(a.perPage??Bo)?t.perPage:void 0],["sort_by",t.sort?.field&&t.sort.field!==(a.sort?.field??"name")?t.sort.field:void 0],["sort_order",t.sort?.direction&&t.sort.direction!==(a.sort?.direction??"asc")?t.sort.direction:void 0]].reduce((e,[t,a])=>a?`${e}/${t}[${a}]`:e,"");window.history.replaceState(null,"",`#/lists${i}`)}(t,b,(0,$e.Aq)("static-segments",Wo,$o))},[t,b]);const U=(0,r.useCallback)(async(e,t,a)=>{const i=t.map(e=>Number(e.id));if(a?.select_all||"empty_trash"===e||0!==i.length)try{const n=await async function(e,t,a){return Oo(),(await(0,Ro.default)({path:"/mailpoet/v1/segments/bulk-action",method:"POST",data:{action:e,ids:t,...a}})).data}(e,i,a),r=function(e,t){return"delete"===e||"empty_trash"===e?t.deleted:t.updated}(e,n);s([]),o(n.errors.length?n.errors.map(e=>e.message).join("\n"):null),d(r>0?function(e,t,a=!1){return"trash"===e?`${a?(0,p.__)("1 list was moved to the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d list was moved to the trash.","%d lists were moved to the trash.",t,"mailpoet"),t)} ${(0,p.__)("Note that deleting a list does not delete its subscribers.","mailpoet")}`:"restore"===e?1===t?(0,p.__)("1 list has been restored from the Trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d list has been restored from the Trash.","%d lists have been restored from the Trash.",t,"mailpoet"),t):`${(0,p.sprintf)((0,p._n)("%d list was permanently deleted.","%d lists were permanently deleted.",t,"mailpoet"),t)} ${(0,p.__)("Note that deleting a list does not delete its subscribers.","mailpoet")}`}(e,r,t.some(Vo)):null),C()}catch(e){const t=e;d(null),o(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}},[C]),I=(0,r.useCallback)(e=>{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,Me.Zn)(e.data.name))),C()}).fail(e=>{m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[C]),A=(0,r.useCallback)(e=>{m.U.Modal.loading(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"segments",action:"synchronize",data:{type:e.type}}).done(()=>{const t="woocommerce_users"===e.type?m.U.I18n.t("listSynchronizationWasScheduled").replace("%1$s",e.name):m.U.I18n.t("listSynchronized").replace("%1$s",e.name);m.U.Modal.loading(!1),m.U.Notice.success(t),C()}).fail(e=>{m.U.Modal.loading(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[C]),T=(0,r.useMemo)(()=>[{id:"edit",label:(0,p.__)("Edit","mailpoet"),isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&!Ho(e),callback:e=>{const t=e[0];t&&(window.location.hash=`/edit/${t.id}`)}},{id:"duplicate",label:m.U.I18n.t("duplicate"),supportsBulk:!1,isEligible:e=>!e.deleted_at&&!Ho(e),callback:e=>{e[0]&&I(e[0])}},{id:"read_more",label:m.U.I18n.t("readMore"),supportsBulk:!1,isEligible:e=>Vo(e),callback:()=>{window.open("https://kb.mailpoet.com/article/133-the-wordpress-users-list","_blank","noopener,noreferrer")}},{id:"synchronize",label:m.U.I18n.t("forceSync"),supportsBulk:!1,isEligible:e=>Vo(e)||qo(e),callback:e=>{e[0]&&A(e[0])}},{id:"view_subscribers",label:m.U.I18n.t("viewSubscribers"),supportsBulk:!1,callback:e=>{const t=e[0];t&&(window.location.href=t.subscribers_url)}},{id:"trash_wp_users",label:(0,p.__)("Trash and disable","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at&&Vo(e),callback:e=>{U("trash",e)}},{id:"trash",label:m.U.I18n.t("moveToTrash"),supportsBulk:!0,isEligible:e=>!e.deleted_at&&!Vo(e)&&!qo(e),callback:e=>{U("trash",e)}},{id:"restore_wp_users",label:(0,p.__)("Restore and enable","mailpoet"),supportsBulk:!1,isEligible:e=>!!e.deleted_at&&Vo(e),callback:e=>{U("restore",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at&&!Vo(e),callback:e=>{U("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at&&!Ho(e),callback:e=>{u({action:"delete",targets:e,count:e.length})}}],[U,I,A]),P=(0,r.useMemo)(()=>({totalItems:y.count,totalPages:y.pages}),[y]),R=(0,r.useMemo)(()=>{const e={all:null,trash:null};return(w??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)}),e},[w]),D=(0,r.useMemo)(()=>{const e=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:e((0,p.__)("All","mailpoet"),R.all),className:"mailpoet-dataviews-group-all"},..."trash"===t||(R.trash??0)>0?[{name:"trash",title:e((0,p.__)("Trash","mailpoet"),R.trash),className:"mailpoet-dataviews-group-trash"}]:[]]},[t,R]);(0,r.useEffect)(()=>{"trash"!==t||j||S||0!==R.trash||(a("all"),s([]),x(e=>({...e,page:1})))},[t,R.trash,j,S,x]);const F=e=>{s(e)},O="trash"===t?(0,p.__)("Trash is empty.","mailpoet"):(0,p.__)("No lists found.","mailpoet"),M=function(e){if(!e)return{title:"",message:"",confirmText:""};const{action:t,count:a}=e;return"empty_trash"===t?{title:(0,p.__)("Empty Trash","mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._n)("Are you sure you want to permanently delete %d list from the Trash?","Are you sure you want to permanently delete %d lists from the Trash?",a,"mailpoet"),a)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Empty Trash","mailpoet")}:{title:(0,p._n)("Delete selected list permanently","Delete selected lists permanently",a,"mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._n)("Are you sure you want to permanently delete %d selected list?","Are you sure you want to permanently delete %d selected lists?",a,"mailpoet"),a)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Delete permanently","mailpoet")}}(c);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ri.x,{}),(0,g.jsx)(Po,{}),S&&(0,g.jsx)(Fe.A,{status:"error",onRemove:N,children:S}),n&&(0,g.jsx)(Fe.A,{status:"error",onRemove:()=>o(null),children:n}),l&&(0,g.jsx)(Fe.A,{status:"success",onRemove:()=>d(null),children:l}),(0,g.jsx)(Ao.A,{className:"mailpoet-segments-dataviews__tabs",activeClass:"is-active",tabs:D,initialTabName:t,onSelect:e=>{"all"!==e&&"trash"!==e||e!==t&&(a(e),s([]),o(null),d(null),N(),x(e=>({...e,page:1})))},children:()=>(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-segments-dataviews mailpoet-segments-listing","data-automation-id":"segments_listing",children:(0,g.jsxs)(Le.A,{data:v,fields:$o,view:b,onChangeView:E,actions:T,paginationInfo:P,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:i,onChangeSelection:F,isLoading:j,empty:(0,g.jsx)("div",{children:O}),children:[(0,g.jsxs)("div",{className:"mailpoet-segments-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),"trash"===t&&(R.trash??0)>0&&(0,g.jsx)("div",{className:"mailpoet-segments-dataviews__toolbar",children:(0,g.jsx)("button",{type:"button",className:"button","data-automation-id":"empty_trash",onClick:()=>{u({action:"empty_trash",targets:[],count:R.trash??0,params:{select_all:!0,group:"trash",page:b.page??1,per_page:b.perPage??Bo,orderby:b.sort?.field,order:b.sort?.direction}})},children:(0,p.__)("Empty Trash","mailpoet")})}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]},t)})},t),(0,g.jsx)(To.A,{className:"mailpoet-confirm-dialog",isOpen:!!c,title:M.title,confirmButtonText:M.confirmText,__experimentalHideHeader:!1,onConfirm:()=>{c&&U(c.action,c.targets,c.params),u(null)},onCancel:()=>u(null),children:(0,g.jsx)("p",{children:M.message})})]})}const Go=window.mailpoet_confirmation_emails||[],Yo=window.mailpoet_pages||[],Ko={0:(0,p.__)("Use global default","mailpoet")};Yo.forEach(e=>{Ko[String(e.id)]=e.title});const Qo=[{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:"public_description",label:m.U.I18n.t("publicDescription"),type:"textarea",tip:m.U.I18n.t("publicDescriptionTip")},{name:"show_in_manage_subscription_page",label:m.U.I18n.t("showInManageSubscriptionPage"),type:"checkbox",values:{show_in_manage_subscription_page:m.U.I18n.t("showInManageSubscriptionPageTip")},isChecked:!0},{name:"confirmation_email_id",label:(0,p.__)("Confirmation email","mailpoet"),type:"reactComponent",component:function({onValueChange:e,item:t}){const[a,i]=(0,r.useState)(Go),[s,n]=(0,r.useState)(!1),o=t.confirmation_email_id||"0",l=(0,r.useCallback)(async()=>{n(!0);try{const t=(await m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletters",action:"createConfirmationEmail"})).data;i(e=>[...e,t]),e({target:{name:"confirmation_email_id",value:String(t.id)}});const a=`admin.php?page=mailpoet-newsletter-editor&id=${t.id}`;m.U.Notice.success(`${(0,p.__)("Confirmation email created.","mailpoet")} <a href="${a}" target="_blank" rel="noopener noreferrer">${(0,p.__)("Edit it now","mailpoet")}</a>`)}catch(e){m.U.Notice.showApiErrorNotice(e,{scroll:!0})}finally{n(!1)}},[e]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{name:"confirmation_email_id",id:"field_confirmation_email_id",value:o,onChange:e,children:[(0,g.jsx)("option",{value:"0",children:(0,p.__)("Use global default","mailpoet")}),a.map(e=>(0,g.jsx)("option",{value:String(e.id),children:e.subject},e.id))]}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Ge.$,{type:"button",variant:"secondary",dimension:"small",onClick:l,isDisabled:s,children:s?(0,p.__)("Creating…","mailpoet"):(0,p.__)("Create new","mailpoet")}),"0"!==o&&(0,g.jsx)(Ge.$,{variant:"secondary",dimension:"small",href:`admin.php?page=mailpoet-newsletter-editor&id=${o}`,target:"_blank",rel:"noopener noreferrer",children:(0,p.__)("Edit","mailpoet")})]})},tip:(0,p.__)("Choose a custom confirmation email for subscribers joining this list. If not set, the global default is used.","mailpoet")},{name:"confirmation_page_id",label:(0,p.__)("Confirmation page","mailpoet"),type:"select",values:Ko,tip:(0,p.__)("Choose a custom confirmation page for subscribers joining this list. If not set, the global default is used.","mailpoet")}],Jo={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 Zo(){const e=(0,Ae.g)();return(0,g.jsxs)("div",{className:"mailpoet-main-container",children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(qe.z,{heading:e.id?(0,p.__)("Edit list","mailpoet"):(0,p.__)("Add new list","mailpoet"),headingPrefix:(0,g.jsx)(qe.o,{href:"#/",label:(0,p.__)("Lists","mailpoet"),"aria-label":(0,p.__)("Navigate to the lists page","mailpoet")})}),(0,g.jsx)(Qt.X,{}),(0,g.jsx)(Kt,{endpoint:"segments",fields:Qo,params:e,messages:Jo})]})}Zo.displayName="SegmentForm";const Xo=document.getElementById("static_segments_container"),el=(0,o.withBoundary)(Zo),tl=(0,o.withBoundary)(function(){return(0,g.jsx)(zo,{})});function al(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ie.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"/new",element:(0,g.jsx)(el,{})}),(0,g.jsx)(Ae.qh,{path:"/edit/:id",element:(0,g.jsx)(el,{})}),(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(tl,{})})]})]})})}Xo&&((0,o.registerTranslations)(),(0,n.H)(Xo).render((0,g.jsx)(al,{})));var il=a(98141),sl=a(8392);function nl({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)(sl.D,{level:4,children:t}),(0,g.jsx)("p",{children:a})]}),(0,g.jsx)(oa.A,{children:(0,g.jsx)(la.A,{children:e})})]})}function rl({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 ol=a(70458),ll=a(67230),dl=a(61258),cl=a(66542);function ml({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=(0,C.A)(e=>e(dl.Hz).getAutomations(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.A)(dl.Hz);(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&i({operator:ll.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)(Be.Select,{value:t.operator,onChange:t=>{s("operator",e,t)},isMinWidth:!0,children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(il.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 ul={[cl.g.ENTERED_AUTOMATION]:ml,[cl.g.EXITED_AUTOMATION]:ml};var pl=a(19388);const hl=["automation","automation_transactional"],gl=e=>pl.s.format(e);function _l(e,t=gl){const a=e??[],i=a.filter(({type:e})=>"standard"===e).map(e=>function(e,t){return{label:e.name,tag:e.sent_at?t(e.sent_at):(0,p.__)("Not sent yet","mailpoet"),value:Number(e.id)}}(e,t)),s=a.filter(({type:e})=>function(e){return hl.includes(e)}(e)).map(e=>function(e){return{label:e.name,value:Number(e.id)}}(e)),n=[];return i.length>0&&n.push({label:(0,p.__)("Standard emails","mailpoet"),options:i}),s.length>0&&n.push({label:(0,p.__)("Automation emails","mailpoet"),options:s}),{flatOptions:[...i,...s],groupedOptions:n}}function fl({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.Hz).getNewslettersList(),[]),{flatOptions:n,groupedOptions:o}=_l(s);return(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e),t.action===ll._R.MACHINE_OPENED&&t.operator===ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[t.action,t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{isMinWidth:!0,automationId:"segment-email-opens-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),t.action!==ll._R.MACHINE_OPENED?(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")}):null]},"select"),(0,g.jsx)(il.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:o,automationId:"segment-email",value:n.filter(({value:e})=>t.newsletters?.includes(e)),onChange:t=>{a({newsletters:(t||[]).map(({value:e})=>e)},e)}})]})}const bl=e=>!!e;var xl=a(89011);function vl(e,t){const a=t?.additionalDigits??2,i=function(e){const t={},a=e.split(yl.dateTimeDelimiter);let i;if(a.length>2)return t;if(/:/.test(a[0])?i=a[0]:(t.date=a[0],i=a[1],yl.timeZoneDelimiter.test(t.date)&&(t.date=e.split(yl.timeZoneDelimiter)[0],i=e.substr(t.date.length,e.length))),i){const e=yl.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(wl);if(!a)return new Date(NaN);const i=!!a[4],s=kl(a[1]),n=kl(a[2])-1,r=kl(a[3]),o=kl(a[4]),l=kl(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<=(Cl[t]||(El(e)?29:28))}(t,n,r)&&function(e,t){return t>=1&&t<=(El(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(jl);if(!t)return NaN;const a=Nl(t[1]),i=Nl(t[2]),s=Nl(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*xl.s0+i*xl.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(Sl);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*xl.s0+s*xl.Cg):NaN}(i.timezone),isNaN(r)?new Date(NaN):new Date(n+o+r)}const yl={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},wl=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,jl=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Sl=/^([+-])(\d{2})(?::?(\d{2}))?$/;function kl(e){return e?parseInt(e):1}function Nl(e){return e&&parseFloat(e.replace(",","."))||0}const Cl=[31,null,31,30,31,30,31,31,30,31,30,31];function El(e){return e%400==0||e%4==0&&e%100!=0}var Ul=a(85963);function Il(e){if(!(t=e,t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof e))return!1;var t;const a=(0,Ul.a)(e);return!isNaN(Number(a))}const Al=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"})}},Tl=e=>{if(!e)return;const t=vl(e);return Il(t)?t:void 0};function Pl({filterIndex:e,defaultTimeframe:t=ll.VE.IN_THE_LAST}){const a=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:i,updateSegmentFilter:s}=(0,fe.A)(dl.Hz);(0,r.useEffect)(()=>{(0,ar.J)(a.timeframe,ll.VE)||s({timeframe:t},e),a.timeframe!==ll.VE.IN_THE_LAST||"string"!=typeof a.days||/^\d*$/.exec(a.days)||s({days:""},e),![ll.VE.BEFORE,ll.VE.AFTER,ll.VE.ON,ll.VE.BETWEEN].some(e=>e===a.timeframe)||void 0!==Tl(a.value||"")&&/^\d+-\d+-\d+$/.test(a.value||"")||s({value:Al(new Date)},e),a.timeframe!==ll.VE.BETWEEN||void 0!==Tl(a.value2||"")&&/^\d+-\d+-\d+$/.test(a.value2||"")||s({value2:Al(new Date)},e)},[a,s,e,t]);const n=a.timeframe===ll.VE.IN_THE_LAST,l=a.timeframe===ll.VE.BEFORE||a.timeframe===ll.VE.AFTER||a.timeframe===ll.VE.ON;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:a.timeframe,onChange:t=>{i("timeframe",e,t)},children:[(0,g.jsx)("option",{value:ll.VE.ALL_TIME,children:m.U.I18n.t("overAllTime")}),(0,g.jsx)("option",{value:ll.VE.IN_THE_LAST,children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:ll.VE.BEFORE,children:m.U.I18n.t("before")}),(0,g.jsx)("option",{value:ll.VE.AFTER,children:m.U.I18n.t("after")}),(0,g.jsx)("option",{value:ll.VE.ON,children:m.U.I18n.t("on")}),(0,g.jsx)("option",{value:ll.VE.BETWEEN,children:m.U.I18n.t("between")})]},"timeframe-select"),n&&(0,g.jsxs)("div",{className:"mailpoet-segments-date-period-controls",children:[(0,g.jsx)(o.Input,{className:"mailpoet-segments-input-small",type:"number",value:a.days||"","data-automation-id":"segment-number-of-days",onChange:t=>{i("days",e,t)},min:1,step:1,placeholder:m.U.I18n.t("daysPlaceholder")},"input"),(0,g.jsx)("span",{children:m.U.I18n.t("daysPlaceholder")})]}),l&&(0,g.jsx)("div",{className:"mailpoet-segments-date-period-controls",children:(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{s({value:Al(t)},e)},selected:a.value?Tl(a.value):void 0})}),a.timeframe===ll.VE.BETWEEN&&(0,g.jsxs)("div",{className:"mailpoet-segments-date-period-controls",children:[(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{s({value:Al(t)},e)},selected:a.value?Tl(a.value):void 0}),(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{s({value2:Al(t)},e)},selected:a.value2?Tl(a.value2):void 0})]})]})}function Rl(e){return e.timeframe===ll.VE.ALL_TIME||([ll.VE.BEFORE,ll.VE.AFTER,ll.VE.ON].some(t=>t===e.timeframe)?/^\d+-\d+-\d+$/.test(e.value||""):e.timeframe===ll.VE.BETWEEN?/^\d+-\d+-\d+$/.test(e.value||"")&&/^\d+-\d+-\d+$/.test(e.value2||""):parseInt(e.days,10)>=1)}function Dl({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.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)(Ei.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(Be.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)(It.p,{type:"number",value:t.opens||"","data-automation-id":"segment-number-of-opens",onChange:t=>{i("opens",e,t)},min:"0",placeholder:m.U.I18n.t("emailActionOpens")},"input"):"string"==typeof a&&a.trim().length>1?(0,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)(Pl,{filterIndex:e})]});var s}const Fl={[ll._R.OPENS_ABSOLUTE_COUNT]:Dl,[ll._R.MACHINE_OPENS_ABSOLUTE_COUNT]:Dl,[ll._R.CLICKED]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.Hz).getNewslettersList(),[]),[n,o]=(0,r.useState)([]),[l,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),{flatOptions:p,groupedOptions:h}=_l(s),_=(0,r.useCallback)(()=>{var e;bl(t.newsletter_id)&&(d([]),e=t.newsletter_id,o([]),u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"newsletter_links",action:"get",data:{newsletterId:e}}).then(e=>{const{data:t}=e,a=t.map(e=>({value:e.id,label:e.url}));u(!1),d(a)}).fail(e=>{o(e.errors)}))},[t.newsletter_id]);return(0,r.useEffect)(()=>{_()},[_,t.newsletter_id]),(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[t.operator,e,a]),(0,g.jsxs)(g.Fragment,{children:[n.length>0&&(0,g.jsx)(oi,{errors:n}),(0,g.jsx)(il.ReactSelect,{placeholder:m.U.I18n.t("selectNewsletterPlaceholder"),options:h,value:p.find(({value:e})=>e===Number(t.newsletter_id)),onChange:t=>{a({newsletter_id:t.value,link_ids:[]},e)},automationId:"segment-email"}),(0,g.jsxs)(Be.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),c&&(0,g.jsx)("span",{children:m.U.I18n.t("loadingDynamicSegmentItems")}),!c&&bl(t.newsletter_id)&&(0,g.jsx)(il.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,mn.filter)(e=>!!t.link_ids&&-1!==t.link_ids.indexOf(e.value),l),onChange:t=>{a({link_ids:(t||[]).map(e=>e.value)},e)}})]})},[ll._R.OPENED]:fl,[ll._R.WAS_SENT]:fl,[ll._R.MACHINE_OPENED]:fl,[ll._R.CLICKED_ANY]:null,[ll._R.NUMBER_RECEIVED]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.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)(Ei.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(Be.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)(It.p,{type:"number",value:t.emails||"","data-automation-id":"segment-number-emails-received",onChange:t=>{i("emails",e,t)},min:"0",placeholder:(0,p.__)("emails","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"emails"):null,(0,p.__)("{condition} {emails} emails","mailpoet").split(/({condition})|({emails})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(Pl,{filterIndex:e})]});var s},[ll._R.NUMBER_OF_CLICKS]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.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)(Ei.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(Be.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)(It.p,{type:"number",value:t.clicks||"","data-automation-id":"segment-number-of-clicks",onChange:t=>{i("clicks",e,t)},min:"0",placeholder:(0,p.__)("clicks","mailpoet")},"input"):"string"==typeof a&&a.trim().length>1?(0,g.jsx)("div",{children:a},"clicks"):null,(0,p.__)("{condition} {clicks} clicks","mailpoet").split(/({condition})|({clicks})|(\b[a-zA-Z]+\b)/gim).map(s))}),(0,g.jsx)(Pl,{filterIndex:e})]});var s}};let Ol=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.BETWEEN="between",e.IN_THE_LAST="inTheLast",e.NOT_IN_THE_LAST="notInTheLast",e}({});const Ml=[Ol.BEFORE,Ol.AFTER,Ol.ON,Ol.ON_OR_AFTER,Ol.ON_OR_BEFORE,Ol.NOT_ON,Ol.BETWEEN,Ol.IN_THE_LAST,Ol.NOT_IN_THE_LAST];function Ll({filterIndex:e,defaultOperator:t}){const a=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.A)(dl.Hz);return(0,r.useEffect)(()=>{Ml.includes(a.operator)||i({operator:t},e),a.operator!==Ol.BEFORE&&a.operator!==Ol.AFTER&&a.operator!==Ol.ON&&a.operator!==Ol.ON_OR_AFTER&&a.operator!==Ol.ON_OR_BEFORE&&a.operator!==Ol.BETWEEN&&a.operator!==Ol.NOT_ON||void 0!==Tl(a.value)&&/^\d+-\d+-\d+$/.test(a.value)||i({value:Al(new Date)},e),a.operator!==Ol.BETWEEN||void 0!==Tl(a.value2||"")&&/^\d+-\d+-\d+$/.test(a.value2||"")||i({value2:Al(new Date)},e),a.operator!==Ol.IN_THE_LAST&&a.operator!==Ol.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)(Be.Select,{value:a.operator,isMinWidth:!0,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:Ol.BEFORE,children:m.U.I18n.t("before")}),(0,g.jsx)("option",{value:Ol.ON_OR_BEFORE,children:m.U.I18n.t("onOrBefore")}),(0,g.jsx)("option",{value:Ol.ON,children:m.U.I18n.t("on")}),(0,g.jsx)("option",{value:Ol.NOT_ON,children:m.U.I18n.t("notOn")}),(0,g.jsx)("option",{value:Ol.BETWEEN,children:m.U.I18n.t("between")}),(0,g.jsx)("option",{value:Ol.ON_OR_AFTER,children:m.U.I18n.t("onOrAfter")}),(0,g.jsx)("option",{value:Ol.AFTER,children:m.U.I18n.t("after")}),(0,g.jsx)("option",{value:Ol.IN_THE_LAST,children:m.U.I18n.t("inTheLast")}),(0,g.jsx)("option",{value:Ol.NOT_IN_THE_LAST,children:m.U.I18n.t("notInTheLast")})]},"select"),(a.operator===Ol.BEFORE||a.operator===Ol.AFTER||a.operator===Ol.ON||a.operator===Ol.ON_OR_AFTER||a.operator===Ol.ON_OR_BEFORE||a.operator===Ol.NOT_ON)&&(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value:Al(t)},e)},selected:a.value?Tl(a.value):void 0}),a.operator===Ol.BETWEEN&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value:Al(t)},e)},selected:a.value?Tl(a.value):void 0}),(0,g.jsx)(Li.t,{className:"mailpoet-segments-datepicker-small",dateFormat:"MMM d, yyyy",onChange:t=>{i({value2:Al(t)},e)},selected:a.value2?Tl(a.value2):void 0})]}),(a.operator===Ol.IN_THE_LAST||a.operator===Ol.NOT_IN_THE_LAST)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(It.p,{className:"mailpoet-segments-input-small",type:"number",value:a.value||"",onChange:t=>{s("value",e,t)},min:"1",placeholder:m.U.I18n.t("daysPlaceholder")},"input"),(0,g.jsx)("span",{children:m.U.I18n.t("daysPlaceholder")})]})]})}function $l(e){if(!e.operator||!e.value)return!1;if([Ol.BEFORE,Ol.AFTER,Ol.ON,Ol.NOT_ON,Ol.ON_OR_BEFORE,Ol.ON_OR_AFTER].includes(e.operator))return/^\d+-\d+-\d+$/.test(e.value);if([Ol.IN_THE_LAST,Ol.NOT_IN_THE_LAST].includes(e.operator))return/^\d+$/.test(e.value)&&Number(e.value)>0;if(e.operator===Ol.BETWEEN){const t=/^\d+-\d+-\d+$/;return t.test(e.value)&&t.test(e.value2||"")}return!1}function Bl(e){return function(t){return(0,g.jsx)(Ll,{...t,defaultOperator:e})}}const Wl=Bl(Ol.BEFORE),Vl=Bl(Ol.IN_THE_LAST);var ql=a(66567);function Hl({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.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)(Ei.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)(Pl,{filterIndex:e})]})}const zl=["is","isNot","contains","notContains","startsWith","notStartsWith","endsWith","notEndsWith"];function Gl(e){return!!zl.includes(e.operator)&&"string"==typeof e.value&&e.value.length>0}function Yl({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.A)(dl.Hz);return(0,r.useEffect)(()=>{zl.includes(t.operator)||i({operator:"is",value:""},e)},[i,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.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)(It.p,{className:"mailpoet-segments-input-medium","data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}const Kl={[ql.Ag.CUSTOMER_IN_COUNTRY]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getWooCommerceCountries(),[]).map(e=>({value:e.code,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator-country",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-country"),(0,g.jsx)(il.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("selectWooCountry"),options:i,value:(0,mn.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")]})},[ql.Ag.CUSTOMER_IN_CITY]:Yl,[ql.Ag.CUSTOMER_IN_POSTAL_CODE]:Yl,[ql.Ag.NUMBER_OF_ORDERS]:Hl,[ql.Ag.NUMBER_OF_ORDERS_WITH_COUPON]:Hl,[ql.Ag.NUMBER_OF_REVIEWS]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz);return(0,r.useEffect)(()=>{(0,ar.J)(t.count_type,ll.YR)||a({count_type:ll.YR.EQUALS},e),(0,ar.J)(t.rating,ll.Un)||a({rating:ll.Un.ANY},e),(0,ar.J)(t.timeframe,ll.VE)||a({timeframe:ll.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:ll.Un.ANY,children:m.U.I18n.t("wooAnyStarRating")}),(0,g.jsx)("option",{value:ll.Un.ONE,children:m.U.I18n.t("wooOneStarRating")}),(0,g.jsx)("option",{value:ll.Un.TWO,children:m.U.I18n.t("wooTwoStarRating")}),(0,g.jsx)("option",{value:ll.Un.THREE,children:m.U.I18n.t("wooThreeStarRating")}),(0,g.jsx)("option",{value:ll.Un.FOUR,children:m.U.I18n.t("wooFourStarRating")}),(0,g.jsx)("option",{value:ll.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:ll.YR.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:ll.YR.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:ll.YR.MORE_THAN,children:m.U.I18n.t("moreThan")}),(0,g.jsx)("option",{value:ll.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)(Pl,{filterIndex:e})]})},[ql.Ag.PURCHASE_DATE]:Wl,[ql.Ag.PURCHASED_PRODUCT]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ALL&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedProduct"),options:i,value:(0,mn.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"),(0,g.jsx)(Pl,{filterIndex:e,defaultTimeframe:ll.VE.ALL_TIME})]})},[ql.Ag.PURCHASED_PRODUCT_VARIATION]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getVariableProducts(),[]),s=(0,r.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i]),[n,o]=(0,r.useState)(void 0),[l,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[h,_]=(0,r.useState)(!1),f=(0,r.useRef)(0),b=(0,r.useCallback)(e=>{f.current+=1;const t=f.current;u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"woocommerce_product_variations",action:"getVariations",data:{product_id:e}}).then(e=>{t===f.current&&d(e.data.variations.map(e=>({value:e.id,label:e.name})))}).always(()=>{t===f.current&&u(!1)})},[]),x=(0,r.useCallback)(e=>{f.current+=1;const t=f.current;u(!0),m.U.Ajax.post({api_version:m.U.apiVersion,endpoint:"woocommerce_product_variations",action:"getVariations",data:{variation_id:e}}).then(e=>{t===f.current&&(e.data.product&&o(e.data.product.id),d(e.data.variations.map(e=>({value:e.id,label:e.name}))))}).always(()=>{t===f.current&&u(!1)})},[]);(0,r.useEffect)(()=>{t.operator!==ll.dP.ALL&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t.operator,e]),(0,r.useEffect)(()=>{h||(_(!0),Array.isArray(t.variation_ids)&&t.variation_ids.length>0&&x(t.variation_ids[0]))},[h,t.variation_ids,x]);const v=(0,mn.filter)(e=>!(!Array.isArray(t.variation_ids)||0===t.variation_ids.length)&&-1!==t.variation_ids.indexOf(e.value),l),y=n&&s.find(e=>e.value===n)||null;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(il.ReactSelect,{dimension:"small",isClearable:!0,placeholder:m.U.I18n.t("selectWooVariableProduct"),options:s,value:y,onChange:t=>(t=>{const i=t?t.value:void 0;o(i),d([]),a({variation_ids:[]},e),i&&b(i)})(t),automationId:"select-variable-product"},"select-variable-product"),(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",placeholder:c?(0,p.__)("Loading variations…","mailpoet"):m.U.I18n.t("selectWooPurchasedProductVariation"),isDisabled:!n||c,options:l,value:v,onChange:t=>{a({variation_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-product-variations"},"select-product-variations"),(0,g.jsx)(Pl,{filterIndex:e,defaultTimeframe:ll.VE.ALL_TIME})]})},[ql.Ag.PURCHASED_CATEGORY]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getProductCategories(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ALL&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",placeholder:m.U.I18n.t("selectWooPurchasedCategory"),options:i,value:(0,mn.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"),(0,g.jsx)(Pl,{filterIndex:e,defaultTimeframe:ll.VE.ALL_TIME})]})},[ql.Ag.PURCHASED_WITH_ATTRIBUTE]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.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,C.A)(e=>e(dl.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!==ll.dP.ALL&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]);const m=(0,r.useCallback)(t=>{l.includes(t.value)?a({attribute_type:"local",attribute_local_name:t.value.replace(/@local$/,""),attribute_local_values:[],attribute_taxonomy_slug:null,attribute_term_ids:null},e):a({attribute_type:"taxonomy",attribute_local_name:null,attribute_local_values:null,attribute_taxonomy_slug:t.value,attribute_term_ids:[]},e)},[e,l,a]),u=(0,r.useMemo)(()=>"local"===t.attribute_type?(0,mn.filter)(e=>{if(t.attribute_local_name)return`${t.attribute_local_name}@local`===e.value},o):(0,mn.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,mn.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)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:(0,p.__)("any of","mailpoet")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:(0,p.__)("all of","mailpoet")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:(0,p.__)("none of","mailpoet")})]},"select-operator"),(0,g.jsx)(il.ReactSelect,{dimension:"small",placeholder:(0,p.__)("Search attributes","mailpoet"),options:d,value:u,onChange:m},"select-segment-product-attribute"),c.length>0&&(0,g.jsx)(il.ReactSelect,{dimension:"small",isMulti:!0,placeholder:(0,p.__)("Search attributes terms","mailpoet"),options:c,value:h,onChange:_},"select-segment-product-attribute-terms"),(0,g.jsx)(Pl,{filterIndex:e,defaultTimeframe:ll.VE.ALL_TIME})]})},[ql.Ag.PURCHASED_TAG]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getProductTags(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ALL&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,isMinWidth:!0,onChange:t=>{a({operator:t.target.value},e)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator"),(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",placeholder:(0,p.__)("Search tags","mailpoet"),options:i,value:(0,mn.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"),(0,g.jsx)(Pl,{filterIndex:e,defaultTimeframe:ll.VE.ALL_TIME})]})},[ql.Ag.SINGLE_ORDER_VALUE]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.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)(Ei.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)(Pl,{filterIndex:e})]})},[ql.Ag.TOTAL_SPENT]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.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)(Ei.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)(Pl,{filterIndex:e})]})},[ql.Ag.AVERAGE_SPENT]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.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)(Pl,{filterIndex:e})]})},[ql.Ag.USED_COUPON_CODE]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),[i,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,h]=(0,r.useState)(1),[_,f]=(0,r.useState)(!0),[b,x]=(0,r.useState)(""),[v,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,mn.uniqBy)(e=>e.value,[...e,...s])),h(n)),e||c(!1)}).fail(e=>{y(e.errors)}))},[t.coupon_code_ids]),j=(0,mn.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,u,b,_),s(!0))},[i,u,b,w,_]),(0,r.useEffect)(()=>{Array.isArray(t.coupon_code_ids)||a({coupon_code_ids:[]},e),(0,ar.J)(t.operator,ll.dP)||a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[v.length>0&&(0,g.jsx)(oi,{errors:v}),i?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Ei.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:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-coupon-codes"),(0,g.jsx)(il.ReactSelect,{isFullWidth:!0,isMulti:!0,isLoadingMore:d,placeholder:m.U.I18n.t("selectWooCouponCodes"),options:n,value:(0,mn.filter)(e=>{if(t.coupon_code_ids)return-1!==t.coupon_code_ids.indexOf(e.value)},n),onInputChange:e=>{j(e)},onChange:t=>{a({coupon_code_ids:(t||[]).map(e=>e.value)},e)},automationId:"select-shipping-methods",onMenuScrollToBottom:()=>{!d&&_&&w(!1,u,b,_)}},"select-coupon-codes")]}),(0,g.jsx)(Pl,{filterIndex:e})]}):(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,p.__)("Loading coupon codes...","mailpoet")})]})},[ql.Ag.USED_PAYMENT_METHOD]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getPaymentMethods(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Ei.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:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-payment-methods"),(0,g.jsx)(il.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooPaymentMethods"),options:i,value:(0,mn.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)(Pl,{filterIndex:e})]})},[ql.Ag.USED_SHIPPING_METHOD]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getShippingMethods(),[]).map(e=>({value:e.instanceId,label:e.name}));return(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Ei.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:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator-used-shipping-methods"),(0,g.jsx)(il.ReactSelect,{isFullWidth:!0,isMulti:!0,placeholder:m.U.I18n.t("selectWooShippingMethods"),options:i,value:(0,mn.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)(Pl,{filterIndex:e})]})},[ql.Ag.FIRST_ORDER]:Wl};function Ql({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz);(0,r.useEffect)(()=>{t.action===ll.gw.WORDPRESS_ROLE&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]);const s=(0,C.A)(e=>e(dl.Hz).getWordpressRoles(),[]).map(e=>({value:e.role_id,label:e.role_name}));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsxs)(Be.Select,{isFullWidth:!0,automationId:"segment-wordpress-role-condition",value:t.operator,onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select")}),(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsx)(il.ReactSelect,{dimension:"small",isMulti:!0,automationId:"segment-wordpress-role",placeholder:m.U.I18n.t("selectUserRolePlaceholder"),options:s,value:(0,mn.filter)(e=>{if(t.wordpressRole)return-1!==t.wordpressRole.indexOf(e.value)},s),onChange:t=>{a({wordpressRole:(0,mn.map)("value",t)},e)}})})]})}let Jl=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.DORMANT="dormant",e.NOT_DORMANT="not_dormant",e}({});const Zl=[Jl.HIGHER_THAN,Jl.LOWER_THAN,Jl.EQUALS,Jl.NOT_EQUALS,Jl.UNKNOWN,Jl.NOT_UNKNOWN,Jl.DORMANT,Jl.NOT_DORMANT];function Xl(e){return!!(0,ll.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 ed({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.A)(dl.Hz);return(0,r.useEffect)(()=>{void 0===t.operator&&i({operator:"equals",value:""},e)},[i,t,e]),(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.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,ll.uA)(t.operator)&&(0,g.jsx)(It.p,{"data-automation-id":"text-custom-field-value",value:t.value||"",onChange:t=>{a("value",e,t)},placeholder:m.U.I18n.t("value")},"input")]})}function td(e){return!!(0,ll.uA)(e.operator)||"string"==typeof e.value&&e.value.length>0}function ad({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.Hz).getCustomFieldsList(),[]),n=(0,mn.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)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.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:ll.FI.BLANK,children:m.U.I18n.t("isBlank")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:m.U.I18n.t("isNotBlank")})]},"select"),!(0,ll.uA)(t.operator)&&(0,g.jsx)(il.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 id=a(86452),sd=a(16519),nd=a(51831);function rd(e){const t=(0,Ul.a)(e);return(0,sd.m)(t,function(e){const t=(0,Ul.a)(e),a=(0,nd.w)(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t))+1}var od=a(98491);function ld(e){return(0,od.k)(e,{weekStartsOn:1})}function dd(e){const t=(0,Ul.a)(e),a=t.getFullYear(),i=(0,nd.w)(e,0);i.setFullYear(a+1,0,4),i.setHours(0,0,0,0);const s=ld(i),n=(0,nd.w)(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const r=ld(n);return t.getTime()>=s.getTime()?a+1:t.getTime()>=r.getTime()?a:a-1}function cd(e){const t=(0,Ul.a)(e),a=+ld(t)-+function(e){const t=dd(e),a=(0,nd.w)(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),ld(a)}(t);return Math.round(a/xl.my)+1}function md(e,t){const a=(0,Ul.a)(e),i=a.getFullYear(),s=(0,id.q)(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,r=(0,nd.w)(e,0);r.setFullYear(i+1,0,n),r.setHours(0,0,0,0);const o=(0,od.k)(r,t),l=(0,nd.w)(e,0);l.setFullYear(i,0,n),l.setHours(0,0,0,0);const d=(0,od.k)(l,t);return a.getTime()>=o.getTime()?i+1:a.getTime()>=d.getTime()?i:i-1}function ud(e,t){const a=(0,Ul.a)(e),i=+(0,od.k)(a,t)-+function(e,t){const a=(0,id.q)(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=md(e,t),n=(0,nd.w)(e,0);return n.setFullYear(s,0,i),n.setHours(0,0,0,0),(0,od.k)(n,t)}(a,t);return Math.round(i/xl.my)+1}function pd(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const hd={y(e,t){const a=e.getFullYear(),i=a>0?a:1-a;return pd("yy"===t?i%100:i,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):pd(a+1,2)},d:(e,t)=>pd(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>pd(e.getHours()%12||12,t.length),H:(e,t)=>pd(e.getHours(),t.length),m:(e,t)=>pd(e.getMinutes(),t.length),s:(e,t)=>pd(e.getSeconds(),t.length),S(e,t){const a=t.length,i=e.getMilliseconds();return pd(Math.trunc(i*Math.pow(10,a-3)),t.length)}},gd={G:function(e,t,a){const i=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(i,{width:"abbreviated"});case"GGGGG":return a.era(i,{width:"narrow"});default:return a.era(i,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),i=t>0?t:1-t;return a.ordinalNumber(i,{unit:"year"})}return hd.y(e,t)},Y:function(e,t,a,i){const s=md(e,i),n=s>0?s:1-s;return"YY"===t?pd(n%100,2):"Yo"===t?a.ordinalNumber(n,{unit:"year"}):pd(n,t.length)},R:function(e,t){return pd(dd(e),t.length)},u:function(e,t){return pd(e.getFullYear(),t.length)},Q:function(e,t,a){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return pd(i,2);case"Qo":return a.ordinalNumber(i,{unit:"quarter"});case"QQQ":return a.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(i,{width:"narrow",context:"formatting"});default:return a.quarter(i,{width:"wide",context:"formatting"})}},q:function(e,t,a){const i=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return pd(i,2);case"qo":return a.ordinalNumber(i,{unit:"quarter"});case"qqq":return a.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(i,{width:"narrow",context:"standalone"});default:return a.quarter(i,{width:"wide",context:"standalone"})}},M:function(e,t,a){const i=e.getMonth();switch(t){case"M":case"MM":return hd.M(e,t);case"Mo":return a.ordinalNumber(i+1,{unit:"month"});case"MMM":return a.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(i,{width:"narrow",context:"formatting"});default:return a.month(i,{width:"wide",context:"formatting"})}},L:function(e,t,a){const i=e.getMonth();switch(t){case"L":return String(i+1);case"LL":return pd(i+1,2);case"Lo":return a.ordinalNumber(i+1,{unit:"month"});case"LLL":return a.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(i,{width:"narrow",context:"standalone"});default:return a.month(i,{width:"wide",context:"standalone"})}},w:function(e,t,a,i){const s=ud(e,i);return"wo"===t?a.ordinalNumber(s,{unit:"week"}):pd(s,t.length)},I:function(e,t,a){const i=cd(e);return"Io"===t?a.ordinalNumber(i,{unit:"week"}):pd(i,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):hd.d(e,t)},D:function(e,t,a){const i=rd(e);return"Do"===t?a.ordinalNumber(i,{unit:"dayOfYear"}):pd(i,t.length)},E:function(e,t,a){const i=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(i,{width:"short",context:"formatting"});default:return a.day(i,{width:"wide",context:"formatting"})}},e:function(e,t,a,i){const s=e.getDay(),n=(s-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return pd(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,a,i){const s=e.getDay(),n=(s-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return pd(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(s,{width:"narrow",context:"standalone"});case"cccccc":return a.day(s,{width:"short",context:"standalone"});default:return a.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,a){const i=e.getDay(),s=0===i?7:i;switch(t){case"i":return String(s);case"ii":return pd(s,t.length);case"io":return a.ordinalNumber(s,{unit:"day"});case"iii":return a.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(i,{width:"short",context:"formatting"});default:return a.day(i,{width:"wide",context:"formatting"})}},a:function(e,t,a){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(i,{width:"narrow",context:"formatting"});default:return a.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,a){const i=e.getHours();let s;switch(s=12===i?"noon":0===i?"midnight":i/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,a){const i=e.getHours();let s;switch(s=i>=17?"evening":i>=12?"afternoon":i>=4?"morning":"night",t){case"B":case"BB":case"BBB":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return hd.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):hd.H(e,t)},K:function(e,t,a){const i=e.getHours()%12;return"Ko"===t?a.ordinalNumber(i,{unit:"hour"}):pd(i,t.length)},k:function(e,t,a){let i=e.getHours();return 0===i&&(i=24),"ko"===t?a.ordinalNumber(i,{unit:"hour"}):pd(i,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):hd.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):hd.s(e,t)},S:function(e,t){return hd.S(e,t)},X:function(e,t,a){const i=e.getTimezoneOffset();if(0===i)return"Z";switch(t){case"X":return fd(i);case"XXXX":case"XX":return bd(i);default:return bd(i,":")}},x:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"x":return fd(i);case"xxxx":case"xx":return bd(i);default:return bd(i,":")}},O:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_d(i,":");default:return"GMT"+bd(i,":")}},z:function(e,t,a){const i=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_d(i,":");default:return"GMT"+bd(i,":")}},t:function(e,t,a){return pd(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return pd(e.getTime(),t.length)}};function _d(e,t=""){const a=e>0?"-":"+",i=Math.abs(e),s=Math.trunc(i/60),n=i%60;return 0===n?a+String(s):a+String(s)+t+pd(n,2)}function fd(e,t){return e%60==0?(e>0?"-":"+")+pd(Math.abs(e)/60,2):bd(e,t)}function bd(e,t=""){const a=e>0?"-":"+",i=Math.abs(e);return a+pd(Math.trunc(i/60),2)+t+pd(i%60,2)}const xd=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},vd=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},yd={p:vd,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],i=a[1],s=a[2];if(!s)return xd(e,t);let n;switch(i){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",xd(i,t)).replace("{{time}}",vd(s,t))}},wd=/^D+$/,jd=/^Y+$/,Sd=["D","DD","YY","YYYY"],kd=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Nd=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Cd=/^'([^]*?)'?$/,Ed=/''/g,Ud=/[a-zA-Z]/;function Id(e,t,a){const i=(0,id.q)(),s=a?.locale??i.locale??Oi,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,r=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,o=(0,Ul.a)(e);if(!Il(o))throw new RangeError("Invalid time value");let l=t.match(Nd).map(e=>{const t=e[0];return"p"===t||"P"===t?(0,yd[t])(e,s.formatLong):e}).join("").match(kd).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Ad(e)};if(gd[t])return{isToken:!0,value:e};if(t.match(Ud))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(l=s.localize.preprocessor(o,l));const d={firstWeekContainsDate:n,weekStartsOn:r,locale:s};return l.map(i=>{if(!i.isToken)return i.value;const n=i.value;return(!a?.useAdditionalWeekYearTokens&&function(e){return jd.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return wd.test(e)}(n))&&function(e,t,a){const i=function(e,t,a){const i="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${i} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(console.warn(i),Sd.includes(e))throw new RangeError(i)}(n,t,String(e)),(0,gd[n[0]])(o,n,s.localize,d)}).join("")}function Ad(e){const t=e.match(Cd);return t?t[1].replace(Ed,"'"):e}function Td(e){return!!(0,ll.uA)(e.operator)||("month"===e.date_type||!("string"!=typeof e.operator||e.operator.length<1))&&"string"==typeof e.value&&e.value.length>1}const Pd=e=>{if(null!==e){if(Array.isArray(e))throw new Error("convertDateToString can process only single date array given");return Id(e,"yyyy-MM-dd 00:00:00")}},Rd=e=>{const t=vl(e);if(Il(t))return t},Dd={month:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{Td(t)||e((0,mn.assign)(t,{value:"2017-01-01 00:00:00"}),a),void 0===t.operator&&e((0,mn.assign)(t,{operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,onChange:i=>{e((0,mn.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,ll.uA)(t.operator)&&(0,g.jsxs)(Be.Select,{value:t.value,onChange:i=>{e((0,mn.assign)(t,{value:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"2017-01-01 00:00:00",children:(0,p.__)("january","mailpoet")}),(0,g.jsx)("option",{value:"2017-02-01 00:00:00",children:(0,p.__)("february","mailpoet")}),(0,g.jsx)("option",{value:"2017-03-01 00:00:00",children:(0,p.__)("march","mailpoet")}),(0,g.jsx)("option",{value:"2017-04-01 00:00:00",children:(0,p.__)("april","mailpoet")}),(0,g.jsx)("option",{value:"2017-05-01 00:00:00",children:(0,p.__)("may","mailpoet")}),(0,g.jsx)("option",{value:"2017-06-01 00:00:00",children:(0,p.__)("june","mailpoet")}),(0,g.jsx)("option",{value:"2017-07-01 00:00:00",children:(0,p.__)("july","mailpoet")}),(0,g.jsx)("option",{value:"2017-08-01 00:00:00",children:(0,p.__)("august","mailpoet")}),(0,g.jsx)("option",{value:"2017-09-01 00:00:00",children:(0,p.__)("september","mailpoet")}),(0,g.jsx)("option",{value:"2017-10-01 00:00:00",children:(0,p.__)("october","mailpoet")}),(0,g.jsx)("option",{value:"2017-11-01 00:00:00",children:(0,p.__)("november","mailpoet")}),(0,g.jsx)("option",{value:"2017-12-01 00:00:00",children:(0,p.__)("december","mailpoet")})]},"select")]})},year:function({onChange:e,item:t,filterIndex:a}){const i=(s=new Date,(0,Ul.a)(s).getFullYear());var s;return(0,r.useEffect)(()=>{Td(t)||e((0,mn.assign)(t,{value:`${i}-01-01 00:00:00`,operator:"equals"}),a)},[i,e,t,a]),(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,onChange:i=>{e((0,mn.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:ll.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),(0,g.jsx)(Be.Select,{value:t.value,onChange:i=>{e((0,mn.assign)(t,{value:i.target.value}),a)},children:(0,mn.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,mn.assign)(t,{value:`${Id(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,onChange:i=>{e((0,mn.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:ll.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,ll.uA)(t.operator)&&(0,g.jsx)(Li.t,{onChange:i=>e((0,mn.assign)(t,{value:Pd(i)}),a),selected:t.value?Rd(t.value):void 0,dateFormat:"MM/yyyy",showMonthYearPicker:!0})]})},year_month_day:function({onChange:e,item:t,filterIndex:a}){return(0,r.useEffect)(()=>{Td(t)||e((0,mn.assign)(t,{value:`${Id(new Date,"yyyy-MM-dd")} 00:00:00`,operator:"equals"}),a)},[e,t,a]),(0,g.jsxs)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,onChange:i=>{e((0,mn.assign)(t,{operator:i.target.value}),a)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:"before",children:(0,p._x)("before",'Meaning: "Subscriber subscribed before April"',"mailpoet")}),(0,g.jsx)("option",{value:"after",children:(0,p._x)("after",'Meaning: "Subscriber subscribed after April',"mailpoet")}),(0,g.jsx)("option",{value:ll.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,ll.uA)(t.operator)&&(0,g.jsx)(Li.t,{dateFormat:"MMM d, yyyy",onChange:i=>e((0,mn.assign)(t,{value:Pd(i)}),a),selected:t.value?Rd(t.value):void 0})]})}};var Fd=function(e){return e.DATE="date",e.TEXT="text",e.TEXTAREA="textarea",e.RADIO="radio",e.CHECKBOX="checkbox",e.SELECT="select",e}(Fd||{});const Od={[Fd.TEXT]:Xl,[Fd.TEXTAREA]:Xl,[Fd.RADIO]:td,[Fd.SELECT]:td,[Fd.CHECKBOX]:function(e){return!!(0,ll.uA)(e.operator)||["1","0"].includes(e.value)},[Fd.DATE]:Td},Md={[Fd.TEXT]:ed,[Fd.TEXTAREA]:ed,[Fd.RADIO]:ad,[Fd.SELECT]:ad,[Fd.CHECKBOX]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilterFromEvent:a,updateSegmentFilter:i}=(0,fe.A)(dl.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)(Ei.Grid.CenteredRow,{children:[(0,g.jsxs)(Be.Select,{value:t.operator,onChange:t=>{a("operator",e,t)},children:[(0,g.jsx)("option",{value:"equals",children:(0,p.__)("is","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.BLANK,children:(0,p.__)("is blank","mailpoet")}),(0,g.jsx)("option",{value:ll.FI.NOT_BLANK,children:(0,p.__)("is not blank","mailpoet")})]},"select-operator"),!(0,ll.uA)(t.operator)&&(0,g.jsxs)(Be.Select,{value:t.value,onChange:t=>{a("value",e,t)},children:[(0,g.jsx)("option",{value:"1",children:(0,p.__)("checked","mailpoet")}),(0,g.jsx)("option",{value:"0",children:(0,p.__)("unchecked","mailpoet")})]},"select")]})},[Fd.DATE]:function({customField:e,filterIndex:t}){const a=(0,C.A)(e=>e(dl.Hz).getSegmentFilter(t),[t]),{updateSegmentFilter:i}=(0,fe.A)(dl.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=Dd[e.params.date_type];return s?(0,g.jsx)(s,{item:a,onChange:i,filterIndex:t}):null}};function Ld(){return(0,g.jsx)(Ba,{message:(()=>{const e=m.U.I18n.t("premiumFeatureMultipleConditions");return(0,g.jsx)("p",{children:b()(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)(Ge.$,{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 $d={[ll.gw.WORDPRESS_ROLE]:Ql,[ll.gw.SUBSCRIBER_SCORE]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz);return(0,r.useEffect)(()=>{Zl.includes(t.operator)||a({operator:Jl.HIGHER_THAN},e),t.operator!==Jl.HIGHER_THAN&&t.operator!==Jl.LOWER_THAN&&t.operator!==Jl.EQUALS&&t.operator!==Jl.NOT_EQUALS||void 0!==t.value||a({value:""},e),t.operator!==Jl.UNKNOWN&&t.operator!==Jl.NOT_UNKNOWN&&t.operator!==Jl.DORMANT&&t.operator!==Jl.NOT_DORMANT||a({value:null},e)},[a,t,e]),(0,g.jsx)(Ei.Grid.CenteredRow,{children:(s=a=>"{condition}"===a?(0,g.jsxs)(Be.Select,{value:t.operator,automationId:"segment-subscriber-score-operator",onChange:t=>{i("operator",e,t)},children:[(0,g.jsx)("option",{value:Jl.HIGHER_THAN,children:m.U.I18n.t("higherThan")}),(0,g.jsx)("option",{value:Jl.LOWER_THAN,children:m.U.I18n.t("lowerThan")}),(0,g.jsx)("option",{value:Jl.EQUALS,children:m.U.I18n.t("equals")}),(0,g.jsx)("option",{value:Jl.NOT_EQUALS,children:m.U.I18n.t("notEquals")}),(0,g.jsx)("option",{value:Jl.UNKNOWN,children:m.U.I18n.t("unknown")}),(0,g.jsx)("option",{value:Jl.NOT_UNKNOWN,children:m.U.I18n.t("notUnknown")}),(0,g.jsx)("option",{value:Jl.DORMANT,children:m.U.I18n.t("dormant")}),(0,g.jsx)("option",{value:Jl.NOT_DORMANT,children:m.U.I18n.t("notDormant")})]},"select"):"{score}"===a?(t.operator===Jl.HIGHER_THAN||t.operator===Jl.LOWER_THAN||t.operator===Jl.EQUALS||t.operator===Jl.NOT_EQUALS)&&(0,g.jsx)(It.p,{type:"number",value:t.value||"","data-automation-id":"segment-subscriber-score-value",onChange:t=>{i("value",e,t)},min:"0",placeholder:m.U.I18n.t("subscriberScorePlaceholder")},"input"):"string"==typeof a&&a.trim().length>0?t.operator!==Jl.UNKNOWN&&t.operator!==Jl.NOT_UNKNOWN&&t.operator!==Jl.DORMANT&&t.operator!==Jl.NOT_DORMANT&&(0,g.jsx)("div",{children:a},"score"):null,m.U.I18n.t("subscriberScoreSentence").split(/({condition})|({score})|(\b%\b)/gim).map(s))});var s},[ll.gw.SUBSCRIBED_DATE]:Wl,[ll.gw.MAILPOET_CUSTOM_FIELD]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getCustomFieldsList(),[]),s=(0,mn.find)({id:Number(t.custom_field_id)},i),n=i.map(e=>({value:e.id.toString(),label:e.name})),r=Md[t.custom_field_type];return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{children:(0,g.jsx)(il.ReactSelect,{dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectCustomFieldPlaceholder"),options:n,automationId:"select-custom-field",value:(0,mn.find)(e=>{if(t.custom_field_id)return t.custom_field_id===e.value},n),onChange:t=>{const s=(0,mn.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})})]})},[ll.gw.SUBSCRIBED_TO_LIST]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=(0,C.A)(e=>e(dl.Hz).getStaticSegmentsList(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.A)(dl.Hz);(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&i({operator:ll.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)(Be.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(il.ReactSelect,{dimension:"small",isMulti:!0,placeholder:m.U.I18n.t("searchLists"),options:n,value:(0,mn.filter)(e=>{if(!t.segments)return;const a=e.value;return-1!==t.segments.indexOf(a)},n),onChange:t=>{i({segments:(0,mn.map)((0,mn.parseInt)(10),(0,mn.map)("value",t))},e)}})]})},[ll.gw.SUBSCRIBER_TAG]:function({filterIndex:e}){return Sa.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag",(0,g.jsx)(Ld,{}),e)},[ll.gw.SUBSCRIBER_FIRST_NAME]:Yl,[ll.gw.SUBSCRIBER_LAST_NAME]:Yl,[ll.gw.SUBSCRIBER_EMAIL]:Yl,[ll.gw.SUBSCRIBED_VIA_FORM]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=(0,C.A)(e=>e(dl.Hz).getSignupForms(),[]),{updateSegmentFilter:i,updateSegmentFilterFromEvent:s}=(0,fe.A)(dl.Hz);(0,r.useEffect)(()=>{t.operator!==ll.dP.ANY&&t.operator!==ll.dP.NONE&&i({operator:ll.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)(Be.Select,{isMinWidth:!0,value:t.operator,onChange:t=>{s("operator",e,t)},children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select"),(0,g.jsx)(il.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)}})]})},[ll.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE]:Vl,[ll.gw.SUBSCRIBER_LAST_PURCHASE_DATE]:Vl,[ll.gw.SUBSCRIBER_LAST_OPEN_DATE]:Vl,[ll.gw.SUBSCRIBER_LAST_CLICK_DATE]:Vl,[ll.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE]:Vl,[ll.gw.SUBSCRIBER_LAST_SENDING_DATE]:Vl},Bd={[ll.dx.Automations]:function(e){return!!Object.values(cl.g).some(t=>t===e.action)&&(e.action!==cl.g.ENTERED_AUTOMATION||function(e){return(e.operator===ll.dP.ANY||e.operator===ll.dP.NONE||e.operator===ll.dP.ALL)&&Array.isArray(e.automation_ids)&&e.automation_ids.length>0}(e))},[ll.dx.Email]:function(e){return!!Object.values(ll._R).some(t=>t===e.action)&&(e.action===ll._R.CLICKED_ANY||(e.action===ll._R.CLICKED?!!e.newsletter_id:[ll._R.OPENED,ll._R.MACHINE_OPENED,ll._R.WAS_SENT].includes(e.action)?Array.isArray(e.newsletters)&&e.newsletters.length>0:[ll._R.OPENS_ABSOLUTE_COUNT,ll._R.MACHINE_OPENS_ABSOLUTE_COUNT].includes(e.action)?Rl(e)&&!!e.opens&&!!e.operator:ll._R.NUMBER_RECEIVED===e.action?Rl(e)&&!!e.emails&&!!e.operator:e.action===ll._R.NUMBER_OF_CLICKS&&Rl(e)&&!!e.clicks&&!!e.operator))},[ll.dx.WooCommerce]:function(e){return!!Object.values(ql.Ag).some(t=>t===e.action)&&(e.action===ql.Ag.PURCHASED_CATEGORY?function(e){return!(void 0===e.category_ids||0===e.category_ids.length||!e.operator||!Rl(e))}(e):e.action===ql.Ag.PURCHASED_PRODUCT?function(e){return!(void 0===e.product_ids||0===e.product_ids.length||!e.operator||!Rl(e))}(e):e.action===ql.Ag.PURCHASED_PRODUCT_VARIATION?function(e){return Array.isArray(e.variation_ids)&&e.variation_ids.length>0&&!!e.operator&&Rl(e)}(e):e.action===ql.Ag.CUSTOMER_IN_COUNTRY?function(e){return!(void 0===e.country_code||0===e.country_code.length)}(e):[ql.Ag.NUMBER_OF_ORDERS,ql.Ag.NUMBER_OF_ORDERS_WITH_COUPON].includes(e.action)?function(e){return!(!e.number_of_orders_count||!Rl(e)||!e.number_of_orders_type)}(e):e.action===ql.Ag.TOTAL_SPENT?function(e){return!(!e.total_spent_amount||!Rl(e)||!e.total_spent_type)}(e):e.action===ql.Ag.SINGLE_ORDER_VALUE?function(e){return!(!e.single_order_value_amount||!Rl(e)||!e.single_order_value_type)}(e):e.action===ql.Ag.AVERAGE_SPENT?function(e){return!(!e.average_spent_amount||!e.average_spent_type||!Rl(e))}(e):e.action===ql.Ag.USED_PAYMENT_METHOD?function(e){return!(!e.payment_methods||e.payment_methods.length<1||!e.operator||!Rl(e))}(e):e.action===ql.Ag.USED_SHIPPING_METHOD?function(e){return!(!e.shipping_methods||e.shipping_methods.length<1||!e.operator||!Rl(e))}(e):e.action===ql.Ag.PURCHASE_DATE?$l(e):e.action===ql.Ag.NUMBER_OF_REVIEWS?function(e){return!!(e.count&&e.count_type&&e.rating&&Rl(e))}(e):e.action===ql.Ag.USED_COUPON_CODE?function(e){return!(!e.coupon_code_ids||e.coupon_code_ids.length<1||!(0,ar.J)(e.operator,ll.dP)||!Rl(e))}(e):e.action===ql.Ag.FIRST_ORDER?$l(e):e.action===ql.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)&&Rl(e))}(e):[ql.Ag.CUSTOMER_IN_POSTAL_CODE,ql.Ag.CUSTOMER_IN_CITY].includes(e.action)?Gl(e):e.action!==ql.Ag.PURCHASED_TAG||function(e){return!(void 0===e.tag_ids||0===e.tag_ids.length||!e.operator||!Rl(e))}(e))},[ll.dx.WordPressRole]:function(e){return e.action&&e.action!==ll.gw.WORDPRESS_ROLE?e.action===ll.gw.MAILPOET_CUSTOM_FIELD?function(e){const t=Od[e.custom_field_type];return!!t&&t(e)}(e):e.action===ll.gw.SUBSCRIBER_SCORE?function(e){if(e.operator===Jl.HIGHER_THAN||e.operator===Jl.LOWER_THAN||e.operator===Jl.EQUALS||e.operator===Jl.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===Jl.UNKNOWN||e.operator===Jl.NOT_UNKNOWN||e.operator===Jl.DORMANT||e.operator===Jl.NOT_DORMANT}(e):e.action===ll.gw.SUBSCRIBED_TO_LIST?function(e){return(e.operator===ll.dP.ANY||e.operator===ll.dP.ALL||e.operator===ll.dP.NONE)&&Array.isArray(e.segments)&&e.segments.length>0}(e):e.action===ll.gw.SUBSCRIBER_TAG?function(e){return Sa.Hooks.applyFilters("mailpoet_dynamic_segments_filter_subscriber_tag_validate",!1,e)}(e):[ll.gw.SUBSCRIBER_FIRST_NAME,ll.gw.SUBSCRIBER_LAST_NAME,ll.gw.SUBSCRIBER_EMAIL].includes(e.action)?Gl(e):[ll.gw.SUBSCRIBER_LAST_ENGAGEMENT_DATE,ll.gw.SUBSCRIBER_LAST_PURCHASE_DATE,ll.gw.SUBSCRIBER_LAST_OPEN_DATE,ll.gw.SUBSCRIBER_LAST_CLICK_DATE,ll.gw.SUBSCRIBER_LAST_PAGE_VIEW_DATE,ll.gw.SUBSCRIBER_LAST_SENDING_DATE].includes(e.action)?$l(e):e.action===ll.gw.SUBSCRIBED_VIA_FORM?function(e){return(e.operator===ll.dP.ANY||e.operator===ll.dP.NONE)&&Array.isArray(e.form_ids)&&e.form_ids.length>0}(e):!(!e.operator||!e.value)&&!!Object.values(Ol).includes(e.operator)&&$l(e):Array.isArray(e.wordpressRole)&&e.wordpressRole.length>0},[ll.dx.WooCommerceMembership]:function(e){const t=!e.plan_ids||!e.plan_ids.length||!e.operator;return e.action!==ql.HM.MEMBER_OF||!t},[ll.dx.WooCommerceSubscription]:function(e){const t=!e.product_ids||!e.product_ids.length||!e.operator;return e.action!==ql.IC.ACTIVE_SUBSCRIPTIONS||!t}};function Wd(e){return!(e.length<1)&&0===e.map(e=>void 0!==Bd[e.segmentType]&&Bd[e.segmentType](e)).filter(e=>!1===e).length}let Vd,qd;function Hd(){const e=(0,C.A)(e=>e(dl.Hz).getSegment(),[]),t=(0,C.A)(e=>e(dl.Hz).getSubscriberCount(),[]),{updateSubscriberCount:a}=(0,fe.A)(dl.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,Si.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 ki().isEqual(t,Vd)?Promise.resolve(qd):(Vd={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 qd={count:t.count,errors:void 0},qd}))}(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)(()=>{Wd(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 zd={[ll.dx.Automations]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=ul[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[ll.dx.Email]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=Fl[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[ll.dx.WooCommerce]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),a=Kl[t.action];return a?(0,g.jsx)(a,{filterIndex:e}):null},[ll.dx.WordPressRole]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]);let a;return a=t.action?$d[t.action]:Ql,a?(0,g.jsx)(a,{filterIndex:e}):null},[ll.dx.WooCommerceMembership]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.Hz).getMembershipPlans(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===ql.HM.MEMBER_OF&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsxs)(Be.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooMembership"),options:s,value:(0,mn.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")})]})},[ll.dx.WooCommerceSubscription]:function({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]),{updateSegmentFilter:a,updateSegmentFilterFromEvent:i}=(0,fe.A)(dl.Hz),s=(0,C.A)(e=>e(dl.Hz).getSubscriptionProducts(),[]).map(e=>({value:e.id,label:e.name}));return(0,r.useEffect)(()=>{t.action===ql.IC.ACTIVE_SUBSCRIPTIONS&&t.operator!==ll.dP.ANY&&t.operator!==ll.dP.ALL&&t.operator!==ll.dP.NONE&&a({operator:ll.dP.ANY},e)},[a,t,e]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsxs)(Be.Select,{value:t.operator,onChange:t=>{i("operator",e,t)},automationId:"select-operator",children:[(0,g.jsx)("option",{value:ll.dP.ANY,children:m.U.I18n.t("anyOf")}),(0,g.jsx)("option",{value:ll.dP.ALL,children:m.U.I18n.t("allOf")}),(0,g.jsx)("option",{value:ll.dP.NONE,children:m.U.I18n.t("noneOf")})]},"select-operator")}),(0,g.jsx)(Ei.Grid.CenteredRow,{children:(0,g.jsx)(il.ReactSelect,{isMulti:!0,dimension:"small",isFullWidth:!0,placeholder:m.U.I18n.t("selectWooSubscription"),options:s,value:(0,mn.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 Gd({filterIndex:e}){const t=(0,C.A)(t=>t(dl.Hz).getSegmentFilter(e),[e]);if(void 0===t||void 0===zd[t.segmentType])return null;const a=zd[t.segmentType];return(0,g.jsx)(a,{filterIndex:e})}function Yd(){const e=(0,C.A)(e=>e(dl.Hz).getSegment(),[]),t=[ll._R.OPENED,ll._R.OPENS_ABSOLUTE_COUNT,ll._R.MACHINE_OPENED,ll._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 Kd=Sa.Hooks.applyFilters("mailpoet_dynamic_segments_form_filters_before",()=>null),Qd=Sa.Hooks.applyFilters("mailpoet_dynamic_filters_filter_before",()=>null),Jd=Sa.Hooks.applyFilters("mailpoet_dynamic_filters_filter_after",()=>(0,g.jsx)("div",{className:"mailpoet-gap"})),Zd=Sa.Hooks.applyFilters("mailpoet_dynamic_segments_form_conditions_bottom",()=>null),Xd=Sa.Hooks.applyFilters("mailpoet_dynamic_segments_filter_group_before",()=>null);function ec({isNewSegment:e,newsletterId:t}){const{segment:a,segmentFilters:i,subscriberCount:s,filterRows:n,errors:o}=(0,C.A)(e=>{const t=e(dl.Hz).getSegment();return{segment:t,segmentFilters:e(dl.Hz).getAvailableFilters(),subscriberCount:e(dl.Hz).getSubscriberCount(),filterRows:e(dl.Hz).findFiltersValueForSegment(t),errors:e(dl.Hz).getErrors()}},[]),l=a.filters.length,d=m.U.capabilities.segmentFilters.value>0&&l>=m.U.capabilities.segmentFilters.value,{updateSegment:c,updateSegmentFilter:u,handleSave:h}=(0,fe.A)(dl.Hz),[_,f]=(0,r.useState)(!1),b=Sa.Hooks.applyFilters("mailpoet_dynamic_segments_form_add_condition_action",()=>{f(!0)}),x=Array.isArray(n)?((e,t)=>e.reduce((e,a)=>{const i=t.filters[a.index]?.group_id??0,s=e.find(e=>e.groupId===i);return s?s.rows.push(a):e.push({groupId:i,rows:[a]}),e},[]))(n,a):[],v=x.length>1;return(0,g.jsx)("div",{className:"mailpoet-form-container",children:(0,g.jsxs)("form",{children:[o.length>0&&(0,g.jsx)(oi,{errors:o.map(e=>({message:e}))}),(0,g.jsxs)(nl,{title:(0,p.__)("Details","mailpoet"),description:(0,p.__)("What do you want to call this segment?","mailpoet"),children:[(0,g.jsx)(rl,{slug:"name",title:(0,p.__)("Name","mailpoet"),children:(0,g.jsx)(It.p,{isFullWidth:!0,type:"text",name:"name",id:"field_name",value:a.name||"","data-automation-id":"input-name",onChange:e=>{c({name:e.target.value})},placeholder:(0,p.__)("Enter name","mailpoet")})}),(0,g.jsx)(rl,{slug:"description",title:(0,p.__)("Description","mailpoet"),description:(0,p.__)("This text box is for your own use and is never shown to your subscribers.","mailpoet"),children:(0,g.jsx)(It.p,{isFullWidth:!0,name:"description",id:"field_description",value:a.description||"","data-automation-id":"input-description",onChange:e=>{c({description:e.target.value})},placeholder:(0,p.__)("Enter description","mailpoet")})})]}),(0,g.jsx)(nl,{title:(0,p.__)("Conditions","mailpoet"),description:(0,p.__)("Set your segment constraints","mailpoet"),children:(0,g.jsx)(rl,{children:(0,g.jsxs)("div",{className:"mailpoet-segments-segments-section",children:[(0,g.jsx)(Kd,{}),x.map((e,t)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-segments-filter-group"+(v?" mailpoet-segments-filter-group-is-separated":""),"data-automation-id":`filter-group-${e.groupId}`,children:[(0,g.jsx)(Xd,{groupFilterRows:e.rows,groupId:e.groupId}),e.rows.map((t,a)=>(0,g.jsxs)(r.Fragment,{children:[(0,g.jsxs)("div",{className:"mailpoet-segments-grid","data-automation-id":`filter-row-${t.index}`,children:[(0,g.jsx)(Qd,{filterRows:n,groupFilterRows:e.rows,groupId:e.groupId,index:t.index}),(0,g.jsx)("div",{className:"mailpoet-segments-filter-selector",children:(0,g.jsx)(il.ReactSelect,{dimension:"small",placeholder:(0,p.__)("Select action","mailpoet"),options:i,value:t.filterValue,onChange:e=>{u({segmentType:e.group,action:e.value},t.index)},automationId:"select-segment-action",isFullWidth:!0})}),void 0!==t.index&&(0,g.jsx)(Gd,{filterIndex:t.index})]}),a<e.rows.length-1&&(0,g.jsx)(Jd,{index:t.index})]},t.index)),(0,g.jsx)("div",{className:"mailpoet-segments-filter-group-actions",children:(0,g.jsx)(ge.Ay,{type:"button",variant:"secondary",onClick:t=>{t.preventDefault(),b(a,c,e.groupId)},children:(0,p.__)("Add a condition","mailpoet")})})]}),t<x.length-1&&(0,g.jsx)(Jd,{index:e.rows[e.rows.length-1].index})]},e.groupId)),(0,g.jsxs)("div",{className:"mailpoet-segments-conditions-bottom",children:[(0,g.jsx)(Zd,{}),(!m.U.premiumActive||!m.U.hasValidPremiumKey||m.U.subscribersLimitReached||d)&&(0,g.jsx)(ol.S,{text:(0,p.__)("UPGRADE","mailpoet")}),_&&(0,g.jsx)(ts.D,{onRequestClose:()=>{f(!1)},data:{capabilities:{segmentFilters:0}},children:(0,p.__)("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)(Hd,{}),(0,g.jsx)(Yd,{})]}),(0,g.jsx)("div",{className:"mailpoet-form-actions",children:(0,g.jsx)(ge.Ay,{variant:"primary",type:"submit",onClick:a=>{a.preventDefault(),h(e,t)},disabled:!Wd(a.filters)||void 0===s.count,children:t?(0,p.__)("Save and return","mailpoet"):(0,p.__)("Save","mailpoet")})})]})]})})}function tc(){const e=(0,Ae.g)(),{pageLoaded:t,pageUnloaded:a}=(0,fe.A)(dl.Hz),i=(0,C.A)(e=>e(dl.Hz).getPreviousPage())||"/",s=(0,Ae.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)(qe.z,{heading:e.id?(0,p.__)("Edit segment","mailpoet"):(0,p.__)("Add new segment","mailpoet"),headingPrefix:(0,g.jsx)(qe.o,{id:"mailpoet-segments-back-button",href:`#${i}`,label:(0,p.__)("Return to previous page","mailpoet"),onClick:e=>{n&&(e.preventDefault(),window.location.href=`admin.php?page=mailpoet-newsletters#/send/${n}`)}})}),(0,g.jsx)(ec,{isNewSegment:o,newsletterId:n})]})}tc.displayName="SegmentEditor";var ac=a(62623);function ic(){const{notices:e}=(0,C.A)(e=>({notices:e(ac.store).getNotices()}),[]),{removeNotice:t}=(0,fe.A)(ac.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))]})}const sc={offset:0,limit:25,search:"",sort_by:"updated_at",sort_order:"desc",group:"all"};function nc(e){return e.split("/").map(e=>e.replace(/\]$/,"").split("[")).map(([e,t])=>[e,"number"==typeof sc[e]?parseInt(t,10):t]).reduce((e,[t,a])=>({...e,[t]:a}),{})}function rc(e=window.location.hash,t={}){return{...sc,...t,...nc(e)}}var oc=a(61479);let lc=!1;function dc(){if(lc)return;const e=window.mailpoet_segments_api;Ro.default.use(Ro.default.createRootURLMiddleware(`${e.root}/`)),Ro.default.use(Ro.default.createNonceMiddleware(e.nonce)),lc=!0}function cc(e){return Object.entries(e).reduce((e,[t,a])=>void 0!==a?{...e,[t]:a}:e,{})}const mc=[{id:"name",label:(0,p.__)("Segment","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!0,render:({item:e})=>(0,r.createElement)("div",{"data-automation-id":`mailpoet_dynamic_segment_name_${e.id}`},e.is_plugin_missing?(0,r.createElement)("span",null,e.name):(0,r.createElement)("a",{href:`#${oc.r$}/${e.id}`},e.name),e.description?(0,r.createElement)("div",null,e.description):null,e.is_plugin_missing?(0,r.createElement)("div",{className:"mailpoet-segments-dataviews__row-note","data-automation-id":`mailpoet_dynamic_segment_plugin_missing_message_${e.id}`},function(e){return(0,p.sprintf)((0,p.__)("Edit unavailable: %s","mailpoet"),e.missing_plugin_message?.message??(0,p.__)("Required plugin is inactive.","mailpoet"))}(e)):null)},{id:"subscribers",label:(0,p.__)("Number of subscribers","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>e.is_plugin_missing?(0,r.createElement)("span",null,"—"):(0,r.createElement)("div",{"data-automation-id":`mailpoet_dynamic_segment_count_all_${e.id}`},e.count_all)},{id:"subscribed",label:(0,p.__)("Subscribed","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>e.is_plugin_missing?null:"0"===e.count_subscribed?(0,r.createElement)("span",null,e.count_subscribed):(0,r.createElement)("a",{"data-automation-id":`mailpoet_dynamic_segment_count_subscribed_${e.id}`,className:"components-button is-link mailpoet-listing-text-right-align",href:e.subscribers_url},e.count_subscribed)},{id:"updated_at",label:(0,p.__)("Modified","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{return t=e.updated_at,a=e.id,t?(0,r.createElement)("span",{"data-automation-id":a?`mailpoet_dynamic_segment_updated_at_${a}`:"mailpoet_dynamic_segment_updated_at"},(0,r.createElement)("span",null,m.U.Date.short(t)),(0,r.createElement)("br",null),(0,r.createElement)("span",null,m.U.Date.time(t))):(0,r.createElement)("span",null,"—");var t,a}}];var uc=a(79534);const pc={type:"table",fields:["subscribers","subscribed","updated_at"],titleField:"name",showTitle:!0};function hc(e,t=pc){return{...t,perPage:e.limit,page:Math.floor(e.offset/e.limit)+1,search:e.search,sort:{field:e.sort_by,direction:"asc"===e.sort_order?"asc":"desc"}}}function gc(e,t){return(e.perPage??25)===t.limit&&(e.page??1)===Math.floor(t.offset/t.limit)+1&&(e.search??"")===t.search&&(e.sort?.field??"updated_at")===t.sort_by&&(e.sort?.direction??"desc")===t.sort_order}function _c(e){return e.limit>0&&e.offset%e.limit!==0}var fc=a(87691);const bc=[{name:(0,p.__)("Recently Subscribed","mailpoet"),slug:"recently-subscribed",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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,p.__)("Engaged Subscribers (30 days)","mailpoet"),slug:"engaged-subscribers-30-days",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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,p.__)("Engaged Subscribers (3 months)","mailpoet"),slug:"engaged-subscribers-3-months",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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,p.__)("Engaged Subscribers (6 months)","mailpoet"),slug:"engaged-subscribers-6-months",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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:ll.Z2.OR},{name:(0,p.__)("Unengaged Subscribers","mailpoet"),slug:"unengaged-subscribers",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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:ll.VE.ALL_TIME}],isEssential:!0},{name:(0,p.__)("First-Time Buyers","mailpoet"),slug:"first-time-buyers",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made their first purchase in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:"firstOrder",operator:Ol.IN_THE_LAST,value:"30"}],isEssential:!0},{name:(0,p.__)("Recent Buyers","mailpoet"),slug:"recent-buyers",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made a purchase within the last 30 days. ","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:ll.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:0,days:"30"}]},{name:(0,p.__)("Repeat Buyers","mailpoet"),slug:"repeat-buyers",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made at least two purchases in the last 6 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:ll.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:1,days:"180"}]},{name:(0,p.__)("Loyal Buyers","mailpoet"),slug:"loyal-buyers",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("Customers who have made at least five purchases in the last 12 months.","mailpoet"),isEssential:!0,filters:[{segmentType:"woocommerce",action:"numberOfOrders",timeframe:ll.VE.IN_THE_LAST,number_of_orders_type:">",number_of_orders_count:4,days:"365"}]},{name:(0,p.__)("Win-Back","mailpoet"),slug:"win-back",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("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,p.__)("Lapsed Customers","mailpoet"),slug:"lapsed-customers",category:ll.eu.PURCHASE_HISTORY,description:(0,p.__)("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,p.__)("Clickers","mailpoet"),slug:"clickers",category:ll.eu.ENGAGEMENT,description:(0,p.__)("Contacts who regularly click on your emails in the last 90 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:ll.VE.IN_THE_LAST,clicks:"2",days:"90"}],isEssential:!1},{name:(0,p.__)("Non-Openers","mailpoet"),slug:"non-openers",category:ll.eu.ENGAGEMENT,description:(0,p.__)("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:ll.VE.IN_THE_LAST,emails:"0",days:"90"},{segmentType:"email",action:"opensAbsoluteCount",operator:"equals",timeframe:ll.VE.IN_THE_LAST,opens:"0",days:"90"}]},{name:(0,p.__)("Recent Clickers","mailpoet"),slug:"recent-clickers",category:ll.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have clicked on an email in the last 7 days.","mailpoet"),filters:[{segmentType:"email",action:"numberOfClicks",operator:"more",timeframe:ll.VE.IN_THE_LAST,clicks:"0",days:"7"}],isEssential:!1},{name:(0,p.__)("Recent Openers","mailpoet"),slug:"recent-openers",category:ll.eu.ENGAGEMENT,description:(0,p.__)("Contacts who have opened an email in the last 7 days.","mailpoet"),isEssential:!1,filters:[{segmentType:"email",action:"opensAbsoluteCount",operator:"more",timeframe:ll.VE.IN_THE_LAST,opens:"0",days:"7"}]},{name:(0,p.__)("Big Spenders","mailpoet"),slug:"big-spenders",category:ll.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who have completed $100 or more worth of orders in the last 12 months.","mailpoet"),isEssential:!1,filters:[{segmentType:"woocommerce",action:"totalSpent",timeframe:ll.VE.IN_THE_LAST,total_spent_type:">",total_spent_amount:100,days:"365"}]},{name:(0,p.__)("Used a discount code","mailpoet"),slug:"used-a-discount-code",category:ll.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who made a purchase with a coupon code in the last 30 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:ql.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:0,timeframe:ll.VE.IN_THE_LAST,days:"30"}],isEssential:!1},{name:(0,p.__)("Frequently uses discounts","mailpoet"),slug:"frequently-uses-discounts",category:ll.eu.SHOPPING_BEHAVIOR,description:(0,p.__)("Customers who have regularly used coupons in the last 90 days.","mailpoet"),filters:[{segmentType:"woocommerce",action:ql.Ag.NUMBER_OF_ORDERS_WITH_COUPON,number_of_orders_type:">",number_of_orders_count:2,timeframe:ll.VE.IN_THE_LAST,days:"90"}],isEssential:!1}],xc=[{slug:ll.eu.ENGAGEMENT,name:(0,p.__)("Engagement","mailpoet")},{slug:ll.eu.PURCHASE_HISTORY,name:(0,p.__)("Purchase History","mailpoet")},{slug:ll.eu.SHOPPING_BEHAVIOR,name:(0,p.__)("Shopping Behavior","mailpoet")}];function vc(e){const t=xc.find(t=>t.slug===e);return t?t.name:null}var yc=a(97384);const wc=[{name:"all",title:(0,g.jsx)(yc.Ic,{title:(0,p.__)("All","mailpoet"),count:bc.length})}];xc.forEach(e=>{const t=bc.filter(t=>t.category===e.slug).length;wc.push({name:e.slug,title:(0,g.jsx)(yc.Ic,{title:e.name,count:t})})});const jc=document.getElementById("dynamic_segments_container");function Sc(){const{setPreviousPage:e}=(0,fe.A)(dl.Hz),t=(0,Ae.zy)(),a=(0,r.useRef)(t.pathname);return(0,r.useEffect)(()=>{e(a.current),a.current=t.pathname},[t,e]),null}const kc=(0,o.withBoundary)(tc),Nc=(0,o.withBoundary)(function(){const e=(0,C.A)(e=>e(dl.Hz).getErrors(),[]),{createFromTemplate:t}=(0,fe.A)(dl.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)(qe.z,{className:"mailpoet-templates-header",heading:(0,p.__)("Start with a pre-built segment","mailpoet"),headingPrefix:(0,g.jsx)(qe.o,{href:"#/",label:(0,p.__)("Segments list","mailpoet"),"aria-label":(0,p.__)("Navigate to the segments list page","mailpoet")}),children:[(0,g.jsx)(fc.A,{label:(0,p.__)("Search segment templates","mailpoet"),onChange:()=>null}),(0,g.jsx)("a",{href:`#${oc.LX}`,"data-automation-id":"new-custom-segment",onClick:()=>{a()},className:"page-title-action",children:(0,p.__)("Or, create custom segment","mailpoet")})]}),e.length>0&&(0,g.jsx)(oi,{errors:e.map(e=>({message:e}))}),(0,g.jsx)(yc.Kp,{tabs:wc,children:e=>(0,g.jsx)(yc.xA,{children:bc.filter(t=>"all"===e.name||t.category===e.name).map(e=>(0,g.jsx)(yc.q7,{name:e.name,description:e.description,category:vc(e.category),badge:e.isEssential?"essential":void 0,onClick:()=>{t(e)}},e.slug))})}),(0,g.jsxs)(yc.wi,{children:[(0,g.jsx)("p",{children:(0,p.__)("Want to set your own conditions?","mailpoet")}),(0,g.jsx)(ge.Ay,{variant:"link",href:`#${oc.LX}`,onClick:()=>{a()},children:(0,p.__)("Create custom segment","mailpoet")})]})]})}),Cc=(0,o.withBoundary)(function(){const e=(0,r.useCallback)(()=>function(e){return{limit:e.perPage??25,sort_by:e.sort?.field??"updated_at",sort_order:e.sort?.direction??"desc"}}((0,$e.Aq)("dynamic-segments",pc,mc)),[]),t=(0,r.useMemo)(()=>(0,$e.Aq)("dynamic-segments",pc,mc),[]),[a]=(0,r.useState)(()=>rc(window.location.hash,e())),[i,s]=(0,r.useState)(a.group),[n,o]=(0,r.useState)([]),[l,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[_,f]=(0,r.useState)(null),b=(0,r.useRef)(_c(a)?a.offset:null),x=(0,r.useRef)(hc(a,t)),v=(0,r.useRef)(a.group),y=(0,r.useCallback)(e=>async function(e){return dc(),(await(0,Ro.default)({path:(0,Do.F)("/mailpoet/v1/dynamic-segments",cc(e)),method:"GET",signal:void 0})).data}({...e,group:i}),[i]),{view:w,setView:j,items:S,meta:N,groups:C,isLoading:E,error:U,onChangeView:I,clearError:A,refresh:T}=(0,$e.i7)({initialView:hc(a,t),load:y,extraParams:e=>null!==b.current&&gc(e,{...a,offset:b.current})?{page:void 0,per_page:void 0,offset:b.current,limit:e.perPage??a.limit,sort_by:e.sort?.field??"updated_at",sort_order:e.sort?.direction??"desc"}:{}});(0,r.useEffect)(()=>{x.current=w,v.current=i},[i,w]),(0,r.useEffect)(()=>{null!==b.current&&gc(w,{...a,offset:b.current})||function(e,t={}){const a={...sc,...t},i=Object.entries({...nc(window.location.hash),...e}).filter(([e,t])=>t!==a[e]).sort(([e],[t])=>e.localeCompare(t)).reduce((e,[t,a])=>a?`${e}/${t}[${a}]`:e,"");window.location.hash=`/segments${i}`}({group:i,limit:w.perPage??25,offset:((w.page??1)-1)*(w.perPage??25),search:w.search??"",sort_by:w.sort?.field??"updated_at",sort_order:w.sort?.direction??"desc"},e())},[e,i,a,w]),(0,r.useEffect)(()=>{const t=()=>{const t=rc(window.location.hash,e()),a=t.group;b.current=_c(t)?t.offset:null,a!==v.current&&s(a),gc(x.current,t)||j(e=>gc(e,t)?e:hc(t,e)),o([]),c(null),h(null),A()};return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)},[A,e,j]);const P=(0,r.useCallback)(e=>{b.current=null,I(e)},[I]),R=(0,$e.wh)("dynamic-segments",w,P),D=(0,r.useCallback)(async(e,t)=>{if(0!==t.length)try{const a=await async function(e,t){return dc(),(await(0,Ro.default)({path:"/mailpoet/v1/dynamic-segments/bulk-action",method:"POST",data:{action:e,ids:t}})).data}(e,t.map(e=>Number(e.id))),i=function(e,t){return"delete"===e?t.deleted:t.updated}(e,a);o([]),c(a.errors.length?a.errors.map(e=>e.message).join("\n"):null),h(i>0?function(e,t){return"trash"===e?(0,p.sprintf)((0,p._n)("Segment moved to trash.","%d segments moved to trash.",t,"mailpoet"),t):"restore"===e?(0,p.sprintf)((0,p._n)("Segment restored.","%d segments restored.",t,"mailpoet"),t):(0,p.sprintf)((0,p._n)("Segment permanently deleted.","%d segments permanently deleted.",t,"mailpoet"),t)}(e,i):null),T()}catch(e){const t=e;h(null),c(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}},[T]),F=(0,r.useCallback)(async e=>{try{const t=(await m.U.Ajax.post({api_version:"v1",endpoint:"dynamic_segments",action:"duplicate",data:{id:e.id}})).data;m.U.Notice.success((0,p.sprintf)((0,p.__)('Segment "%s" has been duplicated.',"mailpoet"),(0,Me.Zn)(t.name))),T()}catch(e){(0,uc.C)(e)&&m.U.Notice.showApiErrorNotice(e)}},[T]),O=(0,r.useMemo)(()=>[{id:"view_subscribers",label:(0,p.__)("View subscribers","mailpoet"),supportsBulk:!1,callback:e=>{const t=e[0];t&&(window.location.href=t.subscribers_url)}},{id:"edit",label:(0,p.__)("Edit","mailpoet"),isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&!e.is_plugin_missing,callback:e=>{const t=e[0];t&&(window.location.hash=`${oc.r$}/${t.id}`)}},{id:"edit_missing_plugin",label:(0,p.__)("Edit unavailable","mailpoet"),disabled:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at&&e.is_plugin_missing,callback:()=>{}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{e[0]&&F(e[0])}},{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),supportsBulk:!0,isEligible:e=>!e.deleted_at,callback:e=>{f({action:"trash",selected:e})}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at,callback:e=>{f({action:"restore",selected:e})}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at,callback:e=>{f({action:"delete",selected:e})}}],[F]),M=(0,r.useMemo)(()=>({totalItems:N.count,totalPages:N.pages}),[N]),L=(0,r.useMemo)(()=>{const e={all:null,trash:null};(C??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)});const t=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:t((0,p.__)("All","mailpoet"),e.all),className:"mailpoet-dataviews-group-all mailpoet-tab-all"},{name:"trash",title:t((0,p.__)("Trash","mailpoet"),e.trash),className:"mailpoet-dataviews-group-trash mailpoet-tab-trash"}]},[C]),$=function(e){if(!e)return{title:"",message:"",confirmText:""};const{action:t,selected:a}=e,i=a.map(({name:e})=>`"${e}"`).join(", ");return"trash"===t?{title:(0,p._n)("Trash selected segment","Trash selected segments",a.length,"mailpoet"),message:(0,p.sprintf)((0,p._n)("Are you sure you want to trash the selected segment %s?","Are you sure you want to trash the selected segments %s?",a.length,"mailpoet"),i),confirmText:(0,p.__)("Trash","mailpoet")}:"restore"===t?{title:(0,p._n)("Restore selected segment","Restore selected segments",a.length,"mailpoet"),message:(0,p.sprintf)((0,p._n)("Are you sure you want to restore the selected segment %s?","Are you sure you want to restore segments %s?",a.length,"mailpoet"),i),confirmText:(0,p.__)("Restore","mailpoet")}:{title:(0,p._n)("Delete selected segment permanently","Delete selected segments permanently",a.length,"mailpoet"),message:(0,g.jsxs)(g.Fragment,{children:[(0,p.sprintf)((0,p._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?",a.length,"mailpoet"),i)," ",(0,g.jsx)("strong",{children:(0,p.__)("This action can not be reversed.","mailpoet")})]}),confirmText:(0,p.__)("Delete permanently","mailpoet")}}(_);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.x,{hideScreenOptions:!0}),(0,g.jsx)(ic,{}),(0,g.jsx)(qe.z,{heading:(0,p.__)("Segments","mailpoet"),children:(0,g.jsx)("a",{href:`#${oc.WA}`,"data-automation-id":"new-segment",className:"page-title-action",children:(0,p.__)("Add new segment","mailpoet")})}),(0,g.jsxs)("div",{className:"mailpoet-segment-subscriber-count",children:[(0,g.jsx)(ze,{subscribersInPlan:m.U.subscribersCount,subscribersInPlanLimit:m.U.subscribersLimit}),(0,g.jsx)(Ye,{cacheCalculation:window.mailpoet_subscribers_counts_cache_created_at})]}),(0,g.jsx)(k.D,{}),U&&(0,g.jsx)(Fe.A,{status:"error",onRemove:A,children:U}),l&&(0,g.jsx)(Fe.A,{status:"error",onRemove:()=>c(null),children:l}),u&&(0,g.jsx)(Fe.A,{status:"success",onRemove:()=>h(null),children:u}),(0,g.jsx)(Ao.A,{className:"mailpoet-segments-dataviews__tabs",activeClass:"is-active",tabs:L,initialTabName:i,onSelect:e=>{"all"!==e&&"trash"!==e||e!==i&&(b.current=null,s(e),o([]),c(null),h(null),A(),j({...w,page:1}))},children:()=>(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-segments-dataviews mailpoet-segments-listing","data-automation-id":"dynamic_segments_listing",children:(0,g.jsxs)(Le.A,{data:S,fields:mc,view:w,onChangeView:R,actions:O,paginationInfo:M,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:n,onChangeSelection:o,isLoading:E,empty:(0,g.jsx)("div",{children:(0,p.__)("No data to display","mailpoet")}),children:[(0,g.jsxs)("div",{className:"mailpoet-segments-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})})},i),(0,g.jsx)(To.A,{className:"mailpoet-confirm-dialog",isOpen:!!_,title:$.title,confirmButtonText:$.confirmText,__experimentalHideHeader:!1,onConfirm:()=>{_&&D(_.action,_.selected),f(null)},onCancel:()=>f(null),children:(0,g.jsx)("p",{children:$.message})})]})});function Ec(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ie.HashRouter,{children:[(0,g.jsx)(Sc,{}),(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:oc.LX,element:(0,g.jsx)(kc,{})}),(0,g.jsx)(Ae.qh,{path:`${oc.r$}/:id`,element:(0,g.jsx)(kc,{})}),(0,g.jsx)(Ae.qh,{path:oc.WA,element:(0,g.jsx)(Nc,{})}),(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(Cc,{})})]})]})})}jc&&((0,o.registerTranslations)(),(0,dl.y$)(),(0,n.H)(jc).render((0,g.jsx)(Ec,{})));const Uc=()=>{m.U.trackEvent("Forms > Add New"),setTimeout(()=>{window.location.href=window.mailpoet_form_template_selection_url},200)};function Ic(){const[e,t]=(0,r.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ke,{}),(0,g.jsx)(d.x,{}),(0,g.jsx)(qe.z,{heading:(0,p.__)("Forms","mailpoet"),children:(0,g.jsx)("button",{onClick:()=>{t(!0),Uc()},"data-automation-id":"create_new_form",className:"page-title-action "+(e?"mailpoet-button-with-spinner":""),type:"button",children:(0,p.__)("Add new form","mailpoet")})})]})}function Ac({form:e}){const[t,a]=(0,r.useState)("enabled"===e.status),[i,s]=(0,r.useState)(!1);return(0,g.jsxs)("div",{children:[(0,g.jsx)(Xi.l,{onCheck:(i,n)=>{n.persist();const r=t;a(i),s(!0),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"setStatus",data:{id:Number(e.id),status:i?"enabled":"disabled"}}).done(e=>{"enabled"===e.data.status&&m.U.Notice.success((0,p.__)("Your Form is now activated!","mailpoet"))}).fail(e=>{m.U.Notice.showApiErrorNotice(e),a(r)}).always(()=>s(!1))},"data-id":e.id,dimension:"small",checked:t,disabled:i}),(0,g.jsxs)("p",{children:[(0,p.__)("Sign-ups","mailpoet"),": ",e.signups.toLocaleString()]})]})}Ic.displayName="FormsHeading",Ac.displayName="FormStatusToggle";const Tc=[{id:"name",label:(0,p.__)("Name","mailpoet"),type:"text",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)("a",{className:"mailpoet-listing-title",href:`admin.php?page=mailpoet-form-editor&id=${e.id}`},e.name?e.name:`(${(0,p.__)("no name","mailpoet")})`)},{id:"segments",label:(0,p.__)("Lists","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>{const t=new Set(e.segments.map(e=>String(e))),a=window.mailpoet_segments.filter(e=>t.has(String(e.id)));return(0,r.createElement)(Bn.vC,{segments:a,dimension:"large"},"user"===e.settings?.segments_selected_by?(0,r.createElement)("span",{className:"mailpoet-tags-prefix"},(0,p.__)("User choice:","mailpoet")):null)}},{id:"type",label:(0,p.__)("Type","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)("span",null,function(e){const t=[],a=e?.form_placement;return"1"===a?.fixed_bar?.enabled&&t.push((0,p.__)("Fixed bar","mailpoet")),"1"===a?.below_posts?.enabled&&t.push((0,p.__)("Below pages","mailpoet")),"1"===a?.popup?.enabled&&t.push((0,p.__)("Pop-up","mailpoet")),"1"===a?.slide_in?.enabled&&t.push((0,p.__)("Slide–in","mailpoet")),t.length>0?t.join(", "):(0,p.__)("Others (widget)","mailpoet")}(e.settings))},{id:"status",label:(0,p.__)("Status","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,render:({item:e})=>(0,r.createElement)(Ac,{form:e})},{id:"updated_at",label:(0,p.__)("Modified date","mailpoet"),type:"datetime",enableSorting:!0,enableGlobalSearch:!1,render:({item:e})=>{if(!e.updated_at)return(0,r.createElement)("span",null,"—");const t=m.U.Date.short(e.updated_at),a=m.U.Date.time(e.updated_at);return(0,r.createElement)("span",null,(0,r.createElement)("span",null,t),(0,r.createElement)("br",null),(0,r.createElement)("span",null,a))}}];let Pc=!1;function Rc(){if(Pc)return;const e=window.mailpoet_forms_api;Ro.default.use(Ro.default.createRootURLMiddleware(`${e.root}/`)),Ro.default.use(Ro.default.createNonceMiddleware(e.nonce)),Pc=!0}const Dc={type:"table",perPage:20,page:1,sort:{field:"updated_at",direction:"desc"},fields:["segments","type","status","updated_at"],titleField:"name",showTitle:!0};function Fc(){const[e,t]=(0,r.useState)("all"),[a,i]=(0,r.useState)([]),[s,n]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),[c]=(0,r.useState)(()=>(0,$e.Aq)("forms",Dc,Tc)),u=(0,r.useCallback)(t=>async function(e){return Rc(),(await(0,Ro.default)({path:(0,Do.F)("/mailpoet/v1/forms",e),method:"GET"})).data}({...t,group:e}),[e]),{view:h,setView:_,items:f,meta:b,groups:x,isLoading:v,error:y,onChangeView:w,clearError:j,refresh:S}=(0,$e.i7)({initialView:c,load:u}),k=(0,$e.wh)("forms",h,w),N=(0,r.useRef)(new Set);(0,r.useEffect)(()=>{f.forEach(e=>{null===e.settings&&(N.current.has(e.id)||(N.current.add(e.id),m.U.Notice.error((0,p.__)('Form settings of "%1$s" form are corrupted. Please [link]reconfigure the form in the editor[/link].',"mailpoet").replace("%1$s",(0,Me.Zn)(e.name)).replace("[link]",`<a class="mailpoet-link" href="admin.php?page=mailpoet-form-editor&id=${parseInt(e.id,10)}">`).replace("[/link]","</a>"))))})},[f]);const C=(0,r.useCallback)(async(e,t)=>{const a=t.map(e=>Number(e.id));if(0!==a.length){if("delete"===e){const e=1===a.length?(0,p.__)("Delete this form permanently?","mailpoet"):(0,p.sprintf)((0,p._n)("Delete %d form permanently?","Delete %d forms permanently?",a.length,"mailpoet"),a.length);if(!window.confirm(e))return}try{const t=await async function(e,t){return Rc(),(await(0,Ro.default)({path:"/mailpoet/v1/forms/bulk-action",method:"POST",data:{action:e,ids:t}})).data.count}(e,a);i([]),d(function(e,t){return"trash"===e?1===t?(0,p.__)("1 form was moved to the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form was moved to the trash.","%d forms were moved to the trash.",t,"mailpoet"),t):"restore"===e?1===t?(0,p.__)("1 form has been restored from the trash.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form has been restored from the trash.","%d forms have been restored from the trash.",t,"mailpoet"),t):1===t?(0,p.__)("1 form was permanently deleted.","mailpoet"):(0,p.sprintf)((0,p._n)("%d form was permanently deleted.","%d forms were permanently deleted.",t,"mailpoet"),t)}(e,t)),S()}catch(e){const t=e;n(t?.message||(0,p.__)("The bulk action could not be completed.","mailpoet"))}}},[S]),E=(0,r.useCallback)(e=>{m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"forms",action:"duplicate",data:{id:Number(e.id)}}).done(e=>{const t=e.data.name?e.data.name:(0,p.__)("no name","mailpoet");m.U.Notice.success((0,p.__)('Form "%1$s" has been duplicated.',"mailpoet").replace("%1$s",(0,Me.Zn)(t))),S()}).fail(e=>{e.errors&&e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})},[S]),U=(0,r.useMemo)(()=>[{id:"edit",label:(0,p.__)("Edit","mailpoet"),icon:"edit",isPrimary:!0,supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{const t=e[0];t&&(window.location.href=`admin.php?page=mailpoet-form-editor&id=${t.id}`)}},{id:"duplicate",label:(0,p.__)("Duplicate","mailpoet"),supportsBulk:!1,isEligible:e=>!e.deleted_at,callback:e=>{e[0]&&E(e[0])}},{id:"trash",label:(0,p.__)("Move to trash","mailpoet"),supportsBulk:!0,isEligible:e=>!e.deleted_at,callback:e=>{C("trash",e)}},{id:"restore",label:(0,p.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:e=>!!e.deleted_at,callback:e=>{C("restore",e)}},{id:"delete",label:(0,p.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:e=>!!e.deleted_at,callback:e=>{C("delete",e)}}],[C,E]),I=(0,r.useMemo)(()=>({totalItems:b.count,totalPages:b.pages}),[b]),A=(0,r.useMemo)(()=>{const e={all:null,trash:null};(x??[]).forEach(t=>{"all"!==t.name&&"trash"!==t.name||(e[t.name]=t.count)});const t=(e,t)=>null===t?e:`${e} (${t})`;return[{name:"all",title:t((0,p.__)("All","mailpoet"),e.all),className:"mailpoet-dataviews-group-all"},{name:"trash",title:t((0,p.__)("Trash","mailpoet"),e.trash),className:"mailpoet-dataviews-group-trash"}]},[x]),T="trash"===e?(0,p.__)("Trash is empty.","mailpoet"):(0,p.__)("No forms were found. Why not create a new one?","mailpoet");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ic,{}),y&&(0,g.jsx)(Fe.A,{status:"error",onRemove:j,children:y}),s&&(0,g.jsx)(Fe.A,{status:"error",onRemove:()=>n(null),children:s}),l&&(0,g.jsx)(Fe.A,{status:"success",onRemove:()=>d(null),children:l}),(0,g.jsx)(Ao.A,{className:"mailpoet-forms-dataviews__tabs",activeClass:"is-active",tabs:A,initialTabName:e,onSelect:a=>{"all"!==a&&"trash"!==a||a!==e&&(t(a),i([]),n(null),d(null),j(),_({...h,page:1}))},children:()=>(0,g.jsx)("div",{className:"mailpoet-dataviews mailpoet-forms-dataviews","data-automation-id":"forms_listing",children:(0,g.jsxs)(Le.A,{data:f,fields:Tc,view:h,onChangeView:k,actions:U,paginationInfo:I,defaultLayouts:{table:{}},getItemId:e=>String(e.id),selection:a,onChangeSelection:i,isLoading:v,empty:"trash"===e?(0,g.jsx)("div",{children:T}):(0,g.jsxs)("div",{className:"mailpoet-forms-add-new-row",children:[(0,g.jsx)("p",{children:T}),(0,g.jsx)(o.Button,{onClick:Uc,automationId:"add_new_form",children:(0,p.__)("Add new form","mailpoet")})]}),children:[(0,g.jsxs)("div",{className:"mailpoet-forms-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search forms","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})})})]})}Fc.displayName="FormList";const Oc=eo(Fc);function Mc(){return(0,g.jsx)(Oc,{})}function Lc(){return(0,g.jsx)(l.F.Provider,{value:(0,l.f)(window),children:(0,g.jsxs)(Ie.HashRouter,{children:[(0,g.jsx)(c.D,{}),(0,g.jsx)(u.q,{}),(0,g.jsx)(k.D,{}),(0,g.jsx)(Ae.BV,{children:(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Mc,{})})})})]})})}const $c=document.getElementById("forms_container");function Bc(){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)(Ge.$,{target:"_blank",rel:"noreferrer noopener",href:"https://kb.mailpoet.com/",children:m.U.I18n.t("knowledgeBaseButton")})]})}$c&&((0,o.registerTranslations)(),(0,n.H)($c).render((0,g.jsx)(Lc,{})));var Wc=a(61630);function Vc(e){e.target.select()}function qc(e,t){if(Rt.default.isObject(e)){const a=Object.keys(e).map(t=>`${t}: ${e[t]}`);return(0,g.jsx)("textarea",{readOnly:!0,id:t,onFocus:Vc,value:a.join("\n"),style:{width:"100%",height:"400px"}})}return(0,g.jsx)("p",{children:m.U.I18n.t("systemInfoDataError")})}function Hc(){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")})}),qc(t,e),(0,g.jsx)(Wc.T,{variant:"secondary",targetId:e})]})}function zc({rows:e,max_width:t="auto",is_fixed:a=!0}){return(0,g.jsx)("table",{className:v()("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 Gc({truthy:e=(0,p.__)("Yes","mailpoet"),falsy:t=(0,p.__)("No","mailpoet"),unknown:a=(0,p.__)("Unknown","mailpoet"),children:i=null}){return(0,g.jsx)("span",{children:!0===i&&e||!1===i&&t||a})}function Yc(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)(zc,{max_width:"400px",rows:[{key:m.U.I18n.t("accessible"),value:(0,g.jsx)(Gc,{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")}]})]})}function Kc({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)(To.A,{className:"mailpoet-help-modal",isOpen:a,title:o?(0,p.__)("Cancel task","mailpoet"):(0,p.__)("Reschedule task","mailpoet"),cancelButtonText:(0,p.__)("Not now","mailpoet"),confirmButtonText:o?(0,p.__)("Yes, cancel task","mailpoet"):(0,p.__)("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)(Fe.A,{status:"error",isDismissible:!1,children:s}),(0,g.jsx)("br",{})]}),o&&(0,p.sprintf)((0,p.__)('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.toString(),e.newsletter.subject||(0,p.__)("(no subject)","mailpoet")),l&&(0,p.sprintf)((0,p.__)('Are you sure you want to reschedule the task with ID %1$s for the email "%2$s"?',"mailpoet"),e.id.toString(),e.newsletter.subject||(0,p.__)("(no subject)","mailpoet"))," ",l&&c&&(0,p.__)("The email will be sent immediately.","mailpoet"),l&&!c&&(0,p.sprintf)((0,p.__)("The task will be scheduled for sending on %s.","mailpoet"),`${m.U.Date.short(d)} ${m.U.Date.time(d)}`)]}),(0,g.jsx)(ge.Ay,{variant:"secondary",size:"small",isDestructive:o,onClick:()=>i(!0),children:o?(0,p.__)("Cancel task","mailpoet"):(0,p.__)("Reschedule task","mailpoet")})]})}function Qc({task:e}){return(0,g.jsx)(Kc,{task:e,type:"cancel"})}function Jc({task:e}){return(0,g.jsx)(Kc,{task:e,type:"reschedule"})}function Zc({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)(Qc,{task:t})}):null,n?(0,g.jsx)("td",{children:(0,g.jsx)(Jc,{task:t})}):null]})}function Xc({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 em({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)(Xc,{type:t})}),(0,g.jsx)("tbody",{children:e.length?e.map(e=>(0,g.jsx)(Zc,{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)(Xc,{type:t})})]})}function tm({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)(zc,{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)(em,{type:"scheduled",tasks:t.latestTasks.filter(e=>"scheduled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("cancelledTasks")}),(0,g.jsx)(em,{type:"cancelled",tasks:t.latestTasks.filter(e=>"cancelled"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("runningTasks")}),(0,g.jsx)(em,{type:"running",tasks:t.latestTasks.filter(e=>null===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("pausedTasks")}),(0,g.jsx)(em,{type:"paused",tasks:t.latestTasks.filter(e=>"paused"===e.status)}),(0,g.jsx)("h5",{children:m.U.I18n.t("completedTasks")}),(0,g.jsx)(em,{type:"completed",tasks:t.latestTasks.filter(e=>"completed"===e.status)})]})}function am({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)(zc,{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 im(){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,p.__)("Orphaned Sending Tasks","mailpoet"),orphaned_sending_task_subscribers:(0,p.__)("Orphaned Sending Task Subscribers","mailpoet"),sending_queue_without_newsletter:(0,p.__)("Sending Queues without Newsletter","mailpoet"),orphaned_subscriptions:(0,p.__)("Orphaned Subscriptions","mailpoet"),orphaned_links:(0,p.__)("Orphaned Links","mailpoet"),orphaned_newsletter_posts:(0,p.__)("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,p.__)("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)(ge.Ay,{variant:"primary",size:"small",label:(0,p.__)("Clean","mailpoet"),onClick:()=>n(e),isBusy:a===e,disabled:!!a,children:(0,p.__)("Fix","mailpoet")})}));return(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{children:(0,p.__)("Data Inconsistencies","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)('We found the following data inconsistencies in your DB. Click the "Fix" button to clean them.',"mailpoet")}),(0,g.jsx)(zc,{rows:o,max_width:"400px",is_fixed:!1})]})}function sm(e){return null==e||""===e?m.U.I18n.t("none"):"boolean"==typeof e?e?m.U.I18n.t("yes"):m.U.I18n.t("no"):Array.isArray(e)?0===e.length?m.U.I18n.t("none"):e.map(e=>e&&e.worker&&e.message?`${e.worker}: ${e.message}`:`${e}`).join("; "):"object"==typeof e?JSON.stringify(e):`${e}`}function nm(e){return e?m.U.Date.full(1e3*e):m.U.I18n.t("unknown")}function rm(e,t){e.push(""),e.push(`### ${t} ###`)}function om(e,t,a){e.push(`  - ${t}: ${sm(a)}`)}function lm(e){return null==e||""===e?m.U.I18n.t("none"):e}function dm(e){if("boolean"==typeof e)return e?m.U.I18n.t("yes"):m.U.I18n.t("no");const t=`${e||""}`.trim().toLowerCase();return"yes"===t||"no"===t?m.U.I18n.t(t):sm(e)}function cm(e,t){const a={};if(!e||"string"!=typeof e)return a;if(t&&t.length>0){const i=[...t].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),s=new RegExp(`(?:^| - )(?<key>${i.join("|")}): `,"g"),n=[...e.matchAll(s)];return n.forEach((t,i)=>{const s=t.index+t[0].length,r=n[i+1]?n[i+1].index:e.length;a[t.groups.key]=e.slice(s,r).trim()}),a}return e.split(" - ").forEach(e=>{const t=e.indexOf(": ");-1!==t&&(a[e.slice(0,t).trim()]=e.slice(t+2).trim())}),a}function mm(e,t,a,i,s){const n=e?"success":"error";let r=e?t:a;return i&&(r=b()(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 um(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})}),mm(t,s,i,"https://kb.mailpoet.com/article/231-sending-does-not-work",n)]})}function pm(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")}),mm(e.mss.isReachable,a,t,"https://kb.mailpoet.com/article/319-known-errors-when-validating-a-mailpoet-key",null)]})}function hm(){const e="mailpoet-system-status-report",t=window.systemInfoData,a=window.systemStatusData,i=window.actionSchedulerData,[s,n]=(0,r.useState)(!1),[o,l]=(0,r.useState)(m.U.I18n.t("systemStatusCopyForSupport")),d=(0,r.useMemo)(()=>function(e,t,a){const i=[],s=t.queueStatus||{},n=e||{},r=cm(n["WP info"],["WP_MEMORY_LIMIT","WP_MAX_MEMORY_LIMIT","WP_DEBUG","WordPress language","WordPress timezone"]),o=cm(n["PHP info"],["PHP max_execution_time","PHP memory_limit","PHP upload_max_filesize","PHP post_max_size"]),l=cm(n["MailPoet Sending Service"],["Is reachable","Ping response","API key state","Premium key state"]),d=cm(n["MailPoet sending info"],["Send all site's emails with","Task Scheduler method","Default FROM address","Default Reply-To address","Bounce Email Address"]),c=cm(n["Data inconsistency status"]),u=[l["API key state"],l["Premium key state"]?`premium: ${l["Premium key state"]}`:null].filter(Boolean).join("; "),p=u?`${n["MailPoet Premium/MSS key"]} (${u})`:n["MailPoet Premium/MSS key"],h=t.cronStatus||{},g=Array.isArray(h.last_error)?h.last_error.map(e=>`${e.worker}: ${e.message}`).join("; "):h.last_error,_=a?.version||m.U.I18n.t("none"),f=a?.storage||m.U.I18n.t("none"),b=a?.latestTrigger?m.U.Date.full(a.latestTrigger):m.U.I18n.t("unknown"),x=a?.latestCompletedTrigger?m.U.Date.full(a.latestCompletedTrigger):m.U.I18n.t("unknown"),v=a?.latestCompletedRun?m.U.Date.full(a.latestCompletedRun):m.U.I18n.t("unknown");let y=m.U.I18n.t("unknown");"paused"===s.status?y=m.U.I18n.t("paused"):void 0!==s.status&&(y=m.U.I18n.t("running"));const w=void 0!==s.retryAttempt&&null!==s.retryAttempt?s.retryAttempt:m.U.I18n.t("none"),j=s.retryAt?nm(s.retryAt):m.U.I18n.t("unknown"),S=s.error?.errorMessage||m.U.I18n.t("none"),k=s.tasksStatusCounts||{},N=Array.isArray(t.activePlugins)?t.activePlugins.map(e=>({name:`${e?.name||""}`.trim(),author:`${e?.author||""}`.trim(),version:`${e?.version||""}`.trim(),versionLatest:e?.versionLatest?`${e.versionLatest}`.trim():null})).filter(e=>e.name&&e.author&&e.version):[];return i.push("### MailPoet System Status Report ###"),i.push(`Generated: ${(new Date).toISOString()}`),rm(i,"Site & Account"),om(i,"Site name",n.name),om(i,"Email",n.email),om(i,"MailPoet Premium/MSS key",p),om(i,"Plugin installed at",n["Plugin installed at"]),om(i,"Installed via WooCommerce onboarding wizard",dm(n["Installed via WooCommerce onboarding wizard"])),om(i,"Total subscribers",n["Total number of subscribers"]),rm(i,"Versions"),om(i,"MailPoet Free",n["MailPoet Free version"]),om(i,"MailPoet Premium",n["MailPoet Premium version"]),om(i,"WordPress",n["WordPress version"]),om(i,"PHP",n["PHP version"]),om(i,"Database",n["Database version"]),om(i,"Action Scheduler",_),rm(i,"Environment"),om(i,"Web server",n["Web server"]),om(i,"Server OS",n["Server OS"]),om(i,"Multisite",n["Multisite environment?"]),om(i,"Current theme",n["Current Theme"]),om(i,"WordPress language",r["WordPress language"]),om(i,"WordPress timezone",r["WordPress timezone"]),rm(i,"WordPress & PHP Config"),om(i,"WP_MEMORY_LIMIT",r.WP_MEMORY_LIMIT),om(i,"WP_MAX_MEMORY_LIMIT",r.WP_MAX_MEMORY_LIMIT),om(i,"WP_DEBUG",r.WP_DEBUG),om(i,"PHP max_execution_time",o["PHP max_execution_time"]),om(i,"PHP memory_limit",o["PHP memory_limit"]),om(i,"PHP upload_max_filesize",o["PHP upload_max_filesize"]),om(i,"PHP post_max_size",o["PHP post_max_size"]),rm(i,`Active Plugins (${N.length})`),function(e,t){const a=(t||[]).filter(Boolean);a.length?a.forEach(t=>{const a=t.versionLatest?` (update to version ${t.versionLatest} is available)`:"";e.push(`  - ${t.name}: by ${t.author} - ${t.version}${a}`)}):e.push(`  - ${m.U.I18n.t("none")}`)}(i,N),rm(i,"Sending Configuration"),om(i,"Sending method",n["Sending Method"]),om(i,"Send all site's emails with",d["Send all site's emails with"]),om(i,"Sending frequency",n["Sending Frequency"]),om(i,"Default FROM address",lm(d["Default FROM address"])),om(i,"Default Reply-To address",lm(d["Default Reply-To address"])),om(i,"Bounce email address",lm(d["Bounce Email Address"])),rm(i,"Connection to MailPoet Sending Service"),om(i,"Enabled",dm(t.mss?.enabled)),om(i,"Reachable",dm(t.mss?.isReachable)),om(i,"Ping response",l["Ping response"]),om(i,"API key state",l["API key state"]),om(i,"Premium key state",l["Premium key state"]),rm(i,"Task Scheduler / Cron"),om(i,"Status",h.status||m.U.I18n.t("unknown")),om(i,"Task Scheduler method",d["Task Scheduler method"]),om(i,"Ping URL",t.cron?.url),om(i,"Accessible",dm(h.accessible)),om(i,"Ping response",t.cron?.pingResponse),om(i,"Last updated",nm(h.updated_at)),om(i,"Last run started",nm(h.run_started_at)),om(i,"Last run completed",nm(h.run_completed_at)),om(i,"Last seen error",g||m.U.I18n.t("none")),rm(i,"Action Scheduler Status"),om(i,"Storage type",f),om(i,"Next trigger run",b),om(i,"Last trigger run",x),om(i,"Last worker run",v),rm(i,"Sending Queue"),om(i,"Status",y),om(i,"Started at",nm(s.started)),om(i,"Sent emails",s.sent||0),om(i,"Retry attempt",w),om(i,"Retry at",j),om(i,"Error",S),om(i,"Total completed tasks",k.completed||0),om(i,"Total running tasks",k.running||0),om(i,"Total paused tasks",k.paused||0),om(i,"Total cancelled tasks",k.cancelled||0),om(i,"Total scheduled tasks",k.scheduled||0),rm(i,"Data Inconsistency"),om(i,"Orphaned sending tasks",c["Orphaned sending tasks"]),om(i,"Orphaned sending task subscribers",c["Orphaned sending task subscribers"]),om(i,"Sending queue without newsletter",c["Sending queue without newsletter"]),om(i,"Orphaned subscriptions",c["Orphaned subscriptions"]),om(i,"Orphaned links",c["Orphaned links"]),om(i,"Orphaned newsletter posts",c["Orphaned newsletter posts"]),i.push(""),i.join("\n")}(t,a,i),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"mailpoet_notice notice inline",children:(0,g.jsx)("p",{children:a.mss.enabled?m.U.I18n.t("systemStatusIntroCronMSS"):m.U.I18n.t("systemStatusIntroCron")})}),(0,g.jsxs)("div",{className:"updated mailpoet-system-status-report inline",children:[(0,g.jsx)("p",{children:m.U.I18n.t("systemStatusGetReportIntro")}),(0,g.jsxs)("p",{className:"submit",children:[(0,g.jsx)("button",{type:"button",className:"button button-primary",onClick:()=>n(!0),children:m.U.I18n.t("systemStatusGetReportTitle")}),(0,g.jsx)("a",{className:"button button-secondary",href:"https://kb.mailpoet.com/article/understanding-the-mailpoet-system-status-page",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("systemStatusUnderstandingReport")})]}),s?(0,g.jsxs)("div",{className:"mailpoet-debug-report",children:[(0,g.jsx)("textarea",{readOnly:!0,id:e,value:d}),(0,g.jsxs)("p",{className:"submit",children:[(0,g.jsx)("button",{type:"button",className:"button button-primary",onClick:()=>function(e){const t=`mailpoet-system-status-${(new Date).toISOString().slice(0,10)}.txt`,a=new Blob([e],{type:"text/plain;charset=utf-8"}),i=window.URL.createObjectURL(a),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(i)}(d),children:m.U.I18n.t("systemStatusDownloadReport")}),(0,g.jsx)("button",{type:"button",className:"button",onClick:async()=>{try{await(0,ar.l)(e,e=>{e?(l(m.U.I18n.t("copyToClipboardSuccess")),window.setTimeout(()=>{l(m.U.I18n.t("systemStatusCopyForSupport"))},3e3)):l(m.U.I18n.t("copyToClipboardFailure"))},!0)}catch{l(m.U.I18n.t("copyToClipboardFailure"))}},children:o})]})]}):null]}),um(a),pm(a),(0,g.jsx)(Yc,{status_data:a.cronStatus}),(0,g.jsx)(am,{...i}),i?(0,g.jsx)(tm,{statusData:a.queueStatus}):null,(0,g.jsx)(im,{})]})}function gm(){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)(Ge.$,{target:"_blank",rel:"noreferrer noopener",href:"https://www.mailpoet.com/privacy-notice/",children:m.U.I18n.t("yourPrivacyButton")})]})}Gc.propTypes={truthy:Ut().string,falsy:Ut().string,unknown:Ut().string,children:Ut().bool},Yc.propTypes={status_data:Ut().shape({accessible:Ut().bool,last_error_date:Ut().string,status:Ut().string,updated_at:Ut().number,run_accessed_at:Ut().number,run_completed_at:Ut().number,run_started_at:Ut().number,last_error:Ut().oneOfType([Ut().string,Ut().array])}).isRequired};var _m=a(4379);function fm(){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)(u.q,{}),(0,g.jsx)(_m.z,{heading:(0,p.__)("Help","mailpoet")}),(0,g.jsx)(k.D,{}),(0,g.jsxs)(Yr.k,{activeKey:"knowledgeBase",children:[(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabKnowledgeBaseTitle"),children:(0,g.jsx)(Bc,{})},"knowledgeBase"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemStatusTitle"),children:(0,g.jsx)(hm,{})},"systemStatus"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabSystemInfoTitle"),children:(0,g.jsx)(Hc,{})},"systemInfo"),(0,g.jsx)(o.Tab,{title:m.U.I18n.t("tabYourPrivacyTitle"),children:(0,g.jsx)(gm,{})},"yourPrivacy")]})]})}const bm=document.getElementById("help_container");bm&&((0,o.registerTranslations)(),(0,n.H)(bm).render((0,g.jsx)(fm,{})));var xm=a(77129);function vm({children:e}){const t=(0,Ae.zy)();return(0,r.useEffect)(()=>{window.scrollTo(0,0)},[t.pathname]),e||null}vm.propTypes={children:Ut().node.isRequired},vm.displayName="ScrollToTopComponent";const ym=(0,xm.fk)(vm);var wm=a(60695);function jm({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)(wm.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)(Ft.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)(Ft.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)(Ft.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 Sm({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)(Ge.$,{type:"button",variant:"secondary",onClick:i,children:m.U.I18n.t("previousStep")}),(0,g.jsx)(Ge.$,{type:"button",automationId:"import-next-step",isDisabled:!a,onClick:()=>{a&&s()},children:m.U.I18n.t(t?"import":"nextStep")})]})}function km({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:b()(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)(Tt.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)(Sm,{canGoNext:e,onPreviousAction:s,onNextAction:i})]})}function Nm({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:b()(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)(It.p,{type:"file",id:"file_local",accept:".csv","data-automation-id":"import-file-upload-input",onChange:t=>{const a=t.target.value.match(/[^.]+$/);m.U.Notice.hide(),null===a||"csv"!==a[0].toLowerCase()?(m.U.Notice.error(m.U.I18n.t("wrongFileFormat")),e("")):e(t.target.files[0])}})}),(0,g.jsx)(Sm,{canGoNext:t,onPreviousAction:i,onNextAction:a})]})}function Cm({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:b()(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)(It.p,{dimension:"small",id:"mailpoet_mailchimp_key_input",type:"text",onChange:e=>{i(e.target.value),""===e.target.value.trim()&&n(void 0)}}),(0,g.jsx)("span",{className:"mailpoet-gap"}),(0,g.jsx)(Ge.$,{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)(Ve.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)(Sm,{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})})}})]})}jm.propTypes={activeMethod:Ut().string,onMethodChange:Ut().func.isRequired},jm.displayName="SelectImportMethod",Sm.propTypes={canGoNext:Ut().bool,hidePrevious:Ut().bool,isLastStep:Ut().bool,onPreviousAction:Ut().func,onNextAction:Ut().func},Sm.displayName="PreviousNextStepButtons",km.propTypes={onFinish:Ut().func,onPrevious:Ut().func,canFinish:Ut().bool.isRequired,onValueChange:Ut().func.isRequired,data:Ut().string},km.displayName="MethodPaste",Nm.propTypes={canFinish:Ut().bool.isRequired,onFinish:Ut().func,onPrevious:Ut().func,onValueChange:Ut().func.isRequired},Nm.displayName="MethodUpload",Cm.propTypes={onFinish:Ut().func,onPrevious:Ut().func},Cm.displayName="MethodMailChimp";var Em=a(87714),Um=a.n(Em);const Im=e=>{if("string"!=typeof e)return!1;const t=e.toLowerCase();return window.roleBasedEmails.findIndex(e=>t.startsWith(`${e}@`))>=0},Am=e=>{let t,a=Rt.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)&&a};function Tm({setStepMethodSelectionData:e,subscribersLimitForValidation:t}){const a=(0,Ae.Zp)(),[i,s]=(0,r.useState)(void 0),[n,l]=(0,r.useState)(""),[d,c]=(0,r.useState)(void 0),u=s=>{e(s),a(((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))},p=()=>{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),Um().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=0,m=0,u=0,p=null,h=null,g=!1;return Object.keys(e).forEach(_=>{if(l=e[_].map(e=>e.trim()),d=l.length,null===h&&(h=d),d===h)if(null===p){let e=null;if(Object.keys(l).forEach(i=>{o=Am(l[i]),null===p&&window.mailpoet_email_regex.test(o)&&(Im(o)?null===e&&(e=i):(p=i,a[o]=!0,l[i]=o,t[o]=l))}),null===p&&null!==e){p=e;const t=Am(l[e]);a[t]=!0,n.push(l[e]),u+=1}null===p&&0===parseInt(_,10)&&(g=!0,t[0]=l)}else""!==l[p]&&(r=Am(l[p]),Rt.default.has(a,r)?(i.push(r),c+=1):Im(r)?(a[r]=!0,n.push(l[p]),u+=1):window.mailpoet_email_regex.test(r)?(a[r]=!0,l[p]=r,t[r]=l):(s.push(l[p]),m+=1))}),t=Rt.default.values(t),t&&(g&&t.length>=2||!g&&t.length>=1)?{header:window.mailpoet_email_regex.test(t[0][p])?null:t.shift(),subscribers:t,subscribersCount:t.length,duplicate:Rt.default.uniq(i),invalid:Rt.default.uniq(s),role:Rt.default.uniq(n),duplicateRowsCount:c,invalidRowsCount:m,roleRowsCount:u}: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"}),u(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)(jm,{activeMethod:i,onMethodChange:s})}),"paste-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(km,{onPrevious:p,onValueChange:l,onFinish:h,canFinish:!!n.trim(),data:n})}),"file-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Nm,{onPrevious:p,onValueChange:c,onFinish:h,canFinish:!!d,data:d})}),"mailchimp-method"===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Cm,{onPrevious:p,onFinish:e=>{m.U.trackEvent("Subscribers import started",{source:"MailChimp"}),u(e)}})}),void 0===i&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Sm,{canGoNext:!1,onPreviousAction:p})})]})}function Pm({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)(Ge.$,{onClick:e,variant:"tertiary",children:m.U.I18n.t("listCleaningGotIt")}),(0,g.jsx)(Ge.$,{target:"_blank",href:"https://kb.mailpoet.com/article/287-list-cleaning-services",children:m.U.I18n.t("tryListCleaning")}),t&&(0,g.jsx)(Ge.$,{onClick:t,variant:"secondary",children:m.U.I18n.t("cleanedList")})]})]})}function Rm({onSubmit:e}){const t=(0,Ae.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)(Ft.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)(Ft.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)(Sm,{canGoNext:void 0!==a,onPreviousAction:()=>t("/step_method_selection"),onNextAction:()=>e(a)})]})}function Dm(){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)(Ge.$,{href:"https://kb.mailpoet.com/article/269-reconfirm-subscribers-to-your-list",target:"_blank",rel:"noopener noreferrer",children:m.U.I18n.t("validationStepBlockButton")})})]})}function Fm({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)(Be.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)(Ge.$,{type:"button",automationId:"last_sent_to_list_next",onClick:s,children:m.U.I18n.t("validationStepLastSentNext")})})]})}function Om({stepMethodSelectionData:e}){const t=(0,Ae.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)(Rm,{onSubmit:i})}),"address-book"===a&&(0,g.jsx)(Dm,{}),"existing-list"===a&&void 0===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Fm,{onSubmit:l})}),"existing-list"===a&&"notRecently"===s&&(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Pm,{iHaveCleanedList:()=>l("recently")})})]})}function Mm({translation:e,subscribers:t}){let a="";return t.length&&(a=b()(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 Lm({stepMethodSelectionData:e={invalid:[],duplicate:[],role:[]}}){const{invalid:t,duplicate:a,role:i}=e,[s,n]=(0,r.useState)(!1),o=v()("mailpoet_subscribers_data_parse_results_details",{mailpoet_hidden:!s}),l=(0,g.jsx)(Mm,{translation:m.U.I18n.t("importNoticeInvalid"),subscribers:t}),d=(0,g.jsx)(Mm,{translation:m.U.I18n.t("importNoticeDuplicate"),subscribers:a});let c="";if(i.length&&(c=b()(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:[b()(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}Tm.propTypes={setStepMethodSelectionData:Ut().func.isRequired,subscribersLimitForValidation:Ut().number.isRequired},Tm.diplayName="StepMethodSelection",Pm.displayName="CleanList",Rm.propTypes={onSubmit:Ut().func.isRequired},Rm.displayName="InitialQuestion",Fm.propTypes={onSubmit:Ut().func.isRequired},Fm.displayName="LastSentQuestion",Om.displayName="StepInputValidation",Mm.propTypes={translation:Ut().string.isRequired,subscribers:Ut().arrayOf(Ut().string).isRequired},Lm.propTypes={stepMethodSelectionData:Ut().shape({duplicate:Ut().arrayOf(Ut().string),invalid:Ut().arrayOf(Ut().string),role:Ut().arrayOf(Ut().string)})};function $m({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}`})},t))]})}function Bm({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 Wm({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 Vm({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)(Wm,{subscriber:e,index:t+1})},`${e[0]}-${t}`)),t>11?(0,g.jsx)("tr",{children:(0,g.jsx)(Wm,{subscriber:i,index:a})},"filler"):null,t>10?(0,g.jsx)("tr",{children:(0,g.jsx)(Wm,{subscriber:e[t-1],index:t})},e[t-1][0]):null]})}function qm({subscribersCount:e=0,subscribers:t=[],header:a=[],onCreateCustomField:i}){return(0,r.useLayoutEffect)(()=>{(e=>{const t={data:window.mailpoetColumnsSelect2,width:"15em"};Ct()("select.mailpoet_subscribers_column_data_match").select2(t).on("select2:selecting",t=>{const a=t.currentTarget,i=t.params.args.data.id;"create"===i?(t.preventDefault(),Ct()(a).select2("close"),e(a)):Ct()("select.mailpoet_subscribers_column_data_match").each((e,s)=>{if(s===a)return;const n=Ct()(s).val();n===i&&"ignore"!==n&&(confirm(`${m.U.I18n.t("selectedValueAlreadyMatched")} ${m.U.I18n.t("confirmCorrespondingColumn")}`)?Ct()(s).data("column-id","ignore"):(t.preventDefault(),Ct()(a).select2("close")))})}).on("select2:select",e=>{const t=e.currentTarget,a=e.params.data.id;Ct()(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()}),Ct().map(Ct()(".mailpoet_subscribers_column_data_match"),e=>{const t=Ct()(e).data("column-id");Ct()(e).val(t).trigger("change")})})(i)},[i]),(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)($m,{header:a,subscribers:t})}),(0,g.jsxs)("tbody",{children:[a?(0,g.jsx)(Bm,{header:a}):null,(0,g.jsx)(Vm,{subscribers:t,subscribersCount:e})]})]})})}function Hm({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=Ct()("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=Ct()('[data-id="notice_segmentSelection"]');t.currentTarget.value?Ct()('[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)})(Rt.default.pluck(a.select2("data"),"id"))})}(s)},[s,e]);const o=t=>{!function(){const e=Ct()("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)(Ge.$,{variant:"tertiary",onClick:()=>{return e=o,m.U.Modal.popup({title:m.U.I18n.t("addNewList"),template:Ct()("#new_segment_template").html()}),Ct()("#new_segment_name").on("keypress",e=>{13===e.which&&Ct()("#new_segment_process").trigger("click")}),Ct()("#new_segment_process").on("click",()=>{const t=Ct()("#new_segment_name").val()?.toString().trim()||"",a=Ct()("#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 Ct()("#new_segment_cancel").on("click",()=>{m.U.Modal.close()});var e},children:m.U.I18n.t("createANewList")})]})})]})}function zm(){return(0,g.jsx)("p",{className:"description",children:b()(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 Gm({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)(zm,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(Be.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 Ym({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)(zm,{})]}),(0,g.jsx)("div",{className:"mailpoet-settings-inputs",children:(0,g.jsxs)(Be.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 Km({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)(Ft.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)(Ft.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")})]})]})}$m.propTypes={subscribers:Ut().arrayOf(Ut().arrayOf(Ut().oneOfType([Ut().string,Ut().number]))).isRequired,header:Ut().arrayOf(Ut().string)},Bm.propTypes={header:Ut().arrayOf(Ut().string).isRequired},Wm.propTypes={subscriber:Ut().arrayOf(Ut().oneOfType([Ut().string,Ut().number])).isRequired,index:Ut().node.isRequired},Vm.propTypes={subscribersCount:Ut().number.isRequired,subscribers:Ut().arrayOf(Ut().arrayOf(Ut().oneOfType([Ut().string,Ut().number]))).isRequired},qm.propTypes={subscribersCount:Ut().number,subscribers:Ut().arrayOf(Ut().arrayOf(Ut().oneOfType([Ut().string,Ut().number]))),header:Ut().arrayOf(Ut().string),onCreateCustomField:Ut().func.isRequired},Hm.propTypes={setSelectedSegments:Ut().func.isRequired},Km.propTypes={setUpdateExistingSubscribers:Ut().func.isRequired,updateExistingSubscribers:Ut().bool.isRequired},a(36202);function Qm({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")})})]})}var Jm=a(13911),Zm=a(12146),Xm=a(2373);function eu({dateSettings:e,onClose:t,onSuccess:a}){const[i,s]=(0,r.useState)(()=>(0,Xm.uS)(e)),[n,o]=(0,r.useState)(!1),[l,d]=(0,r.useState)(null);return(0,g.jsx)(Te.A,{title:m.U.I18n.t("addNewField"),onRequestClose:t,className:"mailpoet-custom-fields-form-modal",focusOnMount:!0,children:(0,g.jsxs)("form",{onSubmit:async function(e){e.preventDefault();const t=(0,Xm._J)(i);if(t)d(t);else{o(!0),d(null);try{a(await(0,Zm.AA)((0,Xm.WD)(i)))}catch(e){d(function(e){return e?.message||m.U.I18n.t("customFieldCreateError")||(0,p.__)("Custom field could not be created","mailpoet")}(e))}finally{o(!1)}}},"data-automation-id":"create_custom_field_form",children:[(0,g.jsx)(Xm.bV,{data:i,dateSettings:e,disabled:n,onChange:s}),l&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Jm.A,{marginTop:4}),(0,g.jsx)("div",{className:"mailpoet-custom-fields-form-error",role:"alert",children:l})]}),(0,g.jsx)(Jm.A,{marginTop:6}),(0,g.jsxs)(ia.A,{justify:"flex-end",gap:3,children:[(0,g.jsx)(sa.A,{children:(0,g.jsx)(ge.Ay,{variant:"tertiary",onClick:t,disabled:n,__next40pxDefaultSize:!0,children:(0,p.__)("Cancel","mailpoet")})}),(0,g.jsx)(sa.A,{children:(0,g.jsx)(ge.Ay,{variant:"primary",type:"submit",isBusy:n,disabled:n,__next40pxDefaultSize:!0,children:(0,p.__)("Create custom field","mailpoet")})})]})]})})}function tu({subscribersLimitForValidation:e,setStepDataManipulationData:t,stepMethodSelectionData:a}){const i=(0,Ae.Zp)(),[s,n]=(0,r.useState)([]),[o,l]=(0,r.useState)(!0),[d,c]=(0,r.useState)("subscribed"),[u,p]=(0,r.useState)("dontUpdate"),[h,_]=(0,r.useState)([]),[f,b]=(0,r.useState)(null),x=(0,r.useMemo)(()=>({dateTypes:window.mailpoet_import_custom_fields_date_types??[],dateFormats:window.mailpoet_import_custom_fields_date_formats??{}}),[]),v=(0,r.useCallback)(e=>{b(e)},[]);(0,r.useEffect)(()=>{void 0===a&&i("/step_method_selection",{replace:!0})},[a,i]);const y=(0,r.useMemo)(()=>({duplicate:a?.duplicateRowsCount??a?.duplicate?.length??0,invalid:a?.invalidRowsCount??a?.invalid?.length??0,role:a?.roleRowsCount??a?.role?.length??0}),[a]);return void 0===a?null:(0,g.jsxs)("div",{"data-automation-id":"import_data_manipulation_step",children:[(0,g.jsx)(Lm,{stepMethodSelectionData:a}),(0,g.jsx)(qm,{subscribersCount:a.subscribersCount,subscribers:a.subscribers,header:a.header,onCreateCustomField:v}),(0,g.jsxs)("div",{className:"mailpoet-settings-grid",children:[(0,g.jsx)(Hm,{setSelectedSegments:n}),(0,g.jsx)(Gm,{newSubscribersStatus:d,setNewSubscribersStatus:c}),(0,g.jsx)(Ym,{existingSubscribersStatus:u,setExistingSubscribersStatus:p}),(0,g.jsx)(Km,{setUpdateExistingSubscribers:l,updateExistingSubscribers:o}),(0,g.jsx)(Qm,{selectedTags:h,setSelectedTags:_}),(0,g.jsx)(Sm,{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(Ct().AsyncQueue);let d=0;const c=Date.now()/1e3,u={created:0,updated:0,errors:[],segments:[],tags:[]};m.U.Modal.progress(!0);const p=e.reduce((e,t,a)=>(a%2e3==0&&e.push([]),e[e.length-1].push(t),e),[]);Rt.default.each(Ct()("select.mailpoet_subscribers_column_data_match"),(e,t)=>{const a=Ct()(e).data("column-id");"ignore"!==a&&(o[a]={index:t})}),Rt.default.each(p,()=>{l.add(r=>{r.pause(),m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"ImportExport",action:"processImport",data:JSON.stringify({columns:o,subscribers:p[d],timestamp:c,segments:t,newSubscribersStatus:a,existingSubscribersStatus:i,updateSubscribers:s,tags:n})}).done(t=>{const a=t.data.added_to_segment_with_welcome_notification;var i,s;u.created+=t.data.created,u.updated+=t.data.updated,u.segments=t.data.segments,u.added_to_segment_with_welcome_notification=a,m.U.Modal.setProgress((i=u,s=e,Math.floor((i.created+i.updated)/s.length*100))),r.run()}).fail(e=>{m.U.Modal.progress(!1),e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})}),d+=1})}),l.run(),l.onComplete(()=>{m.U.Modal.progress(!1),u.errors.length>0&&!u.updated&&!u.created?m.U.Notice.error(Rt.default.flatten(u.errors)):(u.segments=Rt.default.map(Rt.default.filter(u.segments,e=>t.includes(e.id)),e=>e.name),r(u))})})(a.subscribers,s,d,u,o,h,e=>{t({...e,skipped_duplicate:y.duplicate,skipped_invalid:y.invalid,skipped_role:y.role}),i("/step_results")})},isLastStep:!0})]}),f&&(0,g.jsx)(eu,{dateSettings:x,onClose:()=>b(null),onSuccess:e=>{f&&(((e,t)=>{const a=(e=>({id:e.id,name:e.name,text:e.name,type:e.type,params:e.params,custom:!0}))(t);(()=>{let e=window.mailpoetColumnsSelect2.find(e=>e.name===m.U.I18n.t("userColumns"));if(!e){const t=m.U.I18n.t("userColumns");e={name:t,text:t,children:[]},window.mailpoetColumnsSelect2.push(e)}return e})().children.push(a),window.mailpoetColumns.push(a);const i=`${a.id}`,s={data:window.mailpoetColumnsSelect2,width:"15em"};Ct()("select.mailpoet_subscribers_column_data_match").each((t,n)=>{const r=Ct()(n);if(n===e)return r.find(`option[value="${i}"]`).remove(),r.append(new Option(a.text,i,!0,!0)),r.data("column-id",a.id),r.attr("data-column-id",a.id),r.val(i).trigger("change"),r.trigger({type:"select2:select",params:{data:{...a,id:i}}}),void r.next(".select2-container").find(".select2-selection__rendered").text(a.text).attr("title",a.text);const o=r.data("column-id");r.html("").select2("destroy").select2(s),r.data("column-id",o),r.attr("data-column-id",o),r.val(`${o}`).trigger("change")})})(f,e),b(null))}})]})}function au({subscribersCount:e=0,segments:t=[],initialMessage:a=""}){if(e){let i=b()(a,"%1$s",()=>(0,g.jsx)("strong",{children:e.toLocaleString()},"%1$s"));return i=b()(i,"%2$s",()=>`"${t.join('", "')}"`),(0,g.jsx)("p",{children:i})}return null}function iu({createdSubscribers:e=0,updatedSubscribers:t=0}){return e||t?null:(0,g.jsx)("p",{children:m.U.I18n.t("importNoAction")})}function su({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:b()(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 nu({addedToSegmentWithWelcomeNotification:e=!1}){return e?(0,g.jsx)("p",{children:m.U.I18n.t("importNoWelcomeEmail")}):null}function ru({errors:e=[],createdSubscribers:t,updatedSubscribers:a,skippedDuplicateSubscribers:i,skippedInvalidSubscribers:s,skippedRoleSubscribers:n,segments:l,addedToSegmentWithWelcomeNotification:d}){const c=(0,Ae.Zp)();return(0,r.useEffect)(()=>{void 0===l&&0===e.length&&void 0===t&&void 0===i&&void 0===s&&void 0===n&&void 0===a&&c("/step_method_selection",{replace:!0})},[l,t,e.length,c,i,s,n,a]),e.length&&m.U.Notice.error(Rt.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)(au,{subscribersCount:t,segments:l,initialMessage:m.U.I18n.t("subscribersCreated")}),(0,g.jsx)(au,{subscribersCount:a,segments:l,initialMessage:m.U.I18n.t("subscribersUpdated")}),(0,g.jsx)(au,{subscribersCount:s,initialMessage:m.U.I18n.t("importSkippedInvalid")}),(0,g.jsx)(au,{subscribersCount:i,initialMessage:m.U.I18n.t("importSkippedDuplicate")}),(0,g.jsx)(au,{subscribersCount:n,initialMessage:m.U.I18n.t("importSkippedRoleBased")}),(0,g.jsx)(iu,{createdSubscribers:t,updatedSubscribers:a}),(0,g.jsx)(nu,{addedToSegmentWithWelcomeNotification:d})]})}),(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(su,{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)(Ge.$,{variant:"secondary",type:"button",onClick:()=>{window.location.href=`${window.location.pathname}${window.location.search}#/step_method_selection`},children:m.U.I18n.t("importAgain")}),(0,g.jsx)(Ge.$,{type:"button",onClick:()=>{window.location.href="admin.php?page=mailpoet-subscribers"},children:m.U.I18n.t("viewSubscribers")})]})})]})}function ou(){const e=(0,Ae.Zp)();return(0,g.jsx)(Pm,{onProceed:()=>e("/step_method_selection")})}tu.propTypes={stepMethodSelectionData:Ut().shape({duplicate:Ut().arrayOf(Ut().string),duplicateRowsCount:Ut().number,header:Ut().arrayOf(Ut().string),invalid:Ut().arrayOf(Ut().string),invalidRowsCount:Ut().number,role:Ut().arrayOf(Ut().string),roleRowsCount:Ut().number,subscribersCount:Ut().number,subscribers:Ut().arrayOf(Ut().arrayOf(Ut().oneOfType([Ut().string,Ut().number])))}),subscribersLimitForValidation:Ut().number.isRequired,setStepDataManipulationData:Ut().func.isRequired},au.propTypes={segments:Ut().arrayOf(Ut().string.isRequired),subscribersCount:Ut().number,initialMessage:Ut().string},au.displayName="ResultMessage",iu.propTypes={createdSubscribers:Ut().number,updatedSubscribers:Ut().number},iu.displayName="NoAction",su.propTypes={createdSubscribers:Ut().number,updatedSubscribers:Ut().number},su.displayName="SuppressionListReminder",nu.propTypes={addedToSegmentWithWelcomeNotification:Ut().bool},nu.diplayName="NoWelcomeEmail",ru.propTypes={errors:Ut().arrayOf(Ut().string.isRequired),segments:Ut().arrayOf(Ut().string.isRequired),createdSubscribers:Ut().number,updatedSubscribers:Ut().number,skippedDuplicateSubscribers:Ut().number,skippedInvalidSubscribers:Ut().number,skippedRoleSubscribers:Ut().number,addedToSegmentWithWelcomeNotification:Ut().bool},ru.displayName="StepResults",ou.displayName="StepCleanList";const lu=document.getElementById("import_container");function du(){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)(Ie.HashRouter,{children:[(0,g.jsx)(u.q,{}),(0,g.jsx)(ym,{children:(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"/step_clean_list",element:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ou,{})})}),(0,g.jsx)(Ae.qh,{path:"/step_method_selection",element:(0,g.jsx)(Tm,{setStepMethodSelectionData:t,subscribersLimitForValidation:100})}),(0,g.jsx)(Ae.qh,{path:"/step_input_validation",element:(0,g.jsx)(Om,{stepMethodSelectionData:e})}),(0,g.jsx)(Ae.qh,{path:"/step_data_manipulation",element:(0,g.jsx)(tu,{stepMethodSelectionData:e,subscribersLimitForValidation:100,setStepDataManipulationData:i})}),(0,g.jsx)(Ae.qh,{path:"/step_results",element:(0,g.jsx)(ru,{errors:a.errors,createdSubscribers:a.created,updatedSubscribers:a.updated,skippedDuplicateSubscribers:a.skipped_duplicate,skippedInvalidSubscribers:a.skipped_invalid,skippedRoleSubscribers:a.skipped_role,segments:a.segments,addedToSegmentWithWelcomeNotification:a.added_to_segment_with_welcome_notification})}),(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(Ae.C5,{to:"/step_clean_list"})})]})})]})})}lu&&((0,o.registerTranslations)(),(0,n.H)(lu).render((0,g.jsx)(du,{})));var cu=a(75370),mu=a.n(cu);Ct()(document).ready(()=>{let e;if(!Ct()("#mailpoet_subscribers_export").length)return;if(!window.exportData.segments)return;const t=mu().compile(Ct()("#mailpoet_subscribers_export_template").html());function a(t){const a="mailpoet-disabled";"on"===t?e.removeClass(a):e.addClass(a)}Ct()("#mailpoet-export").html(t(window.exportData));const i=Ct()("#export_lists"),s=Ct()("#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;Rt.default.contains(i,a)&&(t.preventDefault(),"deselect"===a?Ct()(t.target).val("").trigger("change"):(s=[],Rt.default.each(e.find("option"),e=>{const t=e.value;Rt.default.contains(i,t)||s.push(t)}),Ct()(t.target).val(s).trigger("change")),Ct()(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=Ct()("#mailpoet-export-button"),window.segments.forEach(e=>{i.append(Ct()("<option></option>").attr("value",e.id).text(e.name))}),window.subscriberFieldsSelect2.forEach(e=>{e.text=e.name,e.children.forEach(e=>{e.name=(0,Me.Zn)(e.name),e.text=(0,Me.Zn)(e.name)})}),r(i,window.segments),r(s,window.subscriberFieldsSelect2),s.val(["email","first_name","last_name","list_status","global_status","created_at","confirmed_at"]).trigger("change"),e.on("click",e=>{if(Ct()(e.target).hasClass("mailpoet-disabled"))return;m.U.Modal.loading(!0);const t=Ct()(':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>");Ct()("#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 uu=a(6072),pu=a(9339);function hu({children:e}){return(0,g.jsx)("div",{className:"mailpoet-steps-content",children:e})}const gu=(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"})}),_u=(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 fu({onCheck:e,showError:t,checked:a,automationId:i,...s}){return(0,g.jsxs)("div",{className:v()({"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,p.__)("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:gu})]}),(0,g.jsxs)("label",{children:[(0,g.jsx)("input",{"aria-label":(0,p.__)("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:_u})]})]})}function bu({submitForm:e,loading:t,showCustomersImportSetting:a,isWizardStep:i=!1}){const[s,n]=(0,r.useState)(null),[l,d]=(0,r.useState)(!1===a?"unsubscribed":null),[c,m]=(0,r.useState)(!1),u=i?(0,p._x)("Continue","A label on a button","mailpoet"):(0,p._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,p._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,p.__)("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:b()((0,p.__)("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,p._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)(fu,{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:b()((0,p.__)("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,p._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)(fu,{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:u})]})]})}function xu(e){return(0,g.jsx)(Cn,{illustrationUrl:e.illustrationUrl,children:e.children})}function vu({isWizardStep:e=!1,redirectToNextStep:t=null}){const[a,i]=(0,r.useState)(!1),[s,n]=(0,pu.iK)("woocommerce"),l=(0,pu.iK)("tracking")[1],d=(0,pu.iK)("woocommerce_import_screen_displayed")[1],c=(0,pu.iK)("mailpoet_subscribe_old_woocommerce_customers")[1],u=e=>{i(!1),m.U.Notice.showApiErrorNotice(e,{scroll:!0})},p=e=>m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:e}).fail(u),h=(0,g.jsx)(xu,{illustrationUrl:window.wizard_woocommerce_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(bu,{loading:a,submitForm:async(a,r)=>{i(!0);const o="basic"===m.U.trackingConfig.level?"basic":"partial",h={level:r?"full":o,opens:"merged"},g={enabled:"subscribed"===a?"1":""},_={woocommerce_import_screen_displayed:1,"mailpoet_subscribe_old_woocommerce_customers.enabled":g.enabled,"tracking.level":h.level,"woocommerce.accept_cookie_revenue_tracking.set":"1","tracking.opens":h.opens};await p(_),l(h),c(g),n({...s,accept_cookie_revenue_tracking:{...s.accept_cookie_revenue_tracking||{},set:"1"}}),d("1"),await m.U.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"importExport",action:"setupWooCommerceInitialImport"}).fail(u),e?t():await(async()=>{e?await p({version:window.mailpoet_version}).then(()=>{window.location.href=window.finish_wizard_url}):window.location.href=window.finish_wizard_url})()},isWizardStep:e,showCustomersImportSetting:window.mailpoet_show_customers_import})})});return e?h:(0,g.jsx)(hu,{children:h})}function yu({skipStep:e,loading:t,update_sender:a,submit_sender:i,sender:s=null}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(qt.D,{level:1,children:(0,p.__)("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,p.__)("Default sender","mailpoet")}),(0,g.jsx)("br",{}),(0,p.__)("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(),Ct()("#mailpoet_sender_form").parsley().validate()&&i()},children:[(0,g.jsxs)(Ei.Grid.TwoColumns,{children:[(0,g.jsxs)("label",{htmlFor:"senderName",children:[(0,g.jsx)("span",{className:"mailpoet-wizard-label",children:(0,p._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,p._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,p._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,p._x)("Skip this step","A label on a skip button","mailpoet")})]})]})}xu.propTypes={illustrationUrl:Ut().string.isRequired,children:Ut().oneOfType([Ut().arrayOf(Ut().node),Ut().node]).isRequired},vu.displayName="WooCommerceController",yu.displayName="WelcomeWizardSenderStep";const wu=e=>null==e;function ju({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)(qt.D,{level:1,children:(0,p.__)("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),wu(a.libs3rdParty)||wu(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,p.__)("Enable modern text fonts in emails and show contextual help articles in MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:b()((0,p.__)("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)(fu,{showError:s&&wu(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,p.__)("Help improve MailPoet","mailpoet")}),(0,g.jsx)("div",{className:"mailpoet-wizard-note",children:b()((0,p.__)("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)(fu,{showError:s&&wu(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)(Ge.$,{className:"mailpoet-wizard-continue-button",isFullWidth:!0,type:"submit",withSpinner:e,disabled:e,children:(0,p._x)("Continue","A label on a button","mailpoet")})]})]})}ju.propTypes={loading:Ut().bool.isRequired,submitForm:Ut().func.isRequired},ju.displayName="WelcomeWizardUsageTrackingStep";var Su=a(69472);async function ku(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 Nu(e=null){await ku({version:window.mailpoet_version,installed_after_new_domain_restrictions:1,welcome_wizard_current_step:""}),window.location.href=e||window.finish_wizard_url}function Cu(){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:b()(m.U.I18n.t("welcomeWizardMSSAdvancedUsers"),/\[link](.*?)\[\/link]/g,(e,t)=>(0,g.jsx)("a",{onClick:a,href:"#",children:e},t))}),e&&(0,g.jsxs)(Te.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 Nu("admin.php?page=mailpoet-settings#/mta/other")},children:m.U.I18n.t("welcomeWizardMSSConfirmationModalOkButton")})]})]})]})}const Eu=(e,t,a=!1)=>{ku({welcome_wizard_current_step:t}),a?e(t,{replace:!0}):e(t)},Uu="https://account.mailpoet.com/?ref=plugin-wizard&utm_source=plugin&utm_medium=onboarding&utm_campaign=purchase";function Iu(){const e=(0,Ae.Zp)(),{step:t}=(0,Ae.g)(),a=(0,pu.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&Eu(e,`/steps/${t}/part/3`,!0)},[a.isKeyValid,e,t]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(qt.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<500?(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:Uu,target:"_blank",rel:"noopener noreferrer",onClick:a=>function(e,t,a){e.preventDefault(),window.open(Uu),Eu(t,`/steps/${a}/part/2`)}(a,e,t),iconEnd:(0,g.jsx)(ii.A,{icon:Su.A}),children:m.U.I18n.t("welcomeWizardMSSFirstPartButton")}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Cu,{})]})}var Au=a(87560),Tu=a(14240);function Pu(){const e=(0,Ae.Zp)(),{step:t}=(0,Ae.g)(),a=(0,pu.d4)("getKeyActivationState");return(0,r.useEffect)(()=>{!0===a.isKeyValid&&Eu(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:b()(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)(Tu.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)(Au.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)(Cu,{})]})}function Ru(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(qt.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:()=>Nu(),isFullWidth:!0,children:m.U.I18n.t("welcomeWizardMSSThirdPartButton")})]})}function Du(){const{pathname:e}=(0,Ae.zy)(),{step:t}=(0,Ae.g)(),a=(0,Ae.Zp)(),i=(0,Ae.zy)();return(0,r.useEffect)(()=>{i.pathname.includes("part")||Eu(a,`/steps/${t}/part/1`,!0)},[t,e,a,i]),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"part/1",element:(0,g.jsx)(Iu,{})}),(0,g.jsx)(Ae.qh,{path:"part/2",element:(0,g.jsx)(Pu,{})}),(0,g.jsx)(Ae.qh,{path:"part/3",element:(0,g.jsx)(Ru,{})})]})}const Fu=()=>{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},Ou=()=>Fu().length,Mu=async(e,t,a)=>{a<Ou()?Eu(e,`/steps/${a+1}`):t()};var Lu=a(22572);function $u(){const e=(0,Ae.g)(),t=(0,Ae.Zp)(),a=Ou(),i=parseInt(e.step,10),[s,n]=(0,r.useState)(!1),[l,c]=(0,pu.iK)("sender"),m=(0,pu.iK)("analytics")[1],u=(0,pu.iK)("3rd_party_libs")[1];(0,r.useEffect)(()=>{(i>a||i<1)&&Eu(t,"/steps/1")},[i,a,t]);const p=(0,Rt.partial)(Mu,t,Nu),h=(0,r.useCallback)(async(e,t)=>{const a={enabled:e?"1":""},i={enabled:t?"1":""},s={analytics:a,"3rd_party_libs":i};await ku(s),m(a),u(i)},[m,u]),_=(0,r.useCallback)(async(e,t)=>{n(!0),await h(e,t),p(i),n(!1)},[p,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 ku((({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})})(l)).then(()=>p(i)),n(!1)},[p,l,i,h]),x=(0,r.useCallback)(async e=>{e.preventDefault(),n(!0),window.mailpoet_is_dotcom&&!window.wizard_has_tracking_settings&&await h(!0,!0),p(i),n(!1)},[p,i,h]),v=(y=i,Fu()[y-1]||null);var y;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.V,{hideScreenOptions:!0,logoWithLink:!1,children:(0,g.jsx)(Lu.g,{count:a,current:i,doneCallback:e=>{Eu(t,`/steps/${e}`)}})}),(0,g.jsxs)(hu,{children:["WelcomeWizardSenderStep"===v?(0,g.jsx)(xu,{illustrationUrl:window.wizard_sender_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(yu,{update_sender:f,submit_sender:b,skipStep:x,loading:s,sender:l})})}):null,"WelcomeWizardUsageTrackingStep"===v?(0,g.jsx)(xu,{illustrationUrl:window.wizard_tracking_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(ju,{loading:s,submitForm:_})})}):null,"WelcomeWizardPitchMSSStep"===v?(0,g.jsx)(xu,{illustrationUrl:window.wizard_MSS_pitch_illustration_url,children:(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Du,{})})}):null,"WizardWooCommerceStep"===v?(0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(vu,{isWizardStep:!0,redirectToNextStep:()=>p(i)})}):null]})]})}$u.displayName="WelcomeWizardStepsController";const Bu=(0,o.withBoundary)($u),Wu=(0,o.withBoundary)(vu);function Vu(){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)(Ie.HashRouter,{children:[(0,g.jsx)(u.q,{}),(0,g.jsxs)(Ae.BV,{children:[(0,g.jsx)(Ae.qh,{path:"/steps/:step/*",element:(0,g.jsx)(Bu,{})}),(0,g.jsx)(Ae.qh,{path:"/woocommerce",element:(0,g.jsx)(Wu,{})}),(0,g.jsx)(Ae.qh,{path:"*",element:(0,g.jsx)(Ae.C5,{to:e})})]})]})})}const qu=document.getElementById("mailpoet-wizard-container");function Hu(){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)(u.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)})]})})}qu&&((0,o.registerTranslations)(),(0,uu.k)(),(0,n.H)(qu).render((0,g.jsx)(Vu,{})));const zu=document.getElementById("experimental_features_container");Hu.displayName="ExperimentalFeatures",zu&&((0,o.registerTranslations)(),(0,n.H)(zu).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Hu,{})})));let Gu=!1;function Yu({item:e,isExpanded:t,onToggle:a}){const i=`mailpoet-log-message-${e.id}`;return(0,g.jsx)("button",{type:"button",className:"button button-secondary button-small mailpoet-button","aria-expanded":t,"aria-controls":i,"aria-label":t?(0,p.sprintf)((0,p.__)("Show less of log message %d","mailpoet"),e.id):(0,p.sprintf)((0,p.__)("Show more of log message %d","mailpoet"),e.id),onClick:()=>a(e.id),children:(0,g.jsx)("span",{children:t?(0,p.__)("Show less","mailpoet"):(0,p.__)("Show more","mailpoet")})})}function Ku(e,t){return[{id:"name",label:(0,p.__)("Name","mailpoet"),type:"text",enableSorting:!1,enableGlobalSearch:!1,filterBy:!1,render:({item:e})=>(0,r.createElement)("span",{className:"mailpoet-logs-min-width"},e.name)},{id:"message",label:(0,p.__)("Message","mailpoet"),type:"text",enableSorting:!1,enableGlobalSearch:!1,filterBy:!1,render:({item:t})=>{const a=e.has(t.id);return(0,r.createElement)("div",{id:`mailpoet-log-message-${t.id}`,className:"mailpoet-logs-message "+(a?"mailpoet-logs-message-full":"")},t.message)}},{id:"action",label:(0,p.__)("Action","mailpoet"),enableSorting:!1,enableGlobalSearch:!1,filterBy:!1,render:({item:a})=>(0,r.createElement)(Yu,{item:a,isExpanded:e.has(a.id),onToggle:t})},{id:"created_at",label:(0,p.__)("Created On","mailpoet"),type:"datetime",enableSorting:!1,enableGlobalSearch:!1,filterBy:!1,render:({item:e})=>{return(0,r.createElement)("span",{className:"mailpoet-logs-min-width"},(t=e.created_at)?pl.s.full(t):"—");var t}}]}const Qu=new Set,Ju=()=>{};function Zu(e){if(!e)return;const t=Number(e);return!Number.isInteger(t)||t<1?void 0:t}function Xu(e){return e?Math.min(e,100):20}function ep(e){return e.split("").every(e=>e>="0"&&e<="9")}function tp(e){if(!e||10!==e.length)return!1;const t=e.split("-");if(3!==t.length||4!==t[0].length||2!==t[1].length||2!==t[2].length||!t.every(ep))return!1;const a=Number(t[0]),i=Number(t[1]),s=Number(t[2]),n=new Date(Date.UTC(a,i-1,s));return n.getUTCFullYear()===a&&n.getUTCMonth()===i-1&&n.getUTCDate()===s}function ap(e){if(!tp(e))return;const[t,a,i]=e.split("-").map(Number);return new Date(t,a-1,i)}function ip(e){return String(e).padStart(2,"0")}function sp(e){if(e&&!Number.isNaN(e.getTime()))return[e.getFullYear(),ip(e.getMonth()+1),ip(e.getDate())].join("-")}function np(e){const t=e.get("search")?.trim();return t||void 0}function rp(e,t){const a=e.get("from"),i=e.get("to"),s={};return tp(a)?s.from=a:tp(t)&&(s.from=t),tp(i)&&(s.to=i),s}function op(e,t){const a=Zu(e.get("logs_page"));if(a)return a;const i=function(e){if(null===e||""===e.trim())return;const t=Number(e);return!Number.isInteger(t)||t<0?void 0:t}(e.get("offset"));return void 0!==i?Math.floor(i/t)+1:1}function lp(e){return e.from&&e.to&&e.from>e.to?(0,p.__)("The start date must be before or equal to the end date.","mailpoet"):null}const dp={type:"table",perPage:20,page:1,sort:{field:"created_at",direction:"desc"},fields:["message","action","created_at"],titleField:"name",showTitle:!0};function cp(e){const t=window.location.href,a=function(e,t){const a=new URL(e).searchParams,i=function(e){return Xu(Zu(e.get("per_page"))||Zu(e.get("limit")))}(a);return{page:op(a,i),perPage:i,search:np(a),dateFilters:rp(a,t)}}(t,e),i=new URL(t).searchParams,s=i.has("per_page")||i.has("limit"),n=(0,$e.Aq)("logs",dp,Ku(Qu,Ju));return{view:{...n,page:a.page,perPage:s?a.perPage:n.perPage,search:a.search},dateFilters:a.dateFilters}}function mp({defaultFrom:e}){const t="mailpoet-logs-date-error",a=(0,r.useMemo)(()=>cp(e),[e]),[i,s]=(0,r.useState)(a.dateFilters),[n,l]=(0,r.useState)(a.dateFilters),[d,c]=(0,r.useState)(()=>new Set),m=(0,r.useRef)(!1),u=(0,r.useCallback)((e,t)=>lp(i)?Promise.resolve({items:[],meta:{count:0,pages:0}}):async function(e,t){return function(){if(Gu)return;const e=window.mailpoet_logs_api;Ro.default.use(Ro.default.createRootURLMiddleware(`${e.root}/`)),Ro.default.use(Ro.default.createNonceMiddleware(e.nonce)),Gu=!0}(),(await(0,Ro.default)({path:(0,Do.F)("/mailpoet/v1/logs",e),method:"GET",signal:t})).data}(function(e,t){const a=e.search?.trim();return{...e,search:a||void 0,filter:t}}(e,i),t),[i]),{view:h,setView:_,items:f,meta:b,isLoading:x,error:v,clearError:y,refresh:w}=(0,$e.i7)({initialView:a.view,load:u}),j=lp(n),S=v||j?null:(0,g.jsx)("div",{children:(0,p.__)("No logs found.","mailpoet")}),k=(0,r.useCallback)(e=>{const t=(e.search??"")!==(h.search??""),a=e.perPage!==h.perPage;_({...e,page:t||a?1:e.page})},[_,h]),N=(0,$e.wh)("logs",h,k);(0,r.useEffect)(()=>{if(!m.current)return void(m.current=!0);const e=function(e,t,a){const i=new URL(e),s=t.search?.trim();return i.searchParams.set("page","mailpoet-logs"),i.searchParams.delete("offset"),i.searchParams.delete("limit"),i.searchParams.delete("search"),i.searchParams.delete("from"),i.searchParams.delete("to"),s&&i.searchParams.set("search",s),a.from&&i.searchParams.set("from",a.from),a.to&&i.searchParams.set("to",a.to),i.searchParams.set("logs_page",String(t.page??1)),i.searchParams.set("per_page",String(Xu(t.perPage??20))),i.href}(window.location.href,h,i);window.history.replaceState({},"",e)},[i,h]),(0,r.useEffect)(()=>{c(e=>e.size>0?new Set:e)},[i,h.page,h.perPage,h.search]);const C=(0,r.useCallback)(e=>{c(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),E=(0,r.useMemo)(()=>Ku(d,C),[d,C]),U=(0,r.useMemo)(()=>({totalItems:b.count,totalPages:b.pages}),[b]),I=(0,r.useCallback)(()=>{j||(s(n),_(e=>({...e,page:1})))},[j,n,_]),A=(0,r.useCallback)(()=>{const e={};l(e),s(e),_(e=>({...e,page:1}))},[_]),T=(0,r.useCallback)(()=>{y(),w()},[y,w]);return(0,g.jsxs)("div",{className:"mailpoet-listing mailpoet-logs mailpoet-logs-dataviews",children:[v&&(0,g.jsx)(Fe.A,{status:"error",isDismissible:!1,children:(0,g.jsxs)("div",{className:"mailpoet-logs-error",children:[(0,g.jsx)("span",{children:(0,p.__)("Logs could not be loaded.","mailpoet")}),(0,g.jsx)(o.Button,{dimension:"small",variant:"secondary",onClick:T,isDisabled:x,children:(0,p.__)("Retry","mailpoet")})]})}),(0,g.jsxs)(Le.A,{data:f,fields:E,view:h,onChangeView:N,paginationInfo:U,defaultLayouts:{table:{}},getItemId:e=>String(e.id),isLoading:x,empty:S,children:[(0,g.jsxs)("div",{className:"mailpoet-logs-dataviews__toolbar",children:[(0,g.jsx)(Le.A.Search,{label:(0,p.__)("Search logs","mailpoet")}),(0,g.jsxs)("div",{className:"mailpoet-logs-date-filters",children:[(0,g.jsxs)("label",{className:"mailpoet-logs-date-filter",htmlFor:"mailpoet-logs-from",children:[(0,g.jsx)("span",{children:(0,p.__)("From","mailpoet")}),(0,g.jsx)(Li.t,{id:"mailpoet-logs-from",dateFormat:"MMMM d, yyyy",onChange:e=>l(t=>({...t,from:sp(e)})),maxDate:new Date,selected:ap(n.from),dimension:"small",disabled:x,isClearable:!0,"aria-label":(0,p.__)("Filter logs from date","mailpoet"),"aria-invalid":Boolean(j)||void 0,"aria-describedby":j?t:void 0})]}),(0,g.jsxs)("label",{className:"mailpoet-logs-date-filter",htmlFor:"mailpoet-logs-to",children:[(0,g.jsx)("span",{children:(0,p.__)("To","mailpoet")}),(0,g.jsx)(Li.t,{id:"mailpoet-logs-to",dateFormat:"MMMM d, yyyy",onChange:e=>l(t=>({...t,to:sp(e)})),maxDate:new Date,selected:ap(n.to),dimension:"small",disabled:x,isClearable:!0,"aria-label":(0,p.__)("Filter logs to date","mailpoet"),"aria-invalid":Boolean(j)||void 0,"aria-describedby":j?t:void 0})]}),(0,g.jsx)(o.Button,{dimension:"small",onClick:I,isDisabled:x||Boolean(j),children:(0,p.__)("Apply","mailpoet")}),(0,g.jsx)(o.Button,{dimension:"small",variant:"secondary",onClick:A,isDisabled:x,children:(0,p.__)("Clear","mailpoet")})]}),(0,g.jsx)("div",{className:"mailpoet-dataviews__toolbar-end",children:(0,g.jsx)(Le.A.ViewConfig,{})}),j&&(0,g.jsx)("div",{className:"mailpoet-logs-date-error",id:t,role:"alert",children:j})]}),(0,g.jsx)(Le.A.Layout,{}),(0,g.jsx)(Le.A.Footer,{})]})]})}mp.displayName="LogsList";const up=document.getElementById("mailpoet_logs_container");up&&(0,n.H)(up).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(mp,{defaultFrom:window.mailpoet_logs_default_from})}));var pp=a(66162);function hp({onRequestClose:e=Si.noop}){const[t,a]=(0,r.useState)(!1);return Ct()(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)(u.q,{}),t&&(0,g.jsx)(pp.U,{onRequestClose:()=>{a(!1),e()}})]})}const gp=document.getElementById("mailpoet_set_from_address_modal");gp&&(0,n.H)(gp).render((0,g.jsx)(hp,{onRequestClose:()=>{window.location.href.includes("?page=mailpoet-settings")&&window.location.reload()}}));const _p=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,Yi.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,p.__)("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,p.__)("Sending has been resumed.","mailpoet"))}).fail(e=>{e.errors.length>0&&m.U.Notice.showApiErrorNotice(e,{scroll:!0})})});Ct()(e=>{e(document).on("click",".notice .mailpoet-js-button-resume-sending",e=>{_p(e.target.value)})});var fp=a(11234);const bp=e=>{const t=window.location.href.includes("?page=mailpoet-settings"),a=window.location.href.includes("?page=mailpoet-newsletters#/send");(e=>{const t=`${(0,Yi.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 xp(){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)};Ct()(t=>{t(document).on("click",".mailpoet-js-button-authorize-email-and-sender-domain",e)})},[]),(0,g.jsx)(g.Fragment,{children:e&&(0,g.jsx)(fp.J,{senderEmail:e,onRequestClose:()=>{t("")},onSuccessAction:bp,showSenderEmailTab:"email"===a,showSenderDomainTab:"domain"===a,initialTab:"domain"===a?"sender_domain":"sender_email"})})}const vp=document.getElementById("mailpoet_authorize_sender_email_modal");function yp({color:e}){return(0,g.jsx)("style",{dangerouslySetInnerHTML:{__html:`body { background: ${e}; }`}})}vp&&(0,n.H)(vp).render((0,g.jsx)(xp,{}));const wp=()=>{window.location.href=window.mailpoet_welcome_wizard_url};function jp(){const e=window.mailpoet_welcome_wizard_current_step,t="string"==typeof e&&e.startsWith("/steps");return(0,g.jsx)(o.Button,{onClick:wp,dimension:"hero",children:t?(0,p.__)("Continue setup","mailpoet"):(0,p.__)("Begin setup","mailpoet")})}function Sp(){return(0,g.jsx)("section",{className:"landing-header",children:(0,g.jsxs)("div",{className:"mailpoet-content-center",children:[(0,g.jsx)(qt.D,{level:0,children:(0,p.__)("Better email — without leaving WordPress","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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)(jp,{})]})})}function kp(){return(0,g.jsx)("section",{className:"landing-footer",children:(0,g.jsxs)("div",{className:"landing-footer-content mailpoet-content-center",children:[(0,g.jsxs)(qt.D,{level:4,children:[" ",(0,p.__)("Ready to start using MailPoet?","mailpoet")," "]}),(0,g.jsx)(jp,{})]})})}function Np(){const e=[{slug:"item-1",title:(0,p.__)("What types of campaigns can I create with MailPoet?","mailpoet"),text:(0,p.__)("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,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/141-create-an-email-types-of-campaigns"},{slug:"item-2",title:(0,p.__)("How do I send a newsletter?","mailpoet"),text:(0,p.__)("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,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/344-create-a-standard-newsletter"},{slug:"item-3",title:(0,p.__)("Do I need a paid plan?","mailpoet"),text:(0,p.__)("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,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/349-mailpoet-plans-and-limits-explained"},{slug:"item-4",title:(0,p.__)("How do I import my customers from WooCommerce?","mailpoet"),text:(0,p.__)('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,p.__)("Read More","mailpoet"),readMoreLink:"https://kb.mailpoet.com/article/284-import-old-customers-to-the-woocommerce-customers-list"},{slug:"item-5",title:(0,p.__)("How do I customize emails for my store?","mailpoet"),text:(0,p.__)("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,p.__)("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)(qt.D,{level:2,children:[" ",(0,p.__)("Frequently asked questions","mailpoet")," "]}),(0,g.jsx)("p",{children:b()((0,p.__)("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)(qt.D,{level:2,children:(0,p.__)("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,p.__)("Can’t find what you’re looking for?","mailpoet")}),(0,g.jsx)("p",{children:b()((0,p.__)("[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))})]})]})}Sp.displayName="Landingpage Header",kp.displayName="Landingpage Footer",Np.displayName="Landingpage FAQ";const Cp={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 Ep(){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:Cp.heroImage,alt:"",className:"hero-image landingpage-images"}),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),(0,g.jsx)(qt.D,{level:4,children:(0,p.sprintf)((0,p.__)("Powerful email marketing, trusted by %s websites","mailpoet"),"600,000+")}),(0,g.jsx)("br",{}),(0,g.jsxs)(Ei.Grid.FourColumns,{className:"landingpage-general-features",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("img",{src:Cp.featureImages.icon_1,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Deliver beautiful emails","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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:Cp.featureImages.icon_2,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Grow your mailing list","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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:Cp.featureImages.icon_3,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Reach the right people","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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:Cp.featureImages.icon_4,alt:"",className:"landingpage-feature-icon"}),(0,g.jsx)("strong",{children:(0,p.__)("Save time with automations","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("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)(qt.D,{level:2,children:(0,p.__)("MailPoet + WooCommerce","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Deliver hyper-relevant content at every stage of your customer’s journey","mailpoet")})]}),(0,g.jsx)("br",{}),(0,g.jsxs)(Ei.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:Cp.wooCommerceFeatureImages.feature_1,alt:(0,p.__)("Automate customer communication feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Automate customer communication","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Drive sales and build loyalty through automated marketing messages that respond to your customer’s purchase data.","mailpoet")})]})]}),(0,g.jsxs)(Ei.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:Cp.wooCommerceFeatureImages.feature_2,alt:(0,p.__)("Measure revenue per email feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Measure revenue per email","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("See how much revenue your campaign is bringing and make improvements based on auto-generated email statistics.","mailpoet")})]})]}),(0,g.jsxs)(Ei.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:Cp.wooCommerceFeatureImages.feature_3,alt:(0,p.__)("Let your brand shine feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Let your brand shine","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Use our inbuilt WooCommerce email customizer to design your store's transactional emails and build customer confidence.","mailpoet")})]})]}),(0,g.jsxs)(Ei.Grid.TwoColumns,{className:"landingpage-wooCommerce-feature-item",children:[(0,g.jsx)("div",{children:(0,g.jsx)("img",{src:Cp.wooCommerceFeatureImages.feature_4,alt:(0,p.__)("Rescue abandoned carts feature Image","mailpoet"),className:"landingpage-images"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("strong",{children:(0,p.__)("Rescue abandoned carts","mailpoet")}),(0,g.jsx)("p",{children:(0,p.__)("Set up automated abandoned cart emails to win customers back and recover lost revenue.","mailpoet")})]})]})]})]})}function Up(){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)(yp,{color:"#fff"}),(0,g.jsx)(Sp,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Ep,{}),(0,g.jsx)("div",{className:"mailpoet-gap"}),(0,g.jsx)(Np,{}),(0,g.jsx)(kp,{})]})})}Ep.displayName="Landingpage Content",Up.displayName="Landingpage";const Ip=document.getElementById("mailpoet_landingpage_container");Ip&&((0,o.registerTranslations)(),(0,n.H)(Ip).render((0,g.jsx)(o.ErrorBoundary,{children:(0,g.jsx)(Up,{})}))),a(13435)},13435(){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(y(o)&&(i.dynamicTypingFunction=o,o={}),i.dynamicTyping=o,i.transform=!!y(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=y(i.step),i.chunk=y(i.chunk),i.complete=y(i.complete),i.error=y(i.error),delete i.worker,void l.postMessage({input:a,config:i,workerId:l.id})}var p=null;return r.NODE_STREAM_INPUT,"string"==typeof a?(a=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(a),p=i.download?new d(i):new m(i)):!0===a.readable&&y(a.read)&&y(a.on)?p=new u(i):(t.File&&a instanceof File||a instanceof Object)&&(p=new c(i)),p.stream(a)},unparse:function(e,t){var a=!1,i=!0,s=",",n="\r\n",o='"',l=o+o,d=!1,c=null,m=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||r.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e)}).length||(s=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(a=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(d=t.skipEmptyLines),"string"==typeof t.newline&&(n=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(i=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(m=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var u=new RegExp(h(o),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return p(null,e,d);if("object"==typeof e[0])return p(c||Object.keys(e[0]),e,d)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),p(e.fields||[],e.data||[],d);throw new Error("Unable to serialize unrecognized input");function p(e,t,a){var r="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var o=Array.isArray(e)&&0<e.length,l=!Array.isArray(t[0]);if(o&&i){for(var d=0;d<e.length;d++)0<d&&(r+=s),r+=g(e[d],d);0<t.length&&(r+=n)}for(var c=0;c<t.length;c++){var m=o?e.length:t[c].length,u=!1,p=o?0===Object.keys(t[c]).length:0===t[c].length;if(a&&!o&&(u="greedy"===a?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===a&&o){for(var h=[],_=0;_<m;_++){var f=l?e[_]:_;h.push(t[c][f])}u=""===h.join("").trim()}if(!u){for(var b=0;b<m;b++){0<b&&!p&&(r+=s);var x=o&&l?e[b]:b;r+=g(t[c][x],b)}c<t.length-1&&(!a||0<m&&!p)&&(r+=n)}}return r}function g(e,t){if(null==e)return"";if(e.constructor===Date)return JSON.stringify(e).slice(1,25);var i=!1;m&&"string"==typeof e&&m.test(e)&&(e="'"+e,i=!0);var n=e.toString().replace(u,l);return(i=i||!0===a||"function"==typeof a&&a(e,t)||Array.isArray(a)&&a[t]||function(e,t){for(var a=0;a<t.length;a++)if(-1<e.indexOf(t[a]))return!0;return!1}(n,r.BAD_DELIMITERS)||-1<n.indexOf(s)||" "===n.charAt(0)||" "===n.charAt(n.length-1))?o+n+o:n}}};if(r.RECORD_SEP=String.fromCharCode(30),r.UNIT_SEP=String.fromCharCode(31),r.BYTE_ORDER_MARK="\ufeff",r.BAD_DELIMITERS=["\r","\n",'"',r.BYTE_ORDER_MARK],r.WORKERS_SUPPORTED=!a&&!!t.Worker,r.NODE_STREAM_INPUT=1,r.LocalChunkSize=10485760,r.RemoteChunkSize=5242880,r.DefaultDelimiter=",",r.Parser=g,r.ParserHandle=p,r.NetworkStreamer=d,r.FileStreamer=c,r.StringStreamer=m,r.ReadableStreamStreamer=u,t.jQuery){var o=t.jQuery;o.fn.parse=function(e){var a=e.config||{},i=[];return this.each(function(e){if("INPUT"!==o(this).prop("tagName").toUpperCase()||"file"!==o(this).attr("type").toLowerCase()||!t.FileReader||!this.files||0===this.files.length)return!0;for(var s=0;s<this.files.length;s++)i.push({file:this.files[s],inputElem:this,instanceConfig:o.extend({},a)})}),s(),this;function s(){if(0!==i.length){var t,a,s,l=i[0];if(y(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(y(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){y(c)&&c(e,l.file,l.inputElem),n()},r.parse(l.file,l.instanceConfig)}else y(e.complete)&&e.complete()}function n(){i.splice(0,1),s()}}}function l(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=x(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new p(t),(this._handle.streamer=this)._config=t}.call(this,e),this.parseChunk=function(e,a){if(this.isFirstChunk&&y(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(y(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||!y(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){y(this._config.error)?this._config.error(e):i&&this._config.error&&t.postMessage({workerId:r.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=r.RemoteChunkSize),l.call(this,e),this._nextChunk=a?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),a||(t.onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!a),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var i in e)t.setRequestHeader(i,e[i])}if(this._config.chunkSize){var s=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+s)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}a&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var a=t.statusText||e;this._sendError(new Error(a))}}function c(e){var t,a;(e=e||{}).chunkSize||(e.chunkSize=r.LocalChunkSize),l.call(this,e);var i="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,a=e.slice||e.webkitSlice||e.mozSlice,i?((t=new FileReader).onload=v(this._chunkLoaded,this),t.onerror=v(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input;if(this._config.chunkSize){var s=Math.min(this._start+this._config.chunkSize,this._input.size);e=a.call(e,this._start,s)}var n=t.readAsText(e,this._config.encoding);i||this._chunkLoaded({target:{result:n}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function m(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,a=this._config.chunkSize;return a?(e=t.substring(0,a),t=t.substring(a)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function u(e){l.call(this,e=e||{});var t=[],a=!0,i=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){i&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):a=!0},this._streamData=v(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),a&&(a=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=v(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=v(function(){this._streamCleanUp(),i=!0,this._streamData("")},this),this._streamCleanUp=v(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function p(e){var t,a,i,s=Math.pow(2,53),n=-s,o=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,d=this,c=0,m=0,u=!1,p=!1,_=[],f={data:[],errors:[],meta:{}};if(y(e.step)){var b=e.step;e.step=function(t){if(f=t,j())w();else{if(w(),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 w(){return f&&i&&(k("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)})),j()&&function(){if(f)if(Array.isArray(f.data[0])){for(var t=0;j()&&t<f.data.length;t++)f.data[t].forEach(a);f.data.splice(0,1)}else f.data.forEach(a);function a(t,a){y(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?k("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+i,m+a):i<_.length&&k("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 j(){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 k(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)y(e.delimiter)&&(e.delimiter=e.delimiter(s),f.meta.delimiter=e.delimiter);else{var d=function(t,a,i,s,n){var o,l,d,c;n=n||[",","\t","|",";",r.RECORD_SEP,r.UNIT_SEP];for(var m=0;m<n.length;m++){var u=n[m],p=0,h=0,_=0;d=void 0;for(var f=new g({comments:s,delimiter:u,newline:a,preview:10}).parse(t),b=0;b<f.data.length;b++)if(i&&v(f.data[b]))_++;else{var x=f.data[b].length;h+=x,void 0!==d?0<x&&(p+=Math.abs(x-d),d=x):d=x}0<f.data.length&&(h/=f.data.length-_),(void 0===l||p<=l)&&(void 0===c||c<h)&&1.99<h&&(l=p,o=u,c=h)}return{successful:!!(e.delimiter=o),bestDelimiter:o}}(s,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess);d.successful?e.delimiter=d.bestDelimiter:(i=!0,e.delimiter=r.DefaultDelimiter),f.meta.delimiter=e.delimiter}var c=x(e);return e.preview&&e.header&&c.preview++,t=s,a=new g(c),f=a.parse(t,n,o),w(),u?{meta:{paused:!0}}:f||{meta:{paused:!1}}},this.paused=function(){return u},this.pause=function(){u=!0,a.abort(),t=y(e.chunk)?"":t.substring(a.getCharIndex())},this.resume=function(){d.streamer._halted?(u=!1,d.streamer.parseChunk(t,!0)):setTimeout(d.resume,3)},this.aborted=function(){return p},this.abort=function(){p=!0,a.abort(),f.meta.aborted=!0,y(e.complete)&&e.complete(f),t=""}}function h(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(e){var t,a=(e=e||{}).delimiter,i=e.newline,s=e.comments,n=e.step,o=e.preview,l=e.fastMode,d=t=void 0===e.quoteChar||null===e.quoteChar?'"':e.quoteChar;if(void 0!==e.escapeChar&&(d=e.escapeChar),("string"!=typeof a||-1<r.BAD_DELIMITERS.indexOf(a))&&(a=","),s===a)throw new Error("Comment character same as delimiter");!0===s?s="#":("string"!=typeof s||-1<r.BAD_DELIMITERS.indexOf(s))&&(s=!1),"\n"!==i&&"\r"!==i&&"\r\n"!==i&&(i="\n");var c=0,m=!1;this.parse=function(r,u,p){if("string"!=typeof r)throw new Error("Input must be a string");var g=r.length,_=a.length,f=i.length,b=s.length,x=y(n),v=[],w=[],j=[],S=c=0;if(!r)return z();if(e.header&&!u){var k=r.split(i)[0].split(a),N=[],C={},E=!1;for(var U in k){var I=k[U];y(e.transformHeader)&&(I=e.transformHeader(I,U));var A=I,T=C[I]||0;for(0<T&&(E=!0,A=I+"_"+T),C[I]=T+1;N.includes(A);)A=A+"_"+T;N.push(A)}if(E){var P=r.split(i);P[0]=N.join(a),r=P.join(i)}}if(l||!1!==l&&-1===r.indexOf(t)){for(var R=r.split(i),D=0;D<R.length;D++){if(j=R[D],c+=j.length,D!==R.length-1)c+=i.length;else if(p)return z();if(!s||j.substring(0,b)!==s){if(x){if(v=[],W(j.split(a)),G(),m)return z()}else W(j.split(a));if(o&&o<=D)return v=v.slice(0,o),z(!0)}}return z()}for(var F=r.indexOf(a,c),O=r.indexOf(i,c),M=new RegExp(h(d)+h(t),"g"),L=r.indexOf(t,c);;)if(r[c]!==t)if(s&&0===j.length&&r.substring(c,c+b)===s){if(-1===O)return z();c=O+f,O=r.indexOf(i,c),F=r.indexOf(a,c)}else if(-1!==F&&(F<O||-1===O))j.push(r.substring(c,F)),c=F+_,F=r.indexOf(a,c);else{if(-1===O)break;if(j.push(r.substring(c,O)),H(O+f),x&&(G(),m))return z();if(o&&v.length>=o)return z(!0)}else for(L=c,c++;;){if(-1===(L=r.indexOf(t,L+1)))return p||w.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),q();if(L===g-1)return q(r.substring(c,L).replace(M,t));if(t!==d||r[L+1]!==d){if(t===d||0===L||r[L-1]!==d){-1!==F&&F<L+1&&(F=r.indexOf(a,L+1)),-1!==O&&O<L+1&&(O=r.indexOf(i,L+1));var $=V(-1===O?F:Math.min(F,O));if(r.substr(L+1+$,_)===a){j.push(r.substring(c,L).replace(M,t)),r[c=L+1+$+_]!==t&&(L=r.indexOf(t,c)),F=r.indexOf(a,c),O=r.indexOf(i,c);break}var B=V(O);if(r.substring(L+1+B,L+1+B+f)===i){if(j.push(r.substring(c,L).replace(M,t)),H(L+1+B+f),F=r.indexOf(a,c),L=r.indexOf(t,c),x&&(G(),m))return z();if(o&&v.length>=o)return z(!0);break}w.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),L++}}else L++}return q();function W(e){v.push(e),S=c}function V(e){var t=0;if(-1!==e){var a=r.substring(L+1,e);a&&""===a.trim()&&(t=a.length)}return t}function q(e){return p||(void 0===e&&(e=r.substring(c)),j.push(e),c=g,W(j),x&&G()),z()}function H(e){c=e,W(j),j=[],O=r.indexOf(i,c)}function z(e){return{data:v,errors:w,meta:{delimiter:a,linebreak:i,aborted:m,truncated:!!e,cursor:S+(u||0)}}}function G(){n(z()),v=[],w=[]}},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(y(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 y(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];y(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 y(e){return"function"==typeof e}return i&&(t.onmessage=function(e){var a=e.data;if(void 0===r.WORKER_ID&&a&&(r.WORKER_ID=a.workerId),"string"==typeof a.input)t.postMessage({workerId:r.WORKER_ID,results:r.parse(a.input,a.config),finished:!0});else if(t.File&&a.input instanceof File||a.input instanceof Object){var i=r.parse(a.input,a.config);i&&t.postMessage({workerId:r.WORKER_ID,results:i,finished:!0})}}),(d.prototype=Object.create(l.prototype)).constructor=d,(c.prototype=Object.create(l.prototype)).constructor=c,(m.prototype=Object.create(m.prototype)).constructor=m,(u.prototype=Object.create(l.prototype)).constructor=u,r},void 0===(i=a.apply(t,[]))||(e.exports=i)},38255(e){e.exports=function(e){if(!window.satismeter){window.satismeter=function(){var e=[];function t(){e.push(arguments)}return t.q=e,t}();var t=document.createElement("script"),a=document.getElementsByTagName("script")[0].parentNode;t.async=1,t.src="https://app.satismeter.com/satismeter.js",a.appendChild(t)}return window.satismeter(e)}},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}},41669(e){"use strict";e.exports=jQuery}},e=>{e.O(0,[223],()=>e(e.s=34989)),e.O()}]);

Youez - 2016 - github.com/yon3zu
LinuXploit