"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[662],{24663(t,e,a){var o={};a.r(o),a.d(o,{deleteAutomation:()=>R,duplicateAutomation:()=>I,loadAutomations:()=>O,restoreAutomation:()=>M,trashAutomation:()=>D});var i={};a.r(i),a.d(i,{deleteLegacyAutomation:()=>K,loadLegacyAutomations:()=>J,restoreLegacyAutomation:()=>q,trashLegacyAutomation:()=>W});var s={};a.r(s),a.d(s,{getAllAutomations:()=>Z,getAutomationCount:()=>tt,getAutomations:()=>X,getLegacyAutomations:()=>Q});var n=a(7378),r=a(79124),l=a(36125),u=a(25354),c=a(91923),m=a(51751),d=a(14762),p=a(65591),h=a(10812),g=a(99708),_=a(69360);const A="mailpoet/automation-listing";var f=a(89074),y=a(95924),b=a(91736),w=a(73201),T=a(69611),x=a(69139),v=a(62623),j=a(37048),S=a(59717),N=a(86106);function E({automation:t,previousStatus:e}){const{restoreAutomation:a}=(0,S.A)(A);return(0,N.jsx)(T.Ay,{variant:"link",onClick:()=>{a(t,e)},children:(0,x.__)("Undo","mailpoet")})}var k=a(85123),P=a(83673);function U(t){return t.isLegacy?`?page=mailpoet-newsletter-editor&id=${t.id}`:(0,k.F)(P.U.urls.automationEditor,{id:t.id})}const L=(t,e)=>(0,w.J)(v.store).createSuccessNotice(t,e),C=t=>!1!==t?.showSuccessNotice;function*O(){const t=yield(0,b.apiFetch)({path:"/automations"});return{type:"SET_AUTOMATIONS",automations:Array.isArray(t.data?.items)?t.data.items:[]}}function*I(t,e){const a=yield(0,b.apiFetch)({path:`/automations/${t.id}/duplicate`,method:"POST"});return C(e)&&L((0,x.sprintf)((0,x.__)('Automation "%s" was duplicated.',"mailpoet"),t.name)),{type:"ADD_AUTOMATION",automation:a.data}}function*D(t,e){const a=yield(0,b.apiFetch)({path:`/automations/${t.id}`,method:"PUT",data:{status:j.i.TRASH}}),o=(0,x.sprintf)((0,x.__)('Automation "%s" was moved to the trash.',"mailpoet"),t.name);return C(e)&&L(o,{id:`automation-trashed-${t.id}`,__unstableHTML:(0,N.jsxs)("p",{children:[o," ",(0,N.jsx)(E,{automation:t,previousStatus:t.status})]})}),{type:"UPDATE_AUTOMATION",automation:a.data}}function*M(t,e,a){const o=yield(0,b.apiFetch)({path:`/automations/${t.id}`,method:"PUT",data:{status:e}});var i;i=`automation-trashed-${t.id}`,(0,w.J)(v.store).removeNotice(i);const s=(0,x.sprintf)((0,x.__)('Automation "%s" was restored from the trash.',"mailpoet"),t.name);return C(a)&&L(s,{__unstableHTML:(0,N.jsxs)("p",{children:[s," ",(0,N.jsx)(T.Ay,{variant:"link",href:U(t),children:(0,x.__)("Edit automation","mailpoet")})]})}),{type:"UPDATE_AUTOMATION",automation:o.data}}function*R(t,e){return yield(0,b.apiFetch)({path:`/automations/${t.id}`,method:"DELETE"}),C(e)&&L((0,x.sprintf)((0,x.__)('Automation "%s" and all associated data were permanently deleted.',"mailpoet"),t.name)),{type:"DELETE_AUTOMATION",automation:t}}var $=a(73193);const F=window.mailpoet_roles||{},H=window.mailpoet_segments||[],B=window.mailpoet_woocommerce_automatic_emails||{},Y=t=>{const e="welcome"===t.type?(t=>{const e=t.options;if("user"===e.event)return"mailpoet_all"===e.role?(0,x.__)("Sent when a new WordPress user is added to your site.","mailpoet"):(0,x.sprintf)((0,x.__)("Sent when a new WordPress user with the role %s is added to your site.","mailpoet"),F[e.role]);const a=Object.values(H).find(({id:t})=>Number(t)===Number(e.segment));return void 0===a?(0,N.jsx)("a",{href:`/send/${t.id}`,children:(0,x.__)("You need to select a list to send to.","mailpoet")}):(0,x.sprintf)((0,x.__)("Sent when someone subscribes to the list: %s.","mailpoet"),a.name)})(t):(t=>{const e=t.options,a=B[e.group].events[e.event];let o;try{o=JSON.parse(e.meta??null)}catch(t){o=e.meta??null}const i=o&&o.option&&Array.isArray(o.option)?o.option.map(({name:t})=>t):[];if(o&&0===i.length)return(0,N.jsx)("span",{className:"mailpoet-listing-error",children:(0,x.__)("You need to configure email options before this email can be sent.","mailpoet")});const s=i.length>1&&"listingScheduleDisplayTextPlural"in a?a.listingScheduleDisplayTextPlural:a.listingScheduleDisplayText;return(0,x.sprintf)(s.endsWith(".")?s:`${s}.`,i.join(", "))})(t),a=e?(t=>{const e=t.options;if("immediate"===e.afterTimeType)return;const a=e.afterTimeNumber;switch(e.afterTimeType){case"minutes":return(0,x.sprintf)((0,x.__)("%d minute(s) later","mailpoet"),a);case"hours":return(0,x.sprintf)((0,x.__)("%d hour(s) later","mailpoet"),a);case"days":return(0,x.sprintf)((0,x.__)("%d day(s) later","mailpoet"),a);case"weeks":return(0,x.sprintf)((0,x.__)("%d week(s) later","mailpoet"),a);default:return(0,x.__)("Invalid sending delay.","mailpoet")}})(t):void 0;return e?(0,N.jsxs)(N.Fragment,{children:[e,a&&(0,N.jsxs)(N.Fragment,{children:[" ",a]})]}):void 0},G=(t,e)=>(0,w.J)(v.store).createSuccessNotice(t,e),V=t=>!1!==t?.showSuccessNotice,z=t=>({id:t.id,name:t.subject,status:t.deleted_at?j.i.TRASH:t.status,stats:{totals:{entered:t.total_scheduled+t.total_sent,in_progress:t.total_scheduled,exited:t.total_sent}},isLegacy:!0,description:Y(t)});function*J(){return{type:"SET_LEGACY_AUTOMATIONS",automations:(yield(0,b.__unstableAwaitPromise)(Promise.all([(0,$.k)({endpoint:"newsletters",method:"listing","data[params][type]":"welcome","data[limit]":"400"}),(0,$.k)({endpoint:"newsletters",method:"listing","data[params][type]":"automatic","data[limit]":"400"})]))).flatMap(({data:t})=>t).map(z)}}function*W(t,e){return yield(0,b.__unstableAwaitPromise)((0,$.k)({endpoint:"newsletters",method:"trash","data[id]":`${t.id}`})),V(e)&&G((0,x.sprintf)((0,x.__)('Automation "%s" was moved to the trash.',"mailpoet"),t.name)),{type:"UPDATE_LEGACY_AUTOMATION_STATUS",id:t.id,status:j.i.TRASH}}function*q(t,e){const a=yield(0,b.__unstableAwaitPromise)((0,$.k)({endpoint:"newsletters",method:"restore","data[id]":`${t.id}`}));var o;return o=`automation-trashed-${t.id}`,(0,w.J)(v.store).removeNotice(o),V(e)&&G((0,x.sprintf)((0,x.__)('Automation "%s" was restored from the trash.',"mailpoet"),t.name)),{type:"UPDATE_LEGACY_AUTOMATION_STATUS",id:t.id,status:a.data.status}}function*K(t,e){return yield(0,b.__unstableAwaitPromise)((0,$.k)({endpoint:"newsletters",method:"delete","data[id]":`${t.id}`})),V(e)&&G((0,x.sprintf)((0,x.__)('Automation "%s" and all associated data were permanently deleted.',"mailpoet"),t.name)),{type:"DELETE_LEGACY_AUTOMATION",id:t.id}}function X(t){return t.automations}function Q(t){return t.legacyAutomations}function Z(t){return t.automations&&t.legacyAutomations?[...t.automations,...t.legacyAutomations]:void 0}function tt(t){return t.automations&&t.legacyAutomations?t.automations.length+t.legacyAutomations.length:_.automationCount+_.legacyAutomationCount}var et=a(94779),at=a(53169),ot=a(38986),it=a(99843),st=a(98077),nt=a(43103);function rt(t=""){return ot(t.trim().toLowerCase())}var lt=[],ut=a(84051),ct=a(99091),mt=a(4686),dt=a(81667),pt=a(80307);const ht=[{id:"name",label:(0,x.__)("Name","mailpoet"),type:"text",enableGlobalSearch:!0,enableSorting:!0,render:({item:t})=>(0,N.jsx)("a",{href:U(t),children:t.name})},{id:"description",label:(0,x.__)("Description","mailpoet"),enableGlobalSearch:!1,enableSorting:!1,enableHiding:!1,render:({item:t})=>t.description?(0,N.jsx)("div",{children:t.description}):null},{id:"subscribers",label:(0,x.__)("Subscribers","mailpoet"),enableGlobalSearch:!1,enableSorting:!1,getValue:({item:t})=>t.stats.totals.entered,render:({item:t})=>(0,N.jsx)(pt.K,{labelPosition:"after",items:[{key:"entered",label:(0,x._x)("Entered","automation stats","mailpoet"),value:t.stats.totals.entered},{key:"processing",label:(0,x._x)("Processing","automation stats","mailpoet"),value:t.stats.totals.in_progress},{key:"exited",label:(0,x._x)("Exited","automation stats","mailpoet"),value:t.stats.totals.exited}]})},{id:"status",label:(0,x.__)("Status","mailpoet"),enableGlobalSearch:!1,enableSorting:!1,getValue:({item:t})=>t.status,render:({item:t})=>(0,N.jsx)("span",{className:"mailpoet-automation-listing-cell-status",children:(0,N.jsx)(dt.iM,{status:t.status})})}],gt=25,_t={type:"table",perPage:gt,page:1,fields:["subscribers","status"],titleField:"name",descriptionField:"description",showTitle:!0,showDescription:!0,layout:{styles:{subscribers:{minWidth:"360px"},status:{width:"120px"}}}},At=["all",j.i.ACTIVE,j.i.DRAFT,j.i.TRASH];function ft(t){if(!t)return;const e=Number(t);return Number.isInteger(e)&&e>0?e:void 0}function yt(t){const e=t.get("status");return At.includes(e)?e:"all"}function bt(t){const e=t.get("order"),a=t.get("orderby");return{..._t,page:ft(t.get("paged"))??_t.page,perPage:ft(t.get("per_page"))??_t.perPage,search:t.get("search")??void 0,sort:!a||"asc"!==e&&"desc"!==e?void 0:{field:a,direction:e}}}function wt(t,e){return e>0?`${t} (${e})`:t}function Tt(t,e){switch(t){case"duplicate":return e.filter(t=>!t.isLegacy&&t.status!==j.i.TRASH);case"trash":return e.filter(t=>t.status!==j.i.TRASH);case"restore":case"delete":return e.filter(t=>t.status===j.i.TRASH);default:return[]}}function xt(){return(0,N.jsx)(mt.z,{heading:(0,x.__)("Automations","mailpoet"),children:(0,N.jsx)("a",{href:P.U.urls.automationTemplates,className:"page-title-action",children:(0,x.__)("Add new automation","mailpoet")})})}function vt(){const t=(0,ct.Zp)(),e=(0,ct.zy)(),[a,o]=(0,n.useState)(()=>yt(new URLSearchParams(e.search))),[i,s]=(0,n.useState)(()=>bt(new URLSearchParams(e.search))),[r,l]=(0,n.useState)([]),[u,c]=(0,n.useState)(null),d=(0,n.useRef)(a),p=(0,n.useRef)(i),h=(0,m.A)(t=>t(A).getAllAutomations()),{loadAutomations:g,loadLegacyAutomations:f,restoreAutomation:y,restoreLegacyAutomation:b,duplicateAutomation:T,trashAutomation:E,trashLegacyAutomation:L,deleteAutomation:C,deleteLegacyAutomation:O}=(0,S.A)(A);(0,n.useEffect)(()=>{g(),f()},[g,f]),(0,n.useEffect)(()=>{d.current=a,p.current=i},[a,i]),(0,n.useEffect)(()=>{const t=new URLSearchParams(e.search),a=yt(t);let i=!1;a!==d.current&&(o(a),i=!0),function(t,e){const a=bt(e);return(t.page??1)===(a.page??1)&&(t.perPage??gt)===(a.perPage??gt)&&(t.search??"")===(a.search??"")&&(t.sort?.field??"")===(a.sort?.field??"")&&(t.sort?.direction??"")===(a.sort?.direction??"")}(p.current,t)||(s(bt(t)),i=!0),i&&l([])},[e.search]);const I=(0,n.useCallback)((a,o)=>{const i=new URLSearchParams(e.search);i.set("status",a),(o.page??1)>1?i.set("paged",String(o.page)):i.delete("paged"),(o.perPage??gt)!==gt?i.set("per_page",String(o.perPage)):i.delete("per_page"),o.search?i.set("search",o.search):i.delete("search"),o.sort?(i.set("orderby",o.sort.field),i.set("order",o.sort.direction)):(i.delete("orderby"),i.delete("order"));const s=e.search.startsWith("?")?e.search.slice(1):e.search,n=i.toString();n!==s&&t({search:n})},[e.search,t]),D=(0,n.useCallback)(t=>{l([]),s(t),I(a,t)},[a,I]),M=(0,n.useMemo)(()=>{const t={all:[],[j.i.ACTIVE]:[],[j.i.DRAFT]:[],[j.i.TRASH]:[]};return(h??[]).forEach(e=>{e.status in t&&t[e.status].push(e),e.status!==j.i.TRASH&&t.all.push(e)}),t},[h]),R=_.automationCount+_.legacyAutomationCount,{data:$,paginationInfo:F}=(0,n.useMemo)(()=>h?function(t,e,a){if(!t)return{data:lt,paginationInfo:{totalItems:0,totalPages:0}};const o=(0,nt.A)(a);let i=[...t];if(e.search){const t=rt(e.search);i=i.filter(e=>o.filter(t=>t.enableGlobalSearch).some(a=>{const o=a.getValue({item:e});return(Array.isArray(o)?o:[o]).some(e=>rt(String(e)).includes(t))}))}e.filters&&e.filters?.length>0&&e.filters.forEach(t=>{const e=o.find(e=>e.id===t.field);if(e){t.operator===st.UX&&(0,it.A)("The 'isNotAll' filter operator",{since:"7.0",alternative:"'isNone'"});const a=e.filter[t.operator];a&&(i=i.filter(o=>a(o,e,t.value)))}});const s=e.sort?.field?o.find(t=>!1!==t.enableSorting&&t.id===e.sort?.field):null,n=e.groupBy?.field?o.find(t=>!1!==t.enableSorting&&t.id===e.groupBy?.field):null;(s||n)&&i.sort((t,a)=>{if(n){const o=n.sort(t,a,e.groupBy?.direction??"asc");if(0!==o)return o}return s?s.sort(t,a,e.sort?.direction??"desc"):0});let r=i.length,l=1;if(e.infiniteScrollEnabled&&void 0!==e.startPosition&&void 0!==e.perPage){const t=e.startPosition-1,a=Math.min(t+e.perPage,r);i=i?.slice(t,a)}else if(void 0!==e.page&&void 0!==e.perPage){const t=(e.page-1)*e.perPage;r=i?.length||0,l=Math.ceil(r/e.perPage),i=i?.slice(t,t+e.perPage)}return{data:i,paginationInfo:{totalItems:r,totalPages:l}}}(M[a]??[],i,ht):{data:[],paginationInfo:{totalItems:R,totalPages:Math.ceil(R/(i.perPage??gt))}},[h,a,M,R,i]);(0,n.useEffect)(()=>{const t=i.page??1,e=F.totalPages;h&&e>0&&t>e&&D({...i,page:e})},[h,D,F.totalPages,i]);const H=(0,n.useMemo)(()=>[{name:"all",title:wt((0,x.__)("All","mailpoet"),M.all.length),className:"mailpoet-dataviews-group-all mailpoet-tab-all"},{name:j.i.ACTIVE,title:wt((0,x.__)("Active","mailpoet"),M[j.i.ACTIVE].length),className:"mailpoet-tab-active"},{name:j.i.DRAFT,title:wt((0,x._x)("Inactive","noun","mailpoet"),M[j.i.DRAFT].length),className:"mailpoet-tab-draft"},{name:j.i.TRASH,title:wt((0,x._x)("Trash","noun","mailpoet"),M[j.i.TRASH].length),className:"mailpoet-dataviews-group-trash mailpoet-tab-trash"}],[M]),B=(0,n.useCallback)(async(t,e)=>{const a=Tt(t,e);if(0===a.length)return;const o=1===a.length,i={showSuccessNotice:o};var s;await Promise.all(a.map(e=>"duplicate"===t?T(e,i):"trash"===t?(e.isLegacy?L:E)(e,i):"restore"===t?e.isLegacy?b(e,i):y(e,j.i.DRAFT,i):(e.isLegacy?O:C)(e,i))),o||(s=function(t,e){return"duplicate"===t?(0,x.sprintf)((0,x._n)("%d automation was duplicated.","%d automations were duplicated.",e,"mailpoet"),e):"trash"===t?(0,x.sprintf)((0,x._n)("%d automation was moved to the trash.","%d automations were moved to the trash.",e,"mailpoet"),e):"restore"===t?(0,x.sprintf)((0,x._n)("%d automation was restored from the trash.","%d automations were restored from the trash.",e,"mailpoet"),e):(0,x.sprintf)((0,x._n)("%d automation was permanently deleted.","%d automations were permanently deleted.",e,"mailpoet"),e)}(t,a.length),(0,w.J)(v.store).createSuccessNotice(s)),l([])},[C,O,T,y,b,E,L]),Y=(0,n.useCallback)(()=>{u&&(B(u.action,u.targets),c(null))},[u,B]),G=(0,n.useMemo)(()=>[{id:"analytics",label:(0,x.__)("Analytics","mailpoet"),isPrimary:!0,supportsBulk:!1,callback:t=>{var e;t[0]&&(window.location.href=(e=t[0]).isLegacy?`?page=mailpoet-newsletters&context=automation#/stats/${e.id}`:(0,k.F)(P.U.urls.automationAnalytics,{id:e.id}))}},{id:"edit",label:(0,x.__)("Edit","mailpoet"),icon:"edit",isPrimary:!0,supportsBulk:!1,callback:t=>{t[0]&&(window.location.href=U(t[0]))}},{id:"duplicate",label:(0,x.__)("Duplicate","mailpoet"),supportsBulk:!0,isEligible:t=>!t.isLegacy&&t.status!==j.i.TRASH,callback:t=>{B("duplicate",t)}},{id:"trash",label:(0,x._x)("Trash","verb","mailpoet"),supportsBulk:!0,isEligible:t=>t.status!==j.i.TRASH,callback:t=>{const e=Tt("trash",t);e.length>0&&c({action:"trash",targets:e})}},{id:"restore",label:(0,x.__)("Restore","mailpoet"),supportsBulk:!0,isEligible:t=>t.status===j.i.TRASH,callback:t=>{B("restore",t)}},{id:"delete",label:(0,x.__)("Delete permanently","mailpoet"),supportsBulk:!0,isDestructive:!0,isEligible:t=>t.status===j.i.TRASH,callback:t=>{const e=Tt("delete",t);e.length>0&&c({action:"delete",targets:e})}}],[B]),V=a===j.i.TRASH?(0,x.__)("Trash is empty.","mailpoet"):(0,x.__)("No automations found.","mailpoet"),z=function(t){if(!t)return{title:"",message:"",confirmText:""};const e=t.targets.length,a=t.targets.map(t=>`"${t.name}"`).join(", ");return"trash"===t.action?{title:(0,x._n)("Trash automation","Trash automations",e,"mailpoet"),message:(0,x.sprintf)((0,x._n)("Are you sure you want to move the automation %s to the Trash?","Are you sure you want to move the automations %s to the Trash?",e,"mailpoet"),a),confirmText:(0,x.__)("Yes, move to trash","mailpoet")}:{title:(0,x._n)("Permanently delete automation","Permanently delete automations",e,"mailpoet"),message:(0,x.sprintf)((0,x._n)("Are you sure you want to permanently delete %s and all associated data? This cannot be undone!","Are you sure you want to permanently delete %s and all associated data? This cannot be undone!",e,"mailpoet"),a),confirmText:(0,x.__)("Yes, permanently delete","mailpoet")}}(u);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(et.A,{className:"mailpoet-dataviews__tabs",activeClass:"is-active",tabs:H,initialTabName:a,onSelect:t=>{if(!At.includes(t))return;const e=t;if(e===a)return;const n={...i,page:1};o(e),l([]),s(n),I(e,n)},children:()=>(0,N.jsx)("div",{className:"mailpoet-dataviews mailpoet-automation-dataviews","data-automation-id":"automation_listing",children:(0,N.jsxs)(ut.A,{data:$,fields:ht,view:i,onChangeView:D,actions:G,paginationInfo:F,defaultLayouts:{table:{}},getItemId:t=>`${t.isLegacy?"legacy":"automation"}-${t.id}`,selection:r,onChangeSelection:l,isLoading:!h,empty:(0,N.jsx)("div",{children:V}),children:[(0,N.jsx)("div",{className:"mailpoet-dataviews__toolbar",children:(0,N.jsx)(ut.A.Search,{label:(0,x.__)("Search automations","mailpoet")})}),(0,N.jsx)(ut.A.Layout,{}),(0,N.jsx)(ut.A.Footer,{})]},a)})},a),(0,N.jsx)(at.A,{className:"mailpoet-confirm-dialog",isOpen:!!u,title:z.title,confirmButtonText:z.confirmText,__experimentalHideHeader:!1,onConfirm:Y,onCancel:()=>c(null),children:z.message})]})}var jt=a(35843),St=a(88138),Nt=a(42176),Et=a(90194),kt=a(45919);function Pt({controls:t,title:e,onClick:a,variant:o}){const[i,s]=(0,n.useState)(!1),r=Object.values(t).filter(t=>t.slot),l=i?"mailpoet-option-button-opener is-busy":"mailpoet-option-button-opener";return(0,N.jsxs)("div",{className:"mailpoet-option-button",children:[(0,N.jsx)(T.Ay,{isBusy:i,disabled:i,variant:o,className:"mailpoet-option-button-main",onClick:()=>{s(!0),a(s)},children:e}),r.length>0&&r.map(({key:t,slot:e})=>(0,N.jsx)(e,{},t)),Object.values(t).length>0&&(0,N.jsx)(Et.A,{className:l,label:(0,x.__)("More","mailpoet"),icon:kt.A,controls:Object.values(t).map(t=>({...t.control,onClick:()=>{s(!0),t.control.onClick()}})),popoverProps:{placement:"bottom-start"}})]})}function Ut(){const t=Nt.Hooks.applyFilters("mailpoet.automation.hero.actions",{});return(0,N.jsx)("section",{className:"mailpoet-automation-section mailpoet-automation-white-background",children:(0,N.jsxs)("div",{className:"mailpoet-automation-section-content mailpoet-automation-section-hero",children:[(0,N.jsxs)("div",{children:[(0,N.jsx)("span",{className:"mailpoet-automation-preheading",children:(0,x.__)("Automations","mailpoet")}),(0,N.jsx)("h1",{children:(0,x.__)("Better engagement begins with automation","mailpoet")}),(0,N.jsx)("p",{children:(0,x.__)("Send emails that inform, reward, and engage your audience through powerful segmenting, scheduling, and design tools.","mailpoet")}),(0,N.jsx)(Pt,{variant:"primary",onClick:()=>{window.location.href=P.U.urls.automationTemplates},title:(0,x.__)("Start with a template","mailpoet"),controls:t})]}),(0,N.jsx)("img",{src:`${P.U.cdnUrl}automation/sections/hero.png`,alt:(0,x.__)("Welcome","mailpoet")})]})})}var Lt=a(328),Ct=a(8666);function Ot(){const t=Lt.X.slice(0,3);return(0,N.jsx)("section",{className:"mailpoet-automation-section",children:(0,N.jsxs)("div",{className:"mailpoet-automation-section-content mailpoet-section-templates",children:[(0,N.jsx)("h2",{children:(0,x.__)("Explore essentials","mailpoet")}),(0,N.jsx)("p",{children:(0,x.__)("Choose from our list of pre-made templates and make it your own.","mailpoet")}),(0,N.jsx)("ul",{className:"mailpoet-section-template-list",children:(0,N.jsx)(Ct.i,{templates:t})}),(0,N.jsx)(T.Ay,{variant:"link",href:P.U.urls.automationTemplates,children:(0,x.__)("Browse all templates →","mailpoet")})]})})}function It(){const[t,e]=(0,n.useState)("start-with-a-trigger"),a=[{slug:"start-with-a-trigger",title:(0,x.__)("Start with a trigger","mailpoet"),text:(0,x.__)("Deliver relevant messages to your customers based on who they are and how they interact with your business.","mailpoet"),image:`${P.U.cdnUrl}automation/sections/start-with-a-trigger.png`},{slug:"customize-your-automation",title:(0,x.__)("Customize your automation","mailpoet"),text:(0,x.__)("Choose steps and create a custom journey to best suit your needs.","mailpoet"),image:`${P.U.cdnUrl}automation/sections/customize-your-automation.png`},{slug:"design-your-email",title:(0,x.__)("Design your email","mailpoet"),text:(0,x.__)("Modify one of our pre-made email templates or create your own design.","mailpoet"),image:`${P.U.cdnUrl}automation/sections/design-your-email.png`},{slug:"start-engaging",title:(0,x.__)("Start engaging","mailpoet"),text:(0,x.__)("Activate the automation and start engaging with your customers as they interact with your business.","mailpoet"),image:`${P.U.cdnUrl}automation/sections/start-engaging.png`}],o=a.filter(e=>e.slug===t)[0];return(0,N.jsx)("section",{className:"mailpoet-automation-section mailpoet-automation-white-background",children:(0,N.jsxs)("div",{className:"mailpoet-automation-section-content mailpoet-section-build-your-own",children:[(0,N.jsxs)("div",{children:[(0,N.jsx)("h2",{children:(0,x.__)("Build your own automations","mailpoet")}),(0,N.jsx)("p",{children:(0,x.__)("Create customized email sequences with our new automation editor.","mailpoet")}),(0,N.jsx)("ol",{children:a.map((a,o)=>(0,N.jsxs)("li",{className:t===a.slug?"open":"",children:[(0,N.jsx)("div",{className:"marker",children:o<10?`0${o+1}`:o+1}),(0,N.jsxs)("div",{children:[(0,N.jsx)("button",{type:"button",onClick:()=>e(a.slug),className:"mailpoet-section-build-list-button",children:a.title}),(0,N.jsx)("p",{children:a.text})]})]},a.slug))})]}),(0,N.jsx)("img",{src:o.image,alt:o.title})]})})}var Dt=a(10995),Mt=a(27314),Rt=a(98933),$t=a(14442);const Ft=(0,Rt.qN)();function Ht(){const t=(0,n.useCallback)(()=>{(0,$.k)({endpoint:"UserFlags",method:"set","data[legacy_automations_notice_dismissed]":"1"})},[]);return(0,N.jsx)($t.$,{type:"info",timeout:!1,closable:!0,renderInPlace:!0,onClose:t,children:(0,N.jsx)("p",{children:Ft?(0,x.__)("Your existing automations are now listed here. You can also create new, more powerful automations with our new Automations editor.","mailpoet"):(0,Mt.A)((0,x.__)("Your existing automations are now listed here. You can also create new, more powerful automations with our new Automations editor. Learn more","mailpoet"),{link:(0,N.jsx)("a",{href:"https://kb.mailpoet.com/article/397-how-to-set-up-an-automation",target:"_blank",rel:"noopener noreferrer"})})})})}function Bt(){const[t,e]=(0,n.useState)(!0),a=(0,m.A)(t=>t(A).getAutomationCount());(0,n.useEffect)(()=>{t&&0!==a&&(P.U.trackEvent("Automations > Listing viewed"),e(!1))},[t,a]);const o=a>0?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(xt,{}),_.legacyAutomationCount>0&&!window.mailpoet_legacy_automations_notice_dismissed&&(0,N.jsx)(Ht,{}),(0,N.jsx)(vt,{})]}):(0,N.jsx)(Ut,{});return(0,n.useEffect)(()=>{const t="mailpoet-automation-is-onboarding",e=document.querySelector("body");0!==a||e.classList.contains(t)||e.classList.add(t),a>0&&e.classList.contains(t)&&e.classList.remove(t)},[a]),(0,N.jsxs)(N.Fragment,{children:[o,(0,N.jsx)(Ot,{}),(0,N.jsx)(It,{})]})}function Yt(){return(0,Dt.A)(),(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(u.x,{}),(0,N.jsx)(p.D,{}),(0,N.jsx)(St.q,{}),(0,N.jsx)(h.D,{}),(0,N.jsx)(Bt,{})]})}function Gt(){return(0,N.jsx)(c.Kq,{children:(0,N.jsx)(l.BrowserRouter,{basename:new URL(P.U.urls.automationListing).pathname,children:(0,N.jsx)(Yt,{})})})}window.addEventListener("DOMContentLoaded",()=>{(()=>{const t=(0,f.A)(A,{actions:{...o,...i},controls:b.controls,selectors:s,reducer:(t,e)=>function(t,e){switch(e.type){case"SET_LEGACY_AUTOMATIONS":return{...t,legacyAutomations:e.automations};case"UPDATE_LEGACY_AUTOMATION_STATUS":return{...t,legacyAutomations:t.legacyAutomations.map(t=>t.id===e.id?{...t,status:e.status}:t)};case"DELETE_LEGACY_AUTOMATION":return{...t,legacyAutomations:t.legacyAutomations.filter(t=>t.id!==e.id)};default:return t}}(function(t,e){switch(e.type){case"SET_AUTOMATIONS":return{...t,automations:e.automations};case"ADD_AUTOMATION":return{...t,automations:[e.automation,...t.automations]};case"UPDATE_AUTOMATION":return{...t,automations:t.automations.map(t=>t.id===e.automation.id?e.automation:t)};case"DELETE_AUTOMATION":return{...t,automations:t.automations.filter(t=>t.id!==e.automation.id)};default:return t}}(t,e),e),initialState:{automations:void 0,legacyAutomations:void 0}});(0,y.register)(t)})();const t=document.getElementById("mailpoet_automation");t&&((0,d.registerTranslations)(),(0,jt._)(),(0,g.b)(),(0,r.H)(t).render((0,N.jsx)(Gt,{})))})},41669(t){t.exports=jQuery}},t=>{t.O(0,[223],()=>t(t.s=24663)),t.O()}]);