File: /home/ohirex/web/ohirex.com/public_html/wp-content/plugins/mailster/build/workflows/stop/index.js
(()=>{var t={6942:(t,e)=>{var s;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var t="",e=0;e<arguments.length;e++){var s=arguments[e];s&&(t=o(t,n(s)))}return t}function n(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return i.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var e="";for(var s in t)r.call(t,s)&&t[s]&&(e=o(e,s));return e}function o(t,e){return e?t?t+" "+e:t+e:t}t.exports?(i.default=i,t.exports=i):void 0===(s=function(){return i}.apply(e,[]))||(t.exports=s)}()}},e={};function s(r){var i=e[r];if(void 0!==i)return i.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,s),n.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t=window.wp.blocks,e=window.wp.i18n,r=window.wp.blockEditor,i=window.wp.components,n=window.ReactJSXRuntime;function o(t){const{attributes:e,setAttributes:s}=t;return(0,n.jsx)(r.InspectorControls,{children:(0,n.jsx)(i.Panel,{})})}const a=(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsxs)("g",{fill:"none",children:[(0,n.jsx)("path",{stroke:"#c3232d",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M10 12V3.5A1.5 1.5 0 0111.5 2v0A1.5 1.5 0 0113 3.5V12M10 5.5A1.5 1.5 0 008.5 4v0A1.5 1.5 0 007 5.5V12"}),(0,n.jsx)("path",{stroke:"#c3232d",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M13 5.5A1.5 1.5 0 0114.5 4v0A1.5 1.5 0 0116 5.5V14l1.901-1.901a1.554 1.554 0 012.198 0v0c.524.524.605 1.345.194 1.961l-3.512 5.268A6 6 0 0111.789 22H10a6 6 0 01-6-6V7.5A1.5 1.5 0 015.5 6v0A1.5 1.5 0 017 7.5"})]})});var l=s(6942),d=s.n(l);const c=window.wp.element,h=window.wp.data,m=window.wp.apiFetch;var u=s.n(m);const f=window.wp.date,p=(0,f.getSettings)(),_=((0,e.__)("Minute","mailster"),(0,e.__)("Minutes","mailster"),(0,e.__)("Hour","mailster"),(0,e.__)("Hours","mailster"),(0,e.__)("Day","mailster"),(0,e.__)("Days","mailster"),(0,e.__)("Week","mailster"),(0,e.__)("Weeks","mailster"),(0,e.__)("Month","mailster"),(0,e.__)("Months","mailster"),(0,e.__)("Specific Time of the day","mailster"),(0,e.__)("Specific day of the week","mailster"),(0,e.__)("Specific day of the month","mailster"),(0,e.__)("Specific date","mailster"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"1st"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"2nd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"3rd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"4th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"5th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"6th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"7th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"8th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"9th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"10th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"11st"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"12nd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"13rd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"14th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"15th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"16th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"17th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"18th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"19th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"20th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"21st"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"22nd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"23rd"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"24th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"25th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"26th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"27th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"28th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"29th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"30th"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"31st"),(0,e.sprintf)((0,e.__)("%s day of the month","mailster"),"Last"),p.l10n.weekdays.slice(p.l10n.startOfWeek),p.l10n.weekdays.slice(0,p.l10n.startOfWeek),p.l10n.startOfWeek,p.formats.date),x=p.formats.time;function w({id:t,align:e}){const s=new URL("https://kb.mailster.co/"+t);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 r={};return e&&(r.float=e),(0,n.jsx)("a",{className:"mailster-help",href:s.toString(),"data-article":t,style:r})}function y(t){const{attributes:s}=t,{id:o}=s,a=(0,h.useSelect)((t=>t("core/editor").getCurrentPostId()),[]),[l,d]=(0,c.useState)(!1),[m,f]=(0,c.useState)(!1),p=function(t){const e=(0,h.useSelect)((t=>t("mailster/automation").getQueue()),[]),[s,r]=(0,c.useState)(0);return(0,c.useEffect)((()=>{e&&r(e[t]||0)}),[t,e]),s}(o),_=(0,e.sprintf)((0,e._n)("%s subscriber queued","%s subscribers queued",p,"mailster"),p);return(0,c.useEffect)((()=>{if(l&&o&&a)return p?void u()({path:"/mailster/v1/automations/queue/"+a+"/"+o}).then((t=>{f(t)})):f([])}),[l,a,o,p]),(0,n.jsxs)(n.Fragment,{children:[p>0&&(0,n.jsx)("span",{className:"mailster-step-queued",title:_,onClick:()=>d(!0),children:p}),l&&(0,n.jsxs)(i.Modal,{title:_,onRequestClose:()=>d(!1),children:[(0,n.jsx)(w,{id:"66b09cdba62a7505fcf33836",align:"right"}),(0,n.jsxs)("div",{className:"mailster-queue-table",children:[!m&&(0,n.jsx)(i.Panel,{children:(0,n.jsx)(i.PanelBody,{children:(0,n.jsx)(i.PanelRow,{children:(0,n.jsx)(i.Spinner,{})})})}),m&&(0,n.jsx)(j,{data:m,setData:f,...t})]}),(0,n.jsx)(i.Tip,{children:(0,e.__)("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,n.jsx)(r.InspectorControls,{children:p>0&&(0,n.jsxs)(i.Panel,{children:[(0,n.jsxs)(i.PanelBody,{title:(0,e.__)("Queue","mailster"),children:[(0,n.jsx)(w,{id:"66b09cdba62a7505fcf33836",align:"right"}),(0,n.jsx)(i.PanelRow,{children:(0,n.jsx)(i.Button,{onClick:()=>d(!0),variant:"secondary",children:_})})]}),(0,n.jsx)(i.PanelBody,{children:(0,n.jsx)(i.Tip,{children:(0,e.__)("Subscribers who are already queued in this step will not be affected by any changes you make.","mailster")})})]})})]})}p.formats.datetime,p.formats.time.match(/[a|A]/),window.lodash,window.moment;const j=t=>{const{attributes:s,data:r,setData:o}=t,{id:a}=s,[l,d]=(0,c.useState)(!1),m=(0,h.useSelect)((t=>t("core/editor").getCurrentPostId()),[]),p=(t,e,s,i)=>{const n="/mailster/v1/automations/queue/"+m+"/"+a+"/"+t.ID;d(!0),u()({path:n,method:s,data:i}).then((t=>{t&&o(r.filter(((t,s)=>s!==e))),d(!1),(0,h.dispatch)("mailster/automation").invalidateResolutionForStoreSelector("getQueue")}))},w=(new Date).getTime(),y=r.map(((t,r)=>{const o=1e3*t.timestamp,a=1e3*t.added;return(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{children:[(0,n.jsx)(i.ExternalLink,{href:"edit.php?post_type=newsletter&page=mailster_subscribers&ID="+t.subscriber_id,children:t.email}),0==t.status&&(0,n.jsx)("p",{className:"description",children:(0,e.__)("This subscriber hasn't confirmed their subscription yet. The workflow will continue once the user confirms their subscriptions.","mailster")})]}),(0,n.jsx)("td",{children:t.trigger}),(0,n.jsx)("td",{children:a&&(0,n.jsx)(i.Tooltip,{text:(0,f.dateI18n)(_,a)+" @ "+(0,f.dateI18n)(x,a),children:(0,n.jsx)("div",{children:(0,f.humanTimeDiff)(a)})})}),(0,n.jsx)("td",{children:o&&(0,n.jsx)(i.Tooltip,{text:(0,f.dateI18n)(_,o)+" @ "+(0,f.dateI18n)(x,o),children:(0,n.jsx)("div",{children:o>w?(0,f.humanTimeDiff)(o):(0,e.__)("right now","mailster")})})}),(0,n.jsxs)("td",{children:[(0,n.jsx)(i.Button,{icon:"flag",disabled:l,label:(0,e.__)("Finish Journey","mailster"),onClick:()=>((t,s)=>{const r=(0,e.sprintf)((0,e.__)("Do you really like to finish the journey for %s?","mailster"),t.email);confirm(r)&&p(t,s,"POST",{finish:!0})})(t,r)}),(0,n.jsx)(i.Button,{icon:"controls-skipforward",disabled:l||1!=t.status||s.disabled,label:(0,e.__)("Forward to next step","mailster"),onClick:()=>((t,s)=>{const r=(0,e.sprintf)((0,e.__)("Do you really like to forward %s to the next step?","mailster"),t.email);confirm(r)&&p(t,s,"POST",{forward:!0})})(t,r)}),(0,n.jsx)(i.Button,{icon:"trash",disabled:l,isDestructive:!0,label:(0,e.__)("Remove entry","mailster"),onClick:()=>((t,s)=>{const r=(0,e.sprintf)((0,e.__)("Do you really like to remove %s from the queue?","mailster"),t.email);confirm(r)&&p(t,s,"DELETE")})(t,r)})]})]},r)}));return(0,n.jsxs)("table",{className:"wp-list-table widefat striped",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:(0,e.__)("Subscriber","mailster")}),(0,n.jsx)("th",{children:(0,e.__)("Trigger","mailster")}),(0,n.jsx)("th",{children:(0,e.__)("Added","mailster")}),(0,n.jsx)("th",{children:(0,e.__)("Continues","mailster")}),(0,n.jsx)("th",{style:{width:"150px"},children:(0,e.__)("Actions","mailster")})]})}),(0,n.jsx)("tbody",{children:y})]})},b={label:(0,e.__)("Skip Step","mailster"),help:(0,e.__)("Skip this step when the workflow is executed.","mailster")},g={label:(0,e.__)("Skip Trigger","mailster"),help:(0,e.__)("Disable this trigger for the workflow.","mailster")};function k(t){const{attributes:e,setAttributes:s,name:o}=t,{disabled:a=!1}=e;if("mailster-workflow/stop"===o)return null;const l="mailster-workflow/trigger"==o?g:b;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.BlockControls,{group:"other",children:(0,n.jsx)(i.ToolbarButton,{icon:a?"hidden":"visibility",isPressed:a,title:l.label,onClick:()=>s({disabled:!a||void 0})})}),(0,n.jsx)(r.InspectorControls,{children:(0,n.jsx)(i.Panel,{children:(0,n.jsx)(i.PanelBody,{children:(0,n.jsx)(i.PanelRow,{children:(0,n.jsx)(i.ToggleControl,{__nextHasNoMarginBottom:!0,icon:a?"hidden":"visibility",label:l.label,help:l.help,checked:a,onChange:t=>s({disabled:!!t||void 0})})})})})})]})}function v(t){const{attributes:s,setAttributes:o,name:a}=t,{comment:l=""}=s;return"mailster-workflow/trigger"===a?null:(0,n.jsxs)(n.Fragment,{children:[l&&(0,n.jsx)("div",{className:"mailster-step-comment",children:l}),(0,n.jsx)(r.InspectorControls,{children:(0,n.jsx)(i.Panel,{children:(0,n.jsx)(i.PanelBody,{children:(0,n.jsx)(i.PanelRow,{children:(0,n.jsx)(i.TextControl,{__nextHasNoMarginBottom:!0,label:(0,e.__)("Comment","mailster"),help:(0,e.__)("Add a comment to help you understand your workflow.","mailster"),value:l,onChange:t=>o({comment:t||void 0})})})})})})]})}function S(t){const{attributes:s}=t,{id:o}=s;if(o)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"mailster-step-id",title:sprintf((0,e.__)("Step ID : %s","mailster"),o),children:o}),(0,n.jsx)(r.InspectorControls,{children:(0,n.jsx)(i.Panel,{children:(0,n.jsx)(i.PanelBody,{className:"code",children:sprintf((0,e.__)("Step ID : %s","mailster"),o)})})})]})}function P(t){const{attributes:s,clientId:o,name:a,isSelectionEnabled:l}=t,{isExample:d}=s;if((0,h.useSelect)((t=>{const e=t("core/block-editor").getBlocks();return e.length?e.at(-1).clientId:null}))!==o)return null;const c="mailster-workflow/triggers"===a?(0,e.__)("Click + to add a step","mailster"):(0,e.__)("Workflow Finished","mailster");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Tooltip,{text:(0,e.__)("Once the user reaches this point the workflow will be finished.","mailster"),children:(0,n.jsx)("span",{className:"workflow-finished "+a.replace("mailster-workflow/","workflow-finished-"),children:!d&&c})}),l&&(0,n.jsx)(r.ButtonBlockAppender,{})]})}function C(t){const{attributes:e,setAttributes:s,children:o,className:a=[],hasStepId:l=!0,before:m,after:u,inspectorControls:f,isSelected:p,isIncomplete:_,clientId:x,blockAttributes:w={},isSelectionEnabled:j}=t,{id:b,disabled:g=!1}=e;!function(t){const[e,s]=(0,c.useState)();(0,c.useEffect)((()=>{new Promise((t=>{const e=(0,h.subscribe)((()=>{if((0,h.select)("core/editor").isCleanNewPost()||(0,h.select)("core/block-editor").getBlockCount()>0){const s=document.querySelector('iframe[name="editor-canvas"]'),r=s?s.contentWindow:window,i=()=>{r.removeEventListener("load",i),e(),t(r)};r.document.querySelector(".is-root-container")?i():r.addEventListener("load",i)}}))})).then((e=>{s(e.document),t&&t(e.document)}))}),[])}((t=>{t&&l&&(!b||t.querySelectorAll(".mailster-step-"+b).length>1)&&s({id:x.substring(30)})})),(0,c.useEffect)((()=>{if(p&&b)return history.replaceState(void 0,void 0,"#step-"+b),()=>{history.pushState("",document.title,location.pathname+location.search)}}),[p]);const C=(0,c.useRef)();b&&a.push("mailster-step-"+b),_&&j&&a.push("mailster-step-incomplete"),g&&a.push("mailster-step-disabled");const A=(0,r.useBlockProps)({className:d()({},a),...w});return(0,n.jsxs)(n.Fragment,{children:[f,(0,n.jsxs)("div",{...A,children:[m,(0,n.jsxs)(i.Card,{className:"mailster-step",ref:C,children:[(0,n.jsx)(v,{...t}),(0,n.jsx)(k,{...t}),(0,n.jsx)(y,{...t}),(0,n.jsx)(S,{...t}),(0,n.jsx)("div",{className:"mailster-step-inner",children:o})]}),u,(0,n.jsx)("div",{className:"end-stop canvas-handle"})]}),(0,n.jsx)(P,{...t})]})}const A=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"mailster-workflow/stop","title":"Stop","category":"mailster-workflow-steps","keywords":["stop"],"parent":["mailster-workflow/condition-yes","mailster-workflow/condition-no"],"description":"This is a stop block which prevents any further action in the workflow.","example":{},"supports":{"html":false,"className":false,"customClassName":false},"attributes":{"id":{"type":"string"},"comment":{"type":"string"}},"textdomain":"mailster","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css"}'),{name:T,...B}=A;(0,t.registerBlockType)(T,{...B,icon:a,edit:function(t){const{attributes:e,setAttributes:s,isSelected:r,clientId:i}=t;return(0,n.jsx)(C,{...t,inspectorControls:(0,n.jsx)(o,{...t}),children:(0,n.jsx)("div",{className:"mailster-stop",children:a})})},save:()=>null})})()})();