"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[457],{77737:(e,t,a)=>{var s=a(99581),o=a(7936),l=a(16951),n=a(83201),i=a(94143),r=a(32976),c=a(16184),m=a(33014),u=a(70079),d=a(3939),h=a(97442),p=a(85180),x=a(45820),j=a(12266),_=a(30533),C=a(35250);function g(e){let{showModal:t,onClose:a}=e;return t?(0,C.jsx)(j.ZG,{onRequestClose:a,tracking:{utm_medium:"upsell_modal",utm_campaign:"create_automation_from_scratch"},children:(0,o.__)("You cannot create automation from scratch.","mailpoet")}):null}function b(e,t){h.Hooks.applyFilters("mailpoet.automation.templates.from_scratch_button",(()=>{e()}))(t)}function f(){const[e,t]=(0,u.useState)(!1),[a,s]=(0,u.useState)(null),[l,n]=(0,u.useState)(!1),i=(0,u.useCallback)((()=>{b((()=>{t(!0)}),s)}),[]);return(0,C.jsxs)(C.Fragment,{children:[a&&(0,C.jsx)(_.q,{type:"error",closable:!0,timeout:!1,children:(0,C.jsx)("p",{children:a})}),(0,C.jsx)(d.ZP,{variant:"secondary",isBusy:l,disabled:l,onClick:()=>{n(!0),i()},children:(0,o.__)("From scratch","mailpoet")}),(0,C.jsx)(g,{showModal:e,onClose:()=>{t(!1),n(!1)}})]})}function k(){const[e,t]=(0,u.useState)(!1),[a,s]=(0,u.useState)(!1),[l,n]=(0,u.useState)(null),i=(0,u.useCallback)((()=>{b((()=>{t(!0)}),n)}),[]);return(0,C.jsxs)("li",{className:"mailpoet-automation-template-list-item mailpoet-automation-from-scratch",children:[l&&(0,C.jsx)(_.q,{type:"error",closable:!0,timeout:!1,children:(0,C.jsx)("p",{children:l})}),(0,C.jsxs)(d.ZP,{isBusy:a,disabled:a,onClick:()=>{s(!0),i()},children:[(0,C.jsx)(p.Z,{width:"50px",height:"50px",icon:x.Z}),(0,o.__)("Create from scratch","mailpoet")]}),(0,C.jsx)(g,{showModal:e,onClose:()=>{t(!1),s(!1)}})]})}function w(){return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(m.Q,{}),(0,C.jsxs)(l.Z,{className:"mailpoet-automation-templates-heading",children:[(0,C.jsx)("h1",{className:"wp-heading-inline",children:(0,o.__)("Choose your automation template","mailpoet")}),(0,C.jsx)(f,{})]}),(0,C.jsxs)("ul",{className:"mailpoet-automation-templates",children:[i.U.map((e=>(0,C.jsx)(r.v,{template:e},e.slug))),(0,C.jsx)(k,{})]})]})}window.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("mailpoet_automation_templates");e&&((0,n.registerTranslations)(),(0,c.q)(),s.render((0,C.jsx)(w,{}),e))}))},65311:e=>{e.exports=jQuery}},e=>{e.O(0,[351],(()=>(77737,e(e.s=77737)))),e.O()}]);