From e912d699b676041fef06860a7d66e3bba26c7d6f Mon Sep 17 00:00:00 2001 From: picocodes Date: Sun, 12 Jan 2025 07:03:43 +0300 Subject: [PATCH] changes --- build/Emails/Types/Recurring.php | 19 ++++- build/Emails/assets/js/email-editor.asset.php | 2 +- build/Emails/assets/js/email-editor.js | 2 +- .../class-noptin-dynamic-content-tags.php | 8 +- .../email-templates/noptin-visual/styles.php | 4 + vendor/hizzle/store/src/REST_Controller.php | 77 +++++++++++++++++-- 6 files changed, 98 insertions(+), 14 deletions(-) diff --git a/build/Emails/Types/Recurring.php b/build/Emails/Types/Recurring.php index e50cb1b3..6d22b1b1 100644 --- a/build/Emails/Types/Recurring.php +++ b/build/Emails/Types/Recurring.php @@ -625,7 +625,7 @@ public function about_automation( $about, $campaign ) { '
%s
', $error, esc_attr( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next_send + ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ), - esc_html( $this->get_formatted_next_send_time( $next_send, wp_parse_id_list( $campaign->get( 'skip_days' ) ) ) ) + wp_kses_post( $this->get_formatted_next_send_time( $next_send, wp_parse_id_list( $campaign->get( 'skip_days' ) ) ) ) ); // If we have a next send time, but no cron event, display a warning. @@ -681,9 +681,20 @@ private function get_formatted_next_send_time( $timestamp, $skip_days = array() // If past, abort. if ( $timestamp < $now ) { return sprintf( - // translators: %1 is the time. - __( 'Was supposed to be send %1$s ago', 'newsletter-optin-box' ), - human_time_diff( $timestamp, $now ) + '%s. %s', + sprintf( + // translators: %1 is the time. + __( 'Was supposed to be send %1$s ago', 'newsletter-optin-box' ), + human_time_diff( $timestamp, $now ) + ), + sprintf( + '%s', + sprintf( + // translators: %s is the cron URL. + __( 'Set up an external cron job for "%s" to fix such issues.', 'newsletter-optin-box' ), + home_url( '/' ) . 'wp-cron.php' + ) + ) ); } diff --git a/build/Emails/assets/js/email-editor.asset.php b/build/Emails/assets/js/email-editor.asset.php index 176db7c6..80c72c21 100644 --- a/build/Emails/assets/js/email-editor.asset.php +++ b/build/Emails/assets/js/email-editor.asset.php @@ -1 +1 @@ - array('lodash', 'react', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '6ae81294a444bf1752cd'); + array('lodash', 'react', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '2aff7e3d73026b9b6647'); diff --git a/build/Emails/assets/js/email-editor.js b/build/Emails/assets/js/email-editor.js index 728ae98d..55b33f70 100644 --- a/build/Emails/assets/js/email-editor.js +++ b/build/Emails/assets/js/email-editor.js @@ -48,7 +48,7 @@ footer:(0,T.__)("Footer"),...s};return(0,b.jsxs)("div",{...u?x:{},ref:(0,d.useMe `,er=Wn.div` direction: ltr; display: flex; -`,tr=({value:e,onChange:t,...n})=>{const{baseControlProps:r,controlProps:a}=(0,C.useBaseControlProps)(n),o=e?e.split(":"):["07","00"],[l,i]=(0,_.useState)(o[0]),[s,c]=(0,_.useState)(o[1]),u=(e,t="00")=>(e=Number(e),isNaN(e)?t:e<10?`0${e}`:e),p=`${u(l)}:${u(s)}`;return(0,_.useEffect)((()=>{e!==p&&t(p)}),[p]),(0,_.createElement)(C.BaseControl,{...r},(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)(er,null,(0,_.createElement)(Qn,{value:u(l),onChange:i,min:0,max:23,step:1,...a,label:(0,T.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Yn(2)}),(0,_.createElement)(Zn,{"aria-hidden":"true"},":"),(0,_.createElement)(Jn,{value:u(s),onChange:c,min:0,max:59,step:1,label:(0,T.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Yn(2)})),(0,_.createElement)(Xn,null)))},nr=[{label:(0,T.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,T.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],rr=[{label:(0,T.__)("all","newsletter-optin-box"),value:"all"},{label:(0,T.__)("any","newsletter-optin-box"),value:"any"}];function ar(e,t){return(0,_.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function or({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:r}){const a=n>1;return(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,_.createElement)(C.SelectControl,{label:(0,T.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:nr,onChange:e=>r("action",e),size:"default",__nextHasNoMarginBottom:!0}),a&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.SelectControl,{label:(0,T.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:rr,onChange:e=>r("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,_.createElement)(C.__experimentalText,null,(0,T.__)("of the following rules are true:","newsletter-optin-box"))))}function lr({rule:e,comparisons:t,availableSmartTags:n,mergeTagsArray:r,index:a,updateRule:o,removeRule:l}){var i;const s=e=>o(a,{value:e}),c=null!==(i=e.full)&&void 0!==i?i:e.type?`[[${e.type}]]`:"",u=c.indexOf("]]"),p=c.indexOf("[[",u),m=-1===u||-1!==p&&p>u,d=e=>{const t={full:e};if(e){const n=e.match(/\[\[([^\s\]]+)/)?.[1]||"";n&&(t.type=n.replace("[[","").replace("]]",""))}o(a,t)},g=yr({availableSmartTags:r,onMergeTagClick:e=>{d(c?`${c} ${e}`.trim():e)}}),f=yr({availableSmartTags:r,onMergeTagClick:t=>{s(e.value?`${e.value} ${t}`.trim():t)}}),h=(0,_.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const r=t.replace("_",".",1);if(void 0!==n[r])return n[r];for(const[e,r]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return r;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(r.deprecated&&n(r.deprecated).includes(t))return r}return null}),[e.type,n]),b=ar((y=h?.options,(0,_.useMemo)((()=>y?Array.isArray(y)?y.map(((e,t)=>({label:e,value:t}))):Object.keys(y).map((e=>({label:y[e],value:e}))):[]),[y])),(0,T.__)("Select a value","newsletter-optin-box"));var y;const x=!m&&b.length>1,v=m?"string":h?.conditional_logic||"string",E=ar((0,_.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let r=t[n].type;if(x){if("string"===v&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==r&&r!=v||e.push({label:t[n].name,value:n})})),e}),[v,t]),(0,T.__)("Select a comparison","newsletter-optin-box")),w="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0,expanded:!0},(0,_.createElement)("div",{style:{minWidth:320}},(0,_.createElement)(C.__experimentalInputControl,{type:"text",label:(0,T.__)("Smart Tag","newsletter-optin-box"),hideLabelFromVision:!0,placeholder:(0,T.__)("Enter a smart tag","newsletter-optin-box"),value:c,onChange:d,autoComplete:"off",suffix:g,__next40pxDefaultSize:!0})),(0,_.createElement)("div",{style:{width:150}},(0,_.createElement)(C.SelectControl,{label:(0,T.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:E,onChange:e=>o(a,{condition:e}),size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})),!w&&(0,_.createElement)("div",{style:{minWidth:320}},x&&(0,_.createElement)(C.SelectControl,{label:(0,T.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:b,onChange:s,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),!x&&(0,_.createElement)(C.__experimentalInputControl,{type:"number"===v?"number":"text",label:(0,T.__)("Value","newsletter-optin-box"),placeholder:(0,T.__)("Enter a value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:s,suffix:f,__next40pxDefaultSize:!0})),(0,_.createElement)(C.Button,{onClick:()=>l(a),icon:"trash",variant:"tertiary",isDestructive:!0}))}function ir({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:r,disableTags:a,disableProps:o,closeModal:l}){const i=(0,_.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[e]),s=(0,_.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic,isPremium:Array.isArray(a)&&a.some((e=>t.smart_tag.startsWith(e)))||Array.isArray(o)&&o.some((e=>!!t[e]))})})),e}),[n]),c=(0,_.useCallback)((e=>{const t=[...i];t.splice(e,1),r("rules",t)}),[i,r]),u=(0,_.useCallback)(((e,t)=>{const n=[...i];n[e]={...n[e],...t},r("rules",n)}),[i,r]),p=(0,_.useMemo)((()=>Object.values(s)),[s]),m=(0,_.useCallback)(((e,t)=>{const n=s[e],a=n?.options||[],o=n?.placeholder||"";let l=Array.isArray(a)&&a.length?Object.keys(a)[0]:o;n?.default&&(l=n.default);const c=[...i];c.push({type:e,condition:"is",full:t,value:l}),r("rules",c)}),[i]),d=0===i.length?(0,T.__)("Add a conditional logic rule","newsletter-optin-box"):(0,T.__)("Add another rule","newsletter-optin-box"),g=yr({availableSmartTags:p,onMergeTagClick:m,raw:!0,icon:"plus",label:d,text:d,toggleProps:{variant:"primary"}});return(0,_.createElement)(_.Fragment,null,i.map(((e,n)=>(0,_.createElement)(lr,{key:n,rule:e,index:n,updateRule:u,removeRule:c,comparisons:t,availableSmartTags:s,mergeTagsArray:p}))),(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},g,l&&(0,_.createElement)(C.Button,{onClick:l,variant:"secondary"},(0,T.__)("Return to editor","newsletter-optin-box"))))}function sr({onChange:e,value:t,comparisons:n,toggleText:r,availableSmartTags:a,className:o,inModal:l=!1,...i}){const[s,c]=(0,_.useState)(!1),u=(0,_.useMemo)((()=>"object"!=typeof t?{enabled:!1,action:"allow",rules:[],type:"all"}:t),[t]),p=(0,_.useCallback)(((t,n)=>{e({...u,[t]:n})}),[e,u]),m=(0,_.createElement)(C.__experimentalVStack,{spacing:5},(0,_.createElement)(or,{ruleCount:Array.isArray(u.rules)?u.rules.length:0,type:u.type,action:u.action,setConditionalLogicAttribute:p}),(0,_.createElement)(ir,{rules:u.rules,comparisons:n,availableSmartTags:a,setConditionalLogicAttribute:p,closeModal:l&&(()=>c(!1)),...i}));return(0,_.createElement)(C.__experimentalVStack,{spacing:5,className:o},(0,_.createElement)(C.ToggleControl,{checked:!!u.enabled,onChange:e=>p("enabled",e),label:r||(0,T.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),u.enabled&&(0,_.createElement)(_.Fragment,null,l?(0,_.createElement)(_.Fragment,null,s&&(0,_.createElement)(C.Modal,{title:(0,T.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>c(!1),isFullScreen:!0},m),(0,_.createElement)(C.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>c(!0)},(0,T.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,_.createElement)(_.Fragment,null,m)))}const cr={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>ee<=t,includes:(e,t)=>e.includes(t),"!includes":(e,t)=>!e.includes(t),"^includes":(e,t)=>t.includes(e),"^!includes":(e,t)=>!t.includes(e),empty:(e,t)=>!t,"!empty":(e,t)=>t},ur=(e,t,n)=>!!cr[t]&&cr[t](e,"boolean"==typeof e&&void 0===n?Boolean(n):n),pr=["number","search","email","password","tel","url","date"];function mr({setting:e,availableSmartTags:t,isPressEnterToChange:n,...r}){void 0===n&&(n=!0);const a=yr({availableSmartTags:t,onMergeTagClick:(0,_.useCallback)((e=>{r.onChange&&r.onChange(r.value?`${r.value} ${e}`.trim():e)}),[r.value,r.onChange])});return"string"==typeof r.suffix||r.suffix instanceof String?r.suffix=(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,r.suffix):e.disabled||!a||r.suffix||(r.suffix=a),"datetime-local"===e.type&&(r.suffix=(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,(0,_.createElement)(C.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:e,onToggle:t})=>(0,_.createElement)(C.Button,{onClick:t,"aria-expanded":e,icon:gt}),renderContent:()=>(0,_.createElement)(C.DateTimePicker,{currentDate:r.value,onChange:e=>{e&&(e=(0,yt.format)("c",e)),r.onChange(e||"")}})}))),e.disabled&&(r.readOnly=!0,r.onFocus=e=>e.target.select(),e.value&&(r.value=e.value)),("string"==typeof r.prefix||r.prefix instanceof String)&&(r.prefix=(0,_.createElement)(C.__experimentalInputControlPrefixWrapper,null,r.prefix)),(0,_.createElement)(C.__experimentalInputControl,{...r,type:pr.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function dr({value:e,onChange:t,...n}){const{baseControlProps:r,controlProps:a}=(0,C.useBaseControlProps)({...n});return(0,_.createElement)(C.BaseControl,{...r},(0,_.createElement)(C.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:t,onToggle:n})=>(0,_.createElement)(C.Button,{onClick:n,"aria-expanded":t},(0,_.createElement)(C.ColorIndicator,{colorValue:e})),renderContent:()=>(0,_.createElement)(C.ColorPicker,{color:e,onChange:t}),...a}))}function _r({availableSmartTags:e,autoGrow:t=!1,label:n,id:r,setting:a,...o}){const l=yr({availableSmartTags:e,onMergeTagClick:(0,_.useCallback)((e=>{o.onChange&&o.onChange(o.value?`${o.value} ${e}`.trim():e)}),[o.value,o.onChange]),toggleProps:{size:"small"}}),i=!a.disabled&&l?(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)("span",null,n),l):n,s=r||(0,d.useInstanceId)(_r,"noptin-textarea");return(0,_.useEffect)((()=>{if(t){const e=document.getElementById(s);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[o.value,t,s]),a.disabled&&(o.readOnly=!0,o.onFocus=e=>e.target.select(),a.value&&(o.value=a.value)),(0,_.createElement)(C.TextareaControl,{...o,id:s,label:i,__nextHasNoMarginBottom:!0})}function gr({options:e,...t}){return(0,_.createElement)(C.__experimentalToggleGroupControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,...t},e.map(((e,t)=>(0,_.createElement)(C.__experimentalToggleGroupControlOption,{key:t,...e}))))}function fr({options:e,...t}){const[n,r]=(0,_.useState)(e);return(0,_.createElement)(C.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{r(t?e.filter((e=>!e.disabled&&""!==e.value&&(e.search?e.search.toLowerCase():e.label.toLowerCase()).includes(t.toLowerCase()))):e)},__experimentalRenderItem:({item:e,...t})=>e.render?"string"==typeof e.render?(0,_.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function hr({options:e,value:t,onChange:n,...r}){const a=Array.isArray(t)?t:[],o=(0,_.useMemo)((()=>e.map((e=>e.label))),[e]),l=(0,_.useCallback)((e=>o.includes(e)),[o]),i=(0,_.useMemo)((()=>a.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),s=(0,_.useCallback)((t=>{const r=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&r.add(t.value)}n(Array.from(r))}),[n,e]),c=(0,_.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,_.createElement)(ce.RawHTML,null,n.render):(0,_.createElement)(_.Fragment,null,t.item)}),[e]);return(0,_.createElement)(C.FormTokenField,{value:i,suggestions:o,onChange:s,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:l,__experimentalRenderItem:c,...r})}const br=[{id:"key",label:(0,T.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,T.__)("Value","noptin-addons-pack"),type:"text"}];function yr({availableSmartTags:e=[],onMergeTagClick:t=((e,t)=>{}),raw:n=!1,icon:r="shortcode",label:a=(0,T.__)("Insert merge tag","newsletter-optin-box"),...o}){const l=ne(e),i=Object.keys(l).length;let s=null;return i>0&&(s=(0,_.createElement)(C.DropdownMenu,{icon:r,label:a,...o},(({onClose:e})=>(0,_.createElement)(_.Fragment,null,Object.keys(l).map(((r,a)=>(0,_.createElement)(C.MenuGroup,{label:i>1?r:void 0,key:a},l[r].map((r=>(0,_.createElement)(C.MenuItem,{icon:r.isPremium?ft:r.icon||ht,iconPosition:"left",disabled:r.isPremium,onClick:()=>{if(!r.isPremium){if(t){const e=n?r.smart_tag:`[[${xr(r)}]]`;t(e,`[[${xr(r)}]]`)}e()}},key:r.smart_tag},(0,_.createElement)(ce.RawHTML,null,r.isPremium?`${r.label} - Premium`:r.label))))))))))),s}function xr(e){return e.example?e.example:e.default?`${e.smart_tag} default="${e.default}"`:`${e.smart_tag}`}function vr({availableSmartTags:e,value:t,onChange:n,button:r,fields:a,openModal:o,prepend:l,disable:i,disabled:s,onDisable:c,cardProps:u,repeaterKey:p,id:m,defaultItem:g,...f}){const[h,b]=(0,_.useState)(!1),y=Array.isArray(t)?t:[],x=m||(0,d.useInstanceId)(vr,"noptin-repeater"),{baseControlProps:v,controlProps:E}=(0,C.useBaseControlProps)({...f,id:x}),w=g||{};if(p?.newOnly&&(w.new=!0),!a)return console.warn("No fields provided to repeater control."),null;Object.keys(a).forEach((e=>{void 0!==a[e].default&&(w[e]=a[e].default)}));const k=!!o,S=(e,t)=>e.key?e.key:p?.to&&Tr(e,p.to)?Tr(e,p.to):t,P=(0,_.createElement)(C.__experimentalVStack,null,l,y.map(((t,r)=>(0,_.createElement)(C.Card,{size:"small",className:"noptin-no-shadow",id:`${x}__item-${S(t,r)}`,"data-index":r,borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0,...u||{},key:S(t,r)},(0,_.createElement)(Er,{id:`${x}__item-${S(t,r)}`,fields:a,value:t,availableSmartTags:e,onChange:e=>{let t={...e};if(p?.to&&p.from&&Tr(t,p.from)&&(!p.newOnly||t.new)){const e=Tr(t,p.from).toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");t=Pr(t,p.to,e.substring(0,p.maxLength||64)),y.find(((e,n)=>r!==n&&Tr(e,p.to)===Tr(t,p.to)))&&(t=Pr(t,p.to,`${Tr(t,p.to)}_${r}`))}const a=[...y];a[r]=t,n(a)},onDelete:()=>{const e=[...y];e.splice(r,1),n(e)},onMoveUp:r>0?()=>{const e=[...y],t=e[r];e.splice(r,1),e.splice(r-1,0,t),n(e)}:null,onMoveDown:r{const e=[...y],t=e[r];e.splice(r,1),e.splice(r+1,0,t),n(e)}:null,repeaterKey:p})))),(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)(C.Button,{onClick:()=>{const e=[...y],t=Date.now().toString(36),r=Math.random().toString(36).substring(2,8);e.push({key:`${t}_${r}`,...w}),n(e)},variant:"primary"},r||(0,T.__)("Add Item","newsletter-optin-box")),k&&(0,_.createElement)(C.Button,{onClick:()=>b(!1),variant:"secondary"},(0,T.__)("Go Back","newsletter-optin-box")))),M=!i||!s;return(0,_.createElement)(C.BaseControl,{...v},(0,_.createElement)("div",{...E},k&&(0,_.createElement)(C.__experimentalVStack,null,i&&(0,_.createElement)(C.ToggleControl,{label:i,checked:s,onChange:e=>{c&&c(e)}}),M&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.Button,{onClick:()=>b(!0),variant:"secondary"},o||(0,T.__)("Set Items","newsletter-optin-box")),h&&(0,_.createElement)(C.Modal,{title:f.label||o||(0,T.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>b(!1),size:"medium"},P))),!k&&P))}function Er({fields:e,availableSmartTags:t,value:n,onChange:r,repeaterKey:a,onDelete:o,onMoveUp:l,onMoveDown:i,id:s}){const[c,u]=(0,_.useState)(!a?.from),p=(0,_.useCallback)((()=>{u(!c)}),[c]),m=!c&&a?.from;let d=null;if(a){const e=!1!==a.display&&a.to&&n?.[a.to]?(0,_.createElement)("code",null,(0,T.sprintf)(a.display||"%s",n?.[a.to])):null,t={paddingLeft:16,paddingRight:16,height:48},r=Tr(n,a.from)||Tr(n,a.fallback);d=(0,_.createElement)(C.CardHeader,{style:{padding:0}},(0,_.createElement)(C.Flex,{as:C.Button,onClick:p,style:t,"aria-controls":`${s}__body`,"aria-expanded":!m,type:"button"},(0,_.createElement)(C.__experimentalHStack,{as:C.FlexBlock},(0,_.createElement)(C.__experimentalText,{weight:600},r||(0,T.__)("(new)","newsletter-optin-box"))),(0,_.createElement)(C.FlexItem,null,(0,_.createElement)(C.__experimentalHStack,null,e,(0,_.createElement)(C.Icon,{icon:c?"arrow-up-alt2":"arrow-down-alt2"})))))}return(0,_.createElement)(_.Fragment,null,d,!m&&(0,_.createElement)(C.CardBody,{id:`${s}__body`,hidden:m},(0,_.createElement)(C.__experimentalVStack,null,Object.keys(e).map((a=>(0,_.createElement)(Mr,{key:a,settingKey:a,availableSmartTags:t,setting:e[a],saved:n,setAttributes:e=>{r({...n,...e})}}))),(0,_.createElement)(C.__experimentalHStack,{className:"noptin-repeater-item__actions",justify:"flex-start"},!n?.predefined&&(0,_.createElement)(C.Button,{variant:"link",onClick:o,text:(0,T.__)("Remove Item","newsletter-optin-box"),isDestructive:!0}),l&&(0,_.createElement)(C.Button,{onClick:l,icon:"arrow-up-alt",text:(0,T.__)("Move Up","newsletter-optin-box"),size:"small",iconSize:16}),i&&(0,_.createElement)(C.Button,{onClick:i,icon:"arrow-down-alt",text:(0,T.__)("Move Down","newsletter-optin-box"),size:"small",iconSize:16})))))}function wr({setting:e,availableSmartTags:t,value:n,onChange:r,...a}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(a);Array.isArray(n)||(n=[]);const i=(0,_.useCallback)((({item:e,index:a})=>(0,_.createElement)(C.Flex,{className:"noptin-repeater-item",wrap:!0},br.map(((o,l)=>(0,_.createElement)(kr,{key:l,availableSmartTags:t,field:o,value:void 0===e[o.id]?"":e[o.id],onChange:e=>{const t=[...n];t[a][o.id]=e,r(t)}}))),(0,_.createElement)(C.FlexItem,null,(0,_.createElement)(C.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,T.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(a,1),r(e)},isDestructive:!0})))),[n,r]);return(0,_.createElement)(C.BaseControl,{...o},(0,_.createElement)("div",{...l},n.map(((e,t)=>(0,_.createElement)(i,{key:t,item:e,index:t}))),(0,_.createElement)(C.Button,{onClick:()=>{const e=[...n];e.push({}),r(e)},variant:"secondary"},e.add_field?e.add_field:(0,T.__)("Add","newsletter-optin-box"))))}function kr({field:e,availableSmartTags:t,value:n,onChange:r}){const a=yr({availableSmartTags:t,onMergeTagClick:(0,_.useCallback)((e=>{r&&r(n?`${n} ${e}`.trim():e)}),[n,r])});return(0,_.createElement)(C.FlexBlock,null,(0,_.createElement)(C.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,T.sprintf)((0,T.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:a,onChange:r,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Sr({setting:e,value:t,options:n,onChange:r,...a}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(a);return Array.isArray(t)||(t=[]),(0,_.createElement)(C.BaseControl,{...o},(0,_.createElement)("div",{...l},n.map(((e,n)=>(0,_.createElement)(C.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{r(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function Cr({value:e,onChange:t,id:n,...r}){const{baseControlProps:a,controlProps:o}=(0,C.useBaseControlProps)({...r,id:n,__nextHasNoMarginBottom:!0}),{wp:l,tinymce:i}=window,s=(0,_.useRef)(!1),c=(0,_.useRef)(null);return(0,_.useEffect)((()=>{if(!s.current)return;const t=t=>{t?.target?.classList?.contains("wp-switch-editor")&&setTimeout((()=>{const t=i?.get(n);t&&(t.setContent(e||""),t._lastChange=e)}),50)};return c.current?.addEventListener("click",t),()=>{c.current?.removeEventListener("click",t)}}),[c.current,e]),(0,_.useEffect)((()=>{if(!s.current)return;const e=i?.get(n);e&&e._lastChange}),[e]),(0,_.useEffect)((()=>{function r(){l.oldEditor.initialize(n,{tinymce:!!window.tinymce&&{content_css:!1,theme_advanced_buttons:"bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect",drag_drop_upload:!0,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,dfw",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",min_height:400,wpautop:!1,setup(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const r=(0,d.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",r),n.on("remove",r.cancel),n.on("keydown",(e=>{bt.isKeyboardEvent.primary(e,"z")&&e.stopPropagation(),bt.isKeyboardEvent.primary(e,"s")&&r.flush();const{altKey:t}=e;t&&e.keyCode===bt.F10&&e.stopPropagation()})),s.current=!0},...window?.tinyMCEPreInit?.mceInit[n]||{}},mediaButtons:!0,quicktags:{buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,close"}})}function a(){"complete"===document.readyState&&r()}return i?.execCommand("mceRemoveEditor",!0,n),"complete"===document.readyState?r():document.addEventListener("readystatechange",a),()=>{document.removeEventListener("readystatechange",a),l.oldEditor.remove(n)}}),[]),(0,_.createElement)(C.BaseControl,{...a},(0,_.createElement)("div",{ref:c},(0,_.createElement)("textarea",{...o,className:"wp-editor-area",style:{width:"100%"},value:e,onChange:e=>t(e.target.value),rows:10})))}const Tr=(e,t)=>{if(!t||0===t.length)return;if("string"==typeof t&&(t=t.split(".")),0===t.length||!e||"object"!=typeof e)return;const[n,...r]=t;return 0===r.length?e[n]:Tr(e[n],r)},Pr=(e,t,n)=>{if(!t||0===t.length)return e;"string"==typeof t&&(t=t.split("."));const[r,...a]=t;return 0===a.length?{...e,[r]:n}:{...e,[r]:Pr(e[r]||{},a,n)}};function Mr({settingKey:e,setting:t,availableSmartTags:n,prop:r,saved:a,setAttributes:o}){const l=(r?`${r}.${e}`:e).split("."),i=t.sanitize?t.sanitize:e=>e,s=(0,_.useCallback)((e=>{if(Tr(a,l)===e)return;const[t,...n]=l;return 0===n.length?o(i({[t]:e})):o(i({[t]:Pr(a[t]||{},n,e)}))}),[a,l,o,i]);if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!Tr(a,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return ur(e.value,n,Tr(a,t))})))return null;if(t.condition&&!t.condition(a))return null;let c=Tr(a,l);(void 0===c||t.disabled)&&(c=t.default);const u=void 0!==c&&""!==c&&null!==c;let p=[];t.options&&(p=Array.isArray(t.options)?[...t.options]:Object.keys(t.options).map((e=>({label:t.options?.[e],value:e}))));const m=`noptin-component__field-${e}`,d="string"==typeof t.description?(0,_.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,g=t.customAttributes?t.customAttributes:{},f={label:t.label,value:u?c:"",onChange:s,className:m,help:d,...g};if(t.tooltip&&(f.label=(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start"},(0,_.createElement)("span",null,t.label),(0,_.createElement)(C.Tooltip,{delay:0,placement:"top",text:t.tooltip},(0,_.createElement)("span",null,(0,_.createElement)(C.Icon,{icon:"info",style:{color:"#454545"}}))))),t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color","image"].includes(t.type)&&(t.el="input")),"button"===t.el)return(0,_.createElement)("div",null,(0,_.createElement)(C.Button,{...t.buttonProps||{}}));if("toggle_group"===t.el)return(0,_.createElement)(gr,{...f,options:p});if("select"===t.el)return t.multiple?(0,_.createElement)(hr,{...f,options:p}):(p.find((e=>""===e?.value))||p.unshift({label:t.placeholder?t.placeholder:(0,T.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,_.createElement)(C.SelectControl,{...f,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return p.unshift({label:t.placeholder?t.placeholder:(0,T.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,_.createElement)(fr,{...f,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,_.createElement)(C.FormTokenField,{...f,value:Array.isArray(f.value)?f.value:[],suggestions:Array.isArray(t.suggestions)?t.suggestions:[],__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,tokenizeOnBlur:!0});if("multi_checkbox"===t.el||"multi_checkbox_alt"===t.el)return(0,_.createElement)(Sr,{...f,options:p});if("conditional_logic"===t.el)return(0,_.createElement)(sr,{...f,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,_.createElement)(tr,{...f});if("color"===t.el||"input"===t.el&&"color"===t.type)return(0,_.createElement)(dr,{...f,__nextHasNoMarginBottom:!0});if("unit"===t.el)return(0,_.createElement)(C.__experimentalUnitControl,{labelPosition:"edge",__unstableInputWidth:"80px",__next40pxDefaultSize:!0,isPressEnterToChange:!0,...f});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,_.createElement)(C.ToggleControl,{...f,checked:!!u&&c});if("number"===t.type){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,e):e},n=e=>{if(e)return"string"==typeof e||e instanceof String?(0,_.createElement)(C.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(f.suffix)?f.suffix=e(1===c||"1"===c?f.suffix[0]:f.suffix[1]):f.suffix=e(f.suffix),Array.isArray(f.prefix)?f.prefix=n(1===c||"1"===c?f.prefix[0]:f.prefix[1]):f.prefix=n(f.prefix),(0,_.createElement)(C.__experimentalNumberControl,{...f,placeholder:t.placeholder?t.placeholder:"",__next40pxDefaultSize:!0})}return"image"===t.type&&(f.suffix=(0,_.createElement)(C.Button,{onClick:()=>{var e=window.wp.media({title:(0,T.__)("Upload Image","newsletter-optin-box"),multiple:!1,library:{type:"image"}}).open().on("select",(t=>{let n=e.state().get("selection").first();s(n.toJSON().sizes.full.url)}))},icon:"upload",label:(0,T.__)("Upload Image","newsletter-optin-box"),showTooltip:!0})),(0,_.createElement)(mr,{...f,setting:t,availableSmartTags:"trigger_settings"===r?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,_.createElement)(_r,{...f,setting:t,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===r?[]:n}):"tinymce"===t.el?(0,_.createElement)(Cr,{...f}):"paragraph"===t.el?(0,_.createElement)("div",{className:m},(0,_.createElement)(C.Tip,null,t.raw?(0,_.createElement)(ce.RawHTML,null,t.content):t.content)):"hero"===t.el?(0,_.createElement)("div",{className:m},(0,_.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,_.createElement)(wr,{...f,setting:t,availableSmartTags:"trigger_settings"===r?[]:n}):"repeater"===t.el?(0,_.createElement)(vr,{...f,availableSmartTags:"trigger_settings"===r?[]:n}):(console.log(t),e)}function Ar({onError:e=(e=>e),...t}){(0,m.uploadMedia)({onError:({message:t})=>e(t),wpAllowedMimeTypes:I?.wpAllowedMimeTypes,...t})}const Nr=function(e){const{preferredStyleVariations:t}=(0,P.useSelect)((e=>({preferredStyleVariations:e(Ee.store).get(N,"preferredStyleVariations")})),[]),{updatePreferredStyleVariations:n}=(0,P.useDispatch)(it);return(0,_.useMemo)((()=>({...I?.settings,...e,allowRightClickOverrides:!0,mediaUpload:I?.user?.canUpload?Ar:void 0,__experimentalFetchLinkSuggestions:(t,n)=>(0,M.__experimentalFetchLinkSuggestions)(t,n,e),__experimentalFetchRichUrlData:M.__experimentalFetchUrlData,__experimentalPreferredStyleVariations:{value:t,onChange:n}})),[e,t,n])},Ir=function(){const[e]=U("meta"),t=e?.campaign_data||{},n=t.background_color,r=t.background_image,a=t.font_family,o=t.font_size,l=t.font_style,i=t.font_weight,s=t.line_height,c=t.color,u=t.link_color,p=t.button_color,m=t.button_background,d=t.custom_css,g=t.block_css;return(0,_.useMemo)((()=>`\n\t\t\t\t.block-editor-iframe__body.editor-styles-wrapper {\n\t\t\t\t\tbackground-color: ${n||"#ffffff"};\n\t\t\t\t\tfont-family: ${a||"Arial, Helvetica, sans-serif"};\n\t\t\t\t\tfont-size: ${o||"14px"};\n\t\t\t\t\tfont-style: ${l||"normal"};\n\t\t\t\t\tfont-weight: ${i||"normal"};\n\t\t\t\t\tline-height: ${s||"1.5"};\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t${r?.url?`background-image: url(${r.url});`:""}\n\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\tbackground-repeat: no-repeat;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content.is-premium-feature {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\talign-items: center;\n\t\t\t\t\tjustify-content: center;\n\t\t\t\t\tpadding: 20px;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content.is-premium-feature .noptin-premium-feature {\n\t\t\t\t\tmax-width: 600px;\n\t\t\t\t}\n\t\t\t\t.content {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tmax-width: 100%;\n\t\t\t\t\tcolor: ${c||"#111111"};\n\t\t\t\t\tpadding: 0;\n\t\t\t\t\toverflow: auto;\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t}\n\t\t\t\t.content * {\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t}\n\t\t\t\t.content .block-editor-button-block-appender {\n\t\t\t\t\tcolor: currentColor;\n\t\t\t\t\tbox-shadow: inset 0 0 0 1px currentColor;\n\t\t\t\t}\n\t\t\t\t.wp-block-noptin-group {\n\t\t\t\t\tbackground-image: none !important;\n\t\t\t\t}\n\t\t\t\t.noptin-record {\n\t\t\t\t\tmin-height: 20px;\n\t\t\t\t\tmargin: 10px;\n\t\t\t\t\tpadding: 0;\n\t\t\t\t}\n\t\t\t\tdiv,\n\t\t\t\tol,\n\t\t\t\tul,\n\t\t\t\tp {\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t}\n\t\t\t\tp, h1, h2, h3, h4, h5, h6, .noptin-block__margin-wrapper {\n\t\t\t\t\tmargin: 0px 10px 16px;\n\t\t\t\t}\n\t\t\t\t.noptin-records__wrapper,\n\t\t\t\t.wp-block-noptin-separator {\n\t\t\t\t\tmargin-bottom: 16px;\n\t\t\t\t}\n\t\t\t\t.noptin-button-link {\n\t\t\t\t\tpadding-top: 10px;\n\t\t\t\t\tpadding-right: 25px;\n\t\t\t\t\tpadding-bottom: 10px;\n\t\t\t\t\tpadding-left: 25px;\n\t\t\t\t}\n\t\t\t\th1 {\n\t\t\t\t\tfont-size: 2em;\n\t\t\t\t\tline-height: 48px;\n\t\t\t\t}\n\t\t\t\th2{\n\t\t\t\t\tfont-size: 1.75em;\n\t\t\t\t\tline-height: 36px;\n\t\t\t\t}\n\n\t\t\t\th3 {\n\t\t\t\t\tfont-size: 1.5em;\n\t\t\t\t\tline-height: 30px;\n\t\t\t\t}\n\n\t\t\t\th4 {\n\t\t\t\t\tfont-size: 1.25em;\n\t\t\t\t\tline-height: 26px;\n\t\t\t\t}\n\n\t\t\t\th5 {\n\t\t\t\t\tfont-size: 1.125em;\n\t\t\t\t\tline-height: 22px;\n\t\t\t\t}\n\t\t\t\th6 {\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t\tline-height: 20px;\n\t\t\t\t}\n\t\t\t\timg, figure {\n\t\t\t\t\theight: auto;\n\t\t\t\t\tline-height: 100%;\n\t\t\t\t\ttext-decoration: none;\n\t\t\t\t\tborder: 0;\n\t\t\t\t\toutline: none;\n\t\t\t\t\tmax-width: 100%;\n\t\t\t\t}\n\t\t\t\t.content a {\n\t\t\t\t\tcolor: ${u||"#1a82e2"};\n\t\t\t\t\ttext-decoration: none;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:hover,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:focus,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:active {\n\t\t\t\t\tcolor: ${p||"#fff"};\n\t\t\t\t}\n\t\t\t\t.block-editor-default-block-appender__content {\n\t\t\t\t\tmargin-left: 10px;\n\t\t\t\t\tmargin-right: 10px;\n\t\t\t\t}\n\t\t\t\t.noptin-button-link__wrapper {\n\t\t\t\t\tbackground-color: ${m||"#1a82e2"};\n\t\t\t\t\tcolor: ${p||"#fff"};\n\t\t\t\t}\n\n\t\t\t\t.noptin-columns {\n\t\t\t\t\tdisplay: table;\n\t\t\t\t\ttable-layout: fixed;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t}\n\n\t\t\t\t.noptin-column {\n\t\t\t\t\tdisplay: table-cell;\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t}\n\n\t\t\t\t.noptin-column__inner {\n\t\t\t\t\tpadding: 10px;\n\t\t\t\t\tmargin-left: 10px;\n\t\t\t\t\tmargin-right: 10px;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper {\n\t\t\t\t\tborder-spacing: 0;\n\t\t\t\t\tborder-collapse: collapse;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper:not(.noptin-image-block__wrapper-is-aligned) {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper img {\n\t\t\t\t\tvertical-align: bottom;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-button-block__wrapper {\n\t\t\t\t\tborder-collapse: separate;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tline-height: 100%;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-button-block__wrapper table {\n\t\t\t\t\tborder-collapse: separate;\n\t\t\t\t}\n\n\t\t\t\t@media only screen and (max-width: 360px) {\n\t\t\t\t\t.noptin-is-stacked-on-mobile {\n\t\t\t\t\t\tdisplay: block !important;\n\t\t\t\t\t}\n\n\t\t\t\t\t.noptin-is-stacked-on-mobile.noptin-column {\n\t\t\t\t\t\tvertical-align: top !important;\n\t\t\t\t\t\twidth: 100% !important;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t${g?Object.values(g).join("\n"):""}\n\t\t\t\t${d||""}\n\n\t\t\t\t.block-editor-url-popover__settings > .components-h-stack .components-toggle-control:first-child {\n\t\t\t\t\tdisplay: none;\n\t\t\t\t}\n\t\t\t\t.wp-block-noptin-group {\n\t\t\t\t\tmargin-left: auto;\n\t\t\t\t\tmargin-right: auto;\n\t\t\t\t\tmargin-top: 20px;\n\t\t\t\t\tmargin-bottom: 20px;\n\t\t\t\t}\n\t\t\t\t.noptin-block-group__inner {\n\t\t\t\t\tpadding-top: 20px;\n\t\t\t\t\tpadding-bottom: 20px;\n\t\t\t\t}\n\t\t\t\ttable, td {\n\t\t\t\t\tborder-collapse: collapse;\n\t\t\t\t}\n\t\t\t`),[c,u,p,m,n,r,a,o,l,i,s,d,g])},Br=B.license||{},Fr=Br.is_usable&&Br.key,Or=({heading:e,helpText:t,needsAddonsPack:n,slug:r})=>{if(Lr(n))return[!0,null];const a=n&&Br.install_desc||(0,T.__)("Activate your license key to unlock","newsletter-optin-box"),o=n&&Br.install_text||(0,T.__)("View Pricing","newsletter-optin-box");let l=n&&Br.install_url||Br.upgrade_url||"https://noptin.com/pricing/";return Br.key||(l=(0,v.addQueryArgs)(l,{utm_source:r,utm_campaign:"emails"})),[!1,(0,_.createElement)(C.Placeholder,{icon:ft,label:e||(0,T.__)("Premium Feature","newsletter-optin-box"),className:"noptin-premium-feature"},(0,_.createElement)(C.__experimentalVStack,{spacing:4},t&&(0,_.createElement)("div",null,t),(0,_.createElement)("div",null,a),(0,_.createElement)(C.__experimentalHStack,{justify:"start",wrap:!0},!Br.key&&(0,_.createElement)(C.Button,{href:Br.activate_url,variant:"secondary",target:"_blank",text:(0,T.__)("Activate license","newsletter-optin-box"),style:{margin:0}}),(0,_.createElement)(C.Button,{href:l,variant:"primary",target:"_blank",text:o,style:{margin:0}}))))]},Lr=e=>(!e||Br.is_usable)&&Br.key,jr=/_published|_unpublished|_deleted|_user_role$/,Rr=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],Dr=[["woocommerce","subscription"],["latest_","_digest"]],zr=["WordPress Users"],Vr=["latest_posts_digest"],$r=["periodic"],Hr=(e,t=void 0)=>{if(!e||Vr.includes(e))return!1;if($r.includes(e))return!0;if(t&&zr.includes(t))return!0;if(Dr.some((t=>t.every((t=>e.includes(t))))))return!0;const n=e.replace(/^automation_rule_/,"");return jr.test(n)?"post_published"!==n:Rr.some((e=>n.startsWith(e)))};function Gr(e,t,n=500){const[r,a]=(0,_.useState)(e),o=(0,_.useRef)(t);return(0,_.useEffect)((()=>{o.current=t}),[t]),(0,_.useEffect)((()=>{const t=setTimeout((()=>{r!==e&&o.current(r)}),n);return()=>clearTimeout(t)}),[r,n,e]),{value:r,onChange:a}}const Ur=()=>{const e=(0,P.useSelect)((e=>e(M.store).getPostTypes({per_page:100})),[]);return(0,_.useMemo)((()=>{const t=["attachment"];return e?.filter((({viewable:e,slug:n})=>e&&!t.includes(n)))}),[e])},Kr=e=>(0,P.useSelect)((t=>{const{getTaxonomies:n}=t(M.store);return n({type:e,per_page:-1,context:"view"})}),[e]),Wr=()=>window.noptinEmailEditorSettings.settings?.__experimentalFeatures?.color?.palette?.theme||[],Yr=e=>{const t=(0,P.useSelect)((t=>t(Ve).isModalActive(e)),[e]),{openModal:n,closeModal:r}=(0,P.useDispatch)(Ve);return(0,_.useMemo)((()=>({openModal:()=>n(e),closeModal:r,toggleModal:()=>t?r():n(e),isModalActive:t})),[n,r,t,e])},qr=({...e})=>{const t=ae(),n=Lr(!1);return e.disableMergeTags||(e.availableSmartTags=t),"image_size_select"===e.setting?.el&&(e.setting.el="select",Array.isArray(I.settings?.imageSizes)&&(e.setting.options=I.settings.imageSizes.map((({name:e,slug:t})=>({label:e,value:t}))))),n||"conditional_logic"!==e.setting?.el||(e.setting.customAttributes={...e.setting.customAttributes,disableTags:["post_author.","post.tax_"],disableProps:["isSenderTag"]}),(0,_.createElement)(Mr,{...e})},Xr=e=>{const[t]=U("meta"),{editPost:n}=(0,P.useDispatch)("core/editor");return(0,_.createElement)(qr,{...e,saved:t?.campaign_data||{},setAttributes:e=>{const t=(0,P.select)("core/editor").getEditedPostAttribute("meta"),r={...t,campaign_data:{...t?.campaign_data,...e}};n({meta:r})}})};class Zr extends g().Component{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}render(){return this.state.hasError?(0,_.createElement)("div",null,(0,_.createElement)("div",{style:{backgroundColor:"#FEE2E2",border:"1px solid #F87171",color:"#B91C1C",padding:"0.75rem 1rem",borderRadius:"0.25rem",position:"relative"},role:"alert"},(0,_.createElement)(C.__experimentalText,{as:"strong",weight:500,color:"#B91C1C"},"Oops! Something went wrong.")," ",(0,_.createElement)(C.__experimentalText,{color:"#B91C1C"},"This error is being logged."),(0,_.createElement)("details",{style:{marginTop:"0.5rem",fontSize:"0.875rem"}},(0,_.createElement)("summary",null,"Click for error details"),(0,_.createElement)("pre",{style:{overflow:"auto",fontSize:"0.875rem",marginTop:"0.5rem"}},this.state.error&&this.state.error.toString(),(0,_.createElement)("br",null),this.state.errorInfo?.componentStack)))):this.props.children}}const Qr=Zr,Jr=()=>{const e=Y(),[t,n]=Or({heading:(0,T.__)("Set tags and categories","newsletter-optin-box"),helpText:(0,_.createElement)(_.Fragment,null,(0,T.__)("This email will send for all blog posts.","newsletter-optin-box"),(0,_.createElement)("br",null),(0,T.__)("A paid plan allows you to limit notifications to certain categories, tags, and authors.","newsletter-optin-box")),needsAddonsPack:!0,slug:"filter-posts"});return t||"latest_posts_digest"!==e?null:n};function ea(){return(0,_.createElement)(C.Flex,{align:"top",justify:"center"},(0,_.createElement)(C.FlexBlock,{style:{maxWidth:620,margin:32}},(0,_.createElement)(C.__experimentalVStack,{spacing:8},(0,_.createElement)(Xr,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,T.__)("Email Subject","newsletter-optin-box"),description:(0,T.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,_.createElement)(Xr,{settingKey:"heading",setting:{el:"input",type:"text",label:(0,T.__)("Email Heading","newsletter-optin-box"),description:(0,T.__)("This text will be displayed at the top of the email.","newsletter-optin-box")}}),(0,_.createElement)(Qr,null,(0,_.createElement)(Xr,{settingKey:"content_normal",setting:{el:"tinymce",label:(0,T.__)("Email Content","newsletter-optin-box"),description:(0,T.__)("The content of your email. You can use email tags to provide dynamic values.","newsletter-optin-box"),customAttributes:{id:"noptin-email-content__classic"}}})),(0,_.createElement)(Xr,{settingKey:"footer_text",setting:{el:"textarea",label:(0,T.__)("Footer Text","newsletter-optin-box"),description:(0,T.__)("This text will be displayed at the bottom of the email.","newsletter-optin-box")}}),(0,_.createElement)(Jr,null),(0,_.createElement)(dt,null))))}const ta=function({type:e,help:t,...n}){return(0,_.createElement)(C.Flex,{align:"top",justify:"center"},(0,_.createElement)(C.__experimentalVStack,{as:C.FlexBlock,spacing:8,style:{maxWidth:620,margin:32}},(0,_.createElement)(Xr,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,T.__)("Email Subject","newsletter-optin-box"),description:(0,T.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,_.createElement)(Xr,{settingKey:`content_${e}`,setting:{el:"textarea",className:`notin-edit-email-content__${e} noptin-field-control block-library-html__edit`,description:t,customAttributes:{autoGrow:!0},...n}}),(0,_.createElement)(Jr,null),(0,_.createElement)(dt,null)))},na=window.wp.blockEditor,ra=window.wp.blocks,aa=function(){const{replaceBlocks:e}=(0,P.useDispatch)(na.store),{getBlockName:t,getSelectedBlockClientId:n,getBlockAttributes:r}=(0,P.useSelect)(na.store),a=(a,o)=>{a.preventDefault();const l=0===o?"core/paragraph":"noptin/heading",i=n();if(null===i)return;const s=t(i);if("core/paragraph"!==s&&"noptin/heading"!==s)return;const c=r(i);e(i,(0,ra.createBlock)(l,{level:o,...c}))};return(0,st.useShortcut)("core/edit-email/transform-heading-to-paragraph",(e=>a(e,0))),[1,2,3,4,5,6].forEach((e=>{(0,st.useShortcut)(`core/edit-email/transform-paragraph-to-heading-${e}`,(t=>a(t,e)))})),null},oa="wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text",la=/[\r\n]+/g;function ia(e){const t=(0,_.useRef)(),n=(0,P.useSelect)((e=>e(A.store).isCleanNewPost()),[]);return(0,_.useImperativeHandle)(e,(()=>({focus:()=>{t?.current?.focus()}}))),(0,_.useEffect)((()=>{if(!t.current)return;const{defaultView:e}=t.current.ownerDocument,{name:r,parent:a}=e,o="editor-canvas"===r?a.document:e.document,{activeElement:l,body:i}=o;!n||l&&i!==l||t.current.focus()}),[n]),{ref:t}}const sa=(0,_.forwardRef)((function(e,t){const[n,r]=(0,_.useState)(!1),[a,o]=U("meta"),[l,i]=ee("subject",a,o),{ref:s}=ia(t),c=h(oa,{"is-selected":n,"is-raw-text":!0});return(0,_.createElement)(C.TextareaControl,{ref:s,value:l,onChange:function(e){i(e.replace(la," "))},onFocus:function(){r(!0)},onBlur:function(){r(!1)},label:(0,T.__)("Enter email subject"),className:c,placeholder:(0,T.__)("Enter email subject"),hideLabelFromVision:!0,autoComplete:"off",dir:"auto",rows:1,__nextHasNoMarginBottom:!0})})),ca=({children:e})=>{const t=Ir(),[n,r]=Or({heading:(0,T.__)("Block Editor","newsletter-optin-box"),helpText:(0,T.__)("A premium plan allows you to edit your emails using a drag and drop block editor.","newsletter-optin-box"),needsAddonsPack:!1,slug:"block-editor"}),a=h("content",{"is-premium-feature":!n});return(0,_.createElement)(_.Fragment,null,I.styles&&Object.keys(I.styles).map((e=>(0,_.createElement)("link",{key:e,rel:"stylesheet",id:`${e}-css`,href:I.styles[e]}))),(0,_.createElement)("style",{dangerouslySetInnerHTML:{__html:t}}),(0,_.createElement)("div",{className:a,id:"noptin-email-content"},n?e:r))};function ua(){const{switchEditorMode:e}=(0,P.useDispatch)(A.store),t=(0,_.useRef)();return(0,_.useEffect)((()=>{t?.current?.focus()})),(0,_.createElement)(ca,null,(0,_.createElement)("div",{className:"editor-text-editor"},(0,_.createElement)("div",{className:"editor-text-editor__toolbar"},(0,_.createElement)("h2",null,(0,T.__)("Editing code")),(0,_.createElement)(C.Button,{variant:"tertiary",onClick:()=>e("visual")},(0,T.__)("Exit code editor"))),(0,_.createElement)("div",{className:"editor-text-editor__body"},(0,_.createElement)(sa,{ref:t}),(0,_.createElement)(A.PostTextEditor,null))))}function pa(){const e=(0,P.useSelect)((e=>e(it).getPreviewDeviceType()),[]),t=(0,na.__experimentalUseResizeCanvas)(e),n=(0,na.__unstableUseTypingObserver)(),r={marginLeft:10,marginRight:10};return(0,d.useViewportMatch)("medium","<")&&(r.marginTop=48),(0,_.createElement)("div",{className:"editor-visual-editor"},(0,_.createElement)(na.BlockTools,{style:t,className:`edit-post-visual-editor__editor-canvas is-${e.toLowerCase()}-preview`},(0,_.createElement)(na.BlockCanvas,{height:"100%"},(0,_.createElement)(ca,null,(0,_.createElement)("div",{className:"editor-editor-canvas__post-title-wrapper",contentEditable:!1,ref:n,style:r},(0,_.createElement)(Zo,null)),(0,_.createElement)(Qr,null,(0,_.createElement)(na.BlockList,{className:"edit-post-editor-canvas__block-list"}))))))}const ma=function(){const e=(0,P.useSelect)((e=>{var t;return null!==(t=e(Ee.store).get("core","editorMode"))&&void 0!==t?t:"visual"}),[]);return(0,_.createElement)(_.Fragment,null,(0,_.createElement)(aa,null),"text"===e?(0,_.createElement)(ua,null):(0,_.createElement)(pa,null))},da=(0,_.memo)((function({mode:e}){return(0,_.createElement)(_.Fragment,null,"visual"===e&&(0,_.createElement)(ma,null),"normal"===e&&(0,_.createElement)(ea,null),"plain_text"===e&&(0,_.createElement)(ta,{type:"plain_text",label:(0,T.__)("Email Content","newsletter-optin-box"),placeholder:(0,T.__)("Type your email content here","newsletter-optin-box"),help:(0,T.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}),"raw_html"===e&&(0,_.createElement)(ta,{type:"raw_html",label:(0,T.__)("Email Content","newsletter-optin-box"),placeholder:(0,T.__)("Paste the raw HTML of your email here","newsletter-optin-box"),help:(0,T.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}))}));function _a(){const{emailType:e}=J();return(0,_.createElement)(Qr,null,(0,_.createElement)(da,{mode:e}))}const ga=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),fa=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),ha=e=>{e.preventDefault()},ba=(0,_.forwardRef)((function(e,t){const n=(0,bt.isAppleOS)()?bt.displayShortcut.primaryShift("`"):bt.displayShortcut.primary("`"),r=(0,P.useSelect)((e=>e(it).isInserterOpened()),[]),{setIsInserterOpened:a}=(0,P.useDispatch)(it);return(0,_.createElement)(C.Button,{...e,ref:t,className:"edit-post-header-toolbar__inserter-toggle",variant:"primary",isPressed:r,"aria-expanded":r,onMouseDown:ha,onClick:()=>a(!r),icon:fa +`,tr=({value:e,onChange:t,...n})=>{const{baseControlProps:r,controlProps:a}=(0,C.useBaseControlProps)(n),o=e?e.split(":"):["07","00"],[l,i]=(0,_.useState)(o[0]),[s,c]=(0,_.useState)(o[1]),u=(e,t="00")=>(e=Number(e),isNaN(e)?t:e<10?`0${e}`:e),p=`${u(l)}:${u(s)}`;return(0,_.useEffect)((()=>{e!==p&&t(p)}),[p]),(0,_.createElement)(C.BaseControl,{...r},(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)(er,null,(0,_.createElement)(Qn,{value:u(l),onChange:i,min:0,max:23,step:1,...a,label:(0,T.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Yn(2)}),(0,_.createElement)(Zn,{"aria-hidden":"true"},":"),(0,_.createElement)(Jn,{value:u(s),onChange:c,min:0,max:59,step:1,label:(0,T.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:Yn(2)})),(0,_.createElement)(Xn,null)))},nr=[{label:(0,T.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,T.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],rr=[{label:(0,T.__)("all","newsletter-optin-box"),value:"all"},{label:(0,T.__)("any","newsletter-optin-box"),value:"any"}];function ar(e,t){return(0,_.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function or({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:r}){const a=n>1;return(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,_.createElement)(C.SelectControl,{label:(0,T.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:nr,onChange:e=>r("action",e),size:"default",__nextHasNoMarginBottom:!0}),a&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.SelectControl,{label:(0,T.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:rr,onChange:e=>r("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,_.createElement)(C.__experimentalText,null,(0,T.__)("of the following rules are true:","newsletter-optin-box"))))}function lr({rule:e,comparisons:t,availableSmartTags:n,mergeTagsArray:r,index:a,updateRule:o,removeRule:l}){var i;const s=e=>o(a,{value:e}),c=null!==(i=e.full)&&void 0!==i?i:e.type?`[[${e.type}]]`:"",u=c.indexOf("]]"),p=c.indexOf("[[",u),m=-1===u||-1!==p&&p>u,d=e=>{const t={full:e};if(e){const n=e.match(/\[\[([^\s\]]+)/)?.[1]||"";n&&(t.type=n.replace("[[","").replace("]]",""))}o(a,t)},g=yr({availableSmartTags:r,onMergeTagClick:e=>{d(c?`${c} ${e}`.trim():e)}}),f=yr({availableSmartTags:r,onMergeTagClick:t=>{s(e.value?`${e.value} ${t}`.trim():t)}}),h=(0,_.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const r=t.replace("_",".",1);if(void 0!==n[r])return n[r];for(const[e,r]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return r;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(r.deprecated&&n(r.deprecated).includes(t))return r}return null}),[e.type,n]),b=ar((y=h?.options,(0,_.useMemo)((()=>y?Array.isArray(y)?y.map(((e,t)=>({label:e,value:t}))):Object.keys(y).map((e=>({label:y[e],value:e}))):[]),[y])),(0,T.__)("Select a value","newsletter-optin-box"));var y;const x=!m&&b.length>1,v=m?"string":h?.conditional_logic||"string",E=ar((0,_.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let r=t[n].type;if(x){if("string"===v&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==r&&r!=v||e.push({label:t[n].name,value:n})})),e}),[v,t]),(0,T.__)("Select a comparison","newsletter-optin-box")),w="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0,expanded:!0},(0,_.createElement)("div",{style:{minWidth:320}},(0,_.createElement)(C.__experimentalInputControl,{type:"text",label:(0,T.__)("Smart Tag","newsletter-optin-box"),hideLabelFromVision:!0,placeholder:(0,T.__)("Enter a smart tag","newsletter-optin-box"),value:c,onChange:d,autoComplete:"off",suffix:g,__next40pxDefaultSize:!0})),(0,_.createElement)("div",{style:{width:150}},(0,_.createElement)(C.SelectControl,{label:(0,T.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:E,onChange:e=>o(a,{condition:e}),size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})),!w&&(0,_.createElement)("div",{style:{minWidth:320}},x&&(0,_.createElement)(C.SelectControl,{label:(0,T.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:b,onChange:s,size:"default",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),!x&&(0,_.createElement)(C.__experimentalInputControl,{type:"number"===v?"number":"text",label:(0,T.__)("Value","newsletter-optin-box"),placeholder:(0,T.__)("Enter a value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:s,suffix:f,__next40pxDefaultSize:!0})),(0,_.createElement)(C.Button,{onClick:()=>l(a),icon:"trash",variant:"tertiary",isDestructive:!0}))}function ir({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:r,disableTags:a,disableProps:o,closeModal:l}){const i=(0,_.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[e]),s=(0,_.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic,isPremium:Array.isArray(a)&&a.some((e=>t.smart_tag.startsWith(e)))||Array.isArray(o)&&o.some((e=>!!t[e]))})})),e}),[n]),c=(0,_.useCallback)((e=>{const t=[...i];t.splice(e,1),r("rules",t)}),[i,r]),u=(0,_.useCallback)(((e,t)=>{const n=[...i];n[e]={...n[e],...t},r("rules",n)}),[i,r]),p=(0,_.useMemo)((()=>Object.values(s)),[s]),m=(0,_.useCallback)(((e,t)=>{const n=s[e],a=n?.options||[],o=n?.placeholder||"";let l=Array.isArray(a)&&a.length?Object.keys(a)[0]:o;n?.default&&(l=n.default);const c=[...i];c.push({type:e,condition:"is",full:t,value:l}),r("rules",c)}),[i]),d=0===i.length?(0,T.__)("Add a conditional logic rule","newsletter-optin-box"):(0,T.__)("Add another rule","newsletter-optin-box"),g=yr({availableSmartTags:p,onMergeTagClick:m,raw:!0,icon:"plus",label:d,text:d,toggleProps:{variant:"primary"}});return(0,_.createElement)(_.Fragment,null,i.map(((e,n)=>(0,_.createElement)(lr,{key:n,rule:e,index:n,updateRule:u,removeRule:c,comparisons:t,availableSmartTags:s,mergeTagsArray:p}))),(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},g,l&&(0,_.createElement)(C.Button,{onClick:l,variant:"secondary"},(0,T.__)("Return to editor","newsletter-optin-box"))))}function sr({onChange:e,value:t,comparisons:n,toggleText:r,availableSmartTags:a,className:o,inModal:l=!1,...i}){const[s,c]=(0,_.useState)(!1),u=(0,_.useMemo)((()=>"object"!=typeof t?{enabled:!1,action:"allow",rules:[],type:"all"}:t),[t]),p=(0,_.useCallback)(((t,n)=>{e({...u,[t]:n})}),[e,u]),m=(0,_.createElement)(C.__experimentalVStack,{spacing:5},(0,_.createElement)(or,{ruleCount:Array.isArray(u.rules)?u.rules.length:0,type:u.type,action:u.action,setConditionalLogicAttribute:p}),(0,_.createElement)(ir,{rules:u.rules,comparisons:n,availableSmartTags:a,setConditionalLogicAttribute:p,closeModal:l&&(()=>c(!1)),...i}));return(0,_.createElement)(C.__experimentalVStack,{spacing:5,className:o},(0,_.createElement)(C.ToggleControl,{checked:!!u.enabled,onChange:e=>p("enabled",e),label:r||(0,T.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),u.enabled&&(0,_.createElement)(_.Fragment,null,l?(0,_.createElement)(_.Fragment,null,s&&(0,_.createElement)(C.Modal,{title:(0,T.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>c(!1),isFullScreen:!0},m),(0,_.createElement)(C.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>c(!0)},(0,T.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,_.createElement)(_.Fragment,null,m)))}const cr={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>ee<=t,includes:(e,t)=>e.includes(t),"!includes":(e,t)=>!e.includes(t),"^includes":(e,t)=>t.includes(e),"^!includes":(e,t)=>!t.includes(e),empty:(e,t)=>!t,"!empty":(e,t)=>t},ur=(e,t,n)=>!!cr[t]&&cr[t](e,"boolean"==typeof e&&void 0===n?Boolean(n):n),pr=["number","search","email","password","tel","url","date"];function mr({setting:e,availableSmartTags:t,isPressEnterToChange:n,...r}){void 0===n&&(n=!0);const a=yr({availableSmartTags:t,onMergeTagClick:(0,_.useCallback)((e=>{r.onChange&&r.onChange(r.value?`${r.value} ${e}`.trim():e)}),[r.value,r.onChange])});return"string"==typeof r.suffix||r.suffix instanceof String?r.suffix=(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,r.suffix):e.disabled||!a||r.suffix||(r.suffix=a),"datetime-local"===e.type&&(r.suffix=(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,(0,_.createElement)(C.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:e,onToggle:t})=>(0,_.createElement)(C.Button,{onClick:t,"aria-expanded":e,icon:gt}),renderContent:()=>(0,_.createElement)(C.DateTimePicker,{currentDate:r.value,onChange:e=>{e&&(e=(0,yt.format)("c",e)),r.onChange(e||"")}})}))),e.disabled&&(r.readOnly=!0,r.onFocus=e=>e.target.select(),e.value&&(r.value=e.value)),("string"==typeof r.prefix||r.prefix instanceof String)&&(r.prefix=(0,_.createElement)(C.__experimentalInputControlPrefixWrapper,null,r.prefix)),(0,_.createElement)(C.__experimentalInputControl,{...r,type:pr.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function dr({value:e,onChange:t,...n}){const{baseControlProps:r,controlProps:a}=(0,C.useBaseControlProps)({...n});return(0,_.createElement)(C.BaseControl,{...r},(0,_.createElement)(C.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:t,onToggle:n})=>(0,_.createElement)(C.Button,{onClick:n,"aria-expanded":t},(0,_.createElement)(C.ColorIndicator,{colorValue:e})),renderContent:()=>(0,_.createElement)(C.ColorPicker,{color:e,onChange:t}),...a}))}function _r({availableSmartTags:e,autoGrow:t=!1,label:n,id:r,setting:a,...o}){const l=yr({availableSmartTags:e,onMergeTagClick:(0,_.useCallback)((e=>{o.onChange&&o.onChange(o.value?`${o.value} ${e}`.trim():e)}),[o.value,o.onChange]),toggleProps:{size:"small"}}),i=!a.disabled&&l?(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)("span",null,n),l):n,s=r||(0,d.useInstanceId)(_r,"noptin-textarea");return(0,_.useEffect)((()=>{if(t){const e=document.getElementById(s);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[o.value,t,s]),a.disabled&&(o.readOnly=!0,o.onFocus=e=>e.target.select(),a.value&&(o.value=a.value)),(0,_.createElement)(C.TextareaControl,{...o,id:s,label:i,__nextHasNoMarginBottom:!0})}function gr({options:e,...t}){return(0,_.createElement)(C.__experimentalToggleGroupControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,...t},e.map(((e,t)=>(0,_.createElement)(C.__experimentalToggleGroupControlOption,{key:t,...e}))))}function fr({options:e,...t}){const[n,r]=(0,_.useState)(e);return(0,_.createElement)(C.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{r(t?e.filter((e=>!e.disabled&&""!==e.value&&(e.search?e.search.toLowerCase():e.label.toLowerCase()).includes(t.toLowerCase()))):e)},__experimentalRenderItem:({item:e,...t})=>e.render?"string"==typeof e.render?(0,_.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function hr({options:e,value:t,onChange:n,...r}){const a=Array.isArray(t)?t:[],o=(0,_.useMemo)((()=>e.map((e=>e.label))),[e]),l=(0,_.useCallback)((e=>o.includes(e)),[o]),i=(0,_.useMemo)((()=>a.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),s=(0,_.useCallback)((t=>{const r=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&r.add(t.value)}n(Array.from(r))}),[n,e]),c=(0,_.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,_.createElement)(ce.RawHTML,null,n.render):(0,_.createElement)(_.Fragment,null,t.item)}),[e]);return(0,_.createElement)(C.FormTokenField,{value:i,suggestions:o,onChange:s,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:l,__experimentalRenderItem:c,...r})}const br=[{id:"key",label:(0,T.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,T.__)("Value","noptin-addons-pack"),type:"text"}];function yr({availableSmartTags:e=[],onMergeTagClick:t=((e,t)=>{}),raw:n=!1,icon:r="shortcode",label:a=(0,T.__)("Insert merge tag","newsletter-optin-box"),...o}){const l=ne(e),i=Object.keys(l).length;let s=null;return i>0&&(s=(0,_.createElement)(C.DropdownMenu,{icon:r,label:a,...o},(({onClose:e})=>(0,_.createElement)(_.Fragment,null,Object.keys(l).map(((r,a)=>(0,_.createElement)(C.MenuGroup,{label:i>1?r:void 0,key:a},l[r].map((r=>(0,_.createElement)(C.MenuItem,{icon:r.isPremium?ft:r.icon||ht,iconPosition:"left",disabled:r.isPremium,onClick:()=>{if(!r.isPremium){if(t){const e=n?r.smart_tag:`[[${xr(r)}]]`;t(e,`[[${xr(r)}]]`)}e()}},key:r.smart_tag},(0,_.createElement)(ce.RawHTML,null,r.isPremium?`${r.label} - Premium`:r.label))))))))))),s}function xr(e){return e.example?e.example:e.default?`${e.smart_tag} default="${e.default}"`:`${e.smart_tag}`}function vr({availableSmartTags:e,value:t,onChange:n,button:r,fields:a,openModal:o,prepend:l,disable:i,disabled:s,onDisable:c,cardProps:u,repeaterKey:p,id:m,defaultItem:g,...f}){const[h,b]=(0,_.useState)(!1),y=Array.isArray(t)?t:[],x=m||(0,d.useInstanceId)(vr,"noptin-repeater"),{baseControlProps:v,controlProps:E}=(0,C.useBaseControlProps)({...f,id:x}),w=g||{};if(p?.newOnly&&(w.new=!0),!a)return console.warn("No fields provided to repeater control."),null;Object.keys(a).forEach((e=>{void 0!==a[e].default&&(w[e]=a[e].default)}));const k=!!o,S=(e,t)=>e.key?e.key:p?.to&&Tr(e,p.to)?Tr(e,p.to):t,P=(0,_.createElement)(C.__experimentalVStack,null,l,y.map(((t,r)=>(0,_.createElement)(C.Card,{size:"small",className:"noptin-no-shadow",id:`${x}__item-${S(t,r)}`,"data-index":r,borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0,...u||{},key:S(t,r)},(0,_.createElement)(Er,{id:`${x}__item-${S(t,r)}`,fields:a,value:t,availableSmartTags:e,onChange:e=>{let t={...e};if(p?.to&&p.from&&Tr(t,p.from)&&(!p.newOnly||t.new)){const e=Tr(t,p.from).toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");t=Pr(t,p.to,e.substring(0,p.maxLength||64)),y.find(((e,n)=>r!==n&&Tr(e,p.to)===Tr(t,p.to)))&&(t=Pr(t,p.to,`${Tr(t,p.to)}_${r}`))}const a=[...y];a[r]=t,n(a)},onDelete:()=>{const e=[...y];e.splice(r,1),n(e)},onMoveUp:r>0?()=>{const e=[...y],t=e[r];e.splice(r,1),e.splice(r-1,0,t),n(e)}:null,onMoveDown:r{const e=[...y],t=e[r];e.splice(r,1),e.splice(r+1,0,t),n(e)}:null,repeaterKey:p})))),(0,_.createElement)(C.__experimentalHStack,null,(0,_.createElement)(C.Button,{onClick:()=>{const e=[...y],t=Date.now().toString(36),r=Math.random().toString(36).substring(2,8);e.push({key:`${t}_${r}`,...w}),n(e)},variant:"primary"},r||(0,T.__)("Add Item","newsletter-optin-box")),k&&(0,_.createElement)(C.Button,{onClick:()=>b(!1),variant:"secondary"},(0,T.__)("Go Back","newsletter-optin-box")))),M=!i||!s;return(0,_.createElement)(C.BaseControl,{...v},(0,_.createElement)("div",{...E},k&&(0,_.createElement)(C.__experimentalVStack,null,i&&(0,_.createElement)(C.ToggleControl,{label:i,checked:s,onChange:e=>{c&&c(e)}}),M&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.Button,{onClick:()=>b(!0),variant:"secondary"},o||(0,T.__)("Set Items","newsletter-optin-box")),h&&(0,_.createElement)(C.Modal,{title:f.label||o||(0,T.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>b(!1),size:"medium"},P))),!k&&P))}function Er({fields:e,availableSmartTags:t,value:n,onChange:r,repeaterKey:a,onDelete:o,onMoveUp:l,onMoveDown:i,id:s}){const[c,u]=(0,_.useState)(!a?.from),p=(0,_.useCallback)((()=>{u(!c)}),[c]),m=!c&&a?.from;let d=null;if(a){const e=!1!==a.display&&a.to&&n?.[a.to]?(0,_.createElement)("code",null,(0,T.sprintf)(a.display||"%s",n?.[a.to])):null,t={paddingLeft:16,paddingRight:16,height:48},r=Tr(n,a.from)||Tr(n,a.fallback);d=(0,_.createElement)(C.CardHeader,{style:{padding:0}},(0,_.createElement)(C.Flex,{as:C.Button,onClick:p,style:t,"aria-controls":`${s}__body`,"aria-expanded":!m,type:"button"},(0,_.createElement)(C.__experimentalHStack,{as:C.FlexBlock},(0,_.createElement)(C.__experimentalText,{weight:600},r||(0,T.__)("(new)","newsletter-optin-box"))),(0,_.createElement)(C.FlexItem,null,(0,_.createElement)(C.__experimentalHStack,null,e,(0,_.createElement)(C.Icon,{icon:c?"arrow-up-alt2":"arrow-down-alt2"})))))}return(0,_.createElement)(_.Fragment,null,d,!m&&(0,_.createElement)(C.CardBody,{id:`${s}__body`,hidden:m},(0,_.createElement)(C.__experimentalVStack,null,Object.keys(e).map((a=>(0,_.createElement)(Mr,{key:a,settingKey:a,availableSmartTags:t,setting:e[a],saved:n,setAttributes:e=>{r({...n,...e})}}))),(0,_.createElement)(C.__experimentalHStack,{className:"noptin-repeater-item__actions",justify:"flex-start"},!n?.predefined&&(0,_.createElement)(C.Button,{variant:"link",onClick:o,text:(0,T.__)("Remove Item","newsletter-optin-box"),isDestructive:!0}),l&&(0,_.createElement)(C.Button,{onClick:l,icon:"arrow-up-alt",text:(0,T.__)("Move Up","newsletter-optin-box"),size:"small",iconSize:16}),i&&(0,_.createElement)(C.Button,{onClick:i,icon:"arrow-down-alt",text:(0,T.__)("Move Down","newsletter-optin-box"),size:"small",iconSize:16})))))}function wr({setting:e,availableSmartTags:t,value:n,onChange:r,...a}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(a);Array.isArray(n)||(n=[]);const i=(0,_.useCallback)((({item:e,index:a})=>(0,_.createElement)(C.Flex,{className:"noptin-repeater-item",wrap:!0},br.map(((o,l)=>(0,_.createElement)(kr,{key:l,availableSmartTags:t,field:o,value:void 0===e[o.id]?"":e[o.id],onChange:e=>{const t=[...n];t[a][o.id]=e,r(t)}}))),(0,_.createElement)(C.FlexItem,null,(0,_.createElement)(C.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,T.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(a,1),r(e)},isDestructive:!0})))),[n,r]);return(0,_.createElement)(C.BaseControl,{...o},(0,_.createElement)("div",{...l},n.map(((e,t)=>(0,_.createElement)(i,{key:t,item:e,index:t}))),(0,_.createElement)(C.Button,{onClick:()=>{const e=[...n];e.push({}),r(e)},variant:"secondary"},e.add_field?e.add_field:(0,T.__)("Add","newsletter-optin-box"))))}function kr({field:e,availableSmartTags:t,value:n,onChange:r}){const a=yr({availableSmartTags:t,onMergeTagClick:(0,_.useCallback)((e=>{r&&r(n?`${n} ${e}`.trim():e)}),[n,r])});return(0,_.createElement)(C.FlexBlock,null,(0,_.createElement)(C.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,T.sprintf)((0,T.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:a,onChange:r,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Sr({setting:e,value:t,options:n,onChange:r,...a}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(a);return Array.isArray(t)||(t=[]),(0,_.createElement)(C.BaseControl,{...o},(0,_.createElement)("div",{...l},n.map(((e,n)=>(0,_.createElement)(C.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{r(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function Cr({value:e,onChange:t,id:n,...r}){const{baseControlProps:a,controlProps:o}=(0,C.useBaseControlProps)({...r,id:n,__nextHasNoMarginBottom:!0}),{wp:l,tinymce:i}=window,s=(0,_.useRef)(!1),c=(0,_.useRef)(null);return(0,_.useEffect)((()=>{if(!s.current)return;const t=t=>{t?.target?.classList?.contains("wp-switch-editor")&&setTimeout((()=>{const t=i?.get(n);t&&(t.setContent(e||""),t._lastChange=e)}),50)};return c.current?.addEventListener("click",t),()=>{c.current?.removeEventListener("click",t)}}),[c.current,e]),(0,_.useEffect)((()=>{if(!s.current)return;const e=i?.get(n);e&&e._lastChange}),[e]),(0,_.useEffect)((()=>{function r(){l.oldEditor.initialize(n,{tinymce:!!window.tinymce&&{content_css:!1,theme_advanced_buttons:"bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect",drag_drop_upload:!0,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,spellchecker,wp_adv,dfw",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",min_height:400,wpautop:!1,setup(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const r=(0,d.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",r),n.on("remove",r.cancel),n.on("keydown",(e=>{bt.isKeyboardEvent.primary(e,"z")&&e.stopPropagation(),bt.isKeyboardEvent.primary(e,"s")&&r.flush();const{altKey:t}=e;t&&e.keyCode===bt.F10&&e.stopPropagation()})),s.current=!0},...window?.tinyMCEPreInit?.mceInit[n]||{}},mediaButtons:!0,quicktags:{buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,close"}})}function a(){"complete"===document.readyState&&r()}return i?.execCommand("mceRemoveEditor",!0,n),"complete"===document.readyState?r():document.addEventListener("readystatechange",a),()=>{document.removeEventListener("readystatechange",a),l.oldEditor.remove(n)}}),[]),(0,_.createElement)(C.BaseControl,{...a},(0,_.createElement)("div",{ref:c},(0,_.createElement)("textarea",{...o,className:"wp-editor-area",style:{width:"100%"},value:e,onChange:e=>t(e.target.value),rows:10})))}const Tr=(e,t)=>{if(!t||0===t.length)return;if("string"==typeof t&&(t=t.split(".")),0===t.length||!e||"object"!=typeof e)return;const[n,...r]=t;return 0===r.length?e[n]:Tr(e[n],r)},Pr=(e,t,n)=>{if(!t||0===t.length)return e;"string"==typeof t&&(t=t.split("."));const[r,...a]=t;return 0===a.length?{...e,[r]:n}:{...e,[r]:Pr(e[r]||{},a,n)}};function Mr({settingKey:e,setting:t,availableSmartTags:n,prop:r,saved:a,setAttributes:o}){const l=(r?`${r}.${e}`:e).split("."),i=t.sanitize?t.sanitize:e=>e,s=(0,_.useCallback)((e=>{if(Tr(a,l)===e)return;const[t,...n]=l;return 0===n.length?o(i({[t]:e})):o(i({[t]:Pr(a[t]||{},n,e)}))}),[a,l,o,i]);if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!Tr(a,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return ur(e.value,n,Tr(a,t))})))return null;if(t.condition&&!t.condition(a))return null;let c=Tr(a,l);(void 0===c||t.disabled)&&(c=t.default);const u=void 0!==c&&""!==c&&null!==c;let p=[];t.options&&(p=Array.isArray(t.options)?[...t.options]:Object.keys(t.options).map((e=>({label:t.options?.[e],value:e}))));const m=`noptin-component__field-${e}`,d="string"==typeof t.description?(0,_.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,g=t.customAttributes?t.customAttributes:{},f={label:t.label,value:u?c:"",onChange:s,className:m,help:d,...g};if(t.tooltip&&(f.label=(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start"},(0,_.createElement)("span",null,t.label),(0,_.createElement)(C.Tooltip,{delay:0,placement:"top",text:t.tooltip},(0,_.createElement)("span",null,(0,_.createElement)(C.Icon,{icon:"info",style:{color:"#454545"}}))))),t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color","image"].includes(t.type)&&(t.el="input")),"button"===t.el)return(0,_.createElement)("div",null,(0,_.createElement)(C.Button,{...t.buttonProps||{}}));if("toggle_group"===t.el)return(0,_.createElement)(gr,{...f,options:p});if("select"===t.el)return t.multiple?(0,_.createElement)(hr,{...f,options:p}):(p.find((e=>""===e?.value))||p.unshift({label:t.placeholder?t.placeholder:(0,T.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,_.createElement)(C.SelectControl,{...f,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return p.unshift({label:t.placeholder?t.placeholder:(0,T.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,_.createElement)(fr,{...f,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,_.createElement)(C.FormTokenField,{...f,value:Array.isArray(f.value)?f.value:[],suggestions:Array.isArray(t.suggestions)?t.suggestions:[],__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,tokenizeOnBlur:!0});if("multi_checkbox"===t.el||"multi_checkbox_alt"===t.el)return(0,_.createElement)(Sr,{...f,options:p});if("conditional_logic"===t.el)return(0,_.createElement)(sr,{...f,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,_.createElement)(tr,{...f});if("color"===t.el||"input"===t.el&&"color"===t.type)return(0,_.createElement)(dr,{...f,__nextHasNoMarginBottom:!0});if("unit"===t.el)return(0,_.createElement)(C.__experimentalUnitControl,{labelPosition:"edge",__unstableInputWidth:"80px",__next40pxDefaultSize:!0,isPressEnterToChange:!0,...f});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,_.createElement)(C.ToggleControl,{...f,checked:!!u&&c});if("number"===t.type){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,_.createElement)(C.__experimentalInputControlSuffixWrapper,null,e):e},n=e=>{if(e)return"string"==typeof e||e instanceof String?(0,_.createElement)(C.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(f.suffix)?f.suffix=e(1===c||"1"===c?f.suffix[0]:f.suffix[1]):f.suffix=e(f.suffix),Array.isArray(f.prefix)?f.prefix=n(1===c||"1"===c?f.prefix[0]:f.prefix[1]):f.prefix=n(f.prefix),(0,_.createElement)(C.__experimentalNumberControl,{...f,placeholder:t.placeholder?t.placeholder:"",__next40pxDefaultSize:!0})}return"image"===t.type&&(f.suffix=(0,_.createElement)(C.Button,{onClick:()=>{var e=window.wp.media({title:(0,T.__)("Upload Image","newsletter-optin-box"),multiple:!1,library:{type:"image"}}).open().on("select",(t=>{let n=e.state().get("selection").first();s(n.toJSON().sizes.full.url)}))},icon:"upload",label:(0,T.__)("Upload Image","newsletter-optin-box"),showTooltip:!0})),(0,_.createElement)(mr,{...f,setting:t,availableSmartTags:"trigger_settings"===r?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,_.createElement)(_r,{...f,setting:t,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===r?[]:n}):"tinymce"===t.el?(0,_.createElement)(Cr,{...f}):"paragraph"===t.el?(0,_.createElement)("div",{className:m},(0,_.createElement)(C.Tip,null,t.raw?(0,_.createElement)(ce.RawHTML,null,t.content):t.content)):"hero"===t.el?(0,_.createElement)("div",{className:m},(0,_.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,_.createElement)(wr,{...f,setting:t,availableSmartTags:"trigger_settings"===r?[]:n}):"repeater"===t.el?(0,_.createElement)(vr,{...f,availableSmartTags:"trigger_settings"===r?[]:n}):(console.log(t),e)}function Ar({onError:e=(e=>e),...t}){(0,m.uploadMedia)({onError:({message:t})=>e(t),wpAllowedMimeTypes:I?.wpAllowedMimeTypes,...t})}const Nr=function(e){const{preferredStyleVariations:t}=(0,P.useSelect)((e=>({preferredStyleVariations:e(Ee.store).get(N,"preferredStyleVariations")})),[]),{updatePreferredStyleVariations:n}=(0,P.useDispatch)(it);return(0,_.useMemo)((()=>({...I?.settings,...e,allowRightClickOverrides:!0,mediaUpload:I?.user?.canUpload?Ar:void 0,__experimentalFetchLinkSuggestions:(t,n)=>(0,M.__experimentalFetchLinkSuggestions)(t,n,e),__experimentalFetchRichUrlData:M.__experimentalFetchUrlData,__experimentalPreferredStyleVariations:{value:t,onChange:n}})),[e,t,n])},Ir=function(){const[e]=U("meta"),t=e?.campaign_data||{},n=t.background_color,r=t.background_image,a=t.font_family,o=t.font_size,l=t.font_style,i=t.font_weight,s=t.line_height,c=t.color,u=t.link_color,p=t.button_color,m=t.button_background,d=t.custom_css,g=t.block_css;return(0,_.useMemo)((()=>`\n\t\t\t\t.block-editor-iframe__body.editor-styles-wrapper {\n\t\t\t\t\tbackground-color: ${n||"#ffffff"};\n\t\t\t\t\tfont-family: ${a||"Arial, Helvetica, sans-serif"};\n\t\t\t\t\tfont-size: ${o||"14px"};\n\t\t\t\t\tfont-style: ${l||"normal"};\n\t\t\t\t\tfont-weight: ${i||"normal"};\n\t\t\t\t\tline-height: ${s||"1.5"};\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t${r?.url?`background-image: url(${r.url});`:""}\n\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\tbackground-repeat: no-repeat;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content.is-premium-feature {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\talign-items: center;\n\t\t\t\t\tjustify-content: center;\n\t\t\t\t\tpadding: 20px;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content.is-premium-feature .noptin-premium-feature {\n\t\t\t\t\tmax-width: 600px;\n\t\t\t\t}\n\t\t\t\t.content {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tmax-width: 100%;\n\t\t\t\t\tcolor: ${c||"#111111"};\n\t\t\t\t\tpadding: 0;\n\t\t\t\t\toverflow: auto;\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t}\n\t\t\t\t.content * {\n\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t}\n\t\t\t\t.content .block-editor-button-block-appender {\n\t\t\t\t\tcolor: currentColor;\n\t\t\t\t\tbox-shadow: inset 0 0 0 1px currentColor;\n\t\t\t\t}\n\t\t\t\t.wp-block-noptin-group {\n\t\t\t\t\tbackground-image: none !important;\n\t\t\t\t}\n\t\t\t\t.noptin-record {\n\t\t\t\t\tmin-height: 20px;\n\t\t\t\t\tmargin: 10px;\n\t\t\t\t\tpadding: 0;\n\t\t\t\t}\n\t\t\t\tdiv,\n\t\t\t\tol,\n\t\t\t\tul,\n\t\t\t\tp {\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t}\n\t\t\t\tp, h1, h2, h3, h4, h5, h6, .noptin-block__margin-wrapper {\n\t\t\t\t\tmargin: 0px 10px 16px;\n\t\t\t\t}\n\t\t\t\t.noptin-records__wrapper,\n\t\t\t\t.wp-block-noptin-separator {\n\t\t\t\t\tmargin-bottom: 16px;\n\t\t\t\t}\n\t\t\t\t.noptin-button-link {\n\t\t\t\t\tpadding-top: 10px;\n\t\t\t\t\tpadding-right: 25px;\n\t\t\t\t\tpadding-bottom: 10px;\n\t\t\t\t\tpadding-left: 25px;\n\t\t\t\t}\n\t\t\t\th1 {\n\t\t\t\t\tfont-size: 2em;\n\t\t\t\t\tline-height: 48px;\n\t\t\t\t}\n\t\t\t\th2{\n\t\t\t\t\tfont-size: 1.75em;\n\t\t\t\t\tline-height: 36px;\n\t\t\t\t}\n\n\t\t\t\th3 {\n\t\t\t\t\tfont-size: 1.5em;\n\t\t\t\t\tline-height: 30px;\n\t\t\t\t}\n\n\t\t\t\th4 {\n\t\t\t\t\tfont-size: 1.25em;\n\t\t\t\t\tline-height: 26px;\n\t\t\t\t}\n\n\t\t\t\th5 {\n\t\t\t\t\tfont-size: 1.125em;\n\t\t\t\t\tline-height: 22px;\n\t\t\t\t}\n\t\t\t\th6 {\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t\tline-height: 20px;\n\t\t\t\t}\n\t\t\t\timg, figure {\n\t\t\t\t\theight: auto;\n\t\t\t\t\tline-height: 100%;\n\t\t\t\t\ttext-decoration: none;\n\t\t\t\t\tborder: 0;\n\t\t\t\t\toutline: none;\n\t\t\t\t\tmax-width: 100%;\n\t\t\t\t}\n\t\t\t\t.content a {\n\t\t\t\t\tcolor: ${u||"#1a82e2"};\n\t\t\t\t\ttext-decoration: none;\n\t\t\t\t}\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:hover,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:focus,\n\t\t\t\t#noptin-email-content .noptin-button-link__wrapper .noptin-button-link:active {\n\t\t\t\t\tcolor: ${p||"#fff"};\n\t\t\t\t}\n\t\t\t\t.block-editor-default-block-appender__content {\n\t\t\t\t\tmargin-left: 10px;\n\t\t\t\t\tmargin-right: 10px;\n\t\t\t\t}\n\t\t\t\t.noptin-button-link__wrapper {\n\t\t\t\t\tbackground-color: ${m||"#1a82e2"};\n\t\t\t\t\tcolor: ${p||"#fff"};\n\t\t\t\t}\n\n\t\t\t\t.noptin-columns {\n\t\t\t\t\tdisplay: table;\n\t\t\t\t\ttable-layout: fixed;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t}\n\n\t\t\t\t.noptin-column {\n\t\t\t\t\tdisplay: table-cell;\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t}\n\n\t\t\t\t.noptin-column__inner {\n\t\t\t\t\tpadding: 10px;\n\t\t\t\t\tmargin-left: 10px;\n\t\t\t\t\tmargin-right: 10px;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper {\n\t\t\t\t\tborder-spacing: 0;\n\t\t\t\t\tborder-collapse: collapse;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper:not(.noptin-image-block__wrapper-is-aligned) {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper img {\n\t\t\t\t\tvertical-align: bottom;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-image-block__wrapper div {\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-button-block__wrapper {\n\t\t\t\t\tborder-collapse: separate;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tline-height: 100%;\n\t\t\t\t}\n\n\t\t\t\ttable.noptin-button-block__wrapper table {\n\t\t\t\t\tborder-collapse: separate;\n\t\t\t\t}\n\n\t\t\t\t@media only screen and (max-width: 360px) {\n\t\t\t\t\t.noptin-is-stacked-on-mobile {\n\t\t\t\t\t\tdisplay: block !important;\n\t\t\t\t\t}\n\n\t\t\t\t\t.noptin-is-stacked-on-mobile.noptin-column {\n\t\t\t\t\t\tvertical-align: top !important;\n\t\t\t\t\t\twidth: 100% !important;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t${g?Object.values(g).join("\n"):""}\n\t\t\t\t${d||""}\n\n\t\t\t\t.block-editor-url-popover__settings > .components-h-stack .components-toggle-control:first-child {\n\t\t\t\t\tdisplay: none;\n\t\t\t\t}\n\t\t\t\t.wp-block-noptin-group {\n\t\t\t\t\tmargin-left: auto;\n\t\t\t\t\tmargin-right: auto;\n\t\t\t\t\tmargin-top: 20px;\n\t\t\t\t\tmargin-bottom: 20px;\n\t\t\t\t}\n\t\t\t\t.noptin-block-group__inner {\n\t\t\t\t\tpadding-top: 20px;\n\t\t\t\t\tpadding-bottom: 20px;\n\t\t\t\t}\n\t\t\t\ttable, td {\n\t\t\t\t\tborder-collapse: collapse;\n\t\t\t\t}\n\t\t\t`),[c,u,p,m,n,r,a,o,l,i,s,d,g])},Br=B.license||{},Fr=Br.is_usable&&Br.key,Or=({heading:e,helpText:t,needsAddonsPack:n,slug:r})=>{if(Lr(n))return[!0,null];const a=n&&Br.install_desc||(0,T.__)("Activate your license key to unlock","newsletter-optin-box"),o=n&&Br.install_text||(0,T.__)("View Pricing","newsletter-optin-box");let l=n&&Br.install_url||Br.upgrade_url||"https://noptin.com/pricing/";return Br.key||(l=(0,v.addQueryArgs)(l,{utm_source:r,utm_campaign:"emails"})),[!1,(0,_.createElement)(C.Placeholder,{icon:ft,label:e||(0,T.__)("Premium Feature","newsletter-optin-box"),className:"noptin-premium-feature"},(0,_.createElement)(C.__experimentalVStack,{spacing:4},t&&(0,_.createElement)("div",null,t),(0,_.createElement)("div",null,a),(0,_.createElement)(C.__experimentalHStack,{justify:"start",wrap:!0},!Br.key&&(0,_.createElement)(C.Button,{href:Br.activate_url,variant:"secondary",target:"_blank",text:(0,T.__)("Activate license","newsletter-optin-box"),style:{margin:0}}),(0,_.createElement)(C.Button,{href:l,variant:"primary",target:"_blank",text:o,style:{margin:0}}))))]},Lr=e=>(!e||Br.is_usable)&&Br.key,jr=/_published|_unpublished|_deleted|_user_role$/,Rr=["noptin_subscriber_","delete_user","new_user","update_user","wp_login","after_password_reset","create_or_update_"],Dr=[["woocommerce","subscription"],["latest_","_digest"]],zr=["WordPress Users"],Vr=["latest_posts_digest"],$r=["periodic"],Hr=(e,t=void 0)=>{if(!e||Vr.includes(e))return!1;if($r.includes(e))return!0;if(t&&zr.includes(t))return!0;if(Dr.some((t=>t.every((t=>e.includes(t))))))return!0;const n=e.replace(/^automation_rule_/,"");return jr.test(n)?"post_published"!==n:Rr.some((e=>n.startsWith(e)))};function Gr(e,t,n=500){const[r,a]=(0,_.useState)(e),o=(0,_.useRef)(t);return(0,_.useEffect)((()=>{o.current=t}),[t]),(0,_.useEffect)((()=>{const t=setTimeout((()=>{r!==e&&o.current(r)}),n);return()=>clearTimeout(t)}),[r,n,e]),{value:r,onChange:a}}const Ur=()=>{const e=(0,P.useSelect)((e=>e(M.store).getPostTypes({per_page:100})),[]);return(0,_.useMemo)((()=>{const t=["attachment"];return e?.filter((({viewable:e,slug:n})=>e&&!t.includes(n)))}),[e])},Kr=e=>(0,P.useSelect)((t=>{const{getTaxonomies:n}=t(M.store);return n({type:e,per_page:-1,context:"view"})}),[e]),Wr=()=>window.noptinEmailEditorSettings.settings?.__experimentalFeatures?.color?.palette?.theme||[],Yr=e=>{const t=(0,P.useSelect)((t=>t(Ve).isModalActive(e)),[e]),{openModal:n,closeModal:r}=(0,P.useDispatch)(Ve);return(0,_.useMemo)((()=>({openModal:()=>n(e),closeModal:r,toggleModal:()=>t?r():n(e),isModalActive:t})),[n,r,t,e])},qr=({...e})=>{const t=ae(),n=Lr(!1);return e.disableMergeTags||(e.availableSmartTags=t),"image_size_select"===e.setting?.el&&(e.setting.el="select",Array.isArray(I.settings?.imageSizes)&&(e.setting.options=I.settings.imageSizes.map((({name:e,slug:t})=>({label:e,value:t}))))),n||"conditional_logic"!==e.setting?.el||(e.setting.customAttributes={...e.setting.customAttributes,disableTags:["post_author.","post.tax_"],disableProps:["isSenderTag"]}),(0,_.createElement)(Mr,{...e})},Xr=e=>{const[t]=U("meta"),{editPost:n}=(0,P.useDispatch)("core/editor");return(0,_.createElement)(qr,{...e,saved:t?.campaign_data||{},setAttributes:e=>{const t=(0,P.select)("core/editor").getEditedPostAttribute("meta"),r={...t,campaign_data:{...t?.campaign_data,...e}};n({meta:r})}})};class Zr extends g().Component{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}render(){return this.state.hasError?(0,_.createElement)("div",null,(0,_.createElement)("div",{style:{backgroundColor:"#FEE2E2",border:"1px solid #F87171",color:"#B91C1C",padding:"0.75rem 1rem",borderRadius:"0.25rem",position:"relative"},role:"alert"},(0,_.createElement)(C.__experimentalText,{as:"strong",weight:500,color:"#B91C1C"},"Oops! Something went wrong.")," ",(0,_.createElement)(C.__experimentalText,{color:"#B91C1C"},"This error is being logged."),(0,_.createElement)("details",{style:{marginTop:"0.5rem",fontSize:"0.875rem"}},(0,_.createElement)("summary",null,"Click for error details"),(0,_.createElement)("pre",{style:{overflow:"auto",fontSize:"0.875rem",marginTop:"0.5rem"}},this.state.error&&this.state.error.toString(),(0,_.createElement)("br",null),this.state.errorInfo?.componentStack)))):this.props.children}}const Qr=Zr,Jr=()=>{const e=Y(),[t,n]=Or({heading:(0,T.__)("Set tags and categories","newsletter-optin-box"),helpText:(0,_.createElement)(_.Fragment,null,(0,T.__)("This email will send for all blog posts.","newsletter-optin-box"),(0,_.createElement)("br",null),(0,T.__)("A paid plan allows you to limit notifications to certain categories, tags, and authors.","newsletter-optin-box")),needsAddonsPack:!0,slug:"filter-posts"});return t||"latest_posts_digest"!==e?null:n};function ea(){return(0,_.createElement)(C.Flex,{align:"top",justify:"center"},(0,_.createElement)(C.FlexBlock,{style:{maxWidth:620,margin:32}},(0,_.createElement)(C.__experimentalVStack,{spacing:8},(0,_.createElement)(Xr,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,T.__)("Email Subject","newsletter-optin-box"),description:(0,T.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,_.createElement)(Xr,{settingKey:"heading",setting:{el:"input",type:"text",label:(0,T.__)("Email Heading","newsletter-optin-box"),description:(0,T.__)("This text will be displayed at the top of the email.","newsletter-optin-box")}}),(0,_.createElement)(Qr,null,(0,_.createElement)(Xr,{settingKey:"content_normal",setting:{el:"tinymce",label:(0,T.__)("Email Content","newsletter-optin-box"),description:(0,T.__)("The content of your email. You can use email tags to provide dynamic values.","newsletter-optin-box"),customAttributes:{id:"noptin-email-content__classic"}}})),(0,_.createElement)(Xr,{settingKey:"footer_text",setting:{el:"textarea",label:(0,T.__)("Footer Text","newsletter-optin-box"),description:(0,T.__)("This text will be displayed at the bottom of the email.","newsletter-optin-box")}}),(0,_.createElement)(Jr,null),(0,_.createElement)(dt,null))))}const ta=function({type:e,help:t,...n}){return(0,_.createElement)(C.Flex,{align:"top",justify:"center"},(0,_.createElement)(C.__experimentalVStack,{as:C.FlexBlock,spacing:8,style:{maxWidth:620,margin:32}},(0,_.createElement)(Xr,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,T.__)("Email Subject","newsletter-optin-box"),description:(0,T.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,_.createElement)(Xr,{settingKey:`content_${e}`,setting:{el:"textarea",className:`notin-edit-email-content__${e} noptin-field-control block-library-html__edit`,description:t,customAttributes:{autoGrow:!0},...n}}),(0,_.createElement)(Jr,null),(0,_.createElement)(dt,null)))},na=window.wp.blockEditor,ra=window.wp.blocks,aa=function(){const{replaceBlocks:e}=(0,P.useDispatch)(na.store),{getBlockName:t,getSelectedBlockClientId:n,getBlockAttributes:r}=(0,P.useSelect)(na.store),a=(a,o)=>{a.preventDefault();const l=0===o?"core/paragraph":"noptin/heading",i=n();if(null===i)return;const s=t(i);if("core/paragraph"!==s&&"noptin/heading"!==s)return;const c=r(i);e(i,(0,ra.createBlock)(l,{level:o,...c}))};return(0,st.useShortcut)("core/edit-email/transform-heading-to-paragraph",(e=>a(e,0))),[1,2,3,4,5,6].forEach((e=>{(0,st.useShortcut)(`core/edit-email/transform-paragraph-to-heading-${e}`,(t=>a(t,e)))})),null},oa="wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text",la=/[\r\n]+/g;function ia(e){const t=(0,_.useRef)(),n=(0,P.useSelect)((e=>e(A.store).isCleanNewPost()),[]);return(0,_.useImperativeHandle)(e,(()=>({focus:()=>{t?.current?.focus()}}))),(0,_.useEffect)((()=>{if(!t.current)return;const{defaultView:e}=t.current.ownerDocument,{name:r,parent:a}=e,o="editor-canvas"===r?a.document:e.document,{activeElement:l,body:i}=o;!n||l&&i!==l||t.current.focus()}),[n]),{ref:t}}const sa=(0,_.forwardRef)((function(e,t){const[n,r]=(0,_.useState)(!1),[a,o]=U("meta"),[l,i]=ee("subject",a,o),{ref:s}=ia(t),c=h(oa,{"is-selected":n,"is-raw-text":!0});return(0,_.createElement)(C.TextareaControl,{ref:s,value:l,onChange:function(e){i(e.replace(la," "))},onFocus:function(){r(!0)},onBlur:function(){r(!1)},label:(0,T.__)("Enter email subject"),className:c,placeholder:(0,T.__)("Enter email subject"),hideLabelFromVision:!0,autoComplete:"off",dir:"auto",rows:1,__nextHasNoMarginBottom:!0})})),ca=({children:e})=>{const t=Ir(),[n,r]=Or({heading:(0,T.__)("Block Editor","newsletter-optin-box"),helpText:(0,T.__)("A premium plan allows you to edit your emails using a drag and drop block editor.","newsletter-optin-box"),needsAddonsPack:!1,slug:"block-editor"}),a=h("content",{"is-premium-feature":!n});return(0,_.createElement)(_.Fragment,null,I.styles&&Object.keys(I.styles).map((e=>(0,_.createElement)("link",{key:e,rel:"stylesheet",id:`${e}-css`,href:I.styles[e]}))),(0,_.createElement)("style",{dangerouslySetInnerHTML:{__html:t}}),(0,_.createElement)("div",{className:a,id:"noptin-email-content"},n?e:r))};function ua(){const{switchEditorMode:e}=(0,P.useDispatch)(A.store),t=(0,_.useRef)();return(0,_.useEffect)((()=>{t?.current?.focus()})),(0,_.createElement)(ca,null,(0,_.createElement)("div",{className:"editor-text-editor"},(0,_.createElement)("div",{className:"editor-text-editor__toolbar"},(0,_.createElement)("h2",null,(0,T.__)("Editing code")),(0,_.createElement)(C.Button,{variant:"tertiary",onClick:()=>e("visual")},(0,T.__)("Exit code editor"))),(0,_.createElement)("div",{className:"editor-text-editor__body"},(0,_.createElement)(sa,{ref:t}),(0,_.createElement)(A.PostTextEditor,null))))}function pa(){const e=(0,P.useSelect)((e=>e(it).getPreviewDeviceType()),[]),t=(0,na.__experimentalUseResizeCanvas)(e),n=(0,na.__unstableUseTypingObserver)(),r={marginLeft:10,marginRight:10};return(0,d.useViewportMatch)("medium","<")&&(r.marginTop=48),(0,_.createElement)("div",{className:"editor-visual-editor"},(0,_.createElement)(na.BlockTools,{style:t,className:`edit-post-visual-editor__editor-canvas is-${e.toLowerCase()}-preview`},(0,_.createElement)(na.BlockCanvas,{height:"100%"},(0,_.createElement)(ca,null,(0,_.createElement)("div",{className:"editor-editor-canvas__post-title-wrapper",contentEditable:!1,ref:n,style:r},(0,_.createElement)(Zo,null)),(0,_.createElement)(Qr,null,(0,_.createElement)(na.BlockList,{className:"edit-post-editor-canvas__block-list"}))))))}const ma=function(){const e=(0,P.useSelect)((e=>{var t;return null!==(t=e(Ee.store).get("core","editorMode"))&&void 0!==t?t:"visual"}),[]);return(0,_.createElement)(_.Fragment,null,(0,_.createElement)(aa,null),"text"===e?(0,_.createElement)(ua,null):(0,_.createElement)(pa,null))},da=(0,_.memo)((function({mode:e}){return(0,_.createElement)(_.Fragment,null,"visual"===e&&(0,_.createElement)(ma,null),"normal"===e&&(0,_.createElement)(ea,null),"plain_text"===e&&(0,_.createElement)(ta,{type:"plain_text",label:(0,T.__)("Email Content","newsletter-optin-box"),placeholder:(0,T.__)("Type your email content here","newsletter-optin-box"),help:(0,T.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}),"raw_html"===e&&(0,_.createElement)(ta,{type:"raw_html",label:(0,T.__)("Email Content","newsletter-optin-box"),placeholder:(0,T.__)("Paste the raw HTML of your email here","newsletter-optin-box"),help:(0,T.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}))}));function _a(){const{emailType:e}=J();return(0,_.createElement)(Qr,null,(0,_.createElement)(da,{mode:e}))}const ga=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),fa=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),ha=e=>{e.preventDefault()},ba=(0,_.forwardRef)((function(e,t){const n=(0,bt.isAppleOS)()?bt.displayShortcut.primaryShift("`"):bt.displayShortcut.primary("`"),r=(0,P.useSelect)((e=>e(it).isInserterOpened()),[]),{setIsInserterOpened:a}=(0,P.useDispatch)(it);return(0,_.createElement)(C.Button,{...e,ref:t,className:"edit-post-header-toolbar__inserter-toggle",variant:"primary",isPressed:r,"aria-expanded":r,onMouseDown:ha,onClick:()=>a(!r),icon:fa /* translators: button label text should, if possible, be under 16 characters. */,label:(0,T.__)("Toggle block inserter"),shortcut:n,showTooltip:!0})})),ya=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z"})});function xa({isCollapsed:e,onToggle:t}){const{blockSelectionStart:n}=(0,P.useSelect)((e=>({blockSelectionStart:e(na.store).getBlockSelectionStart()})),[]),r=function(){const{isToolbarEnabled:e,isBlockDisabled:t}=(0,P.useSelect)((e=>{const{getBlockEditingMode:t,getBlockName:n,getBlockSelectionStart:r}=e(na.store),a=r(),o=a&&(0,ra.getBlockType)(n(a));return{isToolbarEnabled:o&&(0,ra.hasBlockSupport)(o,"__experimentalToolbar",!0),isBlockDisabled:"disabled"===t(a)}}),[]);return!(!e||t)}(),a=!!n;return(0,_.useEffect)((()=>{n&&t(!1)}),[n,t]),r?(0,_.createElement)(_.Fragment,null,(0,_.createElement)("div",{className:h("editor-collapsible-block-toolbar",{"is-collapsed":e||!a})},(0,_.createElement)(na.BlockToolbar,{hideDragHandle:!0})),(0,_.createElement)(C.Popover.Slot,{name:"block-toolbar"}),(0,_.createElement)(C.Button,{className:"editor-collapsible-block-toolbar__toggle",icon:e?ht:ya,onClick:()=>{t(!e)},label:e?(0,T.__)("Show block tools"):(0,T.__)("Hide block tools"),size:"compact"})):null}const va=function({contentType:e,hideActions:t}){const n=(0,T.sprintf)(/* translators: %s: content type label. */ /* translators: %s: content type label. */ (0,T.__)("%s Email"),O[e]?.label||""),{hasFixedToolbar:r}=(0,P.useSelect)((e=>{const{get:t}=e(Ee.store);return{hasFixedToolbar:t("core","fixedToolbar")}}),[]),[a,o]=(0,_.useState)(!0);return(0,_.createElement)(na.NavigableToolbar,{className:"edit-post-header-toolbar editor-document-tools","aria-label":(0,T.__)("Email tools"),shouldUseKeyboardFocusShortcut:!0,variant:"unstyled"},(0,_.createElement)("div",{className:"edit-post-header-toolbar__left editor-document-tools__left"},t?" ":(0,_.createElement)(_.Fragment,null,"visual"===e&&(0,_.createElement)(mt,{breakpoint:"large"},(0,_.createElement)(C.ToolbarItem,{as:ba})),(0,_.createElement)(C.ToolbarItem,{as:A.EditorHistoryUndo,size:"compact"}),(0,_.createElement)(C.ToolbarItem,{as:A.EditorHistoryRedo,size:"compact"}),"visual"!==e&&(0,_.createElement)(C.__experimentalText,{className:"edit-post-header-toolbar__title",as:"span",size:14,weight:500,numberOfLines:1,truncate:!0,upperCase:!0},n),"visual"===e&&(0,_.createElement)(mt,{breakpoint:"large"},(0,_.createElement)("div",{className:"editor-header__toolbar"},r&&(0,_.createElement)(xa,{isCollapsed:a,onToggle:o}))))))},Ea=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})}),wa=function(){const[e,t]=U("meta");return(0,_.createElement)(C.MenuGroup,{label:(0,T.__)("Editor")},(0,_.createElement)(C.MenuItemsChoice,{choices:L,value:e?.campaign_data?.email_type,onSelect:n=>{t({...e,campaign_data:Q({...e?.campaign_data||{},email_type:n})})}}))},ka=[{label:(0,T.__)("Drag & Drop"),value:"visual"},{label:(0,T.__)("Edit as HTML"),value:"text"}],Sa=function(){const[e]=U("meta"),t=Lr(!1),n=(0,P.useSelect)((e=>{var t;return null!==(t=e(Ee.store).get("core","editorMode"))&&void 0!==t?t:"visual"}),[]),{switchEditorMode:r}=(0,P.useDispatch)(A.store);return t&&"visual"===e?.campaign_data?.email_type?(0,_.createElement)(C.MenuGroup,{label:(0,T.__)("Mode")},(0,_.createElement)(C.MenuItemsChoice,{choices:ka,value:n,onSelect:r})):null},{Fill:Ca,Slot:Ta}=(0,C.createSlotFill)("ToolsMoreMenuGroup");Ca.Slot=({fillProps:e})=>(0,_.createElement)(Ta,{fillProps:e},(e=>e.length>0&&(0,_.createElement)(C.MenuGroup,{label:(0,T.__)("Tools")},e)));const Pa=Ca,Ma=function(){const{openModal:e}=Yr("noptin/email-editor/mergeTags"),{emailType:t}=J();return(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.MenuGroup,{label:(0,T._x)("View","noun")},(0,_.createElement)(Ee.PreferenceToggleMenuItem,{scope:it.name,name:"fullscreenMode",label:(0,T.__)("Fullscreen mode"),info:(0,T.__)("Show and hide admin UI"),messageActivated:(0,T.__)("Fullscreen mode activated"),messageDeactivated:(0,T.__)("Fullscreen mode deactivated")}),"visual"===t&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(Ee.PreferenceToggleMenuItem,{scope:"core",name:"focusMode",label:(0,T.__)("Spotlight mode"),info:(0,T.__)("Focus on one block at a time"),messageActivated:(0,T.__)("Spotlight mode activated."),messageDeactivated:(0,T.__)("Spotlight mode deactivated.")}),(0,_.createElement)(Ee.PreferenceToggleMenuItem,{scope:"core",name:"fixedToolbar",label:(0,T.__)("Top toolbar"),info:(0,T.__)("Access all block and document tools in a single place"),messageActivated:(0,T.__)("Top toolbar activated."),messageDeactivated:(0,T.__)("Top toolbar deactivated.")})),(0,_.createElement)(C.MenuItem,{onClick:e,info:(0,T.__)("View available merge tags","newsletter-optin-box"),icon:"shortcode"},(0,T.__)("Merge tags","newsletter-optin-box"))))},Aa=()=>(0,_.createElement)(C.DropdownMenu,{className:"interface-more-menu-dropdown",icon:Ea,label:(0,T.__)("Options"),popoverProps:{placement:"bottom-end",className:"interface-more-menu-dropdown__content"},toggleProps:{tooltipPosition:"bottom",showTooltip:!0,size:"compact"}},(({onClose:e})=>(0,_.createElement)(_.Fragment,null,(0,_.createElement)(mt,{breakpoint:"large",operator:"<"},(0,_.createElement)(fe.Slot,{scope:N})),(0,_.createElement)(mt,{breakpoint:"medium"},(0,_.createElement)(Ma,null)),(0,_.createElement)(wa,null),(0,_.createElement)(Sa,null),(0,_.createElement)(ye.Slot,{name:`${N}/plugin-more-menu`,label:(0,T.__)("Plugins"),as:C.MenuGroup,fillProps:{onClick:e}}),(0,_.createElement)(Pa.Slot,{fillProps:{onClose:e}})))),Na=window.wp.notices,Ia=({mergeTag:e})=>{const{createInfoNotice:t}=(0,P.useDispatch)(Na.store),n=(0,d.useCopyToClipboard)(`[[${e.example||e.smart_tag}]]`,(()=>{t((0,T.__)("Copied to clipboard."),{type:"snackbar"})}));let r=`[[${e.example||e.smart_tag}]]`;return r.length>50&&(r=r.slice(0,50)+"..."),(0,_.createElement)(C.__experimentalItem,{as:C.Button,label:"Click to copy merge tag",style:{overflow:"hidden"},ref:n,showTooltip:!0},(0,_.createElement)(C.__experimentalHStack,{alignment:"baseline"},(0,_.createElement)(C.__experimentalText,{as:C.FlexBlock,align:"left"},e.label||e.description),(0,_.createElement)(C.__experimentalText,{as:"kbd",weight:600,limit:50,ellipsizeMode:"auto",numberOfLines:1,align:"right",style:{background:"none",padding:0,maxWidth:420},"aria-label":e.description||e.label,truncate:!0,isBlock:!0},r)))},Ba=({mergeTags:e})=>(0,_.createElement)(C.__experimentalItemGroup,{role:"list",isSeparated:!0,isBordered:!0},e.map(((e,t)=>(0,_.createElement)(Ia,{mergeTag:e,key:t})))),Fa=({title:e,mergeTags:t})=>(0,_.createElement)(C.__experimentalVStack,{as:"section",spacing:4},!!e&&(0,_.createElement)(C.__experimentalText,{as:"h2",size:15,weight:600},e),(0,_.createElement)(Ba,{mergeTags:t}));function Oa(){const e=ne(ae()),t=Object.keys(e).length;return(0,_.createElement)(C.__experimentalVStack,{spacing:8},Object.keys(e).map(((n,r)=>(0,_.createElement)(Fa,{title:t>1?n:void 0,mergeTags:e[n],key:r}))))}const La=()=>{const{isModalActive:e,closeModal:t}=Yr("noptin/email-editor/mergeTags");return(0,_.createElement)(_.Fragment,null,e&&(0,_.createElement)(C.Modal,{title:(0,T.__)("Merge tags","newsletter-optin-box"),onRequestClose:t},(0,_.createElement)(C.__experimentalVStack,{spacing:6},(0,_.createElement)(C.Tip,null,(0,T.__)("Merge tags are special placeholders that allow you to personalize your emails. Here are some of the available merge tags:","newsletter-optin-box")),(0,_.createElement)(Oa,null))))},ja=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"})}),Ra=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})}),Da=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})}),za=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})}),Va=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})});function $a({isVisual:e}){const t=(0,P.useSelect)((e=>e(it).getPreviewDeviceType()),[]),{setPreviewDeviceType:n}=(0,P.useDispatch)(it),r={"aria-label":(0,T.__)("View options")},a={mobile:ja,tablet:Ra,desktop:Da};return(0,_.createElement)(C.DropdownMenu,{className:"editor-preview-dropdown",popoverProps:{placement:"bottom-end"},toggleProps:{className:"editor-preview-dropdown__toggle",size:"compact",showTooltip:!0},menuProps:r,icon:a[t.toLowerCase()],label:(0,T.__)("View")},(({onClose:r})=>(0,_.createElement)(_.Fragment,null,e&&(0,_.createElement)(C.MenuGroup,null,(0,_.createElement)(C.MenuItem,{onClick:()=>n("Desktop"),icon:"Desktop"===t&&za},(0,T.__)("Desktop")),(0,_.createElement)(C.MenuItem,{onClick:()=>n("Tablet"),icon:"Tablet"===t&&za},(0,T.__)("Tablet")),(0,_.createElement)(C.MenuItem,{onClick:()=>n("Mobile"),icon:"Mobile"===t&&za},(0,T.__)("Mobile"))),(0,_.createElement)(C.MenuGroup,null,(0,_.createElement)(A.PostPreviewButton,{className:"editor-preview-dropdown__button-external",role:"menuitem",textContent:(0,_.createElement)(_.Fragment,null,(0,T.__)("Preview in new tab"),(0,_.createElement)(C.Icon,{icon:Va})),onPreview:r})))))}const Ha=()=>{const[e,t]=U("title"),n=K(),{emailType:r}=J();return(0,_.createElement)(_.Fragment,null,"normal"===r&&(0,_.createElement)(Xr,{settingKey:"template",setting:{el:"select",label:(0,T.__)("Template","newsletter-optin-box"),options:j,description:(0,T.__)("Choose the template you want to use.","newsletter-optin-box"),sanitize:Q}}),(0,_.createElement)(qr,{settingKey:"title",setting:{el:"input",label:(0,T.__)("Campaign Name","newsletter-optin-box"),description:(0,T.__)("For your reference only.","newsletter-optin-box"),placeholder:(0,T.__)("Example: Black Friday Sale","newsletter-optin-box")},saved:{title:e},setAttributes:e=>t(e.title||""),disableMergeTags:!0}),("visual"===r||"normal"===r)&&(0,_.createElement)(Xr,{settingKey:"preview_text",setting:{el:"input",type:"text",label:(0,T.__)("Preview Text","newsletter-optin-box"),description:(0,T.__)("This is the text that appears in the inbox when the email is received.","newsletter-optin-box"),placeholder:(0,T.__)("Example: Save up to 50%","newsletter-optin-box")}}),n?.extra_settings&&(0,_.createElement)(_.Fragment,null,Object.keys(n.extra_settings).map((e=>(0,_.createElement)(Xr,{key:e,settingKey:e,setting:n.extra_settings[e]})))),(0,_.createElement)(C.Slot,{name:`${N}/editor-settings__main`}))},Ga=()=>{const{emailType:e}=J();return(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Email Settings","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,{spacing:4},(0,_.createElement)(Xr,{settingKey:"email_type",setting:{el:"select",label:(0,T.__)("Editor","newsletter-optin-box"),options:L,description:O[e]?.description||(0,T.__)("Choose the type of email you want to create.","newsletter-optin-box"),sanitize:Q}}),(0,_.createElement)(Ha,null)))},Ua=(0,_.forwardRef)((({className:e,label:t,children:n},r)=>{const a={};return t||(a.width="100%"),(0,_.createElement)(C.__experimentalHStack,{className:h("editor-post-panel__row",e),ref:r},t&&(0,_.createElement)("div",{className:"editor-post-panel__row-label"},t),(0,_.createElement)("div",{className:"editor-post-panel__row-control",style:a},n))}));function Ka({popoverAnchor:e}){const t=(0,_.useMemo)((()=>({anchor:e,"aria-label":(0,T.__)("Change publish date"),placement:"bottom-end"})),[e]),n=A.usePostScheduleLabel?(0,A.usePostScheduleLabel)():"";return(0,_.createElement)(A.PostScheduleCheck,null,(0,_.createElement)(C.Dropdown,{popoverProps:t,focusOnMount:!0,className:"editor-post-schedule__panel-dropdown",contentClassName:"editor-post-schedule__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,_.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:n,showTooltip:!0,"aria-expanded":t},(0,_.createElement)(A.PostScheduleLabel,null)),renderContent:({onClose:e})=>(0,_.createElement)(A.PostSchedule,{onClose:e})}))}function Wa(){const[e,t]=(0,_.useState)(null),n="newsletter"===W();return(0,_.createElement)(A.PostScheduleCheck,null,(0,_.createElement)(Ua,{label:n?(0,T.__)("Send"):(0,T.__)("Publish"),ref:t},(0,_.createElement)(Ka,{popoverAnchor:e})))}function Ya(){const[e,t]=(0,_.useState)(null),{isModalActive:n,closeModal:r}=Yr("noptin/email-editor/publish"),a="newsletter"===W(),o=(0,P.useSelect)((e=>e(A.store).isCurrentPostScheduled()&&e(A.store).isEditedPostBeingScheduled()),[]);return n?(0,_.createElement)(C.Modal,{onRequestClose:r,size:"small",title:a?(0,T.__)("Send Newsletter","newsletter-optin-box"):(0,T.__)("Publish Email","newsletter-optin-box")},(0,_.createElement)(C.__experimentalVStack,{spacing:4},a&&(0,_.createElement)(C.Tip,null,!o&&(0,T.__)("You are about to send this newsletter.","newsletter-optin-box"),o&&(0,T.__)("You are about to schedule this newsletter.","newsletter-optin-box")," ",(0,T.__)("Please make sure you have tested it and it is ready to be sent.","newsletter-optin-box")),(0,_.createElement)(C.__experimentalHStack,{ref:t},(0,_.createElement)("strong",null,a?(0,T.__)("Send"):(0,T.__)("Publish")),(0,_.createElement)(Ka,{popoverAnchor:e})),(0,_.createElement)(Xr,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,T.__)("Email Subject","newsletter-optin-box"),placeholder:(0,T.__)("Enter email subject","newsletter-optin-box")}}),(0,_.createElement)(Ha,null),(0,_.createElement)(C.__experimentalHStack,{justify:"flex-start"},(0,_.createElement)(A.PostPublishButton,null),(0,_.createElement)(A.PostSavedState,null)))):null}function qa(){const{toggleModal:e,isModalActive:t}=Yr("noptin/email-editor/publish"),n=(0,P.useSelect)((e=>{var t;const n=e(A.store).isCurrentPostPublished(),r=e(A.store).getPostEdits()?.status,a=e(A.store).getEditedPostAttribute("status"),o=(e(A.store).isCurrentPostScheduled(),e(A.store).isEditedPostBeingScheduled(),null!==(t=e(A.store).getCurrentPost()?._links?.["wp:action-publish"])&&void 0!==t&&t);return!(n||r&&!["future","publish"].includes(a)||!o)}),[]);return(0,_.createElement)(_.Fragment,null,(0,_.createElement)(A.PostPublishButton,{isOpen:t,isToggle:n,onToggle:e}),n&&(0,_.createElement)(Ya,null))}const Xa=function({hideActions:e}){const{emailType:t}=J(),{isModalActive:n,openModal:r}=Yr("noptin/email-editor/mergeTags"),a="visual"===t;return(0,_.createElement)(C.__experimentalHStack,{style:{maxWidth:"100vw",height:60}},(0,_.createElement)(C.Button,{className:"edit-post-fullscreen-mode-close",icon:ga,href:I.back,label:(0,T.__)("Back"),showTooltip:!0}),(0,_.createElement)(va,{hideActions:e,contentType:t}),(0,_.createElement)(C.__experimentalHStack,{justify:"flex-end",wrap:!0},(0,_.createElement)(mt,{breakpoint:"medium",operator:"<"},(0,_.createElement)(A.PostPreviewButton,{className:"edit-post-header__post-preview-button"})),(0,_.createElement)(A.PostSavedState,null),(0,_.createElement)(qa,null),(0,_.createElement)(mt,{breakpoint:"large"},(0,_.createElement)($a,{isVisual:a}),(0,_.createElement)(fe.Slot,{scope:N}),(0,_.createElement)(C.Button,{isPressed:n,"aria-expanded":n,onClick:r,label:(0,T.__)("View available merge tags","newsletter-optin-box"),icon:"shortcode",showTooltip:!0,size:"compact"})),(0,_.createElement)(Aa,null)),(0,_.createElement)(La,null))};function Za(){return(0,_.createElement)("div",{className:"edit-post-layout__footer"},(0,_.createElement)(na.BlockBreadcrumb,{rootLabelText:(0,T.__)("Email")}))}const Qa=(0,b.jsx)(_t.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z"})}),Ja=(0,b.jsx)(_t.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z"})}),eo={color:(0,T.__)("Text"),link_color:(0,T.__)("Link"),background_color:(0,T.__)("Background"),content_background:(0,T.__)("Content Background"),footer_text_color:(0,T.__)("Footer text color")},to=()=>{const e=Wr(),[t,n]=U("meta"),{templateSupports:r}=J(),a=(0,_.useMemo)((()=>(0,S.compact)(Object.entries(eo).map((([e,a])=>r(e)?{value:t?.campaign_data?.[e]||"",onChange:r=>n({...t||{},campaign_data:{...t?.campaign_data||{},[e]:r}}),label:a}:null)))),[r,t,n]);return(0,_.createElement)(_.Fragment,null,a.length>0&&(0,_.createElement)(na.PanelColorSettings,{__experimentalIsRenderedInSidebar:!0,enableAlpha:!1,showTitle:!0,disableCustomColors:!1,colors:e,title:(0,T.__)("Colors"),colorSettings:a}))},no=window.wp.blob,ro=window.wp.dom,ao=[{a11yLabel:"Pixels (px)",label:"px",step:1,value:"px"},{a11yLabel:"Rem (rem)",label:"rem",step:.5,value:"rem"},{a11yLabel:"Em (em)",label:"em",step:.5,value:"em"}];function oo({label:e,filename:t,url:n}){const r=e||(0,v.getFilename)(n);return(0,b.jsx)(C.__experimentalItemGroup,{as:"span",children:(0,b.jsxs)(C.__experimentalHStack,{justify:"flex-start",as:"span",children:[(0,b.jsx)("span",{className:h("block-editor-hooks__background__inspector-image-indicator-wrapper",{"has-image":n}),"aria-hidden":!0,children:n&&(0,b.jsx)("span",{className:"block-editor-hooks__background__inspector-image-indicator",style:{backgroundImage:`url(${n})`}})}),(0,b.jsxs)(C.FlexItem,{as:"span",children:[(0,b.jsx)(C.__experimentalTruncate,{numberOfLines:1,className:"block-editor-hooks__background__inspector-media-replace-title",children:r}),(0,b.jsx)(C.VisuallyHidden,{as:"span",children:t?(0,T.sprintf)(/* translators: %s: file name */ /* translators: %s: file name */ (0,T.__)("Selected image: %s"),t):(0,T.__)("No image selected")})]})]})})}function lo({background:e,setBackground:t}){const n=(0,P.useSelect)((e=>e(na.store).getSettings().mediaUpload),[]),{id:r,title:a,url:o}=e||{},l=(0,_.useRef)(),{createErrorNotice:i}=(0,P.useDispatch)(Na.store),s=e=>{i(e,{type:"snackbar"})},c=e=>{if(!e||!e.url)return t({});(0,no.isBlobURL)(e.url)||(e.media_type&&"image"!==e.media_type||!e.media_type&&e.type&&"image"!==e.type?s((0,T.__)("Only images can be used as a background image.")):t({url:e.url,id:e.id,source:"file",title:e.title||void 0}))};return(0,b.jsxs)("div",{className:"block-editor-hooks__background__inspector-media-replace-container",ref:l,children:[(0,b.jsx)(na.MediaReplaceFlow,{mediaId:r,mediaURL:o,allowedTypes:["image"],accept:"image/*",onSelect:c,name:(0,b.jsx)(oo,{label:(0,T.__)("Background image"),filename:a,url:o}),variant:"secondary",children:o&&(0,b.jsx)(C.MenuItem,{onClick:()=>{const[e]=ro.focus.tabbable.find(l.current);e?.focus(),e?.click(),t({})},children:(0,T.__)("Reset ")})}),(0,b.jsx)(C.DropZone,{onFilesDrop:e=>{n({allowedTypes:["image"],filesList:e,onFileChange([e]){(0,no.isBlobURL)(e?.url)||c(e)},onError:s})},label:(0,T.__)("Drop to upload")})]})}const io=()=>{const[e,t]=U("meta"),[n,r]=ee("width",e,t),[a,o]=ee("background_image",e,t),{templateSupports:l}=J();return l("custom_css")||l("width")||l("background_image")?(0,b.jsx)(C.PanelBody,{title:(0,T.__)("Design","newsletter-optin-box"),initialOpen:!1,children:(0,b.jsxs)(C.__experimentalVStack,{spacing:4,children:[l("width")&&(0,b.jsx)(C.__experimentalUnitControl,{label:(0,T.__)("Width","newsletter-optin-box"),value:n||"600px",onChange:r,min:100,max:1e3,units:ao,help:(0,T.__)("The width of your email's content area.","newsletter-optin-box")}),l("background_image")&&(0,b.jsx)(lo,{background:a||{},setBackground:o}),l("custom_css")&&(0,b.jsx)(Xr,{settingKey:"custom_css",setting:{el:"textarea",label:(0,T.__)("Custom CSS","newsletter-optin-box"),description:(0,T.__)("Add custom CSS to your email. You can also use this field to import custom fonts.","newsletter-optin-box")}}),(0,b.jsx)(C.Slot,{name:`${N}/editor-settings__design`})]})}):null},so=()=>{const[e,t]=U("meta"),[n,r]=ee("font_family",e,t),[a,o]=ee("font_size",e,t),[l,i]=ee("font_style",e,t),[s,c]=ee("font_weight",e,t),[u,p]=ee("line_height",e,t),{templateSupports:m}=J(),d=["font_family","font_size","font_style","font_weight","line_height"].some((e=>m(e))),g=(0,_.useCallback)((({fontStyle:e,fontWeight:t})=>{i(e),c(t)}),[c,i]),f={fontStyle:l,fontWeight:s};return d?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Typography","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,{spacing:4},m("font_family")&&(0,_.createElement)(pt,{value:n||"",onChange:r}),m("font_size")&&(0,_.createElement)(na.FontSizePicker,{__nextHasNoMarginBottom:!0,value:a||14,fallbackFontSize:14,onChange:o,label:(0,T.__)("Font size","newsletter-optin-box"),disableCustomFontSizes:!1}),(m("font_style")||m("font_weight"))&&(0,_.createElement)(na.__experimentalFontAppearanceControl,{__nextHasNoMarginBottom:!0,hasFontStyles:m("font_style"),hasFontWeights:m("font_weight"),value:f,onChange:g}),m("line_height")&&(0,_.createElement)(na.LineHeightControl,{__nextHasNoMarginBottom:!0,value:u||"1.7",onChange:p,label:(0,T.__)("Line height","newsletter-optin-box"),__unstableInputWidth:"100%"}),(0,_.createElement)(C.Slot,{name:`${N}/editor-settings__typography`}))):null},co=()=>{const[e,t]=Or({heading:(0,T.__)("Attach Files","newsletter-optin-box"),helpText:(0,T.__)("The add-ons pack allows you to attach images, videos, PDFs or other file types to this email.","newsletter-optin-box"),needsAddonsPack:!1,slug:"attachments"}),[n,r]=U("meta"),[a,o]=ee("attachments",n,r),l=a||[],i=(0,_.useCallback)((()=>{o([...l,""])}),[l,o]),s=(0,_.useCallback)((e=>{o(l.filter(((t,n)=>n!==e)))}),[l,o]),c=(0,_.useCallback)(((e,t)=>{o(l.map(((n,r)=>r===e?t:n)))}),[l,o]);return(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Email Attachments","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,_.createElement)(_.Fragment,null,l.map(((e,t)=>(0,_.createElement)(C.__experimentalInputControl,{label:(0,T.__)("Enter file path or URL","newsletter-optin-box"),value:e,onChange:e=>c(t,e),isPressEnterToChange:!0,hideLabelFromVision:!0,placeholder:(0,T.__)("Enter file path or URL","newsletter-optin-box"),key:t,prefix:(0,_.createElement)(_.Fragment,null,(0,_.createElement)(m.MediaUpload,{onSelect:e=>{if(!e?.length)return;const n=e.map((e=>e.url));o([...l.slice(0,t),...n,...l.slice(t+1)])},multiple:!0,render:({open:e})=>(0,_.createElement)(C.Button,{variant:"tertiary",onClick:e,icon:"upload",label:(0,T.__)("Upload","newsletter-optin-box"),showTooltip:!0})})),suffix:(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.Button,{isDestructive:!0,variant:"tertiary",onClick:()=>s(t),icon:"trash",label:(0,T.__)("Remove","newsletter-optin-box"),showTooltip:!0}))}))),(0,_.createElement)(C.Button,{variant:"primary",onClick:i,style:{justifyContent:"center"}},(0,T.__)("Add Attachment","newsletter-optin-box"),(0,_.createElement)(C.Icon,{icon:"plus"})),(0,_.createElement)("p",{className:"description"},(0,T.__)("You can only attach files that are hosted on your server.","newsletter-optin-box")))))};function uo(){return(0,_.createElement)(A.PostTrashCheck,null,(0,_.createElement)(A.PostTrash,null))}const po=function(){return(0,_.createElement)(A.PostPendingStatusCheck,null,(0,_.createElement)(Ua,null,(0,_.createElement)(A.PostPendingStatus,null)))},{Fill:mo,Slot:_o}=(0,C.createSlotFill)("PluginPostStatusInfo"),go=({children:e,className:t})=>(0,_.createElement)(mo,null,(0,_.createElement)(C.PanelRow,{className:t},e));go.Slot=_o;const fo=go,ho=({onClose:e})=>{const t=H(),[n,r]=(0,_.useState)(I.user?.email||""),[a,o]=(0,_.useState)(!1),[l,i]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),u=(0,P.useSelect)((e=>e(A.store).isEditedPostDirty()),[]);return(0,_.useEffect)((()=>{l&&i(null),s&&c(null)}),[n]),(0,_.useEffect)((()=>{a&&(i(null),c(null),w()({path:`/wp/v2/noptin-campaign/${t}/send-test`,method:"POST",data:{email:n}}).then((e=>{c(e.message)})).catch((e=>{i(e.message),console.log(e)})).finally((()=>{o(!1)})))}),[a]),u?(0,_.createElement)(C.Notice,{status:"warning",isDismissible:!1,className:"noptin-test-email-form__notice",actions:[{label:(0,T.__)("Go Back"),onClick:e}]},(0,T.__)("Please save your changes before sending a test email.")):(0,_.createElement)(C.__experimentalVStack,{className:"noptin-test-email-form"},(0,_.createElement)(C.TextControl,{label:(0,T.__)("Email address"),type:"email",placeholder:(0,T.__)("Enter email address"),help:(0,T.__)("Enter the email address where you want to send the test email."),value:n,onChange:r}),(0,_.createElement)(C.Button,{variant:"primary",onClick:()=>o(!0),disabled:a||!n||!(0,v.isEmail)(n),isPressed:a,isBusy:a},!a&&(0,T.__)("Send test email"),a&&(0,T.__)("Sending..."),!a&&(0,_.createElement)(C.Icon,{icon:"arrow-right-alt"}),a&&(0,_.createElement)(C.Spinner,null)),(0,_.createElement)(C.Button,{variant:"secondary",onClick:e},s?(0,T.__)("Close"):(0,T.__)("Cancel")),l&&(0,_.createElement)(C.Notice,{status:"error",className:"noptin-test-email-form__notice",onDismiss:()=>i(null)},l),s&&(0,_.createElement)(C.Notice,{status:"success",className:"noptin-test-email-form__notice",onDismiss:()=>c(null)},s))};function bo(){const[e,t]=(0,_.useState)(null),n=(0,_.useMemo)((()=>({anchor:e,"aria-label":(0,T.__)("Send a test email"),placement:"bottom-end"})),[e]);return(0,_.createElement)(Ua,{label:(0,T.__)("Test"),ref:t},(0,_.createElement)(C.Dropdown,{popoverProps:n,focusOnMount:!0,className:"editor-post-test__panel-dropdown",contentClassName:"editor-post-test__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,_.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:(0,T.__)("Send a test email"),showTooltip:!0,"aria-expanded":t},(0,T.__)("Send a test email")),renderContent:({onClose:e})=>(0,_.createElement)(ho,{onClose:e})}))}function yo(){return(0,_.createElement)(C.PanelBody,{className:"edit-post-post-status",title:(0,T.__)("Summary"),initialOpen:!0},(0,_.createElement)(fo.Slot,null,(e=>(0,_.createElement)(C.__experimentalVStack,null,(0,_.createElement)(Wa,null),(0,_.createElement)(bo,null),e,(0,_.createElement)(po,null),(0,_.createElement)(C.__experimentalHStack,{style:{marginTop:"16px"},spacing:4,wrap:!0},(0,_.createElement)(A.PostSwitchToDraftButton,null),(0,_.createElement)(uo,null))))))}const xo=[{label:(0,T.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,T.__)("Minutes","newsletter-optin-box"),value:"minutes"},{label:(0,T.__)("Hours","newsletter-optin-box"),value:"hours"},{label:(0,T.__)("Days","newsletter-optin-box"),value:"days"},{label:(0,T.__)("Weeks","newsletter-optin-box"),value:"weeks"},{label:(0,T.__)("Months","newsletter-optin-box"),value:"months"},{label:(0,T.__)("Years","newsletter-optin-box"),value:"years"}],vo=[{label:(0,T.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,T.__)("Minute","newsletter-optin-box"),value:"minutes"},{label:(0,T.__)("Hour","newsletter-optin-box"),value:"hours"},{label:(0,T.__)("Day","newsletter-optin-box"),value:"days"},{label:(0,T.__)("Week","newsletter-optin-box"),value:"weeks"},{label:(0,T.__)("Month","newsletter-optin-box"),value:"months"},{label:(0,T.__)("Year","newsletter-optin-box"),value:"years"}],Eo=()=>{const e=K(),[t,n]=Or({heading:(0,T.__)("Delay sending this email","newsletter-optin-box"),helpText:(0,T.__)("Premium plans allow you to delay (schedule) this email for a given number of minutes, hours, or days.","newsletter-optin-box"),needsAddonsPack:!1,slug:"timing"}),[r,a]=U("meta"),[o,l]=ee("when_to_run",r,a),[i,s]=ee("sends_after",r,a),[c,u]=ee("sends_after_unit",r,a),p="delayed"===o,m=(0,_.useCallback)((()=>{l(p?"immediately":"delayed")}),[p,l]);return e?.supports_timing?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Timing","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,null,!t&&n,t&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.ToggleControl,{label:(0,T.__)("Delay sending this email","newsletter-optin-box"),checked:p,onChange:m,__nextHasNoMarginBottom:!0}),p&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(C.__experimentalInputControl,{type:"number",label:(0,T.__)("Send after","newsletter-optin-box"),placeholder:"1",value:i||"",onChange:s,min:1}),(0,_.createElement)(C.SelectControl,{label:(0,T.__)("Unit","newsletter-optin-box"),hideLabelFromVision:!0,value:c||"",onChange:e=>u(e),options:1===parseInt(i)?vo:xo}),(0,_.createElement)("p",{className:"description"},e?.email_type?.timing_help_text||(0,T.__)("This email will be sent after the specified time has elapsed.","newsletter-optin-box")))))):null},wo=Object.entries(B.senders).map((([e,t])=>({label:!1===t.is_installed?`${t.label} - Premium`:t.label,value:e,disabled:!1===t.is_installed}))),ko=({recipient:e,onRemove:t})=>e?(0,_.createElement)(C.__experimentalHStack,{spacing:1,style:{border:"1px solid #e0e0e0",padding:4},wrap:!1},(0,_.createElement)("img",{src:e.avatar,style:{borderRadius:"9999px"},width:32,alt:e.name}),(0,_.createElement)(C.__experimentalText,null,e.name?e.email:`${e.name} <${e.email}>`),e.url&&(0,_.createElement)(C.Button,{href:e.url,size:"compact",target:"_blank"},(0,_.createElement)(C.Icon,{icon:"external"})),(0,_.createElement)(C.Button,{isDestructive:!0,size:"compact",onClick:t},(0,_.createElement)(C.Icon,{icon:"no-alt"}))):null,So=({recipientData:e,recipientIds:t,setRecipientIds:n})=>(0,_.createElement)(_.Fragment,null,t.map((r=>(0,_.createElement)(ko,{key:r,recipient:e.find((e=>e.id===r)),onRemove:()=>n(t.filter((e=>e!==r)))})))),Co=({sender:e})=>{const{fields:t,key:n,upsell:r,disableMergeTags:a=!0}=B.senders?.[e]?.settings||{},[o,l]=Or({heading:(0,T.sprintf)((0,T.__)("Filter %s","newsletter-optin-box"),B.senders?.[e]?.label||(0,T.__)("Recipients","newsletter-optin-box")),helpText:r?.message||(0,T.__)("A premium plan allows you to filter recipients by custom fields etc.","newsletter-optin-box"),needsAddonsPack:!1,slug:"filter-subscribers"});if(!t||Array.isArray(t)||0===Object.keys(t).length)return null;const i="manual_recipients"===e||o;return(0,_.createElement)(_.Fragment,null,!i&&l,i&&(0,_.createElement)(_.Fragment,null,Object.entries(t).map((([e,t])=>(0,_.createElement)(Xr,{key:e,settingKey:e,setting:t,prop:n,disableMergeTags:a})))))},To=()=>{const e=K(),[t,n]=U("meta"),[r,a]=ee("manual_recipients_ids",t,n),o=Array.isArray(r)&&r.length>0;return e.supports_recipients?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Send To","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,{spacing:4},o?(0,_.createElement)(So,{recipientData:e.manual_recipients,recipientIds:r,setRecipientIds:a}):(0,_.createElement)(_.Fragment,null,(0,_.createElement)(Xr,{settingKey:"email_sender",setting:{el:"select",label:(0,T.__)("Send To","newsletter-optin-box"),options:wo,customAttributes:{allowReset:!1,hideLabelFromVision:!0}}}),(0,_.createElement)(Co,{sender:t?.campaign_data?.email_sender})))):null},Po=()=>{const e=K(),[t,n]=U("noptin_automation_rule"),r=e=>{n({...t,saved:{...t.saved,...e}})};return e?.is_automation_rule?t.error?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.Notice,{status:"error",isDismissible:!1},t.error)):t.settings?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,null,Object.keys(t.settings).map((e=>(0,_.createElement)(qr,{key:e,settingKey:e,saved:t.saved,setAttributes:r,setting:t.settings[e]}))))):null:null},Mo="post_notifications",Ao="post_digest",No=({isPostDigest:e})=>{const t=Ur();if(!Array.isArray(t)||!t.length)return null;const n={el:"combobox",label:(0,T.__)("Post type","newsletter-optin-box"),placeholder:(0,T.__)("Select a post type","newsletter-optin-box"),description:e?(0,_.createElement)(_.Fragment,null,(0,T.__)("The [[post_digest]] merge tag will display this post type if you do not set a post type in the merge tag.","newsletter-optin-box"),(0,_.createElement)("br",null),(0,_.createElement)(C.Button,{href:"https://noptin.com/guide/sending-emails/new-post-notifications/#set-digest-post-types",target:"_blank",variant:"link"},(0,T.__)("Learn more","newsletter-optin-box"))):(0,T.__)("New post notifications will only send for this post type.","newsletter-optin-box"),options:t.map((({slug:e,name:t})=>({value:e,label:t})))};return(0,_.createElement)(Xr,{settingKey:"noptin-ap-post-type",setting:n})},Io={"-1":(0,T.__)("Do not filter by tags, categories, etc","newsletter-optin-box"),include:(0,T.__)("Only send for some tags, categories, etc","newsletter-optin-box"),exclude:(0,T.__)("Do not send for some tags, categories, etc","newsletter-optin-box")},Bo=({postType:e})=>{const[t,n]=U("meta"),{termsByTaxonomy:r}=K(),a=t?.campaign_data||{},o=a["noptin-ap-terms-action"]||"-1",l=Kr(e),i=(0,_.useCallback)((e=>{const r=t||{};n({...r,campaign_data:{...r.campaign_data||{},...e}})}),[t,n]);return(0,_.useEffect)((()=>{""!==a["noptin-ap-terms"]&&"object"==typeof r&&i({"noptin-ap-terms":"",tax_query:{...a.tax_query||{},...r}})}),[r,i]),l&&0!==l.length?(0,_.createElement)(_.Fragment,null,(0,_.createElement)(Xr,{settingKey:"noptin-ap-terms-action",setting:{el:"select",options:Io,label:(0,T.__)("Filter by terms","newsletter-optin-box"),description:(0,T.__)("Optional. Select how to filter posts by terms.","newsletter-optin-box")}}),["include","exclude"].includes(o)&&(0,_.createElement)(nl,{postType:e,attributes:a,setAttributes:i})):null},Fo=()=>{const[e,t]=Or({heading:(0,T.__)("Set post type","newsletter-optin-box"),helpText:(0,_.createElement)(_.Fragment,null,(0,T.__)("This email will only send for blog posts.","newsletter-optin-box"),(0,_.createElement)("br",null),(0,T.__)("The addons pack allows you to send notifications for products and other post types or limit notifications to certain categories, tags, and authors.","newsletter-optin-box")),needsAddonsPack:!0,slug:"filter-posts"}),[n]=U("meta"),r=n?.campaign_type,a=n?.automation_type,o=n?.campaign_data?.["noptin-ap-post-type"];return"automation"===r&&[Ao,Mo].includes(a)?(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Post settings","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(No,{isPostDigest:Ao===a}),Mo===a&&(0,_.createElement)(_.Fragment,null,(0,_.createElement)(Xr,{settingKey:"noptin-ap-authors",setting:{el:"input",type:"text",label:(0,T.__)("Authors","newsletter-optin-box"),placeholder:(0,T.__)("Send for all authors","newsletter-optin-box"),description:(0,T.__)("Enter a comma-separated list of author IDs or leave blank to send for all authors.","newsletter-optin-box")},disableMergeTags:!0}),I?.languages&&(0,_.createElement)(Xr,{settingKey:"noptin-ap-language",setting:{el:"combobox",label:(0,T.__)("Language","newsletter-optin-box"),placeholder:(0,T.__)("All languages","newsletter-optin-box"),options:I.languages,description:(0,T.__)("Optional. Send for posts in the selected language only.","newsletter-optin-box")}})),o&&(0,_.createElement)(Bo,{postType:o})))):null},Oo=()=>(0,_.createElement)(C.PanelBody,{title:(0,T.__)("Send From","newsletter-optin-box"),initialOpen:!1},(0,_.createElement)(C.__experimentalVStack,{spacing:4},(0,_.createElement)(Xr,{settingKey:"from_name",setting:{el:"input",type:"text",label:(0,T.__)('"From" Name',"newsletter-optin-box"),description:(0,T.__)("Leave blank to use the default name.","newsletter-optin-box"),placeholder:B.from_name}}),(0,_.createElement)(Xr,{settingKey:"from_email",setting:{el:"input",type:"text",label:(0,T.__)('"From" Email',"newsletter-optin-box"),placeholder:B.from_email}}),(0,_.createElement)(Xr,{settingKey:"reply_to",setting:{el:"input",type:"text",label:(0,T.__)("Reply To","newsletter-optin-box"),description:(0,T.__)("Leave blank to use the default reply email.","newsletter-optin-box"),placeholder:B.reply_to}})));function Lo(){return(0,_.createElement)(_.Fragment,null,(0,_.createElement)(yo,null),(0,_.createElement)(Ga,null),(0,_.createElement)(Fo,null),(0,_.createElement)(Po,null),(0,_.createElement)(Oo,null),(0,_.createElement)(To,null),(0,_.createElement)(Eo,null),(0,_.createElement)(co,null),(0,_.createElement)(so,null),(0,_.createElement)(io,null),(0,_.createElement)(to,null))}const jo=(0,b.jsx)(_t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,b.jsx)(_t.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})});function Ro({as:e=C.Button,name:t,...n}){const r=e,a=(0,P.useSelect)((e=>e(it).getCurrentSidebar()===t),[t]),{setCurrentSidebar:o}=(0,P.useDispatch)(it);return(0,_.createElement)(r,{"aria-controls":t.replace("/",":"),onClick:()=>{o(a?null:t)},...n})}const Do=({children:e,className:t,toggleButtonProps:n})=>{const r=(0,b.jsx)(Ro,{icon:jo,...n});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"components-panel__header interface-complementary-area-header__small",children:r}),(0,b.jsxs)("div",{className:h("components-panel__header","interface-complementary-area-header",t),tabIndex:-1,children:[e,r]})]})},zo=`${N}/sidebar-area`;function Vo({children:e,className:t,id:n}){return(0,b.jsx)(C.Fill,{name:zo,children:(0,b.jsx)("div",{id:n,className:t,children:e})})}function $o({children:e,className:t,closeLabel:n=(0,T.__)("Close plugin"),name:r,header:a,headerClassName:o,icon:l,panelClassName:i,title:s}){const c=(0,P.useSelect)((e=>e(it).getCurrentSidebar()),[r])===r;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(fe,{scope:N,children:(0,b.jsx)(Ro,{name:r,isPressed:c,"aria-expanded":c,label:s,icon:l,showTooltip:!0,size:"compact"})}),c&&(0,b.jsxs)(Vo,{className:h("interface-complementary-area",t),id:r.replace("/",":"),children:[(0,b.jsx)(Do,{className:o,toggleButtonProps:{label:n,name:r},children:a}),(0,b.jsx)(C.Panel,{className:i,children:e})]})]})}$o.Slot=e=>(0,b.jsx)(C.Slot,{name:zo,...e});const Ho=$o;function Go(){const[e,t]=(0,_.useState)(D),{emailType:n}=J(),r=(0,_.useCallback)((()=>{t(R)}),[t]),a=(0,_.useCallback)((()=>{t(D)}),[t]),o=(0,P.useSelect)((e=>!!e(na.store).getSelectedBlock()),[]);(0,_.useEffect)((()=>{"visual"===n||e!==R?(o&&e===D&&t(R),o||e!==R||t(D)):t(D)}),[o,t,n]);const l=(0,_.useMemo)((()=>(0,S.compact)([{name:D,title:(0,T.__)("Settings"),onClick:a},"visual"===n&&{name:R,title:(0,T.__)("Block"),onClick:r}])),[a,r,n]);return(0,_.createElement)(Ho,{className:"edit-post-sidebar",header:(0,_.createElement)("ul",null,l.map((t=>(0,_.createElement)("li",{key:t.name},(0,_.createElement)(C.Button,{onClick:t.onClick,className:h("edit-post-sidebar__panel-tab",t.name.replace(/\//g,"__").toLowerCase(),{"is-active":e===t.name}),"aria-label":e===t.name?(0,T.sprintf)((0,T.__)("%s (selected)"),t.title):t.title,"data-label":t.title},t.title))))),headerClassName:"edit-post-sidebar__panel-tabs" diff --git a/includes/class-noptin-dynamic-content-tags.php b/includes/class-noptin-dynamic-content-tags.php index dbaec229..b49fc5ef 100644 --- a/includes/class-noptin-dynamic-content-tags.php +++ b/includes/class-noptin-dynamic-content-tags.php @@ -670,7 +670,13 @@ public function check_conditional_logic( $conditional_logic, $skip_tags = array( } // If the rule is met. - if ( noptin_is_conditional_logic_met( $current_value, $compare_value, $rule['condition'] ) ) { + $is_met = noptin_is_conditional_logic_met( $current_value, $compare_value, $rule['condition'] ); + + if ( ! $is_met ) { + noptin_error_log( 'Conditional logic rule not met: ' . json_encode( compact( 'current_value', 'compare_value', 'rule' ) ) ); + } + + if ( $is_met ) { // If we're using the "any" condition, we can stop here. if ( 'any' === $type ) { diff --git a/templates/email-templates/noptin-visual/styles.php b/templates/email-templates/noptin-visual/styles.php index 9402f522..98c642b6 100644 --- a/templates/email-templates/noptin-visual/styles.php +++ b/templates/email-templates/noptin-visual/styles.php @@ -123,6 +123,10 @@ vertical-align: bottom; } + table.noptin-image-block__wrapper div { + overflow: hidden; + } + table.noptin-button-block__wrapper { border-collapse: separate; width: 100%; diff --git a/vendor/hizzle/store/src/REST_Controller.php b/vendor/hizzle/store/src/REST_Controller.php index bb3fd216..c0b18618 100644 --- a/vendor/hizzle/store/src/REST_Controller.php +++ b/vendor/hizzle/store/src/REST_Controller.php @@ -557,6 +557,12 @@ public function get_items( $request ) { $items[] = $this->prepare_response_for_collection( $data ); } + $per_page = (int) $query->query_vars['per_page']; + $total = (int) $query->get_total(); + $paged = (int) $query->query_vars['page']; + + $max_pages = $total > 0 && $per_page > 1 ? ceil( $total / $per_page ) : 1; + $response = rest_ensure_response( apply_filters( $this->prefix_hook( 'get_items' ), @@ -570,7 +576,7 @@ public function get_items( $request ) { 'value' => $query->get_total(), ), ), - 'total' => $query->get_total(), + 'total' => $total, ), $query, $request, @@ -578,7 +584,42 @@ public function get_items( $request ) { ) ); - $response->header( 'X-WP-Total', $query->get_total() ); + /* + $response = rest_ensure_response( + apply_filters( + $this->prefix_hook( 'get_items' ), + $items, + $query, + $request, + $this + ) + ); + */ + + // Add headers. + $response->header( 'X-WP-Total', $total ); + $response->header( 'X-WP-TotalPages', $max_pages ); + + $request_params = $request->get_query_params(); + $collection_url = rest_url( $this->namespace . '/' . $this->rest_base ); + $base = add_query_arg( urlencode_deep( $request_params ), $collection_url ); + + if ( $paged > 1 ) { + $prev_page = $paged - 1; + + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + + $prev_link = add_query_arg( 'paged', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + + if ( $max_pages > $paged ) { + $next_page = $paged + 1; + $next_link = add_query_arg( 'paged', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } return $response; } @@ -594,8 +635,12 @@ public function get_items( $request ) { public function get_item( $request ) { $object = $this->get_object( $request ); + if ( is_wp_error( $object ) ) { + return $object; + } + if ( ! $object || ! $object->exists() ) { - return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) ); + return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) ); } $data = $this->prepare_item_for_response( $object, $request ); @@ -615,8 +660,12 @@ public function get_item( $request ) { public function get_item_overview( $request ) { $object = $this->get_object( $request ); + if ( is_wp_error( $object ) ) { + return $object; + } + if ( ! $object || ! $object->exists() ) { - return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) ); + return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) ); } return rest_ensure_response( array_values( $object->get_overview() ) ); @@ -634,8 +683,12 @@ public function get_item_overview( $request ) { public function remote_action( $request ) { $object = $this->get_object( $request ); + if ( is_wp_error( $object ) ) { + return $object; + } + if ( ! $object || ! $object->exists() ) { - return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) ); + return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) ); } $action = $request['action']; @@ -718,6 +771,10 @@ public function update_item( $request ) { $object = $this->get_object( $request ); + if ( is_wp_error( $object ) ) { + return $object; + } + if ( ! $object || ! $object->exists() ) { return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) ); } @@ -755,10 +812,16 @@ public function delete_item( $request ) { $object = $this->get_object( $request ); $force = isset( $request['force'] ) ? (bool) $request['force'] : false; - if ( $object->exists() ) { - $object->delete( $force ); + if ( is_wp_error( $object ) ) { + return $object; } + if ( empty( $object ) || ! $object->exists() ) { + return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) ); + } + + $object->delete( $force ); + return new \WP_REST_Response( true, 204 ); }