HEX
Server: Apache/2.4.57 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.2
System: Linux vmi267337.contaboserver.net 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
User: ohirex (1008)
PHP: 8.2.8
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec
Upload Files
File: /home/ohirex/web/ohirex.com/public_html/wp-content/plugins/mailster/build/workflows/email/index.js
(()=>{var e={6942:(e,t)=>{var s;!function(){"use strict";var i={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(e=n(e,a(s)))}return e}function a(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var s in e)i.call(e,s)&&e[s]&&(t=n(t,s));return t}function n(e,t){return t?e?e+" "+t:e+t:e}e.exports?(r.default=r,e.exports=r):void 0===(s=function(){return r}.apply(t,[]))||(e.exports=s)}()}},t={};function s(i){var r=t[i];if(void 0!==r)return r.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,i=window.wp.element,r=window.wp.data,a=window.wp.components;var n=s(6942),l=s.n(n);const o=window.wp.blockEditor,c=window.wp.apiFetch;var d=s.n(c);const m=window.wp.date,h=(0,m.getSettings)(),u=((0,t.__)("Minute","mailster"),(0,t.__)("Minutes","mailster"),(0,t.__)("Hour","mailster"),(0,t.__)("Hours","mailster"),(0,t.__)("Day","mailster"),(0,t.__)("Days","mailster"),(0,t.__)("Week","mailster"),(0,t.__)("Weeks","mailster"),(0,t.__)("Month","mailster"),(0,t.__)("Months","mailster"),(0,t.__)("Specific Time of the day","mailster"),(0,t.__)("Specific day of the week","mailster"),(0,t.__)("Specific day of the month","mailster"),(0,t.__)("Specific date","mailster"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"1st"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"2nd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"3rd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"4th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"5th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"6th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"7th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"8th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"9th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"10th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"11st"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"12nd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"13rd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"14th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"15th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"16th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"17th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"18th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"19th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"20th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"21st"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"22nd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"23rd"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"24th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"25th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"26th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"27th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"28th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"29th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"30th"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"31st"),(0,t.sprintf)((0,t.__)("%s day of the month","mailster"),"Last"),h.l10n.weekdays.slice(h.l10n.startOfWeek),h.l10n.weekdays.slice(0,h.l10n.startOfWeek),h.l10n.startOfWeek,h.formats.date),p=h.formats.time,_=(h.formats.datetime,h.formats.time.match(/[a|A]/),window.lodash,window.moment,window.ReactJSXRuntime);function f({id:e,align:t}){const s=new URL("https://kb.mailster.co/"+e);s.searchParams.set("utm_campaign","plugin"),s.searchParams.set("utm_medium","link"),s.searchParams.set("utm_source","Mailster Plugin"),s.searchParams.set("utm_term","workflow");var i={};return t&&(i.float=t),(0,_.jsx)("a",{className:"mailster-help",href:s.toString(),"data-article":e,style:i})}function x(e,t){(0,r.dispatch)(t).invalidateResolutionForStoreSelector(e)}function j(e){const{attributes:s}=e,{id:n}=s,l=(0,r.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),[c,m]=(0,i.useState)(!1),[h,u]=(0,i.useState)(!1),p=function(e){const t=(0,r.useSelect)((e=>e("mailster/automation").getQueue()),[]),[s,a]=(0,i.useState)(0);return(0,i.useEffect)((()=>{t&&a(t[e]||0)}),[e,t]),s}(n),x=(0,t.sprintf)((0,t._n)("%s subscriber queued","%s subscribers queued",p,"mailster"),p);return(0,i.useEffect)((()=>{if(c&&n&&l)return p?void d()({path:"/mailster/v1/automations/queue/"+l+"/"+n}).then((e=>{u(e)})):u([])}),[c,l,n,p]),(0,_.jsxs)(_.Fragment,{children:[p>0&&(0,_.jsx)("span",{className:"mailster-step-queued",title:x,onClick:()=>m(!0),children:p}),c&&(0,_.jsxs)(a.Modal,{title:x,onRequestClose:()=>m(!1),children:[(0,_.jsx)(f,{id:"66b09cdba62a7505fcf33836",align:"right"}),(0,_.jsxs)("div",{className:"mailster-queue-table",children:[!h&&(0,_.jsx)(a.Panel,{children:(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(a.Spinner,{})})})}),h&&(0,_.jsx)(w,{data:h,setData:u,...e})]}),(0,_.jsx)(a.Tip,{children:(0,t.__)("This table shows you the subscribers which are currently queued in this step. You can finish, trash or move them to the next step with the action buttons.","mailster")})]}),(0,_.jsx)(o.InspectorControls,{children:p>0&&(0,_.jsxs)(a.Panel,{children:[(0,_.jsxs)(a.PanelBody,{title:(0,t.__)("Queue","mailster"),children:[(0,_.jsx)(f,{id:"66b09cdba62a7505fcf33836",align:"right"}),(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(a.Button,{onClick:()=>m(!0),variant:"secondary",children:x})})]}),(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.Tip,{children:(0,t.__)("Subscribers who are already queued in this step will not be affected by any changes you make.","mailster")})})]})})]})}const w=e=>{const{attributes:s,data:n,setData:l}=e,{id:o}=s,[c,h]=(0,i.useState)(!1),f=(0,r.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),j=(e,t,s,i)=>{const r="/mailster/v1/automations/queue/"+f+"/"+o+"/"+e.ID;h(!0),d()({path:r,method:s,data:i}).then((e=>{e&&l(n.filter(((e,s)=>s!==t))),h(!1),x("getQueue","mailster/automation")}))},w=(new Date).getTime(),b=n.map(((e,i)=>{const r=1e3*e.timestamp,n=1e3*e.added;return(0,_.jsxs)("tr",{children:[(0,_.jsxs)("td",{children:[(0,_.jsx)(a.ExternalLink,{href:"edit.php?post_type=newsletter&page=mailster_subscribers&ID="+e.subscriber_id,children:e.email}),0==e.status&&(0,_.jsx)("p",{className:"description",children:(0,t.__)("This subscriber hasn't confirmed their subscription yet. The workflow will continue once the user confirms their subscriptions.","mailster")})]}),(0,_.jsx)("td",{children:e.trigger}),(0,_.jsx)("td",{children:n&&(0,_.jsx)(a.Tooltip,{text:(0,m.dateI18n)(u,n)+" @ "+(0,m.dateI18n)(p,n),children:(0,_.jsx)("div",{children:(0,m.humanTimeDiff)(n)})})}),(0,_.jsx)("td",{children:r&&(0,_.jsx)(a.Tooltip,{text:(0,m.dateI18n)(u,r)+" @ "+(0,m.dateI18n)(p,r),children:(0,_.jsx)("div",{children:r>w?(0,m.humanTimeDiff)(r):(0,t.__)("right now","mailster")})})}),(0,_.jsxs)("td",{children:[(0,_.jsx)(a.Button,{icon:"flag",disabled:c,label:(0,t.__)("Finish Journey","mailster"),onClick:()=>((e,s)=>{const i=(0,t.sprintf)((0,t.__)("Do you really like to finish the journey for %s?","mailster"),e.email);confirm(i)&&j(e,s,"POST",{finish:!0})})(e,i)}),(0,_.jsx)(a.Button,{icon:"controls-skipforward",disabled:c||1!=e.status||s.disabled,label:(0,t.__)("Forward to next step","mailster"),onClick:()=>((e,s)=>{const i=(0,t.sprintf)((0,t.__)("Do you really like to forward %s to the next step?","mailster"),e.email);confirm(i)&&j(e,s,"POST",{forward:!0})})(e,i)}),(0,_.jsx)(a.Button,{icon:"trash",disabled:c,isDestructive:!0,label:(0,t.__)("Remove entry","mailster"),onClick:()=>((e,s)=>{const i=(0,t.sprintf)((0,t.__)("Do you really like to remove %s from the queue?","mailster"),e.email);confirm(i)&&j(e,s,"DELETE")})(e,i)})]})]},i)}));return(0,_.jsxs)("table",{className:"wp-list-table widefat striped",children:[(0,_.jsx)("thead",{children:(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{children:(0,t.__)("Subscriber","mailster")}),(0,_.jsx)("th",{children:(0,t.__)("Trigger","mailster")}),(0,_.jsx)("th",{children:(0,t.__)("Added","mailster")}),(0,_.jsx)("th",{children:(0,t.__)("Continues","mailster")}),(0,_.jsx)("th",{style:{width:"150px"},children:(0,t.__)("Actions","mailster")})]})}),(0,_.jsx)("tbody",{children:b})]})},b={label:(0,t.__)("Skip Step","mailster"),help:(0,t.__)("Skip this step when the workflow is executed.","mailster")},g={label:(0,t.__)("Skip Trigger","mailster"),help:(0,t.__)("Disable this trigger for the workflow.","mailster")};function y(e){const{attributes:t,setAttributes:s,name:i}=e,{disabled:r=!1}=t;if("mailster-workflow/stop"===i)return null;const n="mailster-workflow/trigger"==i?g:b;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(o.BlockControls,{group:"other",children:(0,_.jsx)(a.ToolbarButton,{icon:r?"hidden":"visibility",isPressed:r,title:n.label,onClick:()=>s({disabled:!r||void 0})})}),(0,_.jsx)(o.InspectorControls,{children:(0,_.jsx)(a.Panel,{children:(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(a.ToggleControl,{__nextHasNoMarginBottom:!0,icon:r?"hidden":"visibility",label:n.label,help:n.help,checked:r,onChange:e=>s({disabled:!!e||void 0})})})})})})]})}function v(e){const{attributes:s,setAttributes:i,name:r}=e,{comment:n=""}=s;return"mailster-workflow/trigger"===r?null:(0,_.jsxs)(_.Fragment,{children:[n&&(0,_.jsx)("div",{className:"mailster-step-comment",children:n}),(0,_.jsx)(o.InspectorControls,{children:(0,_.jsx)(a.Panel,{children:(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("Comment","mailster"),help:(0,t.__)("Add a comment to help you understand your workflow.","mailster"),value:n,onChange:e=>i({comment:e||void 0})})})})})})]})}function k(e){const{attributes:s}=e,{id:i}=s;if(i)return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{className:"mailster-step-id",title:sprintf((0,t.__)("Step ID : %s","mailster"),i),children:i}),(0,_.jsx)(o.InspectorControls,{children:(0,_.jsx)(a.Panel,{children:(0,_.jsx)(a.PanelBody,{className:"code",children:sprintf((0,t.__)("Step ID : %s","mailster"),i)})})})]})}function S(e){const{attributes:s,clientId:i,name:n,isSelectionEnabled:l}=e,{isExample:c}=s;if((0,r.useSelect)((e=>{const t=e("core/block-editor").getBlocks();return t.length?t.at(-1).clientId:null}))!==i)return null;const d="mailster-workflow/triggers"===n?(0,t.__)("Click + to add a step","mailster"):(0,t.__)("Workflow Finished","mailster");return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a.Tooltip,{text:(0,t.__)("Once the user reaches this point the workflow will be finished.","mailster"),children:(0,_.jsx)("span",{className:"workflow-finished "+n.replace("mailster-workflow/","workflow-finished-"),children:!c&&d})}),l&&(0,_.jsx)(o.ButtonBlockAppender,{})]})}function C(e){const{attributes:t,setAttributes:s,children:n,className:c=[],hasStepId:d=!0,before:m,after:h,inspectorControls:u,isSelected:p,isIncomplete:f,clientId:x,blockAttributes:w={},isSelectionEnabled:b}=e,{id:g,disabled:C=!1}=t;!function(e){const[t,s]=(0,i.useState)();(0,i.useEffect)((()=>{new Promise((e=>{const t=(0,r.subscribe)((()=>{if((0,r.select)("core/editor").isCleanNewPost()||(0,r.select)("core/block-editor").getBlockCount()>0){const s=document.querySelector('iframe[name="editor-canvas"]'),i=s?s.contentWindow:window,r=()=>{i.removeEventListener("load",r),t(),e(i)};i.document.querySelector(".is-root-container")?r():i.addEventListener("load",r)}}))})).then((t=>{s(t.document),e&&e(t.document)}))}),[])}((e=>{e&&d&&(!g||e.querySelectorAll(".mailster-step-"+g).length>1)&&s({id:x.substring(30)})})),(0,i.useEffect)((()=>{if(p&&g)return history.replaceState(void 0,void 0,"#step-"+g),()=>{history.pushState("",document.title,location.pathname+location.search)}}),[p]);const N=(0,i.useRef)();g&&c.push("mailster-step-"+g),f&&b&&c.push("mailster-step-incomplete"),C&&c.push("mailster-step-disabled");const P=(0,o.useBlockProps)({className:l()({},c),...w});return(0,_.jsxs)(_.Fragment,{children:[u,(0,_.jsxs)("div",{...P,children:[m,(0,_.jsxs)(a.Card,{className:"mailster-step",ref:N,children:[(0,_.jsx)(v,{...e}),(0,_.jsx)(y,{...e}),(0,_.jsx)(j,{...e}),(0,_.jsx)(k,{...e}),(0,_.jsx)("div",{className:"mailster-step-inner",children:n})]}),h,(0,_.jsx)("div",{className:"end-stop canvas-handle"})]}),(0,_.jsx)(S,{...e})]})}function N(e){const{attributes:s,setAttributes:n,campaignObj:l}=e,{campaign:c}=s,d=(0,r.useSelect)((e=>e("mailster/automation").getCampaigns()),[]),m=(0,r.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),[h,u]=(0,i.useState)(!1);(0,i.useEffect)((()=>(window.mailster_receiver_post_id=e=>{n({campaign:void 0}),x("getCampaigns","mailster/automation"),setTimeout((()=>{n({campaign:e?parseInt(e,10):void 0})}),100),u(!1)},()=>{window.mailster_receiver_post_id=!1})),[]);const p=()=>{const e=l?.nonce,t=l?.edit_url,s=new URL(t),i=s.searchParams;i.set("post",c),i.set("action","edit"),i.set("workflow",m),i.set("nonce",e),u(s.toString())},f=()=>{const e=new URL(location.origin+location.pathname.replace("post.php","post-new.php")),t=e.searchParams;t.set("post_type","newsletter"),t.set("workflow",m),u(e.toString())};return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(o.BlockControls,{group:"inline",children:[(0,_.jsx)(a.ToolbarButton,{icon:"edit",disabled:!c||!l,title:(0,t.__)("Edit Email","mailster"),onClick:p}),(0,_.jsx)(a.ToolbarButton,{icon:"welcome-add-page",title:(0,t.__)("New Email","mailster"),onClick:f})]}),d.length>0&&(0,_.jsx)(a.TreeSelect,{__nextHasNoMarginBottom:!0,label:(0,t.__)("Email","mailster"),help:(0,t.__)("Select an email you like to send in this step","mailster"),noOptionLabel:(0,t.__)("Select a email","mailster"),value:c,onChange:e=>{n({campaign:e?parseInt(e,10):void 0})},tree:d.map(((e,s)=>({name:(0,t.sprintf)("[#%d] %s",e.ID,e.title),id:e.ID})))}),(0,_.jsxs)(a.ButtonGroup,{children:[(0,_.jsx)(a.Button,{variant:"secondary",onClick:p,disabled:!c||!l,children:(0,t.__)("Edit Email","mailster")})," ",(0,_.jsx)(a.Button,{variant:"secondary",onClick:f,children:(0,t.__)("New Email","mailster")})]}),h&&(0,_.jsx)(a.Modal,{title:(0,t.__)("Email for this step","mailster"),className:"mailster-edit-campaign-modal",onRequestClose:()=>u(!1),shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,isFullScreen:!1,__experimentalHideHeader:!1,children:(0,_.jsx)("iframe",{src:h,id:"modal-iframe"})})]})}function P(e){const{attributes:s,setAttributes:i,campaignObj:r}=e,{campaign:n,subject:l="",preheader:c="",from:d="",from_name:m="",name:h=""}=s;return(0,_.jsxs)(o.InspectorControls,{children:[(0,_.jsx)(a.Panel,{children:(0,_.jsxs)(a.PanelBody,{children:[(0,_.jsx)(f,{id:"64623ab58783627a4ed4c5ec",align:"right"}),(0,_.jsx)(N,{...e})]})}),(0,_.jsxs)(a.Panel,{children:[(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("Name","mailster"),help:(0,t.__)("Set a name of this email.","mailster"),value:h,onChange:e=>i({name:e||void 0})})}),n&&(0,_.jsxs)(a.PanelBody,{children:[(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("Subject","mailster"),help:(0,t.__)("Overwrite the subject line of this email.","mailster"),placeholder:r?.subject,value:l,onChange:e=>i({subject:e||void 0})}),(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("Preheader","mailster"),help:(0,t.__)("Overwrite the preheader of this email.","mailster"),placeholder:r?.preheader,value:c,onChange:e=>i({preheader:e||void 0})}),(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("From Email Address","mailster"),help:(0,t.__)("Overwrite the email address of this email.","mailster"),placeholder:r?.from,value:d,onChange:e=>i({from:e||void 0})}),(0,_.jsx)(a.TextControl,{__nextHasNoMarginBottom:!0,label:(0,t.__)("From Name","mailster"),help:(0,t.__)("Overwrite the from name of this email.","mailster"),placeholder:r?.from_name,value:m,onChange:e=>i({from_name:e||void 0})})]})]}),(0,_.jsx)(a.Panel,{children:n&&(0,_.jsx)(a.PanelBody,{children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(a.Tip,{children:(0,t.__)("Emails get queued in this step and sent by your current cron process.","mailster")})})})})]})}const B=()=>(0,_.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 92.66 111.33",children:(0,_.jsx)("g",{fill:"#d6d6d6",children:(0,_.jsx)("path",{d:"M77.7 81.68H15.43c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM15.43 10.49h34.92c.44 0 .67-.22.67-.67s-.22-.67-.67-.67H15.43c-.44 0-.67.22-.67.67s.22.67.67.67zM77.7 77.66H15.43c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM76.52 14.82H16.6c-.92 0-1.84.73-1.84 1.7v35.02c0 .97.61 1.46 1.84 1.46h59.92c1.23 0 1.84-.49 1.84-1.46V16.28c0-.97-.61-1.46-1.84-1.46zM37.11 57.58H15.43c-.33 0-.67.33-.67.78v16.01c0 .44.22.67.67.67h21.68c.44 0 .67-.22.67-.67V58.25c0-.44-.22-.67-.67-.67zM77.7 57.58H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 61.6H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 65.61H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 69.63H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 73.65H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM37.11 88.5H15.43c-.33 0-.67.33-.67.78v16.01c0 .44.22.67.67.67h21.68c.44 0 .67-.22.67-.67V89.17c0-.44-.22-.67-.67-.67zM77.7 88.5H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 92.51H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 96.53H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 100.54H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67zM77.7 104.56H42.12c-.44 0-.67.22-.67.67s.22.67.67.67H77.7c.44 0 .67-.22.67-.67s-.22-.67-.67-.67z"})})}),H=(0,_.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,_.jsxs)("g",{fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",children:[(0,_.jsx)("path",{d:"M3 6.782v0c0 .591.293 1.144.782 1.475l5.981 4.053a4.001 4.001 0 004.488 0l5.966-4.044c.49-.33.783-.883.783-1.474v-.01C21 5.798 20.202 5 19.218 5H4.782C3.798 5 3 5.798 3 6.782z"}),(0,_.jsx)("path",{d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V7M3.586 18.414l6.14-6.14M14.281 12.281l6.13 6.13"})]})}),E=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"mailster-workflow/email","title":"Email","category":"mailster-workflow-steps","description":"Send an email.","parent":["core/post-content","mailster-workflow/condition-yes","mailster-workflow/condition-no"],"example":{"attributes":{"name":"Code is Poetry"}},"supports":{"html":false,"className":false,"customClassName":false},"attributes":{"id":{"type":"string"},"disabled":{"type":"boolean"},"name":{"type":"string"},"campaign":{"type":"integer"},"subject":{"type":"string"},"preheader":{"type":"string"},"comment":{"type":"string"}},"textdomain":"mailster","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css"}'),{name:M,...I}=E;(0,e.registerBlockType)(M,{...I,icon:H,__experimentalLabel:function(e,{context:s}){const{name:i,content:r,metadata:a}=e;return a?.name?a.name:(0,t.sprintf)((0,t.__)("Send Email %s","mailster"),'"'+i+'"')||r},edit:function(e){const{attributes:s,setAttributes:n,isSelected:l,clientId:o}=e,{id:c,campaign:d,subject:m,preheader:h,comment:u,isExample:p,name:f}=s,x=function(e,t=null,s=!0){const{getBlocks:i,getBlockRootClientId:a}=(0,r.select)("core/block-editor"),n=i(t);let l=[];return function t(i){i.forEach((i=>{i.name&&new RegExp(e,"g").test(i.name)&&(i.rootClientId=a(i.clientId),l.push(i)),s&&i.innerBlocks.length>0&&t(i.innerBlocks)}))}(n),l}("mailster-workflow/email"),j=x.findIndex((e=>e.clientId===o)),[w,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(),{invalidateResolutionForStore:v}=(0,r.useSelect)("mailster/automation"),{invalidateResolutionForStoreSelector:k}=(0,r.useDispatch)("mailster/automation"),S=(0,r.useSelect)((e=>e("mailster/automation").getCampaigns())),N=(0,r.useSelect)((e=>e("mailster/automation").getCampaignStats(d)),[d]);(0,i.useEffect)((()=>{b(H(d)),g&&n({name:g.title})}),[d,g]),(0,i.useEffect)((()=>{if(!S)return;if(!d)return;const e=S.filter((e=>e.ID==d));e.length&&y(e[0])}),[d,S]),(0,i.useEffect)((()=>{f||n({name:(0,t.sprintf)((0,t.__)("Email #%s","mailster"),j+1)})}),[x]),(0,i.useEffect)((()=>{k("getEmails")}),[d,f,c]);const H=e=>{if(!e)return!1;const t=new URL(location.origin+location.pathname.replace("post-new.php","post.php")),s=t.searchParams;s.set("post",e),s.set("action","preview_newsletter");const i={subject:m||g?.subject,preheader:h||g?.preheader};for(var r in i)i[r]&&s.append("replace["+r+"]",i[r]);return s.set("_cache",+new Date),t.toString()},E=m||g?.subject,M=w?(0,_.jsx)("iframe",{src:w,loading:"lazy",tabIndex:-1}):(0,_.jsx)(B,{});return(0,_.jsxs)(C,{...e,isIncomplete:!d&&!p,inspectorControls:(0,_.jsx)(P,{...e,campaignObj:g}),children:[(0,_.jsxs)(a.CardBody,{children:[(0,_.jsxs)("div",{className:"mailster-step-info",children:[(0,t.__)("Send Email","mailster"),d&&(0,_.jsxs)("span",{className:"mailster-campaign-id",children:[" #",d]})]}),(0,_.jsx)("div",{className:"mailster-step-label",children:f})]}),(0,_.jsx)(a.CardMedia,{children:(0,_.jsxs)("div",{className:"email-preview",children:[E&&(0,_.jsx)("div",{className:"email-preview-subject",children:E}),M]})}),(0,_.jsx)(a.CardFooter,{children:(0,_.jsxs)("div",{className:"email-stats",children:[(0,_.jsxs)("div",{className:"email-stats-sent",children:[(0,_.jsx)("div",{className:"email-stats-label",children:(0,t.__)("Sent","mailster")}),(0,_.jsx)("div",{className:"email-stats-value",children:N?.sent||"-"})]}),(0,_.jsxs)("div",{className:"email-stats-opens",children:[(0,_.jsx)("div",{className:"email-stats-label",children:(0,t.__)("Opened","mailster")}),(0,_.jsx)("div",{className:"email-stats-value",children:N?.opens||"-"})]}),(0,_.jsxs)("div",{className:"email-stats-clicks",children:[(0,_.jsx)("div",{className:"email-stats-label",children:(0,t.__)("Clicked","mailster")}),(0,_.jsx)("div",{className:"email-stats-value",children:N?.clicks||"-"})]}),(0,_.jsxs)("div",{className:"email-stats-unsubs",children:[(0,_.jsx)("div",{className:"email-stats-label",children:(0,t.__)("Unsubs","mailster")}),(0,_.jsx)("div",{className:"email-stats-value",children:N?.unsubs||"-"})]})]})})]})},save:()=>null})})()})();